@cortexkit/opencode-antigravity-auth 3.0.36 → 3.0.37

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.
Files changed (47) hide show
  1. package/dist/cli.js +6 -1
  2. package/dist/cli.js.map +2 -2
  3. package/dist/cli.meta.json +11 -11
  4. package/dist/index.js +12 -7
  5. package/dist/index.js.map +2 -2
  6. package/dist/index.meta.json +29 -13
  7. package/dist/server.js +15 -10
  8. package/dist/server.js.map +2 -2
  9. package/dist/server.meta.json +1 -1
  10. package/dist/src/common-auth-embedded/claustrum/availability.d.ts +1 -0
  11. package/dist/src/common-auth-embedded/claustrum/availability.js +2 -0
  12. package/dist/src/common-auth-embedded/claustrum/index.d.ts +1 -1
  13. package/dist/src/common-auth-embedded/claustrum/index.js +1 -1
  14. package/dist/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +51 -0
  15. package/dist/src/common-auth-embedded/routing-accessor/cache-policy.js +186 -0
  16. package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +2 -1
  17. package/dist/src/common-auth-embedded/routing-accessor/index.js +1 -0
  18. package/dist/src/common-auth-embedded/source-output.json +41 -25
  19. package/dist/src/ga/server/auth.js +1 -1
  20. package/dist/src/ga/server/auth.js.map +1 -1
  21. package/dist/src/ga/server/index.js +1 -1
  22. package/dist/src/ga/server/index.js.map +1 -1
  23. package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
  24. package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
  25. package/dist/src/plugin/ga-location-services.js +2 -2
  26. package/dist/src/plugin/ga-location-services.js.map +1 -1
  27. package/dist/src/plugin/vault-custody.js +6 -6
  28. package/dist/src/plugin/vault-custody.js.map +1 -1
  29. package/dist/src/setup.js +1 -1
  30. package/dist/src/setup.js.map +1 -1
  31. package/dist/tui-build-map.json +1 -1
  32. package/dist/tui-ga-build-map.json +1 -1
  33. package/dist/types/src/common-auth-embedded/claustrum/availability.d.ts +1 -0
  34. package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +1 -1
  35. package/dist/types/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +51 -0
  36. package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +2 -1
  37. package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
  38. package/package.json +4 -4
  39. package/src/common-auth-embedded/claustrum/availability.d.ts +1 -0
  40. package/src/common-auth-embedded/claustrum/availability.js +2 -0
  41. package/src/common-auth-embedded/claustrum/index.d.ts +1 -1
  42. package/src/common-auth-embedded/claustrum/index.js +1 -1
  43. package/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +51 -0
  44. package/src/common-auth-embedded/routing-accessor/cache-policy.js +186 -0
  45. package/src/common-auth-embedded/routing-accessor/index.d.ts +2 -1
  46. package/src/common-auth-embedded/routing-accessor/index.js +1 -0
  47. package/src/common-auth-embedded/source-output.json +41 -25
