@stigmer/cli 3.18.1-dev.20260919070736 → 3.19.1-dev.20260920100552

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 (141) hide show
  1. package/commands/apply.d.ts.map +1 -1
  2. package/commands/apply.js +45 -101
  3. package/commands/apply.js.map +1 -1
  4. package/commands/install.js +2 -1
  5. package/commands/install.js.map +1 -1
  6. package/commands/marketplace.js +3 -3
  7. package/commands/marketplace.js.map +1 -1
  8. package/commands/push.js +3 -1
  9. package/commands/push.js.map +1 -1
  10. package/commands/validate.js +3 -4
  11. package/commands/validate.js.map +1 -1
  12. package/local/bootstrap.d.ts +1 -2
  13. package/local/bootstrap.d.ts.map +1 -1
  14. package/local/bootstrap.js +13 -41
  15. package/local/bootstrap.js.map +1 -1
  16. package/local/daemon/launch.d.ts +2 -2
  17. package/local/daemon/launch.d.ts.map +1 -1
  18. package/local/daemon/launch.js +2 -2
  19. package/local/daemon/launch.js.map +1 -1
  20. package/local/plugins/defaults.js +2 -2
  21. package/local/plugins/defaults.js.map +1 -1
  22. package/marketplace/config.d.ts.map +1 -1
  23. package/marketplace/config.js +13 -9
  24. package/marketplace/config.js.map +1 -1
  25. package/marketplace/render.d.ts.map +1 -1
  26. package/marketplace/render.js +1 -7
  27. package/marketplace/render.js.map +1 -1
  28. package/package.json +7 -7
  29. package/registry/index.d.ts +2 -2
  30. package/registry/index.d.ts.map +1 -1
  31. package/registry/index.js +2 -2
  32. package/registry/index.js.map +1 -1
  33. package/registry/metadata.d.ts +9 -0
  34. package/registry/metadata.d.ts.map +1 -1
  35. package/registry/metadata.js +14 -5
  36. package/registry/metadata.js.map +1 -1
  37. package/registry/registry.d.ts +9 -0
  38. package/registry/registry.d.ts.map +1 -1
  39. package/registry/registry.js +16 -1
  40. package/registry/registry.js.map +1 -1
  41. package/registry/verb-support.d.ts.map +1 -1
  42. package/registry/verb-support.js +0 -13
  43. package/registry/verb-support.js.map +1 -1
  44. package/resources/apply/apply.d.ts +11 -12
  45. package/resources/apply/apply.d.ts.map +1 -1
  46. package/resources/apply/apply.js +12 -21
  47. package/resources/apply/apply.js.map +1 -1
  48. package/resources/apply/handlers.js +2 -2
  49. package/resources/apply/handlers.js.map +1 -1
  50. package/resources/connect/oauth.d.ts.map +1 -1
  51. package/resources/connect/oauth.js +4 -1
  52. package/resources/connect/oauth.js.map +1 -1
  53. package/resources/delete.d.ts.map +1 -1
  54. package/resources/delete.js +0 -1
  55. package/resources/delete.js.map +1 -1
  56. package/resources/get-bindings.d.ts.map +1 -1
  57. package/resources/get-bindings.js +0 -5
  58. package/resources/get-bindings.js.map +1 -1
  59. package/resources/list.d.ts.map +1 -1
  60. package/resources/list.js +0 -1
  61. package/resources/list.js.map +1 -1
  62. package/resources/plugin.d.ts +27 -0
  63. package/resources/plugin.d.ts.map +1 -1
  64. package/resources/plugin.js +113 -8
  65. package/resources/plugin.js.map +1 -1
  66. package/resources/validate.d.ts.map +1 -1
  67. package/resources/validate.js +0 -2
  68. package/resources/validate.js.map +1 -1
  69. package/src/commands/apply.ts +40 -150
  70. package/src/commands/install.test.ts +20 -21
  71. package/src/commands/install.ts +2 -1
  72. package/src/commands/marketplace.test.ts +10 -19
  73. package/src/commands/marketplace.ts +3 -3
  74. package/src/commands/push.ts +6 -1
  75. package/src/commands/validate.ts +2 -4
  76. package/src/local/bootstrap.test.ts +15 -59
  77. package/src/local/bootstrap.ts +12 -53
  78. package/src/local/daemon/launch.ts +4 -4
  79. package/src/local/plugins/defaults.test.ts +28 -28
  80. package/src/local/plugins/defaults.ts +2 -2
  81. package/src/marketplace/__fixtures__/cursor-marketplace.ts +16 -12
  82. package/src/marketplace/config.test.ts +12 -28
  83. package/src/marketplace/config.ts +13 -9
  84. package/src/marketplace/install.test.ts +19 -19
  85. package/src/marketplace/read.test.ts +6 -6
  86. package/src/marketplace/render.ts +1 -10
  87. package/src/registry/index.ts +7 -1
  88. package/src/registry/metadata.ts +15 -5
  89. package/src/registry/registry.test.ts +1 -7
  90. package/src/registry/registry.ts +17 -1
  91. package/src/registry/verb-support.ts +0 -13
  92. package/src/resources/apply/apply.integration.test.ts +15 -3
  93. package/src/resources/apply/apply.ts +15 -26
  94. package/src/resources/apply/handlers.ts +2 -2
  95. package/src/resources/connect/oauth.test.ts +2 -2
  96. package/src/resources/connect/oauth.ts +4 -1
  97. package/src/resources/delete.ts +0 -1
  98. package/src/resources/get-bindings.ts +0 -5
  99. package/src/resources/list.ts +0 -1
  100. package/src/resources/plugin.test.ts +119 -2
  101. package/src/resources/plugin.ts +140 -8
  102. package/src/resources/validate.test.ts +0 -1
  103. package/src/resources/validate.ts +0 -2
  104. package/local/seedpack-retire.d.ts +0 -63
  105. package/local/seedpack-retire.d.ts.map +0 -1
  106. package/local/seedpack-retire.js +0 -361
  107. package/local/seedpack-retire.js.map +0 -1
  108. package/resources/apply/declarative.d.ts +0 -106
  109. package/resources/apply/declarative.d.ts.map +0 -1
  110. package/resources/apply/declarative.js +0 -397
  111. package/resources/apply/declarative.js.map +0 -1
  112. package/resources/apply/synth/project-track.d.ts +0 -21
  113. package/resources/apply/synth/project-track.d.ts.map +0 -1
  114. package/resources/apply/synth/project-track.js +0 -102
  115. package/resources/apply/synth/project-track.js.map +0 -1
  116. package/resources/apply/synth/reader.d.ts +0 -18
  117. package/resources/apply/synth/reader.d.ts.map +0 -1
  118. package/resources/apply/synth/reader.js +0 -55
  119. package/resources/apply/synth/reader.js.map +0 -1
  120. package/resources/apply/synth/runtime.d.ts +0 -8
  121. package/resources/apply/synth/runtime.d.ts.map +0 -1
  122. package/resources/apply/synth/runtime.js +0 -32
  123. package/resources/apply/synth/runtime.js.map +0 -1
  124. package/resources/apply/synth/synthesize.d.ts +0 -43
  125. package/resources/apply/synth/synthesize.d.ts.map +0 -1
  126. package/resources/apply/synth/synthesize.js +0 -115
  127. package/resources/apply/synth/synthesize.js.map +0 -1
  128. package/src/local/seedpack-retire.test.ts +0 -499
  129. package/src/local/seedpack-retire.ts +0 -474
  130. package/src/resources/apply/declarative.integration.test.ts +0 -204
  131. package/src/resources/apply/declarative.test.ts +0 -132
  132. package/src/resources/apply/declarative.ts +0 -491
  133. package/src/resources/apply/synth/capstone.integration.test.ts +0 -134
  134. package/src/resources/apply/synth/project-track.integration.test.ts +0 -194
  135. package/src/resources/apply/synth/project-track.ts +0 -126
  136. package/src/resources/apply/synth/reader.test.ts +0 -90
  137. package/src/resources/apply/synth/reader.ts +0 -68
  138. package/src/resources/apply/synth/runtime.test.ts +0 -29
  139. package/src/resources/apply/synth/runtime.ts +0 -39
  140. package/src/resources/apply/synth/synthesize.test.ts +0 -109
  141. package/src/resources/apply/synth/synthesize.ts +0 -161
