agents 0.32.0 → 0.34.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 (187) hide show
  1. package/README.md +1 -1
  2. package/dist/{agent-routing-vVMA7m8Y.d.ts → agent-routing-BSoZzNiP.d.ts} +537 -373
  3. package/dist/agent-routing.d.ts +1 -1
  4. package/dist/agent-tool-types.d.ts +1 -1
  5. package/dist/{agent-tools-gGXXkf1z.d.ts → agent-tools-Be-hpRpH.d.ts} +2 -2
  6. package/dist/agent-tools.d.ts +1 -1
  7. package/dist/{ai-sdk-Kon40i0q.js → ai-sdk-CRMlEBX7.js} +75 -44
  8. package/dist/ai-sdk-CRMlEBX7.js.map +1 -0
  9. package/dist/browser/ai.js +2 -3
  10. package/dist/browser/ai.js.map +1 -1
  11. package/dist/browser/index.d.ts +33 -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 +4 -4
  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 +4 -4
  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-C9T74n4c.d.ts} +302 -95
  24. package/dist/browser-tool-DOqT1oSD.js +360 -0
  25. package/dist/browser-tool-DOqT1oSD.js.map +1 -0
  26. package/dist/{browser-tool-BhjCcNVE.d.ts → browser-tool-DxAYQY9T.d.ts} +2 -2
  27. package/dist/capability-DBAKc6UZ.js.map +1 -1
  28. package/dist/{capability-runner-BiVUtjqC.d.ts → capability-runner-uFOdSANC.d.ts} +3 -2
  29. package/dist/chat/index.d.ts +37 -6
  30. package/dist/chat/index.js +39 -3
  31. package/dist/chat/index.js.map +1 -1
  32. package/dist/chat/react.js +1 -0
  33. package/dist/chat/react.js.map +1 -1
  34. package/dist/chat-sdk/index.d.ts +3 -3
  35. package/dist/chat-sdk/index.js +1 -1
  36. package/dist/cli.js +62 -60
  37. package/dist/client-CkT8voRY.js +3740 -0
  38. package/dist/client-CkT8voRY.js.map +1 -0
  39. package/dist/{client-eSfgYvd3.d.ts → client-DqS6oequ.d.ts} +2 -2
  40. package/dist/client.d.ts +1 -1
  41. package/dist/{connector-CM-uuxKM.js → connector-Bphz6wIw.js} +414 -3
  42. package/dist/connector-Bphz6wIw.js.map +1 -0
  43. package/dist/{conversations-FjHDRZyD.d.ts → conversations-CoAYNW_q.d.ts} +4 -4
  44. package/dist/{current-agent-CKgT5d1O.d.ts → current-agent-DShbQHDO.d.ts} +24 -3
  45. package/dist/current-agent-DhoDkSnH.js.map +1 -1
  46. package/dist/{do-oauth-client-provider-DtNqv7oj.d.ts → do-oauth-client-provider-BsT8-vtd.d.ts} +22 -2
  47. package/dist/{durable-object-lifecycle-DOI_bzCH.d.ts → durable-object-lifecycle-CRCA6O0W.d.ts} +2 -2
  48. package/dist/experimental/channels/index.d.ts +2 -2
  49. package/dist/experimental/channels/web/index.d.ts +2 -2
  50. package/dist/experimental/channels/web/index.js +1 -1
  51. package/dist/{gateway-BFO6vRDn.d.ts → gateway-Dz8zyZBJ.d.ts} +2 -2
  52. package/dist/harness/ai-sdk/index.d.ts +2 -2
  53. package/dist/harness/container/index.d.ts +2 -2
  54. package/dist/harness/container/index.js +1 -1
  55. package/dist/harness/container/index.js.map +1 -1
  56. package/dist/harness/opencode/index.d.ts +1 -1
  57. package/dist/harness/pi/index.d.ts +200 -37
  58. package/dist/harness/pi/index.js +202 -100
  59. package/dist/harness/pi/index.js.map +1 -1
  60. package/dist/harness/think/index.d.ts +2 -2
  61. package/dist/{images-CfuRCjwq.js → images-D4gtE06D.js} +119 -27
  62. package/dist/images-D4gtE06D.js.map +1 -0
  63. package/dist/{index-8k4qsX1T.d.ts → index-BXVgv6tp.d.ts} +4 -4
  64. package/dist/{index-BEL3ZV-s.d.ts → index-Cs7Ed9la.d.ts} +2 -2
  65. package/dist/{index-CBt8oRJt.d.ts → index-XiZxauMU.d.ts} +3 -3
  66. package/dist/index.d.ts +21 -21
  67. package/dist/index.js +2 -2
  68. package/dist/{input-schema-BQykTEp_.js → input-schema-D6GilRXI.js} +3 -3
  69. package/dist/input-schema-D6GilRXI.js.map +1 -0
  70. package/dist/{input-schema-B0Etuo-o.js → input-schema-y8W5bOdM.js} +3 -3
  71. package/dist/input-schema-y8W5bOdM.js.map +1 -0
  72. package/dist/internal_context.d.ts +1 -1
  73. package/dist/lifecycle/index.d.ts +3 -3
  74. package/dist/lifecycle/index.js +1 -1
  75. package/dist/{lifecycle-v1rKHV2C.js → lifecycle-CB5Dmtrt.js} +126 -38
  76. package/dist/lifecycle-CB5Dmtrt.js.map +1 -0
  77. package/dist/mcp/client/do-oauth-client-provider.d.ts +1 -1
  78. package/dist/mcp/client/do-oauth-client-provider.js +45 -2
  79. package/dist/mcp/client/do-oauth-client-provider.js.map +1 -1
  80. package/dist/mcp/client/index.d.ts +42 -36
  81. package/dist/mcp/client/index.js +2 -2
  82. package/dist/mcp/index.d.ts +16 -16
  83. package/dist/mcp/index.js +2 -2
  84. package/dist/models/ai-sdk/index.d.ts +9 -5
  85. package/dist/models/ai-sdk/index.js +1 -1
  86. package/dist/models/opencode/index.d.ts +3 -3
  87. package/dist/models/opencode/index.js +2 -2
  88. package/dist/models/opencode/index.js.map +1 -1
  89. package/dist/models/pi-ai/index.d.ts +4 -4
  90. package/dist/models/pi-ai/index.js +64 -170
  91. package/dist/models/pi-ai/index.js.map +1 -1
  92. package/dist/{options-CiIsJHXR.d.ts → options-CiXaymmZ.d.ts} +2 -2
  93. package/dist/queue/index.d.ts +1 -1
  94. package/dist/queue/index.js +1 -1
  95. package/dist/{queue-CcIjVYTE.js → queue-B_wl6K0Z.js} +24 -5
  96. package/dist/queue-B_wl6K0Z.js.map +1 -0
  97. package/dist/react.d.ts +2 -2
  98. package/dist/routing/index.d.ts +2 -2
  99. package/dist/{scheduler-BCLESHSC.d.ts → scheduler-CTpR0Ct0.d.ts} +2 -2
  100. package/dist/{scheduler-FIHv2-kJ.js → scheduler-DGNEmxQR.js} +2 -1
  101. package/dist/scheduler-DGNEmxQR.js.map +1 -0
  102. package/dist/schedules/index.d.ts +1 -1
  103. package/dist/schedules/index.js +1 -1
  104. package/dist/serializable.d.ts +1 -1
  105. package/dist/{session-7CDgVE0z.js → session-CRY0bGiI.js} +423 -411
  106. package/dist/session-CRY0bGiI.js.map +1 -0
  107. package/dist/sessions/index.d.ts +1 -1
  108. package/dist/{settings-Dk2il2Hf.js → settings-D2F_qONv.js} +11 -2
  109. package/dist/settings-D2F_qONv.js.map +1 -0
  110. package/dist/{src-DoGNJ4Ud.js → src-BO1FdLK1.js} +145 -86
  111. package/dist/src-BO1FdLK1.js.map +1 -0
  112. package/dist/state/index.d.ts +1 -1
  113. package/dist/streams/index.d.ts +1 -1
  114. package/dist/{streams-vrCtbUIn.d.ts → streams-CAZxZBDg.d.ts} +2 -2
  115. package/dist/sub-routing.d.ts +12 -12
  116. package/dist/tasks/index.d.ts +1 -1
  117. package/dist/tasks/index.js +1 -1
  118. package/dist/{tasks-BN_5AWqI.js → tasks-Cf_UfEO4.js} +2 -1
  119. package/dist/{tasks-BN_5AWqI.js.map → tasks-Cf_UfEO4.js.map} +1 -1
  120. package/dist/{tasks-E89KdwkS.d.ts → tasks-Cs8ilctE.d.ts} +2 -2
  121. package/dist/{tool-DkT_DJBm.js → tool-CmAGY6Fo.js} +24 -3
  122. package/dist/tool-CmAGY6Fo.js.map +1 -0
  123. package/dist/{tool-CxKsvxjm.js → tool-Kxcj8_22.js} +24 -4
  124. package/dist/tool-Kxcj8_22.js.map +1 -0
  125. package/dist/{tool-helpers-BI7ifO2S.js → tool-helpers-F3_Wy2YX.js} +2 -2
  126. package/dist/{tool-helpers-BI7ifO2S.js.map → tool-helpers-F3_Wy2YX.js.map} +1 -1
  127. package/dist/{transport-5moD2pW5.d.ts → transport-hV8AW4Bv.d.ts} +45 -12
  128. package/dist/voice/index.d.ts +2 -2
  129. package/dist/web/fetch/index.js +1 -1
  130. package/dist/web/fetch/tools/ai-sdk.js +2 -2
  131. package/dist/web/fetch/tools/pi.d.ts +9 -7
  132. package/dist/web/fetch/tools/pi.js +31 -7
  133. package/dist/web/fetch/tools/pi.js.map +1 -1
  134. package/dist/web/fetch/tools/tanstack-ai.js +2 -2
  135. package/dist/web/search/index.js +1 -1
  136. package/dist/web/search/tools/ai-sdk.js +2 -2
  137. package/dist/web/search/tools/pi.d.ts +9 -4
  138. package/dist/web/search/tools/pi.js +27 -11
  139. package/dist/web/search/tools/pi.js.map +1 -1
  140. package/dist/web/search/tools/tanstack-ai.js +2 -2
  141. package/dist/websockets/index.d.ts +2 -2
  142. package/dist/websockets/index.js +1 -1
  143. package/dist/{websockets-C6SJtWCJ.js → websockets-W4uhRg4-.js} +68 -5
  144. package/dist/websockets-W4uhRg4-.js.map +1 -0
  145. package/dist/workflow-types.d.ts +1 -1
  146. package/dist/workflows.d.ts +1 -1
  147. package/docs/agent-class.md +30 -4
  148. package/docs/browse-the-web.md +50 -3
  149. package/docs/chat-agents.md +13 -10
  150. package/docs/client-tools-continuation.md +1 -1
  151. package/docs/codemode.md +1 -1
  152. package/docs/configuration.md +6 -3
  153. package/docs/cross-domain-authentication.md +1 -1
  154. package/docs/fetch-the-web.md +20 -0
  155. package/docs/harnesses/pi.md +242 -33
  156. package/docs/harnesses/think.md +1 -1
  157. package/docs/http-websockets.md +40 -32
  158. package/docs/human-in-the-loop.md +2 -2
  159. package/docs/lifecycle.md +56 -0
  160. package/docs/mcp-client.md +104 -7
  161. package/docs/models-pi-ai.md +24 -10
  162. package/docs/models.md +42 -17
  163. package/docs/resumable-streaming.md +1 -1
  164. package/docs/retries.md +3 -6
  165. package/docs/search-the-web.md +10 -0
  166. package/docs/voice.md +1 -1
  167. package/package.json +16 -9
  168. package/dist/ai-sdk-Kon40i0q.js.map +0 -1
  169. package/dist/browser-1eUbPvC2.js +0 -931
  170. package/dist/browser-1eUbPvC2.js.map +0 -1
  171. package/dist/browser-tool-DRan7Lk6.js +0 -497
  172. package/dist/browser-tool-DRan7Lk6.js.map +0 -1
  173. package/dist/client-DMWujQJ1.js +0 -2325
  174. package/dist/client-DMWujQJ1.js.map +0 -1
  175. package/dist/connector-CM-uuxKM.js.map +0 -1
  176. package/dist/images-CfuRCjwq.js.map +0 -1
  177. package/dist/input-schema-B0Etuo-o.js.map +0 -1
  178. package/dist/input-schema-BQykTEp_.js.map +0 -1
  179. package/dist/lifecycle-v1rKHV2C.js.map +0 -1
  180. package/dist/queue-CcIjVYTE.js.map +0 -1
  181. package/dist/scheduler-FIHv2-kJ.js.map +0 -1
  182. package/dist/session-7CDgVE0z.js.map +0 -1
  183. package/dist/settings-Dk2il2Hf.js.map +0 -1
  184. package/dist/src-DoGNJ4Ud.js.map +0 -1
  185. package/dist/tool-CxKsvxjm.js.map +0 -1
  186. package/dist/tool-DkT_DJBm.js.map +0 -1
  187. package/dist/websockets-C6SJtWCJ.js.map +0 -1
