@ai-matrx/agents 0.31.0 → 0.33.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/content-transfer/index.cjs.map +1 -1
  3. package/dist/content-transfer/index.js.map +1 -1
  4. package/dist/content-transfer/react/index.cjs.map +1 -1
  5. package/dist/content-transfer/react/index.js.map +1 -1
  6. package/dist/context/index.cjs.map +1 -1
  7. package/dist/context/index.d.cts +13 -2
  8. package/dist/context/index.d.ts +13 -2
  9. package/dist/context/index.js.map +1 -1
  10. package/dist/context/react/index.cjs +23 -10
  11. package/dist/context/react/index.cjs.map +1 -1
  12. package/dist/context/react/index.d.cts +14 -3
  13. package/dist/context/react/index.d.ts +14 -3
  14. package/dist/context/react/index.js +23 -10
  15. package/dist/context/react/index.js.map +1 -1
  16. package/dist/envelope/index.cjs +208 -0
  17. package/dist/envelope/index.cjs.map +1 -0
  18. package/dist/envelope/index.d.cts +314 -0
  19. package/dist/envelope/index.d.ts +314 -0
  20. package/dist/envelope/index.js +192 -0
  21. package/dist/envelope/index.js.map +1 -0
  22. package/dist/field-flags/index.cjs +63 -0
  23. package/dist/field-flags/index.cjs.map +1 -0
  24. package/dist/field-flags/index.d.cts +40 -0
  25. package/dist/field-flags/index.d.ts +40 -0
  26. package/dist/field-flags/index.js +42 -0
  27. package/dist/field-flags/index.js.map +1 -0
  28. package/dist/mandates/index.cjs +57 -2
  29. package/dist/mandates/index.cjs.map +1 -1
  30. package/dist/mandates/index.d.cts +85 -5
  31. package/dist/mandates/index.d.ts +85 -5
  32. package/dist/mandates/index.js +57 -2
  33. package/dist/mandates/index.js.map +1 -1
  34. package/dist/models/index.cjs +267 -0
  35. package/dist/models/index.cjs.map +1 -0
  36. package/dist/models/index.d.cts +118 -0
  37. package/dist/models/index.d.ts +118 -0
  38. package/dist/models/index.js +244 -0
  39. package/dist/models/index.js.map +1 -0
  40. package/mandates/snapshots/keys.0.32.0.json +653 -0
  41. package/mandates/snapshots/keys.0.33.0.json +653 -0
  42. package/package.json +35 -4
@@ -6,9 +6,9 @@
6
6
  * from the IN-PROCESS mandate declarations — the same `declared_mandates()` the
7
7
  * boot sync writes to the database from. There is no hand list anywhere.
8
8
  *
9
- * aidream revision: ca7b341ea8078cb2cde45613f39ad6d7e78dbc05
9
+ * aidream revision: 74afbd5d601164b5b5188572fd3d242dbed25996
10
10
  * generator version: 1.0.0
11
- * package version: 0.31.0
11
+ * package version: 0.33.0
12
12
  * active keys: 544
13
13
  * retiring keys: 0
14
14
  *
@@ -19,9 +19,9 @@
19
19
  */
20
20
  /** Where this module came from — surfaced so a report can name the exact build. */
21
21
  declare const MANDATE_KEYS_META: {
22
- readonly aidreamRevision: "ca7b341ea8078cb2cde45613f39ad6d7e78dbc05";
22
+ readonly aidreamRevision: "74afbd5d601164b5b5188572fd3d242dbed25996";
23
23
  readonly generatorVersion: "1.0.0";
24
- readonly packageVersion: "0.31.0";
24
+ readonly packageVersion: "0.33.0";
25
25
  readonly retireWindow: 3;
26
26
  };
27
27
  /** Every declared mandate key, by THE IDENTIFIER RULE. */
@@ -629,6 +629,63 @@ declare function mandateKeyOfApp(appSlug: string, surfaceSlug?: string): Dynamic
629
629
  */
630
630
  declare function mandateKeyOfShortcut(shortcutSlug: string, surfaceSlug?: string): DynamicMandateKey;
631
631
 
