@bike4mind/cli 4.10.0 → 5.0.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 (33) hide show
  1. package/dist/{AgentHistoryStore-CjGVgxLR.mjs → AgentHistoryStore-C3hJOgpM.mjs} +188 -90
  2. package/dist/{ApiClient-SVXSI3HI.mjs → ApiClient-CeuIcSY8.mjs} +3 -3
  3. package/dist/{BubblewrapRuntime-CTc_KPnd.mjs → BubblewrapRuntime-BF5wXaNS.mjs} +2 -2
  4. package/dist/ConfigStore--dPqdX3O.mjs +2 -0
  5. package/dist/{ConfigStore-B2Dy-PT9.mjs → ConfigStore-nr0ebq4v.mjs} +1 -1
  6. package/dist/{Logger-7MmrU5w6.mjs → Logger-CovZt7LL.mjs} +509 -103
  7. package/dist/{RemoteSkillSource-D_F99yBR.mjs → RemoteSkillSource-HqoLRV56.mjs} +2 -6
  8. package/dist/{SandboxOrchestrator-CeDwd6Fj.mjs → SandboxOrchestrator-DTz_5Zub.mjs} +1 -1
  9. package/dist/{SandboxRuntimeAdapter-CjNDzYSf.mjs → SandboxRuntimeAdapter-CC5KlbZ8.mjs} +2 -2
  10. package/dist/{SandboxRuntimeAdapter-CFEIywKt.mjs → SandboxRuntimeAdapter-X0HAkbpW.mjs} +1 -1
  11. package/dist/{SeatbeltRuntime-CQItj-F1.mjs → SeatbeltRuntime-zdxVqGZ3.mjs} +2 -2
  12. package/dist/{WorkItemsClient-C9_pjHCo.mjs → WorkItemsClient-lKJCPP0j.mjs} +1 -1
  13. package/dist/{buildToolSearch-8xyBwXRx.mjs → buildToolSearch-BlOSK4m3.mjs} +2 -2
  14. package/dist/commands/acpCommand.mjs +6 -6
  15. package/dist/commands/apiCommand.mjs +1 -1
  16. package/dist/commands/doctorCommand.mjs +2 -2
  17. package/dist/commands/envCommand.mjs +1 -1
  18. package/dist/commands/headlessCommand.mjs +7 -7
  19. package/dist/commands/mcpCommand.mjs +3 -3
  20. package/dist/commands/mirrorCommand.mjs +2 -2
  21. package/dist/commands/modelsCommand.mjs +4 -4
  22. package/dist/commands/pluginCommand.mjs +1 -1
  23. package/dist/commands/skillsCommand.mjs +4 -4
  24. package/dist/commands/updateCommand.mjs +2 -2
  25. package/dist/{dist-DHgMhdzV.mjs → dist-BrBjZ6Cv.mjs} +33 -3
  26. package/dist/{fit-D8Quui6j.mjs → fit-vnmP4Dfc.mjs} +3 -3
  27. package/dist/index.mjs +12 -417
  28. package/dist/{modelServers-JsKBm7Wn.mjs → modelServers-CjSlPFsg.mjs} +1 -1
  29. package/dist/{package-r_xumsGY.mjs → package-BTvxFRbB.mjs} +1 -1
  30. package/dist/{serve-BM9PKMLH.mjs → serve-BLBhPkyw.mjs} +6 -6
  31. package/dist/{updateChecker-BOqaLeZU.mjs → updateChecker-uDIZuEZg.mjs} +1 -1
  32. package/package.json +10 -11
  33. package/dist/ConfigStore-zlY0PikB.mjs +0 -2
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import { C as NotAuthenticatedError, D as sanitizeTerminalText, d as sandboxedCommandArg, l as commandTextOf, p as writePathOf, s as loadContextFiles, u as isReadOnlyTool, w as SessionRevokedError } from "./ConfigStore-B2Dy-PT9.mjs";
3
- import { a as extractErrorMessage, d as BaseStorage, f as isPrivateIP, l as OllamaBackend, n as B4mStreamEndedError, o as getSettingsMap, p as Logger, r as createClient, s as getSettingsValue, t as B4mApiError, u as OpenAICompatibleBackend } from "./dist-DHgMhdzV.mjs";
4
- import { At as isExpectedToolError, B as LOW_CONFIDENCE_COMPLETION_MODES, Et as googleMapsSearchUrl, G as NotFoundError, I as ExpectedToolError, Jt as signImageUrl, Kt as secureParameters, M as DecisionTextPartSchema, Mt as isProviderRefusalStopReason, N as DecisionsRequestSchema, Nt as isRetryableError, T as ChatModels, U as McpServerName, Ut as reasoningChannelOf, V as MODEL_DECLINED_MESSAGE, Y as PermissionDeniedError, Yt as splitEquals, _t as createReasoningWithholder, a as htmlFirstH1, an as withholdsReasoning, at as SEARCH_RESULT_CARDS_LANGUAGE, ft as WORK_ITEM_STATUSES, h as ApiKeyType, i as htmlErrorTitle, in as withRetry, jt as isPlaceholderImageSigningSecret, lt as UnprocessableEntityError, n as SESSION_ID_PATTERN, o as escapeArtifactBodyJson, pn as frontmatterHasSourceStamp, pt as assertAuthOriginMatchesApiKey, r as isValidSessionId, t as logger, w as CUSTOM_MCP_DATA_NOTICE, wt as getMcpProviderMetadata, x as CONFIDENCE_GATE_MODES, xt as fromCliTodos, z as LOCATION_MAP_LANGUAGE, zt as obfuscateApiKey } from "./Logger-7MmrU5w6.mjs";
5
- import { r as isReservedCommandName } from "./RemoteSkillSource-D_F99yBR.mjs";
2
+ import { C as NotAuthenticatedError, D as sanitizeTerminalText, d as sandboxedCommandArg, l as commandTextOf, p as writePathOf, s as loadContextFiles, u as isReadOnlyTool, w as SessionRevokedError } from "./ConfigStore-nr0ebq4v.mjs";
3
+ import { a as extractErrorMessage, d as BaseStorage, f as isPrivateIP, h as redactLogValue, l as OllamaBackend, m as redactLogText, n as B4mStreamEndedError, o as getSettingsMap, p as Logger, r as createClient, s as getSettingsValue, t as B4mApiError, u as OpenAICompatibleBackend } from "./dist-BrBjZ6Cv.mjs";
4
+ import { At as isProviderRefusalStopReason, B as LOW_CONFIDENCE_COMPLETION_MODES, G as NotFoundError, I as ExpectedToolError, Kt as signImageUrl, Lt as obfuscateApiKey, M as DecisionTextPartSchema, N as DecisionsRequestSchema, Ot as isExpectedToolError, St as getMcpProviderMetadata, T as ChatModels, U as McpServerName, V as MODEL_DECLINED_MESSAGE, Vt as reasoningChannelOf, Wt as secureParameters, Y as PermissionDeniedError, a as htmlFirstH1, dn as frontmatterHasSourceStamp, dt as assertAuthOriginMatchesApiKey, h as ApiKeyType, ht as createReasoningWithholder, i as htmlErrorTitle, it as SEARCH_RESULT_CARDS_LANGUAGE, jt as isRetryableError, kt as isPlaceholderImageSigningSecret, n as SESSION_ID_PATTERN, nn as withRetry, o as escapeArtifactBodyJson, qt as splitEquals, r as isValidSessionId, rn as withholdsReasoning, st as UnprocessableEntityError, t as logger, ut as WORK_ITEM_STATUSES, w as CUSTOM_MCP_DATA_NOTICE, wt as googleMapsSearchUrl, x as CONFIDENCE_GATE_MODES, yt as fromCliTodos, z as LOCATION_MAP_LANGUAGE } from "./Logger-CovZt7LL.mjs";
5
+ import { r as isReservedCommandName } from "./RemoteSkillSource-HqoLRV56.mjs";
6
6
  import { n as isPathAllowed, t as assertPathAllowed } from "./pathValidation-BRqf4HFX-CHwtwp3O.mjs";
