@stigmer/cli 3.18.0-dev.20260918103812 → 3.18.1-dev.20260919070736

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 (109) hide show
  1. package/commands/bootstrap.d.ts +3 -0
  2. package/commands/bootstrap.d.ts.map +1 -0
  3. package/commands/bootstrap.js +75 -0
  4. package/commands/bootstrap.js.map +1 -0
  5. package/commands/marketplace.d.ts.map +1 -1
  6. package/commands/marketplace.js +7 -7
  7. package/commands/marketplace.js.map +1 -1
  8. package/config/resolve.d.ts.map +1 -1
  9. package/config/resolve.js +8 -7
  10. package/config/resolve.js.map +1 -1
  11. package/local/bootstrap.d.ts +32 -13
  12. package/local/bootstrap.d.ts.map +1 -1
  13. package/local/bootstrap.js +105 -64
  14. package/local/bootstrap.js.map +1 -1
  15. package/local/daemon/launch.d.ts +1 -1
  16. package/local/daemon/launch.d.ts.map +1 -1
  17. package/local/paths.d.ts +1 -1
  18. package/local/paths.js +1 -1
  19. package/local/plugins/defaults.d.ts +27 -7
  20. package/local/plugins/defaults.d.ts.map +1 -1
  21. package/local/plugins/defaults.js +55 -28
  22. package/local/plugins/defaults.js.map +1 -1
  23. package/local/runtime/runtimes-install.d.ts.map +1 -1
  24. package/local/runtime/runtimes-install.js +7 -4
  25. package/local/runtime/runtimes-install.js.map +1 -1
  26. package/local/seedpack-retire.d.ts +63 -0
  27. package/local/seedpack-retire.d.ts.map +1 -0
  28. package/local/seedpack-retire.js +361 -0
  29. package/local/seedpack-retire.js.map +1 -0
  30. package/local/system-org.d.ts +15 -0
  31. package/local/system-org.d.ts.map +1 -0
  32. package/local/system-org.js +57 -0
  33. package/local/system-org.js.map +1 -0
  34. package/marketplace/config.d.ts +3 -1
  35. package/marketplace/config.d.ts.map +1 -1
  36. package/marketplace/config.js +24 -11
  37. package/marketplace/config.js.map +1 -1
  38. package/marketplace/github.d.ts +37 -0
  39. package/marketplace/github.d.ts.map +1 -1
  40. package/marketplace/github.js +70 -1
  41. package/marketplace/github.js.map +1 -1
  42. package/marketplace/install.d.ts +13 -6
  43. package/marketplace/install.d.ts.map +1 -1
  44. package/marketplace/install.js +63 -16
  45. package/marketplace/install.js.map +1 -1
  46. package/marketplace/official.js +4 -4
  47. package/marketplace/official.js.map +1 -1
  48. package/marketplace/render.d.ts.map +1 -1
  49. package/marketplace/render.js +10 -4
  50. package/marketplace/render.js.map +1 -1
  51. package/package.json +7 -7
  52. package/program.js +2 -2
  53. package/program.js.map +1 -1
  54. package/resources/apply/declarative.js +2 -2
  55. package/resources/apply/declarative.js.map +1 -1
  56. package/resources/plugin.d.ts.map +1 -1
  57. package/resources/plugin.js +12 -9
  58. package/resources/plugin.js.map +1 -1
  59. package/src/commands/bootstrap.test.ts +253 -0
  60. package/src/commands/bootstrap.ts +91 -0
  61. package/src/commands/install.test.ts +28 -9
  62. package/src/commands/marketplace.test.ts +28 -14
  63. package/src/commands/marketplace.ts +9 -7
  64. package/src/config/resolve.test.ts +2 -2
  65. package/src/config/resolve.ts +8 -7
  66. package/src/local/bootstrap.test.ts +110 -38
  67. package/src/local/bootstrap.ts +179 -89
  68. package/src/local/daemon/launch.ts +1 -1
  69. package/src/local/paths.ts +1 -1
  70. package/src/local/plugins/defaults.test.ts +46 -13
  71. package/src/local/plugins/defaults.ts +77 -34
  72. package/src/local/runtime/runtimes-install.test.ts +2 -0
  73. package/src/local/runtime/runtimes-install.ts +7 -4
  74. package/src/local/seedpack-retire.test.ts +499 -0
  75. package/src/local/seedpack-retire.ts +474 -0
  76. package/src/local/system-org.test.ts +124 -0
  77. package/src/local/system-org.ts +63 -0
  78. package/src/marketplace/__fixtures__/cursor-marketplace.ts +5 -2
  79. package/src/marketplace/config.test.ts +47 -22
  80. package/src/marketplace/config.ts +27 -12
  81. package/src/marketplace/github.test.ts +77 -1
  82. package/src/marketplace/github.ts +115 -1
  83. package/src/marketplace/install.test.ts +84 -17
  84. package/src/marketplace/install.ts +73 -15
  85. package/src/marketplace/official.ts +4 -4
  86. package/src/marketplace/read.test.ts +1 -1
  87. package/src/marketplace/render.ts +13 -4
  88. package/src/program.ts +2 -2
  89. package/src/resources/apply/declarative.integration.test.ts +2 -2
  90. package/src/resources/apply/declarative.ts +2 -2
  91. package/src/resources/connect/discover.test.ts +1 -1
  92. package/src/resources/plugin.ts +11 -10
  93. package/commands/seedpack.d.ts +0 -3
  94. package/commands/seedpack.d.ts.map +0 -1
  95. package/commands/seedpack.js +0 -98
  96. package/commands/seedpack.js.map +0 -1
  97. package/local/seedpack/apply.d.ts +0 -72
  98. package/local/seedpack/apply.d.ts.map +0 -1
  99. package/local/seedpack/apply.js +0 -145
  100. package/local/seedpack/apply.js.map +0 -1
  101. package/local/seedpack/content.d.ts +0 -61
  102. package/local/seedpack/content.d.ts.map +0 -1
  103. package/local/seedpack/content.js +0 -178
  104. package/local/seedpack/content.js.map +0 -1
  105. package/src/commands/seedpack.ts +0 -116
  106. package/src/local/seedpack/apply.test.ts +0 -287
  107. package/src/local/seedpack/apply.ts +0 -199
  108. package/src/local/seedpack/content.test.ts +0 -169
  109. package/src/local/seedpack/content.ts +0 -222
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../src/local/plugins/defaults.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,KAAK,OAAO,EAAc,MAAM,cAAc,CAAC;AAKxD,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,+BAA+B,CAAC;AAQvC,MAAM,WAAW,kBAAkB;IACjC,0DAA0D;IAC1D,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,qCAAqC;IACrC,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,qBAAqB;IACpC,+FAA+F;IAC/F,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,QAAQ,CAAC,QAAQ,CAAC,EAAE,sBAAsB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AC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;CAC/B;AAED,iFAAiF;AACjF,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;CACnC;AAED,MAAM,MAAM,oBAAoB,GAC5B;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEN,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,QAAQ,EAAE,SAAS,oBAAoB,EAAE,CAAC;IACnD,6DAA6D;IAC7D,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,CAAC,EAAE,sBAAsB,GAChC,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC,CAerC;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,kBAAkB,EACxB,QAAQ,EAAE,SAAS,eAAe,EAAE,EACpC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,oBAAoB,CAAC,CA2B/B"}
@@ -1,48 +1,75 @@
1
- // The default plugins a fresh local backend is bootstrapped with: the
2
- // `defaults` list of the official marketplace, installed in order into the
3
- // system org as public, so the global default-agent lookup and cross-org
4
- // references find them exactly where the seedpack used to put them.
1
+ // The default plugins a backend is bootstrapped with: the `defaults` list of
2
+ // the official marketplace, installed in order into the system org as
3
+ // public, so the global default-agent lookup and cross-org references find
4
+ // them.
5
5
  //