@@ -3,7 +3,7 @@ import {
3
3
  n as CapabilityStartContext,
4
4
  s as LifecycleCapability,
5
5
  v as LifecycleJobOutcome
6
- } from "../../capability-runner-BiVUtjqC.js";
6
+ } from "../../capability-runner-uFOdSANC.js";
7
7
  import { OpenCodeWorkerd } from "@opencode/sdk/workerd";
8
8
 
9
9
  //#region src/harness/opencode/types.d.ts
@@ -3,21 +3,30 @@ import {
3
3
  n as CapabilityStartContext,
4
4
  s as LifecycleCapability,
5
5
  v as LifecycleJobOutcome
6
- } from "../../capability-runner-BiVUtjqC.js";
6
+ } from "../../capability-runner-uFOdSANC.js";
7
7
  import { a as SkillSource } from "../../source-9RQzlEhM.js";
8
- import { Api, Model, ModelThinkingLevel } from "@earendil-works/pi-ai";
9
8
  import {
10
9
  AgentChange,
11
- AgentEventStream,
12
10
  Conversation,
11
+ ConversationInit,
12
+ ConversationWatch,
13
+ ConversationWindow,
14
+ Cursor,
15
+ EntryQuery,
13
16
  EntryRecord,
14
17
  Extension,
15
18
  Harness,
16
19
  InputEntry,
20
+ Page,
21
+ SignalResult,
22
+ SignalToken,
23
+ SubmissionNotify,
24
+ TaskId,
17
25
  UserInput,
18
26
  Wake
19
27
  } from "@earendil-works/pi-durable";