632
+ /**
633
+ * The Mandate CONTRACT, client-side — one leaf module so both the resolution
634
+ * path (`service.ts`) and the binding-editor path (`overrides.ts`) read the
635
+ * same shape without importing each other.
636
+ *
637
+ * 🚨 THE DOCUMENT-VARIABLE LAW (disease D4, Arman 2026-08-19). A Mandate's
638
+ * `required_variables` are not decoration and not only a BIND-time check
639
+ * against what the agent declares. They are also a RUN-time precondition on
640
+ * what the CALLER supplies:
641
+ *
642
+ * "this agent should never have even started without getting the rules in
643
+ * place."
644
+ *
645
+ * `missingRequiredVariables` is the one implementation of that check. A run
646
+ * whose required variable is absent or blank REFUSES — there is no seed
647
+ * fallback and no "the model can fetch it with a tool" consolation, because a
648
+ * document that arrives by tool call is a document that gets skimmed.
649
+ *
650
+ * Law: `common-docs/systems/agent-variable-binding/FEATURE.md` § THE
651
+ * USER-INPUT LAW · register: `common-docs/operations/agent-failure-diseases.md` § D4.
652
+ */
653
+
654
+ interface MandateContract {
655
+ requiredVariables: string[];
656
+ requiredContextPolicyKeys: string[];
657
+ requiredOutputKeys: string[];
658
+ /**
659
+ * Variables the contract deliberately delivers as user text instead of a
660
+ * declared variable (Scenario 4). A spilled variable still ARRIVES, so it is
661
+ * never counted as missing — but structured content may never take this
662
+ * path.
663
+ */
664
+ spillVariables: string[];
665
+ /**
666
+ * The Mandate's context kill switch (`contract.auto_context_disabled`): only
667
+ * the Holder's declared Context Policies reach it, unless the person turned a
668
+ * value on themselves (common-docs context-delivery RULES.md §2). The
669
+ * composer's context table needs it to show the truth before the first turn.
670
+ */
671
+ autoContextDisabled: boolean;
672
+ }
673
+ declare const EMPTY_MANDATE_CONTRACT: MandateContract;
674
+ declare function parseMandateContract(contract: unknown): MandateContract;
675
+ /**
676
+ * Which of the Mandate's required variables the caller did NOT actually
677
+ * supply. Blank counts as missing: a required document that resolved to an
678
+ * empty string is the wiring failure this check exists to catch, and a
679
+ * deliberately empty document must still say so in words (see
680
+ * `features/masterwork/agent-context/rulebookDocument.ts`).
681
+ *
682
+ * Spilled variables are excluded — they arrive as user text, so they are
683
+ * delivered, just not as a named variable.
684
+ */
685
+ declare function missingRequiredVariables(contract: MandateContract, supplied: Record<string, unknown> | null | undefined): string[];
686
+ /** The one refusal message, so every surface says the same thing. */
687
+ declare function missingVariablesMessage(mandateKey: AnyMandateKey, missing: string[]): string;
688
+
632
689
  /**
633
690
  * `@ai-matrx/agents/mandates` — the ONE place a TypeScript client learns a
634
691
  * mandate key.
@@ -693,5 +750,28 @@ declare function isMandateKey(value: unknown): value is MandateKey;
693
750
  * key set came from, and what to do — never a bare "invalid key".
694
751
  */
695
752
  declare function assertMandateKey(value: unknown, context?: string): asserts value is MandateKey;
753
+ /**
754
+ * A DB-AUTHORED KEY THE GENERATED UNION CANNOT CARRY — the ONE typed door for
755
+ * a literal a client's mandate-key allowlist already governs.
756
+ *
757
+ * Two honest cases: an `origin='user'` mandate somebody created in the console
758
+ * (no generator built from code declarations can ever contain it), and a key
759
+ * aidream has declared but the installed `@ai-matrx/agents` predates. Because
760
+ * the parameter is a literal type, the key still appears verbatim at the call
761
+ * site for a hand-typed-key scanner and for a human reading the diff.
762
+ *
763
+ * 🚨 NOT an escape hatch for a declared key. A key in `MANDATE_KEYS` goes
764
+ * through `MANDATE_KEYS.<id>`; using this for one hides a real rename from the
765
+ * compiler. When the package publishes a key routed through here, delete the call.
766
+ */
767
+ declare function dbAuthoredMandateKey<K extends string>(key: K): DynamicMandateKey;
768
+ interface MandateKeyParts {
769
+ /** The feature/domain namespace before the first dot. */
770
+ feature: string;
771
+ /** The complete step name after the first dot; later dots are preserved. */
772
+ mandate: string;
773
+ }
774
+ /** Split canonical `<feature>.<mandate>` identity without losing information. */
775
+ declare function splitMandateKey(mandateKey: string): MandateKeyParts;
696
776
 
