@nylorun/harness 0.12.0-beta → 0.13.0-beta
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 +23 -0
- package/README.md +124 -5
- package/dist/definition/agent-definition.d.ts +11 -0
- package/dist/definition/agent-definition.js +12 -0
- package/dist/definition/assemble.d.ts +22 -0
- package/dist/{build → definition}/assemble.js +6 -4
- package/dist/definition/bind-agent.d.ts +9 -0
- package/dist/definition/bind-agent.js +21 -0
- package/dist/{build → definition}/bind-tool.d.ts +2 -1
- package/dist/{build → definition}/bind-tool.js +1 -0
- package/dist/definition/bound.d.ts +16 -0
- package/dist/definition/builder.d.ts +30 -0
- package/dist/definition/builder.js +94 -0
- package/dist/definition/declaration.d.ts +3 -0
- package/dist/definition/declaration.js +53 -0
- package/dist/{build → definition}/helpers.d.ts +1 -1
- package/dist/{build → definition}/manifest.d.ts +3 -1
- package/dist/definition/manifest.js +45 -0
- package/dist/{session → definition}/output-contract.d.ts +2 -2
- package/dist/{session → definition}/output-contract.js +1 -1
- package/dist/definition/registry.d.ts +10 -0
- package/dist/definition/registry.js +48 -0
- package/dist/{build → definition}/schema.d.ts +4 -4
- package/dist/errors.d.ts +1 -1
- package/dist/execution/dispatch.d.ts +2 -0
- package/dist/execution/dispatch.js +164 -0
- package/dist/execution/initial-state.d.ts +3 -0
- package/dist/execution/initial-state.js +14 -0
- package/dist/execution/invocation.d.ts +21 -0
- package/dist/execution/invocation.js +32 -0
- package/dist/{model → execution/model}/adapters.d.ts +2 -2
- package/dist/{model → execution/model}/adapters.js +2 -2
- package/dist/{model → execution/model}/normalize.d.ts +2 -2
- package/dist/{model → execution/model}/normalize.js +2 -2
- package/dist/{model → execution/model}/prepared.d.ts +3 -3
- package/dist/{step → execution/model}/project.d.ts +1 -1
- package/dist/{step → execution/model}/project.js +2 -10
- package/dist/execution/observe.d.ts +17 -0
- package/dist/execution/observe.js +53 -0
- package/dist/execution/options.d.ts +10 -0
- package/dist/execution/options.js +49 -0
- package/dist/execution/resume.d.ts +4 -0
- package/dist/execution/resume.js +52 -0
- package/dist/execution/run.d.ts +5 -0
- package/dist/execution/run.js +256 -0
- package/dist/execution/state.d.ts +8 -0
- package/dist/execution/state.js +208 -0
- package/dist/{step → execution/step}/canonicalize.d.ts +2 -2
- package/dist/{step → execution/step}/canonicalize.js +2 -2
- package/dist/{step → execution/step}/compose.d.ts +3 -2
- package/dist/{step → execution/step}/compose.js +5 -5
- package/dist/{step → execution/step}/context-draft.d.ts +3 -5
- package/dist/{step → execution/step}/context-draft.js +5 -22
- package/dist/execution/step/describe.d.ts +9 -0
- package/dist/execution/step/describe.js +22 -0
- package/dist/{step → execution/step}/model-configuration.d.ts +4 -3
- package/dist/{step → execution/step}/model-configuration.js +3 -3
- package/dist/execution/step/resolve.d.ts +11 -0
- package/dist/{step → execution/step}/resolve.js +5 -3
- package/dist/execution/step/run.d.ts +29 -0
- package/dist/{step → execution/step}/run.js +19 -53
- package/dist/execution/step/runtime.d.ts +32 -0
- package/dist/execution/step/runtime.js +1 -0
- package/dist/{step → execution/step}/seal.d.ts +13 -8
- package/dist/{step → execution/step}/seal.js +8 -6
- package/dist/{step → execution/step}/slot-assembly.d.ts +4 -4
- package/dist/{step → execution/step}/slot-assembly.js +4 -4
- package/dist/{step → execution/step}/step-context.d.ts +11 -12
- package/dist/{step → execution/step}/step-context.js +5 -27
- package/dist/execution/tool-result.d.ts +4 -0
- package/dist/execution/tool-result.js +30 -0
- package/dist/execution/transcript.d.ts +2 -0
- package/dist/{session/seed.js → execution/transcript.js} +9 -39
- package/dist/index.d.ts +15 -12
- package/dist/index.js +5 -5
- package/dist/types/agent.d.ts +9 -0
- package/dist/types/agent.js +1 -0
- package/dist/types/execution.d.ts +97 -0
- package/dist/types/execution.js +1 -0
- package/dist/types/manifest.d.ts +16 -13
- package/dist/types/middleware.d.ts +11 -40
- package/dist/types/model.d.ts +10 -10
- package/dist/types/observe.d.ts +165 -0
- package/dist/types/observe.js +1 -0
- package/dist/types/shared.d.ts +1 -225
- package/dist/types/tool.d.ts +19 -20
- package/dist/types/transcript.d.ts +65 -0
- package/dist/types/transcript.js +1 -0
- package/dist/utils/canonical.d.ts +1 -0
- package/dist/utils/canonical.js +10 -0
- package/dist/utils/immutable.d.ts +1 -0
- package/dist/utils/immutable.js +8 -0
- package/package.json +3 -3
- package/dist/build/agent.d.ts +0 -17
- package/dist/build/agent.js +0 -32
- package/dist/build/assemble.d.ts +0 -7
- package/dist/build/builder.d.ts +0 -38
- package/dist/build/builder.js +0 -136
- package/dist/build/manifest.js +0 -20
- package/dist/session/capability-state.d.ts +0 -14
- package/dist/session/capability-state.js +0 -67
- package/dist/session/event-log.d.ts +0 -12
- package/dist/session/event-log.js +0 -63
- package/dist/session/input-queue.d.ts +0 -41
- package/dist/session/input-queue.js +0 -94
- package/dist/session/record.d.ts +0 -11
- package/dist/session/record.js +0 -26
- package/dist/session/scheduler.d.ts +0 -62
- package/dist/session/scheduler.js +0 -475
- package/dist/session/seed.d.ts +0 -10
- package/dist/session/session.d.ts +0 -17
- package/dist/session/session.js +0 -101
- package/dist/session/state.d.ts +0 -15
- package/dist/session/state.js +0 -48
- package/dist/session/submission-stream.d.ts +0 -16
- package/dist/session/submission-stream.js +0 -46
- package/dist/step/resolve.d.ts +0 -10
- package/dist/step/run.d.ts +0 -33
- package/dist/turn/plan-runner.d.ts +0 -72
- package/dist/turn/plan-runner.js +0 -389
- package/dist/turn/runner.d.ts +0 -69
- package/dist/turn/runner.js +0 -159
- package/dist/types/session.d.ts +0 -230
- package/dist/utils/maps.d.ts +0 -1
- package/dist/utils/maps.js +0 -37
- package/dist/utils/observe.d.ts +0 -3
- package/dist/utils/observe.js +0 -13
- /package/dist/{types/session.js → definition/bound.js} +0 -0
- /package/dist/{build → definition}/helpers.js +0 -0
- /package/dist/{build → definition}/schema.js +0 -0
- /package/dist/{model → execution/model}/prepared.js +0 -0
package/dist/turn/runner.js
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { beginTurn, commitCandidate, commitFinal, commitToolResults, withStatus, } from "../session/state.js";
|
|
2
|
-
import { runStep } from "../step/run.js";
|
|
3
|
-
import { createId } from "../utils/ids.js";
|
|
4
|
-
import { copyJson } from "../utils/immutable.js";
|
|
5
|
-
import { ToolPlanRunner } from "./plan-runner.js";
|
|
6
|
-
/** Advances one Turn until it finalizes, trips policy, or reaches a waiting barrier. */
|
|
7
|
-
export class TurnRunner {
|
|
8
|
-
agent;
|
|
9
|
-
sessionId;
|
|
10
|
-
session;
|
|
11
|
-
constructor(agent, sessionId, session) {
|
|
12
|
-
this.agent = agent;
|
|
13
|
-
this.sessionId = sessionId;
|
|
14
|
-
this.session = session;
|
|
15
|
-
}
|
|
16
|
-
async start(state, event, context, output) {
|
|
17
|
-
const turnId = createId("turn");
|
|
18
|
-
state = await context.commit(beginTurn(state, turnId, event), "input");
|
|
19
|
-
context.onConversation({ type: "input", event, turnId });
|
|
20
|
-
return this.advance(state, turnId, 1, [event], [], context, output);
|
|
21
|
-
}
|
|
22
|
-
async continue(state, context) {
|
|
23
|
-
const turnId = createId("turn");
|
|
24
|
-
return this.advance(beginTurn(state, turnId), turnId, 1, [], [], context);
|
|
25
|
-
}
|
|
26
|
-
async resume(state, pending, event, context) {
|
|
27
|
-
const resume = pending.plan.interactionResume(event);
|
|
28
|
-
const active = pending.plan.activeInteractionRecord(pending.turnId, pending.stepId, resume);
|
|
29
|
-
state = await context.commit(withStatus(state, "running", undefined, active), "input", active);
|
|
30
|
-
context.onConversation({ type: "input", event, turnId: pending.turnId });
|
|
31
|
-
const progress = await this.runPlan(pending, context, event);
|
|
32
|
-
if (progress.kind === "interaction-required")
|
|
33
|
-
return this.waitForInteraction(state, pending, progress.interaction, context);
|
|
34
|
-
if (progress.kind === "deferred")
|
|
35
|
-
return this.waitForDeferred(state, pending, pending.plan.activeToolsRecord(pending.turnId, pending.stepId), context);
|
|
36
|
-
state = await context.commit(commitToolResults(state, pending.turnId, pending.stepId, progress.results), "tool-results");
|
|
37
|
-
pending.plan.publishSettlements(context.observe);
|
|
38
|
-
const claimed = await context.claimInterrupts(state, pending.turnId);
|
|
39
|
-
return this.advance(claimed.state, pending.turnId, pending.stepNumber + 1, claimed.arrivals, progress.results, context, pending.output);
|
|
40
|
-
}
|
|
41
|
-
async advance(initialState, turnId, firstStep, arrivals, initialResults, context, output) {
|
|
42
|
-
let state = initialState;
|
|
43
|
-
let stepArrivals = arrivals;
|
|
44
|
-
let toolResults = initialResults;
|
|
45
|
-
for (let stepNumber = firstStep;; stepNumber += 1) {
|
|
46
|
-
const stepId = createId("step");
|
|
47
|
-
const run = await runStep({
|
|
48
|
-
agent: this.agent,
|
|
49
|
-
observe: context.observe,
|
|
50
|
-
state,
|
|
51
|
-
sessionId: this.sessionId,
|
|
52
|
-
turnId,
|
|
53
|
-
stepId,
|
|
54
|
-
turnNumber: state.turnCount,
|
|
55
|
-
stepNumber,
|
|
56
|
-
arrivals: stepArrivals,
|
|
57
|
-
toolResults,
|
|
58
|
-
signal: context.signal,
|
|
59
|
-
session: this.session,
|
|
60
|
-
states: context.states,
|
|
61
|
-
output,
|
|
62
|
-
recordModelRequested: (next, active) => context.commit(next, "model-requested", active),
|
|
63
|
-
});
|
|
64
|
-
context.assertCurrent();
|
|
65
|
-
state = run.state;
|
|
66
|
-
const pending = run.output.kind === "tools"
|
|
67
|
-
? {
|
|
68
|
-
plan: new ToolPlanRunner(run.output.plan),
|
|
69
|
-
turnId,
|
|
70
|
-
stepId,
|
|
71
|
-
stepNumber,
|
|
72
|
-
...(output === undefined ? {} : { output }),
|
|
73
|
-
}
|
|
74
|
-
: undefined;
|
|
75
|
-
if (run.candidate) {
|
|
76
|
-
const active = pending?.plan.activeToolsRecord(turnId, stepId);
|
|
77
|
-
state = await context.commit(commitCandidate(state, turnId, stepId, run.candidate), "candidate", active);
|
|
78
|
-
context.observe({
|
|
79
|
-
type: "model.completed",
|
|
80
|
-
turnId,
|
|
81
|
-
stepId,
|
|
82
|
-
...(run.requestedModelId === undefined ? {} : { requestedModelId: run.requestedModelId }),
|
|
83
|
-
attributes: run.candidate,
|
|
84
|
-
});
|
|
85
|
-
context.onConversation({ type: "candidate", turnId, stepId, candidate: run.candidate });
|
|
86
|
-
}
|
|
87
|
-
if (run.output.kind === "tripwire")
|
|
88
|
-
return { kind: "tripwire", state, turnId, stepId, tripwire: run.output.tripwire };
|
|
89
|
-
if (run.output.kind === "deferred-model") {
|
|
90
|
-
state = await context.commit(withStatus(state, "waiting", undefined, run.output.active), "waiting", run.output.active);
|
|
91
|
-
return { kind: "deferred", state, turnId, stepId, active: run.output.active };
|
|
92
|
-
}
|
|
93
|
-
if (run.output.kind === "final") {
|
|
94
|
-
state = await context.commit(withStatus(commitFinal(state, turnId, stepId, run.output.output), "idle"), "final");
|
|
95
|
-
return { kind: "final", state, turnId, stepId, output: run.output.output };
|
|
96
|
-
}
|
|
97
|
-
const toolPlan = run.output.plan;
|
|
98
|
-
context.observe(() => ({
|
|
99
|
-
type: "tool.sealed",
|
|
100
|
-
turnId,
|
|
101
|
-
stepId,
|
|
102
|
-
attributes: {
|
|
103
|
-
executable: Object.freeze(toolPlan.executable.map((entry) => Object.freeze({
|
|
104
|
-
callId: entry.call.callId,
|
|
105
|
-
toolName: entry.call.toolName,
|
|
106
|
-
args: copyJson(entry.call.args),
|
|
107
|
-
invocationId: entry.invocationId,
|
|
108
|
-
owner: entry.owner,
|
|
109
|
-
...(entry.interaction === undefined
|
|
110
|
-
? {}
|
|
111
|
-
: { interaction: copyJson(entry.interaction) }),
|
|
112
|
-
}))),
|
|
113
|
-
immediate: copyJson(toolPlan.immediateResults),
|
|
114
|
-
},
|
|
115
|
-
}));
|
|
116
|
-
const progress = await this.runPlan(pending, context);
|
|
117
|
-
if (progress.kind === "interaction-required")
|
|
118
|
-
return this.waitForInteraction(state, pending, progress.interaction, context);
|
|
119
|
-
if (progress.kind === "deferred")
|
|
120
|
-
return this.waitForDeferred(state, pending, pending.plan.activeToolsRecord(turnId, stepId), context);
|
|
121
|
-
state = await context.commit(commitToolResults(state, turnId, stepId, progress.results), "tool-results");
|
|
122
|
-
pending.plan.publishSettlements(context.observe);
|
|
123
|
-
const claimed = await context.claimInterrupts(state, turnId);
|
|
124
|
-
state = claimed.state;
|
|
125
|
-
stepArrivals = claimed.arrivals;
|
|
126
|
-
toolResults = progress.results;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
async waitForInteraction(state, pending, interaction, context) {
|
|
130
|
-
const active = pending.plan.activeInteractionRecord(pending.turnId, pending.stepId);
|
|
131
|
-
state = await context.commit(withStatus(state, "waiting", interaction, active), "waiting", active);
|
|
132
|
-
pending.plan.publishSettlements(context.observe);
|
|
133
|
-
return { kind: "interaction-required", state, pending, interaction };
|
|
134
|
-
}
|
|
135
|
-
async waitForDeferred(state, pending, active, context) {
|
|
136
|
-
state = await context.commit(withStatus(state, "waiting", undefined, active), "waiting", active);
|
|
137
|
-
pending.plan.publishSettlements(context.observe);
|
|
138
|
-
return {
|
|
139
|
-
kind: "deferred",
|
|
140
|
-
state,
|
|
141
|
-
turnId: pending.turnId,
|
|
142
|
-
stepId: pending.stepId,
|
|
143
|
-
active,
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
async runPlan(pending, context, resume) {
|
|
147
|
-
context.onPlanActive(pending);
|
|
148
|
-
const progress = await pending.plan.run({
|
|
149
|
-
signal: context.signal,
|
|
150
|
-
observe: context.observe,
|
|
151
|
-
ids: { sessionId: this.sessionId, turnId: pending.turnId, stepId: pending.stepId },
|
|
152
|
-
states: context.states,
|
|
153
|
-
onModelCall: this.agent.invoke,
|
|
154
|
-
}, resume);
|
|
155
|
-
context.assertCurrent();
|
|
156
|
-
context.onPlanActive(undefined);
|
|
157
|
-
return progress;
|
|
158
|
-
}
|
|
159
|
-
}
|
package/dist/types/session.d.ts
DELETED
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import type { ModelAdapter, ModelCall, ModelCandidate } from "./model.js";
|
|
2
|
-
import type { JsonObject, JsonValue, Observer, Tripwire } from "./shared.js";
|
|
3
|
-
import type { RequiredInteraction, SchemaOutput, ToolExecutionResume, ToolOwner, ToolResult, ToolSchemaSource } from "./tool.js";
|
|
4
|
-
export type InputEvent = {
|
|
5
|
-
readonly kind: "user-message" | "interrupt";
|
|
6
|
-
readonly text: string;
|
|
7
|
-
readonly metadata?: JsonObject;
|
|
8
|
-
} | {
|
|
9
|
-
readonly kind: "user-message" | "interrupt";
|
|
10
|
-
readonly content: readonly UserContentPart[];
|
|
11
|
-
/** Undefined for content-bearing events; retained for text-event narrowing compatibility. */
|
|
12
|
-
readonly text?: undefined;
|
|
13
|
-
readonly metadata?: JsonObject;
|
|
14
|
-
} | {
|
|
15
|
-
readonly kind: "approve";
|
|
16
|
-
readonly interactionId: string;
|
|
17
|
-
readonly approved: boolean;
|
|
18
|
-
} | {
|
|
19
|
-
readonly kind: "respond";
|
|
20
|
-
readonly interactionId: string;
|
|
21
|
-
readonly value: JsonValue;
|
|
22
|
-
};
|
|
23
|
-
export type SessionEvent<Output = string> = {
|
|
24
|
-
readonly type: "input";
|
|
25
|
-
readonly event: InputEvent;
|
|
26
|
-
readonly turnId: string;
|
|
27
|
-
} | {
|
|
28
|
-
readonly type: "candidate";
|
|
29
|
-
readonly turnId: string;
|
|
30
|
-
readonly stepId: string;
|
|
31
|
-
readonly candidate: ModelCandidate;
|
|
32
|
-
} | {
|
|
33
|
-
readonly type: "final";
|
|
34
|
-
readonly output: Output;
|
|
35
|
-
readonly turnId: string;
|
|
36
|
-
} | {
|
|
37
|
-
readonly type: "interaction.required";
|
|
38
|
-
readonly interaction: RequiredInteraction;
|
|
39
|
-
readonly turnId: string;
|
|
40
|
-
} | {
|
|
41
|
-
readonly type: "tripwire";
|
|
42
|
-
readonly tripwire: Tripwire;
|
|
43
|
-
readonly turnId: string;
|
|
44
|
-
} | {
|
|
45
|
-
readonly type: "execution.deferred";
|
|
46
|
-
readonly active: ActiveExecutionRecord;
|
|
47
|
-
readonly turnId: string;
|
|
48
|
-
} | {
|
|
49
|
-
readonly type: "input.queued";
|
|
50
|
-
readonly inputId: string;
|
|
51
|
-
} | {
|
|
52
|
-
readonly type: "input.rejected";
|
|
53
|
-
readonly inputId: string;
|
|
54
|
-
readonly reason: string;
|
|
55
|
-
} | {
|
|
56
|
-
readonly type: "input.cancelled";
|
|
57
|
-
readonly inputId: string;
|
|
58
|
-
readonly reason: string;
|
|
59
|
-
} | {
|
|
60
|
-
readonly type: "session.stopped";
|
|
61
|
-
readonly sessionId: string;
|
|
62
|
-
};
|
|
63
|
-
export interface InputCompletion<Output = string> {
|
|
64
|
-
readonly inputId: string;
|
|
65
|
-
readonly status: "completed" | "waiting" | "rejected" | "cancelled" | "stopped";
|
|
66
|
-
readonly events: readonly SessionEvent<Output>[];
|
|
67
|
-
}
|
|
68
|
-
export interface InputHandle<Output = string> {
|
|
69
|
-
readonly inputId: string;
|
|
70
|
-
readonly completed: Promise<InputCompletion<Output>>;
|
|
71
|
-
}
|
|
72
|
-
export interface SessionOptions {
|
|
73
|
-
readonly onModelCall: ModelAdapter;
|
|
74
|
-
readonly id?: string;
|
|
75
|
-
readonly userId?: string;
|
|
76
|
-
readonly context?: JsonObject;
|
|
77
|
-
readonly seed?: never;
|
|
78
|
-
readonly recorder?: SessionRecorder;
|
|
79
|
-
readonly observer?: Observer;
|
|
80
|
-
}
|
|
81
|
-
/** Stable host-owned facts available while a capability creates session-local state. */
|
|
82
|
-
export interface SessionIdentity {
|
|
83
|
-
readonly id: string;
|
|
84
|
-
readonly userId?: string;
|
|
85
|
-
readonly context?: JsonObject;
|
|
86
|
-
}
|
|
87
|
-
export interface SeededSessionOptions {
|
|
88
|
-
readonly onModelCall: ModelAdapter;
|
|
89
|
-
readonly seed: SessionSeed;
|
|
90
|
-
readonly recorder?: SessionRecorder;
|
|
91
|
-
readonly observer?: Observer;
|
|
92
|
-
readonly id?: never;
|
|
93
|
-
readonly userId?: never;
|
|
94
|
-
readonly context?: never;
|
|
95
|
-
}
|
|
96
|
-
export type SessionRunOptions = SessionOptions | SeededSessionOptions;
|
|
97
|
-
export interface InputOptions {
|
|
98
|
-
readonly signal?: AbortSignal;
|
|
99
|
-
}
|
|
100
|
-
/** Per-turn, locally-enforced terminal JSON contract. */
|
|
101
|
-
export interface OutputInputOptions<Schema extends ToolSchemaSource = ToolSchemaSource> extends InputOptions {
|
|
102
|
-
readonly outputSchema?: Schema;
|
|
103
|
-
}
|
|
104
|
-
/** Ordered, model-visible user content. Media references stay host-owned JSON values. */
|
|
105
|
-
export type UserContentPart = {
|
|
106
|
-
readonly type: "text";
|
|
107
|
-
readonly text: string;
|
|
108
|
-
} | {
|
|
109
|
-
readonly type: "media";
|
|
110
|
-
readonly mediaType: string;
|
|
111
|
-
readonly reference: JsonValue;
|
|
112
|
-
};
|
|
113
|
-
export type MessageInput = string | {
|
|
114
|
-
readonly text: string;
|
|
115
|
-
readonly metadata?: JsonObject;
|
|
116
|
-
} | {
|
|
117
|
-
readonly content: readonly UserContentPart[];
|
|
118
|
-
readonly metadata?: JsonObject;
|
|
119
|
-
};
|
|
120
|
-
export type InteractionReply = Extract<InputEvent, {
|
|
121
|
-
kind: "approve" | "respond";
|
|
122
|
-
}>;
|
|
123
|
-
/** Ordinary user text or an interaction reply. Use `Session.interrupt()` for barge-in text. */
|
|
124
|
-
export type SessionInput = MessageInput | InteractionReply;
|
|
125
|
-
export interface TranscriptInputEntry {
|
|
126
|
-
readonly kind: "input";
|
|
127
|
-
readonly turnId: string;
|
|
128
|
-
readonly event: InputEvent;
|
|
129
|
-
}
|
|
130
|
-
export interface TranscriptCandidateEntry {
|
|
131
|
-
readonly kind: "candidate";
|
|
132
|
-
readonly turnId: string;
|
|
133
|
-
readonly stepId: string;
|
|
134
|
-
readonly candidate: ModelCandidate;
|
|
135
|
-
}
|
|
136
|
-
export interface TranscriptToolsEntry {
|
|
137
|
-
readonly kind: "tool-results";
|
|
138
|
-
readonly turnId: string;
|
|
139
|
-
readonly stepId: string;
|
|
140
|
-
readonly results: readonly ToolResult[];
|
|
141
|
-
}
|
|
142
|
-
export interface TranscriptFinalEntry {
|
|
143
|
-
readonly kind: "final";
|
|
144
|
-
readonly turnId: string;
|
|
145
|
-
readonly stepId: string;
|
|
146
|
-
readonly output: JsonValue;
|
|
147
|
-
}
|
|
148
|
-
export type TranscriptEntry = TranscriptInputEntry | TranscriptCandidateEntry | TranscriptToolsEntry | TranscriptFinalEntry;
|
|
149
|
-
export interface SessionSnapshot {
|
|
150
|
-
readonly id: string;
|
|
151
|
-
readonly status: "idle" | "running" | "waiting" | "stopped";
|
|
152
|
-
readonly turnCount: number;
|
|
153
|
-
readonly revision: number;
|
|
154
|
-
readonly transcript: readonly TranscriptEntry[];
|
|
155
|
-
readonly pendingInteraction?: RequiredInteraction;
|
|
156
|
-
readonly active?: ActiveExecutionRecord;
|
|
157
|
-
}
|
|
158
|
-
export interface SessionSeed {
|
|
159
|
-
readonly id?: string;
|
|
160
|
-
readonly userId?: string;
|
|
161
|
-
readonly context?: JsonObject;
|
|
162
|
-
readonly turnCount?: number;
|
|
163
|
-
readonly revision?: number;
|
|
164
|
-
readonly transcript: readonly TranscriptEntry[];
|
|
165
|
-
}
|
|
166
|
-
export interface ActiveModelExecutionRecord {
|
|
167
|
-
readonly kind: "model";
|
|
168
|
-
readonly turnId: string;
|
|
169
|
-
readonly stepId: string;
|
|
170
|
-
readonly invocationId: string;
|
|
171
|
-
readonly call: ModelCall;
|
|
172
|
-
readonly token?: JsonValue;
|
|
173
|
-
}
|
|
174
|
-
export interface ActiveToolCallRecord {
|
|
175
|
-
readonly callId: string;
|
|
176
|
-
readonly toolName: string;
|
|
177
|
-
readonly args: JsonValue;
|
|
178
|
-
readonly invocationId: string;
|
|
179
|
-
readonly owner: ToolOwner;
|
|
180
|
-
readonly status: "pending" | "settled" | "deferred";
|
|
181
|
-
readonly result?: ToolResult;
|
|
182
|
-
readonly token?: JsonValue;
|
|
183
|
-
}
|
|
184
|
-
export interface ActiveToolsExecutionRecord {
|
|
185
|
-
readonly kind: "tools";
|
|
186
|
-
readonly turnId: string;
|
|
187
|
-
readonly stepId: string;
|
|
188
|
-
readonly calls: readonly ActiveToolCallRecord[];
|
|
189
|
-
}
|
|
190
|
-
export interface ActiveInteractionExecutionRecord {
|
|
191
|
-
readonly kind: "interaction";
|
|
192
|
-
readonly turnId: string;
|
|
193
|
-
readonly stepId: string;
|
|
194
|
-
readonly callId: string;
|
|
195
|
-
readonly toolName: string;
|
|
196
|
-
readonly interaction: RequiredInteraction;
|
|
197
|
-
readonly token?: JsonValue;
|
|
198
|
-
readonly resume?: ToolExecutionResume;
|
|
199
|
-
readonly tools: ActiveToolsExecutionRecord;
|
|
200
|
-
}
|
|
201
|
-
export type ActiveExecutionRecord = ActiveModelExecutionRecord | ActiveToolsExecutionRecord | ActiveInteractionExecutionRecord;
|
|
202
|
-
export interface SessionRecord {
|
|
203
|
-
readonly version: 1;
|
|
204
|
-
readonly revision: number;
|
|
205
|
-
readonly transition: "input" | "model-requested" | "candidate" | "tool-results" | "waiting" | "final" | "stopped";
|
|
206
|
-
readonly session: {
|
|
207
|
-
readonly id: string;
|
|
208
|
-
readonly userId?: string;
|
|
209
|
-
readonly context?: JsonObject;
|
|
210
|
-
readonly turnCount: number;
|
|
211
|
-
readonly status: SessionSnapshot["status"];
|
|
212
|
-
};
|
|
213
|
-
readonly transcript: readonly TranscriptEntry[];
|
|
214
|
-
readonly active?: ActiveExecutionRecord;
|
|
215
|
-
}
|
|
216
|
-
export interface SessionRecorder {
|
|
217
|
-
record(value: SessionRecord): Promise<void>;
|
|
218
|
-
}
|
|
219
|
-
export interface Session {
|
|
220
|
-
readonly id: string;
|
|
221
|
-
readonly state: SessionSnapshot;
|
|
222
|
-
input<Schema extends ToolSchemaSource>(event: MessageInput, options: OutputInputOptions<Schema> & {
|
|
223
|
-
readonly outputSchema: Schema;
|
|
224
|
-
}): InputHandle<SchemaOutput<Schema>>;
|
|
225
|
-
input(event: SessionInput, options?: InputOptions): InputHandle<string>;
|
|
226
|
-
interrupt(event: MessageInput, options?: InputOptions): InputHandle;
|
|
227
|
-
continue(options?: InputOptions): InputHandle;
|
|
228
|
-
stream(): AsyncIterable<SessionEvent<JsonValue>>;
|
|
229
|
-
stop(reason?: string): Promise<void>;
|
|
230
|
-
}
|
package/dist/utils/maps.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function createFixedMap<K, V>(values: Iterable<readonly [K, V]>): ReadonlyMap<K, V>;
|
package/dist/utils/maps.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
class FixedReadonlyMap {
|
|
2
|
-
#values;
|
|
3
|
-
constructor(values) {
|
|
4
|
-
this.#values = new Map(values);
|
|
5
|
-
Object.freeze(this);
|
|
6
|
-
}
|
|
7
|
-
get size() {
|
|
8
|
-
return this.#values.size;
|
|
9
|
-
}
|
|
10
|
-
get(key) {
|
|
11
|
-
return this.#values.get(key);
|
|
12
|
-
}
|
|
13
|
-
has(key) {
|
|
14
|
-
return this.#values.has(key);
|
|
15
|
-
}
|
|
16
|
-
entries() {
|
|
17
|
-
return this.#values.entries();
|
|
18
|
-
}
|
|
19
|
-
keys() {
|
|
20
|
-
return this.#values.keys();
|
|
21
|
-
}
|
|
22
|
-
values() {
|
|
23
|
-
return this.#values.values();
|
|
24
|
-
}
|
|
25
|
-
forEach(callbackfn, thisArg) {
|
|
26
|
-
this.#values.forEach((value, key) => callbackfn.call(thisArg, value, key, this));
|
|
27
|
-
}
|
|
28
|
-
[Symbol.iterator]() {
|
|
29
|
-
return this.#values[Symbol.iterator]();
|
|
30
|
-
}
|
|
31
|
-
get [Symbol.toStringTag]() {
|
|
32
|
-
return "FixedReadonlyMap";
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export function createFixedMap(values) {
|
|
36
|
-
return new FixedReadonlyMap(values);
|
|
37
|
-
}
|
package/dist/utils/observe.d.ts
DELETED
package/dist/utils/observe.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export function emitObserve(listener, event) {
|
|
2
|
-
if (!listener)
|
|
3
|
-
return;
|
|
4
|
-
const snapshot = Object.freeze({ ...(typeof event === "function" ? event() : event) });
|
|
5
|
-
try {
|
|
6
|
-
const result = listener(snapshot);
|
|
7
|
-
if (result && typeof result.then === "function")
|
|
8
|
-
void Promise.resolve(result).catch(() => undefined);
|
|
9
|
-
}
|
|
10
|
-
catch {
|
|
11
|
-
// Observation is deliberately fail-open.
|
|
12
|
-
}
|
|
13
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|