20
- import { Context as Context$1 } from "@earendil-works/chord/context";
28
+ import { Context } from "@earendil-works/chord/context";
29
+ import { Api, Model, ModelThinkingLevel } from "@earendil-works/pi-ai";
21
30
  import { SqliteStorage } from "@earendil-works/pi-durable/storage/sqlite";
22
31
 
23
32
  //#region src/harness/pi/types.d.ts
@@ -38,10 +47,32 @@ type PiSessionId = string;
38
47
  * submitted again later. Use it to submit only if idle, atomically.
39
48
  */
40
49
  type PiWhenBusy = "followUp" | "steer" | "reject";
50
+ /**
51
+ * What a submission does when the session is idle.
52
+ *
53
+ * - unset (default): starts a run.
54
+ * - `reject`: not admitted. `submit()` rejects with pi-durable's
55
+ * `ConversationIdle` and saves nothing. With `whenBusy: "steer"`, the
56
+ * input joins the running work or is refused, in one step that cannot
57
+ * race the run's end.
58
+ */
59
+ type PiWhenIdle = "reject";
60
+ /**
61
+ * What aborting the session does with a queued input:
62
+ *
63
+ * - `withdraw` (default): the input settles `unanswered` with reason
64
+ * `aborted`.
65
+ * - `keep`: the input stays queued; the next input runs it first. For input
66
+ * its sender cannot send again, such as another agent's message.
67
+ * Withdrawing the operation itself (`abort(operationId)`) still removes it.
68
+ */
69
+ type PiOnAbort = "withdraw" | "keep";
41
70
  type PiSubmitOptions = {
42
71
  /** Default: the root session. */ readonly session?: PiSessionId /** Idempotency key. Submitting the same id twice returns the same receipt. */;
43
72
  readonly operationId?: string;
44
73
  readonly whenBusy?: PiWhenBusy;
74
+ readonly whenIdle?: PiWhenIdle;
75
+ readonly onAbort?: PiOnAbort;
45
76
  /**
46
77
  * The transcript entry the input is placed as, instead of pi's `pi.user`:
47
78
  * for input the user did not type, such as a scheduled prompt, a webhook,
@@ -50,10 +81,44 @@ type PiSubmitOptions = {
50
81
  * start with `pi.`.
51
82
  */
52
83
  readonly entry?: InputEntry;
84
+ /**
85
+ * A pi task to signal when this input settles: pi delivers its
86
+ * `SubmissionSettled` signal, the settled record, to `taskId` under `key`.
87
+ * For a tool that parks until another session answers. If the task has
88
+ * ended or does not exist, the input settles as usual.
89
+ */
90
+ readonly notify?: SubmissionNotify;
91
+ };
92
+ type PiContinueOptions = {
93
+ /** Idempotency key. Continuing with the same id twice returns the same receipt. */ readonly operationId?: string /** A pi task to signal when the run settles. See `PiSubmitOptions.notify`. */;
94
+ readonly notify?: SubmissionNotify;
53
95
  };
