@astrosheep/keiyaku 4.6.33 → 4.6.34
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 +10 -1
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +5 -2
- package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +5 -2
- package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +5 -2
- package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/plugins/pi/keiyaku.ts +1 -135
- package/build/skills/keiyaku-akuma/SKILL.md +5 -2
- package/build/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/src/akuma/akuma-observe.d.ts +8 -0
- package/build/src/akuma/akuma-observe.js +8 -0
- package/build/src/akuma/akuma-owner.d.ts +1 -0
- package/build/src/akuma/akuma-owner.js +3 -5
- package/build/src/akuma/akuma-wait.d.ts +117 -2
- package/build/src/akuma/akuma-wait.js +53 -22
- package/build/src/akuma/akuma.d.ts +6 -1
- package/build/src/akuma/akuma.js +37 -18
- package/build/src/akuma/heart/facts.d.ts +1 -0
- package/build/src/akuma/heart/facts.js +14 -0
- package/build/src/akuma/heart/index.d.ts +6 -0
- package/build/src/akuma/heart/index.js +27 -9
- package/build/src/akuma/heart/rows.d.ts +1 -0
- package/build/src/akuma/heart/rows.js +4 -0
- package/build/src/akuma/lineage-cache.d.ts +7 -2
- package/build/src/akuma/lineage-cache.js +48 -24
- package/build/src/akuma/projection-read.js +4 -9
- package/build/src/akuma/selection-observation.d.ts +622 -0
- package/build/src/akuma/selection-observation.js +7 -3
- package/build/src/bounded-list.d.ts +8 -0
- package/build/src/bounded-list.js +10 -0
- package/build/src/cli/commands/akuma-grammar.d.ts +2 -3
- package/build/src/cli/commands/akuma-grammar.js +32 -39
- package/build/src/cli/commands/akuma.js +6 -3
- package/build/src/cli/commands/contract-grammar.js +32 -31
- package/build/src/cli/commands/contract-help.d.ts +3 -3
- package/build/src/cli/commands/contract-help.js +10 -8
- package/build/src/cli/commands/contract.d.ts +3 -3
- package/build/src/cli/commands/contract.js +11 -10
- package/build/src/cli/parse.d.ts +4 -10
- package/build/src/cli/parse.js +1 -1
- package/build/src/cli/render/akuma-activity.d.ts +9 -19
- package/build/src/cli/render/akuma-activity.js +83 -110
- package/build/src/cli/render/catalog.js +3 -2
- package/build/src/cli/render/contract-history.d.ts +1 -3
- package/build/src/cli/render/contract-history.js +68 -49
- package/build/src/cli/render/contract-wait.js +9 -1
- package/build/src/cli/render/kanshi-akuma.d.ts +4 -3
- package/build/src/cli/render/kanshi-akuma.js +26 -21
- package/build/src/cli/render/kanshi.js +34 -43
- package/build/src/cli/render/verbs.js +20 -17
- package/build/src/cli/runtime.js +9 -23
- package/build/src/debt/board.d.ts +2 -1
- package/build/src/debt/board.js +3 -3
- package/build/src/debt/catalog.js +2 -1
- package/build/src/debt/document.d.ts +1 -0
- package/build/src/debt/document.js +3 -0
- package/build/src/debt/index.d.ts +2 -1
- package/build/src/debt/index.js +3 -3
- package/build/src/debt/operations.d.ts +2 -1
- package/build/src/git/observe.d.ts +4 -3
- package/build/src/git/observe.js +8 -7
- package/build/src/history.d.ts +26 -0
- package/build/src/history.js +43 -0
- package/build/src/index.d.ts +4 -3
- package/build/src/kanshi/counts.d.ts +15 -1
- package/build/src/kanshi/counts.js +14 -3
- package/build/src/kanshi/index.d.ts +3 -3
- package/build/src/kanshi/index.js +2 -2
- package/build/src/kanshi/read.js +5 -2
- package/build/src/library/akumas.d.ts +5 -1
- package/build/src/library/akumas.js +11 -5
- package/build/src/library/contract-composition.js +10 -10
- package/build/src/library/contract-creation.js +2 -2
- package/build/src/library/contract-types.d.ts +215 -25
- package/build/src/library/contract-types.js +31 -13
- package/build/src/library/contract-wait.d.ts +205 -0
- package/build/src/library/contract-wait.js +15 -3
- package/build/src/library/input.d.ts +3 -3
- package/build/src/library/input.js +5 -5
- package/build/src/library/kei.js +134 -76
- package/build/src/library/keiyaku-attribution.d.ts +1 -1
- package/build/src/library/keiyaku-attribution.js +3 -1
- package/build/src/library/keiyaku-classify.js +5 -1
- package/build/src/library/keiyaku-debt.d.ts +8 -7
- package/build/src/library/keiyaku-identity.d.ts +4 -3
- package/build/src/library/keiyaku-identity.js +30 -7
- package/build/src/library/keiyaku-verbs.d.ts +515 -44
- package/build/src/library/keiyaku-verbs.js +84 -79
- package/build/src/library/keiyaku-wait.d.ts +570 -0
- package/build/src/library/keiyaku-wait.js +25 -8
- package/build/src/library/keiyaku.d.ts +3110 -31
- package/build/src/library/keiyaku.js +335 -407
- package/build/src/library/model-tools.d.ts +268 -70
- package/build/src/library/model-tools.js +110 -95
- package/build/src/library/selection.d.ts +6 -5
- package/build/src/library/selection.js +10 -3
- package/build/src/mcp/adapter.js +1 -1
- package/build/src/mcp/help.d.ts +1 -1
- package/build/src/mcp/help.js +4 -3
- package/build/src/pi/index.d.ts +2 -0
- package/build/src/pi/index.js +23 -7
- package/build/src/pi/status.d.ts +12 -0
- package/build/src/pi/status.js +140 -0
- package/build/src/protocol/operations.d.ts +2 -0
- package/build/src/protocol/operations.js +1 -1
- package/build/src/protocol/read/status.d.ts +12 -4
- package/build/src/protocol/read/status.js +19 -12
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/package.json +1 -1
- package/plugins/paseo/plugin/index.server.ts +6 -2
- package/plugins/paseo/plugin/server/attach.ts +68 -48
- package/plugins/paseo/plugin/server/directory.ts +259 -0
- package/plugins/paseo/plugin/server/mirror-identity.ts +3 -32
- package/plugins/paseo/plugin/server/reopen.ts +52 -38
- package/plugins/pi/keiyaku.ts +1 -135
- package/skills/keiyaku-akuma/SKILL.md +5 -2
- package/skills/keiyaku-debt/SKILL.md +2 -1
package/README.md
CHANGED
|
@@ -126,11 +126,20 @@ Inspect durable facts and their requirement scope separately from live execution
|
|
|
126
126
|
|
|
127
127
|
```bash
|
|
128
128
|
keiyaku history <contract>
|
|
129
|
-
keiyaku history <contract> --
|
|
129
|
+
keiyaku history <contract> --before 13 --limit 4
|
|
130
|
+
keiyaku history <contract> --id 2 --json
|
|
131
|
+
keiyaku history <akuma> --answer
|
|
130
132
|
keiyaku status <contract>
|
|
131
133
|
keiyaku deliver <contract> --dry-run --json
|
|
132
134
|
```
|
|
133
135
|
|
|
136
|
+
History defaults to the latest 12 entries for either family. Use `--before` for
|
|
137
|
+
older entries or `--since` for the earliest newer entries, then copy a visible
|
|
138
|
+
address to `--id` for the complete retained item. Contract decimal addresses stay
|
|
139
|
+
stable as facts append; exact records retain their own historical terms. Akuma
|
|
140
|
+
`--answer` returns the latest retained answered Turn, even after later failed work;
|
|
141
|
+
JSON includes its exact `turn/N` coordinate.
|
|
142
|
+
|
|
134
143
|
Each terminal check records testimony for its gate, stable requirement, and exact
|
|
135
144
|
captured snapshot; there is no aggregate Verification attestation. A later
|
|
136
145
|
unsatisfied result supersedes earlier satisfaction only for the same requirement
|
|
@@ -51,8 +51,11 @@ research.
|
|
|
51
51
|
- **`kanshi`, `status`, and `history`:** `kanshi` shows the `World` board;
|
|
52
52
|
`status <aku/...|kei/...|@name>` observes one identity, with current work and
|
|
53
53
|
file-change summary for an Akuma. Plural and category status are refused.
|
|
54
|
-
`history` reads
|
|
55
|
-
|
|
54
|
+
`history` reads bounded timeline entries; `--before`, `--since`, and `--limit`
|
|
55
|
+
page either Contract or Akuma history. Copy a decimal row address to `--id` for
|
|
56
|
+
a complete Contract record or Akuma activity, or an Akuma `turn/N` or `report/N`
|
|
57
|
+
address for that retained item. `--answer` returns the latest retained answered
|
|
58
|
+
Turn as raw bytes; JSON also carries its exact Turn coordinate.
|
|
56
59
|
- **`ls`, `fork`, and `kill`:** `ls` lists akumaNames (`aku/`), recent
|
|
57
60
|
instances with life and associations (`"aku/*/*"`), or your own call tree;
|
|
58
61
|
`fork` branches a new `Akuma`
|
|
@@ -26,7 +26,8 @@ Only `needs` orders work: a `Debt` with unresolved `needs` is `blocked`, and
|
|
|
26
26
|
becomes `ready` once every prerequisite is `done` or `drop`. Do not add `needs`
|
|
27
27
|
merely because two `Debts` touch the same `Region` or are related.
|
|
28
28
|
|
|
29
|
-
`show
|
|
29
|
+
`keiyaku show <debt/...>` requires an explicit selector and displays current
|
|
30
|
+
prerequisites and their availability. Native readiness
|
|
30
31
|
and blocked views interpret unresolved `needs`. Creation starts open; use update
|
|
31
32
|
to set disposition or its current explanation. Every state may be reopened or
|
|
32
33
|
changed to another state. Reopening a prerequisite blocks open dependents again.
|
|
@@ -51,8 +51,11 @@ research.
|
|
|
51
51
|
- **`kanshi`, `status`, and `history`:** `kanshi` shows the `World` board;
|
|
52
52
|
`status <aku/...|kei/...|@name>` observes one identity, with current work and
|
|
53
53
|
file-change summary for an Akuma. Plural and category status are refused.
|
|
54
|
-
`history` reads
|
|
55
|
-
|
|
54
|
+
`history` reads bounded timeline entries; `--before`, `--since`, and `--limit`
|
|
55
|
+
page either Contract or Akuma history. Copy a decimal row address to `--id` for
|
|
56
|
+
a complete Contract record or Akuma activity, or an Akuma `turn/N` or `report/N`
|
|
57
|
+
address for that retained item. `--answer` returns the latest retained answered
|
|
58
|
+
Turn as raw bytes; JSON also carries its exact Turn coordinate.
|
|
56
59
|
- **`ls`, `fork`, and `kill`:** `ls` lists akumaNames (`aku/`), recent
|
|
57
60
|
instances with life and associations (`"aku/*/*"`), or your own call tree;
|
|
58
61
|
`fork` branches a new `Akuma`
|
|
@@ -26,7 +26,8 @@ Only `needs` orders work: a `Debt` with unresolved `needs` is `blocked`, and
|
|
|
26
26
|
becomes `ready` once every prerequisite is `done` or `drop`. Do not add `needs`
|
|
27
27
|
merely because two `Debts` touch the same `Region` or are related.
|
|
28
28
|
|
|
29
|
-
`show
|
|
29
|
+
`keiyaku show <debt/...>` requires an explicit selector and displays current
|
|
30
|
+
prerequisites and their availability. Native readiness
|
|
30
31
|
and blocked views interpret unresolved `needs`. Creation starts open; use update
|
|
31
32
|
to set disposition or its current explanation. Every state may be reopened or
|
|
32
33
|
changed to another state. Reopening a prerequisite blocks open dependents again.
|
|
@@ -51,8 +51,11 @@ research.
|
|
|
51
51
|
- **`kanshi`, `status`, and `history`:** `kanshi` shows the `World` board;
|
|
52
52
|
`status <aku/...|kei/...|@name>` observes one identity, with current work and
|
|
53
53
|
file-change summary for an Akuma. Plural and category status are refused.
|
|
54
|
-
`history` reads
|
|
55
|
-
|
|
54
|
+
`history` reads bounded timeline entries; `--before`, `--since`, and `--limit`
|
|
55
|
+
page either Contract or Akuma history. Copy a decimal row address to `--id` for
|
|
56
|
+
a complete Contract record or Akuma activity, or an Akuma `turn/N` or `report/N`
|
|
57
|
+
address for that retained item. `--answer` returns the latest retained answered
|
|
58
|
+
Turn as raw bytes; JSON also carries its exact Turn coordinate.
|
|
56
59
|
- **`ls`, `fork`, and `kill`:** `ls` lists akumaNames (`aku/`), recent
|
|
57
60
|
instances with life and associations (`"aku/*/*"`), or your own call tree;
|
|
58
61
|
`fork` branches a new `Akuma`
|
|
@@ -26,7 +26,8 @@ Only `needs` orders work: a `Debt` with unresolved `needs` is `blocked`, and
|
|
|
26
26
|
becomes `ready` once every prerequisite is `done` or `drop`. Do not add `needs`
|
|
27
27
|
merely because two `Debts` touch the same `Region` or are related.
|
|
28
28
|
|
|
29
|
-
`show
|
|
29
|
+
`keiyaku show <debt/...>` requires an explicit selector and displays current
|
|
30
|
+
prerequisites and their availability. Native readiness
|
|
30
31
|
and blocked views interpret unresolved `needs`. Creation starts open; use update
|
|
31
32
|
to set disposition or its current explanation. Every state may be reopened or
|
|
32
33
|
changed to another state. Reopening a prerequisite blocks open dependents again.
|
|
@@ -1,135 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { registerKeiyakuTools } from "@astrosheep/keiyaku/pi";
|
|
3
|
-
import { Kanshi, NoGitWorldError, Repo, World } from "@astrosheep/keiyaku";
|
|
4
|
-
|
|
5
|
-
type ExecResult = Readonly<{ stdout: string; stderr: string; code: number }>;
|
|
6
|
-
|
|
7
|
-
async function runStatus(pi: ExtensionAPI): Promise<ExecResult> {
|
|
8
|
-
return await pi.exec("keiyaku", ["kanshi"]);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function lineForWidth(value: string, width: number): string {
|
|
12
|
-
const clean = value.replaceAll(/[\u0000-\u001f\u007f]/gu, " ");
|
|
13
|
-
return clean.length <= width ? clean : `${clean.slice(0, Math.max(0, width - 1))}…`;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function overlay(lines: readonly string[], theme: Theme, done: () => void) {
|
|
17
|
-
return {
|
|
18
|
-
invalidate(): void {},
|
|
19
|
-
handleInput(data: string): void {
|
|
20
|
-
if (data === "\u001b" || data === "q" || data === "Q" || data === "\r") done();
|
|
21
|
-
},
|
|
22
|
-
render(width: number): string[] {
|
|
23
|
-
const inner = Math.max(1, Math.min(100, width - 2));
|
|
24
|
-
const border = theme.fg("border", "+");
|
|
25
|
-
const rule = theme.fg("border", "-".repeat(inner));
|
|
26
|
-
return [
|
|
27
|
-
`${border}${rule}${border}`,
|
|
28
|
-
`${theme.fg("border", "|")}${lineForWidth("Keiyaku", inner).padEnd(inner)}${theme.fg("border", "|")}`,
|
|
29
|
-
`${theme.fg("border", "|")}${" ".repeat(inner)}${theme.fg("border", "|")}`,
|
|
30
|
-
...lines.map(
|
|
31
|
-
(line) => `${theme.fg("border", "|")}${lineForWidth(line, inner).padEnd(inner)}${theme.fg("border", "|")}`,
|
|
32
|
-
),
|
|
33
|
-
`${theme.fg("border", "|")}${" ".repeat(inner)}${theme.fg("border", "|")}`,
|
|
34
|
-
`${theme.fg("border", "|")}${lineForWidth("esc/q/enter close", inner).padEnd(inner)}${theme.fg("border", "|")}`,
|
|
35
|
-
`${border}${rule}${border}`,
|
|
36
|
-
];
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
type StatusReaders = {
|
|
42
|
-
repo: typeof Repo.at;
|
|
43
|
-
world: typeof World.resolve;
|
|
44
|
-
counts: (scope: Parameters<typeof Kanshi.of>[0]) => ReturnType<Kanshi["counts"]>;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export default function keiyakuExtension(
|
|
48
|
-
pi: ExtensionAPI,
|
|
49
|
-
readers: StatusReaders = { repo: Repo.at, world: World.resolve, counts: (scope) => Kanshi.of(scope).counts() },
|
|
50
|
-
): void {
|
|
51
|
-
registerKeiyakuTools(pi);
|
|
52
|
-
let close: (() => void) | undefined;
|
|
53
|
-
let refresh: (() => void) | undefined;
|
|
54
|
-
pi.on("session_start", (_event, ctx) => {
|
|
55
|
-
close?.();
|
|
56
|
-
close = undefined;
|
|
57
|
-
refresh = undefined;
|
|
58
|
-
if (ctx.mode !== "tui") return;
|
|
59
|
-
const cwd = ctx.cwd;
|
|
60
|
-
const ui = ctx.ui;
|
|
61
|
-
let live = true;
|
|
62
|
-
let reading = false;
|
|
63
|
-
let pending = false;
|
|
64
|
-
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
65
|
-
const unknown = "aku ? · kei ? · debt ?";
|
|
66
|
-
const show = (text: string | undefined): void => ui.setStatus("keiyaku", text);
|
|
67
|
-
const value = (section: { kind: "present"; value: number } | { kind: "absent" | "failed" }): string =>
|
|
68
|
-
section.kind === "present" ? String(section.value) : section.kind === "absent" ? "-" : "?";
|
|
69
|
-
const sample = async (): Promise<string> => {
|
|
70
|
-
let repo: Repo | undefined;
|
|
71
|
-
try {
|
|
72
|
-
repo = await readers.repo({ path: cwd });
|
|
73
|
-
} catch (error) {
|
|
74
|
-
if (!(error instanceof NoGitWorldError)) throw error;
|
|
75
|
-
}
|
|
76
|
-
const world = await readers.world(repo === undefined ? { cwd } : { cwd, repositoryRoot: repo.root });
|
|
77
|
-
const report = await readers.counts({ world: world.root, ...(repo === undefined ? {} : { repo }) });
|
|
78
|
-
return `aku ${value(report.akuma)} · kei ${value(report.contracts)} · debt ${value(report.debts)}`;
|
|
79
|
-
};
|
|
80
|
-
const request = (): void => {
|
|
81
|
-
if (!live) return;
|
|
82
|
-
if (timer !== undefined) clearTimeout(timer);
|
|
83
|
-
timer = undefined;
|
|
84
|
-
if (reading) {
|
|
85
|
-
pending = true;
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
reading = true;
|
|
89
|
-
void sample().catch(() => unknown).then((text) => {
|
|
90
|
-
if (!live) return;
|
|
91
|
-
show(text);
|
|
92
|
-
reading = false;
|
|
93
|
-
if (pending) {
|
|
94
|
-
pending = false;
|
|
95
|
-
request();
|
|
96
|
-
} else {
|
|
97
|
-
timer = setTimeout(request, 5_000);
|
|
98
|
-
timer.unref();
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
close = () => {
|
|
103
|
-
if (!live) return;
|
|
104
|
-
live = false;
|
|
105
|
-
if (timer !== undefined) clearTimeout(timer);
|
|
106
|
-
show(undefined);
|
|
107
|
-
};
|
|
108
|
-
refresh = request;
|
|
109
|
-
show(unknown);
|
|
110
|
-
request();
|
|
111
|
-
});
|
|
112
|
-
pi.on("agent_settled", () => { refresh?.(); });
|
|
113
|
-
pi.on("session_shutdown", () => {
|
|
114
|
-
close?.();
|
|
115
|
-
close = undefined;
|
|
116
|
-
refresh = undefined;
|
|
117
|
-
});
|
|
118
|
-
pi.registerCommand("keiyaku", {
|
|
119
|
-
description: "Open the Kanshi world status",
|
|
120
|
-
handler: async (_args, ctx) => {
|
|
121
|
-
if (!ctx.hasUI) return;
|
|
122
|
-
let body: string[];
|
|
123
|
-
try {
|
|
124
|
-
const result = await runStatus(pi);
|
|
125
|
-
body = result.code === 0 ? result.stdout.trimEnd().split("\n") : [result.stderr.trim() || "status unavailable"];
|
|
126
|
-
} catch {
|
|
127
|
-
body = ["status unavailable"];
|
|
128
|
-
}
|
|
129
|
-
await ctx.ui.custom<void>((_tui, theme, _keybindings, done) => overlay(body, theme, done), {
|
|
130
|
-
overlay: true,
|
|
131
|
-
overlayOptions: { anchor: "center", width: 100, maxHeight: 40 },
|
|
132
|
-
});
|
|
133
|
-
},
|
|
134
|
-
});
|
|
135
|
-
}
|
|
1
|
+
export { registerKeiyakuExtension as default } from "@astrosheep/keiyaku/pi";
|
|
@@ -51,8 +51,11 @@ research.
|
|
|
51
51
|
- **`kanshi`, `status`, and `history`:** `kanshi` shows the `World` board;
|
|
52
52
|
`status <aku/...|kei/...|@name>` observes one identity, with current work and
|
|
53
53
|
file-change summary for an Akuma. Plural and category status are refused.
|
|
54
|
-
`history` reads
|
|
55
|
-
|
|
54
|
+
`history` reads bounded timeline entries; `--before`, `--since`, and `--limit`
|
|
55
|
+
page either Contract or Akuma history. Copy a decimal row address to `--id` for
|
|
56
|
+
a complete Contract record or Akuma activity, or an Akuma `turn/N` or `report/N`
|
|
57
|
+
address for that retained item. `--answer` returns the latest retained answered
|
|
58
|
+
Turn as raw bytes; JSON also carries its exact Turn coordinate.
|
|
56
59
|
- **`ls`, `fork`, and `kill`:** `ls` lists akumaNames (`aku/`), recent
|
|
57
60
|
instances with life and associations (`"aku/*/*"`), or your own call tree;
|
|
58
61
|
`fork` branches a new `Akuma`
|
|
@@ -26,7 +26,8 @@ Only `needs` orders work: a `Debt` with unresolved `needs` is `blocked`, and
|
|
|
26
26
|
becomes `ready` once every prerequisite is `done` or `drop`. Do not add `needs`
|
|
27
27
|
merely because two `Debts` touch the same `Region` or are related.
|
|
28
28
|
|
|
29
|
-
`show
|
|
29
|
+
`keiyaku show <debt/...>` requires an explicit selector and displays current
|
|
30
|
+
prerequisites and their availability. Native readiness
|
|
30
31
|
and blocked views interpret unresolved `needs`. Creation starts open; use update
|
|
31
32
|
to set disposition or its current explanation. Every state may be reopened or
|
|
32
33
|
changed to another state. Reopening a prerequisite blocks open dependents again.
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { type WaitFacts } from "./heart/index.js";
|
|
1
2
|
import { type AkumaId, type AkumaPaths } from "./identity.js";
|
|
2
3
|
import { selectHistory, type ActivityHistory, type ActivityRow, type ActivitySnapshot } from "./projection.js";
|
|
3
4
|
import type { WorldRoot } from "../world.js";
|
|
4
5
|
import type { AkumaRosterRow, AkumaStatus } from "./akuma.js";
|
|
5
6
|
export declare function rosterListRow(paths: AkumaPaths, expected: AkumaId): Promise<AkumaRosterRow>;
|
|
7
|
+
/** Lightweight born-life observation using the same leash refresh as status and wait. */
|
|
8
|
+
export declare function readBornLife(paths: AkumaPaths, expected: AkumaId): Promise<AkumaStatus["life"]>;
|
|
6
9
|
/** Optional semantic seam; the observer composition owns delivery and deduplication. */
|
|
7
10
|
export type OutcomeObserver = (akumaId: AkumaId, historyIds: readonly string[]) => Promise<void>;
|
|
8
11
|
export declare function observeOutcomeRows(id: AkumaId, rows: readonly ActivityRow[], observer?: OutcomeObserver): Promise<void>;
|
|
@@ -21,6 +24,10 @@ type BudgetedStatusObservation = Readonly<{
|
|
|
21
24
|
export type LiveStatusObservation = BudgetedStatusObservation & Readonly<{
|
|
22
25
|
rows: readonly ActivityRow[];
|
|
23
26
|
}>;
|
|
27
|
+
export type WaitStatusObservation = WaitFacts & Readonly<{
|
|
28
|
+
id: AkumaId;
|
|
29
|
+
life: AkumaStatus["life"];
|
|
30
|
+
}>;
|
|
24
31
|
type StatusObservationInput = Readonly<{
|
|
25
32
|
aperture: "monitoring" | "receipt";
|
|
26
33
|
ordinaryBudget?: number;
|
|
@@ -51,6 +58,7 @@ export declare function createLiveStatusReader(paths: AkumaPaths, expected: Akum
|
|
|
51
58
|
completedAt: string;
|
|
52
59
|
}> | undefined;
|
|
53
60
|
}>;
|
|
61
|
+
wait(recent: boolean, signal?: AbortSignal): Promise<WaitStatusObservation>;
|
|
54
62
|
complete(signal?: AbortSignal): Promise<boolean>;
|
|
55
63
|
read(input: StatusObservationInput, signal?: AbortSignal): Promise<LiveStatusObservation>;
|
|
56
64
|
};
|
|
@@ -71,6 +71,10 @@ async function bornObservation(paths, expected, read, snapshot) {
|
|
|
71
71
|
claim?.release();
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
+
/** Lightweight born-life observation using the same leash refresh as status and wait. */
|
|
75
|
+
export async function readBornLife(paths, expected) {
|
|
76
|
+
return (await bornObservation(paths, expected, () => readLifeSnapshot(paths))).currentLife;
|
|
77
|
+
}
|
|
74
78
|
export async function observeOutcomeRows(id, rows, observer) {
|
|
75
79
|
if (observer === undefined)
|
|
76
80
|
return;
|
|
@@ -164,6 +168,10 @@ export function createLiveStatusReader(paths, expected) {
|
|
|
164
168
|
return (await bornObservation(paths, expected, () => reader.life(signal))).currentLife;
|
|
165
169
|
},
|
|
166
170
|
tellOutcome: reader.tellOutcome,
|
|
171
|
+
async wait(recent, signal) {
|
|
172
|
+
const observed = await bornObservation(paths, expected, () => reader.wait(recent, signal));
|
|
173
|
+
return { ...observed.snapshot, id: expected, life: observed.currentLife };
|
|
174
|
+
},
|
|
167
175
|
async complete(signal) {
|
|
168
176
|
try {
|
|
169
177
|
const observed = await bornObservation(paths, expected, () => reader.life(signal));
|
|
@@ -16,8 +16,7 @@ import { resolveProviderExecution } from "./providers/index.js";
|
|
|
16
16
|
import { publishAkuma } from "./publication.js";
|
|
17
17
|
import { z } from "zod";
|
|
18
18
|
import { publicSessionCoordinate, publicSessionCoordinateSchema } from "./coordinate.js";
|
|
19
|
-
|
|
20
|
-
const historyLimit = historySequence.max(5_000).exactOptional();
|
|
19
|
+
import { historyPageSchemas } from "../history.js";
|
|
21
20
|
export const historyInputSchemas = [
|
|
22
21
|
z.strictObject({
|
|
23
22
|
id: z
|
|
@@ -27,8 +26,7 @@ export const historyInputSchemas = [
|
|
|
27
26
|
message: "id must be a positive safe decimal integer, turn/<positive safe integer> or report/<positive safe integer>",
|
|
28
27
|
}),
|
|
29
28
|
}),
|
|
30
|
-
|
|
31
|
-
z.strictObject({ since: historySequence, limit: historyLimit }),
|
|
29
|
+
...historyPageSchemas,
|
|
32
30
|
];
|
|
33
31
|
const historyInputSchema = z.union(historyInputSchemas);
|
|
34
32
|
export const forkFailureSchemas = {
|
|
@@ -441,7 +439,7 @@ export class AkumaOwner {
|
|
|
441
439
|
if (turn?.end?.outcome.kind !== "answered")
|
|
442
440
|
return { kind: "no-answer" };
|
|
443
441
|
await this.outcomeObserved?.(this.id, [`turn/${turn.sequence}`]);
|
|
444
|
-
return { kind: "answer", answer: turn.end.outcome.answer };
|
|
442
|
+
return { kind: "answer", answer: turn.end.outcome.answer, historyId: `turn/${turn.sequence}` };
|
|
445
443
|
}
|
|
446
444
|
}
|
|
447
445
|
/* ---------------------------------------------------------------------------
|
|
@@ -20,11 +20,125 @@ export type NativeWaitResult = Readonly<{
|
|
|
20
20
|
}>;
|
|
21
21
|
export declare const AKUMA_WAIT_POLL_MS = 250;
|
|
22
22
|
/** Private observation custody shared by native and invocation set waits. */
|
|
23
|
-
export declare function createAkumaWaitObserver(path: WorldRoot, ids: readonly AkumaStatus["id"][]): {
|
|
23
|
+
export declare function createAkumaWaitObserver(path: WorldRoot, ids: readonly AkumaStatus["id"][], lightweight?: boolean): {
|
|
24
24
|
items: Map<import("./identity.js").AkumaId, Readonly<{
|
|
25
25
|
kind: "observed";
|
|
26
26
|
id: import("./identity.js").AkumaId;
|
|
27
27
|
life: "hung" | "untidy" | "killed" | "running" | "asleep" | "stranded";
|
|
28
|
+
lastActivityAt?: string;
|
|
29
|
+
events?: readonly (Readonly<{
|
|
30
|
+
kind: "tell";
|
|
31
|
+
sequence: number;
|
|
32
|
+
at: string;
|
|
33
|
+
tellId: string;
|
|
34
|
+
text: string;
|
|
35
|
+
state: "pending" | "told";
|
|
36
|
+
deliveries: readonly Readonly<{
|
|
37
|
+
deliveredAt: string;
|
|
38
|
+
route: "launch" | "live";
|
|
39
|
+
turnSequence: number;
|
|
40
|
+
}>[];
|
|
41
|
+
}> | Readonly<{
|
|
42
|
+
kind: "report";
|
|
43
|
+
sequence: number;
|
|
44
|
+
bodySequence: number;
|
|
45
|
+
turnSequence: number;
|
|
46
|
+
text: string;
|
|
47
|
+
at: string;
|
|
48
|
+
}> | Readonly<{
|
|
49
|
+
kind: "permission";
|
|
50
|
+
sequence: number;
|
|
51
|
+
turnSequence: number;
|
|
52
|
+
at: string;
|
|
53
|
+
requests: readonly Readonly<{
|
|
54
|
+
id: string;
|
|
55
|
+
action: string;
|
|
56
|
+
resources: readonly string[];
|
|
57
|
+
tool?: string;
|
|
58
|
+
}>[];
|
|
59
|
+
truncated?: true;
|
|
60
|
+
}> | Readonly<{
|
|
61
|
+
kind: "call";
|
|
62
|
+
sequence: number;
|
|
63
|
+
turnSequence: number;
|
|
64
|
+
at: string;
|
|
65
|
+
text: string;
|
|
66
|
+
}> | Readonly<{
|
|
67
|
+
kind: "thought" | "note" | "said";
|
|
68
|
+
sequence: number;
|
|
69
|
+
turnSequence: number;
|
|
70
|
+
at: string;
|
|
71
|
+
text: string;
|
|
72
|
+
truncated?: true;
|
|
73
|
+
}> | Readonly<{
|
|
74
|
+
kind: "turn";
|
|
75
|
+
sequence: number;
|
|
76
|
+
bodySequence: number;
|
|
77
|
+
at: string;
|
|
78
|
+
}> | Readonly<{
|
|
79
|
+
kind: "outcome";
|
|
80
|
+
sequence: number;
|
|
81
|
+
turnSequence: number;
|
|
82
|
+
at: string;
|
|
83
|
+
outcome: Readonly<{
|
|
84
|
+
kind: "answered";
|
|
85
|
+
answer: string;
|
|
86
|
+
foldedSaidSequence?: number;
|
|
87
|
+
}> | Readonly<{
|
|
88
|
+
kind: "failed";
|
|
89
|
+
diagnostic: string;
|
|
90
|
+
}> | Readonly<{
|
|
91
|
+
kind: "canceled";
|
|
92
|
+
}>;
|
|
93
|
+
}> | Readonly<{
|
|
94
|
+
kind: "tool";
|
|
95
|
+
sequence: number;
|
|
96
|
+
turnSequence: number;
|
|
97
|
+
at: string;
|
|
98
|
+
name: string;
|
|
99
|
+
call: Readonly<{
|
|
100
|
+
kind: "run";
|
|
101
|
+
command: string;
|
|
102
|
+
}> | Readonly<{
|
|
103
|
+
kind: "read";
|
|
104
|
+
path: string;
|
|
105
|
+
offset?: number;
|
|
106
|
+
limit?: number;
|
|
107
|
+
}> | Readonly<{
|
|
108
|
+
kind: "search";
|
|
109
|
+
query: string;
|
|
110
|
+
scope?: "content" | "files" | "web";
|
|
111
|
+
path?: string;
|
|
112
|
+
glob?: string;
|
|
113
|
+
}> | Readonly<{
|
|
114
|
+
kind: "fileChange";
|
|
115
|
+
changes: readonly Readonly<{
|
|
116
|
+
op: "add" | "update" | "delete" | "unspecified";
|
|
117
|
+
path: string;
|
|
118
|
+
diffstat?: Readonly<{
|
|
119
|
+
added: number;
|
|
120
|
+
removed: number;
|
|
121
|
+
}>;
|
|
122
|
+
patch?: string;
|
|
123
|
+
}>[];
|
|
124
|
+
}> | Readonly<{
|
|
125
|
+
kind: "other";
|
|
126
|
+
input?: Readonly<{
|
|
127
|
+
json: string;
|
|
128
|
+
truncated?: true;
|
|
129
|
+
}>;
|
|
130
|
+
}>;
|
|
131
|
+
toolId: string;
|
|
132
|
+
state: "active" | "unsettled" | Readonly<{
|
|
133
|
+
status: "error" | "ok";
|
|
134
|
+
message?: string;
|
|
135
|
+
output?: string;
|
|
136
|
+
exitCode?: number;
|
|
137
|
+
}>;
|
|
138
|
+
durationMs?: number;
|
|
139
|
+
truncated?: true;
|
|
140
|
+
}>)[];
|
|
141
|
+
eventsUnavailable?: string;
|
|
28
142
|
pending?: true;
|
|
29
143
|
outcome?: Readonly<{
|
|
30
144
|
kind: "answered";
|
|
@@ -48,11 +162,12 @@ export declare function createAkumaWaitObserver(path: WorldRoot, ids: readonly A
|
|
|
48
162
|
id: import("./identity.js").AkumaId;
|
|
49
163
|
}>>;
|
|
50
164
|
satisfied: (id: AkumaStatus["id"]) => boolean;
|
|
51
|
-
observe: (signal?: AbortSignal) => Promise<Readonly<{
|
|
165
|
+
observe: (signal?: AbortSignal, recent?: boolean) => Promise<Readonly<{
|
|
52
166
|
observations: readonly LiveStatusObservation[];
|
|
53
167
|
unobserved: readonly AkumaUnobserved[];
|
|
54
168
|
missing: readonly AkumaStatus["id"][];
|
|
55
169
|
}>>;
|
|
170
|
+
unavailableRecent(message: string): void;
|
|
56
171
|
probe: (completion: "any" | "all", signal?: AbortSignal) => Promise<boolean>;
|
|
57
172
|
notify(observer?: OutcomeObserver): Promise<void>;
|
|
58
173
|
clear: () => void;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { AkumaNotBornError } from "./akuma-errors.js";
|
|
2
|
-
import { createLiveStatusReader, defaultWaitComplete, readWaitComplete, waitForObservation, } from "./akuma-observe.js";
|
|
2
|
+
import { createLiveStatusReader, defaultWaitComplete, executionProgress, readWaitComplete, waitForObservation, } from "./akuma-observe.js";
|
|
3
3
|
import { pathsForAkumaId } from "./identity.js";
|
|
4
|
+
import { projectTurns } from "./projection.js";
|
|
4
5
|
const SHARED_ORDINARY_BUDGET = 30;
|
|
5
6
|
export const AKUMA_WAIT_POLL_MS = 250;
|
|
6
|
-
async function observeWaitRound(ids, readerFor, signal, witnessed) {
|
|
7
|
+
async function observeWaitRound(ids, readerFor, signal, witnessed, mode = { lightweight: false, recent: false }) {
|
|
7
8
|
const read = (id, ordinaryBudget) => readerFor(id).read({ aperture: "monitoring", ...(ordinaryBudget === undefined ? {} : { ordinaryBudget }) }, signal);
|
|
8
9
|
signal?.throwIfAborted();
|
|
9
10
|
let remaining = SHARED_ORDINARY_BUDGET;
|
|
@@ -13,10 +14,16 @@ async function observeWaitRound(ids, readerFor, signal, witnessed) {
|
|
|
13
14
|
for (const id of ids) {
|
|
14
15
|
signal?.throwIfAborted();
|
|
15
16
|
try {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
if (mode.lightweight) {
|
|
18
|
+
const item = completionSnapshot(await readerFor(id).wait(mode.recent, signal));
|
|
19
|
+
witnessed?.(item);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const observed = await read(id, remaining);
|
|
23
|
+
observations.push(observed);
|
|
24
|
+
witnessed?.(completionItem(observed));
|
|
25
|
+
remaining -= observed.ordinarySelected;
|
|
26
|
+
}
|
|
20
27
|
}
|
|
21
28
|
catch (error) {
|
|
22
29
|
signal?.throwIfAborted();
|
|
@@ -58,16 +65,40 @@ function completionItem({ status, rows }) {
|
|
|
58
65
|
kind: "observed",
|
|
59
66
|
id: status.id,
|
|
60
67
|
life: status.life,
|
|
68
|
+
...(status.lastActivityAt === undefined ? {} : { lastActivityAt: status.lastActivityAt }),
|
|
61
69
|
...(pending ? { pending: true } : {}),
|
|
62
70
|
...(outcome === undefined ? {} : { outcome: waitOutcome(outcome) }),
|
|
63
71
|
...(status.strandedReason === undefined ? {} : { strandedReason: status.strandedReason }),
|
|
64
72
|
};
|
|
65
73
|
}
|
|
74
|
+
function completionSnapshot(snapshot) {
|
|
75
|
+
const turn = snapshot.turn;
|
|
76
|
+
const outcome = turn?.end === undefined ? undefined : projectTurns([turn, turn.end]).latestOutcome;
|
|
77
|
+
let events;
|
|
78
|
+
let eventsUnavailable = snapshot.activityDiagnostic;
|
|
79
|
+
if (snapshot.activity !== undefined && snapshot.life === "running") {
|
|
80
|
+
try {
|
|
81
|
+
events = projectTurns(snapshot.activity.rows).rows.slice(-3);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
eventsUnavailable = diagnostic(error);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
kind: "observed",
|
|
89
|
+
id: snapshot.id,
|
|
90
|
+
life: snapshot.life,
|
|
91
|
+
...(snapshot.lastActivityAt === null ? {} : { lastActivityAt: snapshot.lastActivityAt }),
|
|
92
|
+
...(snapshot.hasPendingTell ? { pending: true } : {}),
|
|
93
|
+
...(outcome === undefined ? {} : { outcome: waitOutcome(outcome) }),
|
|
94
|
+
...(events === undefined ? {} : { events }),
|
|
95
|
+
...(eventsUnavailable === undefined ? {} : { eventsUnavailable: diagnostic(eventsUnavailable) }),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
66
98
|
/** Private observation custody shared by native and invocation set waits. */
|
|
67
|
-
export function createAkumaWaitObserver(path, ids) {
|
|
99
|
+
export function createAkumaWaitObserver(path, ids, lightweight = false) {
|
|
68
100
|
const readers = new Map();
|
|
69
101
|
const items = new Map();
|
|
70
|
-
const observations = new Map();
|
|
71
102
|
const readerFor = (id) => {
|
|
72
103
|
let reader = readers.get(id);
|
|
73
104
|
if (reader === undefined) {
|
|
@@ -79,16 +110,16 @@ export function createAkumaWaitObserver(path, ids) {
|
|
|
79
110
|
return {
|
|
80
111
|
items,
|
|
81
112
|
satisfied: (id) => {
|
|
82
|
-
const
|
|
83
|
-
return
|
|
113
|
+
const item = items.get(id);
|
|
114
|
+
return item?.kind === "observed" && executionProgress(item.life, item.pending === true) !== "advancing";
|
|
115
|
+
},
|
|
116
|
+
observe: (signal, recent = false) => observeWaitRound(ids, readerFor, signal, (item) => items.set(item.id, item), { lightweight, recent }),
|
|
117
|
+
unavailableRecent(message) {
|
|
118
|
+
for (const [id, item] of items) {
|
|
119
|
+
if (item.kind === "observed" && item.life === "running" && item.events === undefined)
|
|
120
|
+
items.set(id, { ...item, eventsUnavailable: diagnostic(message) });
|
|
121
|
+
}
|
|
84
122
|
},
|
|
85
|
-
observe: (signal) => observeWaitRound(ids, readerFor, signal, (item, observation) => {
|
|
86
|
-
items.set(item.id, item);
|
|
87
|
-
if (observation === undefined)
|
|
88
|
-
observations.delete(item.id);
|
|
89
|
-
else
|
|
90
|
-
observations.set(item.id, observation);
|
|
91
|
-
}),
|
|
92
123
|
probe: (completion, signal) => readWaitComplete(path, ids, completion, signal, (id) => readerFor(id)
|
|
93
124
|
.complete(signal)
|
|
94
125
|
.catch((error) => {
|
|
@@ -97,10 +128,9 @@ export function createAkumaWaitObserver(path, ids) {
|
|
|
97
128
|
throw error;
|
|
98
129
|
})),
|
|
99
130
|
async notify(observer) {
|
|
100
|
-
for (const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
await observer?.(status.id, [`turn/${outcome.turnSequence}`]);
|
|
131
|
+
for (const item of items.values()) {
|
|
132
|
+
if (item.kind === "observed" && item.outcome !== undefined)
|
|
133
|
+
await observer?.(item.id, [item.outcome.historyId]);
|
|
104
134
|
}
|
|
105
135
|
},
|
|
106
136
|
clear: () => {
|
|
@@ -137,5 +167,6 @@ export async function executeWaitAkuma(input) {
|
|
|
137
167
|
}
|
|
138
168
|
}
|
|
139
169
|
function diagnostic(error) {
|
|
140
|
-
|
|
170
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
171
|
+
return message.length <= 500 ? message : `${message.slice(0, 500)}...`;
|
|
141
172
|
}
|