@codexhost/cli-darwin-x64 0.21.0 → 0.23.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 +3333 -249
- package/app/console-web.js +9884 -2837
- package/app/desktop-controller.mjs +3139 -310
- package/app/host-runtime.mjs +6652 -2111
- package/app/plugins/antigravity/plugin.mjs +1796 -1338
- package/app/plugins/claude-code/plugin.mjs +1272 -238
- package/app/plugins/codebuddy/plugin.mjs +588 -109
- package/app/plugins/codex-usage/plugin.mjs +533 -88
- package/app/plugins/copilot/plugin.mjs +533 -88
- package/app/plugins/cursor-cli/plugin.mjs +588 -109
- package/app/plugins/deepseek-harness/plugin.mjs +875 -218
- package/app/plugins/devin/plugin.mjs +533 -88
- package/app/plugins/grok/plugin.mjs +778 -272
- package/app/plugins/hermes/plugin.mjs +533 -88
- package/app/plugins/kimi-code/plugin.mjs +533 -88
- package/app/plugins/kiro-cli/plugin.mjs +533 -88
- package/app/plugins/omp/plugin.mjs +640 -110
- package/app/plugins/opencode/plugin.mjs +533 -88
- package/app/plugins/pi/plugin.mjs +657 -116
- package/app/plugins/qoder/plugin.mjs +533 -88
- package/app/plugins/qoder-cn/plugin.mjs +533 -88
- package/app/plugins/qwen-code/plugin.mjs +533 -88
- package/app/plugins/workbuddy/plugin.mjs +646 -120
- package/app/plugins/zcode/plugin.mjs +540 -95
- package/app/renderer-extension.js +12947 -4450
- package/app/web/assets/index-Dyh1KzAB.js +201 -0
- package/app/web/codexhost-settings.js +9794 -2934
- package/app/web/index.html +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +69 -69
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -74
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +3 -3
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +90 -90
- package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-browser/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +79 -79
- package/app/web-modules/licenses/werift-NOTICES.txt +123 -0
- package/app/web-modules/licenses/werift-libwebrtc-NOTICES.txt +58 -0
- package/app/web-modules/server.mjs +34958 -2911
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/package.json +1 -1
- package/app/web/assets/index-BdmZfTRW.js +0 -201
|
@@ -14525,6 +14525,87 @@ function date4(params) {
|
|
|
14525
14525
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
14526
14526
|
config(en_default());
|
|
14527
14527
|
|
|
14528
|
+
// ../../shared-contracts/dist/ids.js
|
|
14529
|
+
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
14530
|
+
message: "Identifier must not be empty or whitespace"
|
|
14531
|
+
});
|
|
14532
|
+
var harnessIdSchema = opaqueIdSchema.brand();
|
|
14533
|
+
var hostThreadIdSchema = opaqueIdSchema.brand();
|
|
14534
|
+
var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
14535
|
+
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
14536
|
+
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
14537
|
+
|
|
14538
|
+
// ../../shared-contracts/dist/harness-plugins.js
|
|
14539
|
+
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
14540
|
+
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
14541
|
+
var HARNESS_PLUGIN_LIMIT = 128;
|
|
14542
|
+
var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
|
|
14543
|
+
var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
|
|
14544
|
+
var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id2) => id2 !== "codex", "The official Codex identity is reserved");
|
|
14545
|
+
var pluginRelativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
|
|
14546
|
+
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
14547
|
+
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
14548
|
+
var harnessInstallationGuideSchema = external_exports.object({
|
|
14549
|
+
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
14550
|
+
before: localizedTextSchema.optional(),
|
|
14551
|
+
after: localizedTextSchema.optional(),
|
|
14552
|
+
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
14553
|
+
}).strict();
|
|
14554
|
+
var pluginPresentationShape = {
|
|
14555
|
+
id: installedHarnessPluginIdSchema,
|
|
14556
|
+
name: external_exports.string().trim().min(1).max(128),
|
|
14557
|
+
version: external_exports.string().min(1).max(128),
|
|
14558
|
+
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
14559
|
+
kind: external_exports.literal("usage").optional(),
|
|
14560
|
+
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
14561
|
+
iconStyle: external_exports.object({
|
|
14562
|
+
vector: external_exports.object({
|
|
14563
|
+
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
14564
|
+
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
14565
|
+
paths: external_exports.array(external_exports.object({
|
|
14566
|
+
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
14567
|
+
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
14568
|
+
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
14569
|
+
}).strict()).min(1).max(32)
|
|
14570
|
+
}).strict().optional(),
|
|
14571
|
+
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
14572
|
+
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
14573
|
+
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
14574
|
+
}).strict().optional(),
|
|
14575
|
+
installation: harnessInstallationGuideSchema.optional(),
|
|
14576
|
+
notice: localizedTextSchema.optional(),
|
|
14577
|
+
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
14578
|
+
launchCommand: external_exports.literal(true).optional(),
|
|
14579
|
+
links: external_exports.object({
|
|
14580
|
+
website: documentationUrlSchema.optional(),
|
|
14581
|
+
documentation: documentationUrlSchema.optional(),
|
|
14582
|
+
installation: documentationUrlSchema.optional()
|
|
14583
|
+
}).strict().optional()
|
|
14584
|
+
};
|
|
14585
|
+
var harnessPluginManifestSchema = external_exports.object({
|
|
14586
|
+
manifestVersion: external_exports.literal(1),
|
|
14587
|
+
...pluginPresentationShape,
|
|
14588
|
+
adapterApiVersion: external_exports.number().int().positive(),
|
|
14589
|
+
entry: pluginRelativeResourceSchema,
|
|
14590
|
+
icon: pluginRelativeResourceSchema.optional()
|
|
14591
|
+
}).strict();
|
|
14592
|
+
var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
|
|
14593
|
+
var harnessPluginDescriptorSchema = external_exports.object({
|
|
14594
|
+
...pluginPresentationShape,
|
|
14595
|
+
icon: harnessPluginIconSchema.optional()
|
|
14596
|
+
}).strict();
|
|
14597
|
+
var harnessPluginListParamsSchema = external_exports.object({}).strict();
|
|
14598
|
+
var harnessPluginListResultSchema = external_exports.object({
|
|
14599
|
+
plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
|
|
14600
|
+
}).strict();
|
|
14601
|
+
var harnessPluginConfigurationSchema = external_exports.object({
|
|
14602
|
+
version: external_exports.literal(1),
|
|
14603
|
+
enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
14604
|
+
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
14605
|
+
message: "Enabled plugin IDs must be unique",
|
|
14606
|
+
path: ["enabled"]
|
|
14607
|
+
});
|
|
14608
|
+
|
|
14528
14609
|
// ../../shared-contracts/dist/json-value.js
|
|
14529
14610
|
function rejectExplicitUndefined(keys) {
|
|
14530
14611
|
return (value, context) => {
|
|
@@ -14584,6 +14665,346 @@ var jsonValueSchema = nonCircularSchema.pipe(recursiveJsonValueSchema);
|
|
|
14584
14665
|
var jsonArraySchema = nonCircularSchema.pipe(external_exports.array(recursiveJsonValueSchema));
|
|
14585
14666
|
var jsonObjectSchema = nonCircularSchema.pipe(external_exports.record(external_exports.string(), recursiveJsonValueSchema));
|
|
14586
14667
|
|
|
14668
|
+
// ../../shared-contracts/dist/desktop-extensions.js
|
|
14669
|
+
var DESKTOP_EXTENSION_API_VERSION = 1;
|
|
14670
|
+
var DESKTOP_EXTENSION_LIMIT = 64;
|
|
14671
|
+
var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
|
|
14672
|
+
var DESKTOP_EXTENSION_ZIP_MAX_BASE64_LENGTH = 4 * Math.ceil(DESKTOP_EXTENSION_ZIP_MAX_BYTES / 3);
|
|
14673
|
+
var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
|
|
14674
|
+
var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
|
|
14675
|
+
var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
|
|
14676
|
+
var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
|
|
14677
|
+
var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
|
|
14678
|
+
var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
|
|
14679
|
+
var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
|
|
14680
|
+
var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
|
|
14681
|
+
var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
|
|
14682
|
+
var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
|
|
14683
|
+
var desktopExtensionIdSchema = installedPluginIdSchema;
|
|
14684
|
+
var desktopExtensionSlotSchema = external_exports.enum([
|
|
14685
|
+
"sidebar.thread-layout",
|
|
14686
|
+
"sidebar.thread-badge",
|
|
14687
|
+
"appearance.theme"
|
|
14688
|
+
]);
|
|
14689
|
+
var desktopExtensionCategorySchema = external_exports.enum([
|
|
14690
|
+
"appearance",
|
|
14691
|
+
"interface",
|
|
14692
|
+
"workflow",
|
|
14693
|
+
"analytics",
|
|
14694
|
+
"integrations",
|
|
14695
|
+
"tools"
|
|
14696
|
+
]);
|
|
14697
|
+
var extensionName = external_exports.string().trim().min(1).max(128);
|
|
14698
|
+
function desktopExtensionScreenshotMimeType(resource) {
|
|
14699
|
+
switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
|
|
14700
|
+
case "png":
|
|
14701
|
+
return "image/png";
|
|
14702
|
+
case "jpg":
|
|
14703
|
+
case "jpeg":
|
|
14704
|
+
return "image/jpeg";
|
|
14705
|
+
case "webp":
|
|
14706
|
+
return "image/webp";
|
|
14707
|
+
default:
|
|
14708
|
+
return void 0;
|
|
14709
|
+
}
|
|
14710
|
+
}
|
|
14711
|
+
function desktopExtensionAssetMimeType(resource) {
|
|
14712
|
+
switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
|
|
14713
|
+
case "gif":
|
|
14714
|
+
return "image/gif";
|
|
14715
|
+
case "svg":
|
|
14716
|
+
return "image/svg+xml";
|
|
14717
|
+
case "woff2":
|
|
14718
|
+
return "font/woff2";
|
|
14719
|
+
case "json":
|
|
14720
|
+
return "application/json";
|
|
14721
|
+
case "css":
|
|
14722
|
+
return "text/css";
|
|
14723
|
+
default:
|
|
14724
|
+
return desktopExtensionScreenshotMimeType(resource);
|
|
14725
|
+
}
|
|
14726
|
+
}
|
|
14727
|
+
var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
|
|
14728
|
+
var desktopExtensionAssetPathSchema = pluginRelativeResourceSchema.refine((resource) => hasPortableSegments(resource) && desktopExtensionAssetMimeType(resource) !== void 0, "Expected a relative Desktop extension asset path with a supported suffix");
|
|
14729
|
+
var imagePathSchema = pluginRelativeResourceSchema.refine((resource) => desktopExtensionScreenshotMimeType(resource) !== void 0 && hasPortableSegments(resource), "Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space");
|
|
14730
|
+
var desktopExtensionHttpUrlSchema = external_exports.string().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu, "Expected an HTTP(S) URL").pipe(external_exports.url({ protocol: /^https?$/u })).refine((value) => {
|
|
14731
|
+
const { username, password } = new URL(value);
|
|
14732
|
+
return !username && !password && !/[\\\s]/u.test(value);
|
|
14733
|
+
}, "URL must not contain credentials, backslashes, or whitespace");
|
|
14734
|
+
function localizedText(text2) {
|
|
14735
|
+
return external_exports.strictObject({ en: text2, "zh-CN": text2 });
|
|
14736
|
+
}
|
|
14737
|
+
var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
|
|
14738
|
+
var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
|
|
14739
|
+
var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
|
|
14740
|
+
var settingField = {
|
|
14741
|
+
key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
|
|
14742
|
+
label: desktopExtensionLocalizedTextSchema,
|
|
14743
|
+
description: desktopExtensionLocalizedTextSchema.optional()
|
|
14744
|
+
};
|
|
14745
|
+
var numericSetting = {
|
|
14746
|
+
...settingField,
|
|
14747
|
+
step: external_exports.number().positive().optional(),
|
|
14748
|
+
default: external_exports.number().optional()
|
|
14749
|
+
};
|
|
14750
|
+
var settingOption = external_exports.strictObject({
|
|
14751
|
+
value: external_exports.string(),
|
|
14752
|
+
label: desktopExtensionLocalizedTextSchema
|
|
14753
|
+
});
|
|
14754
|
+
var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
|
|
14755
|
+
external_exports.strictObject({
|
|
14756
|
+
...settingField,
|
|
14757
|
+
type: external_exports.literal("boolean"),
|
|
14758
|
+
default: external_exports.boolean().optional()
|
|
14759
|
+
}),
|
|
14760
|
+
external_exports.strictObject({
|
|
14761
|
+
...settingField,
|
|
14762
|
+
type: external_exports.literal("string"),
|
|
14763
|
+
placeholder: desktopExtensionLocalizedTextSchema.optional(),
|
|
14764
|
+
default: external_exports.string().optional()
|
|
14765
|
+
}),
|
|
14766
|
+
external_exports.strictObject({
|
|
14767
|
+
...numericSetting,
|
|
14768
|
+
type: external_exports.literal("number"),
|
|
14769
|
+
min: external_exports.number().optional(),
|
|
14770
|
+
max: external_exports.number().optional()
|
|
14771
|
+
}),
|
|
14772
|
+
external_exports.strictObject({
|
|
14773
|
+
...numericSetting,
|
|
14774
|
+
type: external_exports.literal("range"),
|
|
14775
|
+
min: external_exports.number(),
|
|
14776
|
+
max: external_exports.number()
|
|
14777
|
+
}),
|
|
14778
|
+
external_exports.strictObject({
|
|
14779
|
+
...settingField,
|
|
14780
|
+
type: external_exports.literal("select"),
|
|
14781
|
+
options: external_exports.array(settingOption).min(1),
|
|
14782
|
+
default: external_exports.string().optional()
|
|
14783
|
+
})
|
|
14784
|
+
]).superRefine((field2, ctx) => {
|
|
14785
|
+
const issue2 = (path18, message) => ctx.addIssue({ code: "custom", path: [path18], message });
|
|
14786
|
+
if (field2.type === "number" || field2.type === "range") {
|
|
14787
|
+
const { min = -Infinity, max = Infinity, default: value } = field2;
|
|
14788
|
+
if (min > max)
|
|
14789
|
+
issue2("max", "Must be at least min");
|
|
14790
|
+
if (value !== void 0 && (value < min || value > max))
|
|
14791
|
+
issue2("default", "Must be within min and max");
|
|
14792
|
+
} else if (field2.type === "select") {
|
|
14793
|
+
const values = new Set(field2.options.map(({ value }) => value));
|
|
14794
|
+
if (values.size !== field2.options.length)
|
|
14795
|
+
issue2("options", "Duplicate option values");
|
|
14796
|
+
if (field2.default !== void 0 && !values.has(field2.default))
|
|
14797
|
+
issue2("default", "Must match an option value");
|
|
14798
|
+
}
|
|
14799
|
+
});
|
|
14800
|
+
var manifestHeader = external_exports.object({
|
|
14801
|
+
manifestVersion: external_exports.int().positive(),
|
|
14802
|
+
id: desktopExtensionIdSchema,
|
|
14803
|
+
name: external_exports.union([extensionName, localizedText(extensionName)]),
|
|
14804
|
+
version: external_exports.string().min(1).max(128),
|
|
14805
|
+
desktopApi: external_exports.int().positive()
|
|
14806
|
+
}).passthrough();
|
|
14807
|
+
var desktopExtensionManifestSchema = manifestHeader.extend({
|
|
14808
|
+
manifestVersion: external_exports.literal(1),
|
|
14809
|
+
desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
|
|
14810
|
+
description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
|
|
14811
|
+
author: external_exports.string().trim().min(1).max(128).optional(),
|
|
14812
|
+
repository: desktopExtensionHttpUrlSchema.optional(),
|
|
14813
|
+
details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
|
|
14814
|
+
icon: imagePathSchema.optional(),
|
|
14815
|
+
screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
|
|
14816
|
+
desktop: external_exports.strictObject({
|
|
14817
|
+
script: pluginRelativeResourceSchema,
|
|
14818
|
+
style: pluginRelativeResourceSchema.optional()
|
|
14819
|
+
}).optional(),
|
|
14820
|
+
backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
|
|
14821
|
+
slots: slotsSchema.default(() => []),
|
|
14822
|
+
settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
|
|
14823
|
+
categories: categoriesSchema.optional()
|
|
14824
|
+
}).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
|
|
14825
|
+
var desktopExtensionConfigurationSchema = external_exports.strictObject({
|
|
14826
|
+
version: external_exports.literal(1),
|
|
14827
|
+
revision: external_exports.int().nonnegative(),
|
|
14828
|
+
enabled: external_exports.array(desktopExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs"),
|
|
14829
|
+
reloadToken: external_exports.uuid().optional()
|
|
14830
|
+
});
|
|
14831
|
+
var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
|
|
14832
|
+
var desktopExtensionStatusSchema = external_exports.strictObject({
|
|
14833
|
+
state: external_exports.enum([
|
|
14834
|
+
"running",
|
|
14835
|
+
"disabled",
|
|
14836
|
+
"invalid",
|
|
14837
|
+
"incompatible",
|
|
14838
|
+
"conflict",
|
|
14839
|
+
"failed",
|
|
14840
|
+
"waiting"
|
|
14841
|
+
]),
|
|
14842
|
+
hash: desktopExtensionHashSchema.optional(),
|
|
14843
|
+
error: external_exports.string().optional(),
|
|
14844
|
+
conflictWith: desktopExtensionIdSchema.optional()
|
|
14845
|
+
});
|
|
14846
|
+
var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
|
|
14847
|
+
controllerPid: external_exports.int().positive(),
|
|
14848
|
+
targetId: external_exports.string().nullable(),
|
|
14849
|
+
updatedAt: external_exports.iso.datetime(),
|
|
14850
|
+
handledReloadToken: external_exports.uuid().optional(),
|
|
14851
|
+
extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema)
|
|
14852
|
+
});
|
|
14853
|
+
var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
|
|
14854
|
+
function isGitHubDesktopExtensionZipballUrl(url2) {
|
|
14855
|
+
return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
|
|
14856
|
+
}
|
|
14857
|
+
var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
|
|
14858
|
+
const url2 = new URL(input);
|
|
14859
|
+
return /\.zip$/iu.test(url2.pathname) || isGitHubDesktopExtensionZipballUrl(url2) || url2.origin === "https://github.com" && /^\/[\w-]+\/[\w.-]+\/zipball(?:\/.+)?\/?$/u.test(url2.pathname) || url2.origin === "https://codeload.github.com" && /^\/[\w-]+\/[\w.-]+\/(?:zip|zipball|legacy\.zip)\/.+$/u.test(url2.pathname);
|
|
14860
|
+
}, "Expected a .zip download URL or a GitHub zipball URL");
|
|
14861
|
+
var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
|
|
14862
|
+
id: desktopExtensionIdSchema,
|
|
14863
|
+
version: external_exports.string().trim().min(1).max(128),
|
|
14864
|
+
name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
|
|
14865
|
+
description: localizedText(external_exports.string().trim().min(1).max(4096)),
|
|
14866
|
+
details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
|
|
14867
|
+
author: external_exports.string().trim().min(1).max(128),
|
|
14868
|
+
repository: desktopExtensionHttpUrlSchema,
|
|
14869
|
+
stars: external_exports.number().int().min(0).optional(),
|
|
14870
|
+
downloads: external_exports.number().int().min(0).optional(),
|
|
14871
|
+
categories: categoriesSchema.optional(),
|
|
14872
|
+
trustTier: desktopExtensionTrustTierSchema.default("community"),
|
|
14873
|
+
icon: desktopExtensionHttpUrlSchema.optional(),
|
|
14874
|
+
screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
14875
|
+
downloadUrl: desktopExtensionZipUrlSchema,
|
|
14876
|
+
sha256: desktopExtensionHashSchema,
|
|
14877
|
+
slots: slotsSchema.optional(),
|
|
14878
|
+
publishedAt: external_exports.string().optional(),
|
|
14879
|
+
updatedAt: external_exports.string().optional(),
|
|
14880
|
+
minCodexHostVersion: external_exports.string().optional()
|
|
14881
|
+
});
|
|
14882
|
+
var desktopExtensionCatalogSchema = external_exports.strictObject({
|
|
14883
|
+
schemaVersion: external_exports.literal(1),
|
|
14884
|
+
generatedAt: external_exports.string(),
|
|
14885
|
+
extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
|
|
14886
|
+
});
|
|
14887
|
+
var DESKTOP_EXTENSIONS_ASSET_METHOD = "codexhost/desktop/extensions/asset";
|
|
14888
|
+
var DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD = "codexhost/desktop/extensions/settings/get";
|
|
14889
|
+
var DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD = "codexhost/desktop/extensions/settings/set";
|
|
14890
|
+
var DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD = "codexhost/desktop/extensions/backend/invoke";
|
|
14891
|
+
var extensionIdParams = { id: desktopExtensionIdSchema };
|
|
14892
|
+
var desktopExtensionsAssetParamsSchema = external_exports.strictObject({
|
|
14893
|
+
...extensionIdParams,
|
|
14894
|
+
path: desktopExtensionAssetPathSchema
|
|
14895
|
+
});
|
|
14896
|
+
var desktopExtensionsAssetResultSchema = external_exports.strictObject({
|
|
14897
|
+
mimeType: external_exports.string(),
|
|
14898
|
+
dataUrl: external_exports.string()
|
|
14899
|
+
});
|
|
14900
|
+
var desktopExtensionsSettingsGetParamsSchema = external_exports.strictObject(extensionIdParams);
|
|
14901
|
+
var desktopExtensionsSettingsSetParamsSchema = external_exports.strictObject({
|
|
14902
|
+
...extensionIdParams,
|
|
14903
|
+
values: jsonObjectSchema
|
|
14904
|
+
});
|
|
14905
|
+
var desktopExtensionsSettingsResultSchema = external_exports.strictObject({ values: jsonObjectSchema });
|
|
14906
|
+
var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
|
|
14907
|
+
var desktopExtensionsBackendInvokeParamsSchema = external_exports.strictObject({
|
|
14908
|
+
...extensionIdParams,
|
|
14909
|
+
method: desktopExtensionBackendMethodSchema,
|
|
14910
|
+
params: jsonValueSchema.optional()
|
|
14911
|
+
});
|
|
14912
|
+
var desktopExtensionsBackendInvokeResultSchema = external_exports.strictObject({
|
|
14913
|
+
result: jsonValueSchema
|
|
14914
|
+
});
|
|
14915
|
+
|
|
14916
|
+
// ../../shared-contracts/dist/desktop-extension-management.js
|
|
14917
|
+
var DESKTOP_EXTENSIONS_LIST_METHOD = "codexhost/desktop/extensions/list";
|
|
14918
|
+
var DESKTOP_EXTENSIONS_ENABLE_METHOD = "codexhost/desktop/extensions/enable";
|
|
14919
|
+
var DESKTOP_EXTENSIONS_DISABLE_METHOD = "codexhost/desktop/extensions/disable";
|
|
14920
|
+
var DESKTOP_EXTENSIONS_CATALOG_METHOD = "codexhost/desktop/extensions/catalog";
|
|
14921
|
+
var DESKTOP_EXTENSIONS_INSTALL_METHOD = "codexhost/desktop/extensions/install";
|
|
14922
|
+
var DESKTOP_EXTENSIONS_UNINSTALL_METHOD = "codexhost/desktop/extensions/uninstall";
|
|
14923
|
+
var DESKTOP_EXTENSIONS_RECOVER_METHOD = "codexhost/desktop/extensions/disable-all-and-reload";
|
|
14924
|
+
var DESKTOP_EXTENSION_MANAGEMENT_METHODS = [
|
|
14925
|
+
DESKTOP_EXTENSIONS_LIST_METHOD,
|
|
14926
|
+
DESKTOP_EXTENSIONS_ENABLE_METHOD,
|
|
14927
|
+
DESKTOP_EXTENSIONS_DISABLE_METHOD,
|
|
14928
|
+
DESKTOP_EXTENSIONS_RECOVER_METHOD,
|
|
14929
|
+
DESKTOP_EXTENSIONS_CATALOG_METHOD,
|
|
14930
|
+
DESKTOP_EXTENSIONS_INSTALL_METHOD,
|
|
14931
|
+
DESKTOP_EXTENSIONS_UNINSTALL_METHOD,
|
|
14932
|
+
DESKTOP_EXTENSIONS_ASSET_METHOD,
|
|
14933
|
+
DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD,
|
|
14934
|
+
DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD,
|
|
14935
|
+
DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD
|
|
14936
|
+
];
|
|
14937
|
+
var revisionSchema = external_exports.int().nonnegative();
|
|
14938
|
+
var desktopExtensionsListParamsSchema = external_exports.strictObject({});
|
|
14939
|
+
var desktopExtensionSelectionParamsSchema = external_exports.strictObject({
|
|
14940
|
+
id: desktopExtensionIdSchema,
|
|
14941
|
+
expectedRevision: revisionSchema
|
|
14942
|
+
});
|
|
14943
|
+
var desktopExtensionsRecoveryParamsSchema = external_exports.strictObject({
|
|
14944
|
+
expectedRevision: revisionSchema.optional()
|
|
14945
|
+
});
|
|
14946
|
+
var rasterDataUrlSchema = (maxBytes) => external_exports.string().max("data:image/jpeg;base64,".length + 4 * Math.ceil(maxBytes / 3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u);
|
|
14947
|
+
var desktopExtensionListItemSchema = external_exports.strictObject({
|
|
14948
|
+
// An invalid discovery can have a directory name that isn't a valid extension ID.
|
|
14949
|
+
id: external_exports.string().min(1),
|
|
14950
|
+
manifest: desktopExtensionManifestSchema.optional(),
|
|
14951
|
+
iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
|
|
14952
|
+
screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
|
|
14953
|
+
enabled: external_exports.boolean(),
|
|
14954
|
+
status: desktopExtensionStatusSchema
|
|
14955
|
+
});
|
|
14956
|
+
var desktopExtensionsListResultSchema = external_exports.strictObject({
|
|
14957
|
+
configuration: desktopExtensionConfigurationSchema,
|
|
14958
|
+
desktopConnected: external_exports.boolean(),
|
|
14959
|
+
diagnostics: external_exports.array(external_exports.string()),
|
|
14960
|
+
extensions: external_exports.array(desktopExtensionListItemSchema)
|
|
14961
|
+
});
|
|
14962
|
+
var desktopExtensionsCatalogParamsSchema = external_exports.strictObject({
|
|
14963
|
+
forceRefresh: external_exports.boolean().optional()
|
|
14964
|
+
});
|
|
14965
|
+
var desktopExtensionsCatalogResultSchema = external_exports.strictObject({
|
|
14966
|
+
catalogUrl: external_exports.string(),
|
|
14967
|
+
source: external_exports.enum(["remote", "fallback"]),
|
|
14968
|
+
fetchedAt: external_exports.string(),
|
|
14969
|
+
cached: external_exports.boolean(),
|
|
14970
|
+
extensions: desktopExtensionCatalogSchema.shape.extensions,
|
|
14971
|
+
error: external_exports.string().optional()
|
|
14972
|
+
});
|
|
14973
|
+
var desktopExtensionsInstallParamsSchema = external_exports.strictObject({
|
|
14974
|
+
source: external_exports.discriminatedUnion("type", [
|
|
14975
|
+
external_exports.strictObject({ type: external_exports.literal("catalog"), id: desktopExtensionIdSchema }),
|
|
14976
|
+
external_exports.strictObject({
|
|
14977
|
+
type: external_exports.literal("url"),
|
|
14978
|
+
url: desktopExtensionHttpUrlSchema,
|
|
14979
|
+
expectedSha256: desktopExtensionHashSchema.optional()
|
|
14980
|
+
}),
|
|
14981
|
+
external_exports.strictObject({
|
|
14982
|
+
type: external_exports.literal("zip-base64"),
|
|
14983
|
+
fileName: external_exports.string().trim().min(1).max(255),
|
|
14984
|
+
contentBase64: external_exports.string().min(4).max(DESKTOP_EXTENSION_ZIP_MAX_BASE64_LENGTH).refine((value) => value.length % 4 === 0 && /^[A-Za-z0-9+/]+={0,2}$/u.test(value), "Expected standard padded base64")
|
|
14985
|
+
})
|
|
14986
|
+
])
|
|
14987
|
+
});
|
|
14988
|
+
var desktopExtensionsInstallResultSchema = external_exports.strictObject({
|
|
14989
|
+
extensionId: desktopExtensionIdSchema,
|
|
14990
|
+
version: external_exports.string().min(1),
|
|
14991
|
+
replaced: external_exports.boolean(),
|
|
14992
|
+
installedPath: external_exports.string(),
|
|
14993
|
+
list: desktopExtensionsListResultSchema
|
|
14994
|
+
});
|
|
14995
|
+
var desktopExtensionsUninstallParamsSchema = external_exports.strictObject({
|
|
14996
|
+
id: desktopExtensionIdSchema
|
|
14997
|
+
});
|
|
14998
|
+
var desktopExtensionsUninstallResultSchema = external_exports.strictObject({
|
|
14999
|
+
removedId: desktopExtensionIdSchema,
|
|
15000
|
+
list: desktopExtensionsListResultSchema
|
|
15001
|
+
});
|
|
15002
|
+
var desktopExtensionMutationResultSchema = external_exports.discriminatedUnion("state", [
|
|
15003
|
+
external_exports.strictObject({ state: external_exports.literal("saved"), configuration: desktopExtensionConfigurationSchema }),
|
|
15004
|
+
external_exports.strictObject({ state: external_exports.literal("slot-conflict"), conflictWith: desktopExtensionIdSchema }),
|
|
15005
|
+
external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: revisionSchema })
|
|
15006
|
+
]);
|
|
15007
|
+
|
|
14587
15008
|
// ../../shared-contracts/dist/errors.js
|
|
14588
15009
|
var codexhostErrorSchema = external_exports.strictObject({
|
|
14589
15010
|
code: external_exports.string().min(1),
|
|
@@ -14604,16 +15025,6 @@ var harnessLocalizationsSchema = external_exports.record(localeSchema, external_
|
|
|
14604
15025
|
}).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
|
|
14605
15026
|
var harnessLocalizedTextSchema = external_exports.record(localeSchema, displayText(4096)).refine((entries) => typeof entries.en === "string", "English fallback is required").refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
|
|
14606
15027
|
|
|
14607
|
-
// ../../shared-contracts/dist/ids.js
|
|
14608
|
-
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
14609
|
-
message: "Identifier must not be empty or whitespace"
|
|
14610
|
-
});
|
|
14611
|
-
var harnessIdSchema = opaqueIdSchema.brand();
|
|
14612
|
-
var hostThreadIdSchema = opaqueIdSchema.brand();
|
|
14613
|
-
var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
14614
|
-
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
14615
|
-
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
14616
|
-
|
|
14617
15028
|
// ../../shared-contracts/dist/harness-permission-modes.js
|
|
14618
15029
|
var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
|
|
14619
15030
|
var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
|
|
@@ -14813,6 +15224,13 @@ var accountCreditsSnapshotSchema = external_exports.object({
|
|
|
14813
15224
|
productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
|
|
14814
15225
|
resetCredits: accountResetCreditsSchema.optional()
|
|
14815
15226
|
}).strict();
|
|
15227
|
+
var accountBalanceSnapshotSchema = external_exports.object({
|
|
15228
|
+
amount: external_exports.number().finite().nonnegative(),
|
|
15229
|
+
/** ISO 4217 code as reported by the Provider, for example `CNY`. */
|
|
15230
|
+
currency: external_exports.string().trim().min(1).max(8),
|
|
15231
|
+
/** Native label when the Harness exposes several Billing Sources. */
|
|
15232
|
+
label: external_exports.string().trim().min(1).max(128).optional()
|
|
15233
|
+
}).strict();
|
|
14816
15234
|
var threadUsageInspectionParamsSchema = external_exports.object({
|
|
14817
15235
|
threadId: hostThreadIdSchema,
|
|
14818
15236
|
refresh: external_exports.literal("exact").optional()
|
|
@@ -14821,7 +15239,10 @@ var threadUsageInspectionSchema = external_exports.object({
|
|
|
14821
15239
|
threadId: hostThreadIdSchema,
|
|
14822
15240
|
usage: threadUsageSnapshotSchema.nullable(),
|
|
14823
15241
|
accountCredits: accountCreditsSnapshotSchema.optional(),
|
|
14824
|
-
/**
|
|
15242
|
+
/** Prepaid funds for the Thread's Billing Source; shown only when no percentage quota exists. */
|
|
15243
|
+
accountBalance: accountBalanceSnapshotSchema.optional(),
|
|
15244
|
+
/** Whether this source can provide cached account quota (credits or a prepaid balance)
|
|
15245
|
+
* independently of usage. */
|
|
14825
15246
|
accountCreditsSupported: external_exports.boolean().optional()
|
|
14826
15247
|
}).strict();
|
|
14827
15248
|
|
|
@@ -14851,6 +15272,11 @@ var harnessModelSchema = external_exports.object({
|
|
|
14851
15272
|
fastModel: harnessModelRefSchema.optional(),
|
|
14852
15273
|
supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
|
|
14853
15274
|
}).strict();
|
|
15275
|
+
function catalogModelForRef(catalog, ref) {
|
|
15276
|
+
if (!ref)
|
|
15277
|
+
return void 0;
|
|
15278
|
+
return catalog?.models.find((model2) => model2.ref.id === ref.id || model2.fastModel?.id === ref.id);
|
|
15279
|
+
}
|
|
14854
15280
|
var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
|
|
14855
15281
|
const ids = /* @__PURE__ */ new Set();
|
|
14856
15282
|
for (const [index, option2] of options.entries()) {
|
|
@@ -15113,12 +15539,89 @@ var threadSteeringInspectResultSchema = external_exports.object({
|
|
|
15113
15539
|
}).strict();
|
|
15114
15540
|
|
|
15115
15541
|
// ../../shared-contracts/dist/thread-archive-confirm.js
|
|
15542
|
+
var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
|
|
15116
15543
|
var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
|
|
15117
15544
|
var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
|
|
15118
15545
|
|
|
15119
15546
|
// ../../shared-contracts/dist/client-channel.js
|
|
15120
15547
|
var CLIENT_CHANNEL_VERSION = 1;
|
|
15121
15548
|
var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
|
|
15549
|
+
var CLIENT_CHANNEL_METHODS = [
|
|
15550
|
+
"codexhost/skills/list",
|
|
15551
|
+
"codexhost/voice/status",
|
|
15552
|
+
"codexhost/voice/transcribe",
|
|
15553
|
+
"codexhost/harness/display-settings/get",
|
|
15554
|
+
"codexhost/harness/display-settings/set",
|
|
15555
|
+
"codexhost/harness/display-settings/capabilities",
|
|
15556
|
+
"codexhost/harness/preferences/get",
|
|
15557
|
+
"codexhost/harness/preferences/patch",
|
|
15558
|
+
"thread/list",
|
|
15559
|
+
"codexhost/thread/catalog/read",
|
|
15560
|
+
"thread/read",
|
|
15561
|
+
"thread/resume",
|
|
15562
|
+
"thread/fork",
|
|
15563
|
+
"thread/turns/list",
|
|
15564
|
+
"thread/revert",
|
|
15565
|
+
"thread/items/list",
|
|
15566
|
+
"thread/start",
|
|
15567
|
+
"thread/name/set",
|
|
15568
|
+
"codexhost/thread/title/generate",
|
|
15569
|
+
"thread/archive",
|
|
15570
|
+
THREAD_ARCHIVE_CONFIRM_METHOD,
|
|
15571
|
+
"thread/unarchive",
|
|
15572
|
+
"turn/start",
|
|
15573
|
+
"turn/interrupt",
|
|
15574
|
+
"turn/steer",
|
|
15575
|
+
"thread/queue/list",
|
|
15576
|
+
"thread/queue/add",
|
|
15577
|
+
"thread/queue/update",
|
|
15578
|
+
"thread/queue/delete",
|
|
15579
|
+
"thread/queue/reorder",
|
|
15580
|
+
"thread/queue/start",
|
|
15581
|
+
"codexhost/thread/queue/send-now",
|
|
15582
|
+
"codexhost/workspace/read",
|
|
15583
|
+
"codexhost/thread/tree/read",
|
|
15584
|
+
"codexhost/thread/pins/list",
|
|
15585
|
+
"codexhost/thread/pins/set",
|
|
15586
|
+
"codexhost/harness/plugins/list",
|
|
15587
|
+
"codexhost/harness/inspect",
|
|
15588
|
+
"codexhost/thread/inspect",
|
|
15589
|
+
"codexhost/thread/usage/inspect",
|
|
15590
|
+
"codexhost/thread/ownership/list",
|
|
15591
|
+
"codexhost/thread/model/select",
|
|
15592
|
+
"codexhost/thread/thinking/select",
|
|
15593
|
+
"codexhost/thread/permission-mode/select",
|
|
15594
|
+
"codexhost/thread/commands/inspect",
|
|
15595
|
+
"codexhost/harness/commands/inspect",
|
|
15596
|
+
"codexhost/thread/command/execute",
|
|
15597
|
+
"codexhost/thread/fork",
|
|
15598
|
+
"codexhost/harness/session-import/sources",
|
|
15599
|
+
"codexhost/harness/session-import/list",
|
|
15600
|
+
"codexhost/harness/session-import/import",
|
|
15601
|
+
// Host settings shared across Desktop and Web.
|
|
15602
|
+
...DESKTOP_EXTENSION_MANAGEMENT_METHODS,
|
|
15603
|
+
"codexhost/harness/installation",
|
|
15604
|
+
"codexhost/harness/installation/start",
|
|
15605
|
+
"codexhost/harness/installation/status",
|
|
15606
|
+
"codexhost/harness/launch-settings/get",
|
|
15607
|
+
"codexhost/harness/launch-settings/set",
|
|
15608
|
+
"codexhost/harness/web-ui/open",
|
|
15609
|
+
"codexhost/harness/accounts/sources",
|
|
15610
|
+
"codexhost/harness/accounts/list",
|
|
15611
|
+
"codexhost/harness/accounts/inspect",
|
|
15612
|
+
"codexhost/harness/credential-imports",
|
|
15613
|
+
"codexhost/account/list",
|
|
15614
|
+
"codexhost/account/refresh",
|
|
15615
|
+
"codexhost/account/usage/inspect",
|
|
15616
|
+
"codexhost/usage/model-prices/get",
|
|
15617
|
+
"codexhost/usage/model-prices/set",
|
|
15618
|
+
"codexhost/usage/model-prices/default",
|
|
15619
|
+
"codexhost/usage/statistics/get",
|
|
15620
|
+
"codexhost/update/check",
|
|
15621
|
+
"codexhost/update/start",
|
|
15622
|
+
"codexhost/update/status",
|
|
15623
|
+
"codexhost/sessions/loaded/list"
|
|
15624
|
+
];
|
|
15122
15625
|
var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
|
|
15123
15626
|
var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
|
|
15124
15627
|
var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
|
|
@@ -15332,6 +15835,29 @@ var threadCatalogReadResultSchema = external_exports.object({
|
|
|
15332
15835
|
officialCursor: external_exports.object({ live: external_exports.string().nullable(), archived: external_exports.string().nullable().optional() }).strict().optional()
|
|
15333
15836
|
}).strict();
|
|
15334
15837
|
|
|
15838
|
+
// ../../shared-contracts/dist/thread-tree-watch.js
|
|
15839
|
+
var THREAD_TREE_MAX_NODES = 5e3;
|
|
15840
|
+
var threadTreeStatusSchema = external_exports.enum(["running", "waiting", "idle", "unknown"]);
|
|
15841
|
+
var threadTreeNodeSchema = external_exports.strictObject({
|
|
15842
|
+
harnessId: harnessIdSchema,
|
|
15843
|
+
title: external_exports.string().optional(),
|
|
15844
|
+
status: threadTreeStatusSchema,
|
|
15845
|
+
archived: external_exports.boolean()
|
|
15846
|
+
});
|
|
15847
|
+
var threadTreeSnapshotSchema = external_exports.strictObject({
|
|
15848
|
+
revision: external_exports.int().nonnegative(),
|
|
15849
|
+
parents: external_exports.record(hostThreadIdSchema, hostThreadIdSchema),
|
|
15850
|
+
nodes: external_exports.record(hostThreadIdSchema, threadTreeNodeSchema),
|
|
15851
|
+
truncated: external_exports.boolean()
|
|
15852
|
+
}).refine((snapshot) => Object.keys(snapshot.nodes).length <= THREAD_TREE_MAX_NODES, "Too many Thread tree nodes").refine(({ parents, nodes }) => Object.entries(parents).every(([child, parent]) => Object.hasOwn(nodes, child) && Object.hasOwn(nodes, parent)), "Missing Thread tree node");
|
|
15853
|
+
var subscriptionId = external_exports.string().min(1).max(128);
|
|
15854
|
+
var threadTreeWatchParamsSchema = external_exports.strictObject({});
|
|
15855
|
+
var threadTreeUnwatchParamsSchema = external_exports.strictObject({ subscriptionId });
|
|
15856
|
+
var threadTreeUnwatchResultSchema = external_exports.strictObject({});
|
|
15857
|
+
var threadTreeWatchResultSchema = threadTreeUnwatchParamsSchema.extend({
|
|
15858
|
+
snapshot: threadTreeSnapshotSchema
|
|
15859
|
+
});
|
|
15860
|
+
|
|
15335
15861
|
// ../../shared-contracts/dist/voice.js
|
|
15336
15862
|
var VOICE_AUDIO_MAX_BYTES = 10 * 1024 * 1024;
|
|
15337
15863
|
var voiceAudioMimeTypeSchema = external_exports.string().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);
|
|
@@ -15962,13 +16488,6 @@ var threadManualCompactionStartedSchema = external_exports.strictObject({
|
|
|
15962
16488
|
});
|
|
15963
16489
|
|
|
15964
16490
|
// ../../shared-contracts/dist/harness-accounts.js
|
|
15965
|
-
var accountBalanceSnapshotSchema = external_exports.object({
|
|
15966
|
-
amount: external_exports.number().finite().nonnegative(),
|
|
15967
|
-
/** ISO 4217 code as reported by the Provider, for example `CNY`. */
|
|
15968
|
-
currency: external_exports.string().trim().min(1).max(8),
|
|
15969
|
-
/** Native label when the Harness exposes several Billing Sources. */
|
|
15970
|
-
label: external_exports.string().trim().min(1).max(128).optional()
|
|
15971
|
-
}).strict();
|
|
15972
16491
|
var harnessAccountSnapshotObject = external_exports.object({
|
|
15973
16492
|
email: external_exports.string().trim().min(1).max(320).optional(),
|
|
15974
16493
|
label: external_exports.string().trim().min(1).max(256).optional(),
|
|
@@ -16002,76 +16521,6 @@ var harnessAccountListResultSchema = external_exports.object({
|
|
|
16002
16521
|
accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
|
|
16003
16522
|
}).strict();
|
|
16004
16523
|
|
|
16005
|
-
// ../../shared-contracts/dist/harness-plugins.js
|
|
16006
|
-
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
16007
|
-
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
16008
|
-
var HARNESS_PLUGIN_LIMIT = 128;
|
|
16009
|
-
var installedHarnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).pipe(harnessIdSchema);
|
|
16010
|
-
var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id2) => id2 !== "codex", "The official Codex identity is reserved");
|
|
16011
|
-
var relativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
|
|
16012
|
-
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
16013
|
-
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
16014
|
-
var harnessInstallationGuideSchema = external_exports.object({
|
|
16015
|
-
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
16016
|
-
before: localizedTextSchema.optional(),
|
|
16017
|
-
after: localizedTextSchema.optional(),
|
|
16018
|
-
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
16019
|
-
}).strict();
|
|
16020
|
-
var pluginPresentationShape = {
|
|
16021
|
-
id: installedHarnessPluginIdSchema,
|
|
16022
|
-
name: external_exports.string().trim().min(1).max(128),
|
|
16023
|
-
version: external_exports.string().min(1).max(128),
|
|
16024
|
-
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
16025
|
-
kind: external_exports.literal("usage").optional(),
|
|
16026
|
-
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
16027
|
-
iconStyle: external_exports.object({
|
|
16028
|
-
vector: external_exports.object({
|
|
16029
|
-
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
16030
|
-
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
16031
|
-
paths: external_exports.array(external_exports.object({
|
|
16032
|
-
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
16033
|
-
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
16034
|
-
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
16035
|
-
}).strict()).min(1).max(32)
|
|
16036
|
-
}).strict().optional(),
|
|
16037
|
-
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
16038
|
-
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
16039
|
-
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
16040
|
-
}).strict().optional(),
|
|
16041
|
-
installation: harnessInstallationGuideSchema.optional(),
|
|
16042
|
-
notice: localizedTextSchema.optional(),
|
|
16043
|
-
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
16044
|
-
launchCommand: external_exports.literal(true).optional(),
|
|
16045
|
-
links: external_exports.object({
|
|
16046
|
-
website: documentationUrlSchema.optional(),
|
|
16047
|
-
documentation: documentationUrlSchema.optional(),
|
|
16048
|
-
installation: documentationUrlSchema.optional()
|
|
16049
|
-
}).strict().optional()
|
|
16050
|
-
};
|
|
16051
|
-
var harnessPluginManifestSchema = external_exports.object({
|
|
16052
|
-
manifestVersion: external_exports.literal(1),
|
|
16053
|
-
...pluginPresentationShape,
|
|
16054
|
-
adapterApiVersion: external_exports.number().int().positive(),
|
|
16055
|
-
entry: relativeResourceSchema,
|
|
16056
|
-
icon: relativeResourceSchema.optional()
|
|
16057
|
-
}).strict();
|
|
16058
|
-
var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
|
|
16059
|
-
var harnessPluginDescriptorSchema = external_exports.object({
|
|
16060
|
-
...pluginPresentationShape,
|
|
16061
|
-
icon: harnessPluginIconSchema.optional()
|
|
16062
|
-
}).strict();
|
|
16063
|
-
var harnessPluginListParamsSchema = external_exports.object({}).strict();
|
|
16064
|
-
var harnessPluginListResultSchema = external_exports.object({
|
|
16065
|
-
plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
|
|
16066
|
-
}).strict();
|
|
16067
|
-
var harnessPluginConfigurationSchema = external_exports.object({
|
|
16068
|
-
version: external_exports.literal(1),
|
|
16069
|
-
enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
16070
|
-
}).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
|
|
16071
|
-
message: "Enabled plugin IDs must be unique",
|
|
16072
|
-
path: ["enabled"]
|
|
16073
|
-
});
|
|
16074
|
-
|
|
16075
16524
|
// ../../shared-contracts/dist/harness-route.js
|
|
16076
16525
|
var harnessPluginRouteSchema = external_exports.object({
|
|
16077
16526
|
harnessId: harnessPluginIdSchema,
|
|
@@ -16435,6 +16884,19 @@ var updateStatusResultSchema = external_exports.strictObject({
|
|
|
16435
16884
|
status: updateStatusSchema.nullable()
|
|
16436
16885
|
});
|
|
16437
16886
|
|
|
16887
|
+
// ../../shared-contracts/dist/desktop-attachments.js
|
|
16888
|
+
var ATTACHED_FILES_HEADING = /^\s*# Files mentioned by the user:[ \t]*(?:\r?\n|$)/u;
|
|
16889
|
+
var REQUEST_HEADING = /(?:^|\n)## My request:[ \t]*(?:\r?\n|$)/u;
|
|
16890
|
+
var IMAGE_ATTACHMENT_PATTERN = /(?:^|\n)## [^\r\n]+: ((?:\/|[A-Za-z]:[\\/]|\\\\)[^\r\n]+)\r?\nImage attachment: true(?=\r?\n|$)/gu;
|
|
16891
|
+
var CONTROL_CHARACTER_PATTERN = /[\u0000-\u001f\u007f]/u;
|
|
16892
|
+
function desktopImageAttachmentPaths(text2) {
|
|
16893
|
+
const end = text2.search(REQUEST_HEADING);
|
|
16894
|
+
const context = end < 0 ? text2 : text2.slice(0, end);
|
|
16895
|
+
if (!ATTACHED_FILES_HEADING.test(context))
|
|
16896
|
+
return [];
|
|
16897
|
+
return [...context.matchAll(IMAGE_ATTACHMENT_PATTERN)].map((match) => match[1] ?? "").filter((path18) => path18.length > 0 && !CONTROL_CHARACTER_PATTERN.test(path18));
|
|
16898
|
+
}
|
|
16899
|
+
|
|
16438
16900
|
// ../../shared-contracts/dist/thread-watch-notice.js
|
|
16439
16901
|
var THREAD_WATCH_NOTICE_OUTCOMES = [
|
|
16440
16902
|
"completed",
|
|
@@ -16506,6 +16968,7 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
|
16506
16968
|
message: "A history continuation requires its connection epoch"
|
|
16507
16969
|
}).optional()
|
|
16508
16970
|
}),
|
|
16971
|
+
external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
|
|
16509
16972
|
external_exports.strictObject({
|
|
16510
16973
|
kind: external_exports.literal("configure"),
|
|
16511
16974
|
...thread,
|
|
@@ -17111,6 +17574,7 @@ function configureSubagentSnapshot(snapshot, parent) {
|
|
|
17111
17574
|
// ../../harness-broker/dist/protocol.js
|
|
17112
17575
|
var HARNESS_BROKER_PROTOCOL_VERSION = 1;
|
|
17113
17576
|
var HARNESS_BROKER_MAX_FRAME_BYTES = 8 * 1024 * 1024;
|
|
17577
|
+
var HARNESS_BROKER_MAX_RESPONSE_BYTES = 32 * 1024 * 1024;
|
|
17114
17578
|
var HARNESS_BROKER_MAX_PENDING_REQUESTS = 32;
|
|
17115
17579
|
var HARNESS_BROKER_REQUEST_TIMEOUT_MS = 15e3;
|
|
17116
17580
|
var HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE = 100;
|
|
@@ -17138,7 +17602,9 @@ var harnessBrokerHelloSchema = external_exports.object({
|
|
|
17138
17602
|
generation: external_exports.string().uuid(),
|
|
17139
17603
|
sequence: external_exports.literal(1),
|
|
17140
17604
|
kind: external_exports.literal("hello"),
|
|
17141
|
-
token: external_exports.string().regex(/^[a-f0-9]{64}$/u)
|
|
17605
|
+
token: external_exports.string().regex(/^[a-f0-9]{64}$/u),
|
|
17606
|
+
// A declared limit must leave room for the hello and frame-size error responses.
|
|
17607
|
+
maxResponseBytes: external_exports.number().int().min(512).max(Number.MAX_SAFE_INTEGER).optional()
|
|
17142
17608
|
}).strict();
|
|
17143
17609
|
var harnessBrokerRequestSchema = external_exports.object({
|
|
17144
17610
|
version: external_exports.literal(HARNESS_BROKER_PROTOCOL_VERSION),
|
|
@@ -17187,40 +17653,63 @@ var harnessBrokerDescriptorSchema = external_exports.object({
|
|
|
17187
17653
|
}).strict();
|
|
17188
17654
|
|
|
17189
17655
|
// ../../harness-broker/dist/framing.js
|
|
17190
|
-
function writeBrokerFrame(socket, value) {
|
|
17656
|
+
function writeBrokerFrame(socket, value, maxBytes = HARNESS_BROKER_MAX_FRAME_BYTES) {
|
|
17191
17657
|
const frame = `${JSON.stringify(value)}
|
|
17192
17658
|
`;
|
|
17193
|
-
if (Buffer.byteLength(frame) >
|
|
17194
|
-
|
|
17659
|
+
if (Buffer.byteLength(frame) > maxBytes) {
|
|
17660
|
+
throw new Error("Harness broker frame exceeds the maximum size");
|
|
17195
17661
|
}
|
|
17196
17662
|
return new Promise((resolve5, reject) => {
|
|
17197
17663
|
socket.write(frame, (error52) => error52 ? reject(error52) : resolve5());
|
|
17198
17664
|
});
|
|
17199
17665
|
}
|
|
17200
|
-
function consumeBrokerFrames(socket, onFrame, onError) {
|
|
17666
|
+
function consumeBrokerFrames(socket, onFrame, onError, maxBytes = HARNESS_BROKER_MAX_FRAME_BYTES) {
|
|
17201
17667
|
let buffered = Buffer.alloc(0);
|
|
17668
|
+
let bufferedBytes = 0;
|
|
17669
|
+
let stopped = false;
|
|
17670
|
+
const fail = (error52) => {
|
|
17671
|
+
stopped = true;
|
|
17672
|
+
buffered = Buffer.alloc(0);
|
|
17673
|
+
bufferedBytes = 0;
|
|
17674
|
+
onError(error52);
|
|
17675
|
+
socket.destroy();
|
|
17676
|
+
};
|
|
17202
17677
|
socket.on("data", (chunk) => {
|
|
17203
|
-
|
|
17204
|
-
if (buffered.length > HARNESS_BROKER_MAX_FRAME_BYTES) {
|
|
17205
|
-
onError(new Error("Harness broker frame exceeds the maximum size"));
|
|
17206
|
-
socket.destroy();
|
|
17678
|
+
if (stopped)
|
|
17207
17679
|
return;
|
|
17208
|
-
|
|
17209
|
-
|
|
17210
|
-
|
|
17211
|
-
const
|
|
17212
|
-
|
|
17213
|
-
if (
|
|
17680
|
+
let start = 0;
|
|
17681
|
+
while (start < chunk.length) {
|
|
17682
|
+
const newline = chunk.indexOf(10, start);
|
|
17683
|
+
const part = chunk.subarray(start, newline < 0 ? chunk.length : newline);
|
|
17684
|
+
const required2 = bufferedBytes + part.length;
|
|
17685
|
+
if (required2 + (newline < 0 ? 0 : 1) > maxBytes) {
|
|
17686
|
+
fail(new Error("Harness broker frame exceeds the maximum size"));
|
|
17687
|
+
return;
|
|
17688
|
+
}
|
|
17689
|
+
if (required2 > buffered.length) {
|
|
17690
|
+
const capacity = Math.min(maxBytes, Math.max(required2, 4096, buffered.length * 2));
|
|
17691
|
+
const next = Buffer.allocUnsafe(capacity);
|
|
17692
|
+
buffered.copy(next, 0, 0, bufferedBytes);
|
|
17693
|
+
buffered = next;
|
|
17694
|
+
}
|
|
17695
|
+
part.copy(buffered, bufferedBytes);
|
|
17696
|
+
bufferedBytes = required2;
|
|
17697
|
+
if (newline < 0)
|
|
17698
|
+
return;
|
|
17699
|
+
const text2 = buffered.toString("utf8", 0, bufferedBytes);
|
|
17700
|
+
bufferedBytes = 0;
|
|
17701
|
+
if (buffered.length > 64 * 1024)
|
|
17702
|
+
buffered = Buffer.alloc(0);
|
|
17703
|
+
if (text2.length > 0) {
|
|
17214
17704
|
try {
|
|
17215
|
-
const value = JSON.parse(
|
|
17705
|
+
const value = JSON.parse(text2);
|
|
17216
17706
|
onFrame(value);
|
|
17217
17707
|
} catch (error52) {
|
|
17218
|
-
|
|
17219
|
-
socket.destroy();
|
|
17708
|
+
fail(error52 instanceof SyntaxError ? new Error("Harness broker received invalid JSON") : error52 instanceof Error ? error52 : new Error(String(error52)));
|
|
17220
17709
|
return;
|
|
17221
17710
|
}
|
|
17222
17711
|
}
|
|
17223
|
-
|
|
17712
|
+
start = newline + 1;
|
|
17224
17713
|
}
|
|
17225
17714
|
});
|
|
17226
17715
|
}
|
|
@@ -17417,6 +17906,7 @@ var eventKeys = /* @__PURE__ */ new Map([
|
|
|
17417
17906
|
["item.updated", /* @__PURE__ */ new Set(["type", "turnId", "itemId", "update"])],
|
|
17418
17907
|
["item.completed", /* @__PURE__ */ new Set(["type", "turnId", "snapshot"])],
|
|
17419
17908
|
["item.detached", /* @__PURE__ */ new Set(["type", "turnId", "itemId"])],
|
|
17909
|
+
["item.background.started", /* @__PURE__ */ new Set(["type", "turnId", "item"])],
|
|
17420
17910
|
["interaction.closed", /* @__PURE__ */ new Set(["type", "interactionId", "turnId", "reason"])],
|
|
17421
17911
|
["turn.completed", /* @__PURE__ */ new Set(["type", "turnId", "nativeTurnRef", "outcome"])],
|
|
17422
17912
|
["session.faulted", /* @__PURE__ */ new Set(["type", "error"])]
|
|
@@ -17455,6 +17945,12 @@ var harnessOutputSchema = external_exports.custom((value) => {
|
|
|
17455
17945
|
return false;
|
|
17456
17946
|
if (event.type === "session.state.changed")
|
|
17457
17947
|
return harnessSessionStateSchema.safeParse(event.state).success;
|
|
17948
|
+
if (event.type === "item.background.started")
|
|
17949
|
+
return hostTurnIdSchema.safeParse(event.turnId).success && external_exports.object({
|
|
17950
|
+
type: external_exports.enum(["agentMessage", "reasoning"]),
|
|
17951
|
+
itemId: hostItemIdSchema,
|
|
17952
|
+
text: external_exports.string()
|
|
17953
|
+
}).strict().safeParse(event.item).success;
|
|
17458
17954
|
if (event.type === "session.faulted")
|
|
17459
17955
|
return harnessErrorSchema.safeParse(event.error).success;
|
|
17460
17956
|
if (event.type === "usage.history")
|
|
@@ -17732,7 +18228,7 @@ var BrokerConnection = class _BrokerConnection {
|
|
|
17732
18228
|
constructor(descriptor, socket) {
|
|
17733
18229
|
this.#descriptor = descriptor;
|
|
17734
18230
|
this.#socket = socket;
|
|
17735
|
-
consumeBrokerFrames(socket, (raw) => this.#frame(raw), (error52) => this.#fail(error52));
|
|
18231
|
+
consumeBrokerFrames(socket, (raw) => this.#frame(raw), (error52) => this.#fail(error52), HARNESS_BROKER_MAX_RESPONSE_BYTES);
|
|
17736
18232
|
socket.once("close", () => this.#fail(new Error("Aqua Harness broker connection closed")));
|
|
17737
18233
|
socket.once("error", (error52) => this.#fail(error52));
|
|
17738
18234
|
}
|
|
@@ -17769,7 +18265,8 @@ var BrokerConnection = class _BrokerConnection {
|
|
|
17769
18265
|
generation: descriptor.generation,
|
|
17770
18266
|
sequence: 1,
|
|
17771
18267
|
kind: "hello",
|
|
17772
|
-
token: descriptor.token
|
|
18268
|
+
token: descriptor.token,
|
|
18269
|
+
maxResponseBytes: HARNESS_BROKER_MAX_RESPONSE_BYTES
|
|
17773
18270
|
});
|
|
17774
18271
|
await hello;
|
|
17775
18272
|
return connection;
|
|
@@ -18602,6 +19099,7 @@ function claudePromptCacheIndicators(accountCreditsSupported, lastResponseAtUnix
|
|
|
18602
19099
|
// dist/claude-code-adapter.js
|
|
18603
19100
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
18604
19101
|
import path15 from "node:path";
|
|
19102
|
+
import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
|
|
18605
19103
|
|
|
18606
19104
|
// ../../../node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
|
|
18607
19105
|
import { createRequire as jre } from "node:module";
|
|
@@ -54528,9 +55026,14 @@ var ClaudeSessionImportIndex = class {
|
|
|
54528
55026
|
async #scan(signal) {
|
|
54529
55027
|
const next = /* @__PURE__ */ new Map();
|
|
54530
55028
|
const identities = /* @__PURE__ */ new Set();
|
|
55029
|
+
const ambiguous = /* @__PURE__ */ new Set();
|
|
54531
55030
|
const sources = [];
|
|
54532
55031
|
for (const file2 of await sessionFiles(this.#directory, signal)) {
|
|
54533
55032
|
signal.throwIfAborted();
|
|
55033
|
+
const nativeSessionId = path4.basename(file2, ".jsonl");
|
|
55034
|
+
if (identities.has(nativeSessionId))
|
|
55035
|
+
ambiguous.add(nativeSessionId);
|
|
55036
|
+
identities.add(nativeSessionId);
|
|
54534
55037
|
try {
|
|
54535
55038
|
const fingerprint = await stat2(file2);
|
|
54536
55039
|
const cached2 = this.#cache.get(file2);
|
|
@@ -54539,10 +55042,6 @@ var ClaudeSessionImportIndex = class {
|
|
|
54539
55042
|
continue;
|
|
54540
55043
|
if (!(await stat2(source.candidate.cwd)).isDirectory())
|
|
54541
55044
|
continue;
|
|
54542
|
-
if (identities.has(source.candidate.nativeSessionId)) {
|
|
54543
|
-
throw new Error("Claude Code Session identity is ambiguous across files");
|
|
54544
|
-
}
|
|
54545
|
-
identities.add(source.candidate.nativeSessionId);
|
|
54546
55045
|
next.set(file2, { fingerprint, source });
|
|
54547
55046
|
sources.push(source);
|
|
54548
55047
|
} catch (error52) {
|
|
@@ -54551,7 +55050,7 @@ var ClaudeSessionImportIndex = class {
|
|
|
54551
55050
|
}
|
|
54552
55051
|
}
|
|
54553
55052
|
this.#cache = next;
|
|
54554
|
-
return structuredClone(sources.sort((left, right) => right.candidate.updatedAt - left.candidate.updatedAt));
|
|
55053
|
+
return structuredClone(sources.filter((source) => !ambiguous.has(source.candidate.nativeSessionId)).sort((left, right) => right.candidate.updatedAt - left.candidate.updatedAt));
|
|
54555
55054
|
}
|
|
54556
55055
|
async resolve(nativeSessionId, signal) {
|
|
54557
55056
|
if (!external_exports.uuid().safeParse(nativeSessionId).success)
|
|
@@ -55314,6 +55813,105 @@ function projectClaudeFileChange(value, cwd) {
|
|
|
55314
55813
|
return { path: normalizedPath, kind: value.kind, unifiedDiff };
|
|
55315
55814
|
}
|
|
55316
55815
|
|
|
55816
|
+
// dist/thinking-signature.js
|
|
55817
|
+
import { atob as atob2 } from "node:buffer";
|
|
55818
|
+
import { TextDecoder as TextDecoder2 } from "node:util";
|
|
55819
|
+
var MAX_VARINT_BYTES = 10;
|
|
55820
|
+
var WIRE_TYPE_VARINT = 0;
|
|
55821
|
+
var WIRE_TYPE_FIXED_64 = 1;
|
|
55822
|
+
var WIRE_TYPE_LENGTH_DELIMITED = 2;
|
|
55823
|
+
var WIRE_TYPE_FIXED_32 = 5;
|
|
55824
|
+
var SIGNATURE_FIELD = 2;
|
|
55825
|
+
var METADATA_FIELD = 1;
|
|
55826
|
+
var KIND_FIELD = 8;
|
|
55827
|
+
var NARRATION_KIND = "narration";
|
|
55828
|
+
var kindDecoder = new TextDecoder2("utf-8", { ignoreBOM: true });
|
|
55829
|
+
function readVarint(bytes, offset) {
|
|
55830
|
+
let value = 0;
|
|
55831
|
+
let factor = 1;
|
|
55832
|
+
for (let i = 0; i < MAX_VARINT_BYTES; i += 1) {
|
|
55833
|
+
const index = offset + i;
|
|
55834
|
+
if (index >= bytes.length)
|
|
55835
|
+
return void 0;
|
|
55836
|
+
const byte = bytes[index];
|
|
55837
|
+
if (byte === void 0)
|
|
55838
|
+
return void 0;
|
|
55839
|
+
value += (byte & 127) * factor;
|
|
55840
|
+
if ((byte & 128) === 0)
|
|
55841
|
+
return { value, next: index + 1 };
|
|
55842
|
+
factor *= 128;
|
|
55843
|
+
}
|
|
55844
|
+
return void 0;
|
|
55845
|
+
}
|
|
55846
|
+
function readLengthDelimitedField(bytes, fieldNumber) {
|
|
55847
|
+
let found;
|
|
55848
|
+
let offset = 0;
|
|
55849
|
+
while (offset < bytes.length) {
|
|
55850
|
+
const tag = readVarint(bytes, offset);
|
|
55851
|
+
if (tag === void 0)
|
|
55852
|
+
return void 0;
|
|
55853
|
+
const wireType = tag.value & 7;
|
|
55854
|
+
const tagFieldNumber = Math.floor(tag.value / 8);
|
|
55855
|
+
offset = tag.next;
|
|
55856
|
+
switch (wireType) {
|
|
55857
|
+
case WIRE_TYPE_VARINT: {
|
|
55858
|
+
const field2 = readVarint(bytes, offset);
|
|
55859
|
+
if (field2 === void 0)
|
|
55860
|
+
return void 0;
|
|
55861
|
+
offset = field2.next;
|
|
55862
|
+
break;
|
|
55863
|
+
}
|
|
55864
|
+
case WIRE_TYPE_FIXED_64:
|
|
55865
|
+
if (offset + 8 > bytes.length)
|
|
55866
|
+
return void 0;
|
|
55867
|
+
offset += 8;
|
|
55868
|
+
break;
|
|
55869
|
+
case WIRE_TYPE_LENGTH_DELIMITED: {
|
|
55870
|
+
const length = readVarint(bytes, offset);
|
|
55871
|
+
if (length === void 0 || length.value > bytes.length - length.next)
|
|
55872
|
+
return void 0;
|
|
55873
|
+
const end = length.next + length.value;
|
|
55874
|
+
if (tagFieldNumber === fieldNumber)
|
|
55875
|
+
found = bytes.subarray(length.next, end);
|
|
55876
|
+
offset = end;
|
|
55877
|
+
break;
|
|
55878
|
+
}
|
|
55879
|
+
case WIRE_TYPE_FIXED_32:
|
|
55880
|
+
if (offset + 4 > bytes.length)
|
|
55881
|
+
return void 0;
|
|
55882
|
+
offset += 4;
|
|
55883
|
+
break;
|
|
55884
|
+
default:
|
|
55885
|
+
return void 0;
|
|
55886
|
+
}
|
|
55887
|
+
}
|
|
55888
|
+
return found;
|
|
55889
|
+
}
|
|
55890
|
+
function decodeSignatureKind(signature) {
|
|
55891
|
+
let binary;
|
|
55892
|
+
try {
|
|
55893
|
+
binary = atob2(signature);
|
|
55894
|
+
} catch {
|
|
55895
|
+
return void 0;
|
|
55896
|
+
}
|
|
55897
|
+
const bytes = new Uint8Array(binary.length);
|
|
55898
|
+
for (let i = 0; i < binary.length; i += 1)
|
|
55899
|
+
bytes[i] = binary.charCodeAt(i);
|
|
55900
|
+
const signed = readLengthDelimitedField(bytes, SIGNATURE_FIELD);
|
|
55901
|
+
if (signed === void 0)
|
|
55902
|
+
return void 0;
|
|
55903
|
+
const metadata = readLengthDelimitedField(signed, METADATA_FIELD);
|
|
55904
|
+
if (metadata === void 0)
|
|
55905
|
+
return void 0;
|
|
55906
|
+
const kind = readLengthDelimitedField(metadata, KIND_FIELD);
|
|
55907
|
+
return kind === void 0 ? void 0 : kindDecoder.decode(kind);
|
|
55908
|
+
}
|
|
55909
|
+
function isClaudeNarrationSignature(signature) {
|
|
55910
|
+
if (typeof signature !== "string")
|
|
55911
|
+
return false;
|
|
55912
|
+
return decodeSignatureKind(signature) === NARRATION_KIND;
|
|
55913
|
+
}
|
|
55914
|
+
|
|
55317
55915
|
// dist/native-message.js
|
|
55318
55916
|
var ABORTED_TERMINALS = /* @__PURE__ */ new Set(["aborted_streaming", "aborted_tools"]);
|
|
55319
55917
|
var AUTHENTICATION_ERRORS = /* @__PURE__ */ new Set(["authentication_failed", "oauth_org_not_allowed"]);
|
|
@@ -55649,6 +56247,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
55649
56247
|
#completedToolIds = /* @__PURE__ */ new Set();
|
|
55650
56248
|
#messageOrdinal = 0;
|
|
55651
56249
|
#messages = /* @__PURE__ */ new Map();
|
|
56250
|
+
#completedThinkingBlocks = /* @__PURE__ */ new Set();
|
|
55652
56251
|
#protocolConflict = false;
|
|
55653
56252
|
#textConflict = false;
|
|
55654
56253
|
#tools = /* @__PURE__ */ new Map();
|
|
@@ -55787,7 +56386,8 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
55787
56386
|
if (message.type !== "system")
|
|
55788
56387
|
return;
|
|
55789
56388
|
if (message.subtype === "init") {
|
|
55790
|
-
|
|
56389
|
+
const mcpServers = Array.isArray(message.mcp_servers) ? message.mcp_servers.flatMap((server) => isRecord7(server) && typeof server.name === "string" ? [server.name] : []) : void 0;
|
|
56390
|
+
events.push({ type: "segment.started", ...mcpServers ? { mcpServers } : {} });
|
|
55791
56391
|
return;
|
|
55792
56392
|
}
|
|
55793
56393
|
if (message.subtype !== "background_tasks_changed" || !Array.isArray(message.tasks))
|
|
@@ -55947,29 +56547,66 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
55947
56547
|
this.#messageState(event.message.id);
|
|
55948
56548
|
return;
|
|
55949
56549
|
}
|
|
55950
|
-
|
|
56550
|
+
const index = typeof event.index === "number" ? event.index : 0;
|
|
56551
|
+
if (event.type === "content_block_stop") {
|
|
56552
|
+
const messageId2 = this.#activeRootStreamMessageId;
|
|
56553
|
+
if (messageId2 === null)
|
|
56554
|
+
return;
|
|
56555
|
+
const thinking2 = this.#messages.get(messageId2)?.thinking.get(index);
|
|
56556
|
+
if (thinking2 && !thinking2.stopped) {
|
|
56557
|
+
const blockId = `${messageId2}:thinking:${index}`;
|
|
56558
|
+
this.#completeStreamedThinking(thinking2, blockId, events);
|
|
56559
|
+
this.#publishNarration(thinking2, blockId, thinking2.signature, thinking2.text, events);
|
|
56560
|
+
}
|
|
56561
|
+
return;
|
|
56562
|
+
}
|
|
56563
|
+
const start = event.type === "content_block_start" && isRecord7(event.content_block) && event.content_block.type === "thinking" ? event.content_block : null;
|
|
56564
|
+
const delta = event.type === "content_block_delta" && isRecord7(event.delta) ? event.delta : null;
|
|
56565
|
+
if (!start && !delta)
|
|
55951
56566
|
return;
|
|
55952
56567
|
const messageId = this.#activeRootStreamMessageId ?? nativeUuid(message) ?? this.#nextMessageId();
|
|
55953
56568
|
if (!this.#activeRootStreamMessageId)
|
|
55954
56569
|
this.#activeRootStreamMessageId = messageId;
|
|
55955
56570
|
const state = this.#messageState(messageId);
|
|
55956
56571
|
if (state.completed) {
|
|
55957
|
-
if (
|
|
56572
|
+
if (delta?.type === "text_delta")
|
|
55958
56573
|
this.#textConflict = true;
|
|
55959
56574
|
return;
|
|
55960
56575
|
}
|
|
55961
|
-
if (
|
|
55962
|
-
if (
|
|
56576
|
+
if (delta?.type === "text_delta" && typeof delta.text === "string") {
|
|
56577
|
+
if (delta.text.length === 0)
|
|
55963
56578
|
return;
|
|
55964
|
-
state.text +=
|
|
55965
|
-
events.push({ type: "text.delta", messageId, delta:
|
|
56579
|
+
state.text += delta.text;
|
|
56580
|
+
events.push({ type: "text.delta", messageId, delta: delta.text });
|
|
55966
56581
|
return;
|
|
55967
56582
|
}
|
|
55968
|
-
|
|
55969
|
-
|
|
55970
|
-
|
|
55971
|
-
|
|
55972
|
-
|
|
56583
|
+
const text2 = delta?.type === "thinking_delta" && typeof delta.thinking === "string" ? delta.thinking : "";
|
|
56584
|
+
const signature = delta?.type === "signature_delta" && typeof delta.signature === "string" ? delta.signature : "";
|
|
56585
|
+
if (!start && !text2 && !signature)
|
|
56586
|
+
return;
|
|
56587
|
+
let thinking = state.thinking.get(index);
|
|
56588
|
+
if (!thinking) {
|
|
56589
|
+
thinking = {
|
|
56590
|
+
text: typeof start?.thinking === "string" ? start.thinking : "",
|
|
56591
|
+
signature: typeof start?.signature === "string" ? start.signature : "",
|
|
56592
|
+
streamed: false,
|
|
56593
|
+
stopped: false,
|
|
56594
|
+
matched: false,
|
|
56595
|
+
narrationPublished: false
|
|
56596
|
+
};
|
|
56597
|
+
state.thinking.set(index, thinking);
|
|
56598
|
+
}
|
|
56599
|
+
if (thinking.stopped)
|
|
56600
|
+
return;
|
|
56601
|
+
thinking.signature += signature;
|
|
56602
|
+
if (text2) {
|
|
56603
|
+
thinking.text += text2;
|
|
56604
|
+
thinking.streamed = true;
|
|
56605
|
+
events.push({
|
|
56606
|
+
type: "reasoning.delta",
|
|
56607
|
+
messageId: `${messageId}:thinking:${index}`,
|
|
56608
|
+
delta: text2
|
|
56609
|
+
});
|
|
55973
56610
|
}
|
|
55974
56611
|
}
|
|
55975
56612
|
#consumeAssistantMessage(message, events) {
|
|
@@ -55977,6 +56614,33 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
55977
56614
|
const nativeMessageId = assistantNativeMessageId(message);
|
|
55978
56615
|
const messageId = this.#activeRootStreamMessageId ?? nativeMessageId ?? checkpointId ?? this.#nextMessageId();
|
|
55979
56616
|
const state = this.#messageState(messageId);
|
|
56617
|
+
const content = assistantContent(message) ?? [];
|
|
56618
|
+
for (const [index, block] of content.entries()) {
|
|
56619
|
+
if (!isRecord7(block) || block.type !== "thinking")
|
|
56620
|
+
continue;
|
|
56621
|
+
const identity2 = `${checkpointId ?? nativeMessageId ?? messageId}:${index}`;
|
|
56622
|
+
if (this.#completedThinkingBlocks.has(identity2))
|
|
56623
|
+
continue;
|
|
56624
|
+
this.#completedThinkingBlocks.add(identity2);
|
|
56625
|
+
const streamedIndex = content.length === 1 ? [...state.thinking].find(([, thinking2]) => !thinking2.matched)?.[0] : index;
|
|
56626
|
+
const thinking = streamedIndex === void 0 ? void 0 : state.thinking.get(streamedIndex);
|
|
56627
|
+
const blockId = `${messageId}:thinking:${streamedIndex ?? index}`;
|
|
56628
|
+
if (thinking) {
|
|
56629
|
+
thinking.matched = true;
|
|
56630
|
+
this.#completeStreamedThinking(thinking, blockId, events);
|
|
56631
|
+
}
|
|
56632
|
+
const streamed = thinking?.text ?? "";
|
|
56633
|
+
const complete = typeof block.thinking === "string" ? block.thinking : "";
|
|
56634
|
+
this.#publishNarration(thinking, blockId, block.signature || thinking?.signature, complete.startsWith(streamed) ? complete : streamed, events);
|
|
56635
|
+
}
|
|
56636
|
+
const keepsStreaming = nativeMessageId !== null && nativeMessageId === this.#activeRootStreamMessageId && content.length === 1 && isRecord7(content[0]) && content[0].type === "thinking";
|
|
56637
|
+
if (keepsStreaming && checkpointId && this.#publishedCheckpointIds.has(checkpointId))
|
|
56638
|
+
return;
|
|
56639
|
+
if (!keepsStreaming) {
|
|
56640
|
+
for (const [index, thinking] of state.thinking) {
|
|
56641
|
+
this.#completeStreamedThinking(thinking, `${messageId}:thinking:${index}`, events);
|
|
56642
|
+
}
|
|
56643
|
+
}
|
|
55980
56644
|
if (state.completed) {
|
|
55981
56645
|
const splitText = checkpointId && !this.#publishedCheckpointIds.has(checkpointId) ? assistantText(message) : null;
|
|
55982
56646
|
if (checkpointId && splitText) {
|
|
@@ -56010,9 +56674,6 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
56010
56674
|
}
|
|
56011
56675
|
return;
|
|
56012
56676
|
}
|
|
56013
|
-
if (state.reasoning.length > 0) {
|
|
56014
|
-
events.push({ type: "reasoning.completed", messageId });
|
|
56015
|
-
}
|
|
56016
56677
|
const completeText = assistantText(message);
|
|
56017
56678
|
if (completeText !== null && completeText.length > 0) {
|
|
56018
56679
|
if (completeText.startsWith(state.text)) {
|
|
@@ -56027,8 +56688,9 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
56027
56688
|
}
|
|
56028
56689
|
this.#consumeToolUseBlocks(message, events, false);
|
|
56029
56690
|
if (!this.#protocolConflict && !this.#textConflict) {
|
|
56030
|
-
const usage = assistantRequestUsage(message, this.#provider);
|
|
56031
|
-
|
|
56691
|
+
const usage = state.usagePublished ? void 0 : assistantRequestUsage(message, this.#provider);
|
|
56692
|
+
if (usage)
|
|
56693
|
+
state.usagePublished = true;
|
|
56032
56694
|
events.push({
|
|
56033
56695
|
type: "message.completed",
|
|
56034
56696
|
messageId,
|
|
@@ -56036,12 +56698,33 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
56036
56698
|
...usage ? { lastRequestUsage: usage } : {}
|
|
56037
56699
|
});
|
|
56038
56700
|
}
|
|
56039
|
-
state.completed = true;
|
|
56040
56701
|
if (checkpointId)
|
|
56041
56702
|
this.#publishedCheckpointIds.add(checkpointId);
|
|
56703
|
+
if (keepsStreaming)
|
|
56704
|
+
return;
|
|
56705
|
+
state.completed = true;
|
|
56042
56706
|
if (this.#activeRootStreamMessageId === messageId)
|
|
56043
56707
|
this.#activeRootStreamMessageId = null;
|
|
56044
56708
|
}
|
|
56709
|
+
#completeStreamedThinking(thinking, messageId, events) {
|
|
56710
|
+
if (thinking.stopped)
|
|
56711
|
+
return;
|
|
56712
|
+
thinking.stopped = true;
|
|
56713
|
+
if (thinking.streamed)
|
|
56714
|
+
events.push({ type: "reasoning.completed", messageId });
|
|
56715
|
+
}
|
|
56716
|
+
#publishNarration(thinking, messageId, signature, text2, events) {
|
|
56717
|
+
if (!text2 || thinking?.narrationPublished || !isClaudeNarrationSignature(signature))
|
|
56718
|
+
return;
|
|
56719
|
+
if (thinking)
|
|
56720
|
+
thinking.narrationPublished = true;
|
|
56721
|
+
events.push({
|
|
56722
|
+
type: "narration.completed",
|
|
56723
|
+
messageId,
|
|
56724
|
+
text: text2,
|
|
56725
|
+
...thinking?.streamed ? {} : { completeOnly: true }
|
|
56726
|
+
});
|
|
56727
|
+
}
|
|
56045
56728
|
#consumeToolUseBlocks(message, events, ignoreKnownIds) {
|
|
56046
56729
|
for (const block of assistantContent(message) ?? []) {
|
|
56047
56730
|
if (!isRecord7(block) || block.type !== "tool_use")
|
|
@@ -56181,7 +56864,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
56181
56864
|
return existing;
|
|
56182
56865
|
const created = {
|
|
56183
56866
|
completed: false,
|
|
56184
|
-
|
|
56867
|
+
thinking: /* @__PURE__ */ new Map(),
|
|
56185
56868
|
text: "",
|
|
56186
56869
|
usagePublished: false
|
|
56187
56870
|
};
|
|
@@ -56194,6 +56877,31 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
56194
56877
|
}
|
|
56195
56878
|
};
|
|
56196
56879
|
|
|
56880
|
+
// dist/claude-tool-item.js
|
|
56881
|
+
function mcpServerSegment(server) {
|
|
56882
|
+
const segment = server.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
56883
|
+
return server.startsWith("claude.ai ") ? segment.replace(/_+/g, "_").replace(/^_|_$/g, "") : segment;
|
|
56884
|
+
}
|
|
56885
|
+
function mcpTool(toolName, servers) {
|
|
56886
|
+
if (!toolName.startsWith("mcp__"))
|
|
56887
|
+
return null;
|
|
56888
|
+
const known = servers.map((server2) => `mcp__${mcpServerSegment(server2)}__`).filter((prefix) => toolName.length > prefix.length && toolName.startsWith(prefix)).sort((left, right) => right.length - left.length)[0];
|
|
56889
|
+
if (known)
|
|
56890
|
+
return { server: known.slice(5, -2), tool: toolName.slice(known.length) };
|
|
56891
|
+
const [, server, ...tool] = toolName.split("__");
|
|
56892
|
+
const name = tool.join("__");
|
|
56893
|
+
return server && name ? { server, tool: name } : null;
|
|
56894
|
+
}
|
|
56895
|
+
function claudeToolItem(itemId, toolName, args, mcpServers = []) {
|
|
56896
|
+
const mcp = mcpTool(toolName, mcpServers);
|
|
56897
|
+
if (mcp)
|
|
56898
|
+
return { type: "mcpToolCall", itemId, ...mcp, arguments: args };
|
|
56899
|
+
if (toolName === "WebSearch" && typeof args === "object" && args !== null && !Array.isArray(args) && typeof args.query === "string" && args.query.length > 0) {
|
|
56900
|
+
return { type: "webSearch", itemId, query: args.query };
|
|
56901
|
+
}
|
|
56902
|
+
return { type: "toolExecution", itemId, toolName, arguments: args };
|
|
56903
|
+
}
|
|
56904
|
+
|
|
56197
56905
|
// dist/item-identity.js
|
|
56198
56906
|
function claudeTranscriptItemId(nativeTurnKey, kind, ordinal) {
|
|
56199
56907
|
return hostItemIdSchema.parse(`claude-item-v2-${nativeTurnKey}-${kind}-${ordinal}`);
|
|
@@ -56208,10 +56916,18 @@ function readClaudeQueuedCommand(value, sessionId) {
|
|
|
56208
56916
|
if (value.type !== "attachment" || !isRecord8(attachment) || attachment.type !== "queued_command" || attachment.commandMode !== "prompt" || !isRecord8(attachment.origin) || attachment.origin.kind !== "human" || attachment.humanTurn === false || attachment.isMeta === true || attachment.isSynthetic === true || value.isMeta === true || value.isSynthetic === true || value.isSidechain === true || isRecord8(value.origin) && value.origin.kind !== "human" || typeof value.parent_tool_use_id === "string" && value.parent_tool_use_id.length > 0 || value.sessionId !== void 0 && value.sessionId !== sessionId || value.session_id !== sessionId) {
|
|
56209
56917
|
return null;
|
|
56210
56918
|
}
|
|
56211
|
-
|
|
56919
|
+
const prompt = promptText(attachment.prompt);
|
|
56920
|
+
if (typeof value.uuid !== "string" || value.uuid.length === 0 || typeof attachment.source_uuid !== "string" || attachment.source_uuid.length === 0 || prompt.length === 0) {
|
|
56212
56921
|
throw new Error("Claude queued human input has an invalid identity or text prompt");
|
|
56213
56922
|
}
|
|
56214
|
-
return { uuid: value.uuid, sourceUuid: attachment.source_uuid, prompt
|
|
56923
|
+
return { uuid: value.uuid, sourceUuid: attachment.source_uuid, prompt };
|
|
56924
|
+
}
|
|
56925
|
+
function promptText(prompt) {
|
|
56926
|
+
if (typeof prompt === "string")
|
|
56927
|
+
return prompt;
|
|
56928
|
+
if (!Array.isArray(prompt))
|
|
56929
|
+
return "";
|
|
56930
|
+
return prompt.flatMap((block) => isRecord8(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("\n");
|
|
56215
56931
|
}
|
|
56216
56932
|
|
|
56217
56933
|
// dist/claude-history.js
|
|
@@ -56245,11 +56961,6 @@ function textParts(value) {
|
|
|
56245
56961
|
return [];
|
|
56246
56962
|
return value.flatMap((part) => isRecord9(part) && part.type === "text" && typeof part.text === "string" ? [part.text] : []);
|
|
56247
56963
|
}
|
|
56248
|
-
function thinkingParts(value) {
|
|
56249
|
-
if (!Array.isArray(value))
|
|
56250
|
-
return [];
|
|
56251
|
-
return value.flatMap((part) => isRecord9(part) && part.type === "thinking" && typeof part.thinking === "string" ? [part.thinking] : []);
|
|
56252
|
-
}
|
|
56253
56964
|
var localCommandRecordPattern = /^\s*<(local-command-(?:stdout|caveat))>[\s\S]*<\/\1>\s*$/u;
|
|
56254
56965
|
var taskNotificationRecordPattern = /^\s*<task-notification>[\s\S]*<\/task-notification>\s*$/u;
|
|
56255
56966
|
var commandEnvelopePattern = /^\s*(?:<(command-(?:message|name|args))>[\s\S]*?<\/\1>\s*)+$/u;
|
|
@@ -56482,10 +57193,10 @@ function itemOutcome(outcome) {
|
|
|
56482
57193
|
function isCheckpointCandidate(message) {
|
|
56483
57194
|
return !message.nested && (message.type === "assistant" || message.interrupted || hasRootToolResult(message));
|
|
56484
57195
|
}
|
|
56485
|
-
function mapClaudeSnapshot(values, sessionId) {
|
|
56486
|
-
return mapClaudeSnapshotWithCheckpointIds(values, sessionId).snapshot;
|
|
57196
|
+
function mapClaudeSnapshot(values, sessionId, mcpServers) {
|
|
57197
|
+
return mapClaudeSnapshotWithCheckpointIds(values, sessionId, mcpServers).snapshot;
|
|
56487
57198
|
}
|
|
56488
|
-
function mapClaudeSnapshotWithCheckpointIds(values, sessionId) {
|
|
57199
|
+
function mapClaudeSnapshotWithCheckpointIds(values, sessionId, mcpServers) {
|
|
56489
57200
|
const messages = conversationMessages(values, sessionId);
|
|
56490
57201
|
const turns = [];
|
|
56491
57202
|
const turnCheckpointIds = [];
|
|
@@ -56562,7 +57273,6 @@ function mapClaudeSnapshotWithCheckpointIds(values, sessionId) {
|
|
|
56562
57273
|
const assistantOutcome = outcome.status === "failed" && (!message.failed || message.nested) ? { status: "succeeded" } : itemOutcome(outcome);
|
|
56563
57274
|
const content = message.message.content;
|
|
56564
57275
|
const text2 = textParts(content).join("");
|
|
56565
|
-
const reasoning = thinkingParts(content).join("");
|
|
56566
57276
|
if (!Array.isArray(content)) {
|
|
56567
57277
|
return text2.length > 0 ? [
|
|
56568
57278
|
{
|
|
@@ -56576,21 +57286,34 @@ function mapClaudeSnapshotWithCheckpointIds(values, sessionId) {
|
|
|
56576
57286
|
] : [];
|
|
56577
57287
|
}
|
|
56578
57288
|
const items = [];
|
|
56579
|
-
let projectedReasoning = false;
|
|
56580
57289
|
let projectedText = false;
|
|
56581
57290
|
for (const [blockIndex, block] of content.entries()) {
|
|
56582
57291
|
if (!isRecord9(block))
|
|
56583
57292
|
continue;
|
|
56584
|
-
if (block.type === "thinking" &&
|
|
56585
|
-
|
|
56586
|
-
|
|
56587
|
-
|
|
56588
|
-
|
|
56589
|
-
|
|
56590
|
-
|
|
56591
|
-
|
|
56592
|
-
|
|
56593
|
-
|
|
57293
|
+
if (block.type === "thinking" && typeof block.thinking === "string") {
|
|
57294
|
+
if (block.thinking.length === 0)
|
|
57295
|
+
continue;
|
|
57296
|
+
reasoningOrdinal += 1;
|
|
57297
|
+
if (isClaudeNarrationSignature(block.signature)) {
|
|
57298
|
+
items.push({
|
|
57299
|
+
item: {
|
|
57300
|
+
type: "agentMessage",
|
|
57301
|
+
itemId: claudeTranscriptItemId(user.uuid, "agentMessage", agentMessageOrdinal += 1),
|
|
57302
|
+
text: block.thinking,
|
|
57303
|
+
phase: "commentary"
|
|
57304
|
+
},
|
|
57305
|
+
outcome: assistantOutcome
|
|
57306
|
+
});
|
|
57307
|
+
} else {
|
|
57308
|
+
items.push({
|
|
57309
|
+
item: {
|
|
57310
|
+
type: "reasoning",
|
|
57311
|
+
itemId: claudeTranscriptItemId(user.uuid, "reasoning", reasoningOrdinal),
|
|
57312
|
+
text: block.thinking
|
|
57313
|
+
},
|
|
57314
|
+
outcome: assistantOutcome
|
|
57315
|
+
});
|
|
57316
|
+
}
|
|
56594
57317
|
continue;
|
|
56595
57318
|
}
|
|
56596
57319
|
if (block.type === "text" && !projectedText && text2.length > 0) {
|
|
@@ -56635,15 +57358,8 @@ function mapClaudeSnapshotWithCheckpointIds(values, sessionId) {
|
|
|
56635
57358
|
});
|
|
56636
57359
|
continue;
|
|
56637
57360
|
}
|
|
56638
|
-
const argumentsResult = jsonValueSchema.safeParse(block.input);
|
|
56639
57361
|
items.push({
|
|
56640
|
-
item:
|
|
56641
|
-
type: "toolExecution",
|
|
56642
|
-
itemId,
|
|
56643
|
-
toolName: block.name,
|
|
56644
|
-
arguments: argumentsResult.success ? argumentsResult.data : null,
|
|
56645
|
-
...output ? { output: { content: [{ type: "text", text: output }] } } : {}
|
|
56646
|
-
},
|
|
57362
|
+
item: historyToolItem(itemId, block.name, block.input, output, mcpServers),
|
|
56647
57363
|
outcome: toolOutcome
|
|
56648
57364
|
});
|
|
56649
57365
|
}
|
|
@@ -56655,6 +57371,11 @@ function mapClaudeSnapshotWithCheckpointIds(values, sessionId) {
|
|
|
56655
57371
|
}
|
|
56656
57372
|
return { snapshot: { turns }, turnCheckpointIds };
|
|
56657
57373
|
}
|
|
57374
|
+
function historyToolItem(itemId, toolName, input, output, mcpServers) {
|
|
57375
|
+
const argumentsResult = jsonValueSchema.safeParse(input);
|
|
57376
|
+
const item = claudeToolItem(itemId, toolName, argumentsResult.success ? argumentsResult.data : null, mcpServers);
|
|
57377
|
+
return output ? { ...item, output: { content: [{ type: "text", text: output }] } } : item;
|
|
57378
|
+
}
|
|
56658
57379
|
function toolResultBlocks(messages) {
|
|
56659
57380
|
const results = /* @__PURE__ */ new Map();
|
|
56660
57381
|
for (const message of messages) {
|
|
@@ -56744,7 +57465,7 @@ function mapClaudeSubagentSnapshot(values, parentSessionId, nativeSubagentId2, p
|
|
|
56744
57465
|
if (block.type === "thinking" && typeof block.thinking === "string") {
|
|
56745
57466
|
if (block.thinking.length > 0) {
|
|
56746
57467
|
items.push({
|
|
56747
|
-
item: { type: "reasoning", itemId, text: block.thinking },
|
|
57468
|
+
item: isClaudeNarrationSignature(block.signature) ? { type: "agentMessage", itemId, text: block.thinking, phase: "commentary" } : { type: "reasoning", itemId, text: block.thinking },
|
|
56748
57469
|
outcome: itemOutcome(outcome)
|
|
56749
57470
|
});
|
|
56750
57471
|
}
|
|
@@ -56788,15 +57509,8 @@ function mapClaudeSubagentSnapshot(values, parentSessionId, nativeSubagentId2, p
|
|
|
56788
57509
|
});
|
|
56789
57510
|
continue;
|
|
56790
57511
|
}
|
|
56791
|
-
const argumentsResult = jsonValueSchema.safeParse(block.input);
|
|
56792
57512
|
items.push({
|
|
56793
|
-
item:
|
|
56794
|
-
type: "toolExecution",
|
|
56795
|
-
itemId,
|
|
56796
|
-
toolName: block.name,
|
|
56797
|
-
arguments: argumentsResult.success ? argumentsResult.data : null,
|
|
56798
|
-
...output ? { output: { content: [{ type: "text", text: output }] } } : {}
|
|
56799
|
-
},
|
|
57513
|
+
item: historyToolItem(itemId, block.name, block.input, output),
|
|
56800
57514
|
outcome: toolOutcome
|
|
56801
57515
|
});
|
|
56802
57516
|
}
|
|
@@ -57197,6 +57911,37 @@ var CLAUDE_THINKING_OPTIONS = [
|
|
|
57197
57911
|
];
|
|
57198
57912
|
var CLAUDE_THINKING_OPTION_IDS = CLAUDE_THINKING_OPTIONS.map(({ id: id2 }) => id2);
|
|
57199
57913
|
var CLAUDE_DEFAULT_THINKING_OPTION_ID = harnessThinkingOptionIdSchema.parse("auto");
|
|
57914
|
+
function claudeSupportedThinkingOptionIds(model2) {
|
|
57915
|
+
if (model2.supportsEffort === void 0 && model2.supportedEffortLevels === void 0 && model2.supportsAdaptiveThinking === void 0 && model2.supportsThinkingOff === void 0) {
|
|
57916
|
+
return [...CLAUDE_THINKING_OPTION_IDS];
|
|
57917
|
+
}
|
|
57918
|
+
const efforts = new Set(model2.supportsEffort === false ? [] : model2.supportedEffortLevels ?? []);
|
|
57919
|
+
return CLAUDE_THINKING_OPTION_IDS.filter((id2) => {
|
|
57920
|
+
if (id2 === "off")
|
|
57921
|
+
return model2.supportsThinkingOff !== false;
|
|
57922
|
+
if (id2 === "auto")
|
|
57923
|
+
return true;
|
|
57924
|
+
if (id2 === "ultracode")
|
|
57925
|
+
return efforts.has("xhigh");
|
|
57926
|
+
return efforts.has(id2);
|
|
57927
|
+
});
|
|
57928
|
+
}
|
|
57929
|
+
var CLAUDE_EFFORT_ORDER = ["low", "medium", "high", "xhigh", "max"];
|
|
57930
|
+
function fitClaudeThinkingOptionId(requested, supported) {
|
|
57931
|
+
if (!supported || supported.includes(requested))
|
|
57932
|
+
return requested;
|
|
57933
|
+
const ceiling = CLAUDE_EFFORT_ORDER.indexOf(requested === "ultracode" ? "xhigh" : requested);
|
|
57934
|
+
let best = CLAUDE_DEFAULT_THINKING_OPTION_ID;
|
|
57935
|
+
let bestRank = -1;
|
|
57936
|
+
for (const id2 of supported) {
|
|
57937
|
+
const rank = CLAUDE_EFFORT_ORDER.indexOf(id2);
|
|
57938
|
+
if (rank > bestRank && rank <= ceiling) {
|
|
57939
|
+
best = id2;
|
|
57940
|
+
bestRank = rank;
|
|
57941
|
+
}
|
|
57942
|
+
}
|
|
57943
|
+
return best;
|
|
57944
|
+
}
|
|
57200
57945
|
function parseClaudeThinkingOptionId(value) {
|
|
57201
57946
|
const id2 = harnessThinkingOptionIdSchema.parse(value);
|
|
57202
57947
|
if (!CLAUDE_THINKING_OPTION_IDS.includes(id2)) {
|
|
@@ -57229,7 +57974,13 @@ var modelInfoSchema = external_exports.object({
|
|
|
57229
57974
|
value: external_exports.string().trim().min(1).max(CLAUDE_MODEL_VALUE_MAX_LENGTH),
|
|
57230
57975
|
displayName: external_exports.string().trim().min(1).max(HARNESS_MODEL_LABEL_MAX_LENGTH),
|
|
57231
57976
|
description: external_exports.string().trim().max(HARNESS_MODEL_LABEL_MAX_LENGTH).optional(),
|
|
57232
|
-
resolvedModel: harnessResolvedModelLabelSchema.optional()
|
|
57977
|
+
resolvedModel: harnessResolvedModelLabelSchema.optional(),
|
|
57978
|
+
// Malformed capability fields count as unreported instead of failing the whole catalog;
|
|
57979
|
+
// unknown effort levels are ignored when mapping Thinking options.
|
|
57980
|
+
supportsEffort: external_exports.boolean().optional().catch(void 0),
|
|
57981
|
+
supportedEffortLevels: external_exports.array(external_exports.string()).optional().catch(void 0),
|
|
57982
|
+
supportsAdaptiveThinking: external_exports.boolean().optional().catch(void 0),
|
|
57983
|
+
supportsThinkingOff: external_exports.boolean().optional().catch(void 0)
|
|
57233
57984
|
});
|
|
57234
57985
|
var modelPickerOptionSchema = external_exports.object({
|
|
57235
57986
|
model: external_exports.string().trim().min(1).max(CLAUDE_MODEL_VALUE_MAX_LENGTH),
|
|
@@ -57412,12 +58163,17 @@ function uniqueDisplayLabels(rows) {
|
|
|
57412
58163
|
}
|
|
57413
58164
|
return labels;
|
|
57414
58165
|
}
|
|
58166
|
+
function canonicalRow(row) {
|
|
58167
|
+
if (row.supportedEffortLevels === void 0)
|
|
58168
|
+
return row;
|
|
58169
|
+
return { ...row, supportedEffortLevels: [...new Set(row.supportedEffortLevels)].sort() };
|
|
58170
|
+
}
|
|
57415
58171
|
function normalizeRows(value) {
|
|
57416
58172
|
if (!Array.isArray(value))
|
|
57417
58173
|
throw new Error("Claude Code Model catalog is not an array");
|
|
57418
58174
|
const byValue = /* @__PURE__ */ new Map();
|
|
57419
58175
|
for (const nativeRow of value) {
|
|
57420
|
-
const row = modelInfoSchema.parse(nativeRow);
|
|
58176
|
+
const row = canonicalRow(modelInfoSchema.parse(nativeRow));
|
|
57421
58177
|
const existing = byValue.get(row.value);
|
|
57422
58178
|
if (existing && JSON.stringify(existing) !== JSON.stringify(row)) {
|
|
57423
58179
|
throw new Error("Claude Code Model catalog contains conflicting selectable values");
|
|
@@ -57442,7 +58198,7 @@ function normalizeClaudeModelCatalog(snapshot) {
|
|
|
57442
58198
|
ref: encodeClaudeModelRef(row.value),
|
|
57443
58199
|
label: labels.get(row.value) ?? row.displayName,
|
|
57444
58200
|
...row.resolvedModel ? { resolvedModelLabel: row.resolvedModel } : {},
|
|
57445
|
-
supportedThinkingOptionIds:
|
|
58201
|
+
supportedThinkingOptionIds: claudeSupportedThinkingOptionIds(row)
|
|
57446
58202
|
};
|
|
57447
58203
|
});
|
|
57448
58204
|
models.sort((left, right) => {
|
|
@@ -57931,6 +58687,7 @@ function isRootOutput(event) {
|
|
|
57931
58687
|
case "text.delta":
|
|
57932
58688
|
case "reasoning.delta":
|
|
57933
58689
|
case "reasoning.completed":
|
|
58690
|
+
case "narration.completed":
|
|
57934
58691
|
case "message.completed":
|
|
57935
58692
|
case "tool.started":
|
|
57936
58693
|
case "tool.progress":
|
|
@@ -58059,7 +58816,10 @@ var ClaudeSdkTransport = class {
|
|
|
58059
58816
|
// Adaptive Thinking is redacted by default: the API streams `thinking_delta`
|
|
58060
58817
|
// frames carrying only token estimates and empty text, so no Reasoning Item
|
|
58061
58818
|
// would ever start. Summarized display is the official channel for readable
|
|
58062
|
-
// Thinking and is what Claude Code's own TUI renders.
|
|
58819
|
+
// Thinking and is what Claude Code's own TUI renders. The SDK passes this as
|
|
58820
|
+
// `--thinking adaptive`, which only turns Thinking on: Claude Code sends adaptive
|
|
58821
|
+
// Thinking to Models that support it and a token budget to the rest. The caller
|
|
58822
|
+
// fits the effort to the Model's catalog levels.
|
|
58063
58823
|
thinking: thinking.enabled ? { type: "adaptive", display: "summarized" } : { type: "disabled" },
|
|
58064
58824
|
...thinking.effort ? { effort: thinking.effort } : {},
|
|
58065
58825
|
pathToClaudeCodeExecutable: executable,
|
|
@@ -58162,13 +58922,23 @@ var ClaudeSdkTransport = class {
|
|
|
58162
58922
|
throw new Error("Claude SDK transport is not started");
|
|
58163
58923
|
return this.#permissionMode;
|
|
58164
58924
|
}
|
|
58165
|
-
async setModel(model2) {
|
|
58925
|
+
async setModel(model2, thinkingOptionId = this.#thinkingOptionId) {
|
|
58166
58926
|
const activeQuery = this.#query;
|
|
58167
58927
|
if (!this.#started || !activeQuery)
|
|
58168
58928
|
throw new Error("Claude SDK transport is not started");
|
|
58169
|
-
const
|
|
58929
|
+
const id2 = parseClaudeThinkingOptionId(thinkingOptionId);
|
|
58930
|
+
const previous = claudeThinkingConfiguration(this.#thinkingOptionId);
|
|
58931
|
+
const thinking = claudeThinkingConfiguration(id2);
|
|
58170
58932
|
const previousModel = this.#currentModel;
|
|
58171
58933
|
await activeQuery.setModel(model2);
|
|
58934
|
+
if (id2 !== this.#thinkingOptionId && !thinking.ultracode) {
|
|
58935
|
+
try {
|
|
58936
|
+
await activeQuery.applyFlagSettings(claudeThinkingFlagSettings(thinking, previous));
|
|
58937
|
+
} catch (error52) {
|
|
58938
|
+
await this.#restoreOrFault(() => activeQuery.setModel(previousModel));
|
|
58939
|
+
throw error52;
|
|
58940
|
+
}
|
|
58941
|
+
}
|
|
58172
58942
|
if (thinking.ultracode) {
|
|
58173
58943
|
try {
|
|
58174
58944
|
await activeQuery.applyFlagSettings(claudeThinkingFlagSettings(thinking, thinking));
|
|
@@ -58176,13 +58946,14 @@ var ClaudeSdkTransport = class {
|
|
|
58176
58946
|
} catch (error52) {
|
|
58177
58947
|
await this.#restoreOrFault(async () => {
|
|
58178
58948
|
await activeQuery.setModel(previousModel);
|
|
58179
|
-
await activeQuery.applyFlagSettings(claudeThinkingFlagSettings(
|
|
58180
|
-
await this.#verifyUltracode(activeQuery);
|
|
58949
|
+
await activeQuery.applyFlagSettings(claudeThinkingFlagSettings(previous, thinking));
|
|
58950
|
+
await (previous.ultracode ? this.#verifyUltracode(activeQuery) : this.#verifyUltracodeOff(activeQuery));
|
|
58181
58951
|
});
|
|
58182
58952
|
throw error52;
|
|
58183
58953
|
}
|
|
58184
58954
|
}
|
|
58185
58955
|
this.#currentModel = model2;
|
|
58956
|
+
this.#thinkingOptionId = id2;
|
|
58186
58957
|
}
|
|
58187
58958
|
async setThinkingOption(thinkingOptionId) {
|
|
58188
58959
|
const activeQuery = this.#query;
|
|
@@ -58254,19 +59025,20 @@ var ClaudeSdkTransport = class {
|
|
|
58254
59025
|
recap(userMessageId, onEvent) {
|
|
58255
59026
|
return this.runTurn("/recap", userMessageId, onEvent);
|
|
58256
59027
|
}
|
|
58257
|
-
runTurn(
|
|
59028
|
+
runTurn(content, userMessageId, onEvent) {
|
|
58258
59029
|
if (this.#closePromise || !this.#started || !this.#query) {
|
|
58259
59030
|
return Promise.reject(new Error("Claude SDK transport is not started"));
|
|
58260
59031
|
}
|
|
58261
59032
|
if (this.#active || this.#autonomous?.live) {
|
|
58262
59033
|
return Promise.reject(new Error("Claude SDK transport is busy"));
|
|
58263
59034
|
}
|
|
58264
|
-
const
|
|
59035
|
+
const takeover = this.#autonomous;
|
|
59036
|
+
const unclaimed = takeover?.events ?? [];
|
|
58265
59037
|
this.#autonomous = null;
|
|
58266
59038
|
const promise2 = new Promise((resolve5, reject) => {
|
|
58267
59039
|
this.#rootToolCalls.clear();
|
|
58268
59040
|
this.#active = {
|
|
58269
|
-
accumulator: new ClaudeNativeTurnAccumulator(this.#provider ? { provider: this.#provider } : {}),
|
|
59041
|
+
accumulator: takeover?.accumulator ?? new ClaudeNativeTurnAccumulator(this.#provider ? { provider: this.#provider } : {}),
|
|
58270
59042
|
onEvent,
|
|
58271
59043
|
resolve: resolve5,
|
|
58272
59044
|
reject
|
|
@@ -58276,7 +59048,7 @@ var ClaudeSdkTransport = class {
|
|
|
58276
59048
|
onEvent(event);
|
|
58277
59049
|
this.#input.push({
|
|
58278
59050
|
type: "user",
|
|
58279
|
-
message: { role: "user", content
|
|
59051
|
+
message: { role: "user", content },
|
|
58280
59052
|
parent_tool_use_id: null,
|
|
58281
59053
|
session_id: this.sessionId,
|
|
58282
59054
|
uuid: userMessageId,
|
|
@@ -58293,7 +59065,7 @@ var ClaudeSdkTransport = class {
|
|
|
58293
59065
|
* The Turn ending first therefore does not reject it, and a missing `queued` receipt resolves
|
|
58294
59066
|
* after a bounded wait so callers that serialize requests are never held indefinitely.
|
|
58295
59067
|
*/
|
|
58296
|
-
steer(
|
|
59068
|
+
steer(content, messageId, onTakeover) {
|
|
58297
59069
|
if (this.#closePromise || !this.#started || !this.#query || !this.canSteerActiveTurn()) {
|
|
58298
59070
|
return Promise.reject(new ClaudeSteerMissedTurnError());
|
|
58299
59071
|
}
|
|
@@ -58303,7 +59075,7 @@ var ClaudeSdkTransport = class {
|
|
|
58303
59075
|
try {
|
|
58304
59076
|
this.#input.push({
|
|
58305
59077
|
type: "user",
|
|
58306
|
-
message: { role: "user", content
|
|
59078
|
+
message: { role: "user", content },
|
|
58307
59079
|
parent_tool_use_id: null,
|
|
58308
59080
|
session_id: this.sessionId,
|
|
58309
59081
|
uuid: messageId,
|
|
@@ -59550,6 +60322,7 @@ var ClaudeToolLifecycle = class {
|
|
|
59550
60322
|
#onDetached;
|
|
59551
60323
|
#outputLimit;
|
|
59552
60324
|
#taskTracker;
|
|
60325
|
+
#mcpServers;
|
|
59553
60326
|
#nativeTurnKey;
|
|
59554
60327
|
#tools = /* @__PURE__ */ new Map();
|
|
59555
60328
|
#toolOrdinal = 0;
|
|
@@ -59560,6 +60333,7 @@ var ClaudeToolLifecycle = class {
|
|
|
59560
60333
|
this.#onDetached = options.onDetached;
|
|
59561
60334
|
this.#outputLimit = options.outputLimit;
|
|
59562
60335
|
this.#taskTracker = options.taskTracker;
|
|
60336
|
+
this.#mcpServers = options.mcpServers ?? (() => []);
|
|
59563
60337
|
this.#nativeTurnKey = options.nativeTurnKey;
|
|
59564
60338
|
}
|
|
59565
60339
|
get size() {
|
|
@@ -59575,12 +60349,7 @@ var ClaudeToolLifecycle = class {
|
|
|
59575
60349
|
itemId,
|
|
59576
60350
|
command,
|
|
59577
60351
|
cwd: this.#cwd
|
|
59578
|
-
} : {
|
|
59579
|
-
type: "toolExecution",
|
|
59580
|
-
itemId,
|
|
59581
|
-
toolName: isClaudeTaskTool(event.toolName) ? "Todo" : event.toolName,
|
|
59582
|
-
arguments: isClaudeTaskTool(event.toolName) ? {} : event.arguments
|
|
59583
|
-
};
|
|
60352
|
+
} : isClaudeTaskTool(event.toolName) ? { type: "toolExecution", itemId, toolName: "Todo", arguments: {} } : claudeToolItem(itemId, event.toolName, event.arguments, this.#mcpServers());
|
|
59584
60353
|
this.#tools.set(event.callId, {
|
|
59585
60354
|
item,
|
|
59586
60355
|
nativeName: event.toolName,
|
|
@@ -59625,6 +60394,8 @@ var ClaudeToolLifecycle = class {
|
|
|
59625
60394
|
} : {},
|
|
59626
60395
|
durationMs
|
|
59627
60396
|
};
|
|
60397
|
+
} else if (tool.item.type === "webSearch") {
|
|
60398
|
+
tool.item = { ...tool.item, ...output ? { output } : {} };
|
|
59628
60399
|
} else {
|
|
59629
60400
|
tool.item = { ...tool.item, ...output ? { output } : {}, durationMs };
|
|
59630
60401
|
}
|
|
@@ -59653,7 +60424,7 @@ var ClaudeToolLifecycle = class {
|
|
|
59653
60424
|
for (const [callId, tool] of this.#tools) {
|
|
59654
60425
|
this.#tools.delete(callId);
|
|
59655
60426
|
const durationMs = Math.max(tool.elapsedMs, Date.now() - tool.startedAtMs, 0);
|
|
59656
|
-
this.#completeItem(turnId, { ...tool.item, durationMs }, outcome);
|
|
60427
|
+
this.#completeItem(turnId, tool.item.type === "webSearch" ? tool.item : { ...tool.item, durationMs }, outcome);
|
|
59657
60428
|
}
|
|
59658
60429
|
}
|
|
59659
60430
|
#completeItem(turnId, item, outcome) {
|
|
@@ -59705,6 +60476,135 @@ function estimateClaudeRequestCostUsd(usage) {
|
|
|
59705
60476
|
return Number.isFinite(cost) && cost >= 0 ? cost : void 0;
|
|
59706
60477
|
}
|
|
59707
60478
|
|
|
60479
|
+
// dist/turn-input.js
|
|
60480
|
+
import { constants as constants3 } from "node:fs";
|
|
60481
|
+
import { open as open5 } from "node:fs/promises";
|
|
60482
|
+
var MAX_IMAGE_FILE_BYTES = 20 * 1024 * 1024;
|
|
60483
|
+
var MAX_STEER_BASE64_BYTES = 5 * 1024 * 1024;
|
|
60484
|
+
var MAX_STEER_IMAGE_SIDE = 2e3;
|
|
60485
|
+
var HEADER_BYTES = 32;
|
|
60486
|
+
function imageMediaType(data) {
|
|
60487
|
+
if (data.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]))) {
|
|
60488
|
+
return "image/png";
|
|
60489
|
+
}
|
|
60490
|
+
if (data.subarray(0, 3).equals(Buffer.from([255, 216, 255])))
|
|
60491
|
+
return "image/jpeg";
|
|
60492
|
+
const head = data.subarray(0, 12).toString("latin1");
|
|
60493
|
+
if (head.startsWith("GIF87a") || head.startsWith("GIF89a"))
|
|
60494
|
+
return "image/gif";
|
|
60495
|
+
if (head.startsWith("RIFF") && head.slice(8) === "WEBP")
|
|
60496
|
+
return "image/webp";
|
|
60497
|
+
return null;
|
|
60498
|
+
}
|
|
60499
|
+
function jpegDimensions(data) {
|
|
60500
|
+
let offset = 2;
|
|
60501
|
+
while (offset + 9 <= data.length) {
|
|
60502
|
+
if (data[offset] !== 255)
|
|
60503
|
+
return null;
|
|
60504
|
+
const marker = data[offset + 1] ?? 0;
|
|
60505
|
+
if (marker === 255) {
|
|
60506
|
+
offset += 1;
|
|
60507
|
+
continue;
|
|
60508
|
+
}
|
|
60509
|
+
if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) {
|
|
60510
|
+
return { height: data.readUInt16BE(offset + 5), width: data.readUInt16BE(offset + 7) };
|
|
60511
|
+
}
|
|
60512
|
+
if (marker === 1 || marker >= 208 && marker <= 216) {
|
|
60513
|
+
offset += 2;
|
|
60514
|
+
continue;
|
|
60515
|
+
}
|
|
60516
|
+
offset += 2 + data.readUInt16BE(offset + 2);
|
|
60517
|
+
}
|
|
60518
|
+
return null;
|
|
60519
|
+
}
|
|
60520
|
+
function imageDimensions(data, mediaType) {
|
|
60521
|
+
if (data.length < 30)
|
|
60522
|
+
return null;
|
|
60523
|
+
switch (mediaType) {
|
|
60524
|
+
case "image/png":
|
|
60525
|
+
return { width: data.readUInt32BE(16), height: data.readUInt32BE(20) };
|
|
60526
|
+
case "image/gif":
|
|
60527
|
+
return { width: data.readUInt16LE(6), height: data.readUInt16LE(8) };
|
|
60528
|
+
case "image/webp": {
|
|
60529
|
+
const chunk = data.toString("latin1", 12, 16);
|
|
60530
|
+
if (chunk === "VP8 ") {
|
|
60531
|
+
return { width: data.readUInt16LE(26) & 16383, height: data.readUInt16LE(28) & 16383 };
|
|
60532
|
+
}
|
|
60533
|
+
if (chunk === "VP8L") {
|
|
60534
|
+
const bits = data.readUInt32LE(21);
|
|
60535
|
+
return { width: (bits & 16383) + 1, height: (bits >>> 14 & 16383) + 1 };
|
|
60536
|
+
}
|
|
60537
|
+
if (chunk === "VP8X") {
|
|
60538
|
+
return { width: data.readUIntLE(24, 3) + 1, height: data.readUIntLE(27, 3) + 1 };
|
|
60539
|
+
}
|
|
60540
|
+
return null;
|
|
60541
|
+
}
|
|
60542
|
+
case "image/jpeg":
|
|
60543
|
+
return jpegDimensions(data);
|
|
60544
|
+
}
|
|
60545
|
+
}
|
|
60546
|
+
function fitsSteer(data, mediaType) {
|
|
60547
|
+
if (Math.ceil(data.length / 3) * 4 > MAX_STEER_BASE64_BYTES)
|
|
60548
|
+
return false;
|
|
60549
|
+
const size = imageDimensions(data, mediaType);
|
|
60550
|
+
return size !== null && size.width > 0 && size.height > 0 && size.width <= MAX_STEER_IMAGE_SIDE && size.height <= MAX_STEER_IMAGE_SIDE;
|
|
60551
|
+
}
|
|
60552
|
+
async function imageBlock(file2, steer) {
|
|
60553
|
+
let handle;
|
|
60554
|
+
try {
|
|
60555
|
+
handle = await open5(file2, constants3.O_RDONLY | constants3.O_NONBLOCK);
|
|
60556
|
+
} catch {
|
|
60557
|
+
return null;
|
|
60558
|
+
}
|
|
60559
|
+
try {
|
|
60560
|
+
const stats = await handle.stat();
|
|
60561
|
+
if (!stats.isFile() || stats.size > MAX_IMAGE_FILE_BYTES)
|
|
60562
|
+
return null;
|
|
60563
|
+
if (steer && Math.ceil(stats.size / 3) * 4 > MAX_STEER_BASE64_BYTES)
|
|
60564
|
+
return null;
|
|
60565
|
+
const header = Buffer.alloc(HEADER_BYTES);
|
|
60566
|
+
const { bytesRead } = await handle.read(header, 0, HEADER_BYTES, 0);
|
|
60567
|
+
if (!imageMediaType(header.subarray(0, bytesRead)))
|
|
60568
|
+
return null;
|
|
60569
|
+
const buffer = Buffer.alloc(stats.size + 1);
|
|
60570
|
+
let length = 0;
|
|
60571
|
+
while (length < buffer.length) {
|
|
60572
|
+
const read = await handle.read(buffer, length, buffer.length - length, length);
|
|
60573
|
+
if (read.bytesRead === 0)
|
|
60574
|
+
break;
|
|
60575
|
+
length += read.bytesRead;
|
|
60576
|
+
}
|
|
60577
|
+
if (length > stats.size)
|
|
60578
|
+
return null;
|
|
60579
|
+
const data = buffer.subarray(0, length);
|
|
60580
|
+
const mediaType = imageMediaType(data.subarray(0, HEADER_BYTES));
|
|
60581
|
+
if (!mediaType)
|
|
60582
|
+
return null;
|
|
60583
|
+
if (steer && !fitsSteer(data, mediaType))
|
|
60584
|
+
return null;
|
|
60585
|
+
return {
|
|
60586
|
+
type: "image",
|
|
60587
|
+
source: { type: "base64", media_type: mediaType, data: data.toString("base64") }
|
|
60588
|
+
};
|
|
60589
|
+
} catch {
|
|
60590
|
+
return null;
|
|
60591
|
+
} finally {
|
|
60592
|
+
await handle.close().catch(() => void 0);
|
|
60593
|
+
}
|
|
60594
|
+
}
|
|
60595
|
+
async function claudeUserContent(text2, { steer = false } = {}) {
|
|
60596
|
+
const paths = [...new Set(desktopImageAttachmentPaths(text2))];
|
|
60597
|
+
if (paths.length === 0)
|
|
60598
|
+
return text2;
|
|
60599
|
+
const content = [{ type: "text", text: text2 }];
|
|
60600
|
+
for (const file2 of paths) {
|
|
60601
|
+
const block = await imageBlock(file2, steer);
|
|
60602
|
+
if (block)
|
|
60603
|
+
content.push(block);
|
|
60604
|
+
}
|
|
60605
|
+
return content.length > 1 ? content : text2;
|
|
60606
|
+
}
|
|
60607
|
+
|
|
59708
60608
|
// dist/claude-code-adapter.js
|
|
59709
60609
|
var claudeCodeHarnessId2 = harnessIdSchema.parse("claude-code");
|
|
59710
60610
|
var claudeCommandCatalog = harnessCommandCatalogSchema.parse({
|
|
@@ -59928,6 +60828,40 @@ function claudeCacheHitRatePercent(usage) {
|
|
|
59928
60828
|
function isoFromUnix(unixSeconds) {
|
|
59929
60829
|
return new Date(unixSeconds * 1e3).toISOString();
|
|
59930
60830
|
}
|
|
60831
|
+
function unixFromIso(iso) {
|
|
60832
|
+
const ms2 = Date.parse(iso);
|
|
60833
|
+
if (!Number.isFinite(ms2))
|
|
60834
|
+
return void 0;
|
|
60835
|
+
const unix = Math.trunc(ms2 / 1e3);
|
|
60836
|
+
return Number.isSafeInteger(unix) ? unix : void 0;
|
|
60837
|
+
}
|
|
60838
|
+
function planLimitWindowFromCredits(utilizationPercent, resetsAt) {
|
|
60839
|
+
const resetsAtUnix = resetsAt === void 0 ? void 0 : unixFromIso(resetsAt);
|
|
60840
|
+
return {
|
|
60841
|
+
utilizationPercent,
|
|
60842
|
+
...resetsAtUnix !== void 0 ? { resetsAtUnix } : {}
|
|
60843
|
+
};
|
|
60844
|
+
}
|
|
60845
|
+
function planLimitFromAccountCredits(credits) {
|
|
60846
|
+
if (!credits)
|
|
60847
|
+
return null;
|
|
60848
|
+
const event = {};
|
|
60849
|
+
if (credits.periodType === "five_hour") {
|
|
60850
|
+
event.fiveHour = planLimitWindowFromCredits(credits.usedPercent, credits.resetsAt);
|
|
60851
|
+
const sevenDay = credits.productUsage?.find((product) => product.periodType === "seven_day" && !product.scope);
|
|
60852
|
+
if (sevenDay) {
|
|
60853
|
+
event.sevenDay = planLimitWindowFromCredits(sevenDay.usagePercent, sevenDay.resetsAt);
|
|
60854
|
+
}
|
|
60855
|
+
} else if (credits.periodType === "seven_day" && !credits.scope) {
|
|
60856
|
+
event.sevenDay = planLimitWindowFromCredits(credits.usedPercent, credits.resetsAt);
|
|
60857
|
+
} else {
|
|
60858
|
+
return null;
|
|
60859
|
+
}
|
|
60860
|
+
if (!accountCreditsSnapshotSchema.safeParse(projectClaudePlanLimitToCredits(event)).success) {
|
|
60861
|
+
return null;
|
|
60862
|
+
}
|
|
60863
|
+
return event.fiveHour || event.sevenDay ? event : null;
|
|
60864
|
+
}
|
|
59931
60865
|
function projectClaudePlanLimitToCredits(planLimit) {
|
|
59932
60866
|
if (!planLimit)
|
|
59933
60867
|
return null;
|
|
@@ -59996,12 +60930,16 @@ var ClaudeHarnessSession = class {
|
|
|
59996
60930
|
#requestedModel;
|
|
59997
60931
|
#requestedPermissionModeId;
|
|
59998
60932
|
#requestedThinkingOptionId;
|
|
60933
|
+
/** This Session's folder's inspected catalog, which says what Thinking each Model accepts. */
|
|
60934
|
+
#modelCatalog;
|
|
59999
60935
|
#readSessionMessages;
|
|
60000
60936
|
#sessionId;
|
|
60001
60937
|
#toolOutputLimit;
|
|
60002
60938
|
#backgroundCommands;
|
|
60003
60939
|
#continuationQuiescenceMs;
|
|
60004
60940
|
#taskTracker = new ClaudeTaskTracker();
|
|
60941
|
+
/** MCP server names the latest native Segment reported; they disambiguate MCP Tool names. */
|
|
60942
|
+
#mcpServers = [];
|
|
60005
60943
|
#acceptingTurn = false;
|
|
60006
60944
|
#active = null;
|
|
60007
60945
|
#closePromise = null;
|
|
@@ -60053,7 +60991,8 @@ var ClaudeHarnessSession = class {
|
|
|
60053
60991
|
this.#openMode = options.openMode;
|
|
60054
60992
|
this.#requestedModel = options.requestedModel;
|
|
60055
60993
|
this.#requestedPermissionModeId = options.requestedPermissionModeId;
|
|
60056
|
-
this.#
|
|
60994
|
+
this.#modelCatalog = options.modelCatalog;
|
|
60995
|
+
this.#requestedThinkingOptionId = fitClaudeThinkingOptionId(options.requestedThinkingOptionId, this.#supportedThinkingOptionIds(options.requestedModel ?? (this.#openMode === "create" ? CLAUDE_DEFAULT_MODEL_REF : void 0)));
|
|
60057
60996
|
this.#sessionId = options.sessionId;
|
|
60058
60997
|
this.#toolOutputLimit = options.toolOutputLimit;
|
|
60059
60998
|
this.#backgroundCommands = new ClaudeBackgroundCommandItems({
|
|
@@ -60121,39 +61060,56 @@ var ClaudeHarnessSession = class {
|
|
|
60121
61060
|
this.#readingHistory = true;
|
|
60122
61061
|
try {
|
|
60123
61062
|
let messages;
|
|
60124
|
-
|
|
60125
|
-
|
|
60126
|
-
|
|
61063
|
+
const deadline = Date.now() + this.#closeTimeoutMs;
|
|
61064
|
+
for (; ; ) {
|
|
61065
|
+
try {
|
|
60127
61066
|
messages = await this.#readSessionMessages({
|
|
60128
61067
|
cwd: this.#cwd,
|
|
60129
61068
|
sessionId: this.#sessionId
|
|
60130
61069
|
}) ?? [];
|
|
60131
|
-
|
|
60132
|
-
|
|
60133
|
-
|
|
60134
|
-
|
|
60135
|
-
|
|
60136
|
-
|
|
60137
|
-
|
|
60138
|
-
|
|
60139
|
-
|
|
60140
|
-
code: "sessionBusy",
|
|
60141
|
-
message: "Claude Code history is still being persisted",
|
|
60142
|
-
retryable: true
|
|
60143
|
-
}
|
|
60144
|
-
};
|
|
60145
|
-
}
|
|
60146
|
-
await delay2(25);
|
|
61070
|
+
} catch {
|
|
61071
|
+
return {
|
|
61072
|
+
ok: false,
|
|
61073
|
+
error: {
|
|
61074
|
+
code: "nativeFailure",
|
|
61075
|
+
message: "Claude Code history could not be read",
|
|
61076
|
+
retryable: true
|
|
61077
|
+
}
|
|
61078
|
+
};
|
|
60147
61079
|
}
|
|
60148
|
-
|
|
60149
|
-
|
|
60150
|
-
|
|
60151
|
-
|
|
60152
|
-
|
|
60153
|
-
|
|
60154
|
-
|
|
60155
|
-
}
|
|
60156
|
-
}
|
|
61080
|
+
let ids;
|
|
61081
|
+
try {
|
|
61082
|
+
ids = new Set(messages.flatMap((message) => {
|
|
61083
|
+
if (!isRecord15(message) || typeof message.uuid !== "string")
|
|
61084
|
+
return [];
|
|
61085
|
+
const queued = readClaudeQueuedCommand(message, this.#sessionId);
|
|
61086
|
+
return queued ? [message.uuid, queued.sourceUuid] : [message.uuid];
|
|
61087
|
+
}));
|
|
61088
|
+
} catch {
|
|
61089
|
+
return {
|
|
61090
|
+
ok: false,
|
|
61091
|
+
error: {
|
|
61092
|
+
code: "protocolError",
|
|
61093
|
+
message: "Claude Code history is invalid",
|
|
61094
|
+
retryable: false
|
|
61095
|
+
}
|
|
61096
|
+
};
|
|
61097
|
+
}
|
|
61098
|
+
if (this.#unpersistedMessageIds.every((id2) => isPersistedClaudeMessageId(id2, ids))) {
|
|
61099
|
+
this.#unpersistedMessageIds = [];
|
|
61100
|
+
break;
|
|
61101
|
+
}
|
|
61102
|
+
if (Date.now() >= deadline || this.#phase !== "open") {
|
|
61103
|
+
return {
|
|
61104
|
+
ok: false,
|
|
61105
|
+
error: {
|
|
61106
|
+
code: "sessionBusy",
|
|
61107
|
+
message: "Claude Code history is still being persisted",
|
|
61108
|
+
retryable: true
|
|
61109
|
+
}
|
|
61110
|
+
};
|
|
61111
|
+
}
|
|
61112
|
+
await delay2(25);
|
|
60157
61113
|
}
|
|
60158
61114
|
if (messages.length === 0 && isPendingClaudeSession(this.#nativeRef)) {
|
|
60159
61115
|
try {
|
|
@@ -60184,7 +61140,10 @@ var ClaudeHarnessSession = class {
|
|
|
60184
61140
|
try {
|
|
60185
61141
|
return {
|
|
60186
61142
|
ok: true,
|
|
60187
|
-
value: {
|
|
61143
|
+
value: {
|
|
61144
|
+
...mapClaudeSnapshot(messages, this.#sessionId, this.#mcpServers),
|
|
61145
|
+
state: this.#state
|
|
61146
|
+
}
|
|
60188
61147
|
};
|
|
60189
61148
|
} catch {
|
|
60190
61149
|
return {
|
|
@@ -60238,6 +61197,7 @@ var ClaudeHarnessSession = class {
|
|
|
60238
61197
|
};
|
|
60239
61198
|
}
|
|
60240
61199
|
this.#acceptingTurn = true;
|
|
61200
|
+
const content = await claudeUserContent(text2);
|
|
60241
61201
|
const startingTransport = this.#transport === null;
|
|
60242
61202
|
let transport;
|
|
60243
61203
|
try {
|
|
@@ -60296,6 +61256,7 @@ var ClaudeHarnessSession = class {
|
|
|
60296
61256
|
cwd: this.#cwd,
|
|
60297
61257
|
outputLimit: this.#toolOutputLimit,
|
|
60298
61258
|
taskTracker: this.#taskTracker,
|
|
61259
|
+
mcpServers: () => this.#mcpServers,
|
|
60299
61260
|
nativeTurnKey,
|
|
60300
61261
|
newItemId: () => hostItemIdSchema.parse(this.#randomUUID()),
|
|
60301
61262
|
emit: (event) => this.#event(event),
|
|
@@ -60334,7 +61295,7 @@ var ClaudeHarnessSession = class {
|
|
|
60334
61295
|
nativeTurnKey,
|
|
60335
61296
|
formatVersion: 1
|
|
60336
61297
|
});
|
|
60337
|
-
const running = transport.runTurn(
|
|
61298
|
+
const running = transport.runTurn(content, nativeTurnRef.nativeTurnKey, (event) => {
|
|
60338
61299
|
this.#handleTurnEvent(active, event);
|
|
60339
61300
|
});
|
|
60340
61301
|
active.userMessageId = nativeTurnRef.nativeTurnKey;
|
|
@@ -60346,13 +61307,6 @@ var ClaudeHarnessSession = class {
|
|
|
60346
61307
|
return { ok: true, value: { turnId: command.turnId } };
|
|
60347
61308
|
}
|
|
60348
61309
|
async #steer(command) {
|
|
60349
|
-
const active = this.#active;
|
|
60350
|
-
if (!active || active.command.turnId !== command.turnId) {
|
|
60351
|
-
return { ok: false, error: invalidState("Claude Code steer target is not the active Turn") };
|
|
60352
|
-
}
|
|
60353
|
-
if (active.cancellationRequested) {
|
|
60354
|
-
return { ok: false, error: invalidState("Claude Code steer target is being cancelled") };
|
|
60355
|
-
}
|
|
60356
61310
|
const text2 = command.input.map((input) => input.text).join("\n");
|
|
60357
61311
|
if (text2.length === 0) {
|
|
60358
61312
|
return {
|
|
@@ -60364,6 +61318,14 @@ var ClaudeHarnessSession = class {
|
|
|
60364
61318
|
}
|
|
60365
61319
|
};
|
|
60366
61320
|
}
|
|
61321
|
+
const content = await claudeUserContent(text2, { steer: true });
|
|
61322
|
+
const active = this.#active;
|
|
61323
|
+
if (!active || active.command.turnId !== command.turnId) {
|
|
61324
|
+
return { ok: false, error: invalidState("Claude Code steer target is not the active Turn") };
|
|
61325
|
+
}
|
|
61326
|
+
if (active.cancellationRequested) {
|
|
61327
|
+
return { ok: false, error: invalidState("Claude Code steer target is being cancelled") };
|
|
61328
|
+
}
|
|
60367
61329
|
const transport = this.#transport;
|
|
60368
61330
|
if (!transport) {
|
|
60369
61331
|
return { ok: false, error: invalidState("Claude Code steer missed the active Turn") };
|
|
@@ -60381,7 +61343,7 @@ var ClaudeHarnessSession = class {
|
|
|
60381
61343
|
const messageId = this.#randomUUID();
|
|
60382
61344
|
active.steersAwaitingNative.add(messageId);
|
|
60383
61345
|
try {
|
|
60384
|
-
await transport.steer(
|
|
61346
|
+
await transport.steer(content, messageId, (started) => this.#takeOverSteer(active, messageId, started));
|
|
60385
61347
|
} catch (error52) {
|
|
60386
61348
|
if (error52 instanceof ClaudeSteerMissedTurnError) {
|
|
60387
61349
|
this.#takeOverSteer(active, messageId, false);
|
|
@@ -60474,6 +61436,7 @@ var ClaudeHarnessSession = class {
|
|
|
60474
61436
|
cwd: this.#cwd,
|
|
60475
61437
|
outputLimit: this.#toolOutputLimit,
|
|
60476
61438
|
taskTracker: this.#taskTracker,
|
|
61439
|
+
mcpServers: () => this.#mcpServers,
|
|
60477
61440
|
nativeTurnKey,
|
|
60478
61441
|
newItemId: () => hostItemIdSchema.parse(this.#randomUUID()),
|
|
60479
61442
|
emit: (event) => this.#event(event),
|
|
@@ -60590,10 +61553,11 @@ var ClaudeHarnessSession = class {
|
|
|
60590
61553
|
resolveConfiguration = resolve5;
|
|
60591
61554
|
});
|
|
60592
61555
|
try {
|
|
61556
|
+
const thinkingOptionId = fitClaudeThinkingOptionId(this.#requestedThinkingOptionId, this.#supportedThinkingOptionIds(command.model));
|
|
60593
61557
|
const transport = this.#transport;
|
|
60594
61558
|
if (transport) {
|
|
60595
61559
|
try {
|
|
60596
|
-
await transport.setModel(model2);
|
|
61560
|
+
await transport.setModel(model2, thinkingOptionId);
|
|
60597
61561
|
} catch (error52) {
|
|
60598
61562
|
return {
|
|
60599
61563
|
ok: false,
|
|
@@ -60606,6 +61570,7 @@ var ClaudeHarnessSession = class {
|
|
|
60606
61570
|
}
|
|
60607
61571
|
}
|
|
60608
61572
|
this.#requestedModel = command.model;
|
|
61573
|
+
this.#requestedThinkingOptionId = thinkingOptionId;
|
|
60609
61574
|
const persistenceError = await this.#savePendingConfiguration();
|
|
60610
61575
|
if (persistenceError)
|
|
60611
61576
|
return { ok: false, error: persistenceError };
|
|
@@ -60640,6 +61605,17 @@ var ClaudeHarnessSession = class {
|
|
|
60640
61605
|
}
|
|
60641
61606
|
};
|
|
60642
61607
|
}
|
|
61608
|
+
const supported = this.#supportedThinkingOptionIds(this.#effectiveModelRef());
|
|
61609
|
+
if (supported && !supported.includes(thinkingOptionId)) {
|
|
61610
|
+
return {
|
|
61611
|
+
ok: false,
|
|
61612
|
+
error: {
|
|
61613
|
+
code: "invalidRequest",
|
|
61614
|
+
message: "Claude Code Thinking option is unavailable for the selected Model",
|
|
61615
|
+
retryable: false
|
|
61616
|
+
}
|
|
61617
|
+
};
|
|
61618
|
+
}
|
|
60643
61619
|
this.#usageGeneration += 1;
|
|
60644
61620
|
this.#contextUsageFreshUntilMs = 0;
|
|
60645
61621
|
this.#contextUsageCooldownUntilMs = 0;
|
|
@@ -61106,15 +62082,39 @@ var ClaudeHarnessSession = class {
|
|
|
61106
62082
|
}
|
|
61107
62083
|
}
|
|
61108
62084
|
#configuredState(nativeReady = this.#state.nativeRef !== void 0) {
|
|
61109
|
-
const effectiveModel = this.#
|
|
62085
|
+
const effectiveModel = this.#effectiveModelRef();
|
|
62086
|
+
const supported = this.#supportedThinkingOptionIds(effectiveModel);
|
|
61110
62087
|
return {
|
|
61111
62088
|
...nativeReady ? { nativeRef: this.#nativeRef } : {},
|
|
61112
62089
|
...effectiveModel ? { effectiveModel } : {},
|
|
61113
62090
|
effectiveThinkingOptionId: this.#requestedThinkingOptionId,
|
|
61114
|
-
|
|
62091
|
+
// A live Claude Code keeps running a choice made before the catalog arrived; it stays
|
|
62092
|
+
// listed until the next Model switch fits it.
|
|
62093
|
+
availableThinkingOptions: CLAUDE_THINKING_OPTIONS.filter(({ id: id2 }) => !supported || supported.includes(id2) || id2 === this.#requestedThinkingOptionId),
|
|
61115
62094
|
effectivePermissionModeId: this.#requestedPermissionModeId
|
|
61116
62095
|
};
|
|
61117
62096
|
}
|
|
62097
|
+
#effectiveModelRef() {
|
|
62098
|
+
return this.#requestedModel ?? (this.#openMode === "create" ? CLAUDE_DEFAULT_MODEL_REF : this.#state.effectiveModel);
|
|
62099
|
+
}
|
|
62100
|
+
#supportedThinkingOptionIds(model2) {
|
|
62101
|
+
return catalogModelForRef(this.#modelCatalog(), model2)?.supportedThinkingOptionIds;
|
|
62102
|
+
}
|
|
62103
|
+
/**
|
|
62104
|
+
* Fits the requested Thinking to a catalog inspected after this Session opened, so the choice
|
|
62105
|
+
* Claude Code starts with is the one shown. A live Claude Code already runs the earlier choice.
|
|
62106
|
+
*/
|
|
62107
|
+
refitThinking(cwd) {
|
|
62108
|
+
if (this.#phase !== "open" || cwd !== this.#cwd || this.#transport)
|
|
62109
|
+
return;
|
|
62110
|
+
this.#requestedThinkingOptionId = fitClaudeThinkingOptionId(this.#requestedThinkingOptionId, this.#supportedThinkingOptionIds(this.#effectiveModelRef()));
|
|
62111
|
+
if (this.#state.effectiveThinkingOptionId === void 0)
|
|
62112
|
+
return;
|
|
62113
|
+
const state = this.#configuredState();
|
|
62114
|
+
if (state.effectiveThinkingOptionId !== this.#state.effectiveThinkingOptionId || !isDeepStrictEqual2(state.availableThinkingOptions, this.#state.availableThinkingOptions)) {
|
|
62115
|
+
this.#publishState(state);
|
|
62116
|
+
}
|
|
62117
|
+
}
|
|
61118
62118
|
#publishState(state = this.#state) {
|
|
61119
62119
|
this.#state = state;
|
|
61120
62120
|
this.#statePublished = true;
|
|
@@ -61139,6 +62139,8 @@ var ClaudeHarnessSession = class {
|
|
|
61139
62139
|
return;
|
|
61140
62140
|
switch (event.type) {
|
|
61141
62141
|
case "segment.started":
|
|
62142
|
+
if (event.mcpServers)
|
|
62143
|
+
this.#mcpServers = event.mcpServers;
|
|
61142
62144
|
this.#observeRootOutput(active);
|
|
61143
62145
|
if (active.cancellation && !active.cancellation.interrupting) {
|
|
61144
62146
|
this.#interruptCancelledSegment(active).catch(() => this.#hardCancel(active));
|
|
@@ -61160,6 +62162,13 @@ var ClaudeHarnessSession = class {
|
|
|
61160
62162
|
this.#observeRootOutput(active);
|
|
61161
62163
|
this.#appendText(active, event.messageId, event.delta);
|
|
61162
62164
|
return;
|
|
62165
|
+
case "narration.completed":
|
|
62166
|
+
this.#observeRootOutput(active);
|
|
62167
|
+
if (event.completeOnly)
|
|
62168
|
+
active.reasoningOrdinal += 1;
|
|
62169
|
+
this.#appendText(active, event.messageId, event.text, "commentary");
|
|
62170
|
+
this.#completeAgentItem(active, { status: "succeeded" }, false);
|
|
62171
|
+
return;
|
|
61163
62172
|
case "reasoning.delta":
|
|
61164
62173
|
if (event.delta.length > 0)
|
|
61165
62174
|
this.#observeRootOutput(active);
|
|
@@ -61460,13 +62469,13 @@ var ClaudeHarnessSession = class {
|
|
|
61460
62469
|
}
|
|
61461
62470
|
active.assistantMessageId = messageId;
|
|
61462
62471
|
}
|
|
61463
|
-
#appendText(active, messageId, delta) {
|
|
62472
|
+
#appendText(active, messageId, delta, phase) {
|
|
61464
62473
|
if (this.#active !== active || delta.length === 0)
|
|
61465
62474
|
return;
|
|
61466
62475
|
this.#activateAssistantMessage(active, messageId);
|
|
61467
62476
|
if (!active.item)
|
|
61468
62477
|
throw new Error("Claude Assistant text has no active Item");
|
|
61469
|
-
active.item = { ...active.item, text: active.item.text + delta };
|
|
62478
|
+
active.item = { ...active.item, ...phase ? { phase } : {}, text: active.item.text + delta };
|
|
61470
62479
|
this.#event({
|
|
61471
62480
|
type: "item.updated",
|
|
61472
62481
|
turnId: active.command.turnId,
|
|
@@ -61567,6 +62576,7 @@ var ClaudeHarnessSession = class {
|
|
|
61567
62576
|
cwd: this.#cwd,
|
|
61568
62577
|
outputLimit: this.#toolOutputLimit,
|
|
61569
62578
|
taskTracker: this.#taskTracker,
|
|
62579
|
+
mcpServers: () => this.#mcpServers,
|
|
61570
62580
|
nativeTurnKey,
|
|
61571
62581
|
newItemId: () => hostItemIdSchema.parse(this.#randomUUID()),
|
|
61572
62582
|
emit: (event) => this.#event(event),
|
|
@@ -62258,8 +63268,11 @@ var ClaudeCodeAdapter = class {
|
|
|
62258
63268
|
if (current)
|
|
62259
63269
|
return current;
|
|
62260
63270
|
const inspection = this.#inspectModels(cwd).then((result) => {
|
|
62261
|
-
if (result.status === "ready")
|
|
63271
|
+
if (result.status === "ready") {
|
|
62262
63272
|
this.#inspectionCache.set(cwd, result);
|
|
63273
|
+
for (const session of this.#sessions)
|
|
63274
|
+
session.refitThinking(cwd);
|
|
63275
|
+
}
|
|
62263
63276
|
return result;
|
|
62264
63277
|
});
|
|
62265
63278
|
this.#inspectionInFlight.set(cwd, inspection);
|
|
@@ -62290,8 +63303,22 @@ var ClaudeCodeAdapter = class {
|
|
|
62290
63303
|
const account = await inspector.inspectAccount?.() ?? null;
|
|
62291
63304
|
if (this.#latestPlanLimit === planLimitAtStart) {
|
|
62292
63305
|
this.#accountCreditsSupported = account?.credits !== void 0;
|
|
63306
|
+
const inspected = planLimitFromAccountCredits(account?.credits);
|
|
63307
|
+
if (inspected) {
|
|
63308
|
+
const next = { ...this.#latestPlanLimit ?? {} };
|
|
63309
|
+
if (inspected.fiveHour)
|
|
63310
|
+
next.fiveHour = inspected.fiveHour;
|
|
63311
|
+
if (inspected.sevenDay)
|
|
63312
|
+
next.sevenDay = inspected.sevenDay;
|
|
63313
|
+
if (accountCreditsSnapshotSchema.safeParse(projectClaudePlanLimitToCredits(next)).success) {
|
|
63314
|
+
this.#latestPlanLimit = next.fiveHour || next.sevenDay ? next : null;
|
|
63315
|
+
this.#accountCreditsSupported = true;
|
|
63316
|
+
}
|
|
63317
|
+
}
|
|
62293
63318
|
for (const session of this.#sessions) {
|
|
62294
63319
|
session.publishAccountCreditsSupport(this.#accountCreditsSupported);
|
|
63320
|
+
if (this.#latestPlanLimit && inspected)
|
|
63321
|
+
session.publishPlanLimit(this.#latestPlanLimit);
|
|
62295
63322
|
}
|
|
62296
63323
|
}
|
|
62297
63324
|
return account;
|
|
@@ -62541,6 +63568,10 @@ var ClaudeCodeAdapter = class {
|
|
|
62541
63568
|
...requestedModel ? { requestedModel } : {},
|
|
62542
63569
|
requestedPermissionModeId,
|
|
62543
63570
|
requestedThinkingOptionId,
|
|
63571
|
+
modelCatalog: () => {
|
|
63572
|
+
const inspection = this.#inspectionCache.get(cwd);
|
|
63573
|
+
return inspection?.status === "ready" ? inspection.catalog : void 0;
|
|
63574
|
+
},
|
|
62544
63575
|
toolOutputLimit: this.#toolOutputLimit,
|
|
62545
63576
|
cancelTimeoutMs: this.#cancelTimeoutMs,
|
|
62546
63577
|
continuationQuiescenceMs: this.#continuationQuiescenceMs
|
|
@@ -62595,6 +63626,9 @@ var ClaudeCodeAdapter = class {
|
|
|
62595
63626
|
credits() {
|
|
62596
63627
|
return projectClaudePlanLimitToCredits(this.#latestPlanLimit);
|
|
62597
63628
|
}
|
|
63629
|
+
refreshCredits() {
|
|
63630
|
+
return this.inspectAccount().then(() => this.credits());
|
|
63631
|
+
}
|
|
62598
63632
|
close() {
|
|
62599
63633
|
if (!this.#closePromise) {
|
|
62600
63634
|
this.#inspectionCache.clear();
|