697
- export { ALL_MANDATE_KEYS, type AnyMandateKey, DYNAMIC_MANDATE_FAMILIES, type DynamicMandateFamilyPrefix, type DynamicMandateKey, MANDATE_FAMILIES, MANDATE_KEYS, MANDATE_KEYS_META, type MandateFamilyMember, type MandateFamilyPrefix, type MandateKey, RETIRING_MANDATE_KEYS, assertMandateKey, isMandateKey, mandateKeyOfApp, mandateKeyOfShortcut, storedMandateKey };
777
+ export { ALL_MANDATE_KEYS, type AnyMandateKey, DYNAMIC_MANDATE_FAMILIES, type DynamicMandateFamilyPrefix, type DynamicMandateKey, EMPTY_MANDATE_CONTRACT, MANDATE_FAMILIES, MANDATE_KEYS, MANDATE_KEYS_META, type MandateContract, type MandateFamilyMember, type MandateFamilyPrefix, type MandateKey, type MandateKeyParts, RETIRING_MANDATE_KEYS, assertMandateKey, dbAuthoredMandateKey, isMandateKey, mandateKeyOfApp, mandateKeyOfShortcut, missingRequiredVariables, missingVariablesMessage, parseMandateContract, splitMandateKey, storedMandateKey };
@@ -6,9 +6,9 @@
6
6
  * from the IN-PROCESS mandate declarations — the same `declared_mandates()` the
7
7
  * boot sync writes to the database from. There is no hand list anywhere.
8
8
  *
9
- * aidream revision: ca7b341ea8078cb2cde45613f39ad6d7e78dbc05
9
+ * aidream revision: 74afbd5d601164b5b5188572fd3d242dbed25996
10
10
  * generator version: 1.0.0
11
- * package version: 0.31.0
11
+ * package version: 0.33.0
12
12
  * active keys: 544
13
13
  * retiring keys: 0
14
14
  *
@@ -19,9 +19,9 @@
19
19
  */
20
20
  /** Where this module came from — surfaced so a report can name the exact build. */
21
21
  declare const MANDATE_KEYS_META: {
22
- readonly aidreamRevision: "ca7b341ea8078cb2cde45613f39ad6d7e78dbc05";
22
+ readonly aidreamRevision: "74afbd5d601164b5b5188572fd3d242dbed25996";
23
23
  readonly generatorVersion: "1.0.0";
24
- readonly packageVersion: "0.31.0";
24
+ readonly packageVersion: "0.33.0";
25
25
  readonly retireWindow: 3;
26
26
  };
27
27
  /** Every declared mandate key, by THE IDENTIFIER RULE. */
@@ -629,6 +629,63 @@ declare function mandateKeyOfApp(appSlug: string, surfaceSlug?: string): Dynamic
629
629
  */
630
630
  declare function mandateKeyOfShortcut(shortcutSlug: string, surfaceSlug?: string): DynamicMandateKey;
631
631
 
632
+ /**
633
+ * The Mandate CONTRACT, client-side — one leaf module so both the resolution
634
+ * path (`service.ts`) and the binding-editor path (`overrides.ts`) read the
635
+ * same shape without importing each other.
636
+ *
637
+ * 🚨 THE DOCUMENT-VARIABLE LAW (disease D4, Arman 2026-08-19). A Mandate's
638
+ * `required_variables` are not decoration and not only a BIND-time check
639
+ * against what the agent declares. They are also a RUN-time precondition on
640
+ * what the CALLER supplies:
641
+ *
642
+ * "this agent should never have even started without getting the rules in
643
+ * place."
644
+ *
645
+ * `missingRequiredVariables` is the one implementation of that check. A run
646
+ * whose required variable is absent or blank REFUSES — there is no seed
647
+ * fallback and no "the model can fetch it with a tool" consolation, because a
648
+ * document that arrives by tool call is a document that gets skimmed.
649
+ *
650
+ * Law: `common-docs/systems/agent-variable-binding/FEATURE.md` § THE
651
+ * USER-INPUT LAW · register: `common-docs/operations/agent-failure-diseases.md` § D4.
652
+ */
653
+
654
+ interface MandateContract {
655
+ requiredVariables: string[];
656
+ requiredContextPolicyKeys: string[];
657
+ requiredOutputKeys: string[];
658
+ /**
659
+ * Variables the contract deliberately delivers as user text instead of a
660
+ * declared variable (Scenario 4). A spilled variable still ARRIVES, so it is
661
+ * never counted as missing — but structured content may never take this
662
+ * path.
663
+ */
664
+ spillVariables: string[];
665
+ /**
666
+ * The Mandate's context kill switch (`contract.auto_context_disabled`): only
667
+ * the Holder's declared Context Policies reach it, unless the person turned a
668
+ * value on themselves (common-docs context-delivery RULES.md §2). The
669
+ * composer's context table needs it to show the truth before the first turn.
670
+ */
671
+ autoContextDisabled: boolean;
672
+ }
673
+ declare const EMPTY_MANDATE_CONTRACT: MandateContract;
674
+ declare function parseMandateContract(contract: unknown): MandateContract;
675
+ /**
676
+ * Which of the Mandate's required variables the caller did NOT actually
677
+ * supply. Blank counts as missing: a required document that resolved to an
678
+ * empty string is the wiring failure this check exists to catch, and a
679
+ * deliberately empty document must still say so in words (see
680
+ * `features/masterwork/agent-context/rulebookDocument.ts`).
681
+ *
682
+ * Spilled variables are excluded — they arrive as user text, so they are
683
+ * delivered, just not as a named variable.
684
+ */
685
+ declare function missingRequiredVariables(contract: MandateContract, supplied: Record<string, unknown> | null | undefined): string[];
686
+ /** The one refusal message, so every surface says the same thing. */
687
+ declare function missingVariablesMessage(mandateKey: AnyMandateKey, missing: string[]): string;
688
+
632
689
  /**
633
690
  * `@ai-matrx/agents/mandates` — the ONE place a TypeScript client learns a
634
691
  * mandate key.
@@ -693,5 +750,28 @@ declare function isMandateKey(value: unknown): value is MandateKey;
693
750
  * key set came from, and what to do — never a bare "invalid key".
694
751
  */
