agents 0.31.0 → 0.33.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 (148) hide show
  1. package/dist/{agent-routing-wS1TimZ_.d.ts → agent-routing-vVMA7m8Y.d.ts} +6 -6
  2. package/dist/agent-routing.d.ts +1 -1
  3. package/dist/agent-tool-types.d.ts +1 -1
  4. package/dist/{agent-tools-Bamxxb6Y.d.ts → agent-tools-gGXXkf1z.d.ts} +2 -2
  5. package/dist/agent-tools.d.ts +1 -1
  6. package/dist/agent-tools.js +0 -1
  7. package/dist/agent-tools.js.map +1 -1
  8. package/dist/{ai-sdk-hW3vntnk.d.ts → ai-sdk-CpuRsjP5.d.ts} +2 -2
  9. package/dist/browser/ai.js +2 -3
  10. package/dist/browser/ai.js.map +1 -1
  11. package/dist/browser/index.d.ts +29 -21
  12. package/dist/browser/index.js +937 -4
  13. package/dist/browser/index.js.map +1 -0
  14. package/dist/browser/tools/ai-sdk.d.ts +5 -5
  15. package/dist/browser/tools/ai-sdk.js +9 -3
  16. package/dist/browser/tools/ai-sdk.js.map +1 -1
  17. package/dist/browser/tools/pi.d.ts +11 -8
  18. package/dist/browser/tools/pi.js +58 -11
  19. package/dist/browser/tools/pi.js.map +1 -1
  20. package/dist/browser/tools/tanstack-ai.d.ts +6 -6
  21. package/dist/browser/tools/tanstack-ai.js +3 -3
  22. package/dist/browser/tools/tanstack-ai.js.map +1 -1
  23. package/dist/{browser-D9RNpJuT.d.ts → browser-CI97khiJ.d.ts} +222 -94
  24. package/dist/{browser-tool-BhjCcNVE.d.ts → browser-tool-Cxtiwfua.d.ts} +2 -2
  25. package/dist/browser-tool-DOqT1oSD.js +360 -0
  26. package/dist/browser-tool-DOqT1oSD.js.map +1 -0
  27. package/dist/catalog-BpOejOsE.js +239 -0
  28. package/dist/catalog-BpOejOsE.js.map +1 -0
  29. package/dist/catalog-BpiVV1OF.d.ts +173 -0
  30. package/dist/chat/index.d.ts +2 -2
  31. package/dist/chat/react.js +1 -0
  32. package/dist/chat/react.js.map +1 -1
  33. package/dist/chat-sdk/index.d.ts +1 -1
  34. package/dist/chat-sdk/index.js +1 -1
  35. package/dist/cli.js +63 -62
  36. package/dist/{client-wn4-yqGz.d.ts → client-eSfgYvd3.d.ts} +2 -2
  37. package/dist/client.d.ts +1 -1
  38. package/dist/{cloudflare-Dzvc7V2N.js → cloudflare-CUUm_9q9.js} +26 -4
  39. package/dist/cloudflare-CUUm_9q9.js.map +1 -0
  40. package/dist/{connector-CM-uuxKM.js → connector-Dl098To-.js} +402 -3
  41. package/dist/connector-Dl098To-.js.map +1 -0
  42. package/dist/{do-oauth-client-provider-DfsUcpc3.d.ts → do-oauth-client-provider-DtNqv7oj.d.ts} +26 -2
  43. package/dist/{index-YSKgfgg9.d.ts → emitter-BJZtCVjQ.d.ts} +6 -140
  44. package/dist/emitter-DPOVcCln.js +15 -0
  45. package/dist/emitter-DPOVcCln.js.map +1 -0
  46. package/dist/experimental/channels/web/index.js +1 -1
  47. package/dist/experimental/webmcp.js +1 -1
  48. package/dist/harness/container/index.js +0 -1
  49. package/dist/harness/container/index.js.map +1 -1
  50. package/dist/harness/container/runtime/index.js +2 -2
  51. package/dist/harness/opencode/index.js +0 -1
  52. package/dist/harness/opencode/index.js.map +1 -1
  53. package/dist/harness/pi/index.d.ts +84 -30
  54. package/dist/harness/pi/index.js +120 -224
  55. package/dist/harness/pi/index.js.map +1 -1
  56. package/dist/index.d.ts +2 -3
  57. package/dist/index.js +2 -2
  58. package/dist/{input-schema-BQykTEp_.js → input-schema-0uUu392-.js} +2 -2
  59. package/dist/input-schema-0uUu392-.js.map +1 -0
  60. package/dist/{input-schema-B0Etuo-o.js → input-schema-waggtYrH.js} +2 -2
  61. package/dist/input-schema-waggtYrH.js.map +1 -0
  62. package/dist/markdown-BZ-VLtA1.js +86 -0
  63. package/dist/markdown-BZ-VLtA1.js.map +1 -0
  64. package/dist/mcp/client/do-oauth-client-provider.d.ts +4 -2
  65. package/dist/mcp/client/do-oauth-client-provider.js +15 -1
  66. package/dist/mcp/client/do-oauth-client-provider.js.map +1 -1
  67. package/dist/mcp/client/index.d.ts +1 -1
  68. package/dist/mcp/client/x402.d.ts +8 -8
  69. package/dist/mcp/index.d.ts +2 -2
  70. package/dist/mcp/index.js +4 -4
  71. package/dist/mcp/index.js.map +1 -1
  72. package/dist/models/pi-ai/index.js +12 -15
  73. package/dist/models/pi-ai/index.js.map +1 -1
  74. package/dist/observability/ai/index.js +1 -2
  75. package/dist/observability/ai/index.js.map +1 -1
  76. package/dist/observability/index.d.ts +170 -9
  77. package/dist/observability/index.js +386 -11
  78. package/dist/observability/index.js.map +1 -1
  79. package/dist/react.d.ts +2 -2
  80. package/dist/resource-B59OV2a2.js +325 -0
  81. package/dist/resource-B59OV2a2.js.map +1 -0
  82. package/dist/routing/index.d.ts +1 -1
  83. package/dist/script-CFDLTk5b.d.ts +91 -0
  84. package/dist/script-workspace-BpdAYq1R.d.ts +41 -0
  85. package/dist/serializable.d.ts +1 -1
  86. package/dist/{session-7CDgVE0z.js → session-CRY0bGiI.js} +423 -411
  87. package/dist/session-CRY0bGiI.js.map +1 -0
  88. package/dist/skill-DRBcIBjC.d.ts +221 -0
  89. package/dist/skills/index.d.ts +275 -36
  90. package/dist/skills/index.js +265 -1534
  91. package/dist/skills/index.js.map +1 -1
  92. package/dist/skills/runner.d.ts +37 -0
  93. package/dist/skills/runner.js +912 -0
  94. package/dist/skills/runner.js.map +1 -0
  95. package/dist/skills/tools/ai-sdk.d.ts +36 -0
  96. package/dist/skills/tools/ai-sdk.js +94 -0
  97. package/dist/skills/tools/ai-sdk.js.map +1 -0
  98. package/dist/source-9RQzlEhM.d.ts +112 -0
  99. package/dist/{src-BGolXG_H.js → src-DoGNJ4Ud.js} +4 -5
  100. package/dist/src-DoGNJ4Ud.js.map +1 -0
  101. package/dist/sub-routing.d.ts +1 -1
  102. package/dist/tool-CxKsvxjm.js.map +1 -1
  103. package/dist/tool-DkT_DJBm.js.map +1 -1
  104. package/dist/{tool-helpers-BodWi4gd.js → tool-helpers-F3_Wy2YX.js} +2 -3
  105. package/dist/{tool-helpers-BodWi4gd.js.map → tool-helpers-F3_Wy2YX.js.map} +1 -1
  106. package/dist/vite.d.ts +2 -2
  107. package/dist/vite.js +10 -258
  108. package/dist/vite.js.map +1 -1
  109. package/dist/voice/index.d.ts +1 -1
  110. package/dist/web/fetch/tools/ai-sdk.js +1 -1
  111. package/dist/web/fetch/tools/pi.d.ts +4 -7
  112. package/dist/web/fetch/tools/pi.js +7 -6
  113. package/dist/web/fetch/tools/pi.js.map +1 -1
  114. package/dist/web/fetch/tools/tanstack-ai.js +1 -1
  115. package/dist/web/search/tools/ai-sdk.js +1 -1
  116. package/dist/web/search/tools/pi.d.ts +5 -4
  117. package/dist/web/search/tools/pi.js +5 -10
  118. package/dist/web/search/tools/pi.js.map +1 -1
  119. package/dist/web/search/tools/tanstack-ai.js +1 -1
  120. package/dist/websockets/index.js +1 -1
  121. package/dist/{websockets-CyoeosdO.js → websockets-C6SJtWCJ.js} +1 -2
  122. package/dist/{websockets-CyoeosdO.js.map → websockets-C6SJtWCJ.js.map} +1 -1
  123. package/dist/workflow-types.d.ts +1 -1
  124. package/dist/workflows.d.ts +1 -1
  125. package/dist/workflows.js +0 -1
  126. package/dist/workflows.js.map +1 -1
  127. package/docs/browse-the-web.md +36 -3
  128. package/docs/harnesses/pi.md +59 -33
  129. package/docs/mcp-client.md +23 -1
  130. package/docs/mcp-servers.md +2 -2
  131. package/docs/models-pi-ai.md +1 -1
  132. package/docs/observability.md +5 -3
  133. package/package.json +37 -22
  134. package/dist/browser-1eUbPvC2.js +0 -931
  135. package/dist/browser-1eUbPvC2.js.map +0 -1
  136. package/dist/browser-tool-lGnvEBLJ.js +0 -497
  137. package/dist/browser-tool-lGnvEBLJ.js.map +0 -1
  138. package/dist/cloudflare-Dzvc7V2N.js.map +0 -1
  139. package/dist/connector-CM-uuxKM.js.map +0 -1
  140. package/dist/index-iv9FTXX9.d.ts +0 -311
  141. package/dist/input-schema-B0Etuo-o.js.map +0 -1
  142. package/dist/input-schema-BQykTEp_.js.map +0 -1
  143. package/dist/session-7CDgVE0z.js.map +0 -1
  144. package/dist/skills/compile.d.ts +0 -40
  145. package/dist/skills/compile.js +0 -65
  146. package/dist/skills/compile.js.map +0 -1
  147. package/dist/src-BGolXG_H.js.map +0 -1
  148. package/skills-module.d.ts +0 -22
