@liberseek/boft-cli-linux-x64 0.7.8 → 0.8.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.
Files changed (57) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.txt +8 -0
  3. package/app/codexhost-distribution.json +1 -1
  4. package/app/console-server.mjs +16801 -16440
  5. package/app/console-web.js +9774 -3685
  6. package/app/desktop-controller.mjs +16475 -374
  7. package/app/host-runtime.mjs +9052 -1793
  8. package/app/plugins/antigravity/manifest.json +18 -1
  9. package/app/plugins/antigravity/plugin.mjs +357 -42
  10. package/app/plugins/claude-code/manifest.json +28 -0
  11. package/app/plugins/claude-code/plugin.mjs +1448 -491
  12. package/app/plugins/codebuddy/manifest.json +17 -0
  13. package/app/plugins/codebuddy/plugin.mjs +6589 -5423
  14. package/app/plugins/codex-usage/manifest.json +9 -0
  15. package/app/plugins/codex-usage/plugin.mjs +16750 -0
  16. package/app/plugins/cursor-cli/manifest.json +18 -1
  17. package/app/plugins/cursor-cli/plugin.mjs +782 -197
  18. package/app/plugins/deepseek-harness/assets/icon.svg +1 -0
  19. package/app/plugins/deepseek-harness/manifest.json +35 -2
  20. package/app/plugins/deepseek-harness/plugin.mjs +879 -242
  21. package/app/plugins/enabled.json +3 -1
  22. package/app/plugins/grok/manifest.json +21 -1
  23. package/app/plugins/grok/plugin.mjs +1274 -241
  24. package/app/plugins/hermes/assets/icon.png +0 -0
  25. package/app/plugins/hermes/manifest.json +30 -2
  26. package/app/plugins/hermes/plugin.mjs +3493 -7686
  27. package/app/plugins/kimi-code/assets/icon.svg +5 -0
  28. package/app/plugins/kimi-code/manifest.json +25 -2
  29. package/app/plugins/kimi-code/plugin.mjs +922 -76
  30. package/app/plugins/kiro-cli/assets/kiro-agent.svg +11 -0
  31. package/app/plugins/kiro-cli/manifest.json +18 -1
  32. package/app/plugins/kiro-cli/plugin.mjs +658 -57
  33. package/app/plugins/muse/manifest.json +18 -1
  34. package/app/plugins/muse/plugin.mjs +332 -17
  35. package/app/plugins/omp/manifest.json +21 -1
  36. package/app/plugins/omp/plugin.mjs +2320 -1131
  37. package/app/plugins/opencode/manifest.json +18 -1
  38. package/app/plugins/opencode/plugin.mjs +979 -184
  39. package/app/plugins/pi/manifest.json +32 -0
  40. package/app/plugins/pi/plugin.mjs +2785 -2090
  41. package/app/plugins/qoder/manifest.json +18 -1
  42. package/app/plugins/qoder/plugin.mjs +832 -82
  43. package/app/plugins/qoder-cn/manifest.json +18 -1
  44. package/app/plugins/qoder-cn/plugin.mjs +832 -82
  45. package/app/plugins/workbuddy/manifest.json +18 -0
  46. package/app/plugins/workbuddy/plugin.mjs +6947 -5773
  47. package/app/plugins/zcode/assets/icon.svg +8 -0
  48. package/app/plugins/zcode/manifest.json +32 -0
  49. package/app/plugins/zcode/plugin.mjs +20110 -0
  50. package/app/renderer-extension.js +4762 -2470
  51. package/bin/boft +0 -0
  52. package/libexec/boft-shim +0 -0
  53. package/libexec/boft-updater +0 -0
  54. package/licenses/Cordis-LICENSE.txt +21 -0
  55. package/licenses/Cosmokit-LICENSE.txt +21 -0
  56. package/package.json +1 -1
  57. package/app/plugins/kiro-cli/assets/icon.svg +0 -5
