@stigmer/cli 3.1.7 → 3.1.8

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 (70) hide show
  1. package/commands/share.d.ts +3 -0
  2. package/commands/share.d.ts.map +1 -0
  3. package/commands/share.js +75 -0
  4. package/commands/share.js.map +1 -0
  5. package/config/index.d.ts +1 -1
  6. package/config/index.d.ts.map +1 -1
  7. package/config/index.js +1 -1
  8. package/config/index.js.map +1 -1
  9. package/config/resolve.d.ts +19 -2
  10. package/config/resolve.d.ts.map +1 -1
  11. package/config/resolve.js +40 -2
  12. package/config/resolve.js.map +1 -1
  13. package/local/runtime/node.d.ts +9 -2
  14. package/local/runtime/node.d.ts.map +1 -1
  15. package/local/runtime/node.js +38 -23
  16. package/local/runtime/node.js.map +1 -1
  17. package/package.json +6 -6
  18. package/program.d.ts.map +1 -1
  19. package/program.js +2 -0
  20. package/program.js.map +1 -1
  21. package/resources/connect/oauth.d.ts +0 -9
  22. package/resources/connect/oauth.d.ts.map +1 -1
  23. package/resources/connect/oauth.js +1 -17
  24. package/resources/connect/oauth.js.map +1 -1
  25. package/resources/share.d.ts +37 -0
  26. package/resources/share.d.ts.map +1 -0
  27. package/resources/share.js +144 -0
  28. package/resources/share.js.map +1 -0
  29. package/resources/stream/convert.d.ts +6 -2
  30. package/resources/stream/convert.d.ts.map +1 -1
  31. package/resources/stream/convert.js +8 -2
  32. package/resources/stream/convert.js.map +1 -1
  33. package/resources/stream/events.d.ts +14 -2
  34. package/resources/stream/events.d.ts.map +1 -1
  35. package/resources/stream/events.js.map +1 -1
  36. package/resources/stream/render-ndjson.js +2 -0
  37. package/resources/stream/render-ndjson.js.map +1 -1
  38. package/resources/stream/render-plaintext.d.ts.map +1 -1
  39. package/resources/stream/render-plaintext.js +3 -0
  40. package/resources/stream/render-plaintext.js.map +1 -1
  41. package/resources/stream/snapshot.js +6 -1
  42. package/resources/stream/snapshot.js.map +1 -1
  43. package/resources/stream/tool-state.d.ts +1 -1
  44. package/resources/stream/tool-state.d.ts.map +1 -1
  45. package/resources/stream/tool-state.js +13 -4
  46. package/resources/stream/tool-state.js.map +1 -1
  47. package/src/commands/connect.test.ts +26 -4
  48. package/src/commands/share.ts +99 -0
  49. package/src/config/index.ts +2 -0
  50. package/src/config/resolve.test.ts +38 -0
  51. package/src/config/resolve.ts +42 -3
  52. package/src/local/runtime/node.ts +43 -25
  53. package/src/local/runtime/runtime.test.ts +5 -4
  54. package/src/program.test.ts +7 -0
  55. package/src/program.ts +2 -0
  56. package/src/resources/connect/oauth.test.ts +1 -24
  57. package/src/resources/connect/oauth.ts +1 -17
  58. package/src/resources/read-verbs.integration.test.ts +1 -1
  59. package/src/resources/share.test.ts +389 -0
  60. package/src/resources/share.ts +227 -0
  61. package/src/resources/stream/convert.ts +17 -3
  62. package/src/resources/stream/diff.test.ts +22 -0
  63. package/src/resources/stream/events.ts +15 -1
  64. package/src/resources/stream/render-ndjson.test.ts +10 -0
  65. package/src/resources/stream/render-ndjson.ts +2 -0
  66. package/src/resources/stream/render-plaintext.test.ts +8 -0
  67. package/src/resources/stream/render-plaintext.ts +3 -0
  68. package/src/resources/stream/snapshot.test.ts +14 -0
  69. package/src/resources/stream/snapshot.ts +5 -1
  70. package/src/resources/stream/tool-state.ts +13 -4
