@plitzi/sdk-mcp 0.38.19 → 0.38.21

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 (65) hide show
  1. package/CHANGELOG.md +186 -0
  2. package/README.md +6 -0
  3. package/dist/modules/mcp/resources/renderGuide.d.ts +29 -0
  4. package/dist/modules/mcp/resources/renderGuide.js +74 -1
  5. package/dist/modules/mcp/server.js +1 -1
  6. package/dist/render.d.ts +4 -2
  7. package/dist/render.js +2 -2
  8. package/package.json +10 -7
  9. package/dist/createServer.test.d.ts +0 -1
  10. package/dist/modules/mcp/accessibilityOutline.test.d.ts +0 -1
  11. package/dist/modules/mcp/apps/apps.test.d.ts +0 -1
  12. package/dist/modules/mcp/apps/render/styles.test.d.ts +0 -1
  13. package/dist/modules/mcp/catalogs/pluginCatalog.test.d.ts +0 -1
  14. package/dist/modules/mcp/e2e/connector.test.d.ts +0 -1
  15. package/dist/modules/mcp/e2e/host.test.d.ts +0 -1
  16. package/dist/modules/mcp/e2e/oauthConnector.test.d.ts +0 -1
  17. package/dist/modules/mcp/helpers/callToolResult.test.d.ts +0 -1
  18. package/dist/modules/mcp/helpers/log.test.d.ts +0 -1
  19. package/dist/modules/mcp/localScreenshotClient.test.d.ts +0 -1
  20. package/dist/modules/mcp/mcp.bench.d.ts +0 -1
  21. package/dist/modules/mcp/proxy/endpoint.test.d.ts +0 -1
  22. package/dist/modules/mcp/proxy/proxy.test.d.ts +0 -1
  23. package/dist/modules/mcp/proxy/wiring.test.d.ts +0 -1
  24. package/dist/modules/mcp/resources/explain.test.d.ts +0 -1
  25. package/dist/modules/mcp/screenshotClient.test.d.ts +0 -1
  26. package/dist/modules/mcp/tests/activity.test.d.ts +0 -1
  27. package/dist/modules/mcp/tests/agentRoundtrip.test.d.ts +0 -1
  28. package/dist/modules/mcp/tests/apply.test.d.ts +0 -1
  29. package/dist/modules/mcp/tests/bindings.test.d.ts +0 -1
  30. package/dist/modules/mcp/tests/cheapMistakes.test.d.ts +0 -1
  31. package/dist/modules/mcp/tests/components.test.d.ts +0 -1
  32. package/dist/modules/mcp/tests/connectors.test.d.ts +0 -1
  33. package/dist/modules/mcp/tests/css.test.d.ts +0 -1
  34. package/dist/modules/mcp/tests/flags.test.d.ts +0 -1
  35. package/dist/modules/mcp/tests/grants.test.d.ts +0 -1
  36. package/dist/modules/mcp/tests/guide.test.d.ts +0 -1
  37. package/dist/modules/mcp/tests/helpers.d.ts +0 -20
  38. package/dist/modules/mcp/tests/intents.test.d.ts +0 -1
  39. package/dist/modules/mcp/tests/interactions.test.d.ts +0 -1
  40. package/dist/modules/mcp/tests/layouts.test.d.ts +0 -1
  41. package/dist/modules/mcp/tests/look.test.d.ts +0 -1
  42. package/dist/modules/mcp/tests/pages.test.d.ts +0 -1
  43. package/dist/modules/mcp/tests/reads.test.d.ts +0 -1
  44. package/dist/modules/mcp/tests/schemaIds.test.d.ts +0 -1
  45. package/dist/modules/mcp/tests/search.test.d.ts +0 -1
  46. package/dist/modules/mcp/tests/skill.test.d.ts +0 -1
  47. package/dist/modules/mcp/tests/styles.test.d.ts +0 -1
  48. package/dist/modules/mcp/tests/tools.test.d.ts +0 -1
  49. package/dist/modules/mcp/tests/validation.test.d.ts +0 -1
  50. package/dist/modules/mcp/tools/describeOperation.test.d.ts +0 -1
  51. package/dist/modules/mcp/tools/operations/actions/actions.test.d.ts +0 -1
  52. package/dist/modules/mcp/tools/operations/data/data.test.d.ts +0 -1
  53. package/dist/modules/mcp/tools/operations/functions/functions.test.d.ts +0 -1
  54. package/dist/modules/mcp/tools/operations/schema/motion.test.d.ts +0 -1
  55. package/dist/modules/mcp/tools/operations/schema/translator.test.d.ts +0 -1
  56. package/dist/modules/mcp/tools/operations/style/fonts/fonts.test.d.ts +0 -1
  57. package/dist/modules/mcp/tools/render.test.d.ts +0 -1
  58. package/dist/modules/mcp/tools/shared/draftBatch.test.d.ts +0 -1
  59. package/dist/modules/mcp/tools/shared/effects.test.d.ts +0 -1
  60. package/dist/modules/mcp/tools/shared/lintDraft.test.d.ts +0 -1
  61. package/dist/modules/mcp/tools/shared/newSuggestions.test.d.ts +0 -1
  62. package/dist/modules/oauth/oauth.test.d.ts +0 -1
  63. package/dist/packageBoundary.test.d.ts +0 -1
  64. package/dist/pipeline.test.d.ts +0 -1
  65. package/dist/tests/httpRequest.d.ts +0 -16
