agents 0.29.0 → 0.30.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.
Files changed (35) hide show
  1. package/dist/browser/tools/pi.d.ts +6 -2
  2. package/dist/browser/tools/pi.js +6 -2
  3. package/dist/browser/tools/pi.js.map +1 -1
  4. package/dist/chat-sdk/index.js +1 -1
  5. package/dist/cli.js +46 -45
  6. package/dist/experimental/channels/web/index.js +1 -1
  7. package/dist/harness/container/index.js +1 -1
  8. package/dist/harness/opencode/index.js +1 -1
  9. package/dist/harness/pi/index.d.ts +57 -35
  10. package/dist/harness/pi/index.js +261 -119
  11. package/dist/harness/pi/index.js.map +1 -1
  12. package/dist/index.js +1 -1
  13. package/dist/lifecycle/index.js +1 -1
  14. package/dist/{lifecycle-ClT4DmF2.js → lifecycle-v1rKHV2C.js} +57 -17
  15. package/dist/lifecycle-v1rKHV2C.js.map +1 -0
  16. package/dist/mcp/index.js +1 -1
  17. package/dist/models/pi-ai/index.js +2 -2
  18. package/dist/models/pi-ai/index.js.map +1 -1
  19. package/dist/{src-6lr7MtM_.js → src-DfLzdwlK.js} +3 -3
  20. package/dist/{src-6lr7MtM_.js.map → src-DfLzdwlK.js.map} +1 -1
  21. package/dist/web/fetch/tools/pi.d.ts +10 -6
  22. package/dist/web/fetch/tools/pi.js +10 -6
  23. package/dist/web/fetch/tools/pi.js.map +1 -1
  24. package/dist/web/search/tools/pi.d.ts +10 -6
  25. package/dist/web/search/tools/pi.js +10 -6
  26. package/dist/web/search/tools/pi.js.map +1 -1
  27. package/dist/websockets/index.js +1 -1
  28. package/dist/{websockets-CqxnntmE.js → websockets-CyoeosdO.js} +2 -2
  29. package/dist/{websockets-CqxnntmE.js.map → websockets-CyoeosdO.js.map} +1 -1
  30. package/dist/workflows.js +1 -1
  31. package/docs/harnesses/pi.md +62 -28
  32. package/docs/lifecycle.md +7 -1
  33. package/docs/models-pi-ai.md +5 -1
  34. package/package.json +11 -6
  35. 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,34 @@ 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
+ readonly onWake: (wake: Wake) => void;
117
113
  };
118
114
  /**
119
- * Opens pi's `Harness`. The harness adopts what it returns.
115
+ * Opens pi's `Harness`. The harness adopts what it returns. Pass `onWake`
116
+ * through to `Harness.open`.
120
117
  *
121
118
  * ```ts
122
- * harness: async ({ storage, context }) => {
119
+ * harness: async ({ storage, context, onWake }) => {
123
120
  * const registry = createRegistry();
124
121
  * registry.install(await skills(sources));
125
- * return Harness.open(storage, { models, registry }, context);
122
+ * return Harness.open(storage, { models, registry, onWake }, context);
126
123
  * }
127
124
  * ```
128
125
  */
@@ -169,12 +166,14 @@ type PiHarnessOptions = {
169
166
  *
170
167
  * What pi cannot do on a Durable Object is wake itself: its scheduler runs
171
168
  * 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.
169
+ * with one Lifecycle job driven by `pi.wake()`. Input goes to pi once, in
170
+ * `submit()`, after the job is scheduled. While pi has work running, the
171
+ * job waits on it, rescheduling itself as a heartbeat. While pi's tasks
172
+ * sleep, the job is due when the first one wakes; pi tells the harness
173
+ * through the `onWake` the factory passes to `Harness.open`. When pi has
174
+ * nothing to do, the job completes. An eviction mid-run leaves the job due,
175
+ * so its alarm restarts the object, pi reopens and resumes its own tasks,
176
+ * and the job waits again.
178
177
  *
179
178
  * @beta The API may change between releases.
180
179
  */
@@ -184,6 +183,16 @@ declare class PiHarness extends LifecycleCapability {
184
183
  constructor(options: PiHarnessOptions);
185
184
  onStart(_context: CapabilityStartContext): Promise<void>;
186
185
  onJob(context: LifecycleJobContext): Promise<LifecycleJobOutcome | void>;
186
+ /**
187
+ * A wake dispatch that failed through Lifecycle's retries, as when pi
188
+ * cannot be opened. Lifecycle would complete the job, and pi's work would
189
+ * never be woken again, so try again later: at the heartbeat, doubling
190
+ * while the failures continue, up to 10 minutes.
191
+ */
192
+ onJobError(
193
+ context: LifecycleJobContext,
194
+ error: unknown
195
+ ): LifecycleJobOutcome | void;
187
196
  /** Close pi's in-memory resources. Durable state is untouched. */
188
197
  dispose(): Promise<void>;
189
198
  /** A handle on one session. No I/O until you call it. */
@@ -201,6 +210,11 @@ declare class PiHarness extends LifecycleCapability {
201
210
  readonly operationId?: string;
202
211
  }
203
212
  ): Promise<boolean>;
213
+ /**
214
+ * Run again the tasks pi's crash-loop guard parked in a session's work.
215
+ * False when nothing was parked.
216
+ */
217
+ retry(options?: PiSessionOptions): Promise<boolean>;
204
218
  wait(
205
219
  operationId: string,
206
220
  options?: PiSessionOptions & {
@@ -223,6 +237,8 @@ declare class PiHarness extends LifecycleCapability {
223
237
  input: UserInput,
224
238
  options: PiSubmitOptions
225
239
  ): Promise<PiReceipt>;
240
+ /** @internal Run again the tasks pi's restart limit parked in a session. */
241
+ retryParked(session: PiSessionId): Promise<boolean>;
226
242
  /** @internal Withdraw a queued input, or abort the run it joined. */
227
243
  withdraw(session: PiSessionId, operationId: string): Promise<boolean>;
228
244
  /** @internal Wait for pi to settle an operation, by its request id. */
@@ -259,6 +275,12 @@ declare class PiSession {
259
275
  * running work.
260
276
  */
261
277
  abort(operationId?: string): Promise<boolean>;
278
+ /**
279
+ * Run again the tasks pi's crash-loop guard (`settings.restartLimit`)
280
+ * parked in this session's work, including subagent sessions it owns.
281
+ * False when nothing was parked.
282
+ */
283
+ retry(): Promise<boolean>;
262
284
  /** Start a new context, optionally from a handoff note. */
263
285
  reset(handoff?: string): Promise<void>;
264
286
  /**