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
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
{ "name": "model", "description": "Choose a Superagent HEAD model or preset, or use --lane for the bound lane.", "text": "Omit for the menu, or enter list, provider/model, --lane provider/model, or a preset command.",
|
|
14
14
|
"discord": { "description": "Choose a model for the Superagent HEAD or the current lane.", "text": true } },
|
|
15
15
|
{ "name": "effort", "description": "Choose the Superagent HEAD thinking effort.", "text": "Omit for the menu, or enter an exact advertised effort level." },
|
|
16
|
+
{ "name": "fast", "description": "Choose and confirm the Superagent HEAD fast service tier." },
|
|
16
17
|
{ "name": "compact", "description": "Compact Superagent HEAD context when idle.", "text": "Optional compaction instructions, including multiple lines." },
|
|
17
18
|
{ "name": "stop", "description": "Stop Superagent work in this conversation, the shared HEAD, or a named lane.", "text": "Omit for this conversation, or specify head or an exact lane ID." },
|
|
18
19
|
{ "name": "new", "description": "Start a Superagent work topic; use a sibling for a new request in an existing thread.", "text": "An optional first request for the new topic." },
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import catalog from "./messenger-command-catalog.json" with { type: "json" };
|
|
2
|
+
import type { Inbound } from "../contracts";
|
|
3
|
+
|
|
4
|
+
/** Owner controls and platform-specific registration metadata shared with the native Gateway. */
|
|
5
|
+
export const MESSENGER_COMMAND_CATALOG: readonly {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly description: string;
|
|
8
|
+
readonly text?: string;
|
|
9
|
+
readonly discordOnly?: boolean;
|
|
10
|
+
readonly discord?: {
|
|
11
|
+
readonly description: string;
|
|
12
|
+
readonly text: boolean;
|
|
13
|
+
};
|
|
14
|
+
}[] = catalog;
|
|
15
|
+
|
|
16
|
+
export const MESSENGER_COMMANDS = MESSENGER_COMMAND_CATALOG.filter(command => !command.discordOnly);
|
|
17
|
+
|
|
18
|
+
/** Never promote a slash token exposed by Telegram's routing-only redaction. */
|
|
19
|
+
export function telegramCommandBlocked(input: Inbound): boolean {
|
|
20
|
+
if (input.route.platform !== "telegram" || input.pickerSelection) return false;
|
|
21
|
+
if (input.telegramProtectedCommand !== undefined) return input.telegramProtectedCommand;
|
|
22
|
+
if (input.routingText === undefined) return false;
|
|
23
|
+
// Legacy receipts have no explicit verdict. The old redaction can veto
|
|
24
|
+
// command authority but cannot give it to a different token in the view.
|
|
25
|
+
const written = /^\s*(\/\S+)/u.exec(input.text);
|
|
26
|
+
if (!written) return input.routingText.trimStart().startsWith("/");
|
|
27
|
+
return !input.routingText.startsWith(written[0])
|
|
28
|
+
|| !/^(?:\s|$)/u.test(input.routingText.slice(written[0].length));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Ordinary Slack messages use mrkdwn entities; slash payloads and picker values do not. */
|
|
32
|
+
export function messengerCommandText(input: Inbound): string {
|
|
33
|
+
const { text } = input;
|
|
34
|
+
if (input.route.platform !== "slack" || input.messageId === null || !text.includes("&")) return text;
|
|
35
|
+
const name = /^\s*\/([a-z-]+)\s/u.exec(text)?.[1];
|
|
36
|
+
if (!name || !MESSENGER_COMMANDS.some(command => command.name === name)) return text;
|
|
37
|
+
// Decode exactly once. The stored text remains the identity used for replay.
|
|
38
|
+
return text.replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Discord may strip this bot's addresses from the edges, but not change the owner's command. */
|
|
42
|
+
export function matchesWrittenCommand(input: Inbound): boolean {
|
|
43
|
+
if (input.discordOriginalText === undefined) return true;
|
|
44
|
+
let written = input.discordOriginalText.trim();
|
|
45
|
+
const text = input.text.trim();
|
|
46
|
+
const addresses = [`<@${input.route.accountId}>`, `<@!${input.route.accountId}>`];
|
|
47
|
+
while (written !== text) {
|
|
48
|
+
const leading = addresses.find(tag => written.startsWith(tag));
|
|
49
|
+
if (leading) { written = written.slice(leading.length).trimStart(); continue; }
|
|
50
|
+
const trailing = addresses.find(tag => written.endsWith(tag));
|
|
51
|
+
if (!trailing) return false;
|
|
52
|
+
written = written.slice(0, -trailing.length).trimEnd();
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
@@ -2,7 +2,7 @@ import { isAbsolute } from "node:path";
|
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import type { ExtensionAPI } from "@oh-my-pi/pi-coding-agent";
|
|
4
4
|
import { Type } from "@sinclair/typebox";
|
|
5
|
-
import type { Inbound } from "
|
|
5
|
+
import type { Inbound } from "../contracts";
|
|
6
6
|
|
|
7
7
|
const MAX_RESULT_ATTACHMENT_BYTES = 8 * 1024 * 1024;
|
|
8
8
|
export const RESULT_ATTACH_TOOL = "result_attach";
|
|
@@ -65,7 +65,7 @@ export function isOriginalAttachmentMessage({ id, messageId, route }: Inbound):
|
|
|
65
65
|
: `${route.platform}:${route.accountId}:${route.channelId}:${messageId}:original`);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
const binary = fileURLToPath(new URL(
|
|
68
|
+
const binary = fileURLToPath(new URL(`../../gateway/bin/omp-gateway-${process.platform}-${process.arch}`, import.meta.url));
|
|
69
69
|
|
|
70
70
|
type StageCommand =
|
|
71
71
|
| { readonly action: "stage"; readonly stateDir: string; readonly cwd: string; readonly path: string; readonly privatePaths: readonly string[] }
|
|
@@ -94,7 +94,7 @@ export function isResultAttachmentSnapshot(value: unknown): value is ResultAttac
|
|
|
94
94
|
const snapshot = asRecord(value);
|
|
95
95
|
return snapshot !== null && Object.keys(snapshot).length === 5 &&
|
|
96
96
|
typeof snapshot.name === "string" && validPath(snapshot.name) && Buffer.byteLength(snapshot.name) <= 180 &&
|
|
97
|
-
/^[\p{L}\p{N}\p{M}_.
|
|
97
|
+
/^[\p{L}\p{N}\p{M}_. &-]+$/u.test(snapshot.name) &&
|
|
98
98
|
typeof snapshot.size === "number" && Number.isSafeInteger(snapshot.size) &&
|
|
99
99
|
snapshot.size > 0 && snapshot.size <= MAX_RESULT_ATTACHMENT_BYTES &&
|
|
100
100
|
typeof snapshot.sha256 === "string" && /^[a-f0-9]{64}$/.test(snapshot.sha256) &&
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Config } from "
|
|
2
|
-
import { readCredentialFile, validateCredential } from "
|
|
3
|
-
import { runOperator, type OperatorRun } from "
|
|
1
|
+
import type { Config } from "../config/config";
|
|
2
|
+
import { readCredentialFile, validateCredential } from "../config/credentials";
|
|
3
|
+
import { runOperator, type OperatorRun } from "../operator/operator";
|
|
4
4
|
|
|
5
5
|
export interface SlackCommandRegistrationOptions {
|
|
6
6
|
readonly apply?: boolean;
|
|
@@ -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
|
import languageCodes from "./telegram-command-languages.json";
|
|
4
4
|
|
|
5
5
|
interface MenuCommand {
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { lstat } from "node:fs/promises";
|
|
2
|
+
import { isDeepStrictEqual } from "node:util";
|
|
3
|
+
import type { RotationSelection } from "../runtime/head-rotation";
|
|
4
|
+
import { stockReplayRefusal } from "./stock-head-launch";
|
|
5
|
+
|
|
6
|
+
type HeadResumeInput = {
|
|
7
|
+
readonly argv: readonly string[];
|
|
8
|
+
readonly sessionFile: string;
|
|
9
|
+
readonly sessionId: string;
|
|
10
|
+
readonly selection: RotationSelection;
|
|
11
|
+
readonly checkJournal: boolean;
|
|
12
|
+
readonly rotationOnly?: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
async function checkHeadResumeJournal(input: HeadResumeInput, needsServiceTier: boolean): Promise<string | undefined> {
|
|
16
|
+
const before = await lstat(input.sessionFile);
|
|
17
|
+
if (!before.isFile()) return "HEAD sleep requires a regular native journal, not a symlink";
|
|
18
|
+
const { loadSessionFile } = await import("@oh-my-pi/pi-coding-agent/session/session-loader");
|
|
19
|
+
const { entries, invalidHeader, malformedRecords, sourceSize } =
|
|
20
|
+
await loadSessionFile(input.sessionFile, undefined, { throwIfMissing: true });
|
|
21
|
+
const after = await lstat(input.sessionFile);
|
|
22
|
+
const [header] = entries;
|
|
23
|
+
if (!after.isFile() || after.dev !== before.dev || after.ino !== before.ino ||
|
|
24
|
+
after.size !== before.size || sourceSize !== before.size ||
|
|
25
|
+
after.mtimeMs !== before.mtimeMs || after.ctimeMs !== before.ctimeMs ||
|
|
26
|
+
invalidHeader || malformedRecords !== 0 || header?.type !== "session" || header.id !== input.sessionId)
|
|
27
|
+
return "HEAD journal changed or could not be read as the exact native session";
|
|
28
|
+
if (entries.some((entry, i) => i !== 0 && entry.type === "session"))
|
|
29
|
+
return "HEAD journal contains a competing native session header";
|
|
30
|
+
const { lastModelChangeRole, SessionEntryIndex } = await import("@oh-my-pi/pi-coding-agent/session/session-manager");
|
|
31
|
+
const index = new SessionEntryIndex();
|
|
32
|
+
const records = entries.filter(entry => entry.type !== "session");
|
|
33
|
+
index.rebuild(records);
|
|
34
|
+
const branch = index.branchView();
|
|
35
|
+
const { buildSessionContext, getRestorableSessionModels } = await import("@oh-my-pi/pi-coding-agent/session/session-context");
|
|
36
|
+
const { models, serviceTier } = buildSessionContext(records, index.leafId(), index.entriesById());
|
|
37
|
+
const saved = getRestorableSessionModels(models, lastModelChangeRole(branch))[0];
|
|
38
|
+
const hasServiceTier = branch.some(entry => entry.type === "service_tier_change");
|
|
39
|
+
if (needsServiceTier && !hasServiceTier)
|
|
40
|
+
return "HEAD cannot remove stock --service-tier without a saved selection on the active journal branch";
|
|
41
|
+
const { selection } = input;
|
|
42
|
+
if (!isDeepStrictEqual(hasServiceTier ? serviceTier ?? {} : selection.serviceTierDefaults, selection.serviceTier))
|
|
43
|
+
return "Stock HEAD resume cannot restore the active service tier from the journal or its native defaults";
|
|
44
|
+
const exact = selection.modelIdentity;
|
|
45
|
+
if (saved === exact) return;
|
|
46
|
+
// Before the first turn stock can leave its model entry in memory only.
|
|
47
|
+
// The restored settings overlay contains the attested effective default,
|
|
48
|
+
// but this fallback cannot override a model stock finds in the journal.
|
|
49
|
+
if (!saved && selection.modelSettings.modelRoles.default === exact) return;
|
|
50
|
+
const { parseModelString } = await import("@oh-my-pi/pi-coding-agent/config/model-selector");
|
|
51
|
+
const parsed = saved && parseModelString(saved, { allowMaxSuffix: true, allowAutoAlias: true });
|
|
52
|
+
if (parsed && `${parsed.provider}/${parsed.id}` === exact) return;
|
|
53
|
+
return "Stock HEAD resume cannot restore the active model from the journal or its exact bootstrap default";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Prove that stock can restore this exact live selection without replaying one-shot options. */
|
|
57
|
+
export async function headResumeCommand(input: HeadResumeInput) {
|
|
58
|
+
const { argv, sessionFile, selection } = input;
|
|
59
|
+
const { extractProfileFlags } = await import("@oh-my-pi/pi-coding-agent/cli/profile-bootstrap");
|
|
60
|
+
const { setProfile, resolveProfileEnv } = await import("@oh-my-pi/pi-utils/dirs");
|
|
61
|
+
const suffix = ["--mode", "rpc-ui", "--session", sessionFile];
|
|
62
|
+
const original = extractProfileFlags([...argv, ...suffix]);
|
|
63
|
+
setProfile(original.profile ?? resolveProfileEnv(process.env.OMP_PROFILE, process.env.PI_PROFILE));
|
|
64
|
+
const { resolveCliArgv } = await import("@oh-my-pi/pi-coding-agent/cli-commands");
|
|
65
|
+
const { parseArgs } = await import("@oh-my-pi/pi-coding-agent/cli/args");
|
|
66
|
+
const parseStockLaunch = (args: string[]) => {
|
|
67
|
+
const resolved = resolveCliArgv(args);
|
|
68
|
+
return "error" in resolved || resolved.argv[0] !== "launch" ? null : parseArgs(resolved.argv.slice(1));
|
|
69
|
+
};
|
|
70
|
+
const parsed = parseStockLaunch(original.argv);
|
|
71
|
+
const refusal = stockReplayRefusal(parsed, sessionFile);
|
|
72
|
+
if (refusal || !parsed) return { refused: refusal ?? "HEAD wake launch was not parsed" };
|
|
73
|
+
const { flagConsumesValue } = await import("@oh-my-pi/pi-coding-agent/cli/flag-tables");
|
|
74
|
+
const command: string[] = [];
|
|
75
|
+
for (let i = 0; i < argv.length; i++) {
|
|
76
|
+
const token = argv[i];
|
|
77
|
+
const flag = token.split("=", 1)[0];
|
|
78
|
+
const consumesValue = flagConsumesValue(token, argv[i + 1]);
|
|
79
|
+
// The managed --session suffix wins in parseArgs, hiding an earlier
|
|
80
|
+
// selector. Inspect only stock option tokens, not other flags' values.
|
|
81
|
+
if (flag === "--resume" || flag === "-r" || flag === "--session")
|
|
82
|
+
return { refused: "HEAD wake cannot combine competing stock session selectors" };
|
|
83
|
+
if (flag !== "--model" && flag !== "--provider" && flag !== "--thinking" && flag !== "--service-tier") {
|
|
84
|
+
command.push(token);
|
|
85
|
+
if (consumesValue) command.push(argv[i + 1]);
|
|
86
|
+
}
|
|
87
|
+
if (consumesValue) i++;
|
|
88
|
+
}
|
|
89
|
+
if (selection.stockLaunchReplay !== true)
|
|
90
|
+
return { refused: "The original HEAD did not attest that its actual stock launch is replayable" };
|
|
91
|
+
if (input.rotationOnly) return { command: argv };
|
|
92
|
+
if (!selection.modelIdentity || !selection.serviceTier || !selection.serviceTierDefaults || !selection.effectiveServiceTier)
|
|
93
|
+
return { refused: "The original HEAD did not attest its exact routed model and service tier" };
|
|
94
|
+
if (parsed.model && parsed.apiKey)
|
|
95
|
+
return { refused: "Stock --api-key is bound to an explicit --model; HEAD wake cannot rebind it to the saved session model" };
|
|
96
|
+
for (const [role, value] of [["smol", parsed.smol], ["slow", parsed.slow], ["plan", parsed.plan]] as const) {
|
|
97
|
+
if (value && selection.modelSettings.modelRoles[role] !== value)
|
|
98
|
+
return { refused: `HEAD wake cannot replay the conflicting stock --${role} role override` };
|
|
99
|
+
}
|
|
100
|
+
const effort = selection.configuredThinkingLevel ?? undefined;
|
|
101
|
+
if (effort === undefined && selection.reasoning)
|
|
102
|
+
return { refused: "Stock --thinking has no inherit selector for this HEAD's absent reasoning effort" };
|
|
103
|
+
// Let stock restore the branch model and tier. An old --model can overwrite
|
|
104
|
+
// the default role; --service-tier would overwrite even an explicit /fast off.
|
|
105
|
+
// Keep the live configured effort, including auto before it has journaled
|
|
106
|
+
// the first classification.
|
|
107
|
+
if (effort !== undefined) command.push(`--thinking=${effort}`);
|
|
108
|
+
const normalized = extractProfileFlags([...command, ...suffix]);
|
|
109
|
+
const restored = parseStockLaunch(normalized.argv);
|
|
110
|
+
const omitSelection = ({
|
|
111
|
+
model: _model, provider: _provider, thinking: _thinking, serviceTier: _serviceTier, ...other
|
|
112
|
+
}: typeof parsed) => other;
|
|
113
|
+
if (!restored || restored.model !== undefined || restored.provider !== undefined
|
|
114
|
+
|| restored.thinking !== effort || restored.serviceTier !== undefined
|
|
115
|
+
|| normalized.profile !== original.profile || normalized.aliasName !== original.aliasName
|
|
116
|
+
|| !isDeepStrictEqual(omitSelection(restored), omitSelection(parsed)))
|
|
117
|
+
return { refused: "Stock HEAD model, effort and service tier flags cannot be replaced without changing other launch options" };
|
|
118
|
+
if (input.checkJournal) {
|
|
119
|
+
const refused = await checkHeadResumeJournal(input, parsed.serviceTier !== undefined);
|
|
120
|
+
if (refused) return { refused };
|
|
121
|
+
}
|
|
122
|
+
return { command };
|
|
123
|
+
}
|
|
@@ -3,7 +3,7 @@ import { access } from "node:fs/promises";
|
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
|
|
5
5
|
export const hostOwnerExecutable = fileURLToPath(new URL(
|
|
6
|
-
|
|
6
|
+
`../../host-owner/bin/omp-host-owner-${process.platform}-${process.arch}`, import.meta.url,
|
|
7
7
|
));
|
|
8
8
|
|
|
9
9
|
export async function requireHostOwner(): Promise<string> {
|
|
@@ -4,7 +4,8 @@ import { StringDecoder } from "node:string_decoder";
|
|
|
4
4
|
import { MAX_RPC_REASSEMBLED_BYTES, RpcFrameDecoder, RpcFrameEncoder } from "@oh-my-pi/pi-coding-agent/modes/rpc/rpc-frame";
|
|
5
5
|
import type { RpcResponse, RpcSessionState } from "@oh-my-pi/pi-coding-agent/modes/rpc/rpc-types";
|
|
6
6
|
import type { UnitSnapshot } from "@oh-my-pi/pi-coding-agent/daemon/protocol";
|
|
7
|
-
import type {
|
|
7
|
+
import type { ServiceTierByFamily } from "@oh-my-pi/pi-ai";
|
|
8
|
+
import type { LanePresetSnapshot } from "../contracts";
|
|
8
9
|
|
|
9
10
|
export const PR_REVIEW_SYSTEM_PROMPT = [
|
|
10
11
|
"You are a static pull request reviewer. Review only the material provided in the current request.",
|
|
@@ -17,6 +18,11 @@ export const PR_REVIEW_SYSTEM_PROMPT = [
|
|
|
17
18
|
export const PR_REVIEW_GITHUB_ENV = ["GH_TOKEN", "GITHUB_TOKEN", "GH_ENTERPRISE_TOKEN", "GITHUB_ENTERPRISE_TOKEN"] as const;
|
|
18
19
|
export const LANE_MODEL_PROMOTION_RECEIPT = "superagent_lane_model_promotion";
|
|
19
20
|
|
|
21
|
+
export type FastModeState = {
|
|
22
|
+
readonly mode: "off" | "on" | "ultra";
|
|
23
|
+
readonly active: boolean;
|
|
24
|
+
};
|
|
25
|
+
|
|
20
26
|
/** Private adapter observations, not additions to the stock RPC protocol. */
|
|
21
27
|
export type HostState = RpcSessionState & {
|
|
22
28
|
hostPid: number;
|
|
@@ -25,6 +31,9 @@ export type HostState = RpcSessionState & {
|
|
|
25
31
|
readonly loadedSuperkitPath?: string;
|
|
26
32
|
readonly prReviewPolicy?: { readonly version: 1; readonly cwd: string; readonly modelApi: string };
|
|
27
33
|
readonly journalCursorVersion?: 1;
|
|
34
|
+
readonly replyVoiceVersion?: 1 | 2;
|
|
35
|
+
readonly fastMode?: FastModeState;
|
|
36
|
+
readonly serviceTier?: Readonly<ServiceTierByFamily>;
|
|
28
37
|
settingsScope: "session";
|
|
29
38
|
modelSettings: LanePresetSnapshot;
|
|
30
39
|
hasOwnedRunningWork: boolean;
|
|
@@ -38,7 +47,7 @@ export type ServiceUnit = Pick<UnitSnapshot, "id" | "key" | "owner" |
|
|
|
38
47
|
};
|
|
39
48
|
export type Response = Frame & { success: boolean; data?: unknown; error?: string };
|
|
40
49
|
export type HostResponse = RpcResponse | {
|
|
41
|
-
type: "response"; id?: string; command: "shutdown_host" | "set_model_preset" | "set_pr_review_model" | "get_host_admission"; success: true; data: Frame;
|
|
50
|
+
type: "response"; id?: string; command: "shutdown_host" | "set_model_preset" | "set_pr_review_model" | "get_host_admission" | "set_head_fast_mode"; success: true; data: Frame;
|
|
42
51
|
} | {
|
|
43
52
|
type: "response"; id?: string; command: "set_lane_model"; success: true;
|
|
44
53
|
data: { readonly provider: string; readonly id: string };
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import type { AgentSession, ExtensionAPI } from "@oh-my-pi/pi-coding-agent";
|
|
4
|
+
import { isUserAuthoredMessage } from "@oh-my-pi/pi-coding-agent/session/messages";
|
|
5
|
+
import type { Frame } from "./host-protocol";
|
|
6
|
+
import { renderReplyVoice } from "./soul";
|
|
7
|
+
|
|
8
|
+
type Message = AgentSession["messages"][number];
|
|
9
|
+
type StagedVoice = { readonly token: string; readonly digest: string; readonly voice: string };
|
|
10
|
+
type Binding = StagedVoice & { readonly phase: "staged" | "input" | "submitted" };
|
|
11
|
+
type Submission = {
|
|
12
|
+
readonly token: string;
|
|
13
|
+
kind: "prompt" | "local-command" | "command-prompt";
|
|
14
|
+
admitted: boolean; prepared?: string;
|
|
15
|
+
};
|
|
16
|
+
const wirePrefix = "\0omp-superagent-reply-voice:";
|
|
17
|
+
|
|
18
|
+
const digest = (text: string) => createHash("sha256").update(text).digest("hex");
|
|
19
|
+
const messageText = (message: Extract<Message, { role: "user" }>) =>
|
|
20
|
+
typeof message.content === "string" ? message.content
|
|
21
|
+
: message.content.flatMap(part => part.type === "text" ? [part.text] : []).join("");
|
|
22
|
+
|
|
23
|
+
/** Project into the root's provider call, not its stored or effective session prompt. */
|
|
24
|
+
export function installReplyVoice(pi: ExtensionAPI, session: AgentSession, claim: (token: string) => Promise<boolean>,
|
|
25
|
+
retire: (token: string) => void) {
|
|
26
|
+
const { agent, sessionId, sessionFile, extensionRunner: runner } = session;
|
|
27
|
+
if (typeof agent.addBeforeModelCallHook !== "function" || typeof agent.streamFn !== "function"
|
|
28
|
+
|| typeof session.prompt !== "function" || typeof session.addDisposer !== "function"
|
|
29
|
+
|| typeof session.subscribeRunState !== "function" || !runner || typeof runner.emitInput !== "function") return;
|
|
30
|
+
const sameSession = () => session.sessionId === sessionId && session.sessionFile === sessionFile && !session.isDisposed;
|
|
31
|
+
const idle = () => sameSession() && !session.isRunActive && !session.isBusyForSnapshot
|
|
32
|
+
&& !session.hasAdmittedSubmission && !session.hasPostPromptWork && session.queuedMessageCount === 0;
|
|
33
|
+
const scope = new AsyncLocalStorage<Submission>();
|
|
34
|
+
let binding: Binding | undefined;
|
|
35
|
+
let runVoice: StagedVoice | undefined;
|
|
36
|
+
let approvedSignal: AbortSignal | undefined;
|
|
37
|
+
const clear = (token?: string) => {
|
|
38
|
+
if (token !== undefined && token !== binding?.token) return;
|
|
39
|
+
binding = undefined;
|
|
40
|
+
runVoice = undefined;
|
|
41
|
+
approvedSignal = undefined;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// Keep stock RPC's input path active even when no other extension handles it.
|
|
45
|
+
pi.on("input", () => {});
|
|
46
|
+
const emitInput = runner.emitInput;
|
|
47
|
+
const receive: typeof emitInput = async (text, images, source) => {
|
|
48
|
+
if (source !== "rpc" || !text.startsWith(wirePrefix)) return emitInput.call(runner, text, images, source);
|
|
49
|
+
const separator = text.indexOf("\n", wirePrefix.length);
|
|
50
|
+
if (separator === -1) throw new Error("Invalid owned reply voice input");
|
|
51
|
+
const original = text.slice(separator + 1);
|
|
52
|
+
const candidate = binding;
|
|
53
|
+
if (candidate?.phase !== "staged" || candidate.token !== text.slice(wirePrefix.length, separator)
|
|
54
|
+
|| digest(original) !== candidate.digest) throw new Error("Owned reply voice input did not match its staging");
|
|
55
|
+
// Strip the stock-only marker before other extensions see input; only a
|
|
56
|
+
// pass-through from the complete input hook may bind the RPC prompt.
|
|
57
|
+
const result = await emitInput.call(runner, original, images, source);
|
|
58
|
+
if (binding === candidate && !result.handled && (result.text ?? original) === original && idle()) {
|
|
59
|
+
const claimed = await claim(candidate.token).catch((error: unknown) => {
|
|
60
|
+
if (error instanceof Error) return false;
|
|
61
|
+
throw error;
|
|
62
|
+
});
|
|
63
|
+
if (binding === candidate) {
|
|
64
|
+
if (claimed) binding = { ...candidate, phase: "input" };
|
|
65
|
+
else clear();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return { ...result, text: result.text ?? original };
|
|
69
|
+
};
|
|
70
|
+
pi.on("before_agent_start", (event, ctx) => {
|
|
71
|
+
const submission = scope.getStore();
|
|
72
|
+
if (ctx.agent.kind === "main" && ctx.sessionManager === session.sessionManager && event.reason === "prompt"
|
|
73
|
+
&& submission?.admitted && submission.token === binding?.token && !runVoice) {
|
|
74
|
+
submission.prepared ??= digest(event.prompt);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const prompt = session.prompt;
|
|
79
|
+
// The private marker was consumed by the stock input carrier, not shown
|
|
80
|
+
// to a model. Observe its matching admission and actual new root input.
|
|
81
|
+
const boundPrompt: typeof prompt = (text, options) => {
|
|
82
|
+
const inherited = scope.getStore();
|
|
83
|
+
if (inherited?.kind === "local-command" && inherited.token === binding?.token && sameSession()
|
|
84
|
+
&& !session.isStreaming && !session.isRunActive
|
|
85
|
+
&& options?.expandPromptTemplates === false && options.throwOnDrop === true && options.streamingBehavior === "steer"
|
|
86
|
+
&& (options.attribution === undefined || options.attribution === "user")) {
|
|
87
|
+
// An extension command (such as a workflow alias) can handle the slash
|
|
88
|
+
// locally and submit its real user turn through pi.sendUserMessage.
|
|
89
|
+
// Use that SDK call's scoped admission, not the slash or rewritten text.
|
|
90
|
+
inherited.kind = "command-prompt";
|
|
91
|
+
return prompt.call(session, text, {
|
|
92
|
+
...options,
|
|
93
|
+
onPromptAdmitted: () => { inherited.admitted = session.isStreaming && !agent.state.isStreaming; },
|
|
94
|
+
}).finally(() => { if (runVoice?.token !== inherited.token) clear(inherited.token); });
|
|
95
|
+
}
|
|
96
|
+
const notify = options?.onPromptAdmitted;
|
|
97
|
+
if (binding?.phase !== "input" || !idle() || !options || typeof notify !== "function"
|
|
98
|
+
|| options.streamingBehavior !== undefined
|
|
99
|
+
|| !Object.hasOwn(options, "images") || !Object.hasOwn(options, "streamingBehavior") || Object.keys(options).length !== 3
|
|
100
|
+
|| digest(text) !== binding.digest) {
|
|
101
|
+
return scope.exit(() => prompt.call(session, text, options));
|
|
102
|
+
}
|
|
103
|
+
const { token } = binding;
|
|
104
|
+
binding = { ...binding, phase: "submitted" };
|
|
105
|
+
const submission: Submission = { token, kind: "prompt", admitted: false };
|
|
106
|
+
return scope.run(submission, () => prompt.call(session, text, {
|
|
107
|
+
...options,
|
|
108
|
+
onPromptAdmitted: () => {
|
|
109
|
+
// An idle SDK prompt routed to a local command fires the same
|
|
110
|
+
// callback before its handler, but has not claimed prompt setup.
|
|
111
|
+
submission.admitted = session.isStreaming && !agent.state.isStreaming;
|
|
112
|
+
if (!submission.admitted && !session.isStreaming) submission.kind = "local-command";
|
|
113
|
+
notify();
|
|
114
|
+
},
|
|
115
|
+
})).finally(() => {
|
|
116
|
+
if (submission.kind !== "command-prompt" && runVoice?.token !== token) clear(token);
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const dispatch = agent.streamFn;
|
|
121
|
+
const project: typeof dispatch = (model, input, options) => {
|
|
122
|
+
const voice = approvedSignal && !approvedSignal.aborted && session.isRunActive && sameSession()
|
|
123
|
+
&& !options?.signal?.aborted ? runVoice?.voice : undefined;
|
|
124
|
+
return dispatch(model, voice ? { ...input, systemPrompt: [...(input.systemPrompt ?? []), voice] } : input, options);
|
|
125
|
+
};
|
|
126
|
+
const unhook = agent.addBeforeModelCallHook((signal, context) => {
|
|
127
|
+
approvedSignal = undefined;
|
|
128
|
+
if (!sameSession() || !session.isRunActive || !signal || signal.aborted) return;
|
|
129
|
+
// A paused root run may resume in a fresh loop (and signal) to consume
|
|
130
|
+
// background work. The public run boundary, not the loop, owns the voice.
|
|
131
|
+
if (runVoice) { approvedSignal = signal; return; }
|
|
132
|
+
const submission = scope.getStore();
|
|
133
|
+
if (!submission?.admitted || !binding || submission.token !== binding.token) return;
|
|
134
|
+
// The first call's new input is in the loop context but has not yet
|
|
135
|
+
// emitted message_end. Use the current history after any pre-send rewrite.
|
|
136
|
+
const previousUser = agent.state.messages.findLast(isUserAuthoredMessage);
|
|
137
|
+
const previousIndex = previousUser ? context.messages.lastIndexOf(previousUser) : -1;
|
|
138
|
+
const firstUser = context.messages.find((message, index) => index > previousIndex && isUserAuthoredMessage(message));
|
|
139
|
+
if (firstUser?.role !== "user" || digest(messageText(firstUser)) !== submission.prepared) {
|
|
140
|
+
clear(submission.token);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
submission.prepared = undefined;
|
|
144
|
+
runVoice = binding;
|
|
145
|
+
approvedSignal = signal;
|
|
146
|
+
});
|
|
147
|
+
const unwatch = session.subscribeRunState(state => {
|
|
148
|
+
if (state === "idle" && runVoice) {
|
|
149
|
+
const { token } = runVoice;
|
|
150
|
+
clear(token);
|
|
151
|
+
retire(token);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
runner.emitInput = receive;
|
|
155
|
+
session.prompt = boundPrompt;
|
|
156
|
+
agent.streamFn = project;
|
|
157
|
+
session.addDisposer(() => {
|
|
158
|
+
clear();
|
|
159
|
+
unwatch();
|
|
160
|
+
unhook();
|
|
161
|
+
if (runner.emitInput === receive) runner.emitInput = emitInput;
|
|
162
|
+
if (session.prompt === boundPrompt) session.prompt = prompt;
|
|
163
|
+
if (agent.streamFn === project) agent.streamFn = dispatch;
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
const available = () => sameSession() && session.extensionRunner === runner && runner.emitInput === receive
|
|
167
|
+
&& session.prompt === boundPrompt && agent.streamFn === project;
|
|
168
|
+
return {
|
|
169
|
+
available, clear,
|
|
170
|
+
stage(command: Frame): boolean {
|
|
171
|
+
const { token, message } = command;
|
|
172
|
+
if (!available() || binding || typeof token !== "string" || !token || typeof message !== "string") {
|
|
173
|
+
throw new Error("Native reply voice cannot be staged");
|
|
174
|
+
}
|
|
175
|
+
const voice = renderReplyVoice(command.voice);
|
|
176
|
+
if (!idle()) return false;
|
|
177
|
+
binding = { token, digest: digest(message), voice, phase: "staged" };
|
|
178
|
+
return true;
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { realpathSync } from "node:fs";
|
|
2
2
|
import { sep } from "node:path";
|
|
3
3
|
import type { AgentSession } from "@oh-my-pi/pi-coding-agent";
|
|
4
|
-
import { readManagedUlwPackage } from "./managed-
|
|
4
|
+
import { readManagedUlwPackage } from "./managed-super";
|
|
5
5
|
|
|
6
6
|
/** Inspect this stock session's bound factories, not a second SDK loader or launch argv. */
|
|
7
7
|
export async function verifyHostSuperkit(session: AgentSession, selected: string | undefined): Promise<string> {
|
|
@@ -5,6 +5,7 @@ import * as net from "node:net";
|
|
|
5
5
|
import * as path from "node:path";
|
|
6
6
|
import { Readable, type Writable } from "node:stream";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
|
+
import { isDeepStrictEqual } from "node:util";
|
|
8
9
|
import {
|
|
9
10
|
RpcClient,
|
|
10
11
|
type RpcAgentProcess,
|
|
@@ -13,9 +14,9 @@ import { RPC_GOAL_CONTINUATION_MODE } from "@oh-my-pi/pi-coding-agent/modes/rpc/
|
|
|
13
14
|
import { HostChannel, PR_REVIEW_GITHUB_ENV, PR_REVIEW_SYSTEM_PROMPT, type HostResponse, type HostState } from "./host-protocol";
|
|
14
15
|
import { requireHostOwner } from "./host-owner-path";
|
|
15
16
|
import { inspectInstalledOmp, resolveOmpCommand } from "./installed-omp";
|
|
16
|
-
import type { DialogResponse, LanePresetSnapshot } from "
|
|
17
|
-
import type { WorkerHostProfile } from "
|
|
18
|
-
import { activeManagedUlw, managedUlwLaunch, MANAGED_ULW_ENV, MANAGED_ULW_FIXTURE_ENV, MANAGED_ULW_FIXTURE_ROOT_ENV, validateManagedUlwPackage } from "./managed-
|
|
17
|
+
import type { DialogResponse, LanePresetSnapshot } from "../contracts";
|
|
18
|
+
import type { WorkerHostProfile } from "../worker/worker-profile";
|
|
19
|
+
import { activeManagedUlw, managedUlwLaunch, MANAGED_ULW_ENV, MANAGED_ULW_FIXTURE_ENV, MANAGED_ULW_FIXTURE_ROOT_ENV, validateManagedUlwPackage } from "./managed-super";
|
|
19
20
|
|
|
20
21
|
const CONNECT_TIMEOUT_MS = 5_000;
|
|
21
22
|
const START_TIMEOUT_MS = 30_000;
|
|
@@ -28,10 +29,13 @@ export const PR_REVIEW_INPUT_PREFIX = "Static PR review input:\n";
|
|
|
28
29
|
const prReviewSettings = {
|
|
29
30
|
memory: { backend: "off" },
|
|
30
31
|
goal: { enabled: false },
|
|
32
|
+
plan: { enabled: false },
|
|
31
33
|
compaction: { enabled: false },
|
|
32
34
|
advisor: { enabled: false },
|
|
33
35
|
autolearn: { enabled: false },
|
|
34
36
|
dev: { autoqa: false },
|
|
37
|
+
speechgen: { enabled: false },
|
|
38
|
+
externalThinking: false,
|
|
35
39
|
skills: { enabled: false, enableSkillCommands: false, customDirectories: [] },
|
|
36
40
|
mcp: { enableProjectConfig: false },
|
|
37
41
|
marketplace: { autoUpdate: "off" },
|
|
@@ -348,10 +352,12 @@ export async function buildHostArgs(options: HostOptions, configPath = `${option
|
|
|
348
352
|
}
|
|
349
353
|
if (options.prReviewOnly) {
|
|
350
354
|
await assertPrReviewLaunch(options);
|
|
355
|
+
// Both stock interfaces accept an explicit empty built-in list. Unlike
|
|
356
|
+
// --no-tools in OMP 19.2, this permits the exact trusted lifecycle module.
|
|
351
357
|
return ["--mode", "rpc-ui", "--session", options.sessionFile, "--cwd", options.cwd,
|
|
352
|
-
"--
|
|
358
|
+
"--tools=", "--no-extensions", "--no-lsp", "--no-skills", "--no-rules", "--no-context-files",
|
|
353
359
|
"--no-title", "--no-prewalk", "--offline",
|
|
354
|
-
"--trusted-extension", await fs.realpath(fileURLToPath(new URL("
|
|
360
|
+
"--trusted-extension", await fs.realpath(fileURLToPath(new URL("../host-extension.ts", import.meta.url))),
|
|
355
361
|
"--system-prompt", PR_REVIEW_SYSTEM_PROMPT, "--config", configPath];
|
|
356
362
|
}
|
|
357
363
|
if (options.modelPreset) {
|
|
@@ -363,9 +369,8 @@ export async function buildHostArgs(options: HostOptions, configPath = `${option
|
|
|
363
369
|
}
|
|
364
370
|
const managedUlwPath = selectManagedUlw(options);
|
|
365
371
|
const extensions = composition?.extensionPaths ?? [
|
|
366
|
-
fileURLToPath(new URL("
|
|
367
|
-
fileURLToPath(new URL("
|
|
368
|
-
fileURLToPath(new URL("./host-extension.ts", import.meta.url)),
|
|
372
|
+
fileURLToPath(new URL("../../", import.meta.url)), managedUlwPath, options.extensionPath,
|
|
373
|
+
fileURLToPath(new URL("../host-extension.ts", import.meta.url)),
|
|
369
374
|
];
|
|
370
375
|
return [
|
|
371
376
|
"--mode", "rpc-ui",
|
|
@@ -410,7 +415,7 @@ async function launchHost(options: HostOptions, beforeSessionPrepare?: () => voi
|
|
|
410
415
|
})) throw new Error("Static PR review workspace must be outside a Git checkout");
|
|
411
416
|
if (path.dirname(dir) === dir) break;
|
|
412
417
|
}
|
|
413
|
-
const { assertWorkerWorkspaceStartup } = await import("
|
|
418
|
+
const { assertWorkerWorkspaceStartup } = await import("../worker/worker-profile");
|
|
414
419
|
assertWorkerWorkspaceStartup(cwd, options.env.HOME ?? "");
|
|
415
420
|
const env = { ...options.env };
|
|
416
421
|
for (const name of [...PR_REVIEW_GITHUB_ENV,
|
|
@@ -478,15 +483,15 @@ async function launchHost(options: HostOptions, beforeSessionPrepare?: () => voi
|
|
|
478
483
|
}
|
|
479
484
|
const manifestPath = path.join(launchDirectory, "owner.json");
|
|
480
485
|
const { env: _inheritedEnvironment, worker: _workerProfile, ...launchOptions } = options;
|
|
481
|
-
const helperPath = fileURLToPath(new URL("
|
|
486
|
+
const helperPath = fileURLToPath(new URL("../host-sdk-helper.ts", import.meta.url));
|
|
482
487
|
let manifest: Record<string, unknown> | undefined;
|
|
483
|
-
const extensionPaths = managedUlwPath === undefined ? [] : [fileURLToPath(new URL("
|
|
484
|
-
managedUlwPath, options.extensionPath,
|
|
485
|
-
fileURLToPath(new URL("
|
|
488
|
+
const extensionPaths = managedUlwPath === undefined ? [] : [fileURLToPath(new URL("../../", import.meta.url)),
|
|
489
|
+
managedUlwPath, options.extensionPath,
|
|
490
|
+
fileURLToPath(new URL("../host-extension.ts", import.meta.url))];
|
|
486
491
|
// The same helper discovers composition and then prepares the session.
|
|
487
492
|
// The worker launch fence is committed only immediately before the manifest
|
|
488
493
|
// is sent. Preparation and owner startup share the same deadline.
|
|
489
|
-
const { prepared, deadline } = await managedUlwLaunch({ cwd: options.cwd, managedUlwPath,
|
|
494
|
+
const { composition, prepared, deadline } = await managedUlwLaunch({ cwd: options.cwd, managedUlwPath,
|
|
490
495
|
extensionPaths, configPath, parentConfigPath: process.env.OMP_SUPERAGENT_HOST_CONFIG, commandArgs: options.command.slice(1),
|
|
491
496
|
...(options.worker ? { worker: { extensionPaths: options.worker.extensionPaths } } : {}),
|
|
492
497
|
launchArgs: managedUlwPath === undefined ? [] : [...options.command.slice(1), ...await buildHostArgs(options, configPath)],
|
|
@@ -504,10 +509,14 @@ async function launchHost(options: HostOptions, beforeSessionPrepare?: () => voi
|
|
|
504
509
|
const flags = JSON.parse(prepared);
|
|
505
510
|
if (typeof flags?.toolsExplicitlySelected !== "boolean" || typeof flags.noTools !== "boolean")
|
|
506
511
|
throw new Error("Native session preparation did not confirm tool selection");
|
|
507
|
-
if (options.prReviewOnly && (
|
|
508
|
-
throw new Error("Native launch did not resolve
|
|
512
|
+
if (options.prReviewOnly && (flags.emptyToolSelection !== true || flags.noTools || !flags.toolsExplicitlySelected))
|
|
513
|
+
throw new Error("Native launch did not resolve an explicit empty tool selection");
|
|
514
|
+
if (!options.prReviewOnly && !options.worker && (!composition.nativeProfile
|
|
515
|
+
|| !isDeepStrictEqual(flags.nativeProfileBinding?.profile, composition.nativeProfile)))
|
|
516
|
+
throw new Error("Native preparation did not bind the local Host's discovery profile");
|
|
509
517
|
await fs.writeFile(manifestPath, JSON.stringify({ ...manifest, toolsExplicitlySelected: flags.toolsExplicitlySelected,
|
|
510
|
-
noTools: flags.noTools,
|
|
518
|
+
noTools: flags.noTools, ...(options.prReviewOnly ? { emptyToolSelection: true } : {}),
|
|
519
|
+
inventory: flags.inventory, nativeProfileBinding: flags.nativeProfileBinding, replayableArgvHash: flags.replayableArgvHash }), { flag: "wx", mode: 0o600 });
|
|
511
520
|
if (performance.now() >= deadline) throw new Error("Native Host startup timed out before launch");
|
|
512
521
|
child = spawn(hostOwnerExecutable, [manifestPath], {
|
|
513
522
|
cwd: options.cwd, env: options.env,
|
|
@@ -2,7 +2,7 @@ import { closeSync, constants, fstatSync, openSync, readSync, realpathSync, stat
|
|
|
2
2
|
import { basename, delimiter, dirname, isAbsolute, join, resolve } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
|
|
5
|
-
const root = resolve(dirname(fileURLToPath(import.meta.url)), "
|
|
5
|
+
const root = resolve(dirname(fileURLToPath(import.meta.url)), "../..");
|
|
6
6
|
|
|
7
7
|
/** Resolve outside dependency shims, including PATH injected by bun run/install. */
|
|
8
8
|
export function discoverInstalledOmp(path = process.env.PATH ?? ""): string {
|
|
@@ -2,7 +2,7 @@ import type { Settings } from "@oh-my-pi/pi-coding-agent/config/settings";
|
|
|
2
2
|
import { Type, type Static } from "@sinclair/typebox";
|
|
3
3
|
import { IsStandardObject as isRecord, Value } from "@sinclair/typebox/value";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { credentialEnvNames, type Config } from "
|
|
5
|
+
import { credentialEnvNames, type Config } from "../config/config";
|
|
6
6
|
|
|
7
7
|
const nativeScope = {
|
|
8
8
|
source: Type.Union([Type.Literal("default"), Type.Literal("global"), Type.Literal("project"),
|
|
@@ -116,7 +116,7 @@ export function applyConsentedMnemopi(config: Config, consent: GlobalMemoryCandi
|
|
|
116
116
|
async function runMemoryHelper(config: Config, consent?: GlobalMemoryCandidate): Promise<ManagedMemoryReport> {
|
|
117
117
|
const env = { ...process.env };
|
|
118
118
|
for (const name of credentialEnvNames(config)) delete env[name];
|
|
119
|
-
const helper = fileURLToPath(new URL("
|
|
119
|
+
const helper = fileURLToPath(new URL("../managed-memory-helper.ts", import.meta.url));
|
|
120
120
|
const unavailable: ManagedMemoryReport = { memory: { status: "unknown" }, updated: false };
|
|
121
121
|
try {
|
|
122
122
|
const operation = consent ? "apply-consented" : "inspect";
|