omp-superagent 0.1.8 → 0.1.9
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 +6 -2
- package/README.ko.md +12 -9
- package/README.md +13 -9
- package/THIRD_PARTY_NOTICES.md +8 -8
- package/docs/OPERATIONS.md +62 -20
- package/docs/design/execution.md +79 -14
- package/docs/design/messaging.md +66 -15
- package/docs/releases/0.1.9.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/notices/darwin-arm64/Cargo-LICENSES.txt +2 -0
- package/host-owner/bin/notices/darwin-arm64/Cargo-SOURCES.txt +2 -0
- package/host-owner/bin/notices/darwin-arm64/crates/bitflags-2.13.2/LICENSE-APACHE +201 -0
- package/host-owner/bin/notices/darwin-arm64/crates/bitflags-2.13.2/LICENSE-MIT +25 -0
- package/host-owner/bin/notices/darwin-arm64/crates/rustix-1.1.6/COPYRIGHT +29 -0
- package/host-owner/bin/notices/darwin-arm64/crates/rustix-1.1.6/LICENSE-APACHE +201 -0
- package/host-owner/bin/notices/darwin-arm64/crates/rustix-1.1.6/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
- package/host-owner/bin/notices/darwin-arm64/crates/rustix-1.1.6/LICENSE-MIT +23 -0
- package/host-owner/bin/notices/darwin-x64/Cargo-LICENSES.txt +2 -0
- package/host-owner/bin/notices/darwin-x64/Cargo-SOURCES.txt +2 -0
- package/host-owner/bin/notices/darwin-x64/crates/bitflags-2.13.2/LICENSE-APACHE +201 -0
- package/host-owner/bin/notices/darwin-x64/crates/bitflags-2.13.2/LICENSE-MIT +25 -0
- package/host-owner/bin/notices/darwin-x64/crates/rustix-1.1.6/COPYRIGHT +29 -0
- package/host-owner/bin/notices/darwin-x64/crates/rustix-1.1.6/LICENSE-APACHE +201 -0
- package/host-owner/bin/notices/darwin-x64/crates/rustix-1.1.6/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
- package/host-owner/bin/notices/darwin-x64/crates/rustix-1.1.6/LICENSE-MIT +23 -0
- package/host-owner/bin/notices/linux-arm64/Cargo-LICENSES.txt +3 -0
- package/host-owner/bin/notices/linux-arm64/Cargo-SOURCES.txt +3 -0
- package/host-owner/bin/notices/linux-arm64/crates/bitflags-2.13.2/LICENSE-APACHE +201 -0
- package/host-owner/bin/notices/linux-arm64/crates/bitflags-2.13.2/LICENSE-MIT +25 -0
- package/host-owner/bin/notices/linux-arm64/crates/linux-raw-sys-0.12.1/COPYRIGHT +29 -0
- package/host-owner/bin/notices/linux-arm64/crates/linux-raw-sys-0.12.1/LICENSE-APACHE +201 -0
- package/host-owner/bin/notices/linux-arm64/crates/linux-raw-sys-0.12.1/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
- package/host-owner/bin/notices/linux-arm64/crates/linux-raw-sys-0.12.1/LICENSE-MIT +23 -0
- package/host-owner/bin/notices/linux-arm64/crates/rustix-1.1.6/COPYRIGHT +29 -0
- package/host-owner/bin/notices/linux-arm64/crates/rustix-1.1.6/LICENSE-APACHE +201 -0
- package/host-owner/bin/notices/linux-arm64/crates/rustix-1.1.6/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
- package/host-owner/bin/notices/linux-arm64/crates/rustix-1.1.6/LICENSE-MIT +23 -0
- package/host-owner/bin/notices/linux-x64/Cargo-LICENSES.txt +3 -0
- package/host-owner/bin/notices/linux-x64/Cargo-SOURCES.txt +3 -0
- package/host-owner/bin/notices/linux-x64/crates/bitflags-2.13.2/LICENSE-APACHE +201 -0
- package/host-owner/bin/notices/linux-x64/crates/bitflags-2.13.2/LICENSE-MIT +25 -0
- package/host-owner/bin/notices/linux-x64/crates/linux-raw-sys-0.12.1/COPYRIGHT +29 -0
- package/host-owner/bin/notices/linux-x64/crates/linux-raw-sys-0.12.1/LICENSE-APACHE +201 -0
- package/host-owner/bin/notices/linux-x64/crates/linux-raw-sys-0.12.1/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
- package/host-owner/bin/notices/linux-x64/crates/linux-raw-sys-0.12.1/LICENSE-MIT +23 -0
- package/host-owner/bin/notices/linux-x64/crates/rustix-1.1.6/COPYRIGHT +29 -0
- package/host-owner/bin/notices/linux-x64/crates/rustix-1.1.6/LICENSE-APACHE +201 -0
- package/host-owner/bin/notices/linux-x64/crates/rustix-1.1.6/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
- package/host-owner/bin/notices/linux-x64/crates/rustix-1.1.6/LICENSE-MIT +23 -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 -8
- package/skills/head/SKILL.md +3 -11
- package/skills/head/references/routing.md +23 -17
- package/skills/head/references/supervision.md +13 -1
- package/skills/lane/references/workflow.md +8 -8
- package/src/cli.ts +4 -4
- package/src/contracts.ts +71 -7
- package/src/discord-command-registration.ts +34 -186
- package/src/extension.ts +22 -2
- package/src/gateway-client.ts +11 -59
- package/src/gateway-protocol.ts +35 -1
- package/src/head-recovery.ts +226 -17
- package/src/host-extension.ts +82 -9
- package/src/host-protocol.ts +5 -9
- package/src/lane-models.ts +8 -0
- package/src/managed-ulw-probe.ts +22 -20
- package/src/messenger-command-catalog.json +6 -3
- package/src/messenger-commands.ts +9 -2
- package/src/operator.ts +77 -0
- package/src/pr-github-schema.ts +2 -0
- package/src/pr-intake-automation.ts +1 -2
- package/src/pr-intake-comment.ts +1 -2
- package/src/pr-intake-fix.ts +1 -2
- package/src/pr-intake-github.ts +1 -2
- package/src/pr-intake-material.ts +1 -2
- package/src/pr-intake-tree.ts +1 -2
- package/src/pr-review-models.ts +28 -0
- package/src/result-attachment.ts +60 -79
- package/src/runtime.ts +1461 -254
- package/src/setup-profiles.ts +26 -65
- package/src/slack-command-registration.ts +48 -197
- package/src/store.ts +265 -45
- package/src/superkit-skills.ts +22 -0
- package/src/telegram-command-languages.json +17 -0
- package/src/telegram-command-registration.ts +32 -134
- package/src/worker-bridge.ts +21 -0
- package/src/worker-enrollment.ts +2 -1
- package/src/worker-host.ts +0 -24
- package/src/worker-serve-prepare.ts +19 -0
- package/src/worker-service.ts +51 -47
- package/scripts/ci.ts +0 -44
- package/scripts/release.ts +0 -112
- package/scripts/test-omp.sh +0 -44
- package/src/discord-commands.ts +0 -29
- package/src/discord-markdown.ts +0 -399
- package/src/slack-commands.ts +0 -18
- package/src/telegram-signal.ts +0 -14
- package/src/worker-stdio.ts +0 -61
package/src/head-recovery.ts
CHANGED
|
@@ -9,6 +9,184 @@ export interface HeadQuotaFailure {
|
|
|
9
9
|
const object = (value: unknown): Record<string, unknown> =>
|
|
10
10
|
value !== null && typeof value === "object" ? value as Record<string, unknown> : {};
|
|
11
11
|
|
|
12
|
+
const codexFailureCode = /^Codex (?:error event|response failed)(?:: [\s\S]+)? \(code=([a-z_]+)(?:, status=[a-z_]+)?\)$/;
|
|
13
|
+
// AssistantMessage.errorId uses the SDK's public wire bits. Read them without
|
|
14
|
+
// requiring the installed CLI to expose a particular SDK error submodule.
|
|
15
|
+
const transientErrorBit = 0x0002_0000;
|
|
16
|
+
const usageLimitErrorBit = 0x0008_0000;
|
|
17
|
+
|
|
18
|
+
function googleQuotaError(message: string, status: unknown): boolean {
|
|
19
|
+
const http = /^(Google API|Cloud Code Assist API) error \((402|429)\)(?: resuming a long generation)?: /.exec(message);
|
|
20
|
+
const prefix = http ?? /^(?:Google API|Cloud Code Assist) stream error: /.exec(message);
|
|
21
|
+
if (!prefix || (http ? status !== Number(http[2]) : status !== undefined && status !== 429 && status !== 402)) return false;
|
|
22
|
+
// Cloud Code Assist HTTP preserves the whole response body. Google/Vertex HTTP
|
|
23
|
+
// and both streaming adapters can append a JSON.stringify'd RPC status suffix.
|
|
24
|
+
const detail = message.slice(prefix[0].length).trim();
|
|
25
|
+
const suffix = http?.[1] === "Cloud Code Assist API" ? -1 : detail.lastIndexOf(' {"error":{"status":');
|
|
26
|
+
if (!http && (suffix < 0 || !/(?: \(RESOURCE_EXHAUSTED\)|^RESOURCE_EXHAUSTED)$/.test(detail.slice(0, suffix)))) return false;
|
|
27
|
+
try {
|
|
28
|
+
const error = object(object(JSON.parse(detail.slice(suffix + 1))).error);
|
|
29
|
+
if (error.status !== "RESOURCE_EXHAUSTED" || !Array.isArray(error.details)
|
|
30
|
+
|| (suffix >= 0 && Object.keys(error).length !== 2)) return false;
|
|
31
|
+
const reasons = error.details.map(object).filter(part => part["@type"] === "type.googleapis.com/google.rpc.ErrorInfo");
|
|
32
|
+
return reasons.some(part => part.reason === "QUOTA_EXHAUSTED" || part.reason === "INSUFFICIENT_G1_CREDITS_BALANCE")
|
|
33
|
+
&& !reasons.some(part => part.reason === "MODEL_CAPACITY_EXHAUSTED" || part.reason === "MODEL_CAPACITY_EXCEEDED");
|
|
34
|
+
} catch (error) {
|
|
35
|
+
if (error instanceof SyntaxError) return false;
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Classify only the error metadata of an owned native prompt receipt or
|
|
42
|
+
* terminal assistant message. A bare HTTP status or SDK UsageLimit flag can
|
|
43
|
+
* also represent a throttle; neither is evidence of account quota exhaustion.
|
|
44
|
+
*/
|
|
45
|
+
export function laneQuotaExhausted(error: unknown): boolean {
|
|
46
|
+
const failure = object(error);
|
|
47
|
+
const assistant = failure.role === "assistant" && failure.stopReason === "error";
|
|
48
|
+
if (failure.role !== undefined && !assistant) return false;
|
|
49
|
+
const errorId = assistant && typeof failure.errorId === "number" ? failure.errorId : 0;
|
|
50
|
+
const transient = failure.retryable === true || (errorId & transientErrorBit) !== 0;
|
|
51
|
+
const detail = assistant ? failure.errorClassificationMessage ?? failure.errorMessage : failure.message;
|
|
52
|
+
// DashScope uses the same code and billing wording for a transient TPM/TPS cap.
|
|
53
|
+
const lower = typeof detail === "string" ? detail.toLowerCase() : "";
|
|
54
|
+
if (lower.includes("you exceeded your current quota, please check your plan and billing details")
|
|
55
|
+
&& lower.includes("error-code") && lower.includes("#token-limit")) return false;
|
|
56
|
+
const code = failure.code ?? failure.type;
|
|
57
|
+
if (code !== undefined) return !transient && (code === "usage_limit_reached" || code === "insufficient_quota");
|
|
58
|
+
if (typeof detail !== "string" || typeof failure.provider !== "string" || !failure.provider
|
|
59
|
+
|| (!assistant && typeof failure.retryable !== "boolean")) return false;
|
|
60
|
+
|
|
61
|
+
// Stock OMP 19.1.1 strips structured provider codes in RPC prompt errors.
|
|
62
|
+
// Its native formatters can still preserve one in a dedicated position.
|
|
63
|
+
const message = detail.replace(/ retry-after-ms=\d+$/, "");
|
|
64
|
+
const status = assistant ? failure.errorStatus : failure.httpStatus;
|
|
65
|
+
// The stock SDK can mark any ProviderHttpError 429 transient, even when
|
|
66
|
+
// its provider-specific machine code proves a persistent quota failure.
|
|
67
|
+
if (failure.provider === "cursor" && (failure.api === undefined || failure.api === "cursor-agent")) {
|
|
68
|
+
return status === 429 && /^Cursor USAGE_PRICING_REQUIRED: \S/.test(message);
|
|
69
|
+
}
|
|
70
|
+
const googleWire = failure.api === undefined
|
|
71
|
+
? ["google", "google-vertex", "google-antigravity", "google-gemini-cli"].includes(failure.provider)
|
|
72
|
+
: failure.api === "google-generative-ai" || failure.api === "google-vertex" || failure.api === "google-gemini-cli";
|
|
73
|
+
if (googleWire) return googleQuotaError(message, status);
|
|
74
|
+
if (failure.provider === "openai-codex" || failure.api === "openai-codex-responses") {
|
|
75
|
+
if (transient) return false;
|
|
76
|
+
const nativeCode = codexFailureCode.exec(message)?.[1];
|
|
77
|
+
if (nativeCode !== undefined) return nativeCode === "usage_limit_reached" || nativeCode === "insufficient_quota";
|
|
78
|
+
// Codex's HTTP adapter uses the same friendly text for usage_not_included.
|
|
79
|
+
// The stock SDK marks that HTTP 429 transient, while usage_limit_reached
|
|
80
|
+
// is non-transient. Require the native classification, not the phrase alone.
|
|
81
|
+
return status === 429 && (!assistant || (errorId & usageLimitErrorBit) !== 0)
|
|
82
|
+
&& /^You have hit your ChatGPT usage limit(?: \([a-z0-9_-]+ plan\))?\.(?: Try again in ~\d+ min\.)?$/.test(message);
|
|
83
|
+
}
|
|
84
|
+
const openAiApi = failure.api === "openai-responses" || failure.api === "azure-openai-responses"
|
|
85
|
+
|| failure.api === "openai-completions";
|
|
86
|
+
if (failure.api !== undefined && !openAiApi) return false;
|
|
87
|
+
const knownOpenAiWire = openAiApi || ["openai", "openai-api", "azure"].includes(failure.provider);
|
|
88
|
+
// Responses-API event and failed-response errors prefix the machine code.
|
|
89
|
+
if (knownOpenAiWire && !transient && /^(?:Error Code )?insufficient_quota: [\s\S]+$/.test(message)) return true;
|
|
90
|
+
// The captured HTTP formatter renders type, param and code in order but
|
|
91
|
+
// re-labels after omitting null fields. A lone param is not a machine code.
|
|
92
|
+
const http = /^(402|429) [\s\S]+ \(type=([a-z_]+)(?: param=([\w.-]+)(?: code=([\w.-]+))?)?\)$/.exec(message);
|
|
93
|
+
if (!http || (status === undefined ? !knownOpenAiWire : status !== Number(http[1]))
|
|
94
|
+
|| (transient && status !== 429)) return false;
|
|
95
|
+
const [, , type, param, httpCode] = http;
|
|
96
|
+
// Stock SDK text classification adds Transient for the literal status prefix
|
|
97
|
+
// "429", even on HTTP billing caps. Override it only with the captured code
|
|
98
|
+
// or corroborating type and relabeled code, never the status or a lone type.
|
|
99
|
+
return httpCode === "insufficient_quota" || (httpCode === undefined && type === "insufficient_quota"
|
|
100
|
+
&& (param === "insufficient_quota" || (param === undefined && knownOpenAiWire && !transient)));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function sessionExitWithoutPendingTools(entry: Record<string, unknown>): boolean {
|
|
104
|
+
if (entry.type !== "custom" || entry.customType !== "session_exit") return false;
|
|
105
|
+
const { reason, kind, pendingToolCalls } = object(entry.data);
|
|
106
|
+
return typeof reason === "string" && (kind === "normal" || kind === "signal" || kind === "fatal" || kind === "process_exit")
|
|
107
|
+
&& (pendingToolCalls === undefined || (Array.isArray(pendingToolCalls) && pendingToolCalls.length === 0));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Recover one settled prompt from the journal suffix after its authenticated cursor. */
|
|
111
|
+
export function settledLaneReceipt(entries: unknown[], owner: {
|
|
112
|
+
readonly sessionId: string; readonly sessionFile: string; readonly requestId: string; readonly hostPid: number;
|
|
113
|
+
}): { frame: Record<string, unknown>; assistant?: Record<string, unknown> } | null {
|
|
114
|
+
if (!Number.isSafeInteger(owner.hostPid) || owner.hostPid <= 0) return null;
|
|
115
|
+
const owned = (data: Record<string, unknown>) => data.hostPid === owner.hostPid
|
|
116
|
+
&& data.sessionId === owner.sessionId && data.sessionFile === owner.sessionFile;
|
|
117
|
+
let start: Record<string, unknown> | undefined;
|
|
118
|
+
let frame: Record<string, unknown> | undefined;
|
|
119
|
+
let assistant: Record<string, unknown> | undefined;
|
|
120
|
+
let userSeen = false;
|
|
121
|
+
for (const value of entries) {
|
|
122
|
+
const entry = object(value);
|
|
123
|
+
if (typeof entry.id !== "string" || typeof entry.type !== "string") return null;
|
|
124
|
+
if (frame) {
|
|
125
|
+
if (entry.type === "model_usage" || sessionExitWithoutPendingTools(entry)) continue;
|
|
126
|
+
// A later run, user/assistant, tool, or unknown effect prevents recovery.
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
if (entry.type === "custom" && entry.customType === "rpc_agent_start") {
|
|
130
|
+
const data = object(entry.data);
|
|
131
|
+
if (start || !owned(data) || typeof data.instanceKey !== "string" || !data.instanceKey
|
|
132
|
+
|| typeof data.runOrdinal !== "number" || !Number.isSafeInteger(data.runOrdinal) || data.runOrdinal <= 0) return null;
|
|
133
|
+
start = data;
|
|
134
|
+
} else if (entry.type === "custom" && entry.customType === "rpc_prompt_result") {
|
|
135
|
+
const data = object(entry.data);
|
|
136
|
+
const receipt = object(data.frame);
|
|
137
|
+
if (!start || !userSeen || !owned(data) || data.instanceKey !== start.instanceKey
|
|
138
|
+
|| data.runOrdinal !== start.runOrdinal || receipt.id !== owner.requestId || receipt.sessionSettled !== true
|
|
139
|
+
|| receipt.agentInvoked !== true) return null;
|
|
140
|
+
frame = receipt;
|
|
141
|
+
} else if (entry.type === "custom" && entry.customType === "tool_execution_start" && (!start || !userSeen)) {
|
|
142
|
+
return null;
|
|
143
|
+
} else if (entry.type === "message") {
|
|
144
|
+
const message = object(entry.message);
|
|
145
|
+
if (message.role === "user") {
|
|
146
|
+
if (userSeen) return null;
|
|
147
|
+
userSeen = true;
|
|
148
|
+
} else if (message.role === "assistant") {
|
|
149
|
+
if (!start || !userSeen) return null;
|
|
150
|
+
assistant = message;
|
|
151
|
+
} else if (message.role === "toolResult" && (!start || !userSeen)) return null;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (!frame) return null;
|
|
155
|
+
switch (frame.status) {
|
|
156
|
+
case "completed":
|
|
157
|
+
return assistant?.stopReason === "stop" || assistant?.stopReason === "length" ? { frame, assistant } : null;
|
|
158
|
+
case "aborted":
|
|
159
|
+
if (assistant?.stopReason === "aborted") return { frame, assistant };
|
|
160
|
+
// An owned abort can settle before the provider replies or while tools run.
|
|
161
|
+
return !assistant || assistant.stopReason === "toolUse" ? { frame } : null;
|
|
162
|
+
case "error":
|
|
163
|
+
return assistant?.stopReason === "error" ? { frame, assistant } : { frame };
|
|
164
|
+
default:
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Stock Usage.server counts provider-side tool requests, independently of
|
|
170
|
+
// whether the provider retained a tool block in the journal.
|
|
171
|
+
function usedServerTools(usage: unknown): boolean {
|
|
172
|
+
return Object.values(object(object(usage).server)).some(count => typeof count === "number" && count > 0);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Opaque provider history can contain effects outside content. In content
|
|
176
|
+
// allow only passive blocks, not tools, images, or unknown future variants.
|
|
177
|
+
function passiveAssistantOutput({ content, providerPayload, usage }: Record<string, unknown>): boolean {
|
|
178
|
+
return providerPayload === undefined && !usedServerTools(usage) && Array.isArray(content) && content.every(part => {
|
|
179
|
+
const block = object(part);
|
|
180
|
+
switch (block.type) {
|
|
181
|
+
case "text": return typeof block.text === "string";
|
|
182
|
+
case "thinking": return typeof block.thinking === "string";
|
|
183
|
+
case "redactedThinking": return typeof block.data === "string";
|
|
184
|
+
case "fallback": return typeof object(block.from).model === "string" && typeof object(block.to).model === "string";
|
|
185
|
+
default: return false;
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
12
190
|
/** Only journal identities and native outcome fields leave this evidence reader. */
|
|
13
191
|
export function headRecoveryEvidence(entries: unknown[], owner: Pick<HeadRecoveryAttempt,
|
|
14
192
|
"sessionId" | "sessionFile" | "requestId" | "cursor">, boundary?: string) {
|
|
@@ -52,43 +230,74 @@ export function headRecoveryEvidence(entries: unknown[], owner: Pick<HeadRecover
|
|
|
52
230
|
const error = object(frame.error);
|
|
53
231
|
const failedAt = typeof receipt.timestamp === "string" ? Date.parse(receipt.timestamp) : NaN;
|
|
54
232
|
const receiptIndex = slice.indexOf(receipt);
|
|
55
|
-
const
|
|
233
|
+
const sameRun = typeof receiptData.hostPid === "number" && Number.isSafeInteger(receiptData.hostPid)
|
|
56
234
|
&& receiptData.hostPid > 0 && typeof receiptData.instanceKey === "string" && receiptData.instanceKey !== ""
|
|
57
235
|
&& typeof receiptData.runOrdinal === "number" && Number.isSafeInteger(receiptData.runOrdinal) && receiptData.runOrdinal > 0
|
|
58
236
|
&& receiptData.hostPid === startData.hostPid && receiptData.instanceKey === startData.instanceKey
|
|
59
237
|
&& receiptData.runOrdinal === startData.runOrdinal;
|
|
60
|
-
// The exact
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
&&
|
|
65
|
-
// Stock OMP's RPC error lacks a structured quota code. Match either
|
|
66
|
-
// native Codex formatter, but require the exact code in its metadata.
|
|
67
|
-
&& /^Codex (?:error event|response failed)(?:: [\s\S]+)? \(code=usage_limit_reached(?:, status=[a-z_]+)?\)$/.test(error.message)
|
|
68
|
-
&& Number.isFinite(failedAt) && sameQuotaRun && latestRunStatus === "error"
|
|
69
|
-
&& users.length === 1 && receiptIndex > latestStartIndex
|
|
238
|
+
// The exact settled run failed before any tool started: only its prompt,
|
|
239
|
+
// passive failed model/refusal output and usage records exist. An earlier
|
|
240
|
+
// tool, another request or unknown journal entry leaves effects unproven.
|
|
241
|
+
const settledToolFreeError = frame.status === "error" && frame.sessionSettled === true && frame.agentInvoked === true
|
|
242
|
+
&& sameRun && users.length === 1 && receiptIndex > latestStartIndex
|
|
70
243
|
&& slice.every((entry, index) => {
|
|
71
|
-
if (entry.
|
|
72
|
-
if (
|
|
244
|
+
if (typeof entry.id !== "string") return false;
|
|
245
|
+
if (entry.type === "model_usage") return !usedServerTools(entry.usage);
|
|
246
|
+
if (entry === receipt) return true;
|
|
247
|
+
// These stock restart records don't start work. Arbitrary custom
|
|
248
|
+
// messages can trigger another turn; unknown custom entries prove nothing.
|
|
249
|
+
if (index > receiptIndex) {
|
|
250
|
+
if (entry.type === "custom_message" && entry.customType === "eval-state-context") return typeof entry.content === "string";
|
|
251
|
+
return sessionExitWithoutPendingTools(entry) && typeof object(entry.data).recordedAt === "string";
|
|
252
|
+
}
|
|
73
253
|
if (matches(entry, "rpc_agent_start")) {
|
|
74
254
|
const start = object(entry.data);
|
|
75
255
|
return start.hostPid === receiptData.hostPid && start.instanceKey === receiptData.instanceKey
|
|
76
256
|
&& typeof start.runOrdinal === "number" && Number.isSafeInteger(start.runOrdinal)
|
|
77
257
|
&& start.runOrdinal > 0 && start.runOrdinal <= Number(receiptData.runOrdinal);
|
|
78
258
|
}
|
|
259
|
+
if (entry.type === "custom" && entry.customType === "provider_refusal") {
|
|
260
|
+
const refusal = object(entry.data);
|
|
261
|
+
return (refusal.stopType === "refusal" || refusal.stopType === "sensitive") && passiveAssistantOutput(refusal);
|
|
262
|
+
}
|
|
263
|
+
if (entry.type !== "message") return false;
|
|
264
|
+
const message = object(entry.message);
|
|
265
|
+
return message.role === "user" || message.role === "assistant" && message.stopReason === "error" && passiveAssistantOutput(message);
|
|
266
|
+
});
|
|
267
|
+
const quotaLikeText = (value: unknown): boolean => typeof value === "string"
|
|
268
|
+
&& /(?:usage_limit_reached|insufficient_quota|quota_exceeded|usage_limit|usage limit|quota)/i.test(value);
|
|
269
|
+
const quotaLikeFailure = laneQuotaExhausted(error) || quotaLikeText(error.message) || quotaLikeText(error.code) || quotaLikeText(error.type)
|
|
270
|
+
|| slice.some(entry => {
|
|
79
271
|
if (entry.type !== "message") return false;
|
|
80
272
|
const message = object(entry.message);
|
|
81
|
-
return message.role === "
|
|
82
|
-
&& message
|
|
83
|
-
|
|
273
|
+
return message.role === "assistant"
|
|
274
|
+
&& (laneQuotaExhausted(message) || quotaLikeText(message.errorMessage) || quotaLikeText(message.error));
|
|
275
|
+
});
|
|
276
|
+
// The exact provider refused the entire turn for quota. A partial answer or
|
|
277
|
+
// another provider's reply makes it something other than a quota hold.
|
|
278
|
+
const quotaFailure: HeadQuotaFailure | null = settledToolFreeError
|
|
279
|
+
&& error.provider === "openai-codex" && typeof error.model === "string" && error.model !== ""
|
|
280
|
+
&& error.retryable === false && typeof error.message === "string"
|
|
281
|
+
// Stock OMP's RPC error lacks a structured quota code. Match either
|
|
282
|
+
// native Codex formatter, but require the exact code in its metadata.
|
|
283
|
+
&& codexFailureCode.exec(error.message)?.[1] === "usage_limit_reached"
|
|
284
|
+
&& Number.isFinite(failedAt) && latestRunStatus === "error"
|
|
285
|
+
&& slice.slice(receiptIndex + 1).every(entry => entry.type === "model_usage")
|
|
286
|
+
&& slice.every(entry => {
|
|
287
|
+
if (entry.type === "custom") return entry.customType !== "provider_refusal";
|
|
288
|
+
const message = object(entry.message);
|
|
289
|
+
return entry.type !== "message" || message.role !== "assistant" || message.provider === error.provider
|
|
290
|
+
&& message.model === error.model && Array.isArray(message.content) && message.content.length === 0;
|
|
84
291
|
})
|
|
85
292
|
? { failedAt, model: { provider: error.provider, id: error.model } } : null;
|
|
293
|
+
// Quota-like refusals stay held unless native quota recovery proves safe release.
|
|
294
|
+
const toolFreeFailure = settledToolFreeError && !quotaFailure && !quotaLikeFailure;
|
|
86
295
|
const selected = [receipt, ...starts, ...assistants];
|
|
87
296
|
if (selected.some(entry => typeof entry.id !== "string")) return null;
|
|
88
297
|
const entryIds = [...new Set(selected.map(entry => String(entry.id)))];
|
|
89
298
|
const proof = { entryIds, receiptStatus: String(frame.status), latestRunStatus: latestRunStatus ?? null,
|
|
90
299
|
outcome: outcome ?? null };
|
|
91
|
-
return { ...proof, quotaFailure, boundary: String(journal[end]!.id),
|
|
300
|
+
return { ...proof, settledToolFreeError, toolFreeFailure, quotaFailure, boundary: String(journal[end]!.id),
|
|
92
301
|
fingerprint: createHash("sha256").update(JSON.stringify(slice.map(entry => [
|
|
93
302
|
entry.id, entry.type, entry.customType,
|
|
94
303
|
matches(entry, "rpc_prompt_result") ? object(entry.data).frame : null,
|
package/src/host-extension.ts
CHANGED
|
@@ -8,10 +8,10 @@ import type { UnitScope } from "@oh-my-pi/pi-coding-agent/daemon/protocol";
|
|
|
8
8
|
import { cfgDefaultThinkingLevel } from "@oh-my-pi/pi-coding-agent/session/settings";
|
|
9
9
|
import { Settings } from "@oh-my-pi/pi-coding-agent/config/settings";
|
|
10
10
|
import { lookup as lookupSetting } from "@oh-my-pi/pi-coding-agent/config/registry";
|
|
11
|
-
import { pickDefaultAvailableModel, resolveModelRoleValue } from "@oh-my-pi/pi-coding-agent/config/model-resolver";
|
|
11
|
+
import { formatModelStringWithRouting, pickDefaultAvailableModel, resolveModelRoleValue } from "@oh-my-pi/pi-coding-agent/config/model-resolver";
|
|
12
12
|
import { resolveThinkingLevelForModel } from "@oh-my-pi/pi-tui/thinking";
|
|
13
13
|
import { parseSessionEntries, readSessionHeaderId } from "@oh-my-pi/pi-coding-agent/session/session-loader";
|
|
14
|
-
import { HostChannel, PR_REVIEW_GITHUB_ENV, PR_REVIEW_SYSTEM_PROMPT, indexServiceCompletions, serviceGenerationKey, type Frame, type ServiceUnit } from "./host-protocol";
|
|
14
|
+
import { HostChannel, LANE_MODEL_PROMOTION_RECEIPT, PR_REVIEW_GITHUB_ENV, PR_REVIEW_SYSTEM_PROMPT, indexServiceCompletions, serviceGenerationKey, type Frame, type ServiceUnit } from "./host-protocol";
|
|
15
15
|
import { USER_INTERRUPT_LABEL } from "@oh-my-pi/pi-coding-agent/session/messages";
|
|
16
16
|
import { MAX_RPC_REASSEMBLED_BYTES } from "@oh-my-pi/pi-coding-agent/modes/rpc/rpc-frame";
|
|
17
17
|
import { fitAbortAndRestoreQueueResponse } from "@oh-my-pi/pi-coding-agent/modes/rpc/rpc-mode";
|
|
@@ -21,6 +21,7 @@ import { toolWireSchema } from "@oh-my-pi/pi-ai/utils/schema";
|
|
|
21
21
|
import type { LanePresetSnapshot } from "./contracts";
|
|
22
22
|
import { MANAGED_ULW_ENV } from "./managed-ulw";
|
|
23
23
|
import { verifyHostSuperkit } from "./host-superkit";
|
|
24
|
+
import { isPrReviewInferenceModel, prReviewModelChoices } from "./pr-review-models";
|
|
24
25
|
import { HEAD_ROTATION_GUARD, HEAD_ROTATION_PROBE, type RotationGuardEvent,
|
|
25
26
|
type RotationNative, type RotationProbeEvent } from "./head-rotation";
|
|
26
27
|
|
|
@@ -33,8 +34,6 @@ const serviceOwner = ({ agent, sessionManager }: ExtensionContext) => {
|
|
|
33
34
|
return agent.kind === "sub" && agent.id === "advisor" ? `${id}-advisor` : id;
|
|
34
35
|
};
|
|
35
36
|
|
|
36
|
-
const reviewInferenceApis = new Set(["openai-completions", "openai-responses", "openai-codex-responses",
|
|
37
|
-
"azure-openai-responses", "anthropic-messages"]);
|
|
38
37
|
const stockAutoresearchTools = ["init_experiment", "run_experiment", "log_experiment", "update_notes"] as const;
|
|
39
38
|
// --no-tools can still leave builtins in the registration catalogue: write
|
|
40
39
|
// on stock 19.0, resolution/QA devices on 19.1. None may be enabled, mounted,
|
|
@@ -47,8 +46,6 @@ const reviewSettingValues = {
|
|
|
47
46
|
"prewalk.auto": "off", "spotlight.experiment.enabled": false, "providers.cacheWarming": "off", "telemetry.otlpExportEnabled": false,
|
|
48
47
|
"dev.autoqa": false,
|
|
49
48
|
} as const;
|
|
50
|
-
const reviewModelAllowed = (model: { api: string; provider: string; transport?: unknown } | undefined) =>
|
|
51
|
-
model !== undefined && reviewInferenceApis.has(model.api) && model.provider !== "gitlab-duo" && model.transport !== "pi-native";
|
|
52
49
|
class ReviewIsolationError extends Error {}
|
|
53
50
|
|
|
54
51
|
/** Match the running CLI's own RPC settlement predicate (old and new SDK surface). */
|
|
@@ -100,6 +97,25 @@ export default function hostExtension(pi: ExtensionAPI): void {
|
|
|
100
97
|
if (!(root instanceof pi.pi.AgentSession)) throw new Error("Native root session is unavailable");
|
|
101
98
|
return root;
|
|
102
99
|
};
|
|
100
|
+
const flushLaneModel = (session: ReturnType<typeof rootSession>, previousLeaf: string | null, promoting: boolean) => {
|
|
101
|
+
const journal = session.sessionManager;
|
|
102
|
+
const model = session.model;
|
|
103
|
+
const branch = journal.getBranch();
|
|
104
|
+
const previousIndex = previousLeaf === null ? -1 : branch.findIndex(entry => entry.id === previousLeaf);
|
|
105
|
+
const modelIndex = branch.findLastIndex(entry => entry.type === "model_change" && (entry.role ?? "default") === "default");
|
|
106
|
+
const change = branch[modelIndex];
|
|
107
|
+
if (!model || (previousLeaf !== null && previousIndex === -1) || modelIndex <= previousIndex
|
|
108
|
+
|| change?.type !== "model_change" || change.resolvedModelIsFallback === true
|
|
109
|
+
|| change.model !== formatModelStringWithRouting(model))
|
|
110
|
+
throw new Error("Lane model journal selection could not be confirmed");
|
|
111
|
+
if (promoting) {
|
|
112
|
+
// The stock selector may flatten distinct provider/ID pairs.
|
|
113
|
+
journal.appendCustomEntry(LANE_MODEL_PROMOTION_RECEIPT, {
|
|
114
|
+
entryId: change.id, selector: change.model, model: { provider: model.provider, id: model.id },
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
journal.flushSync();
|
|
118
|
+
};
|
|
103
119
|
const serviceObservation = (data: Frame) => {
|
|
104
120
|
const root = rootSession();
|
|
105
121
|
root.sessionManager.appendCustomEntry("superagent_service_generation", {
|
|
@@ -171,7 +187,7 @@ export default function hostExtension(pi: ExtensionAPI): void {
|
|
|
171
187
|
let reviewStream: NativeSession["agent"]["streamFn"] | undefined;
|
|
172
188
|
const reviewPolicy = (session: NativeSession, cwd: string) => {
|
|
173
189
|
const model = session.model;
|
|
174
|
-
if (!
|
|
190
|
+
if (!model || !isPrReviewInferenceModel(model))
|
|
175
191
|
throw new ReviewIsolationError("Static PR review requires a known tool-less inference API, not an external agent harness");
|
|
176
192
|
if (workerAttempt || realpathSync(session.sessionManager.getCwd()) !== cwd)
|
|
177
193
|
throw new ReviewIsolationError("Static PR review workspace identity is unavailable");
|
|
@@ -224,12 +240,12 @@ export default function hostExtension(pi: ExtensionAPI): void {
|
|
|
224
240
|
reviewPolicy(session, cwd);
|
|
225
241
|
// The actual candidate can differ from the selection on provider retry.
|
|
226
242
|
// Reject it before native dispatch, rather than trusting provider naming.
|
|
227
|
-
if (!
|
|
243
|
+
if (!isPrReviewInferenceModel(model) || input.tools?.length || input.inactiveTools?.length)
|
|
228
244
|
throw new Error("Static PR review refused a tool-capable provider request");
|
|
229
245
|
const checkedPayload: NonNullable<NonNullable<typeof options>["onPayload"]> = async (payload, current, signal) => {
|
|
230
246
|
const replacement = await options?.onPayload?.(payload, current, signal);
|
|
231
247
|
const outgoing = replacement ?? payload;
|
|
232
|
-
if (!
|
|
248
|
+
if (!isPrReviewInferenceModel(current ?? model) || !outgoing || typeof outgoing !== "object"
|
|
233
249
|
|| ["tools", "functions", "mcp_servers"].some(key => {
|
|
234
250
|
const value = Object.getOwnPropertyDescriptor(outgoing, key)?.value;
|
|
235
251
|
return value !== undefined && (!Array.isArray(value) || value.length !== 0);
|
|
@@ -573,6 +589,63 @@ export default function hostExtension(pi: ExtensionAPI): void {
|
|
|
573
589
|
...(typeof ownership.identity.session.configuredThinkingLevel === "function"
|
|
574
590
|
? { configuredThinkingLevel: ownership.identity.session.configuredThinkingLevel() ?? null } : {}) };
|
|
575
591
|
}
|
|
592
|
+
if (command.type === "set_lane_model") {
|
|
593
|
+
if (reviewCwd || process.env.OMP_SUPERAGENT_ROLE !== "lane")
|
|
594
|
+
throw new Error("An ordinary managed lane Host is required");
|
|
595
|
+
if (!localIdle()) throw new Error("session_busy");
|
|
596
|
+
const ownership = await owned(true);
|
|
597
|
+
const { session, ref, id, file } = ownership.identity;
|
|
598
|
+
if (ownership.unknown || ownership.busy) throw new Error("session_busy");
|
|
599
|
+
// Use the current native catalogue and configured credential source,
|
|
600
|
+
// without resolving a key, refreshing discovery, or probing inference.
|
|
601
|
+
const candidates = session.getAvailableModels().filter(model =>
|
|
602
|
+
model.provider === command.provider && model.id === command.modelId);
|
|
603
|
+
const [model] = candidates;
|
|
604
|
+
if (candidates.length !== 1 || !model || (model.kind !== undefined && model.kind !== "chat")
|
|
605
|
+
|| !session.modelRegistry.hasConfiguredAuth(model))
|
|
606
|
+
throw new Error("An available exact chat model with configured auth is required");
|
|
607
|
+
const previousLeaf = session.sessionManager.getLeafId();
|
|
608
|
+
const before = exact();
|
|
609
|
+
// No await after the final native guard until the stock setter starts.
|
|
610
|
+
if (!file || before.ref !== ref || before.session !== session || before.id !== id || before.file !== file
|
|
611
|
+
|| !localIdle()) throw new Error("session_busy");
|
|
612
|
+
const prior = session.model;
|
|
613
|
+
const promoting = prior?.provider === model.provider && prior.id === model.id;
|
|
614
|
+
mutationHeld = true;
|
|
615
|
+
await session.setModel(model);
|
|
616
|
+
const after = exact();
|
|
617
|
+
const actual = session.model;
|
|
618
|
+
if (after.ref !== ref || after.session !== session || after.id !== id || after.file !== file
|
|
619
|
+
|| actual?.provider !== model.provider || actual.id !== model.id)
|
|
620
|
+
throw new Error("Lane model selection could not be confirmed");
|
|
621
|
+
flushLaneModel(session, previousLeaf, promoting);
|
|
622
|
+
mutationHeld = false;
|
|
623
|
+
return { provider: actual.provider, id: actual.id };
|
|
624
|
+
}
|
|
625
|
+
if (command.type === "set_pr_review_model") {
|
|
626
|
+
if (!reviewCwd || !localIdle()) throw new ReviewIsolationError("Static PR review model selection requires an idle owned review session");
|
|
627
|
+
const ownership = await owned(true);
|
|
628
|
+
const { session, ref } = ownership.identity;
|
|
629
|
+
const previous = session.model;
|
|
630
|
+
if (ownership.unknown || ownership.busy || !localIdle() || exact().ref !== ref
|
|
631
|
+
|| !previous || previous.provider !== command.previousProvider || previous.id !== command.previousModelId) {
|
|
632
|
+
throw new ReviewIsolationError("The previous static PR review model or ownership no longer matches");
|
|
633
|
+
}
|
|
634
|
+
reviewPolicy(session, reviewCwd);
|
|
635
|
+
const model = prReviewModelChoices(session.getAvailableModels()).find(model =>
|
|
636
|
+
model.provider === command.provider && model.id === command.modelId);
|
|
637
|
+
if (!model)
|
|
638
|
+
throw new ReviewIsolationError("Static PR review requires an available exact tool-less inference model");
|
|
639
|
+
const previousLeaf = session.sessionManager.getLeafId();
|
|
640
|
+
mutationHeld = true;
|
|
641
|
+
await session.setModel(model);
|
|
642
|
+
reviewPolicy(session, reviewCwd);
|
|
643
|
+
if (exact().ref !== ref || session.model?.provider !== model.provider || session.model?.id !== model.id)
|
|
644
|
+
throw new ReviewIsolationError("The static PR review model selection could not be confirmed");
|
|
645
|
+
flushLaneModel(session, previousLeaf, previous.provider === model.provider && previous.id === model.id);
|
|
646
|
+
mutationHeld = false;
|
|
647
|
+
return { provider: model.provider, id: model.id };
|
|
648
|
+
}
|
|
576
649
|
if (command.type === "set_model_preset") {
|
|
577
650
|
if (!localIdle()) throw new Error("Native session is busy or has an unresolved mutation");
|
|
578
651
|
const ownership = await owned(true);
|
package/src/host-protocol.ts
CHANGED
|
@@ -15,6 +15,7 @@ export const PR_REVIEW_SYSTEM_PROMPT = [
|
|
|
15
15
|
'Otherwise use {"verdict":"blocked","summary":"findings or missing evidence"}.',
|
|
16
16
|
].join("\n");
|
|
17
17
|
export const PR_REVIEW_GITHUB_ENV = ["GH_TOKEN", "GITHUB_TOKEN", "GH_ENTERPRISE_TOKEN", "GITHUB_ENTERPRISE_TOKEN"] as const;
|
|
18
|
+
export const LANE_MODEL_PROMOTION_RECEIPT = "superagent_lane_model_promotion";
|
|
18
19
|
|
|
19
20
|
/** Private adapter observations, not additions to the stock RPC protocol. */
|
|
20
21
|
export type HostState = RpcSessionState & {
|
|
@@ -37,7 +38,10 @@ export type ServiceUnit = Pick<UnitSnapshot, "id" | "key" | "owner" |
|
|
|
37
38
|
};
|
|
38
39
|
export type Response = Frame & { success: boolean; data?: unknown; error?: string };
|
|
39
40
|
export type HostResponse = RpcResponse | {
|
|
40
|
-
type: "response"; id?: string; command: "shutdown_host" | "set_model_preset" | "get_host_admission"; success: true; data: Frame;
|
|
41
|
+
type: "response"; id?: string; command: "shutdown_host" | "set_model_preset" | "set_pr_review_model" | "get_host_admission"; success: true; data: Frame;
|
|
42
|
+
} | {
|
|
43
|
+
type: "response"; id?: string; command: "set_lane_model"; success: true;
|
|
44
|
+
data: { readonly provider: string; readonly id: string };
|
|
41
45
|
} | {
|
|
42
46
|
type: "response"; id?: string; command: "set_host_message_updates"; success: true;
|
|
43
47
|
data: { readonly messageUpdates: "full" | "activity-v1" };
|
|
@@ -74,14 +78,6 @@ function serviceExitKey({ owner, id, generation, startedAt, restartCount, exited
|
|
|
74
78
|
return JSON.stringify([owner, id, generation, String(startedAt), String(restartCount), String(exitedAt)]);
|
|
75
79
|
}
|
|
76
80
|
|
|
77
|
-
/** Positive native journal evidence for this exact terminal service generation. */
|
|
78
|
-
export function serviceCompletionRecorded(daemon: Frame, entries: readonly unknown[]): boolean {
|
|
79
|
-
const key = serviceExitKey(daemon);
|
|
80
|
-
if (key === undefined || !hasValidGeneration(daemon) || !isTerminal(String(daemon.state))) return false;
|
|
81
|
-
return entries.some(entry => launchCompletions(entry)?.some(observed => isFrame(observed)
|
|
82
|
-
&& observed.state === daemon.state && serviceExitKey(observed) === key));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
81
|
/** Builds proof for the current observation only, from one native transcript. */
|
|
86
82
|
export function indexServiceCompletions(entries: readonly unknown[]) {
|
|
87
83
|
const byGeneration = new Set<string>();
|
package/src/lane-models.ts
CHANGED
|
@@ -21,6 +21,14 @@ export function isLaneModel(value: unknown): value is LaneModel {
|
|
|
21
21
|
typeof model.id === "string" && !!model.id.trim() && !model.id.includes("\0");
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
// Match worker_rpc::model_id: Rust char::is_whitespace / char::is_control.
|
|
25
|
+
const invalidRestrictedSelector = /[\p{White_Space}\p{Cc}]/u;
|
|
26
|
+
|
|
27
|
+
/** The narrow exact-selector wire used by remote workers and static PR Hosts. */
|
|
28
|
+
export function acceptsRestrictedModelSelector(model: LaneModel): boolean {
|
|
29
|
+
return !!model.provider && !!model.id && !invalidRestrictedSelector.test(model.provider) && !invalidRestrictedSelector.test(model.id);
|
|
30
|
+
}
|
|
31
|
+
|
|
24
32
|
/** Project native catalog facts only: endpoints, headers, credentials and opaque internals never leave here. */
|
|
25
33
|
export function codingModels(value: unknown): LaneModelCandidate[] {
|
|
26
34
|
if (!Array.isArray(value)) throw new Error("Native available-model response is missing its model list");
|
package/src/managed-ulw-probe.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Finite native prompt-composition gate, not a model turn or workflow execution.
|
|
2
2
|
import assert from "node:assert/strict";
|
|
3
3
|
import { mkdir, readFile, realpath } from "node:fs/promises";
|
|
4
|
-
import { dirname, join, resolve } from "node:path";
|
|
4
|
+
import { dirname, join, resolve, sep } from "node:path";
|
|
5
5
|
import { getBundledModel, getBundledProviders } from "@oh-my-pi/pi-catalog";
|
|
6
6
|
import { ModelRegistry, Settings, AuthStorage, SessionManager, createAgentSession } from "@oh-my-pi/pi-coding-agent";
|
|
7
7
|
import { ExtensionRunner } from "@oh-my-pi/pi-coding-agent/extensibility/extensions/runner";
|
|
@@ -10,6 +10,7 @@ import { buildAvailableSlashCommands } from "@oh-my-pi/pi-coding-agent/slash-com
|
|
|
10
10
|
import { buildSystemPrompt } from "@oh-my-pi/pi-coding-agent/system-prompt";
|
|
11
11
|
import { WORKFLOW_NAMES } from "./contracts";
|
|
12
12
|
import { readManagedUlwPackage } from "./managed-ulw";
|
|
13
|
+
import { canonicalSuperkitSkills, hasCanonicalSuperkitSkills, legacySuperkitSkills, superkitWorkflows as workflows } from "./superkit-skills";
|
|
13
14
|
import { advertisedWorkflow } from "./workflow";
|
|
14
15
|
|
|
15
16
|
const packageArg = process.argv[2];
|
|
@@ -23,18 +24,13 @@ let networkAttempts = 0;
|
|
|
23
24
|
const refuseNetwork = () => { networkAttempts++; throw new Error("Managed Superkit probe forbids network and provider calls"); };
|
|
24
25
|
globalThis.fetch = Object.assign(async () => refuseNetwork(), { preconnect: refuseNetwork });
|
|
25
26
|
|
|
26
|
-
// Public command names changed; installed skill IDs (also legacy commands,
|
|
27
|
-
// except ultrawork) and the prompt/journal protocol did not.
|
|
28
|
-
const workflows = [
|
|
29
|
-
["super-plan", "ulw-plan"],
|
|
30
|
-
["super-run", "ulw-execute"],
|
|
31
|
-
["super-loop", "ulw-loop"],
|
|
32
|
-
["super-graph", "mass-ulw"],
|
|
33
|
-
["super-research", "ulw-research"],
|
|
34
|
-
] as const;
|
|
35
27
|
const skillPath = (id: string) => join(packagePath, "skills", id, "SKILL.md");
|
|
36
|
-
const
|
|
37
|
-
|
|
28
|
+
const canonicalLayout = hasCanonicalSuperkitSkills(packagePath);
|
|
29
|
+
const directiveId = (canonicalLayout ? canonicalSuperkitSkills : legacySuperkitSkills)[0];
|
|
30
|
+
const directivePath = await realpath(skillPath(directiveId));
|
|
31
|
+
assert(directivePath.startsWith(packagePath + sep), `Managed Superkit skill leaves its package: ${directiveId}`);
|
|
32
|
+
const directive = /<ultrawork-mode>([\s\S]*?)<\/ultrawork-mode>/.exec(await readFile(directivePath, "utf8"))?.[1];
|
|
33
|
+
assert(directive?.trim(), `Managed Superkit must ship a directive in its installed ${directiveId} skill`);
|
|
38
34
|
|
|
39
35
|
const modules = await listPackageExtensionModules([packagePath], process.cwd(), { plugins: false });
|
|
40
36
|
assert.deepEqual(await Promise.all(modules.map(module => realpath(module.path))), extensionFiles,
|
|
@@ -113,7 +109,7 @@ try {
|
|
|
113
109
|
if (workflow) {
|
|
114
110
|
const policy = /<omp-ulw-policy>\s*<ultrawork-mode>([\s\S]*?)<\/ultrawork-mode>\s*<\/omp-ulw-policy>/.exec(text)?.[1];
|
|
115
111
|
assert(policy && policy.trim().length > 200, "Activated SUPER policy must contain the workflow directive");
|
|
116
|
-
assert.equal(policy, directive,
|
|
112
|
+
assert.equal(policy, directive, `Activated SUPER policy must use the installed ${directiveId} directive`);
|
|
117
113
|
assert(!nativeBase.join("\n\n").includes(policy), "Workflow policy must come from the candidate hook");
|
|
118
114
|
}
|
|
119
115
|
assert.deepEqual(errors, [], "Managed Superkit native hooks failed");
|
|
@@ -129,11 +125,15 @@ try {
|
|
|
129
125
|
typeof message === "object" && "customType" in message && message.customType === "omo-ultrawork:directive" ? [message] : []);
|
|
130
126
|
assert.equal(pointers.length, selected ? 1 : 0, "Only an explicitly selected specialized SUPER invocation may add a workflow directive");
|
|
131
127
|
if (selected) {
|
|
132
|
-
const [command,
|
|
128
|
+
const [command, legacyId] = selected;
|
|
129
|
+
const skill = canonicalLayout ? command : legacyId;
|
|
130
|
+
const path = skillPath(skill);
|
|
133
131
|
const content = pointers[0]?.content;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
132
|
+
// In the canonical layout the path already contains the command name.
|
|
133
|
+
// Check the invocation separately without prescribing pointer formatting.
|
|
134
|
+
assert(typeof content === "string" && content.startsWith(`<omp-${legacyId}-pointer>`) && content.endsWith(`</omp-${legacyId}-pointer>`)
|
|
135
|
+
&& content.includes(path) && content.split(path).some(part => part.includes(command)),
|
|
136
|
+
`SUPER directive must name /${command} and point to its installed ${skill} skill`);
|
|
137
137
|
}
|
|
138
138
|
return blocks;
|
|
139
139
|
};
|
|
@@ -190,18 +190,20 @@ try {
|
|
|
190
190
|
}
|
|
191
191
|
assert(resources.getEnabledToolNames().includes("read"), "Native read must remain available");
|
|
192
192
|
assert(resources.getEnabledToolNames().includes("task"), "Native task must remain available");
|
|
193
|
-
const skills = resources.skills.filter(skill => skill.filePath.startsWith(packagePath +
|
|
194
|
-
for (const id of [
|
|
193
|
+
const skills = resources.skills.filter(skill => skill.filePath.startsWith(packagePath + sep));
|
|
194
|
+
for (const id of canonicalLayout ? [...canonicalSuperkitSkills, ...legacySuperkitSkills] : legacySuperkitSkills) {
|
|
195
195
|
assert.equal(skills.find(skill => skill.name === id)?.filePath, skillPath(id),
|
|
196
196
|
`Native Superkit skill discovery must retain skill://${id} and its installed path`);
|
|
197
197
|
}
|
|
198
198
|
const read = resources.getToolByName("read");
|
|
199
199
|
assert(read, "Native read tool must be resolvable");
|
|
200
200
|
for (const skill of skills) {
|
|
201
|
+
const target = await realpath(skill.filePath);
|
|
202
|
+
assert(target.startsWith(packagePath + sep), `Managed Superkit skill leaves its package: ${skill.name}`);
|
|
201
203
|
const uri = `skill://${skill.name}:raw`;
|
|
202
204
|
const output = await read.execute(`managed-ulw-resource-${resourceReads.length}`, { path: uri });
|
|
203
205
|
const text = output.content.flatMap(block => block.type === "text" ? [block.text] : []).join("\n");
|
|
204
|
-
assert.equal(text, await readFile(
|
|
206
|
+
assert.equal(text, await readFile(target, "utf8"), `Native resource differs from ${skill.filePath}`);
|
|
205
207
|
resourceReads.push(uri);
|
|
206
208
|
}
|
|
207
209
|
assert.equal(resources.isStreaming, false);
|
|
@@ -4,14 +4,17 @@
|
|
|
4
4
|
{ "name": "status", "description": "Inspect Superagent HEAD and this conversation's lane, including while busy." },
|
|
5
5
|
{ "name": "restart", "description": "Interrupt HEAD work and restart Superagent Gateway and HEAD with the same session and memory." },
|
|
6
6
|
{ "name": "context", "description": "Inspect Superagent HEAD context without starting a model turn." },
|
|
7
|
-
{ "name": "usage", "description": "Show Superagent's OMP quotas or open the saved reset picker.", "text": "Omit to view quotas, or enter reset to choose an account and confirm using one saved reset."
|
|
7
|
+
{ "name": "usage", "description": "Show Superagent's OMP quotas or open the saved reset picker.", "text": "Omit to view quotas, or enter reset to choose an account and confirm using one saved reset.",
|
|
8
|
+
"discord": { "description": "Show Superagent's OMP quotas.", "text": false } },
|
|
8
9
|
{ "name": "cron", "description": "Schedule and manage Superagent jobs in this conversation.", "text": "Use help, add, list, show, edit, pause, resume, run or remove." },
|
|
9
10
|
{ "name": "resume", "description": "Resume the Superagent lane bound to this conversation." },
|
|
10
11
|
{ "name": "resolve", "description": "Close an uncertain Superagent HEAD or bound lane input without replay.", "text": "Exact uncertain HEAD input ID, or --lane followed by the bound lane's exact input ID." },
|
|
11
12
|
{ "name": "main", "description": "Select the main Superagent topic in this owner DM." },
|
|
12
|
-
{ "name": "model", "description": "Choose a Superagent HEAD model
|
|
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
|
+
"discord": { "description": "Choose a model for the Superagent HEAD or the current lane.", "text": true } },
|
|
13
15
|
{ "name": "effort", "description": "Choose the Superagent HEAD thinking effort.", "text": "Omit for the menu, or enter an exact advertised effort level." },
|
|
14
16
|
{ "name": "compact", "description": "Compact Superagent HEAD context when idle.", "text": "Optional compaction instructions, including multiple lines." },
|
|
15
17
|
{ "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." },
|
|
16
|
-
{ "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." }
|
|
18
|
+
{ "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." },
|
|
19
|
+
{ "name": "usage-reset", "description": "Choose an OMP account and review a saved usage reset in Superagent.", "discordOnly": true }
|
|
17
20
|
]
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import catalog from "./messenger-command-catalog.json" with { type: "json" };
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
export const
|
|
3
|
+
/** Owner controls and platform-specific registration metadata shared with the native Gateway. */
|
|
4
|
+
export const MESSENGER_COMMAND_CATALOG: readonly {
|
|
5
5
|
readonly name: string;
|
|
6
6
|
readonly description: string;
|
|
7
7
|
readonly text?: string;
|
|
8
|
+
readonly discordOnly?: boolean;
|
|
9
|
+
readonly discord?: {
|
|
10
|
+
readonly description: string;
|
|
11
|
+
readonly text: boolean;
|
|
12
|
+
};
|
|
8
13
|
}[] = catalog;
|
|
14
|
+
|
|
15
|
+
export const MESSENGER_COMMANDS = MESSENGER_COMMAND_CATALOG.filter(command => !command.discordOnly);
|