slot-flight 0.1.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 +21 -0
- package/README.md +242 -0
- package/dist/adapters/openai.d.ts +49 -0
- package/dist/adapters/openai.d.ts.map +1 -0
- package/dist/adapters/openai.js +93 -0
- package/dist/adapters/openai.js.map +1 -0
- package/dist/adapters/stream.d.ts +10 -0
- package/dist/adapters/stream.d.ts.map +1 -0
- package/dist/adapters/stream.js +18 -0
- package/dist/adapters/stream.js.map +1 -0
- package/dist/adapters/vercel.d.ts +20 -0
- package/dist/adapters/vercel.d.ts.map +1 -0
- package/dist/adapters/vercel.js +67 -0
- package/dist/adapters/vercel.js.map +1 -0
- package/dist/core.d.ts +4 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +3 -0
- package/dist/core.js.map +1 -0
- package/dist/engine.d.ts +14 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +43 -0
- package/dist/engine.js.map +1 -0
- package/dist/errors.d.ts +23 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +41 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/slot/execution/events.d.ts +15 -0
- package/dist/slot/execution/events.d.ts.map +1 -0
- package/dist/slot/execution/events.js +114 -0
- package/dist/slot/execution/events.js.map +1 -0
- package/dist/slot/execution/failures.d.ts +14 -0
- package/dist/slot/execution/failures.d.ts.map +1 -0
- package/dist/slot/execution/failures.js +71 -0
- package/dist/slot/execution/failures.js.map +1 -0
- package/dist/slot/execution/frame-request.d.ts +13 -0
- package/dist/slot/execution/frame-request.d.ts.map +1 -0
- package/dist/slot/execution/frame-request.js +45 -0
- package/dist/slot/execution/frame-request.js.map +1 -0
- package/dist/slot/execution/index.d.ts +4 -0
- package/dist/slot/execution/index.d.ts.map +1 -0
- package/dist/slot/execution/index.js +30 -0
- package/dist/slot/execution/index.js.map +1 -0
- package/dist/slot/execution/request.d.ts +3 -0
- package/dist/slot/execution/request.d.ts.map +1 -0
- package/dist/slot/execution/request.js +10 -0
- package/dist/slot/execution/request.js.map +1 -0
- package/dist/slot/execution/scope.d.ts +10 -0
- package/dist/slot/execution/scope.d.ts.map +1 -0
- package/dist/slot/execution/scope.js +85 -0
- package/dist/slot/execution/scope.js.map +1 -0
- package/dist/slot/execution/types.d.ts +21 -0
- package/dist/slot/execution/types.d.ts.map +1 -0
- package/dist/slot/execution/types.js +2 -0
- package/dist/slot/execution/types.js.map +1 -0
- package/dist/slot/frame/parser.d.ts +27 -0
- package/dist/slot/frame/parser.d.ts.map +1 -0
- package/dist/slot/frame/parser.js +143 -0
- package/dist/slot/frame/parser.js.map +1 -0
- package/dist/slot/frame/prompt.d.ts +4 -0
- package/dist/slot/frame/prompt.d.ts.map +1 -0
- package/dist/slot/frame/prompt.js +59 -0
- package/dist/slot/frame/prompt.js.map +1 -0
- package/dist/slot/frame/request.d.ts +5 -0
- package/dist/slot/frame/request.d.ts.map +1 -0
- package/dist/slot/frame/request.js +23 -0
- package/dist/slot/frame/request.js.map +1 -0
- package/dist/slot/index.d.ts +9 -0
- package/dist/slot/index.d.ts.map +1 -0
- package/dist/slot/index.js +9 -0
- package/dist/slot/index.js.map +1 -0
- package/dist/slot/object/definition.d.ts +12 -0
- package/dist/slot/object/definition.d.ts.map +1 -0
- package/dist/slot/object/definition.js +53 -0
- package/dist/slot/object/definition.js.map +1 -0
- package/dist/slot/object/projections.d.ts +6 -0
- package/dist/slot/object/projections.d.ts.map +1 -0
- package/dist/slot/object/projections.js +37 -0
- package/dist/slot/object/projections.js.map +1 -0
- package/dist/slot/object/run.d.ts +18 -0
- package/dist/slot/object/run.d.ts.map +1 -0
- package/dist/slot/object/run.js +94 -0
- package/dist/slot/object/run.js.map +1 -0
- package/dist/slot/object/stream.d.ts +34 -0
- package/dist/slot/object/stream.d.ts.map +1 -0
- package/dist/slot/object/stream.js +25 -0
- package/dist/slot/object/stream.js.map +1 -0
- package/dist/slot/object/web.d.ts +5 -0
- package/dist/slot/object/web.d.ts.map +1 -0
- package/dist/slot/object/web.js +107 -0
- package/dist/slot/object/web.js.map +1 -0
- package/dist/slot/path.d.ts +20 -0
- package/dist/slot/path.d.ts.map +1 -0
- package/dist/slot/path.js +125 -0
- package/dist/slot/path.js.map +1 -0
- package/dist/slot/plan.d.ts +7 -0
- package/dist/slot/plan.d.ts.map +1 -0
- package/dist/slot/plan.js +17 -0
- package/dist/slot/plan.js.map +1 -0
- package/dist/types.d.ts +94 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +70 -0
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
export declare class SlotFlightError extends Error {
|
|
3
|
+
}
|
|
4
|
+
export declare class SlotFlightConfigurationError extends SlotFlightError {
|
|
5
|
+
constructor(message: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class SlotFlightValidationError extends SlotFlightError {
|
|
8
|
+
readonly path: string;
|
|
9
|
+
readonly issues: z.ZodIssue[];
|
|
10
|
+
constructor(path: string, issues: z.ZodIssue[]);
|
|
11
|
+
}
|
|
12
|
+
export declare class SlotFlightSlotProtocolError extends SlotFlightError {
|
|
13
|
+
readonly retryable: boolean;
|
|
14
|
+
constructor(message: string, retryable: boolean);
|
|
15
|
+
}
|
|
16
|
+
export declare class SlotFlightJsonParseError extends SlotFlightError {
|
|
17
|
+
readonly path: string;
|
|
18
|
+
constructor(path: string, reason: string);
|
|
19
|
+
}
|
|
20
|
+
export declare class SlotFlightStreamError extends SlotFlightError {
|
|
21
|
+
constructor(message: string);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,qBAAa,eAAgB,SAAQ,KAAK;CAAG;AAE7C,qBAAa,4BAA6B,SAAQ,eAAe;gBACnD,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,yBAA0B,SAAQ,eAAe;IAE1D,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;gBADpB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CAKhC;AAED,qBAAa,2BAA4B,SAAQ,eAAe;IAG5D,QAAQ,CAAC,SAAS,EAAE,OAAO;gBAD3B,OAAO,EAAE,MAAM,EACN,SAAS,EAAE,OAAO;CAK9B;AAED,qBAAa,wBAAyB,SAAQ,eAAe;IAEzD,QAAQ,CAAC,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM;CAKjB;AAED,qBAAa,qBAAsB,SAAQ,eAAe;gBAC5C,OAAO,EAAE,MAAM;CAI5B"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export class SlotFlightError extends Error {
|
|
2
|
+
}
|
|
3
|
+
export class SlotFlightConfigurationError extends SlotFlightError {
|
|
4
|
+
constructor(message) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = "SlotFlightConfigurationError";
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export class SlotFlightValidationError extends SlotFlightError {
|
|
10
|
+
path;
|
|
11
|
+
issues;
|
|
12
|
+
constructor(path, issues) {
|
|
13
|
+
super(`Slot "${path}" failed validation.`);
|
|
14
|
+
this.path = path;
|
|
15
|
+
this.issues = issues;
|
|
16
|
+
this.name = "SlotFlightValidationError";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export class SlotFlightSlotProtocolError extends SlotFlightError {
|
|
20
|
+
retryable;
|
|
21
|
+
constructor(message, retryable) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.retryable = retryable;
|
|
24
|
+
this.name = "SlotFlightSlotProtocolError";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export class SlotFlightJsonParseError extends SlotFlightError {
|
|
28
|
+
path;
|
|
29
|
+
constructor(path, reason) {
|
|
30
|
+
super(`Slot "${path}" did not emit valid JSON: ${reason}`);
|
|
31
|
+
this.path = path;
|
|
32
|
+
this.name = "SlotFlightJsonParseError";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export class SlotFlightStreamError extends SlotFlightError {
|
|
36
|
+
constructor(message) {
|
|
37
|
+
super(message);
|
|
38
|
+
this.name = "SlotFlightStreamError";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,eAAgB,SAAQ,KAAK;CAAG;AAE7C,MAAM,OAAO,4BAA6B,SAAQ,eAAe;IAC/D,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;IAC7C,CAAC;CACF;AAED,MAAM,OAAO,yBAA0B,SAAQ,eAAe;IAEjD;IACA;IAFX,YACW,IAAY,EACZ,MAAoB;QAE7B,KAAK,CAAC,SAAS,IAAI,sBAAsB,CAAC,CAAC;QAHlC,SAAI,GAAJ,IAAI,CAAQ;QACZ,WAAM,GAAN,MAAM,CAAc;QAG7B,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IAC1C,CAAC;CACF;AAED,MAAM,OAAO,2BAA4B,SAAQ,eAAe;IAGnD;IAFX,YACE,OAAe,EACN,SAAkB;QAE3B,KAAK,CAAC,OAAO,CAAC,CAAC;QAFN,cAAS,GAAT,SAAS,CAAS;QAG3B,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;IAC5C,CAAC;CACF;AAED,MAAM,OAAO,wBAAyB,SAAQ,eAAe;IAEhD;IADX,YACW,IAAY,EACrB,MAAc;QAEd,KAAK,CAAC,SAAS,IAAI,8BAA8B,MAAM,EAAE,CAAC,CAAC;QAHlD,SAAI,GAAJ,IAAI,CAAQ;QAIrB,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF;AAED,MAAM,OAAO,qBAAsB,SAAQ,eAAe;IACxD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EACjB,yBAAyB,EACzB,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SlotFrameParser } from "../frame/parser.js";
|
|
2
|
+
import type { CompiledSlot } from "../plan.js";
|
|
3
|
+
import type { PendingFailure, SlotExecutionEvent } from "./types.js";
|
|
4
|
+
export declare function consumeFrameStream({ stream, parser, slots, attempts, state, completed, failures, signal, cloneState }: {
|
|
5
|
+
stream: AsyncIterable<string>;
|
|
6
|
+
parser: SlotFrameParser;
|
|
7
|
+
slots: CompiledSlot[];
|
|
8
|
+
attempts: Map<string, number>;
|
|
9
|
+
state: unknown;
|
|
10
|
+
completed: Set<string>;
|
|
11
|
+
failures: Map<string, PendingFailure>;
|
|
12
|
+
signal: AbortSignal;
|
|
13
|
+
cloneState: <T>(value: T) => T;
|
|
14
|
+
}): AsyncGenerator<SlotExecutionEvent>;
|
|
15
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/slot/execution/events.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAwB,MAAM,oBAAoB,CAAC;AAEhF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErE,wBAAuB,kBAAkB,CAAC,EACxC,MAAM,EACN,MAAM,EACN,KAAK,EACL,QAAQ,EACR,KAAK,EACL,SAAS,EACT,QAAQ,EACR,MAAM,EACN,UAAU,EACX,EAAE;IACD,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC9B,MAAM,EAAE,eAAe,CAAC;IACxB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACtC,MAAM,EAAE,WAAW,CAAC;IACpB,UAAU,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;CAChC,GAAG,cAAc,CAAC,kBAAkB,CAAC,CAiBrC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { SlotFlightJsonParseError, SlotFlightSlotProtocolError, SlotFlightValidationError } from "../../errors.js";
|
|
2
|
+
import { setPathValue } from "../path.js";
|
|
3
|
+
import { abortable, normalizeError } from "./scope.js";
|
|
4
|
+
export async function* consumeFrameStream({ stream, parser, slots, attempts, state, completed, failures, signal, cloneState }) {
|
|
5
|
+
for await (const chunk of abortable(stream, signal)) {
|
|
6
|
+
for (const frameEvent of parser.push(chunk)) {
|
|
7
|
+
const event = handleFrameEvent({
|
|
8
|
+
frameEvent,
|
|
9
|
+
slots,
|
|
10
|
+
attempts,
|
|
11
|
+
state,
|
|
12
|
+
completed,
|
|
13
|
+
failures,
|
|
14
|
+
cloneState
|
|
15
|
+
});
|
|
16
|
+
if (event !== undefined) {
|
|
17
|
+
yield event;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function handleFrameEvent({ frameEvent, slots, attempts, state, completed, failures, cloneState }) {
|
|
23
|
+
if (frameEvent.type === "slot-start") {
|
|
24
|
+
return {
|
|
25
|
+
type: "slot-start",
|
|
26
|
+
slot: frameEvent.slot,
|
|
27
|
+
attempt: attempts.get(frameEvent.slot) ?? 1,
|
|
28
|
+
state: cloneState(state)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
if (frameEvent.type === "slot-delta") {
|
|
32
|
+
// Partial state intentionally contains raw streaming text. The complete
|
|
33
|
+
// event replaces it with the parsed and validated value.
|
|
34
|
+
setPathValue(state, frameEvent.slot, frameEvent.value);
|
|
35
|
+
return {
|
|
36
|
+
type: "slot-delta",
|
|
37
|
+
slot: frameEvent.slot,
|
|
38
|
+
attempt: attempts.get(frameEvent.slot) ?? 1,
|
|
39
|
+
delta: frameEvent.delta,
|
|
40
|
+
value: frameEvent.value,
|
|
41
|
+
state: cloneState(state)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return completeSlotFrame({
|
|
45
|
+
frameEvent,
|
|
46
|
+
slots,
|
|
47
|
+
attempts,
|
|
48
|
+
state,
|
|
49
|
+
completed,
|
|
50
|
+
failures,
|
|
51
|
+
cloneState
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function completeSlotFrame({ frameEvent, slots, attempts, state, completed, failures, cloneState }) {
|
|
55
|
+
const slot = mustFindSlot(slots, frameEvent.slot);
|
|
56
|
+
const attempt = attempts.get(slot.path) ?? 1;
|
|
57
|
+
const parsedValue = parseSlotValue(slot, frameEvent.value);
|
|
58
|
+
if (!parsedValue.success) {
|
|
59
|
+
// The frame arrived, but the value is unusable. Mark it completed for this
|
|
60
|
+
// pass so missing-slot detection does not add a second failure for it.
|
|
61
|
+
failures.set(slot.path, {
|
|
62
|
+
slot,
|
|
63
|
+
attempt,
|
|
64
|
+
error: parsedValue.error,
|
|
65
|
+
retryable: true
|
|
66
|
+
});
|
|
67
|
+
completed.add(slot.path);
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
const validated = slot.definition.schema.safeParse(parsedValue.value);
|
|
71
|
+
if (!validated.success) {
|
|
72
|
+
// Zod failures are slot-local: retry this slot without regenerating slots
|
|
73
|
+
// that already produced validated values.
|
|
74
|
+
failures.set(slot.path, {
|
|
75
|
+
slot,
|
|
76
|
+
attempt,
|
|
77
|
+
error: new SlotFlightValidationError(slot.path, validated.error.issues),
|
|
78
|
+
retryable: true
|
|
79
|
+
});
|
|
80
|
+
completed.add(slot.path);
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
setPathValue(state, slot.path, validated.data);
|
|
84
|
+
completed.add(slot.path);
|
|
85
|
+
return {
|
|
86
|
+
type: "slot-complete",
|
|
87
|
+
slot: slot.path,
|
|
88
|
+
attempt,
|
|
89
|
+
value: validated.data,
|
|
90
|
+
state: cloneState(state)
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function mustFindSlot(slots, path) {
|
|
94
|
+
const slot = slots.find((candidate) => candidate.path === path);
|
|
95
|
+
if (slot === undefined) {
|
|
96
|
+
throw new SlotFlightSlotProtocolError(`Received unregistered slot "${path}".`, false);
|
|
97
|
+
}
|
|
98
|
+
return slot;
|
|
99
|
+
}
|
|
100
|
+
function parseSlotValue(slot, rawValue) {
|
|
101
|
+
if (slot.definition.mode !== "json") {
|
|
102
|
+
return { success: true, value: rawValue };
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
return { success: true, value: JSON.parse(rawValue) };
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
return {
|
|
109
|
+
success: false,
|
|
110
|
+
error: new SlotFlightJsonParseError(slot.path, normalizeError(error).message)
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/slot/execution/events.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,yBAAyB,EAC1B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGvD,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,kBAAkB,CAAC,EACxC,MAAM,EACN,MAAM,EACN,KAAK,EACL,QAAQ,EACR,KAAK,EACL,SAAS,EACT,QAAQ,EACR,MAAM,EACN,UAAU,EAWX;IACC,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;QACpD,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5C,MAAM,KAAK,GAAG,gBAAgB,CAAC;gBAC7B,UAAU;gBACV,KAAK;gBACL,QAAQ;gBACR,KAAK;gBACL,SAAS;gBACT,QAAQ;gBACR,UAAU;aACX,CAAC,CAAC;YACH,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,MAAM,KAAK,CAAC;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AK,EAAE,UAAU,CAAC,KAAK,CAAC;KACzB,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,KAAqB,EAAE,IAAY;IACvD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAChE,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,MAAM,IAAI,2BAA2B,CACnC,+BAA+B,IAAI,IAAI,EACvC,KAAK,CACN,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,cAAc,CACrB,IAAkB,EAClB,QAAgB;IAEhB,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAC5C,CAAC;IAED,IAAI,CAAC;QACH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;IACxD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,IAAI,wBAAwB,CACjC,IAAI,CAAC,IAAI,EACT,cAAc,CAAC,KAAK,CAAC,CAAC,OAAO,CAC9B;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CompiledSlot } from "../plan.js";
|
|
2
|
+
import type { PendingFailure, SlotExecutionEvent } from "./types.js";
|
|
3
|
+
export declare function recordMissingSlots(slots: CompiledSlot[], completed: ReadonlySet<string>, failures: Map<string, PendingFailure>, attempts: ReadonlyMap<string, number>): void;
|
|
4
|
+
export declare function recordFrameFailure(slots: CompiledSlot[], completed: ReadonlySet<string>, failures: Map<string, PendingFailure>, attempts: ReadonlyMap<string, number>, error: Error, retryable: boolean): void;
|
|
5
|
+
export declare function nextPendingSlots({ failures, remaining, attempts, maxRetries, state, cloneState }: {
|
|
6
|
+
failures: Map<string, PendingFailure>;
|
|
7
|
+
remaining: CompiledSlot[];
|
|
8
|
+
attempts: Map<string, number>;
|
|
9
|
+
maxRetries: number;
|
|
10
|
+
state: unknown;
|
|
11
|
+
cloneState: <T>(value: T) => T;
|
|
12
|
+
}): AsyncGenerator<SlotExecutionEvent, CompiledSlot[]>;
|
|
13
|
+
export declare function frameSlotErrors(slots: CompiledSlot[], attempts: ReadonlyMap<string, number>, error: Error, state: unknown, cloneState: <T>(value: T) => T): AsyncGenerator<SlotExecutionEvent>;
|
|
14
|
+
//# sourceMappingURL=failures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"failures.d.ts","sourceRoot":"","sources":["../../../src/slot/execution/failures.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErE,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,YAAY,EAAE,EACrB,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,EAC9B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,EACrC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,IAAI,CAgBN;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,YAAY,EAAE,EACrB,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,EAC9B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,EACrC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EACrC,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,OAAO,GACjB,IAAI,CAWN;AAED,wBAAuB,gBAAgB,CAAC,EACtC,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,UAAU,EACV,KAAK,EACL,UAAU,EACX,EAAE;IACD,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACtC,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;CAChC,GAAG,cAAc,CAAC,kBAAkB,EAAE,YAAY,EAAE,CAAC,CAkCrD;AAED,wBAAuB,eAAe,CACpC,KAAK,EAAE,YAAY,EAAE,EACrB,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EACrC,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,OAAO,EACd,UAAU,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,GAC7B,cAAc,CAAC,kBAAkB,CAAC,CAUpC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { SlotFlightSlotProtocolError } from "../../errors.js";
|
|
2
|
+
export function recordMissingSlots(slots, completed, failures, attempts) {
|
|
3
|
+
// Missing frames are slot failures, not whole-run failures. This keeps retry
|
|
4
|
+
// scoped to the smallest unit the engine can safely regenerate.
|
|
5
|
+
for (const slot of slots) {
|
|
6
|
+
if (!completed.has(slot.path) && !failures.has(slot.path)) {
|
|
7
|
+
failures.set(slot.path, {
|
|
8
|
+
slot,
|
|
9
|
+
attempt: attempts.get(slot.path) ?? 1,
|
|
10
|
+
error: new SlotFlightSlotProtocolError(`Slot "${slot.path}" was not emitted by the stream.`, true),
|
|
11
|
+
retryable: true
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function recordFrameFailure(slots, completed, failures, attempts, error, retryable) {
|
|
17
|
+
for (const slot of slots) {
|
|
18
|
+
if (!completed.has(slot.path) && !failures.has(slot.path)) {
|
|
19
|
+
failures.set(slot.path, {
|
|
20
|
+
slot,
|
|
21
|
+
attempt: attempts.get(slot.path) ?? 1,
|
|
22
|
+
error,
|
|
23
|
+
retryable
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export async function* nextPendingSlots({ failures, remaining, attempts, maxRetries, state, cloneState }) {
|
|
29
|
+
if (failures.size === 0) {
|
|
30
|
+
return remaining;
|
|
31
|
+
}
|
|
32
|
+
const retrySlots = [];
|
|
33
|
+
for (const failure of failures.values()) {
|
|
34
|
+
const maxAttempts = (failure.slot.definition.maxRetries ?? maxRetries) + 1;
|
|
35
|
+
if (failure.retryable && failure.attempt < maxAttempts) {
|
|
36
|
+
yield {
|
|
37
|
+
type: "slot-retry",
|
|
38
|
+
slot: failure.slot.path,
|
|
39
|
+
attempt: failure.attempt,
|
|
40
|
+
error: failure.error,
|
|
41
|
+
state: cloneState(state)
|
|
42
|
+
};
|
|
43
|
+
attempts.set(failure.slot.path, failure.attempt + 1);
|
|
44
|
+
retrySlots.push(failure.slot);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
yield {
|
|
48
|
+
type: "slot-error",
|
|
49
|
+
slot: failure.slot.path,
|
|
50
|
+
attempt: failure.attempt,
|
|
51
|
+
error: failure.error,
|
|
52
|
+
state: cloneState(state)
|
|
53
|
+
};
|
|
54
|
+
throw failure.error;
|
|
55
|
+
}
|
|
56
|
+
// Retry failed slots before moving on so partial state progresses in the same
|
|
57
|
+
// order callers requested, while already validated slots are not regenerated.
|
|
58
|
+
return [...retrySlots, ...remaining];
|
|
59
|
+
}
|
|
60
|
+
export async function* frameSlotErrors(slots, attempts, error, state, cloneState) {
|
|
61
|
+
for (const slot of slots) {
|
|
62
|
+
yield {
|
|
63
|
+
type: "slot-error",
|
|
64
|
+
slot: slot.path,
|
|
65
|
+
attempt: attempts.get(slot.path) ?? 1,
|
|
66
|
+
error,
|
|
67
|
+
state: cloneState(state)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=failures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"failures.js","sourceRoot":"","sources":["../../../src/slot/execution/failures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAI9D,MAAM,UAAU,kBAAkB,CAChC,KAAqB,EACrB,SAA8B,EAC9B,QAAqC,EACrC,QAAqC;IAErC,6EAA6E;IAC7E,gEAAgE;IAChE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1D,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE;gBACtB,IAAI;gBACJ,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;gBACrC,KAAK,EAAE,IAAI,2BAA2B,CACpC,SAAS,IAAI,CAAC,IAAI,kCAAkC,EACpD,IAAI,CACL;gBACD,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,KAAqB,EACrB,SAA8B,EAC9B,QAAqC,EACrC,QAAqC,EACrC,KAAY,EACZ,SAAkB;IAElB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1D,QAAQ,CAAC,GAAG,CAAC,I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ACxB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC;SACzB,CAAC;QACF,MAAM,OAAO,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,8EAA8E;IAC9E,8EAA8E;IAC9E,OAAO,CAAC,GAAG,UAAU,EAAE,GAAG,SAAS,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,eAAe,CACpC,KAAqB,EACrB,QAAqC,EACrC,KAAY,EACZ,KAAc,EACd,UAA8B;IAE9B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM;YACJ,IAAI,EAAE,YAAY;YAClB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;YACrC,KAAK;YACL,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC;SACzB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SlotFlightPrompt, SlotGenerator } from "../../types.js";
|
|
2
|
+
import type { CompiledSlot } from "../plan.js";
|
|
3
|
+
import type { PendingFailure, SlotExecutionEvent } from "./types.js";
|
|
4
|
+
export declare function runFrameRequest({ slots, attempts, state, generate, prompt, signal, cloneState }: {
|
|
5
|
+
slots: CompiledSlot[];
|
|
6
|
+
attempts: Map<string, number>;
|
|
7
|
+
state: unknown;
|
|
8
|
+
generate: SlotGenerator;
|
|
9
|
+
prompt?: SlotFlightPrompt;
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
cloneState: <T>(value: T) => T;
|
|
12
|
+
}): AsyncGenerator<SlotExecutionEvent, Map<string, PendingFailure>>;
|
|
13
|
+
//# sourceMappingURL=frame-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame-request.d.ts","sourceRoot":"","sources":["../../../src/slot/execution/frame-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAc/C,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErE,wBAAuB,eAAe,CAAC,EACrC,KAAK,EACL,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,MAAM,EACN,MAAM,EACN,UAAU,EACX,EAAE;IACD,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,UAAU,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;CAChC,GAAG,cAAc,CAAC,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAqDlE"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { SlotFrameParser } from "../frame/parser.js";
|
|
2
|
+
import { createSlotFrameRequests } from "../frame/request.js";
|
|
3
|
+
import { consumeFrameStream } from "./events.js";
|
|
4
|
+
import { frameSlotErrors, recordFrameFailure, recordMissingSlots } from "./failures.js";
|
|
5
|
+
import { createSlotFlightRequest } from "./request.js";
|
|
6
|
+
import { createRequestScope, isAbortError, isRetryableSlotProtocolError, normalizeError } from "./scope.js";
|
|
7
|
+
export async function* runFrameRequest({ slots, attempts, state, generate, prompt, signal, cloneState }) {
|
|
8
|
+
const requestScope = createRequestScope(signal);
|
|
9
|
+
const frameRequests = createSlotFrameRequests(slots, attempts);
|
|
10
|
+
const request = createSlotFlightRequest(frameRequests, prompt, requestScope.signal);
|
|
11
|
+
const completed = new Set();
|
|
12
|
+
const failures = new Map();
|
|
13
|
+
try {
|
|
14
|
+
const stream = await generate(request);
|
|
15
|
+
const parser = new SlotFrameParser(new Map(frameRequests.map((slot) => [slot.id, slot.path])));
|
|
16
|
+
yield* consumeFrameStream({
|
|
17
|
+
stream,
|
|
18
|
+
parser,
|
|
19
|
+
slots,
|
|
20
|
+
attempts,
|
|
21
|
+
state,
|
|
22
|
+
completed,
|
|
23
|
+
failures,
|
|
24
|
+
signal: request.signal,
|
|
25
|
+
cloneState
|
|
26
|
+
});
|
|
27
|
+
parser.finish();
|
|
28
|
+
recordMissingSlots(slots, completed, failures, attempts);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
const normalized = normalizeError(error);
|
|
32
|
+
if (isAbortError(normalized, signal)) {
|
|
33
|
+
yield* frameSlotErrors(slots, attempts, normalized, state, cloneState);
|
|
34
|
+
throw normalized;
|
|
35
|
+
}
|
|
36
|
+
// Provider/runtime failures are recorded for incomplete slots but are not
|
|
37
|
+
// retried unless the parser can prove this was a recoverable protocol miss.
|
|
38
|
+
recordFrameFailure(slots, completed, failures, attempts, normalized, isRetryableSlotProtocolError(normalized));
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
requestScope.cleanup();
|
|
42
|
+
}
|
|
43
|
+
return failures;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=frame-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame-request.js","sourceRoot":"","sources":["../../../src/slot/execution/frame-request.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAA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C,CAAC;QACzC,IAAI,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,CAAC;YACrC,KAAK,CAAC,CAAC,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;YACvE,MAAM,UAAU,CAAC;QACnB,CAAC;QAED,0EAA0E;QAC1E,4EAA4E;QAC5E,kBAAkB,CAChB,KAAK,EACL,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,4BAA4B,CAAC,UAAU,CAAC,CACzC,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SlotExecutionEvent, SlotExecutionOptions } from "./types.js";
|
|
2
|
+
export type { SlotExecutionOptions } from "./types.js";
|
|
3
|
+
export declare function runSlotFrameStream({ slots, state, generate, prompt, maxRetries, signal, cloneState }: SlotExecutionOptions): AsyncGenerator<SlotExecutionEvent, void>;
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/slot/execution/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE3E,YAAY,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,wBAAuB,kBAAkB,CAAC,EACxC,KAAK,EACL,KAAK,EACL,QAAQ,EACR,MAAM,EACN,UAAU,EACV,MAAM,EACN,UAAU,EACX,EAAE,oBAAoB,GAAG,cAAc,CAAC,kBAAkB,EAAE,IAAI,CAAC,CA4BjE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { nextPendingSlots } from "./failures.js";
|
|
2
|
+
import { runFrameRequest } from "./frame-request.js";
|
|
3
|
+
import { throwIfAborted } from "./scope.js";
|
|
4
|
+
export async function* runSlotFrameStream({ slots, state, generate, prompt, maxRetries, signal, cloneState }) {
|
|
5
|
+
const attempts = new Map(slots.map((slot) => [slot.path, 1]));
|
|
6
|
+
let pending = [...slots];
|
|
7
|
+
while (pending.length > 0) {
|
|
8
|
+
throwIfAborted(signal);
|
|
9
|
+
// Each pass asks for every currently pending slot in one frame stream.
|
|
10
|
+
// Completed slots drop out; only retryable failures come back as pending.
|
|
11
|
+
const failures = yield* runFrameRequest({
|
|
12
|
+
slots: pending,
|
|
13
|
+
attempts,
|
|
14
|
+
state,
|
|
15
|
+
generate,
|
|
16
|
+
prompt,
|
|
17
|
+
signal,
|
|
18
|
+
cloneState
|
|
19
|
+
});
|
|
20
|
+
pending = yield* nextPendingSlots({
|
|
21
|
+
failures,
|
|
22
|
+
remaining: [],
|
|
23
|
+
attempts,
|
|
24
|
+
maxRetries,
|
|
25
|
+
state,
|
|
26
|
+
cloneState
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/slot/execution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAK5C,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,kBAAkB,CAAC,EACxC,KAAK,EACL,KAAK,EACL,QAAQ,EACR,MAAM,EACN,UAAU,EACV,MAAM,EACN,UAAU,EACW;IACrB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,IAAI,OAAO,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC;IAEzB,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,cAAc,CAAC,MAAM,CAAC,CAAC;QAEvB,uEAAuE;QACvE,0EAA0E;QAC1E,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,eAAe,CAAC;YACtC,KAAK,EAAE,OAAO;YACd,QAAQ;YACR,KAAK;YACL,QAAQ;YACR,MAAM;YACN,MAAM;YACN,UAAU;SACX,CAAC,CAAC;QAEH,OAAO,GAAG,KAAK,CAAC,CAAC,gBAAgB,CAAC;YAChC,QAAQ;YACR,SAAS,EAAE,EAAE;YACb,QAAQ;YACR,UAAU;YACV,KAAK;YACL,UAAU;SACX,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { SlotFlightPrompt, SlotFlightRequest } from "../../types.js";
|
|
2
|
+
export declare function createSlotFlightRequest(frameRequests: SlotFlightRequest["slots"], prompt: SlotFlightPrompt | undefined, signal: AbortSignal): SlotFlightRequest;
|
|
3
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/slot/execution/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAG1E,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,iBAAiB,CAAC,OAAO,CAAC,EACzC,MAAM,EAAE,gBAAgB,GAAG,SAAS,EACpC,MAAM,EAAE,WAAW,GAClB,iBAAiB,CAOnB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createSlotFramePrompt } from "../frame/prompt.js";
|
|
2
|
+
export function createSlotFlightRequest(frameRequests, prompt, signal) {
|
|
3
|
+
return {
|
|
4
|
+
prompt: createSlotFramePrompt(frameRequests, prompt),
|
|
5
|
+
slots: frameRequests,
|
|
6
|
+
attempt: Math.max(...frameRequests.map((slot) => slot.attempt)),
|
|
7
|
+
signal
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../src/slot/execution/request.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,UAAU,uBAAuB,CACrC,aAAyC,EACzC,MAAoC,EACpC,MAAmB;IAEnB,OAAO;QACL,MAAM,EAAE,qBAAqB,CAAC,aAAa,EAAE,MAAM,CAAC;QACpD,KAAK,EAAE,aAAa;QACpB,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/D,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function createRequestScope(parentSignal: AbortSignal | undefined): {
|
|
2
|
+
signal: AbortSignal;
|
|
3
|
+
cleanup: () => void;
|
|
4
|
+
};
|
|
5
|
+
export declare function abortable<T>(stream: AsyncIterable<T>, signal: AbortSignal): AsyncGenerator<T>;
|
|
6
|
+
export declare function throwIfAborted(signal: AbortSignal | undefined): void;
|
|
7
|
+
export declare function normalizeError(error: unknown): Error;
|
|
8
|
+
export declare function isAbortError(error: Error, parentSignal: AbortSignal | undefined): boolean;
|
|
9
|
+
export declare function isRetryableSlotProtocolError(error: Error): boolean;
|
|
10
|
+
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../../src/slot/execution/scope.ts"],"names":[],"mappings":"AAEA,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,WAAW,GAAG,SAAS,GAAG;IACzE,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAUA;AAED,wBAAuB,SAAS,CAAC,CAAC,EAChC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,EACxB,MAAM,EAAE,WAAW,GAClB,cAAc,CAAC,CAAC,CAAC,CAyBnB;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,IAAI,CAIpE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAMpD;AAED,wBAAgB,YAAY,CAC1B,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,WAAW,GAAG,SAAS,GACpC,OAAO,CAET;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAElE"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { SlotFlightSlotProtocolError } from "../../errors.js";
|
|
2
|
+
export function createRequestScope(parentSignal) {
|
|
3
|
+
// One signal controls the provider request, parser consumption, and caller
|
|
4
|
+
// cancellation for a single frame stream.
|
|
5
|
+
const controller = new AbortController();
|
|
6
|
+
const cleanupAbort = linkAbortSignal(parentSignal, controller);
|
|
7
|
+
return {
|
|
8
|
+
signal: controller.signal,
|
|
9
|
+
cleanup: cleanupAbort
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export async function* abortable(stream, signal) {
|
|
13
|
+
const iterator = stream[Symbol.asyncIterator]();
|
|
14
|
+
const abort = createAbortPromise(signal);
|
|
15
|
+
let completed = false;
|
|
16
|
+
try {
|
|
17
|
+
while (true) {
|
|
18
|
+
const next = await Promise.race([iterator.next(), abort.promise]);
|
|
19
|
+
throwIfAborted(signal);
|
|
20
|
+
if (next.done) {
|
|
21
|
+
completed = true;
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
yield next.value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
if (!completed) {
|
|
29
|
+
// Give SDK streams a chance to release sockets/readers when cancellation
|
|
30
|
+
// interrupts a frame stream mid-iteration.
|
|
31
|
+
await iterator.return?.();
|
|
32
|
+
}
|
|
33
|
+
abort.cleanup();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function throwIfAborted(signal) {
|
|
37
|
+
if (signal?.aborted) {
|
|
38
|
+
throw signal.reason ?? new DOMException("Aborted", "AbortError");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export function normalizeError(error) {
|
|
42
|
+
if (error instanceof Error) {
|
|
43
|
+
return error;
|
|
44
|
+
}
|
|
45
|
+
return new Error(String(error));
|
|
46
|
+
}
|
|
47
|
+
export function isAbortError(error, parentSignal) {
|
|
48
|
+
return parentSignal?.aborted === true || error.name === "AbortError";
|
|
49
|
+
}
|
|
50
|
+
export function isRetryableSlotProtocolError(error) {
|
|
51
|
+
return error instanceof SlotFlightSlotProtocolError && error.retryable;
|
|
52
|
+
}
|
|
53
|
+
function createAbortPromise(signal) {
|
|
54
|
+
if (signal.aborted) {
|
|
55
|
+
return {
|
|
56
|
+
promise: Promise.reject(signal.reason ?? new DOMException("Aborted", "AbortError")),
|
|
57
|
+
cleanup: () => undefined
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
let rejectAbort;
|
|
61
|
+
const promise = new Promise((_, reject) => {
|
|
62
|
+
rejectAbort = reject;
|
|
63
|
+
});
|
|
64
|
+
const onAbort = () => {
|
|
65
|
+
rejectAbort(signal.reason ?? new DOMException("Aborted", "AbortError"));
|
|
66
|
+
};
|
|
67
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
68
|
+
return {
|
|
69
|
+
promise,
|
|
70
|
+
cleanup: () => signal.removeEventListener("abort", onAbort)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function linkAbortSignal(parent, child) {
|
|
74
|
+
if (parent === undefined) {
|
|
75
|
+
return () => undefined;
|
|
76
|
+
}
|
|
77
|
+
if (parent.aborted) {
|
|
78
|
+
child.abort(parent.reason);
|
|
79
|
+
return () => undefined;
|
|
80
|
+
}
|
|
81
|
+
const abort = () => child.abort(parent.reason);
|
|
82
|
+
parent.addEventListener("abort", abort, { once: true });
|
|
83
|
+
return () => parent.removeEventListener("abort", abort);
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../../src/slot/execution/scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAE9D,MAAM,UAAU,kBAAkB,CAAC,YAAqC;IAItE,2EAA2E;IAC3E,0CAA0C;IAC1C,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,YAAY,GAAG,eAAe,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IAE/D,OAAO;QACL,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,OAAO,EAAE,YAAY;KACtB,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,SAAS,CAC9B,MAAwB,EACxB,MAAmB;IAEnB,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;IAChD,MAAM,KAAK,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACzC,IAAI,SAAS,GAAG,KAAK,CAAC;IAEtB,IAAI,CAAC;QACH,OAAO,IAAI,EAAE,CAAC;YACZ,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;YAClE,cAAc,CAAC,MAAM,CAAC,CAAC;YAEvB,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBACd,SAAS,GAAG,IAAI,CAAC;gBACjB,OAAO;YAC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,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;QAC/C,WAAW,GAAG,MAAM,CAAC;IACvB,CAAC,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,WAAW,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,YAAY,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;IAC1E,CAAC,CAAC;IAEF,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAE1D,OAAO;QACL,OAAO;QACP,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC;KAC5D,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CACtB,MAA+B,EAC/B,KAAsB;IAEtB,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC;IACzB,CAAC;IAED,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC3B,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC;IACzB,CAAC;IAED,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SlotFlightEvent, SlotFlightPrompt, SlotGenerator } from "../../types.js";
|
|
2
|
+
import type { CompiledSlot } from "../plan.js";
|
|
3
|
+
export interface SlotExecutionOptions {
|
|
4
|
+
slots: CompiledSlot[];
|
|
5
|
+
state: unknown;
|
|
6
|
+
generate: SlotGenerator;
|
|
7
|
+
prompt?: SlotFlightPrompt;
|
|
8
|
+
maxRetries: number;
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
cloneState: <T>(value: T) => T;
|
|
11
|
+
}
|
|
12
|
+
export type SlotExecutionEvent = Exclude<SlotFlightEvent, {
|
|
13
|
+
type: "done";
|
|
14
|
+
}>;
|
|
15
|
+
export interface PendingFailure {
|
|
16
|
+
slot: CompiledSlot;
|
|
17
|
+
attempt: number;
|
|
18
|
+
error: Error;
|
|
19
|
+
retryable: boolean;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/slot/execution/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,aAAa,EACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,UAAU,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;CAChC;AAED,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,eAAe,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE5E,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/slot/execution/types.ts"],"names":[],"mappings":""}
|