@rarebit-one/harness-kernel 0.10.0 → 0.11.0-next.1
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 +160 -6
- package/dist/agent.d.ts +117 -8
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +332 -25
- package/dist/agent.js.map +1 -1
- package/dist/engines/native.d.ts +5 -0
- package/dist/engines/native.d.ts.map +1 -1
- package/dist/engines/native.js +30 -10
- package/dist/engines/native.js.map +1 -1
- package/dist/engines/types.d.ts +31 -1
- package/dist/engines/types.d.ts.map +1 -1
- package/dist/events.d.ts +30 -2
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js.map +1 -1
- package/dist/index.d.ts +18 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/dist/loop.d.ts +60 -11
- package/dist/loop.d.ts.map +1 -1
- package/dist/loop.js +7 -5
- package/dist/loop.js.map +1 -1
- package/dist/models/chat.d.ts +2 -1
- package/dist/models/chat.d.ts.map +1 -1
- package/dist/models/chat.js +20 -4
- package/dist/models/chat.js.map +1 -1
- package/dist/models/types.d.ts +16 -0
- package/dist/models/types.d.ts.map +1 -1
- package/dist/models/types.js.map +1 -1
- package/dist/private.d.ts.map +1 -1
- package/dist/private.js +29 -1
- package/dist/private.js.map +1 -1
- package/dist/providers/anthropic.d.ts +30 -4
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +130 -29
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/index.d.ts +42 -6
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +132 -48
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/mock.d.ts +6 -3
- package/dist/providers/mock.d.ts.map +1 -1
- package/dist/providers/mock.js +9 -4
- package/dist/providers/mock.js.map +1 -1
- package/dist/providers/openai.d.ts +54 -8
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +164 -32
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/options.d.ts +177 -0
- package/dist/providers/options.d.ts.map +1 -0
- package/dist/providers/options.js +67 -0
- package/dist/providers/options.js.map +1 -0
- package/dist/providers/scripted.d.ts +49 -0
- package/dist/providers/scripted.d.ts.map +1 -0
- package/dist/providers/scripted.js +90 -0
- package/dist/providers/scripted.js.map +1 -0
- package/dist/providers/types.d.ts +60 -0
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/tools/metadata.d.ts +24 -0
- package/dist/tools/metadata.d.ts.map +1 -1
- package/dist/tools/metadata.js +8 -0
- package/dist/tools/metadata.js.map +1 -1
- package/dist/tools/registry.d.ts +10 -3
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/registry.js +9 -4
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/terminal.d.ts +33 -0
- package/dist/tools/terminal.d.ts.map +1 -0
- package/dist/tools/terminal.js +32 -0
- package/dist/tools/terminal.js.map +1 -0
- package/package.json +4 -3
package/dist/engines/native.js
CHANGED
|
@@ -3,7 +3,7 @@ import { assembleContext, renderContext } from "../context/types.js";
|
|
|
3
3
|
import { runEventEmitter } from "../events.js";
|
|
4
4
|
import { nativeLoop, runWithEvents } from "../loop.js";
|
|
5
5
|
import { asChatModel } from "../models/chat.js";
|
|
6
|
-
import { selectProvider } from "../providers/index.js";
|
|
6
|
+
import { providerAvailability, selectProvider } from "../providers/index.js";
|
|
7
7
|
import { secretsToEnv } from "../secrets.js";
|
|
8
8
|
import { primitiveTools, connectorTools } from "../tools/registry.js";
|
|
9
9
|
import { PrivateRunError, privateRunChannels } from "../private.js";
|
|
@@ -25,6 +25,11 @@ export class NativeEngine {
|
|
|
25
25
|
this.loop = options.loop ?? nativeLoop;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
+
* A run is refused here, with a reason, when its provider cannot be resolved
|
|
29
|
+
* to a credential: the same check `selectProvider` makes, surfaced before any
|
|
30
|
+
* sandbox is prepared. Set `provider.allowMockFallback` (or
|
|
31
|
+
* `provider.preferred: "mock"`) to run offline instead.
|
|
32
|
+
*
|
|
28
33
|
* A private run must stay on local inference, and that is a guarantee, not a
|
|
29
34
|
* preference: it is refused unless the run names the `local` provider AND the
|
|
30
35
|
* host has one configured. There is no fallback to a cloud provider found in
|
|
@@ -32,9 +37,11 @@ export class NativeEngine {
|
|
|
32
37
|
* that silently ran somewhere else, or not at all, would look like it worked.
|
|
33
38
|
*/
|
|
34
39
|
supports(spec) {
|
|
35
|
-
if (spec
|
|
40
|
+
if (!spec)
|
|
41
|
+
return { ok: true };
|
|
42
|
+
if (spec.private)
|
|
36
43
|
return privateProviderSupport(spec);
|
|
37
|
-
return
|
|
44
|
+
return providerAvailability(spec.provider.preferred, spec.provider);
|
|
38
45
|
}
|
|
39
46
|
async run(spec, ctx) {
|
|
40
47
|
if (!spec.private)
|
|
@@ -76,10 +83,10 @@ export class NativeEngine {
|
|
|
76
83
|
// never started its loop, so it emits no events.
|
|
77
84
|
if (ctx.signal?.aborted)
|
|
78
85
|
return canceledBeforeLoop(ctx);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
86
|
+
// The whole selection, not a hand-picked subset: `supports()` judged the
|
|
87
|
+
// run on `spec.provider` (including `allowMockFallback`), so `run()` must
|
|
88
|
+
// resolve it from the same object or the two can disagree.
|
|
89
|
+
const provider = selectProvider(spec.provider.preferred, spec.provider);
|
|
83
90
|
// Belt and braces for the private path: whatever selection did, a private
|
|
84
91
|
// run proceeds on the local provider or not at all.
|
|
85
92
|
if (spec.private && provider.name !== "local") {
|
|
@@ -126,12 +133,14 @@ export class NativeEngine {
|
|
|
126
133
|
throw err;
|
|
127
134
|
return canceledBeforeLoop(ctx);
|
|
128
135
|
}
|
|
136
|
+
const model = asChatModel(provider);
|
|
129
137
|
const result = await runWithEvents(this.loop, {
|
|
130
|
-
model
|
|
138
|
+
model,
|
|
131
139
|
system: buildSystemPrompt(spec.workflow, spec.workspaceId, spec.workflowPath),
|
|
132
|
-
|
|
140
|
+
messages: [{ role: "user", text: buildUserPrompt(spec.workflow, context, spec.inputs) }],
|
|
133
141
|
tools,
|
|
134
142
|
limits: resolveLoopLimits(spec.limits),
|
|
143
|
+
...(spec.providerOptions ? { providerOptions: spec.providerOptions } : {}),
|
|
135
144
|
},
|
|
136
145
|
// The bookends come from `runWithEvents`, so an application's own loop
|
|
137
146
|
// gets them without having to know they exist.
|
|
@@ -141,7 +150,18 @@ export class NativeEngine {
|
|
|
141
150
|
runId: spec.runId,
|
|
142
151
|
...(ctx.signal ? { signal: ctx.signal } : {}),
|
|
143
152
|
});
|
|
144
|
-
|
|
153
|
+
// Observed, not predicted: the loop says what served it. A custom loop
|
|
154
|
+
// that reports nothing falls back to the adapter this engine selected.
|
|
155
|
+
const served = result.model ?? provider.model;
|
|
156
|
+
return {
|
|
157
|
+
text: result.text,
|
|
158
|
+
outcome: result.outcome,
|
|
159
|
+
...(result.stopReason !== undefined ? { stopReason: result.stopReason } : {}),
|
|
160
|
+
...(result.finishReason !== undefined ? { finishReason: result.finishReason } : {}),
|
|
161
|
+
provider: result.provider ?? model.id,
|
|
162
|
+
...(served !== undefined ? { model: served } : {}),
|
|
163
|
+
...(result.upstream !== undefined ? { upstream: result.upstream } : {}),
|
|
164
|
+
};
|
|
145
165
|
}
|
|
146
166
|
finally {
|
|
147
167
|
// Connectors are only needed during the loop; close them here (the engine
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.js","sourceRoot":"","sources":["../../src/engines/native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAwB,MAAM,qBAAqB,CAAA;AAC1F,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAa,MAAM,YAAY,CAAA;AACjE,OAAO,EAAE,WAAW,EA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AAS,iBAAiB,CACxB,QAA4B,EAC5B,WAAmB,EACnB,YAAoB;IAEpB,OAAO;QACL,4EAA4E;QAC5E,cAAc,WAAW,EAAE;QAC3B,aAAa,QAAQ,CAAC,IAAI,IAAI,YAAY,EAAE;QAC5C,+EAA+E;QAC/E,sEAAsE;QACtE,8EAA8E;QAC9E,4EAA4E;QAC5E,qCAAqC;KACtC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACd,CAAC;AAED,SAAS,eAAe,CACtB,QAA4B,EAC5B,OAAe,EACf,MAA+B;IAE/B,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IACxD,OAAO;QACL,QAAQ,CAAC,MAAM,IAAI,gBAAgB,QAAQ,CAAC,IAAI,aAAa;QAC7D,EAAE;QACF,WAAW;QACX,SAAS;QACT,UAAU;QACV,KAAK;QACL,EAAE;QACF,sBAAsB;QACtB,OAAO,IAAI,4BAA4B;KACxC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACd,CAAC"}
|
package/dist/engines/types.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { RunEventSink, RunOutcome } from "../events.js";
|
|
1
|
+
import type { RunEventSink, RunOutcome, StopReason } from "../events.js";
|
|
2
2
|
import type { ProviderSelection } from "../providers/index.js";
|
|
3
|
+
import type { ProviderOptions } from "../providers/options.js";
|
|
4
|
+
import type { FinishReason } from "../providers/types.js";
|
|
3
5
|
import type { ConnectorConfig, Permissions, WorkflowDefinition } from "../types.js";
|
|
4
6
|
import type { Isolation } from "./isolation.js";
|
|
5
7
|
/**
|
|
@@ -41,6 +43,13 @@ export interface RunSpec {
|
|
|
41
43
|
maxSteps?: number;
|
|
42
44
|
maxDurationMs?: number;
|
|
43
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Per-call provider options for the run's model calls (prompt caching,
|
|
48
|
+
* token cap, OpenRouter routing). The native engine sends them on every
|
|
49
|
+
* call; an out-of-process engine, which brings its own model client,
|
|
50
|
+
* ignores them like it ignores `limits`.
|
|
51
|
+
*/
|
|
52
|
+
providerOptions?: ProviderOptions;
|
|
44
53
|
/**
|
|
45
54
|
* How strongly the caller isolated this run from every other run on the host:
|
|
46
55
|
* `none` (a shared process), `container` (one per run) or `vm` (a microVM per
|
|
@@ -119,6 +128,27 @@ export interface EngineResult {
|
|
|
119
128
|
* `failed`). Optional so an engine that cannot tell stays honest by omitting it.
|
|
120
129
|
*/
|
|
121
130
|
outcome?: RunOutcome;
|
|
131
|
+
/**
|
|
132
|
+
* One level finer than `outcome`, when the engine's loop reported it. A
|
|
133
|
+
* `completed` run with `stopReason: "length"` is a prose answer the output
|
|
134
|
+
* cap cut short, which a caller must not apply as if it were whole; the
|
|
135
|
+
* native engine always sets this, so that distinction reaches the engine
|
|
136
|
+
* API and not only `runConversation`.
|
|
137
|
+
*/
|
|
138
|
+
stopReason?: StopReason;
|
|
139
|
+
/** Why the last model call stopped generating, when reported. */
|
|
140
|
+
finishReason?: FinishReason;
|
|
141
|
+
/**
|
|
142
|
+
* The adapter that served the run (`"anthropic"`, `"openrouter"`, `"mock"`,
|
|
143
|
+
* …), observed from inside the run rather than predicted from its inputs.
|
|
144
|
+
* The native engine always reports it; an out-of-process engine brings its
|
|
145
|
+
* own model and credential, so it omits it rather than guess.
|
|
146
|
+
*/
|
|
147
|
+
provider?: string;
|
|
148
|
+
/** The model id the run's last response named, else the adapter's configured model. */
|
|
149
|
+
model?: string;
|
|
150
|
+
/** Behind an aggregator, the upstream that served the run's last response. */
|
|
151
|
+
upstream?: string;
|
|
122
152
|
}
|
|
123
153
|
/** The outcome of an engine's capability check for a given run. */
|
|
124
154
|
export type EngineSupport = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/engines/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,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Aa,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;CAC9D"}
|
package/dist/events.d.ts
CHANGED
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
* context providers.
|
|
29
29
|
*/
|
|
30
30
|
import type { Usage } from "./models/types.js";
|
|
31
|
+
import type { FinishReason } from "./providers/types.js";
|
|
31
32
|
/** Every event kind the loop emits. */
|
|
32
33
|
export type RunEventType = "run.started" | "model.turn" | "model.turn.failed" | "tool.called" | "tool.succeeded" | "tool.failed" | "run.budget_exhausted" | "run.finished";
|
|
33
34
|
/**
|
|
@@ -60,6 +61,20 @@ export interface RunEventBase {
|
|
|
60
61
|
* a throw.
|
|
61
62
|
*/
|
|
62
63
|
export type RunOutcome = "completed" | "steps_exhausted" | "timed_out" | "canceled" | "failed";
|
|
64
|
+
/**
|
|
65
|
+
* Why the loop stopped, one level finer than {@link RunOutcome}. `end_turn` and
|
|
66
|
+
* `terminal_tool` both map to `outcome: "completed"`: the model finished of its
|
|
67
|
+
* own accord either by answering in prose or by calling a terminal tool, and a
|
|
68
|
+
* consumer that only cares whether the run finished reads `outcome`. The rest
|
|
69
|
+
* mirror their outcome. `RunOutcome` stays the coarse, wire-stable vocabulary;
|
|
70
|
+
* this is where a finer reason is added (a suspended run awaiting external
|
|
71
|
+
* tool results, say) without touching every consumer's outcome switch.
|
|
72
|
+
* `failed` is here for the same reason it is on `RunOutcome`: the native loop
|
|
73
|
+
* throws instead, but a custom loop may report it. `length` is a prose answer
|
|
74
|
+
* the output token cap cut short: the run `completed`, but a consumer should
|
|
75
|
+
* not apply the text as if it were whole.
|
|
76
|
+
*/
|
|
77
|
+
export type StopReason = "end_turn" | "terminal_tool" | "length" | "steps_exhausted" | "timed_out" | "canceled" | "failed";
|
|
63
78
|
/**
|
|
64
79
|
* Whether a tool's effect is safe to execute again after an interruption,
|
|
65
80
|
* copied from `ToolMetadata.replay`. Absent means the tool made no claim, which
|
|
@@ -89,6 +104,14 @@ export interface ModelTurnEvent extends RunEventBase {
|
|
|
89
104
|
/** What the turn cost, when the model reported it (`ModelResult.usage`).
|
|
90
105
|
* Absent means "not reported", never "free". */
|
|
91
106
|
usage?: Usage;
|
|
107
|
+
/** The model id the response was served by, when the provider reported it. */
|
|
108
|
+
model?: string;
|
|
109
|
+
/** The provider's id for the response (message / completion / generation id), when reported. */
|
|
110
|
+
responseId?: string;
|
|
111
|
+
/** Behind an aggregator, the upstream that served the request (OpenRouter's response-level `provider`). */
|
|
112
|
+
upstream?: string;
|
|
113
|
+
/** Why the model stopped generating, when the provider reported it. */
|
|
114
|
+
finishReason?: FinishReason;
|
|
92
115
|
}
|
|
93
116
|
/**
|
|
94
117
|
* A model invocation failed and the loop **absorbed** it: the run carries on
|
|
@@ -170,13 +193,16 @@ export interface ToolSucceededEvent extends RunEventBase {
|
|
|
170
193
|
* `threw` because they mean different things to a consumer: one is a model
|
|
171
194
|
* hallucinating a name, the other is a real effect that may have partially
|
|
172
195
|
* landed. `aborted` is a tool stopped by the run's cancel or deadline — its
|
|
173
|
-
* effect may also have partially landed, but the tool did not fail.
|
|
196
|
+
* effect may also have partially landed, but the tool did not fail.
|
|
197
|
+
* `truncated` is a call the loop refused to run because the output token cap
|
|
198
|
+
* cut it off (a terminal call on a `length` turn, or arguments that do not
|
|
199
|
+
* parse); nothing ran, and the model was told to answer again. */
|
|
174
200
|
export interface ToolFailedEvent extends RunEventBase {
|
|
175
201
|
type: "tool.failed";
|
|
176
202
|
step: number;
|
|
177
203
|
callId: string;
|
|
178
204
|
name: string;
|
|
179
|
-
reason: "threw" | "unknown_tool" | "aborted";
|
|
205
|
+
reason: "threw" | "unknown_tool" | "aborted" | "truncated";
|
|
180
206
|
error: string;
|
|
181
207
|
}
|
|
182
208
|
/** A budget was exhausted. Emitted at the moment the loop notices, which for
|
|
@@ -200,6 +226,8 @@ export interface RunBudgetExhaustedEvent extends RunEventBase {
|
|
|
200
226
|
export interface RunFinishedEvent extends RunEventBase {
|
|
201
227
|
type: "run.finished";
|
|
202
228
|
outcome: RunOutcome;
|
|
229
|
+
/** The loop's finer stop reason, when it reported one (the native loop always does). */
|
|
230
|
+
stopReason?: StopReason;
|
|
203
231
|
steps?: number;
|
|
204
232
|
text?: string;
|
|
205
233
|
/** Present when `outcome` is `failed`, and when a loop THREW on a caller
|
package/dist/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD,uCAAuC;AACvC,MAAM,MAAM,YAAY,GACpB,aAAa,GACb,YAAY,GACZ,mBAAmB,GACnB,aAAa,GACb,gBAAgB,GAChB,aAAa,GACb,sBAAsB,GACtB,cAAc,CAAA;AAElB;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,EAAE,EAAE,MAAM,CAAA;IACV;;;;OAIG;IACH,QAAQ,CAAC,EAAE,IAAI,CAAA;CAChB;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,iBAAiB,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAA;AAE9F;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,UAAU,GACpB,UAAU,GAAG,eAAe,GAAG,QAAQ,GAAG,iBAAiB,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAA;AAEnG;;;;GAIG;AACH,MAAM,MAAM,UAAU,GA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GAMG;AACH,wBAAgB,eAAe,CAC7B,IAAI,CAAC,EAAE,YAAY,EACnB,GAAG,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAe,GACrC,eAAe,CAmBjB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,IAAI;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,QAAQ,EAAE,CAAA;CAAE,CAG5E"}
|
package/dist/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AA4RH;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAmB,EACnB,MAA8B,GAAG,EAAE,GAAE,CAAC;IAEtC,IAAI,GAAG,GAAG,CAAC,CAAA;IACX,OAAO;QACL,IAAI,CAAC,KAAoB;YACvB,MAAM,OAAO,GAAa,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAA;YAClE,IAAI,CAAC,IAAI;gBAAE,OAAM;YACjB,IAAI,CAAC;gBACH,IAAI,CAAC,OAAO,CAAC,CAAA;YACf,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,qDAAqD;gBACrD,GAAG,CACD,uBAAuB,OAAO,CAAC,IAAI,KAAK,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAC3F,CAAA;YACH,CAAC;QACH,CAAC;QACD,IAAI,KAAK;YACP,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,MAAM,GAAe,EAAE,CAAA;IAC7B,OAAO,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;AAC7D,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export type { ConnectorConfig, Permissions, WorkflowDefinition } from "./types.js";
|
|
2
|
-
export { selectProvider } from "./providers/index.js";
|
|
3
|
-
export type { ProviderSelection } from "./providers/index.js";
|
|
4
|
-
export
|
|
2
|
+
export { selectProvider, providerAvailability, ProviderCredentialsError, } from "./providers/index.js";
|
|
3
|
+
export type { ProviderSelection, ProviderAvailability } from "./providers/index.js";
|
|
4
|
+
export { ProviderOptionsError, MAX_TRAILING_CACHE_MESSAGES } from "./providers/options.js";
|
|
5
|
+
export type { ProviderOptions, PromptCacheOptions, CacheTtl, ResponseFormat, ToolChoice, OpenRouterOptions, OpenRouterProviderPreferences, } from "./providers/options.js";
|
|
6
|
+
export type { Provider, CompletionRequest, ConverseRequest, ConverseResult, ConverseOptions, AgentMessage, ToolSpec, ToolCall, ToolResult, FinishReason, } from "./providers/types.js";
|
|
5
7
|
export { AnthropicProvider } from "./providers/anthropic.js";
|
|
6
8
|
export { OpenAIProvider, OpenAICompatibleProvider } from "./providers/openai.js";
|
|
7
9
|
export type { OpenAICompatibleOptions } from "./providers/openai.js";
|
|
@@ -9,8 +11,10 @@ export { OpenRouterProvider } from "./providers/openrouter.js";
|
|
|
9
11
|
export type { OpenRouterAttribution } from "./providers/openrouter.js";
|
|
10
12
|
export { LocalProvider, LOCAL_DEFAULT_MODEL } from "./providers/local.js";
|
|
11
13
|
export { MockProvider } from "./providers/mock.js";
|
|
14
|
+
export { ScriptedProvider, ScriptExhaustedError } from "./providers/scripted.js";
|
|
15
|
+
export type { ScriptedTurn, ScriptedProviderOptions } from "./providers/scripted.js";
|
|
12
16
|
export { emitCompleteToolCall, invokeStreaming, modelIdentity, requireCapability, CapabilityError, } from "./models/types.js";
|
|
13
|
-
export type { ModelInvocation, ModelKind, ModelCaps, ModelIdentity, ModelResult, InvokeContext, StreamSink, Usage, TokenUsage, UnitUsage, Health, HealthStatus, } from "./models/types.js";
|
|
17
|
+
export type { ModelInvocation, ModelKind, ModelCaps, ModelIdentity, ModelResult, InvokeContext, StreamSink, Usage, TokenUsage, ReportedCost, UnitUsage, Health, HealthStatus, } from "./models/types.js";
|
|
14
18
|
export { chatModel, asChatModel, isChatModel, chatRequest, CHAT_KIND } from "./models/chat.js";
|
|
15
19
|
export type { ChatModel, ChatRequest, ChatResponse, ChatPart, BinaryRef } from "./models/chat.js";
|
|
16
20
|
export { ModelRegistry, UnknownModelError } from "./models/registry.js";
|
|
@@ -22,18 +26,20 @@ export { UnknownCapabilityError } from "./routing/types.js";
|
|
|
22
26
|
export type { RouteResolver, RouteContext, RouteLimits, CapabilityDefinition, ResolvedRoute, } from "./routing/types.js";
|
|
23
27
|
export { assembleContext, renderContext } from "./context/types.js";
|
|
24
28
|
export type { ContextProvider, ContextFragment, ContextSpec } from "./context/types.js";
|
|
25
|
-
export { runAgent, maxToolResultBytes, resolveLoopLimits } from "./agent.js";
|
|
26
|
-
export type { RunAgentOptions } from "./agent.js";
|
|
29
|
+
export { runAgent, runConversation, isTruncatedCall, TruncatedAnswerError, maxToolResultBytes, resolveLoopLimits, } from "./agent.js";
|
|
30
|
+
export type { RunAgentOptions, RunConversationOptions, ConversationResult, LoopRunOptions, } from "./agent.js";
|
|
27
31
|
export { nativeLoop, runWithEvents } from "./loop.js";
|
|
28
|
-
export type { Loop, LoopRequest, LoopContext, RunContext, LoopResult } from "./loop.js";
|
|
32
|
+
export type { Loop, LoopRequest, LoopContext, RunContext, LoopResult, TerminalCall, } from "./loop.js";
|
|
29
33
|
export { runEventEmitter, recordRunEvents } from "./events.js";
|
|
30
|
-
export type { RunEvent, RunEventType, RunEventBase, RunEventInput, RunEventSink, RunEventEmitter, LoopEventInput, LoopEventEmitter, RunOutcome, ToolReplay, BudgetKind, RunStartedEvent, ModelTurnEvent, ModelTurnFailedEvent, ToolCalledEvent, ToolSucceededEvent, ToolFailedEvent, RunBudgetExhaustedEvent, RunFinishedEvent, } from "./events.js";
|
|
34
|
+
export type { RunEvent, RunEventType, RunEventBase, RunEventInput, RunEventSink, RunEventEmitter, LoopEventInput, LoopEventEmitter, RunOutcome, StopReason, ToolReplay, BudgetKind, RunStartedEvent, ModelTurnEvent, ModelTurnFailedEvent, ToolCalledEvent, ToolSucceededEvent, ToolFailedEvent, RunBudgetExhaustedEvent, RunFinishedEvent, } from "./events.js";
|
|
31
35
|
export { privateRunChannels, PrivateRunError, PRIVATE_REDACTION } from "./private.js";
|
|
32
36
|
export type { PrivateRunChannels } from "./private.js";
|
|
33
|
-
export { primitiveTools, connectorTools, executeTool } from "./tools/registry.js";
|
|
34
|
-
export type { Tool, ToolOutput, ToolContext } from "./tools/registry.js";
|
|
35
|
-
export { selectTools, isToolVisible, toToolSpecs, toolsRequiringConfirmation, replaySafeTools, undoToolFor, } from "./tools/metadata.js";
|
|
36
|
-
export type { ToolMetadata, ToolSelection, InvocationMode, ResultRetention, ClientResultVisibility, } from "./tools/metadata.js";
|
|
37
|
+
export { primitiveTools, connectorTools, executeTool, namespacedToolName, } from "./tools/registry.js";
|
|
38
|
+
export type { Tool, ToolOutput, ToolContext, ConnectorToolName } from "./tools/registry.js";
|
|
39
|
+
export { selectTools, isToolVisible, toToolSpecs, toolsRequiringConfirmation, replaySafeTools, undoToolFor, toolDispatch, terminalTools, } from "./tools/metadata.js";
|
|
40
|
+
export type { ToolMetadata, ToolSelection, InvocationMode, ResultRetention, ClientResultVisibility, ToolDispatch, } from "./tools/metadata.js";
|
|
41
|
+
export { terminalTool } from "./tools/terminal.js";
|
|
42
|
+
export type { TerminalToolOptions } from "./tools/terminal.js";
|
|
37
43
|
export { modelAsTool } from "./tools/modelTool.js";
|
|
38
44
|
export type { ModelToolOptions } from "./tools/modelTool.js";
|
|
39
45
|
export { runCode } from "./primitives/codeExec.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAKlF,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAKlF,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AACnF,OAAO,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAA;AAC1F,YAAY,EACV,eAAe,EACf,kBAAkB,EAClB,QAAQ,EACR,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,6BAA6B,GAC9B,MAAM,wBAAwB,CAAA;AAC/B,YAAY,EACV,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,YAAY,GACb,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAChF,YAAY,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9D,YAAY,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AACt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jF,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAMnE,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAChG,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAClG,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAChE,YAAY,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AACpE,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EACL,0BAA0B,EAC1B,eAAe,EACf,4BAA4B,GAC7B,MAAM,8BAA8B,CAAA;AACrC,YAAY,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AAGjG,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AAKhF,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
// ---------------------------------------------------------------------------
|
|
5
5
|
// Providers — the model adapters and their selection
|
|
6
6
|
// ---------------------------------------------------------------------------
|
|
7
|
-
export { selectProvider } from "./providers/index.js";
|
|
7
|
+
export { selectProvider, providerAvailability, ProviderCredentialsError, } from "./providers/index.js";
|
|
8
|
+
export { ProviderOptionsError, MAX_TRAILING_CACHE_MESSAGES } from "./providers/options.js";
|
|
8
9
|
export { AnthropicProvider } from "./providers/anthropic.js";
|
|
9
10
|
export { OpenAIProvider, OpenAICompatibleProvider } from "./providers/openai.js";
|
|
10
11
|
export { OpenRouterProvider } from "./providers/openrouter.js";
|
|
11
12
|
export { LocalProvider, LOCAL_DEFAULT_MODEL } from "./providers/local.js";
|
|
12
13
|
export { MockProvider } from "./providers/mock.js";
|
|
14
|
+
export { ScriptedProvider, ScriptExhaustedError } from "./providers/scripted.js";
|
|
13
15
|
// ---------------------------------------------------------------------------
|
|
14
16
|
// The model seam — the neutral arrow every model kind is invoked through
|
|
15
17
|
// ---------------------------------------------------------------------------
|
|
@@ -32,7 +34,7 @@ export { assembleContext, renderContext } from "./context/types.js";
|
|
|
32
34
|
// ---------------------------------------------------------------------------
|
|
33
35
|
// The tool-use loop
|
|
34
36
|
// ---------------------------------------------------------------------------
|
|
35
|
-
export { runAgent, maxToolResultBytes, resolveLoopLimits } from "./agent.js";
|
|
37
|
+
export { runAgent, runConversation, isTruncatedCall, TruncatedAnswerError, maxToolResultBytes, resolveLoopLimits, } from "./agent.js";
|
|
36
38
|
// Extension point 7 — the control loop itself. The kernel ships exactly one
|
|
37
39
|
// (`nativeLoop`, the loop `runAgent` has always run); this is the interface
|
|
38
40
|
// around it, so an application can change control flow without forking.
|
|
@@ -47,8 +49,9 @@ export { privateRunChannels, PrivateRunError, PRIVATE_REDACTION } from "./privat
|
|
|
47
49
|
// Extension point 6 — tools: generic primitives, injectable domain emissions,
|
|
48
50
|
// MCP connectors, rich metadata + projections, and models-as-tools
|
|
49
51
|
// ---------------------------------------------------------------------------
|
|
50
|
-
export { primitiveTools, connectorTools, executeTool } from "./tools/registry.js";
|
|
51
|
-
export { selectTools, isToolVisible, toToolSpecs, toolsRequiringConfirmation, replaySafeTools, undoToolFor, } from "./tools/metadata.js";
|
|
52
|
+
export { primitiveTools, connectorTools, executeTool, namespacedToolName, } from "./tools/registry.js";
|
|
53
|
+
export { selectTools, isToolVisible, toToolSpecs, toolsRequiringConfirmation, replaySafeTools, undoToolFor, toolDispatch, terminalTools, } from "./tools/metadata.js";
|
|
54
|
+
export { terminalTool } from "./tools/terminal.js";
|
|
52
55
|
export { modelAsTool } from "./tools/modelTool.js";
|
|
53
56
|
// ---------------------------------------------------------------------------
|
|
54
57
|
// Sandbox primitives (the executors the tools are built on)
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,gFAAgF;AAChF,mBAAmB;AAOnB,8EAA8E;AAC9E,qDAAqD;AACrD,8EAA8E;AAC9E,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,gFAAgF;AAChF,mBAAmB;AAOnB,8EAA8E;AAC9E,qDAAqD;AACrD,8EAA8E;AAC9E,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAA;AAsB1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAEhF,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAE9D,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAGhF,8EAA8E;AAC9E,yEAAyE;AACzE,8EAA8E;AAC9E,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,eAAe,GAChB,MAAM,mBAAmB,CAAA;AAiB1B,6EAA6E;AAC7E,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EA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AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/loop.d.ts
CHANGED
|
@@ -19,27 +19,39 @@
|
|
|
19
19
|
* code that has always run. This adds the interface around it, not an
|
|
20
20
|
* alternative to it.
|
|
21
21
|
*/
|
|
22
|
-
import type { LoopEventEmitter, RunEventEmitter, RunOutcome } from "./events.js";
|
|
22
|
+
import type { LoopEventEmitter, RunEventEmitter, RunOutcome, StopReason } from "./events.js";
|
|
23
23
|
import type { ChatModel } from "./models/chat.js";
|
|
24
|
-
import type {
|
|
24
|
+
import type { TokenUsage } from "./models/types.js";
|
|
25
|
+
import type { ProviderOptions } from "./providers/options.js";
|
|
26
|
+
import type { AgentMessage, FinishReason } from "./providers/types.js";
|
|
27
|
+
import type { Tool, ToolOutput } from "./tools/registry.js";
|
|
25
28
|
/**
|
|
26
29
|
* One run's materials, resolved.
|
|
27
30
|
*
|
|
28
31
|
* Everything here is already decided: the model is bound (registry-resolved and
|
|
29
|
-
* middleware-wrapped if it was going to be), the
|
|
30
|
-
* surface is projected, the budgets are numbers rather than optionals. A
|
|
31
|
-
* decides *control flow* and nothing else — which is what keeps a second
|
|
32
|
+
* middleware-wrapped if it was going to be), the conversation is seeded, the
|
|
33
|
+
* tool surface is projected, the budgets are numbers rather than optionals. A
|
|
34
|
+
* loop decides *control flow* and nothing else — which is what keeps a second
|
|
32
35
|
* implementation small enough to be worth writing.
|
|
33
36
|
*/
|
|
34
37
|
export interface LoopRequest {
|
|
35
38
|
model: ChatModel;
|
|
36
39
|
system: string;
|
|
37
|
-
|
|
40
|
+
/**
|
|
41
|
+
* The conversation so far, oldest first. A fresh run seeds one user message;
|
|
42
|
+
* a conversational application seeds its stored history plus the new user
|
|
43
|
+
* turn. It must end with a user message or the tool results the model is
|
|
44
|
+
* waiting for, since the loop's first act is to ask the model to continue it.
|
|
45
|
+
* The loop never mutates this array: it copies, then appends to the copy.
|
|
46
|
+
*/
|
|
47
|
+
messages: AgentMessage[];
|
|
38
48
|
tools: Tool[];
|
|
39
49
|
limits: {
|
|
40
50
|
maxSteps: number;
|
|
41
51
|
maxDurationMs: number;
|
|
42
52
|
};
|
|
53
|
+
/** Sent on every model call this loop makes, the budget summary included. */
|
|
54
|
+
providerOptions?: ProviderOptions;
|
|
43
55
|
}
|
|
44
56
|
/**
|
|
45
57
|
* What a loop is given to talk to the outside world. Both are the same channels
|
|
@@ -83,6 +95,17 @@ export interface RunContext {
|
|
|
83
95
|
/** Passed through to the loop; see {@link LoopContext.runId}. */
|
|
84
96
|
runId?: string;
|
|
85
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* The terminal-tool call that ended a run: the structured answer. `input` is
|
|
100
|
+
* the model's arguments (a detached copy), `output` is what the tool's
|
|
101
|
+
* executor returned when the loop ran it.
|
|
102
|
+
*/
|
|
103
|
+
export interface TerminalCall {
|
|
104
|
+
callId: string;
|
|
105
|
+
name: string;
|
|
106
|
+
input: Record<string, unknown>;
|
|
107
|
+
output: ToolOutput;
|
|
108
|
+
}
|
|
86
109
|
/**
|
|
87
110
|
* What a loop returns.
|
|
88
111
|
*
|
|
@@ -92,6 +115,13 @@ export interface RunContext {
|
|
|
92
115
|
* same two values appear on the `run.finished` event, and they must agree —
|
|
93
116
|
* the event stream and the return value are two views of one run, never two
|
|
94
117
|
* sources of truth.
|
|
118
|
+
*
|
|
119
|
+
* The fields after `outcome` are what a conversational caller needs and the
|
|
120
|
+
* native loop always fills: the finer `stopReason`, the full `messages` (seed
|
|
121
|
+
* plus everything appended), summed `usage`, the `terminal` call when one
|
|
122
|
+
* ended the run, and the `provider`/`model` that served it. They are optional
|
|
123
|
+
* on this seam so a custom loop that has nothing to say about them stays as
|
|
124
|
+
* small as it was; `runConversation` derives what it can when they are absent.
|
|
95
125
|
*/
|
|
96
126
|
export interface LoopResult {
|
|
97
127
|
text: string;
|
|
@@ -105,6 +135,24 @@ export interface LoopResult {
|
|
|
105
135
|
* `"timed_out"` with the prose it had accumulated.
|
|
106
136
|
*/
|
|
107
137
|
outcome: RunOutcome;
|
|
138
|
+
/** One level finer than `outcome`; see {@link StopReason}. */
|
|
139
|
+
stopReason?: StopReason;
|
|
140
|
+
/** The whole conversation: the seed followed by every message appended. */
|
|
141
|
+
messages?: AgentMessage[];
|
|
142
|
+
/** Token usage summed over every model call that reported it. */
|
|
143
|
+
usage?: TokenUsage;
|
|
144
|
+
/** Present when a terminal tool ended the run. */
|
|
145
|
+
terminal?: TerminalCall;
|
|
146
|
+
/** The `ChatModel.id` that served the run: the adapter name for a wrapped `Provider`. */
|
|
147
|
+
provider?: string;
|
|
148
|
+
/** The model id the last response named, else the adapter's configured model. */
|
|
149
|
+
model?: string;
|
|
150
|
+
/** Every response id the provider reported, in call order; what a billing or audit query keys on. */
|
|
151
|
+
responseIds?: string[];
|
|
152
|
+
/** The upstream that served the last response behind an aggregator, when reported. */
|
|
153
|
+
upstream?: string;
|
|
154
|
+
/** Why the last model call stopped generating, when the provider reported it. */
|
|
155
|
+
finishReason?: FinishReason;
|
|
108
156
|
}
|
|
109
157
|
/**
|
|
110
158
|
* A pluggable control loop. Implementations: the native tool-use loop, or an
|
|
@@ -123,9 +171,9 @@ export interface Loop {
|
|
|
123
171
|
* The kernel's one loop: the provider-neutral tool-use loop that `runAgent` has
|
|
124
172
|
* always run, behind the interface.
|
|
125
173
|
*
|
|
126
|
-
* This is the same code path, not a reimplementation — `runAgent
|
|
127
|
-
* `nativeLoop`
|
|
128
|
-
* sync and no way for
|
|
174
|
+
* This is the same code path, not a reimplementation — `runAgent`,
|
|
175
|
+
* `runConversation` and `nativeLoop` all delegate to it, so there is no second
|
|
176
|
+
* behaviour to keep in sync and no way for them to drift.
|
|
129
177
|
*/
|
|
130
178
|
export declare const nativeLoop: Loop;
|
|
131
179
|
/**
|
|
@@ -135,8 +183,9 @@ export declare const nativeLoop: Loop;
|
|
|
135
183
|
* forgets them produces a run that appears never to have started — and after
|
|
136
184
|
* the loop became a seam, "any loop" includes ones this kernel has never seen.
|
|
137
185
|
* A guarantee that depends on every future implementor remembering it is not a
|
|
138
|
-
* guarantee.
|
|
139
|
-
* here, so the property holds no matter whose
|
|
186
|
+
* guarantee. Every entry point — `runAgent`, `runConversation` and
|
|
187
|
+
* `NativeEngine` — comes through here, so the property holds no matter whose
|
|
188
|
+
* loop runs.
|
|
140
189
|
*
|
|
141
190
|
* On a throw it closes the stream with `outcome: "failed"` and then **rethrows
|
|
142
191
|
* the original error, untouched**. This changes what is observed, never what is
|
package/dist/loop.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../src/loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../src/loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC5F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACtE,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAE3D;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,SAAS,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd;;;;;;OAMG;IACH,QAAQ,EAAE,YAAY,EAAE,CAAA;IACxB,KAAK,EAAE,IAAI,EAAE,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QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,iFAAiF;IACjF,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,qGAAqG;IACrG,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,sFAAsF;IACtF,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,iFAAiF;IACjF,YAAY,CAAC,EAAE,YAAY,CAAA;CAC5B;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,GAAG,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CAC7D;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,EAAE,IAGxB,CAAA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,UAAU,CAAC,CA4BrB"}
|
package/dist/loop.js
CHANGED
|
@@ -25,9 +25,9 @@ import { isAbortError } from "./signals.js";
|
|
|
25
25
|
* The kernel's one loop: the provider-neutral tool-use loop that `runAgent` has
|
|
26
26
|
* always run, behind the interface.
|
|
27
27
|
*
|
|
28
|
-
* This is the same code path, not a reimplementation — `runAgent
|
|
29
|
-
* `nativeLoop`
|
|
30
|
-
* sync and no way for
|
|
28
|
+
* This is the same code path, not a reimplementation — `runAgent`,
|
|
29
|
+
* `runConversation` and `nativeLoop` all delegate to it, so there is no second
|
|
30
|
+
* behaviour to keep in sync and no way for them to drift.
|
|
31
31
|
*/
|
|
32
32
|
export const nativeLoop = {
|
|
33
33
|
name: "native",
|
|
@@ -40,8 +40,9 @@ export const nativeLoop = {
|
|
|
40
40
|
* forgets them produces a run that appears never to have started — and after
|
|
41
41
|
* the loop became a seam, "any loop" includes ones this kernel has never seen.
|
|
42
42
|
* A guarantee that depends on every future implementor remembering it is not a
|
|
43
|
-
* guarantee.
|
|
44
|
-
* here, so the property holds no matter whose
|
|
43
|
+
* guarantee. Every entry point — `runAgent`, `runConversation` and
|
|
44
|
+
* `NativeEngine` — comes through here, so the property holds no matter whose
|
|
45
|
+
* loop runs.
|
|
45
46
|
*
|
|
46
47
|
* On a throw it closes the stream with `outcome: "failed"` and then **rethrows
|
|
47
48
|
* the original error, untouched**. This changes what is observed, never what is
|
|
@@ -74,6 +75,7 @@ export async function runWithEvents(loop, req, ctx) {
|
|
|
74
75
|
ctx.events.emit({
|
|
75
76
|
type: "run.finished",
|
|
76
77
|
outcome: result.outcome,
|
|
78
|
+
...(result.stopReason !== undefined ? { stopReason: result.stopReason } : {}),
|
|
77
79
|
steps: result.steps,
|
|
78
80
|
text: result.text,
|
|
79
81
|
});
|
package/dist/loop.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop.js","sourceRoot":"","sources":["../src/loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"loop.js","sourceRoot":"","sources":["../src/loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAyJ3C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GAAS;IAC9B,IAAI,EAAE,QAAQ;IACd,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC;CAC3C,CAAA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,IAAU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