@astrosheep/keiyaku 2.9.2 → 2.9.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/build/.tsbuildinfo +1 -1
- package/build/agents/call-terms.js +13 -94
- package/build/agents/harness/activity-values.js +16 -0
- package/build/agents/harness/event-persistence.js +218 -0
- package/build/agents/harness/execution-handle.js +25 -222
- package/build/agents/harness/index.js +3 -1
- package/build/agents/harness/outcome.js +47 -4
- package/build/agents/harness/projection.js +42 -59
- package/build/agents/harness/provider-adapter.js +58 -0
- package/build/agents/harness/router.js +11 -187
- package/build/agents/harness/runtime.js +17 -4
- package/build/agents/harness/session.js +15 -0
- package/build/agents/launch-snapshot/model.js +15 -236
- package/build/agents/launch-snapshot/parse-helpers.js +114 -0
- package/build/agents/launch-snapshot/resolve.js +17 -43
- package/build/agents/opencode-sdk.js +45 -12
- package/build/agents/providers/claude-agent-sdk/adapter.js +6 -17
- package/build/agents/providers/claude-agent-sdk/registration.js +214 -0
- package/build/agents/providers/claude-agent-sdk/session-schema.js +2 -0
- package/build/agents/providers/codex-app-server/adapter.js +50 -53
- package/build/agents/providers/codex-app-server/events.js +67 -11
- package/build/agents/providers/codex-app-server/identity.js +1 -0
- package/build/agents/providers/codex-app-server/policy.js +29 -0
- package/build/agents/providers/codex-app-server/registration.js +248 -0
- package/build/agents/providers/codex-app-server/session-schema.js +6 -0
- package/build/agents/providers/codex-app-server/session.js +23 -17
- package/build/agents/providers/codex-app-server/terms.js +1 -0
- package/build/agents/providers/opencode-sdk/adapter.js +94 -50
- package/build/agents/providers/opencode-sdk/events.js +8 -4
- package/build/agents/providers/opencode-sdk/registration.js +135 -0
- package/build/agents/providers/opencode-sdk/session-schema.js +2 -0
- package/build/agents/providers/opencode-sdk/session.js +21 -14
- package/build/agents/providers/opencode-sdk/terms.js +1 -0
- package/build/agents/providers/pi/adapter.js +36 -30
- package/build/agents/providers/pi/registration.js +145 -0
- package/build/agents/providers/pi/session-schema.js +6 -0
- package/build/agents/providers/pi/terms.js +1 -0
- package/build/agents/providers/registration.js +7 -0
- package/build/agents/providers/registry.js +76 -0
- package/build/agents/selector.js +2 -29
- package/build/agents/types.js +8 -0
- package/build/artifact-directories.js +22 -0
- package/build/cli/commands/akuma/akuma/handler.js +1 -1
- package/build/cli/commands/akuma/view/handler.js +5 -4
- package/build/cli/commands/akuma.js +6 -0
- package/build/cli/commands/contract/amend/handler.js +8 -2
- package/build/cli/commands/contract/arc/handler.js +7 -1
- package/build/cli/commands/contract/bind/handler.js +4 -3
- package/build/cli/commands/contract/bind/meta.js +34 -7
- package/build/cli/commands/contract/forfeit/handler.js +4 -4
- package/build/cli/commands/contract/log/handler.js +3 -3
- package/build/cli/commands/contract/petition/handler.js +4 -6
- package/build/cli/commands/contract/renew/handler.js +20 -6
- package/build/cli/commands/contract/renew/meta.js +5 -4
- package/build/cli/commands/metadata.js +58 -0
- package/build/cli/commands/projection/call/handler.js +6 -5
- package/build/cli/commands/projection/kill/handler.js +16 -32
- package/build/cli/commands/projection/shared.js +28 -0
- package/build/cli/commands/projection/status/handler.js +1 -1
- package/build/cli/commands/projection/tell/handler.js +14 -30
- package/build/cli/commands/projection/wait/handler.js +45 -22
- package/build/cli/commands/projection/wait/meta.js +7 -2
- package/build/cli/commands/registry.js +2 -54
- package/build/cli/commands/shared.js +10 -7
- package/build/cli/commands/skills/install/handler.js +2 -5
- package/build/cli/commands/skills/skills/handler.js +1 -1
- package/build/cli/commands/task/add/handler.js +5 -13
- package/build/cli/commands/task/catalog.js +2 -2
- package/build/cli/commands/task/done/handler.js +4 -8
- package/build/cli/commands/task/drop/handler.js +3 -6
- package/build/cli/commands/task/ls/handler.js +3 -5
- package/build/cli/commands/task/shared.js +14 -4
- package/build/cli/commands/task/{view → show}/handler.js +7 -8
- package/build/cli/commands/task/show/meta.js +8 -0
- package/build/cli/commands/task/start/handler.js +3 -6
- package/build/cli/commands/task/stop/handler.js +4 -8
- package/build/cli/commands/task/task/handler.js +1 -1
- package/build/cli/commands/task/update/handler.js +4 -8
- package/build/cli/completion.js +1 -1
- package/build/cli/flags.js +19 -3
- package/build/cli/help.js +4 -11
- package/build/cli/index.js +57 -83
- package/build/cli/missing-subcommand.js +7 -0
- package/build/cli/parse-flags.js +14 -5
- package/build/cli/parse-metadata.js +3 -3
- package/build/cli/parse-selectors.js +1 -1
- package/build/cli/parse.js +21 -0
- package/build/cli/projection-address.js +7 -12
- package/build/cli/render/address.js +41 -37
- package/build/cli/render/arc.js +24 -12
- package/build/cli/render/call.js +11 -5
- package/build/cli/render/errors.js +36 -1
- package/build/cli/render/format.js +4 -0
- package/build/cli/render/kanshi.js +6 -12
- package/build/cli/render/kill.js +9 -0
- package/build/cli/render/misc.js +55 -12
- package/build/cli/render/petition.js +20 -15
- package/build/cli/render/projection-activity.js +3 -0
- package/build/cli/render/shared.js +60 -21
- package/build/cli/render/skills.js +10 -0
- package/build/cli/render/status.js +37 -14
- package/build/cli/render/success-response.js +77 -0
- package/build/cli/render/task.js +54 -14
- package/build/cli/render/tell.js +5 -0
- package/build/cli/render/terminal-failure.js +58 -0
- package/build/cli/render/types.js +1 -0
- package/build/cli/render/wait.js +38 -36
- package/build/cli/types.js +1 -1
- package/build/config/akuma-loader.js +0 -5
- package/build/config/env-keys.js +1 -1
- package/build/config/provider-policy-ownership.js +3 -32
- package/build/config/settings/disease.js +8 -1
- package/build/config/settings/loader.js +11 -3
- package/build/config/settings/provider-instance-fields.js +51 -0
- package/build/config/settings/schema.js +6 -176
- package/build/core/addressing.js +66 -16
- package/build/core/amend.js +135 -18
- package/build/core/arc.js +19 -67
- package/build/core/bind.js +82 -35
- package/build/core/call/call.js +15 -9
- package/build/core/call/context.js +6 -51
- package/build/core/call/execution.js +21 -22
- package/build/core/call/prompt.js +14 -1
- package/build/core/command-markdown.js +45 -0
- package/build/core/context.js +13 -7
- package/build/core/contract-view.js +20 -3
- package/build/core/draft.js +123 -16
- package/build/core/forfeit.js +5 -2
- package/build/core/hints.js +1 -75
- package/build/core/identifier-slug.js +66 -0
- package/build/core/ids.js +25 -11
- package/build/core/ledger.js +20 -68
- package/build/core/markdown/parser.js +0 -68
- package/build/core/markdown/render.js +68 -0
- package/build/core/markdown/sections.js +2 -1
- package/build/core/outcome-base.js +4 -0
- package/build/core/projection/generation/database.js +2 -38
- package/build/core/projection/generation/model.js +42 -1
- package/build/core/{projection-generation-continuation.js → projection/generation/projection-generation-continuation.js} +3 -3
- package/build/core/{projection-generation-execution.js → projection/generation/projection-generation-execution.js} +19 -49
- package/build/core/{projection-generation-identity.js → projection/generation/projection-generation-identity.js} +2 -2
- package/build/core/{projection-generation-launcher.js → projection/generation/projection-generation-launcher.js} +5 -3
- package/build/core/{projection-generation-process.js → projection/generation/projection-generation-process.js} +2 -1
- package/build/core/{projection-generation-runner.js → projection/generation/projection-generation-runner.js} +18 -3
- package/build/core/projection/generation/store.js +2 -2
- package/build/core/projection/generation/transitions.js +1 -1
- package/build/core/projection/index.js +27 -0
- package/build/core/{projection-activity.js → projection/projection-activity.js} +12 -0
- package/build/core/{projection-alias.js → projection/projection-alias.js} +14 -19
- package/build/core/projection/projection-coordinate.js +61 -0
- package/build/core/{projection-core.js → projection/projection-core.js} +9 -9
- package/build/core/{projection-execution-observer.js → projection/projection-execution-observer.js} +2 -57
- package/build/core/{projection-identity.js → projection/projection-identity.js} +1 -1
- package/build/core/{projection-kill.js → projection/projection-kill.js} +1 -1
- package/build/core/{projection-life-observer.js → projection/projection-life-observer.js} +1 -1
- package/build/core/{projection-mint.js → projection/projection-mint.js} +10 -10
- package/build/core/{projection-status.js → projection/projection-status.js} +98 -25
- package/build/core/projection/projection-terminal-failure.js +104 -0
- package/build/core/projection/projection-wait.js +278 -0
- package/build/core/projection/projection-wake.js +203 -0
- package/build/core/provider-loader-ports.js +4 -0
- package/build/core/ref-log.js +65 -40
- package/build/core/registry.js +63 -10
- package/build/core/renew-session.js +128 -0
- package/build/core/renew.js +426 -99
- package/build/core/scope.js +143 -66
- package/build/core/seal.js +139 -35
- package/build/core/{claim-delivery.js → settlement/claim-delivery.js} +9 -14
- package/build/core/{claim.js → settlement/claim.js} +32 -8
- package/build/core/settlement/index.js +19 -0
- package/build/core/{petition-claim-gates.js → settlement/petition-claim-gates.js} +22 -18
- package/build/core/{petition-forfeit.js → settlement/petition-forfeit.js} +2 -2
- package/build/core/{petition-head-guard.js → settlement/petition-head-guard.js} +2 -2
- package/build/core/settlement/petition-io.js +1 -0
- package/build/core/{petition-preview.js → settlement/petition-preview.js} +1 -1
- package/build/core/{petition.js → settlement/petition.js} +12 -10
- package/build/core/settlement/queue-read-model.js +143 -0
- package/build/core/settlement/queue-seat-allocation.js +156 -0
- package/build/core/settlement/queue.js +6 -0
- package/build/core/settlement/settlement.js +295 -0
- package/build/core/{verdict.js → settlement/verdict.js} +9 -37
- package/build/core/status/board.js +24 -23
- package/build/core/status/ledger-batch.js +158 -0
- package/build/core/status/reconciliation.js +10 -4
- package/build/core/stored-agent-event.js +3 -0
- package/build/core/task/board.js +40 -4
- package/build/core/task/commands.js +30 -21
- package/build/core/task/index.js +12 -0
- package/build/core/task/settlement-git.js +157 -65
- package/build/core/task/settlement-policy.js +54 -24
- package/build/core/task/task-contract.js +370 -0
- package/build/core/{task-doctor.js → task/task-doctor.js} +1 -1
- package/build/core/{task-git-actor.js → task/task-git-actor.js} +5 -10
- package/build/core/{task-git-runtime.js → task/task-git-runtime.js} +3 -3
- package/build/core/{task-git-store.js → task/task-git-store.js} +92 -29
- package/build/core/task/task-repository.js +1 -0
- package/build/core/{task-store-repository.js → task/task-store-repository.js} +5 -4
- package/build/core/task/task-store.js +1 -0
- package/build/core/{task-worktree.js → task/task-worktree.js} +2 -1
- package/build/core/task/task.js +5 -0
- package/build/core/task/tree.js +37 -0
- package/build/core/task/validation.js +5 -2
- package/build/core/transcripts.js +15 -3
- package/build/core/worktree-path.js +43 -28
- package/build/flow-error.js +85 -39
- package/build/fs/durability.js +27 -0
- package/build/fs/path-coordinate.js +16 -0
- package/build/generated/version.js +3 -2
- package/build/git/branches.js +2 -1
- package/build/git/core.js +106 -2
- package/build/git/path-coordinate.js +17 -0
- package/build/git/refs.js +57 -0
- package/build/git/streaming-batch.js +301 -0
- package/build/git/worktree.js +65 -0
- package/build/index.js +3 -3
- package/build/keiyaku.js +2 -36
- package/package.json +4 -10
- package/skills/keiyaku/SKILL.md +3 -2
- package/skills/keiyaku-akuma/SKILL.md +10 -6
- package/skills/keiyaku-task/SKILL.md +1 -1
- package/skills/keiyaku-workflow/SKILL.md +25 -4
- package/build/agents/providers/codex-sdk.js +0 -329
- package/build/cli/commands/task/view/meta.js +0 -8
- package/build/core/command-io.js +0 -174
- package/build/core/path-coordinate.js +0 -27
- package/build/core/petition-claim.js +0 -117
- package/build/core/petition-run.js +0 -83
- package/build/core/projection-coordinate.js +0 -63
- package/build/core/projection-wait.js +0 -165
- package/build/core/projection-wake.js +0 -136
- package/build/core/queue.js +0 -343
- package/build/core/task-contract.js +0 -237
- package/build/core/task.js +0 -4
- /package/build/{core/task-repository.js → agents/launch-snapshot/types.js} +0 -0
- /package/build/{core/task-store.js → agents/providers/claude-agent-sdk/terms.js} +0 -0
- /package/build/core/{projection-generation-runtime.js → projection/generation/projection-generation-runtime.js} +0 -0
- /package/build/core/{projection-life-protocol.js → projection/projection-life-protocol.js} +0 -0
- /package/build/core/{projection-runner-lock.js → projection/projection-runner-lock.js} +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
export const KEIYAKU_DRAFT_DIR = path.join(".keiyaku", "draft");
|
|
3
|
+
export const RESPONSE_HISTORY_DIR = path.join(".keiyaku", "response");
|
|
4
|
+
export const KEIYAKU_ARTIFACT_DIRS = [KEIYAKU_DRAFT_DIR, RESPONSE_HISTORY_DIR];
|
|
5
|
+
function formatArtifactDirectory(directory) {
|
|
6
|
+
return `\`${directory}/\``;
|
|
7
|
+
}
|
|
8
|
+
export function formatArtifactDirectories(directories) {
|
|
9
|
+
const formatted = directories.map(formatArtifactDirectory);
|
|
10
|
+
if (formatted.length === 0)
|
|
11
|
+
return "";
|
|
12
|
+
if (formatted.length === 1)
|
|
13
|
+
return formatted[0];
|
|
14
|
+
if (formatted.length === 2)
|
|
15
|
+
return `${formatted[0]} and ${formatted[1]}`;
|
|
16
|
+
return `${formatted.slice(0, -1).join(", ")}, and ${formatted[formatted.length - 1]}`;
|
|
17
|
+
}
|
|
18
|
+
function buildArtifactNotice(directory) {
|
|
19
|
+
return `Auto-generated artifact. Add ${formatArtifactDirectory(directory)} to \`.gitignore\` if you do not want it tracked.`;
|
|
20
|
+
}
|
|
21
|
+
export const DRAFT_ARTIFACT_NOTICE = buildArtifactNotice(KEIYAKU_ARTIFACT_DIRS[0]);
|
|
22
|
+
export const RESPONSE_ARTIFACT_NOTICE = buildArtifactNotice(KEIYAKU_ARTIFACT_DIRS[1]);
|
|
@@ -2,12 +2,12 @@ import { FlowError } from "../../../../flow-error.js";
|
|
|
2
2
|
import { assertSettingsKnobUsable } from "../../../../config/settings/disease.js";
|
|
3
3
|
import { loadKeiyakuSettings } from "../../../../config/settings/loader.js";
|
|
4
4
|
import { loadAkumaCatalog } from "../../../../config/akuma-loader.js";
|
|
5
|
-
import { readProjectionStatusBoard } from "../../../../core/projection
|
|
5
|
+
import { readProjectionStatusBoard } from "../../../../core/projection/index.js";
|
|
6
6
|
import { isResponseArtifactId } from "../../../../core/response-artifact-id.js";
|
|
7
7
|
import { textResponse } from "../../../render/shared.js";
|
|
8
8
|
import { renderProjectionStatusSection } from "../../../render/status.js";
|
|
9
9
|
import { projectDirectory } from "../../shared.js";
|
|
10
|
-
import { renderAkumaShow } from "../../akuma.js";
|
|
10
|
+
import { renderAkumaShow, renderAkumaView } from "../../akuma.js";
|
|
11
11
|
const NONTERMINAL_PROJECTION_STATES = new Set([
|
|
12
12
|
"minting",
|
|
13
13
|
"startup-timeout",
|
|
@@ -28,7 +28,8 @@ export const handler = async (_stdin, flags, _signal, positional) => {
|
|
|
28
28
|
assertSettingsKnobUsable(loaded, "default");
|
|
29
29
|
assertSettingsKnobUsable(loaded, "reviewer");
|
|
30
30
|
const profile = renderAkumaShow(await loadAkumaCatalog(cwd), loaded.providerInstances, loaded.knobs, name).trimEnd();
|
|
31
|
-
const
|
|
31
|
+
const projectionStatus = await readProjectionStatusBoard(cwd, Date.now(), { showAll: true });
|
|
32
|
+
const rows = (projectionStatus?.rows ?? []).filter((row) => row.akuma === name && NONTERMINAL_PROJECTION_STATES.has(row.state));
|
|
32
33
|
const projections = renderProjectionStatusSection({ rows }).trimEnd();
|
|
33
|
-
return textResponse(
|
|
34
|
+
return textResponse(renderAkumaView(profile, projections));
|
|
34
35
|
};
|
|
@@ -140,6 +140,12 @@ export function renderAkumaList(catalog, providerInstances, settings) {
|
|
|
140
140
|
}
|
|
141
141
|
return lines.join("\n");
|
|
142
142
|
}
|
|
143
|
+
/** Compose profile inspection with an optional nonterminal projection section. */
|
|
144
|
+
export function renderAkumaView(profile, projectionsSection) {
|
|
145
|
+
return projectionsSection ? `${profile}
|
|
146
|
+
|
|
147
|
+
${projectionsSection}` : profile;
|
|
148
|
+
}
|
|
143
149
|
export function renderAkumaShow(catalog, providerInstances, settings, name) {
|
|
144
150
|
const candidate = catalog.selected[name];
|
|
145
151
|
if (candidate === undefined) {
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { amendKeiyaku } from "../../../../core/amend.js";
|
|
2
|
-
import {
|
|
2
|
+
import { resolveExistingContractAddress } from "../../../../core/addressing.js";
|
|
3
|
+
import { buildAmendInput } from "../../../../core/amend.js";
|
|
3
4
|
import { buildAmendResponse } from "../../../render/arc.js";
|
|
4
5
|
import { renderCoreResult } from "../../../render/shared.js";
|
|
5
6
|
import { effectiveDirectory, repositoryDirectory } from "../../shared.js";
|
|
6
7
|
export const handler = async (stdin, flags) => {
|
|
7
8
|
const parsed = buildAmendInput(stdin, effectiveDirectory(flags), flags.contractId, flags.contractAddressSource);
|
|
8
9
|
const cwd = await repositoryDirectory(flags, "amend");
|
|
9
|
-
|
|
10
|
+
const address = await resolveExistingContractAddress(cwd, flags.contractId, flags.contractAddressSource, effectiveDirectory(flags));
|
|
11
|
+
return renderCoreResult(amendKeiyaku({
|
|
12
|
+
...parsed,
|
|
13
|
+
cwd,
|
|
14
|
+
address,
|
|
15
|
+
}), buildAmendResponse);
|
|
10
16
|
};
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { arcKeiyaku, buildArcInput } from "../../../../core/arc.js";
|
|
2
|
+
import { resolveExistingContractAddress } from "../../../../core/addressing.js";
|
|
2
3
|
import { buildArcResponse } from "../../../render/arc.js";
|
|
3
4
|
import { renderCoreResult } from "../../../render/shared.js";
|
|
4
5
|
import { effectiveDirectory, repositoryDirectory } from "../../shared.js";
|
|
5
6
|
export const handler = async (stdin, flags) => {
|
|
6
7
|
const parsed = buildArcInput(stdin, effectiveDirectory(flags), flags.waivePaths, flags.contractId, flags.contractAddressSource);
|
|
7
8
|
const cwd = await repositoryDirectory(flags, "arc");
|
|
8
|
-
|
|
9
|
+
const address = await resolveExistingContractAddress(cwd, flags.contractId, flags.contractAddressSource, effectiveDirectory(flags));
|
|
10
|
+
return renderCoreResult(arcKeiyaku({
|
|
11
|
+
...parsed,
|
|
12
|
+
cwd,
|
|
13
|
+
address,
|
|
14
|
+
}), buildArcResponse);
|
|
9
15
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { bindContract } from "../../../../core/bind.js";
|
|
2
|
-
import { defaultActorClock } from "../../../../core/
|
|
2
|
+
import { defaultActorClock } from "../../../../core/outcome-base.js";
|
|
3
3
|
import { writeDraftArtifact } from "../../../draft-artifact.js";
|
|
4
4
|
import { buildBindDraftResponse, buildBindResponse, textResponse } from "../../../render/shared.js";
|
|
5
5
|
import { repositoryDirectory } from "../../shared.js";
|
|
6
|
-
export const handler = async (stdin, flags) => {
|
|
6
|
+
export const handler = async (stdin, flags, signal) => {
|
|
7
7
|
if (flags.dryRun) {
|
|
8
8
|
return textResponse(stdin);
|
|
9
9
|
}
|
|
@@ -14,7 +14,8 @@ export const handler = async (stdin, flags) => {
|
|
|
14
14
|
const result = await bindContract({
|
|
15
15
|
cwd, draft: stdin, ...defaultActorClock(), workspace: "worktree",
|
|
16
16
|
after: flags.after ?? [], exclusive: flags.exclusive,
|
|
17
|
-
...(flags.
|
|
17
|
+
...(flags.bindTaskIds === undefined ? {} : { taskIds: flags.bindTaskIds }),
|
|
18
|
+
signal,
|
|
18
19
|
onProgress: (line) => {
|
|
19
20
|
process.stdout.write(`${line}\n`);
|
|
20
21
|
},
|
|
@@ -2,14 +2,14 @@ export const meta = {
|
|
|
2
2
|
command: "bind",
|
|
3
3
|
summary: "Create a contract ledger and workspace files",
|
|
4
4
|
usage: [
|
|
5
|
-
"keiyaku bind [-C|--cwd DIR] [--repo DIR] [--task ID]
|
|
6
|
-
"keiyaku bind [-C|--cwd DIR] [--repo DIR] [--task ID] --place NAME --objective TEXT --scope GLOB --checks CHECK [--dry-run]",
|
|
5
|
+
"keiyaku bind [-C|--cwd DIR] [--repo DIR] [--task ID]... <<'KEIYAKU'",
|
|
6
|
+
"keiyaku bind [-C|--cwd DIR] [--repo DIR] [--task ID]... --place NAME --objective TEXT --scope GLOB --checks CHECK [--dry-run]",
|
|
7
7
|
],
|
|
8
8
|
stdin: "optional",
|
|
9
9
|
flags: ["cwd", "repo", "after", "exclusive", "draft-only", "place", "objective", "scope", "checks", "task", "dry-run"],
|
|
10
10
|
// contract is parseable only so the mouth can reject it with bind-specific copy.
|
|
11
11
|
parseFlags: ["cwd", "repo", "contract", "after", "exclusive", "draft-only", "place", "objective", "scope", "checks", "task", "dry-run"],
|
|
12
|
-
purpose: "Bind a Keiyaku from
|
|
12
|
+
purpose: "Bind a Keiyaku from contract Markdown on stdin.",
|
|
13
13
|
input: [
|
|
14
14
|
"# <name>",
|
|
15
15
|
"",
|
|
@@ -17,14 +17,41 @@ export const meta = {
|
|
|
17
17
|
"<what the commission should accomplish>",
|
|
18
18
|
"",
|
|
19
19
|
"## Scope",
|
|
20
|
-
"- <
|
|
20
|
+
"- <pattern>",
|
|
21
21
|
"",
|
|
22
22
|
"## Checks",
|
|
23
|
-
"- <
|
|
23
|
+
"- <verification>",
|
|
24
24
|
],
|
|
25
25
|
notes: [
|
|
26
|
-
"bind creates a
|
|
27
|
-
"
|
|
26
|
+
"bind creates a contract and does not accept @addr or --contract.",
|
|
27
|
+
"Primary form is stdin Markdown (full document below).",
|
|
28
|
+
"With --task, title and body supply name/objective defaults; stdin may send only the missing sections and any present section overrides the task default.",
|
|
29
|
+
"Domain flags remain available as a full-document alternative; they cannot mix with stdin Markdown.",
|
|
30
|
+
],
|
|
31
|
+
examples: [
|
|
32
|
+
[
|
|
33
|
+
"keiyaku bind <<'KEIYAKU'",
|
|
34
|
+
"# <name>",
|
|
35
|
+
"",
|
|
36
|
+
"## Objective",
|
|
37
|
+
"<what the commission should accomplish>",
|
|
38
|
+
"",
|
|
39
|
+
"## Scope",
|
|
40
|
+
"- <pattern>",
|
|
41
|
+
"",
|
|
42
|
+
"## Checks",
|
|
43
|
+
"- <verification>",
|
|
44
|
+
"KEIYAKU",
|
|
45
|
+
].join("\n"),
|
|
46
|
+
[
|
|
47
|
+
"keiyaku bind --task fix-flaky-pump <<'KEIYAKU'",
|
|
48
|
+
"## Scope",
|
|
49
|
+
"- <pattern>",
|
|
50
|
+
"",
|
|
51
|
+
"## Checks",
|
|
52
|
+
"- <verification>",
|
|
53
|
+
"KEIYAKU",
|
|
54
|
+
].join("\n"),
|
|
28
55
|
],
|
|
29
56
|
completionRank: 0,
|
|
30
57
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { defaultActorClock } from "../../../../core/
|
|
1
|
+
import { resolveExistingContractAddress, withResolvedAddress } from "../../../../core/addressing.js";
|
|
2
|
+
import { defaultActorClock } from "../../../../core/outcome-base.js";
|
|
3
3
|
import { forfeitContractCommand } from "../../../../core/forfeit.js";
|
|
4
4
|
import { buildForfeitResponse } from "../../../render/shared.js";
|
|
5
|
-
import { repositoryDirectory } from "../../shared.js";
|
|
5
|
+
import { effectiveDirectory, repositoryDirectory } from "../../shared.js";
|
|
6
6
|
export const handler = async (_stdin, flags) => {
|
|
7
7
|
const cwd = await repositoryDirectory(flags, "forfeit");
|
|
8
|
-
const address = await
|
|
8
|
+
const address = await resolveExistingContractAddress(cwd, flags.contractId, flags.contractAddressSource, effectiveDirectory(flags));
|
|
9
9
|
return await withResolvedAddress(address, async () => buildForfeitResponse({
|
|
10
10
|
...await forfeitContractCommand({ cwd, contractId: address.binding.commissionId, ...defaultActorClock(), note: flags.reason }),
|
|
11
11
|
address,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveExistingContractAddress, withResolvedAddress } from "../../../../core/addressing.js";
|
|
2
2
|
import { readContractLog } from "../../../../core/log.js";
|
|
3
3
|
import { buildLogResponse } from "../../../render/misc.js";
|
|
4
|
-
import { repositoryDirectory } from "../../shared.js";
|
|
4
|
+
import { effectiveDirectory, repositoryDirectory } from "../../shared.js";
|
|
5
5
|
export const handler = async (_stdin, flags) => {
|
|
6
6
|
const cwd = await repositoryDirectory(flags, "log");
|
|
7
|
-
const address = await
|
|
7
|
+
const address = await resolveExistingContractAddress(cwd, flags.contractId, flags.contractAddressSource, effectiveDirectory(flags));
|
|
8
8
|
return await withResolvedAddress(address, async () => {
|
|
9
9
|
const result = await readContractLog({ cwd, contractId: address.binding.commissionId });
|
|
10
10
|
return buildLogResponse({ ...result, address });
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { FlowError } from "../../../../flow-error.js";
|
|
2
|
-
import {
|
|
3
|
-
import { buildPetitionClaimInput } from "../../../../core/
|
|
4
|
-
import { previewPetition } from "../../../../core/petition-preview.js";
|
|
5
|
-
import { petitionKeiyaku } from "../../../../core/petition-run.js";
|
|
2
|
+
import { resolveExistingContractAddress, withResolvedAddress } from "../../../../core/addressing.js";
|
|
3
|
+
import { buildPetitionClaimInput, petitionKeiyaku, previewPetition, } from "../../../../core/settlement/index.js";
|
|
6
4
|
import { buildPetitionClaimResponse, buildPetitionPreviewResponse } from "../../../render/petition.js";
|
|
7
|
-
import { repositoryDirectory } from "../../shared.js";
|
|
5
|
+
import { effectiveDirectory, repositoryDirectory } from "../../shared.js";
|
|
8
6
|
export const handler = async (stdin, flags, signal) => {
|
|
9
7
|
if (flags.json && !flags.dryRun) {
|
|
10
8
|
throw new FlowError("EMPTY_PARAM", "petition --json requires --dry-run");
|
|
11
9
|
}
|
|
12
10
|
const cwd = await repositoryDirectory(flags, "petition");
|
|
13
|
-
const address = await
|
|
11
|
+
const address = await resolveExistingContractAddress(cwd, flags.contractId, flags.contractAddressSource, effectiveDirectory(flags));
|
|
14
12
|
return await withResolvedAddress(address, async () => {
|
|
15
13
|
const input = buildPetitionClaimInput({ cwd, contractId: address.binding.commissionId, stdin, signal, waivePaths: flags.waivePaths });
|
|
16
14
|
if (flags.dryRun) {
|
|
@@ -1,10 +1,24 @@
|
|
|
1
|
-
import { resolveContractAddress } from "../../../../core/addressing.js";
|
|
2
|
-
import { renewKeiyaku } from "../../../../core/renew.js";
|
|
3
|
-
import { buildRenewResponse } from "../../../render/arc.js";
|
|
1
|
+
import { resolveContractAddress, resolveExistingContractAddress } from "../../../../core/addressing.js";
|
|
2
|
+
import { abortRenewKeiyaku, continueRenewKeiyaku, renewKeiyaku } from "../../../../core/renew.js";
|
|
3
|
+
import { buildRenewAbortResponse, buildRenewResponse } from "../../../render/arc.js";
|
|
4
4
|
import { renderCoreResult } from "../../../render/shared.js";
|
|
5
|
-
import { repositoryDirectory } from "../../shared.js";
|
|
5
|
+
import { effectiveDirectory, repositoryDirectory } from "../../shared.js";
|
|
6
6
|
export const handler = async (_stdin, flags) => {
|
|
7
7
|
const cwd = await repositoryDirectory(flags, "renew");
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
const resolveAddress = flags.renewContinue || flags.renewAbort
|
|
9
|
+
? resolveContractAddress
|
|
10
|
+
: resolveExistingContractAddress;
|
|
11
|
+
const address = await resolveAddress(cwd, flags.contractId, flags.contractAddressSource, effectiveDirectory(flags));
|
|
12
|
+
if (flags.renewContinue) {
|
|
13
|
+
return renderCoreResult(continueRenewKeiyaku({ cwd, address, waivePaths: flags.waivePaths }), buildRenewResponse);
|
|
14
|
+
}
|
|
15
|
+
if (flags.renewAbort) {
|
|
16
|
+
return renderCoreResult(abortRenewKeiyaku({ cwd, address }), buildRenewAbortResponse);
|
|
17
|
+
}
|
|
18
|
+
return renderCoreResult(renewKeiyaku({
|
|
19
|
+
cwd,
|
|
20
|
+
address,
|
|
21
|
+
waivePaths: flags.waivePaths,
|
|
22
|
+
resolveConflicts: flags.renewResolve,
|
|
23
|
+
}), buildRenewResponse);
|
|
10
24
|
};
|
|
@@ -2,16 +2,17 @@ export const meta = {
|
|
|
2
2
|
command: "renew",
|
|
3
3
|
summary: "Rewrite delivery onto the current base",
|
|
4
4
|
usage: [
|
|
5
|
-
"keiyaku renew [-C|--cwd DIR] [--repo DIR] [--contract ADDR] [--waive PATH]",
|
|
6
|
-
"keiyaku @<id> renew
|
|
5
|
+
"keiyaku renew [-C|--cwd DIR] [--repo DIR] [--contract ADDR] [--waive PATH] [--resolve]",
|
|
6
|
+
"keiyaku @<id> renew --continue [--waive PATH]",
|
|
7
|
+
"keiyaku @<id> renew --abort",
|
|
7
8
|
],
|
|
8
9
|
stdin: "none",
|
|
9
|
-
flags: ["cwd", "repo", "contract", "waive"],
|
|
10
|
+
flags: ["cwd", "repo", "contract", "waive", "resolve", "continue", "abort"],
|
|
10
11
|
purpose: "Capture receipts, rewrite delivery onto the default branch, then seal the current a0 or open explicit arc and record the renewal.",
|
|
11
12
|
notes: [
|
|
12
13
|
"After an explicit arc closes, refuses loose commits until another arc is open.",
|
|
13
14
|
"Refuses while an Akuma is in flight.",
|
|
14
|
-
"
|
|
15
|
+
"Ordinary conflicts restore the delivery branch and worktree without ledger writes; --resolve opens an owned session for --continue or --abort.",
|
|
15
16
|
],
|
|
16
17
|
completionRank: 9,
|
|
17
18
|
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { meta as bindMeta } from "./contract/bind/meta.js";
|
|
2
|
+
import { meta as arcMeta } from "./contract/arc/meta.js";
|
|
3
|
+
import { meta as callMeta } from "./projection/call/meta.js";
|
|
4
|
+
import { meta as reviveMeta } from "./projection/revive/meta.js";
|
|
5
|
+
import { meta as waitMeta } from "./projection/wait/meta.js";
|
|
6
|
+
import { meta as tellMeta } from "./projection/tell/meta.js";
|
|
7
|
+
import { meta as killMeta } from "./projection/kill/meta.js";
|
|
8
|
+
import { meta as logMeta } from "./contract/log/meta.js";
|
|
9
|
+
import { meta as akumaMeta } from "./akuma/akuma/meta.js";
|
|
10
|
+
import { meta as akumaLsMeta } from "./akuma/list/meta-ls.js";
|
|
11
|
+
import { meta as akumaViewMeta } from "./akuma/view/meta.js";
|
|
12
|
+
import { meta as skillsMeta } from "./skills/skills/meta.js";
|
|
13
|
+
import { meta as skillsInstallMeta } from "./skills/install/meta.js";
|
|
14
|
+
import { meta as amendMeta } from "./contract/amend/meta.js";
|
|
15
|
+
import { meta as renewMeta } from "./contract/renew/meta.js";
|
|
16
|
+
import { meta as petitionMeta } from "./contract/petition/meta.js";
|
|
17
|
+
import { meta as forfeitMeta } from "./contract/forfeit/meta.js";
|
|
18
|
+
import { meta as guideMeta } from "./system/guide/meta.js";
|
|
19
|
+
import { meta as completionMeta } from "./system/completion/meta.js";
|
|
20
|
+
import { meta as statusMeta } from "./projection/status/meta.js";
|
|
21
|
+
import { meta as taskMeta } from "./task/task/meta.js";
|
|
22
|
+
import { meta as taskAddMeta } from "./task/add/meta.js";
|
|
23
|
+
import { meta as taskShowMeta } from "./task/show/meta.js";
|
|
24
|
+
import { meta as taskLsMeta } from "./task/ls/meta.js";
|
|
25
|
+
import { meta as taskStartMeta } from "./task/start/meta.js";
|
|
26
|
+
import { meta as taskStopMeta } from "./task/stop/meta.js";
|
|
27
|
+
import { meta as taskDoneMeta } from "./task/done/meta.js";
|
|
28
|
+
import { meta as taskDropMeta } from "./task/drop/meta.js";
|
|
29
|
+
import { meta as taskUpdateMeta } from "./task/update/meta.js";
|
|
30
|
+
import { meta as taskDoctorMeta } from "./task/doctor/meta.js";
|
|
31
|
+
import { meta as dumpEnvMeta } from "./system/dump-env/meta.js";
|
|
32
|
+
export const COMMAND_METADATA_ORDER = [
|
|
33
|
+
"bind", "arc", "call", "revive", "wait", "tell", "kill", "log",
|
|
34
|
+
"akuma", "akuma ls", "akuma view", "skills", "skills install", "amend",
|
|
35
|
+
"renew", "petition", "forfeit", "guide", "completion", "status", "task",
|
|
36
|
+
"task add", "task show", "task ls", "task start", "task stop", "task done",
|
|
37
|
+
"task drop", "task update", "task doctor", "dump-env",
|
|
38
|
+
];
|
|
39
|
+
const COMMAND_METADATA = [
|
|
40
|
+
bindMeta, arcMeta, callMeta, reviveMeta, waitMeta, tellMeta, killMeta, logMeta,
|
|
41
|
+
akumaMeta, akumaLsMeta, akumaViewMeta, skillsMeta, skillsInstallMeta, amendMeta,
|
|
42
|
+
renewMeta, petitionMeta, forfeitMeta, guideMeta, completionMeta, statusMeta,
|
|
43
|
+
taskMeta, taskAddMeta, taskShowMeta, taskLsMeta, taskStartMeta, taskStopMeta,
|
|
44
|
+
taskDoneMeta, taskDropMeta, taskUpdateMeta, taskDoctorMeta, dumpEnvMeta,
|
|
45
|
+
];
|
|
46
|
+
export const CLI_COMMAND_METADATA = Object.fromEntries(COMMAND_METADATA.map((meta) => [meta.command, meta]));
|
|
47
|
+
export function getCommandMetadata(command) {
|
|
48
|
+
return CLI_COMMAND_METADATA[command];
|
|
49
|
+
}
|
|
50
|
+
export function allCommandMetadata() {
|
|
51
|
+
return COMMAND_METADATA_ORDER.map((command) => CLI_COMMAND_METADATA[command]);
|
|
52
|
+
}
|
|
53
|
+
export function commandParseOrder() {
|
|
54
|
+
return [...COMMAND_METADATA_ORDER].sort((a, b) => {
|
|
55
|
+
const tokenDelta = b.split(" ").length - a.split(" ").length;
|
|
56
|
+
return tokenDelta !== 0 ? tokenDelta : COMMAND_METADATA_ORDER.indexOf(a) - COMMAND_METADATA_ORDER.indexOf(b);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { runCallAndPersist } from "../../../../core/call-persist.js";
|
|
2
|
-
import { projectionDir } from "../../../../core/projection
|
|
3
|
-
import { waitForProjection } from "../../../../core/projection
|
|
2
|
+
import { projectionDir } from "../../../../core/projection/index.js";
|
|
3
|
+
import { waitForProjection } from "../../../../core/projection/index.js";
|
|
4
4
|
import { buildCallResponse, renderAdoptedLaunchReceipt } from "../../../render/call.js";
|
|
5
5
|
import { buildWaitResponse } from "../../../render/wait.js";
|
|
6
6
|
import { buildCallInput } from "../../shared.js";
|
|
@@ -12,8 +12,8 @@ export const handler = async (stdin, flags, signal) => {
|
|
|
12
12
|
signal,
|
|
13
13
|
...(!flags.detach
|
|
14
14
|
? {
|
|
15
|
-
onLaunch: ({ address, projection }) => {
|
|
16
|
-
process.stdout.write(`${renderAdoptedLaunchReceipt(address, projection.id, projection.alias, projection.previousAliasTarget)}\n`);
|
|
15
|
+
onLaunch: ({ address, projection, akumaName }) => {
|
|
16
|
+
process.stdout.write(`${renderAdoptedLaunchReceipt(address, projection.id, projection.alias, projection.previousAliasTarget, akumaName)}\n`);
|
|
17
17
|
},
|
|
18
18
|
}
|
|
19
19
|
: {}),
|
|
@@ -25,8 +25,9 @@ export const handler = async (stdin, flags, signal) => {
|
|
|
25
25
|
const projectionRoot = outcome.result.address.repo.kind === "repository"
|
|
26
26
|
? outcome.result.address.repo.stableRoot
|
|
27
27
|
: flags.cwd ?? process.cwd();
|
|
28
|
+
const projectionDirectory = await projectionDir(projectionRoot, projection.id);
|
|
28
29
|
return buildWaitResponse(projection.id, await waitForProjection({
|
|
29
|
-
projectionDirectory
|
|
30
|
+
projectionDirectory,
|
|
30
31
|
timeoutMs: flags.timeoutMs,
|
|
31
32
|
signal,
|
|
32
33
|
}), { alias: projection.alias });
|
|
@@ -1,37 +1,21 @@
|
|
|
1
1
|
import { FlowError } from "../../../../flow-error.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { waitForProjection } from "../../../../core/projection-wait.js";
|
|
6
|
-
import { resolveProjectionAddress } from "../../../projection-address.js";
|
|
7
|
-
import { textResponse } from "../../../render/shared.js";
|
|
2
|
+
import { killProjectionGeneration } from "../../../../core/projection/index.js";
|
|
3
|
+
import { waitForProjection } from "../../../../core/projection/index.js";
|
|
4
|
+
import { buildKillAcceptedResponse, buildKillAlreadyClosedResponse } from "../../../render/kill.js";
|
|
8
5
|
import { buildWaitResponse } from "../../../render/wait.js";
|
|
9
|
-
import {
|
|
10
|
-
export const handler = async (_stdin, flags, signal, positional) => {
|
|
11
|
-
const cwd = flags.contractId
|
|
12
|
-
? await repositoryDirectory(flags, "kill contract addressing")
|
|
13
|
-
: await projectDirectory(flags, "kill");
|
|
6
|
+
import { resolveProjectionCommandTarget, runProjectionCommand, } from "../shared.js";
|
|
7
|
+
export const handler = async (_stdin, flags, signal, positional) => runProjectionCommand(flags, "kill", async (ctx) => {
|
|
14
8
|
const [projectionAddress] = positional;
|
|
15
9
|
if (!projectionAddress)
|
|
16
10
|
throw new FlowError("EMPTY_PARAM", "kill requires a projection address");
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return textResponse(`· ${projection.id} already closed`);
|
|
29
|
-
}
|
|
30
|
-
if (flags.timeoutMs === undefined) {
|
|
31
|
-
return textResponse(`✓ kill ${projection.id}\n» keiyaku wait ${projection.id}`);
|
|
32
|
-
}
|
|
33
|
-
// Accepted with --wait: no acceptance receipt or address preamble.
|
|
34
|
-
return buildWaitResponse(projection.id, await waitForProjection({ projectionDirectory: directory, timeoutMs: flags.timeoutMs, signal }), { alias: projection.alias });
|
|
35
|
-
};
|
|
36
|
-
return address ? await withResolvedAddress(address, operation) : await operation();
|
|
37
|
-
};
|
|
11
|
+
const projection = await resolveProjectionCommandTarget(ctx, projectionAddress, "kill");
|
|
12
|
+
const result = killProjectionGeneration(projection.directory);
|
|
13
|
+
if (result.status === "already-closed") {
|
|
14
|
+
return buildKillAlreadyClosedResponse(projection.id);
|
|
15
|
+
}
|
|
16
|
+
if (flags.timeoutMs === undefined) {
|
|
17
|
+
return buildKillAcceptedResponse(projection.id);
|
|
18
|
+
}
|
|
19
|
+
// Accepted with --wait: no acceptance receipt or address preamble.
|
|
20
|
+
return buildWaitResponse(projection.id, await waitForProjection({ projectionDirectory: projection.directory, timeoutMs: flags.timeoutMs, signal }), { alias: projection.alias });
|
|
21
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { resolveContractAddress, withResolvedAddress, } from "../../../core/addressing.js";
|
|
2
|
+
import { projectionDir } from "../../../core/projection/index.js";
|
|
3
|
+
import { resolveProjectionAddress, } from "../../projection-address.js";
|
|
4
|
+
import { projectDirectory, repositoryDirectory } from "../shared.js";
|
|
5
|
+
/** Resolve cwd + optional contract address, then run the verb under that carrier. */
|
|
6
|
+
export async function runProjectionCommand(flags, verb, operation) {
|
|
7
|
+
const cwd = flags.contractId
|
|
8
|
+
? await repositoryDirectory(flags, `${verb} contract addressing`)
|
|
9
|
+
: await projectDirectory(flags, verb);
|
|
10
|
+
const address = flags.contractId
|
|
11
|
+
? await resolveContractAddress(cwd, flags.contractId, flags.contractAddressSource)
|
|
12
|
+
: undefined;
|
|
13
|
+
const run = () => operation({ cwd, address });
|
|
14
|
+
return address ? await withResolvedAddress(address, run) : await run();
|
|
15
|
+
}
|
|
16
|
+
export function resolveProjectionCommandAddress(ctx, projectionAddress, verb) {
|
|
17
|
+
return resolveProjectionAddress({
|
|
18
|
+
cwd: ctx.cwd,
|
|
19
|
+
address: projectionAddress,
|
|
20
|
+
scope: ctx.address,
|
|
21
|
+
verb,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export async function resolveProjectionCommandTarget(ctx, projectionAddress, verb) {
|
|
25
|
+
const projection = await resolveProjectionCommandAddress(ctx, projectionAddress, verb);
|
|
26
|
+
const directory = await projectionDir(ctx.cwd, projection.id);
|
|
27
|
+
return { ...projection, directory };
|
|
28
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readKanshiBoard } from "../../../../core/status/board.js";
|
|
2
2
|
import { normalizeTargetRef } from "../../../../core/target-ref.js";
|
|
3
|
-
import { isProjectionId } from "../../../../core/projection
|
|
3
|
+
import { isProjectionId } from "../../../../core/projection/index.js";
|
|
4
4
|
import { FlowError } from "../../../../flow-error.js";
|
|
5
5
|
import { renderProjectionFilteredStatus, renderStatusBoard } from "../../../render/status.js";
|
|
6
6
|
import { textResponse } from "../../../render/shared.js";
|
|
@@ -1,36 +1,20 @@
|
|
|
1
1
|
import { FlowError } from "../../../../flow-error.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { assertTellEffortSupported, tellProjection } from "../../../../core/projection-wake.js";
|
|
5
|
-
import { waitForProjection } from "../../../../core/projection-wait.js";
|
|
6
|
-
import { resolveProjectionAddress } from "../../../projection-address.js";
|
|
2
|
+
import { assertTellEffortSupported, tellProjection, writeInboxTell } from "../../../../core/projection/index.js";
|
|
3
|
+
import { waitForProjection } from "../../../../core/projection/index.js";
|
|
7
4
|
import { prependAddressReceipt } from "../../../render/address.js";
|
|
8
|
-
import {
|
|
5
|
+
import { buildSilentTellResponse } from "../../../render/tell.js";
|
|
9
6
|
import { buildWaitResponse } from "../../../render/wait.js";
|
|
10
|
-
import {
|
|
11
|
-
export const handler = async (body, flags, signal, positional) => {
|
|
12
|
-
const cwd = flags.contractId
|
|
13
|
-
? await repositoryDirectory(flags, "tell contract addressing")
|
|
14
|
-
: await projectDirectory(flags, "tell");
|
|
7
|
+
import { resolveProjectionCommandTarget, runProjectionCommand, } from "../shared.js";
|
|
8
|
+
export const handler = async (body, flags, signal, positional) => runProjectionCommand(flags, "tell", async (ctx) => {
|
|
15
9
|
const projectionAddress = positional[0];
|
|
16
10
|
if (!projectionAddress)
|
|
17
11
|
throw new FlowError("EMPTY_PARAM", "tell requires a projection address and message");
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
assertTellEffortSupported(directory, flags.effort);
|
|
28
|
-
// Mailbox first: do not inspect phase before this immutable write.
|
|
29
|
-
writeInboxTell(directory, body, Date.now(), { effort: flags.effort });
|
|
30
|
-
await tellProjection(directory, flags.effort);
|
|
31
|
-
if (flags.timeoutMs === undefined)
|
|
32
|
-
return textResponse("");
|
|
33
|
-
return prependAddressReceipt(buildWaitResponse(projection.id, await waitForProjection({ projectionDirectory: directory, timeoutMs: flags.timeoutMs, signal }), { alias: projection.alias }), address, { projectionId: projection.id, projectionAlias: projection.alias });
|
|
34
|
-
};
|
|
35
|
-
return address ? await withResolvedAddress(address, operation) : await operation();
|
|
36
|
-
};
|
|
12
|
+
const projection = await resolveProjectionCommandTarget(ctx, projectionAddress, "tell");
|
|
13
|
+
assertTellEffortSupported(projection.directory, flags.effort);
|
|
14
|
+
// Mailbox first: do not inspect phase before this immutable write.
|
|
15
|
+
writeInboxTell(projection.directory, body, Date.now(), { effort: flags.effort });
|
|
16
|
+
await tellProjection(projection.directory, projection.id, flags.effort);
|
|
17
|
+
if (flags.timeoutMs === undefined)
|
|
18
|
+
return buildSilentTellResponse();
|
|
19
|
+
return prependAddressReceipt(buildWaitResponse(projection.id, await waitForProjection({ projectionDirectory: projection.directory, timeoutMs: flags.timeoutMs, signal }), { alias: projection.alias }), ctx.address, { projectionId: projection.id, projectionAlias: projection.alias });
|
|
20
|
+
});
|
|
@@ -1,23 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { resolveProjectionAddress } from "../../../projection-address.js";
|
|
1
|
+
import { projectionDir } from "../../../../core/projection/index.js";
|
|
2
|
+
import { snapshotCommissionProjectionIds, waitForProjection, waitForProjectionSet } from "../../../../core/projection/index.js";
|
|
3
|
+
import { FlowError } from "../../../../flow-error.js";
|
|
5
4
|
import { prependAddressReceipt } from "../../../render/address.js";
|
|
6
|
-
import { buildWaitResponse } from "../../../render/wait.js";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
5
|
+
import { buildProjectionWaitSetResponse, buildWaitResponse } from "../../../render/wait.js";
|
|
6
|
+
import { resolveProjectionCommandAddress, resolveProjectionCommandTarget, runProjectionCommand, } from "../shared.js";
|
|
7
|
+
import { WAIT_SET_SELECTION_ERROR } from "./meta.js";
|
|
8
|
+
export const handler = async (_stdin, flags, signal, positional) => runProjectionCommand(flags, "wait", async (ctx) => {
|
|
9
|
+
// Selection modes only govern admitted sets with more than one explicit member.
|
|
10
|
+
if (positional.length === 1) {
|
|
11
|
+
const projection = await resolveProjectionCommandTarget(ctx, positional[0], "wait");
|
|
12
|
+
return prependAddressReceipt(buildWaitResponse(projection.id, await waitForProjection({
|
|
13
|
+
projectionDirectory: projection.directory,
|
|
14
|
+
timeoutMs: flags.timeoutMs,
|
|
15
|
+
signal,
|
|
16
|
+
}), { alias: projection.alias }), ctx.address, { projectionId: projection.id, projectionAlias: projection.alias });
|
|
17
|
+
}
|
|
18
|
+
const selected = [];
|
|
19
|
+
if (positional.length === 0) {
|
|
20
|
+
if (ctx.address?.binding.kind === "commission") {
|
|
21
|
+
selected.push(...await snapshotCommissionProjectionIds(ctx.cwd, ctx.address.binding.commissionId));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
// Resolve in argument order so multiple bad coordinates have one stable failure.
|
|
26
|
+
for (const projectionAddress of positional) {
|
|
27
|
+
selected.push((await resolveProjectionCommandAddress(ctx, projectionAddress, "wait")).id);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const ids = [...new Set(selected)].sort();
|
|
31
|
+
if (ids.length === 0) {
|
|
32
|
+
throw new FlowError("EMPTY_PARAM", "wait commission snapshot contains no projections");
|
|
33
|
+
}
|
|
34
|
+
if (!flags.any && !flags.all) {
|
|
35
|
+
throw new FlowError("EMPTY_PARAM", WAIT_SET_SELECTION_ERROR);
|
|
36
|
+
}
|
|
37
|
+
return prependAddressReceipt(buildProjectionWaitSetResponse(await waitForProjectionSet({
|
|
38
|
+
projections: await Promise.all(ids.map(async (id) => ({
|
|
39
|
+
id,
|
|
40
|
+
projectionDirectory: await projectionDir(ctx.cwd, id),
|
|
41
|
+
}))),
|
|
42
|
+
selection: flags.any ? "any" : "all",
|
|
43
|
+
timeoutMs: flags.timeoutMs,
|
|
44
|
+
signal,
|
|
45
|
+
})), ctx.address);
|
|
46
|
+
});
|