package/CHANGELOG.md CHANGED
@@ -1,5 +1,191 @@
1
1
  # @plitzi/sdk-mcp
2
2
 
3
+ ## 0.38.21
4
+
5
+ ### Patch Changes
6
+
7
+ - 19fbc45: ## Server
8
+
9
+ - **Jobs: work longer than a request** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`, `@plitzi/sdk-elements`,
10
+ `@plitzi/plitzi-sdk`, `@plitzi/sdk-authoring`) — PZ-136. A space's code declares them in
11
+ `defineFunctions({ jobs: { train: { watch, maxSeconds, run(input, job, ctx) } } })` and starts them with
12
+ `ctx.jobs.start(name, input, { key })` (`get`, `pause`, `resume`, `cancel` beside it). They run in the actions' durable
13
+ queue — leased, taken over when a server dies, retried with backoff — slice by slice, in the sandbox, in a space's
14
+ runtime and natively alike: `job.save(state)` is the one checkpoint and the next slice starts with `job.state`;
15
+ `job.report(fraction, step)` says how far it is; on `job.signal` (`job.stopping`: `pause`, `cancel`, `limit`,
16
+ `shutdown`) the code has 5 s to save and return. A sandbox slice runs at most `sliceMs` and goes on in the next if it
17
+ saved since it began — one that saved nothing fails, so a job cannot loop forever; a runtime's runs until the job's
18
+ time is up. A real pause: `paused` keeps what it saved until resumed. Who may watch it is RBAC: whoever started it, and
19
+ whoever its `watch` (a channel's access) lets in, on `$job:<id>` — the platform's topic, retained — read with
20
+ `useJob(id)` or a `channel` element on `$job:{{ id }}`; the view never carries its input, its state, or an error other
21
+ than the code's own refusal. Limits per space (its plan) through `functions.jobs.limitsFor` —
22
+ `DEFAULT_FUNCTION_JOB_LIMITS` otherwise: 10 running across the account's spaces (`pool`, the oldest first), 1,000
23
+ waiting, 6 h, slices of 5 min / 30 s CPU / 10,000 calls, 1 MB of state.
24
+ - **The queue's types are the queue's** (`@plitzi/sdk-shared`, `@plitzi/sdk-server`): `ActionJobQueue`, `ActionJob`,
25
+ `ActionJobInput`, `ActionJobStatus`, `ActionJobAttempt`, `ActionJobSettlement`, `ActionJobQuery` are `JobQueue`, `Job`,
26
+ `JobInput`, `JobStatus`, `JobAttempt`, `JobSettlement`, `JobQuery` (`ACTION_JOB_STATUSES` → `JOB_STATUSES`,
27
+ `isJobStatus`, `TERMINAL_JOB_STATUSES`) — the queue holds a schedule's fires, the runs set for later and the jobs of
28
+ the spaces' functions. **What a job runs is its `target`**: `{ kind: 'action', name, trigger }` or
29
+ `{ kind: 'function', name, user, watch, at }`, in place of `actionId`, `trigger` and `function`; `listJobs` filters
30
+ by `kind` and `name`. Also on the queue: `paused` with `pause`/`resume`, `write` for what a running job saves and
31
+ reports, `state`/`progress`/`result`/`activeMs`, `heartbeat` answering `{ jobId, stop: 'cancel' | 'pause' }[]`, a
32
+ settlement's explicit `refund`, `requeue(…, { input, fresh })`. The helpers bring a store a release before left up
33
+ to it by themselves: MySQL's `ensureJobTables` gives each job its target from `action_id`/`trigger_type` and drops
34
+ them (`mysqlJobSchemaUpgrades` lists the statements for a deployment's own migrations); Mongo's queue does the same
35
+ to the documents on first use and drops the `spaceId_1_actionId_1_updatedAt_-1` index. A deployment with a queue of
36
+ its own: the contract tests (`describeJobQueue`) say what it must now do.
37
+ - **A runtime's routes stream** (`@plitzi/sdk-server`): a route under `/fn/` answered by a space's runtime is passed on
38
+ as it is written — its head at once, its body as the code writes it, with the platform's `ctx` — over the functions
39
+ protocol's new `head`/`chunk` messages, with no time limit once it answered; the deployment's own routes stream too.
40
+ A runtime's `endpoints` are for addresses outside `/fn/` (an MCP server at `/mcp`); anything that can live under
41
+ `/fn/` is a route. A sandbox's routes are answered whole, as before.
42
+ - **`createJobControl({ queue, realtime: { pubsub, kv } })`** (`@plitzi/sdk-server/actions`): an operator's
43
+ `pause`/`resume`/`cancel`/`requeue` from a process that serves no pages — a Queue panel's API — each said on
44
+ `$job:<id>` through the page server's own pub/sub and retained store, so a watcher hears what an operator did.
45
+ - **A run's user carries no session** (`RunUser`): what a step, a function and a job see of who asked.
46
+ - **The builder shows the jobs** (`@plitzi/plitzi-builder`, `@plitzi/sdk-shared`): **Server → Functions** lists the
47
+ jobs the code declares as it is typed (how long each may run; one spread in or built by a call is counted, not
48
+ guessed), and the inspector of one says how it is started and who may watch it, with the space's runs of it — live
49
+ while one moves, progress and step as its code reported them — and **Pause**, **Resume**, **Cancel** and **Run
50
+ again**. Through two new builder operations, `SpaceJobs(kind, name, status, page, pageSize)` — a `SpaceJob` each:
51
+ what it runs, where it is and how far, never its input, state or result — and `SpaceControlJob(jobId, control)`
52
+ (`JobControlAction`). Beside them in `@plitzi/sdk-shared/actions`: `JOB_KINDS`/`isJobKind`, and `actionAccessOf`, the
53
+ one reading of a channel's access, which the functions' manifest now reads a job's `watch` with too.
54
+
55
+ - **`ctx.oauth.token` for an SDK in the page** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`): Spotify's Web Playback,
56
+ Google's Picker and their kind ask the page for the access token themselves, and `ctx.oauth` kept every token on the
57
+ server. A connection that declares `exposeToken: true` now answers `ctx.oauth.token(name, { owner })` —
58
+ `{ token, type, expiresAt, scopes }`, renewed first when about to lapse — for a route of the code to hand to the
59
+ connection's owner. The refresh token never leaves; a connection without `exposeToken` refuses `token`, naming the
60
+ field. Through the sandbox's protocol and natively alike.
61
+
62
+ - **A page for some permissions, kept by the server** (`@plitzi/sdk-shared`, `@plitzi/sdk-server`,
63
+ `@plitzi/sdk-authoring`, `@plitzi/sdk-elements`, `@plitzi/plitzi-builder`): a page says
64
+ `access: { permissions: [...] }`, and a visitor without every one is answered 401 (or the page's sign-in redirect) or
65
+ 403 with a refusal drawn in the page's layout. Its content is withheld from everything that visitor is sent — the
66
+ render, the hydration payload, the space document (and a document built for somebody with access is not handed to
67
+ somebody without it by its name) and the page's server data. The builder's page settings take the permissions;
68
+ authoring refuses an `access` the server could not keep (`page-access`). A space read back as code — `plitzi create
69
+ --from`, the Export — keeps each page's `access`, so a protected page is never exported open. A page's handle carries
70
+ its `access` too, and a project's `visual/home.spec.ts` leaves such a page to a test that signs in, as it does a page
71
+ behind a session (`plitzi upgrade` rewrites an untouched one).
72
+ - **A project's first plugin is picked up while it runs** (`@plitzi/sdk-server`): `start:dev` registers a plugin folder
73
+ added under `src/plugins/` and reloads the open pages — but only watched that folder when it existed at boot, so a
74
+ project with no plugin yet (one taken out of a space that had none) showed nothing of its first `plitzi plugin add`
75
+ until a restart. With no folder, the server waits for it to appear and takes what it holds then.
76
+
77
+ ## Packaging
78
+ - **No package ships the declarations of its tests** (`@plitzi/sdk-server`, `@plitzi/sdk-mcp`, `@plitzi/plitzi-sdk`,
79
+ `@plitzi/plitzi-builder`, `@plitzi/sdk-elements`, `@plitzi/sdk-shared`): each app wrote its declarations with its own
80
+ `dts({ exclude })`, and the ones that left the tests out of it shipped a `.test.d.ts` beside their modules — 148 in
81
+ sdk-server alone — and the base config let a `.bench.d.ts` through. Every `dts()` now excludes
82
+ `'**/*.(test|bench).(ts|tsx)'`, and `yarn check:dist-exports` (CI, after `build:prod`) fails a build of any published
83
+ package that holds one.
84
+ - **`@plitzi/plitzi-builder` depends on `graphql` ^16** (was ^17): Apollo Server — the builder's API — supports only
85
+ 16, so a host installing the builder beside it got two copies. The builder uses nothing of 17's.
86
+
87
+ ## Elements
88
+ - **A dropdown closes when a link in it is chosen** (`@plitzi/sdk-elements`): a link stops its click from bubbling,
89
+ and the popup listened for clicks on the way up — so no menu of links ever closed, and a click that did reach it was
90
+ cancelled, which would have kept an external link from going anywhere. The popup now hears the click as it goes down
91
+ and lets it through.
92
+
93
+ ## CLI
94
+ - **A refused push says why** (`@plitzi/cli`): `space push functions` and the data push read any 409 as "changed since
95
+ your pull" — and the platform also answers 409 when the space has no private bucket to keep its code or data in, so
96
+ a first push to a space with no storage sent its author to pull, which changed nothing. The CLI now names a conflict
97
+ only when the refusal says `version`, and prints the platform's own words otherwise (where to add the bucket).
98
+ - **`create` points at the Academy** (`@plitzi/cli`): its last lines name the docs' Academy,
99
+ `https://docs.plitzi.com/academy`, for whoever is new to Plitzi — and the README the docs themselves.
100
+
101
+ ## Builder
102
+ - **A space served by Plitzi has a server, and the builder says so** (`@plitzi/plitzi-builder`, `@plitzi/sdk-shared`):
103
+ whether a space can run its actions and resolve its connectors was read off an SSR _credential_, which only a space
104
+ deployed to a page server of its own has — so every space served at `<space>.plitzi.app` showed "No server-rendered
105
+ deployment" over Server and counted its actions unavailable, while they ran. The deployments now carry what serves
106
+ them (`provider`), and a deployment served by SSR — Plitzi's or the space's — counts.
107
+ - **New Layout saves the layout** (`@plitzi/sdk-schema`): a layout is a root of the pages' tree, added with no anchor,
108
+ and `flatMapOf` found no tree for an empty anchor — so the server refused every new layout, saying it was "already
109
+ added". A root now goes into the pages' tree, and the refusal says which of the two it is.
110
+ - **Settings → Realtime: a space's channels, declared by hand** (`@plitzi/plitzi-builder`): `settings.channels` was
111
+ written only in code or by an agent over MCP, so a space made in the builder could not open a channel. The section
112
+ lists the channels with who may join (anyone, signed-in visitors, visitors with permissions), who may speak (pages, or
113
+ only the server's `Publish On Channel`), presence, a grant, keeping the last message and the two limits — saved only
114
+ when `channelProblems` passes, with what is wrong said under the channel otherwise.
115
+
116
+ - Updated dependencies [19fbc45]
117
+ - @plitzi/plitzi-sdk@0.38.21
118
+ - @plitzi/sdk-server@0.38.21
119
+ - @plitzi/sdk-authoring@0.38.21
120
+ - @plitzi/sdk-schema@0.38.21
121
+ - @plitzi/sdk-shared@0.38.21
122
+ - @plitzi/sdk-style@0.38.21
123
+
124
+ ## 0.38.20
125
+
126
+ ### Patch Changes
127
+
128
+ - c7c241a: ## Security
129
+
130
+ - **The `Origin` fallback reads the request's own authority before a forwarded one** (`@plitzi/sdk-server`): 0.38.19
131
+ took `X-Forwarded-Host` first, and with no proxy in front a client could send one naming this host on another port,
132
+ making that port's `Origin` this server's own. Now `:authority` or `Host` decide whenever they name the host the
133
+ request is answered as; `X-Forwarded-Host` only when they do not — a host that took its hostname from the header
134
+ (Express's `trust proxy`) trusts the proxy that wrote it. No option to set: what the host resolved says which one it
135
+ believes. The write guard (`crossSiteWrites`), the sign-in's login-CSRF check and `createOriginGuardMiddleware`
136
+ share it.
137
+
138
+ ## Server
139
+ - **`ctx.oauth`: OAuth 2.0 for a space's code, any provider** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`): a
140
+ connection is data in `defineFunctions({ oauth: { calendar: { issuer | authorizeUrl + tokenUrl, credential, scopes,
141
+ authorizeParams, clientAuth } } })` — an OpenID provider by its `issuer` (endpoints discovered), any other by its
142
+ endpoints; none is known to the platform by name. `ctx.oauth.connect(name, { returnTo, owner? })` answers the
143
+ consent URL (authorization code with PKCE); the platform answers `/fn/oauth/callback` — the one address to register
144
+ with every provider — exchanges the code with the app's id and secret from the named credential, and sends the
145
+ visitor back to `returnTo` with `?oauth=<name>&oauth_result=connected` (or `&oauth_error=`). `ctx.oauth.fetch(name,
146
+ url)` writes the token in, renewed before it lapses and once more on a 401, only to `allow.hosts`; `status` and
147
+ `disconnect` (revoked where the provider says). A token is a signed-in visitor's own by default, `{ owner: 'space' }`
148
+ the space's, or a key of the code's own; it is kept in the space's `kv` sealed with a key of the space's that no
149
+ `ctx.sign` reaches, so the code never holds one. In the sandbox, natively and in a space's runtime alike; a plugin's
150
+ functions declare and reach none. Needs `signingSecret`. Runs also carry the `origin` of the request that started
151
+ them (`ctx.origin` of a task context), what the callback address is made of.
152
+
153
+ ## Packages
154
+ - **No path a package does not export is written anywhere in the packages** (`@plitzi/plitzi-sdk`,
155
+ `@plitzi/sdk-shared`): two JSDoc comments sent readers to `@plitzi/sdk-authoring/testing`, which is not an entry —
156
+ `inspectRenders` is exported by `@plitzi/sdk-authoring`. `yarn check:specifiers` (in CI after the build) reads every
157
+ `@plitzi/<package>/<path>` the workspace writes — the code, its built declarations, JSDoc, skills and docs — against
158
+ what that package exports, so an import somebody would copy into a project and get `ERR_MODULE_NOT_FOUND` from cannot
159
+ be published again.
160
+
161
+ - **The packages that run in Node say which Node** (`@plitzi/sdk-server`, `@plitzi/cli`, `@plitzi/sdk-mcp`,
162
+ `@plitzi/sdk-authoring`): `"engines": { "node": ">=22.18" }`, the floor every project the CLI makes already declares —
163
+ installed on an older Node they now say so, instead of failing on the first API it lacks (`--env-file-if-exists`,
164
+ `--permission`, `Set#union`). The browser's packages declare none: a bundler reads them.
165
+
166
+ - **A short render guide, and each part of it alone** (`@plitzi/sdk-mcp`): `renderGuideText` stays the whole guide
167
+ (~30k characters); `renderGuideCore` is a third of it for an agent that counts its tokens — a voice assistant, a small
168
+ model — with the model of a render, the element types, the host's theme and what to do on a refusal, and the address
169
+ of every other section; `renderGuideTopics[topic]` and `renderGuideTopicUri(topic)` (`plitzi://render/guide/repeat`,
170
+ `…/data`…) serve each one, cut from the one text. The MCP server answers them as resources and through `plitzi_read`.
171
+
172
+ ## CLI
173
+ - **What Plitzi decided reaches the agent writing a report** (`@plitzi/cli`): `plitzi feedback`'s brief lists what was
174
+ reported and kept as it is — with why, and what to do instead — so a report files it under `changed` as `decided`
175
+ rather than carrying it as open, and the page has that status.
176
+
177
+ - **The CLI skill says what `ERR_MODULE_NOT_FOUND` into a `@plitzi` package's `dist` is** (`@plitzi/cli`): an import of
178
+ a path the package does not export — a file rather than its folder — with `plitzi doctor` to name each one and
179
+ `plitzi upgrade migrations --write` to rewrite it.
180
+
181
+ - Updated dependencies [c7c241a]
182
+ - @plitzi/plitzi-sdk@0.38.20
183
+ - @plitzi/sdk-server@0.38.20
184
+ - @plitzi/sdk-authoring@0.38.20
185
+ - @plitzi/sdk-schema@0.38.20
186
+ - @plitzi/sdk-shared@0.38.20
187
+ - @plitzi/sdk-style@0.38.20
188
+
3
189
  ## 0.38.19
4
190
 
5
191
  ### Patch Changes
package/README.md CHANGED
@@ -155,6 +155,12 @@ if (answer.rendered) {
155
155
  `base` is the style of the space that shows the widget: its tokens in both themes, its classes and its fonts come
156
156
  with it, so the widget looks like the page around it. Left out, the widget starts from nothing, as one in a chat does.
157
157
 
158
+ The guide is long (~30k characters) because it teaches everything a widget can do. An agent that counts its tokens — a
159
+ voice assistant, a small model — is handed `renderGuideCore` instead (a third of it: the model of a render, the
160
+ element types, the host's theme, what to do on a refusal) and reads the rest when a widget needs it: each section is
161
+ `renderGuideTopics[topic]`, addressed `renderGuideTopicUri(topic)` (`plitzi://render/guide/repeat`, `…/data`…), which
162
+ the core names. On this package's own server those addresses are resources, read with `plitzi_read`.
163
+
158
164
  ## Draft preview
159
165
 
160
166
  The two halves live in different packages, joined by a one-shot token:
@@ -5,8 +5,37 @@ export declare const RENDER_GUIDE_URI = "plitzi://render/guide";
5
5
  export declare const RENDER_TYPES_URI = "plitzi://render/types";
6
6
  /** How a widget is authored: what an agent reads before its first render, whichever server hands it the tool. */
7
7
  export declare const renderGuideText: string;
8
+ /** Each section of the guide by a name of its own, matched by how its heading starts. */
9
+ declare const RENDER_GUIDE_TOPIC_HEADINGS: {
10
+ readonly 'one-call': "Build the whole widget in ONE upsertElement";
11
+ readonly repeat: "Repeating rows";
12
+ readonly classes: "Style with reusable classes";
13
+ readonly layout: "Fit the panel";
14
+ readonly theme: "Match the host theme";
15
+ readonly types: "Element types";
16
+ readonly svg: "Draw with inline SVG";
17
+ readonly small: "Keep the call small";
18
+ readonly example: "Full worked example";
19
+ readonly data: "Data & interactivity";
20
+ readonly fails: "When it fails";
21
+ };
22
+ export type RenderGuideTopic = keyof typeof RENDER_GUIDE_TOPIC_HEADINGS;
23
+ /**
24
+ * The guide's sections, each readable alone (`plitzi://render/guide/<topic>`) — cut from the one text, so the whole guide
25
+ * and its parts cannot say different things. A heading no topic names fails here, at load, not in an agent's reading.
26
+ */
27
+ export declare const renderGuideTopics: Readonly<Record<RenderGuideTopic, string>>;
28
+ /** Where a topic is read: a resource of its own, and through `plitzi_read`. */
29
+ export declare const renderGuideTopicUri: (topic: RenderGuideTopic) => string;
30
+ /**
31
+ * The guide for a host that counts its tokens — a voice assistant, a small model: the model of a render, the sections a
32
+ * first widget cannot do without, and every other section by name and address, to read when the widget needs it.
33
+ * `renderGuideText` stays the whole guide, and is what a host with room should hand over.
34
+ */
35
+ export declare const renderGuideCore: string;
8
36
  /** The same two documents through the READ path (the router, hence plitzi_read), not only as MCP resources: an
9
37
  * agent that reaches for the batch-read tool — the reflex the guide itself teaches — must not be told its own
10
38
  * authoring guide does not exist. Space-independent, like the core singletons. */
11
39
  export declare const readRenderResource: (uri: string) => ResourceEnvelope<unknown> | undefined;
12
40
  export declare const registerRenderResources: (server: McpServer, log: McpLog) => void;
41
+ export {};
@@ -1,5 +1,6 @@
1
1
  import { elementCatalog } from "../catalogs/index.js";
2
2
  import { envelope, jsonContents } from "./envelope.js";
3
+ import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
3
4
  import { STYLE_STATES } from "@plitzi/sdk-shared/style";
4
5
  //#region src/modules/mcp/resources/renderGuide.ts
5
6
  var RENDER_GUIDE_URI = "plitzi://render/guide";
@@ -473,11 +474,69 @@ them; if both are needed, the render warns you and names the pair.
473
474
  The tool returns \`rendered: false\` with \`errors: [{ path, message, hint }]\`. Read the hint, fix that one op, and
474
475
  retry — you never lose the rest of the batch.
475
476
  `;
477
+ /** Each section of the guide by a name of its own, matched by how its heading starts. */
478
+ var RENDER_GUIDE_TOPIC_HEADINGS = {
479
+ "one-call": "Build the whole widget in ONE upsertElement",
480
+ repeat: "Repeating rows",
481
+ classes: "Style with reusable classes",
482
+ layout: "Fit the panel",
483
+ theme: "Match the host theme",
484
+ types: "Element types",
485
+ svg: "Draw with inline SVG",
486
+ small: "Keep the call small",
487
+ example: "Full worked example",
488
+ data: "Data & interactivity",
489
+ fails: "When it fails"
490
+ };
491
+ var [renderGuideIntro, ...renderGuideSections] = renderGuideText.split(/\n(?=## )/);
492
+ /**
493
+ * The guide's sections, each readable alone (`plitzi://render/guide/<topic>`) — cut from the one text, so the whole guide
494
+ * and its parts cannot say different things. A heading no topic names fails here, at load, not in an agent's reading.
495
+ */
496
+ var renderGuideTopics = (() => {
497
+ const topics = {};
498
+ for (const section of renderGuideSections) {
499
+ const heading = section.slice(3, section.indexOf("\n"));
500
+ const entry = Object.entries(RENDER_GUIDE_TOPIC_HEADINGS).find(([, start]) => heading.startsWith(start));
501
+ if (!entry) throw new Error(`[render guide] the section "${heading}" has no topic: name it in RENDER_GUIDE_TOPIC_HEADINGS`);
502
+ topics[entry[0]] = section.trim();
503
+ }
504
+ const missing = Object.keys(RENDER_GUIDE_TOPIC_HEADINGS).filter((topic) => !(topic in topics));
505
+ if (missing.length > 0) throw new Error(`[render guide] no section for the topic(s) ${missing.join(", ")}`);
506
+ return topics;
507
+ })();
508
+ /** Where a topic is read: a resource of its own, and through `plitzi_read`. */
509
+ var renderGuideTopicUri = (topic) => `${RENDER_GUIDE_URI}/${topic}`;
510
+ /** What the core carries whole: enough to render a correct, themed widget in one call and recover from a refusal. */
511
+ var CORE_TOPICS = [
512
+ "one-call",
513
+ "theme",
514
+ "types",
515
+ "small",
516
+ "fails"
517
+ ];
518
+ /**
519
+ * The guide for a host that counts its tokens — a voice assistant, a small model: the model of a render, the sections a
520
+ * first widget cannot do without, and every other section by name and address, to read when the widget needs it.
521
+ * `renderGuideText` stays the whole guide, and is what a host with room should hand over.
522
+ */
523
+ var renderGuideCore = [
524
+ renderGuideIntro.trim(),
525
+ ...CORE_TOPICS.map((topic) => renderGuideTopics[topic]),
526
+ [
527
+ "## More, when the widget needs it",
528
+ "Each is a section of the full guide (`plitzi://render/guide`), read on its own with `plitzi_read`:",
529
+ "",
530
+ ...Object.entries(RENDER_GUIDE_TOPIC_HEADINGS).filter(([topic]) => !CORE_TOPICS.some((core) => core === topic)).map(([topic, heading]) => `- \`${RENDER_GUIDE_URI}/${topic}\` — ${heading}`)
531
+ ].join("\n")
532
+ ].join("\n\n");
476
533
  /** The same two documents through the READ path (the router, hence plitzi_read), not only as MCP resources: an
477
534
  * agent that reaches for the batch-read tool — the reflex the guide itself teaches — must not be told its own
478
535
  * authoring guide does not exist. Space-independent, like the core singletons. */
479
536
  var readRenderResource = (uri) => {
480
537
  if (uri === "plitzi://render/guide") return envelope(renderGuideText);
538
+ const topic = uri.startsWith(`plitzi://render/guide/`) ? uri.slice(22) : void 0;
539
+ if (topic !== void 0 && Object.hasOwn(renderGuideTopics, topic)) return envelope(renderGuideTopics[topic]);
481
540
  if (uri === "plitzi://render/types") return envelope(renderTypes());
482
541
  };
483
542
  var registerRenderResources = (server, log) => {
@@ -494,6 +553,20 @@ var registerRenderResources = (server, log) => {
494
553
  log.resourceRead(RENDER_GUIDE_URI, performance.now() - start);
495
554
  return contents;
496
555
  });
556
+ server.registerResource("Render guide section", new ResourceTemplate(`${RENDER_GUIDE_URI}/{topic}`, { list: void 0 }), {
557
+ description: `One section of the render guide: ${Object.keys(RENDER_GUIDE_TOPIC_HEADINGS).join(", ")}.`,
558
+ mimeType: "text/markdown"
559
+ }, (uri) => {
560
+ const start = performance.now();
561
+ const topic = uri.href.slice(22);
562
+ const text = Object.hasOwn(renderGuideTopics, topic) ? renderGuideTopics[topic] : `No section "${topic}" in the render guide: ${Object.keys(RENDER_GUIDE_TOPIC_HEADINGS).join(", ")}.`;
563
+ log.resourceRead(uri.href, performance.now() - start);
564
+ return { contents: [{
565
+ uri: uri.href,
566
+ mimeType: "text/markdown",
567
+ text
568
+ }] };
569
+ });
497
570
  server.registerResource("Render element types", RENDER_TYPES_URI, {
498
571
  description: "Built-in element types a plitzi_render widget can use, with descriptions.",
499
572
  mimeType: "application/json"
@@ -505,4 +578,4 @@ var registerRenderResources = (server, log) => {
505
578
  });
506
579
  };
507
580
  //#endregion
508
- export { RENDER_GUIDE_URI, RENDER_TYPES_URI, readRenderResource, registerRenderResources, renderGuideText };
581
+ export { RENDER_GUIDE_URI, RENDER_TYPES_URI, readRenderResource, registerRenderResources, renderGuideCore, renderGuideText, renderGuideTopicUri, renderGuideTopics };
@@ -73,7 +73,7 @@ var createMcpServer = async ({ adapters, getGrant, preview, screenshot, logger,
73
73
  const getSpace = () => spacePromise ??= loadSpace();
74
74
  const server = new McpServer({
75
75
  name: "plitzi-mcp",
76
- version: "0.38.19"
76
+ version: "0.38.21"
77
77
  }, { instructions: hasSpace ? serverInstructions : widgetsOnlyInstructions });
78
78
  const { getChanges } = adapters;
79
79
  registerResources(server, getSpace, MCP_ENV, log, hasSpace, getChanges ? (query) => getChanges(requireSpaceId(), MCP_ENV, query) : void 0);
package/dist/render.d.ts CHANGED
@@ -2,9 +2,11 @@
2
2
  * space, no OAuth.
3
3
  *
4
4
  * Import it as `@plitzi/sdk-mcp/render` in a project whose own agent draws UI in its own pages: register `render` as
5
- * a tool of the project's MCP server with `renderWidgetShape` as its input and `renderGuideText` for the agent to read,
5
+ * a tool of the project's MCP server with `renderWidgetShape` as its input and `renderGuideText` for the agent to read
6
+ * (`renderGuideCore` when it counts its tokens, with `renderGuideTopics` to serve the rest on demand),
6
7
  * hand it `base` — the style of the project's space — so the widget looks like the page around it, and draw the
7
8
  * answer with the `plitziSdk` element (its `offlineData`). */
8
9
  export { HOST_PAGE_REF as RENDER_ROOT_REF, render, renderWidgetShape } from './modules/mcp/tools/renderWidget';
9
- export { renderGuideText } from './modules/mcp/resources/renderGuide';
10
+ export { renderGuideCore, renderGuideText, renderGuideTopics, renderGuideTopicUri } from './modules/mcp/resources/renderGuide';
11
+ export type { RenderGuideTopic } from './modules/mcp/resources/renderGuide';
10
12
  export type { RenderOptions, RenderResponse, RenderWidgetInput } from './modules/mcp/tools/renderWidget';
package/dist/render.js CHANGED
@@ -1,3 +1,3 @@
1
- import { renderGuideText } from "./modules/mcp/resources/renderGuide.js";
1
+ import { renderGuideCore, renderGuideText, renderGuideTopicUri, renderGuideTopics } from "./modules/mcp/resources/renderGuide.js";
2
2
  import { HOST_PAGE_REF, render, renderWidgetShape } from "./modules/mcp/tools/renderWidget.js";
3
- export { HOST_PAGE_REF as RENDER_ROOT_REF, render, renderGuideText, renderWidgetShape };
3
+ export { HOST_PAGE_REF as RENDER_ROOT_REF, render, renderGuideCore, renderGuideText, renderGuideTopicUri, renderGuideTopics, renderWidgetShape };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-mcp",
3
- "version": "0.38.19",
3
+ "version": "0.38.21",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist",
@@ -34,16 +34,19 @@
34
34
  "url": "https://github.com/plitzi/plitzi-workspace.git"
35
35
  },
36
36
  "type": "module",
37
+ "engines": {
38
+ "node": ">=22.18"
39
+ },
37
40
  "sideEffects": false,
38
41
  "dependencies": {
39
42
  "@modelcontextprotocol/ext-apps": "^1.7.5",
40
43
  "@modelcontextprotocol/sdk": "^1.32.1",
41
- "@plitzi/plitzi-sdk": "0.38.19",
42
- "@plitzi/sdk-authoring": "0.38.19",
43
- "@plitzi/sdk-schema": "0.38.19",
44
- "@plitzi/sdk-server": "0.38.19",
45
- "@plitzi/sdk-shared": "0.38.19",
46
- "@plitzi/sdk-style": "0.38.19",
44
+ "@plitzi/plitzi-sdk": "0.38.21",
45
+ "@plitzi/sdk-authoring": "0.38.21",
46
+ "@plitzi/sdk-schema": "0.38.21",
47
+ "@plitzi/sdk-server": "0.38.21",
48
+ "@plitzi/sdk-shared": "0.38.21",
49
+ "@plitzi/sdk-style": "0.38.21",
47
50
  "ejs": "^7.0.2",
48
51
  "esbuild": "^0.28.2",
49
52
  "zod": "^4.6.7"
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,20 +0,0 @@
1
- import { Space } from '../helpers';
2
- import { Operation } from '../tools';
3
- import { Persisters, ValidationResult } from '../types';
4
- declare const buildSpace: () => Space;
5
- declare const capturing: (space: Space) => {
6
- persisters: Persisters;
7
- saved: () => Space;
8
- };
9
- declare const spaceWithRoute: () => Space;
10
- declare const varOp: (pageRef: string, type: string, value: string) => Operation;
11
- declare const scopeSpace: () => Space;
12
- declare const malformedSpace: () => Space;
13
- /**
14
- * What `plitzi_apply`'s dryRun answers of a batch, as one result to assert on: the same `draftBatch` it runs before
15
- * anything is saved, so a refusal here is the one an agent meets.
16
- */
17
- declare const checkBatch: (input: {
18
- operations: Operation[];
19
- }, space: Space) => ValidationResult;
20
- export { buildSpace, capturing, checkBatch, spaceWithRoute, varOp, scopeSpace, malformedSpace };
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,16 +0,0 @@
1
- import { default as http } from 'node:http';
2
- export type HttpProbeResult = {
3
- status: number;
4
- body: string;
5
- headers: http.IncomingHttpHeaders;
6
- };
7
- /** Minimal HTTP client for the server-level tests. They drive a real listening server rather than calling a
8
- * handler, because what is under test is the pipeline — which stage answers, and in what order. */
9
- export declare const httpRequest: (port: number, method: string, path: string, headers?: Record<string, string>, body?: string) => Promise<HttpProbeResult>;
10
- /** Headers every MCP JSON-RPC call needs: the Streamable HTTP transport refuses a request that does not accept
11
- * both a JSON body and an SSE stream. */
12
- export declare const RPC_HEADERS: {
13
- 'Content-Type': string;
14
- Accept: string;
15
- };
16
- export declare const jsonRpc: (method: string, params?: unknown, id?: number) => string;