695
752
  declare function assertMandateKey(value: unknown, context?: string): asserts value is MandateKey;
753
+ /**
754
+ * A DB-AUTHORED KEY THE GENERATED UNION CANNOT CARRY — the ONE typed door for
755
+ * a literal a client's mandate-key allowlist already governs.
756
+ *
757
+ * Two honest cases: an `origin='user'` mandate somebody created in the console
758
+ * (no generator built from code declarations can ever contain it), and a key
759
+ * aidream has declared but the installed `@ai-matrx/agents` predates. Because
760
+ * the parameter is a literal type, the key still appears verbatim at the call
761
+ * site for a hand-typed-key scanner and for a human reading the diff.
762
+ *
763
+ * 🚨 NOT an escape hatch for a declared key. A key in `MANDATE_KEYS` goes
764
+ * through `MANDATE_KEYS.<id>`; using this for one hides a real rename from the
765
+ * compiler. When the package publishes a key routed through here, delete the call.
766
+ */
767
+ declare function dbAuthoredMandateKey<K extends string>(key: K): DynamicMandateKey;
768
+ interface MandateKeyParts {
769
+ /** The feature/domain namespace before the first dot. */
770
+ feature: string;
771
+ /** The complete step name after the first dot; later dots are preserved. */
772
+ mandate: string;
773
+ }
774
+ /** Split canonical `<feature>.<mandate>` identity without losing information. */
775
+ declare function splitMandateKey(mandateKey: string): MandateKeyParts;
696
776
 
697
- export { ALL_MANDATE_KEYS, type AnyMandateKey, DYNAMIC_MANDATE_FAMILIES, type DynamicMandateFamilyPrefix, type DynamicMandateKey, MANDATE_FAMILIES, MANDATE_KEYS, MANDATE_KEYS_META, type MandateFamilyMember, type MandateFamilyPrefix, type MandateKey, RETIRING_MANDATE_KEYS, assertMandateKey, isMandateKey, mandateKeyOfApp, mandateKeyOfShortcut, storedMandateKey };
777
+ export { ALL_MANDATE_KEYS, type AnyMandateKey, DYNAMIC_MANDATE_FAMILIES, type DynamicMandateFamilyPrefix, type DynamicMandateKey, EMPTY_MANDATE_CONTRACT, MANDATE_FAMILIES, MANDATE_KEYS, MANDATE_KEYS_META, type MandateContract, type MandateFamilyMember, type MandateFamilyPrefix, type MandateKey, type MandateKeyParts, RETIRING_MANDATE_KEYS, assertMandateKey, dbAuthoredMandateKey, isMandateKey, mandateKeyOfApp, mandateKeyOfShortcut, missingRequiredVariables, missingVariablesMessage, parseMandateContract, splitMandateKey, storedMandateKey };
@@ -1,8 +1,8 @@
1
1
  // mandates/keys.generated.ts
