@makaio/framework 1.0.0-dev-1788511348215 → 1.0.0-dev-1788721567504
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/.makaio-build.json +2 -2
- package/dist/attempt-record-codec-BORASgzn.mjs +1 -0
- package/dist/bus/index.d.mts +19 -19
- package/dist/bus/index.mjs +1 -1
- package/dist/{context-resolution-841T7jBI.d.mts → context-resolution-CoKFKIqz.d.mts} +3 -3
- package/dist/contracts/adapter/index.d.mts +1 -1
- package/dist/contracts/artifact/index.d.mts +2 -2
- package/dist/contracts/canonical-model/index.d.mts +1 -1
- package/dist/contracts/capabilities/index.d.mts +1 -1
- package/dist/contracts/client/index.d.mts +1 -1
- package/dist/contracts/extension/index.d.mts +3 -3
- package/dist/contracts/index.d.mts +616 -122
- package/dist/contracts/index.mjs +1 -1
- package/dist/contracts/materialization/index.d.mts +2 -2
- package/dist/contracts/session/index.d.mts +2 -2
- package/dist/contracts/shared/index.d.mts +1 -1
- package/dist/contracts/variant/index.d.mts +1 -1
- package/dist/contracts/worker/index.d.mts +1 -1
- package/dist/contracts/worker/index.mjs +1 -1
- package/dist/contracts/workflow/index.d.mts +2 -2
- package/dist/{execution-attempt-repository-DY4KTptE.d.mts → execution-attempt-repository-CRdrgou3.d.mts} +512 -3
- package/dist/{index-jxPncqWZ2.d.mts → index--Ws52sWV2.d.mts} +4 -4
- package/dist/{index-Wbd_syN2.d.mts → index-37_b--BH.d.mts} +11 -11
- package/dist/{index-6trZYnUP2.d.mts → index-8NdPPzUh2.d.mts} +12 -12
- package/dist/{index-B-3I98nw.d.mts → index-AdcDBUnc.d.mts} +95 -95
- package/dist/{index-C6aSnO8m.d.mts → index-BJdkVFX9.d.mts} +288 -24
- package/dist/{index-DXtQRehh.d.mts → index-BKIxdzIw.d.mts} +11 -11
- package/dist/{index-CmwAJ8-5.d.mts → index-CFI6FxC7.d.mts} +1 -1
- package/dist/{index-DI2lS7VT.d.mts → index-CVcG4Q3X.d.mts} +5 -5
- package/dist/{index-DHH-93YD.d.mts → index-CYjgoYeX.d.mts} +1 -1
- package/dist/{index-CDud4NAm.d.mts → index-CxwqnZpT.d.mts} +75 -75
- package/dist/{index-BkbnC65b.d.mts → index-CyWGSxrs.d.mts} +291 -291
- package/dist/{index-C146Eq_J.d.mts → index-D1wTWSLR.d.mts} +327 -327
- package/dist/{index-Bqk0pJBQ2.d.mts → index-DBD_oFEt2.d.mts} +1 -1
- package/dist/{index-BmilK-co2.d.mts → index-DV38-klA2.d.mts} +12 -36
- package/dist/{index-DNI6UF9h.d.mts → index-I5a37JCm.d.mts} +4 -4
- package/dist/kernel/extension/index.d.mts +1 -1
- package/dist/kernel/index.d.mts +2 -2
- package/dist/kernel/observability/index.d.mts +1 -1
- package/dist/{namespace-l-HG1rLF.d.mts → namespace-Bo94cenp.d.mts} +136 -136
- package/dist/{namespace-DknCutQZ.d.mts → namespace-CPm9dhi2.d.mts} +2 -2
- package/dist/{namespace-BNp7n_gu.d.mts → namespace-CsnrP8AD.d.mts} +3 -3
- package/dist/{namespace-BGRHcrmp.d.mts → namespace-CstawJgN.d.mts} +2 -2
- package/dist/{package-efR90JGe.d.mts → package-DkZmsdCd.d.mts} +49 -1
- package/dist/package-UemD2NWn.mjs +7 -0
- package/dist/package.json +1 -1
- package/dist/runtime-node/index.d.mts +2 -2
- package/dist/runtime-node/index.mjs +24 -24
- package/dist/runtime-node/workflow-execution-bus-access.mjs +1 -1
- package/dist/runtime-node/workflow-worker/index.d.mts +2 -2
- package/dist/runtime-node/workflow-worker/index.mjs +1 -1
- package/dist/runtime-node/workflow-worker/worker-entry.d.mts +49 -9
- package/dist/runtime-node/workflow-worker/worker-entry.mjs +1 -1
- package/dist/runtime-registration-client-BTtFpt_k.mjs +1 -0
- package/dist/{schemas-D7EeKBDJ.d.mts → schemas-CJKHYluy.d.mts} +13 -13
- package/dist/{schemas-C1mxTfd7.d.mts → schemas-CenET9Cq.d.mts} +1 -1
- package/dist/{schemas-D7ScxLrf.d.mts → schemas-DTJtS14K.d.mts} +136 -136
- package/dist/services/adapter-runtime/index.d.mts +3 -3
- package/dist/services/adapter-runtime/namespace.d.mts +1 -1
- package/dist/services/adapter-runtime/schemas.d.mts +1 -1
- package/dist/services/agent-runtime/index.d.mts +2 -2
- package/dist/services/agent-runtime/namespace.d.mts +1 -1
- package/dist/services/agent-runtime/schemas.d.mts +1 -1
- package/dist/services/filesystem/namespace.d.mts +6 -6
- package/dist/services/filesystem/schemas.d.mts +3 -3
- package/dist/services/index.d.mts +86 -86
- package/dist/services/session/index.d.mts +1 -1
- package/dist/services/session/messages/namespace.d.mts +1 -1
- package/dist/services/settings/namespace.d.mts +10 -10
- package/dist/services/settings/storage/extension-configs/namespace.d.mts +3 -3
- package/dist/services/subagent-template/index.d.mts +2 -2
- package/dist/services/subagent-template/namespace.d.mts +1 -1
- package/dist/services/subagent-template/schemas.d.mts +1 -1
- package/dist/{transition-D3zUBTPc.d.mts → transition-DxsrTsn4.d.mts} +1 -1
- package/dist/{types-DcxBYlPA.d.mts → types-Czdm5op1.d.mts} +306 -306
- package/dist/{view-builder-B0j9p5C0.d.mts → view-builder-D-Wz_l_B.d.mts} +1 -1
- package/dist/worker-DlRdLf2d.mjs +1 -0
- package/dist/workflow-engine/execution-attempt-repository.d.mts +2 -2
- package/dist/workflow-engine/execution-attempt-repository.mjs +1 -1
- package/dist/workflow-engine/index.d.mts +205 -70
- package/dist/workflow-engine/index.mjs +1 -1
- package/dist/workflow-engine/package.d.mts +1 -1
- package/dist/workflow-engine/package.mjs +1 -1
- package/dist/workflow-engine/testing/index.d.mts +55 -3
- package/dist/workflow-engine/testing/index.mjs +1 -1
- package/dist/workflow-engine/testing/sqlite.d.mts +1 -1
- package/dist/workflow-engine/testing/sqlite.mjs +106 -38
- package/dist/workflow-worker-DjUfKshi.mjs +1 -0
- package/package.json +1 -1
- package/dist/attempt-record-codec-dC9LSFUE.mjs +0 -1
- package/dist/await-trigger-Bkg2BQfg.mjs +0 -1
- package/dist/package-Cgjpm9om.mjs +0 -7
- package/dist/worker-CARV52hT.mjs +0 -1
- package/dist/workflow-worker-Dul-wcOR.mjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{randomBytes as e}from"node:crypto";import{getFullSubjectForSubjectDefinition as t}from"@makaio/framework/core";import{ArtifactSubjects as n,
|
|
1
|
+
import{randomBytes as e}from"node:crypto";import{getFullSubjectForSubjectDefinition as t}from"@makaio/framework/core";import{ArtifactSubjects as n,ExecutionAttemptSubjects as r,SubagentSubjects as i,WorkerSubjects as a,WorkflowSubjects as o}from"@makaio/framework/contracts";import{registerHmacIdentitySecret as s,resolveHmacIdentityPeer as c,resolveHmacIdentitySecret as l,rotateHmacIdentitySecret as u}from"@makaio/framework/node/transports";import{AdapterSubsystemSubjects as d}from"@makaio/framework/services/adapter-subsystem";import{WorkflowStorageSubjects as f}from"@makaio/framework/workflow-engine";const p=[r.runtime.register,r.operation.admit,r.operation.deliver,a.control.outcome.submit,o.getRunContext,d.listAdapters,o.bootstrapAuthorityState,o.finalizeDelegateResult,f.getExecution,f.setFrame,f.setSpan,f.listFrames,f.getGateInstance,f.setGateInstance,o.frame.started,o.frame.completed,o.frame.failed,o.frame.sessionLinked,o.execution.progress,o.gate.suspended,o.gate.resumed,o.gate.resolved,o.gate.respond,o.state.get,o.state.patch,o.resolveAgent,o.resolveRole,n.query,n.create,n.revise,o.artifact.updated,i.spawn,i.await,i.getStatus,i.kill];function m(e){return[...p.map(t),`workflow.${e}.cancel`]}function h(e){let{executionAttemptId:t,executionId:n,secret:r}=e,i=e.allowedSubjects??m(n);return{secret:r,cleanup:s(t,r,{peerKind:`workflow-execution-attempt`,claims:{executionId:n},allowedSubjects:i})}}function g(t){let n=e(32).toString(`hex`);return h({...t,secret:n})}function _(t){let{executionAttemptId:n,executionId:r}=t,i=c(n);if(i?.kind!==`workflow-execution-attempt`||i.claims?.executionId!==r)throw Error(`Cannot rotate workflow execution bus secret: attempt "${n}" is not registered for execution "${r}"`);let a=e(32).toString(`hex`);return{secret:a,cleanup:u(n,a)}}function v(e){return l(e.executionAttemptId)===null?g(e):_(e)}function y(e){return l(e)??void 0}export{m as buildExecutionAttemptAllowedSubjects,v as mintOrRotateWorkflowExecutionBusSecret,g as mintWorkflowExecutionBusSecret,h as registerWorkflowExecutionBusSecret,y as resolveWorkflowExecutionBusSecret,_ as rotateWorkflowExecutionBusSecret};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { CreateIsolatedWorkflowRuntimeOptions, CreateNodeWorkflowRunnerPackageOptionsParams, DELIVERED_DECISIONS, HeadlessWorkerBootstrap, HeadlessWorkerBootstrapCredentials, HeadlessWorkerBusConnector, HeadlessWorkerContributionLoader, HeadlessWorkerExecutor, HeadlessWorkerMaterializer, HeadlessWorkerPostCommitObserver, HeadlessWorkflowWorkerDeps, HeadlessWorkflowWorkerResult, IWorkflowRunner, InProcessWorkflowRunner, InProcessWorkflowRunnerOptions, IsolatedWorkflowRuntime, IsolatedWorkflowRuntimeContext, LocalDirectoryMaterializerOptions, MaterializationError, MaterializedWorkspace, NodeWorkflowRunnerPackageOptions, OutcomeDeliveryError, OutcomeReconnect, OutcomeSubmitPayload, OutcomeSubmitRetryConfig, ParsedSriIntegrity, PiscinaThinWorkflowProvider, PiscinaThinWorkflowProviderOptions, RuntimeLoadedWorkflow, ThinWorkflowPiscinaRunner, ThinWorkflowPiscinaRunnerOptions, WorkerRunner, WorkerRunnerOptions, WorkflowRunResult, WorkflowRuntimeAuthorityConnector, WorkflowRuntimeContributionLoader, WorkflowWorkerEntryMode, WorkflowWorkerEntryResolverOptions, WorkspaceRootResolver, assertContainedIn, assertNoSymlinkEscape, computeContributionPackageDigest, computeDirectoryDigest, computeFileDigest, createIsolatedWorkflowRuntime, createNodeWorkflowRunner, createNodeWorkflowRunnerPackageOptions, loadWorkflowFromConfig, loadWorkflowModule, loadWorkflowModules, materializeLocalDirectory, parseSriIntegrity, resolveWorkflowWorkerEntry, runHeadlessWorkflowWorker, submitOutcomeWithAck, verifyContribution };
|
|
1
|
+
import { $ as ThinWorkflowPiscinaRunner, A as runHeadlessWorkflowWorker, B as PiscinaThinWorkflowProviderOptions, C as HeadlessWorkerContributionLoader, Ct as verifyContribution, D as HeadlessWorkflowWorkerDeps, E as HeadlessWorkerPostCommitObserver, Et as resolveWorkflowWorkerEntry, F as WorkflowRuntimeContributionLoader, G as OutcomeSubmitRetryConfig, H as OutcomeDeliveryError, I as createIsolatedWorkflowRuntime, J as WorkerRunnerOptions, K as submitOutcomeWithAck, L as InProcessWorkflowRunner, M as IsolatedWorkflowRuntime, N as IsolatedWorkflowRuntimeContext, O as HeadlessWorkflowWorkerResult, P as WorkflowRuntimeAuthorityConnector, Q as createNodeWorkflowRunnerPackageOptions, R as InProcessWorkflowRunnerOptions, S as HeadlessWorkerBusConnector, St as parseSriIntegrity, T as HeadlessWorkerMaterializer, Tt as WorkflowWorkerEntryResolverOptions, U as OutcomeReconnect, V as DELIVERED_DECISIONS, W as OutcomeSubmitPayload, X as NodeWorkflowRunnerPackageOptions, Y as CreateNodeWorkflowRunnerPackageOptionsParams, Z as createNodeWorkflowRunner, _ as loadWorkflowModule, _t as assertNoSymlinkEscape, a as OperationAdmissionRefusedError, b as HeadlessWorkerBootstrap, bt as computeFileDigest, c as OperationDeliveryHandler, d as RegisterWorkerRuntimeOptions, et as IWorkflowRunner, f as RuntimeRegistrationRefusedError, ft as LocalDirectoryMaterializerOptions, g as registerWorkerRuntime, gt as assertContainedIn, h as registerAndAdmitWorkflowRun, ht as WorkspaceRootResolver, i as DeliverableOperationKind, j as CreateIsolatedWorkflowRuntimeOptions, k as MaterializedWorkspace, l as OperationDeliveryHandlers, m as installOperationDeliveryEndpoint, mt as ParsedSriIntegrity, n as AdmitWorkflowRunOperationOptions, nt as ThinWorkflowPiscinaRunnerOptions, o as OperationDeliveryEndpoint, p as admitWorkflowRunOperation, pt as MaterializationError, q as WorkerRunner, r as AdmittedWorkflowRun, rt as WorkflowRunResult, s as OperationDeliveryEndpointIdentity, t as ALLOCATION_VISIBILITY_DEADLINE_MS, tt as RuntimeLoadedWorkflow, u as RegisterAndAdmitWorkflowRunOptions, v as loadWorkflowModules, vt as computeContributionPackageDigest, w as HeadlessWorkerExecutor, wt as WorkflowWorkerEntryMode, x as HeadlessWorkerBootstrapCredentials, xt as materializeLocalDirectory, y as loadWorkflowFromConfig, yt as computeDirectoryDigest, z as PiscinaThinWorkflowProvider } from "../../index-BJdkVFX9.mjs";
|
|
2
|
+
export { ALLOCATION_VISIBILITY_DEADLINE_MS, AdmitWorkflowRunOperationOptions, AdmittedWorkflowRun, CreateIsolatedWorkflowRuntimeOptions, CreateNodeWorkflowRunnerPackageOptionsParams, DELIVERED_DECISIONS, DeliverableOperationKind, HeadlessWorkerBootstrap, HeadlessWorkerBootstrapCredentials, HeadlessWorkerBusConnector, HeadlessWorkerContributionLoader, HeadlessWorkerExecutor, HeadlessWorkerMaterializer, HeadlessWorkerPostCommitObserver, HeadlessWorkflowWorkerDeps, HeadlessWorkflowWorkerResult, IWorkflowRunner, InProcessWorkflowRunner, InProcessWorkflowRunnerOptions, IsolatedWorkflowRuntime, IsolatedWorkflowRuntimeContext, LocalDirectoryMaterializerOptions, MaterializationError, MaterializedWorkspace, NodeWorkflowRunnerPackageOptions, OperationAdmissionRefusedError, OperationDeliveryEndpoint, OperationDeliveryEndpointIdentity, OperationDeliveryHandler, OperationDeliveryHandlers, OutcomeDeliveryError, OutcomeReconnect, OutcomeSubmitPayload, OutcomeSubmitRetryConfig, ParsedSriIntegrity, PiscinaThinWorkflowProvider, PiscinaThinWorkflowProviderOptions, RegisterAndAdmitWorkflowRunOptions, RegisterWorkerRuntimeOptions, RuntimeLoadedWorkflow, RuntimeRegistrationRefusedError, ThinWorkflowPiscinaRunner, ThinWorkflowPiscinaRunnerOptions, WorkerRunner, WorkerRunnerOptions, WorkflowRunResult, WorkflowRuntimeAuthorityConnector, WorkflowRuntimeContributionLoader, WorkflowWorkerEntryMode, WorkflowWorkerEntryResolverOptions, WorkspaceRootResolver, admitWorkflowRunOperation, assertContainedIn, assertNoSymlinkEscape, computeContributionPackageDigest, computeDirectoryDigest, computeFileDigest, createIsolatedWorkflowRuntime, createNodeWorkflowRunner, createNodeWorkflowRunnerPackageOptions, installOperationDeliveryEndpoint, loadWorkflowFromConfig, loadWorkflowModule, loadWorkflowModules, materializeLocalDirectory, parseSriIntegrity, registerAndAdmitWorkflowRun, registerWorkerRuntime, resolveWorkflowWorkerEntry, runHeadlessWorkflowWorker, submitOutcomeWithAck, verifyContribution };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as u,n as d,o as f,p,r as m,s as h,t as g,u as _,v,x as y,y as b}from"../../workflow-worker-
|
|
1
|
+
import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as u,n as d,o as f,p,r as m,s as h,t as g,u as _,v,x as y,y as b}from"../../workflow-worker-DjUfKshi.mjs";import{a as x,d as S,i as C,l as w,n as T,o as E,r as D,s as O,t as k,u as A}from"../../runtime-registration-client-BTtFpt_k.mjs";export{k as ALLOCATION_VISIBILITY_DEADLINE_MS,c as DELIVERED_DECISIONS,l as InProcessWorkflowRunner,p as MaterializationError,T as OperationAdmissionRefusedError,t as OutcomeDeliveryError,m as PiscinaThinWorkflowProvider,D as RuntimeRegistrationRefusedError,a as ThinWorkflowPiscinaRunner,_ as WorkerRunner,C as admitWorkflowRunOperation,u as assertContainedIn,s as assertNoSymlinkEscape,o as computeContributionPackageDigest,e as computeDirectoryDigest,v as computeFileDigest,d as createIsolatedWorkflowRuntime,h as createNodeWorkflowRunner,r as createNodeWorkflowRunnerPackageOptions,x as installOperationDeliveryEndpoint,w as loadWorkflowFromConfig,A as loadWorkflowModule,S as loadWorkflowModules,b as materializeLocalDirectory,n as parseSriIntegrity,E as registerAndAdmitWorkflowRun,O as registerWorkerRuntime,i as resolveWorkflowWorkerEntry,g as runHeadlessWorkflowWorker,f as submitOutcomeWithAck,y as verifyContribution};
|
|
@@ -2,14 +2,14 @@ import { WorkerContributionManifest, WorkflowRunResult } from "@makaio/framework
|
|
|
2
2
|
|
|
3
3
|
//#region runtimes/node/src/workflow-worker/worker-entry.d.ts
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Fields every worker-entry invocation carries, whatever gate it runs behind.
|
|
6
6
|
*
|
|
7
|
-
* Mirrors the shape passed by {@link ThinWorkflowPiscinaRunner
|
|
7
|
+
* Mirrors the shape passed by {@link ThinWorkflowPiscinaRunner} — the `config`
|
|
8
8
|
* is the raw (unserialized) `WorkflowWorkerConfig`, `manifest` declares the
|
|
9
9
|
* exact contribution identity, and `contributionEntrypoints` is the matching
|
|
10
10
|
* verified local realization returned by materialization.
|
|
11
11
|
*/
|
|
12
|
-
interface
|
|
12
|
+
interface WorkflowWorkerRunParamsBase {
|
|
13
13
|
/** Raw workflow worker configuration (will be validated by Zod schema). */
|
|
14
14
|
readonly config: unknown;
|
|
15
15
|
/** Contribution manifest declaring which extension packages to load. */
|
|
@@ -19,24 +19,64 @@ interface WorkflowWorkerRunParams {
|
|
|
19
19
|
/** Optional abort signal for cooperative cancellation. */
|
|
20
20
|
readonly signal?: AbortSignal;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Run parameters for a workflow no ExecutionAttempt owns.
|
|
24
|
+
*
|
|
25
|
+
* The host drove this run through {@link ThinWorkflowPiscinaRunner.run}: there
|
|
26
|
+
* is no attempt to register a runtime with, no start gate to pass, and no
|
|
27
|
+
* readiness fact to report to the pool.
|
|
28
|
+
*/
|
|
29
|
+
interface UnboundWorkerParams extends WorkflowWorkerRunParamsBase {
|
|
30
|
+
/**
|
|
31
|
+
* Discriminator selecting the attempt-free lifecycle.
|
|
32
|
+
*
|
|
33
|
+
* Named for the binding, not for the work: `workflow-run` is the wire
|
|
34
|
+
* operation kind the attempt-bound arm admits, and the two vocabularies must
|
|
35
|
+
* not overlap.
|
|
36
|
+
*/
|
|
37
|
+
readonly kind: 'unbound';
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Run parameters for a workflow an ExecutionAttempt owns.
|
|
41
|
+
*
|
|
42
|
+
* The attempt identifier is required: this arm proves the runtime to the
|
|
43
|
+
* Authority and admits the run through the attempt's start gate before it
|
|
44
|
+
* composes anything.
|
|
45
|
+
*/
|
|
46
|
+
interface AttemptBoundWorkerParams extends WorkflowWorkerRunParamsBase {
|
|
47
|
+
/** Discriminator selecting the attempt-bound lifecycle. */
|
|
48
|
+
readonly kind: 'attempt-bound';
|
|
49
|
+
/** Authority-created attempt this runtime registers itself as the endpoint of. */
|
|
50
|
+
readonly executionAttemptId: string;
|
|
51
|
+
}
|
|
52
|
+
/** Parameters accepted by the Piscina worker entrypoint. */
|
|
53
|
+
type WorkflowWorkerRunParams = UnboundWorkerParams | AttemptBoundWorkerParams;
|
|
22
54
|
/**
|
|
23
55
|
* Execute a complete workflow inside an isolated worker context.
|
|
24
56
|
*
|
|
25
57
|
* Implements the full worker lifecycle:
|
|
26
58
|
* 1. Parse and validate `config` against `WorkflowWorkerConfigSchema`
|
|
27
59
|
* 2. Boot an isolated bus instance (with optional WebSocket transport)
|
|
28
|
-
* 3.
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
60
|
+
* 3. Subscribe cancellation routing and, on the attempt-bound arm, prove this
|
|
61
|
+
* runtime to the Authority: install the operation delivery endpoint,
|
|
62
|
+
* register the runtime, and admit the run through the attempt's start gate
|
|
63
|
+
* 4. Load worker-local contributions from verified materialization output
|
|
64
|
+
* 5. Boot worker-local tool runtime if toolset contributions exist
|
|
65
|
+
* 6. Load the workflow module from the source descriptor
|
|
66
|
+
* 7. Run the workflow orchestrator
|
|
67
|
+
* 8. Always close the runtime (when booted) and bus in the `finally` block
|
|
68
|
+
*
|
|
69
|
+
* Registration precedes contribution loading, which is the whole point:
|
|
70
|
+
* readiness must not depend on what the runtime later composes.
|
|
33
71
|
*
|
|
34
72
|
* Contributions are loaded once per workflow, not once per step — the
|
|
35
73
|
* orchestrator owns step dispatch and reuses the same bus and runtime
|
|
36
74
|
* throughout the execution.
|
|
37
75
|
* @param params - Worker run parameters including config, verified contributions, and signal.
|
|
38
76
|
* @returns The terminal workflow run result.
|
|
77
|
+
* @throws {@link RuntimeRegistrationRefusedError} When the Authority refuses this runtime.
|
|
78
|
+
* @throws {@link OperationAdmissionRefusedError} When the Authority refuses the run.
|
|
39
79
|
*/
|
|
40
80
|
declare function runWorkflowInWorker(params: WorkflowWorkerRunParams): Promise<WorkflowRunResult>;
|
|
41
81
|
//#endregion
|
|
42
|
-
export { WorkflowWorkerRunParams, runWorkflowInWorker as default, runWorkflowInWorker };
|
|
82
|
+
export { AttemptBoundWorkerParams, UnboundWorkerParams, WorkflowWorkerRunParams, WorkflowWorkerRunParamsBase, runWorkflowInWorker as default, runWorkflowInWorker };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,
|
|
1
|
+
import{a as e,c as t,f as n,l as r,o as i}from"../../runtime-registration-client-BTtFpt_k.mjs";import{pathToFileURL as a}from"node:url";import*as o from"node:path";import{randomUUID as s}from"node:crypto";import{createBusInstance as c,waitForSubscriptionPropagation as l}from"@makaio/framework/bus";import{FrameworkContractNamespaces as u,FrameworkStorageNamespaces as d,WorkflowWorkerConfigSchema as f,createWorkflowCancelSubject as p}from"@makaio/framework/contracts";import{HmacAuth as m,WebSocketClientTransport as h}from"@makaio/framework/node/transports";import{runWorkflowOrchestrator as g}from"@makaio/framework/workflow-engine/workflow-orchestrator";import{parentPort as _}from"node:worker_threads";import{McpServerBridgeService as v}from"@makaio/framework/mcp-http-server";import{ToolRegistry as y}from"@makaio/framework/services/tools";async function b(e){let t=c();if(t.registerNamespaces(u),t.registerNamespaces(d),!e.busUrl)return{bus:t,close(){}};let n=e.busAuth.kind===`hmac`?new m({secret:e.busAuth.secret,...e.identityId!==void 0&&{identityId:e.identityId}}):void 0,r=new h({url:e.busUrl,auth:n,autoReconnect:!1});return t.registerTransport(r),await t.connect(),{bus:t,async close(){await t.disconnect()}}}async function x(e,t){let n=new y({bus:e.bus}),r=new v(e.bus),i=async()=>{try{await r.destroy()}finally{n.dispose()}};try{await r.init();for(let e of t.toolsets)await S(n,e)}catch(e){throw await i(),e}return{close:i}}async function S(e,t){await e.register(t)}function C(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.name==`string`?typeof t.tools==`object`&&t.tools!==null||Array.isArray(t.adapters):!1}function w(e,t){if(C(e.default))return e.default;for(let t of Object.keys(e))if(t!==`default`&&C(e[t]))return e[t]}function T(e){return Object.freeze({bus:e?.bus,identity:Object.freeze({extensionName:`__worker__`}),dataDir:``,machineId:``,platform:process.platform,homedir:``,makaioHome:``,username:``,signal:e?.signal??new AbortController().signal,tryImport:async()=>null,getService:()=>{throw Error(`Worker-local contribution context does not expose host services.`)},hasExtension:()=>!1})}async function E(e,t){let n=await Promise.all(e.map(e=>D(e,t))),r=[];for(let e of n)r.push(...e.toolsets);return{toolsets:r}}async function D(e,t){if(!o.isAbsolute(e))throw Error(`Worker contribution entrypoint must be an absolute materialized path: ${e}`);let n=w(await import(a(e).href),e);if(!n)throw Error(`No recognizable extension export in "${e}". Expected a default export or named export with a "name" field and "tools" or "adapters" surface.`);let r=[];if(n.tools?.createToolsets){let e=n.tools.createToolsets(T(t));r.push(...e)}return{toolsets:r}}async function O(a){let o=f.parse(a.config),c=new AbortController,u=()=>c.abort(),d=a.signal??c.signal;d!==c.signal&&(d.aborted?c.abort():d.addEventListener(`abort`,u,{once:!0}));let m,h,v,y;try{if(m=await b({busUrl:o.busUrl,busAuth:o.busAuth,...a.kind===`attempt-bound`?{identityId:a.executionAttemptId}:{}}),v=m.bus.on(p(o.cancelSubject),()=>{c.abort()}),await l(v),a.contributionEntrypoints.length!==a.manifest.contributionRefs.length)throw Error(`Worker contribution materialization does not match the declared contribution identity set.`);if(a.kind===`attempt-bound`){let t=s();y=await e(m.bus,{executionAttemptId:a.executionAttemptId,runtimeIncarnationId:t},{}),await i(m.bus,{executionAttemptId:a.executionAttemptId,runtimeIncarnationId:t,endpoint:y,signal:c.signal}),_?.postMessage(n(o.executionId,o.cancelSubject,a.executionAttemptId))}let u=await E(a.contributionEntrypoints,{bus:m.bus,signal:c.signal});u.toolsets.length>0&&(h=await x(m,u));let d=await r(o);return await g({config:await t(o,d,m.bus,c.signal),loaded:d,bus:m.bus,signal:c.signal})}finally{v?.(),y?.cleanup(),d.removeEventListener(`abort`,u);try{h&&await h.close()}finally{m&&await m.close()}}}export{O as default,O as runWorkflowInWorker};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pathToFileURL as e}from"node:url";import{mkdir as t,rm as n,writeFile as r}from"node:fs/promises";import{basename as i,join as a}from"node:path";import{randomBytes as o}from"node:crypto";import{waitForSubscriptionPropagation as s}from"@makaio/framework/bus";import{ExecutionAttemptSchemas as c,ExecutionAttemptSubjects as l,WorkflowDefinitionSchema as u,WorkflowError as d,WorkflowErrorCode as f}from"@makaio/framework/contracts";import{tmpdir as p}from"node:os";import{AUTOMATION_TRIGGER_BUILTINS_OWNER as m,AutomationTriggerBindingRuntime as h,busBackedAutomationTriggers as g}from"@makaio/framework/services/automation-trigger";import{assertWorkflowTriggerPayload as _,compileWorkflowTriggerBindingFilter as v}from"@makaio/framework/workflow-engine/workflow-trigger-binding-consumer";function y(e,t,n){return{type:`makaio.workflow-worker.ready`,executionId:e,cancelSubject:t,executionAttemptId:n}}function b(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`makaio.workflow-worker.ready`&&typeof t.executionId==`string`&&typeof t.cancelSubject==`string`&&typeof t.executionAttemptId==`string`}function x(e){if(typeof e!=`object`||!e)throw new d(f.NOT_EXECUTABLE,`Invalid workflow module default export: expected an object with 'definition' and 'runtimeHandlers', got ${typeof e}.`);let t=e;if(!(t.runtimeHandlers instanceof Map))throw new d(f.NOT_EXECUTABLE,`Invalid workflow module default export: 'runtimeHandlers' must be a Map instance.`);let n=u.safeParse(t.definition);if(!n.success)throw new d(f.NOT_EXECUTABLE,`Invalid workflow module default export: 'definition' must satisfy WorkflowDefinitionSchema. `+n.error.message);let r=S(t.zodSchemas)?t.zodSchemas:void 0,i=t.runtimeLoopGates;if(i!==void 0&&!(i instanceof Map))throw new d(f.NOT_EXECUTABLE,`Invalid workflow module default export: 'runtimeLoopGates' must be a Map instance when provided.`);return{definition:n.data,runtimeHandlers:t.runtimeHandlers,...r===void 0?{}:{zodSchemas:r},...i===void 0?{}:{runtimeLoopGates:i}}}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&`gates`in e}async function C(e,s){let c=i(e);if(!c||c===`.`||c===`..`)throw Error(`Invalid workflow source filename: ${e}`);let l=a(p(),`makaio-wf-${o(6).toString(`hex`)}`);await t(l,{recursive:!0});let u=a(l,c.endsWith(`.mjs`)?c:`${c}.mjs`);try{await r(u,s,`utf8`)}catch(e){throw await n(l,{recursive:!0,force:!0}).catch(()=>{}),e}return{tempDir:l,tempPath:u}}function w(e){return typeof e==`object`&&e&&Array.isArray(e.workflows)?e.workflows.map(x):[x(e)]}async function T(t){if(t.kind===`path`)return w((await import(e(t.path).href)).default);let{tempDir:r,tempPath:i}=await C(t.filename,t.source);try{return w((await import(e(i).href)).default)}finally{await n(r,{recursive:!0,force:!0})}}async function E(e){if(e.kind===`definition`)throw new d(f.NOT_EXECUTABLE,`Definition-sourced workers are handled by the workflow executor, not the file loader. Received source: ${JSON.stringify(e)}`);let t=await T(e);if(t.length!==1)throw new d(f.NOT_EXECUTABLE,`loadWorkflowModule expects a single workflow export, but the module exported ${String(t.length)} workflows. Use loadWorkflowModules for bundle exports.`);return t[0]}async function D(e){if(e.source.kind===`definition`){if(e.definition===void 0)throw Error(`Definition-sourced worker config for workflowId "${e.source.workflowId}" is missing the required 'definition' field. Ensure the executor populates WorkflowWorkerConfig.definition before dispatching.`);return{definition:e.definition,runtimeHandlers:new Map}}let t=await E(e.source);return O(e,t),e.definition===void 0?t:{...t,definition:e.definition}}function O(e,t){if(e.workflowId!==e.executionId&&t.definition.id!==e.workflowId)throw new d(f.SOURCE_MISMATCH,`Source-backed workflow for logical workflow '${e.workflowId}' loaded definition '${t.definition.id}'.`)}const k=`[WorkflowWorkerAwaitTrigger]`;function A(e){let t=g(e);return{resolveRegistration:e=>{let n=t.find(t=>t.kind===e);return n===void 0?void 0:{owner:m,type:n}}}}async function j(e,t,n){let r=new h(A(e)),i=t.flatMap(e=>{let t=r.prepareBinding(e);return t===void 0?(console.warn(`${k} skipping binding '${e.kind}': awaiting it inside a worker is unsupported. A worker carries only bus-backed trigger types; schedules and extension-contributed sources are activated by the host that owns their placement.`),[]):t.workflowCompatible?[{binding:e,prepared:t}]:(console.warn(`${k} skipping binding '${e.kind}': its event payload does not have an object root.`),[])});if(i.length===0){await r.close();return}try{if(n.aborted)throw n.reason??Error(`Await-trigger aborted`);let e=Promise.withResolvers();e.promise.catch(()=>void 0);let t=()=>{e.reject(n.reason??Error(`Await-trigger aborted`))};n.addEventListener(`abort`,t,{once:!0});try{return await Promise.all(i.map(async({binding:t,prepared:n})=>{let r=v(t);await n.subscribe(t=>{r(t.payload)&&e.resolve(_(t.payload))})})),await e.promise}finally{n.removeEventListener(`abort`,t)}}finally{await r.close()}}async function M(e,t,n,r){let i=t.definition.triggers??[];if(e.triggerMode!==`await-trigger`||i.length===0)return e;let a=await j(n,i,r);return a===void 0?e:{...e,triggerPayload:a}}async function N(e,t,n){if(e.operationKind===`runtime-probe`)return{receipt:`completed`};if(n===void 0||e.runtimeGeneration!==n)return{receipt:`refused`,refusalReason:`stale-generation`};let r=t[e.operationKind];return r===void 0?{receipt:`refused`,refusalReason:`unknown-kind`}:await r(e)}async function P(e,t,n){let{executionAttemptId:r,runtimeIncarnationId:i}=t,a=t.runtimeGeneration,o=e.withFilter({executionAttemptId:r,runtimeIncarnationId:i}).on(l.operation.deliver,async e=>{e.setResult(await N(e.payload,n,a))});return await s(o),{bindGeneration(e){a=e},cleanup(){let e=o;o=void 0,e?.()}}}var F=class extends Error{executionAttemptId;refusalReason;constructor(e,t){super(`Runtime registration refused by the Authority (executionAttemptId=${e}, refusalReason=${t??`unreported`})`),this.executionAttemptId=e,this.refusalReason=t,this.name=`RuntimeRegistrationRefusedError`}},I=class extends Error{executionAttemptId;admissionKey;refusalReason;constructor(e,t,n){super(`Operation admission refused by the Authority (executionAttemptId=${e}, admissionKey=${t}, refusalReason=${n??`unreported`})`),this.executionAttemptId=e,this.admissionKey=t,this.refusalReason=n,this.name=`OperationAdmissionRefusedError`}};function L(e,t,n,r){let i=t.safeParse(n);if(i.success)return i.data;let a=i.error.issues.map(e=>`${e.path.join(`.`)||`<root>`}: ${e.message}`);throw Error(`Malformed '${e.$meta.namespace}.${e.subject}' response from the Authority (executionAttemptId=${r}): ${a.join(`; `)}`)}const R=1e4;async function z(e,t){let{executionAttemptId:n,runtimeIncarnationId:r,signal:i}=t,a=Date.now()+(t.allocationVisibilityDeadlineMs??1e4);for(;;){i?.throwIfAborted();let t=L(l.runtime.register,c[`runtime.register`].response,await e.request(l.runtime.register,{executionAttemptId:n,runtimeIncarnationId:r},{signal:i}),n);if(t.decision!==`refused`)return t.runtimeGeneration;if(t.refusalReason!==`not-allocated`||Date.now()>=a)throw new F(n,t.refusalReason);await B(50,i)}}function B(e,t){return new Promise((n,r)=>{let i=()=>{clearTimeout(a),r(t?.reason instanceof Error?t.reason:Error(`Registration retry aborted`))},a=setTimeout(()=>{t?.removeEventListener(`abort`,i),n()},e);t?.addEventListener(`abort`,i,{once:!0})})}async function V(e,t){let{executionAttemptId:n,runtimeGeneration:r,admissionKey:i,signal:a}=t,o=L(l.operation.admit,c[`operation.admit`].response,await e.request(l.operation.admit,{executionAttemptId:n,operationKind:`workflow-run`,admissionKey:i,runtimeGeneration:r},{signal:a}),n);if(o.decision===`refused`)throw new I(n,i,o.refusalReason);if(o.operationId===void 0)throw Error(`Operation admission decision '${o.decision}' named no operation (executionAttemptId=${n}, admissionKey=${i})`);return o.operationId}async function H(e,t){let{executionAttemptId:n,runtimeIncarnationId:r,endpoint:i,signal:a}=t,o=await z(e,{executionAttemptId:n,runtimeIncarnationId:r,signal:a});return i.bindGeneration(o),{runtimeGeneration:o,operationId:await V(e,{executionAttemptId:n,runtimeGeneration:o,admissionKey:`workflow-run:${r}`,signal:a})}}export{P as a,M as c,T as d,y as f,V as i,D as l,I as n,H as o,b as p,F as r,z as s,R as t,E as u};
|
|
@@ -45,17 +45,17 @@ type SubagentTemplateSummary = z.infer<typeof SubagentTemplateSummarySchema>;
|
|
|
45
45
|
declare const SubagentTemplateCreateSchema: z.ZodObject<{
|
|
46
46
|
name: z.ZodString;
|
|
47
47
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
48
|
-
|
|
48
|
+
contextMode: z.ZodDefault<z.ZodEnum<{
|
|
49
|
+
fork: "fork";
|
|
50
|
+
fresh: "fresh";
|
|
51
|
+
}>>;
|
|
49
52
|
adapterName: z.ZodString;
|
|
53
|
+
providerConfigId: z.ZodOptional<z.ZodString>;
|
|
50
54
|
model: z.ZodOptional<z.ZodString>;
|
|
51
55
|
systemPrompt: z.ZodOptional<z.ZodString>;
|
|
52
56
|
allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
53
57
|
disallowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
54
58
|
allowedDirectories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
55
|
-
contextMode: z.ZodDefault<z.ZodEnum<{
|
|
56
|
-
fork: "fork";
|
|
57
|
-
fresh: "fresh";
|
|
58
|
-
}>>;
|
|
59
59
|
}, z.core.$strip>;
|
|
60
60
|
type SubagentTemplateCreate = z.infer<typeof SubagentTemplateCreateSchema>;
|
|
61
61
|
/**
|
|
@@ -130,17 +130,17 @@ declare const SubagentTemplateSettingsSchemas: {
|
|
|
130
130
|
request: z.ZodObject<{
|
|
131
131
|
name: z.ZodString;
|
|
132
132
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
133
|
-
|
|
133
|
+
contextMode: z.ZodDefault<z.ZodEnum<{
|
|
134
|
+
fork: "fork";
|
|
135
|
+
fresh: "fresh";
|
|
136
|
+
}>>;
|
|
134
137
|
adapterName: z.ZodString;
|
|
138
|
+
providerConfigId: z.ZodOptional<z.ZodString>;
|
|
135
139
|
model: z.ZodOptional<z.ZodString>;
|
|
136
140
|
systemPrompt: z.ZodOptional<z.ZodString>;
|
|
137
141
|
allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
138
142
|
disallowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
139
143
|
allowedDirectories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
140
|
-
contextMode: z.ZodDefault<z.ZodEnum<{
|
|
141
|
-
fork: "fork";
|
|
142
|
-
fresh: "fresh";
|
|
143
|
-
}>>;
|
|
144
144
|
}, z.core.$strip>;
|
|
145
145
|
response: z.ZodObject<{
|
|
146
146
|
id: z.ZodString;
|
|
@@ -191,9 +191,9 @@ declare const SubagentTemplateInstanceSchema: z.ZodObject<{
|
|
|
191
191
|
status: z.ZodEnum<{
|
|
192
192
|
completed: "completed";
|
|
193
193
|
cancelled: "cancelled";
|
|
194
|
-
failed: "failed";
|
|
195
194
|
running: "running";
|
|
196
195
|
waiting_input: "waiting_input";
|
|
196
|
+
failed: "failed";
|
|
197
197
|
}>;
|
|
198
198
|
createdAt: z.ZodString;
|
|
199
199
|
}, z.core.$strip>;
|
|
@@ -222,9 +222,9 @@ declare const SubagentTemplateInstanceStatusSchema: z.ZodObject<{
|
|
|
222
222
|
status: z.ZodEnum<{
|
|
223
223
|
completed: "completed";
|
|
224
224
|
cancelled: "cancelled";
|
|
225
|
-
failed: "failed";
|
|
226
225
|
running: "running";
|
|
227
226
|
waiting_input: "waiting_input";
|
|
227
|
+
failed: "failed";
|
|
228
228
|
}>;
|
|
229
229
|
result: z.ZodOptional<z.ZodString>;
|
|
230
230
|
error: z.ZodOptional<z.ZodString>;
|
|
@@ -274,9 +274,9 @@ declare const SubagentTemplateKernelSchemas: {
|
|
|
274
274
|
status: z.ZodEnum<{
|
|
275
275
|
completed: "completed";
|
|
276
276
|
cancelled: "cancelled";
|
|
277
|
-
failed: "failed";
|
|
278
277
|
running: "running";
|
|
279
278
|
waiting_input: "waiting_input";
|
|
279
|
+
failed: "failed";
|
|
280
280
|
}>;
|
|
281
281
|
result: z.ZodOptional<z.ZodString>;
|
|
282
282
|
error: z.ZodOptional<z.ZodString>;
|
|
@@ -143,8 +143,8 @@ declare const AdapterRuntimeSchemas: {
|
|
|
143
143
|
teardownCompleted: z.ZodObject<{
|
|
144
144
|
evidence: z.ZodEnum<{
|
|
145
145
|
unknown: "unknown";
|
|
146
|
-
exited: "exited";
|
|
147
146
|
closed: "closed";
|
|
147
|
+
exited: "exited";
|
|
148
148
|
released: "released";
|
|
149
149
|
detached: "detached";
|
|
150
150
|
}>;
|