@cortexkit/opencode-antigravity-auth 3.0.8 → 3.0.10

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 (145) hide show
  1. package/dist/cli.js +584 -189
  2. package/dist/cli.js.map +4 -4
  3. package/dist/cli.meta.json +122 -48
  4. package/dist/index.js +920 -336
  5. package/dist/index.js.map +4 -4
  6. package/dist/index.meta.json +141 -64
  7. package/dist/server.js +954 -368
  8. package/dist/server.js.map +4 -4
  9. package/dist/server.meta.json +1 -1
  10. package/dist/src/common-auth-embedded/auth-menu/login.d.ts +6 -10
  11. package/dist/src/common-auth-embedded/auth-menu/login.js +14 -11
  12. package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +8 -2
  13. package/dist/src/common-auth-embedded/claustrum/consumer.js +64 -21
  14. package/dist/src/common-auth-embedded/claustrum/index.d.ts +2 -1
  15. package/dist/src/common-auth-embedded/claustrum/index.js +1 -0
  16. package/dist/src/common-auth-embedded/claustrum/insula.d.ts +23 -0
  17. package/dist/src/common-auth-embedded/claustrum/insula.js +64 -2
  18. package/dist/src/common-auth-embedded/claustrum/quota-writer.d.ts +18 -0
  19. package/dist/src/common-auth-embedded/claustrum/quota-writer.js +253 -0
  20. package/dist/src/common-auth-embedded/claustrum/roster.d.ts +18 -2
  21. package/dist/src/common-auth-embedded/claustrum/roster.js +100 -43
  22. package/dist/src/common-auth-embedded/fs/with-lock.d.ts +1 -0
  23. package/dist/src/common-auth-embedded/fs/with-lock.js +2 -0
  24. package/dist/src/common-auth-embedded/quota/format.d.ts +19 -0
  25. package/dist/src/common-auth-embedded/quota/format.js +50 -5
  26. package/dist/src/common-auth-embedded/quota/index.d.ts +3 -3
  27. package/dist/src/common-auth-embedded/quota/index.js +2 -2
  28. package/dist/src/common-auth-embedded/quota/map.d.ts +24 -1
  29. package/dist/src/common-auth-embedded/quota/map.js +31 -6
  30. package/dist/src/common-auth-embedded/quota/merge.d.ts +6 -1
  31. package/dist/src/common-auth-embedded/quota/merge.js +17 -3
  32. package/dist/src/common-auth-embedded/quota/projection.d.ts +3 -1
  33. package/dist/src/common-auth-embedded/quota/projection.js +3 -1
  34. package/dist/src/common-auth-embedded/setup/process-fence.d.ts +7 -0
  35. package/dist/src/common-auth-embedded/setup/process-fence.js +5 -3
  36. package/dist/src/common-auth-embedded/source-output.json +95 -79
  37. package/dist/src/plugin/background-vault-quota-refresh.d.ts.map +1 -1
  38. package/dist/src/plugin/background-vault-quota-refresh.js +8 -1
  39. package/dist/src/plugin/background-vault-quota-refresh.js.map +1 -1
  40. package/dist/src/plugin/index.d.ts.map +1 -1
  41. package/dist/src/plugin/index.js +1 -0
  42. package/dist/src/plugin/index.js.map +1 -1
  43. package/dist/src/plugin/quota.d.ts +1 -1
  44. package/dist/src/plugin/quota.d.ts.map +1 -1
  45. package/dist/src/plugin/quota.js +17 -5
  46. package/dist/src/plugin/quota.js.map +1 -1
  47. package/dist/src/plugin/request-helpers.d.ts +5 -0
  48. package/dist/src/plugin/request-helpers.d.ts.map +1 -1
  49. package/dist/src/plugin/request-helpers.js +1 -0
  50. package/dist/src/plugin/request-helpers.js.map +1 -1
  51. package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
  52. package/dist/src/plugin/shared/request-services.js +123 -5
  53. package/dist/src/plugin/shared/request-services.js.map +1 -1
  54. package/dist/src/plugin/shared/vault-request-credentials.d.ts +9 -6
  55. package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  56. package/dist/src/plugin/shared/vault-request-credentials.js +9 -4
  57. package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
  58. package/dist/src/plugin/vault-custody.d.ts +2 -0
  59. package/dist/src/plugin/vault-custody.d.ts.map +1 -1
  60. package/dist/src/plugin/vault-custody.js +9 -0
  61. package/dist/src/plugin/vault-custody.js.map +1 -1
  62. package/dist/src/plugin/vault-insula-quota.d.ts +6 -0
  63. package/dist/src/plugin/vault-insula-quota.d.ts.map +1 -0
  64. package/dist/src/plugin/vault-insula-quota.js +50 -0
  65. package/dist/src/plugin/vault-insula-quota.js.map +1 -0
  66. package/dist/src/plugin/vault-quota-outcome.d.ts +1 -1
  67. package/dist/src/plugin/vault-quota-outcome.d.ts.map +1 -1
  68. package/dist/src/plugin/vault-quota-outcome.js.map +1 -1
  69. package/dist/tui-build-map.json +21 -21
  70. package/dist/tui-ga-build-map.json +21 -21
  71. package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +8 -2
  72. package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +2 -1
  73. package/dist/types/src/common-auth-embedded/claustrum/insula.d.ts +23 -0
  74. package/dist/types/src/common-auth-embedded/claustrum/quota-writer.d.ts +18 -0
  75. package/dist/types/src/common-auth-embedded/claustrum/roster.d.ts +18 -2
  76. package/dist/types/src/common-auth-embedded/quota/format.d.ts +19 -0
  77. package/dist/types/src/common-auth-embedded/quota/index.d.ts +3 -3
  78. package/dist/types/src/common-auth-embedded/quota/map.d.ts +24 -1
  79. package/dist/types/src/common-auth-embedded/quota/merge.d.ts +6 -1
  80. package/dist/types/src/common-auth-embedded/quota/projection.d.ts +3 -1
  81. package/dist/types/src/common-auth-embedded/setup/process-fence.d.ts +7 -0
  82. package/dist/types/src/plugin/background-vault-quota-refresh.d.ts.map +1 -1
  83. package/dist/types/src/plugin/config/schema.d.ts +2 -2
  84. package/dist/types/src/plugin/index.d.ts.map +1 -1
  85. package/dist/types/src/plugin/quota.d.ts +1 -1
  86. package/dist/types/src/plugin/quota.d.ts.map +1 -1
  87. package/dist/types/src/plugin/request-helpers.d.ts +5 -0
  88. package/dist/types/src/plugin/request-helpers.d.ts.map +1 -1
  89. package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
  90. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts +9 -6
  91. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  92. package/dist/types/src/plugin/vault-custody.d.ts +2 -0
  93. package/dist/types/src/plugin/vault-custody.d.ts.map +1 -1
  94. package/dist/types/src/plugin/vault-insula-quota.d.ts +6 -0
  95. package/dist/types/src/plugin/vault-insula-quota.d.ts.map +1 -0
  96. package/dist/types/src/plugin/vault-quota-outcome.d.ts +1 -1
  97. package/dist/types/src/plugin/vault-quota-outcome.d.ts.map +1 -1
  98. package/package.json +2 -2
  99. package/src/common-auth-embedded/auth-menu/login.d.ts +6 -10
  100. package/src/common-auth-embedded/auth-menu/login.js +14 -11
  101. package/src/common-auth-embedded/claustrum/consumer.d.ts +8 -2
  102. package/src/common-auth-embedded/claustrum/consumer.js +64 -21
  103. package/src/common-auth-embedded/claustrum/index.d.ts +2 -1
  104. package/src/common-auth-embedded/claustrum/index.js +1 -0
  105. package/src/common-auth-embedded/claustrum/insula.d.ts +23 -0
  106. package/src/common-auth-embedded/claustrum/insula.js +64 -2
  107. package/src/common-auth-embedded/claustrum/quota-writer.d.ts +18 -0
  108. package/src/common-auth-embedded/claustrum/quota-writer.js +253 -0
  109. package/src/common-auth-embedded/claustrum/roster.d.ts +18 -2
  110. package/src/common-auth-embedded/claustrum/roster.js +100 -43
  111. package/src/common-auth-embedded/fs/with-lock.d.ts +1 -0
  112. package/src/common-auth-embedded/fs/with-lock.js +2 -0
  113. package/src/common-auth-embedded/quota/format.d.ts +19 -0
  114. package/src/common-auth-embedded/quota/format.js +50 -5
  115. package/src/common-auth-embedded/quota/index.d.ts +3 -3
  116. package/src/common-auth-embedded/quota/index.js +2 -2
  117. package/src/common-auth-embedded/quota/map.d.ts +24 -1
  118. package/src/common-auth-embedded/quota/map.js +31 -6
  119. package/src/common-auth-embedded/quota/merge.d.ts +6 -1
  120. package/src/common-auth-embedded/quota/merge.js +17 -3
  121. package/src/common-auth-embedded/quota/projection.d.ts +3 -1
  122. package/src/common-auth-embedded/quota/projection.js +3 -1
  123. package/src/common-auth-embedded/setup/process-fence.d.ts +7 -0
  124. package/src/common-auth-embedded/setup/process-fence.js +5 -3
  125. package/src/common-auth-embedded/source-output.json +95 -79
  126. package/src/tui-compiled/common-auth-embedded/quota/format.js +50 -5
  127. package/src/tui-compiled/common-auth-embedded/quota/index.js +2 -2
  128. package/src/tui-compiled/common-auth-embedded/quota/map.js +31 -6
  129. package/src/tui-compiled/common-auth-embedded/quota/merge.js +17 -3
  130. package/src/tui-compiled/common-auth-embedded/quota/projection.js +3 -1
  131. package/src/tui-ga-compiled/shared/1ff34afa7c42d196-projection.js +3 -1
  132. package/src/tui-ga-compiled/shared/77138df80c7ae006-map.js +31 -6
  133. package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +50 -5
  134. package/src/tui-ga-compiled/shared/bf17cbee28e58197-index.js +2 -2
  135. package/src/tui-ga-compiled/shared/ecc214300932dfb6-merge.js +17 -3
  136. package/src/tui-ga-raw/shared/1ff34afa7c42d196-projection.js +3 -1
  137. package/src/tui-ga-raw/shared/77138df80c7ae006-map.js +31 -6
  138. package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +50 -5
  139. package/src/tui-ga-raw/shared/bf17cbee28e58197-index.js +2 -2
  140. package/src/tui-ga-raw/shared/ecc214300932dfb6-merge.js +17 -3
  141. package/src/tui-raw/common-auth-embedded/quota/format.js +50 -5
  142. package/src/tui-raw/common-auth-embedded/quota/index.js +2 -2
  143. package/src/tui-raw/common-auth-embedded/quota/map.js +31 -6
  144. package/src/tui-raw/common-auth-embedded/quota/merge.js +17 -3
  145. package/src/tui-raw/common-auth-embedded/quota/projection.js +3 -1
