@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.
@@ -3091,10 +3091,11 @@ function triggerReason(trigger) {
3091
3091
  return "superseded";
3092
3092
  }
3093
3093
  }
3094
- function condenseStub(target, tool, trigger, origLen) {
3094
+ function condenseStub(target, tool, trigger, origLen, restorable) {
3095
3095
  const what = target === "args" ? "args" : "result";
3096
3096
  const key = trigger.kind === "superseded" ? ` ${trigger.by}` : "";
3097
- return `[${tool}${key} \u2014 ${what} elided, ~${origLen} chars (${triggerReason(trigger)}); re-call to restore]`;
3097
+ const restore = restorable ? "; re-call to restore" : "";
3098
+ return `[${tool}${key} \u2014 ${what} elided, ~${origLen} chars (${triggerReason(trigger)})${restore}]`;
3098
3099
  }
3099
3100
  function triggerLabel(trigger) {
3100
3101
  switch (trigger.kind) {
@@ -3151,9 +3152,14 @@ function applyCondensation(history, policies, ctx, onCondensed) {
3151
3152
  return latestByKey.get(trig.by) !== toolCallId;
3152
3153
  }
3153
3154
  };
3154
- const firstFired = (toolCallId, entry) => triggersOf(entry).find(
3155
- (t) => (marksDiscontinuity(t.kind) || withinBatch(entry)) && triggerFires(toolCallId, entry, t)
3156
- );
3155
+ const firstFired = (toolCallId, entry) => {
3156
+ if (entry.firedTrigger) return entry.firedTrigger;
3157
+ const fired = triggersOf(entry).find(
3158
+ (t) => (marksDiscontinuity(t.kind) || withinBatch(entry)) && triggerFires(toolCallId, entry, t)
3159
+ );
3160
+ if (fired) entry.firedTrigger = fired;
3161
+ return fired;
3162
+ };
3157
3163
  return history.map((msg) => {
3158
3164
  if (msg.toolCalls?.length) {
3159
3165
  let changed = false;
@@ -3166,8 +3172,8 @@ function applyCondensation(history, policies, ctx, onCondensed) {
3166
3172
  if (origLen < CONDENSE_MIN_CHARS) return tc;
3167
3173
  changed = true;
3168
3174
  const result = entry.policy.args;
3169
- const args = result === "drop" ? {} : {
3170
- [CONDENSED_ARGS_KEY]: result === "pointer" ? condenseStub("args", tc.name, fired, origLen) : result.replaceWith
3175
+ const args = {
3176
+ [CONDENSED_ARGS_KEY]: result === "drop" || result === "pointer" ? condenseStub("args", tc.name, fired, origLen, result === "pointer") : result.replaceWith
3171
3177
  };
3172
3178
  if (!entry.reportedArgs) {
3173
3179
  entry.reportedArgs = true;
@@ -3193,7 +3199,7 @@ function applyCondensation(history, policies, ctx, onCondensed) {
3193
3199
  if (entry && fired && origLen >= CONDENSE_MIN_CHARS) {
3194
3200
  const tool = nameById.get(msg.toolResult.toolCallId) ?? msg.toolResult.toolCallId;
3195
3201
  const result = entry.policy.response;
3196
- const content = result === "drop" ? "[elided]" : result === "pointer" ? condenseStub("response", tool, fired, origLen) : result.replaceWith;
3202
+ const content = result === "drop" || result === "pointer" ? condenseStub("response", tool, fired, origLen, result === "pointer") : result.replaceWith;
3197
3203
  if (!entry.reportedResponse) {
3198
3204
  entry.reportedResponse = true;
3199
3205
  onCondensed({