@ebitex/mcp 0.0.0-stage → 1.1.313

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 (79) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +143 -2
  3. package/dist/app.d.ts +57 -0
  4. package/dist/app.d.ts.map +1 -0
  5. package/dist/app.js +8 -0
  6. package/dist/app.js.map +1 -0
  7. package/dist/apps/content/app.d.ts +23 -0
  8. package/dist/apps/content/app.d.ts.map +1 -0
  9. package/dist/apps/content/app.js +95 -0
  10. package/dist/apps/content/app.js.map +1 -0
  11. package/dist/apps/content/client.d.ts +34 -0
  12. package/dist/apps/content/client.d.ts.map +1 -0
  13. package/dist/apps/content/client.js +68 -0
  14. package/dist/apps/content/client.js.map +1 -0
  15. package/dist/apps/content/config.d.ts +29 -0
  16. package/dist/apps/content/config.d.ts.map +1 -0
  17. package/dist/apps/content/config.js +30 -0
  18. package/dist/apps/content/config.js.map +1 -0
  19. package/dist/apps/content/errors.d.ts +59 -0
  20. package/dist/apps/content/errors.d.ts.map +1 -0
  21. package/dist/apps/content/errors.js +122 -0
  22. package/dist/apps/content/errors.js.map +1 -0
  23. package/dist/apps/content/resources/helpCorpus.generated.d.ts +7 -0
  24. package/dist/apps/content/resources/helpCorpus.generated.d.ts.map +1 -0
  25. package/dist/apps/content/resources/helpCorpus.generated.js +162 -0
  26. package/dist/apps/content/resources/helpCorpus.generated.js.map +1 -0
  27. package/dist/apps/content/resources/register.d.ts +8 -0
  28. package/dist/apps/content/resources/register.d.ts.map +1 -0
  29. package/dist/apps/content/resources/register.js +81 -0
  30. package/dist/apps/content/resources/register.js.map +1 -0
  31. package/dist/apps/content/routes.d.ts +67 -0
  32. package/dist/apps/content/routes.d.ts.map +1 -0
  33. package/dist/apps/content/routes.js +163 -0
  34. package/dist/apps/content/routes.js.map +1 -0
  35. package/dist/apps/content/session.d.ts +60 -0
  36. package/dist/apps/content/session.d.ts.map +1 -0
  37. package/dist/apps/content/session.js +81 -0
  38. package/dist/apps/content/session.js.map +1 -0
  39. package/dist/apps/content/tools/catalog.d.ts +58 -0
  40. package/dist/apps/content/tools/catalog.d.ts.map +1 -0
  41. package/dist/apps/content/tools/catalog.js +81 -0
  42. package/dist/apps/content/tools/catalog.js.map +1 -0
  43. package/dist/apps/content/tools/cursor.d.ts +62 -0
  44. package/dist/apps/content/tools/cursor.d.ts.map +1 -0
  45. package/dist/apps/content/tools/cursor.js +94 -0
  46. package/dist/apps/content/tools/cursor.js.map +1 -0
  47. package/dist/apps/content/tools/register.d.ts +36 -0
  48. package/dist/apps/content/tools/register.d.ts.map +1 -0
  49. package/dist/apps/content/tools/register.js +470 -0
  50. package/dist/apps/content/tools/register.js.map +1 -0
  51. package/dist/apps/content/tools/result.d.ts +28 -0
  52. package/dist/apps/content/tools/result.d.ts.map +1 -0
  53. package/dist/apps/content/tools/result.js +26 -0
  54. package/dist/apps/content/tools/result.js.map +1 -0
  55. package/dist/apps/content/tools/whoami.d.ts +36 -0
  56. package/dist/apps/content/tools/whoami.d.ts.map +1 -0
  57. package/dist/apps/content/tools/whoami.js +39 -0
  58. package/dist/apps/content/tools/whoami.js.map +1 -0
  59. package/dist/apps/index.d.ts +8 -0
  60. package/dist/apps/index.d.ts.map +1 -0
  61. package/dist/apps/index.js +8 -0
  62. package/dist/apps/index.js.map +1 -0
  63. package/dist/config.d.ts +46 -0
  64. package/dist/config.d.ts.map +1 -0
  65. package/dist/config.js +69 -0
  66. package/dist/config.js.map +1 -0
  67. package/dist/index.d.ts +19 -0
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +20 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/main.d.ts +3 -0
  72. package/dist/main.d.ts.map +1 -0
  73. package/dist/main.js +51 -0
  74. package/dist/main.js.map +1 -0
  75. package/dist/server.d.ts +51 -0
  76. package/dist/server.d.ts.map +1 -0
  77. package/dist/server.js +104 -0
  78. package/dist/server.js.map +1 -0
  79. package/package.json +44 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpCorpus.generated.js","sourceRoot":"","sources":["../../../../src/apps/content/resources/helpCorpus.generated.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,EAAE;AACF,kGAAkG;AAClG,oGAAoG;AAIpG,MAAM,CAAC,MAAM,WAAW,GAAgB;IACtC;QACE,MAAM,EAAE,iBAAiB;QACzB,OAAO,EAAE,0CAA0C;QACnD,MAAM,EAAE,sqaAAsqa;KAC/qa;IACD;QACE,MAAM,EAAE,aAAa;QACrB,OAAO,EAAE,aAAa;QACtB,MAAM,EAAE,wnGAAwnG;KACjoG;IACD;QACE,MAAM,EAAE,YAAY;QACpB,OAAO,EAAE,sBAAsB;QAC/B,MAAM,EAAE,kv4BAAkv4B;KAC3v4B;IACD;QACE,MAAM,EAAE,kBAAkB;QAC1B,OAAO,EAAE,kCAAkC;QAC3C,MAAM,EAAE,2ooBAA2ooB;KACppoB;IACD;QACE,MAAM,EAAE,mBAAmB;QAC3B,OAAO,EAAE,0BAA0B;QACnC,MAAM,EAAE,i9OAAi9O;KAC19O;IACD;QACE,MAAM,EAAE,kBAAkB;QAC1B,OAAO,EAAE,gCAAgC;QACzC,MAAM,EAAE,ur6BAAur6B;KAChs6B;IACD;QACE,MAAM,EAAE,sBAAsB;QAC9B,OAAO,EAAE,sBAAsB;QAC/B,MAAM,EAAE,yyoBAAyyoB;KAClzoB;IACD;QACE,MAAM,EAAE,eAAe;QACvB,OAAO,EAAE,2CAA2C;QACpD,MAAM,EAAE,ygLAAygL;KAClhL;IACD;QACE,MAAM,EAAE,mBAAmB;QAC3B,OAAO,EAAE,wCAAwC;QACjD,MAAM,EAAE,m0TAAm0T;KAC50T;IACD;QACE,MAAM,EAAE,yBAAyB;QACjC,OAAO,EAAE,4BAA4B;QACrC,MAAM,EAAE,0sRAA0sR;KACntR;IACD;QACE,MAAM,EAAE,mBAAmB;QAC3B,OAAO,EAAE,mBAAmB;QAC5B,MAAM,EAAE,quTAAquT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AqB;QAC7B,OAAO,EAAE,qBAAqB;QAC9B,MAAM,EAAE,4sLAA4sL;KACrtL;IACD;QACE,MAAM,EAAE,mBAAmB;QAC3B,OAAO,EAAE,+BAA+B;QACxC,MAAM,EAAE,g2EAAg2E;KACz2E;IACD;QACE,MAAM,EAAE,aAAa;QACrB,OAAO,EAAE,cAAc;QACvB,MAAM,EAAE,yqLAAyqL;KAClrL;IACD;QACE,MAAM,EAAE,OAAO;QACf,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,i7FAAi7F;KAC17F;IACD;QACE,MAAM,EAAE,WAAW;QACnB,OAAO,EAAE,mCAAmC;QAC5C,MAAM,EAAE,usLAAusL;KAChtL;IACD;QACE,MAAM,EAAE,kBAAkB;QAC1B,OAAO,EAAE,kBAAkB;QAC3B,MAAM,EAAE,yvJAAyvJ;KAClwJ;IACD;QACE,MAAM,EAAE,gBAAgB;QACxB,OAAO,EAAE,qCAAqC;QAC9C,MAAM,EAAE,qiPAAqiP;KAC9iP;CACF,CAAA"}
