@genesislcap/ai-assistant 15.61.0 → 15.62.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 (134) hide show
  1. package/dist/ai-assistant.api.json +18231 -11171
  2. package/dist/ai-assistant.d.ts +1235 -9
  3. package/dist/chat-driver.cjs +658 -50
  4. package/dist/chat-driver.cjs.map +4 -4
  5. package/dist/chat-driver.mjs +657 -50
  6. package/dist/chat-driver.mjs.map +4 -4
  7. package/dist/custom-elements.json +6169 -2127
  8. package/dist/dts/autopilot/autopilot-driver.d.ts +278 -0
  9. package/dist/dts/autopilot/autopilot-driver.d.ts.map +1 -0
  10. package/dist/dts/autopilot/autopilot-session.d.ts +163 -0
  11. package/dist/dts/autopilot/autopilot-session.d.ts.map +1 -0
  12. package/dist/dts/autopilot/autopilot-tools.d.ts +15 -0
  13. package/dist/dts/autopilot/autopilot-tools.d.ts.map +1 -0
  14. package/dist/dts/autopilot/decision-message.d.ts +62 -0
  15. package/dist/dts/autopilot/decision-message.d.ts.map +1 -0
  16. package/dist/dts/autopilot/hand-back/hand-back.controller.d.ts +69 -0
  17. package/dist/dts/autopilot/hand-back/hand-back.controller.d.ts.map +1 -0
  18. package/dist/dts/autopilot/hand-back/hand-back.d.ts +22 -0
  19. package/dist/dts/autopilot/hand-back/hand-back.d.ts.map +1 -0
  20. package/dist/dts/autopilot/index.d.ts +4 -0
  21. package/dist/dts/autopilot/index.d.ts.map +1 -0
  22. package/dist/dts/channel/ai-activity-bus.d.ts.map +1 -1
  23. package/dist/dts/channel/ai-activity-channel.d.ts +17 -0
  24. package/dist/dts/channel/ai-activity-channel.d.ts.map +1 -1
  25. package/dist/dts/channel/autopilot-needs-user.d.ts +8 -0
  26. package/dist/dts/channel/autopilot-needs-user.d.ts.map +1 -0
  27. package/dist/dts/components/agent-picker/agent-picker.constants.d.ts +10 -0
  28. package/dist/dts/components/agent-picker/agent-picker.constants.d.ts.map +1 -1
  29. package/dist/dts/components/agent-picker/agent-picker.d.ts +4 -0
  30. package/dist/dts/components/agent-picker/agent-picker.d.ts.map +1 -1
  31. package/dist/dts/components/agent-picker/agent-picker.template.d.ts.map +1 -1
  32. package/dist/dts/components/ai-driver/ai-driver.d.ts +34 -1
  33. package/dist/dts/components/ai-driver/ai-driver.d.ts.map +1 -1
  34. package/dist/dts/components/ai-driver/base-driver-decorator.d.ts +3 -1
  35. package/dist/dts/components/ai-driver/base-driver-decorator.d.ts.map +1 -1
  36. package/dist/dts/components/chat-bubble/chat-bubble.d.ts +21 -0
  37. package/dist/dts/components/chat-bubble/chat-bubble.d.ts.map +1 -1
  38. package/dist/dts/components/chat-bubble/chat-bubble.styles.d.ts.map +1 -1
  39. package/dist/dts/components/chat-bubble/chat-bubble.template.d.ts.map +1 -1
  40. package/dist/dts/components/chat-driver/chat-driver.d.ts +5 -1
  41. package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
  42. package/dist/dts/components/chat-driver/interaction-controller.d.ts +27 -3
  43. package/dist/dts/components/chat-driver/interaction-controller.d.ts.map +1 -1
  44. package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.d.ts +10 -2
  45. package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.d.ts.map +1 -1
  46. package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts +9 -1
  47. package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts.map +1 -1
  48. package/dist/dts/config/config.d.ts +183 -0
  49. package/dist/dts/config/config.d.ts.map +1 -1
  50. package/dist/dts/config/define-stateful-agent.d.ts +31 -1
  51. package/dist/dts/config/define-stateful-agent.d.ts.map +1 -1
  52. package/dist/dts/index.d.ts +7 -3
  53. package/dist/dts/index.d.ts.map +1 -1
  54. package/dist/dts/main/main.d.ts +128 -5
  55. package/dist/dts/main/main.d.ts.map +1 -1
  56. package/dist/dts/main/main.styles.d.ts.map +1 -1
  57. package/dist/dts/main/main.template.d.ts +2 -2
  58. package/dist/dts/main/main.template.d.ts.map +1 -1
  59. package/dist/dts/react.d.ts +10 -0
  60. package/dist/dts/state/debug-event-log.d.ts +1 -1
  61. package/dist/dts/state/debug-event-log.d.ts.map +1 -1
  62. package/dist/dts/state/decision-surface.d.ts +46 -0
  63. package/dist/dts/state/decision-surface.d.ts.map +1 -0
  64. package/dist/dts/state/interaction-context.d.ts +21 -1
  65. package/dist/dts/state/interaction-context.d.ts.map +1 -1
  66. package/dist/dts/state/interaction-registry.d.ts +63 -0
  67. package/dist/dts/state/interaction-registry.d.ts.map +1 -0
  68. package/dist/dts/state/persistence/session-persister.d.ts.map +1 -1
  69. package/dist/dts/state/persistence/session-snapshot.d.ts +21 -0
  70. package/dist/dts/state/persistence/session-snapshot.d.ts.map +1 -1
  71. package/dist/dts/state/run-steps.d.ts +66 -0
  72. package/dist/dts/state/run-steps.d.ts.map +1 -0
  73. package/dist/dts/types/ai-chat-widget.d.ts +7 -1
  74. package/dist/dts/types/ai-chat-widget.d.ts.map +1 -1
  75. package/dist/dts/types/interaction-context.d.ts +66 -1
  76. package/dist/dts/types/interaction-context.d.ts.map +1 -1
  77. package/dist/dts/types/interaction-interceptor.d.ts +60 -2
  78. package/dist/dts/types/interaction-interceptor.d.ts.map +1 -1
  79. package/dist/dts/types/interaction-surface.d.ts +195 -0
  80. package/dist/dts/types/interaction-surface.d.ts.map +1 -0
  81. package/dist/dts/utils/context-tokens.d.ts +6 -0
  82. package/dist/dts/utils/context-tokens.d.ts.map +1 -1
  83. package/dist/dts/utils/delegated-message.d.ts +13 -0
  84. package/dist/dts/utils/delegated-message.d.ts.map +1 -1
  85. package/dist/dts/utils/history-transform.d.ts.map +1 -1
  86. package/dist/dts/utils/preserved-user-messages.d.ts +21 -0
  87. package/dist/dts/utils/preserved-user-messages.d.ts.map +1 -0
  88. package/dist/esm/autopilot/autopilot-driver.js +906 -0
  89. package/dist/esm/autopilot/autopilot-session.js +449 -0
  90. package/dist/esm/autopilot/autopilot-tools.js +68 -0
  91. package/dist/esm/autopilot/decision-message.js +206 -0
  92. package/dist/esm/autopilot/hand-back/hand-back.controller.js +47 -0
  93. package/dist/esm/autopilot/hand-back/hand-back.js +129 -0
  94. package/dist/esm/autopilot/index.js +4 -0
  95. package/dist/esm/channel/ai-activity-bus.js +7 -0
  96. package/dist/esm/channel/autopilot-needs-user.js +26 -0
  97. package/dist/esm/components/agent-picker/agent-picker.constants.js +10 -0
  98. package/dist/esm/components/agent-picker/agent-picker.js +11 -1
  99. package/dist/esm/components/agent-picker/agent-picker.template.js +2 -4
  100. package/dist/esm/components/ai-driver/ai-driver.js +2 -0
  101. package/dist/esm/components/ai-driver/base-driver-decorator.js +8 -0
  102. package/dist/esm/components/chat-bubble/chat-bubble.js +45 -0
  103. package/dist/esm/components/chat-bubble/chat-bubble.styles.js +26 -0
  104. package/dist/esm/components/chat-bubble/chat-bubble.template.js +13 -0
  105. package/dist/esm/components/chat-driver/chat-driver.js +53 -18
  106. package/dist/esm/components/chat-driver/interaction-controller.js +297 -12
  107. package/dist/esm/components/chat-interaction-wrapper/chat-interaction-wrapper.js +16 -2
  108. package/dist/esm/components/orchestrating-driver/orchestrating-driver.js +28 -11
  109. package/dist/esm/config/define-stateful-agent.js +34 -29
  110. package/dist/esm/index.js +3 -0
  111. package/dist/esm/main/main.js +334 -15
  112. package/dist/esm/main/main.styles.js +126 -0
  113. package/dist/esm/main/main.template.js +116 -11
  114. package/dist/esm/state/debug-event-log.js +28 -1
  115. package/dist/esm/state/decision-surface.js +209 -0
  116. package/dist/esm/state/interaction-context.js +89 -1
  117. package/dist/esm/state/interaction-registry.js +33 -0
  118. package/dist/esm/state/persistence/session-persister.js +23 -11
  119. package/dist/esm/state/persistence/session-snapshot.js +1 -1
  120. package/dist/esm/state/run-steps.js +77 -0
  121. package/dist/esm/types/interaction-surface.js +1 -0
  122. package/dist/esm/utils/context-tokens.js +23 -9
  123. package/dist/esm/utils/delegated-message.js +15 -0
  124. package/dist/esm/utils/history-transform.js +18 -7
  125. package/dist/esm/utils/preserved-user-messages.js +31 -0
  126. package/dist/react.cjs +7 -0
  127. package/dist/react.mjs +6 -0
  128. package/docs/styling.md +1 -1
  129. package/package.json +17 -17
  130. package/sandbox/README.md +38 -2
  131. package/sandbox/autopilot.ts +358 -0
  132. package/sandbox/controls.ts +24 -1
  133. package/sandbox/fixtures.ts +2 -0
  134. package/sandbox/sandbox.ts +188 -1
