@toist/in 0.8.0 → 0.8.1
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/CHANGELOG.md +6 -0
- package/package.json +4 -4
- package/src/cli.ts +129 -11
- package/templates/default/_package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@toist/in` are recorded here.
|
|
4
4
|
|
|
5
|
+
## 0.8.1 — 2026-05-08
|
|
6
|
+
|
|
7
|
+
Patch: normalize toist run --remote JSON shape to match local RunSpecResult (.output/.runId, projected suspendedAt, results map). HTTP API and @toist/core unchanged.
|
|
8
|
+
|
|
9
|
+
Scaffold template pins `@toist/aja` and `@toist/spec` to `^0.8.1`.
|
|
10
|
+
|
|
5
11
|
## 0.8.0 — 2026-05-08
|
|
6
12
|
|
|
7
13
|
`@toist/in` is now the user-facing package: ships the `toist` CLI binary
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toist/in",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Adopt Toist into a repo: scaffold a Toist home or embedded .toist layout",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"README.md"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@toist/aja": "0.8.
|
|
20
|
-
"@toist/core": "0.8.
|
|
21
|
-
"@toist/spec": "0.8.
|
|
19
|
+
"@toist/aja": "0.8.1",
|
|
20
|
+
"@toist/core": "0.8.1",
|
|
21
|
+
"@toist/spec": "0.8.1"
|
|
22
22
|
}
|
|
23
23
|
}
|
package/src/cli.ts
CHANGED
|
@@ -62,6 +62,52 @@ interface CliTaskRef {
|
|
|
62
62
|
responseToken: string
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
type NormalizedStepList = Array<Record<string, unknown>>
|
|
66
|
+
|
|
67
|
+
type NormalizedRunResult =
|
|
68
|
+
| {
|
|
69
|
+
status: "done"
|
|
70
|
+
runId: number
|
|
71
|
+
output: unknown
|
|
72
|
+
steps: NormalizedStepList
|
|
73
|
+
results: Record<string, unknown>
|
|
74
|
+
}
|
|
75
|
+
| {
|
|
76
|
+
status: "suspended"
|
|
77
|
+
runId: number
|
|
78
|
+
suspendedAt: {
|
|
79
|
+
taskId: number
|
|
80
|
+
nodeId: string
|
|
81
|
+
cause: {
|
|
82
|
+
kind: "human.input" | "error_review"
|
|
83
|
+
spec: {
|
|
84
|
+
prompt: string
|
|
85
|
+
schema?: unknown
|
|
86
|
+
assignee?: string | null
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
task: {
|
|
91
|
+
id: number
|
|
92
|
+
kind: string
|
|
93
|
+
prompt: string
|
|
94
|
+
schema: unknown
|
|
95
|
+
assignee: string | null
|
|
96
|
+
responseToken: string
|
|
97
|
+
} | null
|
|
98
|
+
steps: NormalizedStepList
|
|
99
|
+
results: Record<string, unknown>
|
|
100
|
+
}
|
|
101
|
+
| {
|
|
102
|
+
status: "error"
|
|
103
|
+
runId: number
|
|
104
|
+
error: string
|
|
105
|
+
steps?: NormalizedStepList
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
type PrintableRunResult = RunSpecResult | NormalizedRunResult
|
|
109
|
+
type PrintableSuspendedRunResult = Extract<RunSpecResult, { status: "suspended" }> | Extract<NormalizedRunResult, { status: "suspended" }>
|
|
110
|
+
|
|
65
111
|
function help() {
|
|
66
112
|
console.log("toist <command> [options]\n")
|
|
67
113
|
console.log(" init run setup wizard")
|
|
@@ -159,6 +205,70 @@ function parseJsonValue(value: string | null | undefined): unknown {
|
|
|
159
205
|
try { return JSON.parse(value) } catch { return value }
|
|
160
206
|
}
|
|
161
207
|
|
|
208
|
+
function asCliTaskKind(kind: string): "human.input" | "error_review" {
|
|
209
|
+
if (kind !== "human.input" && kind !== "error_review") {
|
|
210
|
+
throw new Error(`unsupported task kind: ${kind}`)
|
|
211
|
+
}
|
|
212
|
+
return kind
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
async function fetchResultsMap(client: RunnerClient, runId: number): Promise<Record<string, unknown>> {
|
|
216
|
+
const nodes = await client.runs.nodes(runId)
|
|
217
|
+
const results: Record<string, unknown> = {}
|
|
218
|
+
for (const node of nodes) results[node.nodeId] = node.output
|
|
219
|
+
return results
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async function normalizeRemoteRunResult(
|
|
223
|
+
client: RunnerClient,
|
|
224
|
+
response: PipelineRunResponse,
|
|
225
|
+
): Promise<NormalizedRunResult> {
|
|
226
|
+
const base = {
|
|
227
|
+
runId: response.id,
|
|
228
|
+
status: response.status,
|
|
229
|
+
steps: ("steps" in response ? response.steps : []) as unknown as NormalizedStepList,
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (response.status === "done") {
|
|
233
|
+
return {
|
|
234
|
+
...base,
|
|
235
|
+
status: "done",
|
|
236
|
+
output: response.result,
|
|
237
|
+
results: await fetchResultsMap(client, response.id),
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (response.status === "suspended") {
|
|
242
|
+
const task = response.task
|
|
243
|
+
if (!task) throw new Error(`remote run ${response.id} suspended without task payload`)
|
|
244
|
+
|
|
245
|
+
return {
|
|
246
|
+
...base,
|
|
247
|
+
status: "suspended",
|
|
248
|
+
suspendedAt: {
|
|
249
|
+
taskId: task.id,
|
|
250
|
+
nodeId: response.suspendedAt,
|
|
251
|
+
cause: {
|
|
252
|
+
kind: asCliTaskKind(task.kind),
|
|
253
|
+
spec: {
|
|
254
|
+
prompt: task.prompt,
|
|
255
|
+
schema: task.schema,
|
|
256
|
+
assignee: task.assignee,
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
task,
|
|
261
|
+
results: await fetchResultsMap(client, response.id),
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return {
|
|
266
|
+
...base,
|
|
267
|
+
status: "error",
|
|
268
|
+
error: response.error,
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
162
272
|
async function waitForRemoteRun(client: RunnerClient, runId: number): Promise<PipelineRunResponse> {
|
|
163
273
|
for (;;) {
|
|
164
274
|
const run = await client.runs.get(runId)
|
|
@@ -320,12 +430,16 @@ async function promptTaskResponse(task: CliTaskRef): Promise<unknown> {
|
|
|
320
430
|
}
|
|
321
431
|
}
|
|
322
432
|
|
|
323
|
-
function printFinalResult(result:
|
|
324
|
-
|
|
325
|
-
|
|
433
|
+
function printFinalResult(result: PrintableRunResult) {
|
|
434
|
+
if ("events" in result) {
|
|
435
|
+
const { events: _events, ...printable } = result
|
|
436
|
+
console.log(JSON.stringify(printable, null, 2))
|
|
437
|
+
return
|
|
438
|
+
}
|
|
439
|
+
console.log(JSON.stringify(result, null, 2))
|
|
326
440
|
}
|
|
327
441
|
|
|
328
|
-
function printSuspendAsJson(result:
|
|
442
|
+
function printSuspendAsJson(result: PrintableSuspendedRunResult) {
|
|
329
443
|
console.log(JSON.stringify({ runId: result.runId, suspendedAt: result.suspendedAt }, null, 2))
|
|
330
444
|
}
|
|
331
445
|
|
|
@@ -414,20 +528,22 @@ async function runRemoteCommand(opts: RunCliOptions) {
|
|
|
414
528
|
|
|
415
529
|
if (opts.suspendAsJson) {
|
|
416
530
|
const final = await waitForRemoteRun(client, started.id)
|
|
417
|
-
|
|
418
|
-
|
|
531
|
+
const normalized = await normalizeRemoteRunResult(client, final)
|
|
532
|
+
if (normalized.status === "suspended") {
|
|
533
|
+
printSuspendAsJson(normalized)
|
|
419
534
|
return
|
|
420
535
|
}
|
|
421
|
-
|
|
422
|
-
if (
|
|
536
|
+
printFinalResult(normalized)
|
|
537
|
+
if (normalized.status === "error") process.exit(1)
|
|
423
538
|
return
|
|
424
539
|
}
|
|
425
540
|
|
|
426
541
|
const eventsPromise = printRemoteRunEvents(client, started.id)
|
|
427
542
|
const final = await waitForRemoteRun(client, started.id)
|
|
543
|
+
const normalized = await normalizeRemoteRunResult(client, final)
|
|
428
544
|
await eventsPromise
|
|
429
|
-
|
|
430
|
-
if (
|
|
545
|
+
printFinalResult(normalized)
|
|
546
|
+
if (normalized.status === "error") process.exit(1)
|
|
431
547
|
}
|
|
432
548
|
|
|
433
549
|
async function runCommand(opts: RunCliOptions) {
|
|
@@ -577,7 +693,9 @@ async function answerTaskCommand(taskId: number, responseArg?: string, remote?:
|
|
|
577
693
|
response,
|
|
578
694
|
respondedBy: "cli",
|
|
579
695
|
})
|
|
580
|
-
|
|
696
|
+
const normalized = await normalizeRemoteRunResult(client, result)
|
|
697
|
+
printFinalResult(normalized)
|
|
698
|
+
if (normalized.status === "error") process.exit(1)
|
|
581
699
|
return
|
|
582
700
|
}
|
|
583
701
|
|