@rowan-agent/agent 0.8.0 → 0.8.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/README.md +2 -2
- package/dist/index.d.ts +18 -11
- package/dist/index.js +9 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -84,7 +84,7 @@ JSON-safe value. Progress is live-only and may be dropped.
|
|
|
84
84
|
|
|
85
85
|
- transient `message_delta` and `tool_progress` events are live-only and
|
|
86
86
|
best-effort;
|
|
87
|
-
- durable `message_committed`, `
|
|
87
|
+
- durable `message_committed`, `run_state_changed`, and `tool_state_changed`
|
|
88
88
|
events are replayable;
|
|
89
89
|
- a durable `message_committed` event is the authoritative full content if a
|
|
90
90
|
transient delta was coalesced or dropped.
|
|
@@ -92,7 +92,7 @@ JSON-safe value. Progress is live-only and may be dropped.
|
|
|
92
92
|
`runtime.consume()` delivers only `DurableRunEvent` values:
|
|
93
93
|
|
|
94
94
|
- `message_committed`
|
|
95
|
-
- `
|
|
95
|
+
- `run_state_changed`
|
|
96
96
|
- `tool_state_changed`
|
|
97
97
|
|
|
98
98
|
Durable events and their corresponding Run aggregate changes commit in one
|
package/dist/index.d.ts
CHANGED
|
@@ -747,44 +747,45 @@ type MessageCommitted = DurableEventBase & Readonly<{
|
|
|
747
747
|
kind: "message_committed";
|
|
748
748
|
message: Message;
|
|
749
749
|
}>;
|
|
750
|
-
type
|
|
751
|
-
kind: "
|
|
750
|
+
type RunStateChanged = DurableEventBase & (Readonly<{
|
|
751
|
+
kind: "run_state_changed";
|
|
752
752
|
from: null;
|
|
753
753
|
to: "queued";
|
|
754
754
|
}> | Readonly<{
|
|
755
|
-
kind: "
|
|
755
|
+
kind: "run_state_changed";
|
|
756
756
|
from: "input_required";
|
|
757
757
|
to: "queued";
|
|
758
758
|
}> | Readonly<{
|
|
759
|
-
kind: "
|
|
759
|
+
kind: "run_state_changed";
|
|
760
760
|
from: "queued";
|
|
761
761
|
to: "running";
|
|
762
762
|
}> | Readonly<{
|
|
763
|
-
kind: "
|
|
763
|
+
kind: "run_state_changed";
|
|
764
764
|
from: "running";
|
|
765
765
|
to: "input_required";
|
|
766
766
|
request: Readonly<{
|
|
767
767
|
id: InputRequestId;
|
|
768
|
+
phase: string;
|
|
768
769
|
prompt: AssistantMessage;
|
|
769
770
|
}>;
|
|
770
771
|
}> | Readonly<{
|
|
771
|
-
kind: "
|
|
772
|
+
kind: "run_state_changed";
|
|
772
773
|
from: "running";
|
|
773
774
|
to: "completed";
|
|
774
775
|
outcome: Outcome;
|
|
775
776
|
output?: AssistantMessage;
|
|
776
777
|
}> | Readonly<{
|
|
777
|
-
kind: "
|
|
778
|
+
kind: "run_state_changed";
|
|
778
779
|
from: "queued";
|
|
779
780
|
to: "failed";
|
|
780
781
|
failure: QueuedRunFailure;
|
|
781
782
|
}> | Readonly<{
|
|
782
|
-
kind: "
|
|
783
|
+
kind: "run_state_changed";
|
|
783
784
|
from: "running";
|
|
784
785
|
to: "failed";
|
|
785
786
|
failure: RunningRunFailure;
|
|
786
787
|
}> | Readonly<{
|
|
787
|
-
kind: "
|
|
788
|
+
kind: "run_state_changed";
|
|
788
789
|
from: "queued" | "running" | "input_required";
|
|
789
790
|
to: "cancelled";
|
|
790
791
|
reason?: string;
|
|
@@ -844,7 +845,7 @@ type ToolStateChanged = DurableEventBase & (Readonly<{
|
|
|
844
845
|
state: "indeterminate";
|
|
845
846
|
}>;
|
|
846
847
|
}>);
|
|
847
|
-
type DurableRunEvent = MessageCommitted |
|
|
848
|
+
type DurableRunEvent = MessageCommitted | RunStateChanged | ToolStateChanged;
|
|
848
849
|
type MessageDelta = Readonly<{
|
|
849
850
|
kind: "message_delta";
|
|
850
851
|
durability: "transient";
|
|
@@ -944,6 +945,7 @@ type ExecutionCheckpoint = Readonly<{
|
|
|
944
945
|
}>;
|
|
945
946
|
type InputRequest = Readonly<{
|
|
946
947
|
id: InputRequestId;
|
|
948
|
+
phase: string;
|
|
947
949
|
messageId: MessageId;
|
|
948
950
|
createdAt: string;
|
|
949
951
|
}>;
|
|
@@ -1036,6 +1038,7 @@ type RunSnapshot = RunSnapshotBase & (Readonly<{
|
|
|
1036
1038
|
state: "input_required";
|
|
1037
1039
|
request: Readonly<{
|
|
1038
1040
|
id: InputRequestId;
|
|
1041
|
+
phase: string;
|
|
1039
1042
|
prompt: AssistantMessage;
|
|
1040
1043
|
}>;
|
|
1041
1044
|
}> | Readonly<{
|
|
@@ -1052,6 +1055,7 @@ type RunSnapshot = RunSnapshotBase & (Readonly<{
|
|
|
1052
1055
|
type RunBoundary = Readonly<{
|
|
1053
1056
|
type: "input_required";
|
|
1054
1057
|
requestId: InputRequestId;
|
|
1058
|
+
phase: string;
|
|
1055
1059
|
prompt: AssistantMessage;
|
|
1056
1060
|
}> | Readonly<{
|
|
1057
1061
|
type: "completed";
|
|
@@ -1132,6 +1136,7 @@ interface OwnedStore {
|
|
|
1132
1136
|
execution: ExecutionToken;
|
|
1133
1137
|
expectedRevision: number;
|
|
1134
1138
|
requestId?: InputRequestId;
|
|
1139
|
+
phase: string;
|
|
1135
1140
|
prompt: AssistantMessage;
|
|
1136
1141
|
checkpoint: ExecutionCheckpoint;
|
|
1137
1142
|
}): Promise<InputRequiredCommit>;
|
|
@@ -1426,6 +1431,7 @@ declare class InMemoryStore implements DurableStore {
|
|
|
1426
1431
|
execution: ExecutionToken;
|
|
1427
1432
|
expectedRevision: number;
|
|
1428
1433
|
requestId?: InputRequestId;
|
|
1434
|
+
phase: string;
|
|
1429
1435
|
prompt: AssistantMessage;
|
|
1430
1436
|
checkpoint: ExecutionCheckpoint;
|
|
1431
1437
|
}): InputRequiredCommit;
|
|
@@ -1572,6 +1578,7 @@ declare class SqliteStore implements DurableStore {
|
|
|
1572
1578
|
execution: ExecutionToken;
|
|
1573
1579
|
expectedRevision: number;
|
|
1574
1580
|
requestId?: InputRequestId;
|
|
1581
|
+
phase: string;
|
|
1575
1582
|
prompt: AssistantMessage;
|
|
1576
1583
|
checkpoint: ExecutionCheckpoint;
|
|
1577
1584
|
}): Promise<InputRequiredCommit>;
|
|
@@ -1800,4 +1807,4 @@ declare function loadExtensionsFromPath(path: string): Promise<{
|
|
|
1800
1807
|
|
|
1801
1808
|
declare function createCoreTools(input?: CoreToolContext): Tool[];
|
|
1802
1809
|
|
|
1803
|
-
export { type AfterToolCall, type AgentConfig, type AgentDefinitionContext, type AgentId, type AgentListCursor, type AgentRecord, type AgentRun, AgentRuntime, type AgentRuntimeOptions, type AgentSummary, type AnyRuntimeError, type AssistantContent, type AssistantMessage, type BeforeToolCall, type ConfigProvider, type ConfigPutResult, type ConfigResolution, type ConfigToken, type CoreToolContext, type DurableConsumer, type DurableRunEvent, type DurableStore, type DurableToolResult, type EventCursor, type EventId, type ExecutionCheckpoint, type ExecutionId, type ExecutionToken, type ExtensionAPI, type ExtensionFactory, type HookEvent, type HookEventType, type HookHandler, InMemoryConfigProvider, InMemoryStore, type InputRequest, type InputRequestId, type InputRequiredCommit, type JsonObject, type JsonPrimitive, type JsonValue, type LoadExtensionsResult, type LoadedExtension, type Message, type MessageBase, type MessageCommitted, type MessageContent, type MessageDelta, type MessageId, type Metadata, type OpaqueId, type Outcome, type OwnerLease, type OwnerToken, type Page, type Phase, type PhaseContext, type PhaseExecutionIdentity, type PhaseInvocation, type PhaseOutput, type PhaseRegistry, type PhaseState, type RunBoundary, type RunClaim, type RunEvent, type RunFailure, type RunId, type RunListCursor, type RunRecord, type RunSnapshot, type RunState, type
|
|
1810
|
+
export { type AfterToolCall, type AgentConfig, type AgentDefinitionContext, type AgentId, type AgentListCursor, type AgentRecord, type AgentRun, AgentRuntime, type AgentRuntimeOptions, type AgentSummary, type AnyRuntimeError, type AssistantContent, type AssistantMessage, type BeforeToolCall, type ConfigProvider, type ConfigPutResult, type ConfigResolution, type ConfigToken, type CoreToolContext, type DurableConsumer, type DurableRunEvent, type DurableStore, type DurableToolResult, type EventCursor, type EventId, type ExecutionCheckpoint, type ExecutionId, type ExecutionToken, type ExtensionAPI, type ExtensionFactory, type HookEvent, type HookEventType, type HookHandler, InMemoryConfigProvider, InMemoryStore, type InputRequest, type InputRequestId, type InputRequiredCommit, type JsonObject, type JsonPrimitive, type JsonValue, type LoadExtensionsResult, type LoadedExtension, type Message, type MessageBase, type MessageCommitted, type MessageContent, type MessageDelta, type MessageId, type Metadata, type OpaqueId, type Outcome, type OwnerLease, type OwnerToken, type Page, type Phase, type PhaseContext, type PhaseExecutionIdentity, type PhaseInvocation, type PhaseOutput, type PhaseRegistry, type PhaseState, type RunBoundary, type RunClaim, type RunEvent, type RunFailure, type RunId, type RunListCursor, type RunRecord, type RunSnapshot, type RunState, type RunStateChanged, type RunSummary, RuntimeError, type RuntimeErrorCode, type RuntimeErrorDetails, type Skill, SqliteStore, type TextContent, type ThinkingContent, type Tool, type ToolCallId, type ToolCallSnapshot, type ToolCallState, type ToolDefinition, type ToolExecutionResult, type ToolInvocationContext, type ToolMessage, type ToolMessageContent, type ToolProgress, type ToolResultContent, type ToolStateChanged, type ToolUseContent, type UserContent, type UserInput, type UserMessage, brandConfigToken, createCoreTools, isRuntimeError, loadExtensionsFromPath as loadExtensions, loadPhases, loadSkills };
|
package/dist/index.js
CHANGED
|
@@ -4071,7 +4071,7 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
4071
4071
|
});
|
|
4072
4072
|
if (result.type === "input_required") {
|
|
4073
4073
|
const prompt = promptMessage(run, result.request.prompt, result.messages.length);
|
|
4074
|
-
await this.owned.commitInputRequired({ runId: run.id, execution: claim.execution, expectedRevision: executionRevision, requestId: createId("input"), prompt, checkpoint: result.checkpoint });
|
|
4074
|
+
await this.owned.commitInputRequired({ runId: run.id, execution: claim.execution, expectedRevision: executionRevision, requestId: createId("input"), phase: result.request.phase, prompt, checkpoint: result.checkpoint });
|
|
4075
4075
|
this.transientEvents.clear(run.id, claim.execution.executionId);
|
|
4076
4076
|
return;
|
|
4077
4077
|
}
|
|
@@ -4266,7 +4266,7 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
4266
4266
|
subscription.clearTool(event.toolCall.id);
|
|
4267
4267
|
}
|
|
4268
4268
|
yield event;
|
|
4269
|
-
if (event.kind === "
|
|
4269
|
+
if (event.kind === "run_state_changed" && ["completed", "failed", "cancelled"].includes(event.to)) return;
|
|
4270
4270
|
}
|
|
4271
4271
|
const transient = subscription.shift();
|
|
4272
4272
|
if (transient) {
|
|
@@ -4341,7 +4341,7 @@ function durableOutcome(outcome) {
|
|
|
4341
4341
|
function boundaryFromSnapshot(snapshot) {
|
|
4342
4342
|
switch (snapshot.state) {
|
|
4343
4343
|
case "input_required":
|
|
4344
|
-
return { type: "input_required", requestId: snapshot.request.id, prompt: snapshot.request.prompt };
|
|
4344
|
+
return { type: "input_required", requestId: snapshot.request.id, phase: snapshot.request.phase, prompt: snapshot.request.prompt };
|
|
4345
4345
|
case "completed":
|
|
4346
4346
|
return { type: "completed", outcome: snapshot.outcome, ...snapshot.output ? { output: snapshot.output } : {} };
|
|
4347
4347
|
case "failed":
|
|
@@ -4634,9 +4634,10 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
4634
4634
|
}
|
|
4635
4635
|
commitInputRequired(lease, input) {
|
|
4636
4636
|
this.assertOwner(lease);
|
|
4637
|
+
if (typeof input.phase !== "string" || input.phase.length === 0) throw new TypeError("phase must be non-empty");
|
|
4637
4638
|
const requestId = input.requestId ?? createId("input");
|
|
4638
4639
|
const operationKey = `input_required:${requestId}`;
|
|
4639
|
-
const operationPayload = canonicalJson([input.runId, input.expectedRevision, input.prompt.id, input.checkpoint]);
|
|
4640
|
+
const operationPayload = canonicalJson([input.runId, input.expectedRevision, input.phase, input.prompt.id, input.checkpoint]);
|
|
4640
4641
|
const replay = this.replayOperation(operationKey, operationPayload);
|
|
4641
4642
|
if (replay) return clone(replay);
|
|
4642
4643
|
const run = this.requireRun(input.runId);
|
|
@@ -4649,6 +4650,7 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
4649
4650
|
};
|
|
4650
4651
|
const request = {
|
|
4651
4652
|
id: requestId,
|
|
4653
|
+
phase: input.phase,
|
|
4652
4654
|
messageId: prompt.id,
|
|
4653
4655
|
createdAt: createTimestamp()
|
|
4654
4656
|
};
|
|
@@ -4971,7 +4973,7 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
4971
4973
|
const request = run.openInputRequest;
|
|
4972
4974
|
const prompt = request && this.messages.get(request.messageId);
|
|
4973
4975
|
if (!prompt || prompt.role !== "assistant") throw new Error(`Run ${run.id} has an invalid input prompt.`);
|
|
4974
|
-
return { ...base, state: "input_required", request: { id: request.id, prompt: clone(prompt) } };
|
|
4976
|
+
return { ...base, state: "input_required", request: { id: request.id, phase: request.phase, prompt: clone(prompt) } };
|
|
4975
4977
|
}
|
|
4976
4978
|
case "completed": {
|
|
4977
4979
|
const output = this.messagesForRun(run.id).filter((message) => message.role === "assistant").at(-1);
|
|
@@ -5124,10 +5126,10 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
5124
5126
|
appendTransition(run, from, to, request, prompt, outcome, failure, reason) {
|
|
5125
5127
|
const transition = {
|
|
5126
5128
|
...this.baseEvent(run),
|
|
5127
|
-
kind: "
|
|
5129
|
+
kind: "run_state_changed",
|
|
5128
5130
|
from,
|
|
5129
5131
|
to,
|
|
5130
|
-
...to === "input_required" && request && prompt ? { request: { id: request.id, prompt } } : {},
|
|
5132
|
+
...to === "input_required" && request && prompt ? { request: { id: request.id, phase: request.phase, prompt } } : {},
|
|
5131
5133
|
...to === "completed" && outcome ? { outcome } : {},
|
|
5132
5134
|
...to === "failed" && failure ? { failure } : {},
|
|
5133
5135
|
...to === "cancelled" && reason ? { reason } : {}
|