@corbat-tech/coco 2.39.0 → 2.40.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,269 @@ 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
+ type WorkflowRisk = "read-only" | "write" | "network" | "destructive" | "secrets-sensitive";
797
+ interface WorkflowStepDefinition {
798
+ id: string;
799
+ description: string;
800
+ requiredTools: string[];
801
+ risk: WorkflowRisk;
802
+ }
803
+ interface WorkflowRetryPolicy {
804
+ maxAttempts: number;
805
+ backoffMs?: number;
806
+ }
807
+ interface WorkflowDefinition {
808
+ id: string;
809
+ name: string;
810
+ description: string;
811
+ inputSchema: string;
812
+ /** Legacy linear workflow steps. Prefer nodes for new multi-agent workflows. */
813
+ steps: WorkflowStepDefinition[];
814
+ nodes?: AgentGraphNode[];
815
+ edges?: AgentGraphDefinition["edges"];
816
+ gates?: AgentGateDefinition[];
817
+ retryPolicy?: WorkflowRetryPolicy;
818
+ parallelism?: number;
819
+ checks: string[];
820
+ outputKind: "markdown" | "json" | "patch" | "pull-request" | "release";
821
+ replayable: boolean;
822
+ }
823
+ interface WorkflowPlan {
824
+ id: string;
825
+ workflowId: string;
826
+ input: Record<string, unknown>;
827
+ status: "planned";
828
+ createdAt: string;
829
+ }
830
+ declare function workflowToAgentGraph(workflow: WorkflowDefinition): AgentGraphDefinition;
831
+ /** Descriptive catalog of reusable workflow definitions; it does not execute workflows. */
832
+ declare class WorkflowCatalog {
833
+ private workflows;
834
+ constructor(workflows?: WorkflowDefinition[]);
835
+ register(workflow: WorkflowDefinition): void;
836
+ get(id: string): WorkflowDefinition | undefined;
837
+ list(): WorkflowDefinition[];
838
+ createPlan(workflowId: string, input: Record<string, unknown>, eventLog?: EventLog): WorkflowPlan;
839
+ }
840
+ declare const DEFAULT_WORKFLOWS: WorkflowDefinition[];
841
+ declare const WorkflowRegistry: typeof WorkflowCatalog;
842
+ declare function createWorkflowCatalog(workflows?: WorkflowDefinition[]): WorkflowCatalog;
843
+ declare function createWorkflowRegistry(workflows?: WorkflowDefinition[]): WorkflowCatalog;
844
+
845
+ type RuntimeSurface = "cli" | "api" | "web" | "whatsapp" | "slack" | "teams" | "internal" | "mcp" | "worker";
846
+ interface TenantContext {
847
+ id: string;
848
+ name?: string;
849
+ environment?: "development" | "staging" | "production";
850
+ metadata?: Record<string, unknown>;
851
+ }
852
+ interface UserContext {
853
+ id?: string;
854
+ displayName?: string;
855
+ roles?: string[];
856
+ groups?: string[];
857
+ metadata?: Record<string, unknown>;
858
+ }
859
+ interface DataBoundary {
860
+ region?: string;
861
+ classification?: "public" | "internal" | "confidential" | "restricted";
862
+ allowCrossTenantMemory?: boolean;
863
+ redactSensitiveData?: boolean;
864
+ }
865
+ interface CostBudget {
866
+ maxInputTokens?: number;
867
+ maxOutputTokens?: number;
868
+ maxEstimatedCostUsd?: number;
869
+ maxTurns?: number;
870
+ }
871
+ interface RetentionPolicy {
872
+ conversationDays?: number;
873
+ eventDays?: number;
874
+ artifactDays?: number;
875
+ }
876
+ interface RuntimePolicy {
877
+ allowedTools?: string[];
878
+ maxToolRisk?: WorkflowRisk;
879
+ requireHumanApprovalFor?: WorkflowRisk[];
880
+ dataBoundary?: DataBoundary;
881
+ costBudget?: CostBudget;
882
+ retention?: RetentionPolicy;
883
+ rateLimit?: {
884
+ maxRequestsPerMinute?: number;
885
+ maxConcurrentRuns?: number;
886
+ };
887
+ }
888
+ interface RuntimeRequestContext {
889
+ tenant?: TenantContext;
890
+ user?: UserContext;
891
+ surface: RuntimeSurface;
892
+ channel?: string;
893
+ correlationId?: string;
894
+ policy?: RuntimePolicy;
895
+ metadata?: Record<string, unknown>;
896
+ }
897
+ declare function createRuntimeRequestContext(input?: Partial<RuntimeRequestContext>): RuntimeRequestContext;
898
+ declare function mergeRuntimePolicy(base: RuntimePolicy | undefined, override: RuntimePolicy | undefined): RuntimePolicy | undefined;
899
+ declare function runtimeContextToMetadata(context: RuntimeRequestContext | undefined): Record<string, unknown>;
900
+
901
+ type ReasoningEffort = "auto" | "low" | "medium" | "high" | "max";
902
+ type RuntimeMode = AgentModeId;
903
+ interface AgentRuntimeOptions {
904
+ providerType: ProviderType;
905
+ model?: string;
906
+ providerConfig?: ProviderConfig;
907
+ provider?: LLMProvider;
908
+ toolRegistry?: ToolRegistry;
909
+ /** Legacy CLI session store passthrough. Runtime APIs use runtimeSessionStore. */
910
+ sessionStore?: unknown;
911
+ runtimeSessionStore?: RuntimeSessionStore;
912
+ workflowEngine?: WorkflowEngine;
913
+ permissionPolicy?: PermissionPolicy;
914
+ eventLog?: EventLog;
915
+ eventLogPath?: string;
916
+ turnRunner?: RuntimeTurnRunner;
917
+ /**
918
+ * Publish provider/tools into Coco's legacy process-global subagent bridge.
919
+ * CLI/headless use this for compatibility; embedders should leave it false.
920
+ */
921
+ publishToGlobalBridge?: boolean;
922
+ legacyAgentBridge?: {
923
+ setAgentProvider(provider: LLMProvider): void;
924
+ setAgentToolRegistry(registry: ToolRegistry): void;
925
+ };
926
+ runtimeContext?: RuntimeRequestContext;
927
+ runtimePolicy?: RuntimePolicy;
928
+ }
929
+ interface AgentRuntimeSnapshot {
930
+ provider: {
931
+ type: ProviderType;
932
+ model: string;
933
+ capability: ProviderRuntimeCapability;
934
+ };
935
+ tools: {
936
+ count: number;
937
+ names: string[];
938
+ };
939
+ modes: AgentModeDefinition[];
940
+ context?: RuntimeRequestContext;
941
+ policy?: RuntimePolicy;
942
+ }
943
+ 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";
944
+ interface RuntimeEvent {
945
+ id: string;
946
+ type: RuntimeEventType;
947
+ timestamp: string;
948
+ data: Record<string, unknown>;
949
+ }
950
+ interface EventLog {
951
+ record(type: RuntimeEventType, data?: Record<string, unknown>): RuntimeEvent;
952
+ list(): RuntimeEvent[];
953
+ count(): number;
954
+ clear(): void;
955
+ }
956
+ interface PermissionDecision {
957
+ allowed: boolean;
958
+ reason?: string;
959
+ requiresConfirmation?: boolean;
960
+ risk: "read-only" | "write" | "network" | "destructive" | "secrets-sensitive";
961
+ }
962
+ interface PermissionPolicy {
963
+ canExecuteTool(mode: RuntimeMode, tool: ToolDefinition): PermissionDecision;
964
+ canExecuteToolInput?(mode: RuntimeMode, tool: ToolDefinition, input: Record<string, unknown>): PermissionDecision;
965
+ }
966
+ interface ProviderRuntimeSelection {
967
+ provider: ProviderType;
968
+ model: string;
969
+ thinking?: ThinkingMode;
970
+ }
971
+ interface RuntimeSession {
972
+ id: string;
973
+ createdAt: string;
974
+ updatedAt: string;
975
+ mode: RuntimeMode;
976
+ messages: Message[];
977
+ instructions?: string;
978
+ metadata: Record<string, unknown>;
979
+ }
980
+ interface RuntimeSessionCreateOptions {
981
+ id?: string;
982
+ mode?: RuntimeMode;
983
+ instructions?: string;
984
+ metadata?: Record<string, unknown>;
985
+ messages?: Message[];
986
+ }
987
+ interface RuntimeSessionStore {
988
+ create(options?: RuntimeSessionCreateOptions): RuntimeSession;
989
+ get(id: string): RuntimeSession | undefined;
990
+ update(session: RuntimeSession): RuntimeSession;
991
+ list(): RuntimeSession[];
992
+ delete(id: string): boolean;
993
+ }
994
+ interface RuntimeTurnInput {
995
+ content: string;
996
+ sessionId?: string;
997
+ mode?: RuntimeMode;
998
+ options?: ChatOptions;
999
+ metadata?: Record<string, unknown>;
1000
+ /**
1001
+ * Tool names that the embedding product has explicitly confirmed for this
1002
+ * turn. Destructive tools are still blocked unless listed here.
1003
+ */
1004
+ confirmedTools?: string[];
1005
+ }
1006
+ interface RuntimeTurnResult {
1007
+ sessionId: string;
1008
+ content: string;
1009
+ usage: {
1010
+ inputTokens: number;
1011
+ outputTokens: number;
1012
+ estimated?: boolean;
1013
+ };
1014
+ model: string;
1015
+ mode: RuntimeMode;
1016
+ }
1017
+ type RuntimeTurnStreamEvent = {
1018
+ type: "text";
1019
+ sessionId: string;
1020
+ text: string;
1021
+ } | {
1022
+ type: "done";
1023
+ sessionId: string;
1024
+ result: RuntimeTurnResult;
1025
+ } | {
1026
+ type: "error";
1027
+ sessionId: string;
1028
+ error: string;
1029
+ };
1030
+ interface RuntimeTurnContext {
1031
+ runtime: unknown;
1032
+ session: RuntimeSession;
1033
+ provider: LLMProvider;
1034
+ toolRegistry: ToolRegistry;
1035
+ permissionPolicy: PermissionPolicy;
1036
+ eventLog: EventLog;
1037
+ }
1038
+ interface RuntimeTurnRunner {
1039
+ run(input: RuntimeTurnInput, context: RuntimeTurnContext): Promise<RuntimeTurnResult>;
1040
+ }
1041
+ interface RuntimeToolExecutionInput {
1042
+ sessionId?: string;
1043
+ mode?: RuntimeMode;
1044
+ toolName: string;
1045
+ input: Record<string, unknown>;
1046
+ confirmed?: boolean;
1047
+ metadata?: Record<string, unknown>;
1048
+ }
1049
+ interface RuntimeToolExecutionResult {
1050
+ toolName: string;
1051
+ success: boolean;
1052
+ output?: unknown;
1053
+ error?: string;
1054
+ duration: number;
1055
+ decision: PermissionDecision;
1056
+ }
891
1057
 
