@tangle-network/agent-runtime 0.11.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,394 +1,9 @@
1
- import { ControlEvalResult, KnowledgeRequirement, ControlBudget, KnowledgeReadinessReport, ControlStep, ControlDecision, UserQuestion, DataAcquisitionPlan, ControlRunResult, RunRecord, TraceStore, AgentEvalError, TraceEvent } from '@tangle-network/agent-eval';
1
+ import { AgentEvalError, KnowledgeReadinessReport, ControlEvalResult, KnowledgeRequirement, TraceEvent } from '@tangle-network/agent-eval';
2
2
  export { AgentEvalError, AgentEvalErrorCode, CaptureIntegrityError, ConfigError, ControlBudget, ControlDecision, ControlEvalResult, ControlRunResult, ControlStep, DataAcquisitionPlan, JudgeError, KnowledgeReadinessReport, KnowledgeRequirement, NotFoundError, ReplayError, RunRecord, UserQuestion, ValidationError, VerificationError } from '@tangle-network/agent-eval';
3
+ import { A as AgentBackendInput, a as AgentExecutionBackend, b as AgentBackendContext, R as RuntimeStreamEvent, K as KnowledgeReadinessDecision, c as RunAgentTaskOptions, d as AgentTaskRunResult, e as RunAgentTaskStreamOptions, f as AgentTaskRunSummary, g as AgentTaskSpec, h as AgentRuntimeEvent, i as AgentTaskStatus, j as RuntimeSessionStore, k as RuntimeSession } from './types-afLuHk1G.js';
4
+ export { l as AgentAdapter, m as AgentKnowledgeProvider, n as AgentRuntimeEventSink, o as AgentTaskContext } from './types-afLuHk1G.js';
3
5
  import { AgentProfilePrompt, AgentProfileResources, AgentSubagentProfile, AgentProfile, SandboxInstance } from '@tangle-network/sandbox';
4
6
 
