effect-agent 0.1.0-beta.103 → 0.1.0-beta.106
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/{Agent-CM6JubNX.d.mts → Agent-Bk-mLtov.d.mts} +2 -2
- package/dist/{AgentError-CggcAQ7V.d.mts → AgentError-Bn1ytXRD.d.mts} +20 -4
- package/dist/{AgentRuntime-B1SXMVN7.d.mts → AgentRuntime-BEXToYl1.d.mts} +8 -8
- package/dist/{AgentRuntime-BWOnNc0d.mjs → AgentRuntime-e2M5UoXn.mjs} +4 -3
- package/dist/AgentRuntime-e2M5UoXn.mjs.map +1 -0
- package/dist/{DurableAgentRuntime-C9eRZS9N.mjs → DurableAgentRuntime-wd1x0TcB.mjs} +67 -36
- package/dist/DurableAgentRuntime-wd1x0TcB.mjs.map +1 -0
- package/dist/{EventSource-K7XUzurY.d.mts → EventSource-pH-v0k42.d.mts} +3 -3
- package/dist/FailureDiagnostic-BElLOoED.mjs +274 -0
- package/dist/FailureDiagnostic-BElLOoED.mjs.map +1 -0
- package/dist/FailureDiagnostic-CaAkzGHL.d.mts +223 -0
- package/dist/{Messaging-QMYhp297.d.mts → Messaging-Bl4SBKpR.d.mts} +3 -3
- package/dist/{MessagingHost-gAxs5gme.d.mts → MessagingHost-nwBMdRoh.d.mts} +3 -3
- package/dist/{Output-CjocJzsl.d.mts → Output-B6RQ5jRU.d.mts} +2 -2
- package/dist/{PreparedInputAdmission-KLk5rGFI.d.mts → PreparedInputAdmission-D3-BgmA9.d.mts} +8 -4
- package/dist/{Records-Bidb7ByL.d.mts → Records-B4S02MX1.d.mts} +201 -14
- package/dist/{RunJournal-srpbEBEy.mjs → RunJournal-BdIlgAEj.mjs} +2 -2
- package/dist/{RunJournal-srpbEBEy.mjs.map → RunJournal-BdIlgAEj.mjs.map} +1 -1
- package/dist/{RunOptions-Bruk54SE.d.mts → RunOptions-qOcPv08p.d.mts} +10 -5
- package/dist/{Schedule-Cy9up8Uf.d.mts → Schedule-D2TVEu3W.d.mts} +7 -2
- package/dist/{Scheduling-CHCsSCGo.mjs → Scheduling-DPb2QyAK.mjs} +2 -2
- package/dist/{Scheduling-CHCsSCGo.mjs.map → Scheduling-DPb2QyAK.mjs.map} +1 -1
- package/dist/{Subagent-DP0CzO16.d.mts → Subagent-BxuDuCHt.d.mts} +172 -8
- package/dist/{Subagent-C2s8PFrd.mjs → Subagent-uXWHXiKb.mjs} +64 -29
- package/dist/Subagent-uXWHXiKb.mjs.map +1 -0
- package/dist/{SubagentHost-CYcxkpRc.d.mts → SubagentHost-DEPw4YME.d.mts} +6 -3
- package/dist/{Subscription-CHyoQelH.d.mts → Subscription-nX0rz4GQ.d.mts} +3 -3
- package/dist/{SubscriptionInput-DqrHW-Ja.d.mts → SubscriptionInput-CAG3_pyJ.d.mts} +3 -3
- package/dist/{Worker--j87JI__.d.mts → Worker-Bbj9uq5H.d.mts} +5 -2
- package/dist/{agent-registration-ByeHejH3.mjs → agent-registration-B5CI-Ygk.mjs} +7 -5
- package/dist/agent-registration-B5CI-Ygk.mjs.map +1 -0
- package/dist/capabilities/Commands.d.mts +1 -1
- package/dist/capabilities/Messaging.d.mts +2 -2
- package/dist/capabilities/RunHooks.d.mts +1 -1
- package/dist/capabilities/Subagent.d.mts +2 -2
- package/dist/capabilities/Subagent.mjs +1 -1
- package/dist/core/Agent.d.mts +1 -1
- package/dist/core/AgentError.d.mts +2 -2
- package/dist/core/AgentError.mjs +19 -2
- package/dist/core/AgentError.mjs.map +1 -1
- package/dist/core/FailureDiagnostic.d.mts +2 -0
- package/dist/core/FailureDiagnostic.mjs +2 -0
- package/dist/core/Worker.d.mts +1 -1
- package/dist/core/Worker.mjs +4 -1
- package/dist/core/Worker.mjs.map +1 -1
- 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 +1 -1
- package/dist/durable/AgentRegistration.mjs +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 +7 -7
- package/dist/durable/Digest.mjs.map +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 +15 -3
- package/dist/durable/MessageDelivery.mjs +44 -24
- package/dist/durable/MessageDelivery.mjs.map +1 -1
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +4 -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/PreparedInputAdmission.mjs +8 -4
- package/dist/durable/PreparedInputAdmission.mjs.map +1 -1
- package/dist/durable/Records.d.mts +1 -1
- package/dist/durable/Records.mjs +831 -2
- package/dist/durable/Records.mjs.map +1 -0
- 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 +12 -3
- package/dist/durable/Schedule.mjs.map +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/SqlMessageDeliveryStore.mjs +13 -11
- package/dist/durable/SqlMessageDeliveryStore.mjs.map +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/SqlThreadNativeReads.d.mts +1 -1
- package/dist/durable/SqlThreadNativeReads.mjs +2 -2
- package/dist/durable/SubmissionLedger.d.mts +1 -1
- package/dist/durable/SubmissionLedger.mjs +6 -3
- package/dist/durable/SubmissionLedger.mjs.map +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 +2 -2
- 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 +2 -2
- 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 +3 -3
- package/dist/engine/AgentRuntime.d.mts +1 -1
- package/dist/engine/AgentRuntime.mjs +1 -1
- package/dist/engine/MessagingHost.d.mts +1 -1
- package/dist/engine/Output.d.mts +1 -1
- package/dist/engine/RunOptions.d.mts +1 -1
- package/dist/engine/RunOptions.mjs +2 -0
- package/dist/engine/RunOptions.mjs.map +1 -1
- package/dist/engine/SubagentHost.d.mts +1 -1
- package/dist/engine/SubagentHost.mjs.map +1 -1
- package/dist/index.d.mts +18 -17
- package/dist/index.mjs +8 -7
- package/package.json +1 -1
- package/src/capabilities/internal/subagent-background.ts +66 -23
- package/src/capabilities/internal/subagent-contract.ts +4 -0
- package/src/core/AgentError.ts +20 -0
- package/src/core/FailureDiagnostic.ts +343 -0
- package/src/core/Worker.ts +4 -1
- package/src/durable/Digest.ts +22 -28
- package/src/durable/DurableAgentRuntime.ts +37 -13
- package/src/durable/MessageDelivery.ts +82 -24
- package/src/durable/PreparedInputAdmission.ts +17 -4
- package/src/durable/Records.ts +5 -15
- package/src/durable/Schedule.ts +11 -2
- package/src/durable/SqlMessageDeliveryStore.ts +21 -9
- package/src/durable/SubmissionLedger.ts +4 -1
- package/src/durable/internal/agent-registration.ts +46 -14
- package/src/durable/internal/worker-host.ts +32 -19
- package/src/engine/RunOptions.ts +11 -3
- package/src/engine/SubagentHost.ts +3 -0
- package/src/engine/internal/agent-runtime.ts +23 -16
- package/src/index.ts +1 -0
- package/dist/AgentRuntime-BWOnNc0d.mjs.map +0 -1
- package/dist/DurableAgentRuntime-C9eRZS9N.mjs.map +0 -1
- package/dist/Records-D8167fHn.mjs +0 -844
- package/dist/Records-D8167fHn.mjs.map +0 -1
- package/dist/Subagent-C2s8PFrd.mjs.map +0 -1
- package/dist/agent-registration-ByeHejH3.mjs.map +0 -1
|
@@ -3,12 +3,13 @@ import { AgentId, DelegationId, RunId, SettlementId, ThreadId, ToolCallId } from
|
|
|
3
3
|
import { n as utf8ByteLength } from "./utf8-DchGZRBd.mjs";
|
|
4
4
|
import { AgentPolicy } from "./core/AgentPolicy.mjs";
|
|
5
5
|
import { IdempotencyKey, JoinedToHost, Receipt } from "./core/Receipt.mjs";
|
|
6
|
+
import { i as Failure, o as Value } from "./FailureDiagnostic-BElLOoED.mjs";
|
|
6
7
|
import { IdGenerator as IdGenerator$1 } from "./core/IdGenerator.mjs";
|
|
7
8
|
import { BackgroundSpawnTool, DelegationTool, SubagentBudgetReservation, SubagentDelegationCaps, SubagentExecutionFailure, SubagentExecutionFailureClassification, SubagentGrant, SubagentReservationAmounts, WorkerOperationTool, narrowSubagentGrant } from "./core/SubagentContract.mjs";
|
|
8
9
|
import { RunUsageReport, unknownRunTotals } from "./core/Usage.mjs";
|
|
9
10
|
import { WorkerCompletion, WorkerContext, WorkerError, WorkerPage, WorkerRef, WorkerReport, WorkerStarted, WorkerSummary } from "./core/Worker.mjs";
|
|
10
11
|
import { BackgroundReporting, SubagentHost, WorkerReportPreparationFailure } from "./engine/SubagentHost.mjs";
|
|
11
|
-
import { a as SubagentDurability, i as AgentSpawner, o as SubagentDurabilityError, s as ToolCallWaiting } from "./AgentRuntime-
|
|
12
|
+
import { a as SubagentDurability, i as AgentSpawner, o as SubagentDurabilityError, s as ToolCallWaiting } from "./AgentRuntime-e2M5UoXn.mjs";
|
|
12
13
|
import { RunEventSink } from "./engine/RunEventSink.mjs";
|
|
13
14
|
import { SubagentBudgetExhausted, SubagentObservedUsage, SubagentReservationRequest, SubagentReservations, makeBudgetReservationId } from "./capabilities/SubagentReservations.mjs";
|
|
14
15
|
import { t as utf8Bytes } from "./utf8-BYfhEkcj.mjs";
|
|
@@ -75,7 +76,10 @@ var SubagentPrestartDenied = class extends Schema.TaggedError()("SubagentPrestar
|
|
|
75
76
|
var SubagentProjectionFailure = class extends Schema.TaggedError()("SubagentProjectionFailure", {
|
|
76
77
|
delegationId: DelegationId,
|
|
77
78
|
stage: Schema.Literals(["input", "result"]),
|
|
78
|
-
message: BoundedFailureText
|
|
79
|
+
message: BoundedFailureText,
|
|
80
|
+
/** Original validation error; detailed diagnostics are never part of the safe message. */
|
|
81
|
+
cause: Schema.optionalKey(Value),
|
|
82
|
+
stack: Schema.optionalKey(Schema.String)
|
|
79
83
|
}) {};
|
|
80
84
|
const millisOfMaxDuration = (policy) => Math.max(1, Math.ceil(Duration.toMillis(policy.maxDuration)));
|
|
81
85
|
/**
|
|
@@ -308,8 +312,8 @@ const reportingToWorker = (report, destination) => {
|
|
|
308
312
|
//#region src/capabilities/internal/subagent-background.ts
|
|
309
313
|
/** Portable identity checked against this declaration; possession grants no authority. */
|
|
310
314
|
const Worker = (declaration) => WorkerRef.check(Schema.makeFilter((worker) => worker.delegationId === declaration.delegationId && worker.targetAgentId === declaration.target.id)).pipe(Schema.brand(`@effect-agent/Worker/${declaration.name}`));
|
|
311
|
-
/**
|
|
312
|
-
const
|
|
315
|
+
/** Model-facing projection deliberately excludes operator-private diagnostics. */
|
|
316
|
+
const toolObservation = (success) => Schema.Union([
|
|
313
317
|
Schema.Struct({
|
|
314
318
|
_tag: Schema.Literal("Pending"),
|
|
315
319
|
receipt: Receipt
|
|
@@ -331,6 +335,18 @@ const WorkerObservation = (success) => Schema.Union([
|
|
|
331
335
|
failure: SubagentExecutionFailure
|
|
332
336
|
})
|
|
333
337
|
]);
|
|
338
|
+
/** One exact Receipt, including private canonical failure evidence for programmatic callers. */
|
|
339
|
+
const WorkerObservation = (success) => {
|
|
340
|
+
const projected = toolObservation(success);
|
|
341
|
+
return Schema.Union([
|
|
342
|
+
projected.members[0],
|
|
343
|
+
projected.members[1],
|
|
344
|
+
Schema.Struct({
|
|
345
|
+
...projected.members[2].fields,
|
|
346
|
+
diagnostic: Schema.optionalKey(Failure)
|
|
347
|
+
})
|
|
348
|
+
]);
|
|
349
|
+
};
|
|
334
350
|
const host = Effect.serviceOption(SubagentHost).pipe(Effect.flatMap((service) => Option.match(service, {
|
|
335
351
|
onNone: () => WorkerError.make({
|
|
336
352
|
operation: "context",
|
|
@@ -341,25 +357,29 @@ const host = Effect.serviceOption(SubagentHost).pipe(Effect.flatMap((service) =>
|
|
|
341
357
|
const receiptEqual = (left, right) => left.threadId === right.threadId && left.submissionId === right.submissionId && left.receiptId === right.receiptId && left.queueSequence === right.queueSequence;
|
|
342
358
|
const operations = (declaration) => {
|
|
343
359
|
const workerSchema = Worker(declaration);
|
|
344
|
-
const projectionFailure = (stage) => SubagentProjectionFailure.make({
|
|
360
|
+
const projectionFailure = (stage, cause) => SubagentProjectionFailure.make({
|
|
345
361
|
delegationId: declaration.delegationId,
|
|
346
362
|
stage,
|
|
363
|
+
...cause === void 0 ? {} : { cause },
|
|
347
364
|
message: stage === "input" ? "Worker input did not satisfy the declaration Schema" : "Worker result did not satisfy the declaration Schema"
|
|
348
365
|
});
|
|
349
|
-
const validateWorker = (worker, operation) => Schema.decodeUnknownEffect(workerSchema)(worker).pipe(Effect.mapError(() => WorkerError.make({
|
|
366
|
+
const validateWorker = (worker, operation) => Schema.decodeUnknownEffect(workerSchema)(worker).pipe(Effect.mapError((cause) => WorkerError.make({
|
|
350
367
|
operation,
|
|
351
|
-
reason: "worker-mismatch"
|
|
368
|
+
reason: "worker-mismatch",
|
|
369
|
+
cause
|
|
352
370
|
})));
|
|
353
|
-
const validateReceipt = (worker, receipt, operation) => Schema.decodeEffect(Receipt.check(Schema.makeFilter((value) => value.threadId === worker.threadId)))(receipt).pipe(Effect.mapError(() => WorkerError.make({
|
|
371
|
+
const validateReceipt = (worker, receipt, operation) => Schema.decodeEffect(Receipt.check(Schema.makeFilter((value) => value.threadId === worker.threadId)))(receipt).pipe(Effect.mapError((cause) => WorkerError.make({
|
|
354
372
|
operation,
|
|
355
|
-
reason: "receipt-mismatch"
|
|
373
|
+
reason: "receipt-mismatch",
|
|
374
|
+
cause
|
|
356
375
|
})));
|
|
357
376
|
const context = host.pipe(Effect.flatMap((service) => service.context), Effect.flatMap(Schema.decodeUnknownEffect(Schema.toType(WorkerContext))), Effect.mapError((error) => Schema.is(WorkerError)(error) ? error : WorkerError.make({
|
|
358
377
|
operation: "context",
|
|
359
|
-
reason: "corrupt"
|
|
378
|
+
reason: "corrupt",
|
|
379
|
+
cause: error
|
|
360
380
|
})));
|
|
361
381
|
const prepare = Effect.fn("Subagent.prepareWorkerInput")(function* (parameters, caller) {
|
|
362
|
-
const encodedParameters = yield* Schema.encodeEffect(declaration.parameters)(parameters).pipe(Effect.mapError(() => projectionFailure("input")));
|
|
382
|
+
const encodedParameters = yield* Schema.encodeEffect(declaration.parameters)(parameters).pipe(Effect.mapError((cause) => projectionFailure("input", cause)));
|
|
363
383
|
const source = caller.source;
|
|
364
384
|
const preparation = source._tag === "tool" ? {
|
|
365
385
|
source: "tool",
|
|
@@ -381,12 +401,13 @@ const operations = (declaration) => {
|
|
|
381
401
|
const input = yield* declaration.prepareInput(parameters, preparation);
|
|
382
402
|
return {
|
|
383
403
|
encodedParameters,
|
|
384
|
-
encodedInput: yield* Schema.encodeEffect(declaration.target.input)(input).pipe(Effect.mapError(() => projectionFailure("input")))
|
|
404
|
+
encodedInput: yield* Schema.encodeEffect(declaration.target.input)(input).pipe(Effect.mapError((cause) => projectionFailure("input", cause)))
|
|
385
405
|
};
|
|
386
406
|
});
|
|
387
|
-
const validateKey = (key, operation) => Schema.decodeEffect(IdempotencyKey)(key).pipe(Effect.mapError(() => WorkerError.make({
|
|
407
|
+
const validateKey = (key, operation) => Schema.decodeEffect(IdempotencyKey)(key).pipe(Effect.mapError((cause) => WorkerError.make({
|
|
388
408
|
operation,
|
|
389
|
-
reason: "idempotency-conflict"
|
|
409
|
+
reason: "idempotency-conflict",
|
|
410
|
+
cause
|
|
390
411
|
})));
|
|
391
412
|
return {
|
|
392
413
|
start: Effect.fn("Subagent.start")(function* (parameters, options) {
|
|
@@ -413,7 +434,7 @@ const operations = (declaration) => {
|
|
|
413
434
|
});
|
|
414
435
|
const resolvedTarget = Option.getOrUndefined(effectiveTarget);
|
|
415
436
|
const resolved = resolveSubagentPolicy(declaration, options.budgetScope === "worker-run" ? resolvedTarget ?? declaration.target.policy : caller.policy, void 0, options.budgetScope === "worker-run" ? "root-attached" : "conserved", resolvedTarget);
|
|
416
|
-
const encodedGrant = yield* Schema.encodeEffect(SubagentGrant)(grant).pipe(Effect.mapError(() => projectionFailure("input")));
|
|
437
|
+
const encodedGrant = yield* Schema.encodeEffect(SubagentGrant)(grant).pipe(Effect.mapError((cause) => projectionFailure("input", cause)));
|
|
417
438
|
const started = yield* service.start({
|
|
418
439
|
...prepared,
|
|
419
440
|
delegationId: declaration.delegationId,
|
|
@@ -429,9 +450,10 @@ const operations = (declaration) => {
|
|
|
429
450
|
}),
|
|
430
451
|
toolCallAllowance: resolveToolCallAllowance(declaration.toolCallAllowance, parameters, resolved.policy, resolved.childPolicy)
|
|
431
452
|
});
|
|
432
|
-
const validated = yield* Schema.decodeEffect(WorkerStarted)(started).pipe(Effect.mapError(() => WorkerError.make({
|
|
453
|
+
const validated = yield* Schema.decodeEffect(WorkerStarted)(started).pipe(Effect.mapError((cause) => WorkerError.make({
|
|
433
454
|
operation: "start",
|
|
434
|
-
reason: "corrupt"
|
|
455
|
+
reason: "corrupt",
|
|
456
|
+
cause
|
|
435
457
|
})));
|
|
436
458
|
return {
|
|
437
459
|
worker: yield* validateWorker(validated.worker, "start"),
|
|
@@ -478,18 +500,25 @@ const operations = (declaration) => {
|
|
|
478
500
|
const base = {
|
|
479
501
|
_tag: "Settled",
|
|
480
502
|
receipt: returned,
|
|
481
|
-
...observed.runId === void 0 ? {} : { runId: yield* Schema.decodeEffect(RunId)(observed.runId).pipe(Effect.mapError(() => WorkerError.make({
|
|
503
|
+
...observed.runId === void 0 ? {} : { runId: yield* Schema.decodeEffect(RunId)(observed.runId).pipe(Effect.mapError((cause) => WorkerError.make({
|
|
482
504
|
operation,
|
|
483
|
-
reason: "corrupt"
|
|
505
|
+
reason: "corrupt",
|
|
506
|
+
cause
|
|
484
507
|
}))) },
|
|
485
|
-
settlementId: yield* Schema.decodeEffect(SettlementId)(observed.settlementId).pipe(Effect.mapError(() => WorkerError.make({
|
|
508
|
+
settlementId: yield* Schema.decodeEffect(SettlementId)(observed.settlementId).pipe(Effect.mapError((cause) => WorkerError.make({
|
|
486
509
|
operation,
|
|
487
|
-
reason: "corrupt"
|
|
510
|
+
reason: "corrupt",
|
|
511
|
+
cause
|
|
488
512
|
})))
|
|
489
513
|
};
|
|
490
514
|
if (observed.outcome === "failed" || observed.outcome === "aborted") return {
|
|
491
515
|
...base,
|
|
492
516
|
outcome: observed.outcome,
|
|
517
|
+
...observed.diagnostic === void 0 ? {} : { diagnostic: yield* Schema.decodeEffect(Failure)(observed.diagnostic).pipe(Effect.mapError((cause) => WorkerError.make({
|
|
518
|
+
operation,
|
|
519
|
+
reason: "corrupt",
|
|
520
|
+
cause
|
|
521
|
+
}))) },
|
|
493
522
|
failure: SubagentExecutionFailure.make({
|
|
494
523
|
delegationId: declaration.delegationId,
|
|
495
524
|
targetAgentId: declaration.target.id,
|
|
@@ -505,18 +534,18 @@ const operations = (declaration) => {
|
|
|
505
534
|
operation,
|
|
506
535
|
reason: "corrupt"
|
|
507
536
|
});
|
|
508
|
-
const parameters = yield* Schema.decodeUnknownEffect(declaration.parameters)(observed.encodedParameters).pipe(Effect.mapError(() => projectionFailure("result")));
|
|
509
|
-
const output = yield* Schema.decodeUnknownEffect(declaration.target.output)(observed.encodedResult).pipe(Effect.mapError(() => projectionFailure("result")));
|
|
537
|
+
const parameters = yield* Schema.decodeUnknownEffect(declaration.parameters)(observed.encodedParameters).pipe(Effect.mapError((cause) => projectionFailure("result", cause)));
|
|
538
|
+
const output = yield* Schema.decodeUnknownEffect(declaration.target.output)(observed.encodedResult).pipe(Effect.mapError((cause) => projectionFailure("result", cause)));
|
|
510
539
|
const result = yield* declaration.projectResult(output, { budgetExhausted: observed.budgetExhausted }, parameters);
|
|
511
|
-
const encoded = yield* Schema.encodeEffect(declaration.success)(result).pipe(Effect.mapError(() => projectionFailure("result")));
|
|
512
|
-
const json = yield* Schema.decodeUnknownEffect(Schema.Json)(encoded).pipe(Effect.mapError(() => projectionFailure("result")));
|
|
540
|
+
const encoded = yield* Schema.encodeEffect(declaration.success)(result).pipe(Effect.mapError((cause) => projectionFailure("result", cause)));
|
|
541
|
+
const json = yield* Schema.decodeUnknownEffect(Schema.Json)(encoded).pipe(Effect.mapError((cause) => projectionFailure("result", cause)));
|
|
513
542
|
const caller = yield* context;
|
|
514
543
|
if (utf8ByteLength(JSON.stringify(json)) > (declaration.policy?.maxResultBytes ?? caller.policy.toolResultBounds.maxBytes)) return yield* projectionFailure("result");
|
|
515
544
|
return yield* Schema.decodeUnknownEffect(Schema.toType(WorkerObservation(declaration.success)))({
|
|
516
545
|
...base,
|
|
517
546
|
outcome: "completed",
|
|
518
547
|
result
|
|
519
|
-
}).pipe(Effect.mapError(() => projectionFailure("result")));
|
|
548
|
+
}).pipe(Effect.mapError((cause) => projectionFailure("result", cause)));
|
|
520
549
|
}),
|
|
521
550
|
list: Effect.fn("Subagent.list")(function* (options = {}) {
|
|
522
551
|
const service = yield* host;
|
|
@@ -726,7 +755,7 @@ const background$1 = (declaration, selected) => {
|
|
|
726
755
|
const inspectTool = Tool.make(`${declaration.name}_inspect`, {
|
|
727
756
|
description: `Inspect one exact ${declaration.name} Receipt without waiting.`,
|
|
728
757
|
parameters: receiptParameters,
|
|
729
|
-
success:
|
|
758
|
+
success: toolObservation(declaration.success),
|
|
730
759
|
failure
|
|
731
760
|
}).annotate(WorkerOperationTool, true).addDependency(SubagentHost);
|
|
732
761
|
const summaryTool = Tool.make(`${declaration.name}_summary`, {
|
|
@@ -774,7 +803,13 @@ const background$1 = (declaration, selected) => {
|
|
|
774
803
|
}),
|
|
775
804
|
[inspectTool.name]: (parameters) => Effect.gen(function* () {
|
|
776
805
|
const service = yield* host;
|
|
777
|
-
return yield* ops.observe("inspect", parameters.worker, parameters.receipt).pipe(Effect.
|
|
806
|
+
return yield* ops.observe("inspect", parameters.worker, parameters.receipt).pipe(Effect.map((observed) => {
|
|
807
|
+
if ("diagnostic" in observed) {
|
|
808
|
+
const { diagnostic: _diagnostic, ...projected } = observed;
|
|
809
|
+
return projected;
|
|
810
|
+
}
|
|
811
|
+
return observed;
|
|
812
|
+
}), Effect.provideService(SubagentHost, service), Effect.provide(captured));
|
|
778
813
|
}),
|
|
779
814
|
[listTool.name]: (parameters) => ops.list(parameters),
|
|
780
815
|
[summaryTool.name]: (parameters) => summary(declaration, parameters.worker),
|
|
@@ -1466,4 +1501,4 @@ function background(targetOrDeclaration, selected) {
|
|
|
1466
1501
|
//#endregion
|
|
1467
1502
|
export { delegationCapsFromPolicy as C, delegationAllocationFromPolicy as S, reporting as _, define as a, SubagentPrestartDenied as b, Worker as c, cancel as d, followUp as f, start as g, observe as h, background as i, WorkerObservation as l, list as m, SubagentResult as n, layer as o, inspect as p, Subagent_exports as r, make as s, SubagentDurableAccounting as t, awaitWorker as u, reportingToWorker as v, SubagentProjectionFailure as x, SubagentPolicy as y };
|
|
1468
1503
|
|
|
1469
|
-
//# sourceMappingURL=Subagent-
|
|
1504
|
+
//# sourceMappingURL=Subagent-uXWHXiKb.mjs.map
|