@clipform/mcp-server 5.3.0 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@ import {
6
6
  recoveryHint,
7
7
  structuredResult,
8
8
  textResult
9
- } from "./chunk-5D3UEINC.js";
9
+ } from "./chunk-42DEGWIU.js";
10
10
  import "./chunk-ENVV65JX.js";
11
11
  import "./chunk-PBQ5BQWD.js";
12
12
  import "./chunk-PZ5AY32C.js";
@@ -103,6 +103,16 @@ var FEATURES = {
103
103
  status: "beta",
104
104
  category: "builder"
105
105
  },
106
+ variables: {
107
+ name: "Custom variables",
108
+ description: "Save answers to named number or text variables and use them in logic and results",
109
+ // Dogfood-only (#5242): invisible beta - enabled:false, never 'live'/'planned' so
110
+ // no public surface lists it. Available to FEATURE_COMPANY_ALLOWLIST.variables
111
+ // via companyHasVariables; the global flip (+ wentLiveAt) is the launch step.
112
+ enabled: false,
113
+ status: "beta",
114
+ category: "builder"
115
+ },
106
116
  response_trash: {
107
117
  name: "Response trash",
108
118
  description: "Move responses to the trash and restore them from the Responses tab",
@@ -2898,6 +2908,32 @@ function isAnonMcpLockedNode(node) {
2898
2908
  );
2899
2909
  }
2900
2910
 
2911
+ // ../config/variables.js
2912
+ var VARIABLE_KEY_MAX_LENGTH = 40;
2913
+ var VARIABLE_KEY_PATTERN = new RegExp(`^[a-z][a-z0-9_]{0,${VARIABLE_KEY_MAX_LENGTH - 1}}$`);
2914
+
2915
+ // ../config/recall.js
2916
+ var RECALL_FALLBACK_MAX_LENGTH = 60;
2917
+ var RECALL_FIELD_ID_MAX_LENGTH = 64;
2918
+ var UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
2919
+ var KEY = `[a-z][a-z0-9_]{0,${VARIABLE_KEY_MAX_LENGTH - 1}}`;
2920
+ var FIELD_ID = `[^.{}|\\s]{1,${RECALL_FIELD_ID_MAX_LENGTH}}`;
2921
+ var ANSWER = `answer:(${UUID})(?:\\.(${FIELD_ID}))?`;
2922
+ var REF = `answer:${UUID}(?:\\.${FIELD_ID})?|${KEY}`;
2923
+ var RECALL_TOKEN_SOURCE = `\\{\\{(${REF})(?:\\|([^{}|\\r\\n]{1,${RECALL_FALLBACK_MAX_LENGTH}}))?\\}\\}`;
2924
+ var RECALL_TOKEN_PATTERN = new RegExp(RECALL_TOKEN_SOURCE, "g");
2925
+ var ANSWER_REF = new RegExp(`^${ANSWER}$`);
2926
+ var KEY_REF = new RegExp(`^${KEY}$`);
2927
+ var WHOLE_TOKEN = new RegExp(`^${RECALL_TOKEN_SOURCE}$`);
2928
+ function parseRecallRef(ref) {
2929
+ if (typeof ref !== "string") return null;
2930
+ const a = ANSWER_REF.exec(ref);
2931
+ if (a) return { kind: "answer", ref, nodeId: a[1], fieldId: a[2] ?? null };
2932
+ if (KEY_REF.test(ref)) return { kind: "variable", ref, key: ref };
2933
+ return null;
2934
+ }
2935
+ var RECALL_RESERVED_LABELS = { score: "Quiz score", max_score: "Quiz max score" };
2936
+
2901
2937
  // ../config/validate.js
2902
2938
  function lettersCapError(nodeType, config, count) {
2903
2939
  const typeDef = NODE_TYPES[nodeType];
@@ -3689,6 +3725,49 @@ var MCP_TOOL_SECURITY = Object.freeze(
3689
3725
  );
3690
3726
  var MAX_CLIP_SECONDS = 30;
3691
3727
  var MAX_NARRATION_CHARS = 400;
3728
+ function recallAnswerLabel(node, fieldId) {
3729
+ const label = typeof node?.label === "string" ? node.label.trim() : "";
3730
+ const type = node?.type ?? "";
3731
+ const base = label || NODE_TYPES[type]?.label || type;
3732
+ if (!fieldId) return base;
3733
+ const fields = Array.isArray(node?.config?.fields) ? node.config.fields : [];
3734
+ const f = fields.find((x) => x?.id === fieldId);
3735
+ return `${base} - ${contactFieldLabel({ id: fieldId, is_custom: f?.is_custom, label: f?.label })}`;
3736
+ }
3737
+ function variableDisplayName(key, variables) {
3738
+ const list = Array.isArray(variables) ? variables : [];
3739
+ const v = list.find((x) => x?.key === key);
3740
+ const label = typeof v?.label === "string" ? v.label.trim() : "";
3741
+ if (label) return label;
3742
+ if (Object.hasOwn(RECALL_RESERVED_LABELS, key)) return RECALL_RESERVED_LABELS[key];
3743
+ return key;
3744
+ }
3745
+ function recallDisplayText(text, ctx) {
3746
+ if (typeof text !== "string" || !text.includes("{{")) return text;
3747
+ const variables = ctx?.variables;
3748
+ const nodes = Array.isArray(ctx?.nodes) ? ctx.nodes : [];
3749
+ const render = (input, nested) => input.replace(new RegExp(RECALL_TOKEN_SOURCE, "g"), (_whole, ref, fallback) => {
3750
+ const parsed = parseRecallRef(ref);
3751
+ let name;
3752
+ if (parsed?.kind === "answer") {
3753
+ if (nested) {
3754
+ name = "Earlier answer";
3755
+ } else {
3756
+ const node = nodes.find((n) => n?.id === parsed.nodeId);
3757
+ if (!node) {
3758
+ name = "Deleted question";
3759
+ } else {
3760
+ name = recallAnswerLabel(node, parsed.fieldId);
3761
+ if (name.includes("{{")) name = render(name, true);
3762
+ }
3763
+ }
3764
+ } else {
3765
+ name = variableDisplayName(parsed?.key ?? ref, variables);
3766
+ }
3767
+ return fallback !== void 0 ? `[${name} \xB7 ${fallback}]` : `[${name}]`;
3768
+ });
3769
+ return render(text, false);
3770
+ }
3692
3771
 
3693
3772
  // src/lib/api-client.ts
3694
3773
  function getApiBaseUrl() {
@@ -3897,6 +3976,7 @@ export {
3897
3976
  MCP_TOOL_SECURITY,
3898
3977
  MAX_CLIP_SECONDS,
3899
3978
  MAX_NARRATION_CHARS,
3979
+ recallDisplayText,
3900
3980
  callApi,
3901
3981
  recoveryHint,
3902
3982
  errorResult,
@@ -3905,4 +3985,4 @@ export {
3905
3985
  textResult,
3906
3986
  structuredResult
3907
3987
  };
3908
- //# sourceMappingURL=chunk-5D3UEINC.js.map
3988
+ //# sourceMappingURL=chunk-42DEGWIU.js.map