experimental-ash 0.7.1 → 0.7.3

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 (61) hide show
  1. package/dist/docs/external-agent-protocol.md +5 -5
  2. package/dist/docs/internals/README.md +8 -8
  3. package/dist/docs/internals/context.md +1 -1
  4. package/dist/docs/internals/hooks.md +5 -5
  5. package/dist/docs/internals/message-runtime.md +6 -6
  6. package/dist/docs/public/README.md +22 -22
  7. package/dist/docs/public/agent-ts.md +21 -17
  8. package/dist/docs/public/auth-and-route-protection.md +13 -13
  9. package/dist/docs/public/channels/README.md +16 -13
  10. package/dist/docs/public/cli-build-and-debugging.md +3 -3
  11. package/dist/docs/public/connections.md +5 -5
  12. package/dist/docs/public/context-control.md +8 -8
  13. package/dist/docs/public/evals.md +3 -3
  14. package/dist/docs/public/getting-started.md +5 -5
  15. package/dist/docs/public/hooks.md +4 -4
  16. package/dist/docs/public/human-in-the-loop.md +3 -3
  17. package/dist/docs/public/instrumentation.md +4 -3
  18. package/dist/docs/public/project-layout.md +11 -11
  19. package/dist/docs/public/runs-and-streaming.md +3 -3
  20. package/dist/docs/public/sandbox.md +3 -3
  21. package/dist/docs/public/session-context.md +10 -6
  22. package/dist/docs/public/skills.md +5 -3
  23. package/dist/docs/public/subagents.md +2 -2
  24. package/dist/docs/public/tools.md +4 -5
  25. package/dist/docs/public/typescript-api.md +12 -12
  26. package/dist/docs/public/vercel-deployment.md +4 -4
  27. package/dist/docs/public/workspace.md +3 -3
  28. package/dist/src/channel/compiled-channel.d.ts +4 -2
  29. package/dist/src/channel/schedule.d.ts +11 -23
  30. package/dist/src/channel/schedule.js +18 -19
  31. package/dist/src/chunks/{dev-authored-source-watcher-CYsfBiYM.js → dev-authored-source-watcher-Druw92QN.js} +1 -1
  32. package/dist/src/chunks/{host-CsF9KDv8.js → host-CQ7AZID3.js} +2 -2
  33. package/dist/src/chunks/{paths-DvimrhJF.js → paths-DQbfjCIS.js} +25 -25
  34. package/dist/src/chunks/{prewarm-DdHk68ib.js → prewarm-CcphIXc0.js} +1 -1
  35. package/dist/src/cli/commands/info.js +1 -1
  36. package/dist/src/cli/run.js +1 -1
  37. package/dist/src/compiler/normalize-channel.d.ts +4 -4
  38. package/dist/src/compiler/normalize-channel.js +9 -22
  39. package/dist/src/evals/cli/eval.js +1 -1
  40. package/dist/src/internal/application/package.js +1 -1
  41. package/dist/src/internal/authored-definition/channel.d.ts +7 -9
  42. package/dist/src/internal/authored-definition/channel.js +9 -33
  43. package/dist/src/internal/nitro/routes/channel-dispatch.d.ts +5 -3
  44. package/dist/src/internal/nitro/routes/channel-dispatch.js +8 -5
  45. package/dist/src/internal/nitro/routes/runtime-stack.js +1 -1
  46. package/dist/src/internal/nitro/routes/schedule-task.d.ts +3 -4
  47. package/dist/src/internal/nitro/routes/schedule-task.js +5 -7
  48. package/dist/src/public/channels/{http.d.ts → ash.d.ts} +2 -2
  49. package/dist/src/public/channels/{http.js → ash.js} +2 -2
  50. package/dist/src/public/channels/slack/slackChannel.js +1 -1
  51. package/dist/src/public/definitions/channel.d.ts +1 -63
  52. package/dist/src/public/definitions/channel.js +0 -16
  53. package/dist/src/public/definitions/defineChannel.d.ts +7 -4
  54. package/dist/src/runtime/framework-channels/index.d.ts +1 -1
  55. package/dist/src/runtime/framework-channels/index.js +7 -7
  56. package/dist/src/runtime/resolve-channel.d.ts +9 -4
  57. package/dist/src/runtime/resolve-channel.js +21 -28
  58. package/dist/src/runtime/types.d.ts +13 -8
  59. package/package.json +5 -5
  60. package/dist/src/compiler/channel-url.d.ts +0 -5
  61. package/dist/src/compiler/channel-url.js +0 -14
