@cmmd-center/forge 0.13.125 → 0.13.127

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 (38) hide show
  1. package/dist/bin.cjs +138 -41
  2. package/dist/bin.mjs +162 -65
  3. package/dist/client/assets/{CanvasPanel-BOh2xUZv.js → CanvasPanel-Db1Iz4JN.js} +2 -2
  4. package/dist/client/assets/CompositeItem-BxPZ_9BJ.js +2 -0
  5. package/dist/client/assets/DiffPanel-CqRZidQp.js +64 -0
  6. package/dist/client/assets/{DiffPanel.logic-DS1mmUZB.js → DiffPanel.logic-D4K70r-U.js} +2 -2
  7. package/dist/client/assets/{DiffWorkerPoolProvider-C2tnM5gq.js → DiffWorkerPoolProvider-BHmRAZ9V.js} +11 -11
  8. package/dist/client/assets/PullRequestCodePanel-Bfws9NZf.js +5 -0
  9. package/dist/client/assets/{ThemeEditorPanel-v2mnY18G.js → ThemeEditorPanel-DTfrlPBc.js} +2 -2
  10. package/dist/client/assets/{Virtualizer-Ds5-GzY3.js → Virtualizer-BaK0M9lw.js} +2 -2
  11. package/dist/client/assets/WorkerPoolContext-CD9L3Rin.js +1533 -0
  12. package/dist/client/assets/{canvasStateStore-xaZAenqH.js → canvasStateStore-DKtQcBVc.js} +2 -2
  13. package/dist/client/assets/cmmdForgeRuntimeListResource-lbV63vQg.js +1008 -0
  14. package/dist/client/assets/currentForgeWorkspaceStore-Cukj-AKS.js +2 -0
  15. package/dist/client/assets/index-CFdawhcA.js +169 -0
  16. package/dist/client/assets/popover-Cvb1Axgx.js +2 -0
  17. package/dist/client/assets/scroll-area-DzReJmNn.js +2 -0
  18. package/dist/client/assets/switch-RuRK1onH.js +2 -0
  19. package/dist/client/assets/{themePalette-eOA8OvYM.js → themePalette-gr6ZYaOx.js} +2 -2
  20. package/dist/client/assets/toggle-D8xaJAgP.js +2 -0
  21. package/dist/client/assets/toggle-group-CwSbXP07.js +2 -0
  22. package/dist/client/assets/useOpenInteractionType-B983ff5H.js +2 -0
  23. package/dist/client/assets/utils-B4G-Q0s7.js +2 -0
  24. package/dist/client/index.html +16 -13
  25. package/dist/forge-build.json +1 -1
  26. package/dist/{open-yHTUkd2Y.mjs → open-2-reBrpv.mjs} +3 -3
  27. package/package.json +1 -1
  28. package/dist/client/assets/CompositeItem-DNVaubQt.js +0 -2
  29. package/dist/client/assets/DiffPanel-BM-qanPT.js +0 -64
  30. package/dist/client/assets/PullRequestCodePanel-zxkVGUeq.js +0 -5
  31. package/dist/client/assets/WorkerPoolContext-BWuPUnhX.js +0 -2538
  32. package/dist/client/assets/index-Rx6Z6FPS.js +0 -169
  33. package/dist/client/assets/popover-Cxnw5kve.js +0 -2
  34. package/dist/client/assets/scroll-area-DDcW71H4.js +0 -2
  35. package/dist/client/assets/switch-Wi-2Dkh9.js +0 -2
  36. package/dist/client/assets/toggle-group-Cqh7gA8I.js +0 -2
  37. package/dist/client/assets/toggle-m8ncTpRB.js +0 -2
  38. package/dist/client/assets/useOpenInteractionType-CN3hnnfp.js +0 -2