54
96
  type PiSessionOptions = {
55
97
  /** Default: the root session. */ readonly session?: PiSessionId;
56
98
  };
99
+ /**
100
+ * How `harness.root()`, `sessions.create()` and `sessions.fork()` create a
101
+ * session: pi-durable's `ConversationCreateOptions`, without `ownership`.
102
+ * Both apply in the one commit that creates the session.
103
+ */
104
+ type PiSessionCreateOptions = {
105
+ /**
106
+ * pi's agent change for the new session. For the root and `create()`, it
107
+ * is applied over the harness's `defaults`; a fork starts with its
108
+ * parent's configuration, and this is applied over that. As in pi, a
109
+ * field that is `undefined` leaves the value underneath in place, and
110
+ * `null` clears it.
111
+ */
112
+ readonly agent?: AgentChange;
113
+ /**
114
+ * pi's `ConversationInit`: runs inside the commit that creates the
115
+ * session, after `agent`, for example to seed its transcript with
116
+ * `tx.appendEntry()`, one entry per message. Table reads throw
117
+ * `ReadAfterWrite` there. A throw fails the commit, so the session is not
118
+ * created.
119
+ */
120
+ readonly init?: ConversationInit;
121
+ };
57
122
  /** Returned once a submission is durable. It says nothing about the model yet. */
