@thoughtminers/agent-runtime-core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +31 -0
- package/dist/agent.d.ts +65 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +324 -0
- package/dist/agent.js.map +1 -0
- package/dist/context/budget.d.ts +23 -0
- package/dist/context/budget.d.ts.map +1 -0
- package/dist/context/budget.js +18 -0
- package/dist/context/budget.js.map +1 -0
- package/dist/context/replay.d.ts +66 -0
- package/dist/context/replay.d.ts.map +1 -0
- package/dist/context/replay.js +171 -0
- package/dist/context/replay.js.map +1 -0
- package/dist/context/summarize.d.ts +12 -0
- package/dist/context/summarize.d.ts.map +1 -0
- package/dist/context/summarize.js +38 -0
- package/dist/context/summarize.js.map +1 -0
- package/dist/generate.d.ts +13 -0
- package/dist/generate.d.ts.map +1 -0
- package/dist/generate.js +69 -0
- package/dist/generate.js.map +1 -0
- package/dist/hooks.d.ts +53 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +76 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/lock/memory.d.ts +12 -0
- package/dist/lock/memory.d.ts.map +1 -0
- package/dist/lock/memory.js +46 -0
- package/dist/lock/memory.js.map +1 -0
- package/dist/loop.d.ts +53 -0
- package/dist/loop.d.ts.map +1 -0
- package/dist/loop.js +165 -0
- package/dist/loop.js.map +1 -0
- package/dist/provider/mock.d.ts +22 -0
- package/dist/provider/mock.d.ts.map +1 -0
- package/dist/provider/mock.js +68 -0
- package/dist/provider/mock.js.map +1 -0
- package/dist/store/conformance.d.ts +9 -0
- package/dist/store/conformance.d.ts.map +1 -0
- package/dist/store/conformance.js +109 -0
- package/dist/store/conformance.js.map +1 -0
- package/dist/store/memory.d.ts +11 -0
- package/dist/store/memory.d.ts.map +1 -0
- package/dist/store/memory.js +94 -0
- package/dist/store/memory.js.map +1 -0
- package/dist/types/events.d.ts +51 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +2 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/hooks.d.ts +96 -0
- package/dist/types/hooks.d.ts.map +1 -0
- package/dist/types/hooks.js +2 -0
- package/dist/types/hooks.js.map +1 -0
- package/dist/types/lock.d.ts +18 -0
- package/dist/types/lock.d.ts.map +1 -0
- package/dist/types/lock.js +11 -0
- package/dist/types/lock.js.map +1 -0
- package/dist/types/provider.d.ts +73 -0
- package/dist/types/provider.d.ts.map +1 -0
- package/dist/types/provider.js +2 -0
- package/dist/types/provider.js.map +1 -0
- package/dist/types/store.d.ts +76 -0
- package/dist/types/store.d.ts.map +1 -0
- package/dist/types/store.js +2 -0
- package/dist/types/store.js.map +1 -0
- package/dist/types/tools.d.ts +49 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +2 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/types/turns.d.ts +47 -0
- package/dist/types/turns.d.ts.map +1 -0
- package/dist/types/turns.js +7 -0
- package/dist/types/turns.js.map +1 -0
- package/dist/util.d.ts +10 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +37 -0
- package/dist/util.js.map +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { ConversationStore } from './store.js';
|
|
2
|
+
export interface Logger {
|
|
3
|
+
debug(msg: string, data?: unknown): void;
|
|
4
|
+
info(msg: string, data?: unknown): void;
|
|
5
|
+
warn(msg: string, data?: unknown): void;
|
|
6
|
+
error(msg: string, data?: unknown): void;
|
|
7
|
+
}
|
|
8
|
+
/** A one-shot generation available to hooks and tools, at their OWN model. */
|
|
9
|
+
export interface HookLlmRequest {
|
|
10
|
+
prompt: string;
|
|
11
|
+
system?: string;
|
|
12
|
+
/** Defaults to the hook's declared model, else the agent model. */
|
|
13
|
+
model?: string;
|
|
14
|
+
maxOutputTokens?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Capabilities handed to every hook and tool. `Ctx` is the opaque
|
|
18
|
+
* caller-supplied identity/context — the harness never inspects it.
|
|
19
|
+
*/
|
|
20
|
+
export interface StepContext<Ctx = unknown> {
|
|
21
|
+
conversationId: string;
|
|
22
|
+
runId: string;
|
|
23
|
+
/** The inbound user message text. */
|
|
24
|
+
input: string;
|
|
25
|
+
/**
|
|
26
|
+
* Mutable loop state for blocking steps (enrichment written here is visible
|
|
27
|
+
* to the loop); async steps receive a frozen structuredClone snapshot.
|
|
28
|
+
*/
|
|
29
|
+
state: Record<string, unknown>;
|
|
30
|
+
ctx: Ctx;
|
|
31
|
+
llm(req: HookLlmRequest): Promise<string>;
|
|
32
|
+
store: ConversationStore;
|
|
33
|
+
signal: AbortSignal;
|
|
34
|
+
log: Logger;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Reduced context for lazyload tools re-run at replay time. No `state`, no
|
|
38
|
+
* `store`, no `llm` — as close to type-enforced purity as TypeScript gets.
|
|
39
|
+
*/
|
|
40
|
+
export type LazyContext<Ctx = unknown> = Pick<StepContext<Ctx>, 'conversationId' | 'ctx' | 'signal' | 'log'>;
|
|
41
|
+
export type StepResult = {
|
|
42
|
+
action: 'continue';
|
|
43
|
+
} | {
|
|
44
|
+
action: 'halt';
|
|
45
|
+
response: string;
|
|
46
|
+
} | {
|
|
47
|
+
action: 'replace';
|
|
48
|
+
response: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Pre-hooks run before the loop, in declaration order.
|
|
52
|
+
* The `mode` discriminant selects the run signature: an async hook returns
|
|
53
|
+
* Promise<void>, so "an async hook that halts" is a compile error.
|
|
54
|
+
*/
|
|
55
|
+
export type PreHook<Ctx = unknown> = {
|
|
56
|
+
name: string;
|
|
57
|
+
mode: 'blocking';
|
|
58
|
+
model?: string;
|
|
59
|
+
run(step: StepContext<Ctx>): Promise<StepResult>;
|
|
60
|
+
} | {
|
|
61
|
+
name: string;
|
|
62
|
+
mode: 'async';
|
|
63
|
+
model?: string;
|
|
64
|
+
/** Fire-and-forget; frozen state; errors swallowed + logged. */
|
|
65
|
+
run(step: Readonly<StepContext<Ctx>>): Promise<void>;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Post-hooks run after the loop. Orthogonal axes:
|
|
69
|
+
* mode: blocking | async
|
|
70
|
+
* delivery: streamable (delta transformer) | terminal (needs full text)
|
|
71
|
+
* The union below is exactly the legal set:
|
|
72
|
+
* - streamable is only meaningful as a blocking transformer on the live stream
|
|
73
|
+
* - a blocking terminal hook forces BUFFER MODE (no deltas reach the consumer
|
|
74
|
+
* until every terminal hook has run)
|
|
75
|
+
* - async is inherently terminal (full-text snapshot, void return)
|
|
76
|
+
*/
|
|
77
|
+
export type PostHook<Ctx = unknown> = {
|
|
78
|
+
name: string;
|
|
79
|
+
mode: 'blocking';
|
|
80
|
+
delivery: 'streamable';
|
|
81
|
+
model?: string;
|
|
82
|
+
/** Runs on the live stream; returns the (possibly rewritten) delta. */
|
|
83
|
+
transform(delta: string, step: StepContext<Ctx>): string | Promise<string>;
|
|
84
|
+
} | {
|
|
85
|
+
name: string;
|
|
86
|
+
mode: 'blocking';
|
|
87
|
+
delivery: 'terminal';
|
|
88
|
+
model?: string;
|
|
89
|
+
run(step: StepContext<Ctx>, fullText: string): Promise<StepResult>;
|
|
90
|
+
} | {
|
|
91
|
+
name: string;
|
|
92
|
+
mode: 'async';
|
|
93
|
+
model?: string;
|
|
94
|
+
run(step: Readonly<StepContext<Ctx>>, fullText: string): Promise<void>;
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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,MAAM,CAAC;IACf,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACpE,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/types/hooks.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-conversation serialization with SUPERSEDE semantics: claiming a
|
|
3
|
+
* conversation that already has a live lease aborts that lease's run (its
|
|
4
|
+
* `signal` fires) and resolves once it releases. The newer message then
|
|
5
|
+
* processes with the fuller context — "abort the previous" by construction.
|
|
6
|
+
*
|
|
7
|
+
* Queue/drain semantics (process every message eventually) belong to the
|
|
8
|
+
* transport layer above the harness.
|
|
9
|
+
*/
|
|
10
|
+
export interface Lease {
|
|
11
|
+
/** Fires when a newer claim supersedes this run — threaded into the loop. */
|
|
12
|
+
signal: AbortSignal;
|
|
13
|
+
release(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export interface Lock {
|
|
16
|
+
claim(conversationId: string): Promise<Lease>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=lock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lock.d.ts","sourceRoot":"","sources":["../../src/types/lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,WAAW,KAAK;IACpB,6EAA6E;IAC7E,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,MAAM,WAAW,IAAI;IACnB,KAAK,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;CAC/C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-conversation serialization with SUPERSEDE semantics: claiming a
|
|
3
|
+
* conversation that already has a live lease aborts that lease's run (its
|
|
4
|
+
* `signal` fires) and resolves once it releases. The newer message then
|
|
5
|
+
* processes with the fuller context — "abort the previous" by construction.
|
|
6
|
+
*
|
|
7
|
+
* Queue/drain semantics (process every message eventually) belong to the
|
|
8
|
+
* transport layer above the harness.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=lock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lock.js","sourceRoot":"","sources":["../../src/types/lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { JSONSchema, ToolCall, Turn } from './turns.js';
|
|
2
|
+
/**
|
|
3
|
+
* Normalized stop reasons. Adapters map their wire values into this set;
|
|
4
|
+
* anything unmappable becomes 'other'.
|
|
5
|
+
*/
|
|
6
|
+
export type StopReason = 'end_turn' | 'tool_use' | 'max_tokens' | 'stop_sequence' | 'refusal' | 'other';
|
|
7
|
+
export interface Usage {
|
|
8
|
+
inputTokens: number;
|
|
9
|
+
outputTokens: number;
|
|
10
|
+
cacheReadInputTokens?: number;
|
|
11
|
+
cacheCreationInputTokens?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The normalized event union every provider emits. Proven shape: the same
|
|
15
|
+
* five events cleanly cover Anthropic, OpenAI-family, and Gemini streaming.
|
|
16
|
+
*/
|
|
17
|
+
export type ProviderEvent = {
|
|
18
|
+
type: 'text_delta';
|
|
19
|
+
text: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: 'tool_use_start';
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
} | {
|
|
25
|
+
type: 'tool_input_delta';
|
|
26
|
+
json: string;
|
|
27
|
+
} | {
|
|
28
|
+
type: 'tool_use_end';
|
|
29
|
+
} | {
|
|
30
|
+
type: 'message_done';
|
|
31
|
+
stopReason: StopReason;
|
|
32
|
+
usage?: Usage;
|
|
33
|
+
};
|
|
34
|
+
export interface ToolSpec {
|
|
35
|
+
name: string;
|
|
36
|
+
description: string;
|
|
37
|
+
inputSchema: JSONSchema;
|
|
38
|
+
}
|
|
39
|
+
export interface GenerateRequest {
|
|
40
|
+
model: string;
|
|
41
|
+
maxOutputTokens: number;
|
|
42
|
+
system?: string;
|
|
43
|
+
/** Never contains role:'system' turns — system travels separately. */
|
|
44
|
+
turns: Turn[];
|
|
45
|
+
tools?: ToolSpec[];
|
|
46
|
+
toolChoice?: 'auto' | 'any' | 'none';
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The provider seam: ONE generation turn as a normalized event stream.
|
|
50
|
+
* The harness owns the loop; a provider only knows how to generate once.
|
|
51
|
+
*/
|
|
52
|
+
export interface Provider {
|
|
53
|
+
readonly name: string;
|
|
54
|
+
/** Total context window (tokens) for a model id. */
|
|
55
|
+
contextWindow(model: string): number;
|
|
56
|
+
/** Optional accurate counter; the harness falls back to chars/4. */
|
|
57
|
+
countTokens?(text: string, model: string): number | Promise<number>;
|
|
58
|
+
/**
|
|
59
|
+
* MUST respect `signal`: abort the upstream request and throw an error with
|
|
60
|
+
* name === 'AbortError'.
|
|
61
|
+
*/
|
|
62
|
+
stream(req: GenerateRequest, opts?: {
|
|
63
|
+
signal?: AbortSignal;
|
|
64
|
+
}): AsyncIterable<ProviderEvent>;
|
|
65
|
+
}
|
|
66
|
+
/** Result of collecting one provider stream. */
|
|
67
|
+
export interface CollectedTurn {
|
|
68
|
+
text: string;
|
|
69
|
+
toolCalls: ToolCall[];
|
|
70
|
+
stopReason: StopReason;
|
|
71
|
+
usage?: Usage;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/types/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAE7D;;;GAGG;AACH,MAAM,MAAM,UAAU,GACpB,UAAU,GAAG,UAAU,GAAG,YAAY,GAAG,eAAe,GAAG,SAAS,GAAG,OAAO,CAAC;AAEjF,MAAM,WAAW,KAAK;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACpD;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,GACxB;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,UAAU,EAAE,UAAU,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAEpE,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,UAAU,CAAC;CACzB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sEAAsE;IACtE,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;CACtC;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACrC,oEAAoE;IACpE,WAAW,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACpE;;;OAGG;IACH,MAAM,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,aAAa,CAAC,aAAa,CAAC,CAAC;CAC7F;AAED,gDAAgD;AAChD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/types/provider.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { Usage } from './provider.js';
|
|
2
|
+
/**
|
|
3
|
+
* Two-table storage model:
|
|
4
|
+
* - `messages` — the user-facing transcript (what the human saw)
|
|
5
|
+
* - `messages_llm` — the raw agent trace (what the model actually did)
|
|
6
|
+
*
|
|
7
|
+
* The trace is APPEND-ONLY: the wire payload is reconstructed at replay time
|
|
8
|
+
* (with per-tool compaction policies applied); stored rows are never mutated
|
|
9
|
+
* except the `interrupted` flag.
|
|
10
|
+
*/
|
|
11
|
+
export interface MessageRecord {
|
|
12
|
+
id: string;
|
|
13
|
+
conversationId: string;
|
|
14
|
+
role: 'user' | 'assistant';
|
|
15
|
+
content: string;
|
|
16
|
+
/** Idempotency key (e.g. the transport's message id). UNIQUE per conversation. */
|
|
17
|
+
externalMessageId: string | null;
|
|
18
|
+
interrupted: boolean;
|
|
19
|
+
createdAt: Date;
|
|
20
|
+
}
|
|
21
|
+
export interface ToolCallEntry {
|
|
22
|
+
/** Provider tool-use id, verbatim. */
|
|
23
|
+
id: string;
|
|
24
|
+
/** Registry key — the compaction policy is resolved by this name at replay. */
|
|
25
|
+
name: string;
|
|
26
|
+
/** Verbatim model args. */
|
|
27
|
+
input: unknown;
|
|
28
|
+
/** Verbatim result, OR { lazy: true } stub (lazyload tools), OR null on error. */
|
|
29
|
+
result: unknown;
|
|
30
|
+
error: string | null;
|
|
31
|
+
}
|
|
32
|
+
/** One trace row. Tool results live embedded on the assistant row. */
|
|
33
|
+
export interface TraceRecord {
|
|
34
|
+
id: string;
|
|
35
|
+
conversationId: string;
|
|
36
|
+
/** Groups every row produced for one inbound message. */
|
|
37
|
+
runId: string;
|
|
38
|
+
role: 'user' | 'assistant';
|
|
39
|
+
content: string | null;
|
|
40
|
+
toolCalls: ToolCallEntry[] | null;
|
|
41
|
+
model: string | null;
|
|
42
|
+
usage: Usage | null;
|
|
43
|
+
latencyMs: number | null;
|
|
44
|
+
interrupted: boolean;
|
|
45
|
+
createdAt: Date;
|
|
46
|
+
}
|
|
47
|
+
export type NewMessage = Omit<MessageRecord, 'id' | 'createdAt' | 'interrupted'> & {
|
|
48
|
+
interrupted?: boolean;
|
|
49
|
+
};
|
|
50
|
+
export type NewTrace = Omit<TraceRecord, 'id' | 'createdAt' | 'interrupted'> & {
|
|
51
|
+
interrupted?: boolean;
|
|
52
|
+
};
|
|
53
|
+
export interface ConversationHistory {
|
|
54
|
+
/** Chronological user-facing messages. */
|
|
55
|
+
messages: MessageRecord[];
|
|
56
|
+
/** Chronological trace rows (all runs). */
|
|
57
|
+
trace: TraceRecord[];
|
|
58
|
+
}
|
|
59
|
+
export interface ConversationStore {
|
|
60
|
+
/** Idempotency: has this external message id already been ingested? */
|
|
61
|
+
seen(conversationId: string, externalMessageId: string): Promise<boolean>;
|
|
62
|
+
/**
|
|
63
|
+
* Append a user-facing message. MUST be idempotent on
|
|
64
|
+
* (conversationId, externalMessageId): a duplicate returns the existing row.
|
|
65
|
+
*/
|
|
66
|
+
appendMessage(msg: NewMessage): Promise<MessageRecord>;
|
|
67
|
+
/** Append one raw trace row (append-only). */
|
|
68
|
+
appendTrace(row: NewTrace): Promise<TraceRecord>;
|
|
69
|
+
/** Everything the replay pipeline needs, chronological. */
|
|
70
|
+
loadHistory(conversationId: string, opts?: {
|
|
71
|
+
limit?: number;
|
|
72
|
+
}): Promise<ConversationHistory>;
|
|
73
|
+
/** Flag every row of an aborted run (rows were written incrementally). */
|
|
74
|
+
markRunInterrupted(runId: string): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/types/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE3C;;;;;;;;GAQG;AAEH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,kFAAkF;IAClF,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,sCAAsC;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,KAAK,EAAE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CAA8C;IAC9C,WAAW,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAEjD,2DAA2D;IAC3D,WAAW,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAE7F,0EAA0E;IAC1E,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/types/store.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { LazyContext, StepContext } from './hooks.js';
|
|
2
|
+
import type { JSONSchema } from './turns.js';
|
|
3
|
+
/**
|
|
4
|
+
* How a tool's persisted result is rendered into the replayed context.
|
|
5
|
+
* Resolved by tool NAME at replay time — pure data, so tuning a TTL is a
|
|
6
|
+
* constant change applied retroactively to all history, no migration.
|
|
7
|
+
* - keep: verbatim forever
|
|
8
|
+
* - ttl: verbatim until createdAt + ttlMs, then a small "stale" stub
|
|
9
|
+
* - drop: verbatim only inside the still-in-flight run; a marker afterwards
|
|
10
|
+
*/
|
|
11
|
+
export type CompactionPolicy = {
|
|
12
|
+
mode: 'keep';
|
|
13
|
+
} | {
|
|
14
|
+
mode: 'ttl';
|
|
15
|
+
ttlMs: number;
|
|
16
|
+
} | {
|
|
17
|
+
mode: 'drop';
|
|
18
|
+
};
|
|
19
|
+
export interface ToolOutcome {
|
|
20
|
+
/** JSON-serialized into the tool_result the model sees. */
|
|
21
|
+
result: unknown;
|
|
22
|
+
/** Optional user-facing text, surfaced as a `tool_emit` AgentEvent. */
|
|
23
|
+
emit?: string;
|
|
24
|
+
}
|
|
25
|
+
interface ToolShared {
|
|
26
|
+
name: string;
|
|
27
|
+
description: string;
|
|
28
|
+
/** RAW JSON Schema — schema libraries are a consumer concern, not core's. */
|
|
29
|
+
inputSchema: JSONSchema;
|
|
30
|
+
/** Default: { mode: 'keep' } */
|
|
31
|
+
compaction?: CompactionPolicy;
|
|
32
|
+
}
|
|
33
|
+
export interface Tool<Ctx = unknown> extends ToolShared {
|
|
34
|
+
lazyload?: false;
|
|
35
|
+
execute(input: unknown, step: StepContext<Ctx>): Promise<ToolOutcome>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Lazyload tool: a { lazy: true } stub is persisted instead of the verbatim
|
|
39
|
+
* result, and execute() is re-run at replay time to splice fresh data in.
|
|
40
|
+
* CONTRACT: execute MUST be pure/side-effect-free — the reduced LazyContext
|
|
41
|
+
* (no state, no store, no llm) enforces this as far as types can.
|
|
42
|
+
*/
|
|
43
|
+
export interface LazyTool<Ctx = unknown> extends ToolShared {
|
|
44
|
+
lazyload: true;
|
|
45
|
+
execute(input: unknown, step: LazyContext<Ctx>): Promise<ToolOutcome>;
|
|
46
|
+
}
|
|
47
|
+
export type AnyTool<Ctx = unknown> = Tool<Ctx> | LazyTool<Ctx>;
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/types/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpG,MAAM,WAAW,WAAW;IAC1B,2DAA2D;IAC3D,MAAM,EAAE,OAAO,CAAC;IAChB,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,WAAW,EAAE,UAAU,CAAC;IACxB,gCAAgC;IAChC,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAED,MAAM,WAAW,IAAI,CAAC,GAAG,GAAG,OAAO,CAAE,SAAQ,UAAU;IACrD,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CACvE;AAED;;;;;GAKG;AACH,MAAM,WAAW,QAAQ,CAAC,GAAG,GAAG,OAAO,CAAE,SAAQ,UAAU;IACzD,QAAQ,EAAE,IAAI,CAAC;IACf,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CACvE;AAED,MAAM,MAAM,OAAO,CAAC,GAAG,GAAG,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/types/tools.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-neutral message model. Providers render these turns to their own
|
|
3
|
+
* wire format (Anthropic content blocks, OpenAI chat messages, ...) — the core
|
|
4
|
+
* never sees a provider wire shape.
|
|
5
|
+
*/
|
|
6
|
+
/** Loose JSON Schema, passed verbatim to the provider wire format. */
|
|
7
|
+
export type JSONSchema = Record<string, unknown>;
|
|
8
|
+
export type ContentPart = {
|
|
9
|
+
type: 'text';
|
|
10
|
+
text: string;
|
|
11
|
+
} | {
|
|
12
|
+
type: 'image';
|
|
13
|
+
mediaType: string;
|
|
14
|
+
data: string;
|
|
15
|
+
} | Record<string, unknown>;
|
|
16
|
+
export interface ToolCall {
|
|
17
|
+
/** Provider tool-use id, verbatim. */
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
input: unknown;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* One provider-neutral conversational turn.
|
|
24
|
+
*
|
|
25
|
+
* Notes:
|
|
26
|
+
* - `system` turns never appear in GenerateRequest.turns (system travels
|
|
27
|
+
* separately); the variant exists for pipeline-internal representations.
|
|
28
|
+
* - Consecutive `tool_result` turns belong to ONE model round-trip; renderers
|
|
29
|
+
* MUST group them into a single user-side message (parallel-tool contract).
|
|
30
|
+
*/
|
|
31
|
+
export type Turn = {
|
|
32
|
+
role: 'system';
|
|
33
|
+
content: string;
|
|
34
|
+
} | {
|
|
35
|
+
role: 'user';
|
|
36
|
+
content: string | ContentPart[];
|
|
37
|
+
} | {
|
|
38
|
+
role: 'assistant';
|
|
39
|
+
content: string;
|
|
40
|
+
toolCalls?: ToolCall[];
|
|
41
|
+
} | {
|
|
42
|
+
role: 'tool_result';
|
|
43
|
+
toolUseId: string;
|
|
44
|
+
content: string | ContentPart[];
|
|
45
|
+
isError?: boolean;
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=turns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turns.d.ts","sourceRoot":"","sources":["../../src/types/turns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,sEAAsE;AACtE,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAClD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5B,MAAM,WAAW,QAAQ;IACvB,sCAAsC;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,IAAI,GACZ;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE,CAAA;CAAE,GACjD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAA;CAAE,GAC9D;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turns.js","sourceRoot":"","sources":["../../src/types/turns.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
package/dist/util.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Logger } from './types/hooks.js';
|
|
2
|
+
export declare const isAbortError: (err: unknown) => boolean;
|
|
3
|
+
export declare const newAbortError: (message?: string) => Error;
|
|
4
|
+
export declare const throwIfAborted: (signal: AbortSignal) => void;
|
|
5
|
+
/** Deep-freeze a structuredClone snapshot for async (fire-and-forget) steps. */
|
|
6
|
+
export declare const freezeState: <T>(value: T) => T;
|
|
7
|
+
export declare const consoleLogger: Logger;
|
|
8
|
+
/** A logger that drops everything (default for tests). */
|
|
9
|
+
export declare const silentLogger: Logger;
|
|
10
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,eAAO,MAAM,YAAY,GAAI,KAAK,OAAO,KAAG,OACO,CAAC;AAEpD,eAAO,MAAM,aAAa,GAAI,gBAAqC,KAAG,KAIrE,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,QAAQ,WAAW,KAAG,IAEpD,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,OAAO,CAAC,KAAG,CASzC,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,MAK3B,CAAC;AAEF,0DAA0D;AAC1D,eAAO,MAAM,YAAY,EAAE,MAK1B,CAAC"}
|
package/dist/util.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const isAbortError = (err) => err instanceof Error && err.name === 'AbortError';
|
|
2
|
+
export const newAbortError = (message = 'The operation was aborted') => {
|
|
3
|
+
const err = new Error(message);
|
|
4
|
+
err.name = 'AbortError';
|
|
5
|
+
return err;
|
|
6
|
+
};
|
|
7
|
+
export const throwIfAborted = (signal) => {
|
|
8
|
+
if (signal.aborted)
|
|
9
|
+
throw newAbortError();
|
|
10
|
+
};
|
|
11
|
+
/** Deep-freeze a structuredClone snapshot for async (fire-and-forget) steps. */
|
|
12
|
+
export const freezeState = (value) => {
|
|
13
|
+
const clone = structuredClone(value);
|
|
14
|
+
const deepFreeze = (obj) => {
|
|
15
|
+
if (obj === null || typeof obj !== 'object')
|
|
16
|
+
return;
|
|
17
|
+
Object.freeze(obj);
|
|
18
|
+
for (const v of Object.values(obj))
|
|
19
|
+
deepFreeze(v);
|
|
20
|
+
};
|
|
21
|
+
deepFreeze(clone);
|
|
22
|
+
return clone;
|
|
23
|
+
};
|
|
24
|
+
export const consoleLogger = {
|
|
25
|
+
debug: (msg, data) => console.debug(msg, data ?? ''),
|
|
26
|
+
info: (msg, data) => console.info(msg, data ?? ''),
|
|
27
|
+
warn: (msg, data) => console.warn(msg, data ?? ''),
|
|
28
|
+
error: (msg, data) => console.error(msg, data ?? ''),
|
|
29
|
+
};
|
|
30
|
+
/** A logger that drops everything (default for tests). */
|
|
31
|
+
export const silentLogger = {
|
|
32
|
+
debug: () => { },
|
|
33
|
+
info: () => { },
|
|
34
|
+
warn: () => { },
|
|
35
|
+
error: () => { },
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAY,EAAW,EAAE,CACpD,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY,CAAC;AAEpD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAO,GAAG,2BAA2B,EAAS,EAAE;IAC5E,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/B,GAAG,CAAC,IAAI,GAAG,YAAY,CAAC;IACxB,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAmB,EAAQ,EAAE;IAC1D,IAAI,MAAM,CAAC,OAAO;QAAE,MAAM,aAAa,EAAE,CAAC;AAC5C,CAAC,CAAC;AAEF,gFAAgF;AAChF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAI,KAAQ,EAAK,EAAE;IAC5C,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IACrC,MAAM,UAAU,GAAG,CAAC,GAAY,EAAQ,EAAE;QACxC,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE,OAAO;QACpD,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnB,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;YAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC,CAAC;IACF,UAAU,CAAC,KAAK,CAAC,CAAC;IAClB,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAW;IACnC,KAAK,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC;IACpD,IAAI,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC;IAClD,IAAI,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC;IAClD,KAAK,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC;CACrD,CAAC;AAEF,0DAA0D;AAC1D,MAAM,CAAC,MAAM,YAAY,GAAW;IAClC,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;IACf,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;IACd,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;IACd,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;CAChB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@thoughtminers/agent-runtime-core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Zero-dependency LLM agent harness: streaming loop, hooks, tools, replay-time compaction, per-conversation locking.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/thoughtminers/agent-runtime-core.git",
|
|
9
|
+
"directory": "packages/core"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/thoughtminers/agent-runtime-core#readme",
|
|
12
|
+
"bugs": "https://github.com/thoughtminers/agent-runtime-core/issues",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=24"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "^24.0.0",
|
|
32
|
+
"typescript": "^5.8.0"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc --build",
|
|
36
|
+
"test": "node --test 'test/**/*.test.ts' && tsc -p tsconfig.typetest.json"
|
|
37
|
+
}
|
|
38
|
+
}
|