@rowan-agent/agent 0.9.22 → 0.9.23
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 +6 -0
- package/dist/index.js +32 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2407,6 +2407,12 @@ declare class InMemoryStore implements DurableStore {
|
|
|
2407
2407
|
private writeReceipt;
|
|
2408
2408
|
private replayOperation;
|
|
2409
2409
|
private writeOperationReceipt;
|
|
2410
|
+
/**
|
|
2411
|
+
* A Claim receipt exists for idempotent replay of one live Execution Attempt
|
|
2412
|
+
* and carries that Attempt's history. Dropping it when the Attempt ends keeps
|
|
2413
|
+
* one history snapshot per Agent instead of one per Attempt.
|
|
2414
|
+
*/
|
|
2415
|
+
private dropClaimReceipt;
|
|
2410
2416
|
private requireAgent;
|
|
2411
2417
|
private requireRun;
|
|
2412
2418
|
private requireToolCall;
|
package/dist/index.js
CHANGED
|
@@ -5848,6 +5848,7 @@ function selectedRefs(refs, names) {
|
|
|
5848
5848
|
var DEFAULT_CONCURRENCY = 10;
|
|
5849
5849
|
var DEFAULT_POLL_MS = 25;
|
|
5850
5850
|
var MAX_CONSUMER_IDLE_POLL_MS = 250;
|
|
5851
|
+
var RUN_STATE_CHECK_INTERVAL_MS = 1e3;
|
|
5851
5852
|
var OWNER_LEASE_MS = 3e4;
|
|
5852
5853
|
var OWNER_RENEWAL_MS = 1e4;
|
|
5853
5854
|
var MAX_INLINE_TOOL_RESULT_BYTES = 16 * 1024;
|
|
@@ -6652,15 +6653,25 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
6652
6653
|
async *observe(runId, options = {}) {
|
|
6653
6654
|
let cursor = options.after;
|
|
6654
6655
|
const subscription = this.transientEvents.subscribe(runId);
|
|
6656
|
+
let nextRunStateCheckAtMs = 0;
|
|
6655
6657
|
try {
|
|
6656
6658
|
while (true) {
|
|
6659
|
+
const published = subscription.shift();
|
|
6660
|
+
if (published) {
|
|
6661
|
+
yield published;
|
|
6662
|
+
continue;
|
|
6663
|
+
}
|
|
6657
6664
|
const observationVersion = subscription.checkpoint();
|
|
6658
|
-
const
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
const
|
|
6663
|
-
if (!
|
|
6665
|
+
const aborted = options.signal?.aborted === true;
|
|
6666
|
+
if (aborted || Date.now() >= nextRunStateCheckAtMs) {
|
|
6667
|
+
nextRunStateCheckAtMs = Date.now() + RUN_STATE_CHECK_INTERVAL_MS;
|
|
6668
|
+
const snapshot = await this.owned.snapshotRun(runId);
|
|
6669
|
+
const terminal = ["completed", "failed", "cancelled"].includes(snapshot.state);
|
|
6670
|
+
if (aborted && !terminal) throw abortError();
|
|
6671
|
+
if (terminal) {
|
|
6672
|
+
const pending = await this.owned.listEvents(cursor ? { after: cursor } : {});
|
|
6673
|
+
if (!pending.some((event) => event.runId === runId)) return;
|
|
6674
|
+
}
|
|
6664
6675
|
}
|
|
6665
6676
|
const events = await this.owned.listEvents(cursor ? { after: cursor } : {});
|
|
6666
6677
|
for (const event of events) {
|
|
@@ -6957,6 +6968,7 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
6957
6968
|
const failure = indeterminateToolCallIds.length > 0 ? { code: "tool_indeterminate", message, toolCallIds: indeterminateToolCallIds } : { code: "runtime_interrupted", message, ownerEpoch };
|
|
6958
6969
|
run.state = "failed";
|
|
6959
6970
|
run.failure = failure;
|
|
6971
|
+
this.dropClaimReceipt(run.execution);
|
|
6960
6972
|
delete run.execution;
|
|
6961
6973
|
run.revision += 1;
|
|
6962
6974
|
run.updatedAt = createTimestamp();
|
|
@@ -7186,6 +7198,7 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
7186
7198
|
delete run.openInputRequest;
|
|
7187
7199
|
delete run.checkpoint;
|
|
7188
7200
|
}
|
|
7201
|
+
this.dropClaimReceipt(run.execution);
|
|
7189
7202
|
delete run.execution;
|
|
7190
7203
|
run.state = "cancelled";
|
|
7191
7204
|
run.cancellationReason = "Run superseded by Message revision.";
|
|
@@ -7369,6 +7382,7 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
7369
7382
|
delete run.openInteractions;
|
|
7370
7383
|
delete run.interactionAnswers;
|
|
7371
7384
|
}
|
|
7385
|
+
this.dropClaimReceipt(run.execution);
|
|
7372
7386
|
delete run.execution;
|
|
7373
7387
|
run.revision += 1;
|
|
7374
7388
|
run.updatedAt = createTimestamp();
|
|
@@ -7623,6 +7637,7 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
7623
7637
|
};
|
|
7624
7638
|
run.state = "failed";
|
|
7625
7639
|
run.failure = failure;
|
|
7640
|
+
this.dropClaimReceipt(run.execution);
|
|
7626
7641
|
delete run.execution;
|
|
7627
7642
|
run.revision += 1;
|
|
7628
7643
|
run.updatedAt = createTimestamp();
|
|
@@ -7653,6 +7668,7 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
7653
7668
|
run.state = nextState;
|
|
7654
7669
|
if (input.outcome) run.outcome = clone(input.outcome);
|
|
7655
7670
|
if (input.failure) run.failure = clone(input.failure);
|
|
7671
|
+
this.dropClaimReceipt(run.execution);
|
|
7656
7672
|
delete run.execution;
|
|
7657
7673
|
delete run.openInteractions;
|
|
7658
7674
|
delete run.interactionAnswers;
|
|
@@ -7699,6 +7715,7 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
7699
7715
|
run.state = "failed";
|
|
7700
7716
|
run.failure = failure;
|
|
7701
7717
|
delete run.cancellationReason;
|
|
7718
|
+
this.dropClaimReceipt(run.execution);
|
|
7702
7719
|
delete run.execution;
|
|
7703
7720
|
delete run.openInputRequest;
|
|
7704
7721
|
delete run.openInteractions;
|
|
@@ -7712,6 +7729,7 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
7712
7729
|
}
|
|
7713
7730
|
run.state = "cancelled";
|
|
7714
7731
|
run.cancellationReason = input.reason;
|
|
7732
|
+
this.dropClaimReceipt(run.execution);
|
|
7715
7733
|
delete run.execution;
|
|
7716
7734
|
delete run.openInputRequest;
|
|
7717
7735
|
delete run.openInteractions;
|
|
@@ -7885,6 +7903,14 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
7885
7903
|
writeOperationReceipt(key, payload, result) {
|
|
7886
7904
|
this.operationReceipts.set(key, { payload, result: clone(result) });
|
|
7887
7905
|
}
|
|
7906
|
+
/**
|
|
7907
|
+
* A Claim receipt exists for idempotent replay of one live Execution Attempt
|
|
7908
|
+
* and carries that Attempt's history. Dropping it when the Attempt ends keeps
|
|
7909
|
+
* one history snapshot per Agent instead of one per Attempt.
|
|
7910
|
+
*/
|
|
7911
|
+
dropClaimReceipt(execution) {
|
|
7912
|
+
if (execution) this.operationReceipts.delete(`claim:${execution.executionId}`);
|
|
7913
|
+
}
|
|
7888
7914
|
requireAgent(agentId) {
|
|
7889
7915
|
const agent = this.agents.get(agentId);
|
|
7890
7916
|
if (!agent) throw new RuntimeError("agent_not_found", { agentId });
|