@@ -23,6 +23,15 @@
23
23
  // and what `stigmer up` compares with the server's digest before deciding
24
24
  // to push. `validate -f`, `push plugin --dry-run` and `push plugin` share one
25
25
  // description renderer so the author reads one vocabulary at every step.
26
+ //
27
+ // `readNextSteps` is what the install leaves the user to do, read from the
28
+ // servers the push produced: a sign-in an OAuth server needs (`stigmer
29
+ // connect mcp-server` runs it), the variables an API-key server wants and
30
+ // where they are asked, and, for a plugin that installed tools and no
31
+ // agent, the agent the tools still need. Best-effort by design: a server
32
+ // or a grant the CLI cannot read yields no line rather than a failed
33
+ // install, because the install itself succeeded. `stigmer up` does not
34
+ // read them: its plugin is the built-in assistant, not a user's act.
26
35
 
27
36
  import { readdirSync, readFileSync, statSync } from "node:fs";
28
37
  import { join } from "node:path";
@@ -48,6 +57,10 @@ import {
48
57
  PushPluginRequestSchema,
49
58
  type PluginMember,
50
59
  } from "@stigmer/protos/ai/stigmer/agentic/plugin/v1/io_pb";
60
+ import {
61
+ GetOAuthGrantStatusInputSchema,
62
+ OAuthConnectionHealth,
63
+ } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/io_pb";
51
64
  import { PluginDialect as PluginDialectProto } from "@stigmer/protos/ai/stigmer/agentic/plugin/v1/spec_pb";