5
- /**
6
- * @stable
7
- *
8
- * Core task, session, adapter, and stream-event types for the runtime.
9
- *
10
- * This module owns the public shape of every cross-cutting record (`TaskSpec`,
11
- * `RuntimeSession`, `RuntimeStreamEvent`). Everything else in the runtime
12
- * imports from here so type-level changes ripple in one place.
13
- */
14
-
15
- /** @stable */
16
- interface AgentTaskSpec {
17
- id: string;
18
- intent: string;
19
- /** Domain is metadata, not an architectural boundary: tax, legal, gtm, creative, blueprint, redteam, etc. */
20
- domain?: string;
21
- inputs?: Record<string, unknown>;
22
- requiredKnowledge?: KnowledgeRequirement[];
23
- budget?: Partial<ControlBudget>;
24
- metadata?: Record<string, unknown>;
25
- }
26
- /** @stable */
27
- interface AgentKnowledgeProvider {
28
- buildReadiness?(task: AgentTaskSpec): Promise<KnowledgeReadinessReport> | KnowledgeReadinessReport;
29
- answerQuestions?(questions: UserQuestion[], task: AgentTaskSpec): Promise<Record<string, string>> | Record<string, string>;
30
- executeAcquisitionPlans?(plans: DataAcquisitionPlan[], task: AgentTaskSpec): Promise<string[]> | string[];
31
- refreshReadiness?(input: {
32
- task: AgentTaskSpec;
33
- previous: KnowledgeReadinessReport;
34
- userAnswers: Record<string, string>;
35
- acquiredEvidenceIds: string[];
36
- }): Promise<KnowledgeReadinessReport> | KnowledgeReadinessReport;
37
- }
38
- /** @stable */
39
- interface AgentTaskContext<TState, TAction, TActionResult, TEval extends ControlEvalResult = ControlEvalResult> {
40
- task: AgentTaskSpec;
41
- knowledge: KnowledgeReadinessReport;
42
- state: TState;
43
- evals: TEval[];
44
- history: ControlStep<TState, TAction, TActionResult, TEval>[];
45
- budget: ControlBudget;
46
- stepIndex: number;
47
- wallMs: number;
48
- spentCostUsd: number;
49
- remainingCostUsd?: number;
50
- abortSignal: AbortSignal;
51
- }
52
- /** @stable */
53
- interface AgentAdapter<TState, TAction, TActionResult, TEval extends ControlEvalResult = ControlEvalResult> {
54
- observe(ctx: {
55
- task: AgentTaskSpec;
56
- knowledge: KnowledgeReadinessReport;
57
- history: ControlStep<TState, TAction, TActionResult, TEval>[];
58
- abortSignal: AbortSignal;
59
- }): Promise<TState> | TState;
60
- validate(ctx: {
61
- task: AgentTaskSpec;
62
- knowledge: KnowledgeReadinessReport;
63
- state: TState;
64
- history: ControlStep<TState, TAction, TActionResult, TEval>[];
65
- abortSignal: AbortSignal;
66
- }): Promise<TEval[]> | TEval[];
67
- decide(ctx: AgentTaskContext<TState, TAction, TActionResult, TEval>): Promise<ControlDecision<TAction>> | ControlDecision<TAction>;
68
- act(action: TAction, ctx: AgentTaskContext<TState, TAction, TActionResult, TEval>): Promise<TActionResult> | TActionResult;
69
- shouldStop?(ctx: AgentTaskContext<TState, TAction, TActionResult, TEval>): Promise<{
70
- stop: boolean;
71
- pass: boolean;
72
- reason: string;
73
- score?: number;
74
- }> | {
75
- stop: boolean;
76
- pass: boolean;
77
- reason: string;
78
- score?: number;
79
- };
80
- onKnowledgeBlocked?(ctx: {
81
- task: AgentTaskSpec;
82
- knowledge: KnowledgeReadinessReport;
83
- questions: UserQuestion[];
84
- acquisitionPlans: DataAcquisitionPlan[];
85
- }): Promise<ControlDecision<TAction>> | ControlDecision<TAction>;
86
- getActionCostUsd?(ctx: {
87
- action: TAction;
88
- result: TActionResult;
89
- task: AgentTaskSpec;
90
- state: TState;
91
- evals: TEval[];
92
- history: ControlStep<TState, TAction, TActionResult, TEval>[];
93
- }): number | undefined;
94
- projectRunRecords?(result: ControlRunResult<TState, TAction, TActionResult, TEval>, task: AgentTaskSpec): RunRecord[];
95
- }
96
- /** @stable */
97
- type AgentTaskStatus = 'completed' | 'blocked' | 'failed' | 'aborted';
98
- /** @stable */
99
- type AgentRuntimeEvent<TState = unknown, TAction = unknown, TActionResult = unknown, TEval extends ControlEvalResult = ControlEvalResult> = {
100
- type: 'task_start';
101
- task: AgentTaskSpec;
102
- } | {
103
- type: 'readiness_start';
104
- task: AgentTaskSpec;
105
- } | {
106
- type: 'readiness_end';
107
- task: AgentTaskSpec;
108
- knowledge: KnowledgeReadinessReport;
109
- } | {
110
- type: 'questions_start';
111
- task: AgentTaskSpec;
112
- questions: UserQuestion[];
113
- } | {
114
- type: 'questions_end';
115
- task: AgentTaskSpec;
116
- questions: UserQuestion[];
117
- userAnswers: Record<string, string>;
118
- } | {
119
- type: 'acquisition_start';
120
- task: AgentTaskSpec;
121
- acquisitionPlans: DataAcquisitionPlan[];
122
- } | {
123
- type: 'acquisition_end';
124
- task: AgentTaskSpec;
125
- acquisitionPlans: DataAcquisitionPlan[];
126
- acquiredEvidenceIds: string[];
127
- } | {
128
- type: 'control_start';
129
- task: AgentTaskSpec;
130
- knowledge: KnowledgeReadinessReport;
131
- } | {
132
- type: 'control_step';
133
- task: AgentTaskSpec;
134
- step: ControlStep<TState, TAction, TActionResult, TEval>;
135
- } | {
136
- type: 'control_end';
137
- task: AgentTaskSpec;
138
- control: ControlRunResult<TState, TAction, TActionResult, TEval>;
139
- } | {
140
- type: 'task_end';
141
- task: AgentTaskSpec;
142
- status: AgentTaskStatus;
143
- reason: string;
144
- };
145
- /** @stable */
146
- type AgentRuntimeEventSink<TState = unknown, TAction = unknown, TActionResult = unknown, TEval extends ControlEvalResult = ControlEvalResult> = (event: AgentRuntimeEvent<TState, TAction, TActionResult, TEval>) => Promise<void> | void;
147
- /** @stable */
148
- type RuntimeStreamEvent = {
149
- type: 'task_start';
150
- task: AgentTaskSpec;
151
- timestamp: string;
152
- } | {
153
- type: 'readiness_start';
154
- task: AgentTaskSpec;
155
- timestamp: string;
156
- } | {
157
- type: 'readiness_end';
158
- task: AgentTaskSpec;
159
- knowledge: KnowledgeReadinessReport;
160
- decision: KnowledgeReadinessDecision;
161
- timestamp: string;
162
- } | {
163
- type: 'questions_start';
164
- task: AgentTaskSpec;
165
- questions: UserQuestion[];
166
- timestamp: string;
167
- } | {
168
- type: 'questions_end';
169
- task: AgentTaskSpec;
170
- questions: UserQuestion[];
171
- userAnswers: Record<string, string>;
172
- timestamp: string;
173
- } | {
174
- type: 'acquisition_start';
175
- task: AgentTaskSpec;
176
- acquisitionPlans: DataAcquisitionPlan[];
177
- timestamp: string;
178
- } | {
179
- type: 'acquisition_end';
180
- task: AgentTaskSpec;
181
- acquisitionPlans: DataAcquisitionPlan[];
182
- acquiredEvidenceIds: string[];
183
- timestamp: string;
184
- } | {
185
- type: 'session_created';
186
- task: AgentTaskSpec;
187
- session: RuntimeSession;
188
- timestamp: string;
189
- } | {
190
- type: 'session_resumed';
191
- task: AgentTaskSpec;
192
- session: RuntimeSession;
193
- timestamp: string;
194
- } | {
195
- type: 'backend_start';
196
- task: AgentTaskSpec;
197
- session: RuntimeSession;
198
- backend: string;
199
- timestamp: string;
200
- } | {
201
- type: 'text_delta';
202
- task?: AgentTaskSpec;
203
- session?: RuntimeSession;
204
- text: string;
205
- timestamp?: string;
206
- } | {
207
- type: 'reasoning_delta';
208
- task?: AgentTaskSpec;
209
- session?: RuntimeSession;
210
- text: string;
211
- timestamp?: string;
212
- } | {
213
- type: 'tool_call';
214
- task?: AgentTaskSpec;
215
- session?: RuntimeSession;
216
- toolName: string;
217
- toolCallId?: string;
218
- args?: unknown;
219
- timestamp?: string;
220
- } | {
221
- type: 'tool_result';
222
- task?: AgentTaskSpec;
223
- session?: RuntimeSession;
224
- toolName: string;
225
- toolCallId?: string;
226
- result?: unknown;
227
- timestamp?: string;
228
- } | {
229
- type: 'llm_call';
230
- task?: AgentTaskSpec;
231
- session?: RuntimeSession;
232
- model: string;
233
- tokensIn?: number;
234
- tokensOut?: number;
235
- costUsd?: number;
236
- latencyMs?: number;
237
- finishReason?: string;
238
- timestamp?: string;
239
- } | {
240
- type: 'artifact';
241
- task?: AgentTaskSpec;
242
- session?: RuntimeSession;
243
- artifactId: string;
244
- name?: string;
245
- mimeType?: string;
246
- uri?: string;
247
- metadata?: Record<string, unknown>;
248
- timestamp?: string;
249
- } | {
250
- type: 'backend_error';
251
- task: AgentTaskSpec;
252
- session?: RuntimeSession;
253
- backend: string;
254
- message: string;
255
- recoverable: boolean;
256
- timestamp: string;
257
- } | {
258
- type: 'backend_end';
259
- task: AgentTaskSpec;
260
- session: RuntimeSession;
261
- backend: string;
262
- timestamp: string;
263
- } | {
264
- type: 'task_end';
265
- task: AgentTaskSpec;
266
- status: AgentTaskStatus;
267
- reason: string;
268
- timestamp: string;
269
- } | {
270
- type: 'final';
271
- task: AgentTaskSpec;
272
- session?: RuntimeSession;
273
- status: AgentTaskStatus;
274
- reason: string;
275
- text?: string;
276
- metadata?: Record<string, unknown>;
277
- timestamp: string;
278
- };
279
- /** @stable */
280
- interface RuntimeSession {
281
- id: string;
282
- backend: string;
283
- status: 'active' | 'completed' | 'failed' | 'aborted';
284
- resumeToken?: string;
285
- createdAt: string;
286
- updatedAt: string;
287
- metadata?: Record<string, unknown>;
288
- }
289
- /** @stable */
290
- interface RuntimeSessionStore {
291
- get(sessionId: string): Promise<RuntimeSession | undefined> | RuntimeSession | undefined;
292
- put(session: RuntimeSession): Promise<void> | void;
293
- appendEvent?(sessionId: string, event: RuntimeStreamEvent): Promise<void> | void;
294
- listEvents?(sessionId: string): Promise<RuntimeStreamEvent[]> | RuntimeStreamEvent[];
295
- }
296
- /** @stable */
297
- interface AgentBackendInput {
298
- task: AgentTaskSpec;
299
- message?: string;
300
- messages?: Array<{
301
- role: string;
302
- content: string;
303
- }>;
304
- inputs?: Record<string, unknown>;
305
- }
306
- /** @stable */
307
- interface AgentBackendContext {
308
- task: AgentTaskSpec;
309
- knowledge: KnowledgeReadinessReport;
310
- session: RuntimeSession;
311
- signal?: AbortSignal;
312
- }
313
- /** @stable */
314
- interface AgentExecutionBackend<TInput extends AgentBackendInput = AgentBackendInput> {
315
- kind: string;
316
- start?(input: TInput, context: Omit<AgentBackendContext, 'session'> & {
317
- requestedSessionId?: string;
318
- }): Promise<RuntimeSession> | RuntimeSession;
319
- resume?(session: RuntimeSession, input: TInput, context: Omit<AgentBackendContext, 'session'>): Promise<RuntimeSession> | RuntimeSession;
320
- stream(input: TInput, context: AgentBackendContext): AsyncIterable<RuntimeStreamEvent>;
321
- stop?(session: RuntimeSession, reason: string): Promise<void> | void;
322
- }
323
- /** @stable */
324
- interface RunAgentTaskStreamOptions<TInput extends AgentBackendInput = AgentBackendInput> {
325
- task: AgentTaskSpec;
326
- backend: AgentExecutionBackend<TInput>;
327
- input?: Omit<TInput, 'task'>;
328
- knowledge?: AgentKnowledgeProvider;
329
- sessionStore?: RuntimeSessionStore;
330
- sessionId?: string;
331
- resume?: boolean;
332
- signal?: AbortSignal;
333
- minimumReadinessScore?: number;
334
- }
335
- /** @stable */
336
- interface RunAgentTaskOptions<TState, TAction, TActionResult, TEval extends ControlEvalResult = ControlEvalResult> {
337
- task: AgentTaskSpec;
338
- adapter: AgentAdapter<TState, TAction, TActionResult, TEval>;
339
- knowledge?: AgentKnowledgeProvider;
340
- onEvent?: AgentRuntimeEventSink<TState, TAction, TActionResult, TEval>;
341
- store?: TraceStore;
342
- signal?: AbortSignal;
343
- scenarioId?: string;
344
- projectId?: string;
345
- variantId?: string;
346
- minimumReadinessScore?: number;
347
- }
348
- /** @stable */
349
- interface AgentTaskRunResult<TState, TAction, TActionResult, TEval extends ControlEvalResult = ControlEvalResult> {
350
- task: AgentTaskSpec;
351
- status: AgentTaskStatus;
352
- knowledge: KnowledgeReadinessReport;
353
- questions: UserQuestion[];
354
- acquisitionPlans: DataAcquisitionPlan[];
355
- userAnswers: Record<string, string>;
356
- acquiredEvidenceIds: string[];
357
- control: ControlRunResult<TState, TAction, TActionResult, TEval>;
358
- runRecords: RunRecord[];
359
- }
360
- /** @stable */
361
- interface AgentTaskRunSummary {
362
- taskId: string;
363
- domain?: string;
364
- status: AgentTaskStatus;
365
- reason: string;
366
- readinessStatus: KnowledgeReadinessDecision['status'];
367
- readinessScore: number;
368
- recommendedAction: KnowledgeReadinessReport['recommendedAction'];
369
- blockingGapIds: string[];
370
- nonBlockingGapIds: string[];
371
- questionCount: number;
372
- acquisitionPlanCount: number;
373
- acquiredEvidenceCount: number;
374
- controlStepCount: number;
375
- pass: boolean;
376
- failureClass?: string;
377
- wallMs: number;
378
- costUsd: number;
379
- }
380
- /** @stable */
381
- interface KnowledgeReadinessDecision {
382
- passed: boolean;
383
- status: 'ready' | 'blocked' | 'caveat';
384
- reason: string;
385
- readinessScore: number;
386
- recommendedAction: KnowledgeReadinessReport['recommendedAction'];
387
- severity: KnowledgeReadinessReport['severity'];
388
- blockingGapIds: string[];
389
- nonBlockingGapIds: string[];
390
- }
391
-
392
7
  /**
393
8
  * @stable
394
9
  *
@@ -1090,4 +705,4 @@ declare function createTraceBridge(options: TraceBridgeOptions): TraceBridge;
1090
705
  */
