@rowan-agent/agent 0.32.0 → 0.34.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.
- package/dist/{index-BNGbx6JB.d.ts → index-Det5FQSu.d.ts} +13 -55
- package/dist/index.d.ts +1 -1
- package/dist/runtime.d.ts +3 -9
- package/dist/runtime.js +28 -139
- package/package.json +1 -1
|
@@ -154,12 +154,6 @@ interface EventBus {
|
|
|
154
154
|
on(event: string, listener: Listener): () => void;
|
|
155
155
|
/** Emit an event to all subscribers. */
|
|
156
156
|
emit(event: string, ...args: unknown[]): void;
|
|
157
|
-
/** Remove all listeners for an event, or all listeners if no event specified. */
|
|
158
|
-
off(event?: string): void;
|
|
159
|
-
/** Check if there are listeners for an event. */
|
|
160
|
-
has(event: string): boolean;
|
|
161
|
-
/** Get listener count for an event. */
|
|
162
|
-
count(event: string): number;
|
|
163
157
|
}
|
|
164
158
|
|
|
165
159
|
/**
|
|
@@ -348,8 +342,8 @@ declare class ExtensionRunner {
|
|
|
348
342
|
private readonly skills;
|
|
349
343
|
private readonly pendingProviders;
|
|
350
344
|
private bound;
|
|
345
|
+
private readonly providersChangedListeners;
|
|
351
346
|
private readonly errorListeners;
|
|
352
|
-
private readonly capabilityListeners;
|
|
353
347
|
private readonly resourceChangeListeners;
|
|
354
348
|
private runtimeAgents?;
|
|
355
349
|
private readonly activeExtensionPhases;
|
|
@@ -416,24 +410,12 @@ declare class ExtensionRunner {
|
|
|
416
410
|
* Get a tool definition by name. Returns undefined if not found.
|
|
417
411
|
*/
|
|
418
412
|
getToolDefinition(toolName: string): RegisteredTool["definition"] | undefined;
|
|
419
|
-
/** Get all contributed capabilities across all extensions. */
|
|
420
|
-
getCapabilities(): readonly ExtensionCapability[];
|
|
421
|
-
/**
|
|
422
|
-
* Subscribe to capability changes (contributions added, removed, or extensions disposed).
|
|
423
|
-
* Returns an unsubscribe function.
|
|
424
|
-
*/
|
|
425
|
-
onCapabilitiesChanged(listener: (capabilities: readonly ExtensionCapability[]) => void): () => void;
|
|
426
413
|
/**
|
|
427
414
|
* Subscribe to resource changes (tools, phases, skills registered, unregistered, or disposed).
|
|
428
415
|
* Used by RuntimeBootstrapRegistry to re-commit implicit sources after activation.
|
|
429
416
|
*/
|
|
430
417
|
onResourceChange(listener: (kind: "tool" | "phase" | "skill") => Promise<void> | void): () => void;
|
|
431
418
|
private notifyResourceChange;
|
|
432
|
-
triggerUiAction(event: {
|
|
433
|
-
contributionId: string;
|
|
434
|
-
actionId: string;
|
|
435
|
-
scope?: ScopeRef;
|
|
436
|
-
}): void;
|
|
437
419
|
getPhase(name: string): Phase | undefined;
|
|
438
420
|
getPhases(): Phase[];
|
|
439
421
|
getRegisteredPhases(): readonly RegisteredPhase[];
|
|
@@ -507,8 +489,6 @@ declare class ExtensionRunner {
|
|
|
507
489
|
private createExtensionAPI;
|
|
508
490
|
private registerTool;
|
|
509
491
|
private unregisterTool;
|
|
510
|
-
private contributeCapability;
|
|
511
|
-
private notifyCapabilitiesChanged;
|
|
512
492
|
private registerPhase;
|
|
513
493
|
private registerPhaseDefinition;
|
|
514
494
|
private unregisterPhase;
|
|
@@ -517,6 +497,9 @@ declare class ExtensionRunner {
|
|
|
517
497
|
private registerSkillDefinition;
|
|
518
498
|
private unregisterSkill;
|
|
519
499
|
private loadRegisteredSkill;
|
|
500
|
+
/** Called after a Provider registration change has been applied to the model registry. */
|
|
501
|
+
onProvidersChanged(listener: () => void): () => void;
|
|
502
|
+
private notifyProvidersChanged;
|
|
520
503
|
private registerProvider;
|
|
521
504
|
private unregisterProvider;
|
|
522
505
|
private flushPendingProviders;
|
|
@@ -1288,13 +1271,8 @@ interface AgentRuntime {
|
|
|
1288
1271
|
signal: AbortSignal;
|
|
1289
1272
|
}>): void | Promise<void>;
|
|
1290
1273
|
}): Promise<DurableConsumer>;
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
triggerUiAction(event: {
|
|
1294
|
-
contributionId: string;
|
|
1295
|
-
actionId: string;
|
|
1296
|
-
scope?: ScopeRef;
|
|
1297
|
-
}): void;
|
|
1274
|
+
/** Called after an Extension registers, replaces or unregisters a Provider in the model registry. */
|
|
1275
|
+
onProvidersChanged(listener: () => void): () => void;
|
|
1298
1276
|
close(): Promise<void>;
|
|
1299
1277
|
}
|
|
1300
1278
|
type ConsumerRegistration = Readonly<{
|
|
@@ -1437,18 +1415,6 @@ interface HostApiExtension {
|
|
|
1437
1415
|
readonly namespaces: Readonly<Record<string, unknown>>;
|
|
1438
1416
|
dispose?(): void;
|
|
1439
1417
|
}
|
|
1440
|
-
type ExtensionToolContribution = {
|
|
1441
|
-
kind: "tool";
|
|
1442
|
-
name: string;
|
|
1443
|
-
description: string;
|
|
1444
|
-
};
|
|
1445
|
-
type ExtensionCapabilityContribution = ExtensionToolContribution;
|
|
1446
|
-
type ExtensionCapability = {
|
|
1447
|
-
extensionId: string;
|
|
1448
|
-
kind: "tool";
|
|
1449
|
-
name: string;
|
|
1450
|
-
description: string;
|
|
1451
|
-
};
|
|
1452
1418
|
interface SourceInfo {
|
|
1453
1419
|
source: string;
|
|
1454
1420
|
baseDir?: string;
|
|
@@ -1630,17 +1596,15 @@ interface ExtensionAgentsRuntimeDelegate {
|
|
|
1630
1596
|
* ```
|
|
1631
1597
|
*/
|
|
1632
1598
|
interface ExtensionAPI {
|
|
1633
|
-
/** Hook events — subscribe
|
|
1599
|
+
/** Hook events — subscribe; Rowan removes subscriptions when the Extension is disposed. */
|
|
1634
1600
|
hooks: {
|
|
1635
1601
|
/**
|
|
1636
|
-
* Subscribe to a hook event.
|
|
1602
|
+
* Subscribe to a hook event. Returns an unsubscribe function.
|
|
1637
1603
|
*
|
|
1638
1604
|
* @param eventType - Hook type, e.g. "before_tool_call"
|
|
1639
1605
|
* @param handler - Hook handler, can return result to modify behavior
|
|
1640
1606
|
*/
|
|
1641
|
-
on<K extends HookEventType>(eventType: K, handler: HookHandler<K>): void;
|
|
1642
|
-
/** Unsubscribe from a hook event. */
|
|
1643
|
-
off<K extends HookEventType>(eventType: K, handler: HookHandler<K>): void;
|
|
1607
|
+
on<K extends HookEventType>(eventType: K, handler: HookHandler<K>): () => void;
|
|
1644
1608
|
};
|
|
1645
1609
|
/** Extension configuration — read own layered config or listen for changes. */
|
|
1646
1610
|
config: {
|
|
@@ -1692,21 +1656,15 @@ interface ExtensionAPI {
|
|
|
1692
1656
|
agents: ExtensionAgentsAPI;
|
|
1693
1657
|
/** Shared event bus for inter-extension communication. */
|
|
1694
1658
|
events: EventBus;
|
|
1695
|
-
/** Capability contributions — advertise tools or features to the host. */
|
|
1696
|
-
capabilities: {
|
|
1697
|
-
/** Contribute a capability to the host. Returns a disposer to remove the contribution. */
|
|
1698
|
-
contribute(contribution: ExtensionCapabilityContribution): () => void;
|
|
1699
|
-
};
|
|
1700
1659
|
/** Runtime context — cwd, signal, exec. */
|
|
1701
1660
|
context: ExtensionContext;
|
|
1702
1661
|
}
|
|
1703
1662
|
/**
|
|
1704
1663
|
* Extension factory function.
|
|
1705
|
-
* Receives ExtensionAPI for registering hooks, phases, and providers.
|
|
1664
|
+
* Receives ExtensionAPI for registering hooks, phases, and providers. Return a cleanup
|
|
1665
|
+
* function only for resources the Extension owns itself; Rowan removes every registration.
|
|
1706
1666
|
*/
|
|
1707
|
-
type
|
|
1708
|
-
type ExtensionFactoryResult = void | ExtensionDisposer;
|
|
1709
|
-
type ExtensionFactory = (api: ExtensionAPI) => ExtensionFactoryResult | Promise<ExtensionFactoryResult>;
|
|
1667
|
+
type ExtensionFactory = (api: ExtensionAPI) => void | (() => void | Promise<void>) | Promise<void | (() => void | Promise<void>)>;
|
|
1710
1668
|
|
|
1711
1669
|
type PhaseStatusState = "running" | "completed";
|
|
1712
1670
|
/** Normalized status event exposed to Runtime consumers. */
|
|
@@ -2257,4 +2215,4 @@ declare class RunInteractionBoundary extends Error {
|
|
|
2257
2215
|
constructor(state: ExecutionState, interactions: readonly RunInteraction[]);
|
|
2258
2216
|
}
|
|
2259
2217
|
|
|
2260
|
-
export { type
|
|
2218
|
+
export { type ExecutionCheckpoint as $, type AgentRuntime as A, type DurableStore as B, type ContextStatus as C, type DurableRunEvent as D, type ExtensionHost as E, type AgentRecord as F, type RunRecord as G, type HostApiExtension as H, type InvocationSource as I, type ToolCallSnapshot as J, type ContextCompactionRecord as K, type LoadInput as L, type MessageId as M, type OwnedStore as N, type OwnerLease as O, type Phase as P, type ConfigToken as Q, type ResourceKind as R, type Skill as S, type Tool as T, type UserContent as U, type ExecutionId as V, type ContextCandidate as W, type RunClaim as X, type RunFailure as Y, type ExecutionToken as Z, type AssistantMessage as _, type AgentRuntimeOptions as a, type MessageRevised as a$, type RunInteraction as a0, type ToolCommit as a1, type ToolCallReservation as a2, type ToolBatchCommit as a3, type Outcome as a4, type ConsumerRegistration as a5, type RetentionResult as a6, type ConfigProvider as a7, type ConfigurationSnapshot as a8, type ConfigPutResult as a9, isConfigurationSnapshot as aA, mergeToolCall as aB, parseAgentDefinition as aC, resolveConfigurationSnapshot as aD, type AfterToolCall as aE, type AssistantContent as aF, type BeforeToolCall as aG, type EventBus as aH, type EventId as aI, type ExecOptions as aJ, type ExecResult as aK, type ExtensionAPI as aL, type ExtensionAgentConsumerDisposer as aM, type ExtensionAgentsAPI as aN, type ExtensionContext as aO, type ExtensionFactory as aP, type ExtensionStateStore as aQ, type HookEvent as aR, type HookEventType as aS, type HookHandler as aT, type InteractionRecord as aU, type InternalModelLoopOptions as aV, type LiveInteractionEvent as aW, type MessageBase as aX, type MessageCommitted as aY, type MessageContent as aZ, type MessageDelta as a_, type ConfigResolution as aa, type PhaseRegistry as ab, type LoadedExtension as ac, type DefinitionLayer as ad, type ExtensionActivationError as ae, type ExtensionActivationResult as af, type ExtensionContribution as ag, ExtensionLifetimeError as ah, type ExtensionLifetimeErrorCode as ai, type ExtensionLoadInput as aj, type LoadExtensionsResult as ak, type ModelRetry as al, type OpaqueId as am, type OwnerToken as an, type PhaseRegistrySelection as ao, type ResolvedResourceView as ap, type ResourceDiagnostic as aq, type ResourceRef as ar, ResourceRegistry as as, ResourceRegistryError as at, type ResourceRegistryErrorCode as au, type ResourceSourceId as av, type ResourceView as aw, RuntimeBootstrapRegistry as ax, RuntimeExtensionLifetime as ay, extensionSourceId as az, type AgentDefinition as b, type ModelInvokeOutput as b0, type PhaseContext as b1, type PhaseExecution as b2, type PhaseExecutionIdentity as b3, type PhaseInput as b4, type PhaseInvocation as b5, type PhaseMessageManager as b6, type PhaseOutput as b7, type PhaseRegistration as b8, type PhaseRunHandler as b9, type ToolMessageContent as bA, type ToolResultBlock as bB, type ToolResultRecord as bC, type ToolStateChanged as bD, type ToolUseBlock as bE, type UserMessage as bF, type WithdrawnUserInput as bG, type PhaseState as ba, type PhaseStatus as bb, type PhaseStatusState as bc, type RunEndEvent as bd, RunInteractionBoundary as be, RunInteractionCancelledError as bf, type RunInteractionDriver as bg, type RunInteractionState as bh, type RunInteractionStatus as bi, type RunStartEvent as bj, type RunStateChanged as bk, type SettingsBadge as bl, type SettingsControl as bm, type SettingsDefinition as bn, type SettingsItem as bo, type SettingsOption as bp, type SettingsSection as bq, type SkillRegistration as br, type ThinkingDelta as bs, type ToolCallContext as bt, type ToolCallDelta as bu, type ToolCallPhase as bv, type ToolCallPresentationInput as bw, type ToolCallPresentationOutput as bx, type ToolInvocationContext as by, type ToolMessage as bz, type LoadResult as c, type AgentConfiguration as d, type HistorySeed as e, type AgentId as f, type AgentDeletionRequest as g, type MessageRevisionResult as h, type RunId as i, type ToolCallId as j, type EventCursor as k, type UserInput as l, type AgentRun as m, type EntryPhaseSpec as n, type AgentListCursor as o, type Page as p, type AgentSummary as q, type RunState as r, type RunListCursor as s, type RunSummary as t, type InvocationCatalogEntry as u, type DurableConsumer as v, type RunSnapshot as w, type Message as x, type RunBoundary as y, type RunEvent as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _rowan_agent_models from '@rowan-agent/models';
|
|
2
2
|
export { _rowan_agent_models as models };
|
|
3
3
|
export { AudioBlock, ContentBlock, ImageBlock, JsonObject, JsonPrimitive, JsonValue, ResourceBlock, ResourceLinkBlock, RunInteractionKind, RunInteractionRequest, ScopeRef, StreamBlock, TextBlock, ThinkingBlock, ToolResult } from '@rowan-agent/models';
|
|
4
|
-
export {
|
|
4
|
+
export { aE as AfterToolCall, f as AgentId, o as AgentListCursor, m as AgentRun, q as AgentSummary, aF as AssistantContent, _ as AssistantMessage, aG as BeforeToolCall, W as ContextCandidate, K as ContextCompactionRecord, C as ContextStatus, v as DurableConsumer, D as DurableRunEvent, aH as EventBus, k as EventCursor, aI as EventId, aJ as ExecOptions, aK as ExecResult, aL as ExtensionAPI, aM as ExtensionAgentConsumerDisposer, aN as ExtensionAgentsAPI, aO as ExtensionContext, aP as ExtensionFactory, aQ as ExtensionStateStore, aR as HookEvent, aS as HookEventType, aT as HookHandler, aU as InteractionRecord, aV as InternalModelLoopOptions, aW as LiveInteractionEvent, x as Message, aX as MessageBase, aY as MessageCommitted, aZ as MessageContent, a_ as MessageDelta, M as MessageId, a$ as MessageRevised, h as MessageRevisionResult, b0 as ModelInvokeOutput, p as Page, P as Phase, b1 as PhaseContext, b2 as PhaseExecution, b3 as PhaseExecutionIdentity, b4 as PhaseInput, b5 as PhaseInvocation, b6 as PhaseMessageManager, b7 as PhaseOutput, b8 as PhaseRegistration, b9 as PhaseRunHandler, ba as PhaseState, bb as PhaseStatus, bc as PhaseStatusState, y as RunBoundary, bd as RunEndEvent, z as RunEvent, Y as RunFailure, i as RunId, a0 as RunInteraction, be as RunInteractionBoundary, bf as RunInteractionCancelledError, bg as RunInteractionDriver, bh as RunInteractionState, bi as RunInteractionStatus, s as RunListCursor, w as RunSnapshot, bj as RunStartEvent, r as RunState, bk as RunStateChanged, t as RunSummary, bl as SettingsBadge, bm as SettingsControl, bn as SettingsDefinition, bo as SettingsItem, bp as SettingsOption, bq as SettingsSection, br as SkillRegistration, bs as ThinkingDelta, T as Tool, bt as ToolCallContext, bu as ToolCallDelta, j as ToolCallId, bv as ToolCallPhase, bw as ToolCallPresentationInput, bx as ToolCallPresentationOutput, J as ToolCallSnapshot, by as ToolInvocationContext, bz as ToolMessage, bA as ToolMessageContent, bB as ToolResultBlock, bC as ToolResultRecord, bD as ToolStateChanged, bE as ToolUseBlock, U as UserContent, l as UserInput, bF as UserMessage, bG as WithdrawnUserInput } from './index-Det5FQSu.js';
|
|
5
5
|
import 'typebox';
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as ExtensionHost, H as HostApiExtension, A as AgentRuntime$1, a as AgentRuntimeOptions, L as LoadInput, b as AgentDefinition, c as LoadResult, S as Skill, P as Phase, T as Tool, R as ResourceKind, d as AgentConfiguration, e as HistorySeed, f as AgentId, g as AgentDeletionRequest, M as MessageId, U as UserContent, h as MessageRevisionResult, i as RunId, j as ToolCallId, k as EventCursor, C as ContextStatus, l as UserInput, m as AgentRun, n as EntryPhaseSpec, o as AgentListCursor, p as Page, q as AgentSummary, r as RunState, s as RunListCursor, t as RunSummary, I as InvocationSource, u as InvocationCatalogEntry, D as DurableRunEvent, v as DurableConsumer, w as
|
|
2
|
-
export {
|
|
1
|
+
import { E as ExtensionHost, H as HostApiExtension, A as AgentRuntime$1, a as AgentRuntimeOptions, L as LoadInput, b as AgentDefinition, c as LoadResult, S as Skill, P as Phase, T as Tool, R as ResourceKind, d as AgentConfiguration, e as HistorySeed, f as AgentId, g as AgentDeletionRequest, M as MessageId, U as UserContent, h as MessageRevisionResult, i as RunId, j as ToolCallId, k as EventCursor, C as ContextStatus, l as UserInput, m as AgentRun, n as EntryPhaseSpec, o as AgentListCursor, p as Page, q as AgentSummary, r as RunState, s as RunListCursor, t as RunSummary, I as InvocationSource, u as InvocationCatalogEntry, D as DurableRunEvent, v as DurableConsumer, w as RunSnapshot, x as Message, y as RunBoundary, z as RunEvent, B as DurableStore, F as AgentRecord, G as RunRecord, J as ToolCallSnapshot, K as ContextCompactionRecord, O as OwnerLease, N as OwnedStore, Q as ConfigToken, V as ExecutionId, W as ContextCandidate, X as RunClaim, Y as RunFailure, Z as ExecutionToken, _ as AssistantMessage, $ as ExecutionCheckpoint, a0 as RunInteraction, a1 as ToolCommit, a2 as ToolCallReservation, a3 as ToolBatchCommit, a4 as Outcome, a5 as ConsumerRegistration, a6 as RetentionResult, a7 as ConfigProvider, a8 as ConfigurationSnapshot, a9 as ConfigPutResult, aa as ConfigResolution, ab as PhaseRegistry, ac as LoadedExtension } from './index-Det5FQSu.js';
|
|
2
|
+
export { ad as DefinitionLayer, ae as ExtensionActivationError, af as ExtensionActivationResult, ag as ExtensionContribution, ah as ExtensionLifetimeError, ai as ExtensionLifetimeErrorCode, aj as ExtensionLoadInput, ak as LoadExtensionsResult, al as ModelRetry, am as OpaqueId, an as OwnerToken, ao as PhaseRegistrySelection, ap as ResolvedResourceView, aq as ResourceDiagnostic, ar as ResourceRef, as as ResourceRegistry, at as ResourceRegistryError, au as ResourceRegistryErrorCode, av as ResourceSourceId, aw as ResourceView, ax as RuntimeBootstrapRegistry, ay as RuntimeExtensionLifetime, az as extensionSourceId, aA as isConfigurationSnapshot, aB as mergeToolCall, aC as parseAgentDefinition, aD as resolveConfigurationSnapshot } from './index-Det5FQSu.js';
|
|
3
3
|
import * as _rowan_agent_models from '@rowan-agent/models';
|
|
4
4
|
import { JsonObject, JsonValue, ScopeRef, ModelRef, LlmTokenUsage, StreamBlock, ToolKind, ToolCallLocation, ToolCallContent, ToolResult, ToolCall, ToolCallUpdate } from '@rowan-agent/models';
|
|
5
5
|
import 'typebox';
|
|
@@ -135,14 +135,8 @@ declare class AgentRuntime implements AgentRuntime$1 {
|
|
|
135
135
|
signal: AbortSignal;
|
|
136
136
|
}>): void | Promise<void>;
|
|
137
137
|
}): Promise<DurableConsumer>;
|
|
138
|
-
listCapabilities(): readonly ExtensionCapability[];
|
|
139
|
-
onCapabilitiesChanged(listener: (capabilities: readonly ExtensionCapability[]) => void): () => void;
|
|
140
|
-
triggerUiAction(event: {
|
|
141
|
-
contributionId: string;
|
|
142
|
-
actionId: string;
|
|
143
|
-
scope?: ScopeRef;
|
|
144
|
-
}): void;
|
|
145
138
|
private liveInteract;
|
|
139
|
+
onProvidersChanged(listener: () => void): () => void;
|
|
146
140
|
close(): Promise<void>;
|
|
147
141
|
snapshot(runId: RunId): Promise<RunSnapshot>;
|
|
148
142
|
history(agentId: AgentId): Promise<readonly Message[]>;
|
package/dist/runtime.js
CHANGED
|
@@ -7300,11 +7300,9 @@ function createExtensionAPI(hooks, options, runtime, eventBus) {
|
|
|
7300
7300
|
on: (eventType, handler) => {
|
|
7301
7301
|
assertActive();
|
|
7302
7302
|
hooks?.on(eventType, handler);
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
assertActive();
|
|
7307
|
-
hooks?.off(eventType, handler);
|
|
7303
|
+
const unsubscribe = () => hooks?.off(eventType, handler);
|
|
7304
|
+
trackCleanup?.(unsubscribe);
|
|
7305
|
+
return unsubscribe;
|
|
7308
7306
|
}
|
|
7309
7307
|
},
|
|
7310
7308
|
config: {
|
|
@@ -7488,33 +7486,10 @@ function createExtensionAPI(hooks, options, runtime, eventBus) {
|
|
|
7488
7486
|
trackCleanup?.(unsubscribe);
|
|
7489
7487
|
return unsubscribe;
|
|
7490
7488
|
},
|
|
7491
|
-
|
|
7492
|
-
emit: (event, ...args) => eventBus.emit(event, ...args),
|
|
7493
|
-
has: (event) => eventBus.has(event),
|
|
7494
|
-
count: (event) => eventBus.count(event)
|
|
7489
|
+
emit: (event, ...args) => eventBus.emit(event, ...args)
|
|
7495
7490
|
} : { on: () => () => {
|
|
7496
|
-
}, off: () => {
|
|
7497
7491
|
}, emit: () => {
|
|
7498
|
-
}
|
|
7499
|
-
capabilities: {
|
|
7500
|
-
contribute: (contribution) => {
|
|
7501
|
-
assertActive();
|
|
7502
|
-
if (!contribution || typeof contribution !== "object") {
|
|
7503
|
-
throw new TypeError("Capability contribution must be an object.");
|
|
7504
|
-
}
|
|
7505
|
-
if (contribution.kind !== "tool") {
|
|
7506
|
-
throw new TypeError(`Unsupported capability contribution kind: "${contribution.kind}".`);
|
|
7507
|
-
}
|
|
7508
|
-
if (typeof contribution.name !== "string" || contribution.name.trim() === "") {
|
|
7509
|
-
throw new TypeError("Capability contribution requires a non-empty name.");
|
|
7510
|
-
}
|
|
7511
|
-
if (typeof contribution.description !== "string") {
|
|
7512
|
-
throw new TypeError("Capability contribution requires a description string.");
|
|
7513
|
-
}
|
|
7514
|
-
return options?.contributeCapability ? options.contributeCapability(contribution) : () => {
|
|
7515
|
-
};
|
|
7516
|
-
}
|
|
7517
|
-
},
|
|
7492
|
+
} },
|
|
7518
7493
|
context: ctx
|
|
7519
7494
|
};
|
|
7520
7495
|
if (options?.namespaces) {
|
|
@@ -7769,20 +7744,6 @@ function createEventBus() {
|
|
|
7769
7744
|
console.error(`[event-bus] Listener error for "${event}":`, err);
|
|
7770
7745
|
}
|
|
7771
7746
|
}
|
|
7772
|
-
},
|
|
7773
|
-
off(event) {
|
|
7774
|
-
if (event) {
|
|
7775
|
-
listeners.delete(event);
|
|
7776
|
-
} else {
|
|
7777
|
-
listeners.clear();
|
|
7778
|
-
}
|
|
7779
|
-
},
|
|
7780
|
-
has(event) {
|
|
7781
|
-
const set = listeners.get(event);
|
|
7782
|
-
return set !== void 0 && set.size > 0;
|
|
7783
|
-
},
|
|
7784
|
-
count(event) {
|
|
7785
|
-
return listeners.get(event)?.size ?? 0;
|
|
7786
7747
|
}
|
|
7787
7748
|
};
|
|
7788
7749
|
}
|
|
@@ -7879,10 +7840,9 @@ var ExtensionRunner = class {
|
|
|
7879
7840
|
// Provider management
|
|
7880
7841
|
pendingProviders = [];
|
|
7881
7842
|
bound = false;
|
|
7843
|
+
providersChangedListeners = /* @__PURE__ */ new Set();
|
|
7882
7844
|
// Error listeners
|
|
7883
7845
|
errorListeners = /* @__PURE__ */ new Set();
|
|
7884
|
-
// Capability change listeners
|
|
7885
|
-
capabilityListeners = /* @__PURE__ */ new Set();
|
|
7886
7846
|
// Resource change listeners (for Registry live sync)
|
|
7887
7847
|
resourceChangeListeners = /* @__PURE__ */ new Set();
|
|
7888
7848
|
runtimeAgents;
|
|
@@ -7994,7 +7954,6 @@ var ExtensionRunner = class {
|
|
|
7994
7954
|
tools: /* @__PURE__ */ new Map(),
|
|
7995
7955
|
phases: /* @__PURE__ */ new Set(),
|
|
7996
7956
|
skills: /* @__PURE__ */ new Set(),
|
|
7997
|
-
capabilities: /* @__PURE__ */ new Map(),
|
|
7998
7957
|
cleanup: [],
|
|
7999
7958
|
runtime: createExtensionRuntime(),
|
|
8000
7959
|
hostApi
|
|
@@ -8005,9 +7964,6 @@ var ExtensionRunner = class {
|
|
|
8005
7964
|
if (typeof disposer === "function") extension.disposer = disposer;
|
|
8006
7965
|
this.extensions.push(extension);
|
|
8007
7966
|
this._phaseCache = null;
|
|
8008
|
-
if (extension.capabilities.size > 0) {
|
|
8009
|
-
this.notifyCapabilitiesChanged();
|
|
8010
|
-
}
|
|
8011
7967
|
} catch (error) {
|
|
8012
7968
|
await this.rollbackExtension(extension);
|
|
8013
7969
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -8031,7 +7987,6 @@ var ExtensionRunner = class {
|
|
|
8031
7987
|
tools: /* @__PURE__ */ new Map(),
|
|
8032
7988
|
phases: /* @__PURE__ */ new Set(),
|
|
8033
7989
|
skills: /* @__PURE__ */ new Set(),
|
|
8034
|
-
capabilities: /* @__PURE__ */ new Map(),
|
|
8035
7990
|
cleanup: [],
|
|
8036
7991
|
runtime: createExtensionRuntime(),
|
|
8037
7992
|
hostApi: this.host.extendApi?.(phase.name)
|
|
@@ -8097,8 +8052,8 @@ var ExtensionRunner = class {
|
|
|
8097
8052
|
}
|
|
8098
8053
|
this.extensions.length = 0;
|
|
8099
8054
|
this.activeExtensionPhases.clear();
|
|
8100
|
-
this.capabilityListeners.clear();
|
|
8101
8055
|
this.resourceChangeListeners.clear();
|
|
8056
|
+
this.providersChangedListeners.clear();
|
|
8102
8057
|
this.phases.clear();
|
|
8103
8058
|
this._phaseCache = null;
|
|
8104
8059
|
this.skills.clear();
|
|
@@ -8174,32 +8129,6 @@ var ExtensionRunner = class {
|
|
|
8174
8129
|
}
|
|
8175
8130
|
return void 0;
|
|
8176
8131
|
}
|
|
8177
|
-
// ---------------------------------------------------------------------------
|
|
8178
|
-
// Capability management
|
|
8179
|
-
// ---------------------------------------------------------------------------
|
|
8180
|
-
/** Get all contributed capabilities across all extensions. */
|
|
8181
|
-
getCapabilities() {
|
|
8182
|
-
const result = [];
|
|
8183
|
-
for (const ext of this.extensions) {
|
|
8184
|
-
for (const contrib of ext.capabilities.values()) {
|
|
8185
|
-
result.push({
|
|
8186
|
-
extensionId: ext.id,
|
|
8187
|
-
kind: contrib.kind,
|
|
8188
|
-
name: contrib.name,
|
|
8189
|
-
description: contrib.description
|
|
8190
|
-
});
|
|
8191
|
-
}
|
|
8192
|
-
}
|
|
8193
|
-
return Object.freeze(result);
|
|
8194
|
-
}
|
|
8195
|
-
/**
|
|
8196
|
-
* Subscribe to capability changes (contributions added, removed, or extensions disposed).
|
|
8197
|
-
* Returns an unsubscribe function.
|
|
8198
|
-
*/
|
|
8199
|
-
onCapabilitiesChanged(listener) {
|
|
8200
|
-
this.capabilityListeners.add(listener);
|
|
8201
|
-
return () => this.capabilityListeners.delete(listener);
|
|
8202
|
-
}
|
|
8203
8132
|
/**
|
|
8204
8133
|
* Subscribe to resource changes (tools, phases, skills registered, unregistered, or disposed).
|
|
8205
8134
|
* Used by RuntimeBootstrapRegistry to re-commit implicit sources after activation.
|
|
@@ -8214,9 +8143,6 @@ var ExtensionRunner = class {
|
|
|
8214
8143
|
await listener(kind);
|
|
8215
8144
|
}
|
|
8216
8145
|
}
|
|
8217
|
-
triggerUiAction(event) {
|
|
8218
|
-
this.events.emit("ui.action", event);
|
|
8219
|
-
}
|
|
8220
8146
|
// ---------------------------------------------------------------------------
|
|
8221
8147
|
// Phase management
|
|
8222
8148
|
// ---------------------------------------------------------------------------
|
|
@@ -8412,7 +8338,6 @@ var ExtensionRunner = class {
|
|
|
8412
8338
|
unregisterProvider: (name) => this.unregisterProvider(name),
|
|
8413
8339
|
registerTool: (tool, scope) => this.registerTool(extension, tool, scope),
|
|
8414
8340
|
unregisterTool: (toolName, scope) => this.unregisterTool(extension, toolName, scope),
|
|
8415
|
-
contributeCapability: (contribution) => this.contributeCapability(extension, contribution),
|
|
8416
8341
|
context: extContext,
|
|
8417
8342
|
namespaces,
|
|
8418
8343
|
runtimeAgents: this.runtimeAgents,
|
|
@@ -8493,46 +8418,6 @@ var ExtensionRunner = class {
|
|
|
8493
8418
|
if (!extension.tools.delete(regKey)) return Promise.resolve();
|
|
8494
8419
|
return this.notifyResourceChange("tool");
|
|
8495
8420
|
}
|
|
8496
|
-
contributeCapability(extension, contribution) {
|
|
8497
|
-
const key = `${contribution.kind}:${contribution.name}`;
|
|
8498
|
-
const entry = {
|
|
8499
|
-
kind: contribution.kind,
|
|
8500
|
-
name: contribution.name,
|
|
8501
|
-
description: contribution.description
|
|
8502
|
-
};
|
|
8503
|
-
extension.capabilities.set(key, entry);
|
|
8504
|
-
if (this.extensions.includes(extension)) {
|
|
8505
|
-
this.notifyCapabilitiesChanged();
|
|
8506
|
-
}
|
|
8507
|
-
let disposed = false;
|
|
8508
|
-
const dispose = () => {
|
|
8509
|
-
if (disposed) return;
|
|
8510
|
-
disposed = true;
|
|
8511
|
-
if (extension.capabilities.get(key) === entry) {
|
|
8512
|
-
extension.capabilities.delete(key);
|
|
8513
|
-
if (this.extensions.includes(extension)) {
|
|
8514
|
-
this.notifyCapabilitiesChanged();
|
|
8515
|
-
}
|
|
8516
|
-
}
|
|
8517
|
-
};
|
|
8518
|
-
extension.cleanup.push(dispose);
|
|
8519
|
-
return dispose;
|
|
8520
|
-
}
|
|
8521
|
-
notifyCapabilitiesChanged() {
|
|
8522
|
-
const capabilities = this.getCapabilities();
|
|
8523
|
-
for (const listener of this.capabilityListeners) {
|
|
8524
|
-
try {
|
|
8525
|
-
listener(capabilities);
|
|
8526
|
-
} catch (error) {
|
|
8527
|
-
this.emitError({
|
|
8528
|
-
extensionPath: "<runtime>",
|
|
8529
|
-
event: "capabilities_changed",
|
|
8530
|
-
error: error instanceof Error ? error.message : String(error),
|
|
8531
|
-
stack: error instanceof Error ? error.stack : void 0
|
|
8532
|
-
});
|
|
8533
|
-
}
|
|
8534
|
-
}
|
|
8535
|
-
}
|
|
8536
8421
|
async registerPhase(extension, registration, scope) {
|
|
8537
8422
|
if (typeof registration === "string") {
|
|
8538
8423
|
if (registration.length === 0) {
|
|
@@ -8632,9 +8517,24 @@ var ExtensionRunner = class {
|
|
|
8632
8517
|
const skill = await loadSkill(resolve5(extensionBase, registration));
|
|
8633
8518
|
await this.registerSkillDefinition(extension, skill, scope);
|
|
8634
8519
|
}
|
|
8520
|
+
/** Called after a Provider registration change has been applied to the model registry. */
|
|
8521
|
+
onProvidersChanged(listener) {
|
|
8522
|
+
this.providersChangedListeners.add(listener);
|
|
8523
|
+
return () => this.providersChangedListeners.delete(listener);
|
|
8524
|
+
}
|
|
8525
|
+
notifyProvidersChanged() {
|
|
8526
|
+
for (const listener of this.providersChangedListeners) {
|
|
8527
|
+
try {
|
|
8528
|
+
listener();
|
|
8529
|
+
} catch (err) {
|
|
8530
|
+
console.error("[extension-runner] Providers-changed listener failed:", err);
|
|
8531
|
+
}
|
|
8532
|
+
}
|
|
8533
|
+
}
|
|
8635
8534
|
registerProvider(config) {
|
|
8636
8535
|
if (this.bound) {
|
|
8637
8536
|
applyProviderRegistration(config);
|
|
8537
|
+
this.notifyProvidersChanged();
|
|
8638
8538
|
} else {
|
|
8639
8539
|
this.pendingProviders.push({ kind: "register", config });
|
|
8640
8540
|
}
|
|
@@ -8642,6 +8542,7 @@ var ExtensionRunner = class {
|
|
|
8642
8542
|
unregisterProvider(name) {
|
|
8643
8543
|
if (this.bound) {
|
|
8644
8544
|
applyProviderUnregistration(name);
|
|
8545
|
+
this.notifyProvidersChanged();
|
|
8645
8546
|
} else {
|
|
8646
8547
|
this.pendingProviders.push({ kind: "unregister", name });
|
|
8647
8548
|
}
|
|
@@ -8654,7 +8555,9 @@ var ExtensionRunner = class {
|
|
|
8654
8555
|
applyProviderUnregistration(action.name);
|
|
8655
8556
|
}
|
|
8656
8557
|
}
|
|
8558
|
+
const applied = this.pendingProviders.length > 0;
|
|
8657
8559
|
this.pendingProviders.length = 0;
|
|
8560
|
+
if (applied) this.notifyProvidersChanged();
|
|
8658
8561
|
}
|
|
8659
8562
|
getRegisteredPhase(name) {
|
|
8660
8563
|
return this.collectRegisteredPhases().get(name);
|
|
@@ -8681,8 +8584,6 @@ var ExtensionRunner = class {
|
|
|
8681
8584
|
}
|
|
8682
8585
|
}
|
|
8683
8586
|
extension.skills.clear();
|
|
8684
|
-
const hadCapabilities = extension.capabilities.size > 0;
|
|
8685
|
-
extension.capabilities.clear();
|
|
8686
8587
|
for (const cleanup of [...extension.cleanup].reverse()) {
|
|
8687
8588
|
await Promise.resolve().then(() => cleanup()).catch(() => void 0);
|
|
8688
8589
|
}
|
|
@@ -8695,9 +8596,6 @@ var ExtensionRunner = class {
|
|
|
8695
8596
|
await Promise.resolve().then(() => hostDispose()).catch(() => void 0);
|
|
8696
8597
|
}
|
|
8697
8598
|
this._phaseCache = null;
|
|
8698
|
-
if (hadCapabilities) {
|
|
8699
|
-
this.notifyCapabilitiesChanged();
|
|
8700
|
-
}
|
|
8701
8599
|
if (this.bound) {
|
|
8702
8600
|
if (hadTools) await this.notifyResourceChange("tool");
|
|
8703
8601
|
if (hadPhases) await this.notifyResourceChange("phase");
|
|
@@ -9864,18 +9762,6 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
9864
9762
|
});
|
|
9865
9763
|
return { caughtUp: subscription.caughtUp.promise, done: subscription.done.promise, stop: () => controller.abort() };
|
|
9866
9764
|
}
|
|
9867
|
-
listCapabilities() {
|
|
9868
|
-
this.assertOpen();
|
|
9869
|
-
return this.resources.extensionRunner.getCapabilities();
|
|
9870
|
-
}
|
|
9871
|
-
onCapabilitiesChanged(listener) {
|
|
9872
|
-
this.assertOpen();
|
|
9873
|
-
return this.resources.extensionRunner.onCapabilitiesChanged(listener);
|
|
9874
|
-
}
|
|
9875
|
-
triggerUiAction(event) {
|
|
9876
|
-
this.assertOpen();
|
|
9877
|
-
this.resources.extensionRunner.triggerUiAction(event);
|
|
9878
|
-
}
|
|
9879
9765
|
liveInteract(runId, request, signal) {
|
|
9880
9766
|
if (signal.aborted) {
|
|
9881
9767
|
return Promise.reject(signal.reason ?? new Error("Run aborted"));
|
|
@@ -9920,6 +9806,9 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
9920
9806
|
});
|
|
9921
9807
|
});
|
|
9922
9808
|
}
|
|
9809
|
+
onProvidersChanged(listener) {
|
|
9810
|
+
return this.resources.extensionRunner.onProvidersChanged(listener);
|
|
9811
|
+
}
|
|
9923
9812
|
async close() {
|
|
9924
9813
|
if (this.closed) return;
|
|
9925
9814
|
this.closed = true;
|