package/dist/bin.mjs CHANGED
@@ -23,7 +23,7 @@ import { createCipheriv, createDecipheriv, createHash, createHmac, createPublicK
23
23
  import * as FS$1 from "node:fs";
24
24
  import fs, { accessSync, chmodSync, constants, createReadStream, existsSync, mkdirSync, mkdtempSync, promises, readFile, readFileSync, readdir, readdirSync, realpathSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
25
25
  import * as NodeOS from "node:os";
26
- import os, { homedir, networkInterfaces, tmpdir } from "node:os";
26
+ import $U, { homedir, networkInterfaces, tmpdir } from "node:os";
27
27
  import * as Path$1 from "node:path";
28
28
  import path, { basename, delimiter, dirname, extname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
29
29
  import { pathToFileURL } from "node:url";
@@ -50658,7 +50658,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
50658
50658
  const min = forceColor || 0;
50659
50659
  if (env.TERM === "dumb") return min;
50660
50660
  if (process$1.platform === "win32") {
50661
- const osRelease = os.release().split(".");
50661
+ const osRelease = $U.release().split(".");
50662
50662
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
50663
50663
  return 1;
50664
50664
  }
@@ -53101,7 +53101,7 @@ var require_ProcessDetector = /* @__PURE__ */ __commonJSMin(((exports) => {
53101
53101
  exports.processDetector = void 0;
53102
53102
  const api_1 = (init_esm$1(), __toCommonJS(esm_exports$1));
53103
53103
  const semconv_1 = require_semconv$1();
53104
- const os$4 = __require("os");
53104
+ const os$3 = __require("os");
53105
53105
  /**
53106
53106
  * ProcessDetector will be used to detect the resources related current process running
53107
53107
  * and being instrumented from the NodeJS Process module.
@@ -53123,7 +53123,7 @@ var require_ProcessDetector = /* @__PURE__ */ __commonJSMin(((exports) => {
53123
53123
  };
53124
53124
  if (process.argv.length > 1) attributes[semconv_1.ATTR_PROCESS_COMMAND] = process.argv[1];
53125
53125
  try {
53126
- const userInfo = os$4.userInfo();
53126
+ const userInfo = os$3.userInfo();
53127
53127
  attributes[semconv_1.ATTR_PROCESS_OWNER] = userInfo.username;
53128
53128
  } catch (e) {
53129
53129
  api_1.diag.debug(`error obtaining process owner: ${e}`);
@@ -66046,7 +66046,7 @@ function normalizeNumberish(value) {
66046
66046
  }
66047
66047
  //#endregion
66048
66048
  //#region package.json
66049
- var version$1 = "0.13.125";
66049
+ var version$1 = "0.13.127";
66050
66050
  //#endregion
66051
66051
  //#region src/sentry.ts
66052
66052
  const SERVER_APP_NAME = "forge-server";
@@ -72318,20 +72318,25 @@ const legacyCmmdToolBridge = {
72318
72318
  };
72319
72319
  //#endregion
72320
72320
  //#region src/command/workIntakeCache.ts
72321
- const cacheBySessionId = /* @__PURE__ */ new Map();
72321
+ const cacheByKey = /* @__PURE__ */ new Map();
72322
+ function cacheKeyFor(sessionId, orgId) {
72323
+ return `${sessionId}\u0000${orgId ?? ""}`;
72324
+ }
72322
72325
  function resolveCmmdWorkIntakeCacheIdentity(subject, cmmdUserId) {
72323
72326
  return cmmdUserId ? `cmmd-user:${cmmdUserId}` : `forge-subject:${subject}`;
72324
72327
  }
72325
72328
  function fingerprintToken(token) {
72326
72329
  return createHash("sha256").update(token).digest("hex");
72327
72330
  }
72328
- async function fetchBlockingSnapshot(input, identityKey, tokenFingerprint, existing) {
72331
+ async function fetchBlockingSnapshot(input, cacheKey, identityKey, tokenFingerprint, existing) {
72329
72332
  if (existing?.inFlight) return existing.inFlight;
72330
72333
  const nowMs = input.nowMs ?? Date.now;
72331
72334
  let promise;
72332
72335
  promise = input.fetchFresh().then((snapshot) => {
72333
- const current = cacheBySessionId.get(input.sessionId);
72334
- if (current?.tokenFingerprint === tokenFingerprint && current.inFlight === promise) cacheBySessionId.set(input.sessionId, {
72336
+ const current = cacheByKey.get(cacheKey);
72337
+ if (current?.tokenFingerprint === tokenFingerprint && current.inFlight === promise) cacheByKey.set(cacheKey, {
72338
+ sessionId: input.sessionId,
72339
+ orgId: input.orgId,
72335
72340
  identityKey,
72336
72341
  tokenFingerprint,
72337
72342
  snapshot,
@@ -72340,12 +72345,14 @@ async function fetchBlockingSnapshot(input, identityKey, tokenFingerprint, exist
72340
72345
  });
72341
72346
  return snapshot;
72342
72347
  }).catch((error) => {
72343
- const current = cacheBySessionId.get(input.sessionId);
72344
- if (current?.tokenFingerprint === tokenFingerprint && current.inFlight === promise) if (legacyCmmdToolBridge.isAuthError(error)) cacheBySessionId.delete(input.sessionId);
72348
+ const current = cacheByKey.get(cacheKey);
72349
+ if (current?.tokenFingerprint === tokenFingerprint && current.inFlight === promise) if (legacyCmmdToolBridge.isAuthError(error)) cacheByKey.delete(cacheKey);
72345
72350
  else current.inFlight = null;
72346
72351
  throw error;
72347
72352
  });
72348
- cacheBySessionId.set(input.sessionId, {
72353
+ cacheByKey.set(cacheKey, {
72354
+ sessionId: input.sessionId,
72355
+ orgId: input.orgId,
72349
72356
  identityKey,
72350
72357
  tokenFingerprint,
72351
72358
  snapshot: existing?.snapshot ?? null,
@@ -72361,9 +72368,9 @@ async function fetchBlockingSnapshot(input, identityKey, tokenFingerprint, exist
72361
72368
  * opportunistically on every read.
72362
72369
  */
72363
72370
  function sweepExpiredWorkIntakeEntries(nowMs) {
72364
- for (const [sessionId, entry] of cacheBySessionId) {
72371
+ for (const [key, entry] of cacheByKey) {
72365
72372
  if (entry.inFlight) continue;
72366
- if (nowMs - entry.cachedAtMs > 3e5) cacheBySessionId.delete(sessionId);
72373
+ if (nowMs - entry.cachedAtMs > 3e5) cacheByKey.delete(key);
72367
72374
  }
72368
72375
  }
72369
72376
  async function readCachedCmmdWorkIntakeForSession(input) {
@@ -72372,17 +72379,18 @@ async function readCachedCmmdWorkIntakeForSession(input) {
72372
72379
  const identityKey = input.identityKey ?? input.sessionId;
72373
72380
  if (input.forceFresh) invalidateCachedCmmdWorkIntakeForIdentity(identityKey);
72374
72381
  const tokenFingerprint = fingerprintToken(input.token);
72375
- const existing = cacheBySessionId.get(input.sessionId);
72376
- if (existing && (existing.identityKey !== identityKey || existing.tokenFingerprint !== tokenFingerprint)) cacheBySessionId.delete(input.sessionId);
72377
- const current = cacheBySessionId.get(input.sessionId);
72378
- if (!current?.snapshot) return fetchBlockingSnapshot(input, identityKey, tokenFingerprint, current);
72382
+ const cacheKey = cacheKeyFor(input.sessionId, input.orgId);
72383
+ const existing = cacheByKey.get(cacheKey);
72384
+ if (existing && (existing.identityKey !== identityKey || existing.tokenFingerprint !== tokenFingerprint)) cacheByKey.delete(cacheKey);
72385
+ const current = cacheByKey.get(cacheKey);
72386
+ if (!current?.snapshot) return fetchBlockingSnapshot(input, cacheKey, identityKey, tokenFingerprint, current);
72379
72387
  const ageMs = Math.max(0, nowMs() - current.cachedAtMs);
72380
72388
  if (ageMs <= 12e4) return current.snapshot;
72381
72389
  if (ageMs <= 3e5) {
72382
72390
  if (!current.inFlight) {
72383
72391
  let refreshPromise;
72384
72392
  refreshPromise = input.fetchFresh().then((snapshot) => {
72385
- const latest = cacheBySessionId.get(input.sessionId);
72393
+ const latest = cacheByKey.get(cacheKey);
72386
72394
  if (latest?.tokenFingerprint === tokenFingerprint && latest.inFlight === refreshPromise) {
72387
72395
  latest.snapshot = snapshot;
72388
72396
  latest.cachedAtMs = nowMs();
@@ -72390,25 +72398,25 @@ async function readCachedCmmdWorkIntakeForSession(input) {
72390
72398
  return snapshot;
72391
72399
  }).catch((error) => {
72392
72400
  if (legacyCmmdToolBridge.isAuthError(error)) {
72393
- const latest = cacheBySessionId.get(input.sessionId);
72394
- if (latest?.tokenFingerprint === tokenFingerprint && latest.inFlight === refreshPromise) cacheBySessionId.delete(input.sessionId);
72401
+ const latest = cacheByKey.get(cacheKey);
72402
+ if (latest?.tokenFingerprint === tokenFingerprint && latest.inFlight === refreshPromise) cacheByKey.delete(cacheKey);
72395
72403
  }
72396
72404
  return current.snapshot;
72397
72405
  }).finally(() => {
72398
- const latest = cacheBySessionId.get(input.sessionId);
72406
+ const latest = cacheByKey.get(cacheKey);
72399
72407
  if (latest?.tokenFingerprint === tokenFingerprint && latest.inFlight === refreshPromise) latest.inFlight = null;
72400
72408
  });
72401
72409
  current.inFlight = refreshPromise;
72402
72410
  }
72403
72411
  return current.snapshot;
72404
72412
  }
72405
- return fetchBlockingSnapshot(input, identityKey, tokenFingerprint, current);
72413
+ return fetchBlockingSnapshot(input, cacheKey, identityKey, tokenFingerprint, current);
72406
72414
  }
72407
72415
  function invalidateCachedCmmdWorkIntakeForSession(sessionId) {
72408
- cacheBySessionId.delete(sessionId);
72416
+ for (const [key, entry] of cacheByKey) if (entry.sessionId === sessionId) cacheByKey.delete(key);
72409
72417
  }
72410
72418
  function invalidateCachedCmmdWorkIntakeForIdentity(identityKey) {
72411
- for (const [sessionId, entry] of cacheBySessionId) if (entry.identityKey === identityKey) cacheBySessionId.delete(sessionId);
72419
+ for (const [key, entry] of cacheByKey) if (entry.identityKey === identityKey) cacheByKey.delete(key);
72412
72420
  }
72413
72421
  //#endregion
72414
72422
  //#region src/cmmdData/proxyRouteRegistry.ts
@@ -76281,7 +76289,7 @@ var require_node_gyp_build = /* @__PURE__ */ __commonJSMin(((exports, module) =>
76281
76289
  var fs$6 = __require("fs");
76282
76290
  var path$5 = __require("path");
76283
76291
  var url$1 = __require("url");
76284
- var os$3 = __require("os");
76292
+ var os$2 = __require("os");
76285
76293
  var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
76286
76294
  var vars = process.config && process.config.variables || {};
76287
76295
  var prebuildsOnly = !!process.env.PREBUILDS_ONLY;
@@ -76289,8 +76297,8 @@ var require_node_gyp_build = /* @__PURE__ */ __commonJSMin(((exports, module) =>
76289
76297
  var abi = versions.modules;
76290
76298
  if (versions.deno || process.isBun) abi = "unsupported";
76291
76299
  var runtime = isElectron() ? "electron" : isNwjs() ? "node-webkit" : "node";
76292
- var arch = process.env.npm_config_arch || os$3.arch();
76293
- var platform = process.env.npm_config_platform || os$3.platform();
76300
+ var arch = process.env.npm_config_arch || os$2.arch();
76301
+ var platform = process.env.npm_config_platform || os$2.platform();
76294
76302
  var libc = process.env.LIBC || (isMusl(platform) ? "musl" : "glibc");
76295
76303
  var armv = process.env.ARM_VERSION || (arch === "arm64" ? "8" : vars.arm_version) || "";
76296
76304
  var uv = (versions.uv || "").split(".")[0];
@@ -94134,7 +94142,7 @@ const launchDetached = (launch) => gen(function* () {
94134
94142
  });
94135
94143
  const OpenLive = effect(Open, gen(function* () {
94136
94144
  const open = yield* tryPromise({
94137
- try: () => import("./open-yHTUkd2Y.mjs"),
94145
+ try: () => import("./open-2-reBrpv.mjs"),
94138
94146
  catch: (cause) => new OpenError$1({
94139
94147
  message: "failed to load browser opener",
94140
94148
  cause
@@ -104835,6 +104843,29 @@ function warn$1(label, cause) {
104835
104843
  return `${label} fetch failed: ${cause instanceof Error ? cause.message : String(cause)}`;
104836
104844
  }
104837
104845
  /**
104846
+ * Reads the workspace catalog off a settled bootstrap call. No explicit org
104847
+ * means CMMD answered `activeWorkspace` with its own default-organization
104848
+ * guess, not a confirmed fact -- leave it null rather than publish it
104849
+ * (forge#3636).
104850
+ */
104851
+ function resolveWorkspacesFromBootstrap(bootstrapResult, orgId, warnings) {
104852
+ if (bootstrapResult.status !== "fulfilled") {
104853
+ warnings.push(warn$1("Workspaces (bootstrap)", bootstrapResult.reason));
104854
+ return {
104855
+ workspaces: [],
104856
+ activeWorkspace: null
104857
+ };
104858
+ }
104859
+ const bootstrap = unwrapRestObject(bootstrapResult.value);
104860
+ const rawWorkspaces = bootstrap?.["workspaces"];
104861
+ const workspaces = Array.isArray(rawWorkspaces) ? rawWorkspaces.map(adaptBootstrapWorkspace) : [];
104862
+ const rawActive = orgId !== void 0 ? bootstrap?.["activeWorkspace"] : void 0;
104863
+ return {
104864
+ workspaces,
104865
+ activeWorkspace: rawActive && typeof rawActive === "object" ? adaptBootstrapWorkspace(rawActive) : null
104866
+ };
104867
+ }
104868
+ /**
104838
104869
  * Build the CMMD work-intake snapshot via the JWT REST API:
104839
104870
  * bootstrap (workspaces) + campaigns + projects + center-board (tasks WITH deps).
104840
104871
  * `identity` is supplied by the session (resolved at login), matching the MCP builder.
@@ -104842,21 +104873,13 @@ function warn$1(label, cause) {
104842
104873
  async function fetchCmmdWorkIntakeViaRest(jwt, identity, deps = {}) {
104843
104874
  const get = deps.proxyGet ?? proxyGet;
104844
104875
  const [bootstrapResult, campaignsResult, projectsResult, boardResult] = await Promise.allSettled([
104845
- get(jwt, "/api/forge/context/bootstrap"),
104876
+ get(jwt, "/api/forge/context/bootstrap", void 0, deps.orgId),
104846
104877
  get(jwt, "/api/forge/context/campaigns"),
104847
104878
  fetchAllProjects(get, jwt),
104848
104879
  get(jwt, "/api/forge/context/work-items/board")
104849
104880
  ]);
104850
104881
  const warnings = [];
104851
- let workspaces = [];
104852
- let activeWorkspace = null;
104853
- if (bootstrapResult.status === "fulfilled") {
104854
- const bootstrap = unwrapRestObject(bootstrapResult.value);
104855
- const rawWorkspaces = bootstrap?.["workspaces"];
104856
- if (Array.isArray(rawWorkspaces)) workspaces = rawWorkspaces.map(adaptBootstrapWorkspace);
104857
- const rawActive = bootstrap?.["activeWorkspace"];
104858
- if (rawActive && typeof rawActive === "object") activeWorkspace = adaptBootstrapWorkspace(rawActive);
104859
- } else warnings.push(warn$1("Workspaces (bootstrap)", bootstrapResult.reason));
104882
+ const { workspaces, activeWorkspace } = resolveWorkspacesFromBootstrap(bootstrapResult, deps.orgId, warnings);
104860
104883
  if (projectsResult.status === "rejected") throw projectsResult.reason;
104861
104884
  if (campaignsResult.status === "rejected") warnings.push(warn$1("Campaigns", campaignsResult.reason));
104862
104885
  if (boardResult.status === "rejected") warnings.push(warn$1("Tasks (board)", boardResult.reason));
@@ -192420,7 +192443,7 @@ var Vce = {
192420
192443
  function Ve() {
192421
192444
  return Vce;
192422
192445
  }
192423
- var Us = os.homedir(), lk = os.tmpdir(), { env: Vc } = process$1, Yce = (e) => {
192446
+ var Us = $U.homedir(), lk = $U.tmpdir(), { env: Vc } = process$1, Yce = (e) => {
192424
192447
  let t = path.join(Us, "Library");
192425
192448
  return {
192426
192449
  data: path.join(t, "Application Support", e),
@@ -202620,12 +202643,12 @@ function qZ(e, t) {
202620
202643
  }
202621
202644
  return n;
202622
202645
  }
202623
- var os$2 = "https://code.claude.com/docs/en", kKe = [
202646
+ var os$1 = "https://code.claude.com/docs/en", kKe = [
202624
202647
  {
202625
202648
  matches: (e) => e.path === "permissions.defaultMode" && e.code === "invalid_value",
202626
202649
  tip: {
202627
202650
  suggestion: "Valid modes: \"acceptEdits\" (ask before file changes), \"plan\" (analysis only), \"bypassPermissions\" (auto-accept all), or \"default\" (standard behavior)",
202628
- docLink: `${os$2}/iam#permission-modes`
202651
+ docLink: `${os$1}/iam#permission-modes`
202629
202652
  }
202630
202653
  },
202631
202654
  {
@@ -202640,7 +202663,7 @@ var os$2 = "https://code.claude.com/docs/en", kKe = [
202640
202663
  matches: (e) => e.path.startsWith("env.") && e.code === "invalid_type",
202641
202664
  tip: {
202642
202665
  suggestion: "Environment variables must be strings. Wrap numbers and booleans in quotes. Example: \"DEBUG\": \"true\", \"PORT\": \"3000\"",
202643
- docLink: `${os$2}/settings#environment-variables`
202666
+ docLink: `${os$1}/settings#environment-variables`
202644
202667
  }
202645
202668
  },
202646
202669
  {
@@ -202651,14 +202674,14 @@ var os$2 = "https://code.claude.com/docs/en", kKe = [
202651
202674
  matches: (e) => e.path.startsWith("hooks.") && e.code === "invalid_key",
202652
202675
  tip: {
202653
202676
  suggestion: "Not a recognized hook event. Common events: PreToolUse, PostToolUse, UserPromptSubmit, SessionStart, SessionEnd, Stop. Check spelling and capitalization.",
202654
- docLink: `${os$2}/hooks`
202677
+ docLink: `${os$1}/hooks`
202655
202678
  }
202656
202679
  },
202657
202680
  {
202658
202681
  matches: (e) => /\.hooks\.\d+\.command$/.test(e.path) && e.code === "invalid_type" && e.received === "undefined",
202659
202682
  tip: {
202660
202683
  suggestion: "Command hooks require `command`. For exec form (no shell), set `command` to the executable and `args` to its arguments: {\"type\": \"command\", \"command\": \"echo\", \"args\": [\"hi\"]}. For shell form, set `command` to the full shell string: {\"type\": \"command\", \"command\": \"echo hi\"}.",
202661
- docLink: `${os$2}/hooks#exec-form-and-shell-form`
202684
+ docLink: `${os$1}/hooks#exec-form-and-shell-form`
202662
202685
  }
202663
202686
  },
202664
202687
  {
@@ -202673,7 +202696,7 @@ var os$2 = "https://code.claude.com/docs/en", kKe = [
202673
202696
  matches: (e) => e.code === "unrecognized_keys",
202674
202697
  tip: {
202675
202698
  suggestion: "Check for typos or refer to the documentation for valid fields",
202676
- docLink: `${os$2}/settings`
202699
+ docLink: `${os$1}/settings`
202677
202700
  }
202678
202701
  },
202679
202702
  {
@@ -202688,13 +202711,13 @@ var os$2 = "https://code.claude.com/docs/en", kKe = [
202688
202711
  matches: (e) => e.path === "permissions.additionalDirectories" && e.code === "invalid_type",
202689
202712
  tip: {
202690
202713
  suggestion: "Must be an array of directory paths. Example: [\"~/projects\", \"/tmp/workspace\"]. You can also use --add-dir flag or /add-dir command",
202691
- docLink: `${os$2}/iam#working-directories`
202714
+ docLink: `${os$1}/iam#working-directories`
202692
202715
  }
202693
202716
  }
202694
202717
  ], AKe = {
202695
- permissions: `${os$2}/iam#configuring-permissions`,
202696
- env: `${os$2}/settings#environment-variables`,
202697
- hooks: `${os$2}/hooks`
202718
+ permissions: `${os$1}/iam#configuring-permissions`,
202719
+ env: `${os$1}/settings#environment-variables`,
202720
+ hooks: `${os$1}/hooks`
202698
202721
  };
202699
202722
  function GZ(e) {
202700
202723
  let t = kKe.find((r) => r.matches(e));
@@ -271238,7 +271261,7 @@ var import_multicast_dns = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
271238
271261
  var dgram = __require("dgram");
271239
271262
  var thunky = require_thunky();
271240
271263
  var events = __require("events");
271241
- var os$1 = __require("os");
271264
+ var os = __require("os");
271242
271265
  var noop = function() {};
271243
271266
  module.exports = function(opts) {
271244
271267
  if (!opts) opts = {};
@@ -271369,14 +271392,14 @@ var import_multicast_dns = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
271369
271392
  return that;
271370
271393
  };
271371
271394
  function defaultInterface() {
271372
- var networks = os$1.networkInterfaces();
271395
+ var networks = os.networkInterfaces();
271373
271396
  var names = Object.keys(networks);
271374
271397
  for (var i = 0; i < names.length; i++) {
271375
271398
  var net = networks[names[i]];
271376
271399
  for (var j = 0; j < net.length; j++) {
271377
271400
  var iface = net[j];
271378
271401
  if (isIPv4(iface.family) && !iface.internal) {
271379
- if (os$1.platform() === "darwin" && names[i] === "en0") return iface.address;
271402
+ if (os.platform() === "darwin" && names[i] === "en0") return iface.address;
271380
271403
  return "0.0.0.0";
271381
271404
  }
271382
271405
  }
@@ -271384,7 +271407,7 @@ var import_multicast_dns = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
271384
271407
  return "127.0.0.1";
271385
271408
  }
271386
271409
  function allInterfaces() {
271387
- var networks = os$1.networkInterfaces();
271410
+ var networks = os.networkInterfaces();
271388
271411
  var names = Object.keys(networks);
271389
271412
  var res = [];
271390
271413
  for (var i = 0; i < names.length; i++) {
@@ -300019,7 +300042,7 @@ function resolveBuildCommitFromEnv(env) {
300019
300042
  * environment descriptor down instead of reporting an honest "unknown".
300020
300043
  */
300021
300044
  function readBakedBuildCommit() {
300022
- return "2b217d6b85f7c98cf77e2a23bce2ef8102d3a0a5";
300045
+ return "c7fe2d96f51605b303a42c585157e3bc4d4af889";
300023
300046
  }
300024
300047
  async function resolveServerBuildCommit(input) {
300025
300048
  if (isFullCommitSha(input.baked)) return input.baked;
@@ -310369,6 +310392,24 @@ function logWorkIntakeFailure(cause) {
310369
310392
  }
310370
310393
  console.error("[work-intake] fetch failed:", cause);
310371
310394
  }
310395
+ /**
310396
+ * `?orgId=` present but empty (a stripped or malformed query string) is not
310397
+ * an explicit org. Treat it the same as an absent param rather than sending
310398
+ * CMMD an empty `X-Organization-ID` header (forge#3636).
310399
+ */
310400
+ function normalizeOrgIdQueryParam(raw) {
310401
+ const trimmed = raw?.trim();
310402
+ return trimmed ? trimmed : void 0;
310403
+ }
310404
+ /**
310405
+ * `{ orgId }` when present, `{}` when not -- the `exactOptionalPropertyTypes`
310406
+ * shape every `orgId?: string` deps object here needs, since spreading
310407
+ * `{ orgId: possiblyUndefined }` inline assigns `undefined` to a property
310408
+ * the type says is only ever absent or a string.
310409
+ */
310410
+ function orgIdDeps(orgId) {
310411
+ return orgId !== void 0 ? { orgId } : {};
310412
+ }
310372
310413
  function fetchRestFallbackWorkIntakeForSession(session, dependencies = {}) {
310373
310414
  return gen(function* () {
310374
310415
  const jwt = yield* (dependencies.resolveJwt ?? resolveCmmdJwtForSession)({
@@ -310380,7 +310421,7 @@ function fetchRestFallbackWorkIntakeForSession(session, dependencies = {}) {
310380
310421
  const identity = (dependencies.readIdentity ?? readCmmdUserIdentityForSession)(session.sessionId);
310381
310422
  const fetchFallback = dependencies.fetchFallback ?? fetchCmmdWorkIntakeViaRest;
310382
310423
  return yield* tryPromise({
310383
- try: () => fetchFallback(jwt, identity),
310424
+ try: () => fetchFallback(jwt, identity, orgIdDeps(dependencies.orgId)),
310384
310425
  catch: (cause) => new WorkIntakeSnapshotReadError({
310385
310426
  detail: "Failed to build CMMD REST work-intake fallback.",
310386
310427
  cause
@@ -310492,7 +310533,9 @@ function unwrapForgeEnvelopeJsonText(text) {
310492
310533
  const cmmdWorkIntakeRouteLayer = add$1("GET", "/api/cmmd/work-intake", gen(function* () {
310493
310534
  const request = yield* HttpServerRequest;
310494
310535
  const session = yield* (yield* ServerAuth).authenticateHttpRequest(request);
310495
- const forceFresh = new URL(request.url, "http://localhost").searchParams.get("fresh") === "1";
310536
+ const requestUrl = new URL(request.url, "http://localhost");
310537
+ const forceFresh = requestUrl.searchParams.get("fresh") === "1";
310538
+ const orgId = normalizeOrgIdQueryParam(requestUrl.searchParams.get("orgId"));
310496
310539
  let accessToken = readCommandAccessTokenForSession(session.sessionId);
310497
310540
  if (!accessToken && session.role === "owner" && (session.subject === "owner-bootstrap" || session.subject === "desktop-bootstrap")) accessToken = (yield* promoteMostRecentOwnerCommandAuthToSession(session.sessionId).pipe(catch_((error) => logWarning$1("Failed to promote owner CMMD auth for work intake.", {
310498
310541
  cause: error,
@@ -310537,8 +310580,9 @@ const cmmdWorkIntakeRouteLayer = add$1("GET", "/api/cmmd/work-intake", gen(funct
310537
310580
  sessionId: session.sessionId,
310538
310581
  identityKey: workIntakeCacheIdentity,
310539
310582
  token: accessToken,
310583
+ ...orgIdDeps(orgId),
310540
310584
  forceFresh,
310541
- fetchFresh: () => cmmdJwt ? fetchCmmdWorkIntakeViaRest(cmmdJwt, sessionIdentity) : Promise.reject(/* @__PURE__ */ new Error("CMMD JWT unavailable for work-intake fetch."))
310585
+ fetchFresh: () => cmmdJwt ? fetchCmmdWorkIntakeViaRest(cmmdJwt, sessionIdentity, orgIdDeps(orgId)) : Promise.reject(/* @__PURE__ */ new Error("CMMD JWT unavailable for work-intake fetch."))
310542
310586
  }),
310543
310587
  catch: (cause) => new WorkIntakeSnapshotReadError({
310544
310588
  detail: "Failed to read CMMD work intake snapshot.",
@@ -310556,7 +310600,7 @@ const cmmdWorkIntakeRouteLayer = add$1("GET", "/api/cmmd/work-intake", gen(funct
310556
310600
  if (isCmmdMcpAuthError(cause)) {
310557
310601
  console.error("[WORK_INTAKE] CMMD_AUTH_EXPIRED mcp_error:", cause instanceof Error ? cause.message : String(cause));
310558
310602
  invalidateCachedCmmdWorkIntakeForSession(session.sessionId);
310559
- const fallback = yield* fetchRestFallbackWorkIntakeForSession(session);
310603
+ const fallback = yield* fetchRestFallbackWorkIntakeForSession(session, orgIdDeps(orgId));
310560
310604
  yield* clearCommandAccessTokenForSession(session.sessionId).pipe(catch_((error) => logWarning$1("Failed to clear expired CMMD token after MCP auth failure.", {
310561
310605
  cause: error,
310562
310606
  sessionId: session.sessionId
@@ -310581,7 +310625,7 @@ const cmmdWorkIntakeRouteLayer = add$1("GET", "/api/cmmd/work-intake", gen(funct
310581
310625
  connected: snapshot.connected
310582
310626
  });
310583
310627
  invalidateCachedCmmdWorkIntakeForSession(session.sessionId);
310584
- const fallback = yield* fetchRestFallbackWorkIntakeForSession(session);
310628
+ const fallback = yield* fetchRestFallbackWorkIntakeForSession(session, orgIdDeps(orgId));
310585
310629
  yield* clearCommandAccessTokenForSession(session.sessionId).pipe(catch_((error) => logWarning$1("Failed to clear expired CMMD token after auth warning.", {
310586
310630
  cause: error,
310587
310631
  sessionId: session.sessionId
@@ -311936,12 +311980,65 @@ registerProxyRoute({
311936
311980
  responseShape: "unwrapData",
311937
311981
  requestBody: "none"
311938
311982
  });
311939
- registerProxyRoute({
311983
+ function parseCmmdBootstrapRequest(request) {
311984
+ return sync$1(() => {
311985
+ return {
311986
+ ok: true,
311987
+ value: normalizeOrgIdQueryParam(new URL(request.url, "http://localhost").searchParams.get("orgId"))
311988
+ };
311989
+ });
311990
+ }
311991
+ /**
311992
+ * Nulls `activeWorkspace` on a bootstrap body, wherever it sits. CMMD answers
311993
+ * `GET /api/forge/context/bootstrap` either flat (`{ activeWorkspace, ... }`)
311994
+ * or enveloped (`{ data: { activeWorkspace, ... } }`) -- `workIntakeRest.ts`'s
311995
+ * `unwrapRestObject` already treats both as live shapes for this exact
311996
+ * endpoint. Nulling only the top level left `data.activeWorkspace` (CMMD's
311997
+ * guess) untouched on the enveloped shape.
311998
+ */
311999
+ function nullActiveWorkspace(body) {
312000
+ const data = body["data"];
312001
+ const nulledData = typeof data === "object" && data !== null && !Array.isArray(data) ? {
312002
+ ...data,
312003
+ activeWorkspace: null
312004
+ } : data;
312005
+ return {
312006
+ ...body,
312007
+ activeWorkspace: null,
312008
+ ...data !== void 0 ? { data: nulledData } : {}
312009
+ };
312010
+ }
312011
+ /**
312012
+ * CMMD resolves `activeWorkspace` to the caller's own default organization
312013
+ * whenever the request carries no `X-Organization-ID` header (forge#3636:
312014
+ * the owner working in org 2119 kept getting org 2142, CMMD's default, back).
312015
+ * Passing the client's explicit `?orgId=` scopes CMMD's answer to that
312016
+ * workspace; without one, CMMD still guesses, so `activeWorkspace` is nulled
312017
+ * here rather than forwarded as fact. Everything else in the bootstrap
312018
+ * response passes through untouched.
312019
+ */
312020
+ function runCmmdBootstrap(orgId, { session }) {
312021
+ return runCmmdRestProxyAsHandlerResult(session, (jwt) => cmmdGateway.request({
312022
+ method: "GET",
312023
+ jwt,
312024
+ path: "/api/forge/context/bootstrap",
312025
+ ...orgId !== void 0 ? { orgId } : {}
312026
+ }), (value) => {
312027
+ if (orgId !== void 0 || value === null || typeof value !== "object") return {
312028
+ status: 200,
312029
+ body: value
312030
+ };
312031
+ return {
312032
+ status: 200,
312033
+ body: nullActiveWorkspace(value)
312034
+ };
312035
+ });
312036
+ }
312037
+ registerProxyHandler({
311940
312038
  forgePath: "/api/cmmd/bootstrap",
311941
312039
  method: "GET",
311942
- cmmdPath: "/api/forge/context/bootstrap",
311943
- orgIdSource: "none",
311944
- responseShape: "passthrough"
312040
+ parse: parseCmmdBootstrapRequest,
312041
+ run: runCmmdBootstrap
311945
312042
  });
311946
312043
  registerProxyRoute({
311947
312044
  forgePath: "/api/cmmd/account/preferences",
@@ -325414,7 +325511,7 @@ const connectLoginCommand = make$33("login", {
325414
325511
  })).json();
325415
325512
  },
325416
325513
  openBrowser: async (url) => {
325417
- const open = (await import("./open-yHTUkd2Y.mjs")).default;
325514
+ const open = (await import("./open-2-reBrpv.mjs")).default;
325418
325515
  await open(url);
325419
325516
  return true;
325420
325517
  },