@rowan-agent/agent 0.5.3 → 0.5.5
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/README.md +6 -2
- package/dist/index.d.ts +4 -9
- package/dist/index.js +132 -61
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -50,6 +50,7 @@ class Agent {
|
|
|
50
50
|
appendMessages(messages: AgentMessage[]): void;
|
|
51
51
|
runWithUserInput(input: string, options?: RunOptions): Promise<RunResult>;
|
|
52
52
|
runWithMessage(message: AgentMessage, options?: RunOptions): Promise<RunResult>;
|
|
53
|
+
resetInitialization(): void;
|
|
53
54
|
|
|
54
55
|
// Context and transcript
|
|
55
56
|
getContext(): AgentContext;
|
|
@@ -140,6 +141,8 @@ const second = await agent.run();
|
|
|
140
141
|
await agent.runWithMessage(createMessage("user", "what changed since last turn?"));
|
|
141
142
|
```
|
|
142
143
|
|
|
144
|
+
The agent uses `context.phases.entryPhaseId` only until the first successful run completes. Later turns start from the normalized `default` phase so long-lived agents do not repeat one-time entry work. Call `agent.resetInitialization()` when the next run should use `entryPhaseId` again.
|
|
145
|
+
|
|
143
146
|
Transcript helpers return snapshots, so callers can inspect or edit history without accidentally mutating the agent until they call a setter.
|
|
144
147
|
|
|
145
148
|
```ts
|
|
@@ -202,6 +205,7 @@ The terminal result produced when the loop completes — carries the final messa
|
|
|
202
205
|
type Outcome = {
|
|
203
206
|
id: string;
|
|
204
207
|
message: string;
|
|
208
|
+
payload?: unknown;
|
|
205
209
|
toolResults?: Array<{
|
|
206
210
|
toolCallId: string;
|
|
207
211
|
toolName: string;
|
|
@@ -341,7 +345,7 @@ Per iteration:
|
|
|
341
345
|
5. Transition, continue, or stop
|
|
342
346
|
```
|
|
343
347
|
|
|
344
|
-
**`entryPhaseId`** specifies which phase the loop enters
|
|
348
|
+
**`entryPhaseId`** specifies which phase the loop enters for an uninitialized Agent. When phases are loaded from `.rowan/phases/`, the first discovered phase becomes the entry. When none are configured, the Agent normalises to `"default"`. After a successful run, later turns start from `"default"` until `agent.resetInitialization()` is called. This field is an internal routing hint for the phase loop — it is **not** exposed to the LLM, since the agent does not need to know which phase is the entry point to make routing decisions.
|
|
345
349
|
|
|
346
350
|
### Example Phase Flow
|
|
347
351
|
|
|
@@ -775,4 +779,4 @@ type LoopMetrics = {
|
|
|
775
779
|
|
|
776
780
|
## Version
|
|
777
781
|
|
|
778
|
-
Current version: **0.
|
|
782
|
+
Current version: **0.5.5**
|
package/dist/index.d.ts
CHANGED
|
@@ -1357,7 +1357,8 @@ type AgentStatus = {
|
|
|
1357
1357
|
context: AgentContext;
|
|
1358
1358
|
model: LlmModelRef;
|
|
1359
1359
|
tools: Tool[];
|
|
1360
|
-
|
|
1360
|
+
initialized: boolean;
|
|
1361
|
+
running: boolean;
|
|
1361
1362
|
currentResult?: RunResult;
|
|
1362
1363
|
error?: string;
|
|
1363
1364
|
};
|
|
@@ -1381,6 +1382,7 @@ declare class Agent {
|
|
|
1381
1382
|
appendMessages(messages: AgentMessage[]): void;
|
|
1382
1383
|
runWithUserInput(input: string, options?: RunOptions): Promise<RunResult>;
|
|
1383
1384
|
runWithMessage(message: AgentMessage, options?: RunOptions): Promise<RunResult>;
|
|
1385
|
+
resetInitialization(): void;
|
|
1384
1386
|
getContext(): AgentContext;
|
|
1385
1387
|
setContext(context: AgentContext): void;
|
|
1386
1388
|
updateContext(updater: (context: AgentContext) => AgentContext): void;
|
|
@@ -1745,13 +1747,6 @@ declare class EmptyResponseError extends Error {
|
|
|
1745
1747
|
readonly code = "empty_response";
|
|
1746
1748
|
constructor(message?: string);
|
|
1747
1749
|
}
|
|
1748
|
-
/** Error thrown when a routed phase needs a route tool call but the model did not emit one. */
|
|
1749
|
-
declare class MissingRouteToolCallError extends Error {
|
|
1750
|
-
readonly code = "missing_route_tool_call";
|
|
1751
|
-
readonly phase: string;
|
|
1752
|
-
readonly toolCallNames: string[];
|
|
1753
|
-
constructor(phase: string, toolCallNames: string[]);
|
|
1754
|
-
}
|
|
1755
1750
|
|
|
1756
1751
|
interface SystemPromptOptions {
|
|
1757
1752
|
/** Base system prompt. */
|
|
@@ -1806,4 +1801,4 @@ declare function buildModelRequest(input: ModelRequestInput, options?: {
|
|
|
1806
1801
|
model?: LlmModelRef;
|
|
1807
1802
|
}): LlmRequest;
|
|
1808
1803
|
|
|
1809
|
-
export { type AbortEvent, type AfterPhaseEvent, type AfterPhaseHookResult, type AfterPhaseResult, type AfterToolCallEvent, type AfterToolCallResult, Agent, type AgentConfigFile, type AgentContext, type AgentEndEvent, AgentEventStream, type AgentOptions, type AgentStartEvent, type AgentStatus, type BeforePhaseEvent, type BeforePhaseHookResult, type BeforePhaseResult, type BeforePromptEvent, type BeforePromptResult, type BeforeToolCallEvent, type BeforeToolCallResult, EmptyResponseError, type EventBus, EventStream, type ExecOptions, type ExecResult, type ExecutionTurn, type Extension, type ExtensionAPI, type ExtensionContext, type ExtensionError, type ExtensionErrorListener, type ExtensionFactory, type ExtensionManifest, type ExtensionPackageManifest, ExtensionRunner, type ExtensionRunnerOptions, type ExtensionRuntime, type ExtensionUtils, HookError, type HookEvent, type HookEventType, type HookHandler, type HookResultMap, HooksManager, type LoadExtensionsResult, type LoadedExtension, LocalJsonlSessionManager, type LoopMetrics, type MessageEndEvent, type MessageStartEvent, type MessageUpdateEvent,
|
|
1804
|
+
export { type AbortEvent, type AfterPhaseEvent, type AfterPhaseHookResult, type AfterPhaseResult, type AfterToolCallEvent, type AfterToolCallResult, Agent, type AgentConfigFile, type AgentContext, type AgentEndEvent, AgentEventStream, type AgentOptions, type AgentStartEvent, type AgentStatus, type BeforePhaseEvent, type BeforePhaseHookResult, type BeforePhaseResult, type BeforePromptEvent, type BeforePromptResult, type BeforeToolCallEvent, type BeforeToolCallResult, EmptyResponseError, type EventBus, EventStream, type ExecOptions, type ExecResult, type ExecutionTurn, type Extension, type ExtensionAPI, type ExtensionContext, type ExtensionError, type ExtensionErrorListener, type ExtensionFactory, type ExtensionManifest, type ExtensionPackageManifest, ExtensionRunner, type ExtensionRunnerOptions, type ExtensionRuntime, type ExtensionUtils, HookError, type HookEvent, type HookEventType, type HookHandler, type HookResultMap, HooksManager, type LoadExtensionsResult, type LoadedExtension, LocalJsonlSessionManager, type LoopMetrics, type MessageEndEvent, type MessageStartEvent, type MessageUpdateEvent, type ModelConfigFromFile, type ModelTranscript, type Phase, type PhaseContext, type PhaseDefinition, type PhaseExecution, type PhaseOutput, type PhaseRegistration, type PhaseRegistry, type PhaseRun, type PhaseState, type ProviderConfigFromFile, type QueueUpdateEvent, type RegisteredPhase, type RegisteredTool, type RunOptions, type RunResult, type SavePointEvent, type Session, type SessionListItem, type SettledEvent, type SourceInfo, type Tool, type ToolDefinition, type ToolExecutionEndEvent, type ToolExecutionResult, type ToolExecutionStartEvent, type ToolExecutionUpdateEvent, type TurnEndEvent, type TurnStartEvent, type WorkspacePaths, appendUserTurn, buildModelRequest, buildSystemPrompt, conversationMessages, createCoreTools, createEventBus, createExtension, createExtensionAPI, createExtensionRunner, createExtensionRuntime, createId, createMessage, createSession, createSourceInfo, createTimestamp, getGlobalHooks, interpolateEnvVars, latestUserInput, loadConfigFile, loadPhase, loadPhases, messageContentText, parseModelRef, registerConfigModels, reloadPhases, resetGlobalHooks, resolveDefaultModel, resolveInWorkspace, resolveWorkspacePaths, serializeSkills };
|
package/dist/index.js
CHANGED
|
@@ -21,19 +21,6 @@ var EmptyResponseError = class extends Error {
|
|
|
21
21
|
this.name = "EmptyResponseError";
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
var MissingRouteToolCallError = class extends Error {
|
|
25
|
-
code = "missing_route_tool_call";
|
|
26
|
-
phase;
|
|
27
|
-
toolCallNames;
|
|
28
|
-
constructor(phase, toolCallNames) {
|
|
29
|
-
super(
|
|
30
|
-
`Phase "${phase}" requires a route tool call, but the model did not emit one.`
|
|
31
|
-
);
|
|
32
|
-
this.name = "MissingRouteToolCallError";
|
|
33
|
-
this.phase = phase;
|
|
34
|
-
this.toolCallNames = toolCallNames;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
24
|
var LoopGuard = {
|
|
38
25
|
/** Returns abort result if signal is aborted */
|
|
39
26
|
checkAbort(signal) {
|
|
@@ -85,7 +72,11 @@ function extractToolResults(transcript) {
|
|
|
85
72
|
}
|
|
86
73
|
var createOutcome = {
|
|
87
74
|
phaseNotFound(output) {
|
|
88
|
-
return {
|
|
75
|
+
return {
|
|
76
|
+
id: createId("out"),
|
|
77
|
+
message: `Phase "${output.phase ?? "Unknown"}" not found.`,
|
|
78
|
+
display: true
|
|
79
|
+
};
|
|
89
80
|
},
|
|
90
81
|
default(output, transcript) {
|
|
91
82
|
const toolResults = transcript ? extractToolResults(transcript) : [];
|
|
@@ -102,11 +93,17 @@ var createOutcome = {
|
|
|
102
93
|
}
|
|
103
94
|
return outcome;
|
|
104
95
|
},
|
|
96
|
+
phase(output, transcript) {
|
|
97
|
+
return {
|
|
98
|
+
...this.default(output, transcript),
|
|
99
|
+
display: true
|
|
100
|
+
};
|
|
101
|
+
},
|
|
105
102
|
aborted() {
|
|
106
103
|
return { id: createId("out"), message: "Agent run aborted." };
|
|
107
104
|
},
|
|
108
105
|
error(message) {
|
|
109
|
-
return { id: createId("out"), message };
|
|
106
|
+
return { id: createId("out"), message, display: true };
|
|
110
107
|
}
|
|
111
108
|
};
|
|
112
109
|
|
|
@@ -196,9 +193,13 @@ async function collectStreamResult(input) {
|
|
|
196
193
|
let stopReason;
|
|
197
194
|
let doneResponse;
|
|
198
195
|
for await (const event of input.events) {
|
|
199
|
-
const
|
|
200
|
-
if (
|
|
201
|
-
|
|
196
|
+
const abortResult2 = LoopGuard.checkAbort(input.config.signal);
|
|
197
|
+
if (abortResult2.stopReason !== "none") {
|
|
198
|
+
if (activeMessageId) {
|
|
199
|
+
await input.message.end(activeMessageId);
|
|
200
|
+
activeMessageId = void 0;
|
|
201
|
+
}
|
|
202
|
+
return { text: abortResult2.message, contentBlocks: [], toolCalls: [], stopReason: "aborted" };
|
|
202
203
|
}
|
|
203
204
|
if (event.type === "model_requested") {
|
|
204
205
|
input.config.emit?.({
|
|
@@ -249,6 +250,14 @@ async function collectStreamResult(input) {
|
|
|
249
250
|
}
|
|
250
251
|
}
|
|
251
252
|
}
|
|
253
|
+
const abortResult = LoopGuard.checkAbort(input.config.signal);
|
|
254
|
+
if (abortResult.stopReason !== "none") {
|
|
255
|
+
if (activeMessageId) {
|
|
256
|
+
await input.message.end(activeMessageId);
|
|
257
|
+
activeMessageId = void 0;
|
|
258
|
+
}
|
|
259
|
+
return { text: abortResult.message, contentBlocks: [], toolCalls: [], stopReason: "aborted" };
|
|
260
|
+
}
|
|
252
261
|
if (activeMessageId) {
|
|
253
262
|
await input.message.end(activeMessageId);
|
|
254
263
|
}
|
|
@@ -1753,11 +1762,19 @@ function createRunResult(config, state, outcome) {
|
|
|
1753
1762
|
};
|
|
1754
1763
|
}
|
|
1755
1764
|
async function completeRun(config, state, outcome) {
|
|
1765
|
+
if (outcome.display) {
|
|
1766
|
+
const messages = createMessageManager(config.context, config.emit, config.onMessage);
|
|
1767
|
+
const messageId = messages.start("assistant", outcome.message, { outcomeId: outcome.id });
|
|
1768
|
+
await messages.end(messageId);
|
|
1769
|
+
}
|
|
1756
1770
|
state.metrics.endedAt = createTimestamp();
|
|
1757
1771
|
state.metrics.durationMs = Date.now() - state.metrics.startedAtMs;
|
|
1758
1772
|
await config.onOutcome?.(outcome);
|
|
1759
1773
|
return createRunResult(config, state, outcome);
|
|
1760
1774
|
}
|
|
1775
|
+
function createTerminalOutcome(phase, output, transcript) {
|
|
1776
|
+
return phase.run || phase.factory ? createOutcome.phase(output, transcript) : createOutcome.default(output, transcript);
|
|
1777
|
+
}
|
|
1761
1778
|
function buildToolsWithRouting(config, availablePhases) {
|
|
1762
1779
|
const tools = [...config.context.tools];
|
|
1763
1780
|
if (availablePhases.length > 0) {
|
|
@@ -1991,10 +2008,34 @@ async function runPhaseLoop(config, state, registry) {
|
|
|
1991
2008
|
const routeToolAvailable = phaseContext.tools.some((tool) => tool.name === PhaseRouteTool);
|
|
1992
2009
|
const routeRequired = !phase.target && !phase.run && !phase.factory && routeToolAvailable && registry.phases.size > 1;
|
|
1993
2010
|
if (routeRequired && !routeDecision) {
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
2011
|
+
if (config.waitForInput) {
|
|
2012
|
+
const preAbort = LoopGuard.checkAbort(config.signal);
|
|
2013
|
+
if (preAbort.stopReason !== "none") {
|
|
2014
|
+
config.emit?.({ type: "phase_end", phase: currentPhaseId, ts: createTimestamp() });
|
|
2015
|
+
removePhaseMessage(config.context.messages, previousPhaseMsgId);
|
|
2016
|
+
previousPhaseMsgId = void 0;
|
|
2017
|
+
return completeRun(config, state, createOutcome.aborted());
|
|
2018
|
+
}
|
|
2019
|
+
config.emit?.({ type: "user_prompt_requested", phase: currentPhaseId, ts: createTimestamp() });
|
|
2020
|
+
const userMessages = await config.waitForInput();
|
|
2021
|
+
const abortResult2 = LoopGuard.checkAbort(config.signal);
|
|
2022
|
+
if (abortResult2.stopReason !== "none") {
|
|
2023
|
+
config.emit?.({ type: "phase_end", phase: currentPhaseId, ts: createTimestamp() });
|
|
2024
|
+
removePhaseMessage(config.context.messages, previousPhaseMsgId);
|
|
2025
|
+
previousPhaseMsgId = void 0;
|
|
2026
|
+
return completeRun(config, state, createOutcome.aborted());
|
|
2027
|
+
}
|
|
2028
|
+
for (const message of userMessages) {
|
|
2029
|
+
config.context.messages.push(message);
|
|
2030
|
+
}
|
|
2031
|
+
removePhaseMessage(config.context.messages, previousPhaseMsgId);
|
|
2032
|
+
previousPhaseMsgId = void 0;
|
|
2033
|
+
isContinuing = true;
|
|
2034
|
+
continue;
|
|
2035
|
+
}
|
|
2036
|
+
config.emit?.({ type: "phase_end", phase: currentPhaseId, ts: createTimestamp() });
|
|
2037
|
+
removePhaseMessage(config.context.messages, previousPhaseMsgId);
|
|
2038
|
+
return completeRun(config, state, createOutcome.default(output, config.context.messages));
|
|
1998
2039
|
}
|
|
1999
2040
|
if (output.route === "continue") {
|
|
2000
2041
|
isContinuing = true;
|
|
@@ -2020,7 +2061,7 @@ async function runPhaseLoop(config, state, registry) {
|
|
|
2020
2061
|
pendingInstruction = routeDecision.instruction;
|
|
2021
2062
|
const entryPhaseId = phase.target ?? registry.entryPhaseId;
|
|
2022
2063
|
if (entryPhaseId === "stop") {
|
|
2023
|
-
return completeRun(config, state,
|
|
2064
|
+
return completeRun(config, state, createTerminalOutcome(phase, output, config.context.messages));
|
|
2024
2065
|
}
|
|
2025
2066
|
currentPhaseId = entryPhaseId;
|
|
2026
2067
|
previousPayload = void 0;
|
|
@@ -2036,7 +2077,7 @@ async function runPhaseLoop(config, state, registry) {
|
|
|
2036
2077
|
}
|
|
2037
2078
|
if (nextRoute === "stop") {
|
|
2038
2079
|
if (routeToolCalled) removePhaseMessage(config.context.messages, previousPhaseMsgId);
|
|
2039
|
-
return completeRun(config, state,
|
|
2080
|
+
return completeRun(config, state, createTerminalOutcome(phase, output, config.context.messages));
|
|
2040
2081
|
}
|
|
2041
2082
|
const targetPhaseId = nextRoute;
|
|
2042
2083
|
if (!registry.phases.has(targetPhaseId)) {
|
|
@@ -3439,7 +3480,8 @@ var Agent = class {
|
|
|
3439
3480
|
context: prepareAgentContext(context),
|
|
3440
3481
|
model: this.options.model,
|
|
3441
3482
|
tools: this.options.context.tools ?? [],
|
|
3442
|
-
|
|
3483
|
+
initialized: false,
|
|
3484
|
+
running: false
|
|
3443
3485
|
};
|
|
3444
3486
|
}
|
|
3445
3487
|
subscribe(listener) {
|
|
@@ -3458,13 +3500,32 @@ var Agent = class {
|
|
|
3458
3500
|
this.setMessages([...this.options.context.messages, ...snapshotMessages(messages)]);
|
|
3459
3501
|
}
|
|
3460
3502
|
runWithUserInput(input, options) {
|
|
3503
|
+
const activeRun = this.activeRun;
|
|
3504
|
+
if (activeRun?.resume) {
|
|
3505
|
+
activeRun.resume([createMessage("user", input)]);
|
|
3506
|
+
return activeRun.promise;
|
|
3507
|
+
}
|
|
3508
|
+
if (activeRun) {
|
|
3509
|
+
return Promise.reject(new Error("Agent is already running."));
|
|
3510
|
+
}
|
|
3461
3511
|
this.appendUserMessage(input);
|
|
3462
3512
|
return this.run(options);
|
|
3463
3513
|
}
|
|
3464
3514
|
runWithMessage(message, options) {
|
|
3515
|
+
const activeRun = this.activeRun;
|
|
3516
|
+
if (activeRun?.resume) {
|
|
3517
|
+
activeRun.resume([message]);
|
|
3518
|
+
return activeRun.promise;
|
|
3519
|
+
}
|
|
3520
|
+
if (activeRun) {
|
|
3521
|
+
return Promise.reject(new Error("Agent is already running."));
|
|
3522
|
+
}
|
|
3465
3523
|
this.appendMessage(message);
|
|
3466
3524
|
return this.run(options);
|
|
3467
3525
|
}
|
|
3526
|
+
resetInitialization() {
|
|
3527
|
+
this.state.initialized = false;
|
|
3528
|
+
}
|
|
3468
3529
|
getContext() {
|
|
3469
3530
|
return prepareAgentContext(this.options.context);
|
|
3470
3531
|
}
|
|
@@ -3679,31 +3740,30 @@ var Agent = class {
|
|
|
3679
3740
|
const message = error instanceof Error ? error.message : "Agent run failed.";
|
|
3680
3741
|
this.state.error = message;
|
|
3681
3742
|
}
|
|
3682
|
-
|
|
3743
|
+
runWithLifecycle(executor) {
|
|
3683
3744
|
if (this.activeRun) {
|
|
3684
|
-
|
|
3745
|
+
return Promise.reject(new Error("Agent is already running."));
|
|
3685
3746
|
}
|
|
3686
|
-
let resolvePromise;
|
|
3687
3747
|
const abortController = new AbortController();
|
|
3688
|
-
const
|
|
3689
|
-
|
|
3748
|
+
const waitForInput = () => new Promise((resolve7) => {
|
|
3749
|
+
const activeRun = this.activeRun;
|
|
3750
|
+
activeRun.resume = (messages) => {
|
|
3751
|
+
activeRun.resume = void 0;
|
|
3752
|
+
resolve7(messages);
|
|
3753
|
+
};
|
|
3690
3754
|
});
|
|
3691
|
-
|
|
3692
|
-
this.state.isRunning = true;
|
|
3693
|
-
try {
|
|
3694
|
-
const result = await executor(abortController.signal);
|
|
3695
|
-
resolvePromise(result);
|
|
3696
|
-
return result;
|
|
3697
|
-
} catch (error) {
|
|
3755
|
+
const promise = Promise.resolve().then(() => executor({ signal: abortController.signal, waitForInput })).catch((error) => {
|
|
3698
3756
|
this.handleRunFailure(error, abortController.signal.aborted);
|
|
3699
|
-
resolvePromise(void 0);
|
|
3700
3757
|
throw error;
|
|
3701
|
-
}
|
|
3758
|
+
}).finally(() => {
|
|
3702
3759
|
this.finishRun();
|
|
3703
|
-
}
|
|
3760
|
+
});
|
|
3761
|
+
this.activeRun = { promise, abortController };
|
|
3762
|
+
this.state.running = true;
|
|
3763
|
+
return promise;
|
|
3704
3764
|
}
|
|
3705
3765
|
finishRun() {
|
|
3706
|
-
this.state.
|
|
3766
|
+
this.state.running = false;
|
|
3707
3767
|
this.activeRun = void 0;
|
|
3708
3768
|
}
|
|
3709
3769
|
async loadExtensions(extensions, cwd) {
|
|
@@ -3725,22 +3785,30 @@ var Agent = class {
|
|
|
3725
3785
|
this.loadedExtensions = extensions;
|
|
3726
3786
|
this.loadedExtensionsCwd = cwd;
|
|
3727
3787
|
}
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3788
|
+
run(config) {
|
|
3789
|
+
return this.runWithLifecycle(async ({ signal, waitForInput }) => {
|
|
3790
|
+
const resolved = this.resolveRunConfig(config);
|
|
3791
|
+
const extensions = resolved.extensions ?? [];
|
|
3792
|
+
await this.loadExtensions(extensions, resolved.cwd);
|
|
3793
|
+
const runContext = prepareAgentContext(resolved.context, this.extensionRunner);
|
|
3794
|
+
const entryPhaseId = this.state.initialized ? DEFAULT_PHASE_ID : runContext.phases?.entryPhaseId ?? DEFAULT_PHASE_ID;
|
|
3795
|
+
const loopContext = {
|
|
3796
|
+
...runContext,
|
|
3797
|
+
phases: {
|
|
3798
|
+
...runContext.phases,
|
|
3799
|
+
entryPhaseId
|
|
3800
|
+
}
|
|
3801
|
+
};
|
|
3802
|
+
const sessionId = resolved.sessionId ?? this.state.sessionId;
|
|
3803
|
+
this.options = resolved;
|
|
3804
|
+
if (sessionId) {
|
|
3805
|
+
this.state.sessionId = sessionId;
|
|
3806
|
+
}
|
|
3807
|
+
this.state.context = runContext;
|
|
3808
|
+
this.state.model = resolved.model;
|
|
3809
|
+
this.state.tools = runContext.tools ?? [];
|
|
3810
|
+
this.state.currentResult = void 0;
|
|
3811
|
+
this.state.error = void 0;
|
|
3744
3812
|
const emit = (event) => {
|
|
3745
3813
|
this.processEvents(event);
|
|
3746
3814
|
};
|
|
@@ -3763,7 +3831,7 @@ var Agent = class {
|
|
|
3763
3831
|
return this.handleAfterToolCall(input.tool, result2);
|
|
3764
3832
|
};
|
|
3765
3833
|
const result = await runAgentLoop({
|
|
3766
|
-
context:
|
|
3834
|
+
context: loopContext,
|
|
3767
3835
|
sessionId: sessionId ?? createId("ses"),
|
|
3768
3836
|
model: resolved.model,
|
|
3769
3837
|
stream: resolved.stream,
|
|
@@ -3777,7 +3845,8 @@ var Agent = class {
|
|
|
3777
3845
|
emit,
|
|
3778
3846
|
onMessage: resolved.onMessage,
|
|
3779
3847
|
onOutcome: resolved.onOutcome,
|
|
3780
|
-
onModelTranscript: resolved.onModelTranscript
|
|
3848
|
+
onModelTranscript: resolved.onModelTranscript,
|
|
3849
|
+
waitForInput
|
|
3781
3850
|
});
|
|
3782
3851
|
const nextContext = {
|
|
3783
3852
|
...prepareAgentContext(resolved.context),
|
|
@@ -3786,6 +3855,7 @@ var Agent = class {
|
|
|
3786
3855
|
this.state.sessionId = result.sessionId;
|
|
3787
3856
|
this.state.context = prepareAgentContext(nextContext, this.extensionRunner);
|
|
3788
3857
|
this.state.currentResult = result;
|
|
3858
|
+
this.state.initialized = true;
|
|
3789
3859
|
this.options = {
|
|
3790
3860
|
...resolved,
|
|
3791
3861
|
sessionId: result.sessionId,
|
|
@@ -3795,7 +3865,9 @@ var Agent = class {
|
|
|
3795
3865
|
});
|
|
3796
3866
|
}
|
|
3797
3867
|
abort(reason = "Aborted by caller.") {
|
|
3798
|
-
this.activeRun
|
|
3868
|
+
const activeRun = this.activeRun;
|
|
3869
|
+
activeRun?.resume?.([]);
|
|
3870
|
+
activeRun?.abortController.abort(reason);
|
|
3799
3871
|
}
|
|
3800
3872
|
/**
|
|
3801
3873
|
* Get formatted skill content for LLM consumption.
|
|
@@ -4422,7 +4494,6 @@ export {
|
|
|
4422
4494
|
ExtensionRunner,
|
|
4423
4495
|
HooksManager,
|
|
4424
4496
|
LocalJsonlSessionManager,
|
|
4425
|
-
MissingRouteToolCallError,
|
|
4426
4497
|
appendUserTurn,
|
|
4427
4498
|
buildModelRequest,
|
|
4428
4499
|
buildSystemPrompt,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rowan-agent/agent",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"build": "tsup"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@rowan-agent/models": "0.
|
|
26
|
+
"@rowan-agent/models": "0.5.5",
|
|
27
27
|
"jiti": "2.7.0",
|
|
28
28
|
"typebox": "^1.0.0",
|
|
29
29
|
"yaml": "^2.7.0"
|