@vaudience/aigentflow-flow-validator 0.21.0 → 0.22.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.
package/dist/index.js CHANGED
@@ -449,7 +449,7 @@ function validateBasicStructure(flow, issues) {
449
449
 
450
450
  // src/spec/aigentflow-spec.json
451
451
  var aigentflow_spec_default = {
452
- specVersion: "2.827.0",
452
+ specVersion: "2.828.0",
453
453
  inputSchemaVersion: 1,
454
454
  executorSchemes: [
455
455
  "a2a",
@@ -946,6 +946,33 @@ var aigentflow_spec_default = {
946
946
  stepFieldFormat: "steps.%s.query.%s",
947
947
  loopStepFieldFormat: "steps.%s.loop.steps.%s.query.%s"
948
948
  },
949
+ flowDataReservedKeys: {
950
+ code: "flow_data_key_reserved",
951
+ fieldFormat: "data.%s",
952
+ messageFormat: "data: key %s is reserved: %s. It would write into the engine's own state, so it is not seeded.",
953
+ suggestion: "Rename the key (no leading `_` or `.`, and not one of the engine namespaces memory., orchestrator., campaign., voiceagent.).",
954
+ exact: {
955
+ org_id: "the mission's organization, set by the engine for Thalamus/Engram calls",
956
+ memory: "the memory scope namespace",
957
+ orchestrator: "the orchestrator's state namespace",
958
+ campaign: "the campaign's state namespace",
959
+ voiceagent: "the voice agent's state namespace",
960
+ current_flow: "engine bookkeeping (the current flow definition)",
961
+ modified_flow: "engine bookkeeping (dynamic flow modification)",
962
+ modification_history: "engine bookkeeping (dynamic flow modification)",
963
+ modification_pending: "engine bookkeeping (dynamic flow modification)",
964
+ modification_requests: "engine bookkeeping (dynamic flow modification)",
965
+ bottleneck_state: "engine bookkeeping (bottleneck analysis)"
966
+ },
967
+ prefixes: [
968
+ { prefix: "_", reason: "keys starting with `_` are engine bookkeeping (current flow, loop and for_each context, taint lists such as `__untrusted_*`)" },
969
+ { prefix: ".", reason: "keys starting with `.` are engine step-response slots" },
970
+ { prefix: "memory.", reason: "the `memory.` namespace belongs to the engine" },
971
+ { prefix: "orchestrator.", reason: "the `orchestrator.` namespace belongs to the orchestrator" },
972
+ { prefix: "campaign.", reason: "the `campaign.` namespace belongs to the campaign engine" },
973
+ { prefix: "voiceagent.", reason: "the `voiceagent.` namespace belongs to the voice agent" }
974
+ ]
975
+ },
949
976
  credentialEndpointPairing: {
950
977
  stepFieldFormat: "steps.%s.query.%s",
951
978
  loopStepFieldFormat: "steps.%s.loop.steps.%s.query.%s",
@@ -1883,6 +1910,14 @@ var SERVER_OWNED_QUERY_KEYS = {
1883
1910
  stepFieldFormat: aigentflow_spec_default.serverOwnedQueryKeys.stepFieldFormat,
1884
1911
  loopStepFieldFormat: aigentflow_spec_default.serverOwnedQueryKeys.loopStepFieldFormat
1885
1912
  };
1913
+ var FLOW_DATA_RESERVED_KEYS = {
1914
+ code: aigentflow_spec_default.flowDataReservedKeys.code,
1915
+ fieldFormat: aigentflow_spec_default.flowDataReservedKeys.fieldFormat,
1916
+ messageFormat: aigentflow_spec_default.flowDataReservedKeys.messageFormat,
1917
+ suggestion: aigentflow_spec_default.flowDataReservedKeys.suggestion,
1918
+ exact: aigentflow_spec_default.flowDataReservedKeys.exact,
1919
+ prefixes: aigentflow_spec_default.flowDataReservedKeys.prefixes
1920
+ };
1886
1921
  var CREDENTIAL_ENDPOINT_PAIRING = {
1887
1922
  stepFieldFormat: aigentflow_spec_default.credentialEndpointPairing.stepFieldFormat,
1888
1923
  loopStepFieldFormat: aigentflow_spec_default.credentialEndpointPairing.loopStepFieldFormat,
@@ -3802,16 +3837,16 @@ function skipSpaces(src, idx) {
3802
3837
  }
3803
3838
  return i;
3804
3839
  }
3805
- function scanString(src, start, quote) {
3840
+ function scanString(src, start, quote2) {
3806
3841
  let i = start + 1;
3807
- const raw = quote === "`";
3842
+ const raw = quote2 === "`";
3808
3843
  while (i < src.length) {
3809
3844
  const c = src[i];
3810
3845
  if (!raw && c === "\\") {
3811
3846
  i += 2;
3812
3847
  continue;
3813
3848
  }
3814
- if (c === quote) return i;
3849
+ if (c === quote2) return i;
3815
3850
  i += 1;
3816
3851
  }
3817
3852
  return -1;
@@ -4414,6 +4449,35 @@ function validateRetiredKeys(flow, issues) {
4414
4449
  }
4415
4450
  }
4416
4451
 
4452
+ // src/validators/flowDataKeys.ts
4453
+ var KEY_DATA = "data";
4454
+ function quote(key) {
4455
+ return JSON.stringify(key);
4456
+ }
4457
+ function flowDataKeyReservation(key) {
4458
+ if (Object.prototype.hasOwnProperty.call(FLOW_DATA_RESERVED_KEYS.exact, key)) {
4459
+ return FLOW_DATA_RESERVED_KEYS.exact[key];
4460
+ }
4461
+ for (const p of FLOW_DATA_RESERVED_KEYS.prefixes) {
4462
+ if (key.startsWith(p.prefix)) return p.reason;
4463
+ }
4464
+ return void 0;
4465
+ }
4466
+ function validateFlowDataKeys(flow, issues) {
4467
+ const data = flow[KEY_DATA];
4468
+ if (!isRecord(data)) return;
4469
+ for (const key of Object.keys(data).sort()) {
4470
+ const reason = flowDataKeyReservation(key);
4471
+ if (reason === void 0) continue;
4472
+ issues.error({
4473
+ field: FLOW_DATA_RESERVED_KEYS.fieldFormat.replace("%s", () => key),
4474
+ message: FLOW_DATA_RESERVED_KEYS.messageFormat.replace("%s", () => quote(key)).replace("%s", () => reason),
4475
+ code: FLOW_DATA_RESERVED_KEYS.code,
4476
+ suggestion: FLOW_DATA_RESERVED_KEYS.suggestion
4477
+ });
4478
+ }
4479
+ }
4480
+
4417
4481
  // src/validators/saveDoor.ts
4418
4482
  var TOOL_DISCOVERY_MODES = /* @__PURE__ */ new Set(["eager", "lazy", "off"]);
4419
4483
  var TEMPLATE_ACTION_OPEN2 = "{{";
@@ -6876,6 +6940,7 @@ function validateParsed(flow, opts, sources) {
6876
6940
  validateSaveDoorExtras(f, issues);
6877
6941
  validateExecutorConfigEnvScopes(f, issues);
6878
6942
  validateServerOwnedQueryKeys(f, issues);
6943
+ validateFlowDataKeys(f, issues);
6879
6944
  validateCredentialEndpointPairing(f, issues);
6880
6945
  validateExamples(f, issues);
6881
6946
  validateOrchestratorExons(f, issues);