@corbat-tech/coco 2.39.0 → 2.41.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,4 +1,4 @@
1
- import { T as ToolRegistry, a as ToolDefinition$1 } from './registry-CEpl9Jq0.js';
1
+ import { z } from 'zod';
2
2
 
3
3
  /**
4
4
  * Unified thinking/reasoning mode support for all LLM providers.
@@ -87,7 +87,7 @@ interface Message {
87
87
  /**
88
88
  * Tool definition for LLM
89
89
  */
90
- interface ToolDefinition {
90
+ interface ToolDefinition$1 {
91
91
  name: string;
92
92
  description: string;
93
93
  input_schema: {
@@ -138,7 +138,7 @@ interface ChatResponse {
138
138
  * Chat with tools options
139
139
  */
140
140
  interface ChatWithToolsOptions extends ChatOptions {
141
- tools: ToolDefinition[];
141
+ tools: ToolDefinition$1[];
142
142
  toolChoice?: "auto" | "any" | {
143
143
  type: "tool";
144
144
  name: string;
@@ -302,19 +302,117 @@ type ProviderType = "anthropic" | "openai" | "codex" | "copilot" | "gemini" | "v
302
302
  */
303
303
  declare function createProvider(type: ProviderType, config?: ProviderConfig): Promise<LLMProvider>;
304
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;
305
+ /**
306
+ * Tool Registry for Corbat-Coco
307
+ * Central management of all available tools
308
+ */
309
+
310
+ /**
311
+ * Tool definition
312
+ */
313
+ interface ToolDefinition<TInput = unknown, TOutput = unknown> {
314
+ name: string;
315
+ description: string;
316
+ category: ToolCategory;
317
+ parameters: z.ZodType<TInput, any, any>;
318
+ execute: (params: TInput) => Promise<TOutput>;
319
+ }
320
+ /**
321
+ * Tool categories
322
+ */
323
+ type ToolCategory = "file" | "bash" | "git" | "test" | "quality" | "build" | "deploy" | "config" | "web" | "search" | "memory" | "document";
324
+ /**
325
+ * Tool execution result
326
+ */
327
+ interface ToolResult<T = unknown> {
328
+ success: boolean;
329
+ data?: T;
330
+ error?: string;
331
+ duration: number;
332
+ }
333
+ /**
334
+ * Progress callback for long-running operations
335
+ */
336
+ type ProgressCallback = (progress: ProgressInfo) => void;
337
+ /**
338
+ * Progress information
339
+ */
340
+ interface ProgressInfo {
341
+ /** Current step or phase name */
342
+ phase: string;
343
+ /** Progress percentage (0-100), null if indeterminate */
344
+ percent: number | null;
345
+ /** Human-readable message */
346
+ message?: string;
347
+ /** Estimated time remaining in ms, null if unknown */
348
+ estimatedTimeRemaining?: number | null;
349
+ /** Additional metadata */
350
+ metadata?: Record<string, unknown>;
351
+ }
352
+ /**
353
+ * Options for tool execution
354
+ */
355
+ interface ExecuteOptions {
356
+ /** Progress callback for long operations */
357
+ onProgress?: ProgressCallback;
358
+ /** Abort signal for cancellation */
359
+ signal?: AbortSignal;
360
+ }
361
+ /**
362
+ * Tool registry
363
+ */
364
+ declare class ToolRegistry {
365
+ private tools;
366
+ private logger;
367
+ /**
368
+ * Register a tool
369
+ */
370
+ register<TInput, TOutput>(tool: ToolDefinition<TInput, TOutput>): void;
371
+ /**
372
+ * Unregister a tool
373
+ */
374
+ unregister(name: string): boolean;
375
+ /**
376
+ * Get a tool by name
377
+ */
378
+ get<TInput = unknown, TOutput = unknown>(name: string): ToolDefinition<TInput, TOutput> | undefined;
379
+ /**
380
+ * Check if a tool exists
381
+ */
382
+ has(name: string): boolean;
383
+ /**
384
+ * Get all tools
385
+ */
386
+ getAll(): ToolDefinition[];
387
+ /**
388
+ * Get tools by category
389
+ */
390
+ getByCategory(category: ToolCategory): ToolDefinition[];
391
+ /**
392
+ * Execute a tool
393
+ */
394
+ execute<TInput, TOutput>(name: string, params: TInput, options?: ExecuteOptions): Promise<ToolResult<TOutput>>;
395
+ /**
396
+ * Get tool definitions for LLM (simplified format)
397
+ */
398
+ getToolDefinitionsForLLM(): Array<{
399
+ name: string;
400
+ description: string;
401
+ input_schema: Record<string, unknown>;
402
+ }>;
403
+ }
404
+ /**
405
+ * Get the global tool registry
406
+ */
407
+ declare function getToolRegistry(): ToolRegistry;
408
+ /**
409
+ * Create a new tool registry
410
+ */
411
+ declare function createToolRegistry(): ToolRegistry;
412
+ /**
413
+ * Helper to create a tool definition with type safety
414
+ */
415
+ declare function defineTool<TInput, TOutput>(definition: ToolDefinition<TInput, TOutput>): ToolDefinition<TInput, TOutput>;
318
416
 
319
417
  /**
320
418
  * Agent mode registry.
@@ -336,204 +434,6 @@ declare function getAgentMode(mode: AgentModeId): AgentModeDefinition;
336
434
  declare function listAgentModes(): AgentModeDefinition[];
337
435
  declare function isAgentMode(value: string): value is AgentModeId;
338
436
 
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
437
  type AgentRole = "researcher" | "planner" | "architect" | "editor" | "coder" | "tester" | "reviewer" | "optimizer" | "security" | "qa" | "integrator" | "pm" | "docs" | "database";
538
438
  interface AgentBudget {
539
439
  maxTurns?: number;
@@ -666,6 +566,7 @@ interface AgentGraphNode {
666
566
  maxAttempts: number;
667
567
  backoffMs?: number;
668
568
  };
569
+ timeoutMs?: number;
669
570
  condition?: string;
670
571
  }
671
572
  interface AgentGraphEdge {
@@ -717,6 +618,7 @@ interface SharedWorkspaceRecord {
717
618
  createdAt: string;
718
619
  }
719
620
  interface SharedWorkspaceWriteInput {
621
+ id?: string;
720
622
  kind: SharedWorkspaceRecordKind;
721
623
  key: string;
722
624
  value: unknown;
@@ -832,6 +734,7 @@ interface AgentGraphEngineOptions {
832
734
  nodeExecutor?: AgentGraphNodeExecutor;
833
735
  gateEvaluator?: AgentGateEvaluator;
834
736
  trace?: AgentTraceContext;
737
+ allowSimulated?: boolean;
835
738
  }
836
739
  interface AgentGraphRunInput {
837
740
  workflowRunId: string;
@@ -888,6 +791,67 @@ declare function normalizeAgentRunResult(input: {
888
791
  }): AgentRunResult;
889
792
  declare function validateAgentCapabilities(capability: AgentCapability, requiredTools?: string[]): AgentGraphValidationIssue[];
890
793
  declare function validateAgentGraph(graph: AgentGraphDefinition): AgentGraphValidationResult;
794
+ declare function dryRunAgentGraphNodeExecutor(execution: AgentGraphNodeExecution): Promise<AgentRunResult>;
795
+
796
+ interface AgentRunnerExecutionInput {
797
+ task: AgentTask;
798
+ capability: AgentCapability;
799
+ trace?: AgentTraceContext;
800
+ toolRiskManifest?: ToolRiskManifest;
801
+ }
802
+ interface AgentRunnerExecutionContext {
803
+ task: AgentTask;
804
+ capability: AgentCapability;
805
+ trace: AgentTraceContext;
806
+ assertToolAllowed(toolName: string): void;
807
+ }
808
+ type AgentRunnerExecutor = (context: AgentRunnerExecutionContext) => Promise<AgentRunnerRawResult>;
809
+ interface AgentRunnerRawResult {
810
+ output: string;
811
+ success?: boolean;
812
+ turns?: number;
813
+ toolsUsed?: string[];
814
+ inputTokens?: number;
815
+ outputTokens?: number;
816
+ error?: string;
817
+ metadata?: Record<string, unknown>;
818
+ }
819
+ interface AgentRunnerOptions {
820
+ eventLog?: EventLog;
821
+ executor?: AgentRunnerExecutor;
822
+ }
823
+ declare class AgentRunner {
824
+ private readonly options;
825
+ constructor(options?: AgentRunnerOptions);
826
+ run(input: AgentRunnerExecutionInput): Promise<AgentRunResult>;
827
+ }
828
+ declare function createAgentRunner(options?: AgentRunnerOptions): AgentRunner;
829
+
830
+ declare class AgentDefinitionRegistry {
831
+ private readonly definitionsByRole;
832
+ private readonly definitionsById;
833
+ constructor(definitions?: AgentDefinition[]);
834
+ register(definition: AgentDefinition): void;
835
+ get(id: string): AgentDefinition | undefined;
836
+ getByRole(role: AgentRole): AgentDefinition | undefined;
837
+ list(): AgentDefinition[];
838
+ }
839
+ interface RuntimeAgentNodeExecutorOptions {
840
+ registry: AgentDefinitionRegistry;
841
+ runner?: AgentRunner;
842
+ runnerOptions?: AgentRunnerOptions;
843
+ runtimePolicy?: RuntimePolicy;
844
+ toolRiskManifest?: ToolRiskManifest;
845
+ }
846
+ declare class RuntimeAgentNodeExecutor {
847
+ private readonly options;
848
+ private readonly runner;
849
+ constructor(options: RuntimeAgentNodeExecutorOptions);
850
+ execute: AgentGraphNodeExecutor;
851
+ private findBlockedTool;
852
+ }
853
+ declare function createAgentDefinitionRegistry(definitions?: AgentDefinition[]): AgentDefinitionRegistry;
854
+ declare function createRuntimeAgentNodeExecutor(options: RuntimeAgentNodeExecutorOptions): AgentGraphNodeExecutor;
891
855
 
892
856
  type WorkflowRunStatus = "completed" | "failed";
893
857
  interface WorkflowRunInput {
@@ -917,12 +881,20 @@ interface WorkflowEngineOptions {
917
881
  eventLog?: EventLog;
918
882
  sharedState?: SharedWorkspaceStore;
919
883
  nodeExecutor?: AgentGraphNodeExecutor;
884
+ agentDefinitionRegistry?: AgentDefinitionRegistry;
885
+ agentNodeExecutorOptions?: Omit<RuntimeAgentNodeExecutorOptions, "registry" | "runtimePolicy">;
886
+ runtimePolicy?: RuntimePolicy;
887
+ runtimeContext?: RuntimeRequestContext;
888
+ runtimeHostMode?: RuntimeHostMode;
920
889
  }
921
890
  declare class WorkflowEngine {
922
891
  private readonly catalog;
923
892
  private readonly eventLog;
924
893
  private handlers;
925
894
  private readonly sharedState;
895
+ private readonly runtimePolicy?;
896
+ private readonly runtimeContext?;
897
+ private readonly runtimeHostMode;
926
898
  private nodeExecutor?;
927
899
  constructor(catalog?: WorkflowCatalog, eventLog?: EventLog, options?: Omit<WorkflowEngineOptions, "catalog" | "eventLog">);
928
900
  registerHandler(workflowId: string, handler: WorkflowHandler): void;
@@ -932,38 +904,318 @@ declare class WorkflowEngine {
932
904
  }
933
905
  declare function createWorkflowEngine(catalog?: WorkflowCatalog, eventLog?: EventLog, options?: Omit<WorkflowEngineOptions, "catalog" | "eventLog">): WorkflowEngine;
934
906
 
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>;
907
+ type ReasoningEffort = "auto" | "low" | "medium" | "high" | "max";
908
+ type RuntimeMode = AgentModeId;
909
+ interface AgentRuntimeOptions {
910
+ providerType: ProviderType;
911
+ model?: string;
912
+ providerConfig?: ProviderConfig;
913
+ provider?: LLMProvider;
914
+ toolRegistry?: ToolRegistry;
915
+ /** Legacy CLI session store passthrough. Runtime APIs use runtimeSessionStore. */
916
+ sessionStore?: unknown;
917
+ runtimeSessionStore?: RuntimeSessionStore;
918
+ workflowEngine?: WorkflowEngine;
919
+ permissionPolicy?: PermissionPolicy;
920
+ eventLog?: EventLog;
921
+ eventLogPath?: string;
922
+ turnRunner?: RuntimeTurnRunner;
923
+ /**
924
+ * Publish provider/tools into Coco's legacy process-global subagent bridge.
925
+ * CLI/headless use this for compatibility; embedders should leave it false.
926
+ */
927
+ publishToGlobalBridge?: boolean;
928
+ legacyAgentBridge?: {
929
+ setAgentProvider(provider: LLMProvider): void;
930
+ setAgentToolRegistry(registry: ToolRegistry): void;
931
+ };
932
+ runtimeContext?: RuntimeRequestContext;
933
+ runtimePolicy?: RuntimePolicy;
934
+ runtimeHostMode?: RuntimeHostMode;
935
+ agentDefinitionRegistry?: AgentDefinitionRegistry;
936
+ }
937
+ interface AgentRuntimeSnapshot {
938
+ provider: {
939
+ type: ProviderType;
940
+ model: string;
941
+ capability: ProviderRuntimeCapability;
942
+ };
943
+ tools: {
944
+ count: number;
945
+ names: string[];
946
+ };
947
+ modes: AgentModeDefinition[];
948
+ context?: RuntimeRequestContext;
949
+ policy?: RuntimePolicy;
950
+ hostMode: RuntimeHostMode;
951
+ }
952
+ type RuntimeEventType = "runtime.initialized" | "provider.attached" | "provider.created" | "provider.updated" | "retention.cleanup" | "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";
953
+ interface RuntimeEvent {
954
+ id: string;
955
+ type: RuntimeEventType;
956
+ timestamp: string;
957
+ data: Record<string, unknown>;
958
+ }
959
+ interface EventLog {
960
+ record(type: RuntimeEventType, data?: Record<string, unknown>): RuntimeEvent;
961
+ list(): RuntimeEvent[];
962
+ count(): number;
963
+ clear(): void;
964
+ }
965
+ interface AsyncEventLog {
966
+ record(type: RuntimeEventType, data?: Record<string, unknown>): Promise<RuntimeEvent>;
967
+ list(): Promise<RuntimeEvent[]>;
968
+ count(): Promise<number>;
969
+ clear(): Promise<void>;
970
+ }
971
+ interface PermissionDecision {
972
+ allowed: boolean;
973
+ reason?: string;
974
+ requiresConfirmation?: boolean;
975
+ risk: "read-only" | "write" | "network" | "destructive" | "secrets-sensitive";
976
+ }
977
+ interface PermissionPolicy {
978
+ canExecuteTool(mode: RuntimeMode, tool: ToolDefinition): PermissionDecision;
979
+ canExecuteToolInput?(mode: RuntimeMode, tool: ToolDefinition, input: Record<string, unknown>): PermissionDecision;
980
+ }
981
+ interface ProviderRuntimeSelection {
982
+ provider: ProviderType;
983
+ model: string;
984
+ thinking?: ThinkingMode;
985
+ }
986
+ interface RuntimeSession {
987
+ id: string;
988
+ createdAt: string;
989
+ updatedAt: string;
990
+ mode: RuntimeMode;
991
+ messages: Message[];
992
+ instructions?: string;
993
+ metadata: Record<string, unknown>;
994
+ }
995
+ interface RuntimeSessionCreateOptions {
996
+ id?: string;
997
+ mode?: RuntimeMode;
998
+ instructions?: string;
999
+ metadata?: Record<string, unknown>;
1000
+ messages?: Message[];
1001
+ }
1002
+ interface RuntimeSessionStore {
1003
+ create(options?: RuntimeSessionCreateOptions): RuntimeSession;
1004
+ get(id: string): RuntimeSession | undefined;
1005
+ update(session: RuntimeSession): RuntimeSession;
1006
+ list(): RuntimeSession[];
1007
+ delete(id: string): boolean;
1008
+ }
1009
+ interface AsyncRuntimeSessionStore {
1010
+ create(options?: RuntimeSessionCreateOptions): Promise<RuntimeSession>;
1011
+ get(id: string): Promise<RuntimeSession | undefined>;
1012
+ update(session: RuntimeSession): Promise<RuntimeSession>;
1013
+ list(): Promise<RuntimeSession[]>;
1014
+ delete(id: string): Promise<boolean>;
1015
+ }
1016
+ interface RuntimeTurnInput {
1017
+ content: string;
1018
+ sessionId?: string;
1019
+ mode?: RuntimeMode;
1020
+ options?: ChatOptions;
1021
+ metadata?: Record<string, unknown>;
1022
+ /**
1023
+ * Tool names that the embedding product has explicitly confirmed for this
1024
+ * turn. Destructive tools are still blocked unless listed here.
1025
+ */
1026
+ confirmedTools?: string[];
1027
+ }
1028
+ interface RuntimeTurnResult {
1029
+ sessionId: string;
1030
+ content: string;
1031
+ usage: {
1032
+ inputTokens: number;
1033
+ outputTokens: number;
1034
+ estimated?: boolean;
1035
+ };
1036
+ model: string;
1037
+ mode: RuntimeMode;
1038
+ }
1039
+ type RuntimeTurnStreamEvent = {
1040
+ type: "text";
1041
+ sessionId: string;
1042
+ text: string;
1043
+ } | {
1044
+ type: "done";
1045
+ sessionId: string;
1046
+ result: RuntimeTurnResult;
1047
+ } | {
1048
+ type: "error";
1049
+ sessionId: string;
1050
+ error: string;
1051
+ };
1052
+ interface RuntimeTurnContext {
1053
+ runtime: unknown;
1054
+ session: RuntimeSession;
1055
+ provider: LLMProvider;
1056
+ toolRegistry: ToolRegistry;
1057
+ permissionPolicy: PermissionPolicy;
1058
+ eventLog: EventLog;
1059
+ }
1060
+ interface RuntimeTurnRunner {
1061
+ run(input: RuntimeTurnInput, context: RuntimeTurnContext): Promise<RuntimeTurnResult>;
1062
+ }
1063
+ interface RuntimeToolExecutionInput {
1064
+ sessionId?: string;
1065
+ mode?: RuntimeMode;
1066
+ toolName: string;
1067
+ input: Record<string, unknown>;
1068
+ confirmed?: boolean;
1069
+ metadata?: Record<string, unknown>;
1070
+ }
1071
+ interface RuntimeToolExecutionResult {
1072
+ toolName: string;
1073
+ success: boolean;
1074
+ output?: unknown;
1075
+ error?: string;
1076
+ duration: number;
1077
+ decision: PermissionDecision;
1078
+ }
1079
+
1080
+ type WorkflowRisk = "read-only" | "write" | "network" | "destructive" | "secrets-sensitive";
1081
+ interface WorkflowStepDefinition {
1082
+ id: string;
1083
+ description: string;
1084
+ requiredTools: string[];
1085
+ risk: WorkflowRisk;
1086
+ }
1087
+ interface WorkflowRetryPolicy {
1088
+ maxAttempts: number;
1089
+ backoffMs?: number;
1090
+ }
1091
+ interface WorkflowDefinition {
1092
+ id: string;
1093
+ name: string;
1094
+ description: string;
1095
+ inputSchema: string;
1096
+ /** Legacy linear workflow steps. Prefer nodes for new multi-agent workflows. */
1097
+ steps: WorkflowStepDefinition[];
1098
+ nodes?: AgentGraphNode[];
1099
+ edges?: AgentGraphDefinition["edges"];
1100
+ gates?: AgentGateDefinition[];
1101
+ retryPolicy?: WorkflowRetryPolicy;
1102
+ parallelism?: number;
1103
+ checks: string[];
1104
+ outputKind: "markdown" | "json" | "patch" | "pull-request" | "release";
1105
+ replayable: boolean;
1106
+ }
1107
+ interface WorkflowPlan {
1108
+ id: string;
1109
+ workflowId: string;
1110
+ input: Record<string, unknown>;
1111
+ status: "planned";
1112
+ createdAt: string;
1113
+ }
1114
+ declare function workflowToAgentGraph(workflow: WorkflowDefinition): AgentGraphDefinition;
1115
+ /** Descriptive catalog of reusable workflow definitions; it does not execute workflows. */
1116
+ declare class WorkflowCatalog {
1117
+ private workflows;
1118
+ constructor(workflows?: WorkflowDefinition[]);
1119
+ register(workflow: WorkflowDefinition): void;
1120
+ get(id: string): WorkflowDefinition | undefined;
1121
+ list(): WorkflowDefinition[];
1122
+ createPlan(workflowId: string, input: Record<string, unknown>, eventLog?: EventLog): WorkflowPlan;
1123
+ }
1124
+ declare const DEFAULT_WORKFLOWS: WorkflowDefinition[];
1125
+ declare const WorkflowRegistry: typeof WorkflowCatalog;
1126
+ declare function createWorkflowCatalog(workflows?: WorkflowDefinition[]): WorkflowCatalog;
1127
+ declare function createWorkflowRegistry(workflows?: WorkflowDefinition[]): WorkflowCatalog;
1128
+
1129
+ type RuntimeSurface = "cli" | "api" | "web" | "whatsapp" | "slack" | "teams" | "internal" | "mcp" | "worker";
1130
+ interface TenantContext {
1131
+ id: string;
1132
+ name?: string;
1133
+ environment?: "development" | "staging" | "production";
1134
+ metadata?: Record<string, unknown>;
1135
+ }
1136
+ interface UserContext {
1137
+ id?: string;
1138
+ displayName?: string;
1139
+ roles?: string[];
1140
+ groups?: string[];
1141
+ metadata?: Record<string, unknown>;
1142
+ }
1143
+ interface DataBoundary {
1144
+ region?: string;
1145
+ classification?: "public" | "internal" | "confidential" | "restricted";
1146
+ allowCrossTenantMemory?: boolean;
1147
+ redactSensitiveData?: boolean;
1148
+ }
1149
+ interface CostBudget {
1150
+ maxInputTokens?: number;
1151
+ maxOutputTokens?: number;
1152
+ maxEstimatedCostUsd?: number;
1153
+ maxTurns?: number;
1154
+ }
1155
+ interface RetentionPolicy {
1156
+ conversationDays?: number;
1157
+ eventDays?: number;
1158
+ artifactDays?: number;
1159
+ }
1160
+ interface RuntimePolicy {
1161
+ allowedTools?: string[];
1162
+ maxToolRisk?: WorkflowRisk;
1163
+ requireHumanApprovalFor?: WorkflowRisk[];
1164
+ dataBoundary?: DataBoundary;
1165
+ costBudget?: CostBudget;
1166
+ retention?: RetentionPolicy;
1167
+ rateLimit?: {
1168
+ maxRequestsPerMinute?: number;
1169
+ maxConcurrentRuns?: number;
1170
+ };
1171
+ }
1172
+ type RuntimeHostMode = "local" | "embedded" | "hosted";
1173
+ interface RuntimeRequestContext {
1174
+ tenant?: TenantContext;
1175
+ user?: UserContext;
1176
+ surface: RuntimeSurface;
1177
+ channel?: string;
1178
+ correlationId?: string;
1179
+ policy?: RuntimePolicy;
1180
+ metadata?: Record<string, unknown>;
1181
+ }
1182
+ type RuntimePolicyViolationCode = "tenant_required" | "tool_not_allowed" | "risk_exceeded" | "approval_required" | "input_tokens_exceeded" | "output_tokens_exceeded" | "estimated_cost_exceeded" | "max_turns_exceeded" | "rate_limit_exceeded" | "concurrency_limit_exceeded";
1183
+ interface RuntimePolicyViolationInput {
1184
+ code: RuntimePolicyViolationCode;
1185
+ subject: string;
1186
+ tenantId?: string;
1187
+ policyPath: string;
1188
+ severity?: "warning" | "blocked";
1189
+ message: string;
1190
+ }
1191
+ declare class RuntimePolicyViolation extends Error {
1192
+ readonly code: RuntimePolicyViolationCode;
1193
+ readonly subject: string;
1194
+ readonly tenantId?: string;
1195
+ readonly policyPath: string;
1196
+ readonly severity: "warning" | "blocked";
1197
+ constructor(input: RuntimePolicyViolationInput);
1198
+ }
1199
+ interface RuntimeTenantBoundary {
1200
+ hostMode: RuntimeHostMode;
1201
+ surface: RuntimeSurface;
1202
+ tenantId?: string;
1203
+ required: boolean;
1204
+ }
1205
+ declare function createRuntimeRequestContext(input?: Partial<RuntimeRequestContext>): RuntimeRequestContext;
1206
+ declare function mergeRuntimePolicy(base: RuntimePolicy | undefined, override: RuntimePolicy | undefined): RuntimePolicy | undefined;
1207
+ declare function runtimeContextToMetadata(context: RuntimeRequestContext | undefined): Record<string, unknown>;
1208
+ declare function createRuntimeTenantBoundary(context: RuntimeRequestContext | undefined, hostMode?: RuntimeHostMode): RuntimeTenantBoundary;
1209
+ declare function assertRuntimeTenantBoundary(context: RuntimeRequestContext | undefined, hostMode?: RuntimeHostMode, subject?: string): RuntimeTenantBoundary;
1210
+ declare function assertRuntimeTurnWithinPolicy(policy: RuntimePolicy | undefined, input: {
1211
+ subject: string;
1212
+ currentTurns: number;
1213
+ tenantId?: string;
1214
+ }): void;
1215
+ declare function createRetentionCutoffs(policy: RuntimePolicy | undefined, now?: Date): {
1216
+ conversationBefore?: string;
1217
+ eventBefore?: string;
1218
+ artifactBefore?: string;
1219
+ };
968
1220
 
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 };
1221
+ export { type AgentGraphValidationIssue as $, type AgentRuntimeOptions as A, type AgentCapability as B, type ChatOptions as C, type DataBoundary as D, type EventLog as E, type AgentCard as F, type AgentDefinition as G, AgentDefinitionRegistry as H, type AgentGateDefinition as I, type AgentGateKind as J, type AgentGraphDefinition as K, type LLMProvider as L, type ModelCatalogEntry as M, type AgentGraphEdge as N, AgentGraphEngine as O, type ProviderType as P, type AgentGraphEngineOptions as Q, type RuntimeRequestContext as R, type StreamChunk as S, ToolRegistry as T, type AgentGraphNode as U, type AgentGraphNodeExecution as V, WorkflowEngine as W, type AgentGraphNodeExecutor as X, type AgentGraphRunInput as Y, type AgentGraphRunResult as Z, type AgentGraphRunStatus as _, type RuntimeTurnStreamEvent as a, type WorkflowStepDefinition as a$, type AgentGraphValidationResult as a0, type AgentGuardrailPolicy as a1, type AgentHandoff as a2, type AgentMessage as a3, type AgentMessageRole as a4, type AgentModeDefinition as a5, type AgentModeId as a6, type AgentRole as a7, type AgentRunResult as a8, type AgentRunStatus as a9, type RuntimePolicyViolationCode as aA, type RuntimeSurface as aB, type RuntimeTenantBoundary as aC, type RuntimeTurnContext as aD, type SharedWorkspaceProvenance as aE, type SharedWorkspaceRecord as aF, type SharedWorkspaceRecordKind as aG, SharedWorkspaceState as aH, type SharedWorkspaceStateSnapshot as aI, type SharedWorkspaceStore as aJ, type SharedWorkspaceWriteInput as aK, type TenantContext as aL, type ToolRiskLevel as aM, type ToolRiskManifest as aN, type ToolRiskManifestEntry as aO, type UserContext as aP, WorkflowCatalog as aQ, type WorkflowDefinition as aR, type WorkflowHandler as aS, type WorkflowPlan as aT, WorkflowRegistry as aU, type WorkflowRetryPolicy as aV, type WorkflowRisk as aW, type WorkflowRunContext as aX, type WorkflowRunInput as aY, type WorkflowRunResult as aZ, type WorkflowRunStatus as a_, AgentRunner as aa, type AgentRunnerExecutionContext as ab, type AgentRunnerExecutionInput as ac, type AgentRunnerExecutor as ad, type AgentRunnerOptions as ae, type AgentRunnerRawResult as af, type AgentToolPolicyDecision as ag, type AgentTraceContext as ah, type AsyncEventLog as ai, type AsyncRuntimeSessionStore as aj, type CostBudget as ak, DEFAULT_WORKFLOWS as al, FileSharedWorkspaceStore as am, InMemorySharedWorkspaceStore as an, type LegacyAgentRoleMapping as ao, type PermissionDecision as ap, type ProviderRuntimeSelection as aq, type ReasoningEffort as ar, type RetentionPolicy as as, RuntimeAgentNodeExecutor as at, type RuntimeAgentNodeExecutorOptions as au, type AgentTask as av, type RuntimeEvent as aw, type RuntimeEventType as ax, type RuntimeHostMode as ay, RuntimePolicyViolation as az, type ProviderConfig as b, assertRuntimeTenantBoundary as b0, assertRuntimeTurnWithinPolicy as b1, createAgentArtifact as b2, createAgentDefinitionRegistry as b3, createAgentGraphEngine as b4, createAgentRunner as b5, createAgentTraceContext as b6, createProvider as b7, createRuntimeAgentNodeExecutor as b8, createRuntimeRequestContext as b9, createRuntimeTenantBoundary as ba, createSummaryArtifact as bb, createToolRegistry as bc, createWorkflowCatalog as bd, createWorkflowEngine as be, createWorkflowRegistry as bf, dryRunAgentGraphNodeExecutor as bg, evaluateAgentToolPolicy as bh, getAgentMode as bi, isAgentMode as bj, listAgentModes as bk, listLegacyAgentRoleMappings as bl, mapLegacyAgentRole as bm, mergeRuntimePolicy as bn, normalizeAgentRunResult as bo, runtimeContextToMetadata as bp, validateAgentCapabilities as bq, validateAgentGraph as br, workflowToAgentGraph as bs, type ToolDefinition as bt, type ToolCategory as bu, type ToolResult as bv, defineTool as bw, getToolRegistry as bx, type RuntimeTurnRunner as c, type RuntimePolicy as d, type RuntimeSession as e, type RuntimeTurnInput as f, type RuntimeTurnResult as g, type ProviderCatalogEntry as h, type ProviderRuntimeCapability as i, type ProviderProbeResult as j, type RuntimeSessionStore as k, type PermissionPolicy as l, type AgentRuntimeSnapshot as m, type RuntimeSessionCreateOptions as n, createRetentionCutoffs as o, type RuntimeToolExecutionInput as p, type RuntimeToolExecutionResult as q, type RuntimeMode as r, type Message as s, type ChatResponse as t, type ChatWithToolsOptions as u, type ChatWithToolsResponse as v, AGENT_MODES as w, type AgentArtifact as x, type AgentArtifactKind as y, type AgentBudget as z };