experimental-ash 0.35.0 → 0.37.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 (144) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +7 -7
  3. package/dist/docs/internals/context.md +6 -5
  4. package/dist/docs/internals/core-beliefs.md +2 -2
  5. package/dist/docs/internals/hooks.md +16 -11
  6. package/dist/docs/internals/mechanical-invariants.md +4 -4
  7. package/dist/docs/internals/testing.md +1 -1
  8. package/dist/docs/public/README.md +11 -11
  9. package/dist/docs/public/{auth-and-route-protection.md → advanced/auth-and-route-protection.md} +5 -4
  10. package/dist/docs/public/{cli-build-and-debugging.md → advanced/cli-build-and-debugging.md} +2 -1
  11. package/dist/docs/public/{context-control.md → advanced/context-control.md} +1 -0
  12. package/dist/docs/public/{evals.md → advanced/evals.md} +1 -0
  13. package/dist/docs/public/{faqs.md → advanced/faqs.md} +5 -5
  14. package/dist/docs/public/{hooks.md → advanced/hooks.md} +19 -23
  15. package/dist/docs/public/{instrumentation.md → advanced/instrumentation.md} +1 -0
  16. package/dist/docs/public/advanced/meta.json +19 -0
  17. package/dist/docs/public/{project-layout.md → advanced/project-layout.md} +1 -0
  18. package/dist/docs/public/{runs-and-streaming.md → advanced/runs-and-streaming.md} +1 -0
  19. package/dist/docs/public/{session-context.md → advanced/session-context.md} +26 -27
  20. package/dist/docs/public/{typescript-api.md → advanced/typescript-api.md} +11 -11
  21. package/dist/docs/public/{vercel-deployment.md → advanced/vercel-deployment.md} +1 -0
  22. package/dist/docs/public/{workspace.md → advanced/workspace.md} +1 -0
  23. package/dist/docs/public/channels/{README.md → index.md} +2 -2
  24. package/dist/docs/public/channels/slack.md +3 -3
  25. package/dist/docs/public/meta.json +1 -14
  26. package/dist/docs/public/sandbox.md +9 -11
  27. package/dist/docs/public/schedules.md +1 -1
  28. package/dist/docs/public/skills.md +3 -4
  29. package/dist/docs/public/subagents.md +1 -1
  30. package/dist/docs/public/tools.md +13 -17
  31. package/dist/src/channel/session.d.ts +3 -29
  32. package/dist/src/channel/session.js +1 -1
  33. package/dist/src/context/accessors.d.ts +0 -25
  34. package/dist/src/context/accessors.js +1 -1
  35. package/dist/src/context/build-callback-context.d.ts +8 -0
  36. package/dist/src/context/build-callback-context.js +1 -0
  37. package/dist/src/context/hook-lifecycle.js +1 -1
  38. package/dist/src/context/keys.d.ts +2 -2
  39. package/dist/src/evals/define-eval-suite.d.ts +3 -2
  40. package/dist/src/evals/types.d.ts +38 -12
  41. package/dist/src/execution/node-step.js +1 -1
  42. package/dist/src/execution/sandbox/bash-tool.d.ts +2 -1
  43. package/dist/src/execution/sandbox/bash-tool.js +1 -1
  44. package/dist/src/execution/sandbox/glob-tool.d.ts +2 -1
  45. package/dist/src/execution/sandbox/glob-tool.js +3 -3
  46. package/dist/src/execution/sandbox/grep-tool.d.ts +2 -1
  47. package/dist/src/execution/sandbox/grep-tool.js +3 -3
  48. package/dist/src/execution/sandbox/read-file-tool.d.ts +2 -1
  49. package/dist/src/execution/sandbox/read-file-tool.js +1 -1
  50. package/dist/src/execution/sandbox/write-file-tool.d.ts +2 -1
  51. package/dist/src/execution/sandbox/write-file-tool.js +1 -1
  52. package/dist/src/execution/skills/types.d.ts +1 -1
  53. package/dist/src/execution/tool-compaction.js +1 -1
  54. package/dist/src/harness/code-mode-approval.js +1 -1
  55. package/dist/src/harness/code-mode.js +1 -1
  56. package/dist/src/harness/step-hooks.d.ts +1 -1
  57. package/dist/src/harness/tool-loop.js +1 -1
  58. package/dist/src/internal/application/package.js +1 -1
  59. package/dist/src/internal/workflow-bundle/builder.js +2 -2
  60. package/dist/src/node_modules/.pnpm/{experimental-ai-sdk-code-mode@1.0.9_ai@7.0.0-canary.154_zod@4.4.3_ → experimental-ai-sdk-code-mode@1.0.10_ai@7.0.0-canary.154_zod@4.4.3_}/node_modules/experimental-ai-sdk-code-mode/dist/index.js +1 -1
  61. package/dist/src/node_modules/.pnpm/experimental-ai-sdk-code-mode@1.0.10_ai@7.0.0-canary.154_zod@4.4.3_/node_modules/experimental-ai-sdk-code-mode/dist/runtime/manager.js +1 -0
  62. package/dist/src/node_modules/.pnpm/experimental-ai-sdk-code-mode@1.0.10_ai@7.0.0-canary.154_zod@4.4.3_/node_modules/experimental-ai-sdk-code-mode/dist/runtime/worker-source.js +408 -0
  63. package/dist/src/packages/ash-scaffold/src/channels.js +2 -12
  64. package/dist/src/packages/ash-scaffold/src/pnpm-workspace.js +11 -0
  65. package/dist/src/packages/ash-scaffold/src/project.js +1 -1
  66. package/dist/src/public/channels/discord/defaults.js +2 -2
  67. package/dist/src/public/channels/discord/discordChannel.d.ts +4 -4
  68. package/dist/src/public/channels/discord/discordChannel.js +1 -1
  69. package/dist/src/public/channels/index.d.ts +1 -1
  70. package/dist/src/public/channels/slack/defaults.js +4 -4
  71. package/dist/src/public/channels/slack/slackChannel.d.ts +4 -4
  72. package/dist/src/public/channels/slack/slackChannel.js +1 -1
  73. package/dist/src/public/channels/teams/defaults.js +3 -3
  74. package/dist/src/public/channels/teams/teamsChannel.d.ts +4 -4
  75. package/dist/src/public/channels/teams/teamsChannel.js +1 -1
  76. package/dist/src/public/channels/telegram/defaults.js +2 -2
  77. package/dist/src/public/channels/telegram/telegramChannel.d.ts +4 -4
  78. package/dist/src/public/channels/telegram/telegramChannel.js +1 -1
  79. package/dist/src/public/channels/twilio/defaults.js +2 -2
  80. package/dist/src/public/channels/twilio/twilioChannel.d.ts +4 -4
  81. package/dist/src/public/channels/twilio/twilioChannel.js +1 -1
  82. package/dist/src/public/context/index.d.ts +3 -2
  83. package/dist/src/public/context/index.js +1 -1
  84. package/dist/src/public/definitions/agent.d.ts +2 -1
  85. package/dist/src/public/definitions/callback-context.d.ts +22 -0
  86. package/dist/src/public/definitions/callback-context.js +1 -0
  87. package/dist/src/public/definitions/defineChannel.d.ts +16 -4
  88. package/dist/src/public/definitions/defineChannel.js +1 -1
  89. package/dist/src/public/definitions/exact.d.ts +7 -0
  90. package/dist/src/public/definitions/exact.js +1 -0
  91. package/dist/src/public/definitions/hook.d.ts +10 -49
  92. package/dist/src/public/definitions/instructions.d.ts +2 -1
  93. package/dist/src/public/definitions/instrumentation.d.ts +2 -1
  94. package/dist/src/public/definitions/schedule.d.ts +12 -2
  95. package/dist/src/public/definitions/skill.d.ts +2 -1
  96. package/dist/src/public/definitions/tool.d.ts +14 -15
  97. package/dist/src/public/hooks/index.d.ts +1 -1
  98. package/dist/src/public/sandbox/index.d.ts +0 -1
  99. package/dist/src/public/sandbox/index.js +1 -1
  100. package/dist/src/public/skills/index.d.ts +0 -1
  101. package/dist/src/public/skills/index.js +1 -1
  102. package/dist/src/public/tools/defaults.js +1 -1
  103. package/dist/src/public/tools/define-bash-tool.js +1 -1
  104. package/dist/src/public/tools/define-glob-tool.js +1 -1
  105. package/dist/src/public/tools/define-grep-tool.js +1 -1
  106. package/dist/src/public/tools/define-read-file-tool.js +1 -1
  107. package/dist/src/public/tools/define-write-file-tool.js +1 -1
  108. package/dist/src/public/tools/index.d.ts +2 -1
  109. package/dist/src/public/tools/internal.d.ts +4 -0
  110. package/dist/src/public/tools/internal.js +1 -1
  111. package/dist/src/runtime/framework-tools/bash.js +1 -1
  112. package/dist/src/runtime/framework-tools/connection-search.js +1 -1
  113. package/dist/src/runtime/framework-tools/connection-tools.js +1 -1
  114. package/dist/src/runtime/framework-tools/file-state.d.ts +2 -2
  115. package/dist/src/runtime/framework-tools/file-state.js +1 -1
  116. package/dist/src/runtime/framework-tools/glob.js +1 -1
  117. package/dist/src/runtime/framework-tools/grep.js +1 -1
  118. package/dist/src/runtime/framework-tools/read-file.js +2 -2
  119. package/dist/src/runtime/framework-tools/skill.js +1 -1
  120. package/dist/src/runtime/framework-tools/todo.js +1 -1
  121. package/dist/src/runtime/framework-tools/write-file.js +1 -1
  122. package/dist/src/runtime/governance/auth/types.d.ts +1 -1
  123. package/dist/src/runtime/types.d.ts +2 -2
  124. package/dist/src/sandbox/state.d.ts +1 -1
  125. package/package.json +2 -2
  126. package/dist/src/node_modules/.pnpm/experimental-ai-sdk-code-mode@1.0.9_ai@7.0.0-canary.154_zod@4.4.3_/node_modules/experimental-ai-sdk-code-mode/dist/runtime/manager.js +0 -1
  127. package/dist/src/node_modules/.pnpm/experimental-ai-sdk-code-mode@1.0.9_ai@7.0.0-canary.154_zod@4.4.3_/node_modules/experimental-ai-sdk-code-mode/dist/runtime/worker-source.js +0 -1153
  128. package/dist/src/node_modules/.pnpm/experimental-ai-sdk-code-mode@1.0.9_ai@7.0.0-canary.154_zod@4.4.3_/node_modules/experimental-ai-sdk-code-mode/dist/runtime-assets.js +0 -1
  129. /package/dist/src/node_modules/.pnpm/{experimental-ai-sdk-code-mode@1.0.9_ai@7.0.0-canary.154_zod@4.4.3_ → experimental-ai-sdk-code-mode@1.0.10_ai@7.0.0-canary.154_zod@4.4.3_}/node_modules/experimental-ai-sdk-code-mode/dist/approval-continuation.js +0 -0
  130. /package/dist/src/node_modules/.pnpm/{experimental-ai-sdk-code-mode@1.0.9_ai@7.0.0-canary.154_zod@4.4.3_ → experimental-ai-sdk-code-mode@1.0.10_ai@7.0.0-canary.154_zod@4.4.3_}/node_modules/experimental-ai-sdk-code-mode/dist/approval-response.js +0 -0
  131. /package/dist/src/node_modules/.pnpm/{experimental-ai-sdk-code-mode@1.0.9_ai@7.0.0-canary.154_zod@4.4.3_ → experimental-ai-sdk-code-mode@1.0.10_ai@7.0.0-canary.154_zod@4.4.3_}/node_modules/experimental-ai-sdk-code-mode/dist/code-mode-tool.js +0 -0
  132. /package/dist/src/node_modules/.pnpm/{experimental-ai-sdk-code-mode@1.0.9_ai@7.0.0-canary.154_zod@4.4.3_ → experimental-ai-sdk-code-mode@1.0.10_ai@7.0.0-canary.154_zod@4.4.3_}/node_modules/experimental-ai-sdk-code-mode/dist/continuation-capability.js +0 -0
  133. /package/dist/src/node_modules/.pnpm/{experimental-ai-sdk-code-mode@1.0.9_ai@7.0.0-canary.154_zod@4.4.3_ → experimental-ai-sdk-code-mode@1.0.10_ai@7.0.0-canary.154_zod@4.4.3_}/node_modules/experimental-ai-sdk-code-mode/dist/errors.js +0 -0
  134. /package/dist/src/node_modules/.pnpm/{experimental-ai-sdk-code-mode@1.0.9_ai@7.0.0-canary.154_zod@4.4.3_ → experimental-ai-sdk-code-mode@1.0.10_ai@7.0.0-canary.154_zod@4.4.3_}/node_modules/experimental-ai-sdk-code-mode/dist/fetch-policy.js +0 -0
  135. /package/dist/src/node_modules/.pnpm/{experimental-ai-sdk-code-mode@1.0.9_ai@7.0.0-canary.154_zod@4.4.3_ → experimental-ai-sdk-code-mode@1.0.10_ai@7.0.0-canary.154_zod@4.4.3_}/node_modules/experimental-ai-sdk-code-mode/dist/host-interrupt.js +0 -0
  136. /package/dist/src/node_modules/.pnpm/{experimental-ai-sdk-code-mode@1.0.9_ai@7.0.0-canary.154_zod@4.4.3_ → experimental-ai-sdk-code-mode@1.0.10_ai@7.0.0-canary.154_zod@4.4.3_}/node_modules/experimental-ai-sdk-code-mode/dist/interrupt-continuation.js +0 -0
  137. /package/dist/src/node_modules/.pnpm/{experimental-ai-sdk-code-mode@1.0.9_ai@7.0.0-canary.154_zod@4.4.3_ → experimental-ai-sdk-code-mode@1.0.10_ai@7.0.0-canary.154_zod@4.4.3_}/node_modules/experimental-ai-sdk-code-mode/dist/options.js +0 -0
  138. /package/dist/src/node_modules/.pnpm/{experimental-ai-sdk-code-mode@1.0.9_ai@7.0.0-canary.154_zod@4.4.3_ → experimental-ai-sdk-code-mode@1.0.10_ai@7.0.0-canary.154_zod@4.4.3_}/node_modules/experimental-ai-sdk-code-mode/dist/run-code-mode.js +0 -0
  139. /package/dist/src/node_modules/.pnpm/{experimental-ai-sdk-code-mode@1.0.9_ai@7.0.0-canary.154_zod@4.4.3_ → experimental-ai-sdk-code-mode@1.0.10_ai@7.0.0-canary.154_zod@4.4.3_}/node_modules/experimental-ai-sdk-code-mode/dist/runtime/max-workers.js +0 -0
  140. /package/dist/src/node_modules/.pnpm/{experimental-ai-sdk-code-mode@1.0.9_ai@7.0.0-canary.154_zod@4.4.3_ → experimental-ai-sdk-code-mode@1.0.10_ai@7.0.0-canary.154_zod@4.4.3_}/node_modules/experimental-ai-sdk-code-mode/dist/serialization.js +0 -0
  141. /package/dist/src/node_modules/.pnpm/{experimental-ai-sdk-code-mode@1.0.9_ai@7.0.0-canary.154_zod@4.4.3_ → experimental-ai-sdk-code-mode@1.0.10_ai@7.0.0-canary.154_zod@4.4.3_}/node_modules/experimental-ai-sdk-code-mode/dist/source-cache.js +0 -0
  142. /package/dist/src/node_modules/.pnpm/{experimental-ai-sdk-code-mode@1.0.9_ai@7.0.0-canary.154_zod@4.4.3_ → experimental-ai-sdk-code-mode@1.0.10_ai@7.0.0-canary.154_zod@4.4.3_}/node_modules/experimental-ai-sdk-code-mode/dist/telemetry.js +0 -0
  143. /package/dist/src/node_modules/.pnpm/{experimental-ai-sdk-code-mode@1.0.9_ai@7.0.0-canary.154_zod@4.4.3_ → experimental-ai-sdk-code-mode@1.0.10_ai@7.0.0-canary.154_zod@4.4.3_}/node_modules/experimental-ai-sdk-code-mode/dist/tool-invocation.js +0 -0
  144. /package/dist/src/node_modules/.pnpm/{experimental-ai-sdk-code-mode@1.0.9_ai@7.0.0-canary.154_zod@4.4.3_ → experimental-ai-sdk-code-mode@1.0.10_ai@7.0.0-canary.154_zod@4.4.3_}/node_modules/experimental-ai-sdk-code-mode/dist/tool-prompt.js +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # experimental-ash