7
7
  import { n as isTerminalShellStatus, t as getShellSessionManager } from "./ShellSessionManager-6o8KZzl1-vrbPAUTq.mjs";
8
8
  import { d as detectRuntimes, m as modelBlobsOf } from "./dist-K7a9yOUb.mjs";
9
- import { A as serverRuntimeId, B as parseGenerationInput, Ct as withDefaultOllamaPort, F as GENERATION_FIELDS, H as parseModelContextSetting, I as LOCAL_OLLAMA_RUNTIME_ID, L as REASONING_EFFORT_SETTINGS, R as effortSent, S as desktopUserDataFile, V as parseLocalModelId, X as clean, a as needsCredential, f as serverFetch, i as loginHint, l as resolveServerTarget, m as unusableStatus, r as loadModelServers, y as SSH_PROBE_TIMEOUT_MS, z as localModelId } from "./modelServers-JsKBm7Wn.mjs";
9
+ import { A as serverRuntimeId, B as parseGenerationInput, Ct as withDefaultOllamaPort, F as GENERATION_FIELDS, H as parseModelContextSetting, I as LOCAL_OLLAMA_RUNTIME_ID, L as REASONING_EFFORT_SETTINGS, R as effortSent, S as desktopUserDataFile, V as parseLocalModelId, X as clean, a as needsCredential, f as serverFetch, i as loginHint, l as resolveServerTarget, m as unusableStatus, r as loadModelServers, y as SSH_PROBE_TIMEOUT_MS, z as localModelId } from "./modelServers-CjSlPFsg.mjs";
10
10
  import { createHash, randomBytes } from "crypto";
