@codyswann/lisa 4.98.1 → 4.98.3
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/core/nightly-e2e-guard-behavior-certificate.js +2 -2
- package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
- package/dist/core/upstream-evidence-manifest.js +27 -8
- package/dist/core/upstream-evidence-manifest.js.map +1 -1
- package/package.json +4 -4
- package/plugins/lisa/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/SKILL.md +50 -13
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/references/runbook-template.md +4 -2
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/answer-record.mjs +97 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-answer-record.mjs +71 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-cycle.mjs +1 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-human.mjs +3 -2
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-usage.mjs +30 -4
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/human-needed.mjs +26 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/ledger-questions.mjs +16 -3
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/session-manager.mjs +7 -1
- package/plugins/lisa/skills/lisa-session-manager/SKILL.md +50 -13
- package/plugins/lisa/skills/lisa-session-manager/references/runbook-template.md +4 -2
- package/plugins/lisa/skills/lisa-session-manager/scripts/answer-record.mjs +97 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-answer-record.mjs +71 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-cycle.mjs +1 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-human.mjs +3 -2
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-usage.mjs +30 -4
- package/plugins/lisa/skills/lisa-session-manager/scripts/human-needed.mjs +26 -1
- package/plugins/lisa/skills/lisa-session-manager/scripts/ledger-questions.mjs +16 -3
- package/plugins/lisa/skills/lisa-session-manager/scripts/session-manager.mjs +7 -1
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-agy/skills/lisa-session-manager/SKILL.md +50 -13
- package/plugins/lisa-agy/skills/lisa-session-manager/references/runbook-template.md +4 -2
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/answer-record.mjs +97 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-answer-record.mjs +71 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-cycle.mjs +1 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-human.mjs +3 -2
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-usage.mjs +30 -4
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/human-needed.mjs +26 -1
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/ledger-questions.mjs +16 -3
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/session-manager.mjs +7 -1
- package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-agy/plugin.json +1 -1
- package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/skills/lisa-session-manager/SKILL.md +50 -13
- package/plugins/lisa-copilot/skills/lisa-session-manager/references/runbook-template.md +4 -2
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/answer-record.mjs +97 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-answer-record.mjs +71 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-cycle.mjs +1 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-human.mjs +3 -2
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-usage.mjs +30 -4
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/human-needed.mjs +26 -1
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/ledger-questions.mjs +16 -3
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/session-manager.mjs +7 -1
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/skills/lisa-session-manager/SKILL.md +50 -13
- package/plugins/lisa-cursor/skills/lisa-session-manager/references/runbook-template.md +4 -2
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/answer-record.mjs +97 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-answer-record.mjs +71 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-cycle.mjs +1 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-human.mjs +3 -2
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-usage.mjs +30 -4
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/human-needed.mjs +26 -1
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/ledger-questions.mjs +16 -3
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/session-manager.mjs +7 -1
- package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/skills/lisa-session-manager/SKILL.md +50 -13
- package/plugins/lisa-devin/skills/lisa-session-manager/references/runbook-template.md +4 -2
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/answer-record.mjs +97 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-answer-record.mjs +71 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-cycle.mjs +1 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-human.mjs +3 -2
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-usage.mjs +30 -4
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/human-needed.mjs +26 -1
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/ledger-questions.mjs +16 -3
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/session-manager.mjs +7 -1
- package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-agy/plugin.json +1 -1
- package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-agy/plugin.json +1 -1
- package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-agy/plugin.json +1 -1
- package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-agy/plugin.json +1 -1
- package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-agy/plugin.json +1 -1
- package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-agy/plugin.json +1 -1
- package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-agy/plugin.json +1 -1
- package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/src/base/skills/lisa-session-manager/SKILL.md +50 -13
- package/plugins/src/base/skills/lisa-session-manager/references/runbook-template.md +4 -2
- package/plugins/src/base/skills/lisa-session-manager/scripts/answer-record.mjs +97 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-answer-record.mjs +71 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-cycle.mjs +1 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-human.mjs +3 -2
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-usage.mjs +30 -4
- package/plugins/src/base/skills/lisa-session-manager/scripts/human-needed.mjs +26 -1
- package/plugins/src/base/skills/lisa-session-manager/scripts/ledger-questions.mjs +16 -3
- package/plugins/src/base/skills/lisa-session-manager/scripts/session-manager.mjs +7 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Record an operator's answer on the item when no worker will receive it
|
|
3
|
+
* (CodySwannGT/lisa#4624).
|
|
4
|
+
*
|
|
5
|
+
* An answer to a question whose worker reported `DONE` or `FAILED` (including
|
|
6
|
+
* one the operator stopped with `stop REF`), or to an `exhausted` item, is
|
|
7
|
+
* delivered to no worker: the next attempt can only read it on the item. An
|
|
8
|
+
* answer given with `answer` (source `cli`) or on Telegram (source `channel`)
|
|
9
|
+
* lives only in the ledger, and clearing the question deletes it there, so
|
|
10
|
+
* the manager must post it on the item, and read it back, before it clears.
|
|
11
|
+
* An answer that came from the item is already there, and a live worker
|
|
12
|
+
* receives its answer directly; both are left as they were.
|
|
13
|
+
*
|
|
14
|
+
* Pure: no I/O and no clock (the time is the answer's own `at`). The answer
|
|
15
|
+
* is data: it is quoted verbatim, never interpreted.
|
|
16
|
+
* @module session-manager/answer-record
|
|
17
|
+
*/
|
|
18
|
+
import {
|
|
19
|
+
MANAGER_COMMENT_PREFIX,
|
|
20
|
+
findCredentialShape,
|
|
21
|
+
} from "./human-needed.mjs";
|
|
22
|
+
|
|
23
|
+
/** Worker statuses after which no worker receives an answer. */
|
|
24
|
+
const FINISHED = new Set(["DONE", "FAILED"]);
|
|
25
|
+
|
|
26
|
+
/** How each answer source is named in the comment. */
|
|
27
|
+
const SOURCE_NAMES = { cli: "answer", channel: "Telegram" };
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The answer, kept verbatim. A one-line answer follows the colon; a longer one
|
|
31
|
+
* is quoted line by line beneath it, so its own lines can never pass for a
|
|
32
|
+
* new comment's first line.
|
|
33
|
+
* @param {string} head - First line, ending with the colon
|
|
34
|
+
* @param {string} text - Answer text
|
|
35
|
+
* @returns {string} Comment body
|
|
36
|
+
*/
|
|
37
|
+
function withAnswer(head, text) {
|
|
38
|
+
if (!/[\r\n]/.test(text)) return `${head} ${text}`;
|
|
39
|
+
const quoted = text
|
|
40
|
+
.split(/\r?\n|\r/)
|
|
41
|
+
.map(line => (line === "" ? ">" : `> ${line}`));
|
|
42
|
+
return [head, "", ...quoted].join("\n");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Why no comment is needed, or null when one is. No worker receives the
|
|
47
|
+
* answer when the worker finished, the item is `exhausted`, or no worker has
|
|
48
|
+
* been started yet (a `decision`, say): then only the item can carry it. A
|
|
49
|
+
* `repo-route` answer is always carried by the `repo:<name>` stamp.
|
|
50
|
+
* @param {string | undefined} status - The ledger item's status
|
|
51
|
+
* @param {string | null | undefined} worker - The ledger item's worker
|
|
52
|
+
* @param {{kind?: string, answer?: {source: string} | null} | null} pending
|
|
53
|
+
* - The pending question
|
|
54
|
+
* @returns {string | null} Reason
|
|
55
|
+
*/
|
|
56
|
+
function skipReason(status, worker, pending) {
|
|
57
|
+
if (!pending) return "no-pending-question";
|
|
58
|
+
if (!pending.answer) return "no-answer-queued";
|
|
59
|
+
if (pending.answer.source === "item") return "answered-on-item";
|
|
60
|
+
if (pending.kind === "repo-route") return "routed-by-repo-stamp";
|
|
61
|
+
if (pending.kind === "exhausted" || FINISHED.has(status ?? "")) return null;
|
|
62
|
+
return worker ? "worker-not-finished" : null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Plan recording a queued answer on the item. Throws when the answer looks
|
|
67
|
+
* like it holds a credential: it would be posted on the item.
|
|
68
|
+
* @param {{ref: string, status?: string, worker?: string | null,
|
|
69
|
+
* pending: object | null}} input - The item's ref, its ledger status and
|
|
70
|
+
* worker, and its pending question
|
|
71
|
+
* @returns {{ref: string, record: false, reason: string} |
|
|
72
|
+
* {ref: string, record: true, source: string, answerAt: string | null,
|
|
73
|
+
* comment: string}} Plan; answerAt is the queued answer's `at`, which
|
|
74
|
+
* `ledger clear-question --expect-answer-at` checks before clearing
|
|
75
|
+
*/
|
|
76
|
+
export function planAnswerRecord({ ref, status, worker, pending }) {
|
|
77
|
+
const reason = skipReason(status, worker, pending);
|
|
78
|
+
if (reason) return { ref, record: false, reason };
|
|
79
|
+
const { source, text, at } = pending.answer;
|
|
80
|
+
const shape = findCredentialShape(text);
|
|
81
|
+
if (shape) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
`the queued answer looks like it holds a credential (${shape}); it would be posted on the item. Nothing was planned: have the operator answer again without it and keep secrets in the secrets provider.`
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
const by = SOURCE_NAMES[source] ?? source;
|
|
87
|
+
return {
|
|
88
|
+
ref,
|
|
89
|
+
record: true,
|
|
90
|
+
source,
|
|
91
|
+
answerAt: at ?? null,
|
|
92
|
+
comment: withAnswer(
|
|
93
|
+
`${MANAGER_COMMENT_PREFIX} The operator answered the question above (by ${by}, ${at ?? "time unknown"}):`,
|
|
94
|
+
text
|
|
95
|
+
),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Answers that only the item can carry to the next attempt
|
|
3
|
+
* (CodySwannGT/lisa#4624): `channel-answer` and `answer-plan`.
|
|
4
|
+
*
|
|
5
|
+
* `channel-answer` queues an operator's Telegram answer in the ledger (source
|
|
6
|
+
* `channel`), so it is handled like a terminal answer instead of being
|
|
7
|
+
* followed straight into Clearing and lost. `answer-plan` says whether the
|
|
8
|
+
* queued answer must be posted on the item before the question is cleared
|
|
9
|
+
* (the worker finished, or the item is `exhausted`) and gives the comment. It
|
|
10
|
+
* writes nothing; the manager posts through `lisa-tracker-write`, as it does
|
|
11
|
+
* for `mark-plan`. Both are manager-only: the operator answers with `answer`.
|
|
12
|
+
*
|
|
13
|
+
* Answer text arrives on stdin, never in argv, and a credential-shaped
|
|
14
|
+
* answer is refused (exit 2) before it can be queued or posted.
|
|
15
|
+
* @module session-manager/cli-answer-record
|
|
16
|
+
*/
|
|
17
|
+
import { planAnswerRecord } from "./answer-record.mjs";
|
|
18
|
+
import { refuseCredential } from "./cli-human.mjs";
|
|
19
|
+
import {
|
|
20
|
+
asSetupError,
|
|
21
|
+
asSetupErrorAsync,
|
|
22
|
+
requirePositional,
|
|
23
|
+
stdinText,
|
|
24
|
+
} from "./cli-runtime.mjs";
|
|
25
|
+
import { readLedger } from "./ledger.mjs";
|
|
26
|
+
import { queueAnswer } from "./ledger-questions.mjs";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* `channel-answer <ref>` (answer on stdin): queue the operator's Telegram
|
|
30
|
+
* answer. Exit 2 when the ref has no pending question, or the text looks
|
|
31
|
+
* like a credential.
|
|
32
|
+
* @param {object} ctx - CLI context
|
|
33
|
+
* @returns {Promise<{ json: object }>} `{queued:true,ref,source:"channel"}`
|
|
34
|
+
*/
|
|
35
|
+
export async function channelAnswer(ctx) {
|
|
36
|
+
const ref = requirePositional(ctx, "ref");
|
|
37
|
+
const text = stdinText(ctx, "answer");
|
|
38
|
+
refuseCredential(text);
|
|
39
|
+
await asSetupErrorAsync(() =>
|
|
40
|
+
queueAnswer(ctx.root, { ref, source: "channel", text })
|
|
41
|
+
);
|
|
42
|
+
return { json: { queued: true, ref, source: "channel" } };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* `answer-plan <ref>`: plan recording the queued answer on the item. Exit 2
|
|
47
|
+
* when the ledger is corrupt or the answer it would post looks like a
|
|
48
|
+
* credential (nothing is printed, so nothing can be posted).
|
|
49
|
+
* @param {object} ctx - CLI context
|
|
50
|
+
* @returns {Promise<{ json: object }>} `{ref,record:false,reason}` or
|
|
51
|
+
* `{ref,record:true,source,comment}`
|
|
52
|
+
*/
|
|
53
|
+
export async function answerPlan(ctx) {
|
|
54
|
+
const ref = requirePositional(ctx, "ref");
|
|
55
|
+
const ledger = await asSetupErrorAsync(() => readLedger(ctx.root));
|
|
56
|
+
const entry = Object.hasOwn(ledger.items, ref) ? ledger.items[ref] : null;
|
|
57
|
+
const pending = entry?.pendingQuestion ?? null;
|
|
58
|
+
// The credential refusal lives in planAnswerRecord and fires only when the
|
|
59
|
+
// plan would post the answer: an answer it would not post (one taken from
|
|
60
|
+
// the item, say) is not this command's to refuse. A refusal is a setup
|
|
61
|
+
// error: exit 2, nothing printed, so nothing can be posted.
|
|
62
|
+
const plan = asSetupError(() =>
|
|
63
|
+
planAnswerRecord({
|
|
64
|
+
ref,
|
|
65
|
+
status: entry?.status,
|
|
66
|
+
worker: entry?.worker ?? null,
|
|
67
|
+
pending,
|
|
68
|
+
})
|
|
69
|
+
);
|
|
70
|
+
return { json: plan };
|
|
71
|
+
}
|
|
@@ -131,6 +131,7 @@ const LEDGER_ACTIONS = {
|
|
|
131
131
|
clearPendingQuestion(ctx.root, {
|
|
132
132
|
ref: requirePositional(ctx, "ref"),
|
|
133
133
|
resetAttempts: ctx.values["reset-attempts"] === true,
|
|
134
|
+
expectAnswerAt: ctx.values["expect-answer-at"],
|
|
134
135
|
}),
|
|
135
136
|
async finish(ctx) {
|
|
136
137
|
const status = ctx.values.status;
|
|
@@ -116,12 +116,13 @@ function withOverruledMarker(plan, ref, label) {
|
|
|
116
116
|
/**
|
|
117
117
|
* Refuse (exit 2) text that looks like it holds a credential.
|
|
118
118
|
* @param {string} text - Answer text
|
|
119
|
+
* @param {string} [consequence] - What the refusal left undone
|
|
119
120
|
*/
|
|
120
|
-
function refuseCredential(text) {
|
|
121
|
+
export function refuseCredential(text, consequence = "nothing was queued") {
|
|
121
122
|
const shape = findCredentialShape(text);
|
|
122
123
|
if (shape) {
|
|
123
124
|
throw new CliError(
|
|
124
|
-
`The answer looks like it holds a credential (${shape});
|
|
125
|
+
`The answer looks like it holds a credential (${shape}); ${consequence}. Keep secrets in the secrets provider.`,
|
|
125
126
|
EXIT.SETUP
|
|
126
127
|
);
|
|
127
128
|
}
|
|
@@ -189,9 +189,13 @@ Per cycle
|
|
|
189
189
|
answer after it, and never reads it as an answer. Exit 2 when it is
|
|
190
190
|
missing or not a tracker comment id, or <ref> has no pending
|
|
191
191
|
question.
|
|
192
|
-
ledger clear-question <ref> [--reset-attempts]
|
|
193
|
-
After the answer is delivered
|
|
192
|
+
ledger clear-question <ref> [--reset-attempts] [--expect-answer-at <iso>]
|
|
193
|
+
After the answer is delivered (or recorded on the item and read back,
|
|
194
|
+
per answer-plan) and the marker removed. --reset-attempts
|
|
194
195
|
zeroes the attempt count (an exhausted item a human has answered).
|
|
196
|
+
--expect-answer-at: the answerAt answer-plan returned; exit 2 and
|
|
197
|
+
nothing cleared when the queued answer's at differs (the operator
|
|
198
|
+
replaced it since) or no answer is queued: record the new one first.
|
|
195
199
|
ledger finish <ref> --status DONE|FAILED [--sender <name>] STDIN: reason
|
|
196
200
|
--sender: exit 2 unless the ledger's worker for <ref> is exactly <name>.
|
|
197
201
|
ledger validation-failed <ref> --updated-at <ts> STDIN: failing gates
|
|
@@ -253,8 +257,10 @@ Per cycle
|
|
|
253
257
|
--max caps captures per cycle (default 3); the rest are deferred.
|
|
254
258
|
answer <ref> STDIN: the answer
|
|
255
259
|
Queues an operator's answer (source "cli") for the next cycle to
|
|
256
|
-
deliver
|
|
257
|
-
|
|
260
|
+
deliver to the worker, or record on the item when the worker has
|
|
261
|
+
finished or the item is exhausted. stdout {queued:true,ref,source}.
|
|
262
|
+
Exit 2 when <ref> has no pending question, or the text looks like a
|
|
263
|
+
credential.
|
|
258
264
|
item-answer <ref> STDIN: {"comments":[{user|author,body,createdAt}]}
|
|
259
265
|
Queues the human's answer from the item's comments (source "item"):
|
|
260
266
|
the first comment after the latest [lisa-session-manager-question]
|
|
@@ -280,6 +286,26 @@ Per cycle
|
|
|
280
286
|
credential-refused (exit 0) means no other reply answers yet. Exit 2
|
|
281
287
|
when <ref> has no pending question, the ledger is corrupt, or STDIN is
|
|
282
288
|
not valid JSON.
|
|
289
|
+
channel-answer <ref> STDIN: the answer
|
|
290
|
+
Manager only: queues the operator's Telegram answer (source
|
|
291
|
+
"channel"), so answer-plan can record it on the item. stdout
|
|
292
|
+
{queued:true,ref,source}. Exit 2 when <ref> has no pending question,
|
|
293
|
+
or the text looks like a credential.
|
|
294
|
+
answer-plan <ref>
|
|
295
|
+
Plans recording the queued answer on the item before clearing; writes
|
|
296
|
+
nothing. stdout {ref,record:true,source,answerAt,comment} when no
|
|
297
|
+
worker will receive the answer (the worker reported DONE or FAILED,
|
|
298
|
+
the question is exhausted, or no worker was started) and the answer
|
|
299
|
+
came from answer (source cli) or Telegram (source channel): post
|
|
300
|
+
comment ([lisa-session-manager] The operator answered the question
|
|
301
|
+
above (by answer|Telegram, <time>): <answer>) and read it back, then
|
|
302
|
+
ledger clear-question --expect-answer-at <answerAt> (answerAt: the
|
|
303
|
+
queued answer's at). A repo-route never records (the repo stamp carries
|
|
304
|
+
it). Otherwise {ref,record:false,reason:no-pending-question|
|
|
305
|
+
no-answer-queued|answered-on-item|worker-not-finished|
|
|
306
|
+
routed-by-repo-stamp}. Exit 2 when the answer it would post looks
|
|
307
|
+
like a credential (nothing printed, nothing to post) or the ledger
|
|
308
|
+
is corrupt.
|
|
283
309
|
record-cycle --outcome <outcome> [--ref <url>]... [--run-id <id>]
|
|
284
310
|
STDIN: one-line summary. Records loop session-manager with runbook
|
|
285
311
|
.lisa/automations/session-manager.runbook.md. stdout {path,appended,
|
|
@@ -149,6 +149,14 @@ function planningMissPlan({ ref, kind, cause, question, overruled }) {
|
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Starts every other comment the manager posts. `item-answer` never reads a
|
|
154
|
+
* comment that starts with a bracketed `[lisa-...]` tag as an answer, so the
|
|
155
|
+
* manager's own notes (and the answers it records on the item) are never
|
|
156
|
+
* taken for a new answer.
|
|
157
|
+
*/
|
|
158
|
+
export const MANAGER_COMMENT_PREFIX = "[lisa-session-manager]";
|
|
159
|
+
|
|
152
160
|
/** Marks the manager's question comment, so its answer can be found after it. */
|
|
153
161
|
export const QUESTION_MARKER = "[lisa-session-manager-question]";
|
|
154
162
|
|
|
@@ -173,6 +181,23 @@ const CREDENTIAL_SHAPES = [
|
|
|
173
181
|
["API key", /\bsk-(?:ant-)?[A-Za-z0-9_-]{20,}/],
|
|
174
182
|
["private key", /-----BEGIN [A-Z ]*PRIVATE KEY-----/],
|
|
175
183
|
["bearer token", /\bbearer\s+[A-Za-z0-9._~+/=-]{20,}/i],
|
|
184
|
+
// The password part cannot cross a `/`, so a port, a path or a query
|
|
185
|
+
// holding an `@` (`http://host:3000/q?owner=a@b.com`) is not refused.
|
|
186
|
+
["URI with a password", /\b[a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:[^\s/@]+@/i],
|
|
187
|
+
// Env-style names (GITHUB_TOKEN, client_secret, DB_PASSWORD) are caught by
|
|
188
|
+
// allowing an identifier prefix: `\b` does not fire after `_`. The value
|
|
189
|
+
// must hold a digit and be 8+ characters, so ordinary prose ("token:
|
|
190
|
+
// expires daily", "secret: yes") is not refused.
|
|
191
|
+
[
|
|
192
|
+
"password or secret assignment",
|
|
193
|
+
/(?:^|[^A-Za-z0-9])[A-Za-z0-9_-]*(?:password|passwd|secret|token)\s*[=:]\s*(?=\S*\d)\S{8,}/i,
|
|
194
|
+
],
|
|
195
|
+
// A password needs no digit to be one: refuse a long value outright
|
|
196
|
+
// (`password: changeme` is still accepted).
|
|
197
|
+
[
|
|
198
|
+
"password assignment",
|
|
199
|
+
/(?:^|[^A-Za-z0-9])[A-Za-z0-9_-]*(?:password|passwd)\s*[=:]\s*\S{12,}/i,
|
|
200
|
+
],
|
|
176
201
|
];
|
|
177
202
|
|
|
178
203
|
/**
|
|
@@ -233,7 +258,7 @@ function questionComment({
|
|
|
233
258
|
"How to answer:",
|
|
234
259
|
...ways,
|
|
235
260
|
"",
|
|
236
|
-
`The session manager keeps working on other items meanwhile. Once the answer is delivered it removes ${markerText} and says so here.`,
|
|
261
|
+
`The session manager keeps working on other items meanwhile. Once the answer is delivered to the worker, or recorded here for the next attempt, it removes ${markerText} and says so here.`,
|
|
237
262
|
].join("\n");
|
|
238
263
|
}
|
|
239
264
|
|
|
@@ -231,19 +231,32 @@ export function setPendingQuestion(
|
|
|
231
231
|
* Clear an item's pending question, once its answer has been delivered and
|
|
232
232
|
* the manager's own marker removed. `resetAttempts` zeroes the attempt count:
|
|
233
233
|
* an `exhausted` item a human has answered starts again from attempt one
|
|
234
|
-
* instead of being exhausted again on its first stall.
|
|
234
|
+
* instead of being exhausted again on its first stall. `expectAnswerAt` is
|
|
235
|
+
* the queued answer's `at` that `answer-plan` recorded on the item: when the
|
|
236
|
+
* pending answer's `at` differs (the operator replaced it since, or none is
|
|
237
|
+
* queued), nothing is cleared and it throws, so a replacement is never
|
|
238
|
+
* deleted unseen (CodySwannGT/lisa#4624). Without it, nothing is compared.
|
|
235
239
|
* @param {string} projectRoot - Absolute project root
|
|
236
|
-
* @param {{ref: string, resetAttempts?: boolean}}
|
|
240
|
+
* @param {{ref: string, resetAttempts?: boolean, expectAnswerAt?: string}}
|
|
241
|
+
* target - Item
|
|
237
242
|
* @param {import("./ledger.mjs").LedgerSeams} [seams] - Injected seams
|
|
238
243
|
* @returns {Promise<import("./ledger.mjs").LedgerItem>} The updated item
|
|
239
244
|
*/
|
|
240
245
|
export function clearPendingQuestion(
|
|
241
246
|
projectRoot,
|
|
242
|
-
{ ref, resetAttempts = false },
|
|
247
|
+
{ ref, resetAttempts = false, expectAnswerAt },
|
|
243
248
|
seams
|
|
244
249
|
) {
|
|
245
250
|
return updateLedger(projectRoot, seams, (ledger, at) => {
|
|
246
251
|
const previous = requireItem(ledger, ref);
|
|
252
|
+
if (
|
|
253
|
+
expectAnswerAt !== undefined &&
|
|
254
|
+
previous.pendingQuestion?.answer?.at !== expectAnswerAt
|
|
255
|
+
) {
|
|
256
|
+
throw new Error(
|
|
257
|
+
`the answer changed since it was planned (${ref}); nothing was cleared. Record the new one first: run answer-plan again and post its comment.`
|
|
258
|
+
);
|
|
259
|
+
}
|
|
247
260
|
return withItem(ledger, ref, {
|
|
248
261
|
...previous,
|
|
249
262
|
pendingQuestion: null,
|
|
@@ -38,6 +38,7 @@ import path from "node:path";
|
|
|
38
38
|
import { fileURLToPath } from "node:url";
|
|
39
39
|
import { parseArgs } from "node:util";
|
|
40
40
|
|
|
41
|
+
import { answerPlan, channelAnswer } from "./cli-answer-record.mjs";
|
|
41
42
|
import {
|
|
42
43
|
LEDGER_ACTION_NAMES,
|
|
43
44
|
blockedPlan,
|
|
@@ -128,6 +129,8 @@ const COMMANDS = {
|
|
|
128
129
|
},
|
|
129
130
|
answer: { run: answer, options: {}, positionals: 1 },
|
|
130
131
|
"item-answer": { run: itemAnswer, options: {}, positionals: 1 },
|
|
132
|
+
"channel-answer": { run: channelAnswer, options: {}, positionals: 1 },
|
|
133
|
+
"answer-plan": { run: answerPlan, options: {}, positionals: 1 },
|
|
131
134
|
"record-cycle": {
|
|
132
135
|
run: recordCycle,
|
|
133
136
|
options: {
|
|
@@ -154,7 +157,10 @@ const LEDGER_SPECS = {
|
|
|
154
157
|
options: { "marker-type": text, marker: text, "comment-id": text },
|
|
155
158
|
positionals: 1,
|
|
156
159
|
},
|
|
157
|
-
"clear-question": {
|
|
160
|
+
"clear-question": {
|
|
161
|
+
options: { "reset-attempts": flag, "expect-answer-at": text },
|
|
162
|
+
positionals: 1,
|
|
163
|
+
},
|
|
158
164
|
finish: { options: { status: text, sender: text }, positionals: 1 },
|
|
159
165
|
"validation-failed": { options: { "updated-at": text }, positionals: 1 },
|
|
160
166
|
"validation-cleared": { options: {}, positionals: 1 },
|