@relayflows/sdk 2.0.35 → 2.0.37
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/adapters/base.d.ts +16 -0
- package/dist/adapters/base.d.ts.map +1 -1
- package/dist/adapters/claude.d.ts.map +1 -1
- package/dist/adapters/claude.js +15 -0
- package/dist/adapters/claude.js.map +1 -1
- package/dist/adapters/codex.d.ts.map +1 -1
- package/dist/adapters/codex.js +4 -0
- package/dist/adapters/codex.js.map +1 -1
- package/dist/adapters/usage-limit.d.ts +2 -0
- package/dist/adapters/usage-limit.d.ts.map +1 -0
- package/dist/adapters/usage-limit.js +17 -0
- package/dist/adapters/usage-limit.js.map +1 -0
- package/dist/authored-activity.d.ts +17 -0
- package/dist/authored-activity.d.ts.map +1 -0
- package/dist/authored-activity.js +218 -0
- package/dist/authored-activity.js.map +1 -0
- package/dist/authored-child-run.d.ts +34 -0
- package/dist/authored-child-run.d.ts.map +1 -0
- package/dist/authored-child-run.js +128 -0
- package/dist/authored-child-run.js.map +1 -0
- package/dist/authored-flow-error.d.ts +32 -3
- package/dist/authored-flow-error.d.ts.map +1 -1
- package/dist/authored-flow-error.js +3 -1
- package/dist/authored-flow-error.js.map +1 -1
- package/dist/authored-flow-executor.d.ts +11 -1
- package/dist/authored-flow-executor.d.ts.map +1 -1
- package/dist/authored-flow-executor.js +32 -1
- package/dist/authored-flow-executor.js.map +1 -1
- package/dist/authored-helper-effect.d.ts.map +1 -1
- package/dist/authored-helper-effect.js +3 -2
- package/dist/authored-helper-effect.js.map +1 -1
- package/dist/authored-mcp.d.ts.map +1 -1
- package/dist/authored-mcp.js +4 -2
- package/dist/authored-mcp.js.map +1 -1
- package/dist/authored-node-entry.js +9 -1
- package/dist/authored-node-entry.js.map +1 -1
- package/dist/authored-node-runner.d.ts.map +1 -1
- package/dist/authored-node-runner.js +42 -9
- package/dist/authored-node-runner.js.map +1 -1
- package/dist/authored-plugin-effect.d.ts.map +1 -1
- package/dist/authored-plugin-effect.js +4 -2
- package/dist/authored-plugin-effect.js.map +1 -1
- package/dist/authored-preflight.d.ts +1 -1
- package/dist/authored-preflight.d.ts.map +1 -1
- package/dist/authored-preflight.js +2 -2
- package/dist/authored-preflight.js.map +1 -1
- package/dist/authored-root.d.ts +12 -7
- package/dist/authored-root.d.ts.map +1 -1
- package/dist/authored-root.js +24 -0
- package/dist/authored-root.js.map +1 -1
- package/dist/authored-step-output.d.ts +24 -8
- package/dist/authored-step-output.d.ts.map +1 -1
- package/dist/authored-step-output.js +81 -15
- package/dist/authored-step-output.js.map +1 -1
- package/dist/authored-subscription-park.d.ts +5 -0
- package/dist/authored-subscription-park.d.ts.map +1 -0
- package/dist/authored-subscription-park.js +47 -0
- package/dist/authored-subscription-park.js.map +1 -0
- package/dist/authored-verdict.d.ts +2 -0
- package/dist/authored-verdict.d.ts.map +1 -1
- package/dist/authored-verdict.js +2 -1
- package/dist/authored-verdict.js.map +1 -1
- package/dist/authored-worker-step.d.ts +1 -1
- package/dist/authored-worker-step.d.ts.map +1 -1
- package/dist/authored-worker-step.js +9 -4
- package/dist/authored-worker-step.js.map +1 -1
- package/dist/cli/check-activities.d.ts +8 -0
- package/dist/cli/check-activities.d.ts.map +1 -0
- package/dist/cli/check-activities.js +155 -0
- package/dist/cli/check-activities.js.map +1 -0
- package/dist/cli/check.d.ts +2 -0
- package/dist/cli/check.d.ts.map +1 -1
- package/dist/cli/check.js +3 -3
- package/dist/cli/check.js.map +1 -1
- package/dist/cli/cli-probe.d.ts +2 -2
- package/dist/cli/cli-probe.d.ts.map +1 -1
- package/dist/cli/cli-probe.js +22 -9
- package/dist/cli/cli-probe.js.map +1 -1
- package/dist/cli/direct-run.d.ts.map +1 -1
- package/dist/cli/direct-run.js +17 -4
- package/dist/cli/direct-run.js.map +1 -1
- package/dist/cli/run.d.ts +18 -5
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +37 -12
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/subscription-report.d.ts +5 -0
- package/dist/cli/subscription-report.d.ts.map +1 -0
- package/dist/cli/subscription-report.js +48 -0
- package/dist/cli/subscription-report.js.map +1 -0
- package/dist/cli-adapter.d.ts +4 -2
- package/dist/cli-adapter.d.ts.map +1 -1
- package/dist/cli-adapter.js +4 -0
- package/dist/cli-adapter.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +13 -5
- package/dist/cli.js.map +1 -1
- package/dist/communication/local.d.ts +1 -1
- package/dist/communication/local.d.ts.map +1 -1
- package/dist/communication/local.js +2 -2
- package/dist/communication/local.js.map +1 -1
- package/dist/communication/worker.d.ts +1 -1
- package/dist/communication/worker.d.ts.map +1 -1
- package/dist/communication/worker.js +4 -4
- package/dist/communication/worker.js.map +1 -1
- package/dist/decimal-dollars.d.ts +12 -0
- package/dist/decimal-dollars.d.ts.map +1 -0
- package/dist/decimal-dollars.js +39 -0
- package/dist/decimal-dollars.js.map +1 -0
- package/dist/effect-channel.d.ts.map +1 -1
- package/dist/effect-channel.js +2 -0
- package/dist/effect-channel.js.map +1 -1
- package/dist/failure-kinds.d.ts +2 -2
- package/dist/failure-kinds.d.ts.map +1 -1
- package/dist/failure-kinds.js +2 -0
- package/dist/failure-kinds.js.map +1 -1
- package/dist/helper-instruction.d.ts +3 -0
- package/dist/helper-instruction.d.ts.map +1 -0
- package/dist/helper-instruction.js +3 -0
- package/dist/helper-instruction.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/journal-client.d.ts +21 -3
- package/dist/journal-client.d.ts.map +1 -1
- package/dist/journal-client.js +45 -6
- package/dist/journal-client.js.map +1 -1
- package/dist/journal-reader.d.ts.map +1 -1
- package/dist/journal-reader.js +2 -0
- package/dist/journal-reader.js.map +1 -1
- package/dist/llm-worker.d.ts +2 -1
- package/dist/llm-worker.d.ts.map +1 -1
- package/dist/llm-worker.js +7 -2
- package/dist/llm-worker.js.map +1 -1
- package/dist/local-agent-environment.d.ts +13 -0
- package/dist/local-agent-environment.d.ts.map +1 -0
- package/dist/local-agent-environment.js +104 -0
- package/dist/local-agent-environment.js.map +1 -0
- package/dist/local-agent.d.ts +4 -1
- package/dist/local-agent.d.ts.map +1 -1
- package/dist/local-agent.js +15 -5
- package/dist/local-agent.js.map +1 -1
- package/dist/preflight.d.ts +6 -0
- package/dist/preflight.d.ts.map +1 -1
- package/dist/preflight.js +36 -10
- package/dist/preflight.js.map +1 -1
- package/dist/protocol.d.ts +187 -1
- package/dist/protocol.d.ts.map +1 -1
- package/dist/reported-cost-total.d.ts +41 -0
- package/dist/reported-cost-total.d.ts.map +1 -0
- package/dist/reported-cost-total.js +63 -0
- package/dist/reported-cost-total.js.map +1 -0
- package/dist/reported-cost.d.ts +24 -0
- package/dist/reported-cost.d.ts.map +1 -0
- package/dist/reported-cost.js +49 -0
- package/dist/reported-cost.js.map +1 -0
- package/dist/run-state.d.ts +9 -11
- package/dist/run-state.d.ts.map +1 -1
- package/dist/run-state.js +15 -38
- package/dist/run-state.js.map +1 -1
- package/dist/step-settling.d.ts +11 -0
- package/dist/step-settling.d.ts.map +1 -0
- package/dist/step-settling.js +22 -0
- package/dist/step-settling.js.map +1 -0
- package/dist/worker-cli.d.ts +1 -1
- package/dist/worker-cli.d.ts.map +1 -1
- package/dist/worker-cli.js +3 -3
- package/dist/worker-cli.js.map +1 -1
- package/dist/worker.d.ts +2 -0
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +5 -2
- package/dist/worker.js.map +1 -1
- package/dist/yaml-helper-effect.d.ts.map +1 -1
- package/dist/yaml-helper-effect.js +2 -1
- package/dist/yaml-helper-effect.js.map +1 -1
- package/dist/yaml-helpers.d.ts.map +1 -1
- package/dist/yaml-helpers.js +2 -1
- package/dist/yaml-helpers.js.map +1 -1
- package/package.json +2 -2
- package/src/adapters/base.ts +19 -0
- package/src/adapters/claude.ts +15 -0
- package/src/adapters/codex.ts +6 -0
- package/src/adapters/usage-limit.ts +17 -0
- package/src/authored-activity.ts +251 -0
- package/src/authored-child-run.ts +138 -0
- package/src/authored-flow-error.ts +33 -0
- package/src/authored-flow-executor.ts +44 -1
- package/src/authored-helper-effect.ts +3 -2
- package/src/authored-mcp.ts +4 -2
- package/src/authored-node-entry.ts +11 -2
- package/src/authored-node-runner.ts +43 -9
- package/src/authored-plugin-effect.ts +4 -2
- package/src/authored-preflight.ts +2 -2
- package/src/authored-root.ts +34 -4
- package/src/authored-step-output.ts +88 -15
- package/src/authored-subscription-park.ts +46 -0
- package/src/authored-verdict.ts +2 -1
- package/src/authored-worker-step.ts +9 -3
- package/src/cli/check-activities.ts +144 -0
- package/src/cli/check.ts +6 -3
- package/src/cli/cli-probe.ts +23 -9
- package/src/cli/direct-run.ts +16 -1
- package/src/cli/run.ts +59 -14
- package/src/cli/subscription-report.ts +51 -0
- package/src/cli-adapter.ts +8 -2
- package/src/cli.ts +13 -6
- package/src/communication/local.ts +3 -2
- package/src/communication/worker.ts +7 -4
- package/src/decimal-dollars.ts +38 -0
- package/src/effect-channel.ts +2 -0
- package/src/failure-kinds.ts +2 -0
- package/src/helper-instruction.ts +2 -0
- package/src/index.ts +6 -0
- package/src/journal-client.ts +60 -7
- package/src/journal-reader.ts +2 -0
- package/src/llm-worker.ts +6 -1
- package/src/local-agent-environment.ts +92 -0
- package/src/local-agent.ts +19 -4
- package/src/preflight.ts +46 -10
- package/src/protocol.ts +151 -0
- package/src/reported-cost-total.ts +82 -0
- package/src/reported-cost.ts +51 -0
- package/src/run-state.ts +25 -37
- package/src/step-settling.ts +19 -0
- package/src/worker-cli.ts +3 -2
- package/src/worker.ts +9 -2
- package/src/yaml-helper-effect.ts +2 -1
- package/src/yaml-helpers.ts +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml-helper-effect.js","sourceRoot":"","sources":["../src/yaml-helper-effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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EAAE,aAAa,EAAE,aAAa;QAC/H,OAAO,EAAE,CAAC,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,QAAQ,CAAC,eAAe,EAAE,CAAC,EAAE,CAAC,CAAC;AAC7F,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml-helpers.d.ts","sourceRoot":"","sources":["../src/yaml-helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAA2C,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACxG,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"yaml-helpers.d.ts","sourceRoot":"","sources":["../src/yaml-helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAA2C,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACxG,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AA0DlF,MAAM,MAAM,UAAU,GAAG;KAAG,CAAC,IAAI,MAAM,gBAAgB,GAAG;SAAG,CAAC,IAAI,MAAM,gBAAgB,CAAC,CAAC,CAAC,GACzF;YAAE,IAAI,EAAE,QAAQ,CAAC;YAAC,QAAQ,EAAE,CAAC,CAAC;YAAC,IAAI,EAAE,CAAC,CAAC;YAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;SAAE;KACzE,CAAC,MAAM,gBAAgB,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC,MAAM,gBAAgB,CAAC,CAAC;AA2BvD,wEAAwE;AACxE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CA4BxD;AAED,sFAAsF;AACtF,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,GAAG,eAAe,CAAC,GAAG,UAAU,GAAG,SAAS,CAKjG;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAGhG"}
|
package/dist/yaml-helpers.js
CHANGED
|
@@ -2,6 +2,7 @@ import Ajv from 'ajv';
|
|
|
2
2
|
import { githubClient, linearClient, slackClient } from '@relayfile/relay-helpers';
|
|
3
3
|
import { canonicalize } from './canonical.js';
|
|
4
4
|
import { unknownKeyErrors } from './unknown-keys.js';
|
|
5
|
+
import { HELPER_INSTRUCTION_PREFIX } from './helper-instruction.js';
|
|
5
6
|
const string = { type: 'string', minLength: 1 };
|
|
6
7
|
const text = { type: 'string' };
|
|
7
8
|
const strings = { type: 'array', items: string };
|
|
@@ -40,7 +41,7 @@ const helpers = {
|
|
|
40
41
|
args: object(issueChanges, []) }), (p, transport) => linearClient({ transport }).updateIssue(p.issueId, p.args)),
|
|
41
42
|
},
|
|
42
43
|
};
|
|
43
|
-
const prefix =
|
|
44
|
+
const prefix = HELPER_INSTRUCTION_PREFIX;
|
|
44
45
|
const commonFields = ['id', 'dependsOn', 'maxIterations', 'verification', 'output'];
|
|
45
46
|
const isObject = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
46
47
|
function descriptor(provider, name) {
|
package/dist/yaml-helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml-helpers.js","sourceRoot":"","sources":["../src/yaml-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAuB,MAAM,0BAA0B,CAAC;AAExG,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"yaml-helpers.js","sourceRoot":"","sources":["../src/yaml-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;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aks the journal protocol.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
50
50
|
"@relayfile/adapter-core": "0.6.2",
|
|
51
51
|
"@relayfile/relay-helpers": "0.4.12",
|
|
52
|
-
"@relayflows/surface": "2.0.
|
|
52
|
+
"@relayflows/surface": "2.0.37",
|
|
53
53
|
"@types/js-yaml": "^4.0.9",
|
|
54
54
|
"acorn": "^8.18.0",
|
|
55
55
|
"ai-hist": "0.4.1",
|
package/src/adapters/base.ts
CHANGED
|
@@ -19,6 +19,19 @@ export interface CliInvocation {
|
|
|
19
19
|
modelEnv?: string;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Why a model-scoped readiness probe exited non-zero, when the CLI's own
|
|
24
|
+
* output says so. `model_unknown` is the only cause that means the model name
|
|
25
|
+
* or the credential's access to it is wrong; the others are the environment.
|
|
26
|
+
*/
|
|
27
|
+
export type ModelProbeFailureCause = 'model_unknown' | 'cli_outdated' | 'provider_usage_limited';
|
|
28
|
+
|
|
29
|
+
export interface ModelProbeFailure {
|
|
30
|
+
cause: ModelProbeFailureCause;
|
|
31
|
+
/** Minimum CLI version the provider named, for `cli_outdated`. */
|
|
32
|
+
requiredVersion?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
22
35
|
export interface CliAdapterIdentification {
|
|
23
36
|
invocation: CliInvocation;
|
|
24
37
|
expectedStdout?: string;
|
|
@@ -52,6 +65,12 @@ export interface HeadlessAdapter {
|
|
|
52
65
|
*/
|
|
53
66
|
buildModelReadinessProbe(model: string): CliInvocation;
|
|
54
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Classify a failed readiness probe from its combined output. Absent, or an
|
|
70
|
+
* `undefined` answer, means the output named no cause this adapter knows.
|
|
71
|
+
*/
|
|
72
|
+
classifyModelProbeFailure?(output: string): ModelProbeFailure | undefined;
|
|
73
|
+
|
|
55
74
|
/** Agent-step worker argv for an instruction under an optional model. */
|
|
56
75
|
buildAgentInvocation(instruction: string, model?: string): CliInvocation;
|
|
57
76
|
|
package/src/adapters/claude.ts
CHANGED
|
@@ -2,7 +2,9 @@ import type {
|
|
|
2
2
|
CliAdapterIdentification,
|
|
3
3
|
CliInvocation,
|
|
4
4
|
HeadlessAdapter,
|
|
5
|
+
ModelProbeFailure,
|
|
5
6
|
} from './base.js';
|
|
7
|
+
import { providerUsageLimited } from './usage-limit.js';
|
|
6
8
|
|
|
7
9
|
const MODEL_PROBE_PROMPT = 'Reply with exactly RELAYFLOWS_MODEL_READY and nothing else.';
|
|
8
10
|
|
|
@@ -30,6 +32,19 @@ export const claudeAdapter: HeadlessAdapter = {
|
|
|
30
32
|
};
|
|
31
33
|
},
|
|
32
34
|
|
|
35
|
+
classifyModelProbeFailure(output: string): ModelProbeFailure | undefined {
|
|
36
|
+
// Checked first: an older Claude Code also prints its own
|
|
37
|
+
// `unrecognized_model` catalog warning for a model newer than it, which
|
|
38
|
+
// must not read as the model being unknown to the provider.
|
|
39
|
+
const outdated = /does not support this model; version (\S+) or newer is required/.exec(output);
|
|
40
|
+
if (outdated !== null) return { cause: 'cli_outdated', requiredVersion: outdated[1]! };
|
|
41
|
+
if (providerUsageLimited(output)) return { cause: 'provider_usage_limited' };
|
|
42
|
+
if (/issue with the selected model|not_found_error|may not exist or you may not have access/i.test(output)) {
|
|
43
|
+
return { cause: 'model_unknown' };
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
},
|
|
47
|
+
|
|
33
48
|
buildAgentInvocation(instruction: string, model?: string): CliInvocation {
|
|
34
49
|
return {
|
|
35
50
|
args: [
|
package/src/adapters/codex.ts
CHANGED
|
@@ -2,7 +2,9 @@ import type {
|
|
|
2
2
|
CliAdapterIdentification,
|
|
3
3
|
CliInvocation,
|
|
4
4
|
HeadlessAdapter,
|
|
5
|
+
ModelProbeFailure,
|
|
5
6
|
} from './base.js';
|
|
7
|
+
import { providerUsageLimited } from './usage-limit.js';
|
|
6
8
|
|
|
7
9
|
const MODEL_PROBE_PROMPT = 'Reply with exactly RELAYFLOWS_MODEL_READY and nothing else.';
|
|
8
10
|
|
|
@@ -29,6 +31,10 @@ export const codexAdapter: HeadlessAdapter = {
|
|
|
29
31
|
};
|
|
30
32
|
},
|
|
31
33
|
|
|
34
|
+
classifyModelProbeFailure(output: string): ModelProbeFailure | undefined {
|
|
35
|
+
return providerUsageLimited(output) ? { cause: 'provider_usage_limited' } : undefined;
|
|
36
|
+
},
|
|
37
|
+
|
|
32
38
|
buildAgentInvocation(instruction: string, model?: string): CliInvocation {
|
|
33
39
|
return {
|
|
34
40
|
args: [
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider refusals that mean "this credential is out of capacity right now",
|
|
3
|
+
* not "this model does not exist". Shared by raw provider adapters because the
|
|
4
|
+
* wording overlaps (HTTP 429, `rate_limit_error`, subscription usage windows).
|
|
5
|
+
*/
|
|
6
|
+
const USAGE_LIMITED = [
|
|
7
|
+
/usage limit/i,
|
|
8
|
+
/hit your (?:usage )?limit/i,
|
|
9
|
+
/(?:5-hour|weekly|session) limit reached/i,
|
|
10
|
+
/rate_limit_error/,
|
|
11
|
+
/API Error: 429\b/,
|
|
12
|
+
/credit balance is too low/i,
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
export function providerUsageLimited(output: string): boolean {
|
|
16
|
+
return USAGE_LIMITED.some(pattern => pattern.test(output));
|
|
17
|
+
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Activity,
|
|
3
|
+
ActivityDuration,
|
|
4
|
+
ActivityOptions,
|
|
5
|
+
EventFrame,
|
|
6
|
+
TriggerSource,
|
|
7
|
+
WebhookTriggerSource,
|
|
8
|
+
Wake,
|
|
9
|
+
} from '@relayflows/surface';
|
|
10
|
+
import type { SubscriptionNextResult } from './protocol.js';
|
|
11
|
+
import { AuthoredFlowExecutionError, type AuthoredFlowSuspension } from './authored-flow-error.js';
|
|
12
|
+
import { JournalClient } from './journal-client.js';
|
|
13
|
+
|
|
14
|
+
type CloseReason = 'closed' | 'run_completed' | 'canceled';
|
|
15
|
+
|
|
16
|
+
interface OpenActivity {
|
|
17
|
+
readonly activity: Activity;
|
|
18
|
+
close(reason: CloseReason): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Owns body-local cursors that must close before the authored root completes. */
|
|
22
|
+
export class AuthoredActivities {
|
|
23
|
+
private readonly activities: OpenActivity[] = [];
|
|
24
|
+
|
|
25
|
+
constructor(
|
|
26
|
+
private readonly journal: JournalClient,
|
|
27
|
+
private readonly runId: string | undefined,
|
|
28
|
+
) {}
|
|
29
|
+
|
|
30
|
+
open(source: TriggerSource, options: ActivityOptions): Activity {
|
|
31
|
+
if (source?.kind !== 'webhook') {
|
|
32
|
+
throw new AuthoredFlowExecutionError('unsupported_header',
|
|
33
|
+
'f.on() requires an event source; schedule triggers start runs and cannot be awaited inside a body');
|
|
34
|
+
}
|
|
35
|
+
if (this.runId === undefined) {
|
|
36
|
+
throw new AuthoredFlowExecutionError('journal_protocol_violation', 'f.on() requires a durable authored root run');
|
|
37
|
+
}
|
|
38
|
+
const id = `activity-${this.activities.length + 1}`;
|
|
39
|
+
const activity = new JournalActivity(this.journal, this.runId, id, source, normalizeOptions(options));
|
|
40
|
+
this.activities.push(activity);
|
|
41
|
+
return activity.activity;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async closeAll(reason: Exclude<CloseReason, 'closed'>): Promise<void> {
|
|
45
|
+
for (const activity of this.activities) await activity.close(reason);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
class JournalActivity implements OpenActivity {
|
|
50
|
+
readonly activity: Activity;
|
|
51
|
+
private readonly openPromise: Promise<void>;
|
|
52
|
+
private closed = false;
|
|
53
|
+
private nextSequence = 0;
|
|
54
|
+
private acknowledgeWaitId: string | undefined;
|
|
55
|
+
|
|
56
|
+
constructor(
|
|
57
|
+
private readonly journal: JournalClient,
|
|
58
|
+
private readonly runId: string,
|
|
59
|
+
private readonly subscriptionId: string,
|
|
60
|
+
private readonly source: WebhookTriggerSource,
|
|
61
|
+
private readonly options: NormalizedActivityOptions,
|
|
62
|
+
) {
|
|
63
|
+
this.activity = Object.freeze({
|
|
64
|
+
next: () => this.next(),
|
|
65
|
+
close: () => this.close('closed'),
|
|
66
|
+
});
|
|
67
|
+
// Opening starts at f.on(), rather than at the first next(), so frames
|
|
68
|
+
// arriving while the body reads state or runs another step are inside the
|
|
69
|
+
// router's binding window. next()/close() await this same handshake.
|
|
70
|
+
this.openPromise = this.openNow();
|
|
71
|
+
void this.openPromise.catch(() => undefined);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async close(reason: CloseReason): Promise<void> {
|
|
75
|
+
if (this.closed) return;
|
|
76
|
+
try {
|
|
77
|
+
await this.ensureOpen();
|
|
78
|
+
} catch (error) {
|
|
79
|
+
// Failure cleanup has no active binding to close before activation.
|
|
80
|
+
// Re-throwing this handoff would disguise a real body failure as a
|
|
81
|
+
// normal suspension. Root termination fences any later activation.
|
|
82
|
+
if (reason !== 'closed' && error instanceof AuthoredFlowExecutionError
|
|
83
|
+
&& error.code === 'subscription_suspended' && error.suspension?.kind === 'activation') return;
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
await this.journal.subscriptionClose({
|
|
87
|
+
run_id: this.runId,
|
|
88
|
+
subscription_id: this.subscriptionId,
|
|
89
|
+
completion_reason: reason,
|
|
90
|
+
});
|
|
91
|
+
this.closed = true;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private async next(): Promise<Wake> {
|
|
95
|
+
if (this.closed) throw new AuthoredFlowExecutionError('activity_closed', 'activity is already closed');
|
|
96
|
+
await this.ensureOpen();
|
|
97
|
+
const result = await this.journal.subscriptionNext({
|
|
98
|
+
run_id: this.runId,
|
|
99
|
+
subscription_id: this.subscriptionId,
|
|
100
|
+
sequence: this.nextSequence,
|
|
101
|
+
...(this.acknowledgeWaitId === undefined ? {} : { acknowledge_wait_id: this.acknowledgeWaitId }),
|
|
102
|
+
});
|
|
103
|
+
if (result.kind === 'suspended') {
|
|
104
|
+
throw suspended({
|
|
105
|
+
kind: 'event_wait', subscriptionId: result.subscription_id,
|
|
106
|
+
stream: result.stream, deadlineAtMs: result.deadline_at_ms,
|
|
107
|
+
}, this.runId);
|
|
108
|
+
}
|
|
109
|
+
const wake = decodeWake(result);
|
|
110
|
+
if (wake.kind === 'deadline' || wake.kind === 'overflow') {
|
|
111
|
+
this.closed = true;
|
|
112
|
+
} else {
|
|
113
|
+
this.acknowledgeWaitId = receiptId(result) ?? `${this.subscriptionId}/next/${this.nextSequence}`;
|
|
114
|
+
this.nextSequence += 1;
|
|
115
|
+
}
|
|
116
|
+
return wake;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private async ensureOpen(): Promise<void> {
|
|
120
|
+
await this.openPromise;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private async openNow(): Promise<void> {
|
|
124
|
+
const result = await this.journal.subscriptionOpen({
|
|
125
|
+
run_id: this.runId,
|
|
126
|
+
subscription_id: this.subscriptionId,
|
|
127
|
+
event_types: [this.source.name],
|
|
128
|
+
...(this.source.filter === undefined ? {} : { pattern: this.source.filter }),
|
|
129
|
+
settle_ms: this.options.settleMs,
|
|
130
|
+
idle_ms: this.options.idleMs,
|
|
131
|
+
deadline_ms: this.options.deadlineMs,
|
|
132
|
+
include_self: this.options.includeSelf,
|
|
133
|
+
});
|
|
134
|
+
if (result.state === 'prepared') {
|
|
135
|
+
throw suspended({
|
|
136
|
+
kind: 'activation', subscriptionId: result.subscription_id,
|
|
137
|
+
eventTypes: Object.freeze([...result.event_types]),
|
|
138
|
+
...(result.pattern === undefined ? {} : { pattern: Object.freeze({ ...result.pattern }) }),
|
|
139
|
+
stream: result.stream, settleMs: result.settle_ms, idleMs: result.idle_ms,
|
|
140
|
+
deadlineAtMs: result.deadline_at_ms, includeSelf: result.include_self,
|
|
141
|
+
}, this.runId);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function suspended(value: AuthoredFlowSuspension, runId: string): AuthoredFlowExecutionError {
|
|
147
|
+
return new AuthoredFlowExecutionError(
|
|
148
|
+
'subscription_suspended',
|
|
149
|
+
`subscription ${value.subscriptionId} is durably suspended for ${value.kind}`,
|
|
150
|
+
undefined,
|
|
151
|
+
runId,
|
|
152
|
+
undefined,
|
|
153
|
+
value,
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function receiptId(result: SubscriptionNextResult): string | undefined {
|
|
158
|
+
const receipt = (result as { acknowledge_wait_id?: unknown }).acknowledge_wait_id;
|
|
159
|
+
return typeof receipt === 'string' && receipt.length > 0 ? receipt : undefined;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
interface NormalizedActivityOptions {
|
|
163
|
+
readonly settleMs: number;
|
|
164
|
+
readonly idleMs: number;
|
|
165
|
+
readonly deadlineMs: number;
|
|
166
|
+
readonly includeSelf: boolean;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function normalizeOptions(options: ActivityOptions): NormalizedActivityOptions {
|
|
170
|
+
if (typeof options !== 'object' || options === null || Array.isArray(options)) {
|
|
171
|
+
throw unboundedSubscription('f.on() requires idle and deadline bounds');
|
|
172
|
+
}
|
|
173
|
+
const value = options as unknown as Record<string, unknown>;
|
|
174
|
+
const allowed = new Set(['settle', 'idle', 'deadline', 'includeSelf']);
|
|
175
|
+
for (const key of Object.keys(value)) {
|
|
176
|
+
if (!allowed.has(key)) throw new AuthoredFlowExecutionError('unbounded_subscription', `f.on() has unknown option ${JSON.stringify(key)}`);
|
|
177
|
+
}
|
|
178
|
+
if (!Object.hasOwn(value, 'idle') || !Object.hasOwn(value, 'deadline')) {
|
|
179
|
+
throw unboundedSubscription('f.on() requires both idle and deadline bounds');
|
|
180
|
+
}
|
|
181
|
+
if (value['includeSelf'] !== undefined && typeof value['includeSelf'] !== 'boolean') {
|
|
182
|
+
throw new AuthoredFlowExecutionError('unbounded_subscription', 'f.on() includeSelf must be a boolean');
|
|
183
|
+
}
|
|
184
|
+
return Object.freeze({
|
|
185
|
+
settleMs: parseDuration(value['settle'] as ActivityDuration | undefined, 'settle', true),
|
|
186
|
+
idleMs: parseDuration(value['idle'] as ActivityDuration, 'idle', false),
|
|
187
|
+
deadlineMs: parseDuration(value['deadline'] as ActivityDuration, 'deadline', false),
|
|
188
|
+
includeSelf: value['includeSelf'] === true,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function parseDuration(value: ActivityDuration | undefined, field: string, zeroAllowed: boolean): number {
|
|
193
|
+
if (value === undefined && zeroAllowed) return 0;
|
|
194
|
+
let milliseconds: number;
|
|
195
|
+
if (typeof value === 'number') milliseconds = value;
|
|
196
|
+
else if (typeof value === 'string') {
|
|
197
|
+
const match = /^(\d+(?:\.\d+)?)(ms|s|m|h|d)$/.exec(value);
|
|
198
|
+
const units: Record<string, number> = { ms: 1, s: 1_000, m: 60_000, h: 3_600_000, d: 86_400_000 };
|
|
199
|
+
const unit = match?.[2];
|
|
200
|
+
milliseconds = match === null || unit === undefined ? NaN : Math.round(Number(match[1]) * units[unit]!);
|
|
201
|
+
} else milliseconds = NaN;
|
|
202
|
+
if (!Number.isSafeInteger(milliseconds) || milliseconds < 0 || (!zeroAllowed && milliseconds === 0)) {
|
|
203
|
+
throw new AuthoredFlowExecutionError(
|
|
204
|
+
'unbounded_subscription',
|
|
205
|
+
`f.on() ${field} must be ${zeroAllowed ? 'a non-negative' : 'a positive'} whole number of milliseconds or a duration such as "72h"`,
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
return milliseconds;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function unboundedSubscription(message: string): AuthoredFlowExecutionError {
|
|
212
|
+
return new AuthoredFlowExecutionError('unbounded_subscription', message);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** Decode the wire result at the journal boundary so malformed wakes fail closed. */
|
|
216
|
+
export function decodeWake(value: SubscriptionNextResult): Wake {
|
|
217
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) return invalidWake();
|
|
218
|
+
if (value.kind === 'idle') return Object.freeze({ kind: 'idle' });
|
|
219
|
+
if (value.kind === 'events') {
|
|
220
|
+
if (!Array.isArray(value.events) || !isOffset(value.offset) || !value.events.every(isEventFrame)) return invalidWake();
|
|
221
|
+
return Object.freeze({ kind: 'events', events: Object.freeze([...value.events]) as readonly EventFrame[], offset: value.offset });
|
|
222
|
+
}
|
|
223
|
+
if (value.kind === 'deadline') {
|
|
224
|
+
if (value.pending !== null && !isPending(value.pending)) return invalidWake();
|
|
225
|
+
return Object.freeze({ kind: 'deadline', pending: value.pending === null ? null : Object.freeze({ ...value.pending }) });
|
|
226
|
+
}
|
|
227
|
+
if (value.kind === 'overflow') {
|
|
228
|
+
if (!isOffset(value.retained) || !isOffset(value.bytes) || !isOffset(value.from)) return invalidWake();
|
|
229
|
+
return Object.freeze({ kind: 'overflow', retained: value.retained, bytes: value.bytes, from: value.from });
|
|
230
|
+
}
|
|
231
|
+
return invalidWake();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function isEventFrame(value: unknown): value is EventFrame {
|
|
235
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
236
|
+
&& typeof (value as { type?: unknown }).type === 'string';
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function isPending(value: unknown): value is { from: number; to: number } {
|
|
240
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
241
|
+
&& isOffset((value as { from?: unknown }).from)
|
|
242
|
+
&& isOffset((value as { to?: unknown }).to);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function isOffset(value: unknown): value is number {
|
|
246
|
+
return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function invalidWake(): never {
|
|
250
|
+
throw new AuthoredFlowExecutionError('journal_protocol_violation', 'subscription.next returned an invalid wake result');
|
|
251
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { delay, LEASE_SWEEP_GRACE_MS } from './cli/run.js';
|
|
2
|
+
import type { JournalClient } from './journal-client.js';
|
|
3
|
+
import type { RunGetResult, RunStatus } from './protocol.js';
|
|
4
|
+
|
|
5
|
+
/** One `journal.read` page; the kernel caps an unbounded read at 100 entries. */
|
|
6
|
+
const PAGE = 1_000;
|
|
7
|
+
const POLL_MS = 50;
|
|
8
|
+
// A run between two of its own actions can report `running` with nothing in
|
|
9
|
+
// flight for a moment (a wait just completed, the next attempt not yet
|
|
10
|
+
// journaled). The same bound `classifyOutcome` gives that window (#179).
|
|
11
|
+
const MAX_IDLE_POLLS = 40;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Every entry of a child run's journal, paged.
|
|
15
|
+
*
|
|
16
|
+
* A single unbounded read returns the first 100 entries only, and a reader
|
|
17
|
+
* that needs the LAST completion of a step cannot stop at a page boundary.
|
|
18
|
+
* A short page is the end of the journal.
|
|
19
|
+
*/
|
|
20
|
+
export async function readChildJournal(journal: JournalClient, runId: string): Promise<unknown[]> {
|
|
21
|
+
const all: unknown[] = [];
|
|
22
|
+
let fromSeq = 1;
|
|
23
|
+
while (true) {
|
|
24
|
+
const { entries } = await journal.journalRead(runId, fromSeq, PAGE);
|
|
25
|
+
all.push(...entries);
|
|
26
|
+
if (entries.length < PAGE) return all;
|
|
27
|
+
const last = entries.at(-1) as { seq?: unknown } | undefined;
|
|
28
|
+
if (typeof last?.seq !== 'number' || !Number.isSafeInteger(last.seq) || last.seq < fromSeq) {
|
|
29
|
+
throw new Error(`invalid journal sequence reading child run "${runId}"`);
|
|
30
|
+
}
|
|
31
|
+
fromSeq = last.seq + 1;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Wait until an authored operation's child run is terminal, and say whether
|
|
37
|
+
* it got there.
|
|
38
|
+
*
|
|
39
|
+
* A child adopted through its admission key is not necessarily finished: on
|
|
40
|
+
* `flows resume` of a root whose daemon survived, `run.start` returns the
|
|
41
|
+
* existing child's CURRENT outcome without driving it, so the child may still
|
|
42
|
+
* be executing an attempt, or sleeping out a retry backoff, on the request
|
|
43
|
+
* that originally started it. Reading its journal then judges a history that
|
|
44
|
+
* is still being written.
|
|
45
|
+
*
|
|
46
|
+
* The wait is read-only on purpose: it never resumes the child. The kernel
|
|
47
|
+
* drives a deterministic attempt inline on the request that started it, and a
|
|
48
|
+
* second driver would presume that attempt dead and run the command again.
|
|
49
|
+
*
|
|
50
|
+
* Bounded by the child's own journaled deadlines, never a fixed one: a running
|
|
51
|
+
* attempt by its lease (renewed as the lease renews) plus the kernel's
|
|
52
|
+
* lease-sweep grace, a backoff by the `sleep.until` it journaled (once that
|
|
53
|
+
* wake has passed, by the settling window). With nothing in flight, only the
|
|
54
|
+
* short settling window above; a child parked on a worker
|
|
55
|
+
* returns at once. Either way the caller gets the status and decides.
|
|
56
|
+
*/
|
|
57
|
+
export async function waitForTerminalChildRun(
|
|
58
|
+
journal: JournalClient,
|
|
59
|
+
runId: string,
|
|
60
|
+
signal?: AbortSignal,
|
|
61
|
+
): Promise<RunStatus> {
|
|
62
|
+
let idlePolls = 0;
|
|
63
|
+
while (true) {
|
|
64
|
+
if (signal?.aborted === true) throw new Error(`waiting for child run "${runId}" was canceled`);
|
|
65
|
+
const snapshot = await journal.runGet(runId);
|
|
66
|
+
if (snapshot.status === 'completed' || snapshot.status === 'failed') return snapshot.status;
|
|
67
|
+
const inFlight = await inFlightDeadline(journal, runId, snapshot);
|
|
68
|
+
if (inFlight === 'parked') return snapshot.status;
|
|
69
|
+
const remainingMs = inFlight === undefined ? 0 : inFlight.deadlineMs + inFlight.graceMs - Date.now();
|
|
70
|
+
if (inFlight !== undefined && remainingMs > 0) {
|
|
71
|
+
idlePolls = 0;
|
|
72
|
+
await delay(Math.min(POLL_MS, remainingMs), signal);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
// Only a lease past its sweep grace is proof nothing is running the
|
|
76
|
+
// attempt. An elapsed retry wake is the kernel's normal transition to the
|
|
77
|
+
// next attempt — its driver may be folding the timer right now — so it is
|
|
78
|
+
// re-polled inside the settling window like any other in-between state.
|
|
79
|
+
if (inFlight?.what === 'lease') {
|
|
80
|
+
throw new Error(`child run "${runId}" step "${inFlight.stepId}" passed its lease`
|
|
81
|
+
+ ` (${inFlight.deadlineMs}) without reaching a terminal state`);
|
|
82
|
+
}
|
|
83
|
+
if (idlePolls >= MAX_IDLE_POLLS) return snapshot.status;
|
|
84
|
+
idlePolls += 1;
|
|
85
|
+
await delay(POLL_MS, signal);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
interface InFlight {
|
|
90
|
+
stepId: string;
|
|
91
|
+
what: 'lease' | 'retry backoff';
|
|
92
|
+
deadlineMs: number;
|
|
93
|
+
graceMs: number;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* What the child is waiting on, and until when; `parked` when it is waiting
|
|
98
|
+
* on nothing this process can wait out.
|
|
99
|
+
*
|
|
100
|
+
* A worker-typed (`agent`/`llm`) step that is runnable, or whose retry
|
|
101
|
+
* backoff has elapsed, with no attempt running, needs a worker — or the
|
|
102
|
+
* `run.resume` a caller like `classifyOutcome` issues — to move. That is the
|
|
103
|
+
* park `classifyOutcome` reports, and waiting on it would only delay the same
|
|
104
|
+
* answer. A deterministic step in that state is the kernel between two of its
|
|
105
|
+
* own actions, which the caller's settling window covers.
|
|
106
|
+
*/
|
|
107
|
+
async function inFlightDeadline(
|
|
108
|
+
journal: JournalClient,
|
|
109
|
+
runId: string,
|
|
110
|
+
snapshot: RunGetResult,
|
|
111
|
+
): Promise<InFlight | 'parked' | undefined> {
|
|
112
|
+
const steps = Object.entries(snapshot.steps);
|
|
113
|
+
const running = steps.find(([, step]) => step.state === 'running' && step.lease_deadline_ms !== undefined);
|
|
114
|
+
if (running !== undefined) {
|
|
115
|
+
return {
|
|
116
|
+
stepId: running[0], what: 'lease', deadlineMs: running[1].lease_deadline_ms!, graceMs: LEASE_SWEEP_GRACE_MS,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const worker = ([, step]: [string, { type: string }]) => step.type !== 'deterministic';
|
|
120
|
+
if (steps.some(entry => worker(entry) && entry[1].state === 'runnable')) return 'parked';
|
|
121
|
+
const backoff = steps.find(([, step]) => step.state === 'backoff');
|
|
122
|
+
if (backoff === undefined) return undefined;
|
|
123
|
+
const wakeAtMs = (await readChildJournal(journal, runId))
|
|
124
|
+
.map(entry => retryWake(entry, backoff[0]))
|
|
125
|
+
.filter((value): value is number => value !== undefined)
|
|
126
|
+
.at(-1);
|
|
127
|
+
if (wakeAtMs === undefined) return undefined;
|
|
128
|
+
if (wakeAtMs <= Date.now()) return worker(backoff) ? 'parked' : undefined;
|
|
129
|
+
return { stepId: backoff[0], what: 'retry backoff', deadlineMs: wakeAtMs, graceMs: 0 };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function retryWake(entry: unknown, stepId: string): number | undefined {
|
|
133
|
+
if (typeof entry !== 'object' || entry === null) return undefined;
|
|
134
|
+
const { entry_type: type, step_id: step, payload } = entry as Record<string, unknown>;
|
|
135
|
+
if (type !== 'sleep.until' || step !== stepId || typeof payload !== 'object' || payload === null) return undefined;
|
|
136
|
+
const wakeAtMs = (payload as Record<string, unknown>)['wake_at_ms'];
|
|
137
|
+
return typeof wakeAtMs === 'number' && Number.isFinite(wakeAtMs) ? wakeAtMs : undefined;
|
|
138
|
+
}
|
|
@@ -11,6 +11,10 @@ export type AuthoredFlowExecutionErrorCode =
|
|
|
11
11
|
| 'helper_slack.credential_missing'
|
|
12
12
|
| 'helper_slack.mount_required'
|
|
13
13
|
| 'budget_syntax_invalid'
|
|
14
|
+
/** The step's CLI is too old for its model — an environment refusal, not a spec error. */
|
|
15
|
+
| 'cli_outdated'
|
|
16
|
+
/** The step's credential hit a provider usage/rate limit during preflight. */
|
|
17
|
+
| 'provider_usage_limited'
|
|
14
18
|
| 'agent_cli_unresolved'
|
|
15
19
|
| 'agent_parked'
|
|
16
20
|
| 'llm_cli_unresolved'
|
|
@@ -39,6 +43,9 @@ export type AuthoredFlowExecutionErrorCode =
|
|
|
39
43
|
| 'unsettled_derived_work'
|
|
40
44
|
| 'unsupported_promise_lifecycle'
|
|
41
45
|
| 'unsupported_workspace_permission'
|
|
46
|
+
| 'unbounded_subscription'
|
|
47
|
+
| 'activity_closed'
|
|
48
|
+
| 'subscription_suspended'
|
|
42
49
|
| 'unawaited_step'
|
|
43
50
|
| 'unsupported_verb';
|
|
44
51
|
|
|
@@ -76,12 +83,38 @@ export class AuthoredFlowExecutionError extends Error {
|
|
|
76
83
|
* Node-child error frame — can forward it instead of dropping it.
|
|
77
84
|
*/
|
|
78
85
|
readonly details?: StepFailedDetails,
|
|
86
|
+
readonly suspension?: AuthoredFlowSuspension,
|
|
79
87
|
) {
|
|
80
88
|
super(`${code}: ${message}`);
|
|
81
89
|
this.name = 'AuthoredFlowExecutionError';
|
|
82
90
|
}
|
|
83
91
|
}
|
|
84
92
|
|
|
93
|
+
/** Serialized into the CLI report so Cloud can atomically finish activation or wait for a wake. */
|
|
94
|
+
export type AuthoredFlowSuspension =
|
|
95
|
+
/**
|
|
96
|
+
* Exact durable `subscription.prepared` facts Cloud must persist before it
|
|
97
|
+
* fences provider ingress and invokes `subscription.activate`. Binding
|
|
98
|
+
* generation and ingress cursor are Cloud-assigned receipts, deliberately
|
|
99
|
+
* absent from the authored request.
|
|
100
|
+
*/
|
|
101
|
+
| {
|
|
102
|
+
readonly kind: 'activation';
|
|
103
|
+
readonly subscriptionId: string;
|
|
104
|
+
readonly eventTypes: readonly string[];
|
|
105
|
+
readonly pattern?: Readonly<Record<string, unknown>>;
|
|
106
|
+
readonly stream: string;
|
|
107
|
+
readonly settleMs: number;
|
|
108
|
+
readonly idleMs: number;
|
|
109
|
+
readonly deadlineAtMs: number;
|
|
110
|
+
readonly includeSelf: boolean;
|
|
111
|
+
}
|
|
112
|
+
| {
|
|
113
|
+
readonly kind: 'event_wait';
|
|
114
|
+
readonly subscriptionId: string;
|
|
115
|
+
readonly stream: string;
|
|
116
|
+
readonly deadlineAtMs: number;
|
|
117
|
+
};
|
|
85
118
|
/** The question an authored body parked on, as the kernel journals it. */
|
|
86
119
|
export interface AuthoredHumanWait {
|
|
87
120
|
readonly waitId: string;
|