@@ -0,0 +1,99 @@
1
+ // `stigmer share agent <ref>` — enable (default) or disable (--off) public
2
+ // sharing for an agent, printing the hosted chat link and embed snippet.
3
+ //
4
+ // Thin handler: resolve credentials/org and the console origin, delegate the
5
+ // merge-preserving toggle to resources/share, render the result. `--open` is a
6
+ // best-effort browser launch after render (mirrors auth login: the URL is
7
+ // already on screen, so a failed launch costs nothing). Heavy modules are
8
+ // lazy-imported so `--help` stays fast (DD-001).
9
+
10
+ import type { Command } from "commander";
11
+ import { ensureAuthenticated, resolveConsoleURL, resolveOrganization } from "../config/index.js";
12
+ import { UsageError } from "../errors/index.js";
13
+ import type { OutputFlags } from "../output/index.js";
14
+ import type { ShareAudience } from "../resources/share.js";
15
+ import { addResultFlags, globalOrg, resultFormat } from "./shared.js";
16
+
17
+ interface ShareAgentFlags extends OutputFlags {
18
+ off?: boolean;
19
+ open?: boolean;
20
+ audience?: string;
21
+ resetLink?: boolean;
22
+ }
23
+
24
+ export function registerShare(program: Command): void {
25
+ const share = program.command("share").description("share resources via a hosted link");
26
+
27
+ const agent = share
28
+ .command("agent <ref>")
29
+ .description("enable sharing for an agent and print its chat link and embed snippet")
30
+ .option("--off", "disable sharing (the link stops working immediately)")
31
+ .option(
32
+ "--audience <audience>",
33
+ "who can chat: 'public' (anyone with the link) or 'org' (signed-in organization members only); omit to keep the current audience",
34
+ )
35
+ .option(
36
+ "--reset-link",
37
+ "generate a new share link and kill the current one immediately (public audience)",
38
+ )
39
+ .option("--open", "open the chat link in your browser")
40
+ .action((ref: string, options: ShareAgentFlags, command: Command) => runShareAgent(ref, options, command));
41
+ addResultFlags(agent);
42
+ }
43
+
44
+ // Validates --audience before any network work; omitted means "preserve".
45
+ function parseAudience(value: string | undefined): ShareAudience | undefined {
46
+ if (value === undefined) return undefined;
47
+ if (value === "public" || value === "org") return value;
48
+ throw new UsageError(`invalid --audience '${value}'\n\nExpected 'public' or 'org'.`);
49
+ }
50
+
51
+ async function runShareAgent(ref: string, options: ShareAgentFlags, command: Command): Promise<void> {
52
+ const format = resultFormat(options);
53
+
54
+ const [{ connectBackend }, { shareAgent }, { renderResult }] = await Promise.all([
55
+ import("../backend.js"),
56
+ import("../resources/share.js"),
57
+ import("../output/command-result.js"),
58
+ ]);
59
+
60
+ const client = connectBackend();
61
+ ensureAuthenticated(client.config);
62
+ const org = resolveOrganization(client.config, globalOrg(command));
63
+
64
+ const backendType = client.config.backend.type;
65
+ const appOrigin = resolveConsoleURL(backendType);
66
+ const enabled = options.off !== true;
67
+ const audience = parseAudience(options.audience);
68
+ const resetLink = options.resetLink === true;
69
+ if (resetLink && !enabled) {
70
+ throw new UsageError(
71
+ "--reset-link cannot be combined with --off\n\n" +
72
+ "Disabling sharing already kills the link. Reset is for keeping\n" +
73
+ "sharing on while invalidating the current URL.",
74
+ );
75
+ }
76
+
77
+ const result = await shareAgent(client.stigmer, ref, org, {
78
+ enabled,
79
+ ...(audience !== undefined ? { audience } : {}),
80
+ resetLink,
81
+ appOrigin,
82
+ isLocal: backendType === "local",
83
+ });
84
+ renderResult(result, format);
85
+
86
+ if (options.open === true && enabled) {
87
+ // Best-effort: the link is already rendered above, so a launch failure
88
+ // only needs a nudge, never an error exit (mirrors auth login).
89
+ const url = result.sections.find((s) => s.title.endsWith("chat link"))?.items[0];
90
+ if (url !== undefined) {
91
+ try {
92
+ const { default: open } = await import("open");
93
+ await open(url);
94
+ } catch {
95
+ process.stderr.write("Could not open the browser automatically. Please open the link above.\n");
96
+ }
97
+ }
98
+ }
99
+ }
@@ -12,7 +12,9 @@ export {
12
12
  save,
13
13
  } from "./config.js";
