@superdurable/dex-agents 0.0.0-stage → 0.2.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/LICENSE +105 -0
- package/README.md +1981 -2
- package/dist/src/agent-built-in-tools.d.ts +81 -0
- package/dist/src/agent-built-in-tools.js +246 -0
- package/dist/src/agent-built-in-tools.js.map +1 -0
- package/dist/src/agent-context-compaction.d.ts +108 -0
- package/dist/src/agent-context-compaction.js +39 -0
- package/dist/src/agent-context-compaction.js.map +1 -0
- package/dist/src/agent-event-writer.d.ts +26 -0
- package/dist/src/agent-event-writer.js +110 -0
- package/dist/src/agent-event-writer.js.map +1 -0
- package/dist/src/agent-framework-runner.d.ts +808 -0
- package/dist/src/agent-framework-runner.js +82 -0
- package/dist/src/agent-framework-runner.js.map +1 -0
- package/dist/src/agent-plans.d.ts +48 -0
- package/dist/src/agent-plans.js +86 -0
- package/dist/src/agent-plans.js.map +1 -0
- package/dist/src/agent-session-cancellation-steps.d.ts +28 -0
- package/dist/src/agent-session-cancellation-steps.js +154 -0
- package/dist/src/agent-session-cancellation-steps.js.map +1 -0
- package/dist/src/agent-session-codecs.d.ts +105 -0
- package/dist/src/agent-session-codecs.js +689 -0
- package/dist/src/agent-session-codecs.js.map +1 -0
- package/dist/src/agent-session-flow.d.ts +416 -0
- package/dist/src/agent-session-flow.js +623 -0
- package/dist/src/agent-session-flow.js.map +1 -0
- package/dist/src/agent-session-persistence.d.ts +133 -0
- package/dist/src/agent-session-persistence.js +74 -0
- package/dist/src/agent-session-persistence.js.map +1 -0
- package/dist/src/agent-session-settings.d.ts +58 -0
- package/dist/src/agent-session-settings.js +81 -0
- package/dist/src/agent-session-settings.js.map +1 -0
- package/dist/src/agent-session-step-options.d.ts +27 -0
- package/dist/src/agent-session-step-options.js +39 -0
- package/dist/src/agent-session-step-options.js.map +1 -0
- package/dist/src/agent-session-step-types.d.ts +20 -0
- package/dist/src/agent-session-step-types.js +28 -0
- package/dist/src/agent-session-step-types.js.map +1 -0
- package/dist/src/agent-session-steps.d.ts +179 -0
- package/dist/src/agent-session-steps.js +1272 -0
- package/dist/src/agent-session-steps.js.map +1 -0
- package/dist/src/agent-session-tracer.d.ts +61 -0
- package/dist/src/agent-session-tracer.js +608 -0
- package/dist/src/agent-session-tracer.js.map +1 -0
- package/dist/src/agent-session-transitions.d.ts +224 -0
- package/dist/src/agent-session-transitions.js +850 -0
- package/dist/src/agent-session-transitions.js.map +1 -0
- package/dist/src/agent-session-values.d.ts +998 -0
- package/dist/src/agent-session-values.js +162 -0
- package/dist/src/agent-session-values.js.map +1 -0
- package/dist/src/agent-session-wait-steps.d.ts +53 -0
- package/dist/src/agent-session-wait-steps.js +389 -0
- package/dist/src/agent-session-wait-steps.js.map +1 -0
- package/dist/src/agent-tracing-options.d.ts +107 -0
- package/dist/src/agent-tracing-options.js +20 -0
- package/dist/src/agent-tracing-options.js.map +1 -0
- package/dist/src/ai-sdk/ai-sdk-model-client.d.ts +40 -0
- package/dist/src/ai-sdk/ai-sdk-model-client.js +235 -0
- package/dist/src/ai-sdk/ai-sdk-model-client.js.map +1 -0
- package/dist/src/ai-sdk/index.d.ts +1 -0
- package/dist/src/ai-sdk/index.js +9 -0
- package/dist/src/ai-sdk/index.js.map +1 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/index.js +17 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/mcp/index.d.ts +3 -0
- package/dist/src/mcp/index.js +10 -0
- package/dist/src/mcp/index.js.map +1 -0
- package/dist/src/mcp/mcp-resource-and-prompt-tools.d.ts +29 -0
- package/dist/src/mcp/mcp-resource-and-prompt-tools.js +185 -0
- package/dist/src/mcp/mcp-resource-and-prompt-tools.js.map +1 -0
- package/dist/src/mcp/mcp-server-config.d.ts +86 -0
- package/dist/src/mcp/mcp-server-config.js +38 -0
- package/dist/src/mcp/mcp-server-config.js.map +1 -0
- package/dist/src/mcp/mcp-tool-source.d.ts +470 -0
- package/dist/src/mcp/mcp-tool-source.js +1204 -0
- package/dist/src/mcp/mcp-tool-source.js.map +1 -0
- package/dist/src/stepwise/agent-definition.d.ts +158 -0
- package/dist/src/stepwise/agent-definition.js +9 -0
- package/dist/src/stepwise/agent-definition.js.map +1 -0
- package/dist/src/stepwise/function-tool.d.ts +130 -0
- package/dist/src/stepwise/function-tool.js +75 -0
- package/dist/src/stepwise/function-tool.js.map +1 -0
- package/dist/src/stepwise/index.d.ts +7 -0
- package/dist/src/stepwise/index.js +12 -0
- package/dist/src/stepwise/index.js.map +1 -0
- package/dist/src/stepwise/json-schema-validation.d.ts +9 -0
- package/dist/src/stepwise/json-schema-validation.js +141 -0
- package/dist/src/stepwise/json-schema-validation.js.map +1 -0
- package/dist/src/stepwise/model-client.d.ts +194 -0
- package/dist/src/stepwise/model-client.js +9 -0
- package/dist/src/stepwise/model-client.js.map +1 -0
- package/dist/src/stepwise/scripted-model-client.d.ts +99 -0
- package/dist/src/stepwise/scripted-model-client.js +156 -0
- package/dist/src/stepwise/scripted-model-client.js.map +1 -0
- package/dist/src/stepwise/stepwise-agent-runner.d.ts +189 -0
- package/dist/src/stepwise/stepwise-agent-runner.js +804 -0
- package/dist/src/stepwise/stepwise-agent-runner.js.map +1 -0
- package/dist/src/stepwise/stepwise-agent-session-flow.d.ts +35 -0
- package/dist/src/stepwise/stepwise-agent-session-flow.js +56 -0
- package/dist/src/stepwise/stepwise-agent-session-flow.js.map +1 -0
- package/dist/src/stepwise/stepwise-input-items.d.ts +12 -0
- package/dist/src/stepwise/stepwise-input-items.js +172 -0
- package/dist/src/stepwise/stepwise-input-items.js.map +1 -0
- package/dist/src/stepwise/tool-source.d.ts +103 -0
- package/dist/src/stepwise/tool-source.js +9 -0
- package/dist/src/stepwise/tool-source.js.map +1 -0
- package/dist/src/testing/agent-session-test-client.d.ts +205 -0
- package/dist/src/testing/agent-session-test-client.js +290 -0
- package/dist/src/testing/agent-session-test-client.js.map +1 -0
- package/dist/src/testing/agent-test-environment.d.ts +52 -0
- package/dist/src/testing/agent-test-environment.js +86 -0
- package/dist/src/testing/agent-test-environment.js.map +1 -0
- package/dist/src/testing/agent-worker-process.d.ts +91 -0
- package/dist/src/testing/agent-worker-process.js +150 -0
- package/dist/src/testing/agent-worker-process.js.map +1 -0
- package/dist/src/testing/child-process-group.d.ts +33 -0
- package/dist/src/testing/child-process-group.js +164 -0
- package/dist/src/testing/child-process-group.js.map +1 -0
- package/dist/src/testing/coordination.d.ts +99 -0
- package/dist/src/testing/coordination.js +155 -0
- package/dist/src/testing/coordination.js.map +1 -0
- package/dist/src/testing/index.d.ts +8 -0
- package/dist/src/testing/index.js +16 -0
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/testing/polling.d.ts +31 -0
- package/dist/src/testing/polling.js +51 -0
- package/dist/src/testing/polling.js.map +1 -0
- package/dist/src/testing/private-dex-engine.d.ts +101 -0
- package/dist/src/testing/private-dex-engine.js +223 -0
- package/dist/src/testing/private-dex-engine.js.map +1 -0
- package/dist/src/testing/scripted-model-client.d.ts +1 -0
- package/dist/src/testing/scripted-model-client.js +10 -0
- package/dist/src/testing/scripted-model-client.js.map +1 -0
- package/dist/src/testing/step-history.d.ts +40 -0
- package/dist/src/testing/step-history.js +59 -0
- package/dist/src/testing/step-history.js.map +1 -0
- package/dist/src/ui-stream/agent-event-json.d.ts +30 -0
- package/dist/src/ui-stream/agent-event-json.js +64 -0
- package/dist/src/ui-stream/agent-event-json.js.map +1 -0
- package/dist/src/ui-stream/agent-event-sse.d.ts +154 -0
- package/dist/src/ui-stream/agent-event-sse.js +159 -0
- package/dist/src/ui-stream/agent-event-sse.js.map +1 -0
- package/dist/src/ui-stream/agent-event-stream-positions.d.ts +42 -0
- package/dist/src/ui-stream/agent-event-stream-positions.js +153 -0
- package/dist/src/ui-stream/agent-event-stream-positions.js.map +1 -0
- package/dist/src/ui-stream/agent-session-record-reader.d.ts +72 -0
- package/dist/src/ui-stream/agent-session-record-reader.js +241 -0
- package/dist/src/ui-stream/agent-session-record-reader.js.map +1 -0
- package/dist/src/ui-stream/agent-ui-message-stream-responses.d.ts +219 -0
- package/dist/src/ui-stream/agent-ui-message-stream-responses.js +440 -0
- package/dist/src/ui-stream/agent-ui-message-stream-responses.js.map +1 -0
- package/dist/src/ui-stream/agent-ui-message-stream.d.ts +138 -0
- package/dist/src/ui-stream/agent-ui-message-stream.js +681 -0
- package/dist/src/ui-stream/agent-ui-message-stream.js.map +1 -0
- package/dist/src/ui-stream/agent-ui-message-types.d.ts +238 -0
- package/dist/src/ui-stream/agent-ui-message-types.js +57 -0
- package/dist/src/ui-stream/agent-ui-message-types.js.map +1 -0
- package/dist/src/ui-stream/agent-ui-messages.d.ts +66 -0
- package/dist/src/ui-stream/agent-ui-messages.js +220 -0
- package/dist/src/ui-stream/agent-ui-messages.js.map +1 -0
- package/dist/src/ui-stream/agent-ui-stream-cursor.d.ts +64 -0
- package/dist/src/ui-stream/agent-ui-stream-cursor.js +186 -0
- package/dist/src/ui-stream/agent-ui-stream-cursor.js.map +1 -0
- package/dist/src/ui-stream/index.d.ts +14 -0
- package/dist/src/ui-stream/index.js +22 -0
- package/dist/src/ui-stream/index.js.map +1 -0
- package/dist/src/ui-stream/server-sent-event-responses.d.ts +6 -0
- package/dist/src/ui-stream/server-sent-event-responses.js +34 -0
- package/dist/src/ui-stream/server-sent-event-responses.js.map +1 -0
- package/package.json +86 -4
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type AgentToolCallRecord } from "../agent-session-values.js";
|
|
2
|
+
/**
|
|
3
|
+
* What the browser already shows of one tool call in the current model call.
|
|
4
|
+
*
|
|
5
|
+
* - `input`: the tool part exists; no approval was requested.
|
|
6
|
+
* - `approval_requested`: the part waits for `resolve_interrupt`.
|
|
7
|
+
* - `approval_resolved`: the session accepted the approval or rejection.
|
|
8
|
+
* - `finished`: the part shows the call's result.
|
|
9
|
+
*/
|
|
10
|
+
export type ToolCallUIState = "input" | "approval_requested" | "approval_resolved" | "finished";
|
|
11
|
+
/** The `RunModel` Step execution whose parts the browser shows last. */
|
|
12
|
+
export interface ModelStepPosition {
|
|
13
|
+
readonly stepExecutionId: string;
|
|
14
|
+
attempt: number;
|
|
15
|
+
openedPartCount: number;
|
|
16
|
+
isUsageRecorded: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** A text or reasoning part that the browser keeps open for further deltas. */
|
|
19
|
+
export interface OpenUIPart {
|
|
20
|
+
readonly kind: "text" | "reasoning";
|
|
21
|
+
readonly id: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Everything a stateless server needs to continue a UI message stream exactly where a browser left it:
|
|
25
|
+
* the Dex resume token plus the parts the browser has open.
|
|
26
|
+
*/
|
|
27
|
+
export interface AgentUIStreamCursor {
|
|
28
|
+
/** Dex resume token of the last event whose parts the browser holds, or `""` for the retained head. */
|
|
29
|
+
eventResumeToken: string;
|
|
30
|
+
/** Parts of the event after `eventResumeToken` that the browser already holds. */
|
|
31
|
+
skippedChunkCount: number;
|
|
32
|
+
turnId: string | null;
|
|
33
|
+
/** While `turnId` is `null`, only a turn with a higher number is followed. */
|
|
34
|
+
afterTurnNumber: number | null;
|
|
35
|
+
/** Dex resume token just before the followed turn's first event, when known. */
|
|
36
|
+
turnStartResumeToken: string | null;
|
|
37
|
+
isMessageStarted: boolean;
|
|
38
|
+
isTurnFinished: boolean;
|
|
39
|
+
modelStep: ModelStepPosition | null;
|
|
40
|
+
openPart: OpenUIPart | null;
|
|
41
|
+
readonly toolCalls: Map<string, ToolCallUIState>;
|
|
42
|
+
}
|
|
43
|
+
/** Maximum length of a UI stream resume token; it must fit an HTTP header. */
|
|
44
|
+
export declare const maximumAgentUIStreamResumeTokenLength: number;
|
|
45
|
+
/** Creates a cursor at one Stream position with nothing shown yet. */
|
|
46
|
+
export declare function createAgentUIStreamCursor(eventResumeToken: string, turnId: string | null, isMessageStarted: boolean): AgentUIStreamCursor;
|
|
47
|
+
/** Returns an independent copy of a cursor. */
|
|
48
|
+
export declare function cloneAgentUIStreamCursor(cursor: AgentUIStreamCursor): AgentUIStreamCursor;
|
|
49
|
+
/** Returns what a browser that rendered these tool call records shows for them. */
|
|
50
|
+
export declare function toolCallUIStateOfRecord(toolCall: AgentToolCallRecord): ToolCallUIState;
|
|
51
|
+
/**
|
|
52
|
+
* Encodes a cursor as the opaque, URL-safe UI stream resume token.
|
|
53
|
+
*
|
|
54
|
+
* Finished tool calls are dropped when the token would exceed the limit; a repeated event for one then
|
|
55
|
+
* repeats an idempotent tool part update.
|
|
56
|
+
* @throws {RangeError} When the token exceeds {@link maximumAgentUIStreamResumeTokenLength} anyway.
|
|
57
|
+
*/
|
|
58
|
+
export declare function encodeAgentUIStreamCursor(cursor: AgentUIStreamCursor): string;
|
|
59
|
+
/**
|
|
60
|
+
* Decodes a UI stream resume token from a browser.
|
|
61
|
+
*
|
|
62
|
+
* @throws {TypeError} When the token was not produced by {@link encodeAgentUIStreamCursor}.
|
|
63
|
+
*/
|
|
64
|
+
export declare function decodeAgentUIStreamCursor(resumeToken: string): AgentUIStreamCursor;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// Copyright (c) 2026 Super Durable, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Sustainable Use License 1.0.
|
|
4
|
+
// You may not use this file except in compliance with the License.
|
|
5
|
+
// See the LICENSE file in the repository root.
|
|
6
|
+
//
|
|
7
|
+
// SPDX-License-Identifier: LicenseRef-Sustainable-Use-1.0
|
|
8
|
+
import { isFinalToolCallStatus } from "../agent-session-values.js";
|
|
9
|
+
/** Maximum length of a UI stream resume token; it must fit an HTTP header. */
|
|
10
|
+
export const maximumAgentUIStreamResumeTokenLength = 64 * 1024;
|
|
11
|
+
const cursorVersion = 2;
|
|
12
|
+
const toolCallUIStates = [
|
|
13
|
+
"input",
|
|
14
|
+
"approval_requested",
|
|
15
|
+
"approval_resolved",
|
|
16
|
+
"finished",
|
|
17
|
+
];
|
|
18
|
+
/** Creates a cursor at one Stream position with nothing shown yet. */
|
|
19
|
+
export function createAgentUIStreamCursor(eventResumeToken, turnId, isMessageStarted) {
|
|
20
|
+
return {
|
|
21
|
+
eventResumeToken,
|
|
22
|
+
skippedChunkCount: 0,
|
|
23
|
+
turnId,
|
|
24
|
+
afterTurnNumber: null,
|
|
25
|
+
turnStartResumeToken: null,
|
|
26
|
+
isMessageStarted,
|
|
27
|
+
isTurnFinished: false,
|
|
28
|
+
modelStep: null,
|
|
29
|
+
openPart: null,
|
|
30
|
+
toolCalls: new Map(),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Returns an independent copy of a cursor. */
|
|
34
|
+
export function cloneAgentUIStreamCursor(cursor) {
|
|
35
|
+
return {
|
|
36
|
+
...cursor,
|
|
37
|
+
modelStep: cursor.modelStep === null ? null : { ...cursor.modelStep },
|
|
38
|
+
toolCalls: new Map(cursor.toolCalls),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** Returns what a browser that rendered these tool call records shows for them. */
|
|
42
|
+
export function toolCallUIStateOfRecord(toolCall) {
|
|
43
|
+
if (isFinalToolCallStatus(toolCall.status)) {
|
|
44
|
+
return "finished";
|
|
45
|
+
}
|
|
46
|
+
if (toolCall.status === "awaiting_approval") {
|
|
47
|
+
return "approval_requested";
|
|
48
|
+
}
|
|
49
|
+
return toolCall.requiresApproval ? "approval_resolved" : "input";
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Encodes a cursor as the opaque, URL-safe UI stream resume token.
|
|
53
|
+
*
|
|
54
|
+
* Finished tool calls are dropped when the token would exceed the limit; a repeated event for one then
|
|
55
|
+
* repeats an idempotent tool part update.
|
|
56
|
+
* @throws {RangeError} When the token exceeds {@link maximumAgentUIStreamResumeTokenLength} anyway.
|
|
57
|
+
*/
|
|
58
|
+
export function encodeAgentUIStreamCursor(cursor) {
|
|
59
|
+
const resumeToken = encodeWireCursor(cursor, [...cursor.toolCalls.entries()]);
|
|
60
|
+
if (resumeToken.length <= maximumAgentUIStreamResumeTokenLength) {
|
|
61
|
+
return resumeToken;
|
|
62
|
+
}
|
|
63
|
+
const openToolCalls = [...cursor.toolCalls.entries()].filter(([, state]) => state !== "finished");
|
|
64
|
+
const compactResumeToken = encodeWireCursor(cursor, openToolCalls);
|
|
65
|
+
if (compactResumeToken.length > maximumAgentUIStreamResumeTokenLength) {
|
|
66
|
+
throw new RangeError(`the agent UI stream resume token exceeds ${maximumAgentUIStreamResumeTokenLength} characters`);
|
|
67
|
+
}
|
|
68
|
+
return compactResumeToken;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Decodes a UI stream resume token from a browser.
|
|
72
|
+
*
|
|
73
|
+
* @throws {TypeError} When the token was not produced by {@link encodeAgentUIStreamCursor}.
|
|
74
|
+
*/
|
|
75
|
+
export function decodeAgentUIStreamCursor(resumeToken) {
|
|
76
|
+
if (resumeToken.length === 0 || resumeToken.length > maximumAgentUIStreamResumeTokenLength) {
|
|
77
|
+
throw invalidResumeToken();
|
|
78
|
+
}
|
|
79
|
+
let wireCursor;
|
|
80
|
+
try {
|
|
81
|
+
wireCursor = JSON.parse(Buffer.from(resumeToken, "base64url").toString("utf8"));
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
throw invalidResumeToken();
|
|
85
|
+
}
|
|
86
|
+
if (!isRecord(wireCursor) || wireCursor["v"] !== cursorVersion) {
|
|
87
|
+
throw invalidResumeToken();
|
|
88
|
+
}
|
|
89
|
+
const { e: eventResumeToken, k: skippedChunkCount, t: turnId, a: afterTurnNumber, b: turnStartResumeToken, s: isMessageStarted, f: isTurnFinished, } = wireCursor;
|
|
90
|
+
if (typeof eventResumeToken !== "string" ||
|
|
91
|
+
!isNonNegativeInteger(skippedChunkCount) ||
|
|
92
|
+
(turnId !== null && typeof turnId !== "string") ||
|
|
93
|
+
(afterTurnNumber !== null && !isNonNegativeInteger(afterTurnNumber)) ||
|
|
94
|
+
(turnStartResumeToken !== null && typeof turnStartResumeToken !== "string") ||
|
|
95
|
+
typeof isMessageStarted !== "boolean" ||
|
|
96
|
+
typeof isTurnFinished !== "boolean") {
|
|
97
|
+
throw invalidResumeToken();
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
eventResumeToken,
|
|
101
|
+
skippedChunkCount,
|
|
102
|
+
turnId,
|
|
103
|
+
afterTurnNumber,
|
|
104
|
+
turnStartResumeToken,
|
|
105
|
+
isMessageStarted,
|
|
106
|
+
isTurnFinished,
|
|
107
|
+
modelStep: decodeModelStep(wireCursor["m"]),
|
|
108
|
+
openPart: decodeOpenPart(wireCursor["o"]),
|
|
109
|
+
toolCalls: decodeToolCalls(wireCursor["c"]),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function encodeWireCursor(cursor, toolCalls) {
|
|
113
|
+
const modelStep = cursor.modelStep;
|
|
114
|
+
const wireCursor = {
|
|
115
|
+
v: cursorVersion,
|
|
116
|
+
e: cursor.eventResumeToken,
|
|
117
|
+
k: cursor.skippedChunkCount,
|
|
118
|
+
t: cursor.turnId,
|
|
119
|
+
a: cursor.afterTurnNumber,
|
|
120
|
+
b: cursor.turnStartResumeToken,
|
|
121
|
+
s: cursor.isMessageStarted,
|
|
122
|
+
f: cursor.isTurnFinished,
|
|
123
|
+
m: modelStep === null
|
|
124
|
+
? null
|
|
125
|
+
: [modelStep.stepExecutionId, modelStep.attempt, modelStep.openedPartCount, modelStep.isUsageRecorded],
|
|
126
|
+
o: cursor.openPart === null ? null : [cursor.openPart.kind, cursor.openPart.id],
|
|
127
|
+
c: toolCalls,
|
|
128
|
+
};
|
|
129
|
+
return Buffer.from(JSON.stringify(wireCursor), "utf8").toString("base64url");
|
|
130
|
+
}
|
|
131
|
+
function decodeModelStep(value) {
|
|
132
|
+
if (value === null) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
if (!Array.isArray(value) || value.length !== 4) {
|
|
136
|
+
throw invalidResumeToken();
|
|
137
|
+
}
|
|
138
|
+
const [stepExecutionId, attempt, openedPartCount, isUsageRecorded] = value;
|
|
139
|
+
if (typeof stepExecutionId !== "string" ||
|
|
140
|
+
!isNonNegativeInteger(attempt) ||
|
|
141
|
+
!isNonNegativeInteger(openedPartCount) ||
|
|
142
|
+
typeof isUsageRecorded !== "boolean") {
|
|
143
|
+
throw invalidResumeToken();
|
|
144
|
+
}
|
|
145
|
+
return { stepExecutionId, attempt, openedPartCount, isUsageRecorded };
|
|
146
|
+
}
|
|
147
|
+
function decodeOpenPart(value) {
|
|
148
|
+
if (value === null) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
if (!Array.isArray(value) || value.length !== 2) {
|
|
152
|
+
throw invalidResumeToken();
|
|
153
|
+
}
|
|
154
|
+
const [kind, id] = value;
|
|
155
|
+
if ((kind !== "text" && kind !== "reasoning") || typeof id !== "string") {
|
|
156
|
+
throw invalidResumeToken();
|
|
157
|
+
}
|
|
158
|
+
return { kind, id };
|
|
159
|
+
}
|
|
160
|
+
function decodeToolCalls(value) {
|
|
161
|
+
if (!Array.isArray(value)) {
|
|
162
|
+
throw invalidResumeToken();
|
|
163
|
+
}
|
|
164
|
+
const toolCalls = new Map();
|
|
165
|
+
for (const entry of value) {
|
|
166
|
+
if (!Array.isArray(entry) || entry.length !== 2) {
|
|
167
|
+
throw invalidResumeToken();
|
|
168
|
+
}
|
|
169
|
+
const [toolCallId, state] = entry;
|
|
170
|
+
if (typeof toolCallId !== "string" || !toolCallUIStates.includes(state)) {
|
|
171
|
+
throw invalidResumeToken();
|
|
172
|
+
}
|
|
173
|
+
toolCalls.set(toolCallId, state);
|
|
174
|
+
}
|
|
175
|
+
return toolCalls;
|
|
176
|
+
}
|
|
177
|
+
function isRecord(value) {
|
|
178
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
179
|
+
}
|
|
180
|
+
function isNonNegativeInteger(value) {
|
|
181
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
182
|
+
}
|
|
183
|
+
function invalidResumeToken() {
|
|
184
|
+
return new TypeError("the agent UI stream resume token is invalid");
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=agent-ui-stream-cursor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-ui-stream-cursor.js","sourceRoot":"","sources":["../../../src/ui-stream/agent-ui-stream-cursor.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAE1D,OAAO,EAAE,qBAAqB,EAA4B,MAAM,4BAA4B,CAAC;AA+C7F,8EAA8E;AAC9E,MAAM,CAAC,MAAM,qCAAqC,GAAG,EAAE,GAAG,IAAI,CAAC;AAE/D,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,gBAAgB,GAA+B;IACnD,OAAO;IACP,oBAAoB;IACpB,mBAAmB;IACnB,UAAU;CACX,CAAC;AAEF,sEAAsE;AACtE,MAAM,UAAU,yBAAyB,CACvC,gBAAwB,EACxB,MAAqB,EACrB,gBAAyB;IAEzB,OAAO;QACL,gBAAgB;QAChB,iBAAiB,EAAE,CAAC;QACpB,MAAM;QACN,eAAe,EAAE,IAAI;QACrB,oBAAoB,EAAE,IAAI;QAC1B,gBAAgB;QAChB,cAAc,EAAE,KAAK;QACrB,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,IAAI,GAAG,EAAE;KACrB,CAAC;AACJ,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,wBAAwB,CAAC,MAA2B;IAClE,OAAO;QACL,GAAG,MAAM;QACT,SAAS,EAAE,MAAM,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,SAAS,EAAE;QACrE,SAAS,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC;KACrC,CAAC;AACJ,CAAC;AAED,mFAAmF;AACnF,MA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CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAChD,MAAM,kBAAkB,EAAE,CAAC;QAC7B,CAAC;QACD,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,GAAG,KAAkB,CAAC;QAC/C,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,KAAwB,CAAC,EAAE,CAAC;YAC3F,MAAM,kBAAkB,EAAE,CAAC;QAC7B,CAAC;QACD,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,KAAwB,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAc;IAC1C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,kBAAkB;IACzB,OAAO,IAAI,SAAS,CAAC,6CAA6C,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI stream adapters for agent sessions: an AI SDK UI message stream, a plain Server-Sent Events stream,
|
|
3
|
+
* and session snapshots, all read from the session's `AgentEvents` Stream and resumable after a reconnect.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
export { convertAgentEventToJson, convertAgentSnapshotToJson } from "./agent-event-json.js";
|
|
8
|
+
export { agentEventStreamHeaders, convertAgentEventStreamSnapshotToJson, createAgentEventSseResponse, formatAgentEventSseFrame, readAgentEventStreamSnapshot, streamAgentEventSseFrames, type AgentEventSseOptions, type AgentEventStreamSnapshot, type AgentEventStreamSnapshotJson, } from "./agent-event-sse.js";
|
|
9
|
+
export { defaultAgentEventPollTimeoutMs } from "./agent-event-stream-positions.js";
|
|
10
|
+
export { streamAgentUIMessageChunks, type AgentUIMessageStreamOptions, } from "./agent-ui-message-stream.js";
|
|
11
|
+
export { agentResumeTokenHeaderName, createAgentUIMessageStreamResponse, readAgentToolApprovalResponses, resolveAgentToolApproval, resolveAgentToolApprovalsWithUIMessageStream, sendAgentUserMessageWithUIMessageStream, type AgentToolApprovalOptions, type AgentToolApprovalResponse, type AgentToolApprovalsUIStreamOptions, type AgentUIMessageStreamResponseOptions, type AgentUserMessageUIStreamOptions, } from "./agent-ui-message-stream-responses.js";
|
|
12
|
+
export { agentAssistantUIMessageId, agentEventDataPartType, agentResumeTokenDataPartType, agentUIMessageStreamHeaders, agentUserUIMessageId, type AgentDynamicToolUIPart, type AgentEventJson, type AgentUIMessage, type AgentUIMessageChunk, type AgentUIMessageFinishReason, type AgentUIMessagePart, } from "./agent-ui-message-types.js";
|
|
13
|
+
export { convertAgentSnapshotToUIMessages, readAgentSessionUIMessages, type AgentSessionUIMessages, } from "./agent-ui-messages.js";
|
|
14
|
+
export { maximumAgentUIStreamResumeTokenLength } from "./agent-ui-stream-cursor.js";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright (c) 2026 Super Durable, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Sustainable Use License 1.0.
|
|
4
|
+
// You may not use this file except in compliance with the License.
|
|
5
|
+
// See the LICENSE file in the repository root.
|
|
6
|
+
//
|
|
7
|
+
// SPDX-License-Identifier: LicenseRef-Sustainable-Use-1.0
|
|
8
|
+
/**
|
|
9
|
+
* UI stream adapters for agent sessions: an AI SDK UI message stream, a plain Server-Sent Events stream,
|
|
10
|
+
* and session snapshots, all read from the session's `AgentEvents` Stream and resumable after a reconnect.
|
|
11
|
+
*
|
|
12
|
+
* @packageDocumentation
|
|
13
|
+
*/
|
|
14
|
+
export { convertAgentEventToJson, convertAgentSnapshotToJson } from "./agent-event-json.js";
|
|
15
|
+
export { agentEventStreamHeaders, convertAgentEventStreamSnapshotToJson, createAgentEventSseResponse, formatAgentEventSseFrame, readAgentEventStreamSnapshot, streamAgentEventSseFrames, } from "./agent-event-sse.js";
|
|
16
|
+
export { defaultAgentEventPollTimeoutMs } from "./agent-event-stream-positions.js";
|
|
17
|
+
export { streamAgentUIMessageChunks, } from "./agent-ui-message-stream.js";
|
|
18
|
+
export { agentResumeTokenHeaderName, createAgentUIMessageStreamResponse, readAgentToolApprovalResponses, resolveAgentToolApproval, resolveAgentToolApprovalsWithUIMessageStream, sendAgentUserMessageWithUIMessageStream, } from "./agent-ui-message-stream-responses.js";
|
|
19
|
+
export { agentAssistantUIMessageId, agentEventDataPartType, agentResumeTokenDataPartType, agentUIMessageStreamHeaders, agentUserUIMessageId, } from "./agent-ui-message-types.js";
|
|
20
|
+
export { convertAgentSnapshotToUIMessages, readAgentSessionUIMessages, } from "./agent-ui-messages.js";
|
|
21
|
+
export { maximumAgentUIStreamResumeTokenLength } from "./agent-ui-stream-cursor.js";
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui-stream/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAE1D;;;;;GAKG;AAEH,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAC5F,OAAO,EACL,uBAAuB,EACvB,qCAAqC,EACrC,2BAA2B,EAC3B,wBAAwB,EACxB,4BAA4B,EAC5B,yBAAyB,GAI1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AACnF,OAAO,EACL,0BAA0B,GAE3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,0BAA0B,EAC1B,kCAAkC,EAClC,8BAA8B,EAC9B,wBAAwB,EACxB,4CAA4C,EAC5C,uCAAuC,GAMxC,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B,2BAA2B,EAC3B,oBAAoB,GAOrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,gCAAgC,EAChC,0BAA0B,GAE3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,qCAAqC,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** SSE comment sent after an empty long poll; it keeps proxies from closing an idle response. */
|
|
2
|
+
export declare const serverSentEventKeepAliveFrame = ": keep-alive\n\n";
|
|
3
|
+
/** Returns a streaming Response that writes each frame as it is produced and stops the frames on cancel. */
|
|
4
|
+
export declare function createServerSentEventResponse(frames: AsyncGenerator<string, void, undefined>, baseHeaders: Readonly<Record<string, string>>, extraHeaders: Readonly<Record<string, string>> | undefined): Response;
|
|
5
|
+
/** Returns the base headers overridden by the application's headers. */
|
|
6
|
+
export declare function mergeHeaders(baseHeaders: Readonly<Record<string, string>>, extraHeaders: Readonly<Record<string, string>> | undefined): Headers;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Copyright (c) 2026 Super Durable, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Sustainable Use License 1.0.
|
|
4
|
+
// You may not use this file except in compliance with the License.
|
|
5
|
+
// See the LICENSE file in the repository root.
|
|
6
|
+
//
|
|
7
|
+
// SPDX-License-Identifier: LicenseRef-Sustainable-Use-1.0
|
|
8
|
+
/** SSE comment sent after an empty long poll; it keeps proxies from closing an idle response. */
|
|
9
|
+
export const serverSentEventKeepAliveFrame = ": keep-alive\n\n";
|
|
10
|
+
/** Returns a streaming Response that writes each frame as it is produced and stops the frames on cancel. */
|
|
11
|
+
export function createServerSentEventResponse(frames, baseHeaders, extraHeaders) {
|
|
12
|
+
const encoder = new TextEncoder();
|
|
13
|
+
const body = new ReadableStream({
|
|
14
|
+
async pull(controller) {
|
|
15
|
+
const frame = await frames.next();
|
|
16
|
+
if (frame.done === true) {
|
|
17
|
+
controller.close();
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
controller.enqueue(encoder.encode(frame.value));
|
|
21
|
+
},
|
|
22
|
+
async cancel() {
|
|
23
|
+
await frames.return(undefined);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
return new Response(body, { status: 200, headers: mergeHeaders(baseHeaders, extraHeaders) });
|
|
27
|
+
}
|
|
28
|
+
/** Returns the base headers overridden by the application's headers. */
|
|
29
|
+
export function mergeHeaders(baseHeaders, extraHeaders) {
|
|
30
|
+
const headers = new Headers(baseHeaders);
|
|
31
|
+
new Headers(extraHeaders).forEach((value, name) => headers.set(name, value));
|
|
32
|
+
return headers;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=server-sent-event-responses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-sent-event-responses.js","sourceRoot":"","sources":["../../../src/ui-stream/server-sent-event-responses.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAE1D,iGAAiG;AACjG,MAAM,CAAC,MAAM,6BAA6B,GAAG,kBAAkB,CAAC;AAEhE,4GAA4G;AAC5G,MAAM,UAAU,6BAA6B,CAC3C,MAA+C,EAC/C,WAA6C,EAC7C,YAA0D;IAE1D,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAClC,MAAM,IAAI,GAAG,IAAI,cAAc,CAAa;QAC1C,KAAK,CAAC,IAAI,CAAC,UAAU;YACnB,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAClC,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;gBACxB,UAAU,CAAC,KAAK,EAAE,CAAC;gBACnB,OAAO;YACT,CAAC;YACD,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QAClD,CAAC;QACD,KAAK,CAAC,MAAM;YACV,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACjC,CAAC;KACF,CAAC,CAAC;IACH,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY,CAAC,WAAW,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC;AAC/F,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,YAAY,CAC1B,WAA6C,EAC7C,YAA0D;IAE1D,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;IACzC,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IAC7E,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,88 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/dex-agents",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Durable agent sessions for Dex, shared by the Dex TypeScript agent framework adapters",
|
|
5
|
+
"license": "LicenseRef-Sustainable-Use-1.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/superdurable/dex.git",
|
|
9
|
+
"directory": "agents/typescript/core"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/superdurable/dex/tree/main/agents/typescript/core#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/superdurable/dex/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"types": "./dist/src/index.d.ts",
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": "^22.0.0 || ^24.0.0"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist/src",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/src/index.d.ts",
|
|
28
|
+
"import": "./dist/src/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./testing": {
|
|
31
|
+
"types": "./dist/src/testing/index.d.ts",
|
|
32
|
+
"import": "./dist/src/testing/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./mcp": {
|
|
35
|
+
"types": "./dist/src/mcp/index.d.ts",
|
|
36
|
+
"import": "./dist/src/mcp/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./ui-stream": {
|
|
39
|
+
"types": "./dist/src/ui-stream/index.d.ts",
|
|
40
|
+
"import": "./dist/src/ui-stream/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./stepwise": {
|
|
43
|
+
"types": "./dist/src/stepwise/index.d.ts",
|
|
44
|
+
"import": "./dist/src/stepwise/index.js"
|
|
45
|
+
},
|
|
46
|
+
"./ai-sdk": {
|
|
47
|
+
"types": "./dist/src/ai-sdk/index.d.ts",
|
|
48
|
+
"import": "./dist/src/ai-sdk/index.js"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "tsc -p tsconfig.json",
|
|
53
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
54
|
+
"test:integration": "npm run build && node --test --test-concurrency=1 --test-timeout=240000 'dist/test/integ/*.integration.test.js'",
|
|
55
|
+
"test:long": "npm run build && node --test --test-concurrency=1 --test-timeout=1800000 'dist/test/long/*.integration.test.js'"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
59
|
+
"@opentelemetry/api": "^1.3.0",
|
|
60
|
+
"@superdurable/dex": "1.35.0",
|
|
61
|
+
"ai": "^7.0.159"
|
|
62
|
+
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"@modelcontextprotocol/sdk": {
|
|
65
|
+
"optional": true
|
|
66
|
+
},
|
|
67
|
+
"@opentelemetry/api": {
|
|
68
|
+
"optional": true
|
|
69
|
+
},
|
|
70
|
+
"ai": {
|
|
71
|
+
"optional": true
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"@modelcontextprotocol/sdk": "1.32.2",
|
|
76
|
+
"@opentelemetry/api": "1.9.1",
|
|
77
|
+
"@opentelemetry/sdk-trace-base": "2.12.0",
|
|
78
|
+
"@superdurable/dex": "1.35.0",
|
|
79
|
+
"@types/node": "22.20.5",
|
|
80
|
+
"ai": "7.0.159",
|
|
81
|
+
"typescript": "5.9.3",
|
|
82
|
+
"zod": "4.6.7"
|
|
83
|
+
},
|
|
84
|
+
"publishConfig": {
|
|
85
|
+
"access": "public",
|
|
86
|
+
"provenance": true
|
|
87
|
+
}
|
|
88
|
+
}
|