@topolo/cli 0.9.8 → 0.9.9

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 (2) hide show
  1. package/dist/index.js +125 -13
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import { platform as platform2 } from "os";
9
9
  import { createInterface } from "readline/promises";
10
10
  import { stdin as input } from "process";
11
11
 
12
- // node_modules/@topolo/sdk/dist/index.js
12
+ // ../../../../../TopoloWork2/.worktrees/cli-postinstall-message/packages/topolo-cli/node_modules/@topolo/sdk/dist/index.js
13
13
  function applyAuthHeaders(headers, credential) {
14
14
  if (credential.kind === "api_key") {
15
15
  headers.set("X-Api-Key", credential.apiKey);
@@ -2948,7 +2948,7 @@ function createTopolo(options) {
2948
2948
  };
2949
2949
  }
2950
2950
 
2951
- // node_modules/@topolo/sdk/dist/node/credential-store.js
2951
+ // ../../../../../TopoloWork2/.worktrees/cli-postinstall-message/packages/topolo-cli/node_modules/@topolo/sdk/dist/node/credential-store.js
2952
2952
  import { mkdir, readFile, writeFile, chmod, rm, stat } from "fs/promises";
2953
2953
  import { existsSync } from "fs";
2954
2954
  import { homedir, platform } from "os";
@@ -5107,8 +5107,20 @@ async function readCodexRegistrations(homeDir) {
5107
5107
  if (!existsSync2(path)) return [];
5108
5108
  const registrations = /* @__PURE__ */ new Map();
5109
5109
  let section;
5110
+ let pending;
5110
5111
  for (const rawLine of (await readFile3(path, "utf8")).split(/\r?\n/)) {
5111
- const line = rawLine.trim();
5112
+ const line = stripTomlComment(rawLine).trim();
5113
+ if (pending) {
5114
+ if (line.startsWith("[")) {
5115
+ throw new Error(`Cannot read unsupported MCP value in Codex configuration at ${path}.`);
5116
+ }
5117
+ pending.value = `${pending.value} ${line}`;
5118
+ if (isTomlValueComplete(pending.value)) {
5119
+ applyCodexAssignment(path, section, pending, registrations);
5120
+ pending = void 0;
5121
+ }
5122
+ continue;
5123
+ }
5112
5124
  const heading = line.match(/^\[mcp_servers\.([A-Za-z0-9_-]+)(\.env)?\]$/);
5113
5125
  if (heading) {
5114
5126
  section = { name: heading[1], env: Boolean(heading[2]) };
@@ -5124,20 +5136,120 @@ async function readCodexRegistrations(homeDir) {
5124
5136
  if (!section || !isPublicRegistrationName(section.name) || !line || line.startsWith("#")) continue;
5125
5137
  const assignment = line.match(/^([A-Za-z0-9_]+)\s*=\s*(.+)$/);
5126
5138
  if (!assignment) continue;
5127
- const registration = registrations.get(section.name);
5128
- try {
5129
- const value = JSON.parse(assignment[2]);
5130
- if (section.env && typeof value === "string") registration.env[assignment[1]] = value;
5131
- if (!section.env && assignment[1] === "command" && typeof value === "string") registration.command = value;
5132
- if (!section.env && assignment[1] === "args" && Array.isArray(value) && value.every((item) => typeof item === "string")) {
5133
- registration.args = value;
5134
- }
5135
- } catch {
5136
- throw new Error(`Cannot read unsupported MCP value in Codex configuration at ${path}.`);
5139
+ if (!section.env && assignment[1] !== "command" && assignment[1] !== "args") continue;
5140
+ pending = { key: assignment[1], value: assignment[2] };
5141
+ if (isTomlValueComplete(pending.value)) {
5142
+ applyCodexAssignment(path, section, pending, registrations);
5143
+ pending = void 0;
5137
5144
  }
5138
5145
  }
5146
+ if (pending) throw new Error(`Cannot read unsupported MCP value in Codex configuration at ${path}.`);
5139
5147
  return [...registrations.values()].filter((registration) => registration.command);
5140
5148
  }
5149
+ function applyCodexAssignment(path, section, assignment, registrations) {
5150
+ const registration = registrations.get(section.name);
5151
+ let value;
5152
+ try {
5153
+ value = parseTomlValue(assignment.value);
5154
+ } catch {
5155
+ throw new Error(`Cannot read unsupported MCP value in Codex configuration at ${path}.`);
5156
+ }
5157
+ if (section.env && typeof value === "string") registration.env[assignment.key] = value;
5158
+ if (!section.env && assignment.key === "command" && typeof value === "string") registration.command = value;
5159
+ if (!section.env && assignment.key === "args" && Array.isArray(value) && value.every((item) => typeof item === "string")) {
5160
+ registration.args = value;
5161
+ }
5162
+ }
5163
+ function stripTomlComment(line) {
5164
+ let quote;
5165
+ let escaped = false;
5166
+ for (let index = 0; index < line.length; index += 1) {
5167
+ const character = line[index];
5168
+ if (quote === '"') {
5169
+ if (escaped) escaped = false;
5170
+ else if (character === "\\") escaped = true;
5171
+ else if (character === '"') quote = void 0;
5172
+ continue;
5173
+ }
5174
+ if (quote === "'") {
5175
+ if (character === "'" && line[index + 1] === "'") index += 1;
5176
+ else if (character === "'") quote = void 0;
5177
+ continue;
5178
+ }
5179
+ if (character === '"' || character === "'") quote = character;
5180
+ else if (character === "#") return line.slice(0, index);
5181
+ }
5182
+ return line;
5183
+ }
5184
+ function isTomlValueComplete(value) {
5185
+ let quote;
5186
+ let escaped = false;
5187
+ let arrayDepth = 0;
5188
+ for (let index = 0; index < value.length; index += 1) {
5189
+ const character = value[index];
5190
+ if (quote === '"') {
5191
+ if (escaped) escaped = false;
5192
+ else if (character === "\\") escaped = true;
5193
+ else if (character === '"') quote = void 0;
5194
+ continue;
5195
+ }
5196
+ if (quote === "'") {
5197
+ if (character === "'" && value[index + 1] === "'") index += 1;
5198
+ else if (character === "'") quote = void 0;
5199
+ continue;
5200
+ }
5201
+ if (character === '"' || character === "'") quote = character;
5202
+ else if (character === "[") arrayDepth += 1;
5203
+ else if (character === "]") arrayDepth -= 1;
5204
+ }
5205
+ return !quote && arrayDepth === 0;
5206
+ }
5207
+ function parseTomlValue(rawValue) {
5208
+ const value = rawValue.trim();
5209
+ try {
5210
+ return JSON.parse(value);
5211
+ } catch {
5212
+ }
5213
+ if (value.startsWith("'") && value.endsWith("'")) return value.slice(1, -1).replace(/''/g, "'");
5214
+ if (value.startsWith("[") && value.endsWith("]")) {
5215
+ const body = value.slice(1, -1).trim();
5216
+ if (!body) return [];
5217
+ return splitTomlArray(body).map((item) => parseTomlValue(item));
5218
+ }
5219
+ throw new Error("Unsupported TOML value");
5220
+ }
5221
+ function splitTomlArray(value) {
5222
+ const items = [];
5223
+ let start = 0;
5224
+ let quote;
5225
+ let escaped = false;
5226
+ let arrayDepth = 0;
5227
+ for (let index = 0; index < value.length; index += 1) {
5228
+ const character = value[index];
5229
+ if (quote === '"') {
5230
+ if (escaped) escaped = false;
5231
+ else if (character === "\\") escaped = true;
5232
+ else if (character === '"') quote = void 0;
5233
+ continue;
5234
+ }
5235
+ if (quote === "'") {
5236
+ if (character === "'" && value[index + 1] === "'") index += 1;
5237
+ else if (character === "'") quote = void 0;
5238
+ continue;
5239
+ }
5240
+ if (character === '"' || character === "'") quote = character;
5241
+ else if (character === "[") arrayDepth += 1;
5242
+ else if (character === "]") arrayDepth -= 1;
5243
+ else if (character === "," && arrayDepth === 0) {
5244
+ const item = value.slice(start, index).trim();
5245
+ if (item) items.push(item);
5246
+ start = index + 1;
5247
+ }
5248
+ }
5249
+ const last = value.slice(start).trim();
5250
+ if (last) items.push(last);
5251
+ return items;
5252
+ }
5141
5253
  function normalizeRegistration(name, value) {
5142
5254
  if (!value || typeof value !== "object" || Array.isArray(value)) return [];
5143
5255
  const candidate = value;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@topolo/cli",
3
- "version": "0.9.8",
4
- "topoloPublishedVersion": "0.9.8",
3
+ "version": "0.9.9",
4
+ "topoloPublishedVersion": "0.9.9",
5
5
  "description": "Public command-line interface for Topolo customer organizations, developers, and agents.",
6
6
  "license": "UNLICENSED",
7
7
  "author": "Topolo",