@genesislcap/ai-assistant 15.85.0-GENC-1744.1 → 15.85.1

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.
@@ -8100,7 +8100,8 @@ export declare class OrchestratingDriver extends BaseDriverDecorator<ChatDriver>
8100
8100
  *
8101
8101
  * A failed call ends the turn there, as a Stop does: what it asked for still happens, and the
8102
8102
  * next agent runs on the next message. Running it now would meet the same wall (a budget, a
8103
- * refused account, a full context window), or build on a reply that never came.
8103
+ * refused account, a full context window), or build on a reply that never came. The one thing a
8104
+ * Stop takes back is a hand-off that has not started (see `afterAgentCall`).
8104
8105
  */
8105
8106
  private carryOn;
8106
8107
  /**
@@ -8110,6 +8111,11 @@ export declare class OrchestratingDriver extends BaseDriverDecorator<ChatDriver>
8110
8111
  *
8111
8112
  * A plain target hands back when its call ends, released or not, as a plain agent is done once
8112
8113
  * it has answered. A stateful one holds the hand-off until it releases, as it holds its flow.
8114
+ *
8115
+ * A Stop cancels a hand-off that has not started: the user stopped the turn the caller asked for
8116
+ * it in, often during the caller's closing call, so the target is not activated, and the call
8117
+ * ends as if it had never asked (a plain caller's turn ends as usual below). A hand-back is not
8118
+ * taken back: the target finished the work it was given.
8113
8119
  */
8114
8120
  private afterAgentCall;
8115
8121
  /** How the target of `frame` finished: with `completeHandOff`, or a release and its last reply. */
@@ -4473,55 +4473,6 @@ async function generateSuggestions(ctx, history, prompt2, count, allAgentInfo) {
4473
4473
  return parseSuggestions(text, count);
4474
4474
  }
4475
4475
 
4476
- // src/utils/attachment-limits.ts
4477
- var VENDOR_IMAGE_MIME_TYPES = /* @__PURE__ */ new Set([
4478
- "image/jpeg",
4479
- "image/jpg",
4480
- "image/png",
4481
- "image/gif",
4482
- "image/webp"
4483
- ]);
4484
- var MAX_IMAGE_ATTACHMENT_BYTES = 35e5;
4485
- var MAX_ATTACHMENTS_TOTAL_BYTES = 8e6;
4486
- var BASE64_DECODED_RATIO = 0.75;
4487
- function attachmentBytes(a) {
4488
- return a.kind === "image" ? Math.ceil((a.data?.length ?? 0) * BASE64_DECODED_RATIO) : a.content?.length ?? 0;
4489
- }
4490
- function attachmentRefusal(attachments) {
4491
- if (!Array.isArray(attachments)) return "attachments must be an array";
4492
- let total = 0;
4493
- for (const attachment of attachments) {
4494
- const malformed = shapeRefusal(attachment);
4495
- if (malformed) return malformed;
4496
- const a = attachment;
4497
- const bytes = attachmentBytes(a);
4498
- if (a.kind === "image" && bytes > MAX_IMAGE_ATTACHMENT_BYTES) {
4499
- return `"${a.name}" is over the ${MAX_IMAGE_ATTACHMENT_BYTES} byte image limit`;
4500
- }
4501
- total += bytes;
4502
- if (total > MAX_ATTACHMENTS_TOTAL_BYTES) {
4503
- return `"${a.name}" takes the attachments past the ${MAX_ATTACHMENTS_TOTAL_BYTES} byte limit`;
4504
- }
4505
- }
4506
- return void 0;
4507
- }
4508
- function shapeRefusal(value) {
4509
- const a = value;
4510
- if (!a || typeof a !== "object" || typeof a.name !== "string" || typeof a.mimeType !== "string") {
4511
- return "an attachment needs a name and a mimeType";
4512
- }
4513
- if (a.kind === "image") {
4514
- if (typeof a.data !== "string") return `"${a.name}" has no image data`;
4515
- if (!VENDOR_IMAGE_MIME_TYPES.has(a.mimeType.toLowerCase())) {
4516
- return `"${a.name}" is not an image type both vendors take`;
4517
- }
4518
- return void 0;
4519
- }
4520
- if (a.kind !== void 0 && a.kind !== "text") return `"${a.name}" is of an unknown kind`;
4521
- if (typeof a.content !== "string") return `"${a.name}" has no text content`;
4522
- return void 0;
4523
- }
4524
-
4525
4476
  // src/utils/condense-history.ts
4526
4477
  var CONDENSE_MIN_CHARS = 1e3;
4527
4478
  var CONDENSED_ARGS_KEY = "condensed";