11
11
  import { existsSync, lstatSync, promises, readdirSync, realpathSync, rmSync, statSync } from "fs";
12
12
  import os, { homedir } from "os";
@@ -17,6 +17,7 @@ import { AsyncFzf } from "fzf";
17
17
  import ignore from "ignore";
18
18
  import fs, { mkdir, readFile, stat, writeFile } from "fs/promises";
19
19
  import { z as z$1 } from "zod";
20
+ import YAML from "yaml";
20
21
  import { isAxiosError } from "axios";
21
22
  import { execFile, spawn } from "child_process";
22
23
  import { promisify } from "util";
@@ -32,7 +33,6 @@ import sum from "lodash/sum.js";
32
33
  import times from "lodash/times.js";
33
34
  import * as Diff from "diff";
34
35
  import { diffLines } from "diff";
35
- import matter from "gray-matter";
36
36
  import { parse as parse$1 } from "shell-quote";
37
37
  import { EventEmitter } from "events";
38
38
  import { fileURLToPath } from "url";
@@ -3695,7 +3695,7 @@ async function isOperationalBillingEnabled(db, logger, holder) {
3695
3695
  return holder ? isFreeTierHolder(holder) : false;
3696
3696
  }
3697
3697
  //#endregion
3698
- //#region ../../b4m-core/services/dist/toolGenerators-Bh6zx8vU.mjs
3698
+ //#region ../../b4m-core/services/dist/toolGenerators-CkAakXQw.mjs
3699
3699
  const diceRoll = async (parameters) => {
3700
3700
  if (!parameters?.sides || !parameters?.times) throw new Error("Tool dice roll: Missing required parameters");
3701
3701
  return sum(times(parameters.times, () => random(1, parameters.sides))).toString();
@@ -4302,6 +4302,33 @@ const promptEnhancementTool = {
4302
4302
  }
4303
4303
  })
4304
4304
  };
