@karlorz/codexhost-cli-win32-x64 0.14.0-3 → 0.14.0-5
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 +62 -6
- package/app/console-web.js +90 -34
- package/app/cpa-live-voice-hook.js +187 -18
- package/app/desktop-controller.mjs +59 -3
- package/app/host-runtime.mjs +621 -405
- package/app/plugins/antigravity/plugin.mjs +62 -3
- package/app/plugins/claude-code/plugin.mjs +83 -24
- package/app/plugins/codebuddy/plugin.mjs +80 -21
- package/app/plugins/codex-usage/plugin.mjs +84 -28
- package/app/plugins/copilot/plugin.mjs +112 -53
- package/app/plugins/cursor-cli/plugin.mjs +80 -21
- package/app/plugins/deepseek-harness/plugin.mjs +91 -32
- package/app/plugins/grok/plugin.mjs +411 -87
- package/app/plugins/hermes/plugin.mjs +62 -3
- package/app/plugins/kimi-code/plugin.mjs +74 -15
- package/app/plugins/kiro-cli/plugin.mjs +74 -15
- package/app/plugins/omp/plugin.mjs +94 -35
- package/app/plugins/opencode/plugin.mjs +116 -57
- package/app/plugins/pi/plugin.mjs +96 -37
- package/app/plugins/qoder/plugin.mjs +84 -25
- package/app/plugins/qoder-cn/plugin.mjs +84 -25
- package/app/plugins/workbuddy/plugin.mjs +80 -21
- package/app/plugins/zcode/plugin.mjs +85 -26
- package/app/renderer-extension.js +916 -138
- package/bin/codexhost.exe +0 -0
- package/libexec/codexhost-node-repl.exe +0 -0
- package/libexec/codexhost-shim.exe +0 -0
- package/libexec/codexhost-updater.exe +0 -0
- package/package.json +1 -1
package/app/host-runtime.mjs
CHANGED
|
@@ -8462,10 +8462,10 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
8462
8462
|
const shape = def.shape;
|
|
8463
8463
|
const propValues = {};
|
|
8464
8464
|
for (const key in shape) {
|
|
8465
|
-
const
|
|
8466
|
-
if (
|
|
8465
|
+
const field2 = shape[key]._zod;
|
|
8466
|
+
if (field2.values) {
|
|
8467
8467
|
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
8468
|
-
for (const v of
|
|
8468
|
+
for (const v of field2.values)
|
|
8469
8469
|
propValues[key].add(v);
|
|
8470
8470
|
}
|
|
8471
8471
|
}
|
|
@@ -20327,6 +20327,65 @@ function isConsoleHostMethod(method) {
|
|
|
20327
20327
|
// packages/shared-contracts/dist/version.js
|
|
20328
20328
|
var WORKSPACE_CONTRACT_VERSION = 1;
|
|
20329
20329
|
|
|
20330
|
+
// packages/shared-contracts/dist/thread-questions.js
|
|
20331
|
+
var THREAD_QUESTIONS_LIST_METHOD = "codexhost/thread/questions/list";
|
|
20332
|
+
var THREAD_QUESTION_RESPOND_METHOD = "codexhost/thread/question/respond";
|
|
20333
|
+
var THREAD_QUESTION_ACTIVITY_METHOD = "codexhost/thread/question/activity";
|
|
20334
|
+
var threadQuestionsParamsSchema = external_exports.strictObject({ threadId: hostThreadIdSchema });
|
|
20335
|
+
var field = { id: external_exports.string().min(1), prompt: external_exports.string(), optional: external_exports.boolean() };
|
|
20336
|
+
var questionAutoResolutionSchema = external_exports.strictObject({
|
|
20337
|
+
deadlineUnixMs: external_exports.number().int().min(0).max(864e13),
|
|
20338
|
+
action: external_exports.enum(["recommended", "decline"]),
|
|
20339
|
+
resetOnActivity: external_exports.boolean().optional()
|
|
20340
|
+
});
|
|
20341
|
+
var threadQuestionSchema = external_exports.strictObject({
|
|
20342
|
+
interactionId: hostInteractionIdSchema,
|
|
20343
|
+
turnId: hostTurnIdSchema,
|
|
20344
|
+
title: external_exports.string().optional(),
|
|
20345
|
+
expiresAt: external_exports.string().optional(),
|
|
20346
|
+
autoResolution: questionAutoResolutionSchema.optional(),
|
|
20347
|
+
questions: external_exports.array(external_exports.discriminatedUnion("type", [
|
|
20348
|
+
external_exports.strictObject({
|
|
20349
|
+
...field,
|
|
20350
|
+
type: external_exports.literal("choice"),
|
|
20351
|
+
multiple: external_exports.boolean(),
|
|
20352
|
+
allowOther: external_exports.boolean(),
|
|
20353
|
+
options: external_exports.array(external_exports.strictObject({
|
|
20354
|
+
value: external_exports.string().min(1),
|
|
20355
|
+
label: external_exports.string(),
|
|
20356
|
+
description: external_exports.string().optional()
|
|
20357
|
+
})).min(1)
|
|
20358
|
+
}),
|
|
20359
|
+
external_exports.strictObject({
|
|
20360
|
+
...field,
|
|
20361
|
+
type: external_exports.literal("text"),
|
|
20362
|
+
multiline: external_exports.boolean(),
|
|
20363
|
+
secret: external_exports.literal(false),
|
|
20364
|
+
placeholder: external_exports.string().optional(),
|
|
20365
|
+
prefill: external_exports.string().optional()
|
|
20366
|
+
})
|
|
20367
|
+
])).min(1)
|
|
20368
|
+
});
|
|
20369
|
+
var threadQuestionsResultSchema = external_exports.strictObject({
|
|
20370
|
+
questions: external_exports.array(threadQuestionSchema)
|
|
20371
|
+
});
|
|
20372
|
+
var threadQuestionRespondParamsSchema = external_exports.strictObject({
|
|
20373
|
+
threadId: hostThreadIdSchema,
|
|
20374
|
+
interactionId: hostInteractionIdSchema,
|
|
20375
|
+
turnId: hostTurnIdSchema,
|
|
20376
|
+
answers: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())),
|
|
20377
|
+
cancelled: external_exports.boolean().optional()
|
|
20378
|
+
});
|
|
20379
|
+
var threadQuestionRespondResultSchema = external_exports.strictObject({ accepted: external_exports.literal(true) });
|
|
20380
|
+
var threadQuestionActivityParamsSchema = external_exports.strictObject({
|
|
20381
|
+
threadId: hostThreadIdSchema,
|
|
20382
|
+
interactionId: hostInteractionIdSchema,
|
|
20383
|
+
turnId: hostTurnIdSchema
|
|
20384
|
+
});
|
|
20385
|
+
var threadQuestionActivityResultSchema = external_exports.strictObject({
|
|
20386
|
+
autoResolution: questionAutoResolutionSchema.nullable()
|
|
20387
|
+
});
|
|
20388
|
+
|
|
20330
20389
|
// packages/shared-contracts/dist/idle-release.js
|
|
20331
20390
|
var IDLE_RELEASE_SETTINGS_METHOD = "codexhost/settings/idle-release/set";
|
|
20332
20391
|
var IDLE_RELEASE_TIMEOUT_MINUTES_MIN = 5;
|
|
@@ -22657,6 +22716,382 @@ async function hangupRealtimeCall(gateway, callId) {
|
|
|
22657
22716
|
if (!response.ok && response.status !== 404) throw new Error("Realtime call hangup unconfirmed");
|
|
22658
22717
|
}
|
|
22659
22718
|
|
|
22719
|
+
// packages/harness-adapter/dist/account-credits.js
|
|
22720
|
+
function parseHarnessAccountCredits(value2) {
|
|
22721
|
+
if (!value2 || typeof value2 !== "object" || Array.isArray(value2))
|
|
22722
|
+
return null;
|
|
22723
|
+
const publicValue = { ...value2 };
|
|
22724
|
+
delete publicValue.fetchedAt;
|
|
22725
|
+
const parsed2 = accountCreditsSnapshotSchema.safeParse(publicValue);
|
|
22726
|
+
return parsed2.success ? parsed2.data : null;
|
|
22727
|
+
}
|
|
22728
|
+
|
|
22729
|
+
// packages/harness-adapter/dist/question.js
|
|
22730
|
+
function invalidRequest(message2) {
|
|
22731
|
+
return { code: "invalidRequest", message: message2, retryable: false };
|
|
22732
|
+
}
|
|
22733
|
+
function validateHostQuestionResponse(interaction, response) {
|
|
22734
|
+
const questionIds = new Set(interaction.questions.map(({ id: id2 }) => id2));
|
|
22735
|
+
if (response.cancelled) {
|
|
22736
|
+
return Object.keys(response.answers).length === 0 ? null : invalidRequest("Cancelled Question Response must not contain answers");
|
|
22737
|
+
}
|
|
22738
|
+
for (const answerId of Object.keys(response.answers)) {
|
|
22739
|
+
if (!questionIds.has(answerId)) {
|
|
22740
|
+
return invalidRequest("Question Response contains an unknown Question ID");
|
|
22741
|
+
}
|
|
22742
|
+
}
|
|
22743
|
+
for (const question of interaction.questions) {
|
|
22744
|
+
const answers = response.answers[question.id] ?? [];
|
|
22745
|
+
if (new Set(answers).size !== answers.length) {
|
|
22746
|
+
return invalidRequest("Question Response contains duplicate answers");
|
|
22747
|
+
}
|
|
22748
|
+
if (!question.optional && answers.length === 0) {
|
|
22749
|
+
return invalidRequest("Question Response omits a required answer");
|
|
22750
|
+
}
|
|
22751
|
+
if (question.type === "text") {
|
|
22752
|
+
if (answers.length > 1) {
|
|
22753
|
+
return invalidRequest("Text Question accepts at most one answer");
|
|
22754
|
+
}
|
|
22755
|
+
continue;
|
|
22756
|
+
}
|
|
22757
|
+
if (!question.multiple && answers.length > 1) {
|
|
22758
|
+
return invalidRequest("Single-choice Question accepts at most one answer");
|
|
22759
|
+
}
|
|
22760
|
+
const declared = new Set(question.options.map(({ value: value2 }) => value2));
|
|
22761
|
+
if (!question.allowOther && answers.some((answer) => !declared.has(answer))) {
|
|
22762
|
+
return invalidRequest("Question Response contains an undeclared choice");
|
|
22763
|
+
}
|
|
22764
|
+
}
|
|
22765
|
+
return null;
|
|
22766
|
+
}
|
|
22767
|
+
|
|
22768
|
+
// packages/harness-adapter/dist/output-channel.js
|
|
22769
|
+
var HarnessOutputChannel = class {
|
|
22770
|
+
outputs;
|
|
22771
|
+
#consumerCreated = false;
|
|
22772
|
+
#ended = false;
|
|
22773
|
+
#pending = [];
|
|
22774
|
+
#values = [];
|
|
22775
|
+
constructor() {
|
|
22776
|
+
this.outputs = {
|
|
22777
|
+
[Symbol.asyncIterator]: () => {
|
|
22778
|
+
if (this.#consumerCreated) {
|
|
22779
|
+
throw new Error("Harness outputs allow only one consumer");
|
|
22780
|
+
}
|
|
22781
|
+
this.#consumerCreated = true;
|
|
22782
|
+
return {
|
|
22783
|
+
next: () => this.#next()
|
|
22784
|
+
};
|
|
22785
|
+
}
|
|
22786
|
+
};
|
|
22787
|
+
}
|
|
22788
|
+
emit(value2) {
|
|
22789
|
+
if (this.#ended)
|
|
22790
|
+
return false;
|
|
22791
|
+
const resolve = this.#pending.shift();
|
|
22792
|
+
if (resolve)
|
|
22793
|
+
resolve({ done: false, value: value2 });
|
|
22794
|
+
else
|
|
22795
|
+
this.#values.push(value2);
|
|
22796
|
+
return true;
|
|
22797
|
+
}
|
|
22798
|
+
end() {
|
|
22799
|
+
if (this.#ended)
|
|
22800
|
+
return;
|
|
22801
|
+
this.#ended = true;
|
|
22802
|
+
if (this.#values.length !== 0)
|
|
22803
|
+
return;
|
|
22804
|
+
for (const resolve of this.#pending.splice(0))
|
|
22805
|
+
resolve({ done: true, value: void 0 });
|
|
22806
|
+
}
|
|
22807
|
+
#next() {
|
|
22808
|
+
const value2 = this.#values.shift();
|
|
22809
|
+
if (value2 !== void 0)
|
|
22810
|
+
return Promise.resolve({ done: false, value: value2 });
|
|
22811
|
+
if (this.#ended)
|
|
22812
|
+
return Promise.resolve({ done: true, value: void 0 });
|
|
22813
|
+
return new Promise((resolve) => this.#pending.push(resolve));
|
|
22814
|
+
}
|
|
22815
|
+
};
|
|
22816
|
+
|
|
22817
|
+
// packages/harness-adapter/dist/usage.js
|
|
22818
|
+
var hostDerivedUsageFields = [
|
|
22819
|
+
"sessionCacheHitRatePercent",
|
|
22820
|
+
"timeToFirstOutputMs",
|
|
22821
|
+
"costSource",
|
|
22822
|
+
"unpricedModels"
|
|
22823
|
+
];
|
|
22824
|
+
var tokenFields = [
|
|
22825
|
+
"inputTokens",
|
|
22826
|
+
"cachedInputTokens",
|
|
22827
|
+
"cacheWriteInputTokens",
|
|
22828
|
+
"outputTokens",
|
|
22829
|
+
"reasoningOutputTokens",
|
|
22830
|
+
"totalTokens",
|
|
22831
|
+
"contextWindowTokens",
|
|
22832
|
+
"contextUsedTokens"
|
|
22833
|
+
];
|
|
22834
|
+
var safeIntegerFields = [
|
|
22835
|
+
"planFiveHourResetsAtUnix",
|
|
22836
|
+
"planSevenDayResetsAtUnix",
|
|
22837
|
+
"timeToFirstOutputMs"
|
|
22838
|
+
];
|
|
22839
|
+
var percentFields = [
|
|
22840
|
+
"cacheHitRatePercent",
|
|
22841
|
+
"sessionCacheHitRatePercent",
|
|
22842
|
+
"planFiveHourUsedPercent",
|
|
22843
|
+
"planSevenDayUsedPercent"
|
|
22844
|
+
];
|
|
22845
|
+
var usageFields = /* @__PURE__ */ new Set([
|
|
22846
|
+
...tokenFields,
|
|
22847
|
+
...safeIntegerFields,
|
|
22848
|
+
...percentFields,
|
|
22849
|
+
"sessionCacheUsage",
|
|
22850
|
+
"composerIndicators",
|
|
22851
|
+
"totalCostUsd",
|
|
22852
|
+
"totalCredits",
|
|
22853
|
+
"contextUsagePercent",
|
|
22854
|
+
"outputTokensPerSecond",
|
|
22855
|
+
"apiOutputTokensPerSecond",
|
|
22856
|
+
"costSource",
|
|
22857
|
+
"unpricedModels"
|
|
22858
|
+
]);
|
|
22859
|
+
function isRecord(value2) {
|
|
22860
|
+
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
22861
|
+
}
|
|
22862
|
+
function parseHostUsage(value2) {
|
|
22863
|
+
if (!isRecord(value2))
|
|
22864
|
+
throw new Error("Harness Usage must be an object");
|
|
22865
|
+
const keys = Object.keys(value2);
|
|
22866
|
+
if (keys.length === 0)
|
|
22867
|
+
throw new Error("Harness Usage must contain a reliable field");
|
|
22868
|
+
for (const key of keys) {
|
|
22869
|
+
if (!usageFields.has(key)) {
|
|
22870
|
+
throw new Error(`Harness Usage contains unknown field '${key}'`);
|
|
22871
|
+
}
|
|
22872
|
+
}
|
|
22873
|
+
const indicators = value2.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value2.composerIndicators) };
|
|
22874
|
+
for (const field2 of [
|
|
22875
|
+
"totalCredits",
|
|
22876
|
+
"contextUsagePercent",
|
|
22877
|
+
"apiOutputTokensPerSecond"
|
|
22878
|
+
]) {
|
|
22879
|
+
const candidate = value2[field2];
|
|
22880
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
22881
|
+
throw new Error(`Harness Usage '${field2}' must be a finite non-negative number`);
|
|
22882
|
+
}
|
|
22883
|
+
}
|
|
22884
|
+
for (const field2 of tokenFields) {
|
|
22885
|
+
const candidate = value2[field2];
|
|
22886
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
22887
|
+
throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
|
|
22888
|
+
}
|
|
22889
|
+
}
|
|
22890
|
+
for (const field2 of safeIntegerFields) {
|
|
22891
|
+
const candidate = value2[field2];
|
|
22892
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
22893
|
+
throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
|
|
22894
|
+
}
|
|
22895
|
+
}
|
|
22896
|
+
if (value2.outputTokensPerSecond !== void 0 && (typeof value2.outputTokensPerSecond !== "number" || !Number.isFinite(value2.outputTokensPerSecond) || value2.outputTokensPerSecond < 0)) {
|
|
22897
|
+
throw new Error("Harness Usage 'outputTokensPerSecond' must be a finite non-negative number");
|
|
22898
|
+
}
|
|
22899
|
+
if (value2.totalCostUsd !== void 0 && (typeof value2.totalCostUsd !== "number" || !Number.isFinite(value2.totalCostUsd) || value2.totalCostUsd < 0)) {
|
|
22900
|
+
throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
|
|
22901
|
+
}
|
|
22902
|
+
for (const field2 of percentFields) {
|
|
22903
|
+
const candidate = value2[field2];
|
|
22904
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
|
|
22905
|
+
throw new Error(`Harness Usage '${field2}' must be between 0 and 100`);
|
|
22906
|
+
}
|
|
22907
|
+
}
|
|
22908
|
+
if (value2.sessionCacheUsage !== void 0) {
|
|
22909
|
+
const totals2 = value2.sessionCacheUsage;
|
|
22910
|
+
if (!isRecord(totals2) || Object.keys(totals2).some((key) => key !== "inputTokens" && key !== "cachedInputTokens") || typeof totals2.inputTokens !== "number" || !Number.isSafeInteger(totals2.inputTokens) || totals2.inputTokens < 0 || typeof totals2.cachedInputTokens !== "number" || !Number.isSafeInteger(totals2.cachedInputTokens) || totals2.cachedInputTokens < 0 || totals2.cachedInputTokens > totals2.inputTokens) {
|
|
22911
|
+
throw new Error("Harness Usage 'sessionCacheUsage' must contain complete bounded token totals");
|
|
22912
|
+
}
|
|
22913
|
+
}
|
|
22914
|
+
const hasContextUsed = value2.contextUsedTokens !== void 0;
|
|
22915
|
+
const hasContextWindow = value2.contextWindowTokens !== void 0;
|
|
22916
|
+
if (hasContextUsed !== hasContextWindow) {
|
|
22917
|
+
throw new Error("Harness Usage context fields must be provided together");
|
|
22918
|
+
}
|
|
22919
|
+
if (hasContextWindow && value2.contextWindowTokens === 0) {
|
|
22920
|
+
throw new Error("Harness Usage 'contextWindowTokens' must be greater than zero");
|
|
22921
|
+
}
|
|
22922
|
+
if (value2.planFiveHourResetsAtUnix !== void 0 && value2.planFiveHourUsedPercent === void 0) {
|
|
22923
|
+
throw new Error("Harness Usage 'planFiveHourResetsAtUnix' must be provided with 'planFiveHourUsedPercent'");
|
|
22924
|
+
}
|
|
22925
|
+
if (value2.planSevenDayResetsAtUnix !== void 0 && value2.planSevenDayUsedPercent === void 0) {
|
|
22926
|
+
throw new Error("Harness Usage 'planSevenDayResetsAtUnix' must be provided with 'planSevenDayUsedPercent'");
|
|
22927
|
+
}
|
|
22928
|
+
if (value2.costSource !== void 0) {
|
|
22929
|
+
if (value2.costSource !== "publicPrice" && value2.costSource !== "native") {
|
|
22930
|
+
throw new Error("Harness Usage 'costSource' must be 'publicPrice' or 'native'");
|
|
22931
|
+
}
|
|
22932
|
+
if (value2.totalCostUsd === void 0) {
|
|
22933
|
+
throw new Error("Harness Usage 'costSource' must be provided with 'totalCostUsd'");
|
|
22934
|
+
}
|
|
22935
|
+
}
|
|
22936
|
+
if (value2.unpricedModels !== void 0) {
|
|
22937
|
+
const models = value2.unpricedModels;
|
|
22938
|
+
if (!Array.isArray(models) || models.length === 0 || !models.every((model2) => typeof model2 === "string" && model2.length > 0)) {
|
|
22939
|
+
throw new Error("Harness Usage 'unpricedModels' must be a non-empty list of Model IDs");
|
|
22940
|
+
}
|
|
22941
|
+
if (value2.costSource !== "publicPrice") {
|
|
22942
|
+
throw new Error("Harness Usage 'unpricedModels' must be provided with a 'publicPrice' cost");
|
|
22943
|
+
}
|
|
22944
|
+
return { ...value2, ...indicators, unpricedModels: [...models] };
|
|
22945
|
+
}
|
|
22946
|
+
return { ...value2, ...indicators };
|
|
22947
|
+
}
|
|
22948
|
+
var requestTokenFields = [
|
|
22949
|
+
"inputTokens",
|
|
22950
|
+
"cachedInputTokens",
|
|
22951
|
+
"cacheWriteInputTokens",
|
|
22952
|
+
"cacheWrite1hInputTokens",
|
|
22953
|
+
"outputTokens",
|
|
22954
|
+
"reasoningOutputTokens",
|
|
22955
|
+
"startedAtMs",
|
|
22956
|
+
"completedAtMs"
|
|
22957
|
+
];
|
|
22958
|
+
var requestFields = /* @__PURE__ */ new Set([
|
|
22959
|
+
...requestTokenFields,
|
|
22960
|
+
"requestId",
|
|
22961
|
+
"historical",
|
|
22962
|
+
"model",
|
|
22963
|
+
"provider"
|
|
22964
|
+
]);
|
|
22965
|
+
function parseHostUsageRequest(value2) {
|
|
22966
|
+
if (!isRecord(value2))
|
|
22967
|
+
throw new Error("Harness Usage request must be an object");
|
|
22968
|
+
for (const key of Object.keys(value2)) {
|
|
22969
|
+
if (!requestFields.has(key)) {
|
|
22970
|
+
throw new Error(`Harness Usage request contains unknown field '${key}'`);
|
|
22971
|
+
}
|
|
22972
|
+
}
|
|
22973
|
+
if (typeof value2.requestId !== "string" || value2.requestId.length === 0) {
|
|
22974
|
+
throw new Error("Harness Usage request 'requestId' must be a non-empty string");
|
|
22975
|
+
}
|
|
22976
|
+
for (const field2 of ["model", "provider"]) {
|
|
22977
|
+
const candidate = value2[field2];
|
|
22978
|
+
if (candidate !== void 0 && (typeof candidate !== "string" || candidate.length === 0)) {
|
|
22979
|
+
throw new Error(`Harness Usage request '${field2}' must be a non-empty string`);
|
|
22980
|
+
}
|
|
22981
|
+
}
|
|
22982
|
+
if (value2.historical !== void 0 && typeof value2.historical !== "boolean") {
|
|
22983
|
+
throw new Error("Harness Usage request 'historical' must be a boolean");
|
|
22984
|
+
}
|
|
22985
|
+
for (const field2 of requestTokenFields) {
|
|
22986
|
+
const candidate = value2[field2];
|
|
22987
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
22988
|
+
throw new Error(`Harness Usage request '${field2}' must be a non-negative safe integer`);
|
|
22989
|
+
}
|
|
22990
|
+
}
|
|
22991
|
+
if (value2.inputTokens === void 0 || value2.outputTokens === void 0) {
|
|
22992
|
+
throw new Error("Harness Usage request must contain 'inputTokens' and 'outputTokens'");
|
|
22993
|
+
}
|
|
22994
|
+
const request = value2;
|
|
22995
|
+
if ((request.cachedInputTokens ?? 0) + (request.cacheWriteInputTokens ?? 0) > request.inputTokens) {
|
|
22996
|
+
throw new Error("Harness Usage request cache Tokens must not exceed 'inputTokens'");
|
|
22997
|
+
}
|
|
22998
|
+
if ((request.reasoningOutputTokens ?? 0) > request.outputTokens) {
|
|
22999
|
+
throw new Error("Harness Usage request 'reasoningOutputTokens' must not exceed 'outputTokens'");
|
|
23000
|
+
}
|
|
23001
|
+
if (request.cacheWrite1hInputTokens !== void 0 && request.cacheWrite1hInputTokens > (request.cacheWriteInputTokens ?? -1)) {
|
|
23002
|
+
throw new Error("Harness Usage request 'cacheWrite1hInputTokens' must not exceed 'cacheWriteInputTokens'");
|
|
23003
|
+
}
|
|
23004
|
+
if (request.startedAtMs === void 0 !== (request.completedAtMs === void 0)) {
|
|
23005
|
+
throw new Error("Harness Usage request timing fields must be provided together");
|
|
23006
|
+
}
|
|
23007
|
+
if (request.startedAtMs !== void 0 && request.completedAtMs !== void 0 && request.completedAtMs < request.startedAtMs) {
|
|
23008
|
+
throw new Error("Harness Usage request 'completedAtMs' must not precede 'startedAtMs'");
|
|
23009
|
+
}
|
|
23010
|
+
return { ...request };
|
|
23011
|
+
}
|
|
23012
|
+
|
|
23013
|
+
// packages/harness-adapter/dist/live-command-catalog.js
|
|
23014
|
+
var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
|
|
23015
|
+
// Session lifecycle
|
|
23016
|
+
"branch",
|
|
23017
|
+
"clear",
|
|
23018
|
+
"exit",
|
|
23019
|
+
"fork",
|
|
23020
|
+
"fresh",
|
|
23021
|
+
"new",
|
|
23022
|
+
"quit",
|
|
23023
|
+
"rename",
|
|
23024
|
+
"rename-chat",
|
|
23025
|
+
"reset",
|
|
23026
|
+
"resume",
|
|
23027
|
+
"rewind",
|
|
23028
|
+
"session",
|
|
23029
|
+
"sessions",
|
|
23030
|
+
// Desktop-owned configuration
|
|
23031
|
+
"autocompact",
|
|
23032
|
+
"color",
|
|
23033
|
+
"config",
|
|
23034
|
+
"effort",
|
|
23035
|
+
"fast",
|
|
23036
|
+
"keybindings",
|
|
23037
|
+
"model",
|
|
23038
|
+
"models",
|
|
23039
|
+
"output-style",
|
|
23040
|
+
"permissions",
|
|
23041
|
+
"settings",
|
|
23042
|
+
"statusline",
|
|
23043
|
+
"terminal-setup",
|
|
23044
|
+
"theme",
|
|
23045
|
+
"vim",
|
|
23046
|
+
// Trust and approval policy
|
|
23047
|
+
"always-approve",
|
|
23048
|
+
"auto-mode-setup",
|
|
23049
|
+
// Native login
|
|
23050
|
+
"login",
|
|
23051
|
+
"logout",
|
|
23052
|
+
// Work outliving the Turn
|
|
23053
|
+
"autopilot",
|
|
23054
|
+
"background",
|
|
23055
|
+
"bg",
|
|
23056
|
+
"goal",
|
|
23057
|
+
"jobs",
|
|
23058
|
+
"loop",
|
|
23059
|
+
"multitask",
|
|
23060
|
+
"queue",
|
|
23061
|
+
"remote-control",
|
|
23062
|
+
"schedule",
|
|
23063
|
+
"steer",
|
|
23064
|
+
// Native terminal UI
|
|
23065
|
+
"copy",
|
|
23066
|
+
"debug",
|
|
23067
|
+
"feedback",
|
|
23068
|
+
"heapdump",
|
|
23069
|
+
"share",
|
|
23070
|
+
"shell",
|
|
23071
|
+
// Plugin and MCP management
|
|
23072
|
+
"marketplace",
|
|
23073
|
+
"mcp",
|
|
23074
|
+
"plugins",
|
|
23075
|
+
"reload-plugins"
|
|
23076
|
+
]);
|
|
23077
|
+
var COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES = ["__", "hooks-"];
|
|
23078
|
+
function isExcludedLiveCommand(name, kind, extra = {}) {
|
|
23079
|
+
const normalized = name.trim().replace(/^\//u, "");
|
|
23080
|
+
if (new Set(extra.names ?? []).has(normalized))
|
|
23081
|
+
return true;
|
|
23082
|
+
if (extra.prefixes?.some((prefix) => normalized.startsWith(prefix)))
|
|
23083
|
+
return true;
|
|
23084
|
+
if (kind === "skill")
|
|
23085
|
+
return false;
|
|
23086
|
+
return COMMON_EXCLUDED_LIVE_COMMANDS.has(normalized) || COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES.some((prefix) => normalized.startsWith(prefix));
|
|
23087
|
+
}
|
|
23088
|
+
|
|
23089
|
+
// packages/harness-adapter/dist/index.js
|
|
23090
|
+
var packageMetadata = {
|
|
23091
|
+
name: "@codexhost/harness-adapter",
|
|
23092
|
+
contractVersion: WORKSPACE_CONTRACT_VERSION
|
|
23093
|
+
};
|
|
23094
|
+
|
|
22660
23095
|
// packages/host-runtime/src/native-voice-gateway.ts
|
|
22661
23096
|
var RESPONSE_HEADERS = ["content-type", "location", "retry-after"];
|
|
22662
23097
|
var MAX_RESPONSE_BYTES = 16 << 20;
|
|
@@ -22898,12 +23333,12 @@ function createLocalPageOpener(environment) {
|
|
|
22898
23333
|
// packages/desktop-control/dist/cdp-client.js
|
|
22899
23334
|
function cdpExceptionMessage(details, fallback) {
|
|
22900
23335
|
const exception = details.exception;
|
|
22901
|
-
if (
|
|
23336
|
+
if (isRecord2(exception) && typeof exception.description === "string" && exception.description) {
|
|
22902
23337
|
return exception.description;
|
|
22903
23338
|
}
|
|
22904
23339
|
return typeof details.text === "string" && details.text ? details.text : fallback;
|
|
22905
23340
|
}
|
|
22906
|
-
function
|
|
23341
|
+
function isRecord2(value2) {
|
|
22907
23342
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
22908
23343
|
}
|
|
22909
23344
|
function loopbackUrl(value2, protocols) {
|
|
@@ -22920,7 +23355,7 @@ function optionalText(value2) {
|
|
|
22920
23355
|
return typeof value2 === "string" && value2.length > 0 ? value2 : null;
|
|
22921
23356
|
}
|
|
22922
23357
|
function parseTarget(value2) {
|
|
22923
|
-
if (!
|
|
23358
|
+
if (!isRecord2(value2))
|
|
22924
23359
|
throw new Error("CDP target must be an object");
|
|
22925
23360
|
const id2 = optionalText(value2.id);
|
|
22926
23361
|
const type = optionalText(value2.type);
|
|
@@ -22955,12 +23390,12 @@ function messageText(value2) {
|
|
|
22955
23390
|
throw new Error("CDP WebSocket returned a non-text message");
|
|
22956
23391
|
}
|
|
22957
23392
|
function parseResponse(value2) {
|
|
22958
|
-
if (!
|
|
23393
|
+
if (!isRecord2(value2) || typeof value2.id !== "number")
|
|
22959
23394
|
return null;
|
|
22960
23395
|
const response = { id: value2.id };
|
|
22961
23396
|
if ("result" in value2)
|
|
22962
23397
|
response.result = value2.result;
|
|
22963
|
-
if (
|
|
23398
|
+
if (isRecord2(value2.error)) {
|
|
22964
23399
|
response.error = {
|
|
22965
23400
|
...typeof value2.error.code === "number" ? { code: value2.error.code } : {},
|
|
22966
23401
|
...typeof value2.error.message === "string" ? { message: value2.error.message } : {}
|
|
@@ -23065,12 +23500,12 @@ var CdpClient = class _CdpClient {
|
|
|
23065
23500
|
awaitPromise: true,
|
|
23066
23501
|
returnByValue: true
|
|
23067
23502
|
});
|
|
23068
|
-
if (!
|
|
23503
|
+
if (!isRecord2(response))
|
|
23069
23504
|
throw new Error("Runtime.evaluate returned an invalid result");
|
|
23070
|
-
if (
|
|
23505
|
+
if (isRecord2(response.exceptionDetails)) {
|
|
23071
23506
|
throw new Error(cdpExceptionMessage(response.exceptionDetails, "Renderer evaluation failed"));
|
|
23072
23507
|
}
|
|
23073
|
-
if (!
|
|
23508
|
+
if (!isRecord2(response.result) || !("value" in response.result)) {
|
|
23074
23509
|
throw new Error("Runtime.evaluate did not return a value");
|
|
23075
23510
|
}
|
|
23076
23511
|
return response.result.value;
|
|
@@ -23088,7 +23523,7 @@ var CdpClient = class _CdpClient {
|
|
|
23088
23523
|
const value2 = JSON.parse(messageText(event.data));
|
|
23089
23524
|
const response = parseResponse(value2);
|
|
23090
23525
|
if (!response) {
|
|
23091
|
-
if (!
|
|
23526
|
+
if (!isRecord2(value2) || typeof value2.method !== "string")
|
|
23092
23527
|
return;
|
|
23093
23528
|
const sessionId = typeof value2.sessionId === "string" ? value2.sessionId : void 0;
|
|
23094
23529
|
for (const listener of this.#listeners.get(value2.method) ?? []) {
|
|
@@ -24228,7 +24663,7 @@ var startupTraceStartedAt = Date.now();
|
|
|
24228
24663
|
var CPA_LIVE_VOICE_HOOK_GLOBAL = "__codexhostCpaLiveVoiceHookV1";
|
|
24229
24664
|
|
|
24230
24665
|
// packages/desktop-control/dist/renderer-cdp-control-session.js
|
|
24231
|
-
function
|
|
24666
|
+
function isRecord3(value2) {
|
|
24232
24667
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
24233
24668
|
}
|
|
24234
24669
|
function sleep(milliseconds) {
|
|
@@ -24305,7 +24740,7 @@ var RendererAdapterReadinessError = class extends Error {
|
|
|
24305
24740
|
}
|
|
24306
24741
|
};
|
|
24307
24742
|
function validateBindingStatus(value2, expectedAgents) {
|
|
24308
|
-
if (!
|
|
24743
|
+
if (!isRecord3(value2) || value2.version !== 2 || !Array.isArray(value2.enabledAgents) || value2.enabledAgents.some((agent) => typeof agent !== "string") || !sameAgents(value2.enabledAgents, expectedAgents) || !isRecord3(value2.adapter)) {
|
|
24309
24744
|
throw new Error("Production Renderer binding returned an invalid status");
|
|
24310
24745
|
}
|
|
24311
24746
|
if (value2.adapter.state !== "ready" || typeof value2.adapter.reason !== "string") {
|
|
@@ -24346,9 +24781,9 @@ async function evaluateSource(renderer, source) {
|
|
|
24346
24781
|
expression: source,
|
|
24347
24782
|
awaitPromise: true
|
|
24348
24783
|
});
|
|
24349
|
-
if (!
|
|
24784
|
+
if (!isRecord3(response))
|
|
24350
24785
|
throw new Error("Renderer source evaluation returned an invalid result");
|
|
24351
|
-
if (
|
|
24786
|
+
if (isRecord3(response.exceptionDetails)) {
|
|
24352
24787
|
throw new Error(cdpExceptionMessage(response.exceptionDetails, "Renderer source evaluation failed"));
|
|
24353
24788
|
}
|
|
24354
24789
|
}
|
|
@@ -25189,12 +25624,12 @@ function presentExternalVoiceMessage(message2) {
|
|
|
25189
25624
|
var MAX_MESSAGES = 32;
|
|
25190
25625
|
var MAX_MESSAGE_CHARS = 2e3;
|
|
25191
25626
|
var MAX_TOTAL_CHARS = 12e3;
|
|
25192
|
-
function
|
|
25627
|
+
function isRecord4(value2) {
|
|
25193
25628
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
25194
25629
|
}
|
|
25195
25630
|
function userMessageText(item) {
|
|
25196
25631
|
if (!Array.isArray(item.content)) return "";
|
|
25197
|
-
return item.content.filter(
|
|
25632
|
+
return item.content.filter(isRecord4).map((part) => part.type === "text" && typeof part.text === "string" ? part.text.trim() : "").filter((text) => text.length > 0).join("\n");
|
|
25198
25633
|
}
|
|
25199
25634
|
function clip(text) {
|
|
25200
25635
|
return text.length <= MAX_MESSAGE_CHARS ? text : text.slice(0, MAX_MESSAGE_CHARS);
|
|
@@ -25208,7 +25643,7 @@ function liveMessage(role, text) {
|
|
|
25208
25643
|
}
|
|
25209
25644
|
function messageChars(message2) {
|
|
25210
25645
|
const content = message2.content;
|
|
25211
|
-
if (!Array.isArray(content) || !
|
|
25646
|
+
if (!Array.isArray(content) || !isRecord4(content[0]) || typeof content[0].text !== "string") {
|
|
25212
25647
|
return 0;
|
|
25213
25648
|
}
|
|
25214
25649
|
return content[0].text.length;
|
|
@@ -25216,9 +25651,9 @@ function messageChars(message2) {
|
|
|
25216
25651
|
function voiceSessionInputFromTurns(turns) {
|
|
25217
25652
|
const messages = [];
|
|
25218
25653
|
for (const turn of turns) {
|
|
25219
|
-
if (!
|
|
25654
|
+
if (!isRecord4(turn) || !Array.isArray(turn.items)) continue;
|
|
25220
25655
|
for (const item of turn.items) {
|
|
25221
|
-
if (!
|
|
25656
|
+
if (!isRecord4(item)) continue;
|
|
25222
25657
|
if (item.type === "userMessage") {
|
|
25223
25658
|
const text = userMessageText(item);
|
|
25224
25659
|
if (text) messages.push(liveMessage("user", text));
|
|
@@ -25240,13 +25675,13 @@ function voiceSessionInputFromTurns(turns) {
|
|
|
25240
25675
|
}
|
|
25241
25676
|
|
|
25242
25677
|
// packages/host-runtime/src/external-voice-results.ts
|
|
25243
|
-
function
|
|
25678
|
+
function isRecord5(value2) {
|
|
25244
25679
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
25245
25680
|
}
|
|
25246
25681
|
function speakableFromProjectedTurn(turn) {
|
|
25247
|
-
if (!
|
|
25682
|
+
if (!isRecord5(turn) || !Array.isArray(turn.items)) return void 0;
|
|
25248
25683
|
const messages = turn.items.filter(
|
|
25249
|
-
(item) =>
|
|
25684
|
+
(item) => isRecord5(item) && item.type === "agentMessage" && typeof item.text === "string"
|
|
25250
25685
|
);
|
|
25251
25686
|
return speakableFromItems(messages);
|
|
25252
25687
|
}
|
|
@@ -26354,20 +26789,20 @@ var CHECK_EVERY_MS = HOUR_MS;
|
|
|
26354
26789
|
var MISSING_AFTER_MS = 6 * HOUR_MS;
|
|
26355
26790
|
var FETCH_TIMEOUT_MS = 3e4;
|
|
26356
26791
|
var MINIMUM_PRICED_MODELS = 1e3;
|
|
26357
|
-
function
|
|
26792
|
+
function isRecord6(value2) {
|
|
26358
26793
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
26359
26794
|
}
|
|
26360
26795
|
function price(value2) {
|
|
26361
26796
|
return typeof value2 === "number" && Number.isFinite(value2) && value2 >= 0 ? value2 : null;
|
|
26362
26797
|
}
|
|
26363
26798
|
function compactModelsDev(api) {
|
|
26364
|
-
if (!
|
|
26799
|
+
if (!isRecord6(api)) throw new Error("models.dev catalog must be an object");
|
|
26365
26800
|
const providers = {};
|
|
26366
26801
|
let count2 = 0;
|
|
26367
26802
|
for (const [providerId, provider] of Object.entries(api)) {
|
|
26368
|
-
if (!
|
|
26803
|
+
if (!isRecord6(provider) || !isRecord6(provider.models)) continue;
|
|
26369
26804
|
for (const [modelId, model2] of Object.entries(provider.models)) {
|
|
26370
|
-
if (!
|
|
26805
|
+
if (!isRecord6(model2) || !isRecord6(model2.cost)) continue;
|
|
26371
26806
|
const input = price(model2.cost.input);
|
|
26372
26807
|
const output = price(model2.cost.output);
|
|
26373
26808
|
if (input === null || output === null) continue;
|
|
@@ -26394,27 +26829,27 @@ function isEntry(value2) {
|
|
|
26394
26829
|
return value2.length < 5 || value2[4] === true || typeof value2[4] === "string";
|
|
26395
26830
|
}
|
|
26396
26831
|
function parseModelPriceTable(value2) {
|
|
26397
|
-
if (!
|
|
26832
|
+
if (!isRecord6(value2) || !isRecord6(value2.providers)) return null;
|
|
26398
26833
|
if (typeof value2.fetchedAtMs !== "number" || !Number.isSafeInteger(value2.fetchedAtMs)) {
|
|
26399
26834
|
return null;
|
|
26400
26835
|
}
|
|
26401
26836
|
for (const models of Object.values(value2.providers)) {
|
|
26402
|
-
if (!
|
|
26837
|
+
if (!isRecord6(models) || !Object.values(models).every(isEntry)) return null;
|
|
26403
26838
|
}
|
|
26404
26839
|
return value2;
|
|
26405
26840
|
}
|
|
26406
26841
|
function parseModelPriceOverrides(value2) {
|
|
26407
|
-
if (!
|
|
26842
|
+
if (!isRecord6(value2) || !isRecord6(value2.models)) {
|
|
26408
26843
|
throw new Error("Price overrides must contain a 'models' object");
|
|
26409
26844
|
}
|
|
26410
26845
|
const overrides = /* @__PURE__ */ new Map();
|
|
26411
26846
|
for (const [key, entry] of Object.entries(value2.models)) {
|
|
26412
|
-
if (key.length === 0 || !
|
|
26847
|
+
if (key.length === 0 || !isRecord6(entry)) {
|
|
26413
26848
|
throw new Error(`Price override '${key}' is invalid`);
|
|
26414
26849
|
}
|
|
26415
|
-
for (const
|
|
26416
|
-
if (!["input", "output", "cacheRead", "cacheWrite", "cacheWrite1h"].includes(
|
|
26417
|
-
throw new Error(`Price override '${key}' contains unknown field '${
|
|
26850
|
+
for (const field2 of Object.keys(entry)) {
|
|
26851
|
+
if (!["input", "output", "cacheRead", "cacheWrite", "cacheWrite1h"].includes(field2)) {
|
|
26852
|
+
throw new Error(`Price override '${key}' contains unknown field '${field2}'`);
|
|
26418
26853
|
}
|
|
26419
26854
|
}
|
|
26420
26855
|
const input = price(entry.input);
|
|
@@ -26423,11 +26858,11 @@ function parseModelPriceOverrides(value2) {
|
|
|
26423
26858
|
throw new Error(`Price override '${key}' needs non-negative 'input' and 'output'`);
|
|
26424
26859
|
}
|
|
26425
26860
|
const resolved = { input, output };
|
|
26426
|
-
for (const
|
|
26427
|
-
if (entry[
|
|
26428
|
-
const candidate = price(entry[
|
|
26429
|
-
if (candidate === null) throw new Error(`Price override '${key}' has invalid '${
|
|
26430
|
-
resolved[
|
|
26861
|
+
for (const field2 of ["cacheRead", "cacheWrite", "cacheWrite1h"]) {
|
|
26862
|
+
if (entry[field2] === void 0) continue;
|
|
26863
|
+
const candidate = price(entry[field2]);
|
|
26864
|
+
if (candidate === null) throw new Error(`Price override '${key}' has invalid '${field2}'`);
|
|
26865
|
+
resolved[field2] = candidate;
|
|
26431
26866
|
}
|
|
26432
26867
|
overrides.set(key, resolved);
|
|
26433
26868
|
}
|
|
@@ -26765,7 +27200,7 @@ var ModelPriceCatalog = class {
|
|
|
26765
27200
|
function errorMessage2(error51) {
|
|
26766
27201
|
return error51 instanceof Error ? error51.message : String(error51);
|
|
26767
27202
|
}
|
|
26768
|
-
function
|
|
27203
|
+
function isRecord7(value2) {
|
|
26769
27204
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
26770
27205
|
}
|
|
26771
27206
|
async function readDocument(file2) {
|
|
@@ -26806,7 +27241,7 @@ async function updateModelPriceOverridesFile(file2, change) {
|
|
|
26806
27241
|
);
|
|
26807
27242
|
}
|
|
26808
27243
|
const document = current.document ?? { models: {} };
|
|
26809
|
-
const models =
|
|
27244
|
+
const models = isRecord7(document.models) ? document.models : {};
|
|
26810
27245
|
const { key, price: price2, previousKey } = change;
|
|
26811
27246
|
if (previousKey !== void 0 && !Object.hasOwn(models, previousKey)) {
|
|
26812
27247
|
throw new ModelPriceOverridesError(`Custom price '${previousKey}' no longer exists`);
|
|
@@ -27075,7 +27510,7 @@ function rewriteDelegationMentionText(text) {
|
|
|
27075
27510
|
const { text: stripped, mentions } = stripDelegationMentions(text);
|
|
27076
27511
|
return mentions.length === 0 ? text : appendInstruction(stripped, mentions);
|
|
27077
27512
|
}
|
|
27078
|
-
function
|
|
27513
|
+
function isRecord8(value2) {
|
|
27079
27514
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
27080
27515
|
}
|
|
27081
27516
|
function rewriteDelegationMentionInput(input, skill) {
|
|
@@ -27083,7 +27518,7 @@ function rewriteDelegationMentionInput(input, skill) {
|
|
|
27083
27518
|
const seen = /* @__PURE__ */ new Set();
|
|
27084
27519
|
let lastTextIndex = -1;
|
|
27085
27520
|
const rewritten = input.map((item, index) => {
|
|
27086
|
-
if (!
|
|
27521
|
+
if (!isRecord8(item) || item.type !== "text" || typeof item.text !== "string") return item;
|
|
27087
27522
|
lastTextIndex = index;
|
|
27088
27523
|
const result = stripDelegationMentions(item.text);
|
|
27089
27524
|
for (const mention of result.mentions) {
|
|
@@ -27095,356 +27530,19 @@ function rewriteDelegationMentionInput(input, skill) {
|
|
|
27095
27530
|
});
|
|
27096
27531
|
if (mentions.length === 0) return null;
|
|
27097
27532
|
const target = rewritten[lastTextIndex];
|
|
27098
|
-
if (
|
|
27533
|
+
if (isRecord8(target) && typeof target.text === "string") {
|
|
27099
27534
|
rewritten[lastTextIndex] = {
|
|
27100
27535
|
...target,
|
|
27101
27536
|
text: appendInstruction(target.text, mentions)
|
|
27102
27537
|
};
|
|
27103
27538
|
}
|
|
27104
27539
|
const hasSkill = rewritten.some(
|
|
27105
|
-
(item) =>
|
|
27540
|
+
(item) => isRecord8(item) && item.type === "skill" && item.name === skill?.name
|
|
27106
27541
|
);
|
|
27107
27542
|
if (skill && !hasSkill) rewritten.push({ type: "skill", name: skill.name, path: skill.path });
|
|
27108
27543
|
return rewritten;
|
|
27109
27544
|
}
|
|
27110
27545
|
|
|
27111
|
-
// packages/harness-adapter/dist/account-credits.js
|
|
27112
|
-
function parseHarnessAccountCredits(value2) {
|
|
27113
|
-
if (!value2 || typeof value2 !== "object" || Array.isArray(value2))
|
|
27114
|
-
return null;
|
|
27115
|
-
const publicValue = { ...value2 };
|
|
27116
|
-
delete publicValue.fetchedAt;
|
|
27117
|
-
const parsed2 = accountCreditsSnapshotSchema.safeParse(publicValue);
|
|
27118
|
-
return parsed2.success ? parsed2.data : null;
|
|
27119
|
-
}
|
|
27120
|
-
|
|
27121
|
-
// packages/harness-adapter/dist/output-channel.js
|
|
27122
|
-
var HarnessOutputChannel = class {
|
|
27123
|
-
outputs;
|
|
27124
|
-
#consumerCreated = false;
|
|
27125
|
-
#ended = false;
|
|
27126
|
-
#pending = [];
|
|
27127
|
-
#values = [];
|
|
27128
|
-
constructor() {
|
|
27129
|
-
this.outputs = {
|
|
27130
|
-
[Symbol.asyncIterator]: () => {
|
|
27131
|
-
if (this.#consumerCreated) {
|
|
27132
|
-
throw new Error("Harness outputs allow only one consumer");
|
|
27133
|
-
}
|
|
27134
|
-
this.#consumerCreated = true;
|
|
27135
|
-
return {
|
|
27136
|
-
next: () => this.#next()
|
|
27137
|
-
};
|
|
27138
|
-
}
|
|
27139
|
-
};
|
|
27140
|
-
}
|
|
27141
|
-
emit(value2) {
|
|
27142
|
-
if (this.#ended)
|
|
27143
|
-
return false;
|
|
27144
|
-
const resolve = this.#pending.shift();
|
|
27145
|
-
if (resolve)
|
|
27146
|
-
resolve({ done: false, value: value2 });
|
|
27147
|
-
else
|
|
27148
|
-
this.#values.push(value2);
|
|
27149
|
-
return true;
|
|
27150
|
-
}
|
|
27151
|
-
end() {
|
|
27152
|
-
if (this.#ended)
|
|
27153
|
-
return;
|
|
27154
|
-
this.#ended = true;
|
|
27155
|
-
if (this.#values.length !== 0)
|
|
27156
|
-
return;
|
|
27157
|
-
for (const resolve of this.#pending.splice(0))
|
|
27158
|
-
resolve({ done: true, value: void 0 });
|
|
27159
|
-
}
|
|
27160
|
-
#next() {
|
|
27161
|
-
const value2 = this.#values.shift();
|
|
27162
|
-
if (value2 !== void 0)
|
|
27163
|
-
return Promise.resolve({ done: false, value: value2 });
|
|
27164
|
-
if (this.#ended)
|
|
27165
|
-
return Promise.resolve({ done: true, value: void 0 });
|
|
27166
|
-
return new Promise((resolve) => this.#pending.push(resolve));
|
|
27167
|
-
}
|
|
27168
|
-
};
|
|
27169
|
-
|
|
27170
|
-
// packages/harness-adapter/dist/usage.js
|
|
27171
|
-
var hostDerivedUsageFields = [
|
|
27172
|
-
"sessionCacheHitRatePercent",
|
|
27173
|
-
"timeToFirstOutputMs",
|
|
27174
|
-
"costSource",
|
|
27175
|
-
"unpricedModels"
|
|
27176
|
-
];
|
|
27177
|
-
var tokenFields = [
|
|
27178
|
-
"inputTokens",
|
|
27179
|
-
"cachedInputTokens",
|
|
27180
|
-
"cacheWriteInputTokens",
|
|
27181
|
-
"outputTokens",
|
|
27182
|
-
"reasoningOutputTokens",
|
|
27183
|
-
"totalTokens",
|
|
27184
|
-
"contextWindowTokens",
|
|
27185
|
-
"contextUsedTokens"
|
|
27186
|
-
];
|
|
27187
|
-
var safeIntegerFields = [
|
|
27188
|
-
"planFiveHourResetsAtUnix",
|
|
27189
|
-
"planSevenDayResetsAtUnix",
|
|
27190
|
-
"timeToFirstOutputMs"
|
|
27191
|
-
];
|
|
27192
|
-
var percentFields = [
|
|
27193
|
-
"cacheHitRatePercent",
|
|
27194
|
-
"sessionCacheHitRatePercent",
|
|
27195
|
-
"planFiveHourUsedPercent",
|
|
27196
|
-
"planSevenDayUsedPercent"
|
|
27197
|
-
];
|
|
27198
|
-
var usageFields = /* @__PURE__ */ new Set([
|
|
27199
|
-
...tokenFields,
|
|
27200
|
-
...safeIntegerFields,
|
|
27201
|
-
...percentFields,
|
|
27202
|
-
"sessionCacheUsage",
|
|
27203
|
-
"composerIndicators",
|
|
27204
|
-
"totalCostUsd",
|
|
27205
|
-
"totalCredits",
|
|
27206
|
-
"contextUsagePercent",
|
|
27207
|
-
"outputTokensPerSecond",
|
|
27208
|
-
"apiOutputTokensPerSecond",
|
|
27209
|
-
"costSource",
|
|
27210
|
-
"unpricedModels"
|
|
27211
|
-
]);
|
|
27212
|
-
function isRecord8(value2) {
|
|
27213
|
-
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
27214
|
-
}
|
|
27215
|
-
function parseHostUsage(value2) {
|
|
27216
|
-
if (!isRecord8(value2))
|
|
27217
|
-
throw new Error("Harness Usage must be an object");
|
|
27218
|
-
const keys = Object.keys(value2);
|
|
27219
|
-
if (keys.length === 0)
|
|
27220
|
-
throw new Error("Harness Usage must contain a reliable field");
|
|
27221
|
-
for (const key of keys) {
|
|
27222
|
-
if (!usageFields.has(key)) {
|
|
27223
|
-
throw new Error(`Harness Usage contains unknown field '${key}'`);
|
|
27224
|
-
}
|
|
27225
|
-
}
|
|
27226
|
-
const indicators = value2.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value2.composerIndicators) };
|
|
27227
|
-
for (const field of [
|
|
27228
|
-
"totalCredits",
|
|
27229
|
-
"contextUsagePercent",
|
|
27230
|
-
"apiOutputTokensPerSecond"
|
|
27231
|
-
]) {
|
|
27232
|
-
const candidate = value2[field];
|
|
27233
|
-
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
27234
|
-
throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
|
|
27235
|
-
}
|
|
27236
|
-
}
|
|
27237
|
-
for (const field of tokenFields) {
|
|
27238
|
-
const candidate = value2[field];
|
|
27239
|
-
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
27240
|
-
throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
|
|
27241
|
-
}
|
|
27242
|
-
}
|
|
27243
|
-
for (const field of safeIntegerFields) {
|
|
27244
|
-
const candidate = value2[field];
|
|
27245
|
-
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
27246
|
-
throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
|
|
27247
|
-
}
|
|
27248
|
-
}
|
|
27249
|
-
if (value2.outputTokensPerSecond !== void 0 && (typeof value2.outputTokensPerSecond !== "number" || !Number.isFinite(value2.outputTokensPerSecond) || value2.outputTokensPerSecond < 0)) {
|
|
27250
|
-
throw new Error("Harness Usage 'outputTokensPerSecond' must be a finite non-negative number");
|
|
27251
|
-
}
|
|
27252
|
-
if (value2.totalCostUsd !== void 0 && (typeof value2.totalCostUsd !== "number" || !Number.isFinite(value2.totalCostUsd) || value2.totalCostUsd < 0)) {
|
|
27253
|
-
throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
|
|
27254
|
-
}
|
|
27255
|
-
for (const field of percentFields) {
|
|
27256
|
-
const candidate = value2[field];
|
|
27257
|
-
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
|
|
27258
|
-
throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
|
|
27259
|
-
}
|
|
27260
|
-
}
|
|
27261
|
-
if (value2.sessionCacheUsage !== void 0) {
|
|
27262
|
-
const totals2 = value2.sessionCacheUsage;
|
|
27263
|
-
if (!isRecord8(totals2) || Object.keys(totals2).some((key) => key !== "inputTokens" && key !== "cachedInputTokens") || typeof totals2.inputTokens !== "number" || !Number.isSafeInteger(totals2.inputTokens) || totals2.inputTokens < 0 || typeof totals2.cachedInputTokens !== "number" || !Number.isSafeInteger(totals2.cachedInputTokens) || totals2.cachedInputTokens < 0 || totals2.cachedInputTokens > totals2.inputTokens) {
|
|
27264
|
-
throw new Error("Harness Usage 'sessionCacheUsage' must contain complete bounded token totals");
|
|
27265
|
-
}
|
|
27266
|
-
}
|
|
27267
|
-
const hasContextUsed = value2.contextUsedTokens !== void 0;
|
|
27268
|
-
const hasContextWindow = value2.contextWindowTokens !== void 0;
|
|
27269
|
-
if (hasContextUsed !== hasContextWindow) {
|
|
27270
|
-
throw new Error("Harness Usage context fields must be provided together");
|
|
27271
|
-
}
|
|
27272
|
-
if (hasContextWindow && value2.contextWindowTokens === 0) {
|
|
27273
|
-
throw new Error("Harness Usage 'contextWindowTokens' must be greater than zero");
|
|
27274
|
-
}
|
|
27275
|
-
if (value2.planFiveHourResetsAtUnix !== void 0 && value2.planFiveHourUsedPercent === void 0) {
|
|
27276
|
-
throw new Error("Harness Usage 'planFiveHourResetsAtUnix' must be provided with 'planFiveHourUsedPercent'");
|
|
27277
|
-
}
|
|
27278
|
-
if (value2.planSevenDayResetsAtUnix !== void 0 && value2.planSevenDayUsedPercent === void 0) {
|
|
27279
|
-
throw new Error("Harness Usage 'planSevenDayResetsAtUnix' must be provided with 'planSevenDayUsedPercent'");
|
|
27280
|
-
}
|
|
27281
|
-
if (value2.costSource !== void 0) {
|
|
27282
|
-
if (value2.costSource !== "publicPrice" && value2.costSource !== "native") {
|
|
27283
|
-
throw new Error("Harness Usage 'costSource' must be 'publicPrice' or 'native'");
|
|
27284
|
-
}
|
|
27285
|
-
if (value2.totalCostUsd === void 0) {
|
|
27286
|
-
throw new Error("Harness Usage 'costSource' must be provided with 'totalCostUsd'");
|
|
27287
|
-
}
|
|
27288
|
-
}
|
|
27289
|
-
if (value2.unpricedModels !== void 0) {
|
|
27290
|
-
const models = value2.unpricedModels;
|
|
27291
|
-
if (!Array.isArray(models) || models.length === 0 || !models.every((model2) => typeof model2 === "string" && model2.length > 0)) {
|
|
27292
|
-
throw new Error("Harness Usage 'unpricedModels' must be a non-empty list of Model IDs");
|
|
27293
|
-
}
|
|
27294
|
-
if (value2.costSource !== "publicPrice") {
|
|
27295
|
-
throw new Error("Harness Usage 'unpricedModels' must be provided with a 'publicPrice' cost");
|
|
27296
|
-
}
|
|
27297
|
-
return { ...value2, ...indicators, unpricedModels: [...models] };
|
|
27298
|
-
}
|
|
27299
|
-
return { ...value2, ...indicators };
|
|
27300
|
-
}
|
|
27301
|
-
var requestTokenFields = [
|
|
27302
|
-
"inputTokens",
|
|
27303
|
-
"cachedInputTokens",
|
|
27304
|
-
"cacheWriteInputTokens",
|
|
27305
|
-
"cacheWrite1hInputTokens",
|
|
27306
|
-
"outputTokens",
|
|
27307
|
-
"reasoningOutputTokens",
|
|
27308
|
-
"startedAtMs",
|
|
27309
|
-
"completedAtMs"
|
|
27310
|
-
];
|
|
27311
|
-
var requestFields = /* @__PURE__ */ new Set([
|
|
27312
|
-
...requestTokenFields,
|
|
27313
|
-
"requestId",
|
|
27314
|
-
"historical",
|
|
27315
|
-
"model",
|
|
27316
|
-
"provider"
|
|
27317
|
-
]);
|
|
27318
|
-
function parseHostUsageRequest(value2) {
|
|
27319
|
-
if (!isRecord8(value2))
|
|
27320
|
-
throw new Error("Harness Usage request must be an object");
|
|
27321
|
-
for (const key of Object.keys(value2)) {
|
|
27322
|
-
if (!requestFields.has(key)) {
|
|
27323
|
-
throw new Error(`Harness Usage request contains unknown field '${key}'`);
|
|
27324
|
-
}
|
|
27325
|
-
}
|
|
27326
|
-
if (typeof value2.requestId !== "string" || value2.requestId.length === 0) {
|
|
27327
|
-
throw new Error("Harness Usage request 'requestId' must be a non-empty string");
|
|
27328
|
-
}
|
|
27329
|
-
for (const field of ["model", "provider"]) {
|
|
27330
|
-
const candidate = value2[field];
|
|
27331
|
-
if (candidate !== void 0 && (typeof candidate !== "string" || candidate.length === 0)) {
|
|
27332
|
-
throw new Error(`Harness Usage request '${field}' must be a non-empty string`);
|
|
27333
|
-
}
|
|
27334
|
-
}
|
|
27335
|
-
if (value2.historical !== void 0 && typeof value2.historical !== "boolean") {
|
|
27336
|
-
throw new Error("Harness Usage request 'historical' must be a boolean");
|
|
27337
|
-
}
|
|
27338
|
-
for (const field of requestTokenFields) {
|
|
27339
|
-
const candidate = value2[field];
|
|
27340
|
-
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
27341
|
-
throw new Error(`Harness Usage request '${field}' must be a non-negative safe integer`);
|
|
27342
|
-
}
|
|
27343
|
-
}
|
|
27344
|
-
if (value2.inputTokens === void 0 || value2.outputTokens === void 0) {
|
|
27345
|
-
throw new Error("Harness Usage request must contain 'inputTokens' and 'outputTokens'");
|
|
27346
|
-
}
|
|
27347
|
-
const request = value2;
|
|
27348
|
-
if ((request.cachedInputTokens ?? 0) + (request.cacheWriteInputTokens ?? 0) > request.inputTokens) {
|
|
27349
|
-
throw new Error("Harness Usage request cache Tokens must not exceed 'inputTokens'");
|
|
27350
|
-
}
|
|
27351
|
-
if ((request.reasoningOutputTokens ?? 0) > request.outputTokens) {
|
|
27352
|
-
throw new Error("Harness Usage request 'reasoningOutputTokens' must not exceed 'outputTokens'");
|
|
27353
|
-
}
|
|
27354
|
-
if (request.cacheWrite1hInputTokens !== void 0 && request.cacheWrite1hInputTokens > (request.cacheWriteInputTokens ?? -1)) {
|
|
27355
|
-
throw new Error("Harness Usage request 'cacheWrite1hInputTokens' must not exceed 'cacheWriteInputTokens'");
|
|
27356
|
-
}
|
|
27357
|
-
if (request.startedAtMs === void 0 !== (request.completedAtMs === void 0)) {
|
|
27358
|
-
throw new Error("Harness Usage request timing fields must be provided together");
|
|
27359
|
-
}
|
|
27360
|
-
if (request.startedAtMs !== void 0 && request.completedAtMs !== void 0 && request.completedAtMs < request.startedAtMs) {
|
|
27361
|
-
throw new Error("Harness Usage request 'completedAtMs' must not precede 'startedAtMs'");
|
|
27362
|
-
}
|
|
27363
|
-
return { ...request };
|
|
27364
|
-
}
|
|
27365
|
-
|
|
27366
|
-
// packages/harness-adapter/dist/live-command-catalog.js
|
|
27367
|
-
var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
|
|
27368
|
-
// Session lifecycle
|
|
27369
|
-
"branch",
|
|
27370
|
-
"clear",
|
|
27371
|
-
"exit",
|
|
27372
|
-
"fork",
|
|
27373
|
-
"fresh",
|
|
27374
|
-
"new",
|
|
27375
|
-
"quit",
|
|
27376
|
-
"rename",
|
|
27377
|
-
"rename-chat",
|
|
27378
|
-
"reset",
|
|
27379
|
-
"resume",
|
|
27380
|
-
"rewind",
|
|
27381
|
-
"session",
|
|
27382
|
-
"sessions",
|
|
27383
|
-
// Desktop-owned configuration
|
|
27384
|
-
"autocompact",
|
|
27385
|
-
"color",
|
|
27386
|
-
"config",
|
|
27387
|
-
"effort",
|
|
27388
|
-
"fast",
|
|
27389
|
-
"keybindings",
|
|
27390
|
-
"model",
|
|
27391
|
-
"models",
|
|
27392
|
-
"output-style",
|
|
27393
|
-
"permissions",
|
|
27394
|
-
"settings",
|
|
27395
|
-
"statusline",
|
|
27396
|
-
"terminal-setup",
|
|
27397
|
-
"theme",
|
|
27398
|
-
"vim",
|
|
27399
|
-
// Trust and approval policy
|
|
27400
|
-
"always-approve",
|
|
27401
|
-
"auto-mode-setup",
|
|
27402
|
-
// Native login
|
|
27403
|
-
"login",
|
|
27404
|
-
"logout",
|
|
27405
|
-
// Work outliving the Turn
|
|
27406
|
-
"autopilot",
|
|
27407
|
-
"background",
|
|
27408
|
-
"bg",
|
|
27409
|
-
"goal",
|
|
27410
|
-
"jobs",
|
|
27411
|
-
"loop",
|
|
27412
|
-
"multitask",
|
|
27413
|
-
"queue",
|
|
27414
|
-
"remote-control",
|
|
27415
|
-
"schedule",
|
|
27416
|
-
"steer",
|
|
27417
|
-
// Native terminal UI
|
|
27418
|
-
"copy",
|
|
27419
|
-
"debug",
|
|
27420
|
-
"feedback",
|
|
27421
|
-
"heapdump",
|
|
27422
|
-
"share",
|
|
27423
|
-
"shell",
|
|
27424
|
-
// Plugin and MCP management
|
|
27425
|
-
"marketplace",
|
|
27426
|
-
"mcp",
|
|
27427
|
-
"plugins",
|
|
27428
|
-
"reload-plugins"
|
|
27429
|
-
]);
|
|
27430
|
-
var COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES = ["__", "hooks-"];
|
|
27431
|
-
function isExcludedLiveCommand(name, kind, extra = {}) {
|
|
27432
|
-
const normalized = name.trim().replace(/^\//u, "");
|
|
27433
|
-
if (new Set(extra.names ?? []).has(normalized))
|
|
27434
|
-
return true;
|
|
27435
|
-
if (extra.prefixes?.some((prefix) => normalized.startsWith(prefix)))
|
|
27436
|
-
return true;
|
|
27437
|
-
if (kind === "skill")
|
|
27438
|
-
return false;
|
|
27439
|
-
return COMMON_EXCLUDED_LIVE_COMMANDS.has(normalized) || COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES.some((prefix) => normalized.startsWith(prefix));
|
|
27440
|
-
}
|
|
27441
|
-
|
|
27442
|
-
// packages/harness-adapter/dist/index.js
|
|
27443
|
-
var packageMetadata = {
|
|
27444
|
-
name: "@codexhost/harness-adapter",
|
|
27445
|
-
contractVersion: WORKSPACE_CONTRACT_VERSION
|
|
27446
|
-
};
|
|
27447
|
-
|
|
27448
27546
|
// packages/mapping-store/dist/mapping-store.js
|
|
27449
27547
|
import { execFileSync } from "node:child_process";
|
|
27450
27548
|
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
@@ -28751,17 +28849,17 @@ var ELLIPSIS = "…";
|
|
|
28751
28849
|
function isRecord9(value2) {
|
|
28752
28850
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
28753
28851
|
}
|
|
28754
|
-
function boundedText(value2,
|
|
28852
|
+
function boundedText(value2, field2, maxLength) {
|
|
28755
28853
|
const text = value2.trim();
|
|
28756
28854
|
if (text.length === 0 || text.length > maxLength) {
|
|
28757
|
-
throw new Error(`Host Approval ${
|
|
28855
|
+
throw new Error(`Host Approval ${field2} must contain 1 to ${maxLength} characters`);
|
|
28758
28856
|
}
|
|
28759
28857
|
return text;
|
|
28760
28858
|
}
|
|
28761
|
-
function clampedText(value2,
|
|
28859
|
+
function clampedText(value2, field2, maxLength) {
|
|
28762
28860
|
const text = value2.trim();
|
|
28763
28861
|
if (text.length === 0) {
|
|
28764
|
-
throw new Error(`Host Approval ${
|
|
28862
|
+
throw new Error(`Host Approval ${field2} must contain at least 1 character`);
|
|
28765
28863
|
}
|
|
28766
28864
|
const characters = [...text];
|
|
28767
28865
|
if (characters.length <= maxLength)
|
|
@@ -29976,9 +30074,9 @@ function nestedString(value2, keys, preserveText = false) {
|
|
|
29976
30074
|
if (!isRecord12(value2))
|
|
29977
30075
|
return void 0;
|
|
29978
30076
|
for (const key of keys) {
|
|
29979
|
-
const
|
|
29980
|
-
if (typeof
|
|
29981
|
-
return preserveText ?
|
|
30077
|
+
const field2 = value2[key];
|
|
30078
|
+
if (typeof field2 === "string" && (preserveText || field2.trim().length > 0))
|
|
30079
|
+
return preserveText ? field2 : field2.trim();
|
|
29982
30080
|
}
|
|
29983
30081
|
for (const wrapper of ["input", "arguments", "params"]) {
|
|
29984
30082
|
const nested = nestedString(value2[wrapper], keys, preserveText);
|
|
@@ -34363,7 +34461,7 @@ var UsageMeter = class {
|
|
|
34363
34461
|
derive(native, prices) {
|
|
34364
34462
|
const usage = Object.fromEntries(
|
|
34365
34463
|
Object.entries(native ?? {}).filter(
|
|
34366
|
-
([
|
|
34464
|
+
([field2]) => !hostDerivedUsageFields.includes(field2)
|
|
34367
34465
|
)
|
|
34368
34466
|
);
|
|
34369
34467
|
const sessionCacheUsage = usage.sessionCacheUsage;
|
|
@@ -36056,10 +36154,10 @@ var HarnessDelegationCoordinator = class {
|
|
|
36056
36154
|
}
|
|
36057
36155
|
};
|
|
36058
36156
|
});
|
|
36059
|
-
const [
|
|
36157
|
+
const [field2, direction] = input.sort.split("-");
|
|
36060
36158
|
rows.sort((left, right) => {
|
|
36061
|
-
const leftTimestamp =
|
|
36062
|
-
const rightTimestamp =
|
|
36159
|
+
const leftTimestamp = field2 === "created" ? left.createdAt : left.updatedAt;
|
|
36160
|
+
const rightTimestamp = field2 === "created" ? right.createdAt : right.updatedAt;
|
|
36063
36161
|
const leftTime = Date.parse(leftTimestamp ?? "");
|
|
36064
36162
|
const rightTime = Date.parse(rightTimestamp ?? "");
|
|
36065
36163
|
return direction === "asc" ? leftTime - rightTime : rightTime - leftTime;
|
|
@@ -39475,9 +39573,9 @@ var RequestRouteObservationTracker = class {
|
|
|
39475
39573
|
};
|
|
39476
39574
|
|
|
39477
39575
|
// packages/host-runtime/src/external-thread-list.ts
|
|
39478
|
-
function unixTimestamp(value2,
|
|
39576
|
+
function unixTimestamp(value2, field2) {
|
|
39479
39577
|
const parsed2 = Date.parse(value2);
|
|
39480
|
-
if (!Number.isFinite(parsed2)) throw new Error(`External Thread ${
|
|
39578
|
+
if (!Number.isFinite(parsed2)) throw new Error(`External Thread ${field2} is invalid`);
|
|
39481
39579
|
return Math.floor(parsed2 / 1e3);
|
|
39482
39580
|
}
|
|
39483
39581
|
function threadId(thread) {
|
|
@@ -39487,11 +39585,11 @@ function threadId(thread) {
|
|
|
39487
39585
|
return thread.id;
|
|
39488
39586
|
}
|
|
39489
39587
|
function threadListTimestamp(thread, sortKey) {
|
|
39490
|
-
const
|
|
39491
|
-
if (!Number.isSafeInteger(
|
|
39588
|
+
const field2 = sortKey === "created_at" ? thread.createdAt : sortKey === "updated_at" ? thread.updatedAt : thread.recencyAt ?? thread.updatedAt;
|
|
39589
|
+
if (!Number.isSafeInteger(field2)) {
|
|
39492
39590
|
throw new Error(`Thread list row has no valid ${sortKey} timestamp`);
|
|
39493
39591
|
}
|
|
39494
|
-
return
|
|
39592
|
+
return field2;
|
|
39495
39593
|
}
|
|
39496
39594
|
function compareTimestamp(left, right, direction) {
|
|
39497
39595
|
if (left === right) return 0;
|
|
@@ -41166,6 +41264,104 @@ var AppServerHost = class {
|
|
|
41166
41264
|
}
|
|
41167
41265
|
return;
|
|
41168
41266
|
}
|
|
41267
|
+
if (request.method === THREAD_QUESTIONS_LIST_METHOD) {
|
|
41268
|
+
const parsed2 = threadQuestionsParamsSchema.safeParse(request.params);
|
|
41269
|
+
if (!parsed2.success) {
|
|
41270
|
+
await this.#writer.json(rpcError(request, -32602, "Invalid question list request"));
|
|
41271
|
+
return;
|
|
41272
|
+
}
|
|
41273
|
+
const questions = [...this.#pendingDesktopQuestions.values()].filter((pending) => pending.extended && pending.thread.id === parsed2.data.threadId).map(({ interaction }) => ({
|
|
41274
|
+
interactionId: interaction.interactionId,
|
|
41275
|
+
turnId: interaction.turnId,
|
|
41276
|
+
...interaction.title ? { title: interaction.title } : {},
|
|
41277
|
+
...interaction.expiresAt ? { expiresAt: interaction.expiresAt } : {},
|
|
41278
|
+
...interaction.autoResolution ? { autoResolution: interaction.autoResolution } : {},
|
|
41279
|
+
questions: interaction.questions
|
|
41280
|
+
}));
|
|
41281
|
+
await this.#writer.json(
|
|
41282
|
+
rpcEnvelope(request, {
|
|
41283
|
+
result: jsonValueSchema.parse(threadQuestionsResultSchema.parse({ questions }))
|
|
41284
|
+
})
|
|
41285
|
+
);
|
|
41286
|
+
return;
|
|
41287
|
+
}
|
|
41288
|
+
if (request.method === THREAD_QUESTION_ACTIVITY_METHOD) {
|
|
41289
|
+
const parsed2 = threadQuestionActivityParamsSchema.safeParse(request.params);
|
|
41290
|
+
if (!parsed2.success) {
|
|
41291
|
+
await this.#writer.json(rpcError(request, -32602, "Invalid question activity request"));
|
|
41292
|
+
return;
|
|
41293
|
+
}
|
|
41294
|
+
const params = parsed2.data;
|
|
41295
|
+
await this.#externalRuntime.idleRelease.runOperation(params.threadId, async () => {
|
|
41296
|
+
const pending = this.#findSharedQuestion(params);
|
|
41297
|
+
if (!pending || !this.#isCurrentSharedQuestion(pending)) {
|
|
41298
|
+
await this.#writer.json(rpcError(request, -32080, "Question is no longer pending"));
|
|
41299
|
+
return;
|
|
41300
|
+
}
|
|
41301
|
+
let autoResolution = null;
|
|
41302
|
+
if (pending.interaction.autoResolution?.resetOnActivity && pending.thread.session.questionActivity) {
|
|
41303
|
+
const result = await pending.thread.session.questionActivity(params.interactionId);
|
|
41304
|
+
if (!result.ok) {
|
|
41305
|
+
await this.#writer.json(rpcError(request, -32080, result.error.message));
|
|
41306
|
+
return;
|
|
41307
|
+
}
|
|
41308
|
+
const ack = threadQuestionActivityResultSchema.parse({
|
|
41309
|
+
autoResolution: result.value
|
|
41310
|
+
}).autoResolution;
|
|
41311
|
+
if (this.#isCurrentSharedQuestion(pending) && ack) {
|
|
41312
|
+
if (ack.deadlineUnixMs >= (pending.interaction.autoResolution?.deadlineUnixMs ?? 0))
|
|
41313
|
+
pending.interaction.autoResolution = ack;
|
|
41314
|
+
autoResolution = pending.interaction.autoResolution ?? null;
|
|
41315
|
+
}
|
|
41316
|
+
}
|
|
41317
|
+
await this.#writer.json(
|
|
41318
|
+
rpcEnvelope(request, { result: jsonValueSchema.parse({ autoResolution }) })
|
|
41319
|
+
);
|
|
41320
|
+
});
|
|
41321
|
+
return;
|
|
41322
|
+
}
|
|
41323
|
+
if (request.method === THREAD_QUESTION_RESPOND_METHOD) {
|
|
41324
|
+
const parsed2 = threadQuestionRespondParamsSchema.safeParse(request.params);
|
|
41325
|
+
if (!parsed2.success) {
|
|
41326
|
+
await this.#writer.json(rpcError(request, -32602, "Invalid question response"));
|
|
41327
|
+
return;
|
|
41328
|
+
}
|
|
41329
|
+
const params = parsed2.data;
|
|
41330
|
+
await this.#externalRuntime.idleRelease.runOperation(params.threadId, async () => {
|
|
41331
|
+
const pending = this.#findSharedQuestion(params);
|
|
41332
|
+
if (!pending || !this.#isCurrentSharedQuestion(pending)) {
|
|
41333
|
+
await this.#writer.json(rpcError(request, -32080, "Question is no longer pending"));
|
|
41334
|
+
return;
|
|
41335
|
+
}
|
|
41336
|
+
const response = {
|
|
41337
|
+
type: "question",
|
|
41338
|
+
answers: params.answers,
|
|
41339
|
+
...params.cancelled !== void 0 ? { cancelled: params.cancelled } : {}
|
|
41340
|
+
};
|
|
41341
|
+
const invalid = validateHostQuestionResponse(pending.interaction, response);
|
|
41342
|
+
if (invalid) {
|
|
41343
|
+
await this.#writer.json(rpcError(request, -32602, invalid.message));
|
|
41344
|
+
return;
|
|
41345
|
+
}
|
|
41346
|
+
pending.responding = true;
|
|
41347
|
+
try {
|
|
41348
|
+
const result = await pending.thread.session.execute({
|
|
41349
|
+
type: "interaction.respond",
|
|
41350
|
+
interactionId: params.interactionId,
|
|
41351
|
+
response
|
|
41352
|
+
});
|
|
41353
|
+
if (!result.ok) {
|
|
41354
|
+
await this.#writer.json(rpcError(request, -32080, result.error.message));
|
|
41355
|
+
return;
|
|
41356
|
+
}
|
|
41357
|
+
this.#retireDesktopQuestion(params.interactionId);
|
|
41358
|
+
await this.#writer.json(rpcEnvelope(request, { result: { accepted: true } }));
|
|
41359
|
+
} finally {
|
|
41360
|
+
pending.responding = false;
|
|
41361
|
+
}
|
|
41362
|
+
});
|
|
41363
|
+
return;
|
|
41364
|
+
}
|
|
41169
41365
|
if (request.method === HARNESS_DISPLAY_GET_METHOD || request.method === HARNESS_DISPLAY_SET_METHOD) {
|
|
41170
41366
|
const parsed2 = (request.method === HARNESS_DISPLAY_SET_METHOD ? harnessDisplaySetSchema : harnessDisplayGetSchema).safeParse(request.params ?? {});
|
|
41171
41367
|
if (!parsed2.success) {
|
|
@@ -44997,6 +45193,20 @@ var AppServerHost = class {
|
|
|
44997
45193
|
this.#nextApprovalRequestId -= 1;
|
|
44998
45194
|
return requestId2;
|
|
44999
45195
|
}
|
|
45196
|
+
#findSharedQuestion(params) {
|
|
45197
|
+
for (const pending of this.#pendingDesktopQuestions.values()) {
|
|
45198
|
+
if (pending.extended && pending.thread.id === params.threadId && pending.interaction.interactionId === params.interactionId && pending.interaction.turnId === params.turnId)
|
|
45199
|
+
return pending;
|
|
45200
|
+
}
|
|
45201
|
+
return void 0;
|
|
45202
|
+
}
|
|
45203
|
+
#isCurrentSharedQuestion(pending) {
|
|
45204
|
+
return !pending.responding && this.#findSharedQuestion({
|
|
45205
|
+
threadId: pending.thread.id,
|
|
45206
|
+
interactionId: pending.interaction.interactionId,
|
|
45207
|
+
turnId: pending.interaction.turnId
|
|
45208
|
+
}) === pending && this.#externalRuntime.get(pending.thread.id) === pending.thread && !this.#externalRuntime.idleRelease.failure(pending.thread) && (pending.interaction.expiresAt === void 0 || Date.parse(pending.interaction.expiresAt) > Date.now());
|
|
45209
|
+
}
|
|
45000
45210
|
async #projectQuestion(thread, interaction) {
|
|
45001
45211
|
const projection = this.#projectedTurn(thread, interaction.turnId);
|
|
45002
45212
|
await this.#waitForTurnResponse(thread, interaction.turnId);
|
|
@@ -45028,7 +45238,10 @@ var AppServerHost = class {
|
|
|
45028
45238
|
thread,
|
|
45029
45239
|
interaction,
|
|
45030
45240
|
projection: result.questionRequest,
|
|
45031
|
-
timeout: null
|
|
45241
|
+
timeout: null,
|
|
45242
|
+
extended: interaction.questions.some(
|
|
45243
|
+
(question) => question.type === "choice" && (question.multiple || question.allowOther)
|
|
45244
|
+
)
|
|
45032
45245
|
};
|
|
45033
45246
|
if (timeoutMs !== null) {
|
|
45034
45247
|
pending.timeout = setTimeout(() => {
|
|
@@ -45036,6 +45249,7 @@ var AppServerHost = class {
|
|
|
45036
45249
|
}, timeoutMs);
|
|
45037
45250
|
}
|
|
45038
45251
|
this.#pendingDesktopQuestions.set(requestId2, pending);
|
|
45252
|
+
if (pending.extended) return;
|
|
45039
45253
|
try {
|
|
45040
45254
|
await this.#writer.json({ id: requestId2, ...result.questionRequest.request });
|
|
45041
45255
|
} catch (error51) {
|
|
@@ -45053,6 +45267,7 @@ var AppServerHost = class {
|
|
|
45053
45267
|
const requestId2 = value2.id;
|
|
45054
45268
|
const pending = this.#pendingDesktopQuestions.get(requestId2);
|
|
45055
45269
|
if (!pending) return true;
|
|
45270
|
+
if (pending.extended) return true;
|
|
45056
45271
|
return this.#externalRuntime.idleRelease.runOperation(pending.thread.id, async () => {
|
|
45057
45272
|
if (this.#externalRuntime.get(pending.thread.id) !== pending.thread || this.#externalRuntime.idleRelease.failure(pending.thread))
|
|
45058
45273
|
return true;
|
|
@@ -45107,6 +45322,7 @@ var AppServerHost = class {
|
|
|
45107
45322
|
if (pending.interaction.interactionId !== interactionId) continue;
|
|
45108
45323
|
if (pending.timeout) clearTimeout(pending.timeout);
|
|
45109
45324
|
this.#pendingDesktopQuestions.delete(requestId2);
|
|
45325
|
+
if (pending.extended) continue;
|
|
45110
45326
|
await this.#writer.json({
|
|
45111
45327
|
method: "serverRequest/resolved",
|
|
45112
45328
|
params: { threadId: pending.thread.id, requestId: requestId2 }
|
|
@@ -46893,10 +47109,10 @@ var DelegationControlRegistry = class {
|
|
|
46893
47109
|
);
|
|
46894
47110
|
}
|
|
46895
47111
|
#compareThreads(left, right, sort) {
|
|
46896
|
-
const
|
|
47112
|
+
const field2 = sort.startsWith("created") ? "createdAt" : "updatedAt";
|
|
46897
47113
|
const direction = sort.endsWith("asc") ? 1 : -1;
|
|
46898
|
-
const leftValue = left[
|
|
46899
|
-
const rightValue = right[
|
|
47114
|
+
const leftValue = left[field2] ? Date.parse(left[field2]) : 0;
|
|
47115
|
+
const rightValue = right[field2] ? Date.parse(right[field2]) : 0;
|
|
46900
47116
|
return (leftValue - rightValue) * direction || left.threadId.localeCompare(right.threadId);
|
|
46901
47117
|
}
|
|
46902
47118
|
async #matching(predicate) {
|
|
@@ -48272,13 +48488,13 @@ function parseHarnessUsageEntry(value2) {
|
|
|
48272
48488
|
}
|
|
48273
48489
|
if (!tokenCount(entry.inputTokens) || !tokenCount(entry.outputTokens))
|
|
48274
48490
|
return null;
|
|
48275
|
-
for (const
|
|
48491
|
+
for (const field2 of [
|
|
48276
48492
|
"cachedInputTokens",
|
|
48277
48493
|
"cacheWriteInputTokens",
|
|
48278
48494
|
"cacheWrite1hInputTokens",
|
|
48279
48495
|
"reasoningOutputTokens"
|
|
48280
48496
|
]) {
|
|
48281
|
-
if (entry[
|
|
48497
|
+
if (entry[field2] !== void 0 && !tokenCount(entry[field2]))
|
|
48282
48498
|
return null;
|
|
48283
48499
|
}
|
|
48284
48500
|
const cached2 = entry.cachedInputTokens ?? 0;
|