2
2
 
3
+ ## 0.37.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 25ef58e: Reject extra top-level fields passed to core `define*` helpers while preserving literal inference for valid definitions. TypeScript now also enforces documented exclusivity for schedules (`markdown` or `run`) and eval suites (`load` or `cases`, `task.prompt` or `task.messages`).
8
+
9
+ ### Patch Changes
10
+
11
+ - 8b678cc: Channel event handlers now receive `AshCallbackContext` fields — `ctx.session` (with `turn`/`parent`), `ctx.getSandbox()`, and `ctx.getSkill()`. Channel-specific `continuationToken` and `setContinuationToken` are available at the top level of the event context.
12
+
13
+ ## 0.36.0
14
+
15
+ ### Minor Changes
16
+
17
+ - 34722b0: Unify runtime data access: `ctx` is available as the last argument to all ALS-scoped authored callbacks. Omit it when you don't need it.
18
+
19
+ **Breaking changes:**
20
+
21
+ - Tool `execute(input)` → `execute(input, ctx)` — access session, sandbox, and skills via `ctx`
22
+ - Hook lifecycle `(input, ctx)` → `(ctx)` — session identity, auth, and turn info are on `ctx.session`
23
+ - Hook/channel events `(event, ctx)` → same shape, but `ctx` now carries `session`, `getSandbox()`, `getSkill()`
24
+ - `SessionHandle.id` (unchanged), `.auth` is now `{ current, initiator }` (was flat)
25
+ - `getSession()`, `getSandbox()`, `getSkill()` removed — use `ctx.session`, `ctx.getSandbox()`, `ctx.getSkill()`
26
+ - `HookContext.ash` removed — use `defineState` for durable state
27
+ - `CompactionHookInput` → `onCompact({ history, signal }, ctx)`
28
+ - `LifecycleHookInput` removed (absorbed into `HookContext`)
29
+
30
+ Non-ALS callbacks unchanged: schedule `run`, sandbox `bootstrap`/`onSession`, instrumentation `setup`.
31
+
32
+ ### Patch Changes
33
+
34
+ - 4e50396: Fixed parked subagent/remote-agent turns persisting a stale (default) emission state. The runtime-action park now stamps the live turn's emission identity onto the parked session, so the resume turn is classified as a continuation instead of a fresh turn — preventing duplicate `session.started`/`turn.started` events and empty `turnId`s on resume.
35
+
3
36
  ## 0.35.0