892
1058
  type WorkflowRunStatus = "completed" | "failed";
893
1059
  interface WorkflowRunInput {
@@ -917,12 +1083,14 @@ interface WorkflowEngineOptions {
917
1083
  eventLog?: EventLog;
918
1084
  sharedState?: SharedWorkspaceStore;
919
1085
  nodeExecutor?: AgentGraphNodeExecutor;
1086
+ runtimePolicy?: RuntimePolicy;
920
1087
  }
921
1088
  declare class WorkflowEngine {
922
1089
  private readonly catalog;
923
1090
  private readonly eventLog;
924
1091
  private handlers;
925
1092
  private readonly sharedState;
1093
+ private readonly runtimePolicy?;
926
1094
  private nodeExecutor?;
927
1095
  constructor(catalog?: WorkflowCatalog, eventLog?: EventLog, options?: Omit<WorkflowEngineOptions, "catalog" | "eventLog">);
928
1096
  registerHandler(workflowId: string, handler: WorkflowHandler): void;
@@ -932,38 +1100,4 @@ declare class WorkflowEngine {
932
1100
  }
933
1101
  declare function createWorkflowEngine(catalog?: WorkflowCatalog, eventLog?: EventLog, options?: Omit<WorkflowEngineOptions, "catalog" | "eventLog">): WorkflowEngine;
934
1102
 
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 };
1103
+ export { type RetentionPolicy 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, type AgentRuntimeOptions as I, type AgentRuntimeSnapshot as J, type AgentToolPolicyDecision as K, type LLMProvider as L, type Message as M, type AgentTraceContext as N, type CostBudget as O, type ProviderConfig as P, DEFAULT_WORKFLOWS as Q, type DataBoundary as R, type StreamChunk as S, type EventLog as T, FileSharedWorkspaceStore as U, InMemorySharedWorkspaceStore as V, type LegacyAgentRoleMapping as W, type PermissionDecision as X, type PermissionPolicy as Y, type ProviderRuntimeSelection as Z, type ReasoningEffort as _, type ChatResponse as a, validateAgentCapabilities as a$, type AgentTask as a0, type RuntimeEvent as a1, type RuntimeEventType as a2, type RuntimeMode as a3, type RuntimePolicy as a4, type RuntimeRequestContext as a5, type RuntimeSession as a6, type RuntimeSessionCreateOptions as a7, type RuntimeSessionStore as a8, type RuntimeSurface as a9, type WorkflowRetryPolicy as aA, type WorkflowRisk as aB, type WorkflowRunContext as aC, type WorkflowRunInput as aD, type WorkflowRunResult as aE, type WorkflowRunStatus as aF, type WorkflowStepDefinition as aG, createAgentArtifact as aH, createAgentGraphEngine as aI, createAgentTraceContext as aJ, createProvider as aK, createRuntimeRequestContext as aL, createSummaryArtifact as aM, createToolRegistry as aN, createWorkflowCatalog as aO, createWorkflowEngine as aP, createWorkflowRegistry as aQ, dryRunAgentGraphNodeExecutor as aR, evaluateAgentToolPolicy as aS, getAgentMode as aT, isAgentMode as aU, listAgentModes as aV, listLegacyAgentRoleMappings as aW, mapLegacyAgentRole as aX, mergeRuntimePolicy as aY, normalizeAgentRunResult as aZ, runtimeContextToMetadata as a_, type RuntimeToolExecutionInput as aa, type RuntimeToolExecutionResult as ab, type RuntimeTurnContext as ac, type RuntimeTurnInput as ad, type RuntimeTurnResult as ae, type RuntimeTurnRunner as af, type RuntimeTurnStreamEvent as ag, type SharedWorkspaceProvenance as ah, type SharedWorkspaceRecord as ai, type SharedWorkspaceRecordKind as aj, SharedWorkspaceState as ak, type SharedWorkspaceStateSnapshot as al, type SharedWorkspaceStore as am, type SharedWorkspaceWriteInput as an, type TenantContext as ao, ToolRegistry as ap, type ToolRiskLevel as aq, type ToolRiskManifest as ar, type ToolRiskManifestEntry as as, type UserContext as at, WorkflowCatalog as au, type WorkflowDefinition as av, WorkflowEngine as aw, type WorkflowHandler as ax, type WorkflowPlan as ay, WorkflowRegistry as az, type ChatWithToolsOptions as b, validateAgentGraph as b0, workflowToAgentGraph as b1, type ToolDefinition as b2, type ToolCategory as b3, type ToolResult as b4, defineTool as b5, getToolRegistry as b6, type ProviderType as b7, type ProviderCatalogEntry as b8, type ModelCatalogEntry as b9, type ProviderRuntimeCapability as ba, type ProviderProbeResult as bb, 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 };