4305
+ const OBJECT_ID_HEX = /^[0-9a-fA-F]{24}$/;
4306
+ /**
4307
+ * Is this value shaped like something Mongoose can cast to an `_id`?
4308
+ *
4309
+ * Tool arguments are composed by the model out of conversation text and reach us as unvalidated
4310
+ * JSON, so an id parameter routinely holds something that is not an id at all - a filename token,
4311
+ * an arXiv number, a bare integer. Mongoose casts `_id` and throws a CastError on those, which a
4312
+ * generic catch upstream then reports as an outage rather than the bad argument it is (#2530).
4313
+ * Call this before handing a model-supplied id to `findById` and answer a false the same way the
4314
+ * surface answers a genuinely missing row.
4315
+ *
4316
+ * `isObjectIdOrHexString`, not `isValidObjectId`: the latter also accepts a number and casts it to
4317
+ * a fabricated id, and a model emitting `{"file_id": 12}` gives us exactly that despite the
4318
+ * `string` type. Same choice, same reason, as `usableObjectIds` in @bike4mind/db-core, which is
4319
+ * the array-shaped version of this check.
4320
+ *
4321
+ * NOT usable for artifact ids (`artifact_<...>`), which are matched on a string `id` field rather
4322
+ * than `_id` - see `createArtifactId` in @bike4mind/common.
4323
+ *
4324
+ * A copy of Mongoose's `isObjectIdOrHexString` (an ObjectId instance, recognised by its
4325
+ * `_bsontype` tag, or a 24-hex string) rather than an import of it: this module is reached from
4326
+ * the CLI's tool registry, and importing mongoose there costs every CLI launch ~100-200 ms.
4327
+ */
4328
+ function isObjectIdShaped$1(id) {
4329
+ if (typeof id === "string") return OBJECT_ID_HEX.test(id);
4330
+ return typeof id === "object" && id !== null && id._bsontype === "ObjectId";
4331
+ }
4305
4332
  const DecisionToolRequestSchema = DecisionsRequestSchema.pick({
4306
4333
  input: true,
4307
4334
  questions: true,
@@ -4747,35 +4774,6 @@ const generateMcpToolsFromCache = (serverName, cachedTools, callTool) => {
4747
4774
  return result;
4748
4775
  };
4749
4776
  //#endregion
4750
- //#region ../../b4m-core/services/dist/objectId-Bhav0W6F.mjs
4751
- const OBJECT_ID_HEX = /^[0-9a-fA-F]{24}$/;
4752
- /**
4753
- * Is this value shaped like something Mongoose can cast to an `_id`?
4754
- *
4755
- * Tool arguments are composed by the model out of conversation text and reach us as unvalidated
4756
- * JSON, so an id parameter routinely holds something that is not an id at all - a filename token,
4757
- * an arXiv number, a bare integer. Mongoose casts `_id` and throws a CastError on those, which a
4758
- * generic catch upstream then reports as an outage rather than the bad argument it is (#2530).
4759
- * Call this before handing a model-supplied id to `findById` and answer a false the same way the
4760
- * surface answers a genuinely missing row.
4761
- *
4762
- * `isObjectIdOrHexString`, not `isValidObjectId`: the latter also accepts a number and casts it to
4763
- * a fabricated id, and a model emitting `{"file_id": 12}` gives us exactly that despite the
4764
- * `string` type. Same choice, same reason, as `usableObjectIds` in @bike4mind/db-core, which is
4765
- * the array-shaped version of this check.
4766
- *
4767
- * NOT usable for artifact ids (`artifact_<...>`), which are matched on a string `id` field rather
4768
- * than `_id` - see `createArtifactId` in @bike4mind/common.
4769
- *
4770
- * A copy of Mongoose's `isObjectIdOrHexString` (an ObjectId instance, recognised by its
4771
- * `_bsontype` tag, or a 24-hex string) rather than an import of it: this module is reached from
4772
- * the CLI's tool registry, and importing mongoose there costs every CLI launch ~100-200 ms.
4773
- */
4774
- function isObjectIdShaped(id) {
4775
- if (typeof id === "string") return OBJECT_ID_HEX.test(id);
4776
- return typeof id === "object" && id !== null && id._bsontype === "ObjectId";
4777
- }
4778
- //#endregion
4779
4777
  //#region ../../b4m-core/services/dist/llm/tools/cliTools.mjs
4780
4778
  /**
4781
4779
  * Validated fuzzy fallback for `edit_local_file` string matching.
@@ -6193,7 +6191,7 @@ const latticeAddEntityTool = {
6193
6191
  createdAt: /* @__PURE__ */ new Date(),
6194
6192
  updatedAt: /* @__PURE__ */ new Date()
6195
6193
  };
6196
- if (context.db.latticeModels && modelId && isObjectIdShaped(modelId)) try {
6194
+ if (context.db.latticeModels && modelId && isObjectIdShaped$1(modelId)) try {
6197
6195
  const model = await getModelForWrite({
6198
6196
  id: context.userId,
6199
6197
  organizationId: context.user?.organizationId
@@ -6338,7 +6336,7 @@ const latticeSetValueTool = {
6338
6336
  else if (rawValue.toLowerCase() === "true") value = true;
6339
6337
  else if (rawValue.toLowerCase() === "false") value = false;
6340
6338
  const entityId = toEntityId(entityName);
6341
- if (context.db.latticeModels && modelId && isObjectIdShaped(modelId)) try {
6339
+ if (context.db.latticeModels && modelId && isObjectIdShaped$1(modelId)) try {
6342
6340
  const model = await getModelForWrite({
6343
6341
  id: context.userId,
6344
6342
  organizationId: context.user?.organizationId
@@ -6484,7 +6482,7 @@ const latticeCreateRuleTool = {
6484
6482
  };
6485
6483
  const outputEntityId = parsedRule.outputEntity.toLowerCase().replace(/\s+/g, "_");
6486
6484
  let entityCreatedMessage = "";
6487
- if (context.db.latticeModels && modelId && isObjectIdShaped(modelId)) try {
6485
+ if (context.db.latticeModels && modelId && isObjectIdShaped$1(modelId)) try {
6488
6486
  const model = await getModelForWrite({
6489
6487
  id: context.userId,
6490
6488
  organizationId: context.user?.organizationId
@@ -7026,54 +7024,119 @@ async function processFileReferences(message, confineTo) {
7026
7024
  };
7027
7025
  }
7028
7026
  //#endregion
7029
- //#region src/utils/parseFrontmatter.ts
7027
+ //#region ../../b4m-core/common/dist/utils/frontmatter.mjs
7030
7028
  /**
7031
- * gray-matter selects its parse engine from the language tag on the opening
7032
- * fence (e.g. `---js`), and its built-in `javascript` engine `eval()`s the
7033
- * block - so a hostile SKILL.md/command/agent file can run code the moment it
7034
- * is loaded, before any Zod validation. This helper is the single guard both
7035
- * frontmatter call sites route through:
7036
- *
7037
- * 1. Reject any opening fence whose language tag is non-empty and not YAML.
7038
- * 2. Disable the eval-capable engines as defense in depth (gray-matter merges
7039
- * a custom `engines` map ON TOP of its built-ins, so the override, not the
7040
- * absence, is what neutralizes `javascript`).
7041
- *
7042
- * A rejected or malformed file degrades to empty frontmatter (with a warning),
7043
- * never an eval and never an uncaught throw.
7029
+ * YAML front matter for markdown files: CLI skills, commands and agents, and the help articles.
7030
+ * Splits the file the way gray-matter did, which those files were written against, and parses
7031
+ * with the eemeli `yaml` package, which has no eval-capable engines. Sits behind
7032
+ * `@bike4mind/common/utils/frontmatter` so the barrel does not pull in a YAML parser.
7044
7033
  */
7045
- /** Opening `---<lang>` fence: capture the language tag on the first line. */
7046
- const OPENING_FENCE = /^---([^\r\n]*)\r?\n/;
7047
- function nonYamlEngineDisabled() {
7048
- throw new Error("non-YAML frontmatter engine is disabled");
7034
+ var FrontmatterLanguageError = class extends Error {
7035
+ lang;
7036
+ constructor(lang) {
7037
+ super(`Unsupported front matter language "${lang}"; only YAML is supported.`);
7038
+ this.name = "FrontmatterLanguageError";
7039
+ this.lang = lang;
7040
+ }
7041
+ };
7042
+ const OPEN$1 = "---";
7043
+ const CLOSE$1 = "\n---";
7044
+ const INTEGER_PATTERN = /^[-+]?(?:0|0b[01_]*[01]|0x[\da-fA-F_]*[\da-fA-F]|0[0-7_]*[0-7]|[1-9](?:[\d_]*\d)?|[1-9][\d_]*(?::[0-5]?\d)+)$/;
7045
+ const FLOAT_PATTERN = /^(?!.*_$)(?:[-+]?(?:0|[1-9][\d_]*)(?:\.[\d_]*)?(?:[eE][-+]?\d+)?|\.[\d_]+(?:[eE][-+]?\d+)?|[-+]?\d[\d_]*(?::[0-5]?\d)+\.[\d_]*|[-+]?\.(?:inf|Inf|INF)|\.(?:nan|NaN|NAN))$/;
7046
+ function parseSafeNumber(source, integer) {
7047
+ const normalized = source.replaceAll("_", "").toLowerCase();
7048
+ const sign = normalized.startsWith("-") ? -1 : 1;
7049
+ const value = normalized.replace(/^[-+]/, "");
7050
+ if (integer && value === "0") return 0;
7051
+ if (value === ".inf") return sign * Infinity;
7052
+ if (value === ".nan") return NaN;
7053
+ if (value.includes(":")) {
7054
+ const parts = value.split(":");
7055
+ return sign * parts.reduceRight((total, part, index) => total + Number(part) * 60 ** (parts.length - index - 1), 0);
7056
+ }
7057
+ if (!integer) return sign * Number.parseFloat(value);
7058
+ if (value.startsWith("0b")) return sign * Number.parseInt(value.slice(2), 2);
7059
+ if (value.startsWith("0x")) return sign * Number.parseInt(value.slice(2), 16);
7060
+ return sign * Number.parseInt(value, value.startsWith("0") ? 8 : 10);
7061
+ }
7062
+ const safeIntegerTag = {
7063
+ tag: "tag:yaml.org,2002:int",
7064
+ default: true,
7065
+ test: INTEGER_PATTERN,
7066
+ resolve: (source) => parseSafeNumber(source, true)
7067
+ };
7068
+ const safeFloatTag = {
7069
+ tag: "tag:yaml.org,2002:float",
7070
+ default: true,
7071
+ test: FLOAT_PATTERN,
7072
+ resolve: (source) => parseSafeNumber(source, false)
7073
+ };
7074
+ /**
7075
+ * Splits a leading `---` fence off `text` and parses it as YAML. A file that does not open with
7076
+ * `---` has no front matter; a fence that is never closed makes the rest of the file front matter.
7077
+ * Throws FrontmatterLanguageError for a language tag other than yaml/yml on the opening fence, and
7078
+ * an Error for invalid YAML or front matter that is not a set of key: value pairs.
7079
+ */
7080
+ function parseFrontmatter$1(text) {
7081
+ if (text.charCodeAt(0) === 65279) text = text.slice(1);
7082
+ if (!text.startsWith(OPEN$1) || text.charAt(3) === "-") return {
7083
+ data: {},
7084
+ content: text
7085
+ };
7086
+ let rest = text.slice(3);
7087
+ const eol = rest.search(/\r?\n/);
7088
+ const lang = (eol === -1 ? rest : rest.slice(0, eol)).trim().toLowerCase();
7089
+ if (lang && lang !== "yaml" && lang !== "yml") throw new FrontmatterLanguageError(lang);
7090
+ rest = eol === -1 ? "" : rest.slice(eol);
7091
+ const close = rest.indexOf(CLOSE$1);
7092
+ const block = close === -1 ? rest : rest.slice(0, close).replace(/\r$/, "");
7093
+ let content = close === -1 ? "" : rest.slice(close + 4);
7094
+ if (content.startsWith("\r")) content = content.slice(1);
7095
+ if (content.startsWith("\n")) content = content.slice(1);
7096
+ if (block.replace(/^\s*#[^\n]+/gm, "").trim() === "") return {
7097
+ data: {},
7098
+ content
7099
+ };
7100
+ const document = YAML.parseDocument(block, {
7101
+ schema: "core",
7102
+ customTags: (tags) => [
7103
+ ...tags.filter((tag) => typeof tag === "string" || !["tag:yaml.org,2002:int", "tag:yaml.org,2002:float"].includes(tag.tag)),
7104
+ safeIntegerTag,
7105
+ safeFloatTag,
7106
+ "timestamp"
7107
+ ],
7108
+ merge: true,
7109
+ logLevel: "error"
7110
+ });
7111
+ const parseError = document.errors[0] ?? document.warnings.find((warning) => warning.code === "TAG_RESOLVE_FAILED");
7112
+ if (parseError) throw parseError;
7113
+ const data = document.toJS();
7114
+ if (data === null) return {
7115
+ data: {},
7116
+ content
7117
+ };
7118
+ if (Object.prototype.toString.call(data) !== "[object Object]") throw new Error("The front matter must be a set of key: value pairs.");
7119
+ return {
7120
+ data,
7121
+ content
7122
+ };
7049
7123
  }
7124
+ //#endregion
7125
+ //#region src/utils/parseFrontmatter.ts
7126
+ /**
7127
+ * Frontmatter for SKILL.md, command and agent files, which are untrusted input. Only YAML is read:
7128
+ * a `---js`-style fence is never evaluated, and it, like malformed YAML, degrades to empty
7129
+ * frontmatter with a warning rather than throwing.
7130
+ */
7050
7131
  function parseFrontmatter(content) {
7051
- if (content.charCodeAt(0) === 65279) content = content.slice(1);
7052
- const fence = content.match(OPENING_FENCE);
7053
- if (fence) {
7054
- const lang = fence[1].trim().toLowerCase();
7055
- if (lang && lang !== "yaml" && lang !== "yml") {
7056
- logger.warn(`Ignoring non-YAML frontmatter language "${lang}"; treating frontmatter as empty`);
7057
- return {
7058
- data: {},
7059
- content
7060
- };
7061
- }
7062
- }
7063
7132
  try {
7064
- const parsed = matter(content, { engines: {
7065
- javascript: nonYamlEngineDisabled,
7066
- coffee: nonYamlEngineDisabled
7067
- } });
7068
- return {
7069
- data: parsed.data,
7070
- content: parsed.content
7071
- };
7133
+ return parseFrontmatter$1(content);
7072
7134
  } catch (error) {
7073
- logger.warn(`Failed to parse frontmatter: ${error instanceof Error ? error.message : String(error)}`);
7135
+ if (error instanceof FrontmatterLanguageError) logger.warn(`Ignoring non-YAML frontmatter language "${error.lang}"; treating frontmatter as empty`);
7136
+ else logger.warn(`Failed to parse frontmatter: ${error instanceof Error ? error.message : String(error)}`);
7074
7137
  return {
7075
7138
  data: {},
7076
- content
7139
+ content: content.charCodeAt(0) === 65279 ? content.slice(1) : content
7077
7140
  };
7078
7141
  }
7079
7142
  }
@@ -19661,8 +19724,8 @@ async function buildSandbox(input) {
19661
19724
  const { config, sessionId, permissionManager, checkpointStore } = input;
19662
19725
  const log = input.log ?? consoleLog;
19663
19726
  const [{ createSandboxRuntime }, { SandboxOrchestrator }, { DEFAULT_SANDBOX_CONFIG }, { ProxyManager }, { ViolationLogStore }] = await Promise.all([
19664
- import("./SandboxRuntimeAdapter-CFEIywKt.mjs"),
19665
- import("./SandboxOrchestrator-CeDwd6Fj.mjs"),
19727
+ import("./SandboxRuntimeAdapter-X0HAkbpW.mjs"),
19728
+ import("./SandboxOrchestrator-DTz_5Zub.mjs"),
19666
19729
  import("./types-BFIvwByC.mjs"),
19667
19730
  import("./ProxyManager-TxEKlgdO.mjs"),
19668
19731
  import("./ViolationLogStore-byEhxa2A.mjs")
@@ -19951,6 +20014,24 @@ function buildMcpChildEnv({ serverName, envVariables, hasCustomCommand = false }
19951
20014
  droppedKeys
19952
20015
  };
19953
20016
  }
20017
+ function emit(level, scope, message, fields) {
20018
+ const redacted = fields ? redactLogValue(fields) : void 0;
20019
+ console[level](`[${scope}] ${redactLogText(message)}`, ...redacted ? [redacted] : []);
20020
+ }
20021
+ /**
20022
+ * Redacting logger for code that runs inside a host process (the CLI's Ink TUI, desktop main, servers),
20023
+ * as opposed to a stdio server. Redaction happens here in `emit`; writing through `console` lets the
20024
+ * host's console patching apply. debug/info are no-ops: host-side callers do not use them.
20025
+ */
20026
+ function createConsoleLogger(scope) {
20027
+ return {
20028
+ debug: () => {},
20029
+ info: () => {},
20030
+ warn: (message, fields) => emit("warn", scope, message, fields),
20031
+ error: (message, fields) => emit("error", scope, message, fields)
20032
+ };
20033
+ }
20034
+ const log = createConsoleLogger("mcp-client");
19954
20035
  const createSdkClient = () => new Client({
19955
20036
  name: "mcp-client-cli",
19956
20037
  version: "1.0.0"
@@ -20013,14 +20094,16 @@ var MCPClient = class {
20013
20094
  const serverScriptPath = path.join(moduleDir, this.serverName, "index.mjs");
20014
20095
  if (!existsSync(serverScriptPath)) {
20015
20096
  const availableFiles = readdirSync(moduleDir, { withFileTypes: true }).map((d) => d.isDirectory() ? `${d.name}/` : d.name);
20016
- console.error(`[MCP] Server script not found at: ${serverScriptPath}`);
20017
- console.error(`[MCP] Module directory: ${moduleDir}`);
20018
- console.error(`[MCP] Available in module dir:`, availableFiles);
20097
+ log.error("server script not found", {
20098
+ server: this.serverName,
20099
+ serverScriptPath,
20100
+ moduleDir,
20101
+ availableFiles
20102
+ });
20019
20103
  throw new Error(`MCP Server script not found for ${this.serverName} at ${serverScriptPath}. Module dir: ${moduleDir}`);
20020
20104
  }
20021
20105
  command = process.execPath;
20022
20106
  args = [serverScriptPath];
20023
- console.log(`[MCP] Using server: ${this.serverName} at ${serverScriptPath}`);
20024
20107
  }
20025
20108
  const stderrMode = this.suppressStderr ? "ignore" : this.onStderrLine ? "pipe" : void 0;
20026
20109
  const { env, droppedKeys } = buildMcpChildEnv({
@@ -20028,7 +20111,10 @@ var MCPClient = class {
20028
20111
  envVariables: this.envVariables,
20029
20112
  hasCustomCommand: Boolean(customCommand)
20030
20113
  });
20031
- if (droppedKeys.length > 0) console.warn(`[MCP] Withheld ${droppedKeys.length} undeclared env variable(s) from ${this.serverName}: ${droppedKeys.join(", ")}`);
20114
+ if (droppedKeys.length > 0) log.warn("withheld undeclared env variables from server", {
20115
+ server: this.serverName,
20116
+ droppedKeys
20117
+ });
20032
20118
  const transportConfig = {
20033
20119
  command,
20034
20120
  args,
@@ -20038,7 +20124,10 @@ var MCPClient = class {
20038
20124
  const stdioTransport = new StdioClientTransport(transportConfig);
20039
20125
  this.transport = stdioTransport;
20040
20126
  stdioTransport.onerror = (error) => {
20041
- console.error(`[MCP] Transport error for ${this.serverName}:`, error);
20127
+ log.error("transport error", {
20128
+ server: this.serverName,
20129
+ error
20130
+ });
20042
20131
  };
20043
20132
  if (this.onStderrLine && stdioTransport.stderr) this.readStderr(stdioTransport.stderr);
20044
20133
  await this.mcp.connect(stdioTransport);
@@ -20072,7 +20161,10 @@ var MCPClient = class {
20072
20161
  sessionExpired = true;
20073
20162
  return;
20074
20163
  }
20075
- console.error(`[MCP] Transport error for ${this.serverName}: ${error.message}`);
20164
+ log.error("transport error", {
20165
+ server: this.serverName,
20166
+ detail: error.message
20167
+ });
20076
20168
  };
20077
20169
  this.transport = transport;
20078
20170
  await client.connect(transport);
@@ -20206,7 +20298,10 @@ var MCPClient = class {
20206
20298
  }
20207
20299
  } catch (error) {
20208
20300
  if (error instanceof Error && (error.message.includes("Connection closed") || error.message.includes("-32000") || error.message.includes("EPIPE"))) {
20209
- console.error(`[MCP] Connection lost while calling tool ${toolName} on ${this.serverName}`);
20301
+ log.error("connection lost while calling tool", {
20302
+ server: this.serverName,
20303
+ toolName
20304
+ });
20210
20305
  throw new Error(`MCP connection lost for ${this.serverName}. Please retry the operation.`);
20211
20306
  }
20212
20307
  throw error;
@@ -20222,7 +20317,10 @@ var MCPClient = class {
20222
20317
  if (this.transport) await this.mcp.close();
20223
20318
  } catch (error) {
20224
20319
  if (!(error instanceof Error && (error.message.includes("Connection closed") || error.message.includes("-32000") || error.message.includes("EPIPE") || error.message.includes("ECONNRESET")))) {
20225
- console.error("Error during MCP disconnect:", error);
20320
+ log.error("error during disconnect", {
20321
+ server: this.serverName,
20322
+ error
20323
+ });
20226
20324
  throw error;
20227
20325
  }
20228
20326
  } finally {
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { b as AuthenticatedApiClient, t as ConfigStore, x as DeviceFlowClient } from "./ConfigStore-B2Dy-PT9.mjs";
3
- import { t as logger } from "./Logger-7MmrU5w6.mjs";
4
- import { t as version } from "./package-r_xumsGY.mjs";
2
+ import { b as AuthenticatedApiClient, t as ConfigStore, x as DeviceFlowClient } from "./ConfigStore-nr0ebq4v.mjs";
3
+ import { t as logger } from "./Logger-CovZt7LL.mjs";
4
+ import { t as version } from "./package-BTvxFRbB.mjs";
5
5
  import { isAxiosError } from "axios";
6
6
  import { Readable } from "node:stream";
7
7
  //#region src/auth/OAuthClient.ts
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { t as logger } from "./Logger-7MmrU5w6.mjs";
3
- import { a as getContainerSocketPaths, c as resolveSandboxPath, o as getProtectedWorkspacePaths, s as isBinaryAvailable, t as assertProxyPort } from "./SandboxRuntimeAdapter-CjNDzYSf.mjs";
2
+ import { t as logger } from "./Logger-CovZt7LL.mjs";
3
+ import { a as getContainerSocketPaths, c as resolveSandboxPath, o as getProtectedWorkspacePaths, s as isBinaryAvailable, t as assertProxyPort } from "./SandboxRuntimeAdapter-CC5KlbZ8.mjs";
4
4
  import { lstatSync, mkdirSync, statSync } from "fs";
5
5
  import os from "os";
6
6
  import path from "path";
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export { t as ConfigStore } from "./ConfigStore-nr0ebq4v.mjs";
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { T as ChatModels, t as logger } from "./Logger-7MmrU5w6.mjs";
2
+ import { T as ChatModels, t as logger } from "./Logger-CovZt7LL.mjs";
3
3
  import { t as DEFAULT_SANDBOX_CONFIG } from "./types-CxrzVXel.mjs";
4
4
  import { isDeepStrictEqual } from "node:util";
5
5
  import { existsSync, promises } from "fs";