@astrosheep/keiyaku 4.6.32 → 4.6.33
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 +8 -6
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +13 -9
- package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +8 -6
- package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +2 -1
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +13 -9
- package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +8 -6
- package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +2 -1
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +13 -9
- package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +8 -6
- package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +2 -1
- package/build/plugins/pi/README.md +55 -97
- package/build/plugins/pi/keiyaku.ts +2 -9
- package/build/skills/keiyaku-akuma/SKILL.md +13 -9
- package/build/skills/keiyaku-babysit/SKILL.md +8 -6
- package/build/skills/keiyaku-workflow/SKILL.md +2 -1
- package/build/src/akuma/akuma-instance.d.ts +11 -0
- package/build/src/akuma/akuma-instance.js +1 -2
- package/build/src/akuma/akuma-observe.js +73 -14
- package/build/src/akuma/akuma-selection-execution.d.ts +82 -7
- package/build/src/akuma/akuma-selection-execution.js +26 -27
- package/build/src/akuma/akuma-wait.d.ts +40 -1
- package/build/src/akuma/akuma-wait.js +58 -29
- package/build/src/akuma/akuma.d.ts +11 -0
- package/build/src/akuma/body.js +13 -18
- package/build/src/akuma/call-initial-tell.d.ts +0 -1
- package/build/src/akuma/call-initial-tell.js +0 -1
- package/build/src/akuma/heart/activity-schema.d.ts +16 -0
- package/build/src/akuma/heart/activity-schema.js +7 -0
- package/build/src/akuma/heart/index.d.ts +1 -1
- package/build/src/akuma/heart/index.js +9 -1
- package/build/src/akuma/heart/timeline.js +4 -4
- package/build/src/akuma/projection-read.d.ts +4 -2
- package/build/src/akuma/projection-read.js +21 -14
- package/build/src/akuma/projection.d.ts +94 -2
- package/build/src/akuma/projection.js +47 -47
- package/build/src/akuma/provider.d.ts +2 -2
- package/build/src/akuma/provider.js +27 -20
- package/build/src/akuma/providers/acp/core.js +2 -5
- package/build/src/akuma/providers/opencode-sdk/events.d.ts +2 -1
- package/build/src/akuma/providers/opencode-sdk/events.js +31 -1
- package/build/src/akuma/publication.js +3 -2
- package/build/src/akuma/selection-observation.d.ts +23 -0
- package/build/src/akuma/selection-observation.js +15 -4
- package/build/src/akuma/status-projection.d.ts +14 -1
- package/build/src/akuma/status-projection.js +40 -2
- package/build/src/akuma/turn-drive.js +21 -15
- package/build/src/body/amend.js +5 -17
- package/build/src/body/decode.js +11 -1
- package/build/src/body/envelope.d.ts +5 -1
- package/build/src/body/envelope.js +4 -2
- package/build/src/body/render.js +4 -6
- package/build/src/cli/commands/akuma-grammar.d.ts +3 -5
- package/build/src/cli/commands/akuma-grammar.js +22 -40
- package/build/src/cli/commands/akuma.d.ts +1 -2
- package/build/src/cli/commands/akuma.js +6 -58
- package/build/src/cli/commands/contract-grammar.d.ts +1 -0
- package/build/src/cli/commands/contract-grammar.js +7 -11
- package/build/src/cli/commands/contract-help.d.ts +3 -2
- package/build/src/cli/commands/contract-help.js +11 -5
- package/build/src/cli/commands/contract.js +3 -0
- package/build/src/cli/commands/debt-grammar.js +2 -4
- package/build/src/cli/parse.js +1 -4
- package/build/src/cli/render/akuma-activity.d.ts +3 -15
- package/build/src/cli/render/akuma-activity.js +19 -73
- package/build/src/cli/render/akuma.d.ts +5 -11
- package/build/src/cli/render/akuma.js +22 -30
- package/build/src/cli/render/catalog.js +1 -4
- package/build/src/cli/render/contract-history.js +2 -0
- package/build/src/cli/render/contract-observation.d.ts +2 -1
- package/build/src/cli/render/contract-observation.js +25 -1
- package/build/src/cli/render/contract-wait.d.ts +2 -2
- package/build/src/cli/render/contract-wait.js +13 -17
- package/build/src/cli/render/contract.js +12 -9
- package/build/src/cli/render/debt.js +1 -2
- package/build/src/cli/render/execution-progress.js +1 -3
- package/build/src/cli/render/kanshi-akuma.js +1 -2
- package/build/src/cli/render/kanshi.js +11 -17
- package/build/src/cli/render/receipt.d.ts +1 -1
- package/build/src/cli/render/receipt.js +33 -28
- package/build/src/cli/render/reconcile.js +2 -5
- package/build/src/cli/render/refusal.js +3 -6
- package/build/src/cli/render/terminal.d.ts +2 -4
- package/build/src/cli/render/terminal.js +10 -17
- package/build/src/cli/render/verbs.d.ts +1 -0
- package/build/src/cli/render/verbs.js +19 -17
- package/build/src/cli/runtime.js +3 -9
- package/build/src/core/facts/codec.js +7 -2
- package/build/src/core/facts/eligibility.d.ts +4 -4
- package/build/src/core/facts/eligibility.js +11 -0
- package/build/src/core/facts/fold.js +9 -5
- package/build/src/core/facts/gate.d.ts +5 -1
- package/build/src/core/facts/gate.js +14 -10
- package/build/src/core/facts/types.d.ts +5 -1
- package/build/src/core/facts/types.js +7 -0
- package/build/src/core/subject.d.ts +4 -1
- package/build/src/core/subject.js +10 -2
- package/build/src/core/verbs/amend.d.ts +15 -4
- package/build/src/core/verbs/amend.js +19 -9
- package/build/src/debt/index.d.ts +0 -1
- package/build/src/debt/index.js +6 -11
- package/build/src/debt/input.d.ts +2 -1
- package/build/src/debt/input.js +6 -4
- package/build/src/dispatch/index.d.ts +0 -17
- package/build/src/dispatch/index.js +1 -10
- package/build/src/git/identity.js +16 -45
- package/build/src/git/nuke.js +13 -23
- package/build/src/git/observe.d.ts +3 -0
- package/build/src/git/observe.js +25 -23
- package/build/src/git/process.js +11 -18
- package/build/src/git/read-observation.d.ts +5 -4
- package/build/src/git/repository.d.ts +2 -0
- package/build/src/git/repository.js +13 -1
- package/build/src/git/scratch.js +2 -14
- package/build/src/git/terminal-reconcile.js +1 -13
- package/build/src/index.d.ts +2 -0
- package/build/src/kanshi/index.d.ts +0 -1
- package/build/src/kanshi/index.js +0 -1
- package/build/src/kanshi/read.d.ts +21 -0
- package/build/src/kanshi/read.js +2 -1
- package/build/src/kanshi/report.d.ts +94 -0
- package/build/src/library/address.d.ts +12 -5
- package/build/src/library/address.js +18 -32
- package/build/src/library/akuma-creation.d.ts +39 -0
- package/build/src/library/akuma-creation.js +3 -9
- package/build/src/library/continuation.d.ts +10 -0
- package/build/src/library/contract-creation.js +10 -11
- package/build/src/library/contract-outcomes.d.ts +72 -1
- package/build/src/library/contract-outcomes.js +1 -0
- package/build/src/library/contract-types.d.ts +18 -0
- package/build/src/library/contract-types.js +2 -0
- package/build/src/library/contract-wait.d.ts +7 -0
- package/build/src/library/contract-wait.js +53 -49
- package/build/src/library/delivery.d.ts +25 -0
- package/build/src/library/input.d.ts +5 -23
- package/build/src/library/input.js +12 -7
- package/build/src/library/kei.js +39 -20
- package/build/src/library/keiyaku-classify.js +3 -3
- package/build/src/library/keiyaku-debt.js +1 -2
- package/build/src/library/keiyaku-identity.d.ts +3 -3
- package/build/src/library/keiyaku-identity.js +11 -6
- package/build/src/library/keiyaku-verbs.d.ts +456 -1362
- package/build/src/library/keiyaku-verbs.js +80 -92
- package/build/src/library/keiyaku-wait.d.ts +183 -0
- package/build/src/library/keiyaku-wait.js +213 -0
- package/build/src/library/keiyaku.d.ts +3 -1
- package/build/src/library/keiyaku.js +49 -73
- package/build/src/{mcp/output.d.ts → library/model-tools.d.ts} +227 -56
- package/build/src/library/model-tools.js +347 -0
- package/build/src/library/outcome.js +5 -6
- package/build/src/library/refusal.d.ts +25 -1
- package/build/src/library/refusal.js +4 -5
- package/build/src/library/selection.d.ts +12 -0
- package/build/src/library/selection.js +1 -2
- package/build/src/mcp/adapter.d.ts +0 -6
- package/build/src/mcp/adapter.js +10 -159
- package/build/src/mcp/description.d.ts +2 -0
- package/build/src/mcp/description.js +2 -0
- package/build/src/mcp/help.d.ts +1 -1
- package/build/src/mcp/help.js +6 -4
- package/build/src/pi/index.d.ts +3 -0
- package/build/src/pi/index.js +83 -0
- package/build/src/protocol/amend.d.ts +14 -3
- package/build/src/protocol/amend.js +113 -46
- package/build/src/protocol/bind.d.ts +1 -1
- package/build/src/protocol/bind.js +5 -16
- package/build/src/protocol/completion.d.ts +30 -0
- package/build/src/protocol/completion.js +8 -5
- package/build/src/protocol/deliver.js +7 -20
- package/build/src/protocol/delivery-preview.d.ts +5 -0
- package/build/src/protocol/execution-observation.d.ts +8 -0
- package/build/src/protocol/intent.d.ts +1 -0
- package/build/src/protocol/intent.js +4 -1
- package/build/src/protocol/operations.d.ts +54 -16
- package/build/src/protocol/operations.js +17 -31
- package/build/src/protocol/placement.js +7 -1
- package/build/src/protocol/progress.js +0 -6
- package/build/src/protocol/read/status.d.ts +40 -0
- package/build/src/protocol/read/status.js +7 -10
- package/build/src/protocol/reintegrate.js +2 -2
- package/build/src/protocol/result-leaves.d.ts +56 -8
- package/build/src/protocol/result-leaves.js +11 -2
- package/build/src/protocol/run.js +1 -4
- package/build/src/protocol/verify.d.ts +10 -0
- package/build/src/protocol/verify.js +1 -0
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settlement/settle.js +19 -68
- package/package.json +7 -3
- package/plugins/pi/README.md +55 -97
- package/plugins/pi/keiyaku.ts +2 -9
- package/skills/keiyaku-akuma/SKILL.md +13 -9
- package/skills/keiyaku-babysit/SKILL.md +8 -6
- package/skills/keiyaku-workflow/SKILL.md +2 -1
- package/build/plugins/pi/akuma-tools.ts +0 -283
- package/build/src/body/keys.d.ts +0 -4
- package/build/src/body/keys.js +0 -11
- package/build/src/kanshi/roster.d.ts +0 -2
- package/build/src/kanshi/roster.js +0 -2
- package/build/src/mcp/output.js +0 -193
- package/plugins/pi/akuma-tools.ts +0 -283
|
@@ -20,6 +20,7 @@ const bindFields = {
|
|
|
20
20
|
...regionFields,
|
|
21
21
|
};
|
|
22
22
|
const amendFields = {
|
|
23
|
+
target: z.string().exactOptional(),
|
|
23
24
|
changedSections: z.array(z.string()).min(1).readonly().exactOptional(),
|
|
24
25
|
gatesChanged: z.literal(true).exactOptional(),
|
|
25
26
|
afterChanged: z.literal(true).exactOptional(),
|
|
@@ -26,6 +26,14 @@ export declare const contractHistoryEventSchema: z.ZodUnion<readonly [z.ZodReado
|
|
|
26
26
|
kind: z.ZodLiteral<"amend">;
|
|
27
27
|
id: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").EntryUlid, string>>;
|
|
28
28
|
at: z.ZodString;
|
|
29
|
+
target: z.ZodExactOptional<z.ZodUnion<readonly [z.ZodString, z.ZodReadonly<z.ZodObject<{
|
|
30
|
+
kind: z.ZodLiteral<"contract">;
|
|
31
|
+
contractId: z.ZodPipe<z.ZodString, z.ZodTransform<ContractId, string>>;
|
|
32
|
+
}, z.core.$strict>>]>>;
|
|
33
|
+
targetIncarnation: z.ZodExactOptional<z.ZodReadonly<z.ZodObject<{
|
|
34
|
+
id: z.ZodString;
|
|
35
|
+
identity: z.ZodString;
|
|
36
|
+
}, z.core.$strict>>>;
|
|
29
37
|
changedSections: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
30
38
|
gates: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>>;
|
|
31
39
|
after: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<ContractId, string>>>>>;
|
|
@@ -103,6 +111,14 @@ export declare const contractHistorySchema: z.ZodUnion<readonly [z.ZodReadonly<z
|
|
|
103
111
|
kind: z.ZodLiteral<"amend">;
|
|
104
112
|
id: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").EntryUlid, string>>;
|
|
105
113
|
at: z.ZodString;
|
|
114
|
+
target: z.ZodExactOptional<z.ZodUnion<readonly [z.ZodString, z.ZodReadonly<z.ZodObject<{
|
|
115
|
+
kind: z.ZodLiteral<"contract">;
|
|
116
|
+
contractId: z.ZodPipe<z.ZodString, z.ZodTransform<ContractId, string>>;
|
|
117
|
+
}, z.core.$strict>>]>>;
|
|
118
|
+
targetIncarnation: z.ZodExactOptional<z.ZodReadonly<z.ZodObject<{
|
|
119
|
+
id: z.ZodString;
|
|
120
|
+
identity: z.ZodString;
|
|
121
|
+
}, z.core.$strict>>>;
|
|
106
122
|
changedSections: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
107
123
|
gates: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>>;
|
|
108
124
|
after: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<ContractId, string>>>>>;
|
|
@@ -193,6 +209,8 @@ export type KeisOptions = Readonly<{
|
|
|
193
209
|
settings?: Settings;
|
|
194
210
|
}>;
|
|
195
211
|
export type AmendInput = Readonly<{
|
|
212
|
+
/** Explicit existing branch or active Contract; omission retains the target. */
|
|
213
|
+
target?: string;
|
|
196
214
|
markdown?: string;
|
|
197
215
|
after?: readonly ContractId[];
|
|
198
216
|
gates?: readonly string[];
|
|
@@ -26,6 +26,8 @@ export const contractHistoryEventSchema = z.union([
|
|
|
26
26
|
targetIncarnation: z.strictObject({ id: z.string(), identity: z.string() }).readonly().exactOptional(),
|
|
27
27
|
}),
|
|
28
28
|
historyEvent("amend", {
|
|
29
|
+
target: historyTarget.exactOptional(),
|
|
30
|
+
targetIncarnation: z.strictObject({ id: z.string(), identity: z.string() }).readonly().exactOptional(),
|
|
29
31
|
changedSections: z.array(z.string()).readonly().exactOptional(),
|
|
30
32
|
gates: historyGates,
|
|
31
33
|
after: historyAfter,
|
|
@@ -90,4 +90,11 @@ export type ValidatedWait = Readonly<{
|
|
|
90
90
|
}>;
|
|
91
91
|
export declare function validateContractWait(scope: RepositoryScope, input: unknown): ValidatedWait;
|
|
92
92
|
export declare function validateContractWaitHandle(scope: RepositoryScope, id: ContractId, input?: ContractWaitOptions): ValidatedWait;
|
|
93
|
+
/** One invocation's journal baselines and witnessed progress, shared with mixed observation. */
|
|
94
|
+
export declare function createContractWaitObserver(scope: RepositoryScope, ids: readonly ContractId[]): {
|
|
95
|
+
members: () => readonly ContractWaitMember[];
|
|
96
|
+
reason: (completion: "any" | "all") => "deadline" | "missing" | "terminal" | "changed" | undefined;
|
|
97
|
+
satisfied: () => ContractId[];
|
|
98
|
+
observe(signal?: AbortSignal): Promise<void>;
|
|
99
|
+
};
|
|
93
100
|
export declare function waitContractLocal(input: ValidatedWait): Promise<ContractWaitResult>;
|
|
@@ -67,10 +67,12 @@ function validateContractWaitValues(values, scope) {
|
|
|
67
67
|
...(signal === undefined ? {} : { signal }),
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
|
+
function satisfied(member) {
|
|
71
|
+
return member.present === true && (member.changed || member.terminal !== null);
|
|
72
|
+
}
|
|
70
73
|
function readiness(members, completion) {
|
|
71
74
|
if (members.some((member) => member.present === false))
|
|
72
75
|
return "missing";
|
|
73
|
-
const satisfied = (member) => member.present === true && (member.changed || member.terminal !== null);
|
|
74
76
|
if (completion === "any" ? members.some(satisfied) : members.every(satisfied))
|
|
75
77
|
return members.some((member) => member.changed) ? "changed" : "terminal";
|
|
76
78
|
return undefined;
|
|
@@ -91,6 +93,46 @@ function waitResult(members, reason) {
|
|
|
91
93
|
})),
|
|
92
94
|
};
|
|
93
95
|
}
|
|
96
|
+
/** One invocation's journal baselines and witnessed progress, shared with mixed observation. */
|
|
97
|
+
export function createContractWaitObserver(scope, ids) {
|
|
98
|
+
let initialized = false;
|
|
99
|
+
let members = ids.map((id) => ({
|
|
100
|
+
id,
|
|
101
|
+
baseline: null,
|
|
102
|
+
changed: false,
|
|
103
|
+
present: null,
|
|
104
|
+
terminal: null,
|
|
105
|
+
}));
|
|
106
|
+
return {
|
|
107
|
+
members: () => waitResult(members, "deadline").contracts,
|
|
108
|
+
reason: (completion) => readiness(members, completion),
|
|
109
|
+
satisfied: () => members.filter(satisfied).map((member) => member.id),
|
|
110
|
+
async observe(signal) {
|
|
111
|
+
const reading = { ...scope, ...(signal === undefined ? {} : { signal }) };
|
|
112
|
+
const states = await readContractValue(() => withGitDecodeChannel(reading, async (channel) => {
|
|
113
|
+
const observed = await observeContractsForAdmissionAt(reading, channel, ids);
|
|
114
|
+
return ids.map((id) => {
|
|
115
|
+
const record = observed.journals.get(id);
|
|
116
|
+
if (record === undefined)
|
|
117
|
+
throw new Error(`missing requested contract observation: ${id}`);
|
|
118
|
+
return record.state;
|
|
119
|
+
});
|
|
120
|
+
}));
|
|
121
|
+
signal?.throwIfAborted();
|
|
122
|
+
members = members.map((member, index) => {
|
|
123
|
+
const state = states[index] ?? null;
|
|
124
|
+
return {
|
|
125
|
+
...member,
|
|
126
|
+
baseline: initialized ? member.baseline : (state?.head ?? null),
|
|
127
|
+
changed: member.changed || (initialized && state !== null && state.head !== member.baseline),
|
|
128
|
+
present: state !== null,
|
|
129
|
+
terminal: state?.terminal?.kind ?? null,
|
|
130
|
+
};
|
|
131
|
+
});
|
|
132
|
+
initialized = true;
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}
|
|
94
136
|
export async function waitContractLocal(input) {
|
|
95
137
|
const { ids, completion, timeoutMs, signal } = input;
|
|
96
138
|
signal?.throwIfAborted();
|
|
@@ -108,57 +150,19 @@ export async function waitContractLocal(input) {
|
|
|
108
150
|
if (timeoutMs !== undefined && timeoutMs > 0)
|
|
109
151
|
scheduleDeadline();
|
|
110
152
|
const readSignal = signal === undefined ? deadlineController.signal : AbortSignal.any([signal, deadlineController.signal]);
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
throw new Error(`missing requested contract observation: ${id}`);
|
|
118
|
-
return record.state;
|
|
119
|
-
});
|
|
120
|
-
}));
|
|
121
|
-
let members = ids.map((id) => ({
|
|
122
|
-
id,
|
|
123
|
-
baseline: null,
|
|
124
|
-
changed: false,
|
|
125
|
-
present: null,
|
|
126
|
-
terminal: null,
|
|
127
|
-
}));
|
|
128
|
-
const result = (reason) => waitResult(members, reason);
|
|
153
|
+
const observer = createContractWaitObserver(input.scope, ids);
|
|
154
|
+
const result = (reason) => ({
|
|
155
|
+
kind: "contract",
|
|
156
|
+
reason,
|
|
157
|
+
contracts: observer.members(),
|
|
158
|
+
});
|
|
129
159
|
try {
|
|
130
|
-
const initial = await read();
|
|
131
|
-
signal?.throwIfAborted();
|
|
132
|
-
members = members.map((member, index) => {
|
|
133
|
-
const state = initial[index] ?? null;
|
|
134
|
-
return {
|
|
135
|
-
...member,
|
|
136
|
-
baseline: state?.head ?? null,
|
|
137
|
-
present: state !== null,
|
|
138
|
-
terminal: state?.terminal?.kind ?? null,
|
|
139
|
-
};
|
|
140
|
-
});
|
|
141
|
-
const initialResult = readiness(members, completion);
|
|
142
|
-
if (initialResult !== undefined)
|
|
143
|
-
return result(initialResult);
|
|
144
|
-
if (performance.now() >= deadline)
|
|
145
|
-
return result("deadline");
|
|
146
160
|
for (;;) {
|
|
147
|
-
|
|
161
|
+
await observer.observe(readSignal);
|
|
148
162
|
signal?.throwIfAborted();
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return {
|
|
153
|
-
...member,
|
|
154
|
-
present: state !== null,
|
|
155
|
-
terminal: state?.terminal?.kind ?? null,
|
|
156
|
-
changed: member.changed || (state !== null && head !== member.baseline),
|
|
157
|
-
};
|
|
158
|
-
});
|
|
159
|
-
const observedResult = readiness(members, completion);
|
|
160
|
-
if (observedResult !== undefined)
|
|
161
|
-
return result(observedResult);
|
|
163
|
+
const reason = observer.reason(completion);
|
|
164
|
+
if (reason !== undefined)
|
|
165
|
+
return result(reason);
|
|
162
166
|
const remaining = deadline - performance.now();
|
|
163
167
|
if (remaining <= 0)
|
|
164
168
|
return result("deadline");
|
|
@@ -28,6 +28,11 @@ export declare const deliverPlacementSchema: z.ZodUnion<readonly [z.ZodReadonly<
|
|
|
28
28
|
requirement: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").RequirementId, string>>;
|
|
29
29
|
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
30
30
|
state: z.ZodLiteral<"stale">;
|
|
31
|
+
reason: z.ZodExactOptional<z.ZodReadonly<z.ZodObject<{
|
|
32
|
+
kind: z.ZodLiteral<"snapshot-changed">;
|
|
33
|
+
previousSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../index.js").SnapshotId, string>>;
|
|
34
|
+
currentSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../index.js").SnapshotId, string>>;
|
|
35
|
+
}, z.core.$strict>>>;
|
|
31
36
|
previousContentId: z.ZodExactOptional<z.ZodString>;
|
|
32
37
|
currentContentId: z.ZodExactOptional<z.ZodString>;
|
|
33
38
|
gate: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
@@ -143,6 +148,11 @@ export declare const deliveredValueSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
143
148
|
requirement: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").RequirementId, string>>;
|
|
144
149
|
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
145
150
|
state: z.ZodLiteral<"stale">;
|
|
151
|
+
reason: z.ZodExactOptional<z.ZodReadonly<z.ZodObject<{
|
|
152
|
+
kind: z.ZodLiteral<"snapshot-changed">;
|
|
153
|
+
previousSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../index.js").SnapshotId, string>>;
|
|
154
|
+
currentSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../index.js").SnapshotId, string>>;
|
|
155
|
+
}, z.core.$strict>>>;
|
|
146
156
|
previousContentId: z.ZodExactOptional<z.ZodString>;
|
|
147
157
|
currentContentId: z.ZodExactOptional<z.ZodString>;
|
|
148
158
|
gate: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
@@ -252,6 +262,11 @@ export declare const deliveredValueSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
252
262
|
requirement: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").RequirementId, string>>;
|
|
253
263
|
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
254
264
|
state: z.ZodLiteral<"stale">;
|
|
265
|
+
reason: z.ZodExactOptional<z.ZodReadonly<z.ZodObject<{
|
|
266
|
+
kind: z.ZodLiteral<"snapshot-changed">;
|
|
267
|
+
previousSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../index.js").SnapshotId, string>>;
|
|
268
|
+
currentSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../index.js").SnapshotId, string>>;
|
|
269
|
+
}, z.core.$strict>>>;
|
|
255
270
|
previousContentId: z.ZodExactOptional<z.ZodString>;
|
|
256
271
|
currentContentId: z.ZodExactOptional<z.ZodString>;
|
|
257
272
|
gate: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
@@ -370,6 +385,11 @@ export declare const deliverySchema: z.ZodNullable<z.ZodReadonly<z.ZodObject<{
|
|
|
370
385
|
requirement: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").RequirementId, string>>;
|
|
371
386
|
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
372
387
|
state: z.ZodLiteral<"stale">;
|
|
388
|
+
reason: z.ZodExactOptional<z.ZodReadonly<z.ZodObject<{
|
|
389
|
+
kind: z.ZodLiteral<"snapshot-changed">;
|
|
390
|
+
previousSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../index.js").SnapshotId, string>>;
|
|
391
|
+
currentSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../index.js").SnapshotId, string>>;
|
|
392
|
+
}, z.core.$strict>>>;
|
|
373
393
|
previousContentId: z.ZodExactOptional<z.ZodString>;
|
|
374
394
|
currentContentId: z.ZodExactOptional<z.ZodString>;
|
|
375
395
|
gate: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
@@ -479,6 +499,11 @@ export declare const deliverySchema: z.ZodNullable<z.ZodReadonly<z.ZodObject<{
|
|
|
479
499
|
requirement: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").RequirementId, string>>;
|
|
480
500
|
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
481
501
|
state: z.ZodLiteral<"stale">;
|
|
502
|
+
reason: z.ZodExactOptional<z.ZodReadonly<z.ZodObject<{
|
|
503
|
+
kind: z.ZodLiteral<"snapshot-changed">;
|
|
504
|
+
previousSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../index.js").SnapshotId, string>>;
|
|
505
|
+
currentSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../index.js").SnapshotId, string>>;
|
|
506
|
+
}, z.core.$strict>>>;
|
|
482
507
|
previousContentId: z.ZodExactOptional<z.ZodString>;
|
|
483
508
|
currentContentId: z.ZodExactOptional<z.ZodString>;
|
|
484
509
|
gate: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
@@ -3,37 +3,19 @@ import type { DecodedContractDocument } from "../body/types.js";
|
|
|
3
3
|
import { type ContractId, type ContractTerms, type Gate } from "../core/facts/types.js";
|
|
4
4
|
import { type DebtId } from "../debt/identity.js";
|
|
5
5
|
import type { DocumentDerivation } from "../protocol/operations.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
gates: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
10
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
6
|
+
/** Every amendment field is optional; naming none requests an unchanged, fact-free amendment. */
|
|
7
|
+
export declare const amendInputSchema: z.ZodObject<{
|
|
8
|
+
target: z.ZodExactOptional<z.ZodString>;
|
|
11
9
|
markdown: z.ZodExactOptional<z.ZodString>;
|
|
12
|
-
after: z.ZodNonOptional<z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>>;
|
|
13
|
-
gates: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
14
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
15
|
-
markdown: z.ZodExactOptional<z.ZodString>;
|
|
16
|
-
after: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
17
|
-
gates: z.ZodNonOptional<z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>>;
|
|
18
|
-
}, z.core.$strict>];
|
|
19
|
-
export declare const amendInputSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
20
|
-
markdown: z.ZodNonOptional<z.ZodExactOptional<z.ZodString>>;
|
|
21
10
|
after: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
22
11
|
gates: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
23
|
-
}, z.core.$strict
|
|
24
|
-
markdown: z.ZodExactOptional<z.ZodString>;
|
|
25
|
-
after: z.ZodNonOptional<z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>>;
|
|
26
|
-
gates: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
27
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
28
|
-
markdown: z.ZodExactOptional<z.ZodString>;
|
|
29
|
-
after: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
30
|
-
gates: z.ZodNonOptional<z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>>;
|
|
31
|
-
}, z.core.$strict>]>;
|
|
12
|
+
}, z.core.$strict>;
|
|
32
13
|
export declare function requireMarkdown(value: unknown, label?: string): string;
|
|
33
14
|
/** Core contract parsing stays foundational; the caller boundary declares the category once. */
|
|
34
15
|
export declare function callerContractId(value: string): ContractId;
|
|
35
16
|
export declare function requireInput(value: unknown, label: string, allowed?: readonly string[]): Record<string, unknown>;
|
|
36
17
|
export declare function debtOption(value: unknown): DebtId | undefined;
|
|
18
|
+
export declare function nonblank(value: unknown, label: string): string;
|
|
37
19
|
export declare function optionalNonblank(value: unknown, label: string): string | undefined;
|
|
38
20
|
export declare function optionalBoolean(value: unknown, label: string): boolean | undefined;
|
|
39
21
|
export declare function optionalSignal(value: unknown): AbortSignal | undefined;
|
|
@@ -6,17 +6,16 @@ import { verificationDefinition } from "../body/decode.js";
|
|
|
6
6
|
import { contractId } from "../core/facts/types.js";
|
|
7
7
|
import { canonicalDebtId } from "../debt/identity.js";
|
|
8
8
|
import { gateRequirements, prepareVerificationDeclaration } from "../verification/declaration.js";
|
|
9
|
-
|
|
9
|
+
/** Every amendment field is optional; naming none requests an unchanged, fact-free amendment. */
|
|
10
|
+
export const amendInputSchema = z.strictObject({
|
|
11
|
+
target: z
|
|
12
|
+
.string()
|
|
13
|
+
.refine((value) => value.trim() !== "", "target must be nonblank")
|
|
14
|
+
.exactOptional(),
|
|
10
15
|
markdown: z.string().exactOptional(),
|
|
11
16
|
after: z.array(z.string()).readonly().exactOptional(),
|
|
12
17
|
gates: z.array(z.string()).readonly().exactOptional(),
|
|
13
18
|
});
|
|
14
|
-
export const amendInputSchemas = [
|
|
15
|
-
amendFields.required({ markdown: true }),
|
|
16
|
-
amendFields.required({ after: true }),
|
|
17
|
-
amendFields.required({ gates: true }),
|
|
18
|
-
];
|
|
19
|
-
export const amendInputSchema = z.union(amendInputSchemas);
|
|
20
19
|
export function requireMarkdown(value, label = "markdown") {
|
|
21
20
|
if (typeof value !== "string")
|
|
22
21
|
throw new KeiyakuError("invalid-input", `${label} must be a string`);
|
|
@@ -53,6 +52,12 @@ export function debtOption(value) {
|
|
|
53
52
|
throw new KeiyakuError("invalid-input", "debt must be a DebtId");
|
|
54
53
|
return canonicalDebtId(value);
|
|
55
54
|
}
|
|
55
|
+
export function nonblank(value, label) {
|
|
56
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
57
|
+
throw new KeiyakuError("invalid-input", `${label} must be a nonblank string`);
|
|
58
|
+
}
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
56
61
|
export function optionalNonblank(value, label) {
|
|
57
62
|
if (value === undefined)
|
|
58
63
|
return undefined;
|
package/build/src/library/kei.js
CHANGED
|
@@ -13,6 +13,7 @@ import { retainAdmission, } from "./contract-outcomes.js";
|
|
|
13
13
|
import { derivedContractPolicy, derivedFreshness, derivedGates, derivedHooks, gateNames, } from "./contract-settings.js";
|
|
14
14
|
import { compactDelivery, admitDeliveryOperation } from "../protocol/deliver.js";
|
|
15
15
|
import { validateContractWaitHandle, waitContractLocal, } from "./contract-wait.js";
|
|
16
|
+
import { targetName } from "../core/facts/types.js";
|
|
16
17
|
import { prepareAmendDocument } from "../body/amend.js";
|
|
17
18
|
import { decodeArcDocument } from "../body/arc.js";
|
|
18
19
|
import { decodeContractDocument } from "../body/decode.js";
|
|
@@ -146,39 +147,52 @@ export class Kei {
|
|
|
146
147
|
const derived = values.gates === undefined ? undefined : derivedGates(this.composition, gateNames(values.gates));
|
|
147
148
|
return {
|
|
148
149
|
markdown: values.markdown,
|
|
150
|
+
target: values.target,
|
|
149
151
|
gates: derived,
|
|
150
152
|
prerequisites: values.after === undefined ? undefined : normalizedList(values.after, "after", callerContractId),
|
|
151
153
|
};
|
|
152
154
|
});
|
|
153
155
|
}
|
|
154
156
|
async amend(input) {
|
|
155
|
-
const { markdown, gates, prerequisites } = this.amendInput(input);
|
|
157
|
+
const { markdown, target, gates, prerequisites } = this.amendInput(input);
|
|
156
158
|
const hooks = derivedHooks(this.composition);
|
|
159
|
+
const requestsChange = markdown !== undefined || target !== undefined || gates !== undefined || prerequisites !== undefined;
|
|
157
160
|
const amendmentPlan = markdown === undefined ? undefined : validated(() => prepareAmendDocument(markdown));
|
|
158
161
|
let changedSections;
|
|
159
|
-
|
|
162
|
+
const concluded = await this.local("amend", async (accumulator, channel, scope) => {
|
|
160
163
|
const admission = await amendOperation({
|
|
161
164
|
scope,
|
|
162
165
|
channel,
|
|
163
166
|
contractId: this.id,
|
|
164
167
|
progress: accumulator,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
?
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
168
|
+
...(target === undefined ? {} : { target }),
|
|
169
|
+
...(requestsChange
|
|
170
|
+
? {
|
|
171
|
+
deriveAmendment: (source) => {
|
|
172
|
+
const current = persistedDocument(source.document.bytes);
|
|
173
|
+
const amendment = amendmentPlan === undefined ? undefined : validated(() => amendmentPlan(current));
|
|
174
|
+
const amended = amendment === undefined ? current : validated(() => decodeContractDocument(amendment.document));
|
|
175
|
+
changedSections =
|
|
176
|
+
amendment === undefined
|
|
177
|
+
? undefined
|
|
178
|
+
: new Set([...amendment.changedSections].filter((section) => sectionValue(current, section) !== sectionValue(amended, section)));
|
|
179
|
+
const terms = contractTerms(amended, gates ?? source.gates, prerequisites ?? source.after);
|
|
180
|
+
return { terms, verification: documentDerivation(amended).verification };
|
|
181
|
+
},
|
|
182
|
+
}
|
|
183
|
+
: {}),
|
|
176
184
|
});
|
|
185
|
+
// No requested change is the same answer as before: an accepted amendment that changed nothing.
|
|
186
|
+
if (admission.kind === "unchanged")
|
|
187
|
+
return { kind: "unchanged", contractId: this.id };
|
|
177
188
|
if (admission.kind !== "accepted")
|
|
178
189
|
return admission.kind === "refused"
|
|
179
190
|
? { kind: "refused", contractId: this.id, reason: compactReason(admission.refusal) }
|
|
180
191
|
: { contractId: this.id, ...compactRetry(admission.reason) };
|
|
181
|
-
const changes =
|
|
192
|
+
const changes = {
|
|
193
|
+
...changedAmendTerms(admission.value.source, admission.value.terms),
|
|
194
|
+
...(admission.value.target === undefined ? {} : { target: targetName(admission.value.target) }),
|
|
195
|
+
};
|
|
182
196
|
const sections = changedSections === undefined || changedSections.size === 0 ? {} : { changedSections: [...changedSections] };
|
|
183
197
|
accumulator.extendConclusions(this.id, { ...sections, ...changes });
|
|
184
198
|
const region = await observeChangedRegion(scope, this.id, changedSections, decodeContractDocument(admission.value.terms.document.bytes).region);
|
|
@@ -195,6 +209,7 @@ export class Kei {
|
|
|
195
209
|
});
|
|
196
210
|
return { kind: "accepted", contractId: this.id, ...value };
|
|
197
211
|
});
|
|
212
|
+
return concluded.kind === "unchanged" ? { kind: "accepted", contractId: this.id } : concluded;
|
|
198
213
|
}
|
|
199
214
|
/** One promise with an optional observation callback; observation never delays custody. */
|
|
200
215
|
async deliver(input, options) {
|
|
@@ -513,6 +528,14 @@ function attestationHistory(entry) {
|
|
|
513
528
|
...(summary === undefined ? {} : { summary }),
|
|
514
529
|
};
|
|
515
530
|
}
|
|
531
|
+
function historyTarget(target, full) {
|
|
532
|
+
return target === undefined
|
|
533
|
+
? {}
|
|
534
|
+
: {
|
|
535
|
+
target: typeof target === "string" ? target : { kind: "contract", contractId: target.contractId },
|
|
536
|
+
...(full && typeof target === "object" ? { targetIncarnation: target.worktree } : {}),
|
|
537
|
+
};
|
|
538
|
+
}
|
|
516
539
|
function historyEvent(entry, terms, full) {
|
|
517
540
|
const common = { id: entry.entry, at: entry.at };
|
|
518
541
|
switch (entry.kind) {
|
|
@@ -523,17 +546,12 @@ function historyEvent(entry, terms, full) {
|
|
|
523
546
|
...common,
|
|
524
547
|
kind: "bind",
|
|
525
548
|
start: coordinates.start,
|
|
526
|
-
...(target
|
|
527
|
-
? {}
|
|
528
|
-
: {
|
|
529
|
-
target: typeof target === "string" ? target : { kind: "contract", contractId: target.contractId },
|
|
530
|
-
}),
|
|
549
|
+
...historyTarget(target, full),
|
|
531
550
|
...(full
|
|
532
551
|
? {
|
|
533
552
|
document: bound.document.bytes,
|
|
534
553
|
gates: bound.gates,
|
|
535
554
|
after: bound.after,
|
|
536
|
-
...(typeof target === "object" ? { targetIncarnation: target.worktree } : {}),
|
|
537
555
|
}
|
|
538
556
|
: {
|
|
539
557
|
...(bound.gates.length === 0 ? {} : { gates: bound.gates }),
|
|
@@ -545,6 +563,7 @@ function historyEvent(entry, terms, full) {
|
|
|
545
563
|
return {
|
|
546
564
|
...common,
|
|
547
565
|
kind: "amend",
|
|
566
|
+
...historyTarget(entry.data.target, full),
|
|
548
567
|
...changedHistoryTerms(terms, entry.data),
|
|
549
568
|
...(full ? { document: entry.data.document.bytes, gates: entry.data.gates, after: entry.data.after } : {}),
|
|
550
569
|
};
|
|
@@ -54,9 +54,9 @@ function classifyReconcile(result) {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
function classifyWait(result) {
|
|
57
|
-
if (result.kind === "
|
|
58
|
-
return
|
|
59
|
-
return result.
|
|
57
|
+
if (result.members.some((member) => member.kind === "akuma" && (member.observation.kind === "unobserved" || member.observation.kind === "missing")))
|
|
58
|
+
return "failed";
|
|
59
|
+
return result.reason === "missing" ? "refused" : "accepted";
|
|
60
60
|
}
|
|
61
61
|
function classifyHistory(value) {
|
|
62
62
|
return value.kind === "contract-missing" || value.kind === "akuma-unknown-history" ? "refused" : "accepted";
|
|
@@ -5,7 +5,6 @@ import { parseDebtCreationDocument } from "../debt/document.js";
|
|
|
5
5
|
import { invocationCoordinates } from "./keiyaku-coordinates.js";
|
|
6
6
|
const coordinates = (at) => invocationCoordinates({ ...at, use: "none" });
|
|
7
7
|
const absent = { kind: "absent" };
|
|
8
|
-
const missing = () => ({ kind: "refused", reason: "debt-missing" });
|
|
9
8
|
export async function debtAdd(at, input, document) {
|
|
10
9
|
const parsed = document ? addDocumentInput(input) : addInput(input);
|
|
11
10
|
if (document)
|
|
@@ -22,7 +21,7 @@ export async function debtUpdate(at, input) {
|
|
|
22
21
|
.debt({ id })
|
|
23
22
|
.update(rest);
|
|
24
23
|
updateInput(rest).signal?.throwIfAborted();
|
|
25
|
-
return missing
|
|
24
|
+
return { kind: "refused", reason: "debt-missing" };
|
|
26
25
|
}
|
|
27
26
|
export async function debtShow(at, id) {
|
|
28
27
|
const coord = await coordinates(at);
|
|
@@ -3,8 +3,8 @@ import { z } from "zod";
|
|
|
3
3
|
import { Repo } from "./repo.js";
|
|
4
4
|
import { type AkumaCaller } from "../akuma/caller.js";
|
|
5
5
|
import { type WorldRoot } from "../world.js";
|
|
6
|
-
/**
|
|
7
|
-
export declare function akumaCallerFromEnvironment(environment: NodeJS.ProcessEnv): Promise<AkumaCaller | undefined>;
|
|
6
|
+
/** Actor declarations win; an explicit caller bypasses native host decoding. */
|
|
7
|
+
export declare function akumaCallerFromEnvironment(environment: NodeJS.ProcessEnv, caller?: AkumaCaller): Promise<AkumaCaller | undefined>;
|
|
8
8
|
type WhoamiCoordinates = Readonly<{
|
|
9
9
|
cwd: string;
|
|
10
10
|
repo?: Repo;
|
|
@@ -54,5 +54,5 @@ export declare const whoamiFactsSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
54
54
|
profileUnavailable: z.ZodExactOptional<z.ZodString>;
|
|
55
55
|
}, z.core.$strict>>;
|
|
56
56
|
export type WhoamiFacts = z.output<typeof whoamiFactsSchema>;
|
|
57
|
-
export declare function whoami(coordinates: WhoamiCoordinates, environment: NodeJS.ProcessEnv): Promise<WhoamiFacts>;
|
|
57
|
+
export declare function whoami(coordinates: WhoamiCoordinates, environment: NodeJS.ProcessEnv, caller?: AkumaCaller): Promise<WhoamiFacts>;
|
|
58
58
|
export {};
|
|
@@ -11,8 +11,8 @@ import { observeNamedAddress } from "./address.js";
|
|
|
11
11
|
import { dispatchAssociations } from "./selection.js";
|
|
12
12
|
import { decodeAkumaCaller } from "../akuma/caller.js";
|
|
13
13
|
import { World, worldRootSchema } from "../world.js";
|
|
14
|
-
/**
|
|
15
|
-
export async function akumaCallerFromEnvironment(environment) {
|
|
14
|
+
/** Actor declarations win; an explicit caller bypasses native host decoding. */
|
|
15
|
+
export async function akumaCallerFromEnvironment(environment, caller) {
|
|
16
16
|
const id = environment.KEIYAKU_ACTOR_ID;
|
|
17
17
|
const world = environment.KEIYAKU_ACTOR_WORLD;
|
|
18
18
|
if ((id === undefined) !== (world === undefined)) {
|
|
@@ -22,6 +22,8 @@ export async function akumaCallerFromEnvironment(environment) {
|
|
|
22
22
|
const resolved = await World.resolve({ cwd: world, repositoryRoot: world });
|
|
23
23
|
return decodeAkumaCaller({ kind: "akuma", akumaId: id, world: resolved.candidate });
|
|
24
24
|
}
|
|
25
|
+
if (caller !== undefined)
|
|
26
|
+
return caller;
|
|
25
27
|
const hosts = [
|
|
26
28
|
{ integration: "codex", variable: "CODEX_THREAD_ID", id: environment.CODEX_THREAD_ID },
|
|
27
29
|
{ integration: "pi", variable: "PI_SESSION_ID", id: environment.PI_SESSION_ID },
|
|
@@ -73,9 +75,9 @@ export const whoamiFactsSchema = z
|
|
|
73
75
|
function reason(error) {
|
|
74
76
|
return error instanceof Error ? error.message : String(error);
|
|
75
77
|
}
|
|
76
|
-
async function selfFrom(environment) {
|
|
78
|
+
async function selfFrom(environment, explicit) {
|
|
77
79
|
try {
|
|
78
|
-
const caller = await akumaCallerFromEnvironment(environment);
|
|
80
|
+
const caller = await akumaCallerFromEnvironment(environment, explicit);
|
|
79
81
|
return caller === undefined ? { kind: "none" } : callerFact(caller);
|
|
80
82
|
}
|
|
81
83
|
catch (error) {
|
|
@@ -163,9 +165,12 @@ async function callerProfile(caller, coordinates, environment) {
|
|
|
163
165
|
return { profileUnavailable: reason(error) };
|
|
164
166
|
}
|
|
165
167
|
}
|
|
166
|
-
export async function whoami(coordinates, environment) {
|
|
168
|
+
export async function whoami(coordinates, environment, caller) {
|
|
167
169
|
const world = coordinates.world !== null && (await World.established(coordinates.world)) ? coordinates.world : null;
|
|
168
|
-
const [self, contextContract] = await Promise.all([
|
|
170
|
+
const [self, contextContract] = await Promise.all([
|
|
171
|
+
selfFrom(environment, caller),
|
|
172
|
+
contextualContract(coordinates, world),
|
|
173
|
+
]);
|
|
169
174
|
const initiator = self.kind === "akuma" ? await currentTurn(self) : undefined;
|
|
170
175
|
return {
|
|
171
176
|
self,
|