@astrosheep/keiyaku 2.9.12 → 2.9.13
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 +22 -18
- package/build/.tsbuildinfo +1 -1
- package/build/agents/call-terms.js +1 -0
- package/build/agents/providers/claude-agent-sdk/adapter.js +2 -2
- package/build/cli/commands/akuma/akuma/handler.js +2 -1
- package/build/cli/commands/akuma/akuma/meta.js +4 -3
- package/build/cli/commands/akuma/catalog.js +2 -0
- package/build/cli/commands/akuma/list/handler.js +1 -1
- package/build/cli/commands/akuma/list/meta-list.js +12 -0
- package/build/cli/commands/akuma/list/meta-ls.js +2 -2
- package/build/cli/commands/akuma.js +5 -0
- package/build/cli/commands/contract/amend/meta.js +4 -3
- package/build/cli/commands/contract/arc/meta.js +2 -0
- package/build/cli/commands/contract/audit/handler.js +28 -2
- package/build/cli/commands/contract/audit/meta.js +4 -3
- package/build/cli/commands/contract/petition/handler.js +2 -1
- package/build/cli/commands/contract/petition/meta.js +2 -2
- package/build/cli/commands/contract/renew/handler.js +44 -3
- package/build/cli/commands/contract/renew/meta.js +5 -4
- package/build/cli/commands/metadata.js +12 -9
- package/build/cli/commands/projection/call/handler.js +1 -1
- package/build/cli/commands/projection/call/meta.js +1 -1
- package/build/cli/commands/projection/catalog.js +2 -2
- package/build/cli/commands/projection/{revive → fork}/handler.js +10 -5
- package/build/cli/commands/projection/fork/meta.js +12 -0
- package/build/cli/commands/projection/history/handler.js +46 -2
- package/build/cli/commands/projection/history/meta.js +3 -3
- package/build/cli/commands/projection/kill/meta.js +2 -2
- package/build/cli/commands/projection/status/handler.js +29 -13
- package/build/cli/commands/projection/status/meta.js +14 -3
- package/build/cli/commands/projection/tell/handler.js +8 -4
- package/build/cli/commands/projection/tell/meta.js +1 -1
- package/build/cli/commands/projection/wait/handler.js +45 -20
- package/build/cli/commands/projection/wait/meta.js +1 -1
- package/build/cli/commands/shared.js +1 -1
- package/build/cli/commands/system/catalog.js +2 -0
- package/build/cli/commands/task/add/handler.js +28 -12
- package/build/cli/commands/task/add/meta.js +18 -6
- package/build/cli/commands/task/catalog.js +2 -0
- package/build/cli/commands/task/compose/handler.js +2 -2
- package/build/cli/commands/task/compose/meta.js +2 -2
- package/build/cli/commands/task/doctor/handler.js +2 -3
- package/build/cli/commands/task/doctor/meta.js +2 -2
- package/build/cli/commands/task/done/meta.js +2 -2
- package/build/cli/commands/task/drop/handler.js +7 -2
- package/build/cli/commands/task/drop/meta.js +6 -3
- package/build/cli/commands/task/hold/meta.js +2 -2
- package/build/cli/commands/task/log/meta.js +2 -2
- package/build/cli/commands/task/ls/meta.js +2 -2
- package/build/cli/commands/task/note/handler.js +6 -0
- package/build/cli/commands/task/note/meta.js +11 -0
- package/build/cli/commands/task/resume/meta.js +2 -2
- package/build/cli/commands/task/shared.js +29 -15
- package/build/cli/commands/task/show/meta.js +2 -2
- package/build/cli/commands/task/start/meta.js +2 -2
- package/build/cli/commands/task/stop/meta.js +2 -2
- package/build/cli/commands/task/update/meta.js +3 -2
- package/build/cli/commands/verification/handler.js +43 -0
- package/build/cli/commands/verification/meta.js +13 -0
- package/build/cli/completion.js +16 -13
- package/build/cli/flags.js +43 -11
- package/build/cli/help.js +29 -30
- package/build/cli/index.js +6 -5
- package/build/cli/parse-flags.js +39 -0
- package/build/cli/parse-metadata.js +5 -2
- package/build/cli/parse-selectors.js +18 -0
- package/build/cli/parse.js +21 -8
- package/build/cli/render/arc.js +12 -3
- package/build/cli/render/audit.js +2 -2
- package/build/cli/render/call.js +4 -4
- package/build/cli/render/kanshi.js +122 -85
- package/build/cli/render/misc.js +2 -2
- package/build/cli/render/petition.js +16 -1
- package/build/cli/render/projection-history.js +17 -4
- package/build/cli/render/shared.js +5 -5
- package/build/cli/render/status-indicator.js +47 -0
- package/build/cli/render/status.js +106 -76
- package/build/cli/render/success-response.js +20 -5
- package/build/cli/render/task.js +6 -5
- package/build/cli/render/tell.js +10 -4
- package/build/cli/render/tool-command-normalization.js +137 -0
- package/build/cli/render/tool-presentation.js +2 -1
- package/build/cli/render/verification.js +23 -0
- package/build/cli/render/wait.js +101 -33
- package/build/cli/types.js +2 -1
- package/build/config/akuma-loader.js +21 -1
- package/build/config/settings/knobs.js +7 -1
- package/build/config/settings/schema.js +10 -5
- package/build/core/amend.js +102 -17
- package/build/core/arc.js +4 -4
- package/build/core/audit/candidate.js +10 -18
- package/build/core/audit/coordinates.js +12 -17
- package/build/core/audit/evidence.js +6 -4
- package/build/core/audit/facade.js +3 -3
- package/build/core/audit/report.js +1 -1
- package/build/core/bind-reconciliation.js +42 -23
- package/build/core/bind.js +182 -81
- package/build/core/call/call.js +6 -7
- package/build/core/call/context.js +43 -30
- package/build/core/call/execution.js +21 -6
- package/build/core/call/prompt.js +11 -42
- package/build/core/contract-carrier-runtime.js +209 -105
- package/build/core/contract-carrier.js +156 -73
- package/build/core/contract-view.js +42 -5
- package/build/core/contract.js +2 -1
- package/build/core/derived-replay.js +168 -35
- package/build/core/draft.js +9 -5
- package/build/core/forfeit.js +1 -1
- package/build/core/lifecycle-history.js +13 -0
- package/build/core/lifecycle-recovery.js +32 -27
- package/build/core/lifecycle-runner.js +14 -14
- package/build/core/log.js +1 -1
- package/build/core/outcome-base.js +2 -2
- package/build/core/projection/akuma-name.js +43 -0
- package/build/core/projection/generation/database.js +141 -79
- package/build/core/projection/generation/ledger.js +91 -0
- package/build/core/projection/generation/model.js +18 -13
- package/build/core/projection/generation/projection-generation-continuation.js +1 -1
- package/build/core/projection/generation/projection-generation-doorbell.js +88 -0
- package/build/core/projection/generation/projection-generation-execution.js +24 -0
- package/build/core/projection/generation/projection-generation-identity.js +4 -0
- package/build/core/projection/generation/projection-generation-launcher.js +72 -138
- package/build/core/projection/generation/projection-generation-process.js +16 -15
- package/build/core/projection/generation/projection-generation-runner.js +125 -79
- package/build/core/projection/generation/projection-generation-runtime.js +10 -61
- package/build/core/projection/generation/protocol.js +68 -0
- package/build/core/projection/generation/store.js +17 -7
- package/build/core/projection/generation/transitions.js +14 -14
- package/build/core/projection/index.js +5 -5
- package/build/core/projection/projection-core.js +6 -2
- package/build/core/projection/projection-execution-observer.js +1 -1
- package/build/core/projection/projection-history.js +7 -7
- package/build/core/projection/projection-kill.js +15 -6
- package/build/core/projection/projection-life-observer.js +8 -8
- package/build/core/projection/projection-mint.js +6 -8
- package/build/core/projection/projection-status-observation.js +77 -8
- package/build/core/projection/projection-status.js +151 -4
- package/build/core/projection/projection-wait.js +46 -27
- package/build/core/projection/projection-wake.js +27 -89
- package/build/core/projection/tell/launch-store.js +1 -1
- package/build/core/projection/tell/store.js +1 -1
- package/build/core/renew-build.js +204 -74
- package/build/core/renew-plan.js +34 -9
- package/build/core/renew-rewrite.js +56 -15
- package/build/core/renew.js +39 -35
- package/build/core/repository-ledger/accepted-fold-read.js +6 -3
- package/build/core/repository-ledger/codec.js +11 -5
- package/build/core/repository-ledger/current-state-store.js +13 -16
- package/build/core/repository-ledger/fold-repository.js +5 -6
- package/build/core/repository-ledger/identity.js +60 -0
- package/build/core/repository-ledger/inventory.js +3 -3
- package/build/core/repository-ledger/read-model.js +54 -6
- package/build/core/repository-ledger/write-transaction.js +9 -4
- package/build/core/run-control/connection-bound-close.js +41 -0
- package/build/core/run-control/detached-lease-bootstrap.js +208 -0
- package/build/core/run-control/detached-process.js +14 -0
- package/build/core/run-control/index.js +6 -0
- package/build/core/{process-group.js → run-control/process-tree.js} +1 -1
- package/build/core/run-control/runner-lease.js +172 -0
- package/build/core/{sqlite-process-lifetime-lock.js → run-control/sqlite-process-lifetime-lock.js} +4 -24
- package/build/core/seal.js +44 -32
- package/build/core/settlement/claim-delivery.js +22 -9
- package/build/core/settlement/claim.js +8 -6
- package/build/core/settlement/petition-claim-gates.js +9 -8
- package/build/core/settlement/petition-head-guard.js +5 -6
- package/build/core/settlement/petition-preview.js +21 -5
- package/build/core/settlement/petition.js +51 -17
- package/build/core/settlement/settlement.js +20 -15
- package/build/core/settlement/verdict.js +2 -2
- package/build/core/settlement/verification.js +492 -364
- package/build/core/status/board.js +184 -75
- package/build/core/status/drift.js +8 -10
- package/build/core/task/board.js +1 -0
- package/build/core/task/commands.js +25 -0
- package/build/core/task/compose.js +3 -2
- package/build/core/task/document.js +102 -39
- package/build/core/task/index.js +3 -3
- package/build/core/task/settlement-git.js +1 -4
- package/build/core/task/settlement-policy.js +27 -14
- package/build/core/task/source-board.js +1 -0
- package/build/core/task/task-bind-preparation.js +59 -9
- package/build/core/task/task-contract.js +2 -2
- package/build/core/task/task-store-repository.js +1 -0
- package/build/core/task/task.js +2 -2
- package/build/core/transcripts.js +4 -4
- package/build/core/verification-declaration.js +95 -0
- package/build/core/worktree-bootstrap.js +1 -1
- package/build/core/worktree-path.js +7 -11
- package/build/flow-error.js +9 -1
- package/build/generated/version.js +2 -2
- package/build/git/branches.js +41 -70
- package/build/git/commits.js +92 -21
- package/build/git/core.js +9 -161
- package/build/git/diff/preview.js +4 -4
- package/build/git/diff/read.js +4 -4
- package/build/git/diff/structured.js +5 -5
- package/build/git/process.js +229 -0
- package/build/git/refs.js +30 -5
- package/build/git/staging.js +39 -115
- package/build/git/streaming-batch.js +9 -16
- package/build/git/worktree.js +104 -91
- package/build/index.js +7 -0
- package/package.json +1 -1
- package/skills/keiyaku-akuma/SKILL.md +21 -20
- package/skills/keiyaku-task/SKILL.md +38 -4
- package/skills/keiyaku-workflow/SKILL.md +51 -11
- package/build/cli/commands/projection/revive/meta.js +0 -12
- package/build/core/projection/projection-life-protocol.js +0 -115
- package/build/core/projection/projection-runner-lock.js +0 -211
- package/build/core/projection/tell/database.js +0 -127
- package/build/core/settlement/verification-coordination.js +0 -305
- package/build/core/settlement/verification-supervisor.js +0 -275
|
@@ -2,15 +2,24 @@ import { buildCallTerms } from "../../agents/call-terms.js";
|
|
|
2
2
|
import { createAbortError, restoreOutcome, SubagentFailure, } from "../../agents/harness/index.js";
|
|
3
3
|
import { resolveAkumaLaunchSnapshot } from "../../agents/launch-snapshot/resolve.js";
|
|
4
4
|
import { selectSubagent } from "../../agents/selector.js";
|
|
5
|
+
import { assertSettingsKnobUsable } from "../../config/settings/disease.js";
|
|
6
|
+
import { loadKeiyakuSettings } from "../../config/settings/loader.js";
|
|
7
|
+
import { resolveProjectionAdoptionTimeoutMs } from "../../config/settings/knobs.js";
|
|
5
8
|
import { FlowError } from "../../flow-error.js";
|
|
6
9
|
import { assertProjectionAlias, moveProjectionAlias } from "../projection/index.js";
|
|
7
10
|
import { projectionDir } from "../projection/index.js";
|
|
8
|
-
import { createProjectionExecutionId } from "../projection/index.js";
|
|
9
|
-
import {
|
|
10
|
-
import { openProjectionGenerationStore, openProjectionGenerationStoreReadOnly,
|
|
11
|
+
import { createProjectionExecutionId, projectionRunnerLeasePath } from "../projection/index.js";
|
|
12
|
+
import { startProjectionGeneration } from "../projection/index.js";
|
|
13
|
+
import { openProjectionGenerationStore, openProjectionGenerationStoreReadOnly, } from "../projection/index.js";
|
|
14
|
+
import { acquireRunnerLease } from "../run-control/runner-lease.js";
|
|
11
15
|
import { observeProjectionLife } from "../projection/index.js";
|
|
12
16
|
import { mintProjection, mintRepositoryProjection } from "../projection/index.js";
|
|
13
17
|
import { waitForProjection } from "../projection/index.js";
|
|
18
|
+
async function readProjectionAdoptionTimeoutMs(cwd) {
|
|
19
|
+
const settings = await loadKeiyakuSettings(cwd);
|
|
20
|
+
assertSettingsKnobUsable(settings, "projectionAdoptionTimeoutMs");
|
|
21
|
+
return resolveProjectionAdoptionTimeoutMs(settings.knobs);
|
|
22
|
+
}
|
|
14
23
|
export function readCurrentGenerationOrThrow(projectionDirectory) {
|
|
15
24
|
const store = openProjectionGenerationStoreReadOnly(projectionDirectory);
|
|
16
25
|
try {
|
|
@@ -60,11 +69,12 @@ export function outcomeFromGeneration(current) {
|
|
|
60
69
|
return restoreOutcome(record);
|
|
61
70
|
}
|
|
62
71
|
export async function executeSubagent(agentName, prompt, cwd, options) {
|
|
72
|
+
const adoptionTimeoutMs = await readProjectionAdoptionTimeoutMs(cwd);
|
|
63
73
|
const { projection: projectionCoordinate, launchSnapshot, launchFacts } = await buildCallConfig(agentName, prompt, cwd, options);
|
|
64
74
|
if (!projectionCoordinate) {
|
|
65
75
|
throw new FlowError("INTERNAL_STATE", "durable execution requires a projection coordinate");
|
|
66
76
|
}
|
|
67
|
-
const launchOwnership =
|
|
77
|
+
const launchOwnership = acquireRunnerLease(projectionRunnerLeasePath(projectionCoordinate.dir));
|
|
68
78
|
const launched = await startProjectionGeneration(projectionCoordinate.dir, projectionCoordinate.executionId, {
|
|
69
79
|
commitLaunch: () => {
|
|
70
80
|
const store = openProjectionGenerationStore(projectionCoordinate.dir);
|
|
@@ -76,6 +86,7 @@ export async function executeSubagent(agentName, prompt, cwd, options) {
|
|
|
76
86
|
}
|
|
77
87
|
},
|
|
78
88
|
launchOwnership,
|
|
89
|
+
adoptionTimeoutMs,
|
|
79
90
|
});
|
|
80
91
|
launchOwnership.close();
|
|
81
92
|
if (launched.status !== "adopted") {
|
|
@@ -127,11 +138,12 @@ export async function executeSubagent(agentName, prompt, cwd, options) {
|
|
|
127
138
|
throw new FlowError("INTERNAL_STATE", "Unhandled subagent outcome state.");
|
|
128
139
|
}
|
|
129
140
|
export async function launchSubagentGeneration(agentName, prompt, cwd, options) {
|
|
141
|
+
const adoptionTimeoutMs = await readProjectionAdoptionTimeoutMs(cwd);
|
|
130
142
|
const { projection, launchSnapshot, launchFacts } = await buildCallConfig(agentName, prompt, cwd, options);
|
|
131
143
|
if (!projection) {
|
|
132
144
|
throw new FlowError("INTERNAL_STATE", "durable launch requires a projection coordinate");
|
|
133
145
|
}
|
|
134
|
-
const launchOwnership =
|
|
146
|
+
const launchOwnership = acquireRunnerLease(projectionRunnerLeasePath(projection.dir));
|
|
135
147
|
const launched = await startProjectionGeneration(projection.dir, projection.executionId, {
|
|
136
148
|
commitLaunch: () => {
|
|
137
149
|
const store = openProjectionGenerationStore(projection.dir);
|
|
@@ -143,6 +155,7 @@ export async function launchSubagentGeneration(agentName, prompt, cwd, options)
|
|
|
143
155
|
}
|
|
144
156
|
},
|
|
145
157
|
launchOwnership,
|
|
158
|
+
adoptionTimeoutMs,
|
|
146
159
|
});
|
|
147
160
|
launchOwnership.close();
|
|
148
161
|
if (launched.status !== "adopted") {
|
|
@@ -162,6 +175,7 @@ export async function buildCallConfig(agentName, prompt, cwd, options) {
|
|
|
162
175
|
const resolvedTerms = buildCallTerms(launchSnapshot, prompt, cwd, {
|
|
163
176
|
signal: options.signal,
|
|
164
177
|
idleTimeoutMs: options.idleTimeoutMs,
|
|
178
|
+
carrier: options.carrier,
|
|
165
179
|
});
|
|
166
180
|
// Mint projection directory for supervisor pump.
|
|
167
181
|
const slug = launchSnapshot.akuma.name;
|
|
@@ -196,6 +210,7 @@ export async function buildCallConfig(agentName, prompt, cwd, options) {
|
|
|
196
210
|
...(options.evidenceCwd !== undefined ? { evidenceCwd: options.evidenceCwd } : {}),
|
|
197
211
|
...(options.title !== undefined ? { title: options.title } : {}),
|
|
198
212
|
...(options.context !== undefined ? { context: options.context } : {}),
|
|
213
|
+
...(options.carrier !== undefined ? { carrier: options.carrier } : {}),
|
|
199
214
|
persistProjectionResponse: options.persistProjectionResponse ?? false,
|
|
200
215
|
...(options.continuation ? {
|
|
201
216
|
session: options.continuation.session,
|
|
@@ -210,7 +225,7 @@ export async function buildCallConfig(agentName, prompt, cwd, options) {
|
|
|
210
225
|
let previousAliasTargetStillRunning;
|
|
211
226
|
if (previousAliasTarget !== undefined) {
|
|
212
227
|
try {
|
|
213
|
-
const phase = observeProjectionLife(await projectionDir(options.projectionCwd ?? cwd, previousAliasTarget), { nowMs: Date.now()
|
|
228
|
+
const phase = observeProjectionLife(await projectionDir(options.projectionCwd ?? cwd, previousAliasTarget), { nowMs: Date.now() }).phase;
|
|
214
229
|
if (phase === "minting" || phase === "active" || phase === "quiescent") {
|
|
215
230
|
previousAliasTargetStillRunning = previousAliasTarget;
|
|
216
231
|
}
|
|
@@ -7,52 +7,21 @@ const COMMISSIONED_DELIVERY_BOUNDARY = [
|
|
|
7
7
|
].join(" ");
|
|
8
8
|
export function buildCallPrompt(input) {
|
|
9
9
|
const references = [...new Set((input.referenceFiles ?? []).map((file) => file.trim()).filter(Boolean))];
|
|
10
|
-
if (input.
|
|
11
|
-
const arc = input.currentIntent;
|
|
10
|
+
if (!input.commissioned) {
|
|
12
11
|
return [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
`Title: ${arc.title}`,
|
|
16
|
-
`Objective: ${arc.objective}`,
|
|
17
|
-
`Brief:\n${arc.brief}`,
|
|
18
|
-
COMMISSIONED_DELIVERY_BOUNDARY,
|
|
19
|
-
"",
|
|
20
|
-
`Task:\n${input.task}`,
|
|
21
|
-
`Context:\n${input.context?.trim() || "(none provided)"}`,
|
|
12
|
+
input.task,
|
|
13
|
+
input.context?.trim() ?? "",
|
|
22
14
|
references.length > 0 ? `Reference files:\n${references.map((file) => `- ${file}`).join("\n")}` : "",
|
|
23
|
-
"Provide the final result for the caller/main agent.",
|
|
24
|
-
].filter(Boolean).join("\n\n");
|
|
25
|
-
}
|
|
26
|
-
if (input.currentIntent?.source === "bind") {
|
|
27
|
-
const bind = input.currentIntent;
|
|
28
|
-
const trimmedContext = input.context?.trim() ?? "";
|
|
29
|
-
const extensionsBlock = bind.extensions.length > 0
|
|
30
|
-
? `Extensions:\n${bind.extensions.map((extension) => `## ${extension.title}\n${extension.content}`).join("\n\n")}`
|
|
31
|
-
: "";
|
|
32
|
-
return [
|
|
33
|
-
`You are a called ${ACTOR_IDENTITY} working inside derived default arc a0.`,
|
|
34
|
-
"Stay within the contract scope and do the requested work directly.",
|
|
35
|
-
`Contract: ${bind.title}`,
|
|
36
|
-
`Context:\n${bind.context}`,
|
|
37
|
-
`Objective:\n${bind.objective}`,
|
|
38
|
-
`Design & Approach:\n${bind.design}`,
|
|
39
|
-
`Scope:\n${bind.scope.map((value) => `- ${value}`).join("\n")}`,
|
|
40
|
-
`Criteria:\n${bind.criteria.map((value) => `- ${value}`).join("\n")}`,
|
|
41
|
-
`Verification:\n${bind.verification.map((value) => `- ${value}`).join("\n")}`,
|
|
42
|
-
extensionsBlock,
|
|
43
|
-
COMMISSIONED_DELIVERY_BOUNDARY,
|
|
44
|
-
`Task:\n${input.task}`,
|
|
45
|
-
trimmedContext ? `Context:\n${trimmedContext}` : "",
|
|
46
|
-
references.length > 0 ? `Reference files:\n${references.map((file) => `- ${file}`).join("\n")}` : "",
|
|
47
|
-
"Provide the final result for the caller/main agent.",
|
|
48
15
|
].filter(Boolean).join("\n\n");
|
|
49
16
|
}
|
|
50
17
|
return [
|
|
51
|
-
|
|
52
|
-
input.
|
|
53
|
-
|
|
18
|
+
`You are a called ${ACTOR_IDENTITY} working in the commissioned contract worktree.`,
|
|
19
|
+
input.worktree ? `Worktree: ${input.worktree}` : "",
|
|
20
|
+
"Before work, read .keiyaku/KEIYAKU.md. It is the sole contract body for this dispatch.",
|
|
21
|
+
COMMISSIONED_DELIVERY_BOUNDARY,
|
|
22
|
+
`Task:\n${input.task}`,
|
|
23
|
+
input.context?.trim() ? `Context:\n${input.context.trim()}` : "",
|
|
54
24
|
references.length > 0 ? `Reference files:\n${references.map((file) => `- ${file}`).join("\n")}` : "",
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
.join("\n\n");
|
|
25
|
+
"Provide the final result for the caller/main agent.",
|
|
26
|
+
].filter(Boolean).join("\n\n");
|
|
58
27
|
}
|