effect-agent 0.1.0-beta.96 → 0.1.0-beta.97
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/{DurableAgentRuntime-BGwGUIT-.mjs → DurableAgentRuntime-DbUvZHDZ.mjs} +34 -30
- package/dist/DurableAgentRuntime-DbUvZHDZ.mjs.map +1 -0
- package/dist/{EventSource-tCO_dAff.d.mts → EventSource-D6PAAEyK.d.mts} +3 -3
- package/dist/{PreparedInputAdmission-CFSddiT8.d.mts → PreparedInputAdmission-omMbwd--.d.mts} +4 -4
- package/dist/{Records-BEz5IFUu.mjs → Records-BAutSSnJ.mjs} +3 -1
- package/dist/Records-BAutSSnJ.mjs.map +1 -0
- package/dist/{Records-CMByd1eD.d.mts → Records-CV49DgQK.d.mts} +37 -9
- package/dist/{RunJournal-B_fxe57c.mjs → RunJournal-DRRRZmG7.mjs} +2 -2
- package/dist/{RunJournal-B_fxe57c.mjs.map → RunJournal-DRRRZmG7.mjs.map} +1 -1
- package/dist/{Schedule-BxCfnYr0.d.mts → Schedule-DePbGfgd.d.mts} +2 -2
- package/dist/{Scheduling-BW6BD_TP.mjs → Scheduling-C3QpYn0W.mjs} +2 -2
- package/dist/{Scheduling-BW6BD_TP.mjs.map → Scheduling-C3QpYn0W.mjs.map} +1 -1
- package/dist/{Subscription-CrTIQKZR.d.mts → Subscription-BR_8Cxh3.d.mts} +3 -3
- package/dist/{SubscriptionInput-BVOeFF1L.d.mts → SubscriptionInput-B95sQbuk.d.mts} +3 -3
- package/dist/{agent-registration-BTa5vmQF.mjs → agent-registration-CXGDwvJH.mjs} +151 -26
- package/dist/agent-registration-CXGDwvJH.mjs.map +1 -0
- package/dist/durable/ActivityStore.d.mts +1 -1
- package/dist/durable/ActivityStore.mjs +1 -1
- package/dist/durable/Admin.d.mts +1 -1
- package/dist/durable/Admin.mjs +1 -1
- package/dist/durable/AgentRegistration.d.mts +2 -2
- package/dist/durable/AgentRegistration.mjs +3 -2
- package/dist/durable/AgentRegistration.mjs.map +1 -1
- package/dist/durable/Certification.d.mts +1 -1
- package/dist/durable/CommittedActivity.d.mts +1 -1
- package/dist/durable/CommittedActivity.mjs +1 -1
- package/dist/durable/Digest.d.mts +1 -1
- package/dist/durable/Digest.mjs +1 -1
- package/dist/durable/DurableAgentRuntime.d.mts +1 -1
- package/dist/durable/DurableAgentRuntime.mjs +1 -1
- package/dist/durable/EventSource.d.mts +1 -1
- package/dist/durable/EventSource.mjs +1 -1
- package/dist/durable/GitHubWorkflowSource.d.mts +3 -3
- package/dist/durable/GitHubWorkflowSource.mjs +1 -1
- package/dist/durable/MessageDelivery.d.mts +3 -3
- package/dist/durable/MessageDelivery.mjs +1 -1
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +1 -1
- package/dist/durable/MessageDeliveryStoreConformance.mjs +1 -1
- package/dist/durable/PersistentHistory.d.mts +1 -1
- package/dist/durable/PersistentHistory.mjs +2 -2
- package/dist/durable/PreparedInputAdmission.d.mts +1 -1
- package/dist/durable/Records.d.mts +1 -1
- package/dist/durable/Records.mjs +1 -1
- package/dist/durable/Recovery.d.mts +1 -1
- package/dist/durable/Recovery.mjs +1 -1
- package/dist/durable/RunJournal.d.mts +1 -1
- package/dist/durable/RunJournal.mjs +1 -1
- package/dist/durable/Schedule.d.mts +1 -1
- package/dist/durable/Schedule.mjs +1 -1
- package/dist/durable/ScheduleStoreConformance.d.mts +1 -1
- package/dist/durable/ScheduleStoreConformance.mjs +1 -1
- package/dist/durable/ScheduleTransition.d.mts +1 -1
- package/dist/durable/ScheduleTransition.mjs +1 -1
- package/dist/durable/Scheduling.d.mts +2 -2
- package/dist/durable/Scheduling.mjs +1 -1
- package/dist/durable/SqlStorageV2Upgrade.d.mts +2 -2
- package/dist/durable/SqlStorageV2Upgrade.mjs +1 -1
- package/dist/durable/SqlSubscriptionStore.d.mts +2 -2
- package/dist/durable/SqlSubscriptionStore.mjs +1 -1
- package/dist/durable/SubmissionLedger.d.mts +1 -1
- package/dist/durable/SubmissionLedger.mjs +1 -1
- package/dist/durable/SubmissionLedgerConformance.d.mts +1 -1
- package/dist/durable/SubmissionLedgerConformance.mjs +1 -1
- package/dist/durable/SubmissionStatus.d.mts +1 -1
- package/dist/durable/Subscription.d.mts +1 -1
- package/dist/durable/Subscription.mjs +1 -1
- package/dist/durable/SubscriptionInput.d.mts +1 -1
- package/dist/durable/SubscriptionInput.mjs +2 -2
- package/dist/durable/SubscriptionStoreConformance.d.mts +1 -1
- package/dist/durable/SubscriptionStoreConformance.mjs +1 -1
- package/dist/durable/SubscriptionTools.d.mts +3 -3
- package/dist/durable/SubscriptionTransition.d.mts +1 -1
- package/dist/durable/SubscriptionTransition.mjs +1 -1
- package/dist/durable/Subscriptions.d.mts +5 -5
- package/dist/durable/Subscriptions.mjs +1 -1
- package/dist/durable/ThreadContextHistory.d.mts +1 -1
- package/dist/durable/ThreadContextHistory.mjs +1 -1
- package/dist/durable/ThreadContextHistoryProjection.d.mts +1 -1
- package/dist/durable/ThreadContextHistoryProjection.mjs +1 -1
- package/dist/durable/ThreadInvariants.d.mts +1 -1
- package/dist/durable/ThreadInvariants.mjs +1 -1
- package/dist/durable/ThreadProjection.d.mts +1 -1
- package/dist/durable/ThreadProjection.mjs +1 -1
- package/dist/durable/ThreadProjectionMaintenance.d.mts +1 -1
- package/dist/durable/ThreadStore.d.mts +1 -1
- package/dist/durable/ThreadStore.mjs +1 -1
- package/dist/durable/ThreadStoreConformance.d.mts +1 -1
- package/dist/durable/ThreadStoreConformance.mjs +1 -1
- package/dist/durable/ToolReconciler.mjs +1 -1
- package/dist/durable/WorkerHost.d.mts +1 -1
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +4 -4
- package/package.json +1 -1
- package/src/durable/AgentRegistration.ts +1 -0
- package/src/durable/DurableAgentRuntime.ts +3 -1
- package/src/durable/Records.ts +2 -0
- package/src/durable/internal/agent-registration.ts +274 -36
- package/src/durable/internal/messaging-host.ts +2 -5
- package/src/durable/internal/worker-host.ts +119 -85
- package/dist/DurableAgentRuntime-BGwGUIT-.mjs.map +0 -1
- package/dist/Records-BEz5IFUu.mjs.map +0 -1
- package/dist/agent-registration-BTa5vmQF.mjs.map +0 -1
|
@@ -19,12 +19,12 @@ import { getToolExecutionClass } from "./engine/DurableStep.mjs";
|
|
|
19
19
|
import { CompactionError, ContextCompactor } from "./engine/ContextCompactor.mjs";
|
|
20
20
|
import { RunPolicyUsage } from "./core/RunPolicyUsage.mjs";
|
|
21
21
|
import { AgentUpdateAcceptance, CurrentToolFailureObserver, ModelUsageAccounting, RunContextPreparation, RunContextPreparationPassthrough, RunToolAuthorization, RunToolScheduling } from "./engine/RunOptions.mjs";
|
|
22
|
-
import { $ as ToolCallSettled, B as SubagentJoined, E as ProducerEpoch, G as SubmissionSettledRecord, H as SubagentRequested, I as RunPolicyUsageReserved, J as ToolApprovalDecided, K as SubtreeBudgetReserved, L as RunStartedRecord, O as RecordEnvelope, P as RunDurationExhausted, Q as ToolCallResolved, R as SettlementFailureDiagnostic, T as PersistedJson, U as SubagentStarted, V as SubagentLineageRecorded, W as SubmissionSettled, X as ToolCallPrepared, Y as ToolApprovalRequested, at as WorkerInputRequested, c as CanonicalRecordEnvelope, ct as WorkerReportPrepared, d as CompactionCreated, et as ToolCallUnknown, h as Digest, i as BatchId, it as WorkerInputCompleted, j as RepairAnnotated, k as RecordId, lt as WorkerReportRefused, n as AgentUpdateEmitted, nt as UserInputRecorded, o as CanonicalBatch, ot as WorkerOrigin, p as DefinitionDigests, q as ThreadCreated, rt as WorkerAdmission, st as WorkerOriginRecorded, t as AbortRequested, tt as ToolStepSettled, u as CanonicalSequence, ut as WorkerReportingIntent, w as PeerMessagePrepared, x as ModelResponseInterrupted } from "./Records-
|
|
22
|
+
import { $ as ToolCallSettled, B as SubagentJoined, E as ProducerEpoch, G as SubmissionSettledRecord, H as SubagentRequested, I as RunPolicyUsageReserved, J as ToolApprovalDecided, K as SubtreeBudgetReserved, L as RunStartedRecord, O as RecordEnvelope, P as RunDurationExhausted, Q as ToolCallResolved, R as SettlementFailureDiagnostic, T as PersistedJson, U as SubagentStarted, V as SubagentLineageRecorded, W as SubmissionSettled, X as ToolCallPrepared, Y as ToolApprovalRequested, at as WorkerInputRequested, c as CanonicalRecordEnvelope, ct as WorkerReportPrepared, d as CompactionCreated, et as ToolCallUnknown, h as Digest, i as BatchId, it as WorkerInputCompleted, j as RepairAnnotated, k as RecordId, lt as WorkerReportRefused, n as AgentUpdateEmitted, nt as UserInputRecorded, o as CanonicalBatch, ot as WorkerOrigin, p as DefinitionDigests, q as ThreadCreated, rt as WorkerAdmission, st as WorkerOriginRecorded, t as AbortRequested, tt as ToolStepSettled, u as CanonicalSequence, ut as WorkerReportingIntent, w as PeerMessagePrepared, x as ModelResponseInterrupted } from "./Records-BAutSSnJ.mjs";
|
|
23
23
|
import { AbortCommand, AbortIntentRequest, AdmissionPolicyError, AdmissionRequest, ApprovalDecisionCommand, ApprovalPendingSuspension, AttachChildToReservationRequest, BeginChildBudgetReleaseRequest, ChildBudgetReservationRequest, ChildReservationId, ChildSettledNotification, ClaimJoiningRequest, ClaimRequest, LedgerError, MarkInputAppliedRequest, MarkJoinedRequest, MarkReadyRequest, MarkUnknownRequest, OwnershipToken, ParentLinkage, RecoverySnapshotRequest, ReleaseChildBudgetRequest, ReleaseOwnershipRequest, RenewOwnershipRequest, RevertJoiningRequest, Settlement, SettlementFinalization, SettlementReservation, SubmissionLedger, SubmissionLookupById, SubmissionLookupByKey, SuspendRequest, UnknownResolutionCommand, WaitingChild, WaitingForChildSuspension, submissionAbortBatchId, submissionAbortRecordId, submissionInputBatchId, submissionInputRecordId, submissionSettlementBatchId, submissionSettlementId, submissionSettlementRecordId } from "./durable/SubmissionLedger.mjs";
|
|
24
24
|
import { DeclaredPendingBatchEvidence, OpenDelegationCallEvidence, OpenToolCallEvidence, PendingApprovalEvidence, RecoveryDecision, RecoveryEvidence, classifyRecovery } from "./durable/Recovery.mjs";
|
|
25
25
|
import { ExplainedEvidence, ExplainedSubmission, ExplainedUnknownCall, IntegrityCheck, IntegrityReport, ObligationEntry, ObligationReport, RecoveryExplanation, RetryRefused, obligationSeverityOf, predictRecoveryDisposition, recoveryDecisionMeaning } from "./durable/Admin.mjs";
|
|
26
26
|
import { digestJson } from "./durable/Digest.mjs";
|
|
27
|
-
import { a as bindingSupports,
|
|
27
|
+
import { a as bindingSupports, c as definitionDigestsEqual, d as resolveDefinitionBinding, f as resolveWorkerBinding, r as BindingUnavailable, s as compileRegistrations, u as makeLegacyWorkerBinding } from "./agent-registration-CXGDwvJH.mjs";
|
|
28
28
|
import { FencedAppendRequest, LoadCheckpointRequest, SaveRecoveryCheckpointRequest, ThreadCheckpoint, ThreadExportRequest, ThreadMaterialization, ThreadObservation, ThreadRead, ThreadStore, ThreadStoreError, ThreadTailRequest } from "./durable/ThreadStore.mjs";
|
|
29
29
|
import { DurableRuntimeFailpoint } from "./durable/DurableFailpoint.mjs";
|
|
30
30
|
import { ScheduledInputRefused, ScheduledInputRetryable } from "./durable/Schedule.mjs";
|
|
@@ -32,7 +32,7 @@ import { PreparedInputAdmission } from "./durable/PreparedInputAdmission.mjs";
|
|
|
32
32
|
import { PreparedInput } from "./durable/Subscription.mjs";
|
|
33
33
|
import { MessageDeliveryDriver, MessageDeliveryFailpoint, MessageDeliveryRecord, MessageDeliveryStore, messageDeliveryCapacity, messageDeliveryUsesCapacity, prepareMessageDelivery } from "./durable/MessageDelivery.mjs";
|
|
34
34
|
import { n as safeUnknownString, t as inspectForeignDiagnostic } from "./foreign-diagnostic-DBQ1XHKh.mjs";
|
|
35
|
-
import { A as toolApprovalRequestRecordId, C as subagentLineageBatchId, D as subagentStartedBatchId, E as subagentRequestedRecordId, F as toolCallSettledRecordId, H as turnIdForRun, I as toolCallUnknownRecordId, J as makeJournalMetadata, K as turnResultsBatch, L as toolStepSettledBatchId, M as toolCallResolutionBatchId, N as toolCallResolvedRecordId, O as subagentStartedRecordId, P as toolCallResultBatchId, R as toolStepSettledRecordId, S as subagentJoinedRecordId, T as subagentRequestedBatchId, U as turnPreparedBatchId, V as turnCanonicalBatch, W as turnResponseBatch, _ as runDurationRecordId, a as childThreadIdFor, b as runStartedRecordId, c as markUnknownBatchId, d as modelResponseRecordId, g as runDurationBatchId, h as runCompletedRecordId, i as childIdempotencyKeyFor, j as toolCallPreparedRecordId, k as toolApprovalDecisionRecordId, l as modelResponseInterruptedBatchId, o as compactionBatchId, p as projectRunJournalStream, r as approvalDecisionBatchId, s as compactionRecordId, t as RunJournalError, u as modelResponseInterruptedRecordId, v as runIdForSubmission, w as subagentLineageRecordId, x as subagentJoinBatchId, y as runStartedBatchId, z as turnApprovalsBatchId } from "./RunJournal-
|
|
35
|
+
import { A as toolApprovalRequestRecordId, C as subagentLineageBatchId, D as subagentStartedBatchId, E as subagentRequestedRecordId, F as toolCallSettledRecordId, H as turnIdForRun, I as toolCallUnknownRecordId, J as makeJournalMetadata, K as turnResultsBatch, L as toolStepSettledBatchId, M as toolCallResolutionBatchId, N as toolCallResolvedRecordId, O as subagentStartedRecordId, P as toolCallResultBatchId, R as toolStepSettledRecordId, S as subagentJoinedRecordId, T as subagentRequestedBatchId, U as turnPreparedBatchId, V as turnCanonicalBatch, W as turnResponseBatch, _ as runDurationRecordId, a as childThreadIdFor, b as runStartedRecordId, c as markUnknownBatchId, d as modelResponseRecordId, g as runDurationBatchId, h as runCompletedRecordId, i as childIdempotencyKeyFor, j as toolCallPreparedRecordId, k as toolApprovalDecisionRecordId, l as modelResponseInterruptedBatchId, o as compactionBatchId, p as projectRunJournalStream, r as approvalDecisionBatchId, s as compactionRecordId, t as RunJournalError, u as modelResponseInterruptedRecordId, v as runIdForSubmission, w as subagentLineageRecordId, x as subagentJoinBatchId, y as runStartedBatchId, z as turnApprovalsBatchId } from "./RunJournal-DRRRZmG7.mjs";
|
|
36
36
|
import { WorkerBudgetAuthorizer, WorkerConcurrencyLimit, WorkerConcurrencyResolver, WorkerHostAuthorizer, WorkerHostConfig, WorkerPolicyResolver } from "./durable/WorkerHost.mjs";
|
|
37
37
|
import { OperationAuthorizationRequest, OperationAuthorizer, OperationDenied } from "./durable/OperationAuthorizer.mjs";
|
|
38
38
|
import { PendingSubmission, SettledSubmission } from "./durable/SubmissionStatus.mjs";
|
|
@@ -272,7 +272,7 @@ const makeMessagingRuntime = Effect.fn("MessagingHost.make")(function* (options)
|
|
|
272
272
|
const log = yield* read(threadId);
|
|
273
273
|
const created = log.records[0]?.record.payload;
|
|
274
274
|
if (created?._tag !== "ThreadCreated") return yield* failure$1("context", "not-found");
|
|
275
|
-
if (deps.bindings.filter((binding) => binding.agentId === created.agentId
|
|
275
|
+
if (deps.bindings.filter((binding) => binding.agentId === created.agentId).length !== 1) return yield* failure$1("context", "binding-mismatch");
|
|
276
276
|
return {
|
|
277
277
|
log,
|
|
278
278
|
address: {
|
|
@@ -375,7 +375,7 @@ const makeMessagingRuntime = Effect.fn("MessagingHost.make")(function* (options)
|
|
|
375
375
|
if (prior !== void 0) {
|
|
376
376
|
saved = yield* decodeProof(prior);
|
|
377
377
|
const metadata = saved.envelope.messageAdmission;
|
|
378
|
-
if (!Schema.is(MessageAdmission)(metadata) || metadata.peerName !== request.name || saved.envelope.agentId !== target.agentId || !bindingSupports(target, saved.envelope.definitions) || !sameJson$1(saved.envelope.input, input) || (inReplyTo === void 0 || metadata.inReplyTo === void 0 ? inReplyTo !== metadata.inReplyTo : !sameRef(inReplyTo, metadata.inReplyTo))) return yield* failure$1(operation, "conflict");
|
|
378
|
+
if (!Schema.is(MessageAdmission)(metadata) || metadata.peerName !== request.name || saved.envelope.agentId !== target.agentId || !bindingSupports(target, saved.envelope.definitions, void 0, saved.envelope.input) || !sameJson$1(saved.envelope.input, input) || (inReplyTo === void 0 || metadata.inReplyTo === void 0 ? inReplyTo !== metadata.inReplyTo : !sameRef(inReplyTo, metadata.inReplyTo))) return yield* failure$1(operation, "conflict");
|
|
379
379
|
yield* authorize(operation, "send", request, {
|
|
380
380
|
threadId: saved.envelope.threadId,
|
|
381
381
|
agentId: target.agentId
|
|
@@ -676,11 +676,15 @@ const makeWorkerRuntime = Effect.fn("WorkerHost.make")(function* (options) {
|
|
|
676
676
|
...report.destination === void 0 ? {} : { destinationDelegationId: report.destination.delegationId }
|
|
677
677
|
};
|
|
678
678
|
});
|
|
679
|
+
const firstThreadInput = (history) => {
|
|
680
|
+
const first = history.records.find(({ record }) => record.payload._tag === "UserInputRecorded")?.record.payload;
|
|
681
|
+
return first?._tag === "UserInputRecorded" ? first.input : void 0;
|
|
682
|
+
};
|
|
679
683
|
const sourceAuthority = Effect.fn("WorkerHost.sourceAuthority")(function* (threadId, submissionId) {
|
|
680
684
|
const current = yield* read(threadId, "start");
|
|
681
685
|
const created = current.records[0]?.record.payload;
|
|
682
686
|
if (created?._tag !== "ThreadCreated") return yield* failure("start", "not-found");
|
|
683
|
-
const binding = deps.bindings.find((entry) => entry.agentId === created.agentId && bindingSupports(entry, created.definitions));
|
|
687
|
+
const binding = deps.bindings.find((entry) => entry.agentId === created.agentId && bindingSupports(entry, created.definitions, void 0, firstThreadInput(current)));
|
|
684
688
|
const worker = current.records.find(({ record }) => record.payload._tag === "WorkerOriginRecorded")?.record.payload;
|
|
685
689
|
const attached = current.records.find(({ record }) => record.payload._tag === "SubagentLineageRecorded")?.record.payload;
|
|
686
690
|
const nested = worker?._tag === "WorkerOriginRecorded" || attached?._tag === "SubagentLineageRecorded";
|
|
@@ -693,9 +697,11 @@ const makeWorkerRuntime = Effect.fn("WorkerHost.make")(function* (options) {
|
|
|
693
697
|
if (worker?._tag === "WorkerOriginRecorded" && (submission.value.workerAdmission === void 0 || !sameOrigin(submission.value.workerAdmission.origin, worker.origin))) return yield* failure("start", "denied");
|
|
694
698
|
if (attached?._tag === "SubagentLineageRecorded" && (submission.value.parentLinkage?.parentSubmissionId !== attached.parentSubmissionId || submission.value.parentLinkage.parentToolCallId !== attached.parentLink.parentToolCallId)) return yield* failure("start", "denied");
|
|
695
699
|
}
|
|
700
|
+
const ownerBinding = ownerSubmission === void 0 ? void 0 : deps.bindings.find((entry) => entry.agentId === ownerSubmission.agentId && bindingSupports(entry, ownerSubmission.agentDigests, void 0, ownerSubmission.inputPayload));
|
|
701
|
+
const selectedBinding = ownerBinding ?? binding;
|
|
696
702
|
if (worker?._tag === "WorkerOriginRecorded") return {
|
|
697
703
|
current,
|
|
698
|
-
binding,
|
|
704
|
+
binding: selectedBinding,
|
|
699
705
|
submission: ownerSubmission,
|
|
700
706
|
policyOverride: Option.none(),
|
|
701
707
|
policy: worker.origin.policy,
|
|
@@ -708,7 +714,7 @@ const makeWorkerRuntime = Effect.fn("WorkerHost.make")(function* (options) {
|
|
|
708
714
|
if (attached.policy === void 0 || attached.budget === void 0 || attached.grant === void 0) return yield* failure("start", "denied");
|
|
709
715
|
return {
|
|
710
716
|
current,
|
|
711
|
-
binding,
|
|
717
|
+
binding: selectedBinding,
|
|
712
718
|
submission: ownerSubmission,
|
|
713
719
|
policyOverride: Option.none(),
|
|
714
720
|
policy: attached.policy,
|
|
@@ -718,8 +724,6 @@ const makeWorkerRuntime = Effect.fn("WorkerHost.make")(function* (options) {
|
|
|
718
724
|
depth: attached.parentLink.depth
|
|
719
725
|
};
|
|
720
726
|
}
|
|
721
|
-
const ownerBinding = ownerSubmission === void 0 ? void 0 : deps.bindings.find((entry) => entry.agentId === ownerSubmission.agentId && bindingSupports(entry, ownerSubmission.agentDigests));
|
|
722
|
-
const selectedBinding = ownerBinding ?? binding;
|
|
723
727
|
const changedRootAgent = ownerSubmission !== void 0 && ownerSubmission.agentId !== created.agentId;
|
|
724
728
|
if (selectedBinding === void 0 || changedRootAgent && ownerBinding === void 0) return yield* failure("start", "declaration-unavailable");
|
|
725
729
|
const selected = yield* deps.policyResolver.resolveSource({
|
|
@@ -729,7 +733,7 @@ const makeWorkerRuntime = Effect.fn("WorkerHost.make")(function* (options) {
|
|
|
729
733
|
...ownerSubmission === void 0 ? {} : { submission: ownerSubmission }
|
|
730
734
|
});
|
|
731
735
|
if (Option.isSome(selected) && ownerSubmission !== void 0 && ownerBinding === void 0) return yield* failure("start", "declaration-unavailable");
|
|
732
|
-
const effectiveBinding = Option.isSome(selected) || changedRootAgent ? selectedBinding : binding;
|
|
736
|
+
const effectiveBinding = Option.isSome(selected) || changedRootAgent || binding === void 0 ? selectedBinding : binding;
|
|
733
737
|
if (effectiveBinding === void 0) return yield* failure("start", "declaration-unavailable");
|
|
734
738
|
const policy = Option.isNone(selected) ? effectiveBinding.definition.policy : yield* decode(AgentPolicy, selected.value, "start");
|
|
735
739
|
return {
|
|
@@ -823,7 +827,7 @@ const makeWorkerRuntime = Effect.fn("WorkerHost.make")(function* (options) {
|
|
|
823
827
|
if (prior === void 0 && admission.messageId !== origin.firstMessageId) return yield* failure("start", "not-found");
|
|
824
828
|
const caps = origin.budget.caps;
|
|
825
829
|
const sourceBinding = source.binding;
|
|
826
|
-
const targetBinding = deps.bindings.find((entry) => entry.agentId === origin.worker.targetAgentId && bindingSupports(entry, origin.targetDigests));
|
|
830
|
+
const targetBinding = deps.bindings.find((entry) => entry.agentId === origin.worker.targetAgentId && bindingSupports(entry, origin.targetDigests, void 0, input));
|
|
827
831
|
if (sourceBinding === void 0 || targetBinding === void 0) return yield* failure("start", "declaration-unavailable");
|
|
828
832
|
yield* Schema.decodeEffect(Schema.toEncoded(targetBinding.definition.input))(input).pipe(Effect.mapError(() => failure("start", "corrupt")));
|
|
829
833
|
const targetRequest = {
|
|
@@ -930,15 +934,15 @@ const makeWorkerRuntime = Effect.fn("WorkerHost.make")(function* (options) {
|
|
|
930
934
|
const intent = origin?.reporting;
|
|
931
935
|
if (origin === void 0 || intent?.mode !== "standard") return void 0;
|
|
932
936
|
if (update.threadId !== submission.threadId || update.agentId !== origin.worker.targetAgentId) return yield* failure("followUp", "worker-mismatch");
|
|
933
|
-
const sourceBinding = deps.bindings.find((entry) => entry.agentId === origin.source.agentId && bindingSupports(entry, intent.sourceDigests));
|
|
934
|
-
const targetBinding = deps.bindings.find((entry) => entry.agentId === origin.worker.targetAgentId && bindingSupports(entry, origin.targetDigests));
|
|
935
|
-
const reports = sourceBinding?.reporting?.filter((entry) => entry.delegationId === origin.worker.delegationId) ?? [];
|
|
936
|
-
if (sourceBinding === void 0 || targetBinding === void 0 || reports.length !== 1 || reports[0]?.mode !== "standard" || reports[0].target !== targetBinding.definition || !definitionDigestsEqual(submission.agentDigests, origin.targetDigests)) return yield* failure("followUp", "declaration-unavailable");
|
|
937
937
|
const sourceHistory = yield* read(origin.source.threadId, "followUp");
|
|
938
938
|
const first = requests(sourceHistory.records).find((row) => row.admission.messageId === origin.firstMessageId);
|
|
939
939
|
if (first === void 0 || !sameOrigin(first.admission.origin, origin)) return yield* failure("followUp", "corrupt");
|
|
940
940
|
const source = yield* sourceAuthority(origin.source.threadId, first.admission.sourceSubmissionId);
|
|
941
|
-
if (source.binding === void 0 || source.submission === void 0 || !bindingSupports(source.binding, intent.sourceDigests)) return yield* failure("followUp", "declaration-unavailable");
|
|
941
|
+
if (source.binding === void 0 || source.submission === void 0 || !bindingSupports(source.binding, intent.sourceDigests, void 0, source.submission?.inputPayload)) return yield* failure("followUp", "declaration-unavailable");
|
|
942
|
+
const sourceBinding = deps.bindings.find((entry) => entry.agentId === origin.source.agentId && bindingSupports(entry, intent.sourceDigests, void 0, source.submission?.inputPayload));
|
|
943
|
+
const targetBinding = deps.bindings.find((entry) => entry.agentId === origin.worker.targetAgentId && bindingSupports(entry, origin.targetDigests, void 0, submission.inputPayload));
|
|
944
|
+
const reports = sourceBinding?.reporting?.filter((entry) => entry.delegationId === origin.worker.delegationId) ?? [];
|
|
945
|
+
if (sourceBinding === void 0 || targetBinding === void 0 || reports.length !== 1 || reports[0]?.mode !== "standard" || reports[0].target !== targetBinding.definition || !definitionDigestsEqual(submission.agentDigests, origin.targetDigests)) return yield* failure("followUp", "declaration-unavailable");
|
|
942
946
|
const recorded = source.current.records.find(({ record }) => record.payload._tag === "WorkerOriginRecorded")?.record.payload;
|
|
943
947
|
const receivingOrigin = recorded?._tag === "WorkerOriginRecorded" ? recorded.origin : void 0;
|
|
944
948
|
if (source.depth !== 0 && receivingOrigin === void 0) return yield* failure("followUp", "denied");
|
|
@@ -1029,11 +1033,6 @@ const makeWorkerRuntime = Effect.fn("WorkerHost.make")(function* (options) {
|
|
|
1029
1033
|
messageId,
|
|
1030
1034
|
reason
|
|
1031
1035
|
});
|
|
1032
|
-
const sourceBinding = deps.bindings.find((entry) => entry.agentId === origin.source.agentId && bindingSupports(entry, intent.sourceDigests));
|
|
1033
|
-
const targetBinding = deps.bindings.find((entry) => entry.agentId === origin.worker.targetAgentId && bindingSupports(entry, origin.targetDigests));
|
|
1034
|
-
const reports = sourceBinding?.reporting?.filter((entry) => entry.delegationId === origin.worker.delegationId) ?? [];
|
|
1035
|
-
const descriptor = reports[0];
|
|
1036
|
-
if (sourceBinding === void 0 || targetBinding === void 0 || descriptor === void 0 || reports.length !== 1 || !Object.is(descriptor.target, targetBinding.definition) || descriptor.mode !== "standard" && !Object.is(descriptor.input, sourceBinding.definition.input) || descriptor.mode !== intent.mode || descriptor.destination?.delegationId !== intent.destinationDelegationId || descriptor.destination !== void 0 && !Object.is(descriptor.destination.target, sourceBinding.definition)) return refused("declaration-unavailable");
|
|
1037
1036
|
const selected = yield* deps.ledger.lookup(SubmissionLookupById.make({ submissionId: host.submissionId })).pipe(Effect.mapError(storageFailure("inspect")));
|
|
1038
1037
|
if (Option.isNone(selected) || selected.value.threadId !== submission.threadId || selected.value.receiptId !== host.receiptId || selected.value.workerAdmission === void 0 || !sameOrigin(selected.value.workerAdmission.origin, origin)) return yield* failure("inspect", "corrupt");
|
|
1039
1038
|
const hostSubmission = selected.value;
|
|
@@ -1042,7 +1041,12 @@ const makeWorkerRuntime = Effect.fn("WorkerHost.make")(function* (options) {
|
|
|
1042
1041
|
const firstInput = requests(sourceHistory.records).find((row) => row.admission.messageId === origin.firstMessageId);
|
|
1043
1042
|
if (firstInput === void 0 || !sameOrigin(firstInput.admission.origin, origin)) return yield* failure("inspect", "corrupt");
|
|
1044
1043
|
const source = yield* sourceAuthority(origin.source.threadId, firstInput.admission.sourceSubmissionId);
|
|
1045
|
-
if (source.binding === void 0 || !bindingSupports(source.binding, intent.sourceDigests)) return refused("declaration-unavailable");
|
|
1044
|
+
if (source.binding === void 0 || !bindingSupports(source.binding, intent.sourceDigests, void 0, source.submission?.inputPayload)) return refused("declaration-unavailable");
|
|
1045
|
+
const sourceBinding = deps.bindings.find((entry) => entry.agentId === origin.source.agentId && bindingSupports(entry, intent.sourceDigests, void 0, source.submission?.inputPayload));
|
|
1046
|
+
const targetBinding = deps.bindings.find((entry) => entry.agentId === origin.worker.targetAgentId && bindingSupports(entry, origin.targetDigests, void 0, hostSubmission.inputPayload));
|
|
1047
|
+
const reports = sourceBinding?.reporting?.filter((entry) => entry.delegationId === origin.worker.delegationId) ?? [];
|
|
1048
|
+
const descriptor = reports[0];
|
|
1049
|
+
if (sourceBinding === void 0 || targetBinding === void 0 || descriptor === void 0 || reports.length !== 1 || !Object.is(descriptor.target, targetBinding.definition) || descriptor.mode !== "standard" && !Object.is(descriptor.input, sourceBinding.definition.input) || descriptor.mode !== intent.mode || descriptor.destination?.delegationId !== intent.destinationDelegationId || descriptor.destination !== void 0 && !Object.is(descriptor.destination.target, sourceBinding.definition)) return refused("declaration-unavailable");
|
|
1046
1050
|
const sourceOriginRecord = source.current.records.find(({ record }) => record.payload._tag === "WorkerOriginRecorded")?.record.payload;
|
|
1047
1051
|
const sourceOrigin = sourceOriginRecord?._tag === "WorkerOriginRecorded" ? sourceOriginRecord.origin : void 0;
|
|
1048
1052
|
if (source.depth !== 0 && sourceOrigin === void 0) return refused("destination");
|
|
@@ -1236,12 +1240,12 @@ const makeWorkerRuntime = Effect.fn("WorkerHost.make")(function* (options) {
|
|
|
1236
1240
|
};
|
|
1237
1241
|
});
|
|
1238
1242
|
const findOrigin = Effect.fn("WorkerHost.findOrigin")(function* (worker, target, operation) {
|
|
1239
|
-
|
|
1243
|
+
yield* binding(target, operation);
|
|
1240
1244
|
if (worker.targetAgentId !== target.id) return yield* failure(operation, "worker-mismatch");
|
|
1241
1245
|
const source = yield* read(context.source.threadId, operation);
|
|
1242
1246
|
const origin = requests(source.records).find((row) => row.admission.origin.worker.threadId === worker.threadId)?.admission.origin;
|
|
1243
1247
|
if (origin === void 0) return yield* failure(operation, "not-found");
|
|
1244
|
-
if (origin.worker.delegationId !== worker.delegationId
|
|
1248
|
+
if (origin.worker.delegationId !== worker.delegationId) return yield* failure(operation, "worker-mismatch");
|
|
1245
1249
|
return origin;
|
|
1246
1250
|
});
|
|
1247
1251
|
const receiptInput = Effect.fn("WorkerHost.receiptInput")(function* (request, operation) {
|
|
@@ -1570,12 +1574,12 @@ const makeWorkerRuntime = Effect.fn("WorkerHost.make")(function* (options) {
|
|
|
1570
1574
|
const current = yield* read(sourceThreadId, "context");
|
|
1571
1575
|
const created = current.records[0]?.record.payload;
|
|
1572
1576
|
if (created?._tag !== "ThreadCreated") return yield* failure("context", "not-found");
|
|
1573
|
-
const
|
|
1577
|
+
const selected = request.sourceSubmissionId === void 0 ? void 0 : yield* sourceAuthority(sourceThreadId, request.sourceSubmissionId);
|
|
1578
|
+
const resolved = selected === void 0 ? deps.bindings.find((entry) => entry.agentId === created.agentId && bindingSupports(entry, created.definitions, void 0, firstThreadInput(current))) : selected.binding;
|
|
1574
1579
|
if (resolved === void 0) return yield* failure("context", "declaration-unavailable");
|
|
1575
1580
|
const origin = current.records.find(({ record }) => record.payload._tag === "WorkerOriginRecorded")?.record.payload;
|
|
1576
1581
|
const attached = current.records.find(({ record }) => record.payload._tag === "SubagentLineageRecorded")?.record.payload;
|
|
1577
1582
|
const retained = origin?._tag === "WorkerOriginRecorded" ? origin.origin : attached?._tag === "SubagentLineageRecorded" ? attached : void 0;
|
|
1578
|
-
const selected = request.sourceSubmissionId === void 0 ? void 0 : yield* sourceAuthority(sourceThreadId, request.sourceSubmissionId);
|
|
1579
1583
|
return facet({
|
|
1580
1584
|
source: {
|
|
1581
1585
|
_tag: "programmatic",
|
|
@@ -5202,14 +5206,14 @@ const make = Effect.fn("DurableAgentRuntime.make")(function* (bindings) {
|
|
|
5202
5206
|
const candidates = registeredBindings.filter((binding) => binding.agentId === submission.agentId);
|
|
5203
5207
|
const candidate = candidates[0];
|
|
5204
5208
|
if (candidate === void 0 || candidates.length !== 1) return yield* resolveWorkerBinding(registeredBindings, submission.agentId, submission.agentDigests);
|
|
5205
|
-
if (bindingSupports(candidate, submission.agentDigests)) return candidate;
|
|
5209
|
+
if (bindingSupports(candidate, submission.agentDigests, void 0, submission.inputPayload)) return candidate;
|
|
5206
5210
|
const records = yield* Effect.gen(function* () {
|
|
5207
5211
|
const tail = yield* store.inspectTail(ThreadTailRequest.make({ threadId: submission.threadId }));
|
|
5208
5212
|
return yield* Stream.runCollect(canonicalRange(submission.threadId, tail.tailSequence).pipe(Stream.filter(controlRecords([submission.submissionId]))));
|
|
5209
5213
|
}).pipe(Effect.catchTag("ThreadNotMaterialized", () => Effect.succeed([])));
|
|
5210
5214
|
const completionTools = candidate === void 0 ? [] : [...candidate.definition.completion === void 0 ? [] : [candidate.definition.completion.tool], ...candidate.definition.completionFromTools?.map((entry) => entry.tool) ?? []];
|
|
5211
5215
|
const pending = yield* pendingToolBatchFor(records, runIdForSubmission(submission.submissionId), completionTools);
|
|
5212
|
-
return yield* resolveWorkerBinding(registeredBindings, submission.agentId, submission.agentDigests, pending?.calls.filter((call) => call.providerExecuted !== true || completionTools.includes(call.name)).map((call) => call.name) ?? []);
|
|
5216
|
+
return yield* resolveWorkerBinding(registeredBindings, submission.agentId, submission.agentDigests, pending?.calls.filter((call) => call.providerExecuted !== true || completionTools.includes(call.name)).map((call) => call.name) ?? [], submission.inputPayload);
|
|
5213
5217
|
});
|
|
5214
5218
|
const processThreadResolvedImpl = (threadId) => drainThread(resolveRetainedBinding, threadId);
|
|
5215
5219
|
const processThreadHeadImpl = (threadId, options) => processThreadHead(resolveRetainedBinding, threadId, options);
|
|
@@ -6381,4 +6385,4 @@ var DurableAgentRuntime = class DurableAgentRuntime extends Context.Service()("@
|
|
|
6381
6385
|
//#endregion
|
|
6382
6386
|
export { RecoveryReport as a, recoveryRepairRecordId as c, DurableRuntimeConfig as i, threadCreatedBatchId as l, DurableAgentRuntime_exports as n, childReservationIdFor as o, DurableApprovalResolver as r, recoveryRepairBatchId as s, DurableAgentRuntime as t, threadCreatedRecordId as u };
|
|
6383
6387
|
|
|
6384
|
-
//# sourceMappingURL=DurableAgentRuntime-
|
|
6388
|
+
//# sourceMappingURL=DurableAgentRuntime-DbUvZHDZ.mjs.map
|