Mothership
Runtime과 자동화
Runtime은 앱이 선언한 프로필로 계획·도구 실행을 백그라운드에서 이어 가고, 위험한 도구 앞에서 사람의 승인을 기다려요. 자동화는 스케줄·이벤트·웹훅으로 같은 실행 경로를 불러요.
Runtime
앱의 manifest에 runtime_profiles를 선언해요. 실행은 영속 대기열에 들어가고 별도의 runtime_worker가 돌려서, 브라우저가 끊겨도 이어져요.
jsonc
"runtime_profiles": [{
"id": "review-loop",
"model_profile": "smart", // 계획을 세우는 AI 등급
"tool_set": ["document.classify"], // 도구로 쓸 기능(커넥터는 connector:<id>/<tool>)
"procedure": "react", // 또는 "plan-execute"
"skill_policy": {},
"system_instruction": "You review documents.",
"max_iterations": 8
}]
ts
const run = await ctx.api.runtime.start({ profile: "review-loop", input: { question: "보고서를 요약해 줘" } });
for await (const event of ctx.api.runtime.subscribe(run.runId, { transport: "sse" })) {
// run.*, planner.iteration.completed, tool.started|completed, job.linked, output.delta|completed
}
- 시작과 다시 시작은
202와queued상태를 돌려줘요. 이벤트는 순서 번호가 있어 끊긴 곳부터 다시 이어 받아요(폴링 기본, SSE 선택). - 사람의 판단:
risk_class: "high"도구는 언제나 승인을 기다려요. 입력 요청(decision: "submit"과 schema에 맞는input)과 동의(approve/deny)도 같은 방식이에요. 동의는 도구 권한을 더 주지 않아요. skill_policy:deny_tools,require_approval,max_tool_calls,allow_ask_user,allow_consent,interrupt_ttl_seconds. 모르는 항목은 거절해요.- 워커는 단계마다 회사, 구성원, claim, 릴리스, 프로필, 배포 자격을 다시 확인해요. 안전한 지점에서 죽으면 이어서 하고, 외부 도구의 결과를 모르는 채로 죽으면 다시 부르지 않고
runtime_execution_uncertain으로 실패해요.
작업(Job)과 스트림
백엔드 worker의 kind: "job" 동작은 시작(:start) 뒤 진행과 완료를 콜백으로 알려요. 한 번까지만 실행하고 저절로 다시 하지 않아요. 동시 실행은 usage_policy.limits(전체·회사당·사람당)로 막아요. kind: "stream" 동작은 worker의 SSE를 그대로 흘려요.
자동화
manifest의 trigger_templates로 스케줄·이벤트·웹훅 트리거를 선언하고, 앱이 인스턴스를 만들어요. 트리거는 앱이 직접 부르는 것과 같은 실행 경로(허용 목록, claim, 동시 실행 한도 포함)를 거쳐요.
jsonc
"trigger_templates": [{
"id": "nightly-classify",
"source": { "type": "schedule", "interval_seconds": 86400 },
"target": { "type": "capability", "id": "document.classify", "version": "1.0" },
"run_as": "user_delegated", // 또는 "agent_service"
"delivery": "at_least_once",
"configurable_fields": ["interval_seconds"],
"retry": { "max_attempts": 2, "backoff_seconds": 60 },
"concurrency": "forbid"
}]
| 출처 | 부르는 법 |
|---|---|
| 스케줄 | interval_seconds. cron 식과 달력 일정은 아직 없어요 |
| 이벤트 | 앱 토큰으로 POST /api/v1/automation/instances/{id}/events |
| 웹훅 | POST /api/v1/automation/instances/{id}/webhook, X-Mothership-Signature: sha256=<HMAC>(타임스탬프·이벤트 ID·트리거 ID·본문에 서명), 300초 안의 타임스탬프 |
배달은 run_triggers 워커가 해요(운영 Compose의 workers에 들어 있어요). 같은 이벤트의 모든 시도는 같은 Idempotency-Key를 쓰니, 받는 쪽이 지켜야 중복 효과가 없어요.