@rhizogrip/spore-cli 1.60.1 → 1.62.0
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/bin/spore.js +2 -0
- package/package.json +2 -2
- package/src/dispatch.js +30 -2
- package/tui/index.js +1 -1
package/bin/spore.js
CHANGED
|
@@ -82,6 +82,7 @@ const VERBS = `Usage:
|
|
|
82
82
|
spore tick fire every schedule that is due — run by a timer
|
|
83
83
|
spore approval ask <name> [<request.json>|-] ask people to choose, with buttons only they can press, where the request says
|
|
84
84
|
spore approval ls <name> the approvals asked in it, and how each ended
|
|
85
|
+
spore interaction outcome <name> <id> [<outcome.json>|-] an interaction's outcome, from a handler on this host
|
|
85
86
|
spore job ls [<name>] its jobs: running ones with their progress, ended ones how
|
|
86
87
|
spore job stop <name> <job> ask a running job's supervisor to stop it
|
|
87
88
|
spore pause [why] stop every turn and job of your spores, and start none
|
|
@@ -164,6 +165,7 @@ const SHAPES = {
|
|
|
164
165
|
plugin: { bare: 'ls', subs: { ls: withJson(0), show: withJson(1), allow: withJson(ALL), disallow: withJson(1) } },
|
|
165
166
|
schedule: { bare: 'ls', subs: { set: withJson(3), rm: withJson(2), ls: withJson(1) } },
|
|
166
167
|
approval: { bare: 'ls', subs: { ask: withJson(2), ls: withJson(1) } },
|
|
168
|
+
interaction: { subs: { outcome: { flags: [], most: 3 } } },
|
|
167
169
|
job: { bare: 'ls', subs: { ls: withJson(1), stop: withJson(2) } },
|
|
168
170
|
tick: withJson(0),
|
|
169
171
|
pause: withJson(ALL),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rhizogrip/spore-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.62.0",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Christophe Le Bars",
|
|
6
6
|
"email": "clb@toort.net"
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"minimist": "^1.2.8"
|
|
55
55
|
},
|
|
56
56
|
"optionalDependencies": {
|
|
57
|
-
"@rhizogrip/spore": "1.
|
|
57
|
+
"@rhizogrip/spore": "1.62.0"
|
|
58
58
|
},
|
|
59
59
|
"license": "Apache-2.0"
|
|
60
60
|
}
|
package/src/dispatch.js
CHANGED
|
@@ -13,7 +13,7 @@ import { readFileSync } from 'node:fs'
|
|
|
13
13
|
import { homedir } from 'node:os'
|
|
14
14
|
import { basename, join, resolve } from 'node:path'
|
|
15
15
|
|
|
16
|
-
import { addTo, allowPlugin, annotate, billingFor, bytesText, changeText, define, defaultModel, disallowPlugin, durationText, edit, extend, flush, getKey, jobs, list, listApprovals, listPlugins, log, pause, remake, remove, removeFrom, removeSchedule, requestApproval, runningLines, schedules, setDefaultModel, setKey, setSchedule, settings, show, showPlugin, sql, stateWord, stopJob, switchModel, tick, tickReport, unmetered, unpause, upgrade, usage, wrap, CONFIG_FILE, DEFAULT_SPORANGIUM, errorText } from '@rhizogrip/spore'
|
|
16
|
+
import { addTo, allowPlugin, annotate, billingFor, bytesText, changeText, define, defaultModel, disallowPlugin, durationText, edit, extend, flush, getKey, interactionOutcome, jobs, list, listApprovals, listPlugins, log, pause, remake, remove, removeFrom, removeSchedule, requestApproval, runningLines, schedules, setDefaultModel, setKey, setSchedule, settings, show, showPlugin, sql, stateWord, stopJob, switchModel, tick, tickReport, unmetered, unpause, upgrade, usage, wrap, CONFIG_FILE, DEFAULT_SPORANGIUM, errorText } from '@rhizogrip/spore'
|
|
17
17
|
import { diagnose, hostReport, renderDoctor, renderReport } from './doctor.js'
|
|
18
18
|
import { hook } from './hooks.js'
|
|
19
19
|
import { withMoHint } from './mo.js'
|
|
@@ -75,7 +75,8 @@ function renderFlush ({ open }) {
|
|
|
75
75
|
const still = [
|
|
76
76
|
...(open.question ? [`the question it asked: ${cut(open.question)}`] : []),
|
|
77
77
|
...open.approvals.map(one => `approval ${one.id} in ${one.place}, open until ${when(one.until)}`),
|
|
78
|
-
...open.jobs.map(one => `job ${one.name}, running since ${when(one.startedAt)}`)
|
|
78
|
+
...open.jobs.map(one => `job ${one.name}, running since ${when(one.startedAt)}`),
|
|
79
|
+
...open.interactions.map(one => `interaction ${one.id}, asked of ${one.handler} at ${when(one.askedAt)}`)
|
|
79
80
|
]
|
|
80
81
|
if (still.length) console.log(`still open, and it is told so:\n${still.map(line => ` ${line}`).join('\n')}`)
|
|
81
82
|
}
|
|
@@ -768,6 +769,33 @@ export async function manage (verb, argv) {
|
|
|
768
769
|
}
|
|
769
770
|
return emit(requestApproval({ ws, request }), (r) => { console.log(`asked ${r.approval}, open until ${when(r.until)} — the service of the place it names posts it`) })
|
|
770
771
|
}
|
|
772
|
+
if (verb === 'interaction') {
|
|
773
|
+
const [, sub, ws, id, from] = argv._
|
|
774
|
+
if (sub !== 'outcome') {
|
|
775
|
+
console.error(sub ? `spore: interaction has no "${sub}" — outcome` : 'spore: interaction needs outcome — spore interaction outcome <name> <id> [<outcome.json>|-]')
|
|
776
|
+
return 2
|
|
777
|
+
}
|
|
778
|
+
if (!ws || !id) {
|
|
779
|
+
console.error('spore: interaction outcome needs a spore and an interaction — spore interaction outcome <name> <id> [<outcome.json>|-]')
|
|
780
|
+
return 2
|
|
781
|
+
}
|
|
782
|
+
const source = !from || from === '-' ? await readStdin() : readFileSync(resolve(from), 'utf8')
|
|
783
|
+
const said = (line, code) => {
|
|
784
|
+
console.log(JSON.stringify(line))
|
|
785
|
+
return code
|
|
786
|
+
}
|
|
787
|
+
let outcome
|
|
788
|
+
try {
|
|
789
|
+
outcome = JSON.parse(source)
|
|
790
|
+
} catch (err) {
|
|
791
|
+
return said({ type: 'INTERACTION_OUTCOME', message: 'the outcome is not JSON', detail: err.message }, 1)
|
|
792
|
+
}
|
|
793
|
+
try {
|
|
794
|
+
return said(interactionOutcome({ ws, id, outcome }), 0)
|
|
795
|
+
} catch (err) {
|
|
796
|
+
return said({ type: err.type, message: err.message, detail: err.detail }, ['ADMISSION_FULL', 'PAUSED'].includes(err.type) ? 75 : 1)
|
|
797
|
+
}
|
|
798
|
+
}
|
|
771
799
|
if (verb === 'rm') {
|
|
772
800
|
const name = argv._[1]
|
|
773
801
|
if (!name) {
|
package/tui/index.js
CHANGED
|
@@ -523,7 +523,7 @@ export async function runTui ({ ws, commands = [], renderTool = null, greeting =
|
|
|
523
523
|
if (name === 'flush') {
|
|
524
524
|
try {
|
|
525
525
|
const { open } = flush({ ws: state.ws, by: 'its operator' })
|
|
526
|
-
const still = (open.question ? 1 : 0) + open.approvals.length + open.jobs.length
|
|
526
|
+
const still = (open.question ? 1 : 0) + open.approvals.length + open.jobs.length + open.interactions.length
|
|
527
527
|
return notice(`flushed — the next turn starts over; nothing is forgotten${still ? `, and it is told of ${still} thing${still > 1 ? 's' : ''} still open` : ''}`)
|
|
528
528
|
} catch (err) {
|
|
529
529
|
return notice(errorText(err))
|