@benjamolina/pi-antigravity-guard 0.4.10 → 0.5.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.
- package/README.md +11 -1
- package/dist/catalog.d.ts +298 -3
- package/dist/catalog.js +81 -1
- package/dist/context.d.ts +4 -1
- package/dist/context.js +136 -21
- package/dist/envelope.js +22 -0
- package/dist/project.js +2 -1
- package/dist/stream.js +2 -2
- package/dist/tool-context.js +39 -5
- package/dist/tool-schema.js +9 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Choose browser login, or choose manual login and paste the complete callback URL
|
|
|
14
14
|
|
|
15
15
|
## Text registration is not tool enablement
|
|
16
16
|
|
|
17
|
-
All
|
|
17
|
+
All twelve rows below are registered for text. The exact `antigravity-gemini-3.8-flash` `off` route is enabled for tools from recorded direct evidence; every other production route is **not enabled for tools**, so its context with a declaration, assistant tool call, or tool result fails locally before any network request. Text-only requests retain their released behavior.
|
|
18
18
|
|
|
19
19
|
| Public ID | Exposed Pi levels | Tool state | Admission |
|
|
20
20
|
|---|---|---|---|
|
|
@@ -25,6 +25,11 @@ All seven rows below are registered for text. The exact `antigravity-gemini-3.8-
|
|
|
25
25
|
| `antigravity-claude-sonnet-4.6` | off, high | Enabled (off, high) | pi-json-tool-loop/claude-sonnet-4.6-off-v1 |
|
|
26
26
|
| `antigravity-claude-opus-4.6-thinking` | off, high | Enabled (off, high) | pi-json-tool-loop/claude-opus-4.6-thinking-off-v1 |
|
|
27
27
|
| `antigravity-gpt-oss-120b` | off, medium | Enabled (off, medium) | pi-json-tool-loop/gpt-oss-120b-off-v1 |
|
|
28
|
+
| `antigravity-gemini-4-argon` | off, low, medium, high | Enabled (off, low, medium, high) | pi-json-tool-loop/gemini-4-argon-off-v1 |
|
|
29
|
+
| `antigravity-gemini-4-carbon` | off, low, medium, high | Enabled (off, low, medium, high) | pi-json-tool-loop/gemini-4-carbon-off-v1 |
|
|
30
|
+
| `antigravity-gemini-4-neon` | off, low, medium, high, xhigh | Enabled (off, low, medium, high, xhigh) | pi-json-tool-loop/gemini-4-neon-off-v1 |
|
|
31
|
+
| `antigravity-gemini-4-hydrogen` | off, low, medium, high, xhigh | Enabled (off, low, medium, high, xhigh) | pi-json-tool-loop/gemini-4-hydrogen-off-v1 |
|
|
32
|
+
| `antigravity-gemini-3.5-flash-lite` | off, low | Enabled (off, low) | pi-json-tool-loop/gemini-3.5-flash-lite-off-v1 |
|
|
28
33
|
|
|
29
34
|
`off` is available for every row even though it is omitted from Pi's level map; omitted reasoning also selects that row's `off` route. Unsupported levels are not advertised and are rejected before transport. `antigravity-gemini-3.5-flash` is not registered or advertised as supported because its recorded HTTP-200 response lacks the strict terminal metadata required for admission. A future `fixture-qualified` route remains disabled for ordinary tool use; only separately authorized direct validation for the exact route may make it enabled.
|
|
30
35
|
|
|
@@ -51,6 +56,11 @@ Only the evidence-enabled Gemini 3.8 Flash `off` route uses the `parametersJsonS
|
|
|
51
56
|
| `antigravity-claude-sonnet-4.6` | off, high | 250,000 / 64,000 |
|
|
52
57
|
| `antigravity-claude-opus-4.6-thinking` | off, high | 250,000 / 64,000 |
|
|
53
58
|
| `antigravity-gpt-oss-120b` | off, medium | 131,072 / 32,768 |
|
|
59
|
+
| `antigravity-gemini-4-argon` | off, low, medium, high | 1,048,576 / 65,536 |
|
|
60
|
+
| `antigravity-gemini-4-carbon` | off, low, medium, high | 1,048,576 / 262,144 |
|
|
61
|
+
| `antigravity-gemini-4-neon` | off, low, medium, high, xhigh | 1,048,576 / 262,144 |
|
|
62
|
+
| `antigravity-gemini-4-hydrogen` | off, low, medium, high, xhigh | 1,048,576 / 262,144 |
|
|
63
|
+
| `antigravity-gemini-3.5-flash-lite` | off, low | 1,048,576 / 65,535 |
|
|
54
64
|
|
|
55
65
|
An explicit `maxTokens` must be a positive integer no greater than the row's output limit. For a route with a positive finite thinking budget, it must also be greater than that budget. When `maxTokens` is omitted, the provider uses 4,096 unless a larger finite thinking budget needs a 1,024-token answer reserve, always bounded by the row's output limit. Custom `thinkingBudgets` are unsupported and rejected.
|
|
56
66
|
|
package/dist/catalog.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type StandardReasoningLevel = "off" | "minimal" | "low" | "medium" | "high";
|
|
2
|
-
type NativeThinkingLevel = "low" | "medium" | "high";
|
|
1
|
+
export type StandardReasoningLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
2
|
+
type NativeThinkingLevel = "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
3
3
|
export interface ToolEvidenceRef {
|
|
4
4
|
readonly record: string;
|
|
5
5
|
readonly revision: string;
|
|
@@ -51,7 +51,9 @@ export interface CatalogEntry {
|
|
|
51
51
|
readonly publicId: string;
|
|
52
52
|
readonly descriptor: {
|
|
53
53
|
readonly name: string;
|
|
54
|
-
readonly thinkingLevelMap: Readonly<Record<"minimal" | "low" | "medium" | "high", string | null
|
|
54
|
+
readonly thinkingLevelMap: Readonly<Record<"minimal" | "low" | "medium" | "high", string | null> & {
|
|
55
|
+
readonly xhigh?: string | null;
|
|
56
|
+
}>;
|
|
55
57
|
readonly contextWindow: number;
|
|
56
58
|
readonly maxTokens: number;
|
|
57
59
|
};
|
|
@@ -401,6 +403,298 @@ declare const CATALOG: readonly [{
|
|
|
401
403
|
readonly kind: "gemini-envelope";
|
|
402
404
|
readonly family: "gpt-oss";
|
|
403
405
|
};
|
|
406
|
+
}, {
|
|
407
|
+
readonly publicId: "antigravity-gemini-4-argon";
|
|
408
|
+
readonly descriptor: {
|
|
409
|
+
readonly name: "Gemini 4 Argon (Antigravity, text only)";
|
|
410
|
+
readonly thinkingLevelMap: {
|
|
411
|
+
readonly minimal: null;
|
|
412
|
+
readonly low: "low";
|
|
413
|
+
readonly medium: "medium";
|
|
414
|
+
readonly high: "high";
|
|
415
|
+
};
|
|
416
|
+
readonly contextWindow: 1048576;
|
|
417
|
+
readonly maxTokens: 65536;
|
|
418
|
+
};
|
|
419
|
+
readonly routes: {
|
|
420
|
+
readonly off: {
|
|
421
|
+
readonly wireModel: "gemini-4-argon-low";
|
|
422
|
+
readonly thinking: {
|
|
423
|
+
readonly kind: "budget";
|
|
424
|
+
readonly budget: 0;
|
|
425
|
+
readonly includeThoughts: false;
|
|
426
|
+
};
|
|
427
|
+
readonly tools: ToolCapability;
|
|
428
|
+
};
|
|
429
|
+
readonly low: {
|
|
430
|
+
readonly wireModel: "gemini-4-argon-low";
|
|
431
|
+
readonly thinking: {
|
|
432
|
+
readonly kind: "budget";
|
|
433
|
+
readonly budget: 1000;
|
|
434
|
+
readonly includeThoughts: true;
|
|
435
|
+
};
|
|
436
|
+
readonly tools: ToolCapability;
|
|
437
|
+
};
|
|
438
|
+
readonly medium: {
|
|
439
|
+
readonly wireModel: "gemini-4-argon-medium";
|
|
440
|
+
readonly thinking: {
|
|
441
|
+
readonly kind: "budget";
|
|
442
|
+
readonly budget: 4000;
|
|
443
|
+
readonly includeThoughts: true;
|
|
444
|
+
};
|
|
445
|
+
readonly tools: ToolCapability;
|
|
446
|
+
};
|
|
447
|
+
readonly high: {
|
|
448
|
+
readonly wireModel: "gemini-4-argon-high";
|
|
449
|
+
readonly thinking: {
|
|
450
|
+
readonly kind: "budget";
|
|
451
|
+
readonly budget: -1;
|
|
452
|
+
readonly includeThoughts: true;
|
|
453
|
+
};
|
|
454
|
+
readonly tools: ToolCapability;
|
|
455
|
+
};
|
|
456
|
+
};
|
|
457
|
+
readonly replay: {
|
|
458
|
+
readonly kind: "same-public-model";
|
|
459
|
+
};
|
|
460
|
+
readonly response: {
|
|
461
|
+
readonly kind: "gemini-envelope";
|
|
462
|
+
readonly family: "gemini";
|
|
463
|
+
};
|
|
464
|
+
}, {
|
|
465
|
+
readonly publicId: "antigravity-gemini-4-carbon";
|
|
466
|
+
readonly descriptor: {
|
|
467
|
+
readonly name: "Gemini 4 Carbon (Antigravity, text only)";
|
|
468
|
+
readonly thinkingLevelMap: {
|
|
469
|
+
readonly minimal: null;
|
|
470
|
+
readonly low: "low";
|
|
471
|
+
readonly medium: "medium";
|
|
472
|
+
readonly high: "high";
|
|
473
|
+
};
|
|
474
|
+
readonly contextWindow: 1048576;
|
|
475
|
+
readonly maxTokens: 262144;
|
|
476
|
+
};
|
|
477
|
+
readonly routes: {
|
|
478
|
+
readonly off: {
|
|
479
|
+
readonly wireModel: "gemini-4-carbon-low";
|
|
480
|
+
readonly thinking: {
|
|
481
|
+
readonly kind: "budget";
|
|
482
|
+
readonly budget: 0;
|
|
483
|
+
readonly includeThoughts: false;
|
|
484
|
+
};
|
|
485
|
+
readonly tools: ToolCapability;
|
|
486
|
+
};
|
|
487
|
+
readonly low: {
|
|
488
|
+
readonly wireModel: "gemini-4-carbon-low";
|
|
489
|
+
readonly thinking: {
|
|
490
|
+
readonly kind: "budget";
|
|
491
|
+
readonly budget: 1000;
|
|
492
|
+
readonly includeThoughts: true;
|
|
493
|
+
};
|
|
494
|
+
readonly tools: ToolCapability;
|
|
495
|
+
};
|
|
496
|
+
readonly medium: {
|
|
497
|
+
readonly wireModel: "gemini-4-carbon-medium";
|
|
498
|
+
readonly thinking: {
|
|
499
|
+
readonly kind: "budget";
|
|
500
|
+
readonly budget: 4000;
|
|
501
|
+
readonly includeThoughts: true;
|
|
502
|
+
};
|
|
503
|
+
readonly tools: ToolCapability;
|
|
504
|
+
};
|
|
505
|
+
readonly high: {
|
|
506
|
+
readonly wireModel: "gemini-4-carbon-high";
|
|
507
|
+
readonly thinking: {
|
|
508
|
+
readonly kind: "budget";
|
|
509
|
+
readonly budget: -1;
|
|
510
|
+
readonly includeThoughts: true;
|
|
511
|
+
};
|
|
512
|
+
readonly tools: ToolCapability;
|
|
513
|
+
};
|
|
514
|
+
};
|
|
515
|
+
readonly replay: {
|
|
516
|
+
readonly kind: "same-public-model";
|
|
517
|
+
};
|
|
518
|
+
readonly response: {
|
|
519
|
+
readonly kind: "gemini-envelope";
|
|
520
|
+
readonly family: "gemini";
|
|
521
|
+
};
|
|
522
|
+
}, {
|
|
523
|
+
readonly publicId: "antigravity-gemini-4-neon";
|
|
524
|
+
readonly descriptor: {
|
|
525
|
+
readonly name: "Gemini 4 Neon (Antigravity, text only)";
|
|
526
|
+
readonly thinkingLevelMap: {
|
|
527
|
+
readonly minimal: null;
|
|
528
|
+
readonly low: "low";
|
|
529
|
+
readonly medium: "medium";
|
|
530
|
+
readonly high: "high";
|
|
531
|
+
readonly xhigh: "xhigh";
|
|
532
|
+
};
|
|
533
|
+
readonly contextWindow: 1048576;
|
|
534
|
+
readonly maxTokens: 262144;
|
|
535
|
+
};
|
|
536
|
+
readonly routes: {
|
|
537
|
+
readonly off: {
|
|
538
|
+
readonly wireModel: "gemini-4-neon-low";
|
|
539
|
+
readonly thinking: {
|
|
540
|
+
readonly kind: "budget";
|
|
541
|
+
readonly budget: 0;
|
|
542
|
+
readonly includeThoughts: false;
|
|
543
|
+
};
|
|
544
|
+
readonly tools: ToolCapability;
|
|
545
|
+
};
|
|
546
|
+
readonly low: {
|
|
547
|
+
readonly wireModel: "gemini-4-neon-low";
|
|
548
|
+
readonly thinking: {
|
|
549
|
+
readonly kind: "budget";
|
|
550
|
+
readonly budget: 1000;
|
|
551
|
+
readonly includeThoughts: true;
|
|
552
|
+
};
|
|
553
|
+
readonly tools: ToolCapability;
|
|
554
|
+
};
|
|
555
|
+
readonly medium: {
|
|
556
|
+
readonly wireModel: "gemini-4-neon-medium";
|
|
557
|
+
readonly thinking: {
|
|
558
|
+
readonly kind: "budget";
|
|
559
|
+
readonly budget: 4000;
|
|
560
|
+
readonly includeThoughts: true;
|
|
561
|
+
};
|
|
562
|
+
readonly tools: ToolCapability;
|
|
563
|
+
};
|
|
564
|
+
readonly high: {
|
|
565
|
+
readonly wireModel: "gemini-4-neon-high";
|
|
566
|
+
readonly thinking: {
|
|
567
|
+
readonly kind: "budget";
|
|
568
|
+
readonly budget: -1;
|
|
569
|
+
readonly includeThoughts: true;
|
|
570
|
+
};
|
|
571
|
+
readonly tools: ToolCapability;
|
|
572
|
+
};
|
|
573
|
+
readonly xhigh: {
|
|
574
|
+
readonly wireModel: "gemini-4-neon-xhigh";
|
|
575
|
+
readonly thinking: {
|
|
576
|
+
readonly kind: "budget";
|
|
577
|
+
readonly budget: -1;
|
|
578
|
+
readonly includeThoughts: true;
|
|
579
|
+
};
|
|
580
|
+
readonly tools: ToolCapability;
|
|
581
|
+
};
|
|
582
|
+
};
|
|
583
|
+
readonly replay: {
|
|
584
|
+
readonly kind: "same-public-model";
|
|
585
|
+
};
|
|
586
|
+
readonly response: {
|
|
587
|
+
readonly kind: "gemini-envelope";
|
|
588
|
+
readonly family: "gemini";
|
|
589
|
+
};
|
|
590
|
+
}, {
|
|
591
|
+
readonly publicId: "antigravity-gemini-4-hydrogen";
|
|
592
|
+
readonly descriptor: {
|
|
593
|
+
readonly name: "Gemini 4 Hydrogen (Antigravity, text only)";
|
|
594
|
+
readonly thinkingLevelMap: {
|
|
595
|
+
readonly minimal: null;
|
|
596
|
+
readonly low: "low";
|
|
597
|
+
readonly medium: "medium";
|
|
598
|
+
readonly high: "high";
|
|
599
|
+
readonly xhigh: "xhigh";
|
|
600
|
+
};
|
|
601
|
+
readonly contextWindow: 1048576;
|
|
602
|
+
readonly maxTokens: 262144;
|
|
603
|
+
};
|
|
604
|
+
readonly routes: {
|
|
605
|
+
readonly off: {
|
|
606
|
+
readonly wireModel: "gemini-4-hydrogen-low";
|
|
607
|
+
readonly thinking: {
|
|
608
|
+
readonly kind: "budget";
|
|
609
|
+
readonly budget: 0;
|
|
610
|
+
readonly includeThoughts: false;
|
|
611
|
+
};
|
|
612
|
+
readonly tools: ToolCapability;
|
|
613
|
+
};
|
|
614
|
+
readonly low: {
|
|
615
|
+
readonly wireModel: "gemini-4-hydrogen-low";
|
|
616
|
+
readonly thinking: {
|
|
617
|
+
readonly kind: "budget";
|
|
618
|
+
readonly budget: 1000;
|
|
619
|
+
readonly includeThoughts: true;
|
|
620
|
+
};
|
|
621
|
+
readonly tools: ToolCapability;
|
|
622
|
+
};
|
|
623
|
+
readonly medium: {
|
|
624
|
+
readonly wireModel: "gemini-4-hydrogen-medium";
|
|
625
|
+
readonly thinking: {
|
|
626
|
+
readonly kind: "budget";
|
|
627
|
+
readonly budget: 4000;
|
|
628
|
+
readonly includeThoughts: true;
|
|
629
|
+
};
|
|
630
|
+
readonly tools: ToolCapability;
|
|
631
|
+
};
|
|
632
|
+
readonly high: {
|
|
633
|
+
readonly wireModel: "gemini-4-hydrogen-high";
|
|
634
|
+
readonly thinking: {
|
|
635
|
+
readonly kind: "budget";
|
|
636
|
+
readonly budget: -1;
|
|
637
|
+
readonly includeThoughts: true;
|
|
638
|
+
};
|
|
639
|
+
readonly tools: ToolCapability;
|
|
640
|
+
};
|
|
641
|
+
readonly xhigh: {
|
|
642
|
+
readonly wireModel: "gemini-4-hydrogen-xhigh";
|
|
643
|
+
readonly thinking: {
|
|
644
|
+
readonly kind: "budget";
|
|
645
|
+
readonly budget: -1;
|
|
646
|
+
readonly includeThoughts: true;
|
|
647
|
+
};
|
|
648
|
+
readonly tools: ToolCapability;
|
|
649
|
+
};
|
|
650
|
+
};
|
|
651
|
+
readonly replay: {
|
|
652
|
+
readonly kind: "same-public-model";
|
|
653
|
+
};
|
|
654
|
+
readonly response: {
|
|
655
|
+
readonly kind: "gemini-envelope";
|
|
656
|
+
readonly family: "gemini";
|
|
657
|
+
};
|
|
658
|
+
}, {
|
|
659
|
+
readonly publicId: "antigravity-gemini-3.5-flash-lite";
|
|
660
|
+
readonly descriptor: {
|
|
661
|
+
readonly name: "Gemini 3.5 Flash Lite (Antigravity, text only)";
|
|
662
|
+
readonly thinkingLevelMap: {
|
|
663
|
+
readonly minimal: null;
|
|
664
|
+
readonly low: "low";
|
|
665
|
+
readonly medium: null;
|
|
666
|
+
readonly high: null;
|
|
667
|
+
};
|
|
668
|
+
readonly contextWindow: 1048576;
|
|
669
|
+
readonly maxTokens: 65535;
|
|
670
|
+
};
|
|
671
|
+
readonly routes: {
|
|
672
|
+
readonly off: {
|
|
673
|
+
readonly wireModel: "gemini-3.5-flash-lite";
|
|
674
|
+
readonly thinking: {
|
|
675
|
+
readonly kind: "budget";
|
|
676
|
+
readonly budget: 0;
|
|
677
|
+
readonly includeThoughts: false;
|
|
678
|
+
};
|
|
679
|
+
readonly tools: ToolCapability;
|
|
680
|
+
};
|
|
681
|
+
readonly low: {
|
|
682
|
+
readonly wireModel: "gemini-3.5-flash-lite";
|
|
683
|
+
readonly thinking: {
|
|
684
|
+
readonly kind: "budget";
|
|
685
|
+
readonly budget: 1000;
|
|
686
|
+
readonly includeThoughts: true;
|
|
687
|
+
};
|
|
688
|
+
readonly tools: ToolCapability;
|
|
689
|
+
};
|
|
690
|
+
};
|
|
691
|
+
readonly replay: {
|
|
692
|
+
readonly kind: "same-public-model";
|
|
693
|
+
};
|
|
694
|
+
readonly response: {
|
|
695
|
+
readonly kind: "gemini-envelope";
|
|
696
|
+
readonly family: "gemini";
|
|
697
|
+
};
|
|
404
698
|
}];
|
|
405
699
|
type Catalog = typeof CATALOG;
|
|
406
700
|
export type AntigravityPublicModelId = Catalog[number]["publicId"];
|
|
@@ -436,6 +730,7 @@ export declare function toPiModelDescriptor(entry: CatalogEntry): {
|
|
|
436
730
|
low: string | null;
|
|
437
731
|
medium: string | null;
|
|
438
732
|
minimal: string | null;
|
|
733
|
+
xhigh?: string | null;
|
|
439
734
|
};
|
|
440
735
|
input: ("text" | "image")[];
|
|
441
736
|
cost: {
|
package/dist/catalog.js
CHANGED
|
@@ -106,6 +106,86 @@ const CATALOG = freeze(defineCatalog([{
|
|
|
106
106
|
},
|
|
107
107
|
replay: { kind: "same-public-model" },
|
|
108
108
|
response: { kind: "gemini-envelope", family: "gpt-oss" },
|
|
109
|
+
}, {
|
|
110
|
+
publicId: "antigravity-gemini-4-argon",
|
|
111
|
+
descriptor: {
|
|
112
|
+
name: "Gemini 4 Argon (Antigravity, text only)",
|
|
113
|
+
thinkingLevelMap: { minimal: null, low: "low", medium: "medium", high: "high" },
|
|
114
|
+
contextWindow: 1_048_576,
|
|
115
|
+
maxTokens: 65_536,
|
|
116
|
+
},
|
|
117
|
+
routes: {
|
|
118
|
+
off: { wireModel: "gemini-4-argon-low", thinking: { kind: "budget", budget: 0, includeThoughts: false }, tools: enabled({ record: "pi-json-tool-loop", revision: "gemini-4-argon-off-v1", publicModelId: "antigravity-gemini-4-argon", reasoning: "off", wireModel: "gemini-4-argon-low" }, GEMINI_PARAMETERS_JSON_SCHEMA_PROFILE) },
|
|
119
|
+
low: { wireModel: "gemini-4-argon-low", thinking: { kind: "budget", budget: 1000, includeThoughts: true }, tools: enabled({ record: "pi-json-tool-loop", revision: "gemini-4-argon-low-v1", publicModelId: "antigravity-gemini-4-argon", reasoning: "low", wireModel: "gemini-4-argon-low" }, GEMINI_PARAMETERS_JSON_SCHEMA_PROFILE) },
|
|
120
|
+
medium: { wireModel: "gemini-4-argon-medium", thinking: { kind: "budget", budget: 4000, includeThoughts: true }, tools: enabled({ record: "pi-json-tool-loop", revision: "gemini-4-argon-medium-v1", publicModelId: "antigravity-gemini-4-argon", reasoning: "medium", wireModel: "gemini-4-argon-medium" }, GEMINI_PARAMETERS_JSON_SCHEMA_PROFILE) },
|
|
121
|
+
high: { wireModel: "gemini-4-argon-high", thinking: { kind: "budget", budget: -1, includeThoughts: true }, tools: enabled({ record: "pi-json-tool-loop", revision: "gemini-4-argon-high-v1", publicModelId: "antigravity-gemini-4-argon", reasoning: "high", wireModel: "gemini-4-argon-high" }, GEMINI_PARAMETERS_JSON_SCHEMA_PROFILE) },
|
|
122
|
+
},
|
|
123
|
+
replay: { kind: "same-public-model" },
|
|
124
|
+
response: { kind: "gemini-envelope", family: "gemini" },
|
|
125
|
+
}, {
|
|
126
|
+
publicId: "antigravity-gemini-4-carbon",
|
|
127
|
+
descriptor: {
|
|
128
|
+
name: "Gemini 4 Carbon (Antigravity, text only)",
|
|
129
|
+
thinkingLevelMap: { minimal: null, low: "low", medium: "medium", high: "high" },
|
|
130
|
+
contextWindow: 1_048_576,
|
|
131
|
+
maxTokens: 262_144,
|
|
132
|
+
},
|
|
133
|
+
routes: {
|
|
134
|
+
off: { wireModel: "gemini-4-carbon-low", thinking: { kind: "budget", budget: 0, includeThoughts: false }, tools: enabled({ record: "pi-json-tool-loop", revision: "gemini-4-carbon-off-v1", publicModelId: "antigravity-gemini-4-carbon", reasoning: "off", wireModel: "gemini-4-carbon-low" }, GEMINI_PARAMETERS_JSON_SCHEMA_PROFILE) },
|
|
135
|
+
low: { wireModel: "gemini-4-carbon-low", thinking: { kind: "budget", budget: 1000, includeThoughts: true }, tools: enabled({ record: "pi-json-tool-loop", revision: "gemini-4-carbon-low-v1", publicModelId: "antigravity-gemini-4-carbon", reasoning: "low", wireModel: "gemini-4-carbon-low" }, GEMINI_PARAMETERS_JSON_SCHEMA_PROFILE) },
|
|
136
|
+
medium: { wireModel: "gemini-4-carbon-medium", thinking: { kind: "budget", budget: 4000, includeThoughts: true }, tools: enabled({ record: "pi-json-tool-loop", revision: "gemini-4-carbon-medium-v1", publicModelId: "antigravity-gemini-4-carbon", reasoning: "medium", wireModel: "gemini-4-carbon-medium" }, GEMINI_PARAMETERS_JSON_SCHEMA_PROFILE) },
|
|
137
|
+
high: { wireModel: "gemini-4-carbon-high", thinking: { kind: "budget", budget: -1, includeThoughts: true }, tools: enabled({ record: "pi-json-tool-loop", revision: "gemini-4-carbon-high-v1", publicModelId: "antigravity-gemini-4-carbon", reasoning: "high", wireModel: "gemini-4-carbon-high" }, GEMINI_PARAMETERS_JSON_SCHEMA_PROFILE) },
|
|
138
|
+
},
|
|
139
|
+
replay: { kind: "same-public-model" },
|
|
140
|
+
response: { kind: "gemini-envelope", family: "gemini" },
|
|
141
|
+
}, {
|
|
142
|
+
publicId: "antigravity-gemini-4-neon",
|
|
143
|
+
descriptor: {
|
|
144
|
+
name: "Gemini 4 Neon (Antigravity, text only)",
|
|
145
|
+
thinkingLevelMap: { minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh" },
|
|
146
|
+
contextWindow: 1_048_576,
|
|
147
|
+
maxTokens: 262_144,
|
|
148
|
+
},
|
|
149
|
+
routes: {
|
|
150
|
+
off: { wireModel: "gemini-4-neon-low", thinking: { kind: "budget", budget: 0, includeThoughts: false }, tools: enabled({ record: "pi-json-tool-loop", revision: "gemini-4-neon-off-v1", publicModelId: "antigravity-gemini-4-neon", reasoning: "off", wireModel: "gemini-4-neon-low" }, GEMINI_PARAMETERS_JSON_SCHEMA_PROFILE) },
|
|
151
|
+
low: { wireModel: "gemini-4-neon-low", thinking: { kind: "budget", budget: 1000, includeThoughts: true }, tools: enabled({ record: "pi-json-tool-loop", revision: "gemini-4-neon-low-v1", publicModelId: "antigravity-gemini-4-neon", reasoning: "low", wireModel: "gemini-4-neon-low" }, GEMINI_PARAMETERS_JSON_SCHEMA_PROFILE) },
|
|
152
|
+
medium: { wireModel: "gemini-4-neon-medium", thinking: { kind: "budget", budget: 4000, includeThoughts: true }, tools: enabled({ record: "pi-json-tool-loop", revision: "gemini-4-neon-medium-v1", publicModelId: "antigravity-gemini-4-neon", reasoning: "medium", wireModel: "gemini-4-neon-medium" }, GEMINI_PARAMETERS_JSON_SCHEMA_PROFILE) },
|
|
153
|
+
high: { wireModel: "gemini-4-neon-high", thinking: { kind: "budget", budget: -1, includeThoughts: true }, tools: enabled({ record: "pi-json-tool-loop", revision: "gemini-4-neon-high-v1", publicModelId: "antigravity-gemini-4-neon", reasoning: "high", wireModel: "gemini-4-neon-high" }, GEMINI_PARAMETERS_JSON_SCHEMA_PROFILE) },
|
|
154
|
+
xhigh: { wireModel: "gemini-4-neon-xhigh", thinking: { kind: "budget", budget: -1, includeThoughts: true }, tools: enabled({ record: "pi-json-tool-loop", revision: "gemini-4-neon-xhigh-v1", publicModelId: "antigravity-gemini-4-neon", reasoning: "xhigh", wireModel: "gemini-4-neon-xhigh" }, GEMINI_PARAMETERS_JSON_SCHEMA_PROFILE) },
|
|
155
|
+
},
|
|
156
|
+
replay: { kind: "same-public-model" },
|
|
157
|
+
response: { kind: "gemini-envelope", family: "gemini" },
|
|
158
|
+
}, {
|
|
159
|
+
publicId: "antigravity-gemini-4-hydrogen",
|
|
160
|
+
descriptor: {
|
|
161
|
+
name: "Gemini 4 Hydrogen (Antigravity, text only)",
|
|
162
|
+
thinkingLevelMap: { minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh" },
|
|
163
|
+
contextWindow: 1_048_576,
|
|
164
|
+
maxTokens: 262_144,
|
|
165
|
+
},
|
|
166
|
+
routes: {
|
|
167
|
+
off: { wireModel: "gemini-4-hydrogen-low", thinking: { kind: "budget", budget: 0, includeThoughts: false }, tools: enabled({ record: "pi-json-tool-loop", revision: "gemini-4-hydrogen-off-v1", publicModelId: "antigravity-gemini-4-hydrogen", reasoning: "off", wireModel: "gemini-4-hydrogen-low" }, GEMINI_PARAMETERS_JSON_SCHEMA_PROFILE) },
|
|
168
|
+
low: { wireModel: "gemini-4-hydrogen-low", thinking: { kind: "budget", budget: 1000, includeThoughts: true }, tools: enabled({ record: "pi-json-tool-loop", revision: "gemini-4-hydrogen-low-v1", publicModelId: "antigravity-gemini-4-hydrogen", reasoning: "low", wireModel: "gemini-4-hydrogen-low" }, GEMINI_PARAMETERS_JSON_SCHEMA_PROFILE) },
|
|
169
|
+
medium: { wireModel: "gemini-4-hydrogen-medium", thinking: { kind: "budget", budget: 4000, includeThoughts: true }, tools: enabled({ record: "pi-json-tool-loop", revision: "gemini-4-hydrogen-medium-v1", publicModelId: "antigravity-gemini-4-hydrogen", reasoning: "medium", wireModel: "gemini-4-hydrogen-medium" }, GEMINI_PARAMETERS_JSON_SCHEMA_PROFILE) },
|
|
170
|
+
high: { wireModel: "gemini-4-hydrogen-high", thinking: { kind: "budget", budget: -1, includeThoughts: true }, tools: enabled({ record: "pi-json-tool-loop", revision: "gemini-4-hydrogen-high-v1", publicModelId: "antigravity-gemini-4-hydrogen", reasoning: "high", wireModel: "gemini-4-hydrogen-high" }, GEMINI_PARAMETERS_JSON_SCHEMA_PROFILE) },
|
|
171
|
+
xhigh: { wireModel: "gemini-4-hydrogen-xhigh", thinking: { kind: "budget", budget: -1, includeThoughts: true }, tools: enabled({ record: "pi-json-tool-loop", revision: "gemini-4-hydrogen-xhigh-v1", publicModelId: "antigravity-gemini-4-hydrogen", reasoning: "xhigh", wireModel: "gemini-4-hydrogen-xhigh" }, GEMINI_PARAMETERS_JSON_SCHEMA_PROFILE) },
|
|
172
|
+
},
|
|
173
|
+
replay: { kind: "same-public-model" },
|
|
174
|
+
response: { kind: "gemini-envelope", family: "gemini" },
|
|
175
|
+
}, {
|
|
176
|
+
publicId: "antigravity-gemini-3.5-flash-lite",
|
|
177
|
+
descriptor: {
|
|
178
|
+
name: "Gemini 3.5 Flash Lite (Antigravity, text only)",
|
|
179
|
+
thinkingLevelMap: { minimal: null, low: "low", medium: null, high: null },
|
|
180
|
+
contextWindow: 1_048_576,
|
|
181
|
+
maxTokens: 65_535,
|
|
182
|
+
},
|
|
183
|
+
routes: {
|
|
184
|
+
off: { wireModel: "gemini-3.5-flash-lite", thinking: { kind: "budget", budget: 0, includeThoughts: false }, tools: enabled({ record: "pi-json-tool-loop", revision: "gemini-3.5-flash-lite-off-v1", publicModelId: "antigravity-gemini-3.5-flash-lite", reasoning: "off", wireModel: "gemini-3.5-flash-lite" }, GEMINI_PARAMETERS_JSON_SCHEMA_PROFILE) },
|
|
185
|
+
low: { wireModel: "gemini-3.5-flash-lite", thinking: { kind: "budget", budget: 1000, includeThoughts: true }, tools: enabled({ record: "pi-json-tool-loop", revision: "gemini-3.5-flash-lite-low-v1", publicModelId: "antigravity-gemini-3.5-flash-lite", reasoning: "low", wireModel: "gemini-3.5-flash-lite" }, GEMINI_PARAMETERS_JSON_SCHEMA_PROFILE) },
|
|
186
|
+
},
|
|
187
|
+
replay: { kind: "same-public-model" },
|
|
188
|
+
response: { kind: "gemini-envelope", family: "gemini" },
|
|
109
189
|
}]));
|
|
110
190
|
const lookup = new Map(CATALOG.map((entry) => [entry.publicId, entry]));
|
|
111
191
|
function disabled(reason) {
|
|
@@ -142,7 +222,7 @@ export function defineCatalog(entries) {
|
|
|
142
222
|
if (level !== "off" && !Object.hasOwn(entry.descriptor.thinkingLevelMap, level)) {
|
|
143
223
|
throw new Error(`Route is outside descriptor map: ${entry.publicId}/${level}`);
|
|
144
224
|
}
|
|
145
|
-
if (level !== "off" && entry.descriptor.thinkingLevelMap[level]
|
|
225
|
+
if (level !== "off" && entry.descriptor.thinkingLevelMap[level] == null) {
|
|
146
226
|
throw new Error(`Route is hidden by descriptor: ${entry.publicId}/${level}`);
|
|
147
227
|
}
|
|
148
228
|
if (route.thinking.kind === "budget" && route.thinking.budget > 0 && Number.isFinite(route.thinking.budget) && route.thinking.budget + ANSWER_RESERVE > entry.descriptor.maxTokens) {
|
package/dist/context.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Context, Model, SimpleStreamOptions } from "@earendil-works/pi-ai";
|
|
2
2
|
import { type GenerationSelection } from "./catalog.ts";
|
|
3
3
|
import { type ToolReplayDiagnostics } from "./tool-context.ts";
|
|
4
|
+
declare const THINKING_LEVELS: readonly ["minimal", "low", "medium", "high", "xhigh"];
|
|
5
|
+
type ThinkingLevel = typeof THINKING_LEVELS[number];
|
|
4
6
|
interface Part {
|
|
5
7
|
text?: string;
|
|
6
8
|
thought?: true;
|
|
@@ -41,7 +43,7 @@ export interface GenerationRequest {
|
|
|
41
43
|
temperature: number;
|
|
42
44
|
maxOutputTokens: number;
|
|
43
45
|
thinkingConfig?: {
|
|
44
|
-
thinkingLevel:
|
|
46
|
+
thinkingLevel: ThinkingLevel;
|
|
45
47
|
includeThoughts: boolean;
|
|
46
48
|
} | {
|
|
47
49
|
thinkingBudget: number;
|
|
@@ -64,6 +66,7 @@ export interface SerializeTextContextInput {
|
|
|
64
66
|
}
|
|
65
67
|
export declare class ContextSerializationError extends Error {
|
|
66
68
|
}
|
|
69
|
+
export declare function sanitizeAntigravitySystemPrompt(systemPrompt: string): string;
|
|
67
70
|
export declare function serializeContext(input: SerializeTextContextInput, injectedSelection?: GenerationSelection, onDiagnostics?: (diagnostics: ToolReplayDiagnostics) => void): GenerationRequest;
|
|
68
71
|
export declare function serializeTextContext(input: SerializeTextContextInput): GenerationRequest;
|
|
69
72
|
export {};
|
package/dist/context.js
CHANGED
|
@@ -5,9 +5,27 @@ import { hasToolContext, prepareToolContext, replayToolHistory } from "./tool-co
|
|
|
5
5
|
const MAX_TEXT_BYTES = 8 * 1024 * 1024;
|
|
6
6
|
const PROVIDER = "antigravity-guard";
|
|
7
7
|
const RESERVED_HEADERS = new Set(["authorization", "host", "content-type", "content-length"]);
|
|
8
|
-
const THINKING_LEVELS = ["low", "medium", "high"];
|
|
8
|
+
const THINKING_LEVELS = ["minimal", "low", "medium", "high", "xhigh"];
|
|
9
|
+
const PI_HARNESS_MARKER = "operating inside pi, a coding agent harness";
|
|
9
10
|
export class ContextSerializationError extends Error {
|
|
10
11
|
}
|
|
12
|
+
const PI_DOCS_BLOCK_REGEX = /(?:<docs>\r?\n)?Pi documentation \(read only when the user asks about pi[^)]*\):\r?\n- Main documentation: ([^\r\n]+)\r?\n- Additional docs: ([^\r\n]+)\r?\n- Examples: ([^\r\n]+)[^\r\n]*\r?\n(?:- When reading pi docs or examples[^\r\n]+\r?\n)?- When asked about:[^\r\n]+\r?\n(?:- When working on pi topics[^\r\n]+\r?\n)?- Always read pi \.md files completely[^\r\n]+(?:\r?\n<\/docs>)?/g;
|
|
13
|
+
export function sanitizeAntigravitySystemPrompt(systemPrompt) {
|
|
14
|
+
if (!systemPrompt.includes(PI_HARNESS_MARKER))
|
|
15
|
+
return systemPrompt;
|
|
16
|
+
return systemPrompt
|
|
17
|
+
.replaceAll(PI_HARNESS_MARKER, "working on software projects")
|
|
18
|
+
.replace(PI_DOCS_BLOCK_REGEX, [
|
|
19
|
+
"Local harness documentation (read only when the user explicitly asks about local agent customization):",
|
|
20
|
+
"<reference_paths>",
|
|
21
|
+
"- Main reference: $1",
|
|
22
|
+
"- Additional docs: $2",
|
|
23
|
+
"- Examples: $3",
|
|
24
|
+
"</reference_paths>",
|
|
25
|
+
].join("\n"))
|
|
26
|
+
.replace(/Pi documentation \(read only when the user asks about pi[^)]*\):/g, "Local harness documentation (read only when the user explicitly asks about local agent customization):")
|
|
27
|
+
.replace(/<docs>([\s\S]*?)<\/docs>/g, "<reference_paths>$1</reference_paths>");
|
|
28
|
+
}
|
|
11
29
|
export function serializeContext(input, injectedSelection, onDiagnostics) {
|
|
12
30
|
const context = input.context;
|
|
13
31
|
if (!hasToolContext(context))
|
|
@@ -22,10 +40,19 @@ export function serializeContext(input, injectedSelection, onDiagnostics) {
|
|
|
22
40
|
fail("Invalid tool capability selection.");
|
|
23
41
|
if (selection.tools.state !== "enabled")
|
|
24
42
|
fail(capabilityError(entry.publicId, selection.level, selection.tools));
|
|
25
|
-
const
|
|
26
|
-
const
|
|
43
|
+
const normalized = normalizeContextRecord(context);
|
|
44
|
+
const prepared = prepareToolContext(normalized.tools ?? [], isRecord(options) ? field(options, "toolChoice") : undefined, selection.tools.schemaProfile);
|
|
45
|
+
const { tools: _tools, messages: _messages, systemPrompt: _systemPrompt, ...textContext } = context;
|
|
27
46
|
const { toolChoice: _choice, ...textOptions } = isRecord(options) ? options : {};
|
|
28
|
-
const text = serializeTextContext({
|
|
47
|
+
const text = serializeTextContext({
|
|
48
|
+
...input,
|
|
49
|
+
context: {
|
|
50
|
+
...textContext,
|
|
51
|
+
...(normalized.systemPrompt !== undefined ? { systemPrompt: normalized.systemPrompt } : {}),
|
|
52
|
+
messages: [{ role: "user", content: "placeholder", timestamp: 0 }],
|
|
53
|
+
},
|
|
54
|
+
options: textOptions,
|
|
55
|
+
});
|
|
29
56
|
const sameModel = (message) => field(message, "role") === "assistant" && entry.replay.kind === "same-public-model" && isSameProviderAndModel(message, entry.publicId);
|
|
30
57
|
const requireSigned = geminiRequiresSignedToolReplay(selection.route.wireModel);
|
|
31
58
|
const includeToolCallId = entry.response.family === "claude" || entry.response.family === "gpt-oss";
|
|
@@ -35,13 +62,13 @@ export function serializeContext(input, injectedSelection, onDiagnostics) {
|
|
|
35
62
|
toolCallSignature: (part, message) => sameModel(message) ? validThoughtSignature(field(part, "thoughtSignature")) : undefined,
|
|
36
63
|
includeToolCallId,
|
|
37
64
|
} : undefined;
|
|
38
|
-
const contents = replayToolHistory(
|
|
65
|
+
const contents = replayToolHistory(normalized.messages, (part, message) => messagePart(part, field(message, "role") === "assistant", sameModel(message)), onDiagnostics, toolReplayPolicy, prepared?.declarations.length ?? 0);
|
|
39
66
|
const { systemInstruction, generationConfig } = text.request;
|
|
40
67
|
const envelope = buildAntigravityEnvelope({
|
|
41
68
|
wireModelId: selection.route.wireModel,
|
|
42
69
|
family: entry.response.family,
|
|
43
70
|
contentsCount: contents.length,
|
|
44
|
-
messages:
|
|
71
|
+
messages: normalized.messages,
|
|
45
72
|
injectedRequestId: input.requestId,
|
|
46
73
|
});
|
|
47
74
|
return { ...text, request: {
|
|
@@ -80,18 +107,20 @@ export function serializeTextContext(input) {
|
|
|
80
107
|
fail("Invalid text context.");
|
|
81
108
|
const selection = resolveGenerationSelection(entry, option(options, "reasoning"));
|
|
82
109
|
const route = selection.route;
|
|
83
|
-
|
|
110
|
+
const normalized = normalizeContextRecord(context);
|
|
111
|
+
if (isToolBearingNormalizedContext(normalized) && selection.tools.state !== "enabled")
|
|
84
112
|
fail(capabilityError(entry.publicId, selection.level, selection.tools));
|
|
85
|
-
const
|
|
86
|
-
const tools =
|
|
87
|
-
if (
|
|
113
|
+
const rawSystemPrompt = normalized.systemPrompt;
|
|
114
|
+
const tools = normalized.tools;
|
|
115
|
+
if (rawSystemPrompt !== undefined && typeof rawSystemPrompt !== "string")
|
|
88
116
|
fail("Text-only context is required.");
|
|
89
117
|
if (tools !== undefined && isDenseArray(tools).length)
|
|
90
118
|
fail("Tools are not supported by this text-only provider.");
|
|
91
|
-
validateOptions(options);
|
|
119
|
+
validateOptions(options, entry.descriptor.maxTokens);
|
|
120
|
+
const systemPrompt = rawSystemPrompt === undefined ? undefined : sanitizeAntigravitySystemPrompt(rawSystemPrompt);
|
|
92
121
|
let textBytes = byteLength(systemPrompt ?? "");
|
|
93
122
|
const contents = [];
|
|
94
|
-
for (const message of
|
|
123
|
+
for (const message of normalized.messages) {
|
|
95
124
|
if (!isRecord(message))
|
|
96
125
|
fail("Invalid text context.");
|
|
97
126
|
const role = field(message, "role", true);
|
|
@@ -115,7 +144,7 @@ export function serializeTextContext(input) {
|
|
|
115
144
|
wireModelId: route.wireModel,
|
|
116
145
|
family: entry.response.family,
|
|
117
146
|
contentsCount: contents.length,
|
|
118
|
-
messages:
|
|
147
|
+
messages: normalized.messages,
|
|
119
148
|
injectedRequestId: requestId,
|
|
120
149
|
});
|
|
121
150
|
return { project, model: route.wireModel, request: { contents, ...(systemInstruction ? { systemInstruction } : {}), generationConfig: {
|
|
@@ -133,16 +162,102 @@ export function serializeTextContext(input) {
|
|
|
133
162
|
fail("Invalid text context.");
|
|
134
163
|
}
|
|
135
164
|
}
|
|
165
|
+
function normalizeContextRecord(context) {
|
|
166
|
+
const rawSystemPrompt = field(context, "systemPrompt");
|
|
167
|
+
const rawTools = field(context, "tools");
|
|
168
|
+
const rawMessages = isDenseArray(field(context, "messages", true));
|
|
169
|
+
const hasSystemMessage = rawMessages.some((message) => isRecord(message) && field(message, "role") === "system");
|
|
170
|
+
if (!hasSystemMessage) {
|
|
171
|
+
return { systemPrompt: rawSystemPrompt, tools: rawTools, messages: rawMessages };
|
|
172
|
+
}
|
|
173
|
+
if (rawSystemPrompt !== undefined && typeof rawSystemPrompt !== "string")
|
|
174
|
+
fail("Text-only context is required.");
|
|
175
|
+
const systemContentParts = [];
|
|
176
|
+
const sectionMap = new Map();
|
|
177
|
+
const toolMap = new Map();
|
|
178
|
+
if (rawTools !== undefined) {
|
|
179
|
+
for (const tool of isDenseArray(rawTools)) {
|
|
180
|
+
const name = isRecord(tool) ? field(tool, "name") : undefined;
|
|
181
|
+
toolMap.set(typeof name === "string" && name ? name : Symbol("tool"), tool);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
const conversationMessages = [];
|
|
185
|
+
for (const message of rawMessages) {
|
|
186
|
+
if (!isRecord(message))
|
|
187
|
+
fail("Invalid text context.");
|
|
188
|
+
const role = field(message, "role", true);
|
|
189
|
+
if (role !== "system") {
|
|
190
|
+
conversationMessages.push(message);
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
const contentText = extractSystemMessageContent(field(message, "content", true));
|
|
194
|
+
if (contentText.length > 0)
|
|
195
|
+
systemContentParts.push(contentText);
|
|
196
|
+
const rawSections = field(message, "sections");
|
|
197
|
+
if (rawSections !== undefined) {
|
|
198
|
+
if (!isRecord(rawSections))
|
|
199
|
+
fail("Invalid text context.");
|
|
200
|
+
for (const sectionName of Object.keys(rawSections)) {
|
|
201
|
+
const sectionValue = field(rawSections, sectionName);
|
|
202
|
+
if (sectionValue === null)
|
|
203
|
+
sectionMap.delete(sectionName);
|
|
204
|
+
else if (typeof sectionValue === "string")
|
|
205
|
+
sectionMap.set(sectionName, sectionValue);
|
|
206
|
+
else
|
|
207
|
+
fail("Invalid text context.");
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const rawRemoved = field(message, "toolsRemoved");
|
|
211
|
+
if (rawRemoved !== undefined) {
|
|
212
|
+
for (const ref of isDenseArray(rawRemoved)) {
|
|
213
|
+
if (!isRecord(ref))
|
|
214
|
+
fail("Invalid text context.");
|
|
215
|
+
const removedName = field(ref, "name", true);
|
|
216
|
+
if (typeof removedName !== "string" || !removedName)
|
|
217
|
+
fail("Invalid text context.");
|
|
218
|
+
toolMap.delete(removedName);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const rawAdded = field(message, "toolsAdded");
|
|
222
|
+
if (rawAdded !== undefined) {
|
|
223
|
+
for (const tool of isDenseArray(rawAdded)) {
|
|
224
|
+
const addedName = isRecord(tool) ? field(tool, "name") : undefined;
|
|
225
|
+
toolMap.set(typeof addedName === "string" && addedName ? addedName : Symbol("tool"), tool);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const basePrompt = systemContentParts.join("\n\n");
|
|
230
|
+
const transcriptPrompt = [basePrompt, ...sectionMap.values()].filter((part) => part.length > 0).join("\n\n");
|
|
231
|
+
const effectiveSystemPrompt = typeof rawSystemPrompt === "string"
|
|
232
|
+
? [rawSystemPrompt, transcriptPrompt].filter((part) => part.length > 0).join("\n\n")
|
|
233
|
+
: (transcriptPrompt.length > 0 ? transcriptPrompt : undefined);
|
|
234
|
+
const effectiveTools = toolMap.size > 0 ? [...toolMap.values()] : (rawTools !== undefined ? [] : undefined);
|
|
235
|
+
return { systemPrompt: effectiveSystemPrompt, tools: effectiveTools, messages: conversationMessages };
|
|
236
|
+
}
|
|
237
|
+
function extractSystemMessageContent(content) {
|
|
238
|
+
if (typeof content === "string")
|
|
239
|
+
return content;
|
|
240
|
+
const parts = isDenseArray(content);
|
|
241
|
+
const texts = [];
|
|
242
|
+
for (const item of parts) {
|
|
243
|
+
if (!isRecord(item) || field(item, "type", true) !== "text")
|
|
244
|
+
fail("Only text context is supported by this provider.");
|
|
245
|
+
const text = field(item, "text", true);
|
|
246
|
+
if (typeof text !== "string")
|
|
247
|
+
fail("Only text context is supported by this provider.");
|
|
248
|
+
texts.push(text);
|
|
249
|
+
}
|
|
250
|
+
return texts.join("\n");
|
|
251
|
+
}
|
|
136
252
|
function capabilityError(publicId, reasoning, capability) {
|
|
137
253
|
const reason = capability.state === "disabled" ? capability.reason : capability.state;
|
|
138
254
|
return `PI_TOOL_CAPABILITY_NOT_ENABLED: ${publicId}/${reasoning} is ${capability.state} (${reason}).`;
|
|
139
255
|
}
|
|
140
|
-
function
|
|
141
|
-
const tools =
|
|
256
|
+
function isToolBearingNormalizedContext(context) {
|
|
257
|
+
const tools = context.tools;
|
|
142
258
|
if (tools !== undefined && isDenseArray(tools).length > 0)
|
|
143
259
|
return true;
|
|
144
|
-
const
|
|
145
|
-
for (const message of messages) {
|
|
260
|
+
for (const message of context.messages) {
|
|
146
261
|
if (!isRecord(message))
|
|
147
262
|
continue;
|
|
148
263
|
if (field(message, "role") === "toolResult")
|
|
@@ -234,13 +349,13 @@ function validThoughtSignature(value) {
|
|
|
234
349
|
return undefined;
|
|
235
350
|
return /^[A-Za-z0-9+/]+={0,2}$/.test(value) ? value : undefined;
|
|
236
351
|
}
|
|
237
|
-
function validateOptions(options) {
|
|
352
|
+
function validateOptions(options, maxAllowedTokens) {
|
|
238
353
|
if (options === undefined)
|
|
239
354
|
return;
|
|
240
355
|
if (!isRecord(options))
|
|
241
356
|
fail("Invalid generation options.");
|
|
242
357
|
const reasoning = option(options, "reasoning"), budgets = option(options, "thinkingBudgets"), deferred = option(options, "deferred"), toolChoice = option(options, "toolChoice"), sampling = option(options, "samplingParams"), temperature = option(options, "temperature"), maxTokens = option(options, "maxTokens"), headers = option(options, "headers");
|
|
243
|
-
if (reasoning !== undefined && reasoning !== "off" && !isThinkingLevel(reasoning)
|
|
358
|
+
if (reasoning !== undefined && reasoning !== "off" && !isThinkingLevel(reasoning))
|
|
244
359
|
fail("Unsupported reasoning level.");
|
|
245
360
|
if (budgets !== undefined)
|
|
246
361
|
fail("Thinking budgets are not supported.");
|
|
@@ -252,8 +367,8 @@ function validateOptions(options) {
|
|
|
252
367
|
fail("Custom generation options are not supported.");
|
|
253
368
|
if (temperature !== undefined && (typeof temperature !== "number" || !Number.isFinite(temperature) || temperature < 0 || temperature > 2))
|
|
254
369
|
fail("Temperature must be finite and between 0 and 2.");
|
|
255
|
-
if (maxTokens !== undefined && (typeof maxTokens !== "number" || !Number.isInteger(maxTokens) || maxTokens <= 0 || maxTokens >
|
|
256
|
-
fail(
|
|
370
|
+
if (maxTokens !== undefined && (typeof maxTokens !== "number" || !Number.isInteger(maxTokens) || maxTokens <= 0 || maxTokens > maxAllowedTokens))
|
|
371
|
+
fail(`maxTokens must be a positive integer no greater than ${maxAllowedTokens}.`);
|
|
257
372
|
if (headers !== undefined && !isRecord(headers))
|
|
258
373
|
fail("Invalid generation options.");
|
|
259
374
|
for (const name of headers ? Object.keys(headers) : [])
|
package/dist/envelope.js
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
export const ANTIGRAVITY_MODEL_ENUM = Object.freeze({
|
|
3
|
+
// Gemini 4 Argon
|
|
4
|
+
"gemini-4-argon-low": "MODEL_PLACEHOLDER_M419",
|
|
5
|
+
"gemini-4-argon-medium": "MODEL_PLACEHOLDER_M418",
|
|
6
|
+
"gemini-4-argon-high": "MODEL_PLACEHOLDER_M417",
|
|
7
|
+
// Gemini 4 Carbon
|
|
8
|
+
"gemini-4-carbon-low": "MODEL_PLACEHOLDER_M438",
|
|
9
|
+
"gemini-4-carbon-medium": "MODEL_PLACEHOLDER_M437",
|
|
10
|
+
"gemini-4-carbon-high": "MODEL_PLACEHOLDER_M427",
|
|
11
|
+
// Gemini 4 Neon
|
|
12
|
+
"gemini-4-neon-low": "MODEL_PLACEHOLDER_M534",
|
|
13
|
+
"gemini-4-neon-medium": "MODEL_PLACEHOLDER_M533",
|
|
14
|
+
"gemini-4-neon-high": "MODEL_PLACEHOLDER_M532",
|
|
15
|
+
"gemini-4-neon-xhigh": "MODEL_PLACEHOLDER_M535",
|
|
16
|
+
// Gemini 4 Hydrogen
|
|
17
|
+
"gemini-4-hydrogen-low": "MODEL_PLACEHOLDER_M527",
|
|
18
|
+
"gemini-4-hydrogen-medium": "MODEL_PLACEHOLDER_M526",
|
|
19
|
+
"gemini-4-hydrogen-high": "MODEL_PLACEHOLDER_M525",
|
|
20
|
+
"gemini-4-hydrogen-xhigh": "MODEL_PLACEHOLDER_M528",
|
|
21
|
+
"gemini-4-hydrogen-tiered-high": "MODEL_PLACEHOLDER_M530",
|
|
22
|
+
"gemini-4-hydrogen-tiered-xhigh": "MODEL_PLACEHOLDER_M531",
|
|
23
|
+
"gemini-4-hydrogen-sonar": "MODEL_PLACEHOLDER_M578",
|
|
3
24
|
// Gemini 3.8 Flash
|
|
4
25
|
"gemini-3.8-flash": "MODEL_PLACEHOLDER_M318",
|
|
5
26
|
"gemini-3.8-flash-high": "MODEL_PLACEHOLDER_M318",
|
|
@@ -22,6 +43,7 @@ export const ANTIGRAVITY_MODEL_ENUM = Object.freeze({
|
|
|
22
43
|
"gemini-3.5-flash": "MODEL_PLACEHOLDER_M20",
|
|
23
44
|
"gemini-3.5-flash-extra-low": "MODEL_PLACEHOLDER_M187",
|
|
24
45
|
"gemini-3.5-flash-low": "MODEL_PLACEHOLDER_M20",
|
|
46
|
+
"gemini-3.5-flash-lite": "MODEL_PLACEHOLDER_M198",
|
|
25
47
|
"gemini-3-flash-agent": "MODEL_PLACEHOLDER_M84",
|
|
26
48
|
// Gemini 3.1 Pro
|
|
27
49
|
"gemini-3.1-pro": "MODEL_PLACEHOLDER_M36",
|
package/dist/project.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
+
import { formatAntigravityHubUserAgent } from "@benjamolina/antigravity-guard-core";
|
|
2
3
|
const USER_INFO_ENDPOINT = "https://www.googleapis.com/oauth2/v1/userinfo?alt=json";
|
|
3
4
|
const PROJECT_ENDPOINTS = [
|
|
4
5
|
"https://daily-cloudcode-pa.googleapis.com",
|
|
@@ -7,7 +8,7 @@ const PROJECT_ENDPOINTS = [
|
|
|
7
8
|
];
|
|
8
9
|
const MAX_BODY_BYTES = 64 * 1024;
|
|
9
10
|
const REQUEST_TIMEOUT_MS = 10_000;
|
|
10
|
-
const ANTIGRAVITY_USER_AGENT =
|
|
11
|
+
const ANTIGRAVITY_USER_AGENT = formatAntigravityHubUserAgent();
|
|
11
12
|
export async function resolveLoginProject(options) {
|
|
12
13
|
const email = await userEmail(options);
|
|
13
14
|
const projectId = await discoveredProject(options);
|
package/dist/stream.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { calculateCost, createAssistantMessageEventStream } from "@earendil-works/pi-ai";
|
|
2
|
-
import { ANTIGRAVITY_ENDPOINTS } from "@benjamolina/antigravity-guard-core";
|
|
2
|
+
import { ANTIGRAVITY_ENDPOINTS, formatAntigravityHubUserAgent } from "@benjamolina/antigravity-guard-core";
|
|
3
3
|
import { getCatalogEntry, resolveGenerationSelection } from "./catalog.js";
|
|
4
4
|
import { ContextSerializationError, serializeContext } from "./context.js";
|
|
5
5
|
import { ToolPreflightError } from "./tool-contract.js";
|
|
@@ -9,7 +9,7 @@ import { SseFrameError, SseFramer } from "./sse.js";
|
|
|
9
9
|
const TOTAL_TIMEOUT_MS = 120_000;
|
|
10
10
|
const INACTIVITY_TIMEOUT_MS = 30_000;
|
|
11
11
|
const MAX_ERROR_BYTES = 64 * 1024;
|
|
12
|
-
const ANTIGRAVITY_USER_AGENT =
|
|
12
|
+
const ANTIGRAVITY_USER_AGENT = formatAntigravityHubUserAgent();
|
|
13
13
|
const ENDPOINT = `${ANTIGRAVITY_ENDPOINTS.daily}/v1internal:streamGenerateContent?alt=sse`;
|
|
14
14
|
const API = "antigravity-guard-sse";
|
|
15
15
|
const PROTECTED_HEADERS = new Set(["authorization", "host", "content-type", "content-length"]);
|
package/dist/tool-context.js
CHANGED
|
@@ -8,14 +8,48 @@ export function hasToolContext(context) {
|
|
|
8
8
|
if (Array.isArray(tools) && tools.length > 0)
|
|
9
9
|
return true;
|
|
10
10
|
const messages = value(context, "messages");
|
|
11
|
-
|
|
11
|
+
if (!Array.isArray(messages))
|
|
12
|
+
return false;
|
|
13
|
+
const activeTools = new Map();
|
|
14
|
+
for (let index = 0; index < messages.length; index++) {
|
|
15
|
+
const descriptor = Object.getOwnPropertyDescriptor(messages, String(index));
|
|
16
|
+
if (!descriptor || !("value" in descriptor))
|
|
17
|
+
continue;
|
|
18
|
+
const message = descriptor.value;
|
|
12
19
|
if (!isRecord(message))
|
|
13
|
-
|
|
14
|
-
|
|
20
|
+
continue;
|
|
21
|
+
const role = value(message, "role");
|
|
22
|
+
if (role === "toolResult")
|
|
15
23
|
return true;
|
|
24
|
+
if (role === "system") {
|
|
25
|
+
const removed = value(message, "toolsRemoved");
|
|
26
|
+
if (Array.isArray(removed)) {
|
|
27
|
+
for (let r = 0; r < removed.length; r++) {
|
|
28
|
+
const rd = Object.getOwnPropertyDescriptor(removed, String(r));
|
|
29
|
+
const item = rd && "value" in rd ? rd.value : undefined;
|
|
30
|
+
const name = isRecord(item) ? value(item, "name") : undefined;
|
|
31
|
+
if (typeof name === "string" && name)
|
|
32
|
+
activeTools.delete(name);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const added = value(message, "toolsAdded");
|
|
36
|
+
if (Array.isArray(added)) {
|
|
37
|
+
for (let a = 0; a < added.length; a++) {
|
|
38
|
+
const ad = Object.getOwnPropertyDescriptor(added, String(a));
|
|
39
|
+
if (!ad || !("value" in ad))
|
|
40
|
+
continue;
|
|
41
|
+
const item = ad.value;
|
|
42
|
+
const name = isRecord(item) ? value(item, "name") : undefined;
|
|
43
|
+
activeTools.set(typeof name === "string" && name ? name : Symbol("tool"), item);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
16
48
|
const content = value(message, "content");
|
|
17
|
-
|
|
18
|
-
|
|
49
|
+
if (Array.isArray(content) && content.some((part) => isRecord(part) && value(part, "type") === "toolCall"))
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return activeTools.size > 0;
|
|
19
53
|
}
|
|
20
54
|
export function prepareToolContext(tools, choice, schemaProfile) {
|
|
21
55
|
if (schemaProfile !== GEMINI_PARAMETERS_JSON_SCHEMA_PROFILE && schemaProfile !== CLAUDE_CUSTOM_PARAMETERS_PROFILE)
|
package/dist/tool-schema.js
CHANGED
|
@@ -32,7 +32,7 @@ function normalizeDeclaration(value, index, names) {
|
|
|
32
32
|
if (typeof description !== "string" || !description.trim())
|
|
33
33
|
fail("PI_TOOL_DECLARATION_INVALID", name, `${path}.description`);
|
|
34
34
|
const constrainedSampling = ownData(tool, "constrainedSampling", name, path);
|
|
35
|
-
if (constrainedSampling
|
|
35
|
+
if (!isAdmittedConstrainedSampling(constrainedSampling, name, `${path}.constrainedSampling`))
|
|
36
36
|
fail("PI_TOOL_CONSTRAINED_SAMPLING_UNSUPPORTED", name, `${path}.constrainedSampling`);
|
|
37
37
|
const root = plainObject(ownData(tool, "parameters", name, path), name, "$");
|
|
38
38
|
if (ownData(root, "type", name, "$") !== "object")
|
|
@@ -47,6 +47,14 @@ function normalizeDeclaration(value, index, names) {
|
|
|
47
47
|
fail("PI_TOOL_SCHEMA_LIMIT", name, "$");
|
|
48
48
|
return freeze({ name, description, parameters });
|
|
49
49
|
}
|
|
50
|
+
function isAdmittedConstrainedSampling(value, declaration, path) {
|
|
51
|
+
if (value === undefined || value === false)
|
|
52
|
+
return true;
|
|
53
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
54
|
+
return false;
|
|
55
|
+
const config = plainObject(value, declaration, path);
|
|
56
|
+
return ownData(config, "type", declaration, path) === "json_schema" && ownData(config, "strict", declaration, path) === "prefer";
|
|
57
|
+
}
|
|
50
58
|
function snapshotJson(value, declaration, path, state, depth = 0) {
|
|
51
59
|
if (depth > MAX_SCHEMA_DEPTH || ++state.nodes > MAX_SCHEMA_NODES)
|
|
52
60
|
fail("PI_TOOL_SCHEMA_LIMIT", declaration, path);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@benjamolina/pi-antigravity-guard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Pi adapter for Antigravity Guard",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
]
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@benjamolina/antigravity-guard-core": "0.
|
|
32
|
+
"@benjamolina/antigravity-guard-core": "0.2.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@earendil-works/pi-ai": "*",
|