@@ -8092,23 +8043,10 @@ var ChatDriver = class _ChatDriver extends EventTarget {
8092
8043
  data = jsonCopy2(request.data);
8093
8044
  if (data === void 0) return { ok: false, reason: "not-json" };
8094
8045
  }
8095
- let attachments;
8096
- if (request?.attachments !== void 0) {
8097
- const refusal = attachmentRefusal(request.attachments);
8098
- if (refusal) {
8099
- logger2.warn(
8100
- `ChatDriver(${this.activeAgentName ?? "unknown"}): handOff attachments refused \u2014 ${refusal}`
8101
- );
8102
- return { ok: false, reason: "attachment-refused" };
8103
- }
8104
- if (request.attachments.length)
8105
- attachments = jsonCopy2(request.attachments);
8106
- }
8107
8046
  const accepted = {
8108
8047
  to: request.to,
8109
8048
  message: String(request.message ?? ""),
8110
8049
  ...data !== void 0 && { data },
8111
- ...attachments && { attachments },
8112
8050
  ...request.returnTo === false && { returnTo: false }
8113
8051
  };
8114
8052
  const result = this.checkHandOff(accepted, this.activeAgentName);
@@ -10399,7 +10337,8 @@ var OrchestratingDriver = class _OrchestratingDriver extends BaseDriverDecorator
10399
10337
  *
10400
10338
  * A failed call ends the turn there, as a Stop does: what it asked for still happens, and the
10401
10339
  * next agent runs on the next message. Running it now would meet the same wall (a budget, a
10402
- * refused account, a full context window), or build on a reply that never came.
10340
+ * refused account, a full context window), or build on a reply that never came. The one thing a
10341
+ * Stop takes back is a hand-off that has not started (see `afterAgentCall`).
10403
10342
  */
10404
10343
  async carryOn(result) {
10405
10344
  let last = result;
@@ -10417,10 +10356,18 @@ var OrchestratingDriver = class _OrchestratingDriver extends BaseDriverDecorator
10417
10356
  *
10418
10357
  * A plain target hands back when its call ends, released or not, as a plain agent is done once
10419
10358
  * it has answered. A stateful one holds the hand-off until it releases, as it holds its flow.
10359
+ *
10360
+ * A Stop cancels a hand-off that has not started: the user stopped the turn the caller asked for
10361
+ * it in, often during the caller's closing call, so the target is not activated, and the call
10362
+ * ends as if it had never asked (a plain caller's turn ends as usual below). A hand-back is not
10363
+ * taken back: the target finished the work it was given.
10420
10364
  */
10421
10365
  async afterAgentCall() {
10422
10366
  const request = this.chatDriver.getHandOffRequest();
10423
- if (request) return this.startHandOff(request);
10367
+ if (request && !this.cancelled) return this.startHandOff(request);
10368
+ if (request) {
10369
+ logger2.debug(`OrchestratingDriver: stopped before the hand-off to "${request.to}" started`);
10370
+ }
10424
10371
  const active = this.agentSession.getActive();
10425
10372
  if (!active) return void 0;
10426
10373
  const frame = this.topFrameFor(active.name);
@@ -10657,12 +10604,7 @@ var OrchestratingDriver = class _OrchestratingDriver extends BaseDriverDecorator
10657
10604
  }
10658
10605
  this.applyAgent(this.agentSession.getActive() ?? target, caller.name);
10659
10606
  this.agentSession.setHandOffData(target.name, frameCopy(frame).data);
10660
- this.recordDelegated(
10661
- caller.name,
10662
- frame.message,
10663
- `Handed over by ${caller.name}`,
10664
- request.attachments
10665
- );
10607
+ this.recordDelegated(caller.name, frame.message, `Handed over by ${caller.name}`);
10666
10608
  this.dispatchEvent(new CustomEvent("handoff-started", { detail: frameCopy(frame) }));
10667
10609
  return handOffNote(caller.name);
10668
10610
  }
@@ -10714,15 +10656,13 @@ var OrchestratingDriver = class _OrchestratingDriver extends BaseDriverDecorator
10714
10656
  return void 0;
10715
10657
  }
10716
10658
  /** The brief, in the transcript as a message the caller sent on the user's behalf. */
10717
- recordDelegated(from, message, framing, attachments) {
10659
+ recordDelegated(from, message, framing) {
10718
10660
  const history = this.chatDriver.getHistory();
10719
10661
  this.chatDriver.loadHistory([
10720
10662
  ...history,
10721
10663
  {
10722
10664
  role: "user",
10723
10665
  content: message,
10724
- // The files a hand-off carries, on its brief as on any user message (GENC-1744).
10725
- ...attachments && { attachments },
10726
10666
  delegate: from,
10727
10667
  delegateFraming: framing,
10728
10668
  timestamp: (/* @__PURE__ */ new Date()).toISOString()