omp-superagent 0.1.10 → 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 +58 -15
- package/README.ko.md +7 -0
- package/README.md +7 -0
- 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 +1 -0
- package/docs/OPERATIONS.en.md +106 -52
- package/docs/OPERATIONS.md +98 -44
- package/docs/design/execution.md +80 -52
- package/docs/design/messaging.md +113 -32
- 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 +12 -3
- package/skills/head/references/routing.md +1 -1
- package/skills/head/references/supervision.md +23 -26
- package/skills/lane/SKILL.md +28 -21
- package/skills/lane/references/workflow.md +15 -17
- package/src/cli.ts +33 -33
- package/src/{config.ts → config/config.ts} +7 -3
- package/src/config/wake-config.ts +36 -0
- package/src/contracts.ts +61 -12
- 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 +43 -25
- 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 +164 -36
- 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-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 +25 -7
- 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} +10 -2
- 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/{soul.ts → omp/soul.ts} +2 -2
- 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} +5 -5
- 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} +1 -1
- 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} +867 -1213
- 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} +75 -42
- 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/{lane-report.ts → lane/lane-report.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-reply-voice.ts → omp/host-reply-voice.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
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import * as fs from "node:fs/promises";
|
|
2
|
+
import { lstatSync, realpathSync, statSync } from "node:fs";
|
|
3
|
+
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
4
|
+
import { isDeepStrictEqual } from "node:util";
|
|
5
|
+
import { getAgentDbPath, getAgentDir, getSessionsDir } from "@oh-my-pi/pi-utils/dirs";
|
|
6
|
+
import { readSessionInfo } from "@oh-my-pi/pi-coding-agent/session/session-listing";
|
|
7
|
+
import { sessionDirForCwd } from "@oh-my-pi/pi-coding-agent/session/session-paths";
|
|
8
|
+
|
|
9
|
+
export const NATIVE_PROFILE_ENV = "OMP_SUPERAGENT_NATIVE_PROFILE";
|
|
10
|
+
|
|
11
|
+
export type NativeProfilePaths = {
|
|
12
|
+
readonly agentDir: string;
|
|
13
|
+
readonly dataDir: string;
|
|
14
|
+
readonly sessionsDir: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type NativeProfile = NativeProfilePaths & { readonly version: 2 };
|
|
18
|
+
|
|
19
|
+
export type NativeProfileBinding = {
|
|
20
|
+
readonly profile: NativeProfile;
|
|
21
|
+
readonly discoveryEntry: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type HostReadyEvent = {
|
|
25
|
+
readonly pid: number;
|
|
26
|
+
readonly sessionId: string;
|
|
27
|
+
readonly sessionFile: string;
|
|
28
|
+
readonly nativeProfile?: NativeProfile;
|
|
29
|
+
readonly waking?: boolean;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export function sdkNativeProfilePaths(agentDir = getAgentDir()): NativeProfilePaths {
|
|
33
|
+
return { agentDir, dataDir: dirname(getAgentDbPath(agentDir)), sessionsDir: getSessionsDir() };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function isMissing(error: unknown): boolean {
|
|
37
|
+
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Resolve through existing ancestors without creating directories or accepting dangling symlinks. */
|
|
41
|
+
function canonicalDirectory(path: string): string {
|
|
42
|
+
if (!isAbsolute(path)) throw new Error("Native profile paths must be absolute");
|
|
43
|
+
const stat = lstatSync(path, { throwIfNoEntry: false });
|
|
44
|
+
if (!stat) return join(canonicalDirectory(dirname(path)), basename(path));
|
|
45
|
+
const canonical = realpathSync(path);
|
|
46
|
+
if (!(stat.isSymbolicLink() ? statSync(canonical) : stat).isDirectory())
|
|
47
|
+
throw new Error("Native profile path is not a directory");
|
|
48
|
+
return canonical;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function resolveNativeProfile(paths: NativeProfilePaths): NativeProfile {
|
|
52
|
+
return { version: 2, agentDir: canonicalDirectory(paths.agentDir), dataDir: canonicalDirectory(paths.dataDir),
|
|
53
|
+
sessionsDir: canonicalDirectory(paths.sessionsDir) };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function matchesNativeProfile(paths: NativeProfilePaths, profile: NativeProfile): boolean {
|
|
57
|
+
return isDeepStrictEqual(resolveNativeProfile(paths), profile);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Use the injected stock SDK, not a second resolver from node_modules. */
|
|
61
|
+
export async function bindNativeProfile(
|
|
62
|
+
native: Pick<typeof import("@oh-my-pi/pi-coding-agent"), "findSessionFiles" | "getAgentDir">,
|
|
63
|
+
session: { readonly agentDir: string; readonly file: string; readonly id: string },
|
|
64
|
+
binding: NativeProfileBinding,
|
|
65
|
+
): Promise<NativeProfilePaths> {
|
|
66
|
+
const mismatch = () => new Error("Running native Host does not match the prepared agent, data and discovery roots");
|
|
67
|
+
if (native.getAgentDir() !== session.agentDir) throw mismatch();
|
|
68
|
+
const source = realpathSync(session.file);
|
|
69
|
+
const preparedBucket = dirname(binding.discoveryEntry);
|
|
70
|
+
if (dirname(preparedBucket) !== binding.profile.sessionsDir || canonicalDirectory(preparedBucket) !== preparedBucket
|
|
71
|
+
|| realpathSync(binding.discoveryEntry) !== source) throw mismatch();
|
|
72
|
+
// Unlike getDefaultSessionDir, the stock search does not create project
|
|
73
|
+
// buckets or migrate files. Its default root is the native process's data
|
|
74
|
+
// partition, independent of the npm SDK's ambient directory resolver. It
|
|
75
|
+
// may deduplicate legitimate aliases, so compare the owned journal itself.
|
|
76
|
+
for (const entry of await native.findSessionFiles(session.id)) {
|
|
77
|
+
const sessionsDir = dirname(dirname(entry));
|
|
78
|
+
const paths = { agentDir: session.agentDir, dataDir: dirname(sessionsDir), sessionsDir };
|
|
79
|
+
if (matchesNativeProfile(paths, binding.profile) && realpathSync(entry) === source) return paths;
|
|
80
|
+
}
|
|
81
|
+
throw mismatch();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Stock OMP follows leaf session links for discovery and writes through them. */
|
|
85
|
+
export async function publishNativeSession(
|
|
86
|
+
sessionFile: string, cwd: string, expectedId?: string, profile = resolveNativeProfile(sdkNativeProfilePaths()),
|
|
87
|
+
): Promise<string | undefined> {
|
|
88
|
+
const info = await readSessionInfo(sessionFile);
|
|
89
|
+
if (!info) return;
|
|
90
|
+
if (expectedId !== undefined && (info.id !== expectedId || info.cwd !== cwd))
|
|
91
|
+
throw new Error("Refusing to publish a journal with a different managed session identity");
|
|
92
|
+
const source = await fs.realpath(sessionFile);
|
|
93
|
+
const directory = sessionDirForCwd(cwd, profile.sessionsDir);
|
|
94
|
+
const target = join(directory, `${info.created.toISOString().replace(/[:.]/g, "-")}_${info.id}.jsonl`);
|
|
95
|
+
if (target === source) return target;
|
|
96
|
+
|
|
97
|
+
const requireBucket = () => {
|
|
98
|
+
if (!matchesNativeProfile(profile, profile) || canonicalDirectory(directory) !== directory)
|
|
99
|
+
throw new Error("Native discovery directory no longer belongs to the prepared profile");
|
|
100
|
+
};
|
|
101
|
+
requireBucket();
|
|
102
|
+
await fs.mkdir(directory, { recursive: true, mode: 0o700 });
|
|
103
|
+
const link = async (original: string, destination: string) => {
|
|
104
|
+
requireBucket();
|
|
105
|
+
try { await fs.symlink(original, destination); }
|
|
106
|
+
catch (error) {
|
|
107
|
+
if ((error as NodeJS.ErrnoException).code !== "EEXIST") throw error;
|
|
108
|
+
const existing = await fs.readlink(destination).catch(error => {
|
|
109
|
+
if (isMissing(error) || (error instanceof Error && "code" in error && error.code === "EINVAL")) return;
|
|
110
|
+
throw error;
|
|
111
|
+
});
|
|
112
|
+
if (!existing || resolve(dirname(destination), existing) !== original)
|
|
113
|
+
throw new Error(`Native session discovery path already belongs to another file: ${destination}`);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
// The resumed session must keep its original spill artifacts and child journals.
|
|
117
|
+
if (source.endsWith(".jsonl")) {
|
|
118
|
+
const artifacts = source.slice(0, -".jsonl".length);
|
|
119
|
+
await fs.mkdir(artifacts, { recursive: true, mode: 0o700 });
|
|
120
|
+
await link(artifacts, target.slice(0, -".jsonl".length));
|
|
121
|
+
}
|
|
122
|
+
await link(source, target);
|
|
123
|
+
return target;
|
|
124
|
+
}
|
|
@@ -3,7 +3,7 @@ import { delimiter } from "node:path";
|
|
|
3
3
|
import { extractProfileFlags } from "@oh-my-pi/pi-coding-agent/cli/profile-bootstrap";
|
|
4
4
|
import { Type, type Static } from "@sinclair/typebox/type";
|
|
5
5
|
import { Value } from "@sinclair/typebox/value";
|
|
6
|
-
import { credentialEnvNames, type Config } from "
|
|
6
|
+
import { credentialEnvNames, type Config } from "../config/config";
|
|
7
7
|
|
|
8
8
|
// Parse only fields used from the CLI JSON. The stock extension loader does not
|
|
9
9
|
// resolve the SDK usage module's internal omptype import.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Type } from "@sinclair/typebox";
|
|
2
|
-
import type { Inbound, StorePort } from "
|
|
3
|
-
import { ownerRoutingProse, transportRoutingProse } from "
|
|
2
|
+
import type { Inbound, StorePort } from "../contracts";
|
|
3
|
+
import { ownerRoutingProse, transportRoutingProse } from "../routing/topic-history";
|
|
4
4
|
|
|
5
5
|
const dimensions = {
|
|
6
6
|
concept: {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import type { Args } from "@oh-my-pi/pi-coding-agent/cli/args";
|
|
3
|
+
|
|
4
|
+
export function stockReplayRefusal(parsed: Args | null, sessionFile: string): string | undefined {
|
|
5
|
+
if (parsed?.mode !== "rpc-ui" || parsed.resume !== sessionFile)
|
|
6
|
+
return "HEAD wake requires an exact stock rpc-ui session launch";
|
|
7
|
+
if (parsed.fork !== undefined || parsed.continue || parsed.restore || parsed.noSession || parsed.fromClaude || parsed.fromCodex)
|
|
8
|
+
return "HEAD wake cannot combine competing stock session selectors";
|
|
9
|
+
if (parsed.maxTime !== undefined)
|
|
10
|
+
return "Stock --max-time starts a new deadline on launch; HEAD wake cannot restore its remaining time";
|
|
11
|
+
if (parsed.prewalk || parsed.prewalkInto !== undefined)
|
|
12
|
+
return "Stock --prewalk or --prewalk-into rearms one-shot planning on launch; HEAD wake cannot restore its prior state";
|
|
13
|
+
if (parsed.planYolo || parsed.planYoloInto !== undefined)
|
|
14
|
+
return "Stock --plan-yolo rearms autonomous planning on launch; HEAD wake cannot restore its prior state";
|
|
15
|
+
if (parsed.unrecognizedFlags.includes("--preset"))
|
|
16
|
+
return "Stock OMP has no --preset launch selector; an extension-owned --preset cannot be restored by HEAD wake";
|
|
17
|
+
if (parsed.goal !== undefined || parsed.messages.length || parsed.fileArgs.length
|
|
18
|
+
|| parsed.invalidFlagValues.length || parsed.unrecognizedFlags.length || parsed.unknownFlags.size)
|
|
19
|
+
return "HEAD wake cannot prove replay of stock startup input or extension-owned flags";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function launchArgvHash(argv: readonly string[]): string {
|
|
23
|
+
return createHash("sha256").update(JSON.stringify(argv)).digest("hex");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The helper has parsed these exact arguments before spawn. A wrapper may
|
|
27
|
+
* change them, and only the live extension runner knows which flags it owns. */
|
|
28
|
+
export function matchesPreparedLaunch(argv: readonly string[], prepared: unknown, flags?: ReadonlyMap<string, unknown>): boolean {
|
|
29
|
+
return typeof prepared === "string" && flags !== undefined && launchArgvHash(argv) === prepared
|
|
30
|
+
&& !argv.some(arg => arg.startsWith("--") && flags.has(arg.slice(2).split("=", 1)[0]));
|
|
31
|
+
}
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
import { userInfo } from "node:os";
|
|
7
7
|
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
|
-
import { credentialEnvNames, type Config } from "
|
|
10
|
-
import { readCredentialFile, stagePrivateFile, validateCredential } from "
|
|
9
|
+
import { credentialEnvNames, type Config } from "../config/config";
|
|
10
|
+
import { readCredentialFile, stagePrivateFile, validateCredential } from "../config/credentials";
|
|
11
11
|
|
|
12
12
|
interface CommandResult { code: number; stdout: string; stderr: string }
|
|
13
13
|
/** Only OS identity and launchctl transport are injectable; never a production environment switch. */
|
|
@@ -79,7 +79,7 @@ function definition(config: Config, adapters: AutostartAdapters): Definition {
|
|
|
79
79
|
if (!isAbsolute(home) || !isAbsolute(executable)) throw new Error("Autostart requires absolute OS home and Bun paths");
|
|
80
80
|
return {
|
|
81
81
|
stateDir, label, home, executable, ompDirectory, configPath: resolve(config.path),
|
|
82
|
-
cliPath: fileURLToPath(new URL("
|
|
82
|
+
cliPath: fileURLToPath(new URL("../cli.ts", import.meta.url)),
|
|
83
83
|
plistPath: join(home, "Library", "LaunchAgents", `${label}.plist`),
|
|
84
84
|
path: searchPath(executable, ompDirectory),
|
|
85
85
|
target: `gui/${adapters.uid}/${label}`,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { addAbortListener } from "node:events";
|
|
2
|
-
import { requireGateway } from "
|
|
3
|
-
import { readCredentialFile, validateCredential } from "
|
|
2
|
+
import { requireGateway } from "../gateway/gateway-native";
|
|
3
|
+
import { readCredentialFile, validateCredential } from "../config/credentials";
|
|
4
4
|
|
|
5
5
|
type Credentials = { readonly bot: string; readonly manifest?: string };
|
|
6
6
|
export type OperatorRun = <T>(operation: string, request: unknown, credentials: Credentials, signal?: AbortSignal) => Promise<T>;
|
|
@@ -16,7 +16,7 @@ export async function inspectNativeJudge(cwd: string): Promise<JudgeConfiguratio
|
|
|
16
16
|
// Read-only settings intentionally skip legacy global migration. Only an
|
|
17
17
|
// effective higher-layer assignment can settle the role without it; in
|
|
18
18
|
// particular native project null falls through, unlike overlay null.
|
|
19
|
-
const { hasUnresolvedNativeLegacy } = await import("
|
|
19
|
+
const { hasUnresolvedNativeLegacy } = await import("../omp/native-settings");
|
|
20
20
|
if (await hasUnresolvedNativeLegacy(settings.getAgentDir())) return { status: "unknown" };
|
|
21
21
|
}
|
|
22
22
|
// Native modelRoles defaults to an empty record. This accessor normalizes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Config } from "
|
|
2
|
-
import { validateCredential } from "
|
|
1
|
+
import type { Config } from "../config/config";
|
|
2
|
+
import { validateCredential } from "../config/credentials";
|
|
3
3
|
import { OperatorStartError, runOperator, type OperatorRun } from "./operator";
|
|
4
4
|
|
|
5
5
|
interface ProfileOptions {
|
|
@@ -6,16 +6,16 @@ import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { isatty } from "node:tty";
|
|
8
8
|
import { setImmediate as yieldToSignals } from "node:timers/promises";
|
|
9
|
-
import { credentialEnvNames, hostPaths, parseConfig, type Config } from "
|
|
10
|
-
import { discoverInstalledOmp, inspectInstalledOmp } from "
|
|
9
|
+
import { credentialEnvNames, hostPaths, parseConfig, type Config } from "../config/config";
|
|
10
|
+
import { discoverInstalledOmp, inspectInstalledOmp } from "../omp/installed-omp";
|
|
11
11
|
import {
|
|
12
12
|
assertCredentialsUnchanged, readCredentialFile, serializeCredentials, stagePrivateFile,
|
|
13
13
|
validateCredential, writeCredentials,
|
|
14
|
-
} from "
|
|
15
|
-
import { applyConsentedMnemopi, canEnableGlobalMemory, inspectManagedMemory, memoryBlockReason } from "
|
|
14
|
+
} from "../config/credentials";
|
|
15
|
+
import { applyConsentedMnemopi, canEnableGlobalMemory, inspectManagedMemory, memoryBlockReason } from "../omp/managed-memory";
|
|
16
16
|
import { inspectNativeJudge } from "./setup-judge";
|
|
17
17
|
|
|
18
|
-
const root = resolve(dirname(fileURLToPath(import.meta.url)), "
|
|
18
|
+
const root = resolve(dirname(fileURLToPath(import.meta.url)), "../..");
|
|
19
19
|
|
|
20
20
|
class SetupCancelled extends Error {
|
|
21
21
|
constructor(saved = false) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { Type, type Static } from "@sinclair/typebox/type";
|
|
3
|
-
import type { StorePort } from "
|
|
3
|
+
import type { StorePort } from "../contracts";
|
|
4
4
|
import { PrReadError, parseWire, sha40 as sha } from "./pr-github-schema";
|
|
5
5
|
import { inspectIntakeComment, publishIntakeComment } from "./pr-intake-comment";
|
|
6
6
|
import { applyIntakeFix, parseIntakeFix, reconcileIntakeFix } from "./pr-intake-fix";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeIntakeRepository } from "
|
|
1
|
+
import { normalizeIntakeRepository } from "../cron/cron-pr-intake";
|
|
2
2
|
|
|
3
3
|
export const prModeEffects = {
|
|
4
4
|
review: "static review and a bounded GitHub PR comment",
|
|
@@ -24,7 +24,7 @@ const jobId = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/iu;
|
|
|
24
24
|
|
|
25
25
|
export function parsePrModeControl(argument: string): ModeCommand | null {
|
|
26
26
|
if (lineBreak.test(argument)) return null;
|
|
27
|
-
const match = /^pr-mode
|
|
27
|
+
const match = /^pr-mode\s+(?:(\S+)\s+)?(review|fix|merge)$/u.exec(argument.trim());
|
|
28
28
|
const [, selector, mode] = match ?? [];
|
|
29
29
|
if (mode !== "review" && mode !== "fix" && mode !== "merge") return null;
|
|
30
30
|
if (selector === undefined) return { target: null, mode };
|
|
@@ -36,7 +36,7 @@ export function parsePrModeControl(argument: string): ModeCommand | null {
|
|
|
36
36
|
export function prModeArgument(text: string): string | null {
|
|
37
37
|
if (lineBreak.test(text)) return null;
|
|
38
38
|
const command = text.trim();
|
|
39
|
-
const slash = /^\/cron
|
|
39
|
+
const slash = /^\/cron\s+(.+)$/u.exec(command)?.[1];
|
|
40
40
|
if (slash !== undefined) {
|
|
41
41
|
const parsed = parsePrModeControl(slash);
|
|
42
42
|
return parsed?.target ? `pr-mode ${parsed.target} ${parsed.mode}` : null;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { physicalRoute, routeKey, type Inbound, type InputRecord, type Lane, type Route, type StorePort } from "
|
|
3
|
-
import { compareMessageIds } from "
|
|
4
|
-
import type { CronJobs } from "
|
|
5
|
-
import type { CronPrCandidate, CronPrIntake } from "
|
|
6
|
-
import type { CronPrJob } from "
|
|
2
|
+
import { physicalRoute, routeKey, type Inbound, type InputRecord, type Lane, type Route, type StorePort } from "../contracts";
|
|
3
|
+
import { compareMessageIds } from "../routing/message-order";
|
|
4
|
+
import type { CronJobs } from "../cron/cron-jobs";
|
|
5
|
+
import type { CronPrCandidate, CronPrIntake } from "../cron/cron-pr-intake";
|
|
6
|
+
import type { CronPrJob } from "../cron/cron-jobs";
|
|
7
7
|
import { hasIntakeReplyRoute, intakeThreadKey, intakeStatusKey, intakeWorkId, intakeWorkPrefix } from "./pr-intake-work";
|
|
8
8
|
import { inspectIntakeMerge, mergeIntakePull } from "./pr-intake-github";
|
|
9
9
|
import { applyIntakeFix, intakeFixDigest, parseIntakeFix, reconcileIntakeFix } from "./pr-intake-fix";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { routeKey, type InputRecord, type StorePort } from "
|
|
1
|
+
import { routeKey, type InputRecord, type StorePort } from "../contracts";
|
|
2
2
|
|
|
3
3
|
// Controller receipts have no platform message/interaction and are never owner
|
|
4
4
|
// inputs. Only the restricted lane's exact native result has a delivery route.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { LaneModel } from "
|
|
2
|
-
import { acceptsRestrictedModelSelector, isLaneModel } from "
|
|
1
|
+
import type { LaneModel } from "../contracts";
|
|
2
|
+
import { acceptsRestrictedModelSelector, isLaneModel } from "../lane/lane-models";
|
|
3
3
|
|
|
4
4
|
const inferenceApis = new Set(["openai-completions", "openai-responses", "openai-codex-responses",
|
|
5
5
|
"azure-openai-responses", "anthropic-messages"]);
|
|
@@ -4,10 +4,10 @@ import { isDeepStrictEqual } from "node:util";
|
|
|
4
4
|
// OMP intentionally remaps only the package root to its callable tool schemas.
|
|
5
5
|
import { Type, type Static } from "@sinclair/typebox/type";
|
|
6
6
|
import { Value } from "@sinclair/typebox/value";
|
|
7
|
-
import type { Config } from "
|
|
8
|
-
import { authorizeRoute } from "
|
|
9
|
-
import type { InputRecord, OutputRecord, StorePort } from "
|
|
10
|
-
import { routeKey } from "
|
|
7
|
+
import type { Config } from "../config/config";
|
|
8
|
+
import { authorizeRoute } from "../config/config";
|
|
9
|
+
import type { InputRecord, OutputRecord, StorePort } from "../contracts";
|
|
10
|
+
import { routeKey } from "../contracts";
|
|
11
11
|
import { parsePrRef, prKey, readPrSnapshot, type PrSnapshot } from "./pr-github";
|
|
12
12
|
import { ciOutcomeSchema, PrReadError } from "./pr-github-schema";
|
|
13
13
|
|
|
@@ -92,7 +92,7 @@ function changes(watch: Watch, after: PrSnapshot): string[] {
|
|
|
92
92
|
|
|
93
93
|
/** HEAD-owned ordinary-code observation. Never sends a message or calls a lane. */
|
|
94
94
|
export class PrWatcher {
|
|
95
|
-
private running?: Promise<
|
|
95
|
+
private running?: Promise<boolean>;
|
|
96
96
|
|
|
97
97
|
constructor(
|
|
98
98
|
private readonly store: StorePort,
|
|
@@ -168,12 +168,17 @@ export class PrWatcher {
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
private source(id: string): InputRecord {
|
|
171
|
-
const source = this.
|
|
172
|
-
if (!source
|
|
171
|
+
const source = this.pollSource(id);
|
|
172
|
+
if (!source)
|
|
173
173
|
throw new PrWatchError("PR tracking requires an original authorized user source without a cancellation or uncertainty hold");
|
|
174
174
|
return source;
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
+
private pollSource(id: string): InputRecord | null {
|
|
178
|
+
const source = this.ownerSource(id);
|
|
179
|
+
return source && source.state !== "cancelled" && source.state !== "uncertain" ? source : null;
|
|
180
|
+
}
|
|
181
|
+
|
|
177
182
|
/** Recheck the exact registration at native submission, not just when the read completed. */
|
|
178
183
|
canConsume(input: InputRecord): boolean {
|
|
179
184
|
if (!isPrObservation(input.id)) return true;
|
|
@@ -182,9 +187,8 @@ export class PrWatcher {
|
|
|
182
187
|
const watch = state(this.store).watches.find(item => item.epoch === epoch);
|
|
183
188
|
if (!watch || watch.stopBoundary !== this.store.getMeta(STOP_BOUNDARY)
|
|
184
189
|
|| watch.sourceId !== this.store.getMeta(`activity-source:${input.id}`)) return false;
|
|
185
|
-
const source = this.
|
|
186
|
-
return
|
|
187
|
-
&& routeKey(input.route) === routeKey(source.route);
|
|
190
|
+
const source = this.pollSource(watch.sourceId);
|
|
191
|
+
return source !== null && routeKey(input.route) === routeKey(source.route);
|
|
188
192
|
}
|
|
189
193
|
|
|
190
194
|
deliverable(output: OutputRecord): boolean {
|
|
@@ -193,23 +197,27 @@ export class PrWatcher {
|
|
|
193
197
|
&& routeKey(output.route) === routeKey(input.route) && this.canConsume(input);
|
|
194
198
|
}
|
|
195
199
|
|
|
196
|
-
poll(now: number, signal: AbortSignal): Promise<
|
|
200
|
+
poll(now: number, signal: AbortSignal): Promise<boolean> {
|
|
197
201
|
if (this.running) return this.running;
|
|
198
202
|
this.running = this.observe(now, signal).finally(() => { this.running = undefined; });
|
|
199
203
|
return this.running;
|
|
200
204
|
}
|
|
201
205
|
|
|
202
|
-
private
|
|
206
|
+
private scheduled(watch: Watch, boundary: string | null): boolean {
|
|
207
|
+
return watch.snapshot?.state !== "merged" && watch.stopBoundary === boundary;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
hasScheduledWork(): boolean {
|
|
211
|
+
const boundary = this.store.getMeta(STOP_BOUNDARY);
|
|
212
|
+
return state(this.store).watches.some(watch => this.scheduled(watch, boundary) && this.pollSource(watch.sourceId) !== null);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
private async observe(now: number, signal: AbortSignal): Promise<boolean> {
|
|
216
|
+
let admitted = false;
|
|
203
217
|
for (const watch of state(this.store).watches) {
|
|
204
|
-
if (signal.aborted)
|
|
205
|
-
if (watch.nextCheckAt > now || watch.
|
|
206
|
-
|
|
207
|
-
let source: InputRecord;
|
|
208
|
-
try { source = this.source(watch.sourceId); }
|
|
209
|
-
catch (error) {
|
|
210
|
-
if (!(error instanceof PrWatchError)) throw error;
|
|
211
|
-
continue; // Cancelled/unauthorized sources never cause network reads or wakes.
|
|
212
|
-
}
|
|
218
|
+
if (signal.aborted) break;
|
|
219
|
+
if (watch.nextCheckAt > now || !this.scheduled(watch, this.store.getMeta(STOP_BOUNDARY))) continue;
|
|
220
|
+
if (!this.pollSource(watch.sourceId)) continue; // Cancelled/unauthorized sources never cause network reads or wakes.
|
|
213
221
|
let snapshot = watch.snapshot;
|
|
214
222
|
let baseline = watch.baseline ?? null;
|
|
215
223
|
let seen = watch.seen;
|
|
@@ -225,17 +233,17 @@ export class PrWatcher {
|
|
|
225
233
|
seen = [...new Set([...watch.seen, ...observed.feedback.map(item => item.key), ...observed.failures.map(item => item.key),
|
|
226
234
|
...("key" in observed.ci ? [observed.ci.key] : [])])];
|
|
227
235
|
} catch (failure) {
|
|
228
|
-
if (signal.aborted)
|
|
236
|
+
if (signal.aborted) break;
|
|
229
237
|
error = failure instanceof PrReadError || failure instanceof PrWatchError ? failure.message : "GitHub observation failed";
|
|
230
238
|
if (error !== watch.error) lines = ["PR_WATCH_ERROR: observation failed. No baseline was advanced. The owner can request tracking status in this conversation."];
|
|
231
239
|
}
|
|
232
|
-
if (signal.aborted)
|
|
240
|
+
if (signal.aborted) break;
|
|
233
241
|
// A user can untrack/rebind or stop the source while the read is in flight.
|
|
234
242
|
const current = state(this.store);
|
|
235
243
|
if (!current.watches.some(item => item.epoch === watch.epoch)
|
|
236
244
|
|| watch.stopBoundary !== this.store.getMeta(STOP_BOUNDARY)) continue;
|
|
237
|
-
|
|
238
|
-
|
|
245
|
+
const source = this.pollSource(watch.sourceId);
|
|
246
|
+
if (!source) continue;
|
|
239
247
|
const next = { ...watch, snapshot, baseline, seen, events: watch.events + (lines.length ? 1 : 0),
|
|
240
248
|
error, nextCheckAt: now + watch.intervalSeconds * 1000 };
|
|
241
249
|
const serialized = JSON.stringify({ ...current, watches: current.watches.map(item => item.epoch === watch.epoch ? next : item) });
|
|
@@ -243,7 +251,7 @@ export class PrWatcher {
|
|
|
243
251
|
const fingerprint = createHash("sha256").update(JSON.stringify([watch.epoch, next.events])).digest("hex");
|
|
244
252
|
const id = `${OBSERVATION_PREFIX}${fingerprint}`;
|
|
245
253
|
// Admission and the cursor are one existing Store transaction, not print-then-ACK.
|
|
246
|
-
this.store.receive({
|
|
254
|
+
const queued = this.store.receive({
|
|
247
255
|
id, route: source.route, messageId: source.messageId, receivedAt: source.receivedAt,
|
|
248
256
|
...(source.interactionId === undefined ? {} : { interactionId: source.interactionId }),
|
|
249
257
|
...(source.invocationId === undefined ? {} : { invocationId: source.invocationId }),
|
|
@@ -254,6 +262,8 @@ export class PrWatcher {
|
|
|
254
262
|
...lines,
|
|
255
263
|
].join("\n\n"), attachments: [],
|
|
256
264
|
}, "main", { [`activity-source:${id}`]: source.id, [`pr-observation:${id}`]: watch.epoch, [STATE_KEY]: serialized });
|
|
265
|
+
if (queued) admitted = true;
|
|
257
266
|
}
|
|
267
|
+
return admitted;
|
|
258
268
|
}
|
|
259
269
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Platform } from "
|
|
1
|
+
import type { Platform } from "../contracts";
|
|
2
2
|
|
|
3
3
|
/** Platform message order only; event/edit IDs and local arrival times are not clocks. */
|
|
4
4
|
export function compareMessageIds(platform: Platform, left: string, right: string): -1 | 0 | 1 | null {
|
|
@@ -6,8 +6,8 @@ import { lstat, open, realpath } from "node:fs/promises";
|
|
|
6
6
|
import { dirname, isAbsolute, join, normalize } from "node:path";
|
|
7
7
|
import { resolveSessionLeafId, type SessionEntry } from "@oh-my-pi/pi-coding-agent/session/session-entries";
|
|
8
8
|
import { parseSessionContent } from "@oh-my-pi/pi-coding-agent/session/session-loader";
|
|
9
|
-
import type { Inbound, Lane } from "
|
|
10
|
-
import { parseLaneReportResult } from "
|
|
9
|
+
import type { Inbound, Lane } from "../contracts";
|
|
10
|
+
import { parseLaneReportResult } from "../lane/lane-report";
|
|
11
11
|
|
|
12
12
|
export interface TopicMatch {
|
|
13
13
|
readonly laneId: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { realpathSync, statSync } from "node:fs";
|
|
2
2
|
import { basename, isAbsolute } from "node:path";
|
|
3
|
-
import type { Lane } from "
|
|
3
|
+
import type { Lane } from "../contracts";
|
|
4
4
|
|
|
5
5
|
export const TOPIC_CHOICE_WAIT_MS = 5 * 60_000;
|
|
6
6
|
|
|
@@ -9,7 +9,9 @@ export function topicRequest(text: string) {
|
|
|
9
9
|
const request = text.replace(/^\s*\/new(?:\s+|$)/, "");
|
|
10
10
|
const header = /^cwd:[ \t]*([^\n]*)(?:\n|$)/i.exec(request.trimStart());
|
|
11
11
|
if (!header) return { text: request, cwd: null };
|
|
12
|
-
|
|
12
|
+
const path = header[1].trim();
|
|
13
|
+
const quoted = path.match(/^(["'])(\/.*)\1$/u);
|
|
14
|
+
return { text: request.trimStart().slice(header[0].length), cwd: quoted?.[2] ?? path };
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
/** Parse only the original Discord owner request body. An empty result asks for a task. */
|