@cortexkit/opencode-antigravity-auth 3.0.31 → 3.0.33

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.
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Optional THALAMUS routing for vault mode and advisory turn notes for request
3
+ * shaping. Account ids are vault account ids, not local pool rows. Nothing is
4
+ * persisted here; plugins on routes the runner does not serve get no turn notes.
5
+ */
1
6
  /** An eligible vault route, not a local pool row. */
2
7
  export interface RoutingCandidate {
3
8
  /** Vault account id, not the plugin's route id. */
@@ -35,7 +40,7 @@ interface RoutingReportIdentity {
35
40
  accountId: string;
36
41
  credentialId?: string;
37
42
  }
38
- export type ReportRoutingInput = RoutingReportIdentity & ({
43
+ export type ReportRoutingInput = (RoutingReportIdentity & ({
39
44
  outcome: 'served';
40
45
  /**
41
46
  * Pass only rate-limit headers, never the whole response headers.
@@ -56,7 +61,26 @@ export type ReportRoutingInput = RoutingReportIdentity & ({
56
61
  pool?: string;
57
62
  /** Optional reset time in epoch milliseconds. */
58
63
  resetsAt?: number;
59
- });
64
+ })) | {
65
+ sessionId: string;
66
+ kind: 'turn_notes_supported';
67
+ model: string;
68
+ supported: boolean;
69
+ } | {
70
+ sessionId: string;
71
+ kind: 'turn_note_skipped';
72
+ after_tool_use_id: string;
73
+ reason: 'anchor_missing' | 'before_user_message' | 'unsupported_model' | 'not_oauth';
74
+ };
75
+ /**
76
+ * Read advisory input for request shaping, in landing order, without persisting
77
+ * it. If no routing handle is available or the runner does not serve the route,
78
+ * returns [].
79
+ */
80
+ export declare function turnNotes(sessionId: string): readonly {
81
+ afterToolUseId: string;
82
+ text: string;
83
+ }[];
60
84
  /**
61
85
  * Ask routing for an eligible vault route. Any failure or unfamiliar answer
62
86
  * yields undefined so the plugin can keep its own choice. This does not admit
@@ -64,9 +88,10 @@ export type ReportRoutingInput = RoutingReportIdentity & ({
64
88
  */
65
89
  export declare function askRouting<Candidate extends RoutingCandidate>(input: AskRoutingInput<Candidate>): Promise<RoutingSelection<Candidate> | undefined>;
66
90
  /**
67
- * Report a vault request without waiting for routing. Only contract fields are
68
- * sent, and all accessor failures are ignored. Headers must already be limited
69
- * to rate-limit headers by the caller; values are not filtered or redacted here.
91
+ * Report a vault request or turn-note event without waiting for routing. Only
92
+ * contract fields are sent, and all accessor failures are ignored. Headers must
93
+ * already be limited to rate-limit headers by the caller; values are not filtered
94
+ * or redacted here.
70
95
  */
71
96
  export declare function reportRouting(input: ReportRoutingInput): void;
72
97
  export {};
@@ -1,9 +1,60 @@
1
- // Optional THALAMUS routing for vault mode only. Account ids here are vault
2
- // account ids; local pool rows are not known to the routing engine.
1
+ /**
2
+ * Optional THALAMUS routing for vault mode and advisory turn notes for request
3
+ * shaping. Account ids are vault account ids, not local pool rows. Nothing is
4
+ * persisted here; plugins on routes the runner does not serve get no turn notes.
5
+ */
3
6
  import { routingHandle } from './handle.js';
4
7
  function isObject(value) {
5
8
  return typeof value === 'object' && value !== null;
6
9
  }
10
+ /**
11
+ * Read advisory input for request shaping, in landing order, without persisting
12
+ * it. If no routing handle is available or the runner does not serve the route,
13
+ * returns [].
14
+ */
15
+ export function turnNotes(sessionId) {
16
+ try {
17
+ const handle = routingHandle(sessionId);
18
+ if (!handle)
19
+ return [];
20
+ const read = handle.turn_notes;
21
+ if (typeof read !== 'function')
22
+ return [];
23
+ const answer = read.call(handle);
24
+ if (isObject(answer) && typeof answer.then === 'function') {
25
+ void Promise.resolve(answer).catch(() => { });
26
+ return [];
27
+ }
28
+ if (!Array.isArray(answer))
29
+ return [];
30
+ const notes = [];
31
+ const encoder = new TextEncoder();
32
+ for (const entry of answer) {
33
+ try {
34
+ if (!isObject(entry) || Array.isArray(entry))
35
+ continue;
36
+ const afterToolUseId = entry.after_tool_use_id;
37
+ const text = entry.text;
38
+ if (typeof afterToolUseId !== 'string' ||
39
+ afterToolUseId.length === 0 ||
40
+ typeof text !== 'string' ||
41
+ // A whitespace-only note says nothing and a provider may refuse it.
42
+ text.trim().length === 0 ||
43
+ encoder.encode(text).byteLength > 16_384)
44
+ continue;
45
+ notes.push({ afterToolUseId, text });
46
+ }
47
+ catch {
48
+ // One unreadable note entry must not hide its valid neighbours.
49
+ }
50
+ }
51
+ return notes;
52
+ }
53
+ catch {
54
+ // Turn notes are optional and must not break request shaping.
55
+ return [];
56
+ }
57
+ }
7
58
  function selectionFor(answer, candidates) {
8
59
  if (!isObject(answer))
9
60
  return undefined;
@@ -72,9 +123,10 @@ export async function askRouting(input) {
72
123
  }
73
124
  }
74
125
  /**
75
- * Report a vault request without waiting for routing. Only contract fields are
76
- * sent, and all accessor failures are ignored. Headers must already be limited
77
- * to rate-limit headers by the caller; values are not filtered or redacted here.
126
+ * Report a vault request or turn-note event without waiting for routing. Only
127
+ * contract fields are sent, and all accessor failures are ignored. Headers must
128
+ * already be limited to rate-limit headers by the caller; values are not filtered
129
+ * or redacted here.
78
130
  */
79
131
  export function reportRouting(input) {
80
132
  try {
@@ -84,38 +136,75 @@ export function reportRouting(input) {
84
136
  const report = handle.report;
85
137
  if (typeof report !== 'function')
86
138
  return;
87
- const identity = {
88
- account_id: input.accountId,
89
- ...(input.credentialId !== undefined
90
- ? { credential_id: input.credentialId }
91
- : {}),
92
- };
93
139
  let payload;
94
- switch (input.outcome) {
95
- case 'served':
96
- payload = { ...identity, outcome: 'served', headers: input.headers };
97
- break;
98
- case 'exhausted': {
99
- const { window, pool } = input;
100
- if (window !== '5h' && window !== '7d')
140
+ if ('kind' in input) {
141
+ switch (input.kind) {
142
+ case 'turn_notes_supported': {
143
+ const { model, supported } = input;
144
+ if (typeof model !== 'string' ||
145
+ model.length === 0 ||
146
+ typeof supported !== 'boolean')
147
+ return;
148
+ payload = {
149
+ kind: 'turn_notes_supported',
150
+ model,
151
+ supported,
152
+ };
153
+ break;
154
+ }
155
+ case 'turn_note_skipped': {
156
+ const { after_tool_use_id, reason } = input;
157
+ if (typeof after_tool_use_id !== 'string' ||
158
+ after_tool_use_id.length === 0 ||
159
+ (reason !== 'anchor_missing' &&
160
+ reason !== 'before_user_message' &&
161
+ reason !== 'unsupported_model' &&
162
+ reason !== 'not_oauth'))
163
+ return;
164
+ payload = {
165
+ kind: 'turn_note_skipped',
166
+ after_tool_use_id,
167
+ reason,
168
+ };
169
+ break;
170
+ }
171
+ default:
101
172
  return;
102
- // An undefined pool means the whole account, as an omitted one does.
103
- if (pool !== undefined &&
104
- (typeof pool !== 'string' || !/^[a-z0-9._-]{1,64}$/.test(pool)))
173
+ }
174
+ }
175
+ else {
176
+ const identity = {
177
+ account_id: input.accountId,
178
+ ...(input.credentialId !== undefined
179
+ ? { credential_id: input.credentialId }
180
+ : {}),
181
+ };
182
+ switch (input.outcome) {
183
+ case 'served':
184
+ payload = { ...identity, outcome: 'served', headers: input.headers };
185
+ break;
186
+ case 'exhausted': {
187
+ const { window, pool } = input;
188
+ if (window !== '5h' && window !== '7d')
189
+ return;
190
+ // An undefined pool means the whole account, as an omitted one does.
191
+ if (pool !== undefined &&
192
+ (typeof pool !== 'string' || !/^[a-z0-9._-]{1,64}$/.test(pool)))
193
+ return;
194
+ payload = {
195
+ ...identity,
196
+ outcome: 'exhausted',
197
+ window,
198
+ ...(pool ? { pool } : {}),
199
+ ...(input.resetsAt !== undefined
200
+ ? { resets_at: input.resetsAt }
201
+ : {}),
202
+ };
203
+ break;
204
+ }
205
+ default:
105
206
  return;
106
- payload = {
107
- ...identity,
108
- outcome: 'exhausted',
109
- window,
110
- ...(pool ? { pool } : {}),
111
- ...(input.resetsAt !== undefined
112
- ? { resets_at: input.resetsAt }
113
- : {}),
114
- };
115
- break;
116
207
  }
117
- default:
118
- return;
119
208
  }
120
209
  // A broken bridge may return a rejected promise despite its void contract.
121
210
  const pending = report.call(handle, payload);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema": 1,
3
3
  "package": "@cortexkit/common-auth",
4
- "version": "0.38.0",
4
+ "version": "0.39.1",
5
5
  "artifactStatus": "published",
6
6
  "publicRoots": {
7
7
  "./rpc": {
@@ -69,15 +69,15 @@
69
69
  "import": "./src/quota-sidebar/index.tsx"
70
70
  }
71
71
  },
72
- "input": "tools/common-auth-build/inputs/cortexkit-common-auth-0.38.0.tgz",
73
- "tarballSha256": "bbe2dc4c05145544beceac22282c3cc1fde9e6fbfcaa04452790cc9a6cc20557",
74
- "sri": "sha512-YDXtwuuj/gz4h/bPO+UAVItjo3ZMYw9DhccEf4DWAk8dr+Rk/uo/cVUeTRbC4xXE7FXTeBr1HaRnyG7drZIg3w==",
72
+ "input": "tools/common-auth-build/inputs/cortexkit-common-auth-0.39.1.tgz",
73
+ "tarballSha256": "7d4eae5c55f007b6ca1838d0e85552685cc0dac0080594d108da63f69d1c9577",
74
+ "sri": "sha512-Oap+vs4zKFLdFA8iUgvS3X1iOI/xZaXQyhYoDSlUBsjsCutcZZ0M0bXY9C0a16fBFgmmcReXb3Pn3+P9Bebjng==",
75
75
  "canonicalFiles": 216,
76
- "canonicalBytes": 1348812,
76
+ "canonicalBytes": 1355096,
77
77
  "generator": {
78
78
  "path": "packages/opencode/scripts/embed-common-auth.ts",
79
79
  "version": 4,
80
- "sha256": "96e1464c7d9f7d0cedc165ed7f455e38b8bf4dea7a58f1aa7f7782d956f711ea"
80
+ "sha256": "c6a4180f5d873855ea5abaeeeaea39e2beba2309da75dfb20c4cc3d485eda38f"
81
81
  },
82
82
  "files": [
83
83
  {
@@ -643,17 +643,17 @@
643
643
  {
644
644
  "source": "package/dist/fs/refresh-file-lock.d.ts",
645
645
  "output": "fs/refresh-file-lock.d.ts",
646
- "bytes": 3052,
647
- "sourceSha256": "31c23ba9135ddc57ea0196ad56280bd12eab2c9524d33bd43d78112da27214d2",
648
- "outputSha256": "31c23ba9135ddc57ea0196ad56280bd12eab2c9524d33bd43d78112da27214d2",
646
+ "bytes": 3402,
647
+ "sourceSha256": "fefff72fcbbcedd80d96cea0f15d7a367220af76ea8c4dfea3f81f83b9931ab1",
648
+ "outputSha256": "fefff72fcbbcedd80d96cea0f15d7a367220af76ea8c4dfea3f81f83b9931ab1",
649
649
  "transform": "verbatim"
650
650
  },
651
651
  {
652
652
  "source": "package/dist/fs/refresh-file-lock.js",
653
653
  "output": "fs/refresh-file-lock.js",
654
- "bytes": 42093,
655
- "sourceSha256": "a91c34ec1dcac86a816a70359a16e27bf5f8a52cb12f9e1d8162548bbcd69d4e",
656
- "outputSha256": "a91c34ec1dcac86a816a70359a16e27bf5f8a52cb12f9e1d8162548bbcd69d4e",
654
+ "bytes": 43780,
655
+ "sourceSha256": "fa0200d4f4a759a8d4380aa2535cf07d98898650cc919031b0742d241662d96f",
656
+ "outputSha256": "fa0200d4f4a759a8d4380aa2535cf07d98898650cc919031b0742d241662d96f",
657
657
  "transform": "verbatim"
658
658
  },
659
659
  {
@@ -1795,17 +1795,17 @@
1795
1795
  {
1796
1796
  "source": "package/dist/routing-accessor/index.d.ts",
1797
1797
  "output": "routing-accessor/index.d.ts",
1798
- "bytes": 3080,
1799
- "sourceSha256": "9cdfea24f5c4a2e20758b3fc934c912aa42d56f14e25cd0e4134660dde9478d5",
1800
- "outputSha256": "9cdfea24f5c4a2e20758b3fc934c912aa42d56f14e25cd0e4134660dde9478d5",
1798
+ "bytes": 3941,
1799
+ "sourceSha256": "04f480934ab1cd05585abb816014ac37cca32ccf783e90a98dd101513edf7f04",
1800
+ "outputSha256": "04f480934ab1cd05585abb816014ac37cca32ccf783e90a98dd101513edf7f04",
1801
1801
  "transform": "verbatim"
1802
1802
  },
1803
1803
  {
1804
1804
  "source": "package/dist/routing-accessor/index.js",
1805
1805
  "output": "routing-accessor/index.js",
1806
- "bytes": 4904,
1807
- "sourceSha256": "92360e9b5d1549f8f6348072554fdf47456dedcaa39b278721cbc341b588a6f5",
1808
- "outputSha256": "92360e9b5d1549f8f6348072554fdf47456dedcaa39b278721cbc341b588a6f5",
1806
+ "bytes": 8290,
1807
+ "sourceSha256": "ea80ae669e1f65555e88e5c56383d6e1a5ee813de532ffade61011bb4eeea16d",
1808
+ "outputSha256": "ea80ae669e1f65555e88e5c56383d6e1a5ee813de532ffade61011bb4eeea16d",
1809
1809
  "transform": "verbatim"
1810
1810
  }
1811
1811
  ],