omp-antigravity-acp-provider 0.1.37 → 0.1.39

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.
package/AGENT_INSTALL.md CHANGED
@@ -18,5 +18,9 @@ Steps:
18
18
  5. Run `omp models antigravity-acp --json`. Cached listing must not start the ACP server. An empty catalog before sign-in is acceptable; report it instead of retrying in a loop.
19
19
  6. Tell the user to restart OMP, then run `/login` → "Google Antigravity (ACP)" and `/antigravity-acp refresh` inside OMP. Do not perform these steps yourself.
20
20
 
21
+ Notes:
22
+ - The adapter auto-selects the newer of the `agy` CLI's bundled server and its managed registry runtime; no channel configuration is required. An explicit `AGY_ACP_BIN` environment variable overrides the choice — do not set it unless the user asks.
23
+ - ACP sessions are stored under `~/.gemini/antigravity-acp/`. The user's personal `agy` CLI chats under `~/.gemini/antigravity-cli/` are never read or deleted by the adapter.
24
+
21
25
  Acceptance: one adapter installed, `omp models antigravity-acp --json` returns valid JSON, and no credential material appears in any output. Report the commands run, the adapter version, any model IDs and the first step that failed.
22
26
  ```
package/README.md CHANGED
@@ -97,6 +97,23 @@ This shows the runtime, native-tool mode and usage state. Send a short prompt to
97
97
 
98
98
  The installation runbook is in [AGENT_INSTALL.md](AGENT_INSTALL.md). Hand that file to an agent with terminal access; it installs and verifies the adapter without starting an interactive login. For example: `Read AGENT_INSTALL.md and follow it.`
99
99
 
100
+ ## ACP server channels and selection
101
+
102
+ Google ships the same ACP server through two channels; the adapter picks between them automatically at every OMP startup.
103
+
104
+ - **`agy` CLI** — the self-updating command-line product. When its bundled server is newer than the registry runtime, the adapter launches it through a generated `AGY_ACP_BIN` wrapper, so CLI-first models (for example Claude and GPT-OSS) appear without manual setup.
105
+ - **Managed runtime** — the registry-signed release downloaded and verified into `~/.local/opt/agy-acp/`. Used when the CLI is missing or not newer, and installed automatically when neither channel exists.
106
+
107
+ Selection order:
108
+
109
+ 1. An explicit `AGY_ACP_BIN` always wins. Point it at an `agy acp`-capable executable or wrapper to force a channel.
110
+ 2. Otherwise the newer server version wins; ties go to the managed runtime.
111
+ 3. With neither present, the managed runtime is downloaded from Google's registry on next use.
112
+
113
+ Session storage follows the server's own `--app_data_dir`. The generated wrapper pins `antigravity-acp` — the managed runtime's own default — so CLI-launched ACP sessions land in `~/.gemini/antigravity-acp/`, where `/antigravity-acp cleanup` and session ownership tracking operate. Personal `agy` CLI chats stay in `~/.gemini/antigravity-cli/` and are never read or deleted by the adapter. `GEMINI_HOME` relocates the managed runtime's tree (upstream behavior); the `agy` CLI stores under `~/.gemini` regardless.
114
+
115
+ The active channel and its versions are recorded in `~/.omp/agent/antigravity-acp-provider/acp-runtime-source.json` whenever the CLI is chosen.
116
+
100
117
  ## Commands
101
118
 
102
119
  | Command | Purpose |
@@ -102,7 +102,10 @@ function compareVersions(left: string, right: string): number {
102
102
  }
103
103
 
104
104
  function writeCliWrapper(file: string, agyPath: string): void {
105
- const script = `#!/bin/sh\nexec '${agyPath.replace(/'/g, "'\\''")}' acp "$@"\n`;
105
+ // --app_data_dir=antigravity-acp is the managed .par's own default: the CLI
106
+ // binary would otherwise default to antigravity-cli, mixing ACP sessions
107
+ // with personal CLI chats outside session cleanup's tracked tree.
108
+ const script = `#!/bin/sh\nexec '${agyPath.replace(/'/g, "'\\''")}' acp --app_data_dir=antigravity-acp "$@"\n`;
106
109
  try {
107
110
  if (fs.readFileSync(file, "utf8") === script) return;
108
111
  } catch {
@@ -48,6 +48,14 @@ interface RecordItem {
48
48
  record: HistoryRecord;
49
49
  }
50
50
 
51
+ interface HistoryMetrics {
52
+ jsonBytePrefix: number[];
53
+ imageTextBytePrefix: number[];
54
+ originalDigitBytePrefix: number[];
55
+ attachmentCountPrefix: number[];
56
+ localDigitBytePrefix: number[];
57
+ }
58
+
51
59
  // The official harness applies a 64,000-token per-step conversion limit,
52
60
  // independently of the model window. Its overflow path keeps only the first
53
61
  // 192,000 UTF-8 bytes. Reserve room for USER_REQUEST/time metadata added by ACP;
@@ -215,6 +223,104 @@ function assembleStep(
215
223
  return step;
216
224
  }
217
225
 
226
+ function prepareHistoryMetrics(items: readonly RecordItem[]): HistoryMetrics {
227
+ const jsonBytePrefix = [0];
228
+ const imageTextBytePrefix = [0];
229
+ const originalDigitBytePrefix = [0];
230
+ const attachmentCountPrefix = [0];
231
+ const localDigitBytePrefix = [0];
232
+ let attachmentCount = 0;
233
+ for (const item of items) {
234
+ let originalDigits = 0;
235
+ if (item.images.length && Array.isArray(item.record.content)) {
236
+ for (const attachment of item.imageAttachments) {
237
+ originalDigits += String(attachment).length;
238
+ localDigitBytePrefix.push(localDigitBytePrefix.at(-1)! + String(attachmentCount).length);
239
+ attachmentCount++;
240
+ }
241
+ }
242
+ jsonBytePrefix.push(jsonBytePrefix.at(-1)! + Buffer.byteLength(item.json, "utf8"));
243
+ imageTextBytePrefix.push(imageTextBytePrefix.at(-1)! + promptTextBytes(item.images));
244
+ originalDigitBytePrefix.push(originalDigitBytePrefix.at(-1)! + originalDigits);
245
+ attachmentCountPrefix.push(attachmentCount);
246
+ }
247
+ return { jsonBytePrefix, imageTextBytePrefix, originalDigitBytePrefix, attachmentCountPrefix, localDigitBytePrefix };
248
+ }
249
+
250
+ function historyRangeTextBytes(metrics: HistoryMetrics, start: number, end: number): number {
251
+ if (start === end) return 0;
252
+ const attachmentStart = metrics.attachmentCountPrefix[start]!;
253
+ const attachmentEnd = metrics.attachmentCountPrefix[end]!;
254
+ return HISTORY_ENVELOPE_BYTES
255
+ + metrics.jsonBytePrefix[end]! - metrics.jsonBytePrefix[start]!
256
+ + end - start - 1
257
+ + metrics.imageTextBytePrefix[end]! - metrics.imageTextBytePrefix[start]!
258
+ + metrics.localDigitBytePrefix[attachmentEnd - attachmentStart]!
259
+ - (metrics.originalDigitBytePrefix[end]! - metrics.originalDigitBytePrefix[start]!);
260
+ }
261
+
262
+ function planHistorySteps(
263
+ instructionsBlock: TransferBlock | undefined,
264
+ items: readonly RecordItem[],
265
+ tailBlocks: TransferBlock[],
266
+ ): { prompt: TransferBlock[]; seedSteps: TransferBlock[][] } {
267
+ const metrics = prepareHistoryMetrics(items);
268
+ const instructionBytes = instructionsBlock ? promptTextBytes([instructionsBlock]) : 0;
269
+ const seedTail: TransferBlock[] = [{ type: "text", text: SEED_ACK_TEXT }];
270
+ const seedTailBytes = promptTextBytes(seedTail);
271
+ const spans: { start: number; end: number }[] = [];
272
+ let seedInstructions = instructionsBlock;
273
+ let pendingInstructions = instructionsBlock;
274
+ let finalInstructions: TransferBlock | undefined;
275
+ if (instructionBytes + seedTailBytes > ACP_STEP_TEXT_BYTES) {
276
+ finalInstructions = pendingInstructions;
277
+ seedInstructions = undefined;
278
+ pendingInstructions = undefined;
279
+ }
280
+ let cursor = 0;
281
+ while (cursor < items.length || pendingInstructions) {
282
+ const remainingInstructions = finalInstructions ?? pendingInstructions;
283
+ const remaining = assembleStep(remainingInstructions, items.slice(cursor), tailBlocks);
284
+ if (promptTextBytes(remaining) <= ACP_STEP_TEXT_BYTES) break;
285
+ const start = cursor;
286
+ const chunkInstructions = pendingInstructions;
287
+ const chunkInstructionBytes = chunkInstructions ? instructionBytes : 0;
288
+ while (cursor < items.length) {
289
+ const predicted = chunkInstructionBytes
290
+ + historyRangeTextBytes(metrics, start, cursor + 1) + seedTailBytes;
291
+ if (predicted <= ACP_STEP_TEXT_BYTES) {
292
+ cursor++;
293
+ continue;
294
+ }
295
+ const rejected = assembleStep(chunkInstructions, items.slice(start, cursor + 1), seedTail);
296
+ const actual = promptTextBytes(rejected);
297
+ if (actual !== predicted || actual <= ACP_STEP_TEXT_BYTES) {
298
+ throw new Error(`History chunk planner predicted ${predicted} bytes for a rejected candidate but rendered ${actual}`);
299
+ }
300
+ break;
301
+ }
302
+ if (!chunkInstructions && cursor === start) {
303
+ checkStepTextBytes(promptTextBytes(assembleStep(undefined, [items[start]!], seedTail)));
304
+ throw new Error("History chunk planner made no progress");
305
+ }
306
+ spans.push({ start, end: cursor });
307
+ pendingInstructions = undefined;
308
+ }
309
+ const seedSteps = spans.map((span, index) => {
310
+ const stepInstructions = index === 0 ? seedInstructions : undefined;
311
+ const predicted = (stepInstructions ? instructionBytes : 0)
312
+ + historyRangeTextBytes(metrics, span.start, span.end) + seedTailBytes;
313
+ const step = assembleStep(stepInstructions, items.slice(span.start, span.end), seedTail);
314
+ const actual = promptTextBytes(step);
315
+ if (actual !== predicted) throw new Error(`History chunk planner predicted ${predicted} bytes but rendered ${actual}`);
316
+ checkStepTextBytes(actual);
317
+ return step;
318
+ });
319
+ const prompt = assembleStep(finalInstructions ?? pendingInstructions, items.slice(cursor), tailBlocks);
320
+ checkStepTextBytes(promptTextBytes(prompt));
321
+ return { prompt, seedSteps };
322
+ }
323
+
218
324
  interface RequestSplit {
219
325
  seedSteps: TransferBlock[][];
220
326
  tailBlocks: TransferBlock[];
@@ -328,9 +434,22 @@ function historyRecordItems(
328
434
  images: TransferBlock[],
329
435
  imageAttachments: number[],
330
436
  ): RecordItem[] {
331
- const make = (candidate: HistoryRecord): RecordItem => ({
332
- json: serializeRecord(candidate), images, imageAttachments, record: candidate,
333
- });
437
+ const make = (candidate: HistoryRecord, itemImages: TransferBlock[] = images,
438
+ attachments: number[] = imageAttachments, json?: string): RecordItem => {
439
+ const referenced = new Set<number>();
440
+ let referenceCount = 0;
441
+ if (Array.isArray(candidate.content)) for (const block of candidate.content) {
442
+ if (block.type === "image" && typeof block.attachment === "number") {
443
+ referenceCount++;
444
+ referenced.add(block.attachment);
445
+ }
446
+ }
447
+ if (itemImages.length !== attachments.length * 2 || referenceCount !== attachments.length || referenced.size !== attachments.length ||
448
+ attachments.some(attachment => !Number.isSafeInteger(attachment) || attachment < 0 || !referenced.has(attachment))) {
449
+ throw new Error("Historical image attachments do not match their content or data");
450
+ }
451
+ return { json: json ?? serializeRecord(candidate), images: itemImages, imageAttachments: attachments, record: candidate };
452
+ };
334
453
  try {
335
454
  return [make(record)];
336
455
  } catch (error) {
@@ -360,7 +479,7 @@ function historyRecordItems(
360
479
  chunk = takeTextChunk(rest, limit);
361
480
  }
362
481
  }
363
- chunks.push({ json, images: [], imageAttachments: [], record: candidate });
482
+ chunks.push(make(candidate, [], [], json));
364
483
  rest = rest.slice(chunk.length);
365
484
  }
366
485
  return chunks;
@@ -422,12 +541,7 @@ function historyRecordItems(
422
541
  partAttachments.push(block.attachment);
423
542
  }
424
543
  const candidate = { ...record, content: part };
425
- chunks.push({
426
- json: serializeRecord(candidate),
427
- images: partImages,
428
- imageAttachments: partAttachments,
429
- record: candidate,
430
- });
544
+ chunks.push(make(candidate, partImages, partAttachments));
431
545
  }
432
546
  return chunks;
433
547
  }
