@stigmer/sdk 3.2.3 → 3.4.0

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 (108) hide show
  1. package/__tests__/errors.test.js +44 -1
  2. package/__tests__/errors.test.js.map +1 -1
  3. package/__tests__/manifest.test.d.ts +2 -0
  4. package/__tests__/manifest.test.d.ts.map +1 -0
  5. package/__tests__/manifest.test.js +229 -0
  6. package/__tests__/manifest.test.js.map +1 -0
  7. package/__tests__/session.test.d.ts +6 -0
  8. package/__tests__/session.test.d.ts.map +1 -0
  9. package/__tests__/session.test.js +50 -0
  10. package/__tests__/session.test.js.map +1 -0
  11. package/billing.d.ts +83 -1
  12. package/billing.d.ts.map +1 -1
  13. package/billing.js +91 -1
  14. package/billing.js.map +1 -1
  15. package/cursor-accounts.d.ts +94 -0
  16. package/cursor-accounts.d.ts.map +1 -0
  17. package/cursor-accounts.js +119 -0
  18. package/cursor-accounts.js.map +1 -0
  19. package/errors.d.ts +14 -0
  20. package/errors.d.ts.map +1 -1
  21. package/errors.js +26 -0
  22. package/errors.js.map +1 -1
  23. package/gen/agent.d.ts +5 -0
  24. package/gen/agent.d.ts.map +1 -1
  25. package/gen/agent.js +9 -1
  26. package/gen/agent.js.map +1 -1
  27. package/gen/agentexecution.d.ts +1 -0
  28. package/gen/agentexecution.d.ts.map +1 -1
  29. package/gen/agentexecution.js +2 -0
  30. package/gen/agentexecution.js.map +1 -1
  31. package/gen/agentinstance.d.ts +1 -0
  32. package/gen/agentinstance.d.ts.map +1 -1
  33. package/gen/agentinstance.js +1 -0
  34. package/gen/agentinstance.js.map +1 -1
  35. package/gen/authorization-config.d.ts.map +1 -1
  36. package/gen/authorization-config.js +1 -0
  37. package/gen/authorization-config.js.map +1 -1
  38. package/gen/client.d.ts +6 -2
  39. package/gen/client.d.ts.map +1 -1
  40. package/gen/client.js +4 -0
  41. package/gen/client.js.map +1 -1
  42. package/gen/datastore.d.ts +129 -0
  43. package/gen/datastore.d.ts.map +1 -0
  44. package/gen/datastore.js +303 -0
  45. package/gen/datastore.js.map +1 -0
  46. package/gen/session.d.ts +1 -0
  47. package/gen/session.d.ts.map +1 -1
  48. package/gen/session.js +1 -0
  49. package/gen/session.js.map +1 -1
  50. package/index.d.ts +6 -4
  51. package/index.d.ts.map +1 -1
  52. package/index.js +8 -4
  53. package/index.js.map +1 -1
  54. package/manifest/client.d.ts +64 -0
  55. package/manifest/client.d.ts.map +1 -0
  56. package/manifest/client.js +109 -0
  57. package/manifest/client.js.map +1 -0
  58. package/manifest/index.d.ts +9 -0
  59. package/manifest/index.d.ts.map +1 -0
  60. package/manifest/index.js +11 -0
  61. package/manifest/index.js.map +1 -0
  62. package/manifest/parse.d.ts +57 -0
  63. package/manifest/parse.d.ts.map +1 -0
  64. package/manifest/parse.js +134 -0
  65. package/manifest/parse.js.map +1 -0
  66. package/manifest/redaction.d.ts +16 -0
  67. package/manifest/redaction.d.ts.map +1 -0
  68. package/manifest/redaction.js +19 -0
  69. package/manifest/redaction.js.map +1 -0
  70. package/manifest/registry.d.ts +44 -0
  71. package/manifest/registry.d.ts.map +1 -0
  72. package/manifest/registry.js +178 -0
  73. package/manifest/registry.js.map +1 -0
  74. package/manifest/serialize.d.ts +24 -0
  75. package/manifest/serialize.d.ts.map +1 -0
  76. package/manifest/serialize.js +78 -0
  77. package/manifest/serialize.js.map +1 -0
  78. package/package.json +4 -3
  79. package/session.d.ts +37 -0
  80. package/session.d.ts.map +1 -1
  81. package/session.js +43 -0
  82. package/session.js.map +1 -1
  83. package/src/__tests__/errors.test.ts +58 -0
  84. package/src/__tests__/manifest.test.ts +271 -0
  85. package/src/__tests__/session.test.ts +66 -0
  86. package/src/billing.ts +160 -0
  87. package/src/cursor-accounts.ts +207 -0
  88. package/src/errors.ts +27 -0
  89. package/src/gen/agent.ts +15 -1
  90. package/src/gen/agentexecution.ts +2 -0
  91. package/src/gen/agentinstance.ts +2 -0
  92. package/src/gen/authorization-config.ts +1 -0
  93. package/src/gen/client.ts +7 -2
  94. package/src/gen/datastore.ts +381 -0
  95. package/src/gen/session.ts +2 -0
  96. package/src/index.ts +36 -1
  97. package/src/manifest/client.ts +145 -0
  98. package/src/manifest/index.ts +25 -0
  99. package/src/manifest/parse.ts +204 -0
  100. package/src/manifest/redaction.ts +20 -0
  101. package/src/manifest/registry.ts +232 -0
  102. package/src/manifest/serialize.ts +92 -0
  103. package/src/session.ts +48 -0
  104. package/src/stigmer.ts +8 -0
  105. package/stigmer.d.ts +6 -0
  106. package/stigmer.d.ts.map +1 -1
  107. package/stigmer.js +8 -0
  108. package/stigmer.js.map +1 -1