@@ -0,0 +1,195 @@
1
+ /**
2
+ * One option of a short-form decision (GENC-1660). A bare string is an option whose id and label are
3
+ * the same text.
4
+ *
5
+ * @beta
6
+ */
7
+ export type DecisionOption = string | {
8
+ /**
9
+ * The stable name of the option's action — what a view passes to `ctx.claimantOwns` to hide
10
+ * its button. Defaults to `label`.
11
+ */
12
+ readonly id?: string;
13
+ /** The option's text, as the person sees it. */
14
+ readonly label: string;
15
+ /**
16
+ * Whether it can be chosen right now — the button's own guard (e.g. `validated` for a
17
+ * Continue). Read fresh every time. A disabled option is listed as unavailable and refused.
18
+ */
19
+ readonly enabledWhen?: () => boolean;
20
+ };
21
+ /**
22
+ * What was decided, as handed to a short-form decision's `choose` (GENC-1660).
23
+ *
24
+ * @beta
25
+ */
26
+ export type DecisionAnswer =
27
+ /** One option, by id. */
28
+ {
29
+ readonly kind: 'option';
30
+ readonly option: string;
31
+ }
32
+ /** Several options, by id (a multi-select). */
33
+ | {
34
+ readonly kind: 'options';
35
+ readonly options: readonly string[];
36
+ }
37
+ /** A written answer (`freeText`). */
38
+ | {
39
+ readonly kind: 'text';
40
+ readonly text: string;
41
+ };
42
+ /**
43
+ * A short-form decision: the surface most widgets need (GENC-1660). Its actions are its options,
44
+ * all finishing, plus `select` for a multi-select and `reply` for a written answer.
45
+ *
46
+ * @beta
47
+ */
48
+ export interface DecisionSpec {
49
+ readonly options: readonly DecisionOption[];
50
+ /** Adds a `select({ options })` action that picks several. */
51
+ readonly multi?: boolean;
52
+ /** Adds a `reply({ text })` action: an answer in the chooser's own words. */
53
+ readonly freeText?: boolean;
54
+ /**
55
+ * What a decision needs that the person sees on screen in some other form — e.g.
56
+ * `{ validated: true }`. A getter, so it is read fresh whenever the decision is described.
57
+ */
58
+ readonly facts?: () => Readonly<Record<string, unknown>>;
59
+ /**
60
+ * Model-only guidance the person would not see. The decision's own text comes from the
61
+ * widget's `asText`, which is what the person saw.
62
+ */
63
+ readonly prompt?: string;
64
+ /**
65
+ * Act on the answer. The SAME method the view's buttons call, so a claimant's answer runs the
66
+ * code a click runs. Must resolve the interaction (through `ctx.resolve`), now or once its work
67
+ * is done.
68
+ */
69
+ choose(answer: DecisionAnswer): void | Promise<void>;
70
+ }
71
+ /**
72
+ * One action on a surface, as anyone may read it (GENC-1660).
73
+ *
74
+ * @beta
75
+ */
76
+ export interface SurfaceAction {
77
+ /** The name to invoke it by: an option's id, or `select` / `reply`. */
78
+ readonly name: string;
79
+ /** The text the person sees for it, where it has one. */
80
+ readonly label?: string;
81
+ /** Whether running it settles the interaction. Every short-form action does. */
82
+ readonly finishes: boolean;
83
+ /** Whether it can be run right now. */
84
+ readonly enabled: boolean;
85
+ /**
86
+ * What its `args` must look like, where it takes any: `options` (a multi-select's picks), `text`
87
+ * (a written answer) or `fields` (an object, described by `argsSchema`).
88
+ */
89
+ readonly args?: 'options' | 'text' | 'fields';
90
+ /** A full-form action's own description, for the model. Short-form options have none. */
91
+ readonly description?: string;
92
+ /** For `fields`: the JSON schema its arguments are checked against. */
93
+ readonly argsSchema?: Readonly<Record<string, unknown>>;
94
+ }
95
+ /**
96
+ * One action of a full-form surface (GENC-1660 §4.2): a named thing a claimant can do, which may or
97
+ * may not settle the interaction.
98
+ *
99
+ * @beta
100
+ */
101
+ export interface SurfaceActionSpec {
102
+ /** For the model: what it does, and when to use it. */
103
+ readonly description: string;
104
+ /** Whether it settles the interaction. An editing action (`edit_rows`) does not. */
105
+ readonly finishes?: boolean;
106
+ /** The button's own guard, read fresh: the claimant can never do what the view would refuse. */
107
+ readonly enabledWhen?: () => boolean;
108
+ /**
109
+ * The JSON schema of its arguments, an object. Its `properties` and `required` are checked before
110
+ * it runs; a mismatch is refused with the reason, so the model can correct itself.
111
+ */
112
+ readonly argsSchema?: Readonly<Record<string, unknown>>;
113
+ /**
114
+ * Do it — the SAME code the view's control runs. A finishing action resolves the interaction; an
115
+ * editing one returns what changed (fresh errors, say), which the claimant is shown.
116
+ *
117
+ * A finishing action should settle promptly. While one runs asynchronously, the claimant can run
118
+ * nothing else, and it keeps the claimant's credit even if the interaction is handed to the person
119
+ * meanwhile, so the view should block its own controls until it ends: a click that lands then
120
+ * would be credited to the claimant.
121
+ */
122
+ run(args: unknown): unknown | Promise<unknown>;
123
+ }
124
+ /**
125
+ * A full-form surface, for a rich widget (GENC-1660 §4.2): something to describe, views to read,
126
+ * and named actions, some of which only edit.
127
+ *
128
+ * Its actions run one at a time. An asynchronous finishing action should settle promptly, and the
129
+ * view should block its own controls while one runs (see {@link SurfaceActionSpec.run}).
130
+ *
131
+ * @beta
132
+ */
133
+ export interface SurfaceSpec {
134
+ /** For the model: what this is, and what good looks like. Read fresh. */
135
+ describe(): string;
136
+ /** The names of the views `read` answers, e.g. `['summary', 'rows', 'errors']`. */
137
+ readonly views?: readonly string[];
138
+ /**
139
+ * The widget's state as JSON, by view, so a large widget is read a slice at a time. Called with
140
+ * no view for the default (shown with the decision, so pick something small).
141
+ */
142
+ read(view?: string): unknown;
143
+ readonly actions: Readonly<Record<string, SurfaceActionSpec>>;
144
+ /** Model-only guidance, beside `describe`. */
145
+ readonly prompt?: string;
146
+ }
147
+ /**
148
+ * What can be read from an interaction's surface (GENC-1660): its actions as they stand now, and
149
+ * its facts. Present once the controller has exposed one.
150
+ *
151
+ * @beta
152
+ */
153
+ export interface InteractionSurface {
154
+ /** Model-only guidance, from the decision's `prompt`. */
155
+ readonly prompt?: string;
156
+ /** Read fresh on every call. */
157
+ facts(): Readonly<Record<string, unknown>>;
158
+ /** A full-form surface's description. Absent on a short-form decision. */
159
+ describe?(): string;
160
+ /** A full-form surface's views. */
161
+ readonly views?: readonly string[];
162
+ /** Read one view of a full-form surface; absent on a short-form decision. */
163
+ read?(view?: string): unknown;
164
+ /** Read fresh on every call: `enabled` reflects each option's guard right now. */
165
+ actions(): readonly SurfaceAction[];
166
+ /**
167
+ * Whether a claimant could act on it now. A short-form decision is ready once one of its options
168
+ * is enabled; a full-form surface once any of its actions is, since editing comes before
169
+ * finishing (its Save may be disabled until something is edited).
170
+ */
171
+ isReady(): boolean;
172
+ }
173
+ /**
174
+ * What came of an `InteractionHold.invoke` (GENC-1660). On success, `finished` says whether the
175
+ * interaction settled and `actions` is what is enabled now; on failure, `error` says why and nothing
176
+ * ran.
177
+ *
178
+ * @beta
179
+ */
180
+ export type InvokeResult = {
181
+ readonly ok: true;
182
+ readonly finished: boolean;
183
+ readonly actions: readonly SurfaceAction[];
184
+ /** What an editing action returned (fresh errors, say), for the claimant. */
185
+ readonly output?: unknown;
186
+ readonly error?: never;
187
+ readonly message?: never;
188
+ } | {
189
+ readonly ok: false;
190
+ readonly finished?: never;
191
+ readonly error: 'not-held' | 'no-surface' | 'unknown-action' | 'disabled' | 'invalid-args' | 'threw' | 'busy';
192
+ readonly message: string;
193
+ readonly actions?: readonly SurfaceAction[];
194
+ };
195
+ //# sourceMappingURL=interaction-surface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interaction-surface.d.ts","sourceRoot":"","sources":["../../../src/types/interaction-surface.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GACtB,MAAM,GACN;IACE;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC;CACtC,CAAC;AAEN;;;;GAIG;AACH,MAAM,MAAM,cAAc;AACxB,yBAAyB;AACvB;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;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AI,MAAM,CAAC;IACpB,mCAAmC;IACnC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,6EAA6E;IAC7E,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9B,kFAAkF;IAClF,OAAO,IAAI,SAAS,aAAa,EAAE,CAAC;IACpC;;;;OAIG;IACH,OAAO,IAAI,OAAO,CAAC;CACpB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAIpB;IACE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,CAAC;IAC3C,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC;CAC1B,GACD;IACE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC;IAC1B,QAAQ,CAAC,KAAK,EACV,UAAU,GACV,YAAY,GACZ,gBAAgB,GAChB,UAAU,GACV,cAAc,GACd,OAAO,GAGP,MAAM,CAAC;IACX,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;CAC7C,CAAC"}
@@ -230,6 +230,12 @@ export interface CompactionProjection {
230
230
  *
231
231
  * The system preamble is carried across unchanged: compaction removes messages,
232
232
  * never the system prompt or the tool definitions.
233
+ *
234
+ * Besides the summary allowance, the summary carries the covered range's own user
235
+ * messages word for word (GENC-1660, C2), so those are priced too: a range that
236
+ * is mostly the user's own pastes reclaims far less than its size suggests. An
237
+ * earlier summary's kept messages are not carried forward (they fold into the new
238
+ * paraphrase), so they are reclaimed with the rest of the range.
233
239
  */
