@rowan-agent/agent 0.20.0 → 0.20.2
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 +8 -0
- package/dist/index.js +17 -37
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1131,6 +1131,7 @@ interface OwnedStore {
|
|
|
1131
1131
|
execution?: ExecutionToken;
|
|
1132
1132
|
update: ToolCall$1 | ToolCallUpdate;
|
|
1133
1133
|
external?: boolean;
|
|
1134
|
+
contentIndex?: number;
|
|
1134
1135
|
}): Promise<DurableRunEvent>;
|
|
1135
1136
|
snapshotRun(runId: RunId): Promise<RunSnapshot>;
|
|
1136
1137
|
history(agentId: AgentId): Promise<readonly Message[]>;
|
|
@@ -2173,6 +2174,7 @@ type ToolCallSnapshot = ToolCall$1 & Readonly<{
|
|
|
2173
2174
|
resultMessageId?: MessageId;
|
|
2174
2175
|
reason?: string;
|
|
2175
2176
|
external?: boolean;
|
|
2177
|
+
contentIndex?: number;
|
|
2176
2178
|
createdAt?: string;
|
|
2177
2179
|
updatedAt?: string;
|
|
2178
2180
|
}>;
|
|
@@ -2255,6 +2257,8 @@ type ToolStateChanged = (DurableEventBase & Readonly<{
|
|
|
2255
2257
|
}>;
|
|
2256
2258
|
toolCall: ToolCall$1;
|
|
2257
2259
|
external?: boolean;
|
|
2260
|
+
/** For a provider-reported call: assistant content blocks streamed before it. */
|
|
2261
|
+
contentIndex?: number;
|
|
2258
2262
|
}>) | Readonly<{
|
|
2259
2263
|
kind: "tool_state_changed";
|
|
2260
2264
|
durability: "transient";
|
|
@@ -2266,6 +2270,7 @@ type ToolStateChanged = (DurableEventBase & Readonly<{
|
|
|
2266
2270
|
}>;
|
|
2267
2271
|
toolCall: ToolCall$1 | ToolCallUpdate;
|
|
2268
2272
|
external?: boolean;
|
|
2273
|
+
contentIndex?: number;
|
|
2269
2274
|
}>;
|
|
2270
2275
|
type DurableRunEvent = PhaseEntered | MessageCommitted | MessageRevised | RunStateChanged | Extract<ToolStateChanged, {
|
|
2271
2276
|
durability: "durable";
|
|
@@ -2567,6 +2572,7 @@ type StoredToolCall = {
|
|
|
2567
2572
|
rawOutput?: JsonValue;
|
|
2568
2573
|
_meta?: JsonObject;
|
|
2569
2574
|
external?: boolean;
|
|
2575
|
+
contentIndex?: number;
|
|
2570
2576
|
result?: DurableToolResult;
|
|
2571
2577
|
resultMessageId?: MessageId;
|
|
2572
2578
|
reason?: string;
|
|
@@ -2809,6 +2815,7 @@ declare class InMemoryStore implements DurableStore {
|
|
|
2809
2815
|
execution?: ExecutionToken;
|
|
2810
2816
|
update: ToolCall$1 | ToolCallUpdate;
|
|
2811
2817
|
external?: boolean;
|
|
2818
|
+
contentIndex?: number;
|
|
2812
2819
|
}): DurableRunEvent;
|
|
2813
2820
|
snapshotRun(lease: OwnerLease, runId: RunId): RunSnapshot;
|
|
2814
2821
|
listAgents(lease: OwnerLease): readonly AgentRecord[];
|
|
@@ -3063,6 +3070,7 @@ declare class SqliteStore implements DurableStore {
|
|
|
3063
3070
|
execution?: ExecutionToken;
|
|
3064
3071
|
update: ToolCall$1 | ToolCallUpdate;
|
|
3065
3072
|
external?: boolean;
|
|
3073
|
+
contentIndex?: number;
|
|
3066
3074
|
}): Promise<DurableRunEvent>;
|
|
3067
3075
|
snapshotRun(lease: OwnerLease, runId: RunId): Promise<RunSnapshot>;
|
|
3068
3076
|
history(lease: OwnerLease, agentId: AgentId): Promise<readonly Message[]>;
|
package/dist/index.js
CHANGED
|
@@ -1378,43 +1378,23 @@ var LoopGuard = {
|
|
|
1378
1378
|
// src/loop/stream-collector.ts
|
|
1379
1379
|
var MAX_STREAMED_OUTPUT_CHARACTERS = 1024 * 1024;
|
|
1380
1380
|
async function invokeModel(input) {
|
|
1381
|
-
const
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
id: input.config.execution.runId,
|
|
1385
|
-
agentId: input.config.execution.agentId,
|
|
1386
|
-
scope: input.config.execution.scope ?? [],
|
|
1387
|
-
cwd: input.config.execution.cwd ?? input.config.context.cwd ?? ""
|
|
1388
|
-
},
|
|
1389
|
-
interact: async (request) => {
|
|
1390
|
-
const handler = input.config.runtime?.interact ?? input.config.interact;
|
|
1391
|
-
if (!handler) {
|
|
1392
|
-
throw new Error("Run interactions are not supported in this runtime.");
|
|
1393
|
-
}
|
|
1394
|
-
return handler(request);
|
|
1395
|
-
},
|
|
1381
|
+
const position = { contentIndex: 0 };
|
|
1382
|
+
const callContext = {
|
|
1383
|
+
...input.callContext,
|
|
1396
1384
|
tools: {
|
|
1397
|
-
|
|
1398
|
-
return input.config.context.tools.map((t) => ({
|
|
1399
|
-
name: t.name,
|
|
1400
|
-
description: t.description,
|
|
1401
|
-
parameters: t.parameters,
|
|
1402
|
-
...t._meta !== void 0 ? { _meta: t._meta } : {}
|
|
1403
|
-
}));
|
|
1404
|
-
},
|
|
1405
|
-
call: async (_name, _args, _options) => {
|
|
1406
|
-
throw new Error("Tool calling is not available in standalone stream collector without callContext.");
|
|
1407
|
-
},
|
|
1385
|
+
...input.callContext.tools,
|
|
1408
1386
|
report: (update) => {
|
|
1409
1387
|
input.config.onToolReport?.({
|
|
1410
1388
|
runId: input.config.execution.runId,
|
|
1411
|
-
update
|
|
1389
|
+
update,
|
|
1390
|
+
contentIndex: position.contentIndex
|
|
1412
1391
|
});
|
|
1413
1392
|
}
|
|
1414
1393
|
}
|
|
1415
1394
|
};
|
|
1416
1395
|
const events = input.config.stream(input.request, callContext);
|
|
1417
1396
|
const result = await collectStreamResult({
|
|
1397
|
+
position,
|
|
1418
1398
|
config: input.config,
|
|
1419
1399
|
message: input.message,
|
|
1420
1400
|
events,
|
|
@@ -1455,6 +1435,7 @@ async function collectStreamResult(input) {
|
|
|
1455
1435
|
const toolNames = /* @__PURE__ */ new Map();
|
|
1456
1436
|
const toolArguments = /* @__PURE__ */ new Map();
|
|
1457
1437
|
for await (const event of input.events) {
|
|
1438
|
+
if ("partial" in event) input.position.contentIndex = event.partial.contentBlocks.length;
|
|
1458
1439
|
if (event.type === "text_delta") {
|
|
1459
1440
|
streamedOutputCharacters += event.text.length;
|
|
1460
1441
|
} else if (event.type === "thinking_delta") {
|
|
@@ -3780,12 +3761,6 @@ function createPhaseExecution(config, state, phase, messageManager, toolExecutio
|
|
|
3780
3761
|
};
|
|
3781
3762
|
const res = await executePhaseTool(phaseContext, toolCall, options2, true);
|
|
3782
3763
|
return res.ok ? { ok: true, content: res.content } : { ok: false, error: res.error ?? "Tool execution failed", ...res.content !== void 0 ? { content: res.content } : {} };
|
|
3783
|
-
},
|
|
3784
|
-
report: (update) => {
|
|
3785
|
-
config.onToolReport?.({
|
|
3786
|
-
runId: config.execution.runId,
|
|
3787
|
-
update
|
|
3788
|
-
});
|
|
3789
3764
|
}
|
|
3790
3765
|
}
|
|
3791
3766
|
};
|
|
@@ -8112,7 +8087,8 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
8112
8087
|
executionId: claim.execution.executionId,
|
|
8113
8088
|
transition: { from: null, to: event.update.status ?? "in_progress" },
|
|
8114
8089
|
toolCall: event.update,
|
|
8115
|
-
external: true
|
|
8090
|
+
external: true,
|
|
8091
|
+
...event.contentIndex === void 0 ? {} : { contentIndex: event.contentIndex }
|
|
8116
8092
|
});
|
|
8117
8093
|
const task = toolQueue.then(async () => {
|
|
8118
8094
|
const active2 = this.executions.get(run.id);
|
|
@@ -8121,7 +8097,8 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
8121
8097
|
runId: run.id,
|
|
8122
8098
|
execution: claim.execution,
|
|
8123
8099
|
update: event.update,
|
|
8124
|
-
external: true
|
|
8100
|
+
external: true,
|
|
8101
|
+
...event.contentIndex === void 0 ? {} : { contentIndex: event.contentIndex }
|
|
8125
8102
|
});
|
|
8126
8103
|
executionRevision = recorded.runRevision;
|
|
8127
8104
|
});
|
|
@@ -10716,6 +10693,7 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
10716
10693
|
status: toStatus,
|
|
10717
10694
|
state: toStatus,
|
|
10718
10695
|
external: input.external ?? false,
|
|
10696
|
+
...input.contentIndex === void 0 ? {} : { contentIndex: input.contentIndex },
|
|
10719
10697
|
createdAt: timestamp,
|
|
10720
10698
|
updatedAt: timestamp
|
|
10721
10699
|
};
|
|
@@ -10741,7 +10719,8 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
10741
10719
|
kind: "tool_state_changed",
|
|
10742
10720
|
transition: { from: fromStatus, to: toStatus },
|
|
10743
10721
|
toolCall: acpToolCall,
|
|
10744
|
-
...input.external ? { external: true } : {}
|
|
10722
|
+
...input.external ? { external: true } : {},
|
|
10723
|
+
...stored.contentIndex === void 0 ? {} : { contentIndex: stored.contentIndex }
|
|
10745
10724
|
});
|
|
10746
10725
|
this.appendEvent(event);
|
|
10747
10726
|
return event;
|
|
@@ -11185,7 +11164,8 @@ ${record.summary}`,
|
|
|
11185
11164
|
kind: "tool_state_changed",
|
|
11186
11165
|
transition,
|
|
11187
11166
|
toolCall: acpToolCall,
|
|
11188
|
-
...toolCall.external ? { external: true } : {}
|
|
11167
|
+
...toolCall.external ? { external: true } : {},
|
|
11168
|
+
...toolCall.contentIndex === void 0 ? {} : { contentIndex: toolCall.contentIndex }
|
|
11189
11169
|
});
|
|
11190
11170
|
}
|
|
11191
11171
|
baseEvent(run, extra) {
|