2
2
  var MANDATE_KEYS_META = {
3
- aidreamRevision: "ca7b341ea8078cb2cde45613f39ad6d7e78dbc05",
3
+ aidreamRevision: "74afbd5d601164b5b5188572fd3d242dbed25996",
4
4
  generatorVersion: "1.0.0",
5
- packageVersion: "0.31.0",
5
+ packageVersion: "0.33.0",
6
6
  retireWindow: 3
7
7
  };
8
8
  var MANDATE_KEYS = {
@@ -677,6 +677,42 @@ function mandateKeyOfShortcut(shortcutSlug, surfaceSlug) {
677
677
  return dynamicKey("shortcut", shortcutSlug, surfaceSlug);
678
678
  }
679
679
 
680
+ // mandates/contract.ts
681
+ import { isJsonObject } from "@ai-matrx/kit/json-format";
682
+ var EMPTY_MANDATE_CONTRACT = {
683
+ requiredVariables: [],
684
+ requiredContextPolicyKeys: [],
685
+ requiredOutputKeys: [],
686
+ spillVariables: [],
687
+ autoContextDisabled: false
688
+ };
689
+ function stringList(value) {
690
+ return Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
691
+ }
692
+ function parseMandateContract(contract) {
693
+ if (!isJsonObject(contract)) return { ...EMPTY_MANDATE_CONTRACT };
694
+ return {
695
+ requiredVariables: stringList(contract.required_variables),
696
+ requiredContextPolicyKeys: stringList(contract.required_context_policies),
697
+ requiredOutputKeys: stringList(contract.required_output_keys),
698
+ spillVariables: stringList(contract.spill_variables),
699
+ autoContextDisabled: contract.auto_context_disabled === true
700
+ };
701
+ }
702
+ function missingRequiredVariables(contract, supplied) {
703
+ const spilled = new Set(contract.spillVariables);
704
+ return contract.requiredVariables.filter((name) => {
705
+ if (spilled.has(name)) return false;
706
+ const value = supplied?.[name];
707
+ if (value === void 0 || value === null) return true;
708
+ if (typeof value === "string") return value.trim().length === 0;
709
+ return false;
710
+ });
711
+ }
712
+ function missingVariablesMessage(mandateKey, missing) {
713
+ return `The "${mandateKey}" step cannot start: it requires ${missing.map((n) => `\`${n}\``).join(", ")}, and ${missing.length === 1 ? "it was" : "they were"} not supplied. Refusing rather than starting the agent without ${missing.length === 1 ? "it" : "them"}.`;
714
+ }
715
+
680
716
  // mandates/index.ts
681
717
  function storedMandateKey(value) {
682
718
  return value;
@@ -692,17 +728,36 @@ function assertMandateKey(value, context) {
692
728
  `${JSON.stringify(value)} is not a declared mandate key${where}. @ai-matrx/agents@${MANDATE_KEYS_META.packageVersion} ships ${ALL_MANDATE_KEYS.length} keys (aidream ${MANDATE_KEYS_META.aidreamRevision.slice(0, 12)}). If the key is real, this package is behind \u2014 take \`latest\` and re-check. If it is a user-built app or shortcut, it is DB-authored: build it with mandateKeyOfApp() / mandateKeyOfShortcut(), which return DynamicMandateKey.`
693
729
  );
694
730
  }
731
+ function dbAuthoredMandateKey(key) {
732
+ return key;
733
+ }
734
+ function splitMandateKey(mandateKey) {
735
+ const separator = mandateKey.indexOf(".");
736
+ if (separator <= 0 || separator === mandateKey.length - 1) {
737
+ return { feature: "(unscoped)", mandate: mandateKey };
738
+ }
739
+ return {
740
+ feature: mandateKey.slice(0, separator),
741
+ mandate: mandateKey.slice(separator + 1)
742
+ };
743
+ }
695
744
  export {
696
745
  ALL_MANDATE_KEYS,
697
746
  DYNAMIC_MANDATE_FAMILIES,
747
+ EMPTY_MANDATE_CONTRACT,
698
748
  MANDATE_FAMILIES,
699
749
  MANDATE_KEYS,
700
750
  MANDATE_KEYS_META,
701
751
  RETIRING_MANDATE_KEYS,
702
752
  assertMandateKey,
753
+ dbAuthoredMandateKey,
703
754
  isMandateKey,
704
755
  mandateKeyOfApp,
705
756
  mandateKeyOfShortcut,
757
+ missingRequiredVariables,
758
+ missingVariablesMessage,
759
+ parseMandateContract,
760
+ splitMandateKey,
706
761
  storedMandateKey
707
762
  };
708
763
  //# sourceMappingURL=index.js.map