@framers/agentos 0.12.12 → 0.12.14

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 (86) hide show
  1. package/README.md +1 -1
  2. package/dist/api/agency.d.ts.map +1 -1
  3. package/dist/api/agency.js +26 -5
  4. package/dist/api/agency.js.map +1 -1
  5. package/dist/api/agent.d.ts +35 -1
  6. package/dist/api/agent.d.ts.map +1 -1
  7. package/dist/api/agent.js +8 -0
  8. package/dist/api/agent.js.map +1 -1
  9. package/dist/api/gmi.d.ts +21 -0
  10. package/dist/api/gmi.d.ts.map +1 -0
  11. package/dist/api/gmi.js +527 -0
  12. package/dist/api/gmi.js.map +1 -0
  13. package/dist/api/hitl.d.ts +3 -2
  14. package/dist/api/hitl.d.ts.map +1 -1
  15. package/dist/api/hitl.js +8 -2
  16. package/dist/api/hitl.js.map +1 -1
  17. package/dist/api/runtime/agentCognitiveMemory.d.ts +82 -0
  18. package/dist/api/runtime/agentCognitiveMemory.d.ts.map +1 -0
  19. package/dist/api/runtime/agentCognitiveMemory.js +277 -0
  20. package/dist/api/runtime/agentCognitiveMemory.js.map +1 -0
  21. package/dist/api/runtime/approval-gate.d.ts +13 -8
  22. package/dist/api/runtime/approval-gate.d.ts.map +1 -1
  23. package/dist/api/runtime/approval-gate.js +75 -25
  24. package/dist/api/runtime/approval-gate.js.map +1 -1
  25. package/dist/api/runtime/capabilityContract.d.ts +21 -1
  26. package/dist/api/runtime/capabilityContract.d.ts.map +1 -1
  27. package/dist/api/runtime/capabilityContract.js +15 -15
  28. package/dist/api/runtime/capabilityContract.js.map +1 -1
  29. package/dist/api/runtime/gmiCognition.d.ts +66 -0
  30. package/dist/api/runtime/gmiCognition.d.ts.map +1 -0
  31. package/dist/api/runtime/gmiCognition.js +58 -0
  32. package/dist/api/runtime/gmiCognition.js.map +1 -0
  33. package/dist/api/runtime/gmiPersona.d.ts +16 -0
  34. package/dist/api/runtime/gmiPersona.d.ts.map +1 -0
  35. package/dist/api/runtime/gmiPersona.js +91 -0
  36. package/dist/api/runtime/gmiPersona.js.map +1 -0
  37. package/dist/api/runtime/gmiResults.d.ts +98 -0
  38. package/dist/api/runtime/gmiResults.d.ts.map +1 -0
  39. package/dist/api/runtime/gmiResults.js +333 -0
  40. package/dist/api/runtime/gmiResults.js.map +1 -0
  41. package/dist/api/runtime/gmiSession.d.ts +85 -0
  42. package/dist/api/runtime/gmiSession.d.ts.map +1 -0
  43. package/dist/api/runtime/gmiSession.js +285 -0
  44. package/dist/api/runtime/gmiSession.js.map +1 -0
  45. package/dist/api/runtime/gmiTranscript.d.ts +48 -0
  46. package/dist/api/runtime/gmiTranscript.d.ts.map +1 -0
  47. package/dist/api/runtime/gmiTranscript.js +110 -0
  48. package/dist/api/runtime/gmiTranscript.js.map +1 -0
  49. package/dist/api/runtime/lightweightAgentDiagnostics.d.ts +6 -1
  50. package/dist/api/runtime/lightweightAgentDiagnostics.d.ts.map +1 -1
  51. package/dist/api/runtime/lightweightAgentDiagnostics.js +9 -2
  52. package/dist/api/runtime/lightweightAgentDiagnostics.js.map +1 -1
  53. package/dist/api/runtime/tool-emulation/loop.d.ts +5 -0
  54. package/dist/api/runtime/tool-emulation/loop.d.ts.map +1 -1
  55. package/dist/api/runtime/tool-emulation/loop.js +4 -4
  56. package/dist/api/runtime/tool-emulation/loop.js.map +1 -1
  57. package/dist/api/sessionHistory.d.ts +43 -1
  58. package/dist/api/sessionHistory.d.ts.map +1 -1
  59. package/dist/api/sessionHistory.js +56 -1
  60. package/dist/api/sessionHistory.js.map +1 -1
  61. package/dist/api/sessionTranscript.d.ts +8 -0
  62. package/dist/api/sessionTranscript.d.ts.map +1 -1
  63. package/dist/api/sessionTranscript.js.map +1 -1
  64. package/dist/api/transferStyle.d.ts +8 -0
  65. package/dist/api/transferStyle.d.ts.map +1 -1
  66. package/dist/api/transferStyle.js +4 -1
  67. package/dist/api/transferStyle.js.map +1 -1
  68. package/dist/api/types.d.ts +32 -12
  69. package/dist/api/types.d.ts.map +1 -1
  70. package/dist/api/types.js.map +1 -1
  71. package/dist/cognition/substrate/GMI.d.ts.map +1 -1
  72. package/dist/cognition/substrate/GMI.js +54 -2
  73. package/dist/cognition/substrate/GMI.js.map +1 -1
  74. package/dist/cognition/substrate/IGMI.d.ts +23 -1
  75. package/dist/cognition/substrate/IGMI.d.ts.map +1 -1
  76. package/dist/cognition/substrate/IGMI.js.map +1 -1
  77. package/dist/io/vision/VisionPipeline.d.ts +5 -0
  78. package/dist/io/vision/VisionPipeline.d.ts.map +1 -1
  79. package/dist/io/vision/VisionPipeline.js +28 -13
  80. package/dist/io/vision/VisionPipeline.js.map +1 -1
  81. package/dist/io/vision/index.d.ts.map +1 -1
  82. package/dist/io/vision/index.js +2 -0
  83. package/dist/io/vision/index.js.map +1 -1
  84. package/dist/io/vision/types.d.ts +11 -0
  85. package/dist/io/vision/types.d.ts.map +1 -1
  86. package/package.json +1 -1
