terse-cli 0.9.19 → 0.9.21
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/README.md +2 -2
- package/dist/cliUi.d.ts +3 -1
- package/dist/cliUi.d.ts.map +1 -1
- package/dist/cliUi.js +3 -2
- package/dist/cliUi.js.map +1 -1
- package/dist/commands/actor.d.ts.map +1 -1
- package/dist/commands/actor.js +32 -5
- package/dist/commands/actor.js.map +1 -1
- package/dist/commands/actorGenerate.d.ts.map +1 -1
- package/dist/commands/actorGenerate.js +22 -86
- package/dist/commands/actorGenerate.js.map +1 -1
- package/dist/commands/attach.d.ts +0 -7
- package/dist/commands/attach.d.ts.map +1 -1
- package/dist/commands/attach.js +220 -189
- package/dist/commands/attach.js.map +1 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +15 -3
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/generate.d.ts +0 -4
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +161 -127
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/history.d.ts +0 -15
- package/dist/commands/history.d.ts.map +1 -1
- package/dist/commands/history.js +139 -105
- package/dist/commands/history.js.map +1 -1
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +6 -4
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/integrate.d.ts +0 -48
- package/dist/commands/integrate.d.ts.map +1 -1
- package/dist/commands/integrate.js +897 -699
- package/dist/commands/integrate.js.map +1 -1
- package/dist/commands/integrateUse.d.ts +0 -12
- package/dist/commands/integrateUse.d.ts.map +1 -1
- package/dist/commands/integrateUse.js +132 -98
- package/dist/commands/integrateUse.js.map +1 -1
- package/dist/commands/listen.d.ts +0 -7
- package/dist/commands/listen.d.ts.map +1 -1
- package/dist/commands/listen.js +98 -81
- package/dist/commands/listen.js.map +1 -1
- package/dist/commands/memory.d.ts +0 -21
- package/dist/commands/memory.d.ts.map +1 -1
- package/dist/commands/memory.js +147 -128
- package/dist/commands/memory.js.map +1 -1
- package/dist/commands/replay.d.ts +0 -2
- package/dist/commands/replay.d.ts.map +1 -1
- package/dist/commands/replay.js +37 -28
- package/dist/commands/replay.js.map +1 -1
- package/dist/commands/resume.d.ts +0 -4
- package/dist/commands/resume.d.ts.map +1 -1
- package/dist/commands/resume.js +34 -28
- package/dist/commands/resume.js.map +1 -1
- package/dist/commands/run.d.ts +0 -2
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +78 -70
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/state.d.ts +0 -18
- package/dist/commands/state.d.ts.map +1 -1
- package/dist/commands/state.js +129 -108
- package/dist/commands/state.js.map +1 -1
- package/dist/commands/test.d.ts +0 -28
- package/dist/commands/test.d.ts.map +1 -1
- package/dist/commands/test.js +509 -403
- package/dist/commands/test.js.map +1 -1
- package/dist/commands/toolRun.d.ts +0 -6
- package/dist/commands/toolRun.d.ts.map +1 -1
- package/dist/commands/toolRun.js +149 -134
- package/dist/commands/toolRun.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/integrationApi.d.ts +0 -15
- package/dist/integrationApi.d.ts.map +1 -1
- package/dist/integrationApi.js +75 -49
- package/dist/integrationApi.js.map +1 -1
- package/dist/loadJob.d.ts +0 -11
- package/dist/loadJob.d.ts.map +1 -1
- package/dist/loadJob.js +54 -46
- package/dist/loadJob.js.map +1 -1
- package/dist/providers/LanguageProvider.d.ts +0 -29
- package/dist/providers/LanguageProvider.d.ts.map +1 -1
- package/dist/providers/LanguageProvider.js +3 -0
- package/dist/providers/LanguageProvider.js.map +1 -1
- package/dist/providers/typescript/TypeScriptProvider.d.ts +0 -24
- package/dist/providers/typescript/TypeScriptProvider.d.ts.map +1 -1
- package/dist/providers/typescript/TypeScriptProvider.js +113 -113
- package/dist/providers/typescript/TypeScriptProvider.js.map +1 -1
- package/dist/providers/typescript/runtimes/JobRuntime.d.ts +0 -26
- package/dist/providers/typescript/runtimes/JobRuntime.d.ts.map +1 -1
- package/dist/providers/typescript/runtimes/JobRuntime.js +51 -18
- package/dist/providers/typescript/runtimes/JobRuntime.js.map +1 -1
- package/dist/providers/typescript/runtimes/directJobRuntime.d.ts +0 -2
- package/dist/providers/typescript/runtimes/directJobRuntime.d.ts.map +1 -1
- package/dist/providers/typescript/runtimes/directJobRuntime.js +60 -49
- package/dist/providers/typescript/runtimes/directJobRuntime.js.map +1 -1
- package/dist/providers/typescript/runtimes/durableJobRuntime.d.ts +0 -2
- package/dist/providers/typescript/runtimes/durableJobRuntime.d.ts.map +1 -1
- package/dist/providers/typescript/runtimes/durableJobRuntime.js +168 -146
- package/dist/providers/typescript/runtimes/durableJobRuntime.js.map +1 -1
- package/dist/providers/typescript/runtimes/index.d.ts +0 -3
- package/dist/providers/typescript/runtimes/index.d.ts.map +1 -1
- package/dist/providers/typescript/runtimes/index.js +5 -2
- package/dist/providers/typescript/runtimes/index.js.map +1 -1
- package/dist/providers/typescript/runtimes/session.d.ts +0 -4
- package/dist/providers/typescript/runtimes/session.d.ts.map +1 -1
- package/dist/providers/typescript/runtimes/session.js +78 -64
- package/dist/providers/typescript/runtimes/session.js.map +1 -1
- package/dist/providers/typescript/terseWorkflow.d.ts +0 -7
- package/dist/providers/typescript/terseWorkflow.d.ts.map +1 -1
- package/dist/providers/typescript/terseWorkflow.js +12 -7
- package/dist/providers/typescript/terseWorkflow.js.map +1 -1
- package/dist/runLocalTestJob.d.ts +0 -19
- package/dist/runLocalTestJob.d.ts.map +1 -1
- package/dist/runLocalTestJob.js +55 -29
- package/dist/runLocalTestJob.js.map +1 -1
- package/dist/setup.js +1 -1
- package/dist/setup.js.map +1 -1
- package/dist/sourceArchive.d.ts +1 -1
- package/dist/sourceArchive.d.ts.map +1 -1
- package/dist/sourceArchive.js +1 -0
- package/dist/sourceArchive.js.map +1 -1
- package/package.json +3 -4
- package/templates/typescript/init/package.json.hbs +1 -2
- package/templates/typescript/terse-transport.d.ts +25 -0
- package/templates/typescript/terse-transport.js +117 -0
- package/templates/typescript/tsconfig.json +13 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JobRuntime.d.ts","sourceRoot":"","sources":["../../../../src/providers/typescript/runtimes/JobRuntime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"JobRuntime.d.ts","sourceRoot":"","sources":["../../../../src/providers/typescript/runtimes/JobRuntime.ts"],"names":[],"mappings":""}
|
|
@@ -1,19 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// LEGACY-JOBS: Commented out while Terse is actors-only. Uncomment to restore; see the note in terse-sdk/src/index.ts.
|
|
3
|
+
// import type { CreateJobParameters, SessionStreamEvent } from "terse-sdk"
|
|
4
|
+
// import type { SerializedEvent } from "terse-types"
|
|
5
|
+
//
|
|
6
|
+
// import type { SessionHandle } from "../../shared/sessionStream.js"
|
|
7
|
+
//
|
|
8
|
+
// export type RunJobOptions = {
|
|
9
|
+
// verbose?: boolean
|
|
10
|
+
// entryFile?: string
|
|
11
|
+
// projectId?: string
|
|
12
|
+
// onSessionEvent?: (event: SessionStreamEvent) => void
|
|
13
|
+
// pauseUiAround?: <T>(fn: () => Promise<T>) => Promise<T>
|
|
14
|
+
// /** A session stream the caller already opened, so its round trip overlaps loading the job. */
|
|
15
|
+
// session?: Promise<SessionHandle>
|
|
16
|
+
// }
|
|
17
|
+
//
|
|
18
|
+
// export type ResumeRunOptions = {
|
|
19
|
+
// verbose?: boolean
|
|
20
|
+
// pauseUiAround?: <T>(fn: () => Promise<T>) => Promise<T>
|
|
21
|
+
// }
|
|
22
|
+
//
|
|
23
|
+
// export type ResumeHookInput = {
|
|
24
|
+
// token: string
|
|
25
|
+
// payload: unknown
|
|
26
|
+
// }
|
|
27
|
+
//
|
|
28
|
+
// export interface JobRuntime {
|
|
29
|
+
// executeJob(job: CreateJobParameters, runId: string | null, event: SerializedEvent, opts?: RunJobOptions): Promise<void>
|
|
30
|
+
// // Wake a parked run and drive it (timer fired, or recovery).
|
|
31
|
+
// resumeRun(runId: string, opts?: ResumeRunOptions): Promise<void>
|
|
32
|
+
// // Deliver a human response to the run's hook, then drive it (waitForInput answered).
|
|
33
|
+
// resumeRunWithInput(runId: string, input: ResumeHookInput, opts?: ResumeRunOptions): Promise<void>
|
|
34
|
+
// }
|
|
35
|
+
//
|
|
36
|
+
// export function formatErrorDetail(error: unknown): string {
|
|
37
|
+
// if (error instanceof Error) return error.message
|
|
38
|
+
// if (typeof error === "string") return error
|
|
39
|
+
// if (error && typeof error === "object") {
|
|
40
|
+
// return stringifyErrorObject(error)
|
|
41
|
+
// }
|
|
42
|
+
// return String(error)
|
|
43
|
+
// }
|
|
44
|
+
//
|
|
45
|
+
// function stringifyErrorObject(error: object): string {
|
|
46
|
+
// try {
|
|
47
|
+
// return JSON.stringify(error)
|
|
48
|
+
// } catch {
|
|
49
|
+
// return String(error)
|
|
50
|
+
// }
|
|
51
|
+
// }
|
|
19
52
|
//# sourceMappingURL=JobRuntime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JobRuntime.js","sourceRoot":"","sources":["../../../../src/providers/typescript/runtimes/JobRuntime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"JobRuntime.js","sourceRoot":"","sources":["../../../../src/providers/typescript/runtimes/JobRuntime.ts"],"names":[],"mappings":";AAAA,uHAAuH;AACvH,2EAA2E;AAC3E,qDAAqD;AACrD,EAAE;AACF,qEAAqE;AACrE,EAAE;AACF,gCAAgC;AAChC,wBAAwB;AACxB,yBAAyB;AACzB,yBAAyB;AACzB,2DAA2D;AAC3D,8DAA8D;AAC9D,qGAAqG;AACrG,uCAAuC;AACvC,IAAI;AACJ,EAAE;AACF,mCAAmC;AACnC,wBAAwB;AACxB,8DAA8D;AAC9D,IAAI;AACJ,EAAE;AACF,kCAAkC;AAClC,oBAAoB;AACpB,uBAAuB;AACvB,IAAI;AACJ,EAAE;AACF,gCAAgC;AAChC,8HAA8H;AAC9H,oEAAoE;AACpE,uEAAuE;AACvE,4FAA4F;AAC5F,wGAAwG;AACxG,IAAI;AACJ,EAAE;AACF,8DAA8D;AAC9D,uDAAuD;AACvD,kDAAkD;AAClD,gDAAgD;AAChD,6CAA6C;AAC7C,QAAQ;AACR,2BAA2B;AAC3B,IAAI;AACJ,EAAE;AACF,yDAAyD;AACzD,YAAY;AACZ,uCAAuC;AACvC,gBAAgB;AAChB,+BAA+B;AAC/B,QAAQ;AACR,IAAI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directJobRuntime.d.ts","sourceRoot":"","sources":["../../../../src/providers/typescript/runtimes/directJobRuntime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"directJobRuntime.d.ts","sourceRoot":"","sources":["../../../../src/providers/typescript/runtimes/directJobRuntime.ts"],"names":[],"mappings":""}
|
|
@@ -1,50 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// LEGACY-JOBS: Commented out while Terse is actors-only. Uncomment to restore; see the note in terse-sdk/src/index.ts.
|
|
3
|
+
// import chalk from "chalk"
|
|
4
|
+
// import { __buildJobStateAccessor, createSDKTrigger } from "terse-sdk"
|
|
5
|
+
// import { runWithJobContext } from "terse-sdk/dist/runIdentity/jobContextStore.js"
|
|
6
|
+
//
|
|
7
|
+
// import { readApiKeyOrBail } from "../../../api.js"
|
|
8
|
+
// import { CliError } from "../../../cliError.js"
|
|
9
|
+
// import { BACKEND_URL } from "../../../config.js"
|
|
10
|
+
//
|
|
11
|
+
// import { type JobRuntime, formatErrorDetail } from "./JobRuntime.js"
|
|
12
|
+
// import { withSession } from "./session.js"
|
|
13
|
+
//
|
|
14
|
+
// export const directJobRuntime: JobRuntime = {
|
|
15
|
+
// async executeJob(job, runId, event, opts) {
|
|
16
|
+
// const isVerbose = opts?.verbose ?? true
|
|
17
|
+
// const pauseUiAround = opts?.pauseUiAround ?? (async fn => fn())
|
|
18
|
+
// const apiKey = readApiKeyOrBail()
|
|
19
|
+
// const inputEvent = createSDKTrigger(event)
|
|
20
|
+
//
|
|
21
|
+
// try {
|
|
22
|
+
// await withSession(
|
|
23
|
+
// apiKey,
|
|
24
|
+
// isVerbose,
|
|
25
|
+
// pauseUiAround,
|
|
26
|
+
// async sessionId => {
|
|
27
|
+
// await runWithJobContext({ sessionId, runId, apiBaseUrl: BACKEND_URL, projectId: opts?.projectId, jobName: job.name }, async () => {
|
|
28
|
+
// const state = __buildJobStateAccessor(job.states ?? [])
|
|
29
|
+
// if (job.filter && !(await job.filter(inputEvent, state))) {
|
|
30
|
+
// if (isVerbose) console.log(chalk.dim(`\n Job "${job.name}" skipped (filter returned false).\n`))
|
|
31
|
+
// return
|
|
32
|
+
// }
|
|
33
|
+
// if (isVerbose) console.log(chalk.cyan(` Job "${job.name}" started`))
|
|
34
|
+
// await job.onTrigger(inputEvent, state)
|
|
35
|
+
// })
|
|
36
|
+
// },
|
|
37
|
+
// opts?.onSessionEvent,
|
|
38
|
+
// opts?.session
|
|
39
|
+
// )
|
|
40
|
+
// } catch (error) {
|
|
41
|
+
// if (error instanceof CliError) throw error
|
|
42
|
+
// if (error instanceof Error && error.name === "DurableOnlyError") {
|
|
43
|
+
// throw new CliError("durable_only", error.message, { actionRequired: true })
|
|
44
|
+
// }
|
|
45
|
+
// throw new CliError("job_execution_failed", `Job "${job.name}" threw an error.`, { detail: formatErrorDetail(error) })
|
|
46
|
+
// }
|
|
47
|
+
// },
|
|
48
|
+
//
|
|
49
|
+
// async resumeRun() {
|
|
50
|
+
// throw new CliError("resume_not_durable", "Only durable jobs can be resumed.", {
|
|
51
|
+
// detail: "This run belongs to a non-durable job — non-durable jobs run to completion and never suspend."
|
|
52
|
+
// })
|
|
53
|
+
// },
|
|
54
|
+
//
|
|
55
|
+
// async resumeRunWithInput() {
|
|
56
|
+
// throw new CliError("resume_not_durable", "Only durable jobs can be resumed.", {
|
|
57
|
+
// detail: "This run belongs to a non-durable job — non-durable jobs run to completion and never suspend."
|
|
58
|
+
// })
|
|
59
|
+
// }
|
|
60
|
+
// }
|
|
50
61
|
//# sourceMappingURL=directJobRuntime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directJobRuntime.js","sourceRoot":"","sources":["../../../../src/providers/typescript/runtimes/directJobRuntime.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"directJobRuntime.js","sourceRoot":"","sources":["../../../../src/providers/typescript/runtimes/directJobRuntime.ts"],"names":[],"mappings":";AAAA,uHAAuH;AACvH,4BAA4B;AAC5B,wEAAwE;AACxE,oFAAoF;AACpF,EAAE;AACF,qDAAqD;AACrD,kDAAkD;AAClD,mDAAmD;AACnD,EAAE;AACF,uEAAuE;AACvE,6CAA6C;AAC7C,EAAE;AACF,gDAAgD;AAChD,kDAAkD;AAClD,kDAAkD;AAClD,0EAA0E;AAC1E,4CAA4C;AAC5C,qDAAqD;AACrD,EAAE;AACF,gBAAgB;AAChB,iCAAiC;AACjC,0BAA0B;AAC1B,6BAA6B;AAC7B,iCAAiC;AACjC,uCAAuC;AACvC,0JAA0J;AAC1J,kFAAkF;AAClF,sFAAsF;AACtF,gIAAgI;AAChI,qCAAqC;AACrC,4BAA4B;AAC5B,gGAAgG;AAChG,iEAAiE;AACjE,yBAAyB;AACzB,qBAAqB;AACrB,wCAAwC;AACxC,gCAAgC;AAChC,gBAAgB;AAChB,4BAA4B;AAC5B,yDAAyD;AACzD,iFAAiF;AACjF,8FAA8F;AAC9F,gBAAgB;AAChB,oIAAoI;AACpI,YAAY;AACZ,SAAS;AACT,EAAE;AACF,0BAA0B;AAC1B,0FAA0F;AAC1F,sHAAsH;AACtH,aAAa;AACb,SAAS;AACT,EAAE;AACF,mCAAmC;AACnC,0FAA0F;AAC1F,sHAAsH;AACtH,aAAa;AACb,QAAQ;AACR,IAAI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durableJobRuntime.d.ts","sourceRoot":"","sources":["../../../../src/providers/typescript/runtimes/durableJobRuntime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"durableJobRuntime.d.ts","sourceRoot":"","sources":["../../../../src/providers/typescript/runtimes/durableJobRuntime.ts"],"names":[],"mappings":""}
|
|
@@ -1,147 +1,169 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// LEGACY-JOBS: Commented out while Terse is actors-only. Uncomment to restore; see the note in terse-sdk/src/index.ts.
|
|
3
|
+
// import chalk from "chalk"
|
|
4
|
+
// import { FileJournalStore, Runtime } from "little-durable"
|
|
5
|
+
// import type { JournalStore, RuntimeOutcome, Suspension } from "little-durable"
|
|
6
|
+
// import path from "node:path"
|
|
7
|
+
// import { __fetchRegisteredDurableWorkflow, __inputRequestHook, fetchRegisteredJobs } from "terse-sdk"
|
|
8
|
+
// import type { CreateJobParameters, TerseJobContext } from "terse-sdk"
|
|
9
|
+
// import { runWithJobContext } from "terse-sdk/dist/runIdentity/jobContextStore.js"
|
|
10
|
+
// import type { SdkJobSuspendRequestBody, SdkJobSuspendResponseBody } from "terse-types"
|
|
11
|
+
// import { ApiRoutes } from "terse-types"
|
|
12
|
+
//
|
|
13
|
+
// import { fetchWithAuth, readApiKeyOrBail } from "../../../api.js"
|
|
14
|
+
// import { CliError } from "../../../cliError.js"
|
|
15
|
+
// import { BACKEND_URL } from "../../../config.js"
|
|
16
|
+
// import { readProjectConfig } from "../../../projectConfig.js"
|
|
17
|
+
// import { shouldRunTerseWorkflow } from "../terseWorkflow.js"
|
|
18
|
+
//
|
|
19
|
+
// import { type JobRuntime, type ResumeHookInput, type ResumeRunOptions, formatErrorDetail } from "./JobRuntime.js"
|
|
20
|
+
// import { withSession } from "./session.js"
|
|
21
|
+
//
|
|
22
|
+
// export const durableJobRuntime: JobRuntime = {
|
|
23
|
+
// async executeJob(job, runId, event, opts) {
|
|
24
|
+
// if (!runId) throw new CliError("durable_run_id_missing", "Durable execution requires a run ID.")
|
|
25
|
+
//
|
|
26
|
+
// const isVerbose = opts?.verbose ?? true
|
|
27
|
+
// const pauseUiAround = opts?.pauseUiAround ?? (async fn => fn())
|
|
28
|
+
// const apiKey = readApiKeyOrBail()
|
|
29
|
+
//
|
|
30
|
+
// try {
|
|
31
|
+
// await withSession(
|
|
32
|
+
// apiKey,
|
|
33
|
+
// isVerbose,
|
|
34
|
+
// pauseUiAround,
|
|
35
|
+
// async sessionId => {
|
|
36
|
+
// if (isVerbose) console.log(chalk.cyan(` Job "${job.name}" started`))
|
|
37
|
+
// const journalStore = createJournalStore()
|
|
38
|
+
// const runtime = new Runtime({ journalStore })
|
|
39
|
+
// const context = jobContext({ sessionId, runId, job, projectId: opts?.projectId })
|
|
40
|
+
// const shouldRun = await shouldRunTerseWorkflow({ job, event, context })
|
|
41
|
+
// if (!shouldRun) return
|
|
42
|
+
// const workflow = __fetchRegisteredDurableWorkflow(job.name)
|
|
43
|
+
// if (!workflow) throw new Error(`No durable workflow was registered for job "${job.name}".`)
|
|
44
|
+
//
|
|
45
|
+
// const outcome = await runWithJobContext(context, () => runtime.start(workflow, { runId, input: event }).waitForOutcome())
|
|
46
|
+
// await handleOutcome({ runId, outcome, apiKey })
|
|
47
|
+
// },
|
|
48
|
+
// opts?.onSessionEvent,
|
|
49
|
+
// opts?.session
|
|
50
|
+
// )
|
|
51
|
+
// } catch (error) {
|
|
52
|
+
// if (error instanceof CliError) throw error
|
|
53
|
+
// throw new CliError("job_execution_failed", `Job "${job.name}" threw an error.`, { detail: formatErrorDetail(error) })
|
|
54
|
+
// }
|
|
55
|
+
// },
|
|
56
|
+
//
|
|
57
|
+
// async resumeRun(runId, opts) {
|
|
58
|
+
// return driveResume(runId, opts)
|
|
59
|
+
// },
|
|
60
|
+
//
|
|
61
|
+
// async resumeRunWithInput(runId, input, opts) {
|
|
62
|
+
// return driveResume(runId, opts, input)
|
|
63
|
+
// }
|
|
64
|
+
// }
|
|
65
|
+
//
|
|
66
|
+
// async function driveResume(runId: string, opts: ResumeRunOptions | undefined, input?: ResumeHookInput): Promise<void> {
|
|
67
|
+
// const isVerbose = opts?.verbose ?? true
|
|
68
|
+
// const pauseUiAround = opts?.pauseUiAround ?? (async fn => fn())
|
|
69
|
+
// const apiKey = readApiKeyOrBail()
|
|
70
|
+
//
|
|
71
|
+
// try {
|
|
72
|
+
// await withSession(apiKey, isVerbose, pauseUiAround, async sessionId => {
|
|
73
|
+
// const journalStore = createJournalStore()
|
|
74
|
+
// const runtime = new Runtime({ journalStore })
|
|
75
|
+
// const run = await runtime.getRun({ runId })
|
|
76
|
+
// const job = fetchRegisteredJobs().get(run.workflowName)
|
|
77
|
+
// if (!job) throw new Error(`No registered job matches durable workflow "${run.workflowName}".`)
|
|
78
|
+
// const workflow = __fetchRegisteredDurableWorkflow(job.name)
|
|
79
|
+
// if (!workflow) throw new Error(`No durable workflow was registered for job "${job.name}".`)
|
|
80
|
+
//
|
|
81
|
+
// if (isVerbose) console.log(chalk.cyan(` Resuming run ${runId}`))
|
|
82
|
+
// const context = jobContext({ sessionId, runId, job, projectId: readProjectConfig()?.projectId })
|
|
83
|
+
// const outcome = await runWithJobContext(context, async (): Promise<RuntimeOutcome> => {
|
|
84
|
+
// const suspension = await runtime.getSuspension({ runId })
|
|
85
|
+
//
|
|
86
|
+
// if (input) {
|
|
87
|
+
// if (!suspension || suspension.request.name !== __inputRequestHook.name) {
|
|
88
|
+
// throw new Error(`No unresolved input wait with token "${input.token}" exists in run "${runId}".`)
|
|
89
|
+
// }
|
|
90
|
+
// const request = __inputRequestHook.request.safeParse(suspension.request.payload)
|
|
91
|
+
// if (!request.success || request.data.token !== input.token) {
|
|
92
|
+
// throw new Error(`No unresolved input wait with token "${input.token}" exists in run "${runId}".`)
|
|
93
|
+
// }
|
|
94
|
+
// const resolution = __inputRequestHook.resolution.parse(input.payload)
|
|
95
|
+
// return runtime.resumeHook(__inputRequestHook, { runId, workflow, waitId: suspension.waitId, resolution }).waitForOutcome()
|
|
96
|
+
// }
|
|
97
|
+
//
|
|
98
|
+
// return suspension?.request.name === "timer"
|
|
99
|
+
// ? runtime.resumeTimer(workflow, { runId, waitId: suspension.waitId }).waitForOutcome()
|
|
100
|
+
// : runtime.resume(workflow, { runId }).waitForOutcome()
|
|
101
|
+
// })
|
|
102
|
+
//
|
|
103
|
+
// await handleOutcome({ runId, outcome, apiKey })
|
|
104
|
+
//
|
|
105
|
+
// if (isVerbose && outcome.status === "completed") console.log(chalk.green(` Run ${runId} completed`))
|
|
106
|
+
// })
|
|
107
|
+
// } catch (error) {
|
|
108
|
+
// if (error instanceof CliError) throw error
|
|
109
|
+
// throw new CliError("run_resume_failed", `Run "${runId}" could not be resumed.`, { detail: formatErrorDetail(error) })
|
|
110
|
+
// }
|
|
111
|
+
// }
|
|
112
|
+
//
|
|
113
|
+
// function createJournalStore(): JournalStore {
|
|
114
|
+
// return new FileJournalStore(resolveDataDirectory())
|
|
115
|
+
// }
|
|
116
|
+
//
|
|
117
|
+
// function resolveDataDirectory(): string {
|
|
118
|
+
// return process.env.TERSE_JOURNAL_ROOT ?? path.join(process.cwd(), ".terse", "data")
|
|
119
|
+
// }
|
|
120
|
+
//
|
|
121
|
+
// function jobContext({ sessionId, runId, job, projectId }: { sessionId: string; runId: string; job: CreateJobParameters; projectId?: string }): TerseJobContext {
|
|
122
|
+
// return {
|
|
123
|
+
// sessionId,
|
|
124
|
+
// runId,
|
|
125
|
+
// apiBaseUrl: BACKEND_URL,
|
|
126
|
+
// jobName: job.name,
|
|
127
|
+
// projectId
|
|
128
|
+
// }
|
|
129
|
+
// }
|
|
130
|
+
//
|
|
131
|
+
// async function handleOutcome({ runId, outcome, apiKey }: { runId: string; outcome: RuntimeOutcome; apiKey: string }): Promise<void> {
|
|
132
|
+
// if (outcome.status === "completed") return
|
|
133
|
+
// if (outcome.status === "failed") {
|
|
134
|
+
// const error = new Error(outcome.error.message)
|
|
135
|
+
// error.name = outcome.error.name
|
|
136
|
+
// throw error
|
|
137
|
+
// }
|
|
138
|
+
//
|
|
139
|
+
// const body = suspendRequest({ runId, suspension: outcome.suspension })
|
|
140
|
+
// await fetchWithAuth<SdkJobSuspendResponseBody>(ApiRoutes.SDK.SUSPEND, apiKey, body, "POST")
|
|
141
|
+
// }
|
|
142
|
+
//
|
|
143
|
+
// function suspendRequest({ runId, suspension }: { runId: string; suspension: Suspension }): SdkJobSuspendRequestBody {
|
|
144
|
+
// const payload = suspension.request.payload
|
|
145
|
+
// if (suspension.request.name === "timer") {
|
|
146
|
+
// if (typeof payload !== "object" || payload === null || Array.isArray(payload) || typeof payload.wakeAt !== "string") {
|
|
147
|
+
// throw new Error("Timer suspension has an invalid wakeAt.")
|
|
148
|
+
// }
|
|
149
|
+
// return {
|
|
150
|
+
// runId,
|
|
151
|
+
// kind: "timer",
|
|
152
|
+
// delaySeconds: Math.max(1, Math.ceil((Date.parse(payload.wakeAt) - Date.now()) / 1_000)),
|
|
153
|
+
// idempotencyKey: suspension.waitId
|
|
154
|
+
// }
|
|
155
|
+
// }
|
|
156
|
+
//
|
|
157
|
+
// if (suspension.request.name === __inputRequestHook.name) {
|
|
158
|
+
// const input = __inputRequestHook.request.parse(payload)
|
|
159
|
+
// return {
|
|
160
|
+
// runId,
|
|
161
|
+
// kind: "input",
|
|
162
|
+
// hookToken: input.token,
|
|
163
|
+
// idempotencyKey: suspension.waitId
|
|
164
|
+
// }
|
|
165
|
+
// }
|
|
166
|
+
//
|
|
167
|
+
// throw new Error(`Terse does not know how to park hook "${suspension.request.name}".`)
|
|
168
|
+
// }
|
|
147
169
|
//# sourceMappingURL=durableJobRuntime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durableJobRuntime.js","sourceRoot":"","sources":["../../../../src/providers/typescript/runtimes/durableJobRuntime.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"durableJobRuntime.js","sourceRoot":"","sources":["../../../../src/providers/typescript/runtimes/durableJobRuntime.ts"],"names":[],"mappings":";AAAA,uHAAuH;AACvH,4BAA4B;AAC5B,6DAA6D;AAC7D,iFAAiF;AACjF,+BAA+B;AAC/B,wGAAwG;AACxG,wEAAwE;AACxE,oFAAoF;AACpF,yFAAyF;AACzF,0CAA0C;AAC1C,EAAE;AACF,oEAAoE;AACpE,kDAAkD;AAClD,mDAAmD;AACnD,gEAAgE;AAChE,+DAA+D;AAC/D,EAAE;AACF,oHAAoH;AACpH,6CAA6C;AAC7C,EAAE;AACF,iDAAiD;AACjD,kDAAkD;AAClD,2GAA2G;AAC3G,EAAE;AACF,kDAAkD;AAClD,0EAA0E;AAC1E,4CAA4C;AAC5C,EAAE;AACF,gBAAgB;AAChB,iCAAiC;AACjC,0BAA0B;AAC1B,6BAA6B;AAC7B,iCAAiC;AACjC,uCAAuC;AACvC,4FAA4F;AAC5F,gEAAgE;AAChE,oEAAoE;AACpE,wGAAwG;AACxG,8FAA8F;AAC9F,6CAA6C;AAC7C,kFAAkF;AAClF,kHAAkH;AAClH,EAAE;AACF,gJAAgJ;AAChJ,sEAAsE;AACtE,qBAAqB;AACrB,wCAAwC;AACxC,gCAAgC;AAChC,gBAAgB;AAChB,4BAA4B;AAC5B,yDAAyD;AACzD,oIAAoI;AACpI,YAAY;AACZ,SAAS;AACT,EAAE;AACF,qCAAqC;AACrC,0CAA0C;AAC1C,SAAS;AACT,EAAE;AACF,qDAAqD;AACrD,iDAAiD;AACjD,QAAQ;AACR,IAAI;AACJ,EAAE;AACF,0HAA0H;AAC1H,8CAA8C;AAC9C,sEAAsE;AACtE,wCAAwC;AACxC,EAAE;AACF,YAAY;AACZ,mFAAmF;AACnF,wDAAwD;AACxD,4DAA4D;AAC5D,0DAA0D;AAC1D,sEAAsE;AACtE,6GAA6G;AAC7G,0EAA0E;AAC1E,0GAA0G;AAC1G,EAAE;AACF,gFAAgF;AAChF,+GAA+G;AAC/G,sGAAsG;AACtG,4EAA4E;AAC5E,EAAE;AACF,+BAA+B;AAC/B,gGAAgG;AAChG,4HAA4H;AAC5H,wBAAwB;AACxB,uGAAuG;AACvG,oFAAoF;AACpF,4HAA4H;AAC5H,wBAAwB;AACxB,4FAA4F;AAC5F,iJAAiJ;AACjJ,oBAAoB;AACpB,EAAE;AACF,8DAA8D;AAC9D,6GAA6G;AAC7G,6EAA6E;AAC7E,iBAAiB;AACjB,EAAE;AACF,8DAA8D;AAC9D,EAAE;AACF,oHAAoH;AACpH,aAAa;AACb,wBAAwB;AACxB,qDAAqD;AACrD,gIAAgI;AAChI,QAAQ;AACR,IAAI;AACJ,EAAE;AACF,gDAAgD;AAChD,0DAA0D;AAC1D,IAAI;AACJ,EAAE;AACF,4CAA4C;AAC5C,0FAA0F;AAC1F,IAAI;AACJ,EAAE;AACF,mKAAmK;AACnK,eAAe;AACf,qBAAqB;AACrB,iBAAiB;AACjB,mCAAmC;AACnC,6BAA6B;AAC7B,oBAAoB;AACpB,QAAQ;AACR,IAAI;AACJ,EAAE;AACF,wIAAwI;AACxI,iDAAiD;AACjD,yCAAyC;AACzC,yDAAyD;AACzD,0CAA0C;AAC1C,sBAAsB;AACtB,QAAQ;AACR,EAAE;AACF,6EAA6E;AAC7E,kGAAkG;AAClG,IAAI;AACJ,EAAE;AACF,wHAAwH;AACxH,iDAAiD;AACjD,iDAAiD;AACjD,iIAAiI;AACjI,yEAAyE;AACzE,YAAY;AACZ,mBAAmB;AACnB,qBAAqB;AACrB,6BAA6B;AAC7B,uGAAuG;AACvG,gDAAgD;AAChD,YAAY;AACZ,QAAQ;AACR,EAAE;AACF,iEAAiE;AACjE,kEAAkE;AAClE,mBAAmB;AACnB,qBAAqB;AACrB,6BAA6B;AAC7B,sCAAsC;AACtC,gDAAgD;AAChD,YAAY;AACZ,QAAQ;AACR,EAAE;AACF,4FAA4F;AAC5F,IAAI"}
|