omp-superagent 0.1.9 → 0.1.11
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/DESIGN.md +68 -21
- package/README.ko.md +30 -372
- package/README.md +31 -419
- package/THIRD_PARTY_NOTICES.md +35 -436
- package/assets/architecture-dark.svg +7 -12
- package/assets/architecture.ko-dark.svg +7 -12
- package/assets/architecture.ko.svg +7 -12
- package/assets/architecture.mmd +5 -13
- package/assets/architecture.svg +7 -12
- package/config.example.json +8 -0
- package/docs/OPERATIONS.en.md +2277 -0
- package/docs/OPERATIONS.md +198 -45
- package/docs/design/execution.md +163 -54
- package/docs/design/messaging.md +125 -34
- package/docs/kakao-bridge-protocol.md +193 -0
- package/docs/releases/0.1.10.md +17 -0
- package/docs/releases/0.1.11.md +18 -0
- package/gateway/bin/omp-gateway-darwin-arm64 +0 -0
- package/gateway/bin/omp-gateway-darwin-x64 +0 -0
- package/gateway/bin/omp-gateway-linux-arm64 +0 -0
- package/gateway/bin/omp-gateway-linux-x64 +0 -0
- package/host-owner/bin/omp-host-owner-darwin-arm64 +0 -0
- package/host-owner/bin/omp-host-owner-darwin-x64 +0 -0
- package/host-owner/bin/omp-host-owner-linux-arm64 +0 -0
- package/host-owner/bin/omp-host-owner-linux-x64 +0 -0
- package/package.json +10 -11
- package/scripts/{prepare-ulw.ts → prepare-super.ts} +1 -1
- package/skills/head/SKILL.md +36 -5
- package/skills/head/references/routing.md +1 -1
- package/skills/head/references/supervision.md +32 -26
- package/skills/lane/SKILL.md +39 -21
- package/skills/lane/references/workflow.md +23 -16
- package/src/cli.ts +35 -33
- package/src/{config.ts → config/config.ts} +51 -6
- package/src/config/wake-config.ts +36 -0
- package/src/contracts.ts +91 -13
- package/src/{cron-jobs.ts → cron/cron-jobs.ts} +21 -13
- package/src/{cron-pr-intake.ts → cron/cron-pr-intake.ts} +4 -4
- package/src/{cron-schedule.ts → cron/cron-schedule.ts} +3 -3
- package/src/extension.ts +64 -28
- package/src/{gateway-client.ts → gateway/gateway-client.ts} +89 -32
- package/src/{gateway-native.ts → gateway/gateway-native.ts} +4 -4
- package/src/{gateway-protocol.ts → gateway/gateway-protocol.ts} +69 -14
- package/src/{gateway-wire.ts → gateway/gateway-wire.ts} +12 -7
- package/src/gateway-config.ts +1 -1
- package/src/gateway-restart-env.ts +3 -3
- package/src/{group-access.ts → group/group-access.ts} +8 -3
- package/src/{group-policy.ts → group/group-policy.ts} +2 -2
- package/src/{group-runner.ts → group/group-runner.ts} +11 -6
- package/src/host-extension.ts +213 -43
- package/src/host-sdk-helper.ts +62 -65
- package/src/{decision-tool.ts → lane/decision-tool.ts} +12 -4
- package/src/{decisions.ts → lane/decisions.ts} +12 -10
- package/src/{lane-models.ts → lane/lane-models.ts} +1 -1
- package/src/{lane-report.ts → lane/lane-report.ts} +22 -0
- package/src/{lane-rows.ts → lane/lane-rows.ts} +2 -2
- package/src/{lane-watch.ts → lane/lane-watch.ts} +6 -2
- package/src/{workflow.ts → lane/workflow.ts} +1 -1
- package/src/lane-extension.ts +69 -13
- package/src/managed-memory-helper.ts +2 -2
- package/src/{managed-ulw-probe.ts → managed-super-probe.ts} +3 -3
- package/src/{delivery.ts → messaging/delivery.ts} +1 -1
- package/src/{discord-command-registration.ts → messaging/discord-command-registration.ts} +3 -2
- package/src/{discord-context.ts → messaging/discord-context.ts} +1 -1
- package/src/{messenger-command-catalog.json → messaging/messenger-command-catalog.json} +1 -0
- package/src/messaging/messenger-commands.ts +55 -0
- package/src/{result-attachment.ts → messaging/result-attachment.ts} +3 -3
- package/src/{slack-command-registration.ts → messaging/slack-command-registration.ts} +3 -3
- package/src/{telegram-command-registration.ts → messaging/telegram-command-registration.ts} +2 -2
- package/src/omp/head-resume.ts +123 -0
- package/src/{host-owner-path.ts → omp/host-owner-path.ts} +1 -1
- package/src/{host-protocol.ts → omp/host-protocol.ts} +11 -2
- package/src/omp/host-reply-voice.ts +181 -0
- package/src/{host-superkit.ts → omp/host-superkit.ts} +1 -1
- package/src/{host.ts → omp/host.ts} +26 -17
- package/src/{installed-omp.ts → omp/installed-omp.ts} +1 -1
- package/src/{managed-memory.ts → omp/managed-memory.ts} +2 -2
- package/src/{managed-ulw.ts → omp/managed-super.ts} +42 -16
- package/src/omp/native-journal.ts +124 -0
- package/src/{native-launch-profile.ts → omp/native-launch-profile.ts} +6 -2
- package/src/{native-presets.ts → omp/native-presets.ts} +2 -2
- package/src/omp/native-sessions.ts +124 -0
- package/src/{omp-usage.ts → omp/omp-usage.ts} +1 -1
- package/src/omp/soul.ts +214 -0
- package/src/omp/stock-head-launch.ts +31 -0
- package/src/{autostart.ts → operator/autostart.ts} +3 -3
- package/src/{operator.ts → operator/operator.ts} +2 -2
- package/src/{setup-judge.ts → operator/setup-judge.ts} +1 -1
- package/src/{setup-profiles.ts → operator/setup-profiles.ts} +2 -2
- package/src/{setup.ts → operator/setup.ts} +7 -6
- package/src/{pr-intake-automation.ts → pr/pr-intake-automation.ts} +1 -1
- package/src/{pr-intake-mode.ts → pr/pr-intake-mode.ts} +3 -3
- package/src/{pr-intake-review.ts → pr/pr-intake-review.ts} +5 -5
- package/src/{pr-intake-work.ts → pr/pr-intake-work.ts} +1 -1
- package/src/{pr-review-models.ts → pr/pr-review-models.ts} +2 -2
- package/src/{pr-watch.ts → pr/pr-watch.ts} +36 -26
- package/src/{message-order.ts → routing/message-order.ts} +3 -2
- package/src/{topic-history.ts → routing/topic-history.ts} +2 -2
- package/src/{topic-request.ts → routing/topic-request.ts} +4 -2
- package/src/{runtime.ts → runtime/controller.ts} +1278 -1267
- package/src/runtime/deferred-routing.ts +106 -0
- package/src/runtime/dm-timeline.ts +194 -0
- package/src/{head-recovery.ts → runtime/head-recovery.ts} +1 -1
- package/src/{head-rotation.ts → runtime/head-rotation.ts} +32 -5
- package/src/runtime/model-journal.ts +119 -0
- package/src/runtime/native-frames.ts +131 -0
- package/src/{observation-request.ts → runtime/observation-request.ts} +1 -1
- package/src/runtime/preset-sync.ts +232 -0
- package/src/runtime/preset-watch-paths.ts +137 -0
- package/src/runtime/result-attachments.ts +146 -0
- package/src/storage/deferred-routing.ts +149 -0
- package/src/{store.ts → storage/store.ts} +450 -49
- package/src/{worker-bridge.ts → worker/worker-bridge.ts} +2 -2
- package/src/{worker-enrollment.ts → worker/worker-enrollment.ts} +2 -2
- package/src/{worker-host.ts → worker/worker-host.ts} +7 -3
- package/src/{worker-placement.ts → worker/worker-placement.ts} +1 -1
- package/src/{worker-profile.ts → worker/worker-profile.ts} +1 -1
- package/src/{worker-registration.ts → worker/worker-registration.ts} +2 -2
- package/src/{worker-request.ts → worker/worker-request.ts} +5 -5
- package/src/{worker-service.ts → worker/worker-service.ts} +2 -2
- package/src/{worker-trust.ts → worker/worker-trust.ts} +1 -1
- package/src/{worker-wire.ts → worker/worker-wire.ts} +3 -3
- package/src/worker-serve-prepare.ts +4 -4
- package/src/board-extension.ts +0 -217
- package/src/board.ts +0 -467
- package/src/gateway-host-helper.ts +0 -13
- package/src/messenger-commands.ts +0 -15
- package/src/native-sessions.ts +0 -34
- /package/src/{credentials.ts → config/credentials.ts} +0 -0
- /package/src/{dialog.ts → messaging/dialog.ts} +0 -0
- /package/src/{telegram-command-languages.json → messaging/telegram-command-languages.json} +0 -0
- /package/src/{host-broker-services.ts → omp/host-broker-services.ts} +0 -0
- /package/src/{host-inventory-manifest.ts → omp/host-inventory-manifest.ts} +0 -0
- /package/src/{host-services.ts → omp/host-services.ts} +0 -0
- /package/src/{native-settings.ts → omp/native-settings.ts} +0 -0
- /package/src/{superkit-skills.ts → omp/superkit-skills.ts} +0 -0
- /package/src/{repository.ts → operator/repository.ts} +0 -0
- /package/src/{pr-github-schema.ts → pr/pr-github-schema.ts} +0 -0
- /package/src/{pr-github.ts → pr/pr-github.ts} +0 -0
- /package/src/{pr-intake-comment.ts → pr/pr-intake-comment.ts} +0 -0
- /package/src/{pr-intake-fix.ts → pr/pr-intake-fix.ts} +0 -0
- /package/src/{pr-intake-github.ts → pr/pr-intake-github.ts} +0 -0
- /package/src/{pr-intake-material.ts → pr/pr-intake-material.ts} +0 -0
- /package/src/{pr-intake-tree.ts → pr/pr-intake-tree.ts} +0 -0
- /package/src/{head-quota.ts → runtime/head-quota.ts} +0 -0
- /package/src/{worker-checkout.ts → worker/worker-checkout.ts} +0 -0
- /package/src/{worker-destination.ts → worker/worker-destination.ts} +0 -0
- /package/src/{worker-doctor.ts → worker/worker-doctor.ts} +0 -0
- /package/src/{worker-ledger.ts → worker/worker-ledger.ts} +0 -0
- /package/src/{worker-repository.ts → worker/worker-repository.ts} +0 -0
- /package/upstream/{ulw.json → super.json} +0 -0
package/src/host-sdk-helper.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// Short-lived SDK operations. The Rust owner, not this process, owns native stdin and the reconnectable socket.
|
|
2
2
|
import { dirname } from "node:path";
|
|
3
3
|
import { isDeepStrictEqual } from "node:util";
|
|
4
|
-
import { chmod, rename, writeFile } from "node:fs/promises";
|
|
4
|
+
import { chmod, lstat, rename, writeFile } from "node:fs/promises";
|
|
5
5
|
import type { RpcAbortAndRestoreQueueResult } from "@oh-my-pi/pi-coding-agent/modes/rpc/rpc-types";
|
|
6
|
-
import type { HostOptions } from "./host";
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
6
|
+
import type { HostOptions } from "./omp/host";
|
|
7
|
+
import type { RotationSelection } from "./runtime/head-rotation";
|
|
8
|
+
import type { ManagedUlwLaunchComposition, ManagedUlwLaunchInput } from "./omp/managed-super";
|
|
9
|
+
import type { NativeProfile, NativeProfileBinding } from "./omp/native-sessions";
|
|
10
|
+
import { launchArgvHash, stockReplayRefusal } from "./omp/stock-head-launch";
|
|
10
11
|
|
|
11
12
|
type Manifest = {
|
|
12
13
|
readonly options: Omit<HostOptions, "env">;
|
|
@@ -14,57 +15,19 @@ type Manifest = {
|
|
|
14
15
|
readonly configPath: string;
|
|
15
16
|
readonly processBackend: "broker" | "daemon";
|
|
16
17
|
readonly headRotationSelection?: RotationSelection;
|
|
18
|
+
readonly headHibernationSessionId?: string;
|
|
19
|
+
readonly expectedNativeProfile?: NativeProfile;
|
|
17
20
|
};
|
|
18
|
-
type Exit = {
|
|
19
|
-
readonly pid: number; readonly ownerPid: number; readonly code: number | null; readonly signal: string | null;
|
|
20
|
-
readonly sessionId: string; readonly instanceKey?: string | null; readonly runOrdinal: number;
|
|
21
|
-
readonly workerAttempt?: string | null;
|
|
22
|
-
readonly observationFailure: boolean; readonly expectedObservations: readonly [string, Frame][];
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
async function verifyExit({ options }: Manifest, exit: Exit) {
|
|
26
|
-
const { visitEntriesFromFileStream } = await import("@oh-my-pi/pi-coding-agent/session/session-loader");
|
|
27
|
-
const expected = new Map(exit.expectedObservations);
|
|
28
|
-
const starts = new Set<number>();
|
|
29
|
-
let duplicate = false;
|
|
30
|
-
let malformed = false;
|
|
31
|
-
let header = false;
|
|
32
|
-
await visitEntriesFromFileStream(options.sessionFile, entry => {
|
|
33
|
-
if (entry.type === "session") { header ||= entry.id === exit.sessionId; return; }
|
|
34
|
-
if (entry.type !== "custom" || !entry.data || typeof entry.data !== "object") return;
|
|
35
|
-
const data = entry.data as Frame;
|
|
36
|
-
if (data.instanceKey !== (exit.instanceKey ?? undefined)) return;
|
|
37
|
-
if (entry.customType === "rpc_prompt_result" && expected.has(entry.id) &&
|
|
38
|
-
isDeepStrictEqual(data.frame, expected.get(entry.id))) expected.delete(entry.id);
|
|
39
|
-
if (entry.customType === "rpc_agent_start" && data.hostPid === exit.pid && typeof data.runOrdinal === "number" &&
|
|
40
|
-
Number.isSafeInteger(data.runOrdinal) && data.runOrdinal >= 1 && data.runOrdinal <= exit.runOrdinal) {
|
|
41
|
-
duplicate ||= starts.has(data.runOrdinal);
|
|
42
|
-
starts.add(data.runOrdinal);
|
|
43
|
-
}
|
|
44
|
-
}, { throwIfMissing: true, onMalformedRecord: () => { malformed = true; } });
|
|
45
|
-
const journal = Bun.file(options.sessionFile);
|
|
46
|
-
const size = journal.size;
|
|
47
|
-
const persisted = header && !malformed && size > 0 && (await journal.slice(size - 1, size).text()) === "\n";
|
|
48
|
-
const observationsFlushed = !exit.observationFailure && !expected.size && !duplicate && starts.size === exit.runOrdinal;
|
|
49
|
-
const { pid, ownerPid, sessionId, code, signal } = exit;
|
|
50
|
-
const receipt = `${options.socketPath}.exit.json`;
|
|
51
|
-
const temporary = `${receipt}.${crypto.randomUUID()}`;
|
|
52
|
-
await writeFile(temporary, JSON.stringify({ pid, ownerPid, sessionId, sessionFile: options.sessionFile, code,
|
|
53
|
-
...(exit.workerAttempt ? { workerAttempt: exit.workerAttempt } : {}),
|
|
54
|
-
signal, persisted, observationsFlushed }), { mode: 0o600, flag: "wx" });
|
|
55
|
-
await rename(temporary, receipt);
|
|
56
|
-
if (!persisted || !observationsFlushed) throw new Error("Native exit persistence is unconfirmed");
|
|
57
|
-
return { persisted, observationsFlushed };
|
|
58
|
-
}
|
|
59
21
|
|
|
60
|
-
async function run(operation: string | undefined, manifest: Manifest, input: unknown,
|
|
22
|
+
async function run(operation: string | undefined, manifest: Manifest, input: unknown, nativeProfile?: NativeProfile) {
|
|
61
23
|
const { options } = manifest;
|
|
62
24
|
const { extractProfileFlags } = await import("@oh-my-pi/pi-coding-agent/cli/profile-bootstrap");
|
|
63
|
-
const
|
|
25
|
+
const launchArgs = [...options.command.slice(1), ...manifest.args];
|
|
26
|
+
const bootstrap = extractProfileFlags(launchArgs);
|
|
64
27
|
// Native discovery already selected the profile and applied dotenv.
|
|
65
28
|
// Rebootstrapping now would re-select from the mutated environment or
|
|
66
29
|
// clear its effective agent directory before publishing the session.
|
|
67
|
-
if (!
|
|
30
|
+
if (!nativeProfile) {
|
|
68
31
|
const { setProfile, resolveProfileEnv } = await import("@oh-my-pi/pi-utils/dirs");
|
|
69
32
|
setProfile(bootstrap.profile ?? resolveProfileEnv(process.env.OMP_PROFILE, process.env.PI_PROFILE));
|
|
70
33
|
}
|
|
@@ -75,8 +38,19 @@ async function run(operation: string | undefined, manifest: Manifest, input: unk
|
|
|
75
38
|
const argv = resolveCliArgv(bootstrap.argv);
|
|
76
39
|
if ("error" in argv) throw new Error(argv.error);
|
|
77
40
|
const parsed = parseArgs(argv.argv.slice(1));
|
|
41
|
+
const emptyToolSelection = parsed.tools?.length === 0;
|
|
42
|
+
const parkedSession = manifest.headHibernationSessionId;
|
|
43
|
+
const { matchesNativeProfile, publishNativeSession, sdkNativeProfilePaths } = await import("./omp/native-sessions");
|
|
44
|
+
const requireNativeProfile = () => {
|
|
45
|
+
const expected = manifest.expectedNativeProfile;
|
|
46
|
+
if ((nativeProfile && !matchesNativeProfile(sdkNativeProfilePaths(), nativeProfile))
|
|
47
|
+
|| (expected !== undefined && !isDeepStrictEqual(nativeProfile, expected))
|
|
48
|
+
|| (parkedSession !== undefined && expected === undefined))
|
|
49
|
+
throw new Error("Native profile changed before journal preparation or publication");
|
|
50
|
+
};
|
|
51
|
+
requireNativeProfile();
|
|
78
52
|
if (options.prReviewOnly) {
|
|
79
|
-
if (parsed.noTools
|
|
53
|
+
if (parsed.noTools === true || !emptyToolSelection || !parsed.noExtensions ||
|
|
80
54
|
!parsed.noSkills || !parsed.noRules || !parsed.noContextFiles || !parsed.noLsp ||
|
|
81
55
|
!parsed.noTitle || !parsed.noPrewalk || !parsed.offline ||
|
|
82
56
|
parsed.trustedExtensions?.length !== 1 || parsed.config?.length !== 1 || parsed.config[0] !== manifest.configPath)
|
|
@@ -86,7 +60,7 @@ async function run(operation: string | undefined, manifest: Manifest, input: unk
|
|
|
86
60
|
const { cfgDisabledProviders } = await import("@oh-my-pi/pi-coding-agent/config/model-settings");
|
|
87
61
|
const { getAllCapabilitiesInfo } = await import("@oh-my-pi/pi-coding-agent/discovery");
|
|
88
62
|
const { getAllPluginToolPaths } = await import("@oh-my-pi/pi-coding-agent/extensibility/plugins/loader");
|
|
89
|
-
const { PR_REVIEW_GITHUB_ENV } = await import("./host-protocol");
|
|
63
|
+
const { PR_REVIEW_GITHUB_ENV } = await import("./omp/host-protocol");
|
|
90
64
|
if (PR_REVIEW_GITHUB_ENV.some(name => process.env[name]))
|
|
91
65
|
throw new Error("Static PR review cannot load GitHub credentials from the native profile");
|
|
92
66
|
const native = await Settings.loadReadOnly({ cwd: options.cwd, agentDir: getAgentDir() });
|
|
@@ -105,9 +79,15 @@ async function run(operation: string | undefined, manifest: Manifest, input: unk
|
|
|
105
79
|
await writeFile(staging, JSON.stringify({ ...overlay, disabledProviders: [...disabled] }), { mode: 0o600, flag: "wx" });
|
|
106
80
|
await rename(staging, manifest.configPath);
|
|
107
81
|
}
|
|
108
|
-
const {
|
|
82
|
+
const { stat } = await import("node:fs/promises");
|
|
109
83
|
const expectedWorkerSession = process.env.OMP_SUPERAGENT_WORKER_EXPECTED_SESSION;
|
|
110
|
-
const
|
|
84
|
+
const inspect = expectedWorkerSession !== undefined || parkedSession !== undefined || options.prReviewOnly ? lstat : stat;
|
|
85
|
+
const missing = await inspect(options.sessionFile).then(async info => {
|
|
86
|
+
if (parkedSession !== undefined) {
|
|
87
|
+
const { readNativeSessionId } = await import("./omp/native-journal");
|
|
88
|
+
if (!info.isFile() || !parkedSession || await readNativeSessionId(options.sessionFile, info) !== parkedSession)
|
|
89
|
+
throw new Error("HEAD journal no longer matches the hibernated session");
|
|
90
|
+
}
|
|
111
91
|
if (expectedWorkerSession !== undefined) {
|
|
112
92
|
const { readSessionHeaderId } = await import("@oh-my-pi/pi-coding-agent/session/session-loader");
|
|
113
93
|
if (!info.isFile() || !expectedWorkerSession || await readSessionHeaderId(options.sessionFile) !== expectedWorkerSession)
|
|
@@ -127,10 +107,12 @@ async function run(operation: string | undefined, manifest: Manifest, input: unk
|
|
|
127
107
|
return false;
|
|
128
108
|
}, error => {
|
|
129
109
|
if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) throw error;
|
|
110
|
+
if (parkedSession !== undefined) throw new Error("Cannot recreate a missing hibernated HEAD session");
|
|
130
111
|
if (expectedWorkerSession) throw new Error("Worker cannot recreate a missing reserved session");
|
|
131
112
|
return true;
|
|
132
113
|
});
|
|
133
114
|
if (missing) {
|
|
115
|
+
requireNativeProfile();
|
|
134
116
|
const { SessionManager } = await import("@oh-my-pi/pi-coding-agent/session/session-manager");
|
|
135
117
|
const session = SessionManager.create(options.cwd, dirname(options.sessionFile));
|
|
136
118
|
try {
|
|
@@ -139,7 +121,7 @@ async function run(operation: string | undefined, manifest: Manifest, input: unk
|
|
|
139
121
|
session.appendCustomEntry("superagent_pr_review_policy", { version: 1, cwd: options.cwd });
|
|
140
122
|
const selection = manifest.headRotationSelection;
|
|
141
123
|
if (selection) {
|
|
142
|
-
session.appendModelChange(`${selection.provider}/${selection.modelId}`);
|
|
124
|
+
session.appendModelChange(selection.modelIdentity ?? `${selection.provider}/${selection.modelId}`);
|
|
143
125
|
session.appendThinkingLevelChange(selection.thinkingLevel ?? undefined, selection.configuredThinkingLevel ?? undefined);
|
|
144
126
|
}
|
|
145
127
|
await session.ensureOnDisk();
|
|
@@ -147,19 +129,28 @@ async function run(operation: string | undefined, manifest: Manifest, input: unk
|
|
|
147
129
|
} finally { await session.close(); }
|
|
148
130
|
if (options.prReviewOnly) await chmod(options.sessionFile, 0o600);
|
|
149
131
|
}
|
|
132
|
+
let nativeProfileBinding: NativeProfileBinding | undefined;
|
|
150
133
|
if (!options.prReviewOnly) {
|
|
151
|
-
|
|
152
|
-
await publishNativeSession(options.sessionFile, options.cwd);
|
|
134
|
+
requireNativeProfile();
|
|
135
|
+
const discoveryEntry = await publishNativeSession(options.sessionFile, options.cwd, parkedSession, nativeProfile);
|
|
136
|
+
if (nativeProfile) {
|
|
137
|
+
if (!discoveryEntry) throw new Error("Prepared native session could not be found in discovery");
|
|
138
|
+
nativeProfileBinding = { profile: nativeProfile, discoveryEntry };
|
|
139
|
+
}
|
|
153
140
|
}
|
|
154
|
-
const { hostInventoryManifest } = await import("./host-inventory-manifest");
|
|
141
|
+
const { hostInventoryManifest } = await import("./omp/host-inventory-manifest");
|
|
155
142
|
return { toolsExplicitlySelected: parsed.tools !== undefined, noTools: parsed.noTools === true,
|
|
143
|
+
nativeProfileBinding,
|
|
144
|
+
replayableArgvHash: argv.argv[0] === "launch" && !stockReplayRefusal(parsed, options.sessionFile)
|
|
145
|
+
? launchArgvHash(launchArgs) : undefined,
|
|
146
|
+
...(options.prReviewOnly ? { emptyToolSelection } : {}),
|
|
156
147
|
inventory: await hostInventoryManifest(manifest.processBackend, options.cwd) };
|
|
157
148
|
}
|
|
158
149
|
case "inventory": {
|
|
159
150
|
const { projectDir, serviceName } = input as { projectDir?: string; serviceName?: string };
|
|
160
151
|
const list = manifest.processBackend === "broker"
|
|
161
|
-
? (await import("./host-broker-services")).brokerServiceInventory(options.cwd)
|
|
162
|
-
: (await import("./host-services")).listServiceUnits;
|
|
152
|
+
? (await import("./omp/host-broker-services")).brokerServiceInventory(options.cwd)
|
|
153
|
+
: (await import("./omp/host-services")).listServiceUnits;
|
|
163
154
|
return { units: await list(projectDir ?? undefined, serviceName ?? undefined) };
|
|
164
155
|
}
|
|
165
156
|
case "fit": {
|
|
@@ -174,7 +165,6 @@ async function run(operation: string | undefined, manifest: Manifest, input: unk
|
|
|
174
165
|
if (!result.success || result.command !== "abort_and_restore_queue") throw new Error("Cannot fit restored queue");
|
|
175
166
|
return { ...result, data: { ...result.data, ...flags } };
|
|
176
167
|
}
|
|
177
|
-
case "exit": return verifyExit(manifest, input as Exit);
|
|
178
168
|
default: throw new Error("Unknown Host SDK operation");
|
|
179
169
|
}
|
|
180
170
|
}
|
|
@@ -196,11 +186,11 @@ async function launch() {
|
|
|
196
186
|
const newline = buffered.indexOf("\n");
|
|
197
187
|
const input: ManagedUlwLaunchInput | null = JSON.parse(buffered.slice(0, newline));
|
|
198
188
|
let rest = buffered.slice(newline + 1);
|
|
199
|
-
let composition;
|
|
189
|
+
let composition: ManagedUlwLaunchComposition;
|
|
200
190
|
if (input === null) {
|
|
201
191
|
composition = { extensionPaths: [], noExtensions: true, memoryWriteDir: null };
|
|
202
192
|
} else {
|
|
203
|
-
const { managedUlwLaunchComposition } = await import("./managed-
|
|
193
|
+
const { managedUlwLaunchComposition } = await import("./omp/managed-super");
|
|
204
194
|
try { composition = await managedUlwLaunchComposition(input); }
|
|
205
195
|
catch (error) {
|
|
206
196
|
// Discovery refusals name the launch argument or package the operator must change.
|
|
@@ -214,18 +204,25 @@ async function launch() {
|
|
|
214
204
|
rest += decoder.decode();
|
|
215
205
|
if (!rest) return;
|
|
216
206
|
const manifest: Manifest = JSON.parse(rest);
|
|
217
|
-
|
|
207
|
+
if (input?.expectedNativeProfile && !isDeepStrictEqual(composition.nativeProfile, input.expectedNativeProfile))
|
|
208
|
+
throw new Error("Native HEAD profile differs from the sleeping checkpoint");
|
|
209
|
+
process.stdout.write(JSON.stringify(await run("prepare", manifest, manifest, composition.nativeProfile)));
|
|
218
210
|
}
|
|
219
211
|
|
|
220
212
|
const [, , operation, path] = process.argv;
|
|
221
213
|
try {
|
|
222
214
|
if (operation === "launch") await launch();
|
|
215
|
+
else if (operation === "head-resume-command") {
|
|
216
|
+
const { headResumeCommand } = await import("./omp/head-resume");
|
|
217
|
+
const result = await headResumeCommand(await Bun.stdin.json());
|
|
218
|
+
process.stdout.write(`\nMANAGED_HEAD_RESUME ${JSON.stringify(result)}\n`);
|
|
219
|
+
}
|
|
223
220
|
else if (operation === "prepare") throw new Error("Session preparation follows launch discovery");
|
|
224
|
-
else {
|
|
221
|
+
else if (operation === "inventory" || operation === "fit") {
|
|
225
222
|
const input = await Bun.stdin.json();
|
|
226
223
|
const manifest: Manifest = await Bun.file(path!).json();
|
|
227
224
|
process.stdout.write(JSON.stringify(await run(operation, manifest, input)));
|
|
228
|
-
}
|
|
225
|
+
} else throw new Error("Unknown Host SDK operation");
|
|
229
226
|
} catch {
|
|
230
227
|
// SDK errors may contain native frames, authorization data or prompt content.
|
|
231
228
|
console.error("Host SDK operation failed");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@oh-my-pi/pi-coding-agent";
|
|
2
2
|
import { Type } from "@sinclair/typebox";
|
|
3
3
|
import { decisionId } from "./decisions";
|
|
4
|
-
import { parseDialog } from "
|
|
4
|
+
import { parseDialog } from "../messaging/dialog";
|
|
5
5
|
|
|
6
6
|
/** Structured owner questions use the native host's UI, never a second messenger path. */
|
|
7
7
|
export function registerDecisionAsk(pi: ExtensionAPI): void {
|
|
@@ -22,10 +22,15 @@ export function registerDecisionAsk(pi: ExtensionAPI): void {
|
|
|
22
22
|
pi.registerTool({
|
|
23
23
|
name: "decision_ask", label: "Request a tracked decision", approval: "read", loadMode: "essential",
|
|
24
24
|
description: (role === "lane"
|
|
25
|
-
? "
|
|
25
|
+
? "Use to: \"head\" for an in-scope coordination choice that needs HEAD's answer, even from a work topic. " +
|
|
26
|
+
"Omit to for the normal recipient (topic: owner; manager handoff: HEAD). " +
|
|
27
|
+
"HEAD may select an original option or escalate the same question to the owner. " +
|
|
28
|
+
"On corrective assignments, to: \"head\" is cancelled privately, not sent to the owner. " +
|
|
29
|
+
"An answer never grants execution approval or changes scope. "
|
|
26
30
|
: "Ask the owner structured questions on this managed session's native UI. ") +
|
|
27
|
-
"Returns a stable decision id and the actual submitted answers or cancellation, timeout, or chat state. Recommendations, timeouts and chat are not acceptance. No default answers,
|
|
31
|
+
"Returns a stable decision id and the actual submitted answers or cancellation, timeout, or chat state. Recommendations, timeouts and chat are not acceptance. No default answers, route override, or automatic work resume.",
|
|
28
32
|
parameters: Type.Object({
|
|
33
|
+
...(role === "lane" ? { to: Type.Optional(Type.Literal("head")) } : {}),
|
|
29
34
|
questions: Type.Array(Type.Object({
|
|
30
35
|
question: Type.String(),
|
|
31
36
|
header: Type.Optional(Type.String()),
|
|
@@ -40,9 +45,12 @@ export function registerDecisionAsk(pi: ExtensionAPI): void {
|
|
|
40
45
|
}, { additionalProperties: false }),
|
|
41
46
|
async execute(toolCallId, params, signal, _onUpdate, ctx) {
|
|
42
47
|
if (ctx.agent.kind !== "main") throw new Error(restricted);
|
|
48
|
+
if (params.to !== undefined && (role !== "lane" || params.to !== "head"))
|
|
49
|
+
throw new Error("Only a managed lane can direct a coordination question to HEAD");
|
|
43
50
|
const id = decisionId(ctx.sessionManager.getSessionId(), toolCallId);
|
|
51
|
+
const prefix = role === "lane" && params.to === "head" ? `${id}:head` : id;
|
|
44
52
|
const dialog = parseDialog({ method: "ask", questions: Array.isArray(params.questions)
|
|
45
|
-
? params.questions.map((question, index) => ({ ...question, id: `${
|
|
53
|
+
? params.questions.map((question, index) => ({ ...question, id: `${prefix}:${index}` })) : params.questions });
|
|
46
54
|
if (dialog.method !== "ask") throw new Error("Expected structured decision questions");
|
|
47
55
|
if (!ctx.ui.askDialog) throw new Error("Native structured decision UI is unavailable on this host");
|
|
48
56
|
if (asking) throw new Error("An owner decision dialog is already pending in this native session");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import type { Approval, ApprovalResolution, DialogResponse, StorePort } from "
|
|
3
|
-
import { parseDialog, type Question } from "
|
|
4
|
-
import { DeliveryError } from "
|
|
2
|
+
import type { Approval, ApprovalResolution, DialogResponse, StorePort } from "../contracts";
|
|
3
|
+
import { parseDialog, type Question } from "../messaging/dialog";
|
|
4
|
+
import { DeliveryError } from "../messaging/delivery";
|
|
5
5
|
|
|
6
6
|
interface Receipt {
|
|
7
7
|
approvalId: string;
|
|
@@ -36,15 +36,17 @@ export function decisionId(sessionId: string, toolCallId: string): string {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/** Only the managed decision tool's structured questions enter this ledger. */
|
|
39
|
-
export function
|
|
39
|
+
export function decisionRequest(request: Record<string, unknown>): { id: string; toHead: boolean } | null {
|
|
40
40
|
if (request.method !== "ask" || request.secret === true || !Array.isArray(request.questions)) return null;
|
|
41
41
|
const first = request.questions[0] as { id?: unknown } | undefined;
|
|
42
|
-
const
|
|
43
|
-
if (!
|
|
42
|
+
const match = typeof first?.id === "string" ? /^(d-[a-f0-9]{24})(:head)?:0$/.exec(first.id) : null;
|
|
43
|
+
if (!match?.[1]) return null;
|
|
44
|
+
const id = match[1];
|
|
45
|
+
const prefix = id + (match[2] ?? "");
|
|
44
46
|
const dialog = parseDialog(request);
|
|
45
|
-
if (dialog.method !== "ask" || dialog.questions.some((question, index) => question.id !== `${
|
|
47
|
+
if (dialog.method !== "ask" || dialog.questions.some((question, index) => question.id !== `${prefix}:${index}`))
|
|
46
48
|
throw new Error("Decision question identity changed");
|
|
47
|
-
return id;
|
|
49
|
+
return { id, toHead: !!match[2] };
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
const metadataKey = "decisions:v1";
|
|
@@ -54,7 +56,7 @@ const receipts = (store: StorePort): Record<string, Receipt> => JSON.parse(store
|
|
|
54
56
|
export function captureDecision(store: StorePort, approval: Approval): void {
|
|
55
57
|
if (!approval.decision) return;
|
|
56
58
|
const { id } = approval.decision;
|
|
57
|
-
if (
|
|
59
|
+
if (decisionRequest(approval.request)?.id !== id) throw new Error("Decision does not match its native questions");
|
|
58
60
|
const records = receipts(store);
|
|
59
61
|
if (records[id]) throw new Error("Decision already has a native request; do not ask it again");
|
|
60
62
|
records[id] = { approvalId: approval.id, createdAt: Date.now() };
|
|
@@ -121,7 +123,7 @@ export function acknowledgeDecision(store: StorePort, approval: Approval, sessio
|
|
|
121
123
|
export function decisionViews(store: StorePort): DecisionView[] {
|
|
122
124
|
return Object.entries(receipts(store)).map(([id, receipt]) => {
|
|
123
125
|
const approval = store.approval(receipt.approvalId);
|
|
124
|
-
if (!approval?.decision || approval.decision.id !== id ||
|
|
126
|
+
if (!approval?.decision || approval.decision.id !== id || decisionRequest(approval.request)?.id !== id)
|
|
125
127
|
throw new Error("Decision ledger is not bound to its original native question");
|
|
126
128
|
const dialog = parseDialog(approval.request);
|
|
127
129
|
if (dialog.method !== "ask") throw new Error("Decision question is unavailable");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LaneModel, LaneModelChoice, ModelPreset, LanePresetSnapshot, ResolvedLanePreset } from "
|
|
1
|
+
import type { LaneModel, LaneModelChoice, ModelPreset, LanePresetSnapshot, ResolvedLanePreset } from "../contracts";
|
|
2
2
|
|
|
3
3
|
export interface LaneModelCandidate extends LaneModel {
|
|
4
4
|
name?: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isAbsolute, normalize } from "node:path";
|
|
2
|
+
import { isDeepStrictEqual } from "node:util";
|
|
2
3
|
|
|
3
4
|
export type LaneWaitTarget =
|
|
4
5
|
| { kind: "tool" | "approval" | "job"; id: string; target: string }
|
|
@@ -24,6 +25,27 @@ export interface LaneReportEvent {
|
|
|
24
25
|
report: LaneReport;
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
/** Evidence of a tool execution only; it does not authorize a scope change. */
|
|
29
|
+
export type ScopeReviewReceipt = {
|
|
30
|
+
readonly type: "superagent-scope-review";
|
|
31
|
+
readonly sourceId: string;
|
|
32
|
+
readonly sessionId: string;
|
|
33
|
+
readonly sessionFile: string;
|
|
34
|
+
readonly toolCallId: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** Stock OMP select wire for this tool. A positive answer describes this call
|
|
38
|
+
* only; the native Host, not the controller, handles any session-wide choice. */
|
|
39
|
+
export function scopeReviewApproval(request: Record<string, unknown>, response?: { value?: string }): boolean {
|
|
40
|
+
if (request.method !== "select" || request.secret === true) return false;
|
|
41
|
+
const options = request.options;
|
|
42
|
+
const session = "Approve lane_report for this session";
|
|
43
|
+
if (!isDeepStrictEqual(options, ["Approve", "Deny"]) && !isDeepStrictEqual(options, ["Approve", session, "Deny"])) return false;
|
|
44
|
+
if (!response) return true;
|
|
45
|
+
return isDeepStrictEqual(response, { value: "Approve" })
|
|
46
|
+
|| Array.isArray(options) && options.includes(session) && isDeepStrictEqual(response, { value: session });
|
|
47
|
+
}
|
|
48
|
+
|
|
27
49
|
export function laneWaitKey(waiting: LaneWaitTarget): string {
|
|
28
50
|
return JSON.stringify([waiting.kind, waiting.kind === "dependency" ? waiting.target : waiting.id]);
|
|
29
51
|
}
|
|
@@ -2,8 +2,8 @@ import type { Database } from "bun:sqlite";
|
|
|
2
2
|
import { isAbsolute, normalize } from "node:path";
|
|
3
3
|
import { Type } from "@sinclair/typebox";
|
|
4
4
|
import { Value } from "@sinclair/typebox/value";
|
|
5
|
-
import type { Lane } from "
|
|
6
|
-
import type { RemotePlacement } from "
|
|
5
|
+
import type { Lane } from "../contracts";
|
|
6
|
+
import type { RemotePlacement } from "../worker/worker-wire";
|
|
7
7
|
|
|
8
8
|
export interface LaneRow {
|
|
9
9
|
readonly data: string;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { createHash, randomUUID } from "node:crypto";
|
|
3
3
|
import { Type, type Static } from "@sinclair/typebox/type";
|
|
4
4
|
import { Value } from "@sinclair/typebox/value";
|
|
5
|
-
import { authorizeRoute, type Config } from "
|
|
6
|
-
import { routeKey, type InputRecord, type Lane, type OutputRecord, type Route, type StorePort } from "
|
|
5
|
+
import { authorizeRoute, type Config } from "../config/config";
|
|
6
|
+
import { routeKey, type InputRecord, type Lane, type OutputRecord, type Route, type StorePort } from "../contracts";
|
|
7
7
|
|
|
8
8
|
const stateKey = "lane-watch:v1";
|
|
9
9
|
const noticePrefix = "lane-watch-notice:";
|
|
@@ -171,6 +171,10 @@ export class LaneWatcher {
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
+
hasScheduledWork(): boolean {
|
|
175
|
+
return this.state().watches.some(watch => this.held(watch) === null);
|
|
176
|
+
}
|
|
177
|
+
|
|
174
178
|
/** Cross-platform accounts must be authenticated before the durable cursor advances. */
|
|
175
179
|
async pollCrossPlatform(now: number, proof: CrossPlatformProof): Promise<boolean> {
|
|
176
180
|
let notified = false;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WORKFLOW_NAMES, type InputRecord, type WorkflowActivation, type WorkflowChoice, type WorkflowName } from "
|
|
1
|
+
import { WORKFLOW_NAMES, type InputRecord, type WorkflowActivation, type WorkflowChoice, type WorkflowName } from "../contracts";
|
|
2
2
|
|
|
3
3
|
// Public commands and leading delimiters match omp-superkit ulw.ts at c11a6e4.
|
|
4
4
|
// Skill paths and persisted native keys are deliberately not public selectors.
|
package/src/lane-extension.ts
CHANGED
|
@@ -4,9 +4,9 @@ import { resolve } from "node:path";
|
|
|
4
4
|
import type { ToolCall, ToolResultMessage } from "@oh-my-pi/pi-ai";
|
|
5
5
|
import type { ExtensionAPI, ExtensionContext } from "@oh-my-pi/pi-coding-agent";
|
|
6
6
|
import { type Static, Type } from "@sinclair/typebox";
|
|
7
|
-
import { type LaneEvidence, type LaneReportEvent, parseLaneReportResult } from "./lane-report";
|
|
8
|
-
import { registerResultAttach, RESULT_ATTACH_TOOL } from "./result-attachment";
|
|
9
|
-
import { registerDecisionAsk } from "./decision-tool";
|
|
7
|
+
import { type LaneEvidence, type LaneReportEvent, type ScopeReviewReceipt, parseLaneReportResult } from "./lane/lane-report";
|
|
8
|
+
import { registerResultAttach, RESULT_ATTACH_TOOL } from "./messaging/result-attachment";
|
|
9
|
+
import { registerDecisionAsk } from "./lane/decision-tool";
|
|
10
10
|
|
|
11
11
|
const instructions = readFileSync(new URL("../skills/lane/SKILL.md", import.meta.url), "utf8");
|
|
12
12
|
const nonempty = Type.String({ minLength: 1, pattern: "\\S" });
|
|
@@ -29,8 +29,11 @@ const parameters = Type.Union([
|
|
|
29
29
|
{ additionalProperties: false }),
|
|
30
30
|
Type.Object({ status: Type.Literal("resolved"), summary, waiting, evidence: requiredEvidence },
|
|
31
31
|
{ additionalProperties: false }),
|
|
32
|
+
Type.Object({ status: Type.Literal("scope_review"), sourceId: nonempty }, { additionalProperties: false }),
|
|
32
33
|
]);
|
|
33
|
-
|
|
34
|
+
// Resumed native journals can still contain retired board tools. They were never work evidence.
|
|
35
|
+
const coordinationTool = (name: string) =>
|
|
36
|
+
name === "lane_report" || name === RESULT_ATTACH_TOOL || name === "decision_ask" || name.startsWith("board_");
|
|
34
37
|
const record = (value: unknown): value is Record<string, unknown> =>
|
|
35
38
|
value !== null && typeof value === "object" && !Array.isArray(value);
|
|
36
39
|
const text = (value: unknown): value is string => typeof value === "string" && value.trim().length > 0;
|
|
@@ -39,7 +42,12 @@ const keys = (value: Record<string, unknown>, names: string[]) =>
|
|
|
39
42
|
|
|
40
43
|
// Direct native/custom-tool dispatch can bypass model argument validation.
|
|
41
44
|
function validInput(input: unknown): input is Static<typeof parameters> {
|
|
42
|
-
if (!record(input)
|
|
45
|
+
if (!record(input)) return false;
|
|
46
|
+
if (input.status === "scope_review") {
|
|
47
|
+
return Object.hasOwn(input, "status") && Object.hasOwn(input, "sourceId") &&
|
|
48
|
+
keys(input, ["status", "sourceId"]) && text(input.sourceId);
|
|
49
|
+
}
|
|
50
|
+
if (!keys(input, ["status", "summary", "waiting", "evidence"]) ||
|
|
43
51
|
!text(input.summary) || input.summary.length > 4000 ||
|
|
44
52
|
!["progress", "waiting", "resolved"].includes(input.status as string)) return false;
|
|
45
53
|
if (input.evidence !== undefined && (!Array.isArray(input.evidence) || input.evidence.length > 32 ||
|
|
@@ -111,12 +119,26 @@ function toolEvidence(id: string, records: ReturnType<typeof toolRecords>): Lane
|
|
|
111
119
|
if (!call || !result || result.toolName !== call.name || result.isError !== false ||
|
|
112
120
|
coordinationTool(call.name) || (typeof call.arguments.path === "string" &&
|
|
113
121
|
/^xd:\/\/(?:lane_report|board_[a-z_]+)(?:[/?#]|$)/.test(call.arguments.path)) ||
|
|
114
|
-
parseLaneReportResult(result))
|
|
115
|
-
|
|
122
|
+
parseLaneReportResult(result) || (record(result.details) && result.details.type === "superagent-scope-review") ||
|
|
123
|
+
transportedCoordination(call, result)) {
|
|
124
|
+
throw new Error("Lane tool evidence requires a completed successful native tool call, not a coordination receipt");
|
|
116
125
|
}
|
|
117
126
|
// Native identity/time envelopes are not evidence of changed work.
|
|
118
|
-
const
|
|
119
|
-
return { kind: "tool", ref: id, fingerprint: createHash("sha256").update(JSON.stringify(
|
|
127
|
+
const resultRecord = { toolName: result.toolName, content: result.content, details: result.details, isError: result.isError };
|
|
128
|
+
return { kind: "tool", ref: id, fingerprint: createHash("sha256").update(JSON.stringify(resultRecord)).digest("hex") };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function transportedCoordination(call: ToolCall, result: ToolResultMessage): boolean {
|
|
132
|
+
const details = result.details;
|
|
133
|
+
if (!record(details)) return false;
|
|
134
|
+
const device = details.xdev;
|
|
135
|
+
if (call.name === "write" && record(device) && device.mode === "execute" &&
|
|
136
|
+
typeof device.tool === "string" && call.arguments.path === `xd://${device.tool}` && coordinationTool(device.tool))
|
|
137
|
+
return true;
|
|
138
|
+
// The shell's dispatch records, not command text or stdout, identify tools that ran.
|
|
139
|
+
return call.name === "bash" && Array.isArray(details.toolCommands) &&
|
|
140
|
+
details.toolCommands.some((dispatch: unknown) => record(dispatch) && dispatch.mode === "execute" &&
|
|
141
|
+
typeof dispatch.exitCode === "number" && typeof dispatch.tool === "string" && coordinationTool(dispatch.tool));
|
|
120
142
|
}
|
|
121
143
|
|
|
122
144
|
/** A worker role entrypoint, never the head's manager or messenger client. */
|
|
@@ -126,10 +148,12 @@ export default function laneExtension(pi: ExtensionAPI): void {
|
|
|
126
148
|
registerResultAttach(pi);
|
|
127
149
|
let approvalSessionId: string | undefined;
|
|
128
150
|
const pendingApprovals = new Set<string>();
|
|
151
|
+
const scopeApprovals = new Map<string, "requested" | "approved" | "unverified">();
|
|
129
152
|
const approvals = (ctx: ExtensionContext) => {
|
|
130
153
|
const sessionId = ctx.sessionManager.getSessionId();
|
|
131
154
|
if (approvalSessionId !== sessionId) {
|
|
132
155
|
pendingApprovals.clear();
|
|
156
|
+
scopeApprovals.clear();
|
|
133
157
|
approvalSessionId = sessionId;
|
|
134
158
|
}
|
|
135
159
|
return pendingApprovals;
|
|
@@ -154,12 +178,22 @@ export default function laneExtension(pi: ExtensionAPI): void {
|
|
|
154
178
|
pi.on("tool_approval_requested", (event, ctx) => {
|
|
155
179
|
if (ctx.agent.kind === "main" && event.sessionId === ctx.sessionManager.getSessionId()) {
|
|
156
180
|
approvals(ctx).add(event.toolCallId);
|
|
181
|
+
if (event.toolName === "lane_report")
|
|
182
|
+
scopeApprovals.set(event.toolCallId, scopeApprovals.has(event.toolCallId) ? "unverified" : "requested");
|
|
157
183
|
}
|
|
158
184
|
});
|
|
159
185
|
pi.on("tool_approval_resolved", (event, ctx) => {
|
|
160
|
-
if (event.sessionId
|
|
186
|
+
if (event.sessionId !== ctx.sessionManager.getSessionId()) return;
|
|
187
|
+
approvals(ctx).delete(event.toolCallId);
|
|
188
|
+
if (ctx.agent.kind === "main" && event.toolName === "lane_report")
|
|
189
|
+
scopeApprovals.set(event.toolCallId,
|
|
190
|
+
event.approved && scopeApprovals.get(event.toolCallId) === "requested" ? "approved" : "unverified");
|
|
191
|
+
});
|
|
192
|
+
pi.on("agent_end", (_event, ctx) => { if (ctx.agent.kind === "main") scopeApprovals.clear(); });
|
|
193
|
+
pi.on("session_shutdown", () => {
|
|
194
|
+
pendingApprovals.clear();
|
|
195
|
+
scopeApprovals.clear();
|
|
161
196
|
});
|
|
162
|
-
pi.on("session_shutdown", () => { pendingApprovals.clear(); });
|
|
163
197
|
pi.on("before_agent_start", async (event, ctx) => {
|
|
164
198
|
if (ctx.agent.kind !== "main") return;
|
|
165
199
|
return { systemPrompt: [
|
|
@@ -172,12 +206,34 @@ export default function laneExtension(pi: ExtensionAPI): void {
|
|
|
172
206
|
name: "lane_report", label: "Report lane observations", approval: "read", loadMode: "essential",
|
|
173
207
|
description: "Record an evidence-backed progress, waiting, or resolved observation in this lane's native tool journal. " +
|
|
174
208
|
"Progress/resolved require selected real file paths or completed successful native toolCallIds; hashes are computed here. " +
|
|
209
|
+
"Decision receipts and other coordination activity are not evidence of work. " +
|
|
175
210
|
"Waiting/resolved name the exact tool/approval/job ID or a dependency label. Native tool/approval/job waiting IDs must be observable now. " +
|
|
176
|
-
"
|
|
211
|
+
"Topic observations do not notify HEAD. For manager handoffs, changed evidence or wait transitions are queued for HEAD. " +
|
|
212
|
+
"For a standalone original owner message in the active bound topic that appears to supersede the existing assignment, " +
|
|
213
|
+
"call lane_report directly with status scope_review and its Original source ID, never via eval, bash, or write. " +
|
|
214
|
+
"This only requests HEAD review; it does not grant permission. " +
|
|
215
|
+
"Reports do not themselves send messenger messages, prove acceptance, dispatch, resume, or change execution authority.",
|
|
177
216
|
parameters,
|
|
178
|
-
async execute(id, params,
|
|
217
|
+
async execute(id, params, signal, _onUpdate, ctx) {
|
|
179
218
|
if (ctx.agent.kind !== "main") throw new Error("Lane reporting is restricted to the root lane session");
|
|
180
219
|
if (!validInput(params)) throw new Error("Invalid lane report parameters");
|
|
220
|
+
approvals(ctx);
|
|
221
|
+
const nativeApproval = scopeApprovals.get(id);
|
|
222
|
+
scopeApprovals.delete(id);
|
|
223
|
+
if (params.status === "scope_review") {
|
|
224
|
+
signal?.throwIfAborted();
|
|
225
|
+
const sessionFile = ctx.sessionManager.getSessionFile();
|
|
226
|
+
if (!sessionFile) throw new Error("Lane scope review requires a native session file");
|
|
227
|
+
const receipt: ScopeReviewReceipt = {
|
|
228
|
+
type: "superagent-scope-review", sourceId: params.sourceId,
|
|
229
|
+
sessionId: ctx.sessionManager.getSessionId(), sessionFile, toolCallId: id,
|
|
230
|
+
};
|
|
231
|
+
// Only a matched direct native start/end can request review. Do not append a custom entry.
|
|
232
|
+
return {
|
|
233
|
+
content: [{ type: "text", text: "Emitted a scope-review signal. HEAD admission depends on controller verification and successful settlement; the assignment has not changed." }],
|
|
234
|
+
details: nativeApproval === undefined ? receipt : { ...receipt, nativeApproval },
|
|
235
|
+
};
|
|
236
|
+
}
|
|
181
237
|
const target = params.status === "waiting" ? params.waiting : undefined;
|
|
182
238
|
if (target?.kind === "approval" && !approvals(ctx).has(target.id)) {
|
|
183
239
|
throw new Error("Lane approval wait requires an observed pending native tool approval");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Configuration only. Never import the SDK entry point, account storage, or a backend.
|
|
2
|
-
import { canEnableGlobalMemory, effectiveManagedMemory, ensureManagedMemory, parseMemoryConsent, type ManagedMemoryReport } from "./managed-memory";
|
|
3
|
-
import { parseNativeLaunch } from "./native-launch-profile";
|
|
2
|
+
import { canEnableGlobalMemory, effectiveManagedMemory, ensureManagedMemory, parseMemoryConsent, type ManagedMemoryReport } from "./omp/managed-memory";
|
|
3
|
+
import { parseNativeLaunch } from "./omp/native-launch-profile";
|
|
4
4
|
|
|
5
5
|
const unavailable: ManagedMemoryReport = { memory: { status: "unknown" }, updated: false };
|
|
6
6
|
const [operation, ...args] = process.argv.slice(2);
|
|
@@ -9,9 +9,9 @@ import { listPackageExtensionModules, loadExtensions } from "@oh-my-pi/pi-coding
|
|
|
9
9
|
import { buildAvailableSlashCommands } from "@oh-my-pi/pi-coding-agent/slash-commands/available-commands";
|
|
10
10
|
import { buildSystemPrompt } from "@oh-my-pi/pi-coding-agent/system-prompt";
|
|
11
11
|
import { WORKFLOW_NAMES } from "./contracts";
|
|
12
|
-
import { readManagedUlwPackage } from "./managed-
|
|
13
|
-
import { canonicalSuperkitSkills, hasCanonicalSuperkitSkills, legacySuperkitSkills, superkitWorkflows as workflows } from "./superkit-skills";
|
|
14
|
-
import { advertisedWorkflow } from "./workflow";
|
|
12
|
+
import { readManagedUlwPackage } from "./omp/managed-super";
|
|
13
|
+
import { canonicalSuperkitSkills, hasCanonicalSuperkitSkills, legacySuperkitSkills, superkitWorkflows as workflows } from "./omp/superkit-skills";
|
|
14
|
+
import { advertisedWorkflow } from "./lane/workflow";
|
|
15
15
|
|
|
16
16
|
const packageArg = process.argv[2];
|
|
17
17
|
if (!packageArg) throw new Error("Managed Superkit probe requires a package path");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { routeKey, type Approval } from "
|
|
2
|
+
import { routeKey, type Approval } from "../contracts";
|
|
3
3
|
|
|
4
4
|
/** Existing cards and persisted dialog progress must keep this exact identity. */
|
|
5
5
|
export function approvalCardToken(approval: Approval): string {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Config } from "
|
|
2
|
-
import { operatorBotToken, runOperator, type OperatorRun } from "
|
|
1
|
+
import type { Config } from "../config/config";
|
|
2
|
+
import { operatorBotToken, runOperator, type OperatorRun } from "../operator/operator";
|
|
3
3
|
|
|
4
4
|
export interface DiscordCommandRegistrationOptions {
|
|
5
5
|
readonly apply?: boolean;
|
|
@@ -26,6 +26,7 @@ export interface DiscordCommandRegistrationReport {
|
|
|
26
26
|
readonly applicationId: string;
|
|
27
27
|
readonly botId: string;
|
|
28
28
|
readonly plannedGlobal: readonly DiscordDefinition[];
|
|
29
|
+
readonly preApplyTextOptionDrift: readonly string[];
|
|
29
30
|
readonly currentGlobal: readonly RegistrationSummary[];
|
|
30
31
|
readonly obsoleteGlobal: readonly RegistrationSummary[];
|
|
31
32
|
readonly guilds: readonly {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isDeepStrictEqual } from "node:util";
|
|
2
2
|
import { Type } from "@sinclair/typebox/type";
|
|
3
3
|
import { Value } from "@sinclair/typebox/value";
|
|
4
|
-
import { physicalRoute, physicalRouteKey, type DiscordPurposeNote, type DiscordPurposeRequest, type Route, type StorePort } from "
|
|
4
|
+
import { physicalRoute, physicalRouteKey, type DiscordPurposeNote, type DiscordPurposeRequest, type Route, type StorePort } from "../contracts";
|
|
5
5
|
import { DeliveryError } from "./delivery";
|
|
6
6
|
|
|
7
7
|
const PURPOSES = "discord:purposes";
|