@@ -349,7 +349,7 @@ function createHarnessInstaller(environment, source) {
349
349
 
350
350
  // dist/kiro-adapter.js
351
351
  import { randomUUID } from "node:crypto";
352
- import path7 from "node:path";
352
+ import path8 from "node:path";
353
353
 
354
354
  // ../../../node_modules/zod/v4/classic/external.js
355
355
  var external_exports = {};
@@ -1117,10 +1117,10 @@ function mergeDefs(...defs) {
1117
1117
  function cloneDef(schema) {
1118
1118
  return mergeDefs(schema._zod.def);
1119
1119
  }
1120
- function getElementAtPath(obj, path8) {
1121
- if (!path8)
1120
+ function getElementAtPath(obj, path9) {
1121
+ if (!path9)
1122
1122
  return obj;
1123
- return path8.reduce((acc, key) => acc?.[key], obj);
1123
+ return path9.reduce((acc, key) => acc?.[key], obj);
1124
1124
  }
1125
1125
  function promiseAllObject(promisesObj) {
1126
1126
  const keys = Object.keys(promisesObj);
@@ -1529,11 +1529,11 @@ function explicitlyAborted(x, startIndex = 0) {
1529
1529
  }
1530
1530
  return false;
1531
1531
  }
1532
- function prefixIssues(path8, issues) {
1532
+ function prefixIssues(path9, issues) {
1533
1533
  return issues.map((iss) => {
1534
1534
  var _a3;
1535
1535
  (_a3 = iss).path ?? (_a3.path = []);
1536
- iss.path.unshift(path8);
1536
+ iss.path.unshift(path9);
1537
1537
  return iss;
1538
1538
  });
1539
1539
  }
@@ -1680,16 +1680,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
1680
1680
  }
1681
1681
  function formatError(error51, mapper = (issue2) => issue2.message) {
1682
1682
  const fieldErrors = { _errors: [] };
1683
- const processError = (error52, path8 = []) => {
1683
+ const processError = (error52, path9 = []) => {
1684
1684
  for (const issue2 of error52.issues) {
1685
1685
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1686
- issue2.errors.map((issues) => processError({ issues }, [...path8, ...issue2.path]));
1686
+ issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
1687
1687
  } else if (issue2.code === "invalid_key") {
1688
- processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
1688
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
1689
1689
  } else if (issue2.code === "invalid_element") {
1690
- processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
1690
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
1691
1691
  } else {
1692
- const fullpath = [...path8, ...issue2.path];
1692
+ const fullpath = [...path9, ...issue2.path];
1693
1693
  if (fullpath.length === 0) {
1694
1694
  fieldErrors._errors.push(mapper(issue2));
1695
1695
  } else {
@@ -1716,17 +1716,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
1716
1716
  }
1717
1717
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
1718
1718
  const result = { errors: [] };
1719
- const processError = (error52, path8 = []) => {
1719
+ const processError = (error52, path9 = []) => {
1720
1720
  var _a3, _b;
1721
1721
  for (const issue2 of error52.issues) {
1722
1722
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1723
- issue2.errors.map((issues) => processError({ issues }, [...path8, ...issue2.path]));
1723
+ issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
1724
1724
  } else if (issue2.code === "invalid_key") {
1725
- processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
1725
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
1726
1726
  } else if (issue2.code === "invalid_element") {
1727
- processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
1727
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
1728
1728
  } else {
1729
- const fullpath = [...path8, ...issue2.path];
1729
+ const fullpath = [...path9, ...issue2.path];
1730
1730
  if (fullpath.length === 0) {
1731
1731
  result.errors.push(mapper(issue2));
1732
1732
  continue;
@@ -1758,8 +1758,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
1758
1758
  }
1759
1759
  function toDotPath(_path) {
1760
1760
  const segs = [];
1761
- const path8 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1762
- for (const seg of path8) {
1761
+ const path9 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1762
+ for (const seg of path9) {
1763
1763
  if (typeof seg === "number")
1764
1764
  segs.push(`[${seg}]`);
1765
1765
  else if (typeof seg === "symbol")
@@ -4987,8 +4987,8 @@ function az_default() {
4987
4987
  }
4988
4988
 
4989
4989
  // ../../../node_modules/zod/v4/locales/be.js
4990
- function getBelarusianPlural(count, one, few, many) {
4991
- const absCount = Math.abs(count);
4990
+ function getBelarusianPlural(count2, one, few, many) {
4991
+ const absCount = Math.abs(count2);
4992
4992
  const lastDigit = absCount % 10;
4993
4993
  const lastTwoDigits = absCount % 100;
4994
4994
  if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
@@ -7066,8 +7066,8 @@ function hu_default() {
7066
7066
  }
7067
7067
 
7068
7068
  // ../../../node_modules/zod/v4/locales/hy.js
7069
- function getArmenianPlural(count, one, many) {
7070
- return Math.abs(count) === 1 ? one : many;
7069
+ function getArmenianPlural(count2, one, many) {
7070
+ return Math.abs(count2) === 1 ? one : many;
7071
7071
  }
7072
7072
  function withDefiniteArticle(word) {
7073
7073
  if (!word)
@@ -9195,8 +9195,8 @@ function ro_default() {
9195
9195
  }
9196
9196
 
9197
9197
  // ../../../node_modules/zod/v4/locales/ru.js
9198
- function getRussianPlural(count, one, few, many) {
9199
- const absCount = Math.abs(count);
9198
+ function getRussianPlural(count2, one, few, many) {
9199
+ const absCount = Math.abs(count2);
9200
9200
  const lastDigit = absCount % 10;
9201
9201
  const lastTwoDigits = absCount % 100;
9202
9202
  if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
@@ -14451,13 +14451,13 @@ function resolveRef(ref, ctx) {
14451
14451
  if (!ref.startsWith("#")) {
14452
14452
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14453
14453
  }
14454
- const path8 = ref.slice(1).split("/").filter(Boolean);
14455
- if (path8.length === 0) {
14454
+ const path9 = ref.slice(1).split("/").filter(Boolean);
14455
+ if (path9.length === 0) {
14456
14456
  return ctx.rootSchema;
14457
14457
  }
14458
14458
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14459
- if (path8[0] === defsKey) {
14460
- const key = path8[1];
14459
+ if (path9[0] === defsKey) {
14460
+ const key = path9[1];
14461
14461
  if (!key || !ctx.defs[key]) {
14462
14462
  throw new Error(`Reference not found: ${ref}`);
14463
14463
  }
@@ -14865,6 +14865,15 @@ function date4(params) {
14865
14865
  // ../../../node_modules/zod/v4/classic/external.js
14866
14866
  config(en_default());
14867
14867
 
14868
+ // ../../shared-contracts/dist/delegation-read.js
14869
+ var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
14870
+ var delegationReadParamsSchema = external_exports.strictObject({
14871
+ threadId: external_exports.string().min(1).max(1024),
14872
+ view: external_exports.enum(["result", "messages"]),
14873
+ cursor: external_exports.string().min(1).max(8192).optional(),
14874
+ limit: external_exports.number().int().min(1).max(100).optional()
14875
+ });
14876
+
14868
14877
  // ../../shared-contracts/dist/credential-imports.js
14869
14878
  var credentialSourceSchema = external_exports.object({
14870
14879
  id: external_exports.string().min(1).max(256),
@@ -14935,6 +14944,153 @@ var harnessDisplaySetSchema = external_exports.strictObject({
14935
14944
  initializeOnly: external_exports.boolean().optional()
14936
14945
  });
14937
14946
 
14947
+ // ../../shared-contracts/dist/model-price-overrides.js
14948
+ var usdPerMillionTokens = external_exports.number().finite().nonnegative();
14949
+ var modelPriceOverrideSchema = external_exports.strictObject({
14950
+ input: usdPerMillionTokens,
14951
+ output: usdPerMillionTokens,
14952
+ cacheRead: usdPerMillionTokens.optional(),
14953
+ cacheWrite: usdPerMillionTokens.optional(),
14954
+ cacheWrite1h: usdPerMillionTokens.optional()
14955
+ });
14956
+ var modelPriceKeySchema = external_exports.string().max(512).refine((key) => key.trim() === key && key.length > 0, "Model ID is required");
14957
+ var modelPriceOverridesSchema = external_exports.strictObject({
14958
+ /** Absolute path of the Host's `pricing.json`. */
14959
+ path: external_exports.string(),
14960
+ entries: external_exports.array(external_exports.strictObject({ key: external_exports.string(), price: modelPriceOverrideSchema })),
14961
+ /** Why the existing file is unusable; the Host then ignores it and refuses to overwrite it. */
14962
+ error: external_exports.string().nullable()
14963
+ });
14964
+ var modelPriceOverridesGetSchema = external_exports.strictObject({});
14965
+ var modelPriceOverridesSetSchema = external_exports.strictObject({
14966
+ key: modelPriceKeySchema,
14967
+ price: modelPriceOverrideSchema.nullable(),
14968
+ previousKey: modelPriceKeySchema.optional()
14969
+ });
14970
+ var modelPriceDefaultParamsSchema = external_exports.strictObject({
14971
+ model: modelPriceKeySchema
14972
+ });
14973
+ var modelPriceSuggestionSchema = external_exports.strictObject({
14974
+ /** Verified from catalog canonical links, not inferred from names or equal prices. */
14975
+ official: external_exports.boolean().optional(),
14976
+ canonicalModelId: external_exports.string().min(1).optional(),
14977
+ provider: external_exports.string().min(1).max(512),
14978
+ model: external_exports.string().min(1).max(512),
14979
+ price: modelPriceOverrideSchema
14980
+ });
14981
+ var modelPriceDefaultResultSchema = external_exports.strictObject({
14982
+ price: modelPriceOverrideSchema.nullable(),
14983
+ /** Local catalog suggestions only; never used automatically for pricing. */
14984
+ suggestions: external_exports.array(modelPriceSuggestionSchema).max(6).optional()
14985
+ });
14986
+
14987
+ // ../../shared-contracts/dist/usage-statistics.js
14988
+ var USAGE_STATISTICS_RANGES = ["today", "7d", "30d", "90d", "all"];
14989
+ var count = external_exports.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
14990
+ var localDate = external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/u);
14991
+ var harness = external_exports.string().min(1).max(128);
14992
+ var model = external_exports.string().min(1).max(512);
14993
+ var project = external_exports.string().min(1).max(4096);
14994
+ var usageStatisticsParamsSchema = external_exports.strictObject({
14995
+ range: external_exports.enum(USAGE_STATISTICS_RANGES),
14996
+ harness: harness.optional(),
14997
+ model: model.nullable().optional(),
14998
+ project: project.nullable().optional(),
14999
+ /** One local date inside the range. */
15000
+ date: localDate.optional()
15001
+ });
15002
+ var usageStatisticsTotalsSchema = external_exports.strictObject({
15003
+ requests: count,
15004
+ inputTokens: count,
15005
+ cachedInputTokens: count,
15006
+ cacheWriteInputTokens: count,
15007
+ cacheKnownInputTokens: count,
15008
+ outputTokens: count,
15009
+ reasoningOutputTokens: count,
15010
+ /** USD at the public price, summed over the priced requests only. */
15011
+ costUsd: external_exports.number().finite().min(0),
15012
+ /** Requests without a price (or the cache data the price needs); not in `costUsd`. */
15013
+ unpricedRequests: count,
15014
+ /**
15015
+ * Requests whose storage gave no token counts: counted as requests, with neither tokens nor
15016
+ * cost, and not as unpriced.
15017
+ */
15018
+ unmeteredRequests: count
15019
+ });
15020
+ var totals = usageStatisticsTotalsSchema.shape;
15021
+ var usageStatisticsSessionSchema = external_exports.strictObject({
15022
+ harness,
15023
+ sessionId: external_exports.string().min(1).max(512),
15024
+ project: project.nullable(),
15025
+ /** Models the session used, most requests first. */
15026
+ models: external_exports.array(model).max(16),
15027
+ firstAtMs: count,
15028
+ lastAtMs: count,
15029
+ ...totals
15030
+ });
15031
+ var usageStatisticsResultSchema = external_exports.strictObject({
15032
+ range: external_exports.enum(USAGE_STATISTICS_RANGES),
15033
+ /** First local date of the range; null for all time. */
15034
+ from: localDate.nullable(),
15035
+ to: localDate,
15036
+ /** The filters these figures apply, echoed so a late answer to older filters is recognised. */
15037
+ filters: external_exports.strictObject({
15038
+ harness: harness.nullable(),
15039
+ model: model.nullable(),
15040
+ unknownModel: external_exports.boolean(),
15041
+ project: project.nullable(),
15042
+ unknownProject: external_exports.boolean(),
15043
+ date: localDate.nullable()
15044
+ }),
15045
+ /** Reading of native storage: incomplete while the first read, or a refresh, is under way. */
15046
+ reading: external_exports.strictObject({ complete: external_exports.boolean(), sources: count, read: count }),
15047
+ /** Harnesses whose storage could not be read; their part is missing, the rest is complete. */
15048
+ failures: external_exports.array(external_exports.strictObject({ harness, message: external_exports.string().max(2048) })).max(256),
15049
+ /** Every value seen in the range, ignoring the filters, to choose filters from. */
15050
+ options: external_exports.strictObject({
15051
+ harnesses: external_exports.array(harness).max(256),
15052
+ models: external_exports.array(model.nullable()).max(4096),
15053
+ projects: external_exports.array(project.nullable()).max(4096)
15054
+ }),
15055
+ /** Current display metadata, scoped by Harness. Never a pricing or filter identity.
15056
+ * Optional for older Hosts; missing/conflicting labels fall back to the native model ID.
15057
+ */
15058
+ modelLabels: external_exports.array(external_exports.strictObject({ harness, model, label: model })).max(4096).optional(),
15059
+ /** Native credits, all filters applied, never combined across Harnesses or treated as USD.
15060
+ * Only groups with at least one reported value appear; reportedRequests exposes partial data.
15061
+ */
15062
+ credits: external_exports.array(external_exports.strictObject({
15063
+ harness,
15064
+ model: model.nullable(),
15065
+ credits: external_exports.number().finite().min(0),
15066
+ reportedRequests: count,
15067
+ requests: count
15068
+ })).max(4096).optional(),
15069
+ /** All filters applied. */
15070
+ totals: usageStatisticsTotalsSchema,
15071
+ /** Each date and Harness of the range: every filter except the day. */
15072
+ daily: external_exports.array(external_exports.strictObject({ date: localDate, harness, ...totals })).max(2e5),
15073
+ /** Local weekday (0 = Sunday) and hour, all filters applied. */
15074
+ hourly: external_exports.array(external_exports.strictObject({
15075
+ weekday: external_exports.number().int().min(0).max(6),
15076
+ hour: external_exports.number().int().min(0).max(23),
15077
+ ...totals
15078
+ })).max(168),
15079
+ byHarness: external_exports.array(external_exports.strictObject({ harness, ...totals })).max(256),
15080
+ byModel: external_exports.array(external_exports.strictObject({
15081
+ model: model.nullable(),
15082
+ ...totals,
15083
+ /** Requests priced by what the Harness recorded they cost, not by a price list. */
15084
+ harnessPricedRequests: count
15085
+ })).max(4096),
15086
+ byProject: external_exports.array(external_exports.strictObject({ project: project.nullable(), ...totals })).max(4096),
15087
+ /**
15088
+ * The sessions that spent the most, by cost and by tokens without cache, all filters applied;
15089
+ * requests without a native session are not listed here but count everywhere else.
15090
+ */
15091
+ sessions: external_exports.array(usageStatisticsSessionSchema).max(100)
15092
+ });
15093
+
14938
15094
  // ../../shared-contracts/dist/ids.js
14939
15095
  var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
14940
15096
  message: "Identifier must not be empty or whitespace"
@@ -14945,6 +15101,10 @@ var hostTurnIdSchema = opaqueIdSchema.brand();
14945
15101
  var hostItemIdSchema = opaqueIdSchema.brand();
14946
15102
  var hostInteractionIdSchema = opaqueIdSchema.brand();
14947
15103
 
15104
+ // ../../shared-contracts/dist/thread-prewarm.js
15105
+ var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
15106
+ var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
15107
+
14948
15108
  // ../../shared-contracts/dist/harness-plugins.js
14949
15109
  var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
14950
15110
  var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
@@ -14952,13 +15112,40 @@ var HARNESS_PLUGIN_LIMIT = 128;
14952
15112
  var harnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).refine((id) => id !== "codex", "The official Codex identity is reserved").pipe(harnessIdSchema);
14953
15113
  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");
14954
15114
  var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
15115
+ var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
15116
+ var harnessInstallationGuideSchema = external_exports.object({
15117
+ commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
15118
+ before: localizedTextSchema.optional(),
15119
+ after: localizedTextSchema.optional(),
15120
+ downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
15121
+ }).strict();
14955
15122
  var pluginPresentationShape = {
14956
15123
  id: harnessPluginIdSchema,
14957
15124
  name: external_exports.string().trim().min(1).max(128),
14958
15125
  version: external_exports.string().min(1).max(128),
15126
+ /** Capability-only plugin; omitted for existing session-capable plugins. */
15127
+ kind: external_exports.literal("usage").optional(),
15128
+ /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
15129
+ iconStyle: external_exports.object({
15130
+ vector: external_exports.object({
15131
+ viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
15132
+ color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
15133
+ paths: external_exports.array(external_exports.object({
15134
+ d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
15135
+ fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
15136
+ fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
15137
+ }).strict()).min(1).max(32)
15138
+ }).strict().optional(),
15139
+ background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
15140
+ borderRadius: external_exports.number().min(0).max(50).optional(),
15141
+ paddingRatio: external_exports.number().min(0).max(0.25).optional()
15142
+ }).strict().optional(),
15143
+ installation: harnessInstallationGuideSchema.optional(),
15144
+ notice: localizedTextSchema.optional(),
14959
15145
  /** The factory accepts a persisted local entrypoint through its construction context. */
14960
15146
  launchCommand: external_exports.literal(true).optional(),
14961
15147
  links: external_exports.object({
15148
+ website: documentationUrlSchema.optional(),
14962
15149
  documentation: documentationUrlSchema.optional(),
14963
15150
  installation: documentationUrlSchema.optional()
14964
15151
  }).strict().optional()
@@ -15012,6 +15199,9 @@ var consoleOpenResultSchema = external_exports.strictObject({
15012
15199
  url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
15013
15200
  });
15014
15201
  var CONSOLE_HOST_METHODS = Object.freeze([
15202
+ "codexhost/console/remote-connections",
15203
+ "codexhost/runtime/status",
15204
+ "codexhost/remote/ssh-setup",
15015
15205
  "codexhost/harness/plugins/list",
15016
15206
  "codexhost/harness/display-settings/get",
15017
15207
  "codexhost/harness/display-settings/set",
@@ -15032,6 +15222,10 @@ var CONSOLE_HOST_METHODS = Object.freeze([
15032
15222
  "codexhost/account/list",
15033
15223
  "codexhost/account/refresh",
15034
15224
  "codexhost/account/usage/inspect",
15225
+ "codexhost/usage/model-prices/get",
15226
+ "codexhost/usage/model-prices/set",
15227
+ "codexhost/usage/model-prices/default",
15228
+ "codexhost/usage/statistics/get",
15035
15229
  "codexhost/update/check",
15036
15230
  "codexhost/update/start",
15037
15231
  "codexhost/update/status"
@@ -15096,6 +15290,7 @@ var threadUsageSnapshotSchema = external_exports.object({
15096
15290
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
15097
15291
  outputTokens: nonNegativeSafeIntegerSchema.optional(),
15098
15292
  outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
15293
+ apiOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
15099
15294
  reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
15100
15295
  totalTokens: nonNegativeSafeIntegerSchema.optional(),
15101
15296
  totalCostUsd: finiteNonNegativeNumberSchema.optional(),
@@ -15107,7 +15302,11 @@ var threadUsageSnapshotSchema = external_exports.object({
15107
15302
  planFiveHourUsedPercent: cacheHitRatePercentSchema.optional(),
15108
15303
  planFiveHourResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
15109
15304
  planSevenDayUsedPercent: cacheHitRatePercentSchema.optional(),
15110
- planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional()
15305
+ planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
15306
+ sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
15307
+ timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
15308
+ costSource: external_exports.enum(["publicPrice", "native"]).optional(),
15309
+ unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
15111
15310
  }).strict().superRefine((usage, context) => {
15112
15311
  if (Object.keys(usage).length === 0) {
15113
15312
  context.addIssue({ code: "custom", message: "Thread Usage must contain a reliable field" });
@@ -15128,6 +15327,20 @@ var threadUsageSnapshotSchema = external_exports.object({
15128
15327
  path: ["contextWindowTokens"]
15129
15328
  });
15130
15329
  }
15330
+ if (usage.costSource !== void 0 && usage.totalCostUsd === void 0) {
15331
+ context.addIssue({
15332
+ code: "custom",
15333
+ message: "Thread Usage costSource must be provided with totalCostUsd",
15334
+ path: ["costSource"]
15335
+ });
15336
+ }
15337
+ if (usage.unpricedModels !== void 0 && usage.costSource !== "publicPrice") {
15338
+ context.addIssue({
15339
+ code: "custom",
15340
+ message: "Thread Usage unpricedModels must be provided with a publicPrice cost",
15341
+ path: ["unpricedModels"]
15342
+ });
15343
+ }
15131
15344
  if (usage.planFiveHourResetsAtUnix !== void 0 && usage.planFiveHourUsedPercent === void 0) {
15132
15345
  context.addIssue({
15133
15346
  code: "custom",
@@ -15397,27 +15610,27 @@ var harnessModelCatalogSchema = external_exports.object({
15397
15610
  }).strict().superRefine((catalog, context) => {
15398
15611
  const refs = /* @__PURE__ */ new Set();
15399
15612
  const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
15400
- for (const [index, model] of catalog.models.entries()) {
15401
- if (refs.has(model.ref.id)) {
15613
+ for (const [index, model2] of catalog.models.entries()) {
15614
+ if (refs.has(model2.ref.id)) {
15402
15615
  context.addIssue({
15403
15616
  code: "custom",
15404
15617
  message: "Model Catalog refs must be unique",
15405
15618
  path: ["models", index, "ref", "id"]
15406
15619
  });
15407
15620
  }
15408
- refs.add(model.ref.id);
15409
- if (model.fastModel) {
15410
- if (refs.has(model.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model.fastModel?.id)) {
15621
+ refs.add(model2.ref.id);
15622
+ if (model2.fastModel) {
15623
+ if (refs.has(model2.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model2.fastModel?.id)) {
15411
15624
  context.addIssue({
15412
15625
  code: "custom",
15413
15626
  message: "Fast Model refs must be distinct and unique",
15414
15627
  path: ["models", index, "fastModel"]
15415
15628
  });
15416
15629
  }
15417
- refs.add(model.fastModel.id);
15630
+ refs.add(model2.fastModel.id);
15418
15631
  }
15419
15632
  const supportedThinkingIds = /* @__PURE__ */ new Set();
15420
- for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
15633
+ for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
15421
15634
  if (supportedThinkingIds.has(optionId)) {
15422
15635
  context.addIssue({
15423
15636
  code: "custom",
@@ -15957,6 +16170,85 @@ var updateStatusResultSchema = external_exports.strictObject({
15957
16170
  status: updateStatusSchema.nullable()
15958
16171
  });
15959
16172
 
16173
+ // ../../shared-contracts/dist/remote-runtime.js
16174
+ var remoteUpdatePhaseSchema = external_exports.enum([
16175
+ "idle",
16176
+ "installing",
16177
+ "restarting",
16178
+ "succeeded",
16179
+ "failed"
16180
+ ]);
16181
+ var runtimeStatusSchema = external_exports.object({
16182
+ runningVersion: external_exports.string().nullable(),
16183
+ installedVersion: external_exports.string().nullable(),
16184
+ restartRequired: external_exports.boolean(),
16185
+ remote: external_exports.boolean(),
16186
+ updateSupported: external_exports.boolean(),
16187
+ update: external_exports.object({
16188
+ phase: remoteUpdatePhaseSchema,
16189
+ targetVersion: external_exports.string().nullable(),
16190
+ error: external_exports.string().nullable()
16191
+ })
16192
+ });
16193
+ var remoteUpdateParamsSchema = external_exports.object({
16194
+ version: external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)
16195
+ }).strict();
16196
+ var remoteSshSetupParamsSchema = external_exports.object({
16197
+ hostname: external_exports.string().min(1).max(1024).refine((value) => !value.startsWith("-") && !/\s/u.test(value)),
16198
+ port: external_exports.number().int().min(1).max(65535).nullable(),
16199
+ identity: external_exports.string().max(4096).nullable(),
16200
+ action: external_exports.enum(["inspect", "install", "update", "repair", "uninstall"]),
16201
+ uninstallPackage: external_exports.boolean().optional(),
16202
+ version: external_exports.string().regex(/^\d+\.\d+\.\d+$/u).nullable()
16203
+ }).strict();
16204
+ var remoteSshSetupResultSchema = external_exports.object({ state: external_exports.enum(["installed", "not-installed"]) }).strict();
16205
+
16206
+ // ../../shared-contracts/dist/remote-connections.js
16207
+ var hostId = external_exports.string().min(1).max(1024);
16208
+ var codexSshConnectionSchema = external_exports.object({
16209
+ hostId,
16210
+ displayName: external_exports.string().min(1).max(1024),
16211
+ source: external_exports.enum(["codex-managed", "discovered"]),
16212
+ sshAlias: external_exports.string().max(1024).nullable(),
16213
+ sshHost: external_exports.string().min(1).max(1024),
16214
+ sshPort: external_exports.number().int().min(1).max(65535).nullable(),
16215
+ identity: external_exports.string().max(4096).nullable(),
16216
+ autoConnect: external_exports.boolean(),
16217
+ connectionAnalyticsId: external_exports.string().max(1024).optional()
16218
+ });
16219
+ var codexSshDraftSchema = external_exports.strictObject({
16220
+ displayName: external_exports.string().min(1).max(1024),
16221
+ hostname: external_exports.string().min(1).max(1024),
16222
+ sshPort: external_exports.number().int().min(1).max(65535).nullable(),
16223
+ identity: external_exports.string().max(4096).nullable()
16224
+ });
16225
+ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action", [
16226
+ external_exports.strictObject({ action: external_exports.literal("list") }),
16227
+ external_exports.strictObject({
16228
+ action: external_exports.literal("read-thread"),
16229
+ hostId: hostId.refine((id) => id !== "local"),
16230
+ input: delegationReadParamsSchema
16231
+ }),
16232
+ external_exports.strictObject({
16233
+ action: external_exports.literal("save"),
16234
+ draft: codexSshDraftSchema,
16235
+ previous: codexSshConnectionSchema.nullable()
16236
+ }),
16237
+ external_exports.strictObject({ action: external_exports.literal("remove"), previous: codexSshConnectionSchema }),
16238
+ external_exports.strictObject({ action: external_exports.literal("connect"), hostId, enabled: external_exports.boolean() }),
16239
+ external_exports.strictObject({ action: external_exports.literal("state"), hostId }),
16240
+ external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
16241
+ external_exports.strictObject({
16242
+ action: external_exports.literal("update"),
16243
+ hostId: hostId.refine((id) => id !== "local"),
16244
+ version: remoteUpdateParamsSchema.shape.version
16245
+ })
16246
+ ]);
16247
+ var remoteConnectionsReplySchema = external_exports.union([
16248
+ external_exports.strictObject({ result: jsonValueSchema }),
16249
+ external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
16250
+ ]);
16251
+
15960
16252
  // ../../shared-contracts/dist/index.js
15961
16253
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
15962
16254
 
@@ -16068,7 +16360,6 @@ var tokenFields = [
16068
16360
  "cachedInputTokens",
16069
16361
  "cacheWriteInputTokens",
16070
16362
  "outputTokens",
16071
- "outputTokensPerSecond",
16072
16363
  "reasoningOutputTokens",
16073
16364
  "totalTokens",
16074
16365
  "contextWindowTokens",
@@ -16076,10 +16367,12 @@ var tokenFields = [
16076
16367
  ];
16077
16368
  var safeIntegerFields = [
16078
16369
  "planFiveHourResetsAtUnix",
16079
- "planSevenDayResetsAtUnix"
16370
+ "planSevenDayResetsAtUnix",
16371
+ "timeToFirstOutputMs"
16080
16372
  ];
16081
16373
  var percentFields = [
16082
16374
  "cacheHitRatePercent",
16375
+ "sessionCacheHitRatePercent",
16083
16376
  "planFiveHourUsedPercent",
16084
16377
  "planSevenDayUsedPercent"
16085
16378
  ];
@@ -16087,9 +16380,14 @@ var usageFields = /* @__PURE__ */ new Set([
16087
16380
  ...tokenFields,
16088
16381
  ...safeIntegerFields,
16089
16382
  ...percentFields,
16383
+ "sessionCacheUsage",
16090
16384
  "totalCostUsd",
16091
16385
  "totalCredits",
16092
- "contextUsagePercent"
16386
+ "contextUsagePercent",
16387
+ "outputTokensPerSecond",
16388
+ "apiOutputTokensPerSecond",
16389
+ "costSource",
16390
+ "unpricedModels"
16093
16391
  ]);
16094
16392
  function isRecord(value) {
16095
16393
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -16105,7 +16403,11 @@ function parseHostUsage(value) {
16105
16403
  throw new Error(`Harness Usage contains unknown field '${key}'`);
16106
16404
  }
16107
16405
  }
16108
- for (const field of ["totalCredits", "contextUsagePercent"]) {
16406
+ for (const field of [
16407
+ "totalCredits",
16408
+ "contextUsagePercent",
16409
+ "apiOutputTokensPerSecond"
16410
+ ]) {
16109
16411
  const candidate = value[field];
16110
16412
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
16111
16413
  throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
@@ -16141,6 +16443,12 @@ function parseHostUsage(value) {
16141
16443
  throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
16142
16444
  }
16143
16445
  }
16446
+ if (value.sessionCacheUsage !== void 0) {
16447
+ const totals2 = value.sessionCacheUsage;
16448
+ if (!isRecord(totals2) || Object.keys(totals2).some((key) => key !== "inputTokens" && key !== "cachedInputTokens") || typeof totals2.inputTokens !== "number" || !Number.isSafeInteger(totals2.inputTokens) || totals2.inputTokens < 0 || typeof totals2.cachedInputTokens !== "number" || !Number.isSafeInteger(totals2.cachedInputTokens) || totals2.cachedInputTokens < 0 || totals2.cachedInputTokens > totals2.inputTokens) {
16449
+ throw new Error("Harness Usage 'sessionCacheUsage' must contain complete bounded token totals");
16450
+ }
16451
+ }
16144
16452
  const hasContextUsed = value.contextUsedTokens !== void 0;
16145
16453
  const hasContextWindow = value.contextWindowTokens !== void 0;
16146
16454
  if (hasContextUsed !== hasContextWindow) {
@@ -16155,8 +16463,43 @@ function parseHostUsage(value) {
16155
16463
  if (value.planSevenDayResetsAtUnix !== void 0 && value.planSevenDayUsedPercent === void 0) {
16156
16464
  throw new Error("Harness Usage 'planSevenDayResetsAtUnix' must be provided with 'planSevenDayUsedPercent'");
16157
16465
  }
16466
+ if (value.costSource !== void 0) {
16467
+ if (value.costSource !== "publicPrice" && value.costSource !== "native") {
16468
+ throw new Error("Harness Usage 'costSource' must be 'publicPrice' or 'native'");
16469
+ }
16470
+ if (value.totalCostUsd === void 0) {
16471
+ throw new Error("Harness Usage 'costSource' must be provided with 'totalCostUsd'");
16472
+ }
16473
+ }
16474
+ if (value.unpricedModels !== void 0) {
16475
+ const models = value.unpricedModels;
16476
+ if (!Array.isArray(models) || models.length === 0 || !models.every((model2) => typeof model2 === "string" && model2.length > 0)) {
16477
+ throw new Error("Harness Usage 'unpricedModels' must be a non-empty list of Model IDs");
16478
+ }
16479
+ if (value.costSource !== "publicPrice") {
16480
+ throw new Error("Harness Usage 'unpricedModels' must be provided with a 'publicPrice' cost");
16481
+ }
16482
+ return { ...value, unpricedModels: [...models] };
16483
+ }
16158
16484
  return { ...value };
16159
16485
  }
16486
+ var requestTokenFields = [
16487
+ "inputTokens",
16488
+ "cachedInputTokens",
16489
+ "cacheWriteInputTokens",
16490
+ "cacheWrite1hInputTokens",
16491
+ "outputTokens",
16492
+ "reasoningOutputTokens",
16493
+ "startedAtMs",
16494
+ "completedAtMs"
16495
+ ];
16496
+ var requestFields = /* @__PURE__ */ new Set([
16497
+ ...requestTokenFields,
16498
+ "requestId",
16499
+ "historical",
16500
+ "model",
16501
+ "provider"
16502
+ ]);
16160
16503
 
16161
16504
  // ../../harness-adapter/dist/live-command-catalog.js
16162
16505
  var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
@@ -18567,9 +18910,9 @@ var Connection = class {
18567
18910
  return;
18568
18911
  }
18569
18912
  const responseBatch = isResponseBatch(batch);
18570
- const responseCount = responseBatch ? 0 : batch.reduce((count, message) => count + (isNotificationMessage(message) ? 0 : 1), 0);
18913
+ const responseCount = responseBatch ? 0 : batch.reduce((count2, message) => count2 + (isNotificationMessage(message) ? 0 : 1), 0);
18571
18914
  let remaining = responseCount;
18572
- let remainingNotifications = batch.reduce((count, message) => count + (isNotificationMessage(message) ? 1 : 0), 0);
18915
+ let remainingNotifications = batch.reduce((count2, message) => count2 + (isNotificationMessage(message) ? 1 : 0), 0);
18573
18916
  let responseSent = false;
18574
18917
  const responses = [];
18575
18918
  const sendResponsesIfReady = async () => {
@@ -21454,16 +21797,16 @@ var Diff = class {
21454
21797
  }
21455
21798
  }
21456
21799
  }
21457
- addToPath(path8, added, removed, oldPosInc, options) {
21458
- const last = path8.lastComponent;
21800
+ addToPath(path9, added, removed, oldPosInc, options) {
21801
+ const last = path9.lastComponent;
21459
21802
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
21460
21803
  return {
21461
- oldPos: path8.oldPos + oldPosInc,
21804
+ oldPos: path9.oldPos + oldPosInc,
21462
21805
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
21463
21806
  };
21464
21807
  } else {
21465
21808
  return {
21466
- oldPos: path8.oldPos + oldPosInc,
21809
+ oldPos: path9.oldPos + oldPosInc,
21467
21810
  lastComponent: { count: 1, added, removed, previousComponent: last }
21468
21811
  };
21469
21812
  }
@@ -22743,10 +23086,265 @@ async function readKiroSnapshot(location) {
22743
23086
  };
22744
23087
  }
22745
23088
 
22746
- // dist/kiro-adapter.js
23089
+ // dist/session-import.js
23090
+ import { opendir, readFile as readFile2, stat } from "node:fs/promises";
23091
+ import path7 from "node:path";
23092
+
23093
+ // ../../harness-adapter/dist/session-import.js
23094
+ import { lstat } from "node:fs/promises";
23095
+ var SessionImportChangedError = class extends Error {
23096
+ constructor(message = "Native Session changed during discovery; refresh and retry") {
23097
+ super(message);
23098
+ this.name = "SessionImportChangedError";
23099
+ }
23100
+ };
23101
+ function isMissingFileError(error51) {
23102
+ return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "ENOENT";
23103
+ }
23104
+ function sameFileFingerprint(left, right) {
23105
+ return left === null || right === null ? left === right : left.dev === right.dev && left.ino === right.ino && left.size === right.size && left.mtimeMs === right.mtimeMs && left.ctimeMs === right.ctimeMs;
23106
+ }
23107
+ var STORAGE_ACCESS_ERRORS = /* @__PURE__ */ new Set(["EACCES", "EPERM", "EIO", "EMFILE", "ENFILE"]);
23108
+ function isStorageAccessError(error51) {
23109
+ return typeof error51 === "object" && error51 !== null && "code" in error51 && typeof error51.code === "string" && STORAGE_ACCESS_ERRORS.has(error51.code);
23110
+ }
23111
+ async function optionalLstat(file2) {
23112
+ try {
23113
+ return await lstat(file2);
23114
+ } catch (error51) {
23115
+ if (isMissingFileError(error51))
23116
+ return null;
23117
+ throw error51;
23118
+ }
23119
+ }
23120
+ async function readStableFiles(files, read) {
23121
+ const before = await Promise.all(files.map(optionalLstat));
23122
+ const value = await read(before);
23123
+ const after = await Promise.all(files.map(optionalLstat));
23124
+ if (before.some((info, index) => !sameFileFingerprint(info, after[index] ?? null)))
23125
+ throw new SessionImportChangedError();
23126
+ return value;
23127
+ }
23128
+ function sessionImportTitle(value, maxLength = HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH) {
23129
+ if (typeof value !== "string")
23130
+ return null;
23131
+ const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
23132
+ if (!normalized)
23133
+ return null;
23134
+ if (normalized.length <= maxLength)
23135
+ return normalized;
23136
+ const characters = [...normalized];
23137
+ if (characters.length <= maxLength)
23138
+ return normalized;
23139
+ return `${characters.slice(0, maxLength - 1).join("").trimEnd()}…`;
23140
+ }
23141
+ function sessionImportCandidate(input) {
23142
+ const time3 = typeof input.updatedAt === "number" ? input.updatedAt : typeof input.updatedAt === "string" ? Date.parse(input.updatedAt) : Number.NaN;
23143
+ const parsed = harnessSessionImportCandidateSchema.safeParse({
23144
+ nativeSessionId: input.nativeSessionId,
23145
+ cwd: input.cwd,
23146
+ title: typeof input.title === "string" && input.title.trim().length > 0 ? input.title : null,
23147
+ updatedAt: Math.floor(time3),
23148
+ // Unknown must stay unknown; only an explicit boolean is a native statement.
23149
+ running: typeof input.running === "boolean" ? input.running : null
23150
+ });
23151
+ return parsed.success ? parsed.data : null;
23152
+ }
23153
+ var SessionImportScope = class {
23154
+ #abort = new AbortController();
23155
+ #options;
23156
+ #pending = /* @__PURE__ */ new Set();
23157
+ constructor(options) {
23158
+ this.#options = options;
23159
+ }
23160
+ #closed() {
23161
+ return {
23162
+ ok: false,
23163
+ error: { code: "invalidState", message: this.#options.closedMessage, retryable: false }
23164
+ };
23165
+ }
23166
+ read(operation) {
23167
+ const signal = this.#abort.signal;
23168
+ if (signal.aborted)
23169
+ return Promise.resolve(this.#closed());
23170
+ let started;
23171
+ try {
23172
+ started = operation(signal);
23173
+ } catch (error51) {
23174
+ started = Promise.reject(error51 instanceof Error ? error51 : new Error("Session read failed"));
23175
+ }
23176
+ const request = started.then((value) => signal.aborted ? this.#closed() : { ok: true, value }).catch(() => signal.aborted ? this.#closed() : {
23177
+ ok: false,
23178
+ error: {
23179
+ code: "unavailable",
23180
+ message: this.#options.unavailableMessage,
23181
+ retryable: true
23182
+ }
23183
+ }).finally(() => this.#pending.delete(request));
23184
+ this.#pending.add(request);
23185
+ return request;
23186
+ }
23187
+ /** `read` for `resolveCandidate`: a null source is the selected Session having disappeared. */
23188
+ async resolve(operation) {
23189
+ const result = await this.read(operation);
23190
+ if (!result.ok)
23191
+ return result;
23192
+ return result.value ? { ok: true, value: result.value } : {
23193
+ ok: false,
23194
+ error: {
23195
+ code: "sessionNotFound",
23196
+ message: this.#options.notFoundMessage,
23197
+ retryable: false
23198
+ }
23199
+ };
23200
+ }
23201
+ /** Idempotent. Resolves after every started read has settled. */
23202
+ async close() {
23203
+ this.#abort.abort();
23204
+ await Promise.allSettled(this.#pending);
23205
+ }
23206
+ };
23207
+
23208
+ // dist/session-import.js
23209
+ var MAX_METADATA_BYTES = 1024 * 1024;
23210
+ var NON_WORKSPACE_DIRECTORIES = /* @__PURE__ */ new Set(["cli"]);
22747
23211
  function isRecord11(value) {
22748
23212
  return typeof value === "object" && value !== null && !Array.isArray(value);
22749
23213
  }
23214
+ function userText(row) {
23215
+ const { content, text } = row.payload;
23216
+ return kiroVisibleText(typeof content === "string" ? content : text ?? "");
23217
+ }
23218
+ var KiroSessionImport = class {
23219
+ #environment;
23220
+ #scope = new SessionImportScope({
23221
+ closedMessage: "Kiro Session import is closed",
23222
+ unavailableMessage: "Kiro sessions could not be read; close native clients, check storage access and retry",
23223
+ notFoundMessage: "Kiro Session is no longer importable"
23224
+ });
23225
+ constructor(environment) {
23226
+ this.#environment = { ...environment };
23227
+ }
23228
+ listCandidates() {
23229
+ return this.#scope.read(async (signal) => {
23230
+ const candidates = [];
23231
+ for (const [, directories] of await this.#sessionDirectories(signal)) {
23232
+ if (directories.length !== 1 || !directories[0])
23233
+ continue;
23234
+ try {
23235
+ const candidate = await this.#candidate(directories[0], signal);
23236
+ if (candidate)
23237
+ candidates.push(candidate);
23238
+ } catch (error51) {
23239
+ if (!(error51 instanceof SessionImportChangedError))
23240
+ throw error51;
23241
+ }
23242
+ }
23243
+ return candidates;
23244
+ });
23245
+ }
23246
+ resolveCandidate(nativeSessionId) {
23247
+ return this.#scope.resolve(async (signal) => {
23248
+ const directories = (await this.#sessionDirectories(signal)).get(nativeSessionId);
23249
+ if (directories?.length !== 1 || !directories[0])
23250
+ return null;
23251
+ const candidate = await this.#candidate(directories[0], signal);
23252
+ if (!candidate)
23253
+ return null;
23254
+ return {
23255
+ candidate,
23256
+ nativeRef: nativeSessionRefSchema.parse({
23257
+ harnessId: "kiro-cli",
23258
+ nativeSessionId,
23259
+ formatVersion: 1
23260
+ })
23261
+ };
23262
+ });
23263
+ }
23264
+ close() {
23265
+ return this.#scope.close();
23266
+ }
23267
+ /** Session ID to every directory claiming it. Enumerated links are not followed. */
23268
+ async #sessionDirectories(signal) {
23269
+ const root = path7.join(kiroHomeDir(this.#environment), "sessions");
23270
+ const found = /* @__PURE__ */ new Map();
23271
+ const info = await optionalLstat(root);
23272
+ if (!info)
23273
+ return found;
23274
+ if (!info.isDirectory())
23275
+ throw new Error("Kiro Session store is not a directory");
23276
+ for await (const workspace of await opendir(root)) {
23277
+ signal.throwIfAborted();
23278
+ if (!workspace.isDirectory() || NON_WORKSPACE_DIRECTORIES.has(workspace.name))
23279
+ continue;
23280
+ const workspaceDirectory = path7.join(root, workspace.name);
23281
+ const sessions = await opendir(workspaceDirectory).catch((error51) => {
23282
+ if (isMissingFileError(error51))
23283
+ return null;
23284
+ throw error51;
23285
+ });
23286
+ if (!sessions)
23287
+ continue;
23288
+ for await (const session of sessions) {
23289
+ signal.throwIfAborted();
23290
+ if (!session.isDirectory())
23291
+ continue;
23292
+ const directories = found.get(session.name) ?? [];
23293
+ directories.push(path7.join(workspaceDirectory, session.name));
23294
+ found.set(session.name, directories);
23295
+ }
23296
+ }
23297
+ return found;
23298
+ }
23299
+ async #candidate(sessionDirectory, signal) {
23300
+ signal.throwIfAborted();
23301
+ const files = [
23302
+ path7.join(sessionDirectory, "session.json"),
23303
+ path7.join(sessionDirectory, "messages.jsonl")
23304
+ ];
23305
+ return readStableFiles(files, async ([metadata, messages]) => {
23306
+ if (!metadata?.isFile() || !messages?.isFile() || metadata.size > MAX_METADATA_BYTES)
23307
+ return null;
23308
+ try {
23309
+ const meta3 = JSON.parse(await readFile2(files[0], { encoding: "utf8", signal }));
23310
+ if (!isRecord11(meta3) || meta3.id !== path7.basename(sessionDirectory))
23311
+ return null;
23312
+ const workspacePath = Array.isArray(meta3.workspacePaths) ? meta3.workspacePaths[0] : void 0;
23313
+ if (typeof workspacePath !== "string" || !path7.isAbsolute(workspacePath) || workspacePath.includes("\0"))
23314
+ return null;
23315
+ const cwd = path7.resolve(workspacePath);
23316
+ if (!(await stat(cwd)).isDirectory())
23317
+ return null;
23318
+ signal.throwIfAborted();
23319
+ const rows = await readKiroSessionMessages({
23320
+ sessionDirectory,
23321
+ sessionMeta: meta3,
23322
+ cwd
23323
+ });
23324
+ const firstUser = rows.find((row) => row.payload.type === "user");
23325
+ if (!firstUser)
23326
+ return null;
23327
+ const modified = typeof meta3.lastModifiedAt === "string" ? Date.parse(meta3.lastModifiedAt) : Number.NaN;
23328
+ return sessionImportCandidate({
23329
+ nativeSessionId: meta3.id,
23330
+ cwd,
23331
+ title: sessionImportTitle(meta3.title) ?? sessionImportTitle(userText(firstUser)),
23332
+ updatedAt: Number.isFinite(modified) && modified >= 0 ? modified : messages.mtimeMs
23333
+ });
23334
+ } catch (error51) {
23335
+ signal.throwIfAborted();
23336
+ if (isStorageAccessError(error51))
23337
+ throw error51;
23338
+ return null;
23339
+ }
23340
+ });
23341
+ }
23342
+ };
23343
+
23344
+ // dist/kiro-adapter.js
23345
+ function isRecord12(value) {
23346
+ return typeof value === "object" && value !== null && !Array.isArray(value);
23347
+ }
22750
23348
  var KIRO_SESSION_CAPABILITIES = {
22751
23349
  configuration: {
22752
23350
  selectModel: true,
@@ -22771,6 +23369,7 @@ var KiroAdapter = class {
22771
23369
  harnessId = harnessIdSchema.parse("kiro-cli");
22772
23370
  commandCatalog = KIRO_COMMAND_CATALOG;
22773
23371
  liveCommandCatalog = true;
23372
+ sessionImport;
22774
23373
  #options;
22775
23374
  #deps;
22776
23375
  #sessions = /* @__PURE__ */ new Set();
@@ -22779,9 +23378,10 @@ var KiroAdapter = class {
22779
23378
  constructor(options = {}, deps = {}) {
22780
23379
  this.#options = options;
22781
23380
  this.#deps = deps;
23381
+ this.sessionImport = new KiroSessionImport({ ...process.env, ...options.environment });
22782
23382
  }
22783
23383
  async inspect(input = {}) {
22784
- const cwd = path7.resolve(input.cwd ?? process.cwd());
23384
+ const cwd = path8.resolve(input.cwd ?? process.cwd());
22785
23385
  const cached2 = this.#inspectionCache.get(cwd);
22786
23386
  if (!input.refresh && cached2) {
22787
23387
  if (cached2.refreshAfter <= Date.now()) {
@@ -22842,7 +23442,7 @@ var KiroAdapter = class {
22842
23442
  const transport = this.#createTransport(cwd);
22843
23443
  try {
22844
23444
  const initialize = await transport.inspect();
22845
- const modelCatalog = isRecord11(initialize) && isRecord11(initialize.catalog) ? initialize.catalog : parseKiroModelCatalog(isRecord11(initialize) ? initialize.configOptions : void 0);
23445
+ const modelCatalog = isRecord12(initialize) && isRecord12(initialize.catalog) ? initialize.catalog : parseKiroModelCatalog(isRecord12(initialize) ? initialize.configOptions : void 0);
22846
23446
  if (modelCatalog.models.length === 0)
22847
23447
  throw new Error("Kiro returned no native model catalog");
22848
23448
  return {
@@ -23096,6 +23696,7 @@ var KiroAdapter = class {
23096
23696
  async close() {
23097
23697
  try {
23098
23698
  await Promise.all([
23699
+ this.sessionImport.close(),
23099
23700
  ...this.#inspectionInFlight.values(),
23100
23701
  ...[...this.#sessions].map((session) => session.close())
23101
23702
  ]);
@@ -23263,7 +23864,7 @@ var KiroSession = class {
23263
23864
  }
23264
23865
  };
23265
23866
  } catch (error51) {
23266
- if (this.#newSessionWithoutTurn && isRecord11(error51) && error51.code === "ENOENT") {
23867
+ if (this.#newSessionWithoutTurn && isRecord12(error51) && error51.code === "ENOENT") {
23267
23868
  return { ok: true, value: { turns: [], state: this.#state() } };
23268
23869
  }
23269
23870
  return {
@@ -23324,7 +23925,7 @@ var KiroSession = class {
23324
23925
  kind: "event",
23325
23926
  event: { type: "turn.started", turnId }
23326
23927
  });
23327
- const userText = command.input.filter((part) => part.type === "text").map((part) => part.text).join("\n");
23928
+ const userText2 = command.input.filter((part) => part.type === "text").map((part) => part.text).join("\n");
23328
23929
  const output = new KiroTurnOutput(turnId, this.#cwd, (event) => this.#channel.emit(event));
23329
23930
  let assignedUserMessageId;
23330
23931
  const stopped = new Promise((_resolve, reject) => {
@@ -23335,14 +23936,14 @@ var KiroSession = class {
23335
23936
  try {
23336
23937
  const promptResult = await Promise.race([
23337
23938
  stopped,
23338
- this.#transport.runTurn(userText, (event) => {
23939
+ this.#transport.runTurn(userText2, (event) => {
23339
23940
  if (this.#closed || this.#activeTurnId !== turnId)
23340
23941
  return;
23341
23942
  output.accept(event);
23342
23943
  if (event.type === "usage") {
23343
23944
  this.observeUsage(event);
23344
23945
  const meta3 = event.metadata?.kiro;
23345
- if (isRecord11(meta3) && meta3.kind === "user_message_id_assigned" && typeof meta3.userMessageId === "string") {
23946
+ if (isRecord12(meta3) && meta3.kind === "user_message_id_assigned" && typeof meta3.userMessageId === "string") {
23346
23947
  assignedUserMessageId = meta3.userMessageId;
23347
23948
  }
23348
23949
  } else if (event.type === "compaction.completed") {
@@ -23424,7 +24025,7 @@ var KiroSession = class {
23424
24025
  });
23425
24026
  })
23426
24027
  ]);
23427
- if (isRecord11(promptResult) && promptResult.stopReason === "cancelled") {
24028
+ if (isRecord12(promptResult) && promptResult.stopReason === "cancelled") {
23428
24029
  turnOutcome = { status: "cancelled", reason: "User cancelled" };
23429
24030
  } else {
23430
24031
  turnOutcome = { status: "succeeded" };
@@ -23675,9 +24276,9 @@ var KiroSession = class {
23675
24276
  #updateConfig(options) {
23676
24277
  if (this.#closed)
23677
24278
  throw new Error("Session closed during configuration");
23678
- const model = kiroConfigValue(options, "model");
24279
+ const model2 = kiroConfigValue(options, "model");
23679
24280
  const autopilot = kiroConfigValue(options, "autopilot");
23680
- this.#currentModel = model ? harnessModelRefSchema.parse({ id: model }) : void 0;
24281
+ this.#currentModel = model2 ? harnessModelRefSchema.parse({ id: model2 }) : void 0;
23681
24282
  this.#currentPermissionModeId = autopilot === "on" || autopilot === "off" ? encodeKiroPermissionMode(autopilot) : void 0;
23682
24283
  this.#modelCatalog = parseKiroModelCatalog(options);
23683
24284
  this.#thinking = kiroThinkingState(options);
@@ -23753,7 +24354,7 @@ var KiroSession = class {
23753
24354
  }
23754
24355
  });
23755
24356
  const result2 = await Promise.race([stopped, this.#transport.compact()]);
23756
- if (isRecord11(result2) && result2.success === false) {
24357
+ if (isRecord12(result2) && result2.success === false) {
23757
24358
  throw new Error("Kiro context compaction did not complete");
23758
24359
  }
23759
24360
  this.#channel.emit({