@@ -4,21 +4,24 @@ import {
4
4
  s as LifecycleCapability,
5
5
  v as LifecycleJobOutcome
6
6
  } from "../../capability-runner-BiVUtjqC.js";
7
- import { S as SkillSource } from "../../index-iv9FTXX9.js";
8
- import { Api, Model, ModelThinkingLevel } from "@earendil-works/pi-ai";
7
+ import { a as SkillSource } from "../../source-9RQzlEhM.js";
9
8
  import {
10
9
  AgentChange,
11
- AgentEventStream,
12
10
  Conversation,
11
+ ConversationWatch,
12
+ ConversationWindow,
13
+ Cursor,
14
+ EntryQuery,
13
15
  EntryRecord,
14
16
  Extension,
15
17
  Harness,
16
18
  InputEntry,
17
- ToolRegistration,
19
+ Page,
18
20
  UserInput,
19
21
  Wake
20
22
  } from "@earendil-works/pi-durable";
21
- import { Context as Context$1 } from "@earendil-works/chord/context";
23
+ import { Context } from "@earendil-works/chord/context";
24
+ import { Api, Model, ModelThinkingLevel } from "@earendil-works/pi-ai";
22
25
  import { SqliteStorage } from "@earendil-works/pi-durable/storage/sqlite";
