eve 0.36.0 → 0.37.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 (277) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +1 -0
  3. package/dist/src/channel/routes.d.ts +13 -3
  4. package/dist/src/channel/routes.js +1 -1
  5. package/dist/src/channel/session-callback.js +1 -1
  6. package/dist/src/channel/session.d.ts +2 -1
  7. package/dist/src/channel/session.js +1 -1
  8. package/dist/src/channel/types.d.ts +41 -0
  9. package/dist/src/chunks/{use-eve-agent-CnppTEFk.js → use-eve-agent-Bi5fRxcZ.js} +9 -1
  10. package/dist/src/chunks/{use-eve-agent-COmP-H8R.js → use-eve-agent-DbKUBhl-.js} +9 -1
  11. package/dist/src/cli/commands/agent-instructions.d.ts +4 -4
  12. package/dist/src/cli/commands/init-confirm.d.ts +12 -0
  13. package/dist/src/cli/commands/init-confirm.js +1 -0
  14. package/dist/src/cli/commands/init-git.js +1 -1
  15. package/dist/src/cli/commands/init-recovery.d.ts +3 -0
  16. package/dist/src/cli/commands/init-recovery.js +3 -0
  17. package/dist/src/cli/commands/init-target.d.ts +21 -0
  18. package/dist/src/cli/commands/init-target.js +1 -0
  19. package/dist/src/cli/commands/init.d.ts +6 -5
  20. package/dist/src/cli/commands/init.js +1 -1
  21. package/dist/src/cli/dev/tui/runner.d.ts +8 -0
  22. package/dist/src/cli/dev/tui/runner.js +1 -1
  23. package/dist/src/cli/dev/tui/subagent-pump.d.ts +27 -22
  24. package/dist/src/cli/dev/tui/subagent-pump.js +1 -1
  25. package/dist/src/cli/dev/tui/terminal-renderer.d.ts +16 -0
  26. package/dist/src/cli/dev/tui/terminal-renderer.js +12 -12
  27. package/dist/src/cli/dev/tui/tool-presentation.js +1 -1
  28. package/dist/src/cli/run.d.ts +1 -0
  29. package/dist/src/cli/run.js +3 -3
  30. package/dist/src/client/open-stream.d.ts +2 -0
  31. package/dist/src/client/open-stream.js +1 -1
  32. package/dist/src/client/session.js +1 -1
  33. package/dist/src/compiled/.vendor-stamp.json +3 -1
  34. package/dist/src/compiled/@modelcontextprotocol/server/LICENSE +216 -0
  35. package/dist/src/compiled/@modelcontextprotocol/server/index.d.ts +98 -0
  36. package/dist/src/compiled/@modelcontextprotocol/server/index.js +80 -0
  37. package/dist/src/compiled/@vercel/sandbox/api-client/api-client.d.ts +339 -0
  38. package/dist/src/compiled/@vercel/sandbox/api-client/index.d.ts +1 -1
  39. package/dist/src/compiled/@vercel/sandbox/api-client/validators.d.ts +25 -1
  40. package/dist/src/compiled/@vercel/sandbox/drive.d.ts +140 -0
  41. package/dist/src/compiled/@vercel/sandbox/index.d.ts +3 -2
  42. package/dist/src/compiled/@vercel/sandbox/index.js +13 -13
  43. package/dist/src/compiled/@vercel/sandbox/sandbox.d.ts +55 -18
  44. package/dist/src/compiled/@vercel/sandbox-stable/LICENSE +201 -0
  45. package/dist/src/compiled/@vercel/sandbox-stable/_async-retry.d.ts +8 -0
  46. package/dist/src/compiled/@vercel/sandbox-stable/_workflow-serde.d.ts +5 -0
  47. package/dist/src/compiled/@vercel/sandbox-stable/api-client/api-client.d.ts +1456 -0
  48. package/dist/src/compiled/@vercel/sandbox-stable/api-client/api-error.d.ts +29 -0
  49. package/dist/src/compiled/@vercel/sandbox-stable/api-client/base-client.d.ts +39 -0
  50. package/dist/src/compiled/@vercel/sandbox-stable/api-client/file-writer.d.ts +66 -0
  51. package/dist/src/compiled/@vercel/sandbox-stable/api-client/index.d.ts +2 -0
  52. package/dist/src/compiled/@vercel/sandbox-stable/api-client/validators.d.ts +899 -0
  53. package/dist/src/compiled/@vercel/sandbox-stable/api-client/with-retry.d.ts +10 -0
  54. package/dist/src/compiled/@vercel/sandbox-stable/auth/error.d.ts +15 -0
  55. package/dist/src/compiled/@vercel/sandbox-stable/auth/file.d.ts +18 -0
  56. package/dist/src/compiled/@vercel/sandbox-stable/auth/index.d.ts +6 -0
  57. package/dist/src/compiled/@vercel/sandbox-stable/auth/oauth.d.ts +111 -0
  58. package/dist/src/compiled/@vercel/sandbox-stable/auth/poll-for-token.d.ts +28 -0
  59. package/dist/src/compiled/@vercel/sandbox-stable/auth/project.d.ts +40 -0
  60. package/dist/src/compiled/@vercel/sandbox-stable/command.d.ts +292 -0
  61. package/dist/src/compiled/@vercel/sandbox-stable/constants.d.ts +5 -0
  62. package/dist/src/compiled/@vercel/sandbox-stable/execution-context.d.ts +116 -0
  63. package/dist/src/compiled/@vercel/sandbox-stable/filesystem.d.ts +258 -0
  64. package/dist/src/compiled/@vercel/sandbox-stable/index.d.ts +12 -0
  65. package/dist/src/compiled/@vercel/sandbox-stable/index.js +1 -0
  66. package/dist/src/compiled/@vercel/sandbox-stable/network-policy.d.ts +169 -0
  67. package/dist/src/compiled/@vercel/sandbox-stable/proxy.d.ts +55 -0
  68. package/dist/src/compiled/@vercel/sandbox-stable/sandbox-user.d.ts +212 -0
  69. package/dist/src/compiled/@vercel/sandbox-stable/sandbox.d.ts +1216 -0
  70. package/dist/src/compiled/@vercel/sandbox-stable/session.d.ts +433 -0
  71. package/dist/src/compiled/@vercel/sandbox-stable/snapshot.d.ts +229 -0
  72. package/dist/src/compiled/@vercel/sandbox-stable/utils/get-credentials.d.ts +21 -0
  73. package/dist/src/compiled/@vercel/sandbox-stable/utils/paginator.d.ts +16 -0
  74. package/dist/src/compiled/@vercel/sandbox-stable/utils/resolveSignal.d.ts +15 -0
  75. package/dist/src/compiled/@vercel/sandbox-stable/utils/sandbox-snapshot.d.ts +11 -0
  76. package/dist/src/compiled/@vercel/sandbox-stable/utils/types.d.ts +11 -0
  77. package/dist/src/compiled/_chunks/node/{auth-BS3UoyvT.js → auth-BaNbsImr.js} +1 -1
  78. package/dist/src/compiled/_chunks/node/version-BYHw-SDY.js +1 -0
  79. package/dist/src/compiler/extension-compatibility.d.ts +10 -10
  80. package/dist/src/compiler/extension-compatibility.js +1 -1
  81. package/dist/src/compiler/manifest.js +1 -1
  82. package/dist/src/compiler/normalize-agent-config.js +1 -1
  83. package/dist/src/compiler/normalize-manifest.js +1 -1
  84. package/dist/src/compiler/normalize-subagent.d.ts +1 -1
  85. package/dist/src/compiler/normalize-subagent.js +1 -1
  86. package/dist/src/context/serialized-dynamic-model-selection.d.ts +2 -0
  87. package/dist/src/context/serialized-dynamic-model-selection.js +1 -0
  88. package/dist/src/execution/agent-handle-dispatch.d.ts +15 -1
  89. package/dist/src/execution/agent-handle-dispatch.js +1 -1
  90. package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
  91. package/dist/src/execution/delegated-parent-notification.d.ts +17 -0
  92. package/dist/src/execution/delegated-parent-notification.js +1 -1
  93. package/dist/src/execution/deliver-payloads.js +1 -1
  94. package/dist/src/execution/dispatch-runtime-actions-shared.d.ts +155 -0
  95. package/dist/src/execution/dispatch-runtime-actions-shared.js +1 -0
  96. package/dist/src/execution/dispatch-runtime-actions-step.d.ts +18 -14
  97. package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
  98. package/dist/src/execution/dispatch-workflow-runtime-actions-step.d.ts +7 -2
  99. package/dist/src/execution/dispatch-workflow-runtime-actions-step.js +1 -1
  100. package/dist/src/execution/effective-output-schema.d.ts +21 -0
  101. package/dist/src/execution/effective-output-schema.js +1 -0
  102. package/dist/src/execution/eve-workflow-attributes.d.ts +2 -0
  103. package/dist/src/execution/node-step.js +1 -1
  104. package/dist/src/execution/parked-delivery-wait.d.ts +8 -12
  105. package/dist/src/execution/parked-delivery-wait.js +1 -1
  106. package/dist/src/execution/{route-proxied-deliver-step.d.ts → proxied-deliver-step.d.ts} +7 -4
  107. package/dist/src/execution/proxied-deliver-step.js +1 -0
  108. package/dist/src/execution/remote-agent-dispatch.d.ts +32 -0
  109. package/dist/src/execution/remote-agent-dispatch.js +1 -1
  110. package/dist/src/execution/remote-agent-route-url.d.ts +2 -0
  111. package/dist/src/execution/remote-agent-route-url.js +1 -0
  112. package/dist/src/execution/route-child-delivery.d.ts +2 -1
  113. package/dist/src/execution/route-child-delivery.js +1 -1
  114. package/dist/src/execution/sandbox/bindings/vercel.d.ts +2 -1
  115. package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
  116. package/dist/src/execution/session-callback-step.d.ts +11 -0
  117. package/dist/src/execution/session-callback-step.js +1 -1
  118. package/dist/src/execution/session-command-wire.js +1 -1
  119. package/dist/src/execution/session-state-cursor.d.ts +25 -0
  120. package/dist/src/execution/session-state-cursor.js +1 -0
  121. package/dist/src/execution/settle-cancelled-turn-step.d.ts +2 -0
  122. package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
  123. package/dist/src/execution/subagent-event-proxy-step.d.ts +15 -0
  124. package/dist/src/execution/subagent-event-proxy-step.js +1 -1
  125. package/dist/src/execution/subagent-hitl-proxy.d.ts +14 -7
  126. package/dist/src/execution/subagent-hitl-proxy.js +1 -1
  127. package/dist/src/execution/subagent-start-local.d.ts +29 -0
  128. package/dist/src/execution/subagent-start-local.js +1 -0
  129. package/dist/src/execution/subagent-start-remote.d.ts +23 -0
  130. package/dist/src/execution/subagent-start-remote.js +1 -0
  131. package/dist/src/execution/task-event-callback.d.ts +13 -0
  132. package/dist/src/execution/task-event-callback.js +1 -0
  133. package/dist/src/execution/task-input-capability.d.ts +4 -0
  134. package/dist/src/execution/task-input-capability.js +1 -0
  135. package/dist/src/execution/tasks/child/steps.d.ts +46 -0
  136. package/dist/src/execution/tasks/child/steps.js +1 -0
  137. package/dist/src/execution/tasks/child/workflow.d.ts +31 -0
  138. package/dist/src/execution/tasks/child/workflow.js +1 -0
  139. package/dist/src/execution/tasks/parent/agent-identity.d.ts +13 -0
  140. package/dist/src/execution/tasks/parent/agent-identity.js +1 -0
  141. package/dist/src/execution/tasks/parent/agent-views.d.ts +6 -0
  142. package/dist/src/execution/tasks/parent/agent-views.js +1 -0
  143. package/dist/src/execution/tasks/parent/continuation-dispatch.d.ts +37 -0
  144. package/dist/src/execution/tasks/parent/continuation-dispatch.js +1 -0
  145. package/dist/src/execution/tasks/parent/control-shared.d.ts +36 -0
  146. package/dist/src/execution/tasks/parent/control-shared.js +1 -0
  147. package/dist/src/execution/tasks/parent/delegate.d.ts +70 -0
  148. package/dist/src/execution/tasks/parent/delegate.js +1 -0
  149. package/dist/src/execution/tasks/parent/dispatch-task-step.d.ts +19 -0
  150. package/dist/src/execution/tasks/parent/dispatch-task-step.js +1 -0
  151. package/dist/src/execution/tasks/parent/dispatch.d.ts +33 -0
  152. package/dist/src/execution/tasks/parent/dispatch.js +1 -0
  153. package/dist/src/execution/tasks/parent/hitl-proxy-steps.d.ts +29 -0
  154. package/dist/src/execution/tasks/parent/hitl-proxy-steps.js +1 -0
  155. package/dist/src/execution/tasks/parent/run-parent.d.ts +72 -0
  156. package/dist/src/execution/tasks/parent/run-parent.js +1 -0
  157. package/dist/src/execution/tasks/parent/send.d.ts +25 -0
  158. package/dist/src/execution/tasks/parent/send.js +1 -0
  159. package/dist/src/execution/tasks/workflow-target.d.ts +2 -0
  160. package/dist/src/execution/tasks/workflow-target.js +1 -0
  161. package/dist/src/execution/terminate-child-sessions-step.d.ts +1 -0
  162. package/dist/src/execution/terminate-child-sessions-step.js +1 -1
  163. package/dist/src/execution/turn-control-receiver.d.ts +10 -0
  164. package/dist/src/execution/turn-control-receiver.js +1 -1
  165. package/dist/src/execution/turn-dispatch.d.ts +2 -0
  166. package/dist/src/execution/turn-dispatch.js +1 -1
  167. package/dist/src/execution/turn-execution-cursor.d.ts +2 -8
  168. package/dist/src/execution/turn-execution-cursor.js +1 -1
  169. package/dist/src/execution/turn-workflow.js +1 -1
  170. package/dist/src/execution/workflow-callback-url.d.ts +5 -0
  171. package/dist/src/execution/workflow-callback-url.js +1 -1
  172. package/dist/src/execution/workflow-entry.js +1 -1
  173. package/dist/src/execution/workflow-runtime.d.ts +9 -0
  174. package/dist/src/execution/workflow-runtime.js +1 -1
  175. package/dist/src/execution/workflow-steps.d.ts +7 -21
  176. package/dist/src/execution/workflow-steps.js +1 -1
  177. package/dist/src/harness/advertised-tools.js +1 -1
  178. package/dist/src/harness/authorization.js +1 -1
  179. package/dist/src/harness/execute-tool.d.ts +7 -0
  180. package/dist/src/harness/handles/prompt.d.ts +12 -0
  181. package/dist/src/harness/handles/prompt.js +2 -1
  182. package/dist/src/harness/handles/query.js +1 -1
  183. package/dist/src/harness/handles/store.d.ts +9 -2
  184. package/dist/src/harness/handles/store.js +1 -1
  185. package/dist/src/harness/handles/transitions.d.ts +10 -1
  186. package/dist/src/harness/handles/transitions.js +1 -1
  187. package/dist/src/harness/proxy-input-requests.d.ts +21 -4
  188. package/dist/src/harness/proxy-input-requests.js +1 -1
  189. package/dist/src/harness/runtime-actions.d.ts +2 -0
  190. package/dist/src/harness/runtime-actions.js +1 -1
  191. package/dist/src/harness/session-limit-enforcement.js +1 -1
  192. package/dist/src/harness/tool-loop.js +2 -2
  193. package/dist/src/harness/workflow-runtime-action-state.js +1 -1
  194. package/dist/src/internal/application/package.js +1 -1
  195. package/dist/src/internal/authored-definition/core.js +1 -1
  196. package/dist/src/internal/invocation/agent-invocation.d.ts +54 -0
  197. package/dist/src/internal/invocation/agent-invocation.js +1 -0
  198. package/dist/src/internal/invocation/attributes.d.ts +2 -0
  199. package/dist/src/internal/invocation/attributes.js +1 -0
  200. package/dist/src/internal/invocation/metadata.d.ts +9 -0
  201. package/dist/src/internal/invocation/metadata.js +1 -0
  202. package/dist/src/internal/invocation/workflow-execution.d.ts +32 -0
  203. package/dist/src/internal/invocation/workflow-execution.js +1 -0
  204. package/dist/src/internal/mcp/http-security.d.ts +12 -0
  205. package/dist/src/internal/mcp/http-security.js +1 -0
  206. package/dist/src/internal/mcp/protected-resource.d.ts +9 -0
  207. package/dist/src/internal/mcp/protected-resource.js +1 -0
  208. package/dist/src/internal/mcp/streamable-http-server.d.ts +51 -0
  209. package/dist/src/internal/mcp/streamable-http-server.js +1 -0
  210. package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
  211. package/dist/src/internal/nitro/routes/channel-route-context.d.ts +14 -0
  212. package/dist/src/internal/nitro/routes/channel-route-context.js +1 -1
  213. package/dist/src/internal/nitro/routes/runtime-stack.d.ts +2 -0
  214. package/dist/src/internal/nitro/routes/runtime-stack.js +1 -1
  215. package/dist/src/internal/vercel-agent-summary.d.ts +1 -1
  216. package/dist/src/packages/eve-catalog/src/index.js +1 -1
  217. package/dist/src/protocol/message.d.ts +28 -0
  218. package/dist/src/protocol/message.js +2 -2
  219. package/dist/src/protocol/routes.d.ts +14 -0
  220. package/dist/src/protocol/routes.js +1 -1
  221. package/dist/src/public/channels/auth.d.ts +36 -0
  222. package/dist/src/public/channels/auth.js +1 -1
  223. package/dist/src/public/channels/eve.js +1 -1
  224. package/dist/src/public/channels/mcp.d.ts +19 -0
  225. package/dist/src/public/channels/mcp.js +1 -0
  226. package/dist/src/public/definitions/channel.d.ts +2 -2
  227. package/dist/src/public/definitions/channel.js +1 -1
  228. package/dist/src/public/sandbox/backends/vercel.d.ts +5 -4
  229. package/dist/src/public/sandbox/backends/vercel.js +1 -1
  230. package/dist/src/public/sandbox/vercel-sandbox.d.ts +25 -1
  231. package/dist/src/public/sandbox/vercel.d.ts +2 -1
  232. package/dist/src/public/sandbox/vercel.js +1 -1
  233. package/dist/src/react/use-eve-agent.js +1 -1
  234. package/dist/src/runtime/actions/types.d.ts +9 -0
  235. package/dist/src/runtime/actions/types.js +1 -1
  236. package/dist/src/runtime/agent/bootstrap.js +1 -1
  237. package/dist/src/runtime/connections/authorization-complete-page.js +70 -28
  238. package/dist/src/runtime/framework-channels/index.js +1 -1
  239. package/dist/src/runtime/framework-tools/index.js +1 -1
  240. package/dist/src/runtime/framework-tools/tasks.d.ts +95 -0
  241. package/dist/src/runtime/framework-tools/tasks.js +1 -0
  242. package/dist/src/runtime/prompt/compose.d.ts +1 -0
  243. package/dist/src/runtime/prompt/compose.js +1 -1
  244. package/dist/src/runtime/resolve-agent-graph.js +1 -1
  245. package/dist/src/runtime/resolve-agent.js +1 -1
  246. package/dist/src/runtime/session-callback-route.js +1 -1
  247. package/dist/src/runtime/task-input-response-route.d.ts +5 -0
  248. package/dist/src/runtime/task-input-response-route.js +1 -0
  249. package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
  250. package/dist/src/setup/scaffold/create/project.js +1 -1
  251. package/dist/src/setup/scaffold/create/web-template.d.ts +1 -1
  252. package/dist/src/setup/scaffold/create/web-template.js +0 -1
  253. package/dist/src/shared/agent-definition.d.ts +7 -0
  254. package/dist/src/shared/sandbox-network-policy.d.ts +1 -1
  255. package/dist/src/svelte/index.js +1 -1
  256. package/dist/src/svelte/use-eve-agent.js +1 -1
  257. package/dist/src/tasks/json.d.ts +88 -0
  258. package/dist/src/tasks/json.js +1 -0
  259. package/dist/src/tasks/session-index.d.ts +48 -0
  260. package/dist/src/tasks/session-index.js +1 -0
  261. package/dist/src/tasks/task-id.d.ts +34 -0
  262. package/dist/src/tasks/task-id.js +1 -0
  263. package/dist/src/tasks/transitions.d.ts +23 -0
  264. package/dist/src/tasks/transitions.js +1 -0
  265. package/dist/src/tasks/types.d.ts +295 -0
  266. package/dist/src/tasks/types.js +1 -0
  267. package/dist/src/tasks/wire.d.ts +26 -0
  268. package/dist/src/tasks/wire.js +1 -0
  269. package/dist/src/vue/index.js +1 -1
  270. package/dist/src/vue/use-eve-agent.js +1 -1
  271. package/docs/channels/eve.mdx +14 -0
  272. package/docs/guides/client/streaming.mdx +1 -1
  273. package/docs/reference/cli.md +10 -6
  274. package/docs/tools/human-in-the-loop.md +3 -1
  275. package/package.json +8 -1
  276. package/dist/src/compiled/_chunks/node/version-Cztrk7z6.js +0 -1
  277. package/dist/src/execution/route-proxied-deliver-step.js +0 -1