58
123
  type PiReceipt = {
59
124
  readonly operationId: string;
@@ -76,13 +141,8 @@ type PiPromptResponse = PiOperationResult & {
76
141
  /** A submission pi has not settled yet. */
77
142
  type PiPendingOperation = {
78
143
  readonly operationId: string;
79
- readonly session: PiSessionId;
80
- /**
81
- * `queued` in pi's inbox, or `running` as part of the current run.
82
- * `parked`: running, but pi's crash-loop guard (`settings.restartLimit`)
83
- * stopped a task of the session; `retry()` runs it again.
84
- */
85
- readonly status: "queued" | "running" | "parked";
144
+ readonly session: PiSessionId /** `queued` in pi's inbox, or `running` as part of the current run. */;
145
+ readonly status: "queued" | "running";
86
146
  };
87
147
  type PiSessionInfo = {
88
148
  readonly id: PiSessionId /** The session this one was forked from. */;
@@ -100,7 +160,7 @@ declare const ROOT_SESSION: PiSessionId;
100
160
  */
101
161
  type PiHarnessContext = {
102
162
  /** pi's storage over this object's SQLite, its migrations already run. */ readonly storage: SqliteStorage /** Background context, for the open itself. */;
103
- readonly context: Context$1;
163
+ readonly context: Context;
104
164
  /**
105
165
  * Pass this to `Harness.open` as its `onWake` option. pi calls it when it
106
166
  * next needs to run, and the harness sets this object's alarm for then.
@@ -153,12 +213,28 @@ type PiSessionDefaults = {
153
213
  */
154
214
  readonly model?: PiModel;
155
215
  readonly thinkingLevel?: ModelThinkingLevel;
216
+ /**
217
+ * Most tool rounds one run takes: the round that reaches it runs its
218
+ * tools, then the run's operations end unanswered with reason
219
+ * `turn_limit`. An integer, 1 or more. Default: no limit.
220
+ */
221
+ readonly maxTurns?: number;
156
222
  };
157
223
  /** `PiHarness`'s options. Only `harness`, which opens pi, is required. */
158
224
  type PiHarnessOptions = {
159
225
  /** Opens pi's `Harness` over the storage this object prepared. */ readonly harness: PiHarnessFactory /** What a new session starts with. */;
160
226
  readonly defaults?: PiSessionDefaults;
161
227
  };
228
+ /** What `harness.root()` returns. */
229
+ type PiRootResult = {
230
+ /** The root session. */ readonly session: PiSession;
231
+ /**
232
+ * Whether this call created the root, so its `agent` and `init` were
233
+ * applied. `false` when the root already existed: something used it
234
+ * first, and `init` did not run.
235
+ */
236
+ readonly created: boolean;
237
+ };
162
238
  /**
163
239
  * pi-durable hosted in a Durable Object, behind a small harness interface:
164
240
  * `harness.prompt()`, `harness.sessions`, `harness.session(id)`. How a session reaches a
@@ -171,8 +247,9 @@ type PiHarnessOptions = {
171
247
  *
172
248
  * What pi cannot do on a Durable Object is wake itself: its scheduler runs
173
249
  * in memory, and an evicted object has no memory. The harness is that wake,
174
- * with one Lifecycle job driven by `pi.wake()`. Input goes to pi once, in
175
- * `submit()`, after the job is scheduled. While pi has work running, the
250
+ * with one Lifecycle job driven by `pi.wake()`. Anything that can start
251
+ * work, such as `submit()`, `signal()`, `abort()` or `reset()`, goes to pi
252
+ * once, after the job is scheduled. While pi has work running, the
176
253
  * job waits on it, rescheduling itself as a heartbeat. While pi's tasks
177
254
  * sleep, the job is due when the first one wakes; pi tells the harness
178
255
  * through the `onWake` the factory passes to `Harness.open`. When pi has
@@ -200,6 +277,17 @@ declare class PiHarness extends LifecycleCapability {
200
277
  dispose(): Promise<void>;
201
278
  /** A handle on one session. No I/O until you call it. */
202
279
  session(id?: PiSessionId): PiSession;
280
+ /**
281
+ * The root session, creating it with `agent` and `init` in one commit
282
+ * when it does not exist yet, as pi's `Harness.root()` does. `agent` is
283
+ * applied over `defaults`. When the root already exists, nothing is
284
+ * written and `init` does not run; `created` says which happened.
285
+ *
286
+ * Without this call, the first use of the root creates it with
287
+ * `defaults`. So call it before anything else uses the root, for example
288
+ * to seed the root's transcript with an existing history.
289
+ */
290
+ root(options?: PiSessionCreateOptions): Promise<PiRootResult>;
203
291
  /** Submit a prompt and wait for its answer. */
204
292
  prompt(
205
293
  input: UserInput,
@@ -207,17 +295,17 @@ declare class PiHarness extends LifecycleCapability {
207
295
  ): Promise<PiPromptResponse>;
208
296
  /** Durably submit a prompt. Resolves before the model runs. */
209
297
  submit(input: UserInput, options?: PiSubmitOptions): Promise<PiReceipt>;
298
+ /**
299
+ * Run an idle session again on its transcript as it is, without new input.
300
+ * See `PiSession.continue`.
301
+ */
302
+ continue(options?: PiSessionOptions & PiContinueOptions): Promise<PiReceipt>;
210
303
  /** Stop one operation, or everything running in a session. */
211
304
  abort(
212
305
  options?: PiSessionOptions & {
213
306
  readonly operationId?: string;
214
307
  }
215
308
  ): 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>;
221
309
  wait(
222
310
  operationId: string,
223
311
  options?: PiSessionOptions & {
@@ -228,9 +316,25 @@ declare class PiHarness extends LifecycleCapability {
228
316
  messages(options?: PiSessionOptions): Promise<EntryRecord[]>;
229
317
  /** Submissions pi has not settled yet, oldest first. */
230
318
  pending(options?: PiSessionOptions): Promise<PiPendingOperation[]>;
319
+ /**
320
+ * Deliver `value` to pi task `taskId` under `key`, as pi's
321
+ * `Harness.signal()` does: for a tool parked on that signal, such as one
322
+ * waiting for a person's answer or a webhook. The wake job is scheduled
323
+ * first, so if the object dies while the woken call runs, the job's alarm
324
+ * restarts it. Call this rather than `pi().signal()`, which does not.
325
+ */
326
+ signal<T>(
327
+ taskId: TaskId,
328
+ signal: SignalToken<T>,
329
+ key: string,
330
+ value: T
331
+ ): Promise<SignalResult>;
231
332
  /** The opened pi Harness, for anything the interface does not cover. */
232
333
  pi(): Promise<Harness>;
233
- /** @internal */
334
+ /**
335
+ * @internal Every use of a session goes through here. The first use of
336
+ * the root creates it, with `defaults`.
337
+ */
234
338
  conversation(session: PiSessionId): Promise<Conversation>;
235
339
  /** @internal */
236
340
  storage(): Promise<SqliteStorage>;
@@ -240,16 +344,39 @@ declare class PiHarness extends LifecycleCapability {
240
344
  input: UserInput,
241
345
  options: PiSubmitOptions
242
346
  ): Promise<PiReceipt>;
243
- /** @internal Run again the tasks pi's restart limit parked in a session. */
244
- retryParked(session: PiSessionId): Promise<boolean>;
347
+ /** @internal Start a run on the context as it is, without new input. */
348
+ enqueueContinue(
349
+ session: PiSessionId,
350
+ options: PiContinueOptions
351
+ ): Promise<PiReceipt>;
245
352
  /** @internal Withdraw a queued input, or abort the run it joined. */
246
353
  withdraw(session: PiSessionId, operationId: string): Promise<boolean>;
354
+ /**
355
+ * @internal Abort a session's running work and withdraw its queued
356
+ * inputs. Stopping a parked call runs its `cancel()`, which is work, so
357
+ * the wake is scheduled first.
358
+ */
359
+ abortConversation(session: PiSessionId): Promise<void>;
360
+ /**
361
+ * @internal Start a new context. Inputs kept behind a failed run or an
362
+ * abort run in it, so the wake is scheduled first.
363
+ */
364
+ resetConversation(
365
+ session: PiSessionId,
366
+ handoff: string | undefined
367
+ ): Promise<void>;
247
368
  /** @internal Wait for pi to settle an operation, by its request id. */
248
369
  settled(
249
370
  session: PiSessionId,
250
371
  operationId: string,
251
372
  signal?: AbortSignal
252
373
  ): Promise<PiOperationResult>;
374
+ /**
375
+ * @internal `agent` applied over the defaults, by pi's rule for an
376
+ * `AgentChange`: a field set to a value replaces the default, `null`
377
+ * clears it, and `undefined` leaves it in place.
378
+ */
379
+ agentOverDefaults(agent?: AgentChange): AgentChange;
253
380
  /** @internal The per-conversation defaults supported by pi-durable. */
254
381
  agentDefaults(): AgentChange;
255
382
  }
@@ -265,6 +392,14 @@ declare class PiSession {
265
392
  input: UserInput,
266
393
  options?: PiSubmitOptions
267
394
  ): Promise<PiPromptResponse>;
395
+ /**
396
+ * Start a run on the transcript as it is, without a new message: for
397
+ * example, after a run ended unanswered because the model failed or the
398
+ * object kept crashing. Only an idle session takes one; a busy one rejects
399
+ * with pi-durable's `ConversationBusy`. A transcript that ends in an answer
400
+ * settles `unanswered` with reason `nothing_to_answer`.
401
+ */
402
+ continue(options?: PiContinueOptions): Promise<PiReceipt>;
268
403
  /** Join the running work after its current tool round. */
269
404
  steer(
270
405
  input: UserInput,
@@ -274,16 +409,10 @@ declare class PiSession {
274
409
  wait(operationId: string, signal?: AbortSignal): Promise<PiOperationResult>;
275
410
  /**
276
411
  * Withdraw one queued operation (or abort the run it joined), or, with no
277
- * id, abort the session: pi withdraws queued inputs and aborts the
278
- * running work.
412
+ * id, abort the session: pi withdraws queued inputs, apart from those
413
+ * submitted with `onAbort: "keep"`, and aborts the running work.
279
414
  */
280
415
  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>;
287
416
  /** Start a new context, optionally from a handoff note. */
288
417
  reset(handoff?: string): Promise<void>;
289
418
  /**
@@ -293,8 +422,29 @@ declare class PiSession {
293
422
  setModel(model: PiModel): Promise<void>;
294
423
  /** The active transcript, as pi's entries since the newest reset. */
295
424
  messages(): Promise<EntryRecord[]>;
296
- /** pi's agent events for this session: a snapshot, then one batch per commit. */
297
- events(context?: Context$1): Promise<AgentEventStream>;
425
+ /**
426
+ * Watch this session: pi's conversation view, a window over the transcript
427
+ * with the session's documents, such as `pi.live` (the answer being
428
+ * streamed, running tools, and why the last run ended without an answer)
429
+ * and `pi.inbox`. The first value holds the newest entries; new entries
430
+ * are appended. Each change carries pi's operations, for a client that
431
+ * forwards them. To render more than the window, merge each value into a
432
+ * `ConversationTranscript` that pages with `entries()`.
433
+ */
434
+ watch(
435
+ window?: ConversationWindow,
436
+ context?: Context
437
+ ): Promise<ConversationWatch>;
438
+ /**
439
+ * A page of this session's transcript, newest first unless `query.order`
440
+ * is `ascending`, including entries before its resets. The loader a
441
+ * `ConversationTranscript` takes.
442
+ */
443
+ entries(
444
+ query: Omit<EntryQuery, "conversationId">,
445
+ limit: number,
446
+ context?: Context
447
+ ): Promise<Page<EntryRecord, Cursor>>;
298
448
  busy(): Promise<boolean>;
299
449
  }
300
450
  /** Every pi conversation in this object. */
@@ -302,13 +452,21 @@ declare class PiSessions {
302
452
  #private;
303
453
  constructor(harness: PiHarness);
304
454
  get(id: PiSessionId): PiSession;
305
- /** A new top-level session, configured like the root. */
306
- create(): Promise<PiSession>;
307
- /** A new session that sees `from`'s history up to its newest entry. */
308
- fork(from: PiSessionId): Promise<PiSession>;
455
+ /**
456
+ * A new top-level session, configured with `defaults`, then `agent`; `init`
457
+ * runs in the commit that creates it.
458
+ */
459
+ create(options?: PiSessionCreateOptions): Promise<PiSession>;
460
+ /**
461
+ * A new session that sees `from`'s history up to its newest entry, with
462
+ * `from`'s configuration, then `agent`; `init` runs in the commit that
463
+ * creates it.
464
+ */
465
+ fork(from: PiSessionId, options?: PiSessionCreateOptions): Promise<PiSession>;
309
466
  /**
310
467
  * Every conversation, including ones subagent tools own. Read from pi's
311
- * storage directly: the Harness has no conversation listing.
468
+ * storage directly: the Harness has no conversation listing. The root is
469
+ * listed once it exists: its first use, or `harness.root()`, creates it.
312
470
  */
313
471
  list(): Promise<PiSessionInfo[]>;
314
472
  }
@@ -361,16 +519,20 @@ declare function openPiSessionStore(
361
519
  declare function skills(sources: readonly SkillSource[]): Promise<Extension>;
362
520
  //#endregion
363
521
  export {
522
+ type PiContinueOptions,
364
523
  PiHarness,
365
524
  type PiHarnessContext,
366
525
  type PiHarnessFactory,
367
526
  type PiHarnessOptions,
368
527
  type PiModel,
528
+ type PiOnAbort,
369
529
  type PiOperationResult,
370
530
  type PiPendingOperation,
371
531
  type PiPromptResponse,
372
532
  type PiReceipt,
533
+ type PiRootResult,
373
534
  PiSession,
535
+ type PiSessionCreateOptions,
374
536
  type PiSessionDefaults,
375
537
  type PiSessionId,
376
538
  type PiSessionInfo,
@@ -379,6 +541,7 @@ export {
379
541
  PiSessions,
380
542
  type PiSubmitOptions,
381
543
  type PiWhenBusy,
544
+ type PiWhenIdle,
382
545
  ROOT_SESSION,
383
546
  openPiSessionStore,
384
547
  skills