@codexhost/cli-darwin-x64 0.14.0 → 0.16.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 +55 -7
- package/app/console-web.js +281 -79
- package/app/desktop-controller.mjs +155 -22
- package/app/host-runtime.mjs +548 -148
- package/app/plugins/antigravity/plugin.mjs +342 -53
- package/app/plugins/claude-code/plugin.mjs +393 -162
- package/app/plugins/codebuddy/plugin.mjs +245 -49
- package/app/plugins/codex-usage/plugin.mjs +75 -28
- package/app/plugins/copilot/plugin.mjs +100 -53
- package/app/plugins/cursor-cli/plugin.mjs +207 -46
- package/app/plugins/deepseek-harness/plugin.mjs +103 -36
- package/app/plugins/grok/plugin.mjs +354 -84
- package/app/plugins/hermes/plugin.mjs +50 -3
- package/app/plugins/kimi-code/plugin.mjs +62 -15
- package/app/plugins/kiro-cli/plugin.mjs +62 -15
- package/app/plugins/omp/plugin.mjs +82 -35
- package/app/plugins/opencode/plugin.mjs +104 -57
- package/app/plugins/pi/plugin.mjs +134 -50
- package/app/plugins/qoder/plugin.mjs +72 -25
- package/app/plugins/qoder-cn/plugin.mjs +72 -25
- package/app/plugins/workbuddy/plugin.mjs +245 -49
- package/app/plugins/zcode/plugin.mjs +101 -29
- package/app/renderer-extension.js +2353 -344
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/package.json +1 -1
|
@@ -3580,10 +3580,10 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
3580
3580
|
const shape = def.shape;
|
|
3581
3581
|
const propValues = {};
|
|
3582
3582
|
for (const key in shape) {
|
|
3583
|
-
const
|
|
3584
|
-
if (
|
|
3583
|
+
const field2 = shape[key]._zod;
|
|
3584
|
+
if (field2.values) {
|
|
3585
3585
|
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
3586
|
-
for (const v of
|
|
3586
|
+
for (const v of field2.values)
|
|
3587
3587
|
propValues[key].add(v);
|
|
3588
3588
|
}
|
|
3589
3589
|
}
|
|
@@ -15223,6 +15223,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
|
|
|
15223
15223
|
cachedInputTokens: count,
|
|
15224
15224
|
cacheWriteInputTokens: count,
|
|
15225
15225
|
cacheKnownInputTokens: count,
|
|
15226
|
+
cacheHitCachedInputTokens: count,
|
|
15227
|
+
cacheHitInputTokens: count,
|
|
15226
15228
|
outputTokens: count,
|
|
15227
15229
|
reasoningOutputTokens: count,
|
|
15228
15230
|
/** USD at the public price, summed over the priced requests only. */
|
|
@@ -15330,6 +15332,51 @@ var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
|
15330
15332
|
var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
|
|
15331
15333
|
var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
|
|
15332
15334
|
|
|
15335
|
+
// ../../shared-contracts/dist/thread-questions.js
|
|
15336
|
+
var field = external_exports.discriminatedUnion("type", [
|
|
15337
|
+
external_exports.object({
|
|
15338
|
+
id: external_exports.string().min(1),
|
|
15339
|
+
type: external_exports.literal("choice"),
|
|
15340
|
+
prompt: external_exports.string(),
|
|
15341
|
+
options: external_exports.array(external_exports.object({
|
|
15342
|
+
value: external_exports.string().min(1),
|
|
15343
|
+
label: external_exports.string(),
|
|
15344
|
+
description: external_exports.string().optional()
|
|
15345
|
+
})).min(1),
|
|
15346
|
+
multiple: external_exports.boolean(),
|
|
15347
|
+
allowOther: external_exports.boolean(),
|
|
15348
|
+
optional: external_exports.boolean()
|
|
15349
|
+
}),
|
|
15350
|
+
external_exports.object({
|
|
15351
|
+
id: external_exports.string().min(1),
|
|
15352
|
+
type: external_exports.literal("text"),
|
|
15353
|
+
prompt: external_exports.string(),
|
|
15354
|
+
multiline: external_exports.boolean(),
|
|
15355
|
+
secret: external_exports.literal(false),
|
|
15356
|
+
optional: external_exports.boolean(),
|
|
15357
|
+
placeholder: external_exports.string().optional(),
|
|
15358
|
+
prefill: external_exports.string().optional()
|
|
15359
|
+
})
|
|
15360
|
+
]);
|
|
15361
|
+
var threadQuestionSchema = external_exports.object({
|
|
15362
|
+
interactionId: external_exports.string().min(1),
|
|
15363
|
+
turnId: external_exports.string().min(1),
|
|
15364
|
+
title: external_exports.string().optional(),
|
|
15365
|
+
questions: external_exports.array(field).min(1)
|
|
15366
|
+
}).refine(({ questions }) => questions.some((q) => q.type === "choice" && q.multiple), {
|
|
15367
|
+
message: "Shared cards require at least one multi-select question"
|
|
15368
|
+
});
|
|
15369
|
+
var threadQuestionsListParamsSchema = external_exports.strictObject({ threadId: external_exports.string().min(1) });
|
|
15370
|
+
var threadQuestionsResultSchema = external_exports.object({ questions: external_exports.array(threadQuestionSchema) });
|
|
15371
|
+
var threadQuestionRespondParamsSchema = external_exports.strictObject({
|
|
15372
|
+
threadId: external_exports.string().min(1),
|
|
15373
|
+
turnId: external_exports.string().min(1),
|
|
15374
|
+
interactionId: external_exports.string().min(1),
|
|
15375
|
+
answers: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())),
|
|
15376
|
+
cancelled: external_exports.boolean().default(false)
|
|
15377
|
+
});
|
|
15378
|
+
var threadQuestionRespondResultSchema = external_exports.object({ accepted: external_exports.literal(true) });
|
|
15379
|
+
|
|
15333
15380
|
// ../../shared-contracts/dist/console.js
|
|
15334
15381
|
var consoleAnnouncementSchema = external_exports.strictObject({
|
|
15335
15382
|
title: external_exports.string().trim().min(1).max(200),
|
|
@@ -16663,26 +16710,26 @@ function parseHostUsage(value) {
|
|
|
16663
16710
|
}
|
|
16664
16711
|
}
|
|
16665
16712
|
const indicators = value.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value.composerIndicators) };
|
|
16666
|
-
for (const
|
|
16713
|
+
for (const field2 of [
|
|
16667
16714
|
"totalCredits",
|
|
16668
16715
|
"contextUsagePercent",
|
|
16669
16716
|
"apiOutputTokensPerSecond"
|
|
16670
16717
|
]) {
|
|
16671
|
-
const candidate2 = value[
|
|
16718
|
+
const candidate2 = value[field2];
|
|
16672
16719
|
if (candidate2 !== void 0 && (typeof candidate2 !== "number" || !Number.isFinite(candidate2) || candidate2 < 0)) {
|
|
16673
|
-
throw new Error(`Harness Usage '${
|
|
16720
|
+
throw new Error(`Harness Usage '${field2}' must be a finite non-negative number`);
|
|
16674
16721
|
}
|
|
16675
16722
|
}
|
|
16676
|
-
for (const
|
|
16677
|
-
const candidate2 = value[
|
|
16723
|
+
for (const field2 of tokenFields) {
|
|
16724
|
+
const candidate2 = value[field2];
|
|
16678
16725
|
if (candidate2 !== void 0 && (typeof candidate2 !== "number" || !Number.isSafeInteger(candidate2) || candidate2 < 0)) {
|
|
16679
|
-
throw new Error(`Harness Usage '${
|
|
16726
|
+
throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
|
|
16680
16727
|
}
|
|
16681
16728
|
}
|
|
16682
|
-
for (const
|
|
16683
|
-
const candidate2 = value[
|
|
16729
|
+
for (const field2 of safeIntegerFields) {
|
|
16730
|
+
const candidate2 = value[field2];
|
|
16684
16731
|
if (candidate2 !== void 0 && (typeof candidate2 !== "number" || !Number.isSafeInteger(candidate2) || candidate2 < 0)) {
|
|
16685
|
-
throw new Error(`Harness Usage '${
|
|
16732
|
+
throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
|
|
16686
16733
|
}
|
|
16687
16734
|
}
|
|
16688
16735
|
if (value.outputTokensPerSecond !== void 0 && (typeof value.outputTokensPerSecond !== "number" || !Number.isFinite(value.outputTokensPerSecond) || value.outputTokensPerSecond < 0)) {
|
|
@@ -16691,10 +16738,10 @@ function parseHostUsage(value) {
|
|
|
16691
16738
|
if (value.totalCostUsd !== void 0 && (typeof value.totalCostUsd !== "number" || !Number.isFinite(value.totalCostUsd) || value.totalCostUsd < 0)) {
|
|
16692
16739
|
throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
|
|
16693
16740
|
}
|
|
16694
|
-
for (const
|
|
16695
|
-
const candidate2 = value[
|
|
16741
|
+
for (const field2 of percentFields) {
|
|
16742
|
+
const candidate2 = value[field2];
|
|
16696
16743
|
if (candidate2 !== void 0 && (typeof candidate2 !== "number" || !Number.isFinite(candidate2) || candidate2 < 0 || candidate2 > 100)) {
|
|
16697
|
-
throw new Error(`Harness Usage '${
|
|
16744
|
+
throw new Error(`Harness Usage '${field2}' must be between 0 and 100`);
|
|
16698
16745
|
}
|
|
16699
16746
|
}
|
|
16700
16747
|
if (value.sessionCacheUsage !== void 0) {
|
|
@@ -16765,19 +16812,19 @@ function parseHostUsageRequest(value) {
|
|
|
16765
16812
|
if (typeof value.requestId !== "string" || value.requestId.length === 0) {
|
|
16766
16813
|
throw new Error("Harness Usage request 'requestId' must be a non-empty string");
|
|
16767
16814
|
}
|
|
16768
|
-
for (const
|
|
16769
|
-
const candidate2 = value[
|
|
16815
|
+
for (const field2 of ["model", "provider"]) {
|
|
16816
|
+
const candidate2 = value[field2];
|
|
16770
16817
|
if (candidate2 !== void 0 && (typeof candidate2 !== "string" || candidate2.length === 0)) {
|
|
16771
|
-
throw new Error(`Harness Usage request '${
|
|
16818
|
+
throw new Error(`Harness Usage request '${field2}' must be a non-empty string`);
|
|
16772
16819
|
}
|
|
16773
16820
|
}
|
|
16774
16821
|
if (value.historical !== void 0 && typeof value.historical !== "boolean") {
|
|
16775
16822
|
throw new Error("Harness Usage request 'historical' must be a boolean");
|
|
16776
16823
|
}
|
|
16777
|
-
for (const
|
|
16778
|
-
const candidate2 = value[
|
|
16824
|
+
for (const field2 of requestTokenFields) {
|
|
16825
|
+
const candidate2 = value[field2];
|
|
16779
16826
|
if (candidate2 !== void 0 && (typeof candidate2 !== "number" || !Number.isSafeInteger(candidate2) || candidate2 < 0)) {
|
|
16780
|
-
throw new Error(`Harness Usage request '${
|
|
16827
|
+
throw new Error(`Harness Usage request '${field2}' must be a non-negative safe integer`);
|
|
16781
16828
|
}
|
|
16782
16829
|
}
|
|
16783
16830
|
if (value.inputTokens === void 0 || value.outputTokens === void 0) {
|
|
@@ -18171,24 +18218,24 @@ var buildClientParams = (args, fields) => {
|
|
|
18171
18218
|
}
|
|
18172
18219
|
if ("in" in config2) {
|
|
18173
18220
|
if (config2.key) {
|
|
18174
|
-
const
|
|
18175
|
-
const name =
|
|
18176
|
-
if (
|
|
18221
|
+
const field2 = map2.get(config2.key);
|
|
18222
|
+
const name = field2.map || config2.key;
|
|
18223
|
+
if (field2.in) {
|
|
18177
18224
|
;
|
|
18178
|
-
params[
|
|
18225
|
+
params[field2.in][name] = arg;
|
|
18179
18226
|
}
|
|
18180
18227
|
} else {
|
|
18181
18228
|
params.body = arg;
|
|
18182
18229
|
}
|
|
18183
18230
|
} else {
|
|
18184
18231
|
for (const [key, value] of Object.entries(arg ?? {})) {
|
|
18185
|
-
const
|
|
18186
|
-
if (
|
|
18187
|
-
if (
|
|
18188
|
-
const name =
|
|
18189
|
-
params[
|
|
18232
|
+
const field2 = map2.get(key);
|
|
18233
|
+
if (field2) {
|
|
18234
|
+
if (field2.in) {
|
|
18235
|
+
const name = field2.map || key;
|
|
18236
|
+
params[field2.in][name] = value;
|
|
18190
18237
|
} else {
|
|
18191
|
-
params[
|
|
18238
|
+
params[field2.map] = value;
|
|
18192
18239
|
}
|
|
18193
18240
|
} else {
|
|
18194
18241
|
const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
|
|
@@ -24321,8 +24368,8 @@ var OpenCodeHarnessSession = class {
|
|
|
24321
24368
|
this.#event({ type: "item.started", turnId: active.turnId, item });
|
|
24322
24369
|
}
|
|
24323
24370
|
}
|
|
24324
|
-
#appendPartDelta(active, partID,
|
|
24325
|
-
if (
|
|
24371
|
+
#appendPartDelta(active, partID, field2, delta) {
|
|
24372
|
+
if (field2 !== "text" || !delta)
|
|
24326
24373
|
return;
|
|
24327
24374
|
const existing = active.items.get(partID);
|
|
24328
24375
|
if (!existing)
|
|
@@ -27317,16 +27364,16 @@ function permissionInteraction(request, turnId) {
|
|
|
27317
27364
|
};
|
|
27318
27365
|
}
|
|
27319
27366
|
function formInteraction(form, turnId) {
|
|
27320
|
-
const questions = form.fields.map((
|
|
27321
|
-
if (
|
|
27367
|
+
const questions = form.fields.map((field2) => {
|
|
27368
|
+
if (field2.type === "external" || field2.hidden || field2.when?.length) {
|
|
27322
27369
|
throw new Error("OpenCode v2 external, hidden or conditional form fields require its native UI");
|
|
27323
27370
|
}
|
|
27324
27371
|
const base = {
|
|
27325
|
-
id:
|
|
27326
|
-
prompt: [
|
|
27327
|
-
optional: !
|
|
27372
|
+
id: field2.key,
|
|
27373
|
+
prompt: [field2.title, field2.description].filter(Boolean).join("\n") || field2.key,
|
|
27374
|
+
optional: !field2.required
|
|
27328
27375
|
};
|
|
27329
|
-
if (
|
|
27376
|
+
if (field2.type === "boolean")
|
|
27330
27377
|
return {
|
|
27331
27378
|
...base,
|
|
27332
27379
|
type: "choice",
|
|
@@ -27337,22 +27384,22 @@ function formInteraction(form, turnId) {
|
|
|
27337
27384
|
{ value: "false", label: "No" }
|
|
27338
27385
|
]
|
|
27339
27386
|
};
|
|
27340
|
-
if (
|
|
27387
|
+
if (field2.type === "multiselect" || field2.type === "string" && field2.options?.length) {
|
|
27341
27388
|
return {
|
|
27342
27389
|
...base,
|
|
27343
27390
|
type: "choice",
|
|
27344
|
-
multiple:
|
|
27345
|
-
allowOther:
|
|
27346
|
-
options:
|
|
27391
|
+
multiple: field2.type === "multiselect",
|
|
27392
|
+
allowOther: field2.custom ?? false,
|
|
27393
|
+
options: field2.options ?? []
|
|
27347
27394
|
};
|
|
27348
27395
|
}
|
|
27349
27396
|
return {
|
|
27350
27397
|
...base,
|
|
27351
27398
|
type: "text",
|
|
27352
|
-
multiline:
|
|
27399
|
+
multiline: field2.type === "string",
|
|
27353
27400
|
secret: false,
|
|
27354
|
-
...
|
|
27355
|
-
...
|
|
27401
|
+
...field2.type === "string" && field2.placeholder ? { placeholder: field2.placeholder } : {},
|
|
27402
|
+
...field2.default !== void 0 ? { prefill: String(field2.default) } : {}
|
|
27356
27403
|
};
|
|
27357
27404
|
});
|
|
27358
27405
|
return {
|
|
@@ -27395,24 +27442,24 @@ async function replyInteraction(client2, pending, command) {
|
|
|
27395
27442
|
return;
|
|
27396
27443
|
}
|
|
27397
27444
|
const answer = {};
|
|
27398
|
-
for (const
|
|
27399
|
-
const values = command.response.answers[
|
|
27445
|
+
for (const field2 of form.fields) {
|
|
27446
|
+
const values = command.response.answers[field2.key] ?? [];
|
|
27400
27447
|
if (!values.length)
|
|
27401
27448
|
continue;
|
|
27402
27449
|
const value = values[0];
|
|
27403
27450
|
if (value === void 0)
|
|
27404
27451
|
continue;
|
|
27405
|
-
if (
|
|
27406
|
-
answer[
|
|
27407
|
-
else if (
|
|
27408
|
-
answer[
|
|
27409
|
-
else if (
|
|
27452
|
+
if (field2.type === "multiselect")
|
|
27453
|
+
answer[field2.key] = values;
|
|
27454
|
+
else if (field2.type === "boolean")
|
|
27455
|
+
answer[field2.key] = value === "true";
|
|
27456
|
+
else if (field2.type === "number" || field2.type === "integer") {
|
|
27410
27457
|
const number4 = Number(value);
|
|
27411
|
-
if (!value.trim() || !Number.isFinite(number4) ||
|
|
27412
|
-
throw new Error(`Invalid number for ${
|
|
27413
|
-
answer[
|
|
27458
|
+
if (!value.trim() || !Number.isFinite(number4) || field2.type === "integer" && !Number.isInteger(number4))
|
|
27459
|
+
throw new Error(`Invalid number for ${field2.key}`);
|
|
27460
|
+
answer[field2.key] = number4;
|
|
27414
27461
|
} else
|
|
27415
|
-
answer[
|
|
27462
|
+
answer[field2.key] = value;
|
|
27416
27463
|
}
|
|
27417
27464
|
await client2.session.form.reply({ sessionID: form.sessionID, formID: form.id, answer });
|
|
27418
27465
|
}
|
|
@@ -3580,10 +3580,10 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
3580
3580
|
const shape = def.shape;
|
|
3581
3581
|
const propValues = {};
|
|
3582
3582
|
for (const key in shape) {
|
|
3583
|
-
const
|
|
3584
|
-
if (
|
|
3583
|
+
const field2 = shape[key]._zod;
|
|
3584
|
+
if (field2.values) {
|
|
3585
3585
|
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
3586
|
-
for (const v of
|
|
3586
|
+
for (const v of field2.values)
|
|
3587
3587
|
propValues[key].add(v);
|
|
3588
3588
|
}
|
|
3589
3589
|
}
|
|
@@ -15223,6 +15223,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
|
|
|
15223
15223
|
cachedInputTokens: count,
|
|
15224
15224
|
cacheWriteInputTokens: count,
|
|
15225
15225
|
cacheKnownInputTokens: count,
|
|
15226
|
+
cacheHitCachedInputTokens: count,
|
|
15227
|
+
cacheHitInputTokens: count,
|
|
15226
15228
|
outputTokens: count,
|
|
15227
15229
|
reasoningOutputTokens: count,
|
|
15228
15230
|
/** USD at the public price, summed over the priced requests only. */
|
|
@@ -15330,6 +15332,51 @@ var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
|
15330
15332
|
var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
|
|
15331
15333
|
var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
|
|
15332
15334
|
|
|
15335
|
+
// ../../shared-contracts/dist/thread-questions.js
|
|
15336
|
+
var field = external_exports.discriminatedUnion("type", [
|
|
15337
|
+
external_exports.object({
|
|
15338
|
+
id: external_exports.string().min(1),
|
|
15339
|
+
type: external_exports.literal("choice"),
|
|
15340
|
+
prompt: external_exports.string(),
|
|
15341
|
+
options: external_exports.array(external_exports.object({
|
|
15342
|
+
value: external_exports.string().min(1),
|
|
15343
|
+
label: external_exports.string(),
|
|
15344
|
+
description: external_exports.string().optional()
|
|
15345
|
+
})).min(1),
|
|
15346
|
+
multiple: external_exports.boolean(),
|
|
15347
|
+
allowOther: external_exports.boolean(),
|
|
15348
|
+
optional: external_exports.boolean()
|
|
15349
|
+
}),
|
|
15350
|
+
external_exports.object({
|
|
15351
|
+
id: external_exports.string().min(1),
|
|
15352
|
+
type: external_exports.literal("text"),
|
|
15353
|
+
prompt: external_exports.string(),
|
|
15354
|
+
multiline: external_exports.boolean(),
|
|
15355
|
+
secret: external_exports.literal(false),
|
|
15356
|
+
optional: external_exports.boolean(),
|
|
15357
|
+
placeholder: external_exports.string().optional(),
|
|
15358
|
+
prefill: external_exports.string().optional()
|
|
15359
|
+
})
|
|
15360
|
+
]);
|
|
15361
|
+
var threadQuestionSchema = external_exports.object({
|
|
15362
|
+
interactionId: external_exports.string().min(1),
|
|
15363
|
+
turnId: external_exports.string().min(1),
|
|
15364
|
+
title: external_exports.string().optional(),
|
|
15365
|
+
questions: external_exports.array(field).min(1)
|
|
15366
|
+
}).refine(({ questions }) => questions.some((q) => q.type === "choice" && q.multiple), {
|
|
15367
|
+
message: "Shared cards require at least one multi-select question"
|
|
15368
|
+
});
|
|
15369
|
+
var threadQuestionsListParamsSchema = external_exports.strictObject({ threadId: external_exports.string().min(1) });
|
|
15370
|
+
var threadQuestionsResultSchema = external_exports.object({ questions: external_exports.array(threadQuestionSchema) });
|
|
15371
|
+
var threadQuestionRespondParamsSchema = external_exports.strictObject({
|
|
15372
|
+
threadId: external_exports.string().min(1),
|
|
15373
|
+
turnId: external_exports.string().min(1),
|
|
15374
|
+
interactionId: external_exports.string().min(1),
|
|
15375
|
+
answers: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())),
|
|
15376
|
+
cancelled: external_exports.boolean().default(false)
|
|
15377
|
+
});
|
|
15378
|
+
var threadQuestionRespondResultSchema = external_exports.object({ accepted: external_exports.literal(true) });
|
|
15379
|
+
|
|
15333
15380
|
// ../../shared-contracts/dist/console.js
|
|
15334
15381
|
var consoleAnnouncementSchema = external_exports.strictObject({
|
|
15335
15382
|
title: external_exports.string().trim().min(1).max(200),
|
|
@@ -16963,26 +17010,26 @@ function parseHostUsage(value) {
|
|
|
16963
17010
|
}
|
|
16964
17011
|
}
|
|
16965
17012
|
const indicators = value.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value.composerIndicators) };
|
|
16966
|
-
for (const
|
|
17013
|
+
for (const field2 of [
|
|
16967
17014
|
"totalCredits",
|
|
16968
17015
|
"contextUsagePercent",
|
|
16969
17016
|
"apiOutputTokensPerSecond"
|
|
16970
17017
|
]) {
|
|
16971
|
-
const candidate = value[
|
|
17018
|
+
const candidate = value[field2];
|
|
16972
17019
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
16973
|
-
throw new Error(`Harness Usage '${
|
|
17020
|
+
throw new Error(`Harness Usage '${field2}' must be a finite non-negative number`);
|
|
16974
17021
|
}
|
|
16975
17022
|
}
|
|
16976
|
-
for (const
|
|
16977
|
-
const candidate = value[
|
|
17023
|
+
for (const field2 of tokenFields) {
|
|
17024
|
+
const candidate = value[field2];
|
|
16978
17025
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
16979
|
-
throw new Error(`Harness Usage '${
|
|
17026
|
+
throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
|
|
16980
17027
|
}
|
|
16981
17028
|
}
|
|
16982
|
-
for (const
|
|
16983
|
-
const candidate = value[
|
|
17029
|
+
for (const field2 of safeIntegerFields) {
|
|
17030
|
+
const candidate = value[field2];
|
|
16984
17031
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
16985
|
-
throw new Error(`Harness Usage '${
|
|
17032
|
+
throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
|
|
16986
17033
|
}
|
|
16987
17034
|
}
|
|
16988
17035
|
if (value.outputTokensPerSecond !== void 0 && (typeof value.outputTokensPerSecond !== "number" || !Number.isFinite(value.outputTokensPerSecond) || value.outputTokensPerSecond < 0)) {
|
|
@@ -16991,10 +17038,10 @@ function parseHostUsage(value) {
|
|
|
16991
17038
|
if (value.totalCostUsd !== void 0 && (typeof value.totalCostUsd !== "number" || !Number.isFinite(value.totalCostUsd) || value.totalCostUsd < 0)) {
|
|
16992
17039
|
throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
|
|
16993
17040
|
}
|
|
16994
|
-
for (const
|
|
16995
|
-
const candidate = value[
|
|
17041
|
+
for (const field2 of percentFields) {
|
|
17042
|
+
const candidate = value[field2];
|
|
16996
17043
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
|
|
16997
|
-
throw new Error(`Harness Usage '${
|
|
17044
|
+
throw new Error(`Harness Usage '${field2}' must be between 0 and 100`);
|
|
16998
17045
|
}
|
|
16999
17046
|
}
|
|
17000
17047
|
if (value.sessionCacheUsage !== void 0) {
|
|
@@ -17065,19 +17112,19 @@ function parseHostUsageRequest(value) {
|
|
|
17065
17112
|
if (typeof value.requestId !== "string" || value.requestId.length === 0) {
|
|
17066
17113
|
throw new Error("Harness Usage request 'requestId' must be a non-empty string");
|
|
17067
17114
|
}
|
|
17068
|
-
for (const
|
|
17069
|
-
const candidate = value[
|
|
17115
|
+
for (const field2 of ["model", "provider"]) {
|
|
17116
|
+
const candidate = value[field2];
|
|
17070
17117
|
if (candidate !== void 0 && (typeof candidate !== "string" || candidate.length === 0)) {
|
|
17071
|
-
throw new Error(`Harness Usage request '${
|
|
17118
|
+
throw new Error(`Harness Usage request '${field2}' must be a non-empty string`);
|
|
17072
17119
|
}
|
|
17073
17120
|
}
|
|
17074
17121
|
if (value.historical !== void 0 && typeof value.historical !== "boolean") {
|
|
17075
17122
|
throw new Error("Harness Usage request 'historical' must be a boolean");
|
|
17076
17123
|
}
|
|
17077
|
-
for (const
|
|
17078
|
-
const candidate = value[
|
|
17124
|
+
for (const field2 of requestTokenFields) {
|
|
17125
|
+
const candidate = value[field2];
|
|
17079
17126
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
17080
|
-
throw new Error(`Harness Usage request '${
|
|
17127
|
+
throw new Error(`Harness Usage request '${field2}' must be a non-negative safe integer`);
|
|
17081
17128
|
}
|
|
17082
17129
|
}
|
|
17083
17130
|
if (value.inputTokens === void 0 || value.outputTokens === void 0) {
|
|
@@ -17804,9 +17851,9 @@ function nestedToolString(value, keys, allowEmpty = false) {
|
|
|
17804
17851
|
if (!isRecord3(value))
|
|
17805
17852
|
return void 0;
|
|
17806
17853
|
for (const key of keys) {
|
|
17807
|
-
const
|
|
17808
|
-
if (typeof
|
|
17809
|
-
return
|
|
17854
|
+
const field2 = value[key];
|
|
17855
|
+
if (typeof field2 === "string" && (allowEmpty || field2.length > 0))
|
|
17856
|
+
return field2;
|
|
17810
17857
|
}
|
|
17811
17858
|
for (const wrapper of ["input", "arguments", "params", "details"]) {
|
|
17812
17859
|
const nested = nestedToolString(value[wrapper], keys, allowEmpty);
|
|
@@ -17819,15 +17866,15 @@ function patchFromResult(result) {
|
|
|
17819
17866
|
if (!isRecord3(result))
|
|
17820
17867
|
return void 0;
|
|
17821
17868
|
for (const key of ["patch", "diff", "unifiedDiff"]) {
|
|
17822
|
-
const
|
|
17823
|
-
if (typeof
|
|
17824
|
-
return
|
|
17869
|
+
const field2 = result[key];
|
|
17870
|
+
if (typeof field2 === "string" && field2.length > 0)
|
|
17871
|
+
return field2;
|
|
17825
17872
|
}
|
|
17826
17873
|
if (isRecord3(result.details)) {
|
|
17827
17874
|
for (const key of ["patch", "diff", "unifiedDiff"]) {
|
|
17828
|
-
const
|
|
17829
|
-
if (typeof
|
|
17830
|
-
return
|
|
17875
|
+
const field2 = result.details[key];
|
|
17876
|
+
if (typeof field2 === "string" && field2.length > 0)
|
|
17877
|
+
return field2;
|
|
17831
17878
|
}
|
|
17832
17879
|
}
|
|
17833
17880
|
return void 0;
|
|
@@ -18321,8 +18368,8 @@ function parsePiSubagentInspection(value) {
|
|
|
18321
18368
|
return null;
|
|
18322
18369
|
if (parsed.error !== void 0 && (!record3(parsed.error) || typeof parsed.error.code !== "string" || typeof parsed.error.message !== "string"))
|
|
18323
18370
|
return null;
|
|
18324
|
-
for (const
|
|
18325
|
-
if (parsed[
|
|
18371
|
+
for (const field2 of ["asyncId", "childId", "status", "task", "finalOutput"]) {
|
|
18372
|
+
if (parsed[field2] !== void 0 && typeof parsed[field2] !== "string")
|
|
18326
18373
|
return null;
|
|
18327
18374
|
}
|
|
18328
18375
|
if (parsed.messages !== void 0 && (!Array.isArray(parsed.messages) || parsed.messages.length > 200 || parsed.messages.some((entry) => !record3(entry) || typeof entry.role !== "string" || typeof entry.text !== "string" || !["text", "toolCall", "toolResult"].includes(String(entry.kind)) || entry.name !== void 0 && typeof entry.name !== "string")))
|
|
@@ -18447,7 +18494,7 @@ function normalizePiThinkingOptions(levels) {
|
|
|
18447
18494
|
label: PI_THINKING_LABELS[id] ?? fallbackThinkingLabel(id)
|
|
18448
18495
|
}));
|
|
18449
18496
|
}
|
|
18450
|
-
function normalizePiModelCatalog(nativeModels, effectiveModel, thinkingLevels, effectiveThinkingOptionId) {
|
|
18497
|
+
function normalizePiModelCatalog(nativeModels, effectiveModel, thinkingLevels, effectiveThinkingOptionId, effectiveModelReasoning = null) {
|
|
18451
18498
|
const byRef = /* @__PURE__ */ new Map();
|
|
18452
18499
|
for (const native of nativeModels) {
|
|
18453
18500
|
const ref = encodePiModelRef(native);
|
|
@@ -18463,12 +18510,21 @@ function normalizePiModelCatalog(nativeModels, effectiveModel, thinkingLevels, e
|
|
|
18463
18510
|
ref,
|
|
18464
18511
|
label: `${native.provider} / ${native.id}`
|
|
18465
18512
|
},
|
|
18466
|
-
reasoning: native.reasoning
|
|
18513
|
+
reasoning: native.reasoning,
|
|
18514
|
+
synthesized: false
|
|
18467
18515
|
});
|
|
18468
18516
|
}
|
|
18469
18517
|
const defaultModel = effectiveModel ? encodePiModelRef(effectiveModel) : void 0;
|
|
18470
|
-
if (defaultModel && !byRef.has(defaultModel.id)) {
|
|
18471
|
-
|
|
18518
|
+
if (effectiveModel && defaultModel && !byRef.has(defaultModel.id)) {
|
|
18519
|
+
const reasoning = effectiveThinkingOptionId && effectiveThinkingOptionId !== "off" || (effectiveModelReasoning ?? Boolean(thinkingLevels && thinkingLevels.some((level) => level !== "off")));
|
|
18520
|
+
byRef.set(defaultModel.id, {
|
|
18521
|
+
model: {
|
|
18522
|
+
ref: defaultModel,
|
|
18523
|
+
label: `${effectiveModel.provider} / ${effectiveModel.id}`
|
|
18524
|
+
},
|
|
18525
|
+
reasoning,
|
|
18526
|
+
synthesized: true
|
|
18527
|
+
});
|
|
18472
18528
|
}
|
|
18473
18529
|
if (thinkingLevels && effectiveThinkingOptionId && !thinkingLevels.includes(effectiveThinkingOptionId)) {
|
|
18474
18530
|
throw new Error("Pi effective Thinking option is absent from the available option catalog");
|
|
@@ -18479,9 +18535,10 @@ function normalizePiModelCatalog(nativeModels, effectiveModel, thinkingLevels, e
|
|
|
18479
18535
|
const thinkingOptions = thinkingLevels ? normalizePiThinkingOptions(PI_DRAFT_THINKING_OPTION_IDS) : [];
|
|
18480
18536
|
const allThinkingOptionIds = thinkingOptions.map(({ id }) => id);
|
|
18481
18537
|
const offThinkingOptionId = thinkingOptions.find(({ id }) => id === "off")?.id;
|
|
18482
|
-
const
|
|
18538
|
+
const effectiveThinkingOptionIds = thinkingLevels ? allThinkingOptionIds.filter((id) => thinkingLevels.includes(id)) : allThinkingOptionIds;
|
|
18539
|
+
const models = [...byRef.values()].map(({ model: model2, reasoning, synthesized }) => ({
|
|
18483
18540
|
...model2,
|
|
18484
|
-
supportedThinkingOptionIds: reasoning ? allThinkingOptionIds : offThinkingOptionId ? [offThinkingOptionId] : []
|
|
18541
|
+
supportedThinkingOptionIds: reasoning ? synthesized ? effectiveThinkingOptionIds : allThinkingOptionIds : offThinkingOptionId ? [offThinkingOptionId] : []
|
|
18485
18542
|
})).sort((left, right) => compareText(left.label, right.label) || compareText(left.ref.id, right.ref.id));
|
|
18486
18543
|
const defaultThinkingOptionId = thinkingOptions.find(({ id }) => id === effectiveThinkingOptionId)?.id;
|
|
18487
18544
|
return harnessModelCatalogSchema.parse({
|
|
@@ -20153,6 +20210,15 @@ var PiRpcUnsupportedCommandError = class extends Error {
|
|
|
20153
20210
|
this.name = "PiRpcUnsupportedCommandError";
|
|
20154
20211
|
}
|
|
20155
20212
|
};
|
|
20213
|
+
var READ_ONLY_COMMANDS = /* @__PURE__ */ new Set([
|
|
20214
|
+
"get_state",
|
|
20215
|
+
"get_commands",
|
|
20216
|
+
"get_entries",
|
|
20217
|
+
"get_session_stats",
|
|
20218
|
+
"get_available_models",
|
|
20219
|
+
"get_available_thinking_levels"
|
|
20220
|
+
]);
|
|
20221
|
+
var MAX_EXPIRED_IDS = 64;
|
|
20156
20222
|
var textDecoder = new TextDecoder("utf-8", { fatal: true });
|
|
20157
20223
|
function isRecord8(value) {
|
|
20158
20224
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -20180,6 +20246,7 @@ function sessionStateData(response) {
|
|
|
20180
20246
|
function parseSessionState(response) {
|
|
20181
20247
|
const data = sessionStateData(response);
|
|
20182
20248
|
const model2 = parseNativeModel(data.model, "state");
|
|
20249
|
+
const modelReasoning = isRecord8(data.model) && typeof data.model.reasoning === "boolean" ? data.model.reasoning : null;
|
|
20183
20250
|
if (!nonBlankString(data.sessionId)) {
|
|
20184
20251
|
throw new PiRpcFaultError("protocolError", "Pi RPC state has no stable Session identity");
|
|
20185
20252
|
}
|
|
@@ -20192,6 +20259,7 @@ function parseSessionState(response) {
|
|
|
20192
20259
|
sessionFile: typeof data.sessionFile === "string" ? data.sessionFile : null,
|
|
20193
20260
|
provider: model2?.provider ?? null,
|
|
20194
20261
|
modelId: model2?.id ?? null,
|
|
20262
|
+
...modelReasoning === null ? {} : { modelReasoning },
|
|
20195
20263
|
thinkingLevel: thinkingLevel?.data ?? null,
|
|
20196
20264
|
contextUsage: optionalPiStateContextUsage(data.contextUsage)
|
|
20197
20265
|
};
|
|
@@ -20375,7 +20443,11 @@ var PiRpcSession = class {
|
|
|
20375
20443
|
#autonomousTurnHandler = null;
|
|
20376
20444
|
#usageHandler = null;
|
|
20377
20445
|
#usageRequestStartedAtMs = null;
|
|
20378
|
-
|
|
20446
|
+
// Pieces of the unterminated frame; joined once at its newline so a large frame (a long
|
|
20447
|
+
// Session's get_entries) costs linear rather than quadratic copying on the Host event loop.
|
|
20448
|
+
#buffer = [];
|
|
20449
|
+
// Ids whose read-only command timed out; Pi may still answer them late.
|
|
20450
|
+
#expired = /* @__PURE__ */ new Set();
|
|
20379
20451
|
#child = null;
|
|
20380
20452
|
#closed = false;
|
|
20381
20453
|
#closePromise = null;
|
|
@@ -20788,11 +20860,13 @@ var PiRpcSession = class {
|
|
|
20788
20860
|
}
|
|
20789
20861
|
}
|
|
20790
20862
|
#push(chunk) {
|
|
20791
|
-
|
|
20792
|
-
let newline =
|
|
20863
|
+
let rest = chunk;
|
|
20864
|
+
let newline = rest.indexOf(10);
|
|
20793
20865
|
while (newline >= 0) {
|
|
20794
|
-
const
|
|
20795
|
-
this.#buffer
|
|
20866
|
+
const tail = rest.subarray(0, newline);
|
|
20867
|
+
const frame = this.#buffer.length === 0 ? tail : Buffer.concat([...this.#buffer, tail]);
|
|
20868
|
+
this.#buffer = [];
|
|
20869
|
+
rest = rest.subarray(newline + 1);
|
|
20796
20870
|
try {
|
|
20797
20871
|
const value = JSON.parse(textDecoder.decode(frame));
|
|
20798
20872
|
if (!isRecord8(value) || typeof value.type !== "string") {
|
|
@@ -20802,8 +20876,10 @@ var PiRpcSession = class {
|
|
|
20802
20876
|
} catch (error51) {
|
|
20803
20877
|
this.#fail(error51 instanceof PiRpcFaultError ? error51 : new PiRpcFaultError("protocolError", `Pi RPC returned invalid JSONL: ${message2(error51)}`));
|
|
20804
20878
|
}
|
|
20805
|
-
newline =
|
|
20879
|
+
newline = rest.indexOf(10);
|
|
20806
20880
|
}
|
|
20881
|
+
if (rest.length !== 0)
|
|
20882
|
+
this.#buffer.push(rest);
|
|
20807
20883
|
}
|
|
20808
20884
|
#handle(value) {
|
|
20809
20885
|
if (value.type === "extension_ui_request" && value.method === "notify" && typeof value.message === "string" && value.message.startsWith(PI_FAST_ACK)) {
|
|
@@ -21055,6 +21131,8 @@ var PiRpcSession = class {
|
|
|
21055
21131
|
return;
|
|
21056
21132
|
}
|
|
21057
21133
|
const pending = this.#pending.get(id);
|
|
21134
|
+
if (!pending && this.#expired.delete(id))
|
|
21135
|
+
return;
|
|
21058
21136
|
if (!pending) {
|
|
21059
21137
|
this.#fail(new PiRpcFaultError("protocolError", "Pi RPC response id is not pending"));
|
|
21060
21138
|
return;
|
|
@@ -21289,6 +21367,12 @@ var PiRpcSession = class {
|
|
|
21289
21367
|
const error51 = new Error(`Pi RPC '${pending.command}' command timed out`);
|
|
21290
21368
|
if (pending.command !== "prompt") {
|
|
21291
21369
|
this.#pending.delete(id);
|
|
21370
|
+
if (READ_ONLY_COMMANDS.has(pending.command)) {
|
|
21371
|
+
this.#expired.add(id);
|
|
21372
|
+
if (this.#expired.size > MAX_EXPIRED_IDS) {
|
|
21373
|
+
this.#expired.delete(this.#expired.values().next().value);
|
|
21374
|
+
}
|
|
21375
|
+
}
|
|
21292
21376
|
pending.reject(error51);
|
|
21293
21377
|
return;
|
|
21294
21378
|
}
|
|
@@ -21491,9 +21575,9 @@ function outputText(output) {
|
|
|
21491
21575
|
function stringField(value, key) {
|
|
21492
21576
|
if (!isRecord9(value))
|
|
21493
21577
|
return void 0;
|
|
21494
|
-
const
|
|
21495
|
-
if (typeof
|
|
21496
|
-
return
|
|
21578
|
+
const field2 = value[key];
|
|
21579
|
+
if (typeof field2 === "string" && field2.length > 0)
|
|
21580
|
+
return field2;
|
|
21497
21581
|
if (isRecord9(value.input)) {
|
|
21498
21582
|
const nested = value.input[key];
|
|
21499
21583
|
if (typeof nested === "string" && nested.length > 0)
|
|
@@ -21509,8 +21593,8 @@ function stringField(value, key) {
|
|
|
21509
21593
|
function numberField(value, key) {
|
|
21510
21594
|
if (!isRecord9(value))
|
|
21511
21595
|
return void 0;
|
|
21512
|
-
const
|
|
21513
|
-
return typeof
|
|
21596
|
+
const field2 = value[key];
|
|
21597
|
+
return typeof field2 === "number" || field2 === null ? field2 : void 0;
|
|
21514
21598
|
}
|
|
21515
21599
|
function normalizeToolName(name) {
|
|
21516
21600
|
const lower = name.toLowerCase();
|
|
@@ -22957,7 +23041,7 @@ var PiAdapter = class {
|
|
|
22957
23041
|
stage = "capabilities";
|
|
22958
23042
|
const thinkingLevels = await transport.getAvailableThinkingLevels();
|
|
22959
23043
|
this.#thinkingSelectionSupported = thinkingLevels !== null;
|
|
22960
|
-
const normalized = normalizePiModelCatalog(models, nativeModelFromState(transport.state), thinkingLevels, transport.state.thinkingLevel);
|
|
23044
|
+
const normalized = normalizePiModelCatalog(models, nativeModelFromState(transport.state), thinkingLevels, transport.state.thinkingLevel, transport.state.modelReasoning ?? null);
|
|
22961
23045
|
const fastModels = await transport.supportsFastMode?.() ? piFastModelKeys(models) : /* @__PURE__ */ new Set();
|
|
22962
23046
|
const catalog = withPiFast(normalized, fastModels);
|
|
22963
23047
|
await transport.close();
|