@@ -14,6 +14,9 @@
14
14
  // reset clock. It is a tri-state: absent (never reported), a reading, or
15
15
  // cleared (the provider reported that no budget exists).
16
16
  //
17
+ // Provider-named counters and the prepaid credits record sit beside them too,
18
+ // each judged by its own observation time rather than the limits'.
19
+ //
17
20
  // The map is plain JSON so the store can persist it without interpreting it.
18
21
  /** The scope of a limit that binds every request regardless of model. */
19
22
  export const ALL_SCOPE = 'all';
@@ -93,6 +96,18 @@ function isQuotaCounter(value) {
93
96
  export function isQuotaCounters(value) {
94
97
  return isRecord(value) && Object.values(value).every(isQuotaCounter);
95
98
  }
99
+ function isBoolean(value) {
100
+ return typeof value === 'boolean';
101
+ }
102
+ /** True when `value` is a well-formed prepaid-credits record. */
103
+ export function isQuotaCredits(value) {
104
+ return (isRecord(value) &&
105
+ typeof value.hasCredits === 'boolean' &&
106
+ typeof value.unlimited === 'boolean' &&
107
+ optional(value, 'balance', isFiniteNumber) &&
108
+ optional(value, 'overageLimitReached', isBoolean) &&
109
+ isFiniteNumber(value.checkedAt));
110
+ }
96
111
  /** Keep usable counters without letting one malformed count hide a quota map. */
97
112
  export function readQuotaCounters(value) {
98
113
  if (!isRecord(value))
@@ -102,20 +117,29 @@ export function readQuotaCounters(value) {
102
117
  ? undefined
103
118
  : Object.fromEntries(entries);
104
119
  }
105
- /** Decode persisted quota, dropping malformed counters but not limit evidence. */
120
+ /**
121
+ * Decode persisted quota, dropping malformed counters or a malformed credits
122
+ * record but not limit or budget evidence.
123
+ */
106
124
  export function decodeQuotaMap(value) {
107
125
  // A valid map is returned as the same object, so stored quota keeps the
108
- // identity it had before counters existed; only a map with a malformed
109
- // counter is copied without it.
126
+ // identity it had before counters and credits existed. A map with a
127
+ // malformed counter or credits record is copied with those malformed
128
+ // fields left out.
110
129
  if (isQuotaMap(value))
111
130
  return value;
112
131
  if (!isRecord(value))
113
132
  return undefined;
114
- const { counters: rawCounters, ...rest } = value;
133
+ const { counters: rawCounters, credits: rawCredits, ...rest } = value;
115
134
  if (!isQuotaMap(rest))
116
135
  return undefined;
117
136
  const counters = readQuotaCounters(rawCounters);
118
- return { ...rest, ...(counters === undefined ? {} : { counters }) };
137
+ const credits = isQuotaCredits(rawCredits) ? rawCredits : undefined;
138
+ return {
139
+ ...rest,
140
+ ...(counters === undefined ? {} : { counters }),
141
+ ...(credits === undefined ? {} : { credits }),
142
+ };
119
143
  }
120
144
  /**
121
145
  * True when `value` is a well-formed quota map. Unrecognised top-level keys
@@ -136,5 +160,6 @@ export function isQuotaMap(value) {
136
160
  seen.add(key);
137
161
  }
138
162
  return (optional(value, 'budget', isCreditBudgetEntry) &&
139
- optional(value, 'counters', isQuotaCounters));
163
+ optional(value, 'counters', isQuotaCounters) &&
164
+ optional(value, 'credits', isQuotaCredits));
140
165
  }
@@ -11,7 +11,7 @@
11
11
  // no entry gets an absence record. A pair outside the coverage is never
12
12
  // touched, so a header-shaped partial observation (which covers only what it
13
13
  // carries) cannot erase a family limit or the budget.
14
- import { ALL_SCOPE, decodeQuotaMap, entryTime, isQuotaCounters, limitKey, } from "./map.js";
14
+ import { ALL_SCOPE, decodeQuotaMap, entryTime, isQuotaCounters, isQuotaCredits, limitKey, } from "./map.js";
15
15
  /** Thrown by `mergeQuotaObservation` when either argument is malformed. */
16
16
  export class QuotaCodecError extends TypeError {
17
17
  constructor(message) {
@@ -84,7 +84,8 @@ export function isQuotaObservation(value) {
84
84
  if (!coverage.every(isObservedPair))
85
85
  return false;
86
86
  return ((value.budget === undefined || isObservedBudget(value.budget)) &&
87
- (value.counters === undefined || isQuotaCounters(value.counters)));
87
+ (value.counters === undefined || isQuotaCounters(value.counters)) &&
88
+ (value.credits === undefined || isQuotaCredits(value.credits)));
88
89
  }
89
90
  function compareEntries(left, right) {
90
91
  if (left.scope !== right.scope)
@@ -110,6 +111,17 @@ function mergeCounters(stored, observed) {
110
111
  }
111
112
  return counters.size === 0 ? undefined : Object.fromEntries(counters);
112
113
  }
114
+ // Credits merge like a single counter: the newer record wins, an equal time
115
+ // applies (the observation applied last wins), and an observation without
116
+ // credits leaves the stored record alone.
117
+ function mergeCredits(stored, observed) {
118
+ if (observed === undefined)
119
+ return stored;
120
+ if (stored !== undefined && observed.checkedAt < stored.checkedAt) {
121
+ return stored;
122
+ }
123
+ return { ...observed };
124
+ }
113
125
  /**
114
126
  * Applies `observation` to `stored` (undefined for a row with no map yet) and
115
127
  * returns the new map. Pure: neither argument is modified. Throws
@@ -166,13 +178,15 @@ export function mergeQuotaObservation(stored, observation) {
166
178
  : { scope, label: pair.label, kind: 'retired', retiredAt: at });
167
179
  }
168
180
  // Keys this module does not recognise are carried over untouched.
169
- const { limits: _limits, budget: _budget, counters: _counters, ...unknownKeys } = base;
181
+ const { limits: _limits, budget: _budget, counters: _counters, credits: _credits, ...unknownKeys } = base;
170
182
  const budget = mergeBudget(base.budget, observation.budget, at);
171
183
  const counters = mergeCounters(base.counters, observation.counters);
184
+ const credits = mergeCredits(base.credits, observation.credits);
172
185
  return {
173
186
  ...unknownKeys,
174
187
  limits: [...entries.values()].sort(compareEntries),
175
188
  ...(budget === undefined ? {} : { budget }),
176
189
  ...(counters === undefined ? {} : { counters }),
190
+ ...(credits === undefined ? {} : { credits }),
177
191
  };
178
192
  }
@@ -6,7 +6,7 @@
6
6
  // scope, orders the result the way the primitives expect, and carries each
7
7
  // entry's (scope, label) so a decision names the limit it judged rather than
8
8
  // the position it occupied.
9
- import { ALL_SCOPE, readQuotaCounters, } from "./map.js";
9
+ import { ALL_SCOPE, isQuotaCredits, readQuotaCounters, } from "./map.js";
10
10
  function project(entry) {
11
11
  if (entry.kind === 'retired') {
12
12
  return {
@@ -95,12 +95,14 @@ export function projectQuota(map, scope = ALL_SCOPE) {
95
95
  : undefined;
96
96
  const budget = map?.budget?.kind === 'reading' ? projectBudget(map.budget) : undefined;
97
97
  const counters = readQuotaCounters(map?.counters);
98
+ const credits = isQuotaCredits(map?.credits) ? map.credits : undefined;
98
99
  return {
99
100
  scope,
100
101
  limits,
101
102
  ...(checkedAt === undefined ? {} : { checkedAt }),
102
103
  ...(budget === undefined ? {} : { budget }),
103
104
  ...(counters === undefined ? {} : { counters }),
105
+ ...(credits === undefined ? {} : { credits }),
104
106
  };
105
107
  }
106
108
  /**