@relayflows/sdk 2.0.15 → 2.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-artifacts.d.ts +20 -0
- package/dist/agent-artifacts.d.ts.map +1 -0
- package/dist/agent-artifacts.js +81 -0
- package/dist/agent-artifacts.js.map +1 -0
- package/dist/authored-flow-error.d.ts +1 -1
- package/dist/authored-flow-error.d.ts.map +1 -1
- package/dist/authored-flow-error.js.map +1 -1
- package/dist/authored-flow-executor.d.ts +3 -3
- package/dist/authored-flow-executor.d.ts.map +1 -1
- package/dist/authored-flow-executor.js +93 -7
- package/dist/authored-flow-executor.js.map +1 -1
- package/dist/authored-flow-lifecycle.d.ts +10 -0
- package/dist/authored-flow-lifecycle.d.ts.map +1 -1
- package/dist/authored-flow-lifecycle.js +7 -0
- package/dist/authored-flow-lifecycle.js.map +1 -1
- package/dist/authored-flow-operation.d.ts +11 -0
- package/dist/authored-flow-operation.d.ts.map +1 -1
- package/dist/authored-flow-operation.js +32 -7
- package/dist/authored-flow-operation.js.map +1 -1
- package/dist/authored-node-runner.d.ts.map +1 -1
- package/dist/authored-node-runner.js +37 -14
- package/dist/authored-node-runner.js.map +1 -1
- package/dist/authored-step-output.d.ts +2 -0
- package/dist/authored-step-output.d.ts.map +1 -1
- package/dist/authored-step-output.js +5 -1
- package/dist/authored-step-output.js.map +1 -1
- package/dist/authored-worker-step.d.ts.map +1 -1
- package/dist/authored-worker-step.js +15 -8
- package/dist/authored-worker-step.js.map +1 -1
- package/dist/cli/check-triggers.d.ts.map +1 -1
- package/dist/cli/check-triggers.js +10 -0
- package/dist/cli/check-triggers.js.map +1 -1
- package/dist/cli/check.d.ts +14 -0
- package/dist/cli/check.d.ts.map +1 -1
- package/dist/cli/check.js +6 -1
- package/dist/cli/check.js.map +1 -1
- package/dist/cli/cloud-deploy.d.ts +30 -0
- package/dist/cli/cloud-deploy.d.ts.map +1 -0
- package/dist/cli/cloud-deploy.js +162 -0
- package/dist/cli/cloud-deploy.js.map +1 -0
- package/dist/cli/cloud-run.d.ts +3 -1
- package/dist/cli/cloud-run.d.ts.map +1 -1
- package/dist/cli/cloud-run.js +37 -5
- package/dist/cli/cloud-run.js.map +1 -1
- package/dist/cli/cloud-schedule.d.ts +29 -0
- package/dist/cli/cloud-schedule.d.ts.map +1 -0
- package/dist/cli/cloud-schedule.js +131 -0
- package/dist/cli/cloud-schedule.js.map +1 -0
- package/dist/cli/cloud-sync.d.ts +13 -0
- package/dist/cli/cloud-sync.d.ts.map +1 -0
- package/dist/cli/cloud-sync.js +39 -0
- package/dist/cli/cloud-sync.js.map +1 -0
- package/dist/cli/direct-run.js +1 -1
- package/dist/cli/direct-run.js.map +1 -1
- package/dist/cli/run.d.ts +1 -1
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +17 -4
- package/dist/cli/run.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +117 -12
- package/dist/cli.js.map +1 -1
- package/dist/cloud-deploy.d.ts +70 -0
- package/dist/cloud-deploy.d.ts.map +1 -0
- package/dist/cloud-deploy.js +192 -0
- package/dist/cloud-deploy.js.map +1 -0
- package/dist/cloud-http.d.ts +52 -2
- package/dist/cloud-http.d.ts.map +1 -1
- package/dist/cloud-http.js +135 -9
- package/dist/cloud-http.js.map +1 -1
- package/dist/cloud-run.d.ts +53 -0
- package/dist/cloud-run.d.ts.map +1 -1
- package/dist/cloud-run.js +97 -25
- package/dist/cloud-run.js.map +1 -1
- package/dist/cloud-schedule.d.ts +48 -0
- package/dist/cloud-schedule.d.ts.map +1 -0
- package/dist/cloud-schedule.js +125 -0
- package/dist/cloud-schedule.js.map +1 -0
- package/dist/cloud-sync.d.ts +66 -0
- package/dist/cloud-sync.d.ts.map +1 -0
- package/dist/cloud-sync.js +287 -0
- package/dist/cloud-sync.js.map +1 -0
- package/dist/failure-kinds.d.ts +10 -3
- package/dist/failure-kinds.d.ts.map +1 -1
- package/dist/failure-kinds.js +10 -0
- package/dist/failure-kinds.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/named-gate-lowering.js +9 -0
- package/dist/named-gate-lowering.js.map +1 -1
- package/dist/named-gates.d.ts +1 -1
- package/dist/named-gates.d.ts.map +1 -1
- package/dist/named-gates.js +11 -1
- package/dist/named-gates.js.map +1 -1
- package/dist/preflight.d.ts.map +1 -1
- package/dist/preflight.js +155 -9
- package/dist/preflight.js.map +1 -1
- package/dist/schedule-trigger.d.ts +35 -0
- package/dist/schedule-trigger.d.ts.map +1 -0
- package/dist/schedule-trigger.js +53 -0
- package/dist/schedule-trigger.js.map +1 -0
- package/dist/spec.d.ts +11 -1
- package/dist/spec.d.ts.map +1 -1
- package/dist/spec.js.map +1 -1
- package/dist/trigger-executor.js +1 -1
- package/dist/trigger-executor.js.map +1 -1
- package/dist/validate.js +1 -1
- package/dist/validate.js.map +1 -1
- package/dist/worker-cli.d.ts +10 -0
- package/dist/worker-cli.d.ts.map +1 -1
- package/dist/worker-cli.js +51 -22
- package/dist/worker-cli.js.map +1 -1
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +9 -0
- package/dist/worker.js.map +1 -1
- package/dist/wrapper-session.d.ts +3 -1
- package/dist/wrapper-session.d.ts.map +1 -1
- package/dist/wrapper-session.js +6 -3
- package/dist/wrapper-session.js.map +1 -1
- package/package.json +3 -3
- package/src/agent-artifacts.ts +76 -0
- package/src/authored-flow-error.ts +1 -0
- package/src/authored-flow-executor.ts +95 -8
- package/src/authored-flow-lifecycle.ts +7 -0
- package/src/authored-flow-operation.ts +35 -10
- package/src/authored-node-runner.ts +35 -13
- package/src/authored-step-output.ts +6 -1
- package/src/authored-worker-step.ts +16 -9
- package/src/cli/check-triggers.ts +9 -0
- package/src/cli/check.ts +21 -1
- package/src/cli/cloud-deploy.ts +157 -0
- package/src/cli/cloud-run.ts +37 -6
- package/src/cli/cloud-schedule.ts +135 -0
- package/src/cli/cloud-sync.ts +37 -0
- package/src/cli/direct-run.ts +1 -1
- package/src/cli/run.ts +18 -5
- package/src/cli.ts +107 -12
- package/src/cloud-deploy.ts +247 -0
- package/src/cloud-http.ts +173 -9
- package/src/cloud-run.ts +143 -24
- package/src/cloud-schedule.ts +158 -0
- package/src/cloud-sync.ts +315 -0
- package/src/failure-kinds.ts +10 -0
- package/src/index.ts +14 -0
- package/src/named-gate-lowering.ts +9 -0
- package/src/named-gates.ts +11 -1
- package/src/preflight.ts +132 -9
- package/src/schedule-trigger.ts +73 -0
- package/src/spec.ts +12 -1
- package/src/trigger-executor.ts +1 -1
- package/src/validate.ts +1 -1
- package/src/worker-cli.ts +41 -0
- package/src/worker.ts +9 -0
- package/src/wrapper-session.ts +5 -1
package/dist/cloud-run.js
CHANGED
|
@@ -7,14 +7,19 @@ import { canonicalize, specHash } from './canonical.js';
|
|
|
7
7
|
import { CompileError, compileSpec, kernelToAuthoring, toKernelSpec } from './compile.js';
|
|
8
8
|
import { snapshotJsonValue } from './json-value.js';
|
|
9
9
|
import { loadAuthoredFlow } from './authored-flow-loader.js';
|
|
10
|
-
import { CloudFlowError, cloudConnection, cloudRequest, cloudRunId, isCloudRecord, } from './cloud-http.js';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
import { CloudFlowError, cloudConnection, cloudFetch, cloudRequest, cloudRunId, isCloudRecord, } from './cloud-http.js';
|
|
11
|
+
import { packWorkingTree, prepareCloudSync, uploadCloudCode } from './cloud-sync.js';
|
|
12
|
+
/** The request-body fields a submission contributes; identical for a run and a schedule. */
|
|
13
|
+
export function cloudSubmissionBody(submission) {
|
|
14
|
+
return {
|
|
15
|
+
workflow: submission.workflow,
|
|
16
|
+
fileType: submission.fileType,
|
|
17
|
+
relayflowVersion: 'v2',
|
|
18
|
+
...(submission.authoredAuthority === undefined ? {} : { authoredAuthority: submission.authoredAuthority }),
|
|
19
|
+
...(submission.inputPresent ? { inputs: submission.inputs } : {}),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export async function prepareCloudSubmission(flow, options = {}) {
|
|
18
23
|
let spec;
|
|
19
24
|
let authored;
|
|
20
25
|
const inputPresent = Object.prototype.hasOwnProperty.call(options, 'input');
|
|
@@ -28,13 +33,26 @@ export async function runInCloud(flow, options = {}) {
|
|
|
28
33
|
if (!bytes.length || Buffer.from(source, 'utf8').compare(bytes) !== 0) {
|
|
29
34
|
throw new CloudFlowError('invalid_input', 'Authored source must be nonempty, lossless UTF-8.');
|
|
30
35
|
}
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
let loaded;
|
|
37
|
+
let definition;
|
|
38
|
+
try {
|
|
39
|
+
loaded = await loadAuthoredFlow(flow.path);
|
|
40
|
+
definition = loaded.getDefinition(loaded.handle);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
// An authored source that does not load is an authoring problem, and
|
|
44
|
+
// the most common one is `@relayflows/surface` not being resolvable
|
|
45
|
+
// from the flow's directory. Name it; do not call it a spec problem.
|
|
46
|
+
throw new CloudFlowError('unsupported_source', `${flow.path} is not a loadable authored flow: ${error instanceof Error ? error.message : String(error)}. `
|
|
47
|
+
+ 'Run `flows check` on it from the same directory.');
|
|
48
|
+
}
|
|
33
49
|
if (loaded.graph.length !== 1) {
|
|
34
50
|
throw new CloudFlowError('unsupported_source', 'Cloud authored submission currently accepts one self-contained .flow.ts source without use dependencies.');
|
|
35
51
|
}
|
|
36
52
|
authored = {
|
|
37
53
|
source,
|
|
54
|
+
name: definition.name,
|
|
55
|
+
schedules: definition.handlers.flatMap(h => h.trigger.kind === 'schedule' ? [h.trigger] : []),
|
|
38
56
|
authority: Object.freeze({
|
|
39
57
|
schemaVersion: 1,
|
|
40
58
|
sourceSha256: createHash('sha256').update(bytes).digest('hex'),
|
|
@@ -85,27 +103,81 @@ export async function runInCloud(flow, options = {}) {
|
|
|
85
103
|
throw new CloudFlowError('invalid_input', 'Cannot read or compile the declarative flow. Check the file path and YAML/JSON spec.');
|
|
86
104
|
}
|
|
87
105
|
options.signal?.throwIfAborted();
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
: createHash('sha256').update(canonicalize({
|
|
91
|
-
authority: authored.authority,
|
|
92
|
-
input: authoredInput,
|
|
93
|
-
})).digest('hex');
|
|
94
|
-
const result = await cloudRequest('/api/v1/workflows/run', options, {
|
|
106
|
+
if (authored === undefined) {
|
|
107
|
+
const kernel = toKernelSpec(spec);
|
|
95
108
|
// JSON is a YAML subset. Sending canonical data preserves the exact spec
|
|
96
109
|
// while using the server's existing YAML-to-config admission path.
|
|
97
|
-
workflow:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
110
|
+
return { workflow: canonicalize(spec), fileType: 'yaml', inputPresent: false, specHash: specHash(kernel),
|
|
111
|
+
name: spec.name ?? "flow", schedules: [] };
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
workflow: authored.source, fileType: 'ts', authoredAuthority: authored.authority,
|
|
115
|
+
inputs: authoredInput, inputPresent: true, name: authored.name, schedules: authored.schedules,
|
|
116
|
+
specHash: createHash('sha256').update(canonicalize({ authority: authored.authority, input: authoredInput })).digest('hex'),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Submit a declarative flow to Cloud's pinned v2 runtime. Compilation only
|
|
121
|
+
* happens here; Cloud owns provisioning and the Rust engine owns execution.
|
|
122
|
+
* Returns acceptance, not completion. No local daemon, CLI probe, or node up.
|
|
123
|
+
*/
|
|
124
|
+
export async function runInCloud(flow, options = {}) {
|
|
125
|
+
const { baseUrl } = cloudConnection(options);
|
|
126
|
+
const submission = await prepareCloudSubmission(flow, options);
|
|
127
|
+
const hash = submission.specHash;
|
|
128
|
+
// Sync before submission: `prepare` reserves the run ID and the upload lands
|
|
129
|
+
// under it, so the run request below names code Cloud already holds. A
|
|
130
|
+
// refused backend or failed upload therefore never leaves a launched run
|
|
131
|
+
// pointing at a tree that is not there.
|
|
132
|
+
let synced;
|
|
133
|
+
if (options.syncCode !== undefined) {
|
|
134
|
+
const prepared = await prepareCloudSync(options);
|
|
135
|
+
options.signal?.throwIfAborted();
|
|
136
|
+
const packed = await packWorkingTree(options.syncCode.root);
|
|
137
|
+
try {
|
|
138
|
+
options.signal?.throwIfAborted();
|
|
139
|
+
await uploadCloudCode(prepared, packed, options);
|
|
140
|
+
}
|
|
141
|
+
finally {
|
|
142
|
+
packed.dispose();
|
|
143
|
+
}
|
|
144
|
+
synced = { runId: prepared.runId, codeKey: prepared.codeKey, files: packed.files.length, bytes: packed.bytes,
|
|
145
|
+
skippedLinks: packed.skippedLinks };
|
|
146
|
+
}
|
|
147
|
+
options.signal?.throwIfAborted();
|
|
148
|
+
options.onSubmit?.();
|
|
149
|
+
let result;
|
|
150
|
+
try {
|
|
151
|
+
result = await cloudFetch('/api/v1/workflows/run', options, { method: 'POST', detail: true, body: JSON.stringify({
|
|
152
|
+
...cloudSubmissionBody(submission),
|
|
153
|
+
...(options.workspaceId === undefined ? {} : { workspaceId: options.workspaceId }),
|
|
154
|
+
...(synced === undefined ? {} : { runId: synced.runId, s3CodeKey: synced.codeKey }),
|
|
155
|
+
}) });
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
// Cloud accepts exactly one authored Surface (the one its sandbox runs).
|
|
159
|
+
// A CLI on another release is refused with this code; say which side is
|
|
160
|
+
// which instead of leaving the user with a bare 400 (flows#461).
|
|
161
|
+
if (error instanceof CloudFlowError && submission.authoredAuthority !== undefined
|
|
162
|
+
&& error.refusal?.code === 'relayflow_v2_authored_authority_invalid') {
|
|
163
|
+
const expected = error.refusal.expected?.version;
|
|
164
|
+
throw new CloudFlowError('unsupported_source', `Cloud refused this authored flow's Surface: it runs @relayflows/surface ${expected ?? '(version not reported)'} `
|
|
165
|
+
+ `and this CLI authored against ${submission.authoredAuthority.surface.version}. `
|
|
166
|
+
+ 'Install the matching relayflows release, or deploy the flow with `flows deploy`, which uses Cloud\'s own Surface.', error.status, error.refusal);
|
|
167
|
+
}
|
|
168
|
+
throw error;
|
|
169
|
+
}
|
|
104
170
|
if (!isCloudRecord(result) || (result.status !== 'pending' && result.status !== 'running')) {
|
|
105
171
|
throw new CloudFlowError('invalid_response', 'Cloud did not return an accepted run.');
|
|
106
172
|
}
|
|
107
173
|
const runId = cloudRunId(result.runId);
|
|
108
|
-
|
|
174
|
+
if (synced !== undefined && runId !== synced.runId) {
|
|
175
|
+
throw new CloudFlowError('invalid_response', `Cloud accepted run ${runId} but the synced code was uploaded for ${synced.runId}.`);
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
runId, status: result.status, specHash: hash, apiUrl: `${baseUrl}/api/v1/workflows/runs/${runId}`,
|
|
179
|
+
...(synced === undefined ? {} : { synced: { files: synced.files, bytes: synced.bytes, skippedLinks: synced.skippedLinks } }),
|
|
180
|
+
};
|
|
109
181
|
}
|
|
110
182
|
export async function getCloudFlowRun(runId, options = {}) {
|
|
111
183
|
cloudRunId(runId);
|
package/dist/cloud-run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud-run.js","sourceRoot":"","sources":["../src/cloud-run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,
|
|
1
|
+
{"version":3,"file":"cloud-run.js","sourceRoot":"","sources":["../src/cloud-run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAA8B,MAAM,qBAAqB,CAAC;AAEzF,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;A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,CAAC,QAAQ,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;QACxC,CAAC;QACD,MAAM,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,EACrF,SAAS,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type ScheduleTriggerSource } from '@relayflows/surface';
|
|
2
|
+
import { type CloudConnectionOptions } from './cloud-http.js';
|
|
3
|
+
import { type CloudFlowSource } from './cloud-run.js';
|
|
4
|
+
import type { JsonValue } from './json-value.js';
|
|
5
|
+
/**
|
|
6
|
+
* Hosted schedules. `POST /api/v1/workflows/schedules` stores a workflow
|
|
7
|
+
* request and relaycron fires it on the cron; each fire replays the stored
|
|
8
|
+
* request through the same `/workflows/run` admission a `flows run --cloud`
|
|
9
|
+
* takes. So a schedule sends exactly what a run sends — `prepareCloudSubmission`
|
|
10
|
+
* — wrapped in the schedule envelope. Nothing runs at schedule time.
|
|
11
|
+
*/
|
|
12
|
+
export interface ScheduleInCloudInput {
|
|
13
|
+
flow: CloudFlowSource;
|
|
14
|
+
/** Five-field cron. Exactly one of `cron` or `every`, or neither to use the flow's declared `schedule.*`. */
|
|
15
|
+
cron?: string;
|
|
16
|
+
/** Fixed interval such as `5m`; lowered to a cron the server accepts. */
|
|
17
|
+
every?: string;
|
|
18
|
+
/** IANA zone the cron is evaluated in; default UTC. */
|
|
19
|
+
tz?: string;
|
|
20
|
+
/** Authored input, as `flows run --cloud --input`. */
|
|
21
|
+
input?: JsonValue;
|
|
22
|
+
/** Defaults to the flow's declared name. */
|
|
23
|
+
name?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface CloudSchedule {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
cronExpression: string;
|
|
29
|
+
timezone: string;
|
|
30
|
+
status: string;
|
|
31
|
+
createdAt?: string;
|
|
32
|
+
lastTriggeredAt?: string;
|
|
33
|
+
lastTriggeredRunId?: string;
|
|
34
|
+
lastTriggerStatus?: string;
|
|
35
|
+
}
|
|
36
|
+
/** `every("5m")` as a cron the server accepts; only intervals cron can express exactly. */
|
|
37
|
+
export declare function everyToCron(every: string): string;
|
|
38
|
+
/** The cron a declared `schedule.*` source means on Cloud. */
|
|
39
|
+
export declare function declaredScheduleCron(source: ScheduleTriggerSource): {
|
|
40
|
+
cron: string;
|
|
41
|
+
tz?: string;
|
|
42
|
+
};
|
|
43
|
+
export declare function scheduleInCloud(input: ScheduleInCloudInput, options?: CloudConnectionOptions): Promise<CloudSchedule>;
|
|
44
|
+
export declare function listCloudSchedules(options?: CloudConnectionOptions): Promise<CloudSchedule[]>;
|
|
45
|
+
export declare function unscheduleInCloud(scheduleId: string, options?: CloudConnectionOptions): Promise<void>;
|
|
46
|
+
/** Exposed for previews: the tick grid a UTC cron amounts to, if it is exactly one. */
|
|
47
|
+
export declare function cronIntervalMs(cron: string): number | undefined;
|
|
48
|
+
//# sourceMappingURL=cloud-schedule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-schedule.d.ts","sourceRoot":"","sources":["../src/cloud-schedule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACjG,OAAO,EAA2D,KAAK,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACvH,OAAO,EAA+C,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACnG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;;;;GAMG;AAEH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,eAAe,CAAC;IACtB,6GAA6G;IAC7G,IAAI,CA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ronGrid, everyToMs, parseCron } from '@relayflows/surface';
|
|
2
|
+
import { CloudFlowError, cloudFetch, cloudRequest, isCloudRecord } from './cloud-http.js';
|
|
3
|
+
import { cloudSubmissionBody, prepareCloudSubmission } from './cloud-run.js';
|
|
4
|
+
const SCHEDULE_ID = /^[A-Za-z0-9_-]{1,128}$/u;
|
|
5
|
+
/** `every("5m")` as a cron the server accepts; only intervals cron can express exactly. */
|
|
6
|
+
export function everyToCron(every) {
|
|
7
|
+
const ms = everyToMs(every);
|
|
8
|
+
const minutes = ms / 60_000;
|
|
9
|
+
if (Number.isInteger(minutes) && minutes >= 1 && minutes < 60 && 60 % minutes === 0)
|
|
10
|
+
return `*/${minutes} * * * *`;
|
|
11
|
+
if (minutes === 60)
|
|
12
|
+
return '0 * * * *';
|
|
13
|
+
const hours = ms / 3_600_000;
|
|
14
|
+
if (Number.isInteger(hours) && hours > 1 && hours < 24 && 24 % hours === 0)
|
|
15
|
+
return `0 */${hours} * * *`;
|
|
16
|
+
if (hours === 24)
|
|
17
|
+
return '0 0 * * *';
|
|
18
|
+
throw new CloudFlowError('invalid_input', `--every ${every} has no exact cron: use a divisor of an hour (1m-30m), 1h, a divisor of a day (2h-12h), or 1d; or give --cron.`);
|
|
19
|
+
}
|
|
20
|
+
/** The cron a declared `schedule.*` source means on Cloud. */
|
|
21
|
+
export function declaredScheduleCron(source) {
|
|
22
|
+
if (source.cron !== undefined)
|
|
23
|
+
return { cron: source.cron, ...(source.tz === undefined ? {} : { tz: source.tz }) };
|
|
24
|
+
const minutes = (source.intervalMs ?? 0) / 60_000;
|
|
25
|
+
const every = Number.isInteger(minutes) ? `${minutes}m` : `${Math.round((source.intervalMs ?? 0) / 1000)}s`;
|
|
26
|
+
return { cron: everyToCron(every) };
|
|
27
|
+
}
|
|
28
|
+
function assertTimeZone(tz) {
|
|
29
|
+
try {
|
|
30
|
+
new Intl.DateTimeFormat('en-US', { timeZone: tz });
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
throw new CloudFlowError('invalid_input', `--tz ${JSON.stringify(tz)} is not a known IANA zone.`);
|
|
34
|
+
}
|
|
35
|
+
return tz;
|
|
36
|
+
}
|
|
37
|
+
export async function scheduleInCloud(input, options = {}) {
|
|
38
|
+
if (input.cron !== undefined && input.every !== undefined) {
|
|
39
|
+
throw new CloudFlowError('invalid_input', 'Give --cron or --every, not both.');
|
|
40
|
+
}
|
|
41
|
+
const submission = await prepareCloudSubmission(input.flow, {
|
|
42
|
+
...(Object.prototype.hasOwnProperty.call(input, 'input') ? { input: input.input } : {}),
|
|
43
|
+
...(options.signal === undefined ? {} : { signal: options.signal }),
|
|
44
|
+
});
|
|
45
|
+
let cron;
|
|
46
|
+
let tz = input.tz;
|
|
47
|
+
if (input.cron !== undefined) {
|
|
48
|
+
try {
|
|
49
|
+
parseCron(input.cron);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
throw new CloudFlowError('invalid_input', `--cron: ${error instanceof Error ? error.message : String(error)}`);
|
|
53
|
+
}
|
|
54
|
+
cron = input.cron.trim();
|
|
55
|
+
}
|
|
56
|
+
else if (input.every !== undefined) {
|
|
57
|
+
cron = everyToCron(input.every);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
if (submission.schedules.length !== 1) {
|
|
61
|
+
throw new CloudFlowError('invalid_input', submission.schedules.length === 0
|
|
62
|
+
? 'The flow declares no schedule.* handler; give --cron or --every.'
|
|
63
|
+
: 'The flow declares several schedules; say which with --cron or --every.');
|
|
64
|
+
}
|
|
65
|
+
const declared = declaredScheduleCron(submission.schedules[0]);
|
|
66
|
+
cron = declared.cron;
|
|
67
|
+
tz ??= declared.tz;
|
|
68
|
+
}
|
|
69
|
+
const timezone = tz === undefined ? 'UTC' : assertTimeZone(tz);
|
|
70
|
+
const name = (input.name ?? submission.name).trim();
|
|
71
|
+
if (!name)
|
|
72
|
+
throw new CloudFlowError('invalid_input', 'Schedule name must not be empty.');
|
|
73
|
+
options.signal?.throwIfAborted();
|
|
74
|
+
const result = await cloudFetch('/api/v1/workflows/schedules', options, {
|
|
75
|
+
method: 'POST', detail: true,
|
|
76
|
+
body: JSON.stringify({
|
|
77
|
+
name,
|
|
78
|
+
schedule_type: 'cron',
|
|
79
|
+
cron_expression: cron,
|
|
80
|
+
timezone,
|
|
81
|
+
workflowRequest: cloudSubmissionBody(submission),
|
|
82
|
+
}),
|
|
83
|
+
});
|
|
84
|
+
const record = isCloudRecord(result) && isCloudRecord(result.schedule) ? result.schedule : undefined;
|
|
85
|
+
if (record === undefined)
|
|
86
|
+
throw new CloudFlowError('invalid_response', 'Cloud did not return a schedule.');
|
|
87
|
+
return toCloudSchedule(record);
|
|
88
|
+
}
|
|
89
|
+
function toCloudSchedule(row) {
|
|
90
|
+
if (typeof row.id !== 'string' || !SCHEDULE_ID.test(row.id) || typeof row.name !== 'string') {
|
|
91
|
+
throw new CloudFlowError('invalid_response', 'Cloud returned a malformed schedule.');
|
|
92
|
+
}
|
|
93
|
+
const optional = (key) => typeof row[key] === 'string' ? { [key]: row[key] } : {};
|
|
94
|
+
return {
|
|
95
|
+
id: row.id, name: row.name,
|
|
96
|
+
cronExpression: typeof row.cronExpression === 'string' ? row.cronExpression : '',
|
|
97
|
+
timezone: typeof row.timezone === 'string' ? row.timezone : 'UTC',
|
|
98
|
+
status: typeof row.status === 'string' ? row.status : 'unknown',
|
|
99
|
+
...optional('createdAt'), ...optional('lastTriggeredAt'), ...optional('lastTriggeredRunId'), ...optional('lastTriggerStatus'),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export async function listCloudSchedules(options = {}) {
|
|
103
|
+
const payload = await cloudRequest('/api/v1/workflows/schedules', options);
|
|
104
|
+
if (!isCloudRecord(payload) || !Array.isArray(payload.schedules)) {
|
|
105
|
+
throw new CloudFlowError('invalid_response', 'Cloud did not return a schedules list.');
|
|
106
|
+
}
|
|
107
|
+
return payload.schedules.map(row => {
|
|
108
|
+
if (!isCloudRecord(row))
|
|
109
|
+
throw new CloudFlowError('invalid_response', 'Cloud returned a malformed schedule row.');
|
|
110
|
+
return toCloudSchedule(row);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
export async function unscheduleInCloud(scheduleId, options = {}) {
|
|
114
|
+
if (!SCHEDULE_ID.test(scheduleId))
|
|
115
|
+
throw new CloudFlowError('invalid_input', `"${scheduleId}" is not a schedule id.`);
|
|
116
|
+
const result = await cloudFetch(`/api/v1/workflows/schedules/${encodeURIComponent(scheduleId)}`, options, { method: 'DELETE', detail: true });
|
|
117
|
+
if (!isCloudRecord(result) || result.deleted !== true) {
|
|
118
|
+
throw new CloudFlowError('invalid_response', 'Cloud did not confirm the deletion.');
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/** Exposed for previews: the tick grid a UTC cron amounts to, if it is exactly one. */
|
|
122
|
+
export function cronIntervalMs(cron) {
|
|
123
|
+
return cronGrid(parseCron(cron))?.intervalMs;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=cloud-schedule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-schedule.js","sourceRoot":"","sources":["../src/cloud-schedule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAA8B,MAAM,qBAAqB,CAAC;AACjG,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAA+B,MAAM,iBAAiB,CAAC;AACvH,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAwB,MAAM,gBAAgB,CAAC;AAqCnG,MAAM,WAAW,GAAG,yBAAyB,CAAC;AAE9C,2FAA2F;AAC3F,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,MAAM,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IAC5B,MAAM,OAAO,GAAG,EAAE,GAAG,MAAM,CAAC;IAC5B,IAAI,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,OA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AAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IACtC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QACtD,MAAM,IAAI,cAAc,CAAC,kBAAkB,EAAE,qCAAqC,CAAC,CAAC;IACtF,CAAC;AACH,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type CloudConnectionOptions } from './cloud-http.js';
|
|
2
|
+
/**
|
|
3
|
+
* Code sync for hosted v2 runs, Cloud-API transport only.
|
|
4
|
+
*
|
|
5
|
+
* v1's `--sync-code` had two transports: an S3 client with STS credentials and
|
|
6
|
+
* the Cloud API's own storage route. v2 runs on Cloudflare, so this module
|
|
7
|
+
* speaks only the second: `prepare` must answer with a `cloud-api` storage
|
|
8
|
+
* backend, the tarball is `PUT` to `/workflows/runs/<id>/storage/<key>`, and
|
|
9
|
+
* the sandbox's post-run patch is read from `/workflows/runs/<id>/patch`. A
|
|
10
|
+
* `prepare` that hands back anything else is refused before any upload — the
|
|
11
|
+
* SDK never carries an AWS dependency and never sends code to a bucket it did
|
|
12
|
+
* not get through the Cloud API.
|
|
13
|
+
*/
|
|
14
|
+
/** Uncompressed bytes. Matches the sandbox's extraction budget with headroom. */
|
|
15
|
+
export declare const MAX_SYNC_BYTES: number;
|
|
16
|
+
export interface PreparedCloudSync {
|
|
17
|
+
runId: string;
|
|
18
|
+
codeKey: string;
|
|
19
|
+
/** Run-scoped upload credential from `prepare`; falls back to the session token. */
|
|
20
|
+
uploadToken?: string;
|
|
21
|
+
}
|
|
22
|
+
/** `POST /api/v1/workflows/prepare`, refusing every non-Cloud-API storage backend. */
|
|
23
|
+
export declare function prepareCloudSync(options: CloudConnectionOptions): Promise<PreparedCloudSync>;
|
|
24
|
+
export interface PackedTree {
|
|
25
|
+
/** The gzip'd ustar, spooled to a temporary file; `dispose()` removes it. */
|
|
26
|
+
archivePath: string;
|
|
27
|
+
/** Archive members, `root`-relative POSIX paths, sorted. */
|
|
28
|
+
files: string[];
|
|
29
|
+
/** Uncompressed byte total across regular files. */
|
|
30
|
+
bytes: number;
|
|
31
|
+
/** Symlinks left out because their target resolves outside `root`. */
|
|
32
|
+
skippedLinks: string[];
|
|
33
|
+
dispose(): void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* gzip'd ustar of the working tree at `root`, streamed to a temporary file so
|
|
37
|
+
* the peak footprint is one file plus the compressor's window, never the
|
|
38
|
+
* whole tree. Inside a Git checkout the member list is `git ls-files --cached
|
|
39
|
+
* --others --exclude-standard`, so `.gitignore` governs and untracked-but-
|
|
40
|
+
* not-ignored files ride along, as they do in v1. Outside Git, every regular
|
|
41
|
+
* file and in-tree symlink except `.git`/`node_modules`. A Git failure other
|
|
42
|
+
* than "not a repository" is refused rather than silently widened to the walk:
|
|
43
|
+
* an ignored `.env` must never reach Cloud because `git` was missing or the
|
|
44
|
+
* index was locked. Executable bits survive; symlinks whose target leaves the
|
|
45
|
+
* tree are dropped and reported, since on the host they would point at
|
|
46
|
+
* whatever happens to live at that path. Ordering and mtimes are
|
|
47
|
+
* deterministic, so the same tree packs to the same bytes.
|
|
48
|
+
*/
|
|
49
|
+
export declare function packWorkingTree(root: string): Promise<PackedTree>;
|
|
50
|
+
/** `PUT` the archive through the Cloud API; the run-scoped credential wins when present. */
|
|
51
|
+
export declare function uploadCloudCode(prepared: PreparedCloudSync, packed: PackedTree, options: CloudConnectionOptions): Promise<void>;
|
|
52
|
+
export interface CloudPatch {
|
|
53
|
+
patch: string;
|
|
54
|
+
hasChanges: boolean;
|
|
55
|
+
}
|
|
56
|
+
/** The sandbox's post-run diff. Multi-path runs carry several patches and are refused here. */
|
|
57
|
+
export declare function downloadCloudPatch(runId: string, options: CloudConnectionOptions): Promise<CloudPatch>;
|
|
58
|
+
/** Every path a unified diff touches, deletions included, in order of first appearance. */
|
|
59
|
+
export declare function patchedPaths(patch: string): string[];
|
|
60
|
+
/**
|
|
61
|
+
* `git apply --check` then `git apply`; a conflict leaves the tree untouched.
|
|
62
|
+
* The patch lands in the working tree uncommitted, so what the run changed is
|
|
63
|
+
* reviewed with `git diff` before anything is kept — the same contract as v1.
|
|
64
|
+
*/
|
|
65
|
+
export declare function applyCloudPatch(root: string, patch: string): void;
|
|
66
|
+
//# sourceMappingURL=cloud-sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-sync.d.ts","sourceRoot":"","sources":["../src/cloud-sync.ts"],"names":[],"mappings":"AAQA,OAAO,EACgE,KAAK,sBAAsB,EACjG,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;;;GAWG;AAEH,iFAAiF;AACjF,eAAO,MAAM,cAAc,QAAoB,CAAC;AAIhD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,oFAAoF;IACpF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,sFAAsF;AACtF,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAqBlG;AAED,MAAM,WAAW,UAAU;IACzB,6EAA6E;IAC7E,WAAW,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CA6CvE;AA0HD,4FAA4F;AAC5F,wBA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