234
240
  export declare function projectCompaction(history: readonly ChatMessage[], cut: number, summaryTokens?: number, preambleTokens?: number): CompactionProjection;
235
241
  //# sourceMappingURL=context-tokens.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-tokens.d.ts","sourceRoot":"","sources":["../../../src/utils/context-tokens.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D;;;;;;;;;;GAUG;AAEH;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAC;AA6CxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,MAAM,CAiBT;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,OAAQ,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,WAAW,GAAG,OAAO,CAKvD;AA6SD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,GAAG,OAAO,CAE5E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,SAAS,WAAW,EAAE,EAC/B,cAAc,CAAC,EAAE,MAAM,GACtB,MAAM,EAAE,CAEV;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,SAAS,WAAW,EAAE,EAC/B,cAAc,CAAC,EAAE,MAAM,GACtB,MAAM,CAER;AAED;;;;;;;;;;;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ACX,aAAa,GAAE,MAA0C,EACzD,cAAc,CAAC,EAAE,MAAM,GACtB,oBAAoB,CAsBtB"}
@@ -39,7 +39,20 @@ export interface SendMessageOptions {
39
39
  * {@link DEFAULT_DELEGATE_FRAMING}. Ignored unless `delegate` is set.
40
40
  */
41
41
  delegateFraming?: string;
42
+ /**
43
+ * What producing the message cost outside the working agent's own model calls — e.g. the model
44
+ * calls the decorator made to write it — booked on the stored message as `externalCostUsd`, so it
45
+ * reaches the session total. Ignored unless `delegate` is set and it is a positive, finite number.
46
+ */
47
+ externalCostUsd?: number;
42
48
  }