52
65
  import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
53
66
  import type { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
@@ -390,6 +403,113 @@ export async function pushPlugin(
390
403
  export interface RenderPushOptions {
391
404
  /** Where the archive came from when it was not a folder: the marketplace's name and source. */
392
405
  readonly installedFrom?: string;
406
+ /** What the install leaves the user to do, from `readNextSteps`. */
407
+ readonly next?: readonly NextStep[];
408
+ }
409
+
410
+ /** One thing standing between an installed MCP server and its first tool call, or the agent the tools still need. */
411
+ export type NextStep =
412
+ | { readonly kind: "sign-in"; readonly server: string; readonly command: string }
413
+ | { readonly kind: "signed-in"; readonly server: string }
414
+ | {
415
+ readonly kind: "api-key";
416
+ readonly server: string;
417
+ readonly variables: readonly string[];
418
+ /** Where the variables are asked: the agent's first session, or `stigmer connect mcp-server --env`. */
419
+ readonly askedAt: "agent" | "connect";
420
+ readonly command?: string;
421
+ }
422
+ | { readonly kind: "add-to-agent"; readonly servers: readonly string[] };
423
+
424
+ /**
425
+ * What the install leaves the user to do, read from each MCP server the
426
+ * push produced. Best-effort: a server or grant this CLI cannot read yields
427
+ * no step, never a failure, because the install itself succeeded.
428
+ */
429
+ export async function readNextSteps(
430
+ client: Stigmer,
431
+ org: string,
432
+ members: readonly PluginMember[],
433
+ ): Promise<NextStep[]> {
434
+ const servers = members.filter((m) => m.kind === ApiResourceKind.mcp_server);
435
+ const hasAgent = members.some((m) => m.kind === ApiResourceKind.agent);
436
+ const steps: NextStep[] = [];
437
+ for (const member of servers) {
438
+ try {
439
+ const server = await client.mcpServer.getByReference({
440
+ org,
441
+ slug: member.slug,
442
+ });
443
+ const auth = server.spec?.auth;
444
+ const variables = Object.keys(server.spec?.env ?? {});
445
+ if (auth?.targetEnvVar) {
446
+ let connected = false;
447
+ try {
448
+ const grant = await client.mcpServer.getOAuthGrantStatus(
449
+ create(GetOAuthGrantStatusInputSchema, {
450
+ resourceId: server.metadata?.id ?? "",
451
+ org,
452
+ }),
453
+ );
454
+ connected =
455
+ grant.connected &&
456
+ grant.connectionHealth !==
457
+ OAuthConnectionHealth.OAUTH_CONNECTION_HEALTH_TOKEN_EXPIRED;
458
+ } catch {
459
+ // Fail closed: a grant the CLI cannot read is a sign-in still owed.
460
+ }
461
+ steps.push(
462
+ connected
463
+ ? { kind: "signed-in", server: member.slug }
464
+ : {
465
+ kind: "sign-in",
466
+ server: member.slug,
467
+ command: `stigmer connect mcp-server ${member.slug}`,
468
+ },
469
+ );
470
+ } else if (variables.length > 0) {
471
+ steps.push({
472
+ kind: "api-key",
473
+ server: member.slug,
474
+ variables,
475
+ askedAt: hasAgent ? "agent" : "connect",
476
+ ...(hasAgent
477
+ ? {}
478
+ : {
479
+ command: `stigmer connect mcp-server ${member.slug} --env ${variables.map((v) => `${v}=...`).join(" --env ")}`,
480
+ }),
481
+ });
482
+ }
483
+ } catch {
484
+ // A server the CLI cannot read has no line; the Installed section still names it.
485
+ }
486
+ }
487
+ if (!hasAgent && servers.length > 0) {
488
+ steps.push({
489
+ kind: "add-to-agent",
490
+ servers: servers.map((m) => m.slug),
491
+ });
492
+ }
493
+ return steps;
494
+ }
495
+
496
+ function describeNextStep(step: NextStep): string {
497
+ switch (step.kind) {
498
+ case "sign-in":
499
+ return `Sign in to ${step.server}: ${step.command}`;
500
+ case "signed-in":
501
+ return `${step.server}: signed in`;
502
+ case "api-key":
503
+ return step.askedAt === "agent"
504
+ ? `${step.server} needs ${step.variables.join(", ")}; the agent asks at its first session`
505
+ : `${step.server} needs ${step.variables.join(", ")}; set them when you connect: ${step.command ?? ""}`;
506
+ case "add-to-agent":
507
+ return `Add these tools to an agent: list ${step.servers.map((s) => `'${s}'`).join(", ")} under mcp_server_usages in an agent's YAML, or from the plugin's page in the console`;
508
+ default: {
509
+ const exhaustive: never = step;
510
+ return exhaustive;
511
+ }
512
+ }
393
513
  }
394
514
 
395
515
  /** The install as the user reads it: what landed, what was skipped, what to know. */
@@ -400,14 +520,20 @@ export function renderPushOutcome(
400
520
  const { plugin, members } = outcome;
401
521
  const warnings = plugin.status?.warnings ?? [];
402
522
  const counts = plugin.status?.materialized;
403
- const summary = [
404
- count(counts?.skills ?? 0, "skill"),
405
- count(counts?.mcpServers ?? 0, "MCP server"),
406
- count(counts?.agents ?? 0, "agent"),
407
- ...(counts !== undefined && counts.workflows > 0
408
- ? [count(counts.workflows, "workflow")]
409
- : []),
410
- ].join(", ");
523
+ // Only the kinds the plugin installed are named, as the console's
524
+ // `summariseInstall` names them: most catalogue plugins install tools
525
+ // alone, and "0 skills, 1 MCP server, 0 agents" reads as three facts.
526
+ const named = (
527
+ [
528
+ [counts?.skills ?? 0, "skill"],
529
+ [counts?.mcpServers ?? 0, "MCP server"],
530
+ [counts?.agents ?? 0, "agent"],
531
+ [counts?.workflows ?? 0, "workflow"],
532
+ ] as const
533
+ )
534
+ .filter(([n]) => n > 0)
535
+ .map(([n, noun]) => count(n, noun));
536
+ const summary = named.length === 0 ? "nothing installed" : named.join(", ");
411
537
  const headline = `Installed plugin '${plugin.metadata?.slug ?? plugin.spec?.name ?? ""}' (${summary})`;
412
538
  const result =
413
539
  warnings.length === 0
@@ -447,9 +573,15 @@ export function renderPushOutcome(
447
573
  const section = result.addSection("Warnings");
448
574
  for (const warning of warnings) section.item(warning.message);
449
575
  }
576
+ const next = options.next ?? [];
577
+ if (next.length > 0) {
578
+ const section = result.addSection("Next");
579
+ for (const step of next) section.item(describeNextStep(step));
580
+ }
450
581
  return result.withData({
451
582
  plugin: toJson(PluginSchema, plugin),
452
583
  members: members.map((m) => toJson(PluginMemberSchema, m)),
584
+ ...(options.next !== undefined && { next: options.next }),
453
585
  });
454
586
  }
455
587
 
@@ -8,7 +8,6 @@ describe("schemaForValidate", () => {
8
8
  expect(schemaForValidate(ApiResourceKind.agent)).toBeDefined();
9
9
  expect(schemaForValidate(ApiResourceKind.workflow)).toBeDefined();
10
10
  expect(schemaForValidate(ApiResourceKind.mcp_server)).toBeDefined();
11
- expect(schemaForValidate(ApiResourceKind.project)).toBeDefined();
12
11
  });
13
12
 
14
13
  it("returns undefined for non-file-based kinds", () => {
@@ -10,7 +10,6 @@ import { AgentSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb"
10
10
  import { McpServerSchema } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/api_pb";
11
11
  import { type Workflow, WorkflowSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/api_pb";
12
12
  import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
13
- import { ProjectSchema } from "@stigmer/protos/ai/stigmer/tenancy/project/v1/api_pb";
14
13
  import { decodeWorkflowTaskConfigs } from "./task-configs.js";
15
14
 
16
15
  // Exported for the verb/dispatch conformance suite (registry/registry.test.ts),
@@ -21,7 +20,6 @@ export const VALIDATE_SCHEMAS: ReadonlyMap<ApiResourceKind, DescMessage> = new M
21
20
  [ApiResourceKind.agent, AgentSchema],
22
21
  [ApiResourceKind.workflow, WorkflowSchema],
23
22
  [ApiResourceKind.mcp_server, McpServerSchema],
24
- [ApiResourceKind.project, ProjectSchema],
25
23
  ]);
26
24
 
27
25
  export function schemaForValidate(kind: ApiResourceKind): DescMessage | undefined {
@@ -1,63 +0,0 @@
1
- import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
2
- import { type Stigmer } from "@stigmer/sdk";
3
- /**
4
- * The seedpack Project's slug, as every release before this one wrote it
5
- * (the server derived it from `metadata.name` in the seedpack's manifest).
6
- * Pinned bytes of installs that predate this release.
7
- */
8
- export declare const SEEDPACK_PROJECT_SLUG = "stigmer-seedpack";
9
- /**
10
- * The marker older releases wrote in the data dir to skip an unchanged
11
- * seedpack. Nothing reads it any more; the retire removes it so a data dir
12
- * carries no trace of a mechanism that no longer exists.
13
- */
14
- export declare const SEEDPACK_MARKER_FILE = ".seedpack-bootstrapped";
15
- /** A member of the seedpack Project, addressed the way the Project stored it. */
16
- export interface SeedpackMember {
17
- readonly kind: ApiResourceKind;
18
- readonly org: string;
19
- readonly slug: string;
20
- }
21
- export type MemberOutcome = {
22
- readonly action: "removed";
23
- readonly member: SeedpackMember;
24
- } | {
25
- readonly action: "already-gone";
26
- readonly member: SeedpackMember;
27
- } | {
28
- readonly action: "adopted";
29
- readonly member: SeedpackMember;
30
- /** The plugin that now manages the row: its slug, or its id when the plugin row is gone. */
31
- readonly byPlugin: string;
32
- } | {
33
- readonly action: "kept-referenced";
34
- readonly member: SeedpackMember;
35
- /** The referrers, as "agent 'org/slug'". */
36
- readonly by: readonly string[];
37
- } | {
38
- readonly action: "kept-refused";
39
- readonly member: SeedpackMember;
40
- /** The server's sentence. */
41
- readonly reason: string;
42
- };
43
- export type RetireResult = {
44
- readonly present: false;
45
- } | {
46
- readonly present: true;
47
- readonly outcomes: readonly MemberOutcome[];
48
- /** False when the Project row itself could not be deleted; the reason is reported. */
49
- readonly projectRemoved: boolean;
50
- readonly projectRefusal?: string;
51
- };
52
- export interface RetireOptions {
53
- /** The local data dir holding the marker file. */
54
- readonly markerDir: string;
55
- }
56
- /**
57
- * Retire the seedpack Project the system org may hold. Idempotent: no
58
- * Project, no work beyond one read and a stale marker's removal.
59
- */
60
- export declare function retireSeedpack(stigmer: Stigmer, options: RetireOptions): Promise<RetireResult>;
61
- /** The report `stigmer up` prints, one block on stderr through `say`. */
62
- export declare function renderRetireReport(result: RetireResult, say: (line: string) => void): void;
63
- //# sourceMappingURL=seedpack-retire.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"seedpack-retire.d.ts","sourceRoot":"","sources":["../../src/local/seedpack-retire.ts"],"names":[],"mappings":"AAyCA,OAAO,EAAE,eAAe,EAAE,MAAM,qFAAqF,CAAC;AAEtH,OAAO,EAAE,KAAK,OAAO,EAAc,MAAM,cAAc,CAAC;AAOxD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,qBAAqB,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAA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,WAAW,aAAa;IAC5B,kDAAkD;IAClD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CAmCvB;AAED,yEAAyE;AACzE,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC1B,IAAI,CAwDN"}
@@ -1,361 +0,0 @@
1
- // Retiring the seedpack: the one-time removal, on an existing local install,
2
- // of the system content an older release seeded (a `stigmer-seedpack`
3
- // Project in the system org and its member agents, skills, MCP servers and
4
- // workflows). Newer releases seed nothing but the default plugins, so the
5
- // rows have no owner left; `stigmer up` runs this step once and reports
6
- // exactly what it did. This module goes when the Project kind goes.
7
- //
8
- // Shape: the client-side mirror of the server's plugin uninstall
9
- // (GuardMembersUnreferenced then CascadeDeleteMembers in the plugin
10
- // controller). Before anything is deleted, every agent the identity can see
11
- // is read and its spec walked for ApiResourceReferences, the same walk the
12
- // server's ValidateReferences runs; a member some user-authored agent still
13
- // references is KEPT and the report names the referrer, because an
14
- // individual delete never refuses on that ground and a dangling reference
15
- // found at the user's next session is the worse outcome. The one deliberate
16
- // difference from the server's guard, and its reason: the guard refuses the
17
- // whole uninstall and tells the user to detach first; a retire inside `up`
18
- // has no user to ask, so it keeps only what is referenced and removes the
19
- // rest. Members referencing each other are the seedpack's own business and
20
- // never keep anything. A member the default plugins ADOPTED (the bootstrap
21
- // runs first, and the plugin push takes over the system-content row it
22
- // replaces in place, so the seedpack's `assistant` keeps its id and every
23
- // conversation with it) now carries `stigmer.ai/plugin` and is reported as
24
- // such, never deleted: the store says what was adopted, this module keeps
25
- // no list of its own. Deletes run children-first in reference order
26
- // (workflows, agents, skills, MCP servers) through the same SDK calls
27
- // `stigmer delete` binds, so a refusal reaches the user as the server's
28
- // own sentence; the Project row goes last and the marker file with it. A
29
- // failure part-way leaves a Project whose members are still listed, and the
30
- // next `up` converges.
31
- //
32
- // Known limit, shared with the server's guard: a workflow names the agent it
33
- // calls by a DSL string, not a reference, so a user workflow that calls a
34
- // seedpack agent is not seen and not protected.
35
- import { existsSync, rmSync } from "node:fs";
36
- import { join } from "node:path";
37
- import { reflect } from "@bufbuild/protobuf/reflect";
38
- import { AgentSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb";
39
- import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
40
- import { isNotFound } from "@stigmer/sdk";
41
- import { log } from "../logger.js";
42
- import { defaultRegistry } from "../registry/index.js";
43
- import { DELETE_HANDLERS } from "../resources/delete.js";
44
- import { getterFor } from "../resources/get-bindings.js";
45
- import { SYSTEM_ORG } from "./system-org.js";
46
- /**
47
- * The seedpack Project's slug, as every release before this one wrote it
48
- * (the server derived it from `metadata.name` in the seedpack's manifest).
49
- * Pinned bytes of installs that predate this release.
50
- */
51
- export const SEEDPACK_PROJECT_SLUG = "stigmer-seedpack";
52
- /**
53
- * The marker older releases wrote in the data dir to skip an unchanged
54
- * seedpack. Nothing reads it any more; the retire removes it so a data dir
55
- * carries no trace of a mechanism that no longer exists.
56
- */
57
- export const SEEDPACK_MARKER_FILE = ".seedpack-bootstrapped";
58
- /** The order members are removed in: a referrer before what it references. */
59
- const REMOVAL_ORDER = [
60
- ApiResourceKind.workflow,
61
- ApiResourceKind.agent,
62
- ApiResourceKind.skill,
63
- ApiResourceKind.mcp_server,
64
- ];
65
- const REFERRER_PAGE_SIZE = 100;
66
- /**
67
- * Retire the seedpack Project the system org may hold. Idempotent: no
68
- * Project, no work beyond one read and a stale marker's removal.
69
- */
70
- export async function retireSeedpack(stigmer, options) {
71
- const project = await readProject(stigmer);
72
- if (project === undefined) {
73
- removeMarker(options.markerDir);
74
- return { present: false };
75
- }
76
- const members = (project.members ?? []).map(toMember);
77
- const referrers = await indexReferrers(stigmer, members);
78
- const pluginSlugs = new Map();
79
- const outcomes = [];
80
- for (const member of inRemovalOrder(members)) {
81
- const by = referrers.get(keyOf(member));
82
- if (by !== undefined) {
83
- outcomes.push({ action: "kept-referenced", member, by });
84
- continue;
85
- }
86
- outcomes.push(await removeMember(stigmer, member, pluginSlugs));
87
- }
88
- let projectRemoved = true;
89
- let projectRefusal;
90
- try {
91
- await stigmer.project.delete(project.id);
92
- }
93
- catch (error) {
94
- projectRemoved = false;
95
- projectRefusal = messageOf(error);
96
- log.warn("seedpack project delete refused", { error: projectRefusal });
97
- }
98
- removeMarker(options.markerDir);
99
- return projectRefusal === undefined
100
- ? { present: true, outcomes, projectRemoved }
101
- : { present: true, outcomes, projectRemoved, projectRefusal };
102
- }
103
- /** The report `stigmer up` prints, one block on stderr through `say`. */
104
- export function renderRetireReport(result, say) {
105
- if (!result.present)
106
- return;
107
- const removed = result.outcomes.filter((outcome) => outcome.action === "removed").length;
108
- const adopted = result.outcomes.filter((outcome) => outcome.action === "adopted").length;
109
- const kept = result.outcomes.filter((outcome) => outcome.action === "kept-referenced" ||
110
- outcome.action === "kept-refused");
111
- const tail = [
112
- adopted === 0 ? "" : `${count(adopted, "resource")} now managed by a plugin`,
113
- kept.length === 0 ? "" : `kept ${count(kept.length, "resource")}`,
114
- ].filter((part) => part !== "");
115
- say(`Retired the system content an older release installed: removed ${count(removed, "resource")}` +
116
- (tail.length === 0 ? "." : `, ${tail.join(", ")}.`));
117
- for (const outcome of result.outcomes) {
118
- switch (outcome.action) {
119
- case "removed":
120
- case "already-gone":
121
- break;
122
- case "adopted":
123
- say(` ${describe(outcome.member)} is now managed by plugin '${outcome.byPlugin}'; its instances and conversations continue`);
124
- break;
125
- case "kept-referenced":
126
- say(` kept ${describe(outcome.member)}: referenced by ${outcome.by.join(", ")}`);
127
- break;
128
- case "kept-refused":
129
- say(` kept ${describe(outcome.member)}: ${outcome.reason}`);
130
- break;
131
- default: {
132
- const exhaustive = outcome;
133
- throw new Error(`unhandled outcome ${String(exhaustive)}`);
134
- }
135
- }
136
- }
137
- if (kept.length > 0) {
138
- say(" A kept resource's icon no longer resolves. Once its referrer is edited, remove it with 'stigmer delete <kind> <org>/<slug>'.");
139
- }
140
- if (!result.projectRemoved) {
141
- say(` The '${SEEDPACK_PROJECT_SLUG}' project row could not be removed: ${result.projectRefusal ?? "unknown reason"}. Run 'stigmer up' again to retry.`);
142
- }
143
- }
144
- async function readProject(stigmer) {
145
- try {
146
- const project = await stigmer.project.getByReference({
147
- org: SYSTEM_ORG,
148
- slug: SEEDPACK_PROJECT_SLUG,
149
- });
150
- return { id: project.metadata?.id ?? "", members: project.spec?.members };
151
- }
152
- catch (error) {
153
- if (isNotFound(error))
154
- return undefined;
155
- throw error;
156
- }
157
- }
158
- function toMember(ref) {
159
- // Stored references are absolute, but an empty org can only mean the
160
- // Project's own.
161
- return { kind: ref.kind, org: ref.org || SYSTEM_ORG, slug: ref.slug };
162
- }
163
- function keyOf(member) {
164
- return `${member.kind}:${member.org}/${member.slug}`;
165
- }
166
- function inRemovalOrder(members) {
167
- const ordered = [];
168
- for (const kind of REMOVAL_ORDER) {
169
- ordered.push(...members.filter((member) => member.kind === kind));
170
- }
171
- ordered.push(...members.filter((member) => !REMOVAL_ORDER.includes(member.kind)));
172
- return ordered;
173
- }
174
- /**
175
- * Every member some agent outside the seedpack references, mapped to the
176
- * agents that reference it. Reads each agent in every organization the
177
- * identity sees: the listing is search-backed and carries no spec.
178
- */
179
- async function indexReferrers(stigmer, members) {
180
- const memberKeys = new Set(members.map(keyOf));
181
- const referrers = new Map();
182
- if (memberKeys.size === 0)
183
- return referrers;
184
- const orgs = (await stigmer.organization.findMyOrganizations()).entries
185
- .map((org) => org.metadata?.slug ?? "")
186
- .filter((slug) => slug !== "");
187
- for (const org of orgs) {
188
- for (let page = 1;; page += 1) {
189
- const listing = await stigmer.agent.list({
190
- org,
191
- page: { num: page, size: REFERRER_PAGE_SIZE },
192
- });
193
- for (const entry of listing.entries) {
194
- const self = `${ApiResourceKind.agent}:${entry.org || org}/${entry.slug}`;
195
- if (memberKeys.has(self))
196
- continue;
197
- const agent = await stigmer.agent.get(entry.id);
198
- const label = `agent '${entry.org || org}/${entry.slug}'`;
199
- for (const ref of collectSpecReferences(AgentSchema, agent)) {
200
- const key = `${ref.kind}:${ref.org || org}/${ref.slug}`;
201
- if (!memberKeys.has(key))
202
- continue;
203
- const list = referrers.get(key) ?? [];
204
- if (!list.includes(label))
205
- list.push(label);
206
- referrers.set(key, list);
207
- }
208
- }
209
- if (page >= listing.totalPages)
210
- break;
211
- }
212
- }
213
- return referrers;
214
- }
215
- /**
216
- * The membership label the server stamps on every resource a plugin
217
- * materialises; its value is the plugin's id. Read here, never written: a
218
- * seedpack member carrying it was adopted by a default plugin moments ago.
219
- */
220
- const PLUGIN_LABEL = "stigmer.ai/plugin";
221
- async function removeMember(stigmer, member, pluginSlugs) {
222
- const getter = getterFor(member.kind);
223
- const deleter = DELETE_HANDLERS.get(member.kind);
224
- if (getter === undefined || deleter === undefined) {
225
- return {
226
- action: "kept-refused",
227
- member,
228
- reason: "this CLI has no delete for that kind",
229
- };
230
- }
231
- let id;
232
- try {
233
- const found = await getter(stigmer, {
234
- kind: "ref",
235
- org: member.org,
236
- slug: member.slug,
237
- });
238
- const metadata = found.message.metadata;
239
- id = metadata?.id ?? "";
240
- const pluginId = metadata?.labels?.[PLUGIN_LABEL];
241
- if (pluginId !== undefined && pluginId !== "") {
242
- return {
243
- action: "adopted",
244
- member,
245
- byPlugin: await pluginSlugOf(stigmer, pluginId, pluginSlugs),
246
- };
247
- }
248
- }
249
- catch (error) {
250
- if (isNotFound(error))
251
- return { action: "already-gone", member };
252
- return { action: "kept-refused", member, reason: messageOf(error) };
253
- }
254
- try {
255
- await deleter(stigmer, id, false);
256
- return { action: "removed", member };
257
- }
258
- catch (error) {
259
- if (isNotFound(error))
260
- return { action: "already-gone", member };
261
- return { action: "kept-refused", member, reason: messageOf(error) };
262
- }
263
- }
264
- /** The adopting plugin's slug, read once per id; a plugin row that is gone names itself. */
265
- async function pluginSlugOf(stigmer, pluginId, cache) {
266
- const known = cache.get(pluginId);
267
- if (known !== undefined)
268
- return known;
269
- let slug = pluginId;
270
- try {
271
- slug = (await stigmer.plugin.get(pluginId)).metadata?.slug || pluginId;
272
- }
273
- catch (error) {
274
- if (!isNotFound(error))
275
- throw error;
276
- }
277
- cache.set(pluginId, slug);
278
- return slug;
279
- }
280
- function removeMarker(markerDir) {
281
- const marker = join(markerDir, SEEDPACK_MARKER_FILE);
282
- if (existsSync(marker))
283
- rmSync(marker, { force: true });
284
- }
285
- function describe(member) {
286
- const info = defaultRegistry().getByKind(member.kind);
287
- const noun = info?.singular ?? ApiResourceKind[member.kind] ?? "resource";
288
- return `${noun} '${member.org}/${member.slug}'`;
289
- }
290
- function count(n, noun) {
291
- return `${n} ${noun}${n === 1 ? "" : "s"}`;
292
- }
293
- function messageOf(error) {
294
- return error instanceof Error ? error.message : String(error);
295
- }
296
- // --- The reference walk: every ApiResourceReference in a resource's spec ---
297
- //
298
- // The same traversal the server runs in its ValidateReferences step and its
299
- // plugin uninstall guard (singular, repeated and map-valued message fields,
300
- // recursively), so a reference field added to a spec is seen here without a
301
- // change. Server-internal there and not exported to clients; mirrored here
302
- // for the one client that asks the reverse question.
303
- const API_RESOURCE_REFERENCE_TYPE = "ai.stigmer.commons.apiresource.ApiResourceReference";
304
- function collectSpecReferences(schema, msg) {
305
- const refs = [];
306
- const root = reflect(schema, msg);
307
- const spec = root.fields.find((field) => field.name === "spec" && field.fieldKind === "message");
308
- if (spec === undefined || spec.fieldKind !== "message" || !root.isSet(spec)) {
309
- return refs;
310
- }
311
- walk(root.get(spec), (ref) => {
312
- refs.push({
313
- kind: numberField(ref, "kind"),
314
- slug: stringField(ref, "slug"),
315
- org: stringField(ref, "org"),
316
- });
317
- });
318
- return refs;
319
- }
320
- function walk(msg, fn) {
321
- for (const field of msg.fields) {
322
- if (field.fieldKind === "list") {
323
- if (field.listKind !== "message")
324
- continue;
325
- for (const item of msg.get(field))
326
- visit(item, fn);
327
- }
328
- else if (field.fieldKind === "map") {
329
- if (field.mapKind !== "message")
330
- continue;
331
- for (const [, value] of msg.get(field)) {
332
- visit(value, fn);
333
- }
334
- }
335
- else if (field.fieldKind === "message") {
336
- if (msg.isSet(field))
337
- visit(msg.get(field), fn);
338
- }
339
- }
340
- }
341
- function visit(sub, fn) {
342
- if (sub.desc.typeName === API_RESOURCE_REFERENCE_TYPE)
343
- fn(sub);
344
- else
345
- walk(sub, fn);
346
- }
347
- function stringField(msg, name) {
348
- const field = msg.fields.find((f) => f.name === name);
349
- if (field === undefined)
350
- return "";
351
- const value = msg.get(field);
352
- return typeof value === "string" ? value : "";
353
- }
354
- function numberField(msg, name) {
355
- const field = msg.fields.find((f) => f.name === name);
356
- if (field === undefined)
357
- return 0;
358
- const value = msg.get(field);
359
- return typeof value === "number" ? value : 0;
360
- }
361
- //# sourceMappingURL=seedpack-retire.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"seedpack-retire.js","sourceRoot":"","sources":["../../src/local/seedpack-retire.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,sEAAsE;AACtE,2EAA2E;AAC3E,0EAA0E;AAC1E,wEAAwE;AACxE,oEAAoE;AACpE,EAAE;AACF,iEAAiE;AACjE,oEAAoE;AACpE,4EAA4E;AAC5E,2EAA2E;AAC3E,4EAA4E;AAC5E,mEAAmE;AACnE,0EAA0E;AAC1E,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,0EAA0E;AAC1E,2EAA2E;AAC3E,2EAA2E;AAC3E,uEAAuE;AACvE,0EAA0E;AAC1E,2EAA2E;AAC3E,0EAA0E;AAC1E,oEAAoE;AACpE,sEAAsE;AACtE,wEAAwE;AACxE,yEAAyE;AACzE,4EAA4E;AAC5E,uBAAuB;AACvB,EAAE;AACF,6EAA6E;AAC7E,0EAA0E;AAC1E,gDAAgD;AAEhD,OAAO,EAAE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