@@ -0,0 +1,109 @@
1
+ // Kind-agnostic apply/lookup over the manifest registry.
2
+ //
3
+ // One client, every registry kind: `apply` drives the kind's command
4
+ // controller with the full resource proto (create-or-update by slug,
5
+ // server-side), `getByReference` loads current server state for
6
+ // create-vs-update previews and YAML editing.
7
+ import { create } from "@bufbuild/protobuf";
8
+ import { createClient } from "@connectrpc/connect";
9
+ import { ApiResourceReferenceSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
10
+ import { wrapError } from "../gen/errors.js";
11
+ import { metadataOf } from "./parse.js";
12
+ import { manifestHandlerForYamlKind, manifestKinds, } from "./registry.js";
13
+ /**
14
+ * Client for applying and loading Stigmer resources as manifests,
15
+ * independent of kind.
16
+ *
17
+ * Complements the typed per-kind clients (`stigmer.agent`, …): those take
18
+ * curated `*Input` shapes for programmatic use; this one takes full
19
+ * resource protos produced by {@link parseManifest} — the declarative
20
+ * "apply this YAML" path, with the same semantics as `stigmer apply -f`.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const docs = parseManifest(yamlText, { org: "acme" });
25
+ * for (const doc of docs) {
26
+ * const applied = await stigmer.manifest.apply(doc);
27
+ * console.log(`${applied.displayName} ${applied.slug} applied`);
28
+ * }
29
+ * ```
30
+ */
31
+ export class ManifestClient {
32
+ // Raw controller clients are created lazily and cached per service —
33
+ // one dialog session typically touches one or two kinds.
34
+ clients = new Map();
35
+ transport;
36
+ clientFor;
37
+ constructor(transport) {
38
+ this.transport = transport;
39
+ this.clientFor = (service) => {
40
+ let client = this.clients.get(service);
41
+ if (client === undefined) {
42
+ client = createClient(service, this.transport);
43
+ this.clients.set(service, client);
44
+ }
45
+ return client;
46
+ };
47
+ }
48
+ /** The kinds this client can apply, in dependency apply order. */
49
+ supportedKinds() {
50
+ return manifestKinds();
51
+ }
52
+ /**
53
+ * Apply one parsed manifest document (create-or-update by slug).
54
+ *
55
+ * @throws {StigmerError} When the server rejects the apply
56
+ * (validation, permissions, …).
57
+ */
58
+ async apply(document) {
59
+ let applied;
60
+ try {
61
+ applied = await document.handler.apply(this.clientFor, document.message);
62
+ }
63
+ catch (e) {
64
+ throw wrapError(e);
65
+ }
66
+ const metadata = metadataOf(applied);
67
+ return {
68
+ yamlKind: document.handler.yamlKind,
69
+ displayName: document.handler.displayName,
70
+ name: metadata?.name || document.name,
71
+ slug: metadata?.slug || document.slug,
72
+ org: metadata?.org || document.org,
73
+ id: metadata?.id ?? "",
74
+ message: applied,
75
+ };
76
+ }
77
+ /**
78
+ * Load a resource's current server state by kind + org/slug reference.
79
+ *
80
+ * @returns The resource proto, or `null` when it does not exist —
81
+ * the create-vs-update discriminator for previews.
82
+ * @throws {Error} When the kind is not in the manifest registry.
83
+ * @throws {StigmerError} For failures other than not-found.
84
+ */
85
+ async getByReference(yamlKind, org, slug) {
86
+ const handler = manifestHandlerForYamlKind(yamlKind);
87
+ if (handler === undefined) {
88
+ const supported = manifestKinds()
89
+ .map((h) => h.yamlKind)
90
+ .join(", ");
91
+ throw new Error(`Unsupported resource kind "${yamlKind}". Supported kinds: ${supported}.`);
92
+ }
93
+ const ref = create(ApiResourceReferenceSchema, {
94
+ org,
95
+ slug,
96
+ kind: handler.kind,
97
+ });
98
+ try {
99
+ return await handler.getByReference(this.clientFor, ref);
100
+ }
101
+ catch (e) {
102
+ const wrapped = wrapError(e);
103
+ if (wrapped.code === "not-found")
104
+ return null;
105
+ throw wrapped;
106
+ }
107
+ }
108
+ }
109
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/manifest/client.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,EAAE;AACF,qEAAqE;AACrE,qEAAqE;AACrE,gEAAgE;AAChE,8CAA8C;AAG9C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,YAAY,EAA+B,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,0BAA0B,EAAE,MAAM,sDAAsD,CAAC;AAClG,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAyB,MAAM,YAAY,CAAC;AAC/D,OAAO,EACL,0BAA0B,EAC1B,aAAa,GAGd,MAAM,eAAe,CAAC;AAoBvB;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,cAAc;IACzB,qEAAqE;IACrE,yDAAyD;IACxC,OAAO,GAAG,IAAI,GAAG,EAAoC,CAAC;IACtD,SAAS,CAAY;IACrB,SAAS,CAAkB;IAE5C,YAAY,SAAoB;QAC9B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,CAA2B,OAAa,EAAgB,EAAE;YACzE,IAAI,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACvC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,MAAM,GAAG,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;gBAC/C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YACpC,CAAC;YACD,OAAO,MAAsB,CAAC;QAChC,CAAC,CAAC;IACJ,CAAC;IAED,kEAAkE;IAClE,cAAc;QACZ,OAAO,aAAa,EAA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BAA0B,EAAE;YAC7C,GAAG;YACH,IAAI;YACJ,IAAI,EAAE,OAAO,CAAC,IAAI;SACnB,CAAC,CAAC;QAEH,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;QAC3D,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;YAC7B,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW;gBAAE,OAAO,IAAI,CAAC;YAC9C,MAAM,OAAO,CAAC;QAChB,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ export { manifestKinds, manifestHandlerForYamlKind, manifestHandlerForTypeName, } from "./registry.js";
2
+ export type { ManifestKindHandler, ServiceClientFn } from "./registry.js";
3
+ export { parseManifest, metadataOf } from "./parse.js";
4
+ export type { ManifestDocument, ParseManifestOptions } from "./parse.js";
5
+ export { serializeManifest } from "./serialize.js";
6
+ export { ManifestClient } from "./client.js";
7
+ export type { AppliedManifest } from "./client.js";
8
+ export { REDACTED_SECRET_MARKER, containsRedactedSecrets, } from "./redaction.js";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/manifest/index.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,aAAa,EACb,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACvD,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,11 @@
1
+ // Manifest engine: kind-agnostic YAML ⇄ proto ⇄ apply for Stigmer resources.
2
+ //
3
+ // The declarative counterpart to the typed per-kind clients — parse a YAML
4
+ // manifest against generated proto schemas, serialize server state back to
5
+ // editable YAML, and apply through each kind's command controller.
6
+ export { manifestKinds, manifestHandlerForYamlKind, manifestHandlerForTypeName, } from "./registry.js";
7
+ export { parseManifest, metadataOf } from "./parse.js";
8
+ export { serializeManifest } from "./serialize.js";
9
+ export { ManifestClient } from "./client.js";
10
+ export { REDACTED_SECRET_MARKER, containsRedactedSecrets, } from "./redaction.js";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/manifest/index.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,EAAE;AACF,2EAA2E;AAC3E,2EAA2E;AAC3E,mEAAmE;AAEnE,OAAO,EACL,aAAa,EACb,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { type Message } from "@bufbuild/protobuf";
2
+ import { type ApiResourceMetadata } from "@stigmer/protos/ai/stigmer/commons/apiresource/metadata_pb";
3
+ import { type ManifestKindHandler } from "./registry.js";
4
+ /** Options for {@link parseManifest}. */
5
+ export interface ParseManifestOptions {
6
+ /**
7
+ * Target organization slug. Injected into `metadata.org` when the document
8
+ * omits it. When the document specifies a *different* org, the document's
9
+ * value wins and a warning is attached (matching `stigmer apply`).
10
+ */
11
+ readonly org?: string;
12
+ }
13
+ /** One resource document parsed from a manifest. */
14
+ export interface ManifestDocument {
15
+ /** The registry handler for this document's kind. */
16
+ readonly handler: ManifestKindHandler;
17
+ /** The fully-marshalled resource proto, ready for `apply`. */
18
+ readonly message: Message;
19
+ /** `metadata.name` (always present — validated). */
20
+ readonly name: string;
21
+ /** `metadata.slug`, or the name when the document has no explicit slug. */
22
+ readonly slug: string;
23
+ /** `metadata.org` after org injection ("" when unresolvable). */
24
+ readonly org: string;
25
+ /** Org-mismatch warning, when the document's org differs from the target. */
26
+ readonly warning?: string;
27
+ }
28
+ /**
29
+ * Parse a (possibly multi-document) YAML manifest into resource protos.
30
+ *
31
+ * Each document is validated against its kind's generated proto schema —
32
+ * the same schemas the backend serves — so a document that parses here is
33
+ * structurally valid for `apply`. Documents are returned in **dependency
34
+ * apply order** (referenced kinds before dependents, stable within a kind),
35
+ * mirroring the CLI's apply ordering.
36
+ *
37
+ * @param content - Raw YAML text (one or more `---`-separated documents).
38
+ * @param options - Optional target org for `metadata.org` injection.
39
+ * @returns The parsed documents, sorted into dependency apply order.
40
+ * @throws {Error} With a user-facing message when the YAML is malformed,
41
+ * a document has no `kind`, the kind is unsupported, or a document does
42
+ * not match its proto schema (unknown fields included).
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * import { parseManifest } from "@stigmer/sdk";
47
+ *
48
+ * const docs = parseManifest(yamlText, { org: "acme" });
49
+ * for (const doc of docs) {
50
+ * await stigmer.manifest.apply(doc);
51
+ * }
52
+ * ```
53
+ */
54
+ export declare function parseManifest(content: string, options?: ParseManifestOptions): ManifestDocument[];
55
+ /** Read a resource message's metadata envelope, if present. */
56
+ export declare function metadataOf(message: Message): ApiResourceMetadata | undefined;
57
+ //# sourceMappingURL=parse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/manifest/parse.ts"],"names":[],"mappings":"AAQA,OAAO,EAA4B,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE5E,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,4DAA4D,CAAC;AAEpE,OAAO,EACL,KAAK,mBAAmB,EAGzB,MAAM,eAAe,CAAC;AAEvB,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,oDAAoD;AACpD,MAAM,WAAW,gBAAgB;IAC/B,qDAAqD;IACrD,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;IACtC,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,oBAAyB,GACjC,gBAAgB,EAAE,CAwCpB;AAyDD,+DAA+D;AAC/D,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,mBAAmB,GAAG,SAAS,CAE5E"}
@@ -0,0 +1,134 @@
1
+ // Strict YAML → proto parsing for Stigmer resource manifests.
2
+ //
3
+ // The strictness contract matches `stigmer apply -f`: YAML syntax errors and
4
+ // unknown fields both fail loudly (`ignoreUnknownFields: false`) — silently
5
+ // applying a half-parsed or typo'd document would be dangerous. Error
6
+ // messages are written for end users (DD-006): what failed, where, and what
7
+ // a valid document looks like.
8
+ import { fromJson } from "@bufbuild/protobuf";
9
+ import { create } from "@bufbuild/protobuf";
10
+ import { ApiResourceMetadataSchema, } from "@stigmer/protos/ai/stigmer/commons/apiresource/metadata_pb";
11
+ import { parseAllDocuments } from "yaml";
12
+ import { manifestHandlerForYamlKind, manifestKinds, } from "./registry.js";
13
+ /**
14
+ * Parse a (possibly multi-document) YAML manifest into resource protos.
15
+ *
16
+ * Each document is validated against its kind's generated proto schema —
17
+ * the same schemas the backend serves — so a document that parses here is
18
+ * structurally valid for `apply`. Documents are returned in **dependency
19
+ * apply order** (referenced kinds before dependents, stable within a kind),
20
+ * mirroring the CLI's apply ordering.
21
+ *
22
+ * @param content - Raw YAML text (one or more `---`-separated documents).
23
+ * @param options - Optional target org for `metadata.org` injection.
24
+ * @returns The parsed documents, sorted into dependency apply order.
25
+ * @throws {Error} With a user-facing message when the YAML is malformed,
26
+ * a document has no `kind`, the kind is unsupported, or a document does
27
+ * not match its proto schema (unknown fields included).
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { parseManifest } from "@stigmer/sdk";
32
+ *
33
+ * const docs = parseManifest(yamlText, { org: "acme" });
34
+ * for (const doc of docs) {
35
+ * await stigmer.manifest.apply(doc);
36
+ * }
37
+ * ```
38
+ */
39
+ export function parseManifest(content, options = {}) {
40
+ if (!content.trim()) {
41
+ throw new Error("The manifest is empty. Paste or upload a Stigmer resource YAML " +
42
+ "(a document with apiVersion, kind, metadata, and spec).");
43
+ }
44
+ const parsed = parseAllDocuments(content);
45
+ const documents = [];
46
+ for (const [index, doc] of parsed.entries()) {
47
+ const where = parsed.length === 1 ? "the manifest" : `document ${index + 1}`;
48
+ if (doc.errors.length > 0) {
49
+ throw new Error(`Invalid YAML in ${where}: ${doc.errors[0].message}`);
50
+ }
51
+ const value = doc.toJS();
52
+ if (value === null || value === undefined)
53
+ continue; // blank document between separators
54
+ if (typeof value !== "object" || Array.isArray(value)) {
55
+ throw new Error(`Invalid YAML in ${where}: expected a mapping document with ` +
56
+ "apiVersion, kind, metadata, and spec.");
57
+ }
58
+ documents.push(parseDocument(value, where, options.org));
59
+ }
60
+ if (documents.length === 0) {
61
+ throw new Error("The manifest contains no resource documents. Each document needs " +
62
+ "at least a kind (e.g. kind: Agent) and metadata.name.");
63
+ }
64
+ // Stable sort into dependency order so multi-document manifests apply
65
+ // parents before dependents (e.g. Environment before AgentChannel).
66
+ return documents.sort((a, b) => a.handler.applyOrder - b.handler.applyOrder);
67
+ }
68
+ function parseDocument(value, where, org) {
69
+ const kind = value.kind;
70
+ if (typeof kind !== "string" || kind === "") {
71
+ throw new Error(`${capitalize(where)} is missing the required 'kind' field ` +
72
+ "(e.g. kind: Agent).");
73
+ }
74
+ const handler = manifestHandlerForYamlKind(kind);
75
+ if (handler === undefined) {
76
+ const supported = manifestKinds()
77
+ .map((h) => h.yamlKind)
78
+ .join(", ");
79
+ throw new Error(`Unsupported resource kind "${kind}" in ${where}. ` +
80
+ `Supported kinds: ${supported}.`);
81
+ }
82
+ let message;
83
+ try {
84
+ message = fromJson(handler.schema, value, {
85
+ ignoreUnknownFields: false,
86
+ });
87
+ }
88
+ catch (err) {
89
+ throw new Error(`Invalid ${handler.displayName} in ${where}: ${err.message}`);
90
+ }
91
+ const warning = injectOrg(message, org ?? "");
92
+ const metadata = metadataOf(message);
93
+ const name = metadata?.name ?? "";
94
+ if (name === "") {
95
+ throw new Error(`${capitalize(where)} is missing the required metadata.name field.`);
96
+ }
97
+ return {
98
+ handler,
99
+ message,
100
+ name,
101
+ slug: metadata?.slug || name,
102
+ org: metadata?.org ?? "",
103
+ ...(warning !== undefined && { warning }),
104
+ };
105
+ }
106
+ /** Read a resource message's metadata envelope, if present. */
107
+ export function metadataOf(message) {
108
+ return message.metadata;
109
+ }
110
+ // Inject the target org into metadata.org when the document omitted it. When
111
+ // the document specifies a *different* org, the document's value is honored
112
+ // and a warning is returned (matching `stigmer apply`).
113
+ function injectOrg(message, org) {
114
+ if (org === "")
115
+ return undefined;
116
+ const holder = message;
117
+ if (holder.metadata === undefined) {
118
+ holder.metadata = create(ApiResourceMetadataSchema, { org });
119
+ return undefined;
120
+ }
121
+ if (holder.metadata.org === "") {
122
+ holder.metadata.org = org;
123
+ return undefined;
124
+ }
125
+ if (holder.metadata.org !== org) {
126
+ return (`The document's org "${holder.metadata.org}" differs from the ` +
127
+ `target org "${org}"; applying to "${holder.metadata.org}".`);
128
+ }
129
+ return undefined;
130
+ }
131
+ function capitalize(text) {
132
+ return text.charAt(0).toUpperCase() + text.slice(1);
133
+ }
134
+ //# sourceMappingURL=parse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/manifest/parse.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,EAAE;AACF,6EAA6E;AAC7E,4EAA4E;AAC5E,sEAAsE;AACtE,4EAA4E;AAC5E,+BAA+B;AAE/B,OAAO,EAAE,QAAQ,EAAgC,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAEL,yBAAyB,GAC1B,MAAM,4DAA4D,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAEL,0BAA0B,EAC1B,aAAa,GACd,MAAM,eAAe,CAAC;AA4BvB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,aAAa,CAC3B,OAAe,EACf,UAAgC,EAAE;IAElC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,iEAAiE;YAC/D,yDAAyD,CAC5D,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC1C,MAAM,SAAS,GAAuB,EAAE,CAAC;IAEzC,KAAK,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;QAC5C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,KAAK,CA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p reads on both
4
+ * editions). Sending the marker back in an `apply` means "keep the stored
5
+ * secret" — the update pipelines restore the existing encrypted value.
6
+ */
7
+ export declare const REDACTED_SECRET_MARKER = "***REDACTED***";
8
+ /**
9
+ * Whether manifest content contains redacted secret values.
10
+ *
11
+ * Used by editing UIs to explain the marker to users ("redacted secrets
12
+ * keep their stored values when applied") instead of letting it read like
13
+ * a bug.
14
+ */
15
+ export declare function containsRedactedSecrets(content: string): boolean;
16
+ //# sourceMappingURL=redaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redaction.d.ts","sourceRoot":"","sources":["../../src/manifest/redaction.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,mBAAmB,CAAC;AAEvD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEhE"}
@@ -0,0 +1,19 @@
1
+ // The server-side secret-redaction contract, mirrored for client UX.
2
+ /**
3
+ * Sentinel the server substitutes for secret values before they leave the
4
+ * backend (Cloud environment reads, ChannelApp/OAuthApp reads on both
5
+ * editions). Sending the marker back in an `apply` means "keep the stored
6
+ * secret" — the update pipelines restore the existing encrypted value.
7
+ */
8
+ export const REDACTED_SECRET_MARKER = "***REDACTED***";
9
+ /**
10
+ * Whether manifest content contains redacted secret values.
11
+ *
12
+ * Used by editing UIs to explain the marker to users ("redacted secrets
13
+ * keep their stored values when applied") instead of letting it read like
14
+ * a bug.
15
+ */
16
+ export function containsRedactedSecrets(content) {
17
+ return content.includes(REDACTED_SECRET_MARKER);
18
+ }
19
+ //# sourceMappingURL=redaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redaction.js","sourceRoot":"","sources":["../../src/manifest/redaction.ts"],"names":[],"mappings":"AAAA,qEAAqE;AAErE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AAEvD;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAe;IACrD,OAAO,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC;AAClD,CAAC"}
@@ -0,0 +1,44 @@
1
+ import type { DescMessage, DescService, Message } from "@bufbuild/protobuf";
2
+ import type { Client } from "@connectrpc/connect";
3
+ import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
4
+ import type { ApiResourceReference } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
5
+ /**
6
+ * Accessor for a raw Connect client over a generated service controller.
7
+ * Implementations cache clients per service (see `ManifestClient`).
8
+ */
9
+ export type ServiceClientFn = <Desc extends DescService>(service: Desc) => Client<Desc>;
10
+ /**
11
+ * Binds one YAML `kind` to everything the manifest engine needs:
12
+ * the proto schema (strict marshalling), the command controller's `apply`
13
+ * RPC, and the query controller's `getByReference` RPC (create-vs-update
14
+ * preview).
15
+ */
16
+ export interface ManifestKindHandler {
17
+ /** The platform resource kind enum value. */
18
+ readonly kind: ApiResourceKind;
19
+ /** The YAML discriminator, e.g. `"Agent"`. */
20
+ readonly yamlKind: string;
21
+ /** Human-facing name for messages, e.g. `"MCP Server"`. */
22
+ readonly displayName: string;
23
+ /** Canonical `apiVersion` for this kind, e.g. `"agentic.stigmer.ai/v1"`. */
24
+ readonly apiVersion: string;
25
+ /** Proto schema for strict YAML↔proto conversion. */
26
+ readonly schema: DescMessage;
27
+ /**
28
+ * Position in the dependency apply order (ascending). Referenced kinds
29
+ * apply before their dependents, e.g. an McpServer before the Agent that
30
+ * uses it, and everything an AgentChannel references before the channel.
31
+ */
32
+ readonly applyOrder: number;
33
+ /** Drive the command controller's `apply` RPC with the full resource. */
34
+ apply(clientFor: ServiceClientFn, message: Message): Promise<Message>;
35
+ /** Load the current server state by org/slug reference. */
36
+ getByReference(clientFor: ServiceClientFn, ref: ApiResourceReference): Promise<Message>;
37
+ }
38
+ /** All kinds the manifest engine supports, in dependency apply order. */
39
+ export declare function manifestKinds(): readonly ManifestKindHandler[];
40
+ /** Resolve a handler by its YAML `kind` discriminator (e.g. `"Agent"`). */
41
+ export declare function manifestHandlerForYamlKind(yamlKind: string): ManifestKindHandler | undefined;
42
+ /** Resolve a handler from a proto message's fully-qualified type name. */
43
+ export declare function manifestHandlerForTypeName(typeName: string): ManifestKindHandler | undefined;
44
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/manifest/registry.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,qFAAqF,CAAC;AACtH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sDAAsD,CAAC;AAoCjG;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,SAAS,WAAW,EAAE,OAAO,EAAE,IAAI,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC;AAExF;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,8CAA8C;IAC9C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,2DAA2D;IAC3D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,4EAA4E;IAC5E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,qDAAqD;IACrD,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,yEAAyE;IACzE,KAAK,CAAC,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACtE,2DAA2D;IAC3D,cAAc,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACzF;AAiID,yEAAyE;AACzE,wBAAgB,aAAa,IAAI,SAAS,mBAAmB,EAAE,CAE9D;AAED,2EAA2E;AAC3E,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,GACf,mBAAmB,GAAG,SAAS,CAEjC;AAED,0EAA0E;AAC1E,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,GACf,mBAAmB,GAAG,SAAS,CAEjC"}
@@ -0,0 +1,178 @@
1
+ // Explicit manifest-kind registry: the single place that binds a YAML `kind`
2
+ // to its proto schema and controller RPCs.
3
+ //
4
+ // This is the SDK home of the pattern the CLIs already rely on (Go CLI,
5
+ // TS CLI `resources/apply/handlers.ts`, mcp-server): strict YAML→proto
6
+ // marshalling against the *generated schema*, and apply through the raw
7
+ // command controller with the full resource message. The high-level
8
+ // `*Input` wrappers are intentionally bypassed — they are lossy (they drop
9
+ // `metadata.id` and any field codegen hasn't projected), while the `apply`
10
+ // RPC takes the complete resource and the server upserts by slug.
11
+ //
12
+ // Registration is explicit — to support a new kind, add one entry here.
13
+ import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
14
+ import { AgentSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb";
15
+ import { AgentCommandController } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/command_pb";
16
+ import { AgentQueryController } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/query_pb";
17
+ import { AgentChannelSchema } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/api_pb";
18
+ import { AgentChannelCommandController } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/command_pb";
19
+ import { AgentChannelQueryController } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/query_pb";
20
+ import { AgentInstanceSchema } from "@stigmer/protos/ai/stigmer/agentic/agentinstance/v1/api_pb";
21
+ import { AgentInstanceCommandController } from "@stigmer/protos/ai/stigmer/agentic/agentinstance/v1/command_pb";
22
+ import { AgentInstanceQueryController } from "@stigmer/protos/ai/stigmer/agentic/agentinstance/v1/query_pb";
23
+ import { AgentShareSchema } from "@stigmer/protos/ai/stigmer/agentic/agentshare/v1/api_pb";
24
+ import { AgentShareCommandController } from "@stigmer/protos/ai/stigmer/agentic/agentshare/v1/command_pb";
25
+ import { AgentShareQueryController } from "@stigmer/protos/ai/stigmer/agentic/agentshare/v1/query_pb";
26
+ import { ChannelAppSchema } from "@stigmer/protos/ai/stigmer/agentic/channelapp/v1/api_pb";
27
+ import { ChannelAppCommandController } from "@stigmer/protos/ai/stigmer/agentic/channelapp/v1/command_pb";
28
+ import { ChannelAppQueryController } from "@stigmer/protos/ai/stigmer/agentic/channelapp/v1/query_pb";
29
+ import { DatastoreSchema } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/api_pb";
30
+ import { DatastoreCommandController } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/command_pb";
31
+ import { DatastoreQueryController } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/query_pb";
32
+ import { EnvironmentSchema } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/api_pb";
33
+ import { EnvironmentCommandController } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/command_pb";
34
+ import { EnvironmentQueryController } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/query_pb";
35
+ import { McpServerSchema } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/api_pb";
36
+ import { McpServerCommandController } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/command_pb";
37
+ import { McpServerQueryController } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/query_pb";
38
+ import { WorkflowSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/api_pb";
39
+ import { WorkflowCommandController } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/command_pb";
40
+ import { WorkflowQueryController } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/query_pb";
41
+ import { IdentityProviderSchema } from "@stigmer/protos/ai/stigmer/iam/identityprovider/v1/api_pb";
42
+ import { IdentityProviderCommandController } from "@stigmer/protos/ai/stigmer/iam/identityprovider/v1/command_pb";
43
+ import { IdentityProviderQueryController } from "@stigmer/protos/ai/stigmer/iam/identityprovider/v1/query_pb";
44
+ import { OAuthAppSchema } from "@stigmer/protos/ai/stigmer/iam/oauthapp/v1/api_pb";
45
+ import { OAuthAppCommandController } from "@stigmer/protos/ai/stigmer/iam/oauthapp/v1/command_pb";
46
+ import { OAuthAppQueryController } from "@stigmer/protos/ai/stigmer/iam/oauthapp/v1/query_pb";
47
+ const AGENTIC_V1 = "agentic.stigmer.ai/v1";
48
+ const IAM_V1 = "iam.stigmer.ai/v1";
49
+ const HANDLERS = [
50
+ {
51
+ kind: ApiResourceKind.mcp_server,
52
+ yamlKind: "McpServer",
53
+ displayName: "MCP Server",
54
+ apiVersion: AGENTIC_V1,
55
+ schema: McpServerSchema,
56
+ applyOrder: 1,
57
+ apply: (c, m) => c(McpServerCommandController).apply(m),
58
+ getByReference: (c, ref) => c(McpServerQueryController).getByReference(ref),
59
+ },
60
+ // A Datastore applies before the Agents that reference it via
61
+ // datastore_usages (the McpServer-before-Agent pattern).
62
+ {
63
+ kind: ApiResourceKind.datastore,
64
+ yamlKind: "Datastore",
65
+ displayName: "Datastore",
66
+ apiVersion: AGENTIC_V1,
67
+ schema: DatastoreSchema,
68
+ applyOrder: 2,
69
+ apply: (c, m) => c(DatastoreCommandController).apply(m),
70
+ getByReference: (c, ref) => c(DatastoreQueryController).getByReference(ref),
71
+ },
72
+ {
73
+ kind: ApiResourceKind.agent,
74
+ yamlKind: "Agent",
75
+ displayName: "Agent",
76
+ apiVersion: AGENTIC_V1,
77
+ schema: AgentSchema,
78
+ applyOrder: 3,
79
+ apply: (c, m) => c(AgentCommandController).apply(m),
80
+ getByReference: (c, ref) => c(AgentQueryController).getByReference(ref),
81
+ },
82
+ {
83
+ kind: ApiResourceKind.workflow,
84
+ yamlKind: "Workflow",
85
+ displayName: "Workflow",
86
+ apiVersion: AGENTIC_V1,
87
+ schema: WorkflowSchema,
88
+ applyOrder: 4,
89
+ apply: (c, m) => c(WorkflowCommandController).apply(m),
90
+ getByReference: (c, ref) => c(WorkflowQueryController).getByReference(ref),
91
+ },
92
+ {
93
+ kind: ApiResourceKind.environment,
94
+ yamlKind: "Environment",
95
+ displayName: "Environment",
96
+ apiVersion: AGENTIC_V1,
97
+ schema: EnvironmentSchema,
98
+ applyOrder: 5,
99
+ apply: (c, m) => c(EnvironmentCommandController).apply(m),
100
+ getByReference: (c, ref) => c(EnvironmentQueryController).getByReference(ref),
101
+ },
102
+ {
103
+ kind: ApiResourceKind.identity_provider,
104
+ yamlKind: "IdentityProvider",
105
+ displayName: "Identity Provider",
106
+ apiVersion: IAM_V1,
107
+ schema: IdentityProviderSchema,
108
+ applyOrder: 6,
109
+ apply: (c, m) => c(IdentityProviderCommandController).apply(m),
110
+ getByReference: (c, ref) => c(IdentityProviderQueryController).getByReference(ref),
111
+ },
112
+ {
113
+ kind: ApiResourceKind.oauth_app,
114
+ yamlKind: "OAuthApp",
115
+ displayName: "OAuth App",
116
+ apiVersion: IAM_V1,
117
+ schema: OAuthAppSchema,
118
+ applyOrder: 7,
119
+ apply: (c, m) => c(OAuthAppCommandController).apply(m),
120
+ getByReference: (c, ref) => c(OAuthAppQueryController).getByReference(ref),
121
+ },
122
+ {
123
+ kind: ApiResourceKind.channel_app,
124
+ yamlKind: "ChannelApp",
125
+ displayName: "Channel App",
126
+ apiVersion: AGENTIC_V1,
127
+ schema: ChannelAppSchema,
128
+ applyOrder: 8,
129
+ apply: (c, m) => c(ChannelAppCommandController).apply(m),
130
+ getByReference: (c, ref) => c(ChannelAppQueryController).getByReference(ref),
131
+ },
132
+ {
133
+ kind: ApiResourceKind.agent_instance,
134
+ yamlKind: "AgentInstance",
135
+ displayName: "Agent Instance",
136
+ apiVersion: AGENTIC_V1,
137
+ schema: AgentInstanceSchema,
138
+ applyOrder: 9,
139
+ apply: (c, m) => c(AgentInstanceCommandController).apply(m),
140
+ getByReference: (c, ref) => c(AgentInstanceQueryController).getByReference(ref),
141
+ },
142
+ {
143
+ kind: ApiResourceKind.agent_share,
144
+ yamlKind: "AgentShare",
145
+ displayName: "Agent Share",
146
+ apiVersion: AGENTIC_V1,
147
+ schema: AgentShareSchema,
148
+ applyOrder: 10,
149
+ apply: (c, m) => c(AgentShareCommandController).apply(m),
150
+ getByReference: (c, ref) => c(AgentShareQueryController).getByReference(ref),
151
+ },
152
+ // Last: an AgentChannel references an Agent, a ChannelApp, and Environments.
153
+ {
154
+ kind: ApiResourceKind.agent_channel,
155
+ yamlKind: "AgentChannel",
156
+ displayName: "Agent Channel",
157
+ apiVersion: AGENTIC_V1,
158
+ schema: AgentChannelSchema,
159
+ applyOrder: 11,
160
+ apply: (c, m) => c(AgentChannelCommandController).apply(m),
161
+ getByReference: (c, ref) => c(AgentChannelQueryController).getByReference(ref),
162
+ },
163
+ ];
164
+ const BY_YAML_KIND = new Map(HANDLERS.map((h) => [h.yamlKind, h]));
165
+ const BY_TYPE_NAME = new Map(HANDLERS.map((h) => [h.schema.typeName, h]));
166
+ /** All kinds the manifest engine supports, in dependency apply order. */
167
+ export function manifestKinds() {
168
+ return HANDLERS;
169
+ }
170
+ /** Resolve a handler by its YAML `kind` discriminator (e.g. `"Agent"`). */
171
+ export function manifestHandlerForYamlKind(yamlKind) {
172
+ return BY_YAML_KIND.get(yamlKind);
173
+ }
174
+ /** Resolve a handler from a proto message's fully-qualified type name. */
175
+ export function manifestHandlerForTypeName(typeName) {
176
+ return BY_TYPE_NAME.get(typeName);
177
+ }
178
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/manifest/registry.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC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