@tessar/core 0.1.0-alpha.0 → 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/README.md +168 -31
- package/dist/agent.d.ts +37 -87
- package/dist/agent.js +101 -1116
- package/dist/agent.js.map +1 -1
- package/dist/controller.d.ts +13 -4
- package/dist/controller.js +184 -19
- package/dist/controller.js.map +1 -1
- package/dist/engine/call.d.ts +8 -0
- package/dist/engine/call.js +136 -0
- package/dist/engine/call.js.map +1 -0
- package/dist/engine/checkpoint.d.ts +11 -0
- package/dist/engine/checkpoint.js +187 -0
- package/dist/engine/checkpoint.js.map +1 -0
- package/dist/engine/delivery.js +6 -13
- package/dist/engine/delivery.js.map +1 -1
- package/dist/engine/execution.d.ts +5 -0
- package/dist/engine/execution.js +292 -0
- package/dist/engine/execution.js.map +1 -0
- package/dist/engine/frame.d.ts +77 -0
- package/dist/engine/frame.js +83 -0
- package/dist/engine/frame.js.map +1 -0
- package/dist/engine/hooks.d.ts +4 -0
- package/dist/engine/hooks.js +138 -0
- package/dist/engine/hooks.js.map +1 -0
- package/dist/engine/interrupt.d.ts +1 -1
- package/dist/engine/lineage.d.ts +1 -1
- package/dist/engine/recovery.d.ts +1 -2
- package/dist/engine/recovery.js +4 -2
- package/dist/engine/recovery.js.map +1 -1
- package/dist/engine/resume.d.ts +12 -1
- package/dist/engine/resume.js +189 -0
- package/dist/engine/resume.js.map +1 -1
- package/dist/engine/runtime.d.ts +16 -0
- package/dist/engine/runtime.js +29 -0
- package/dist/engine/runtime.js.map +1 -0
- package/dist/engine/services.d.ts +3 -0
- package/dist/engine/services.js +125 -0
- package/dist/engine/services.js.map +1 -0
- package/dist/engine/tool-executor.d.ts +8 -2
- package/dist/engine/tool-executor.js +266 -3
- package/dist/engine/tool-executor.js.map +1 -1
- package/dist/engine/tracked-effects.js +5 -6
- package/dist/engine/tracked-effects.js.map +1 -1
- package/dist/errors.js +24 -9
- package/dist/errors.js.map +1 -1
- package/dist/events/definition.d.ts +2 -0
- package/dist/events/definition.js +2 -0
- package/dist/events/definition.js.map +1 -1
- package/dist/events/dispatcher.d.ts +1 -1
- package/dist/events/dispatcher.js +35 -4
- package/dist/events/dispatcher.js.map +1 -1
- package/dist/events/observer.d.ts +3 -0
- package/dist/events/observer.js +13 -0
- package/dist/events/observer.js.map +1 -0
- package/dist/events/{catalog.d.ts → type.d.ts} +170 -47
- package/dist/events/type.js +175 -0
- package/dist/events/type.js.map +1 -0
- package/dist/identity.d.ts +1 -0
- package/dist/identity.js +23 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/instructions/instruction.d.ts +2 -0
- package/dist/instructions/instruction.js +10 -3
- package/dist/instructions/instruction.js.map +1 -1
- package/dist/loop.d.ts +5 -5
- package/dist/loop.js +44 -204
- package/dist/loop.js.map +1 -1
- package/dist/messages/codec.js +4 -2
- package/dist/messages/codec.js.map +1 -1
- package/dist/messages/message.d.ts +2 -3
- package/dist/messages/message.js +3 -3
- package/dist/messages/message.js.map +1 -1
- package/dist/models/contract.d.ts +15 -0
- package/dist/models/options.d.ts +3 -0
- package/dist/models/options.js +13 -0
- package/dist/models/options.js.map +1 -0
- package/dist/models/registry.d.ts +2 -0
- package/dist/models/registry.js +18 -1
- package/dist/models/registry.js.map +1 -1
- package/dist/models/resolver.d.ts +4 -2
- package/dist/models/resolver.js +9 -4
- package/dist/models/resolver.js.map +1 -1
- package/dist/models/stream.d.ts +6 -0
- package/dist/models/stream.js +61 -2
- package/dist/models/stream.js.map +1 -1
- package/dist/plugins/context.d.ts +27 -2
- package/dist/plugins/host.d.ts +5 -1
- package/dist/plugins/host.js +33 -11
- package/dist/plugins/host.js.map +1 -1
- package/dist/plugins/registry.d.ts +1 -1
- package/dist/plugins/registry.js +18 -10
- package/dist/plugins/registry.js.map +1 -1
- package/dist/session.d.ts +16 -6
- package/dist/session.js +126 -55
- package/dist/session.js.map +1 -1
- package/dist/state/commit.d.ts +5 -0
- package/dist/state/commit.js +50 -5
- package/dist/state/commit.js.map +1 -1
- package/dist/state/fork.js +27 -6
- package/dist/state/fork.js.map +1 -1
- package/dist/state/memory-backend.js +307 -38
- package/dist/state/memory-backend.js.map +1 -1
- package/dist/state/plugin-state.js +73 -18
- package/dist/state/plugin-state.js.map +1 -1
- package/dist/state/queries.d.ts +14 -14
- package/dist/state/queries.js +150 -48
- package/dist/state/queries.js.map +1 -1
- package/dist/state/schema.d.ts +47 -6
- package/dist/state/schema.js +9 -1
- package/dist/state/schema.js.map +1 -1
- package/dist/state/scope.js +3 -2
- package/dist/state/scope.js.map +1 -1
- package/dist/state/sessions.d.ts +2 -0
- package/dist/state/sessions.js +21 -0
- package/dist/state/sessions.js.map +1 -0
- package/dist/state/storage-ports.d.ts +16 -2
- package/dist/state/threads.d.ts +1 -0
- package/dist/state/threads.js +77 -12
- package/dist/state/threads.js.map +1 -1
- package/dist/testing/harness.d.ts +2 -1
- package/dist/testing/harness.js +6 -4
- package/dist/testing/harness.js.map +1 -1
- package/dist/testing/scripted-provider.d.ts +1 -0
- package/dist/testing/scripted-provider.js +7 -0
- package/dist/testing/scripted-provider.js.map +1 -1
- package/dist/testing/storage-conformance.js +111 -0
- package/dist/testing/storage-conformance.js.map +1 -1
- package/dist/thread.d.ts +4 -2
- package/dist/thread.js +14 -6
- package/dist/thread.js.map +1 -1
- package/dist/tools/tool.d.ts +11 -12
- package/dist/tools/tool.js +27 -10
- package/dist/tools/tool.js.map +1 -1
- package/dist/trace/records.d.ts +11 -6
- package/dist/trace/records.js +28 -1
- package/dist/trace/records.js.map +1 -1
- package/package.json +7 -1
- package/dist/events/catalog.js +0 -89
- package/dist/events/catalog.js.map +0 -1
- package/dist/models/cache.d.ts +0 -12
- package/dist/models/cache.js +0 -17
- package/dist/models/cache.js.map +0 -1
- package/dist/session-events.d.ts +0 -60
- package/dist/session-events.js +0 -14
- package/dist/session-events.js.map +0 -1
|
@@ -4,11 +4,25 @@ import type { MessageData } from "../messages/message.js";
|
|
|
4
4
|
import type { ModelRef, ModelRequest, ModelResponse, ToolDescription } from "../models/contract.js";
|
|
5
5
|
import type { ErrorInfo } from "../errors.js";
|
|
6
6
|
import type { ModelUsage, UsageSummary } from "../trace/usage.js";
|
|
7
|
-
import type { ToolResult as ToolResultData } from "../tools/tool.js";
|
|
8
7
|
import type { InterruptRecord, ThreadInfo } from "../state/schema.js";
|
|
9
8
|
import type { CreateThreadOptions } from "../state/threads.js";
|
|
10
9
|
import type { DecisionHookContext } from "../engine/interrupt.js";
|
|
11
10
|
import type { ExecutionHookContext } from "../engine/tracked-effects.js";
|
|
11
|
+
import type { SessionHookContext, ThreadHookContext } from "../plugins/context.js";
|
|
12
|
+
import type { ForkOptions } from "../state/fork.js";
|
|
13
|
+
export type OperationDecision = {
|
|
14
|
+
decision: "allow" | "deny";
|
|
15
|
+
reason?: string;
|
|
16
|
+
};
|
|
17
|
+
export type OperationEvent = "session.model.before-change" | "session.thread.before-switch" | "thread.before-fork" | "thread.before-rename" | "thread.before-delete";
|
|
18
|
+
export interface QueuedInputReceipt {
|
|
19
|
+
id: string;
|
|
20
|
+
threadId: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ExecutionReceipt {
|
|
23
|
+
streamId: string;
|
|
24
|
+
threadId: string;
|
|
25
|
+
}
|
|
12
26
|
export type ControlDecision = {
|
|
13
27
|
decision: "allow" | "deny" | "continue" | "stop" | "retry" | "fail";
|
|
14
28
|
reason?: string;
|
|
@@ -43,55 +57,164 @@ export interface StreamOutcome {
|
|
|
43
57
|
error: ErrorInfo | null;
|
|
44
58
|
interrupt: InterruptRecord | null;
|
|
45
59
|
}
|
|
46
|
-
export declare const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
readonly
|
|
51
|
-
readonly
|
|
52
|
-
readonly
|
|
53
|
-
readonly
|
|
54
|
-
readonly
|
|
55
|
-
readonly
|
|
56
|
-
readonly
|
|
57
|
-
readonly
|
|
58
|
-
readonly
|
|
59
|
-
readonly
|
|
60
|
-
readonly
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
readonly
|
|
64
|
-
readonly
|
|
65
|
-
readonly
|
|
66
|
-
readonly
|
|
67
|
-
readonly
|
|
68
|
-
readonly
|
|
69
|
-
readonly
|
|
70
|
-
readonly
|
|
71
|
-
readonly
|
|
72
|
-
readonly
|
|
73
|
-
readonly
|
|
74
|
-
readonly
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
readonly
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
readonly
|
|
83
|
-
readonly
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
readonly
|
|
87
|
-
readonly
|
|
88
|
-
readonly
|
|
89
|
-
readonly
|
|
60
|
+
export declare const ready = "ready";
|
|
61
|
+
export declare const shutdown = "shutdown";
|
|
62
|
+
export declare const diagnostic = "diagnostic";
|
|
63
|
+
export declare const thread: {
|
|
64
|
+
readonly prepare: "thread.prepare";
|
|
65
|
+
readonly started: "thread.started";
|
|
66
|
+
readonly beforeShutdown: "thread.before-shutdown";
|
|
67
|
+
readonly shutdown: "thread.shutdown";
|
|
68
|
+
readonly updated: "thread.updated";
|
|
69
|
+
readonly beforeFork: "thread.before-fork";
|
|
70
|
+
readonly forked: "thread.forked";
|
|
71
|
+
readonly beforeRename: "thread.before-rename";
|
|
72
|
+
readonly renamed: "thread.renamed";
|
|
73
|
+
readonly beforeDelete: "thread.before-delete";
|
|
74
|
+
readonly deleted: "thread.deleted";
|
|
75
|
+
};
|
|
76
|
+
export declare const session: {
|
|
77
|
+
readonly created: "session.created";
|
|
78
|
+
readonly modelChanged: "session.model-changed";
|
|
79
|
+
readonly threadCreated: "session.thread-created";
|
|
80
|
+
readonly threadSwitched: "session.thread-switched";
|
|
81
|
+
readonly threadRenamed: "session.thread-renamed";
|
|
82
|
+
readonly threadForked: "session.thread-forked";
|
|
83
|
+
readonly threadDeleted: "session.thread-deleted";
|
|
84
|
+
readonly inputQueued: "session.input-queued";
|
|
85
|
+
readonly inputDiscarded: "session.input-discarded";
|
|
86
|
+
readonly beforeClose: "session.before-close";
|
|
87
|
+
readonly closed: "session.closed";
|
|
88
|
+
readonly model: {
|
|
89
|
+
readonly beforeChange: "session.model.before-change";
|
|
90
|
+
};
|
|
91
|
+
readonly thread: {
|
|
92
|
+
readonly beforeSwitch: "session.thread.before-switch";
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
export declare const input: {
|
|
96
|
+
readonly prepare: "input.prepare";
|
|
97
|
+
readonly received: "input.received";
|
|
98
|
+
};
|
|
99
|
+
export declare const stream: {
|
|
100
|
+
readonly before: "stream.before";
|
|
101
|
+
readonly started: "stream.started";
|
|
102
|
+
readonly beforeEnd: "stream.before-end";
|
|
103
|
+
readonly end: "stream.end";
|
|
104
|
+
readonly error: "stream.error";
|
|
105
|
+
readonly suspended: "stream.suspended";
|
|
106
|
+
readonly resumed: "stream.resumed";
|
|
107
|
+
readonly cancel: "stream.cancel";
|
|
108
|
+
};
|
|
109
|
+
export declare const turn: {
|
|
110
|
+
readonly start: "turn.start";
|
|
111
|
+
readonly end: "turn.end";
|
|
112
|
+
readonly decision: "turn.decision";
|
|
113
|
+
};
|
|
114
|
+
export declare const context: {
|
|
115
|
+
readonly prepare: "context.prepare";
|
|
116
|
+
};
|
|
117
|
+
export declare const tools: {
|
|
118
|
+
readonly select: "tools.select";
|
|
119
|
+
};
|
|
120
|
+
export declare const model: {
|
|
121
|
+
readonly select: "model.select";
|
|
122
|
+
readonly request: "model.request";
|
|
123
|
+
readonly start: "model.start";
|
|
124
|
+
readonly end: "model.end";
|
|
125
|
+
readonly response: "model.response";
|
|
126
|
+
readonly usage: "model.usage";
|
|
127
|
+
readonly error: "model.error";
|
|
128
|
+
readonly recover: "model.recover";
|
|
129
|
+
};
|
|
130
|
+
export declare const message: {
|
|
131
|
+
readonly prepare: "message.prepare";
|
|
132
|
+
readonly beforeCommit: "message.before-commit";
|
|
133
|
+
readonly delta: "message.delta";
|
|
134
|
+
readonly committed: "message.committed";
|
|
135
|
+
};
|
|
136
|
+
export declare const tool: {
|
|
137
|
+
readonly prepare: "tool.prepare";
|
|
138
|
+
readonly before: "tool.before";
|
|
139
|
+
readonly start: "tool.start";
|
|
140
|
+
readonly update: "tool.update";
|
|
141
|
+
readonly end: "tool.end";
|
|
142
|
+
readonly error: "tool.error";
|
|
143
|
+
readonly result: "tool.result";
|
|
144
|
+
};
|
|
145
|
+
export declare const checkpoint: {
|
|
146
|
+
readonly committed: "checkpoint.committed";
|
|
90
147
|
};
|
|
91
148
|
type Transform<P> = HookSpec<P, P, ExecutionHookContext>;
|
|
92
149
|
type Decision<P> = HookSpec<P, ControlDecision, DecisionHookContext>;
|
|
93
150
|
declare module "./definition.js" {
|
|
94
151
|
interface EventMap {
|
|
152
|
+
"session.model.before-change": HookSpec<{
|
|
153
|
+
previous: ModelRef;
|
|
154
|
+
model: ModelRef;
|
|
155
|
+
}, OperationDecision, SessionHookContext>;
|
|
156
|
+
"session.thread.before-switch": HookSpec<{
|
|
157
|
+
previousThreadId: string | null;
|
|
158
|
+
threadId: string;
|
|
159
|
+
}, OperationDecision, SessionHookContext>;
|
|
160
|
+
"thread.before-fork": HookSpec<{
|
|
161
|
+
threadId: string;
|
|
162
|
+
options: ForkOptions;
|
|
163
|
+
}, OperationDecision, ThreadHookContext>;
|
|
164
|
+
"thread.before-rename": HookSpec<{
|
|
165
|
+
threadId: string;
|
|
166
|
+
title: string;
|
|
167
|
+
}, OperationDecision, ThreadHookContext>;
|
|
168
|
+
"thread.before-delete": HookSpec<{
|
|
169
|
+
threadId: string;
|
|
170
|
+
permanent?: boolean;
|
|
171
|
+
}, OperationDecision, ThreadHookContext>;
|
|
172
|
+
"thread.forked": HookSpec<{
|
|
173
|
+
threadId: string;
|
|
174
|
+
forkedThreadId: string;
|
|
175
|
+
}, void, ThreadHookContext>;
|
|
176
|
+
"thread.renamed": HookSpec<{
|
|
177
|
+
threadId: string;
|
|
178
|
+
title: string;
|
|
179
|
+
}, void, ThreadHookContext>;
|
|
180
|
+
"thread.deleted": HookSpec<{
|
|
181
|
+
threadId: string;
|
|
182
|
+
permanent?: boolean;
|
|
183
|
+
}, void, ThreadHookContext>;
|
|
184
|
+
"session.created": HookSpec<{
|
|
185
|
+
model: ModelRef;
|
|
186
|
+
}, void, SessionHookContext>;
|
|
187
|
+
"session.model-changed": HookSpec<{
|
|
188
|
+
previous: ModelRef;
|
|
189
|
+
model: ModelRef;
|
|
190
|
+
}, void, SessionHookContext>;
|
|
191
|
+
"session.thread-created": HookSpec<{
|
|
192
|
+
threadId: string;
|
|
193
|
+
}, void, SessionHookContext>;
|
|
194
|
+
"session.thread-switched": HookSpec<{
|
|
195
|
+
previousThreadId: string | null;
|
|
196
|
+
threadId: string;
|
|
197
|
+
}, void, SessionHookContext>;
|
|
198
|
+
"session.thread-renamed": HookSpec<{
|
|
199
|
+
threadId: string;
|
|
200
|
+
title: string;
|
|
201
|
+
}, void, SessionHookContext>;
|
|
202
|
+
"session.thread-forked": HookSpec<{
|
|
203
|
+
sourceThreadId: string;
|
|
204
|
+
threadId: string;
|
|
205
|
+
}, void, SessionHookContext>;
|
|
206
|
+
"session.thread-deleted": HookSpec<{
|
|
207
|
+
threadId: string;
|
|
208
|
+
}, void, SessionHookContext>;
|
|
209
|
+
"session.input-queued": HookSpec<{
|
|
210
|
+
receipt: QueuedInputReceipt;
|
|
211
|
+
}, void, SessionHookContext>;
|
|
212
|
+
"session.input-discarded": HookSpec<{
|
|
213
|
+
receipt: QueuedInputReceipt;
|
|
214
|
+
cause: string;
|
|
215
|
+
}, void, SessionHookContext>;
|
|
216
|
+
"session.before-close": HookSpec<{}, void, SessionHookContext>;
|
|
217
|
+
"session.closed": HookSpec<{}, void, SessionHookContext>;
|
|
95
218
|
diagnostic: HookSpec<{
|
|
96
219
|
error: ErrorInfo;
|
|
97
220
|
}>;
|
|
@@ -205,14 +328,14 @@ declare module "./definition.js" {
|
|
|
205
328
|
"tool.end": HookSpec<{
|
|
206
329
|
toolExecutionId: string;
|
|
207
330
|
toolCallId: string;
|
|
208
|
-
result:
|
|
331
|
+
result: MessageData;
|
|
209
332
|
status: string;
|
|
210
333
|
}>;
|
|
211
334
|
"tool.error": HookSpec<{
|
|
212
335
|
toolExecutionId: string;
|
|
213
336
|
error: ErrorInfo;
|
|
214
337
|
}>;
|
|
215
|
-
"tool.result": Transform<
|
|
338
|
+
"tool.result": Transform<MessageData>;
|
|
216
339
|
"stream.cancel": HookSpec<{
|
|
217
340
|
reason: string;
|
|
218
341
|
}>;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
export const ready = "ready";
|
|
2
|
+
export const shutdown = "shutdown";
|
|
3
|
+
export const diagnostic = "diagnostic";
|
|
4
|
+
export const thread = {
|
|
5
|
+
prepare: "thread.prepare",
|
|
6
|
+
started: "thread.started",
|
|
7
|
+
beforeShutdown: "thread.before-shutdown",
|
|
8
|
+
shutdown: "thread.shutdown",
|
|
9
|
+
updated: "thread.updated",
|
|
10
|
+
beforeFork: "thread.before-fork",
|
|
11
|
+
forked: "thread.forked",
|
|
12
|
+
beforeRename: "thread.before-rename",
|
|
13
|
+
renamed: "thread.renamed",
|
|
14
|
+
beforeDelete: "thread.before-delete",
|
|
15
|
+
deleted: "thread.deleted",
|
|
16
|
+
};
|
|
17
|
+
export const session = {
|
|
18
|
+
created: "session.created",
|
|
19
|
+
modelChanged: "session.model-changed",
|
|
20
|
+
threadCreated: "session.thread-created",
|
|
21
|
+
threadSwitched: "session.thread-switched",
|
|
22
|
+
threadRenamed: "session.thread-renamed",
|
|
23
|
+
threadForked: "session.thread-forked",
|
|
24
|
+
threadDeleted: "session.thread-deleted",
|
|
25
|
+
inputQueued: "session.input-queued",
|
|
26
|
+
inputDiscarded: "session.input-discarded",
|
|
27
|
+
beforeClose: "session.before-close",
|
|
28
|
+
closed: "session.closed",
|
|
29
|
+
model: {
|
|
30
|
+
beforeChange: "session.model.before-change",
|
|
31
|
+
},
|
|
32
|
+
thread: {
|
|
33
|
+
beforeSwitch: "session.thread.before-switch",
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
export const input = {
|
|
37
|
+
prepare: "input.prepare",
|
|
38
|
+
received: "input.received",
|
|
39
|
+
};
|
|
40
|
+
export const stream = {
|
|
41
|
+
before: "stream.before",
|
|
42
|
+
started: "stream.started",
|
|
43
|
+
beforeEnd: "stream.before-end",
|
|
44
|
+
end: "stream.end",
|
|
45
|
+
error: "stream.error",
|
|
46
|
+
suspended: "stream.suspended",
|
|
47
|
+
resumed: "stream.resumed",
|
|
48
|
+
cancel: "stream.cancel",
|
|
49
|
+
};
|
|
50
|
+
export const turn = {
|
|
51
|
+
start: "turn.start",
|
|
52
|
+
end: "turn.end",
|
|
53
|
+
decision: "turn.decision",
|
|
54
|
+
};
|
|
55
|
+
export const context = {
|
|
56
|
+
prepare: "context.prepare",
|
|
57
|
+
};
|
|
58
|
+
export const tools = {
|
|
59
|
+
select: "tools.select",
|
|
60
|
+
};
|
|
61
|
+
export const model = {
|
|
62
|
+
select: "model.select",
|
|
63
|
+
request: "model.request",
|
|
64
|
+
start: "model.start",
|
|
65
|
+
end: "model.end",
|
|
66
|
+
response: "model.response",
|
|
67
|
+
usage: "model.usage",
|
|
68
|
+
error: "model.error",
|
|
69
|
+
recover: "model.recover",
|
|
70
|
+
};
|
|
71
|
+
export const message = {
|
|
72
|
+
prepare: "message.prepare",
|
|
73
|
+
beforeCommit: "message.before-commit",
|
|
74
|
+
delta: "message.delta",
|
|
75
|
+
committed: "message.committed",
|
|
76
|
+
};
|
|
77
|
+
export const tool = {
|
|
78
|
+
prepare: "tool.prepare",
|
|
79
|
+
before: "tool.before",
|
|
80
|
+
start: "tool.start",
|
|
81
|
+
update: "tool.update",
|
|
82
|
+
end: "tool.end",
|
|
83
|
+
error: "tool.error",
|
|
84
|
+
result: "tool.result",
|
|
85
|
+
};
|
|
86
|
+
export const checkpoint = {
|
|
87
|
+
committed: "checkpoint.committed",
|
|
88
|
+
};
|
|
89
|
+
/** Dispatch behavior is internal metadata; public event identifiers are strings. */
|
|
90
|
+
export const hookKinds = Object.freeze({
|
|
91
|
+
ready: "notification",
|
|
92
|
+
shutdown: "barrier",
|
|
93
|
+
diagnostic: "notification",
|
|
94
|
+
"thread.prepare": "transformation",
|
|
95
|
+
"thread.started": "notification",
|
|
96
|
+
"thread.before-shutdown": "barrier",
|
|
97
|
+
"thread.shutdown": "notification",
|
|
98
|
+
"thread.updated": "notification",
|
|
99
|
+
"thread.before-fork": "decision",
|
|
100
|
+
"thread.forked": "notification",
|
|
101
|
+
"thread.before-rename": "decision",
|
|
102
|
+
"thread.renamed": "notification",
|
|
103
|
+
"thread.before-delete": "decision",
|
|
104
|
+
"thread.deleted": "notification",
|
|
105
|
+
"session.created": "notification",
|
|
106
|
+
"session.model-changed": "notification",
|
|
107
|
+
"session.thread-created": "notification",
|
|
108
|
+
"session.thread-switched": "notification",
|
|
109
|
+
"session.thread-renamed": "notification",
|
|
110
|
+
"session.thread-forked": "notification",
|
|
111
|
+
"session.thread-deleted": "notification",
|
|
112
|
+
"session.input-queued": "notification",
|
|
113
|
+
"session.input-discarded": "notification",
|
|
114
|
+
"session.before-close": "barrier",
|
|
115
|
+
"session.closed": "notification",
|
|
116
|
+
"session.model.before-change": "decision",
|
|
117
|
+
"session.thread.before-switch": "decision",
|
|
118
|
+
"input.prepare": "transformation",
|
|
119
|
+
"input.received": "notification",
|
|
120
|
+
"stream.before": "decision",
|
|
121
|
+
"stream.started": "notification",
|
|
122
|
+
"stream.before-end": "barrier",
|
|
123
|
+
"stream.end": "notification",
|
|
124
|
+
"stream.error": "notification",
|
|
125
|
+
"stream.suspended": "notification",
|
|
126
|
+
"stream.resumed": "notification",
|
|
127
|
+
"stream.cancel": "notification",
|
|
128
|
+
"turn.start": "notification",
|
|
129
|
+
"turn.end": "notification",
|
|
130
|
+
"turn.decision": "decision",
|
|
131
|
+
"context.prepare": "transformation",
|
|
132
|
+
"tools.select": "transformation",
|
|
133
|
+
"model.select": "decision",
|
|
134
|
+
"model.request": "transformation",
|
|
135
|
+
"model.start": "notification",
|
|
136
|
+
"model.end": "notification",
|
|
137
|
+
"model.response": "transformation",
|
|
138
|
+
"model.usage": "notification",
|
|
139
|
+
"model.error": "notification",
|
|
140
|
+
"model.recover": "decision",
|
|
141
|
+
"message.prepare": "transformation",
|
|
142
|
+
"message.before-commit": "barrier",
|
|
143
|
+
"message.delta": "notification",
|
|
144
|
+
"message.committed": "notification",
|
|
145
|
+
"tool.prepare": "transformation",
|
|
146
|
+
"tool.before": "decision",
|
|
147
|
+
"tool.start": "notification",
|
|
148
|
+
"tool.update": "notification",
|
|
149
|
+
"tool.end": "notification",
|
|
150
|
+
"tool.error": "notification",
|
|
151
|
+
"tool.result": "transformation",
|
|
152
|
+
"checkpoint.committed": "notification",
|
|
153
|
+
});
|
|
154
|
+
export const ToolDecision = {
|
|
155
|
+
allow: () => ({ decision: "allow" }),
|
|
156
|
+
deny: (reason) => ({ decision: "deny", reason }),
|
|
157
|
+
};
|
|
158
|
+
export const TurnDecision = {
|
|
159
|
+
continue: () => ({ decision: "continue" }),
|
|
160
|
+
stop: (reason) => ({ decision: "stop", reason }),
|
|
161
|
+
};
|
|
162
|
+
export const InputDecision = {
|
|
163
|
+
continue: (messages) => ({
|
|
164
|
+
messages,
|
|
165
|
+
}),
|
|
166
|
+
handled: (outcome) => ({
|
|
167
|
+
messages: [],
|
|
168
|
+
handled: outcome,
|
|
169
|
+
}),
|
|
170
|
+
reject: (error) => ({
|
|
171
|
+
messages: [],
|
|
172
|
+
rejected: error,
|
|
173
|
+
}),
|
|
174
|
+
};
|
|
175
|
+
//# sourceMappingURL=type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/events/type.ts"],"names":[],"mappings":"AAmEA,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAC;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C,aAAa,EAAE,UAAU;IACzB,YAAY,EAAE,cAAc;IAC5B,aAAa,EAAE,cAAc;IAC7B,UAAU,EAAE,cAAc;IAC1B,YAAY,EAAE,cAAc;IAC5B,aAAa,EAAE,gBAAgB;IAC/B,sBAAsB,EAAE,cAAc;CACvC,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,KAAK,EAAE,GAAoB,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;IACrD,IAAI,EAAE,CAAC,MAAc,EAAmB,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;CAC1E,CAAC;AACF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,QAAQ,EAAE,GAAoB,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;IAC3D,IAAI,EAAE,CAAC,MAAc,EAAmB,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;CAC1E,CAAC;AACF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,QAAQ,EAAE,CAAC,QAAgC,EAAoB,EAAE,CAAC,CAAC;QACjE,QAAQ;KACT,CAAC;IACF,OAAO,EAAE,CAAC,OAA2C,EAAoB,EAAE,CAAC,CAAC;QAC3E,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE,OAAO;KACjB,CAAC;IACF,MAAM,EAAE,CAAC,KAAgB,EAAoB,EAAE,CAAC,CAAC;QAC/C,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,KAAK;KAChB,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function reserveId(kind: "Agent" | "Controller", id: string, instance: object): () => void;
|
package/dist/identity.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { fail } from "./errors.js";
|
|
2
|
+
const agents = new Map();
|
|
3
|
+
const controllers = new Map();
|
|
4
|
+
function release({ entries, id, reference }) {
|
|
5
|
+
if (entries.get(id) === reference)
|
|
6
|
+
entries.delete(id);
|
|
7
|
+
}
|
|
8
|
+
// Track identity without keeping otherwise-unused SDK instances alive.
|
|
9
|
+
const collected = new FinalizationRegistry(release);
|
|
10
|
+
export function reserveId(kind, id, instance) {
|
|
11
|
+
const entries = kind === "Agent" ? agents : controllers;
|
|
12
|
+
if (entries.get(id)?.deref())
|
|
13
|
+
fail("RegistrationConflict", `${kind} ID already in use: ${id}`);
|
|
14
|
+
const reference = new WeakRef(instance);
|
|
15
|
+
const reservation = { entries, id, reference };
|
|
16
|
+
entries.set(id, reference);
|
|
17
|
+
collected.register(instance, reservation, reference);
|
|
18
|
+
return () => {
|
|
19
|
+
release(reservation);
|
|
20
|
+
collected.unregister(reference);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAOnC,MAAM,MAAM,GAAG,IAAI,GAAG,EAA2B,CAAC;AAClD,MAAM,WAAW,GAAG,IAAI,GAAG,EAA2B,CAAC;AACvD,SAAS,OAAO,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAe;IACtD,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,SAAS;QAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACxD,CAAC;AACD,uEAAuE;AACvE,MAAM,SAAS,GAAG,IAAI,oBAAoB,CAAc,OAAO,CAAC,CAAC;AAEjE,MAAM,UAAU,SAAS,CACvB,IAA4B,EAC5B,EAAU,EACV,QAAgB;IAEhB,MAAM,OAAO,GAAG,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC;IACxD,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE;QAC1B,IAAI,CAAC,sBAAsB,EAAE,GAAG,IAAI,uBAAuB,EAAE,EAAE,CAAC,CAAC;IACnE,MAAM,SAAS,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxC,MAAM,WAAW,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;IAC3B,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IACrD,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,WAAW,CAAC,CAAC;QACrB,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export * from "./messages/message.js";
|
|
|
5
5
|
export * from "./messages/codec.js";
|
|
6
6
|
export * from "./instructions/instruction.js";
|
|
7
7
|
export * from "./events/definition.js";
|
|
8
|
-
export * from "./events/
|
|
8
|
+
export * from "./events/type.js";
|
|
9
9
|
export * from "./plugins/context.js";
|
|
10
10
|
export * from "./plugins/host.js";
|
|
11
11
|
export * from "./plugins/registry.js";
|
|
@@ -30,5 +30,7 @@ export * from "./agent.js";
|
|
|
30
30
|
export * from "./controller.js";
|
|
31
31
|
export * from "./thread.js";
|
|
32
32
|
export * from "./models/registry.js";
|
|
33
|
+
export { ProfileResolver } from "./models/resolver.js";
|
|
34
|
+
export { snapshotModelOptions } from "./models/options.js";
|
|
33
35
|
export * from "./session.js";
|
|
34
|
-
export * from "./
|
|
36
|
+
export * from "./state/sessions.js";
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ export * from "./messages/message.js";
|
|
|
5
5
|
export * from "./messages/codec.js";
|
|
6
6
|
export * from "./instructions/instruction.js";
|
|
7
7
|
export * from "./events/definition.js";
|
|
8
|
-
export * from "./events/
|
|
8
|
+
export * from "./events/type.js";
|
|
9
9
|
export * from "./plugins/context.js";
|
|
10
10
|
export * from "./plugins/host.js";
|
|
11
11
|
export * from "./plugins/registry.js";
|
|
@@ -30,6 +30,8 @@ export * from "./agent.js";
|
|
|
30
30
|
export * from "./controller.js";
|
|
31
31
|
export * from "./thread.js";
|
|
32
32
|
export * from "./models/registry.js";
|
|
33
|
+
export { ProfileResolver } from "./models/resolver.js";
|
|
34
|
+
export { snapshotModelOptions } from "./models/options.js";
|
|
33
35
|
export * from "./session.js";
|
|
34
|
-
export * from "./
|
|
36
|
+
export * from "./state/sessions.js";
|
|
35
37
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,cAAc,cAAc,CAAC;AAE7B,cAAc,qBAAqB,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export interface InstructionSection {
|
|
2
2
|
readonly id: string;
|
|
3
3
|
readonly content: string;
|
|
4
|
+
/** Lower values come first; omitted values compare as zero. IDs break ties. */
|
|
5
|
+
readonly order?: number;
|
|
4
6
|
}
|
|
5
7
|
export interface Instruction {
|
|
6
8
|
readonly sections: readonly InstructionSection[];
|
|
@@ -4,11 +4,18 @@ export function buildInstruction(sections) {
|
|
|
4
4
|
const ids = new Set();
|
|
5
5
|
for (const section of sections) {
|
|
6
6
|
requireId(section.id, "section id");
|
|
7
|
-
if (typeof section.content !== "string" ||
|
|
8
|
-
|
|
7
|
+
if (typeof section.content !== "string" ||
|
|
8
|
+
ids.has(section.id) ||
|
|
9
|
+
(section.order !== undefined && !Number.isFinite(section.order)))
|
|
10
|
+
fail("InvalidConfiguration", "Instruction sections need unique ids, string content and finite numeric order");
|
|
9
11
|
ids.add(section.id);
|
|
10
12
|
}
|
|
11
|
-
return immutable({
|
|
13
|
+
return immutable({
|
|
14
|
+
sections: sections
|
|
15
|
+
.map(({ order, ...section }) => order === undefined ? section : { ...section, order })
|
|
16
|
+
.sort((a, b) => (a.order ?? 0) - (b.order ?? 0) ||
|
|
17
|
+
(a.id < b.id ? -1 : a.id > b.id ? 1 : 0)),
|
|
18
|
+
});
|
|
12
19
|
}
|
|
13
20
|
export function normalizeInstruction(value = "") {
|
|
14
21
|
return buildInstruction(typeof value === "string"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instruction.js","sourceRoot":"","sources":["../../src/instructions/instruction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"instruction.js","sourceRoot":"","sources":["../../src/instructions/instruction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAUvC,MAAM,UAAU,gBAAgB,CAC9B,QAAuC;IAEvC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,SAAS,CAAC,OAAO,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;QACpC,IACE,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ;YACnC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YACnB,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAEhE,IAAI,CACF,sBAAsB,EACtB,+EAA+E,CAChF,CAAC;QACJ,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,SAAS,CAAC;QACf,QAAQ,EAAE,QAAQ;aACf,GAAG,CAAqB,CAAC,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,EAAE,EAAE,CACjD,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CACtD;aACA,IAAI,CACH,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACP,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;YAC/B,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC3C;KACJ,CAAC,CAAC;AACL,CAAC;AACD,MAAM,UAAU,oBAAoB,CAClC,KAAK,GAAyB,EAAE;IAEhC,OAAO,gBAAgB,CACrB,OAAO,KAAK,KAAK,QAAQ;QACvB,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QACrC,CAAC,CAAC,KAAK,CAAC,QAAQ,CACnB,CAAC;AACJ,CAAC"}
|
package/dist/loop.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import type { ExecutionFrame } from "./
|
|
1
|
+
import type { ExecutionFrame } from "./engine/frame.js";
|
|
2
2
|
import { type Clock, type IdGenerator } from "./json.js";
|
|
3
3
|
import type { AnyEvent, PayloadOf, ResultOf } from "./events/definition.js";
|
|
4
|
-
import {
|
|
4
|
+
import type { MessageData } from "./messages/message.js";
|
|
5
5
|
import type { CheckpointCause, RecordEntry } from "./state/schema.js";
|
|
6
6
|
import type { TrackedServices } from "./engine/tracked-effects.js";
|
|
7
|
-
type LoopContext = {
|
|
7
|
+
export type LoopContext = {
|
|
8
|
+
toolConcurrency: number;
|
|
8
9
|
ids: IdGenerator;
|
|
9
10
|
clock: Clock;
|
|
10
|
-
hook<D extends AnyEvent>(frame: ExecutionFrame, definition: D, payload: PayloadOf<D
|
|
11
|
+
hook<D extends AnyEvent>(frame: ExecutionFrame, definition: D, payload: PayloadOf<D>, toolExecutionId?: string): Promise<ResultOf<D>>;
|
|
11
12
|
put(frame: ExecutionFrame, kind: RecordEntry["kind"], data: RecordEntry["data"]): void;
|
|
12
13
|
rows<T>(frame: ExecutionFrame, kind: RecordEntry["kind"]): T[];
|
|
13
14
|
commit(frame: ExecutionFrame, cause: CheckpointCause): Promise<void>;
|
|
@@ -17,4 +18,3 @@ type LoopContext = {
|
|
|
17
18
|
finish(frame: ExecutionFrame, status: "completed" | "stopped", reason: string | null): Promise<void>;
|
|
18
19
|
};
|
|
19
20
|
export declare function loop(frame: ExecutionFrame, context: LoopContext): Promise<void>;
|
|
20
|
-
export {};
|