4
37
 
5
38
  ### Minor Changes
package/README.md CHANGED
@@ -61,7 +61,7 @@ Runtime accessors live on the subpath that owns the concern:
61
61
  - `getSkill(identifier)` — handle for a named skill visible to the current agent (`experimental-ash/skills`)
62
62
  - `getContext(key)`, `requireContext(key)`, `hasContext(key)`, `setContext(key)`, `ensureContext(key, factory)` — unified context helpers (`experimental-ash/context`)
63
63
 
64
- The complete API reference, including types and lower-level runtime primitives, is in [`./dist/docs/public/typescript-api.md`](./dist/docs/public/typescript-api.md).
64
+ The complete API reference, including types and lower-level runtime primitives, is in [`./dist/docs/public/advanced/typescript-api.md`](./dist/docs/public/advanced/typescript-api.md).
65
65
 
66
66
  ## Tiny Example
67
67
 
@@ -121,7 +121,7 @@ CLI commands:
121
121
 
122
122
  ## Deploying
123
123
 
124
- Ash is built for Vercel. The runtime is Nitro + Vercel Workflows. Read [`./dist/docs/public/vercel-deployment.md`](./dist/docs/public/vercel-deployment.md) for the deployment path, environment variables, and Vercel-specific configuration.
124
+ Ash is built for Vercel. The runtime is Nitro + Vercel Workflows. Read [`./dist/docs/public/advanced/vercel-deployment.md`](./dist/docs/public/advanced/vercel-deployment.md) for the deployment path, environment variables, and Vercel-specific configuration.
125
125
 