@@ -0,0 +1,8 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { ContentClient } from '../client.js';
3
+ import { type Session } from '../session.js';
4
+ export declare function registerResources(server: McpServer, context: {
5
+ client: ContentClient;
6
+ session: Session;
7
+ }): void;
8
+ //# sourceMappingURL=register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../src/apps/content/resources/register.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,eAAe,CAAA;AAuBxD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE;IAAE,MAAM,EAAE,aAAa,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAgF/G"}
@@ -0,0 +1,81 @@
1
+ import { SCOPE_READ } from '../session.js';
2
+ import { HELP_TOPICS } from './helpCorpus.generated.js';
3
+ /**
4
+ * Resources.
5
+ *
6
+ * An agent needs the *conceptual* model (Contract versus Template versus Presentation versus
7
+ * Adapter, inheritance, the five modifiers, contextual values) and no amount of tool typing supplies
8
+ * it. Three layers, in descending order of trustworthiness, and the ordering is the whole design:
9
+ *
10
+ * 1. **Live and generated.** `field-types` with each type's own settings schema, and this
11
+ * environment's Contracts and Templates. These cannot go stale, because they are the server's
12
+ * own declaration of itself. Exposed as resources and not only as tool output so an agent can
13
+ * read them without spending a turn.
14
+ * 2. **Curated prose.** The Content help documentation, inlined into this package at build time.
15
+ * Current-state, already topic-scoped, and carrying no history.
16
+ * 3. **Internal design records: never.** Not a preference — they are historical by design, so they
17
+ * confidently teach shapes that have since been replaced. An agent acting on superseded state is
18
+ * worse than one with no state at all.
19
+ */
20
+ const SCHEME = 'ebitex-content';
21
+ export function registerResources(server, context) {
22
+ const { client, session } = context;
23
+ server.registerResource('whoami', `${SCHEME}://whoami`, {
24
+ title: 'This credential',
25
+ description: 'The organization, authoring environment, role and scopes this key is bound to.',
26
+ mimeType: 'application/json',
27
+ }, async (uri) => ({
28
+ contents: [{ uri: uri.href, mimeType: 'application/json', text: JSON.stringify(session.who, null, 2) }],
29
+ }));
30
+ // Live resources need the read scope, and a key without it should not advertise a resource whose
31
+ // every read fails — the same reasoning §4 applies to tools, for the same reason.
32
+ if (session.has(SCOPE_READ)) {
33
+ const live = [
34
+ {
35
+ name: 'field-types',
36
+ path: '/field-types',
37
+ title: 'Field types',
38
+ description: 'Every field type, each with its own settings JSON Schema. Generated from the field ' +
39
+ 'type itself, so it is never out of date — this is what to read instead of guessing.',
40
+ },
41
+ {
42
+ name: 'contracts',
43
+ path: '/contracts',
44
+ title: 'Contracts in this environment',
45
+ description: 'What already exists. Check here before creating a duplicate.',
46
+ },
47
+ {
48
+ name: 'templates',
49
+ path: '/templates',
50
+ title: 'Templates in this environment',
51
+ description: 'Which Contracts each Template can render, and what settings it offers.',
52
+ },
53
+ {
54
+ name: 'topology',
55
+ path: '/topology',
56
+ title: 'Where this environment sits',
57
+ description: "This environment's direct neighbours: the delivery environments it publishes to, where " +
58
+ 'it promotes to and is promoted from. One hop ' +
59
+ 'only, and nothing about which environment is production.',
60
+ },
61
+ ];
62
+ for (const entry of live) {
63
+ server.registerResource(entry.name, `${SCHEME}://${entry.name}`, { title: entry.title, description: entry.description, mimeType: 'application/json' }, async (uri) => ({
64
+ contents: [
65
+ {
66
+ uri: uri.href,
67
+ mimeType: 'application/json',
68
+ // Fetched per read rather than cached at startup. A cached description of a shape
69
+ // drifts from the shape — the same lesson the platform learned about compiled
70
+ // schemas, which are derived and never trusted.
71
+ text: JSON.stringify(await client.request('GET', entry.path), null, 2),
72
+ },
73
+ ],
74
+ }));
75
+ }
76
+ }
77
+ for (const topic of HELP_TOPICS) {
78
+ server.registerResource(`help-${topic.slug}`, `${SCHEME}://help/${topic.slug}`, { title: topic.title, description: `Content documentation: ${topic.title}`, mimeType: 'text/markdown' }, async (uri) => ({ contents: [{ uri: uri.href, mimeType: 'text/markdown', text: topic.body }] }));
79
+ }
80
+ }
81
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.js","sourceRoot":"","sources":["../../../../src/apps/content/resources/register.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAgB,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAEvD;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,MAAM,GAAG,gBAAgB,CAAA;AAE/B,MAAM,UAAU,iBAAiB,CAAC,MAAiB,EAAE,OAAoD;IACvG,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;IAEnC,MAAM,CAAC,gBAAgB,CACrB,QAAQ,EACR,GAAG,MAAM,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AAE,kBAAkB,EAAE,EACpF,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;gBACd,QAAQ,EAAE;oBACR;wBACE,GAAG,EAAE,GAAG,CAAC,IAAI;wBACb,QAAQ,EAAE,kBAAkB;wBAC5B,kFAAkF;wBAClF,8EAA8E;wBAC9E,gDAAgD;wBAChD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;qBACvE;iBACF;aACF,CAAC,CACH,CAAA;QACH,CAAC;IACH,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,WAAW,EAAE,CAAC;QAChC,MAAM,CAAC,gBAAgB,CACrB,QAAQ,KAAK,CAAC,IAAI,EAAE,EACpB,GAAG,MAAM,WAAW,KAAK,CAAC,IAAI,EAAE,EAChC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,WAAW,EAAE,0BAA0B,KAAK,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE,EACvG,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAChG,CAAA;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * The `kind`-to-route table.
3
+ *
4
+ * **This is the only content-model knowledge this server holds, and it is not much: which URL a
5
+ * kind lives at.** It knows nothing about what a Contract may contain, what field types exist, or
6
+ * what makes a document valid. Those are answered at runtime by the API (`content_describe` for the
7
+ * first two, the write's own response for the third), which is what makes this server unable to
8
+ * drift from the product — there is no second copy of the model here to fall out of step.
9
+ *
10
+ * The table is worth reading carefully, because a reader who assumed a uniform `POST /{kind}` /
11
+ * `PUT /{kind}/{id}` shape would get four things wrong:
12
+ *
13
+ * - **An Adapter updates with `PATCH`.** Every other family takes `PUT`. `PUT /adapters/{id}` does
14
+ * not exist, so assuming uniformity builds clean and answers `405` at run time — on the one
15
+ * family whose mapping canvas is the hardest thing an agent will try to author.
16
+ * - **A node's payload is its own route**, so it is its own kind. `PUT /experience/nodes/{id}`
17
+ * carries identity and location and *not* the payload; folding them together would put a silent
18
+ * no-op behind a successful write, which is worse than a refusal.
19
+ * - **A site is not a node.** `POST /experience/sites` creates a root; a page under it is a
20
+ * separate call to `/experience/nodes`.
21
+ * - **The surface is not uniformly CRUD.** Folders, sites and both taxonomy kinds have
22
+ * no single-entity `GET` at all — they are read by listing. `readOne: null` records that rather
23
+ * than inventing a route that would 404.
24
+ *
25
+ * Anything not in this table is not reachable by this server, and that is the same default-closed
26
+ * posture the API itself takes: a management key is refused any route the API does not explicitly
27
+ * admit. Workflow, providers, environments, promotion and credential minting have no row because a
28
+ * management key cannot reach any of them.
29
+ */
30
+ export declare const WRITABLE_KINDS: readonly ["contract", "template", "component", "folder", "site", "node", "nodePayload", "adapter", "stream", "categoryGroup", "category"];
31
+ export type EntityKind = (typeof WRITABLE_KINDS)[number];
32
+ export type KindRoutes = {
33
+ /** What this kind is called in prose, for messages an agent reads. */
34
+ label: string;
35
+ /** `POST` target, or null where the kind cannot be created on its own (a node's payload). */
36
+ create: string | null;
37
+ /** Path template for update/delete/read, `{id}` substituted. Null where the verb does not exist. */
38
+ update: {
39
+ method: 'PUT' | 'PATCH';
40
+ path: string;
41
+ } | null;
42
+ remove: string | null;
43
+ /** Single-entity `GET`, or null for a family that is only listable. */
44
+ readOne: string | null;
45
+ /** Listing route, which is also how a `readOne: null` kind is read. */
46
+ list: string | null;
47
+ };
48
+ export declare function isEntityKind(value: string): value is EntityKind;
49
+ export declare function routesFor(kind: EntityKind): KindRoutes;
50
+ /**
51
+ * Substitutes `{id}` in a path template.
52
+ *
53
+ * Encoded, because every id here is a Guid today and will not always be — a stream is addressable by
54
+ * external id on the delivery side already, and an id that ever carries a slash would otherwise
55
+ * silently change which route was matched.
56
+ */
57
+ export declare function withId(template: string, id: string): string;
58
+ /**
59
+ * The message a kind this server cannot reach gets.
60
+ *
61
+ * It answers locally rather than sending the request to earn a `404`, because the `404` says only
62
+ * "no such route" — it does not say which kinds *are* writable, which is the one thing that gets the
63
+ * agent to its next call. This is the same instinct as relaying the API's errors verbatim, pointed
64
+ * the other way: be transparent about what the server knows, and say nothing it does not.
65
+ */
66
+ export declare function unknownKindMessage(kind: string): string;
67
+ //# sourceMappingURL=routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../src/apps/content/routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,eAAO,MAAM,cAAc,2IAYjB,CAAA;AAEV,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAA;AAExD,MAAM,MAAM,UAAU,GAAG;IACvB,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAA;IACb,6FAA6F;IAC7F,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,oGAAoG;IACpG,MAAM,EAAE;QAAE,MAAM,EAAE,KAAK,GAAG,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;IACxD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,uEAAuE;IACvE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,uEAAuE;IACvE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CACpB,CAAA;AA8FD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,UAAU,CAE/D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAEtD;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMvD"}
@@ -0,0 +1,163 @@
1
+ /**
2
+ * The `kind`-to-route table.
3
+ *
4
+ * **This is the only content-model knowledge this server holds, and it is not much: which URL a
5
+ * kind lives at.** It knows nothing about what a Contract may contain, what field types exist, or
6
+ * what makes a document valid. Those are answered at runtime by the API (`content_describe` for the
7
+ * first two, the write's own response for the third), which is what makes this server unable to
8
+ * drift from the product — there is no second copy of the model here to fall out of step.
9
+ *
10
+ * The table is worth reading carefully, because a reader who assumed a uniform `POST /{kind}` /
11
+ * `PUT /{kind}/{id}` shape would get four things wrong:
12
+ *
13
+ * - **An Adapter updates with `PATCH`.** Every other family takes `PUT`. `PUT /adapters/{id}` does
14
+ * not exist, so assuming uniformity builds clean and answers `405` at run time — on the one
15
+ * family whose mapping canvas is the hardest thing an agent will try to author.
16
+ * - **A node's payload is its own route**, so it is its own kind. `PUT /experience/nodes/{id}`
17
+ * carries identity and location and *not* the payload; folding them together would put a silent
18
+ * no-op behind a successful write, which is worse than a refusal.
19
+ * - **A site is not a node.** `POST /experience/sites` creates a root; a page under it is a
20
+ * separate call to `/experience/nodes`.
21
+ * - **The surface is not uniformly CRUD.** Folders, sites and both taxonomy kinds have
22
+ * no single-entity `GET` at all — they are read by listing. `readOne: null` records that rather
23
+ * than inventing a route that would 404.
24
+ *
25
+ * Anything not in this table is not reachable by this server, and that is the same default-closed
26
+ * posture the API itself takes: a management key is refused any route the API does not explicitly
27
+ * admit. Workflow, providers, environments, promotion and credential minting have no row because a
28
+ * management key cannot reach any of them.
29
+ */
30
+ export const WRITABLE_KINDS = [
31
+ 'contract',
32
+ 'template',
33
+ 'component',
34
+ 'folder',
35
+ 'site',
36
+ 'node',
37
+ 'nodePayload',
38
+ 'adapter',
39
+ 'stream',
40
+ 'categoryGroup',
41
+ 'category',
42
+ ];
43
+ const ROUTES = {
44
+ contract: {
45
+ label: 'Contract',
46
+ create: '/contracts',
47
+ update: { method: 'PUT', path: '/contracts/{id}' },
48
+ remove: '/contracts/{id}',
49
+ readOne: '/contracts/{id}',
50
+ list: '/contracts',
51
+ },
52
+ template: {
53
+ label: 'Template',
54
+ create: '/templates',
55
+ update: { method: 'PUT', path: '/templates/{id}' },
56
+ remove: '/templates/{id}',
57
+ readOne: '/templates/{id}',
58
+ list: '/templates',
59
+ },
60
+ component: {
61
+ label: 'Component',
62
+ create: '/components',
63
+ update: { method: 'PUT', path: '/components/{id}' },
64
+ remove: '/components/{id}',
65
+ readOne: '/components/{id}',
66
+ list: '/components',
67
+ },
68
+ folder: {
69
+ label: 'Folder',
70
+ create: '/folders',
71
+ update: { method: 'PUT', path: '/folders/{id}' },
72
+ remove: '/folders/{id}',
73
+ readOne: null,
74
+ list: '/folders',
75
+ },
76
+ site: {
77
+ label: 'Site (an Experience root)',
78
+ create: '/experience/sites',
79
+ update: null,
80
+ remove: null,
81
+ readOne: null,
82
+ list: '/experience/sites',
83
+ },
84
+ node: {
85
+ label: 'Experience node (a page)',
86
+ create: '/experience/nodes',
87
+ update: { method: 'PUT', path: '/experience/nodes/{id}' },
88
+ remove: '/experience/nodes/{id}',
89
+ readOne: '/experience/nodes/{id}',
90
+ list: null,
91
+ },
92
+ nodePayload: {
93
+ label: "An Experience node's payload (what it renders)",
94
+ create: null,
95
+ update: { method: 'PUT', path: '/experience/nodes/{id}/payload' },
96
+ remove: '/experience/nodes/{id}/payload',
97
+ readOne: null,
98
+ list: null,
99
+ },
100
+ adapter: {
101
+ label: 'Adapter (a field mapping)',
102
+ create: '/adapters',
103
+ // PATCH, not PUT. See this file's own header.
104
+ update: { method: 'PATCH', path: '/adapters/{id}' },
105
+ remove: '/adapters/{id}',
106
+ readOne: '/adapters/{id}',
107
+ list: '/adapters',
108
+ },
109
+ stream: {
110
+ label: 'Stream (a saved query over published content)',
111
+ create: '/streams',
112
+ update: { method: 'PUT', path: '/streams/{id}' },
113
+ remove: '/streams/{id}',
114
+ readOne: '/streams/{id}',
115
+ list: '/streams',
116
+ },
117
+ categoryGroup: {
118
+ label: 'Category group',
119
+ create: '/taxonomy/groups',
120
+ update: { method: 'PUT', path: '/taxonomy/groups/{id}' },
121
+ remove: '/taxonomy/groups/{id}',
122
+ readOne: null,
123
+ list: '/taxonomy/groups',
124
+ },
125
+ category: {
126
+ label: 'Category',
127
+ create: '/taxonomy/categories',
128
+ update: { method: 'PUT', path: '/taxonomy/categories/{id}' },
129
+ remove: '/taxonomy/categories/{id}',
130
+ readOne: null,
131
+ list: null,
132
+ },
133
+ };
134
+ export function isEntityKind(value) {
135
+ return Object.hasOwn(ROUTES, value);
136
+ }
137
+ export function routesFor(kind) {
138
+ return ROUTES[kind];
139
+ }
140
+ /**
141
+ * Substitutes `{id}` in a path template.
142
+ *
143
+ * Encoded, because every id here is a Guid today and will not always be — a stream is addressable by
144
+ * external id on the delivery side already, and an id that ever carries a slash would otherwise
145
+ * silently change which route was matched.
146
+ */
147
+ export function withId(template, id) {
148
+ return template.replace('{id}', encodeURIComponent(id));
149
+ }
150
+ /**
151
+ * The message a kind this server cannot reach gets.
152
+ *
153
+ * It answers locally rather than sending the request to earn a `404`, because the `404` says only
154
+ * "no such route" — it does not say which kinds *are* writable, which is the one thing that gets the
155
+ * agent to its next call. This is the same instinct as relaying the API's errors verbatim, pointed
156
+ * the other way: be transparent about what the server knows, and say nothing it does not.
157
+ */
158
+ export function unknownKindMessage(kind) {
159
+ return (`Unknown kind "${kind}". This server can write: ${WRITABLE_KINDS.join(', ')}.\n` +
160
+ 'Workflows, providers, environments, promotion and credential minting are deliberately not ' +
161
+ 'reachable with a management key.');
162
+ }
163
+ //# sourceMappingURL=routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.js","sourceRoot":"","sources":["../../../src/apps/content/routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;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AsB;QAC9B,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,2BAA2B,EAAE;QAC5D,MAAM,EAAE,2BAA2B;QACnC,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,IAAI;KACX;CACF,CAAA;AAED,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AACrC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAgB;IACxC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAA;AACrB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,MAAM,CAAC,QAAgB,EAAE,EAAU;IACjD,OAAO,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAAE,CAAC,CAAC,CAAA;AACzD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,OAAO,CACL,iBAAiB,IAAI,6BAA6B,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK;QAChF,4FAA4F;QAC5F,kCAAkC,CACnC,CAAA;AACH,CAAC"}
@@ -0,0 +1,60 @@
1
+ import type { ContentClient } from './client.js';
2
+ /**
3
+ * Who this key is, resolved once at startup from `GET /whoami`.
4
+ *
5
+ * Two things depend on it:
6
+ *
7
+ * - **Which tools exist at all.** A key's scopes decide what it may do, and an agent that cannot
8
+ * see a tool will not plan around it. Advertising a write tool a read-scoped key holds is an
9
+ * expensive way to learn something knowable before the session began — the agent spends a turn,
10
+ * reads a `403`, and has to re-plan.
11
+ * - **Where writes are landing.** The realistic failure of a write-capable agent tool is not a bug
12
+ * in it; it is a key bound to a production environment sitting in a config file somebody else
13
+ * wrote. The server cannot detect that — whether an environment is production is the customer's
14
+ * own topology, and a management key deliberately cannot manage environments — so the mitigation
15
+ * is to say plainly what the key is bound to, at startup and on every write.
16
+ */
17
+ export declare const SCOPE_READ = "content.management.read";
18
+ export declare const SCOPE_WRITE = "content.management.write";
19
+ export declare const SCOPE_PUBLISH = "content.management.publish";
20
+ export declare const SCOPE_AUTHORING = "content.management.authoring";
21
+ export type WhoAmI = {
22
+ organizationId: string;
23
+ organizationName: string | null;
24
+ organizationSlug: string | null;
25
+ environmentId: string;
26
+ environmentName: string | null;
27
+ /**
28
+ * the realm the key acts in. Absent from an API that predates realms, which is the root by construction; the root of an organization with one
29
+ * realm is never named in {@link Session.contextLine}, so nothing changes for it.
30
+ */
31
+ realmId?: string;
32
+ realmKey?: string | null;
33
+ realmName?: string | null;
34
+ roleName: string | null;
35
+ keyName: string | null;
36
+ scopes: string[];
37
+ /**
38
+ * What the acting role may do, as opposed to what the key's scopes allow. Absent from an API that
39
+ * predates it, which is why every reader treats a missing list as "not told" rather than "none".
40
+ */
41
+ permissions?: string[];
42
+ };
43
+ export type Session = {
44
+ who: WhoAmI;
45
+ /** True when the operator forced read-only regardless of what the key could do. */
46
+ readOnlyRequested: boolean;
47
+ has(scope: string): boolean;
48
+ /**
49
+ * True only when the API reported the role's permissions and this one is not among them. An API
50
+ * that reported none cannot say, so the request is sent and the server decides.
51
+ */
52
+ lacksPermission(permission: string): boolean;
53
+ /** One line naming where a write just landed, appended to every write result. */
54
+ contextLine(): string;
55
+ };
56
+ export declare function resolveSession(client: ContentClient, options: {
57
+ readOnlyRequested: boolean;
58
+ expectedRealm?: string | null;
59
+ }): Promise<Session>;
60
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/apps/content/session.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAGhD;;;;;;;;;;;;;;GAcG;AAEH,eAAO,MAAM,UAAU,4BAA4B,CAAA;AACnD,eAAO,MAAM,WAAW,6BAA6B,CAAA;AACrD,eAAO,MAAM,aAAa,+BAA+B,CAAA;AACzD,eAAO,MAAM,eAAe,iCAAiC,CAAA;AAE7D,MAAM,MAAM,MAAM,GAAG;IACnB,cAAc,EAAE,MAAM,CAAA;IACtB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,aAAa,EAAE,MAAM,CAAA;IACrB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,mFAAmF;IACnF,iBAAiB,EAAE,OAAO,CAAA;IAC1B,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAA;IAC3B;;;OAGG;IACH,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAA;IAC5C,iFAAiF;IACjF,WAAW,IAAI,MAAM,CAAA;CACtB,CAAA;AAED,wBAAsB,cAAc,CAClC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE;IAAE,iBAAiB,EAAE,OAAO,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GACrE,OAAO,CAAC,OAAO,CAAC,CA8BlB"}
@@ -0,0 +1,81 @@
1
+ import { StartupError } from '../../app.js';
2
+ import { ContentApiError } from './errors.js';
3
+ /**
4
+ * Who this key is, resolved once at startup from `GET /whoami`.
5
+ *
6
+ * Two things depend on it:
7
+ *
8
+ * - **Which tools exist at all.** A key's scopes decide what it may do, and an agent that cannot
9
+ * see a tool will not plan around it. Advertising a write tool a read-scoped key holds is an
10
+ * expensive way to learn something knowable before the session began — the agent spends a turn,
11
+ * reads a `403`, and has to re-plan.
12
+ * - **Where writes are landing.** The realistic failure of a write-capable agent tool is not a bug
13
+ * in it; it is a key bound to a production environment sitting in a config file somebody else
14
+ * wrote. The server cannot detect that — whether an environment is production is the customer's
15
+ * own topology, and a management key deliberately cannot manage environments — so the mitigation
16
+ * is to say plainly what the key is bound to, at startup and on every write.
17
+ */
18
+ export const SCOPE_READ = 'content.management.read';
19
+ export const SCOPE_WRITE = 'content.management.write';
20
+ export const SCOPE_PUBLISH = 'content.management.publish';
21
+ export const SCOPE_AUTHORING = 'content.management.authoring';
22
+ export async function resolveSession(client, options) {
23
+ let who;
24
+ try {
25
+ who = (await client.request('GET', '/whoami'));
26
+ }
27
+ catch (error) {
28
+ throw new StartupError(startupMessage(error, client.baseUrl));
29
+ }
30
+ const actualRealm = who.realmKey ?? 'root';
31
+ if (options.expectedRealm && options.expectedRealm !== actualRealm) {
32
+ throw new StartupError(who.realmKey == null
33
+ ? `EBITEX_CONTENT_REALM is ${options.expectedRealm}, but ${client.baseUrl} does not report realms, so the key acts in the root realm.`
34
+ : `EBITEX_CONTENT_REALM is ${options.expectedRealm}, but this key acts in the realm ${who.realmName ?? actualRealm} (${actualRealm}). A key is bound to one realm: use a key minted for ${options.expectedRealm}.`);
35
+ }
36
+ const scopes = new Set(who.scopes ?? []);
37
+ const permissions = Array.isArray(who.permissions) ? new Set(who.permissions) : null;
38
+ return {
39
+ who,
40
+ readOnlyRequested: options.readOnlyRequested,
41
+ // A forced read-only session reports every write scope as absent, so tool registration —
42
+ // which asks this and nothing else — needs no second concept of "but the operator said no".
43
+ has: (scope) => (options.readOnlyRequested && isWriteScope(scope) ? false : scopes.has(scope)),
44
+ lacksPermission: (permission) => permissions !== null && !permissions.has(permission),
45
+ contextLine: () => `[${who.organizationName ?? who.organizationId} · ${who.environmentName ?? who.environmentId}${realmSegment(who)} · as ${who.roleName ?? 'unknown role'}]`,
46
+ };
47
+ }
48
+ /** The realm, named only when it is not the root: an organization that never made one sees the line it always saw. */
49
+ function realmSegment(who) {
50
+ return who.realmKey && who.realmKey !== 'root' ? ` · ${who.realmName ?? who.realmKey}` : '';
51
+ }
52
+ function isWriteScope(scope) {
53
+ return scope === SCOPE_WRITE || scope === SCOPE_PUBLISH || scope === SCOPE_AUTHORING;
54
+ }
55
+ /**
56
+ * What a failed startup says.
57
+ *
58
+ * Each arm names a **different remedy**, which is the only reason to distinguish them at all: a
59
+ * `401` means the key string is wrong, a `403 tier_required` means nothing about the key is wrong
60
+ * and somebody has to change the plan, and a `404` means this API predates `/whoami` entirely.
61
+ * Collapsing them into "could not connect" would leave the reader guessing between three unrelated
62
+ * actions.
63
+ */
64
+ function startupMessage(error, baseUrl) {
65
+ if (!(error instanceof ContentApiError)) {
66
+ return (`Could not reach the Content Management API at ${baseUrl}.\n` +
67
+ (error instanceof Error ? error.message : String(error)));
68
+ }
69
+ if (error.status === 401) {
70
+ return `The Content management key was not accepted by ${baseUrl} (${error.code ?? 'unauthorized'}).`;
71
+ }
72
+ if (error.status === 404) {
73
+ return (`${baseUrl} does not serve GET /content/management/v1/whoami, which this server needs in ` +
74
+ 'order to know which organization and environment the key is bound to, and which tools to ' +
75
+ 'offer. Upgrade the API, or point EBITEX_API_BASE at one that has it.');
76
+ }
77
+ // Everything else — tier, lapsed payment, the Content app not enabled, an IP allow-list — is a
78
+ // real refusal with a real message, and relaying it beats classifying it (§3).
79
+ return `The Content Management API refused this key.\n${error.message}`;
80
+ }
81
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/apps/content/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C;;;;;;;;;;;;;;GAcG;AAEH,M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CAAC,CACzD,CAAA;IACH,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACzB,OAAO,kDAAkD,OAAO,KAAK,KAAK,CAAC,IAAI,IAAI,cAAc,IAAI,CAAA;IACvG,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACzB,OAAO,CACL,GAAG,OAAO,gFAAgF;YAC1F,2FAA2F;YAC3F,sEAAsE,CACvE,CAAA;IACH,CAAC;IAED,+FAA+F;IAC/F,+EAA+E;IAC/E,OAAO,iDAAiD,KAAK,CAAC,OAAO,EAAE,CAAA;AACzE,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { type EntityKind } from '../routes.js';
2
+ /**
3
+ * The content-mcp ↔ Platform.Api tool contract.
4
+ *
5
+ * This is the one place that states which scope gates each of the ten tools and which are
6
+ * read-only. `register.ts` reads from it rather than restating the mapping in its own `if` blocks
7
+ * and `withheld[]` construction, which is what makes this a single source rather than a second,
8
+ * hand-kept copy of the same fact.
9
+ *
10
+ * Held in step with `Platform.Api.ContentManagement.ManagementToolCatalog` by
11
+ * `src/test/tool-catalogue.json` (at the package root), asserted from both sides — the same pattern
12
+ * `transfer-identity-modes.json` already uses for one field's enum, generalized here to the whole
13
+ * tool surface.
14
+ */
15
+ /**
16
+ * The sentinel for `content_whoami`, gated on no scope at all. The literal value matches the
17
+ * server's own `ContentManagementRouteScopes.AuthenticatedOnly` (`"*"`) exactly, rather than a
18
+ * TS-side synonym for it — the two would otherwise be two spellings of one fact, and the parity
19
+ * fixture/test would only be checking that both sides remembered to use their own spelling
20
+ * consistently, not that they agree. Never a real scope string, so it can never be satisfied by a
21
+ * key acquiring one.
22
+ */
23
+ export declare const AUTHENTICATED: "*";
24
+ /**
25
+ * The three entity kinds `content_write` may commit immediately from the in-app assistant (spec
26
+ * 939-ai-inline-assistant) rather than as a deferred suggestion: `component` and `node` implement
27
+ * `IVersionedEntity` server-side; `nodePayload` writes the same `ExperienceNode` row through its own
28
+ * route (`PUT /experience/nodes/{id}/payload`) and so qualifies too. `contract` does **not** — it
29
+ * implements only `IConcurrencyProtected` (a bespoke additive/breaking generation counter, not the
30
+ * generic save-history surface) — so it stays deferred like every other non-versioned kind. This
31
+ * field carries no meaning for `content-mcp` itself (an external agent's write always executes
32
+ * directly, immediately, regardless of tier); it exists here only so this file stays the one place
33
+ * that states the fact, mirrored server-side by `ManagementToolCatalog.ContentWriteImmediateKinds`
34
+ * and held in parity by `tool-catalogue.json`.
35
+ */
36
+ export declare const CONTENT_WRITE_IMMEDIATE_KINDS: readonly ["component", "node", "nodePayload"];
37
+ export type ToolDescriptor = {
38
+ name: string;
39
+ requiredScope: string;
40
+ readOnly: boolean;
41
+ /** Present only for the three tools whose `kind` parameter is drawn from `WRITABLE_KINDS`. */
42
+ kinds?: readonly EntityKind[];
43
+ /** Present only for `content_write` — see {@link CONTENT_WRITE_IMMEDIATE_KINDS}. */
44
+ immediateKinds?: readonly EntityKind[];
45
+ };
46
+ /**
47
+ * The permission the acting role must hold, beside the key's scope, to write or delete a kind. A
48
+ * scope is the key's ceiling and a permission is the role's, so a key holding `authoring` can still
49
+ * be refused: a Contract needs `content.contracts.manage`, which Member does not hold. Held in step
50
+ * with the server's `ManagementToolCatalog.KindPermissions` by the same fixture as the tools.
51
+ */
52
+ export declare const KIND_PERMISSIONS: Readonly<Partial<Record<EntityKind, string>>>;
53
+ export declare const TOOL_CATALOG: readonly ToolDescriptor[];
54
+ /** Whether `session` may see the named tool, per the catalogue's `requiredScope`. */
55
+ export declare function sessionCanUse(session: {
56
+ has(scope: string): boolean;
57
+ }, toolName: string): boolean;
58
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../../src/apps/content/tools/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAA;AAG9D;;;;;;;;;;;;GAYG;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAG,GAAY,CAAA;AAEzC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,6BAA6B,+CAAgD,CAAA;AAE1F,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,OAAO,CAAA;IACjB,8FAA8F;IAC9F,KAAK,CAAC,EAAE,SAAS,UAAU,EAAE,CAAA;IAC7B,oFAAoF;IACpF,cAAc,CAAC,EAAE,SAAS,UAAU,EAAE,CAAA;CACvC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAG1E,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,SAAS,cAAc,EAqBxC,CAAA;AAQV,qFAAqF;AACrF,wBAAgB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAGjG"}