agents 0.29.0 → 0.30.1

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.
Files changed (44) hide show
  1. package/README.md +3 -2
  2. package/dist/browser/tools/pi.d.ts +6 -2
  3. package/dist/browser/tools/pi.js +6 -2
  4. package/dist/browser/tools/pi.js.map +1 -1
  5. package/dist/chat-sdk/index.js +1 -1
  6. package/dist/cli.js +46 -45
  7. package/dist/experimental/channels/web/index.js +1 -1
  8. package/dist/harness/container/index.js +1 -1
  9. package/dist/harness/opencode/index.js +1 -1
  10. package/dist/harness/pi/index.d.ts +60 -35
  11. package/dist/harness/pi/index.js +271 -119
  12. package/dist/harness/pi/index.js.map +1 -1
  13. package/dist/index.js +1 -1
  14. package/dist/lifecycle/index.js +1 -1
  15. package/dist/{lifecycle-ClT4DmF2.js → lifecycle-v1rKHV2C.js} +57 -17
  16. package/dist/lifecycle-v1rKHV2C.js.map +1 -0
  17. package/dist/mcp/index.js +1 -1
  18. package/dist/models/pi-ai/index.js +2 -2
  19. package/dist/models/pi-ai/index.js.map +1 -1
  20. package/dist/{src-6lr7MtM_.js → src-DfLzdwlK.js} +3 -3
  21. package/dist/{src-6lr7MtM_.js.map → src-DfLzdwlK.js.map} +1 -1
  22. package/dist/web/fetch/tools/pi.d.ts +10 -6
  23. package/dist/web/fetch/tools/pi.js +10 -6
  24. package/dist/web/fetch/tools/pi.js.map +1 -1
  25. package/dist/web/search/tools/pi.d.ts +10 -6
  26. package/dist/web/search/tools/pi.js +10 -6
  27. package/dist/web/search/tools/pi.js.map +1 -1
  28. package/dist/websockets/index.js +1 -1
  29. package/dist/{websockets-CqxnntmE.js → websockets-CyoeosdO.js} +2 -2
  30. package/dist/{websockets-CqxnntmE.js.map → websockets-CyoeosdO.js.map} +1 -1
  31. package/dist/workflows.js +1 -1
  32. package/docs/get-current-agent.md +4 -7
  33. package/docs/harnesses/pi.md +62 -28
  34. package/docs/human-in-the-loop.md +3 -7
  35. package/docs/index.md +2 -2
  36. package/docs/lifecycle.md +7 -1
  37. package/docs/mcp-client.md +2 -28
  38. package/docs/mcp-servers.md +121 -414
  39. package/docs/mcp-transports.md +30 -289
  40. package/docs/models-pi-ai.md +5 -1
  41. package/docs/routing.md +0 -2
  42. package/docs/securing-mcp-servers.md +7 -2
  43. package/package.json +11 -6
  44. package/dist/lifecycle-ClT4DmF2.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { i as _classPrivateFieldInitSpec, n as _classPrivateFieldSet2, r as _assertClassBrand, t as _classPrivateFieldGet2 } from "../../../classPrivateFieldGet2-DZBYAB34.js";
2
2
  import { t as _classPrivateMethodInitSpec } from "../../../classPrivateMethodInitSpec-qMjJ6sHQ.js";
3
- import { a as getConnectionFlag, l as registerInternalConnectionKeys, t as WebSockets, u as setConnectionFlag } from "../../../websockets-CqxnntmE.js";
3
+ import { a as getConnectionFlag, l as registerInternalConnectionKeys, t as WebSockets, u as setConnectionFlag } from "../../../websockets-CyoeosdO.js";
4
4
  import { i as participantRoute } from "../../../internal-kmw70xwR.js";
5
5
  import { n as parseClientFrame, t as WEB_IDENTITY_HEADER } from "../../../protocol-y2sSY584.js";
6
6
  //#region src/experimental/channels/web/channel.ts
@@ -1,7 +1,7 @@
1
1
  import { i as _classPrivateFieldInitSpec, n as _classPrivateFieldSet2, r as _assertClassBrand, t as _classPrivateFieldGet2 } from "../../classPrivateFieldGet2-DZBYAB34.js";
2
2
  import { t as _classPrivateMethodInitSpec } from "../../classPrivateMethodInitSpec-qMjJ6sHQ.js";
3
3
  import { t as LifecycleCapability } from "../../capability-DBAKc6UZ.js";
4
- import "../../lifecycle-ClT4DmF2.js";
4
+ import "../../lifecycle-v1rKHV2C.js";
5
5
  import { n as openHarnessStore } from "../../store-CslVzfN7.js";
6
6
  import { d as parseDaemonMessage, i as CONTAINER_HEALTH_PATH, l as chunkEntries, o as CONTAINER_SESSION_PATH, r as CONTAINER_ENV, s as CONTAINER_TOKEN_HEADER } from "../../protocol-cOklVBBD.js";