126
126
  ## Read Next
127
127
 
@@ -129,14 +129,14 @@ These files ship inside the installed package at `node_modules/experimental-ash/
129
129
 
130
130
  - [Full docs index](./dist/docs/public/README.md) — recommended entry point
131
131
  - [Getting Started](./dist/docs/public/getting-started.md) — install, scaffold, and run locally
132
- - [Project Layout](./dist/docs/public/project-layout.md) — every authored directory in depth
132
+ - [Project Layout](./dist/docs/public/advanced/project-layout.md) — every authored directory in depth
133
133
  - [`agent.ts`](./dist/docs/public/agent-ts.md) — agent config reference
134
- - [TypeScript API](./dist/docs/public/typescript-api.md) — complete `define*` and runtime helper reference
135
- - [Vercel Deployment](./dist/docs/public/vercel-deployment.md) — deploy to production
134
+ - [TypeScript API](./dist/docs/public/advanced/typescript-api.md) — complete `define*` and runtime helper reference
135
+ - [Vercel Deployment](./dist/docs/public/advanced/vercel-deployment.md) — deploy to production
136
136
 
137
- By authoring concern: [Tools](./dist/docs/public/tools.md) · [Channels](./dist/docs/public/channels/README.md) · [Hooks](./dist/docs/public/hooks.md) · [Skills](./dist/docs/public/skills.md) · [Sandbox](./dist/docs/public/sandbox.md) · [Workspace](./dist/docs/public/workspace.md) · [Connections](./dist/docs/public/connections.md) · [Subagents](./dist/docs/public/subagents.md) · [Schedules](./dist/docs/public/schedules.md) · [Human In The Loop](./dist/docs/public/human-in-the-loop.md) · [Evals](./dist/docs/public/evals.md)
137
+ By authoring concern: [Tools](./dist/docs/public/tools.md) · [Channels](./dist/docs/public/channels/README.md) · [Hooks](./dist/docs/public/advanced/hooks.md) · [Skills](./dist/docs/public/skills.md) · [Sandbox](./dist/docs/public/sandbox.md) · [Workspace](./dist/docs/public/advanced/workspace.md) · [Connections](./dist/docs/public/connections.md) · [Subagents](./dist/docs/public/subagents.md) · [Schedules](./dist/docs/public/schedules.md) · [Human In The Loop](./dist/docs/public/human-in-the-loop.md) · [Evals](./dist/docs/public/advanced/evals.md)
138
138
 
139
- By runtime concern: [Sessions and Streaming](./dist/docs/public/runs-and-streaming.md) · [Session Context](./dist/docs/public/session-context.md) · [Context Control](./dist/docs/public/context-control.md) · [Auth and Route Protection](./dist/docs/public/auth-and-route-protection.md) · [CLI, Build, and Debugging](./dist/docs/public/cli-build-and-debugging.md) · [Instrumentation](./dist/docs/public/instrumentation.md)
139
+ By runtime concern: [Sessions and Streaming](./dist/docs/public/advanced/runs-and-streaming.md) · [Session Context](./dist/docs/public/advanced/session-context.md) · [Context Control](./dist/docs/public/advanced/context-control.md) · [Auth and Route Protection](./dist/docs/public/advanced/auth-and-route-protection.md) · [CLI, Build, and Debugging](./dist/docs/public/advanced/cli-build-and-debugging.md) · [Instrumentation](./dist/docs/public/advanced/instrumentation.md)
140
140
 
141
141
  ## Architecture (Internals)
142
142
 
@@ -17,7 +17,7 @@ interface AshContext {
17
17
  }
18
18
  ```
