@codexhost/cli-darwin-x64 0.23.0 → 0.24.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 +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +1565 -1805
- package/app/console-web.js +5786 -1600
- package/app/desktop-controller.mjs +13104 -2842
- package/app/host-runtime.mjs +50518 -51753
- package/app/plugins/antigravity/plugin.mjs +1932 -1148
- package/app/plugins/claude-code/plugin.mjs +1676 -1218
- package/app/plugins/codebuddy/plugin.mjs +1266 -850
- package/app/plugins/codex-usage/plugin.mjs +916 -737
- package/app/plugins/copilot/plugin.mjs +838 -640
- package/app/plugins/cursor-cli/plugin.mjs +1058 -747
- package/app/plugins/deepseek-harness/plugin.mjs +1302 -1070
- package/app/plugins/devin/plugin.mjs +949 -752
- package/app/plugins/grok/plugin.mjs +1132 -964
- package/app/plugins/hermes/plugin.mjs +1084 -905
- package/app/plugins/kimi-code/plugin.mjs +977 -804
- package/app/plugins/kiro-cli/plugin.mjs +951 -758
- package/app/plugins/omp/plugin.mjs +1408 -1169
- package/app/plugins/opencode/plugin.mjs +1385 -1142
- package/app/plugins/pi/plugin.mjs +1515 -1287
- package/app/plugins/qoder/plugin.mjs +861 -676
- package/app/plugins/qoder-cn/plugin.mjs +861 -676
- package/app/plugins/qwen-code/plugin.mjs +1060 -888
- package/app/plugins/workbuddy/plugin.mjs +1272 -856
- package/app/plugins/zcode/plugin.mjs +1529 -880
- package/app/renderer-extension.js +11568 -7827
- package/app/web/assets/index-CTCFIQbU.css +1 -0
- package/app/web/assets/index-IvFk9KT-.js +203 -0
- package/app/web/codexhost-settings.js +4472 -36194
- 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 +69 -69
- package/app/web/plugins/deepseek-ai__dsh-client-ui-approval/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -74
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +75 -64
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +19 -16
- package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-right/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-theme/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
- package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +3 -3
- package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +7 -7
- package/app/web/sw.js +8 -1
- package/app/web-modules/server.mjs +2682 -5540
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/package.json +1 -1
- package/app/web/assets/index-DJW4bmyx.css +0 -1
- package/app/web/assets/index-Dyh1KzAB.js +0 -201
|
@@ -32,10 +32,10 @@ function executableExtensions(command, platform, environment) {
|
|
|
32
32
|
return [""];
|
|
33
33
|
return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
|
|
34
34
|
}
|
|
35
|
-
function isExecutableFile(
|
|
35
|
+
function isExecutableFile(filePath2, platform) {
|
|
36
36
|
try {
|
|
37
|
-
fs.accessSync(
|
|
38
|
-
return fs.statSync(
|
|
37
|
+
fs.accessSync(filePath2, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
|
|
38
|
+
return fs.statSync(filePath2).isFile();
|
|
39
39
|
} catch {
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
@@ -1661,8 +1661,8 @@ function cleanEnum(obj) {
|
|
|
1661
1661
|
return Number.isNaN(Number.parseInt(k, 10));
|
|
1662
1662
|
}).map((el) => el[1]);
|
|
1663
1663
|
}
|
|
1664
|
-
function base64ToUint8Array(
|
|
1665
|
-
const binaryString = atob(
|
|
1664
|
+
function base64ToUint8Array(base644) {
|
|
1665
|
+
const binaryString = atob(base644);
|
|
1666
1666
|
const bytes = new Uint8Array(binaryString.length);
|
|
1667
1667
|
for (let i = 0; i < binaryString.length; i++) {
|
|
1668
1668
|
bytes[i] = binaryString.charCodeAt(i);
|
|
@@ -1677,9 +1677,9 @@ function uint8ArrayToBase64(bytes) {
|
|
|
1677
1677
|
return btoa(binaryString);
|
|
1678
1678
|
}
|
|
1679
1679
|
function base64urlToUint8Array(base64url3) {
|
|
1680
|
-
const
|
|
1681
|
-
const padding = "=".repeat((4 -
|
|
1682
|
-
return base64ToUint8Array(
|
|
1680
|
+
const base644 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
|
|
1681
|
+
const padding = "=".repeat((4 - base644.length % 4) % 4);
|
|
1682
|
+
return base64ToUint8Array(base644 + padding);
|
|
1683
1683
|
}
|
|
1684
1684
|
function uint8ArrayToBase64url(bytes) {
|
|
1685
1685
|
return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
@@ -3045,8 +3045,8 @@ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
|
3045
3045
|
function isValidBase64URL(data) {
|
|
3046
3046
|
if (!base64url.test(data))
|
|
3047
3047
|
return false;
|
|
3048
|
-
const
|
|
3049
|
-
const padded =
|
|
3048
|
+
const base644 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
3049
|
+
const padded = base644.padEnd(Math.ceil(base644.length / 4) * 4, "=");
|
|
3050
3050
|
return isValidBase64(padded);
|
|
3051
3051
|
}
|
|
3052
3052
|
var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
|
|
@@ -3500,42 +3500,42 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3500
3500
|
}
|
|
3501
3501
|
doc.write(`const newResult = {};`);
|
|
3502
3502
|
for (const key of normalized.keys) {
|
|
3503
|
-
const
|
|
3503
|
+
const id2 = ids[key];
|
|
3504
3504
|
const k = esc(key);
|
|
3505
3505
|
const schema = shape[key];
|
|
3506
3506
|
const isOptionalIn = schema?._zod?.optin === "optional";
|
|
3507
3507
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
3508
|
-
doc.write(`const ${
|
|
3508
|
+
doc.write(`const ${id2} = ${parseStr(key)};`);
|
|
3509
3509
|
if (isOptionalIn && isOptionalOut) {
|
|
3510
3510
|
doc.write(`
|
|
3511
|
-
if (${
|
|
3511
|
+
if (${id2}.issues.length) {
|
|
3512
3512
|
if (${k} in input) {
|
|
3513
|
-
payload.issues = payload.issues.concat(${
|
|
3513
|
+
payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
|
|
3514
3514
|
...iss,
|
|
3515
3515
|
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
3516
3516
|
})));
|
|
3517
3517
|
}
|
|
3518
3518
|
}
|
|
3519
3519
|
|
|
3520
|
-
if (${
|
|
3520
|
+
if (${id2}.value === undefined) {
|
|
3521
3521
|
if (${k} in input) {
|
|
3522
3522
|
newResult[${k}] = undefined;
|
|
3523
3523
|
}
|
|
3524
3524
|
} else {
|
|
3525
|
-
newResult[${k}] = ${
|
|
3525
|
+
newResult[${k}] = ${id2}.value;
|
|
3526
3526
|
}
|
|
3527
3527
|
|
|
3528
3528
|
`);
|
|
3529
3529
|
} else if (!isOptionalIn) {
|
|
3530
3530
|
doc.write(`
|
|
3531
|
-
const ${
|
|
3532
|
-
if (${
|
|
3533
|
-
payload.issues = payload.issues.concat(${
|
|
3531
|
+
const ${id2}_present = ${k} in input;
|
|
3532
|
+
if (${id2}.issues.length) {
|
|
3533
|
+
payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
|
|
3534
3534
|
...iss,
|
|
3535
3535
|
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
3536
3536
|
})));
|
|
3537
3537
|
}
|
|
3538
|
-
if (!${
|
|
3538
|
+
if (!${id2}_present && !${id2}.issues.length) {
|
|
3539
3539
|
payload.issues.push({
|
|
3540
3540
|
code: "invalid_type",
|
|
3541
3541
|
expected: "nonoptional",
|
|
@@ -3544,30 +3544,30 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3544
3544
|
});
|
|
3545
3545
|
}
|
|
3546
3546
|
|
|
3547
|
-
if (${
|
|
3548
|
-
if (${
|
|
3547
|
+
if (${id2}_present) {
|
|
3548
|
+
if (${id2}.value === undefined) {
|
|
3549
3549
|
newResult[${k}] = undefined;
|
|
3550
3550
|
} else {
|
|
3551
|
-
newResult[${k}] = ${
|
|
3551
|
+
newResult[${k}] = ${id2}.value;
|
|
3552
3552
|
}
|
|
3553
3553
|
}
|
|
3554
3554
|
|
|
3555
3555
|
`);
|
|
3556
3556
|
} else {
|
|
3557
3557
|
doc.write(`
|
|
3558
|
-
if (${
|
|
3559
|
-
payload.issues = payload.issues.concat(${
|
|
3558
|
+
if (${id2}.issues.length) {
|
|
3559
|
+
payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
|
|
3560
3560
|
...iss,
|
|
3561
3561
|
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
3562
3562
|
})));
|
|
3563
3563
|
}
|
|
3564
3564
|
|
|
3565
|
-
if (${
|
|
3565
|
+
if (${id2}.value === undefined) {
|
|
3566
3566
|
if (${k} in input) {
|
|
3567
3567
|
newResult[${k}] = undefined;
|
|
3568
3568
|
}
|
|
3569
3569
|
} else {
|
|
3570
|
-
newResult[${k}] = ${
|
|
3570
|
+
newResult[${k}] = ${id2}.value;
|
|
3571
3571
|
}
|
|
3572
3572
|
|
|
3573
3573
|
`);
|
|
@@ -11899,26 +11899,26 @@ function extractDefs(ctx, schema) {
|
|
|
11899
11899
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
11900
11900
|
const idToSchema = /* @__PURE__ */ new Map();
|
|
11901
11901
|
for (const entry of ctx.seen.entries()) {
|
|
11902
|
-
const
|
|
11903
|
-
if (
|
|
11904
|
-
const existing = idToSchema.get(
|
|
11902
|
+
const id2 = ctx.metadataRegistry.get(entry[0])?.id;
|
|
11903
|
+
if (id2) {
|
|
11904
|
+
const existing = idToSchema.get(id2);
|
|
11905
11905
|
if (existing && existing !== entry[0]) {
|
|
11906
|
-
throw new Error(`Duplicate schema id "${
|
|
11906
|
+
throw new Error(`Duplicate schema id "${id2}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
11907
11907
|
}
|
|
11908
|
-
idToSchema.set(
|
|
11908
|
+
idToSchema.set(id2, entry[0]);
|
|
11909
11909
|
}
|
|
11910
11910
|
}
|
|
11911
11911
|
const makeURI = (entry) => {
|
|
11912
11912
|
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
11913
11913
|
if (ctx.external) {
|
|
11914
11914
|
const externalId = ctx.external.registry.get(entry[0])?.id;
|
|
11915
|
-
const uriGenerator = ctx.external.uri ?? ((
|
|
11915
|
+
const uriGenerator = ctx.external.uri ?? ((id3) => id3);
|
|
11916
11916
|
if (externalId) {
|
|
11917
11917
|
return { ref: uriGenerator(externalId) };
|
|
11918
11918
|
}
|
|
11919
|
-
const
|
|
11920
|
-
entry[1].defId =
|
|
11921
|
-
return { defId:
|
|
11919
|
+
const id2 = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
|
|
11920
|
+
entry[1].defId = id2;
|
|
11921
|
+
return { defId: id2, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id2}` };
|
|
11922
11922
|
}
|
|
11923
11923
|
if (entry[1] === root) {
|
|
11924
11924
|
return { ref: "#" };
|
|
@@ -11966,8 +11966,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
11966
11966
|
continue;
|
|
11967
11967
|
}
|
|
11968
11968
|
}
|
|
11969
|
-
const
|
|
11970
|
-
if (
|
|
11969
|
+
const id2 = ctx.metadataRegistry.get(entry[0])?.id;
|
|
11970
|
+
if (id2) {
|
|
11971
11971
|
extractToDef(entry);
|
|
11972
11972
|
continue;
|
|
11973
11973
|
}
|
|
@@ -12063,10 +12063,10 @@ function finalize(ctx, schema) {
|
|
|
12063
12063
|
} else {
|
|
12064
12064
|
}
|
|
12065
12065
|
if (ctx.external?.uri) {
|
|
12066
|
-
const
|
|
12067
|
-
if (!
|
|
12066
|
+
const id2 = ctx.external.registry.get(schema)?.id;
|
|
12067
|
+
if (!id2)
|
|
12068
12068
|
throw new Error("Schema is missing an `id` property");
|
|
12069
|
-
result.$id = ctx.external.uri(
|
|
12069
|
+
result.$id = ctx.external.uri(id2);
|
|
12070
12070
|
}
|
|
12071
12071
|
Object.assign(result, root.def ?? root.schema);
|
|
12072
12072
|
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
@@ -12226,9 +12226,9 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
12226
12226
|
json2.type = "number";
|
|
12227
12227
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
12228
12228
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
12229
|
-
const
|
|
12229
|
+
const legacy2 = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
12230
12230
|
if (exMin) {
|
|
12231
|
-
if (
|
|
12231
|
+
if (legacy2) {
|
|
12232
12232
|
json2.minimum = exclusiveMinimum;
|
|
12233
12233
|
json2.exclusiveMinimum = true;
|
|
12234
12234
|
} else {
|
|
@@ -12238,7 +12238,7 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
12238
12238
|
json2.minimum = minimum;
|
|
12239
12239
|
}
|
|
12240
12240
|
if (exMax) {
|
|
12241
|
-
if (
|
|
12241
|
+
if (legacy2) {
|
|
12242
12242
|
json2.maximum = exclusiveMaximum;
|
|
12243
12243
|
json2.exclusiveMaximum = true;
|
|
12244
12244
|
} else {
|
|
@@ -13100,7 +13100,7 @@ var safeDecodeAsync2 = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
|
13100
13100
|
|
|
13101
13101
|
// ../../../node_modules/zod/v4/classic/schemas.js
|
|
13102
13102
|
var _installedGroups = /* @__PURE__ */ new WeakMap();
|
|
13103
|
-
function _installLazyMethods(inst, group,
|
|
13103
|
+
function _installLazyMethods(inst, group, methods2) {
|
|
13104
13104
|
const proto = Object.getPrototypeOf(inst);
|
|
13105
13105
|
let installed = _installedGroups.get(proto);
|
|
13106
13106
|
if (!installed) {
|
|
@@ -13110,8 +13110,8 @@ function _installLazyMethods(inst, group, methods) {
|
|
|
13110
13110
|
if (installed.has(group))
|
|
13111
13111
|
return;
|
|
13112
13112
|
installed.add(group);
|
|
13113
|
-
for (const key in
|
|
13114
|
-
const fn =
|
|
13113
|
+
for (const key in methods2) {
|
|
13114
|
+
const fn = methods2[key];
|
|
13115
13115
|
Object.defineProperty(proto, key, {
|
|
13116
13116
|
configurable: true,
|
|
13117
13117
|
enumerable: false,
|
|
@@ -14922,87 +14922,6 @@ function date4(params) {
|
|
|
14922
14922
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
14923
14923
|
config(en_default());
|
|
14924
14924
|
|
|
14925
|
-
// ../../shared-contracts/dist/ids.js
|
|
14926
|
-
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
14927
|
-
message: "Identifier must not be empty or whitespace"
|
|
14928
|
-
});
|
|
14929
|
-
var harnessIdSchema = opaqueIdSchema.brand();
|
|
14930
|
-
var hostThreadIdSchema = opaqueIdSchema.brand();
|
|
14931
|
-
var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
14932
|
-
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
14933
|
-
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
14934
|
-
|
|
14935
|
-
// ../../shared-contracts/dist/harness-plugins.js
|
|
14936
|
-
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
14937
|
-
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
14938
|
-
var HARNESS_PLUGIN_LIMIT = 128;
|
|
14939
|
-
var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
|
|
14940
|
-
var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
|
|
14941
|
-
var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id) => id !== "codex", "The official Codex identity is reserved");
|
|
14942
|
-
var pluginRelativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
|
|
14943
|
-
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
14944
|
-
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
14945
|
-
var harnessInstallationGuideSchema = external_exports.object({
|
|
14946
|
-
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
14947
|
-
before: localizedTextSchema.optional(),
|
|
14948
|
-
after: localizedTextSchema.optional(),
|
|
14949
|
-
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
14950
|
-
}).strict();
|
|
14951
|
-
var pluginPresentationShape = {
|
|
14952
|
-
id: installedHarnessPluginIdSchema,
|
|
14953
|
-
name: external_exports.string().trim().min(1).max(128),
|
|
14954
|
-
version: external_exports.string().min(1).max(128),
|
|
14955
|
-
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
14956
|
-
kind: external_exports.literal("usage").optional(),
|
|
14957
|
-
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
14958
|
-
iconStyle: external_exports.object({
|
|
14959
|
-
vector: external_exports.object({
|
|
14960
|
-
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
14961
|
-
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
14962
|
-
paths: external_exports.array(external_exports.object({
|
|
14963
|
-
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
14964
|
-
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
14965
|
-
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
14966
|
-
}).strict()).min(1).max(32)
|
|
14967
|
-
}).strict().optional(),
|
|
14968
|
-
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
14969
|
-
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
14970
|
-
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
14971
|
-
}).strict().optional(),
|
|
14972
|
-
installation: harnessInstallationGuideSchema.optional(),
|
|
14973
|
-
notice: localizedTextSchema.optional(),
|
|
14974
|
-
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
14975
|
-
launchCommand: external_exports.literal(true).optional(),
|
|
14976
|
-
links: external_exports.object({
|
|
14977
|
-
website: documentationUrlSchema.optional(),
|
|
14978
|
-
documentation: documentationUrlSchema.optional(),
|
|
14979
|
-
installation: documentationUrlSchema.optional()
|
|
14980
|
-
}).strict().optional()
|
|
14981
|
-
};
|
|
14982
|
-
var harnessPluginManifestSchema = external_exports.object({
|
|
14983
|
-
manifestVersion: external_exports.literal(1),
|
|
14984
|
-
...pluginPresentationShape,
|
|
14985
|
-
adapterApiVersion: external_exports.number().int().positive(),
|
|
14986
|
-
entry: pluginRelativeResourceSchema,
|
|
14987
|
-
icon: pluginRelativeResourceSchema.optional()
|
|
14988
|
-
}).strict();
|
|
14989
|
-
var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
|
|
14990
|
-
var harnessPluginDescriptorSchema = external_exports.object({
|
|
14991
|
-
...pluginPresentationShape,
|
|
14992
|
-
icon: harnessPluginIconSchema.optional()
|
|
14993
|
-
}).strict();
|
|
14994
|
-
var harnessPluginListParamsSchema = external_exports.object({}).strict();
|
|
14995
|
-
var harnessPluginListResultSchema = external_exports.object({
|
|
14996
|
-
plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
|
|
14997
|
-
}).strict();
|
|
14998
|
-
var harnessPluginConfigurationSchema = external_exports.object({
|
|
14999
|
-
version: external_exports.literal(1),
|
|
15000
|
-
enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
15001
|
-
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
15002
|
-
message: "Enabled plugin IDs must be unique",
|
|
15003
|
-
path: ["enabled"]
|
|
15004
|
-
});
|
|
15005
|
-
|
|
15006
14925
|
// ../../shared-contracts/dist/json-value.js
|
|
15007
14926
|
function rejectExplicitUndefined(keys) {
|
|
15008
14927
|
return (value, context) => {
|
|
@@ -15062,403 +14981,73 @@ var jsonValueSchema = nonCircularSchema.pipe(recursiveJsonValueSchema);
|
|
|
15062
14981
|
var jsonArraySchema = nonCircularSchema.pipe(external_exports.array(recursiveJsonValueSchema));
|
|
15063
14982
|
var jsonObjectSchema = nonCircularSchema.pipe(external_exports.record(external_exports.string(), recursiveJsonValueSchema));
|
|
15064
14983
|
|
|
15065
|
-
// ../../shared-contracts/dist/
|
|
15066
|
-
var
|
|
15067
|
-
|
|
15068
|
-
|
|
15069
|
-
|
|
15070
|
-
|
|
15071
|
-
|
|
15072
|
-
|
|
15073
|
-
|
|
15074
|
-
|
|
15075
|
-
|
|
15076
|
-
|
|
15077
|
-
var
|
|
15078
|
-
var
|
|
15079
|
-
var
|
|
15080
|
-
|
|
15081
|
-
|
|
15082
|
-
|
|
15083
|
-
|
|
15084
|
-
|
|
15085
|
-
|
|
15086
|
-
var
|
|
15087
|
-
"
|
|
15088
|
-
|
|
15089
|
-
|
|
15090
|
-
|
|
15091
|
-
|
|
15092
|
-
|
|
15093
|
-
|
|
15094
|
-
|
|
15095
|
-
|
|
15096
|
-
|
|
15097
|
-
|
|
15098
|
-
|
|
15099
|
-
|
|
15100
|
-
|
|
15101
|
-
|
|
15102
|
-
|
|
15103
|
-
|
|
15104
|
-
|
|
15105
|
-
|
|
14984
|
+
// ../../shared-contracts/dist/errors.js
|
|
14985
|
+
var codexhostErrorSchema = external_exports.strictObject({
|
|
14986
|
+
code: external_exports.string().min(1),
|
|
14987
|
+
message: external_exports.string().min(1),
|
|
14988
|
+
retryable: external_exports.boolean(),
|
|
14989
|
+
diagnostic: external_exports.string().min(1).optional(),
|
|
14990
|
+
stage: external_exports.string().min(1).optional(),
|
|
14991
|
+
durationMs: external_exports.number().int().nonnegative().optional(),
|
|
14992
|
+
stderrTail: external_exports.string().min(1).optional()
|
|
14993
|
+
}).superRefine(rejectExplicitUndefined(["diagnostic", "stage", "durationMs", "stderrTail"]));
|
|
14994
|
+
|
|
14995
|
+
// ../../shared-contracts/dist/harness-presentation.js
|
|
14996
|
+
var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
|
|
14997
|
+
var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text4) => text4.trim().length > 0);
|
|
14998
|
+
var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
|
|
14999
|
+
label: displayText(256).optional(),
|
|
15000
|
+
description: displayText(1024).optional()
|
|
15001
|
+
}).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
|
|
15002
|
+
var harnessLocalizedTextSchema = external_exports.record(localeSchema, displayText(4096)).refine((entries) => typeof entries.en === "string", "English fallback is required").refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
|
|
15003
|
+
|
|
15004
|
+
// ../../shared-contracts/dist/ids.js
|
|
15005
|
+
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
15006
|
+
message: "Identifier must not be empty or whitespace"
|
|
15007
|
+
});
|
|
15008
|
+
var harnessIdSchema = opaqueIdSchema.brand();
|
|
15009
|
+
var hostThreadIdSchema = opaqueIdSchema.brand();
|
|
15010
|
+
var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
15011
|
+
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
15012
|
+
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
15013
|
+
|
|
15014
|
+
// ../../shared-contracts/dist/harness-permission-modes.js
|
|
15015
|
+
var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
|
|
15016
|
+
var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
|
|
15017
|
+
var HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024;
|
|
15018
|
+
var HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32;
|
|
15019
|
+
var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
15020
|
+
message: "Value must not be empty or whitespace"
|
|
15021
|
+
});
|
|
15022
|
+
var harnessPermissionModeIdSchema = nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~:-]+$/u, "Permission Mode ID must use transport-safe characters").brand();
|
|
15023
|
+
var harnessPermissionModeSchema = external_exports.object({
|
|
15024
|
+
id: harnessPermissionModeIdSchema,
|
|
15025
|
+
label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
|
|
15026
|
+
description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
|
|
15027
|
+
dangerous: external_exports.boolean().optional(),
|
|
15028
|
+
localizations: harnessLocalizationsSchema.optional()
|
|
15029
|
+
}).strict();
|
|
15030
|
+
var harnessPermissionModeCatalogSchema = external_exports.object({
|
|
15031
|
+
modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
|
|
15032
|
+
defaultModeId: harnessPermissionModeIdSchema
|
|
15033
|
+
}).strict().superRefine((catalog, context) => {
|
|
15034
|
+
const ids = /* @__PURE__ */ new Set();
|
|
15035
|
+
for (const [index, mode] of catalog.modes.entries()) {
|
|
15036
|
+
if (ids.has(mode.id)) {
|
|
15037
|
+
context.addIssue({
|
|
15038
|
+
code: "custom",
|
|
15039
|
+
message: "Permission Mode IDs must be unique",
|
|
15040
|
+
path: ["modes", index, "id"]
|
|
15041
|
+
});
|
|
15042
|
+
}
|
|
15043
|
+
ids.add(mode.id);
|
|
15106
15044
|
}
|
|
15107
|
-
|
|
15108
|
-
|
|
15109
|
-
|
|
15110
|
-
|
|
15111
|
-
|
|
15112
|
-
|
|
15113
|
-
return "image/svg+xml";
|
|
15114
|
-
case "woff2":
|
|
15115
|
-
return "font/woff2";
|
|
15116
|
-
case "json":
|
|
15117
|
-
return "application/json";
|
|
15118
|
-
case "css":
|
|
15119
|
-
return "text/css";
|
|
15120
|
-
default:
|
|
15121
|
-
return desktopExtensionScreenshotMimeType(resource);
|
|
15122
|
-
}
|
|
15123
|
-
}
|
|
15124
|
-
var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
|
|
15125
|
-
var desktopExtensionAssetPathSchema = pluginRelativeResourceSchema.refine((resource) => hasPortableSegments(resource) && desktopExtensionAssetMimeType(resource) !== void 0, "Expected a relative Desktop extension asset path with a supported suffix");
|
|
15126
|
-
var imagePathSchema = pluginRelativeResourceSchema.refine((resource) => desktopExtensionScreenshotMimeType(resource) !== void 0 && hasPortableSegments(resource), "Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space");
|
|
15127
|
-
var desktopExtensionHttpUrlSchema = external_exports.string().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu, "Expected an HTTP(S) URL").pipe(external_exports.url({ protocol: /^https?$/u })).refine((value) => {
|
|
15128
|
-
const { username, password } = new URL(value);
|
|
15129
|
-
return !username && !password && !/[\\\s]/u.test(value);
|
|
15130
|
-
}, "URL must not contain credentials, backslashes, or whitespace");
|
|
15131
|
-
function localizedText(text4) {
|
|
15132
|
-
return external_exports.strictObject({ en: text4, "zh-CN": text4 });
|
|
15133
|
-
}
|
|
15134
|
-
var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
|
|
15135
|
-
var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
|
|
15136
|
-
var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
|
|
15137
|
-
var settingField = {
|
|
15138
|
-
key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
|
|
15139
|
-
label: desktopExtensionLocalizedTextSchema,
|
|
15140
|
-
description: desktopExtensionLocalizedTextSchema.optional()
|
|
15141
|
-
};
|
|
15142
|
-
var numericSetting = {
|
|
15143
|
-
...settingField,
|
|
15144
|
-
step: external_exports.number().positive().optional(),
|
|
15145
|
-
default: external_exports.number().optional()
|
|
15146
|
-
};
|
|
15147
|
-
var settingOption = external_exports.strictObject({
|
|
15148
|
-
value: external_exports.string(),
|
|
15149
|
-
label: desktopExtensionLocalizedTextSchema
|
|
15150
|
-
});
|
|
15151
|
-
var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
|
|
15152
|
-
external_exports.strictObject({
|
|
15153
|
-
...settingField,
|
|
15154
|
-
type: external_exports.literal("boolean"),
|
|
15155
|
-
default: external_exports.boolean().optional()
|
|
15156
|
-
}),
|
|
15157
|
-
external_exports.strictObject({
|
|
15158
|
-
...settingField,
|
|
15159
|
-
type: external_exports.literal("string"),
|
|
15160
|
-
placeholder: desktopExtensionLocalizedTextSchema.optional(),
|
|
15161
|
-
default: external_exports.string().optional()
|
|
15162
|
-
}),
|
|
15163
|
-
external_exports.strictObject({
|
|
15164
|
-
...numericSetting,
|
|
15165
|
-
type: external_exports.literal("number"),
|
|
15166
|
-
min: external_exports.number().optional(),
|
|
15167
|
-
max: external_exports.number().optional()
|
|
15168
|
-
}),
|
|
15169
|
-
external_exports.strictObject({
|
|
15170
|
-
...numericSetting,
|
|
15171
|
-
type: external_exports.literal("range"),
|
|
15172
|
-
min: external_exports.number(),
|
|
15173
|
-
max: external_exports.number()
|
|
15174
|
-
}),
|
|
15175
|
-
external_exports.strictObject({
|
|
15176
|
-
...settingField,
|
|
15177
|
-
type: external_exports.literal("select"),
|
|
15178
|
-
options: external_exports.array(settingOption).min(1),
|
|
15179
|
-
default: external_exports.string().optional()
|
|
15180
|
-
})
|
|
15181
|
-
]).superRefine((field2, ctx) => {
|
|
15182
|
-
const issue2 = (path18, message3) => ctx.addIssue({ code: "custom", path: [path18], message: message3 });
|
|
15183
|
-
if (field2.type === "number" || field2.type === "range") {
|
|
15184
|
-
const { min = -Infinity, max = Infinity, default: value } = field2;
|
|
15185
|
-
if (min > max)
|
|
15186
|
-
issue2("max", "Must be at least min");
|
|
15187
|
-
if (value !== void 0 && (value < min || value > max))
|
|
15188
|
-
issue2("default", "Must be within min and max");
|
|
15189
|
-
} else if (field2.type === "select") {
|
|
15190
|
-
const values = new Set(field2.options.map(({ value }) => value));
|
|
15191
|
-
if (values.size !== field2.options.length)
|
|
15192
|
-
issue2("options", "Duplicate option values");
|
|
15193
|
-
if (field2.default !== void 0 && !values.has(field2.default))
|
|
15194
|
-
issue2("default", "Must match an option value");
|
|
15195
|
-
}
|
|
15196
|
-
});
|
|
15197
|
-
var manifestHeader = external_exports.object({
|
|
15198
|
-
manifestVersion: external_exports.int().positive(),
|
|
15199
|
-
id: desktopExtensionIdSchema,
|
|
15200
|
-
name: external_exports.union([extensionName, localizedText(extensionName)]),
|
|
15201
|
-
version: external_exports.string().min(1).max(128),
|
|
15202
|
-
desktopApi: external_exports.int().positive()
|
|
15203
|
-
}).passthrough();
|
|
15204
|
-
var desktopExtensionManifestSchema = manifestHeader.extend({
|
|
15205
|
-
manifestVersion: external_exports.literal(1),
|
|
15206
|
-
desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
|
|
15207
|
-
description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
|
|
15208
|
-
author: external_exports.string().trim().min(1).max(128).optional(),
|
|
15209
|
-
repository: desktopExtensionHttpUrlSchema.optional(),
|
|
15210
|
-
details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
|
|
15211
|
-
icon: imagePathSchema.optional(),
|
|
15212
|
-
screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
|
|
15213
|
-
desktop: external_exports.strictObject({
|
|
15214
|
-
script: pluginRelativeResourceSchema,
|
|
15215
|
-
style: pluginRelativeResourceSchema.optional()
|
|
15216
|
-
}).optional(),
|
|
15217
|
-
backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
|
|
15218
|
-
slots: slotsSchema.default(() => []),
|
|
15219
|
-
settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
|
|
15220
|
-
categories: categoriesSchema.optional()
|
|
15221
|
-
}).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
|
|
15222
|
-
var desktopExtensionConfigurationSchema = external_exports.strictObject({
|
|
15223
|
-
version: external_exports.literal(1),
|
|
15224
|
-
revision: external_exports.int().nonnegative(),
|
|
15225
|
-
enabled: external_exports.array(desktopExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs"),
|
|
15226
|
-
reloadToken: external_exports.uuid().optional()
|
|
15227
|
-
});
|
|
15228
|
-
var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
|
|
15229
|
-
var desktopExtensionStatusSchema = external_exports.strictObject({
|
|
15230
|
-
state: external_exports.enum([
|
|
15231
|
-
"running",
|
|
15232
|
-
"disabled",
|
|
15233
|
-
"invalid",
|
|
15234
|
-
"incompatible",
|
|
15235
|
-
"conflict",
|
|
15236
|
-
"failed",
|
|
15237
|
-
"waiting"
|
|
15238
|
-
]),
|
|
15239
|
-
hash: desktopExtensionHashSchema.optional(),
|
|
15240
|
-
error: external_exports.string().optional(),
|
|
15241
|
-
conflictWith: desktopExtensionIdSchema.optional()
|
|
15242
|
-
});
|
|
15243
|
-
var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
|
|
15244
|
-
controllerPid: external_exports.int().positive(),
|
|
15245
|
-
targetId: external_exports.string().nullable(),
|
|
15246
|
-
updatedAt: external_exports.iso.datetime(),
|
|
15247
|
-
handledReloadToken: external_exports.uuid().optional(),
|
|
15248
|
-
extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema)
|
|
15249
|
-
});
|
|
15250
|
-
var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
|
|
15251
|
-
function isGitHubDesktopExtensionZipballUrl(url2) {
|
|
15252
|
-
return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
|
|
15253
|
-
}
|
|
15254
|
-
var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
|
|
15255
|
-
const url2 = new URL(input);
|
|
15256
|
-
return /\.zip$/iu.test(url2.pathname) || isGitHubDesktopExtensionZipballUrl(url2) || url2.origin === "https://github.com" && /^\/[\w-]+\/[\w.-]+\/zipball(?:\/.+)?\/?$/u.test(url2.pathname) || url2.origin === "https://codeload.github.com" && /^\/[\w-]+\/[\w.-]+\/(?:zip|zipball|legacy\.zip)\/.+$/u.test(url2.pathname);
|
|
15257
|
-
}, "Expected a .zip download URL or a GitHub zipball URL");
|
|
15258
|
-
var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
|
|
15259
|
-
id: desktopExtensionIdSchema,
|
|
15260
|
-
version: external_exports.string().trim().min(1).max(128),
|
|
15261
|
-
name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
|
|
15262
|
-
description: localizedText(external_exports.string().trim().min(1).max(4096)),
|
|
15263
|
-
details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
|
|
15264
|
-
author: external_exports.string().trim().min(1).max(128),
|
|
15265
|
-
repository: desktopExtensionHttpUrlSchema,
|
|
15266
|
-
stars: external_exports.number().int().min(0).optional(),
|
|
15267
|
-
downloads: external_exports.number().int().min(0).optional(),
|
|
15268
|
-
categories: categoriesSchema.optional(),
|
|
15269
|
-
trustTier: desktopExtensionTrustTierSchema.default("community"),
|
|
15270
|
-
icon: desktopExtensionHttpUrlSchema.optional(),
|
|
15271
|
-
screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
15272
|
-
downloadUrl: desktopExtensionZipUrlSchema,
|
|
15273
|
-
sha256: desktopExtensionHashSchema,
|
|
15274
|
-
slots: slotsSchema.optional(),
|
|
15275
|
-
publishedAt: external_exports.string().optional(),
|
|
15276
|
-
updatedAt: external_exports.string().optional(),
|
|
15277
|
-
minCodexHostVersion: external_exports.string().optional()
|
|
15278
|
-
});
|
|
15279
|
-
var desktopExtensionCatalogSchema = external_exports.strictObject({
|
|
15280
|
-
schemaVersion: external_exports.literal(1),
|
|
15281
|
-
generatedAt: external_exports.string(),
|
|
15282
|
-
extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, "Duplicate extension IDs")
|
|
15283
|
-
});
|
|
15284
|
-
var DESKTOP_EXTENSIONS_ASSET_METHOD = "codexhost/desktop/extensions/asset";
|
|
15285
|
-
var DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD = "codexhost/desktop/extensions/settings/get";
|
|
15286
|
-
var DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD = "codexhost/desktop/extensions/settings/set";
|
|
15287
|
-
var DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD = "codexhost/desktop/extensions/backend/invoke";
|
|
15288
|
-
var extensionIdParams = { id: desktopExtensionIdSchema };
|
|
15289
|
-
var desktopExtensionsAssetParamsSchema = external_exports.strictObject({
|
|
15290
|
-
...extensionIdParams,
|
|
15291
|
-
path: desktopExtensionAssetPathSchema
|
|
15292
|
-
});
|
|
15293
|
-
var desktopExtensionsAssetResultSchema = external_exports.strictObject({
|
|
15294
|
-
mimeType: external_exports.string(),
|
|
15295
|
-
dataUrl: external_exports.string()
|
|
15296
|
-
});
|
|
15297
|
-
var desktopExtensionsSettingsGetParamsSchema = external_exports.strictObject(extensionIdParams);
|
|
15298
|
-
var desktopExtensionsSettingsSetParamsSchema = external_exports.strictObject({
|
|
15299
|
-
...extensionIdParams,
|
|
15300
|
-
values: jsonObjectSchema
|
|
15301
|
-
});
|
|
15302
|
-
var desktopExtensionsSettingsResultSchema = external_exports.strictObject({ values: jsonObjectSchema });
|
|
15303
|
-
var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
|
|
15304
|
-
var desktopExtensionsBackendInvokeParamsSchema = external_exports.strictObject({
|
|
15305
|
-
...extensionIdParams,
|
|
15306
|
-
method: desktopExtensionBackendMethodSchema,
|
|
15307
|
-
params: jsonValueSchema.optional()
|
|
15308
|
-
});
|
|
15309
|
-
var desktopExtensionsBackendInvokeResultSchema = external_exports.strictObject({
|
|
15310
|
-
result: jsonValueSchema
|
|
15311
|
-
});
|
|
15312
|
-
|
|
15313
|
-
// ../../shared-contracts/dist/desktop-extension-management.js
|
|
15314
|
-
var DESKTOP_EXTENSIONS_LIST_METHOD = "codexhost/desktop/extensions/list";
|
|
15315
|
-
var DESKTOP_EXTENSIONS_ENABLE_METHOD = "codexhost/desktop/extensions/enable";
|
|
15316
|
-
var DESKTOP_EXTENSIONS_DISABLE_METHOD = "codexhost/desktop/extensions/disable";
|
|
15317
|
-
var DESKTOP_EXTENSIONS_CATALOG_METHOD = "codexhost/desktop/extensions/catalog";
|
|
15318
|
-
var DESKTOP_EXTENSIONS_INSTALL_METHOD = "codexhost/desktop/extensions/install";
|
|
15319
|
-
var DESKTOP_EXTENSIONS_UNINSTALL_METHOD = "codexhost/desktop/extensions/uninstall";
|
|
15320
|
-
var DESKTOP_EXTENSIONS_RECOVER_METHOD = "codexhost/desktop/extensions/disable-all-and-reload";
|
|
15321
|
-
var DESKTOP_EXTENSION_MANAGEMENT_METHODS = [
|
|
15322
|
-
DESKTOP_EXTENSIONS_LIST_METHOD,
|
|
15323
|
-
DESKTOP_EXTENSIONS_ENABLE_METHOD,
|
|
15324
|
-
DESKTOP_EXTENSIONS_DISABLE_METHOD,
|
|
15325
|
-
DESKTOP_EXTENSIONS_RECOVER_METHOD,
|
|
15326
|
-
DESKTOP_EXTENSIONS_CATALOG_METHOD,
|
|
15327
|
-
DESKTOP_EXTENSIONS_INSTALL_METHOD,
|
|
15328
|
-
DESKTOP_EXTENSIONS_UNINSTALL_METHOD,
|
|
15329
|
-
DESKTOP_EXTENSIONS_ASSET_METHOD,
|
|
15330
|
-
DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD,
|
|
15331
|
-
DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD,
|
|
15332
|
-
DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD
|
|
15333
|
-
];
|
|
15334
|
-
var revisionSchema = external_exports.int().nonnegative();
|
|
15335
|
-
var desktopExtensionsListParamsSchema = external_exports.strictObject({});
|
|
15336
|
-
var desktopExtensionSelectionParamsSchema = external_exports.strictObject({
|
|
15337
|
-
id: desktopExtensionIdSchema,
|
|
15338
|
-
expectedRevision: revisionSchema
|
|
15339
|
-
});
|
|
15340
|
-
var desktopExtensionsRecoveryParamsSchema = external_exports.strictObject({
|
|
15341
|
-
expectedRevision: revisionSchema.optional()
|
|
15342
|
-
});
|
|
15343
|
-
var rasterDataUrlSchema = (maxBytes) => external_exports.string().max("data:image/jpeg;base64,".length + 4 * Math.ceil(maxBytes / 3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u);
|
|
15344
|
-
var desktopExtensionListItemSchema = external_exports.strictObject({
|
|
15345
|
-
// An invalid discovery can have a directory name that isn't a valid extension ID.
|
|
15346
|
-
id: external_exports.string().min(1),
|
|
15347
|
-
manifest: desktopExtensionManifestSchema.optional(),
|
|
15348
|
-
iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
|
|
15349
|
-
screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
15350
|
-
enabled: external_exports.boolean(),
|
|
15351
|
-
status: desktopExtensionStatusSchema
|
|
15352
|
-
});
|
|
15353
|
-
var desktopExtensionsListResultSchema = external_exports.strictObject({
|
|
15354
|
-
configuration: desktopExtensionConfigurationSchema,
|
|
15355
|
-
desktopConnected: external_exports.boolean(),
|
|
15356
|
-
diagnostics: external_exports.array(external_exports.string()),
|
|
15357
|
-
extensions: external_exports.array(desktopExtensionListItemSchema)
|
|
15358
|
-
});
|
|
15359
|
-
var desktopExtensionsCatalogParamsSchema = external_exports.strictObject({
|
|
15360
|
-
forceRefresh: external_exports.boolean().optional()
|
|
15361
|
-
});
|
|
15362
|
-
var desktopExtensionsCatalogResultSchema = external_exports.strictObject({
|
|
15363
|
-
catalogUrl: external_exports.string(),
|
|
15364
|
-
source: external_exports.enum(["remote", "fallback"]),
|
|
15365
|
-
fetchedAt: external_exports.string(),
|
|
15366
|
-
cached: external_exports.boolean(),
|
|
15367
|
-
extensions: desktopExtensionCatalogSchema.shape.extensions,
|
|
15368
|
-
error: external_exports.string().optional()
|
|
15369
|
-
});
|
|
15370
|
-
var desktopExtensionsInstallParamsSchema = external_exports.strictObject({
|
|
15371
|
-
source: external_exports.discriminatedUnion("type", [
|
|
15372
|
-
external_exports.strictObject({ type: external_exports.literal("catalog"), id: desktopExtensionIdSchema }),
|
|
15373
|
-
external_exports.strictObject({
|
|
15374
|
-
type: external_exports.literal("url"),
|
|
15375
|
-
url: desktopExtensionHttpUrlSchema,
|
|
15376
|
-
expectedSha256: desktopExtensionHashSchema.optional()
|
|
15377
|
-
}),
|
|
15378
|
-
external_exports.strictObject({
|
|
15379
|
-
type: external_exports.literal("zip-base64"),
|
|
15380
|
-
fileName: external_exports.string().trim().min(1).max(255),
|
|
15381
|
-
contentBase64: external_exports.string().min(4).max(DESKTOP_EXTENSION_ZIP_MAX_BASE64_LENGTH).refine((value) => value.length % 4 === 0 && /^[A-Za-z0-9+/]+={0,2}$/u.test(value), "Expected standard padded base64")
|
|
15382
|
-
})
|
|
15383
|
-
])
|
|
15384
|
-
});
|
|
15385
|
-
var desktopExtensionsInstallResultSchema = external_exports.strictObject({
|
|
15386
|
-
extensionId: desktopExtensionIdSchema,
|
|
15387
|
-
version: external_exports.string().min(1),
|
|
15388
|
-
replaced: external_exports.boolean(),
|
|
15389
|
-
installedPath: external_exports.string(),
|
|
15390
|
-
list: desktopExtensionsListResultSchema
|
|
15391
|
-
});
|
|
15392
|
-
var desktopExtensionsUninstallParamsSchema = external_exports.strictObject({
|
|
15393
|
-
id: desktopExtensionIdSchema
|
|
15394
|
-
});
|
|
15395
|
-
var desktopExtensionsUninstallResultSchema = external_exports.strictObject({
|
|
15396
|
-
removedId: desktopExtensionIdSchema,
|
|
15397
|
-
list: desktopExtensionsListResultSchema
|
|
15398
|
-
});
|
|
15399
|
-
var desktopExtensionMutationResultSchema = external_exports.discriminatedUnion("state", [
|
|
15400
|
-
external_exports.strictObject({ state: external_exports.literal("saved"), configuration: desktopExtensionConfigurationSchema }),
|
|
15401
|
-
external_exports.strictObject({ state: external_exports.literal("slot-conflict"), conflictWith: desktopExtensionIdSchema }),
|
|
15402
|
-
external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: revisionSchema })
|
|
15403
|
-
]);
|
|
15404
|
-
|
|
15405
|
-
// ../../shared-contracts/dist/errors.js
|
|
15406
|
-
var codexhostErrorSchema = external_exports.strictObject({
|
|
15407
|
-
code: external_exports.string().min(1),
|
|
15408
|
-
message: external_exports.string().min(1),
|
|
15409
|
-
retryable: external_exports.boolean(),
|
|
15410
|
-
diagnostic: external_exports.string().min(1).optional(),
|
|
15411
|
-
stage: external_exports.string().min(1).optional(),
|
|
15412
|
-
durationMs: external_exports.number().int().nonnegative().optional(),
|
|
15413
|
-
stderrTail: external_exports.string().min(1).optional()
|
|
15414
|
-
}).superRefine(rejectExplicitUndefined(["diagnostic", "stage", "durationMs", "stderrTail"]));
|
|
15415
|
-
|
|
15416
|
-
// ../../shared-contracts/dist/harness-presentation.js
|
|
15417
|
-
var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
|
|
15418
|
-
var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text4) => text4.trim().length > 0);
|
|
15419
|
-
var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
|
|
15420
|
-
label: displayText(256).optional(),
|
|
15421
|
-
description: displayText(1024).optional()
|
|
15422
|
-
}).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
|
|
15423
|
-
var harnessLocalizedTextSchema = external_exports.record(localeSchema, displayText(4096)).refine((entries) => typeof entries.en === "string", "English fallback is required").refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
|
|
15424
|
-
|
|
15425
|
-
// ../../shared-contracts/dist/harness-permission-modes.js
|
|
15426
|
-
var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
|
|
15427
|
-
var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
|
|
15428
|
-
var HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024;
|
|
15429
|
-
var HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32;
|
|
15430
|
-
var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
15431
|
-
message: "Value must not be empty or whitespace"
|
|
15432
|
-
});
|
|
15433
|
-
var harnessPermissionModeIdSchema = nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~:-]+$/u, "Permission Mode ID must use transport-safe characters").brand();
|
|
15434
|
-
var harnessPermissionModeSchema = external_exports.object({
|
|
15435
|
-
id: harnessPermissionModeIdSchema,
|
|
15436
|
-
label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
|
|
15437
|
-
description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
|
|
15438
|
-
dangerous: external_exports.boolean().optional(),
|
|
15439
|
-
localizations: harnessLocalizationsSchema.optional()
|
|
15440
|
-
}).strict();
|
|
15441
|
-
var harnessPermissionModeCatalogSchema = external_exports.object({
|
|
15442
|
-
modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
|
|
15443
|
-
defaultModeId: harnessPermissionModeIdSchema
|
|
15444
|
-
}).strict().superRefine((catalog, context) => {
|
|
15445
|
-
const ids = /* @__PURE__ */ new Set();
|
|
15446
|
-
for (const [index, mode] of catalog.modes.entries()) {
|
|
15447
|
-
if (ids.has(mode.id)) {
|
|
15448
|
-
context.addIssue({
|
|
15449
|
-
code: "custom",
|
|
15450
|
-
message: "Permission Mode IDs must be unique",
|
|
15451
|
-
path: ["modes", index, "id"]
|
|
15452
|
-
});
|
|
15453
|
-
}
|
|
15454
|
-
ids.add(mode.id);
|
|
15455
|
-
}
|
|
15456
|
-
if (!ids.has(catalog.defaultModeId)) {
|
|
15457
|
-
context.addIssue({
|
|
15458
|
-
code: "custom",
|
|
15459
|
-
message: "Default Permission Mode must exist in the catalog",
|
|
15460
|
-
path: ["defaultModeId"]
|
|
15461
|
-
});
|
|
15045
|
+
if (!ids.has(catalog.defaultModeId)) {
|
|
15046
|
+
context.addIssue({
|
|
15047
|
+
code: "custom",
|
|
15048
|
+
message: "Default Permission Mode must exist in the catalog",
|
|
15049
|
+
path: ["defaultModeId"]
|
|
15050
|
+
});
|
|
15462
15051
|
}
|
|
15463
15052
|
});
|
|
15464
15053
|
var threadPermissionModeSelectParamsSchema = external_exports.object({
|
|
@@ -15466,6 +15055,9 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
|
|
|
15466
15055
|
permissionModeId: harnessPermissionModeIdSchema
|
|
15467
15056
|
}).strict();
|
|
15468
15057
|
|
|
15058
|
+
// ../../shared-contracts/dist/harness-route-limit.js
|
|
15059
|
+
var HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH = 8192;
|
|
15060
|
+
|
|
15469
15061
|
// ../../shared-contracts/dist/thread-usage.js
|
|
15470
15062
|
var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
|
|
15471
15063
|
var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
|
|
@@ -15498,7 +15090,7 @@ var composerIndicatorsSchema = external_exports.array(external_exports.object({
|
|
|
15498
15090
|
expiresAtUnix: nonNegativeSafeIntegerSchema,
|
|
15499
15091
|
label: indicatorTextSchema(256).optional(),
|
|
15500
15092
|
tooltip: indicatorTextSchema(1024).optional()
|
|
15501
|
-
}).strict()).max(2).refine((entries) => new Set(entries.map(({ id }) =>
|
|
15093
|
+
}).strict()).max(2).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, {
|
|
15502
15094
|
message: "Composer indicator IDs must be unique"
|
|
15503
15095
|
});
|
|
15504
15096
|
var threadUsageSnapshotSchema = external_exports.object({
|
|
@@ -15524,6 +15116,7 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
15524
15116
|
planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
|
|
15525
15117
|
sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
|
|
15526
15118
|
timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
|
|
15119
|
+
latestRequestTimeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
|
|
15527
15120
|
costSource: external_exports.enum(["publicPrice", "native"]).optional(),
|
|
15528
15121
|
unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
|
|
15529
15122
|
}).strict().superRefine((usage, context) => {
|
|
@@ -15651,10 +15244,15 @@ var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
|
|
|
15651
15244
|
var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
15652
15245
|
message: "Value must not be empty or whitespace"
|
|
15653
15246
|
});
|
|
15654
|
-
var harnessModelRefIdSchema =
|
|
15247
|
+
var harnessModelRefIdSchema = external_exports.string().min(1).max(HARNESS_MODEL_REF_MAX_LENGTH).refine((id2) => !new RegExp("\\p{Cc}", "u").test(id2), "Model Ref must not contain control characters").brand();
|
|
15248
|
+
var harnessModelServiceTierSchema = external_exports.enum(["priority", "ultrafast"]);
|
|
15655
15249
|
var harnessModelRefSchema = external_exports.object({
|
|
15656
|
-
id: harnessModelRefIdSchema
|
|
15250
|
+
id: harnessModelRefIdSchema,
|
|
15251
|
+
serviceTier: harnessModelServiceTierSchema.optional()
|
|
15657
15252
|
}).strict();
|
|
15253
|
+
function sameHarnessModelRef(left, right) {
|
|
15254
|
+
return left?.id === right?.id && left?.serviceTier === right?.serviceTier;
|
|
15255
|
+
}
|
|
15658
15256
|
var harnessThinkingOptionIdSchema = nonBlankTextSchema2.max(HARNESS_THINKING_OPTION_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Thinking option ID must use transport-safe characters").brand();
|
|
15659
15257
|
var harnessResolvedModelLabelSchema = nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
|
|
15660
15258
|
var harnessThinkingOptionSchema = external_exports.object({
|
|
@@ -15668,7 +15266,15 @@ var harnessModelSchema = external_exports.object({
|
|
|
15668
15266
|
/** Optional opaque selection for this same Model with priority processing enabled. */
|
|
15669
15267
|
fastModel: harnessModelRefSchema.optional(),
|
|
15670
15268
|
supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
|
|
15671
|
-
}).strict()
|
|
15269
|
+
}).strict().refine((model2) => model2.fastModel?.serviceTier === void 0 || model2.fastModel.id === model2.ref.id, {
|
|
15270
|
+
path: ["fastModel", "id"],
|
|
15271
|
+
message: "A tiered Fast Model must share the base Model ID"
|
|
15272
|
+
});
|
|
15273
|
+
function catalogModelForRef(catalog, ref) {
|
|
15274
|
+
if (!ref)
|
|
15275
|
+
return void 0;
|
|
15276
|
+
return catalog?.models.find((model2) => sameHarnessModelRef(model2.ref, ref) || sameHarnessModelRef(model2.fastModel, ref));
|
|
15277
|
+
}
|
|
15672
15278
|
var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
|
|
15673
15279
|
const ids = /* @__PURE__ */ new Set();
|
|
15674
15280
|
for (const [index, option] of options.entries()) {
|
|
@@ -15688,26 +15294,26 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
15688
15294
|
thinkingOptions: harnessThinkingOptionsSchema,
|
|
15689
15295
|
defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
|
|
15690
15296
|
}).strict().superRefine((catalog, context) => {
|
|
15691
|
-
const refs =
|
|
15692
|
-
const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) =>
|
|
15297
|
+
const refs = [];
|
|
15298
|
+
const thinkingIds = new Set(catalog.thinkingOptions.map(({ id: id2 }) => id2));
|
|
15693
15299
|
for (const [index, model2] of catalog.models.entries()) {
|
|
15694
|
-
if (refs.
|
|
15300
|
+
if (refs.some((ref) => sameHarnessModelRef(ref, model2.ref))) {
|
|
15695
15301
|
context.addIssue({
|
|
15696
15302
|
code: "custom",
|
|
15697
15303
|
message: "Model Catalog refs must be unique",
|
|
15698
15304
|
path: ["models", index, "ref", "id"]
|
|
15699
15305
|
});
|
|
15700
15306
|
}
|
|
15701
|
-
refs.
|
|
15307
|
+
refs.push(model2.ref);
|
|
15702
15308
|
if (model2.fastModel) {
|
|
15703
|
-
if (refs.
|
|
15309
|
+
if (refs.some((ref) => sameHarnessModelRef(ref, model2.fastModel))) {
|
|
15704
15310
|
context.addIssue({
|
|
15705
15311
|
code: "custom",
|
|
15706
15312
|
message: "Fast Model refs must be distinct and unique",
|
|
15707
15313
|
path: ["models", index, "fastModel"]
|
|
15708
15314
|
});
|
|
15709
15315
|
}
|
|
15710
|
-
refs.
|
|
15316
|
+
refs.push(model2.fastModel);
|
|
15711
15317
|
}
|
|
15712
15318
|
const supportedThinkingIds = /* @__PURE__ */ new Set();
|
|
15713
15319
|
for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
|
|
@@ -15728,7 +15334,7 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
15728
15334
|
}
|
|
15729
15335
|
}
|
|
15730
15336
|
}
|
|
15731
|
-
if (catalog.defaultModel && !
|
|
15337
|
+
if (catalog.defaultModel && !catalogModelForRef(catalog, catalog.defaultModel)) {
|
|
15732
15338
|
context.addIssue({
|
|
15733
15339
|
code: "custom",
|
|
15734
15340
|
message: "Default Model must exist in the Model Catalog",
|
|
@@ -15768,7 +15374,12 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
|
|
|
15768
15374
|
observe: external_exports.boolean()
|
|
15769
15375
|
}).strict().optional(),
|
|
15770
15376
|
/** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
|
|
15771
|
-
steer: external_exports.boolean().optional()
|
|
15377
|
+
steer: external_exports.boolean().optional(),
|
|
15378
|
+
/**
|
|
15379
|
+
* True when the native plan (task list) outlives the Turn that changed it, so a reopened
|
|
15380
|
+
* Thread gets its latest plan again. Otherwise a plan stays with the Turn that made it.
|
|
15381
|
+
*/
|
|
15382
|
+
persistentPlan: external_exports.boolean().optional()
|
|
15772
15383
|
}).strict();
|
|
15773
15384
|
var harnessConfigurationStateSchema = external_exports.object({
|
|
15774
15385
|
effectiveModel: harnessModelRefSchema.optional(),
|
|
@@ -15777,7 +15388,7 @@ var harnessConfigurationStateSchema = external_exports.object({
|
|
|
15777
15388
|
availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
|
|
15778
15389
|
effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
|
|
15779
15390
|
}).strict().superRefine((state2, context) => {
|
|
15780
|
-
if (state2.effectiveThinkingOptionId && state2.availableThinkingOptions && !state2.availableThinkingOptions.some(({ id }) =>
|
|
15391
|
+
if (state2.effectiveThinkingOptionId && state2.availableThinkingOptions && !state2.availableThinkingOptions.some(({ id: id2 }) => id2 === state2.effectiveThinkingOptionId)) {
|
|
15781
15392
|
context.addIssue({
|
|
15782
15393
|
code: "custom",
|
|
15783
15394
|
message: "Effective Thinking option must be currently available",
|
|
@@ -15817,7 +15428,8 @@ var harnessInspectParamsSchema = external_exports.object({
|
|
|
15817
15428
|
cwd: nonBlankTextSchema2.max(16384).optional(),
|
|
15818
15429
|
refresh: external_exports.boolean().optional(),
|
|
15819
15430
|
/** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
|
|
15820
|
-
purpose: external_exports.literal("availability").optional()
|
|
15431
|
+
purpose: external_exports.literal("availability").optional(),
|
|
15432
|
+
credentialAccess: external_exports.enum(["allow", "retry"]).optional()
|
|
15821
15433
|
}).strict();
|
|
15822
15434
|
var harnessWebUiOpenParamsSchema = external_exports.object({
|
|
15823
15435
|
harnessId: harnessIdSchema
|
|
@@ -15848,7 +15460,7 @@ var codexThreadInspectionSchema = external_exports.object({
|
|
|
15848
15460
|
var externalThreadInspectionSchema = external_exports.object({
|
|
15849
15461
|
owner: external_exports.literal("external"),
|
|
15850
15462
|
harnessId: nonBlankTextSchema2.max(256),
|
|
15851
|
-
transportModelId: nonBlankTextSchema2.max(
|
|
15463
|
+
transportModelId: nonBlankTextSchema2.max(HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH),
|
|
15852
15464
|
effectiveModel: harnessModelRefSchema.optional(),
|
|
15853
15465
|
resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
|
|
15854
15466
|
effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
@@ -15905,30 +15517,575 @@ var threadOwnershipListResultSchema = external_exports.object({
|
|
|
15905
15517
|
seen.add(thread2.threadId);
|
|
15906
15518
|
}
|
|
15907
15519
|
});
|
|
15908
|
-
var threadSteeringInspectParamsSchema = external_exports.object({
|
|
15909
|
-
threadId: hostThreadIdSchema,
|
|
15910
|
-
/** The text about to be steered; a Harness command always stops and restarts. */
|
|
15911
|
-
text: external_exports.string().optional()
|
|
15912
|
-
}).strict();
|
|
15913
|
-
var threadSteeringContextSchema = external_exports.object({
|
|
15914
|
-
kind: external_exports.literal("application"),
|
|
15915
|
-
value: external_exports.string().transform((text4, context) => {
|
|
15916
|
-
try {
|
|
15917
|
-
return JSON.parse(text4);
|
|
15918
|
-
} catch {
|
|
15919
|
-
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
15920
|
-
return external_exports.NEVER;
|
|
15921
|
-
}
|
|
15922
|
-
}).pipe(external_exports.object({
|
|
15923
|
-
expectedTurnId: hostTurnIdSchema,
|
|
15924
|
-
clientUserMessageId: external_exports.string().min(1),
|
|
15925
|
-
delivery: external_exports.enum(["newTurn", "activeTurn"])
|
|
15926
|
-
}).strict())
|
|
15927
|
-
}).strict().transform((context) => context.value);
|
|
15928
|
-
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
15929
|
-
var threadSteeringInspectResultSchema = external_exports.object({
|
|
15930
|
-
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
15931
|
-
}).strict();
|
|
15520
|
+
var threadSteeringInspectParamsSchema = external_exports.object({
|
|
15521
|
+
threadId: hostThreadIdSchema,
|
|
15522
|
+
/** The text about to be steered; a Harness command always stops and restarts. */
|
|
15523
|
+
text: external_exports.string().optional()
|
|
15524
|
+
}).strict();
|
|
15525
|
+
var threadSteeringContextSchema = external_exports.object({
|
|
15526
|
+
kind: external_exports.literal("application"),
|
|
15527
|
+
value: external_exports.string().transform((text4, context) => {
|
|
15528
|
+
try {
|
|
15529
|
+
return JSON.parse(text4);
|
|
15530
|
+
} catch {
|
|
15531
|
+
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
15532
|
+
return external_exports.NEVER;
|
|
15533
|
+
}
|
|
15534
|
+
}).pipe(external_exports.object({
|
|
15535
|
+
expectedTurnId: hostTurnIdSchema,
|
|
15536
|
+
clientUserMessageId: external_exports.string().min(1),
|
|
15537
|
+
delivery: external_exports.enum(["newTurn", "activeTurn"])
|
|
15538
|
+
}).strict())
|
|
15539
|
+
}).strict().transform((context) => context.value);
|
|
15540
|
+
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
15541
|
+
var threadSteeringInspectResultSchema = external_exports.object({
|
|
15542
|
+
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
15543
|
+
}).strict();
|
|
15544
|
+
|
|
15545
|
+
// ../../shared-contracts/dist/harness-plugins.js
|
|
15546
|
+
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
15547
|
+
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
15548
|
+
var HARNESS_PLUGIN_LIMIT = 128;
|
|
15549
|
+
var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
|
|
15550
|
+
var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
|
|
15551
|
+
var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id2) => id2 !== "codex", "The official Codex identity is reserved");
|
|
15552
|
+
var pluginRelativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
|
|
15553
|
+
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
15554
|
+
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
15555
|
+
var harnessInstallationGuideSchema = external_exports.object({
|
|
15556
|
+
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
15557
|
+
before: localizedTextSchema.optional(),
|
|
15558
|
+
after: localizedTextSchema.optional(),
|
|
15559
|
+
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
15560
|
+
}).strict();
|
|
15561
|
+
var pluginPresentationShape = {
|
|
15562
|
+
id: installedHarnessPluginIdSchema,
|
|
15563
|
+
name: external_exports.string().trim().min(1).max(128),
|
|
15564
|
+
version: external_exports.string().min(1).max(128),
|
|
15565
|
+
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
15566
|
+
kind: external_exports.literal("usage").optional(),
|
|
15567
|
+
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
15568
|
+
iconStyle: external_exports.object({
|
|
15569
|
+
vector: external_exports.object({
|
|
15570
|
+
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
15571
|
+
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
15572
|
+
paths: external_exports.array(external_exports.object({
|
|
15573
|
+
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
15574
|
+
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
15575
|
+
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
15576
|
+
}).strict()).min(1).max(32)
|
|
15577
|
+
}).strict().optional(),
|
|
15578
|
+
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
15579
|
+
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
15580
|
+
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
15581
|
+
}).strict().optional(),
|
|
15582
|
+
installation: harnessInstallationGuideSchema.optional(),
|
|
15583
|
+
notice: localizedTextSchema.optional(),
|
|
15584
|
+
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
15585
|
+
launchCommand: external_exports.literal(true).optional(),
|
|
15586
|
+
links: external_exports.object({
|
|
15587
|
+
website: documentationUrlSchema.optional(),
|
|
15588
|
+
documentation: documentationUrlSchema.optional(),
|
|
15589
|
+
installation: documentationUrlSchema.optional()
|
|
15590
|
+
}).strict().optional()
|
|
15591
|
+
};
|
|
15592
|
+
var harnessPluginManifestSchema = external_exports.object({
|
|
15593
|
+
manifestVersion: external_exports.literal(1),
|
|
15594
|
+
...pluginPresentationShape,
|
|
15595
|
+
adapterApiVersion: external_exports.number().int().positive(),
|
|
15596
|
+
entry: pluginRelativeResourceSchema,
|
|
15597
|
+
icon: pluginRelativeResourceSchema.optional()
|
|
15598
|
+
}).strict();
|
|
15599
|
+
var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
|
|
15600
|
+
var harnessPluginDescriptorSchema = external_exports.object({
|
|
15601
|
+
...pluginPresentationShape,
|
|
15602
|
+
icon: harnessPluginIconSchema.optional()
|
|
15603
|
+
}).strict();
|
|
15604
|
+
var harnessPluginListParamsSchema = external_exports.object({}).strict();
|
|
15605
|
+
var harnessPluginListResultSchema = external_exports.object({
|
|
15606
|
+
plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
|
|
15607
|
+
}).strict();
|
|
15608
|
+
var harnessPluginConfigurationSchema = external_exports.object({
|
|
15609
|
+
version: external_exports.literal(1),
|
|
15610
|
+
enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
15611
|
+
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
15612
|
+
message: "Enabled plugin IDs must be unique",
|
|
15613
|
+
path: ["enabled"]
|
|
15614
|
+
});
|
|
15615
|
+
|
|
15616
|
+
// ../../shared-contracts/dist/desktop-extensions.js
|
|
15617
|
+
var DESKTOP_EXTENSION_API_VERSION = 1;
|
|
15618
|
+
var DESKTOP_EXTENSION_LIMIT = 64;
|
|
15619
|
+
var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
|
|
15620
|
+
var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
|
|
15621
|
+
var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
|
|
15622
|
+
var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
|
|
15623
|
+
var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
|
|
15624
|
+
var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
|
|
15625
|
+
var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
|
|
15626
|
+
var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
|
|
15627
|
+
var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
|
|
15628
|
+
var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
|
|
15629
|
+
var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
|
|
15630
|
+
var desktopExtensionIdSchema = installedPluginIdSchema;
|
|
15631
|
+
var desktopExtensionSlotSchema = external_exports.enum([
|
|
15632
|
+
"sidebar.thread-layout",
|
|
15633
|
+
"sidebar.thread-badge",
|
|
15634
|
+
"appearance.theme"
|
|
15635
|
+
]);
|
|
15636
|
+
var desktopExtensionCategorySchema = external_exports.enum([
|
|
15637
|
+
"appearance",
|
|
15638
|
+
"interface",
|
|
15639
|
+
"workflow",
|
|
15640
|
+
"analytics",
|
|
15641
|
+
"integrations",
|
|
15642
|
+
"tools"
|
|
15643
|
+
]);
|
|
15644
|
+
var extensionName = external_exports.string().trim().min(1).max(128);
|
|
15645
|
+
function desktopExtensionScreenshotMimeType(resource) {
|
|
15646
|
+
switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
|
|
15647
|
+
case "png":
|
|
15648
|
+
return "image/png";
|
|
15649
|
+
case "jpg":
|
|
15650
|
+
case "jpeg":
|
|
15651
|
+
return "image/jpeg";
|
|
15652
|
+
case "webp":
|
|
15653
|
+
return "image/webp";
|
|
15654
|
+
default:
|
|
15655
|
+
return void 0;
|
|
15656
|
+
}
|
|
15657
|
+
}
|
|
15658
|
+
var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
|
|
15659
|
+
var imagePathSchema = pluginRelativeResourceSchema.refine((resource) => desktopExtensionScreenshotMimeType(resource) !== void 0 && hasPortableSegments(resource), "Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space");
|
|
15660
|
+
var desktopExtensionHttpUrlSchema = external_exports.string().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu, "Expected an HTTP(S) URL").pipe(external_exports.url({ protocol: /^https?$/u })).refine((value) => {
|
|
15661
|
+
const { username, password } = new URL(value);
|
|
15662
|
+
return !username && !password && !/[\\\s]/u.test(value);
|
|
15663
|
+
}, "URL must not contain credentials, backslashes, or whitespace");
|
|
15664
|
+
function localizedText(text4) {
|
|
15665
|
+
return external_exports.strictObject({ en: text4, "zh-CN": text4 });
|
|
15666
|
+
}
|
|
15667
|
+
var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
|
|
15668
|
+
var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
|
|
15669
|
+
var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
|
|
15670
|
+
var settingField = {
|
|
15671
|
+
key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
|
|
15672
|
+
label: desktopExtensionLocalizedTextSchema,
|
|
15673
|
+
description: desktopExtensionLocalizedTextSchema.optional()
|
|
15674
|
+
};
|
|
15675
|
+
var numericSetting = {
|
|
15676
|
+
...settingField,
|
|
15677
|
+
step: external_exports.number().positive().optional(),
|
|
15678
|
+
default: external_exports.number().optional()
|
|
15679
|
+
};
|
|
15680
|
+
var settingOption = external_exports.strictObject({
|
|
15681
|
+
value: external_exports.string(),
|
|
15682
|
+
label: desktopExtensionLocalizedTextSchema
|
|
15683
|
+
});
|
|
15684
|
+
var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
|
|
15685
|
+
external_exports.strictObject({
|
|
15686
|
+
...settingField,
|
|
15687
|
+
type: external_exports.literal("boolean"),
|
|
15688
|
+
default: external_exports.boolean().optional()
|
|
15689
|
+
}),
|
|
15690
|
+
external_exports.strictObject({
|
|
15691
|
+
...settingField,
|
|
15692
|
+
type: external_exports.literal("string"),
|
|
15693
|
+
placeholder: desktopExtensionLocalizedTextSchema.optional(),
|
|
15694
|
+
default: external_exports.string().optional()
|
|
15695
|
+
}),
|
|
15696
|
+
external_exports.strictObject({
|
|
15697
|
+
...numericSetting,
|
|
15698
|
+
type: external_exports.literal("number"),
|
|
15699
|
+
min: external_exports.number().optional(),
|
|
15700
|
+
max: external_exports.number().optional()
|
|
15701
|
+
}),
|
|
15702
|
+
external_exports.strictObject({
|
|
15703
|
+
...numericSetting,
|
|
15704
|
+
type: external_exports.literal("range"),
|
|
15705
|
+
min: external_exports.number(),
|
|
15706
|
+
max: external_exports.number()
|
|
15707
|
+
}),
|
|
15708
|
+
external_exports.strictObject({
|
|
15709
|
+
...settingField,
|
|
15710
|
+
type: external_exports.literal("select"),
|
|
15711
|
+
options: external_exports.array(settingOption).min(1),
|
|
15712
|
+
default: external_exports.string().optional()
|
|
15713
|
+
})
|
|
15714
|
+
]).superRefine((field2, ctx) => {
|
|
15715
|
+
const issue2 = (path18, message3) => ctx.addIssue({ code: "custom", path: [path18], message: message3 });
|
|
15716
|
+
if (field2.type === "number" || field2.type === "range") {
|
|
15717
|
+
const { min = -Infinity, max = Infinity, default: value } = field2;
|
|
15718
|
+
if (min > max)
|
|
15719
|
+
issue2("max", "Must be at least min");
|
|
15720
|
+
if (value !== void 0 && (value < min || value > max))
|
|
15721
|
+
issue2("default", "Must be within min and max");
|
|
15722
|
+
} else if (field2.type === "select") {
|
|
15723
|
+
const values = new Set(field2.options.map(({ value }) => value));
|
|
15724
|
+
if (values.size !== field2.options.length)
|
|
15725
|
+
issue2("options", "Duplicate option values");
|
|
15726
|
+
if (field2.default !== void 0 && !values.has(field2.default))
|
|
15727
|
+
issue2("default", "Must match an option value");
|
|
15728
|
+
}
|
|
15729
|
+
});
|
|
15730
|
+
var manifestHeader = external_exports.object({
|
|
15731
|
+
manifestVersion: external_exports.int().positive(),
|
|
15732
|
+
id: desktopExtensionIdSchema,
|
|
15733
|
+
name: external_exports.union([extensionName, localizedText(extensionName)]),
|
|
15734
|
+
version: external_exports.string().min(1).max(128),
|
|
15735
|
+
desktopApi: external_exports.int().positive()
|
|
15736
|
+
}).passthrough();
|
|
15737
|
+
var desktopExtensionManifestSchema = manifestHeader.extend({
|
|
15738
|
+
manifestVersion: external_exports.literal(1),
|
|
15739
|
+
desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
|
|
15740
|
+
description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
|
|
15741
|
+
author: external_exports.string().trim().min(1).max(128).optional(),
|
|
15742
|
+
repository: desktopExtensionHttpUrlSchema.optional(),
|
|
15743
|
+
details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
|
|
15744
|
+
icon: imagePathSchema.optional(),
|
|
15745
|
+
screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
|
|
15746
|
+
desktop: external_exports.strictObject({
|
|
15747
|
+
script: pluginRelativeResourceSchema,
|
|
15748
|
+
style: pluginRelativeResourceSchema.optional()
|
|
15749
|
+
}).optional(),
|
|
15750
|
+
backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
|
|
15751
|
+
slots: slotsSchema.default(() => []),
|
|
15752
|
+
settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
|
|
15753
|
+
categories: categoriesSchema.optional()
|
|
15754
|
+
}).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
|
|
15755
|
+
var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
|
|
15756
|
+
var desktopExtensionStatusSchema = external_exports.strictObject({
|
|
15757
|
+
state: external_exports.enum([
|
|
15758
|
+
"running",
|
|
15759
|
+
"disabled",
|
|
15760
|
+
"invalid",
|
|
15761
|
+
"incompatible",
|
|
15762
|
+
"conflict",
|
|
15763
|
+
"failed",
|
|
15764
|
+
"waiting"
|
|
15765
|
+
]),
|
|
15766
|
+
hash: desktopExtensionHashSchema.optional(),
|
|
15767
|
+
error: external_exports.string().optional(),
|
|
15768
|
+
conflictWith: desktopExtensionIdSchema.optional()
|
|
15769
|
+
});
|
|
15770
|
+
var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
|
|
15771
|
+
controllerPid: external_exports.int().positive(),
|
|
15772
|
+
targetId: external_exports.string().nullable(),
|
|
15773
|
+
updatedAt: external_exports.iso.datetime(),
|
|
15774
|
+
handledReloadToken: external_exports.uuid().optional(),
|
|
15775
|
+
extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema),
|
|
15776
|
+
surfaces: external_exports.record(external_exports.string(), desktopExtensionStatusSchema).optional()
|
|
15777
|
+
});
|
|
15778
|
+
var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
|
|
15779
|
+
function isGitHubDesktopExtensionZipballUrl(url2) {
|
|
15780
|
+
return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
|
|
15781
|
+
}
|
|
15782
|
+
var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
|
|
15783
|
+
const url2 = new URL(input);
|
|
15784
|
+
return /\.zip$/iu.test(url2.pathname) || isGitHubDesktopExtensionZipballUrl(url2) || url2.origin === "https://github.com" && /^\/[\w-]+\/[\w.-]+\/zipball(?:\/.+)?\/?$/u.test(url2.pathname) || url2.origin === "https://codeload.github.com" && /^\/[\w-]+\/[\w.-]+\/(?:zip|zipball|legacy\.zip)\/.+$/u.test(url2.pathname);
|
|
15785
|
+
}, "Expected a .zip download URL or a GitHub zipball URL");
|
|
15786
|
+
var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
|
|
15787
|
+
id: desktopExtensionIdSchema,
|
|
15788
|
+
version: external_exports.string().trim().min(1).max(128),
|
|
15789
|
+
name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
|
|
15790
|
+
description: localizedText(external_exports.string().trim().min(1).max(4096)),
|
|
15791
|
+
details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
|
|
15792
|
+
author: external_exports.string().trim().min(1).max(128),
|
|
15793
|
+
repository: desktopExtensionHttpUrlSchema,
|
|
15794
|
+
stars: external_exports.number().int().min(0).optional(),
|
|
15795
|
+
downloads: external_exports.number().int().min(0).optional(),
|
|
15796
|
+
categories: categoriesSchema.optional(),
|
|
15797
|
+
trustTier: desktopExtensionTrustTierSchema.default("community"),
|
|
15798
|
+
icon: desktopExtensionHttpUrlSchema.optional(),
|
|
15799
|
+
screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
15800
|
+
downloadUrl: desktopExtensionZipUrlSchema,
|
|
15801
|
+
sha256: desktopExtensionHashSchema,
|
|
15802
|
+
slots: slotsSchema.optional(),
|
|
15803
|
+
publishedAt: external_exports.string().optional(),
|
|
15804
|
+
updatedAt: external_exports.string().optional(),
|
|
15805
|
+
minCodexHostVersion: external_exports.string().optional()
|
|
15806
|
+
});
|
|
15807
|
+
var desktopExtensionCatalogSchema = external_exports.strictObject({
|
|
15808
|
+
schemaVersion: external_exports.literal(1),
|
|
15809
|
+
generatedAt: external_exports.string(),
|
|
15810
|
+
extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
|
|
15811
|
+
});
|
|
15812
|
+
var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
|
|
15813
|
+
|
|
15814
|
+
// ../../shared-contracts/dist/host-extensions.js
|
|
15815
|
+
var reservedName = /^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu;
|
|
15816
|
+
var HOST_EXTENSION_PAGE_API_VERSION = 1;
|
|
15817
|
+
var hostExtensionIdSchema = desktopExtensionIdSchema.refine((id2) => !reservedName.test(id2), "Reserved extension ID");
|
|
15818
|
+
var hostExtensionTargetSchema = external_exports.enum(["desktop", "web"]);
|
|
15819
|
+
var hostExtensionDigestSchema = desktopExtensionHashSchema;
|
|
15820
|
+
var hostExtensionActivationIdSchema = external_exports.uuid();
|
|
15821
|
+
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((path18) => path18.split("/").length <= 32, "Extension resources may be at most 32 segments deep");
|
|
15822
|
+
var legacy = desktopExtensionManifestSchema.shape;
|
|
15823
|
+
var localized = (max, min = 0) => external_exports.strictObject({
|
|
15824
|
+
en: external_exports.string().trim().min(min).max(max),
|
|
15825
|
+
"zh-CN": external_exports.string().trim().min(min).max(max)
|
|
15826
|
+
});
|
|
15827
|
+
var resourceWithSuffix = (suffix) => hostExtensionResourcePathSchema.refine((path18) => path18.endsWith(suffix), `Expected a ${suffix} file`);
|
|
15828
|
+
var moduleEntry = resourceWithSuffix(".mjs");
|
|
15829
|
+
var style = resourceWithSuffix(".css").optional();
|
|
15830
|
+
var hostExtensionCanonicalPath = (path18) => path18.normalize("NFC").toLowerCase();
|
|
15831
|
+
var hostExtensionManifestV2Schema = external_exports.strictObject({
|
|
15832
|
+
manifestVersion: external_exports.literal(2),
|
|
15833
|
+
id: hostExtensionIdSchema,
|
|
15834
|
+
name: localized(128, 1),
|
|
15835
|
+
version: external_exports.string().trim().min(1).max(128),
|
|
15836
|
+
description: localized(4096),
|
|
15837
|
+
details: localized(16384).optional(),
|
|
15838
|
+
author: legacy.author,
|
|
15839
|
+
repository: legacy.repository,
|
|
15840
|
+
icon: legacy.icon.refine((path18) => path18 === void 0 || hostExtensionResourcePathSchema.safeParse(path18).success),
|
|
15841
|
+
screenshots: legacy.screenshots.refine((paths) => paths === void 0 || paths.every((path18) => hostExtensionResourcePathSchema.safeParse(path18).success)),
|
|
15842
|
+
categories: legacy.categories,
|
|
15843
|
+
settingsSchema: legacy.settingsSchema,
|
|
15844
|
+
slots: legacy.slots.removeDefault().optional(),
|
|
15845
|
+
page: external_exports.strictObject({
|
|
15846
|
+
apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
|
|
15847
|
+
entry: moduleEntry,
|
|
15848
|
+
style,
|
|
15849
|
+
title: localized(128, 1).optional()
|
|
15850
|
+
}).optional(),
|
|
15851
|
+
widget: external_exports.strictObject({
|
|
15852
|
+
apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
|
|
15853
|
+
entry: moduleEntry,
|
|
15854
|
+
style
|
|
15855
|
+
}).optional(),
|
|
15856
|
+
desktop: external_exports.strictObject({ apiVersion: external_exports.literal(1), script: resourceWithSuffix(".js"), style }).optional(),
|
|
15857
|
+
web: external_exports.strictObject({ apiVersion: external_exports.literal(1), entry: moduleEntry.optional(), style }).refine(({ entry, style: style2 }) => entry !== void 0 || style2 !== void 0, "Expected a Web entry or style").optional(),
|
|
15858
|
+
backend: external_exports.strictObject({ apiVersion: external_exports.literal(1), entry: moduleEntry }).optional()
|
|
15859
|
+
}).refine(({ page, widget: widget2, desktop, web, backend }) => Boolean(page || widget2 || desktop || web || backend), "Expected at least one page, widget, desktop, web, or backend entry").refine(({ page, widget: widget2, web, backend }) => !backend || [page?.entry, widget2?.entry, web?.entry].every((entry) => entry === void 0 || hostExtensionCanonicalPath(entry) !== hostExtensionCanonicalPath(backend.entry)), { path: ["backend", "entry"], message: "A backend entry cannot also be a frontend entry" });
|
|
15860
|
+
function targetsForCapabilities({ hasPage, hasWidget, hasDesktop, hasWeb, hasBackend }) {
|
|
15861
|
+
if (hasPage || hasWidget || hasBackend && !hasDesktop && !hasWeb)
|
|
15862
|
+
return ["desktop", "web"];
|
|
15863
|
+
const targets = [];
|
|
15864
|
+
if (hasDesktop)
|
|
15865
|
+
targets.push("desktop");
|
|
15866
|
+
if (hasWeb)
|
|
15867
|
+
targets.push("web");
|
|
15868
|
+
return targets;
|
|
15869
|
+
}
|
|
15870
|
+
var hostExtensionBackendMethodSchema = desktopExtensionBackendMethodSchema;
|
|
15871
|
+
|
|
15872
|
+
// ../../shared-contracts/dist/host-extension-management.js
|
|
15873
|
+
var HOST_EXTENSION_ZIP_MAX_BYTES = DESKTOP_EXTENSION_ZIP_MAX_BYTES;
|
|
15874
|
+
var hostExtensionRevisionSchema = external_exports.int().nonnegative();
|
|
15875
|
+
var hostExtensionConfigurationSchema = external_exports.strictObject({
|
|
15876
|
+
revision: hostExtensionRevisionSchema,
|
|
15877
|
+
enabled: external_exports.array(hostExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs")
|
|
15878
|
+
});
|
|
15879
|
+
var { downloadUrl, ...catalogMetadata } = desktopExtensionCatalogEntrySchema.shape;
|
|
15880
|
+
var hostExtensionCatalogEntrySchema = external_exports.object({
|
|
15881
|
+
...catalogMetadata,
|
|
15882
|
+
id: hostExtensionIdSchema,
|
|
15883
|
+
format: external_exports.literal("codexhost"),
|
|
15884
|
+
targets: external_exports.array(hostExtensionTargetSchema).min(1).max(2).refine((targets) => new Set(targets).size === targets.length, "Duplicate targets"),
|
|
15885
|
+
apis: external_exports.strictObject({
|
|
15886
|
+
page: external_exports.int().positive().optional(),
|
|
15887
|
+
widget: external_exports.int().positive().optional(),
|
|
15888
|
+
desktop: external_exports.int().positive().optional(),
|
|
15889
|
+
web: external_exports.int().positive().optional(),
|
|
15890
|
+
backend: external_exports.int().positive().optional()
|
|
15891
|
+
}),
|
|
15892
|
+
downloadUrl: downloadUrl.refine((url2) => url2.startsWith("https://"), "Expected HTTPS")
|
|
15893
|
+
}).refine(({ targets, apis }) => {
|
|
15894
|
+
const derived = targetsForCapabilities({
|
|
15895
|
+
hasPage: Boolean(apis.page),
|
|
15896
|
+
hasWidget: Boolean(apis.widget),
|
|
15897
|
+
hasDesktop: Boolean(apis.desktop),
|
|
15898
|
+
hasWeb: Boolean(apis.web),
|
|
15899
|
+
hasBackend: Boolean(apis.backend)
|
|
15900
|
+
});
|
|
15901
|
+
return targets.length === derived.length && derived.every((target2) => targets.includes(target2));
|
|
15902
|
+
}, "Catalog targets must match the declared APIs");
|
|
15903
|
+
var hostExtensionCatalogSchema = external_exports.object({
|
|
15904
|
+
schemaVersion: external_exports.literal(2),
|
|
15905
|
+
generatedAt: external_exports.string().min(1),
|
|
15906
|
+
extensions: external_exports.array(hostExtensionCatalogEntrySchema).max(1e4).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
|
|
15907
|
+
});
|
|
15908
|
+
var hostExtensionsCatalogResultSchema = hostExtensionCatalogSchema.extend({
|
|
15909
|
+
catalogUrl: desktopExtensionHttpUrlSchema,
|
|
15910
|
+
fetchedAt: external_exports.iso.datetime(),
|
|
15911
|
+
cached: external_exports.boolean()
|
|
15912
|
+
});
|
|
15913
|
+
var id = { id: hostExtensionIdSchema };
|
|
15914
|
+
var active = {
|
|
15915
|
+
...id,
|
|
15916
|
+
activationId: hostExtensionActivationIdSchema,
|
|
15917
|
+
digest: hostExtensionDigestSchema
|
|
15918
|
+
};
|
|
15919
|
+
var optionalActivation = { ...id, activationId: active.activationId.optional() };
|
|
15920
|
+
var filePath = external_exports.string().min(1).max(4096).refine((path18) => /^(?:\/|[a-z]:[/\\])/iu.test(path18) && !path18.includes("\0") && !path18.split(/[/\\]/u).some((part) => part === "." || part === ".."), "Expected an absolute local path without dot segments");
|
|
15921
|
+
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");
|
|
15922
|
+
function base643(maxBytes) {
|
|
15923
|
+
return external_exports.string().max(4 * Math.ceil(maxBytes / 3)).refine((value) => {
|
|
15924
|
+
const padding = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
|
|
15925
|
+
return value.length % 4 === 0 && value.length * 3 / 4 - padding <= maxBytes && /^[A-Za-z0-9+/]*={0,2}$/u.test(value);
|
|
15926
|
+
}, "Expected bounded standard padded base64");
|
|
15927
|
+
}
|
|
15928
|
+
var hostExtensionGitHubSourceSchema = external_exports.strictObject({
|
|
15929
|
+
type: external_exports.literal("github"),
|
|
15930
|
+
repository: external_exports.string().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),
|
|
15931
|
+
ref: gitRef.optional(),
|
|
15932
|
+
tag: gitRef.optional(),
|
|
15933
|
+
asset: external_exports.string().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),
|
|
15934
|
+
subpath: hostExtensionResourcePathSchema.optional()
|
|
15935
|
+
}).refine(({ ref, tag, asset }) => !ref || !tag && !asset, "Use either a zipball ref or a release tag/asset");
|
|
15936
|
+
var hostExtensionInstallSourceSchema = external_exports.union([
|
|
15937
|
+
external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
|
|
15938
|
+
hostExtensionGitHubSourceSchema,
|
|
15939
|
+
external_exports.strictObject({ type: external_exports.literal("zip"), base64: base643(HOST_EXTENSION_ZIP_MAX_BYTES).min(4) }),
|
|
15940
|
+
external_exports.strictObject({ type: external_exports.literal("zip"), localZipPath: filePath }),
|
|
15941
|
+
external_exports.strictObject({ type: external_exports.literal("localDir"), localDir: filePath })
|
|
15942
|
+
]);
|
|
15943
|
+
var hostExtensionProvenanceSchema = external_exports.discriminatedUnion("type", [
|
|
15944
|
+
external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
|
|
15945
|
+
hostExtensionGitHubSourceSchema,
|
|
15946
|
+
external_exports.strictObject({ type: external_exports.literal("zip") }),
|
|
15947
|
+
external_exports.strictObject({ type: external_exports.literal("localDir") })
|
|
15948
|
+
]);
|
|
15949
|
+
var hostExtensionInstallationSchema = external_exports.strictObject({
|
|
15950
|
+
...active,
|
|
15951
|
+
manifest: hostExtensionManifestV2Schema,
|
|
15952
|
+
installedAt: external_exports.iso.datetime(),
|
|
15953
|
+
source: hostExtensionProvenanceSchema.optional()
|
|
15954
|
+
});
|
|
15955
|
+
var rasterDataUrlSchema = (maxBytes) => external_exports.string().max("data:image/jpeg;base64,".length + 4 * Math.ceil(maxBytes / 3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u);
|
|
15956
|
+
var desktopConflict = { desktopConflictWith: hostExtensionIdSchema.optional() };
|
|
15957
|
+
var backendState = external_exports.enum(["none", "inactive", "starting", "running", "failed"]);
|
|
15958
|
+
var hostExtensionListItemSchema = external_exports.discriminatedUnion("state", [
|
|
15959
|
+
hostExtensionInstallationSchema.extend({
|
|
15960
|
+
state: external_exports.literal("valid"),
|
|
15961
|
+
enabled: external_exports.boolean(),
|
|
15962
|
+
...desktopConflict,
|
|
15963
|
+
iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
|
|
15964
|
+
screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
15965
|
+
backendState: backendState.optional(),
|
|
15966
|
+
backendError: external_exports.string().optional()
|
|
15967
|
+
}),
|
|
15968
|
+
external_exports.strictObject({
|
|
15969
|
+
state: external_exports.enum(["invalid", "incompatible"]),
|
|
15970
|
+
id: external_exports.string().min(1),
|
|
15971
|
+
enabled: external_exports.boolean(),
|
|
15972
|
+
error: external_exports.string()
|
|
15973
|
+
})
|
|
15974
|
+
]);
|
|
15975
|
+
var hostExtensionsListResultSchema = external_exports.strictObject({
|
|
15976
|
+
revision: hostExtensionRevisionSchema,
|
|
15977
|
+
configuration: hostExtensionConfigurationSchema,
|
|
15978
|
+
diagnostics: external_exports.array(external_exports.string()),
|
|
15979
|
+
extensions: external_exports.array(hostExtensionListItemSchema)
|
|
15980
|
+
});
|
|
15981
|
+
var hostExtensionRuntimeEntrySchema = hostExtensionInstallationSchema.extend({
|
|
15982
|
+
...desktopConflict,
|
|
15983
|
+
settingsRevision: hostExtensionRevisionSchema
|
|
15984
|
+
});
|
|
15985
|
+
var hostExtensionsSnapshotResultSchema = external_exports.strictObject({
|
|
15986
|
+
/** The Host publishes this revision in extensions-changed, independent of enabled.json's revision. */
|
|
15987
|
+
revision: hostExtensionRevisionSchema,
|
|
15988
|
+
// Enabled, valid activations only. A Desktop conflict does not hide other capabilities.
|
|
15989
|
+
extensions: external_exports.array(hostExtensionRuntimeEntrySchema).max(DESKTOP_EXTENSION_LIMIT)
|
|
15990
|
+
});
|
|
15991
|
+
var HOST_EXTENSIONS_RPC = {
|
|
15992
|
+
list: "codexhost/extensions/list",
|
|
15993
|
+
snapshot: "codexhost/extensions/snapshot",
|
|
15994
|
+
catalog: "codexhost/extensions/catalog",
|
|
15995
|
+
install: "codexhost/extensions/install",
|
|
15996
|
+
update: "codexhost/extensions/update",
|
|
15997
|
+
enable: "codexhost/extensions/enable",
|
|
15998
|
+
disable: "codexhost/extensions/disable",
|
|
15999
|
+
uninstall: "codexhost/extensions/uninstall",
|
|
16000
|
+
recover: "codexhost/extensions/recover",
|
|
16001
|
+
asset: "codexhost/extensions/asset",
|
|
16002
|
+
settingsGet: "codexhost/extensions/settings/get",
|
|
16003
|
+
settingsSet: "codexhost/extensions/settings/set",
|
|
16004
|
+
backendInvoke: "codexhost/extensions/backend/invoke"
|
|
16005
|
+
};
|
|
16006
|
+
var HOST_EXTENSION_MANAGEMENT_METHODS = Object.freeze(Object.values(HOST_EXTENSIONS_RPC));
|
|
16007
|
+
var methods = new Set(HOST_EXTENSION_MANAGEMENT_METHODS);
|
|
16008
|
+
var noParams = external_exports.strictObject({});
|
|
16009
|
+
var expectedRevision = { expectedRevision: hostExtensionRevisionSchema };
|
|
16010
|
+
var selection = external_exports.strictObject({ ...id, ...expectedRevision });
|
|
16011
|
+
var installationResult = hostExtensionInstallationSchema.extend({ replaced: external_exports.boolean() });
|
|
16012
|
+
var mutationResult = external_exports.discriminatedUnion("state", [
|
|
16013
|
+
external_exports.strictObject({ state: external_exports.literal("saved"), configuration: hostExtensionConfigurationSchema }),
|
|
16014
|
+
external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: hostExtensionRevisionSchema })
|
|
16015
|
+
]);
|
|
16016
|
+
var hostExtensionsAssetParamsSchema = external_exports.strictObject({
|
|
16017
|
+
...optionalActivation,
|
|
16018
|
+
digest: active.digest.optional(),
|
|
16019
|
+
path: hostExtensionResourcePathSchema
|
|
16020
|
+
});
|
|
16021
|
+
var hostExtensionsAssetResultSchema = external_exports.strictObject({
|
|
16022
|
+
mimeType: external_exports.string().min(1),
|
|
16023
|
+
base64: base643(DESKTOP_EXTENSION_ASSET_MAX_BYTES),
|
|
16024
|
+
digest: active.digest
|
|
16025
|
+
});
|
|
16026
|
+
var hostExtensionSettingsSchema = external_exports.strictObject({
|
|
16027
|
+
settingsRevision: hostExtensionRevisionSchema,
|
|
16028
|
+
values: jsonObjectSchema
|
|
16029
|
+
});
|
|
16030
|
+
var hostExtensionsRpcSchemas = {
|
|
16031
|
+
[HOST_EXTENSIONS_RPC.list]: { params: noParams, result: hostExtensionsListResultSchema },
|
|
16032
|
+
[HOST_EXTENSIONS_RPC.snapshot]: { params: noParams, result: hostExtensionsSnapshotResultSchema },
|
|
16033
|
+
[HOST_EXTENSIONS_RPC.catalog]: {
|
|
16034
|
+
params: external_exports.strictObject({ forceRefresh: external_exports.boolean().optional() }),
|
|
16035
|
+
result: hostExtensionsCatalogResultSchema
|
|
16036
|
+
},
|
|
16037
|
+
[HOST_EXTENSIONS_RPC.install]: {
|
|
16038
|
+
params: external_exports.strictObject({ source: hostExtensionInstallSourceSchema }),
|
|
16039
|
+
result: installationResult
|
|
16040
|
+
},
|
|
16041
|
+
[HOST_EXTENSIONS_RPC.update]: {
|
|
16042
|
+
params: external_exports.strictObject({
|
|
16043
|
+
...id,
|
|
16044
|
+
expectedDigest: active.digest,
|
|
16045
|
+
expectedActivationId: active.activationId.optional(),
|
|
16046
|
+
source: hostExtensionInstallSourceSchema.optional()
|
|
16047
|
+
}),
|
|
16048
|
+
result: installationResult
|
|
16049
|
+
},
|
|
16050
|
+
[HOST_EXTENSIONS_RPC.enable]: { params: selection, result: mutationResult },
|
|
16051
|
+
[HOST_EXTENSIONS_RPC.disable]: { params: selection, result: mutationResult },
|
|
16052
|
+
[HOST_EXTENSIONS_RPC.uninstall]: {
|
|
16053
|
+
params: external_exports.strictObject({
|
|
16054
|
+
...id,
|
|
16055
|
+
removeData: external_exports.boolean().optional(),
|
|
16056
|
+
expectedDigest: active.digest.optional()
|
|
16057
|
+
}),
|
|
16058
|
+
result: external_exports.strictObject({ ...id, removed: external_exports.boolean() })
|
|
16059
|
+
},
|
|
16060
|
+
[HOST_EXTENSIONS_RPC.recover]: {
|
|
16061
|
+
params: external_exports.strictObject({ expectedRevision: expectedRevision.expectedRevision.optional() }),
|
|
16062
|
+
result: mutationResult
|
|
16063
|
+
},
|
|
16064
|
+
[HOST_EXTENSIONS_RPC.asset]: {
|
|
16065
|
+
params: hostExtensionsAssetParamsSchema,
|
|
16066
|
+
result: hostExtensionsAssetResultSchema
|
|
16067
|
+
},
|
|
16068
|
+
[HOST_EXTENSIONS_RPC.settingsGet]: {
|
|
16069
|
+
params: external_exports.strictObject(optionalActivation),
|
|
16070
|
+
result: hostExtensionSettingsSchema
|
|
16071
|
+
},
|
|
16072
|
+
[HOST_EXTENSIONS_RPC.settingsSet]: {
|
|
16073
|
+
params: external_exports.strictObject({
|
|
16074
|
+
...optionalActivation,
|
|
16075
|
+
expectedSettingsRevision: hostExtensionRevisionSchema,
|
|
16076
|
+
values: jsonObjectSchema
|
|
16077
|
+
}),
|
|
16078
|
+
result: hostExtensionSettingsSchema
|
|
16079
|
+
},
|
|
16080
|
+
[HOST_EXTENSIONS_RPC.backendInvoke]: {
|
|
16081
|
+
params: external_exports.strictObject({
|
|
16082
|
+
...optionalActivation,
|
|
16083
|
+
method: hostExtensionBackendMethodSchema,
|
|
16084
|
+
params: jsonValueSchema.optional()
|
|
16085
|
+
}),
|
|
16086
|
+
result: external_exports.strictObject({ result: jsonValueSchema })
|
|
16087
|
+
}
|
|
16088
|
+
};
|
|
15932
16089
|
|
|
15933
16090
|
// ../../shared-contracts/dist/thread-archive-confirm.js
|
|
15934
16091
|
var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
|
|
@@ -15991,7 +16148,7 @@ var CLIENT_CHANNEL_METHODS = [
|
|
|
15991
16148
|
"codexhost/harness/session-import/list",
|
|
15992
16149
|
"codexhost/harness/session-import/import",
|
|
15993
16150
|
// Host settings shared across Desktop and Web.
|
|
15994
|
-
...
|
|
16151
|
+
...HOST_EXTENSION_MANAGEMENT_METHODS,
|
|
15995
16152
|
"codexhost/harness/installation",
|
|
15996
16153
|
"codexhost/harness/installation/start",
|
|
15997
16154
|
"codexhost/harness/installation/status",
|
|
@@ -16052,6 +16209,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
|
|
|
16052
16209
|
cursor: clientChannelCursorSchema,
|
|
16053
16210
|
revision: external_exports.number().int().nonnegative()
|
|
16054
16211
|
}),
|
|
16212
|
+
external_exports.object({
|
|
16213
|
+
type: external_exports.literal("extensions-changed"),
|
|
16214
|
+
cursor: clientChannelCursorSchema,
|
|
16215
|
+
revision: hostExtensionRevisionSchema
|
|
16216
|
+
}),
|
|
16055
16217
|
external_exports.object({
|
|
16056
16218
|
type: external_exports.literal("hello"),
|
|
16057
16219
|
version: external_exports.literal(1),
|
|
@@ -16488,7 +16650,7 @@ var DEFAULT_IDLE_RELEASE_SETTINGS = Object.freeze({
|
|
|
16488
16650
|
|
|
16489
16651
|
// ../../shared-contracts/dist/harness-preferences.js
|
|
16490
16652
|
var harnessPreferenceScopeSchema = external_exports.string().regex(/^external$/u);
|
|
16491
|
-
var preferenceHarnessKey = harnessIdSchema.transform((
|
|
16653
|
+
var preferenceHarnessKey = harnessIdSchema.transform((id2) => String(id2));
|
|
16492
16654
|
var harnessDefaultConfigurationSchema = external_exports.strictObject({
|
|
16493
16655
|
model: harnessModelRefSchema.optional(),
|
|
16494
16656
|
thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
@@ -16498,11 +16660,19 @@ var newThreadDefaultsSchema = external_exports.strictObject({
|
|
|
16498
16660
|
lastHarness: harnessIdSchema.optional(),
|
|
16499
16661
|
byHarness: external_exports.record(preferenceHarnessKey, harnessDefaultConfigurationSchema)
|
|
16500
16662
|
});
|
|
16663
|
+
var harnessDelegationDefaultSchema = external_exports.strictObject({
|
|
16664
|
+
model: harnessModelRefSchema.optional(),
|
|
16665
|
+
thinkingOptionId: harnessThinkingOptionIdSchema.optional()
|
|
16666
|
+
}).refine((value) => Boolean(value.model || value.thinkingOptionId), "A delegation default must contain a Model or Thinking option");
|
|
16667
|
+
var delegationDefaultsSchema = external_exports.strictObject({
|
|
16668
|
+
byHarness: external_exports.record(preferenceHarnessKey, harnessDelegationDefaultSchema)
|
|
16669
|
+
});
|
|
16501
16670
|
var modelId = external_exports.string().min(1).max(1024);
|
|
16502
16671
|
var harnessPreferenceValuesSchema = external_exports.strictObject({
|
|
16503
16672
|
idleRelease: idleReleaseSettingsSchema.optional(),
|
|
16504
16673
|
favorites: external_exports.record(preferenceHarnessKey, external_exports.array(modelId).max(2048)).default({}),
|
|
16505
|
-
newThread: newThreadDefaultsSchema.optional()
|
|
16674
|
+
newThread: newThreadDefaultsSchema.optional(),
|
|
16675
|
+
delegation: delegationDefaultsSchema.optional()
|
|
16506
16676
|
});
|
|
16507
16677
|
var harnessPreferenceSnapshotSchema = external_exports.strictObject({
|
|
16508
16678
|
scope: harnessPreferenceScopeSchema,
|
|
@@ -16530,6 +16700,11 @@ var harnessPreferenceOperationSchema = external_exports.discriminatedUnion("kind
|
|
|
16530
16700
|
lastHarness: harnessIdSchema.optional(),
|
|
16531
16701
|
harnessId: harnessIdSchema.optional(),
|
|
16532
16702
|
configuration: harnessDefaultConfigurationSchema.optional()
|
|
16703
|
+
}),
|
|
16704
|
+
external_exports.strictObject({
|
|
16705
|
+
kind: external_exports.literal("delegation"),
|
|
16706
|
+
harnessId: harnessIdSchema,
|
|
16707
|
+
configuration: harnessDelegationDefaultSchema.nullable()
|
|
16533
16708
|
})
|
|
16534
16709
|
]);
|
|
16535
16710
|
var harnessPreferencePatchSchema = external_exports.strictObject({
|
|
@@ -17353,9 +17528,12 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
|
17353
17528
|
...thread,
|
|
17354
17529
|
epoch: identity,
|
|
17355
17530
|
modelId: identity.optional(),
|
|
17531
|
+
serviceTier: harnessModelServiceTierSchema.optional(),
|
|
17356
17532
|
thinkingOptionId: identity.optional(),
|
|
17357
17533
|
permissionModeId: identity.optional()
|
|
17358
|
-
}).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting"),
|
|
17534
|
+
}).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting").refine((value) => value.serviceTier === void 0 || value.modelId !== void 0, {
|
|
17535
|
+
message: "A service tier requires a Model ID"
|
|
17536
|
+
}),
|
|
17359
17537
|
external_exports.strictObject({
|
|
17360
17538
|
kind: external_exports.literal("prompt"),
|
|
17361
17539
|
...thread,
|
|
@@ -17405,7 +17583,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
|
|
|
17405
17583
|
external_exports.strictObject({ action: external_exports.literal("catalog") }),
|
|
17406
17584
|
external_exports.strictObject({
|
|
17407
17585
|
action: external_exports.literal("read-thread"),
|
|
17408
|
-
hostId: hostId.refine((
|
|
17586
|
+
hostId: hostId.refine((id2) => id2 !== "local"),
|
|
17409
17587
|
input: delegationReadParamsSchema
|
|
17410
17588
|
}),
|
|
17411
17589
|
external_exports.strictObject({
|
|
@@ -17419,7 +17597,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
|
|
|
17419
17597
|
external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
|
|
17420
17598
|
external_exports.strictObject({
|
|
17421
17599
|
action: external_exports.literal("update"),
|
|
17422
|
-
hostId: hostId.refine((
|
|
17600
|
+
hostId: hostId.refine((id2) => id2 !== "local"),
|
|
17423
17601
|
version: remoteUpdateParamsSchema.shape.version
|
|
17424
17602
|
})
|
|
17425
17603
|
]);
|
|
@@ -17483,7 +17661,7 @@ function invalidRequest(message3) {
|
|
|
17483
17661
|
return { code: "invalidRequest", message: message3, retryable: false };
|
|
17484
17662
|
}
|
|
17485
17663
|
function validateHostQuestionResponse(interaction, response) {
|
|
17486
|
-
const questionIds = new Set(interaction.questions.map(({ id }) =>
|
|
17664
|
+
const questionIds = new Set(interaction.questions.map(({ id: id2 }) => id2));
|
|
17487
17665
|
if (response.cancelled) {
|
|
17488
17666
|
return Object.keys(response.answers).length === 0 ? null : invalidRequest("Cancelled Question Response must not contain answers");
|
|
17489
17667
|
}
|
|
@@ -17514,6 +17692,21 @@ function validateHostQuestionResponse(interaction, response) {
|
|
|
17514
17692
|
return null;
|
|
17515
17693
|
}
|
|
17516
17694
|
|
|
17695
|
+
// ../../harness-adapter/dist/composite-model-ref.js
|
|
17696
|
+
function compositeModelRefIds(entries, fallbackId) {
|
|
17697
|
+
const counts = /* @__PURE__ */ new Map();
|
|
17698
|
+
for (const entry of entries) {
|
|
17699
|
+
const id2 = `${entry.provider}/${entry.model}`;
|
|
17700
|
+
counts.set(id2, (counts.get(id2) ?? 0) + 1);
|
|
17701
|
+
}
|
|
17702
|
+
const ids = /* @__PURE__ */ new Map();
|
|
17703
|
+
for (const entry of entries) {
|
|
17704
|
+
const id2 = `${entry.provider}/${entry.model}`;
|
|
17705
|
+
ids.set(counts.get(id2) === 1 ? id2 : fallbackId(entry), entry);
|
|
17706
|
+
}
|
|
17707
|
+
return ids;
|
|
17708
|
+
}
|
|
17709
|
+
|
|
17517
17710
|
// ../../harness-adapter/dist/output-channel.js
|
|
17518
17711
|
var HarnessOutputChannel = class {
|
|
17519
17712
|
outputs;
|
|
@@ -17586,7 +17779,8 @@ var tokenFields = [
|
|
|
17586
17779
|
var safeIntegerFields = [
|
|
17587
17780
|
"planFiveHourResetsAtUnix",
|
|
17588
17781
|
"planSevenDayResetsAtUnix",
|
|
17589
|
-
"timeToFirstOutputMs"
|
|
17782
|
+
"timeToFirstOutputMs",
|
|
17783
|
+
"latestRequestTimeToFirstOutputMs"
|
|
17590
17784
|
];
|
|
17591
17785
|
var percentFields = [
|
|
17592
17786
|
"cacheHitRatePercent",
|
|
@@ -17849,7 +18043,7 @@ function isExcludedLiveCommand(name, extra = {}) {
|
|
|
17849
18043
|
function liveHarnessCommandPrompt(catalog, idPrefix, commandId, argumentText) {
|
|
17850
18044
|
if (!commandId.startsWith(idPrefix))
|
|
17851
18045
|
return null;
|
|
17852
|
-
const descriptor = catalog.commands.find(({ id }) =>
|
|
18046
|
+
const descriptor = catalog.commands.find(({ id: id2 }) => id2 === commandId);
|
|
17853
18047
|
if (!descriptor)
|
|
17854
18048
|
return null;
|
|
17855
18049
|
const text4 = typeof argumentText === "string" ? argumentText.trim() : "";
|
|
@@ -17859,7 +18053,7 @@ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
|
|
|
17859
18053
|
if (!live)
|
|
17860
18054
|
return builtIns;
|
|
17861
18055
|
const invocations = new Set(builtIns.commands.map(({ invocation }) => invocation));
|
|
17862
|
-
const ids = new Set(builtIns.commands.map(({ id }) =>
|
|
18056
|
+
const ids = new Set(builtIns.commands.map(({ id: id2 }) => id2));
|
|
17863
18057
|
const dynamic = [];
|
|
17864
18058
|
for (const command of live) {
|
|
17865
18059
|
const name = command.name.trim().replace(/^\//u, "");
|
|
@@ -17868,12 +18062,12 @@ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
|
|
|
17868
18062
|
if (isExcludedLiveCommand(name, exclusions))
|
|
17869
18063
|
continue;
|
|
17870
18064
|
const invocation = `/${name}`;
|
|
17871
|
-
const
|
|
17872
|
-
if (invocations.has(invocation) || ids.has(
|
|
18065
|
+
const id2 = `${idPrefix}${name.replace(/[^A-Za-z0-9._:-]/gu, "-")}`.slice(0, 128);
|
|
18066
|
+
if (invocations.has(invocation) || ids.has(id2))
|
|
17873
18067
|
continue;
|
|
17874
18068
|
const description = command.description?.trim().slice(0, 512);
|
|
17875
18069
|
const parsed = harnessCommandDescriptorSchema.safeParse({
|
|
17876
|
-
id,
|
|
18070
|
+
id: id2,
|
|
17877
18071
|
invocation,
|
|
17878
18072
|
label: name.slice(0, 128),
|
|
17879
18073
|
...description ? { description } : {},
|
|
@@ -17882,7 +18076,7 @@ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
|
|
|
17882
18076
|
if (!parsed.success)
|
|
17883
18077
|
continue;
|
|
17884
18078
|
invocations.add(invocation);
|
|
17885
|
-
ids.add(
|
|
18079
|
+
ids.add(id2);
|
|
17886
18080
|
dynamic.push(parsed.data);
|
|
17887
18081
|
}
|
|
17888
18082
|
return harnessCommandCatalogSchema.parse({ commands: [...builtIns.commands, ...dynamic] });
|
|
@@ -18369,8 +18563,8 @@ var PiSessionImportIndex = class {
|
|
|
18369
18563
|
try {
|
|
18370
18564
|
const fingerprint = await stat(file2);
|
|
18371
18565
|
const cached2 = this.#cache.get(file2);
|
|
18372
|
-
const
|
|
18373
|
-
if (
|
|
18566
|
+
const id2 = cached2 && sameFileFingerprint(cached2.fingerprint, fingerprint) ? cached2.source.nativeRef.nativeSessionId : await readIdentity(file2, signal);
|
|
18567
|
+
if (id2 !== nativeSessionId)
|
|
18374
18568
|
continue;
|
|
18375
18569
|
if (selected)
|
|
18376
18570
|
throw new Error("Pi Session identity is ambiguous across files");
|
|
@@ -19031,10 +19225,10 @@ function fileChangeFromPatch(patch, cwd) {
|
|
|
19031
19225
|
return [{ path: displayed.path, kind, unifiedDiff: patch }];
|
|
19032
19226
|
}
|
|
19033
19227
|
function synthesizeFileChange(kind, args, cwd) {
|
|
19034
|
-
const
|
|
19035
|
-
if (!
|
|
19228
|
+
const filePath2 = nestedToolString(args, ["path", "file_path", "filePath", "file"]);
|
|
19229
|
+
if (!filePath2)
|
|
19036
19230
|
return null;
|
|
19037
|
-
const displayed = displayPath(
|
|
19231
|
+
const displayed = displayPath(filePath2, cwd);
|
|
19038
19232
|
if (!displayed)
|
|
19039
19233
|
return null;
|
|
19040
19234
|
if (kind === "write") {
|
|
@@ -19107,8 +19301,8 @@ function argumentFileChange(kind, args, cwd) {
|
|
|
19107
19301
|
function hostDerivesFileChange(kind, args, cwd) {
|
|
19108
19302
|
if (kind === "edit" && isRecord3(args) && args.edits !== void 0)
|
|
19109
19303
|
return false;
|
|
19110
|
-
const
|
|
19111
|
-
return
|
|
19304
|
+
const filePath2 = nestedToolString(args, ["path", "file_path", "filePath", "file"]);
|
|
19305
|
+
return filePath2 !== void 0 && piToolPath(filePath2) === filePath2 && synthesizeFileChange(kind, args, cwd) !== null;
|
|
19112
19306
|
}
|
|
19113
19307
|
function piToolFileChanges(toolName, args, result, cwd) {
|
|
19114
19308
|
const kind = fileMutatingKind(toolName);
|
|
@@ -19289,16 +19483,16 @@ function isRecord4(value) {
|
|
|
19289
19483
|
function text(value, limit = 2048) {
|
|
19290
19484
|
return typeof value === "string" && value.length > 0 && value.length <= limit;
|
|
19291
19485
|
}
|
|
19292
|
-
function gotgenesId(
|
|
19293
|
-
return PREFIX + Buffer.from(
|
|
19486
|
+
function gotgenesId(id2) {
|
|
19487
|
+
return PREFIX + Buffer.from(id2).toString("base64url");
|
|
19294
19488
|
}
|
|
19295
19489
|
function parseGotgenesId(value) {
|
|
19296
19490
|
if (!value.startsWith(PREFIX))
|
|
19297
19491
|
return null;
|
|
19298
|
-
const
|
|
19299
|
-
if (!text(
|
|
19492
|
+
const id2 = Buffer.from(value.slice(PREFIX.length), "base64url").toString("utf8");
|
|
19493
|
+
if (!text(id2, 256) || /[\s/\\]/u.test(id2) || gotgenesId(id2) !== value)
|
|
19300
19494
|
throw new Error("Invalid gotgenes subagent identity");
|
|
19301
|
-
return
|
|
19495
|
+
return id2;
|
|
19302
19496
|
}
|
|
19303
19497
|
function gotgenesRecord(value) {
|
|
19304
19498
|
if (!isRecord4(value) || !text(value.id, 256) || /[\s/\\]/u.test(value.id) || !text(value.type) || !text(value.description) || typeof value.status !== "string" || !Object.hasOwn(STATUSES, value.status))
|
|
@@ -19306,7 +19500,7 @@ function gotgenesRecord(value) {
|
|
|
19306
19500
|
const status = STATUSES[value.status];
|
|
19307
19501
|
if (!status)
|
|
19308
19502
|
return null;
|
|
19309
|
-
const
|
|
19503
|
+
const id2 = gotgenesId(value.id);
|
|
19310
19504
|
const progress = typeof value.toolUses === "number" ? `${value.toolUses} tool uses` : void 0;
|
|
19311
19505
|
const result = typeof value.error === "string" ? value.error : typeof value.result === "string" ? value.result : progress;
|
|
19312
19506
|
return {
|
|
@@ -19314,8 +19508,8 @@ function gotgenesRecord(value) {
|
|
|
19314
19508
|
roleKnown: value.roleKnown !== false,
|
|
19315
19509
|
backgroundKnown: typeof value.isBackground === "boolean",
|
|
19316
19510
|
child: {
|
|
19317
|
-
subagentId:
|
|
19318
|
-
nativeSubagentId:
|
|
19511
|
+
subagentId: id2,
|
|
19512
|
+
nativeSubagentId: id2,
|
|
19319
19513
|
description: value.description,
|
|
19320
19514
|
role: value.type,
|
|
19321
19515
|
status,
|
|
@@ -19412,13 +19606,13 @@ var GotgenesSubagents = class {
|
|
|
19412
19606
|
}
|
|
19413
19607
|
if (!publish || JSON.stringify(previous) === JSON.stringify(merged))
|
|
19414
19608
|
continue;
|
|
19415
|
-
const
|
|
19416
|
-
if (
|
|
19417
|
-
|
|
19609
|
+
const active2 = this.#active.get(record10.id);
|
|
19610
|
+
if (active2) {
|
|
19611
|
+
active2.item = { ...active2.item, subagents: [merged.child] };
|
|
19418
19612
|
this.emit({
|
|
19419
19613
|
type: "item.updated",
|
|
19420
|
-
turnId:
|
|
19421
|
-
itemId:
|
|
19614
|
+
turnId: active2.turnId,
|
|
19615
|
+
itemId: active2.item.itemId,
|
|
19422
19616
|
update: { type: "subagents.replace", subagents: [merged.child] }
|
|
19423
19617
|
});
|
|
19424
19618
|
}
|
|
@@ -19462,14 +19656,14 @@ var GotgenesSubagents = class {
|
|
|
19462
19656
|
return true;
|
|
19463
19657
|
}
|
|
19464
19658
|
finish(turnId) {
|
|
19465
|
-
for (const [
|
|
19466
|
-
if (
|
|
19659
|
+
for (const [id2, active2] of this.#active) {
|
|
19660
|
+
if (active2.turnId !== turnId)
|
|
19467
19661
|
continue;
|
|
19468
|
-
this.#active.delete(
|
|
19662
|
+
this.#active.delete(id2);
|
|
19469
19663
|
this.emit({
|
|
19470
19664
|
type: "item.completed",
|
|
19471
19665
|
turnId,
|
|
19472
|
-
snapshot: { item:
|
|
19666
|
+
snapshot: { item: active2.item, outcome: { status: "succeeded" } }
|
|
19473
19667
|
});
|
|
19474
19668
|
}
|
|
19475
19669
|
}
|
|
@@ -19532,16 +19726,16 @@ function piWorkflowSummary(result) {
|
|
|
19532
19726
|
function piWorkflowSubagentId(address) {
|
|
19533
19727
|
return PREFIX2 + Buffer.from(JSON.stringify([address.workflowRunId, address.childId])).toString("base64url");
|
|
19534
19728
|
}
|
|
19535
|
-
function parsePiWorkflowSubagentId(
|
|
19536
|
-
if (!
|
|
19729
|
+
function parsePiWorkflowSubagentId(id2) {
|
|
19730
|
+
if (!id2.startsWith(PREFIX2))
|
|
19537
19731
|
return null;
|
|
19538
|
-
if (
|
|
19732
|
+
if (id2.length > 3e3)
|
|
19539
19733
|
throw new Error("Invalid Pi workflow child identity");
|
|
19540
|
-
const value = JSON.parse(Buffer.from(
|
|
19734
|
+
const value = JSON.parse(Buffer.from(id2.slice(PREFIX2.length), "base64url").toString("utf8"));
|
|
19541
19735
|
if (!Array.isArray(value) || value.length !== 2 || !text2(value[0]) || !text2(value[1]))
|
|
19542
19736
|
throw new Error("Invalid Pi workflow child identity");
|
|
19543
19737
|
const address = { workflowRunId: value[0], childId: value[1] };
|
|
19544
|
-
if (piWorkflowSubagentId(address) !==
|
|
19738
|
+
if (piWorkflowSubagentId(address) !== id2)
|
|
19545
19739
|
throw new Error("Non-canonical Pi workflow child identity");
|
|
19546
19740
|
return address;
|
|
19547
19741
|
}
|
|
@@ -19553,13 +19747,13 @@ function projectPiWorkflow(summary, itemId2) {
|
|
|
19553
19747
|
itemId: itemId2,
|
|
19554
19748
|
operation: "spawn",
|
|
19555
19749
|
subagents: summary.children.map((child) => {
|
|
19556
|
-
const
|
|
19750
|
+
const id2 = piWorkflowSubagentId({
|
|
19557
19751
|
workflowRunId: summary.workflowRunId,
|
|
19558
19752
|
childId: child.childId
|
|
19559
19753
|
});
|
|
19560
19754
|
return {
|
|
19561
|
-
subagentId:
|
|
19562
|
-
nativeSubagentId:
|
|
19755
|
+
subagentId: id2,
|
|
19756
|
+
nativeSubagentId: id2,
|
|
19563
19757
|
description: child.sessionName ?? child.agent ?? child.childId,
|
|
19564
19758
|
status: child.state,
|
|
19565
19759
|
background: child.background,
|
|
@@ -19645,14 +19839,14 @@ function parsePiSubagentStatus(value) {
|
|
|
19645
19839
|
function piSubagentId(address) {
|
|
19646
19840
|
return ID_PREFIX + Buffer.from(JSON.stringify([address.runId, address.childId ?? null])).toString("base64url");
|
|
19647
19841
|
}
|
|
19648
|
-
function parsePiSubagentId(
|
|
19649
|
-
if (!
|
|
19842
|
+
function parsePiSubagentId(id2) {
|
|
19843
|
+
if (!id2.startsWith(ID_PREFIX) || id2.length > 1500)
|
|
19650
19844
|
throw new Error("Invalid Pi Subagent identity");
|
|
19651
|
-
const value = JSON.parse(Buffer.from(
|
|
19845
|
+
const value = JSON.parse(Buffer.from(id2.slice(ID_PREFIX.length), "base64url").toString("utf8"));
|
|
19652
19846
|
if (!Array.isArray(value) || value.length !== 2 || !token(value[0]) || value[1] !== null && !token(value[1]))
|
|
19653
19847
|
throw new Error("Invalid Pi Subagent identity");
|
|
19654
19848
|
const address = { runId: value[0], ...value[1] === null ? {} : { childId: value[1] } };
|
|
19655
|
-
if (piSubagentId(address) !==
|
|
19849
|
+
if (piSubagentId(address) !== id2)
|
|
19656
19850
|
throw new Error("Non-canonical Pi Subagent identity");
|
|
19657
19851
|
return address;
|
|
19658
19852
|
}
|
|
@@ -19663,12 +19857,12 @@ function states(run) {
|
|
|
19663
19857
|
if (entry.kind === "host-step" || !root && entry.kind === "workflow")
|
|
19664
19858
|
return;
|
|
19665
19859
|
if (entry.kind !== "workflow") {
|
|
19666
|
-
const
|
|
19667
|
-
if (!seen.has(
|
|
19668
|
-
seen.add(
|
|
19860
|
+
const id2 = piSubagentId({ runId: run.id, ...!root ? { childId: entry.id } : {} });
|
|
19861
|
+
if (!seen.has(id2)) {
|
|
19862
|
+
seen.add(id2);
|
|
19669
19863
|
result.push({
|
|
19670
|
-
subagentId:
|
|
19671
|
-
nativeSubagentId:
|
|
19864
|
+
subagentId: id2,
|
|
19865
|
+
nativeSubagentId: id2,
|
|
19672
19866
|
description: entry.label,
|
|
19673
19867
|
...subagentConfiguration(entry),
|
|
19674
19868
|
background: true,
|
|
@@ -19734,17 +19928,17 @@ var PiSubagents = class {
|
|
|
19734
19928
|
this.#active.set(run.id, { turnId: waiting.turnId, item });
|
|
19735
19929
|
this.emit({ type: "item.started", turnId: waiting.turnId, item });
|
|
19736
19930
|
}
|
|
19737
|
-
const
|
|
19738
|
-
if (
|
|
19739
|
-
const merged = new Map(
|
|
19931
|
+
const active2 = this.#active.get(run.id);
|
|
19932
|
+
if (active2 && children.length) {
|
|
19933
|
+
const merged = new Map(active2.item.subagents.map((child) => [child.nativeSubagentId, child]));
|
|
19740
19934
|
for (const child of children)
|
|
19741
19935
|
merged.set(child.nativeSubagentId, child);
|
|
19742
|
-
|
|
19936
|
+
active2.item = { ...active2.item, subagents: [...merged.values()] };
|
|
19743
19937
|
this.emit({
|
|
19744
19938
|
type: "item.updated",
|
|
19745
|
-
turnId:
|
|
19746
|
-
itemId:
|
|
19747
|
-
update: { type: "subagents.replace", subagents:
|
|
19939
|
+
turnId: active2.turnId,
|
|
19940
|
+
itemId: active2.item.itemId,
|
|
19941
|
+
update: { type: "subagents.replace", subagents: active2.item.subagents }
|
|
19748
19942
|
});
|
|
19749
19943
|
}
|
|
19750
19944
|
for (const child of observed) {
|
|
@@ -19823,14 +20017,14 @@ var PiSubagents = class {
|
|
|
19823
20017
|
if (waiting.turnId === turnId)
|
|
19824
20018
|
this.#waiting.delete(runId);
|
|
19825
20019
|
}
|
|
19826
|
-
for (const [runId,
|
|
19827
|
-
if (
|
|
20020
|
+
for (const [runId, active2] of this.#active) {
|
|
20021
|
+
if (active2.turnId !== turnId)
|
|
19828
20022
|
continue;
|
|
19829
20023
|
this.#active.delete(runId);
|
|
19830
20024
|
this.emit({
|
|
19831
20025
|
type: "item.completed",
|
|
19832
20026
|
turnId,
|
|
19833
|
-
snapshot: { item:
|
|
20027
|
+
snapshot: { item: active2.item, outcome: { status: "succeeded" } }
|
|
19834
20028
|
});
|
|
19835
20029
|
}
|
|
19836
20030
|
}
|
|
@@ -19851,7 +20045,7 @@ function parsePiSubagentInspection(value) {
|
|
|
19851
20045
|
return null;
|
|
19852
20046
|
return parsed;
|
|
19853
20047
|
}
|
|
19854
|
-
function piSubagentSnapshot(parentSessionId,
|
|
20048
|
+
function piSubagentSnapshot(parentSessionId, id2, reply) {
|
|
19855
20049
|
const messages = reply.messages ?? [];
|
|
19856
20050
|
const texts = messages.map((entry) => entry.kind === "text" && entry.role === "assistant" ? entry.text : `[${entry.role}${entry.name ? `: ${entry.name}` : ""} / ${entry.kind}]
|
|
19857
20051
|
${entry.text}`);
|
|
@@ -19866,7 +20060,7 @@ ${entry.text}`);
|
|
|
19866
20060
|
nativeTurnRef: nativeTurnRefSchema.parse({
|
|
19867
20061
|
harnessId: "pi",
|
|
19868
20062
|
nativeSessionId: parentSessionId,
|
|
19869
|
-
nativeTurnKey: `pi-subagent-${createHash3("sha256").update(
|
|
20063
|
+
nativeTurnKey: `pi-subagent-${createHash3("sha256").update(id2).digest("hex")}`,
|
|
19870
20064
|
formatVersion: 1
|
|
19871
20065
|
}),
|
|
19872
20066
|
input: reply.task ? [{ type: "text", text: reply.task }] : [],
|
|
@@ -19874,7 +20068,7 @@ ${entry.text}`);
|
|
|
19874
20068
|
item: {
|
|
19875
20069
|
type: "agentMessage",
|
|
19876
20070
|
text: text4,
|
|
19877
|
-
itemId: hostItemIdSchema.parse(`pi-subagent-${createHash3("sha256").update(`${
|
|
20071
|
+
itemId: hostItemIdSchema.parse(`pi-subagent-${createHash3("sha256").update(`${id2}:${index}:${text4}`).digest("hex")}`)
|
|
19878
20072
|
},
|
|
19879
20073
|
outcome: { status: "succeeded" }
|
|
19880
20074
|
})),
|
|
@@ -19894,6 +20088,85 @@ ${entry.text}`);
|
|
|
19894
20088
|
};
|
|
19895
20089
|
}
|
|
19896
20090
|
|
|
20091
|
+
// dist/pi-fast-mode.js
|
|
20092
|
+
import { createHash as createHash4, randomUUID as randomUUID2 } from "node:crypto";
|
|
20093
|
+
import { mkdir as mkdir2, readFile as readFile2, rename as rename2, rm as rm3, writeFile as writeFile3 } from "node:fs/promises";
|
|
20094
|
+
import { homedir as homedir3 } from "node:os";
|
|
20095
|
+
import path8 from "node:path";
|
|
20096
|
+
var PI_FAST_COMMAND = "codexhost-fast-mode";
|
|
20097
|
+
var PI_FAST_ACK = "codexhost-fast-mode:";
|
|
20098
|
+
var PI_FAST_EXTENSION = `export default function(pi) {
|
|
20099
|
+
let target;
|
|
20100
|
+
const wrapped = new Set();
|
|
20101
|
+
const supportsModel = (model) => model && (model.api === "openai-codex-responses" || model.api === "openai-responses") && /gpt/i.test(model.id);
|
|
20102
|
+
pi.on("model_select", (_event, ctx) => {
|
|
20103
|
+
if (target && (target.provider !== ctx.model?.provider || target.id !== ctx.model?.id || !supportsModel(ctx.model))) target = undefined;
|
|
20104
|
+
});
|
|
20105
|
+
pi.on("session_start", (_event, ctx) => {
|
|
20106
|
+
if (typeof ctx.modelRegistry.getProvider !== "function" || typeof pi.registerProvider !== "function") return;
|
|
20107
|
+
pi.registerCommand("${PI_FAST_COMMAND}", {
|
|
20108
|
+
description: "Codex Host Fast mode",
|
|
20109
|
+
handler: async (args, ctx) => {
|
|
20110
|
+
const [mode, nonce] = args.split(" ");
|
|
20111
|
+
if (!nonce || (mode !== "on" && mode !== "off")) throw new Error("Invalid Fast selection");
|
|
20112
|
+
if (mode === "on") {
|
|
20113
|
+
const model = ctx.model;
|
|
20114
|
+
if (!supportsModel(model)) throw new Error("Fast requires a GPT model using the Codex or OpenAI Responses API");
|
|
20115
|
+
const original = ctx.modelRegistry.getProvider(model.provider);
|
|
20116
|
+
if (!original) throw new Error("Provider is unavailable");
|
|
20117
|
+
if (!wrapped.has(model.provider)) {
|
|
20118
|
+
const options = (model, value) => target && supportsModel(model) && target.provider === model.provider && target.id === model.id
|
|
20119
|
+
? {
|
|
20120
|
+
...value,
|
|
20121
|
+
serviceTier: "priority",
|
|
20122
|
+
// Pi streamSimple drops serviceTier but preserves onPayload.
|
|
20123
|
+
onPayload: async (payload, requestModel) => {
|
|
20124
|
+
const request = { ...payload, service_tier: "priority" };
|
|
20125
|
+
const replacement = await value?.onPayload?.(request, requestModel);
|
|
20126
|
+
return { ...(replacement === undefined ? request : replacement), service_tier: "priority" };
|
|
20127
|
+
},
|
|
20128
|
+
} : value;
|
|
20129
|
+
pi.registerProvider({
|
|
20130
|
+
...original,
|
|
20131
|
+
stream: (model, context, value) => original.stream(model, context, options(model, value)),
|
|
20132
|
+
streamSimple: (model, context, value) => original.streamSimple(model, context, options(model, value)),
|
|
20133
|
+
});
|
|
20134
|
+
wrapped.add(model.provider);
|
|
20135
|
+
}
|
|
20136
|
+
target = { provider: model.provider, id: model.id };
|
|
20137
|
+
} else target = undefined;
|
|
20138
|
+
ctx.ui.notify("${PI_FAST_ACK}" + nonce + ":" + mode, "info");
|
|
20139
|
+
},
|
|
20140
|
+
});
|
|
20141
|
+
});
|
|
20142
|
+
}
|
|
20143
|
+
`;
|
|
20144
|
+
async function ensurePiFastExtension(environment) {
|
|
20145
|
+
const digest = createHash4("sha256").update(PI_FAST_EXTENSION).digest("hex").slice(0, 16);
|
|
20146
|
+
const dataDirectory = environment.CODEXHOST_DATA_DIR ?? path8.join(environment.HOME ?? environment.USERPROFILE ?? homedir3(), ".codexhost");
|
|
20147
|
+
const directory = path8.resolve(dataDirectory, "extensions", "pi-codex-fast");
|
|
20148
|
+
const file2 = path8.join(directory, `${digest}.mjs`);
|
|
20149
|
+
if (await readFile2(file2, "utf8").catch(() => "") === PI_FAST_EXTENSION)
|
|
20150
|
+
return file2;
|
|
20151
|
+
await mkdir2(directory, { recursive: true });
|
|
20152
|
+
const temporary = `${file2}.${randomUUID2()}.tmp`;
|
|
20153
|
+
try {
|
|
20154
|
+
await writeFile3(temporary, PI_FAST_EXTENSION, { mode: 384 });
|
|
20155
|
+
try {
|
|
20156
|
+
await rename2(temporary, file2);
|
|
20157
|
+
} catch (error51) {
|
|
20158
|
+
if (await readFile2(file2, "utf8").catch(() => "") !== PI_FAST_EXTENSION)
|
|
20159
|
+
throw error51;
|
|
20160
|
+
}
|
|
20161
|
+
} finally {
|
|
20162
|
+
await rm3(temporary, { force: true });
|
|
20163
|
+
}
|
|
20164
|
+
return file2;
|
|
20165
|
+
}
|
|
20166
|
+
function supportsPiFastModel(model2) {
|
|
20167
|
+
return (model2.api === "openai-codex-responses" || model2.api === "openai-responses") && /gpt/i.test(model2.id);
|
|
20168
|
+
}
|
|
20169
|
+
|
|
19897
20170
|
// dist/pi-model-catalog.js
|
|
19898
20171
|
var PI_MODEL_REF_PREFIX = "pi-model-v1.";
|
|
19899
20172
|
var PI_DRAFT_THINKING_OPTION_IDS = [
|
|
@@ -19904,7 +20177,7 @@ var PI_DRAFT_THINKING_OPTION_IDS = [
|
|
|
19904
20177
|
"high",
|
|
19905
20178
|
"xhigh",
|
|
19906
20179
|
"max"
|
|
19907
|
-
].map((
|
|
20180
|
+
].map((id2) => harnessThinkingOptionIdSchema.parse(id2));
|
|
19908
20181
|
var PI_THINKING_LABELS = {
|
|
19909
20182
|
off: "Off",
|
|
19910
20183
|
minimal: "Minimal",
|
|
@@ -19921,79 +20194,110 @@ function assertNativePart(value, name) {
|
|
|
19921
20194
|
if (value.trim().length === 0)
|
|
19922
20195
|
throw new Error(`Pi ${name} must not be empty`);
|
|
19923
20196
|
}
|
|
19924
|
-
function
|
|
20197
|
+
function readableId({ provider, id: id2 }) {
|
|
20198
|
+
return `${provider}/${id2}`;
|
|
20199
|
+
}
|
|
20200
|
+
function modelLabel({ provider, id: id2 }) {
|
|
20201
|
+
return `${provider} / ${id2}`;
|
|
20202
|
+
}
|
|
20203
|
+
function encodedId({ provider, id: id2 }, legacyFast = false) {
|
|
20204
|
+
const tuple2 = legacyFast ? [provider, id2, true] : [provider, id2];
|
|
20205
|
+
return `${PI_MODEL_REF_PREFIX}${Buffer.from(JSON.stringify(tuple2)).toString("base64url")}`;
|
|
20206
|
+
}
|
|
20207
|
+
function encodePiModelRef(model2, id2 = readableId(model2)) {
|
|
19925
20208
|
assertNativePart(model2.provider, "Model provider");
|
|
19926
20209
|
assertNativePart(model2.id, "Model id");
|
|
19927
|
-
|
|
19928
|
-
|
|
20210
|
+
return harnessModelRefSchema.parse({
|
|
20211
|
+
id: id2,
|
|
20212
|
+
...model2.fast ? { serviceTier: "priority" } : {}
|
|
20213
|
+
});
|
|
20214
|
+
}
|
|
20215
|
+
function createPiModelIndex(models) {
|
|
20216
|
+
const entries = new Map(models.map(({ provider, id: id2 }) => [JSON.stringify([provider, id2]), { provider, model: id2, id: id2 }]));
|
|
20217
|
+
const byId = compositeModelRefIds([...entries.values()], (entry) => encodedId(entry));
|
|
20218
|
+
const idsByPair = new Map([...byId].map(([id2, entry]) => [JSON.stringify([entry.provider, entry.model]), id2]));
|
|
20219
|
+
return {
|
|
20220
|
+
models,
|
|
20221
|
+
byId,
|
|
20222
|
+
ref: (model2) => {
|
|
20223
|
+
const id2 = idsByPair.get(JSON.stringify([model2.provider, model2.id]));
|
|
20224
|
+
return encodePiModelRef(model2, id2 ?? (byId.has(readableId(model2)) ? encodedId(model2) : readableId(model2)));
|
|
20225
|
+
}
|
|
20226
|
+
};
|
|
19929
20227
|
}
|
|
19930
|
-
function
|
|
19931
|
-
const
|
|
19932
|
-
if (!
|
|
19933
|
-
throw new Error("Model Ref
|
|
20228
|
+
function resolvePiModelRef(ref, index) {
|
|
20229
|
+
const model2 = index.byId.get(ref.id);
|
|
20230
|
+
if (!model2 || ref.serviceTier === "ultrafast") {
|
|
20231
|
+
throw new Error("Model Ref is not in the current Pi Model catalog");
|
|
19934
20232
|
}
|
|
19935
|
-
|
|
19936
|
-
|
|
20233
|
+
return { provider: model2.provider, id: model2.id, ...ref.serviceTier ? { fast: true } : {} };
|
|
20234
|
+
}
|
|
20235
|
+
function normalizeStoredPiModelRef(ref, catalog) {
|
|
20236
|
+
if (!ref.id.startsWith(PI_MODEL_REF_PREFIX) || ref.serviceTier === "ultrafast")
|
|
20237
|
+
return void 0;
|
|
20238
|
+
let tuple2;
|
|
19937
20239
|
try {
|
|
19938
|
-
|
|
20240
|
+
tuple2 = JSON.parse(Buffer.from(ref.id.slice(PI_MODEL_REF_PREFIX.length), "base64url").toString("utf8"));
|
|
19939
20241
|
} catch {
|
|
19940
|
-
|
|
19941
|
-
}
|
|
19942
|
-
if (!Array.isArray(decoded) || decoded.length !== 2 && !(decoded.length === 3 && decoded[2] === true) || typeof decoded[0] !== "string" || typeof decoded[1] !== "string") {
|
|
19943
|
-
throw new Error("Pi Model Ref has an invalid native identity");
|
|
19944
|
-
}
|
|
19945
|
-
const native = {
|
|
19946
|
-
provider: decoded[0],
|
|
19947
|
-
id: decoded[1],
|
|
19948
|
-
...decoded[2] === true ? { fast: true } : {}
|
|
19949
|
-
};
|
|
19950
|
-
assertNativePart(native.provider, "Model provider");
|
|
19951
|
-
assertNativePart(native.id, "Model id");
|
|
19952
|
-
if (encodePiModelRef(native).id !== parsedRef.id) {
|
|
19953
|
-
throw new Error("Pi Model Ref is not canonical");
|
|
20242
|
+
return void 0;
|
|
19954
20243
|
}
|
|
19955
|
-
|
|
20244
|
+
if (!Array.isArray(tuple2) || tuple2.length !== 2 && !(tuple2.length === 3 && tuple2[2] === true) || typeof tuple2[0] !== "string" || typeof tuple2[1] !== "string")
|
|
20245
|
+
return void 0;
|
|
20246
|
+
const native = { provider: tuple2[0], id: tuple2[1] };
|
|
20247
|
+
const legacyFast = tuple2[2] === true;
|
|
20248
|
+
if (encodedId(native, legacyFast) !== ref.id || legacyFast && ref.serviceTier)
|
|
20249
|
+
return void 0;
|
|
20250
|
+
const fast = legacyFast || ref.serviceTier === "priority";
|
|
20251
|
+
const encoded = encodedId(native);
|
|
20252
|
+
const readable = readableId(native);
|
|
20253
|
+
const entry = catalog.models.find(({ ref: ref2, label }) => ref2.id === encoded || ref2.id === readable && label === modelLabel(native));
|
|
20254
|
+
return fast ? entry?.fastModel : entry?.ref;
|
|
19956
20255
|
}
|
|
19957
20256
|
function samePiModel(left, right) {
|
|
19958
20257
|
return left === null ? right === null : right !== null && left.provider === right.provider && left.id === right.id;
|
|
19959
20258
|
}
|
|
19960
|
-
function fallbackThinkingLabel(
|
|
19961
|
-
const label =
|
|
19962
|
-
return label ||
|
|
20259
|
+
function fallbackThinkingLabel(id2) {
|
|
20260
|
+
const label = id2.split(/[._~-]+/u).filter((part) => part.length > 0).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
|
|
20261
|
+
return label || id2;
|
|
19963
20262
|
}
|
|
19964
20263
|
function normalizePiThinkingOptions(levels) {
|
|
19965
|
-
return levels.map((
|
|
19966
|
-
id,
|
|
19967
|
-
label: PI_THINKING_LABELS[
|
|
20264
|
+
return levels.map((id2) => harnessThinkingOptionSchema.parse({
|
|
20265
|
+
id: id2,
|
|
20266
|
+
label: PI_THINKING_LABELS[id2] ?? fallbackThinkingLabel(id2)
|
|
19968
20267
|
}));
|
|
19969
20268
|
}
|
|
19970
|
-
function normalizePiModelCatalog(nativeModels, effectiveModel, thinkingLevels, effectiveThinkingOptionId, effectiveModelReasoning = null) {
|
|
20269
|
+
function normalizePiModelCatalog(nativeModels, effectiveModel, thinkingLevels, effectiveThinkingOptionId, effectiveModelReasoning = null, fastSupported = false) {
|
|
20270
|
+
const index = createPiModelIndex(effectiveModel ? [...nativeModels, effectiveModel] : nativeModels);
|
|
19971
20271
|
const byRef = /* @__PURE__ */ new Map();
|
|
19972
20272
|
for (const native of nativeModels) {
|
|
19973
|
-
const ref =
|
|
20273
|
+
const ref = index.ref(native);
|
|
20274
|
+
const fastModel = fastSupported && supportsPiFastModel(native) ? { id: ref.id, serviceTier: "priority" } : void 0;
|
|
19974
20275
|
const existing = byRef.get(ref.id);
|
|
19975
20276
|
if (existing) {
|
|
19976
20277
|
if (existing.reasoning !== native.reasoning) {
|
|
19977
20278
|
throw new Error("Pi duplicate Model entries disagree on reasoning capability");
|
|
19978
20279
|
}
|
|
20280
|
+
if (fastModel)
|
|
20281
|
+
existing.model.fastModel = fastModel;
|
|
19979
20282
|
continue;
|
|
19980
20283
|
}
|
|
19981
20284
|
byRef.set(ref.id, {
|
|
19982
20285
|
model: {
|
|
19983
20286
|
ref,
|
|
19984
|
-
label:
|
|
20287
|
+
label: modelLabel(native),
|
|
20288
|
+
...fastModel ? { fastModel } : {}
|
|
19985
20289
|
},
|
|
19986
20290
|
reasoning: native.reasoning,
|
|
19987
20291
|
synthesized: false
|
|
19988
20292
|
});
|
|
19989
20293
|
}
|
|
19990
|
-
const defaultModel = effectiveModel ?
|
|
20294
|
+
const defaultModel = effectiveModel ? index.ref(effectiveModel) : void 0;
|
|
19991
20295
|
if (effectiveModel && defaultModel && !byRef.has(defaultModel.id)) {
|
|
19992
20296
|
const reasoning = effectiveThinkingOptionId && effectiveThinkingOptionId !== "off" || (effectiveModelReasoning ?? Boolean(thinkingLevels && thinkingLevels.some((level) => level !== "off")));
|
|
19993
20297
|
byRef.set(defaultModel.id, {
|
|
19994
20298
|
model: {
|
|
19995
20299
|
ref: defaultModel,
|
|
19996
|
-
label:
|
|
20300
|
+
label: modelLabel(effectiveModel)
|
|
19997
20301
|
},
|
|
19998
20302
|
reasoning,
|
|
19999
20303
|
synthesized: true
|
|
@@ -20006,14 +20310,14 @@ function normalizePiModelCatalog(nativeModels, effectiveModel, thinkingLevels, e
|
|
|
20006
20310
|
throw new Error("Pi did not report an effective Thinking option");
|
|
20007
20311
|
}
|
|
20008
20312
|
const thinkingOptions = thinkingLevels ? normalizePiThinkingOptions(PI_DRAFT_THINKING_OPTION_IDS) : [];
|
|
20009
|
-
const allThinkingOptionIds = thinkingOptions.map(({ id }) =>
|
|
20010
|
-
const offThinkingOptionId = thinkingOptions.find(({ id }) =>
|
|
20011
|
-
const effectiveThinkingOptionIds = thinkingLevels ? allThinkingOptionIds.filter((
|
|
20313
|
+
const allThinkingOptionIds = thinkingOptions.map(({ id: id2 }) => id2);
|
|
20314
|
+
const offThinkingOptionId = thinkingOptions.find(({ id: id2 }) => id2 === "off")?.id;
|
|
20315
|
+
const effectiveThinkingOptionIds = thinkingLevels ? allThinkingOptionIds.filter((id2) => thinkingLevels.includes(id2)) : allThinkingOptionIds;
|
|
20012
20316
|
const models = [...byRef.values()].map(({ model: model2, reasoning, synthesized }) => ({
|
|
20013
20317
|
...model2,
|
|
20014
20318
|
supportedThinkingOptionIds: reasoning ? synthesized ? effectiveThinkingOptionIds : allThinkingOptionIds : offThinkingOptionId ? [offThinkingOptionId] : []
|
|
20015
20319
|
})).sort((left, right) => compareText(left.label, right.label) || compareText(left.ref.id, right.ref.id));
|
|
20016
|
-
const defaultThinkingOptionId = thinkingOptions.find(({ id }) =>
|
|
20320
|
+
const defaultThinkingOptionId = thinkingOptions.find(({ id: id2 }) => id2 === effectiveThinkingOptionId)?.id;
|
|
20017
20321
|
return harnessModelCatalogSchema.parse({
|
|
20018
20322
|
models,
|
|
20019
20323
|
...defaultModel ? { defaultModel } : {},
|
|
@@ -20023,7 +20327,7 @@ function normalizePiModelCatalog(nativeModels, effectiveModel, thinkingLevels, e
|
|
|
20023
20327
|
}
|
|
20024
20328
|
|
|
20025
20329
|
// dist/pi-progress.js
|
|
20026
|
-
import { createHash as
|
|
20330
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
20027
20331
|
function record5(value) {
|
|
20028
20332
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20029
20333
|
}
|
|
@@ -20072,7 +20376,7 @@ function piCustomNotice(value, sessionId, occurrences) {
|
|
|
20072
20376
|
return null;
|
|
20073
20377
|
const occurrence = occurrences.get(key) ?? 0;
|
|
20074
20378
|
occurrences.set(key, occurrence + 1);
|
|
20075
|
-
const digest =
|
|
20379
|
+
const digest = createHash5("sha256").update(JSON.stringify([sessionId, key, occurrence])).digest("hex");
|
|
20076
20380
|
const [customType, text4] = JSON.parse(key);
|
|
20077
20381
|
return {
|
|
20078
20382
|
type: "progress.message",
|
|
@@ -20397,11 +20701,11 @@ function isEmptyWakeup(entry) {
|
|
|
20397
20701
|
const content = message(entry)?.content;
|
|
20398
20702
|
return content === "" || Array.isArray(content) && content.every((part) => isRecord5(part) && part.type === "text" && part.text === "");
|
|
20399
20703
|
}
|
|
20400
|
-
function turnStarts(
|
|
20704
|
+
function turnStarts(active2) {
|
|
20401
20705
|
const starts = [];
|
|
20402
20706
|
let terminal = true;
|
|
20403
20707
|
let pending = null;
|
|
20404
|
-
for (const [index, entry] of
|
|
20708
|
+
for (const [index, entry] of active2.entries()) {
|
|
20405
20709
|
const role = messageRole(entry);
|
|
20406
20710
|
if (role === "user") {
|
|
20407
20711
|
if (pending && isEmptyWakeup(entry))
|
|
@@ -20421,29 +20725,34 @@ function turnStarts(active) {
|
|
|
20421
20725
|
return starts;
|
|
20422
20726
|
}
|
|
20423
20727
|
function mapPiSnapshot(history, state2, subagents = new PiSubagents(() => void 0)) {
|
|
20424
|
-
const
|
|
20425
|
-
const { identities } = piHistoryMessageIdentities(state2.sessionId,
|
|
20426
|
-
const { notices } = piHistoryNotices(state2.sessionId,
|
|
20728
|
+
const active2 = activePiEntries(history);
|
|
20729
|
+
const { identities } = piHistoryMessageIdentities(state2.sessionId, active2);
|
|
20730
|
+
const { notices } = piHistoryNotices(state2.sessionId, active2);
|
|
20427
20731
|
const turns = [];
|
|
20428
|
-
const starts = turnStarts(
|
|
20732
|
+
const starts = turnStarts(active2);
|
|
20429
20733
|
const byIndex = new Map(starts.map((start, ordinal) => [start.index, ordinal]));
|
|
20734
|
+
const models = createPiModelIndex([
|
|
20735
|
+
...state2.models ?? [],
|
|
20736
|
+
...state2.model ? [state2.model] : [],
|
|
20737
|
+
...active2.map(modelChange).filter((model2) => model2 !== null)
|
|
20738
|
+
]);
|
|
20430
20739
|
let effectiveModel = state2.model;
|
|
20431
|
-
for (let index = 0; index <
|
|
20432
|
-
const model2 = modelChange(
|
|
20740
|
+
for (let index = 0; index < active2.length; ) {
|
|
20741
|
+
const model2 = modelChange(active2[index]);
|
|
20433
20742
|
if (model2) {
|
|
20434
20743
|
effectiveModel = model2;
|
|
20435
20744
|
index += 1;
|
|
20436
20745
|
continue;
|
|
20437
20746
|
}
|
|
20438
|
-
const user =
|
|
20747
|
+
const user = active2[index];
|
|
20439
20748
|
const ordinal = byIndex.get(index);
|
|
20440
20749
|
if (ordinal === void 0) {
|
|
20441
20750
|
index += 1;
|
|
20442
20751
|
continue;
|
|
20443
20752
|
}
|
|
20444
20753
|
const next = starts[ordinal + 1];
|
|
20445
|
-
const end = next?.index ??
|
|
20446
|
-
const entries =
|
|
20754
|
+
const end = next?.index ?? active2.length;
|
|
20755
|
+
const entries = active2.slice(index, end);
|
|
20447
20756
|
const outcome = assistantOutcome(entries);
|
|
20448
20757
|
const userText = textContent2(message(user)?.content);
|
|
20449
20758
|
const nativeTurnRef = nativeTurnRefSchema.parse({
|
|
@@ -20464,7 +20773,7 @@ function mapPiSnapshot(history, state2, subagents = new PiSubagents(() => void 0
|
|
|
20464
20773
|
input: messageRole(user) === "user" ? [{ type: "text", text: userText }] : [],
|
|
20465
20774
|
items: snapshotItems(entries, identities, notices, outcome, subagents, state2.cwd),
|
|
20466
20775
|
outcome,
|
|
20467
|
-
...effectiveModel ? { model:
|
|
20776
|
+
...effectiveModel ? { model: models.ref(effectiveModel) } : {}
|
|
20468
20777
|
});
|
|
20469
20778
|
for (const entry of entries) {
|
|
20470
20779
|
const changed = modelChange(entry);
|
|
@@ -20484,8 +20793,8 @@ function resolvePiLastTurnBoundary(history) {
|
|
|
20484
20793
|
} : null;
|
|
20485
20794
|
}
|
|
20486
20795
|
function resolvePiForkBoundary(history, checkpointId) {
|
|
20487
|
-
const
|
|
20488
|
-
const starts = turnStarts(
|
|
20796
|
+
const active2 = activePiEntries(history);
|
|
20797
|
+
const starts = turnStarts(active2);
|
|
20489
20798
|
const targetTurnIndex = starts.findIndex(({ entry }) => entry.id === checkpointId);
|
|
20490
20799
|
if (targetTurnIndex < 0)
|
|
20491
20800
|
throw new Error("Pi Checkpoint is not on the active branch");
|
|
@@ -20670,14 +20979,14 @@ function createPiUsageStatistics(environment) {
|
|
|
20670
20979
|
return Object.freeze({
|
|
20671
20980
|
// <project>/<session>.jsonl and its subagents' <session>/<id>/run-*/session.jsonl
|
|
20672
20981
|
listSources: (signal) => jsonlUsageSources(piSessionImportDirectory(environment).directory, 4, signal),
|
|
20673
|
-
readSource: (
|
|
20982
|
+
readSource: (id2, signal) => readPiUsage(id2, signal)
|
|
20674
20983
|
});
|
|
20675
20984
|
}
|
|
20676
20985
|
|
|
20677
20986
|
// dist/account-balance.js
|
|
20678
|
-
import { readFile as
|
|
20679
|
-
import { homedir as
|
|
20680
|
-
import
|
|
20987
|
+
import { readFile as readFile3 } from "node:fs/promises";
|
|
20988
|
+
import { homedir as homedir4 } from "node:os";
|
|
20989
|
+
import path9 from "node:path";
|
|
20681
20990
|
var DEEPSEEK_BALANCE_ENDPOINT = "https://api.deepseek.com/user/balance";
|
|
20682
20991
|
var SUB2API_USAGE_PATH = "/v1/usage";
|
|
20683
20992
|
var REQUEST_TIMEOUT_MS = 1e4;
|
|
@@ -20686,11 +20995,11 @@ function agentDirectory(environment) {
|
|
|
20686
20995
|
const configured = environment.PI_CODING_AGENT_DIR?.trim();
|
|
20687
20996
|
if (configured)
|
|
20688
20997
|
return configured;
|
|
20689
|
-
return
|
|
20998
|
+
return path9.join(environment.HOME ?? environment.USERPROFILE ?? homedir4(), ".pi", "agent");
|
|
20690
20999
|
}
|
|
20691
21000
|
var record7 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
20692
21001
|
async function deepSeekApiKey(environment) {
|
|
20693
|
-
const auth = record7(JSON.parse(await
|
|
21002
|
+
const auth = record7(JSON.parse(await readFile3(path9.join(agentDirectory(environment), "auth.json"), "utf8")));
|
|
20694
21003
|
const deepseek = record7(auth.deepseek);
|
|
20695
21004
|
if (deepseek.type !== "api_key")
|
|
20696
21005
|
return void 0;
|
|
@@ -20759,16 +21068,16 @@ function usageEndpoint(baseUrl) {
|
|
|
20759
21068
|
}
|
|
20760
21069
|
async function configuredSub2ApiProviders(environment) {
|
|
20761
21070
|
try {
|
|
20762
|
-
const models = record7(JSON.parse(await
|
|
21071
|
+
const models = record7(JSON.parse(await readFile3(path9.join(agentDirectory(environment), "models.json"), "utf8")));
|
|
20763
21072
|
const providers = record7(models.providers);
|
|
20764
21073
|
const found = [];
|
|
20765
|
-
for (const [
|
|
21074
|
+
for (const [id2, definition] of Object.entries(providers)) {
|
|
20766
21075
|
const provider = record7(definition);
|
|
20767
21076
|
const apiKey = typeof provider.apiKey === "string" ? provider.apiKey.trim() : "";
|
|
20768
21077
|
const baseUrl = typeof provider.baseUrl === "string" ? provider.baseUrl.trim() : "";
|
|
20769
|
-
if (!
|
|
21078
|
+
if (!id2.trim() || id2.length > 128 || !apiKey || !usageEndpoint(baseUrl))
|
|
20770
21079
|
continue;
|
|
20771
|
-
found.push({ id, apiKey, baseUrl });
|
|
21080
|
+
found.push({ id: id2, apiKey, baseUrl });
|
|
20772
21081
|
}
|
|
20773
21082
|
return found.sort((left, right) => left.id.localeCompare(right.id));
|
|
20774
21083
|
} catch {
|
|
@@ -20821,21 +21130,21 @@ async function fetchPiAccountBalance(input) {
|
|
|
20821
21130
|
}
|
|
20822
21131
|
|
|
20823
21132
|
// dist/pi-credential-imports.js
|
|
20824
|
-
import { randomUUID as
|
|
21133
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
20825
21134
|
import { execFile as execFile2 } from "node:child_process";
|
|
20826
21135
|
import { promisify } from "node:util";
|
|
20827
21136
|
import { existsSync, readFileSync, writeFileSync, mkdirSync, rmSync, readdirSync, lstatSync, renameSync, rmdirSync } from "node:fs";
|
|
20828
21137
|
import { realpath as realpath2 } from "node:fs/promises";
|
|
20829
21138
|
import os4 from "node:os";
|
|
20830
|
-
import
|
|
21139
|
+
import path11 from "node:path";
|
|
20831
21140
|
import { pathToFileURL } from "node:url";
|
|
20832
21141
|
|
|
20833
21142
|
// dist/command.js
|
|
20834
21143
|
import fs2 from "node:fs";
|
|
20835
|
-
import { homedir as
|
|
20836
|
-
import
|
|
21144
|
+
import { homedir as homedir5, tmpdir as tmpdir2 } from "node:os";
|
|
21145
|
+
import path10 from "node:path";
|
|
20837
21146
|
var PI_PACKAGE_NAME = "@earendil-works/pi-coding-agent";
|
|
20838
|
-
var PI_PACKAGE_PATH =
|
|
21147
|
+
var PI_PACKAGE_PATH = path10.join("node_modules", "@earendil-works", "pi-coding-agent");
|
|
20839
21148
|
var piDiscoverySpec = {
|
|
20840
21149
|
id: "pi",
|
|
20841
21150
|
command: "pi",
|
|
@@ -20861,18 +21170,18 @@ function resolvePiExecutable(input, dependencies = {}) {
|
|
|
20861
21170
|
return resolution?.executable ?? input.command ?? input.environment.PI_COMMAND ?? "pi";
|
|
20862
21171
|
}
|
|
20863
21172
|
function findPiPackageDirectory(executable) {
|
|
20864
|
-
let directory =
|
|
21173
|
+
let directory = path10.dirname(executable);
|
|
20865
21174
|
while (true) {
|
|
20866
|
-
for (const candidate of [directory,
|
|
21175
|
+
for (const candidate of [directory, path10.join(directory, PI_PACKAGE_PATH)]) {
|
|
20867
21176
|
try {
|
|
20868
|
-
const manifest = JSON.parse(fs2.readFileSync(
|
|
21177
|
+
const manifest = JSON.parse(fs2.readFileSync(path10.join(candidate, "package.json"), "utf8"));
|
|
20869
21178
|
if (typeof manifest === "object" && manifest !== null && "name" in manifest && manifest.name === PI_PACKAGE_NAME) {
|
|
20870
21179
|
return candidate;
|
|
20871
21180
|
}
|
|
20872
21181
|
} catch {
|
|
20873
21182
|
}
|
|
20874
21183
|
}
|
|
20875
|
-
const parent =
|
|
21184
|
+
const parent = path10.dirname(directory);
|
|
20876
21185
|
if (parent === directory)
|
|
20877
21186
|
return void 0;
|
|
20878
21187
|
directory = parent;
|
|
@@ -20880,16 +21189,16 @@ function findPiPackageDirectory(executable) {
|
|
|
20880
21189
|
}
|
|
20881
21190
|
function findPiCliEntry(packageDirectory) {
|
|
20882
21191
|
try {
|
|
20883
|
-
const manifest = JSON.parse(fs2.readFileSync(
|
|
21192
|
+
const manifest = JSON.parse(fs2.readFileSync(path10.join(packageDirectory, "package.json"), "utf8"));
|
|
20884
21193
|
if (typeof manifest !== "object" || manifest === null || !("bin" in manifest))
|
|
20885
21194
|
return void 0;
|
|
20886
21195
|
const bin = manifest.bin;
|
|
20887
21196
|
const entry = typeof bin === "string" ? bin : typeof bin === "object" && bin !== null && "pi" in bin ? bin.pi : void 0;
|
|
20888
21197
|
if (typeof entry !== "string" || !entry.trim())
|
|
20889
21198
|
return void 0;
|
|
20890
|
-
const resolved =
|
|
20891
|
-
const relative =
|
|
20892
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
21199
|
+
const resolved = path10.resolve(packageDirectory, entry);
|
|
21200
|
+
const relative = path10.relative(packageDirectory, resolved);
|
|
21201
|
+
if (relative === ".." || relative.startsWith(`..${path10.sep}`) || path10.isAbsolute(relative) || !fs2.statSync(resolved).isFile()) {
|
|
20893
21202
|
return void 0;
|
|
20894
21203
|
}
|
|
20895
21204
|
return resolved;
|
|
@@ -20898,11 +21207,11 @@ function findPiCliEntry(packageDirectory) {
|
|
|
20898
21207
|
}
|
|
20899
21208
|
}
|
|
20900
21209
|
function isFilesystemRoot(cwd) {
|
|
20901
|
-
const resolved =
|
|
20902
|
-
return resolved ===
|
|
21210
|
+
const resolved = path10.resolve(cwd);
|
|
21211
|
+
return resolved === path10.parse(resolved).root;
|
|
20903
21212
|
}
|
|
20904
21213
|
function writableDirectory(candidate) {
|
|
20905
|
-
if (!candidate || !
|
|
21214
|
+
if (!candidate || !path10.isAbsolute(candidate) || isFilesystemRoot(candidate))
|
|
20906
21215
|
return void 0;
|
|
20907
21216
|
try {
|
|
20908
21217
|
if (!fs2.statSync(candidate).isDirectory())
|
|
@@ -20915,15 +21224,15 @@ function writableDirectory(candidate) {
|
|
|
20915
21224
|
}
|
|
20916
21225
|
function resolvePiInspectCwd(inputCwd, environment = process.env) {
|
|
20917
21226
|
if (typeof inputCwd === "string" && inputCwd.length > 0 && !isFilesystemRoot(inputCwd)) {
|
|
20918
|
-
return
|
|
21227
|
+
return path10.resolve(inputCwd);
|
|
20919
21228
|
}
|
|
20920
|
-
const candidates = [environment.USERPROFILE, environment.HOME,
|
|
21229
|
+
const candidates = [environment.USERPROFILE, environment.HOME, homedir5(), tmpdir2()];
|
|
20921
21230
|
for (const candidate of candidates) {
|
|
20922
21231
|
const usable = writableDirectory(candidate);
|
|
20923
21232
|
if (usable)
|
|
20924
21233
|
return usable;
|
|
20925
21234
|
}
|
|
20926
|
-
return inputCwd && inputCwd.length > 0 ?
|
|
21235
|
+
return inputCwd && inputCwd.length > 0 ? path10.resolve(inputCwd) : process.cwd();
|
|
20927
21236
|
}
|
|
20928
21237
|
|
|
20929
21238
|
// dist/pi-credential-imports.js
|
|
@@ -20968,7 +21277,7 @@ function describeOauth(credential) {
|
|
|
20968
21277
|
};
|
|
20969
21278
|
}
|
|
20970
21279
|
function writeAuth(filename, content) {
|
|
20971
|
-
const temporary = `${filename}.${
|
|
21280
|
+
const temporary = `${filename}.${randomUUID3()}.tmp`;
|
|
20972
21281
|
try {
|
|
20973
21282
|
writeFileSync(temporary, content, { flag: "wx", mode: 384 });
|
|
20974
21283
|
renameSync(temporary, filename);
|
|
@@ -20977,8 +21286,8 @@ function writeAuth(filename, content) {
|
|
|
20977
21286
|
}
|
|
20978
21287
|
}
|
|
20979
21288
|
function removeOwnedFiles(dir) {
|
|
20980
|
-
rmSync(
|
|
20981
|
-
rmSync(
|
|
21289
|
+
rmSync(path11.join(dir, "index.ts"), { force: true });
|
|
21290
|
+
rmSync(path11.join(dir, "import.json"), { force: true });
|
|
20982
21291
|
try {
|
|
20983
21292
|
rmdirSync(dir);
|
|
20984
21293
|
} catch {
|
|
@@ -20990,17 +21299,17 @@ async function installation(command, environment, authPath) {
|
|
|
20990
21299
|
const cliEntry = directory ? findPiCliEntry(directory) : void 0;
|
|
20991
21300
|
if (!directory || !cliEntry)
|
|
20992
21301
|
throw new Error("Pi credential import requires a supported npm Pi installation");
|
|
20993
|
-
const storage = await import(pathToFileURL(
|
|
20994
|
-
const ai =
|
|
20995
|
-
const all = await import(pathToFileURL(
|
|
21302
|
+
const storage = await import(pathToFileURL(path11.join(directory, "dist/core/auth-storage.js")).href);
|
|
21303
|
+
const ai = path11.join(directory, "node_modules/@earendil-works/pi-ai/dist");
|
|
21304
|
+
const all = await import(pathToFileURL(path11.join(ai, "providers/all.js")).href);
|
|
20996
21305
|
const providers = all.getBuiltinProviders();
|
|
20997
21306
|
const providerModules = {
|
|
20998
|
-
"openai-codex": pathToFileURL(
|
|
20999
|
-
xai: pathToFileURL(
|
|
21307
|
+
"openai-codex": pathToFileURL(path11.join(ai, "providers/openai-codex.js")).href,
|
|
21308
|
+
xai: pathToFileURL(path11.join(ai, "providers/xai.js")).href
|
|
21000
21309
|
};
|
|
21001
|
-
for (const [
|
|
21310
|
+
for (const [id2, url2] of Object.entries(providerModules)) {
|
|
21002
21311
|
const module = await import(url2);
|
|
21003
|
-
const provider =
|
|
21312
|
+
const provider = id2 === "xai" ? module.xaiProvider() : module.openaiCodexProvider();
|
|
21004
21313
|
if (!provider.auth?.oauth || !provider.getModels().length)
|
|
21005
21314
|
throw new Error("Pi version does not support subscription imports");
|
|
21006
21315
|
}
|
|
@@ -21010,8 +21319,8 @@ async function installation(command, environment, authPath) {
|
|
|
21010
21319
|
reservedNames: providers.map((p) => typeof p === "string" ? p : p.id),
|
|
21011
21320
|
async configuredProviderNames() {
|
|
21012
21321
|
const { stdout } = await promisify(execFile2)(process.execPath, [cliEntry, "--offline", "--no-approve", "--list-models"], {
|
|
21013
|
-
cwd: existsSync(
|
|
21014
|
-
env: { ...environment, PI_CODING_AGENT_DIR:
|
|
21322
|
+
cwd: existsSync(path11.dirname(authPath)) ? path11.dirname(authPath) : os4.homedir(),
|
|
21323
|
+
env: { ...environment, PI_CODING_AGENT_DIR: path11.dirname(authPath), PI_OFFLINE: "1" },
|
|
21015
21324
|
timeout: 15e3,
|
|
21016
21325
|
maxBuffer: 4 * 1024 * 1024
|
|
21017
21326
|
});
|
|
@@ -21041,17 +21350,17 @@ export default async function (pi) {
|
|
|
21041
21350
|
}
|
|
21042
21351
|
function createPiCredentialImports(options = {}) {
|
|
21043
21352
|
const env = { ...process.env, ...options.environment };
|
|
21044
|
-
const agentDir = env.PI_CODING_AGENT_DIR ??
|
|
21045
|
-
const authPath =
|
|
21046
|
-
const extensionsDir =
|
|
21353
|
+
const agentDir = env.PI_CODING_AGENT_DIR ?? path11.join(env.HOME ?? os4.homedir(), ".pi/agent");
|
|
21354
|
+
const authPath = path11.join(agentDir, "auth.json");
|
|
21355
|
+
const extensionsDir = path11.join(agentDir, "extensions");
|
|
21047
21356
|
const saveAuth = (auth) => (options.writeAuth ?? writeAuth)(authPath, JSON.stringify(auth, null, 2) + "\n");
|
|
21048
21357
|
const resolve = () => options.resolveInstallation?.(authPath) ?? installation(options.command, env, authPath);
|
|
21049
|
-
const location = (name) =>
|
|
21358
|
+
const location = (name) => path11.join(extensionsDir, `${PREFIX3}${credentialImportNameSchema.parse(name)}`);
|
|
21050
21359
|
const readRecord = (name) => {
|
|
21051
21360
|
const dir = location(name);
|
|
21052
21361
|
if (lstatSync(dir).isSymbolicLink())
|
|
21053
21362
|
throw new Error("Imported configuration was changed; manage it in Pi");
|
|
21054
|
-
const value = JSON.parse(readFileSync(
|
|
21363
|
+
const value = JSON.parse(readFileSync(path11.join(dir, "import.json"), "utf8"));
|
|
21055
21364
|
if (value.version !== 1 || typeof value.owner !== "string" || typeof value.extension !== "string")
|
|
21056
21365
|
throw new Error("Invalid import metadata");
|
|
21057
21366
|
const record10 = value.record;
|
|
@@ -21068,7 +21377,7 @@ function createPiCredentialImports(options = {}) {
|
|
|
21068
21377
|
};
|
|
21069
21378
|
const owned = (meta3, auth) => {
|
|
21070
21379
|
const credential = auth[meta3.record.name];
|
|
21071
|
-
const file2 =
|
|
21380
|
+
const file2 = path11.join(location(meta3.record.name), "index.ts");
|
|
21072
21381
|
return existsSync(file2) && !lstatSync(file2).isSymbolicLink() && readFileSync(file2, "utf8") === meta3.extension && object2(credential) && credential.type === "oauth" && credential.codexhostImportId === meta3.owner;
|
|
21073
21382
|
};
|
|
21074
21383
|
const readAuth = () => existsSync(authPath) ? parseAuth(readFileSync(authPath, "utf8")) : {};
|
|
@@ -21082,7 +21391,7 @@ function createPiCredentialImports(options = {}) {
|
|
|
21082
21391
|
const name = entry.slice(PREFIX3.length);
|
|
21083
21392
|
if (!credentialImportNameSchema.safeParse(name).success)
|
|
21084
21393
|
continue;
|
|
21085
|
-
if (!existsSync(
|
|
21394
|
+
if (!existsSync(path11.join(location(name), "import.json")))
|
|
21086
21395
|
continue;
|
|
21087
21396
|
try {
|
|
21088
21397
|
const meta3 = readRecord(name);
|
|
@@ -21116,7 +21425,7 @@ function createPiCredentialImports(options = {}) {
|
|
|
21116
21425
|
...describeOauth(credential)
|
|
21117
21426
|
});
|
|
21118
21427
|
}
|
|
21119
|
-
const modelsPath =
|
|
21428
|
+
const modelsPath = path11.join(agentDir, "models.json");
|
|
21120
21429
|
if (existsSync(modelsPath)) {
|
|
21121
21430
|
const models = JSON.parse(readFileSync(modelsPath, "utf8"));
|
|
21122
21431
|
const providers = object2(models) && object2(models.providers) ? models.providers : {};
|
|
@@ -21137,7 +21446,7 @@ function createPiCredentialImports(options = {}) {
|
|
|
21137
21446
|
throw new Error("Unsupported credential source");
|
|
21138
21447
|
if (sdk.reservedNames.includes(name) || (await sdk.configuredProviderNames?.())?.includes(name))
|
|
21139
21448
|
throw new Error("Provider name already exists; choose another name");
|
|
21140
|
-
const owner =
|
|
21449
|
+
const owner = randomUUID3();
|
|
21141
21450
|
const record10 = credentialImportRecordSchema.parse({
|
|
21142
21451
|
name,
|
|
21143
21452
|
source: transfer.source,
|
|
@@ -21150,15 +21459,15 @@ function createPiCredentialImports(options = {}) {
|
|
|
21150
21459
|
try {
|
|
21151
21460
|
sdk.backend.withLock((current) => {
|
|
21152
21461
|
const auth = parseAuth(current);
|
|
21153
|
-
const modelsPath =
|
|
21462
|
+
const modelsPath = path11.join(agentDir, "models.json");
|
|
21154
21463
|
const models = existsSync(modelsPath) ? JSON.parse(readFileSync(modelsPath, "utf8")) : {};
|
|
21155
|
-
if (Object.hasOwn(auth, name) || Object.hasOwn(models.providers ?? {}, name) || existsSync(dir) || existsSync(
|
|
21464
|
+
if (Object.hasOwn(auth, name) || Object.hasOwn(models.providers ?? {}, name) || existsSync(dir) || existsSync(path11.join(extensionsDir, `${name}-provider.ts`)))
|
|
21156
21465
|
throw new Error("Provider name already exists; choose another name");
|
|
21157
21466
|
mkdirSync(extensionsDir, { recursive: true, mode: 448 });
|
|
21158
21467
|
mkdirSync(dir, { mode: 448 });
|
|
21159
21468
|
created = true;
|
|
21160
|
-
writeFileSync(
|
|
21161
|
-
writeFileSync(
|
|
21469
|
+
writeFileSync(path11.join(dir, "import.json"), JSON.stringify({ version: 1, owner, record: record10, extension }), { flag: "wx", mode: 384 });
|
|
21470
|
+
writeFileSync(path11.join(dir, "index.ts"), extension, { flag: "wx", mode: 384 });
|
|
21162
21471
|
auth[name] = { type: "oauth", ...transfer.oauth, codexhostImportId: owner };
|
|
21163
21472
|
saveAuth(auth);
|
|
21164
21473
|
committed = true;
|
|
@@ -21177,7 +21486,7 @@ function createPiCredentialImports(options = {}) {
|
|
|
21177
21486
|
const auth = parseAuth(current);
|
|
21178
21487
|
if (!owned(meta3, auth) || meta3.record.source.id !== transfer.source.id || meta3.record.source.provider !== transfer.source.provider)
|
|
21179
21488
|
throw new Error("Import ownership or source account changed; refusing replacement");
|
|
21180
|
-
const metadataPath =
|
|
21489
|
+
const metadataPath = path11.join(location(name), "import.json");
|
|
21181
21490
|
const previous = readFileSync(metadataPath, "utf8");
|
|
21182
21491
|
const updated = {
|
|
21183
21492
|
...meta3,
|
|
@@ -21211,91 +21520,6 @@ function createPiCredentialImports(options = {}) {
|
|
|
21211
21520
|
};
|
|
21212
21521
|
}
|
|
21213
21522
|
|
|
21214
|
-
// dist/pi-fast-mode.js
|
|
21215
|
-
import { createHash as createHash5, randomUUID as randomUUID3 } from "node:crypto";
|
|
21216
|
-
import { mkdir as mkdir2, readFile as readFile3, rename as rename2, rm as rm3, writeFile as writeFile3 } from "node:fs/promises";
|
|
21217
|
-
import { homedir as homedir5 } from "node:os";
|
|
21218
|
-
import path11 from "node:path";
|
|
21219
|
-
var PI_FAST_COMMAND = "codexhost-fast-mode";
|
|
21220
|
-
var PI_FAST_ACK = "codexhost-fast-mode:";
|
|
21221
|
-
var PI_FAST_EXTENSION = `export default function(pi) {
|
|
21222
|
-
let target;
|
|
21223
|
-
const wrapped = new Set();
|
|
21224
|
-
const supportsModel = (model) => model && (model.api === "openai-codex-responses" || model.api === "openai-responses") && /gpt/i.test(model.id);
|
|
21225
|
-
pi.on("model_select", (_event, ctx) => {
|
|
21226
|
-
if (target && (target.provider !== ctx.model?.provider || target.id !== ctx.model?.id || !supportsModel(ctx.model))) target = undefined;
|
|
21227
|
-
});
|
|
21228
|
-
pi.on("session_start", (_event, ctx) => {
|
|
21229
|
-
if (typeof ctx.modelRegistry.getProvider !== "function" || typeof pi.registerProvider !== "function") return;
|
|
21230
|
-
pi.registerCommand("${PI_FAST_COMMAND}", {
|
|
21231
|
-
description: "Codex Host Fast mode",
|
|
21232
|
-
handler: async (args, ctx) => {
|
|
21233
|
-
const [mode, nonce] = args.split(" ");
|
|
21234
|
-
if (!nonce || (mode !== "on" && mode !== "off")) throw new Error("Invalid Fast selection");
|
|
21235
|
-
if (mode === "on") {
|
|
21236
|
-
const model = ctx.model;
|
|
21237
|
-
if (!supportsModel(model)) throw new Error("Fast requires a GPT model using the Codex or OpenAI Responses API");
|
|
21238
|
-
const original = ctx.modelRegistry.getProvider(model.provider);
|
|
21239
|
-
if (!original) throw new Error("Provider is unavailable");
|
|
21240
|
-
if (!wrapped.has(model.provider)) {
|
|
21241
|
-
const options = (model, value) => target && supportsModel(model) && target.provider === model.provider && target.id === model.id
|
|
21242
|
-
? {
|
|
21243
|
-
...value,
|
|
21244
|
-
serviceTier: "priority",
|
|
21245
|
-
// Pi streamSimple drops serviceTier but preserves onPayload.
|
|
21246
|
-
onPayload: async (payload, requestModel) => {
|
|
21247
|
-
const request = { ...payload, service_tier: "priority" };
|
|
21248
|
-
const replacement = await value?.onPayload?.(request, requestModel);
|
|
21249
|
-
return { ...(replacement === undefined ? request : replacement), service_tier: "priority" };
|
|
21250
|
-
},
|
|
21251
|
-
} : value;
|
|
21252
|
-
pi.registerProvider({
|
|
21253
|
-
...original,
|
|
21254
|
-
stream: (model, context, value) => original.stream(model, context, options(model, value)),
|
|
21255
|
-
streamSimple: (model, context, value) => original.streamSimple(model, context, options(model, value)),
|
|
21256
|
-
});
|
|
21257
|
-
wrapped.add(model.provider);
|
|
21258
|
-
}
|
|
21259
|
-
target = { provider: model.provider, id: model.id };
|
|
21260
|
-
} else target = undefined;
|
|
21261
|
-
ctx.ui.notify("${PI_FAST_ACK}" + nonce + ":" + mode, "info");
|
|
21262
|
-
},
|
|
21263
|
-
});
|
|
21264
|
-
});
|
|
21265
|
-
}
|
|
21266
|
-
`;
|
|
21267
|
-
async function ensurePiFastExtension(environment) {
|
|
21268
|
-
const digest = createHash5("sha256").update(PI_FAST_EXTENSION).digest("hex").slice(0, 16);
|
|
21269
|
-
const dataDirectory = environment.CODEXHOST_DATA_DIR ?? path11.join(environment.HOME ?? environment.USERPROFILE ?? homedir5(), ".codexhost");
|
|
21270
|
-
const directory = path11.resolve(dataDirectory, "extensions", "pi-codex-fast");
|
|
21271
|
-
const file2 = path11.join(directory, `${digest}.mjs`);
|
|
21272
|
-
if (await readFile3(file2, "utf8").catch(() => "") === PI_FAST_EXTENSION)
|
|
21273
|
-
return file2;
|
|
21274
|
-
await mkdir2(directory, { recursive: true });
|
|
21275
|
-
const temporary = `${file2}.${randomUUID3()}.tmp`;
|
|
21276
|
-
try {
|
|
21277
|
-
await writeFile3(temporary, PI_FAST_EXTENSION, { mode: 384 });
|
|
21278
|
-
try {
|
|
21279
|
-
await rename2(temporary, file2);
|
|
21280
|
-
} catch (error51) {
|
|
21281
|
-
if (await readFile3(file2, "utf8").catch(() => "") !== PI_FAST_EXTENSION)
|
|
21282
|
-
throw error51;
|
|
21283
|
-
}
|
|
21284
|
-
} finally {
|
|
21285
|
-
await rm3(temporary, { force: true });
|
|
21286
|
-
}
|
|
21287
|
-
return file2;
|
|
21288
|
-
}
|
|
21289
|
-
function piFastModelKeys(models) {
|
|
21290
|
-
return new Set(models.filter((model2) => (model2.api === "openai-codex-responses" || model2.api === "openai-responses") && /gpt/i.test(model2.id)).map((model2) => encodePiModelRef(model2).id));
|
|
21291
|
-
}
|
|
21292
|
-
function withPiFast(catalog, supported) {
|
|
21293
|
-
return {
|
|
21294
|
-
...catalog,
|
|
21295
|
-
models: catalog.models.map((model2) => supported.has(model2.ref.id) ? { ...model2, fastModel: encodePiModelRef({ ...decodePiModelRef(model2.ref), fast: true }) } : model2)
|
|
21296
|
-
};
|
|
21297
|
-
}
|
|
21298
|
-
|
|
21299
21523
|
// dist/pi-empty-session.js
|
|
21300
21524
|
import { createReadStream as createReadStream3 } from "node:fs";
|
|
21301
21525
|
import { createInterface as createInterface3 } from "node:readline";
|
|
@@ -21372,8 +21596,8 @@ async function persistEmptyPiSession(input) {
|
|
|
21372
21596
|
throw new Error("Pi empty Session persistence requires native v3 history");
|
|
21373
21597
|
}
|
|
21374
21598
|
const entries = history.entries;
|
|
21375
|
-
const
|
|
21376
|
-
if (
|
|
21599
|
+
const active2 = activePiEntries(history);
|
|
21600
|
+
if (active2.length !== entries.length || active2.some((entry, index) => entry.id !== entries[index]?.id)) {
|
|
21377
21601
|
throw new Error("Pi empty Session must expose its complete active branch");
|
|
21378
21602
|
}
|
|
21379
21603
|
const header = {
|
|
@@ -21537,10 +21761,10 @@ async function readPiWorkflowChild(history, parentSessionId, address) {
|
|
|
21537
21761
|
const result = details.results.findLast((candidate) => record8(candidate) && candidate.workflowKey === address.childId);
|
|
21538
21762
|
if (!record8(result))
|
|
21539
21763
|
break;
|
|
21540
|
-
const
|
|
21764
|
+
const id2 = piWorkflowSubagentId(address);
|
|
21541
21765
|
if (typeof result.sessionFile === "string") {
|
|
21542
21766
|
try {
|
|
21543
|
-
const snapshot = await childHistory(result.sessionFile, parentSessionId,
|
|
21767
|
+
const snapshot = await childHistory(result.sessionFile, parentSessionId, id2);
|
|
21544
21768
|
if (snapshot.turns.length)
|
|
21545
21769
|
return { ok: true, value: snapshot };
|
|
21546
21770
|
} catch {
|
|
@@ -21550,7 +21774,7 @@ async function readPiWorkflowChild(history, parentSessionId, address) {
|
|
|
21550
21774
|
const output = result.finalOutput.slice(0, 64 * 1024);
|
|
21551
21775
|
return {
|
|
21552
21776
|
ok: true,
|
|
21553
|
-
value: piSubagentSnapshot(parentSessionId,
|
|
21777
|
+
value: piSubagentSnapshot(parentSessionId, id2, {
|
|
21554
21778
|
kind: "pi-subagents.inspect-reply",
|
|
21555
21779
|
version: 1,
|
|
21556
21780
|
requestId: "native-workflow-result",
|
|
@@ -21593,8 +21817,8 @@ function gotgenesHistory(history) {
|
|
|
21593
21817
|
function restoreGotgenes(history, observer) {
|
|
21594
21818
|
observer.observe(gotgenesHistory(history), false);
|
|
21595
21819
|
}
|
|
21596
|
-
async function readGotgenesChild(history, parentSessionId,
|
|
21597
|
-
const saved = gotgenesHistory(history).find((entry) => entry.id ===
|
|
21820
|
+
async function readGotgenesChild(history, parentSessionId, id2, live) {
|
|
21821
|
+
const saved = gotgenesHistory(history).find((entry) => entry.id === id2);
|
|
21598
21822
|
const record10 = live?.outputFile ? live : saved;
|
|
21599
21823
|
if (!record10?.outputFile)
|
|
21600
21824
|
return {
|
|
@@ -21608,7 +21832,7 @@ async function readGotgenesChild(history, parentSessionId, id, live) {
|
|
|
21608
21832
|
try {
|
|
21609
21833
|
return {
|
|
21610
21834
|
ok: true,
|
|
21611
|
-
value: await childHistory(record10.outputFile, parentSessionId, gotgenesId(
|
|
21835
|
+
value: await childHistory(record10.outputFile, parentSessionId, gotgenesId(id2), true)
|
|
21612
21836
|
};
|
|
21613
21837
|
} catch (error51) {
|
|
21614
21838
|
return {
|
|
@@ -21681,7 +21905,7 @@ async function restorePiSubagents(history, owners, observer) {
|
|
|
21681
21905
|
continue;
|
|
21682
21906
|
receipts.set(details.asyncId, details.asyncDir);
|
|
21683
21907
|
}
|
|
21684
|
-
for (const [
|
|
21908
|
+
for (const [id2, directory] of [...receipts].slice(-128)) {
|
|
21685
21909
|
let file2;
|
|
21686
21910
|
try {
|
|
21687
21911
|
file2 = await open4(path14.join(directory, "status.json"), constants2.O_RDONLY | (constants2.O_NOFOLLOW ?? 0));
|
|
@@ -21693,7 +21917,7 @@ async function restorePiSubagents(history, owners, observer) {
|
|
|
21693
21917
|
if (bytesRead > 1024 * 1024)
|
|
21694
21918
|
continue;
|
|
21695
21919
|
const value = JSON.parse(buffer.subarray(0, bytesRead).toString("utf8"));
|
|
21696
|
-
const runs = piSubagentArtifact(value,
|
|
21920
|
+
const runs = piSubagentArtifact(value, id2, owners);
|
|
21697
21921
|
if (runs)
|
|
21698
21922
|
observer.restore(runs);
|
|
21699
21923
|
} catch {
|
|
@@ -22132,8 +22356,8 @@ var READ_ONLY_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
22132
22356
|
"get_available_thinking_levels"
|
|
22133
22357
|
]);
|
|
22134
22358
|
var MAX_EXPIRED_IDS = 64;
|
|
22135
|
-
function nativeMessageIdentity(
|
|
22136
|
-
return
|
|
22359
|
+
function nativeMessageIdentity(active2) {
|
|
22360
|
+
return active2.assistantNativeMessageIdentity ? { nativeMessageIdentity: active2.assistantNativeMessageIdentity } : {};
|
|
22137
22361
|
}
|
|
22138
22362
|
var textDecoder = new TextDecoder("utf-8", { fatal: true });
|
|
22139
22363
|
function isRecord9(value) {
|
|
@@ -22440,8 +22664,8 @@ var PiRpcSession = class {
|
|
|
22440
22664
|
if (this.#gotgenesLatest)
|
|
22441
22665
|
handler(this.#gotgenesLatest, "idle");
|
|
22442
22666
|
}
|
|
22443
|
-
inspectSubagent(
|
|
22444
|
-
return this.#subagents.inspect(
|
|
22667
|
+
inspectSubagent(id2) {
|
|
22668
|
+
return this.#subagents.inspect(id2);
|
|
22445
22669
|
}
|
|
22446
22670
|
setUsageHandler(handler) {
|
|
22447
22671
|
this.#usageHandler = handler;
|
|
@@ -22794,9 +23018,9 @@ var PiRpcSession = class {
|
|
|
22794
23018
|
return this.#resolveInteraction(response, "cancelled" in response ? "cancelled" : "responded");
|
|
22795
23019
|
}
|
|
22796
23020
|
async #resolveInteraction(response, reason) {
|
|
22797
|
-
const
|
|
22798
|
-
const pending =
|
|
22799
|
-
if (!
|
|
23021
|
+
const active2 = this.#activeTurn;
|
|
23022
|
+
const pending = active2?.interactions.get(response.requestId);
|
|
23023
|
+
if (!active2 || !pending || this.#closed || this.#failed) {
|
|
22800
23024
|
throw new Error("Pi RPC interaction is not pending");
|
|
22801
23025
|
}
|
|
22802
23026
|
if ("value" in response && !["select", "input", "editor"].includes(pending.request.method)) {
|
|
@@ -22806,12 +23030,12 @@ var PiRpcSession = class {
|
|
|
22806
23030
|
throw new Error("Pi RPC confirmation does not match the request");
|
|
22807
23031
|
}
|
|
22808
23032
|
const frame = "cancelled" in response ? { type: "extension_ui_response", id: response.requestId, cancelled: true } : "confirmed" in response ? { type: "extension_ui_response", id: response.requestId, confirmed: response.confirmed } : { type: "extension_ui_response", id: response.requestId, value: response.value };
|
|
22809
|
-
if (!
|
|
23033
|
+
if (!active2.interactions.delete(response.requestId)) {
|
|
22810
23034
|
throw new Error("Pi RPC interaction is not pending");
|
|
22811
23035
|
}
|
|
22812
23036
|
if (pending.timeout)
|
|
22813
23037
|
clearTimeout(pending.timeout);
|
|
22814
|
-
|
|
23038
|
+
active2.onEvent({ type: "interaction.closed", requestId: response.requestId, reason });
|
|
22815
23039
|
try {
|
|
22816
23040
|
await this.#write(frame);
|
|
22817
23041
|
} catch (error51) {
|
|
@@ -22821,37 +23045,37 @@ var PiRpcSession = class {
|
|
|
22821
23045
|
}
|
|
22822
23046
|
}
|
|
22823
23047
|
abort() {
|
|
22824
|
-
const
|
|
22825
|
-
if (!
|
|
23048
|
+
const active2 = this.#activeTurn;
|
|
23049
|
+
if (!active2 || this.#closed || this.#failed) {
|
|
22826
23050
|
return Promise.reject(new Error("Pi RPC Session has no cancellable Turn"));
|
|
22827
23051
|
}
|
|
22828
|
-
if (
|
|
22829
|
-
return
|
|
22830
|
-
|
|
22831
|
-
|
|
22832
|
-
this.#terminateFailedCancellation(
|
|
23052
|
+
if (active2.abortPromise)
|
|
23053
|
+
return active2.abortPromise;
|
|
23054
|
+
active2.cancellation = "requesting";
|
|
23055
|
+
active2.cancellationTimeout = setTimeout(() => {
|
|
23056
|
+
this.#terminateFailedCancellation(active2, new PiRpcFaultError("protocolError", "Pi Turn cancellation did not settle within its bound"));
|
|
22833
23057
|
}, this.#options.cancelTimeoutMs);
|
|
22834
23058
|
const aborting = this.#send("abort", {}).then(() => {
|
|
22835
|
-
if (this.#activeTurn !==
|
|
23059
|
+
if (this.#activeTurn !== active2)
|
|
22836
23060
|
return;
|
|
22837
|
-
|
|
22838
|
-
this.#finishSettledTurn(
|
|
23061
|
+
active2.cancellation = "accepted";
|
|
23062
|
+
this.#finishSettledTurn(active2);
|
|
22839
23063
|
}).catch((error51) => {
|
|
22840
|
-
if (this.#activeTurn !==
|
|
23064
|
+
if (this.#activeTurn !== active2)
|
|
22841
23065
|
throw error51;
|
|
22842
23066
|
const fault = error51 instanceof PiRpcFaultError ? error51 : new PiRpcFaultError("protocolError", `Pi RPC Abort failed: ${message2(error51)}`);
|
|
22843
|
-
this.#terminateFailedCancellation(
|
|
23067
|
+
this.#terminateFailedCancellation(active2, fault);
|
|
22844
23068
|
throw fault;
|
|
22845
23069
|
});
|
|
22846
|
-
|
|
23070
|
+
active2.abortPromise = aborting;
|
|
22847
23071
|
return aborting;
|
|
22848
23072
|
}
|
|
22849
|
-
#terminateFailedCancellation(
|
|
22850
|
-
if (this.#activeTurn !==
|
|
23073
|
+
#terminateFailedCancellation(active2, fault) {
|
|
23074
|
+
if (this.#activeTurn !== active2)
|
|
22851
23075
|
return;
|
|
22852
|
-
if (
|
|
22853
|
-
clearTimeout(
|
|
22854
|
-
|
|
23076
|
+
if (active2.cancellationTimeout)
|
|
23077
|
+
clearTimeout(active2.cancellationTimeout);
|
|
23078
|
+
active2.cancellationTimeout = null;
|
|
22855
23079
|
this.#fail(fault);
|
|
22856
23080
|
void this.close().catch(() => void 0);
|
|
22857
23081
|
}
|
|
@@ -22970,9 +23194,9 @@ var PiRpcSession = class {
|
|
|
22970
23194
|
this.#compactionActive = false;
|
|
22971
23195
|
const compactionTurn = this.#compactionTurn;
|
|
22972
23196
|
this.#compactionTurn = null;
|
|
22973
|
-
for (const [
|
|
23197
|
+
for (const [id2, pending] of this.#pending) {
|
|
22974
23198
|
if (pending.command === "prompt" || pending.command === "compact") {
|
|
22975
|
-
this.#armCommandTimeout(
|
|
23199
|
+
this.#armCommandTimeout(id2, pending);
|
|
22976
23200
|
}
|
|
22977
23201
|
}
|
|
22978
23202
|
const outcome = value.aborted === true ? "cancelled" : isRecord9(value.result) ? "succeeded" : "failed";
|
|
@@ -22991,26 +23215,26 @@ var PiRpcSession = class {
|
|
|
22991
23215
|
});
|
|
22992
23216
|
return;
|
|
22993
23217
|
}
|
|
22994
|
-
let
|
|
22995
|
-
if (!
|
|
22996
|
-
|
|
23218
|
+
let active2 = this.#activeTurn;
|
|
23219
|
+
if (!active2 && !this.#manualCompaction && !this.#compactionActive && (this.#autonomousTurnHandler || this.#autonomousLifecycleHandler) && value.type === "message_start" && assistantText(value.message) !== null) {
|
|
23220
|
+
active2 = this.#startAutonomousTurn(value.message, generation);
|
|
22997
23221
|
}
|
|
22998
|
-
if (!
|
|
23222
|
+
if (!active2) {
|
|
22999
23223
|
if (value.type === "extension_ui_request" && this.#isBlockingInteraction(value)) {
|
|
23000
23224
|
this.#fail(new PiRpcFaultError("protocolError", "Pi RPC requested blocking Extension UI outside an active Turn"));
|
|
23001
23225
|
}
|
|
23002
23226
|
return;
|
|
23003
23227
|
}
|
|
23004
23228
|
if (value.type === "extension_ui_request") {
|
|
23005
|
-
if (
|
|
23229
|
+
if (active2.origin === "autonomous" && this.#isBlockingInteraction(value)) {
|
|
23006
23230
|
this.#fail(new PiRpcFaultError("protocolError", "Pi RPC requested blocking Extension UI during an autonomous Turn"));
|
|
23007
23231
|
return;
|
|
23008
23232
|
}
|
|
23009
|
-
this.#startInteraction(
|
|
23233
|
+
this.#startInteraction(active2, value);
|
|
23010
23234
|
return;
|
|
23011
23235
|
}
|
|
23012
23236
|
if (value.type === "message_start" && assistantText(value.message) !== null) {
|
|
23013
|
-
this.#startAssistantMessage(
|
|
23237
|
+
this.#startAssistantMessage(active2, value.message);
|
|
23014
23238
|
return;
|
|
23015
23239
|
}
|
|
23016
23240
|
if (value.type === "message_update" && isRecord9(value.assistantMessageEvent)) {
|
|
@@ -23022,54 +23246,54 @@ var PiRpcSession = class {
|
|
|
23022
23246
|
const endingReasoning = eventType === "thinking_end" || eventType === "reasoning_end";
|
|
23023
23247
|
const endingText = eventType === "text_end";
|
|
23024
23248
|
if ((endingReasoning || endingText) && typeof event.content === "string") {
|
|
23025
|
-
this.#ensureAssistantMessage(
|
|
23026
|
-
const stream = endingReasoning ?
|
|
23027
|
-
this.#emitContent(
|
|
23249
|
+
this.#ensureAssistantMessage(active2, value.message);
|
|
23250
|
+
const stream = endingReasoning ? active2.reasoningStream : active2.textStream;
|
|
23251
|
+
this.#emitContent(active2, endingReasoning, stream.complete(event.contentIndex, event.content));
|
|
23028
23252
|
} else if ((isThinking || isText) && delta !== null && delta.length > 0) {
|
|
23029
|
-
this.#ensureAssistantMessage(
|
|
23253
|
+
this.#ensureAssistantMessage(active2, value.message);
|
|
23030
23254
|
if (isThinking)
|
|
23031
|
-
|
|
23255
|
+
active2.sawStreamedMessageReasoning = true;
|
|
23032
23256
|
else
|
|
23033
|
-
|
|
23034
|
-
const stream = isThinking ?
|
|
23035
|
-
this.#emitContent(
|
|
23257
|
+
active2.sawStreamedMessageText = true;
|
|
23258
|
+
const stream = isThinking ? active2.reasoningStream : active2.textStream;
|
|
23259
|
+
this.#emitContent(active2, isThinking, stream.append(event.contentIndex, delta));
|
|
23036
23260
|
} else if (event.type === "error") {
|
|
23037
|
-
this.#ensureAssistantMessage(
|
|
23038
|
-
|
|
23261
|
+
this.#ensureAssistantMessage(active2, value.message);
|
|
23262
|
+
active2.failure = assistantFailure(event.error) ?? assistantFailure(value.message) ?? new Error("Pi assistant message failed");
|
|
23039
23263
|
}
|
|
23040
23264
|
return;
|
|
23041
23265
|
}
|
|
23042
23266
|
if (value.type === "message_end") {
|
|
23043
|
-
this.#finalizeAssistantMessage(
|
|
23267
|
+
this.#finalizeAssistantMessage(active2, value.message);
|
|
23044
23268
|
return;
|
|
23045
23269
|
}
|
|
23046
23270
|
if (value.type === "turn_end") {
|
|
23047
|
-
this.#finalizeAssistantMessage(
|
|
23271
|
+
this.#finalizeAssistantMessage(active2, value.message);
|
|
23048
23272
|
return;
|
|
23049
23273
|
}
|
|
23050
23274
|
if (value.type === "tool_execution_start") {
|
|
23051
|
-
this.#startTool(
|
|
23275
|
+
this.#startTool(active2, value);
|
|
23052
23276
|
return;
|
|
23053
23277
|
}
|
|
23054
23278
|
if (value.type === "tool_execution_update") {
|
|
23055
|
-
this.#updateTool(
|
|
23279
|
+
this.#updateTool(active2, value);
|
|
23056
23280
|
return;
|
|
23057
23281
|
}
|
|
23058
23282
|
if (value.type === "tool_execution_end") {
|
|
23059
|
-
this.#completeTool(
|
|
23283
|
+
this.#completeTool(active2, value);
|
|
23060
23284
|
return;
|
|
23061
23285
|
}
|
|
23062
23286
|
if (value.type === "agent_settled") {
|
|
23063
|
-
if (
|
|
23287
|
+
if (active2.settlement !== "pending")
|
|
23064
23288
|
return;
|
|
23065
|
-
|
|
23066
|
-
void this.#confirmSettledTurn(
|
|
23289
|
+
active2.settlement = "confirming";
|
|
23290
|
+
void this.#confirmSettledTurn(active2, active2.runGeneration);
|
|
23067
23291
|
}
|
|
23068
23292
|
}
|
|
23069
23293
|
#startAutonomousTurn(value, generation) {
|
|
23070
23294
|
const events = [];
|
|
23071
23295
|
const runId = randomUUID6();
|
|
23072
|
-
const
|
|
23296
|
+
const active2 = {
|
|
23073
23297
|
origin: "autonomous",
|
|
23074
23298
|
autonomousRunId: runId,
|
|
23075
23299
|
runGeneration: generation,
|
|
@@ -23104,10 +23328,10 @@ var PiRpcSession = class {
|
|
|
23104
23328
|
cancellationTimeout: null,
|
|
23105
23329
|
abortPromise: null
|
|
23106
23330
|
};
|
|
23107
|
-
this.#activeTurn =
|
|
23331
|
+
this.#activeTurn = active2;
|
|
23108
23332
|
this.#autonomousLifecycleHandler?.({ type: "started", runId });
|
|
23109
|
-
this.#drainProgress(
|
|
23110
|
-
return
|
|
23333
|
+
this.#drainProgress(active2.onEvent);
|
|
23334
|
+
return active2;
|
|
23111
23335
|
}
|
|
23112
23336
|
#handleProgress(value) {
|
|
23113
23337
|
if ((value.type === "message_start" || value.type === "message_end") && isRecord9(value.message) && value.message.role === "custom") {
|
|
@@ -23189,21 +23413,21 @@ var PiRpcSession = class {
|
|
|
23189
23413
|
for (const pending of this.#pendingProgress.splice(0))
|
|
23190
23414
|
onEvent(pending.event);
|
|
23191
23415
|
}
|
|
23192
|
-
#emitAutonomousTurn(
|
|
23416
|
+
#emitAutonomousTurn(active2, result) {
|
|
23193
23417
|
const handler = this.#autonomousTurnHandler;
|
|
23194
|
-
if (
|
|
23418
|
+
if (active2.origin !== "autonomous" || !active2.autonomousEvents || !active2.autonomousRunId) {
|
|
23195
23419
|
return;
|
|
23196
23420
|
}
|
|
23197
23421
|
try {
|
|
23198
23422
|
const turn = {
|
|
23199
|
-
nativeTurnKey:
|
|
23200
|
-
events: [...
|
|
23423
|
+
nativeTurnKey: active2.nativeTurnKey,
|
|
23424
|
+
events: [...active2.autonomousEvents],
|
|
23201
23425
|
result
|
|
23202
23426
|
};
|
|
23203
23427
|
if (this.#autonomousLifecycleHandler)
|
|
23204
23428
|
this.#autonomousLifecycleHandler({
|
|
23205
23429
|
type: "completed",
|
|
23206
|
-
runId:
|
|
23430
|
+
runId: active2.autonomousRunId,
|
|
23207
23431
|
turn
|
|
23208
23432
|
});
|
|
23209
23433
|
else
|
|
@@ -23215,14 +23439,14 @@ var PiRpcSession = class {
|
|
|
23215
23439
|
#isBlockingInteraction(value) {
|
|
23216
23440
|
return ["select", "confirm", "input", "editor"].includes(String(value.method));
|
|
23217
23441
|
}
|
|
23218
|
-
#startInteraction(
|
|
23442
|
+
#startInteraction(active2, value) {
|
|
23219
23443
|
if (!this.#isBlockingInteraction(value))
|
|
23220
23444
|
return;
|
|
23221
23445
|
const requestId = value.id;
|
|
23222
23446
|
const method = value.method;
|
|
23223
23447
|
const title = value.title;
|
|
23224
23448
|
const timeoutMs = value.timeout;
|
|
23225
|
-
if (typeof requestId !== "string" || requestId.length === 0 || typeof method !== "string" || typeof title !== "string" || title.length === 0 || timeoutMs !== void 0 && (typeof timeoutMs !== "number" || !Number.isFinite(timeoutMs) || timeoutMs < 0) ||
|
|
23449
|
+
if (typeof requestId !== "string" || requestId.length === 0 || typeof method !== "string" || typeof title !== "string" || title.length === 0 || timeoutMs !== void 0 && (typeof timeoutMs !== "number" || !Number.isFinite(timeoutMs) || timeoutMs < 0) || active2.interactions.has(requestId)) {
|
|
23226
23450
|
throw new PiRpcFaultError("protocolError", "Pi RPC returned an invalid Interaction request");
|
|
23227
23451
|
}
|
|
23228
23452
|
let request;
|
|
@@ -23274,7 +23498,7 @@ var PiRpcSession = class {
|
|
|
23274
23498
|
const pending = { request, timeout: null };
|
|
23275
23499
|
if (request.timeoutMs !== void 0) {
|
|
23276
23500
|
pending.timeout = setTimeout(() => {
|
|
23277
|
-
if (this.#activeTurn !==
|
|
23501
|
+
if (this.#activeTurn !== active2 || !active2.interactions.has(requestId))
|
|
23278
23502
|
return;
|
|
23279
23503
|
void this.#resolveInteraction({ requestId, cancelled: true }, "expired").catch((error51) => {
|
|
23280
23504
|
if (this.#closed || this.#failed)
|
|
@@ -23283,17 +23507,17 @@ var PiRpcSession = class {
|
|
|
23283
23507
|
});
|
|
23284
23508
|
}, request.timeoutMs);
|
|
23285
23509
|
}
|
|
23286
|
-
|
|
23287
|
-
|
|
23510
|
+
active2.interactions.set(requestId, pending);
|
|
23511
|
+
active2.onEvent({ type: "interaction.requested", request });
|
|
23288
23512
|
}
|
|
23289
23513
|
#handleResponse(value) {
|
|
23290
|
-
const
|
|
23291
|
-
if (typeof
|
|
23514
|
+
const id2 = value.id;
|
|
23515
|
+
if (typeof id2 !== "string") {
|
|
23292
23516
|
this.#fail(new PiRpcFaultError("protocolError", "Pi RPC response has no id"));
|
|
23293
23517
|
return;
|
|
23294
23518
|
}
|
|
23295
|
-
const pending = this.#pending.get(
|
|
23296
|
-
if (!pending && this.#expired.delete(
|
|
23519
|
+
const pending = this.#pending.get(id2);
|
|
23520
|
+
if (!pending && this.#expired.delete(id2))
|
|
23297
23521
|
return;
|
|
23298
23522
|
if (!pending) {
|
|
23299
23523
|
this.#fail(new PiRpcFaultError("protocolError", "Pi RPC response id is not pending"));
|
|
@@ -23301,7 +23525,7 @@ var PiRpcSession = class {
|
|
|
23301
23525
|
}
|
|
23302
23526
|
if (pending.timeout)
|
|
23303
23527
|
clearTimeout(pending.timeout);
|
|
23304
|
-
this.#pending.delete(
|
|
23528
|
+
this.#pending.delete(id2);
|
|
23305
23529
|
if (value.success === true)
|
|
23306
23530
|
pending.resolve(value);
|
|
23307
23531
|
else {
|
|
@@ -23315,40 +23539,40 @@ var PiRpcSession = class {
|
|
|
23315
23539
|
}
|
|
23316
23540
|
}
|
|
23317
23541
|
}
|
|
23318
|
-
#startTool(
|
|
23542
|
+
#startTool(active2, value) {
|
|
23319
23543
|
const callId = value.toolCallId;
|
|
23320
23544
|
const toolName = value.toolName;
|
|
23321
23545
|
const argumentsResult = jsonValueSchema.safeParse(value.args);
|
|
23322
|
-
if (typeof callId !== "string" || callId.length === 0 || typeof toolName !== "string" || toolName.length === 0 || !argumentsResult.success ||
|
|
23546
|
+
if (typeof callId !== "string" || callId.length === 0 || typeof toolName !== "string" || toolName.length === 0 || !argumentsResult.success || active2.tools.has(callId)) {
|
|
23323
23547
|
throw new PiRpcFaultError("protocolError", "Pi RPC returned an invalid Tool start");
|
|
23324
23548
|
}
|
|
23325
|
-
|
|
23326
|
-
|
|
23327
|
-
|
|
23549
|
+
active2.sawTool = true;
|
|
23550
|
+
active2.tools.set(callId, toolName);
|
|
23551
|
+
active2.onEvent({
|
|
23328
23552
|
type: "tool.started",
|
|
23329
23553
|
callId,
|
|
23330
23554
|
toolName,
|
|
23331
23555
|
arguments: argumentsResult.data
|
|
23332
23556
|
});
|
|
23333
23557
|
}
|
|
23334
|
-
#updateTool(
|
|
23558
|
+
#updateTool(active2, value) {
|
|
23335
23559
|
const callId = value.toolCallId;
|
|
23336
23560
|
const outputResult = jsonValueSchema.safeParse(value.partialResult);
|
|
23337
|
-
if (typeof callId !== "string" || !
|
|
23561
|
+
if (typeof callId !== "string" || !active2.tools.has(callId) || !outputResult.success) {
|
|
23338
23562
|
throw new PiRpcFaultError("protocolError", "Pi RPC returned an invalid Tool update");
|
|
23339
23563
|
}
|
|
23340
|
-
|
|
23564
|
+
active2.onEvent({ type: "tool.updated", callId, output: outputResult.data });
|
|
23341
23565
|
}
|
|
23342
|
-
#completeTool(
|
|
23566
|
+
#completeTool(active2, value) {
|
|
23343
23567
|
const callId = value.toolCallId;
|
|
23344
23568
|
const toolName = value.toolName;
|
|
23345
23569
|
const result = jsonValueSchema.safeParse(value.result);
|
|
23346
|
-
const expectedName = typeof callId === "string" ?
|
|
23570
|
+
const expectedName = typeof callId === "string" ? active2.tools.get(callId) : void 0;
|
|
23347
23571
|
if (typeof callId !== "string" || typeof toolName !== "string" || expectedName !== toolName || typeof value.isError !== "boolean" || !result.success) {
|
|
23348
23572
|
throw new PiRpcFaultError("protocolError", "Pi RPC returned an invalid Tool end");
|
|
23349
23573
|
}
|
|
23350
|
-
|
|
23351
|
-
|
|
23574
|
+
active2.tools.delete(callId);
|
|
23575
|
+
active2.onEvent({
|
|
23352
23576
|
type: "tool.completed",
|
|
23353
23577
|
callId,
|
|
23354
23578
|
toolName,
|
|
@@ -23356,8 +23580,8 @@ var PiRpcSession = class {
|
|
|
23356
23580
|
isError: value.isError
|
|
23357
23581
|
});
|
|
23358
23582
|
}
|
|
23359
|
-
#isSettlementCurrent(
|
|
23360
|
-
return this.#activeTurn ===
|
|
23583
|
+
#isSettlementCurrent(active2, generation) {
|
|
23584
|
+
return this.#activeTurn === active2 && active2.runGeneration === generation && active2.settlement === "confirming";
|
|
23361
23585
|
}
|
|
23362
23586
|
#waitForNextRun(generation) {
|
|
23363
23587
|
if (this.#runGeneration > generation)
|
|
@@ -23392,23 +23616,23 @@ var PiRpcSession = class {
|
|
|
23392
23616
|
this.#handle(frame.value, frame.generation);
|
|
23393
23617
|
}
|
|
23394
23618
|
}
|
|
23395
|
-
async #confirmSettledTurn(
|
|
23619
|
+
async #confirmSettledTurn(active2, generation) {
|
|
23396
23620
|
try {
|
|
23397
23621
|
const response = await this.#send("get_state", {});
|
|
23398
23622
|
const state2 = parseSessionState(response);
|
|
23399
|
-
if (!this.#isSettlementCurrent(
|
|
23623
|
+
if (!this.#isSettlementCurrent(active2, generation))
|
|
23400
23624
|
return;
|
|
23401
23625
|
if (parseSessionStreaming(response))
|
|
23402
23626
|
await this.#waitForNextRun(generation);
|
|
23403
|
-
if (!this.#isSettlementCurrent(
|
|
23627
|
+
if (!this.#isSettlementCurrent(active2, generation))
|
|
23404
23628
|
return;
|
|
23405
|
-
if (
|
|
23629
|
+
if (active2.origin === "autonomous" && active2.autonomousMessage) {
|
|
23406
23630
|
const history = await this.getEntries();
|
|
23407
23631
|
const snapshot = mapPiSnapshot(history, { sessionId: state2.sessionId, model: null });
|
|
23408
|
-
if (!this.#isSettlementCurrent(
|
|
23632
|
+
if (!this.#isSettlementCurrent(active2, generation))
|
|
23409
23633
|
return;
|
|
23410
23634
|
const entries = activePiEntries(history);
|
|
23411
|
-
const live =
|
|
23635
|
+
const live = active2.autonomousMessage;
|
|
23412
23636
|
const responseId = assistantMessageId(live);
|
|
23413
23637
|
const matches = snapshot.turns.filter((turn2) => {
|
|
23414
23638
|
if (turn2.input.length !== 0)
|
|
@@ -23420,156 +23644,156 @@ var PiRpcSession = class {
|
|
|
23420
23644
|
const turn = matches.length === 1 ? matches[0] : void 0;
|
|
23421
23645
|
if (!turn)
|
|
23422
23646
|
throw new PiRpcFaultError("protocolError", "Pi autonomous Turn has no matching persisted custom Entry");
|
|
23423
|
-
|
|
23647
|
+
active2.nativeTurnKey = turn.nativeTurnRef.nativeTurnKey;
|
|
23424
23648
|
}
|
|
23425
|
-
if (!this.#isSettlementCurrent(
|
|
23649
|
+
if (!this.#isSettlementCurrent(active2, generation))
|
|
23426
23650
|
return;
|
|
23427
23651
|
this.#state = state2;
|
|
23428
|
-
|
|
23429
|
-
this.#finishSettledTurn(
|
|
23652
|
+
active2.settlement = "confirmed";
|
|
23653
|
+
this.#finishSettledTurn(active2);
|
|
23430
23654
|
} catch (error51) {
|
|
23431
|
-
if (this.#activeTurn !==
|
|
23655
|
+
if (this.#activeTurn !== active2)
|
|
23432
23656
|
return;
|
|
23433
23657
|
const fault = error51 instanceof PiRpcFaultError ? error51 : new PiRpcFaultError("protocolError", `Pi RPC stable Turn state could not be confirmed: ${message2(error51)}`);
|
|
23434
23658
|
this.#fail(fault);
|
|
23435
23659
|
}
|
|
23436
23660
|
}
|
|
23437
|
-
#finishSettledTurn(
|
|
23438
|
-
if (this.#activeTurn !==
|
|
23661
|
+
#finishSettledTurn(active2) {
|
|
23662
|
+
if (this.#activeTurn !== active2 || active2.settlement !== "confirmed" || active2.cancellation === "requesting") {
|
|
23439
23663
|
return;
|
|
23440
23664
|
}
|
|
23441
|
-
if (
|
|
23442
|
-
clearTimeout(
|
|
23443
|
-
|
|
23444
|
-
this.#closeInteractions(
|
|
23445
|
-
if (
|
|
23665
|
+
if (active2.cancellationTimeout)
|
|
23666
|
+
clearTimeout(active2.cancellationTimeout);
|
|
23667
|
+
active2.cancellationTimeout = null;
|
|
23668
|
+
this.#closeInteractions(active2, active2.cancellation === "accepted" ? "cancelled" : "superseded");
|
|
23669
|
+
if (active2.tools.size > 0) {
|
|
23446
23670
|
this.#fail(new PiRpcFaultError("protocolError", "Pi RPC settled with active Tool executions"));
|
|
23447
23671
|
return;
|
|
23448
23672
|
}
|
|
23449
23673
|
this.#activeTurn = null;
|
|
23450
|
-
if (
|
|
23451
|
-
if (
|
|
23452
|
-
this.#emitAutonomousTurn(
|
|
23674
|
+
if (active2.origin === "autonomous") {
|
|
23675
|
+
if (active2.cancellation === "accepted") {
|
|
23676
|
+
this.#emitAutonomousTurn(active2, {
|
|
23453
23677
|
status: "cancelled",
|
|
23454
|
-
text:
|
|
23678
|
+
text: active2.text,
|
|
23455
23679
|
reason: "Cancelled by user"
|
|
23456
23680
|
});
|
|
23457
|
-
} else if (
|
|
23458
|
-
this.#emitAutonomousTurn(
|
|
23681
|
+
} else if (active2.failure) {
|
|
23682
|
+
this.#emitAutonomousTurn(active2, active2.nativeCancellationObserved ? {
|
|
23459
23683
|
status: "cancelled",
|
|
23460
|
-
text:
|
|
23684
|
+
text: active2.text,
|
|
23461
23685
|
reason: "Pi autonomous Assistant was aborted"
|
|
23462
|
-
} : { status: "failed", text:
|
|
23463
|
-
} else if (
|
|
23464
|
-
this.#emitAutonomousTurn(
|
|
23686
|
+
} : { status: "failed", text: active2.text, error: active2.failure });
|
|
23687
|
+
} else if (active2.text.trim().length === 0 && !active2.sawTool) {
|
|
23688
|
+
this.#emitAutonomousTurn(active2, {
|
|
23465
23689
|
status: "failed",
|
|
23466
|
-
text:
|
|
23690
|
+
text: active2.text,
|
|
23467
23691
|
error: new Error("Pi RPC autonomous Turn settled without displayable output")
|
|
23468
23692
|
});
|
|
23469
23693
|
} else {
|
|
23470
|
-
this.#emitAutonomousTurn(
|
|
23694
|
+
this.#emitAutonomousTurn(active2, { status: "succeeded", text: active2.text });
|
|
23471
23695
|
}
|
|
23472
23696
|
this.#drainDeferredRunFrames();
|
|
23473
23697
|
return;
|
|
23474
23698
|
}
|
|
23475
|
-
if (
|
|
23476
|
-
|
|
23477
|
-
} else if (
|
|
23478
|
-
|
|
23479
|
-
} else if (
|
|
23480
|
-
|
|
23699
|
+
if (active2.cancellation === "accepted") {
|
|
23700
|
+
active2.resolve({ text: active2.text, cancelled: true });
|
|
23701
|
+
} else if (active2.failure) {
|
|
23702
|
+
active2.reject(active2.failure);
|
|
23703
|
+
} else if (active2.text.trim().length === 0 && !active2.sawTool) {
|
|
23704
|
+
active2.reject(new Error("Pi RPC settled without displayable output"));
|
|
23481
23705
|
} else {
|
|
23482
|
-
|
|
23706
|
+
active2.resolve({ text: active2.text, cancelled: false });
|
|
23483
23707
|
}
|
|
23484
23708
|
this.#drainDeferredRunFrames();
|
|
23485
23709
|
}
|
|
23486
|
-
#emitContent(
|
|
23710
|
+
#emitContent(active2, reasoning, delta) {
|
|
23487
23711
|
if (delta.length === 0)
|
|
23488
23712
|
return;
|
|
23489
|
-
const messageId =
|
|
23713
|
+
const messageId = active2.assistantMessageId;
|
|
23490
23714
|
if (messageId === null)
|
|
23491
23715
|
throw new Error("Pi content arrived outside an Assistant message");
|
|
23492
23716
|
if (reasoning) {
|
|
23493
|
-
|
|
23494
|
-
|
|
23717
|
+
active2.reasoningMessageOpen = true;
|
|
23718
|
+
active2.sawStreamedMessageReasoning = true;
|
|
23495
23719
|
} else {
|
|
23496
|
-
|
|
23497
|
-
|
|
23720
|
+
active2.text += delta;
|
|
23721
|
+
active2.sawStreamedMessageText = true;
|
|
23498
23722
|
}
|
|
23499
|
-
|
|
23723
|
+
active2.onEvent({
|
|
23500
23724
|
type: reasoning ? "reasoning.delta" : "text.delta",
|
|
23501
23725
|
messageId,
|
|
23502
|
-
...nativeMessageIdentity(
|
|
23726
|
+
...nativeMessageIdentity(active2),
|
|
23503
23727
|
delta
|
|
23504
23728
|
});
|
|
23505
23729
|
}
|
|
23506
|
-
#startAssistantMessage(
|
|
23507
|
-
if (
|
|
23508
|
-
|
|
23509
|
-
if (
|
|
23510
|
-
|
|
23730
|
+
#startAssistantMessage(active2, value) {
|
|
23731
|
+
if (active2.origin === "autonomous" && !active2.autonomousMessage && isRecord9(value))
|
|
23732
|
+
active2.autonomousMessage = value;
|
|
23733
|
+
if (active2.assistantMessageId !== null && active2.reasoningMessageOpen) {
|
|
23734
|
+
active2.onEvent({ type: "reasoning.completed", messageId: active2.assistantMessageId });
|
|
23511
23735
|
}
|
|
23512
23736
|
const nativeResponseId = assistantMessageId(value);
|
|
23513
23737
|
const messageId = nativeResponseId ?? randomUUID6();
|
|
23514
|
-
|
|
23515
|
-
|
|
23516
|
-
|
|
23517
|
-
|
|
23518
|
-
|
|
23519
|
-
|
|
23520
|
-
|
|
23738
|
+
active2.assistantMessageId = messageId;
|
|
23739
|
+
active2.assistantNativeMessageIdentity = piMessageIdentity(this.state.sessionId, value, this.#messageTimestampCounts);
|
|
23740
|
+
active2.textStream = new PiContentStream("text");
|
|
23741
|
+
active2.reasoningStream = new PiContentStream("reasoning");
|
|
23742
|
+
active2.sawStreamedMessageText = false;
|
|
23743
|
+
active2.sawStreamedMessageReasoning = false;
|
|
23744
|
+
active2.reasoningMessageOpen = false;
|
|
23521
23745
|
return messageId;
|
|
23522
23746
|
}
|
|
23523
|
-
#ensureAssistantMessage(
|
|
23524
|
-
if (
|
|
23525
|
-
return this.#startAssistantMessage(
|
|
23526
|
-
if (!
|
|
23747
|
+
#ensureAssistantMessage(active2, value) {
|
|
23748
|
+
if (active2.assistantMessageId === null)
|
|
23749
|
+
return this.#startAssistantMessage(active2, value);
|
|
23750
|
+
if (!active2.sawStreamedMessageText && !active2.sawStreamedMessageReasoning) {
|
|
23527
23751
|
const nativeResponseId = assistantMessageId(value);
|
|
23528
23752
|
if (nativeResponseId) {
|
|
23529
|
-
|
|
23530
|
-
|
|
23753
|
+
active2.assistantMessageId = nativeResponseId;
|
|
23754
|
+
active2.assistantNativeMessageIdentity ??= { responseId: nativeResponseId };
|
|
23531
23755
|
}
|
|
23532
23756
|
}
|
|
23533
|
-
return
|
|
23757
|
+
return active2.assistantMessageId;
|
|
23534
23758
|
}
|
|
23535
|
-
#finalizeAssistantMessage(
|
|
23759
|
+
#finalizeAssistantMessage(active2, value) {
|
|
23536
23760
|
const finalText = assistantText(value);
|
|
23537
23761
|
const finalReasoning = assistantReasoning(value);
|
|
23538
23762
|
const failure = assistantFailure(value);
|
|
23539
23763
|
const cacheHitRatePercent = optionalPiCacheHitRatePercent(value);
|
|
23540
23764
|
if (finalText === null || finalReasoning === null || failure === void 0)
|
|
23541
23765
|
return;
|
|
23542
|
-
if (
|
|
23766
|
+
if (active2.assistantMessageId === null && finalText === active2.lastFinalizedMessageText && finalReasoning === active2.lastFinalizedMessageReasoning && !active2.sawStreamedMessageText && !active2.sawStreamedMessageReasoning) {
|
|
23543
23767
|
return;
|
|
23544
23768
|
}
|
|
23545
|
-
|
|
23546
|
-
if (
|
|
23547
|
-
|
|
23769
|
+
active2.failure = failure;
|
|
23770
|
+
if (active2.origin === "autonomous" && piAssistantWasAborted(value)) {
|
|
23771
|
+
active2.nativeCancellationObserved = true;
|
|
23548
23772
|
}
|
|
23549
23773
|
this.#latestCacheHitRatePercent = cacheHitRatePercent;
|
|
23550
|
-
const messageId = this.#ensureAssistantMessage(
|
|
23774
|
+
const messageId = this.#ensureAssistantMessage(active2, value);
|
|
23551
23775
|
const content = value.content;
|
|
23552
|
-
if (failure === null || !
|
|
23553
|
-
this.#emitContent(
|
|
23776
|
+
if (failure === null || !active2.sawStreamedMessageReasoning) {
|
|
23777
|
+
this.#emitContent(active2, true, active2.reasoningStream.finalize(content.flatMap((part, index) => {
|
|
23554
23778
|
const text4 = extractReasoningText(part);
|
|
23555
23779
|
return text4 === null ? [] : [{ index, text: text4 }];
|
|
23556
23780
|
})));
|
|
23557
23781
|
}
|
|
23558
|
-
if (
|
|
23559
|
-
|
|
23782
|
+
if (active2.reasoningMessageOpen && active2.failure === null) {
|
|
23783
|
+
active2.onEvent({ type: "reasoning.completed", messageId });
|
|
23560
23784
|
}
|
|
23561
|
-
if (failure === null || !
|
|
23562
|
-
this.#emitContent(
|
|
23785
|
+
if (failure === null || !active2.sawStreamedMessageText) {
|
|
23786
|
+
this.#emitContent(active2, false, active2.textStream.finalize(content.flatMap((part, index) => isRecord9(part) && part.type === "text" && typeof part.text === "string" ? [{ index, text: part.text }] : [])));
|
|
23563
23787
|
}
|
|
23564
|
-
|
|
23565
|
-
|
|
23566
|
-
|
|
23567
|
-
|
|
23568
|
-
|
|
23569
|
-
|
|
23570
|
-
|
|
23788
|
+
active2.assistantMessageId = null;
|
|
23789
|
+
active2.assistantNativeMessageIdentity = void 0;
|
|
23790
|
+
active2.sawStreamedMessageText = false;
|
|
23791
|
+
active2.sawStreamedMessageReasoning = false;
|
|
23792
|
+
active2.reasoningMessageOpen = false;
|
|
23793
|
+
active2.lastFinalizedMessageText = finalText;
|
|
23794
|
+
active2.lastFinalizedMessageReasoning = finalReasoning;
|
|
23571
23795
|
const phase = piAssistantPhase(value);
|
|
23572
|
-
|
|
23796
|
+
active2.onEvent({ type: "message.completed", messageId, ...phase ? { phase } : {} });
|
|
23573
23797
|
}
|
|
23574
23798
|
#write(value) {
|
|
23575
23799
|
const child = this.#child;
|
|
@@ -23587,7 +23811,7 @@ var PiRpcSession = class {
|
|
|
23587
23811
|
if (!child?.stdin.writable || this.#closed || this.#failed) {
|
|
23588
23812
|
return Promise.reject(new Error("Pi RPC stdin is unavailable"));
|
|
23589
23813
|
}
|
|
23590
|
-
const
|
|
23814
|
+
const id2 = `codexhost-${randomUUID6()}`;
|
|
23591
23815
|
return new Promise((resolve, reject) => {
|
|
23592
23816
|
const pending = {
|
|
23593
23817
|
command: type,
|
|
@@ -23598,33 +23822,33 @@ var PiRpcSession = class {
|
|
|
23598
23822
|
reject,
|
|
23599
23823
|
timeout: null
|
|
23600
23824
|
};
|
|
23601
|
-
this.#pending.set(
|
|
23602
|
-
this.#armCommandTimeout(
|
|
23603
|
-
const frame = Buffer.from(`${JSON.stringify({ id, type, ...payload })}
|
|
23825
|
+
this.#pending.set(id2, pending);
|
|
23826
|
+
this.#armCommandTimeout(id2, pending);
|
|
23827
|
+
const frame = Buffer.from(`${JSON.stringify({ id: id2, type, ...payload })}
|
|
23604
23828
|
`, "utf8");
|
|
23605
23829
|
child.stdin.write(frame, (error51) => {
|
|
23606
23830
|
if (error51) {
|
|
23607
23831
|
if (pending.timeout)
|
|
23608
23832
|
clearTimeout(pending.timeout);
|
|
23609
|
-
this.#pending.delete(
|
|
23833
|
+
this.#pending.delete(id2);
|
|
23610
23834
|
reject(error51);
|
|
23611
23835
|
}
|
|
23612
23836
|
});
|
|
23613
23837
|
});
|
|
23614
23838
|
}
|
|
23615
|
-
#armCommandTimeout(
|
|
23616
|
-
if (pending.timeout || this.#pending.get(
|
|
23839
|
+
#armCommandTimeout(id2, pending) {
|
|
23840
|
+
if (pending.timeout || this.#pending.get(id2) !== pending || (pending.command === "prompt" || pending.command === "compact") && this.#compactionActive) {
|
|
23617
23841
|
return;
|
|
23618
23842
|
}
|
|
23619
23843
|
pending.timeout = setTimeout(() => {
|
|
23620
|
-
if (this.#pending.get(
|
|
23844
|
+
if (this.#pending.get(id2) !== pending)
|
|
23621
23845
|
return;
|
|
23622
23846
|
pending.timeout = null;
|
|
23623
23847
|
const error51 = new Error(`Pi RPC '${pending.command}' command timed out`);
|
|
23624
23848
|
if (pending.command !== "prompt") {
|
|
23625
|
-
this.#pending.delete(
|
|
23849
|
+
this.#pending.delete(id2);
|
|
23626
23850
|
if (READ_ONLY_COMMANDS.has(pending.command)) {
|
|
23627
|
-
this.#expired.add(
|
|
23851
|
+
this.#expired.add(id2);
|
|
23628
23852
|
if (this.#expired.size > MAX_EXPIRED_IDS) {
|
|
23629
23853
|
this.#expired.delete(this.#expired.values().next().value);
|
|
23630
23854
|
}
|
|
@@ -23655,12 +23879,12 @@ var PiRpcSession = class {
|
|
|
23655
23879
|
this.#rejectAll(finalFault);
|
|
23656
23880
|
this.#options.onFault?.(finalFault);
|
|
23657
23881
|
}
|
|
23658
|
-
#closeInteractions(
|
|
23659
|
-
for (const [requestId, pending] of
|
|
23660
|
-
|
|
23882
|
+
#closeInteractions(active2, reason) {
|
|
23883
|
+
for (const [requestId, pending] of active2.interactions) {
|
|
23884
|
+
active2.interactions.delete(requestId);
|
|
23661
23885
|
if (pending.timeout)
|
|
23662
23886
|
clearTimeout(pending.timeout);
|
|
23663
|
-
|
|
23887
|
+
active2.onEvent({
|
|
23664
23888
|
type: "interaction.closed",
|
|
23665
23889
|
requestId,
|
|
23666
23890
|
reason
|
|
@@ -23668,17 +23892,17 @@ var PiRpcSession = class {
|
|
|
23668
23892
|
}
|
|
23669
23893
|
}
|
|
23670
23894
|
#rejectActiveTurn(error51) {
|
|
23671
|
-
const
|
|
23672
|
-
if (!
|
|
23895
|
+
const active2 = this.#activeTurn;
|
|
23896
|
+
if (!active2)
|
|
23673
23897
|
return;
|
|
23674
|
-
if (
|
|
23675
|
-
clearTimeout(
|
|
23676
|
-
this.#closeInteractions(
|
|
23898
|
+
if (active2.cancellationTimeout)
|
|
23899
|
+
clearTimeout(active2.cancellationTimeout);
|
|
23900
|
+
this.#closeInteractions(active2, "cancelled");
|
|
23677
23901
|
this.#activeTurn = null;
|
|
23678
|
-
if (
|
|
23679
|
-
this.#emitAutonomousTurn(
|
|
23902
|
+
if (active2.origin === "autonomous") {
|
|
23903
|
+
this.#emitAutonomousTurn(active2, { status: "failed", text: active2.text, error: error51 });
|
|
23680
23904
|
} else {
|
|
23681
|
-
|
|
23905
|
+
active2.reject(error51);
|
|
23682
23906
|
}
|
|
23683
23907
|
this.#drainDeferredRunFrames();
|
|
23684
23908
|
}
|
|
@@ -23779,12 +24003,16 @@ function nativeModelFromState(state2) {
|
|
|
23779
24003
|
}
|
|
23780
24004
|
return { provider: state2.provider, id: state2.modelId };
|
|
23781
24005
|
}
|
|
23782
|
-
function
|
|
23783
|
-
const
|
|
23784
|
-
return
|
|
24006
|
+
function livePiModelIndex(models, state2) {
|
|
24007
|
+
const current = nativeModelFromState(state2);
|
|
24008
|
+
return createPiModelIndex(current ? [...models, current] : models);
|
|
23785
24009
|
}
|
|
23786
|
-
function
|
|
23787
|
-
|
|
24010
|
+
async function isFastSupported(model2, models, transport) {
|
|
24011
|
+
return models.some((entry) => samePiModel(entry, model2) && supportsPiFastModel(entry)) && await transport.supportsFastMode?.() === true;
|
|
24012
|
+
}
|
|
24013
|
+
function harnessStateFromPi(state2, thinkingLevels, index) {
|
|
24014
|
+
const model2 = nativeModelFromState(state2);
|
|
24015
|
+
const effectiveModel = model2 ? index.ref({ ...model2, ...state2.fast ? { fast: true } : {} }) : void 0;
|
|
23788
24016
|
const availableThinkingOptions = thinkingLevels ? normalizePiThinkingOptions(thinkingLevels) : void 0;
|
|
23789
24017
|
if (availableThinkingOptions && (!state2.thinkingLevel || !thinkingLevels?.includes(state2.thinkingLevel))) {
|
|
23790
24018
|
throw new PiRpcFaultError("protocolError", "Pi effective Thinking level is absent from its available levels");
|
|
@@ -23863,7 +24091,7 @@ var PiHarnessSession = class {
|
|
|
23863
24091
|
#requestedModel;
|
|
23864
24092
|
#requestedThinkingOptionId;
|
|
23865
24093
|
#toolOutputLimit;
|
|
23866
|
-
#
|
|
24094
|
+
#modelIndex;
|
|
23867
24095
|
#acceptingTurn = false;
|
|
23868
24096
|
#active = null;
|
|
23869
24097
|
#closePromise = null;
|
|
@@ -23887,7 +24115,6 @@ var PiHarnessSession = class {
|
|
|
23887
24115
|
this.#requestedModel = options.model;
|
|
23888
24116
|
this.#requestedThinkingOptionId = options.thinkingOptionId;
|
|
23889
24117
|
this.#toolOutputLimit = options.toolOutputLimit;
|
|
23890
|
-
this.#isFastSupported = options.isFastSupported;
|
|
23891
24118
|
this.capabilities = ((session) => ({
|
|
23892
24119
|
configuration: {
|
|
23893
24120
|
selectModel: true,
|
|
@@ -23908,7 +24135,8 @@ var PiHarnessSession = class {
|
|
|
23908
24135
|
execute: (command) => this.#executeHarnessCommand(command)
|
|
23909
24136
|
};
|
|
23910
24137
|
this.#transport = options.startedTransport ?? null;
|
|
23911
|
-
this
|
|
24138
|
+
this.#modelIndex = this.#transport ? livePiModelIndex(options.startedModels ?? [], this.#transport.state) : createPiModelIndex([]);
|
|
24139
|
+
this.initialState = this.#transport ? harnessStateFromPi(this.#transport.state, options.startedThinkingLevels ?? null, this.#modelIndex) : {};
|
|
23912
24140
|
this.initialUsage = options.initialUsage ?? null;
|
|
23913
24141
|
this.#usage = this.initialUsage;
|
|
23914
24142
|
this.#state = this.initialState;
|
|
@@ -23920,8 +24148,8 @@ var PiHarnessSession = class {
|
|
|
23920
24148
|
if (this.#transport)
|
|
23921
24149
|
this.#bindAutonomousTurnHandler(this.#transport);
|
|
23922
24150
|
}
|
|
23923
|
-
ownsNativeSession(
|
|
23924
|
-
return this.#transport?.state.sessionId ===
|
|
24151
|
+
ownsNativeSession(id2) {
|
|
24152
|
+
return this.#transport?.state.sessionId === id2;
|
|
23925
24153
|
}
|
|
23926
24154
|
async readSubagentHistory(cwd) {
|
|
23927
24155
|
if (this.#phase !== "open" || path17.resolve(cwd) !== path17.resolve(this.#cwd)) {
|
|
@@ -23929,28 +24157,28 @@ var PiHarnessSession = class {
|
|
|
23929
24157
|
}
|
|
23930
24158
|
return (await this.#ensureTransport()).getEntries();
|
|
23931
24159
|
}
|
|
23932
|
-
async readGotgenesChild(
|
|
24160
|
+
async readGotgenesChild(id2, cwd) {
|
|
23933
24161
|
const history = await this.readSubagentHistory(cwd);
|
|
23934
24162
|
const transport = this.#transport;
|
|
23935
24163
|
if (!transport)
|
|
23936
24164
|
throw new Error("Pi parent Session is closed");
|
|
23937
|
-
return readGotgenesChild(history, transport.state.sessionId,
|
|
24165
|
+
return readGotgenesChild(history, transport.state.sessionId, id2, this.#subagents.gotgenes.records.get(id2));
|
|
23938
24166
|
}
|
|
23939
|
-
async inspectSubagent(
|
|
24167
|
+
async inspectSubagent(id2, cwd) {
|
|
23940
24168
|
if (this.#phase !== "open" || path17.resolve(cwd) !== path17.resolve(this.#cwd)) {
|
|
23941
24169
|
throw new Error("Pi Subagent parent workspace or Session is unavailable");
|
|
23942
24170
|
}
|
|
23943
24171
|
const transport = await this.#ensureTransport();
|
|
23944
24172
|
if (!transport.inspectSubagent)
|
|
23945
24173
|
throw new Error("Pi transport does not support Subagent inspection");
|
|
23946
|
-
return transport.inspectSubagent(
|
|
24174
|
+
return transport.inspectSubagent(id2);
|
|
23947
24175
|
}
|
|
23948
24176
|
handleTransportFault(error51) {
|
|
23949
24177
|
queueMicrotask(() => this.#fault(error51));
|
|
23950
24178
|
}
|
|
23951
24179
|
#subagentConfiguration() {
|
|
23952
24180
|
const state2 = this.#state;
|
|
23953
|
-
const model2 =
|
|
24181
|
+
const model2 = this.#transport?.state.modelId;
|
|
23954
24182
|
return {
|
|
23955
24183
|
...model2 ? { model: model2 } : {},
|
|
23956
24184
|
...state2.effectiveThinkingOptionId ? { reasoningEffort: state2.effectiveThinkingOptionId } : {}
|
|
@@ -23985,6 +24213,7 @@ var PiHarnessSession = class {
|
|
|
23985
24213
|
...mapPiSnapshot(history, {
|
|
23986
24214
|
sessionId: transport.state.sessionId,
|
|
23987
24215
|
model: nativeModelForHistory(transport.state),
|
|
24216
|
+
models: this.#modelIndex.models,
|
|
23988
24217
|
cwd: this.#cwd
|
|
23989
24218
|
}, this.#subagents),
|
|
23990
24219
|
state: this.#state
|
|
@@ -24071,7 +24300,7 @@ var PiHarnessSession = class {
|
|
|
24071
24300
|
itemId: this.#newItemId(),
|
|
24072
24301
|
text: ""
|
|
24073
24302
|
};
|
|
24074
|
-
const
|
|
24303
|
+
const active2 = {
|
|
24075
24304
|
command,
|
|
24076
24305
|
agentItem: item,
|
|
24077
24306
|
agentMessageId: null,
|
|
@@ -24091,14 +24320,14 @@ var PiHarnessSession = class {
|
|
|
24091
24320
|
completion,
|
|
24092
24321
|
resolveCompletion
|
|
24093
24322
|
};
|
|
24094
|
-
this.#active =
|
|
24323
|
+
this.#active = active2;
|
|
24095
24324
|
this.#event({ type: "turn.started", turnId: command.turnId });
|
|
24096
24325
|
this.#event({ type: "item.started", turnId: command.turnId, item });
|
|
24097
|
-
void transport.runTurn(text4, (event) => this.#handleTurnEvent(
|
|
24098
|
-
|
|
24326
|
+
void transport.runTurn(text4, (event) => this.#handleTurnEvent(active2, event)).then(async (result) => {
|
|
24327
|
+
active2.settling = true;
|
|
24099
24328
|
try {
|
|
24100
|
-
const identity2 = await this.#completedTurnIdentity(
|
|
24101
|
-
this.#completeTurn(
|
|
24329
|
+
const identity2 = await this.#completedTurnIdentity(active2, transport);
|
|
24330
|
+
this.#completeTurn(active2, result.cancelled ? {
|
|
24102
24331
|
status: "cancelled",
|
|
24103
24332
|
reason: "Cancelled by user",
|
|
24104
24333
|
...identity2.checkpoint ? { checkpoint: identity2.checkpoint } : {}
|
|
@@ -24107,19 +24336,19 @@ var PiHarnessSession = class {
|
|
|
24107
24336
|
...identity2.checkpoint ? { checkpoint: identity2.checkpoint } : {}
|
|
24108
24337
|
}, result.text, identity2.nativeTurnRef);
|
|
24109
24338
|
} catch (error51) {
|
|
24110
|
-
this.#completeTurn(
|
|
24339
|
+
this.#completeTurn(active2, {
|
|
24111
24340
|
status: "failed",
|
|
24112
24341
|
error: normalizedError(error51, "protocolError")
|
|
24113
24342
|
});
|
|
24114
24343
|
}
|
|
24115
24344
|
}).catch(async (error51) => {
|
|
24116
|
-
|
|
24345
|
+
active2.settling = true;
|
|
24117
24346
|
let identity2;
|
|
24118
24347
|
try {
|
|
24119
|
-
identity2 = await this.#completedTurnIdentity(
|
|
24348
|
+
identity2 = await this.#completedTurnIdentity(active2, transport);
|
|
24120
24349
|
} catch {
|
|
24121
24350
|
}
|
|
24122
|
-
this.#completeTurn(
|
|
24351
|
+
this.#completeTurn(active2, active2.cancellationRequested ? {
|
|
24123
24352
|
status: "cancelled",
|
|
24124
24353
|
reason: "Cancelled by user",
|
|
24125
24354
|
...identity2?.checkpoint ? { checkpoint: identity2.checkpoint } : {}
|
|
@@ -24143,9 +24372,9 @@ var PiHarnessSession = class {
|
|
|
24143
24372
|
return this.#closePromise;
|
|
24144
24373
|
}
|
|
24145
24374
|
async #respond(command) {
|
|
24146
|
-
const
|
|
24147
|
-
const pending =
|
|
24148
|
-
if (!
|
|
24375
|
+
const active2 = this.#active;
|
|
24376
|
+
const pending = active2?.interactions.get(command.interactionId);
|
|
24377
|
+
if (!active2 || !pending) {
|
|
24149
24378
|
return {
|
|
24150
24379
|
ok: false,
|
|
24151
24380
|
error: invalidState("Pi Interaction Response must reference a pending Question")
|
|
@@ -24220,9 +24449,12 @@ var PiHarnessSession = class {
|
|
|
24220
24449
|
try {
|
|
24221
24450
|
let requested;
|
|
24222
24451
|
try {
|
|
24223
|
-
|
|
24224
|
-
|
|
24452
|
+
const models = await transport.getAvailableModels();
|
|
24453
|
+
const index = livePiModelIndex(models, transport.state);
|
|
24454
|
+
requested = resolvePiModelRef(harnessModelRefSchema.parse(command.model), index);
|
|
24455
|
+
if (requested.fast && !await isFastSupported(requested, models, transport))
|
|
24225
24456
|
throw new Error("Fast is unavailable for this Pi Model");
|
|
24457
|
+
this.#modelIndex = index;
|
|
24226
24458
|
} catch (error51) {
|
|
24227
24459
|
return { ok: false, error: normalizedError(error51, "invalidRequest") };
|
|
24228
24460
|
}
|
|
@@ -24243,8 +24475,7 @@ var PiHarnessSession = class {
|
|
|
24243
24475
|
return { ok: false, error: normalizedError(error51, "nativeFailure") };
|
|
24244
24476
|
}
|
|
24245
24477
|
const actual = nativeModelFromState(state2);
|
|
24246
|
-
|
|
24247
|
-
if (previousModel?.id !== nextModel?.id) {
|
|
24478
|
+
if (!sameHarnessModelRef(previousModel, this.#state.effectiveModel)) {
|
|
24248
24479
|
this.#invalidateUsage();
|
|
24249
24480
|
void this.#refreshUsage();
|
|
24250
24481
|
}
|
|
@@ -24342,8 +24573,8 @@ var PiHarnessSession = class {
|
|
|
24342
24573
|
}
|
|
24343
24574
|
}
|
|
24344
24575
|
#canSteerActiveTurn() {
|
|
24345
|
-
const
|
|
24346
|
-
return Boolean(this.#phase === "open" &&
|
|
24576
|
+
const active2 = this.#active;
|
|
24577
|
+
return Boolean(this.#phase === "open" && active2 && !active2.cancellationRequested && active2.acceptingSteers && active2.tools.size > 0 && this.#transport);
|
|
24347
24578
|
}
|
|
24348
24579
|
async #steer(command) {
|
|
24349
24580
|
const text4 = command.input.map((input) => input.text).join("\n");
|
|
@@ -24357,17 +24588,17 @@ var PiHarnessSession = class {
|
|
|
24357
24588
|
}
|
|
24358
24589
|
};
|
|
24359
24590
|
}
|
|
24360
|
-
const
|
|
24591
|
+
const active2 = this.#active;
|
|
24361
24592
|
const transport = this.#transport;
|
|
24362
|
-
if (!
|
|
24593
|
+
if (!active2 || !transport || active2.command.turnId !== command.turnId || !this.#canSteerActiveTurn()) {
|
|
24363
24594
|
return { ok: false, error: invalidState("Pi Turn is not accepting native input") };
|
|
24364
24595
|
}
|
|
24365
24596
|
let accepted;
|
|
24366
24597
|
try {
|
|
24367
24598
|
accepted = transport.steer(text4).then(() => {
|
|
24368
|
-
|
|
24599
|
+
active2.acceptedSteerCount += 1;
|
|
24369
24600
|
});
|
|
24370
|
-
|
|
24601
|
+
active2.pendingSteers.add(accepted);
|
|
24371
24602
|
await accepted;
|
|
24372
24603
|
return { ok: true, value: { accepted: true } };
|
|
24373
24604
|
} catch (error51) {
|
|
@@ -24375,40 +24606,40 @@ var PiHarnessSession = class {
|
|
|
24375
24606
|
return { ok: false, error: invalidState(error51.message) };
|
|
24376
24607
|
}
|
|
24377
24608
|
if (error51 instanceof PiRpcSteerTargetEndedError)
|
|
24378
|
-
|
|
24609
|
+
active2.steerFailure = error51;
|
|
24379
24610
|
throw error51;
|
|
24380
24611
|
} finally {
|
|
24381
24612
|
if (accepted)
|
|
24382
|
-
|
|
24613
|
+
active2.pendingSteers.delete(accepted);
|
|
24383
24614
|
}
|
|
24384
24615
|
}
|
|
24385
24616
|
async #cancel(command) {
|
|
24386
|
-
const
|
|
24387
|
-
if (!
|
|
24617
|
+
const active2 = this.#active;
|
|
24618
|
+
if (!active2 || active2.command.turnId !== command.turnId) {
|
|
24388
24619
|
return {
|
|
24389
24620
|
ok: false,
|
|
24390
24621
|
error: invalidState("Pi Turn Cancel must reference the active Turn")
|
|
24391
24622
|
};
|
|
24392
24623
|
}
|
|
24393
|
-
if (
|
|
24624
|
+
if (active2.settling) {
|
|
24394
24625
|
return {
|
|
24395
24626
|
ok: false,
|
|
24396
24627
|
error: invalidState("Pi Turn has finished native execution and is recording its completion")
|
|
24397
24628
|
};
|
|
24398
24629
|
}
|
|
24399
|
-
if (
|
|
24630
|
+
if (active2.cancellationRequested) {
|
|
24400
24631
|
return { ok: true, value: { cancellationRequested: true } };
|
|
24401
24632
|
}
|
|
24402
24633
|
const transport = this.#transport;
|
|
24403
24634
|
if (!transport)
|
|
24404
24635
|
return { ok: false, error: invalidState("Pi transport is unavailable") };
|
|
24405
|
-
|
|
24636
|
+
active2.cancellationRequested = true;
|
|
24406
24637
|
try {
|
|
24407
24638
|
await transport.abort();
|
|
24408
24639
|
return { ok: true, value: { cancellationRequested: true } };
|
|
24409
24640
|
} catch (error51) {
|
|
24410
24641
|
const normalized = normalizedError(error51, "nativeFailure");
|
|
24411
|
-
if (this.#active ===
|
|
24642
|
+
if (this.#active === active2) {
|
|
24412
24643
|
this.#fault(new PiAdapterFaultError(normalized));
|
|
24413
24644
|
void transport.close().catch(() => void 0);
|
|
24414
24645
|
}
|
|
@@ -24499,7 +24730,7 @@ var PiHarnessSession = class {
|
|
|
24499
24730
|
const completion = new Promise((resolve) => {
|
|
24500
24731
|
resolveCompletion = resolve;
|
|
24501
24732
|
});
|
|
24502
|
-
const
|
|
24733
|
+
const active2 = {
|
|
24503
24734
|
command: turnCommand,
|
|
24504
24735
|
agentItem: null,
|
|
24505
24736
|
agentMessageId: null,
|
|
@@ -24519,18 +24750,18 @@ var PiHarnessSession = class {
|
|
|
24519
24750
|
completion,
|
|
24520
24751
|
resolveCompletion
|
|
24521
24752
|
};
|
|
24522
|
-
this.#active =
|
|
24753
|
+
this.#active = active2;
|
|
24523
24754
|
this.#event({ type: "turn.started", turnId: command.turnId });
|
|
24524
|
-
void transport.compact(customInstructions, (event) => this.#handleTurnEvent(
|
|
24755
|
+
void transport.compact(customInstructions, (event) => this.#handleTurnEvent(active2, event)).then((result) => {
|
|
24525
24756
|
if (result.outcome === "succeeded") {
|
|
24526
|
-
this.#completeTurn(
|
|
24757
|
+
this.#completeTurn(active2, { status: "succeeded" });
|
|
24527
24758
|
} else if (result.outcome === "cancelled") {
|
|
24528
|
-
this.#completeTurn(
|
|
24759
|
+
this.#completeTurn(active2, {
|
|
24529
24760
|
status: "cancelled",
|
|
24530
24761
|
reason: "Context compaction was cancelled"
|
|
24531
24762
|
});
|
|
24532
24763
|
} else {
|
|
24533
|
-
this.#completeTurn(
|
|
24764
|
+
this.#completeTurn(active2, {
|
|
24534
24765
|
status: "failed",
|
|
24535
24766
|
error: {
|
|
24536
24767
|
code: "nativeFailure",
|
|
@@ -24540,7 +24771,7 @@ var PiHarnessSession = class {
|
|
|
24540
24771
|
});
|
|
24541
24772
|
}
|
|
24542
24773
|
}).catch((error51) => {
|
|
24543
|
-
this.#completeTurn(
|
|
24774
|
+
this.#completeTurn(active2, {
|
|
24544
24775
|
status: "failed",
|
|
24545
24776
|
error: normalizedError(error51, "nativeFailure")
|
|
24546
24777
|
});
|
|
@@ -24566,9 +24797,14 @@ var PiHarnessSession = class {
|
|
|
24566
24797
|
if (this.#phase !== "open")
|
|
24567
24798
|
throw new Error("Pi Session closed during startup");
|
|
24568
24799
|
let state2 = transport.state;
|
|
24800
|
+
const models = await transport.getAvailableModels();
|
|
24801
|
+
this.#modelIndex = livePiModelIndex(models, state2);
|
|
24569
24802
|
let thinkingLevels = await transport.getAvailableThinkingLevels();
|
|
24570
24803
|
if (this.#requestedModel) {
|
|
24571
|
-
const requested =
|
|
24804
|
+
const requested = resolvePiModelRef(this.#requestedModel, this.#modelIndex);
|
|
24805
|
+
if (requested.fast && !await isFastSupported(requested, models, transport)) {
|
|
24806
|
+
throw new Error("Fast is unavailable for this Pi Model");
|
|
24807
|
+
}
|
|
24572
24808
|
const current = nativeModelFromState(state2);
|
|
24573
24809
|
if (!samePiModel(current, requested))
|
|
24574
24810
|
state2 = await transport.selectModel(requested);
|
|
@@ -24578,8 +24814,8 @@ var PiHarnessSession = class {
|
|
|
24578
24814
|
throw new Error("Pi did not activate the requested create Model");
|
|
24579
24815
|
}
|
|
24580
24816
|
if (requested.fast) {
|
|
24581
|
-
if (!
|
|
24582
|
-
throw new Error("Fast is unavailable
|
|
24817
|
+
if (!transport.selectFastMode)
|
|
24818
|
+
throw new Error("Pi Fast extension is unavailable");
|
|
24583
24819
|
state2 = await transport.selectFastMode(true);
|
|
24584
24820
|
}
|
|
24585
24821
|
}
|
|
@@ -24707,8 +24943,8 @@ var PiHarnessSession = class {
|
|
|
24707
24943
|
this.#startAutonomousHostTurn(update.runId);
|
|
24708
24944
|
return;
|
|
24709
24945
|
}
|
|
24710
|
-
const
|
|
24711
|
-
if (!
|
|
24946
|
+
const active2 = this.#active;
|
|
24947
|
+
if (!active2 || active2.autonomousRunId !== update.runId || update.type === "started") {
|
|
24712
24948
|
this.#fault(new PiAdapterFaultError({
|
|
24713
24949
|
code: "protocolError",
|
|
24714
24950
|
message: "Pi autonomous event has no matching active run",
|
|
@@ -24717,10 +24953,10 @@ var PiHarnessSession = class {
|
|
|
24717
24953
|
return;
|
|
24718
24954
|
}
|
|
24719
24955
|
if (update.type === "event")
|
|
24720
|
-
this.#handleTurnEvent(
|
|
24956
|
+
this.#handleTurnEvent(active2, update.event);
|
|
24721
24957
|
else {
|
|
24722
|
-
|
|
24723
|
-
this.#finishAutonomousHostTurn(transport,
|
|
24958
|
+
active2.settling = true;
|
|
24959
|
+
this.#finishAutonomousHostTurn(transport, active2, update.turn);
|
|
24724
24960
|
}
|
|
24725
24961
|
}
|
|
24726
24962
|
#handleAutonomousTurn(transport, turn) {
|
|
@@ -24753,8 +24989,8 @@ var PiHarnessSession = class {
|
|
|
24753
24989
|
this.#pendingAutonomousTurns.push({ transport, turn });
|
|
24754
24990
|
return;
|
|
24755
24991
|
}
|
|
24756
|
-
const
|
|
24757
|
-
this.#finishAutonomousHostTurn(transport,
|
|
24992
|
+
const active2 = this.#startAutonomousHostTurn();
|
|
24993
|
+
this.#finishAutonomousHostTurn(transport, active2, turn);
|
|
24758
24994
|
}
|
|
24759
24995
|
#startAutonomousHostTurn(runId) {
|
|
24760
24996
|
const turnId = hostTurnIdSchema.parse(randomUUID7());
|
|
@@ -24767,7 +25003,7 @@ var PiHarnessSession = class {
|
|
|
24767
25003
|
itemId: this.#newItemId(),
|
|
24768
25004
|
text: ""
|
|
24769
25005
|
};
|
|
24770
|
-
const
|
|
25006
|
+
const active2 = {
|
|
24771
25007
|
command: { type: "turn.start", turnId, input: [] },
|
|
24772
25008
|
...runId ? { autonomousRunId: runId } : {},
|
|
24773
25009
|
agentItem: item,
|
|
@@ -24788,13 +25024,13 @@ var PiHarnessSession = class {
|
|
|
24788
25024
|
completion,
|
|
24789
25025
|
resolveCompletion
|
|
24790
25026
|
};
|
|
24791
|
-
this.#active =
|
|
25027
|
+
this.#active = active2;
|
|
24792
25028
|
this.#event({ type: "turn.autonomous.started", turnId, input: [] });
|
|
24793
25029
|
this.#event({ type: "turn.started", turnId });
|
|
24794
25030
|
this.#event({ type: "item.started", turnId, item });
|
|
24795
|
-
return
|
|
25031
|
+
return active2;
|
|
24796
25032
|
}
|
|
24797
|
-
#finishAutonomousHostTurn(transport,
|
|
25033
|
+
#finishAutonomousHostTurn(transport, active2, turn) {
|
|
24798
25034
|
const nativeTurnRef = turn.nativeTurnKey ? nativeTurnRefSchema.parse({
|
|
24799
25035
|
harnessId: this.harnessId,
|
|
24800
25036
|
nativeSessionId: transport.state.sessionId,
|
|
@@ -24809,19 +25045,19 @@ var PiHarnessSession = class {
|
|
|
24809
25045
|
}) : void 0;
|
|
24810
25046
|
try {
|
|
24811
25047
|
for (const event of turn.events)
|
|
24812
|
-
this.#handleTurnEvent(
|
|
25048
|
+
this.#handleTurnEvent(active2, event);
|
|
24813
25049
|
if (turn.result.status === "succeeded") {
|
|
24814
25050
|
if (!nativeTurnRef)
|
|
24815
25051
|
throw new Error("Pi autonomous Turn has no native identity");
|
|
24816
|
-
this.#completeTurn(
|
|
25052
|
+
this.#completeTurn(active2, { status: "succeeded", ...checkpoint ? { checkpoint } : {} }, turn.result.text, nativeTurnRef);
|
|
24817
25053
|
} else if (turn.result.status === "cancelled") {
|
|
24818
|
-
this.#completeTurn(
|
|
25054
|
+
this.#completeTurn(active2, {
|
|
24819
25055
|
status: "cancelled",
|
|
24820
25056
|
reason: turn.result.reason,
|
|
24821
25057
|
...checkpoint ? { checkpoint } : {}
|
|
24822
25058
|
}, turn.result.text, nativeTurnRef);
|
|
24823
25059
|
} else {
|
|
24824
|
-
this.#completeTurn(
|
|
25060
|
+
this.#completeTurn(active2, {
|
|
24825
25061
|
status: "failed",
|
|
24826
25062
|
error: normalizedError(turn.result.error, "nativeFailure"),
|
|
24827
25063
|
...checkpoint ? { checkpoint } : {}
|
|
@@ -24829,14 +25065,14 @@ var PiHarnessSession = class {
|
|
|
24829
25065
|
}
|
|
24830
25066
|
} catch (error51) {
|
|
24831
25067
|
const normalized = normalizedError(error51, "protocolError");
|
|
24832
|
-
if (this.#active ===
|
|
24833
|
-
this.#completeTurn(
|
|
25068
|
+
if (this.#active === active2) {
|
|
25069
|
+
this.#completeTurn(active2, { status: "failed", error: normalized }, void 0, nativeTurnRef);
|
|
24834
25070
|
}
|
|
24835
25071
|
this.#fault(new PiAdapterFaultError(normalized));
|
|
24836
25072
|
}
|
|
24837
25073
|
}
|
|
24838
25074
|
#publishTransportState(state2, thinkingLevels) {
|
|
24839
|
-
this.#state = harnessStateFromPi(state2, thinkingLevels);
|
|
25075
|
+
this.#state = harnessStateFromPi(state2, thinkingLevels, this.#modelIndex);
|
|
24840
25076
|
this.#event({ type: "session.state.changed", state: this.#state });
|
|
24841
25077
|
}
|
|
24842
25078
|
#invalidateUsage() {
|
|
@@ -24872,80 +25108,80 @@ var PiHarnessSession = class {
|
|
|
24872
25108
|
...observedForTurnId ? { observedForTurnId } : {}
|
|
24873
25109
|
});
|
|
24874
25110
|
}
|
|
24875
|
-
#handleTurnEvent(
|
|
24876
|
-
if (this.#active !==
|
|
25111
|
+
#handleTurnEvent(active2, event) {
|
|
25112
|
+
if (this.#active !== active2 || this.#phase === "closed" || this.#phase === "faulted")
|
|
24877
25113
|
return;
|
|
24878
25114
|
switch (event.type) {
|
|
24879
25115
|
case "progress.message": {
|
|
24880
|
-
if (
|
|
25116
|
+
if (active2.progressItems.has(event.itemId))
|
|
24881
25117
|
return;
|
|
24882
|
-
|
|
25118
|
+
active2.progressItems.add(event.itemId);
|
|
24883
25119
|
const item = {
|
|
24884
25120
|
type: "agentMessage",
|
|
24885
25121
|
itemId: event.itemId,
|
|
24886
25122
|
text: event.text,
|
|
24887
25123
|
phase: "commentary"
|
|
24888
25124
|
};
|
|
24889
|
-
this.#event({ type: "item.started", turnId:
|
|
24890
|
-
this.#completeItem(
|
|
25125
|
+
this.#event({ type: "item.started", turnId: active2.command.turnId, item });
|
|
25126
|
+
this.#completeItem(active2, item, { status: "succeeded" });
|
|
24891
25127
|
return;
|
|
24892
25128
|
}
|
|
24893
25129
|
case "text.delta":
|
|
24894
|
-
this.#activateAgentMessage(
|
|
24895
|
-
|
|
24896
|
-
this.#appendText(
|
|
25130
|
+
this.#activateAgentMessage(active2, event.messageId, event.nativeMessageIdentity);
|
|
25131
|
+
active2.sawAssistantMessage = true;
|
|
25132
|
+
this.#appendText(active2, event.delta);
|
|
24897
25133
|
return;
|
|
24898
25134
|
case "reasoning.delta":
|
|
24899
|
-
this.#activateAgentMessage(
|
|
24900
|
-
this.#appendReasoning(
|
|
25135
|
+
this.#activateAgentMessage(active2, event.messageId, event.nativeMessageIdentity);
|
|
25136
|
+
this.#appendReasoning(active2, event.delta, event.nativeMessageIdentity);
|
|
24901
25137
|
return;
|
|
24902
25138
|
case "reasoning.completed":
|
|
24903
|
-
this.#completeReasoning(
|
|
25139
|
+
this.#completeReasoning(active2, { status: "succeeded" });
|
|
24904
25140
|
return;
|
|
24905
25141
|
case "message.completed":
|
|
24906
|
-
if (event.phase &&
|
|
24907
|
-
|
|
24908
|
-
void this.#refreshUsage(
|
|
25142
|
+
if (event.phase && active2.agentMessageId === event.messageId && active2.agentItem)
|
|
25143
|
+
active2.agentItem = { ...active2.agentItem, phase: event.phase };
|
|
25144
|
+
void this.#refreshUsage(active2.command.turnId);
|
|
24909
25145
|
return;
|
|
24910
25146
|
case "compaction.started":
|
|
24911
|
-
this.#startCompaction(
|
|
25147
|
+
this.#startCompaction(active2);
|
|
24912
25148
|
return;
|
|
24913
25149
|
case "compaction.completed":
|
|
24914
|
-
this.#completeCompaction(
|
|
25150
|
+
this.#completeCompaction(active2, event);
|
|
24915
25151
|
return;
|
|
24916
25152
|
case "interaction.requested":
|
|
24917
|
-
this.#startInteraction(
|
|
25153
|
+
this.#startInteraction(active2, event.request);
|
|
24918
25154
|
return;
|
|
24919
25155
|
case "interaction.closed":
|
|
24920
|
-
this.#closeInteraction(
|
|
25156
|
+
this.#closeInteraction(active2, event.requestId, event.reason);
|
|
24921
25157
|
return;
|
|
24922
25158
|
case "tool.started":
|
|
24923
|
-
this.#completeReasoning(
|
|
24924
|
-
this.#completeAgentItem(
|
|
24925
|
-
this.#startTool(
|
|
25159
|
+
this.#completeReasoning(active2, { status: "succeeded" });
|
|
25160
|
+
this.#completeAgentItem(active2, { status: "succeeded" }, false);
|
|
25161
|
+
this.#startTool(active2, event);
|
|
24926
25162
|
return;
|
|
24927
25163
|
case "tool.updated":
|
|
24928
|
-
this.#updateTool(
|
|
25164
|
+
this.#updateTool(active2, event);
|
|
24929
25165
|
return;
|
|
24930
25166
|
case "tool.completed":
|
|
24931
|
-
this.#completeTool(
|
|
25167
|
+
this.#completeTool(active2, event);
|
|
24932
25168
|
}
|
|
24933
25169
|
}
|
|
24934
|
-
#startCompaction(
|
|
24935
|
-
if (
|
|
25170
|
+
#startCompaction(active2) {
|
|
25171
|
+
if (active2.compactionItem)
|
|
24936
25172
|
throw new Error("Pi Compaction started more than once");
|
|
24937
25173
|
const item = {
|
|
24938
25174
|
type: "contextCompaction",
|
|
24939
25175
|
itemId: this.#newItemId()
|
|
24940
25176
|
};
|
|
24941
|
-
|
|
24942
|
-
this.#event({ type: "item.started", turnId:
|
|
25177
|
+
active2.compactionItem = item;
|
|
25178
|
+
this.#event({ type: "item.started", turnId: active2.command.turnId, item });
|
|
24943
25179
|
}
|
|
24944
|
-
#completeCompaction(
|
|
24945
|
-
const item =
|
|
25180
|
+
#completeCompaction(active2, event) {
|
|
25181
|
+
const item = active2.compactionItem;
|
|
24946
25182
|
if (!item)
|
|
24947
25183
|
throw new Error("Pi Compaction completed without starting");
|
|
24948
|
-
|
|
25184
|
+
active2.compactionItem = null;
|
|
24949
25185
|
const outcome = event.outcome === "succeeded" ? { status: "succeeded" } : event.outcome === "cancelled" ? { status: "cancelled", reason: "Context compaction was cancelled" } : {
|
|
24950
25186
|
status: "failed",
|
|
24951
25187
|
error: {
|
|
@@ -24954,12 +25190,12 @@ var PiHarnessSession = class {
|
|
|
24954
25190
|
retryable: true
|
|
24955
25191
|
}
|
|
24956
25192
|
};
|
|
24957
|
-
this.#completeItem(
|
|
25193
|
+
this.#completeItem(active2, item, outcome);
|
|
24958
25194
|
if (event.outcome === "succeeded")
|
|
24959
|
-
void this.#refreshUsage(
|
|
25195
|
+
void this.#refreshUsage(active2.command.turnId);
|
|
24960
25196
|
}
|
|
24961
|
-
#startInteraction(
|
|
24962
|
-
if (
|
|
25197
|
+
#startInteraction(active2, request) {
|
|
25198
|
+
if (active2.interactionByNativeId.has(request.requestId)) {
|
|
24963
25199
|
throw new Error("Pi Interaction started more than once");
|
|
24964
25200
|
}
|
|
24965
25201
|
const interactionId = hostInteractionIdSchema.parse(randomUUID7());
|
|
@@ -24992,113 +25228,113 @@ var PiHarnessSession = class {
|
|
|
24992
25228
|
...request.method === "input" && request.placeholder ? { placeholder: request.placeholder } : {},
|
|
24993
25229
|
...request.method === "editor" && request.prefill ? { prefill: request.prefill } : {}
|
|
24994
25230
|
};
|
|
24995
|
-
const associatedTool =
|
|
25231
|
+
const associatedTool = active2.tools.size === 1 ? [...active2.tools.values()][0] : void 0;
|
|
24996
25232
|
const interaction = {
|
|
24997
25233
|
type: "question",
|
|
24998
25234
|
interactionId,
|
|
24999
|
-
turnId:
|
|
25235
|
+
turnId: active2.command.turnId,
|
|
25000
25236
|
...associatedTool?.item.type === "toolExecution" ? { itemId: associatedTool.item.itemId } : {},
|
|
25001
25237
|
title: "Pi",
|
|
25002
25238
|
questions: [question],
|
|
25003
25239
|
...request.timeoutMs !== void 0 ? { expiresAt: new Date(Date.now() + request.timeoutMs).toISOString() } : {}
|
|
25004
25240
|
};
|
|
25005
|
-
|
|
25006
|
-
|
|
25241
|
+
active2.interactions.set(interactionId, { interaction, nativeRequest: request });
|
|
25242
|
+
active2.interactionByNativeId.set(request.requestId, interactionId);
|
|
25007
25243
|
this.#channel.emit({ kind: "interaction", interaction });
|
|
25008
25244
|
}
|
|
25009
|
-
#closeInteraction(
|
|
25010
|
-
const interactionId =
|
|
25245
|
+
#closeInteraction(active2, nativeRequestId, reason) {
|
|
25246
|
+
const interactionId = active2.interactionByNativeId.get(nativeRequestId);
|
|
25011
25247
|
if (!interactionId)
|
|
25012
25248
|
throw new Error("Pi Interaction close references an unknown request");
|
|
25013
|
-
|
|
25014
|
-
|
|
25249
|
+
active2.interactionByNativeId.delete(nativeRequestId);
|
|
25250
|
+
active2.interactions.delete(interactionId);
|
|
25015
25251
|
this.#event({
|
|
25016
25252
|
type: "interaction.closed",
|
|
25017
25253
|
interactionId,
|
|
25018
|
-
turnId:
|
|
25254
|
+
turnId: active2.command.turnId,
|
|
25019
25255
|
reason
|
|
25020
25256
|
});
|
|
25021
25257
|
}
|
|
25022
|
-
#activateAgentMessage(
|
|
25023
|
-
if (
|
|
25258
|
+
#activateAgentMessage(active2, messageId, nativeMessageIdentity2) {
|
|
25259
|
+
if (active2.agentMessageId === messageId)
|
|
25024
25260
|
return;
|
|
25025
25261
|
const nativeItemId = piMessageItemId(nativeMessageIdentity2, "assistant");
|
|
25026
|
-
if (nativeItemId &&
|
|
25027
|
-
this.#completeAgentItem(
|
|
25262
|
+
if (nativeItemId && active2.agentMessageId === null && active2.agentItem?.text === "") {
|
|
25263
|
+
this.#completeAgentItem(active2, { status: "succeeded" }, true);
|
|
25028
25264
|
}
|
|
25029
|
-
if (
|
|
25030
|
-
this.#completeReasoning(
|
|
25031
|
-
this.#completeAgentItem(
|
|
25265
|
+
if (active2.agentMessageId !== null) {
|
|
25266
|
+
this.#completeReasoning(active2, { status: "succeeded" });
|
|
25267
|
+
this.#completeAgentItem(active2, { status: "succeeded" }, true);
|
|
25032
25268
|
}
|
|
25033
|
-
if (!
|
|
25034
|
-
|
|
25269
|
+
if (!active2.agentItem) {
|
|
25270
|
+
active2.agentItem = {
|
|
25035
25271
|
type: "agentMessage",
|
|
25036
25272
|
itemId: nativeItemId ?? this.#newItemId(),
|
|
25037
25273
|
text: ""
|
|
25038
25274
|
};
|
|
25039
25275
|
this.#event({
|
|
25040
25276
|
type: "item.started",
|
|
25041
|
-
turnId:
|
|
25042
|
-
item:
|
|
25277
|
+
turnId: active2.command.turnId,
|
|
25278
|
+
item: active2.agentItem
|
|
25043
25279
|
});
|
|
25044
25280
|
}
|
|
25045
|
-
|
|
25281
|
+
active2.agentMessageId = messageId;
|
|
25046
25282
|
}
|
|
25047
|
-
#appendText(
|
|
25048
|
-
if (
|
|
25283
|
+
#appendText(active2, text4) {
|
|
25284
|
+
if (active2.agentMessageId === null || !active2.agentItem) {
|
|
25049
25285
|
throw new Error("Pi Assistant text arrived outside an active message");
|
|
25050
25286
|
}
|
|
25051
|
-
|
|
25287
|
+
active2.agentItem = { ...active2.agentItem, text: active2.agentItem.text + text4 };
|
|
25052
25288
|
this.#event({
|
|
25053
25289
|
type: "item.updated",
|
|
25054
|
-
turnId:
|
|
25055
|
-
itemId:
|
|
25290
|
+
turnId: active2.command.turnId,
|
|
25291
|
+
itemId: active2.agentItem.itemId,
|
|
25056
25292
|
update: { type: "text.append", text: text4 }
|
|
25057
25293
|
});
|
|
25058
25294
|
}
|
|
25059
|
-
#completeAgentItem(
|
|
25060
|
-
|
|
25061
|
-
const item =
|
|
25295
|
+
#completeAgentItem(active2, outcome, completeEmpty) {
|
|
25296
|
+
active2.agentMessageId = null;
|
|
25297
|
+
const item = active2.agentItem;
|
|
25062
25298
|
if (!item || !completeEmpty && item.text.length === 0)
|
|
25063
25299
|
return;
|
|
25064
|
-
|
|
25065
|
-
this.#completeItem(
|
|
25300
|
+
active2.agentItem = null;
|
|
25301
|
+
this.#completeItem(active2, item, outcome);
|
|
25066
25302
|
}
|
|
25067
|
-
#appendReasoning(
|
|
25303
|
+
#appendReasoning(active2, text4, nativeMessageIdentity2) {
|
|
25068
25304
|
if (text4.length === 0)
|
|
25069
25305
|
return;
|
|
25070
|
-
if (!
|
|
25071
|
-
|
|
25306
|
+
if (!active2.reasoningItem) {
|
|
25307
|
+
active2.reasoningItem = {
|
|
25072
25308
|
type: "reasoning",
|
|
25073
25309
|
itemId: piMessageItemId(nativeMessageIdentity2, "reasoning") ?? this.#newItemId(),
|
|
25074
25310
|
text: ""
|
|
25075
25311
|
};
|
|
25076
25312
|
this.#event({
|
|
25077
25313
|
type: "item.started",
|
|
25078
|
-
turnId:
|
|
25079
|
-
item:
|
|
25314
|
+
turnId: active2.command.turnId,
|
|
25315
|
+
item: active2.reasoningItem
|
|
25080
25316
|
});
|
|
25081
25317
|
}
|
|
25082
|
-
|
|
25083
|
-
...
|
|
25084
|
-
text:
|
|
25318
|
+
active2.reasoningItem = {
|
|
25319
|
+
...active2.reasoningItem,
|
|
25320
|
+
text: active2.reasoningItem.text + text4
|
|
25085
25321
|
};
|
|
25086
25322
|
this.#event({
|
|
25087
25323
|
type: "item.updated",
|
|
25088
|
-
turnId:
|
|
25089
|
-
itemId:
|
|
25324
|
+
turnId: active2.command.turnId,
|
|
25325
|
+
itemId: active2.reasoningItem.itemId,
|
|
25090
25326
|
update: { type: "text.append", text: text4 }
|
|
25091
25327
|
});
|
|
25092
25328
|
}
|
|
25093
|
-
#completeReasoning(
|
|
25094
|
-
const item =
|
|
25329
|
+
#completeReasoning(active2, outcome) {
|
|
25330
|
+
const item = active2.reasoningItem;
|
|
25095
25331
|
if (!item)
|
|
25096
25332
|
return;
|
|
25097
|
-
|
|
25098
|
-
this.#completeItem(
|
|
25333
|
+
active2.reasoningItem = null;
|
|
25334
|
+
this.#completeItem(active2, item, outcome);
|
|
25099
25335
|
}
|
|
25100
|
-
#startTool(
|
|
25101
|
-
if (
|
|
25336
|
+
#startTool(active2, event) {
|
|
25337
|
+
if (active2.tools.has(event.callId))
|
|
25102
25338
|
throw new Error("Pi Tool started more than once");
|
|
25103
25339
|
const shell = piToolCommand(event.toolName, event.arguments);
|
|
25104
25340
|
const item = shell ? {
|
|
@@ -25112,18 +25348,18 @@ var PiHarnessSession = class {
|
|
|
25112
25348
|
toolName: event.toolName,
|
|
25113
25349
|
arguments: event.arguments
|
|
25114
25350
|
};
|
|
25115
|
-
|
|
25351
|
+
active2.tools.set(event.callId, {
|
|
25116
25352
|
item,
|
|
25117
25353
|
nativeName: event.toolName,
|
|
25118
25354
|
startedAtMs: Date.now()
|
|
25119
25355
|
});
|
|
25120
|
-
this.#event({ type: "item.started", turnId:
|
|
25356
|
+
this.#event({ type: "item.started", turnId: active2.command.turnId, item });
|
|
25121
25357
|
}
|
|
25122
|
-
#updateTool(
|
|
25123
|
-
const tool =
|
|
25358
|
+
#updateTool(active2, event) {
|
|
25359
|
+
const tool = active2.tools.get(event.callId);
|
|
25124
25360
|
if (!tool)
|
|
25125
25361
|
throw new Error("Pi Tool update references an unknown Tool Call");
|
|
25126
|
-
this.#subagents.start(
|
|
25362
|
+
this.#subagents.start(active2.command.turnId, tool.nativeName, event.output, this.#newItemId(), event.callId);
|
|
25127
25363
|
const output = boundedOutput(event.output, this.#toolOutputLimit);
|
|
25128
25364
|
if (!output)
|
|
25129
25365
|
return;
|
|
@@ -25140,7 +25376,7 @@ var PiHarnessSession = class {
|
|
|
25140
25376
|
if (delta.length > 0) {
|
|
25141
25377
|
this.#event({
|
|
25142
25378
|
type: "item.updated",
|
|
25143
|
-
turnId:
|
|
25379
|
+
turnId: active2.command.turnId,
|
|
25144
25380
|
itemId: tool.item.itemId,
|
|
25145
25381
|
update: { type: "output.append", text: delta }
|
|
25146
25382
|
});
|
|
@@ -25151,17 +25387,17 @@ var PiHarnessSession = class {
|
|
|
25151
25387
|
tool.item = { ...tool.item, output };
|
|
25152
25388
|
this.#event({
|
|
25153
25389
|
type: "item.updated",
|
|
25154
|
-
turnId:
|
|
25390
|
+
turnId: active2.command.turnId,
|
|
25155
25391
|
itemId: tool.item.itemId,
|
|
25156
25392
|
update: { type: "output.replace", output }
|
|
25157
25393
|
});
|
|
25158
25394
|
}
|
|
25159
|
-
#completeTool(
|
|
25160
|
-
const tool =
|
|
25395
|
+
#completeTool(active2, event) {
|
|
25396
|
+
const tool = active2.tools.get(event.callId);
|
|
25161
25397
|
if (!tool || tool.nativeName !== event.toolName) {
|
|
25162
25398
|
throw new Error("Pi Tool completion references an unknown Tool Call");
|
|
25163
25399
|
}
|
|
25164
|
-
|
|
25400
|
+
active2.tools.delete(event.callId);
|
|
25165
25401
|
const durationMs = Math.max(0, Date.now() - tool.startedAtMs);
|
|
25166
25402
|
const output = boundedOutput(event.result, this.#toolOutputLimit);
|
|
25167
25403
|
if (tool.item.type === "commandExecution") {
|
|
@@ -25178,9 +25414,9 @@ var PiHarnessSession = class {
|
|
|
25178
25414
|
} else {
|
|
25179
25415
|
tool.item = { ...tool.item, ...output ? { output } : {}, durationMs };
|
|
25180
25416
|
}
|
|
25181
|
-
const outcome =
|
|
25182
|
-
this.#completeItem(
|
|
25183
|
-
this.#subagents.start(
|
|
25417
|
+
const outcome = active2.cancellationRequested ? { status: "cancelled", reason: "Cancelled by user" } : event.isError ? { status: "failed", error: toolFailure(event.toolName) } : { status: "succeeded" };
|
|
25418
|
+
this.#completeItem(active2, tool.item, outcome);
|
|
25419
|
+
this.#subagents.start(active2.command.turnId, event.toolName, event.result, this.#newItemId(), event.callId);
|
|
25184
25420
|
if (!event.isError) {
|
|
25185
25421
|
try {
|
|
25186
25422
|
const args = tool.item.type === "toolExecution" ? tool.item.arguments : {};
|
|
@@ -25192,41 +25428,41 @@ var PiHarnessSession = class {
|
|
|
25192
25428
|
sourceItemIds: [tool.item.itemId],
|
|
25193
25429
|
changes
|
|
25194
25430
|
};
|
|
25195
|
-
this.#event({ type: "item.started", turnId:
|
|
25196
|
-
this.#completeItem(
|
|
25431
|
+
this.#event({ type: "item.started", turnId: active2.command.turnId, item: fileItem });
|
|
25432
|
+
this.#completeItem(active2, fileItem, { status: "succeeded" });
|
|
25197
25433
|
}
|
|
25198
25434
|
} catch {
|
|
25199
25435
|
}
|
|
25200
25436
|
}
|
|
25201
25437
|
}
|
|
25202
|
-
#completeItem(
|
|
25438
|
+
#completeItem(active2, item, outcome) {
|
|
25203
25439
|
this.#event({
|
|
25204
25440
|
type: "item.completed",
|
|
25205
|
-
turnId:
|
|
25441
|
+
turnId: active2.command.turnId,
|
|
25206
25442
|
snapshot: { item, outcome }
|
|
25207
25443
|
});
|
|
25208
25444
|
}
|
|
25209
|
-
#closeActiveInteractions(
|
|
25210
|
-
for (const [interactionId, pending] of
|
|
25211
|
-
|
|
25212
|
-
|
|
25445
|
+
#closeActiveInteractions(active2, reason) {
|
|
25446
|
+
for (const [interactionId, pending] of active2.interactions) {
|
|
25447
|
+
active2.interactions.delete(interactionId);
|
|
25448
|
+
active2.interactionByNativeId.delete(pending.nativeRequest.requestId);
|
|
25213
25449
|
this.#event({
|
|
25214
25450
|
type: "interaction.closed",
|
|
25215
25451
|
interactionId,
|
|
25216
|
-
turnId:
|
|
25452
|
+
turnId: active2.command.turnId,
|
|
25217
25453
|
reason
|
|
25218
25454
|
});
|
|
25219
25455
|
}
|
|
25220
25456
|
}
|
|
25221
|
-
async #completedTurnIdentity(
|
|
25222
|
-
|
|
25223
|
-
await Promise.allSettled([...
|
|
25224
|
-
const snapshot = mapPiSnapshot(
|
|
25457
|
+
async #completedTurnIdentity(active2, transport) {
|
|
25458
|
+
active2.acceptingSteers = false;
|
|
25459
|
+
await Promise.allSettled([...active2.pendingSteers]);
|
|
25460
|
+
const snapshot = mapPiSnapshot(active2.steerFailure?.history ?? await transport.getEntries(), {
|
|
25225
25461
|
sessionId: transport.state.sessionId,
|
|
25226
25462
|
model: nativeModelForHistory(transport.state)
|
|
25227
25463
|
});
|
|
25228
|
-
const created = snapshot.turns.filter((turn2) => turn2.input.length > 0 && !
|
|
25229
|
-
const expected = 1 +
|
|
25464
|
+
const created = snapshot.turns.filter((turn2) => turn2.input.length > 0 && !active2.beforeNativeTurnKeys.has(turn2.nativeTurnRef.nativeTurnKey));
|
|
25465
|
+
const expected = 1 + active2.acceptedSteerCount;
|
|
25230
25466
|
if (created.length !== expected) {
|
|
25231
25467
|
throw new Error(`Pi Turn persisted ${created.length} new User Entries; exactly ${expected} is required`);
|
|
25232
25468
|
}
|
|
@@ -25238,34 +25474,34 @@ var PiHarnessSession = class {
|
|
|
25238
25474
|
...turn.checkpoint ? { checkpoint: turn.checkpoint } : {}
|
|
25239
25475
|
};
|
|
25240
25476
|
}
|
|
25241
|
-
#completeTurn(
|
|
25242
|
-
if (this.#active !==
|
|
25477
|
+
#completeTurn(active2, outcome, finalText, nativeTurnRef) {
|
|
25478
|
+
if (this.#active !== active2)
|
|
25243
25479
|
return;
|
|
25244
|
-
this.#closeActiveInteractions(
|
|
25480
|
+
this.#closeActiveInteractions(active2, outcome.status === "succeeded" ? "superseded" : "cancelled");
|
|
25245
25481
|
this.#active = null;
|
|
25246
25482
|
const itemOutcome2 = outcome.status === "failed" ? { status: "failed", error: outcome.error } : outcome.status === "cancelled" ? { status: "cancelled", ...outcome.reason ? { reason: outcome.reason } : {} } : { status: "succeeded" };
|
|
25247
|
-
this.#completeReasoning(
|
|
25248
|
-
if (
|
|
25249
|
-
this.#completeItem(
|
|
25250
|
-
|
|
25251
|
-
}
|
|
25252
|
-
for (const tool of
|
|
25253
|
-
this.#completeItem(
|
|
25254
|
-
|
|
25255
|
-
this.#subagents.finish(
|
|
25256
|
-
if (!
|
|
25257
|
-
|
|
25258
|
-
}
|
|
25259
|
-
this.#completeAgentItem(
|
|
25483
|
+
this.#completeReasoning(active2, itemOutcome2);
|
|
25484
|
+
if (active2.compactionItem) {
|
|
25485
|
+
this.#completeItem(active2, active2.compactionItem, itemOutcome2);
|
|
25486
|
+
active2.compactionItem = null;
|
|
25487
|
+
}
|
|
25488
|
+
for (const tool of active2.tools.values())
|
|
25489
|
+
this.#completeItem(active2, tool.item, itemOutcome2);
|
|
25490
|
+
active2.tools.clear();
|
|
25491
|
+
this.#subagents.finish(active2.command.turnId);
|
|
25492
|
+
if (!active2.sawAssistantMessage && finalText !== void 0 && active2.agentItem) {
|
|
25493
|
+
active2.agentItem = { ...active2.agentItem, text: finalText };
|
|
25494
|
+
}
|
|
25495
|
+
this.#completeAgentItem(active2, itemOutcome2, true);
|
|
25260
25496
|
this.#event({
|
|
25261
25497
|
type: "turn.completed",
|
|
25262
|
-
turnId:
|
|
25498
|
+
turnId: active2.command.turnId,
|
|
25263
25499
|
outcome,
|
|
25264
25500
|
...nativeTurnRef ? { nativeTurnRef } : {}
|
|
25265
25501
|
});
|
|
25266
|
-
|
|
25267
|
-
if (
|
|
25268
|
-
this.#fault(
|
|
25502
|
+
active2.resolveCompletion();
|
|
25503
|
+
if (active2.steerFailure) {
|
|
25504
|
+
this.#fault(active2.steerFailure);
|
|
25269
25505
|
return;
|
|
25270
25506
|
}
|
|
25271
25507
|
queueMicrotask(() => {
|
|
@@ -25273,7 +25509,7 @@ var PiHarnessSession = class {
|
|
|
25273
25509
|
return;
|
|
25274
25510
|
if (this.#transport)
|
|
25275
25511
|
this.#drainPendingAutonomousTurns(this.#transport);
|
|
25276
|
-
void this.#refreshUsage(
|
|
25512
|
+
void this.#refreshUsage(active2.command.turnId);
|
|
25277
25513
|
});
|
|
25278
25514
|
}
|
|
25279
25515
|
#fault(error51) {
|
|
@@ -25300,11 +25536,11 @@ var PiHarnessSession = class {
|
|
|
25300
25536
|
if (!wasFaulted)
|
|
25301
25537
|
this.#phase = "closing";
|
|
25302
25538
|
const transport = this.#transport ?? (this.#starting ? await this.#starting.catch(() => null) : null);
|
|
25303
|
-
const
|
|
25304
|
-
if (transport &&
|
|
25305
|
-
|
|
25539
|
+
const active2 = this.#active;
|
|
25540
|
+
if (transport && active2) {
|
|
25541
|
+
active2.cancellationRequested = true;
|
|
25306
25542
|
await transport.abort().catch(() => void 0);
|
|
25307
|
-
await Promise.race([
|
|
25543
|
+
await Promise.race([active2.completion, delay(this.#closeTimeoutMs)]);
|
|
25308
25544
|
}
|
|
25309
25545
|
try {
|
|
25310
25546
|
if (transport)
|
|
@@ -25331,6 +25567,7 @@ var PiHarnessSession = class {
|
|
|
25331
25567
|
}
|
|
25332
25568
|
};
|
|
25333
25569
|
var PiAdapter = class {
|
|
25570
|
+
normalizeStoredModelRef = normalizeStoredPiModelRef;
|
|
25334
25571
|
credentialImports;
|
|
25335
25572
|
commandCatalog = piCommandCatalog;
|
|
25336
25573
|
liveCommandCatalog = true;
|
|
@@ -25424,6 +25661,7 @@ var PiAdapter = class {
|
|
|
25424
25661
|
const updateCatalog = async (operation) => {
|
|
25425
25662
|
await operation;
|
|
25426
25663
|
this.#inspectionCache.clear();
|
|
25664
|
+
this.#inspectionInFlight.clear();
|
|
25427
25665
|
};
|
|
25428
25666
|
this.credentialImports = {
|
|
25429
25667
|
providers: imports.providers,
|
|
@@ -25463,16 +25701,22 @@ var PiAdapter = class {
|
|
|
25463
25701
|
}
|
|
25464
25702
|
const cwd = resolvePiInspectCwd(input.cwd);
|
|
25465
25703
|
const inFlight = this.#inspectionInFlight.get(cwd);
|
|
25704
|
+
if (input.refresh) {
|
|
25705
|
+
this.#inspectionCache.clear();
|
|
25706
|
+
this.#inspectionInFlight.clear();
|
|
25707
|
+
if (inFlight)
|
|
25708
|
+
this.#inspectionInFlight.set(cwd, inFlight);
|
|
25709
|
+
}
|
|
25466
25710
|
if (inFlight)
|
|
25467
25711
|
return inFlight;
|
|
25468
|
-
|
|
25469
|
-
|
|
25470
|
-
|
|
25471
|
-
return cached2;
|
|
25472
|
-
}
|
|
25712
|
+
const cached2 = this.#inspectionCache.get(cwd);
|
|
25713
|
+
if (cached2)
|
|
25714
|
+
return cached2;
|
|
25473
25715
|
const inspection = this.#inspectCwd(cwd).then((result) => {
|
|
25474
|
-
if (result.status === "ready")
|
|
25716
|
+
if (result.status === "ready" && this.#inspectionInFlight.get(cwd) === inspection) {
|
|
25475
25717
|
this.#inspectionCache.set(cwd, result);
|
|
25718
|
+
this.#thinkingSelectionSupported = result.capabilities.configuration.selectThinkingOption;
|
|
25719
|
+
}
|
|
25476
25720
|
return result;
|
|
25477
25721
|
});
|
|
25478
25722
|
this.#inspectionInFlight.set(cwd, inspection);
|
|
@@ -25494,10 +25738,7 @@ var PiAdapter = class {
|
|
|
25494
25738
|
const models = await transport.getAvailableModels();
|
|
25495
25739
|
stage = "capabilities";
|
|
25496
25740
|
const thinkingLevels = await transport.getAvailableThinkingLevels();
|
|
25497
|
-
|
|
25498
|
-
const normalized = normalizePiModelCatalog(models, nativeModelFromState(transport.state), thinkingLevels, transport.state.thinkingLevel, transport.state.modelReasoning ?? null);
|
|
25499
|
-
const fastModels = await transport.supportsFastMode?.() ? piFastModelKeys(models) : /* @__PURE__ */ new Set();
|
|
25500
|
-
const catalog = withPiFast(normalized, fastModels);
|
|
25741
|
+
const catalog = normalizePiModelCatalog(models, nativeModelFromState(transport.state), thinkingLevels, transport.state.thinkingLevel, transport.state.modelReasoning ?? null, await transport.supportsFastMode?.());
|
|
25501
25742
|
await transport.close();
|
|
25502
25743
|
return {
|
|
25503
25744
|
status: "ready",
|
|
@@ -25534,27 +25775,6 @@ var PiAdapter = class {
|
|
|
25534
25775
|
if (this.#closePromise) {
|
|
25535
25776
|
return { ok: false, error: invalidState("Pi Adapter is closed") };
|
|
25536
25777
|
}
|
|
25537
|
-
if ("model" in input && input.model) {
|
|
25538
|
-
let model2;
|
|
25539
|
-
try {
|
|
25540
|
-
model2 = decodePiModelRef(input.model);
|
|
25541
|
-
} catch (error51) {
|
|
25542
|
-
return { ok: false, error: normalizedError(error51, "invalidRequest") };
|
|
25543
|
-
}
|
|
25544
|
-
if (model2.fast) {
|
|
25545
|
-
if (!this.#isFastSupported(input.model, input.cwd))
|
|
25546
|
-
await this.inspect({ cwd: input.cwd });
|
|
25547
|
-
if (!this.#isFastSupported(input.model, input.cwd) && input.kind !== "resume")
|
|
25548
|
-
return {
|
|
25549
|
-
ok: false,
|
|
25550
|
-
error: {
|
|
25551
|
-
code: "unsupported",
|
|
25552
|
-
message: "Fast is unavailable for this Pi Model",
|
|
25553
|
-
retryable: false
|
|
25554
|
-
}
|
|
25555
|
-
};
|
|
25556
|
-
}
|
|
25557
|
-
}
|
|
25558
25778
|
if (input.cwd.length === 0) {
|
|
25559
25779
|
return {
|
|
25560
25780
|
ok: false,
|
|
@@ -25577,10 +25797,25 @@ var PiAdapter = class {
|
|
|
25577
25797
|
};
|
|
25578
25798
|
}
|
|
25579
25799
|
if (input.model) {
|
|
25580
|
-
|
|
25581
|
-
|
|
25582
|
-
|
|
25583
|
-
|
|
25800
|
+
const parsed = harnessModelRefSchema.safeParse(input.model);
|
|
25801
|
+
if (!parsed.success || parsed.data.serviceTier === "ultrafast") {
|
|
25802
|
+
return {
|
|
25803
|
+
ok: false,
|
|
25804
|
+
error: { code: "invalidRequest", message: "Invalid Pi Model Ref", retryable: false }
|
|
25805
|
+
};
|
|
25806
|
+
}
|
|
25807
|
+
if (parsed.data.serviceTier === "priority") {
|
|
25808
|
+
const inspection = await this.inspect({ cwd: input.cwd });
|
|
25809
|
+
if (inspection.status !== "ready" || !inspection.catalog.models.some(({ fastModel }) => sameHarnessModelRef(fastModel, parsed.data))) {
|
|
25810
|
+
return {
|
|
25811
|
+
ok: false,
|
|
25812
|
+
error: {
|
|
25813
|
+
code: "unsupported",
|
|
25814
|
+
message: "Fast is unavailable for this Pi Model",
|
|
25815
|
+
retryable: false
|
|
25816
|
+
}
|
|
25817
|
+
};
|
|
25818
|
+
}
|
|
25584
25819
|
}
|
|
25585
25820
|
}
|
|
25586
25821
|
const thinkingOptionId = input.thinkingOptionId ? harnessThinkingOptionIdSchema.safeParse(input.thinkingOptionId) : null;
|
|
@@ -25725,7 +25960,9 @@ var PiAdapter = class {
|
|
|
25725
25960
|
await transport.verifySessionCwd(input.cwd);
|
|
25726
25961
|
}
|
|
25727
25962
|
}
|
|
25728
|
-
|
|
25963
|
+
const startedModels = await transport.getAvailableModels();
|
|
25964
|
+
const current = nativeModelFromState(transport.state);
|
|
25965
|
+
if (input.kind === "resume" && input.model && current && sameHarnessModelRef(input.model, livePiModelIndex(startedModels, transport.state).ref({ ...current, fast: true })) && await isFastSupported(current, startedModels, transport)) {
|
|
25729
25966
|
if (!transport.selectFastMode)
|
|
25730
25967
|
throw new Error("Pi Fast extension is unavailable");
|
|
25731
25968
|
await transport.selectFastMode(true);
|
|
@@ -25738,6 +25975,7 @@ var PiAdapter = class {
|
|
|
25738
25975
|
usageHistory,
|
|
25739
25976
|
...input.environment ? { environment: input.environment } : {},
|
|
25740
25977
|
startedTransport: transport,
|
|
25978
|
+
startedModels,
|
|
25741
25979
|
startedThinkingLevels,
|
|
25742
25980
|
initialUsage,
|
|
25743
25981
|
supportsThinkingSelection: startedThinkingLevels !== null
|
|
@@ -25748,9 +25986,6 @@ var PiAdapter = class {
|
|
|
25748
25986
|
return { ok: false, error: normalizedError(error51, "nativeFailure") };
|
|
25749
25987
|
}
|
|
25750
25988
|
}
|
|
25751
|
-
#isFastSupported(ref, cwd) {
|
|
25752
|
-
return this.#inspectionCache.get(cwd)?.catalog.models.some((model2) => model2.fastModel?.id === ref.id) ?? false;
|
|
25753
|
-
}
|
|
25754
25989
|
#trackSession(cwd, options) {
|
|
25755
25990
|
const environment = options.environment;
|
|
25756
25991
|
const createTransport = environment ? (input) => this.#createTransport({ ...input, environment }) : this.#createTransport;
|
|
@@ -25762,15 +25997,8 @@ var PiAdapter = class {
|
|
|
25762
25997
|
...options.thinkingOptionId ? { thinkingOptionId: options.thinkingOptionId } : {},
|
|
25763
25998
|
toolOutputLimit: this.#toolOutputLimit,
|
|
25764
25999
|
supportsThinkingSelection: options.supportsThinkingSelection,
|
|
25765
|
-
isFastSupported: async (ref, transport) => {
|
|
25766
|
-
if (this.#inspectionCache.has(cwd))
|
|
25767
|
-
return this.#isFastSupported(ref, cwd);
|
|
25768
|
-
if (!await transport.supportsFastMode?.())
|
|
25769
|
-
return false;
|
|
25770
|
-
const fastModels = piFastModelKeys(await transport.getAvailableModels());
|
|
25771
|
-
return fastModels.has(encodePiModelRef({ ...decodePiModelRef(ref), fast: false }).id);
|
|
25772
|
-
},
|
|
25773
26000
|
...options.startedTransport ? { startedTransport: options.startedTransport } : {},
|
|
26001
|
+
...options.startedModels ? { startedModels: options.startedModels } : {},
|
|
25774
26002
|
...options.startedThinkingLevels !== void 0 ? { startedThinkingLevels: options.startedThinkingLevels } : {},
|
|
25775
26003
|
...options.initialUsage !== void 0 ? { initialUsage: options.initialUsage } : {},
|
|
25776
26004
|
...options.usageHistory ? { usageHistory: options.usageHistory } : {}
|