@genesislcap/ai-assistant 15.6.0 → 15.6.2-GENC-1475.6

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 (31) hide show
  1. package/dist/ai-assistant.api.json +30 -0
  2. package/dist/ai-assistant.d.ts +25 -13
  3. package/dist/chat-driver.cjs +6 -1
  4. package/dist/chat-driver.cjs.map +2 -2
  5. package/dist/chat-driver.mjs +6 -1
  6. package/dist/chat-driver.mjs.map +2 -2
  7. package/dist/custom-elements.json +103 -64
  8. package/dist/dts/components/settings-modal/settings-modal.styles.d.ts.map +1 -1
  9. package/dist/dts/components/settings-modal/settings-modal.template.d.ts.map +1 -1
  10. package/dist/dts/main/main.d.ts +25 -13
  11. package/dist/dts/main/main.d.ts.map +1 -1
  12. package/dist/dts/utils/banked-usage-baselines.d.ts +35 -0
  13. package/dist/dts/utils/banked-usage-baselines.d.ts.map +1 -0
  14. package/dist/dts/utils/condense-history.d.ts +4 -0
  15. package/dist/dts/utils/condense-history.d.ts.map +1 -1
  16. package/dist/esm/components/settings-modal/settings-modal.styles.js +21 -9
  17. package/dist/esm/components/settings-modal/settings-modal.template.js +15 -5
  18. package/dist/esm/main/cost-session-banking.test.js +111 -8
  19. package/dist/esm/main/main.js +68 -31
  20. package/dist/esm/utils/banked-usage-baselines.js +67 -0
  21. package/dist/esm/utils/condense-history.js +18 -3
  22. package/dist/esm/utils/condense-history.test.js +30 -0
  23. package/dist/tsconfig.tsbuildinfo +1 -1
  24. package/package.json +17 -17
  25. package/src/components/settings-modal/settings-modal.styles.ts +21 -9
  26. package/src/components/settings-modal/settings-modal.template.ts +15 -5
  27. package/src/main/cost-session-banking.test.ts +121 -11
  28. package/src/main/main.ts +68 -31
  29. package/src/utils/banked-usage-baselines.ts +73 -0
  30. package/src/utils/condense-history.test.ts +63 -0
  31. package/src/utils/condense-history.ts +26 -3
@@ -10960,6 +10960,36 @@
10960
10960
  "isProtected": false,
10961
10961
  "isAbstract": false
10962
10962
  },
10963
+ {
10964
+ "kind": "Property",
10965
+ "canonicalReference": "@genesislcap/ai-assistant!FoundationAiAssistant#settingsCostHistoryHeadingVisible:member",
10966
+ "docComment": "/**\n * Whether the \"Build history\" heading has anything under it.\n *\n * Broader than {@link FoundationAiAssistant.settingsCostHistorySectionVisible} because the heading also covers the lifetime total, which renders before the first row exists (rows are written as spend accrues, the lifetime section only needs history switched on). Gating the heading on the rows alone left that total sitting under nothing.\n */\n",
10967
+ "excerptTokens": [
10968
+ {
10969
+ "kind": "Content",
10970
+ "text": "get settingsCostHistoryHeadingVisible(): "
10971
+ },
10972
+ {
10973
+ "kind": "Content",
10974
+ "text": "boolean"
10975
+ },
10976
+ {
10977
+ "kind": "Content",
10978
+ "text": ";"
10979
+ }
10980
+ ],
10981
+ "isReadonly": true,
10982
+ "isOptional": false,
10983
+ "releaseTag": "Beta",
10984
+ "name": "settingsCostHistoryHeadingVisible",
10985
+ "propertyTypeTokenRange": {
10986
+ "startIndex": 1,
10987
+ "endIndex": 2
10988
+ },
10989
+ "isStatic": false,
10990
+ "isProtected": false,
10991
+ "isAbstract": false
10992
+ },
10963
10993
  {
10964
10994
  "kind": "Property",
10965
10995
  "canonicalReference": "@genesislcap/ai-assistant!FoundationAiAssistant#settingsCostHistorySectionVisible:member",
@@ -2331,9 +2331,9 @@ export declare class FoundationAiAssistant extends GenesisElement {
2331
2331
  title?: string;
2332
2332
  }): void;
2333
2333
  /**
2334
- * Spend for `projectKey` that predates the current transcript, resolved once per project
2335
- * and memoised (`_bankedFor`) so it cannot drift mid-session as the row it came from is
2336
- * rewritten by our own upserts.
2334
+ * Spend for `projectKey` that predates the current transcript, resolved once per SESSION and
2335
+ * shared by every element instance wired to it (see `banked-usage-baselines`), so it cannot
2336
+ * drift as the row it came from is rewritten by our own upserts.
2337
2337
  *
2338
2338
  * The two cases turn on whether the transcript is authoritative for this project:
2339
2339
  *
@@ -2343,17 +2343,24 @@ export declare class FoundationAiAssistant extends GenesisElement {
2343
2343
  * - **Transcript starts empty**: nothing on screen accounts for the previous total, so the
2344
2344
  * whole of it becomes banked. Without this the next turn would rewrite the row downwards
2345
2345
  * to just that turn, losing the project's earlier spend.
2346
+ *
2347
+ * The baseline is deliberately NOT element state. This element is remounted repeatedly inside
2348
+ * a single session (the host re-rendering its layout, popping out, docking) and a fresh
2349
+ * instance re-deriving would take the second branch against rows that already hold the live
2350
+ * transcript — banking the session as its own baseline. Keying on the session instead means a
2351
+ * remount inherits the baseline that transcript was paired with.
2346
2352
  */