19
19
 
20
- `loadContext()` returns the active context or throws. Public accessors (`getSession()`, `getSandbox()`, `getSkill()`) delegate to it.
20
+ `loadContext()` returns the active context or throws. Internal accessors (`getSession()`, `getSandbox()`, `getSkill()`) delegate to it — these are implementation details, not public exports. Authored code uses `ctx.session`, `ctx.getSandbox()`, and `ctx.getSkill()` instead.
21
21
 
22
22
  ## Type Hierarchy
23
23
 
@@ -78,9 +78,10 @@ Framework providers use a superset `FrameworkContextProvider` that also receives
78
78
  5. Call framework provider `commit` hooks for provider-owned session state
79
79
 
80
80
  Authored hook lifecycle dispatch (`lifecycle.session`, `lifecycle.turn`)
81
- runs inside step (4)'s ALS scope, before the harness step. See
82
- [Hooks](./hooks.md) for the full pipeline and the
83
- `SessionPreparedKey` flag's failure semantics.
81
+ runs inside step (4)'s ALS scope, before the harness step. Lifecycle
82
+ hooks receive `(ctx)`, and event hooks receive `(event, ctx)`. See
83
+ [Hooks](./hooks.md) for the full pipeline and the `SessionPreparedKey`
84
+ flag's failure semantics.
84
85
 
85
86
  `StepInput.modelContext` has two producers. Channels can provide
86
87
  ephemeral messages through `SendPayload.modelContext`, and lifecycle
@@ -91,7 +92,7 @@ call only and are never persisted to durable session history.
91
92
 
92
93
  ## Channel Context
93
94
 
94
- Channels set custom durable context keys inside `onDeliver(ctx, payload)`. The method receives a `ContextAccessor` and returns `Promise<StepInput>`. This runs once per turn (both initial `run()` and each `deliver()`), after auth keys are seeded. Channel code stays workflow-agnostic because it only touches the accessor.
95
+ Channels set custom durable context keys inside `onDeliver(ctx, payload)`. The method receives a context accessor and returns `Promise<StepInput>`. This runs once per turn (both initial `run()` and each `deliver()`), after auth keys are seeded. Channel code stays workflow-agnostic because it only touches the accessor.
95
96
 
96
97
  Auth lives on the run and deliver inputs:
97
98
 
@@ -15,8 +15,8 @@ source of truth; a repeated `name` field is a second source that can drift.
15
15
 
16
16
  The hooks surface (`agent/hooks/`) deliberately reuses the unified
17
17
  `AshContext` rather than introducing a parallel state-patch channel:
18
- hooks read and write through `ctx.ash` like every other authored
19
- function. One context, one set of keys, one place to look when debugging.
18
+ hooks read and write through `ctx` like every other authored function.
19
+ One context, one set of keys, one place to look when debugging.
20
20
 
21
21
  ## Durable Work Belongs In The Runtime
22
22
 
@@ -18,15 +18,20 @@ through one runtime registry, one `HookContext`, one set of ordering
18
18
  rules.
19
19
 
20
20
  The hooks surface deliberately reuses the unified `AshContext`:
21
- `HookContext.ash` is the same `ContextAccessor` tools, providers, and
22
- channels get. There is no parallel state-patch channel — one
23
- `AshContext`, one set of keys, one place to look when debugging.
21
+ `HookContext` extends `AshCallbackContext`, giving hooks the same
22
+ context surface tools, providers, and channels get. There is no
23
+ parallel state-patch channel — one `AshContext`, one set of keys, one
24
+ place to look when debugging.
24
25
 
25
- `HookContext` itself is intentionally tiny: `agent`, `channel`, `session`
26
- identity plus the `ash` accessor. Per-turn `turnId` and `sequence` come
27
- from `LifecycleHookInput.turn` for lifecycle hooks, and from
28
- `event.data.{turnId, sequence}` for stream-event hooks — never duplicated
29
- on the context.
26
+ `HookContext` carries `agent`, `channel`, and `session` (which includes
27
+ `id`, `auth`, `turn`, and `parent`). `session.auth` is a nested
28
+ `SessionAuth` with `{ current, initiator }`.
29
+
30
+ Lifecycle hooks receive `(ctx)` — a single `HookContext` argument.
31
+ Event hooks receive `(event, ctx)` — event first, context last (omit `ctx` when unused).
32
+ Per-turn `turnId` and `sequence` come from `ctx.session.turn` for
33
+ lifecycle hooks, and from `event.data.{turnId, sequence}` for
34
+ stream-event hooks — never duplicated on the context.
30
35
 
31
36
  ## Authoring shape
32
37
 
@@ -87,7 +92,7 @@ the workflow path.
87
92
  Lifecycle dispatch lives in `src/context/hook-lifecycle.ts`. The
88
93
  workflow runtime entry point (`execution/workflow-steps.ts`) calls
89
94
  `runHookLifecycleStep` once per turn, **inside** the active ALS scope
90
- so hook code can read and write `ctx.ash` like every other authored
95
+ so hook code can read and write context like every other authored
91
96
  function. `runHookLifecycleStep` wraps `dispatchHookLifecycle`, lowers
