@rowan-agent/agent 0.8.5 → 0.8.7

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.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import Type from 'typebox';
2
1
  import * as _rowan_agent_models from '@rowan-agent/models';
3
2
  import { LlmContentPart, ContentBlock, ModelRef, ModelConfig, StreamFn } from '@rowan-agent/models';
4
3
  export { ModelConfig, ModelRef, StreamFn } from '@rowan-agent/models';
4
+ import Type from 'typebox';
5
5
 
6
6
  type AgentMessage = {
7
7
  id: string;
@@ -78,6 +78,11 @@ type PhaseExecution = {
78
78
  * Extension types — simplified for the new hook-based system.
79
79
  */
80
80
 
81
+ interface SourceInfo {
82
+ source: string;
83
+ baseDir?: string;
84
+ displayName?: string;
85
+ }
81
86
  /** Phase run function type for extensions */
82
87
  type PhaseRun = (context: PhaseContext, execution: PhaseExecution) => Promise<PhaseOutput | void>;
83
88
  /** Phase definition shape used by extensions */
@@ -135,6 +140,28 @@ interface ToolExecutionResult$1 {
135
140
  /** Whether this is an error result */
136
141
  isError?: boolean;
137
142
  }
143
+ /**
144
+ * Registered tool with source metadata.
145
+ */
146
+ interface RegisteredTool {
147
+ definition: ToolDefinition;
148
+ sourceInfo: SourceInfo;
149
+ }
150
+ /**
151
+ * Structured extension error with attribution.
152
+ */
153
+ interface ExtensionError {
154
+ /** Path of the extension that caused the error */
155
+ extensionPath: string;
156
+ /** Event or operation that caused the error */
157
+ event: string;
158
+ /** Error message */
159
+ error: string;
160
+ /** Optional stack trace */
161
+ stack?: string;
162
+ }
163
+ /** Error listener callback type. */
164
+ type ExtensionErrorListener = (error: ExtensionError) => void;
138
165
  type ExecOptions = {
139
166
  /** Working directory for the command. Defaults to cwd passed to runtime. */
140
167
  cwd?: string;
@@ -150,6 +177,18 @@ type ExecResult = {
150
177
  stdout: string;
151
178
  stderr: string;
152
179
  };
180
+ /**
181
+ * Shared runtime state created by loader, used during registration and runtime.
182
+ * All ExtensionAPI instances reference this shared state.
183
+ *
184
+ * It only owns the lifetime guard shared by captured Extension API objects.
185
+ */
186
+ interface ExtensionRuntime {
187
+ /** Throws when this extension instance is stale after runtime replacement. */
188
+ assertActive: () => void;
189
+ /** Marks this extension instance as stale after runtime replacement or reload. */
190
+ invalidate: (message?: string) => void;
191
+ }
153
192
  /**
154
193
  * Result of loading extensions from filesystem.
155
194
  * The runner takes these and creates Extension tracking objects.
@@ -274,6 +313,17 @@ type HookEventType = HookEvent["type"];
274
313
  type HookHandler<K extends HookEventType> = (event: Extract<HookEvent, {
275
314
  type: K;
276
315
  }>) => HookResultMap[K] | Promise<HookResultMap[K]> | void | Promise<void>;
316
+ declare class HooksManager {
317
+ private handlers;
318
+ on<K extends HookEventType>(eventType: K, handler: HookHandler<K>): void;
319
+ off<K extends HookEventType>(eventType: K, handler: HookHandler<K>): void;
320
+ emit<K extends HookEventType>(eventType: K, event: Extract<HookEvent, {
321
+ type: K;
322
+ }>): Promise<void>;
323
+ emitFirst<K extends HookEventType>(eventType: K, event: Extract<HookEvent, {
324
+ type: K;
325
+ }>): Promise<HookResultMap[K] | undefined>;
326
+ }
277
327
 
278
328
  /**
279
329
  * @module extensions/context
@@ -424,7 +474,9 @@ interface ExtensionAPI {
424
474
  * Extension factory function.
425
475
  * Receives ExtensionAPI for registering hooks, phases, and providers.
426
476
  */
427
- type ExtensionFactory = (api: ExtensionAPI) => void | Promise<void>;
477
+ type ExtensionDisposer = () => void | Promise<void>;
478
+ type ExtensionFactoryResult = void | ExtensionDisposer;
479
+ type ExtensionFactory = (api: ExtensionAPI) => ExtensionFactoryResult | Promise<ExtensionFactoryResult>;
428
480
 
429
481
  /** Unified phase output — model decides routing via route. */
430
482
  type PhaseOutput = {
@@ -467,6 +519,9 @@ type PhaseExecutionIdentity = Readonly<{
467
519
  agentId: string;
468
520
  runId: string;
469
521
  executionId: string;
522
+ /** Opaque metadata captured at the durable boundary; Rowan does not decode it. */
523
+ agentMetadata?: Readonly<Record<string, unknown>>;
524
+ runMetadata?: Readonly<Record<string, unknown>>;
470
525
  }>;
471
526
  /** Everything a phase needs to execute */
472
527
  interface PhaseContext {
@@ -565,6 +620,108 @@ type CoreToolContext = {
565
620
  maxBashOutputBytes?: number;
566
621
  };
567
622
 
623
+ type PhaseRegistrySelection = Readonly<{
624
+ entryPhaseId: string | null;
625
+ phaseIds: readonly string[];
626
+ }>;
627
+ type AgentDefinition = Readonly<{
628
+ name: string;
629
+ description: string;
630
+ prompt: string;
631
+ tools?: readonly string[];
632
+ skills?: readonly string[];
633
+ phases?: PhaseRegistrySelection;
634
+ contexts?: readonly string[];
635
+ model?: ModelRef;
636
+ }>;
637
+ /** Parse one Markdown definition using the same frontmatter vocabulary as Phase resources. */
638
+ declare function parseAgentDefinition(raw: string): AgentDefinition;
639
+
640
+ type ResourceKind = "agent" | "tool" | "skill" | "phase";
641
+ type ResourceSourceId = string;
642
+ /** Rowan-native contribution aliases. Hosts may adapt their domain handlers to
643
+ * these existing Tool/Phase lifecycles without importing host Scope types. */
644
+ type ToolContribution = Tool;
645
+ type PhaseContribution = Phase;
646
+ type ResourceView = Readonly<{
647
+ agents: readonly ResourceSourceId[];
648
+ tools: readonly ResourceSourceId[];
649
+ skills: readonly ResourceSourceId[];
650
+ phases: readonly ResourceSourceId[];
651
+ }>;
652
+ type ResourceRef = Readonly<{
653
+ kind: ResourceKind;
654
+ sourceId: ResourceSourceId;
655
+ name: string;
656
+ }>;
657
+ type ResourceDiagnostic = Readonly<{
658
+ kind: "invalid" | "missing" | "collision";
659
+ sourceId: ResourceSourceId;
660
+ message: string;
661
+ path?: string;
662
+ }>;
663
+ type LoadResult = Readonly<{
664
+ revision: string;
665
+ registered: readonly ResourceRef[];
666
+ skipped: readonly ResourceDiagnostic[];
667
+ }>;
668
+ type LoadInput<T> = Readonly<{
669
+ sourceId: ResourceSourceId;
670
+ directory?: string;
671
+ values?: readonly T[];
672
+ }>;
673
+ type ResolvedResourceView = Readonly<{
674
+ agents: readonly AgentDefinition[];
675
+ tools: readonly Tool[];
676
+ skills: readonly Skill[];
677
+ phases: readonly Phase[];
678
+ revisions: Readonly<Record<ResourceKind, readonly string[]>>;
679
+ refs: Readonly<Record<ResourceKind, readonly ResourceRef[]>>;
680
+ }>;
681
+ type ResourceRegistryErrorCode = "invalid_source_id" | "invalid_resource_name" | "resource_collision" | "resource_input_missing" | "resource_directory_not_supported" | "unknown_resource_source" | "implicit_source_protected";
682
+ declare class ResourceRegistryError extends Error {
683
+ readonly code: ResourceRegistryErrorCode;
684
+ constructor(code: ResourceRegistryErrorCode, message: string);
685
+ }
686
+ type RegistryValue = AgentDefinition | Tool | Skill | Phase;
687
+ /**
688
+ * Runtime Resource Registry source transaction and view resolver.
689
+ *
690
+ * Directory normalization is intentionally added by the typed loader slice;
691
+ * this first module owns only the atomic source/revision/collision semantics.
692
+ */
693
+ declare class ResourceRegistry {
694
+ private readonly sources;
695
+ /** Sources registered by the bootstrap boundary (currently Extensions). */
696
+ private readonly implicitSources;
697
+ private revisionSequence;
698
+ loadAgents(input: LoadInput<AgentDefinition>): Promise<LoadResult>;
699
+ loadSkills(input: LoadInput<Skill>): Promise<LoadResult>;
700
+ loadPhases(input: LoadInput<Phase>): Promise<LoadResult>;
701
+ loadTools(input: Readonly<{
702
+ sourceId: ResourceSourceId;
703
+ values: readonly ToolContribution[];
704
+ }>): Promise<LoadResult>;
705
+ unload(input: Readonly<{
706
+ kind: ResourceKind;
707
+ sourceId: ResourceSourceId;
708
+ }>): Promise<LoadResult>;
709
+ resolveView(view: ResourceView): ResolvedResourceView;
710
+ /** Mark one already-loaded source as implicit for every Resource View. */
711
+ protected markImplicit(kind: ResourceKind, sourceId: ResourceSourceId): void;
712
+ /** Bootstrap-only helper for replacing an implicit contribution source. */
713
+ protected replaceImplicit<T extends RegistryValue>(kind: ResourceKind, sourceId: ResourceSourceId, values: readonly T[]): Promise<LoadResult>;
714
+ protected hasImplicit(kind: ResourceKind, sourceId: ResourceSourceId): boolean;
715
+ private withImplicit;
716
+ private collect;
717
+ private commit;
718
+ private resolveKind;
719
+ private resolveRevisions;
720
+ private resolveRefs;
721
+ private sourcesFor;
722
+ private nextRevision;
723
+ }
724
+
568
725
  /** Durable and transient DTOs owned by the event-driven Agent Runtime. */
569
726
  declare const opaqueIdBrand: unique symbol;
570
727
  type OpaqueId<Kind extends string> = string & {
@@ -865,19 +1022,259 @@ type ToolProgress = Readonly<{
865
1022
  }>;
866
1023
  type RunEvent = DurableRunEvent | MessageDelta | ToolProgress;
867
1024
 
868
- type AgentDefinition = Readonly<{
869
- name: string;
870
- description: string;
871
- content: string;
1025
+ /**
1026
+ * Extension runner — manages extension loading and hook execution.
1027
+ *
1028
+ * Architecture reference: PI's ExtensionRunner
1029
+ * - Per-extension tracking via Extension objects
1030
+ * - Shared ExtensionRuntime with invalidate/assertActive
1031
+ * - Direct `on()` API for hook registration
1032
+ * - Error listener pattern for structured error handling
1033
+ * - Tool registration support
1034
+ */
1035
+
1036
+ type ExtensionRunnerOptions = {
1037
+ entryPhaseId?: string | null;
1038
+ cwd?: string;
1039
+ };
1040
+ /**
1041
+ * Manages extensions and provides hooks for the agent loop.
1042
+ *
1043
+ * Features:
1044
+ * - Per-extension tracking (handlers, tools, phases)
1045
+ * - Shared runtime with lifecycle protection (invalidate/assertActive)
1046
+ * - Error listener pattern for structured error handling
1047
+ * - Direct hook API and extension-loaded hook API
1048
+ * - Tool registration for LLM-callable tools
1049
+ * - EventBus for inter-extension communication
1050
+ *
1051
+ * @example
1052
+ * ```ts
1053
+ * const runner = createExtensionRunner();
1054
+ *
1055
+ * // Direct hook registration
1056
+ * const unsub = runner.on("before_tool_call", (event) => {
1057
+ * return { allow: false, reason: "Blocked" };
1058
+ * });
1059
+ *
1060
+ * // Error handling
1061
+ * runner.onError((error) => {
1062
+ * console.error(`Extension error in ${error.extensionPath}:`, error.error);
1063
+ * });
1064
+ *
1065
+ * // Load extensions
1066
+ * await runner.loadExtensions(extensions);
1067
+ * runner.bind();
1068
+ * ```
1069
+ */
1070
+ declare class ExtensionRunner {
1071
+ readonly hooks: HooksManager;
1072
+ readonly runtime: ExtensionRuntime;
1073
+ readonly events: EventBus;
1074
+ private readonly cwd;
1075
+ private readonly abortController;
1076
+ private _idle;
1077
+ private readonly extensions;
1078
+ private readonly phases;
1079
+ private _phaseCache;
1080
+ private readonly pendingProviders;
1081
+ private bound;
1082
+ private readonly errorListeners;
1083
+ /** Current agent context — set by the agent before each phase */
1084
+ currentContext?: AgentContext;
1085
+ constructor(options?: ExtensionRunnerOptions);
1086
+ /** Whether the agent is currently idle (not streaming). */
1087
+ get isIdle(): boolean;
1088
+ /** Set idle state — called by the agent loop. */
1089
+ setIdle(idle: boolean): void;
1090
+ /** Abort signal for the current runner instance. */
1091
+ get signal(): AbortSignal;
1092
+ /** Abort the current runner operation. */
1093
+ abort(): void;
1094
+ /**
1095
+ * Register an error listener.
1096
+ * Returns an unsubscribe function.
1097
+ */
1098
+ onError(listener: ExtensionErrorListener): () => void;
1099
+ /**
1100
+ * Emit a structured extension error to all listeners.
1101
+ */
1102
+ emitError(error: ExtensionError): void;
1103
+ /**
1104
+ * Mark all extension contexts as stale.
1105
+ * After calling this, any captured ExtensionAPI or ExtensionContext will throw
1106
+ * on use. Used during runtime replacement or reload.
1107
+ */
1108
+ invalidate(message?: string): void;
1109
+ /**
1110
+ * Subscribe to a specific hook event type.
1111
+ * Returns an unsubscribe function.
1112
+ *
1113
+ * @example
1114
+ * ```ts
1115
+ * const unsub = runner.on("before_tool_call", (event) => {
1116
+ * return { allow: false, reason: "Blocked" };
1117
+ * });
1118
+ * unsub(); // Cancel subscription
1119
+ * ```
1120
+ */
1121
+ on<K extends HookEventType>(type: K, handler: HookHandler<K>): () => void;
1122
+ /**
1123
+ * Load and initialize extensions.
1124
+ * Creates Extension tracking objects and calls each factory with an ExtensionAPI.
1125
+ */
1126
+ loadExtensions(extensions: LoadedExtension[]): Promise<void>;
1127
+ /** Dispose all active Extensions in reverse activation order. */
1128
+ close(): Promise<void>;
1129
+ /** Get all registered tools from all extensions. */
1130
+ getAllRegisteredTools(): RegisteredTool[];
1131
+ /**
1132
+ * Get a tool definition by name. Returns undefined if not found.
1133
+ */
1134
+ getToolDefinition(toolName: string): RegisteredTool["definition"] | undefined;
1135
+ getPhase(name: string): Phase | undefined;
1136
+ getPhases(): Phase[];
1137
+ createPhaseRegistry(input?: {
1138
+ entryPhaseId?: string | null;
1139
+ }): PhaseRegistry;
1140
+ /** Adapt an extension RegisteredPhase to the core Phase type. */
1141
+ private adaptToPhase;
1142
+ /**
1143
+ * Bind the runner — flushes pending provider registrations and
1144
+ * replaces runtime stubs with real implementations.
1145
+ */
1146
+ bind(): void;
1147
+ /**
1148
+ * Generic emit — fire-and-forget for any event type.
1149
+ */
1150
+ emit<K extends HookEventType>(eventType: K, event: Parameters<HookHandler<K>>[0]): Promise<void>;
1151
+ /**
1152
+ * Unified hook emission — returns the first non-undefined result.
1153
+ */
1154
+ private emitHook;
1155
+ emitBeforePhase(phaseId: string, input: PhaseContext): Promise<{
1156
+ abort?: any;
1157
+ skip?: any;
1158
+ input?: PhaseContext;
1159
+ }>;
1160
+ emitAfterPhase(phaseId: string, output: PhaseOutput): Promise<{
1161
+ abort?: any;
1162
+ retry?: PhaseContext;
1163
+ output?: PhaseOutput;
1164
+ }>;
1165
+ emitBeforePrompt(phaseId: string, input: PhaseContext): Promise<PhaseContext>;
1166
+ emitBeforeToolCall(tool: Tool$1, args: unknown): Promise<{
1167
+ allow: boolean;
1168
+ reason?: string;
1169
+ }>;
1170
+ emitAfterToolCall(tool: Tool$1, result: ToolResult): Promise<ToolResult>;
1171
+ /**
1172
+ * Create an ExtensionAPI for a specific extension.
1173
+ * Registration methods write to the extension tracking object.
1174
+ * Action methods delegate to the shared runtime.
1175
+ */
1176
+ private createExtensionAPI;
1177
+ private registerTool;
1178
+ private registerPhase;
1179
+ private registerProvider;
1180
+ private unregisterProvider;
1181
+ private flushPendingProviders;
1182
+ private getRegisteredPhase;
1183
+ private collectRegisteredPhases;
1184
+ private rollbackExtension;
1185
+ private disposeExtension;
1186
+ }
1187
+
1188
+ type ExtensionContribution = LoadedExtension;
1189
+ type ExtensionLoadInput = LoadInput<ExtensionContribution>;
1190
+ type ExtensionActivationError = Readonly<{
1191
+ path: string;
1192
+ error: string;
1193
+ }>;
1194
+ type ExtensionActivationResult = Readonly<{
1195
+ active: readonly string[];
1196
+ errors: readonly ExtensionActivationError[];
1197
+ revision?: string;
1198
+ registered?: readonly string[];
1199
+ skipped?: readonly ResourceDiagnostic[];
1200
+ }>;
1201
+ type ExtensionLifetimeErrorCode = "extensions_frozen" | "extensions_closed";
1202
+ declare class ExtensionLifetimeError extends Error {
1203
+ readonly code: ExtensionLifetimeErrorCode;
1204
+ constructor(code: ExtensionLifetimeErrorCode, message: string);
1205
+ }
1206
+ /** Runtime-global Extension activation and lifetime boundary. */
1207
+ declare class RuntimeExtensionLifetime {
1208
+ private readonly runner;
1209
+ private frozen;
1210
+ private closed;
1211
+ constructor(options?: {
1212
+ cwd?: string;
1213
+ });
1214
+ activate(extensions: readonly LoadedExtension[]): Promise<ExtensionActivationResult>;
1215
+ tools(): readonly RegisteredTool[];
1216
+ phases(): readonly Phase[];
1217
+ get extensionRunner(): ExtensionRunner;
1218
+ close(): Promise<void>;
1219
+ }
1220
+ /** Bootstrap-only Registry facade; its Extension method disappears after init. */
1221
+ declare class RuntimeBootstrapRegistry extends ResourceRegistry {
1222
+ private readonly extensions;
1223
+ private readonly extensionSourceId;
1224
+ constructor(extensions?: RuntimeExtensionLifetime);
1225
+ /** Install Rowan-owned implicit resources before any host source is read. */
1226
+ ensureCoreResources(): Promise<void>;
1227
+ loadExtensions(input: readonly LoadedExtension[] | ExtensionLoadInput): Promise<ExtensionActivationResult>;
1228
+ get extensionRunner(): ExtensionRunner;
1229
+ get extensionTools(): readonly RegisteredTool[];
1230
+ get extensionPhases(): readonly Phase[];
1231
+ closeExtensions(): Promise<void>;
1232
+ }
1233
+
1234
+ type DefinitionLayer = Readonly<{
1235
+ description?: string;
1236
+ prompt?: string;
1237
+ model?: ModelRef;
872
1238
  tools?: readonly string[];
873
1239
  skills?: readonly string[];
874
- phases?: readonly string[];
875
- extensions?: readonly string[];
876
- entryPhase?: string;
877
- model?: ModelRef;
1240
+ phases?: PhaseRegistrySelection;
878
1241
  }>;
879
- /** Parse one Markdown definition using the same frontmatter vocabulary as Phase resources. */
880
- declare function parseAgentDefinition(raw: string): AgentDefinition;
1242
+ type AgentConfiguration = Readonly<{
1243
+ identity: string;
1244
+ definition: Readonly<{
1245
+ name: string;
1246
+ layer?: DefinitionLayer;
1247
+ }>;
1248
+ resourceView: ResourceView;
1249
+ contexts?: readonly ContextCandidate[];
1250
+ cwd?: string;
1251
+ maxAttempts?: number;
1252
+ model: ModelConfig | ModelRef;
1253
+ stream?: StreamFn;
1254
+ }>;
1255
+ type ConfigurationSnapshot = Readonly<{
1256
+ identity: string;
1257
+ definition: AgentDefinition;
1258
+ resources: Readonly<{
1259
+ tools: readonly Tool[];
1260
+ skills: readonly Skill[];
1261
+ phases?: PhaseRegistry;
1262
+ revisions: Readonly<Record<ResourceKind, readonly string[]>>;
1263
+ refs: Readonly<Record<ResourceKind, readonly ResourceRef[]>>;
1264
+ }>;
1265
+ contexts: readonly ContextCandidate[];
1266
+ resourceView: ResourceView;
1267
+ cwd?: string;
1268
+ maxAttempts?: number;
1269
+ model: ModelConfig | ModelRef;
1270
+ stream?: StreamFn;
1271
+ }>;
1272
+ /** Resolve one Definition request into one immutable, source-qualified snapshot. */
1273
+ declare function resolveConfigurationSnapshot(registry: ResourceRegistry, input: AgentConfiguration): ConfigurationSnapshot;
1274
+ /** Materialize the immutable resolver output at the legacy execution seam.
1275
+ * The conversion is intentionally one-way: callers cannot feed concrete
1276
+ * candidate bags back through the public configuration request. */
1277
+ declare function materializeConfigurationSnapshot(snapshot: ConfigurationSnapshot): AgentConfig;
881
1278
 
882
1279
  type UserInput = string | Readonly<{
883
1280
  content: UserContent;
@@ -886,6 +1283,10 @@ type UserInput = string | Readonly<{
886
1283
  type ToolInvocationContext = Readonly<{
887
1284
  agentId: AgentId;
888
1285
  runId: RunId;
1286
+ /** Opaque JSON metadata captured from the Agent and Run records. Rowan does
1287
+ * not interpret host/domain fields. */
1288
+ agentMetadata?: Metadata;
1289
+ runMetadata?: Metadata;
889
1290
  toolCallId: ToolCallId;
890
1291
  reportProgress(progress: JsonValue): void;
891
1292
  }>;
@@ -895,6 +1296,10 @@ type Tool = Readonly<{
895
1296
  parameters: Type.TSchema;
896
1297
  execute(args: JsonValue, context: ToolInvocationContext, signal: AbortSignal): Promise<ToolExecutionResult>;
897
1298
  }>;
1299
+ type ContextCandidate = Readonly<{
1300
+ name: string;
1301
+ value: JsonValue;
1302
+ }>;
898
1303
  type BeforeToolCall = (input: Readonly<{
899
1304
  tool: Tool;
900
1305
  args: JsonValue;
@@ -921,7 +1326,11 @@ type AgentResources = Readonly<{
921
1326
  tools: readonly Tool[];
922
1327
  skills: readonly Skill[];
923
1328
  phases?: PhaseRegistry;
924
- extensions?: readonly LoadedExtension[];
1329
+ contexts?: readonly ContextCandidate[];
1330
+ /** Source-qualified snapshot metadata retained for restart/recovery checks. */
1331
+ resourceView?: ResourceView;
1332
+ resourceRefs?: readonly ResourceRef[];
1333
+ resourceRevisions?: Readonly<Record<ResourceKind, readonly string[]>>;
925
1334
  }>;
926
1335
  type AgentConfig = Readonly<{
927
1336
  identity: string;
@@ -938,6 +1347,8 @@ type AgentConfig = Readonly<{
938
1347
  model: ModelRef;
939
1348
  stream: StreamFn;
940
1349
  })>;
1350
+ /** Definition-reference request accepted at the public Runtime seam. */
1351
+ type AgentConfigRequest = AgentConfig | AgentConfiguration;
941
1352
  type AgentRecord = Readonly<{
942
1353
  id: AgentId;
943
1354
  metadata?: Metadata;
@@ -1084,7 +1495,7 @@ type RunBoundary = Readonly<{
1084
1495
  }>;
1085
1496
  type ConfigResolution = Readonly<{
1086
1497
  kind: "available";
1087
- config: AgentConfig;
1498
+ config: AgentConfigRequest;
1088
1499
  } | {
1089
1500
  kind: "deferred";
1090
1501
  retryAfterMs?: number;
@@ -1102,7 +1513,7 @@ interface ConfigProvider {
1102
1513
  put(input: {
1103
1514
  agentId: AgentId;
1104
1515
  agentMetadata?: Metadata;
1105
- config: AgentConfig;
1516
+ config: AgentConfigRequest;
1106
1517
  operationId: string;
1107
1518
  signal: AbortSignal;
1108
1519
  }): Promise<ConfigPutResult>;
@@ -1233,6 +1644,7 @@ type AgentRuntimeOptions = Readonly<{
1233
1644
  store: DurableStore;
1234
1645
  configs?: ConfigProvider;
1235
1646
  concurrency?: number;
1647
+ bootstrap?: (registry: RuntimeBootstrapRegistry) => void | Promise<void>;
1236
1648
  }>;
1237
1649
  type DurableConsumer = Readonly<{
1238
1650
  caughtUp: Promise<void>;
@@ -1256,11 +1668,22 @@ interface AgentRun {
1256
1668
  cancel(reason?: string): Promise<RunBoundary>;
1257
1669
  }
1258
1670
  interface AgentRuntime$1 {
1259
- createAgent(config: AgentConfig, options?: {
1671
+ loadAgents(input: LoadInput<AgentDefinition>): Promise<LoadResult>;
1672
+ loadSkills(input: LoadInput<Skill>): Promise<LoadResult>;
1673
+ loadPhases(input: LoadInput<Phase>): Promise<LoadResult>;
1674
+ loadTools(input: Readonly<{
1675
+ sourceId: string;
1676
+ values: readonly Tool[];
1677
+ }>): Promise<LoadResult>;
1678
+ unload(input: Readonly<{
1679
+ kind: ResourceKind;
1680
+ sourceId: string;
1681
+ }>): Promise<LoadResult>;
1682
+ createAgent(config: AgentConfigRequest, options?: {
1260
1683
  idempotencyKey?: string;
1261
1684
  metadata?: Metadata;
1262
1685
  }): Promise<AgentId>;
1263
- updateAgentConfig(agentId: AgentId, config: AgentConfig, options: {
1686
+ updateAgentConfig(agentId: AgentId, config: AgentConfigRequest, options: {
1264
1687
  idempotencyKey: string;
1265
1688
  }): Promise<void>;
1266
1689
  start(agentId: AgentId, input: UserInput, options: {
@@ -1301,16 +1724,28 @@ declare class AgentRuntime implements AgentRuntime$1 {
1301
1724
  private readonly executions;
1302
1725
  private readonly consumers;
1303
1726
  private readonly transientEvents;
1727
+ private readonly resources;
1304
1728
  private heartbeat?;
1305
1729
  private pumping;
1306
1730
  private closed;
1307
1731
  private constructor();
1308
1732
  static init(options: AgentRuntimeOptions): Promise<AgentRuntime>;
1309
- createAgent(config: AgentConfig, options?: {
1733
+ loadAgents(input: LoadInput<AgentDefinition>): Promise<LoadResult>;
1734
+ loadSkills(input: LoadInput<Skill>): Promise<LoadResult>;
1735
+ loadPhases(input: LoadInput<Phase>): Promise<LoadResult>;
1736
+ loadTools(input: Readonly<{
1737
+ sourceId: string;
1738
+ values: readonly Tool[];
1739
+ }>): Promise<LoadResult>;
1740
+ unload(input: Readonly<{
1741
+ kind: ResourceKind;
1742
+ sourceId: string;
1743
+ }>): Promise<LoadResult>;
1744
+ createAgent(config: AgentConfigRequest, options?: {
1310
1745
  idempotencyKey?: string;
1311
1746
  metadata?: Metadata;
1312
1747
  }): Promise<AgentId>;
1313
- updateAgentConfig(agentId: AgentId, config: AgentConfig, options: {
1748
+ updateAgentConfig(agentId: AgentId, config: AgentConfigRequest, options: {
1314
1749
  idempotencyKey: string;
1315
1750
  }): Promise<void>;
1316
1751
  start(agentId: AgentId, input: UserInput, options: {
@@ -1358,6 +1793,7 @@ declare class AgentRuntime implements AgentRuntime$1 {
1358
1793
  signal?: AbortSignal;
1359
1794
  }): Promise<RunBoundary>;
1360
1795
  private assertOpen;
1796
+ private materializeConfig;
1361
1797
  private startHeartbeat;
1362
1798
  }
1363
1799
 
@@ -1692,7 +2128,7 @@ declare class InMemoryConfigProvider implements ConfigProvider {
1692
2128
  put(input: {
1693
2129
  agentId: AgentId;
1694
2130
  agentMetadata?: Metadata;
1695
- config: AgentConfig;
2131
+ config: AgentConfigRequest;
1696
2132
  operationId: string;
1697
2133
  signal: AbortSignal;
1698
2134
  }): Promise<ConfigPutResult>;
@@ -1833,4 +2269,4 @@ declare function parseFrontmatter<T = Record<string, unknown>>(raw: string): Fro
1833
2269
 
1834
2270
  declare function createCoreTools(input?: CoreToolContext): Tool[];
1835
2271
 
1836
- export { type AfterToolCall, type AgentConfig, type AgentDefinition, type AgentId, type AgentListCursor, type AgentRecord, type AgentResources, type AgentRun, AgentRuntime, type AgentRuntimeOptions, type AgentSummary, type AnyRuntimeError, type AssistantContent, type AssistantMessage, type BeforeToolCall, type ConfigProvider, type ConfigPutResult, type ConfigResolution, type ConfigToken, type CoreToolContext, type DurableConsumer, type DurableRunEvent, type DurableStore, type DurableToolResult, type EventCursor, type EventId, type ExecutionCheckpoint, type ExecutionId, type ExecutionToken, type ExtensionAPI, type ExtensionFactory, type FrontmatterResult, type HookEvent, type HookEventType, type HookHandler, InMemoryConfigProvider, InMemoryStore, type InputRequest, type InputRequestId, type InputRequiredCommit, type JsonObject, type JsonPrimitive, type JsonValue, type LoadExtensionsResult, type LoadedExtension, type Message, type MessageBase, type MessageCommitted, type MessageContent, type MessageDelta, type MessageId, type Metadata, type OpaqueId, type Outcome, type OwnerLease, type OwnerToken, type Page, type Phase, type PhaseContext, type PhaseExecutionIdentity, type PhaseInvocation, type PhaseOutput, type PhaseRegistry, type PhaseState, type RunBoundary, type RunClaim, type RunEvent, type RunFailure, type RunId, type RunListCursor, type RunRecord, type RunSnapshot, type RunState, type RunStateChanged, type RunSummary, RuntimeError, type RuntimeErrorCode, type RuntimeErrorDetails, type Skill, SqliteStore, type TextContent, type ThinkingContent, type Tool, type ToolCallId, type ToolCallSnapshot, type ToolCallState, type ToolDefinition, type ToolExecutionResult, type ToolInvocationContext, type ToolMessage, type ToolMessageContent, type ToolProgress, type ToolResultContent, type ToolStateChanged, type ToolUseContent, type UserContent, type UserInput, type UserMessage, brandConfigToken, createCoreTools, isRuntimeError, loadExtensionsFromPath as loadExtensions, loadPhases, loadSkills, parseAgentDefinition, parseFrontmatter };
2272
+ export { type AfterToolCall, type AgentConfig, type AgentConfigRequest, type AgentConfiguration, type AgentDefinition, type AgentId, type AgentListCursor, type AgentRecord, type AgentResources, type AgentRun, AgentRuntime, type AgentRuntimeOptions, type AgentSummary, type AnyRuntimeError, type AssistantContent, type AssistantMessage, type BeforeToolCall, type ConfigProvider, type ConfigPutResult, type ConfigResolution, type ConfigToken, type ConfigurationSnapshot, type ContextCandidate, type CoreToolContext, type DefinitionLayer, type DurableConsumer, type DurableRunEvent, type DurableStore, type DurableToolResult, type EventCursor, type EventId, type ExecutionCheckpoint, type ExecutionId, type ExecutionToken, type ExtensionAPI, type ExtensionActivationError, type ExtensionActivationResult, type ExtensionContribution, type ExtensionDisposer, type ExtensionFactory, type ExtensionFactoryResult, ExtensionLifetimeError, type ExtensionLifetimeErrorCode, type ExtensionLoadInput, type FrontmatterResult, type HookEvent, type HookEventType, type HookHandler, InMemoryConfigProvider, InMemoryStore, type InputRequest, type InputRequestId, type InputRequiredCommit, type JsonObject, type JsonPrimitive, type JsonValue, type LoadExtensionsResult, type LoadInput, type LoadResult, type LoadedExtension, type Message, type MessageBase, type MessageCommitted, type MessageContent, type MessageDelta, type MessageId, type Metadata, type OpaqueId, type Outcome, type OwnerLease, type OwnerToken, type Page, type Phase, type PhaseContext, type PhaseContribution, type PhaseExecutionIdentity, type PhaseInvocation, type PhaseOutput, type PhaseRegistry, type PhaseRegistrySelection, type PhaseState, type ResolvedResourceView, type ResourceDiagnostic, type ResourceKind, type ResourceRef, ResourceRegistry, ResourceRegistryError, type ResourceRegistryErrorCode, type ResourceSourceId, type ResourceView, type RunBoundary, type RunClaim, type RunEvent, type RunFailure, type RunId, type RunListCursor, type RunRecord, type RunSnapshot, type RunState, type RunStateChanged, type RunSummary, RuntimeBootstrapRegistry, RuntimeError, type RuntimeErrorCode, type RuntimeErrorDetails, RuntimeExtensionLifetime, type Skill, SqliteStore, type TextContent, type ThinkingContent, type Tool, type ToolCallId, type ToolCallSnapshot, type ToolCallState, type ToolContribution, type ToolDefinition, type ToolExecutionResult, type ToolInvocationContext, type ToolMessage, type ToolMessageContent, type ToolProgress, type ToolResultContent, type ToolStateChanged, type ToolUseContent, type UserContent, type UserInput, type UserMessage, brandConfigToken, createCoreTools, isRuntimeError, loadExtensionsFromPath as loadExtensions, loadPhases, loadSkills, materializeConfigurationSnapshot, parseAgentDefinition, parseFrontmatter, resolveConfigurationSnapshot };