@graphorin/core 0.5.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/CHANGELOG.md +27 -0
- package/LICENSE +21 -0
- package/README.md +70 -0
- package/dist/channels/channels.d.ts +156 -0
- package/dist/channels/channels.d.ts.map +1 -0
- package/dist/channels/channels.js +90 -0
- package/dist/channels/channels.js.map +1 -0
- package/dist/channels/directive.d.ts +34 -0
- package/dist/channels/directive.d.ts.map +1 -0
- package/dist/channels/directive.js +29 -0
- package/dist/channels/directive.js.map +1 -0
- package/dist/channels/dispatch.d.ts +26 -0
- package/dist/channels/dispatch.d.ts.map +1 -0
- package/dist/channels/dispatch.js +32 -0
- package/dist/channels/dispatch.js.map +1 -0
- package/dist/channels/index.d.ts +5 -0
- package/dist/channels/index.js +6 -0
- package/dist/channels/pause.d.ts +84 -0
- package/dist/channels/pause.d.ts.map +1 -0
- package/dist/channels/pause.js +90 -0
- package/dist/channels/pause.js.map +1 -0
- package/dist/contracts/auth-token-store.d.ts +45 -0
- package/dist/contracts/auth-token-store.d.ts.map +1 -0
- package/dist/contracts/checkpoint-store.d.ts +90 -0
- package/dist/contracts/checkpoint-store.d.ts.map +1 -0
- package/dist/contracts/embedder.d.ts +45 -0
- package/dist/contracts/embedder.d.ts.map +1 -0
- package/dist/contracts/eval-scorer.d.ts +46 -0
- package/dist/contracts/eval-scorer.d.ts.map +1 -0
- package/dist/contracts/index.d.ts +22 -0
- package/dist/contracts/index.js +6 -0
- package/dist/contracts/local-provider-trust.d.ts +36 -0
- package/dist/contracts/local-provider-trust.d.ts.map +1 -0
- package/dist/contracts/logger.d.ts +53 -0
- package/dist/contracts/logger.d.ts.map +1 -0
- package/dist/contracts/logger.js +21 -0
- package/dist/contracts/logger.js.map +1 -0
- package/dist/contracts/memory-store.d.ts +106 -0
- package/dist/contracts/memory-store.d.ts.map +1 -0
- package/dist/contracts/oauth-server-store.d.ts +81 -0
- package/dist/contracts/oauth-server-store.d.ts.map +1 -0
- package/dist/contracts/preferred-model.d.ts +60 -0
- package/dist/contracts/preferred-model.d.ts.map +1 -0
- package/dist/contracts/preferred-model.js +15 -0
- package/dist/contracts/preferred-model.js.map +1 -0
- package/dist/contracts/provider.d.ts +272 -0
- package/dist/contracts/provider.d.ts.map +1 -0
- package/dist/contracts/reasoning-retention.d.ts +53 -0
- package/dist/contracts/reasoning-retention.d.ts.map +1 -0
- package/dist/contracts/redaction-validator.d.ts +59 -0
- package/dist/contracts/redaction-validator.d.ts.map +1 -0
- package/dist/contracts/sandbox.d.ts +73 -0
- package/dist/contracts/sandbox.d.ts.map +1 -0
- package/dist/contracts/secret-ref.d.ts +26 -0
- package/dist/contracts/secret-ref.d.ts.map +1 -0
- package/dist/contracts/secret-value.d.ts +112 -0
- package/dist/contracts/secret-value.d.ts.map +1 -0
- package/dist/contracts/secret-value.js +24 -0
- package/dist/contracts/secret-value.js.map +1 -0
- package/dist/contracts/secrets-store.d.ts +87 -0
- package/dist/contracts/secrets-store.d.ts.map +1 -0
- package/dist/contracts/session-store.d.ts +142 -0
- package/dist/contracts/session-store.d.ts.map +1 -0
- package/dist/contracts/token-counter.d.ts +28 -0
- package/dist/contracts/token-counter.d.ts.map +1 -0
- package/dist/contracts/tool.d.ts +264 -0
- package/dist/contracts/tool.d.ts.map +1 -0
- package/dist/contracts/tracer.d.ts +84 -0
- package/dist/contracts/tracer.d.ts.map +1 -0
- package/dist/contracts/tracer.js +34 -0
- package/dist/contracts/tracer.js.map +1 -0
- package/dist/contracts/trigger-store.d.ts +43 -0
- package/dist/contracts/trigger-store.d.ts.map +1 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/types/agent-event.d.ts +449 -0
- package/dist/types/agent-event.d.ts.map +1 -0
- package/dist/types/handoff.d.ts +112 -0
- package/dist/types/handoff.d.ts.map +1 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/index.js +6 -0
- package/dist/types/memory.d.ts +354 -0
- package/dist/types/memory.d.ts.map +1 -0
- package/dist/types/message.d.ts +162 -0
- package/dist/types/message.d.ts.map +1 -0
- package/dist/types/run.d.ts +155 -0
- package/dist/types/run.d.ts.map +1 -0
- package/dist/types/run.js +31 -0
- package/dist/types/run.js.map +1 -0
- package/dist/types/sensitivity.d.ts +35 -0
- package/dist/types/sensitivity.d.ts.map +1 -0
- package/dist/types/sensitivity.js +29 -0
- package/dist/types/sensitivity.js.map +1 -0
- package/dist/types/session-scope.d.ts +22 -0
- package/dist/types/session-scope.d.ts.map +1 -0
- package/dist/types/stop-condition.d.ts +62 -0
- package/dist/types/stop-condition.d.ts.map +1 -0
- package/dist/types/stop-condition.js +81 -0
- package/dist/types/stop-condition.js.map +1 -0
- package/dist/types/tool-call.d.ts +27 -0
- package/dist/types/tool-call.d.ts.map +1 -0
- package/dist/types/tool.d.ts +260 -0
- package/dist/types/tool.d.ts.map +1 -0
- package/dist/types/usage.d.ts +82 -0
- package/dist/types/usage.d.ts.map +1 -0
- package/dist/types/usage.js +17 -0
- package/dist/types/usage.js.map +1 -0
- package/dist/types/workflow-event.d.ts +108 -0
- package/dist/types/workflow-event.d.ts.map +1 -0
- package/dist/utils/assert-never.d.ts +26 -0
- package/dist/utils/assert-never.d.ts.map +1 -0
- package/dist/utils/assert-never.js +29 -0
- package/dist/utils/assert-never.js.map +1 -0
- package/dist/utils/async-context.d.ts +37 -0
- package/dist/utils/async-context.d.ts.map +1 -0
- package/dist/utils/async-context.js +33 -0
- package/dist/utils/async-context.js.map +1 -0
- package/dist/utils/hash.d.ts +30 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/utils/hash.js +102 -0
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/streams.d.ts +59 -0
- package/dist/utils/streams.d.ts.map +1 -0
- package/dist/utils/streams.js +169 -0
- package/dist/utils/streams.js.map +1 -0
- package/dist/utils/validation.d.ts +67 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +36 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import { Sensitivity } from "./sensitivity.js";
|
|
2
|
+
|
|
3
|
+
//#region src/types/memory.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Kinds of memory record in the Graphorin model. The first six are the
|
|
7
|
+
* storage tiers the {@link MemoryStore} contract exposes as 1:1
|
|
8
|
+
* sub-namespaces; `insight` is the derived, reflection-synthesized
|
|
9
|
+
* record kind (P1-1) — it has no base-tier namespace and is persisted
|
|
10
|
+
* through the optional insight surface adapters expose. Used as the
|
|
11
|
+
* discriminator for span types and the `MemoryRecord` union.
|
|
12
|
+
*
|
|
13
|
+
* @stable
|
|
14
|
+
*/
|
|
15
|
+
type MemoryKind = 'working' | 'session' | 'episodic' | 'semantic' | 'procedural' | 'shared' | 'insight';
|
|
16
|
+
/**
|
|
17
|
+
* Where a memory came from — the trust-provenance tag carried by every
|
|
18
|
+
* fact / episode / induced procedure. `user` (the human said it) and
|
|
19
|
+
* `tool` (a tool the agent invoked returned it) are first-party;
|
|
20
|
+
* `extraction` (consolidator distilled it from a transcript),
|
|
21
|
+
* `reflection` (a synthesis pass inferred it), and `induction` (an
|
|
22
|
+
* AWM-style pass distilled a reusable workflow from a successful agent
|
|
23
|
+
* trajectory, P2-2) are *derived* and therefore land quarantined by
|
|
24
|
+
* default; `imported` is bulk-loaded from an external store. Used by
|
|
25
|
+
* P1-4 to gate action-driving recall against memory-poisoning (MINJA /
|
|
26
|
+
* MemoryGraft) — induced procedures drive *actions*, so the quarantine
|
|
27
|
+
* gate matters most for them.
|
|
28
|
+
*
|
|
29
|
+
* @stable
|
|
30
|
+
*/
|
|
31
|
+
type MemoryProvenance = 'user' | 'tool' | 'extraction' | 'reflection' | 'induction' | 'imported';
|
|
32
|
+
/**
|
|
33
|
+
* Retrieval-trust state of a memory. `active` rows are eligible for
|
|
34
|
+
* default recall; `quarantined` rows are persisted and auditable but
|
|
35
|
+
* excluded from action-driving recall until explicitly validated (P1-4).
|
|
36
|
+
* Quarantine is a *retrieval gate*, never a delete.
|
|
37
|
+
*
|
|
38
|
+
* @stable
|
|
39
|
+
*/
|
|
40
|
+
type MemoryStatus = 'active' | 'quarantined';
|
|
41
|
+
/**
|
|
42
|
+
* Snapshot of memory-tier counters surfaced to the model via the
|
|
43
|
+
* memory-aware system prompt. Implementations live in `@graphorin/memory`;
|
|
44
|
+
* the type sits here so the agent runtime can include it in its
|
|
45
|
+
* `RunContext` without a memory dependency.
|
|
46
|
+
*
|
|
47
|
+
* @stable
|
|
48
|
+
*/
|
|
49
|
+
interface MemoryMetadata {
|
|
50
|
+
/** Total number of facts in the user's semantic memory. */
|
|
51
|
+
readonly factCount: number;
|
|
52
|
+
/** Number of episodes stored for the user. */
|
|
53
|
+
readonly episodeCount: number;
|
|
54
|
+
/** Number of past messages indexed for retrieval. */
|
|
55
|
+
readonly messageCount: number;
|
|
56
|
+
/** Active rules count (after context filtering). */
|
|
57
|
+
readonly activeRuleCount: number;
|
|
58
|
+
/** Number of declared working blocks. */
|
|
59
|
+
readonly workingBlockCount: number;
|
|
60
|
+
/** Last consolidator run, ISO-8601, if any. */
|
|
61
|
+
readonly lastConsolidatedAt?: string;
|
|
62
|
+
/** Optional, free-form metadata tags surfaced to the model. */
|
|
63
|
+
readonly tags?: ReadonlyArray<string>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Marker shared by every memory record. Concrete records (`Block`,
|
|
67
|
+
* `Fact`, `Episode`, `Rule`, message rows) all extend it.
|
|
68
|
+
*
|
|
69
|
+
* @stable
|
|
70
|
+
*/
|
|
71
|
+
interface MemoryRecord {
|
|
72
|
+
readonly id: string;
|
|
73
|
+
readonly kind: MemoryKind;
|
|
74
|
+
readonly userId: string;
|
|
75
|
+
readonly agentId?: string;
|
|
76
|
+
readonly sessionId?: string;
|
|
77
|
+
readonly sensitivity: Sensitivity;
|
|
78
|
+
readonly createdAt: string;
|
|
79
|
+
readonly updatedAt?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Soft-delete tombstone. Append-only stores set this instead of removing
|
|
82
|
+
* rows, so prior history is preserved per principle 8.
|
|
83
|
+
*/
|
|
84
|
+
readonly deletedAt?: string;
|
|
85
|
+
readonly tags?: ReadonlyArray<string>;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Working-memory block — a labeled, char-bounded slot rendered into the
|
|
89
|
+
* system prompt every turn.
|
|
90
|
+
*
|
|
91
|
+
* @stable
|
|
92
|
+
*/
|
|
93
|
+
interface Block extends MemoryRecord {
|
|
94
|
+
readonly kind: 'working';
|
|
95
|
+
readonly label: string;
|
|
96
|
+
readonly description?: string;
|
|
97
|
+
readonly value: string;
|
|
98
|
+
readonly charLimit: number;
|
|
99
|
+
readonly readOnly?: boolean;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Single semantic-memory fact: an atomic statement about the user / world.
|
|
103
|
+
*
|
|
104
|
+
* @stable
|
|
105
|
+
*/
|
|
106
|
+
interface Fact extends MemoryRecord {
|
|
107
|
+
readonly kind: 'semantic';
|
|
108
|
+
readonly text: string;
|
|
109
|
+
/**
|
|
110
|
+
* Structured `(subject, predicate, object)` triple for the in-SQLite
|
|
111
|
+
* relation graph (P2-1). The consolidator's extraction prompt emits
|
|
112
|
+
* these; first-party `remember({ text })` writes usually omit them.
|
|
113
|
+
* `subject`/`object` are the graph *entities* (resolved to canonical
|
|
114
|
+
* ids in `fact_entities`); `predicate` is the relation label and is
|
|
115
|
+
* not itself an entity. Absent on rows written before the feature, and
|
|
116
|
+
* on plain free-text facts — they are a soft enrichment that powers
|
|
117
|
+
* one-hop expansion ({@link MemorySearchOptions} has no field; the
|
|
118
|
+
* memory tier's search opts in), never a recall gate.
|
|
119
|
+
*/
|
|
120
|
+
readonly subject?: string;
|
|
121
|
+
/** Relation label of the {@link Fact.subject}→{@link Fact.object} triple (P2-1). */
|
|
122
|
+
readonly predicate?: string;
|
|
123
|
+
/** Object entity of the s/p/o triple (P2-1). See {@link Fact.subject}. */
|
|
124
|
+
readonly object?: string;
|
|
125
|
+
readonly confidence?: number;
|
|
126
|
+
/**
|
|
127
|
+
* Optional salience hint in `[0, 1]` for multi-signal forgetting
|
|
128
|
+
* (X-1). A *soft* signal — higher importance slows a fact's decay and
|
|
129
|
+
* delays capacity-bounded eviction, but never gates recall and never
|
|
130
|
+
* forces retention. Absent on rows written before the feature
|
|
131
|
+
* (treated as neutral, `0.5`).
|
|
132
|
+
*/
|
|
133
|
+
readonly importance?: number;
|
|
134
|
+
/** Bi-temporal: when the fact became true, ISO-8601. */
|
|
135
|
+
readonly validFrom?: string;
|
|
136
|
+
/** Bi-temporal: when the fact stopped being true, ISO-8601. */
|
|
137
|
+
readonly validTo?: string;
|
|
138
|
+
/** ID of the fact this one supersedes, if any. */
|
|
139
|
+
readonly supersedes?: string;
|
|
140
|
+
/** ID of the fact that supersedes this one, if any. */
|
|
141
|
+
readonly supersededBy?: string;
|
|
142
|
+
/**
|
|
143
|
+
* Trust-provenance tag (P1-4). Absent on rows written before the
|
|
144
|
+
* feature; treated as first-party (`active`) when missing.
|
|
145
|
+
*/
|
|
146
|
+
readonly provenance?: MemoryProvenance;
|
|
147
|
+
/**
|
|
148
|
+
* Retrieval-trust state (P1-4). Defaults to `active`; derived /
|
|
149
|
+
* injection-flagged writes land `quarantined` and are excluded from
|
|
150
|
+
* default recall.
|
|
151
|
+
*/
|
|
152
|
+
readonly status?: MemoryStatus;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Episode — a summarized stretch of past activity.
|
|
156
|
+
*
|
|
157
|
+
* @stable
|
|
158
|
+
*/
|
|
159
|
+
interface Episode extends MemoryRecord {
|
|
160
|
+
readonly kind: 'episodic';
|
|
161
|
+
readonly summary: string;
|
|
162
|
+
/** ISO-8601 of the earliest event in the episode. */
|
|
163
|
+
readonly startedAt: string;
|
|
164
|
+
/** ISO-8601 of the latest event in the episode. */
|
|
165
|
+
readonly endedAt: string;
|
|
166
|
+
/** Optional importance score in `[0, 1]`. */
|
|
167
|
+
readonly importance?: number;
|
|
168
|
+
/** Trust-provenance tag (P1-4). See {@link MemoryProvenance}. */
|
|
169
|
+
readonly provenance?: MemoryProvenance;
|
|
170
|
+
/** Retrieval-trust state (P1-4). See {@link MemoryStatus}. */
|
|
171
|
+
readonly status?: MemoryStatus;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Procedural rule — a standing order activated when its `condition` matches.
|
|
175
|
+
*
|
|
176
|
+
* @stable
|
|
177
|
+
*/
|
|
178
|
+
interface Rule extends MemoryRecord {
|
|
179
|
+
readonly kind: 'procedural';
|
|
180
|
+
readonly text: string;
|
|
181
|
+
readonly condition?: string;
|
|
182
|
+
readonly priority: number;
|
|
183
|
+
/**
|
|
184
|
+
* Ordered, value-abstracted step sequence of an *induced* workflow
|
|
185
|
+
* (P2-2) — e.g. `['search for {product}', 'add {quantity} to cart',
|
|
186
|
+
* 'check out']`. Present only on procedures distilled from successful
|
|
187
|
+
* agent trajectories; author-defined rules omit it.
|
|
188
|
+
*/
|
|
189
|
+
readonly steps?: ReadonlyArray<string>;
|
|
190
|
+
/**
|
|
191
|
+
* Names of the variables abstracted from the trajectory's concrete
|
|
192
|
+
* values (P2-2) — the `{product}` / `{quantity}` placeholders that
|
|
193
|
+
* appear in {@link Rule.steps}. Lets a reused procedure be re-bound to
|
|
194
|
+
* fresh arguments instead of replaying one run's literals.
|
|
195
|
+
*/
|
|
196
|
+
readonly variables?: ReadonlyArray<string>;
|
|
197
|
+
/**
|
|
198
|
+
* Voyager-style verifiable success criteria stored alongside an induced
|
|
199
|
+
* procedure (P2-2) so a reuse can *self-verify* its outcome instead of
|
|
200
|
+
* trusting the procedure blindly. Author-defined rules omit it.
|
|
201
|
+
*/
|
|
202
|
+
readonly successCriteria?: ReadonlyArray<string>;
|
|
203
|
+
/**
|
|
204
|
+
* Trust-provenance tag (P1-4 / P2-2). Induced procedures are
|
|
205
|
+
* `'induction'`; author-defined rules omit it (treated first-party).
|
|
206
|
+
* See {@link MemoryProvenance}.
|
|
207
|
+
*/
|
|
208
|
+
readonly provenance?: MemoryProvenance;
|
|
209
|
+
/**
|
|
210
|
+
* Retrieval-trust state (P1-4 / P2-2). Induced procedures land
|
|
211
|
+
* `'quarantined'` and are excluded from activation (they must not drive
|
|
212
|
+
* actions) until validated; author-defined rules omit it (treated
|
|
213
|
+
* `'active'`). See {@link MemoryStatus}.
|
|
214
|
+
*/
|
|
215
|
+
readonly status?: MemoryStatus;
|
|
216
|
+
/**
|
|
217
|
+
* Demonstrated-success counter (MCON-2 part 4). Incremented by
|
|
218
|
+
* `ProceduralMemory.recordOutcome(...)` on each verified successful
|
|
219
|
+
* reuse; drives promotion-by-demonstrated-success for quarantined
|
|
220
|
+
* induced procedures once the configured threshold is reached.
|
|
221
|
+
* Absent ⇒ never counted (adapters without the column).
|
|
222
|
+
*/
|
|
223
|
+
readonly successCount?: number;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Insight — a higher-order observation the consolidator's reflection
|
|
227
|
+
* pass (P1-1) synthesizes over recent memories ("the user has cancelled
|
|
228
|
+
* three evening plans this month — they may be overcommitted"). No
|
|
229
|
+
* single turn states it; it is *inferred*, so it is always
|
|
230
|
+
* `provenance: 'reflection'` and lands `status: 'quarantined'` (P1-4),
|
|
231
|
+
* excluded from action-driving recall until validated.
|
|
232
|
+
*
|
|
233
|
+
* Every insight carries **mandatory citations** (`cites`) — the ids of
|
|
234
|
+
* the supporting memories it was synthesized from — so a reader can
|
|
235
|
+
* trace it back to evidence; this is the "trustworthy reflection"
|
|
236
|
+
* mitigation against confirmation-bias loops. Insights are managed with
|
|
237
|
+
* an ExpeL-style salience counter (new insights start at `2`, pruned at
|
|
238
|
+
* `≤ 0`) and are retrieval-ranked **below** the primary facts they cite.
|
|
239
|
+
*
|
|
240
|
+
* @stable
|
|
241
|
+
*/
|
|
242
|
+
interface Insight extends MemoryRecord {
|
|
243
|
+
readonly kind: 'insight';
|
|
244
|
+
/** The synthesized higher-order observation. */
|
|
245
|
+
readonly text: string;
|
|
246
|
+
/**
|
|
247
|
+
* IDs of the supporting memories (facts / episodes) this insight was
|
|
248
|
+
* synthesized from. Always ≥ 1 — citations are mandatory; an insight
|
|
249
|
+
* with no traceable evidence is never persisted.
|
|
250
|
+
*/
|
|
251
|
+
readonly cites: ReadonlyArray<string>;
|
|
252
|
+
/**
|
|
253
|
+
* ExpeL-style salience counter. New insights start at `2`; a
|
|
254
|
+
* maintenance pass up-/down-votes on subsequent corroboration /
|
|
255
|
+
* contradiction and prunes (soft-deletes) insights at `≤ 0`.
|
|
256
|
+
*/
|
|
257
|
+
readonly salience: number;
|
|
258
|
+
/**
|
|
259
|
+
* Trust-provenance tag (P1-4). Reflection-synthesized insights are
|
|
260
|
+
* `'reflection'`. See {@link MemoryProvenance}.
|
|
261
|
+
*/
|
|
262
|
+
readonly provenance?: MemoryProvenance;
|
|
263
|
+
/**
|
|
264
|
+
* Retrieval-trust state (P1-4). Insights land `'quarantined'`. See
|
|
265
|
+
* {@link MemoryStatus}.
|
|
266
|
+
*/
|
|
267
|
+
readonly status?: MemoryStatus;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Role a {@link GraphEntity} plays in a {@link Fact}'s s/p/o triple
|
|
271
|
+
* (P2-1) — the `subject` or the `object`. The `predicate` is a relation
|
|
272
|
+
* label, not an entity, so it has no role here.
|
|
273
|
+
*
|
|
274
|
+
* @stable
|
|
275
|
+
*/
|
|
276
|
+
type EntityRole = 'subject' | 'object';
|
|
277
|
+
/**
|
|
278
|
+
* Canonical entity in the lightweight in-SQLite relation graph (P2-1).
|
|
279
|
+
* The entity resolver (`@graphorin/memory`) deduplicates the raw
|
|
280
|
+
* `subject`/`object` strings on facts into canonical entities — merging
|
|
281
|
+
* aliases ("Anna", "Anna S.", "my sister") via lexical + embedding
|
|
282
|
+
* similarity (with optional LLM adjudication) — so multi-hop recall can
|
|
283
|
+
* traverse relationships instead of fragmenting them.
|
|
284
|
+
*
|
|
285
|
+
* Merges are **append-only and reversible**: a merged entity is never
|
|
286
|
+
* deleted — its {@link GraphEntity.mergedInto} points at the surviving
|
|
287
|
+
* canonical entity, every merge / unmerge is recorded in an audit
|
|
288
|
+
* ledger, and `mergedInto` is single-level (it always points directly at
|
|
289
|
+
* a root), so `mergedInto ?? id` is the canonical id.
|
|
290
|
+
*
|
|
291
|
+
* @stable
|
|
292
|
+
*/
|
|
293
|
+
interface GraphEntity {
|
|
294
|
+
readonly id: string;
|
|
295
|
+
readonly userId: string;
|
|
296
|
+
/** Display name as first observed (the surface form that minted it). */
|
|
297
|
+
readonly name: string;
|
|
298
|
+
/** Case/space-folded key used for lexical dedup + the canonical unique index. */
|
|
299
|
+
readonly normalizedName: string;
|
|
300
|
+
/**
|
|
301
|
+
* Canonical pointer. `undefined` ⇒ this entity is itself a root.
|
|
302
|
+
* Otherwise it is the id of the surviving entity this one was merged
|
|
303
|
+
* into; single-level by construction, so `mergedInto ?? id` resolves
|
|
304
|
+
* the canonical id without a recursive walk.
|
|
305
|
+
*/
|
|
306
|
+
readonly mergedInto?: string;
|
|
307
|
+
readonly createdAt: string;
|
|
308
|
+
readonly updatedAt?: string;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Search options shared across memory tiers.
|
|
312
|
+
*
|
|
313
|
+
* @stable
|
|
314
|
+
*/
|
|
315
|
+
interface MemorySearchOptions {
|
|
316
|
+
readonly query: string;
|
|
317
|
+
readonly topK?: number;
|
|
318
|
+
readonly tags?: ReadonlyArray<string>;
|
|
319
|
+
readonly dateRange?: {
|
|
320
|
+
readonly from?: string;
|
|
321
|
+
readonly to?: string;
|
|
322
|
+
};
|
|
323
|
+
readonly includeArchived?: boolean;
|
|
324
|
+
/**
|
|
325
|
+
* Include quarantined memories in the result set (P1-4). Defaults to
|
|
326
|
+
* `false`: action-driving recall never returns quarantined rows. Set
|
|
327
|
+
* `true` only for the validation / inspector path — never for
|
|
328
|
+
* auto-recall fed back into the model.
|
|
329
|
+
*/
|
|
330
|
+
readonly includeQuarantined?: boolean;
|
|
331
|
+
readonly signal?: AbortSignal;
|
|
332
|
+
/**
|
|
333
|
+
* Point-in-time ("as of") read. When set, only records whose
|
|
334
|
+
* validity interval contains this instant are returned. For facts:
|
|
335
|
+
* `(valid_from IS NULL OR valid_from <= asOf) AND (valid_to IS NULL OR valid_to > asOf)`;
|
|
336
|
+
* for episodes: `started_at <= asOf`. ISO-8601. Absent ⇒ current
|
|
337
|
+
* behaviour is unchanged (every live row is eligible).
|
|
338
|
+
*/
|
|
339
|
+
readonly asOf?: string;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* A single retrieval hit with similarity / relevance metadata.
|
|
343
|
+
*
|
|
344
|
+
* @stable
|
|
345
|
+
*/
|
|
346
|
+
interface MemoryHit<TRecord extends MemoryRecord = MemoryRecord> {
|
|
347
|
+
readonly record: TRecord;
|
|
348
|
+
readonly score: number;
|
|
349
|
+
/** Optional source signals contributing to `score` (BM25, vec, RRF, …). */
|
|
350
|
+
readonly signals?: Readonly<Record<string, number>>;
|
|
351
|
+
}
|
|
352
|
+
//#endregion
|
|
353
|
+
export { Block, EntityRole, Episode, Fact, GraphEntity, Insight, MemoryHit, MemoryKind, MemoryMetadata, MemoryProvenance, MemoryRecord, MemorySearchOptions, MemoryStatus, Rule };
|
|
354
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","names":[],"sources":["../../src/types/memory.ts"],"sourcesContent":[],"mappings":";;;;;;AAYA;AAwBA;AAgBA;AAUA;AAuBA;;;;AAc+B,KAvFnB,UAAA,GAuFmB,SAAA,GAAA,SAAA,GAAA,UAAA,GAAA,UAAA,GAAA,YAAA,GAAA,QAAA,GAAA,SAAA;AAS/B;AAcA;;;;;AAsDA;;;;;AAoBA;;;;AA8BwB,KA9LZ,gBAAA,GA8LY,MAAA,GAAA,MAAA,GAAA,YAAA,GAAA,YAAA,GAAA,WAAA,GAAA,UAAA;;;;AAmCxB;;;;;AAA6C,KAjNjC,YAAA,GAiNiC,QAAA,GAAA,aAAA;AAmC7C;AAkBA;AAuBA;AA6BA;;;;;AAIqB,UApTJ,cAAA,CAoTI;EAAQ;;;;;;;;;;;;;kBAtSX;;;;;;;;UASD,YAAA;;iBAEA;;;;wBAIO;;;;;;;;kBAQN;;;;;;;;UASD,KAAA,SAAc;;;;;;;;;;;;;UAcd,IAAA,SAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwCN;;;;;;oBAMJ;;;;;;;UAQH,OAAA,SAAgB;;;;;;;;;;wBAUT;;oBAEJ;;;;;;;UAQH,IAAA,SAAa;;;;;;;;;;;mBAWX;;;;;;;uBAOI;;;;;;6BAMM;;;;;;wBAML;;;;;;;oBAOJ;;;;;;;;;;;;;;;;;;;;;;;;;;;UA4BH,OAAA,SAAgB;;;;;;;;;kBASf;;;;;;;;;;;wBAWM;;;;;oBAKJ;;;;;;;;;KAUR,UAAA;;;;;;;;;;;;;;;;;UAkBK,WAAA;;;;;;;;;;;;;;;;;;;;;;UAuBA,mBAAA;;;kBAGC;;;;;;;;;;;;;oBAUE;;;;;;;;;;;;;;;UAgBH,0BAA0B,eAAe;mBACvC;;;qBAGE,SAAS"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { ToolCall } from "./tool-call.js";
|
|
2
|
+
|
|
3
|
+
//#region src/types/message.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A single multimodal content part attached to a chat-style message.
|
|
7
|
+
*
|
|
8
|
+
* The discriminated union is exhaustive: every variant carries a literal
|
|
9
|
+
* `type` field used by both the runtime and the type system to pick the
|
|
10
|
+
* branch. New variants must be added to all three of: this union, every
|
|
11
|
+
* `assertNever` switch in the codebase, and the wire-stable adapters.
|
|
12
|
+
*
|
|
13
|
+
* @stable
|
|
14
|
+
*/
|
|
15
|
+
type MessageContent = TextContent | ImageContent | AudioContent | FileContent | ReasoningContent;
|
|
16
|
+
/**
|
|
17
|
+
* Plain UTF-8 text part. The default for textual replies and tool I/O.
|
|
18
|
+
*
|
|
19
|
+
* @stable
|
|
20
|
+
*/
|
|
21
|
+
interface TextContent {
|
|
22
|
+
readonly type: 'text';
|
|
23
|
+
readonly text: string;
|
|
24
|
+
/**
|
|
25
|
+
* Optional opaque trace of the agent-runtime decisions that produced
|
|
26
|
+
* this content part. Bounded-length, no PII, no secret values.
|
|
27
|
+
* Round-tripped bytes-equal through `Session.push / list / export /
|
|
28
|
+
* import`. See `@graphorin/sessions` commentary-phase sanitization.
|
|
29
|
+
*/
|
|
30
|
+
readonly causalityChain?: ReadonlyArray<string>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Image attachment. The `image` field accepts either raw bytes or a `URL`
|
|
34
|
+
* — adapters dereference the URL when the provider only accepts inline
|
|
35
|
+
* payloads.
|
|
36
|
+
*
|
|
37
|
+
* @stable
|
|
38
|
+
*/
|
|
39
|
+
interface ImageContent {
|
|
40
|
+
readonly type: 'image';
|
|
41
|
+
readonly image: Uint8Array | URL;
|
|
42
|
+
readonly mimeType?: string;
|
|
43
|
+
/** See {@link TextContent.causalityChain}. */
|
|
44
|
+
readonly causalityChain?: ReadonlyArray<string>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Audio attachment (e.g. voice messages). Note: voice realtime / TTS / STT
|
|
48
|
+
* are out of scope for v0.1 — these messages are static blobs.
|
|
49
|
+
*
|
|
50
|
+
* @stable
|
|
51
|
+
*/
|
|
52
|
+
interface AudioContent {
|
|
53
|
+
readonly type: 'audio';
|
|
54
|
+
readonly audio: Uint8Array | URL;
|
|
55
|
+
readonly mimeType?: string;
|
|
56
|
+
/** See {@link TextContent.causalityChain}. */
|
|
57
|
+
readonly causalityChain?: ReadonlyArray<string>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Generic file attachment (PDF, CSV, …). `mimeType` is mandatory because
|
|
61
|
+
* many providers gate file ingestion on it.
|
|
62
|
+
*
|
|
63
|
+
* @stable
|
|
64
|
+
*/
|
|
65
|
+
interface FileContent {
|
|
66
|
+
readonly type: 'file';
|
|
67
|
+
readonly file: Uint8Array | URL;
|
|
68
|
+
readonly mimeType: string;
|
|
69
|
+
readonly filename?: string;
|
|
70
|
+
/** See {@link TextContent.causalityChain}. */
|
|
71
|
+
readonly causalityChain?: ReadonlyArray<string>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Reasoning content emitted by reasoning-capable models. Stored
|
|
75
|
+
* separately from `text` so that consumers can choose to hide / strip
|
|
76
|
+
* it (per the streaming-first principle and the replay-redaction
|
|
77
|
+
* policy).
|
|
78
|
+
*
|
|
79
|
+
* @stable
|
|
80
|
+
*/
|
|
81
|
+
interface ReasoningContent {
|
|
82
|
+
readonly type: 'reasoning';
|
|
83
|
+
readonly text: string;
|
|
84
|
+
/**
|
|
85
|
+
* Provider-specific opaque metadata that MUST round-trip byte-equal
|
|
86
|
+
* when the effective `reasoningRetention` is not `'strip'`. The
|
|
87
|
+
* field is provider-supplied protocol payload, not user content,
|
|
88
|
+
* and is therefore exempt from prompt-redaction scanning.
|
|
89
|
+
*
|
|
90
|
+
* Anthropic Claude tool-use thinking blocks supply
|
|
91
|
+
* `{ provider: 'anthropic', signature, data? }`; other providers
|
|
92
|
+
* are free to populate whatever opaque keys their wire contract
|
|
93
|
+
* requires. Adapters that do not need round-tripping omit this
|
|
94
|
+
* field entirely.
|
|
95
|
+
*/
|
|
96
|
+
readonly meta?: ReasoningContentMeta;
|
|
97
|
+
/** See {@link TextContent.causalityChain}. */
|
|
98
|
+
readonly causalityChain?: ReadonlyArray<string>;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Opaque metadata round-tripped on `ReasoningContent`. Adapter-defined
|
|
102
|
+
* keys; consumers must NOT introspect or modify the contents.
|
|
103
|
+
*
|
|
104
|
+
* @stable
|
|
105
|
+
*/
|
|
106
|
+
interface ReasoningContentMeta {
|
|
107
|
+
readonly provider?: string;
|
|
108
|
+
readonly signature?: string;
|
|
109
|
+
readonly data?: string;
|
|
110
|
+
readonly [extraKey: string]: unknown;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Logical role of a message in a conversation.
|
|
114
|
+
*
|
|
115
|
+
* @stable
|
|
116
|
+
*/
|
|
117
|
+
type MessageRole = 'system' | 'user' | 'assistant' | 'tool';
|
|
118
|
+
/**
|
|
119
|
+
* Chat message. The shape is provider-agnostic: adapters convert it to /
|
|
120
|
+
* from the wire format.
|
|
121
|
+
*
|
|
122
|
+
* - System messages must be plain strings (multimodal system messages are
|
|
123
|
+
* not in the v0.1 surface).
|
|
124
|
+
* - Assistant messages may carry `toolCalls` alongside their content.
|
|
125
|
+
* - Tool messages carry the originating `toolCallId` so the model can
|
|
126
|
+
* correlate the response to its previous request.
|
|
127
|
+
*
|
|
128
|
+
* @stable
|
|
129
|
+
*/
|
|
130
|
+
type Message = SystemMessage | UserMessage | AssistantMessage | ToolMessage;
|
|
131
|
+
/** @stable */
|
|
132
|
+
interface SystemMessage {
|
|
133
|
+
readonly role: 'system';
|
|
134
|
+
readonly content: string;
|
|
135
|
+
}
|
|
136
|
+
/** @stable */
|
|
137
|
+
interface UserMessage {
|
|
138
|
+
readonly role: 'user';
|
|
139
|
+
readonly content: string | readonly MessageContent[];
|
|
140
|
+
/** Multi-agent attribution: which user persona this came from, if any. */
|
|
141
|
+
readonly userId?: string;
|
|
142
|
+
}
|
|
143
|
+
/** @stable */
|
|
144
|
+
interface AssistantMessage {
|
|
145
|
+
readonly role: 'assistant';
|
|
146
|
+
readonly content: string | readonly MessageContent[];
|
|
147
|
+
readonly toolCalls?: readonly ToolCall[];
|
|
148
|
+
/**
|
|
149
|
+
* Multi-agent attribution: which agent produced this message. Required
|
|
150
|
+
* by the multi-agent crew acceptance criteria.
|
|
151
|
+
*/
|
|
152
|
+
readonly agentId?: string;
|
|
153
|
+
}
|
|
154
|
+
/** @stable */
|
|
155
|
+
interface ToolMessage {
|
|
156
|
+
readonly role: 'tool';
|
|
157
|
+
readonly toolCallId: string;
|
|
158
|
+
readonly content: string | readonly MessageContent[];
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
export { AssistantMessage, AudioContent, FileContent, ImageContent, Message, MessageContent, MessageRole, ReasoningContent, ReasoningContentMeta, SystemMessage, TextContent, ToolMessage, UserMessage };
|
|
162
|
+
//# sourceMappingURL=message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.d.ts","names":[],"sources":["../../src/types/message.ts"],"sourcesContent":[],"mappings":";;;;;;AAYA;;;;;;;AAYA;AAmBiB,KA/BL,cAAA,GACR,WA8ByB,GA7BzB,YA6ByB,GA5BzB,YA4ByB,GA3BzB,WA2ByB,GA1BzB,gBA0ByB;;;;;AAc7B;AAEkB,UAnCD,WAAA,CAmCC;EAAa,SAAA,IAAA,EAAA,MAAA;EAGH,SAAA,IAAA,EAAA,MAAA;EAAa;AASzC;;;;;EAiBiB,SAAA,cAAgB,CAAA,EAvDL,aAsEV,CAAA,MAAA,CAAA;AAWlB;AAYA;AAcA;;;;;;AAGiB,UApGA,YAAA,CAoGa;EAMb,SAAA,IAAA,EAAW,OAAA;EAQX,SAAA,KAAA,EAhHC,UAgHe,GAhHF,GAkHO;EAUrB,SAAA,QAAW,CAAA,EAAA,MAGU;;4BA5HV;;;;;;;;UASX,YAAA;;kBAEC,aAAa;;;4BAGH;;;;;;;;UASX,WAAA;;iBAEA,aAAa;;;;4BAIF;;;;;;;;;;UAWX,gBAAA;;;;;;;;;;;;;;;kBAeC;;4BAEU;;;;;;;;UASX,oBAAA;;;;;;;;;;;KAYL,WAAA;;;;;;;;;;;;;KAcA,OAAA,GAAU,gBAAgB,cAAc,mBAAmB;;UAGtD,aAAA;;;;;UAMA,WAAA;;sCAEqB;;;;;UAMrB,gBAAA;;sCAEqB;gCACN;;;;;;;;UASf,WAAA;;;sCAGqB"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { Message } from "./message.js";
|
|
2
|
+
import { ModelUsage, Usage, UsageAccumulator } from "./usage.js";
|
|
3
|
+
import { HandoffRecord } from "./handoff.js";
|
|
4
|
+
import { Tracer } from "../contracts/tracer.js";
|
|
5
|
+
import { CompletedToolCall, ToolApproval } from "./tool.js";
|
|
6
|
+
|
|
7
|
+
//#region src/types/run.d.ts
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Status of an in-flight or completed agent run. Append-only persistence
|
|
11
|
+
* stores expose this verbatim on the `runs` table.
|
|
12
|
+
*
|
|
13
|
+
* @stable
|
|
14
|
+
*/
|
|
15
|
+
type RunStatus = 'running' | 'completed' | 'failed' | 'aborted' | 'awaiting_approval';
|
|
16
|
+
/**
|
|
17
|
+
* Single step inside an agent run. The agent runtime appends one
|
|
18
|
+
* `RunStep` per provider call.
|
|
19
|
+
*
|
|
20
|
+
* @stable
|
|
21
|
+
*/
|
|
22
|
+
interface RunStep {
|
|
23
|
+
readonly stepNumber: number;
|
|
24
|
+
readonly startedAt: string;
|
|
25
|
+
readonly endedAt?: string;
|
|
26
|
+
readonly usage?: Usage;
|
|
27
|
+
readonly toolCalls: readonly CompletedToolCall[];
|
|
28
|
+
/**
|
|
29
|
+
* Stable agent id active for this step (changes after a handoff).
|
|
30
|
+
*/
|
|
31
|
+
readonly agentId: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Per-model usage breakdown carried alongside the aggregate
|
|
35
|
+
* {@link Usage} on {@link RunState}. Populated by the per-step retry
|
|
36
|
+
* loop when `Agent.fallbackModels` fires; for runs that never fall
|
|
37
|
+
* back, the map carries a single entry for the primary model with
|
|
38
|
+
* `attemptCount: 1`.
|
|
39
|
+
*
|
|
40
|
+
* The aggregate `RunState.usage` is always the sum of every entry's
|
|
41
|
+
* `Usage` portion (the field is asserted in tests).
|
|
42
|
+
*
|
|
43
|
+
* @stable
|
|
44
|
+
*/
|
|
45
|
+
interface RunStateUsageByModel {
|
|
46
|
+
readonly [modelId: string]: Usage & {
|
|
47
|
+
readonly attemptCount: number;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The full, serializable state of a run. The agent runtime persists this
|
|
52
|
+
* to the checkpoint store on every `awaiting_approval` boundary, so a
|
|
53
|
+
* separate process can resume the run.
|
|
54
|
+
*
|
|
55
|
+
* The shape is intentionally JSON-stable: every nested type is plain
|
|
56
|
+
* `JSON`-encodable (no `Map`, no `Set`, no `Date`).
|
|
57
|
+
*
|
|
58
|
+
* @stable
|
|
59
|
+
*/
|
|
60
|
+
interface RunState {
|
|
61
|
+
readonly id: string;
|
|
62
|
+
readonly agentId: string;
|
|
63
|
+
readonly currentAgentId: string;
|
|
64
|
+
readonly sessionId: string;
|
|
65
|
+
readonly userId?: string;
|
|
66
|
+
status: RunStatus;
|
|
67
|
+
readonly steps: RunStep[];
|
|
68
|
+
readonly messages: Message[];
|
|
69
|
+
readonly pendingApprovals: ToolApproval[];
|
|
70
|
+
readonly handoffs: HandoffRecord[];
|
|
71
|
+
readonly usage: Usage;
|
|
72
|
+
/**
|
|
73
|
+
* Per-model usage breakdown. Populated by the per-step retry loop
|
|
74
|
+
* when `Agent.fallbackModels` fires (RB-48 / suggested DEC-164 /
|
|
75
|
+
* suggested ADR-052). Backward-compat: rehydrating a serialized
|
|
76
|
+
* state that omits the field synthesizes a single-entry map for
|
|
77
|
+
* the primary model.
|
|
78
|
+
*/
|
|
79
|
+
usageByModel?: RunStateUsageByModel;
|
|
80
|
+
/**
|
|
81
|
+
* AG-19: coarse data-flow taint summary, carried across suspend/resume so a
|
|
82
|
+
* resumed run does not start with an empty ledger that silently un-gates
|
|
83
|
+
* sinks exposed before the suspend. Structurally matches
|
|
84
|
+
* `@graphorin/security`'s `TaintLedgerSnapshot` (core takes no security
|
|
85
|
+
* dependency); only the load-bearing flags are persisted — never the tracked
|
|
86
|
+
* untrusted text spans.
|
|
87
|
+
*/
|
|
88
|
+
taintSummary?: RunTaintSummary;
|
|
89
|
+
/**
|
|
90
|
+
* AG-19: names of deferred tools promoted by `tool_search` this run, carried
|
|
91
|
+
* across suspend/resume so discovered tools remain in the per-step catalogue.
|
|
92
|
+
*/
|
|
93
|
+
promotedTools?: ReadonlyArray<string>;
|
|
94
|
+
readonly startedAt: string;
|
|
95
|
+
finishedAt?: string;
|
|
96
|
+
error?: RunError;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Coarse, serializable data-flow taint summary persisted in {@link RunState}
|
|
100
|
+
* across suspend/resume (AG-19). Structurally identical to
|
|
101
|
+
* `@graphorin/security`'s `TaintLedgerSnapshot`; carries no untrusted text.
|
|
102
|
+
*
|
|
103
|
+
* @stable
|
|
104
|
+
*/
|
|
105
|
+
interface RunTaintSummary {
|
|
106
|
+
readonly untrustedSeen: boolean;
|
|
107
|
+
readonly sensitiveSeen: boolean;
|
|
108
|
+
readonly untrustedSourceKinds: ReadonlyArray<string>;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Snapshot helper used by `@graphorin/observability` aggregators to
|
|
112
|
+
* convert the on-disk `usageByModel` shape into the canonical
|
|
113
|
+
* {@link ModelUsage} array. Pure utility — kept in core so consumers
|
|
114
|
+
* do not have to take an observability dependency just to flatten a
|
|
115
|
+
* run-state breakdown.
|
|
116
|
+
*
|
|
117
|
+
* @stable
|
|
118
|
+
*/
|
|
119
|
+
declare function flattenUsageByModel(byModel: RunStateUsageByModel | undefined): ReadonlyArray<ModelUsage>;
|
|
120
|
+
/**
|
|
121
|
+
* Failure carried by `RunState.error`. The shape mirrors the wire format
|
|
122
|
+
* used by `agent.error` events.
|
|
123
|
+
*
|
|
124
|
+
* @stable
|
|
125
|
+
*/
|
|
126
|
+
interface RunError {
|
|
127
|
+
readonly message: string;
|
|
128
|
+
readonly code: string;
|
|
129
|
+
readonly details?: unknown;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Per-run dependency / context bag handed to every tool, hook and
|
|
133
|
+
* provider middleware in scope. Generic over the user-defined deps shape.
|
|
134
|
+
*
|
|
135
|
+
* `tracer`, `signal`, `usage` and `state` are always present; everything
|
|
136
|
+
* else is optional.
|
|
137
|
+
*
|
|
138
|
+
* @stable
|
|
139
|
+
*/
|
|
140
|
+
interface RunContext<TDeps = unknown> {
|
|
141
|
+
readonly runId: string;
|
|
142
|
+
readonly sessionId: string;
|
|
143
|
+
readonly userId?: string;
|
|
144
|
+
readonly agentId: string;
|
|
145
|
+
readonly deps: TDeps;
|
|
146
|
+
readonly tracer: Tracer;
|
|
147
|
+
readonly signal: AbortSignal;
|
|
148
|
+
readonly usage: UsageAccumulator;
|
|
149
|
+
readonly stepNumber: number;
|
|
150
|
+
readonly messages: ReadonlyArray<Message>;
|
|
151
|
+
readonly state: RunState;
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
154
|
+
export { RunContext, RunError, RunState, RunStateUsageByModel, RunStatus, RunStep, RunTaintSummary, flattenUsageByModel };
|
|
155
|
+
//# sourceMappingURL=run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","names":[],"sources":["../../src/types/run.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAYA;AAQA;AAwBA;AAcA;AAMU,KApDE,SAAA,GAoDF,SAAA,GAAA,WAAA,GAAA,QAAA,GAAA,SAAA,GAAA,mBAAA;;;;;;;AAsBO,UAlEA,OAAA,CAkEA;EAKC,SAAA,UAAA,EAAA,MAAA;EAGR,SAAA,SAAA,EAAA,MAAA;EAAQ,SAAA,OAAA,CAAA,EAAA,MAAA;EAUD,SAAA,KAAA,CAAA,EAhFE,KAgFa;EAehB,SAAA,SAAA,EAAA,SA9Fe,iBA8FI,EAAA;EACxB;;;EACK,SAAA,OAAA,EAAA,MAAA;AAwBhB;AAeA;;;;;;;;;;;;UApHiB,oBAAA;8BACa;;;;;;;;;;;;;;UAab,QAAA;;;;;;UAMP;kBACQ;qBACG;6BACQ;qBACR;kBACH;;;;;;;;iBAQD;;;;;;;;;iBASA;;;;;kBAKC;;;UAGR;;;;;;;;;UAUO,eAAA;;;iCAGgB;;;;;;;;;;;iBAYjB,mBAAA,UACL,mCACR,cAAc;;;;;;;UAwBA,QAAA;;;;;;;;;;;;;;UAeA;;;;;iBAKA;mBACE;mBACA;kBACD;;qBAEG,cAAc;kBACjB"}
|