experimental-ash 0.24.2 → 0.25.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.
- package/CHANGELOG.md +12 -0
- package/dist/docs/public/typescript-api.md +0 -12
- package/dist/src/channel/adapter.d.ts +5 -18
- package/dist/src/channel/adapter.js +2 -8
- package/dist/src/channel/cross-channel-receive.d.ts +10 -1
- package/dist/src/channel/cross-channel-receive.js +21 -3
- package/dist/src/channel/routes.d.ts +2 -1
- package/dist/src/channel/routes.js +6 -3
- package/dist/src/channel/schedule.js +2 -2
- package/dist/src/channel/types.d.ts +1 -1
- package/dist/src/chunks/{client-DLHAGI2g.js → client-BShLWzR6.js} +3 -3
- package/dist/src/chunks/compile-agent-75wLLW-E.js +5 -0
- package/dist/src/chunks/dev-authored-source-watcher-DqoJsDup.js +1 -0
- package/dist/src/chunks/host-JVy7fewA.js +70 -0
- package/dist/src/chunks/paths-DNjq5JOy.js +85 -0
- package/dist/src/chunks/{token-D98SQdvs.js → token-BOkIxJeV.js} +1 -1
- package/dist/src/chunks/types-CjIyrcYo.js +1 -0
- package/dist/src/cli/commands/info.js +1 -1
- package/dist/src/cli/dev/environment.d.ts +0 -5
- package/dist/src/cli/dev/environment.js +1 -1
- package/dist/src/cli/dev/repl.d.ts +1 -1
- package/dist/src/cli/dev/repl.js +3 -3
- package/dist/src/cli/run.d.ts +0 -1
- package/dist/src/cli/run.js +2 -2
- package/dist/src/client/message-reducer.js +13 -25
- package/dist/src/client/message-response.d.ts +2 -1
- package/dist/src/client/open-stream.d.ts +3 -3
- package/dist/src/client/open-stream.js +1 -2
- package/dist/src/client/session.d.ts +2 -1
- package/dist/src/client/session.js +0 -3
- package/dist/src/client/types.d.ts +3 -2
- package/dist/src/compiler/artifacts.d.ts +7 -10
- package/dist/src/compiler/artifacts.js +3 -3
- package/dist/src/compiler/manifest.d.ts +6 -15
- package/dist/src/compiler/manifest.js +3 -3
- package/dist/src/compiler/normalize-agent-config.js +12 -10
- package/dist/src/compiler/normalize-manifest.js +3 -2
- package/dist/src/context/container.d.ts +1 -16
- package/dist/src/context/container.js +1 -24
- package/dist/src/context/hook-lifecycle.d.ts +2 -7
- package/dist/src/context/hook-lifecycle.js +0 -6
- package/dist/src/context/provider.d.ts +1 -11
- package/dist/src/context/providers/sandbox.js +4 -1
- package/dist/src/context/run-step.d.ts +2 -4
- package/dist/src/context/run-step.js +4 -17
- package/dist/src/context/seed-keys.d.ts +1 -1
- package/dist/src/discover/connections.d.ts +2 -1
- package/dist/src/discover/diagnostics.d.ts +0 -8
- package/dist/src/discover/diagnostics.js +4 -16
- package/dist/src/discover/discover-agent.d.ts +3 -13
- package/dist/src/discover/discover-agent.js +1 -11
- package/dist/src/discover/discover-subagent.d.ts +3 -2
- package/dist/src/discover/discover-subagent.js +1 -1
- package/dist/src/discover/filesystem.d.ts +0 -37
- package/dist/src/discover/filesystem.js +0 -115
- package/dist/src/discover/grammar.d.ts +10 -20
- package/dist/src/discover/grammar.js +11 -33
- package/dist/src/discover/lib.d.ts +3 -2
- package/dist/src/discover/manifest.d.ts +3 -3
- package/dist/src/discover/markdown.d.ts +2 -1
- package/dist/src/discover/sandbox.d.ts +2 -1
- package/dist/src/discover/schedules.d.ts +3 -2
- package/dist/src/discover/schedules.js +1 -1
- package/dist/src/discover/skills.d.ts +3 -2
- package/dist/src/discover/skills.js +1 -1
- package/dist/src/discover/slots.d.ts +3 -2
- package/dist/src/evals/cli/eval.d.ts +0 -6
- package/dist/src/evals/cli/eval.js +1 -1
- package/dist/src/evals/loaders/index.d.ts +2 -22
- package/dist/src/evals/loaders/index.js +1 -1
- package/dist/src/evals/reporters/index.d.ts +2 -14
- package/dist/src/evals/reporters/index.js +1 -1
- package/dist/src/evals/runner/discover.d.ts +0 -6
- package/dist/src/evals/runner/discover.js +1 -1
- package/dist/src/evals/runner/execute-case.d.ts +2 -1
- package/dist/src/evals/runner/execute-suite.d.ts +2 -1
- package/dist/src/evals/runner/reporters/braintrust.js +1 -1
- package/dist/src/evals/runner/resolve-git-metadata.d.ts +3 -3
- package/dist/src/evals/scorers/autoevals-client.d.ts +2 -2
- package/dist/src/execution/connection-auth-steps.d.ts +1 -5
- package/dist/src/execution/connection-auth-steps.js +4 -5
- package/dist/src/execution/node-step.d.ts +1 -1
- package/dist/src/execution/skills/instructions.d.ts +2 -1
- package/dist/src/execution/subagent-hitl-proxy.d.ts +1 -1
- package/dist/src/execution/subagent-tool.d.ts +0 -8
- package/dist/src/execution/subagent-tool.js +9 -16
- package/dist/src/execution/tool-compaction.js +0 -2
- package/dist/src/execution/turn-workflow.d.ts +1 -1
- package/dist/src/execution/turn-workflow.js +2 -2
- package/dist/src/execution/web-fetch/tool.js +1 -1
- package/dist/src/execution/workflow-steps.d.ts +17 -1
- package/dist/src/execution/workflow-steps.js +5 -6
- package/dist/src/harness/action-result-helpers.d.ts +0 -12
- package/dist/src/harness/action-result-helpers.js +1 -1
- package/dist/src/harness/emission.d.ts +2 -2
- package/dist/src/harness/execute-tool.d.ts +2 -1
- package/dist/src/harness/input-requests.d.ts +2 -1
- package/dist/src/harness/prompt-cache.d.ts +1 -9
- package/dist/src/harness/prompt-cache.js +0 -12
- package/dist/src/harness/runtime-actions.d.ts +2 -11
- package/dist/src/harness/runtime-actions.js +1 -1
- package/dist/src/harness/step-hooks.d.ts +3 -2
- package/dist/src/harness/step-hooks.js +3 -7
- package/dist/src/harness/tool-loop.js +0 -2
- package/dist/src/harness/types.d.ts +1 -1
- package/dist/src/internal/application/package.js +2 -2
- package/dist/src/internal/application/runtime-compiled-artifacts-source.js +0 -1
- package/dist/src/internal/attachments/errors.d.ts +8 -2
- package/dist/src/internal/attachments/url-refs.d.ts +0 -1
- package/dist/src/internal/attachments/url-refs.js +1 -1
- package/dist/src/internal/authored-definition/channel.d.ts +0 -5
- package/dist/src/internal/authored-definition/channel.js +1 -10
- package/dist/src/internal/authored-definition/sandbox.d.ts +2 -1
- package/dist/src/internal/authored-definition/schema-backed.d.ts +3 -2
- package/dist/src/internal/authored-module-loader.d.ts +0 -6
- package/dist/src/internal/authored-module-loader.js +0 -9
- package/dist/src/internal/authored-module.d.ts +0 -4
- package/dist/src/internal/authored-module.js +0 -10
- package/dist/src/internal/bundler/nitro-rolldown.d.ts +2 -10
- package/dist/src/internal/bundler/nitro-rolldown.js +1 -1
- package/dist/src/{public → internal}/helpers/markdown.d.ts +2 -23
- package/dist/src/{public → internal}/helpers/markdown.js +1 -1
- package/dist/src/internal/logging.d.ts +2 -8
- package/dist/src/internal/nitro/host/build-vercel-agent-summary.d.ts +1 -1
- package/dist/src/internal/nitro/host/build-vercel-agent-summary.js +1 -1
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +2 -2
- package/dist/src/internal/nitro/routes/channel-dispatch.js +2 -2
- package/dist/src/internal/nitro/routes/runtime-artifacts.js +0 -1
- package/dist/src/internal/node-esm-compat-banner.d.ts +1 -1
- package/dist/src/internal/runtime-registry.d.ts +2 -1
- package/dist/src/{protocol → internal}/vercel-agent-summary.d.ts +1 -1
- package/dist/src/protocol/message.d.ts +0 -34
- package/dist/src/protocol/message.js +0 -30
- package/dist/src/public/channels/index.d.ts +1 -1
- package/dist/src/public/channels/index.js +1 -1
- package/dist/src/public/channels/slack/api.d.ts +1 -7
- package/dist/src/public/channels/slack/api.js +1 -1
- package/dist/src/public/channels/slack/connections.d.ts +2 -6
- package/dist/src/public/channels/slack/hitl.d.ts +3 -2
- package/dist/src/public/channels/slack/inbound.d.ts +0 -35
- package/dist/src/public/definitions/channel.d.ts +2 -2
- package/dist/src/public/definitions/channel.js +1 -1
- package/dist/src/public/definitions/defineChannel.d.ts +1 -1
- package/dist/src/public/definitions/defineChannel.js +1 -1
- package/dist/src/public/definitions/instructions.d.ts +0 -11
- package/dist/src/public/definitions/instructions.js +0 -5
- package/dist/src/public/definitions/tool.d.ts +3 -7
- package/dist/src/public/definitions/tool.js +1 -1
- package/dist/src/public/instructions/index.d.ts +1 -5
- package/dist/src/public/instructions/index.js +1 -3
- package/dist/src/public/tool-result-narrowing.d.ts +2 -1
- package/dist/src/react/use-ash-agent.d.ts +2 -1
- package/dist/src/react/use-ash-agent.js +1 -5
- package/dist/src/runtime/actions/types.d.ts +8 -50
- package/dist/src/runtime/actions/types.js +5 -21
- package/dist/src/runtime/agent/bootstrap-model-utils.d.ts +2 -1
- package/dist/src/runtime/agent/mock-model-adapter.js +1 -1
- package/dist/src/runtime/channels/registry.js +3 -8
- package/dist/src/runtime/compiled-artifacts-source.d.ts +4 -11
- package/dist/src/runtime/compiled-artifacts-source.js +3 -7
- package/dist/src/runtime/connections/authorization-tokens.d.ts +1 -14
- package/dist/src/runtime/connections/authorization-tokens.js +2 -28
- package/dist/src/runtime/connections/principal-context.d.ts +3 -2
- package/dist/src/runtime/connections/validate-authorization.d.ts +0 -11
- package/dist/src/runtime/connections/validate-authorization.js +0 -16
- package/dist/src/runtime/framework-channels/index.d.ts +0 -1
- package/dist/src/runtime/framework-channels/index.js +1 -1
- package/dist/src/runtime/framework-tools/index.d.ts +2 -1
- package/dist/src/runtime/framework-tools/index.js +2 -1
- package/dist/src/runtime/framework-tools/skill.d.ts +0 -13
- package/dist/src/runtime/framework-tools/skill.js +1 -1
- package/dist/src/runtime/governance/auth/token-claims.d.ts +1 -16
- package/dist/src/runtime/governance/auth/token-claims.js +3 -3
- package/dist/src/runtime/governance/auth/types.d.ts +0 -4
- package/dist/src/runtime/governance/network/ip-allow-list.d.ts +0 -17
- package/dist/src/runtime/governance/network/ip-allow-list.js +0 -39
- package/dist/src/runtime/hooks/registry.d.ts +7 -4
- package/dist/src/runtime/hooks/registry.js +4 -2
- package/dist/src/runtime/loaders/bundled-artifacts.d.ts +0 -5
- package/dist/src/runtime/loaders/bundled-artifacts.js +0 -7
- package/dist/src/runtime/loaders/compile-metadata.d.ts +3 -10
- package/dist/src/runtime/loaders/compile-metadata.js +6 -8
- package/dist/src/runtime/loaders/manifest.d.ts +2 -2
- package/dist/src/runtime/loaders/manifest.js +4 -5
- package/dist/src/runtime/loaders/module-map.d.ts +2 -2
- package/dist/src/runtime/loaders/module-map.js +3 -4
- package/dist/src/runtime/prompt/compose.d.ts +2 -1
- package/dist/src/runtime/resolve-agent-graph.d.ts +2 -15
- package/dist/src/runtime/resolve-agent-graph.js +1 -1
- package/dist/src/runtime/sandbox/keys.d.ts +2 -1
- package/dist/src/runtime/sandbox/registry.d.ts +3 -3
- package/dist/src/runtime/schedules/resolve-schedule.d.ts +3 -12
- package/dist/src/runtime/schedules/resolve-schedule.js +1 -1
- package/dist/src/runtime/sessions/auth.d.ts +2 -13
- package/dist/src/runtime/sessions/auth.js +1 -11
- package/dist/src/runtime/sessions/compiled-agent-cache.js +1 -1
- package/dist/src/runtime/sessions/runtime-session.d.ts +0 -6
- package/dist/src/runtime/sessions/runtime-session.js +0 -13
- package/dist/src/runtime/sessions/turn.d.ts +2 -2
- package/dist/src/runtime/subagents/registry.d.ts +2 -5
- package/dist/src/runtime/subagents/registry.js +0 -6
- package/dist/src/runtime/tools/registry.d.ts +2 -1
- package/dist/src/runtime/tools/registry.js +1 -4
- package/dist/src/runtime/types.d.ts +4 -3
- package/dist/src/runtime/workspace/seed-files.d.ts +2 -1
- package/dist/src/services/dev-client/request-headers.d.ts +37 -8
- package/dist/src/services/dev-client/request-headers.js +71 -46
- package/dist/src/services/dev-client/stream.d.ts +0 -19
- package/dist/src/services/dev-client/stream.js +0 -37
- package/dist/src/services/dev-client/url.d.ts +3 -7
- package/dist/src/services/dev-client/url.js +4 -10
- package/dist/src/services/dev-client.d.ts +0 -12
- package/dist/src/services/dev-client.js +6 -92
- package/dist/src/shared/agent-definition.d.ts +1 -1
- package/dist/src/shared/json.d.ts +0 -4
- package/dist/src/shared/json.js +0 -38
- package/dist/src/shared/skill-definition.d.ts +0 -2
- package/package.json +1 -6
- package/dist/src/chunks/dev-authored-source-watcher-CBID_Dwh.js +0 -1
- package/dist/src/chunks/host-zBy9FyyX.js +0 -70
- package/dist/src/chunks/package-HUaeub_D.js +0 -1
- package/dist/src/chunks/paths-CebY5GCi.js +0 -89
- package/dist/src/chunks/types-DDA2QUED.js +0 -1
- package/dist/src/compiler/resource-files.d.ts +0 -19
- package/dist/src/compiler/resource-files.js +0 -28
- package/dist/src/execution/subagent-invocation.d.ts +0 -19
- package/dist/src/execution/subagent-invocation.js +0 -17
- package/dist/src/execution/task-mode.d.ts +0 -9
- package/dist/src/execution/task-mode.js +0 -12
- package/dist/src/execution/types.d.ts +0 -20
- package/dist/src/execution/types.js +0 -1
- package/dist/src/internal/logical-paths.d.ts +0 -13
- package/dist/src/internal/logical-paths.js +0 -25
- package/dist/src/runtime/sessions/messages.d.ts +0 -140
- package/dist/src/runtime/sessions/messages.js +0 -170
- package/dist/src/runtime/standard-schema.d.ts +0 -27
- package/dist/src/runtime/standard-schema.js +0 -64
- package/dist/src/services/dev-client/live-stream.d.ts +0 -35
- package/dist/src/services/dev-client/live-stream.js +0 -157
- package/dist/src/services/dev-client/send-message.d.ts +0 -24
- package/dist/src/services/dev-client/send-message.js +0 -185
- package/dist/src/services/dev-client/session.d.ts +0 -54
- package/dist/src/services/dev-client/session.js +0 -52
- package/dist/src/services/host.d.ts +0 -14
- package/dist/src/services/host.js +0 -13
- /package/dist/src/{package-name.d.ts → internal/package-name.d.ts} +0 -0
- /package/dist/src/{package-name.js → internal/package-name.js} +0 -0
- /package/dist/src/{protocol → internal}/vercel-agent-summary.js +0 -0
- /package/dist/src/{run-mode.d.ts → shared/run-mode.d.ts} +0 -0
- /package/dist/src/{run-mode.js → shared/run-mode.js} +0 -0
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { HarnessSession } from "#harness/types.js";
|
|
2
|
-
import type { PendingConnectionAuthorization } from "#runtime/framework-tools/connection-search.js";
|
|
3
|
-
import type { PendingConnectionToolCall } from "#runtime/framework-tools/pending-connection-tool-calls.js";
|
|
4
|
-
export type { ChannelAdapter } from "#channel/adapter.js";
|
|
5
|
-
export type { DeliverInput, EventEmitFn, RunHandle, RunInput, RunResult, Runtime, SessionParent, SessionTurn, } from "#channel/types.js";
|
|
6
|
-
/**
|
|
7
|
-
* Serializable projection of a step result for workflow persistence.
|
|
8
|
-
*/
|
|
9
|
-
export type DurableStepResult = {
|
|
10
|
-
readonly action: "continue" | "park" | "done";
|
|
11
|
-
readonly output?: string;
|
|
12
|
-
readonly serializedContext: Record<string, unknown>;
|
|
13
|
-
readonly session: HarnessSession;
|
|
14
|
-
} | {
|
|
15
|
-
readonly action: "await-authorization";
|
|
16
|
-
readonly pendingToolCalls: readonly PendingConnectionToolCall[];
|
|
17
|
-
readonly pendingAuths: readonly PendingConnectionAuthorization[];
|
|
18
|
-
readonly serializedContext: Record<string, unknown>;
|
|
19
|
-
readonly session: HarnessSession;
|
|
20
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Removes one logical root prefix such as `context/` or `workspace/` when it
|
|
3
|
-
* is present.
|
|
4
|
-
*/
|
|
5
|
-
export declare function stripLogicalPathRoot(logicalPath: string, rootName: string): string;
|
|
6
|
-
/**
|
|
7
|
-
* Removes the authored `context/` logical root prefix when present.
|
|
8
|
-
*/
|
|
9
|
-
export declare function stripContextRootLogicalPath(logicalPath: string): string;
|
|
10
|
-
/**
|
|
11
|
-
* Removes the authored `workspace/` logical root prefix when present.
|
|
12
|
-
*/
|
|
13
|
-
export declare function stripWorkspaceRootLogicalPath(logicalPath: string): string;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { normalizeLogicalPath } from "#discover/filesystem.js";
|
|
2
|
-
/**
|
|
3
|
-
* Removes one logical root prefix such as `context/` or `workspace/` when it
|
|
4
|
-
* is present.
|
|
5
|
-
*/
|
|
6
|
-
export function stripLogicalPathRoot(logicalPath, rootName) {
|
|
7
|
-
const normalizedPath = normalizeLogicalPath(logicalPath);
|
|
8
|
-
const normalizedRootName = normalizeLogicalPath(rootName).replace(/\/+$/, "");
|
|
9
|
-
const prefixedRootName = `${normalizedRootName}/`;
|
|
10
|
-
return normalizedPath.startsWith(prefixedRootName)
|
|
11
|
-
? normalizedPath.slice(prefixedRootName.length)
|
|
12
|
-
: normalizedPath;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Removes the authored `context/` logical root prefix when present.
|
|
16
|
-
*/
|
|
17
|
-
export function stripContextRootLogicalPath(logicalPath) {
|
|
18
|
-
return stripLogicalPathRoot(logicalPath, "context");
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Removes the authored `workspace/` logical root prefix when present.
|
|
22
|
-
*/
|
|
23
|
-
export function stripWorkspaceRootLogicalPath(logicalPath) {
|
|
24
|
-
return stripLogicalPathRoot(logicalPath, "workspace");
|
|
25
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { z } from "#compiled/zod/index.js";
|
|
2
|
-
/**
|
|
3
|
-
* Runtime-owned semantic tag applied to durable session messages.
|
|
4
|
-
*/
|
|
5
|
-
export type RuntimeSessionMessageKind = "compaction" | "default";
|
|
6
|
-
/**
|
|
7
|
-
* Runtime-owned metadata preserved alongside one durable session message.
|
|
8
|
-
*/
|
|
9
|
-
export type RuntimeSessionMessageMetadata = z.infer<typeof runtimeSessionMessageMetadataSchema>;
|
|
10
|
-
export declare const runtimeSessionMessageMetadataSchema: z.ZodObject<{
|
|
11
|
-
kind: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"compaction">, z.ZodLiteral<"default">]>>;
|
|
12
|
-
}, z.core.$strict>;
|
|
13
|
-
/**
|
|
14
|
-
* Serializable system message prepared for one runtime turn.
|
|
15
|
-
*/
|
|
16
|
-
export type RuntimeSystemMessage = z.infer<typeof runtimeSystemMessageSchema>;
|
|
17
|
-
/**
|
|
18
|
-
* Zod schema for one runtime-owned system message.
|
|
19
|
-
*/
|
|
20
|
-
export declare const runtimeSystemMessageSchema: z.ZodObject<{
|
|
21
|
-
content: z.ZodString;
|
|
22
|
-
metadata: z.ZodOptional<z.ZodObject<{
|
|
23
|
-
kind: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"compaction">, z.ZodLiteral<"default">]>>;
|
|
24
|
-
}, z.core.$strict>>;
|
|
25
|
-
role: z.ZodLiteral<"system">;
|
|
26
|
-
}, z.core.$strict>;
|
|
27
|
-
/**
|
|
28
|
-
* Serializable user message prepared for one runtime turn.
|
|
29
|
-
*/
|
|
30
|
-
export type RuntimeUserMessage = z.infer<typeof runtimeUserMessageSchema>;
|
|
31
|
-
/**
|
|
32
|
-
* Zod schema for one runtime-owned user message.
|
|
33
|
-
*/
|
|
34
|
-
export declare const runtimeUserMessageSchema: z.ZodObject<{
|
|
35
|
-
content: z.ZodString;
|
|
36
|
-
metadata: z.ZodOptional<z.ZodObject<{
|
|
37
|
-
kind: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"compaction">, z.ZodLiteral<"default">]>>;
|
|
38
|
-
}, z.core.$strict>>;
|
|
39
|
-
role: z.ZodLiteral<"user">;
|
|
40
|
-
}, z.core.$strict>;
|
|
41
|
-
/**
|
|
42
|
-
* Serializable assistant message prepared for one runtime turn.
|
|
43
|
-
*/
|
|
44
|
-
export type RuntimeAssistantMessage = z.infer<typeof runtimeAssistantMessageSchema>;
|
|
45
|
-
/**
|
|
46
|
-
* Zod schema for one runtime-owned assistant message.
|
|
47
|
-
*/
|
|
48
|
-
export declare const runtimeAssistantMessageSchema: z.ZodObject<{
|
|
49
|
-
content: z.ZodString;
|
|
50
|
-
metadata: z.ZodOptional<z.ZodObject<{
|
|
51
|
-
kind: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"compaction">, z.ZodLiteral<"default">]>>;
|
|
52
|
-
}, z.core.$strict>>;
|
|
53
|
-
role: z.ZodLiteral<"assistant">;
|
|
54
|
-
}, z.core.$strict>;
|
|
55
|
-
/**
|
|
56
|
-
* Serializable model-visible message used to assemble one prepared runtime turn.
|
|
57
|
-
*/
|
|
58
|
-
export type RuntimeSessionMessage = RuntimeAssistantMessage | RuntimeSystemMessage | RuntimeUserMessage;
|
|
59
|
-
/**
|
|
60
|
-
* Zod schema for one runtime-owned serializable session message.
|
|
61
|
-
*/
|
|
62
|
-
export declare const runtimeSessionMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
63
|
-
content: z.ZodString;
|
|
64
|
-
metadata: z.ZodOptional<z.ZodObject<{
|
|
65
|
-
kind: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"compaction">, z.ZodLiteral<"default">]>>;
|
|
66
|
-
}, z.core.$strict>>;
|
|
67
|
-
role: z.ZodLiteral<"assistant">;
|
|
68
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
69
|
-
content: z.ZodString;
|
|
70
|
-
metadata: z.ZodOptional<z.ZodObject<{
|
|
71
|
-
kind: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"compaction">, z.ZodLiteral<"default">]>>;
|
|
72
|
-
}, z.core.$strict>>;
|
|
73
|
-
role: z.ZodLiteral<"system">;
|
|
74
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
75
|
-
content: z.ZodString;
|
|
76
|
-
metadata: z.ZodOptional<z.ZodObject<{
|
|
77
|
-
kind: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"compaction">, z.ZodLiteral<"default">]>>;
|
|
78
|
-
}, z.core.$strict>>;
|
|
79
|
-
role: z.ZodLiteral<"user">;
|
|
80
|
-
}, z.core.$strict>], "role">;
|
|
81
|
-
/**
|
|
82
|
-
* Default inbound user message used when the message route receives only whitespace.
|
|
83
|
-
*/
|
|
84
|
-
export declare const DEFAULT_RUNTIME_USER_MESSAGE = "Hello from Ash";
|
|
85
|
-
/**
|
|
86
|
-
* Normalizes one inbound user message into the runtime-owned session format.
|
|
87
|
-
*/
|
|
88
|
-
export declare function normalizeRuntimeUserMessage(message: string): string;
|
|
89
|
-
/**
|
|
90
|
-
* Creates one runtime-owned system message.
|
|
91
|
-
*/
|
|
92
|
-
export declare function createRuntimeSystemMessage(content: string): RuntimeSystemMessage;
|
|
93
|
-
/**
|
|
94
|
-
* Creates one runtime-owned user message.
|
|
95
|
-
*/
|
|
96
|
-
export declare function createRuntimeUserMessage(content: string): RuntimeUserMessage;
|
|
97
|
-
/**
|
|
98
|
-
* Creates one runtime-owned assistant message.
|
|
99
|
-
*/
|
|
100
|
-
export declare function createRuntimeAssistantMessage(content: string): RuntimeAssistantMessage;
|
|
101
|
-
/**
|
|
102
|
-
* Creates one runtime-owned compaction checkpoint message.
|
|
103
|
-
*/
|
|
104
|
-
export declare function createRuntimeCompactionMessage(content: string): RuntimeSystemMessage;
|
|
105
|
-
/**
|
|
106
|
-
* Returns the canonical runtime-owned session history used to prepare the next turn.
|
|
107
|
-
*/
|
|
108
|
-
export declare function getRuntimeSessionHistory(session: {
|
|
109
|
-
readonly history: unknown;
|
|
110
|
-
}): readonly RuntimeSessionMessage[];
|
|
111
|
-
/**
|
|
112
|
-
* Returns the runtime-visible history slice that starts at the latest
|
|
113
|
-
* compaction checkpoint when one exists.
|
|
114
|
-
*/
|
|
115
|
-
export declare function getRuntimeSessionHistoryFromCompactionBoundary(session: {
|
|
116
|
-
readonly history: unknown;
|
|
117
|
-
readonly lastCompactionIndex: unknown;
|
|
118
|
-
}): readonly RuntimeSessionMessage[];
|
|
119
|
-
/**
|
|
120
|
-
* Merges one visible harness-projected history back into the durable session
|
|
121
|
-
* history while preserving any hidden pre-compaction prefix.
|
|
122
|
-
*/
|
|
123
|
-
export declare function mergeRuntimeSessionHistoryFromProjection(input: {
|
|
124
|
-
readonly history: readonly RuntimeSessionMessage[];
|
|
125
|
-
readonly lastCompactionIndex: number | null;
|
|
126
|
-
readonly projectionHistory: readonly RuntimeSessionMessage[];
|
|
127
|
-
}): readonly RuntimeSessionMessage[];
|
|
128
|
-
/**
|
|
129
|
-
* Returns the durable index of the latest compaction checkpoint message inside
|
|
130
|
-
* one runtime history array.
|
|
131
|
-
*/
|
|
132
|
-
export declare function findLastRuntimeCompactionIndex(history: readonly RuntimeSessionMessage[]): number | null;
|
|
133
|
-
/**
|
|
134
|
-
* Returns true when the durable message is a compaction checkpoint.
|
|
135
|
-
*/
|
|
136
|
-
export declare function isRuntimeCompactionMessage(message: RuntimeSessionMessage): boolean;
|
|
137
|
-
/**
|
|
138
|
-
* Returns true when unknown JSON matches one runtime session message.
|
|
139
|
-
*/
|
|
140
|
-
export declare function isRuntimeSessionMessage(value: unknown): value is RuntimeSessionMessage;
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { z } from "#compiled/zod/index.js";
|
|
2
|
-
export const runtimeSessionMessageMetadataSchema = z
|
|
3
|
-
.object({
|
|
4
|
-
kind: z.union([z.literal("compaction"), z.literal("default")]).optional(),
|
|
5
|
-
})
|
|
6
|
-
.strict();
|
|
7
|
-
/**
|
|
8
|
-
* Zod schema for one runtime-owned system message.
|
|
9
|
-
*/
|
|
10
|
-
export const runtimeSystemMessageSchema = z
|
|
11
|
-
.object({
|
|
12
|
-
content: z.string(),
|
|
13
|
-
metadata: runtimeSessionMessageMetadataSchema.optional(),
|
|
14
|
-
role: z.literal("system"),
|
|
15
|
-
})
|
|
16
|
-
.strict();
|
|
17
|
-
/**
|
|
18
|
-
* Zod schema for one runtime-owned user message.
|
|
19
|
-
*/
|
|
20
|
-
export const runtimeUserMessageSchema = z
|
|
21
|
-
.object({
|
|
22
|
-
content: z.string(),
|
|
23
|
-
metadata: runtimeSessionMessageMetadataSchema.optional(),
|
|
24
|
-
role: z.literal("user"),
|
|
25
|
-
})
|
|
26
|
-
.strict();
|
|
27
|
-
/**
|
|
28
|
-
* Zod schema for one runtime-owned assistant message.
|
|
29
|
-
*/
|
|
30
|
-
export const runtimeAssistantMessageSchema = z
|
|
31
|
-
.object({
|
|
32
|
-
content: z.string(),
|
|
33
|
-
metadata: runtimeSessionMessageMetadataSchema.optional(),
|
|
34
|
-
role: z.literal("assistant"),
|
|
35
|
-
})
|
|
36
|
-
.strict();
|
|
37
|
-
/**
|
|
38
|
-
* Zod schema for one runtime-owned serializable session message.
|
|
39
|
-
*/
|
|
40
|
-
export const runtimeSessionMessageSchema = z.discriminatedUnion("role", [
|
|
41
|
-
runtimeAssistantMessageSchema,
|
|
42
|
-
runtimeSystemMessageSchema,
|
|
43
|
-
runtimeUserMessageSchema,
|
|
44
|
-
]);
|
|
45
|
-
/**
|
|
46
|
-
* Default inbound user message used when the message route receives only whitespace.
|
|
47
|
-
*/
|
|
48
|
-
export const DEFAULT_RUNTIME_USER_MESSAGE = "Hello from Ash";
|
|
49
|
-
/**
|
|
50
|
-
* Normalizes one inbound user message into the runtime-owned session format.
|
|
51
|
-
*/
|
|
52
|
-
export function normalizeRuntimeUserMessage(message) {
|
|
53
|
-
const normalized = message.trim();
|
|
54
|
-
return normalized.length > 0 ? normalized : DEFAULT_RUNTIME_USER_MESSAGE;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Creates one runtime-owned system message.
|
|
58
|
-
*/
|
|
59
|
-
export function createRuntimeSystemMessage(content) {
|
|
60
|
-
return {
|
|
61
|
-
content,
|
|
62
|
-
role: "system",
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Creates one runtime-owned user message.
|
|
67
|
-
*/
|
|
68
|
-
export function createRuntimeUserMessage(content) {
|
|
69
|
-
return {
|
|
70
|
-
content,
|
|
71
|
-
role: "user",
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Creates one runtime-owned assistant message.
|
|
76
|
-
*/
|
|
77
|
-
export function createRuntimeAssistantMessage(content) {
|
|
78
|
-
return {
|
|
79
|
-
content,
|
|
80
|
-
role: "assistant",
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Creates one runtime-owned compaction checkpoint message.
|
|
85
|
-
*/
|
|
86
|
-
export function createRuntimeCompactionMessage(content) {
|
|
87
|
-
return {
|
|
88
|
-
content,
|
|
89
|
-
metadata: {
|
|
90
|
-
kind: "compaction",
|
|
91
|
-
},
|
|
92
|
-
role: "system",
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Returns the canonical runtime-owned session history used to prepare the next turn.
|
|
97
|
-
*/
|
|
98
|
-
export function getRuntimeSessionHistory(session) {
|
|
99
|
-
if (!Array.isArray(session.history) ||
|
|
100
|
-
!session.history.every((message) => isRuntimeSessionMessage(message))) {
|
|
101
|
-
throw new Error("Expected runtime session history to be a serializable message array.");
|
|
102
|
-
}
|
|
103
|
-
return session.history;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Returns the runtime-visible history slice that starts at the latest
|
|
107
|
-
* compaction checkpoint when one exists.
|
|
108
|
-
*/
|
|
109
|
-
export function getRuntimeSessionHistoryFromCompactionBoundary(session) {
|
|
110
|
-
const history = getRuntimeSessionHistory(session);
|
|
111
|
-
const lastCompactionIndex = assertLastCompactionIndex(session.lastCompactionIndex, history.length);
|
|
112
|
-
return lastCompactionIndex === null ? history : history.slice(lastCompactionIndex);
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Merges one visible harness-projected history back into the durable session
|
|
116
|
-
* history while preserving any hidden pre-compaction prefix.
|
|
117
|
-
*/
|
|
118
|
-
export function mergeRuntimeSessionHistoryFromProjection(input) {
|
|
119
|
-
const history = getRuntimeSessionHistory({
|
|
120
|
-
history: input.history,
|
|
121
|
-
});
|
|
122
|
-
const projectionHistory = getRuntimeSessionHistory({
|
|
123
|
-
history: input.projectionHistory,
|
|
124
|
-
});
|
|
125
|
-
const lastCompactionIndex = assertLastCompactionIndex(input.lastCompactionIndex, history.length);
|
|
126
|
-
if (lastCompactionIndex === null) {
|
|
127
|
-
return [...projectionHistory];
|
|
128
|
-
}
|
|
129
|
-
return [...history.slice(0, lastCompactionIndex), ...projectionHistory];
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Returns the durable index of the latest compaction checkpoint message inside
|
|
133
|
-
* one runtime history array.
|
|
134
|
-
*/
|
|
135
|
-
export function findLastRuntimeCompactionIndex(history) {
|
|
136
|
-
const normalizedHistory = getRuntimeSessionHistory({
|
|
137
|
-
history,
|
|
138
|
-
});
|
|
139
|
-
for (let index = normalizedHistory.length - 1; index >= 0; index -= 1) {
|
|
140
|
-
const message = normalizedHistory[index];
|
|
141
|
-
if (message !== undefined && isRuntimeCompactionMessage(message)) {
|
|
142
|
-
return index;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return null;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Returns true when the durable message is a compaction checkpoint.
|
|
149
|
-
*/
|
|
150
|
-
export function isRuntimeCompactionMessage(message) {
|
|
151
|
-
return message.metadata?.kind === "compaction";
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Returns true when unknown JSON matches one runtime session message.
|
|
155
|
-
*/
|
|
156
|
-
export function isRuntimeSessionMessage(value) {
|
|
157
|
-
return runtimeSessionMessageSchema.safeParse(value).success;
|
|
158
|
-
}
|
|
159
|
-
function assertLastCompactionIndex(value, historyLength) {
|
|
160
|
-
if (value === null) {
|
|
161
|
-
return null;
|
|
162
|
-
}
|
|
163
|
-
if (typeof value !== "number" ||
|
|
164
|
-
!Number.isInteger(value) ||
|
|
165
|
-
value < 0 ||
|
|
166
|
-
value >= historyLength) {
|
|
167
|
-
throw new Error(`Expected lastCompactionIndex to point at a durable history entry, received ${String(value)}.`);
|
|
168
|
-
}
|
|
169
|
-
return value;
|
|
170
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { StandardSchemaV1 } from "#compiled/@standard-schema/spec/index.js";
|
|
2
|
-
/**
|
|
3
|
-
* Runtime-owned validator signature extracted from a live Standard Schema.
|
|
4
|
-
*/
|
|
5
|
-
export type StandardSchemaValidator = StandardSchemaV1["~standard"]["validate"];
|
|
6
|
-
/**
|
|
7
|
-
* Normalized result returned from one runtime Standard Schema validation.
|
|
8
|
-
*/
|
|
9
|
-
export type StandardSchemaValidationResult = {
|
|
10
|
-
readonly issues: readonly StandardSchemaV1.Issue[];
|
|
11
|
-
readonly ok: false;
|
|
12
|
-
} | {
|
|
13
|
-
readonly ok: true;
|
|
14
|
-
readonly value: unknown;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Returns the live Standard Schema validator when the value exposes one.
|
|
18
|
-
*/
|
|
19
|
-
export declare function getStandardSchemaValidator(value: unknown): StandardSchemaValidator | undefined;
|
|
20
|
-
/**
|
|
21
|
-
* Runs one Standard Schema validator and normalizes the success/error shape.
|
|
22
|
-
*/
|
|
23
|
-
export declare function validateStandardSchemaValue(validator: StandardSchemaValidator, value: unknown): Promise<StandardSchemaValidationResult>;
|
|
24
|
-
/**
|
|
25
|
-
* Formats Standard Schema issues into a concise single-line message.
|
|
26
|
-
*/
|
|
27
|
-
export declare function formatStandardSchemaIssues(issues: readonly StandardSchemaV1.Issue[]): string;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the live Standard Schema validator when the value exposes one.
|
|
3
|
-
*/
|
|
4
|
-
export function getStandardSchemaValidator(value) {
|
|
5
|
-
if (typeof value !== "object" || value === null) {
|
|
6
|
-
return undefined;
|
|
7
|
-
}
|
|
8
|
-
const standard = value["~standard"];
|
|
9
|
-
if (typeof standard?.validate !== "function") {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
return standard.validate;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Runs one Standard Schema validator and normalizes the success/error shape.
|
|
16
|
-
*/
|
|
17
|
-
export async function validateStandardSchemaValue(validator, value) {
|
|
18
|
-
const result = await validator(value);
|
|
19
|
-
if ("value" in result) {
|
|
20
|
-
return {
|
|
21
|
-
ok: true,
|
|
22
|
-
value: result.value,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
if (result.issues.length > 0) {
|
|
26
|
-
return {
|
|
27
|
-
issues: result.issues,
|
|
28
|
-
ok: false,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
issues: result.issues,
|
|
33
|
-
ok: false,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Formats Standard Schema issues into a concise single-line message.
|
|
38
|
-
*/
|
|
39
|
-
export function formatStandardSchemaIssues(issues) {
|
|
40
|
-
return issues
|
|
41
|
-
.map((issue) => {
|
|
42
|
-
const path = formatIssuePath(issue.path);
|
|
43
|
-
return path.length === 0 ? issue.message : `${path}: ${issue.message}`;
|
|
44
|
-
})
|
|
45
|
-
.join("; ");
|
|
46
|
-
}
|
|
47
|
-
function formatIssuePath(path) {
|
|
48
|
-
if (path === undefined || path.length === 0) {
|
|
49
|
-
return "";
|
|
50
|
-
}
|
|
51
|
-
return path
|
|
52
|
-
.map((segment, index) => {
|
|
53
|
-
const key = typeof segment === "object" && segment !== null && "key" in segment ? segment.key : segment;
|
|
54
|
-
if (typeof key === "number") {
|
|
55
|
-
return `[${key}]`;
|
|
56
|
-
}
|
|
57
|
-
const token = String(key);
|
|
58
|
-
if (index === 0) {
|
|
59
|
-
return token;
|
|
60
|
-
}
|
|
61
|
-
return /^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(token) ? `.${token}` : `[${JSON.stringify(token)}]`;
|
|
62
|
-
})
|
|
63
|
-
.join("");
|
|
64
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { HandleMessageStreamEvent } from "#protocol/message.js";
|
|
2
|
-
/**
|
|
3
|
-
* One reusable service-owned connection to a durable message-run stream.
|
|
4
|
-
*/
|
|
5
|
-
export interface DevelopmentMessageStream {
|
|
6
|
-
/**
|
|
7
|
-
* Absolute stream URL used to open this connection.
|
|
8
|
-
*/
|
|
9
|
-
readonly resourceUrl: string;
|
|
10
|
-
/**
|
|
11
|
-
* Whether the underlying response body can no longer produce future events.
|
|
12
|
-
*/
|
|
13
|
-
readonly closed: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Stops reading from the underlying response and releases any held reader.
|
|
16
|
-
*/
|
|
17
|
-
close(): Promise<void>;
|
|
18
|
-
/**
|
|
19
|
-
* Reads one slice of newline-delimited events from the stream until the
|
|
20
|
-
* configured boundary predicate matches or the response closes.
|
|
21
|
-
*/
|
|
22
|
-
readEvents(input: {
|
|
23
|
-
onEvent?(event: HandleMessageStreamEvent): void;
|
|
24
|
-
startAfterBoundaryCount?: number;
|
|
25
|
-
stopWhen?(event: HandleMessageStreamEvent): boolean;
|
|
26
|
-
}): Promise<HandleMessageStreamEvent[]>;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Opens one reusable message-stream reader for the development client.
|
|
30
|
-
*/
|
|
31
|
-
export declare function openDevelopmentMessageStream(input: {
|
|
32
|
-
boundaryCount?: number;
|
|
33
|
-
resourceUrl: string;
|
|
34
|
-
response: Response;
|
|
35
|
-
}): DevelopmentMessageStream;
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { isCurrentTurnBoundaryEvent } from "#protocol/message.js";
|
|
2
|
-
function isDevelopmentMessageStreamDisconnectError(error) {
|
|
3
|
-
if (error instanceof DOMException) {
|
|
4
|
-
return error.name === "AbortError";
|
|
5
|
-
}
|
|
6
|
-
if (!(error instanceof Error)) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
const errorCode = "code" in error && typeof error.code === "string" ? error.code : undefined;
|
|
10
|
-
return (error.name === "AbortError" ||
|
|
11
|
-
error.message === "terminated" ||
|
|
12
|
-
errorCode === "UND_ERR_SOCKET" ||
|
|
13
|
-
/abort|cancel|disconnect|premature close|socket|terminated/i.test(error.message));
|
|
14
|
-
}
|
|
15
|
-
class BufferedDevelopmentMessageStream {
|
|
16
|
-
resourceUrl;
|
|
17
|
-
#boundaryCount = 0;
|
|
18
|
-
#buffer = "";
|
|
19
|
-
#closed = false;
|
|
20
|
-
#decoder = new TextDecoder();
|
|
21
|
-
#isReading = false;
|
|
22
|
-
#reader;
|
|
23
|
-
constructor(input) {
|
|
24
|
-
this.resourceUrl = input.resourceUrl;
|
|
25
|
-
this.#boundaryCount = input.boundaryCount ?? 0;
|
|
26
|
-
this.#reader = input.response.body?.getReader() ?? null;
|
|
27
|
-
this.#closed = this.#reader === null;
|
|
28
|
-
if (this.#reader) {
|
|
29
|
-
void this.#reader.closed
|
|
30
|
-
.catch(() => undefined)
|
|
31
|
-
.finally(() => {
|
|
32
|
-
this.#closed = true;
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
get closed() {
|
|
37
|
-
return this.#closed;
|
|
38
|
-
}
|
|
39
|
-
async close() {
|
|
40
|
-
const reader = this.#reader;
|
|
41
|
-
this.#closed = true;
|
|
42
|
-
this.#reader = null;
|
|
43
|
-
this.#buffer = "";
|
|
44
|
-
if (reader === null) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
try {
|
|
48
|
-
await reader.cancel();
|
|
49
|
-
}
|
|
50
|
-
finally {
|
|
51
|
-
reader.releaseLock();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
async readEvents(input) {
|
|
55
|
-
if (this.#closed) {
|
|
56
|
-
return [];
|
|
57
|
-
}
|
|
58
|
-
if (this.#isReading) {
|
|
59
|
-
throw new Error("Development message stream does not support concurrent reads.");
|
|
60
|
-
}
|
|
61
|
-
const reader = this.#reader;
|
|
62
|
-
if (reader === null) {
|
|
63
|
-
return [];
|
|
64
|
-
}
|
|
65
|
-
this.#isReading = true;
|
|
66
|
-
try {
|
|
67
|
-
const events = [];
|
|
68
|
-
const stopWhen = input.stopWhen ?? isCurrentTurnBoundaryEvent;
|
|
69
|
-
const startAfterBoundaryCount = input.startAfterBoundaryCount ?? 0;
|
|
70
|
-
let shouldCollect = startAfterBoundaryCount <= this.#boundaryCount;
|
|
71
|
-
const handleEvent = (event) => {
|
|
72
|
-
const isBoundaryEvent = isCurrentTurnBoundaryEvent(event);
|
|
73
|
-
if (shouldCollect) {
|
|
74
|
-
events.push(event);
|
|
75
|
-
input.onEvent?.(event);
|
|
76
|
-
}
|
|
77
|
-
if (!isBoundaryEvent) {
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
this.#boundaryCount += 1;
|
|
81
|
-
if (!shouldCollect && this.#boundaryCount >= startAfterBoundaryCount) {
|
|
82
|
-
shouldCollect = true;
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
return shouldCollect && stopWhen(event);
|
|
86
|
-
};
|
|
87
|
-
while (true) {
|
|
88
|
-
while (true) {
|
|
89
|
-
const newlineIndex = this.#buffer.indexOf("\n");
|
|
90
|
-
if (newlineIndex === -1) {
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
const line = this.#buffer.slice(0, newlineIndex).trim();
|
|
94
|
-
this.#buffer = this.#buffer.slice(newlineIndex + 1);
|
|
95
|
-
if (line.length === 0) {
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
const event = JSON.parse(line);
|
|
99
|
-
if (handleEvent(event)) {
|
|
100
|
-
return events;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (this.#closed) {
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
let done = false;
|
|
107
|
-
let value;
|
|
108
|
-
try {
|
|
109
|
-
const readResult = await reader.read();
|
|
110
|
-
done = readResult.done;
|
|
111
|
-
value = readResult.value;
|
|
112
|
-
}
|
|
113
|
-
catch (error) {
|
|
114
|
-
if (!isDevelopmentMessageStreamDisconnectError(error)) {
|
|
115
|
-
throw error;
|
|
116
|
-
}
|
|
117
|
-
// Discard any incomplete trailing line and reconnect from the last
|
|
118
|
-
// fully parsed event via the durable stream cursor.
|
|
119
|
-
this.#buffer = "";
|
|
120
|
-
this.#closed = true;
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
if (done) {
|
|
124
|
-
this.#buffer += this.#decoder.decode();
|
|
125
|
-
this.#closed = true;
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
if (!value) {
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
this.#buffer += this.#decoder.decode(value, {
|
|
132
|
-
stream: true,
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
const trailingLine = this.#buffer.trim();
|
|
136
|
-
this.#buffer = "";
|
|
137
|
-
if (trailingLine.length > 0) {
|
|
138
|
-
const event = JSON.parse(trailingLine);
|
|
139
|
-
handleEvent(event);
|
|
140
|
-
}
|
|
141
|
-
return events;
|
|
142
|
-
}
|
|
143
|
-
finally {
|
|
144
|
-
this.#isReading = false;
|
|
145
|
-
if (this.#closed) {
|
|
146
|
-
reader.releaseLock();
|
|
147
|
-
this.#reader = null;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Opens one reusable message-stream reader for the development client.
|
|
154
|
-
*/
|
|
155
|
-
export function openDevelopmentMessageStream(input) {
|
|
156
|
-
return new BufferedDevelopmentMessageStream(input);
|
|
157
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { HandleMessageStreamEvent } from "#protocol/message.js";
|
|
2
|
-
import { type DevelopmentRequestHeaders } from "#services/dev-client/request-headers.js";
|
|
3
|
-
import { type DevelopmentSessionState } from "#services/dev-client/session.js";
|
|
4
|
-
/**
|
|
5
|
-
* Sends one message to the configured Ash server and collects its streamed
|
|
6
|
-
* events, forwarding any caller-supplied Ash route headers across the message
|
|
7
|
-
* and stream requests for the current turn.
|
|
8
|
-
*/
|
|
9
|
-
export declare function sendDevelopmentMessage(input: {
|
|
10
|
-
headers?: DevelopmentRequestHeaders;
|
|
11
|
-
message: string;
|
|
12
|
-
onEvent?(event: HandleMessageStreamEvent): void;
|
|
13
|
-
onResponseStart?(response: {
|
|
14
|
-
sessionId?: string;
|
|
15
|
-
}): void;
|
|
16
|
-
signal?: AbortSignal;
|
|
17
|
-
session: DevelopmentSessionState;
|
|
18
|
-
serverUrl: string;
|
|
19
|
-
}): Promise<{
|
|
20
|
-
completedMessage?: string;
|
|
21
|
-
events: HandleMessageStreamEvent[];
|
|
22
|
-
sessionId?: string;
|
|
23
|
-
session: DevelopmentSessionState;
|
|
24
|
-
}>;
|