14
14
  export {
15
+ DEFAULT_CLOUD_CONSOLE_URL,
15
16
  ensureAuthenticated,
17
+ resolveConsoleURL,
16
18
  resolveContextOrganization,
17
19
  resolveEndpoint,
18
20
  resolveOrganization,
@@ -2,7 +2,9 @@ import { afterEach, describe, expect, it } from "vitest";
2
2
  import { CliExitError } from "../errors/index.js";
3
3
  import type { Config } from "./config.js";
4
4
  import {
5
+ DEFAULT_CLOUD_CONSOLE_URL,
5
6
  ensureAuthenticated,
7
+ resolveConsoleURL,
6
8
  resolveContextOrganization,
7
9
  resolveEndpoint,
8
10
  resolveOrganization,
@@ -77,6 +79,42 @@ describe("resolveOrganization", () => {
77
79
  it("falls back to legacy cloud org_id", () => {
78
80
  expect(resolveContextOrganization(cloudConfig({ org_id: "legacy" }))).toBe("legacy");
79
81
  });
82
+
83
+ it("defaults to the seedpack org in local mode when nothing is configured", () => {
84
+ expect(resolveOrganization({ backend: { type: "local" } })).toBe("stigmer");
85
+ });
86
+
87
+ it("prefers an explicit context org over the local default", () => {
88
+ const config: Config = { backend: { type: "local" }, context: { organization: "my-local-org" } };
89
+ expect(resolveOrganization(config)).toBe("my-local-org");
90
+ });
91
+
92
+ it("does not apply the local default in cloud mode (org stays empty)", () => {
93
+ expect(resolveOrganization({ backend: { type: "cloud" } })).toBe("");
94
+ });
95
+
96
+ it("reports an unset local org as empty via resolveContextOrganization (no implicit default)", () => {
97
+ // The implicit local default lives only in resolveOrganization (effective
98
+ // org for operations); the context query must stay faithful so config/context
99
+ // display can show "(not set)".
100
+ expect(resolveContextOrganization({ backend: { type: "local" } })).toBe("");
101
+ });
102
+ });
103
+
104
+ describe("resolveConsoleURL", () => {
105
+ it("prefers the STIGMER_CONSOLE_URL override", () => {
106
+ expect(resolveConsoleURL("cloud", { STIGMER_CONSOLE_URL: "https://console.example" } as NodeJS.ProcessEnv)).toBe(
107
+ "https://console.example",
108
+ );
109
+ });
110
+
111
+ it("uses the local web-console port for the local backend", () => {
112
+ expect(resolveConsoleURL("local", {} as NodeJS.ProcessEnv)).toBe("http://localhost:8234");
113
+ });
114
+
115
+ it("uses the cloud console URL for the cloud backend", () => {
116
+ expect(resolveConsoleURL("cloud", {} as NodeJS.ProcessEnv)).toBe(DEFAULT_CLOUD_CONSOLE_URL);
117
+ });
80
118
  });
81
119
 
82
120
  describe("ensureAuthenticated", () => {
@@ -3,11 +3,22 @@
3
3
  // precedence keeps every call site consistent (mirrors the Go CLI's Resolve*).
4
4
 
5
5
  import { CliExitError, ExitCode } from "../errors/index.js";
6
- import { type Config, isCloudMode } from "./config.js";
6
+ import { WEB_CONSOLE_PORT } from "../local/constants.js";
7
+ import { type BackendType, type Config, isCloudMode } from "./config.js";
7
8
 
8
9
  const DEFAULT_CLOUD_ENDPOINT = "api.stigmer.ai:443";
9
10
  const DEFAULT_LOCAL_ENDPOINT = "localhost:7234";
10
11
 
12
+ /** Well-known URL for the Stigmer Cloud web console. */
13
+ export const DEFAULT_CLOUD_CONSOLE_URL = "https://app.stigmer.ai";
14
+
15
+ // Local mode is single-tenant: the seedpack bootstraps resources into the
16
+ // "stigmer" org (see client-apps/cli/src/local/seedpack/apply.ts DEFAULT_ORG).
17
+ // Org-scoped getByReference now requires an org, so bare-slug `get`/`run`/`apply`
18
+ // in local mode fall back to this default when nothing else is configured. Cloud
19
+ // mode has no implicit org — the caller must select one (flag/env/context/login).
20
+ const DEFAULT_LOCAL_ORG = "stigmer";
21
+
11
22
  /**
12
23
  * Resolve the server endpoint.
13
24
  * STIGMER_SERVER_ADDRESS (explicit override, either backend)
@@ -52,10 +63,38 @@ export function resolveOrganization(config: Config, flagOrg?: string): string {
52
63
  if (env !== undefined && env !== "") {
53
64
  return env;
54
65
  }
55
- return resolveContextOrganization(config);
66
+ const context = resolveContextOrganization(config);
67
+ if (context !== "") {
68
+ return context;
69
+ }
70
+ // Nothing configured: local mode falls back to its single-tenant default org
71
+ // so bare-slug operations resolve without ceremony; cloud stays empty (the
72
+ // caller must select an org, e.g. apply raises a clear "organization not set").
73
+ return isCloudMode(config) ? "" : DEFAULT_LOCAL_ORG;
56
74
  }
57
75
 
58
- /** The configured organization, with the legacy cloud.org_id fallback. */
76
+ /**
77
+ * Resolve the web console URL:
78
+ * 1. `STIGMER_CONSOLE_URL` (explicit override)
79
+ * 2. local backend → `http://localhost:{WEB_CONSOLE_PORT}`
80
+ * 3. cloud backend → {@link DEFAULT_CLOUD_CONSOLE_URL}
81
+ *
82
+ * The console origin is also the app origin that serves the hosted chat
83
+ * page (`/chat/<org>/<slug>`) and the embed loader (`/embed.js`), so
84
+ * share-link builders use this same resolver.
85
+ */
86
+ export function resolveConsoleURL(backendType: BackendType, env: NodeJS.ProcessEnv = process.env): string {
87
+ const override = env.STIGMER_CONSOLE_URL;
88
+ if (override !== undefined && override !== "") return override;
89
+ if (backendType === "local") return `http://localhost:${WEB_CONSOLE_PORT}`;
90
+ return DEFAULT_CLOUD_CONSOLE_URL;
91
+ }
92
+
93
+ /**
94
+ * The configured organization, with the legacy cloud.org_id fallback. Reports
95
+ * only what is explicitly set (no implicit local default) so config/context
96
+ * display can faithfully show "(not set)".
97
+ */
59
98
  export function resolveContextOrganization(config: Config): string {
60
99
  if (config.context?.organization !== undefined && config.context.organization !== "") {
61
100
  return config.context.organization;
@@ -1,10 +1,10 @@
1
1
  // Resolution of the Node.js runtime used to launch the runner subprocess.
2
2
  //
3
3
  // We reuse the very Node that is running the CLI (process.execPath). The CLI is
4
- // itself an npm package with `engines: node >= 20`, so a suitable Node is always
5
- // present by construction — there is deliberately no hermetic Node download
6
- // (DD-002: keep the base install lean; nothing to acquire that the host already
7
- // guarantees). This is exactly what the conformance harness does
4
+ // itself an npm package with `engines: node >= 22.13`, so a suitable Node is
5
+ // always present by construction — there is deliberately no hermetic Node
6
+ // download (DD-002: keep the base install lean; nothing to acquire that the host
7
+ // already guarantees). This is exactly what the conformance harness does
8
8
  // (`spawn(process.execPath, ...)`). An explicit STIGMER_NODE_BIN override is
9
9
  // honored and version-checked for advanced/multi-runtime setups.
10
10
 
@@ -12,8 +12,20 @@ import { execFileSync } from "node:child_process";
12
12
  import { CliExitError } from "../../errors/cli-exit-error.js";
13
13
  import { ExitCode } from "../../errors/exit-codes.js";
14
14
 
15
- /** Minimum Node major version the runner requires. */
16
- export const MIN_NODE_MAJOR = 20;
15
+ /**
16
+ * Minimum Node version the runner requires: 22.13. The runner's durable local
17
+ * checkpointer imports Node's built-in `node:sqlite`, which is only available
18
+ * WITHOUT the --experimental-sqlite flag from v22.13 (and v23.4) onward. A
19
+ * major-only gate would let 22.0-22.12 pass and then crash at checkpointer
20
+ * creation, so the minor is enforced when the major is exactly 22.
21
+ */
22
+ export const MIN_NODE_MAJOR = 22;
23
+ export const MIN_NODE_MINOR_ON_MAJOR = 13;
24
+
25
+ interface NodeVersion {
26
+ major: number;
27
+ minor: number;
28
+ }
17
29
 
18
30
  /**
19
31
  * Resolve the Node binary to launch the runner with. Honors STIGMER_NODE_BIN
@@ -22,46 +34,52 @@ export const MIN_NODE_MAJOR = 20;
22
34
  export function resolveNode(): string {
23
35
  const override = process.env.STIGMER_NODE_BIN;
24
36
  if (override !== undefined && override !== "") {
25
- assertVersion(override, probeNodeMajor(override));
37
+ assertVersion(override, probeNodeVersion(override));
26
38
  return override;
27
39
  }
28
- // The CLI's own runtime: major is readable directly, no subprocess needed.
29
- assertVersion(process.execPath, currentMajor());
40
+ // The CLI's own runtime: version is readable directly, no subprocess needed.
41
+ assertVersion(process.execPath, parseVersion(process.versions.node));
30
42
  return process.execPath;
31
43
  }
32
44
 
33
- function currentMajor(): number | null {
34
- return parseMajor(process.versions.node);
35
- }
36
-
37
- function probeNodeMajor(bin: string): number | null {
45
+ function probeNodeVersion(bin: string): NodeVersion | null {
38
46
  try {
39
47
  const out = execFileSync(bin, ["--version"], { encoding: "utf8" });
40
- return parseMajor(out.trim());
48
+ return parseVersion(out.trim());
41
49
  } catch {
42
50
  return null;
43
51
  }
44
52
  }
45
53
 
46
- // Parses "v22.22.2" or "22.22.2" to its major number.
47
- function parseMajor(version: string): number | null {
48
- const match = /^v?(\d+)\./.exec(version.trim());
54
+ // Parses "v22.22.2" or "22.22.2" to its major/minor numbers.
55
+ function parseVersion(version: string): NodeVersion | null {
56
+ const match = /^v?(\d+)\.(\d+)\./.exec(version.trim());
49
57
  if (match === null) return null;
50
58
  const major = Number.parseInt(match[1], 10);
51
- return Number.isInteger(major) ? major : null;
59
+ const minor = Number.parseInt(match[2], 10);
60
+ if (!Number.isInteger(major) || !Number.isInteger(minor)) return null;
61
+ return { major, minor };
62
+ }
63
+
64
+ // True when the version is at or above the 22.13 floor.
65
+ function meetsFloor(v: NodeVersion): boolean {
66
+ if (v.major > MIN_NODE_MAJOR) return true;
67
+ return v.major === MIN_NODE_MAJOR && v.minor >= MIN_NODE_MINOR_ON_MAJOR;
52
68
  }
53
69
 
54
- function assertVersion(bin: string, major: number | null): void {
55
- if (major === null) {
70
+ function assertVersion(bin: string, version: NodeVersion | null): void {
71
+ const floor = `${MIN_NODE_MAJOR}.${MIN_NODE_MINOR_ON_MAJOR}`;
72
+ if (version === null) {
56
73
  throw new CliExitError(`could not determine the Node version of ${bin}`, ExitCode.General, [
57
- `Ensure ${bin} is a working Node >= ${MIN_NODE_MAJOR} runtime.`,
74
+ `Ensure ${bin} is a working Node >= ${floor} runtime.`,
58
75
  ]);
59
76
  }
60
- if (major < MIN_NODE_MAJOR) {
77
+ if (!meetsFloor(version)) {
61
78
  throw new CliExitError(
62
- `Node >= ${MIN_NODE_MAJOR} is required to run the runner (found major ${major} at ${bin})`,
79
+ `Node >= ${floor} is required to run the runner ` +
80
+ `(found ${version.major}.${version.minor} at ${bin})`,
63
81
  ExitCode.General,
64
- [`Upgrade Node to ${MIN_NODE_MAJOR} or newer, or point STIGMER_NODE_BIN at one.`],
82
+ [`Upgrade Node to ${floor} or newer, or point STIGMER_NODE_BIN at one.`],
65
83
  );
66
84
  }
67
85
  }
@@ -3,7 +3,7 @@ import { tmpdir } from "node:os";
3
3
  import { join } from "node:path";
4
4
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
5
5
  import { CliExitError } from "../../errors/cli-exit-error.js";
6
- import { MIN_NODE_MAJOR, resolveNode } from "./node.js";
6
+ import { MIN_NODE_MAJOR, MIN_NODE_MINOR_ON_MAJOR, resolveNode } from "./node.js";
7
7
  import { acquireRunner, resolveRunner } from "./runner.js";
8
8
  import { resolveServerBinary } from "./server.js";
9
9
  import { which } from "./which.js";
@@ -57,7 +57,7 @@ describe("resolveNode", () => {
57
57
  });
58
58
 
59
59
  it("honors a valid override", () => {
60
- process.env.STIGMER_NODE_BIN = process.execPath; // a real Node >= 20
60
+ process.env.STIGMER_NODE_BIN = process.execPath; // a real Node >= 22.13
61
61
  expect(resolveNode()).toBe(process.execPath);
62
62
  });
63
63
 
@@ -66,8 +66,9 @@ describe("resolveNode", () => {
66
66
  expect(() => resolveNode()).toThrow(CliExitError);
67
67
  });
68
68
 
69
- it("requires Node >= 20", () => {
70
- expect(MIN_NODE_MAJOR).toBe(20);
69
+ it("requires Node >= 22.13 (the node:sqlite floor)", () => {
70
+ expect(MIN_NODE_MAJOR).toBe(22);
71
+ expect(MIN_NODE_MINOR_ON_MAJOR).toBe(13);
71
72
  });
72
73
  });
73
74
 
@@ -43,6 +43,13 @@ describe("buildProgram", () => {
43
43
  expect(message?.required).toBe(true);
44
44
  });
45
45
 
46
+ it("exposes the share subcommands", () => {
47
+ const program = buildProgram();
48
+ const share = program.commands.find((command) => command.name() === "share");
49
+ const subs = share?.commands.map((command) => command.name());
50
+ expect(subs).toEqual(["agent"]);
51
+ });
52
+
46
53
  it("exposes the usage subcommands", () => {
47
54
  const program = buildProgram();
48
55
  const usage = program.commands.find((command) => command.name() === "usage");
package/src/program.ts CHANGED
@@ -31,6 +31,7 @@ import { registerRun } from "./commands/run.js";
31
31
  import { registerSearch } from "./commands/search.js";
32
32
  import { registerSeedpack } from "./commands/seedpack.js";
33
33
  import { registerSetup } from "./commands/setup.js";
34
+ import { registerShare } from "./commands/share.js";
34
35
  import { registerStatus } from "./commands/status.js";
35
36
  import { registerTag } from "./commands/tag.js";
36
37
  import { registerUp } from "./commands/up.js";
@@ -76,6 +77,7 @@ export function buildProgram(): Command {
76
77
  registerValidate(program);
77
78
  registerDelete(program);
78
79
  registerTag(program);
80
+ registerShare(program);
79
81
  registerDiff(program);
80
82
  registerUsage(program);
81
83
  registerPush(program);
@@ -3,14 +3,7 @@ import { McpServerSchema } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1
3
3
  import type { Stigmer } from "@stigmer/sdk";
4
4
  import { afterEach, describe, expect, it, vi } from "vitest";
5
5
  import { UsageError } from "../../errors/index.js";
6
- import {
7
- browserCommand,
8
- DEFAULT_CLOUD_CONSOLE_URL,
9
- resolveConsoleURL,
10
- runOAuthFlow,
11
- waitForOAuthGrant,
12
- type OAuthFlowDeps,
13
- } from "./oauth.js";
6
+ import { browserCommand, runOAuthFlow, waitForOAuthGrant, type OAuthFlowDeps } from "./oauth.js";
14
7
 
15
8
  const server = create(McpServerSchema, {
16
9
  metadata: { id: "mcp_1", slug: "github", name: "GitHub" },
@@ -33,22 +26,6 @@ function fakeClient(connectOnCall: number): { client: Stigmer; calls: () => numb
33
26
 
34
27
  const noopSleep = async (): Promise<void> => {};
35
28
 
36
- describe("resolveConsoleURL", () => {
37
- it("prefers the STIGMER_CONSOLE_URL override", () => {
38
- expect(resolveConsoleURL("cloud", { STIGMER_CONSOLE_URL: "https://console.example" } as NodeJS.ProcessEnv)).toBe(
39
- "https://console.example",
40
- );
41
- });
42
-
43
- it("uses the local web-console port for the local backend", () => {
44
- expect(resolveConsoleURL("local", {} as NodeJS.ProcessEnv)).toBe("http://localhost:8234");
45
- });
46
-
47
- it("uses the cloud console URL for the cloud backend", () => {
48
- expect(resolveConsoleURL("cloud", {} as NodeJS.ProcessEnv)).toBe(DEFAULT_CLOUD_CONSOLE_URL);
49
- });
50
- });
51
-
52
29
  describe("browserCommand", () => {
53
30
  it("maps each supported platform to its opener", () => {
54
31
  expect(browserCommand("darwin", "https://x")).toEqual(["open", ["https://x"]]);
@@ -16,11 +16,8 @@ import type { McpServer } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/
16
16
  import { GetOAuthGrantStatusInputSchema } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/io_pb";
17
17
  import type { Stigmer } from "@stigmer/sdk";
18
18
  import type { BackendType } from "../../config/config.js";
19
+ import { resolveConsoleURL } from "../../config/index.js";
19
20
  import { UsageError } from "../../errors/index.js";
20
- import { WEB_CONSOLE_PORT } from "../../local/constants.js";
21
-
22
- /** Well-known URL for the Stigmer Cloud web console. */
23
- export const DEFAULT_CLOUD_CONSOLE_URL = "https://app.stigmer.ai";
24
21
 
25
22
  const POLL_INTERVAL_MS = 3000;
26
23
  const POLL_TIMEOUT_MS = 5 * 60 * 1000;
@@ -109,19 +106,6 @@ export async function checkOAuthGrant(client: Stigmer, mcpServerId: string, org:
109
106
  return status.connected;
110
107
  }
111
108
 
112
- /**
113
- * Resolve the web console URL:
114
- * 1. `STIGMER_CONSOLE_URL` (explicit override)
115
- * 2. local backend → `http://localhost:{WEB_CONSOLE_PORT}`
116
- * 3. cloud backend → {@link DEFAULT_CLOUD_CONSOLE_URL}
117
- */
118
- export function resolveConsoleURL(backendType: BackendType, env: NodeJS.ProcessEnv = process.env): string {
119
- const override = env.STIGMER_CONSOLE_URL;
120
- if (override !== undefined && override !== "") return override;
121
- if (backendType === "local") return `http://localhost:${WEB_CONSOLE_PORT}`;
122
- return DEFAULT_CLOUD_CONSOLE_URL;
123
- }
124
-
125
109
  // Probe the local web console with a short-timeout GET. Any HTTP response (even
126
110
  // an error status) means it's serving; a network/timeout failure means it isn't.
127
111
  async function probeWebConsole(url: string): Promise<boolean> {
@@ -38,7 +38,7 @@ const knownAgent = create(AgentSchema, {
38
38
  const knownOrg = create(OrganizationSchema, {
39
39
  apiVersion: "tenancy.stigmer.ai/v1",
40
40
  kind: "Organization",
41
- metadata: { name: "Acme", slug: "acme", org: "acme", id: "org_1" },
41
+ metadata: { name: "Acme", slug: "acme", org: "acme", id: "acme" },
42
42
  });
43
43
 
44
44
  const knownApiKey = create(ApiKeySchema, {