@corbat-tech/coco 2.37.0 → 2.39.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.
@@ -0,0 +1,969 @@
1
+ import { T as ToolRegistry, a as ToolDefinition$1 } from './registry-CEpl9Jq0.js';
2
+
3
+ /**
4
+ * Unified thinking/reasoning mode support for all LLM providers.
5
+ *
6
+ * Normalizes three distinct API surfaces:
7
+ * - Anthropic: thinking.budget_tokens
8
+ * - OpenAI Chat Completions: reasoning_effort
9
+ * - OpenAI Responses API: reasoning.effort
10
+ * - Gemini: thinkingConfig.thinkingBudget
11
+ * - Kimi: thinking.type enabled/disabled
12
+ */
13
+ /**
14
+ * Provider-agnostic thinking mode.
15
+ * "off" — disable thinking entirely (or keep disabled for models like Kimi)
16
+ * "auto" — provider default / dynamic budget
17
+ * "low" — minimal reasoning
18
+ * "medium" — balanced reasoning
19
+ * "high" — maximum reasoning
20
+ * { budget: N } — explicit token budget (Anthropic / Gemini only; rejected for effort-only providers)
21
+ */
22
+ type ThinkingMode = "off" | "auto" | "low" | "medium" | "high" | {
23
+ budget: number;
24
+ };
25
+ /**
26
+ * Whether this provider/model uses effort buckets (OpenAI) or token budgets (Anthropic, Gemini).
27
+ */
28
+ type ThinkingKind = "effort" | "budget";
29
+
30
+ /**
31
+ * LLM Provider types for Corbat-Coco
32
+ */
33
+
34
+ /**
35
+ * Message role
36
+ */
37
+ type MessageRole = "system" | "user" | "assistant";
38
+ /**
39
+ * Message content types
40
+ */
41
+ type MessageContent = string | Array<TextContent | ImageContent | ToolUseContent | ToolResultContent>;
42
+ /**
43
+ * Text content block
44
+ */
45
+ interface TextContent {
46
+ type: "text";
47
+ text: string;
48
+ }
49
+ /**
50
+ * Image content block
51
+ */
52
+ interface ImageContent {
53
+ type: "image";
54
+ source: {
55
+ type: "base64";
56
+ media_type: string;
57
+ data: string;
58
+ };
59
+ }
60
+ /**
61
+ * Tool use content block
62
+ */
63
+ interface ToolUseContent {
64
+ type: "tool_use";
65
+ id: string;
66
+ name: string;
67
+ input: Record<string, unknown>;
68
+ /** Gemini-specific: preserve function-call thought signature across tool turns */
69
+ geminiThoughtSignature?: string;
70
+ }
71
+ /**
72
+ * Tool result content block
73
+ */
74
+ interface ToolResultContent {
75
+ type: "tool_result";
76
+ tool_use_id: string;
77
+ content: string;
78
+ is_error?: boolean;
79
+ }
80
+ /**
81
+ * Chat message
82
+ */
83
+ interface Message {
84
+ role: MessageRole;
85
+ content: MessageContent;
86
+ }
87
+ /**
88
+ * Tool definition for LLM
89
+ */
90
+ interface ToolDefinition {
91
+ name: string;
92
+ description: string;
93
+ input_schema: {
94
+ type: "object";
95
+ properties: Record<string, unknown>;
96
+ required?: string[];
97
+ };
98
+ }
99
+ /**
100
+ * Tool call from LLM
101
+ */
102
+ interface ToolCall {
103
+ id: string;
104
+ name: string;
105
+ input: Record<string, unknown>;
106
+ /** Gemini-specific: preserve function-call thought signature across tool turns */
107
+ geminiThoughtSignature?: string;
108
+ }
109
+ /**
110
+ * Chat options
111
+ */
112
+ interface ChatOptions {
113
+ model?: string;
114
+ maxTokens?: number;
115
+ temperature?: number;
116
+ stopSequences?: string[];
117
+ system?: string;
118
+ timeout?: number;
119
+ /** Abort signal to cancel in-flight requests */
120
+ signal?: AbortSignal;
121
+ /** Thinking/reasoning mode to pass to the model (if supported) */
122
+ thinking?: ThinkingMode;
123
+ }
124
+ /**
125
+ * Chat response
126
+ */
127
+ interface ChatResponse {
128
+ id: string;
129
+ content: string;
130
+ stopReason: "end_turn" | "max_tokens" | "stop_sequence" | "tool_use";
131
+ usage: {
132
+ inputTokens: number;
133
+ outputTokens: number;
134
+ };
135
+ model: string;
136
+ }
137
+ /**
138
+ * Chat with tools options
139
+ */
140
+ interface ChatWithToolsOptions extends ChatOptions {
141
+ tools: ToolDefinition[];
142
+ toolChoice?: "auto" | "any" | {
143
+ type: "tool";
144
+ name: string;
145
+ };
146
+ }
147
+ /**
148
+ * Chat with tools response
149
+ */
150
+ interface ChatWithToolsResponse extends ChatResponse {
151
+ toolCalls: ToolCall[];
152
+ }
153
+ /**
154
+ * Stream chunk
155
+ */
156
+ interface StreamChunk {
157
+ type: "text" | "tool_use_start" | "tool_use_delta" | "tool_use_end" | "done";
158
+ text?: string;
159
+ toolCall?: Partial<ToolCall>;
160
+ stopReason?: "end_turn" | "max_tokens" | "stop_sequence" | "tool_use";
161
+ }
162
+ /**
163
+ * LLM Provider interface
164
+ */
165
+ interface LLMProvider {
166
+ /**
167
+ * Provider identifier
168
+ */
169
+ id: string;
170
+ /**
171
+ * Provider display name
172
+ */
173
+ name: string;
174
+ /**
175
+ * Initialize the provider
176
+ */
177
+ initialize(config: ProviderConfig): Promise<void>;
178
+ /**
179
+ * Send a chat message
180
+ */
181
+ chat(messages: Message[], options?: ChatOptions): Promise<ChatResponse>;
182
+ /**
183
+ * Send a chat message with tool use
184
+ */
185
+ chatWithTools(messages: Message[], options: ChatWithToolsOptions): Promise<ChatWithToolsResponse>;
186
+ /**
187
+ * Stream a chat response
188
+ */
189
+ stream(messages: Message[], options?: ChatOptions): AsyncIterable<StreamChunk>;
190
+ /**
191
+ * Stream a chat response with tool use
192
+ */
193
+ streamWithTools(messages: Message[], options: ChatWithToolsOptions): AsyncIterable<StreamChunk>;
194
+ /**
195
+ * Count tokens in text
196
+ */
197
+ countTokens(text: string): number;
198
+ /**
199
+ * Get context window size
200
+ */
201
+ getContextWindow(): number;
202
+ /**
203
+ * Check if provider is available
204
+ */
205
+ isAvailable(): Promise<boolean>;
206
+ }
207
+ /**
208
+ * Provider configuration
209
+ */
210
+ interface ProviderConfig {
211
+ apiKey?: string;
212
+ baseUrl?: string;
213
+ model?: string;
214
+ maxTokens?: number;
215
+ temperature?: number;
216
+ timeout?: number;
217
+ project?: string;
218
+ location?: string;
219
+ /** Internal: flag to indicate using Google Cloud ADC */
220
+ useADC?: boolean;
221
+ }
222
+
223
+ /**
224
+ * Provider and model catalog.
225
+ *
226
+ * This is the source of truth for model IDs, defaults, context windows,
227
+ * pricing metadata, and provider capabilities. Endpoint adapters still own
228
+ * request/response conversion, but they should read model metadata from here.
229
+ */
230
+
231
+ type ModelStatus = "current" | "legacy" | "deprecated" | "experimental";
232
+ type ModelCapability = "streaming" | "tool-use" | "vision" | "reasoning-effort" | "adaptive-thinking" | "thinking-budget" | "openai-responses" | "openai-chat" | "anthropic-messages" | "gemini-generate-content";
233
+ interface ProviderSource {
234
+ name: string;
235
+ url: string;
236
+ verifiedAt: string;
237
+ }
238
+ interface ModelPricing {
239
+ inputPerMillion: number;
240
+ outputPerMillion: number;
241
+ }
242
+ interface ModelCatalogEntry {
243
+ id: string;
244
+ name: string;
245
+ description?: string;
246
+ contextWindow: number;
247
+ maxOutputTokens?: number;
248
+ recommended?: boolean;
249
+ status: ModelStatus;
250
+ capabilities: ModelCapability[];
251
+ pricing?: ModelPricing;
252
+ source: ProviderSource;
253
+ }
254
+ interface ProviderCatalogEntry {
255
+ id: ProviderType;
256
+ defaultModel: string;
257
+ models: ModelCatalogEntry[];
258
+ }
259
+
260
+ /**
261
+ * Runtime compatibility view derived from the static provider catalog.
262
+ *
263
+ * The catalog records what a model is; this module records how Coco should use it
264
+ * safely at runtime, including endpoint selection and reasoning/tooling limits.
265
+ */
266
+
267
+ type ProviderEndpointStrategy = "anthropic-messages" | "openai-responses" | "openai-chat" | "gemini-generate-content";
268
+ type ModelCompatibilityStatus = ModelStatus | "unverified";
269
+ interface ProviderRuntimeCapability {
270
+ provider: ProviderType;
271
+ model: string;
272
+ catalogModel?: ModelCatalogEntry;
273
+ status: ModelCompatibilityStatus;
274
+ endpoint: ProviderEndpointStrategy;
275
+ supportsStreaming: boolean;
276
+ supportsToolUse: boolean;
277
+ supportsVision: boolean;
278
+ supportsReasoning: boolean;
279
+ reasoningKinds: ThinkingKind[];
280
+ defaultReasoning: ThinkingMode;
281
+ contextWindow: number;
282
+ maxOutputTokens?: number;
283
+ sourceUrl?: string;
284
+ restrictions: string[];
285
+ }
286
+ interface ProviderProbeResult extends ProviderRuntimeCapability {
287
+ available: boolean | "not-checked";
288
+ checkedAt: string;
289
+ error?: string;
290
+ }
291
+
292
+ /**
293
+ * Provider exports for Corbat-Coco
294
+ */
295
+
296
+ /**
297
+ * Supported provider types
298
+ */
299
+ type ProviderType = "anthropic" | "openai" | "codex" | "copilot" | "gemini" | "vertex" | "kimi" | "kimi-code" | "lmstudio" | "ollama" | "groq" | "openrouter" | "mistral" | "deepseek" | "together" | "huggingface" | "qwen";
300
+ /**
301
+ * Create a provider by type
302
+ */
303
+ declare function createProvider(type: ProviderType, config?: ProviderConfig): Promise<LLMProvider>;
304
+
305
+ /** Catalog-backed provider/model registry used by runtime consumers. */
306
+ declare class ProviderRegistry {
307
+ listProviders(): ProviderCatalogEntry[];
308
+ getProvider(provider: ProviderType): ProviderCatalogEntry;
309
+ listModels(provider: ProviderType): ModelCatalogEntry[];
310
+ getModel(provider: ProviderType, model: string): ModelCatalogEntry | undefined;
311
+ getDefaultModel(provider: ProviderType): string;
312
+ getRecommendedModel(provider: ProviderType): ModelCatalogEntry;
313
+ getCapability(provider: ProviderType, model?: string): ProviderRuntimeCapability;
314
+ createProvider(provider: ProviderType, config?: ProviderConfig): Promise<LLMProvider>;
315
+ probe(provider: ProviderType, model: string | undefined, checkAvailability?: () => Promise<boolean>): Promise<ProviderProbeResult>;
316
+ }
317
+ declare function createProviderRegistry(): ProviderRegistry;
318
+
319
+ /**
320
+ * Agent mode registry.
321
+ *
322
+ * Modes describe the intended control flow for a runtime turn without changing
323
+ * the provider interface. CLI, headless, and embedders share this registry.
324
+ */
325
+ type AgentModeId = "ask" | "plan" | "build" | "debug" | "review" | "architect";
326
+ interface AgentModeDefinition {
327
+ id: AgentModeId;
328
+ label: string;
329
+ description: string;
330
+ readOnly: boolean;
331
+ preferredTools: string[];
332
+ requiresVerification: boolean;
333
+ }
334
+ declare const AGENT_MODES: Record<AgentModeId, AgentModeDefinition>;
335
+ declare function getAgentMode(mode: AgentModeId): AgentModeDefinition;
336
+ declare function listAgentModes(): AgentModeDefinition[];
337
+ declare function isAgentMode(value: string): value is AgentModeId;
338
+
339
+ type ReasoningEffort = "auto" | "low" | "medium" | "high" | "max";
340
+ type RuntimeMode = AgentModeId;
341
+ interface AgentRuntimeOptions {
342
+ providerType: ProviderType;
343
+ model?: string;
344
+ providerConfig?: ProviderConfig;
345
+ provider?: LLMProvider;
346
+ toolRegistry?: ToolRegistry;
347
+ /** Legacy CLI session store passthrough. Runtime APIs use runtimeSessionStore. */
348
+ sessionStore?: unknown;
349
+ runtimeSessionStore?: RuntimeSessionStore;
350
+ workflowEngine?: WorkflowEngine;
351
+ permissionPolicy?: PermissionPolicy;
352
+ eventLog?: EventLog;
353
+ eventLogPath?: string;
354
+ turnRunner?: RuntimeTurnRunner;
355
+ /**
356
+ * Publish provider/tools into Coco's legacy process-global subagent bridge.
357
+ * CLI/headless use this for compatibility; embedders should leave it false.
358
+ */
359
+ publishToGlobalBridge?: boolean;
360
+ }
361
+ interface AgentRuntimeSnapshot {
362
+ provider: {
363
+ type: ProviderType;
364
+ model: string;
365
+ capability: ProviderRuntimeCapability;
366
+ };
367
+ tools: {
368
+ count: number;
369
+ names: string[];
370
+ };
371
+ modes: AgentModeDefinition[];
372
+ }
373
+ type RuntimeEventType = "runtime.initialized" | "provider.attached" | "provider.created" | "provider.updated" | "turn.started" | "turn.completed" | "turn.cancelled" | "turn.failed" | "tool.started" | "tool.completed" | "tool.allowed" | "tool.blocked" | "tool.skipped" | "agent.started" | "agent.graph.started" | "agent.graph.completed" | "agent.graph.failed" | "agent.tool.called" | "agent.handoff.created" | "agent.artifact.created" | "agent.completed" | "agent.failed" | "guardrail.input" | "guardrail.output" | "guardrail.tool" | "workflow.planned" | "workflow.started" | "workflow.completed" | "workflow.failed" | "workflow.gate.passed" | "workflow.gate.failed" | "shared_state.updated" | "session.created" | "session.updated" | "checkpoint.created" | "error";
374
+ interface RuntimeEvent {
375
+ id: string;
376
+ type: RuntimeEventType;
377
+ timestamp: string;
378
+ data: Record<string, unknown>;
379
+ }
380
+ interface EventLog {
381
+ record(type: RuntimeEventType, data?: Record<string, unknown>): RuntimeEvent;
382
+ list(): RuntimeEvent[];
383
+ count(): number;
384
+ clear(): void;
385
+ }
386
+ interface PermissionDecision {
387
+ allowed: boolean;
388
+ reason?: string;
389
+ requiresConfirmation?: boolean;
390
+ risk: "read-only" | "write" | "network" | "destructive" | "secrets-sensitive";
391
+ }
392
+ interface PermissionPolicy {
393
+ canExecuteTool(mode: RuntimeMode, tool: ToolDefinition$1): PermissionDecision;
394
+ canExecuteToolInput?(mode: RuntimeMode, tool: ToolDefinition$1, input: Record<string, unknown>): PermissionDecision;
395
+ }
396
+ interface ProviderRuntimeSelection {
397
+ provider: ProviderType;
398
+ model: string;
399
+ thinking?: ThinkingMode;
400
+ }
401
+ interface RuntimeSession {
402
+ id: string;
403
+ createdAt: string;
404
+ updatedAt: string;
405
+ mode: RuntimeMode;
406
+ messages: Message[];
407
+ instructions?: string;
408
+ metadata: Record<string, unknown>;
409
+ }
410
+ interface RuntimeSessionCreateOptions {
411
+ id?: string;
412
+ mode?: RuntimeMode;
413
+ instructions?: string;
414
+ metadata?: Record<string, unknown>;
415
+ messages?: Message[];
416
+ }
417
+ interface RuntimeSessionStore {
418
+ create(options?: RuntimeSessionCreateOptions): RuntimeSession;
419
+ get(id: string): RuntimeSession | undefined;
420
+ update(session: RuntimeSession): RuntimeSession;
421
+ list(): RuntimeSession[];
422
+ delete(id: string): boolean;
423
+ }
424
+ interface RuntimeTurnInput {
425
+ content: string;
426
+ sessionId?: string;
427
+ mode?: RuntimeMode;
428
+ options?: ChatOptions;
429
+ metadata?: Record<string, unknown>;
430
+ /**
431
+ * Tool names that the embedding product has explicitly confirmed for this
432
+ * turn. Destructive tools are still blocked unless listed here.
433
+ */
434
+ confirmedTools?: string[];
435
+ }
436
+ interface RuntimeTurnResult {
437
+ sessionId: string;
438
+ content: string;
439
+ usage: {
440
+ inputTokens: number;
441
+ outputTokens: number;
442
+ estimated?: boolean;
443
+ };
444
+ model: string;
445
+ mode: RuntimeMode;
446
+ }
447
+ type RuntimeTurnStreamEvent = {
448
+ type: "text";
449
+ sessionId: string;
450
+ text: string;
451
+ } | {
452
+ type: "done";
453
+ sessionId: string;
454
+ result: RuntimeTurnResult;
455
+ } | {
456
+ type: "error";
457
+ sessionId: string;
458
+ error: string;
459
+ };
460
+ interface RuntimeTurnContext {
461
+ runtime: unknown;
462
+ session: RuntimeSession;
463
+ provider: LLMProvider;
464
+ toolRegistry: ToolRegistry;
465
+ permissionPolicy: PermissionPolicy;
466
+ eventLog: EventLog;
467
+ }
468
+ interface RuntimeTurnRunner {
469
+ run(input: RuntimeTurnInput, context: RuntimeTurnContext): Promise<RuntimeTurnResult>;
470
+ }
471
+ interface RuntimeToolExecutionInput {
472
+ sessionId?: string;
473
+ mode?: RuntimeMode;
474
+ toolName: string;
475
+ input: Record<string, unknown>;
476
+ confirmed?: boolean;
477
+ metadata?: Record<string, unknown>;
478
+ }
479
+ interface RuntimeToolExecutionResult {
480
+ toolName: string;
481
+ success: boolean;
482
+ output?: unknown;
483
+ error?: string;
484
+ duration: number;
485
+ decision: PermissionDecision;
486
+ }
487
+
488
+ type WorkflowRisk = "read-only" | "write" | "network" | "destructive" | "secrets-sensitive";
489
+ interface WorkflowStepDefinition {
490
+ id: string;
491
+ description: string;
492
+ requiredTools: string[];
493
+ risk: WorkflowRisk;
494
+ }
495
+ interface WorkflowRetryPolicy {
496
+ maxAttempts: number;
497
+ backoffMs?: number;
498
+ }
499
+ interface WorkflowDefinition {
500
+ id: string;
501
+ name: string;
502
+ description: string;
503
+ inputSchema: string;
504
+ /** Legacy linear workflow steps. Prefer nodes for new multi-agent workflows. */
505
+ steps: WorkflowStepDefinition[];
506
+ nodes?: AgentGraphNode[];
507
+ edges?: AgentGraphDefinition["edges"];
508
+ gates?: AgentGateDefinition[];
509
+ retryPolicy?: WorkflowRetryPolicy;
510
+ parallelism?: number;
511
+ checks: string[];
512
+ outputKind: "markdown" | "json" | "patch" | "pull-request" | "release";
513
+ replayable: boolean;
514
+ }
515
+ interface WorkflowPlan {
516
+ id: string;
517
+ workflowId: string;
518
+ input: Record<string, unknown>;
519
+ status: "planned";
520
+ createdAt: string;
521
+ }
522
+ declare function workflowToAgentGraph(workflow: WorkflowDefinition): AgentGraphDefinition;
523
+ /** Descriptive catalog of reusable workflow definitions; it does not execute workflows. */
524
+ declare class WorkflowCatalog {
525
+ private workflows;
526
+ constructor(workflows?: WorkflowDefinition[]);
527
+ register(workflow: WorkflowDefinition): void;
528
+ get(id: string): WorkflowDefinition | undefined;
529
+ list(): WorkflowDefinition[];
530
+ createPlan(workflowId: string, input: Record<string, unknown>, eventLog?: EventLog): WorkflowPlan;
531
+ }
532
+ declare const DEFAULT_WORKFLOWS: WorkflowDefinition[];
533
+ declare const WorkflowRegistry: typeof WorkflowCatalog;
534
+ declare function createWorkflowCatalog(workflows?: WorkflowDefinition[]): WorkflowCatalog;
535
+ declare function createWorkflowRegistry(workflows?: WorkflowDefinition[]): WorkflowCatalog;
536
+
537
+ type AgentRole = "researcher" | "planner" | "architect" | "editor" | "coder" | "tester" | "reviewer" | "optimizer" | "security" | "qa" | "integrator" | "pm" | "docs" | "database";
538
+ interface AgentBudget {
539
+ maxTurns?: number;
540
+ timeoutMs?: number;
541
+ maxInputTokens?: number;
542
+ maxOutputTokens?: number;
543
+ maxEstimatedCostUsd?: number;
544
+ maxConcurrentRuns?: number;
545
+ }
546
+ interface AgentCapability {
547
+ role: AgentRole;
548
+ allowedTools: string[];
549
+ risk: WorkflowRisk;
550
+ model?: string;
551
+ temperature?: number;
552
+ budget?: AgentBudget;
553
+ guardrails?: AgentGuardrailPolicy;
554
+ }
555
+ interface AgentGuardrailPolicy {
556
+ input?: boolean;
557
+ output?: boolean;
558
+ toolUse?: boolean;
559
+ redactSecrets?: boolean;
560
+ blockPromptInjection?: boolean;
561
+ }
562
+ interface AgentDefinition {
563
+ id: string;
564
+ role: AgentRole;
565
+ name: string;
566
+ instructions: string;
567
+ capability: AgentCapability;
568
+ outputSchema?: Record<string, unknown>;
569
+ metadata?: Record<string, unknown>;
570
+ }
571
+ interface LegacyAgentRoleMapping {
572
+ legacy: string;
573
+ role: AgentRole;
574
+ reason: string;
575
+ }
576
+ declare function mapLegacyAgentRole(legacyRole: string, fallback?: AgentRole): AgentRole;
577
+ declare function listLegacyAgentRoleMappings(): LegacyAgentRoleMapping[];
578
+ interface AgentTask {
579
+ id: string;
580
+ role: AgentRole;
581
+ objective: string;
582
+ context?: Record<string, unknown>;
583
+ dependencies?: string[];
584
+ expectedOutput?: AgentArtifactKind[];
585
+ constraints?: string[];
586
+ }
587
+ type AgentArtifactKind = "plan" | "findings" | "patchProposal" | "testReport" | "riskReport" | "summary";
588
+ interface AgentArtifact<T = unknown> {
589
+ id: string;
590
+ kind: AgentArtifactKind;
591
+ agentRunId?: string;
592
+ taskId?: string;
593
+ title?: string;
594
+ content: T;
595
+ createdAt: string;
596
+ metadata?: Record<string, unknown>;
597
+ }
598
+ type AgentRunStatus = "completed" | "failed" | "cancelled" | "timeout";
599
+ interface AgentRunResult {
600
+ id: string;
601
+ taskId: string;
602
+ role: AgentRole;
603
+ status: AgentRunStatus;
604
+ success: boolean;
605
+ output: string;
606
+ artifacts: AgentArtifact[];
607
+ toolsUsed: string[];
608
+ turns: number;
609
+ durationMs: number;
610
+ usage?: {
611
+ inputTokens: number;
612
+ outputTokens: number;
613
+ estimated?: boolean;
614
+ };
615
+ error?: string;
616
+ startedAt: string;
617
+ completedAt: string;
618
+ metadata?: Record<string, unknown>;
619
+ }
620
+ type AgentMessageRole = "user" | "agent" | "system" | "tool";
621
+ interface AgentMessage {
622
+ id: string;
623
+ role: AgentMessageRole;
624
+ content: string;
625
+ taskId?: string;
626
+ agentRunId?: string;
627
+ createdAt: string;
628
+ metadata?: Record<string, unknown>;
629
+ }
630
+ interface AgentHandoff {
631
+ id: string;
632
+ fromAgentRunId: string;
633
+ toRole: AgentRole;
634
+ task: AgentTask;
635
+ artifacts: AgentArtifact[];
636
+ createdAt: string;
637
+ metadata?: Record<string, unknown>;
638
+ }
639
+ interface AgentCard {
640
+ id: string;
641
+ role: AgentRole;
642
+ name: string;
643
+ description: string;
644
+ skills: string[];
645
+ inputSchema?: Record<string, unknown>;
646
+ outputSchema?: Record<string, unknown>;
647
+ capability: AgentCapability;
648
+ }
649
+ type AgentGateKind = "tests" | "coverage" | "review" | "security" | "quality-score" | "human-approval";
650
+ interface AgentGateDefinition {
651
+ id: string;
652
+ kind: AgentGateKind;
653
+ description: string;
654
+ required: boolean;
655
+ threshold?: number;
656
+ }
657
+ interface AgentGraphNode {
658
+ id: string;
659
+ agentRole?: AgentRole;
660
+ description: string;
661
+ dependsOn?: string[];
662
+ requiredTools?: string[];
663
+ risk: WorkflowRisk;
664
+ gates?: string[];
665
+ retryPolicy?: {
666
+ maxAttempts: number;
667
+ backoffMs?: number;
668
+ };
669
+ condition?: string;
670
+ }
671
+ interface AgentGraphEdge {
672
+ from: string;
673
+ to: string;
674
+ condition?: string;
675
+ }
676
+ interface AgentGraphDefinition {
677
+ nodes: AgentGraphNode[];
678
+ edges?: AgentGraphEdge[];
679
+ gates?: AgentGateDefinition[];
680
+ parallelism?: number;
681
+ }
682
+ interface AgentGraphValidationIssue {
683
+ code: "duplicate-node" | "missing-dependency" | "missing-edge-node" | "missing-gate" | "cycle" | "invalid-parallelism" | "invalid-retry-policy";
684
+ message: string;
685
+ nodeId?: string;
686
+ gateId?: string;
687
+ }
688
+ interface AgentGraphValidationResult {
689
+ valid: boolean;
690
+ issues: AgentGraphValidationIssue[];
691
+ levels: string[][];
692
+ }
693
+ interface SharedWorkspaceStateSnapshot {
694
+ facts: Record<string, unknown>;
695
+ decisions: Record<string, unknown>;
696
+ risks: Record<string, unknown>;
697
+ files: Record<string, unknown>;
698
+ testResults: Record<string, unknown>;
699
+ artifacts: AgentArtifact[];
700
+ }
701
+ type SharedWorkspaceRecordKind = "fact" | "decision" | "risk" | "file" | "testResult" | "artifact";
702
+ interface SharedWorkspaceProvenance {
703
+ workflowRunId: string;
704
+ agentRunId?: string;
705
+ nodeId?: string;
706
+ taskId?: string;
707
+ eventId?: string;
708
+ confidence?: number;
709
+ risk?: WorkflowRisk;
710
+ }
711
+ interface SharedWorkspaceRecord {
712
+ id: string;
713
+ kind: SharedWorkspaceRecordKind;
714
+ key: string;
715
+ value: unknown;
716
+ provenance: SharedWorkspaceProvenance;
717
+ createdAt: string;
718
+ }
719
+ interface SharedWorkspaceWriteInput {
720
+ kind: SharedWorkspaceRecordKind;
721
+ key: string;
722
+ value: unknown;
723
+ provenance: SharedWorkspaceProvenance;
724
+ createdAt?: string;
725
+ }
726
+ interface SharedWorkspaceStore {
727
+ write(input: SharedWorkspaceWriteInput): SharedWorkspaceRecord;
728
+ list(): SharedWorkspaceRecord[];
729
+ snapshot(): SharedWorkspaceStateSnapshot;
730
+ readForRole(role: AgentRole): SharedWorkspaceStateSnapshot;
731
+ clear(): void;
732
+ }
733
+ declare class InMemorySharedWorkspaceStore implements SharedWorkspaceStore {
734
+ private records;
735
+ write(input: SharedWorkspaceWriteInput): SharedWorkspaceRecord;
736
+ list(): SharedWorkspaceRecord[];
737
+ snapshot(): SharedWorkspaceStateSnapshot;
738
+ readForRole(role: AgentRole): SharedWorkspaceStateSnapshot;
739
+ clear(): void;
740
+ }
741
+ declare class FileSharedWorkspaceStore implements SharedWorkspaceStore {
742
+ private readonly filePath;
743
+ private readonly memory;
744
+ private writable;
745
+ constructor(filePath: string);
746
+ write(input: SharedWorkspaceWriteInput): SharedWorkspaceRecord;
747
+ list(): SharedWorkspaceRecord[];
748
+ snapshot(): SharedWorkspaceStateSnapshot;
749
+ readForRole(role: AgentRole): SharedWorkspaceStateSnapshot;
750
+ clear(): void;
751
+ private readRecordsFromDisk;
752
+ }
753
+ declare class SharedWorkspaceState {
754
+ private readonly workflowRunId;
755
+ private readonly store;
756
+ private facts;
757
+ private decisions;
758
+ private risks;
759
+ private files;
760
+ private testResults;
761
+ private artifacts;
762
+ writeFact(key: string, value: unknown): void;
763
+ recordDecision(key: string, value: unknown): void;
764
+ recordRisk(key: string, value: unknown): void;
765
+ recordFile(path: string, value: unknown): void;
766
+ recordTestResult(key: string, value: unknown): void;
767
+ addArtifact(artifact: AgentArtifact): void;
768
+ readForRole(role: AgentRole): SharedWorkspaceStateSnapshot;
769
+ snapshot(): SharedWorkspaceStateSnapshot;
770
+ records(): SharedWorkspaceRecord[];
771
+ }
772
+ type ToolRiskLevel = "low" | "medium" | "high" | "critical";
773
+ interface ToolRiskManifestEntry {
774
+ toolName: string;
775
+ risk: WorkflowRisk;
776
+ level: ToolRiskLevel;
777
+ requiredCapability?: AgentRole | AgentRole[];
778
+ requiresConsent?: boolean;
779
+ destructive?: boolean;
780
+ secretsSensitive?: boolean;
781
+ network?: boolean;
782
+ filesystem?: boolean;
783
+ }
784
+ type ToolRiskManifest = Record<string, ToolRiskManifestEntry>;
785
+ interface AgentToolPolicyDecision {
786
+ allowed: boolean;
787
+ risk: WorkflowRisk;
788
+ reason?: string;
789
+ requiresConsent?: boolean;
790
+ }
791
+ declare function evaluateAgentToolPolicy(input: {
792
+ capability: AgentCapability;
793
+ toolName: string;
794
+ manifest?: ToolRiskManifest;
795
+ }): AgentToolPolicyDecision;
796
+ interface AgentTraceContext {
797
+ traceId: string;
798
+ spanId: string;
799
+ parentSpanId?: string;
800
+ workflowRunId?: string;
801
+ agentRunId?: string;
802
+ taskId?: string;
803
+ toolCallId?: string;
804
+ }
805
+ declare function createAgentTraceContext(input?: Partial<AgentTraceContext>): AgentTraceContext;
806
+ interface AgentGraphNodeExecution {
807
+ node: AgentGraphNode;
808
+ task: AgentTask;
809
+ attempt: number;
810
+ workflowRunId: string;
811
+ trace: AgentTraceContext;
812
+ dependencyResults: Map<string, AgentRunResult>;
813
+ sharedState: SharedWorkspaceStore;
814
+ eventLog: EventLog;
815
+ }
816
+ type AgentGraphNodeExecutor = (execution: AgentGraphNodeExecution) => Promise<AgentRunResult>;
817
+ type AgentGateEvaluator = (input: {
818
+ gate: AgentGateDefinition;
819
+ node: AgentGraphNode;
820
+ result: AgentRunResult;
821
+ workflowRunId: string;
822
+ trace: AgentTraceContext;
823
+ sharedState: SharedWorkspaceStore;
824
+ eventLog: EventLog;
825
+ }) => Promise<{
826
+ passed: boolean;
827
+ reason?: string;
828
+ }>;
829
+ interface AgentGraphEngineOptions {
830
+ eventLog?: EventLog;
831
+ sharedState?: SharedWorkspaceStore;
832
+ nodeExecutor?: AgentGraphNodeExecutor;
833
+ gateEvaluator?: AgentGateEvaluator;
834
+ trace?: AgentTraceContext;
835
+ }
836
+ interface AgentGraphRunInput {
837
+ workflowRunId: string;
838
+ graph: AgentGraphDefinition;
839
+ input: Record<string, unknown>;
840
+ }
841
+ type AgentGraphRunStatus = "completed" | "failed";
842
+ interface AgentGraphRunResult {
843
+ id: string;
844
+ status: AgentGraphRunStatus;
845
+ nodeResults: Record<string, AgentRunResult>;
846
+ artifacts: AgentArtifact[];
847
+ stateSnapshot: SharedWorkspaceStateSnapshot;
848
+ trace: AgentTraceContext;
849
+ startedAt: string;
850
+ completedAt: string;
851
+ error?: string;
852
+ }
853
+ declare class AgentGraphEngine {
854
+ private readonly eventLog?;
855
+ private readonly sharedState;
856
+ private readonly nodeExecutor;
857
+ private readonly gateEvaluator;
858
+ private readonly trace;
859
+ constructor(options?: AgentGraphEngineOptions);
860
+ run(input: AgentGraphRunInput): Promise<AgentGraphRunResult>;
861
+ private executeNode;
862
+ private evaluateNodeGates;
863
+ }
864
+ declare function createAgentGraphEngine(options?: AgentGraphEngineOptions): AgentGraphEngine;
865
+ declare function createAgentArtifact<T>(input: Omit<AgentArtifact<T>, "id" | "createdAt"> & {
866
+ id?: string;
867
+ createdAt?: string;
868
+ }): AgentArtifact<T>;
869
+ declare function createSummaryArtifact(output: string, metadata?: Pick<AgentArtifact, "agentRunId" | "taskId"> & {
870
+ title?: string;
871
+ }): AgentArtifact<string>;
872
+ declare function normalizeAgentRunResult(input: {
873
+ id: string;
874
+ taskId: string;
875
+ role: AgentRole;
876
+ success: boolean;
877
+ output: string;
878
+ startedAt?: string;
879
+ completedAt?: string;
880
+ durationMs?: number;
881
+ turns?: number;
882
+ toolsUsed?: string[];
883
+ usage?: AgentRunResult["usage"];
884
+ error?: string;
885
+ artifacts?: AgentArtifact[];
886
+ status?: AgentRunStatus;
887
+ metadata?: Record<string, unknown>;
888
+ }): AgentRunResult;
889
+ declare function validateAgentCapabilities(capability: AgentCapability, requiredTools?: string[]): AgentGraphValidationIssue[];
890
+ declare function validateAgentGraph(graph: AgentGraphDefinition): AgentGraphValidationResult;
891
+
892
+ type WorkflowRunStatus = "completed" | "failed";
893
+ interface WorkflowRunInput {
894
+ workflowId: string;
895
+ input: Record<string, unknown>;
896
+ plan?: WorkflowPlan;
897
+ }
898
+ interface WorkflowRunResult {
899
+ id: string;
900
+ workflowId: string;
901
+ status: WorkflowRunStatus;
902
+ output: unknown;
903
+ startedAt: string;
904
+ completedAt: string;
905
+ error?: string;
906
+ graphResult?: AgentGraphRunResult;
907
+ trace?: AgentTraceContext;
908
+ }
909
+ interface WorkflowRunContext {
910
+ workflow: WorkflowDefinition;
911
+ plan: WorkflowPlan;
912
+ eventLog: EventLog;
913
+ }
914
+ type WorkflowHandler = (input: Record<string, unknown>, context: WorkflowRunContext) => Promise<unknown>;
915
+ interface WorkflowEngineOptions {
916
+ catalog?: WorkflowCatalog;
917
+ eventLog?: EventLog;
918
+ sharedState?: SharedWorkspaceStore;
919
+ nodeExecutor?: AgentGraphNodeExecutor;
920
+ }
921
+ declare class WorkflowEngine {
922
+ private readonly catalog;
923
+ private readonly eventLog;
924
+ private handlers;
925
+ private readonly sharedState;
926
+ private nodeExecutor?;
927
+ constructor(catalog?: WorkflowCatalog, eventLog?: EventLog, options?: Omit<WorkflowEngineOptions, "catalog" | "eventLog">);
928
+ registerHandler(workflowId: string, handler: WorkflowHandler): void;
929
+ registerNodeExecutor(executor: AgentGraphNodeExecutor): void;
930
+ createPlan(workflowId: string, input: Record<string, unknown>): WorkflowPlan;
931
+ run(request: WorkflowRunInput): Promise<WorkflowRunResult>;
932
+ }
933
+ declare function createWorkflowEngine(catalog?: WorkflowCatalog, eventLog?: EventLog, options?: Omit<WorkflowEngineOptions, "catalog" | "eventLog">): WorkflowEngine;
934
+
935
+ /**
936
+ * Reusable runtime facade for wiring providers, tools, permissions, sessions,
937
+ * and observability. It does not own the CLI loop; CLI/headless are adapters on
938
+ * top of this boundary.
939
+ */
940
+ declare class AgentRuntime {
941
+ private readonly options;
942
+ readonly providerRegistry: ProviderRegistry;
943
+ readonly toolRegistry: ToolRegistry;
944
+ readonly sessionStore: unknown;
945
+ readonly runtimeSessionStore: RuntimeSessionStore;
946
+ readonly workflowEngine: WorkflowEngine;
947
+ readonly permissionPolicy: PermissionPolicy;
948
+ readonly eventLog: EventLog;
949
+ readonly turnRunner: RuntimeTurnRunner;
950
+ private providerType;
951
+ private model;
952
+ private provider?;
953
+ constructor(options: AgentRuntimeOptions);
954
+ initialize(): Promise<void>;
955
+ getModel(): string;
956
+ updateProvider(providerType: ProviderType, model: string | undefined, provider: LLMProvider): void;
957
+ private publishToGlobalBridge;
958
+ snapshot(): AgentRuntimeSnapshot;
959
+ createSession(options?: RuntimeSessionCreateOptions): RuntimeSession;
960
+ getSession(sessionId: string): RuntimeSession | undefined;
961
+ listSessions(): RuntimeSession[];
962
+ runTurn(input: RuntimeTurnInput): Promise<RuntimeTurnResult>;
963
+ streamTurn(input: RuntimeTurnInput): AsyncIterable<RuntimeTurnStreamEvent>;
964
+ executeTool(input: RuntimeToolExecutionInput): Promise<RuntimeToolExecutionResult>;
965
+ assertToolAllowed(mode: RuntimeMode, toolName: string, input?: Record<string, unknown>): boolean;
966
+ }
967
+ declare function createAgentRuntime(options: AgentRuntimeOptions): Promise<AgentRuntime>;
968
+
969
+ export { type AgentTask as $, AGENT_MODES as A, type AgentMessageRole as B, type ChatOptions as C, type AgentModeDefinition as D, type AgentModeId as E, type AgentRole as F, type AgentRunResult as G, type AgentRunStatus as H, AgentRuntime as I, type AgentRuntimeOptions as J, type AgentRuntimeSnapshot as K, type LLMProvider as L, type Message as M, type AgentToolPolicyDecision as N, type AgentTraceContext as O, type ProviderConfig as P, DEFAULT_WORKFLOWS as Q, type EventLog as R, type StreamChunk as S, FileSharedWorkspaceStore as T, InMemorySharedWorkspaceStore as U, type LegacyAgentRoleMapping as V, type PermissionDecision as W, type PermissionPolicy as X, ProviderRegistry as Y, type ProviderRuntimeSelection as Z, type ReasoningEffort as _, type ChatResponse as a, type RuntimeEvent as a0, type RuntimeEventType as a1, type RuntimeMode as a2, type RuntimeSession as a3, type RuntimeSessionCreateOptions as a4, type RuntimeSessionStore as a5, type RuntimeToolExecutionInput as a6, type RuntimeToolExecutionResult as a7, type RuntimeTurnContext as a8, type RuntimeTurnInput as a9, createAgentArtifact as aA, createAgentGraphEngine as aB, createAgentRuntime as aC, createAgentTraceContext as aD, createProvider as aE, createProviderRegistry as aF, createSummaryArtifact as aG, createWorkflowCatalog as aH, createWorkflowEngine as aI, createWorkflowRegistry as aJ, evaluateAgentToolPolicy as aK, getAgentMode as aL, isAgentMode as aM, listAgentModes as aN, listLegacyAgentRoleMappings as aO, mapLegacyAgentRole as aP, normalizeAgentRunResult as aQ, validateAgentCapabilities as aR, validateAgentGraph as aS, workflowToAgentGraph as aT, type ProviderType as aU, type RuntimeTurnResult as aa, type RuntimeTurnRunner as ab, type RuntimeTurnStreamEvent as ac, type SharedWorkspaceProvenance as ad, type SharedWorkspaceRecord as ae, type SharedWorkspaceRecordKind as af, SharedWorkspaceState as ag, type SharedWorkspaceStateSnapshot as ah, type SharedWorkspaceStore as ai, type SharedWorkspaceWriteInput as aj, type ToolRiskLevel as ak, type ToolRiskManifest as al, type ToolRiskManifestEntry as am, WorkflowCatalog as an, type WorkflowDefinition as ao, WorkflowEngine as ap, type WorkflowHandler as aq, type WorkflowPlan as ar, WorkflowRegistry as as, type WorkflowRetryPolicy as at, type WorkflowRisk as au, type WorkflowRunContext as av, type WorkflowRunInput as aw, type WorkflowRunResult as ax, type WorkflowRunStatus as ay, type WorkflowStepDefinition as az, type ChatWithToolsOptions as b, type ChatWithToolsResponse as c, type AgentArtifact as d, type AgentArtifactKind as e, type AgentBudget as f, type AgentCapability as g, type AgentCard as h, type AgentDefinition as i, type AgentGateDefinition as j, type AgentGateKind as k, type AgentGraphDefinition as l, type AgentGraphEdge as m, AgentGraphEngine as n, type AgentGraphEngineOptions as o, type AgentGraphNode as p, type AgentGraphNodeExecution as q, type AgentGraphNodeExecutor as r, type AgentGraphRunInput as s, type AgentGraphRunResult as t, type AgentGraphRunStatus as u, type AgentGraphValidationIssue as v, type AgentGraphValidationResult as w, type AgentGuardrailPolicy as x, type AgentHandoff as y, type AgentMessage as z };