@rowan-agent/agent 0.9.15 → 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 +89 -2
- package/dist/index.js +46 -17
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -886,6 +886,10 @@ interface ExtensionAPI {
|
|
|
886
886
|
getNextPhase(): string | undefined;
|
|
887
887
|
/** Get the message set by setMessage */
|
|
888
888
|
getMessage(): string | undefined;
|
|
889
|
+
/** Phase Settings contributions registered by the Phase extension. */
|
|
890
|
+
settings: {
|
|
891
|
+
register(provider: PhaseSettingsProvider): void;
|
|
892
|
+
};
|
|
889
893
|
};
|
|
890
894
|
}
|
|
891
895
|
/**
|
|
@@ -976,6 +980,83 @@ interface PhaseContext {
|
|
|
976
980
|
/** Text to append after the system prompt */
|
|
977
981
|
appendSystemPrompt?: string;
|
|
978
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>;
|
|
979
1060
|
/**
|
|
980
1061
|
* Loaded Phase object
|
|
981
1062
|
*/
|
|
@@ -1008,7 +1089,7 @@ interface Phase {
|
|
|
1008
1089
|
disableAutoInvocation?: boolean;
|
|
1009
1090
|
/** Do not expose this Phase to direct user invocation. */
|
|
1010
1091
|
disableImplicitInvocation?: boolean;
|
|
1011
|
-
/** ExtensionAPI factory function
|
|
1092
|
+
/** ExtensionAPI factory function used for registration or programmatic execution. */
|
|
1012
1093
|
factory?: (api: ExtensionAPI) => Promise<void>;
|
|
1013
1094
|
/** Direct run function */
|
|
1014
1095
|
run?: (context: PhaseContext, execution: PhaseExecution) => Promise<PhaseOutput | void>;
|
|
@@ -2645,6 +2726,12 @@ declare function loadSkills(targetPath: string): Promise<Skill[]>;
|
|
|
2645
2726
|
* If a directory is provided, the loader reads its PHASE.md.
|
|
2646
2727
|
*/
|
|
2647
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>;
|
|
2648
2735
|
/**
|
|
2649
2736
|
* Load all phases from the target directory.
|
|
2650
2737
|
*
|
|
@@ -2698,4 +2785,4 @@ declare function parseFrontmatter<T = Record<string, unknown>>(raw: string): Fro
|
|
|
2698
2785
|
|
|
2699
2786
|
declare function createCoreTools(input?: CoreToolContext): Tool[];
|
|
2700
2787
|
|
|
2701
|
-
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 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) {
|
|
@@ -8825,6 +8853,7 @@ export {
|
|
|
8825
8853
|
isRuntimeError,
|
|
8826
8854
|
loadExtensionsFromPath as loadExtensions,
|
|
8827
8855
|
loadPhase,
|
|
8856
|
+
loadPhaseSettings,
|
|
8828
8857
|
loadPhases,
|
|
8829
8858
|
loadSkill,
|
|
8830
8859
|
loadSkills,
|