92
97
  a `turn-failed` outcome into a parking `StepResult` (`{ next: null }`
93
98
  for conversation mode, `{ next: { done: true, output } }` for task
@@ -142,7 +147,7 @@ Subagent hooks are fully isolated by structural construction:
142
147
  established by the existing subagent invocation pipeline. Hooks
143
148
  resolve from the subagent node's `hookRegistry`, not the parent
144
149
  agent's.
145
- - `ctx.ash` reads hit the subagent's container, not the parent's.
150
+ - `ctx` reads hit the subagent's container, not the parent's.
146
151
  - Lexicographic ordering applies within a subagent's hook set only.
147
152
  Parent and child registries do not interleave.
148
153
 
@@ -188,7 +193,7 @@ documented expectations:
188
193
  - Hook modules never import workflow primitives (`start`, `resumeHook`,
189
194
  `createHook`, `getWritable`).
190
195
  - Hook return shapes have no `state` field — durable state goes through
191
- `ctx.ash`.
196
+ `ctx`.
192
197
  - Subagent hooks never read parent ALS context.
193
198
 
194
199
  ## Related Pages
@@ -68,10 +68,10 @@ flags new `@workflow/*` imports from channel, harness, and hook code.
68
68
  ### Hooks Use The Single State Channel
69
69
 
70
70
  Authored hook modules (`agent/hooks/**`) must read and write durable state
71
- through `ctx.ash` (the unified `ContextAccessor`). The hooks surface
72
- introduces no parallel state-patch channel — lifecycle return shapes
73
- expose only `modelContext` (a one-shot per-call ephemeral message list),
74
- and subagent hooks never read parent ALS context.
71
+ through `ctx` (the unified context). The hooks surface introduces no
72
+ parallel state-patch channel — lifecycle return shapes expose only
73
+ `modelContext` (a one-shot per-call ephemeral message list), and subagent
74
+ hooks never read parent ALS context.
75
75
 
76
76
  Enforcement: rule 27 in `scripts/guard-agents-rules.mjs` fails if a
77
77
  `state:` (or `readonly state:`, `state?:`) field is declared on any
@@ -62,7 +62,7 @@ Ad-hoc tmp directories with `package.json` + `agent/` scaffolding.
62
62
 
63
63
  - Unit tier: `unit-guard.ts` throws on disk writes, subprocesses, `process.chdir`, real fetch. If you hit a guard throw, move the test to a higher tier.
64
64
  - Never mutate the process-default `RuntimeSession` — let `createTestRuntime().run(fn)` scope it. Do not call `installBundledCompiledArtifacts` / `resetBundledCompiledArtifacts` / `clearProcessDefaultRuntimeSession` directly.
65
- - Use `runAsSession({}, ...)` when the test needs `getSession()` / `getSandbox()` / `getSkill()` to resolve. Use `run(...)` when only compiled artifacts + bundle cache need scoping.
65
+ - Use `runAsSession({}, ...)` when the test needs `ctx.session` / `ctx.getSandbox()` / `ctx.getSkill()` to resolve (the internal `getSession()`, `getSandbox()`, `getSkill()` free functions still work but are not public API). Use `run(...)` when only compiled artifacts + bundle cache need scoping.
66
66
  - Cleanup is automatic for `mockSkill`, `useScenarioApp`, and `useTemporaryAppRoots`.
67
67
  - Do not commit new fixtures under `test/fixtures/` — CI guard will fail. Use descriptors in `src/internal/testing/scenario-apps/`.
68
68
  - Prefer `vi.stubEnv` over direct `process.env` mutation.
@@ -16,25 +16,25 @@ Important naming note:
16
16
  Read in this order:
17
17
 
18
18
  1. [Getting Started](./getting-started.md)
19
- 2. [Project Layout](./project-layout.md)
19
+ 2. [Project Layout](./advanced/project-layout.md)
20
20
  3. [`agent.ts`](./agent-ts.md)
21
- 4. [TypeScript API](./typescript-api.md)
22
- 5. [Context Control](./context-control.md)
21
+ 4. [TypeScript API](./advanced/typescript-api.md)
22
+ 5. [Context Control](./advanced/context-control.md)
23
23
  6. [Skills](./skills.md)
24
24
  7. [Tools](./tools.md)
25
25
  8. [Connections](./connections.md)
26
- 9. [Workspace](./workspace.md)
26
+ 9. [Workspace](./advanced/workspace.md)
27
27
  10. [Sandboxes](./sandbox.md)
28
28
  11. [Channels](./channels/README.md)
29
29
  12. [Human In The Loop](./human-in-the-loop.md)
30
- 13. [Session Context](./session-context.md)
31
- 14. [Sessions And Streaming](./runs-and-streaming.md)
30
+ 13. [Session Context](./advanced/session-context.md)
31
+ 14. [Sessions And Streaming](./advanced/runs-and-streaming.md)
32
32
  15. [Subagents](./subagents.md)
33
33
  16. [Schedules](./schedules.md)
34
- 17. [Evals](./evals.md)
35
- 18. [Auth And Route Protection](./auth-and-route-protection.md)
36
- 19. [Vercel Deployment](./vercel-deployment.md)
37
- 20. [CLI, Build, And Debugging](./cli-build-and-debugging.md)
34
+ 17. [Evals](./advanced/evals.md)
35
+ 18. [Auth And Route Protection](./advanced/auth-and-route-protection.md)
36
+ 19. [Vercel Deployment](./advanced/vercel-deployment.md)
37
+ 20. [CLI, Build, And Debugging](./advanced/cli-build-and-debugging.md)
38
38
 
39
39
  ## The Public Mental Model
40
40
 
@@ -60,7 +60,7 @@ Ash then gives you:
60
60
  - a reconnectable session stream
61
61
  - durable session state across turns
62
62
  - a per-agent sandbox with a shared runtime workspace
63
- - typed runtime helpers such as `getSession()`, `getSandbox()`, and `getSkill()`
63
+ - typed runtime helpers accessed through `ctx` (`ctx.session`, `ctx.getSandbox()`, `ctx.getSkill()`)
64
64
 
65
65
  ## The Runtime Shape
66
66
 
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  title: "Auth And Route Protection"
3
3
  description: "Protect agent routes with HTTP Basic, JWT, OIDC, and Vercel OIDC."
4
+ url: /auth-and-route-protection
4
5
  ---
5
6
 
6
7
  Ash protects its own HTTP routes through the channel layer.
@@ -163,7 +164,7 @@ configured, and their `environment` matches `VERCEL_TARGET_ENV` or `VERCEL_ENV`
163
164
  those user tokens, `external_sub` becomes the session subject, `external_iss` becomes the session
164
165
  issuer when present, and `connector_id` is used as the issuer fallback before the Vercel OIDC issuer.
165
166
  String OIDC profile claims such as `name`, `picture`, and `email` are exposed in
166
- `getSession().auth.current.attributes`.
167
+ `ctx.session.auth.current.attributes`.
167
168
 
168
169
  ### `none`
169
170
 
@@ -195,7 +196,7 @@ re-materializes them from the authored channel definition when it needs the live
195
196
 
196
197
  ## What Auth Reaches Authored Code
197
198
 
198
- Inside runtime code, `getSession().auth` gives you the caller snapshot.
199
+ Inside runtime code, `ctx.session.auth` gives you the caller snapshot.
199
200
 
200
201
  Important behavior:
201
202
 
@@ -207,8 +208,8 @@ Important behavior:
207
208
  accepts with a `SessionAuthContext` or returns `401`
208
209
 
209
210
  Auth on follow-up messages (`deliver()`) is honored by the workflow runtime. When a different
210
- user sends a follow-up to the same session, `session.auth.current` reflects the new caller on
211
- that turn while `session.auth.initiator` stays the same.
211
+ user sends a follow-up to the same session, `ctx.session.auth.current` reflects the new caller on
212
+ that turn while `ctx.session.auth.initiator` stays the same.
212
213
 
213
214
  ## What Ash Does Not Do
214
215
 
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  title: "CLI, Build, And Debugging"
3
3
  description: "CLI commands: dev, build, info, eval. Debugging techniques."
4
+ url: /cli-build-and-debugging
4
5
  ---
5
6
 
6
7
  Ash's CLI gives you the normal day-to-day workflow for authoring, inspecting, and shipping an app.
@@ -77,7 +78,7 @@ When something is wrong:
77
78
 
78
79
  - `schedules/` are root-only today
79
80
  - `agent.ts` no longer owns inbound auth or network policy; those live on the HTTP channel layer
80
- - runtime helpers such as `getSession()` do not work at module top level
81
+ - runtime helpers on `ctx` (like `ctx.session`) do not work at module top level
81
82
  - skill guidance belongs in `skills/`, not in tool descriptions
82
83
 
83
84
  ## What To Read Next
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  title: "Context Control"
3
3
  description: "Author always-on instructions with instructions.md or instructions.ts."
4
+ url: /context-control
4
5
  ---
5
6
 
6
7
  Ash gives you a few different levers for controlling what the model sees and when it sees it.
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  title: "Evals"
3
3
  description: "Define eval suites with test cases, scoring rubrics, and automated runs."
4
+ url: /evals
4
5
  ---
5
6
 
6
7
  Evals let you define repeatable checks for an Ash agent and run them with the `ash eval` CLI
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  title: "FAQs"
3
3
  description: "Frequently asked questions about Ash."
4
+ url: /faqs
4
5
  ---
5
6
 
6
7
  # FAQs
@@ -56,12 +57,11 @@ the framework's mechanical invariants.
56
57
 
57
58
  If you want session data from your own code, there are two supported surfaces:
58
59
 
59
- - **Tools** can read the current session's metadata (sessionId, turn, auth,
60
- parent lineage) via `getSession()` from `experimental-ash/context`. This is
60
+ - **Tools** can read the current session's metadata (id, turn, auth,
61
+ parent lineage) via `ctx.session` from the optional `ctx` parameter on `execute`. This is
61
62
  read-only.
