@autonome-research/thread-phase 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +226 -0
- package/dist/agent/index.d.ts +28 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +28 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/openai-adapter.d.ts +15 -0
- package/dist/agent/openai-adapter.d.ts.map +1 -0
- package/dist/agent/openai-adapter.js +57 -0
- package/dist/agent/openai-adapter.js.map +1 -0
- package/dist/agent/parse-json.d.ts +12 -0
- package/dist/agent/parse-json.d.ts.map +1 -0
- package/dist/agent/parse-json.js +31 -0
- package/dist/agent/parse-json.js.map +1 -0
- package/dist/agent/retry.d.ts +15 -0
- package/dist/agent/retry.d.ts.map +1 -0
- package/dist/agent/retry.js +35 -0
- package/dist/agent/retry.js.map +1 -0
- package/dist/agent/runner.d.ts +25 -0
- package/dist/agent/runner.d.ts.map +1 -0
- package/dist/agent/runner.js +270 -0
- package/dist/agent/runner.js.map +1 -0
- package/dist/agent/stream-consumer.d.ts +57 -0
- package/dist/agent/stream-consumer.d.ts.map +1 -0
- package/dist/agent/stream-consumer.js +126 -0
- package/dist/agent/stream-consumer.js.map +1 -0
- package/dist/agent/types.d.ts +135 -0
- package/dist/agent/types.d.ts.map +1 -0
- package/dist/agent/types.js +9 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/agent-runner.d.ts +10 -0
- package/dist/agent-runner.d.ts.map +1 -0
- package/dist/agent-runner.js +10 -0
- package/dist/agent-runner.js.map +1 -0
- package/dist/agents/capability.d.ts +36 -0
- package/dist/agents/capability.d.ts.map +1 -0
- package/dist/agents/capability.js +51 -0
- package/dist/agents/capability.js.map +1 -0
- package/dist/agents/event-bus.d.ts +20 -0
- package/dist/agents/event-bus.d.ts.map +1 -0
- package/dist/agents/event-bus.js +40 -0
- package/dist/agents/event-bus.js.map +1 -0
- package/dist/agents/index.d.ts +23 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +33 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/inference-adapter.d.ts +52 -0
- package/dist/agents/inference-adapter.d.ts.map +1 -0
- package/dist/agents/inference-adapter.js +209 -0
- package/dist/agents/inference-adapter.js.map +1 -0
- package/dist/agents/job-store-bridge.d.ts +44 -0
- package/dist/agents/job-store-bridge.d.ts.map +1 -0
- package/dist/agents/job-store-bridge.js +58 -0
- package/dist/agents/job-store-bridge.js.map +1 -0
- package/dist/agents/memory.d.ts +40 -0
- package/dist/agents/memory.d.ts.map +1 -0
- package/dist/agents/memory.js +14 -0
- package/dist/agents/memory.js.map +1 -0
- package/dist/agents/protocol.d.ts +302 -0
- package/dist/agents/protocol.d.ts.map +1 -0
- package/dist/agents/protocol.js +36 -0
- package/dist/agents/protocol.js.map +1 -0
- package/dist/agents/run-helpers.d.ts +70 -0
- package/dist/agents/run-helpers.d.ts.map +1 -0
- package/dist/agents/run-helpers.js +131 -0
- package/dist/agents/run-helpers.js.map +1 -0
- package/dist/agents/serialize-error.d.ts +18 -0
- package/dist/agents/serialize-error.d.ts.map +1 -0
- package/dist/agents/serialize-error.js +27 -0
- package/dist/agents/serialize-error.js.map +1 -0
- package/dist/agents/structured-output.d.ts +90 -0
- package/dist/agents/structured-output.d.ts.map +1 -0
- package/dist/agents/structured-output.js +101 -0
- package/dist/agents/structured-output.js.map +1 -0
- package/dist/agents/test-utils/conformance.d.ts +59 -0
- package/dist/agents/test-utils/conformance.d.ts.map +1 -0
- package/dist/agents/test-utils/conformance.js +207 -0
- package/dist/agents/test-utils/conformance.js.map +1 -0
- package/dist/agents/test-utils/index.d.ts +12 -0
- package/dist/agents/test-utils/index.d.ts.map +1 -0
- package/dist/agents/test-utils/index.js +12 -0
- package/dist/agents/test-utils/index.js.map +1 -0
- package/dist/agents/test-utils/mock-agent.d.ts +66 -0
- package/dist/agents/test-utils/mock-agent.d.ts.map +1 -0
- package/dist/agents/test-utils/mock-agent.js +244 -0
- package/dist/agents/test-utils/mock-agent.js.map +1 -0
- package/dist/agents/thread.d.ts +57 -0
- package/dist/agents/thread.d.ts.map +1 -0
- package/dist/agents/thread.js +128 -0
- package/dist/agents/thread.js.map +1 -0
- package/dist/agents/turn-accumulator.d.ts +94 -0
- package/dist/agents/turn-accumulator.d.ts.map +1 -0
- package/dist/agents/turn-accumulator.js +150 -0
- package/dist/agents/turn-accumulator.js.map +1 -0
- package/dist/agents/with-memory.d.ts +55 -0
- package/dist/agents/with-memory.d.ts.map +1 -0
- package/dist/agents/with-memory.js +155 -0
- package/dist/agents/with-memory.js.map +1 -0
- package/dist/agents/with-thread.d.ts +45 -0
- package/dist/agents/with-thread.d.ts.map +1 -0
- package/dist/agents/with-thread.js +70 -0
- package/dist/agents/with-thread.js.map +1 -0
- package/dist/cache.d.ts +47 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +81 -0
- package/dist/cache.js.map +1 -0
- package/dist/context/compressor.d.ts +36 -0
- package/dist/context/compressor.d.ts.map +1 -0
- package/dist/context/compressor.js +158 -0
- package/dist/context/compressor.js.map +1 -0
- package/dist/context/index.d.ts +4 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +4 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/result-capper.d.ts +32 -0
- package/dist/context/result-capper.d.ts.map +1 -0
- package/dist/context/result-capper.js +50 -0
- package/dist/context/result-capper.js.map +1 -0
- package/dist/context/token-budget.d.ts +81 -0
- package/dist/context/token-budget.d.ts.map +1 -0
- package/dist/context/token-budget.js +99 -0
- package/dist/context/token-budget.js.map +1 -0
- package/dist/helpers/caller.d.ts +18 -0
- package/dist/helpers/caller.d.ts.map +1 -0
- package/dist/helpers/caller.js +40 -0
- package/dist/helpers/caller.js.map +1 -0
- package/dist/helpers/hook.d.ts +73 -0
- package/dist/helpers/hook.d.ts.map +1 -0
- package/dist/helpers/hook.js +244 -0
- package/dist/helpers/hook.js.map +1 -0
- package/dist/helpers/index.d.ts +12 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +11 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/one-shot.d.ts +27 -0
- package/dist/helpers/one-shot.d.ts.map +1 -0
- package/dist/helpers/one-shot.js +43 -0
- package/dist/helpers/one-shot.js.map +1 -0
- package/dist/helpers/schedule.d.ts +59 -0
- package/dist/helpers/schedule.d.ts.map +1 -0
- package/dist/helpers/schedule.js +118 -0
- package/dist/helpers/schedule.js.map +1 -0
- package/dist/helpers/types.d.ts +34 -0
- package/dist/helpers/types.d.ts.map +1 -0
- package/dist/helpers/types.js +11 -0
- package/dist/helpers/types.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/inference.d.ts +27 -0
- package/dist/inference.d.ts.map +1 -0
- package/dist/inference.js +34 -0
- package/dist/inference.js.map +1 -0
- package/dist/messages.d.ts +64 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +17 -0
- package/dist/messages.js.map +1 -0
- package/dist/orchestrator.d.ts +56 -0
- package/dist/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator.js +62 -0
- package/dist/orchestrator.js.map +1 -0
- package/dist/patterns/bounded-fanout-of.d.ts +61 -0
- package/dist/patterns/bounded-fanout-of.d.ts.map +1 -0
- package/dist/patterns/bounded-fanout-of.js +142 -0
- package/dist/patterns/bounded-fanout-of.js.map +1 -0
- package/dist/patterns/bounded-fanout.d.ts +111 -0
- package/dist/patterns/bounded-fanout.d.ts.map +1 -0
- package/dist/patterns/bounded-fanout.js +151 -0
- package/dist/patterns/bounded-fanout.js.map +1 -0
- package/dist/patterns/index.d.ts +14 -0
- package/dist/patterns/index.d.ts.map +1 -0
- package/dist/patterns/index.js +13 -0
- package/dist/patterns/index.js.map +1 -0
- package/dist/patterns/intent-gate.d.ts +27 -0
- package/dist/patterns/intent-gate.d.ts.map +1 -0
- package/dist/patterns/intent-gate.js +32 -0
- package/dist/patterns/intent-gate.js.map +1 -0
- package/dist/patterns/match.d.ts +30 -0
- package/dist/patterns/match.d.ts.map +1 -0
- package/dist/patterns/match.js +58 -0
- package/dist/patterns/match.js.map +1 -0
- package/dist/patterns/parallel-fanout.d.ts +28 -0
- package/dist/patterns/parallel-fanout.d.ts.map +1 -0
- package/dist/patterns/parallel-fanout.js +24 -0
- package/dist/patterns/parallel-fanout.js.map +1 -0
- package/dist/patterns/parallel-phases.d.ts +27 -0
- package/dist/patterns/parallel-phases.d.ts.map +1 -0
- package/dist/patterns/parallel-phases.js +77 -0
- package/dist/patterns/parallel-phases.js.map +1 -0
- package/dist/patterns/preflight-confidence.d.ts +20 -0
- package/dist/patterns/preflight-confidence.d.ts.map +1 -0
- package/dist/patterns/preflight-confidence.js +38 -0
- package/dist/patterns/preflight-confidence.js.map +1 -0
- package/dist/patterns/spot-check.d.ts +19 -0
- package/dist/patterns/spot-check.d.ts.map +1 -0
- package/dist/patterns/spot-check.js +33 -0
- package/dist/patterns/spot-check.js.map +1 -0
- package/dist/patterns/sub-pipeline.d.ts +84 -0
- package/dist/patterns/sub-pipeline.d.ts.map +1 -0
- package/dist/patterns/sub-pipeline.js +90 -0
- package/dist/patterns/sub-pipeline.js.map +1 -0
- package/dist/patterns/synthesize-with-followup.d.ts +35 -0
- package/dist/patterns/synthesize-with-followup.d.ts.map +1 -0
- package/dist/patterns/synthesize-with-followup.js +45 -0
- package/dist/patterns/synthesize-with-followup.js.map +1 -0
- package/dist/patterns/while-condition.d.ts +31 -0
- package/dist/patterns/while-condition.d.ts.map +1 -0
- package/dist/patterns/while-condition.js +59 -0
- package/dist/patterns/while-condition.js.map +1 -0
- package/dist/patterns/with-retry.d.ts +37 -0
- package/dist/patterns/with-retry.d.ts.map +1 -0
- package/dist/patterns/with-retry.js +73 -0
- package/dist/patterns/with-retry.js.map +1 -0
- package/dist/phase.d.ts +78 -0
- package/dist/phase.d.ts.map +1 -0
- package/dist/phase.js +36 -0
- package/dist/phase.js.map +1 -0
- package/dist/session/index.d.ts +5 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +4 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/job-runner.d.ts +67 -0
- package/dist/session/job-runner.d.ts.map +1 -0
- package/dist/session/job-runner.js +131 -0
- package/dist/session/job-runner.js.map +1 -0
- package/dist/session/job-store.d.ts +98 -0
- package/dist/session/job-store.d.ts.map +1 -0
- package/dist/session/job-store.js +37 -0
- package/dist/session/job-store.js.map +1 -0
- package/dist/session/sqlite-job-store.d.ts +40 -0
- package/dist/session/sqlite-job-store.d.ts.map +1 -0
- package/dist/session/sqlite-job-store.js +200 -0
- package/dist/session/sqlite-job-store.js.map +1 -0
- package/dist/session/sse.d.ts +60 -0
- package/dist/session/sse.d.ts.map +1 -0
- package/dist/session/sse.js +97 -0
- package/dist/session/sse.js.map +1 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +2 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/registry.d.ts +44 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +74 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/triggers/index.d.ts +15 -0
- package/dist/triggers/index.d.ts.map +1 -0
- package/dist/triggers/index.js +14 -0
- package/dist/triggers/index.js.map +1 -0
- package/dist/triggers/run-trigger.d.ts +86 -0
- package/dist/triggers/run-trigger.d.ts.map +1 -0
- package/dist/triggers/run-trigger.js +146 -0
- package/dist/triggers/run-trigger.js.map +1 -0
- package/dist/triggers/timer-trigger.d.ts +46 -0
- package/dist/triggers/timer-trigger.d.ts.map +1 -0
- package/dist/triggers/timer-trigger.js +74 -0
- package/dist/triggers/timer-trigger.js.map +1 -0
- package/dist/triggers/types.d.ts +61 -0
- package/dist/triggers/types.d.ts.map +1 -0
- package/dist/triggers/types.js +23 -0
- package/dist/triggers/types.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backward-compat shim — the agent runner was split into focused modules
|
|
3
|
+
* under `./agent/`. This file re-exports the same public surface so existing
|
|
4
|
+
* imports continue to work.
|
|
5
|
+
*
|
|
6
|
+
* For new code, import from `thread-phase` (or directly from `./agent/*`)
|
|
7
|
+
* rather than this path.
|
|
8
|
+
*/
|
|
9
|
+
export { runAgentWithTools, parseJSON, } from './agent/index.js';
|
|
10
|
+
//# sourceMappingURL=agent-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-runner.js","sourceRoot":"","sources":["../src/agent-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,iBAAiB,EACjB,SAAS,GAQV,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static capability assertions for adapters.
|
|
3
|
+
*
|
|
4
|
+
* Patterns that depend on an adapter ability (resumption, streaming mode,
|
|
5
|
+
* structured output strategy) call `requireCapability` at construction time.
|
|
6
|
+
* Failing here is far cheaper than failing at run time after the agent has
|
|
7
|
+
* already consumed tokens.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
import type { AgentAdapterMeta, AgentCapabilities, AgentRunResult } from './protocol.js';
|
|
12
|
+
/**
|
|
13
|
+
* Thrown when an adapter does not satisfy a requested capability. Carries
|
|
14
|
+
* the offending adapter id, the capability key, and both the required and
|
|
15
|
+
* actual values so logs surface the mismatch without further indirection.
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export declare class AgentCapabilityError extends Error {
|
|
20
|
+
adapterId: string;
|
|
21
|
+
capability: keyof AgentCapabilities;
|
|
22
|
+
required: unknown;
|
|
23
|
+
actual: unknown;
|
|
24
|
+
constructor(adapterId: string, capability: keyof AgentCapabilities, required: unknown, actual: unknown);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Assert that an adapter's declared capability matches a required value or
|
|
28
|
+
* passes a predicate. Throws `AgentCapabilityError` on mismatch.
|
|
29
|
+
*
|
|
30
|
+
* The `meta` parameter accepts any adapter regardless of its config/result
|
|
31
|
+
* types — capability checks are config-shape-independent.
|
|
32
|
+
*
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export declare function requireCapability<C extends keyof AgentCapabilities>(meta: AgentAdapterMeta<unknown, AgentRunResult>, capability: C, required: AgentCapabilities[C] | ((actual: AgentCapabilities[C]) => boolean)): void;
|
|
36
|
+
//# sourceMappingURL=capability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../../src/agents/capability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEzF;;;;;;GAMG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAEpC,SAAS,EAAE,MAAM;IACjB,UAAU,EAAE,MAAM,iBAAiB;IACnC,QAAQ,EAAE,OAAO;IACjB,MAAM,EAAE,OAAO;gBAHf,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,iBAAiB,EACnC,QAAQ,EAAE,OAAO,EACjB,MAAM,EAAE,OAAO;CAQzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,iBAAiB,EACjE,IAAI,EAAE,gBAAgB,CAAC,OAAO,EAAE,cAAc,CAAC,EAC/C,UAAU,EAAE,CAAC,EACb,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,GAC3E,IAAI,CASN"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static capability assertions for adapters.
|
|
3
|
+
*
|
|
4
|
+
* Patterns that depend on an adapter ability (resumption, streaming mode,
|
|
5
|
+
* structured output strategy) call `requireCapability` at construction time.
|
|
6
|
+
* Failing here is far cheaper than failing at run time after the agent has
|
|
7
|
+
* already consumed tokens.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Thrown when an adapter does not satisfy a requested capability. Carries
|
|
13
|
+
* the offending adapter id, the capability key, and both the required and
|
|
14
|
+
* actual values so logs surface the mismatch without further indirection.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export class AgentCapabilityError extends Error {
|
|
19
|
+
adapterId;
|
|
20
|
+
capability;
|
|
21
|
+
required;
|
|
22
|
+
actual;
|
|
23
|
+
constructor(adapterId, capability, required, actual) {
|
|
24
|
+
super(`adapter '${adapterId}' does not satisfy capability '${String(capability)}': ` +
|
|
25
|
+
`required=${JSON.stringify(required)}, actual=${JSON.stringify(actual)}`);
|
|
26
|
+
this.adapterId = adapterId;
|
|
27
|
+
this.capability = capability;
|
|
28
|
+
this.required = required;
|
|
29
|
+
this.actual = actual;
|
|
30
|
+
this.name = 'AgentCapabilityError';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Assert that an adapter's declared capability matches a required value or
|
|
35
|
+
* passes a predicate. Throws `AgentCapabilityError` on mismatch.
|
|
36
|
+
*
|
|
37
|
+
* The `meta` parameter accepts any adapter regardless of its config/result
|
|
38
|
+
* types — capability checks are config-shape-independent.
|
|
39
|
+
*
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
export function requireCapability(meta, capability, required) {
|
|
43
|
+
const actual = meta.capabilities[capability];
|
|
44
|
+
const ok = typeof required === 'function'
|
|
45
|
+
? required(actual)
|
|
46
|
+
: actual === required;
|
|
47
|
+
if (!ok) {
|
|
48
|
+
throw new AgentCapabilityError(meta.id, capability, required, actual);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=capability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability.js","sourceRoot":"","sources":["../../src/agents/capability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH;;;;;;GAMG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAEpC;IACA;IACA;IACA;IAJT,YACS,SAAiB,EACjB,UAAmC,EACnC,QAAiB,EACjB,MAAe;QAEtB,KAAK,CACH,YAAY,SAAS,kCAAkC,MAAM,CAAC,UAAU,CAAC,KAAK;YAC5E,YAAY,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAC3E,CAAC;QARK,cAAS,GAAT,SAAS,CAAQ;QACjB,eAAU,GAAV,UAAU,CAAyB;QACnC,aAAQ,GAAR,QAAQ,CAAS;QACjB,WAAM,GAAN,MAAM,CAAS;QAMtB,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAA+C,EAC/C,UAAa,EACb,QAA4E;IAE5E,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAC7C,MAAM,EAAE,GACN,OAAO,QAAQ,KAAK,UAAU;QAC5B,CAAC,CAAE,QAAiD,CAAC,MAAM,CAAC;QAC5D,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC;IAC1B,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,MAAM,IAAI,oBAAoB,CAAC,IAAI,CAAC,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACxE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-subscriber event bus for cross-adapter observation.
|
|
3
|
+
*
|
|
4
|
+
* Plain pub/sub with synchronous emission and best-effort handler dispatch.
|
|
5
|
+
* Handler errors are swallowed so a misbehaving subscriber can't poison the
|
|
6
|
+
* stream for the rest — subscribers handle their own errors. Async handlers
|
|
7
|
+
* are fire-and-forget (no awaiting); use the bus for observation, not for
|
|
8
|
+
* sequencing.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
import type { AgentEventBus } from './protocol.js';
|
|
13
|
+
/**
|
|
14
|
+
* Construct a new event bus. Each adapter that receives one via
|
|
15
|
+
* `AgentRunOptions.eventBus` mirrors its event stream into it.
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export declare function createEventBus(): AgentEventBus;
|
|
20
|
+
//# sourceMappingURL=event-bus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-bus.d.ts","sourceRoot":"","sources":["../../src/agents/event-bus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAc,aAAa,EAAE,MAAM,eAAe,CAAC;AAE/D;;;;;GAKG;AACH,wBAAgB,cAAc,IAAI,aAAa,CAoB9C"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-subscriber event bus for cross-adapter observation.
|
|
3
|
+
*
|
|
4
|
+
* Plain pub/sub with synchronous emission and best-effort handler dispatch.
|
|
5
|
+
* Handler errors are swallowed so a misbehaving subscriber can't poison the
|
|
6
|
+
* stream for the rest — subscribers handle their own errors. Async handlers
|
|
7
|
+
* are fire-and-forget (no awaiting); use the bus for observation, not for
|
|
8
|
+
* sequencing.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Construct a new event bus. Each adapter that receives one via
|
|
14
|
+
* `AgentRunOptions.eventBus` mirrors its event stream into it.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export function createEventBus() {
|
|
19
|
+
const handlers = new Set();
|
|
20
|
+
return {
|
|
21
|
+
emit(event) {
|
|
22
|
+
for (const h of handlers) {
|
|
23
|
+
try {
|
|
24
|
+
void h(event);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// Handler errors are intentionally swallowed; downstream consumers
|
|
28
|
+
// handle their own errors so one bad subscriber can't stall the bus.
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
on(handler) {
|
|
33
|
+
handlers.add(handler);
|
|
34
|
+
return () => {
|
|
35
|
+
handlers.delete(handler);
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=event-bus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-bus.js","sourceRoot":"","sources":["../../src/agents/event-bus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH;;;;;GAKG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA+C,CAAC;IACxE,OAAO;QACL,IAAI,CAAC,KAAK;YACR,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;gBACzB,IAAI,CAAC;oBACH,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;gBAChB,CAAC;gBAAC,MAAM,CAAC;oBACP,mEAAmE;oBACnE,qEAAqE;gBACvE,CAAC;YACH,CAAC;QACH,CAAC;QACD,EAAE,CAAC,OAAO;YACR,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACtB,OAAO,GAAG,EAAE;gBACV,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC3B,CAAC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entry point for the AgentAdapter protocol.
|
|
3
|
+
*
|
|
4
|
+
* The protocol surface is currently `@internal` — covered by no semver
|
|
5
|
+
* guarantee until the first stable release of `@autonome-research/thread-phase-agents`. Until
|
|
6
|
+
* then, every export here may change in a minor version.
|
|
7
|
+
*
|
|
8
|
+
* Subpath: `thread-phase/agents`.
|
|
9
|
+
*/
|
|
10
|
+
export { defineAgentAdapter, isSteerable, type AgentAdapter, type AgentAdapterMeta, type AgentCapabilities, type AgentEvent, type AgentEventBus, type AgentFinishReason, type AgentRun, type AgentRunOptions, type AgentRunResult, type ResumeToken, type SerializableError, type SteerableAgentRun, } from './protocol.js';
|
|
11
|
+
export { createEventBus } from './event-bus.js';
|
|
12
|
+
export { AgentCapabilityError, requireCapability } from './capability.js';
|
|
13
|
+
export { serializeError } from './serialize-error.js';
|
|
14
|
+
export { appendEvent, createThread, resumeTokenFor, setResumeToken, threadToMessages, type Thread, } from './thread.js';
|
|
15
|
+
export type { MemoryProvider, MemoryScope } from './memory.js';
|
|
16
|
+
export { applyStructuredOutputPrompt, extractResponseBlock, parseStructured, parseStructuredFromText, StructuredOutputParseError, type StructuredOutputConfig, } from './structured-output.js';
|
|
17
|
+
export { inferenceAgent, type InferenceAgentConfig, } from './inference-adapter.js';
|
|
18
|
+
export { TurnAccumulator } from './turn-accumulator.js';
|
|
19
|
+
export { composeAbort, createEventQueue, lazyEvents, type CompositeAbort, type EventQueue, } from './run-helpers.js';
|
|
20
|
+
export { withMemory, type WithMemoryOptions } from './with-memory.js';
|
|
21
|
+
export { withThread, type WithThreadOptions } from './with-thread.js';
|
|
22
|
+
export { pipeAgentEventsToJobStore, type PipeAgentEventsOptions, } from './job-store-bridge.js';
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;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@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entry point for the AgentAdapter protocol.
|
|
3
|
+
*
|
|
4
|
+
* The protocol surface is currently `@internal` — covered by no semver
|
|
5
|
+
* guarantee until the first stable release of `@autonome-research/thread-phase-agents`. Until
|
|
6
|
+
* then, every export here may change in a minor version.
|
|
7
|
+
*
|
|
8
|
+
* Subpath: `thread-phase/agents`.
|
|
9
|
+
*/
|
|
10
|
+
// Protocol types.
|
|
11
|
+
export { defineAgentAdapter, isSteerable, } from './protocol.js';
|
|
12
|
+
// Event bus.
|
|
13
|
+
export { createEventBus } from './event-bus.js';
|
|
14
|
+
// Capability assertions.
|
|
15
|
+
export { AgentCapabilityError, requireCapability } from './capability.js';
|
|
16
|
+
// Error serialization helper.
|
|
17
|
+
export { serializeError } from './serialize-error.js';
|
|
18
|
+
// Thread primitive.
|
|
19
|
+
export { appendEvent, createThread, resumeTokenFor, setResumeToken, threadToMessages, } from './thread.js';
|
|
20
|
+
// Structured-output helpers (prompted path).
|
|
21
|
+
export { applyStructuredOutputPrompt, extractResponseBlock, parseStructured, parseStructuredFromText, StructuredOutputParseError, } from './structured-output.js';
|
|
22
|
+
// Reference adapter — wraps runAgentWithTools.
|
|
23
|
+
export { inferenceAgent, } from './inference-adapter.js';
|
|
24
|
+
// Helper for adapters whose runtime emits turn boundaries before tool calls.
|
|
25
|
+
export { TurnAccumulator } from './turn-accumulator.js';
|
|
26
|
+
// Helpers for adapter authors: composite abort, single-consumer event queue, lazy-start wrapper.
|
|
27
|
+
export { composeAbort, createEventQueue, lazyEvents, } from './run-helpers.js';
|
|
28
|
+
// Adapter decorators: auto-handle memory and Thread wiring.
|
|
29
|
+
export { withMemory } from './with-memory.js';
|
|
30
|
+
export { withThread } from './with-thread.js';
|
|
31
|
+
// Bridge adapter events to a JobStore event log.
|
|
32
|
+
export { pipeAgentEventsToJobStore, } from './job-store-bridge.js';
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,kBAAkB;AAClB,OAAO,EACL,kBAAkB,EAClB,WAAW,GAaZ,MAAM,eAAe,CAAC;AAEvB,aAAa;AACb,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,yBAAyB;AACzB,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAE1E,8BAA8B;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,oBAAoB;AACpB,OAAO,EACL,WAAW,EACX,YAAY,EACZ,cAAc,EACd,cAAc,EACd,gBAAgB,GAEjB,MAAM,aAAa,CAAC;AAKrB,6CAA6C;AAC7C,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,EACpB,eAAe,EACf,uBAAuB,EACvB,0BAA0B,GAE3B,MAAM,wBAAwB,CAAC;AAEhC,+CAA+C;AAC/C,OAAO,EACL,cAAc,GAEf,MAAM,wBAAwB,CAAC;AAEhC,6EAA6E;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,iGAAiG;AACjG,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,UAAU,GAGX,MAAM,kBAAkB,CAAC;AAE1B,4DAA4D;AAC5D,OAAO,EAAE,UAAU,EAA0B,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,UAAU,EAA0B,MAAM,kBAAkB,CAAC;AAEtE,iDAAiD;AACjD,OAAO,EACL,yBAAyB,GAE1B,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `inferenceAgent` — the in-tree reference `AgentAdapter`.
|
|
3
|
+
*
|
|
4
|
+
* Wraps `runAgentWithTools` (the OpenAI-compatible inference loop) behind
|
|
5
|
+
* the canonical adapter protocol so the loop becomes one valid adapter
|
|
6
|
+
* alongside future sibling adapters (pi, Claude Code, OpenAI Agents SDK).
|
|
7
|
+
*
|
|
8
|
+
* Declared capabilities:
|
|
9
|
+
* - streaming: 'text' (content deltas only)
|
|
10
|
+
* - cancellation: 'cooperative' (honors `options.signal` and `abort()`)
|
|
11
|
+
* - resumption: 'none'
|
|
12
|
+
* - structuredOutput: 'prompted' (uses ./structured-output.ts)
|
|
13
|
+
*
|
|
14
|
+
* The run starts lazily: the underlying `runAgentWithTools` is invoked
|
|
15
|
+
* when either `events` is iterated or `result` is awaited, whichever comes
|
|
16
|
+
* first. Translation rules from runner stream events → canonical
|
|
17
|
+
* `AgentEvent`s are documented inline on the `onStreamEvent` callback.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
import { type AgentConfig, type AgentRunnerOptions } from '../agent/index.js';
|
|
22
|
+
import type { Message } from '../messages.js';
|
|
23
|
+
import { type AgentAdapterMeta, type AgentEventBus } from './protocol.js';
|
|
24
|
+
import { type StructuredOutputConfig } from './structured-output.js';
|
|
25
|
+
/**
|
|
26
|
+
* Configuration for the in-tree inference adapter. Wraps the same inputs
|
|
27
|
+
* `runAgentWithTools` already takes plus an optional structured-output spec.
|
|
28
|
+
*
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export interface InferenceAgentConfig {
|
|
32
|
+
/** Agent config passed to `runAgentWithTools`. */
|
|
33
|
+
config: AgentConfig;
|
|
34
|
+
/** Initial messages. The adapter prepends/appends none on top. */
|
|
35
|
+
messages: Message[];
|
|
36
|
+
/**
|
|
37
|
+
* Runner options (client, toolExecutor, cache, etc.). The adapter wires
|
|
38
|
+
* `signal` and `onStreamEvent` itself; pre-existing fields on this object
|
|
39
|
+
* are forwarded unchanged.
|
|
40
|
+
*/
|
|
41
|
+
runnerOptions: Omit<AgentRunnerOptions, 'signal' | 'onStreamEvent'>;
|
|
42
|
+
/** Optional structured-output spec (prompted path). */
|
|
43
|
+
outputSchema?: StructuredOutputConfig;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The adapter metadata, suitable for registration alongside future siblings.
|
|
47
|
+
*
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
export declare const inferenceAgent: AgentAdapterMeta<InferenceAgentConfig>;
|
|
51
|
+
export type { AgentEventBus };
|
|
52
|
+
//# sourceMappingURL=inference-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inference-adapter.d.ts","sourceRoot":"","sources":["../../src/agents/inference-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAEL,KAAK,WAAW,EAEhB,KAAK,kBAAkB,EAExB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAInB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,wBAAwB,CAAC;AAKhC;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,kDAAkD;IAClD,MAAM,EAAE,WAAW,CAAC;IACpB,kEAAkE;IAClE,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB;;;;OAIG;IACH,aAAa,EAAE,IAAI,CAAC,kBAAkB,EAAE,QAAQ,GAAG,eAAe,CAAC,CAAC;IACpE,uDAAuD;IACvD,YAAY,CAAC,EAAE,sBAAsB,CAAC;CACvC;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,gBAAgB,CAAC,oBAAoB,CAShE,CAAC;AA6LH,YAAY,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `inferenceAgent` — the in-tree reference `AgentAdapter`.
|
|
3
|
+
*
|
|
4
|
+
* Wraps `runAgentWithTools` (the OpenAI-compatible inference loop) behind
|
|
5
|
+
* the canonical adapter protocol so the loop becomes one valid adapter
|
|
6
|
+
* alongside future sibling adapters (pi, Claude Code, OpenAI Agents SDK).
|
|
7
|
+
*
|
|
8
|
+
* Declared capabilities:
|
|
9
|
+
* - streaming: 'text' (content deltas only)
|
|
10
|
+
* - cancellation: 'cooperative' (honors `options.signal` and `abort()`)
|
|
11
|
+
* - resumption: 'none'
|
|
12
|
+
* - structuredOutput: 'prompted' (uses ./structured-output.ts)
|
|
13
|
+
*
|
|
14
|
+
* The run starts lazily: the underlying `runAgentWithTools` is invoked
|
|
15
|
+
* when either `events` is iterated or `result` is awaited, whichever comes
|
|
16
|
+
* first. Translation rules from runner stream events → canonical
|
|
17
|
+
* `AgentEvent`s are documented inline on the `onStreamEvent` callback.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
import { runAgentWithTools, } from '../agent/index.js';
|
|
22
|
+
import { defineAgentAdapter, } from './protocol.js';
|
|
23
|
+
import { composeAbort, createEventQueue, lazyEvents } from './run-helpers.js';
|
|
24
|
+
import { serializeError } from './serialize-error.js';
|
|
25
|
+
import { applyStructuredOutputPrompt, parseStructuredFromText, } from './structured-output.js';
|
|
26
|
+
import { TurnAccumulator } from './turn-accumulator.js';
|
|
27
|
+
const ADAPTER_ID = 'inference';
|
|
28
|
+
/**
|
|
29
|
+
* The adapter metadata, suitable for registration alongside future siblings.
|
|
30
|
+
*
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export const inferenceAgent = defineAgentAdapter({
|
|
34
|
+
id: ADAPTER_ID,
|
|
35
|
+
capabilities: {
|
|
36
|
+
streaming: 'text',
|
|
37
|
+
cancellation: 'cooperative',
|
|
38
|
+
resumption: 'none',
|
|
39
|
+
structuredOutput: 'prompted',
|
|
40
|
+
},
|
|
41
|
+
adapter: createInferenceAdapter,
|
|
42
|
+
});
|
|
43
|
+
function createInferenceAdapter(config, options = {}) {
|
|
44
|
+
const source = ADAPTER_ID;
|
|
45
|
+
const traceId = options.traceId;
|
|
46
|
+
const { signal: compositeSignal, controller } = composeAbort(options.signal);
|
|
47
|
+
const queue = createEventQueue(options.eventBus);
|
|
48
|
+
const pushEvent = queue.push;
|
|
49
|
+
const closeStream = queue.close;
|
|
50
|
+
// Stream-event bridge: translate runner events to canonical AgentEvents.
|
|
51
|
+
// The runner emits `round_complete` BEFORE that round's `tool_call_started`
|
|
52
|
+
// events — see `TurnAccumulator` for the deferral pattern that handles
|
|
53
|
+
// this without misattributing tool calls to the wrong turn.
|
|
54
|
+
const turns = new TurnAccumulator(pushEvent, source, traceId);
|
|
55
|
+
const onStreamEvent = (e) => {
|
|
56
|
+
switch (e.type) {
|
|
57
|
+
case 'content_delta':
|
|
58
|
+
turns.text(e.delta);
|
|
59
|
+
break;
|
|
60
|
+
case 'tool_call_started':
|
|
61
|
+
turns.toolCall(e.toolCall.id, e.toolCall.name, e.toolCall.input);
|
|
62
|
+
break;
|
|
63
|
+
case 'tool_call_complete':
|
|
64
|
+
turns.toolResult(e.toolCall.id, e.toolCall.name, e.result.content, false);
|
|
65
|
+
break;
|
|
66
|
+
case 'round_complete':
|
|
67
|
+
turns.markTurnEnd();
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
// Lazy start: kick off the underlying runner the first time either
|
|
72
|
+
// `events` is iterated or `result` is awaited. The promise itself acts
|
|
73
|
+
// as the memoization barrier.
|
|
74
|
+
let started = false;
|
|
75
|
+
let runPromise = null;
|
|
76
|
+
const startIfNeeded = () => {
|
|
77
|
+
if (runPromise)
|
|
78
|
+
return runPromise;
|
|
79
|
+
started = true;
|
|
80
|
+
runPromise = runOnce();
|
|
81
|
+
return runPromise;
|
|
82
|
+
};
|
|
83
|
+
async function runOnce() {
|
|
84
|
+
// The outer try/catch is purely defensive — `runAgentWithTools`
|
|
85
|
+
// already swallows its own errors into a `finishReason: 'error'`
|
|
86
|
+
// result, but we surface anything that slips through as an error
|
|
87
|
+
// event + synthetic result.
|
|
88
|
+
pushEvent({ type: 'agent_start', source, traceId });
|
|
89
|
+
// Apply prompted-output instruction up front, if requested.
|
|
90
|
+
const effectiveConfig = config.outputSchema
|
|
91
|
+
? {
|
|
92
|
+
...config.config,
|
|
93
|
+
systemPrompt: applyStructuredOutputPrompt(config.config.systemPrompt, config.outputSchema),
|
|
94
|
+
}
|
|
95
|
+
: config.config;
|
|
96
|
+
let runnerResult;
|
|
97
|
+
try {
|
|
98
|
+
runnerResult = await runAgentWithTools(effectiveConfig, config.messages, {
|
|
99
|
+
...config.runnerOptions,
|
|
100
|
+
signal: compositeSignal,
|
|
101
|
+
onStreamEvent,
|
|
102
|
+
}, config.config.name);
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
// Defensive path: emit error + agent_end + synthesize a result.
|
|
106
|
+
turns.close();
|
|
107
|
+
pushEvent({
|
|
108
|
+
type: 'error',
|
|
109
|
+
source,
|
|
110
|
+
traceId,
|
|
111
|
+
error: serializeError(err),
|
|
112
|
+
transient: false,
|
|
113
|
+
});
|
|
114
|
+
const reason = compositeSignal.aborted ? 'aborted' : 'error';
|
|
115
|
+
pushEvent({ type: 'agent_end', source, traceId, reason });
|
|
116
|
+
closeStream();
|
|
117
|
+
return {
|
|
118
|
+
text: '',
|
|
119
|
+
finishReason: reason,
|
|
120
|
+
usage: { promptTokens: 0, completionTokens: 0, totalTokens: 0 },
|
|
121
|
+
executedToolCalls: [],
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
// Flush any pending turn_end armed during the last round_complete.
|
|
125
|
+
turns.close();
|
|
126
|
+
// If the runner reported 'error' but we asked for abort, override
|
|
127
|
+
// the finish reason — cancellation has a first-class encoding in
|
|
128
|
+
// the canonical vocabulary. `compositeSignal.aborted` reflects both
|
|
129
|
+
// `run.abort()` and `options.signal` paths via AbortSignal.any.
|
|
130
|
+
let finishReason = runnerResult.finishReason;
|
|
131
|
+
if (compositeSignal.aborted) {
|
|
132
|
+
finishReason = 'aborted';
|
|
133
|
+
}
|
|
134
|
+
else if (finishReason === 'error') {
|
|
135
|
+
// The runner encoded an error inside the result; surface it as an
|
|
136
|
+
// explicit error event so consumers see the same shape as the
|
|
137
|
+
// defensive path above.
|
|
138
|
+
const message = tryExtractErrorMessage(runnerResult.text);
|
|
139
|
+
pushEvent({
|
|
140
|
+
type: 'error',
|
|
141
|
+
source,
|
|
142
|
+
traceId,
|
|
143
|
+
error: { name: 'AgentRunError', message },
|
|
144
|
+
transient: false,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
// Build the canonical result. The runner's `AgentRunResult` is
|
|
148
|
+
// assignable to ours (required → optional widening), but we
|
|
149
|
+
// re-shape explicitly so future changes to either side don't
|
|
150
|
+
// silently couple.
|
|
151
|
+
let parsed = undefined;
|
|
152
|
+
let parseError = undefined;
|
|
153
|
+
if (config.outputSchema) {
|
|
154
|
+
try {
|
|
155
|
+
parsed = parseStructuredFromText(runnerResult.text, config.outputSchema);
|
|
156
|
+
}
|
|
157
|
+
catch (err) {
|
|
158
|
+
parseError = serializeError(err);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const result = {
|
|
162
|
+
text: runnerResult.text,
|
|
163
|
+
finishReason,
|
|
164
|
+
usage: runnerResult.usage,
|
|
165
|
+
executedToolCalls: runnerResult.executedToolCalls,
|
|
166
|
+
activity: runnerResult.activity,
|
|
167
|
+
parsed,
|
|
168
|
+
parseError,
|
|
169
|
+
};
|
|
170
|
+
pushEvent({ type: 'agent_end', source, traceId, reason: finishReason });
|
|
171
|
+
closeStream();
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
events: lazyEvents(queue.events, startIfNeeded),
|
|
176
|
+
get result() {
|
|
177
|
+
return startIfNeeded();
|
|
178
|
+
},
|
|
179
|
+
abort(reason) {
|
|
180
|
+
// AbortController.abort is idempotent — second call is a no-op.
|
|
181
|
+
controller.abort(reason);
|
|
182
|
+
// If the run hasn't started yet, kick it off now so the queued
|
|
183
|
+
// abort takes effect — otherwise `result` would never resolve.
|
|
184
|
+
if (!started)
|
|
185
|
+
startIfNeeded();
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Best-effort extraction of an embedded error message from the runner's
|
|
191
|
+
* synthetic JSON error payload. Falls back to the raw text when the shape
|
|
192
|
+
* doesn't match.
|
|
193
|
+
*/
|
|
194
|
+
function tryExtractErrorMessage(text) {
|
|
195
|
+
try {
|
|
196
|
+
const parsed = JSON.parse(text);
|
|
197
|
+
if (parsed !== null &&
|
|
198
|
+
typeof parsed === 'object' &&
|
|
199
|
+
'_error' in parsed &&
|
|
200
|
+
typeof parsed.message === 'string') {
|
|
201
|
+
return parsed.message;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
// not JSON
|
|
206
|
+
}
|
|
207
|
+
return text || 'agent error';
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=inference-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inference-adapter.js","sourceRoot":"","sources":["../../src/agents/inference-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EACL,iBAAiB,GAKlB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,kBAAkB,GAMnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,GAExB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,UAAU,GAAG,WAAW,CAAC;AAuB/B;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,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YACf,OAAO,MAAM,KAAK,QAAQ;YAC1B,QAAQ,IAAI,MAAM;YAClB,OAAQ,MAAgC,CAAC,OAAO,KAAK,QAAQ,EAC7D,CAAC;YACD,OAAQ,MAAgC,CAAC,OAAiB,CAAC;QAC7D,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,WAAW;IACb,CAAC;IACD,OAAO,IAAI,IAAI,aAAa,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge `AgentEventBus` → `JobStore` for pipelines that want every
|
|
3
|
+
* adapter event persisted to the job event log.
|
|
4
|
+
*
|
|
5
|
+
* Without this bridge, JobStore captures pipeline-level events (the
|
|
6
|
+
* `PipelineEvent` stream from each phase) but adapter-level events
|
|
7
|
+
* — text deltas, tool calls, thinking, native — flow only through
|
|
8
|
+
* the bus and are lost when the run ends. Callers writing this glue
|
|
9
|
+
* by hand would reach for `bus.on((event) => store.appendEvent(...))`;
|
|
10
|
+
* this helper ships the canonical version with a clean unsubscribe.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
import type { JobStore } from '../session/index.js';
|
|
15
|
+
import type { AgentEvent, AgentEventBus } from './protocol.js';
|
|
16
|
+
/** @internal */
|
|
17
|
+
export interface PipeAgentEventsOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Event types to drop rather than persist. Useful for high-volume
|
|
20
|
+
* `text` deltas that would balloon the event log. Default: persist
|
|
21
|
+
* everything.
|
|
22
|
+
*/
|
|
23
|
+
dropTypes?: ReadonlyArray<AgentEvent['type']>;
|
|
24
|
+
/**
|
|
25
|
+
* Override the `key` written on each appended `PipelineEvent`. By
|
|
26
|
+
* default, `agent:<source>:<type>` so consumers reading the log
|
|
27
|
+
* can filter by source or type. Set to a fixed string when you
|
|
28
|
+
* want all adapter events to share one key.
|
|
29
|
+
*/
|
|
30
|
+
key?: string | ((event: AgentEvent) => string);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Subscribe to a bus and append every agent event to the JobStore
|
|
34
|
+
* under the given job id. Returns an unsubscribe function — call it
|
|
35
|
+
* when the job ends so the bus doesn't retain the store reference.
|
|
36
|
+
*
|
|
37
|
+
* Adapter events are wrapped in a `PipelineEvent` of type `'data'`
|
|
38
|
+
* (the JobStore's escape hatch for arbitrary payloads); the canonical
|
|
39
|
+
* `AgentEvent` is the `value`.
|
|
40
|
+
*
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
export declare function pipeAgentEventsToJobStore(bus: AgentEventBus, store: JobStore, jobId: string, options?: PipeAgentEventsOptions): () => void;
|
|
44
|
+
//# sourceMappingURL=job-store-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-store-bridge.d.ts","sourceRoot":"","sources":["../../src/agents/job-store-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE/D,gBAAgB;AAChB,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9C;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,UAAU,KAAK,MAAM,CAAC,CAAC;CAChD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,aAAa,EAClB,KAAK,EAAE,QAAQ,EACf,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,sBAA2B,GACnC,MAAM,IAAI,CA+BZ"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge `AgentEventBus` → `JobStore` for pipelines that want every
|
|
3
|
+
* adapter event persisted to the job event log.
|
|
4
|
+
*
|
|
5
|
+
* Without this bridge, JobStore captures pipeline-level events (the
|
|
6
|
+
* `PipelineEvent` stream from each phase) but adapter-level events
|
|
7
|
+
* — text deltas, tool calls, thinking, native — flow only through
|
|
8
|
+
* the bus and are lost when the run ends. Callers writing this glue
|
|
9
|
+
* by hand would reach for `bus.on((event) => store.appendEvent(...))`;
|
|
10
|
+
* this helper ships the canonical version with a clean unsubscribe.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Subscribe to a bus and append every agent event to the JobStore
|
|
16
|
+
* under the given job id. Returns an unsubscribe function — call it
|
|
17
|
+
* when the job ends so the bus doesn't retain the store reference.
|
|
18
|
+
*
|
|
19
|
+
* Adapter events are wrapped in a `PipelineEvent` of type `'data'`
|
|
20
|
+
* (the JobStore's escape hatch for arbitrary payloads); the canonical
|
|
21
|
+
* `AgentEvent` is the `value`.
|
|
22
|
+
*
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
export function pipeAgentEventsToJobStore(bus, store, jobId, options = {}) {
|
|
26
|
+
const dropTypes = new Set(options.dropTypes ?? []);
|
|
27
|
+
const keyFn = typeof options.key === 'function'
|
|
28
|
+
? options.key
|
|
29
|
+
: options.key !== undefined
|
|
30
|
+
? () => options.key
|
|
31
|
+
: (event) => `agent:${event.source}:${event.type}`;
|
|
32
|
+
return bus.on((event) => {
|
|
33
|
+
if (dropTypes.has(event.type))
|
|
34
|
+
return;
|
|
35
|
+
const pipelineEvent = {
|
|
36
|
+
type: 'data',
|
|
37
|
+
key: keyFn(event),
|
|
38
|
+
value: event,
|
|
39
|
+
};
|
|
40
|
+
// Fire-and-forget: the bus signature is sync (`(event) => void`) but
|
|
41
|
+
// appendEvent is async in v3. We swallow rejections so a store
|
|
42
|
+
// failure doesn't poison the bus or surface as an unhandled
|
|
43
|
+
// rejection. Callers wanting failure visibility should subscribe
|
|
44
|
+
// a separate logging handler.
|
|
45
|
+
try {
|
|
46
|
+
const result = store.appendEvent(jobId, pipelineEvent);
|
|
47
|
+
if (result && typeof result.then === 'function') {
|
|
48
|
+
result.catch(() => {
|
|
49
|
+
/* swallow — see comment above */
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// Sync throws (shouldn't happen with async API but defensive).
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=job-store-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-store-bridge.js","sourceRoot":"","sources":["../../src/agents/job-store-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAuBH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,yBAAyB,CACvC,GAAkB,EAClB,KAAe,EACf,KAAa,EACb,UAAkC,EAAE;IAEpC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;IACnD,MAAM,KAAK,GAAG,OAAO,OAAO,CAAC,GAAG,KAAK,UAAU;QAC7C,CAAC,CAAC,OAAO,CAAC,GAAG;QACb,CAAC,CAAC,OAAO,CAAC,GAAG,KAAK,SAAS;YACzB,CAAC,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAa;YAC7B,CAAC,CAAC,CAAC,KAAiB,EAAU,EAAE,CAAC,SAAS,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;IAE3E,OAAO,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE;QACtB,IAAI,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;YAAE,OAAO;QACtC,MAAM,aAAa,GAAkB;YACnC,IAAI,EAAE,MAAM;YACZ,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC;YACjB,KAAK,EAAE,KAAK;SACb,CAAC;QACF,qEA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