@@ -539,41 +653,9 @@ export function buildPromptParts(context: TransferContext, fresh: boolean, unsee
539
653
  let prompt = assembleStep(instructionsBlock, recordItems, tailBlocks);
540
654
  const historySeedSteps: TransferBlock[][] = [];
541
655
  if (promptTextBytes(prompt) > ACP_STEP_TEXT_BYTES) {
542
- const seedTail: TransferBlock[] = [{ type: "text", text: SEED_ACK_TEXT }];
543
- let pendingInstructions = instructionsBlock;
544
- let finalInstructions: TransferBlock | undefined;
545
- if (pendingInstructions && promptTextBytes(assembleStep(pendingInstructions, [], seedTail)) > ACP_STEP_TEXT_BYTES) {
546
- // Instructions that cannot fit beside a seed acknowledgement stay in
547
- // the final prompt; history seed steps can still be sent without them.
548
- finalInstructions = pendingInstructions;
549
- pendingInstructions = undefined;
550
- }
551
- let cursor = 0;
552
- while (cursor < recordItems.length || pendingInstructions) {
553
- const remainingInstructions = finalInstructions ?? pendingInstructions;
554
- const remaining = assembleStep(remainingInstructions, recordItems.slice(cursor), tailBlocks);
555
- if (promptTextBytes(remaining) <= ACP_STEP_TEXT_BYTES) break;
556
- const chunkItems: RecordItem[] = [];
557
- const chunkInst = pendingInstructions;
558
- while (cursor < recordItems.length) {
559
- const candidate = assembleStep(chunkInst, [...chunkItems, recordItems[cursor]!], seedTail);
560
- if (promptTextBytes(candidate) <= ACP_STEP_TEXT_BYTES) {
561
- chunkItems.push(recordItems[cursor]!);
562
- cursor++;
563
- } else {
564
- break;
565
- }
566
- }
567
- if (!chunkInst && chunkItems.length === 0) {
568
- checkStepTextBytes(promptTextBytes(assembleStep(undefined, [recordItems[cursor]!], seedTail)));
569
- }
570
- const seedStep = assembleStep(chunkInst, chunkItems, seedTail);
571
- checkStepTextBytes(promptTextBytes(seedStep));
572
- historySeedSteps.push(seedStep);
573
- pendingInstructions = undefined;
574
- }
575
- prompt = assembleStep(finalInstructions ?? pendingInstructions, recordItems.slice(cursor), tailBlocks);
576
- checkStepTextBytes(promptTextBytes(prompt));
656
+ const planned = planHistorySteps(instructionsBlock, recordItems, tailBlocks);
657
+ prompt = planned.prompt;
658
+ historySeedSteps.push(...planned.seedSteps);
577
659
  }
578
660
  const seedSteps = historySeedSteps.length || requestSeedSteps.length
579
661
  ? [...historySeedSteps, ...requestSeedSteps]
@@ -60054,6 +60054,90 @@ function assembleStep(instructionsBlock, items, tailBlocks) {
60054
60054
  for (const block of tailBlocks) step.push(block);
60055
60055
  return step;
60056
60056
  }
60057
+ function prepareHistoryMetrics(items) {
60058
+ const jsonBytePrefix = [0];
60059
+ const imageTextBytePrefix = [0];
60060
+ const originalDigitBytePrefix = [0];
60061
+ const attachmentCountPrefix = [0];
60062
+ const localDigitBytePrefix = [0];
60063
+ let attachmentCount = 0;
60064
+ for (const item of items) {
60065
+ let originalDigits = 0;
60066
+ if (item.images.length && Array.isArray(item.record.content)) {
60067
+ for (const attachment of item.imageAttachments) {
60068
+ originalDigits += String(attachment).length;
60069
+ localDigitBytePrefix.push(localDigitBytePrefix.at(-1) + String(attachmentCount).length);
60070
+ attachmentCount++;
60071
+ }
60072
+ }
60073
+ jsonBytePrefix.push(jsonBytePrefix.at(-1) + Buffer.byteLength(item.json, "utf8"));
60074
+ imageTextBytePrefix.push(imageTextBytePrefix.at(-1) + promptTextBytes(item.images));
60075
+ originalDigitBytePrefix.push(originalDigitBytePrefix.at(-1) + originalDigits);
60076
+ attachmentCountPrefix.push(attachmentCount);
60077
+ }
60078
+ return { jsonBytePrefix, imageTextBytePrefix, originalDigitBytePrefix, attachmentCountPrefix, localDigitBytePrefix };
60079
+ }
60080
+ function historyRangeTextBytes(metrics, start, end) {
60081
+ if (start === end) return 0;
60082
+ const attachmentStart = metrics.attachmentCountPrefix[start];
60083
+ const attachmentEnd = metrics.attachmentCountPrefix[end];
60084
+ return HISTORY_ENVELOPE_BYTES + metrics.jsonBytePrefix[end] - metrics.jsonBytePrefix[start] + end - start - 1 + metrics.imageTextBytePrefix[end] - metrics.imageTextBytePrefix[start] + metrics.localDigitBytePrefix[attachmentEnd - attachmentStart] - (metrics.originalDigitBytePrefix[end] - metrics.originalDigitBytePrefix[start]);
60085
+ }
60086
+ function planHistorySteps(instructionsBlock, items, tailBlocks) {
60087
+ const metrics = prepareHistoryMetrics(items);
60088
+ const instructionBytes = instructionsBlock ? promptTextBytes([instructionsBlock]) : 0;
60089
+ const seedTail = [{ type: "text", text: SEED_ACK_TEXT }];
60090
+ const seedTailBytes = promptTextBytes(seedTail);
60091
+ const spans = [];
60092
+ let seedInstructions = instructionsBlock;
60093
+ let pendingInstructions = instructionsBlock;
60094
+ let finalInstructions;
60095
+ if (instructionBytes + seedTailBytes > ACP_STEP_TEXT_BYTES) {
60096
+ finalInstructions = pendingInstructions;
60097
+ seedInstructions = void 0;
60098
+ pendingInstructions = void 0;
60099
+ }
60100
+ let cursor = 0;
60101
+ while (cursor < items.length || pendingInstructions) {
60102
+ const remainingInstructions = finalInstructions ?? pendingInstructions;
60103
+ const remaining = assembleStep(remainingInstructions, items.slice(cursor), tailBlocks);
60104
+ if (promptTextBytes(remaining) <= ACP_STEP_TEXT_BYTES) break;
60105
+ const start = cursor;
60106
+ const chunkInstructions = pendingInstructions;
60107
+ const chunkInstructionBytes = chunkInstructions ? instructionBytes : 0;
60108
+ while (cursor < items.length) {
60109
+ const predicted = chunkInstructionBytes + historyRangeTextBytes(metrics, start, cursor + 1) + seedTailBytes;
60110
+ if (predicted <= ACP_STEP_TEXT_BYTES) {
60111
+ cursor++;
60112
+ continue;
60113
+ }
60114
+ const rejected = assembleStep(chunkInstructions, items.slice(start, cursor + 1), seedTail);
60115
+ const actual = promptTextBytes(rejected);
60116
+ if (actual !== predicted || actual <= ACP_STEP_TEXT_BYTES) {
60117
+ throw new Error(`History chunk planner predicted ${predicted} bytes for a rejected candidate but rendered ${actual}`);
60118
+ }
60119
+ break;
60120
+ }
60121
+ if (!chunkInstructions && cursor === start) {
60122
+ checkStepTextBytes(promptTextBytes(assembleStep(void 0, [items[start]], seedTail)));
60123
+ throw new Error("History chunk planner made no progress");
60124
+ }
60125
+ spans.push({ start, end: cursor });
60126
+ pendingInstructions = void 0;
60127
+ }
60128
+ const seedSteps = spans.map((span, index) => {
60129
+ const stepInstructions = index === 0 ? seedInstructions : void 0;
60130
+ const predicted = (stepInstructions ? instructionBytes : 0) + historyRangeTextBytes(metrics, span.start, span.end) + seedTailBytes;
60131
+ const step = assembleStep(stepInstructions, items.slice(span.start, span.end), seedTail);
60132
+ const actual = promptTextBytes(step);
60133
+ if (actual !== predicted) throw new Error(`History chunk planner predicted ${predicted} bytes but rendered ${actual}`);
60134
+ checkStepTextBytes(actual);
60135
+ return step;
60136
+ });
60137
+ const prompt = assembleStep(finalInstructions ?? pendingInstructions, items.slice(cursor), tailBlocks);
60138
+ checkStepTextBytes(promptTextBytes(prompt));
60139
+ return { prompt, seedSteps };
60140
+ }
60057
60141
  function requestFinalHeader(inProgress) {
60058
60142
  return REQUEST_FINAL_HEADER + (inProgress ? "This request is already in progress; the history includes prior assistant actions and tool results. Continue from those results rather than restarting completed work.\n\n" : "");
60059
60143
  }
@@ -60143,12 +60227,20 @@ function splitOversizedRequest(blocks, inProgress) {
60143
60227
  return { seedSteps, tailBlocks };
60144
60228
  }
60145
60229
  function historyRecordItems(record3, images, imageAttachments) {
60146
- const make = (candidate) => ({
60147
- json: serializeRecord(candidate),
60148
- images,
60149
- imageAttachments,
60150
- record: candidate
60151
- });
60230
+ const make = (candidate, itemImages = images, attachments = imageAttachments, json3) => {
60231
+ const referenced = /* @__PURE__ */ new Set();
60232
+ let referenceCount = 0;
60233
+ if (Array.isArray(candidate.content)) for (const block of candidate.content) {
60234
+ if (block.type === "image" && typeof block.attachment === "number") {
60235
+ referenceCount++;
60236
+ referenced.add(block.attachment);
60237
+ }
60238
+ }
60239
+ if (itemImages.length !== attachments.length * 2 || referenceCount !== attachments.length || referenced.size !== attachments.length || attachments.some((attachment) => !Number.isSafeInteger(attachment) || attachment < 0 || !referenced.has(attachment))) {
60240
+ throw new Error("Historical image attachments do not match their content or data");
60241
+ }
60242
+ return { json: json3 ?? serializeRecord(candidate), images: itemImages, imageAttachments: attachments, record: candidate };
60243
+ };
60152
60244
  try {
60153
60245
  return [make(record3)];
60154
60246
  } catch (error62) {
@@ -60175,7 +60267,7 @@ function historyRecordItems(record3, images, imageAttachments) {
60175
60267
  chunk = takeTextChunk(rest, limit);
60176
60268
  }
60177
60269
  }
60178
- chunks.push({ json: json3, images: [], imageAttachments: [], record: candidate });
60270
+ chunks.push(make(candidate, [], [], json3));
60179
60271
  rest = rest.slice(chunk.length);
60180
60272
  }
60181
60273
  return chunks;
@@ -60235,12 +60327,7 @@ function historyRecordItems(record3, images, imageAttachments) {
60235
60327
  partAttachments.push(block.attachment);
60236
60328
  }
60237
60329
  const candidate = { ...record3, content: part };
60238
- chunks.push({
60239
- json: serializeRecord(candidate),
60240
- images: partImages,
60241
- imageAttachments: partAttachments,
60242
- record: candidate
60243
- });
60330
+ chunks.push(make(candidate, partImages, partAttachments));
60244
60331
  }
