terse-cli 0.9.20 → 0.9.22
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 +1 -1
- 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/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/init.d.ts +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +86 -28
- package/dist/commands/init.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 +2 -0
- 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 +115 -121
- 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/dist/templates.d.ts +6 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +78 -0
- package/dist/templates.js.map +1 -0
- package/package.json +3 -4
- package/templates/typescript/init/package.json.hbs +1 -2
|
@@ -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":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/providers/typescript/runtimes/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/providers/typescript/runtimes/index.ts"],"names":[],"mappings":""}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
+
// export { directJobRuntime } from "./directJobRuntime.js"
|
|
4
|
+
// export { durableJobRuntime } from "./durableJobRuntime.js"
|
|
5
|
+
// export type { JobRuntime, ResumeRunOptions, RunJobOptions } from "./JobRuntime.js"
|
|
3
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/providers/typescript/runtimes/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/providers/typescript/runtimes/index.ts"],"names":[],"mappings":";AAAA,uHAAuH;AACvH,2DAA2D;AAC3D,6DAA6D;AAC7D,qFAAqF"}
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
import type { SessionStreamEvent } from "terse-sdk";
|
|
2
|
-
import { type SessionHandle } from "../../shared/sessionStream.js";
|
|
3
|
-
export declare function withSession<T>(apiKey: string, isVerbose: boolean, pauseUiAround: <U>(fn: () => Promise<U>) => Promise<U>, action: (sessionId: string) => Promise<T>, onEvent?: (event: SessionStreamEvent) => void, started?: Promise<SessionHandle>): Promise<T>;
|
|
4
|
-
export declare function startSession(apiKey: string, isVerbose: boolean, pauseUiAround: <U>(fn: () => Promise<U>) => Promise<U>, onEvent?: (event: SessionStreamEvent) => void): Promise<SessionHandle>;
|
|
5
1
|
//# sourceMappingURL=session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/providers/typescript/runtimes/session.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/providers/typescript/runtimes/session.ts"],"names":[],"mappings":""}
|
|
@@ -1,65 +1,79 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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 { isAgentApprovalHandlingClaimed } from "terse-sdk"
|
|
5
|
+
// import type { SessionStreamEvent } from "terse-sdk"
|
|
6
|
+
//
|
|
7
|
+
// import { isCliRunCommandEnabled } from "../../../env.js"
|
|
8
|
+
// import { type SessionHandle, openSessionStream, promptForToolApproval, submitApprovalDecision } from "../../shared/sessionStream.js"
|
|
9
|
+
//
|
|
10
|
+
// let sessionPaused = false
|
|
11
|
+
//
|
|
12
|
+
// // Holds a session stream open (for tool-approval routing) for the duration of `action`,
|
|
13
|
+
// // adopting `started` when a caller opened one ahead of time.
|
|
14
|
+
// export async function withSession<T>(
|
|
15
|
+
// apiKey: string,
|
|
16
|
+
// isVerbose: boolean,
|
|
17
|
+
// pauseUiAround: <U>(fn: () => Promise<U>) => Promise<U>,
|
|
18
|
+
// action: (sessionId: string) => Promise<T>,
|
|
19
|
+
// onEvent?: (event: SessionStreamEvent) => void,
|
|
20
|
+
// started?: Promise<SessionHandle>
|
|
21
|
+
// ): Promise<T> {
|
|
22
|
+
// const session = await (started ?? startSession(apiKey, isVerbose, pauseUiAround, onEvent))
|
|
23
|
+
//
|
|
24
|
+
// try {
|
|
25
|
+
// return await action(session.sessionId)
|
|
26
|
+
// } finally {
|
|
27
|
+
// session.close?.()
|
|
28
|
+
// }
|
|
29
|
+
// }
|
|
30
|
+
//
|
|
31
|
+
// // Opens the stream without holding it: the caller closes it by handing it to withSession.
|
|
32
|
+
// export function startSession(apiKey: string, isVerbose: boolean, pauseUiAround: <U>(fn: () => Promise<U>) => Promise<U>, onEvent?: (event: SessionStreamEvent) => void): Promise<SessionHandle> {
|
|
33
|
+
// let latestRunId: string | null = null
|
|
34
|
+
//
|
|
35
|
+
// const handleSessionEvent = async (event: SessionStreamEvent): Promise<void> => {
|
|
36
|
+
// onEvent?.(event)
|
|
37
|
+
// if (event.type === "run_started") {
|
|
38
|
+
// latestRunId = event.runId
|
|
39
|
+
// return
|
|
40
|
+
// }
|
|
41
|
+
// if (event.type !== "tool_approval_requested") return
|
|
42
|
+
// if (isCliRunCommandEnabled()) return
|
|
43
|
+
// if (isAgentApprovalHandlingClaimed()) return
|
|
44
|
+
//
|
|
45
|
+
// const runId = latestRunId
|
|
46
|
+
// if (!runId) {
|
|
47
|
+
// console.error(chalk.red(" Received approval request before run_started — cannot route decision."))
|
|
48
|
+
// return
|
|
49
|
+
// }
|
|
50
|
+
//
|
|
51
|
+
// const { toolName, arguments: rawArguments, stepId } = event.toolApprovalRequested
|
|
52
|
+
//
|
|
53
|
+
// if (!process.stdout.isTTY) {
|
|
54
|
+
// console.error(chalk.red(` Approval required for "${toolName}" but no TTY is attached — auto-rejecting.`))
|
|
55
|
+
// console.error(chalk.dim(" In non-interactive contexts, set TerseAgent.onApprovalRequired in your job code."))
|
|
56
|
+
// try {
|
|
57
|
+
// await submitApprovalDecision(apiKey, { runId, stepId, approved: false })
|
|
58
|
+
// } catch (error) {
|
|
59
|
+
// console.error(chalk.red(` Failed to submit auto-reject: ${(error as Error).message}`))
|
|
60
|
+
// }
|
|
61
|
+
// return
|
|
62
|
+
// }
|
|
63
|
+
//
|
|
64
|
+
// sessionPaused = true
|
|
65
|
+
// try {
|
|
66
|
+
// await pauseUiAround(async () => {
|
|
67
|
+
// const approved = await promptForToolApproval(toolName, rawArguments)
|
|
68
|
+
// await submitApprovalDecision(apiKey, { runId, stepId, approved })
|
|
69
|
+
// })
|
|
70
|
+
// } catch (error) {
|
|
71
|
+
// console.error(chalk.red(` Failed to submit approval decision: ${(error as Error).message}`))
|
|
72
|
+
// } finally {
|
|
73
|
+
// sessionPaused = false
|
|
74
|
+
// }
|
|
75
|
+
// }
|
|
76
|
+
//
|
|
77
|
+
// return openSessionStream(apiKey, { verbose: isVerbose, isPaused: () => sessionPaused, onEvent: handleSessionEvent })
|
|
78
|
+
// }
|
|
65
79
|
//# sourceMappingURL=session.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../../src/providers/typescript/runtimes/session.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../../src/providers/typescript/runtimes/session.ts"],"names":[],"mappings":";AAAA,uHAAuH;AACvH,4BAA4B;AAC5B,6DAA6D;AAC7D,sDAAsD;AACtD,EAAE;AACF,2DAA2D;AAC3D,uIAAuI;AACvI,EAAE;AACF,4BAA4B;AAC5B,EAAE;AACF,2FAA2F;AAC3F,gEAAgE;AAChE,wCAAwC;AACxC,sBAAsB;AACtB,0BAA0B;AAC1B,8DAA8D;AAC9D,iDAAiD;AACjD,qDAAqD;AACrD,uCAAuC;AACvC,kBAAkB;AAClB,iGAAiG;AACjG,EAAE;AACF,YAAY;AACZ,iDAAiD;AACjD,kBAAkB;AAClB,4BAA4B;AAC5B,QAAQ;AACR,IAAI;AACJ,EAAE;AACF,6FAA6F;AAC7F,oMAAoM;AACpM,4CAA4C;AAC5C,EAAE;AACF,uFAAuF;AACvF,2BAA2B;AAC3B,8CAA8C;AAC9C,wCAAwC;AACxC,qBAAqB;AACrB,YAAY;AACZ,+DAA+D;AAC/D,+CAA+C;AAC/C,uDAAuD;AACvD,EAAE;AACF,oCAAoC;AACpC,wBAAwB;AACxB,kHAAkH;AAClH,qBAAqB;AACrB,YAAY;AACZ,EAAE;AACF,4FAA4F;AAC5F,EAAE;AACF,uCAAuC;AACvC,yHAAyH;AACzH,6HAA6H;AAC7H,oBAAoB;AACpB,2FAA2F;AAC3F,gCAAgC;AAChC,0GAA0G;AAC1G,gBAAgB;AAChB,qBAAqB;AACrB,YAAY;AACZ,EAAE;AACF,+BAA+B;AAC/B,gBAAgB;AAChB,gDAAgD;AAChD,uFAAuF;AACvF,oFAAoF;AACpF,iBAAiB;AACjB,4BAA4B;AAC5B,4GAA4G;AAC5G,sBAAsB;AACtB,oCAAoC;AACpC,YAAY;AACZ,QAAQ;AACR,EAAE;AACF,2HAA2H;AAC3H,IAAI"}
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import type { CreateJobParameters, TerseJobContext } from "terse-sdk";
|
|
2
|
-
import type { SerializedEvent } from "terse-types";
|
|
3
|
-
export declare function shouldRunTerseWorkflow({ job, event, context }: {
|
|
4
|
-
job: CreateJobParameters;
|
|
5
|
-
event: SerializedEvent;
|
|
6
|
-
context: TerseJobContext;
|
|
7
|
-
}): Promise<boolean>;
|
|
8
1
|
//# sourceMappingURL=terseWorkflow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terseWorkflow.d.ts","sourceRoot":"","sources":["../../../src/providers/typescript/terseWorkflow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"terseWorkflow.d.ts","sourceRoot":"","sources":["../../../src/providers/typescript/terseWorkflow.ts"],"names":[],"mappings":""}
|