23
26
 
24
27
  //#region src/harness/pi/types.d.ts
@@ -39,10 +42,21 @@ type PiSessionId = string;
39
42
  * submitted again later. Use it to submit only if idle, atomically.
40
43
  */
41
44
  type PiWhenBusy = "followUp" | "steer" | "reject";
45
+ /**
46
+ * What a submission does when the session is idle.
47
+ *
48
+ * - unset (default): starts a run.
49
+ * - `reject`: not admitted. `submit()` rejects with pi-durable's
50
+ * `ConversationIdle` and saves nothing. With `whenBusy: "steer"`, the
51
+ * input joins the running work or is refused, in one step that cannot
52
+ * race the run's end.
53
+ */
54
+ type PiWhenIdle = "reject";
42
55
  type PiSubmitOptions = {
43
56
  /** Default: the root session. */ readonly session?: PiSessionId /** Idempotency key. Submitting the same id twice returns the same receipt. */;
44
57
  readonly operationId?: string;
45
58
  readonly whenBusy?: PiWhenBusy;
59
+ readonly whenIdle?: PiWhenIdle;
46
60
  /**
47
61
  * The transcript entry the input is placed as, instead of pi's `pi.user`:
48
62
  * for input the user did not type, such as a scheduled prompt, a webhook,
@@ -52,6 +66,9 @@ type PiSubmitOptions = {
52
66
  */
53
67
  readonly entry?: InputEntry;
54
68
  };