@@ -1,13 +1,18 @@
1
- import { isCompiledChannel, normalizeChannelDefinition, } from "#internal/authored-definition/channel.js";
1
+ import { normalizeChannelDefinition } from "#internal/authored-definition/channel.js";
2
2
  import { toErrorMessage } from "#shared/errors.js";
3
3
  import { createResolvedModuleSourceRef, loadResolvedModuleExport, ResolveAgentError, } from "#runtime/resolve-helpers.js";
4
4
  /**
5
5
  * Resolves one compiled channel entry into a runtime-owned definition
6
- * with a live `fetch` or `handler` attached from the authored module.
6
+ * with a live `handler` (the per-route handler authored via `POST` /
7
+ * `GET` / etc. inside `defineChannel`) and the channel's `receive` hook
8
+ * if the author declared one.
7
9
  *
8
- * For CompiledChannel values (produced by `defineChannel()`), the
9
- * resolver finds the matching route by method + path and attaches its
10
- * `handler`. For old-style Route values, it attaches `fetch` directly.
10
+ * Every authored channel is a `CompiledChannel` from `defineChannel`
11
+ * the bare `{ fetch, receive? }` Route shape is rejected by
12
+ * {@link normalizeChannelDefinition}. Framework-internal channels
13
+ * (the connection callback route, the `ash` session channel) build
14
+ * `ResolvedChannelDefinition` values directly and do not flow through
15
+ * this resolver.
11
16
  */