@@ -1,4 +1,9 @@
1
- export type CapabilitySurface = 'agent' | 'generation' | 'runtime';
1
+ /**
2
+ * Where a config field is read: `agent` (the lightweight `agent()` helper on its
3
+ * legacy runtime), `generation` (generateText and streamText), `runtime` (the full
4
+ * AgentOS runtime) and `gmi` (`agent({ runtime: 'gmi' })` and `gmi()`).
5
+ */
6
+ export type CapabilitySurface = 'agent' | 'generation' | 'runtime' | 'gmi';
2
7
  export type CapabilitySupport = 'enforced' | 'partially_enforced' | 'accepted_but_deferred' | 'runtime_only';
3
8
  export declare const CAPABILITY_KEYS: readonly ["tools", "memory", "rag", "discovery", "guardrails", "security", "permissions", "hitl", "emergent", "voice", "channels", "output", "provenance", "observability", "controls"];
4
9
  export type CapabilityKey = (typeof CAPABILITY_KEYS)[number];
@@ -7,76 +12,91 @@ export declare const BASE_AGENT_CONFIG_CAPABILITY_CONTRACT: {
7
12
  readonly agent: "enforced";
8
13
  readonly generation: "enforced";
9
14
  readonly runtime: "enforced";
15
+ readonly gmi: "enforced";
10
16
  };
11
17
  readonly memory: {
12
18
  readonly agent: "partially_enforced";
13
19
  readonly generation: "runtime_only";
14
20
  readonly runtime: "enforced";
21
+ readonly gmi: "enforced";
15
22
  };
16
23
  readonly rag: {
17
24
  readonly agent: "accepted_but_deferred";
18
25
  readonly generation: "runtime_only";
19
26
  readonly runtime: "enforced";
27
+ readonly gmi: "accepted_but_deferred";
20
28
  };
21
29
  readonly discovery: {
22
30
  readonly agent: "accepted_but_deferred";
23
31
  readonly generation: "runtime_only";
24
32
  readonly runtime: "enforced";
33
+ readonly gmi: "accepted_but_deferred";
25
34
  };
26
35
  readonly guardrails: {
27
36
  readonly agent: "accepted_but_deferred";
28
37
  readonly generation: "partially_enforced";
29
38
  readonly runtime: "enforced";
39
+ readonly gmi: "accepted_but_deferred";
30
40
  };
31
41
  readonly security: {
32
42
  readonly agent: "accepted_but_deferred";
33
43
  readonly generation: "runtime_only";
34
44
  readonly runtime: "enforced";
45
+ readonly gmi: "accepted_but_deferred";
35
46
  };
36
47
  readonly permissions: {
37
48
  readonly agent: "accepted_but_deferred";
38
49
  readonly generation: "partially_enforced";
39
50
  readonly runtime: "enforced";
51
+ readonly gmi: "accepted_but_deferred";
40
52
  };
41
53
  readonly hitl: {
42
54
  readonly agent: "accepted_but_deferred";
43
55
  readonly generation: "runtime_only";
44
56
  readonly runtime: "enforced";
57
+ readonly gmi: "accepted_but_deferred";
45
58
  };
46
59
  readonly emergent: {
47
60
  readonly agent: "accepted_but_deferred";
48
61
  readonly generation: "runtime_only";
49
62
  readonly runtime: "enforced";
63
+ readonly gmi: "accepted_but_deferred";
50
64
  };
51
65
  readonly voice: {
52
66
  readonly agent: "accepted_but_deferred";
53
67
  readonly generation: "runtime_only";
54
68
  readonly runtime: "enforced";
69
+ readonly gmi: "runtime_only";
55
70
  };
56
71
  readonly channels: {
57
72
  readonly agent: "accepted_but_deferred";
58
73
  readonly generation: "runtime_only";
59
74
  readonly runtime: "enforced";
75
+ readonly gmi: "runtime_only";
60
76
  };
61
77
  readonly output: {
62
78
  readonly agent: "accepted_but_deferred";
63
79
  readonly generation: "runtime_only";
64
80
  readonly runtime: "enforced";
81
+ readonly gmi: "accepted_but_deferred";
65
82
  };
66
83
  readonly provenance: {
67
84
  readonly agent: "accepted_but_deferred";
68
85
  readonly generation: "runtime_only";
69
86
  readonly runtime: "enforced";
87
+ readonly gmi: "accepted_but_deferred";
70
88
  };
