@corbat-tech/coco 2.37.0 → 2.38.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,756 @@
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.tool.called" | "agent.artifact.created" | "agent.completed" | "agent.failed" | "guardrail.input" | "guardrail.output" | "guardrail.tool" | "workflow.planned" | "workflow.started" | "workflow.completed" | "workflow.failed" | "workflow.gate.failed" | "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 AgentRole = "researcher" | "planner" | "architect" | "editor" | "coder" | "tester" | "reviewer" | "optimizer" | "security" | "qa" | "integrator" | "pm" | "docs" | "database";
489
+ interface AgentBudget {
490
+ maxTurns?: number;
491
+ timeoutMs?: number;
492
+ maxInputTokens?: number;
493
+ maxOutputTokens?: number;
494
+ maxEstimatedCostUsd?: number;
495
+ }
496
+ interface AgentCapability {
497
+ role: AgentRole;
498
+ allowedTools: string[];
499
+ risk: WorkflowRisk;
500
+ model?: string;
501
+ temperature?: number;
502
+ budget?: AgentBudget;
503
+ }
504
+ interface AgentTask {
505
+ id: string;
506
+ role: AgentRole;
507
+ objective: string;
508
+ context?: Record<string, unknown>;
509
+ dependencies?: string[];
510
+ expectedOutput?: AgentArtifactKind[];
511
+ constraints?: string[];
512
+ }
513
+ type AgentArtifactKind = "plan" | "findings" | "patchProposal" | "testReport" | "riskReport" | "summary";
514
+ interface AgentArtifact<T = unknown> {
515
+ id: string;
516
+ kind: AgentArtifactKind;
517
+ agentRunId?: string;
518
+ taskId?: string;
519
+ title?: string;
520
+ content: T;
521
+ createdAt: string;
522
+ metadata?: Record<string, unknown>;
523
+ }
524
+ type AgentRunStatus = "completed" | "failed" | "cancelled" | "timeout";
525
+ interface AgentRunResult {
526
+ id: string;
527
+ taskId: string;
528
+ role: AgentRole;
529
+ status: AgentRunStatus;
530
+ success: boolean;
531
+ output: string;
532
+ artifacts: AgentArtifact[];
533
+ toolsUsed: string[];
534
+ turns: number;
535
+ durationMs: number;
536
+ usage?: {
537
+ inputTokens: number;
538
+ outputTokens: number;
539
+ estimated?: boolean;
540
+ };
541
+ error?: string;
542
+ startedAt: string;
543
+ completedAt: string;
544
+ metadata?: Record<string, unknown>;
545
+ }
546
+ type AgentGateKind = "tests" | "coverage" | "review" | "security" | "quality-score" | "human-approval";
547
+ interface AgentGateDefinition {
548
+ id: string;
549
+ kind: AgentGateKind;
550
+ description: string;
551
+ required: boolean;
552
+ threshold?: number;
553
+ }
554
+ interface AgentGraphNode {
555
+ id: string;
556
+ agentRole?: AgentRole;
557
+ description: string;
558
+ dependsOn?: string[];
559
+ requiredTools?: string[];
560
+ risk: WorkflowRisk;
561
+ gates?: string[];
562
+ retryPolicy?: {
563
+ maxAttempts: number;
564
+ backoffMs?: number;
565
+ };
566
+ condition?: string;
567
+ }
568
+ interface AgentGraphEdge {
569
+ from: string;
570
+ to: string;
571
+ condition?: string;
572
+ }
573
+ interface AgentGraphDefinition {
574
+ nodes: AgentGraphNode[];
575
+ edges?: AgentGraphEdge[];
576
+ gates?: AgentGateDefinition[];
577
+ parallelism?: number;
578
+ }
579
+ interface AgentGraphValidationIssue {
580
+ code: "duplicate-node" | "missing-dependency" | "missing-edge-node" | "missing-gate" | "cycle" | "invalid-parallelism" | "invalid-retry-policy";
581
+ message: string;
582
+ nodeId?: string;
583
+ gateId?: string;
584
+ }
585
+ interface AgentGraphValidationResult {
586
+ valid: boolean;
587
+ issues: AgentGraphValidationIssue[];
588
+ levels: string[][];
589
+ }
590
+ interface SharedWorkspaceStateSnapshot {
591
+ facts: Record<string, unknown>;
592
+ decisions: Record<string, unknown>;
593
+ risks: Record<string, unknown>;
594
+ files: Record<string, unknown>;
595
+ testResults: Record<string, unknown>;
596
+ artifacts: AgentArtifact[];
597
+ }
598
+ declare class SharedWorkspaceState {
599
+ private facts;
600
+ private decisions;
601
+ private risks;
602
+ private files;
603
+ private testResults;
604
+ private artifacts;
605
+ writeFact(key: string, value: unknown): void;
606
+ recordDecision(key: string, value: unknown): void;
607
+ recordRisk(key: string, value: unknown): void;
608
+ recordFile(path: string, value: unknown): void;
609
+ recordTestResult(key: string, value: unknown): void;
610
+ addArtifact(artifact: AgentArtifact): void;
611
+ readForRole(role: AgentRole): SharedWorkspaceStateSnapshot;
612
+ snapshot(): SharedWorkspaceStateSnapshot;
613
+ }
614
+ declare function createAgentArtifact<T>(input: Omit<AgentArtifact<T>, "id" | "createdAt"> & {
615
+ id?: string;
616
+ createdAt?: string;
617
+ }): AgentArtifact<T>;
618
+ declare function createSummaryArtifact(output: string, metadata?: Pick<AgentArtifact, "agentRunId" | "taskId"> & {
619
+ title?: string;
620
+ }): AgentArtifact<string>;
621
+ declare function normalizeAgentRunResult(input: {
622
+ id: string;
623
+ taskId: string;
624
+ role: AgentRole;
625
+ success: boolean;
626
+ output: string;
627
+ startedAt?: string;
628
+ completedAt?: string;
629
+ durationMs?: number;
630
+ turns?: number;
631
+ toolsUsed?: string[];
632
+ usage?: AgentRunResult["usage"];
633
+ error?: string;
634
+ artifacts?: AgentArtifact[];
635
+ status?: AgentRunStatus;
636
+ metadata?: Record<string, unknown>;
637
+ }): AgentRunResult;
638
+ declare function validateAgentCapabilities(capability: AgentCapability, requiredTools?: string[]): AgentGraphValidationIssue[];
639
+ declare function validateAgentGraph(graph: AgentGraphDefinition): AgentGraphValidationResult;
640
+
641
+ type WorkflowRisk = "read-only" | "write" | "network" | "destructive" | "secrets-sensitive";
642
+ interface WorkflowStepDefinition {
643
+ id: string;
644
+ description: string;
645
+ requiredTools: string[];
646
+ risk: WorkflowRisk;
647
+ }
648
+ interface WorkflowRetryPolicy {
649
+ maxAttempts: number;
650
+ backoffMs?: number;
651
+ }
652
+ interface WorkflowDefinition {
653
+ id: string;
654
+ name: string;
655
+ description: string;
656
+ inputSchema: string;
657
+ /** Legacy linear workflow steps. Prefer nodes for new multi-agent workflows. */
658
+ steps: WorkflowStepDefinition[];
659
+ nodes?: AgentGraphNode[];
660
+ edges?: AgentGraphDefinition["edges"];
661
+ gates?: AgentGateDefinition[];
662
+ retryPolicy?: WorkflowRetryPolicy;
663
+ parallelism?: number;
664
+ checks: string[];
665
+ outputKind: "markdown" | "json" | "patch" | "pull-request" | "release";
666
+ replayable: boolean;
667
+ }
668
+ interface WorkflowPlan {
669
+ id: string;
670
+ workflowId: string;
671
+ input: Record<string, unknown>;
672
+ status: "planned";
673
+ createdAt: string;
674
+ }
675
+ declare function workflowToAgentGraph(workflow: WorkflowDefinition): AgentGraphDefinition;
676
+ /** Descriptive catalog of reusable workflow definitions; it does not execute workflows. */
677
+ declare class WorkflowCatalog {
678
+ private workflows;
679
+ constructor(workflows?: WorkflowDefinition[]);
680
+ register(workflow: WorkflowDefinition): void;
681
+ get(id: string): WorkflowDefinition | undefined;
682
+ list(): WorkflowDefinition[];
683
+ createPlan(workflowId: string, input: Record<string, unknown>, eventLog?: EventLog): WorkflowPlan;
684
+ }
685
+ declare const DEFAULT_WORKFLOWS: WorkflowDefinition[];
686
+ declare const WorkflowRegistry: typeof WorkflowCatalog;
687
+ declare function createWorkflowCatalog(workflows?: WorkflowDefinition[]): WorkflowCatalog;
688
+ declare function createWorkflowRegistry(workflows?: WorkflowDefinition[]): WorkflowCatalog;
689
+
690
+ type WorkflowRunStatus = "completed" | "failed";
691
+ interface WorkflowRunInput {
692
+ workflowId: string;
693
+ input: Record<string, unknown>;
694
+ plan?: WorkflowPlan;
695
+ }
696
+ interface WorkflowRunResult {
697
+ id: string;
698
+ workflowId: string;
699
+ status: WorkflowRunStatus;
700
+ output: unknown;
701
+ startedAt: string;
702
+ completedAt: string;
703
+ error?: string;
704
+ }
705
+ interface WorkflowRunContext {
706
+ workflow: WorkflowDefinition;
707
+ plan: WorkflowPlan;
708
+ eventLog: EventLog;
709
+ }
710
+ type WorkflowHandler = (input: Record<string, unknown>, context: WorkflowRunContext) => Promise<unknown>;
711
+ declare class WorkflowEngine {
712
+ private readonly catalog;
713
+ private readonly eventLog;
714
+ private handlers;
715
+ constructor(catalog?: WorkflowCatalog, eventLog?: EventLog);
716
+ registerHandler(workflowId: string, handler: WorkflowHandler): void;
717
+ createPlan(workflowId: string, input: Record<string, unknown>): WorkflowPlan;
718
+ run(request: WorkflowRunInput): Promise<WorkflowRunResult>;
719
+ }
720
+ declare function createWorkflowEngine(catalog?: WorkflowCatalog, eventLog?: EventLog): WorkflowEngine;
721
+
722
+ /**
723
+ * Reusable runtime facade for wiring providers, tools, permissions, sessions,
724
+ * and observability. It does not own the CLI loop; CLI/headless are adapters on
725
+ * top of this boundary.
726
+ */
727
+ declare class AgentRuntime {
728
+ private readonly options;
729
+ readonly providerRegistry: ProviderRegistry;
730
+ readonly toolRegistry: ToolRegistry;
731
+ readonly sessionStore: unknown;
732
+ readonly runtimeSessionStore: RuntimeSessionStore;
733
+ readonly workflowEngine: WorkflowEngine;
734
+ readonly permissionPolicy: PermissionPolicy;
735
+ readonly eventLog: EventLog;
736
+ readonly turnRunner: RuntimeTurnRunner;
737
+ private providerType;
738
+ private model;
739
+ private provider?;
740
+ constructor(options: AgentRuntimeOptions);
741
+ initialize(): Promise<void>;
742
+ getModel(): string;
743
+ updateProvider(providerType: ProviderType, model: string | undefined, provider: LLMProvider): void;
744
+ private publishToGlobalBridge;
745
+ snapshot(): AgentRuntimeSnapshot;
746
+ createSession(options?: RuntimeSessionCreateOptions): RuntimeSession;
747
+ getSession(sessionId: string): RuntimeSession | undefined;
748
+ listSessions(): RuntimeSession[];
749
+ runTurn(input: RuntimeTurnInput): Promise<RuntimeTurnResult>;
750
+ streamTurn(input: RuntimeTurnInput): AsyncIterable<RuntimeTurnStreamEvent>;
751
+ executeTool(input: RuntimeToolExecutionInput): Promise<RuntimeToolExecutionResult>;
752
+ assertToolAllowed(mode: RuntimeMode, toolName: string, input?: Record<string, unknown>): boolean;
753
+ }
754
+ declare function createAgentRuntime(options: AgentRuntimeOptions): Promise<AgentRuntime>;
755
+
756
+ export { WorkflowEngine as $, AGENT_MODES as A, type AgentTask as B, type ChatOptions as C, DEFAULT_WORKFLOWS as D, type EventLog as E, type RuntimeEvent as F, type RuntimeEventType as G, type RuntimeMode as H, type RuntimeSession as I, type RuntimeSessionCreateOptions as J, type RuntimeSessionStore as K, type LLMProvider as L, type Message as M, type RuntimeToolExecutionInput as N, type RuntimeToolExecutionResult as O, type ProviderConfig as P, type RuntimeTurnContext as Q, type ReasoningEffort as R, type StreamChunk as S, type RuntimeTurnInput as T, type RuntimeTurnResult as U, type RuntimeTurnRunner as V, type RuntimeTurnStreamEvent as W, SharedWorkspaceState as X, type SharedWorkspaceStateSnapshot as Y, WorkflowCatalog as Z, type WorkflowDefinition as _, type ChatResponse as a, type WorkflowHandler as a0, type WorkflowPlan as a1, WorkflowRegistry as a2, type WorkflowRetryPolicy as a3, type WorkflowRisk as a4, type WorkflowRunContext as a5, type WorkflowRunInput as a6, type WorkflowRunResult as a7, type WorkflowRunStatus as a8, type WorkflowStepDefinition as a9, createAgentArtifact as aa, createAgentRuntime as ab, createProvider as ac, createProviderRegistry as ad, createSummaryArtifact as ae, createWorkflowCatalog as af, createWorkflowEngine as ag, createWorkflowRegistry as ah, getAgentMode as ai, isAgentMode as aj, listAgentModes as ak, normalizeAgentRunResult as al, validateAgentCapabilities as am, validateAgentGraph as an, workflowToAgentGraph as ao, type ProviderType as ap, 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 AgentGateDefinition as h, type AgentGateKind as i, type AgentGraphDefinition as j, type AgentGraphEdge as k, type AgentGraphNode as l, type AgentGraphValidationIssue as m, type AgentGraphValidationResult as n, type AgentModeDefinition as o, type AgentModeId as p, type AgentRole as q, type AgentRunResult as r, type AgentRunStatus as s, AgentRuntime as t, type AgentRuntimeOptions as u, type AgentRuntimeSnapshot as v, type PermissionDecision as w, type PermissionPolicy as x, ProviderRegistry as y, type ProviderRuntimeSelection as z };