@effect-agent/workflow 0.1.0-beta.85 → 0.1.0-beta.87
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/AgentWorkflow.d.mts +7 -7
- package/dist/AgentWorkflow.mjs +8 -8
- package/dist/AgentWorkflow.mjs.map +1 -1
- package/dist/{WorkflowAgentHost-BwqWlnqZ.mjs → WorkflowAgentHost-C5Ncprj1.mjs} +8 -8
- package/dist/WorkflowAgentHost-C5Ncprj1.mjs.map +1 -0
- package/dist/WorkflowAgentHost.d.mts +4 -4
- package/dist/WorkflowAgentHost.mjs +1 -1
- package/dist/WorkflowDispatch.d.mts +1 -1
- package/dist/WorkflowDispatch.mjs +3 -3
- package/dist/WorkflowDispatch.mjs.map +1 -1
- package/dist/WorkflowExecution.d.mts +2 -2
- package/dist/WorkflowExecution.mjs +2 -2
- package/dist/WorkflowExecution.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/AgentWorkflow.ts +8 -8
- package/src/WorkflowAgentHost.ts +20 -20
- package/src/WorkflowDispatch.ts +3 -3
- package/src/WorkflowExecution.ts +3 -3
- package/dist/WorkflowAgentHost-BwqWlnqZ.mjs.map +0 -1
package/dist/AgentWorkflow.d.mts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { WorkflowDispatchError } from "./WorkflowDispatch.mjs";
|
|
2
2
|
import { WorkflowAgent, WorkflowExecuteOptions, WorkflowExecutionFailure } from "./WorkflowExecution.mjs";
|
|
3
3
|
import { WorkflowAdmissionClosed, WorkflowAgentHost } from "./WorkflowAgentHost.mjs";
|
|
4
|
-
import { AgentInputError, AgentOutputError } from "@effect-agent/core/AgentError";
|
|
5
|
-
import { BindingUnavailable } from "@effect-agent/thread/AgentRegistration";
|
|
6
|
-
import { DigestError } from "@effect-agent/thread/Digest";
|
|
7
|
-
import { DurableRuntimeFailpointError } from "@effect-agent/thread/DurableFailpoint";
|
|
8
|
-
import { OperationDenied } from "@effect-agent/thread/OperationAuthorizer";
|
|
9
|
-
import { AdmissionConflict, AdmissionPolicyError, LedgerError, SettlementConflict } from "@effect-agent/thread/SubmissionLedger";
|
|
10
|
-
import { AppendConflict, FenceRejected, ThreadNotMaterialized, ThreadStoreError } from "@effect-agent/thread/ThreadStore";
|
|
11
4
|
import { Effect, Schema } from "effect";
|
|
5
|
+
import { AgentInputError, AgentOutputError } from "effect-agent/agent-error";
|
|
6
|
+
import { BindingUnavailable } from "effect-agent/agent-registration";
|
|
7
|
+
import { DigestError } from "effect-agent/digest";
|
|
8
|
+
import { DurableRuntimeFailpointError } from "effect-agent/durable-failpoint";
|
|
9
|
+
import { OperationDenied } from "effect-agent/operation-authorizer";
|
|
10
|
+
import { AdmissionConflict, AdmissionPolicyError, LedgerError, SettlementConflict } from "effect-agent/submission-ledger";
|
|
11
|
+
import { AppendConflict, FenceRejected, ThreadNotMaterialized, ThreadStoreError } from "effect-agent/thread-store";
|
|
12
12
|
declare namespace AgentWorkflow_d_exports {
|
|
13
13
|
export { Error, execute };
|
|
14
14
|
}
|
package/dist/AgentWorkflow.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
2
|
import { WorkflowDispatchError } from "./WorkflowDispatch.mjs";
|
|
3
|
-
import { n as WorkflowAgentHost, t as WorkflowAdmissionClosed } from "./WorkflowAgentHost-
|
|
3
|
+
import { n as WorkflowAgentHost, t as WorkflowAdmissionClosed } from "./WorkflowAgentHost-C5Ncprj1.mjs";
|
|
4
4
|
import { WorkflowExecutionFailure } from "./WorkflowExecution.mjs";
|
|
5
|
-
import { AgentInputError, AgentOutputError } from "@effect-agent/core/AgentError";
|
|
6
|
-
import { BindingUnavailable } from "@effect-agent/thread/AgentRegistration";
|
|
7
|
-
import { DigestError } from "@effect-agent/thread/Digest";
|
|
8
|
-
import { DurableRuntimeFailpointError } from "@effect-agent/thread/DurableFailpoint";
|
|
9
|
-
import { OperationDenied } from "@effect-agent/thread/OperationAuthorizer";
|
|
10
|
-
import { AdmissionConflict, AdmissionPolicyError, LedgerError, SettlementConflict } from "@effect-agent/thread/SubmissionLedger";
|
|
11
|
-
import { AppendConflict, FenceRejected, ThreadNotMaterialized, ThreadStoreError } from "@effect-agent/thread/ThreadStore";
|
|
12
5
|
import { Effect, Schema } from "effect";
|
|
6
|
+
import { AgentInputError, AgentOutputError } from "effect-agent/agent-error";
|
|
7
|
+
import { BindingUnavailable } from "effect-agent/agent-registration";
|
|
8
|
+
import { DigestError } from "effect-agent/digest";
|
|
9
|
+
import { DurableRuntimeFailpointError } from "effect-agent/durable-failpoint";
|
|
10
|
+
import { OperationDenied } from "effect-agent/operation-authorizer";
|
|
11
|
+
import { AdmissionConflict, AdmissionPolicyError, LedgerError, SettlementConflict } from "effect-agent/submission-ledger";
|
|
12
|
+
import { AppendConflict, FenceRejected, ThreadNotMaterialized, ThreadStoreError } from "effect-agent/thread-store";
|
|
13
13
|
//#region src/AgentWorkflow.ts
|
|
14
14
|
var AgentWorkflow_exports = /* @__PURE__ */ __exportAll({
|
|
15
15
|
Error: () => Error,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentWorkflow.mjs","names":[],"sources":["../src/AgentWorkflow.ts"],"sourcesContent":["import { AgentInputError, AgentOutputError } from \"
|
|
1
|
+
{"version":3,"file":"AgentWorkflow.mjs","names":[],"sources":["../src/AgentWorkflow.ts"],"sourcesContent":["import { Effect, Schema } from \"effect\";\nimport { AgentInputError, AgentOutputError } from \"effect-agent/agent-error\";\nimport { BindingUnavailable } from \"effect-agent/agent-registration\";\nimport { DigestError } from \"effect-agent/digest\";\nimport { DurableRuntimeFailpointError } from \"effect-agent/durable-failpoint\";\nimport { OperationDenied } from \"effect-agent/operation-authorizer\";\nimport {\n AdmissionConflict,\n AdmissionPolicyError,\n LedgerError,\n SettlementConflict,\n} from \"effect-agent/submission-ledger\";\nimport {\n AppendConflict,\n FenceRejected,\n ThreadNotMaterialized,\n ThreadStoreError,\n} from \"effect-agent/thread-store\";\n\nimport { WorkflowAdmissionClosed, WorkflowAgentHost } from \"./WorkflowAgentHost.ts\";\nimport { WorkflowDispatchError } from \"./WorkflowDispatch.ts\";\nimport {\n WorkflowExecutionFailure,\n type WorkflowAgent,\n type WorkflowExecuteOptions,\n} from \"./WorkflowExecution.ts\";\n\n/** Schema for the exact typed failure channel of execute, suitable for Workflow.make({ error }). */\nexport const Error = Schema.Union([\n AgentInputError,\n AgentOutputError,\n AdmissionConflict,\n AdmissionPolicyError,\n AppendConflict,\n BindingUnavailable,\n DigestError,\n DurableRuntimeFailpointError,\n FenceRejected,\n LedgerError,\n OperationDenied,\n SettlementConflict,\n ThreadNotMaterialized,\n ThreadStoreError,\n WorkflowDispatchError,\n WorkflowAdmissionClosed,\n WorkflowExecutionFailure,\n]);\n\nexport type Error = typeof Error.Type;\n\n/**\n * Run a registered agent inside a native Workflow.toLayer handler. One stable name identifies\n * one submission in that parent execution. Replays verify admission identity and decode the\n * canonical output again. Pending work suspends through Effect DurableDeferred; neither\n * suspension nor parent interruption aborts accepted agent work. Use the host's authorized abort.\n * Provide WorkflowAgentHost at the application boundary, sharing the parent's WorkflowEngine.\n * Pass the exact Agent Definition instance used in runtime registration; a same-ID copy fails\n * with BindingUnavailable before input encoding or admission.\n */\nexport const execute = Effect.fn(\"AgentWorkflow.execute\")(function* <\n Input extends Schema.Top,\n Output extends Schema.Top,\n>(agent: WorkflowAgent<Input, Output>, input: Input[\"Type\"], options: WorkflowExecuteOptions) {\n const host = yield* WorkflowAgentHost;\n\n return yield* host.execute(agent, input, options);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,MAAa,QAAQ,OAAO,MAAM;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;;;;;;AAaD,MAAa,UAAU,OAAO,GAAG,uBAAuB,CAAC,CAAC,WAGxD,OAAqC,OAAsB,SAAiC;CAG5F,OAAO,QAAO,OAFM,kBAAA,CAED,QAAQ,OAAO,OAAO,OAAO;AAClD,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
2
|
import { WorkflowDispatchError, WorkflowDispatchFailpoint, WorkflowDispatchIntent, WorkflowDispatchScan, WorkflowDispatchStore, WorkflowRepairReport, WorkflowRepairTrigger, WorkflowSettlementReference, WorkflowSubmission } from "./WorkflowDispatch.mjs";
|
|
3
3
|
import { WorkflowExecutionFailure } from "./WorkflowExecution.mjs";
|
|
4
|
-
import { AgentOutputError } from "@effect-agent/core/AgentError";
|
|
5
|
-
import "@effect-agent/thread/AgentRegistration";
|
|
6
|
-
import { digestJson } from "@effect-agent/thread/Digest";
|
|
7
|
-
import { IdempotencyKey, Principal, SubmissionLedger, SubmissionLookupById } from "@effect-agent/thread/SubmissionLedger";
|
|
8
4
|
import { Cause, Context, Crypto, Effect, Exit, Layer, Option, RcMap, Ref, Result, Schema, Semaphore, Stream } from "effect";
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
5
|
+
import { AgentOutputError } from "effect-agent/agent-error";
|
|
6
|
+
import "effect-agent/agent-registration";
|
|
7
|
+
import { digestJson } from "effect-agent/digest";
|
|
8
|
+
import { IdempotencyKey, Principal, SubmissionLedger, SubmissionLookupById } from "effect-agent/submission-ledger";
|
|
9
|
+
import { DurableAgentRuntime, DurableRuntimeConfig, Receipt } from "effect-agent/durable-agent-runtime";
|
|
10
|
+
import { ThreadId } from "effect-agent/identifiers";
|
|
11
|
+
import { DeploymentId } from "effect-agent/records";
|
|
12
12
|
import { DurableDeferred, Workflow, WorkflowEngine } from "effect/unstable/workflow";
|
|
13
13
|
//#region src/internal/completion.ts
|
|
14
14
|
/** Native deferred results contain only canonical identities, never a second agent result. */
|
|
@@ -295,4 +295,4 @@ var WorkflowAgentHost = class WorkflowAgentHost extends Context.Service()("@effe
|
|
|
295
295
|
//#endregion
|
|
296
296
|
export { WorkflowHostConfigError as i, WorkflowAgentHost as n, WorkflowAgentHost_exports as r, WorkflowAdmissionClosed as t };
|
|
297
297
|
|
|
298
|
-
//# sourceMappingURL=WorkflowAgentHost-
|
|
298
|
+
//# sourceMappingURL=WorkflowAgentHost-C5Ncprj1.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkflowAgentHost-C5Ncprj1.mjs","names":[],"sources":["../src/internal/completion.ts","../src/WorkflowAgentHost.ts"],"sourcesContent":["import { DurableDeferred } from \"effect/unstable/workflow\";\n\nimport { WorkflowSettlementReference } from \"../WorkflowDispatch.ts\";\n\n/** Native deferred results contain only canonical identities, never a second agent result. */\nexport const workflowCompletion = (name: string) =>\n DurableDeferred.make(name, { success: WorkflowSettlementReference });\n","import {\n Cause,\n Context,\n Crypto,\n Effect,\n Exit,\n Layer,\n Option,\n RcMap,\n Ref,\n Result,\n Schema,\n Semaphore,\n Stream,\n} from \"effect\";\nimport { AgentOutputError } from \"effect-agent/agent-error\";\nimport { type BindingUnavailable } from \"effect-agent/agent-registration\";\nimport { digestJson } from \"effect-agent/digest\";\nimport {\n DurableAgentRuntime,\n DurableRuntimeConfig,\n Receipt,\n type DurableAwaitFailure,\n type DurableSubmitAgent,\n type DurableSubmitFailure,\n type DurableSubmitOptions,\n} from \"effect-agent/durable-agent-runtime\";\nimport { ThreadId } from \"effect-agent/identifiers\";\nimport { DeploymentId } from \"effect-agent/records\";\nimport {\n IdempotencyKey,\n Principal,\n SubmissionLedger,\n SubmissionLookupById,\n} from \"effect-agent/submission-ledger\";\nimport { DurableDeferred, Workflow, WorkflowEngine } from \"effect/unstable/workflow\";\n\nimport { workflowCompletion } from \"./internal/completion.ts\";\nimport {\n WorkflowDispatchError,\n WorkflowDispatchFailpoint,\n WorkflowDispatchIntent,\n WorkflowDispatchScan,\n WorkflowDispatchStore,\n WorkflowRepairReport,\n WorkflowRepairTrigger,\n WorkflowSettlementReference,\n WorkflowSubmission,\n} from \"./WorkflowDispatch.ts\";\nimport {\n WorkflowExecutionFailure,\n type WorkflowAgent,\n type WorkflowExecuteOptions,\n} from \"./WorkflowExecution.ts\";\n\nconst WorkflowHostConfig = Schema.Struct({\n deploymentId: DeploymentId,\n principal: Principal,\n workflowName: Schema.NonEmptyString,\n executionConcurrency: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 64 })),\n repairBatchSize: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 1000 })),\n dispatchTimeoutMillis: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 300_000 })),\n});\n\nexport class WorkflowHostConfigError extends Schema.TaggedError<WorkflowHostConfigError>()(\n \"WorkflowHostConfigError\",\n { message: Schema.String },\n) {}\n\nexport class WorkflowAdmissionClosed extends Schema.TaggedError<WorkflowAdmissionClosed>()(\n \"WorkflowAdmissionClosed\",\n { message: Schema.String },\n) {}\n\nexport interface WorkflowAgentHostOptions {\n readonly deploymentId: string;\n /** Application-owned identity for submissions from AgentWorkflow.execute. */\n readonly principal: string;\n /** Stable versioned name prefix. The native name also includes deploymentId. */\n readonly workflowName?: string;\n /** Concurrent Attempts within this host Layer instance, not a fleet-wide limit. Default 1. */\n readonly executionConcurrency?: number;\n /** Maximum entries per scan per repair invocation. Default 32. */\n readonly repairBatchSize?: number;\n /** Bound each dispatch or scan, including a retrying native engine. Default 10000 ms. */\n readonly dispatchTimeoutMillis?: number;\n}\n\nexport type WorkflowRepairFailure = WorkflowDispatchError | DurableAwaitFailure;\n\nconst nativeOperation = <A, E, R>(operation: string, effect: Effect.Effect<A, E, R>) =>\n effect.pipe(\n Effect.catchDefect((cause) =>\n Effect.fail(\n new WorkflowDispatchError({\n operation,\n message: \"Workflow engine operation failed\",\n cause,\n }),\n ),\n ),\n );\n\nconst makeHost = Effect.fn(\"WorkflowAgentHost.make\")(function* (options: WorkflowAgentHostOptions) {\n const config = yield* Schema.decodeEffect(WorkflowHostConfig)({\n deploymentId: options.deploymentId,\n principal: options.principal,\n workflowName: options.workflowName ?? \"effect-agent/Submission/v1\",\n executionConcurrency: options.executionConcurrency ?? 1,\n repairBatchSize: options.repairBatchSize ?? 32,\n dispatchTimeoutMillis: options.dispatchTimeoutMillis ?? 10_000,\n }).pipe(Effect.mapError((error) => new WorkflowHostConfigError({ message: error.message })));\n\n const runtime = yield* DurableAgentRuntime;\n const crypto = yield* Crypto.Crypto;\n const runtimeConfig = yield* DurableRuntimeConfig;\n const ledger = yield* SubmissionLedger;\n const engine = yield* WorkflowEngine.WorkflowEngine;\n const dispatch = yield* WorkflowDispatchStore;\n const trigger = yield* WorkflowRepairTrigger;\n const failpoint = yield* WorkflowDispatchFailpoint;\n\n if (runtimeConfig.deploymentId !== config.deploymentId) {\n return yield* new WorkflowHostConfigError({\n message: \"Workflow and durable runtime deploymentId must match\",\n });\n }\n const permits = yield* Semaphore.make(config.executionConcurrency);\n const lanes = yield* RcMap.make({ lookup: (_threadId: ThreadId) => Semaphore.make(1) });\n const repairPermit = yield* Semaphore.make(1);\n const admission = yield* Ref.make(true);\n const nativeName = `${config.workflowName}/deployment/${config.deploymentId.length}:${config.deploymentId}`;\n\n const workflow = Workflow.make(nativeName, {\n payload: WorkflowSubmission,\n success: WorkflowSettlementReference,\n idempotencyKey: ({ deploymentId, receipt }) =>\n `v1/${deploymentId.length}:${deploymentId}/${receipt.submissionId}`,\n }).annotate(Workflow.SuspendOnFailure, true);\n\n const bounded = <A, E, R>(operation: string, effect: Effect.Effect<A, E, R>) =>\n nativeOperation(operation, effect).pipe(\n Effect.timeout(config.dispatchTimeoutMillis),\n Effect.catchTag(\"TimeoutError\", () =>\n Effect.fail(\n WorkflowDispatchError.make({\n operation,\n message: \"Workflow dispatch operation timed out; accepted work remains recoverable\",\n }),\n ),\n ),\n );\n\n const validateReceipt = Effect.fn(\"WorkflowAgentHost.validateReceipt\")(function* (\n receipt: Receipt,\n ) {\n const found = yield* ledger.lookup(\n SubmissionLookupById.make({ submissionId: receipt.submissionId }),\n );\n\n if (\n Option.isNone(found) ||\n found.value.deploymentId !== config.deploymentId ||\n found.value.threadId !== receipt.threadId ||\n found.value.receiptId !== receipt.receiptId ||\n found.value.queueSequence !== receipt.queueSequence\n ) {\n return yield* WorkflowDispatchError.make({\n operation: \"identity\",\n message: \"Workflow Receipt does not match its authoritative deployment and Submission\",\n });\n }\n });\n\n // No Activities: rerun journal recovery directly on every native resume. The upstream\n // failure annotation suspends infrastructure failures and defects instead of settling them.\n yield* engine.register(\n workflow,\n Effect.fn(\"WorkflowAgentHost.execute\")(function* (payload, executionId) {\n yield* Effect.annotateCurrentSpan({\n \"workflow.execution.id\": executionId,\n \"agent.submission.id\": payload.receipt.submissionId,\n \"agent.thread.id\": payload.receipt.threadId,\n });\n if (payload.deploymentId !== config.deploymentId) {\n return yield* Effect.die(\"Workflow payload belongs to another deployment\");\n }\n if (executionId !== (yield* workflow.executionId(payload))) {\n return yield* Effect.die(\"Workflow execution identity does not match its Submission\");\n }\n yield* validateReceipt(payload.receipt).pipe(Effect.orDie);\n const initial = yield* runtime.inspectSubmissionStatus(payload.receipt).pipe(Effect.orDie);\n\n if (initial._tag === \"settled\") {\n return new WorkflowSettlementReference({\n version: 1,\n submissionId: initial.settlement.submissionId,\n threadId: payload.receipt.threadId,\n settlementId: initial.settlement.settlementId,\n });\n }\n\n const status = yield* Effect.scoped(\n Effect.gen(function* () {\n // Serialize recovery and processing for one Thread even when a ledger allows\n // same-producer takeover. Followers wait without consuming a global permit.\n const lane = yield* RcMap.get(lanes, payload.receipt.threadId);\n\n return yield* lane.withPermit(\n permits.withPermit(\n Effect.scoped(\n Effect.gen(function* () {\n yield* runtime.recoverSubmission(payload.receipt.submissionId);\n const recovered = yield* runtime.inspectSubmissionStatus(payload.receipt);\n\n if (recovered._tag === \"settled\") return recovered;\n yield* runtime.processThreadHead(payload.receipt.threadId);\n\n return yield* runtime.inspectSubmissionStatus(payload.receipt);\n }),\n ),\n ),\n );\n }),\n ).pipe(Effect.orDie);\n\n if (status._tag === \"settled\") {\n return new WorkflowSettlementReference({\n version: 1,\n submissionId: status.settlement.submissionId,\n threadId: payload.receipt.threadId,\n settlementId: status.settlement.settlementId,\n });\n }\n // Release the permit and Attempt Scope before native suspension, whose lifetime may\n // outlast this process. Completion is never inferred from an empty processing result.\n const instance = yield* WorkflowEngine.WorkflowInstance;\n\n return yield* Workflow.suspend(instance);\n }),\n );\n\n const intentFor = Effect.fn(\"WorkflowAgentHost.intentFor\")(function* (receipt: Receipt) {\n const payload = new WorkflowSubmission({\n version: 1,\n deploymentId: config.deploymentId,\n receipt,\n });\n\n const executionId = yield* workflow.executionId(payload);\n\n return new WorkflowDispatchIntent({\n ...payload,\n workflowName: nativeName,\n executionId,\n });\n });\n\n const dispatchIntent = Effect.fn(\"WorkflowAgentHost.dispatch\")(\n function* (\n requested: WorkflowDispatchIntent,\n ): Effect.fn.Return<boolean, WorkflowRepairFailure> {\n let intent = requested;\n const expected = yield* intentFor(intent.receipt);\n\n if (\n intent.executionId !== expected.executionId ||\n intent.deploymentId !== expected.deploymentId ||\n intent.workflowName !== expected.workflowName\n ) {\n return yield* new WorkflowDispatchError({\n operation: \"dispatch\",\n message: \"Dispatch identity does not match the configured Workflow\",\n });\n }\n yield* validateReceipt(intent.receipt);\n yield* failpoint.hit(\"intent:before-persist\", intent);\n intent = yield* dispatch.put(intent);\n yield* failpoint.hit(\"intent:after-persist\", intent);\n yield* failpoint.hit(\"launch:before\", intent);\n // Submission lifetime belongs to the durable host. Strip the optional parent\n // instance so upstream child interruption cannot cancel this recovery workflow.\n yield* nativeOperation(\n \"execute\",\n engine\n .execute(workflow, {\n executionId: intent.executionId,\n payload: new WorkflowSubmission(intent),\n discard: true,\n })\n .pipe(\n Effect.updateContext((context: Context.Context<never>) =>\n Context.omit(WorkflowEngine.WorkflowInstance)(context),\n ),\n ),\n );\n yield* failpoint.hit(\"launch:after\", intent);\n // Resume before suspension may be a no-op. Keep the intent and retry on a later trigger.\n yield* nativeOperation(\"resume\", engine.resume(workflow, intent.executionId));\n yield* failpoint.hit(\"completion:before-observe\", intent);\n const result = yield* nativeOperation(\"poll\", engine.poll(workflow, intent.executionId));\n\n yield* failpoint.hit(\"completion:after-observe\", intent);\n if (Option.isNone(result) || result.value._tag !== \"Complete\") return false;\n if (Exit.isFailure(result.value.exit)) {\n return yield* new WorkflowDispatchError({\n operation: \"completion\",\n message: \"Native Workflow completed without a Settlement reference; intent retained\",\n cause: result.value.exit.cause,\n });\n }\n const status = yield* runtime.inspectSubmissionStatus(intent.receipt);\n const reference = result.value.exit.value;\n\n if (\n status._tag !== \"settled\" ||\n reference.version !== 1 ||\n reference.submissionId !== intent.receipt.submissionId ||\n reference.threadId !== intent.receipt.threadId ||\n reference.settlementId !== status.settlement.settlementId\n ) {\n return yield* new WorkflowDispatchError({\n operation: \"completion\",\n message: \"Native completion disagrees with canonical Settlement; intent retained\",\n });\n }\n if (intent.completionToken !== undefined) {\n yield* failpoint.hit(\"completion:before-notify\", intent);\n yield* nativeOperation(\n \"notify\",\n DurableDeferred.succeed(workflowCompletion(\"settlement\"), {\n token: intent.completionToken,\n value: reference,\n }).pipe(Effect.provideService(WorkflowEngine.WorkflowEngine, engine)),\n );\n yield* failpoint.hit(\"completion:after-notify\", intent);\n }\n yield* failpoint.hit(\"cleanup:before\", intent);\n yield* dispatch.remove(intent);\n yield* failpoint.hit(\"cleanup:after\", intent);\n\n return true;\n },\n (effect) => bounded(\"dispatch\", effect),\n );\n\n let submissionOffset = 0;\n let intentCursor: string | undefined;\n\n const repair = repairPermit.withPermit(\n Effect.gen(function* () {\n // Respect adapter ordering, which may differ from JavaScript string comparison.\n // Deletions may defer a row until the next wrap; restarts repeat idempotent work.\n const discovery = yield* bounded(\n \"scanSubmissions\",\n ledger.scanNonterminal.pipe(\n Stream.filter((row) => row.deploymentId === config.deploymentId),\n Stream.drop(submissionOffset),\n Stream.take(config.repairBatchSize),\n Stream.runCollect,\n ),\n ).pipe(Effect.result);\n\n const submissions = Result.isSuccess(discovery) ? discovery.success : [];\n\n if (Result.isSuccess(discovery)) {\n submissionOffset =\n submissions.length < config.repairBatchSize ? 0 : submissionOffset + submissions.length;\n }\n\n const discovered = yield* Effect.forEach(submissions, (row) =>\n Effect.flatMap(intentFor(new Receipt(row)), dispatchIntent).pipe(Effect.result),\n );\n\n const outstanding = yield* bounded(\n \"scanIntents\",\n dispatch.scan(\n new WorkflowDispatchScan({\n deploymentId: config.deploymentId,\n workflowName: nativeName,\n ...(intentCursor === undefined ? {} : { after: intentCursor }),\n limit: config.repairBatchSize,\n }),\n ),\n ).pipe(Effect.result);\n\n const intents = Result.isSuccess(outstanding) ? outstanding.success : [];\n\n if (Result.isSuccess(outstanding))\n intentCursor =\n intents.length < config.repairBatchSize\n ? undefined\n : intents[intents.length - 1]?.executionId;\n\n const inspected = yield* Effect.forEach(intents, (intent) =>\n dispatchIntent(intent).pipe(Effect.result),\n );\n\n const results = [...discovered, ...inspected];\n\n if (Result.isFailure(discovery)) return yield* discovery.failure;\n if (Result.isFailure(outstanding)) return yield* outstanding.failure;\n const failure = results.find(Result.isFailure);\n\n if (failure !== undefined) return yield* Effect.fail(failure.failure);\n\n return new WorkflowRepairReport({\n discovered: submissions.length,\n inspected: intents.length,\n completed: results.filter((result) => Result.isSuccess(result) && result.success).length,\n });\n }),\n );\n\n yield* trigger.register(\n repair.pipe(\n Effect.asVoid,\n Effect.catchCause((cause) =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.interrupt\n : Effect.logError(\"Workflow dispatch repair failed; durable obligations remain\", cause),\n ),\n ),\n );\n yield* Effect.addFinalizer(() => Ref.set(admission, false));\n\n const submit = Effect.fn(\"WorkflowAgentHost.submit\")(function* <InputSchema extends Schema.Top>(\n agent: DurableSubmitAgent<InputSchema>,\n input: InputSchema[\"Type\"],\n options: DurableSubmitOptions,\n ): Effect.fn.Return<\n Receipt,\n DurableSubmitFailure | WorkflowRepairFailure | WorkflowAdmissionClosed,\n InputSchema[\"EncodingServices\"]\n > {\n if (!(yield* Ref.get(admission))) {\n return yield* new WorkflowAdmissionClosed({ message: \"The Workflow host is shutting down\" });\n }\n const receipt = yield* runtime.submit(agent, input, options);\n\n yield* dispatchIntent(yield* intentFor(receipt));\n\n return receipt;\n });\n\n const execute = Effect.fn(\"AgentWorkflow.execute\")(function* <\n Input extends Schema.Top,\n Output extends Schema.Top,\n >(agent: WorkflowAgent<Input, Output>, input: Input[\"Type\"], options: WorkflowExecuteOptions) {\n const parentEngine = yield* WorkflowEngine.WorkflowEngine;\n\n if (parentEngine !== engine) {\n return yield* new WorkflowExecutionFailure({\n reason: \"engine-mismatch\",\n message: \"Agent host and parent workflow must share one WorkflowEngine Layer\",\n });\n }\n\n const name = yield* Schema.decodeEffect(Schema.NonEmptyString)(options.name).pipe(\n Effect.mapError(\n () =>\n new WorkflowExecutionFailure({\n reason: \"invalid-name\",\n message: \"Workflow agent steps need a nonempty stable name\",\n }),\n ),\n );\n\n const completion = workflowCompletion(`effect-agent/${name}`);\n const completionToken = yield* DurableDeferred.token(completion);\n\n // Agent identity and input deliberately do not participate: changing either on replay\n // must conflict with the original admission rather than launch new external work.\n const identity = yield* digestJson([\n config.deploymentId,\n config.principal,\n completionToken,\n ]).pipe(Effect.provideService(Crypto.Crypto, crypto));\n\n if (!(yield* Ref.get(admission))) {\n return yield* new WorkflowAdmissionClosed({ message: \"The Workflow host is shutting down\" });\n }\n\n const receipt = yield* runtime.submitRegistered({ definition: agent }, input, {\n threadId: ThreadId.make(`workflow/${identity}`),\n idempotencyKey: IdempotencyKey.make(identity),\n principal: config.principal,\n });\n\n yield* Effect.annotateCurrentSpan({\n \"agent.submission.id\": receipt.submissionId,\n \"agent.workflow.step\": name,\n });\n yield* runtime.submissionStatus(receipt);\n yield* dispatchIntent(\n new WorkflowDispatchIntent({ ...(yield* intentFor(receipt)), completionToken }),\n );\n\n // The deferred stores only a reference. Always reauthorize and read canonical data,\n // including on replay after the workflow engine has cached the notification.\n const reference = yield* DurableDeferred.await(completion);\n\n const record = yield* runtime.settlementRecord(receipt);\n\n if (\n reference.submissionId !== receipt.submissionId ||\n reference.threadId !== receipt.threadId ||\n reference.settlementId !== record.settlementId\n ) {\n return yield* new WorkflowDispatchError({\n operation: \"result\",\n message: \"Workflow completion disagrees with canonical Settlement\",\n });\n }\n if (record.outcome === \"failed\") {\n return yield* new WorkflowExecutionFailure({\n reason: \"failed\",\n message: \"Agent submission failed\",\n receipt,\n failure: record.result,\n });\n }\n if (record.outcome === \"aborted\") {\n return yield* new WorkflowExecutionFailure({\n reason: \"aborted\",\n message: \"Agent submission was aborted\",\n receipt,\n });\n }\n if (record.result === undefined) {\n return yield* new WorkflowExecutionFailure({\n reason: \"missing-output\",\n message: \"Completed submission has no independent output\",\n receipt,\n });\n }\n\n return yield* Schema.decodeEffect(agent.output)(record.result).pipe(\n Effect.mapError(\n (cause) =>\n new AgentOutputError({\n message: `Cannot decode canonical agent output: ${cause.message}`,\n }),\n ),\n );\n });\n\n return WorkflowAgentHost.of({\n execute,\n submit,\n awaitSettlement: runtime.awaitSettlement,\n observe: runtime.observe,\n abort: runtime.abort,\n resolveApproval: runtime.resolveApproval,\n resolveUnknown: runtime.resolveUnknown,\n submissionStatus: runtime.submissionStatus,\n repair,\n executionId: Effect.fn(\"WorkflowAgentHost.executionId\")((receipt: Receipt) =>\n intentFor(receipt).pipe(Effect.map((intent) => intent.executionId)),\n ),\n });\n});\n\n/**\n * Optional engine-independent host. Supply the upstream WorkflowEngine, the existing\n * durable runtime and ledger, durable dispatch storage, and a host-owned repair trigger.\n * Do not also start the ordinary Node worker loop. Waiter interruption only detaches;\n * abort and resolutions retain the runtime's authorization and durable intent protocol.\n */\nexport class WorkflowAgentHost extends Context.Service<\n WorkflowAgentHost,\n {\n readonly execute: <Input extends Schema.Top, Output extends Schema.Top>(\n agent: WorkflowAgent<Input, Output>,\n input: Input[\"Type\"],\n options: WorkflowExecuteOptions,\n ) => Effect.Effect<\n Output[\"Type\"],\n | DurableSubmitFailure\n | BindingUnavailable\n | DurableAwaitFailure\n | WorkflowDispatchError\n | WorkflowAdmissionClosed\n | WorkflowExecutionFailure\n | AgentOutputError,\n | Input[\"EncodingServices\"]\n | Output[\"DecodingServices\"]\n | WorkflowEngine.WorkflowInstance\n | WorkflowEngine.WorkflowEngine\n >;\n readonly submit: <InputSchema extends Schema.Top>(\n agent: DurableSubmitAgent<InputSchema>,\n input: InputSchema[\"Type\"],\n options: DurableSubmitOptions,\n ) => Effect.Effect<\n Receipt,\n DurableSubmitFailure | WorkflowRepairFailure | WorkflowAdmissionClosed,\n InputSchema[\"EncodingServices\"]\n >;\n readonly awaitSettlement: DurableAgentRuntime[\"Service\"][\"awaitSettlement\"];\n readonly observe: DurableAgentRuntime[\"Service\"][\"observe\"];\n readonly abort: DurableAgentRuntime[\"Service\"][\"abort\"];\n readonly resolveApproval: DurableAgentRuntime[\"Service\"][\"resolveApproval\"];\n readonly resolveUnknown: DurableAgentRuntime[\"Service\"][\"resolveUnknown\"];\n readonly submissionStatus: DurableAgentRuntime[\"Service\"][\"submissionStatus\"];\n readonly repair: Effect.Effect<WorkflowRepairReport, WorkflowRepairFailure>;\n readonly executionId: (receipt: Receipt) => Effect.Effect<string>;\n }\n>()(\"@effect-agent/workflow/WorkflowAgentHost\") {\n /** Drive the injected runtime, whose Layer owns executable registrations and their services. */\n static layer(options: WorkflowAgentHostOptions) {\n return Layer.effect(WorkflowAgentHost)(makeHost(options));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAKA,MAAa,sBAAsB,SACjC,gBAAgB,KAAK,MAAM,EAAE,SAAS,4BAA4B,CAAC;;;;;;;;ACiDrE,MAAM,qBAAqB,OAAO,OAAO;CACvC,cAAc;CACd,WAAW;CACX,cAAc,OAAO;CACrB,sBAAsB,OAAO,IAAI,MAAM,OAAO,UAAU;EAAE,SAAS;EAAG,SAAS;CAAG,CAAC,CAAC;CACpF,iBAAi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WAAW,CAAC,CACpE;CACF,CAAC;AACH,CAAC;;;;;;;AAQD,IAAa,oBAAb,MAAa,0BAA0B,QAAQ,QAuC7C,CAAC,CAAC,0CAA0C,CAAC,CAAC;;CAE9C,OAAO,MAAM,SAAmC;EAC9C,OAAO,MAAM,OAAO,iBAAiB,CAAC,CAAC,SAAS,OAAO,CAAC;CAC1D;AACF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { WorkflowDispatchError, WorkflowDispatchStore, WorkflowRepairReport, WorkflowRepairTrigger } from "./WorkflowDispatch.mjs";
|
|
2
2
|
import { WorkflowAgent, WorkflowExecuteOptions, WorkflowExecutionFailure } from "./WorkflowExecution.mjs";
|
|
3
|
-
import { AgentOutputError } from "@effect-agent/core/AgentError";
|
|
4
|
-
import { BindingUnavailable } from "@effect-agent/thread/AgentRegistration";
|
|
5
|
-
import { SubmissionLedger } from "@effect-agent/thread/SubmissionLedger";
|
|
6
3
|
import { Cause, Context, Crypto, Effect, Layer, Schema } from "effect";
|
|
7
|
-
import {
|
|
4
|
+
import { AgentOutputError } from "effect-agent/agent-error";
|
|
5
|
+
import { BindingUnavailable } from "effect-agent/agent-registration";
|
|
6
|
+
import { SubmissionLedger } from "effect-agent/submission-ledger";
|
|
7
|
+
import { DurableAgentRuntime, DurableAwaitFailure, DurableRuntimeConfig, DurableSubmitAgent, DurableSubmitFailure, DurableSubmitOptions, Receipt } from "effect-agent/durable-agent-runtime";
|
|
8
8
|
import { WorkflowEngine } from "effect/unstable/workflow";
|
|
9
9
|
declare namespace WorkflowAgentHost_d_exports {
|
|
10
10
|
export { WorkflowAdmissionClosed, WorkflowAgentHost, WorkflowAgentHostOptions, WorkflowHostConfigError, WorkflowRepairFailure };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "./WorkflowDispatch.mjs";
|
|
2
|
-
import { i as WorkflowHostConfigError, n as WorkflowAgentHost, t as WorkflowAdmissionClosed } from "./WorkflowAgentHost-
|
|
2
|
+
import { i as WorkflowHostConfigError, n as WorkflowAgentHost, t as WorkflowAdmissionClosed } from "./WorkflowAgentHost-C5Ncprj1.mjs";
|
|
3
3
|
import "./WorkflowExecution.mjs";
|
|
4
4
|
export { WorkflowAdmissionClosed, WorkflowAgentHost, WorkflowHostConfigError };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context, Effect, Schema, Scope } from "effect";
|
|
2
|
-
import { Receipt } from "
|
|
2
|
+
import { Receipt } from "effect-agent/durable-agent-runtime";
|
|
3
3
|
declare namespace WorkflowDispatch_d_exports {
|
|
4
4
|
export { WorkflowDispatchError, WorkflowDispatchFailpoint, WorkflowDispatchFailpointLocation, WorkflowDispatchIntent, WorkflowDispatchScan, WorkflowDispatchStore, WorkflowRepairReport, WorkflowRepairTrigger, WorkflowSettlementReference, WorkflowSubmission };
|
|
5
5
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
2
|
import { Context, Effect, Schema } from "effect";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { DeploymentId } from "
|
|
3
|
+
import { Receipt } from "effect-agent/durable-agent-runtime";
|
|
4
|
+
import { SettlementId } from "effect-agent/identifiers";
|
|
5
|
+
import { DeploymentId } from "effect-agent/records";
|
|
6
6
|
import { DurableDeferred } from "effect/unstable/workflow";
|
|
7
7
|
//#region src/WorkflowDispatch.ts
|
|
8
8
|
var WorkflowDispatch_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkflowDispatch.mjs","names":[],"sources":["../src/WorkflowDispatch.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"WorkflowDispatch.mjs","names":[],"sources":["../src/WorkflowDispatch.ts"],"sourcesContent":["import { Context, Effect, Schema, type Scope } from \"effect\";\nimport { Receipt } from \"effect-agent/durable-agent-runtime\";\nimport { SettlementId } from \"effect-agent/identifiers\";\nimport { DeploymentId } from \"effect-agent/records\";\nimport { DurableDeferred } from \"effect/unstable/workflow\";\n\n/** Only identities cross the Workflow boundary; the agent journal owns the outcome. */\nexport class WorkflowSubmission extends Schema.Class<WorkflowSubmission>(\n \"@effect-agent/workflow/WorkflowSubmission\",\n)({\n version: Schema.Literal(1),\n deploymentId: DeploymentId,\n receipt: Receipt,\n}) {}\n\nexport class WorkflowSettlementReference extends Schema.Class<WorkflowSettlementReference>(\n \"@effect-agent/workflow/WorkflowSettlementReference\",\n)({\n version: Schema.Literal(1),\n submissionId: Receipt.fields.submissionId,\n threadId: Receipt.fields.threadId,\n settlementId: SettlementId,\n}) {}\n\n/** Retained until native success has been checked against the canonical Settlement. */\nexport class WorkflowDispatchIntent extends Schema.Class<WorkflowDispatchIntent>(\n \"@effect-agent/workflow/WorkflowDispatchIntent\",\n)({\n ...WorkflowSubmission.fields,\n workflowName: Schema.NonEmptyString,\n executionId: Schema.NonEmptyString,\n /** One workflow step owns this submission. Repair must notify it before removing the intent. */\n completionToken: Schema.optionalKey(DurableDeferred.Token),\n}) {}\n\nexport class WorkflowDispatchError extends Schema.TaggedError<WorkflowDispatchError>()(\n \"WorkflowDispatchError\",\n {\n operation: Schema.String,\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n },\n) {}\n\nexport class WorkflowDispatchScan extends Schema.Class<WorkflowDispatchScan>(\n \"@effect-agent/workflow/WorkflowDispatchScan\",\n)({\n deploymentId: DeploymentId,\n workflowName: Schema.NonEmptyString,\n after: Schema.optionalKey(Schema.String),\n limit: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 1000 })),\n}) {}\n\n/**\n * Adapter-private outbox. `put` returns the stored intent, preserving an existing completion\n * token when omitted and allowing its one-time attachment. Different identities or tokens\n * conflict. `remove` must compare the entire intent, so a concurrent token attachment cannot\n * be lost. `scan` returns at most limit rows in executionId order, after\n * the exclusive cursor, filtered by deployment and workflow. All writes are durable\n * before returning. No transcript, outcome, or native engine storage belongs here.\n */\nexport class WorkflowDispatchStore extends Context.Service<\n WorkflowDispatchStore,\n {\n readonly put: (\n intent: WorkflowDispatchIntent,\n ) => Effect.Effect<WorkflowDispatchIntent, WorkflowDispatchError>;\n readonly scan: (\n request: WorkflowDispatchScan,\n ) => Effect.Effect<ReadonlyArray<WorkflowDispatchIntent>, WorkflowDispatchError>;\n readonly remove: (intent: WorkflowDispatchIntent) => Effect.Effect<void, WorkflowDispatchError>;\n }\n>()(\"@effect-agent/workflow/WorkflowDispatchStore\") {}\n\n/**\n * Host-owned durable repair trigger. Register before admission opens. The host must\n * invoke repair at startup and repeatedly after lost hints or process loss. A Node\n * deployment may use a scoped poller; other hosts may use alarms or durable jobs.\n * Stop invoking the callback when this Scope closes. The shared driver starts no loop.\n */\nexport class WorkflowRepairTrigger extends Context.Service<\n WorkflowRepairTrigger,\n {\n readonly register: (repair: Effect.Effect<void>) => Effect.Effect<void, never, Scope.Scope>;\n }\n>()(\"@effect-agent/workflow/WorkflowRepairTrigger\") {}\n\nexport const WorkflowDispatchFailpointLocation = Schema.Literals([\n \"intent:before-persist\",\n \"intent:after-persist\",\n \"launch:before\",\n \"launch:after\",\n \"completion:before-observe\",\n \"completion:after-observe\",\n \"completion:before-notify\",\n \"completion:after-notify\",\n \"cleanup:before\",\n \"cleanup:after\",\n]);\n\nexport type WorkflowDispatchFailpointLocation = typeof WorkflowDispatchFailpointLocation.Type;\n\nexport const WorkflowDispatchFailpoint = Context.Reference<{\n readonly hit: (\n location: WorkflowDispatchFailpointLocation,\n intent: WorkflowDispatchIntent,\n ) => Effect.Effect<void, WorkflowDispatchError>;\n}>(\"@effect-agent/workflow/WorkflowDispatchFailpoint\", {\n defaultValue: () => ({ hit: () => Effect.void }),\n});\n\nexport class WorkflowRepairReport extends Schema.Class<WorkflowRepairReport>(\n \"@effect-agent/workflow/WorkflowRepairReport\",\n)({\n discovered: Schema.Int,\n inspected: Schema.Int,\n completed: Schema.Int,\n}) {}\n"],"mappings":";;;;;;;;;;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AAoD,EACrD,qBAAqB,EAAE,WAAW,OAAO,KAAK,GAChD,CAAC;AAED,IAAa,uBAAb,cAA0C,OAAO,MAC/C,6CACF,CAAC,CAAC;CACA,YAAY,OAAO;CACnB,WAAW,OAAO;CAClB,WAAW,OAAO;AACpB,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Receipt } from "effect-agent/durable-agent-runtime";
|
|
3
|
+
import { AgentId } from "effect-agent/identifiers";
|
|
4
4
|
declare namespace WorkflowExecution_d_exports {
|
|
5
5
|
export { WorkflowAgent, WorkflowExecuteOptions, WorkflowExecutionFailure };
|
|
6
6
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
2
|
import { Schema } from "effect";
|
|
3
|
-
import { Receipt } from "
|
|
4
|
-
import { SettlementFailureDiagnostic } from "
|
|
3
|
+
import { Receipt } from "effect-agent/durable-agent-runtime";
|
|
4
|
+
import { SettlementFailureDiagnostic } from "effect-agent/records";
|
|
5
5
|
//#region src/WorkflowExecution.ts
|
|
6
6
|
var WorkflowExecution_exports = /* @__PURE__ */ __exportAll({ WorkflowExecutionFailure: () => WorkflowExecutionFailure });
|
|
7
7
|
/** A terminal agent outcome or invalid invocation, distinct from retriable infrastructure errors. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkflowExecution.mjs","names":[],"sources":["../src/WorkflowExecution.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"WorkflowExecution.mjs","names":[],"sources":["../src/WorkflowExecution.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport { Receipt } from \"effect-agent/durable-agent-runtime\";\nimport type { AgentId } from \"effect-agent/identifiers\";\nimport { SettlementFailureDiagnostic } from \"effect-agent/records\";\n\n/** Must be the exact registered Definition instance; its model and tool services belong to registration. */\nexport interface WorkflowAgent<Input extends Schema.Top, Output extends Schema.Top> {\n readonly id: typeof AgentId.Type;\n readonly input: Input;\n readonly output: Output;\n}\n\nexport interface WorkflowExecuteOptions {\n /** Stable, nonempty step name, unique within one parent execution. Use item IDs in loops. */\n readonly name: string;\n}\n\n/** A terminal agent outcome or invalid invocation, distinct from retriable infrastructure errors. */\nexport class WorkflowExecutionFailure extends Schema.TaggedError<WorkflowExecutionFailure>()(\n \"WorkflowExecutionFailure\",\n {\n reason: Schema.Literals([\n \"invalid-name\",\n \"engine-mismatch\",\n \"failed\",\n \"aborted\",\n \"missing-output\",\n ]),\n message: Schema.String,\n receipt: Schema.optionalKey(Receipt),\n failure: Schema.optionalKey(SettlementFailureDiagnostic),\n },\n) {}\n"],"mappings":";;;;;;;AAkBA,IAAa,2BAAb,cAA8C,OAAO,YAAsC,CAAC,CAC1F,4BACA;CACE,QAAQ,OAAO,SAAS;EACtB;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,SAAS,OAAO;CAChB,SAAS,OAAO,YAAY,OAAO;CACnC,SAAS,OAAO,YAAY,2BAA2B;AACzD,CACF,CAAC,CAAC,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as WorkflowDispatch_exports } from "./WorkflowDispatch.mjs";
|
|
2
|
-
import { r as WorkflowAgentHost_exports } from "./WorkflowAgentHost-
|
|
2
|
+
import { r as WorkflowAgentHost_exports } from "./WorkflowAgentHost-C5Ncprj1.mjs";
|
|
3
3
|
import { t as WorkflowExecution_exports } from "./WorkflowExecution.mjs";
|
|
4
4
|
import { t as AgentWorkflow_exports } from "./AgentWorkflow.mjs";
|
|
5
5
|
export { AgentWorkflow_exports as AgentWorkflow, WorkflowAgentHost_exports as WorkflowAgentHost, WorkflowDispatch_exports as WorkflowDispatch, WorkflowExecution_exports as WorkflowExecution };
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@effect-agent/workflow","version":"0.1.0-beta.
|
|
1
|
+
{"name":"@effect-agent/workflow","version":"0.1.0-beta.87","dependencies":{"effect-agent":"0.1.0-beta.87"},"devDependencies":{"@effect-agent/storage-memory":"0.1.0-beta.87","@effect/platform-node":"4.0.0-rc.112","@effect/vitest":"4.0.0-rc.112","effect":"4.0.0-rc.112","typescript":"7.0.2","vite-plus":"0.3.0"},"peerDependencies":{"effect":"^4.0.0-rc.112"},"exports":{".":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"./agent-workflow":{"types":"./dist/AgentWorkflow.d.mts","default":"./dist/AgentWorkflow.mjs"},"./workflow-agent-host":{"types":"./dist/WorkflowAgentHost.d.mts","default":"./dist/WorkflowAgentHost.mjs"},"./workflow-dispatch":{"types":"./dist/WorkflowDispatch.d.mts","default":"./dist/WorkflowDispatch.mjs"},"./workflow-execution":{"types":"./dist/WorkflowExecution.d.mts","default":"./dist/WorkflowExecution.mjs"}},"description":"Effect Workflow execution for the existing durable Agent runtime.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/danieljvdm/effect-agent.git","directory":"packages/workflow"},"files":["dist","src"],"type":"module","sideEffects":[],"publishConfig":{"access":"public"},"scripts":{"build":"vp pack","check":"tsc --noEmit -p tsconfig.json","test":"vp test --passWithNoTests"}}
|
package/src/AgentWorkflow.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { AgentInputError, AgentOutputError } from "effect-agent/agent-error";
|
|
3
|
+
import { BindingUnavailable } from "effect-agent/agent-registration";
|
|
4
|
+
import { DigestError } from "effect-agent/digest";
|
|
5
|
+
import { DurableRuntimeFailpointError } from "effect-agent/durable-failpoint";
|
|
6
|
+
import { OperationDenied } from "effect-agent/operation-authorizer";
|
|
6
7
|
import {
|
|
7
8
|
AdmissionConflict,
|
|
8
9
|
AdmissionPolicyError,
|
|
9
10
|
LedgerError,
|
|
10
11
|
SettlementConflict,
|
|
11
|
-
} from "
|
|
12
|
+
} from "effect-agent/submission-ledger";
|
|
12
13
|
import {
|
|
13
14
|
AppendConflict,
|
|
14
15
|
FenceRejected,
|
|
15
16
|
ThreadNotMaterialized,
|
|
16
17
|
ThreadStoreError,
|
|
17
|
-
} from "
|
|
18
|
-
import { Effect, Schema } from "effect";
|
|
18
|
+
} from "effect-agent/thread-store";
|
|
19
19
|
|
|
20
20
|
import { WorkflowAdmissionClosed, WorkflowAgentHost } from "./WorkflowAgentHost.ts";
|
|
21
21
|
import { WorkflowDispatchError } from "./WorkflowDispatch.ts";
|
package/src/WorkflowAgentHost.ts
CHANGED
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
import { AgentOutputError } from "@effect-agent/core/AgentError";
|
|
2
|
-
import { ThreadId } from "@effect-agent/core/Identifiers";
|
|
3
|
-
import { type BindingUnavailable } from "@effect-agent/thread/AgentRegistration";
|
|
4
|
-
import { digestJson } from "@effect-agent/thread/Digest";
|
|
5
|
-
import {
|
|
6
|
-
DurableAgentRuntime,
|
|
7
|
-
DurableRuntimeConfig,
|
|
8
|
-
Receipt,
|
|
9
|
-
type DurableAwaitFailure,
|
|
10
|
-
type DurableSubmitAgent,
|
|
11
|
-
type DurableSubmitFailure,
|
|
12
|
-
type DurableSubmitOptions,
|
|
13
|
-
} from "@effect-agent/thread/DurableAgentRuntime";
|
|
14
|
-
import { DeploymentId } from "@effect-agent/thread/Records";
|
|
15
|
-
import {
|
|
16
|
-
IdempotencyKey,
|
|
17
|
-
Principal,
|
|
18
|
-
SubmissionLedger,
|
|
19
|
-
SubmissionLookupById,
|
|
20
|
-
} from "@effect-agent/thread/SubmissionLedger";
|
|
21
1
|
import {
|
|
22
2
|
Cause,
|
|
23
3
|
Context,
|
|
@@ -33,6 +13,26 @@ import {
|
|
|
33
13
|
Semaphore,
|
|
34
14
|
Stream,
|
|
35
15
|
} from "effect";
|
|
16
|
+
import { AgentOutputError } from "effect-agent/agent-error";
|
|
17
|
+
import { type BindingUnavailable } from "effect-agent/agent-registration";
|
|
18
|
+
import { digestJson } from "effect-agent/digest";
|
|
19
|
+
import {
|
|
20
|
+
DurableAgentRuntime,
|
|
21
|
+
DurableRuntimeConfig,
|
|
22
|
+
Receipt,
|
|
23
|
+
type DurableAwaitFailure,
|
|
24
|
+
type DurableSubmitAgent,
|
|
25
|
+
type DurableSubmitFailure,
|
|
26
|
+
type DurableSubmitOptions,
|
|
27
|
+
} from "effect-agent/durable-agent-runtime";
|
|
28
|
+
import { ThreadId } from "effect-agent/identifiers";
|
|
29
|
+
import { DeploymentId } from "effect-agent/records";
|
|
30
|
+
import {
|
|
31
|
+
IdempotencyKey,
|
|
32
|
+
Principal,
|
|
33
|
+
SubmissionLedger,
|
|
34
|
+
SubmissionLookupById,
|
|
35
|
+
} from "effect-agent/submission-ledger";
|
|
36
36
|
import { DurableDeferred, Workflow, WorkflowEngine } from "effect/unstable/workflow";
|
|
37
37
|
|
|
38
38
|
import { workflowCompletion } from "./internal/completion.ts";
|
package/src/WorkflowDispatch.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { SettlementId } from "@effect-agent/core/Identifiers";
|
|
2
|
-
import { Receipt } from "@effect-agent/thread/DurableAgentRuntime";
|
|
3
|
-
import { DeploymentId } from "@effect-agent/thread/Records";
|
|
4
1
|
import { Context, Effect, Schema, type Scope } from "effect";
|
|
2
|
+
import { Receipt } from "effect-agent/durable-agent-runtime";
|
|
3
|
+
import { SettlementId } from "effect-agent/identifiers";
|
|
4
|
+
import { DeploymentId } from "effect-agent/records";
|
|
5
5
|
import { DurableDeferred } from "effect/unstable/workflow";
|
|
6
6
|
|
|
7
7
|
/** Only identities cross the Workflow boundary; the agent journal owns the outcome. */
|
package/src/WorkflowExecution.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { AgentId } from "@effect-agent/core/Identifiers";
|
|
2
|
-
import { Receipt } from "@effect-agent/thread/DurableAgentRuntime";
|
|
3
|
-
import { SettlementFailureDiagnostic } from "@effect-agent/thread/Records";
|
|
4
1
|
import { Schema } from "effect";
|
|
2
|
+
import { Receipt } from "effect-agent/durable-agent-runtime";
|
|
3
|
+
import type { AgentId } from "effect-agent/identifiers";
|
|
4
|
+
import { SettlementFailureDiagnostic } from "effect-agent/records";
|
|
5
5
|
|
|
6
6
|
/** Must be the exact registered Definition instance; its model and tool services belong to registration. */
|
|
7
7
|
export interface WorkflowAgent<Input extends Schema.Top, Output extends Schema.Top> {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WorkflowAgentHost-BwqWlnqZ.mjs","names":[],"sources":["../src/internal/completion.ts","../src/WorkflowAgentHost.ts"],"sourcesContent":["import { DurableDeferred } from \"effect/unstable/workflow\";\n\nimport { WorkflowSettlementReference } from \"../WorkflowDispatch.ts\";\n\n/** Native deferred results contain only canonical identities, never a second agent result. */\nexport const workflowCompletion = (name: string) =>\n DurableDeferred.make(name, { success: WorkflowSettlementReference });\n","import { AgentOutputError } from \"@effect-agent/core/AgentError\";\nimport { ThreadId } from \"@effect-agent/core/Identifiers\";\nimport { type BindingUnavailable } from \"@effect-agent/thread/AgentRegistration\";\nimport { digestJson } from \"@effect-agent/thread/Digest\";\nimport {\n DurableAgentRuntime,\n DurableRuntimeConfig,\n Receipt,\n type DurableAwaitFailure,\n type DurableSubmitAgent,\n type DurableSubmitFailure,\n type DurableSubmitOptions,\n} from \"@effect-agent/thread/DurableAgentRuntime\";\nimport { DeploymentId } from \"@effect-agent/thread/Records\";\nimport {\n IdempotencyKey,\n Principal,\n SubmissionLedger,\n SubmissionLookupById,\n} from \"@effect-agent/thread/SubmissionLedger\";\nimport {\n Cause,\n Context,\n Crypto,\n Effect,\n Exit,\n Layer,\n Option,\n RcMap,\n Ref,\n Result,\n Schema,\n Semaphore,\n Stream,\n} from \"effect\";\nimport { DurableDeferred, Workflow, WorkflowEngine } from \"effect/unstable/workflow\";\n\nimport { workflowCompletion } from \"./internal/completion.ts\";\nimport {\n WorkflowDispatchError,\n WorkflowDispatchFailpoint,\n WorkflowDispatchIntent,\n WorkflowDispatchScan,\n WorkflowDispatchStore,\n WorkflowRepairReport,\n WorkflowRepairTrigger,\n WorkflowSettlementReference,\n WorkflowSubmission,\n} from \"./WorkflowDispatch.ts\";\nimport {\n WorkflowExecutionFailure,\n type WorkflowAgent,\n type WorkflowExecuteOptions,\n} from \"./WorkflowExecution.ts\";\n\nconst WorkflowHostConfig = Schema.Struct({\n deploymentId: DeploymentId,\n principal: Principal,\n workflowName: Schema.NonEmptyString,\n executionConcurrency: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 64 })),\n repairBatchSize: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 1000 })),\n dispatchTimeoutMillis: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 300_000 })),\n});\n\nexport class WorkflowHostConfigError extends Schema.TaggedError<WorkflowHostConfigError>()(\n \"WorkflowHostConfigError\",\n { message: Schema.String },\n) {}\n\nexport class WorkflowAdmissionClosed extends Schema.TaggedError<WorkflowAdmissionClosed>()(\n \"WorkflowAdmissionClosed\",\n { message: Schema.String },\n) {}\n\nexport interface WorkflowAgentHostOptions {\n readonly deploymentId: string;\n /** Application-owned identity for submissions from AgentWorkflow.execute. */\n readonly principal: string;\n /** Stable versioned name prefix. The native name also includes deploymentId. */\n readonly workflowName?: string;\n /** Concurrent Attempts within this host Layer instance, not a fleet-wide limit. Default 1. */\n readonly executionConcurrency?: number;\n /** Maximum entries per scan per repair invocation. Default 32. */\n readonly repairBatchSize?: number;\n /** Bound each dispatch or scan, including a retrying native engine. Default 10000 ms. */\n readonly dispatchTimeoutMillis?: number;\n}\n\nexport type WorkflowRepairFailure = WorkflowDispatchError | DurableAwaitFailure;\n\nconst nativeOperation = <A, E, R>(operation: string, effect: Effect.Effect<A, E, R>) =>\n effect.pipe(\n Effect.catchDefect((cause) =>\n Effect.fail(\n new WorkflowDispatchError({\n operation,\n message: \"Workflow engine operation failed\",\n cause,\n }),\n ),\n ),\n );\n\nconst makeHost = Effect.fn(\"WorkflowAgentHost.make\")(function* (options: WorkflowAgentHostOptions) {\n const config = yield* Schema.decodeEffect(WorkflowHostConfig)({\n deploymentId: options.deploymentId,\n principal: options.principal,\n workflowName: options.workflowName ?? \"effect-agent/Submission/v1\",\n executionConcurrency: options.executionConcurrency ?? 1,\n repairBatchSize: options.repairBatchSize ?? 32,\n dispatchTimeoutMillis: options.dispatchTimeoutMillis ?? 10_000,\n }).pipe(Effect.mapError((error) => new WorkflowHostConfigError({ message: error.message })));\n\n const runtime = yield* DurableAgentRuntime;\n const crypto = yield* Crypto.Crypto;\n const runtimeConfig = yield* DurableRuntimeConfig;\n const ledger = yield* SubmissionLedger;\n const engine = yield* WorkflowEngine.WorkflowEngine;\n const dispatch = yield* WorkflowDispatchStore;\n const trigger = yield* WorkflowRepairTrigger;\n const failpoint = yield* WorkflowDispatchFailpoint;\n\n if (runtimeConfig.deploymentId !== config.deploymentId) {\n return yield* new WorkflowHostConfigError({\n message: \"Workflow and durable runtime deploymentId must match\",\n });\n }\n const permits = yield* Semaphore.make(config.executionConcurrency);\n const lanes = yield* RcMap.make({ lookup: (_threadId: ThreadId) => Semaphore.make(1) });\n const repairPermit = yield* Semaphore.make(1);\n const admission = yield* Ref.make(true);\n const nativeName = `${config.workflowName}/deployment/${config.deploymentId.length}:${config.deploymentId}`;\n\n const workflow = Workflow.make(nativeName, {\n payload: WorkflowSubmission,\n success: WorkflowSettlementReference,\n idempotencyKey: ({ deploymentId, receipt }) =>\n `v1/${deploymentId.length}:${deploymentId}/${receipt.submissionId}`,\n }).annotate(Workflow.SuspendOnFailure, true);\n\n const bounded = <A, E, R>(operation: string, effect: Effect.Effect<A, E, R>) =>\n nativeOperation(operation, effect).pipe(\n Effect.timeout(config.dispatchTimeoutMillis),\n Effect.catchTag(\"TimeoutError\", () =>\n Effect.fail(\n WorkflowDispatchError.make({\n operation,\n message: \"Workflow dispatch operation timed out; accepted work remains recoverable\",\n }),\n ),\n ),\n );\n\n const validateReceipt = Effect.fn(\"WorkflowAgentHost.validateReceipt\")(function* (\n receipt: Receipt,\n ) {\n const found = yield* ledger.lookup(\n SubmissionLookupById.make({ submissionId: receipt.submissionId }),\n );\n\n if (\n Option.isNone(found) ||\n found.value.deploymentId !== config.deploymentId ||\n found.value.threadId !== receipt.threadId ||\n found.value.receiptId !== receipt.receiptId ||\n found.value.queueSequence !== receipt.queueSequence\n ) {\n return yield* WorkflowDispatchError.make({\n operation: \"identity\",\n message: \"Workflow Receipt does not match its authoritative deployment and Submission\",\n });\n }\n });\n\n // No Activities: rerun journal recovery directly on every native resume. The upstream\n // failure annotation suspends infrastructure failures and defects instead of settling them.\n yield* engine.register(\n workflow,\n Effect.fn(\"WorkflowAgentHost.execute\")(function* (payload, executionId) {\n yield* Effect.annotateCurrentSpan({\n \"workflow.execution.id\": executionId,\n \"agent.submission.id\": payload.receipt.submissionId,\n \"agent.thread.id\": payload.receipt.threadId,\n });\n if (payload.deploymentId !== config.deploymentId) {\n return yield* Effect.die(\"Workflow payload belongs to another deployment\");\n }\n if (executionId !== (yield* workflow.executionId(payload))) {\n return yield* Effect.die(\"Workflow execution identity does not match its Submission\");\n }\n yield* validateReceipt(payload.receipt).pipe(Effect.orDie);\n const initial = yield* runtime.inspectSubmissionStatus(payload.receipt).pipe(Effect.orDie);\n\n if (initial._tag === \"settled\") {\n return new WorkflowSettlementReference({\n version: 1,\n submissionId: initial.settlement.submissionId,\n threadId: payload.receipt.threadId,\n settlementId: initial.settlement.settlementId,\n });\n }\n\n const status = yield* Effect.scoped(\n Effect.gen(function* () {\n // Serialize recovery and processing for one Thread even when a ledger allows\n // same-producer takeover. Followers wait without consuming a global permit.\n const lane = yield* RcMap.get(lanes, payload.receipt.threadId);\n\n return yield* lane.withPermit(\n permits.withPermit(\n Effect.scoped(\n Effect.gen(function* () {\n yield* runtime.recoverSubmission(payload.receipt.submissionId);\n const recovered = yield* runtime.inspectSubmissionStatus(payload.receipt);\n\n if (recovered._tag === \"settled\") return recovered;\n yield* runtime.processThreadHead(payload.receipt.threadId);\n\n return yield* runtime.inspectSubmissionStatus(payload.receipt);\n }),\n ),\n ),\n );\n }),\n ).pipe(Effect.orDie);\n\n if (status._tag === \"settled\") {\n return new WorkflowSettlementReference({\n version: 1,\n submissionId: status.settlement.submissionId,\n threadId: payload.receipt.threadId,\n settlementId: status.settlement.settlementId,\n });\n }\n // Release the permit and Attempt Scope before native suspension, whose lifetime may\n // outlast this process. Completion is never inferred from an empty processing result.\n const instance = yield* WorkflowEngine.WorkflowInstance;\n\n return yield* Workflow.suspend(instance);\n }),\n );\n\n const intentFor = Effect.fn(\"WorkflowAgentHost.intentFor\")(function* (receipt: Receipt) {\n const payload = new WorkflowSubmission({\n version: 1,\n deploymentId: config.deploymentId,\n receipt,\n });\n\n const executionId = yield* workflow.executionId(payload);\n\n return new WorkflowDispatchIntent({\n ...payload,\n workflowName: nativeName,\n executionId,\n });\n });\n\n const dispatchIntent = Effect.fn(\"WorkflowAgentHost.dispatch\")(\n function* (\n requested: WorkflowDispatchIntent,\n ): Effect.fn.Return<boolean, WorkflowRepairFailure> {\n let intent = requested;\n const expected = yield* intentFor(intent.receipt);\n\n if (\n intent.executionId !== expected.executionId ||\n intent.deploymentId !== expected.deploymentId ||\n intent.workflowName !== expected.workflowName\n ) {\n return yield* new WorkflowDispatchError({\n operation: \"dispatch\",\n message: \"Dispatch identity does not match the configured Workflow\",\n });\n }\n yield* validateReceipt(intent.receipt);\n yield* failpoint.hit(\"intent:before-persist\", intent);\n intent = yield* dispatch.put(intent);\n yield* failpoint.hit(\"intent:after-persist\", intent);\n yield* failpoint.hit(\"launch:before\", intent);\n // Submission lifetime belongs to the durable host. Strip the optional parent\n // instance so upstream child interruption cannot cancel this recovery workflow.\n yield* nativeOperation(\n \"execute\",\n engine\n .execute(workflow, {\n executionId: intent.executionId,\n payload: new WorkflowSubmission(intent),\n discard: true,\n })\n .pipe(\n Effect.updateContext((context: Context.Context<never>) =>\n Context.omit(WorkflowEngine.WorkflowInstance)(context),\n ),\n ),\n );\n yield* failpoint.hit(\"launch:after\", intent);\n // Resume before suspension may be a no-op. Keep the intent and retry on a later trigger.\n yield* nativeOperation(\"resume\", engine.resume(workflow, intent.executionId));\n yield* failpoint.hit(\"completion:before-observe\", intent);\n const result = yield* nativeOperation(\"poll\", engine.poll(workflow, intent.executionId));\n\n yield* failpoint.hit(\"completion:after-observe\", intent);\n if (Option.isNone(result) || result.value._tag !== \"Complete\") return false;\n if (Exit.isFailure(result.value.exit)) {\n return yield* new WorkflowDispatchError({\n operation: \"completion\",\n message: \"Native Workflow completed without a Settlement reference; intent retained\",\n cause: result.value.exit.cause,\n });\n }\n const status = yield* runtime.inspectSubmissionStatus(intent.receipt);\n const reference = result.value.exit.value;\n\n if (\n status._tag !== \"settled\" ||\n reference.version !== 1 ||\n reference.submissionId !== intent.receipt.submissionId ||\n reference.threadId !== intent.receipt.threadId ||\n reference.settlementId !== status.settlement.settlementId\n ) {\n return yield* new WorkflowDispatchError({\n operation: \"completion\",\n message: \"Native completion disagrees with canonical Settlement; intent retained\",\n });\n }\n if (intent.completionToken !== undefined) {\n yield* failpoint.hit(\"completion:before-notify\", intent);\n yield* nativeOperation(\n \"notify\",\n DurableDeferred.succeed(workflowCompletion(\"settlement\"), {\n token: intent.completionToken,\n value: reference,\n }).pipe(Effect.provideService(WorkflowEngine.WorkflowEngine, engine)),\n );\n yield* failpoint.hit(\"completion:after-notify\", intent);\n }\n yield* failpoint.hit(\"cleanup:before\", intent);\n yield* dispatch.remove(intent);\n yield* failpoint.hit(\"cleanup:after\", intent);\n\n return true;\n },\n (effect) => bounded(\"dispatch\", effect),\n );\n\n let submissionOffset = 0;\n let intentCursor: string | undefined;\n\n const repair = repairPermit.withPermit(\n Effect.gen(function* () {\n // Respect adapter ordering, which may differ from JavaScript string comparison.\n // Deletions may defer a row until the next wrap; restarts repeat idempotent work.\n const discovery = yield* bounded(\n \"scanSubmissions\",\n ledger.scanNonterminal.pipe(\n Stream.filter((row) => row.deploymentId === config.deploymentId),\n Stream.drop(submissionOffset),\n Stream.take(config.repairBatchSize),\n Stream.runCollect,\n ),\n ).pipe(Effect.result);\n\n const submissions = Result.isSuccess(discovery) ? discovery.success : [];\n\n if (Result.isSuccess(discovery)) {\n submissionOffset =\n submissions.length < config.repairBatchSize ? 0 : submissionOffset + submissions.length;\n }\n\n const discovered = yield* Effect.forEach(submissions, (row) =>\n Effect.flatMap(intentFor(new Receipt(row)), dispatchIntent).pipe(Effect.result),\n );\n\n const outstanding = yield* bounded(\n \"scanIntents\",\n dispatch.scan(\n new WorkflowDispatchScan({\n deploymentId: config.deploymentId,\n workflowName: nativeName,\n ...(intentCursor === undefined ? {} : { after: intentCursor }),\n limit: config.repairBatchSize,\n }),\n ),\n ).pipe(Effect.result);\n\n const intents = Result.isSuccess(outstanding) ? outstanding.success : [];\n\n if (Result.isSuccess(outstanding))\n intentCursor =\n intents.length < config.repairBatchSize\n ? undefined\n : intents[intents.length - 1]?.executionId;\n\n const inspected = yield* Effect.forEach(intents, (intent) =>\n dispatchIntent(intent).pipe(Effect.result),\n );\n\n const results = [...discovered, ...inspected];\n\n if (Result.isFailure(discovery)) return yield* discovery.failure;\n if (Result.isFailure(outstanding)) return yield* outstanding.failure;\n const failure = results.find(Result.isFailure);\n\n if (failure !== undefined) return yield* Effect.fail(failure.failure);\n\n return new WorkflowRepairReport({\n discovered: submissions.length,\n inspected: intents.length,\n completed: results.filter((result) => Result.isSuccess(result) && result.success).length,\n });\n }),\n );\n\n yield* trigger.register(\n repair.pipe(\n Effect.asVoid,\n Effect.catchCause((cause) =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.interrupt\n : Effect.logError(\"Workflow dispatch repair failed; durable obligations remain\", cause),\n ),\n ),\n );\n yield* Effect.addFinalizer(() => Ref.set(admission, false));\n\n const submit = Effect.fn(\"WorkflowAgentHost.submit\")(function* <InputSchema extends Schema.Top>(\n agent: DurableSubmitAgent<InputSchema>,\n input: InputSchema[\"Type\"],\n options: DurableSubmitOptions,\n ): Effect.fn.Return<\n Receipt,\n DurableSubmitFailure | WorkflowRepairFailure | WorkflowAdmissionClosed,\n InputSchema[\"EncodingServices\"]\n > {\n if (!(yield* Ref.get(admission))) {\n return yield* new WorkflowAdmissionClosed({ message: \"The Workflow host is shutting down\" });\n }\n const receipt = yield* runtime.submit(agent, input, options);\n\n yield* dispatchIntent(yield* intentFor(receipt));\n\n return receipt;\n });\n\n const execute = Effect.fn(\"AgentWorkflow.execute\")(function* <\n Input extends Schema.Top,\n Output extends Schema.Top,\n >(agent: WorkflowAgent<Input, Output>, input: Input[\"Type\"], options: WorkflowExecuteOptions) {\n const parentEngine = yield* WorkflowEngine.WorkflowEngine;\n\n if (parentEngine !== engine) {\n return yield* new WorkflowExecutionFailure({\n reason: \"engine-mismatch\",\n message: \"Agent host and parent workflow must share one WorkflowEngine Layer\",\n });\n }\n\n const name = yield* Schema.decodeEffect(Schema.NonEmptyString)(options.name).pipe(\n Effect.mapError(\n () =>\n new WorkflowExecutionFailure({\n reason: \"invalid-name\",\n message: \"Workflow agent steps need a nonempty stable name\",\n }),\n ),\n );\n\n const completion = workflowCompletion(`effect-agent/${name}`);\n const completionToken = yield* DurableDeferred.token(completion);\n\n // Agent identity and input deliberately do not participate: changing either on replay\n // must conflict with the original admission rather than launch new external work.\n const identity = yield* digestJson([\n config.deploymentId,\n config.principal,\n completionToken,\n ]).pipe(Effect.provideService(Crypto.Crypto, crypto));\n\n if (!(yield* Ref.get(admission))) {\n return yield* new WorkflowAdmissionClosed({ message: \"The Workflow host is shutting down\" });\n }\n\n const receipt = yield* runtime.submitRegistered({ definition: agent }, input, {\n threadId: ThreadId.make(`workflow/${identity}`),\n idempotencyKey: IdempotencyKey.make(identity),\n principal: config.principal,\n });\n\n yield* Effect.annotateCurrentSpan({\n \"agent.submission.id\": receipt.submissionId,\n \"agent.workflow.step\": name,\n });\n yield* runtime.submissionStatus(receipt);\n yield* dispatchIntent(\n new WorkflowDispatchIntent({ ...(yield* intentFor(receipt)), completionToken }),\n );\n\n // The deferred stores only a reference. Always reauthorize and read canonical data,\n // including on replay after the workflow engine has cached the notification.\n const reference = yield* DurableDeferred.await(completion);\n\n const record = yield* runtime.settlementRecord(receipt);\n\n if (\n reference.submissionId !== receipt.submissionId ||\n reference.threadId !== receipt.threadId ||\n reference.settlementId !== record.settlementId\n ) {\n return yield* new WorkflowDispatchError({\n operation: \"result\",\n message: \"Workflow completion disagrees with canonical Settlement\",\n });\n }\n if (record.outcome === \"failed\") {\n return yield* new WorkflowExecutionFailure({\n reason: \"failed\",\n message: \"Agent submission failed\",\n receipt,\n failure: record.result,\n });\n }\n if (record.outcome === \"aborted\") {\n return yield* new WorkflowExecutionFailure({\n reason: \"aborted\",\n message: \"Agent submission was aborted\",\n receipt,\n });\n }\n if (record.result === undefined) {\n return yield* new WorkflowExecutionFailure({\n reason: \"missing-output\",\n message: \"Completed submission has no independent output\",\n receipt,\n });\n }\n\n return yield* Schema.decodeEffect(agent.output)(record.result).pipe(\n Effect.mapError(\n (cause) =>\n new AgentOutputError({\n message: `Cannot decode canonical agent output: ${cause.message}`,\n }),\n ),\n );\n });\n\n return WorkflowAgentHost.of({\n execute,\n submit,\n awaitSettlement: runtime.awaitSettlement,\n observe: runtime.observe,\n abort: runtime.abort,\n resolveApproval: runtime.resolveApproval,\n resolveUnknown: runtime.resolveUnknown,\n submissionStatus: runtime.submissionStatus,\n repair,\n executionId: Effect.fn(\"WorkflowAgentHost.executionId\")((receipt: Receipt) =>\n intentFor(receipt).pipe(Effect.map((intent) => intent.executionId)),\n ),\n });\n});\n\n/**\n * Optional engine-independent host. Supply the upstream WorkflowEngine, the existing\n * durable runtime and ledger, durable dispatch storage, and a host-owned repair trigger.\n * Do not also start the ordinary Node worker loop. Waiter interruption only detaches;\n * abort and resolutions retain the runtime's authorization and durable intent protocol.\n */\nexport class WorkflowAgentHost extends Context.Service<\n WorkflowAgentHost,\n {\n readonly execute: <Input extends Schema.Top, Output extends Schema.Top>(\n agent: WorkflowAgent<Input, Output>,\n input: Input[\"Type\"],\n options: WorkflowExecuteOptions,\n ) => Effect.Effect<\n Output[\"Type\"],\n | DurableSubmitFailure\n | BindingUnavailable\n | DurableAwaitFailure\n | WorkflowDispatchError\n | WorkflowAdmissionClosed\n | WorkflowExecutionFailure\n | AgentOutputError,\n | Input[\"EncodingServices\"]\n | Output[\"DecodingServices\"]\n | WorkflowEngine.WorkflowInstance\n | WorkflowEngine.WorkflowEngine\n >;\n readonly submit: <InputSchema extends Schema.Top>(\n agent: DurableSubmitAgent<InputSchema>,\n input: InputSchema[\"Type\"],\n options: DurableSubmitOptions,\n ) => Effect.Effect<\n Receipt,\n DurableSubmitFailure | WorkflowRepairFailure | WorkflowAdmissionClosed,\n InputSchema[\"EncodingServices\"]\n >;\n readonly awaitSettlement: DurableAgentRuntime[\"Service\"][\"awaitSettlement\"];\n readonly observe: DurableAgentRuntime[\"Service\"][\"observe\"];\n readonly abort: DurableAgentRuntime[\"Service\"][\"abort\"];\n readonly resolveApproval: DurableAgentRuntime[\"Service\"][\"resolveApproval\"];\n readonly resolveUnknown: DurableAgentRuntime[\"Service\"][\"resolveUnknown\"];\n readonly submissionStatus: DurableAgentRuntime[\"Service\"][\"submissionStatus\"];\n readonly repair: Effect.Effect<WorkflowRepairReport, WorkflowRepairFailure>;\n readonly executionId: (receipt: Receipt) => Effect.Effect<string>;\n }\n>()(\"@effect-agent/workflow/WorkflowAgentHost\") {\n /** Drive the injected runtime, whose Layer owns executable registrations and their services. */\n static layer(options: WorkflowAgentHostOptions) {\n return Layer.effect(WorkflowAgentHost)(makeHost(options));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAKA,MAAa,sBAAsB,SACjC,gBAAgB,KAAK,MAAM,EAAE,SAAS,4BAA4B,CAAC;;;;;;;;ACiDrE,MAAM,qBAAqB,OAAO,OAAO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