@codexhost/cli-win32-x64 0.33.0 → 0.34.0
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/README.md +2 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +191 -9
- package/app/console-web.js +930 -168
- package/app/desktop-controller.mjs +267 -13
- package/app/desktop-mcp-client.mjs +619 -0
- package/app/host-runtime.mjs +3254 -2860
- package/app/plugins/antigravity/plugin.mjs +409 -22
- package/app/plugins/claude-code/plugin.mjs +191 -9
- package/app/plugins/codebuddy/plugin.mjs +203 -14
- package/app/plugins/codex-usage/plugin.mjs +191 -9
- package/app/plugins/copilot/plugin.mjs +191 -9
- package/app/plugins/cursor-cli/plugin.mjs +191 -9
- package/app/plugins/deepseek-harness/plugin.mjs +191 -9
- package/app/plugins/devin/plugin.mjs +191 -9
- package/app/plugins/enabled.json +1 -0
- package/app/plugins/grok/plugin.mjs +191 -9
- package/app/plugins/hermes/plugin.mjs +191 -9
- package/app/plugins/kimi-code/plugin.mjs +191 -9
- package/app/plugins/kiro-cli/plugin.mjs +191 -9
- package/app/plugins/omp/plugin.mjs +1002 -240
- package/app/plugins/opencode/plugin.mjs +191 -9
- package/app/plugins/pi/plugin.mjs +191 -9
- package/app/plugins/qoder/plugin.mjs +191 -9
- package/app/plugins/qoder-cn/plugin.mjs +191 -9
- package/app/plugins/qwen-code/plugin.mjs +191 -9
- package/app/plugins/workbuddy/plugin.mjs +823 -451
- package/app/plugins/workbuddy-cn/assets/icon.svg +27 -0
- package/app/plugins/workbuddy-cn/manifest.json +32 -0
- package/app/plugins/workbuddy-cn/plugin.mjs +36211 -0
- package/app/plugins/zcode/plugin.mjs +191 -9
- package/app/renderer-extension.js +2479 -229
- package/app/web/assets/{abnfDiagram-XWFEHMT6-VnfRaHM6.js → abnfDiagram-XWFEHMT6-Cg-E7mc4.js} +1 -1
- package/app/web/assets/{architectureDiagram-CSQXQB3N-BA1ehtvi.js → architectureDiagram-CSQXQB3N-B__CwXjW.js} +1 -1
- package/app/web/assets/{blockDiagram-BEDRHYPZ-31BZSfd4.js → blockDiagram-BEDRHYPZ-Bk2gCIVM.js} +1 -1
- package/app/web/assets/{c4Diagram-M2UUVUY5-CNzGWc5k.js → c4Diagram-M2UUVUY5-DU_TpjJ3.js} +1 -1
- package/app/web/assets/{chunk-2Q5K7J3B-ahAIR-NM.js → chunk-2Q5K7J3B-DnJEi6e4.js} +1 -1
- package/app/web/assets/{chunk-3GCGMST5-BIV5YeRJ.js → chunk-3GCGMST5-Dia9jGkf.js} +1 -1
- package/app/web/assets/{chunk-5VM5RSS4-CluTMPJG.js → chunk-5VM5RSS4-2PGDiDvK.js} +1 -1
- package/app/web/assets/{chunk-7U7NFRK5-4NIQuFbE.js → chunk-7U7NFRK5-BLPm3d5H.js} +1 -1
- package/app/web/assets/{chunk-CNRTWJTD-_0bEfGn3.js → chunk-CNRTWJTD-GH_nAEXs.js} +1 -1
- package/app/web/assets/{chunk-D5HYT7QG-_kTC6f8F.js → chunk-D5HYT7QG-DnIm-Ely.js} +1 -1
- package/app/web/assets/{chunk-EBZ3SEQC-CykaYOrL.js → chunk-EBZ3SEQC-C6N5qLCR.js} +2 -2
- package/app/web/assets/{chunk-JWPE2WC7-3vVOQ_py.js → chunk-JWPE2WC7-D_kMgdmr.js} +1 -1
- package/app/web/assets/{chunk-KTR4FSNJ-aVg5vgrm.js → chunk-KTR4FSNJ-BRb9femQ.js} +1 -1
- package/app/web/assets/{chunk-XXDRQBXY-_gVwGeSp.js → chunk-XXDRQBXY-BFaK95zq.js} +1 -1
- package/app/web/assets/{classDiagram-v2-KXABOMEV-fI1LfeBf.js → classDiagram-v2-KXABOMEV--_hR_XrU.js} +1 -1
- package/app/web/assets/{cose-bilkent-JH36ORCC-DFXMlWov.js → cose-bilkent-JH36ORCC-C7ghEB3_.js} +1 -1
- package/app/web/assets/{cynefin-EF2NZ3EQ-lZy7X6FO.js → cynefin-EF2NZ3EQ-Ce1lURwZ.js} +1 -1
- package/app/web/assets/{cynefinDiagram-NJNITYFG-N4DwFSW1.js → cynefinDiagram-NJNITYFG-Cgr5aSTS.js} +1 -1
- package/app/web/assets/{dagre-KIHZ2IZ3-B7-8baTH.js → dagre-KIHZ2IZ3-BBFKmRP1.js} +1 -1
- package/app/web/assets/{diagram-7YQZDPLS-DLfjiBXV.js → diagram-7YQZDPLS-CJQih32K.js} +1 -1
- package/app/web/assets/{diagram-QBROCOUO-CQnRzSTi.js → diagram-QBROCOUO-Cl3S7IUT.js} +1 -1
- package/app/web/assets/{diagram-RJJCUUZO-DPnxazRT.js → diagram-RJJCUUZO-B6C8N2cV.js} +1 -1
- package/app/web/assets/{diagram-WERXNKYE-BBuEFRvD.js → diagram-WERXNKYE-NkciBSQl.js} +1 -1
- package/app/web/assets/{diagram-YHHI257C-BQ92JNJs.js → diagram-YHHI257C-DlEvljeY.js} +1 -1
- package/app/web/assets/{diagram-YR4HJLHV-Ce6BQO3J.js → diagram-YR4HJLHV-e4_Gzbt6.js} +1 -1
- package/app/web/assets/{ebnfDiagram-N527522P-DYknE2Jy.js → ebnfDiagram-N527522P-WvQEFmPi.js} +1 -1
- package/app/web/assets/{elk-O5DQBFGD-4S6_JJFF.js → elk-O5DQBFGD-CkyJsjzf.js} +1 -1
- package/app/web/assets/{erDiagram-K3K3BIDK-DRtF7JVQ.js → erDiagram-K3K3BIDK-B93gK3X0.js} +1 -1
- package/app/web/assets/{flowDiagram-Z6JWZHQI-7Ho8CyR9.js → flowDiagram-Z6JWZHQI-NFaGX6B4.js} +1 -1
- package/app/web/assets/{ganttDiagram-3PRQTZWP-CW8Ig5y4.js → ganttDiagram-3PRQTZWP-Czh68CQm.js} +1 -1
- package/app/web/assets/{gitGraphDiagram-VXDFKS5L-CzS8Xg2D.js → gitGraphDiagram-VXDFKS5L-t95UHKja.js} +1 -1
- package/app/web/assets/{grid-E2QIVN74-Cq284lCe.js → grid-E2QIVN74-C87DucDN.js} +1 -1
- package/app/web/assets/index-CGI50Nfg.css +1 -0
- package/app/web/assets/index-Dr6wHi0A.js +208 -0
- package/app/web/assets/{infoDiagram-EZ3ZOAHP-BZgN6qlY.js → infoDiagram-EZ3ZOAHP-CxFlfQbY.js} +1 -1
- package/app/web/assets/{ishikawaDiagram-S3EKX5GW-BH9YHc-1.js → ishikawaDiagram-S3EKX5GW-D4IwQJde.js} +1 -1
- package/app/web/assets/{journeyDiagram-POQNLL5X-D50KYOLe.js → journeyDiagram-POQNLL5X-C0Bf5W4T.js} +1 -1
- package/app/web/assets/{kanban-definition-BH5XI6FM-Crw_5mMP.js → kanban-definition-BH5XI6FM-Cda7r2yr.js} +1 -1
- package/app/web/assets/{mermaid.core-o2Qjrppc.js → mermaid.core-f4LJm6AC.js} +4 -4
- package/app/web/assets/{mindmap-definition-WVAN44T4-B_bEbpAH.js → mindmap-definition-WVAN44T4-DKapinG7.js} +1 -1
- package/app/web/assets/{pegDiagram-D4NLKWP3-VecAHoyw.js → pegDiagram-D4NLKWP3-D7iEZGN2.js} +1 -1
- package/app/web/assets/{pieDiagram-36ENHN4W-o3ei2T-6.js → pieDiagram-36ENHN4W-CopXZ5qt.js} +1 -1
- package/app/web/assets/{quadrantDiagram-ZQUDMS73-DHndOAcn.js → quadrantDiagram-ZQUDMS73-mmkKPDGK.js} +1 -1
- package/app/web/assets/{railroadDiagram-JIZHGYPL-DRd_lfii.js → railroadDiagram-JIZHGYPL-BAGwIIkV.js} +1 -1
- package/app/web/assets/{render-VIF2ZAQL-awM3hUqB.js → render-VIF2ZAQL-dXxGa09y.js} +2 -2
- package/app/web/assets/{requirementDiagram-AXW2TVFA-Ce1ePsOe.js → requirementDiagram-AXW2TVFA-C35tmLFs.js} +1 -1
- package/app/web/assets/{sankeyDiagram-FBCJTAIF-cP-LtgW-.js → sankeyDiagram-FBCJTAIF-BbSo5yeK.js} +1 -1
- package/app/web/assets/{sequenceDiagram-3LA2ROMG-C3JStTuW.js → sequenceDiagram-3LA2ROMG-Cgm2unNy.js} +1 -1
- package/app/web/assets/{sizeCapture-2Q2CQKSF-Dyyelr9K.js → sizeCapture-2Q2CQKSF-DCXFjl2x.js} +1 -1
- package/app/web/assets/{stateDiagram-v2-ATKHQDJO-DkYRBVTd.js → stateDiagram-v2-ATKHQDJO-B349iAao.js} +1 -1
- package/app/web/assets/{swimlanes-YQL5WMAO-B2FwJU5_.js → swimlanes-YQL5WMAO-6OvL1sEz.js} +1 -1
- package/app/web/assets/swimlanesDiagram-UCCPES4V-CIKaQUvP.js +8 -0
- package/app/web/assets/{timeline-definition-7Z437IG3-Di-qRIIi.js → timeline-definition-7Z437IG3-Bh1E3mhW.js} +1 -1
- package/app/web/assets/{usecaseDiagram-RDK6N6HP-yAImn62t.js → usecaseDiagram-RDK6N6HP-Dr5A05lL.js} +1 -1
- package/app/web/assets/{vennDiagram-SHRQU5PJ-BEv8jpfv.js → vennDiagram-SHRQU5PJ-CQPPBa27.js} +1 -1
- package/app/web/assets/{wardleyDiagram-F3OXNVQS-7irksA0b.js → wardleyDiagram-F3OXNVQS-BHin00q8.js} +1 -1
- package/app/web/assets/{xychartDiagram-GDYJKCDI-BokJGG2y.js → xychartDiagram-GDYJKCDI-D4BAWlQZ.js} +1 -1
- package/app/web/codexhost-settings.js +330 -130
- package/app/web/index.html +2 -2
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +8 -8
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +75 -75
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +160 -77
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +104 -100
- package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +64 -64
- package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +5 -5
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +6 -6
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +80 -80
- package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +70 -70
- package/app/web/role-avatars/builtin/advisor-otter.webp +0 -0
- package/app/web/role-avatars/builtin/builder-otter.webp +0 -0
- package/app/web/role-avatars/builtin/sailor-otter.webp +0 -0
- package/app/web/role-avatars/builtin/wizard-otter.webp +0 -0
- package/app/web-modules/server.mjs +5794 -2268
- package/bin/codexhost.exe +0 -0
- package/libexec/codexhost-node-repl.exe +0 -0
- package/libexec/codexhost-screenshot.exe +0 -0
- package/libexec/codexhost-shell.exe +0 -0
- package/libexec/codexhost-shim.exe +0 -0
- package/libexec/codexhost-updater.exe +0 -0
- package/package.json +1 -1
- package/app/web/assets/index-CINZ6P-q.css +0 -1
- package/app/web/assets/index-CvV6veuY.js +0 -208
- package/app/web/assets/swimlanesDiagram-UCCPES4V-BkMsxCPb.js +0 -8
|
@@ -1227,10 +1227,10 @@ function mergeDefs(...defs) {
|
|
|
1227
1227
|
function cloneDef(schema) {
|
|
1228
1228
|
return mergeDefs(schema._zod.def);
|
|
1229
1229
|
}
|
|
1230
|
-
function getElementAtPath(obj,
|
|
1231
|
-
if (!
|
|
1230
|
+
function getElementAtPath(obj, path10) {
|
|
1231
|
+
if (!path10)
|
|
1232
1232
|
return obj;
|
|
1233
|
-
return
|
|
1233
|
+
return path10.reduce((acc, key) => acc?.[key], obj);
|
|
1234
1234
|
}
|
|
1235
1235
|
function promiseAllObject(promisesObj) {
|
|
1236
1236
|
const keys = Object.keys(promisesObj);
|
|
@@ -1570,11 +1570,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
1570
1570
|
}
|
|
1571
1571
|
return false;
|
|
1572
1572
|
}
|
|
1573
|
-
function prefixIssues(
|
|
1573
|
+
function prefixIssues(path10, issues) {
|
|
1574
1574
|
return issues.map((iss) => {
|
|
1575
1575
|
var _a3;
|
|
1576
1576
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1577
|
-
iss.path.unshift(
|
|
1577
|
+
iss.path.unshift(path10);
|
|
1578
1578
|
return iss;
|
|
1579
1579
|
});
|
|
1580
1580
|
}
|
|
@@ -2036,16 +2036,16 @@ function flattenError(error62, mapper = (issue2) => issue2.message) {
|
|
|
2036
2036
|
}
|
|
2037
2037
|
function formatError(error62, mapper = (issue2) => issue2.message) {
|
|
2038
2038
|
const fieldErrors = { _errors: [] };
|
|
2039
|
-
const processError = (error63,
|
|
2039
|
+
const processError = (error63, path10 = []) => {
|
|
2040
2040
|
for (const issue2 of error63.issues) {
|
|
2041
2041
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
2042
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
2042
|
+
issue2.errors.map((issues) => processError({ issues }, [...path10, ...issue2.path]));
|
|
2043
2043
|
} else if (issue2.code === "invalid_key") {
|
|
2044
|
-
processError({ issues: issue2.issues }, [...
|
|
2044
|
+
processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
|
|
2045
2045
|
} else if (issue2.code === "invalid_element") {
|
|
2046
|
-
processError({ issues: issue2.issues }, [...
|
|
2046
|
+
processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
|
|
2047
2047
|
} else {
|
|
2048
|
-
const fullpath = [...
|
|
2048
|
+
const fullpath = [...path10, ...issue2.path];
|
|
2049
2049
|
if (fullpath.length === 0) {
|
|
2050
2050
|
fieldErrors._errors.push(mapper(issue2));
|
|
2051
2051
|
} else {
|
|
@@ -2084,17 +2084,17 @@ function formatError(error62, mapper = (issue2) => issue2.message) {
|
|
|
2084
2084
|
}
|
|
2085
2085
|
function treeifyError(error62, mapper = (issue2) => issue2.message) {
|
|
2086
2086
|
const result = { errors: [] };
|
|
2087
|
-
const processError = (error63,
|
|
2087
|
+
const processError = (error63, path10 = []) => {
|
|
2088
2088
|
var _a3;
|
|
2089
2089
|
for (const issue2 of error63.issues) {
|
|
2090
2090
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
2091
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
2091
|
+
issue2.errors.map((issues) => processError({ issues }, [...path10, ...issue2.path]));
|
|
2092
2092
|
} else if (issue2.code === "invalid_key") {
|
|
2093
|
-
processError({ issues: issue2.issues }, [...
|
|
2093
|
+
processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
|
|
2094
2094
|
} else if (issue2.code === "invalid_element") {
|
|
2095
|
-
processError({ issues: issue2.issues }, [...
|
|
2095
|
+
processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
|
|
2096
2096
|
} else {
|
|
2097
|
-
const fullpath = [...
|
|
2097
|
+
const fullpath = [...path10, ...issue2.path];
|
|
2098
2098
|
if (fullpath.length === 0) {
|
|
2099
2099
|
result.errors.push(mapper(issue2));
|
|
2100
2100
|
continue;
|
|
@@ -2133,8 +2133,8 @@ function treeifyError(error62, mapper = (issue2) => issue2.message) {
|
|
|
2133
2133
|
}
|
|
2134
2134
|
function toDotPath(_path) {
|
|
2135
2135
|
const segs = [];
|
|
2136
|
-
const
|
|
2137
|
-
for (const seg of
|
|
2136
|
+
const path10 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
2137
|
+
for (const seg of path10) {
|
|
2138
2138
|
if (typeof seg === "number")
|
|
2139
2139
|
segs.push(`[${seg}]`);
|
|
2140
2140
|
else if (typeof seg === "symbol")
|
|
@@ -17063,8 +17063,8 @@ function rewriteKeyNames(ctx) {
|
|
|
17063
17063
|
bySchema.set(entry.schema, entry);
|
|
17064
17064
|
}
|
|
17065
17065
|
const rewrites = /* @__PURE__ */ new Map();
|
|
17066
|
-
for (const
|
|
17067
|
-
const seen = ctx.seen.get(
|
|
17066
|
+
for (const record4 of pendingRecords.get(ctx) ?? []) {
|
|
17067
|
+
const seen = ctx.seen.get(record4);
|
|
17068
17068
|
const names = (seen?.def ?? seen?.schema)?.propertyNames;
|
|
17069
17069
|
if (!names || names === true || rewrites.has(names))
|
|
17070
17070
|
continue;
|
|
@@ -19272,13 +19272,13 @@ function resolveRef(ref, ctx) {
|
|
|
19272
19272
|
if (!ref.startsWith("#")) {
|
|
19273
19273
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
19274
19274
|
}
|
|
19275
|
-
const
|
|
19276
|
-
if (
|
|
19275
|
+
const path10 = ref.slice(1).split("/").filter(Boolean);
|
|
19276
|
+
if (path10.length === 0) {
|
|
19277
19277
|
return ctx.rootSchema;
|
|
19278
19278
|
}
|
|
19279
19279
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
19280
|
-
if (
|
|
19281
|
-
const key =
|
|
19280
|
+
if (path10[0] === defsKey) {
|
|
19281
|
+
const key = path10[1] === void 0 ? void 0 : decodeJSONPointerSegment(path10[1]);
|
|
19282
19282
|
if (!key || !ctx.defs[key]) {
|
|
19283
19283
|
throw new Error(`Reference not found: ${ref}`);
|
|
19284
19284
|
}
|
|
@@ -20317,7 +20317,11 @@ var BUILTIN_ROLE_AVATAR_IDS = [
|
|
|
20317
20317
|
"security-otter",
|
|
20318
20318
|
"audio-otter",
|
|
20319
20319
|
"scholar-otter",
|
|
20320
|
-
"data-otter"
|
|
20320
|
+
"data-otter",
|
|
20321
|
+
"advisor-otter",
|
|
20322
|
+
"builder-otter",
|
|
20323
|
+
"wizard-otter",
|
|
20324
|
+
"sailor-otter"
|
|
20321
20325
|
];
|
|
20322
20326
|
var builtinRoleAvatarSchema = external_exports.templateLiteral([
|
|
20323
20327
|
"builtin:",
|
|
@@ -21083,7 +21087,7 @@ var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("ty
|
|
|
21083
21087
|
default: external_exports.string().optional()
|
|
21084
21088
|
})
|
|
21085
21089
|
]).superRefine((field2, ctx) => {
|
|
21086
|
-
const issue2 = (
|
|
21090
|
+
const issue2 = (path10, message3) => ctx.addIssue({ code: "custom", path: [path10], message: message3 });
|
|
21087
21091
|
if (field2.type === "number" || field2.type === "range") {
|
|
21088
21092
|
const { min = -Infinity, max = Infinity, default: value } = field2;
|
|
21089
21093
|
if (min > max)
|
|
@@ -21189,16 +21193,16 @@ var hostExtensionIdSchema = desktopExtensionIdSchema.refine((id2) => !reservedNa
|
|
|
21189
21193
|
var hostExtensionTargetSchema = external_exports.enum(["desktop", "web"]);
|
|
21190
21194
|
var hostExtensionDigestSchema = desktopExtensionHashSchema;
|
|
21191
21195
|
var hostExtensionActivationIdSchema = external_exports.uuid();
|
|
21192
|
-
var hostExtensionResourcePathSchema = pluginRelativeResourceSchema.refine((resource) => !/[\x00-\x1f\x7f<>"|*]/u.test(resource) && resource.split("/").every((part) => !/[. ]$/u.test(part) && !reservedName.test(part)), "Expected a portable relative resource path").refine((
|
|
21196
|
+
var hostExtensionResourcePathSchema = pluginRelativeResourceSchema.refine((resource) => !/[\x00-\x1f\x7f<>"|*]/u.test(resource) && resource.split("/").every((part) => !/[. ]$/u.test(part) && !reservedName.test(part)), "Expected a portable relative resource path").refine((path10) => path10.split("/").length <= 32, "Extension resources may be at most 32 segments deep");
|
|
21193
21197
|
var legacy = desktopExtensionManifestSchema.shape;
|
|
21194
21198
|
var localized = (max, min = 0) => external_exports.strictObject({
|
|
21195
21199
|
en: external_exports.string().trim().min(min).max(max),
|
|
21196
21200
|
"zh-CN": external_exports.string().trim().min(min).max(max)
|
|
21197
21201
|
});
|
|
21198
|
-
var resourceWithSuffix = (suffix) => hostExtensionResourcePathSchema.refine((
|
|
21202
|
+
var resourceWithSuffix = (suffix) => hostExtensionResourcePathSchema.refine((path10) => path10.endsWith(suffix), `Expected a ${suffix} file`);
|
|
21199
21203
|
var moduleEntry = resourceWithSuffix(".mjs");
|
|
21200
21204
|
var style = resourceWithSuffix(".css").optional();
|
|
21201
|
-
var hostExtensionCanonicalPath = (
|
|
21205
|
+
var hostExtensionCanonicalPath = (path10) => path10.normalize("NFC").toLowerCase();
|
|
21202
21206
|
var hostExtensionManifestV2Schema = external_exports.strictObject({
|
|
21203
21207
|
manifestVersion: external_exports.literal(2),
|
|
21204
21208
|
id: hostExtensionIdSchema,
|
|
@@ -21208,8 +21212,8 @@ var hostExtensionManifestV2Schema = external_exports.strictObject({
|
|
|
21208
21212
|
details: localized(16384).optional(),
|
|
21209
21213
|
author: legacy.author,
|
|
21210
21214
|
repository: legacy.repository,
|
|
21211
|
-
icon: legacy.icon.refine((
|
|
21212
|
-
screenshots: legacy.screenshots.refine((paths) => paths === void 0 || paths.every((
|
|
21215
|
+
icon: legacy.icon.refine((path10) => path10 === void 0 || hostExtensionResourcePathSchema.safeParse(path10).success),
|
|
21216
|
+
screenshots: legacy.screenshots.refine((paths) => paths === void 0 || paths.every((path10) => hostExtensionResourcePathSchema.safeParse(path10).success)),
|
|
21213
21217
|
categories: legacy.categories,
|
|
21214
21218
|
settingsSchema: legacy.settingsSchema,
|
|
21215
21219
|
slots: legacy.slots.removeDefault().optional(),
|
|
@@ -21335,7 +21339,7 @@ var active = {
|
|
|
21335
21339
|
digest: hostExtensionDigestSchema
|
|
21336
21340
|
};
|
|
21337
21341
|
var optionalActivation = { ...id, activationId: active.activationId.optional() };
|
|
21338
|
-
var filePath = external_exports.string().min(1).max(4096).refine((
|
|
21342
|
+
var filePath = external_exports.string().min(1).max(4096).refine((path10) => /^(?:\/|[a-z]:[/\\])/iu.test(path10) && !path10.includes("\0") && !path10.split(/[/\\]/u).some((part) => part === "." || part === ".."), "Expected an absolute local path without dot segments");
|
|
21339
21343
|
var gitRef = external_exports.string().min(1).max(256).refine((ref) => ref.split("/").every((part) => part && /^[a-z0-9_.-]+$/iu.test(part) && part !== "." && part !== ".."), "Invalid GitHub ref");
|
|
21340
21344
|
function base643(maxBytes) {
|
|
21341
21345
|
return external_exports.string().max(4 * Math.ceil(maxBytes / 3)).refine((value) => {
|
|
@@ -21535,6 +21539,7 @@ var hostExtensionsRpcSchemas = {
|
|
|
21535
21539
|
// ../../shared-contracts/dist/group-chat.js
|
|
21536
21540
|
var DEFAULT_GROUP_MAX_AGENT_HOPS = 5;
|
|
21537
21541
|
var MAX_GROUP_AGENT_HOPS = 20;
|
|
21542
|
+
var GROUP_NOTICE_MAX_LENGTH = 2e3;
|
|
21538
21543
|
var remoteGroupRoomIdSchema = external_exports.string().regex(/^remote:[A-Za-z0-9_-]{8,512}$/u);
|
|
21539
21544
|
var groupRoomIdSchema = external_exports.union([external_exports.uuidv4(), remoteGroupRoomIdSchema]);
|
|
21540
21545
|
var groupMemberIdSchema = external_exports.uuidv4();
|
|
@@ -21561,11 +21566,16 @@ var groupMemberSchema = external_exports.object({
|
|
|
21561
21566
|
roleSnapshot: threadRoleSnapshotSchema.optional(),
|
|
21562
21567
|
harnessId: harnessIdSchema,
|
|
21563
21568
|
status: groupMemberStatusSchema,
|
|
21569
|
+
projectless: external_exports.boolean().optional(),
|
|
21564
21570
|
joinedAtSeq: nonnegativeInteger,
|
|
21565
21571
|
lastDeliveredSeq: nonnegativeInteger,
|
|
21566
21572
|
lastRosterVersion: nonnegativeInteger,
|
|
21567
21573
|
createdAt: timestamp
|
|
21568
21574
|
});
|
|
21575
|
+
var groupProjectlessWorkspaceSchema = external_exports.object({
|
|
21576
|
+
workspaceRoot: nonblankString,
|
|
21577
|
+
outputDirectory: nonblankString
|
|
21578
|
+
});
|
|
21569
21579
|
var groupRoomRemoteHostSchema = external_exports.object({
|
|
21570
21580
|
hostId: nonblankString,
|
|
21571
21581
|
displayName: nonblankString,
|
|
@@ -21577,6 +21587,7 @@ var groupRoomSchema = external_exports.object({
|
|
|
21577
21587
|
roomId: groupRoomIdSchema,
|
|
21578
21588
|
title: nonblankString,
|
|
21579
21589
|
defaultCwd: nonblankString,
|
|
21590
|
+
projectlessWorkspace: groupProjectlessWorkspaceSchema.optional(),
|
|
21580
21591
|
unmentionedPolicy: groupUnmentionedPolicySchema.default("none"),
|
|
21581
21592
|
allowAgentMentions: external_exports.boolean().default(true),
|
|
21582
21593
|
maxAgentHops: maxAgentHopsSchema.default(DEFAULT_GROUP_MAX_AGENT_HOPS),
|
|
@@ -21657,8 +21668,10 @@ var GROUPS_DELETE_METHOD = "codexhost/groups/delete";
|
|
|
21657
21668
|
var GROUPS_ADD_MEMBER_METHOD = "codexhost/groups/member/add";
|
|
21658
21669
|
var GROUPS_UPDATE_MEMBER_METHOD = "codexhost/groups/member/update";
|
|
21659
21670
|
var GROUPS_REMOVE_MEMBER_METHOD = "codexhost/groups/member/remove";
|
|
21671
|
+
var GROUPS_REBIND_MEMBER_METHOD = "codexhost/groups/member/rebind";
|
|
21660
21672
|
var GROUPS_POST_MESSAGE_METHOD = "codexhost/groups/message/post";
|
|
21661
21673
|
var GROUPS_READ_MESSAGES_METHOD = "codexhost/groups/messages/read";
|
|
21674
|
+
var GROUPS_INSPECT_CWD_METHOD = "codexhost/groups/cwd/inspect";
|
|
21662
21675
|
var roomIdentity = { roomId: groupRoomIdSchema };
|
|
21663
21676
|
var memberIdentity = { ...roomIdentity, memberId: groupMemberIdSchema };
|
|
21664
21677
|
var roomEdits = {
|
|
@@ -21681,7 +21694,7 @@ var groupsGetResultSchema = external_exports.object({
|
|
|
21681
21694
|
});
|
|
21682
21695
|
var groupsCreateParamsSchema = external_exports.strictObject({
|
|
21683
21696
|
...roomEdits,
|
|
21684
|
-
defaultCwd: nonblankString,
|
|
21697
|
+
defaultCwd: nonblankString.optional(),
|
|
21685
21698
|
members: external_exports.array(groupCreateMemberInputSchema)
|
|
21686
21699
|
});
|
|
21687
21700
|
var groupsCreateResultSchema = external_exports.object({ room: groupRoomSchema });
|
|
@@ -21707,14 +21720,90 @@ var groupsUpdateMemberParamsSchema = external_exports.strictObject({
|
|
|
21707
21720
|
status: groupMemberStatusSchema.optional()
|
|
21708
21721
|
});
|
|
21709
21722
|
var groupsRemoveMemberParamsSchema = external_exports.strictObject(memberIdentity);
|
|
21723
|
+
var groupsRebindMemberParamsSchema = external_exports.strictObject({
|
|
21724
|
+
...memberIdentity,
|
|
21725
|
+
threadId: hostThreadIdSchema,
|
|
21726
|
+
redeliverFrom: positiveInteger.optional(),
|
|
21727
|
+
note: external_exports.string().optional()
|
|
21728
|
+
});
|
|
21729
|
+
var groupCliRebindMemberParamsSchema = external_exports.strictObject({
|
|
21730
|
+
...roomIdentity,
|
|
21731
|
+
memberId: groupMemberIdSchema.optional(),
|
|
21732
|
+
memberHandle: groupMemberHandleSchema.optional(),
|
|
21733
|
+
threadId: hostThreadIdSchema,
|
|
21734
|
+
redeliverFrom: positiveInteger.optional(),
|
|
21735
|
+
note: external_exports.string().optional()
|
|
21736
|
+
}).refine((value) => value.memberId !== void 0 !== (value.memberHandle !== void 0), "Provide exactly one of memberId or memberHandle");
|
|
21737
|
+
var groupsRebindMemberResultSchema = external_exports.object({
|
|
21738
|
+
room: groupRoomSchema,
|
|
21739
|
+
member: groupMemberSchema,
|
|
21740
|
+
previousThreadId: hostThreadIdSchema,
|
|
21741
|
+
awakened: external_exports.boolean()
|
|
21742
|
+
});
|
|
21743
|
+
var groupCliListMemberSchema = external_exports.object({
|
|
21744
|
+
memberId: groupMemberIdSchema,
|
|
21745
|
+
threadId: hostThreadIdSchema,
|
|
21746
|
+
handle: groupMemberHandleSchema,
|
|
21747
|
+
displayName: nonblankString,
|
|
21748
|
+
status: groupMemberStatusSchema,
|
|
21749
|
+
harnessId: harnessIdSchema,
|
|
21750
|
+
roleSlug: roleSlugSchema.optional(),
|
|
21751
|
+
roleName: nonblankString.optional()
|
|
21752
|
+
});
|
|
21753
|
+
var groupCliListEntrySchema = external_exports.object({
|
|
21754
|
+
roomId: groupRoomIdSchema,
|
|
21755
|
+
title: nonblankString,
|
|
21756
|
+
memberCount: nonnegativeInteger,
|
|
21757
|
+
updatedAt: timestamp,
|
|
21758
|
+
member: groupCliListMemberSchema.optional()
|
|
21759
|
+
});
|
|
21760
|
+
var groupCliListParamsSchema = external_exports.strictObject({
|
|
21761
|
+
threadId: hostThreadIdSchema.optional()
|
|
21762
|
+
});
|
|
21763
|
+
var groupCliListResultSchema = external_exports.object({
|
|
21764
|
+
rooms: external_exports.array(groupCliListEntrySchema)
|
|
21765
|
+
});
|
|
21710
21766
|
var groupsPostMessageParamsSchema = external_exports.strictObject({
|
|
21711
21767
|
...roomIdentity,
|
|
21712
21768
|
content: external_exports.string().max(64e3),
|
|
21713
21769
|
attachments: external_exports.array(groupAttachmentSchema).max(12).optional(),
|
|
21714
21770
|
replyToSeq: positiveInteger.optional(),
|
|
21715
21771
|
targetMemberIds: external_exports.array(groupMemberIdSchema).optional(),
|
|
21716
|
-
mentionAll: external_exports.boolean().optional()
|
|
21717
|
-
|
|
21772
|
+
mentionAll: external_exports.boolean().optional(),
|
|
21773
|
+
notice: external_exports.boolean().optional()
|
|
21774
|
+
}).superRefine((value, context) => {
|
|
21775
|
+
if (value.notice === true) {
|
|
21776
|
+
if (value.content.trim().length === 0) {
|
|
21777
|
+
context.addIssue({
|
|
21778
|
+
code: "custom",
|
|
21779
|
+
path: ["content"],
|
|
21780
|
+
message: "Notice content is required"
|
|
21781
|
+
});
|
|
21782
|
+
}
|
|
21783
|
+
if (value.content.length > GROUP_NOTICE_MAX_LENGTH) {
|
|
21784
|
+
context.addIssue({
|
|
21785
|
+
code: "custom",
|
|
21786
|
+
path: ["content"],
|
|
21787
|
+
message: `Notice content must be at most ${GROUP_NOTICE_MAX_LENGTH} characters`
|
|
21788
|
+
});
|
|
21789
|
+
}
|
|
21790
|
+
if ((value.targetMemberIds?.length ?? 0) > 0 || value.mentionAll === true || (value.attachments?.length ?? 0) > 0) {
|
|
21791
|
+
context.addIssue({
|
|
21792
|
+
code: "custom",
|
|
21793
|
+
path: ["notice"],
|
|
21794
|
+
message: "System notices cannot target members or include attachments"
|
|
21795
|
+
});
|
|
21796
|
+
}
|
|
21797
|
+
return;
|
|
21798
|
+
}
|
|
21799
|
+
if (value.content.trim().length === 0 && (value.attachments?.length ?? 0) === 0) {
|
|
21800
|
+
context.addIssue({
|
|
21801
|
+
code: "custom",
|
|
21802
|
+
path: ["content"],
|
|
21803
|
+
message: "Message content or at least one attachment is required"
|
|
21804
|
+
});
|
|
21805
|
+
}
|
|
21806
|
+
});
|
|
21718
21807
|
var groupsPostMessageResultSchema = external_exports.object({
|
|
21719
21808
|
room: groupRoomSchema,
|
|
21720
21809
|
message: groupMessageSchema,
|
|
@@ -21731,6 +21820,13 @@ var groupsReadMessagesResultSchema = external_exports.object({
|
|
|
21731
21820
|
messages: external_exports.array(groupMessageSchema),
|
|
21732
21821
|
totalSeq: nonnegativeInteger
|
|
21733
21822
|
});
|
|
21823
|
+
var groupsInspectCwdParamsSchema = external_exports.strictObject({
|
|
21824
|
+
cwd: nonblankString,
|
|
21825
|
+
roomId: groupRoomIdSchema.optional()
|
|
21826
|
+
});
|
|
21827
|
+
var groupsInspectCwdResultSchema = external_exports.object({
|
|
21828
|
+
isGitRepo: external_exports.boolean()
|
|
21829
|
+
});
|
|
21734
21830
|
|
|
21735
21831
|
// ../../shared-contracts/dist/thread-archive-confirm.js
|
|
21736
21832
|
var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
|
|
@@ -21777,6 +21873,7 @@ var TELEMETRY_OFFICIAL_HARNESSES = [
|
|
|
21777
21873
|
"kiro-cli",
|
|
21778
21874
|
"codebuddy",
|
|
21779
21875
|
"workbuddy",
|
|
21876
|
+
"workbuddy-cn",
|
|
21780
21877
|
"devin",
|
|
21781
21878
|
"hermes",
|
|
21782
21879
|
"qoder",
|
|
@@ -21916,8 +22013,10 @@ var CLIENT_CHANNEL_METHODS = [
|
|
|
21916
22013
|
GROUPS_ADD_MEMBER_METHOD,
|
|
21917
22014
|
GROUPS_UPDATE_MEMBER_METHOD,
|
|
21918
22015
|
GROUPS_REMOVE_MEMBER_METHOD,
|
|
22016
|
+
GROUPS_REBIND_MEMBER_METHOD,
|
|
21919
22017
|
GROUPS_POST_MESSAGE_METHOD,
|
|
21920
22018
|
GROUPS_READ_MESSAGES_METHOD,
|
|
22019
|
+
GROUPS_INSPECT_CWD_METHOD,
|
|
21921
22020
|
"codexhost/voice/status",
|
|
21922
22021
|
"codexhost/voice/transcribe",
|
|
21923
22022
|
"codexhost/harness/display-settings/get",
|
|
@@ -22482,7 +22581,23 @@ var REMOTE_PEER_ID_PATTERN = /^[a-zA-Z0-9_-]{1,64}$/u;
|
|
|
22482
22581
|
var remotePeerIdSchema = external_exports.string().regex(REMOTE_PEER_ID_PATTERN);
|
|
22483
22582
|
var remotePeerNodeIdSchema = external_exports.string().regex(REMOTE_PEER_ID_PATTERN);
|
|
22484
22583
|
var remotePeerHostIdSchema = external_exports.string().regex(/^remote-peer:[a-zA-Z0-9_-]{1,64}$/u);
|
|
22485
|
-
var remotePeerTransportKindSchema = external_exports.enum(["relay", "tailscale", "lan", "custom"]);
|
|
22584
|
+
var remotePeerTransportKindSchema = external_exports.enum(["relay", "tailscale", "lan", "ssh", "custom"]);
|
|
22585
|
+
var remotePeerSshAuthModeSchema = external_exports.enum(["auto", "key", "password"]);
|
|
22586
|
+
var remotePeerSshConfigSchema = external_exports.object({
|
|
22587
|
+
host: external_exports.string().trim().min(1).max(255),
|
|
22588
|
+
port: external_exports.number().int().min(1).max(65535).optional(),
|
|
22589
|
+
user: external_exports.string().trim().min(1).max(128).optional(),
|
|
22590
|
+
identityFile: external_exports.string().trim().min(1).max(1024).optional(),
|
|
22591
|
+
authMode: remotePeerSshAuthModeSchema.default("auto"),
|
|
22592
|
+
remoteDataDir: external_exports.string().trim().min(1).max(1024).optional()
|
|
22593
|
+
});
|
|
22594
|
+
var remotePeerSshSummarySchema = external_exports.object({
|
|
22595
|
+
host: external_exports.string().min(1).max(255),
|
|
22596
|
+
port: external_exports.number().int().min(1).max(65535).optional(),
|
|
22597
|
+
user: external_exports.string().min(1).max(128).optional(),
|
|
22598
|
+
authMode: remotePeerSshAuthModeSchema,
|
|
22599
|
+
keyInstalled: external_exports.boolean().optional()
|
|
22600
|
+
});
|
|
22486
22601
|
var REMOTE_PEER_COLORS = [
|
|
22487
22602
|
"blue",
|
|
22488
22603
|
"purple",
|
|
@@ -22509,6 +22624,7 @@ var remotePeerSummarySchema = external_exports.object({
|
|
|
22509
22624
|
color: remotePeerColorSchema.optional(),
|
|
22510
22625
|
origin: external_exports.string().min(1).max(2048),
|
|
22511
22626
|
transportKind: remotePeerTransportKindSchema,
|
|
22627
|
+
ssh: remotePeerSshSummarySchema.optional(),
|
|
22512
22628
|
encrypted: external_exports.boolean(),
|
|
22513
22629
|
enabled: external_exports.boolean(),
|
|
22514
22630
|
state: remotePeerStateSchema,
|
|
@@ -22756,8 +22872,66 @@ var delegationHostHarnessOptionSchema = external_exports.object({
|
|
|
22756
22872
|
var delegationHostHarnessesResultSchema = external_exports.object({
|
|
22757
22873
|
harnesses: external_exports.array(delegationHostHarnessOptionSchema)
|
|
22758
22874
|
});
|
|
22875
|
+
var sshConfigHostEntrySchema = external_exports.object({
|
|
22876
|
+
alias: external_exports.string().min(1).max(255),
|
|
22877
|
+
hostName: external_exports.string().max(255).optional(),
|
|
22878
|
+
user: external_exports.string().max(128).optional(),
|
|
22879
|
+
port: external_exports.number().int().min(1).max(65535).optional(),
|
|
22880
|
+
identityFile: external_exports.string().max(1024).optional()
|
|
22881
|
+
});
|
|
22882
|
+
var remotePeerListSshConfigHostsResultSchema = external_exports.object({
|
|
22883
|
+
hosts: external_exports.array(sshConfigHostEntrySchema)
|
|
22884
|
+
});
|
|
22885
|
+
var remotePeerSshConnectParamsSchema = external_exports.object({
|
|
22886
|
+
host: external_exports.string().trim().min(1).max(255),
|
|
22887
|
+
port: external_exports.number().int().min(1).max(65535).optional(),
|
|
22888
|
+
user: external_exports.string().trim().min(1).max(128).optional(),
|
|
22889
|
+
identityFile: external_exports.string().trim().min(1).max(1024).optional(),
|
|
22890
|
+
authMode: remotePeerSshAuthModeSchema.default("auto"),
|
|
22891
|
+
password: external_exports.string().max(1024).optional(),
|
|
22892
|
+
installAuthorizedKey: external_exports.boolean().optional(),
|
|
22893
|
+
name: external_exports.string().trim().min(1).max(120).optional(),
|
|
22894
|
+
color: remotePeerColorSchema.optional(),
|
|
22895
|
+
remoteDataDir: external_exports.string().trim().min(1).max(1024).optional(),
|
|
22896
|
+
sessionId: external_exports.string().min(1).max(128).optional()
|
|
22897
|
+
});
|
|
22898
|
+
var remotePeerSshTestResultSchema = external_exports.object({
|
|
22899
|
+
ok: external_exports.boolean(),
|
|
22900
|
+
codexhostInstalled: external_exports.boolean(),
|
|
22901
|
+
version: external_exports.string().max(128).optional(),
|
|
22902
|
+
nodeId: remotePeerNodeIdSchema.optional(),
|
|
22903
|
+
platform: external_exports.string().max(64).optional(),
|
|
22904
|
+
hostname: external_exports.string().max(255).optional(),
|
|
22905
|
+
latencyMs: external_exports.number().int().nonnegative().optional(),
|
|
22906
|
+
errorCode: external_exports.string().max(128).optional(),
|
|
22907
|
+
error: external_exports.string().max(1e3).optional()
|
|
22908
|
+
});
|
|
22909
|
+
var remotePeerSshInstallResultSchema = external_exports.object({
|
|
22910
|
+
ok: external_exports.boolean(),
|
|
22911
|
+
version: external_exports.string().max(128).optional(),
|
|
22912
|
+
message: external_exports.string().max(1e3).optional()
|
|
22913
|
+
});
|
|
22914
|
+
var remotePeerSshAuthPromptSchema = external_exports.object({
|
|
22915
|
+
promptId: external_exports.string().min(1).max(128),
|
|
22916
|
+
sessionId: external_exports.string().min(1).max(128).optional(),
|
|
22917
|
+
peerId: remotePeerIdSchema.optional(),
|
|
22918
|
+
host: external_exports.string().min(1).max(255),
|
|
22919
|
+
kind: external_exports.enum(["host-key", "password", "passphrase", "otp", "generic"]),
|
|
22920
|
+
prompt: external_exports.string().min(1).max(1e3),
|
|
22921
|
+
echo: external_exports.boolean()
|
|
22922
|
+
});
|
|
22923
|
+
var remotePeerSshRespondAuthParamsSchema = external_exports.object({
|
|
22924
|
+
promptId: external_exports.string().min(1).max(128),
|
|
22925
|
+
sessionId: external_exports.string().min(1).max(128).optional(),
|
|
22926
|
+
response: external_exports.string().max(1024).optional(),
|
|
22927
|
+
cancel: external_exports.boolean().optional()
|
|
22928
|
+
});
|
|
22759
22929
|
|
|
22760
22930
|
// ../../shared-contracts/dist/peer-delegation.js
|
|
22931
|
+
var peerWatchNudgeParamsSchema = external_exports.strictObject({
|
|
22932
|
+
hostId: remotePeerHostIdSchema,
|
|
22933
|
+
threadId: external_exports.string().min(1).max(1024).optional()
|
|
22934
|
+
});
|
|
22761
22935
|
var PEER_DELEGATION_BRIDGE_VERSION = 1;
|
|
22762
22936
|
var PEER_DELEGATION_OPERATIONS = [
|
|
22763
22937
|
"listHarnesses",
|
|
@@ -22941,11 +23115,12 @@ var delegationDefaultsSchema = external_exports.strictObject({
|
|
|
22941
23115
|
byHarness: external_exports.record(preferenceHarnessKey, harnessDelegationDefaultSchema)
|
|
22942
23116
|
});
|
|
22943
23117
|
var modelId = external_exports.string().min(1).max(1024);
|
|
22944
|
-
var harnessPreferenceValuesSchema = external_exports.
|
|
23118
|
+
var harnessPreferenceValuesSchema = external_exports.object({
|
|
22945
23119
|
idleRelease: idleReleaseSettingsSchema.optional(),
|
|
22946
23120
|
favorites: external_exports.record(preferenceHarnessKey, external_exports.array(modelId).max(2048)).default({}),
|
|
22947
23121
|
newThread: newThreadDefaultsSchema.optional(),
|
|
22948
|
-
delegation: delegationDefaultsSchema.optional()
|
|
23122
|
+
delegation: delegationDefaultsSchema.optional(),
|
|
23123
|
+
showGroupChatsInSidebar: external_exports.boolean().optional()
|
|
22949
23124
|
});
|
|
22950
23125
|
var harnessPreferenceSnapshotSchema = external_exports.strictObject({
|
|
22951
23126
|
scope: harnessPreferenceScopeSchema,
|
|
@@ -22978,6 +23153,10 @@ var harnessPreferenceOperationSchema = external_exports.discriminatedUnion("kind
|
|
|
22978
23153
|
kind: external_exports.literal("delegation"),
|
|
22979
23154
|
harnessId: harnessIdSchema,
|
|
22980
23155
|
configuration: harnessDelegationDefaultSchema.nullable()
|
|
23156
|
+
}),
|
|
23157
|
+
external_exports.strictObject({
|
|
23158
|
+
kind: external_exports.literal("groupChatsSidebar"),
|
|
23159
|
+
visible: external_exports.boolean()
|
|
22981
23160
|
})
|
|
22982
23161
|
]);
|
|
22983
23162
|
var harnessPreferencePatchSchema = external_exports.strictObject({
|
|
@@ -23814,7 +23993,7 @@ var THREAD_WATCH_NOTICE_OUTCOMES = [
|
|
|
23814
23993
|
"unreadable",
|
|
23815
23994
|
"notFound"
|
|
23816
23995
|
];
|
|
23817
|
-
var ENTRY_PATTERN = new RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)
|
|
23996
|
+
var ENTRY_PATTERN = new RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)(?:\?hostId=([^\s()<>"?#/&]+))?\): ` + `(${THREAD_WATCH_NOTICE_OUTCOMES.join("|")})(?:. (.+))?$`, "u");
|
|
23818
23997
|
|
|
23819
23998
|
// ../../shared-contracts/dist/remote-runtime.js
|
|
23820
23999
|
var remoteUpdatePhaseSchema = external_exports.enum([
|
|
@@ -23843,7 +24022,7 @@ var remoteSshSetupParamsSchema = external_exports.object({
|
|
|
23843
24022
|
hostname: external_exports.string().min(1).max(1024).refine((value) => !value.startsWith("-") && !/\s/u.test(value)),
|
|
23844
24023
|
port: external_exports.number().int().min(1).max(65535).nullable(),
|
|
23845
24024
|
identity: external_exports.string().max(4096).nullable(),
|
|
23846
|
-
action: external_exports.enum(["inspect", "install", "update", "repair", "uninstall"]),
|
|
24025
|
+
action: external_exports.enum(["inspect", "install", "update", "restart", "repair", "uninstall"]),
|
|
23847
24026
|
uninstallPackage: external_exports.boolean().optional(),
|
|
23848
24027
|
version: external_exports.string().regex(/^\d+\.\d+\.\d+$/u).nullable()
|
|
23849
24028
|
}).strict();
|
|
@@ -23859,6 +24038,7 @@ var target = {
|
|
|
23859
24038
|
var thread2 = { ...target, threadId: identity };
|
|
23860
24039
|
var text = external_exports.string().min(1).max(8e3);
|
|
23861
24040
|
var input2 = { text, requestId: identity };
|
|
24041
|
+
var queueReorderItemIdsSchema = external_exports.array(identity).min(2).max(100).refine((ids) => new Set(ids).size === ids.length, "Queued submission IDs must be distinct");
|
|
23862
24042
|
var remoteDeliveryReplySchema = external_exports.discriminatedUnion("accepted", [
|
|
23863
24043
|
external_exports.object({ accepted: external_exports.literal(true), startQueuedItemId: identity.optional() }),
|
|
23864
24044
|
external_exports.object({
|
|
@@ -23878,6 +24058,7 @@ var remoteQueueSnapshotSchema = external_exports.discriminatedUnion("available",
|
|
|
23878
24058
|
external_exports.object({ available: external_exports.literal(false) }),
|
|
23879
24059
|
external_exports.object({
|
|
23880
24060
|
available: external_exports.literal(true),
|
|
24061
|
+
canReorder: external_exports.literal(true).optional(),
|
|
23881
24062
|
items: external_exports.array(external_exports.object({ id: identity, clientUserMessageId: identity, preview: external_exports.string().max(801) })).max(100)
|
|
23882
24063
|
})
|
|
23883
24064
|
]);
|
|
@@ -23955,6 +24136,7 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
|
23955
24136
|
external_exports.strictObject({ kind: external_exports.literal("enqueue"), ...input2 }),
|
|
23956
24137
|
external_exports.strictObject({ kind: external_exports.literal("steer"), ...input2, turnId: identity }),
|
|
23957
24138
|
external_exports.strictObject({ kind: external_exports.literal("remove"), itemId: identity }),
|
|
24139
|
+
external_exports.strictObject({ kind: external_exports.literal("reorder"), itemIds: queueReorderItemIdsSchema }),
|
|
23958
24140
|
external_exports.strictObject({
|
|
23959
24141
|
kind: external_exports.literal("start"),
|
|
23960
24142
|
itemId: identity,
|
|
@@ -24743,9 +24925,9 @@ async function jsonlHeader(file2, match, signal, maxLines = 4) {
|
|
|
24743
24925
|
continue;
|
|
24744
24926
|
}
|
|
24745
24927
|
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
24746
|
-
const
|
|
24747
|
-
if (match(
|
|
24748
|
-
return
|
|
24928
|
+
const record4 = value;
|
|
24929
|
+
if (match(record4))
|
|
24930
|
+
return record4;
|
|
24749
24931
|
}
|
|
24750
24932
|
}
|
|
24751
24933
|
return null;
|
|
@@ -24756,6 +24938,7 @@ function nativeTimeMs(value) {
|
|
|
24756
24938
|
}
|
|
24757
24939
|
|
|
24758
24940
|
// dist/session-import.js
|
|
24941
|
+
import { randomUUID } from "node:crypto";
|
|
24759
24942
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
24760
24943
|
import { opendir, realpath, stat } from "node:fs/promises";
|
|
24761
24944
|
import os2 from "node:os";
|
|
@@ -24985,7 +25168,17 @@ var OmpSessionImport = class {
|
|
|
24985
25168
|
if (sources?.length !== 1 || !sources[0])
|
|
24986
25169
|
return null;
|
|
24987
25170
|
const source = await this.#source(sources[0].file, signal);
|
|
24988
|
-
|
|
25171
|
+
if (!source || source.candidate.nativeSessionId !== nativeSessionId)
|
|
25172
|
+
return null;
|
|
25173
|
+
return {
|
|
25174
|
+
candidate: source.candidate,
|
|
25175
|
+
nativeRef: nativeSessionRefSchema.parse({
|
|
25176
|
+
harnessId: "omp",
|
|
25177
|
+
nativeSessionId,
|
|
25178
|
+
formatVersion: 1,
|
|
25179
|
+
locator: { sessionFile: source.file, speedScope: randomUUID() }
|
|
25180
|
+
})
|
|
25181
|
+
};
|
|
24989
25182
|
});
|
|
24990
25183
|
}
|
|
24991
25184
|
close() {
|
|
@@ -25027,9 +25220,9 @@ var OmpSessionImport = class {
|
|
|
25027
25220
|
const source = await this.#source(file2, signal);
|
|
25028
25221
|
if (!source)
|
|
25029
25222
|
continue;
|
|
25030
|
-
const sources = found.get(source.
|
|
25223
|
+
const sources = found.get(source.candidate.nativeSessionId) ?? [];
|
|
25031
25224
|
sources.push(source);
|
|
25032
|
-
found.set(source.
|
|
25225
|
+
found.set(source.candidate.nativeSessionId, sources);
|
|
25033
25226
|
} catch (error62) {
|
|
25034
25227
|
if (!(error62 instanceof SessionImportChangedError))
|
|
25035
25228
|
throw error62;
|
|
@@ -25058,17 +25251,7 @@ var OmpSessionImport = class {
|
|
|
25058
25251
|
});
|
|
25059
25252
|
if (!candidate)
|
|
25060
25253
|
return null;
|
|
25061
|
-
return {
|
|
25062
|
-
file: file2,
|
|
25063
|
-
candidate,
|
|
25064
|
-
// Resume needs the file itself: OMP is started with `--session <file>`.
|
|
25065
|
-
nativeRef: nativeSessionRefSchema.parse({
|
|
25066
|
-
harnessId: "omp",
|
|
25067
|
-
nativeSessionId: facts.nativeSessionId,
|
|
25068
|
-
locator: { sessionFile: await realpath(file2) },
|
|
25069
|
-
formatVersion: 1
|
|
25070
|
-
})
|
|
25071
|
-
};
|
|
25254
|
+
return { file: await realpath(file2), candidate };
|
|
25072
25255
|
} catch (error62) {
|
|
25073
25256
|
signal.throwIfAborted();
|
|
25074
25257
|
if (isStorageAccessError(error62))
|
|
@@ -25112,16 +25295,28 @@ function readableId({ provider, id: id2 }) {
|
|
|
25112
25295
|
function modelLabel({ provider, id: id2 }) {
|
|
25113
25296
|
return `${provider} / ${id2}`;
|
|
25114
25297
|
}
|
|
25298
|
+
function supportsOmpChatGptFast(model2) {
|
|
25299
|
+
return model2.provider === "openai-codex" && model2.api === "openai-codex-responses" && model2.fastEligible !== false && /^gpt(?:[-.]|$)/iu.test(model2.id) && (!model2.serviceTiers?.length || model2.serviceTiers.includes("priority"));
|
|
25300
|
+
}
|
|
25115
25301
|
function encodedId({ provider, id: id2 }) {
|
|
25116
25302
|
return `${OMP_MODEL_REF_PREFIX}${Buffer.from(JSON.stringify([provider, id2])).toString("base64url")}`;
|
|
25117
25303
|
}
|
|
25118
25304
|
function encodeOmpModelRef(model2, id2 = readableId(model2)) {
|
|
25119
25305
|
assertNativePart(model2.provider, "Model provider");
|
|
25120
25306
|
assertNativePart(model2.id, "Model id");
|
|
25121
|
-
return harnessModelRefSchema.parse({
|
|
25307
|
+
return harnessModelRefSchema.parse({
|
|
25308
|
+
id: id2,
|
|
25309
|
+
...model2.serviceTier && { serviceTier: model2.serviceTier }
|
|
25310
|
+
});
|
|
25122
25311
|
}
|
|
25123
25312
|
function createOmpModelIndex(models) {
|
|
25124
|
-
const entries =
|
|
25313
|
+
const entries = /* @__PURE__ */ new Map();
|
|
25314
|
+
for (const entry of models) {
|
|
25315
|
+
const pair = JSON.stringify([entry.provider, entry.id]);
|
|
25316
|
+
if (entry.api || entry.serviceTiers || !entries.has(pair)) {
|
|
25317
|
+
entries.set(pair, { ...entry, model: entry.id });
|
|
25318
|
+
}
|
|
25319
|
+
}
|
|
25125
25320
|
const byId = compositeModelRefIds([...entries.values()], (entry) => encodedId(entry));
|
|
25126
25321
|
const idsByPair = new Map([...byId].map(([id2, entry]) => [JSON.stringify([entry.provider, entry.model]), id2]));
|
|
25127
25322
|
return {
|
|
@@ -25135,13 +25330,17 @@ function createOmpModelIndex(models) {
|
|
|
25135
25330
|
}
|
|
25136
25331
|
function resolveOmpModelRef(ref, index) {
|
|
25137
25332
|
const model2 = index.byId.get(ref.id);
|
|
25138
|
-
if (!model2 || ref.serviceTier) {
|
|
25333
|
+
if (!model2 || ref.serviceTier && (ref.serviceTier !== "priority" || !supportsOmpChatGptFast(model2))) {
|
|
25139
25334
|
throw new Error("Model Ref is not in the current Omp Model catalog");
|
|
25140
25335
|
}
|
|
25141
|
-
return {
|
|
25336
|
+
return {
|
|
25337
|
+
provider: model2.provider,
|
|
25338
|
+
id: model2.id,
|
|
25339
|
+
...ref.serviceTier && { serviceTier: ref.serviceTier }
|
|
25340
|
+
};
|
|
25142
25341
|
}
|
|
25143
25342
|
function normalizeStoredOmpModelRef(ref, catalog) {
|
|
25144
|
-
if (!ref.id.startsWith(OMP_MODEL_REF_PREFIX)
|
|
25343
|
+
if (!ref.id.startsWith(OMP_MODEL_REF_PREFIX))
|
|
25145
25344
|
return void 0;
|
|
25146
25345
|
let tuple2;
|
|
25147
25346
|
try {
|
|
@@ -25156,7 +25355,10 @@ function normalizeStoredOmpModelRef(ref, catalog) {
|
|
|
25156
25355
|
if (encoded !== ref.id)
|
|
25157
25356
|
return void 0;
|
|
25158
25357
|
const readable = readableId(native);
|
|
25159
|
-
|
|
25358
|
+
const base = catalog.models.find(({ ref: ref2, label }) => !ref2.serviceTier && (ref2.id === encoded || ref2.id === readable && label === modelLabel(native)));
|
|
25359
|
+
if (!base || !ref.serviceTier)
|
|
25360
|
+
return base?.ref;
|
|
25361
|
+
return ref.serviceTier === "priority" ? base.fastModel : void 0;
|
|
25160
25362
|
}
|
|
25161
25363
|
function sameOmpModel(left, right) {
|
|
25162
25364
|
return left === null ? right === null : right !== null && left.provider === right.provider && left.id === right.id;
|
|
@@ -25171,7 +25373,7 @@ function normalizeOmpThinkingOptions(levels) {
|
|
|
25171
25373
|
label: OMP_THINKING_LABELS[id2] ?? fallbackThinkingLabel(id2)
|
|
25172
25374
|
}));
|
|
25173
25375
|
}
|
|
25174
|
-
function normalizeOmpModelCatalog(nativeModels, effectiveModel, thinkingLevels, effectiveThinkingOptionId) {
|
|
25376
|
+
function normalizeOmpModelCatalog(nativeModels, effectiveModel, thinkingLevels, effectiveThinkingOptionId, speedAvailable = false) {
|
|
25175
25377
|
const index = createOmpModelIndex(nativeModels);
|
|
25176
25378
|
const byRef = /* @__PURE__ */ new Map();
|
|
25177
25379
|
for (const native of nativeModels) {
|
|
@@ -25181,17 +25383,14 @@ function normalizeOmpModelCatalog(nativeModels, effectiveModel, thinkingLevels,
|
|
|
25181
25383
|
if (existing.reasoning !== native.reasoning) {
|
|
25182
25384
|
throw new Error("Omp duplicate Model entries disagree on reasoning capability");
|
|
25183
25385
|
}
|
|
25386
|
+
if (supportsOmpChatGptFast(existing) !== supportsOmpChatGptFast(native)) {
|
|
25387
|
+
throw new Error("Omp duplicate Model entries disagree on service tiers");
|
|
25388
|
+
}
|
|
25184
25389
|
continue;
|
|
25185
25390
|
}
|
|
25186
|
-
byRef.set(ref.id,
|
|
25187
|
-
model: {
|
|
25188
|
-
ref,
|
|
25189
|
-
label: modelLabel(native)
|
|
25190
|
-
},
|
|
25191
|
-
reasoning: native.reasoning
|
|
25192
|
-
});
|
|
25391
|
+
byRef.set(ref.id, native);
|
|
25193
25392
|
}
|
|
25194
|
-
const defaultModel = effectiveModel ? index.ref(effectiveModel) : void 0;
|
|
25393
|
+
const defaultModel = effectiveModel ? index.ref({ provider: effectiveModel.provider, id: effectiveModel.id }) : void 0;
|
|
25195
25394
|
if (defaultModel && !byRef.has(defaultModel.id)) {
|
|
25196
25395
|
throw new Error("Omp effective Model is absent from the available Model catalog");
|
|
25197
25396
|
}
|
|
@@ -25204,9 +25403,11 @@ function normalizeOmpModelCatalog(nativeModels, effectiveModel, thinkingLevels,
|
|
|
25204
25403
|
const thinkingOptions = thinkingLevels ? normalizeOmpThinkingOptions(OMP_DRAFT_THINKING_OPTION_IDS) : [];
|
|
25205
25404
|
const allThinkingOptionIds = thinkingOptions.map(({ id: id2 }) => id2);
|
|
25206
25405
|
const offThinkingOptionId = thinkingOptions.find(({ id: id2 }) => id2 === "off")?.id;
|
|
25207
|
-
const models = [...byRef
|
|
25208
|
-
|
|
25209
|
-
|
|
25406
|
+
const models = [...byRef].map(([id2, native]) => ({
|
|
25407
|
+
ref: { id: id2 },
|
|
25408
|
+
label: modelLabel(native),
|
|
25409
|
+
...speedAvailable && supportsOmpChatGptFast(native) ? { fastModel: { id: id2, serviceTier: "priority" } } : {},
|
|
25410
|
+
supportedThinkingOptionIds: native.reasoning ? allThinkingOptionIds : offThinkingOptionId ? [offThinkingOptionId] : []
|
|
25210
25411
|
})).sort((left, right) => compareText(left.label, right.label) || compareText(left.ref.id, right.ref.id));
|
|
25211
25412
|
const defaultThinkingOptionId = thinkingOptions.find(({ id: id2 }) => id2 === effectiveThinkingOptionId)?.id;
|
|
25212
25413
|
return harnessModelCatalogSchema.parse({
|
|
@@ -25629,10 +25830,10 @@ function ompUsageHistory(history) {
|
|
|
25629
25830
|
for (const entry of history.entries) {
|
|
25630
25831
|
if (entry.type !== "message")
|
|
25631
25832
|
continue;
|
|
25632
|
-
const
|
|
25633
|
-
if (
|
|
25634
|
-
requests.push(
|
|
25635
|
-
else if (
|
|
25833
|
+
const record4 = ompUsageRecord(entry.message, { historical: true });
|
|
25834
|
+
if (record4?.kind === "request")
|
|
25835
|
+
requests.push(record4.request);
|
|
25836
|
+
else if (record4?.kind === "missing")
|
|
25636
25837
|
complete = false;
|
|
25637
25838
|
}
|
|
25638
25839
|
return { requests, complete };
|
|
@@ -25641,8 +25842,8 @@ function ompUsageHistory(history) {
|
|
|
25641
25842
|
// dist/omp-usage-statistics.js
|
|
25642
25843
|
async function readOmpUsage(file2, signal) {
|
|
25643
25844
|
const entries = [];
|
|
25644
|
-
const header = await jsonlHeader(file2, (
|
|
25645
|
-
const titled = await jsonlHeader(file2, (
|
|
25845
|
+
const header = await jsonlHeader(file2, (record4) => record4.type === "session", signal);
|
|
25846
|
+
const titled = await jsonlHeader(file2, (record4) => record4.type === "title", signal);
|
|
25646
25847
|
const session = {
|
|
25647
25848
|
sessionId: typeof header?.id === "string" ? header.id : void 0,
|
|
25648
25849
|
cwd: typeof header?.cwd === "string" ? header.cwd : void 0,
|
|
@@ -25651,12 +25852,12 @@ async function readOmpUsage(file2, signal) {
|
|
|
25651
25852
|
for await (const line of jsonlRecords(file2, '"assistant"', signal)) {
|
|
25652
25853
|
if (line.type !== "message")
|
|
25653
25854
|
continue;
|
|
25654
|
-
const
|
|
25655
|
-
if (
|
|
25855
|
+
const record4 = ompUsageRecord(line.message);
|
|
25856
|
+
if (record4?.kind !== "request")
|
|
25656
25857
|
continue;
|
|
25657
25858
|
const message3 = line.message;
|
|
25658
25859
|
const at = nativeTimeMs(message3.timestamp) ?? nativeTimeMs(line.timestamp);
|
|
25659
|
-
const entry = at !== null && usageEntryFromRequest(
|
|
25860
|
+
const entry = at !== null && usageEntryFromRequest(record4.request, at);
|
|
25660
25861
|
if (!entry)
|
|
25661
25862
|
continue;
|
|
25662
25863
|
if (!(typeof message3.responseId === "string" && message3.responseId.length > 0)) {
|
|
@@ -25707,8 +25908,8 @@ function resolveOmpExecutable(input3, dependencies = {}) {
|
|
|
25707
25908
|
|
|
25708
25909
|
// dist/omp-rpc-session.js
|
|
25709
25910
|
import { spawn, spawnSync } from "node:child_process";
|
|
25710
|
-
import { randomUUID } from "node:crypto";
|
|
25711
|
-
import
|
|
25911
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
25912
|
+
import path7 from "node:path";
|
|
25712
25913
|
|
|
25713
25914
|
// dist/omp-slash-commands.js
|
|
25714
25915
|
var OMP_LIVE_COMMAND_ID_PREFIX = "omp.slash.";
|
|
@@ -25740,6 +25941,121 @@ function ompLiveCommands(native) {
|
|
|
25740
25941
|
}));
|
|
25741
25942
|
}
|
|
25742
25943
|
|
|
25944
|
+
// dist/omp-native-extension.js
|
|
25945
|
+
import { createHash, createHmac, randomUUID as randomUUID2 } from "node:crypto";
|
|
25946
|
+
import { mkdir, readFile, rename, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
25947
|
+
import { homedir as homedir2 } from "node:os";
|
|
25948
|
+
import path6 from "node:path";
|
|
25949
|
+
var hookKeyEnv = "CODEXHOST_OMP_RPC_KEY";
|
|
25950
|
+
var hookStatus = "codexhost.rpc.v1";
|
|
25951
|
+
function proof(key, ...parts) {
|
|
25952
|
+
return createHmac("sha256", key).update(JSON.stringify(parts)).digest("base64url");
|
|
25953
|
+
}
|
|
25954
|
+
var record3 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
25955
|
+
function eligibleWireRoute(model2) {
|
|
25956
|
+
if (model2.providerType != null && model2.providerType !== "openai-codex")
|
|
25957
|
+
return false;
|
|
25958
|
+
if (model2.transport != null)
|
|
25959
|
+
return false;
|
|
25960
|
+
if (model2.requestModelId != null && (typeof model2.requestModelId !== "string" || !/^gpt(?:[-.]|$)/iu.test(model2.requestModelId)))
|
|
25961
|
+
return false;
|
|
25962
|
+
if (model2.accountAccess == null)
|
|
25963
|
+
return true;
|
|
25964
|
+
return record3(model2.accountAccess) && Object.values(model2.accountAccess).every((access) => {
|
|
25965
|
+
if (!record3(access))
|
|
25966
|
+
return false;
|
|
25967
|
+
const tiers = access.serviceTiers;
|
|
25968
|
+
return tiers == null || Array.isArray(tiers) && (tiers.length === 0 || tiers.includes("priority"));
|
|
25969
|
+
});
|
|
25970
|
+
}
|
|
25971
|
+
var routeFields = [
|
|
25972
|
+
"provider",
|
|
25973
|
+
"api",
|
|
25974
|
+
"id",
|
|
25975
|
+
"requestModelId",
|
|
25976
|
+
"baseUrl",
|
|
25977
|
+
"providerType",
|
|
25978
|
+
"transport",
|
|
25979
|
+
"headers",
|
|
25980
|
+
"serviceTiers",
|
|
25981
|
+
"accountAccess"
|
|
25982
|
+
];
|
|
25983
|
+
function requestScope(key, session, file2, model2) {
|
|
25984
|
+
return proof(key, "request", session, file2, ...routeFields.map((field2) => model2[field2] ?? null));
|
|
25985
|
+
}
|
|
25986
|
+
var ompHookSource = `import { createHmac } from "node:crypto";
|
|
25987
|
+
const key = process.env.${hookKeyEnv};
|
|
25988
|
+
delete process.env.${hookKeyEnv};
|
|
25989
|
+
const sign = (...parts) => createHmac("sha256", key).update(JSON.stringify(parts)).digest("base64url");
|
|
25990
|
+
const fields = ${JSON.stringify(routeFields)};
|
|
25991
|
+
const main = ctx => ctx.mode === "rpc" && ctx.agent?.kind === "main";
|
|
25992
|
+
export default function(pi) {
|
|
25993
|
+
if (!key) return;
|
|
25994
|
+
let durableSession;
|
|
25995
|
+
pi.on("before_agent_start", async (event, ctx) => {
|
|
25996
|
+
if (event.reason !== "prompt" || !main(ctx)) return;
|
|
25997
|
+
const manager = ctx.sessionManager;
|
|
25998
|
+
const file = manager.getSessionFile();
|
|
25999
|
+
const id = manager.getSessionId();
|
|
26000
|
+
if (!file || durableSession === id || !manager.ensureOnDisk) return;
|
|
26001
|
+
await manager.ensureOnDisk();
|
|
26002
|
+
ctx.ui.setStatus("${hookStatus}", sign("durable", id, file));
|
|
26003
|
+
durableSession = id;
|
|
26004
|
+
});
|
|
26005
|
+
const version = /^(\\d+)\\.(\\d+)\\.(\\d+)(?:\\+[^-]+)?$/.exec(pi.pi?.VERSION);
|
|
26006
|
+
if (!version) return;
|
|
26007
|
+
const [major, minor, patch] = version.slice(1).map(Number);
|
|
26008
|
+
if (major < 19 || (major === 19 && (minor < 4 || (minor === 4 && patch < 1)))) return;
|
|
26009
|
+
const status = state => (_event, ctx) => { if (main(ctx)) ctx.ui.setStatus("${hookStatus}", sign(state)); };
|
|
26010
|
+
pi.on("session_start", status("ready"));
|
|
26011
|
+
pi.on("session_switch", status("ready"));
|
|
26012
|
+
pi.on("session_shutdown", status("shutdown"));
|
|
26013
|
+
const title = sign("select");
|
|
26014
|
+
pi.on("before_provider_request", async ({payload}, ctx) => {
|
|
26015
|
+
const m = ctx.model;
|
|
26016
|
+
if (!main(ctx) || m?.provider !== "openai-codex" || m.api !== "openai-codex-responses" ||
|
|
26017
|
+
!/^gpt(?:[-.]|$)/i.test(m.id) || payload?.model !== (m.requestModelId ?? m.id)) return;
|
|
26018
|
+
const scope = sign("request", ctx.sessionManager.getSessionId(), ctx.sessionManager.getSessionFile() ?? null,
|
|
26019
|
+
...fields.map(field => m[field] ?? null));
|
|
26020
|
+
const missed = () => ctx.ui.setStatus("${hookStatus}", sign("missed", scope));
|
|
26021
|
+
let lane;
|
|
26022
|
+
try {
|
|
26023
|
+
lane = await ctx.ui.input(title, scope, { timeout: 2000, onTimeout: missed });
|
|
26024
|
+
} catch {
|
|
26025
|
+
missed();
|
|
26026
|
+
}
|
|
26027
|
+
if (lane === "priority") return { ...payload, service_tier: "priority" };
|
|
26028
|
+
});
|
|
26029
|
+
}
|
|
26030
|
+
`;
|
|
26031
|
+
var digest = createHash("sha256").update(ompHookSource).digest("hex");
|
|
26032
|
+
async function ensureOmpHook(environment) {
|
|
26033
|
+
const data = environment.CODEXHOST_DATA_DIR ?? path6.join(environment.HOME ?? environment.USERPROFILE ?? homedir2(), ".codexhost");
|
|
26034
|
+
const directory = path6.resolve(data, "extensions", "omp-rpc");
|
|
26035
|
+
const file2 = path6.join(directory, `${digest}.js`);
|
|
26036
|
+
const matches = async () => await readFile(file2, "utf8").catch((error62) => {
|
|
26037
|
+
if (error62.code === "ENOENT")
|
|
26038
|
+
return null;
|
|
26039
|
+
throw error62;
|
|
26040
|
+
}) === ompHookSource;
|
|
26041
|
+
if (await matches())
|
|
26042
|
+
return file2;
|
|
26043
|
+
await mkdir(directory, { recursive: true, mode: 448 });
|
|
26044
|
+
const temporary = `${file2}.${randomUUID2()}.tmp`;
|
|
26045
|
+
try {
|
|
26046
|
+
await writeFile2(temporary, ompHookSource, { flag: "wx", mode: 384 });
|
|
26047
|
+
try {
|
|
26048
|
+
await rename(temporary, file2);
|
|
26049
|
+
} catch (error62) {
|
|
26050
|
+
if (!await matches())
|
|
26051
|
+
throw error62;
|
|
26052
|
+
}
|
|
26053
|
+
} finally {
|
|
26054
|
+
await rm2(temporary, { force: true });
|
|
26055
|
+
}
|
|
26056
|
+
return file2;
|
|
26057
|
+
}
|
|
26058
|
+
|
|
25743
26059
|
// dist/omp-session-file.js
|
|
25744
26060
|
import { createReadStream as createReadStream3 } from "node:fs";
|
|
25745
26061
|
import { open as open2, realpath as realpath2 } from "node:fs/promises";
|
|
@@ -25801,7 +26117,8 @@ async function readOmpSessionHistory(sessionFile, maxBytes) {
|
|
|
25801
26117
|
continue;
|
|
25802
26118
|
}
|
|
25803
26119
|
entries.push(entry);
|
|
25804
|
-
|
|
26120
|
+
if (entry.type !== "model_usage")
|
|
26121
|
+
leafId = entry.id;
|
|
25805
26122
|
}
|
|
25806
26123
|
return { entries, leafId, ...incomplete ? { incomplete: true } : {} };
|
|
25807
26124
|
}
|
|
@@ -25988,7 +26305,18 @@ function sessionStateData(response) {
|
|
|
25988
26305
|
throw new OmpRpcFaultError("protocolError", "Omp RPC state response has no data");
|
|
25989
26306
|
return data;
|
|
25990
26307
|
}
|
|
25991
|
-
function
|
|
26308
|
+
function fastMetadata(model2) {
|
|
26309
|
+
const { serviceTiers } = model2;
|
|
26310
|
+
if (serviceTiers != null && !(Array.isArray(serviceTiers) && serviceTiers.every(nonBlankString))) {
|
|
26311
|
+
throw new OmpRpcFaultError("protocolError", "Omp RPC Model contains invalid service tiers");
|
|
26312
|
+
}
|
|
26313
|
+
return {
|
|
26314
|
+
...nonBlankString(model2.api) && { api: model2.api },
|
|
26315
|
+
...serviceTiers != null && { serviceTiers },
|
|
26316
|
+
...model2.provider === "openai-codex" && !eligibleWireRoute(model2) && { fastEligible: false }
|
|
26317
|
+
};
|
|
26318
|
+
}
|
|
26319
|
+
function parseSessionState(response, key) {
|
|
25992
26320
|
const data = sessionStateData(response);
|
|
25993
26321
|
const model2 = parseNativeModel(data.model, "state");
|
|
25994
26322
|
if (!nonBlankString(data.sessionId)) {
|
|
@@ -26003,16 +26331,25 @@ function parseSessionState(response) {
|
|
|
26003
26331
|
const parsed = harnessThinkingOptionIdSchema.safeParse(level);
|
|
26004
26332
|
return parsed.success ? [parsed.data] : [];
|
|
26005
26333
|
}) : null;
|
|
26334
|
+
const metadata = isRecord8(data.model) ? fastMetadata(data.model) : {};
|
|
26335
|
+
const file2 = typeof data.sessionFile === "string" ? data.sessionFile : null;
|
|
26336
|
+
const eligible = model2 && supportsOmpChatGptFast({ ...model2, ...metadata });
|
|
26006
26337
|
return {
|
|
26007
26338
|
sessionId: data.sessionId,
|
|
26008
|
-
sessionFile:
|
|
26339
|
+
sessionFile: file2,
|
|
26009
26340
|
provider: model2?.provider ?? null,
|
|
26010
26341
|
modelId: model2?.id ?? null,
|
|
26342
|
+
...metadata,
|
|
26343
|
+
...eligible && isRecord8(data.model) && { fastScope: requestScope(key, data.sessionId, file2, data.model) },
|
|
26344
|
+
...eligible && typeof data.fastModeEnabled === "boolean" && { fastModeEnabled: data.fastModeEnabled },
|
|
26011
26345
|
thinkingLevel: thinkingLevel?.data ?? null,
|
|
26012
26346
|
contextUsage: optionalOmpStateContextUsage(data.contextUsage),
|
|
26013
26347
|
availableThinkingLevels
|
|
26014
26348
|
};
|
|
26015
26349
|
}
|
|
26350
|
+
function isOmpNativeSpeedMutation(text3) {
|
|
26351
|
+
return /^\s*\/(?:fast|ultrafast)(?=$|[:\s])(?![\s:]+status\s*$)|^\s*\/switch(?=$|[:\s])/iu.test(text3);
|
|
26352
|
+
}
|
|
26016
26353
|
function parseSessionStreaming(response) {
|
|
26017
26354
|
const isStreaming = sessionStateData(response).isStreaming;
|
|
26018
26355
|
if (typeof isStreaming !== "boolean") {
|
|
@@ -26034,7 +26371,7 @@ function parseAvailableModels(response) {
|
|
|
26034
26371
|
if (!parsed || !isRecord8(model2) || typeof model2.reasoning !== "boolean") {
|
|
26035
26372
|
throw new OmpRpcFaultError("protocolError", "Omp RPC catalog contains a Model without reasoning capability");
|
|
26036
26373
|
}
|
|
26037
|
-
return { ...parsed, reasoning: model2.reasoning };
|
|
26374
|
+
return { ...parsed, reasoning: model2.reasoning, ...fastMetadata(model2) };
|
|
26038
26375
|
});
|
|
26039
26376
|
}
|
|
26040
26377
|
function parseSubagentMessages(response) {
|
|
@@ -26144,11 +26481,12 @@ function ompRpcProcessCommand(options, dependencies = {}) {
|
|
|
26144
26481
|
"--mode",
|
|
26145
26482
|
// OMP only creates ask and connects its tool UI in rpc-ui mode.
|
|
26146
26483
|
"rpc-ui",
|
|
26484
|
+
...options.extensionFile ? ["--extension", options.extensionFile] : [],
|
|
26147
26485
|
...permissionArguments,
|
|
26148
26486
|
...modelArguments,
|
|
26149
26487
|
...sessionArguments
|
|
26150
26488
|
];
|
|
26151
|
-
const extension =
|
|
26489
|
+
const extension = path7.win32.extname(command).toLowerCase();
|
|
26152
26490
|
if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
|
|
26153
26491
|
return { command, arguments: arguments_, windowsVerbatimArguments: false };
|
|
26154
26492
|
}
|
|
@@ -26185,9 +26523,16 @@ var OmpRpcSession = class {
|
|
|
26185
26523
|
#compactionTurn = null;
|
|
26186
26524
|
#compactionTimeout = null;
|
|
26187
26525
|
#failed = false;
|
|
26526
|
+
#started = false;
|
|
26188
26527
|
#pending = /* @__PURE__ */ new Map();
|
|
26189
26528
|
#state = null;
|
|
26190
26529
|
#availableCommands = null;
|
|
26530
|
+
#settingFast = false;
|
|
26531
|
+
#hookKey = randomUUID3();
|
|
26532
|
+
#hookTitle = proof(this.#hookKey, "select");
|
|
26533
|
+
#hookReady = false;
|
|
26534
|
+
#durableProof = null;
|
|
26535
|
+
#fastScope;
|
|
26191
26536
|
#latestCacheHitRatePercent;
|
|
26192
26537
|
#manualCompaction = null;
|
|
26193
26538
|
#usageRequestStartedAtMs = null;
|
|
@@ -26228,18 +26573,28 @@ var OmpRpcSession = class {
|
|
|
26228
26573
|
get stderrTail() {
|
|
26229
26574
|
return this.#stderrTail;
|
|
26230
26575
|
}
|
|
26576
|
+
get speedAvailable() {
|
|
26577
|
+
return this.#hookReady && !this.#closed && !this.#failed;
|
|
26578
|
+
}
|
|
26231
26579
|
async start() {
|
|
26232
|
-
if (this.#
|
|
26580
|
+
if (this.#started || this.#closed)
|
|
26233
26581
|
throw new Error("Omp RPC Session cannot be started twice");
|
|
26582
|
+
this.#started = true;
|
|
26583
|
+
const environment = withNodeRuntimeOnPath({
|
|
26584
|
+
...process.env,
|
|
26585
|
+
...this.#options.environment,
|
|
26586
|
+
[hookKeyEnv]: this.#hookKey,
|
|
26587
|
+
OMP_SKIP_VERSION_CHECK: "1",
|
|
26588
|
+
OMP_TELEMETRY: "0"
|
|
26589
|
+
});
|
|
26590
|
+
const extensionFile = this.#processAdapter === nodeProcessAdapter ? await ensureOmpHook(environment) : void 0;
|
|
26591
|
+
if (this.#closed)
|
|
26592
|
+
throw new Error("Omp RPC Session closed during startup");
|
|
26234
26593
|
const child = this.#processAdapter.spawn({
|
|
26235
26594
|
cwd: this.#options.cwd,
|
|
26236
26595
|
...this.#options.command ? { command: this.#options.command } : {},
|
|
26237
|
-
environment
|
|
26238
|
-
|
|
26239
|
-
...this.#options.environment,
|
|
26240
|
-
OMP_SKIP_VERSION_CHECK: "1",
|
|
26241
|
-
OMP_TELEMETRY: "0"
|
|
26242
|
-
}),
|
|
26596
|
+
environment,
|
|
26597
|
+
...extensionFile && { extensionFile },
|
|
26243
26598
|
...this.#options.sessionFile ? { sessionFile: this.#options.sessionFile } : {},
|
|
26244
26599
|
...this.#options.forkSessionFile ? { forkSessionFile: this.#options.forkSessionFile } : {},
|
|
26245
26600
|
...this.#options.model ? { model: this.#options.model } : {},
|
|
@@ -26293,7 +26648,7 @@ var OmpRpcSession = class {
|
|
|
26293
26648
|
await this.#send("set_subagent_subscription", { level: "events" }).catch(() => void 0);
|
|
26294
26649
|
}
|
|
26295
26650
|
try {
|
|
26296
|
-
this.#state = parseSessionState(await this.#send("get_state", {}));
|
|
26651
|
+
this.#state = parseSessionState(await this.#send("get_state", {}), this.#hookKey);
|
|
26297
26652
|
} catch (error62) {
|
|
26298
26653
|
const fault = error62 instanceof OmpRpcFaultError ? error62 : new OmpRpcFaultError("unavailable", `Omp RPC state unavailable: ${message2(error62)}`);
|
|
26299
26654
|
this.#fail(fault);
|
|
@@ -26376,7 +26731,7 @@ var OmpRpcSession = class {
|
|
|
26376
26731
|
if (!this.#child || !this.#state || this.#closed || this.#failed) {
|
|
26377
26732
|
throw new Error("Omp RPC Session is unavailable");
|
|
26378
26733
|
}
|
|
26379
|
-
if (this.#activeTurn || this.#manualCompaction || this.#compactionActive) {
|
|
26734
|
+
if (this.#activeTurn || this.#settingFast || this.#manualCompaction || this.#compactionActive) {
|
|
26380
26735
|
throw new Error("Omp RPC Session already has an active operation");
|
|
26381
26736
|
}
|
|
26382
26737
|
const result = new Promise((resolve, reject) => {
|
|
@@ -26400,7 +26755,7 @@ var OmpRpcSession = class {
|
|
|
26400
26755
|
if (!(error62 instanceof OmpRpcUnsupportedCommandError))
|
|
26401
26756
|
throw error62;
|
|
26402
26757
|
const response = await this.#send("get_state", {});
|
|
26403
|
-
const observedState = parseSessionState(response);
|
|
26758
|
+
const observedState = parseSessionState(response, this.#hookKey);
|
|
26404
26759
|
if (!this.#state || observedState.sessionId !== this.#state.sessionId || observedState.provider !== this.#state.provider || observedState.modelId !== this.#state.modelId) {
|
|
26405
26760
|
throw new Error("Omp RPC Usage fallback does not match the confirmed Session state");
|
|
26406
26761
|
}
|
|
@@ -26422,6 +26777,8 @@ var OmpRpcSession = class {
|
|
|
26422
26777
|
return this.#latestCacheHitRatePercent === null || this.#latestCacheHitRatePercent === void 0 ? usage : parseHostUsage({ ...usage, cacheHitRatePercent: this.#latestCacheHitRatePercent });
|
|
26423
26778
|
}
|
|
26424
26779
|
async fork(entryId) {
|
|
26780
|
+
if (this.#settingFast)
|
|
26781
|
+
throw new Error("Omp RPC Session already has an active operation");
|
|
26425
26782
|
if (!nonBlankString(entryId))
|
|
26426
26783
|
throw new Error("Omp RPC Fork requires an Entry identity");
|
|
26427
26784
|
try {
|
|
@@ -26430,7 +26787,8 @@ var OmpRpcSession = class {
|
|
|
26430
26787
|
if (!data || data.cancelled === true) {
|
|
26431
26788
|
throw new OmpRpcFaultError("unavailable", "Omp RPC Fork was cancelled");
|
|
26432
26789
|
}
|
|
26433
|
-
this.#
|
|
26790
|
+
this.#releaseOverlay();
|
|
26791
|
+
this.#state = parseSessionState(await this.#send("get_state", {}), this.#hookKey);
|
|
26434
26792
|
return this.#state;
|
|
26435
26793
|
} catch (error62) {
|
|
26436
26794
|
if (error62 instanceof OmpRpcFaultError)
|
|
@@ -26458,18 +26816,84 @@ var OmpRpcSession = class {
|
|
|
26458
26816
|
return this.state.availableThinkingLevels;
|
|
26459
26817
|
}
|
|
26460
26818
|
async selectModel(model2) {
|
|
26819
|
+
if (this.#settingFast)
|
|
26820
|
+
throw new Error("Omp RPC Session already has an active operation");
|
|
26461
26821
|
await this.#send("set_model", { provider: model2.provider, modelId: model2.id });
|
|
26822
|
+
this.#releaseOverlay();
|
|
26462
26823
|
return this.#refreshState("Model");
|
|
26463
26824
|
}
|
|
26464
26825
|
async selectThinkingOption(thinkingOptionId) {
|
|
26826
|
+
if (this.#settingFast)
|
|
26827
|
+
throw new Error("Omp RPC Session already has an active operation");
|
|
26465
26828
|
const level = harnessThinkingOptionIdSchema.parse(thinkingOptionId);
|
|
26466
26829
|
await this.#send("set_thinking_level", { level });
|
|
26467
26830
|
return this.#refreshState("Thinking");
|
|
26468
26831
|
}
|
|
26469
|
-
async
|
|
26832
|
+
async selectSpeed(tier) {
|
|
26833
|
+
if (tier !== "priority" && tier !== null)
|
|
26834
|
+
throw new Error("Unsupported Omp speed");
|
|
26835
|
+
if (this.#manualCompaction || this.#compactionActive || this.#settingFast) {
|
|
26836
|
+
throw new Error("Omp RPC Session already has an active operation");
|
|
26837
|
+
}
|
|
26838
|
+
this.#settingFast = true;
|
|
26470
26839
|
try {
|
|
26471
|
-
|
|
26840
|
+
const active2 = this.#activeTurn;
|
|
26841
|
+
const previousScope = this.state.fastScope;
|
|
26842
|
+
const snapshot = await this.#send("get_state", {});
|
|
26843
|
+
if (this.state.fastScope !== previousScope)
|
|
26844
|
+
throw new Error("Omp Fast selection target changed");
|
|
26845
|
+
const state = this.#acceptState(parseSessionState(snapshot, this.#hookKey));
|
|
26846
|
+
const settled = sessionSettled(snapshot, true);
|
|
26847
|
+
if (this.#compactionActive || sessionStateData(snapshot).isCompacting === true || !this.#activeTurn && !settled) {
|
|
26848
|
+
throw new Error("Omp RPC Session is not idle");
|
|
26849
|
+
}
|
|
26850
|
+
if (active2 && (active2.nativeSpeedMutation || active2.cancellation !== "none")) {
|
|
26851
|
+
throw new Error("Omp RPC Session already has an active operation");
|
|
26852
|
+
}
|
|
26853
|
+
if (tier !== null || active2) {
|
|
26854
|
+
if (state.fastScope !== previousScope)
|
|
26855
|
+
throw new Error("Omp Fast selection target changed");
|
|
26856
|
+
if (!state.fastScope)
|
|
26857
|
+
throw new Error("Omp Fast requires an eligible ChatGPT Codex Model");
|
|
26858
|
+
if (!this.speedAvailable)
|
|
26859
|
+
throw new Error("Omp request-scoped Fast hook is unavailable");
|
|
26860
|
+
}
|
|
26861
|
+
if (tier === null) {
|
|
26862
|
+
this.#clearSelectedSpeed();
|
|
26863
|
+
return this.state;
|
|
26864
|
+
}
|
|
26865
|
+
this.#fastScope = state.fastScope;
|
|
26866
|
+
this.#state = { ...state, serviceTier: "priority" };
|
|
26472
26867
|
return this.#state;
|
|
26868
|
+
} finally {
|
|
26869
|
+
this.#settingFast = false;
|
|
26870
|
+
}
|
|
26871
|
+
}
|
|
26872
|
+
#releaseOverlay() {
|
|
26873
|
+
if (this.#activeTurn)
|
|
26874
|
+
this.#activeTurn.fastScope = void 0;
|
|
26875
|
+
this.#clearSelectedSpeed();
|
|
26876
|
+
}
|
|
26877
|
+
#clearSelectedSpeed() {
|
|
26878
|
+
this.#fastScope = void 0;
|
|
26879
|
+
if (this.#state?.serviceTier) {
|
|
26880
|
+
const { serviceTier: _, ...native } = this.#state;
|
|
26881
|
+
this.#state = native;
|
|
26882
|
+
}
|
|
26883
|
+
}
|
|
26884
|
+
#acceptState(state) {
|
|
26885
|
+
const eligibleScope = this.speedAvailable ? state.fastScope : void 0;
|
|
26886
|
+
if (this.#fastScope !== eligibleScope)
|
|
26887
|
+
this.#fastScope = void 0;
|
|
26888
|
+
if (this.#activeTurn && this.#activeTurn.fastScope !== eligibleScope) {
|
|
26889
|
+
this.#activeTurn.fastScope = void 0;
|
|
26890
|
+
}
|
|
26891
|
+
this.#state = this.#fastScope ? { ...state, serviceTier: "priority" } : state;
|
|
26892
|
+
return this.#state;
|
|
26893
|
+
}
|
|
26894
|
+
async #refreshState(operation) {
|
|
26895
|
+
try {
|
|
26896
|
+
return this.#acceptState(parseSessionState(await this.#send("get_state", {}), this.#hookKey));
|
|
26473
26897
|
} catch (error62) {
|
|
26474
26898
|
const fault = error62 instanceof OmpRpcFaultError ? error62 : new OmpRpcFaultError("protocolError", `Omp RPC ${operation} state could not be confirmed: ${message2(error62)}`);
|
|
26475
26899
|
this.#fail(fault);
|
|
@@ -26484,6 +26908,11 @@ var OmpRpcSession = class {
|
|
|
26484
26908
|
throw new Error("Omp steer text must not be empty");
|
|
26485
26909
|
const target2 = this.#activeTurn;
|
|
26486
26910
|
let targetEnded = false;
|
|
26911
|
+
if (isOmpNativeSpeedMutation(message3)) {
|
|
26912
|
+
if (target2)
|
|
26913
|
+
target2.nativeSpeedMutation = true;
|
|
26914
|
+
this.#releaseOverlay();
|
|
26915
|
+
}
|
|
26487
26916
|
const response = await this.#send("steer", { message: message3 }, void 0, () => {
|
|
26488
26917
|
targetEnded = target2 !== null && this.#activeTurn !== target2;
|
|
26489
26918
|
});
|
|
@@ -26504,14 +26933,20 @@ var OmpRpcSession = class {
|
|
|
26504
26933
|
if (!this.#child || !this.#state || this.#closed || this.#failed) {
|
|
26505
26934
|
throw new Error("Omp RPC Session is unavailable");
|
|
26506
26935
|
}
|
|
26507
|
-
if (this.#activeTurn)
|
|
26508
|
-
throw new Error("Omp RPC Session already has an active
|
|
26936
|
+
if (this.#activeTurn || this.#settingFast) {
|
|
26937
|
+
throw new Error("Omp RPC Session already has an active operation");
|
|
26938
|
+
}
|
|
26509
26939
|
if (text3.length === 0)
|
|
26510
26940
|
throw new Error("Omp text Turn must not be empty");
|
|
26511
|
-
const
|
|
26941
|
+
const nativeSpeedMutation = isOmpNativeSpeedMutation(text3);
|
|
26942
|
+
if (nativeSpeedMutation)
|
|
26943
|
+
this.#releaseOverlay();
|
|
26944
|
+
const promptId = `codexhost-${randomUUID3()}`;
|
|
26512
26945
|
const settled = new Promise((resolve, reject) => {
|
|
26513
26946
|
this.#activeTurn = {
|
|
26514
26947
|
promptId,
|
|
26948
|
+
fastScope: this.#fastScope,
|
|
26949
|
+
nativeSpeedMutation,
|
|
26515
26950
|
localResult: null,
|
|
26516
26951
|
text: "",
|
|
26517
26952
|
assistantMessageId: null,
|
|
@@ -26688,6 +27123,27 @@ var OmpRpcSession = class {
|
|
|
26688
27123
|
this.#readyResolve = null;
|
|
26689
27124
|
return;
|
|
26690
27125
|
}
|
|
27126
|
+
if (value.type === "extension_ui_request") {
|
|
27127
|
+
const scope = this.#activeTurn ? this.#activeTurn.fastScope : this.#fastScope;
|
|
27128
|
+
if (value.method === "setStatus" && value.statusKey === hookStatus) {
|
|
27129
|
+
if (value.statusText === proof(this.#hookKey, "ready"))
|
|
27130
|
+
this.#hookReady = true;
|
|
27131
|
+
else if (value.statusText === proof(this.#hookKey, "shutdown"))
|
|
27132
|
+
this.#hookReady = false;
|
|
27133
|
+
else if (scope && value.statusText === proof(this.#hookKey, "missed", scope)) {
|
|
27134
|
+
this.#releaseOverlay();
|
|
27135
|
+
this.#fail(new OmpRpcFaultError("protocolError", "Omp Fast request could not be confirmed"));
|
|
27136
|
+
} else if (this.#state?.sessionFile && value.statusText === proof(this.#hookKey, "durable", this.#state.sessionId, this.#state.sessionFile)) {
|
|
27137
|
+
this.#durableProof = value.statusText;
|
|
27138
|
+
}
|
|
27139
|
+
return;
|
|
27140
|
+
}
|
|
27141
|
+
if (value.method === "input" && value.title === this.#hookTitle && nonBlankString(value.id)) {
|
|
27142
|
+
const lane = this.speedAvailable && scope && value.placeholder === scope ? "priority" : "native";
|
|
27143
|
+
void this.#write({ type: "extension_ui_response", id: value.id, value: lane }).catch((error62) => this.#fail(new OmpRpcFaultError("processExited", `Omp request hook disconnected: ${message2(error62)}`)));
|
|
27144
|
+
return;
|
|
27145
|
+
}
|
|
27146
|
+
}
|
|
26691
27147
|
if (value.type === "response") {
|
|
26692
27148
|
this.#handleResponse(value);
|
|
26693
27149
|
return;
|
|
@@ -26743,6 +27199,9 @@ var OmpRpcSession = class {
|
|
|
26743
27199
|
this.#observeUsage(value);
|
|
26744
27200
|
if (value.type === "agent_start" && active2) {
|
|
26745
27201
|
active2.terminalEnd = false;
|
|
27202
|
+
if (!active2.sawAgentStart && (!this.#hookReady || this.state.sessionFile && this.#durableProof === proof(this.#hookKey, "durable", this.state.sessionId, this.state.sessionFile))) {
|
|
27203
|
+
active2.onEvent({ type: "agent.started" });
|
|
27204
|
+
}
|
|
26746
27205
|
active2.sawAgentStart = true;
|
|
26747
27206
|
}
|
|
26748
27207
|
if ((value.type === "session_settled" || value.type === "agent_start") && active2?.cancellation === "accepted") {
|
|
@@ -27151,11 +27610,12 @@ var OmpRpcSession = class {
|
|
|
27151
27610
|
return;
|
|
27152
27611
|
response = await this.#send("get_state", {});
|
|
27153
27612
|
}
|
|
27154
|
-
let state = parseSessionState(response);
|
|
27613
|
+
let state = parseSessionState(response, this.#hookKey);
|
|
27155
27614
|
if (this.#activeTurn !== active2 || active2.cancellation !== "accepted")
|
|
27156
27615
|
return;
|
|
27157
27616
|
const data = sessionStateData(response);
|
|
27158
27617
|
if (!active2.cancellationReloaded && state.sessionFile && state.sessionId === this.state.sessionId && state.sessionFile === this.state.sessionFile && data.isStreaming === false && data.isCompacting === false && data.queuedMessageCount === 0 && data.hasPendingAsyncWork === true && active2.tools.size === 0) {
|
|
27618
|
+
const previous = state;
|
|
27159
27619
|
await this.verifySessionCwd(this.#options.cwd);
|
|
27160
27620
|
if (this.#activeTurn !== active2)
|
|
27161
27621
|
return;
|
|
@@ -27172,9 +27632,8 @@ var OmpRpcSession = class {
|
|
|
27172
27632
|
if (!isRecord8(reloaded.data) || reloaded.data.cancelled !== false) {
|
|
27173
27633
|
throw new OmpRpcFaultError("unavailable", "Omp cancelled Session reload was refused");
|
|
27174
27634
|
}
|
|
27175
|
-
const previous = state;
|
|
27176
27635
|
response = await this.#send("get_state", {});
|
|
27177
|
-
state = parseSessionState(response);
|
|
27636
|
+
state = parseSessionState(response, this.#hookKey);
|
|
27178
27637
|
if (state.sessionId !== previous.sessionId || state.sessionFile !== previous.sessionFile) {
|
|
27179
27638
|
throw new OmpRpcFaultError("protocolError", "Omp cancelled Session reload changed its identity");
|
|
27180
27639
|
}
|
|
@@ -27187,9 +27646,11 @@ var OmpRpcSession = class {
|
|
|
27187
27646
|
if (previous.thinkingLevel && state.thinkingLevel !== previous.thinkingLevel) {
|
|
27188
27647
|
await this.#send("set_thinking_level", { level: previous.thinkingLevel });
|
|
27189
27648
|
}
|
|
27190
|
-
|
|
27191
|
-
|
|
27192
|
-
|
|
27649
|
+
if (state.provider !== previous.provider || state.modelId !== previous.modelId || state.thinkingLevel !== previous.thinkingLevel) {
|
|
27650
|
+
response = await this.#send("get_state", {});
|
|
27651
|
+
state = parseSessionState(response, this.#hookKey);
|
|
27652
|
+
}
|
|
27653
|
+
if (state.sessionId !== previous.sessionId || state.sessionFile !== previous.sessionFile || state.provider !== previous.provider || state.modelId !== previous.modelId || state.fastScope !== previous.fastScope || state.fastModeEnabled !== previous.fastModeEnabled || this.#fastScope !== void 0 && !this.speedAvailable || previous.thinkingLevel !== null && state.thinkingLevel !== previous.thinkingLevel) {
|
|
27193
27654
|
throw new OmpRpcFaultError("protocolError", "Omp cancelled Session reload changed its identity or configuration");
|
|
27194
27655
|
}
|
|
27195
27656
|
}
|
|
@@ -27201,7 +27662,9 @@ var OmpRpcSession = class {
|
|
|
27201
27662
|
}, 250);
|
|
27202
27663
|
return;
|
|
27203
27664
|
}
|
|
27204
|
-
this.#
|
|
27665
|
+
if (this.#activeTurn !== active2)
|
|
27666
|
+
return;
|
|
27667
|
+
this.#acceptState(state);
|
|
27205
27668
|
active2.settlement = "confirmed";
|
|
27206
27669
|
this.#finishSettledTurn(active2);
|
|
27207
27670
|
} catch (error62) {
|
|
@@ -27228,7 +27691,8 @@ var OmpRpcSession = class {
|
|
|
27228
27691
|
active2.settlement = "confirming";
|
|
27229
27692
|
try {
|
|
27230
27693
|
const response = await this.#send("get_state", {});
|
|
27231
|
-
const
|
|
27694
|
+
const settled = sessionSettled(response, hasTurnCompletion(active2));
|
|
27695
|
+
const state = parseSessionState(response, this.#hookKey);
|
|
27232
27696
|
if (this.#activeTurn !== active2)
|
|
27233
27697
|
return;
|
|
27234
27698
|
if (active2.cancellation !== "none") {
|
|
@@ -27242,7 +27706,7 @@ var OmpRpcSession = class {
|
|
|
27242
27706
|
active2.settledNotice = false;
|
|
27243
27707
|
return;
|
|
27244
27708
|
}
|
|
27245
|
-
if (!
|
|
27709
|
+
if (!settled) {
|
|
27246
27710
|
active2.settlement = "pending";
|
|
27247
27711
|
if (active2.settledNotice) {
|
|
27248
27712
|
active2.settledNotice = false;
|
|
@@ -27253,7 +27717,7 @@ var OmpRpcSession = class {
|
|
|
27253
27717
|
}
|
|
27254
27718
|
return;
|
|
27255
27719
|
}
|
|
27256
|
-
this.#state
|
|
27720
|
+
this.#acceptState(state);
|
|
27257
27721
|
active2.settlement = "confirmed";
|
|
27258
27722
|
this.#finishSettledTurn(active2);
|
|
27259
27723
|
} catch (error62) {
|
|
@@ -27303,7 +27767,7 @@ var OmpRpcSession = class {
|
|
|
27303
27767
|
if (active2.assistantMessageId !== null && active2.reasoningMessageOpen) {
|
|
27304
27768
|
active2.onEvent({ type: "reasoning.completed", messageId: active2.assistantMessageId });
|
|
27305
27769
|
}
|
|
27306
|
-
const messageId = assistantMessageId(value) ??
|
|
27770
|
+
const messageId = assistantMessageId(value) ?? randomUUID3();
|
|
27307
27771
|
active2.assistantMessageId = messageId;
|
|
27308
27772
|
active2.sawStreamedMessageText = false;
|
|
27309
27773
|
active2.sawStreamedMessageReasoning = false;
|
|
@@ -27356,7 +27820,7 @@ var OmpRpcSession = class {
|
|
|
27356
27820
|
child.stdin.write(frame, (error62) => error62 ? reject(error62) : resolve());
|
|
27357
27821
|
});
|
|
27358
27822
|
}
|
|
27359
|
-
#send(type, payload, id2 = `codexhost-${
|
|
27823
|
+
#send(type, payload, id2 = `codexhost-${randomUUID3()}`, onResponse) {
|
|
27360
27824
|
const child = this.#child;
|
|
27361
27825
|
if (!child?.stdin.writable || this.#closed || this.#failed) {
|
|
27362
27826
|
return Promise.reject(new Error("Omp RPC stdin is unavailable"));
|
|
@@ -27548,7 +28012,17 @@ function parseOmpModelList(output2) {
|
|
|
27548
28012
|
if (!isRecord9(model2) || !nonBlankString2(model2.provider) || !nonBlankString2(model2.id) || typeof model2.reasoning !== "boolean") {
|
|
27549
28013
|
return null;
|
|
27550
28014
|
}
|
|
27551
|
-
|
|
28015
|
+
const { serviceTiers } = model2;
|
|
28016
|
+
if (serviceTiers != null && !(Array.isArray(serviceTiers) && serviceTiers.every(nonBlankString2))) {
|
|
28017
|
+
return null;
|
|
28018
|
+
}
|
|
28019
|
+
models.push({
|
|
28020
|
+
provider: model2.provider,
|
|
28021
|
+
id: model2.id,
|
|
28022
|
+
...typeof model2.api === "string" && { api: model2.api },
|
|
28023
|
+
reasoning: model2.reasoning,
|
|
28024
|
+
...serviceTiers != null && { serviceTiers }
|
|
28025
|
+
});
|
|
27552
28026
|
}
|
|
27553
28027
|
return models;
|
|
27554
28028
|
}
|
|
@@ -27659,16 +28133,16 @@ var Diff = class {
|
|
|
27659
28133
|
}
|
|
27660
28134
|
}
|
|
27661
28135
|
}
|
|
27662
|
-
addToPath(
|
|
27663
|
-
const last =
|
|
28136
|
+
addToPath(path10, added, removed, oldPosInc, options) {
|
|
28137
|
+
const last = path10.lastComponent;
|
|
27664
28138
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
27665
28139
|
return {
|
|
27666
|
-
oldPos:
|
|
28140
|
+
oldPos: path10.oldPos + oldPosInc,
|
|
27667
28141
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
27668
28142
|
};
|
|
27669
28143
|
} else {
|
|
27670
28144
|
return {
|
|
27671
|
-
oldPos:
|
|
28145
|
+
oldPos: path10.oldPos + oldPosInc,
|
|
27672
28146
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
27673
28147
|
};
|
|
27674
28148
|
}
|
|
@@ -28080,9 +28554,9 @@ function splitLines(text3) {
|
|
|
28080
28554
|
}
|
|
28081
28555
|
|
|
28082
28556
|
// dist/omp-adapter.js
|
|
28083
|
-
import { createHash, randomUUID as
|
|
28557
|
+
import { createHash as createHash3, randomUUID as randomUUID5 } from "node:crypto";
|
|
28084
28558
|
import { realpath as realpath3, stat as stat2 } from "node:fs/promises";
|
|
28085
|
-
import
|
|
28559
|
+
import path8 from "node:path";
|
|
28086
28560
|
|
|
28087
28561
|
// dist/omp-account-credits.js
|
|
28088
28562
|
var CACHE_MS = 3e4;
|
|
@@ -28286,6 +28760,49 @@ async function rollbackOmpLastTurn(transport, sourceSessionId, cwd) {
|
|
|
28286
28760
|
return { ok: true };
|
|
28287
28761
|
}
|
|
28288
28762
|
|
|
28763
|
+
// dist/omp-speed-selection.js
|
|
28764
|
+
import { createHash as createHash2, randomUUID as randomUUID4 } from "node:crypto";
|
|
28765
|
+
import { open as open3, rename as rename2, rm as rm3, writeFile as writeFile3 } from "node:fs/promises";
|
|
28766
|
+
function selectionFile(sessionFile, scope) {
|
|
28767
|
+
const key = createHash2("sha256").update(scope).digest("hex");
|
|
28768
|
+
return `${sessionFile}.codexhost-speed-${key}`;
|
|
28769
|
+
}
|
|
28770
|
+
async function readOmpSpeedSelection(sessionFile, sessionId, scope) {
|
|
28771
|
+
let handle;
|
|
28772
|
+
try {
|
|
28773
|
+
handle = await open3(selectionFile(sessionFile, scope), "r");
|
|
28774
|
+
const { size } = await handle.stat();
|
|
28775
|
+
if (!size || size > 4096)
|
|
28776
|
+
return null;
|
|
28777
|
+
const { buffer, bytesRead } = await handle.read(Buffer.allocUnsafe(size));
|
|
28778
|
+
const record4 = JSON.parse(buffer.toString("utf8", 0, bytesRead));
|
|
28779
|
+
return record4?.sessionId === sessionId && typeof record4.fastModelId === "string" ? record4.fastModelId : null;
|
|
28780
|
+
} catch {
|
|
28781
|
+
return null;
|
|
28782
|
+
} finally {
|
|
28783
|
+
await handle?.close();
|
|
28784
|
+
}
|
|
28785
|
+
}
|
|
28786
|
+
async function writeOmpSpeedSelection(state, scope, fastModelId) {
|
|
28787
|
+
if (!state.sessionFile)
|
|
28788
|
+
return;
|
|
28789
|
+
const file2 = selectionFile(state.sessionFile, scope);
|
|
28790
|
+
if (fastModelId === null) {
|
|
28791
|
+
await rm3(file2, { force: true });
|
|
28792
|
+
return;
|
|
28793
|
+
}
|
|
28794
|
+
const temporary = `${file2}.${randomUUID4()}.tmp`;
|
|
28795
|
+
try {
|
|
28796
|
+
await writeFile3(temporary, JSON.stringify({ sessionId: state.sessionId, fastModelId }), {
|
|
28797
|
+
flag: "wx",
|
|
28798
|
+
mode: 384
|
|
28799
|
+
});
|
|
28800
|
+
await rename2(temporary, file2);
|
|
28801
|
+
} finally {
|
|
28802
|
+
await rm3(temporary, { force: true });
|
|
28803
|
+
}
|
|
28804
|
+
}
|
|
28805
|
+
|
|
28289
28806
|
// dist/omp-permission-modes.js
|
|
28290
28807
|
var nativePermissionModes = /* @__PURE__ */ new Set(["always-ask", "write", "yolo"]);
|
|
28291
28808
|
var OMP_DEFAULT_PERMISSION_MODE_ID = harnessPermissionModeIdSchema.parse("yolo");
|
|
@@ -28515,7 +29032,7 @@ function normalizedError(error62, fallbackCode) {
|
|
|
28515
29032
|
function invalidState(message3) {
|
|
28516
29033
|
return { code: "invalidState", message: message3, retryable: false };
|
|
28517
29034
|
}
|
|
28518
|
-
function
|
|
29035
|
+
function nativeModelForHistory(state) {
|
|
28519
29036
|
if (state.provider === null && state.modelId === null)
|
|
28520
29037
|
return null;
|
|
28521
29038
|
if (state.provider === null || state.modelId === null) {
|
|
@@ -28523,7 +29040,14 @@ function nativeModelFromState(state) {
|
|
|
28523
29040
|
}
|
|
28524
29041
|
return { provider: state.provider, id: state.modelId };
|
|
28525
29042
|
}
|
|
28526
|
-
function
|
|
29043
|
+
function nativeModelFromState(state) {
|
|
29044
|
+
const model2 = nativeModelForHistory(state);
|
|
29045
|
+
if (model2?.provider === "openai-codex" && state.serviceTier) {
|
|
29046
|
+
model2.serviceTier = state.serviceTier;
|
|
29047
|
+
}
|
|
29048
|
+
return model2;
|
|
29049
|
+
}
|
|
29050
|
+
function harnessStateFromOmp(state, thinkingLevels, index, permissionModeId, speedScope) {
|
|
28527
29051
|
const model2 = nativeModelFromState(state);
|
|
28528
29052
|
const effectiveModel = model2 ? index.ref(model2) : void 0;
|
|
28529
29053
|
const availableThinkingOptions = thinkingLevels ? normalizeOmpThinkingOptions(thinkingLevels) : void 0;
|
|
@@ -28531,12 +29055,14 @@ function harnessStateFromOmp(state, thinkingLevels, index, permissionModeId) {
|
|
|
28531
29055
|
throw new OmpRpcFaultError("protocolError", "Omp effective Thinking level is absent from its available levels");
|
|
28532
29056
|
}
|
|
28533
29057
|
return {
|
|
28534
|
-
|
|
28535
|
-
|
|
28536
|
-
|
|
28537
|
-
|
|
28538
|
-
|
|
28539
|
-
|
|
29058
|
+
...speedScope !== null ? {
|
|
29059
|
+
nativeRef: nativeSessionRefSchema.parse({
|
|
29060
|
+
harnessId: ompHarnessId2,
|
|
29061
|
+
nativeSessionId: state.sessionId,
|
|
29062
|
+
...state.sessionFile ? { locator: { sessionFile: state.sessionFile, speedScope } } : {},
|
|
29063
|
+
formatVersion: 1
|
|
29064
|
+
})
|
|
29065
|
+
} : {},
|
|
28540
29066
|
...effectiveModel ? { effectiveModel } : {},
|
|
28541
29067
|
...state.thinkingLevel ? { effectiveThinkingOptionId: state.thinkingLevel } : {},
|
|
28542
29068
|
...availableThinkingOptions ? { availableThinkingOptions } : {},
|
|
@@ -28556,8 +29082,89 @@ async function reconcileThinkingLevel(transport, state, thinkingLevels) {
|
|
|
28556
29082
|
thinkingLevels: await transport.getAvailableThinkingLevels()
|
|
28557
29083
|
};
|
|
28558
29084
|
}
|
|
28559
|
-
function
|
|
28560
|
-
|
|
29085
|
+
function validateOmpModel(ref) {
|
|
29086
|
+
const parsed = harnessModelRefSchema.parse(ref);
|
|
29087
|
+
if (parsed.serviceTier !== void 0 && parsed.serviceTier !== "priority") {
|
|
29088
|
+
throw new Error("Unsupported Omp service tier");
|
|
29089
|
+
}
|
|
29090
|
+
return parsed;
|
|
29091
|
+
}
|
|
29092
|
+
async function selectBaseModel(transport, model2) {
|
|
29093
|
+
if (!sameOmpModel(nativeModelForHistory(transport.state), model2)) {
|
|
29094
|
+
await transport.selectModel({ provider: model2.provider, id: model2.id });
|
|
29095
|
+
if (!sameOmpModel(nativeModelForHistory(transport.state), model2)) {
|
|
29096
|
+
throw new Error("Omp did not activate the requested Model");
|
|
29097
|
+
}
|
|
29098
|
+
}
|
|
29099
|
+
}
|
|
29100
|
+
async function selectOmpSpeed(transport, fast) {
|
|
29101
|
+
const tier = fast ? "priority" : null;
|
|
29102
|
+
const state = await transport.selectSpeed(tier);
|
|
29103
|
+
if (state.serviceTier === "priority" !== fast) {
|
|
29104
|
+
throw new Error("Omp did not activate the requested speed");
|
|
29105
|
+
}
|
|
29106
|
+
}
|
|
29107
|
+
async function restoreOmpSpeed(transport, fastModelId) {
|
|
29108
|
+
if (!transport.speedAvailable || transport.state.provider !== "openai-codex" || transport.state.modelId !== fastModelId)
|
|
29109
|
+
return null;
|
|
29110
|
+
try {
|
|
29111
|
+
await selectOmpSpeed(transport, true);
|
|
29112
|
+
return fastModelId;
|
|
29113
|
+
} catch (error62) {
|
|
29114
|
+
if (error62 instanceof OmpRpcFaultError)
|
|
29115
|
+
throw error62;
|
|
29116
|
+
if (transport.state.serviceTier === "priority")
|
|
29117
|
+
await selectOmpSpeed(transport, false);
|
|
29118
|
+
return null;
|
|
29119
|
+
}
|
|
29120
|
+
}
|
|
29121
|
+
async function applyOmpModel(transport, requested, ownedFastModelId, commit) {
|
|
29122
|
+
const oldModel = nativeModelForHistory(transport.state);
|
|
29123
|
+
const { serviceTier, thinkingLevel, fastScope } = transport.state;
|
|
29124
|
+
const fast = requested.serviceTier === "priority";
|
|
29125
|
+
if (fast && !transport.speedAvailable) {
|
|
29126
|
+
throw new OmpAdapterFaultError({
|
|
29127
|
+
code: "unsupported",
|
|
29128
|
+
message: "Omp speed selection is unavailable",
|
|
29129
|
+
retryable: false
|
|
29130
|
+
});
|
|
29131
|
+
}
|
|
29132
|
+
const changingModel = !sameOmpModel(oldModel, requested);
|
|
29133
|
+
let attemptedSpeed = false;
|
|
29134
|
+
try {
|
|
29135
|
+
let selection2 = changingModel ? null : ownedFastModelId;
|
|
29136
|
+
await selectBaseModel(transport, requested);
|
|
29137
|
+
if (transport.state.serviceTier === "priority" !== fast) {
|
|
29138
|
+
attemptedSpeed = true;
|
|
29139
|
+
await selectOmpSpeed(transport, fast);
|
|
29140
|
+
selection2 = fast ? requested.id : null;
|
|
29141
|
+
}
|
|
29142
|
+
await commit(selection2);
|
|
29143
|
+
} catch (error62) {
|
|
29144
|
+
if (error62 instanceof OmpRpcFaultError)
|
|
29145
|
+
throw error62;
|
|
29146
|
+
const switched = !sameOmpModel(nativeModelForHistory(transport.state), oldModel);
|
|
29147
|
+
if (!changingModel && (switched || fastScope !== transport.state.fastScope || serviceTier === transport.state.serviceTier && thinkingLevel === transport.state.thinkingLevel)) {
|
|
29148
|
+
throw error62;
|
|
29149
|
+
}
|
|
29150
|
+
try {
|
|
29151
|
+
if (switched && oldModel)
|
|
29152
|
+
await selectBaseModel(transport, oldModel);
|
|
29153
|
+
if (ownedFastModelId && (switched || attemptedSpeed))
|
|
29154
|
+
await selectOmpSpeed(transport, true);
|
|
29155
|
+
else if (attemptedSpeed && !switched)
|
|
29156
|
+
await selectOmpSpeed(transport, false);
|
|
29157
|
+
if (thinkingLevel && thinkingLevel !== transport.state.thinkingLevel) {
|
|
29158
|
+
await transport.selectThinkingOption(thinkingLevel);
|
|
29159
|
+
}
|
|
29160
|
+
if (!sameOmpModel(nativeModelForHistory(transport.state), oldModel) || serviceTier !== transport.state.serviceTier || thinkingLevel !== transport.state.thinkingLevel) {
|
|
29161
|
+
throw new Error("previous configuration was not restored");
|
|
29162
|
+
}
|
|
29163
|
+
} catch (rollbackError) {
|
|
29164
|
+
throw new OmpRpcFaultError("protocolError", `Omp Model selection failed (${errorMessage(error62)}) and could not be rolled back: ${errorMessage(rollbackError)}`);
|
|
29165
|
+
}
|
|
29166
|
+
throw error62;
|
|
29167
|
+
}
|
|
28561
29168
|
}
|
|
28562
29169
|
function sessionFileFromRef(ref) {
|
|
28563
29170
|
if (ref.harnessId !== ompHarnessId2 || !isRecord10(ref.locator) || typeof ref.locator.sessionFile !== "string" || ref.locator.sessionFile.length === 0) {
|
|
@@ -28570,7 +29177,7 @@ function subagentTranscriptPath(parentSessionFile, nativeSubagentId) {
|
|
|
28570
29177
|
if (nativeSubagentId.includes("/") || nativeSubagentId.includes("\\") || nativeSubagentId.includes("\0") || nativeSubagentId === "." || nativeSubagentId === "..") {
|
|
28571
29178
|
throw new Error("Omp Subagent ID is not a plain transcript file name");
|
|
28572
29179
|
}
|
|
28573
|
-
if (!parentSessionFile.endsWith(".jsonl") || !
|
|
29180
|
+
if (!parentSessionFile.endsWith(".jsonl") || !path8.isAbsolute(parentSessionFile)) {
|
|
28574
29181
|
return null;
|
|
28575
29182
|
}
|
|
28576
29183
|
return `${parentSessionFile.slice(0, -".jsonl".length)}/${nativeSubagentId}.jsonl`;
|
|
@@ -28579,7 +29186,7 @@ async function readSubagentTranscriptFile(parentSessionFile, nativeSubagentId) {
|
|
|
28579
29186
|
const transcriptFile = subagentTranscriptPath(parentSessionFile, nativeSubagentId);
|
|
28580
29187
|
if (transcriptFile === null)
|
|
28581
29188
|
return { status: "missing" };
|
|
28582
|
-
const parentDirectory =
|
|
29189
|
+
const parentDirectory = path8.dirname(transcriptFile);
|
|
28583
29190
|
let metadata;
|
|
28584
29191
|
try {
|
|
28585
29192
|
metadata = await stat2(transcriptFile);
|
|
@@ -28597,7 +29204,7 @@ async function readSubagentTranscriptFile(parentSessionFile, nativeSubagentId) {
|
|
|
28597
29204
|
realpath3(transcriptFile),
|
|
28598
29205
|
realpath3(parentDirectory)
|
|
28599
29206
|
]);
|
|
28600
|
-
if (
|
|
29207
|
+
if (path8.dirname(resolvedTranscript) !== resolvedParentDirectory) {
|
|
28601
29208
|
throw new Error("Omp Subagent transcript resolves outside its parent Session directory");
|
|
28602
29209
|
}
|
|
28603
29210
|
return {
|
|
@@ -28662,10 +29269,10 @@ function stripDiffPrefix(pathString) {
|
|
|
28662
29269
|
return pathString.startsWith("a/") || pathString.startsWith("b/") ? pathString.slice(2) : pathString;
|
|
28663
29270
|
}
|
|
28664
29271
|
function displayPath(nativePath, cwd) {
|
|
28665
|
-
const resolvedCwd =
|
|
28666
|
-
const resolvedPath =
|
|
28667
|
-
const relative =
|
|
28668
|
-
const inside = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${
|
|
29272
|
+
const resolvedCwd = path8.resolve(cwd);
|
|
29273
|
+
const resolvedPath = path8.isAbsolute(nativePath) ? path8.resolve(nativePath) : path8.resolve(cwd, nativePath);
|
|
29274
|
+
const relative = path8.relative(resolvedCwd, resolvedPath);
|
|
29275
|
+
const inside = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path8.sep}`);
|
|
28669
29276
|
const selected = inside ? relative : resolvedPath;
|
|
28670
29277
|
const normalized = selected.replaceAll("\\", "/");
|
|
28671
29278
|
if (normalized.length === 0 || normalized === ".")
|
|
@@ -28825,6 +29432,10 @@ var OmpHarnessSession = class {
|
|
|
28825
29432
|
#onClosed;
|
|
28826
29433
|
#requestedModel;
|
|
28827
29434
|
#requestedThinkingOptionId;
|
|
29435
|
+
#fastModelId;
|
|
29436
|
+
#speedScope;
|
|
29437
|
+
#hasNativeRef;
|
|
29438
|
+
#mayHaveTurns;
|
|
28828
29439
|
#toolOutputLimit;
|
|
28829
29440
|
#accountCredits;
|
|
28830
29441
|
#modelIndex;
|
|
@@ -28834,6 +29445,7 @@ var OmpHarnessSession = class {
|
|
|
28834
29445
|
#active = null;
|
|
28835
29446
|
#closePromise = null;
|
|
28836
29447
|
#configuring = false;
|
|
29448
|
+
#modelStateWrites = Promise.resolve();
|
|
28837
29449
|
#phase = "open";
|
|
28838
29450
|
#starting = null;
|
|
28839
29451
|
#state = {};
|
|
@@ -28850,6 +29462,10 @@ var OmpHarnessSession = class {
|
|
|
28850
29462
|
this.#closeTimeoutMs = options.closeTimeoutMs;
|
|
28851
29463
|
this.#requestedModel = options.model;
|
|
28852
29464
|
this.#requestedThinkingOptionId = options.thinkingOptionId;
|
|
29465
|
+
this.#fastModelId = options.fastModelId ?? null;
|
|
29466
|
+
this.#speedScope = options.speedScope ?? randomUUID5();
|
|
29467
|
+
this.#hasNativeRef = !!options.startedTransport;
|
|
29468
|
+
this.#mayHaveTurns = this.#hasNativeRef;
|
|
28853
29469
|
this.#toolOutputLimit = options.toolOutputLimit;
|
|
28854
29470
|
this.#accountCredits = options.accountCredits;
|
|
28855
29471
|
this.#accountKey = options.initialAccountKey ?? null;
|
|
@@ -28874,7 +29490,7 @@ var OmpHarnessSession = class {
|
|
|
28874
29490
|
};
|
|
28875
29491
|
this.#transport = options.startedTransport ?? null;
|
|
28876
29492
|
this.#modelIndex = createOmpModelIndex(options.startedModels ?? []);
|
|
28877
|
-
this.initialState = options.startedTransport ? harnessStateFromOmp(options.startedTransport.state, options.startedThinkingLevels ?? null, this.#modelIndex, this.#permissionModeId) : { effectivePermissionModeId: this.#permissionModeId };
|
|
29493
|
+
this.initialState = options.startedTransport ? harnessStateFromOmp(options.startedTransport.state, options.startedThinkingLevels ?? null, this.#modelIndex, this.#permissionModeId, this.#speedScope) : { effectivePermissionModeId: this.#permissionModeId };
|
|
28878
29494
|
this.initialUsage = options.initialUsage ?? null;
|
|
28879
29495
|
this.#usage = this.initialUsage;
|
|
28880
29496
|
this.#state = this.initialState;
|
|
@@ -28919,10 +29535,10 @@ var OmpHarnessSession = class {
|
|
|
28919
29535
|
if (this.#phase !== "open")
|
|
28920
29536
|
return;
|
|
28921
29537
|
this.#finishAccountAttempt(ompMessageAccount(observation.message));
|
|
28922
|
-
const
|
|
28923
|
-
if (
|
|
28924
|
-
this.#event({ type: "usage.request", request:
|
|
28925
|
-
else if (
|
|
29538
|
+
const record4 = ompUsageRecord(observation.message, observation);
|
|
29539
|
+
if (record4?.kind === "request")
|
|
29540
|
+
this.#event({ type: "usage.request", request: record4.request });
|
|
29541
|
+
else if (record4?.kind === "missing")
|
|
28926
29542
|
this.#event({ type: "usage.history", complete: false });
|
|
28927
29543
|
}
|
|
28928
29544
|
#displayedAccount() {
|
|
@@ -29084,7 +29700,7 @@ var OmpHarnessSession = class {
|
|
|
29084
29700
|
}
|
|
29085
29701
|
this.#acceptingTurn = true;
|
|
29086
29702
|
try {
|
|
29087
|
-
const
|
|
29703
|
+
const noHistory = !this.#mayHaveTurns;
|
|
29088
29704
|
let transport;
|
|
29089
29705
|
try {
|
|
29090
29706
|
transport = await this.#ensureTransport();
|
|
@@ -29095,7 +29711,7 @@ var OmpHarnessSession = class {
|
|
|
29095
29711
|
return { ok: false, error: invalidState("Omp Session became unavailable during startup") };
|
|
29096
29712
|
}
|
|
29097
29713
|
let beforeHistory;
|
|
29098
|
-
if (
|
|
29714
|
+
if (noHistory) {
|
|
29099
29715
|
beforeHistory = { turns: [] };
|
|
29100
29716
|
} else {
|
|
29101
29717
|
try {
|
|
@@ -29142,29 +29758,41 @@ var OmpHarnessSession = class {
|
|
|
29142
29758
|
this.#event({ type: "turn.started", turnId: command.turnId });
|
|
29143
29759
|
this.#event({ type: "item.started", turnId: command.turnId, item });
|
|
29144
29760
|
void transport.runTurn(text3, (event) => this.#handleTurnEvent(active2, event)).then(async (result) => {
|
|
29761
|
+
if (active2.admission)
|
|
29762
|
+
await active2.admission;
|
|
29145
29763
|
if (!result.agentInvoked) {
|
|
29764
|
+
await this.#observeTurnState(transport, "unconfirmed");
|
|
29146
29765
|
this.#completeTurn(active2, result.error !== void 0 ? { status: "failed", error: normalizedError(result.error, "nativeFailure") } : result.cancelled ? { status: "cancelled", reason: "Cancelled by user" } : { status: "succeeded" }, result.text, void 0, true);
|
|
29147
29766
|
return;
|
|
29148
29767
|
}
|
|
29149
29768
|
try {
|
|
29769
|
+
this.#mayHaveTurns = true;
|
|
29150
29770
|
const identity2 = await this.#completedTurnIdentity(active2, transport);
|
|
29771
|
+
await this.#observeTurnState(transport, "persisted");
|
|
29151
29772
|
this.#completeTurn(active2, result.cancelled ? {
|
|
29152
29773
|
status: "cancelled",
|
|
29153
29774
|
reason: "Cancelled by user",
|
|
29154
29775
|
checkpoint: identity2.checkpoint
|
|
29155
29776
|
} : { status: "succeeded", checkpoint: identity2.checkpoint }, result.text, identity2.nativeTurnRef);
|
|
29156
29777
|
} catch (error62) {
|
|
29778
|
+
if (this.#phase === "open")
|
|
29779
|
+
await this.#observeTurnState(transport, "unconfirmed");
|
|
29157
29780
|
this.#completeTurn(active2, {
|
|
29158
29781
|
status: "failed",
|
|
29159
29782
|
error: normalizedError(error62, "protocolError")
|
|
29160
29783
|
});
|
|
29161
29784
|
}
|
|
29162
29785
|
}).catch(async (error62) => {
|
|
29786
|
+
if (active2.admission)
|
|
29787
|
+
await active2.admission;
|
|
29163
29788
|
let identity2;
|
|
29164
29789
|
try {
|
|
29165
29790
|
identity2 = await this.#completedTurnIdentity(active2, transport);
|
|
29791
|
+
this.#mayHaveTurns = true;
|
|
29166
29792
|
} catch {
|
|
29167
29793
|
}
|
|
29794
|
+
if (this.#phase === "open")
|
|
29795
|
+
await this.#observeTurnState(transport, identity2 ? "persisted" : "unconfirmed");
|
|
29168
29796
|
this.#completeTurn(active2, {
|
|
29169
29797
|
status: "failed",
|
|
29170
29798
|
error: normalizedError(error62, "nativeFailure"),
|
|
@@ -29183,7 +29811,7 @@ var OmpHarnessSession = class {
|
|
|
29183
29811
|
return this.#closePromise;
|
|
29184
29812
|
}
|
|
29185
29813
|
async #selectModel(command) {
|
|
29186
|
-
if (this.#acceptingTurn || this.#configuring) {
|
|
29814
|
+
if (this.#acceptingTurn || this.#configuring || this.#starting) {
|
|
29187
29815
|
return {
|
|
29188
29816
|
ok: false,
|
|
29189
29817
|
error: {
|
|
@@ -29193,56 +29821,84 @@ var OmpHarnessSession = class {
|
|
|
29193
29821
|
}
|
|
29194
29822
|
};
|
|
29195
29823
|
}
|
|
29196
|
-
const transport = this.#transport;
|
|
29197
|
-
if (!transport) {
|
|
29198
|
-
return {
|
|
29199
|
-
ok: false,
|
|
29200
|
-
error: invalidState("Omp Model selection requires a started Native Session")
|
|
29201
|
-
};
|
|
29202
|
-
}
|
|
29203
|
-
const previousModel = this.#state.effectiveModel;
|
|
29204
29824
|
this.#configuring = true;
|
|
29205
29825
|
try {
|
|
29206
|
-
|
|
29826
|
+
return await this.#withModelState(() => this.#applyModelSelection(command));
|
|
29827
|
+
} finally {
|
|
29828
|
+
this.#configuring = false;
|
|
29829
|
+
}
|
|
29830
|
+
}
|
|
29831
|
+
// Turn admission/settlement and the composer both publish the model and persist its preference.
|
|
29832
|
+
#withModelState(update) {
|
|
29833
|
+
const result = this.#modelStateWrites.then(update);
|
|
29834
|
+
this.#modelStateWrites = result.then(() => void 0, () => void 0);
|
|
29835
|
+
return result;
|
|
29836
|
+
}
|
|
29837
|
+
async #applyModelSelection(command) {
|
|
29838
|
+
try {
|
|
29839
|
+
let model2;
|
|
29207
29840
|
try {
|
|
29208
|
-
|
|
29209
|
-
requested = resolveOmpModelRef(harnessModelRefSchema.parse(command.model), index);
|
|
29210
|
-
this.#modelIndex = index;
|
|
29841
|
+
model2 = validateOmpModel(command.model);
|
|
29211
29842
|
} catch (error62) {
|
|
29212
29843
|
return { ok: false, error: normalizedError(error62, "invalidRequest") };
|
|
29213
29844
|
}
|
|
29214
|
-
|
|
29215
|
-
|
|
29845
|
+
const transport = this.#transport;
|
|
29846
|
+
if (!transport) {
|
|
29847
|
+
await this.#ensureTransport(model2, true);
|
|
29848
|
+
this.#requestedModel = model2;
|
|
29849
|
+
return { ok: true, value: { completed: true } };
|
|
29850
|
+
}
|
|
29851
|
+
let requested;
|
|
29216
29852
|
try {
|
|
29217
|
-
|
|
29218
|
-
|
|
29219
|
-
const reconciled = await reconcileThinkingLevel(transport, state, thinkingLevels);
|
|
29220
|
-
state = reconciled.state;
|
|
29221
|
-
thinkingLevels = reconciled.thinkingLevels;
|
|
29222
|
-
this.#publishTransportState(state, thinkingLevels);
|
|
29853
|
+
this.#modelIndex = createOmpModelIndex(await transport.getAvailableModels());
|
|
29854
|
+
requested = resolveOmpModelRef(model2, this.#modelIndex);
|
|
29223
29855
|
} catch (error62) {
|
|
29224
|
-
|
|
29225
|
-
this.#fault(error62);
|
|
29226
|
-
return { ok: false, error: normalizedError(error62, "nativeFailure") };
|
|
29227
|
-
}
|
|
29228
|
-
const actual = nativeModelFromState(state);
|
|
29229
|
-
if (previousModel?.id !== this.#state.effectiveModel?.id) {
|
|
29230
|
-
this.#invalidateUsage();
|
|
29231
|
-
void this.#refreshUsage();
|
|
29856
|
+
return { ok: false, error: normalizedError(error62, "invalidRequest") };
|
|
29232
29857
|
}
|
|
29233
|
-
|
|
29858
|
+
const previousModel = nativeModelFromState(transport.state);
|
|
29859
|
+
const changingModel = !sameOmpModel(previousModel, requested);
|
|
29860
|
+
if (this.#active && changingModel && (requested.serviceTier === "priority" || previousModel?.serviceTier === "priority" || this.#fastModelId !== null)) {
|
|
29234
29861
|
return {
|
|
29235
29862
|
ok: false,
|
|
29236
29863
|
error: {
|
|
29237
|
-
code: "
|
|
29238
|
-
message: "Omp
|
|
29239
|
-
retryable:
|
|
29864
|
+
code: "sessionBusy",
|
|
29865
|
+
message: "Omp cannot switch models and Fast mode together during an active Turn",
|
|
29866
|
+
retryable: true
|
|
29240
29867
|
}
|
|
29241
29868
|
};
|
|
29242
29869
|
}
|
|
29870
|
+
await applyOmpModel(transport, requested, this.#fastModelId, async (selection2) => {
|
|
29871
|
+
const current = transport.state;
|
|
29872
|
+
const reconciled = changingModel ? await reconcileThinkingLevel(transport, current, await transport.getAvailableThinkingLevels()) : { state: current, thinkingLevels: current.availableThinkingLevels };
|
|
29873
|
+
const state = this.#projectState(reconciled.state, reconciled.thinkingLevels);
|
|
29874
|
+
this.#confirmModel(model2, state);
|
|
29875
|
+
if (this.#hasNativeRef && selection2 !== this.#fastModelId) {
|
|
29876
|
+
await writeOmpSpeedSelection(reconciled.state, this.#speedScope, selection2);
|
|
29877
|
+
}
|
|
29878
|
+
this.#fastModelId = selection2;
|
|
29879
|
+
this.#requestedModel = model2;
|
|
29880
|
+
this.#publishState(state);
|
|
29881
|
+
});
|
|
29882
|
+
if (changingModel) {
|
|
29883
|
+
this.#invalidateUsage();
|
|
29884
|
+
void this.#refreshUsage();
|
|
29885
|
+
}
|
|
29243
29886
|
return { ok: true, value: { completed: true } };
|
|
29244
|
-
}
|
|
29245
|
-
|
|
29887
|
+
} catch (error62) {
|
|
29888
|
+
if (error62 instanceof OmpRpcFaultError) {
|
|
29889
|
+
this.#fault(error62);
|
|
29890
|
+
void this.#transport?.close().catch(() => void 0);
|
|
29891
|
+
}
|
|
29892
|
+
return { ok: false, error: normalizedError(error62, "nativeFailure") };
|
|
29893
|
+
}
|
|
29894
|
+
}
|
|
29895
|
+
#confirmModel(requested, state) {
|
|
29896
|
+
if (!sameHarnessModelRef(state.effectiveModel, requested)) {
|
|
29897
|
+
throw new OmpAdapterFaultError({
|
|
29898
|
+
code: "nativeFailure",
|
|
29899
|
+
message: "Omp did not activate the requested Model and speed",
|
|
29900
|
+
retryable: false
|
|
29901
|
+
});
|
|
29246
29902
|
}
|
|
29247
29903
|
}
|
|
29248
29904
|
async #selectThinking(command) {
|
|
@@ -29309,6 +29965,7 @@ var OmpHarnessSession = class {
|
|
|
29309
29965
|
}
|
|
29310
29966
|
try {
|
|
29311
29967
|
this.#publishTransportState(state, thinkingLevels);
|
|
29968
|
+
this.#requestedThinkingOptionId = thinkingOptionId;
|
|
29312
29969
|
} catch (error62) {
|
|
29313
29970
|
if (error62 instanceof OmpRpcFaultError)
|
|
29314
29971
|
this.#fault(error62);
|
|
@@ -29342,7 +29999,16 @@ var OmpHarnessSession = class {
|
|
|
29342
29999
|
return { ok: true, value: { completed: true } };
|
|
29343
30000
|
}
|
|
29344
30001
|
const transport = this.#transport;
|
|
29345
|
-
if (!transport) {
|
|
30002
|
+
if (!transport || !this.#mayHaveTurns) {
|
|
30003
|
+
if (transport) {
|
|
30004
|
+
this.#configuring = true;
|
|
30005
|
+
try {
|
|
30006
|
+
await transport.close();
|
|
30007
|
+
this.#transport = null;
|
|
30008
|
+
} finally {
|
|
30009
|
+
this.#configuring = false;
|
|
30010
|
+
}
|
|
30011
|
+
}
|
|
29346
30012
|
this.#permissionMode = permissionMode;
|
|
29347
30013
|
this.#permissionModeId = permissionModeId;
|
|
29348
30014
|
this.#state = { ...this.#state, effectivePermissionModeId: permissionModeId };
|
|
@@ -29378,6 +30044,7 @@ var OmpHarnessSession = class {
|
|
|
29378
30044
|
throw new Error("Omp Permission Mode restart changed the Native Session identity");
|
|
29379
30045
|
}
|
|
29380
30046
|
const thinkingLevels = await replacement.getAvailableThinkingLevels();
|
|
30047
|
+
await this.#restoreAfterRestart(replacement);
|
|
29381
30048
|
this.#transport = replacement;
|
|
29382
30049
|
this.#permissionMode = permissionMode;
|
|
29383
30050
|
this.#permissionModeId = permissionModeId;
|
|
@@ -29393,6 +30060,7 @@ var OmpHarnessSession = class {
|
|
|
29393
30060
|
throw new Error("Omp Permission Mode recovery changed the Native Session identity");
|
|
29394
30061
|
}
|
|
29395
30062
|
const thinkingLevels = await recovery.getAvailableThinkingLevels();
|
|
30063
|
+
await this.#restoreAfterRestart(recovery);
|
|
29396
30064
|
this.#transport = recovery;
|
|
29397
30065
|
this.#publishTransportState(recovery.state, thinkingLevels);
|
|
29398
30066
|
} catch (recoveryError) {
|
|
@@ -29683,7 +30351,7 @@ var OmpHarnessSession = class {
|
|
|
29683
30351
|
this.#acceptingTurn = false;
|
|
29684
30352
|
}
|
|
29685
30353
|
}
|
|
29686
|
-
async #ensureTransport() {
|
|
30354
|
+
async #ensureTransport(requestedModel = this.#requestedModel, configure = false) {
|
|
29687
30355
|
if (this.#transport)
|
|
29688
30356
|
return this.#transport;
|
|
29689
30357
|
if (this.#starting)
|
|
@@ -29700,46 +30368,57 @@ var OmpHarnessSession = class {
|
|
|
29700
30368
|
const starting = transport.start().then(async () => {
|
|
29701
30369
|
if (this.#phase !== "open")
|
|
29702
30370
|
throw new Error("Omp Session closed during startup");
|
|
29703
|
-
let state = transport.state;
|
|
29704
30371
|
const models = await transport.getAvailableModels();
|
|
29705
30372
|
this.#modelIndex = createOmpModelIndex(models);
|
|
29706
|
-
let
|
|
29707
|
-
if (
|
|
29708
|
-
|
|
29709
|
-
|
|
29710
|
-
|
|
29711
|
-
|
|
29712
|
-
|
|
29713
|
-
|
|
29714
|
-
|
|
29715
|
-
|
|
29716
|
-
|
|
29717
|
-
|
|
29718
|
-
|
|
29719
|
-
if (!thinkingLevels) {
|
|
29720
|
-
|
|
29721
|
-
|
|
29722
|
-
|
|
29723
|
-
|
|
29724
|
-
|
|
29725
|
-
|
|
29726
|
-
|
|
29727
|
-
|
|
30373
|
+
let requested;
|
|
30374
|
+
if (requestedModel) {
|
|
30375
|
+
try {
|
|
30376
|
+
requested = resolveOmpModelRef(requestedModel, this.#modelIndex);
|
|
30377
|
+
} catch (error62) {
|
|
30378
|
+
throw new OmpAdapterFaultError(normalizedError(error62, "invalidRequest"));
|
|
30379
|
+
}
|
|
30380
|
+
}
|
|
30381
|
+
const finishStartup = async (selection2) => {
|
|
30382
|
+
let state = transport.state;
|
|
30383
|
+
let thinkingLevels = await transport.getAvailableThinkingLevels();
|
|
30384
|
+
const requestedThinking = this.#requestedThinkingOptionId;
|
|
30385
|
+
const changedDraftModel = configure && requestedModel?.id !== this.#requestedModel?.id;
|
|
30386
|
+
if (requestedThinking && (!changedDraftModel || thinkingLevels?.includes(requestedThinking))) {
|
|
30387
|
+
if (thinkingLevels) {
|
|
30388
|
+
state = await transport.selectThinkingOption(requestedThinking);
|
|
30389
|
+
thinkingLevels = await transport.getAvailableThinkingLevels();
|
|
30390
|
+
} else {
|
|
30391
|
+
const current = nativeModelFromState(state);
|
|
30392
|
+
const thinkingAlreadyOff = requestedThinking === "off" && (state.thinkingLevel === "off" || current !== null && models.some((model2) => sameOmpModel(model2, current) && model2.reasoning === false));
|
|
30393
|
+
if (!thinkingAlreadyOff) {
|
|
30394
|
+
throw new OmpAdapterFaultError({
|
|
30395
|
+
code: "unsupported",
|
|
30396
|
+
message: "Installed Omp does not support Thinking selection",
|
|
30397
|
+
retryable: false
|
|
30398
|
+
});
|
|
30399
|
+
}
|
|
29728
30400
|
}
|
|
29729
|
-
} else {
|
|
29730
|
-
state = await transport.selectThinkingOption(this.#requestedThinkingOptionId);
|
|
29731
|
-
thinkingLevels = await transport.getAvailableThinkingLevels();
|
|
29732
30401
|
}
|
|
29733
|
-
|
|
29734
|
-
|
|
29735
|
-
|
|
29736
|
-
|
|
29737
|
-
|
|
29738
|
-
|
|
30402
|
+
const reconciled = await reconcileThinkingLevel(transport, state, thinkingLevels);
|
|
30403
|
+
const projected = this.#projectState(reconciled.state, reconciled.thinkingLevels);
|
|
30404
|
+
if (requestedModel)
|
|
30405
|
+
this.#confirmModel(requestedModel, projected);
|
|
30406
|
+
if (this.#phase !== "open")
|
|
30407
|
+
throw new Error("Omp Session closed during configuration");
|
|
30408
|
+
this.#fastModelId = selection2;
|
|
30409
|
+
if (configure)
|
|
30410
|
+
this.#requestedThinkingOptionId = projected.effectiveThinkingOptionId;
|
|
30411
|
+
this.#transport = transport;
|
|
30412
|
+
this.#publishState(projected);
|
|
30413
|
+
};
|
|
30414
|
+
if (requested)
|
|
30415
|
+
await applyOmpModel(transport, requested, null, finishStartup);
|
|
30416
|
+
else
|
|
30417
|
+
await finishStartup(null);
|
|
29739
30418
|
return transport;
|
|
29740
30419
|
}).catch(async (error62) => {
|
|
29741
30420
|
await transport.close().catch(() => void 0);
|
|
29742
|
-
if (this.#phase === "open")
|
|
30421
|
+
if (this.#phase === "open" && !configure)
|
|
29743
30422
|
this.#fault(error62);
|
|
29744
30423
|
throw error62;
|
|
29745
30424
|
}).finally(() => {
|
|
@@ -29749,9 +30428,59 @@ var OmpHarnessSession = class {
|
|
|
29749
30428
|
this.#starting = starting;
|
|
29750
30429
|
return starting;
|
|
29751
30430
|
}
|
|
30431
|
+
async #restoreAfterRestart(transport) {
|
|
30432
|
+
if (!this.#fastModelId)
|
|
30433
|
+
return;
|
|
30434
|
+
this.#fastModelId = await restoreOmpSpeed(transport, this.#fastModelId);
|
|
30435
|
+
if (!this.#fastModelId) {
|
|
30436
|
+
await writeOmpSpeedSelection(transport.state, this.#speedScope, null).catch(() => void 0);
|
|
30437
|
+
}
|
|
30438
|
+
}
|
|
30439
|
+
#observeTurnState(transport, journal) {
|
|
30440
|
+
return this.#withModelState(() => this.#synchronizeTurnState(transport, journal));
|
|
30441
|
+
}
|
|
30442
|
+
async #synchronizeTurnState(transport, journal) {
|
|
30443
|
+
const state = transport.state;
|
|
30444
|
+
const publishIdentity = journal !== "unconfirmed" && !this.#hasNativeRef;
|
|
30445
|
+
const selection2 = this.#fastModelId;
|
|
30446
|
+
const relinquish = selection2 !== null && (state.provider !== "openai-codex" || state.modelId !== selection2 || state.serviceTier !== "priority");
|
|
30447
|
+
if (publishIdentity && selection2 && !relinquish || this.#hasNativeRef && relinquish) {
|
|
30448
|
+
await writeOmpSpeedSelection(state, this.#speedScope, relinquish ? null : selection2).catch(() => void 0);
|
|
30449
|
+
}
|
|
30450
|
+
if (relinquish) {
|
|
30451
|
+
this.#fastModelId = null;
|
|
30452
|
+
this.#requestedModel = void 0;
|
|
30453
|
+
}
|
|
30454
|
+
if (journal === "admitted" && this.#phase !== "open")
|
|
30455
|
+
return;
|
|
30456
|
+
if (publishIdentity)
|
|
30457
|
+
this.#hasNativeRef = true;
|
|
30458
|
+
if (journal === "admitted") {
|
|
30459
|
+
const { nativeRef } = this.#projectState(state, null);
|
|
30460
|
+
if (nativeRef)
|
|
30461
|
+
this.#publishState({ ...this.#state, nativeRef });
|
|
30462
|
+
return;
|
|
30463
|
+
}
|
|
30464
|
+
const model2 = nativeModelFromState(state);
|
|
30465
|
+
if (publishIdentity || !sameHarnessModelRef(this.#state.effectiveModel, model2 ? this.#modelIndex.ref(model2) : void 0) || this.#state.effectiveThinkingOptionId !== (state.thinkingLevel ?? void 0)) {
|
|
30466
|
+
try {
|
|
30467
|
+
const actual = await reconcileThinkingLevel(transport, state, state.availableThinkingLevels);
|
|
30468
|
+
this.#publishTransportState(actual.state, actual.thinkingLevels);
|
|
30469
|
+
} catch (error62) {
|
|
30470
|
+
this.#fault(error62);
|
|
30471
|
+
void transport.close().catch(() => void 0);
|
|
30472
|
+
}
|
|
30473
|
+
}
|
|
30474
|
+
}
|
|
30475
|
+
#projectState(state, levels) {
|
|
30476
|
+
return harnessStateFromOmp(state, levels, this.#modelIndex, this.#permissionModeId, this.#hasNativeRef ? this.#speedScope : null);
|
|
30477
|
+
}
|
|
30478
|
+
#publishState(state) {
|
|
30479
|
+
this.#state = state;
|
|
30480
|
+
this.#event({ type: "session.state.changed", state });
|
|
30481
|
+
}
|
|
29752
30482
|
#publishTransportState(state, thinkingLevels) {
|
|
29753
|
-
this.#
|
|
29754
|
-
this.#event({ type: "session.state.changed", state: this.#state });
|
|
30483
|
+
this.#publishState(this.#projectState(state, thinkingLevels));
|
|
29755
30484
|
}
|
|
29756
30485
|
#invalidateUsage() {
|
|
29757
30486
|
this.#usageGeneration += 1;
|
|
@@ -29790,6 +30519,12 @@ var OmpHarnessSession = class {
|
|
|
29790
30519
|
if (this.#active !== active2 || this.#phase === "closed" || this.#phase === "faulted")
|
|
29791
30520
|
return;
|
|
29792
30521
|
switch (event.type) {
|
|
30522
|
+
case "agent.started":
|
|
30523
|
+
this.#mayHaveTurns = true;
|
|
30524
|
+
if (!this.#hasNativeRef && !active2.admission && this.#transport?.state.sessionFile) {
|
|
30525
|
+
active2.admission = this.#observeTurnState(this.#transport, "admitted").catch((error62) => this.#fault(error62));
|
|
30526
|
+
}
|
|
30527
|
+
return;
|
|
29793
30528
|
case "text.delta":
|
|
29794
30529
|
this.#activateAgentMessage(active2, event.messageId);
|
|
29795
30530
|
this.#appendText(active2, event.delta);
|
|
@@ -29872,7 +30607,7 @@ var OmpHarnessSession = class {
|
|
|
29872
30607
|
if (active2.interactionByNativeId.has(request.requestId)) {
|
|
29873
30608
|
throw new Error("Omp Interaction started more than once");
|
|
29874
30609
|
}
|
|
29875
|
-
const interactionId = hostInteractionIdSchema.parse(
|
|
30610
|
+
const interactionId = hostInteractionIdSchema.parse(randomUUID5());
|
|
29876
30611
|
let interaction;
|
|
29877
30612
|
if (request.method === "select" && request.options.length === 2 && request.options[0] === "Approve" && request.options[1] === "Deny") {
|
|
29878
30613
|
interaction = {
|
|
@@ -30253,7 +30988,7 @@ var OmpHarnessSession = class {
|
|
|
30253
30988
|
this.#channel.emit({ kind: "event", event });
|
|
30254
30989
|
}
|
|
30255
30990
|
#newItemId() {
|
|
30256
|
-
return hostItemIdSchema.parse(
|
|
30991
|
+
return hostItemIdSchema.parse(randomUUID5());
|
|
30257
30992
|
}
|
|
30258
30993
|
};
|
|
30259
30994
|
var OmpAdapter = class {
|
|
@@ -30357,7 +31092,7 @@ var OmpAdapter = class {
|
|
|
30357
31092
|
const leafId = entries.at(-1)?.id;
|
|
30358
31093
|
const snapshot = mapOmpSnapshot({ entries, leafId: typeof leafId === "string" ? leafId : null }, {
|
|
30359
31094
|
sessionId: input3.parent.nativeSessionId,
|
|
30360
|
-
model:
|
|
31095
|
+
model: nativeModelForHistory(transport.state)
|
|
30361
31096
|
});
|
|
30362
31097
|
return { ok: true, value: snapshot };
|
|
30363
31098
|
} catch (error62) {
|
|
@@ -30538,7 +31273,7 @@ var OmpAdapter = class {
|
|
|
30538
31273
|
const models = await transport.getAvailableModels();
|
|
30539
31274
|
stage = "capabilities";
|
|
30540
31275
|
const thinkingLevels = await transport.getAvailableThinkingLevels();
|
|
30541
|
-
const catalog = normalizeOmpModelCatalog(models, nativeModelFromState(transport.state), thinkingLevels, transport.state.thinkingLevel);
|
|
31276
|
+
const catalog = normalizeOmpModelCatalog(models, nativeModelFromState(transport.state), thinkingLevels, transport.state.thinkingLevel, transport.speedAvailable);
|
|
30542
31277
|
await transport.close();
|
|
30543
31278
|
return {
|
|
30544
31279
|
status: "ready",
|
|
@@ -30580,6 +31315,14 @@ var OmpAdapter = class {
|
|
|
30580
31315
|
}
|
|
30581
31316
|
};
|
|
30582
31317
|
}
|
|
31318
|
+
const modelHint = "model" in input3 ? input3.model : void 0;
|
|
31319
|
+
if (modelHint && input3.kind === "create") {
|
|
31320
|
+
try {
|
|
31321
|
+
validateOmpModel(modelHint);
|
|
31322
|
+
} catch (error62) {
|
|
31323
|
+
return { ok: false, error: normalizedError(error62, "invalidRequest") };
|
|
31324
|
+
}
|
|
31325
|
+
}
|
|
30583
31326
|
const environment = input3.environment ? { ...this.#environment, ...input3.environment } : this.#environment;
|
|
30584
31327
|
if (input3.kind === "create") {
|
|
30585
31328
|
let permissionModeId = input3.permissionModeId ?? (input3.executionPolicy === "unattended-full-access" ? encodeOmpPermissionModeId("yolo") : OMP_DEFAULT_PERMISSION_MODE_ID);
|
|
@@ -30590,15 +31333,6 @@ var OmpAdapter = class {
|
|
|
30590
31333
|
} catch (error62) {
|
|
30591
31334
|
return { ok: false, error: normalizedError(error62, "invalidRequest") };
|
|
30592
31335
|
}
|
|
30593
|
-
if (input3.model) {
|
|
30594
|
-
const parsed = harnessModelRefSchema.safeParse(input3.model);
|
|
30595
|
-
if (!parsed.success || parsed.data.serviceTier) {
|
|
30596
|
-
return {
|
|
30597
|
-
ok: false,
|
|
30598
|
-
error: { code: "invalidRequest", message: "Invalid Omp Model Ref", retryable: false }
|
|
30599
|
-
};
|
|
30600
|
-
}
|
|
30601
|
-
}
|
|
30602
31336
|
const thinkingOptionId = input3.thinkingOptionId ? harnessThinkingOptionIdSchema.safeParse(input3.thinkingOptionId) : null;
|
|
30603
31337
|
if (thinkingOptionId && !thinkingOptionId.success) {
|
|
30604
31338
|
return {
|
|
@@ -30647,15 +31381,18 @@ var OmpAdapter = class {
|
|
|
30647
31381
|
});
|
|
30648
31382
|
}
|
|
30649
31383
|
}
|
|
30650
|
-
|
|
31384
|
+
const callbacks = {
|
|
30651
31385
|
cwd: input3.cwd,
|
|
30652
31386
|
environment,
|
|
30653
|
-
...input3.kind === "resume" ? { sessionFile: sourceSessionFile } : { forkSessionFile: sourceSessionFile },
|
|
30654
31387
|
onFault: (error62) => session?.handleTransportFault(error62),
|
|
30655
31388
|
onSubagentEvent: (event) => session?.handleTransportEvent(event),
|
|
30656
31389
|
onAssistantStart: (message3) => session?.handleAssistantStart(message3),
|
|
30657
31390
|
onAssistantSummary: (messages) => session?.handleAssistantSummary(messages),
|
|
30658
31391
|
onUsage: (observation) => session?.handleTransportUsage(observation)
|
|
31392
|
+
};
|
|
31393
|
+
transport = this.#createTransport({
|
|
31394
|
+
...callbacks,
|
|
31395
|
+
...input3.kind === "resume" ? { sessionFile: sourceSessionFile } : { forkSessionFile: sourceSessionFile }
|
|
30659
31396
|
});
|
|
30660
31397
|
await transport.start();
|
|
30661
31398
|
if (input3.kind === "resume") {
|
|
@@ -30706,6 +31443,27 @@ var OmpAdapter = class {
|
|
|
30706
31443
|
});
|
|
30707
31444
|
}
|
|
30708
31445
|
}
|
|
31446
|
+
const startedModels = await transport.getAvailableModels();
|
|
31447
|
+
const current = nativeModelForHistory(transport.state);
|
|
31448
|
+
const locator = sourceRef.locator;
|
|
31449
|
+
let sourceScope;
|
|
31450
|
+
if (isRecord10(locator) && typeof locator.speedScope === "string")
|
|
31451
|
+
sourceScope = locator.speedScope;
|
|
31452
|
+
else if (environment.CODEXHOST_THREAD_ID)
|
|
31453
|
+
sourceScope = `legacy:${environment.CODEXHOST_DATA_DIR ?? ""}`;
|
|
31454
|
+
const speedScope = input3.kind === "resume" && sourceScope ? sourceScope : randomUUID5();
|
|
31455
|
+
let fastModelId = null;
|
|
31456
|
+
const stored = sourceScope ? await readOmpSpeedSelection(sourceSessionFile, sourceRef.nativeSessionId, sourceScope) : null;
|
|
31457
|
+
if (stored) {
|
|
31458
|
+
const eligible = current?.id === stored && startedModels.some((m) => sameOmpModel(m, current) && supportsOmpChatGptFast(m));
|
|
31459
|
+
const consistent = !modelHint || current && createOmpModelIndex(startedModels).ref(current).id === modelHint.id && modelHint.serviceTier === "priority";
|
|
31460
|
+
if (eligible && consistent)
|
|
31461
|
+
fastModelId = await restoreOmpSpeed(transport, stored);
|
|
31462
|
+
const previous = input3.kind === "resume" ? stored : null;
|
|
31463
|
+
if (previous !== fastModelId) {
|
|
31464
|
+
await writeOmpSpeedSelection(transport.state, speedScope, fastModelId).catch(() => void 0);
|
|
31465
|
+
}
|
|
31466
|
+
}
|
|
30709
31467
|
let startedThinkingLevels = await transport.getAvailableThinkingLevels();
|
|
30710
31468
|
const reconciled = await reconcileThinkingLevel(transport, transport.state, startedThinkingLevels);
|
|
30711
31469
|
startedThinkingLevels = reconciled.thinkingLevels;
|
|
@@ -30724,7 +31482,9 @@ var OmpAdapter = class {
|
|
|
30724
31482
|
initialAccountKey,
|
|
30725
31483
|
environment,
|
|
30726
31484
|
startedTransport: transport,
|
|
30727
|
-
startedModels
|
|
31485
|
+
startedModels,
|
|
31486
|
+
fastModelId,
|
|
31487
|
+
speedScope,
|
|
30728
31488
|
startedThinkingLevels,
|
|
30729
31489
|
initialUsage,
|
|
30730
31490
|
supportsThinkingSelection: startedThinkingLevels !== null,
|
|
@@ -30750,7 +31510,7 @@ var OmpAdapter = class {
|
|
|
30750
31510
|
#trackSession(cwd, options) {
|
|
30751
31511
|
const environment = options.environment;
|
|
30752
31512
|
const entries = Object.entries(environment).filter(([name]) => name !== "CODEXHOST_THREAD_ID").sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
30753
|
-
const key =
|
|
31513
|
+
const key = createHash3("sha256").update(JSON.stringify([cwd, entries])).digest("hex");
|
|
30754
31514
|
let quota = this.#sessionQuota.get(key);
|
|
30755
31515
|
if (!quota) {
|
|
30756
31516
|
quota = {
|
|
@@ -30776,6 +31536,8 @@ var OmpAdapter = class {
|
|
|
30776
31536
|
permissionMode: options.permissionMode,
|
|
30777
31537
|
permissionModeId: options.permissionModeId,
|
|
30778
31538
|
...options.startedTransport ? { startedTransport: options.startedTransport } : {},
|
|
31539
|
+
...options.fastModelId ? { fastModelId: options.fastModelId } : {},
|
|
31540
|
+
...options.speedScope ? { speedScope: options.speedScope } : {},
|
|
30779
31541
|
...options.startedModels ? { startedModels: options.startedModels } : {},
|
|
30780
31542
|
...options.startedThinkingLevels !== void 0 ? { startedThinkingLevels: options.startedThinkingLevels } : {},
|
|
30781
31543
|
...options.initialUsage !== void 0 ? { initialUsage: options.initialUsage } : {},
|
|
@@ -30800,7 +31562,7 @@ var OmpAdapter = class {
|
|
|
30800
31562
|
|
|
30801
31563
|
// dist/installation.js
|
|
30802
31564
|
import { realpath as realpath4 } from "node:fs/promises";
|
|
30803
|
-
import
|
|
31565
|
+
import path9 from "node:path";
|
|
30804
31566
|
function createOmpInstallation(environment, command) {
|
|
30805
31567
|
let executable;
|
|
30806
31568
|
let env;
|
|
@@ -30811,7 +31573,7 @@ function createOmpInstallation(environment, command) {
|
|
|
30811
31573
|
const pathKey = Object.keys(environment).find((key) => key.toLowerCase() === "path") ?? "PATH";
|
|
30812
31574
|
env = {
|
|
30813
31575
|
...environment,
|
|
30814
|
-
[pathKey]: `${
|
|
31576
|
+
[pathKey]: `${path9.dirname(executable)}${path9.delimiter}${environment[pathKey] ?? ""}`
|
|
30815
31577
|
};
|
|
30816
31578
|
const target2 = resolveHarnessExecutable({ id: "omp", command: "omp", installRoots: { posix: [], windows: [] } }, { environment: env });
|
|
30817
31579
|
const canUpdate = !selected.includes("/nix/store/") && !!target2 && await realpath4(target2.executable) === selected;
|