@rowan-agent/agent 0.10.2 → 0.11.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 +15 -10
- package/dist/index.js +86 -33
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -98,6 +98,7 @@ type ExecutionContinuationState = {
|
|
|
98
98
|
|
|
99
99
|
type PhaseInteractionKind = "user_input" | "permission" | "elicitation" | "confirmation";
|
|
100
100
|
type PhaseInteractionStatus = "pending" | "answered" | "denied" | "cancelled" | "expired";
|
|
101
|
+
type PhaseInteractionOrigin = "tool_call" | "phase";
|
|
101
102
|
type PhaseInteraction = Readonly<{
|
|
102
103
|
id: string;
|
|
103
104
|
phase: string;
|
|
@@ -106,6 +107,8 @@ type PhaseInteraction = Readonly<{
|
|
|
106
107
|
payload?: JsonValue;
|
|
107
108
|
createdAt: string;
|
|
108
109
|
status: PhaseInteractionStatus;
|
|
110
|
+
origin?: PhaseInteractionOrigin;
|
|
111
|
+
toolCallId?: string;
|
|
109
112
|
}>;
|
|
110
113
|
type PhaseInteractionState = Readonly<{
|
|
111
114
|
requests: readonly PhaseInteraction[];
|
|
@@ -119,6 +122,8 @@ type PhaseInteractionDriver = Readonly<{
|
|
|
119
122
|
kind: PhaseInteractionKind;
|
|
120
123
|
prompt: string;
|
|
121
124
|
payload?: JsonValue;
|
|
125
|
+
origin?: PhaseInteractionOrigin;
|
|
126
|
+
toolCallId?: string;
|
|
122
127
|
}>): PhaseInteraction;
|
|
123
128
|
pending(): readonly PhaseInteraction[];
|
|
124
129
|
answers(): ReadonlyMap<string, JsonValue>;
|
|
@@ -348,10 +353,10 @@ type RunStateChanged = DurableEventBase & (Readonly<{
|
|
|
348
353
|
kind: "run_state_changed";
|
|
349
354
|
from: "running";
|
|
350
355
|
to: "input_required";
|
|
351
|
-
request
|
|
356
|
+
request?: Readonly<{
|
|
352
357
|
id: InputRequestId;
|
|
353
358
|
phase: string;
|
|
354
|
-
prompt
|
|
359
|
+
prompt?: AssistantMessage;
|
|
355
360
|
}>;
|
|
356
361
|
interactions: readonly PhaseInteraction[];
|
|
357
362
|
answers: Readonly<Record<string, JsonValue>>;
|
|
@@ -1666,7 +1671,7 @@ type ExecutionCheckpoint = Readonly<{
|
|
|
1666
1671
|
type InputRequest = Readonly<{
|
|
1667
1672
|
id: InputRequestId;
|
|
1668
1673
|
phase: string;
|
|
1669
|
-
messageId
|
|
1674
|
+
messageId?: MessageId;
|
|
1670
1675
|
createdAt: string;
|
|
1671
1676
|
}>;
|
|
1672
1677
|
type OwnerLease = Readonly<{
|
|
@@ -1682,7 +1687,7 @@ type RunClaim = Readonly<{
|
|
|
1682
1687
|
}>;
|
|
1683
1688
|
type InputRequiredCommit = Readonly<{
|
|
1684
1689
|
run: RunRecord;
|
|
1685
|
-
prompt
|
|
1690
|
+
prompt?: AssistantMessage;
|
|
1686
1691
|
request: InputRequest;
|
|
1687
1692
|
interactions: readonly PhaseInteraction[];
|
|
1688
1693
|
}>;
|
|
@@ -1783,7 +1788,7 @@ type RunSnapshot = RunSnapshotBase & (Readonly<{
|
|
|
1783
1788
|
request: Readonly<{
|
|
1784
1789
|
id: InputRequestId;
|
|
1785
1790
|
phase: string;
|
|
1786
|
-
prompt
|
|
1791
|
+
prompt?: AssistantMessage;
|
|
1787
1792
|
}>;
|
|
1788
1793
|
interactions: readonly PhaseInteraction[];
|
|
1789
1794
|
answers: Readonly<Record<string, JsonValue>>;
|
|
@@ -1802,7 +1807,7 @@ type RunBoundary = Readonly<{
|
|
|
1802
1807
|
type: "input_required";
|
|
1803
1808
|
requestId: InputRequestId;
|
|
1804
1809
|
phase: string;
|
|
1805
|
-
prompt
|
|
1810
|
+
prompt?: AssistantMessage;
|
|
1806
1811
|
interactions: readonly PhaseInteraction[];
|
|
1807
1812
|
answers: Readonly<Record<string, JsonValue>>;
|
|
1808
1813
|
}> | Readonly<{
|
|
@@ -1902,7 +1907,7 @@ interface OwnedStore {
|
|
|
1902
1907
|
expectedRevision: number;
|
|
1903
1908
|
requestId?: InputRequestId;
|
|
1904
1909
|
phase: string;
|
|
1905
|
-
prompt
|
|
1910
|
+
prompt?: AssistantMessage;
|
|
1906
1911
|
checkpoint: ExecutionCheckpoint;
|
|
1907
1912
|
interactions?: readonly PhaseInteraction[];
|
|
1908
1913
|
interactionAnswers?: Readonly<Record<string, JsonValue>>;
|
|
@@ -2319,7 +2324,7 @@ declare class InMemoryStore implements DurableStore {
|
|
|
2319
2324
|
expectedRevision: number;
|
|
2320
2325
|
requestId?: InputRequestId;
|
|
2321
2326
|
phase: string;
|
|
2322
|
-
prompt
|
|
2327
|
+
prompt?: AssistantMessage;
|
|
2323
2328
|
checkpoint: ExecutionCheckpoint;
|
|
2324
2329
|
interactions?: readonly PhaseInteraction[];
|
|
2325
2330
|
interactionAnswers?: Readonly<Record<string, JsonValue>>;
|
|
@@ -2515,7 +2520,7 @@ declare class SqliteStore implements DurableStore {
|
|
|
2515
2520
|
expectedRevision: number;
|
|
2516
2521
|
requestId?: InputRequestId;
|
|
2517
2522
|
phase: string;
|
|
2518
|
-
prompt
|
|
2523
|
+
prompt?: AssistantMessage;
|
|
2519
2524
|
checkpoint: ExecutionCheckpoint;
|
|
2520
2525
|
interactions?: readonly PhaseInteraction[];
|
|
2521
2526
|
interactionAnswers?: Readonly<Record<string, JsonValue>>;
|
|
@@ -2813,4 +2818,4 @@ declare function parseFrontmatter<T = Record<string, unknown>>(raw: string): Fro
|
|
|
2813
2818
|
|
|
2814
2819
|
declare function createCoreTools(input?: CoreToolContext): Tool[];
|
|
2815
2820
|
|
|
2816
|
-
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 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 PhaseInput, 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 ToolCallInteractionRequest, 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, isConfigurationSnapshot, isRuntimeError, loadExtensionsFromPath as loadExtensions, loadPhase, loadPhaseSettings, loadPhases, loadSkill, loadSkills, parseAgentDefinition, parseFrontmatter, resolveConfigurationSnapshot };
|
|
2821
|
+
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 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 PhaseInput, type PhaseInteraction, PhaseInteractionBoundary, PhaseInteractionCancelledError, type PhaseInteractionDriver, type PhaseInteractionKind, type PhaseInteractionOrigin, 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 ToolCallInteractionRequest, 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, isConfigurationSnapshot, isRuntimeError, loadExtensionsFromPath as loadExtensions, loadPhase, loadPhaseSettings, loadPhases, loadSkill, loadSkills, parseAgentDefinition, parseFrontmatter, resolveConfigurationSnapshot };
|
package/dist/index.js
CHANGED
|
@@ -677,7 +677,18 @@ function createReadTool(context) {
|
|
|
677
677
|
error: invalidLimit
|
|
678
678
|
});
|
|
679
679
|
}
|
|
680
|
-
|
|
680
|
+
let fileStat;
|
|
681
|
+
try {
|
|
682
|
+
fileStat = await stat(resolved.absolutePath);
|
|
683
|
+
} catch (error) {
|
|
684
|
+
return toolResult({
|
|
685
|
+
context: toolContext,
|
|
686
|
+
toolName: "read",
|
|
687
|
+
ok: false,
|
|
688
|
+
content: null,
|
|
689
|
+
error: error instanceof Error ? error.message : String(error)
|
|
690
|
+
});
|
|
691
|
+
}
|
|
681
692
|
if (!fileStat.isFile()) {
|
|
682
693
|
return toolResult({
|
|
683
694
|
context: toolContext,
|
|
@@ -687,7 +698,18 @@ function createReadTool(context) {
|
|
|
687
698
|
error: `Not a file: ${resolved.relativePath}`
|
|
688
699
|
});
|
|
689
700
|
}
|
|
690
|
-
|
|
701
|
+
let bytes;
|
|
702
|
+
try {
|
|
703
|
+
bytes = await readFile2(resolved.absolutePath);
|
|
704
|
+
} catch (error) {
|
|
705
|
+
return toolResult({
|
|
706
|
+
context: toolContext,
|
|
707
|
+
toolName: "read",
|
|
708
|
+
ok: false,
|
|
709
|
+
content: null,
|
|
710
|
+
error: error instanceof Error ? error.message : String(error)
|
|
711
|
+
});
|
|
712
|
+
}
|
|
691
713
|
const source = new TextDecoder().decode(bytes);
|
|
692
714
|
const sourceLines = source.split(/\r\n|\n|\r/);
|
|
693
715
|
const requestedOffset = parsed.offset ?? 1;
|
|
@@ -1380,6 +1402,8 @@ function createPhaseInteractionDriver(state, phase, signal) {
|
|
|
1380
1402
|
kind: input.kind,
|
|
1381
1403
|
prompt: input.prompt,
|
|
1382
1404
|
...input.payload === void 0 ? {} : { payload: input.payload },
|
|
1405
|
+
...input.origin === void 0 ? {} : { origin: input.origin },
|
|
1406
|
+
...input.toolCallId === void 0 ? {} : { toolCallId: input.toolCallId },
|
|
1383
1407
|
createdAt: createTimestamp(),
|
|
1384
1408
|
status: "pending"
|
|
1385
1409
|
};
|
|
@@ -6380,19 +6404,20 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
6380
6404
|
return;
|
|
6381
6405
|
}
|
|
6382
6406
|
if (result.type === "input_required") {
|
|
6407
|
+
const isToolCallInteraction = result.interactions?.some((i) => i.origin === "tool_call");
|
|
6383
6408
|
const output = result.interactions && result.interactions.length > 0 ? void 0 : latestAssistant(
|
|
6384
6409
|
run,
|
|
6385
6410
|
result.messages.slice(modelMessages.length),
|
|
6386
6411
|
modelMessages.length
|
|
6387
6412
|
);
|
|
6388
|
-
const prompt = output ?? promptMessage(run, result.request.prompt, result.messages.length);
|
|
6413
|
+
const prompt = isToolCallInteraction ? void 0 : output ?? promptMessage(run, result.request.prompt, result.messages.length);
|
|
6389
6414
|
await this.owned.commitInputRequired({
|
|
6390
6415
|
runId: run.id,
|
|
6391
6416
|
execution: claim.execution,
|
|
6392
6417
|
expectedRevision: executionRevision,
|
|
6393
6418
|
requestId: createId("input"),
|
|
6394
6419
|
phase: result.request.phase,
|
|
6395
|
-
prompt,
|
|
6420
|
+
...prompt ? { prompt } : {},
|
|
6396
6421
|
checkpoint: result.checkpoint,
|
|
6397
6422
|
interactions: result.interactions,
|
|
6398
6423
|
interactionAnswers: claim.run.interactionAnswers
|
|
@@ -6735,7 +6760,9 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
6735
6760
|
id: decision.interaction.id,
|
|
6736
6761
|
kind: decision.interaction.kind,
|
|
6737
6762
|
prompt: decision.interaction.prompt,
|
|
6738
|
-
payload: decision.interaction.payload
|
|
6763
|
+
payload: decision.interaction.payload,
|
|
6764
|
+
origin: "tool_call",
|
|
6765
|
+
toolCallId
|
|
6739
6766
|
});
|
|
6740
6767
|
input.driver.suspend({
|
|
6741
6768
|
checkpoint: {
|
|
@@ -7055,7 +7082,7 @@ function boundaryFromSnapshot(snapshot) {
|
|
|
7055
7082
|
type: "input_required",
|
|
7056
7083
|
requestId: snapshot.request.id,
|
|
7057
7084
|
phase: snapshot.request.phase,
|
|
7058
|
-
prompt: snapshot.request.prompt,
|
|
7085
|
+
...snapshot.request.prompt ? { prompt: snapshot.request.prompt } : {},
|
|
7059
7086
|
interactions: snapshot.interactions,
|
|
7060
7087
|
answers: snapshot.answers
|
|
7061
7088
|
};
|
|
@@ -7630,24 +7657,28 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
7630
7657
|
const requestId = input.requestId ?? createId("input");
|
|
7631
7658
|
const operationKey = `input_required:${requestId}`;
|
|
7632
7659
|
const interactions = input.interactions ?? [];
|
|
7633
|
-
const operationPayload = canonicalJson([input.runId, input.expectedRevision, input.phase, input.prompt.id, input.checkpoint, interactions, input.interactionAnswers ?? null]);
|
|
7660
|
+
const operationPayload = canonicalJson([input.runId, input.expectedRevision, input.phase, input.prompt ? input.prompt.id : null, input.checkpoint, interactions, input.interactionAnswers ?? null]);
|
|
7634
7661
|
const replay = this.replayOperation(operationKey, operationPayload);
|
|
7635
7662
|
if (replay) return clone(replay);
|
|
7636
7663
|
const run = this.requireRun(input.runId);
|
|
7637
7664
|
this.assertExecution(run, input.execution, input.expectedRevision);
|
|
7638
7665
|
this.assertState(run, ["running"]);
|
|
7639
7666
|
this.assertNoOpenTools(run);
|
|
7640
|
-
const
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
|
|
7667
|
+
const isToolCallInteraction = interactions.length > 0 && interactions.some((interaction) => interaction.origin === "tool_call");
|
|
7668
|
+
let prompt;
|
|
7669
|
+
if (input.prompt && !isToolCallInteraction) {
|
|
7670
|
+
prompt = {
|
|
7671
|
+
...clone(input.prompt),
|
|
7672
|
+
sequenceWithinRun: this.nextMessageSequence(run.id)
|
|
7673
|
+
};
|
|
7674
|
+
this.messages.set(prompt.id, prompt);
|
|
7675
|
+
}
|
|
7644
7676
|
const request = {
|
|
7645
7677
|
id: requestId,
|
|
7646
7678
|
phase: input.phase,
|
|
7647
|
-
messageId: prompt.id,
|
|
7679
|
+
...prompt ? { messageId: prompt.id } : {},
|
|
7648
7680
|
createdAt: createTimestamp()
|
|
7649
7681
|
};
|
|
7650
|
-
this.messages.set(prompt.id, prompt);
|
|
7651
7682
|
run.state = "input_required";
|
|
7652
7683
|
run.checkpoint = clone(input.checkpoint);
|
|
7653
7684
|
run.openInputRequest = request;
|
|
@@ -7662,9 +7693,16 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
7662
7693
|
delete run.execution;
|
|
7663
7694
|
run.revision += 1;
|
|
7664
7695
|
run.updatedAt = createTimestamp();
|
|
7665
|
-
|
|
7696
|
+
if (prompt) {
|
|
7697
|
+
this.appendMessage(run, prompt);
|
|
7698
|
+
}
|
|
7666
7699
|
this.appendTransition(run, "running", "input_required", request, prompt, void 0, void 0, void 0, interactions, run.interactionAnswers ?? {});
|
|
7667
|
-
const result = {
|
|
7700
|
+
const result = {
|
|
7701
|
+
run: clone(run),
|
|
7702
|
+
...prompt ? { prompt: clone(prompt) } : {},
|
|
7703
|
+
request: clone(request),
|
|
7704
|
+
interactions: clone(interactions)
|
|
7705
|
+
};
|
|
7668
7706
|
this.writeOperationReceipt(operationKey, operationPayload, result);
|
|
7669
7707
|
return result;
|
|
7670
7708
|
}
|
|
@@ -7717,28 +7755,33 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
7717
7755
|
this.assertRevision(run, input.expectedRevision);
|
|
7718
7756
|
this.assertState(run, ["input_required"]);
|
|
7719
7757
|
const openInteractions = run.openInteractions ?? [];
|
|
7720
|
-
|
|
7758
|
+
const targetInteraction = openInteractions.find((interaction) => interaction.id === input.interactionId);
|
|
7759
|
+
if (!targetInteraction) {
|
|
7721
7760
|
throw new RuntimeError("input_request_conflict", { runId: run.id, requestId: input.interactionId, reason: "not_found" });
|
|
7722
7761
|
}
|
|
7723
|
-
const
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
|
|
7762
|
+
const isToolCall = targetInteraction.origin === "tool_call";
|
|
7763
|
+
const now = createTimestamp();
|
|
7764
|
+
if (!isToolCall) {
|
|
7765
|
+
const message = {
|
|
7766
|
+
id: createId("msg"),
|
|
7767
|
+
agentId: run.agentId,
|
|
7768
|
+
runId: run.id,
|
|
7769
|
+
role: "user",
|
|
7770
|
+
content: typeof input.input === "string" ? input.input : JSON.stringify(input.input),
|
|
7771
|
+
metadata: { kind: "phase_interaction", interactionId: input.interactionId },
|
|
7772
|
+
sequenceWithinRun: this.nextMessageSequence(run.id),
|
|
7773
|
+
createdAt: now
|
|
7774
|
+
};
|
|
7775
|
+
this.messages.set(message.id, message);
|
|
7776
|
+
this.appendMessage(run, message);
|
|
7777
|
+
}
|
|
7734
7778
|
run.openInteractions = openInteractions.filter((interaction) => interaction.id !== input.interactionId);
|
|
7735
7779
|
run.interactionAnswers = {
|
|
7736
7780
|
...run.interactionAnswers ?? {},
|
|
7737
7781
|
[input.interactionId]: clone(input.input)
|
|
7738
7782
|
};
|
|
7739
7783
|
run.revision += 1;
|
|
7740
|
-
run.updatedAt =
|
|
7741
|
-
this.appendMessage(run, message);
|
|
7784
|
+
run.updatedAt = now;
|
|
7742
7785
|
if (run.openInteractions.length === 0) {
|
|
7743
7786
|
delete run.openInteractions;
|
|
7744
7787
|
delete run.openInputRequest;
|
|
@@ -8039,12 +8082,16 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
8039
8082
|
return { ...base, state: run.state };
|
|
8040
8083
|
case "input_required": {
|
|
8041
8084
|
const request = run.openInputRequest;
|
|
8042
|
-
const prompt = request
|
|
8043
|
-
if (!prompt || prompt.role !== "assistant") throw new Error(`Run ${run.id} has an invalid input prompt.`);
|
|
8085
|
+
const prompt = request?.messageId ? this.messages.get(request.messageId) : void 0;
|
|
8086
|
+
if (request?.messageId && (!prompt || prompt.role !== "assistant")) throw new Error(`Run ${run.id} has an invalid input prompt.`);
|
|
8044
8087
|
return {
|
|
8045
8088
|
...base,
|
|
8046
8089
|
state: "input_required",
|
|
8047
|
-
request: {
|
|
8090
|
+
request: {
|
|
8091
|
+
id: request?.id ?? "",
|
|
8092
|
+
phase: request?.phase ?? "",
|
|
8093
|
+
...prompt ? { prompt: clone(prompt) } : {}
|
|
8094
|
+
},
|
|
8048
8095
|
interactions: clone(run.openInteractions ?? []),
|
|
8049
8096
|
answers: clone(run.interactionAnswers ?? {})
|
|
8050
8097
|
};
|
|
@@ -8366,7 +8413,13 @@ ${record.summary}`,
|
|
|
8366
8413
|
kind: "run_state_changed",
|
|
8367
8414
|
from,
|
|
8368
8415
|
to,
|
|
8369
|
-
...to === "input_required" && request
|
|
8416
|
+
...to === "input_required" && request ? {
|
|
8417
|
+
request: {
|
|
8418
|
+
id: request.id,
|
|
8419
|
+
phase: request.phase,
|
|
8420
|
+
...prompt ? { prompt } : {}
|
|
8421
|
+
}
|
|
8422
|
+
} : {},
|
|
8370
8423
|
...to === "input_required" ? { interactions: clone(interactions ?? []), answers: clone(answers ?? {}) } : {},
|
|
8371
8424
|
...to === "completed" && outcome ? { outcome } : {},
|
|
8372
8425
|
...to === "failed" && failure ? { failure } : {},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rowan-agent/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"build": "tsup && bun scripts/check-public-interface.ts"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@rowan-agent/models": "0.6.
|
|
26
|
+
"@rowan-agent/models": "0.6.8",
|
|
27
27
|
"jiti": "2.7.0",
|
|
28
28
|
"typebox": "^1.0.0",
|
|
29
29
|
"yaml": "^2.7.0"
|