7
7
  import { WorkerEntrypoint } from "cloudflare:workers";
@@ -1,7 +1,7 @@
1
1
  import { i as _classPrivateFieldInitSpec, n as _classPrivateFieldSet2, r as _assertClassBrand, t as _classPrivateFieldGet2 } from "../../classPrivateFieldGet2-DZBYAB34.js";
2
2
  import { t as _classPrivateMethodInitSpec } from "../../classPrivateMethodInitSpec-qMjJ6sHQ.js";
3
3
  import { t as LifecycleCapability } from "../../capability-DBAKc6UZ.js";
4
- import "../../lifecycle-ClT4DmF2.js";
4
+ import "../../lifecycle-v1rKHV2C.js";
5
5
  //#region src/harness/table-prefix.ts
6
6
  /**
7
7
  * A view of `storage` whose SQL is rewritten into `prefix`'s namespace.
@@ -15,32 +15,12 @@ import {
15
15
  Harness,
16
16
  InputEntry,
17
17
  ToolRegistration,
18
- UserInput
18
+ UserInput,
19
+ Wake
19
20
  } from "@earendil-works/pi-durable";
21
+ import { Context as Context$1 } from "@earendil-works/chord/context";
20
22
  import { SqliteStorage } from "@earendil-works/pi-durable/storage/sqlite";
21
23
 
22
- //#region src/harness/pi/context.d.ts
23
- /**
24
- * pi's invocation context, as `@earendil-works/chord` defines it.
25
- *
26
- * pi-durable takes a chord `Context` on every call but does not re-export
27
- * the type or its constructors. The harness needs only a background context
28
- * and a way to add an abort signal, so both are inlined here instead of
29
- * depending on chord directly. A chord `Context` is a plain structural
30
- * interface (an abort signal, keyed values, and a name), so these interoperate
31
- * with chord's own contexts inside pi.
32
- *
33
- * One limit: chord's own derived contexts read the abort signal through a
34
- * private key rather than `abortSignal`, so a chord `withContextValue`
35
- * wrapped around one of these would not see its signal. pi-durable does not
36
- * use `withContextValue` to wrap a caller's context that way; `withAbortSignal`
37
- * and `withCancel` read `abortSignal` and work.
38
- *
39
- * If pi-durable starts re-exporting chord's context helpers, replace this
40
- * file with those.
41
- */
42
- type Context$1 = Parameters<Harness["close"]>[0];
43
- //#endregion
44
24
  //#region src/harness/pi/types.d.ts
45
25
  /**
46
26
  * `PiHarness`'s own types: how the harness addresses sessions and reports
@@ -94,8 +74,13 @@ type PiPromptResponse = PiOperationResult & {
94
74
  /** A submission pi has not settled yet. */
95
75
  type PiPendingOperation = {
96
76
  readonly operationId: string;
97
- readonly session: PiSessionId /** `queued` in pi's inbox, or `running` as part of the current run. */;
98
- readonly status: "queued" | "running";
77
+ readonly session: PiSessionId;
78
+ /**
79
+ * `queued` in pi's inbox, or `running` as part of the current run.
80
+ * `parked`: running, but pi's crash-loop guard (`settings.restartLimit`)
81
+ * stopped a task of the session; `retry()` runs it again.
82
+ */
83
+ readonly status: "queued" | "running" | "parked";
99
84
  };
