effect-agent 0.1.0-beta.156 → 0.1.0-beta.158
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/{Admin-BjmupLN3.d.mts → Admin-BbTZHSLu.d.mts} +23 -11
- package/dist/{Agent-1DMSO_Fl.mjs → Agent-BMATXYsI.mjs} +9 -2
- package/dist/Agent-BMATXYsI.mjs.map +1 -0
- package/dist/{AgentRuntime-BAjT5gXl.d.mts → AgentRuntime-BPlAn5nA.d.mts} +6 -6
- package/dist/{AgentRuntime-IF_1GoUf.mjs → AgentRuntime-D4eoBpIW.mjs} +32 -10
- package/dist/AgentRuntime-D4eoBpIW.mjs.map +1 -0
- package/dist/{Digest-CaJ2RIsF.d.mts → Digest-CNHImGy0.d.mts} +2 -2
- package/dist/{DurableAgentRuntime-BQzYkFVy.mjs → DurableAgentRuntime-eImXoGqD.mjs} +78 -27
- package/dist/DurableAgentRuntime-eImXoGqD.mjs.map +1 -0
- package/dist/{EventSource-C8CKwQy5.d.mts → EventSource-CETtQTiH.d.mts} +3 -3
- package/dist/InMemory.d.mts +1 -1
- package/dist/{PreparedInputAdmission-CU1PzUVD.d.mts → PreparedInputAdmission-Swp9t800.d.mts} +4 -4
- package/dist/{Records-BrEpibum.d.mts → Records-BxGWRs-t.d.mts} +2 -2
- package/dist/{RunEvent-DV_llBcq.d.mts → RunEvent-D0aepYwN.d.mts} +2 -2
- package/dist/{RunEventSink-D5aVhISG.d.mts → RunEventSink-DsbcGXog.d.mts} +2 -2
- package/dist/{RunOptions-CkRYnlJa.d.mts → RunOptions-GjDlAuKh.d.mts} +5 -2
- package/dist/{Schedule-B_z7PMg-.d.mts → Schedule-B94iS2X3.d.mts} +2 -2
- package/dist/{Subagent-CmFtZaeI.mjs → Subagent-211Oz2IN.mjs} +2 -2
- package/dist/{Subagent-CmFtZaeI.mjs.map → Subagent-211Oz2IN.mjs.map} +1 -1
- package/dist/{Subagent-Dld4W1BY.d.mts → Subagent-CLaMeZKu.d.mts} +6 -6
- package/dist/{Subscription-BomcQ9_W.d.mts → Subscription-DaMCppa_.d.mts} +4 -4
- package/dist/{SubscriptionInput-gpZSR9vB.d.mts → SubscriptionInput-B0ZtrQoY.d.mts} +3 -3
- package/dist/{ThreadHistory-ZEu_ja6L.d.mts → ThreadHistory-FD-o4TsR.d.mts} +2 -2
- package/dist/{Usage-Dx0aknfk.d.mts → Usage-BNjPR7Zr.d.mts} +9 -1
- package/dist/{WorkerAdmission-CNbm4o_x.mjs → WorkerAdmission-N9hZV85Q.mjs} +2 -2
- package/dist/{WorkerAdmission-CNbm4o_x.mjs.map → WorkerAdmission-N9hZV85Q.mjs.map} +1 -1
- package/dist/{agent-registration-U3kmV7nW.mjs → agent-registration-BIOzAej4.mjs} +10 -1
- package/dist/agent-registration-BIOzAej4.mjs.map +1 -0
- package/dist/capabilities/Commands.d.mts +1 -1
- package/dist/capabilities/Redaction.d.mts +1 -1
- package/dist/capabilities/RunHooks.d.mts +1 -1
- package/dist/capabilities/Subagent.d.mts +1 -1
- package/dist/capabilities/Subagent.mjs +1 -1
- package/dist/capabilities/ToolDiscovery.d.mts +5 -0
- package/dist/capabilities/ToolDiscovery.mjs +18 -9
- package/dist/capabilities/ToolDiscovery.mjs.map +1 -1
- package/dist/capabilities/WebSearch.d.mts +5 -1
- package/dist/capabilities/WebSearch.mjs +9 -1
- package/dist/capabilities/WebSearch.mjs.map +1 -1
- package/dist/core/Agent.mjs +1 -1
- package/dist/core/RunEvent.d.mts +1 -1
- package/dist/core/Usage.d.mts +1 -1
- package/dist/core/Usage.mjs +22 -1
- package/dist/core/Usage.mjs.map +1 -1
- package/dist/durable/ActivityStore.d.mts +1 -1
- package/dist/durable/Admin.d.mts +1 -1
- package/dist/durable/AgentRegistration.d.mts +1 -1
- package/dist/durable/AgentRegistration.mjs +1 -1
- package/dist/durable/Certification.d.mts +1 -1
- package/dist/durable/CommittedActivity.d.mts +3 -3
- package/dist/durable/Digest.d.mts +1 -1
- package/dist/durable/DurableAgentRuntime.d.mts +1 -1
- package/dist/durable/DurableAgentRuntime.mjs +2 -2
- package/dist/durable/EventSource.d.mts +1 -1
- package/dist/durable/GitHubWorkflowSource.d.mts +3 -3
- package/dist/durable/LifecyclePublication.d.mts +1 -1
- package/dist/durable/LifecyclePublication.mjs +2 -2
- package/dist/durable/LifecyclePublication.mjs.map +1 -1
- package/dist/durable/MessageDelivery.d.mts +24 -10
- package/dist/durable/MessageDelivery.mjs +49 -17
- package/dist/durable/MessageDelivery.mjs.map +1 -1
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +5 -5
- package/dist/durable/PersistentHistory.d.mts +2 -2
- package/dist/durable/PreparedInputAdmission.d.mts +1 -1
- package/dist/durable/Records.d.mts +1 -1
- package/dist/durable/Recovery.d.mts +1 -1
- package/dist/durable/RunJournal.d.mts +1 -1
- package/dist/durable/Schedule.d.mts +1 -1
- package/dist/durable/ScheduleStoreConformance.d.mts +1 -1
- package/dist/durable/ScheduleTransition.d.mts +1 -1
- package/dist/durable/Scheduling.d.mts +3 -3
- package/dist/durable/SubmissionLedger.d.mts +1 -1
- package/dist/durable/SubmissionLedgerConformance.d.mts +2 -2
- package/dist/durable/SubmissionStatus.d.mts +1 -1
- package/dist/durable/Subscription.d.mts +1 -1
- package/dist/durable/SubscriptionInput.d.mts +1 -1
- package/dist/durable/SubscriptionInput.mjs +1 -1
- package/dist/durable/SubscriptionStoreConformance.d.mts +1 -1
- package/dist/durable/SubscriptionTools.d.mts +4 -4
- package/dist/durable/SubscriptionTransition.d.mts +1 -1
- package/dist/durable/Subscriptions.d.mts +6 -6
- package/dist/durable/ThreadContextHistory.d.mts +1 -1
- package/dist/durable/ThreadContextHistoryProjection.d.mts +1 -1
- package/dist/durable/ThreadInvariants.d.mts +2 -2
- package/dist/durable/ThreadProjection.d.mts +1 -1
- package/dist/durable/ThreadProjectionMaintenance.d.mts +1 -1
- package/dist/durable/ThreadStore.d.mts +1 -1
- package/dist/durable/ThreadStoreConformance.d.mts +1 -1
- package/dist/durable/WorkerAdmission.d.mts +2 -2
- package/dist/durable/WorkerAdmission.mjs +1 -1
- package/dist/durable/WorkerHost.d.mts +2 -2
- package/dist/engine/AgentRuntime.d.mts +1 -1
- package/dist/engine/AgentRuntime.mjs +1 -1
- package/dist/engine/RunEventSink.d.mts +1 -1
- package/dist/engine/RunOptions.d.mts +1 -1
- package/dist/engine/RunOptions.mjs +1 -0
- package/dist/engine/RunOptions.mjs.map +1 -1
- package/dist/engine/ThreadHistory.d.mts +1 -1
- package/dist/index.d.mts +15 -15
- package/dist/index.mjs +5 -5
- package/package.json +1 -1
- package/src/capabilities/ToolDiscovery.ts +24 -10
- package/src/capabilities/WebSearch.ts +15 -0
- package/src/core/Agent.ts +16 -2
- package/src/core/Usage.ts +41 -0
- package/src/durable/DurableAgentRuntime.ts +119 -21
- package/src/durable/LifecyclePublication.ts +15 -2
- package/src/durable/MessageDelivery.ts +64 -20
- package/src/durable/internal/agent-registration.ts +11 -0
- package/src/engine/RunOptions.ts +3 -0
- package/src/engine/internal/agent-runtime.ts +91 -20
- package/dist/Agent-1DMSO_Fl.mjs.map +0 -1
- package/dist/AgentRuntime-IF_1GoUf.mjs.map +0 -1
- package/dist/DurableAgentRuntime-BQzYkFVy.mjs.map +0 -1
- package/dist/agent-registration-U3kmV7nW.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as Digest, h as DefinitionDigests, m as DefinitionDigestInput, s as CanonicalBatch } from "./Records-
|
|
1
|
+
import { _ as Digest, h as DefinitionDigests, m as DefinitionDigestInput, s as CanonicalBatch } from "./Records-BxGWRs-t.mjs";
|
|
2
2
|
import { Crypto, Effect, Schema } from "effect";
|
|
3
3
|
declare namespace Digest_d_exports {
|
|
4
4
|
export { DigestError, EMPTY_TAIL_DIGEST, digestCanonicalBatch, digestDefinition, digestDefinitions, digestJson };
|
|
@@ -19,4 +19,4 @@ declare const digestDefinitions: (definitions: DefinitionDigestInput) => Effect.
|
|
|
19
19
|
declare const EMPTY_TAIL_DIGEST: string & import("effect/Brand").Brand<"@effect-agent/thread/Digest">;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { digestDefinition as a, digestCanonicalBatch as i, Digest_d_exports as n, digestDefinitions as o, EMPTY_TAIL_DIGEST as r, digestJson as s, DigestError as t };
|
|
22
|
-
//# sourceMappingURL=Digest-
|
|
22
|
+
//# sourceMappingURL=Digest-CNHImGy0.d.mts.map
|
|
@@ -15,7 +15,7 @@ import { a as PeerMessageCapacity, d as MessageAdmission, f as MessagingError, i
|
|
|
15
15
|
import { SubagentHost } from "./engine/SubagentHost.mjs";
|
|
16
16
|
import { ThreadHistory } from "./engine/ThreadHistory.mjs";
|
|
17
17
|
import { n as RunToolVisibility } from "./ToolExposure-9uF_Yo0T.mjs";
|
|
18
|
-
import { f as renderInputPrompt, n as AgentChildPending, y as streamWithUsageAccountingUnknown } from "./AgentRuntime-
|
|
18
|
+
import { f as renderInputPrompt, n as AgentChildPending, y as streamWithUsageAccountingUnknown } from "./AgentRuntime-D4eoBpIW.mjs";
|
|
19
19
|
import { ContextRolloverTool } from "./engine/ContextWindow.mjs";
|
|
20
20
|
import { getToolExecutionClass } from "./engine/DurableStep.mjs";
|
|
21
21
|
import { CompactionError, ContextCompactor } from "./engine/ContextCompactor.mjs";
|
|
@@ -26,7 +26,7 @@ import { AbortCommand, AbortIntentRequest, AdmissionPolicyError, AdmissionReques
|
|
|
26
26
|
import { DeclaredPendingBatchEvidence, OpenDelegationCallEvidence, OpenToolCallEvidence, PendingApprovalEvidence, RecoveryDecision, RecoveryEvidence, classifyRecovery } from "./durable/Recovery.mjs";
|
|
27
27
|
import { ExplainedEvidence, ExplainedSubmission, ExplainedUnknownCall, IntegrityCheck, IntegrityReport, ObligationEntry, ObligationReport, RecoveryExplanation, RetryRefused, obligationSeverityOf, predictRecoveryDisposition, recoveryDecisionMeaning } from "./durable/Admin.mjs";
|
|
28
28
|
import { digestJson } from "./durable/Digest.mjs";
|
|
29
|
-
import { a as compileRegistrations, c as resolveDefinitionBinding, l as resolveWorkerBinding, n as CurrentBindingSelection, o as definitionDigestsEqual, s as makeLegacyWorkerBinding, t as BindingUnavailable, u as toolReplayContracts } from "./agent-registration-
|
|
29
|
+
import { a as compileRegistrations, c as resolveDefinitionBinding, l as resolveWorkerBinding, n as CurrentBindingSelection, o as definitionDigestsEqual, s as makeLegacyWorkerBinding, t as BindingUnavailable, u as toolReplayContracts } from "./agent-registration-BIOzAej4.mjs";
|
|
30
30
|
import { $ as workerOriginRecordId, A as subagentRequestedRecordId, B as toolCallUnknownRecordId, C as runStartedBatchId, D as subagentLineageBatchId, E as subagentJoinedRecordId, F as toolCallPreparedRecordId, G as turnCanonicalBatch, H as toolStepSettledRecordId, I as toolCallResolutionBatchId, J as turnResponseBatch, K as turnIdForRun, L as toolCallResolvedRecordId, M as subagentStartedRecordId, N as toolApprovalDecisionRecordId, O as subagentLineageRecordId, P as toolApprovalRequestRecordId, Q as workerInputRecordId, R as toolCallResultBatchId, S as runIdForSubmission, T as subagentJoinBatchId, U as turnApprovalsBatchId, V as toolStepSettledBatchId, X as turnResultsBatch, a as childIdempotencyKeyFor, b as runDurationBatchId, c as compactionRecordId, d as modelResponseInterruptedBatchId, et as workerReportRecordId, f as modelResponseInterruptedRecordId, g as projectRunJournalStream, i as approvalDecisionBatchId, j as subagentStartedBatchId, k as subagentRequestedBatchId, l as firstWorkerInputRecordId, m as peerMessageRecordId, o as childThreadIdFor, p as modelResponseRecordId, q as turnPreparedBatchId, r as agentUpdateRecordId, s as compactionBatchId, t as RunJournalError, tt as makeJournalMetadata, u as markUnknownBatchId, v as runCompletedRecordId, w as runStartedRecordId, x as runDurationRecordId, y as runCompletionDigest, z as toolCallSettledRecordId } from "./RunJournal-ixFRCyW3.mjs";
|
|
31
31
|
import { FencedAppendRequest, LoadCheckpointRequest, MAX_THREAD_EXPORT_RECORDS, SaveRecoveryCheckpointRequest, ThreadCheckpoint, ThreadExportRequest, ThreadIdentityRequest, ThreadMaterialization, ThreadObservation, ThreadRead, ThreadStore, ThreadStoreDiagnostic, ThreadStoreError, ThreadTailRequest, getRecord, getRunInput, readWorkerState } from "./durable/ThreadStore.mjs";
|
|
32
32
|
import { DurableRuntimeFailpoint } from "./durable/DurableFailpoint.mjs";
|
|
@@ -36,7 +36,7 @@ import { PreparedInput } from "./durable/Subscription.mjs";
|
|
|
36
36
|
import { MessageDeliveryDriver, MessageDeliveryFailpoint, MessageDeliveryRecord, MessageDeliveryStore, messageDeliveryCapacity, messageDeliveryUsesCapacity, prepareMessageDelivery } from "./durable/MessageDelivery.mjs";
|
|
37
37
|
import { WakeScheduler } from "./durable/WakeScheduler.mjs";
|
|
38
38
|
import { n as safeUnknownString, t as inspectForeignDiagnostic } from "./foreign-diagnostic-DBQ1XHKh.mjs";
|
|
39
|
-
import { c as threadCreatedBatchId, l as threadCreatedRecordId, n as WorkerAdmissionPort, o as ensureThreadCreated, r as WorkerAdmissionRequest, s as ensureWorkerOrigin } from "./WorkerAdmission-
|
|
39
|
+
import { c as threadCreatedBatchId, l as threadCreatedRecordId, n as WorkerAdmissionPort, o as ensureThreadCreated, r as WorkerAdmissionRequest, s as ensureWorkerOrigin } from "./WorkerAdmission-N9hZV85Q.mjs";
|
|
40
40
|
import { WorkerBudgetAuthorizer, WorkerConcurrencyLimit, WorkerConcurrencyResolver, WorkerHostAuthorizer, WorkerHostConfig, WorkerPolicyResolver } from "./durable/WorkerHost.mjs";
|
|
41
41
|
import { OperationAuthorizationRequest, OperationAuthorizer, OperationDenied } from "./durable/OperationAuthorizer.mjs";
|
|
42
42
|
import { PendingSubmission, SettledSubmission } from "./durable/SubmissionStatus.mjs";
|
|
@@ -2374,6 +2374,7 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
2374
2374
|
const ledger = yield* SubmissionLedger;
|
|
2375
2375
|
const submissionScheduling = yield* SubmissionScheduling;
|
|
2376
2376
|
const store = yield* ThreadStore;
|
|
2377
|
+
const deliveries = yield* Effect.serviceOption(MessageDeliveryStore);
|
|
2377
2378
|
let projectedJournal;
|
|
2378
2379
|
const wake = yield* WakeScheduler;
|
|
2379
2380
|
const failpoint = yield* DurableRuntimeFailpoint;
|
|
@@ -3337,7 +3338,45 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
3337
3338
|
* notification for single-store parent re-suspension races; `ResumeWaitingParent` remains the
|
|
3338
3339
|
* repair for older data and any already-recorded canonical settlement.
|
|
3339
3340
|
*/
|
|
3340
|
-
const notifyParentOfChildSettlement = Effect.fn("DurableAgentRuntime.notifyParentOfChildSettlement")(function* (submission) {
|
|
3341
|
+
const notifyParentOfChildSettlement = Effect.fn("DurableAgentRuntime.notifyParentOfChildSettlement")(function* (submission, record) {
|
|
3342
|
+
const admission = submission.messageAdmission;
|
|
3343
|
+
const worker = submission.workerAdmission;
|
|
3344
|
+
const key = admission === void 0 ? worker === void 0 ? void 0 : {
|
|
3345
|
+
ownerThreadId: worker.origin.source.threadId,
|
|
3346
|
+
messageId: worker.messageId
|
|
3347
|
+
} : Schema.is(MessageAdmission)(admission) ? admission.message : {
|
|
3348
|
+
ownerThreadId: admission._tag === "WorkerCompletion" ? admission.report.worker.threadId : admission.worker.threadId,
|
|
3349
|
+
messageId: submission.idempotencyKey
|
|
3350
|
+
};
|
|
3351
|
+
if (key !== void 0 && Option.isSome(deliveries)) {
|
|
3352
|
+
const settled = yield* settlementPayloadFromRecord(record, submission.submissionId);
|
|
3353
|
+
yield* deliveries.value.change(key, {
|
|
3354
|
+
_tag: "Complete",
|
|
3355
|
+
nowMillis: yield* Clock.currentTimeMillis,
|
|
3356
|
+
admissionKey: submission.idempotencyKey,
|
|
3357
|
+
inputDigest: submission.inputDigest,
|
|
3358
|
+
receipt: Receipt.make({
|
|
3359
|
+
threadId: submission.threadId,
|
|
3360
|
+
submissionId: submission.submissionId,
|
|
3361
|
+
receiptId: submission.receiptId,
|
|
3362
|
+
queueSequence: submission.queueSequence
|
|
3363
|
+
}),
|
|
3364
|
+
settlement: Settlement.make({
|
|
3365
|
+
submissionId: settled.submissionId,
|
|
3366
|
+
receiptId: settled.receiptId,
|
|
3367
|
+
settlementId: settled.settlementId,
|
|
3368
|
+
outcome: settled.outcome,
|
|
3369
|
+
settledAt: record.createdAt,
|
|
3370
|
+
...settled.outcome === "failed" ? { failure: settled.result } : {},
|
|
3371
|
+
...settled.usageSummary === void 0 ? {} : { usageSummary: settled.usageSummary },
|
|
3372
|
+
...settled.runDisposition === void 0 ? {} : { runDisposition: settled.runDisposition }
|
|
3373
|
+
})
|
|
3374
|
+
}).pipe(Effect.catchCause((cause) => Effect.failCause(Cause.map(cause, (error) => LedgerError.make({
|
|
3375
|
+
operation: "delivery-completion",
|
|
3376
|
+
message: "Destination acknowledgement remains pending",
|
|
3377
|
+
cause: error
|
|
3378
|
+
})))));
|
|
3379
|
+
}
|
|
3341
3380
|
if (submission.workerAdmission?.origin.reporting?.mode === "standard") yield* updateRuntime.repair(submission.threadId).pipe(Effect.mapError(() => LedgerError.make({
|
|
3342
3381
|
operation: "update-delivery",
|
|
3343
3382
|
message: "Update delivery remains pending"
|
|
@@ -3396,13 +3435,13 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
3396
3435
|
records: [record]
|
|
3397
3436
|
})).pipe(Effect.catchTag("AppendConflict", () => Effect.void), Effect.asVoid);
|
|
3398
3437
|
yield* hit("terminalize:after-canonical-append");
|
|
3399
|
-
yield* notifyParentOfChildSettlement(submission);
|
|
3438
|
+
yield* notifyParentOfChildSettlement(submission, record);
|
|
3400
3439
|
const settlement = yield* ledger.finalizeSettlement(SettlementFinalization.make({
|
|
3401
3440
|
submissionId,
|
|
3402
3441
|
settlementId
|
|
3403
3442
|
}));
|
|
3404
3443
|
yield* wake.notify(submission.threadId);
|
|
3405
|
-
yield* notifyParentOfChildSettlement(submission);
|
|
3444
|
+
yield* notifyParentOfChildSettlement(submission, record);
|
|
3406
3445
|
return settlement;
|
|
3407
3446
|
});
|
|
3408
3447
|
/**
|
|
@@ -3465,14 +3504,14 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
3465
3504
|
records: [reserved.record]
|
|
3466
3505
|
})).pipe(Effect.catchTag("AppendConflict", () => Effect.void), Effect.asVoid);
|
|
3467
3506
|
yield* hit("terminalize:after-canonical-append");
|
|
3468
|
-
yield* notifyParentOfChildSettlement(submission);
|
|
3507
|
+
yield* notifyParentOfChildSettlement(submission, reserved.record);
|
|
3469
3508
|
const settlement = yield* ledger.finalizeSettlement(SettlementFinalization.make({
|
|
3470
3509
|
submissionId,
|
|
3471
3510
|
settlementId
|
|
3472
3511
|
}));
|
|
3473
3512
|
const canonicalSettlement = yield* settlementPayloadFromRecord(reserved.record, submissionId);
|
|
3474
3513
|
yield* wake.notify(submission.threadId);
|
|
3475
|
-
yield* notifyParentOfChildSettlement(submission);
|
|
3514
|
+
yield* notifyParentOfChildSettlement(submission, reserved.record);
|
|
3476
3515
|
yield* settleJoinedSubmissions(ctx, canonicalSettlement);
|
|
3477
3516
|
return materializeSettlement(settlement, reserved.record);
|
|
3478
3517
|
});
|
|
@@ -3486,28 +3525,28 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
3486
3525
|
})).pipe(Effect.catchTag("AppendConflict", () => Effect.void), Effect.asVoid);
|
|
3487
3526
|
yield* hit("terminalize:after-canonical-append");
|
|
3488
3527
|
}
|
|
3489
|
-
yield* notifyParentOfChildSettlement(submission);
|
|
3528
|
+
yield* notifyParentOfChildSettlement(submission, reservation.record);
|
|
3490
3529
|
const settlement = yield* ledger.finalizeSettlement(SettlementFinalization.make({
|
|
3491
3530
|
submissionId: submission.submissionId,
|
|
3492
3531
|
settlementId: reservation.settlementId
|
|
3493
3532
|
}));
|
|
3494
3533
|
const canonicalSettlement = yield* settlementPayloadFromRecord(reservation.record, submission.submissionId);
|
|
3495
3534
|
yield* wake.notify(submission.threadId);
|
|
3496
|
-
yield* notifyParentOfChildSettlement(submission);
|
|
3535
|
+
yield* notifyParentOfChildSettlement(submission, reservation.record);
|
|
3497
3536
|
yield* settleJoinedSubmissions(ctx, canonicalSettlement);
|
|
3498
3537
|
return materializeSettlement(settlement, reservation.record);
|
|
3499
3538
|
});
|
|
3500
3539
|
/** Canonical settlement exists: rebuild the ledger from history, never the reverse (DUR-015). */
|
|
3501
3540
|
const finalizeFromHistory = Effect.fn("DurableAgentRuntime.finalizeFromHistory")(function* (submission, record) {
|
|
3502
3541
|
const canonicalSettlement = yield* settlementPayloadFromRecord(record, submission.submissionId);
|
|
3503
|
-
yield* notifyParentOfChildSettlement(submission);
|
|
3542
|
+
yield* notifyParentOfChildSettlement(submission, record);
|
|
3504
3543
|
const settlement = yield* ledger.finalizeSettlement(SettlementFinalization.make({
|
|
3505
3544
|
submissionId: submission.submissionId,
|
|
3506
3545
|
settlementId: canonicalSettlement.settlementId
|
|
3507
3546
|
}));
|
|
3508
3547
|
const snapshot = yield* ledger.loadRecoverySnapshot(RecoverySnapshotRequest.make({ submissionId: submission.submissionId }));
|
|
3509
3548
|
yield* wake.notify(submission.threadId);
|
|
3510
|
-
yield* notifyParentOfChildSettlement(submission);
|
|
3549
|
+
yield* notifyParentOfChildSettlement(submission, record);
|
|
3511
3550
|
return materializeSettlement(settlement, snapshot.reservation?.record);
|
|
3512
3551
|
});
|
|
3513
3552
|
/**
|
|
@@ -4107,7 +4146,7 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
4107
4146
|
* journal ends mid-batch,
|
|
4108
4147
|
* `RunOptions.resume` replays the declared batch without re-invoking the model (§2.4).
|
|
4109
4148
|
*/
|
|
4110
|
-
const runModel = (agent, ctx, submission, tokenRef, records, canonical, canonicalThrough, journalSeed, journalMetadata, lineage, approvalDecisions, currentContracts, runTiming, yieldAfter) => Effect.gen(function* () {
|
|
4149
|
+
const runModel = (agent, ctx, submission, tokenRef, renewAtRef, records, canonical, canonicalThrough, journalSeed, journalMetadata, lineage, approvalDecisions, currentContracts, runTiming, yieldAfter) => Effect.gen(function* () {
|
|
4111
4150
|
const submissionId = submission.submissionId;
|
|
4112
4151
|
const runId = runIdForSubmission(submissionId);
|
|
4113
4152
|
const boundaries = [];
|
|
@@ -4384,6 +4423,7 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
4384
4423
|
const uncached = yield* addUsageTotal("inputTokens.uncached", detailed.inputTokens.uncached, legacyInput);
|
|
4385
4424
|
const text = yield* addUsageTotal("outputTokens.text", detailed.outputTokens.text, legacyOutput);
|
|
4386
4425
|
return RunUsageSummary.make({
|
|
4426
|
+
...legacyCalls === 0 && detailed.webSearchCalls !== void 0 ? { webSearchCalls: detailed.webSearchCalls } : {},
|
|
4387
4427
|
modelCalls,
|
|
4388
4428
|
inputTokens: InputTokenUsage.make({
|
|
4389
4429
|
total: inputTokens,
|
|
@@ -5612,14 +5652,22 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
5612
5652
|
return { _tag: "aborted" };
|
|
5613
5653
|
}
|
|
5614
5654
|
}));
|
|
5615
|
-
const renewal = halt(Effect.
|
|
5616
|
-
const
|
|
5617
|
-
const
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5655
|
+
const renewal = halt(Effect.gen(function* () {
|
|
5656
|
+
const renewAt = yield* Ref.get(renewAtRef);
|
|
5657
|
+
const now = yield* Clock.currentTimeMillis;
|
|
5658
|
+
yield* Effect.sleep(Math.max(0, renewAt - now));
|
|
5659
|
+
yield* Effect.repeat(Effect.gen(function* () {
|
|
5660
|
+
const ownershipToken = yield* Ref.get(tokenRef);
|
|
5661
|
+
const renewingAt = yield* Clock.currentTimeMillis;
|
|
5662
|
+
const renewal = yield* ledger.renewOwnership(RenewOwnershipRequest.make({
|
|
5663
|
+
submissionId,
|
|
5664
|
+
ownershipToken
|
|
5665
|
+
}));
|
|
5666
|
+
yield* Ref.set(tokenRef, renewal.ownershipToken);
|
|
5667
|
+
yield* Ref.set(renewAtRef, renewingAt + Duration.toMillis(config.leaseRenewalInterval));
|
|
5668
|
+
}).pipe(Effect.uninterruptible), { schedule: Schedule.spaced(config.leaseRenewalInterval) });
|
|
5669
|
+
return yield* Effect.never;
|
|
5670
|
+
}));
|
|
5623
5671
|
const execution = Effect.raceFirst(consume, Effect.raceFirst(abortWatcher, renewal));
|
|
5624
5672
|
const result = yield* (yieldAfter === void 0 && submissionScheduling.yieldTo === void 0 ? execution : Effect.raceFirst(execution, Deferred.await(yieldSignal).pipe(Effect.map((nextSubmissionId) => ({
|
|
5625
5673
|
_tag: "yielded",
|
|
@@ -5703,7 +5751,7 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
5703
5751
|
* (Unknown Outcomes, or a durable approval suspension) — no settlement occurs and the
|
|
5704
5752
|
* obligation stays owed.
|
|
5705
5753
|
*/
|
|
5706
|
-
const runAttempt = (registeredAgent, threadId, claim, tokenRef, resumeAfterRetention, onHandoff, yieldAfter) => Effect.gen(function* () {
|
|
5754
|
+
const runAttempt = (registeredAgent, threadId, claim, tokenRef, renewAtRef, resumeAfterRetention, onHandoff, yieldAfter) => Effect.gen(function* () {
|
|
5707
5755
|
const submissionId = claim.submissionId;
|
|
5708
5756
|
const supersededEpoch = yield* store.inspectTail(ThreadTailRequest.make({ threadId })).pipe(Effect.map((tail) => tail.producerEpoch), Effect.catchTag("ThreadNotMaterialized", () => Effect.succeed(ZERO_EPOCH)));
|
|
5709
5757
|
yield* store.materialize(ThreadMaterialization.make({
|
|
@@ -5886,7 +5934,7 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
5886
5934
|
const tail = yield* store.inspectTail(ThreadTailRequest.make({ threadId }));
|
|
5887
5935
|
const canonical = Stream.concat(initialView.canonical, canonicalRange(threadId, tail.tailSequence, initialThrough));
|
|
5888
5936
|
const currentRecords = yield* refreshControl(tail.tailSequence);
|
|
5889
|
-
const outcome = yield* runModel(agent, ctx, submission, tokenRef, currentRecords, canonical, tail.tailSequence, initialView.seed, journalMetadata?.snapshot(), lineage, approvalDecisionIntents, currentContracts, runTiming, yieldAfter);
|
|
5937
|
+
const outcome = yield* runModel(agent, ctx, submission, tokenRef, renewAtRef, currentRecords, canonical, tail.tailSequence, initialView.seed, journalMetadata?.snapshot(), lineage, approvalDecisionIntents, currentContracts, runTiming, yieldAfter);
|
|
5890
5938
|
if (outcome._tag === "yielded") {
|
|
5891
5939
|
if (outcome.nextSubmissionId !== void 0) onHandoff(outcome.nextSubmissionId);
|
|
5892
5940
|
return Option.none();
|
|
@@ -5972,6 +6020,7 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
5972
6020
|
}
|
|
5973
6021
|
}).pipe(Effect.scoped);
|
|
5974
6022
|
const acquireClaim = Effect.fn("DurableAgentRuntime.acquireClaim")(function* (threadId, handoff) {
|
|
6023
|
+
const acquiringAt = yield* Clock.currentTimeMillis;
|
|
5975
6024
|
const claimed = yield* ledger.claim(ClaimRequest.make({
|
|
5976
6025
|
threadId,
|
|
5977
6026
|
producerId: config.producerId,
|
|
@@ -5980,6 +6029,7 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
5980
6029
|
if (Option.isNone(claimed)) return Option.none();
|
|
5981
6030
|
const claim = claimed.value;
|
|
5982
6031
|
const tokenRef = yield* Ref.make(claim.ownershipToken);
|
|
6032
|
+
const renewAtRef = yield* Ref.make(acquiringAt + Duration.toMillis(config.leaseRenewalInterval));
|
|
5983
6033
|
yield* Effect.addFinalizer(() => Ref.get(tokenRef).pipe(Effect.flatMap((ownershipToken) => ledger.releaseOwnership(ReleaseOwnershipRequest.make({
|
|
5984
6034
|
submissionId: claim.submissionId,
|
|
5985
6035
|
ownershipToken
|
|
@@ -5990,7 +6040,8 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
5990
6040
|
});
|
|
5991
6041
|
return Option.some({
|
|
5992
6042
|
claim,
|
|
5993
|
-
tokenRef
|
|
6043
|
+
tokenRef,
|
|
6044
|
+
renewAtRef
|
|
5994
6045
|
});
|
|
5995
6046
|
}, Effect.uninterruptible);
|
|
5996
6047
|
const processThreadHead = (resolve, threadId, options) => Effect.gen(function* () {
|
|
@@ -6000,7 +6051,7 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
6000
6051
|
const attempt = Effect.scoped(Effect.gen(function* () {
|
|
6001
6052
|
const claimed = yield* acquireClaim(threadId, handoff);
|
|
6002
6053
|
if (Option.isNone(claimed)) return Option.none();
|
|
6003
|
-
const { claim, tokenRef } = claimed.value;
|
|
6054
|
+
const { claim, tokenRef, renewAtRef } = claimed.value;
|
|
6004
6055
|
const attributes = {
|
|
6005
6056
|
threadId,
|
|
6006
6057
|
submissionId: claim.submissionId,
|
|
@@ -6034,7 +6085,7 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
6034
6085
|
failure
|
|
6035
6086
|
}) }));
|
|
6036
6087
|
if (resolution._tag === "refused") return yield* resolution.failure;
|
|
6037
|
-
return yield* resolution.binding.attempt((agent, attemptThreadId, attemptClaim) => runAttempt(agent, attemptThreadId, attemptClaim, tokenRef, () => {
|
|
6088
|
+
return yield* resolution.binding.attempt((agent, attemptThreadId, attemptClaim) => runAttempt(agent, attemptThreadId, attemptClaim, tokenRef, renewAtRef, () => {
|
|
6038
6089
|
resumeAfterRetention = true;
|
|
6039
6090
|
}, (nextSubmissionId) => {
|
|
6040
6091
|
nextHandoff = ClaimHandoff.make({
|
|
@@ -7301,4 +7352,4 @@ var DurableAgentRuntime = class DurableAgentRuntime extends Context.Service()("@
|
|
|
7301
7352
|
//#endregion
|
|
7302
7353
|
export { DurableApprovalSuspension as a, RecoveryFailure as c, childReservationIdFor as d, isolateRecovery as f, DurableApprovalResolver as i, RecoveryReport as l, recoveryRepairRecordId as m, DurableAgentRuntime as n, DurableRuntimeConfig as o, recoveryRepairBatchId as p, DurableAgentRuntime_exports as r, RecoveryBlocked as s, ApprovalSuspensionError as t, RecoverySweepResult as u };
|
|
7303
7354
|
|
|
7304
|
-
//# sourceMappingURL=DurableAgentRuntime-
|
|
7355
|
+
//# sourceMappingURL=DurableAgentRuntime-eImXoGqD.mjs.map
|