omp-antigravity-acp-provider 0.1.38 → 0.1.40
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/extension/context-transfer.ts +127 -45
- package/extension/runtime.mjs +106 -47
- package/extension/tool-routing.ts +4 -1
- package/package.json +1 -1
|
@@ -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
|
|
332
|
-
|
|
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(
|
|
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
|
|
543
|
-
|
|
544
|
-
|
|
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]
|
package/extension/runtime.mjs
CHANGED
|
@@ -24340,9 +24340,11 @@ var TOOL_ROUTING = "Supplied OMP tools are exposed by the authenticated pi-bridg
|
|
|
24340
24340
|
function systemRouting(mode) {
|
|
24341
24341
|
return TOOL_ROUTING + (mode === "disabled" ? "\nAntigravity-native tools are disabled for this session. Report a missing capability instead of substituting one." : "");
|
|
24342
24342
|
}
|
|
24343
|
+
var OFFICIAL_AGENT_NAMES = /* @__PURE__ */ new Set(["antigravity-acp", "Antigravity ACP Server"]);
|
|
24343
24344
|
function supportsSessionRouting(initialize) {
|
|
24345
|
+
const name = initialize?.agentInfo?.name;
|
|
24344
24346
|
const version2 = initialize?.agentInfo?.version?.match(/^(\d+)\.(\d+)\.(\d+)$/);
|
|
24345
|
-
return
|
|
24347
|
+
return typeof name === "string" && OFFICIAL_AGENT_NAMES.has(name) && initialize.agentCapabilities?._meta?.antigravity?.systemPrompt?.append === true && !!version2 && Number(version2[1]) === 1 && (Number(version2[2]) > 4 || Number(version2[2]) === 4 && Number(version2[3]) >= 1);
|
|
24346
24348
|
}
|
|
24347
24349
|
function sessionRoutingRequest(request, initialize, mode) {
|
|
24348
24350
|
if (!supportsSessionRouting(initialize)) {
|
|
@@ -60054,6 +60056,90 @@ function assembleStep(instructionsBlock, items, tailBlocks) {
|
|
|
60054
60056
|
for (const block of tailBlocks) step.push(block);
|
|
60055
60057
|
return step;
|
|
60056
60058
|
}
|
|
60059
|
+
function prepareHistoryMetrics(items) {
|
|
60060
|
+
const jsonBytePrefix = [0];
|
|
60061
|
+
const imageTextBytePrefix = [0];
|
|
60062
|
+
const originalDigitBytePrefix = [0];
|
|
60063
|
+
const attachmentCountPrefix = [0];
|
|
60064
|
+
const localDigitBytePrefix = [0];
|
|
60065
|
+
let attachmentCount = 0;
|
|
60066
|
+
for (const item of items) {
|
|
60067
|
+
let originalDigits = 0;
|
|
60068
|
+
if (item.images.length && Array.isArray(item.record.content)) {
|
|
60069
|
+
for (const attachment of item.imageAttachments) {
|
|
60070
|
+
originalDigits += String(attachment).length;
|
|
60071
|
+
localDigitBytePrefix.push(localDigitBytePrefix.at(-1) + String(attachmentCount).length);
|
|
60072
|
+
attachmentCount++;
|
|
60073
|
+
}
|
|
60074
|
+
}
|
|
60075
|
+
jsonBytePrefix.push(jsonBytePrefix.at(-1) + Buffer.byteLength(item.json, "utf8"));
|
|
60076
|
+
imageTextBytePrefix.push(imageTextBytePrefix.at(-1) + promptTextBytes(item.images));
|
|
60077
|
+
originalDigitBytePrefix.push(originalDigitBytePrefix.at(-1) + originalDigits);
|
|
60078
|
+
attachmentCountPrefix.push(attachmentCount);
|
|
60079
|
+
}
|
|
60080
|
+
return { jsonBytePrefix, imageTextBytePrefix, originalDigitBytePrefix, attachmentCountPrefix, localDigitBytePrefix };
|
|
60081
|
+
}
|
|
60082
|
+
function historyRangeTextBytes(metrics, start, end) {
|
|
60083
|
+
if (start === end) return 0;
|
|
60084
|
+
const attachmentStart = metrics.attachmentCountPrefix[start];
|
|
60085
|
+
const attachmentEnd = metrics.attachmentCountPrefix[end];
|
|
60086
|
+
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]);
|
|
60087
|
+
}
|
|
60088
|
+
function planHistorySteps(instructionsBlock, items, tailBlocks) {
|
|
60089
|
+
const metrics = prepareHistoryMetrics(items);
|
|
60090
|
+
const instructionBytes = instructionsBlock ? promptTextBytes([instructionsBlock]) : 0;
|
|
60091
|
+
const seedTail = [{ type: "text", text: SEED_ACK_TEXT }];
|
|
60092
|
+
const seedTailBytes = promptTextBytes(seedTail);
|
|
60093
|
+
const spans = [];
|
|
60094
|
+
let seedInstructions = instructionsBlock;
|
|
60095
|
+
let pendingInstructions = instructionsBlock;
|
|
60096
|
+
let finalInstructions;
|
|
60097
|
+
if (instructionBytes + seedTailBytes > ACP_STEP_TEXT_BYTES) {
|
|
60098
|
+
finalInstructions = pendingInstructions;
|
|
60099
|
+
seedInstructions = void 0;
|
|
60100
|
+
pendingInstructions = void 0;
|
|
60101
|
+
}
|
|
60102
|
+
let cursor = 0;
|
|
60103
|
+
while (cursor < items.length || pendingInstructions) {
|
|
60104
|
+
const remainingInstructions = finalInstructions ?? pendingInstructions;
|
|
60105
|
+
const remaining = assembleStep(remainingInstructions, items.slice(cursor), tailBlocks);
|
|
60106
|
+
if (promptTextBytes(remaining) <= ACP_STEP_TEXT_BYTES) break;
|
|
60107
|
+
const start = cursor;
|
|
60108
|
+
const chunkInstructions = pendingInstructions;
|
|
60109
|
+
const chunkInstructionBytes = chunkInstructions ? instructionBytes : 0;
|
|
60110
|
+
while (cursor < items.length) {
|
|
60111
|
+
const predicted = chunkInstructionBytes + historyRangeTextBytes(metrics, start, cursor + 1) + seedTailBytes;
|
|
60112
|
+
if (predicted <= ACP_STEP_TEXT_BYTES) {
|
|
60113
|
+
cursor++;
|
|
60114
|
+
continue;
|
|
60115
|
+
}
|
|
60116
|
+
const rejected = assembleStep(chunkInstructions, items.slice(start, cursor + 1), seedTail);
|
|
60117
|
+
const actual = promptTextBytes(rejected);
|
|
60118
|
+
if (actual !== predicted || actual <= ACP_STEP_TEXT_BYTES) {
|
|
60119
|
+
throw new Error(`History chunk planner predicted ${predicted} bytes for a rejected candidate but rendered ${actual}`);
|
|
60120
|
+
}
|
|
60121
|
+
break;
|
|
60122
|
+
}
|
|
60123
|
+
if (!chunkInstructions && cursor === start) {
|
|
60124
|
+
checkStepTextBytes(promptTextBytes(assembleStep(void 0, [items[start]], seedTail)));
|
|
60125
|
+
throw new Error("History chunk planner made no progress");
|
|
60126
|
+
}
|
|
60127
|
+
spans.push({ start, end: cursor });
|
|
60128
|
+
pendingInstructions = void 0;
|
|
60129
|
+
}
|
|
60130
|
+
const seedSteps = spans.map((span, index) => {
|
|
60131
|
+
const stepInstructions = index === 0 ? seedInstructions : void 0;
|
|
60132
|
+
const predicted = (stepInstructions ? instructionBytes : 0) + historyRangeTextBytes(metrics, span.start, span.end) + seedTailBytes;
|
|
60133
|
+
const step = assembleStep(stepInstructions, items.slice(span.start, span.end), seedTail);
|
|
60134
|
+
const actual = promptTextBytes(step);
|
|
60135
|
+
if (actual !== predicted) throw new Error(`History chunk planner predicted ${predicted} bytes but rendered ${actual}`);
|
|
60136
|
+
checkStepTextBytes(actual);
|
|
60137
|
+
return step;
|
|
60138
|
+
});
|
|
60139
|
+
const prompt = assembleStep(finalInstructions ?? pendingInstructions, items.slice(cursor), tailBlocks);
|
|
60140
|
+
checkStepTextBytes(promptTextBytes(prompt));
|
|
60141
|
+
return { prompt, seedSteps };
|
|
60142
|
+
}
|
|
60057
60143
|
function requestFinalHeader(inProgress) {
|
|
60058
60144
|
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
60145
|
}
|
|
@@ -60143,12 +60229,20 @@ function splitOversizedRequest(blocks, inProgress) {
|
|
|
60143
60229
|
return { seedSteps, tailBlocks };
|
|
60144
60230
|
}
|
|
60145
60231
|
function historyRecordItems(record3, images, imageAttachments) {
|
|
60146
|
-
const make = (candidate) =>
|
|
60147
|
-
|
|
60148
|
-
|
|
60149
|
-
|
|
60150
|
-
|
|
60151
|
-
|
|
60232
|
+
const make = (candidate, itemImages = images, attachments = imageAttachments, json3) => {
|
|
60233
|
+
const referenced = /* @__PURE__ */ new Set();
|
|
60234
|
+
let referenceCount = 0;
|
|
60235
|
+
if (Array.isArray(candidate.content)) for (const block of candidate.content) {
|
|
60236
|
+
if (block.type === "image" && typeof block.attachment === "number") {
|
|
60237
|
+
referenceCount++;
|
|
60238
|
+
referenced.add(block.attachment);
|
|
60239
|
+
}
|
|
60240
|
+
}
|
|
60241
|
+
if (itemImages.length !== attachments.length * 2 || referenceCount !== attachments.length || referenced.size !== attachments.length || attachments.some((attachment) => !Number.isSafeInteger(attachment) || attachment < 0 || !referenced.has(attachment))) {
|
|
60242
|
+
throw new Error("Historical image attachments do not match their content or data");
|
|
60243
|
+
}
|
|
60244
|
+
return { json: json3 ?? serializeRecord(candidate), images: itemImages, imageAttachments: attachments, record: candidate };
|
|
60245
|
+
};
|
|
60152
60246
|
try {
|
|
60153
60247
|
return [make(record3)];
|
|
60154
60248
|
} catch (error62) {
|
|
@@ -60175,7 +60269,7 @@ function historyRecordItems(record3, images, imageAttachments) {
|
|
|
60175
60269
|
chunk = takeTextChunk(rest, limit);
|
|
60176
60270
|
}
|
|
60177
60271
|
}
|
|
60178
|
-
chunks.push(
|
|
60272
|
+
chunks.push(make(candidate, [], [], json3));
|
|
60179
60273
|
rest = rest.slice(chunk.length);
|
|
60180
60274
|
}
|
|
60181
60275
|
return chunks;
|
|
@@ -60235,12 +60329,7 @@ function historyRecordItems(record3, images, imageAttachments) {
|
|
|
60235
60329
|
partAttachments.push(block.attachment);
|
|
60236
60330
|
}
|
|
60237
60331
|
const candidate = { ...record3, content: part };
|
|
60238
|
-
chunks.push(
|
|
60239
|
-
json: serializeRecord(candidate),
|
|
60240
|
-
images: partImages,
|
|
60241
|
-
imageAttachments: partAttachments,
|
|
60242
|
-
record: candidate
|
|
60243
|
-
});
|
|
60332
|
+
chunks.push(make(candidate, partImages, partAttachments));
|
|
60244
60333
|
}
|
|
60245
60334
|
return chunks;
|
|
60246
60335
|
}
|
|
@@ -60333,39 +60422,9 @@ ${instructions}` : "";
|
|
|
60333
60422
|
let prompt = assembleStep(instructionsBlock, recordItems, tailBlocks);
|
|
60334
60423
|
const historySeedSteps = [];
|
|
60335
60424
|
if (promptTextBytes(prompt) > ACP_STEP_TEXT_BYTES) {
|
|
60336
|
-
const
|
|
60337
|
-
|
|
60338
|
-
|
|
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));
|
|
60425
|
+
const planned = planHistorySteps(instructionsBlock, recordItems, tailBlocks);
|
|
60426
|
+
prompt = planned.prompt;
|
|
60427
|
+
historySeedSteps.push(...planned.seedSteps);
|
|
60369
60428
|
}
|
|
60370
60429
|
const seedSteps = historySeedSteps.length || requestSeedSteps.length ? [...historySeedSteps, ...requestSeedSteps] : void 0;
|
|
60371
60430
|
let imageBytes = 0;
|
|
@@ -14,6 +14,8 @@ export function parseNativeToolMode(value: unknown): NativeToolMode {
|
|
|
14
14
|
throw new Error("nativeTools must be prefer or disabled");
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
const OFFICIAL_AGENT_NAMES = new Set(["antigravity-acp", "Antigravity ACP Server"]);
|
|
18
|
+
|
|
17
19
|
export interface InitializeMetadata {
|
|
18
20
|
agentInfo?: { name?: string; version?: string };
|
|
19
21
|
agentCapabilities?: {
|
|
@@ -41,8 +43,9 @@ export interface SessionRpcRequest {
|
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
export function supportsSessionRouting(initialize: InitializeMetadata | undefined): boolean {
|
|
46
|
+
const name = initialize?.agentInfo?.name;
|
|
44
47
|
const version = initialize?.agentInfo?.version?.match(/^(\d+)\.(\d+)\.(\d+)$/);
|
|
45
|
-
return
|
|
48
|
+
return typeof name === "string" && OFFICIAL_AGENT_NAMES.has(name) &&
|
|
46
49
|
initialize.agentCapabilities?._meta?.antigravity?.systemPrompt?.append === true &&
|
|
47
50
|
!!version && Number(version[1]) === 1 &&
|
|
48
51
|
(Number(version[2]) > 4 || (Number(version[2]) === 4 && Number(version[3]) >= 1));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omp-antigravity-acp-provider",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.40",
|
|
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",
|