@@ -0,0 +1,186 @@
1
+ import { routingHandle } from './handle.js';
2
+ const warned = new Set();
3
+ // Inspect descriptors rather than values so warning deduplication cannot invoke
4
+ // a broken bridge's getters a second time. Do not print policy contents.
5
+ function shape(value, seen = new Set()) {
6
+ if (typeof value !== 'object' || value === null) {
7
+ return `${typeof value}:${String(value)}`;
8
+ }
9
+ if (seen.has(value))
10
+ return 'cycle';
11
+ seen.add(value);
12
+ return `${Array.isArray(value) ? 'array' : 'object'}:{${Object.entries(Object.getOwnPropertyDescriptors(value))
13
+ .sort(([a], [b]) => a.localeCompare(b))
14
+ .map(([key, descriptor]) => `${key}:${'value' in descriptor ? shape(descriptor.value, seen) : 'accessor'}`)
15
+ .join(',')}}`;
16
+ }
17
+ function invalid(kind, value) {
18
+ let fingerprint = 'unreadable';
19
+ try {
20
+ fingerprint = shape(value);
21
+ }
22
+ catch {
23
+ // Uninspectable proxies share one diagnostic shape, without invoking getters.
24
+ }
25
+ try {
26
+ const key = `${kind}:${fingerprint}`;
27
+ if (!warned.has(key)) {
28
+ warned.add(key);
29
+ console.warn(`[common-auth] Ignoring invalid session ${kind} policy`);
30
+ }
31
+ }
32
+ catch {
33
+ // A broken warning sink must not break a request either.
34
+ }
35
+ return null;
36
+ }
37
+ function record(value) {
38
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
39
+ }
40
+ function rejectAsync(value) {
41
+ if (typeof value.then !== 'function')
42
+ return false;
43
+ // Absorb a rejected promise from a bridge that broke the synchronous contract.
44
+ void Promise.resolve(value).catch(() => { });
45
+ return true;
46
+ }
47
+ function onlyKeys(value, keys) {
48
+ return Reflect.ownKeys(value).every((key) => typeof key === 'string' && keys.includes(key));
49
+ }
50
+ /**
51
+ * Read the session's current plan on every decision; never retain it across
52
+ * requests. Null means the plugin keeps its own settings. No I/O or exceptions.
53
+ */
54
+ export function sessionCachePolicy(sessionId) {
55
+ let answer;
56
+ try {
57
+ const handle = routingHandle(sessionId);
58
+ if (!handle)
59
+ return null;
60
+ const read = handle.cache;
61
+ if (typeof read !== 'function')
62
+ return null;
63
+ answer = read.call(handle);
64
+ if (answer === null)
65
+ return null;
66
+ if (!record(answer) || rejectAsync(answer))
67
+ return invalid('cache', answer);
68
+ const { ttl, keep_warm, hours } = answer;
69
+ if (!onlyKeys(answer, ['ttl', 'keep_warm', 'hours']) ||
70
+ (ttl !== undefined &&
71
+ ttl !== 'none' &&
72
+ ttl !== 'short' &&
73
+ ttl !== 'long') ||
74
+ (keep_warm !== undefined &&
75
+ keep_warm !== 'off' &&
76
+ keep_warm !== 'hours' &&
77
+ keep_warm !== 'always' &&
78
+ keep_warm !== 'auto') ||
79
+ (ttl === 'none' && keep_warm !== undefined && keep_warm !== 'off') ||
80
+ (keep_warm !== 'hours' && 'hours' in answer)) {
81
+ return invalid('cache', answer);
82
+ }
83
+ const policy = {
84
+ ...(ttl !== undefined ? { ttl } : {}),
85
+ ...(keep_warm !== undefined ? { keep_warm } : {}),
86
+ };
87
+ if (keep_warm === 'hours') {
88
+ if (!record(hours) || !onlyKeys(hours, ['from', 'to', 'tz'])) {
89
+ return invalid('cache', answer);
90
+ }
91
+ const { from, to, tz } = hours;
92
+ const time = /^(?:[01]\d|2[0-3]):[0-5]\d$/;
93
+ if (typeof from !== 'string' ||
94
+ !time.test(from) ||
95
+ typeof to !== 'string' ||
96
+ !time.test(to) ||
97
+ from === to ||
98
+ typeof tz !== 'string' ||
99
+ tz.length === 0) {
100
+ return invalid('cache', answer);
101
+ }
102
+ new Intl.DateTimeFormat('en', { timeZone: tz });
103
+ policy.hours = { from, to, tz };
104
+ }
105
+ return policy;
106
+ }
107
+ catch {
108
+ return invalid('cache', answer);
109
+ }
110
+ }
111
+ /** Read the oldest running plan tool afresh, without I/O or exceptions. */
112
+ export function sessionToolWait(sessionId) {
113
+ let answer;
114
+ try {
115
+ const handle = routingHandle(sessionId);
116
+ if (!handle)
117
+ return null;
118
+ const read = handle.tool_wait;
119
+ if (typeof read !== 'function')
120
+ return null;
121
+ answer = read.call(handle);
122
+ if (answer === null)
123
+ return null;
124
+ if (!record(answer) || rejectAsync(answer))
125
+ return invalid('tool_wait', answer);
126
+ const { since } = answer;
127
+ if (!onlyKeys(answer, ['since']) ||
128
+ typeof since !== 'number' ||
129
+ !Number.isSafeInteger(since) ||
130
+ since < 0) {
131
+ return invalid('tool_wait', answer);
132
+ }
133
+ return { since };
134
+ }
135
+ catch {
136
+ return invalid('tool_wait', answer);
137
+ }
138
+ }
139
+ function report(sessionId, payload) {
140
+ const handle = routingHandle(sessionId);
141
+ if (!handle)
142
+ return;
143
+ const send = handle.report;
144
+ if (typeof send !== 'function')
145
+ return;
146
+ const pending = send.call(handle, payload);
147
+ if (record(pending) && typeof pending.then === 'function') {
148
+ void Promise.resolve(pending).catch(() => { });
149
+ }
150
+ }
151
+ /**
152
+ * Call only after the reply has been handed to the host, never on the awaited
153
+ * request path. Synchronous fire-and-forget, with no retries; the bridge owns
154
+ * redelivery of the newest touch. Accessor and report failures are absorbed.
155
+ */
156
+ export function reportCacheTouch(sessionId, input) {
157
+ try {
158
+ const { at, ttlMs, source } = input;
159
+ if (!Number.isSafeInteger(at) ||
160
+ at < 0 ||
161
+ (ttlMs !== 'implicit' &&
162
+ (typeof ttlMs !== 'number' || !Number.isFinite(ttlMs) || ttlMs < 0)) ||
163
+ (source !== 'response' && source !== 'warm'))
164
+ return;
165
+ report(sessionId, { kind: 'cache_touch', at, ttl_ms: ttlMs, source });
166
+ }
167
+ catch {
168
+ // Optional reporting must never change the result of an auth request.
169
+ }
170
+ }
171
+ /**
172
+ * Call off the request path, after handing the reply to the host. Report only
173
+ * a session that actually warmed, never one that was off from the start.
174
+ * Synchronous fire-and-forget; failures are absorbed and never retried here.
175
+ */
176
+ export function reportCacheWarmStopped(sessionId, input) {
177
+ try {
178
+ const { at, reason } = input;
179
+ if (!Number.isSafeInteger(at) || at < 0 || typeof reason !== 'string')
180
+ return;
181
+ report(sessionId, { kind: 'cache_warm_stopped', at, reason });
182
+ }
183
+ catch {
184
+ // Optional reporting must never change the result of an auth request.
185
+ }
186
+ }
@@ -3,6 +3,8 @@
3
3
  * shaping. Account ids are vault account ids, not local pool rows. Nothing is
