@astrosheep/keiyaku 4.6.25 → 4.6.27
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 +37 -0
- package/build/plugins/claude/skills/keiyaku/SKILL.md +14 -26
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +26 -41
- package/build/plugins/claude/skills/keiyaku-akuma/references/automation.md +9 -18
- package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +3 -14
- package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +13 -8
- package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +14 -38
- package/build/plugins/codex/skills/keiyaku/SKILL.md +14 -26
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +26 -41
- package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +9 -18
- package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +3 -14
- package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +13 -8
- package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +14 -38
- package/build/plugins/opencode/skills/keiyaku/SKILL.md +14 -26
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +26 -41
- package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +9 -18
- package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +3 -14
- package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +13 -8
- package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +14 -38
- package/build/skills/keiyaku/SKILL.md +14 -26
- package/build/skills/keiyaku-akuma/SKILL.md +26 -41
- package/build/skills/keiyaku-akuma/references/automation.md +9 -18
- package/build/skills/keiyaku-bind/SKILL.md +3 -14
- package/build/skills/keiyaku-debt/SKILL.md +13 -8
- package/build/skills/keiyaku-workflow/SKILL.md +14 -38
- package/build/src/akuma/akuma-owner.d.ts +1 -1
- package/build/src/akuma/akuma-owner.js +7 -3
- package/build/src/akuma/body.js +1 -0
- package/build/src/akuma/providers/codex-app-server/events.d.ts +1 -1
- package/build/src/akuma/providers/codex-app-server/events.js +1 -3
- package/build/src/cli/commands/akuma-grammar.js +4 -4
- package/build/src/cli/commands/contract-help.js +49 -73
- package/build/src/cli/commands/debt-grammar.js +15 -15
- package/build/src/cli/commands/install.d.ts +1 -1
- package/build/src/cli/commands/install.js +1 -2
- package/build/src/cli/parse.js +1 -1
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/package.json +7 -7
- package/plugins/paseo/plugin/index.server.ts +9 -3
- package/plugins/paseo/plugin/paseo-plugin.json +1 -1
- package/plugins/paseo/plugin/server/attach.ts +1 -6
- package/plugins/paseo/plugin/server/handoff.ts +114 -0
- package/plugins/paseo/plugin/server/provider.ts +18 -5
- package/plugins/paseo/plugin/server/reopen.ts +78 -0
- package/skills/keiyaku/SKILL.md +14 -26
- package/skills/keiyaku-akuma/SKILL.md +26 -41
- package/skills/keiyaku-akuma/references/automation.md +9 -18
- package/skills/keiyaku-bind/SKILL.md +3 -14
- package/skills/keiyaku-debt/SKILL.md +13 -8
- package/skills/keiyaku-workflow/SKILL.md +14 -38
|
@@ -41,18 +41,16 @@ export const CONTRACT_COMMAND_SPECS = {
|
|
|
41
41
|
" # <title>",
|
|
42
42
|
" ## Context motivation, authority, baseline, and boundaries",
|
|
43
43
|
" ## Objective one observable end state",
|
|
44
|
-
" ## Design
|
|
45
|
-
" leave implementation details to the person doing the work",
|
|
44
|
+
" ## Design settled design: decisions the implementation must follow",
|
|
46
45
|
" ## Region narrowest justified intended writes for this approach, one pattern per line",
|
|
47
46
|
" ## Criteria one or more ### <criterion> entries",
|
|
48
47
|
" ## Verification optional fenced executor declarations",
|
|
49
48
|
"",
|
|
50
|
-
"Region
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"info string or exactly 'txt'.",
|
|
49
|
+
"Region lists the narrowest writes this approach needs, not every file involved;",
|
|
50
|
+
"avoid broad directories and redundant parent/child patterns. Put one repository-relative",
|
|
51
|
+
"pattern per nonblank line: bare lines, list items, or fences (no info string, or",
|
|
52
|
+
"txt) are combined. A trailing '/' means 'path/**'. Whitespace in a pattern",
|
|
53
|
+
"binds with a warning.",
|
|
56
54
|
"",
|
|
57
55
|
"Verification runs only with the verified gate; without it the section is inert text.",
|
|
58
56
|
"Verification uses one or more closed bash, zsh, or pwsh fences. Its fence",
|
|
@@ -67,17 +65,13 @@ export const CONTRACT_COMMAND_SPECS = {
|
|
|
67
65
|
usage: "amend [<contract>|@<contract>] [--after <kei/...> [--after <kei/...>]... | --clear-after] [--gates <name,...>] [--actor <actor>] [--repo <path>] [-]",
|
|
68
66
|
purpose: "Change a Contract's document, prerequisites, or acceptance gates.",
|
|
69
67
|
details: [
|
|
70
|
-
"Gates are
|
|
71
|
-
"
|
|
72
|
-
"",
|
|
73
|
-
|
|
74
|
-
"from Settings (keiyaku settings). A group expands into its gates; unknown names",
|
|
75
|
-
"are rejected with the known names listed. Custom gates must be declared in a",
|
|
76
|
-
"configured group. Duplicates are removed in first-seen order.",
|
|
77
|
-
"Names match ^[a-z][a-z0-9-]{0,63}$.",
|
|
78
|
-
'Omitting --gates leaves gates unchanged; --gates "" clears them.',
|
|
68
|
+
"Gates are checked at integration: reviewed needs a satisfied review;",
|
|
69
|
+
"verified needs passing Verification. --gates <name,...> replaces them with",
|
|
70
|
+
"reviewed, verified, or configured groups (see keiyaku settings).",
|
|
71
|
+
'Omitting --gates keeps them; --gates "" clears them.',
|
|
79
72
|
"",
|
|
80
|
-
"
|
|
73
|
+
"stdin is an amendment; each heading is one edit:",
|
|
74
|
+
" ## Context|Objective|Design|Region|Criteria|Verification|<extension> (replace, or add a new extension)",
|
|
81
75
|
" ## Replace: Context|Objective|Design|Region|Criteria|Verification|<extension>",
|
|
82
76
|
" ## Append: Context|Objective|Design|Criteria|<extension>",
|
|
83
77
|
" ## Add: Criteria|<new-extension-title>",
|
|
@@ -100,22 +94,33 @@ export const CONTRACT_COMMAND_SPECS = {
|
|
|
100
94
|
usage: "deliver [<contract>|@<contract>] [--message <text>] [--include-dirty] [--materialize-conflict] [--overwrite] [--repo <path>]\ndeliver [<contract>|@<contract>] --dry-run [--include-dirty] [--show-diff] [--repo <path>]",
|
|
101
95
|
purpose: "Submit work for a Contract and integrate it when its requirements are met.",
|
|
102
96
|
details: [
|
|
103
|
-
"
|
|
104
|
-
"With the verified gate
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
-
"
|
|
112
|
-
"
|
|
113
|
-
"
|
|
114
|
-
"Content identity
|
|
97
|
+
"Delivery is judged against the whole Contract, not the current Arc. It uses",
|
|
98
|
+
"HEAD. With the verified gate it runs Verification or reuses current satisfied",
|
|
99
|
+
"evidence. If prerequisites and gates pass, it integrates and accepts now;",
|
|
100
|
+
"otherwise the candidate waits. Delivery never counts as a review.",
|
|
101
|
+
"",
|
|
102
|
+
"Repeating delivery with unchanged work resumes unfinished Verification or",
|
|
103
|
+
"integration. Changed work replaces the candidate and invalidates earlier review.",
|
|
104
|
+
"Identical content keeps review across rebase or target movement.",
|
|
105
|
+
"",
|
|
106
|
+
"Progress goes to stderr; stdout carries one final result. Ctrl-C requests a",
|
|
107
|
+
"stop and waits for the final receipt; it does not roll back admitted work.",
|
|
108
|
+
"Content identity is a content hash, not a commit: it survives rebase, and Git",
|
|
109
|
+
"cannot look it up.",
|
|
110
|
+
"",
|
|
111
|
+
" --include-dirty Include all non-ignored changes, staged or not;",
|
|
112
|
+
" capturing them leaves your branch and index unchanged.",
|
|
113
|
+
" --message Set the delivery commit's subject.",
|
|
114
|
+
" --dry-run Preview candidate, conflicts, standing evidence and",
|
|
115
|
+
" target followability. No Verification, hooks or",
|
|
116
|
+
" integration; refs, index and worktrees stay untouched.",
|
|
117
|
+
" Real delivery checks again; preview promises no acceptance.",
|
|
118
|
+
" --show-diff Include the proposed diff; requires --dry-run.",
|
|
119
|
+
" --materialize-conflict Write the observed conflict as an uncommitted merge.",
|
|
120
|
+
" With --include-dirty, preserve current changes first.",
|
|
121
|
+
" --overwrite Bypass reuse of a candidate with unfinished Verification.",
|
|
115
122
|
"",
|
|
116
|
-
"
|
|
117
|
-
" With --include-dirty, current non-ignored changes are preserved first.",
|
|
118
|
-
" --overwrite Replace a candidate whose Verification has not finished.",
|
|
123
|
+
"--message, --materialize-conflict and --overwrite are refused with --dry-run.",
|
|
119
124
|
].join("\n"),
|
|
120
125
|
},
|
|
121
126
|
review: {
|
|
@@ -230,55 +235,26 @@ export function renderContractHelp(command) {
|
|
|
230
235
|
const spec = CONTRACT_COMMAND_SPECS[command];
|
|
231
236
|
if (command === "settings") {
|
|
232
237
|
return [
|
|
233
|
-
"Show effective Settings
|
|
238
|
+
"Show effective Settings (read-only), merged from:",
|
|
234
239
|
" user ~/.keiyaku/settings.json",
|
|
235
240
|
" project <WorldRoot>/.keiyaku/settings.json",
|
|
236
|
-
"A project record wholly shadows the same-name user record.",
|
|
241
|
+
"A project record wholly shadows the same-name user record. Edit the files",
|
|
242
|
+
"directly; there is no write command.",
|
|
237
243
|
"",
|
|
238
|
-
|
|
239
|
-
"command; edit the files directly.",
|
|
244
|
+
usageLine(spec.usage),
|
|
240
245
|
"",
|
|
241
246
|
"Recognized settings:",
|
|
242
|
-
" gates named gate groups
|
|
243
|
-
" worktree commands run when worktrees are created or destroyed",
|
|
244
|
-
" git.requireBranchesToBeUpToDate whether delivery and
|
|
245
|
-
" providers
|
|
246
|
-
"",
|
|
247
|
-
"Each entry is validated by the feature that reads it. A rejected",
|
|
248
|
-
"value's diagnostic states the expected shape.",
|
|
247
|
+
" gates named gate groups for bind/amend --gates",
|
|
248
|
+
" worktree commands run when Contract worktrees are created or destroyed",
|
|
249
|
+
" git.requireBranchesToBeUpToDate whether delivery and preview require an up-to-date target",
|
|
250
|
+
" providers Akuma providers and how each is run",
|
|
249
251
|
"",
|
|
250
252
|
"Akuma definitions are Markdown files, one per name:",
|
|
251
253
|
" user ~/.keiyaku/akumas/<name>.md",
|
|
252
254
|
" project <WorldRoot>/.keiyaku/akumas/<name>.md",
|
|
253
|
-
"
|
|
254
|
-
"
|
|
255
|
-
"
|
|
256
|
-
"an optional system prompt.",
|
|
257
|
-
"",
|
|
258
|
-
"Local Paseo provider in settings.json:",
|
|
259
|
-
' { "providers": { "paseo": {',
|
|
260
|
-
' "kind": "paseo",',
|
|
261
|
-
' "config": { "url": "ws://127.0.0.1:6767/ws", "provider": "claude" }',
|
|
262
|
-
" } } }",
|
|
263
|
-
"The native provider id is bare (claude, codex, pi), not provider/model.",
|
|
264
|
-
"Example .keiyaku/akumas/paseo-worker.md frontmatter:",
|
|
265
|
-
" ---",
|
|
266
|
-
" provider: paseo",
|
|
267
|
-
" model: <native-model-id>",
|
|
268
|
-
" effort: high",
|
|
269
|
-
" ---",
|
|
270
|
-
"Model and effort must be offered by the selected native provider;",
|
|
271
|
-
"effort names its native thinking option id.",
|
|
272
|
-
'PASEO_PASSWORD=<password> keiyaku call paseo-worker "<prompt>"',
|
|
273
|
-
"Paseo must already be running locally. Resume keeps its live native",
|
|
274
|
-
"runtime; after Paseo native reload/restart create a fresh Akuma.",
|
|
275
|
-
"Observed busy agents refuse; native steer still has a check/send race.",
|
|
276
|
-
"Explicit control cancels native current execution session-wide and may",
|
|
277
|
-
"affect concurrent human work. Normal completion only retires the client",
|
|
278
|
-
"and its sockets; it never cancels later work or closes the native runtime.",
|
|
279
|
-
"Socket closure does not prove native cancellation succeeded.",
|
|
280
|
-
"",
|
|
281
|
-
usageLine(spec.usage),
|
|
255
|
+
"Project wins. Frontmatter: provider, base, model, effort, network, allowed,",
|
|
256
|
+
"systemPromptMode, description. The body is an optional system prompt.",
|
|
257
|
+
"Provider setup: see README Configuration.",
|
|
282
258
|
].join("\n");
|
|
283
259
|
}
|
|
284
260
|
const help = `${spec.purpose}\n\n${usageLine(spec.usage)}`;
|
|
@@ -24,8 +24,8 @@ const DEBT_COMMAND_SPECS = {
|
|
|
24
24
|
usage: `debt add <TITLE> [--namespace <ns>] [--priority 0..3]
|
|
25
25
|
[--state open|done|drop]
|
|
26
26
|
[--note <text>] [--actor <actor>]
|
|
27
|
-
[--needs <
|
|
28
|
-
[--supersedes <
|
|
27
|
+
[--needs <debt/...>]... [--parent <debt/...>]
|
|
28
|
+
[--supersedes <debt/...>]... [--relates <debt/...>]...
|
|
29
29
|
[--body <text>]
|
|
30
30
|
debt add [--namespace <ns>] [--actor <actor>] -`,
|
|
31
31
|
purpose: "Create a Debt from flags or a Debt document on stdin.",
|
|
@@ -34,13 +34,13 @@ debt add [--namespace <ns>] [--actor <actor>] -`,
|
|
|
34
34
|
show: {
|
|
35
35
|
arity: [1, Number.POSITIVE_INFINITY],
|
|
36
36
|
flags: COMMON,
|
|
37
|
-
usage: "debt show <
|
|
37
|
+
usage: "debt show <debt/...>...",
|
|
38
38
|
purpose: "Read one or more Debts and their relationships.",
|
|
39
39
|
},
|
|
40
40
|
ls: {
|
|
41
41
|
arity: [0, 1],
|
|
42
42
|
flags: { ...COMMON, closed: "boolean", all: "boolean", world: "boolean", limit: "value" },
|
|
43
|
-
usage: "debt ls [<namespace-selector>] [--closed | --all] [--world] [--limit <
|
|
43
|
+
usage: "debt ls [<namespace-selector>] [--closed | --all] [--world] [--limit <count>]",
|
|
44
44
|
purpose: "List Debts in the selected namespace.",
|
|
45
45
|
details: [
|
|
46
46
|
"With no selector, lists the current directory Debt context.",
|
|
@@ -50,14 +50,14 @@ debt add [--namespace <ns>] [--actor <actor>] -`,
|
|
|
50
50
|
ready: {
|
|
51
51
|
arity: [0, 0],
|
|
52
52
|
flags: { ...COMMON, world: "boolean", parent: "value", limit: "value" },
|
|
53
|
-
usage: "debt ready [--world] [--parent <
|
|
53
|
+
usage: "debt ready [--world] [--parent <debt/...>] [--limit <count>]",
|
|
54
54
|
purpose: "List open Debts whose every dependency is complete or dropped.",
|
|
55
55
|
details: "--world lists every namespace in the current Debt world.",
|
|
56
56
|
},
|
|
57
57
|
blocked: {
|
|
58
58
|
arity: [0, 0],
|
|
59
59
|
flags: { ...COMMON, world: "boolean", parent: "value", limit: "value" },
|
|
60
|
-
usage: "debt blocked [--world] [--parent <
|
|
60
|
+
usage: "debt blocked [--world] [--parent <debt/...>] [--limit <count>]",
|
|
61
61
|
purpose: "List Debts with unmet dependencies.",
|
|
62
62
|
details: "--world lists every namespace in the current Debt world.",
|
|
63
63
|
},
|
|
@@ -73,7 +73,7 @@ debt add [--namespace <ns>] [--actor <actor>] -`,
|
|
|
73
73
|
limit: "value",
|
|
74
74
|
},
|
|
75
75
|
usage: `debt query [--where <expression>] [--closed | --all] [--world]
|
|
76
|
-
[--sort priority|created|updated|id] [--limit <
|
|
76
|
+
[--sort priority|created|updated|id] [--limit <count>]`,
|
|
77
77
|
purpose: "Filter and sort Debts with a boolean expression.",
|
|
78
78
|
details: [
|
|
79
79
|
"fields: state priority title id parent under needs blocks ready blocked created updated",
|
|
@@ -89,7 +89,7 @@ debt add [--namespace <ns>] [--actor <actor>] -`,
|
|
|
89
89
|
tree: {
|
|
90
90
|
arity: [1, 1],
|
|
91
91
|
flags: COMMON,
|
|
92
|
-
usage: "debt tree <
|
|
92
|
+
usage: "debt tree <debt/...>",
|
|
93
93
|
purpose: "Show a Debt and its parent/child breakdown.",
|
|
94
94
|
},
|
|
95
95
|
doctor: {
|
|
@@ -116,12 +116,12 @@ debt add [--namespace <ns>] [--actor <actor>] -`,
|
|
|
116
116
|
relates: "repeat",
|
|
117
117
|
"drop-relates": "repeat",
|
|
118
118
|
},
|
|
119
|
-
usage: `debt update <
|
|
119
|
+
usage: `debt update <debt/...> [--title <text>] [--body <text>|- | --append <text>]
|
|
120
120
|
[--note <text>]
|
|
121
|
-
[--priority 0..3] [--needs <
|
|
122
|
-
[--parent <
|
|
123
|
-
[--supersedes <
|
|
124
|
-
[--relates <
|
|
121
|
+
[--priority 0..3] [--needs <debt/...>]... [--drop-needs <debt/...>]...
|
|
122
|
+
[--parent <debt/...> | --no-parent]
|
|
123
|
+
[--supersedes <debt/...>]... [--drop-supersedes <debt/...>]...
|
|
124
|
+
[--relates <debt/...>]... [--drop-relates <debt/...>]...`,
|
|
125
125
|
purpose: "Change a Debt's fields and relationships.",
|
|
126
126
|
details: [
|
|
127
127
|
"--body replaces the body; --append adds text after it, separated by a newline when needed.",
|
|
@@ -131,13 +131,13 @@ debt add [--namespace <ns>] [--actor <actor>] -`,
|
|
|
131
131
|
done: {
|
|
132
132
|
arity: [1, Number.POSITIVE_INFINITY],
|
|
133
133
|
flags: { ...COMMON, note: "value" },
|
|
134
|
-
usage: "debt done <
|
|
134
|
+
usage: "debt done <debt/...>... [--note <text>]",
|
|
135
135
|
purpose: "Mark one or more Debts done.",
|
|
136
136
|
},
|
|
137
137
|
drop: {
|
|
138
138
|
arity: [1, Number.POSITIVE_INFINITY],
|
|
139
139
|
flags: { ...COMMON, note: "value" },
|
|
140
|
-
usage: "debt drop <
|
|
140
|
+
usage: "debt drop <debt/...>... [--note <text>]",
|
|
141
141
|
purpose: "Mark one or more Debts as no longer needed.",
|
|
142
142
|
},
|
|
143
143
|
context: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { CliOutcome } from "../streams.js";
|
|
2
2
|
import type { ProcessInput, ProcessOutcome } from "../../runtime/proc/run.js";
|
|
3
3
|
declare const HARNESS_NAMES: readonly ["codex", "claude", "opencode", "pi"];
|
|
4
4
|
type HarnessName = (typeof HARNESS_NAMES)[number];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { cliExitCode } from "../streams.js";
|
|
2
1
|
import { dirname, resolve } from "node:path";
|
|
3
2
|
import { fileURLToPath } from "node:url";
|
|
4
3
|
import { CliUsageError, commandGuide, usageLine } from "../usage.js";
|
|
@@ -45,7 +44,7 @@ export function parseInstallCommand(argv) {
|
|
|
45
44
|
};
|
|
46
45
|
}
|
|
47
46
|
export function renderInstallHelp() {
|
|
48
|
-
return `${INSTALL_ROOT_PURPOSE}\n\n${usageLine(INSTALL_USAGE)}\n\n--all continues past failures
|
|
47
|
+
return `${INSTALL_ROOT_PURPOSE}\n\n${usageLine(INSTALL_USAGE)}\n\n--all continues past failures and fails if any harness failed.`;
|
|
49
48
|
}
|
|
50
49
|
const INSTALL_TIMEOUT_MS = 5 * 60 * 1000;
|
|
51
50
|
const ASSET_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "../../../plugins");
|
package/build/src/cli/parse.js
CHANGED
|
@@ -87,7 +87,7 @@ export function renderHelp(coordinate, columns) {
|
|
|
87
87
|
case "install":
|
|
88
88
|
return renderInstallHelp();
|
|
89
89
|
case "whoami":
|
|
90
|
-
return `${WHOAMI_PURPOSE}\n\n${usageLine(WHOAMI_USAGE)}\n\nRead-only
|
|
90
|
+
return `${WHOAMI_PURPOSE}\n\n${usageLine(WHOAMI_USAGE)}\n\nRead-only. For an Akuma, who started its current turn is shown apart from who called it. Missing or unreadable facts stay explicit.`;
|
|
91
91
|
case "akuma":
|
|
92
92
|
return renderAkumaHelp(coordinate.action);
|
|
93
93
|
}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrosheep/keiyaku",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.27",
|
|
4
4
|
"workspaces": [
|
|
5
5
|
"plugins/square",
|
|
6
6
|
"plugins/paseo/forwarder"
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@earendil-works/pi-coding-agent": "^1.4.0",
|
|
68
|
-
"@getpaseo/plugin": "0.
|
|
69
|
-
"@getpaseo/server": "0.
|
|
68
|
+
"@getpaseo/plugin": "0.14.0",
|
|
69
|
+
"@getpaseo/server": "0.14.0",
|
|
70
70
|
"@types/cross-spawn": "^6.0.6",
|
|
71
71
|
"@types/node": "^25.0.0",
|
|
72
72
|
"@types/ws": "^8.18.2",
|
|
@@ -81,10 +81,10 @@
|
|
|
81
81
|
"dependencies": {
|
|
82
82
|
"@agentclientprotocol/sdk": "^1.3.0",
|
|
83
83
|
"@anthropic-ai/claude-agent-sdk": "^0.3.226",
|
|
84
|
-
"@astrosheep/keiyaku-plugin-square": "0.1.
|
|
85
|
-
"@astrosheep/square": "^0.3.
|
|
86
|
-
"@getpaseo/client": "0.
|
|
87
|
-
"@getpaseo/protocol": "0.
|
|
84
|
+
"@astrosheep/keiyaku-plugin-square": "0.1.20",
|
|
85
|
+
"@astrosheep/square": "^0.3.106",
|
|
86
|
+
"@getpaseo/client": "0.14.0",
|
|
87
|
+
"@getpaseo/protocol": "0.14.0",
|
|
88
88
|
"@opencode/client": "2.0.20",
|
|
89
89
|
"@opencode/schema": "2.0.20",
|
|
90
90
|
"cross-spawn": "^7.0.6",
|
|
@@ -4,14 +4,20 @@ import { createSdkTransport } from "./server/sdk.js";
|
|
|
4
4
|
import { attach } from "./server/attach.js";
|
|
5
5
|
import { attachRpc } from "./shared/attach-rpc.js";
|
|
6
6
|
import { refreshRpc } from "./shared/refresh-rpc.js";
|
|
7
|
+
import { refreshOrReopen } from "./server/reopen.js";
|
|
8
|
+
import { createRegistrationHandoff, registerRegistrationHooks } from "./server/handoff.js";
|
|
7
9
|
|
|
8
10
|
export default function contribute(server: PluginServerContext) {
|
|
9
11
|
const transport = createSdkTransport();
|
|
10
|
-
const
|
|
12
|
+
const handoff = createRegistrationHandoff();
|
|
13
|
+
const mirror = createProvider(transport, handoff);
|
|
11
14
|
server.registerProvider(mirror.provider);
|
|
12
|
-
server.handle(refreshRpc, (input) => mirror.refresh
|
|
13
|
-
server.handle(attachRpc, (input, context) => attach(input, context
|
|
15
|
+
server.handle(refreshRpc, (input, context) => refreshOrReopen(context.paseo, input, mirror.refresh));
|
|
16
|
+
server.handle(attachRpc, (input, context) => attach(input, context));
|
|
17
|
+
const removeHooks = registerRegistrationHooks(server, handoff);
|
|
14
18
|
return async () => {
|
|
19
|
+
removeHooks();
|
|
20
|
+
await handoff.close();
|
|
15
21
|
try { await mirror.close(); } finally { await transport.close(); }
|
|
16
22
|
};
|
|
17
23
|
}
|
|
@@ -7,8 +7,7 @@ function skip(reason: string) {
|
|
|
7
7
|
console.warn(`Keiyaku mirror not attached: ${reason}`);
|
|
8
8
|
return { attached: false };
|
|
9
9
|
}
|
|
10
|
-
export async function attach(input: z.output<typeof attachRpc.input>, { paseo }: PluginHandlerContext
|
|
11
|
-
sync: (input: { world: string; akuId: string }) => Promise<void>) {
|
|
10
|
+
export async function attach(input: z.output<typeof attachRpc.input>, { paseo }: PluginHandlerContext) {
|
|
12
11
|
const caller = input.caller;
|
|
13
12
|
if (caller?.kind !== "external") return skip("caller is not an external host");
|
|
14
13
|
const native = ["codex", "pi", "claude"].includes(caller.integration);
|
|
@@ -44,9 +43,5 @@ export async function attach(input: z.output<typeof attachRpc.input>, { paseo }:
|
|
|
44
43
|
config: { provider: "keiyaku/mirror", options: { world, akuId: input.akuId } },
|
|
45
44
|
idempotencyKey: `keiyaku:${world}:${input.akuId}`,
|
|
46
45
|
});
|
|
47
|
-
// Creation returns only after the host has registered and subscribed to the session.
|
|
48
|
-
// Opening's ready event is too early to restore running presentation there.
|
|
49
|
-
try { await sync({ world, akuId: input.akuId }); }
|
|
50
|
-
catch (error) { console.warn(`Keiyaku mirror attached, but synchronization failed: ${error instanceof Error ? error.message : String(error)}`); }
|
|
51
46
|
return { attached: true };
|
|
52
47
|
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { PaseoApi } from "@getpaseo/client";
|
|
2
|
+
import type { PluginHookContext, PluginServerContext, PluginSessionOpenRequest } from "@getpaseo/plugin/server";
|
|
3
|
+
import type { SessionOutboundMessage } from "@getpaseo/protocol/messages";
|
|
4
|
+
|
|
5
|
+
type ObservedSession = Readonly<{ observe(reannounce?: boolean): Promise<void> }>;
|
|
6
|
+
type Attempt = {
|
|
7
|
+
agentId: string;
|
|
8
|
+
controller: AbortController;
|
|
9
|
+
timer: ReturnType<typeof setTimeout>;
|
|
10
|
+
unsubscribeContext: () => void;
|
|
11
|
+
subscription?: Awaited<ReturnType<PaseoApi["agents"]["list"]>>["subscription"];
|
|
12
|
+
session?: ObservedSession;
|
|
13
|
+
idleObserved: boolean;
|
|
14
|
+
syncing: boolean;
|
|
15
|
+
active: boolean;
|
|
16
|
+
cleanup?: Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
const ATTEMPT_TIMEOUT_MS = 90_000;
|
|
19
|
+
|
|
20
|
+
export function registerRegistrationHooks(server: Pick<PluginServerContext, "before" | "on">,
|
|
21
|
+
handoff: ReturnType<typeof createRegistrationHandoff>): () => void {
|
|
22
|
+
const removeBefore = server.before("agent.session_open", ({ request }, context) => handoff.beforeOpen(request, context));
|
|
23
|
+
const removeArchived = server.on("agent.archived", ({ agent }) => handoff.closed(agent.id));
|
|
24
|
+
const removeClosed = server.on("agent.closed", ({ agent }) => handoff.closed(agent.id));
|
|
25
|
+
return () => { removeBefore(); removeArchived(); removeClosed(); };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function createRegistrationHandoff() {
|
|
29
|
+
const attempts = new Map<string, Attempt>();
|
|
30
|
+
const release = (attempt: Attempt): Promise<void> => {
|
|
31
|
+
if (attempt.cleanup) return attempt.cleanup;
|
|
32
|
+
if (!attempt.active) return Promise.resolve();
|
|
33
|
+
attempt.active = false;
|
|
34
|
+
clearTimeout(attempt.timer);
|
|
35
|
+
attempt.controller.abort();
|
|
36
|
+
attempt.unsubscribeContext();
|
|
37
|
+
if (attempts.get(attempt.agentId) === attempt) attempts.delete(attempt.agentId);
|
|
38
|
+
attempt.cleanup = attempt.subscription?.release().catch((error: unknown) => {
|
|
39
|
+
console.warn(`Keiyaku mirror registration subscription cleanup failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
40
|
+
}) ?? Promise.resolve();
|
|
41
|
+
return attempt.cleanup;
|
|
42
|
+
};
|
|
43
|
+
const synchronize = (attempt: Attempt): void => {
|
|
44
|
+
if (!attempt.active || attempt.syncing || !attempt.idleObserved || !attempt.session) return;
|
|
45
|
+
attempt.syncing = true;
|
|
46
|
+
void attempt.session.observe(true).catch((error: unknown) => {
|
|
47
|
+
console.warn(`Keiyaku mirror registration synchronization failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
48
|
+
}).finally(async () => { await release(attempt); });
|
|
49
|
+
};
|
|
50
|
+
const update = (attempt: Attempt, message: SessionOutboundMessage): void => {
|
|
51
|
+
if (!attempt.active || !attempt.session || message.type !== "agent_update" || message.payload.kind !== "upsert") return;
|
|
52
|
+
const { agent } = message.payload;
|
|
53
|
+
if (agent.id !== attempt.agentId || agent.provider !== "keiyaku" || agent.status !== "idle" || agent.archivedAt) return;
|
|
54
|
+
attempt.idleObserved = true;
|
|
55
|
+
synchronize(attempt);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
async beforeOpen(request: PluginSessionOpenRequest, context: PluginHookContext): Promise<void> {
|
|
60
|
+
if (request.provider !== "keiyaku") return;
|
|
61
|
+
const agentId = request.agentId;
|
|
62
|
+
if (!agentId) return;
|
|
63
|
+
const prior = attempts.get(agentId);
|
|
64
|
+
if (prior) await release(prior);
|
|
65
|
+
const controller = new AbortController();
|
|
66
|
+
let attempt!: Attempt;
|
|
67
|
+
const abortFromContext = () => { void release(attempt); };
|
|
68
|
+
context.signal.addEventListener("abort", abortFromContext, { once: true });
|
|
69
|
+
attempt = {
|
|
70
|
+
agentId, controller, timer: setTimeout(() => release(attempt), ATTEMPT_TIMEOUT_MS),
|
|
71
|
+
unsubscribeContext: () => context.signal.removeEventListener("abort", abortFromContext),
|
|
72
|
+
idleObserved: false, syncing: false, active: true,
|
|
73
|
+
};
|
|
74
|
+
attempts.set(agentId, attempt);
|
|
75
|
+
if (context.signal.aborted) {
|
|
76
|
+
await release(attempt);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
const result = await context.paseo.agents.list({ filter: { includeArchived: true, includeBackground: true },
|
|
81
|
+
page: { limit: 1 }, subscribe: {}, signal: controller.signal });
|
|
82
|
+
const subscription = result.subscription;
|
|
83
|
+
if (!subscription) throw new Error("Paseo did not establish the agent directory subscription");
|
|
84
|
+
attempt.subscription = subscription;
|
|
85
|
+
if (!attempt.active) {
|
|
86
|
+
await subscription.release();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
subscription.subscribe({ snapshot: () => {}, update: (message) => update(attempt, message) });
|
|
90
|
+
} catch (error) {
|
|
91
|
+
await release(attempt);
|
|
92
|
+
console.warn(`Keiyaku mirror registration observation unavailable: ${error instanceof Error ? error.message : String(error)}`);
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
providerReady(agentId: string | undefined, session: ObservedSession): void {
|
|
96
|
+
if (!agentId) return;
|
|
97
|
+
const attempt = attempts.get(agentId);
|
|
98
|
+
if (!attempt?.active) return;
|
|
99
|
+
attempt.session = session;
|
|
100
|
+
synchronize(attempt);
|
|
101
|
+
},
|
|
102
|
+
providerClosed(agentId: string | undefined, session: ObservedSession): Promise<void> {
|
|
103
|
+
const attempt = agentId ? attempts.get(agentId) : undefined;
|
|
104
|
+
return attempt?.session === session ? release(attempt) : Promise.resolve();
|
|
105
|
+
},
|
|
106
|
+
closed(agentId: string): Promise<void> {
|
|
107
|
+
const attempt = attempts.get(agentId);
|
|
108
|
+
return attempt ? release(attempt) : Promise.resolve();
|
|
109
|
+
},
|
|
110
|
+
async close(): Promise<void> {
|
|
111
|
+
await Promise.all([...attempts.values()].map(release));
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
@@ -8,14 +8,19 @@ import { createMirror } from "./mirror.js";
|
|
|
8
8
|
import { modelConfig } from "./model.js";
|
|
9
9
|
import type { StopAttempt } from "./stop.js";
|
|
10
10
|
|
|
11
|
+
type RegistrationHandoff = Readonly<{
|
|
12
|
+
providerReady(agentId: string | undefined, session: Readonly<{ observe(reannounce?: boolean): Promise<void> }>): void;
|
|
13
|
+
providerClosed(agentId: string | undefined, session: Readonly<{ observe(reannounce?: boolean): Promise<void> }>): Promise<void> | void;
|
|
14
|
+
}>;
|
|
15
|
+
|
|
11
16
|
const identity = z.object({ world: z.string().min(1), akuId: z.string().regex(/^aku\//u) });
|
|
12
|
-
export function createProvider(transport: AkumaTransport) {
|
|
13
|
-
const sessions = new Set<{ world: string; akuId: string; observe(reannounce?: boolean): Promise<void>; stop(): Promise<void> }>();
|
|
17
|
+
export function createProvider(transport: AkumaTransport, handoff?: RegistrationHandoff) {
|
|
18
|
+
const sessions = new Set<{ agentId: string | undefined; world: string; akuId: string; observe(reannounce?: boolean): Promise<void>; stop(): Promise<void> }>();
|
|
14
19
|
const provider: ProviderRegistration = {
|
|
15
20
|
id: "keiyaku", label: "Keiyaku", description: "Akuma runtime mirror",
|
|
16
21
|
async connect(request): Promise<ProviderConnection> {
|
|
17
22
|
if (!request.versions.includes(1)) throw new Error("Provider protocol version 1 is required");
|
|
18
|
-
const capabilities = negotiateProviderCapabilities(request.capabilities, ["session.persistence", "prompt.message", "prompt.steer"]);
|
|
23
|
+
const capabilities = negotiateProviderCapabilities(request.capabilities, ["session.persistence", "prompt.message", "prompt.steer", "session.can_stop_runtime"]);
|
|
19
24
|
const listeners = new Set<(event: ProviderEvent) => void>();
|
|
20
25
|
const local = new Map<string, { stop(): Promise<void>; stopExecution(requestId: string): Promise<void>; prompt(prompt: ProviderPrompt): Promise<void> }>();
|
|
21
26
|
let closed = false;
|
|
@@ -36,6 +41,7 @@ export function createProvider(transport: AkumaTransport) {
|
|
|
36
41
|
const world = await realpath(target.world);
|
|
37
42
|
const mirror = createMirror(input.sessionId, emit);
|
|
38
43
|
const cancellation = new AbortController();
|
|
44
|
+
const agentId = input.config.env.PASEO_AGENT_ID;
|
|
39
45
|
// The opening window seeds retained state instead of announcing it.
|
|
40
46
|
const skipRetained = input.history === "skip";
|
|
41
47
|
let opening = true;
|
|
@@ -127,7 +133,7 @@ export function createProvider(transport: AkumaTransport) {
|
|
|
127
133
|
return running;
|
|
128
134
|
}
|
|
129
135
|
const session = {
|
|
130
|
-
world, akuId: target.akuId,
|
|
136
|
+
agentId, world, akuId: target.akuId,
|
|
131
137
|
observe,
|
|
132
138
|
async prompt(prompt: ProviderPrompt) {
|
|
133
139
|
const respond = (result: Extract<ProviderEvent, { type: "session.prompt_result" }>["result"]) => emit({
|
|
@@ -180,6 +186,7 @@ export function createProvider(transport: AkumaTransport) {
|
|
|
180
186
|
releaseObservation();
|
|
181
187
|
sessions.delete(session);
|
|
182
188
|
local.delete(input.sessionId);
|
|
189
|
+
await handoff?.providerClosed(agentId, session);
|
|
183
190
|
await Promise.allSettled([...submissions]);
|
|
184
191
|
await stopping;
|
|
185
192
|
await running;
|
|
@@ -228,7 +235,13 @@ export function createProvider(transport: AkumaTransport) {
|
|
|
228
235
|
// Ready names the first observed window, or the explicit report that
|
|
229
236
|
// none could be read. It never waits for the observation to end.
|
|
230
237
|
await session.observe();
|
|
231
|
-
if (!cancellation.signal.aborted)
|
|
238
|
+
if (!cancellation.signal.aborted) {
|
|
239
|
+
handoff?.providerReady(agentId, session);
|
|
240
|
+
emit({ type: "session.ready", requestId: input.requestId, sessionId: input.sessionId });
|
|
241
|
+
}
|
|
242
|
+
} else if (input.type === "session.can_stop_runtime") {
|
|
243
|
+
emit({ type: "session.can_stop_runtime", requestId: input.requestId, sessionId: input.sessionId,
|
|
244
|
+
canStop: !local.has(input.sessionId) });
|
|
232
245
|
} else if (input.type === "session.interrupt" || input.type === "session.close") {
|
|
233
246
|
const session = local.get(input.sessionId);
|
|
234
247
|
if (input.type === "session.close") {
|