6
- // Idempotent by the server's own identity, not a marker file: before each
7
- // push the entry is prepared (walked, zipped, hashed) and the org's plugin
8
- // of that name is read back; when its digest equals the prepared archive's,
9
- // it is READY and it is public, there is nothing to do and nothing is sent.
10
- // A second `stigmer up` therefore pushes nothing, and a `stigmer up` after
11
- // an upgrade pushes exactly the entries whose content changed. The record is
12
- // the server, so any machine that reaches the same backend sees the same
13
- // answer (the seedpack's cloud-mode rule, made the only rule).
6
+ // Two phases, deliberately separate. Preparing (resolve the official tree,
7
+ // which may acquire `@stigmer/plugins` at the CLI's version; walk, zip and
8
+ // hash every default) needs no backend and is all-or-nothing: the catalogue
9
+ // is ours and validated on CI, so a default that cannot be prepared is a
10
+ // release defect, not a condition to install around. Installing pushes the
11
+ // prepared archives and is best-effort per entry: one default failing to
12
+ // land does not stop the next, and the caller decides how to surface the
13
+ // failures. The split lets `stigmer up` hold every replacement in hand
14
+ // before it retires what the replacement supersedes (local/bootstrap.ts).
14
15
  //
15
- // Best-effort per entry: one default failing to install does not stop the
16
- // next, and the caller decides how to surface the failures (the daemon
17
- // launcher warns and names `stigmer install <name>`).
16
+ // Idempotent by the server's own identity, not a marker file: before each
17
+ // push the org's plugin of that name is read back; when its digest equals the
18
+ // prepared archive's, it is READY and it is public, there is nothing to do
19
+ // and nothing is sent. A second `stigmer up` therefore pushes nothing, and a
20
+ // `stigmer up` after an upgrade pushes exactly the entries whose content
21
+ // changed. The record is the server, so any machine that reaches the same
22
+ // backend sees the same answer.
18
23
  import { isNotFound } from "@stigmer/sdk";