1091
706
  declare function toAgentEvalTrace(event: RuntimeStreamEvent, options: TraceBridgeOptions): TraceEvent | undefined;
1092
707
 
1093
- export { type AgentAdapter, type AgentBackendContext, type AgentBackendInput, type AgentExecutionBackend, type AgentKnowledgeProvider, type AgentRuntimeEvent, type AgentRuntimeEventSink, type AgentTaskContext, type AgentTaskRunResult, type AgentTaskRunSummary, type AgentTaskSpec, type AgentTaskStatus, BackendTransportError, ChatTurnError, type ChatTurnMessage, type ChatTurnOverlay, type ChatTurnSandbox, type ClassifyIntentOptions, type ClassifyIntentResult, type ConformanceIssue, type ConformanceOptions, type ConformanceResult, InMemoryRuntimeSessionStore, type KnowledgeReadinessDecision, type RunAgentTaskOptions, type RunAgentTaskStreamOptions, type RunChatTurnOptions, type RuntimeEventCollector, type RuntimeRunCompleteInput, type RuntimeRunCost, type RuntimeRunHandle, type RuntimeRunOptions, type RuntimeRunPersistenceAdapter, type RuntimeRunRow, RuntimeRunStateError, type RuntimeRunStatus, type RuntimeSession, type RuntimeSessionStore, type RuntimeStreamEvent, type RuntimeStreamEventCollector, type RuntimeStreamEventSink, type RuntimeStreamEventSummary, type RuntimeTelemetryOptions, type SanitizedKnowledgeReadinessReport, type SanitizedKnowledgeRequirement, type ServerSentEventOptions, SessionMismatchError, type SubagentMatcher, type TraceBridge, type TraceBridgeOptions, assertProfileConformance, classifyIntent, composeTurnProfile, createIterableBackend, createOpenAICompatibleBackend, createRuntimeEventCollector, createRuntimeStreamEventCollector, createSandboxPromptBackend, createTraceBridge, decideKnowledgeReadiness, encodeServerSentEvent, readinessServerSentEvent, runAgentTask, runAgentTaskStream, runChatTurn, runtimeStreamServerSentEvent, sandboxAsChatTurnTarget, sanitizeAgentRuntimeEvent, sanitizeKnowledgeReadinessReport, sanitizeRuntimeStreamEvent, startRuntimeRun, summarizeAgentTaskRun, toAgentEvalTrace };
708
+ export { AgentBackendContext, AgentBackendInput, AgentExecutionBackend, AgentRuntimeEvent, AgentTaskRunResult, AgentTaskRunSummary, AgentTaskSpec, AgentTaskStatus, BackendTransportError, ChatTurnError, type ChatTurnMessage, type ChatTurnOverlay, type ChatTurnSandbox, type ClassifyIntentOptions, type ClassifyIntentResult, type ConformanceIssue, type ConformanceOptions, type ConformanceResult, InMemoryRuntimeSessionStore, KnowledgeReadinessDecision, RunAgentTaskOptions, RunAgentTaskStreamOptions, type RunChatTurnOptions, type RuntimeEventCollector, type RuntimeRunCompleteInput, type RuntimeRunCost, type RuntimeRunHandle, type RuntimeRunOptions, type RuntimeRunPersistenceAdapter, type RuntimeRunRow, RuntimeRunStateError, type RuntimeRunStatus, RuntimeSession, RuntimeSessionStore, RuntimeStreamEvent, type RuntimeStreamEventCollector, type RuntimeStreamEventSink, type RuntimeStreamEventSummary, type RuntimeTelemetryOptions, type SanitizedKnowledgeReadinessReport, type SanitizedKnowledgeRequirement, type ServerSentEventOptions, SessionMismatchError, type SubagentMatcher, type TraceBridge, type TraceBridgeOptions, assertProfileConformance, classifyIntent, composeTurnProfile, createIterableBackend, createOpenAICompatibleBackend, createRuntimeEventCollector, createRuntimeStreamEventCollector, createSandboxPromptBackend, createTraceBridge, decideKnowledgeReadiness, encodeServerSentEvent, readinessServerSentEvent, runAgentTask, runAgentTaskStream, runChatTurn, runtimeStreamServerSentEvent, sandboxAsChatTurnTarget, sanitizeAgentRuntimeEvent, sanitizeKnowledgeReadinessReport, sanitizeRuntimeStreamEvent, startRuntimeRun, summarizeAgentTaskRun, toAgentEvalTrace };