2347
2353
  private bankedUsageFor;
2348
2354
  /**
2349
- * Discard the banked figure — for when the spend it stands for has been deliberately
2350
- * thrown away (the user clearing history, or deleting this project's row).
2355
+ * Re-baseline this session against an emptied transcript: everything the row holds now
2356
+ * predates what is on screen, so the whole of it becomes banked.
2351
2357
  *
2352
- * NOT for reloads. A reload re-reads rows that already include our own upserts, so
2353
- * re-deriving from them would fold the live session into its own baseline; only a genuine
2354
- * project change should re-derive, which `bankedUsageFor`'s per-project memo handles.
2358
+ * Not the same as dropping the baseline. Dropping it re-derives through `persistenceActive`,
2359
+ * and with persistence ON that carries the row's *old* banked figure forward — discarding
2360
+ * every turn between the last baseline and the clear. The transcript is gone either way, so
2361
+ * the branch that reads it as authoritative no longer applies.
2355
2362
  */
2356
- private resetBankedUsage;
2363
+ private rebaselineOnClearedTranscript;
2357
2364
  showConfirmationDialog(confirmationMessage: string, modalParent: HTMLElement, onConfirm: () => void, onCancel?: () => void): void;
2358
2365
  /** Remove one entry from persisted build history. */
2359
2366
  removeCostSessionFromHistory(id: string): void;
@@ -2459,10 +2466,6 @@ export declare class FoundationAiAssistant extends GenesisElement {
2459
2466
  * (same key) from a project switch (key already flipped) — see `syncActiveCostSessionTitle`.
2460
2467
  */
2461
2468
  private _activeCostSessionKey?;
2462
- /** Memoised pre-transcript spend for `_bankedFor` — see `bankedUsageFor`. */
2463
- private _bankedUsage;
2464
- /** Project key `_bankedUsage` was resolved for; `undefined` means "not yet resolved". */
2465
- private _bankedFor;
2466
2469
  /**
2467
2470
  * Whether the row list reflects storage yet. Gates cost writes so a project's banked
2468
2471
  * spend is never derived from a ledger that simply hasn't arrived.
@@ -2867,6 +2870,15 @@ export declare class FoundationAiAssistant extends GenesisElement {
2867
2870
  private unwireAppSettingsProvider;
2868
2871
  get settingsCostCurrentSectionVisible(): boolean;
2869
2872
  get settingsCostHistorySectionVisible(): boolean;
2873
+ /**
2874
+ * Whether the "Build history" heading has anything under it.
2875
+ *
2876
+ * Broader than {@link FoundationAiAssistant.settingsCostHistorySectionVisible} because the
2877
+ * heading also covers the lifetime total, which renders before the first row exists (rows are
2878
+ * written as spend accrues, the lifetime section only needs history switched on). Gating the
2879
+ * heading on the rows alone left that total sitting under nothing.
2880
+ */
2881
+ get settingsCostHistoryHeadingVisible(): boolean;
2870
2882
  /** Whether the built-in Usage tab summary block has anything to show. */
2871
2883
  get settingsCostSummaryVisible(): boolean;
2872
2884
  /**
@@ -2840,6 +2840,9 @@ function triggerLabel(trigger) {
2840
2840
  function estimateTokensSaved(origLen, stubLen) {
2841
2841
  return Math.max(0, Math.ceil((origLen - stubLen) / APPROX_CHARS_PER_TOKEN));
2842
2842
  }
2843
+ function marksDiscontinuity(kind) {
2844
+ return kind === "agentEnd" || kind === "phaseEnd";
2845
+ }
2843
2846
  function applyCondensation(history, policies, ctx, onCondensed) {
2844
2847
  if (policies.size === 0) return history;
2845
2848
  const triggersOf = (entry) => Array.isArray(entry.policy.on) ? entry.policy.on : [entry.policy.on];
@@ -2879,7 +2882,9 @@ function applyCondensation(history, policies, ctx, onCondensed) {
2879
2882
  return latestByKey.get(trig.by) !== toolCallId;
2880
2883
  }
2881
2884
  };
2882
- const firstFired = (toolCallId, entry) => withinBatch(entry) ? triggersOf(entry).find((t) => triggerFires(toolCallId, entry, t)) : void 0;
2885
+ const firstFired = (toolCallId, entry) => triggersOf(entry).find(
2886
+ (t) => (marksDiscontinuity(t.kind) || withinBatch(entry)) && triggerFires(toolCallId, entry, t)
2887
+ );
2883
2888
  return history.map((msg) => {
2884
2889
  if (msg.toolCalls?.length) {
2885
2890
  let changed = false;