12
17
  export async function resolveChannelDefinition(definition, moduleMap, nodeId) {
13
18
  try {
@@ -23,35 +28,23 @@ export async function resolveChannelDefinition(definition, moduleMap, nodeId) {
23
28
  logicalPath: definition.logicalPath,
24
29
  sourceId: definition.sourceId,
25
30
  });
26
- if (isCompiledChannel(channelDefinition)) {
27
- const matchedRoute = channelDefinition.routes.find((r) => r.method.toUpperCase() === definition.method.toUpperCase() &&
28
- r.path === definition.urlPath);
29
- const adapter = channelDefinition.adapter;
30
- if (adapter && adapter.kind !== "http") {
31
- adapter.kind = `channel:${definition.name}`;
32
- }
33
- return {
34
- name: definition.name,
35
- method: definition.method,
36
- urlPath: definition.urlPath,
37
- fetch: async (req, ctx) => {
38
- if (matchedRoute)
39
- return matchedRoute.handler(req, ctx);
40
- return Response.json({ error: "No matching route handler.", ok: false }, { status: 404 });
41
- },
42
- handler: matchedRoute?.handler,
43
- receive: channelDefinition.receive,
44
- adapter,
45
- ...sourceRef,
46
- };
31
+ const matchedRoute = channelDefinition.routes.find((r) => r.method.toUpperCase() === definition.method.toUpperCase() && r.path === definition.urlPath);
32
+ const adapter = channelDefinition.adapter;
33
+ if (adapter && adapter.kind !== "http") {
34
+ adapter.kind = `channel:${definition.name}`;
47
35
  }
48
36
  return {
49
37
  name: definition.name,
50
38
  method: definition.method,
51
39
  urlPath: definition.urlPath,
52
- fetch: channelDefinition.fetch,
40
+ fetch: async (req, ctx) => {
41
+ if (matchedRoute)
42
+ return matchedRoute.handler(req, ctx);
43
+ return Response.json({ error: "No matching route handler.", ok: false }, { status: 404 });
44
+ },
45
+ handler: matchedRoute?.handler,
53
46
  receive: channelDefinition.receive,
54
- adapter: channelDefinition.adapter,
47
+ adapter,
55
48
  ...sourceRef,
56
49
  };
57
50
  }
@@ -1,7 +1,8 @@
1
1
  import type { FlexibleSchema } from "ai";
2
2
  import type { ChannelAdapter } from "#channel/adapter.js";
3
+ import type { CompiledChannel } from "#channel/compiled-channel.js";
3
4
  import type { DiscoverDiagnosticsSummary } from "#discover/diagnostics.js";
4
- import type { ChannelMethod, Route, RouteContext } from "#public/definitions/channel.js";
5
+ import type { ChannelMethod, RouteContext } from "#public/definitions/channel.js";
5
6
  import type { RouteHandler } from "#channel/routes.js";
6
7
  import type { LifecycleHooks, StreamEventHook } from "#public/definitions/hook.js";
7
8
  import type { CompactionHookInput, CompactionHookResult, NeedsApprovalContext, ToolRetentionPolicy } from "#public/definitions/tool.js";
@@ -172,16 +173,20 @@ export interface ResolvedChannelDefinition extends ResolvedModuleSourceRef {
172
173
  readonly method: ChannelMethod;
173
174
  readonly adapter?: ChannelAdapter;
174
175
  readonly urlPath: string;
175
- readonly fetch: Route["fetch"] | ((req: Request, ctx: RouteContext) => Promise<Response>);
176
+ readonly fetch: (req: Request, ctx: RouteContext) => Promise<Response>;
176
177
  /**
177
- * Old-style receive from Route or new-style receive from CompiledChannel.
178
- * The schedule dispatcher adapts to whichever shape is present.
178
+ * Universal entry point for new sessions, called by cross-channel
179
+ * initiators (the schedule dispatcher today). Typed precisely as
180
+ * {@link CompiledChannel.receive} — `(input, { send }) => Session` —
181
+ * so any caller passing the wrong context shape is a typecheck error,
182
+ * not a runtime crash.
179
183
  *
180
- * Both signatures accept a first arg with `{ message, args }`. The
181
- * second arg differs: old uses `{ agent, waitUntil }`, new uses
182
- * `{ send }`. The dispatcher passes the appropriate shape.
184
+ * Old Route-style channels do not flow `receive` through here. The
185
+ * resolver sets it to `undefined` for those; callers that need
186
+ * `receive` then throw with a clear error rather than silently
187
+ * accepting a different shape.
183
188
  */
184
- readonly receive?: (...args: any[]) => Promise<any>;
189
+ readonly receive?: CompiledChannel["receive"];
185
190
  /**
186
191
  * New-style route handler from CompiledChannel. When present, the
187
192
  * dispatch layer uses this instead of `fetch`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "experimental-ash",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "bin": {
5
5
  "ash": "./bin/ash.js",
6
6
  "experimental-ash": "./bin/ash.js"
@@ -120,10 +120,10 @@
120
120
  "import": "./dist/src/public/channels/index.js",
121
121
  "default": "./dist/src/public/channels/index.js"
122
122
  },
123
- "./channels/http": {
124
- "types": "./dist/src/public/channels/http.d.ts",
125
- "import": "./dist/src/public/channels/http.js",
126
- "default": "./dist/src/public/channels/http.js"
123
+ "./channels/ash": {
124
+ "types": "./dist/src/public/channels/ash.d.ts",
125
+ "import": "./dist/src/public/channels/ash.js",
126
+ "default": "./dist/src/public/channels/ash.js"
127
127
  },
128
128
  "./channels/auth": {
129
129
  "types": "./dist/src/public/channels/auth.d.ts",
@@ -1,5 +0,0 @@
1
- /**
2
- * Translates a filesystem-derived channel name into the URL path the Nitro
3
- * router mounts.
4
- */
5
- export declare function deriveChannelUrlPath(name: string): string;
@@ -1,14 +0,0 @@
1
- /**
2
- * Translates a filesystem-derived channel name into the URL path the Nitro
3
- * router mounts.
4
- */
5
- export function deriveChannelUrlPath(name) {
6
- const segments = name.split("/").map(translateChannelPathSegment);
7
- return `/${segments.join("/")}`;
8
- }
9
- function translateChannelPathSegment(segment) {
10
- if (segment.startsWith("[") && segment.endsWith("]")) {
11
- return `:${segment.slice(1, -1)}`;
12
- }
13
- return segment;
14
- }