@rowan-agent/agent 0.31.0 → 0.33.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-jC_-oKbx.d.ts → index-OBJCF_CO.d.ts} +10 -55
- package/dist/index.d.ts +1 -1
- package/dist/runtime.d.ts +2 -9
- package/dist/runtime.js +10 -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
|
/**
|
|
@@ -349,7 +343,6 @@ declare class ExtensionRunner {
|
|
|
349
343
|
private readonly pendingProviders;
|
|
350
344
|
private bound;
|
|
351
345
|
private readonly errorListeners;
|
|
352
|
-
private readonly capabilityListeners;
|
|
353
346
|
private readonly resourceChangeListeners;
|
|
354
347
|
private runtimeAgents?;
|
|
355
348
|
private readonly activeExtensionPhases;
|
|
@@ -416,24 +409,12 @@ declare class ExtensionRunner {
|
|
|
416
409
|
* Get a tool definition by name. Returns undefined if not found.
|
|
417
410
|
*/
|
|
418
411
|
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
412
|
/**
|
|
427
413
|
* Subscribe to resource changes (tools, phases, skills registered, unregistered, or disposed).
|
|
428
414
|
* Used by RuntimeBootstrapRegistry to re-commit implicit sources after activation.
|
|
429
415
|
*/
|
|
430
416
|
onResourceChange(listener: (kind: "tool" | "phase" | "skill") => Promise<void> | void): () => void;
|
|
431
417
|
private notifyResourceChange;
|
|
432
|
-
triggerUiAction(event: {
|
|
433
|
-
contributionId: string;
|
|
434
|
-
actionId: string;
|
|
435
|
-
scope?: ScopeRef;
|
|
436
|
-
}): void;
|
|
437
418
|
getPhase(name: string): Phase | undefined;
|
|
438
419
|
getPhases(): Phase[];
|
|
439
420
|
getRegisteredPhases(): readonly RegisteredPhase[];
|
|
@@ -507,8 +488,6 @@ declare class ExtensionRunner {
|
|
|
507
488
|
private createExtensionAPI;
|
|
508
489
|
private registerTool;
|
|
509
490
|
private unregisterTool;
|
|
510
|
-
private contributeCapability;
|
|
511
|
-
private notifyCapabilitiesChanged;
|
|
512
491
|
private registerPhase;
|
|
513
492
|
private registerPhaseDefinition;
|
|
514
493
|
private unregisterPhase;
|
|
@@ -1288,13 +1267,6 @@ interface AgentRuntime {
|
|
|
1288
1267
|
signal: AbortSignal;
|
|
1289
1268
|
}>): void | Promise<void>;
|
|
1290
1269
|
}): Promise<DurableConsumer>;
|
|
1291
|
-
listCapabilities(): readonly ExtensionCapability[];
|
|
1292
|
-
onCapabilitiesChanged(listener: (capabilities: readonly ExtensionCapability[]) => void): () => void;
|
|
1293
|
-
triggerUiAction(event: {
|
|
1294
|
-
contributionId: string;
|
|
1295
|
-
actionId: string;
|
|
1296
|
-
scope?: ScopeRef;
|
|
1297
|
-
}): void;
|
|
1298
1270
|
close(): Promise<void>;
|
|
1299
1271
|
}
|
|
1300
1272
|
type ConsumerRegistration = Readonly<{
|
|
@@ -1437,18 +1409,6 @@ interface HostApiExtension {
|
|
|
1437
1409
|
readonly namespaces: Readonly<Record<string, unknown>>;
|
|
1438
1410
|
dispose?(): void;
|
|
1439
1411
|
}
|
|
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
1412
|
interface SourceInfo {
|
|
1453
1413
|
source: string;
|
|
1454
1414
|
baseDir?: string;
|
|
@@ -1575,6 +1535,8 @@ interface ExtensionAgentsAPI {
|
|
|
1575
1535
|
after?: RunListCursor;
|
|
1576
1536
|
limit?: number;
|
|
1577
1537
|
}): Promise<Page<RunSummary, RunListCursor>>;
|
|
1538
|
+
/** One Run in full, including its outcome once it ended. */
|
|
1539
|
+
run(runId: string): Promise<RunSnapshot>;
|
|
1578
1540
|
runPhase(agentId: AgentId | string, options: {
|
|
1579
1541
|
phase: string;
|
|
1580
1542
|
payload?: JsonValue;
|
|
@@ -1601,6 +1563,7 @@ interface ExtensionAgentsRuntimeDelegate {
|
|
|
1601
1563
|
after?: RunListCursor;
|
|
1602
1564
|
limit?: number;
|
|
1603
1565
|
}): Promise<Page<RunSummary, RunListCursor>>;
|
|
1566
|
+
snapshot(runId: RunSnapshot["runId"]): Promise<RunSnapshot>;
|
|
1604
1567
|
runPhase(agentId: AgentId, options: {
|
|
1605
1568
|
phase: string;
|
|
1606
1569
|
payload?: JsonValue;
|
|
@@ -1627,17 +1590,15 @@ interface ExtensionAgentsRuntimeDelegate {
|
|
|
1627
1590
|
* ```
|
|
1628
1591
|
*/
|
|
1629
1592
|
interface ExtensionAPI {
|
|
1630
|
-
/** Hook events — subscribe
|
|
1593
|
+
/** Hook events — subscribe; Rowan removes subscriptions when the Extension is disposed. */
|
|
1631
1594
|
hooks: {
|
|
1632
1595
|
/**
|
|
1633
|
-
* Subscribe to a hook event.
|
|
1596
|
+
* Subscribe to a hook event. Returns an unsubscribe function.
|
|
1634
1597
|
*
|
|
1635
1598
|
* @param eventType - Hook type, e.g. "before_tool_call"
|
|
1636
1599
|
* @param handler - Hook handler, can return result to modify behavior
|
|
1637
1600
|
*/
|
|
1638
|
-
on<K extends HookEventType>(eventType: K, handler: HookHandler<K>): void;
|
|
1639
|
-
/** Unsubscribe from a hook event. */
|
|
1640
|
-
off<K extends HookEventType>(eventType: K, handler: HookHandler<K>): void;
|
|
1601
|
+
on<K extends HookEventType>(eventType: K, handler: HookHandler<K>): () => void;
|
|
1641
1602
|
};
|
|
1642
1603
|
/** Extension configuration — read own layered config or listen for changes. */
|
|
1643
1604
|
config: {
|
|
@@ -1689,21 +1650,15 @@ interface ExtensionAPI {
|
|
|
1689
1650
|
agents: ExtensionAgentsAPI;
|
|
1690
1651
|
/** Shared event bus for inter-extension communication. */
|
|
1691
1652
|
events: EventBus;
|
|
1692
|
-
/** Capability contributions — advertise tools or features to the host. */
|
|
1693
|
-
capabilities: {
|
|
1694
|
-
/** Contribute a capability to the host. Returns a disposer to remove the contribution. */
|
|
1695
|
-
contribute(contribution: ExtensionCapabilityContribution): () => void;
|
|
1696
|
-
};
|
|
1697
1653
|
/** Runtime context — cwd, signal, exec. */
|
|
1698
1654
|
context: ExtensionContext;
|
|
1699
1655
|
}
|
|
1700
1656
|
/**
|
|
1701
1657
|
* Extension factory function.
|
|
1702
|
-
* Receives ExtensionAPI for registering hooks, phases, and providers.
|
|
1658
|
+
* Receives ExtensionAPI for registering hooks, phases, and providers. Return a cleanup
|
|
1659
|
+
* function only for resources the Extension owns itself; Rowan removes every registration.
|
|
1703
1660
|
*/
|
|
1704
|
-
type
|
|
1705
|
-
type ExtensionFactoryResult = void | ExtensionDisposer;
|
|
1706
|
-
type ExtensionFactory = (api: ExtensionAPI) => ExtensionFactoryResult | Promise<ExtensionFactoryResult>;
|
|
1661
|
+
type ExtensionFactory = (api: ExtensionAPI) => void | (() => void | Promise<void>) | Promise<void | (() => void | Promise<void>)>;
|
|
1707
1662
|
|
|
1708
1663
|
type PhaseStatusState = "running" | "completed";
|
|
1709
1664
|
/** Normalized status event exposed to Runtime consumers. */
|
|
@@ -2254,4 +2209,4 @@ declare class RunInteractionBoundary extends Error {
|
|
|
2254
2209
|
constructor(state: ExecutionState, interactions: readonly RunInteraction[]);
|
|
2255
2210
|
}
|
|
2256
2211
|
|
|
2257
|
-
export { type
|
|
2212
|
+
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-OBJCF_CO.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-OBJCF_CO.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-OBJCF_CO.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,13 +135,6 @@ 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;
|
|
146
139
|
close(): Promise<void>;
|
|
147
140
|
snapshot(runId: RunId): Promise<RunSnapshot>;
|
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: {
|
|
@@ -7448,6 +7446,11 @@ function createExtensionAPI(hooks, options, runtime, eventBus) {
|
|
|
7448
7446
|
if (!agentsDelegate) throw new Error("AgentRuntime is not available in this extension context.");
|
|
7449
7447
|
return agentsDelegate.listRuns({ agentId, ...filter });
|
|
7450
7448
|
},
|
|
7449
|
+
run: async (runId) => {
|
|
7450
|
+
assertActive();
|
|
7451
|
+
if (!agentsDelegate) throw new Error("AgentRuntime is not available in this extension context.");
|
|
7452
|
+
return agentsDelegate.snapshot(runId);
|
|
7453
|
+
},
|
|
7451
7454
|
runPhase: async (agentId, runOpt) => {
|
|
7452
7455
|
assertActive();
|
|
7453
7456
|
if (!agentsDelegate) throw new Error("AgentRuntime is not available in this extension context.");
|
|
@@ -7483,33 +7486,10 @@ function createExtensionAPI(hooks, options, runtime, eventBus) {
|
|
|
7483
7486
|
trackCleanup?.(unsubscribe);
|
|
7484
7487
|
return unsubscribe;
|
|
7485
7488
|
},
|
|
7486
|
-
|
|
7487
|
-
emit: (event, ...args) => eventBus.emit(event, ...args),
|
|
7488
|
-
has: (event) => eventBus.has(event),
|
|
7489
|
-
count: (event) => eventBus.count(event)
|
|
7489
|
+
emit: (event, ...args) => eventBus.emit(event, ...args)
|
|
7490
7490
|
} : { on: () => () => {
|
|
7491
|
-
}, off: () => {
|
|
7492
7491
|
}, emit: () => {
|
|
7493
|
-
}
|
|
7494
|
-
capabilities: {
|
|
7495
|
-
contribute: (contribution) => {
|
|
7496
|
-
assertActive();
|
|
7497
|
-
if (!contribution || typeof contribution !== "object") {
|
|
7498
|
-
throw new TypeError("Capability contribution must be an object.");
|
|
7499
|
-
}
|
|
7500
|
-
if (contribution.kind !== "tool") {
|
|
7501
|
-
throw new TypeError(`Unsupported capability contribution kind: "${contribution.kind}".`);
|
|
7502
|
-
}
|
|
7503
|
-
if (typeof contribution.name !== "string" || contribution.name.trim() === "") {
|
|
7504
|
-
throw new TypeError("Capability contribution requires a non-empty name.");
|
|
7505
|
-
}
|
|
7506
|
-
if (typeof contribution.description !== "string") {
|
|
7507
|
-
throw new TypeError("Capability contribution requires a description string.");
|
|
7508
|
-
}
|
|
7509
|
-
return options?.contributeCapability ? options.contributeCapability(contribution) : () => {
|
|
7510
|
-
};
|
|
7511
|
-
}
|
|
7512
|
-
},
|
|
7492
|
+
} },
|
|
7513
7493
|
context: ctx
|
|
7514
7494
|
};
|
|
7515
7495
|
if (options?.namespaces) {
|
|
@@ -7764,20 +7744,6 @@ function createEventBus() {
|
|
|
7764
7744
|
console.error(`[event-bus] Listener error for "${event}":`, err);
|
|
7765
7745
|
}
|
|
7766
7746
|
}
|
|
7767
|
-
},
|
|
7768
|
-
off(event) {
|
|
7769
|
-
if (event) {
|
|
7770
|
-
listeners.delete(event);
|
|
7771
|
-
} else {
|
|
7772
|
-
listeners.clear();
|
|
7773
|
-
}
|
|
7774
|
-
},
|
|
7775
|
-
has(event) {
|
|
7776
|
-
const set = listeners.get(event);
|
|
7777
|
-
return set !== void 0 && set.size > 0;
|
|
7778
|
-
},
|
|
7779
|
-
count(event) {
|
|
7780
|
-
return listeners.get(event)?.size ?? 0;
|
|
7781
7747
|
}
|
|
7782
7748
|
};
|
|
7783
7749
|
}
|
|
@@ -7876,8 +7842,6 @@ var ExtensionRunner = class {
|
|
|
7876
7842
|
bound = false;
|
|
7877
7843
|
// Error listeners
|
|
7878
7844
|
errorListeners = /* @__PURE__ */ new Set();
|
|
7879
|
-
// Capability change listeners
|
|
7880
|
-
capabilityListeners = /* @__PURE__ */ new Set();
|
|
7881
7845
|
// Resource change listeners (for Registry live sync)
|
|
7882
7846
|
resourceChangeListeners = /* @__PURE__ */ new Set();
|
|
7883
7847
|
runtimeAgents;
|
|
@@ -7989,7 +7953,6 @@ var ExtensionRunner = class {
|
|
|
7989
7953
|
tools: /* @__PURE__ */ new Map(),
|
|
7990
7954
|
phases: /* @__PURE__ */ new Set(),
|
|
7991
7955
|
skills: /* @__PURE__ */ new Set(),
|
|
7992
|
-
capabilities: /* @__PURE__ */ new Map(),
|
|
7993
7956
|
cleanup: [],
|
|
7994
7957
|
runtime: createExtensionRuntime(),
|
|
7995
7958
|
hostApi
|
|
@@ -8000,9 +7963,6 @@ var ExtensionRunner = class {
|
|
|
8000
7963
|
if (typeof disposer === "function") extension.disposer = disposer;
|
|
8001
7964
|
this.extensions.push(extension);
|
|
8002
7965
|
this._phaseCache = null;
|
|
8003
|
-
if (extension.capabilities.size > 0) {
|
|
8004
|
-
this.notifyCapabilitiesChanged();
|
|
8005
|
-
}
|
|
8006
7966
|
} catch (error) {
|
|
8007
7967
|
await this.rollbackExtension(extension);
|
|
8008
7968
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -8026,7 +7986,6 @@ var ExtensionRunner = class {
|
|
|
8026
7986
|
tools: /* @__PURE__ */ new Map(),
|
|
8027
7987
|
phases: /* @__PURE__ */ new Set(),
|
|
8028
7988
|
skills: /* @__PURE__ */ new Set(),
|
|
8029
|
-
capabilities: /* @__PURE__ */ new Map(),
|
|
8030
7989
|
cleanup: [],
|
|
8031
7990
|
runtime: createExtensionRuntime(),
|
|
8032
7991
|
hostApi: this.host.extendApi?.(phase.name)
|
|
@@ -8092,7 +8051,6 @@ var ExtensionRunner = class {
|
|
|
8092
8051
|
}
|
|
8093
8052
|
this.extensions.length = 0;
|
|
8094
8053
|
this.activeExtensionPhases.clear();
|
|
8095
|
-
this.capabilityListeners.clear();
|
|
8096
8054
|
this.resourceChangeListeners.clear();
|
|
8097
8055
|
this.phases.clear();
|
|
8098
8056
|
this._phaseCache = null;
|
|
@@ -8169,32 +8127,6 @@ var ExtensionRunner = class {
|
|
|
8169
8127
|
}
|
|
8170
8128
|
return void 0;
|
|
8171
8129
|
}
|
|
8172
|
-
// ---------------------------------------------------------------------------
|
|
8173
|
-
// Capability management
|
|
8174
|
-
// ---------------------------------------------------------------------------
|
|
8175
|
-
/** Get all contributed capabilities across all extensions. */
|
|
8176
|
-
getCapabilities() {
|
|
8177
|
-
const result = [];
|
|
8178
|
-
for (const ext of this.extensions) {
|
|
8179
|
-
for (const contrib of ext.capabilities.values()) {
|
|
8180
|
-
result.push({
|
|
8181
|
-
extensionId: ext.id,
|
|
8182
|
-
kind: contrib.kind,
|
|
8183
|
-
name: contrib.name,
|
|
8184
|
-
description: contrib.description
|
|
8185
|
-
});
|
|
8186
|
-
}
|
|
8187
|
-
}
|
|
8188
|
-
return Object.freeze(result);
|
|
8189
|
-
}
|
|
8190
|
-
/**
|
|
8191
|
-
* Subscribe to capability changes (contributions added, removed, or extensions disposed).
|
|
8192
|
-
* Returns an unsubscribe function.
|
|
8193
|
-
*/
|
|
8194
|
-
onCapabilitiesChanged(listener) {
|
|
8195
|
-
this.capabilityListeners.add(listener);
|
|
8196
|
-
return () => this.capabilityListeners.delete(listener);
|
|
8197
|
-
}
|
|
8198
8130
|
/**
|
|
8199
8131
|
* Subscribe to resource changes (tools, phases, skills registered, unregistered, or disposed).
|
|
8200
8132
|
* Used by RuntimeBootstrapRegistry to re-commit implicit sources after activation.
|
|
@@ -8209,9 +8141,6 @@ var ExtensionRunner = class {
|
|
|
8209
8141
|
await listener(kind);
|
|
8210
8142
|
}
|
|
8211
8143
|
}
|
|
8212
|
-
triggerUiAction(event) {
|
|
8213
|
-
this.events.emit("ui.action", event);
|
|
8214
|
-
}
|
|
8215
8144
|
// ---------------------------------------------------------------------------
|
|
8216
8145
|
// Phase management
|
|
8217
8146
|
// ---------------------------------------------------------------------------
|
|
@@ -8407,7 +8336,6 @@ var ExtensionRunner = class {
|
|
|
8407
8336
|
unregisterProvider: (name) => this.unregisterProvider(name),
|
|
8408
8337
|
registerTool: (tool, scope) => this.registerTool(extension, tool, scope),
|
|
8409
8338
|
unregisterTool: (toolName, scope) => this.unregisterTool(extension, toolName, scope),
|
|
8410
|
-
contributeCapability: (contribution) => this.contributeCapability(extension, contribution),
|
|
8411
8339
|
context: extContext,
|
|
8412
8340
|
namespaces,
|
|
8413
8341
|
runtimeAgents: this.runtimeAgents,
|
|
@@ -8488,46 +8416,6 @@ var ExtensionRunner = class {
|
|
|
8488
8416
|
if (!extension.tools.delete(regKey)) return Promise.resolve();
|
|
8489
8417
|
return this.notifyResourceChange("tool");
|
|
8490
8418
|
}
|
|
8491
|
-
contributeCapability(extension, contribution) {
|
|
8492
|
-
const key = `${contribution.kind}:${contribution.name}`;
|
|
8493
|
-
const entry = {
|
|
8494
|
-
kind: contribution.kind,
|
|
8495
|
-
name: contribution.name,
|
|
8496
|
-
description: contribution.description
|
|
8497
|
-
};
|
|
8498
|
-
extension.capabilities.set(key, entry);
|
|
8499
|
-
if (this.extensions.includes(extension)) {
|
|
8500
|
-
this.notifyCapabilitiesChanged();
|
|
8501
|
-
}
|
|
8502
|
-
let disposed = false;
|
|
8503
|
-
const dispose = () => {
|
|
8504
|
-
if (disposed) return;
|
|
8505
|
-
disposed = true;
|
|
8506
|
-
if (extension.capabilities.get(key) === entry) {
|
|
8507
|
-
extension.capabilities.delete(key);
|
|
8508
|
-
if (this.extensions.includes(extension)) {
|
|
8509
|
-
this.notifyCapabilitiesChanged();
|
|
8510
|
-
}
|
|
8511
|
-
}
|
|
8512
|
-
};
|
|
8513
|
-
extension.cleanup.push(dispose);
|
|
8514
|
-
return dispose;
|
|
8515
|
-
}
|
|
8516
|
-
notifyCapabilitiesChanged() {
|
|
8517
|
-
const capabilities = this.getCapabilities();
|
|
8518
|
-
for (const listener of this.capabilityListeners) {
|
|
8519
|
-
try {
|
|
8520
|
-
listener(capabilities);
|
|
8521
|
-
} catch (error) {
|
|
8522
|
-
this.emitError({
|
|
8523
|
-
extensionPath: "<runtime>",
|
|
8524
|
-
event: "capabilities_changed",
|
|
8525
|
-
error: error instanceof Error ? error.message : String(error),
|
|
8526
|
-
stack: error instanceof Error ? error.stack : void 0
|
|
8527
|
-
});
|
|
8528
|
-
}
|
|
8529
|
-
}
|
|
8530
|
-
}
|
|
8531
8419
|
async registerPhase(extension, registration, scope) {
|
|
8532
8420
|
if (typeof registration === "string") {
|
|
8533
8421
|
if (registration.length === 0) {
|
|
@@ -8676,8 +8564,6 @@ var ExtensionRunner = class {
|
|
|
8676
8564
|
}
|
|
8677
8565
|
}
|
|
8678
8566
|
extension.skills.clear();
|
|
8679
|
-
const hadCapabilities = extension.capabilities.size > 0;
|
|
8680
|
-
extension.capabilities.clear();
|
|
8681
8567
|
for (const cleanup of [...extension.cleanup].reverse()) {
|
|
8682
8568
|
await Promise.resolve().then(() => cleanup()).catch(() => void 0);
|
|
8683
8569
|
}
|
|
@@ -8690,9 +8576,6 @@ var ExtensionRunner = class {
|
|
|
8690
8576
|
await Promise.resolve().then(() => hostDispose()).catch(() => void 0);
|
|
8691
8577
|
}
|
|
8692
8578
|
this._phaseCache = null;
|
|
8693
|
-
if (hadCapabilities) {
|
|
8694
|
-
this.notifyCapabilitiesChanged();
|
|
8695
|
-
}
|
|
8696
8579
|
if (this.bound) {
|
|
8697
8580
|
if (hadTools) await this.notifyResourceChange("tool");
|
|
8698
8581
|
if (hadPhases) await this.notifyResourceChange("phase");
|
|
@@ -9859,18 +9742,6 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
9859
9742
|
});
|
|
9860
9743
|
return { caughtUp: subscription.caughtUp.promise, done: subscription.done.promise, stop: () => controller.abort() };
|
|
9861
9744
|
}
|
|
9862
|
-
listCapabilities() {
|
|
9863
|
-
this.assertOpen();
|
|
9864
|
-
return this.resources.extensionRunner.getCapabilities();
|
|
9865
|
-
}
|
|
9866
|
-
onCapabilitiesChanged(listener) {
|
|
9867
|
-
this.assertOpen();
|
|
9868
|
-
return this.resources.extensionRunner.onCapabilitiesChanged(listener);
|
|
9869
|
-
}
|
|
9870
|
-
triggerUiAction(event) {
|
|
9871
|
-
this.assertOpen();
|
|
9872
|
-
this.resources.extensionRunner.triggerUiAction(event);
|
|
9873
|
-
}
|
|
9874
9745
|
liveInteract(runId, request, signal) {
|
|
9875
9746
|
if (signal.aborted) {
|
|
9876
9747
|
return Promise.reject(signal.reason ?? new Error("Run aborted"));
|