49
+ /**
50
+ * The fields a delegated `user` message is stored with, from the options it was sent with: who sent
51
+ * it, the framing the model reads, and what writing it cost. Empty for the person's own message.
52
+ *
53
+ * @internal
54
+ */
55
+ export declare function delegatedFields(options: SendMessageOptions | undefined): Pick<ChatMessage, 'delegate' | 'delegateFraming' | 'externalCostUsd'>;
43
56
  /**
44
57
  * A delegated `user` message's content as the model reads it: its framing in brackets, then the
45
58
  * text. The one place this string is built, so the first model call (which takes the message as
@@ -1 +1 @@
1
- {"version":3,"file":"delegated-message.d.ts","sourceRoot":"","sources":["../../../src/utils/delegated-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAElE;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,WAAW,KAAG,OAAO,IAAI,gBAC1C,CAAC;AAErB;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,+BAA+B,CAAC;AAErE;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAE1F"}
1
+ {"version":3,"file":"delegated-message.d.ts","sourceRoot":"","sources":["../../../src/utils/delegated-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAElE;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,WAAW,KAAG,OAAO,IAAI,gBAC1C,CAAC;AAErB;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,+BAA+B,CAAC;AAErE;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,kBAAkB,GAAG,SAAS,GACtC,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,iBAAiB,GAAG,iBAAiB,CAAC,CAUvE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAE1F"}
@@ -1 +1 @@
1
- {"version":3,"file":"history-transform.d.ts","sourceRoot":"","sources":["../../../src/utils/history-transform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAEL,KAAK,oBAAoB,EAI1B,MAAM,kBAAkB,CAAC;AAqC1B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,wBAAwB,CAA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,EAAE,EAC/B,OAAO,GAAE,qBAA0B,GAClC,oBAAoB,GAAG,IAAI,CAc7B;AA4CD;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,SAAS,WAAW,EAAE,GAAG;IAC/E,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB,CAkBA;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,GAAG,WAAW,EAAE,CAuBnF;AAED,oEAAoE;AACpE,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM,CAG7D"}
@@ -0,0 +1,21 @@
1
+ import type { ChatMessage } from '@genesislcap/foundation-ai';
2
+ /** One user message a compaction keeps word for word. */
3
+ export type PreservedUserMessage = NonNullable<NonNullable<ChatMessage['compaction']>['preservedUserMessages']>[number];
4
+ /**
5
+ * The user messages a compaction of `toCompact` keeps word for word (GENC-1660, critique C2): the
6
+ * range's own, oldest first, delegated ones still marked as such.
7
+ *
8
+ * Only the range's own. An earlier summary in the range is not carried forward: the summariser
9
+ * reads it with its own kept messages, and folds them into the new paraphrase. So the kept block
10
+ * never grows past one compaction's worth, at the cost of steering from before the previous
11
+ * compaction surviving only as paraphrase.
12
+ */
13
+ export declare function freshUserMessages(toCompact: readonly ChatMessage[]): PreservedUserMessage[];
14
+ /** One kept message as the model reads it: as the user, framed when it was sent on their behalf. */
15
+ export declare const preservedUserLine: (u: PreservedUserMessage) => string;
16
+ /**
17
+ * The kept user messages as the block that follows a summary on the wire, or `''` when there are
18
+ * none. The one place it is built, so what is sent and what the context estimate counts agree.
19
+ */
20
+ export declare function verbatimUserMessagesBlock(preserved: readonly PreservedUserMessage[] | undefined): string;
21
+ //# sourceMappingURL=preserved-user-messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preserved-user-messages.d.ts","sourceRoot":"","sources":["../../../src/utils/preserved-user-messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAG9D,yDAAyD;AACzD,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAC5C,WAAW,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAChE,CAAC,MAAM,CAAC,CAAC;AAEV;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,SAAS,WAAW,EAAE,GAAG,oBAAoB,EAAE,CAY3F;AAED,oGAAoG;AACpG,eAAO,MAAM,iBAAiB,GAAI,GAAG,oBAAoB,KAAG,MAC6B,CAAC;AAE1F;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,SAAS,oBAAoB,EAAE,GAAG,SAAS,GACrD,MAAM,CAGR"}