19
24
  import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
20
25
  import { PluginState } from "@stigmer/protos/ai/stigmer/agentic/plugin/v1/status_pb";
26
+ import { CliExitError } from "../../errors/cli-exit-error.js";
27
+ import { ExitCode } from "../../errors/exit-codes.js";
21
28
  import { log } from "../../logger.js";
22
29
  import { VERSION } from "../../version.js";
23
30
  import { resolveOfficialMarketplace, } from "../../marketplace/official.js";
24
31
  import { readMarketplaceTree } from "../../marketplace/read.js";
25
32
  import { prepareEntry } from "../../marketplace/install.js";
26
- import { pushPrepared, } from "../../resources/plugin.js";
27
- /** Install every default the official marketplace names, in order, skipping what the backend already holds. */
28
- export async function installDefaultPlugins(deps, options) {
29
- const official = resolveOfficialMarketplace(options.official);
30
- const tree = readMarketplaceTree(official.dir, "the official marketplace");
31
- const outcomes = [];
33
+ import { count, pushPrepared, } from "../../resources/plugin.js";
34
+ /**
35
+ * Phase 1: every default the official marketplace names, prepared in the
36
+ * marketplace's order. Throws when the tree cannot be resolved, offers less
37
+ * than it lists (the library drops an entry it cannot install with a
38
+ * warning, which for a user's marketplace is `show`'s business and for ours
39
+ * is a broken release), or any default cannot be prepared; nothing is
40
+ * returned half-ready.
41
+ */
42
+ export async function prepareDefaultPlugins(official) {
43
+ const resolved = resolveOfficialMarketplace(official);
44
+ const tree = readMarketplaceTree(resolved.dir, "the official marketplace");
45
+ if (tree.warnings.length > 0) {
46
+ throw new CliExitError(`the official marketplace at ${resolved.dir} lists ${count(tree.warnings.length, "plugin")} this CLI cannot install`, ExitCode.General, tree.warnings.map((finding) => finding.message));
47
+ }
48
+ const prepared = [];
32
49
  for (const name of tree.marketplace.defaults) {
50
+ prepared.push({ name, push: await prepareEntry(tree, name) });
51
+ }
52
+ return prepared;
53
+ }
54
+ /**
55
+ * Phase 2: install the prepared defaults into `org`, skipping what the
56
+ * backend already holds. Best-effort per entry.
57
+ */
58
+ export async function installPreparedDefaults(deps, prepared, org) {
59
+ const outcomes = [];
60
+ for (const { name, push } of prepared) {
33
61
  try {
34
- const prepared = await prepareEntry(tree, name);
35
- if (await isAlreadyInstalled(deps.stigmer, options.org, prepared)) {
36
- outcomes.push({ name, action: "up-to-date", digest: prepared.digest });
62
+ if (await isAlreadyInstalled(deps.stigmer, org, push)) {
63
+ outcomes.push({ name, action: "up-to-date", digest: push.digest });
37
64
  continue;
38
65
  }
39
66
  deps.info(`Installing default plugin '${name}'…`);
40
- await pushPrepared(deps.stigmer, prepared, {
41
- org: options.org,
67
+ await pushPrepared(deps.stigmer, push, {
68
+ org,
42
69
  visibility: ApiResourceVisibility.visibility_public,
43
- message: `default plugin, installed by stigmer up (${VERSION})`,
70
+ message: `default plugin, installed by ${deps.verb} (${VERSION})`,
44
71
  });
45
- outcomes.push({ name, action: "installed", digest: prepared.digest });
72
+ outcomes.push({ name, action: "installed", digest: push.digest });
46
73
  }
47
74
  catch (error) {
48
75
  const message = error instanceof Error ? error.message : String(error);
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../../src/local/plugins/defaults.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,2EAA2E;AAC3E,yEAAyE;AACzE,oEAAoE;AACpE,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,6EAA6E;AAC7E,yEAAyE;AACzE,+DAA+D;AAC/D,EAAE;AACF,0EAA0E;AAC1E,uEAAuE;AACvE,sDAAsD;AAEtD,OAAO,EAAgB,UAAU,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,wDAAwD,CAAC;AACrF,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAEL,0BAA0B,GAC3B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D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,CAAC,MAAM,CAAC,KAAK,KAAK,WAAW,CAAC,KAAK;QAC3C,QAAQ,CAAC,QAAQ,EAAE,UAAU,KAAK,qBAAqB,CAAC,iBAAiB,CAC1E,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"runtimes-install.d.ts","sourceRoot":"","sources":["../../../src/local/runtime/runtimes-install.ts"],"names":[],"mappings":"AAYA,wDAAwD;AACxD,MAAM,MAAM,UAAU,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;AAEpE;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAS3D;AAMD,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CA2B7E;AAKD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAE5D"}
1
+ {"version":3,"file":"runtimes-install.d.ts","sourceRoot":"","sources":["../../../src/local/runtime/runtimes-install.ts"],"names":[],"mappings":"AAaA,wDAAwD;AACxD,MAAM,MAAM,UAAU,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;AAEpE;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAS3D;AAMD,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CA2B7E;AAOD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAE5D"}
@@ -6,6 +6,7 @@
6
6
  import { execFileSync } from "node:child_process";
7
7
  import { existsSync, mkdirSync, writeFileSync } from "node:fs";
8
8
  import { join } from "node:path";
9
+ import { isReleaseVersion } from "@stigmer/plugin-package/client";
9
10
  import { CliExitError } from "../../errors/cli-exit-error.js";
10
11
  import { ExitCode } from "../../errors/exit-codes.js";
11
12
  /**
@@ -51,10 +52,12 @@ export function npmInstallIntoRuntimes(installDir, spec) {
51
52
  ]);
52
53
  }
53
54
  }
54
- // A source build reports "0.0.0-dev" and the dev npm channel stamps
55
- // "<v>-dev.<stamp>" versions; neither publishes matching runtime packages,
56
- // so they are not acquirable. Release and rc/next versions are.
55
+ // A source build reports "0.0.0-dev", an unbundled server the bare "dev",
56
+ // and the dev npm channel stamps "<v>-dev.<stamp>"; none publishes matching
57
+ // runtime packages, so none is acquirable. Release and rc/next versions are.
58
+ // The rule is the shared client predicate, so the console's read of the
59
+ // official catalogue and this acquisition agree on every version.
57
60
  export function isAcquirableRelease(version) {
58
- return !version.includes("-dev");
61
+ return isReleaseVersion(version);
59
62
  }
60
63
  //# sourceMappingURL=runtimes-install.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtimes-install.js","sourceRoot":"","sources":["../../../src/local/runtime/runtimes-install.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,4EAA4E;AAC5E,yEAAyE;AACzE,6EAA6E;AAC7E,sDAAsD;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAKtD;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAAkB;IACnD,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3C,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IACtD,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC9B,aAAa,CACX,YAAY,EACZ,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAC7F,CAAC;IACJ,CAAC;AACH,CAAC;AAED,2EAA2E;AAC3E,wEAAwE;AACxE,4EAA4E;AAC5E,4CAA4C;AAC5C,MAAM,UAAU,sBAAsB,CAAC,UAAkB,EAAE,IAAY;IACrE,IAAI,CAAC;QACH,YAAY,CACV,KAAK,EACL;YACE,SAAS;YACT,IAAI;YACJ,UAAU;YACV,UAAU;YACV,YAAY;YACZ,YAAY;YACZ,WAAW;SACZ,EACD;YACE,KAAK,EAAE,SAAS;SACjB,CACF,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,YAAY,CAAC,qBAAqB,IAAI,EAAE,EAAE,QAAQ,CAAC,OAAO,EAAE;YACpE,wBAAwB,IAAI,aAAa,UAAU,EAAE;YACrD,qDAAqD;YACrD,qEAAqE;YACrE,gEAAgE;YAChE,GAAG,UAAU,aAAa;YAC1B,MAAM,CAAC,GAAG,CAAC;SACZ,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,oEAAoE;AACpE,2EAA2E;AAC3E,gEAAgE;AAChE,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC"}
1
+ {"version":3,"file":"runtimes-install.js","sourceRoot":"","sources":["../../../src/local/runtime/runtimes-install.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,4EAA4E;AAC5E,yEAAyE;AACzE,6EAA6E;AAC7E,sDAAsD;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE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CAAC;AAED,0EAA0E;AAC1E,4EAA4E;AAC5E,6EAA6E;AAC7E,wEAAwE;AACxE,kEAAkE;AAClE,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,63 @@
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
@@ -0,0 +1 @@
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,MAAM,oBAAoB,2BAA2B,CAAC;AAY7D,iFAAiF;AACjF,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;CAAE,GAC/D;IAAE,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;CAAE,GACpE;IACE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,4FAA4F;IAC5F,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,GACD;IACE,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,EAAE,SAAS,MAAM,EAAE,CAAC;CAChC,GACD;IACE,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,6BAA6B;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAEN,MAAM,MAAM,YAAY,GACpB;IAAE,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAA;CAAE,GAC3B;IACE,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IAC5C,sFAAsF;IACtF,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AAEN,MAAM,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"}
@@ -0,0 +1,361 @@
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
@@ -0,0 +1 @@
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,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,M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