agents 0.26.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -9
- package/dist/{agent-routing-0DR0Tk2v.d.ts → agent-routing-Bhdbvf7s.d.ts} +13 -8
- package/dist/agent-routing.d.ts +1 -1
- package/dist/agent-tool-types.d.ts +1 -1
- package/dist/{agent-tools-YrATZJu2.d.ts → agent-tools-bJZwBMfq.d.ts} +2 -2
- package/dist/agent-tools.d.ts +1 -1
- package/dist/ai-sdk-OoGkFy3s.js +2444 -0
- package/dist/ai-sdk-OoGkFy3s.js.map +1 -0
- package/dist/apply-chunks-1FheRb9W.js +99 -0
- package/dist/apply-chunks-1FheRb9W.js.map +1 -0
- package/dist/broadcast-state-CEyI4uAK.js +69 -0
- package/dist/broadcast-state-CEyI4uAK.js.map +1 -0
- package/dist/browser/ai-sdk.d.ts +1 -1
- package/dist/browser/ai-sdk.js +2 -2
- package/dist/browser/ai-sdk.js.map +1 -1
- package/dist/browser/index.d.ts +1 -1
- package/dist/browser/tanstack-ai.d.ts +1 -1
- package/dist/browser/tanstack-ai.js +1 -1
- package/dist/{browser-DE3d-RLk.d.ts → browser-tmkcAAI3.d.ts} +2 -2
- package/dist/{browser-tool-DuNdlwZ9.d.ts → browser-tool-Bn-nzJQI.d.ts} +3 -3
- package/dist/{browser-tool-CQ10e6Kj.js → browser-tool-CBqs6hqa.js} +58 -18
- package/dist/browser-tool-CBqs6hqa.js.map +1 -0
- package/dist/capability-B4WbF81e.js.map +1 -1
- package/dist/{capability-runner-DBAnGr6L.d.ts → capability-runner-O5VbQzqg.d.ts} +9 -1
- package/dist/channel-Bak_6zDP.d.ts +333 -0
- package/dist/chat/index.d.ts +11 -9
- package/dist/chat/index.js +5 -194
- package/dist/chat/index.js.map +1 -1
- package/dist/chat/react.d.ts +2 -4
- package/dist/chat/react.js +3 -1
- package/dist/chat/react.js.map +1 -1
- package/dist/chat-sdk/index.d.ts +1 -1
- package/dist/chat-sdk/index.js +1 -1
- package/dist/cli.js +144 -0
- package/dist/{client-fyQrLGkD.js → client-1tEQ1Oqz.js} +27 -2
- package/dist/{client-fyQrLGkD.js.map → client-1tEQ1Oqz.js.map} +1 -1
- package/dist/{client-je3koD9Z.d.ts → client-DS3Dz9l0.d.ts} +2 -2
- package/dist/client-tools-aIBO0Fk7.d.ts +53 -0
- package/dist/client.d.ts +1 -1
- package/dist/conversations-DH0ut_8n.d.ts +192 -0
- package/dist/{current-agent-vAk_5JMt.d.ts → current-agent-C07C5o5Y.d.ts} +3 -3
- package/dist/daemon-core-Buubj-y1.js +481 -0
- package/dist/daemon-core-Buubj-y1.js.map +1 -0
- package/dist/daemon-core-CbohVPAu.d.ts +132 -0
- package/dist/{do-oauth-client-provider-Tmf1vgKz.d.ts → do-oauth-client-provider-DfsUcpc3.d.ts} +7 -1
- package/dist/{durable-object-lifecycle-HhgOMWq9.d.ts → durable-object-lifecycle-DRqp475_.d.ts} +2 -2
- package/dist/{channels/email.d.ts → experimental/channels/email/index.d.ts} +25 -12
- package/dist/{channels/email.js → experimental/channels/email/index.js} +13 -35
- package/dist/experimental/channels/email/index.js.map +1 -0
- package/dist/experimental/channels/index.d.ts +270 -0
- package/dist/experimental/channels/index.js +1186 -0
- package/dist/experimental/channels/index.js.map +1 -0
- package/dist/{channels/slack.d.ts → experimental/channels/slack/index.d.ts} +19 -9
- package/dist/experimental/channels/slack/index.js +267 -0
- package/dist/experimental/channels/slack/index.js.map +1 -0
- package/dist/{channels/telegram.d.ts → experimental/channels/telegram/index.d.ts} +19 -9
- package/dist/experimental/channels/telegram/index.js +198 -0
- package/dist/experimental/channels/telegram/index.js.map +1 -0
- package/dist/experimental/channels/web/ai-sdk.d.ts +55 -0
- package/dist/experimental/channels/web/ai-sdk.js +266 -0
- package/dist/experimental/channels/web/ai-sdk.js.map +1 -0
- package/dist/experimental/channels/web/client.d.ts +97 -0
- package/dist/experimental/channels/web/client.js +349 -0
- package/dist/experimental/channels/web/client.js.map +1 -0
- package/dist/experimental/channels/web/index.d.ts +189 -0
- package/dist/experimental/channels/web/index.js +332 -0
- package/dist/experimental/channels/web/index.js.map +1 -0
- package/dist/gateway-BDC07gYO.d.ts +100 -0
- package/dist/handle-zAzh0UW2.d.ts +460 -0
- package/dist/harness/ai-sdk/index.d.ts +175 -0
- package/dist/harness/ai-sdk/index.js +605 -0
- package/dist/harness/ai-sdk/index.js.map +1 -0
- package/dist/harness/container/daemon/index.d.ts +76 -0
- package/dist/harness/container/daemon/index.js +3 -0
- package/dist/harness/container/index.d.ts +740 -0
- package/dist/harness/container/index.js +2152 -0
- package/dist/harness/container/index.js.map +1 -0
- package/dist/harness/container/runtime/index.d.ts +144 -0
- package/dist/harness/container/runtime/index.js +1082 -0
- package/dist/harness/container/runtime/index.js.map +1 -0
- package/dist/harness/opencode/index.d.ts +369 -0
- package/dist/harness/opencode/index.js +1072 -0
- package/dist/harness/opencode/index.js.map +1 -0
- package/dist/harness/pi/index.d.ts +2 -1
- package/dist/harness/store/index.d.ts +24 -0
- package/dist/harness/store/index.js +2 -0
- package/dist/harness/think/index.d.ts +821 -0
- package/dist/harness/think/index.js +2529 -0
- package/dist/harness/think/index.js.map +1 -0
- package/dist/harness-B6B9S3rb.d.ts +203 -0
- package/dist/{images-iiTDSyRu.js → images-Ce9SCu3X.js} +2 -248
- package/dist/images-Ce9SCu3X.js.map +1 -0
- package/dist/{index-BreL0YrQ.d.ts → index-D0A5tbWu.d.ts} +2 -2
- package/dist/index-Ib_4dwOo.d.ts +200 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +2 -2
- package/dist/ingress-EFbrS547.js +9 -0
- package/dist/ingress-EFbrS547.js.map +1 -0
- package/dist/input-schema-DNrpTu49.js +23 -0
- package/dist/input-schema-DNrpTu49.js.map +1 -0
- package/dist/internal-kmw70xwR.js +46 -0
- package/dist/internal-kmw70xwR.js.map +1 -0
- package/dist/internal_context.d.ts +1 -1
- package/dist/lifecycle/index.d.ts +3 -3
- package/dist/mcp/client/do-oauth-client-provider.d.ts +1 -1
- package/dist/mcp/client/do-oauth-client-provider.js +9 -0
- package/dist/mcp/client/do-oauth-client-provider.js.map +1 -1
- package/dist/mcp/client/index.d.ts +1 -1
- package/dist/mcp/client/index.js +1 -1
- package/dist/mcp/client/x402.d.ts +35 -4
- package/dist/mcp/client/x402.js +24 -3
- package/dist/mcp/client/x402.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +2 -2
- package/dist/models/ai-sdk/index.d.ts +16 -14
- package/dist/models/ai-sdk/index.js +1 -2442
- package/dist/models/opencode/index.d.ts +65 -0
- package/dist/models/opencode/index.js +285 -0
- package/dist/models/opencode/index.js.map +1 -0
- package/dist/models/pi-ai/index.d.ts +9 -7
- package/dist/models/pi-ai/index.js +2 -1
- package/dist/models/pi-ai/index.js.map +1 -1
- package/dist/options-pwTNq9z6.d.ts +134 -0
- package/dist/protocol-BEgrJYC5.d.ts +331 -0
- package/dist/protocol-CukuI73M.d.ts +386 -0
- package/dist/protocol-cOklVBBD.js +227 -0
- package/dist/protocol-cOklVBBD.js.map +1 -0
- package/dist/{protocol-kHsr-f0X.js → protocol-eXeJxhgu.js} +2 -67
- package/dist/protocol-eXeJxhgu.js.map +1 -0
- package/dist/protocol-y2sSY584.js +148 -0
- package/dist/protocol-y2sSY584.js.map +1 -0
- package/dist/queue/index.d.ts +1 -1
- package/dist/react.d.ts +2 -2
- package/dist/routing/index.d.ts +2 -2
- package/dist/{scheduler-RdACNXDP.d.ts → scheduler-CrFCnv_J.d.ts} +2 -2
- package/dist/schedules/index.d.ts +1 -1
- package/dist/serializable.d.ts +1 -1
- package/dist/sessions/index.d.ts +11 -434
- package/dist/sessions/index.js +1 -2271
- package/dist/sessions-B9pNuxdT.js +2272 -0
- package/dist/sessions-B9pNuxdT.js.map +1 -0
- package/dist/settings-C45hDliX.js +253 -0
- package/dist/settings-C45hDliX.js.map +1 -0
- package/dist/{transport-PfFnt-Ld.d.ts → settings-NgGwF7Qt.d.ts} +14 -208
- package/dist/{src-BZeu-SCD.js → src-DgCbZtIR.js} +4 -4
- package/dist/{src-BZeu-SCD.js.map → src-DgCbZtIR.js.map} +1 -1
- package/dist/stall-watchdog-BpRF2uwG.js +195 -0
- package/dist/stall-watchdog-BpRF2uwG.js.map +1 -0
- package/dist/state/index.d.ts +1 -1
- package/dist/store-DLeqKuj3.d.ts +310 -0
- package/dist/store-vgcPYo8K.js +432 -0
- package/dist/store-vgcPYo8K.js.map +1 -0
- package/dist/streams/index.d.ts +1 -1
- package/dist/streams/index.js +1 -1
- package/dist/{streams-DW-UCOUc.js → streams-CITClVer.js} +16 -3
- package/dist/streams-CITClVer.js.map +1 -0
- package/dist/{streams-Cmkj9QfW.d.ts → streams-fbG61qM8.d.ts} +2 -2
- package/dist/sub-routing.d.ts +1 -1
- package/dist/tasks/index.d.ts +1 -1
- package/dist/tasks/index.js +1 -1
- package/dist/{tasks-68DESxf0.js → tasks-CkTZNaV1.js} +2 -1
- package/dist/tasks-CkTZNaV1.js.map +1 -0
- package/dist/{tasks-9YxYtByh.d.ts → tasks-PtlB4Uyn.d.ts} +2 -2
- package/dist/tool-3PA8xjB_.js +421 -0
- package/dist/tool-3PA8xjB_.js.map +1 -0
- package/dist/tool-BPJEbwaX.d.ts +278 -0
- package/dist/transport-k2mFrtL8.d.ts +200 -0
- package/dist/turns-DCV3ycDl.js +317 -0
- package/dist/turns-DCV3ycDl.js.map +1 -0
- package/dist/voice/client.js +1 -1
- package/dist/voice/index.d.ts +2 -2
- package/dist/voice/index.js +1 -1
- package/dist/websearch/index.d.ts +58 -0
- package/dist/websearch/index.js +2 -0
- package/dist/websearch/tools/ai-sdk.d.ts +77 -0
- package/dist/websearch/tools/ai-sdk.js +46 -0
- package/dist/websearch/tools/ai-sdk.js.map +1 -0
- package/dist/websearch/tools/pi.d.ts +82 -0
- package/dist/websearch/tools/pi.js +89 -0
- package/dist/websearch/tools/pi.js.map +1 -0
- package/dist/websearch/tools/tanstack-ai.d.ts +71 -0
- package/dist/websearch/tools/tanstack-ai.js +46 -0
- package/dist/websearch/tools/tanstack-ai.js.map +1 -0
- package/dist/websockets/index.d.ts +12 -296
- package/dist/websockets/index.js +1 -1
- package/dist/{websockets-Ci-LZFHH.js → websockets-CmENGb-Z.js} +18 -4
- package/dist/websockets-CmENGb-Z.js.map +1 -0
- package/dist/{wire-types-CrjKvDyi.d.ts → wire-types-Cv0iwjk5.d.ts} +3 -51
- package/dist/workflow-types.d.ts +1 -1
- package/dist/workflows.d.ts +1 -1
- package/dist/workflows.js +1 -1
- package/docs/browse-the-web.md +3 -0
- package/docs/harnesses/think.md +215 -0
- package/docs/index.md +2 -1
- package/docs/lifecycle.md +40 -0
- package/docs/search-the-web.md +133 -0
- package/package.json +117 -38
- package/dist/browser-tool-CQ10e6Kj.js.map +0 -1
- package/dist/channel-Bnm4S7T2.d.ts +0 -491
- package/dist/channels/ai-sdk.d.ts +0 -46
- package/dist/channels/ai-sdk.js +0 -120
- package/dist/channels/ai-sdk.js.map +0 -1
- package/dist/channels/email.js.map +0 -1
- package/dist/channels/index.d.ts +0 -233
- package/dist/channels/index.js +0 -608
- package/dist/channels/index.js.map +0 -1
- package/dist/channels/slack.js +0 -614
- package/dist/channels/slack.js.map +0 -1
- package/dist/channels/tanstack-ai.d.ts +0 -39
- package/dist/channels/tanstack-ai.js +0 -17
- package/dist/channels/tanstack-ai.js.map +0 -1
- package/dist/channels/telegram.js +0 -427
- package/dist/channels/telegram.js.map +0 -1
- package/dist/channels/voice.d.ts +0 -45
- package/dist/channels/voice.js +0 -122
- package/dist/channels/voice.js.map +0 -1
- package/dist/images-iiTDSyRu.js.map +0 -1
- package/dist/index-BB0kqhIz.d.ts +0 -101
- package/dist/ingress-BfetZbMO.js +0 -83
- package/dist/ingress-BfetZbMO.js.map +0 -1
- package/dist/internal-CYlgHl1l.js +0 -59
- package/dist/internal-CYlgHl1l.js.map +0 -1
- package/dist/models/ai-sdk/index.js.map +0 -1
- package/dist/protocol-kHsr-f0X.js.map +0 -1
- package/dist/sessions/index.js.map +0 -1
- package/dist/streams-DW-UCOUc.js.map +0 -1
- package/dist/surface-bZZJqBka.js +0 -17
- package/dist/surface-bZZJqBka.js.map +0 -1
- package/dist/tasks-68DESxf0.js.map +0 -1
- package/dist/tool-schema-CBjGPrsQ.js +0 -31
- package/dist/tool-schema-CBjGPrsQ.js.map +0 -1
- package/dist/websockets-Ci-LZFHH.js.map +0 -1
- package/docs/channels.md +0 -323
|
@@ -0,0 +1,740 @@
|
|
|
1
|
+
import {
|
|
2
|
+
_ as LifecycleJobContext,
|
|
3
|
+
n as CapabilityStartContext,
|
|
4
|
+
s as LifecycleCapability,
|
|
5
|
+
v as LifecycleJobOutcome
|
|
6
|
+
} from "../../capability-runner-O5VbQzqg.js";
|
|
7
|
+
import {
|
|
8
|
+
d as ContainerInputPart,
|
|
9
|
+
f as ContainerMessage,
|
|
10
|
+
g as ContainerWhenBusy,
|
|
11
|
+
h as ContainerSettings,
|
|
12
|
+
l as ContainerEvent,
|
|
13
|
+
m as ContainerPart,
|
|
14
|
+
u as ContainerInput,
|
|
15
|
+
x as JsonValue
|
|
16
|
+
} from "../../protocol-BEgrJYC5.js";
|
|
17
|
+
import { r as JsonValue$1, t as HarnessStore } from "../../store-DLeqKuj3.js";
|
|
18
|
+
import { WorkerEntrypoint } from "cloudflare:workers";
|
|
19
|
+
|
|
20
|
+
//#region src/harness/container/egress.d.ts
|
|
21
|
+
/** One intercepted host and where its requests go. */
|
|
22
|
+
type EgressRoute = {
|
|
23
|
+
/** The placeholder hostname the CLI calls, such as `anthropic.harness.internal`. */ readonly host: string /** The real base URL. The request's path and query are appended. */;
|
|
24
|
+
readonly upstream: string /** Headers to set on the forwarded request, such as credentials. */;
|
|
25
|
+
readonly headers: {
|
|
26
|
+
readonly [name: string]: string;
|
|
27
|
+
} /** Headers to drop from the CLI's request, such as its placeholder key. */;
|
|
28
|
+
readonly strip: readonly string[];
|
|
29
|
+
};
|
|
30
|
+
/** What `ContainerEgress` is given, as its props. */
|
|
31
|
+
type ContainerEgressProps = {
|
|
32
|
+
readonly routes: readonly EgressRoute[];
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* The `ctx.exports` entry for `ContainerEgress`: called with props, it
|
|
36
|
+
* returns the `Fetcher` an intercept hands requests to.
|
|
37
|
+
*/
|
|
38
|
+
type ContainerEgressBinding = (init: {
|
|
39
|
+
readonly props: ContainerEgressProps;
|
|
40
|
+
}) => Fetcher;
|
|
41
|
+
/**
|
|
42
|
+
* The egress for a `ContainerHarness`'s credentials. Export it from your
|
|
43
|
+
* Worker's main module so `ctx.exports.ContainerEgress` exists:
|
|
44
|
+
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* export { ContainerEgress } from "agents/harness/container";
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @experimental The API may change before it stabilizes.
|
|
50
|
+
*/
|
|
51
|
+
declare class ContainerEgress extends WorkerEntrypoint<
|
|
52
|
+
unknown,
|
|
53
|
+
ContainerEgressProps
|
|
54
|
+
> {
|
|
55
|
+
/**
|
|
56
|
+
* Forward one request the container made.
|
|
57
|
+
*
|
|
58
|
+
* @param request - The intercepted request.
|
|
59
|
+
* @returns The upstream's response.
|
|
60
|
+
*/
|
|
61
|
+
fetch(request: Request): Promise<Response>;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/harness/container/managed-image.d.ts
|
|
65
|
+
/**
|
|
66
|
+
* One setup command, run once in the fresh container and kept in its
|
|
67
|
+
* snapshot.
|
|
68
|
+
*
|
|
69
|
+
* Steps run as root by default. A step with `user: "agent"` runs as the
|
|
70
|
+
* user the CLI runs as, with `HOME=/home/agent`: anything it puts in that
|
|
71
|
+
* home (installed plugins and mods, `~/.claude/settings.json`, skills,
|
|
72
|
+
* `~/.codex/config.toml`) is in every session's home, because each session
|
|
73
|
+
* home starts as a copy of it.
|
|
74
|
+
*/
|
|
75
|
+
type SetupStep = {
|
|
76
|
+
/** What the step does, for error messages. */ readonly name: string;
|
|
77
|
+
readonly command: readonly string[] /** Who runs it. Default `root`. */;
|
|
78
|
+
readonly user?: "root" | "agent";
|
|
79
|
+
};
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/harness/container/agents.d.ts
|
|
82
|
+
/**
|
|
83
|
+
* Where a CLI's model requests go, and the credentials they carry. Added
|
|
84
|
+
* outside the container, by `ContainerEgress`.
|
|
85
|
+
*
|
|
86
|
+
* - Straight to the provider: `{ apiKey }`.
|
|
87
|
+
* - AI Gateway with Unified Billing: `{ baseUrl: `${gateway}/anthropic`,
|
|
88
|
+
* apiKey: gatewayToken }`; the gateway takes its token as the key.
|
|
89
|
+
* - AI Gateway with BYOK: `{ baseUrl, headers: { "cf-aig-authorization":
|
|
90
|
+
* `Bearer ${gatewayToken}` } }`; the gateway holds the provider key.
|
|
91
|
+
*/
|
|
92
|
+
type ProviderConnection = {
|
|
93
|
+
/** Sent the way the provider expects: `x-api-key`, or `Authorization: Bearer`. */ readonly apiKey?: string;
|
|
94
|
+
/**
|
|
95
|
+
* The provider's base URL, as its SDK names it (`ANTHROPIC_BASE_URL`,
|
|
96
|
+
* `OPENAI_BASE_URL`). Default: the provider's own API.
|
|
97
|
+
*/
|
|
98
|
+
readonly baseUrl?: string /** More headers on every model request, such as gateway metadata. */;
|
|
99
|
+
readonly headers?: {
|
|
100
|
+
readonly [name: string]: string;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
/** How the container is built. */
|
|
104
|
+
type ContainerImage =
|
|
105
|
+
/**
|
|
106
|
+
* `cloudflare/debian-trixie`, set up at runtime by the harness: the
|
|
107
|
+
* steps run once and the result is snapshotted. The harness installs the
|
|
108
|
+
* daemon.
|
|
109
|
+
*/
|
|
110
|
+
| {
|
|
111
|
+
readonly kind: "managed";
|
|
112
|
+
readonly setup: readonly SetupStep[];
|
|
113
|
+
} /** An image you built, whose entrypoint runs the daemon itself. */
|
|
114
|
+
| {
|
|
115
|
+
readonly kind: "custom";
|
|
116
|
+
readonly image: string;
|
|
117
|
+
};
|
|
118
|
+
/** What runs in the container. Build one with a preset. */
|
|
119
|
+
type ContainerAgent = {
|
|
120
|
+
/** The daemon adapter: `claude-code`, `codex`, `echo`, or your own. */ readonly adapter: string;
|
|
121
|
+
readonly image: ContainerImage /** Environment for the daemon and the CLI. Never put secrets here. */;
|
|
122
|
+
readonly env: {
|
|
123
|
+
readonly [name: string]: string;
|
|
124
|
+
} /** Hosts the harness intercepts to add credentials. */;
|
|
125
|
+
readonly egress: readonly EgressRoute[] /** The model and adapter options new sessions start with. */;
|
|
126
|
+
readonly model?: string;
|
|
127
|
+
readonly options?: JsonValue;
|
|
128
|
+
};
|
|
129
|
+
/** `claudeCode()`'s options: its provider connection and settings. */
|
|
130
|
+
type ClaudeCodeAgentOptions = ProviderConnection & {
|
|
131
|
+
/** Default `claude-sonnet-4-5`. Change one session's with `setModel`. */ readonly model?: string /** The `@anthropic-ai/claude-code` version. Default `2.1.289`. */;
|
|
132
|
+
readonly version?: string;
|
|
133
|
+
readonly appendSystemPrompt?: string;
|
|
134
|
+
readonly allowedTools?: readonly string[];
|
|
135
|
+
readonly disallowedTools?: readonly string[];
|
|
136
|
+
readonly maxTurns?: number;
|
|
137
|
+
/**
|
|
138
|
+
* More setup steps, run after the install and kept in the snapshot. Use
|
|
139
|
+
* `user: "agent"` to install plugins, mods or settings in the agent's
|
|
140
|
+
* home, which every session home starts from.
|
|
141
|
+
*/
|
|
142
|
+
readonly setup?: readonly SetupStep[];
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Claude Code, installed at runtime on `cloudflare/debian-trixie`.
|
|
146
|
+
*
|
|
147
|
+
* @param options - Its provider connection (`apiKey`, `baseUrl`,
|
|
148
|
+
* `headers`) and settings.
|
|
149
|
+
* @returns The agent, for `ContainerHarness`'s `agent`.
|
|
150
|
+
*
|
|
151
|
+
* @experimental The API may change before it stabilizes.
|
|
152
|
+
*/
|
|
153
|
+
declare function claudeCode(options: ClaudeCodeAgentOptions): ContainerAgent;
|
|
154
|
+
/** `codex()`'s options: its provider connection and settings. */
|
|
155
|
+
type CodexAgentOptions = ProviderConnection & {
|
|
156
|
+
/** Default `gpt-5.1`. Change one session's with `setModel`. */ readonly model?: string /** The `@openai/codex` version. Default `0.157.0`. */;
|
|
157
|
+
readonly version?: string /** Extra `-c key=value` config overrides. */;
|
|
158
|
+
readonly config?: readonly string[];
|
|
159
|
+
/**
|
|
160
|
+
* More setup steps, run after the install and kept in the snapshot. Use
|
|
161
|
+
* `user: "agent"` to install plugins, mods or settings in the agent's
|
|
162
|
+
* home, which every session home starts from.
|
|
163
|
+
*/
|
|
164
|
+
readonly setup?: readonly SetupStep[];
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Codex, installed at runtime on `cloudflare/debian-trixie`.
|
|
168
|
+
*
|
|
169
|
+
* @param options - Its provider connection (`apiKey`, `baseUrl`,
|
|
170
|
+
* `headers`) and settings.
|
|
171
|
+
* @returns The agent, for `ContainerHarness`'s `agent`.
|
|
172
|
+
*
|
|
173
|
+
* @experimental The API may change before it stabilizes.
|
|
174
|
+
*/
|
|
175
|
+
declare function codex(options: CodexAgentOptions): ContainerAgent;
|
|
176
|
+
/** `containerAgent()`'s options. */
|
|
177
|
+
type CustomAgentOptions = {
|
|
178
|
+
/** Your image, such as `ctx.container.images.agent`. Its entrypoint runs the daemon. */ readonly image: string /** The adapter its daemon runs. */;
|
|
179
|
+
readonly adapter: string;
|
|
180
|
+
readonly env?: {
|
|
181
|
+
readonly [name: string]: string;
|
|
182
|
+
};
|
|
183
|
+
readonly egress?: readonly EgressRoute[];
|
|
184
|
+
readonly model?: string;
|
|
185
|
+
readonly options?: JsonValue;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* An agent in an image you built, whose entrypoint serves the daemon
|
|
189
|
+
* (`serveFromEnv` from `agents/harness/container/runtime`).
|
|
190
|
+
*
|
|
191
|
+
* @param options - The image, the adapter, and its environment.
|
|
192
|
+
* @returns The agent, for `ContainerHarness`'s `agent`.
|
|
193
|
+
*
|
|
194
|
+
* @experimental The API may change before it stabilizes.
|
|
195
|
+
*/
|
|
196
|
+
declare function containerAgent(options: CustomAgentOptions): ContainerAgent;
|
|
197
|
+
/**
|
|
198
|
+
* The echo adapter on `cloudflare/debian-trixie`: no CLI, no model, no
|
|
199
|
+
* credentials. For smoke tests of the whole path.
|
|
200
|
+
*
|
|
201
|
+
* @returns The agent, for `ContainerHarness`'s `agent`.
|
|
202
|
+
*
|
|
203
|
+
* @experimental The API may change before it stabilizes.
|
|
204
|
+
*/
|
|
205
|
+
declare function echoAgent(): ContainerAgent;
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region src/harness/container/types.d.ts
|
|
208
|
+
/**
|
|
209
|
+
* `ContainerHarness`'s own types: how the harness addresses sessions and
|
|
210
|
+
* reports operations. They mirror `agents/harness/pi` one for one, so code
|
|
211
|
+
* written against one harness reads the same against the other. Transcript
|
|
212
|
+
* messages and events are the wire's types (`ContainerMessage`,
|
|
213
|
+
* `ContainerEvent`), the one format every container adapter produces.
|
|
214
|
+
*/
|
|
215
|
+
/** A session, addressed by its id. The root is `"root"`. */
|
|
216
|
+
type ContainerSessionId = string;
|
|
217
|
+
/** Options for submitting a prompt. */
|
|
218
|
+
type ContainerSubmitOptions = {
|
|
219
|
+
/** Default: the root session. */ readonly session?: ContainerSessionId /** Idempotency key. Submitting the same id twice returns the same receipt. */;
|
|
220
|
+
readonly operationId?: string;
|
|
221
|
+
/**
|
|
222
|
+
* What the submission does when the session is already running.
|
|
223
|
+
*
|
|
224
|
+
* - `followUp` (default): answered after the current run, as its own run.
|
|
225
|
+
* - `steer`: joins the running turn, when the adapter can steer;
|
|
226
|
+
* otherwise it is queued as a follow-up.
|
|
227
|
+
*/
|
|
228
|
+
readonly whenBusy?: ContainerWhenBusy;
|
|
229
|
+
};
|
|
230
|
+
/** Addresses one session. */
|
|
231
|
+
type ContainerSessionOptions = {
|
|
232
|
+
/** Default: the root session. */ readonly session?: ContainerSessionId;
|
|
233
|
+
};
|
|
234
|
+
/** Returned once a submission is durable. It says nothing about the model yet. */
|
|
235
|
+
type ContainerReceipt = {
|
|
236
|
+
readonly operationId: string;
|
|
237
|
+
readonly session: ContainerSessionId /** False when this operation id was already submitted. */;
|
|
238
|
+
readonly accepted: boolean;
|
|
239
|
+
};
|
|
240
|
+
/** How one operation ended. */
|
|
241
|
+
type ContainerOperationResult = {
|
|
242
|
+
readonly operationId: string;
|
|
243
|
+
readonly session: ContainerSessionId /** `done`: answered. `unanswered`: failed, aborted, or lost with its container. */;
|
|
244
|
+
readonly status: "done" | "unanswered";
|
|
245
|
+
/**
|
|
246
|
+
* Why an unanswered operation ended: the adapter's reason, `aborted`,
|
|
247
|
+
* `container_lost` (its container stopped mid-run), `not_found`, or
|
|
248
|
+
* `container_unavailable` (no container could be started).
|
|
249
|
+
*/
|
|
250
|
+
readonly reason?: string /** The final assistant text, when answered. */;
|
|
251
|
+
readonly text?: string;
|
|
252
|
+
};
|
|
253
|
+
/** What `prompt()` returns: the result and the transcript after it. */
|
|
254
|
+
type ContainerPromptResponse = ContainerOperationResult & {
|
|
255
|
+
/** The session's active transcript after the operation. */ readonly messages: readonly ContainerMessage[];
|
|
256
|
+
};
|
|
257
|
+
/** A submission that has not settled yet. */
|
|
258
|
+
type ContainerPendingOperation = {
|
|
259
|
+
readonly operationId: string;
|
|
260
|
+
readonly session: ContainerSessionId /** `queued`, or `running` in the container. */;
|
|
261
|
+
readonly status: "queued" | "running";
|
|
262
|
+
};
|
|
263
|
+
/** One session, as `sessions.list()` reports it. */
|
|
264
|
+
type ContainerSessionInfo = {
|
|
265
|
+
readonly id: ContainerSessionId /** The session this one was forked from. */;
|
|
266
|
+
readonly parent?: ContainerSessionId;
|
|
267
|
+
readonly busy: boolean;
|
|
268
|
+
};
|
|
269
|
+
/** Where the container is, as the harness sees it. */
|
|
270
|
+
type ContainerStatus =
|
|
271
|
+
| "starting"
|
|
272
|
+
| "ready" /** The container stopped while it had work; that work is reconciled. */
|
|
273
|
+
| "lost" /** The container was stopped after it went idle. */
|
|
274
|
+
| "stopped";
|
|
275
|
+
/** One event on a session's stream. */
|
|
276
|
+
type ContainerSessionEvent =
|
|
277
|
+
/** What the adapter reported, tagged with its operation. */ | (ContainerEvent & {
|
|
278
|
+
readonly operationId: string | null;
|
|
279
|
+
})
|
|
280
|
+
| {
|
|
281
|
+
readonly type: "operation-start";
|
|
282
|
+
readonly operationId: string;
|
|
283
|
+
}
|
|
284
|
+
| {
|
|
285
|
+
readonly type: "operation-end";
|
|
286
|
+
readonly result: ContainerOperationResult;
|
|
287
|
+
}
|
|
288
|
+
| {
|
|
289
|
+
readonly type: "container";
|
|
290
|
+
readonly status: ContainerStatus;
|
|
291
|
+
};
|
|
292
|
+
/** The state of a session when a stream starts. */
|
|
293
|
+
type ContainerSessionSnapshot = {
|
|
294
|
+
readonly session: ContainerSessionId;
|
|
295
|
+
readonly messages: readonly ContainerMessage[];
|
|
296
|
+
readonly pending: readonly ContainerPendingOperation[];
|
|
297
|
+
readonly busy: boolean;
|
|
298
|
+
};
|
|
299
|
+
/**
|
|
300
|
+
* A session's events: the snapshot taken when the stream was opened, then
|
|
301
|
+
* every event after it, in batches, including any that arrived before
|
|
302
|
+
* `start()`. An event may repeat what the snapshot already shows; messages
|
|
303
|
+
* are keyed by id. Live: events reach listeners in the isolate that runs
|
|
304
|
+
* the harness. Call `stop()` when done, started or not.
|
|
305
|
+
*/
|
|
306
|
+
type ContainerEventStream = {
|
|
307
|
+
readonly snapshot: ContainerSessionSnapshot /** Start delivering events. Call once. */;
|
|
308
|
+
start(
|
|
309
|
+
listener: (events: readonly ContainerSessionEvent[]) => void
|
|
310
|
+
): void /** Stop delivering events. */;
|
|
311
|
+
stop(): Promise<void>;
|
|
312
|
+
};
|
|
313
|
+
//#endregion
|
|
314
|
+
//#region src/harness/container/harness.d.ts
|
|
315
|
+
/** The root session's id. */
|
|
316
|
+
declare const ROOT_SESSION: ContainerSessionId;
|
|
317
|
+
/** A container instance size: a named type or a custom shape. */
|
|
318
|
+
type ContainerInstance =
|
|
319
|
+
| "lite"
|
|
320
|
+
| "standard-1"
|
|
321
|
+
| "standard-2"
|
|
322
|
+
| "standard-3"
|
|
323
|
+
| "standard-4"
|
|
324
|
+
| {
|
|
325
|
+
readonly vcpu: number;
|
|
326
|
+
readonly memoryMib: number;
|
|
327
|
+
readonly diskMb: number;
|
|
328
|
+
};
|
|
329
|
+
/** Applied to a session the first time it is created. */
|
|
330
|
+
type ContainerSessionDefaults = {
|
|
331
|
+
/** The adapter's model name. Change one session's with `session.setModel`. */ readonly model?: string /** Adapter options, passed through to the adapter untouched. */;
|
|
332
|
+
readonly options?: JsonValue$1;
|
|
333
|
+
};
|
|
334
|
+
/** `ContainerHarness`'s options. */
|
|
335
|
+
type ContainerHarnessOptions = {
|
|
336
|
+
/** The object's container: `ctx.container`. */ readonly container: Container /** What runs in it: `claudeCode()`, `codex()`, or `containerAgent()`. */;
|
|
337
|
+
readonly agent: ContainerAgent;
|
|
338
|
+
/**
|
|
339
|
+
* `ctx.exports.ContainerEgress`, which adds the agent's credentials to
|
|
340
|
+
* its requests outside the container. Required when the agent has egress
|
|
341
|
+
* routes (every preset does). Export `ContainerEgress` from
|
|
342
|
+
* your Worker's main module.
|
|
343
|
+
*/
|
|
344
|
+
readonly egress?: ContainerEgressBinding /** Instance size. Default `standard-1`. */;
|
|
345
|
+
readonly instance?: ContainerInstance;
|
|
346
|
+
/**
|
|
347
|
+
* Whether the container may reach the Internet beyond its egress routes.
|
|
348
|
+
* Default true: managed images need it to install their CLI in setup.
|
|
349
|
+
* Commands the agent runs can then reach any host (credentials still
|
|
350
|
+
* stay outside: only the egress routes carry them). Set false, with a
|
|
351
|
+
* `containerAgent()` image that has its CLI installed, to allow nothing
|
|
352
|
+
* but the egress routes.
|
|
353
|
+
*/
|
|
354
|
+
readonly enableInternet?: boolean /** Where the daemon listens. Default 8080. */;
|
|
355
|
+
readonly port?: number;
|
|
356
|
+
/**
|
|
357
|
+
* How long the container keeps running after its last work, in
|
|
358
|
+
* milliseconds. The harness then snapshots its filesystem (workspace
|
|
359
|
+
* included) and stops it; the next prompt starts a new one from that
|
|
360
|
+
* snapshot and resumes the session in it. Default five minutes; at most
|
|
361
|
+
* six hours less two minutes (the platform's own stop comes two minutes
|
|
362
|
+
* later, and the harness must snapshot first).
|
|
363
|
+
*/
|
|
364
|
+
readonly idleTimeoutMs?: number /** How long a new container may take to answer. Default 60 seconds. */;
|
|
365
|
+
readonly startTimeoutMs?: number /** What a new session starts with. Default: the agent's model and options. */;
|
|
366
|
+
readonly defaults?: ContainerSessionDefaults;
|
|
367
|
+
/**
|
|
368
|
+
* What happens to an operation whose container stopped while it ran.
|
|
369
|
+
*
|
|
370
|
+
* - `fail` (default): it settles `unanswered` with `container_lost`. The
|
|
371
|
+
* session itself survives: the next prompt resumes it in a new
|
|
372
|
+
* container, from everything the adapter persisted.
|
|
373
|
+
* - `retry`: it runs again from the start in the new container. Only safe
|
|
374
|
+
* when the agent's tools can be repeated.
|
|
375
|
+
*/
|
|
376
|
+
readonly onContainerLost?:
|
|
377
|
+
| "fail"
|
|
378
|
+
| "retry" /** Table prefix for the session store. Default `container_`. */;
|
|
379
|
+
readonly storePrefix?: string;
|
|
380
|
+
};
|
|
381
|
+
/**
|
|
382
|
+
* An agent CLI running in a Cloudflare Container, driven from a Durable
|
|
383
|
+
* Object, behind the same interface as `PiHarness`: `harness.prompt()`,
|
|
384
|
+
* `harness.sessions`, `harness.session(id)`.
|
|
385
|
+
*
|
|
386
|
+
* The harness does not know which agent runs in the container. A preset
|
|
387
|
+
* (`claudeCode()`, `codex()`) says what to install and which adapter the
|
|
388
|
+
* daemon runs; the harness builds the container from
|
|
389
|
+
* `cloudflare/debian-trixie` on first use, installs the bundled daemon, and
|
|
390
|
+
* snapshots the result, so there is no image to build. Credentials stay
|
|
391
|
+
* outside: the CLI calls a placeholder host, and `ContainerEgress` adds the
|
|
392
|
+
* real key. Any adapter that produces `ContainerEvent`s works, including
|
|
393
|
+
* one in an image of your own (`containerAgent()`).
|
|
394
|
+
*
|
|
395
|
+
* The object owns the durable record, in a `HarnessStore`: sessions,
|
|
396
|
+
* operations, the transcript, and the adapter's resume state. The container
|
|
397
|
+
* is disposable. It is started on demand with `ctx.container.start()`, kept
|
|
398
|
+
* for `idleTimeoutMs` after its last work, and then stopped. The next
|
|
399
|
+
* prompt starts a new container and hands the adapter everything it
|
|
400
|
+
* persisted, so the agent resumes its own session there.
|
|
401
|
+
*
|
|
402
|
+
* Each session has one Lifecycle wake job. It runs while the session has
|
|
403
|
+
* open operations: it starts or reattaches to the container, reconciles
|
|
404
|
+
* what the container knows with what the object stored, delivers queued
|
|
405
|
+
* operations, and waits for them, rescheduling itself as a heartbeat. An
|
|
406
|
+
* eviction mid-run leaves the job due, so its alarm restarts the object,
|
|
407
|
+
* which reattaches and replays the frames it missed from its cursor.
|
|
408
|
+
*
|
|
409
|
+
* Recovery, by what was lost:
|
|
410
|
+
*
|
|
411
|
+
* - **The object** (eviction, deploy): the container keeps running for
|
|
412
|
+
* `idleTimeoutMs`. The wake reattaches and replays from the cursor.
|
|
413
|
+
* - **The socket**: the same, on the next heartbeat.
|
|
414
|
+
* - **The container** (idle stop, crash, platform restart): a new one
|
|
415
|
+
* answers with a different runtime id. The session is reopened in it
|
|
416
|
+
* from the persisted resume state; queued operations run there; an
|
|
417
|
+
* operation that was running is settled `container_lost` or run again,
|
|
418
|
+
* per `onContainerLost`.
|
|
419
|
+
*
|
|
420
|
+
* @experimental The API may change before it stabilizes.
|
|
421
|
+
*/
|
|
422
|
+
declare class ContainerHarness extends LifecycleCapability {
|
|
423
|
+
#private;
|
|
424
|
+
/** Every session in this object. */
|
|
425
|
+
readonly sessions: ContainerSessions;
|
|
426
|
+
/**
|
|
427
|
+
* @param options - The container, the agent, and session defaults.
|
|
428
|
+
*/
|
|
429
|
+
constructor(options: ContainerHarnessOptions);
|
|
430
|
+
/** Reopen the store, re-arm the container's idle timeout, and wake open sessions. */
|
|
431
|
+
onStart(_context: CapabilityStartContext): Promise<void>;
|
|
432
|
+
/** Dispatch the harness's jobs: one wake per session, and the idle stop. */
|
|
433
|
+
onJob(context: LifecycleJobContext): Promise<LifecycleJobOutcome | void>;
|
|
434
|
+
/** Close the session sockets. Durable state and the container are untouched. */
|
|
435
|
+
dispose(): Promise<void>;
|
|
436
|
+
/**
|
|
437
|
+
* A handle on one session. No I/O until you call it.
|
|
438
|
+
*
|
|
439
|
+
* @param id - The session. Default: the root session.
|
|
440
|
+
* @returns The handle.
|
|
441
|
+
*/
|
|
442
|
+
session(id?: ContainerSessionId): ContainerSession;
|
|
443
|
+
/**
|
|
444
|
+
* Submit a prompt and wait for its answer.
|
|
445
|
+
*
|
|
446
|
+
* @param input - The prompt.
|
|
447
|
+
* @param options - Session, idempotency key, and busy behaviour.
|
|
448
|
+
* @returns The result, with the session's transcript after it.
|
|
449
|
+
*/
|
|
450
|
+
prompt(
|
|
451
|
+
input: ContainerInput,
|
|
452
|
+
options?: ContainerSubmitOptions
|
|
453
|
+
): Promise<ContainerPromptResponse>;
|
|
454
|
+
/**
|
|
455
|
+
* Durably submit a prompt. Resolves before the agent runs.
|
|
456
|
+
*
|
|
457
|
+
* @param input - The prompt.
|
|
458
|
+
* @param options - Session, idempotency key, and busy behaviour.
|
|
459
|
+
* @returns The receipt.
|
|
460
|
+
*/
|
|
461
|
+
submit(
|
|
462
|
+
input: ContainerInput,
|
|
463
|
+
options?: ContainerSubmitOptions
|
|
464
|
+
): Promise<ContainerReceipt>;
|
|
465
|
+
/**
|
|
466
|
+
* Stop one operation, or everything running in a session.
|
|
467
|
+
*
|
|
468
|
+
* @param options - The session, and optionally one operation.
|
|
469
|
+
* @returns Whether anything was stopped.
|
|
470
|
+
*/
|
|
471
|
+
abort(
|
|
472
|
+
options?: ContainerSessionOptions & {
|
|
473
|
+
readonly operationId?: string;
|
|
474
|
+
}
|
|
475
|
+
): Promise<boolean>;
|
|
476
|
+
/**
|
|
477
|
+
* Wait for an operation to settle.
|
|
478
|
+
*
|
|
479
|
+
* @param operationId - The operation.
|
|
480
|
+
* @param options - The session, and a signal that stops only the wait.
|
|
481
|
+
* @returns How it ended.
|
|
482
|
+
*/
|
|
483
|
+
wait(
|
|
484
|
+
operationId: string,
|
|
485
|
+
options?: ContainerSessionOptions & {
|
|
486
|
+
readonly signal?: AbortSignal;
|
|
487
|
+
}
|
|
488
|
+
): Promise<ContainerOperationResult>;
|
|
489
|
+
/**
|
|
490
|
+
* The session's active transcript.
|
|
491
|
+
*
|
|
492
|
+
* @param options - The session.
|
|
493
|
+
* @returns Its messages since the newest reset.
|
|
494
|
+
*/
|
|
495
|
+
messages(options?: ContainerSessionOptions): Promise<ContainerMessage[]>;
|
|
496
|
+
/**
|
|
497
|
+
* Submissions that have not settled yet, oldest first.
|
|
498
|
+
*
|
|
499
|
+
* @param options - Narrow to one session. Default: every session.
|
|
500
|
+
* @returns The open operations.
|
|
501
|
+
*/
|
|
502
|
+
pending(
|
|
503
|
+
options?: ContainerSessionOptions
|
|
504
|
+
): Promise<ContainerPendingOperation[]>;
|
|
505
|
+
/**
|
|
506
|
+
* The container, as the harness sees it.
|
|
507
|
+
*
|
|
508
|
+
* @returns Whether it runs, and the id the harness started it with.
|
|
509
|
+
*/
|
|
510
|
+
container(): Promise<{
|
|
511
|
+
readonly running: boolean;
|
|
512
|
+
readonly runtimeId: string | undefined;
|
|
513
|
+
}>;
|
|
514
|
+
/**
|
|
515
|
+
* Stop the container now. Sessions survive: the next prompt starts a new
|
|
516
|
+
* container and resumes them in it. Running operations are reconciled as
|
|
517
|
+
* if the container had died.
|
|
518
|
+
*/
|
|
519
|
+
stop(): Promise<void>;
|
|
520
|
+
/** @internal */
|
|
521
|
+
store(): Promise<HarnessStore>;
|
|
522
|
+
/** @internal Create a session with the defaults, or fork one. */
|
|
523
|
+
createSession(
|
|
524
|
+
id: ContainerSessionId,
|
|
525
|
+
from?: ContainerSessionId
|
|
526
|
+
): Promise<void>;
|
|
527
|
+
/** @internal */
|
|
528
|
+
enqueue(
|
|
529
|
+
session: ContainerSessionId,
|
|
530
|
+
input: ContainerInput,
|
|
531
|
+
options: ContainerSubmitOptions
|
|
532
|
+
): Promise<ContainerReceipt>;
|
|
533
|
+
/** @internal Withdraw or abort one operation, or all of a session's. */
|
|
534
|
+
withdraw(
|
|
535
|
+
session: ContainerSessionId,
|
|
536
|
+
operationId: string | undefined
|
|
537
|
+
): Promise<boolean>;
|
|
538
|
+
/** @internal Wait for an operation to settle. */
|
|
539
|
+
settled(
|
|
540
|
+
session: ContainerSessionId,
|
|
541
|
+
operationId: string,
|
|
542
|
+
signal?: AbortSignal
|
|
543
|
+
): Promise<ContainerOperationResult>;
|
|
544
|
+
/** @internal The active transcript. */
|
|
545
|
+
transcript(session: ContainerSessionId): Promise<ContainerMessage[]>;
|
|
546
|
+
/** @internal */
|
|
547
|
+
busy(session: ContainerSessionId): Promise<boolean>;
|
|
548
|
+
/** @internal Start a new context: a new agent session, without history. */
|
|
549
|
+
resetSession(
|
|
550
|
+
session: ContainerSessionId,
|
|
551
|
+
handoff: string | undefined
|
|
552
|
+
): Promise<void>;
|
|
553
|
+
/** @internal */
|
|
554
|
+
setModel(session: ContainerSessionId, model: string): Promise<void>;
|
|
555
|
+
/** @internal */
|
|
556
|
+
events(session: ContainerSessionId): Promise<ContainerEventStream>;
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* One session, addressed through the harness.
|
|
560
|
+
*
|
|
561
|
+
* @experimental The API may change before it stabilizes.
|
|
562
|
+
*/
|
|
563
|
+
declare class ContainerSession {
|
|
564
|
+
#private;
|
|
565
|
+
/** The session id. */
|
|
566
|
+
readonly id: ContainerSessionId;
|
|
567
|
+
/**
|
|
568
|
+
* @param harness - The harness.
|
|
569
|
+
* @param id - The session id.
|
|
570
|
+
*/
|
|
571
|
+
constructor(harness: ContainerHarness, id: ContainerSessionId);
|
|
572
|
+
/**
|
|
573
|
+
* Durably submit a prompt. Resolves before the agent runs.
|
|
574
|
+
*
|
|
575
|
+
* @param input - The prompt.
|
|
576
|
+
* @param options - Idempotency key and busy behaviour.
|
|
577
|
+
* @returns The receipt.
|
|
578
|
+
*/
|
|
579
|
+
submit(
|
|
580
|
+
input: ContainerInput,
|
|
581
|
+
options?: ContainerSubmitOptions
|
|
582
|
+
): Promise<ContainerReceipt>;
|
|
583
|
+
/**
|
|
584
|
+
* Submit and wait for the answer and the updated transcript.
|
|
585
|
+
*
|
|
586
|
+
* @param input - The prompt.
|
|
587
|
+
* @param options - Idempotency key and busy behaviour.
|
|
588
|
+
* @returns The result, with the transcript after it.
|
|
589
|
+
*/
|
|
590
|
+
prompt(
|
|
591
|
+
input: ContainerInput,
|
|
592
|
+
options?: ContainerSubmitOptions
|
|
593
|
+
): Promise<ContainerPromptResponse>;
|
|
594
|
+
/**
|
|
595
|
+
* Join the running turn, when the adapter can steer; otherwise queue.
|
|
596
|
+
*
|
|
597
|
+
* @param input - The prompt.
|
|
598
|
+
* @param options - Idempotency key.
|
|
599
|
+
* @returns The receipt.
|
|
600
|
+
*/
|
|
601
|
+
steer(
|
|
602
|
+
input: ContainerInput,
|
|
603
|
+
options?: Omit<ContainerSubmitOptions, "whenBusy">
|
|
604
|
+
): Promise<ContainerReceipt>;
|
|
605
|
+
/**
|
|
606
|
+
* Wait for an operation to settle. Aborting `signal` stops only the wait.
|
|
607
|
+
*
|
|
608
|
+
* @param operationId - The operation.
|
|
609
|
+
* @param signal - Stops the wait.
|
|
610
|
+
* @returns How it ended.
|
|
611
|
+
*/
|
|
612
|
+
wait(
|
|
613
|
+
operationId: string,
|
|
614
|
+
signal?: AbortSignal
|
|
615
|
+
): Promise<ContainerOperationResult>;
|
|
616
|
+
/**
|
|
617
|
+
* Withdraw or abort one operation, or, with no id, every open operation
|
|
618
|
+
* of the session. Aborted operations settle `unanswered` with `aborted`.
|
|
619
|
+
*
|
|
620
|
+
* @param operationId - The operation. Default: all of them.
|
|
621
|
+
* @returns Whether anything was open to abort (always true with no id).
|
|
622
|
+
*/
|
|
623
|
+
abort(operationId?: string): Promise<boolean>;
|
|
624
|
+
/**
|
|
625
|
+
* Start a new context: a new agent session without the old history,
|
|
626
|
+
* optionally seeded with a handoff note prepended to the next prompt.
|
|
627
|
+
* Throws while the session is busy.
|
|
628
|
+
*
|
|
629
|
+
* @param handoff - The note.
|
|
630
|
+
*/
|
|
631
|
+
reset(handoff?: string): Promise<void>;
|
|
632
|
+
/**
|
|
633
|
+
* Change this session's model, by the adapter's model name.
|
|
634
|
+
*
|
|
635
|
+
* @param model - The model.
|
|
636
|
+
*/
|
|
637
|
+
setModel(model: string): Promise<void>;
|
|
638
|
+
/**
|
|
639
|
+
* The active transcript, since the newest reset.
|
|
640
|
+
*
|
|
641
|
+
* @returns The messages, oldest first.
|
|
642
|
+
*/
|
|
643
|
+
messages(): Promise<ContainerMessage[]>;
|
|
644
|
+
/**
|
|
645
|
+
* This session's events: a snapshot, then live batches.
|
|
646
|
+
*
|
|
647
|
+
* @returns The stream.
|
|
648
|
+
*/
|
|
649
|
+
events(): Promise<ContainerEventStream>;
|
|
650
|
+
/**
|
|
651
|
+
* Whether the session has open operations.
|
|
652
|
+
*
|
|
653
|
+
* @returns True while anything is queued or running.
|
|
654
|
+
*/
|
|
655
|
+
busy(): Promise<boolean>;
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* Every session in this object.
|
|
659
|
+
*
|
|
660
|
+
* @experimental The API may change before it stabilizes.
|
|
661
|
+
*/
|
|
662
|
+
declare class ContainerSessions {
|
|
663
|
+
#private;
|
|
664
|
+
/**
|
|
665
|
+
* @param harness - The harness.
|
|
666
|
+
*/
|
|
667
|
+
constructor(harness: ContainerHarness);
|
|
668
|
+
/**
|
|
669
|
+
* A handle on one session.
|
|
670
|
+
*
|
|
671
|
+
* @param id - The session id.
|
|
672
|
+
* @returns The handle.
|
|
673
|
+
*/
|
|
674
|
+
get(id: ContainerSessionId): ContainerSession;
|
|
675
|
+
/**
|
|
676
|
+
* A new top-level session, with the harness's defaults.
|
|
677
|
+
*
|
|
678
|
+
* @returns The new session.
|
|
679
|
+
*/
|
|
680
|
+
create(): Promise<ContainerSession>;
|
|
681
|
+
/**
|
|
682
|
+
* A new session that continues `from`'s history as a branch.
|
|
683
|
+
*
|
|
684
|
+
* @param from - The session to fork.
|
|
685
|
+
* @returns The new session.
|
|
686
|
+
*/
|
|
687
|
+
fork(from: ContainerSessionId): Promise<ContainerSession>;
|
|
688
|
+
/**
|
|
689
|
+
* Every session, oldest first.
|
|
690
|
+
*
|
|
691
|
+
* @returns Each session's id, parent, and whether it is busy.
|
|
692
|
+
*/
|
|
693
|
+
list(): Promise<ContainerSessionInfo[]>;
|
|
694
|
+
}
|
|
695
|
+
//#endregion
|
|
696
|
+
export {
|
|
697
|
+
type ClaudeCodeAgentOptions,
|
|
698
|
+
type CodexAgentOptions,
|
|
699
|
+
type ContainerAgent,
|
|
700
|
+
ContainerEgress,
|
|
701
|
+
type ContainerEgressBinding,
|
|
702
|
+
type ContainerEgressProps,
|
|
703
|
+
type ContainerEvent,
|
|
704
|
+
type ContainerEventStream,
|
|
705
|
+
ContainerHarness,
|
|
706
|
+
type ContainerHarnessOptions,
|
|
707
|
+
type ContainerImage,
|
|
708
|
+
type ContainerInput,
|
|
709
|
+
type ContainerInputPart,
|
|
710
|
+
type ContainerInstance,
|
|
711
|
+
type ContainerMessage,
|
|
712
|
+
type ContainerOperationResult,
|
|
713
|
+
type ContainerPart,
|
|
714
|
+
type ContainerPendingOperation,
|
|
715
|
+
type ContainerPromptResponse,
|
|
716
|
+
type ContainerReceipt,
|
|
717
|
+
ContainerSession,
|
|
718
|
+
type ContainerSessionDefaults,
|
|
719
|
+
type ContainerSessionEvent,
|
|
720
|
+
type ContainerSessionId,
|
|
721
|
+
type ContainerSessionInfo,
|
|
722
|
+
type ContainerSessionOptions,
|
|
723
|
+
type ContainerSessionSnapshot,
|
|
724
|
+
ContainerSessions,
|
|
725
|
+
type ContainerSettings,
|
|
726
|
+
type ContainerStatus,
|
|
727
|
+
type ContainerSubmitOptions,
|
|
728
|
+
type ContainerWhenBusy,
|
|
729
|
+
type CustomAgentOptions,
|
|
730
|
+
type EgressRoute,
|
|
731
|
+
type JsonValue,
|
|
732
|
+
type ProviderConnection,
|
|
733
|
+
ROOT_SESSION,
|
|
734
|
+
type SetupStep,
|
|
735
|
+
claudeCode,
|
|
736
|
+
codex,
|
|
737
|
+
containerAgent,
|
|
738
|
+
echoAgent
|
|
739
|
+
};
|
|
740
|
+
//# sourceMappingURL=index.d.ts.map
|