69
+ type PiContinueOptions = {
70
+ /** Idempotency key. Continuing with the same id twice returns the same receipt. */ readonly operationId?: string;
71
+ };
55
72
  type PiSessionOptions = {
56
73
  /** Default: the root session. */ readonly session?: PiSessionId;
57
74
  };
@@ -77,13 +94,8 @@ type PiPromptResponse = PiOperationResult & {
77
94
  /** A submission pi has not settled yet. */
78
95
  type PiPendingOperation = {
79
96
  readonly operationId: string;
80
- readonly session: PiSessionId;
81
- /**
82
- * `queued` in pi's inbox, or `running` as part of the current run.
83
- * `parked`: running, but pi's crash-loop guard (`settings.restartLimit`)
84
- * stopped a task of the session; `retry()` runs it again.
85
- */
86
- readonly status: "queued" | "running" | "parked";
97
+ readonly session: PiSessionId /** `queued` in pi's inbox, or `running` as part of the current run. */;
98
+ readonly status: "queued" | "running";
87
99
  };
88
100
  type PiSessionInfo = {
89
101
  readonly id: PiSessionId /** The session this one was forked from. */;
@@ -101,7 +113,7 @@ declare const ROOT_SESSION: PiSessionId;
101
113
  */
102
114
  type PiHarnessContext = {
103
115
  /** pi's storage over this object's SQLite, its migrations already run. */ readonly storage: SqliteStorage /** Background context, for the open itself. */;
104
- readonly context: Context$1;
116
+ readonly context: Context;
105
117
  /**
106
118
  * Pass this to `Harness.open` as its `onWake` option. pi calls it when it
107
119
  * next needs to run, and the harness sets this object's alarm for then.
@@ -154,6 +166,12 @@ type PiSessionDefaults = {
154
166
  */
155
167
  readonly model?: PiModel;
156
168
  readonly thinkingLevel?: ModelThinkingLevel;
169
+ /**
170
+ * Most tool rounds one run takes: the round that reaches it runs its
171
+ * tools, then the run's operations end unanswered with reason
172
+ * `turn_limit`. An integer, 1 or more. Default: no limit.
173
+ */
174
+ readonly maxTurns?: number;
157
175
  };
158
176
  /** `PiHarness`'s options. Only `harness`, which opens pi, is required. */
159
177
  type PiHarnessOptions = {
@@ -208,17 +226,17 @@ declare class PiHarness extends LifecycleCapability {
208
226
  ): Promise<PiPromptResponse>;
209
227
  /** Durably submit a prompt. Resolves before the model runs. */
210
228
  submit(input: UserInput, options?: PiSubmitOptions): Promise<PiReceipt>;
229
+ /**
230
+ * Run an idle session again on its transcript as it is, without new input.
231
+ * See `PiSession.continue`.
232
+ */
233
+ continue(options?: PiSessionOptions & PiContinueOptions): Promise<PiReceipt>;
211
234
  /** Stop one operation, or everything running in a session. */
212
235
  abort(
213
236
  options?: PiSessionOptions & {
214
237
  readonly operationId?: string;
215
238
  }
216
239
  ): Promise<boolean>;
217
- /**
218
- * Run again the tasks pi's crash-loop guard parked in a session's work.
219
- * False when nothing was parked.
220
- */
221
- retry(options?: PiSessionOptions): Promise<boolean>;
222
240
  wait(
223
241
  operationId: string,
224
242
  options?: PiSessionOptions & {
@@ -241,8 +259,11 @@ declare class PiHarness extends LifecycleCapability {
241
259
  input: UserInput,
242
260
  options: PiSubmitOptions
243
261
  ): Promise<PiReceipt>;
244
- /** @internal Run again the tasks pi's restart limit parked in a session. */
245
- retryParked(session: PiSessionId): Promise<boolean>;
262
+ /** @internal Start a run on the context as it is, without new input. */
263
+ enqueueContinue(
264
+ session: PiSessionId,
265
+ options: PiContinueOptions
266
+ ): Promise<PiReceipt>;
246
267
  /** @internal Withdraw a queued input, or abort the run it joined. */
247
268
  withdraw(session: PiSessionId, operationId: string): Promise<boolean>;
248
269
  /** @internal Wait for pi to settle an operation, by its request id. */
@@ -266,6 +287,14 @@ declare class PiSession {
266
287
  input: UserInput,
267
288
  options?: PiSubmitOptions
268
289
  ): Promise<PiPromptResponse>;
290
+ /**
291
+ * Start a run on the transcript as it is, without a new message: for
292
+ * example, after a run ended unanswered because the model failed or the
293
+ * object kept crashing. Only an idle session takes one; a busy one rejects
294
+ * with pi-durable's `ConversationBusy`. A transcript that ends in an answer
295
+ * settles `unanswered` with reason `nothing_to_answer`.
296
+ */
297
+ continue(options?: PiContinueOptions): Promise<PiReceipt>;
269
298
  /** Join the running work after its current tool round. */
270
299
  steer(
271
300
  input: UserInput,
@@ -279,12 +308,6 @@ declare class PiSession {
279
308
  * running work.
280
309
  */
281
310
  abort(operationId?: string): Promise<boolean>;
282
- /**
283
- * Run again the tasks pi's crash-loop guard (`settings.restartLimit`)
284
- * parked in this session's work, including subagent sessions it owns.
285
- * False when nothing was parked.
286
- */
287
- retry(): Promise<boolean>;
288
311
  /** Start a new context, optionally from a handoff note. */
289
312
  reset(handoff?: string): Promise<void>;
290
313
  /**
@@ -294,8 +317,29 @@ declare class PiSession {
294
317
  setModel(model: PiModel): Promise<void>;
295
318
  /** The active transcript, as pi's entries since the newest reset. */
296
319
  messages(): Promise<EntryRecord[]>;
297
- /** pi's agent events for this session: a snapshot, then one batch per commit. */
298
- events(context?: Context$1): Promise<AgentEventStream>;
320
+ /**
321
+ * Watch this session: pi's conversation view, a window over the transcript
322
+ * with the session's documents, such as `pi.live` (the answer being
323
+ * streamed, running tools, and why the last run ended without an answer)
324
+ * and `pi.inbox`. The first value holds the newest entries; new entries
325
+ * are appended. Each change carries pi's operations, for a client that
326
+ * forwards them. To render more than the window, merge each value into a
327
+ * `ConversationTranscript` that pages with `entries()`.
328
+ */
329
+ watch(
330
+ window?: ConversationWindow,
331
+ context?: Context
332
+ ): Promise<ConversationWatch>;
333
+ /**
334
+ * A page of this session's transcript, newest first unless `query.order`
335
+ * is `ascending`, including entries before its resets. The loader a
336
+ * `ConversationTranscript` takes.
337
+ */
338
+ entries(
339
+ query: Omit<EntryQuery, "conversationId">,
340
+ limit: number,
341
+ context?: Context
342
+ ): Promise<Page<EntryRecord, Cursor>>;
299
343
  busy(): Promise<boolean>;
300
344
  }
301
345
  /** Every pi conversation in this object. */
@@ -345,15 +389,24 @@ declare function openPiSessionStore(
345
389
  /**
346
390
  * `agents/skills` sources as a pi extension, named `agents.skills`: the
347
391
  * activation tools and a `skills` system prompt section. Install it on
348
- * pi's registry in the harness factory.
392
+ * pi's registry in the harness factory. Sources are read once, when the
393
+ * extension is built.
349
394
  *
350
395
  * ```ts
351
- * registry.install(await skills(sources));
396
+ * import * as agentSkills from "agents/skills";
397
+ *
398
+ * registry.install(
399
+ * await skills([agentSkills.workspace(workspace), agentSkills.r2(env.SKILLS)])
400
+ * );
352
401
  * ```
402
+ *
403
+ * @param sources - Skill sources in priority order.
404
+ * @returns The pi extension.
353
405
  */
354
406
  declare function skills(sources: readonly SkillSource[]): Promise<Extension>;
355
407
  //#endregion
356
408
  export {
409
+ type PiContinueOptions,
357
410
  PiHarness,
358
411
  type PiHarnessContext,
359
412
  type PiHarnessFactory,
@@ -372,6 +425,7 @@ export {
372
425
  PiSessions,
373
426
  type PiSubmitOptions,
374
427
  type PiWhenBusy,
428
+ type PiWhenIdle,
375
429
  ROOT_SESSION,
376
430
  openPiSessionStore,
377
431
  skills