@astrosheep/keiyaku 4.6.6 → 4.6.8
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 +11 -0
- package/build/{integrations/marketplace → plugins}/.agents/plugins/marketplace.json +1 -1
- package/build/plugins/.claude-plugin/marketplace.json +5 -0
- package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/.claude-plugin/plugin.json +1 -1
- package/build/{integrations/marketplace/plugins/keiyaku → plugins/codex}/.codex-plugin/plugin.json +1 -1
- package/build/plugins/codex/skills/keiyaku/SKILL.md +44 -0
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +130 -0
- package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +269 -0
- package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +65 -0
- package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +216 -0
- package/build/plugins/codex/skills/keiyaku-bind/agents/openai.yaml +4 -0
- package/build/plugins/codex/skills/keiyaku-task/SKILL.md +104 -0
- package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +129 -0
- package/build/plugins/opencode/package.json +6 -0
- package/build/plugins/opencode/skills/keiyaku/SKILL.md +44 -0
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +130 -0
- package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +269 -0
- package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +65 -0
- package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +216 -0
- package/build/plugins/opencode/skills/keiyaku-bind/agents/openai.yaml +4 -0
- package/build/plugins/opencode/skills/keiyaku-task/SKILL.md +104 -0
- package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +129 -0
- package/build/{integrations → plugins}/pi/keiyaku.ts +0 -5
- package/build/skills/keiyaku/SKILL.md +44 -0
- package/build/skills/keiyaku-akuma/SKILL.md +130 -0
- package/build/skills/keiyaku-akuma/references/automation.md +269 -0
- package/build/skills/keiyaku-babysit/SKILL.md +65 -0
- package/build/skills/keiyaku-bind/SKILL.md +216 -0
- package/build/skills/keiyaku-bind/agents/openai.yaml +4 -0
- package/build/skills/keiyaku-task/SKILL.md +104 -0
- package/build/skills/keiyaku-workflow/SKILL.md +129 -0
- package/build/src/akuma/akuma-call.d.ts +2 -0
- package/build/src/akuma/akuma-call.js +8 -2
- package/build/src/akuma/akuma-instance.d.ts +12 -1
- package/build/src/akuma/akuma-instance.js +31 -9
- package/build/src/akuma/akuma-observe.d.ts +4 -0
- package/build/src/akuma/akuma-observe.js +14 -0
- package/build/src/akuma/akuma-owner.d.ts +6 -2
- package/build/src/akuma/akuma-owner.js +32 -10
- package/build/src/akuma/akuma-selection-execution.d.ts +3 -1
- package/build/src/akuma/akuma-selection-execution.js +2 -1
- package/build/src/akuma/akuma-wait.d.ts +2 -1
- package/build/src/akuma/akuma-wait.js +4 -1
- package/build/src/akuma/akuma.d.ts +35 -5
- package/build/src/akuma/akuma.js +8 -10
- package/build/src/akuma/archetype.d.ts +7 -15
- package/build/src/akuma/archetype.js +36 -35
- package/build/src/akuma/body.d.ts +6 -3
- package/build/src/akuma/body.js +41 -30
- package/build/src/akuma/call-request.d.ts +18 -10
- package/build/src/akuma/call-request.js +10 -3
- package/build/src/akuma/caller.d.ts +39 -0
- package/build/src/akuma/caller.js +36 -0
- package/build/src/akuma/dispatch-association.d.ts +0 -1
- package/build/src/akuma/dispatch-association.js +0 -3
- package/build/src/akuma/heart/facts.d.ts +16 -12
- package/build/src/akuma/heart/facts.js +8 -0
- package/build/src/akuma/heart/index.d.ts +2 -7
- package/build/src/akuma/heart/index.js +3 -17
- package/build/src/akuma/heart/rows.d.ts +3 -3
- package/build/src/akuma/heart/soul.d.ts +1 -1
- package/build/src/akuma/heart/soul.js +5 -24
- package/build/src/akuma/heart/storage.d.ts +5 -0
- package/build/src/akuma/heart/storage.js +7 -3
- package/build/src/akuma/identity.d.ts +0 -1
- package/build/src/akuma/identity.js +2 -5
- package/build/src/akuma/index.d.ts +5 -2
- package/build/src/akuma/index.js +1 -0
- package/build/src/akuma/nuke.js +6 -28
- package/build/src/akuma/projection.d.ts +0 -11
- package/build/src/akuma/provider-recipe.d.ts +7 -6
- package/build/src/akuma/provider-recipe.js +1 -1
- package/build/src/akuma/provider.d.ts +6 -10
- package/build/src/akuma/provider.js +6 -7
- package/build/src/akuma/providers/acp/events.js +5 -18
- package/build/src/akuma/providers/acp/index.js +2 -3
- package/build/src/akuma/providers/claude/events.js +35 -60
- package/build/src/akuma/providers/claude/index.d.ts +2 -2
- package/build/src/akuma/providers/claude/index.js +2 -3
- package/build/src/akuma/providers/codex-app-server/index.js +2 -2
- package/build/src/akuma/providers/decode.d.ts +25 -0
- package/build/src/akuma/providers/decode.js +44 -0
- package/build/src/akuma/providers/execution-environment.d.ts +2 -1
- package/build/src/akuma/providers/execution-environment.js +3 -0
- package/build/src/akuma/providers/grok-build/index.js +6 -22
- package/build/src/akuma/providers/index.js +2 -0
- package/build/src/akuma/providers/lifecycle.d.ts +9 -0
- package/build/src/akuma/providers/lifecycle.js +10 -0
- package/build/src/akuma/providers/opencode-sdk/events.js +1 -14
- package/build/src/akuma/providers/opencode-sdk/index.js +10 -17
- package/build/src/akuma/providers/opencode-sdk/session.js +1 -3
- package/build/src/akuma/providers/paseo/events.d.ts +25 -0
- package/build/src/akuma/providers/paseo/events.js +157 -0
- package/build/src/akuma/providers/paseo/index.d.ts +9 -0
- package/build/src/akuma/providers/paseo/index.js +353 -0
- package/build/src/akuma/providers/pi/events.js +5 -15
- package/build/src/akuma/publication.d.ts +2 -0
- package/build/src/akuma/publication.js +5 -0
- package/build/src/akuma/request-lifecycle.d.ts +3 -0
- package/build/src/akuma/request-lifecycle.js +25 -4
- package/build/src/akuma/requests.d.ts +3 -1
- package/build/src/akuma/requests.js +32 -0
- package/build/src/akuma/selection-observation.d.ts +72 -2
- package/build/src/akuma/selection-observation.js +0 -6
- package/build/src/akuma/selection-owner-port.d.ts +1 -1
- package/build/src/akuma/selection-owner-port.js +16 -5
- package/build/src/akuma/selection-request.d.ts +2 -0
- package/build/src/akuma/selection-request.js +2 -1
- package/build/src/akuma/turn-drive.js +2 -5
- package/build/src/akuma-body.js +4 -2
- package/build/src/cli/akuma-caller.d.ts +3 -0
- package/build/src/cli/akuma-caller.js +21 -0
- package/build/src/cli/commands/akuma-grammar.js +7 -12
- package/build/src/cli/commands/akuma.js +18 -16
- package/build/src/cli/commands/contract-grammar.d.ts +2 -1
- package/build/src/cli/commands/contract-grammar.js +13 -15
- package/build/src/cli/commands/contract-help.d.ts +2 -1
- package/build/src/cli/commands/contract-help.js +31 -1
- package/build/src/cli/commands/contract.js +24 -53
- package/build/src/cli/commands/install.js +3 -3
- package/build/src/cli/commands/task.js +18 -35
- package/build/src/cli/parse.d.ts +2 -2
- package/build/src/cli/render/catalog.d.ts +2 -5
- package/build/src/cli/render/contract-history.js +3 -6
- package/build/src/cli/render/contract.js +15 -50
- package/build/src/cli/render/receipt.js +3 -10
- package/build/src/cli/render/task.d.ts +4 -6
- package/build/src/cli/render/task.js +9 -26
- package/build/src/cli/runtime.d.ts +1 -1
- package/build/src/cli/runtime.js +11 -17
- package/build/src/cli/selectors.d.ts +3 -6
- package/build/src/cli/selectors.js +22 -53
- package/build/src/dispatch/index.d.ts +3 -3
- package/build/src/dispatch/index.js +1 -2
- package/build/src/git/observe.d.ts +6 -2
- package/build/src/git/observe.js +6 -2
- package/build/src/index.d.ts +6 -6
- package/build/src/index.js +2 -2
- package/build/src/kanshi/index.d.ts +1 -1
- package/build/src/kanshi/read.js +21 -6
- package/build/src/library/address.js +2 -4
- package/build/src/library/akuma-creation.d.ts +5 -1
- package/build/src/library/akuma-creation.js +33 -51
- package/build/src/library/akumas.d.ts +5 -4
- package/build/src/library/akumas.js +13 -9
- package/build/src/library/bind.d.ts +14 -14
- package/build/src/library/bind.js +11 -7
- package/build/src/library/contract-address.d.ts +9 -0
- package/build/src/library/contract-address.js +71 -0
- package/build/src/library/contract-composition.d.ts +4 -7
- package/build/src/library/contract-composition.js +6 -18
- package/build/src/library/contract-creation.d.ts +3 -5
- package/build/src/library/contract-creation.js +19 -17
- package/build/src/library/contract-execution.js +18 -23
- package/build/src/library/contract-outcomes.d.ts +2 -14
- package/build/src/library/contract-outcomes.js +2 -13
- package/build/src/library/contract-types.d.ts +36 -2
- package/build/src/library/delivery.d.ts +0 -2
- package/build/src/library/delivery.js +2 -5
- package/build/src/library/keiyaku.d.ts +0 -5
- package/build/src/library/keiyaku.js +6 -12
- package/build/src/library/outcome.d.ts +500 -499
- package/build/src/library/outcome.js +10 -0
- package/build/src/library/reconcile.js +8 -16
- package/build/src/library/refusal.d.ts +2 -2
- package/build/src/library/repo.d.ts +3 -2
- package/build/src/library/repo.js +10 -5
- package/build/src/library/selection.d.ts +4 -4
- package/build/src/library/selection.js +12 -9
- package/build/src/plugin/akuma-signals.d.ts +12 -11
- package/build/src/plugin/akuma-signals.js +40 -20
- package/build/src/plugin/public.d.ts +32 -2
- package/build/src/plugin/runtime.d.ts +1 -0
- package/build/src/plugin/runtime.js +35 -24
- package/build/src/protocol/amend.js +3 -2
- package/build/src/protocol/attempt.js +3 -8
- package/build/src/protocol/bind.d.ts +2 -2
- package/build/src/protocol/bind.js +1 -1
- package/build/src/protocol/deliver.js +3 -3
- package/build/src/protocol/operations.d.ts +1 -3
- package/build/src/protocol/operations.js +0 -8
- package/build/src/protocol/outcome.d.ts +1 -2
- package/build/src/protocol/outcome.js +1 -13
- package/build/src/protocol/placement.js +3 -10
- package/build/src/protocol/read/status.js +31 -70
- package/build/src/protocol/reintegrate.js +3 -10
- package/build/src/protocol/review.js +3 -3
- package/build/src/protocol/run.d.ts +5 -1
- package/build/src/protocol/run.js +3 -3
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/package.json +12 -8
- package/plugins/pi/keiyaku.ts +57 -0
- package/skills/keiyaku/SKILL.md +44 -0
- package/skills/keiyaku-akuma/SKILL.md +130 -0
- package/skills/keiyaku-akuma/references/automation.md +269 -0
- package/skills/keiyaku-babysit/SKILL.md +65 -0
- package/skills/keiyaku-bind/SKILL.md +216 -0
- package/skills/keiyaku-bind/agents/openai.yaml +4 -0
- package/skills/keiyaku-task/SKILL.md +104 -0
- package/skills/keiyaku-workflow/SKILL.md +129 -0
- package/build/integrations/marketplace/.claude-plugin/marketplace.json +0 -5
- package/build/integrations/marketplace/plugins/keiyaku/package.json +0 -17
- package/build/src/cli/commands/amend.d.ts +0 -12
- package/build/src/cli/commands/amend.js +0 -10
- package/build/src/cli/commands/bind.d.ts +0 -11
- package/build/src/cli/commands/bind.js +0 -23
- package/build/src/dispatch/association.d.ts +0 -1
- package/build/src/dispatch/association.js +0 -1
- /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku/SKILL.md +0 -0
- /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-akuma/SKILL.md +0 -0
- /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-akuma/references/automation.md +0 -0
- /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-babysit/SKILL.md +0 -0
- /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-bind/SKILL.md +0 -0
- /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-bind/agents/openai.yaml +0 -0
- /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-task/SKILL.md +0 -0
- /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-workflow/SKILL.md +0 -0
- /package/build/{integrations/marketplace/plugins/keiyaku/opencode.js → plugins/opencode/index.js} +0 -0
package/build/src/akuma/body.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { projectAkumaBirth } from "./caller.js";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import { decodeSoulSeed } from "./heart/soul.js";
|
|
3
4
|
import { sessionAdmissionSchema } from "./heart/rows.js";
|
|
@@ -10,7 +11,7 @@ import { HeldAkumaLeash, breakBody, decidePendingTellDisposition, drainPendingTe
|
|
|
10
11
|
import { akumaPathsSchema, pathsForAkuId, worldRootForAkumaPaths } from "./identity.js";
|
|
11
12
|
import { admitCallInitialTell, } from "./call-initial-tell.js";
|
|
12
13
|
import { akumaExecutionEnvironment } from "./providers/execution-environment.js";
|
|
13
|
-
import {
|
|
14
|
+
import { emitPluginSignal } from "../plugin/akuma-signals.js";
|
|
14
15
|
import { World } from "../world.js";
|
|
15
16
|
import { resolveProviderExecution } from "./providers/index.js";
|
|
16
17
|
import { clearBodyRequestTransport, settleBodyRequests } from "./request-serve.js";
|
|
@@ -35,6 +36,7 @@ export const bodyLaunchSchema = z
|
|
|
35
36
|
birthSession: sessionAdmissionSchema.optional(),
|
|
36
37
|
initialBody: z.string().optional(),
|
|
37
38
|
initiator: z.string().optional(),
|
|
39
|
+
birthInitiator: z.string().optional(),
|
|
38
40
|
initialSchemaJson: z.string().optional(),
|
|
39
41
|
refuseIfHeld: z.boolean().optional(),
|
|
40
42
|
completion: z.object({ contractId: z.string().optional() }).strict().optional(),
|
|
@@ -74,17 +76,18 @@ async function takeLeash(paths, refuseIfHeld = false) {
|
|
|
74
76
|
async function bornSoul(launch, leash, now) {
|
|
75
77
|
const before = await readHeart(launch.paths);
|
|
76
78
|
if (before.soul !== null)
|
|
77
|
-
return before.soul;
|
|
79
|
+
return { soul: before.soul, created: false };
|
|
78
80
|
if (launch.seed === undefined)
|
|
79
81
|
throw new Error("Akuma wake has no born soul");
|
|
80
82
|
const candidate = { ...launch.seed, createdAt: now };
|
|
81
|
-
|
|
83
|
+
const result = await leash.birth(launch.paths, candidate, launch.birthSession);
|
|
84
|
+
if (result === "sealed")
|
|
82
85
|
return null;
|
|
83
86
|
const born = (await readHeart(launch.paths)).soul;
|
|
84
87
|
if (born === null || born.id !== candidate.id) {
|
|
85
88
|
throw new Error("Akuma birth identity does not match its directory");
|
|
86
89
|
}
|
|
87
|
-
return born;
|
|
90
|
+
return { soul: born, created: result === "born" };
|
|
88
91
|
}
|
|
89
92
|
async function launchCwd(launch) {
|
|
90
93
|
if (launch.seed !== undefined)
|
|
@@ -156,7 +159,7 @@ function boundedDiagnostic(error) {
|
|
|
156
159
|
const text = diagnostic(error);
|
|
157
160
|
return text.length <= 500 ? text : `${text.slice(0, 500)}...`;
|
|
158
161
|
}
|
|
159
|
-
async function recordPluginDiagnostic(paths, occurrence, error) {
|
|
162
|
+
export async function recordPluginDiagnostic(paths, occurrence, error) {
|
|
160
163
|
try {
|
|
161
164
|
await appendFile(paths.log, `plugin ${occurrence} failed: ${boundedDiagnostic(error)}\n`);
|
|
162
165
|
}
|
|
@@ -233,14 +236,18 @@ export async function bodyProcessInput(launch, bodyModuleUrl = import.meta.url)
|
|
|
233
236
|
return {
|
|
234
237
|
argv: source ? [executable, "--import", import.meta.resolve("tsx"), entry, encoded] : [executable, entry, encoded],
|
|
235
238
|
cwd: await launchCwd(launch),
|
|
236
|
-
env: akumaExecutionEnvironment(process.env, {
|
|
239
|
+
env: akumaExecutionEnvironment(process.env, {
|
|
240
|
+
KEIYAKU_ACTOR_ID: actorId,
|
|
241
|
+
KEIYAKU_ACTOR_WORLD: worldRootForAkumaPaths(launch.paths),
|
|
242
|
+
}),
|
|
237
243
|
log: launch.paths.log,
|
|
238
244
|
};
|
|
239
245
|
}
|
|
240
246
|
async function prepareBodyExecution(launch, leash, runtime, adapter) {
|
|
241
|
-
const
|
|
242
|
-
if (
|
|
247
|
+
const birth = await bornSoul(launch, leash, runtime.now());
|
|
248
|
+
if (birth === null)
|
|
243
249
|
return null;
|
|
250
|
+
const { soul } = birth;
|
|
244
251
|
if (launch.seed === undefined && launch.initialBody === undefined) {
|
|
245
252
|
const [heart, requests] = await Promise.all([readHeart(launch.paths), readNonterminalRequests(launch.paths)]);
|
|
246
253
|
if (heart.pending.length === 0 && requests.length === 0)
|
|
@@ -249,7 +256,7 @@ async function prepareBodyExecution(launch, leash, runtime, adapter) {
|
|
|
249
256
|
const selected = adapter ?? (await resolveProviderExecution(soul.provider)).adapter;
|
|
250
257
|
if (!(await prepareBodyStart(launch.paths, leash)))
|
|
251
258
|
return null;
|
|
252
|
-
return {
|
|
259
|
+
return { ...birth, adapter: selected };
|
|
253
260
|
}
|
|
254
261
|
async function runPreparedBody(input) {
|
|
255
262
|
let pendingTellDisposition;
|
|
@@ -306,8 +313,7 @@ async function recoverBodyRequests(input) {
|
|
|
306
313
|
}
|
|
307
314
|
return false;
|
|
308
315
|
}
|
|
309
|
-
function turnOutcomeEmitter(launch, soul) {
|
|
310
|
-
let plugins;
|
|
316
|
+
function turnOutcomeEmitter(launch, soul, world) {
|
|
311
317
|
const reportDiagnostic = (message) => {
|
|
312
318
|
void recordPluginDiagnostic(launch.paths, "turn outcome", message);
|
|
313
319
|
};
|
|
@@ -318,11 +324,7 @@ function turnOutcomeEmitter(launch, soul) {
|
|
|
318
324
|
if (turn === null)
|
|
319
325
|
throw new Error(`Committed Turn ${turnSequence} is missing from Heart`);
|
|
320
326
|
const participants = await readTurnParticipants(launch.paths, turnSequence);
|
|
321
|
-
|
|
322
|
-
world: await World.at(worldRootForAkumaPaths(launch.paths)),
|
|
323
|
-
reportDiagnostic,
|
|
324
|
-
});
|
|
325
|
-
await (await plugins).emit({
|
|
327
|
+
await emitPluginSignal({ world, reportDiagnostic }, {
|
|
326
328
|
kind: "akuma.turn-outcome",
|
|
327
329
|
akumaId: soul.id,
|
|
328
330
|
bodySequence: turn.bodySequence,
|
|
@@ -333,7 +335,7 @@ function turnOutcomeEmitter(launch, soul) {
|
|
|
333
335
|
? { kind: "answered", text: outcome.answer }
|
|
334
336
|
: { kind: "failed", reason: outcome.diagnostic },
|
|
335
337
|
...(launch.completion?.contractId === undefined ? {} : { contractId: launch.completion.contractId }),
|
|
336
|
-
}
|
|
338
|
+
});
|
|
337
339
|
}
|
|
338
340
|
catch (error) {
|
|
339
341
|
await recordPluginDiagnostic(launch.paths, "turn outcome", error);
|
|
@@ -341,22 +343,16 @@ function turnOutcomeEmitter(launch, soul) {
|
|
|
341
343
|
},
|
|
342
344
|
};
|
|
343
345
|
}
|
|
344
|
-
function bodyEndEmitter(launch, soul) {
|
|
345
|
-
let plugins;
|
|
346
|
+
function bodyEndEmitter(launch, soul, world) {
|
|
346
347
|
const reportDiagnostic = (message) => {
|
|
347
348
|
void recordPluginDiagnostic(launch.paths, "body end", message);
|
|
348
349
|
};
|
|
349
|
-
return (bodySequence, end, diagnostic) =>
|
|
350
|
+
return async (bodySequence, end, diagnostic) => {
|
|
350
351
|
try {
|
|
351
352
|
const latestTurn = await readLatestTurnForBody(launch.paths, bodySequence);
|
|
352
353
|
const initiator = latestTurn?.initiator;
|
|
353
354
|
const participants = latestTurn === null ? [] : await readTurnParticipants(launch.paths, latestTurn.sequence);
|
|
354
|
-
|
|
355
|
-
world: await World.at(worldRootForAkumaPaths(launch.paths)),
|
|
356
|
-
reportDiagnostic,
|
|
357
|
-
});
|
|
358
|
-
const runtime = await plugins;
|
|
359
|
-
await runtime.emit({
|
|
355
|
+
await emitPluginSignal({ world, reportDiagnostic }, {
|
|
360
356
|
kind: "akuma.body-ended",
|
|
361
357
|
akumaId: soul.id,
|
|
362
358
|
bodySequence,
|
|
@@ -365,12 +361,12 @@ function bodyEndEmitter(launch, soul) {
|
|
|
365
361
|
...(participants.length === 0 ? {} : { participants }),
|
|
366
362
|
...(diagnostic === undefined ? {} : { diagnostic }),
|
|
367
363
|
...(launch.completion?.contractId === undefined ? {} : { contractId: launch.completion.contractId }),
|
|
368
|
-
}
|
|
364
|
+
});
|
|
369
365
|
}
|
|
370
366
|
catch (error) {
|
|
371
367
|
await recordPluginDiagnostic(launch.paths, "body end", error);
|
|
372
368
|
}
|
|
373
|
-
}
|
|
369
|
+
};
|
|
374
370
|
}
|
|
375
371
|
async function admitInitialCallTell(runtime, input) {
|
|
376
372
|
const paths = pathsForAkuId(runtime.world, input.id);
|
|
@@ -575,10 +571,25 @@ export async function driveAkumaBody(launch, adapter, runtimeInput = {}) {
|
|
|
575
571
|
const prepared = await prepareBodyExecution(launch, leash, runtime, adapter);
|
|
576
572
|
if (prepared === null)
|
|
577
573
|
return;
|
|
578
|
-
emitBodyEnd = bodyEndEmitter(launch, prepared.soul);
|
|
579
|
-
emitTurnOutcome = turnOutcomeEmitter(launch, prepared.soul);
|
|
574
|
+
emitBodyEnd = bodyEndEmitter(launch, prepared.soul, world);
|
|
575
|
+
emitTurnOutcome = turnOutcomeEmitter(launch, prepared.soul, world);
|
|
580
576
|
const body = await leash.recordBody(launch.paths, { leashTakenAt: runtime.now() });
|
|
581
577
|
bodySequence = body.sequence;
|
|
578
|
+
if (prepared.created) {
|
|
579
|
+
await emitPluginSignal({
|
|
580
|
+
world,
|
|
581
|
+
reportDiagnostic: (message) => {
|
|
582
|
+
void recordPluginDiagnostic(launch.paths, "birth", message);
|
|
583
|
+
},
|
|
584
|
+
}, {
|
|
585
|
+
kind: "akuma.born",
|
|
586
|
+
akumaId: prepared.soul.id,
|
|
587
|
+
bodySequence: body.sequence,
|
|
588
|
+
...projectAkumaBirth(prepared.soul),
|
|
589
|
+
...(launch.birthInitiator === undefined ? {} : { initiator: launch.birthInitiator }),
|
|
590
|
+
...(launch.completion?.contractId === undefined ? {} : { contractId: launch.completion.contractId }),
|
|
591
|
+
});
|
|
592
|
+
}
|
|
582
593
|
const supervisor = await BodySupervisor.open(launch.paths, body.sequence, leash);
|
|
583
594
|
pendingTellDisposition = await runPreparedBody({
|
|
584
595
|
launch,
|
|
@@ -33,6 +33,7 @@ declare const akumaCallRecipeSchema: z.ZodObject<{
|
|
|
33
33
|
"codex-app-server": "codex-app-server";
|
|
34
34
|
"grok-build": "grok-build";
|
|
35
35
|
"opencode-sdk": "opencode-sdk";
|
|
36
|
+
paseo: "paseo";
|
|
36
37
|
pi: "pi";
|
|
37
38
|
}>;
|
|
38
39
|
executable: z.ZodOptional<z.ZodString>;
|
|
@@ -43,10 +44,10 @@ declare const akumaCallRecipeSchema: z.ZodObject<{
|
|
|
43
44
|
config?: Readonly<Record<string, unknown>>;
|
|
44
45
|
executable?: string;
|
|
45
46
|
name: string;
|
|
46
|
-
kind: "acp" | "claude-agent-sdk" | "codex-app-server" | "grok-build" | "opencode-sdk" | "pi";
|
|
47
|
+
kind: "acp" | "claude-agent-sdk" | "codex-app-server" | "grok-build" | "opencode-sdk" | "paseo" | "pi";
|
|
47
48
|
}>, {
|
|
48
49
|
name: string;
|
|
49
|
-
kind: "acp" | "claude-agent-sdk" | "codex-app-server" | "grok-build" | "opencode-sdk" | "pi";
|
|
50
|
+
kind: "acp" | "claude-agent-sdk" | "codex-app-server" | "grok-build" | "opencode-sdk" | "paseo" | "pi";
|
|
50
51
|
executable?: string | undefined;
|
|
51
52
|
config?: Record<string, unknown> | undefined;
|
|
52
53
|
env?: Record<string, string> | undefined;
|
|
@@ -60,11 +61,11 @@ declare const akumaCallRecipeSchema: z.ZodObject<{
|
|
|
60
61
|
}>>;
|
|
61
62
|
systemPrompt: z.ZodOptional<z.ZodString>;
|
|
62
63
|
systemPromptMode: z.ZodOptional<z.ZodEnum<{
|
|
63
|
-
append: "append";
|
|
64
64
|
replace: "replace";
|
|
65
|
+
append: "append";
|
|
65
66
|
}>>;
|
|
66
67
|
}, z.core.$strip>, z.ZodTransform<Readonly<{
|
|
67
|
-
systemPromptMode?: "
|
|
68
|
+
systemPromptMode?: "replace" | "append";
|
|
68
69
|
systemPrompt?: string;
|
|
69
70
|
network?: "disabled" | "enabled";
|
|
70
71
|
effort?: string;
|
|
@@ -74,7 +75,7 @@ declare const akumaCallRecipeSchema: z.ZodObject<{
|
|
|
74
75
|
effort?: string | undefined;
|
|
75
76
|
network?: "disabled" | "enabled" | undefined;
|
|
76
77
|
systemPrompt?: string | undefined;
|
|
77
|
-
systemPromptMode?: "
|
|
78
|
+
systemPromptMode?: "replace" | "append" | undefined;
|
|
78
79
|
}>>;
|
|
79
80
|
}, z.core.$strict>;
|
|
80
81
|
declare const akumaCallPayloadSchema: z.ZodObject<{
|
|
@@ -86,6 +87,8 @@ declare const akumaCallPayloadSchema: z.ZodObject<{
|
|
|
86
87
|
schemaJson: z.ZodOptional<z.ZodString>;
|
|
87
88
|
initiator: z.ZodOptional<z.ZodString>;
|
|
88
89
|
}, z.core.$strict>>;
|
|
90
|
+
birthInitiator: z.ZodOptional<z.ZodString>;
|
|
91
|
+
contractId: z.ZodOptional<z.ZodString>;
|
|
89
92
|
cwd: z.ZodOptional<z.ZodString>;
|
|
90
93
|
recipe: z.ZodObject<{
|
|
91
94
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -115,6 +118,7 @@ declare const akumaCallPayloadSchema: z.ZodObject<{
|
|
|
115
118
|
"codex-app-server": "codex-app-server";
|
|
116
119
|
"grok-build": "grok-build";
|
|
117
120
|
"opencode-sdk": "opencode-sdk";
|
|
121
|
+
paseo: "paseo";
|
|
118
122
|
pi: "pi";
|
|
119
123
|
}>;
|
|
120
124
|
executable: z.ZodOptional<z.ZodString>;
|
|
@@ -125,10 +129,10 @@ declare const akumaCallPayloadSchema: z.ZodObject<{
|
|
|
125
129
|
config?: Readonly<Record<string, unknown>>;
|
|
126
130
|
executable?: string;
|
|
127
131
|
name: string;
|
|
128
|
-
kind: "acp" | "claude-agent-sdk" | "codex-app-server" | "grok-build" | "opencode-sdk" | "pi";
|
|
132
|
+
kind: "acp" | "claude-agent-sdk" | "codex-app-server" | "grok-build" | "opencode-sdk" | "paseo" | "pi";
|
|
129
133
|
}>, {
|
|
130
134
|
name: string;
|
|
131
|
-
kind: "acp" | "claude-agent-sdk" | "codex-app-server" | "grok-build" | "opencode-sdk" | "pi";
|
|
135
|
+
kind: "acp" | "claude-agent-sdk" | "codex-app-server" | "grok-build" | "opencode-sdk" | "paseo" | "pi";
|
|
132
136
|
executable?: string | undefined;
|
|
133
137
|
config?: Record<string, unknown> | undefined;
|
|
134
138
|
env?: Record<string, string> | undefined;
|
|
@@ -142,11 +146,11 @@ declare const akumaCallPayloadSchema: z.ZodObject<{
|
|
|
142
146
|
}>>;
|
|
143
147
|
systemPrompt: z.ZodOptional<z.ZodString>;
|
|
144
148
|
systemPromptMode: z.ZodOptional<z.ZodEnum<{
|
|
145
|
-
append: "append";
|
|
146
149
|
replace: "replace";
|
|
150
|
+
append: "append";
|
|
147
151
|
}>>;
|
|
148
152
|
}, z.core.$strip>, z.ZodTransform<Readonly<{
|
|
149
|
-
systemPromptMode?: "
|
|
153
|
+
systemPromptMode?: "replace" | "append";
|
|
150
154
|
systemPrompt?: string;
|
|
151
155
|
network?: "disabled" | "enabled";
|
|
152
156
|
effort?: string;
|
|
@@ -156,7 +160,7 @@ declare const akumaCallPayloadSchema: z.ZodObject<{
|
|
|
156
160
|
effort?: string | undefined;
|
|
157
161
|
network?: "disabled" | "enabled" | undefined;
|
|
158
162
|
systemPrompt?: string | undefined;
|
|
159
|
-
systemPromptMode?: "
|
|
163
|
+
systemPromptMode?: "replace" | "append" | undefined;
|
|
160
164
|
}>>;
|
|
161
165
|
}, z.core.$strict>;
|
|
162
166
|
}, z.core.$strict>;
|
|
@@ -167,6 +171,10 @@ export type AkumaCallRequest = z.infer<typeof akumaCallPayloadSchema> & Readonly
|
|
|
167
171
|
export type AkumaCallRequestChildLaunch = Readonly<{
|
|
168
172
|
paths: AkumaPaths;
|
|
169
173
|
seed: Omit<Soul, "createdAt">;
|
|
174
|
+
birthInitiator?: string;
|
|
175
|
+
completion?: Readonly<{
|
|
176
|
+
contractId?: string;
|
|
177
|
+
}>;
|
|
170
178
|
}>;
|
|
171
179
|
export type InitialTellAdmissionRequest = Readonly<{
|
|
172
180
|
id: AkuId;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { isAbsolute, resolve } from "node:path";
|
|
2
2
|
import { allowedActionsSchema } from "./allowed.js";
|
|
3
3
|
import { refuseRequest, reserveRequest } from "./heart/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { validateAkumaName } from "../identity/normalize.js";
|
|
5
|
+
import { akumaIdSchema } from "./identity.js";
|
|
5
6
|
import { callDiagnostic, executePreparedCall } from "./publication.js";
|
|
6
7
|
import { tellResultSchema } from "./call-initial-tell.js";
|
|
7
8
|
import { providerOptionsSchema, providerRecipeSchema } from "./provider-recipe.js";
|
|
@@ -11,7 +12,7 @@ import { z } from "zod";
|
|
|
11
12
|
const absolutePathSchema = z.string().refine((value) => isAbsolute(value) && resolve(value) === value);
|
|
12
13
|
const archetypeSchema = z.string().transform((value, context) => {
|
|
13
14
|
try {
|
|
14
|
-
return
|
|
15
|
+
return validateAkumaName(value);
|
|
15
16
|
}
|
|
16
17
|
catch {
|
|
17
18
|
context.addIssue({ code: "custom", message: "expected Akuma name" });
|
|
@@ -39,6 +40,8 @@ const akumaCallPayloadSchema = z
|
|
|
39
40
|
world: absolutePathSchema,
|
|
40
41
|
archetype: archetypeSchema,
|
|
41
42
|
initialTell: initialTellSchema.optional(),
|
|
43
|
+
birthInitiator: z.string().optional(),
|
|
44
|
+
contractId: z.string().optional(),
|
|
42
45
|
cwd: absolutePathSchema.optional(),
|
|
43
46
|
recipe: akumaCallRecipeSchema,
|
|
44
47
|
})
|
|
@@ -95,7 +98,11 @@ async function executeAkumaCall(request, facts, capabilities) {
|
|
|
95
98
|
refuse: async (diagnostic) => {
|
|
96
99
|
await refuseRequest(paths, facts.id, diagnostic);
|
|
97
100
|
},
|
|
98
|
-
spawn
|
|
101
|
+
spawn: async (launch) => await spawn({
|
|
102
|
+
...launch,
|
|
103
|
+
...(request.birthInitiator === undefined ? {} : { birthInitiator: request.birthInitiator }),
|
|
104
|
+
...(request.contractId === undefined ? {} : { completion: { contractId: request.contractId } }),
|
|
105
|
+
}),
|
|
99
106
|
admitInitialTell,
|
|
100
107
|
},
|
|
101
108
|
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { WorldRoot } from "../world.js";
|
|
3
|
+
import { type Soul } from "./heart/facts.js";
|
|
4
|
+
export declare const akumaCallerSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
5
|
+
kind: z.ZodLiteral<"akuma">;
|
|
6
|
+
world: z.ZodCustom<WorldRoot, WorldRoot>;
|
|
7
|
+
akuId: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
|
|
8
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
9
|
+
kind: z.ZodLiteral<"external">;
|
|
10
|
+
integration: z.ZodString;
|
|
11
|
+
id: z.ZodString;
|
|
12
|
+
}, z.core.$strict>], "kind">;
|
|
13
|
+
export type AkumaCaller = z.infer<typeof akumaCallerSchema>;
|
|
14
|
+
export declare const akumaBirthSchema: z.ZodObject<{
|
|
15
|
+
origin: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
16
|
+
kind: z.ZodLiteral<"direct">;
|
|
17
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
18
|
+
kind: z.ZodLiteral<"request">;
|
|
19
|
+
parent: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
|
|
20
|
+
requestId: z.ZodString;
|
|
21
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
22
|
+
kind: z.ZodLiteral<"fork">;
|
|
23
|
+
parent: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
|
|
24
|
+
at: z.ZodString;
|
|
25
|
+
}, z.core.$strip>], "kind">;
|
|
26
|
+
caller: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
27
|
+
kind: z.ZodLiteral<"akuma">;
|
|
28
|
+
world: z.ZodCustom<WorldRoot, WorldRoot>;
|
|
29
|
+
akuId: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
|
|
30
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
31
|
+
kind: z.ZodLiteral<"external">;
|
|
32
|
+
integration: z.ZodString;
|
|
33
|
+
id: z.ZodString;
|
|
34
|
+
}, z.core.$strict>], "kind">, z.ZodObject<{
|
|
35
|
+
kind: z.ZodLiteral<"unknown">;
|
|
36
|
+
}, z.core.$strict>]>;
|
|
37
|
+
}, z.core.$strict>;
|
|
38
|
+
export declare function projectAkumaBirth(soul: Soul): z.infer<typeof akumaBirthSchema>;
|
|
39
|
+
export declare function decodeAkumaCaller(value: unknown): AkumaCaller | undefined;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { isAbsolute, resolve } from "node:path";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { akumaIdSchema } from "./identity.js";
|
|
4
|
+
import { akumaOriginSchema } from "./heart/facts.js";
|
|
5
|
+
// Stored attribution is a coordinate, not a live World capability or lookup.
|
|
6
|
+
const callerWorldSchema = z.custom((value) => typeof value === "string" && isAbsolute(value) && resolve(value) === value, "caller world must be an absolute normalized path");
|
|
7
|
+
export const akumaCallerSchema = z.discriminatedUnion("kind", [
|
|
8
|
+
z.object({ kind: z.literal("akuma"), world: callerWorldSchema, akuId: akumaIdSchema }).strict(),
|
|
9
|
+
z
|
|
10
|
+
.object({
|
|
11
|
+
kind: z.literal("external"),
|
|
12
|
+
integration: z.string().regex(/^[a-z][a-z0-9._-]{0,63}$/u),
|
|
13
|
+
id: z
|
|
14
|
+
.string()
|
|
15
|
+
.max(512)
|
|
16
|
+
.refine((value) => value.trim().length > 0 && !/[\u0000-\u001f\u007f-\u009f]/u.test(value), "external caller id must be nonblank and contain no control characters"),
|
|
17
|
+
})
|
|
18
|
+
.strict(),
|
|
19
|
+
]);
|
|
20
|
+
export const akumaBirthSchema = z
|
|
21
|
+
.object({
|
|
22
|
+
origin: akumaOriginSchema,
|
|
23
|
+
caller: z.union([akumaCallerSchema, z.object({ kind: z.literal("unknown") }).strict()]),
|
|
24
|
+
})
|
|
25
|
+
.strict();
|
|
26
|
+
export function projectAkumaBirth(soul) {
|
|
27
|
+
return { origin: soul.origin, caller: soul.caller ?? { kind: "unknown" } };
|
|
28
|
+
}
|
|
29
|
+
export function decodeAkumaCaller(value) {
|
|
30
|
+
if (value === undefined)
|
|
31
|
+
return undefined;
|
|
32
|
+
const parsed = akumaCallerSchema.safeParse(value);
|
|
33
|
+
if (!parsed.success)
|
|
34
|
+
throw new TypeError(`Invalid Akuma caller: ${parsed.error.message}`);
|
|
35
|
+
return parsed.data;
|
|
36
|
+
}
|
|
@@ -10,4 +10,3 @@ export declare const dispatchAssociationSchema: z.ZodUnion<readonly [z.ZodObject
|
|
|
10
10
|
}, z.core.$strict>]>;
|
|
11
11
|
export type DispatchAssociation = z.infer<typeof dispatchAssociationSchema>;
|
|
12
12
|
export declare const NO_DISPATCH_ASSOCIATION: DispatchAssociation;
|
|
13
|
-
export declare function parseDispatchAssociation(value: unknown): DispatchAssociation;
|
|
@@ -6,6 +6,3 @@ export const dispatchAssociationSchema = z.union([
|
|
|
6
6
|
z.object({ kind: z.literal("failed"), diagnostic: z.string() }).strict(),
|
|
7
7
|
]);
|
|
8
8
|
export const NO_DISPATCH_ASSOCIATION = { kind: "none" };
|
|
9
|
-
export function parseDispatchAssociation(value) {
|
|
10
|
-
return dispatchAssociationSchema.parse(value);
|
|
11
|
-
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AkumaCaller } from "../caller.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { type AkuId } from "../identity.js";
|
|
2
4
|
import type { ResumeCoordinate } from "../coordinate.js";
|
|
3
5
|
import type { ProviderExecution, ProviderOptions } from "../provider-recipe.js";
|
|
4
6
|
import type { AllowedActions } from "../allowed.js";
|
|
@@ -6,17 +8,18 @@ export type { ResumeCoordinate } from "../coordinate.js";
|
|
|
6
8
|
export declare class HeartAuthorityCorruptionError extends Error {
|
|
7
9
|
constructor(message: string, options?: ErrorOptions);
|
|
8
10
|
}
|
|
9
|
-
export
|
|
10
|
-
kind: "direct"
|
|
11
|
-
}
|
|
12
|
-
kind: "request"
|
|
13
|
-
parent: AkuId
|
|
14
|
-
requestId:
|
|
15
|
-
}
|
|
16
|
-
kind: "fork"
|
|
17
|
-
parent: AkuId
|
|
18
|
-
at:
|
|
19
|
-
}>;
|
|
11
|
+
export declare const akumaOriginSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
12
|
+
kind: z.ZodLiteral<"direct">;
|
|
13
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
14
|
+
kind: z.ZodLiteral<"request">;
|
|
15
|
+
parent: z.ZodPipe<z.ZodString, z.ZodTransform<AkuId, string>>;
|
|
16
|
+
requestId: z.ZodString;
|
|
17
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
18
|
+
kind: z.ZodLiteral<"fork">;
|
|
19
|
+
parent: z.ZodPipe<z.ZodString, z.ZodTransform<AkuId, string>>;
|
|
20
|
+
at: z.ZodString;
|
|
21
|
+
}, z.core.$strip>], "kind">;
|
|
22
|
+
export type AkumaOrigin = z.infer<typeof akumaOriginSchema>;
|
|
20
23
|
export type Soul = Readonly<{
|
|
21
24
|
id: AkuId;
|
|
22
25
|
archetype: string;
|
|
@@ -25,6 +28,7 @@ export type Soul = Readonly<{
|
|
|
25
28
|
options: ProviderOptions;
|
|
26
29
|
cwd: string;
|
|
27
30
|
origin: AkumaOrigin;
|
|
31
|
+
caller?: AkumaCaller;
|
|
28
32
|
allowed: AllowedActions;
|
|
29
33
|
createdAt: string;
|
|
30
34
|
}>;
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { akumaIdSchema } from "../identity.js";
|
|
1
3
|
export class HeartAuthorityCorruptionError extends Error {
|
|
2
4
|
constructor(message, options) {
|
|
3
5
|
super(message, options);
|
|
4
6
|
this.name = "HeartAuthorityCorruptionError";
|
|
5
7
|
}
|
|
6
8
|
}
|
|
9
|
+
const originText = z.string().refine((value) => value.trim().length > 0);
|
|
10
|
+
export const akumaOriginSchema = z.discriminatedUnion("kind", [
|
|
11
|
+
z.object({ kind: z.literal("direct") }),
|
|
12
|
+
z.object({ kind: z.literal("request"), parent: akumaIdSchema, requestId: originText }),
|
|
13
|
+
z.object({ kind: z.literal("fork"), parent: akumaIdSchema, at: originText }),
|
|
14
|
+
]);
|
|
7
15
|
export function projectTell(fact) {
|
|
8
16
|
return {
|
|
9
17
|
kind: "tell",
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import type { AkumaPaths } from "../identity.js";
|
|
2
2
|
import type { BodyEnd, BodyFact, ForkPoint, HeartSnapshot, KillFact, SealFact, SessionFact, Soul, TellDeliveryInput, TellFact, TellReceiptInput, TurnEndFact, TurnFact, TurnOutcome, TurnStartFact } from "./facts.js";
|
|
3
|
-
export type { CallFact } from "./facts.js";
|
|
4
|
-
import type { ActivityFact } from "./rows.js";
|
|
5
3
|
import type { AgentEvent } from "./activity-schema.js";
|
|
6
4
|
import { type StatusFactInput, type ActivityFactSlice } from "./timeline.js";
|
|
7
5
|
export { HeartAbsentError, HeldAkumaLeash, classifyHeartSchema, initializeHeart, isHeartAbsent, probeLeash, } from "./storage.js";
|
|
8
6
|
export { admitRequest, beginRequest, isRequestInputConflict, readNonterminalRequests, readRequest, refuseRequest, reserveRequest, serveRequest, serveUpstreamRequest, unproveRequest, voidRequest, } from "./request-authority.js";
|
|
9
7
|
export { AkumaBusyError, life, lifeAt, projectTell } from "./facts.js";
|
|
10
8
|
export { drainPendingTells } from "./tells.js";
|
|
11
|
-
export type { AkumaLife, AkumaOrigin, BodyEnd,
|
|
9
|
+
export type { AkumaLife, AkumaOrigin, BodyEnd, HeartSnapshot, KillEvidence, RequestFact, SessionFact, Soul, TellFact, TurnEndFact, TurnOutcome, } from "./facts.js";
|
|
12
10
|
export type { ResumeCoordinate } from "../coordinate.js";
|
|
13
11
|
export declare function readSoul(paths: AkumaPaths): Promise<Soul | null>;
|
|
14
12
|
export declare function heartExists(paths: AkumaPaths): Promise<boolean>;
|
|
@@ -19,8 +17,7 @@ export declare function appendActivity(paths: AkumaPaths, input: Readonly<{
|
|
|
19
17
|
event: AgentEvent;
|
|
20
18
|
at: string;
|
|
21
19
|
}>): Promise<number>;
|
|
22
|
-
|
|
23
|
-
export type { ActivityFact };
|
|
20
|
+
type ActivitySlice = ActivityFactSlice;
|
|
24
21
|
export type { TimelineFact } from "./timeline.js";
|
|
25
22
|
export declare function activitySlice(paths: AkumaPaths): Promise<ActivitySlice>;
|
|
26
23
|
export declare function readStatusFacts(paths: AkumaPaths, input: StatusFactInput, signal?: AbortSignal): Promise<ActivitySlice["rows"]>;
|
|
@@ -74,8 +71,6 @@ export declare function requestPause(paths: AkumaPaths, at: string, signal?: Abo
|
|
|
74
71
|
kind: "requested";
|
|
75
72
|
body: BodyFact;
|
|
76
73
|
}>>;
|
|
77
|
-
export declare function stopRequested(paths: AkumaPaths, bodySequence?: number): Promise<boolean>;
|
|
78
|
-
export declare function pauseRequested(paths: AkumaPaths, bodySequence?: number): Promise<boolean>;
|
|
79
74
|
export declare function breakBody(paths: AkumaPaths, input: Readonly<{
|
|
80
75
|
sequence: number;
|
|
81
76
|
end: Exclude<BodyEnd, "exited">;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { parsePublicHistoryId } from "../identity.js";
|
|
2
2
|
import { answeredTurnFact, endBodyFact, finishBodyFact, deleteStopControl, insertActivityFact, insertTurnEndFact, insertTurnStartFact, insertPauseControl, insertKillFact, insertSessionFact, insertStopControl, killFactForBody, latestBodyFact, latestKillFact, latestSessionFact, latestTurnFactForBody, lastAnsweredTurnFact, pauseFact, sessionFactForCoordinate, stopFact, turnFact, } from "./rows.js";
|
|
3
|
-
import { insertTellDeliveryFact, dispositionSnapshotProven, insertTellBindingFact, insertTellDispositionSnapshot,
|
|
3
|
+
import { insertTellDeliveryFact, dispositionSnapshotProven, insertTellBindingFact, insertTellDispositionSnapshot, insertTellReceiptFact, insertUndeliveredTellReceipts, latestOpenTellDisposition, openBoundTurns, openTellDispositionIds, pendingTellFacts, hasPendingTell, resolveTellDispositionSnapshot, tellDispositionResolved, tellFact, tellIdsForFence, turnParticipants, } from "./tells.js";
|
|
4
4
|
import { activityFactSlice, statusFacts, readStatusBatch, decodeTimelineBatch, lastActivityAt as readLastActivityAt, pruneActivityFacts, } from "./timeline.js";
|
|
5
|
-
import { isHeartAbsent, readSealFromLeash, withHeartTransaction, withReadOnlyHeart } from "./storage.js";
|
|
5
|
+
import { isHeartAbsent, readSealFromLeash, recordPendingTell, withHeartTransaction, withReadOnlyHeart, } from "./storage.js";
|
|
6
6
|
import { soulFact } from "./soul.js";
|
|
7
7
|
import { AkumaBusyError, HeartAuthorityCorruptionError } from "./facts.js";
|
|
8
8
|
export { HeartAbsentError, HeldAkumaLeash, classifyHeartSchema, initializeHeart, isHeartAbsent, probeLeash, } from "./storage.js";
|
|
@@ -138,9 +138,7 @@ export async function recordTell(paths, tell, options = {}) {
|
|
|
138
138
|
const running = body !== null && body.end === undefined && body.hung === undefined;
|
|
139
139
|
if (tell.schemaJson !== undefined && running && options.interrupt !== true)
|
|
140
140
|
throw new AkumaBusyError();
|
|
141
|
-
|
|
142
|
-
pruneActivityFacts(heart, ACTIVITY_LIMIT);
|
|
143
|
-
return { kind: "recorded", tell: { sequence, ...tell, state: "pending", deliveries: [] } };
|
|
141
|
+
return recordPendingTell(heart, tell);
|
|
144
142
|
});
|
|
145
143
|
}
|
|
146
144
|
export async function readTell(paths, id) {
|
|
@@ -256,18 +254,6 @@ export async function requestPause(paths, at, signal) {
|
|
|
256
254
|
return { kind: "requested", body };
|
|
257
255
|
}, signal);
|
|
258
256
|
}
|
|
259
|
-
export async function stopRequested(paths, bodySequence) {
|
|
260
|
-
return await withReadOnlyHeart(paths, (heart) => {
|
|
261
|
-
const target = stopFact(heart);
|
|
262
|
-
return target !== null && (bodySequence === undefined || target.bodySequence === bodySequence);
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
export async function pauseRequested(paths, bodySequence) {
|
|
266
|
-
return await withReadOnlyHeart(paths, (heart) => {
|
|
267
|
-
const target = pauseFact(heart);
|
|
268
|
-
return target !== null && (bodySequence === undefined || target.bodySequence === bodySequence);
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
257
|
export async function breakBody(paths, input) {
|
|
272
258
|
await withHeartTransaction(paths, (heart) => endBodyFact(heart, input));
|
|
273
259
|
}
|
|
@@ -41,11 +41,11 @@ export declare const sessionAdmissionSchema: z.ZodObject<{
|
|
|
41
41
|
}>>;
|
|
42
42
|
systemPrompt: z.ZodOptional<z.ZodString>;
|
|
43
43
|
systemPromptMode: z.ZodOptional<z.ZodEnum<{
|
|
44
|
-
append: "append";
|
|
45
44
|
replace: "replace";
|
|
45
|
+
append: "append";
|
|
46
46
|
}>>;
|
|
47
47
|
}, z.core.$strip>, z.ZodTransform<Readonly<{
|
|
48
|
-
systemPromptMode?: "
|
|
48
|
+
systemPromptMode?: "replace" | "append";
|
|
49
49
|
systemPrompt?: string;
|
|
50
50
|
network?: "disabled" | "enabled";
|
|
51
51
|
effort?: string;
|
|
@@ -55,7 +55,7 @@ export declare const sessionAdmissionSchema: z.ZodObject<{
|
|
|
55
55
|
effort?: string | undefined;
|
|
56
56
|
network?: "disabled" | "enabled" | undefined;
|
|
57
57
|
systemPrompt?: string | undefined;
|
|
58
|
-
systemPromptMode?: "
|
|
58
|
+
systemPromptMode?: "replace" | "append" | undefined;
|
|
59
59
|
}>>;
|
|
60
60
|
admittedAt: z.ZodString;
|
|
61
61
|
}, z.core.$strict>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DatabaseSync } from "node:sqlite";
|
|
2
|
-
import type
|
|
2
|
+
import { type Soul, type SoulRow } from "./facts.js";
|
|
3
3
|
export declare function decodeSoulSeed(value: unknown): Omit<Soul, "createdAt">;
|
|
4
4
|
export declare function decodeSoul(value: unknown): Soul;
|
|
5
5
|
export declare function encodeSoul(soul: Soul): string;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { decodeAkumaCaller } from "../caller.js";
|
|
1
2
|
import { parseAkuId } from "../identity.js";
|
|
2
3
|
import { decodeProviderOptions, decodeProviderRecipe } from "../provider-recipe.js";
|
|
4
|
+
import { akumaOriginSchema } from "./facts.js";
|
|
3
5
|
import { historicalAllowedActions } from "../allowed.js";
|
|
4
6
|
function record(value) {
|
|
5
7
|
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
@@ -20,29 +22,6 @@ function soulAkuIdentity(value, what) {
|
|
|
20
22
|
throw new Error(`Akuma soul ${what} is not an Akuma identity coordinate`, { cause: error });
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
|
-
function decodeOrigin(value) {
|
|
24
|
-
const origin = record(value);
|
|
25
|
-
if (origin === null)
|
|
26
|
-
throw new Error("Akuma soul origin must be an object");
|
|
27
|
-
if (origin.kind === "direct") {
|
|
28
|
-
return { kind: "direct" };
|
|
29
|
-
}
|
|
30
|
-
if (origin.kind === "request") {
|
|
31
|
-
return {
|
|
32
|
-
kind: "request",
|
|
33
|
-
parent: soulAkuIdentity(origin.parent, "request parent").id,
|
|
34
|
-
requestId: nonblank(origin.requestId, "request requestId"),
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
if (origin.kind === "fork") {
|
|
38
|
-
return {
|
|
39
|
-
kind: "fork",
|
|
40
|
-
parent: soulAkuIdentity(origin.parent, "fork parent").id,
|
|
41
|
-
at: nonblank(origin.at, "fork at"),
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
throw new Error("Akuma soul origin must be direct, request, or fork");
|
|
45
|
-
}
|
|
46
25
|
export function decodeSoulSeed(value) {
|
|
47
26
|
const soul = record(value);
|
|
48
27
|
if (soul === null)
|
|
@@ -55,6 +34,7 @@ export function decodeSoulSeed(value) {
|
|
|
55
34
|
const description = soul.description === undefined ? undefined : nonblank(soul.description, "description");
|
|
56
35
|
const provider = decodeProviderRecipe(soul.provider);
|
|
57
36
|
const options = decodeProviderOptions(soul.options);
|
|
37
|
+
const caller = decodeAkumaCaller(soul.caller);
|
|
58
38
|
return {
|
|
59
39
|
id,
|
|
60
40
|
archetype,
|
|
@@ -62,7 +42,8 @@ export function decodeSoulSeed(value) {
|
|
|
62
42
|
provider,
|
|
63
43
|
options,
|
|
64
44
|
cwd: nonblank(soul.cwd, "cwd"),
|
|
65
|
-
origin:
|
|
45
|
+
origin: akumaOriginSchema.parse(soul.origin),
|
|
46
|
+
...(caller === undefined ? {} : { caller }),
|
|
66
47
|
allowed: historicalAllowedActions(soul.allowed),
|
|
67
48
|
};
|
|
68
49
|
}
|