@rowan-agent/agent 0.21.0 → 0.22.1
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 +13 -26
- package/dist/index.js +28 -105
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -289,10 +289,12 @@ declare class InMemoryExtensionHost implements ExtensionHost {
|
|
|
289
289
|
private readonly agentState;
|
|
290
290
|
private readonly globalState;
|
|
291
291
|
private readonly listeners;
|
|
292
|
+
extendApi?(extensionId: string): HostApiExtension | undefined;
|
|
292
293
|
constructor(options?: {
|
|
293
294
|
configs?: Record<string, Record<string, JsonObject>>;
|
|
294
295
|
agentState?: Record<string, Record<string, Record<string, JsonValue>>>;
|
|
295
296
|
globalState?: Record<string, Record<string, JsonValue>>;
|
|
297
|
+
extendApi?: (extensionId: string) => HostApiExtension | undefined;
|
|
296
298
|
});
|
|
297
299
|
setConfig(extensionId: string, config: JsonObject | null, scope?: ScopeRef): void;
|
|
298
300
|
getConfig(extensionId: string, scope?: ScopeRef): JsonObject | null;
|
|
@@ -370,7 +372,6 @@ declare class ExtensionRunner {
|
|
|
370
372
|
private bound;
|
|
371
373
|
private readonly errorListeners;
|
|
372
374
|
private readonly capabilityListeners;
|
|
373
|
-
private readonly hostContributionListeners;
|
|
374
375
|
/** Current agent context — set by the agent before each phase */
|
|
375
376
|
currentContext?: AgentContext;
|
|
376
377
|
constructor(options?: ExtensionRunnerOptions);
|
|
@@ -436,13 +437,6 @@ declare class ExtensionRunner {
|
|
|
436
437
|
* Returns an unsubscribe function.
|
|
437
438
|
*/
|
|
438
439
|
onCapabilitiesChanged(listener: (capabilities: readonly ExtensionCapability[]) => void): () => void;
|
|
439
|
-
/** Get all contributed host elements across all extensions. */
|
|
440
|
-
getHostContributions(): readonly HostContribution[];
|
|
441
|
-
/**
|
|
442
|
-
* Subscribe to host contribution changes (contributions added, removed, or extensions disposed).
|
|
443
|
-
* Returns an unsubscribe function.
|
|
444
|
-
*/
|
|
445
|
-
onHostContributionsChanged(listener: (contributions: readonly HostContribution[]) => void): () => void;
|
|
446
440
|
triggerUiAction(event: {
|
|
447
441
|
contributionId: string;
|
|
448
442
|
actionId: string;
|
|
@@ -517,8 +511,6 @@ declare class ExtensionRunner {
|
|
|
517
511
|
private unregisterTool;
|
|
518
512
|
private contributeCapability;
|
|
519
513
|
private notifyCapabilitiesChanged;
|
|
520
|
-
private contributeToHost;
|
|
521
|
-
private notifyHostContributionsChanged;
|
|
522
514
|
private registerPhase;
|
|
523
515
|
private registerPhaseDefinition;
|
|
524
516
|
private unregisterPhase;
|
|
@@ -1276,8 +1268,6 @@ interface AgentRuntime$1 {
|
|
|
1276
1268
|
}): Promise<DurableConsumer>;
|
|
1277
1269
|
listCapabilities(): readonly ExtensionCapability[];
|
|
1278
1270
|
onCapabilitiesChanged(listener: (capabilities: readonly ExtensionCapability[]) => void): () => void;
|
|
1279
|
-
listHostContributions(): readonly HostContribution[];
|
|
1280
|
-
onHostContributionsChanged(listener: (contributions: readonly HostContribution[]) => void): () => void;
|
|
1281
1271
|
triggerUiAction(event: {
|
|
1282
1272
|
contributionId: string;
|
|
1283
1273
|
actionId: string;
|
|
@@ -1290,12 +1280,6 @@ type ConsumerRegistration = Readonly<{
|
|
|
1290
1280
|
waterline: EventCursor;
|
|
1291
1281
|
}>;
|
|
1292
1282
|
|
|
1293
|
-
type HostContribution = {
|
|
1294
|
-
readonly kind: string;
|
|
1295
|
-
readonly id: string;
|
|
1296
|
-
} & {
|
|
1297
|
-
readonly [key: string]: JsonValue;
|
|
1298
|
-
};
|
|
1299
1283
|
interface ExtensionStateStore {
|
|
1300
1284
|
get(key: string): Promise<JsonValue | undefined>;
|
|
1301
1285
|
set(key: string, value: JsonValue): Promise<void>;
|
|
@@ -1310,6 +1294,16 @@ interface ExtensionHost {
|
|
|
1310
1294
|
getGlobalState(extensionId: string, key: string): Promise<JsonValue | undefined> | JsonValue | undefined;
|
|
1311
1295
|
setGlobalState(extensionId: string, key: string, value: JsonValue): Promise<void> | void;
|
|
1312
1296
|
deleteGlobalState(extensionId: string, key: string): Promise<void> | void;
|
|
1297
|
+
/**
|
|
1298
|
+
* Called once per extension load. The returned namespaces are merged into that extension's `api`
|
|
1299
|
+
* (a name already used by Rowan's own API is an error). `dispose` runs when the extension is
|
|
1300
|
+
* unloaded, reloaded or fails activation, so the host can drop everything that extension registered.
|
|
1301
|
+
*/
|
|
1302
|
+
extendApi?(extensionId: string): HostApiExtension | undefined;
|
|
1303
|
+
}
|
|
1304
|
+
interface HostApiExtension {
|
|
1305
|
+
readonly namespaces: Readonly<Record<string, unknown>>;
|
|
1306
|
+
dispose?(): void;
|
|
1313
1307
|
}
|
|
1314
1308
|
type ExtensionToolContribution = {
|
|
1315
1309
|
kind: "tool";
|
|
@@ -1538,11 +1532,6 @@ interface ExtensionAPI {
|
|
|
1538
1532
|
/** Get the message set by setMessage */
|
|
1539
1533
|
getMessage(): string | undefined;
|
|
1540
1534
|
};
|
|
1541
|
-
/** Declarative host contributions. */
|
|
1542
|
-
host: {
|
|
1543
|
-
/** Contribute a declarative declaration to the host. Returns a disposer to remove the contribution. */
|
|
1544
|
-
contribute<T extends HostContribution>(contribution: T): () => void;
|
|
1545
|
-
};
|
|
1546
1535
|
/** Extension manifest from package.json `rowan` field. */
|
|
1547
1536
|
manifest?: ExtensionManifest;
|
|
1548
1537
|
/** Utility functions. */
|
|
@@ -2524,8 +2513,6 @@ declare class AgentRuntime implements AgentRuntime$1 {
|
|
|
2524
2513
|
}): Promise<DurableConsumer>;
|
|
2525
2514
|
listCapabilities(): readonly ExtensionCapability[];
|
|
2526
2515
|
onCapabilitiesChanged(listener: (capabilities: readonly ExtensionCapability[]) => void): () => void;
|
|
2527
|
-
listHostContributions(): readonly HostContribution[];
|
|
2528
|
-
onHostContributionsChanged(listener: (contributions: readonly HostContribution[]) => void): () => void;
|
|
2529
2516
|
triggerUiAction(event: {
|
|
2530
2517
|
contributionId: string;
|
|
2531
2518
|
actionId: string;
|
|
@@ -3344,4 +3331,4 @@ declare function parseFrontmatter<T = Record<string, unknown>>(raw: string): Fro
|
|
|
3344
3331
|
|
|
3345
3332
|
declare function createCoreTools(input?: CoreToolContext): Tool$1[];
|
|
3346
3333
|
|
|
3347
|
-
export { type AfterToolCall, type AgentConfiguration, type AgentDefinition, type AgentId, type AgentListCursor, type AgentRecord, type AgentRun, AgentRuntime, type AgentRuntimeOptions, type AgentSummary, type AnyRuntimeError, type AssistantContent, type AssistantMessage, type BeforeToolCall, COMPACT_PHASE_ID, type ConfigProvider, type ConfigPutResult, type ConfigResolution, type ConfigToken, type ConfigurationSnapshot, type ContextCandidate, type ContextCompactionRecord, type ContextStatus, type CoreToolContext, DEFAULT_PHASE_ID, type DefinitionLayer, type DurableConsumer, type DurableRunEvent, type DurableStore, type DurableToolResult, type EntryPhaseSpec, type EventCursor, type EventId, type ExecutionCheckpoint, type ExecutionId, type ExecutionToken, type ExtensionAPI, type ExtensionActivationError, type ExtensionActivationResult, type ExtensionCapability, type ExtensionCapabilityContribution, type ExtensionContribution, type ExtensionDisposer, type ExtensionFactory, type ExtensionFactoryResult, type ExtensionHost, ExtensionLifetimeError, type ExtensionLifetimeErrorCode, type ExtensionLoadInput, type ExtensionStateStore, type ExtensionToolContribution, type FrontmatterResult, type HistorySeed, type HookEvent, type HookEventType, type HookHandler, type
|
|
3334
|
+
export { type AfterToolCall, type AgentConfiguration, type AgentDefinition, type AgentId, type AgentListCursor, type AgentRecord, type AgentRun, AgentRuntime, type AgentRuntimeOptions, type AgentSummary, type AnyRuntimeError, type AssistantContent, type AssistantMessage, type BeforeToolCall, COMPACT_PHASE_ID, type ConfigProvider, type ConfigPutResult, type ConfigResolution, type ConfigToken, type ConfigurationSnapshot, type ContextCandidate, type ContextCompactionRecord, type ContextStatus, type CoreToolContext, DEFAULT_PHASE_ID, type DefinitionLayer, type DurableConsumer, type DurableRunEvent, type DurableStore, type DurableToolResult, type EntryPhaseSpec, type EventCursor, type EventId, type ExecutionCheckpoint, type ExecutionId, type ExecutionToken, type ExtensionAPI, type ExtensionActivationError, type ExtensionActivationResult, type ExtensionCapability, type ExtensionCapabilityContribution, type ExtensionContribution, type ExtensionDisposer, type ExtensionFactory, type ExtensionFactoryResult, type ExtensionHost, ExtensionLifetimeError, type ExtensionLifetimeErrorCode, type ExtensionLoadInput, type ExtensionStateStore, type ExtensionToolContribution, type FrontmatterResult, type HistorySeed, type HookEvent, type HookEventType, type HookHandler, type HostApiExtension, InMemoryConfigProvider, InMemoryExtensionHost, InMemoryStore, type InteractionRecord, type InvocationCatalogEntry, type InvocationSource, type JsonObject, type JsonPrimitive, type JsonValue, type LiveInteractionEvent, type LoadExtensionsResult, type LoadInput, type LoadResult, type LoadedExtension, type Message, type MessageBase, type MessageCommitted, type MessageContent, type MessageDelta, type MessageId, type MessageRevised, type MessageRevisionResult, type Metadata, type ModelRetry, type OpaqueId, type Outcome$1 as Outcome, type OwnerLease, type OwnerToken, type Page, type Phase, type PhaseContext, type PhaseContribution, type PhaseExecution, type PhaseExecutionIdentity, type PhaseInput, type PhaseInvocation, type PhaseMessageManager, type PhaseOutput, type PhaseRegistry, type PhaseRegistrySelection, type PhaseState, type PhaseStatus, type PhaseStatusState, type ResolvedResourceView, type ResourceDiagnostic, type ResourceKind, type ResourceRef, ResourceRegistry, ResourceRegistryError, type ResourceRegistryErrorCode, type ResourceSourceId, type ResourceView, type RetentionResult, type RunBoundary, type RunClaim, type RunEndEvent, type RunEvent, type RunFailure, type RunId, type RunInteraction, RunInteractionBoundary, RunInteractionCancelledError, type RunInteractionDriver, type RunInteractionKind, type RunInteractionRequest, type RunInteractionState, type RunInteractionStatus, type RunListCursor, type RunRecord, type RunSnapshot, type RunStartEvent, type RunState, type RunStateChanged, type RunSummary, RuntimeBootstrapRegistry, RuntimeError, type RuntimeErrorCode, type RuntimeErrorDetails, RuntimeExtensionLifetime, STOP_PHASE_ID, type SettingsBadge, type SettingsControl, type SettingsDefinition, type SettingsItem, type SettingsOption, type SettingsSection, type Skill, SqliteStore, type TextContent, type ThinkingContent, type ThinkingDelta, type Tool$1 as Tool, type ToolCallContext, type ToolCallDelta, type ToolCallId, type ToolCallPresentationInput, type ToolCallPresentationOutput, type ToolCallSnapshot, type ToolCallState, type ToolContribution, type ToolDefinition, type ToolExecutionResult, type ToolInvocationContext, type ToolMessage, type ToolMessageContent, type ToolResultContent, type ToolStateChanged, type ToolUseContent, type UserContent, type UserInput, type UserMessage, type WithdrawnUserInput, brandConfigToken, createCompactPhase, createCorePhases, createCoreTools, createDefaultPhase, createStopPhase, isConfigurationSnapshot, isRuntimeError, loadExtensionsFromPath as loadExtensions, loadPhase, loadPhases, loadSkill, loadSkills, mergeToolCall, parseAgentDefinition, parseFrontmatter, resolveConfigurationSnapshot };
|
package/dist/index.js
CHANGED
|
@@ -1620,7 +1620,7 @@ function createExtensionAPI(hooks, options, runtime, eventBus) {
|
|
|
1620
1620
|
let outputPayload = phaseIn?.state?.payload;
|
|
1621
1621
|
let nextPhase;
|
|
1622
1622
|
let outputMessage;
|
|
1623
|
-
|
|
1623
|
+
const api = {
|
|
1624
1624
|
hooks: {
|
|
1625
1625
|
on: (eventType, handler) => {
|
|
1626
1626
|
assertActive();
|
|
@@ -1783,27 +1783,17 @@ function createExtensionAPI(hooks, options, runtime, eventBus) {
|
|
|
1783
1783
|
},
|
|
1784
1784
|
getNextPhase: () => nextPhase,
|
|
1785
1785
|
getMessage: () => outputMessage
|
|
1786
|
-
},
|
|
1787
|
-
host: {
|
|
1788
|
-
contribute: (contribution) => {
|
|
1789
|
-
assertActive();
|
|
1790
|
-
if (!contribution || typeof contribution !== "object" || Array.isArray(contribution)) {
|
|
1791
|
-
throw new TypeError("Host contribution must be an object.");
|
|
1792
|
-
}
|
|
1793
|
-
if (typeof contribution.kind !== "string" || contribution.kind.trim() === "") {
|
|
1794
|
-
throw new TypeError("Host contribution requires a non-empty kind.");
|
|
1795
|
-
}
|
|
1796
|
-
if (typeof contribution.id !== "string" || contribution.id.trim() === "") {
|
|
1797
|
-
throw new TypeError("Host contribution requires a non-empty id.");
|
|
1798
|
-
}
|
|
1799
|
-
assertJsonValue(contribution, "Host contribution");
|
|
1800
|
-
const dispose = options?.contributeToHost ? options.contributeToHost(contribution) : () => {
|
|
1801
|
-
};
|
|
1802
|
-
trackCleanup?.(dispose);
|
|
1803
|
-
return dispose;
|
|
1804
|
-
}
|
|
1805
1786
|
}
|
|
1806
1787
|
};
|
|
1788
|
+
if (options?.namespaces) {
|
|
1789
|
+
for (const [key, value] of Object.entries(options.namespaces)) {
|
|
1790
|
+
if (key in api) {
|
|
1791
|
+
throw new Error(`Host API namespace collision: "${key}" is a built-in API key.`);
|
|
1792
|
+
}
|
|
1793
|
+
Object.defineProperty(api, key, { value, enumerable: true });
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
return api;
|
|
1807
1797
|
}
|
|
1808
1798
|
|
|
1809
1799
|
// src/harness/phases/interactions.ts
|
|
@@ -3512,12 +3502,10 @@ var DEFAULT_RETRY_DELAY_MS = 5e3;
|
|
|
3512
3502
|
function isRetryableError(error) {
|
|
3513
3503
|
if (!(error instanceof Error)) return false;
|
|
3514
3504
|
const message = error.message.toLowerCase();
|
|
3515
|
-
if (
|
|
3516
|
-
if (message.includes("
|
|
3517
|
-
if (message.includes("server error") || message.includes("
|
|
3518
|
-
if (message.includes("
|
|
3519
|
-
if (message.includes("service unavailable") || message.includes("503")) return true;
|
|
3520
|
-
if (message.includes("gateway timeout") || message.includes("504")) return true;
|
|
3505
|
+
if (/(?<![\d:])(429|500|502|503|504|529)(?!\d)/.test(message)) return true;
|
|
3506
|
+
if (message.includes("rate limit") || message.includes("overloaded")) return true;
|
|
3507
|
+
if (message.includes("server error") || message.includes("bad gateway")) return true;
|
|
3508
|
+
if (message.includes("service unavailable") || message.includes("gateway timeout")) return true;
|
|
3521
3509
|
if (message.includes("econnreset") || message.includes("econnrefused")) return true;
|
|
3522
3510
|
if (message.includes("socket connection was closed") || message.includes("socket hang up")) return true;
|
|
3523
3511
|
if (message.includes("fetch failed") || message.includes("etimedout")) return true;
|
|
@@ -5836,6 +5824,9 @@ var InMemoryExtensionHost = class {
|
|
|
5836
5824
|
globalState = /* @__PURE__ */ new Map();
|
|
5837
5825
|
listeners = /* @__PURE__ */ new Set();
|
|
5838
5826
|
constructor(options = {}) {
|
|
5827
|
+
if (options.extendApi) {
|
|
5828
|
+
this.extendApi = options.extendApi;
|
|
5829
|
+
}
|
|
5839
5830
|
if (options.configs) {
|
|
5840
5831
|
for (const [scopeKey, extMap] of Object.entries(options.configs)) {
|
|
5841
5832
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -6121,8 +6112,6 @@ var ExtensionRunner = class {
|
|
|
6121
6112
|
errorListeners = /* @__PURE__ */ new Set();
|
|
6122
6113
|
// Capability change listeners
|
|
6123
6114
|
capabilityListeners = /* @__PURE__ */ new Set();
|
|
6124
|
-
// Host contribution change listeners
|
|
6125
|
-
hostContributionListeners = /* @__PURE__ */ new Set();
|
|
6126
6115
|
/** Current agent context — set by the agent before each phase */
|
|
6127
6116
|
currentContext;
|
|
6128
6117
|
constructor(options) {
|
|
@@ -6220,18 +6209,19 @@ var ExtensionRunner = class {
|
|
|
6220
6209
|
async loadExtensions(extensions) {
|
|
6221
6210
|
for (const ext of extensions) {
|
|
6222
6211
|
const extensionId = ext.id ?? ext.manifest?.id ?? ext.name;
|
|
6212
|
+
const hostApi = this.host.extendApi?.(extensionId);
|
|
6223
6213
|
const extension = {
|
|
6224
6214
|
id: extensionId,
|
|
6225
6215
|
path: ext.path,
|
|
6226
6216
|
tools: /* @__PURE__ */ new Map(),
|
|
6227
6217
|
phases: /* @__PURE__ */ new Set(),
|
|
6228
6218
|
capabilities: /* @__PURE__ */ new Map(),
|
|
6229
|
-
hostContributions: /* @__PURE__ */ new Map(),
|
|
6230
6219
|
cleanup: [],
|
|
6231
|
-
runtime: createExtensionRuntime()
|
|
6220
|
+
runtime: createExtensionRuntime(),
|
|
6221
|
+
hostApi
|
|
6232
6222
|
};
|
|
6233
6223
|
try {
|
|
6234
|
-
const api = this.createExtensionAPI(extension, ext.manifest);
|
|
6224
|
+
const api = this.createExtensionAPI(extension, ext.manifest, hostApi?.namespaces);
|
|
6235
6225
|
const disposer = await ext.factory(api);
|
|
6236
6226
|
if (typeof disposer === "function") extension.disposer = disposer;
|
|
6237
6227
|
this.extensions.push(extension);
|
|
@@ -6239,9 +6229,6 @@ var ExtensionRunner = class {
|
|
|
6239
6229
|
if (extension.capabilities.size > 0) {
|
|
6240
6230
|
this.notifyCapabilitiesChanged();
|
|
6241
6231
|
}
|
|
6242
|
-
if (extension.hostContributions.size > 0) {
|
|
6243
|
-
this.notifyHostContributionsChanged();
|
|
6244
|
-
}
|
|
6245
6232
|
} catch (error) {
|
|
6246
6233
|
await this.rollbackExtension(extension);
|
|
6247
6234
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -6370,24 +6357,6 @@ var ExtensionRunner = class {
|
|
|
6370
6357
|
this.capabilityListeners.add(listener);
|
|
6371
6358
|
return () => this.capabilityListeners.delete(listener);
|
|
6372
6359
|
}
|
|
6373
|
-
/** Get all contributed host elements across all extensions. */
|
|
6374
|
-
getHostContributions() {
|
|
6375
|
-
const result = [];
|
|
6376
|
-
for (const ext of this.extensions) {
|
|
6377
|
-
for (const contrib of ext.hostContributions.values()) {
|
|
6378
|
-
result.push(contrib);
|
|
6379
|
-
}
|
|
6380
|
-
}
|
|
6381
|
-
return Object.freeze(result);
|
|
6382
|
-
}
|
|
6383
|
-
/**
|
|
6384
|
-
* Subscribe to host contribution changes (contributions added, removed, or extensions disposed).
|
|
6385
|
-
* Returns an unsubscribe function.
|
|
6386
|
-
*/
|
|
6387
|
-
onHostContributionsChanged(listener) {
|
|
6388
|
-
this.hostContributionListeners.add(listener);
|
|
6389
|
-
return () => this.hostContributionListeners.delete(listener);
|
|
6390
|
-
}
|
|
6391
6360
|
triggerUiAction(event) {
|
|
6392
6361
|
this.events.emit("ui.action", event);
|
|
6393
6362
|
}
|
|
@@ -6548,7 +6517,7 @@ var ExtensionRunner = class {
|
|
|
6548
6517
|
* Registration methods write to the extension tracking object.
|
|
6549
6518
|
* Action methods delegate to the shared runtime.
|
|
6550
6519
|
*/
|
|
6551
|
-
createExtensionAPI(extension, manifest) {
|
|
6520
|
+
createExtensionAPI(extension, manifest, namespaces) {
|
|
6552
6521
|
const runner = this;
|
|
6553
6522
|
const extContext = {
|
|
6554
6523
|
get cwd() {
|
|
@@ -6605,9 +6574,9 @@ var ExtensionRunner = class {
|
|
|
6605
6574
|
registerTool: (tool) => this.registerTool(extension, tool),
|
|
6606
6575
|
unregisterTool: (toolName) => this.unregisterTool(extension, toolName),
|
|
6607
6576
|
contributeCapability: (contribution) => this.contributeCapability(extension, contribution),
|
|
6608
|
-
contributeToHost: (contribution) => this.contributeToHost(extension, contribution),
|
|
6609
6577
|
context: extContext,
|
|
6610
6578
|
manifest,
|
|
6579
|
+
namespaces,
|
|
6611
6580
|
trackCleanup: (cleanup) => extension.cleanup.push(cleanup),
|
|
6612
6581
|
config: {
|
|
6613
6582
|
get: async (scope) => {
|
|
@@ -6715,44 +6684,6 @@ var ExtensionRunner = class {
|
|
|
6715
6684
|
}
|
|
6716
6685
|
}
|
|
6717
6686
|
}
|
|
6718
|
-
contributeToHost(extension, contribution) {
|
|
6719
|
-
const key = `${contribution.kind}:${contribution.id}`;
|
|
6720
|
-
const entry = {
|
|
6721
|
-
...contribution
|
|
6722
|
-
};
|
|
6723
|
-
extension.hostContributions.set(key, entry);
|
|
6724
|
-
if (this.extensions.includes(extension)) {
|
|
6725
|
-
this.notifyHostContributionsChanged();
|
|
6726
|
-
}
|
|
6727
|
-
let disposed = false;
|
|
6728
|
-
const dispose = () => {
|
|
6729
|
-
if (disposed) return;
|
|
6730
|
-
disposed = true;
|
|
6731
|
-
if (extension.hostContributions.get(key) === entry) {
|
|
6732
|
-
extension.hostContributions.delete(key);
|
|
6733
|
-
if (this.extensions.includes(extension)) {
|
|
6734
|
-
this.notifyHostContributionsChanged();
|
|
6735
|
-
}
|
|
6736
|
-
}
|
|
6737
|
-
};
|
|
6738
|
-
extension.cleanup.push(dispose);
|
|
6739
|
-
return dispose;
|
|
6740
|
-
}
|
|
6741
|
-
notifyHostContributionsChanged() {
|
|
6742
|
-
const contributions = this.getHostContributions();
|
|
6743
|
-
for (const listener of this.hostContributionListeners) {
|
|
6744
|
-
try {
|
|
6745
|
-
listener(contributions);
|
|
6746
|
-
} catch (error) {
|
|
6747
|
-
this.emitError({
|
|
6748
|
-
extensionPath: "<runtime>",
|
|
6749
|
-
event: "host_contributions_changed",
|
|
6750
|
-
error: error instanceof Error ? error.message : String(error),
|
|
6751
|
-
stack: error instanceof Error ? error.stack : void 0
|
|
6752
|
-
});
|
|
6753
|
-
}
|
|
6754
|
-
}
|
|
6755
|
-
}
|
|
6756
6687
|
async registerPhase(extension, registration) {
|
|
6757
6688
|
if (typeof registration === "string") {
|
|
6758
6689
|
if (registration.length === 0) {
|
|
@@ -6841,21 +6772,21 @@ var ExtensionRunner = class {
|
|
|
6841
6772
|
for (const name of extension.phases) this.phases.delete(name);
|
|
6842
6773
|
const hadCapabilities = extension.capabilities.size > 0;
|
|
6843
6774
|
extension.capabilities.clear();
|
|
6844
|
-
const hadHostContributions = extension.hostContributions.size > 0;
|
|
6845
|
-
extension.hostContributions.clear();
|
|
6846
6775
|
for (const cleanup of [...extension.cleanup].reverse()) {
|
|
6847
6776
|
await Promise.resolve().then(() => cleanup()).catch(() => void 0);
|
|
6848
6777
|
}
|
|
6849
6778
|
if (extension.disposer) {
|
|
6850
6779
|
await Promise.resolve().then(() => extension.disposer()).catch(() => void 0);
|
|
6851
6780
|
}
|
|
6781
|
+
if (extension.hostApi?.dispose) {
|
|
6782
|
+
const hostDispose = extension.hostApi.dispose;
|
|
6783
|
+
extension.hostApi = { ...extension.hostApi, dispose: void 0 };
|
|
6784
|
+
await Promise.resolve().then(() => hostDispose()).catch(() => void 0);
|
|
6785
|
+
}
|
|
6852
6786
|
this._phaseCache = null;
|
|
6853
6787
|
if (hadCapabilities) {
|
|
6854
6788
|
this.notifyCapabilitiesChanged();
|
|
6855
6789
|
}
|
|
6856
|
-
if (hadHostContributions) {
|
|
6857
|
-
this.notifyHostContributionsChanged();
|
|
6858
|
-
}
|
|
6859
6790
|
}
|
|
6860
6791
|
};
|
|
6861
6792
|
function createExtensionRunner(options) {
|
|
@@ -7978,14 +7909,6 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
7978
7909
|
this.assertOpen();
|
|
7979
7910
|
return this.resources.extensionRunner.onCapabilitiesChanged(listener);
|
|
7980
7911
|
}
|
|
7981
|
-
listHostContributions() {
|
|
7982
|
-
this.assertOpen();
|
|
7983
|
-
return this.resources.extensionRunner.getHostContributions();
|
|
7984
|
-
}
|
|
7985
|
-
onHostContributionsChanged(listener) {
|
|
7986
|
-
this.assertOpen();
|
|
7987
|
-
return this.resources.extensionRunner.onHostContributionsChanged(listener);
|
|
7988
|
-
}
|
|
7989
7912
|
triggerUiAction(event) {
|
|
7990
7913
|
this.assertOpen();
|
|
7991
7914
|
this.resources.extensionRunner.triggerUiAction(event);
|