@@ -4988,7 +4988,6 @@ const betterAuthSession: AuthFn<Request> = async (request) => {
4988
4988
  return {
4989
4989
  attributes,
4990
4990
  authenticator: "better-auth:vercel",
4991
- issuer: "https://vercel.com",
4992
4991
  principalId: session.user.id,
4993
4992
  principalType: "user",
4994
4993
  };
@@ -180,6 +180,13 @@ export interface AgentExperimentalDefinition {
180
180
  * When unset, delegated children run as one-shot tasks.
181
181
  */
182
182
  readonly subagentPersistentSessions?: boolean;
183
+ /**
184
+ * Runs this agent's delegated subagent calls as durable background tasks.
185
+ * The originating tool call returns a task receipt immediately and the
186
+ * model manages the work through the `task_*` framework tools. Implies
187
+ * persistent-session children for subagent dispatch. Root agents only.
188
+ */
189
+ readonly tasks?: boolean;
183
190
  /**
184
191
  * Durable Workflow runtime configuration. Root agents may use this to select
185
192
  * the Workflow world backing sessions and runs.
@@ -1,4 +1,4 @@
1
- import type * as Vercel from "#compiled/@vercel/sandbox/index.js";
1
+ import type * as Vercel from "#compiled/@vercel/sandbox-stable/index.js";
2
2
  /**
3
3
  * Firewall network policy applied to a live sandbox session.
4
4
  *
@@ -1,3 +1,3 @@
1
- import { n as defaultMessageReducer, t as useEveAgent } from "../chunks/use-eve-agent-COmP-H8R.js";
1
+ import { n as defaultMessageReducer, t as useEveAgent } from "../chunks/use-eve-agent-DbKUBhl-.js";
2
2
 
3
3
  export { defaultMessageReducer, useEveAgent };
@@ -1,3 +1,3 @@
1
- import { t as useEveAgent } from "../chunks/use-eve-agent-COmP-H8R.js";
1
+ import { t as useEveAgent } from "../chunks/use-eve-agent-DbKUBhl-.js";
2
2
 
3
3
  export { useEveAgent };
@@ -0,0 +1,88 @@
1
+ import { z } from "#compiled/zod/index.js";
2
+ import type { JsonValue } from "#shared/json.js";
3
+ import type { TaskView } from "#tasks/types.js";
4
+ /** Model-visible task shape. Unlisted private fields are stripped by zod. */
5
+ declare const taskViewJsonSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
6
+ metadata: z.ZodObject<{
7
+ agentId: z.ZodString;
8
+ kind: z.ZodLiteral<"subagent">;
9
+ mode: z.ZodEnum<{
10
+ local: "local";
11
+ remote: "remote";
12
+ }>;
13
+ name: z.ZodString;
14
+ }, z.core.$strip>;
15
+ taskId: z.ZodString;
16
+ status: z.ZodLiteral<"working">;
17
+ }, z.core.$strip>, z.ZodObject<{
18
+ metadata: z.ZodObject<{
19
+ agentId: z.ZodString;
20
+ kind: z.ZodLiteral<"subagent">;
21
+ mode: z.ZodEnum<{
22
+ local: "local";
23
+ remote: "remote";
24
+ }>;
25
+ name: z.ZodString;
26
+ }, z.core.$strip>;
27
+ taskId: z.ZodString;
28
+ inputRequests: z.ZodReadonly<z.ZodArray<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>;
29
+ status: z.ZodLiteral<"input_required">;
30
+ }, z.core.$strip>, z.ZodObject<{
31
+ metadata: z.ZodObject<{
32
+ agentId: z.ZodString;
33
+ kind: z.ZodLiteral<"subagent">;
34
+ mode: z.ZodEnum<{
35
+ local: "local";
36
+ remote: "remote";
37
+ }>;
38
+ name: z.ZodString;
39
+ }, z.core.$strip>;
40
+ taskId: z.ZodString;
41
+ lastOutput: z.ZodObject<{
42
+ data: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
43
+ type: z.ZodLiteral<"result">;
44
+ }, z.core.$strip>;
45
+ status: z.ZodLiteral<"completed">;
46
+ }, z.core.$strip>, z.ZodObject<{
47
+ metadata: z.ZodObject<{
48
+ agentId: z.ZodString;
49
+ kind: z.ZodLiteral<"subagent">;
50
+ mode: z.ZodEnum<{
51
+ local: "local";
52
+ remote: "remote";
53
+ }>;
54
+ name: z.ZodString;
55
+ }, z.core.$strip>;
56
+ taskId: z.ZodString;
57
+ lastOutput: z.ZodObject<{
58
+ data: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
59
+ type: z.ZodLiteral<"error">;
60
+ }, z.core.$strip>;
61
+ status: z.ZodLiteral<"failed">;
62
+ }, z.core.$strip>, z.ZodObject<{
63
+ metadata: z.ZodObject<{
64
+ agentId: z.ZodString;
65
+ kind: z.ZodLiteral<"subagent">;
66
+ mode: z.ZodEnum<{
67
+ local: "local";
68
+ remote: "remote";
69
+ }>;
70
+ name: z.ZodString;
71
+ }, z.core.$strip>;
72
+ taskId: z.ZodString;
73
+ status: z.ZodLiteral<"cancelled">;
74
+ }, z.core.$strip>], "status">;
75
+ /**
76
+ * Model-visible task view, inferred from {@link taskViewJsonSchema}.
77
+ *
78
+ * This is the public projection of `TaskView` (#tasks/types.js), not a
79
+ * replacement for it: the durable view additionally carries private
80
+ * `executor` and `usage`, and its module must stay zod-free because it is
81
+ * bundled into workflow bodies.
82
+ */
83
+ type TaskViewJson = z.infer<typeof taskViewJsonSchema>;
84
+ /** Projects a task view into the JSON value carried by tool results. */
85
+ export declare function taskViewToJson(view: TaskView): TaskViewJson;
86
+ /** Projects many views into one `{ tasks }` tool output. */
87
+ export declare function taskViewsToJson(views: readonly TaskView[]): JsonValue;
88
+ export {};
@@ -0,0 +1 @@
1
+ import{z}from"#compiled/zod/index.js";import{jsonValueSchema}from"#shared/json-schemas.js";const taskMetadataJsonSchema=z.object({agentId:z.string(),kind:z.literal(`subagent`),mode:z.enum([`local`,`remote`]),name:z.string()}),taskOutputJsonSchema=z.object({data:jsonValueSchema,type:z.enum([`result`,`error`])}),taskViewJsonBaseShape={metadata:taskMetadataJsonSchema,taskId:z.string()},taskViewJsonSchema=z.discriminatedUnion(`status`,[z.object({...taskViewJsonBaseShape,status:z.literal(`working`)}),z.object({...taskViewJsonBaseShape,inputRequests:z.array(jsonValueSchema).readonly(),status:z.literal(`input_required`)}),z.object({...taskViewJsonBaseShape,lastOutput:taskOutputJsonSchema.extend({type:z.literal(`result`)}),status:z.literal(`completed`)}),z.object({...taskViewJsonBaseShape,lastOutput:taskOutputJsonSchema.extend({type:z.literal(`error`)}),status:z.literal(`failed`)}),z.object({...taskViewJsonBaseShape,status:z.literal(`cancelled`)})]);function taskViewToJson(e){return taskViewJsonSchema.parse(e)}function taskViewsToJson(e){return{tasks:e.map(e=>taskViewToJson(e))}}export{taskViewToJson,taskViewsToJson};
@@ -0,0 +1,48 @@
1
+ import type { HarnessSession, SessionStateMap } from "#harness/types.js";
2
+ import type { TaskMetadata, TaskView } from "#tasks/types.js";
3
+ /**
4
+ * Session-state key for the parent's live-task index.
5
+ *
6
+ * The parent session stores only this index; the mutable task record
7
+ * lives in the dedicated durable task run. The PR #1190 spike found the
8
+ * session-state boundary unworkable for task state itself: session state
9
+ * threads through step results, while callback routes and child
10
+ * executors must update tasks without holding the current snapshot.
11
+ */
12
+ export declare const SESSION_TASKS_STATE_KEY = "eve.tasks";
13
+ /**
14
+ * One task owned by this session. Immutable model-safe metadata keeps the
15
+ * task-to-agent join available before the task run publishes its first view.
16
+ *
17
+ * `taskInboxToken` is the private routing credential for the task run's
18
+ * inbound hook. It must never render into model context, history, task
19
+ * views, or compaction summaries — the model addresses tasks by
20
+ * `taskId` only, and lookup verifies ownership through this index.
21
+ */
22
+ export interface SessionTaskIndexEntry {
23
+ readonly taskId: string;
24
+ readonly taskRunId: string;
25
+ /** Immutable fallback once the owning workflow run expires. */
26
+ readonly terminalView?: TaskView;
27
+ readonly taskInboxToken: string;
28
+ readonly createdByStepIndex?: number;
29
+ readonly createdByTurnId: string;
30
+ readonly metadata: TaskMetadata;
31
+ readonly operationId: string;
32
+ }
33
+ /**
34
+ * Reads and validates the task index from session state.
35
+ *
36
+ * A present but invalid index throws: treating corruption as absence
37
+ * would silently orphan every live task's routing credential.
38
+ */
39
+ export declare function getSessionTaskIndex(state: SessionStateMap | undefined): readonly SessionTaskIndexEntry[];
40
+ /** Caches one terminal view beside its task-run address. */
41
+ export declare function cacheTerminalTaskView(state: SessionStateMap | undefined, view: TaskView): SessionStateMap | undefined;
42
+ /** Finds one owned task; `undefined` enforces parent-session ownership. */
43
+ export declare function findSessionTaskEntry(state: SessionStateMap | undefined, taskId: string): SessionTaskIndexEntry | undefined;
44
+ /**
45
+ * Records one task, replacing any entry with the same id so replayed
46
+ * creation for the same originating call stays idempotent.
47
+ */
48
+ export declare function recordSessionTask(session: HarnessSession, entry: SessionTaskIndexEntry): HarnessSession;
@@ -0,0 +1 @@
1
+ import{z}from"#compiled/zod/index.js";const SESSION_TASKS_STATE_KEY=`eve.tasks`,taskMetadataSchema=z.strictObject({agentId:z.string().min(1),kind:z.literal(`subagent`),mode:z.enum([`local`,`remote`]),name:z.string().min(1)}),taskViewBaseShape={executor:z.strictObject({childSessionId:z.string().min(1).optional(),childTurnId:z.string().min(1).optional(),lifecycle:z.enum([`parked`,`terminal`]).optional()}).optional(),metadata:taskMetadataSchema,taskId:z.string().min(1),usage:z.strictObject({cacheReadTokens:z.number().nonnegative(),cacheWriteTokens:z.number().nonnegative(),inputTokens:z.number().nonnegative(),outputTokens:z.number().nonnegative()}).optional()},taskViewSchema=z.discriminatedUnion(`status`,[z.strictObject({...taskViewBaseShape,lastOutput:z.strictObject({data:z.custom(),type:z.literal(`result`)}),status:z.literal(`completed`)}),z.strictObject({...taskViewBaseShape,lastOutput:z.strictObject({data:z.custom(),type:z.literal(`error`)}),status:z.literal(`failed`)}),z.strictObject({...taskViewBaseShape,status:z.literal(`cancelled`)})]),sessionTaskIndexEntrySchema=z.strictObject({taskInboxToken:z.string().min(1),createdByStepIndex:z.number().int().nonnegative().optional(),createdByTurnId:z.string().min(1),metadata:taskMetadataSchema,operationId:z.string().min(1),taskId:z.string().min(1),taskRunId:z.string().min(1),terminalView:taskViewSchema.optional()}),sessionTaskIndexSchema=z.strictObject({tasks:z.array(sessionTaskIndexEntrySchema)}).refine(e=>new Set(e.tasks.map(e=>e.taskId)).size===e.tasks.length,{message:`Task ids must be unique.`}).refine(e=>e.tasks.every(e=>e.terminalView===void 0||e.terminalView.taskId===e.taskId&&sameTaskMetadata(e.terminalView.metadata,e.metadata)),{message:`Cached terminal views must match their task index entry.`});function getSessionTaskIndex(e){let n=e?.[SESSION_TASKS_STATE_KEY];if(n===void 0)return[];let r=sessionTaskIndexSchema.safeParse(n);if(!r.success)throw Error(`Corrupt task index under session state key "${SESSION_TASKS_STATE_KEY}": ${r.error.message}`);return r.data.tasks}function cacheTerminalTaskView(e,n){if(!isValidTerminalView(n))throw Error(`Cannot cache invalid terminal task "${n.taskId}".`);let r=getSessionTaskIndex(e),i=r.findIndex(e=>e.taskId===n.taskId);if(i<0)return e;if(!sameTaskMetadata(r[i].metadata,n.metadata))throw Error(`Task view metadata does not match index entry "${n.taskId}".`);let a=[...r];return a[i]={...a[i],terminalView:n},{...e,[SESSION_TASKS_STATE_KEY]:{tasks:a}}}function isValidTerminalView(e){if(e.inputRequests!==void 0)return!1;switch(e.status){case`completed`:return e.lastOutput?.type===`result`;case`failed`:return e.lastOutput?.type===`error`;case`cancelled`:return e.lastOutput===void 0;case`working`:return!1}}function sameTaskMetadata(e,t){return e.agentId===t.agentId&&e.kind===t.kind&&e.mode===t.mode&&e.name===t.name}function findSessionTaskEntry(e,t){return getSessionTaskIndex(e).find(e=>e.taskId===t)}function recordSessionTask(e,n){let r=[...getSessionTaskIndex(e.state).filter(e=>e.taskId!==n.taskId),n];return{...e,state:{...e.state,[SESSION_TASKS_STATE_KEY]:{tasks:r}}}}export{SESSION_TASKS_STATE_KEY,cacheTerminalTaskView,findSessionTaskEntry,getSessionTaskIndex,recordSessionTask};
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Derives the stable task id for one originating subagent call.
3
+ *
4
+ * Reuses the agent-handle operation-id derivation —
5
+ * `hash(parentSessionId, parentTurnId, callId)` — so replayed creation
6
+ * for the same call yields the same task without new machinery, and a
7
+ * task can never be confused with a child session id or continuation
8
+ * token.
9
+ *
10
+ * Lives apart from the pure task modules because the derivation needs
11
+ * `node:crypto`, which workflow bodies reject; ids are only ever minted
12
+ * inside dispatch steps.
13
+ */
14
+ export declare function deriveTaskId(input: {
15
+ readonly callId: string;
16
+ readonly parentSessionId: string;
17
+ readonly parentTurnId: string;
18
+ }): string;
19
+ /**
20
+ * Derives the task run's private inbox token.
21
+ *
22
+ * Deterministic on purpose: a durable replay of the dispatch step must
23
+ * re-derive the same token so the duplicate task run loses the hook
24
+ * claim and exits instead of splitting the lifecycle across two runs.
25
+ * Unguessable in practice: the parent session's continuation token is
26
+ * itself a private capability, and the derived token never renders to
27
+ * the model.
28
+ */
29
+ export declare function deriveTaskInboxToken(input: {
30
+ readonly parentContinuationToken: string;
31
+ readonly taskId: string;
32
+ }): string;
33
+ /** Reads the non-secret task id embedded in a private task inbox token. */
34
+ export declare function readTaskIdFromInboxToken(token: string): string | undefined;
@@ -0,0 +1 @@
1
+ import{createHash}from"node:crypto";import{deriveAgentOperationId}from"#harness/handles/operation-id.js";function deriveTaskId(e){return`task_${deriveAgentOperationId(e).slice(0,24)}`}function deriveTaskInboxToken(t){return`task:${t.taskId}:${createHash(`sha256`).update(`${t.taskId}\0${t.parentContinuationToken}`).digest(`hex`).slice(0,32)}`}function readTaskIdFromInboxToken(e){return/^task:(task_[^:]+):[a-f0-9]{32}$/.exec(e)?.[1]}export{deriveTaskId,deriveTaskInboxToken,readTaskIdFromInboxToken};
@@ -0,0 +1,23 @@
1
+ import type { TaskCommand, TaskView } from "#tasks/types.js";
2
+ /**
3
+ * Outcome of applying one command to a task view.
4
+ *
5
+ * - `accepted`: the state changed; the new view must be appended.
6
+ * - `noop`: the command is recognized and benign (idempotent cancel,
7
+ * stale answer); nothing changed and nothing is appended.
8
+ * - `rejected`: the command is invalid for the current status; the
9
+ * reason is diagnostic only.
10
+ */
11
+ type TaskTransitionResult = {
12
+ readonly outcome: "accepted";
13
+ readonly view: TaskView;
14
+ } | {
15
+ readonly outcome: "noop";
16
+ readonly view: TaskView;
17
+ } | {
18
+ readonly outcome: "rejected";
19
+ readonly view: TaskView;
20
+ readonly reason: string;
21
+ };
22
+ export declare function applyTaskTransition(view: TaskView, command: TaskCommand): TaskTransitionResult;
23
+ export {};
@@ -0,0 +1 @@
1
+ import{isTerminalTaskStatus,readTaskInputRequestId}from"#tasks/types.js";function terminalView(e,t,n){let r={executor:t.lifecycle===void 0?e.executor:{...e.executor,lifecycle:t.lifecycle},metadata:e.metadata,taskId:e.taskId};switch(t.usage!==void 0&&(r.usage=t.usage),n.status){case`completed`:return{...r,lastOutput:n.lastOutput,status:`completed`};case`failed`:return{...r,lastOutput:n.lastOutput,status:`failed`};case`cancelled`:return{...r,status:`cancelled`}}}function applyTaskTransition(n,r){if(isTerminalTaskStatus(n.status)){if(r.kind===`settle-executor`){let e={...n.executor,lifecycle:`terminal`};if(sameUsage(n.usage,r.usage)&&n.executor?.lifecycle===`terminal`)return{outcome:`noop`,view:n};let t={...n,executor:e};return{outcome:`accepted`,view:r.usage===void 0?t:{...t,usage:r.usage}}}return r.kind===`cancel`&&n.status===`cancelled`?{outcome:`noop`,view:n}:{outcome:`rejected`,reason:`Task "${n.taskId}" is already ${n.status}; "${r.kind}" cannot change a terminal task.`,view:n}}switch(r.kind){case`complete`:return{outcome:`accepted`,view:terminalView(n,r,{lastOutput:{data:r.data,type:`result`},status:`completed`})};case`fail`:case`reject-dispatch`:return{outcome:`accepted`,view:terminalView(n,r,{lastOutput:{data:r.data,type:`error`},status:`failed`})};case`cancel`:return{outcome:`accepted`,view:terminalView(n,r,{status:`cancelled`})};case`settle-executor`:return{outcome:`rejected`,reason:`Task "${n.taskId}" is not terminal; usage settles with its terminal command.`,view:n};case`require-authorization`:{let e={blockedOn:`authorization`,requestId:r.requestId};return n.status===`input_required`?n.inputRequests.some(e=>readTaskInputRequestId(e)===r.requestId)?{outcome:`noop`,view:n}:{outcome:`accepted`,view:{...n,inputRequests:[...n.inputRequests,e]}}:{outcome:`accepted`,view:{inputRequests:[e],executor:n.executor,metadata:n.metadata,status:`input_required`,taskId:n.taskId}}}case`require-input`:return isValidInputRequestBatch(r.inputRequests)?{outcome:`accepted`,view:{inputRequests:r.inputRequests,executor:n.executor,metadata:n.metadata,status:`input_required`,taskId:n.taskId}}:{outcome:`rejected`,reason:`Task "${n.taskId}" received an invalid input request batch.`,view:n};case`ready`:return{outcome:`accepted`,view:n};case`answered`:{if(n.status!==`input_required`)return{outcome:`noop`,view:n};let e=new Set(r.requestIds),i=n.inputRequests,a=i.filter(n=>{let r=readTaskInputRequestId(n);return r===void 0||!e.has(r)});return a.length===i.length?{outcome:`noop`,view:n}:a.length>0?{outcome:`accepted`,view:{inputRequests:a,executor:n.executor,metadata:n.metadata,status:`input_required`,taskId:n.taskId}}:{outcome:`accepted`,view:{executor:n.executor,metadata:n.metadata,status:`working`,taskId:n.taskId}}}case`start-turn`:return r.taskId===n.taskId?n.executor?.childSessionId!==void 0&&n.executor.childSessionId!==r.childSessionId?{outcome:`rejected`,reason:`Task child session "${r.childSessionId}" does not match "${n.executor.childSessionId}".`,view:n}:n.executor?.childSessionId===r.childSessionId&&n.executor.childTurnId===r.childTurnId?{outcome:`noop`,view:n}:{outcome:`accepted`,view:{...n,executor:{...n.executor,childSessionId:r.childSessionId,childTurnId:r.childTurnId}}}:{outcome:`rejected`,reason:`Task turn identity "${r.taskId}" does not match "${n.taskId}".`,view:n}}}function isValidInputRequestBatch(e){if(e.length===0)return!1;let n=e.map(readTaskInputRequestId);return n.every(e=>e!==void 0&&e.length>0)&&new Set(n).size===n.length}function sameUsage(e,t){return e===void 0||t===void 0?e===t:e?.cacheReadTokens===t.cacheReadTokens&&e.cacheWriteTokens===t.cacheWriteTokens&&e.inputTokens===t.inputTokens&&e.outputTokens===t.outputTokens}export{applyTaskTransition};
@@ -0,0 +1,295 @@
1
+ import type { JsonValue } from "#shared/json.js";
2
+ import type { SubagentAuthorizationEvent } from "#channel/types.js";
3
+ /**
4
+ * Task lifecycle contract for `experimental.tasks`.
5
+ *
6
+ * A task is one durable unit of delegated work owned by a parent session.
7
+ * The durable task run is the single writer for lifecycle transitions
8
+ * (see `#execution/tasks/child/workflow.js`); every other path submits
9
+ * commands and reads views. This module is dependency-free on
10
+ * purpose: it is bundled into workflow bodies, which reject Node.js
11
+ * builtins and heavyweight validators.
12
+ */
13
+ /**
14
+ * Task lifecycle status.
15
+ *
16
+ * `completed`, `failed`, and `cancelled` are terminal and final.
17
+ * `input_required` is not terminal but is ready for parent action; the
18
+ * child must wake its parent rather than deadlock while waiting for input.
19
+ */
20
+ export type TaskStatus = "working" | "input_required" | "completed" | "failed" | "cancelled";
21
+ /**
22
+ * Immutable identity of the delegated work behind a task.
23
+ *
24
+ * `agentId` is parent-controlled and exists before the child acknowledges its
25
+ * private address, so the durable task can bind to persistent identity before
26
+ * the dispatch side effect runs.
27
+ */
28
+ export interface TaskMetadata {
29
+ /** Stable model-visible identity of the persistent child session. */
30
+ readonly agentId: string;
31
+ readonly kind: "subagent";
32
+ readonly mode: "local" | "remote";
33
+ /** Authored subagent name the parent dispatched. */
34
+ readonly name: string;
35
+ }
36
+ /** Private executor state retained for cancellation and address reconciliation. */
37
+ export interface TaskExecutorState {
38
+ readonly childSessionId?: string;
39
+ readonly childTurnId?: string;
40
+ readonly lifecycle?: "parked" | "terminal";
41
+ }
42
+ /**
43
+ * Terminal task output. Failure is the state (`failed`); the `error`
44
+ * output is its consequence — a `failed` task always carries one.
45
+ * This intentionally diverges from MCP, which reserves `failed` for
46
+ * protocol-level errors.
47
+ */
48
+ export type TaskOutput = {
49
+ readonly type: "result";
50
+ readonly data: JsonValue;
51
+ } | {
52
+ readonly type: "error";
53
+ readonly data: JsonValue;
54
+ };
55
+ /**
56
+ * One outstanding request forwarded from a blocked child. Carried
57
+ * opaquely: the task layer routes the batch, the input contract owns
58
+ * its shape.
59
+ */
60
+ export type TaskInputRequest = JsonValue;
61
+ /**
62
+ * Provider token usage a child turn reported. Structural on purpose: it
63
+ * mirrors `TokenUsage` (#shared/token-usage.js) without importing its
64
+ * zod-backed module into a workflow-bundled file.
65
+ */
66
+ export interface TaskUsage {
67
+ readonly cacheReadTokens: number;
68
+ readonly cacheWriteTokens: number;
69
+ readonly inputTokens: number;
70
+ readonly outputTokens: number;
71
+ }
72
+ /**
73
+ * Validates one wire-carried usage value into {@link TaskUsage}.
74
+ * Anything malformed is dropped rather than rejected: retention is
75
+ * best-effort and must never fail a lifecycle transition.
76
+ */
77
+ export declare function readTaskUsage(value: unknown): TaskUsage | undefined;
78
+ /**
79
+ * One human answer to an outstanding request. Structural on purpose: it
80
+ * mirrors the input contract's `InputResponse` without importing its
81
+ * zod-backed module into a workflow-bundled file.
82
+ */
83
+ export interface TaskInputResponse {
84
+ readonly optionId?: string;
85
+ readonly requestId: string;
86
+ readonly text?: string;
87
+ }
88
+ /** Stable task blocker id shared by one authorization attempt's events. */
89
+ export declare function taskAuthorizationRequestId(event: SubagentAuthorizationEvent): string;
90
+ /** Reads the `requestId` of one opaque outstanding request. */
91
+ export declare function readTaskInputRequestId(request: TaskInputRequest): string | undefined;
92
+ /** Fields shared by every durable task view. */
93
+ interface TaskViewBase {
94
+ readonly taskId: string;
95
+ readonly metadata: TaskMetadata;
96
+ /** Private executor state; deliberately excluded from model-visible JSON. */
97
+ readonly executor?: TaskExecutorState;
98
+ /**
99
+ * Provider usage the child reported at settlement; present when the
100
+ * terminal command carried it. Retained for later accounting only —
101
+ * budgets stay best-effort until a reservation model lands — and
102
+ * deliberately excluded from model-visible task views (tasks/json.ts).
103
+ */
104
+ readonly usage?: TaskUsage;
105
+ }
106
+ /**
107
+ * Full durable task view discriminated by lifecycle status.
108
+ *
109
+ * The task run appends one per accepted command; readers always observe a
110
+ * complete view, never a delta. A view never contains routing credentials,
111
+ * continuation tokens, or authorization capabilities.
112
+ *
113
+ * Completed and failed tasks carry their corresponding output, cancelled
114
+ * tasks carry no output, and only input-required tasks carry requests.
115
+ */
116
+ export type TaskView = TaskViewBase & ({
117
+ readonly status: "working";
118
+ readonly inputRequests?: never;
119
+ readonly lastOutput?: never;
120
+ } | {
121
+ readonly status: "input_required";
122
+ readonly inputRequests: readonly TaskInputRequest[];
123
+ readonly lastOutput?: never;
124
+ } | {
125
+ readonly status: "completed";
126
+ readonly inputRequests?: never;
127
+ readonly lastOutput: Extract<TaskOutput, {
128
+ type: "result";
129
+ }>;
130
+ } | {
131
+ readonly status: "failed";
132
+ readonly inputRequests?: never;
133
+ readonly lastOutput: Extract<TaskOutput, {
134
+ type: "error";
135
+ }>;
136
+ } | {
137
+ readonly status: "cancelled";
138
+ readonly inputRequests?: never;
139
+ readonly lastOutput?: never;
140
+ });
141
+ /** Commands accepted by the durable task run's transition function. */
142
+ export type TaskCommand = {
143
+ readonly kind: "complete";
144
+ readonly data: JsonValue;
145
+ readonly lifecycle?: "parked" | "terminal";
146
+ readonly usage?: TaskUsage;
147
+ } | {
148
+ readonly kind: "fail";
149
+ readonly data: JsonValue;
150
+ readonly lifecycle?: "parked" | "terminal";
151
+ readonly usage?: TaskUsage;
152
+ }
153
+ /** Terminal dispatch rejection for a task that was never indexed by its parent. */
154
+ | {
155
+ readonly kind: "reject-dispatch";
156
+ readonly data: JsonValue;
157
+ readonly lifecycle?: never;
158
+ readonly usage?: never;
159
+ } | {
160
+ readonly kind: "cancel";
161
+ readonly lifecycle?: "parked" | "terminal";
162
+ readonly usage?: TaskUsage;
163
+ }
164
+ /** Retains a late executor settlement without changing task terminal status. */
165
+ | {
166
+ readonly kind: "settle-executor";
167
+ readonly usage?: TaskUsage;
168
+ } | {
169
+ readonly kind: "require-authorization";
170
+ readonly requestId: string;
171
+ } | {
172
+ readonly kind: "require-input";
173
+ readonly inputRequests: readonly TaskInputRequest[];
174
+ } | {
175
+ readonly kind: "ready";
176
+ }
177
+ /**
178
+ * Clears the listed requests from the outstanding batch. Bound to
179
+ * ids rather than unbound like the former `resume`, so an answer can
180
+ * only ever release the batch it was written against.
181
+ */
182
+ | {
183
+ readonly kind: "answered";
184
+ readonly requestIds: readonly string[];
185
+ } | {
186
+ readonly kind: "start-turn";
187
+ readonly childSessionId: string;
188
+ readonly childTurnId: string;
189
+ readonly taskId: string;
190
+ };
191
+ /** Hook payload envelope commanding a durable task run. */
192
+ export interface TaskCommandHookPayload {
193
+ readonly kind: "task-command";
194
+ readonly command: TaskCommand;
195
+ }
196
+ /**
197
+ * Structural shapes of the child wire payloads a task run consumes.
198
+ *
199
+ * These mirror the existing parent-notification contracts (the local
200
+ * `notifyDelegatedParentStep`, the subagent adapter's HITL forwarding,
201
+ * and the remote callback route) without importing their zod-backed
202
+ * modules: this file is bundled into workflow bodies. The wire itself
203
+ * is unchanged — delegated dispatch only points it at the task run's
204
+ * hook instead of the parent turn's inbox.
205
+ */
206
+ export interface TaskInboundChildResult {
207
+ readonly kind: "runtime-action-result";
208
+ readonly results: readonly {
209
+ readonly isError?: boolean;
210
+ readonly outcome?: {
211
+ readonly kind: "parked" | "terminal";
212
+ readonly result: {
213
+ readonly kind: "succeeded";
214
+ readonly output: JsonValue;
215
+ } | {
216
+ readonly error: JsonValue;
217
+ readonly kind: "failed";
218
+ } | {
219
+ readonly kind: "cancelled";
220
+ };
221
+ /**
222
+ * Provider usage this turn added. Retained on the terminal task
223
+ * view ({@link TaskView.usage}); folding it into parent
224
+ * budgets is deferred until a reservation model lands.
225
+ */
226
+ readonly usageDelta?: unknown;
227
+ };
228
+ readonly output: JsonValue;
229
+ }[];
230
+ }
231
+ /**
232
+ * Arrives when the delegated child emits `input.requested`. After dispatch is
233
+ * acknowledged, the task run exposes the batch in an `input_required`
234
+ * view and forwards the request to the parent session.
235
+ */
236
+ export interface TaskInboundInputRequest {
237
+ readonly callId: string;
238
+ readonly childContinuationToken: string;
239
+ readonly childSessionId: string;
240
+ readonly kind: "subagent-input-request";
241
+ readonly event: {
242
+ readonly requests: readonly TaskInputRequest[];
243
+ readonly sequence: number;
244
+ readonly stepIndex: number;
245
+ readonly turnId: string;
246
+ };
247
+ readonly subagentName: string;
248
+ }
249
+ /**
250
+ * Arrives when a delegated child turn starts and its session and turn ids are
251
+ * known. The task run records those ids for executor addressing; this payload
252
+ * does not itself make the task ready or wake the parent.
253
+ */
254
+ export interface TaskInboundTurnStarted {
255
+ readonly childSessionId: string;
256
+ readonly childTurnId: string;
257
+ readonly kind: "turn-started";
258
+ readonly taskId: string;
259
+ }
260
+ /**
261
+ * Arrives when the delegated child emits `authorization.required` or
262
+ * `authorization.completed`. The former exposes an authorization blocker in
263
+ * the task view; the latter clears it. The event is forwarded separately
264
+ * to the parent and is never copied into the view.
265
+ */
266
+ export interface TaskInboundAuthorizationEvent {
267
+ readonly callId: string;
268
+ readonly childSessionId: string;
269
+ readonly kind: "authorization-event";
270
+ readonly event: SubagentAuthorizationEvent;
271
+ readonly subagentName: string;
272
+ }
273
+ /**
274
+ * Human answers routed to the task run rather than straight to the
275
+ * child. The run owns both the delivery and the state change, so the
276
+ * batch it clears is exactly the batch it forwarded — the parent can no
277
+ * longer unblock the child while the run still believes it is blocked.
278
+ */
279
+ export interface TaskInboundAnswerInput {
280
+ readonly auth?: unknown;
281
+ readonly childContinuationToken: string;
282
+ readonly childResponseUrl?: string;
283
+ readonly inputResponses: readonly TaskInputResponse[];
284
+ readonly kind: "input-response";
285
+ readonly taskId: string;
286
+ }
287
+ /** Everything a task run's inbound continuation hook may receive. */
288
+ export type TaskRunInboundPayload = TaskCommandHookPayload | TaskInboundChildResult | TaskInboundInputRequest | TaskInboundTurnStarted | TaskInboundAuthorizationEvent | TaskInboundAnswerInput;
289
+ /** Namespaced run stream carrying appended `TaskView` records. */
290
+ export declare const TASK_VIEW_STREAM_NAMESPACE = "eve.task";
291
+ /** True when the status can never change again. */
292
+ export declare function isTerminalTaskStatus(status: TaskStatus): boolean;
293
+ /** True when a transition into this status should wake the parent. */
294
+ export declare function isReadyTaskStatus(status: TaskStatus): boolean;
295
+ export {};
@@ -0,0 +1 @@
1
+ function readTaskUsage(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=readUsageAxis(e,`cacheReadTokens`),n=readUsageAxis(e,`cacheWriteTokens`),r=readUsageAxis(e,`inputTokens`),i=readUsageAxis(e,`outputTokens`);if(!(t===void 0||n===void 0||r===void 0||i===void 0))return{cacheReadTokens:t,cacheWriteTokens:n,inputTokens:r,outputTokens:i}}function readUsageAxis(e,t){let n=Reflect.get(e,t);return typeof n==`number`&&Number.isFinite(n)&&n>=0?n:void 0}const TASK_AUTHORIZATION_REQUEST_ID_PREFIX=`task:authorization`;function taskAuthorizationRequestId(t){return t.type===`approval.candidate`||t.type===`approval.settled`?`${TASK_AUTHORIZATION_REQUEST_ID_PREFIX}:${t.data.requestId}`:`${TASK_AUTHORIZATION_REQUEST_ID_PREFIX}:${t.data.attemptId??t.data.name}`}function readTaskInputRequestId(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=Reflect.get(e,`requestId`);return typeof t==`string`?t:void 0}const TASK_VIEW_STREAM_NAMESPACE=`eve.task`;function isTerminalTaskStatus(e){return e===`completed`||e===`failed`||e===`cancelled`}function isReadyTaskStatus(e){return e===`input_required`||isTerminalTaskStatus(e)}export{TASK_VIEW_STREAM_NAMESPACE,isReadyTaskStatus,isTerminalTaskStatus,readTaskInputRequestId,readTaskUsage,taskAuthorizationRequestId};
@@ -0,0 +1,26 @@
1
+ import type { TaskCommand, TaskRunInboundPayload } from "#tasks/types.js";
2
+ /**
3
+ * Translates one inbound hook payload into a lifecycle command.
4
+ *
5
+ * The child wire is unchanged by `experimental.tasks`; delegated
6
+ * dispatch hands children the task run's hook token, so the payloads
7
+ * that used to resume the parent turn arrive here instead:
8
+ *
9
+ * - a settled child turn (local notification or remote callback)
10
+ * carries an explicit outcome — its result status decides
11
+ * `complete`, `fail`, or `cancel`;
12
+ * - a forwarded HITL batch marks the task `input_required` with the
13
+ * outstanding requests;
14
+ * - `authorization.required` also blocks the task (the child cannot
15
+ * proceed without the parent's user) under a reserved request id, and
16
+ * `authorization.completed` clears exactly that id. Authorization
17
+ * payloads never enter the view — only the fact that the child is
18
+ * blocked does.
19
+ *
20
+ * `input-response` is deliberately absent: the run must forward the
21
+ * answers to the child before it may record them, so it builds that
22
+ * command itself rather than translating one here.
23
+ *
24
+ * Returns `undefined` for unrecognized payloads, which the run ignores.
25
+ */
26
+ export declare function translateTaskInboundPayload(payload: TaskRunInboundPayload): TaskCommand | undefined;
@@ -0,0 +1 @@
1
+ import{readTaskUsage,taskAuthorizationRequestId}from"#tasks/types.js";function translateTaskInboundPayload(n){switch(n.kind){case`task-command`:return n.command;case`runtime-action-result`:{let t=n.results[0];if(t===void 0)return;if(t.outcome!==void 0){let n=readTaskUsage(t.outcome.usageDelta);switch(t.outcome.result.kind){case`succeeded`:return withUsage({data:t.output,kind:`complete`,lifecycle:t.outcome.kind},n);case`failed`:return withUsage({data:t.output,kind:`fail`,lifecycle:t.outcome.kind},n);case`cancelled`:return withUsage({kind:`cancel`,lifecycle:t.outcome.kind},n)}}return}case`subagent-input-request`:return{inputRequests:n.event.requests,kind:`require-input`};case`turn-started`:return{childSessionId:n.childSessionId,childTurnId:n.childTurnId,kind:`start-turn`,taskId:n.taskId};case`authorization-event`:{let e=taskAuthorizationRequestId(n.event);return n.event.type===`authorization.required`?{kind:`require-authorization`,requestId:e}:{kind:`answered`,requestIds:[e]}}default:return}}function withUsage(e,t){return t===void 0?e:{...e,usage:t}}export{translateTaskInboundPayload};
@@ -1,3 +1,3 @@
1
- import { n as defaultMessageReducer, t as useEveAgent } from "../chunks/use-eve-agent-CnppTEFk.js";
1
+ import { n as defaultMessageReducer, t as useEveAgent } from "../chunks/use-eve-agent-Bi5fRxcZ.js";
2
2
 