71
89
  readonly observability: {
72
90
  readonly agent: "partially_enforced";
73
91
  readonly generation: "partially_enforced";
74
92
  readonly runtime: "enforced";
93
+ readonly gmi: "partially_enforced";
75
94
  };
76
95
  readonly controls: {
77
96
  readonly agent: "partially_enforced";
78
97
  readonly generation: "runtime_only";
79
98
  readonly runtime: "enforced";
99
+ readonly gmi: "partially_enforced";
80
100
  };
81
101
  };
82
102
  export declare function getCapabilitySupport(surface: CapabilitySurface, key: CapabilityKey): CapabilitySupport;
@@ -1 +1 @@
1
- {"version":3,"file":"capabilityContract.d.ts","sourceRoot":"","sources":["../../../src/api/runtime/capabilityContract.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,YAAY,GAAG,SAAS,CAAC;AAEnE,MAAM,MAAM,iBAAiB,GACzB,UAAU,GACV,oBAAoB,GACpB,uBAAuB,GACvB,cAAc,CAAC;AAEnB,eAAO,MAAM,eAAe,yLAgBlB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgBsC,CAAC;AAEzF,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,iBAAiB,EAC1B,GAAG,EAAE,aAAa,GACjB,iBAAiB,CAEnB"}
1
+ {"version":3,"file":"capabilityContract.d.ts","sourceRoot":"","sources":["../../../src/api/runtime/capabilityContract.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,YAAY,GAAG,SAAS,GAAG,KAAK,CAAC;AAE3E,MAAM,MAAM,iBAAiB,GACzB,UAAU,GACV,oBAAoB,GACpB,uBAAuB,GACvB,cAAc,CAAC;AAEnB,eAAO,MAAM,eAAe,yLAgBlB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgBsC,CAAC;AAEzF,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,iBAAiB,EAC1B,GAAG,EAAE,aAAa,GACjB,iBAAiB,CAEnB"}
@@ -16,21 +16,21 @@ export const CAPABILITY_KEYS = [
16
16
  'controls',
17
17
  ];
18
18
  export const BASE_AGENT_CONFIG_CAPABILITY_CONTRACT = {
19
- tools: { agent: 'enforced', generation: 'enforced', runtime: 'enforced' },
20
- memory: { agent: 'partially_enforced', generation: 'runtime_only', runtime: 'enforced' },
21
- rag: { agent: 'accepted_but_deferred', generation: 'runtime_only', runtime: 'enforced' },
22
- discovery: { agent: 'accepted_but_deferred', generation: 'runtime_only', runtime: 'enforced' },
23
- guardrails: { agent: 'accepted_but_deferred', generation: 'partially_enforced', runtime: 'enforced' },
24
- security: { agent: 'accepted_but_deferred', generation: 'runtime_only', runtime: 'enforced' },
25
- permissions: { agent: 'accepted_but_deferred', generation: 'partially_enforced', runtime: 'enforced' },
26
- hitl: { agent: 'accepted_but_deferred', generation: 'runtime_only', runtime: 'enforced' },
27
- emergent: { agent: 'accepted_but_deferred', generation: 'runtime_only', runtime: 'enforced' },
28
- voice: { agent: 'accepted_but_deferred', generation: 'runtime_only', runtime: 'enforced' },
29
- channels: { agent: 'accepted_but_deferred', generation: 'runtime_only', runtime: 'enforced' },
30
- output: { agent: 'accepted_but_deferred', generation: 'runtime_only', runtime: 'enforced' },
31
- provenance: { agent: 'accepted_but_deferred', generation: 'runtime_only', runtime: 'enforced' },
32
- observability: { agent: 'partially_enforced', generation: 'partially_enforced', runtime: 'enforced' },
33
- controls: { agent: 'partially_enforced', generation: 'runtime_only', runtime: 'enforced' },
19
+ tools: { agent: 'enforced', generation: 'enforced', runtime: 'enforced', gmi: 'enforced' },
20
+ memory: { agent: 'partially_enforced', generation: 'runtime_only', runtime: 'enforced', gmi: 'enforced' },
21
+ rag: { agent: 'accepted_but_deferred', generation: 'runtime_only', runtime: 'enforced', gmi: 'accepted_but_deferred' },
22
+ discovery: { agent: 'accepted_but_deferred', generation: 'runtime_only', runtime: 'enforced', gmi: 'accepted_but_deferred' },
23
+ guardrails: { agent: 'accepted_but_deferred', generation: 'partially_enforced', runtime: 'enforced', gmi: 'accepted_but_deferred' },
24
+ security: { agent: 'accepted_but_deferred', generation: 'runtime_only', runtime: 'enforced', gmi: 'accepted_but_deferred' },
25
+ permissions: { agent: 'accepted_but_deferred', generation: 'partially_enforced', runtime: 'enforced', gmi: 'accepted_but_deferred' },
26
+ hitl: { agent: 'accepted_but_deferred', generation: 'runtime_only', runtime: 'enforced', gmi: 'accepted_but_deferred' },
27
+ emergent: { agent: 'accepted_but_deferred', generation: 'runtime_only', runtime: 'enforced', gmi: 'accepted_but_deferred' },
28
+ voice: { agent: 'accepted_but_deferred', generation: 'runtime_only', runtime: 'enforced', gmi: 'runtime_only' },
29
+ channels: { agent: 'accepted_but_deferred', generation: 'runtime_only', runtime: 'enforced', gmi: 'runtime_only' },
30
+ output: { agent: 'accepted_but_deferred', generation: 'runtime_only', runtime: 'enforced', gmi: 'accepted_but_deferred' },
31
+ provenance: { agent: 'accepted_but_deferred', generation: 'runtime_only', runtime: 'enforced', gmi: 'accepted_but_deferred' },
32
+ observability: { agent: 'partially_enforced', generation: 'partially_enforced', runtime: 'enforced', gmi: 'partially_enforced' },
33
+ controls: { agent: 'partially_enforced', generation: 'runtime_only', runtime: 'enforced', gmi: 'partially_enforced' },
34
34
  };
35
35
  export function getCapabilitySupport(surface, key) {
36
36
  return BASE_AGENT_CONFIG_CAPABILITY_CONTRACT[key][surface];
@@ -1 +1 @@
1
- {"version":3,"file":"capabilityContract.js","sourceRoot":"","sources":["../../../src/api/runtime/capabilityContract.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,OAAO;IACP,QAAQ;IACR,KAAK;IACL,WAAW;IACX,YAAY;IACZ,UAAU;IACV,aAAa;IACb,MAAM;IACN,UAAU;IACV,OAAO;IACP,UAAU;IACV,QAAQ;IACR,YAAY;IACZ,eAAe;IACf,UAAU;CACF,CAAC;AAIX,MAAM,CAAC,MAAM,qCAAqC,GAAG;IACnD,KAAK,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE;IACzE,MAAM,EAAE,EAAE,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE;IACxF,GAAG,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE;IACxF,SAAS,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE;IAC9F,UAAU,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,UAAU,EAAE,oBAAoB,EAAE,OAAO,EAAE,UAAU,EAAE;IACrG,QAAQ,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE;IAC7F,WAAW,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,UAAU,EAAE,oBAAoB,EAAE,OAAO,EAAE,UAAU,EAAE;IACtG,IAAI,EAAE,EAAE,KAAK,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O,EAAE,UAAU,EAAE,GAAG,EAAE,cAAc,EAAE;IAC/G,QAAQ,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,cAAc,EAAE;IAClH,MAAM,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,uBAAuB,EAAE;IACzH,UAAU,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,uBAAuB,EAAE;IAC7H,aAAa,EAAE,EAAE,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,oBAAoB,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,oBAAoB,EAAE;IAChI,QAAQ,EAAE,EAAE,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,oBAAoB,EAAE;CAC/B,CAAC;AAEzF,MAAM,UAAU,oBAAoB,CAClC,OAA0B,EAC1B,GAAkB;IAElB,OAAO,qCAAqC,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * @file gmiCognition.ts
3
+ * Cognition profiles for GMIs built from agent options (`agent({ runtime: 'gmi' })`).
4
+ *
5
+ * `light` (the default) is a GMI with its reasoning trace and nothing else
6
+ * unless `memory` is set. `full` adds cognitive memory with every mechanism,
7
+ * sentiment tracking and every metaprompt preset. A {@link CognitionConfig}
8
+ * sets each switch on its own.
9
+ */
10
+ import type { MemoryConfig } from '../types.js';
11
+ import type { CognitiveMechanismsConfig } from '../../cognition/memory/mechanisms/types.js';
12
+ import type { SentimentTrackingConfig } from '../../cognition/substrate/personas/IPersonaDefinition.js';
13
+ /** A named cognition profile. */
14
+ export type CognitionProfile = 'light' | 'full';
15
+ /** A metaprompt preset, named as `SentimentTrackingConfig.presets` names it. */
16
+ export type MetapromptPreset = Exclude<NonNullable<SentimentTrackingConfig['presets']>[number], 'all'>;
17
+ /** Each cognition switch set explicitly, in place of a named profile. */
18
+ export interface CognitionConfig {
19
+ /** Cognitive memory: false, true (defaults) or a MemoryConfig. Unset: the agent's `memory` option. */
20
+ memory?: boolean | MemoryConfig;
21
+ /**
22
+ * Memory mechanisms: true (the agent's `cognitiveMechanisms`, or every
23
+ * mechanism at its defaults), false (none) or a per-mechanism config.
24
+ * Unset means true. Needs memory.
25
+ */
26
+ mechanisms?: boolean | CognitiveMechanismsConfig;
27
+ /** Sentiment tracking: every user turn is scored by the utility AI's lexicon. */
28
+ sentiment?: boolean;
29
+ /**
30
+ * Metaprompt presets: `'all'`, a list of presets, or false. Needs
31
+ * `sentiment`: the presets answer the events sentiment tracking raises.
32
+ */
33
+ metaprompts?: 'all' | MetapromptPreset[] | false;
34
+ }
35
+ /** What a GMI built from agent options runs. */
36
+ export interface ResolvedCognition {
37
+ profile: CognitionProfile | 'custom';
38
+ /** The cognitive memory config, or false for none. */
39
+ memory: MemoryConfig | false;
40
+ /** The mechanisms config the memory manager runs; undefined when memory or the mechanisms are off. */
41
+ mechanisms: CognitiveMechanismsConfig | undefined;
42
+ sentiment: boolean;
43
+ /** The metaprompt presets; false when sentiment is off. */
44
+ metaprompts: 'all' | MetapromptPreset[] | false;
45
+ }
46
+ /** The agent options {@link resolveCognition} reads. */
47
+ export interface CognitionInputs {
48
+ cognition?: CognitionProfile | CognitionConfig;
49
+ memory?: boolean | MemoryConfig;
50
+ cognitiveMechanisms?: CognitiveMechanismsConfig;
51
+ }
52
+ /**
53
+ * Resolves an agent's `cognition`, `memory` and `cognitiveMechanisms` options
54
+ * into the switches a GMI runs with.
55
+ *
56
+ * - `light`: memory only when `memory` is set (then every mechanism, or the
57
+ * agent's `cognitiveMechanisms`); no sentiment tracking, no metaprompts.
58
+ * - `full`: memory unless `memory: false`, every mechanism (or the agent's
59
+ * `cognitiveMechanisms`), sentiment tracking and every metaprompt preset.
60
+ * - A {@link CognitionConfig}: each switch as set, with `memory` falling back
61
+ * to the agent's `memory` option.
62
+ *
63
+ * @throws {Error} When `cognition` names an unknown profile or an unknown metaprompt preset.
64
+ */
65
+ export declare function resolveCognition(opts: CognitionInputs): ResolvedCognition;
66
+ //# sourceMappingURL=gmiCognition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gmiCognition.d.ts","sourceRoot":"","sources":["../../../src/api/runtime/gmiCognition.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAC5F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0DAA0D,CAAC;AAGxG,iCAAiC;AACjC,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,MAAM,CAAC;AAEhD,gFAAgF;AAChF,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC;AAEvG,yEAAyE;AACzE,MAAM,WAAW,eAAe;IAC9B,sGAAsG;IACtG,MAAM,CAAC,EAAE,OAAO,GAAG,YAAY,CAAC;IAChC;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG,yBAAyB,CAAC;IACjD,iFAAiF;IACjF,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,KAAK,GAAG,gBAAgB,EAAE,GAAG,KAAK,CAAC;CAClD;AAED,gDAAgD;AAChD,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,gBAAgB,GAAG,QAAQ,CAAC;IACrC,sDAAsD;IACtD,MAAM,EAAE,YAAY,GAAG,KAAK,CAAC;IAC7B,sGAAsG;IACtG,UAAU,EAAE,yBAAyB,GAAG,SAAS,CAAC;IAClD,SAAS,EAAE,OAAO,CAAC;IACnB,2DAA2D;IAC3D,WAAW,EAAE,KAAK,GAAG,gBAAgB,EAAE,GAAG,KAAK,CAAC;CACjD;AAED,wDAAwD;AACxD,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,gBAAgB,GAAG,eAAe,CAAC;IAC/C,MAAM,CAAC,EAAE,OAAO,GAAG,YAAY,CAAC;IAChC,mBAAmB,CAAC,EAAE,yBAAyB,CAAC;CACjD;AAuBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,eAAe,GAAG,iBAAiB,CAsBzE"}
@@ -0,0 +1,58 @@
1
+ import { SENTIMENT_PRESET_IDS } from '../../cognition/substrate/personas/personaNormalization.js';
2
+ function memoryOf(value) {
3
+ if (value === undefined || value === false)
4
+ return false;
5
+ return value === true ? {} : value;
6
+ }
7
+ function presetsOf(value) {
8
+ if (value === undefined || value === false)
9
+ return false;
10
+ if (value === 'all')
11
+ return 'all';
12
+ if (!Array.isArray(value)) {
13
+ throw new Error("cognition.metaprompts must be 'all', a list of presets, or false.");
14
+ }
15
+ const unknown = value.filter((name) => !Object.prototype.hasOwnProperty.call(SENTIMENT_PRESET_IDS, name));
16
+ if (unknown.length > 0) {
17
+ throw new Error(`cognition.metaprompts: unknown preset ${unknown.map((name) => `'${String(name)}'`).join(', ')}; ` +
18
+ `use 'all' or a list of ${Object.keys(SENTIMENT_PRESET_IDS).join(', ')}.`);
19
+ }
20
+ return [...value];
21
+ }
22
+ /**
23
+ * Resolves an agent's `cognition`, `memory` and `cognitiveMechanisms` options
24
+ * into the switches a GMI runs with.
25
+ *
26
+ * - `light`: memory only when `memory` is set (then every mechanism, or the
27
+ * agent's `cognitiveMechanisms`); no sentiment tracking, no metaprompts.
28
+ * - `full`: memory unless `memory: false`, every mechanism (or the agent's
29
+ * `cognitiveMechanisms`), sentiment tracking and every metaprompt preset.
30
+ * - A {@link CognitionConfig}: each switch as set, with `memory` falling back
31
+ * to the agent's `memory` option.
32
+ *
33
+ * @throws {Error} When `cognition` names an unknown profile or an unknown metaprompt preset.
34
+ */
35
+ export function resolveCognition(opts) {
36
+ const c = opts.cognition ?? 'light';
37
+ if (c === 'light') {
38
+ const memory = memoryOf(opts.memory);
39
+ return { profile: 'light', memory, mechanisms: memory ? (opts.cognitiveMechanisms ?? {}) : undefined, sentiment: false, metaprompts: false };
40
+ }
41
+ if (c === 'full') {
42
+ const memory = memoryOf(opts.memory ?? true);
43
+ return { profile: 'full', memory, mechanisms: memory ? (opts.cognitiveMechanisms ?? {}) : undefined, sentiment: true, metaprompts: 'all' };
44
+ }
45
+ if (typeof c !== 'object') {
46
+ throw new Error(`cognition: unknown profile '${String(c)}'; use 'light', 'full' or a CognitionConfig.`);
47
+ }
48
+ const memory = memoryOf(c.memory ?? opts.memory);
49
+ const mechanisms = !memory || c.mechanisms === false
50
+ ? undefined
51
+ : c.mechanisms === true || c.mechanisms === undefined
52
+ ? (opts.cognitiveMechanisms ?? {})
53
+ : c.mechanisms;
54
+ const sentiment = c.sentiment === true;
55
+ const metaprompts = presetsOf(c.metaprompts);
56
+ return { profile: 'custom', memory, mechanisms, sentiment, metaprompts: sentiment ? metaprompts : false };
57
+ }
58
+ //# sourceMappingURL=gmiCognition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gmiCognition.js","sourceRoot":"","sources":["../../../src/api/runtime/gmiCognition.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4DAA4D,CAAC;AA8ClG,SAAS,QAAQ,CAAC,KAAyC;IACzD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IACzD,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AACrC,CAAC;AAED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AE,CAAC;AAC5G,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { type AgentOptions } from '../agent.js';
2
+ import type { IPersonaDefinition } from '../../cognition/substrate/personas/IPersonaDefinition.js';
3
+ import type { ITool } from '../../core/tools/ITool.js';
4
+ import type { ResolvedCognition } from './gmiCognition.js';
5
+ /** The session store bounds history (spec D10), so the GMI's own count window stays out of the way. */
6
+ export declare const GMI_SESSION_MAX_HISTORY_MESSAGES = 100000;
7
+ /**
8
+ * Builds the persona of a GMI from agent options (spec D6).
9
+ *
10
+ * @param opts - The agent's options.
11
+ * @param cognition - The resolved profile ({@link resolveCognition}): sentiment tracking and metaprompts.
12
+ * @param tools - The agent's tools, adapted: they decide the chain-of-thought text and the persona's capabilities.
13
+ * @throws {Error} When no provider or model can be resolved, as `generateText` throws.
14
+ */
15
+ export declare function personaFromAgentOptions(opts: AgentOptions, cognition: ResolvedCognition, tools: ITool[]): IPersonaDefinition;
16
+ //# sourceMappingURL=gmiPersona.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gmiPersona.d.ts","sourceRoot":"","sources":["../../../src/api/runtime/gmiPersona.ts"],"names":[],"mappings":"AAYA,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAKnE,OAAO,KAAK,EAAE,kBAAkB,EAA2B,MAAM,0DAA0D,CAAC;AAC5H,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,uGAAuG;AACvG,eAAO,MAAM,gCAAgC,SAAU,CAAC;AAsCxD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,kBAAkB,CAsB5H"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * @file gmiPersona.ts
3
+ * The persona of a GMI built from agent options (`agent({ runtime: 'gmi' })`).
4
+ *
5
+ * The base system prompt is the text the legacy path sends: `buildSystemPrompt(opts)`
6
+ * (or the joined `systemBlocks`), with the chain-of-thought instruction first when
7
+ * the agent has tools, as `generateText` puts it. The completion options are the
8
+ * ones `agent()` forwards on every call. Sentiment presets are expanded into
9
+ * metaprompts, as the persona loaders expand them, because the GMI runs only the
10
+ * persona's `metaPrompts`.
11
+ */
12
+ import { createHash, randomUUID } from 'node:crypto';
13
+ import { buildSystemPrompt } from '../agent.js';
14
+ import { resolveChainOfThought } from '../generateText.js';
15
+ import { resolveModelOption } from '../model.js';
16
+ import { normalizeHexacoTraits } from '../../cognition/substrate/personas/hexaco.js';
17
+ import { normalizePersonaDefinition } from '../../cognition/substrate/personas/personaNormalization.js';
18
+ /** The session store bounds history (spec D10), so the GMI's own count window stays out of the way. */
19
+ export const GMI_SESSION_MAX_HISTORY_MESSAGES = 100000;
20
+ /**
21
+ * A stable persona id from the agent's name: a lowercase ASCII slug, or, for a
22
+ * name with no Latin letters or digits, `agent-` and a hash of the name.
23
+ */
24
+ function personaIdFor(name) {
25
+ const slug = name
26
+ .normalize('NFKD')
27
+ .replace(/[̀-ͯ]/g, '')
28
+ .toLowerCase()
29
+ .replace(/[^a-z0-9]+/g, '-')
30
+ .replace(/^-+|-+$/g, '');
31
+ return slug || `agent-${createHash('sha256').update(name).digest('hex').slice(0, 12)}`;
32
+ }
33
+ /** The completion options `agent()` forwards on every call (its `baseOpts`), unset ones left out. */
34
+ function completionOptionsOf(opts) {
35
+ const out = {};
36
+ const maxTokens = opts.maxTokens ?? opts.controls?.maxTotalTokens;
37
+ if (maxTokens !== undefined)
38
+ out.maxTokens = maxTokens;
39
+ if (opts.controls?.maxDurationMs !== undefined)
40
+ out.requestTimeout = opts.controls.maxDurationMs;
41
+ if (opts.thinking !== undefined)
42
+ out.thinking = opts.thinking;
43
+ if (opts.effort !== undefined)
44
+ out.effort = opts.effort;
45
+ if (opts.customModelParams !== undefined)
46
+ out.customModelParams = opts.customModelParams;
47
+ if (opts.cache !== undefined)
48
+ out.cache = opts.cache;
49
+ return out;
50
+ }
51
+ function basePrompt(opts, hasTools) {
52
+ const system = opts.systemBlocks
53
+ ? opts.systemBlocks.map((block) => block.text).filter(Boolean).join('\n\n')
54
+ : buildSystemPrompt(opts) ?? '';
55
+ const cot = hasTools ? resolveChainOfThought(opts.chainOfThought ?? true) : undefined;
56
+ if (!cot)
57
+ return system;
58
+ return system ? `${cot}\n\n${system}` : cot;
59
+ }
60
+ /**
61
+ * Builds the persona of a GMI from agent options (spec D6).
62
+ *
63
+ * @param opts - The agent's options.
64
+ * @param cognition - The resolved profile ({@link resolveCognition}): sentiment tracking and metaprompts.
65
+ * @param tools - The agent's tools, adapted: they decide the chain-of-thought text and the persona's capabilities.
66
+ * @throws {Error} When no provider or model can be resolved, as `generateText` throws.
67
+ */
68
+ export function personaFromAgentOptions(opts, cognition, tools) {
69
+ const { providerId, modelId } = resolveModelOption({ provider: opts.provider, model: opts.model, baseUrl: opts.baseUrl }, 'text');
70
+ const name = opts.name?.trim() || 'Agent';
71
+ const firstLine = opts.instructions?.split('\n').map((line) => line.trim()).find(Boolean);
72
+ const completion = completionOptionsOf(opts);
73
+ const presets = cognition.metaprompts === 'all' ? ['all'] : cognition.metaprompts || [];
74
+ const persona = {
75
+ id: opts.name?.trim() ? personaIdFor(opts.name.trim()) : `agent-${randomUUID()}`,
76
+ name,
77
+ description: firstLine ?? name,
78
+ version: '1.0.0',
79
+ baseSystemPrompt: basePrompt(opts, tools.length > 0),
80
+ ...(opts.personality ? { personalityTraits: normalizeHexacoTraits(opts.personality) } : {}),
81
+ defaultProviderId: providerId,
82
+ defaultModelId: modelId,
83
+ ...(Object.keys(completion).length > 0 ? { defaultModelCompletionOptions: completion } : {}),
84
+ allowedCapabilities: [...new Set(tools.flatMap((tool) => tool.requiredCapabilities ?? []))],
85
+ conversationContextConfig: { maxMessages: GMI_SESSION_MAX_HISTORY_MESSAGES },
86
+ sentimentTracking: cognition.sentiment ? { enabled: true, presets } : { enabled: false },
87
+ ...(cognition.metaprompts === false ? { metaPrompts: [] } : {}),
88
+ };
89
+ return normalizePersonaDefinition(persona);
90
+ }
91
+ //# sourceMappingURL=gmiPersona.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gmiPersona.js","sourceRoot":"","sources":["../../../src/api/runtime/gmiPersona.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAqB,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,4DAA4D,CAAC;AAMxG,uGAAuG;AACvG,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAO,CAAC;AAExD;;;GAGG;AACH,SAAS,YAAY,CAAC,IAAY;IAChC,MAAM,IAAI,GAAG,IAAI;SACd,SAAS,CAAC,MAAM,CAAC;SACjB,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;SACrB,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAC3B,OAAO,IAAI,IAAI,SAAS,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;AACzF,CAAC;AAED,qGAAqG;AACrG,SAAS,mBAAmB,CAAC,IAAkB;IAC7C,MAAM,GAAG,GAAoC,EAAE,CAAC;IAChD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,IAA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I,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3F,iBAAiB,EAAE,UAAU;QAC7B,cAAc,EAAE,OAAO;QACvB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,6BAA6B,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5F,mBAAmB,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC,CAAC;QAC3F,yBAAyB,EAAE,EAAE,WAAW,EAAE,gCAAgC,EAAE;QAC5E,iBAAiB,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE;QACxF,GAAG,CAAC,SAAS,CAAC,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAChE,CAAC;IACF,OAAO,0BAA0B,CAAC,OAAO,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * @file gmiResults.ts
3
+ * Folds a GMI turn's output chunks into the result shapes of `generateText`
4
+ * (`session.send()`) and `streamText` (`session.stream()`) on the GMI path
5
+ * (`agent({ runtime: 'gmi' })`).
6
+ *
7
+ * The rules are streamText's: the turn's text is the latest step that produced
8
+ * text; usage adds each step's STEP_FINISHED usage once (USAGE_UPDATE carries a
9
+ * request's running total) plus the billed usage of attempts that failed before
10
+ * any output; a run that called tools and produced no text ends as
11
+ * `'tool-calls'`; an ERROR chunk ends it as `'error'` with the GMI's code.
12
+ */
13
+ import { GMIError } from '../../core/utils/errors.js';
14
+ import { type GMIOutputChunk, type StepFinishedChunkPayload, type ToolResultChunkPayload } from '../../cognition/substrate/IGMI.js';
15
+ import { type GenerateTextResult, type TokenUsage, type ToolCallRecord } from '../generateText.js';
16
+ import { type StreamTextResult } from '../streamText.js';
17
+ import type { SessionTranscriptMessage } from '../sessionTranscript.js';
18
+ /** The error a turn ended with, as the GMI reported it. */
19
+ export interface GmiTurnError {
20
+ code?: string;
21
+ message: string;
22
+ details?: unknown;
23
+ }
24
+ /** An attempt that failed before any output and was billed (reported on a USAGE_UPDATE with `metadata.attemptFailed`). */
25
+ export interface GmiFailedAttempt {
26
+ providerId?: string;
27
+ modelId?: string;
28
+ usage: TokenUsage;
29
+ }
30
+ /** The message a failed tool result carries. */
31
+ export declare function toolErrorMessage(result: ToolResultChunkPayload): string;
32
+ /**
33
+ * Accumulates one turn's chunks. `push` every chunk in order; read the result
34
+ * once the turn has ended (or at any point for a partial view).
35
+ */
36
+ export declare class GmiTurnFolder {
37
+ /** The STEP_FINISHED payloads, in order. */
38
+ readonly steps: StepFinishedChunkPayload[];
39
+ /** Every requested call in order, with its result once the TOOL_RESULT arrived. */
40
+ private readonly calls;
41
+ private readonly overrides;
42
+ private readonly failed;
43
+ private failure;
44
+ push(chunk: GMIOutputChunk): void;
45
+ /** Marks the turn failed by a thrown error (the turn's generator itself threw). An ERROR chunk already seen wins. */
46
+ fail(error: unknown): void;
47
+ /** Replaces a step's text (`onAfterGeneration`), in the result and in what the session stores. */
48
+ overrideStepText(stepIndex: number, text: string): void;
49
+ /** A step's text as the result reports it: a schema answer as its JSON string, else the hook's replacement, else the step's own text. */
50
+ stepText(step: StepFinishedChunkPayload): string;
51
+ /** The latest step that produced text, streamText's rule. */
52
+ text(): string;
53
+ /** Each step's usage once, plus every billed failed attempt. */
54
+ usage(): TokenUsage;
55
+ /** The billed attempts that failed before any output, in order. */
56
+ failedAttempts(): GmiFailedAttempt[];
57
+ /** Every call the model requested, with its result or error. */
58
+ toolCalls(): ToolCallRecord[];
59
+ /** The latest schema answer a step carried, if any. */
60
+ structuredOutput(): unknown;
61
+ error(): GmiTurnError | undefined;
62
+ finishReason(): GenerateTextResult['finishReason'];
63
+ /** The error the turn ended with, as a GMIError keeping the GMI's code. */
64
+ toError(): GMIError | undefined;
65
+ /**
66
+ * The turn as `generateText` reports a run: provider, model and response
67
+ * metadata from the last step, the text, the usage, the tool calls and the
68
+ * finish reason.
69
+ *
70
+ * @param transcriptDelta - The messages the turn added to the session store.
71
+ */
72
+ toGenerateTextResult(transcriptDelta?: SessionTranscriptMessage[]): GenerateTextResult;
73
+ }
74
+ /** Options for {@link streamFromGmiTurn}. */
75
+ export interface GmiStreamOptions {
76
+ /**
77
+ * A folder the turn already pushes every chunk into (the session's, which
78
+ * carries the `onAfterGeneration` replacements). Without one, the stream
79
+ * folds the chunks itself.
80
+ */
81
+ folder?: GmiTurnFolder;
82
+ }
83
+ /**
84
+ * A `StreamTextResult` over a GMI turn. The turn is drained eagerly, so every
85
+ * promise settles whether the caller iterates, stops iterating early, or never
86
+ * iterates; `textStream` and `fullStream` replay what arrived and wait for more.
87
+ *
88
+ * `textStream` yields every TEXT_DELTA as it arrives. `fullStream` maps
89
+ * TEXT_DELTA to `text`, TOOL_CALL_REQUEST to `tool-call`, TOOL_RESULT to
90
+ * `tool-result` and ERROR (or a thrown error) to a final `error` part. `text`
91
+ * is the latest step's text; after an error it is the text the failed step
92
+ * delivered, as streamText resolves it.
93
+ *
94
+ * @param turn - The turn's chunks.
95
+ * @param options - A caller-owned folder; see {@link GmiStreamOptions}.
96
+ */
97
+ export declare function streamFromGmiTurn(turn: AsyncIterable<GMIOutputChunk>, options?: GmiStreamOptions): StreamTextResult;
98
+ //# sourceMappingURL=gmiResults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gmiResults.d.ts","sourceRoot":"","sources":["../../../src/api/runtime/gmiResults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,QAAQ,EAAgB,MAAM,4BAA4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