@livepreso/cdk 0.0.4 → 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
  /**
@@ -2987,7 +3030,8 @@ const TOOL_DEFINITIONS = [
2987
3030
  name: "call_actions",
2988
3031
  description: stripIndent(`
2989
3032
  Change content across any number of targets in one request. Every
2990
- step changes something: read with read_deck instead, which covers a
3033
+ step changes something, or is a query that takes input and is listed
3034
+ under "queries". Read everything else with read_deck, which covers a
2991
3035
  whole deck in one call. A target's steps succeed or fail together
2992
3036
  and leave other targets alone: "succeeded" counts the steps that
2993
3037
  went through, and "refused" names each target whose steps were all
@@ -2995,9 +3039,9 @@ const TOOL_DEFINITIONS = [
2995
3039
  was written. A later step sees what an earlier one did.
2996
3040
 
2997
3041
  Each step's input has to match that operation's inputSchema, which
2998
- read_deck gives under "calls", or the step refuses its own target.
2999
- The call's description says what the value itself may contain, which
3000
- 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.
3001
3045
  `),
3002
3046
  inputSchema: {
3003
3047
  type: "object",
@@ -3013,23 +3057,29 @@ const TOOL_DEFINITIONS = [
3013
3057
 
3014
3058
  value the text a field shows
3015
3059
  from where that text came from: "default",
3016
- "everyone" or "personal"
3060
+ "everyone", "personal" or "query"
3017
3061
  default the copy the deck was built with, which is
3018
3062
  what reverting restores
3019
3063
  type "text" or "image"
3020
3064
  description what the field is for
3021
- calls what can be done to the field: each operation
3022
- by name, with the input it takes. A field
3023
- with none cannot be changed.
3024
- calls.description what that call does and what it allows a
3025
- value to contain
3026
- calls.errors the reasons it can refuse
3027
-
3028
- "calls" carries the input every call takes, so it is all you need
3029
- before writing. Read the calls for every field you will write: two
3030
- fields on one target often take different input.
3031
-
3032
- 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
3033
3083
  "inputShape" in place of "inputSchema", naming an entry under
3034
3084
  "inputShapes" at the top of the answer. That entry is the schema,
3035
3085
  read exactly as "inputSchema" would be.
@@ -3041,12 +3091,12 @@ const TOOL_DEFINITIONS = [
3041
3091
  for where its key may not say, and put every wording you mean in the
3042
3092
  one query.
3043
3093
 
3044
- "value", "from", "default", "type" and "calls" come back for the
3045
- whole deck at once. "description" and the paths under "calls" are
3046
- read a target at a time: ask for them deck-wide and they come back
3047
- under "omitted", with the rest answered as usual. "calls" alone
3048
- names every operation and the input it takes, which is what a write
3049
- 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.
3050
3100
 
3051
3101
  Every field comes back whether anything is in it or not. "value" is
3052
3102
  what the field shows: an edit where the field has been edited, and
@@ -3054,15 +3104,28 @@ const TOOL_DEFINITIONS = [
3054
3104
  of the two it is, and a "value" of null is a field that has neither
3055
3105
  an edit nor copy the deck built in.
3056
3106
 
3107
+ A field with no "value" or "default" controls the slide rather than
3108
+ storing text. Call it to change the slide.
3109
+
3110
+ "from": "query" marks a value the field's query returned, such as copy
3111
+ from a feed. One query gives the value itself, and several give an
3112
+ object keyed by query name. A query that could not run is under
3113
+ "unread" with the reason. For "no-render", show the slide and read
3114
+ again.
3115
+
3116
+ Every query under "queries" takes input, which is why read_deck does
3117
+ not return its value. Run one with call_actions.
3118
+
3057
3119
  Fields under "shared" are one value the whole deck reads: name the
3058
3120
  target each one gives to change it, and every target showing it
3059
3121
  changes. A call carries "requiresRender" where it only runs on the
3060
3122
  slide the preview has open. A target that could not be read at all
3061
3123
  is named under "unread".
3062
3124
 
3063
- A target named under "unwritable" cannot be changed, and the entry
3064
- says why. Its calls still answer what can be done where a value
3065
- belongs, so read them to learn what a field takes.
3125
+ A target named under "unwritable" cannot have a stored value
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.
3066
3129
  `),
3067
3130
  inputSchema: {
3068
3131
  type: "object",
@@ -3700,7 +3763,7 @@ function allTools(deps = {}) {
3700
3763
 
3701
3764
 
3702
3765
  },
3703
- 144(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
3766
+ 671(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
3704
3767
 
3705
3768
  // EXPORTS
3706
3769
  __webpack_require__.d(__webpack_exports__, {
@@ -3716,6 +3779,7 @@ __webpack_require__.d(routes_namespaceObject, {
3716
3779
  deckAssetsRoutes: () => (deckAssetsRoutes),
3717
3780
  envsRoutes: () => (envsRoutes),
3718
3781
  feedsRoutes: () => (feedsRoutes),
3782
+ interceptsRoutes: () => (interceptsRoutes),
3719
3783
  projectRoutes: () => (projectRoutes),
3720
3784
  publicRoutes: () => (publicRoutes),
3721
3785
  rootRoutes: () => (rootRoutes) });
@@ -4110,6 +4174,65 @@ function customerRoutes(config, fastify) {
4110
4174
  );
4111
4175
  }
4112
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
+
4113
4236
  ;// CONCATENATED MODULE: ./src/backend/routes/index.mjs
4114
4237
 
4115
4238
 
@@ -4121,6 +4244,7 @@ function customerRoutes(config, fastify) {
4121
4244
 
4122
4245
 
4123
4246
 
4247
+
4124
4248
  ;// CONCATENATED MODULE: external "@fastify/websocket"
4125
4249
 
4126
4250
  ;// CONCATENATED MODULE: ./src/backend/pages/index.mjs
@@ -5072,7 +5196,8 @@ const PRESENT_STATES = [
5072
5196
  {
5073
5197
  title: "Add slides",
5074
5198
  key: "add-slides",
5075
- description: "Test a template in various stages",
5199
+ description:
5200
+ "Test a template dropped into a preso from the slide picker",
5076
5201
  bodyClasses: ["master", "omnipreso", "livepreso"],
5077
5202
  tabs: [_tabs_mjs__rspack_import_0/* .TEMPLATES */.QT],
5078
5203
  children: [
@@ -5087,7 +5212,8 @@ const PRESENT_STATES = [
5087
5212
  {
5088
5213
  title: "User template",
5089
5214
  key: "user-template",
5090
- description: "A template override owned by a salesperson",
5215
+ description:
5216
+ "A template a salesperson saved as their own, dropped into a preso",
5091
5217
  bodyClasses: ["edit-mode"],
5092
5218
  showEditables: true,
5093
5219
  editStore: TEMPLATE_CONTEXT,
@@ -5099,7 +5225,8 @@ const PRESENT_STATES = [
5099
5225
  {
5100
5226
  title: "Unsaved custom slide",
5101
5227
  key: "custom-slide",
5102
- 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",
5103
5230
  bodyClasses: ["edit-mode"],
5104
5231
  showEditables: true,
5105
5232
  editStore: TEMPLATE_CONTEXT,
@@ -5113,7 +5240,8 @@ const PRESENT_STATES = [
5113
5240
  {
5114
5241
  title: "Saved custom slide",
5115
5242
  key: "custom-slide-saved",
5116
- 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",
5117
5245
  bodyClasses: ["edit-mode"],
5118
5246
  showEditables: true,
5119
5247
  editStore: TEMPLATE_CONTEXT,