@astrosheep/keiyaku 4.0.4 → 4.0.5
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/integrations/marketplace/plugins/keiyaku/.claude-plugin/plugin.json +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/.codex-plugin/plugin.json +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/package.json +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +3 -3
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +14 -0
- package/build/src/akuma/akuma.d.ts +0 -1
- package/build/src/akuma/akuma.js +1 -6
- package/build/src/akuma/allowed.d.ts +1 -1
- package/build/src/akuma/allowed.js +3 -10
- package/build/src/akuma/body.d.ts +5 -2
- package/build/src/akuma/body.js +29 -23
- package/build/src/akuma/heart/facts.d.ts +35 -9
- package/build/src/akuma/heart/index.d.ts +4 -13
- package/build/src/akuma/heart/index.js +2 -133
- package/build/src/akuma/heart/request-authority.d.ts +12 -0
- package/build/src/akuma/heart/request-authority.js +119 -0
- package/build/src/akuma/heart/request-rows.d.ts +16 -0
- package/build/src/akuma/heart/request-rows.js +88 -0
- package/build/src/akuma/heart/rows.d.ts +1 -28
- package/build/src/akuma/heart/rows.js +0 -137
- package/build/src/akuma/heart/schema.d.ts +1 -1
- package/build/src/akuma/heart/schema.js +9 -2
- package/build/src/akuma/heart/soul.js +0 -36
- package/build/src/akuma/index.d.ts +1 -1
- package/build/src/akuma/provider-recipe.js +1 -11
- package/build/src/akuma/provider.d.ts +1 -6
- package/build/src/akuma/providers/acp/core.js +6 -2
- package/build/src/akuma/providers/acp/index.js +0 -1
- package/build/src/akuma/providers/claude/index.d.ts +0 -4
- package/build/src/akuma/providers/claude/index.js +7 -3
- package/build/src/akuma/providers/codex-app-server/index.d.ts +2 -27
- package/build/src/akuma/providers/codex-app-server/index.js +0 -2
- package/build/src/akuma/providers/grok-build/index.js +0 -1
- package/build/src/akuma/providers/opencode-sdk/index.d.ts +2 -28
- package/build/src/akuma/providers/opencode-sdk/index.js +8 -4
- package/build/src/akuma/providers/opencode-sdk/session.d.ts +1 -1
- package/build/src/akuma/providers/opencode-sdk/session.js +1 -1
- package/build/src/akuma/providers/pi/index.js +11 -4
- package/build/src/akuma/request-serve.d.ts +87 -0
- package/build/src/akuma/request-serve.js +484 -0
- package/build/src/akuma/request-wire.d.ts +124 -0
- package/build/src/akuma/request-wire.js +380 -0
- package/build/src/akuma/requests.d.ts +28 -94
- package/build/src/akuma/requests.js +52 -562
- package/build/src/akuma-body.d.ts +7 -0
- package/build/src/akuma-body.js +54 -1
- package/build/src/body/arc.js +4 -29
- package/build/src/body/decode.js +5 -39
- package/build/src/body/envelope.d.ts +7 -0
- package/build/src/body/envelope.js +37 -0
- package/build/src/cli/accepted.js +17 -9
- package/build/src/cli/commands/akuma.js +2 -2
- package/build/src/cli/commands/contract.d.ts +6 -6
- package/build/src/cli/commands/contract.js +3 -3
- package/build/src/cli/commands/task-invoke.js +98 -9
- package/build/src/cli/coordinates.d.ts +1 -0
- package/build/src/cli/coordinates.js +7 -4
- package/build/src/cli/invoke.js +28 -4
- package/build/src/cli/parse.d.ts +2 -2
- package/build/src/cli/parse.js +21 -8
- package/build/src/cli/render/akuma.js +56 -13
- package/build/src/cli/render/audit.js +2 -6
- package/build/src/cli/render/contract.js +40 -0
- package/build/src/cli/render/receipt.js +28 -1
- package/build/src/cli/render/terminal.d.ts +0 -2
- package/build/src/cli/render/terminal.js +0 -29
- package/build/src/cli/result.d.ts +15 -7
- package/build/src/contract-worktree.d.ts +1 -2
- package/build/src/contract-worktree.js +4 -9
- package/build/src/core/facts/codec.js +9 -0
- package/build/src/core/facts/fold.js +13 -1
- package/build/src/core/facts/types.d.ts +8 -1
- package/build/src/core/subject.js +4 -3
- package/build/src/core/verbs/placement.d.ts +9 -1
- package/build/src/core/verbs/placement.js +24 -6
- package/build/src/core/verbs/reintegrate.d.ts +13 -0
- package/build/src/core/verbs/reintegrate.js +24 -0
- package/build/src/dispatch/index.d.ts +1 -1
- package/build/src/git/admission.d.ts +2 -1
- package/build/src/git/integration.d.ts +5 -2
- package/build/src/git/integration.js +54 -1
- package/build/src/git/observe.d.ts +2 -1
- package/build/src/git/observe.js +6 -5
- package/build/src/git/process.d.ts +26 -0
- package/build/src/git/process.js +94 -0
- package/build/src/git/read-observation.d.ts +2 -1
- package/build/src/git/read-observation.js +3 -2
- package/build/src/git/reconcile.d.ts +2 -1
- package/build/src/git/reconcile.js +9 -6
- package/build/src/git/repository.d.ts +2 -29
- package/build/src/git/repository.js +4 -118
- package/build/src/git/scratch.d.ts +1 -1
- package/build/src/git/scratch.js +1 -1
- package/build/src/git/target-placement.d.ts +1 -1
- package/build/src/git/target-placement.js +9 -7
- package/build/src/git/tender.d.ts +1 -1
- package/build/src/git/tender.js +2 -1
- package/build/src/git/terminal-seal.d.ts +2 -2
- package/build/src/git/terminal-seal.js +3 -6
- package/build/src/git/workspace.d.ts +1 -1
- package/build/src/git/workspace.js +1 -1
- package/build/src/index.d.ts +1 -2
- package/build/src/index.js +1 -1
- package/build/src/library/address.js +7 -1
- package/build/src/library/audit.d.ts +2 -1
- package/build/src/library/audit.js +1 -1
- package/build/src/library/bind.d.ts +2 -1
- package/build/src/library/bind.js +1 -1
- package/build/src/library/configuration.d.ts +1 -1
- package/build/src/library/configuration.js +52 -18
- package/build/src/library/contract.d.ts +55 -2
- package/build/src/library/contract.js +162 -23
- package/build/src/library/delivery.d.ts +1 -1
- package/build/src/library/fleet.d.ts +27 -7
- package/build/src/library/fleet.js +79 -39
- package/build/src/library/input.d.ts +0 -1
- package/build/src/library/input.js +0 -5
- package/build/src/library/keiyaku.d.ts +1 -1
- package/build/src/library/mutation.d.ts +2 -1
- package/build/src/library/reconcile.d.ts +2 -1
- package/build/src/library/reconcile.js +3 -1
- package/build/src/library/region.d.ts +1 -1
- package/build/src/library/repo.d.ts +3 -1
- package/build/src/library/repo.js +8 -4
- package/build/src/protocol/abandon.d.ts +9 -0
- package/build/src/protocol/abandon.js +15 -0
- package/build/src/protocol/amend.d.ts +16 -0
- package/build/src/protocol/amend.js +77 -0
- package/build/src/protocol/arc.d.ts +6 -0
- package/build/src/protocol/arc.js +12 -0
- package/build/src/protocol/attempt.d.ts +2 -1
- package/build/src/protocol/audit.d.ts +53 -0
- package/build/src/protocol/audit.js +140 -0
- package/build/src/protocol/bind.d.ts +1 -1
- package/build/src/protocol/completion.d.ts +32 -0
- package/build/src/protocol/completion.js +130 -0
- package/build/src/protocol/deliver.d.ts +37 -0
- package/build/src/protocol/deliver.js +160 -0
- package/build/src/protocol/intent.d.ts +1 -1
- package/build/src/protocol/intent.js +1 -1
- package/build/src/protocol/operations.d.ts +64 -200
- package/build/src/protocol/operations.js +21 -640
- package/build/src/protocol/placement.d.ts +4 -13
- package/build/src/protocol/placement.js +3 -15
- package/build/src/protocol/read/status.d.ts +1 -1
- package/build/src/protocol/read/status.js +3 -1
- package/build/src/protocol/reconcile.d.ts +35 -0
- package/build/src/protocol/reconcile.js +41 -0
- package/build/src/protocol/reintegrate.d.ts +31 -0
- package/build/src/protocol/reintegrate.js +74 -0
- package/build/src/protocol/review.d.ts +33 -0
- package/build/src/protocol/review.js +148 -0
- package/build/src/protocol/run.d.ts +1 -1
- package/build/src/settlement/fence.d.ts +1 -1
- package/build/src/settlement/holder.d.ts +1 -1
- package/build/src/settlement/settle.d.ts +1 -1
- package/build/src/task/board.d.ts +0 -1
- package/build/src/task/board.js +0 -3
- package/build/src/task/compose.d.ts +1 -1
- package/build/src/task/compose.js +11 -4
- package/build/src/task/index.d.ts +1 -1
- package/build/src/task/index.js +2 -127
- package/build/src/task/input.d.ts +18 -0
- package/build/src/task/input.js +189 -0
- package/build/src/task/mutation.d.ts +39 -0
- package/build/src/task/mutation.js +85 -0
- package/build/src/task/operations.d.ts +2 -0
- package/build/src/task/operations.js +35 -11
- package/build/src/task/store.js +0 -2
- package/build/src/verification/execution.d.ts +1 -1
- package/build/src/workspace-place.d.ts +1 -4
- package/build/src/workspace-place.js +0 -15
- package/package.json +3 -3
|
@@ -2,7 +2,7 @@ import * as acp from "@agentclientprotocol/sdk";
|
|
|
2
2
|
import { Readable, Writable } from "node:stream";
|
|
3
3
|
import { spawnStdioProcess } from "../../../runtime/proc/stdio.js";
|
|
4
4
|
import { abortable } from "../../abort.js";
|
|
5
|
-
import { AgentEventChannel, } from "../../provider.js";
|
|
5
|
+
import { AKUMA_REQUESTS_ENV, AgentEventChannel, } from "../../provider.js";
|
|
6
6
|
import { EMPTY_ACP_EVENT_STATE, flushAcpEvents, mapAcpUpdate, } from "./events.js";
|
|
7
7
|
function diagnostic(error) {
|
|
8
8
|
if (!(error instanceof Error))
|
|
@@ -130,7 +130,11 @@ export async function startAcpSession(launch, input, dependencies = {}) {
|
|
|
130
130
|
const child = (dependencies.spawnProcess ?? spawnStdioProcess)({
|
|
131
131
|
argv: launch.argv,
|
|
132
132
|
cwd: input.cwd,
|
|
133
|
-
env: {
|
|
133
|
+
env: {
|
|
134
|
+
...globalThis.process.env,
|
|
135
|
+
...launch.env,
|
|
136
|
+
...(input.requests === undefined ? {} : { [AKUMA_REQUESTS_ENV]: input.requests.dir }),
|
|
137
|
+
},
|
|
134
138
|
});
|
|
135
139
|
let sessionId;
|
|
136
140
|
let turn;
|
|
@@ -86,7 +86,6 @@ export function createAcpProvider(execution, dependencies = {}) {
|
|
|
86
86
|
return (await startAcpSession(launch, input, dependencies)).session;
|
|
87
87
|
};
|
|
88
88
|
return {
|
|
89
|
-
confinement: () => ({ kind: "unconfined" }),
|
|
90
89
|
admitOptions: (options) => optionAdmission(options, config),
|
|
91
90
|
start: async (input) => await drive(input),
|
|
92
91
|
resume: async (input) => await drive(input),
|
|
@@ -21,10 +21,6 @@ export type ClaudeSdk = Readonly<{
|
|
|
21
21
|
}>;
|
|
22
22
|
export declare function createClaudeProvider(load: () => Promise<ClaudeSdk>, execution?: ClaudeExecution): ProviderAdapter;
|
|
23
23
|
export declare const claudeProvider: Readonly<{
|
|
24
|
-
confinement(input: Readonly<{
|
|
25
|
-
cwd: string;
|
|
26
|
-
options: ProviderOptions;
|
|
27
|
-
}>): import("../../index.js").Confinement;
|
|
28
24
|
admitOptions(options: ProviderOptions): import("../../provider.js").ProviderOptionAdmission;
|
|
29
25
|
fork?(input: Readonly<{
|
|
30
26
|
session: ResumeCoordinate;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { abortable } from "../../abort.js";
|
|
3
|
-
import { AgentEventChannel, } from "../../provider.js";
|
|
3
|
+
import { AKUMA_REQUESTS_ENV, AgentEventChannel, } from "../../provider.js";
|
|
4
4
|
import { emitClaudeMessage, } from "./events.js";
|
|
5
5
|
import { claudeUserMessage, createClaudeInput, isClaudeTurnEnded } from "./input.js";
|
|
6
6
|
export { CLAUDE_MESSAGE_DISPOSITIONS, CLAUDE_SYSTEM_DISPOSITIONS } from "./events.js";
|
|
@@ -61,8 +61,13 @@ function claudeQueryOptions(input, execution, abortController) {
|
|
|
61
61
|
return {
|
|
62
62
|
cwd: input.cwd,
|
|
63
63
|
abortController,
|
|
64
|
+
...(input.requests === undefined ? {} : { additionalDirectories: [input.requests.dir] }),
|
|
64
65
|
...(execution.executable === undefined ? {} : { pathToClaudeCodeExecutable: execution.executable }),
|
|
65
|
-
...(execution.env === undefined ? {} : { env: {
|
|
66
|
+
...((execution.env === undefined && input.requests === undefined) ? {} : { env: {
|
|
67
|
+
...process.env,
|
|
68
|
+
...execution.env,
|
|
69
|
+
...(input.requests === undefined ? {} : { [AKUMA_REQUESTS_ENV]: input.requests.dir }),
|
|
70
|
+
} }),
|
|
66
71
|
permissionMode: mode,
|
|
67
72
|
...(mode === "bypassPermissions" ? { allowDangerouslySkipPermissions: true } : {}),
|
|
68
73
|
settingSources: ["user", "project", "local"],
|
|
@@ -269,7 +274,6 @@ async function driveClaude(load, execution, drive) {
|
|
|
269
274
|
}
|
|
270
275
|
export function createClaudeProvider(load, execution = {}) {
|
|
271
276
|
return {
|
|
272
|
-
confinement: () => ({ kind: "unconfined" }),
|
|
273
277
|
admitOptions: admitClaudeOptions,
|
|
274
278
|
fork: (input) => forkClaude(load, execution, input),
|
|
275
279
|
start: (input) => driveClaude(load, execution, input),
|
|
@@ -1,29 +1,4 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type { ProviderExecution
|
|
1
|
+
import { type ProviderAdapter } from "../../provider.js";
|
|
2
|
+
import type { ProviderExecution } from "../../provider-recipe.js";
|
|
3
3
|
export { CODEX_ITEM_DISPOSITIONS, CODEX_NOTIFICATION_DISPOSITIONS } from "./events.js";
|
|
4
4
|
export declare function createCodexAppServerProvider(input?: string | ProviderExecution): ProviderAdapter;
|
|
5
|
-
export declare const codexAppServerProvider: Readonly<{
|
|
6
|
-
confinement(input: Readonly<{
|
|
7
|
-
cwd: string;
|
|
8
|
-
options: ProviderOptions;
|
|
9
|
-
}>): import("../../index.js").Confinement;
|
|
10
|
-
admitOptions(options: ProviderOptions): import("../../provider.js").ProviderOptionAdmission;
|
|
11
|
-
fork?(input: Readonly<{
|
|
12
|
-
session: import("../../coordinate.js").ResumeCoordinate;
|
|
13
|
-
at: string;
|
|
14
|
-
cwd: string;
|
|
15
|
-
}>): Promise<Readonly<{
|
|
16
|
-
session: import("../../coordinate.js").ResumeCoordinate;
|
|
17
|
-
}>>;
|
|
18
|
-
start(input: import("../../provider.js").DriveInput & Readonly<{
|
|
19
|
-
session: Readonly<{
|
|
20
|
-
kind: "fresh";
|
|
21
|
-
}>;
|
|
22
|
-
}>): Promise<Session>;
|
|
23
|
-
resume?(input: import("../../provider.js").DriveInput & Readonly<{
|
|
24
|
-
session: Readonly<{
|
|
25
|
-
kind: "resume";
|
|
26
|
-
coordinate: import("../../coordinate.js").ResumeCoordinate;
|
|
27
|
-
}>;
|
|
28
|
-
}>): Promise<Session>;
|
|
29
|
-
}>;
|
|
@@ -190,7 +190,6 @@ export function createCodexAppServerProvider(input = "codex") {
|
|
|
190
190
|
? { name: "codex-app-server", kind: "codex-app-server", executable: input }
|
|
191
191
|
: input;
|
|
192
192
|
return {
|
|
193
|
-
confinement: ({ cwd }) => ({ kind: "declared", writableRoots: [cwd] }),
|
|
194
193
|
admitOptions(options) {
|
|
195
194
|
return {
|
|
196
195
|
kind: "admitted",
|
|
@@ -203,4 +202,3 @@ export function createCodexAppServerProvider(input = "codex") {
|
|
|
203
202
|
resume: (input) => startCodex(execution, input),
|
|
204
203
|
};
|
|
205
204
|
}
|
|
206
|
-
export const codexAppServerProvider = createCodexAppServerProvider();
|
|
@@ -132,7 +132,6 @@ export function createGrokBuildProvider(execution, dependencies = {}) {
|
|
|
132
132
|
}));
|
|
133
133
|
};
|
|
134
134
|
return {
|
|
135
|
-
confinement: () => ({ kind: "unconfined" }),
|
|
136
135
|
admitOptions: optionAdmission,
|
|
137
136
|
start: async (input) => await drive(input),
|
|
138
137
|
resume: async (input) => await drive(input),
|
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
import { type ProviderAdapter
|
|
2
|
-
import type {
|
|
3
|
-
import type { ProviderExecution, ProviderOptions } from "../../provider-recipe.js";
|
|
1
|
+
import { type ProviderAdapter } from "../../provider.js";
|
|
2
|
+
import type { ProviderExecution } from "../../provider-recipe.js";
|
|
4
3
|
import { type OpencodeSdkLoader } from "./session.js";
|
|
5
4
|
export type OpencodeProviderTestOptions = Readonly<{
|
|
6
5
|
loader?: OpencodeSdkLoader;
|
|
7
6
|
}>;
|
|
8
7
|
export declare function createOpencodeProvider(input?: ProviderExecution | OpencodeProviderTestOptions): ProviderAdapter;
|
|
9
|
-
export declare const opencodeProvider: Readonly<{
|
|
10
|
-
confinement(input: Readonly<{
|
|
11
|
-
cwd: string;
|
|
12
|
-
options: ProviderOptions;
|
|
13
|
-
}>): import("../../heart/facts.js").Confinement;
|
|
14
|
-
admitOptions(options: ProviderOptions): import("../../provider.js").ProviderOptionAdmission;
|
|
15
|
-
fork?(input: Readonly<{
|
|
16
|
-
session: ResumeCoordinate;
|
|
17
|
-
at: string;
|
|
18
|
-
cwd: string;
|
|
19
|
-
}>): Promise<Readonly<{
|
|
20
|
-
session: ResumeCoordinate;
|
|
21
|
-
}>>;
|
|
22
|
-
start(input: import("../../provider.js").DriveInput & Readonly<{
|
|
23
|
-
session: Readonly<{
|
|
24
|
-
kind: "fresh";
|
|
25
|
-
}>;
|
|
26
|
-
}>): Promise<Session>;
|
|
27
|
-
resume?(input: import("../../provider.js").DriveInput & Readonly<{
|
|
28
|
-
session: Readonly<{
|
|
29
|
-
kind: "resume";
|
|
30
|
-
coordinate: ResumeCoordinate;
|
|
31
|
-
}>;
|
|
32
|
-
}>): Promise<Session>;
|
|
33
|
-
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { abortable } from "../../abort.js";
|
|
3
|
-
import { AgentEventChannel } from "../../provider.js";
|
|
3
|
+
import { AKUMA_REQUESTS_ENV, AgentEventChannel, } from "../../provider.js";
|
|
4
4
|
import { createEventState, mapEvent } from "./events.js";
|
|
5
5
|
import { coordinate, loadOpencode, OPENCODE_SDK_PROVIDER, parseModel } from "./session.js";
|
|
6
6
|
function object(value) {
|
|
@@ -205,7 +205,13 @@ async function drive(execution, input, loader) {
|
|
|
205
205
|
const abortSetup = () => abortController.abort(signal.reason);
|
|
206
206
|
signal.addEventListener("abort", abortSetup, { once: true });
|
|
207
207
|
signal.throwIfAborted();
|
|
208
|
-
const runtime = await abortable(loadOpencode(
|
|
208
|
+
const runtime = await abortable(loadOpencode({
|
|
209
|
+
...execution,
|
|
210
|
+
env: {
|
|
211
|
+
...execution.env,
|
|
212
|
+
...(input.requests === undefined ? {} : { [AKUMA_REQUESTS_ENV]: input.requests.dir }),
|
|
213
|
+
},
|
|
214
|
+
}, input.cwd, abortController.signal, loader), abortController.signal, async (late) => await late.close());
|
|
209
215
|
let closing;
|
|
210
216
|
let iterator;
|
|
211
217
|
const closeOnce = () => {
|
|
@@ -263,7 +269,6 @@ export function createOpencodeProvider(input = { name: OPENCODE_SDK_PROVIDER, ki
|
|
|
263
269
|
const execution = "kind" in input ? input : { name: OPENCODE_SDK_PROVIDER, kind: "opencode-sdk" };
|
|
264
270
|
const loader = "loader" in input ? input.loader : undefined;
|
|
265
271
|
return {
|
|
266
|
-
confinement: ({ cwd }) => ({ kind: "declared", writableRoots: [cwd] }),
|
|
267
272
|
admitOptions(options) {
|
|
268
273
|
try {
|
|
269
274
|
admit(options);
|
|
@@ -305,4 +310,3 @@ export function createOpencodeProvider(input = { name: OPENCODE_SDK_PROVIDER, ki
|
|
|
305
310
|
},
|
|
306
311
|
};
|
|
307
312
|
}
|
|
308
|
-
export const opencodeProvider = createOpencodeProvider();
|
|
@@ -3,7 +3,7 @@ import type { ResumeCoordinate } from "../../heart/index.js";
|
|
|
3
3
|
import type { ProviderExecution } from "../../provider-recipe.js";
|
|
4
4
|
export type OpencodeSdkSession = Pick<OpencodeClient["session"], "create" | "get" | "fork" | "abort" | "promptAsync" | "messages">;
|
|
5
5
|
export type OpencodeSdkEvent = Pick<OpencodeClient["event"], "subscribe">;
|
|
6
|
-
export type OpencodeSdkLoader = (cwd: string) => Promise<Readonly<{
|
|
6
|
+
export type OpencodeSdkLoader = (cwd: string, execution: ProviderExecution) => Promise<Readonly<{
|
|
7
7
|
client: {
|
|
8
8
|
session: OpencodeSdkSession;
|
|
9
9
|
event: OpencodeSdkEvent;
|
|
@@ -40,7 +40,7 @@ async function availablePort() {
|
|
|
40
40
|
}
|
|
41
41
|
export async function loadOpencode(execution, cwd, signal, loader) {
|
|
42
42
|
if (loader) {
|
|
43
|
-
const loaded = await loader(cwd);
|
|
43
|
+
const loaded = await loader(cwd, execution);
|
|
44
44
|
return { client: loaded.client, close: async () => { await loaded.close?.(); } };
|
|
45
45
|
}
|
|
46
46
|
const port = await availablePort();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { createAgentSession, DefaultResourceLoader, getAgentDir, ModelRuntime, SessionManager, } from "@earendil-works/pi-coding-agent";
|
|
1
|
+
import { createAgentSession, createBashToolDefinition, DefaultResourceLoader, getAgentDir, ModelRuntime, SessionManager, } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { abortable } from "../../abort.js";
|
|
3
|
-
import { AgentEventChannel } from "../../provider.js";
|
|
3
|
+
import { AKUMA_REQUESTS_ENV, AgentEventChannel, } from "../../provider.js";
|
|
4
4
|
import { piTerminalFailure, translatePiEvent } from "./events.js";
|
|
5
5
|
const PI_THINKING_LEVELS = new Set(["minimal", "low", "medium", "high", "xhigh", "max"]);
|
|
6
|
-
const MODEL_PATTERN = /^[^/\s]+\/[
|
|
6
|
+
const MODEL_PATTERN = /^[^/\s]+\/[^\s]+$/u;
|
|
7
7
|
function diagnostic(error) { return error instanceof Error ? error.message : String(error); }
|
|
8
8
|
function admitPiOptions(options) {
|
|
9
9
|
if (options.network !== undefined)
|
|
@@ -48,6 +48,14 @@ async function piCreateOptions(sdk, input) {
|
|
|
48
48
|
...(resourceLoader === undefined ? {} : { resourceLoader }),
|
|
49
49
|
...(input.options.effort === undefined ? {} : { thinkingLevel: input.options.effort }),
|
|
50
50
|
...(input.options.readonly === undefined ? {} : { tools: ["read", "grep", "find", "ls"] }),
|
|
51
|
+
...(input.requests === undefined || input.options.readonly === true
|
|
52
|
+
? {}
|
|
53
|
+
: { customTools: [createBashToolDefinition(input.cwd, {
|
|
54
|
+
spawnHook: (context) => ({
|
|
55
|
+
...context,
|
|
56
|
+
env: { ...context.env, [AKUMA_REQUESTS_ENV]: input.requests.dir },
|
|
57
|
+
}),
|
|
58
|
+
})] }),
|
|
51
59
|
};
|
|
52
60
|
}
|
|
53
61
|
async function createPiSession(sdk, input, signal) {
|
|
@@ -176,7 +184,6 @@ export function createPiProvider(execution = { name: "pi", kind: "pi" }, load =
|
|
|
176
184
|
return drivePi(await abortable(load(), signal), input, signal);
|
|
177
185
|
};
|
|
178
186
|
return {
|
|
179
|
-
confinement: ({ cwd }) => ({ kind: "declared", writableRoots: [cwd] }),
|
|
180
187
|
admitOptions: admitPiOptions,
|
|
181
188
|
start: drive,
|
|
182
189
|
resume: async (input) => {
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { type KillEvidence, type Soul } from "./heart/index.js";
|
|
2
|
+
import { type AkuId, type AkumaPaths } from "./identity.js";
|
|
3
|
+
import { type TaskMutationRequest } from "../task/mutation.js";
|
|
4
|
+
export type RequestChildLaunch = Readonly<{
|
|
5
|
+
paths: AkumaPaths;
|
|
6
|
+
seed: Omit<Soul, "createdAt">;
|
|
7
|
+
initialBody: string;
|
|
8
|
+
}>;
|
|
9
|
+
type UpstreamCall = Readonly<{
|
|
10
|
+
signal: AbortSignal;
|
|
11
|
+
}>;
|
|
12
|
+
type RequesterCall = UpstreamCall & Readonly<{
|
|
13
|
+
requester: AkuId;
|
|
14
|
+
}>;
|
|
15
|
+
type ContractCall = RequesterCall & Readonly<{
|
|
16
|
+
repoRoot: string;
|
|
17
|
+
contractId: string;
|
|
18
|
+
}>;
|
|
19
|
+
export type UpstreamExecutionPort = Readonly<{
|
|
20
|
+
wait(input: UpstreamCall & Readonly<{
|
|
21
|
+
targets: readonly AkuId[];
|
|
22
|
+
completion: "any" | "all";
|
|
23
|
+
timeoutMs?: number;
|
|
24
|
+
}>): Promise<unknown>;
|
|
25
|
+
tell(input: UpstreamCall & Readonly<{
|
|
26
|
+
target: AkuId;
|
|
27
|
+
body: string;
|
|
28
|
+
tellId: string;
|
|
29
|
+
recordedAt: string;
|
|
30
|
+
}>): Promise<unknown>;
|
|
31
|
+
kill(input: Readonly<{
|
|
32
|
+
targets: readonly AkuId[];
|
|
33
|
+
signal: AbortSignal;
|
|
34
|
+
}>): Promise<Readonly<{
|
|
35
|
+
result: unknown;
|
|
36
|
+
service: readonly Readonly<{
|
|
37
|
+
id: AkuId;
|
|
38
|
+
evidence: KillEvidence;
|
|
39
|
+
}>[];
|
|
40
|
+
}>>;
|
|
41
|
+
deliver(input: ContractCall & Readonly<{
|
|
42
|
+
message?: string;
|
|
43
|
+
includeDirty: boolean;
|
|
44
|
+
}>): Promise<Readonly<{
|
|
45
|
+
result: unknown;
|
|
46
|
+
deliveryFactId?: string;
|
|
47
|
+
}>>;
|
|
48
|
+
review(input: ContractCall & Readonly<{
|
|
49
|
+
verdict: "satisfied" | "unsatisfied";
|
|
50
|
+
summary?: string;
|
|
51
|
+
}>): Promise<Readonly<{
|
|
52
|
+
result: unknown;
|
|
53
|
+
reviewFactId?: string;
|
|
54
|
+
}>>;
|
|
55
|
+
task(input: RequesterCall & Readonly<{
|
|
56
|
+
world: string;
|
|
57
|
+
request: TaskMutationRequest;
|
|
58
|
+
}>): Promise<unknown>;
|
|
59
|
+
}>;
|
|
60
|
+
type PumpInput = Readonly<{
|
|
61
|
+
paths: AkumaPaths;
|
|
62
|
+
parent: Soul;
|
|
63
|
+
bodySequence: number;
|
|
64
|
+
now(): string;
|
|
65
|
+
spawn(launch: RequestChildLaunch): Promise<void>;
|
|
66
|
+
upstream?: UpstreamExecutionPort;
|
|
67
|
+
signal: AbortSignal;
|
|
68
|
+
}>;
|
|
69
|
+
export declare class BodyRequestPump {
|
|
70
|
+
private readonly input;
|
|
71
|
+
readonly directory: string;
|
|
72
|
+
readonly failure: Promise<never>;
|
|
73
|
+
private readonly closeSignal;
|
|
74
|
+
private readonly executionSignal;
|
|
75
|
+
private readonly handled;
|
|
76
|
+
private readonly running;
|
|
77
|
+
private readonly cancelBody;
|
|
78
|
+
private admissionClosed;
|
|
79
|
+
private constructor();
|
|
80
|
+
static open(input: PumpInput): Promise<BodyRequestPump>;
|
|
81
|
+
private run;
|
|
82
|
+
close(): Promise<void>;
|
|
83
|
+
stopAdmission(): void;
|
|
84
|
+
}
|
|
85
|
+
export declare function clearBodyRequestTransport(paths: AkumaPaths): Promise<void>;
|
|
86
|
+
export declare function settleBodyRequests(paths: AkumaPaths, parent: Soul, now: () => string, signal?: AbortSignal): Promise<"settled" | "pending">;
|
|
87
|
+
export {};
|