@genesislcap/ai-assistant 15.10.3 → 15.10.4

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.
@@ -3044,10 +3044,11 @@ function triggerReason(trigger) {
3044
3044
  return "superseded";
3045
3045
  }
3046
3046
  }
3047
- function condenseStub(target, tool, trigger, origLen) {
3047
+ function condenseStub(target, tool, trigger, origLen, restorable) {
3048
3048
  const what = target === "args" ? "args" : "result";
3049
3049
  const key = trigger.kind === "superseded" ? ` ${trigger.by}` : "";
3050
- return `[${tool}${key} \u2014 ${what} elided, ~${origLen} chars (${triggerReason(trigger)}); re-call to restore]`;
3050
+ const restore = restorable ? "; re-call to restore" : "";
3051
+ return `[${tool}${key} \u2014 ${what} elided, ~${origLen} chars (${triggerReason(trigger)})${restore}]`;
3051
3052
  }
3052
3053
  function triggerLabel(trigger) {
3053
3054
  switch (trigger.kind) {
@@ -3104,9 +3105,14 @@ function applyCondensation(history, policies, ctx, onCondensed) {
3104
3105
  return latestByKey.get(trig.by) !== toolCallId;
3105
3106
  }
3106
3107
  };
3107
- const firstFired = (toolCallId, entry) => triggersOf(entry).find(
3108
- (t) => (marksDiscontinuity(t.kind) || withinBatch(entry)) && triggerFires(toolCallId, entry, t)
3109
- );
3108
+ const firstFired = (toolCallId, entry) => {
3109
+ if (entry.firedTrigger) return entry.firedTrigger;
3110
+ const fired = triggersOf(entry).find(
3111
+ (t) => (marksDiscontinuity(t.kind) || withinBatch(entry)) && triggerFires(toolCallId, entry, t)
3112
+ );
3113
+ if (fired) entry.firedTrigger = fired;
3114
+ return fired;
3115
+ };
3110
3116
  return history.map((msg) => {
3111
3117
  if (msg.toolCalls?.length) {
3112
3118
  let changed = false;
@@ -3119,8 +3125,8 @@ function applyCondensation(history, policies, ctx, onCondensed) {
3119
3125
  if (origLen < CONDENSE_MIN_CHARS) return tc;
3120
3126
  changed = true;
3121
3127
  const result = entry.policy.args;
3122
- const args = result === "drop" ? {} : {
3123
- [CONDENSED_ARGS_KEY]: result === "pointer" ? condenseStub("args", tc.name, fired, origLen) : result.replaceWith
3128
+ const args = {
3129
+ [CONDENSED_ARGS_KEY]: result === "drop" || result === "pointer" ? condenseStub("args", tc.name, fired, origLen, result === "pointer") : result.replaceWith
3124
3130
  };
3125
3131
  if (!entry.reportedArgs) {
3126
3132
  entry.reportedArgs = true;
@@ -3146,7 +3152,7 @@ function applyCondensation(history, policies, ctx, onCondensed) {
3146
3152
  if (entry && fired && origLen >= CONDENSE_MIN_CHARS) {
3147
3153
  const tool = nameById.get(msg.toolResult.toolCallId) ?? msg.toolResult.toolCallId;
3148
3154
  const result = entry.policy.response;
3149
- const content = result === "drop" ? "[elided]" : result === "pointer" ? condenseStub("response", tool, fired, origLen) : result.replaceWith;
3155
+ const content = result === "drop" || result === "pointer" ? condenseStub("response", tool, fired, origLen, result === "pointer") : result.replaceWith;
3150
3156
  if (!entry.reportedResponse) {
3151
3157
  entry.reportedResponse = true;
3152
3158
  onCondensed({