100
85
  type PiSessionInfo = {
101
86
  readonly id: PiSessionId /** The session this one was forked from. */;
@@ -107,22 +92,37 @@ type PiSessionInfo = {
107
92
  /** The root session's id. */
108
93
  declare const ROOT_SESSION: PiSessionId;
109
94
  /**
110
- * What the factory is handed: the two things only the harness can build.
95
+ * What the factory is handed: the things only the harness can build.
111
96
  * Everything else `Harness.open` takes (models, registry, settings, env,
112
97
  * onReport) the factory builds itself.
113
98
  */
114
99
  type PiHarnessContext = {
115
100
  /** pi's storage over this object's SQLite, its migrations already run. */ readonly storage: SqliteStorage /** Background context, for the open itself. */;
116
101
  readonly context: Context$1;
102
+ /**
103
+ * Pass this to `Harness.open` as its `onWake` option. pi calls it when it
104
+ * next needs to run, and the harness sets this object's alarm for then.
105
+ *
106
+ * With it, pi sets no in-memory timer for a sleeping task (a retry
107
+ * backoff, a poll, a `sleepUntil`), so the object can hibernate until the
108
+ * alarm. Without it the harness still works, but pi's timer keeps the
109
+ * object in memory, and billed, while a task sleeps, and the harness logs
110
+ * a warning when it opens pi.
111
+ *
112
+ * The harness reads pi's wake times against `Date.now()`, so do not pass
113
+ * `now` to `Harness.open`.
114
+ */
115
+ readonly onWake: (wake: Wake) => void;
117
116
  };
118
117
  /**
119
- * Opens pi's `Harness`. The harness adopts what it returns.
118
+ * Opens pi's `Harness`. The harness adopts what it returns. Pass `onWake`
119
+ * through to `Harness.open`.
120
120
  *
121
121
  * ```ts
122
- * harness: async ({ storage, context }) => {
122
+ * harness: async ({ storage, context, onWake }) => {
123
123
  * const registry = createRegistry();
124
124
  * registry.install(await skills(sources));
125
- * return Harness.open(storage, { models, registry }, context);
125
+ * return Harness.open(storage, { models, registry, onWake }, context);
126
126
  * }
127
127
  * ```
128
128
  */
@@ -169,12 +169,14 @@ type PiHarnessOptions = {
169
169
  *
170
170
  * What pi cannot do on a Durable Object is wake itself: its scheduler runs
171
171
  * in memory, and an evicted object has no memory. The harness is that wake,
172
- * with one Lifecycle job per session. Input goes to pi once, in `submit()`,
173
- * after the session's job is scheduled. The job waits while pi has live
174
- * tasks in the session, rescheduling itself as a heartbeat, and completes
175
- * when there are none. An eviction mid-run leaves the job due, so its alarm
176
- * restarts the object, pi reopens and resumes its own tasks, and the job
177
- * waits again.
172
+ * with one Lifecycle job driven by `pi.wake()`. Input goes to pi once, in
173
+ * `submit()`, after the job is scheduled. While pi has work running, the
174
+ * job waits on it, rescheduling itself as a heartbeat. While pi's tasks
175
+ * sleep, the job is due when the first one wakes; pi tells the harness
176
+ * through the `onWake` the factory passes to `Harness.open`. When pi has
177
+ * nothing to do, the job completes. An eviction mid-run leaves the job due,
178
+ * so its alarm restarts the object, pi reopens and resumes its own tasks,
179
+ * and the job waits again.
178
180
  *
179
181
  * @beta The API may change between releases.
180
182
  */
@@ -184,6 +186,16 @@ declare class PiHarness extends LifecycleCapability {
184
186
  constructor(options: PiHarnessOptions);
185
187
  onStart(_context: CapabilityStartContext): Promise<void>;
186
188
  onJob(context: LifecycleJobContext): Promise<LifecycleJobOutcome | void>;
189
+ /**
190
+ * A wake dispatch that failed through Lifecycle's retries, as when pi
191
+ * cannot be opened. Lifecycle would complete the job, and pi's work would
192
+ * never be woken again, so try again later: at the heartbeat, doubling
193
+ * while the failures continue, up to 10 minutes.
194
+ */
195
+ onJobError(
196
+ context: LifecycleJobContext,
197
+ error: unknown
198
+ ): LifecycleJobOutcome | void;
187
199
  /** Close pi's in-memory resources. Durable state is untouched. */
188
200
  dispose(): Promise<void>;
189
201
  /** A handle on one session. No I/O until you call it. */
@@ -201,6 +213,11 @@ declare class PiHarness extends LifecycleCapability {
201
213
  readonly operationId?: string;
202
214
  }
203
215
  ): Promise<boolean>;
216
+ /**
217
+ * Run again the tasks pi's crash-loop guard parked in a session's work.
218
+ * False when nothing was parked.
219
+ */
220
+ retry(options?: PiSessionOptions): Promise<boolean>;
204
221
  wait(
205
222
  operationId: string,
206
223
  options?: PiSessionOptions & {
@@ -223,6 +240,8 @@ declare class PiHarness extends LifecycleCapability {
223
240
  input: UserInput,
224
241
  options: PiSubmitOptions
225
242
  ): Promise<PiReceipt>;
243
+ /** @internal Run again the tasks pi's restart limit parked in a session. */
244
+ retryParked(session: PiSessionId): Promise<boolean>;
226
245
  /** @internal Withdraw a queued input, or abort the run it joined. */
227
246
  withdraw(session: PiSessionId, operationId: string): Promise<boolean>;
228
247
  /** @internal Wait for pi to settle an operation, by its request id. */
@@ -259,6 +278,12 @@ declare class PiSession {
259
278
  * running work.
260
279
  */
261
280
  abort(operationId?: string): Promise<boolean>;
281
+ /**
282
+ * Run again the tasks pi's crash-loop guard (`settings.restartLimit`)
283
+ * parked in this session's work, including subagent sessions it owns.
284
+ * False when nothing was parked.
285
+ */
286
+ retry(): Promise<boolean>;
262
287
  /** Start a new context, optionally from a handoff note. */
263
288
  reset(handoff?: string): Promise<void>;
264
289
  /**