4
4
  * persisted here; plugins on routes the runner does not serve get no turn notes.
5
5
  */
6
+ export type { CacheTouchInput, CacheWarmStoppedInput, CacheWarmStopReason, SessionCacheHours, SessionCachePolicy, SessionCacheTtl, SessionKeepWarmMode, SessionToolWait, } from './cache-policy.js';
7
+ export { reportCacheTouch, reportCacheWarmStopped, sessionCachePolicy, sessionToolWait, } from './cache-policy.js';
6
8
  /** An eligible vault route, not a local pool row. */
7
9
  export interface RoutingCandidate {
8
10
  /** Vault account id, not the plugin's route id. */
@@ -94,4 +96,3 @@ export declare function askRouting<Candidate extends RoutingCandidate>(input: As
94
96
  * or redacted here.
95
97
  */
96
98
  export declare function reportRouting(input: ReportRoutingInput): void;
97
- export {};
@@ -4,6 +4,7 @@
4
4
  * persisted here; plugins on routes the runner does not serve get no turn notes.
5
5
  */
6
6
  import { routingHandle } from './handle.js';
7
+ export { reportCacheTouch, reportCacheWarmStopped, sessionCachePolicy, sessionToolWait, } from './cache-policy.js';
7
8
  function isObject(value) {
8
9
  return typeof value === 'object' && value !== null;
9
10
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema": 1,
3
3
  "package": "@cortexkit/common-auth",
4
- "version": "0.40.0",
4
+ "version": "0.42.0",
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.40.0.tgz",
73
- "tarballSha256": "c1346992a2f15355b9304e729ff2ff47de9bf07d578563b9f0c6f83b969253b4",
74
- "sri": "sha512-P0rfQ+fRXTBhAAG0rWkcP2CXkDb32Zplo37qpQx6TINHi78yzp8kNEnHSSwSeEReH5imh7hptg9L69AYCg4Jdw==",
75
- "canonicalFiles": 218,
76
- "canonicalBytes": 1365319,
72
+ "input": "tools/common-auth-build/inputs/cortexkit-common-auth-0.42.0.tgz",
73
+ "tarballSha256": "c3f1c832fe8391529be331c1e2f5577b60eaa7a1c848e97f6668aca06118af04",
74
+ "sri": "sha512-LAZ67qRdJA+9SmglIyDRtEd2Wz+6X2dDRTC+qXt6HryQzir87LIiY+sWWllWT707agUA9rxOocCCP6e+mwoZyA==",
75
+ "canonicalFiles": 220,
76
+ "canonicalBytes": 1374785,
77
77
  "generator": {
78
78
  "path": "packages/opencode/scripts/embed-common-auth.ts",
79
79
  "version": 4,
80
- "sha256": "3d9e00d8b43c67a911c6b14648432aad4d43c85d210c9dc5a3e9524cf67aff3c"
80
+ "sha256": "225a77c54d91e241bbece24dc289ce479330d00c20304ff8508ceb59975728c4"
81
81
  },
82
82
  "files": [
83
83
  {
@@ -243,17 +243,17 @@
243
243
  {
244
244
  "source": "package/dist/claustrum/availability.d.ts",
245
245
  "output": "claustrum/availability.d.ts",
246
- "bytes": 3375,
247
- "sourceSha256": "eba8ff78abed434be6194715d214a53322f4414a28e6a7389fe14f8a52b772ac",
248
- "outputSha256": "eba8ff78abed434be6194715d214a53322f4414a28e6a7389fe14f8a52b772ac",
246
+ "bytes": 3406,
247
+ "sourceSha256": "a77a53ae0220230273b124b7793e2d8842ab3841bfab1d987309411752f7b80a",
248
+ "outputSha256": "a77a53ae0220230273b124b7793e2d8842ab3841bfab1d987309411752f7b80a",
249
249
  "transform": "verbatim"
250
250
  },
251
251
  {
252
252
  "source": "package/dist/claustrum/availability.js",
253
253
  "output": "claustrum/availability.js",
254
- "bytes": 4107,
255
- "sourceSha256": "4bfb03de131ed7d036631a6d6455cc6f465ab7a9ea61575a7378d2f447c7cf67",
256
- "outputSha256": "4bfb03de131ed7d036631a6d6455cc6f465ab7a9ea61575a7378d2f447c7cf67",
254
+ "bytes": 4219,
255
+ "sourceSha256": "07fe16b372bb3dbf5870725b4ea8e2b4c3e50e5d7394fa365de789f72ff01b04",
256
+ "outputSha256": "07fe16b372bb3dbf5870725b4ea8e2b4c3e50e5d7394fa365de789f72ff01b04",
257
257
  "transform": "verbatim"
258
258
  },
259
259
  {
@@ -371,17 +371,17 @@
371
371
  {
372
372
  "source": "package/dist/claustrum/index.d.ts",
373
373
  "output": "claustrum/index.d.ts",
374
- "bytes": 4923,
375
- "sourceSha256": "17fe239561e9a3c8769cef79b08ca279b6d359ab9946fe03e40f1f285edadf03",
376
- "outputSha256": "17fe239561e9a3c8769cef79b08ca279b6d359ab9946fe03e40f1f285edadf03",
374
+ "bytes": 4937,
375
+ "sourceSha256": "9270d05fd212b2e4b38afe6fc1021b0763ced055921de03943fec1992c871aa3",
376
+ "outputSha256": "9270d05fd212b2e4b38afe6fc1021b0763ced055921de03943fec1992c871aa3",
377
377
  "transform": "verbatim"
378
378
  },
379
379
  {
380
380
  "source": "package/dist/claustrum/index.js",
381
381
  "output": "claustrum/index.js",
382
- "bytes": 4048,
383
- "sourceSha256": "9f50749354dbcf643a3cddc9ff994824c603fac288f50015703ca6e1f730ca08",
384
- "outputSha256": "9f50749354dbcf643a3cddc9ff994824c603fac288f50015703ca6e1f730ca08",
382
+ "bytes": 4062,
383
+ "sourceSha256": "72f0f4bd7c17b82aa7abc3f196e1499d5a3d51173a456fbd7c3b72425ffaba48",
384
+ "outputSha256": "72f0f4bd7c17b82aa7abc3f196e1499d5a3d51173a456fbd7c3b72425ffaba48",
385
385
  "transform": "verbatim"
386
386
  },
387
387
  {
@@ -1800,6 +1800,22 @@
1800
1800
  "outputSha256": "f35e4fd7b218110756bd04357c5b8c4bbb64be5012aefc7d7a7c1ab303d483ae",
1801
1801
  "transform": "verbatim"
1802
1802
  },
1803
+ {
1804
+ "source": "package/dist/routing-accessor/cache-policy.d.ts",
1805
+ "output": "routing-accessor/cache-policy.d.ts",
1806
+ "bytes": 2177,
1807
+ "sourceSha256": "d9a938b7f5c688e398a8d67a74c5ad9d3fd1e2c72648f3bcae02acf9f8894ac2",
1808
+ "outputSha256": "d9a938b7f5c688e398a8d67a74c5ad9d3fd1e2c72648f3bcae02acf9f8894ac2",
1809
+ "transform": "verbatim"
1810
+ },
1811
+ {
1812
+ "source": "package/dist/routing-accessor/cache-policy.js",
1813
+ "output": "routing-accessor/cache-policy.js",
1814
+ "bytes": 6700,
1815
+ "sourceSha256": "3342f84975f498d36a44860b60263bb0e3a2d826faa9aff6fb24a58944d7b71b",
1816
+ "outputSha256": "3342f84975f498d36a44860b60263bb0e3a2d826faa9aff6fb24a58944d7b71b",
1817
+ "transform": "verbatim"
1818
+ },
1803
1819
  {
1804
1820
  "source": "package/dist/routing-accessor/handle.js",
1805
1821
  "output": "routing-accessor/handle.js",
@@ -1811,17 +1827,17 @@
1811
1827
  {
1812
1828
  "source": "package/dist/routing-accessor/index.d.ts",
1813
1829
  "output": "routing-accessor/index.d.ts",
1814
- "bytes": 3941,
1815
- "sourceSha256": "04f480934ab1cd05585abb816014ac37cca32ccf783e90a98dd101513edf7f04",
1816
- "outputSha256": "04f480934ab1cd05585abb816014ac37cca32ccf783e90a98dd101513edf7f04",
1830
+ "bytes": 4243,
1831
+ "sourceSha256": "f2dd26706a869322c9c31ccae1bc3612d5ce89e4f79b6c4fb999f6b50ae5f88e",
1832
+ "outputSha256": "f2dd26706a869322c9c31ccae1bc3612d5ce89e4f79b6c4fb999f6b50ae5f88e",
1817
1833
  "transform": "verbatim"
1818
1834
  },
1819
1835
  {
1820
1836
  "source": "package/dist/routing-accessor/index.js",
1821
1837
  "output": "routing-accessor/index.js",
1822
- "bytes": 8290,
1823
- "sourceSha256": "ea80ae669e1f65555e88e5c56383d6e1a5ee813de532ffade61011bb4eeea16d",
1824
- "outputSha256": "ea80ae669e1f65555e88e5c56383d6e1a5ee813de532ffade61011bb4eeea16d",
1838
+ "bytes": 8406,
1839
+ "sourceSha256": "83945bf1bcd2b6d7d5bfdd597b62211d5b00b8cdd75e29089c75478af7f6eafc",
1840
+ "outputSha256": "83945bf1bcd2b6d7d5bfdd597b62211d5b00b8cdd75e29089c75478af7f6eafc",
1825
1841
  "transform": "verbatim"
1826
1842
  }
1827
1843
  ],