3
3
  export { defaultMessageReducer, useEveAgent };
@@ -1,3 +1,3 @@
1
- import { t as useEveAgent } from "../chunks/use-eve-agent-CnppTEFk.js";
1
+ import { t as useEveAgent } from "../chunks/use-eve-agent-Bi5fRxcZ.js";
2
2
 
3
3
  export { useEveAgent };
@@ -45,6 +45,20 @@ curl -X POST https://<deployment>/eve/v1/session \
45
45
  # {"ok":true,"sessionId":"wrun_A","status":"accepted"}
46
46
  ```
47
47
 
48
+ Authenticated callers that may retry a create request can pass their own `operationId` for
49
+ create-once semantics. The same operation under the same authenticated principal returns the
50
+ active session it already created instead of dispatching the input again. The first accepted
51
+ payload wins; retries with different input still return that first session. Anonymous callers
52
+ cannot use `operationId`, and operation ownership expires when the session is no longer resumable.
53
+
54
+ ```bash
55
+ curl -X POST https://<deployment>/eve/v1/session \
56
+ -H "Authorization: Bearer <token>" \
57
+ -H "Content-Type: application/json" \
58
+ -d '{"message":"What is the weather in Paris?","operationId":"order-4213-research"}'
59
+ # {"ok":true,"sessionId":"wrun_A","status":"accepted"} — retries return the same sessionId
60
+ ```
61
+
48
62
  The first request requires `message`. A follow-up request accepts exactly one of
49
63
  `message` or `inputResponses`; use the latter to answer a pending HITL request:
50
64
 
@@ -126,7 +126,7 @@ If you support refresh while an authorization prompt is pending, keep the sessio
126
126
 
127
127
  ## Reconnection
128
128
 
129
- HTTP connections can end before a run does. The client reconnects from the number of events already consumed, so long turns continue without replaying events. It stops at a turn boundary, when aborted, or when the stream can no longer make progress.
129
+ HTTP connections can end before a run does. The client reconnects from the number of events already consumed, so long turns continue without replaying events. By default, a turn response keeps reconnecting until it reaches a turn boundary or is aborted, including while the turn is paused for authorization. A manually opened `session.stream()` eventually stops after repeated empty streams when it can no longer make progress.
130
130
 
131
131
  If your consumer persists events, key on `event.meta.id`. It is stable across reconnects and rewinds, so an overlapping replay is safe to ingest twice. See [the event envelope](../../concepts/sessions-runs-and-streaming#the-event-envelope).
132
132