@bluecopa/harness 0.1.0-snapshot.99 → 2.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.
@@ -1,745 +0,0 @@
1
- import * as zod from 'zod';
2
- import { Tool } from 'ai';
3
-
4
- interface ToolCallInfo {
5
- toolCallId: string;
6
- toolName: string;
7
- args: Record<string, unknown>;
8
- /** Provider-specific metadata preserved across round-trips (e.g., Gemini thought signatures). */
9
- providerMetadata?: Record<string, unknown>;
10
- }
11
- interface ToolResultInfo {
12
- toolCallId: string;
13
- toolName: string;
14
- result: string;
15
- isError?: boolean;
16
- }
17
- type ContentPart = {
18
- type: 'text';
19
- text: string;
20
- } | {
21
- type: 'image';
22
- image: Buffer | Uint8Array;
23
- mimeType: string;
24
- };
25
- interface AgentMessage {
26
- role: 'system' | 'user' | 'assistant' | 'tool';
27
- content: string | ContentPart[];
28
- toolCalls?: ToolCallInfo[];
29
- toolResults?: ToolResultInfo[];
30
- /** Provider-specific metadata preserved across round-trips (e.g., Gemini thought signatures). */
31
- providerMetadata?: Record<string, unknown>;
32
- }
33
- interface ToolCallAction {
34
- type: 'tool';
35
- name: string;
36
- args: Record<string, unknown>;
37
- toolCallId?: string;
38
- }
39
- interface FinalAction {
40
- type: 'final';
41
- content: string;
42
- }
43
- interface ToolBatchAction {
44
- type: 'tool_batch';
45
- calls: ToolCallAction[];
46
- }
47
- type AgentAction = ToolCallAction | FinalAction | ToolBatchAction;
48
- /** Token usage breakdown for a single LLM step. */
49
- interface StepUsage {
50
- inputTokens?: number;
51
- outputTokens?: number;
52
- cacheReadTokens?: number;
53
- cacheWriteTokens?: number;
54
- reasoningTokens?: number;
55
- }
56
- type AgentStreamEvent = {
57
- type: 'text_delta';
58
- text: string;
59
- } | {
60
- type: 'tool_start';
61
- name: string;
62
- args: Record<string, unknown>;
63
- toolCallId?: string;
64
- } | {
65
- type: 'tool_end';
66
- name: string;
67
- result: {
68
- success: boolean;
69
- output: string;
70
- error?: string;
71
- [key: string]: unknown;
72
- };
73
- } | {
74
- type: 'step_start';
75
- step: number;
76
- } | {
77
- type: 'step_end';
78
- step: number;
79
- usage?: StepUsage;
80
- } | {
81
- type: 'done';
82
- output: string;
83
- steps: number;
84
- };
85
- interface AgentLoop {
86
- nextAction(messages: AgentMessage[]): Promise<AgentAction>;
87
- streamAction?(messages: AgentMessage[]): AsyncIterable<AgentStreamEvent>;
88
- }
89
- /** Context passed to `prepareStep` before each LLM call. */
90
- interface PrepareStepContext {
91
- stepNumber: number;
92
- toolCallHistory: string[];
93
- }
94
- /** Overrides returned by `prepareStep`. All fields optional — omit to keep defaults. */
95
- interface PrepareStepResult {
96
- model?: string;
97
- activeTools?: string[];
98
- }
99
-
100
- type PermissionMode = 'allow_all' | 'deny_all' | 'ask';
101
- interface PermissionRequest {
102
- toolName: string;
103
- input?: Record<string, unknown>;
104
- }
105
- type PermissionResolver = (request: PermissionRequest) => Promise<boolean>;
106
- declare class PermissionManager {
107
- private readonly mode;
108
- private readonly resolver?;
109
- constructor(mode: PermissionMode, resolver?: PermissionResolver | undefined);
110
- check(request: PermissionRequest): Promise<{
111
- allow: boolean;
112
- reason?: string;
113
- }>;
114
- }
115
-
116
- interface ToolResult {
117
- success: boolean;
118
- output: string;
119
- /** Compact summary for LLM context. When present, sent to the model instead of `output`. */
120
- modelOutput?: string | undefined;
121
- error?: string | undefined;
122
- metadata?: Record<string, unknown> | undefined;
123
- }
124
- interface BashOptions {
125
- timeout?: number | undefined;
126
- cwd?: string | undefined;
127
- }
128
- interface ReadOptions {
129
- lineRange?: [number, number] | undefined;
130
- maxLines?: number | undefined;
131
- }
132
- interface GlobOptions {
133
- ignore?: string[] | undefined;
134
- maxResults?: number | undefined;
135
- }
136
- interface GrepOptions {
137
- caseInsensitive?: boolean | undefined;
138
- wholeWord?: boolean | undefined;
139
- maxResults?: number | undefined;
140
- include?: string | undefined;
141
- }
142
- interface WebFetchOptions {
143
- url: string;
144
- selector?: string | undefined;
145
- maxContentLength?: number | undefined;
146
- headers?: Record<string, string> | undefined;
147
- }
148
- type BatchOp = {
149
- op: "exec";
150
- command: string;
151
- cwd?: string;
152
- timeoutMs?: number;
153
- } | {
154
- op: "write_file";
155
- path: string;
156
- content: string;
157
- encoding?: "utf8" | "base64";
158
- } | {
159
- op: "read_file";
160
- path: string;
161
- encoding?: "utf8" | "base64";
162
- };
163
- type BatchResult = {
164
- success: true;
165
- op: "exec";
166
- exitCode: number;
167
- stdout: string;
168
- stderr: string;
169
- } | {
170
- success: true;
171
- op: "write_file";
172
- } | {
173
- success: true;
174
- op: "read_file";
175
- content: string;
176
- } | {
177
- success: false;
178
- op: string;
179
- error: string;
180
- };
181
- interface ToolProviderCapabilities {
182
- bash: boolean;
183
- fileSystem: boolean;
184
- webFetch: boolean;
185
- webSearch: boolean;
186
- codeExecution: boolean;
187
- sandboxed: boolean;
188
- }
189
- interface ToolProvider {
190
- bash(command: string, options?: BashOptions): Promise<ToolResult>;
191
- readFile(path: string, options?: ReadOptions): Promise<ToolResult>;
192
- writeFile(path: string, content: string): Promise<ToolResult>;
193
- editFile(path: string, oldText: string, newText: string): Promise<ToolResult>;
194
- glob(pattern: string, options?: GlobOptions): Promise<ToolResult>;
195
- grep(pattern: string, path?: string, options?: GrepOptions): Promise<ToolResult>;
196
- webFetch?: ((options: WebFetchOptions) => Promise<ToolResult>) | undefined;
197
- webSearch?: ((query: string) => Promise<ToolResult>) | undefined;
198
- batch?: ((ops: BatchOp[]) => Promise<BatchResult[]>) | undefined;
199
- initialize?: (() => Promise<void>) | undefined;
200
- destroy?: (() => Promise<void>) | undefined;
201
- capabilities(): ToolProviderCapabilities;
202
- }
203
-
204
- type HookEventName = 'PreToolUse' | 'PostToolUse' | 'SessionStart' | 'SessionEnd' | 'CompactionStart' | 'CompactionEnd' | 'RunComplete' | 'BeforeWorker' | 'AfterWorker' | 'AcceptEpisode' | 'StopCondition' | 'BeforeSynthesis';
205
- interface HookContext {
206
- event: HookEventName;
207
- toolName?: string;
208
- input?: Record<string, unknown>;
209
- output?: ToolResult;
210
- metadata?: Record<string, unknown>;
211
- }
212
- interface HookDecision {
213
- allow: boolean;
214
- reason?: string;
215
- }
216
- type HookCallback = (context: HookContext) => Promise<HookDecision | void>;
217
-
218
- declare class HookRunner {
219
- private readonly hooks;
220
- register(event: HookContext['event'], callback: HookCallback): void;
221
- run(context: HookContext): Promise<HookDecision>;
222
- }
223
-
224
- interface SpanRecord {
225
- traceId: string;
226
- spanId: string;
227
- parentSpanId?: string | undefined;
228
- name: string;
229
- attributes: Record<string, string | number | boolean>;
230
- startTime: number;
231
- endTime: number;
232
- }
233
- interface MetricRecord {
234
- name: string;
235
- value: number;
236
- type: 'counter' | 'histogram';
237
- attributes: Record<string, string | number | boolean>;
238
- }
239
- interface SpanHandle {
240
- traceId: string;
241
- spanId: string;
242
- end(attributes?: Record<string, string | number | boolean>): void;
243
- }
244
- declare class HarnessTelemetry {
245
- private readonly enabled;
246
- private readonly context;
247
- private readonly spans;
248
- private readonly metrics;
249
- constructor(enabled?: boolean);
250
- isEnabled(): boolean;
251
- startSpan(name: string, attributes?: Record<string, string | number | boolean>): SpanHandle;
252
- withSpan<T>(name: string, attributes: Record<string, string | number | boolean>, fn: () => Promise<T>): Promise<T>;
253
- counter(name: string, value?: number, attributes?: Record<string, string | number | boolean>): void;
254
- histogram(name: string, value: number, attributes?: Record<string, string | number | boolean>): void;
255
- getSpans(): SpanRecord[];
256
- getMetrics(): MetricRecord[];
257
- }
258
-
259
- interface SandboxExecResult {
260
- exitCode: number;
261
- stdout: string;
262
- stderr: string;
263
- }
264
- interface SandboxExecOptions {
265
- cwd?: string | undefined;
266
- timeoutMs?: number | undefined;
267
- env?: Record<string, string> | undefined;
268
- }
269
- interface SandboxFileBlob {
270
- data: Uint8Array;
271
- mimeType?: string | undefined;
272
- filename?: string | undefined;
273
- }
274
- interface SandboxProvider {
275
- initialize?(): Promise<void>;
276
- destroy?(): Promise<void>;
277
- exec(command: string, options?: SandboxExecOptions): Promise<SandboxExecResult>;
278
- readSandboxFile(path: string): Promise<SandboxFileBlob>;
279
- writeSandboxFile(path: string, content: SandboxFileBlob): Promise<void>;
280
- upload?(localPath: string, remotePath: string): Promise<void>;
281
- listFiles?(path: string): Promise<string[]>;
282
- snapshot?(): Promise<string>;
283
- restore?(snapshotId: string): Promise<void>;
284
- }
285
-
286
- interface SkillSummary {
287
- name: string;
288
- description: string;
289
- path: string;
290
- }
291
- interface SkillInvokeResult {
292
- skill: SkillSummary;
293
- instructions: string;
294
- execution?: {
295
- attempted: boolean;
296
- success: boolean;
297
- output: string;
298
- error?: string;
299
- commandsRun?: number;
300
- };
301
- }
302
-
303
- declare class SkillManager {
304
- private readonly sandbox;
305
- private readonly telemetry?;
306
- private readonly summaries;
307
- private readonly fullSkills;
308
- private readonly installState;
309
- constructor(sandbox?: SandboxProvider, telemetry?: HarnessTelemetry | undefined);
310
- registerSummary(skill: SkillSummary): void;
311
- getSkillSummaryForPrompt(): SkillSummary[];
312
- discover(skillIndexPath: string): Promise<SkillSummary[]>;
313
- private assertSafeSkillPath;
314
- private extractShellBlocks;
315
- invoke(name: string, options?: {
316
- mode?: 'execute' | 'instructions_only';
317
- }): Promise<SkillInvokeResult>;
318
- installDependencies(name: string): Promise<void>;
319
- getInstallState(name: string): 'ready' | 'degraded' | 'installing' | 'unknown';
320
- }
321
-
322
- /**
323
- * SkillResolver — pluggable interface for resolving skill instructions from action text.
324
- *
325
- * Extracted from ArcLoop to satisfy DIP + SRP:
326
- * - ArcLoop depends on the interface, not on SkillRouter/file loader directly
327
- * - Tests can mock skill resolution without filesystem
328
- * - Alternative implementations (remote registries) plug in without touching ArcLoop
329
- */
330
-
331
- interface ResolvedSkill {
332
- name: string;
333
- /** Full skill instructions (for legacy injection). */
334
- systemPrompt: string;
335
- /** File path to the skill (for progressive loading). */
336
- path: string;
337
- /** Pre-resolved sub-guide contents keyed by filename. */
338
- subGuides?: Record<string, string>;
339
- }
340
- interface SkillResolver {
341
- resolve(action: string, profileSkills?: string[]): Promise<ResolvedSkill | null>;
342
- }
343
-
344
- interface PagedResult {
345
- /** Opaque reference ID for retrieval. */
346
- ref: string;
347
- /** LLM-generated or heuristic summary of the paged content. */
348
- summary: string;
349
- /** Original content length in characters. */
350
- originalLength: number;
351
- }
352
- /**
353
- * ResultPager — stores large tool results externally and returns summaries.
354
- *
355
- * Implementations handle both storage and summarization. The harness calls
356
- * `page()` when a tool result exceeds the configured threshold, and `retrieve()`
357
- * when the LLM calls the auto-registered ReadFullResult tool.
358
- */
359
- interface ResultPager {
360
- /**
361
- * Store a large tool result and return a summary + reference.
362
- */
363
- page(content: string, meta: {
364
- toolName: string;
365
- toolCallId: string;
366
- processId?: string;
367
- }): Promise<PagedResult>;
368
- /**
369
- * Retrieve full content by reference.
370
- * Returns null if expired or not found.
371
- */
372
- retrieve(ref: string): Promise<string | null>;
373
- }
374
-
375
- /** Context passed to each resilience policy execution. */
376
- interface ExecutionContext {
377
- /** Current attempt number (0-based). */
378
- attempt: number;
379
- /** Total attempts allowed. */
380
- totalAttempts: number;
381
- /** Timestamp when the first attempt started. */
382
- startTime: number;
383
- /** Abort signal for cooperative cancellation. */
384
- signal: AbortSignal;
385
- }
386
- /** A resilience policy that wraps an async operation. */
387
- interface ResiliencePolicy {
388
- readonly name: string;
389
- execute<T>(fn: (ctx: ExecutionContext) => Promise<T>, ctx: ExecutionContext): Promise<T>;
390
- }
391
-
392
- interface Episode {
393
- id: string;
394
- taskId: string;
395
- sessionId: string;
396
- index: number;
397
- threadAction: string;
398
- summary: string;
399
- toolCalls: string[];
400
- filesRead: string[];
401
- filesModified: string[];
402
- model: string;
403
- steps: number;
404
- success: boolean;
405
- createdAt: number;
406
- parentEpisodeIds: string[];
407
- /** Typed output from generateObject when profile has a typed signature. */
408
- structuredOutput?: Record<string, unknown>;
409
- }
410
- interface EpisodeTrace {
411
- episodeId: string;
412
- messages: AgentMessage[];
413
- createdAt: number;
414
- ttl?: number;
415
- }
416
- interface SessionMemo {
417
- id: string;
418
- sessionId: string;
419
- content: string;
420
- sourceEpisodeIds: string[];
421
- createdAt: number;
422
- updatedAt?: number;
423
- }
424
- interface LongTermMemory {
425
- id: string;
426
- content: string;
427
- category: string;
428
- sourceSessionMemoIds: string[];
429
- createdAt: number;
430
- updatedAt: number;
431
- }
432
- interface EpisodeStore {
433
- addEpisode(episode: Episode): Promise<void>;
434
- addTrace(trace: EpisodeTrace): Promise<void>;
435
- getEpisode(id: string): Promise<Episode | null>;
436
- getTrace(episodeId: string): Promise<EpisodeTrace | null>;
437
- getEpisodesByTask(taskId: string): Promise<Episode[]>;
438
- getEpisodesBySession(sessionId: string): Promise<Episode[]>;
439
- getRecentEpisodes(limit: number): Promise<Episode[]>;
440
- evictTraces(olderThan: number): Promise<number>;
441
- }
442
- interface SessionMemoStore {
443
- addMemo(memo: SessionMemo): Promise<void>;
444
- getMemo(id: string): Promise<SessionMemo | null>;
445
- getMemoBySession?(sessionId: string): Promise<SessionMemo | null>;
446
- getMemosBySession(sessionId: string): Promise<SessionMemo[]>;
447
- getRecentMemos(limit: number): Promise<SessionMemo[]>;
448
- }
449
- interface LongTermStore {
450
- addMemory(memory: LongTermMemory): Promise<void>;
451
- getMemory(id: string): Promise<LongTermMemory | null>;
452
- getAllMemories(): Promise<LongTermMemory[]>;
453
- getMemoriesByCategory(category: string): Promise<LongTermMemory[]>;
454
- updateMemory(id: string, updates: Partial<Pick<LongTermMemory, 'content' | 'category' | 'updatedAt'>>): Promise<void>;
455
- deleteMemory(id: string): Promise<void>;
456
- }
457
- type ModelTier = 'fast' | 'medium' | 'strong';
458
- type AnyTool = Tool<any, any>;
459
-
460
- /** Creates an ai-sdk LanguageModel from a model ID string. Defaults to anthropic(). */
461
- type ModelFactory = (modelId: string) => any;
462
- /** Static tool choice value for LLM calls. */
463
- type ToolChoiceValue = 'auto' | 'required' | 'none' | {
464
- type: 'tool';
465
- toolName: string;
466
- };
467
- /**
468
- * Tool choice configuration — static value or per-turn callback.
469
- *
470
- * As a callback, receives the turn/step number (0-indexed) and returns the choice for that turn.
471
- * This enables patterns like forcing tool use on the first turn only:
472
- * `(turn) => turn === 0 ? 'required' : 'auto'`
473
- */
474
- type ToolChoiceConfig = ToolChoiceValue | ((turn: number) => ToolChoiceValue);
475
- interface ArcLoopConfig {
476
- /** Orchestrator model (default: 'claude-opus-4-6'). Accepts a model ID or tier name. */
477
- model?: string;
478
- /** Model tier mapping. Override to use different models for fast/medium/strong. */
479
- modelMap?: Record<ModelTier, string>;
480
- /** Model factory — creates an ai-sdk LanguageModel from a model ID. Defaults to anthropic(). */
481
- createModel?: ModelFactory;
482
- /** @deprecated Use createModel instead. Anthropic API key (set via ANTHROPIC_API_KEY env var). */
483
- apiKey?: string;
484
- /** Custom orchestrator system prompt */
485
- systemPrompt?: string;
486
- /** Max orchestrator turns before stopping (default: 30) */
487
- maxTurns?: number;
488
- /** Extra orchestrator tools beyond Thread/Check/Cancel/Remember */
489
- extraOrchestratorTools?: Record<string, AnyTool>;
490
- /** Handler for extra orchestrator tools. Return an AgentAction (typically FinalAction with directive). */
491
- onOrchestratorTool?: (name: string, args: Record<string, unknown>) => Promise<AgentAction>;
492
- /** Optional resilience policy applied to LLM calls (retry, circuit breaker, timeout, etc.). */
493
- resilience?: ResiliencePolicy;
494
- /** Tool choice for orchestrator LLM calls. Supports per-turn callbacks. Default: 'auto'. */
495
- orchestratorToolChoice?: ToolChoiceConfig;
496
- /** Default tool choice for all processes. Individual profiles can override. Default: 'auto'. */
497
- processToolChoice?: ToolChoiceConfig;
498
- /** ResultPager for storing large tool results externally in processes. */
499
- resultPager?: ResultPager;
500
- /** Character threshold above which tool results are paged. Default: 4000. */
501
- resultPageThreshold?: number;
502
- /** Tool names to never page (e.g., ['Read', 'Edit']). */
503
- pagingExclude?: string[];
504
- /** Hard cap on tool result length (chars) when no resultPager is configured. Truncates with a note. */
505
- maxToolResultLength?: number;
506
- /** Structured facts injected into process system prompts (e.g., from long-term memory). */
507
- contextFacts?: string[];
508
- /** Max context tokens for worker threads. When set, stubs old tool results to keep within budget. */
509
- maxContextTokens?: number;
510
- /**
511
- * Seed context injected into every process as a system message.
512
- * Use this to pass the user's original request, attachment metadata,
513
- * or other context that threads need but the orchestrator may not include
514
- * in the Thread action text.
515
- */
516
- processSeedContext?: string | AgentMessage[];
517
- /** Per-process timeout in ms (default: 120_000) */
518
- processTimeout?: number;
519
- /** Per-process max steps (default: 20) */
520
- processMaxSteps?: number;
521
- /** Default system prompt for all processes (overrides the built-in default) */
522
- processSystemPrompt?: string;
523
- /** Named process profiles. Accepts ProfileDeclaration (new, declarative) or ProcessProfile (legacy). */
524
- processProfiles?: Record<string, ProfileConfig>;
525
- /** Tools available inside processes (default: builtinTools) */
526
- processTools?: Record<string, AnyTool>;
527
- /** Context window size in tokens (default: 200_000) */
528
- contextWindowSize?: number;
529
- /** Tokens reserved for output (default: 20_000) */
530
- outputReserve?: number;
531
- /**
532
- * Enable dynamic context window detection via OpenRouter API.
533
- * When true, fetches model-specific context_length from OpenRouter.
534
- * Falls back to 128K tokens for unknown models.
535
- * Overrides contextWindowSize if both are set.
536
- * @default false
537
- */
538
- dynamicContextWindow?: boolean;
539
- episodeStore: EpisodeStore;
540
- sessionMemoStore: SessionMemoStore;
541
- longTermStore: LongTermStore;
542
- taskId: string;
543
- sessionId: string;
544
- /** Enable auto-memory detection and promotion (default: true) */
545
- autoMemory?: boolean;
546
- /** Pre-built SkillResolver instance. If omitted, one is created from skillIndexPath (if provided). */
547
- skillResolver?: SkillResolver;
548
- toolProvider: ToolProvider;
549
- /** Tool provider for skill-matched processes (sandbox) */
550
- skillToolProvider?: ToolProvider;
551
- /** Local directory to sync sandbox output artifacts to (default: './outputs') */
552
- localOutputDir?: string;
553
- sandboxProvider?: SandboxProvider;
554
- skillManager?: SkillManager;
555
- skillIndexPath?: string;
556
- telemetry?: HarnessTelemetry;
557
- hookRunner?: HookRunner;
558
- permissionManager?: PermissionManager;
559
- executeToolAction?: (action: ToolCallAction) => Promise<ToolResult | null>;
560
- }
561
- /**
562
- * ProfileDeclaration — typed, declarative profile definition.
563
- *
564
- * Replaces hand-written system prompts with structured declarations.
565
- * The system generates prompts from the declaration and enforces tool constraints.
566
- *
567
- * @example
568
- * const visual: ProfileDeclaration = {
569
- * name: 'visual',
570
- * signature: 'description -> compiledArtifact',
571
- * tools: ['CompileJsx', 'Read', 'ListFiles'],
572
- * skills: ['visual-explainer'],
573
- * };
574
- */
575
- interface ProfileDeclaration {
576
- /** Profile name (matches the Thread tool's profile parameter). */
577
- name: string;
578
- /** Typed signature: "input -> output". Describes what this profile produces. */
579
- signature: string;
580
- /** Tool names this profile can use. Only these tools are available — enforced at schema + executor level. */
581
- tools: string[];
582
- /** Domain knowledge injected into system prompt (skill content, color systems, etc.). */
583
- background?: string;
584
- /** Default model tier. */
585
- model?: ModelTier;
586
- /** Max LLM steps. */
587
- maxSteps?: number;
588
- /** Skill names this profile can use. SkillRouter is constrained to this set. Omit for all skills. */
589
- skills?: string[];
590
- /** Few-shot demonstration examples. Rendered as user/assistant message pairs in the prompt. */
591
- demos?: Array<{
592
- input: Record<string, string>;
593
- output: Record<string, unknown>;
594
- }>;
595
- }
596
- /** A named process profile — runtime form with resolved prompt and tools. */
597
- interface ProcessProfile {
598
- /** System prompt for processes using this profile. */
599
- systemPrompt: string;
600
- /** Tools available to processes using this profile (overrides processTools). */
601
- tools?: Record<string, AnyTool>;
602
- /** Default model tier for this profile (Thread tool's explicit model overrides this). */
603
- model?: ModelTier;
604
- /** Max steps for this profile (Thread tool's explicit maxSteps overrides this). */
605
- maxSteps?: number;
606
- /** Allowed tool names for executor-level validation (populated from ProfileDeclaration.tools). */
607
- allowedToolNames?: string[];
608
- /** Zod schema for structured output on the terminal step (generated from typed signatures). */
609
- outputSchema?: zod.ZodObject<any>;
610
- /** Few-shot demo messages rendered before the task prompt. */
611
- demoMessages?: AgentMessage[];
612
- }
613
- /** A profile config can be either a declaration (new) or a raw ProcessProfile (backward compat). */
614
- type ProfileConfig = ProfileDeclaration | ProcessProfile;
615
- type Activity = {
616
- type: 'tool_start';
617
- name: string;
618
- args: Record<string, unknown>;
619
- ts: number;
620
- } | {
621
- type: 'tool_end';
622
- name: string;
623
- ok: boolean;
624
- ms: number;
625
- preview?: string;
626
- ts: number;
627
- };
628
- type ArcEvent = {
629
- type: 'text_delta';
630
- text: string;
631
- } | {
632
- type: 'turn_start';
633
- turn: number;
634
- } | {
635
- type: 'turn_end';
636
- turn: number;
637
- } | {
638
- type: 'process_dispatched';
639
- id: string;
640
- action: string;
641
- model: string;
642
- label?: string;
643
- profile?: string;
644
- } | {
645
- type: 'thread_rejected';
646
- action: string;
647
- reason: string;
648
- } | {
649
- type: 'skill_resolved';
650
- processId: string;
651
- skillName: string;
652
- skillPath: string;
653
- } | {
654
- type: 'process_activity';
655
- id: string;
656
- activity: Activity;
657
- } | {
658
- type: 'process_text_delta';
659
- id: string;
660
- text: string;
661
- } | {
662
- type: 'process_step_start';
663
- id: string;
664
- step: number;
665
- } | {
666
- type: 'process_step_end';
667
- id: string;
668
- step: number;
669
- usage?: StepUsage;
670
- } | {
671
- type: 'process_completed';
672
- id: string;
673
- episodeId: string;
674
- summary: string;
675
- durationMs: number;
676
- } | {
677
- type: 'process_failed';
678
- id: string;
679
- error: string;
680
- } | {
681
- type: 'process_cancelled';
682
- id: string;
683
- } | {
684
- type: 'memory_stored';
685
- id: string;
686
- content: string;
687
- } | {
688
- type: 'context_compressed';
689
- tier: 'template' | 'episode_group' | 'llm';
690
- tokensSaved: number;
691
- } | {
692
- type: 'done';
693
- output: string;
694
- stats: RunStats;
695
- };
696
- interface RunStats {
697
- turns: number;
698
- processes: number;
699
- durationMs: number;
700
- }
701
- interface ArcRunResult {
702
- output: string;
703
- events: ArcEvent[];
704
- }
705
- interface TraceEvent {
706
- ts: number;
707
- kind: TraceEventKind;
708
- }
709
- type TraceEventKind = {
710
- type: 'turn_start';
711
- turn: number;
712
- } | {
713
- type: 'turn_end';
714
- turn: number;
715
- } | {
716
- type: 'llm_call_start';
717
- } | {
718
- type: 'llm_call_end';
719
- response_type: string;
720
- } | {
721
- type: 'process_created';
722
- id: string;
723
- status: string;
724
- } | {
725
- type: 'process_transition';
726
- id: string;
727
- from: string;
728
- to: string;
729
- } | {
730
- type: 'tool_call';
731
- tool: string;
732
- process_id?: string;
733
- } | {
734
- type: 'context_prepare';
735
- used: number;
736
- limit: number;
737
- compression_tier: string;
738
- } | {
739
- type: 'abort_signal';
740
- target?: string;
741
- } | {
742
- type: 'done';
743
- };
744
-
745
- export type { ArcEvent as A, ModelFactory as M, ProfileConfig as P, StepUsage as S, TraceEvent as T, ArcLoopConfig as a, AgentMessage as b, ArcRunResult as c, ProfileDeclaration as d, AnyTool as e, ProcessProfile as f, AgentLoop as g, ToolChoiceConfig as h, PrepareStepContext as i, PrepareStepResult as j, AgentAction as k, AgentStreamEvent as l };