60245
60332
  return chunks;
60246
60333
  }
@@ -60333,39 +60420,9 @@ ${instructions}` : "";
60333
60420
  let prompt = assembleStep(instructionsBlock, recordItems, tailBlocks);
60334
60421
  const historySeedSteps = [];
60335
60422
  if (promptTextBytes(prompt) > ACP_STEP_TEXT_BYTES) {
60336
- const seedTail = [{ type: "text", text: SEED_ACK_TEXT }];
60337
- let pendingInstructions = instructionsBlock;
60338
- let finalInstructions;
60339
- if (pendingInstructions && promptTextBytes(assembleStep(pendingInstructions, [], seedTail)) > ACP_STEP_TEXT_BYTES) {
60340
- finalInstructions = pendingInstructions;
60341
- pendingInstructions = void 0;
60342
- }
60343
- let cursor = 0;
60344
- while (cursor < recordItems.length || pendingInstructions) {
60345
- const remainingInstructions = finalInstructions ?? pendingInstructions;
60346
- const remaining = assembleStep(remainingInstructions, recordItems.slice(cursor), tailBlocks);
60347
- if (promptTextBytes(remaining) <= ACP_STEP_TEXT_BYTES) break;
60348
- const chunkItems = [];
60349
- const chunkInst = pendingInstructions;
60350
- while (cursor < recordItems.length) {
60351
- const candidate = assembleStep(chunkInst, [...chunkItems, recordItems[cursor]], seedTail);
60352
- if (promptTextBytes(candidate) <= ACP_STEP_TEXT_BYTES) {
60353
- chunkItems.push(recordItems[cursor]);
60354
- cursor++;
60355
- } else {
60356
- break;
60357
- }
60358
- }
60359
- if (!chunkInst && chunkItems.length === 0) {
60360
- checkStepTextBytes(promptTextBytes(assembleStep(void 0, [recordItems[cursor]], seedTail)));
60361
- }
60362
- const seedStep = assembleStep(chunkInst, chunkItems, seedTail);
60363
- checkStepTextBytes(promptTextBytes(seedStep));
60364
- historySeedSteps.push(seedStep);
60365
- pendingInstructions = void 0;
60366
- }
60367
- prompt = assembleStep(finalInstructions ?? pendingInstructions, recordItems.slice(cursor), tailBlocks);
60368
- checkStepTextBytes(promptTextBytes(prompt));
60423
+ const planned = planHistorySteps(instructionsBlock, recordItems, tailBlocks);
60424
+ prompt = planned.prompt;
60425
+ historySeedSteps.push(...planned.seedSteps);
60369
60426
  }
60370
60427
  const seedSteps = historySeedSteps.length || requestSeedSteps.length ? [...historySeedSteps, ...requestSeedSteps] : void 0;
60371
60428
  let imageBytes = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omp-antigravity-acp-provider",
3
- "version": "0.1.37",
3
+ "version": "0.1.39",
4
4
  "ompAcpBundle": 1,
5
5
  "description": "Google Antigravity ACP provider for Oh My Pi (OMP), with tool bridging and per-model thinking; derived from zacbemis/pi-antigravity-acp-provider",
6
6
  "type": "module",