@livepreso/cdk 0.1.0 → 0.2.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.
@@ -100,7 +100,7 @@ __webpack_require__.a(__webpack_module__, async function (__rspack_load_async_de
100
100
  /* import */ var commander__rspack_import_1 = __webpack_require__(444);
101
101
  /* import */ var fs_extra_esm__rspack_import_2 = __webpack_require__(674);
102
102
  /* import */ var path__rspack_import_3 = __webpack_require__(928);
103
- /* import */ var _server_mjs__rspack_import_4 = __webpack_require__(144);
103
+ /* import */ var _server_mjs__rspack_import_4 = __webpack_require__(671);
104
104
  /* import */ var _mcp_stdio_proxy_mjs__rspack_import_5 = __webpack_require__(270);
105
105
  /* import */ var handle_cli_error__rspack_import_6 = __webpack_require__(648);
106
106
  /* import */ var _cli_feeds_index_mjs__rspack_import_7 = __webpack_require__(377);
@@ -165,12 +165,16 @@ commander__rspack_import_1.program.command("dev")
165
165
  .summary("start the development server")
166
166
  // Get rid of this... use the current directory cli is run in I reckon
167
167
  .argument("dir", "project directory")
168
- .action(async (projectDir) => {
168
+ .option(
169
+ "--port <number>",
170
+ "serve on this port rather than the one the package name gives; the MCP server and check look only on that one",
171
+ parseWholeNumber,
172
+ )
173
+ .action(async (projectDir, options) => {
169
174
  const resolvedProjectDir = path__rspack_import_3.resolve(projectDir);
170
175
  const distPath = path__rspack_import_3.join(resolvedProjectDir, "dist");
171
176
  const pkg = await (0,fs_extra_esm__rspack_import_2.readJson)(path__rspack_import_3.join(resolvedProjectDir, "package.json"));
172
- // The MCP server and check work out the same port, so this is the only one they can reach.
173
- const port = (0,_utils_get_port_by_name_mjs__rspack_import_12/* .getPortByName */.u)(pkg.name);
177
+ const port = options.port ?? (0,_utils_get_port_by_name_mjs__rspack_import_12/* .getPortByName */.u)(pkg.name);
174
178
 
175
179
  await reportStaleBundle();
176
180
 
@@ -1154,15 +1158,47 @@ function selectTargets(targets, patterns) {
1154
1158
  }
1155
1159
 
1156
1160
  /** Lists the operation names the interface offers on each target, keyed by target. */
1157
- function groupOperationsByTarget(read) {
1161
+ function groupOperationsByTarget(described) {
1162
+ const namesByTarget = {};
1163
+
1164
+ // One declaration covers every target using the same component, so its
1165
+ // `on` lists the names each of them got from it.
1166
+ for (const { on } of described.operations ?? []) {
1167
+ for (const [target, names] of Object.entries(on ?? {})) {
1168
+ const found = namesByTarget[target] ?? [];
1169
+
1170
+ namesByTarget[target] = [...found, ...names];
1171
+ }
1172
+ }
1173
+
1174
+ return Object.fromEntries(
1175
+ Object.entries(namesByTarget).map(([target, names]) => [
1176
+ target,
1177
+ names.sort(),
1178
+ ]),
1179
+ );
1180
+ }
1181
+
1182
+ /**
1183
+ * Every target's operation names, keyed by target.
1184
+ */
1185
+ async function describeEachTarget(describe, keys) {
1186
+ const described = await describe(keys);
1187
+
1188
+ if (!described.refused) {
1189
+ return groupOperationsByTarget(described);
1190
+ }
1191
+
1192
+ // One target the deck cannot describe refuses the whole batch, so the rest
1193
+ // are asked for one at a time rather than reported as having none.
1158
1194
  const operationsByTarget = {};
1159
1195
 
1160
- for (const [target, fields] of Object.entries(read.targets ?? {})) {
1161
- const names = Object.values(fields).flatMap((aspects) =>
1162
- (aspects.calls ?? []).map((call) => call.name),
1163
- );
1196
+ for (const key of keys) {
1197
+ const one = await describe([key]);
1164
1198
 
1165
- operationsByTarget[target] = names.sort();
1199
+ if (!one.refused) {
1200
+ Object.assign(operationsByTarget, groupOperationsByTarget(one));
1201
+ }
1166
1202
  }
1167
1203
 
1168
1204
  return operationsByTarget;
@@ -1441,22 +1477,26 @@ async function describeAllTargets(reusablePage, targets) {
1441
1477
  try {
1442
1478
  const { page } = await reusablePage.prepare((/* inlined export .SLIDES */"slides"));
1443
1479
  const keys = targets.map((target) => target.key);
1444
- const read = await page.evaluate(
1445
- (targetKeys) =>
1446
- window.cdk.run("read_deck", {
1447
- targets: targetKeys,
1448
- select: ["calls"],
1449
- }),
1480
+
1481
+ return await describeEachTarget(
1482
+ (targetKeys) => describeKeys(page, targetKeys),
1450
1483
  keys,
1451
1484
  );
1452
-
1453
- return groupOperationsByTarget(read);
1454
1485
  } catch {
1455
1486
  // A deck below project file version 4 has no interface, so nothing has operations.
1456
1487
  return {};
1457
1488
  }
1458
1489
  }
1459
1490
 
1491
+ function describeKeys(page, keys) {
1492
+ return page.evaluate(
1493
+ // Not `read_deck`: that is pruned to the reads a model should make, and
1494
+ // a spec here names an operation outright.
1495
+ (targetKeys) => window.cdk.run("describe_targets", { targets: targetKeys }),
1496
+ keys,
1497
+ );
1498
+ }
1499
+
1460
1500
  ;// CONCATENATED MODULE: ./src/backend/cli/headless/index.mjs
1461
1501
 
1462
1502
 
@@ -2834,24 +2874,25 @@ function fixtureTools({ pages }) {
2834
2874
  /**
2835
2875
  * The parts of a field `read_deck` returns, as `select` names them.
2836
2876
  *
2837
- * A path reaching into `calls` adds that part to every call listed, under the
2838
- * name the rest of the interface gives it.
2877
+ * A path reaching into `mutations` or `queries` adds that part to every
2878
+ * operation listed there, under the name the rest of the interface gives it.
2839
2879
  *
2840
2880
  * Kept apart from both so `llm/definitions.js` can publish the list without
2841
2881
  * importing the interface, which it must stay free of.
2842
2882
  */
2843
2883
 
2844
- /** Each part of a call, named as a target describes it. */
2845
- const CALL_PARTS = ["description", "errors"];
2884
+ /** Each part of an operation, named as a target describes it. */
2885
+ const OPERATION_PARTS = ["description", "errors"];
2846
2886
 
2847
2887
  /**
2848
2888
  * The aspects a deck-wide read leaves out, because serving them means reading
2849
- * the prose on every slide in the deck. `calls` names the operations without
2850
- * it, which is what a caller needs before writing.
2889
+ * the prose on every slide in the deck. `mutations` and `queries` name the
2890
+ * operations without it, which is what a caller needs before writing.
2851
2891
  */
2852
2892
  const NEEDS_SLIDE = new Set([
2853
2893
  "description",
2854
- ...CALL_PARTS.map((part) => `calls.${part}`),
2894
+ ...OPERATION_PARTS.map((part) => `mutations.${part}`),
2895
+ ...OPERATION_PARTS.map((part) => `queries.${part}`),
2855
2896
  ]);
2856
2897
 
2857
2898
  const ASPECTS = [
@@ -2860,8 +2901,10 @@ const ASPECTS = [
2860
2901
  "default",
2861
2902
  "type",
2862
2903
  "description",
2863
- "calls",
2864
- ...CALL_PARTS.map((part) => `calls.${part}`),
2904
+ "mutations",
2905
+ ...OPERATION_PARTS.map((part) => `mutations.${part}`),
2906
+ "queries",
2907
+ ...OPERATION_PARTS.map((part) => `queries.${part}`),
2865
2908
  ];
2866
2909
 
2867
2910
  /**
@@ -2988,7 +3031,7 @@ const TOOL_DEFINITIONS = [
2988
3031
  description: stripIndent(`
2989
3032
  Change content across any number of targets in one request. Every
2990
3033
  step changes something, or is a query that takes input and is listed
2991
- under "calls". Read everything else with read_deck, which covers a
3034
+ under "queries". Read everything else with read_deck, which covers a
2992
3035
  whole deck in one call. A target's steps succeed or fail together
2993
3036
  and leave other targets alone: "succeeded" counts the steps that
2994
3037
  went through, and "refused" names each target whose steps were all
@@ -2996,9 +3039,9 @@ const TOOL_DEFINITIONS = [
2996
3039
  was written. A later step sees what an earlier one did.
2997
3040
 
2998
3041
  Each step's input has to match that operation's inputSchema, which
2999
- read_deck gives under "calls", or the step refuses its own target.
3000
- The call's description says what the value itself may contain, which
3001
- differs by field.
3042
+ read_deck gives under "mutations" or "queries", or the step refuses
3043
+ that target. The operation's description says what the value itself
3044
+ may contain, which differs by field.
3002
3045
  `),
3003
3046
  inputSchema: {
3004
3047
  type: "object",
@@ -3019,18 +3062,24 @@ const TOOL_DEFINITIONS = [
3019
3062
  what reverting restores
3020
3063
  type "text" or "image"
3021
3064
  description what the field is for
3022
- calls what can be done to the field: each operation
3023
- by name, with the input it takes. A field
3024
- with none cannot be changed.
3025
- calls.description what that call does and what it allows a
3026
- value to contain
3027
- calls.errors the reasons it can refuse
3028
-
3029
- "calls" carries the input every call takes, so it is all you need
3030
- before writing. Read the calls for every field you will write: two
3031
- fields on one target often take different input.
3032
-
3033
- Where several calls take the same input, each one carries
3065
+ mutations what can be done to the field: each one by
3066
+ name, with the input it takes. A field with
3067
+ none cannot be changed.
3068
+ mutations.description what that mutation does and what it allows a
3069
+ value to contain
3070
+ mutations.errors the reasons it can refuse
3071
+ queries the searches to run against the field. Each
3072
+ one takes input; run it with call_actions.
3073
+ A query the read runs for you has its
3074
+ result under "value".
3075
+ queries.description what that query reports
3076
+ queries.errors the reasons it can refuse
3077
+
3078
+ "mutations" carries the input every one takes, so it is all you need
3079
+ before writing. Read the mutations for every field you will write:
3080
+ two fields on one target often take different input.
3081
+
3082
+ Where several operations take the same input, each one carries
3034
3083
  "inputShape" in place of "inputSchema", naming an entry under
3035
3084
  "inputShapes" at the top of the answer. That entry is the schema,
3036
3085
  read exactly as "inputSchema" would be.
@@ -3042,12 +3091,12 @@ const TOOL_DEFINITIONS = [
3042
3091
  for where its key may not say, and put every wording you mean in the
3043
3092
  one query.
3044
3093
 
3045
- "value", "from", "default", "type" and "calls" come back for the
3046
- whole deck at once. "description" and the paths under "calls" are
3047
- read a target at a time: ask for them deck-wide and they come back
3048
- under "omitted", with the rest answered as usual. "calls" alone
3049
- names every operation and the input it takes, which is what a write
3050
- needs.
3094
+ "value", "from", "default", "type", "mutations" and "queries" come
3095
+ back for the whole deck at once. "description" and the paths under
3096
+ "mutations" and "queries" are read a target at a time: ask for them
3097
+ deck-wide and they come back under "omitted", with the rest returned
3098
+ as usual. "mutations" alone names every one and the input it takes,
3099
+ which is what a write needs.
3051
3100
 
3052
3101
  Every field comes back whether anything is in it or not. "value" is
3053
3102
  what the field shows: an edit where the field has been edited, and
@@ -3056,7 +3105,7 @@ const TOOL_DEFINITIONS = [
3056
3105
  an edit nor copy the deck built in.
3057
3106
 
3058
3107
  A field with no "value" or "default" controls the slide rather than
3059
- holding text. Call it to change the slide.
3108
+ storing text. Call it to change the slide.
3060
3109
 
3061
3110
  "from": "query" marks a value the field's query returned, such as copy
3062
3111
  from a feed. One query gives the value itself, and several give an
@@ -3064,8 +3113,8 @@ const TOOL_DEFINITIONS = [
3064
3113
  "unread" with the reason. For "no-render", show the slide and read
3065
3114
  again.
3066
3115
 
3067
- A call listed with "kind": "query" is one that takes input, which is
3068
- why read_deck does not answer it. Run it with call_actions.
3116
+ Every query under "queries" takes input, which is why read_deck does
3117
+ not return its value. Run one with call_actions.
3069
3118
 
3070
3119
  Fields under "shared" are one value the whole deck reads: name the
3071
3120
  target each one gives to change it, and every target showing it
@@ -3074,8 +3123,9 @@ const TOOL_DEFINITIONS = [
3074
3123
  is named under "unread".
3075
3124
 
3076
3125
  A target named under "unwritable" cannot have a stored value
3077
- changed, and the entry says why. A call marked "stateless" still
3078
- runs there. Read the other calls to learn what a field takes.
3126
+ changed, and the entry says why. An operation marked "stateless"
3127
+ still runs there. Read the other operations to learn what a field
3128
+ takes.
3079
3129
  `),
3080
3130
  inputSchema: {
3081
3131
  type: "object",
@@ -3713,7 +3763,7 @@ function allTools(deps = {}) {
3713
3763
 
3714
3764
 
3715
3765
  },
3716
- 144(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
3766
+ 671(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
3717
3767
 
3718
3768
  // EXPORTS
3719
3769
  __webpack_require__.d(__webpack_exports__, {
@@ -3729,6 +3779,7 @@ __webpack_require__.d(routes_namespaceObject, {
3729
3779
  deckAssetsRoutes: () => (deckAssetsRoutes),
3730
3780
  envsRoutes: () => (envsRoutes),
3731
3781
  feedsRoutes: () => (feedsRoutes),
3782
+ interceptsRoutes: () => (interceptsRoutes),
3732
3783
  projectRoutes: () => (projectRoutes),
3733
3784
  publicRoutes: () => (publicRoutes),
3734
3785
  rootRoutes: () => (rootRoutes) });
@@ -4123,6 +4174,65 @@ function customerRoutes(config, fastify) {
4123
4174
  );
4124
4175
  }
4125
4176
 
4177
+ ;// CONCATENATED MODULE: ./src/shared/cdk-files.mjs
4178
+ // Where a deck's `.cdk/intercepts` folder is served from, so the page can
4179
+ // import the modules in it.
4180
+ const CDK_INTERCEPTS_PREFIX = "/server/cdk/intercepts/";
4181
+
4182
+ ;// CONCATENATED MODULE: ./src/backend/utils/get-intercepts.mjs
4183
+
4184
+
4185
+
4186
+ /**
4187
+ * The intercept files a deck ships, keyed by filename without the extension.
4188
+ */
4189
+ async function getIntercepts(config) {
4190
+ const { projectDir } = config;
4191
+ const interceptsPath = external_path_.join(projectDir, ".cdk/intercepts");
4192
+
4193
+ const filepaths = await external_fast_glob_["default"].async([`${interceptsPath}/*.js`]);
4194
+
4195
+ // Matching is first-match-wins, so two overlapping patterns must not swap
4196
+ // precedence between machines. fast-glob gives no order of its own.
4197
+ filepaths.sort();
4198
+
4199
+ return filepaths.map((file) => {
4200
+ const filename = external_path_.basename(file);
4201
+
4202
+ return { key: filename.replace(/\.js$/, ""), filename };
4203
+ });
4204
+ }
4205
+
4206
+ ;// CONCATENATED MODULE: ./src/backend/routes/intercepts.mjs
4207
+
4208
+
4209
+
4210
+
4211
+
4212
+
4213
+ function interceptsRoutes(config, fastify) {
4214
+ fastify.get(
4215
+ "/server/api/intercepts/",
4216
+ { config: { internalName: "intercepts" } },
4217
+ async (_request, reply) => {
4218
+ reply.send({ results: await getIntercepts(config) });
4219
+ },
4220
+ );
4221
+
4222
+ fastify.register(async (scope) => {
4223
+ await scope.register(__rspack_external__fastify_static_a76d2a9e["default"], {
4224
+ root: external_path_.join(config.projectDir, ".cdk/intercepts"),
4225
+ prefix: CDK_INTERCEPTS_PREFIX,
4226
+ wildcard: true,
4227
+ });
4228
+ });
4229
+
4230
+ config.listedRoutes.push({
4231
+ path: `${CDK_INTERCEPTS_PREFIX}*`,
4232
+ internalName: "cdk-intercepts",
4233
+ });
4234
+ }
4235
+
4126
4236
  ;// CONCATENATED MODULE: ./src/backend/routes/index.mjs
4127
4237
 
4128
4238
 
@@ -4134,6 +4244,7 @@ function customerRoutes(config, fastify) {
4134
4244
 
4135
4245
 
4136
4246
 
4247
+
4137
4248
  ;// CONCATENATED MODULE: external "@fastify/websocket"
4138
4249
 
4139
4250
  ;// CONCATENATED MODULE: ./src/backend/pages/index.mjs
@@ -5085,7 +5196,8 @@ const PRESENT_STATES = [
5085
5196
  {
5086
5197
  title: "Add slides",
5087
5198
  key: "add-slides",
5088
- description: "Test a template in various stages",
5199
+ description:
5200
+ "Test a template dropped into a preso from the slide picker",
5089
5201
  bodyClasses: ["master", "omnipreso", "livepreso"],
5090
5202
  tabs: [_tabs_mjs__rspack_import_0/* .TEMPLATES */.QT],
5091
5203
  children: [
@@ -5100,7 +5212,8 @@ const PRESENT_STATES = [
5100
5212
  {
5101
5213
  title: "User template",
5102
5214
  key: "user-template",
5103
- description: "A template override owned by a salesperson",
5215
+ description:
5216
+ "A template a salesperson saved as their own, dropped into a preso",
5104
5217
  bodyClasses: ["edit-mode"],
5105
5218
  showEditables: true,
5106
5219
  editStore: TEMPLATE_CONTEXT,
@@ -5112,7 +5225,8 @@ const PRESENT_STATES = [
5112
5225
  {
5113
5226
  title: "Unsaved custom slide",
5114
5227
  key: "custom-slide",
5115
- description: "A custom slide dropped in, before it is uploaded",
5228
+ description:
5229
+ "A template dropped into a preso as a custom slide, before it is uploaded",
5116
5230
  bodyClasses: ["edit-mode"],
5117
5231
  showEditables: true,
5118
5232
  editStore: TEMPLATE_CONTEXT,
@@ -5126,7 +5240,8 @@ const PRESENT_STATES = [
5126
5240
  {
5127
5241
  title: "Saved custom slide",
5128
5242
  key: "custom-slide-saved",
5129
- description: "A custom slide dropped in, once it is uploaded",
5243
+ description:
5244
+ "A template dropped into a preso as a custom slide, once it is uploaded",
5130
5245
  bodyClasses: ["edit-mode"],
5131
5246
  showEditables: true,
5132
5247
  editStore: TEMPLATE_CONTEXT,