@rowan-agent/agent 0.9.14 → 0.9.16
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 +108 -2
- package/dist/index.js +47 -17
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -566,6 +566,25 @@ type PhaseExecution = {
|
|
|
566
566
|
executeTool(context: AgentContext, toolCall: ToolCall): Promise<ToolResult>;
|
|
567
567
|
executeTools(context: AgentContext, toolCalls: readonly ToolCall[]): Promise<readonly ToolResult[]>;
|
|
568
568
|
interaction: PhaseInteractionDriver;
|
|
569
|
+
/** Message lifecycle manager for streaming updates from programmatic phases */
|
|
570
|
+
messages: PhaseMessageManager;
|
|
571
|
+
};
|
|
572
|
+
/** Message lifecycle manager for streaming updates */
|
|
573
|
+
type PhaseMessageManager = {
|
|
574
|
+
/** Get all visible messages in the transcript */
|
|
575
|
+
visible(): AgentMessage[];
|
|
576
|
+
/** Reserve the eventual message identity before stream deltas arrive. */
|
|
577
|
+
reserve(role: "assistant" | "tool", metadata?: Record<string, unknown>): string;
|
|
578
|
+
/** Start a new message stream, returns message id */
|
|
579
|
+
start(role: "assistant" | "tool", content: AgentMessage["content"], metadata?: Record<string, unknown>): string;
|
|
580
|
+
/** Stream a text delta */
|
|
581
|
+
update(messageId: string, delta: string): Promise<void>;
|
|
582
|
+
/** Replace the active message content with model-native content parts */
|
|
583
|
+
replaceContent(messageId: string, content: string | LlmContentPart[]): void;
|
|
584
|
+
/** End the message stream, appends to transcript */
|
|
585
|
+
end(messageId: string): Promise<void>;
|
|
586
|
+
/** Drop an unstarted stream that produced no content. */
|
|
587
|
+
discard(messageId: string): void;
|
|
569
588
|
};
|
|
570
589
|
|
|
571
590
|
/**
|
|
@@ -867,6 +886,10 @@ interface ExtensionAPI {
|
|
|
867
886
|
getNextPhase(): string | undefined;
|
|
868
887
|
/** Get the message set by setMessage */
|
|
869
888
|
getMessage(): string | undefined;
|
|
889
|
+
/** Phase Settings contributions registered by the Phase extension. */
|
|
890
|
+
settings: {
|
|
891
|
+
register(provider: PhaseSettingsProvider): void;
|
|
892
|
+
};
|
|
870
893
|
};
|
|
871
894
|
}
|
|
872
895
|
/**
|
|
@@ -957,6 +980,83 @@ interface PhaseContext {
|
|
|
957
980
|
/** Text to append after the system prompt */
|
|
958
981
|
appendSystemPrompt?: string;
|
|
959
982
|
}
|
|
983
|
+
/** JSON-safe option metadata exposed by a Phase to a host Settings surface. */
|
|
984
|
+
interface PhaseSettingsOption {
|
|
985
|
+
value: string;
|
|
986
|
+
label: string;
|
|
987
|
+
description?: string;
|
|
988
|
+
disabled?: boolean;
|
|
989
|
+
}
|
|
990
|
+
interface PhaseSettingsBadge {
|
|
991
|
+
label: string;
|
|
992
|
+
tone?: "neutral" | "success" | "review" | "danger";
|
|
993
|
+
}
|
|
994
|
+
interface PhaseSettingsItem {
|
|
995
|
+
id: string;
|
|
996
|
+
title: string;
|
|
997
|
+
description?: string;
|
|
998
|
+
badges?: readonly PhaseSettingsBadge[];
|
|
999
|
+
}
|
|
1000
|
+
type PhaseSettingsControl = {
|
|
1001
|
+
type: "boolean";
|
|
1002
|
+
path: string;
|
|
1003
|
+
label: string;
|
|
1004
|
+
description?: string;
|
|
1005
|
+
} | {
|
|
1006
|
+
type: "number";
|
|
1007
|
+
path: string;
|
|
1008
|
+
label: string;
|
|
1009
|
+
description?: string;
|
|
1010
|
+
min?: number;
|
|
1011
|
+
max?: number;
|
|
1012
|
+
step?: number;
|
|
1013
|
+
unit?: string;
|
|
1014
|
+
scale?: number;
|
|
1015
|
+
} | {
|
|
1016
|
+
type: "select";
|
|
1017
|
+
path: string;
|
|
1018
|
+
label: string;
|
|
1019
|
+
description?: string;
|
|
1020
|
+
options: readonly PhaseSettingsOption[];
|
|
1021
|
+
} | {
|
|
1022
|
+
type: "text";
|
|
1023
|
+
path: string;
|
|
1024
|
+
label: string;
|
|
1025
|
+
description?: string;
|
|
1026
|
+
placeholder?: string;
|
|
1027
|
+
format?: "string" | "string-array" | "key-value";
|
|
1028
|
+
multiline?: boolean;
|
|
1029
|
+
} | {
|
|
1030
|
+
type: "collection";
|
|
1031
|
+
path: string;
|
|
1032
|
+
label: string;
|
|
1033
|
+
description?: string;
|
|
1034
|
+
items: readonly PhaseSettingsItem[];
|
|
1035
|
+
fields: readonly PhaseSettingsControl[];
|
|
1036
|
+
add?: {
|
|
1037
|
+
label: string;
|
|
1038
|
+
idLabel?: string;
|
|
1039
|
+
fields: readonly PhaseSettingsControl[];
|
|
1040
|
+
};
|
|
1041
|
+
removeLabel?: string;
|
|
1042
|
+
};
|
|
1043
|
+
interface PhaseSettingsSection {
|
|
1044
|
+
id: string;
|
|
1045
|
+
title: string;
|
|
1046
|
+
description?: string;
|
|
1047
|
+
controls: readonly PhaseSettingsControl[];
|
|
1048
|
+
}
|
|
1049
|
+
/** Declarative, host-neutral Settings surface contributed by a Phase. */
|
|
1050
|
+
interface PhaseSettingsDefinition {
|
|
1051
|
+
description?: string;
|
|
1052
|
+
sections: readonly PhaseSettingsSection[];
|
|
1053
|
+
}
|
|
1054
|
+
/** Host context is intentionally opaque beyond the effective configuration. */
|
|
1055
|
+
interface PhaseSettingsContext {
|
|
1056
|
+
configuration: Readonly<Record<string, unknown>>;
|
|
1057
|
+
metadata?: Readonly<Record<string, unknown>>;
|
|
1058
|
+
}
|
|
1059
|
+
type PhaseSettingsProvider = (context: PhaseSettingsContext) => PhaseSettingsDefinition | Promise<PhaseSettingsDefinition>;
|
|
960
1060
|
/**
|
|
961
1061
|
* Loaded Phase object
|
|
962
1062
|
*/
|
|
@@ -989,7 +1089,7 @@ interface Phase {
|
|
|
989
1089
|
disableAutoInvocation?: boolean;
|
|
990
1090
|
/** Do not expose this Phase to direct user invocation. */
|
|
991
1091
|
disableImplicitInvocation?: boolean;
|
|
992
|
-
/** ExtensionAPI factory function
|
|
1092
|
+
/** ExtensionAPI factory function used for registration or programmatic execution. */
|
|
993
1093
|
factory?: (api: ExtensionAPI) => Promise<void>;
|
|
994
1094
|
/** Direct run function */
|
|
995
1095
|
run?: (context: PhaseContext, execution: PhaseExecution) => Promise<PhaseOutput | void>;
|
|
@@ -2626,6 +2726,12 @@ declare function loadSkills(targetPath: string): Promise<Skill[]>;
|
|
|
2626
2726
|
* If a directory is provided, the loader reads its PHASE.md.
|
|
2627
2727
|
*/
|
|
2628
2728
|
declare function loadPhase(targetPath: string): Promise<Phase>;
|
|
2729
|
+
/**
|
|
2730
|
+
* Collect and evaluate the Settings provider registered through the Phase's
|
|
2731
|
+
* ExtensionAPI namespace. Settings discovery never reads a direct module
|
|
2732
|
+
* export; the Phase contributes through `api.phase.settings.register()`.
|
|
2733
|
+
*/
|
|
2734
|
+
declare function loadPhaseSettings(phase: Phase, context: PhaseSettingsContext): Promise<PhaseSettingsDefinition | undefined>;
|
|
2629
2735
|
/**
|
|
2630
2736
|
* Load all phases from the target directory.
|
|
2631
2737
|
*
|
|
@@ -2679,4 +2785,4 @@ declare function parseFrontmatter<T = Record<string, unknown>>(raw: string): Fro
|
|
|
2679
2785
|
|
|
2680
2786
|
declare function createCoreTools(input?: CoreToolContext): Tool[];
|
|
2681
2787
|
|
|
2682
|
-
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, 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 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 HistorySeed, type HookEvent, type HookEventType, type HookHandler, InMemoryConfigProvider, InMemoryStore, type InputRequest, type InputRequestId, type InputRequiredCommit, type InvocationCatalogEntry, type InvocationSource, 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 MessageRevised, type MessageRevisionResult, type Metadata, type OpaqueId, type Outcome, type OwnerLease, type OwnerToken, type Page, type Phase, type PhaseContext, type PhaseContribution, type PhaseExecution, type PhaseExecutionIdentity, type PhaseInteraction, PhaseInteractionBoundary, PhaseInteractionCancelledError, type PhaseInteractionDriver, type PhaseInteractionKind, type PhaseInteractionState, type PhaseInteractionStatus, type PhaseInvocation, 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 RunEvent, type RunFailure, type RunId, type RunListCursor, type RunRecord, type RunSnapshot, type RunState, type RunStateChanged, type RunSummary, RuntimeBootstrapRegistry, RuntimeError, type RuntimeErrorCode, type RuntimeErrorDetails, RuntimeExtensionLifetime, STOP_PHASE_ID, type Skill, SqliteStore, type TextContent, type ThinkingContent, type ThinkingDelta, type Tool, type ToolCallId, type ToolCallSnapshot, type ToolCallState, type ToolContribution, type ToolDefinition, type ToolExecutionResult$1 as ToolExecutionResult, type ToolInvocationContext, type ToolMessage, type ToolMessageContent, type ToolProgress, type ToolResultContent, type ToolStateChanged, type ToolUseContent, type UserContent, type UserInput, type UserMessage, brandConfigToken, createCompactPhase, createCorePhases, createCoreTools, createDefaultPhase, createStopPhase, isRuntimeError, loadExtensionsFromPath as loadExtensions, loadPhase, loadPhases, loadSkill, loadSkills, materializeConfigurationSnapshot, parseAgentDefinition, parseFrontmatter, resolveConfigurationSnapshot };
|
|
2788
|
+
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, 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 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 HistorySeed, type HookEvent, type HookEventType, type HookHandler, InMemoryConfigProvider, InMemoryStore, type InputRequest, type InputRequestId, type InputRequiredCommit, type InvocationCatalogEntry, type InvocationSource, 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 MessageRevised, type MessageRevisionResult, type Metadata, type OpaqueId, type Outcome, type OwnerLease, type OwnerToken, type Page, type Phase, type PhaseContext, type PhaseContribution, type PhaseExecution, type PhaseExecutionIdentity, type PhaseInteraction, PhaseInteractionBoundary, PhaseInteractionCancelledError, type PhaseInteractionDriver, type PhaseInteractionKind, type PhaseInteractionState, type PhaseInteractionStatus, type PhaseInvocation, type PhaseMessageManager, type PhaseOutput, type PhaseRegistry, type PhaseRegistrySelection, type PhaseSettingsBadge, type PhaseSettingsContext, type PhaseSettingsControl, type PhaseSettingsDefinition, type PhaseSettingsItem, type PhaseSettingsOption, type PhaseSettingsProvider, type PhaseSettingsSection, 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 RunEvent, type RunFailure, type RunId, type RunListCursor, type RunRecord, type RunSnapshot, type RunState, type RunStateChanged, type RunSummary, RuntimeBootstrapRegistry, RuntimeError, type RuntimeErrorCode, type RuntimeErrorDetails, RuntimeExtensionLifetime, STOP_PHASE_ID, type Skill, SqliteStore, type TextContent, type ThinkingContent, type ThinkingDelta, type Tool, type ToolCallId, type ToolCallSnapshot, type ToolCallState, type ToolContribution, type ToolDefinition, type ToolExecutionResult$1 as ToolExecutionResult, type ToolInvocationContext, type ToolMessage, type ToolMessageContent, type ToolProgress, type ToolResultContent, type ToolStateChanged, type ToolUseContent, type UserContent, type UserInput, type UserMessage, brandConfigToken, createCompactPhase, createCorePhases, createCoreTools, createDefaultPhase, createStopPhase, isRuntimeError, loadExtensionsFromPath as loadExtensions, loadPhase, loadPhaseSettings, loadPhases, loadSkill, loadSkills, materializeConfigurationSnapshot, parseAgentDefinition, parseFrontmatter, resolveConfigurationSnapshot };
|
package/dist/index.js
CHANGED
|
@@ -1055,6 +1055,7 @@ function createExtensionAPI(hooks, options, runtime, eventBus) {
|
|
|
1055
1055
|
let outputPayload = phaseIn?.state?.payload;
|
|
1056
1056
|
let nextPhase;
|
|
1057
1057
|
let outputMessage;
|
|
1058
|
+
let settingsProvider;
|
|
1058
1059
|
return {
|
|
1059
1060
|
on: (eventType, handler) => {
|
|
1060
1061
|
assertActive();
|
|
@@ -1115,7 +1116,20 @@ function createExtensionAPI(hooks, options, runtime, eventBus) {
|
|
|
1115
1116
|
nextPhase = id;
|
|
1116
1117
|
},
|
|
1117
1118
|
getNextPhase: () => nextPhase,
|
|
1118
|
-
getMessage: () => outputMessage
|
|
1119
|
+
getMessage: () => outputMessage,
|
|
1120
|
+
settings: {
|
|
1121
|
+
register: (provider) => {
|
|
1122
|
+
assertActive();
|
|
1123
|
+
if (typeof provider !== "function") {
|
|
1124
|
+
throw new Error("Phase Settings registration requires a provider function.");
|
|
1125
|
+
}
|
|
1126
|
+
if (settingsProvider) {
|
|
1127
|
+
throw new Error("A Phase may register only one Settings provider.");
|
|
1128
|
+
}
|
|
1129
|
+
settingsProvider = provider;
|
|
1130
|
+
options?.registerSettings?.(provider);
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1119
1133
|
}
|
|
1120
1134
|
};
|
|
1121
1135
|
}
|
|
@@ -1627,12 +1641,24 @@ async function loadPhase(targetPath) {
|
|
|
1627
1641
|
const code = await loadPhaseCode(codePath);
|
|
1628
1642
|
if (code.factory) {
|
|
1629
1643
|
phase.factory = code.factory;
|
|
1630
|
-
}
|
|
1644
|
+
}
|
|
1645
|
+
if (code.run) {
|
|
1631
1646
|
phase.run = code.run;
|
|
1632
1647
|
}
|
|
1633
1648
|
}
|
|
1634
1649
|
return phase;
|
|
1635
1650
|
}
|
|
1651
|
+
async function loadPhaseSettings(phase, context) {
|
|
1652
|
+
if (!phase.factory) return void 0;
|
|
1653
|
+
let provider;
|
|
1654
|
+
const api = createExtensionAPI(void 0, {
|
|
1655
|
+
registerSettings: (candidate) => {
|
|
1656
|
+
provider = candidate;
|
|
1657
|
+
}
|
|
1658
|
+
});
|
|
1659
|
+
await phase.factory(api);
|
|
1660
|
+
return provider ? provider(context) : void 0;
|
|
1661
|
+
}
|
|
1636
1662
|
async function loadPhaseSkills(baseDir) {
|
|
1637
1663
|
const entries = await readdir2(baseDir, { withFileTypes: true });
|
|
1638
1664
|
const skills = [];
|
|
@@ -1743,13 +1769,15 @@ async function loadPhaseCode(codePath) {
|
|
|
1743
1769
|
moduleCache: false,
|
|
1744
1770
|
tryNative: false
|
|
1745
1771
|
});
|
|
1746
|
-
const mod = await jiti.import(codePath
|
|
1747
|
-
const
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1772
|
+
const mod = await jiti.import(codePath);
|
|
1773
|
+
const namespace = mod && typeof mod === "object" ? mod : {};
|
|
1774
|
+
const fn = typeof mod === "function" ? mod : namespace.default;
|
|
1775
|
+
const run = namespace.run;
|
|
1776
|
+
if (typeof fn === "function" || typeof run === "function") {
|
|
1777
|
+
return {
|
|
1778
|
+
...typeof fn === "function" ? { factory: fn } : {},
|
|
1779
|
+
...typeof run === "function" ? { run } : {}
|
|
1780
|
+
};
|
|
1753
1781
|
}
|
|
1754
1782
|
throw new Error(`Phase code at "${codePath}" must export a default function or a run() function.`);
|
|
1755
1783
|
}
|
|
@@ -2784,6 +2812,14 @@ async function withRetry(fn, options = {}) {
|
|
|
2784
2812
|
}
|
|
2785
2813
|
async function executePhase(ctx) {
|
|
2786
2814
|
const { phase, config, execution, registry, context } = ctx;
|
|
2815
|
+
if (phase.run) {
|
|
2816
|
+
const output = resolvePhaseOutput(await phase.run(context, execution));
|
|
2817
|
+
output.phase = phase.name;
|
|
2818
|
+
if (output.message === "Phase completed.") {
|
|
2819
|
+
output.message = `${phase.name} phase completed.`;
|
|
2820
|
+
}
|
|
2821
|
+
return output;
|
|
2822
|
+
}
|
|
2787
2823
|
if (phase.factory) {
|
|
2788
2824
|
const api = createExtensionAPI(void 0, {
|
|
2789
2825
|
registerPhase: async () => {
|
|
@@ -2822,14 +2858,6 @@ async function executePhase(ctx) {
|
|
|
2822
2858
|
payload: api.phase.getPayload()
|
|
2823
2859
|
};
|
|
2824
2860
|
}
|
|
2825
|
-
if (phase.run) {
|
|
2826
|
-
const output = resolvePhaseOutput(await phase.run(context, execution));
|
|
2827
|
-
output.phase = phase.name;
|
|
2828
|
-
if (output.message === "Phase completed.") {
|
|
2829
|
-
output.message = `${phase.name} phase completed.`;
|
|
2830
|
-
}
|
|
2831
|
-
return output;
|
|
2832
|
-
}
|
|
2833
2861
|
return executePhaseWithModel(ctx);
|
|
2834
2862
|
}
|
|
2835
2863
|
async function executeToolCall(input) {
|
|
@@ -2882,6 +2910,7 @@ function createPhaseExecution(config, state, phase, messageManager, toolExecutio
|
|
|
2882
2910
|
const interaction = createPhaseInteractionDriver(state, phase.name, config.signal);
|
|
2883
2911
|
return {
|
|
2884
2912
|
interaction,
|
|
2913
|
+
messages: messageManager,
|
|
2885
2914
|
snapshot() {
|
|
2886
2915
|
return {
|
|
2887
2916
|
systemPrompt: config.context.systemPrompt,
|
|
@@ -8824,6 +8853,7 @@ export {
|
|
|
8824
8853
|
isRuntimeError,
|
|
8825
8854
|
loadExtensionsFromPath as loadExtensions,
|
|
8826
8855
|
loadPhase,
|
|
8856
|
+
loadPhaseSettings,
|
|
8827
8857
|
loadPhases,
|
|
8828
8858
|
loadSkill,
|
|
8829
8859
|
loadSkills,
|