62
- - **Durable context keys + `ContextProvider`** are the supported pattern for
63
- reading or writing session-scoped durable state from authored code — see
64
- [Session Context](./session-context.md).
63
+ - **`defineState`** is the supported pattern for reading or writing session-scoped durable state
64
+ from authored code — see [Session Context](./session-context.md).
65
65
 
66
66
  For the wire-level session lifecycle (creating sessions, streaming events,
67
67
  reconnecting by event index) see [Sessions And Streaming](./runs-and-streaming.md).
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  title: "Hooks"
3
3
  description: "Subscribe to lifecycle moments and runtime stream events from agent/hooks/."
4
+ url: /hooks
4
5
  ---
5
6
 
6
7
  Hooks are Ash's authored extension points for the per-turn lifecycle and
@@ -20,7 +21,7 @@ import { defineHook } from "experimental-ash/hooks";
20
21
  export default defineHook({
21
22
  events: {
22
23
  async "session.started"(_event, ctx) {
23
- console.info("session started", { sessionId: ctx.session.sessionId });
24
+ console.info("session started", { sessionId: ctx.session.id });
24
25
  },
25
26
  async "message.completed"(event) {
26
27
  console.info("model finished", { length: event.data.message?.length ?? 0 });
@@ -33,8 +34,7 @@ The slug is the path-relative basename: `agent/hooks/audit.ts` → `"audit"`,
33
34
  `agent/hooks/auth/load-profile.ts` → `"auth/load-profile"`.
34
35
 
35
36
  `defineHook`, `HookDefinition`, and `HookContext` live on
36
- `experimental-ash/hooks`. Runtime context helpers (`getSession`,
37
- `getContext`, …) live on `experimental-ash/context`.
37
+ `experimental-ash/hooks`. The `defineState` helper lives on `experimental-ash/context`.
38
38
 
39
39
  ## Shape
40
40
 
@@ -55,16 +55,10 @@ Every handler receives the same `HookContext`:
55
55
  interface HookContext {
56
56
  readonly agent: { readonly name: string; readonly nodeId?: string };
57
57
  readonly channel: { readonly kind?: string; readonly continuationToken?: string };
58
- readonly session: { readonly sessionId: string };
59
- readonly ash: ContextAccessor;
58
+ readonly session: { readonly id: string };
60
59
  }
61
60
  ```
62
61
 
63
- `ctx.ash` is the same `ContextAccessor` tools, providers, and channels use.
64
- Hooks read and write durable state through `ctx.ash.set(...)` /
65
- `ctx.ash.get(...)`. The hooks surface deliberately introduces no parallel
66
- state-patch channel — one `AshContext`, one set of keys.
67
-
68
62
  ### Narrowing tool results
69
63
 
70
64
  `toolResultFrom` narrows an `action.result` event to a specific authored
@@ -108,11 +102,13 @@ Lifecycle hooks share one signature:
108
102
 
109
103
  ```ts
110
104
  type LifecycleHook = (
111
- input: { session: { sessionId: string }; turn: { sequence: number; turnId: string } },
112
105
  ctx: HookContext,
113
106
  ) => void | { modelContext?: readonly ModelMessage[]; skills?: readonly NamedSkillDefinition[] } | Promise<…>;
114
107
  ```
115
108
 
109
+ Session and turn metadata are available on `ctx.session`. For example,
110
+ `ctx.session.turn.sequence` gives the current turn sequence number.
111
+
116
112
  `lifecycle.session` runs **once per durable session**, before the first
117
113
  model turn. `lifecycle.turn` runs **once per fresh delivery** — tool-loop
118
114
  continuations and HITL resumes do not re-fire it.
@@ -130,24 +126,24 @@ lifecycle hook messages.
130
126
 
131
127
  ```ts
132
128
  // agent/hooks/load-profile.ts
133
- import { ContextKey } from "experimental-ash/context";
129
+ import { defineState } from "experimental-ash/context";
134
130
  import { defineHook } from "experimental-ash/hooks";
135
131
  import { fetchGithubProfile, type GithubProfile } from "../lib/github";
136
132
 
137
- const GithubProfileKey = new ContextKey<GithubProfile>("myapp.githubProfile");
133
+ const githubProfile = defineState<GithubProfile | null>("myapp.githubProfile", () => null);
138
134
 
139
135
  export default defineHook({
140
136
  lifecycle: {
141
- async session(_input, ctx) {
142
- const profile = await fetchGithubProfile(ctx.session.sessionId);
143
- ctx.ash.set(GithubProfileKey, profile);
137
+ async session(ctx) {
138
+ const profile = await fetchGithubProfile(ctx.session.id);
139
+ githubProfile.update(() => profile);
144
140
  },
145
141
  },
146
142
  });
147
143
  ```
148
144
 
149
145
  The profile is now visible to every tool, provider, and subsequent hook
150
- through `ctx.ash.get(GithubProfileKey)`.
146
+ through `githubProfile.get()`.
151
147
 
152
148
  ### Inject ephemeral system text
153
149
 
@@ -158,7 +154,7 @@ import { fetchActiveIncident } from "../lib/linear";
158
154
 
159
155
  export default defineHook({
160
156
  lifecycle: {
161
- async turn() {
157
+ async turn(ctx) {
162
158
  const incident = await fetchActiveIncident();
163
159
  if (incident === null) return;
164
160
 
@@ -186,7 +182,7 @@ import { defineHook } from "experimental-ash/hooks";
186
182
 
187
183
  export default defineHook({
188
184
  lifecycle: {
189
- async session() {
185
+ async session(ctx) {
190
186
  return {
191
187
  skills: [
192
188
  {
@@ -216,12 +212,12 @@ import { defineHook } from "experimental-ash/hooks";
216
212
 
217
213
  export default defineHook({
218
214
  lifecycle: {
219
- async session(_input, ctx) {
215
+ async session(ctx) {
220
216
  return {
221
217
  modelContext: [
222
218
  {
223
219
  role: "system",
224
- content: `Greet the user by name (${await lookupName(ctx.session.sessionId)}).`,
220
+ content: `Greet the user by name (${await lookupName(ctx.session.id)}).`,
225
221
  },
226
222
  ],
227
223
  };
@@ -247,7 +243,7 @@ import { postToHoneycomb } from "../lib/honeycomb";
247
243
  export default defineHook({
248
244
  events: {
249
245
  async "session.started"(_event, ctx) {
250
- await postToHoneycomb({ event: "session.started", sessionId: ctx.session.sessionId });
246
+ await postToHoneycomb({ event: "session.started", sessionId: ctx.session.id });
251
247
  },
252
248
  async "message.completed"(event) {
253
249
  await postToHoneycomb({ event: "message.completed", payload: event.data });
@@ -282,7 +278,7 @@ in `try`/`catch` — Ash treats a thrown hook as a real failure.
282
278
  Subagents may carry their own `agent/hooks/` directory. Subagent hooks
283
279
  fire only inside the subagent scope; parent-agent hooks do not fire for
284
280
  subagent turns, and subagent hooks see only the subagent's own
285
- `ctx.ash`.
281
+ context.
286
282
 
287
283
  ## When to use a hook vs a tool vs a provider
288
284
 
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  title: "instrumentation.ts"
3
3
  description: "Configure OpenTelemetry exporters and AI SDK span behavior for your agent."
4
+ url: /instrumentation
4
5
  ---
5
6
 
6
7
  `instrumentation.ts` is the single place to configure OpenTelemetry for an Ash agent. It controls
@@ -0,0 +1,19 @@
1
+ {
2
+ "title": "Advanced",
3
+ "pages": [
4
+ "project-layout",
5
+ "context-control",
6
+ "hooks",
7
+ "auth-and-route-protection",
8
+ "vercel-deployment",
9
+ "runs-and-streaming",
10
+ "session-context",
11
+ "workspace",
12
+ "evals",
13
+ "instrumentation",
14
+ "cli-build-and-debugging",
15
+ "typescript-api",
16
+ "...",
17
+ "faqs"
18
+ ]
19
+ }
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  title: "Project Layout"
3
3
  description: "Directory structure and filesystem conventions."
4
+ url: /project-layout
4
5
  ---
5
6
 
6
7
  Ash supports two layouts:
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  title: "Sessions And Streaming"
3
3
  description: "The HTTP API, NDJSON event stream, and session lifecycle."
4
+ url: /runs-and-streaming
4
5
  ---
5
6
 
6
7
  Ash is durable and session-based by default.