@mnemom/mnemom 0.17.34-next.2 → 0.17.34-next.4
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/commands/agent-run.d.ts +16 -6
- package/dist/commands/agent-run.js +52 -27
- package/dist/commands/agent-share-test-issuer.d.ts +67 -0
- package/dist/commands/agent-share-test-issuer.js +139 -0
- package/dist/commands/agent-share.d.ts +7 -1
- package/dist/commands/agent-share.js +14 -4
- package/dist/commands/agent.d.ts +7 -5
- package/dist/commands/agent.js +84 -45
- package/dist/commands/durable-lock.d.ts +8 -1
- package/dist/commands/durable-lock.js +9 -4
- package/dist/commands/scan.d.ts +12 -1
- package/dist/commands/scan.js +22 -3
- package/dist/commands/wrap.js +1 -1
- package/dist/durable/adopt-live.js +5 -8
- package/dist/durable/adopt.d.ts +8 -0
- package/dist/durable/adopt.js +27 -6
- package/dist/durable/cwd-rule.d.ts +9 -1
- package/dist/durable/cwd-rule.js +18 -0
- package/dist/durable/launch-spec.d.ts +2 -0
- package/dist/durable/launch-spec.js +1 -1
- package/dist/durable/test-mode.mjs +25 -1
- package/dist/host/client.d.ts +3 -1
- package/dist/host/daemon.d.ts +7 -3
- package/dist/host/daemon.js +13 -3
- package/dist/host/owner.d.ts +3 -0
- package/dist/host/owner.js +2 -0
- package/dist/host/run.d.ts +2 -3
- package/dist/host/run.js +5 -20
- package/dist/host/s1-names.d.ts +1 -0
- package/dist/host/s1-names.js +1 -0
- package/dist/host/verbs.d.ts +2 -0
- package/dist/host/verbs.js +11 -0
- package/dist/index.js +13 -9
- package/dist/lib/agent.d.ts +5 -3
- package/dist/lib/agent.js +6 -3
- package/dist/lib/claude-bin.d.ts +6 -0
- package/dist/lib/claude-bin.js +26 -0
- package/dist/lib/commit-report.d.ts +5 -4
- package/dist/lib/commit-report.js +6 -9
- package/dist/lib/config.d.ts +8 -1
- package/dist/lib/config.js +28 -0
- package/dist/lib/durable/launch.d.ts +28 -11
- package/dist/lib/durable/launch.js +33 -15
- package/dist/lib/durable/live.d.ts +15 -19
- package/dist/lib/durable/live.js +41 -43
- package/dist/lib/launcher-config.d.ts +6 -0
- package/dist/lib/launcher-config.js +11 -0
- package/dist/lib/runner/exec-append.d.ts +15 -0
- package/dist/lib/runner/exec-append.js +2 -0
- package/dist/lib/runner/executor-client.d.ts +2 -1
- package/dist/lib/runner/executor-state.d.ts +10 -0
- package/dist/lib/runner/executor-state.js +24 -0
- package/dist/lib/runner/github-base.d.ts +24 -0
- package/dist/lib/runner/github-base.js +27 -0
- package/dist/lib/runner/job.d.ts +11 -4
- package/dist/lib/runner/job.js +59 -16
- package/dist/lib/runner/oidc.d.ts +3 -2
- package/dist/lib/runner/oidc.js +7 -4
- package/dist/lib/runner/options.d.ts +6 -0
- package/dist/lib/runner/options.js +19 -1
- package/dist/lib/runner/outcome.js +2 -3
- package/dist/lib/runner/phases.d.ts +7 -4
- package/dist/lib/runner/phases.js +8 -4
- package/dist/lib/runner/proxy.d.ts +5 -1
- package/dist/lib/runner/proxy.js +7 -1
- package/dist/lib/scan/cost-per-pr.d.ts +93 -0
- package/dist/lib/scan/cost-per-pr.js +101 -0
- package/dist/lib/scan/record.d.ts +27 -1
- package/dist/lib/scan/record.js +114 -16
- package/dist/lib/scan/report-email.d.ts +25 -5
- package/dist/lib/scan/report-email.js +23 -2
- package/dist/lib/scan/scan.d.ts +3 -0
- package/dist/lib/scan/scan.js +13 -1
- package/dist/lib/session-key.d.ts +4 -3
- package/dist/vendor/durable-contract/index.js +207 -169
- package/dist/vendor/shared/durable-contract/doors.d.ts +26 -1
- package/dist/vendor/shared/durable-contract/doors.js +37 -1
- package/dist/vendor/shared/durable-contract/events.d.ts +1 -1
- package/dist/vendor/shared/durable-contract/events.js +13 -3
- package/dist/vendor/shared/durable-contract/freeze-record.d.ts +2 -2
- package/dist/vendor/shared/durable-contract/schema.d.ts +5 -0
- package/dist/vendor/shared/durable-contract/schema.js +6 -0
- package/dist/vendor/shared/durable-contract/states.d.ts +2 -1
- package/dist/vendor/shared/durable-contract/states.js +2 -1
- package/package.json +1 -1
- package/dist/lib/durable/first-turn.d.ts +0 -50
- package/dist/lib/durable/first-turn.js +0 -102
|
@@ -51,7 +51,8 @@ export const SUSPENDED_REASONS = [
|
|
|
51
51
|
];
|
|
52
52
|
/** breakglass is P0a-B; it stays in the enum so the CHECK never needs widening. */
|
|
53
53
|
export const PAUSED_REASONS = ["owner", "agent_contained", "breakglass"];
|
|
54
|
-
|
|
54
|
+
/** S1 amendment 59: runner_failed is a pool job's terminal failure, after its retries (doors.ts). */
|
|
55
|
+
export const FAILED_REASONS = ["transcript_lost", "runner_failed"];
|
|
55
56
|
export const KILLED_REASONS = ["agent_killed"];
|
|
56
57
|
/**
|
|
57
58
|
* The closed state_reason enum per state. `null` in a list means NULL is allowed there and what it
|
package/package.json
CHANGED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lock after the first turn (ruling dogfood B5). A launch that locks a NEW Claude Code session
|
|
3
|
-
* (`durable = always`, or ask answered yes, with no transcript yet) cannot lock before claude has
|
|
4
|
-
* run: the daemon's seat resumes the session's transcript, and there is none until the first turn
|
|
5
|
-
* writes it (host/transcript.ts ensureTranscript answers lost, the session fails transcript_lost).
|
|
6
|
-
*
|
|
7
|
-
* So the launcher spawns claude attended and watches the transcript. Once the first turn has
|
|
8
|
-
* completed it locks, under the running-session handover (C02-R26: freeze, commit, the seat's
|
|
9
|
-
* hello, then the original is killed and the parent attaches to the seat). Never before. A lock
|
|
10
|
-
* refusal at that point leaves the attended session running and prints the refusal with its fix
|
|
11
|
-
* line.
|
|
12
|
-
*
|
|
13
|
-
* No I/O here: lib/durable/live.ts wires the transcript reads, the lock and the clock.
|
|
14
|
-
*/
|
|
15
|
-
import type { LockOutcome, TranscriptDirs } from "../../commands/durable-lock.js";
|
|
16
|
-
import { DurableRefusal } from "./refusal.js";
|
|
17
|
-
/** How often the launcher re-reads the transcript while it waits for the first turn. */
|
|
18
|
-
export declare const FIRST_TURN_POLL_MS = 1000;
|
|
19
|
-
/**
|
|
20
|
-
* Whether a Claude Code transcript (JSONL) holds a completed turn: an assistant entry whose
|
|
21
|
-
* stop_reason ends the turn (end_turn, max_tokens, stop_sequence, refusal), or the engine's own
|
|
22
|
-
* turn-end record (system turn_duration or stop_hook_summary). Unparseable lines (a line still
|
|
23
|
-
* being written) are skipped.
|
|
24
|
-
*/
|
|
25
|
-
export declare function turnCompleted(jsonl: string): boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Reads `<projects>/<dir>/<cc>.jsonl` from the first project dir that holds it; null while none
|
|
28
|
-
* does, when it cannot be read (it is read again on the next poll), or with no CC session id.
|
|
29
|
-
*/
|
|
30
|
-
export declare function transcriptReader(projects: string, dirs: TranscriptDirs, cc: string | null | undefined, read: (path: string) => string): () => string | null;
|
|
31
|
-
export interface FirstTurnLockDeps {
|
|
32
|
-
/** The session name (the fix line of a lock that could not be sent). */
|
|
33
|
-
name: string;
|
|
34
|
-
/** The session's transcript text, or null while Claude Code has written none. */
|
|
35
|
-
readTranscript(): string | null;
|
|
36
|
-
/** The attended claude is still running. */
|
|
37
|
-
childAlive(): boolean;
|
|
38
|
-
/** The lock of the row under the running-session handover (lockResolvedRow). */
|
|
39
|
-
lock(): Promise<LockOutcome>;
|
|
40
|
-
/** Print a lock refusal and its fix line (the session stays attended). */
|
|
41
|
-
printRefusal(r: DurableRefusal): void;
|
|
42
|
-
sleep(ms: number): Promise<void>;
|
|
43
|
-
}
|
|
44
|
-
export type FirstTurnLock = "locked" | "refused" | "ended";
|
|
45
|
-
/**
|
|
46
|
-
* Wait for the first completed turn, then lock. "ended": claude exited first, nothing was locked.
|
|
47
|
-
* "locked": the handover took the session (the parent's exit path attaches to the seat).
|
|
48
|
-
* "refused": the refusal was printed and the attended session goes on.
|
|
49
|
-
*/
|
|
50
|
-
export declare function lockAfterFirstTurn(d: FirstTurnLockDeps, pollMs?: number): Promise<FirstTurnLock>;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lock after the first turn (ruling dogfood B5). A launch that locks a NEW Claude Code session
|
|
3
|
-
* (`durable = always`, or ask answered yes, with no transcript yet) cannot lock before claude has
|
|
4
|
-
* run: the daemon's seat resumes the session's transcript, and there is none until the first turn
|
|
5
|
-
* writes it (host/transcript.ts ensureTranscript answers lost, the session fails transcript_lost).
|
|
6
|
-
*
|
|
7
|
-
* So the launcher spawns claude attended and watches the transcript. Once the first turn has
|
|
8
|
-
* completed it locks, under the running-session handover (C02-R26: freeze, commit, the seat's
|
|
9
|
-
* hello, then the original is killed and the parent attaches to the seat). Never before. A lock
|
|
10
|
-
* refusal at that point leaves the attended session running and prints the refusal with its fix
|
|
11
|
-
* line.
|
|
12
|
-
*
|
|
13
|
-
* No I/O here: lib/durable/live.ts wires the transcript reads, the lock and the clock.
|
|
14
|
-
*/
|
|
15
|
-
import { join } from "node:path";
|
|
16
|
-
import { DurableRefusal } from "./refusal.js";
|
|
17
|
-
/** How often the launcher re-reads the transcript while it waits for the first turn. */
|
|
18
|
-
export const FIRST_TURN_POLL_MS = 1000;
|
|
19
|
-
/** An assistant stop that ends the turn: anything but a tool call or a paused turn. */
|
|
20
|
-
const TURN_CONTINUES = new Set(["tool_use", "pause_turn"]);
|
|
21
|
-
/**
|
|
22
|
-
* Whether a Claude Code transcript (JSONL) holds a completed turn: an assistant entry whose
|
|
23
|
-
* stop_reason ends the turn (end_turn, max_tokens, stop_sequence, refusal), or the engine's own
|
|
24
|
-
* turn-end record (system turn_duration or stop_hook_summary). Unparseable lines (a line still
|
|
25
|
-
* being written) are skipped.
|
|
26
|
-
*/
|
|
27
|
-
export function turnCompleted(jsonl) {
|
|
28
|
-
for (const line of jsonl.split("\n")) {
|
|
29
|
-
let e;
|
|
30
|
-
try {
|
|
31
|
-
e = JSON.parse(line);
|
|
32
|
-
}
|
|
33
|
-
catch {
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
if (e === null || typeof e !== "object")
|
|
37
|
-
continue;
|
|
38
|
-
const r = e;
|
|
39
|
-
if (r.type === "system" && (r.subtype === "turn_duration" || r.subtype === "stop_hook_summary"))
|
|
40
|
-
return true;
|
|
41
|
-
if (r.type !== "assistant" || r.message === null || typeof r.message !== "object")
|
|
42
|
-
continue;
|
|
43
|
-
const stop = r.message.stop_reason;
|
|
44
|
-
if (typeof stop === "string" && !TURN_CONTINUES.has(stop))
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Reads `<projects>/<dir>/<cc>.jsonl` from the first project dir that holds it; null while none
|
|
51
|
-
* does, when it cannot be read (it is read again on the next poll), or with no CC session id.
|
|
52
|
-
*/
|
|
53
|
-
export function transcriptReader(projects, dirs, cc, read) {
|
|
54
|
-
return () => {
|
|
55
|
-
if (!cc)
|
|
56
|
-
return null;
|
|
57
|
-
const found = dirs(cc)?.[0];
|
|
58
|
-
if (found === undefined)
|
|
59
|
-
return null;
|
|
60
|
-
try {
|
|
61
|
-
return read(join(projects, found, `${cc}.jsonl`));
|
|
62
|
-
}
|
|
63
|
-
catch {
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Wait for the first completed turn, then lock. "ended": claude exited first, nothing was locked.
|
|
70
|
-
* "locked": the handover took the session (the parent's exit path attaches to the seat).
|
|
71
|
-
* "refused": the refusal was printed and the attended session goes on.
|
|
72
|
-
*/
|
|
73
|
-
export async function lockAfterFirstTurn(d, pollMs = FIRST_TURN_POLL_MS) {
|
|
74
|
-
for (;;) {
|
|
75
|
-
if (!d.childAlive())
|
|
76
|
-
return "ended";
|
|
77
|
-
const t = d.readTranscript();
|
|
78
|
-
if (t !== null && turnCompleted(t))
|
|
79
|
-
break;
|
|
80
|
-
await d.sleep(pollMs);
|
|
81
|
-
}
|
|
82
|
-
let o;
|
|
83
|
-
try {
|
|
84
|
-
o = await d.lock();
|
|
85
|
-
}
|
|
86
|
-
catch (e) {
|
|
87
|
-
o = {
|
|
88
|
-
ok: false,
|
|
89
|
-
refusal: e instanceof DurableRefusal
|
|
90
|
-
? e
|
|
91
|
-
: new DurableRefusal({
|
|
92
|
-
code: "session_registry_unavailable",
|
|
93
|
-
message: `mnemom agent: the lock after the first turn failed (${e instanceof Error ? e.message : String(e)}); the session stays attended`,
|
|
94
|
-
fix: `\`mnemom agent lock ${d.name}\``,
|
|
95
|
-
}),
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
if (o.ok)
|
|
99
|
-
return "locked";
|
|
100
|
-
d.printRefusal(o.refusal);
|
|
101
|
-
return "refused";
|
|
102
|
-
}
|