@wtfalch/foundry 0.19.0 → 0.20.0

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.
@@ -3,7 +3,7 @@ import type { CoolifyClient } from '@wtfalch/providers/coolify';
3
3
  import { type ZitadelClient } from '@wtfalch/providers/zitadel';
4
4
  import type { OrgId } from '../org.js';
5
5
  import type { DeclaredOrgStore } from '../store.js';
6
- import type { CloudflareReader, CmsReader, CoolifyReader, LiveResource, ZitadelReader } from './live.js';
6
+ import type { AiReader, CloudflareReader, CmsReader, CoolifyReader, LiveResource, ZitadelReader } from './live.js';
7
7
  /**
8
8
  * Real `CoolifyReader`, `CloudflareReader` and `ZitadelReader` implementations
9
9
  * (`live.ts:31-45`), backed by `@wtfalch/providers`' HTTP clients instead of
@@ -144,6 +144,28 @@ export declare class ProvidersZitadelReader implements ZitadelReader {
144
144
  */
145
145
  private liveIssuer;
146
146
  }
147
+ /**
148
+ * Reads the org's applied AI budget limit back, so `diff.ts`'s `planAiBudget`
149
+ * stops re-proposing "set the AI budget" once it has already landed (#515).
150
+ * AI's own API offers no read for this (`live.ts`'s `AiReader` doc comment:
151
+ * wiring a real budget read is #20, a non-goal of #27 -- unlike
152
+ * {@link ProvidersZitadelReader}/{@link ProvidersCloudflareReader}, which both
153
+ * call a real provider client), so `executor.ts`'s `aiBudget` recording the
154
+ * limit it just applied under the flat `ai_budget_limit_micros` scope key is
155
+ * the only evidence there is -- the same "nothing live yet" shape
156
+ * {@link storeScopeResolver}'s own doc comment describes for `cloudflare_zone`
157
+ * before #510 fixed it.
158
+ *
159
+ * Nothing recorded yet reads as `[]`, never a default: a never-applied org
160
+ * must still plan its first `ai:budget` step, and inventing the declared (or
161
+ * default) limit here would make a budget that actually drifted out of band
162
+ * read as converged.
163
+ */
164
+ export declare class ProvidersAiReader implements AiReader {
165
+ private readonly resolveLimit;
166
+ constructor(resolveLimit: ScopeResolver);
167
+ listResources(orgId: OrgId): Promise<LiveResource[]>;
168
+ }
147
169
  /**
148
170
  * Backed by the same `@wtfalch/providers/coolify`'s `CoolifyClient.listResources`
149
171
  * call {@link ProvidersCoolifyReader} makes, not a real cms admin API --
@@ -358,6 +358,35 @@ export class ProvidersZitadelReader {
358
358
  return { system: 'zitadel', kind: 'issuer', key: orgId, config: {} };
359
359
  }
360
360
  }
361
+ /**
362
+ * Reads the org's applied AI budget limit back, so `diff.ts`'s `planAiBudget`
363
+ * stops re-proposing "set the AI budget" once it has already landed (#515).
364
+ * AI's own API offers no read for this (`live.ts`'s `AiReader` doc comment:
365
+ * wiring a real budget read is #20, a non-goal of #27 -- unlike
366
+ * {@link ProvidersZitadelReader}/{@link ProvidersCloudflareReader}, which both
367
+ * call a real provider client), so `executor.ts`'s `aiBudget` recording the
368
+ * limit it just applied under the flat `ai_budget_limit_micros` scope key is
369
+ * the only evidence there is -- the same "nothing live yet" shape
370
+ * {@link storeScopeResolver}'s own doc comment describes for `cloudflare_zone`
371
+ * before #510 fixed it.
372
+ *
373
+ * Nothing recorded yet reads as `[]`, never a default: a never-applied org
374
+ * must still plan its first `ai:budget` step, and inventing the declared (or
375
+ * default) limit here would make a budget that actually drifted out of band
376
+ * read as converged.
377
+ */
378
+ export class ProvidersAiReader {
379
+ resolveLimit;
380
+ constructor(resolveLimit) {
381
+ this.resolveLimit = resolveLimit;
382
+ }
383
+ async listResources(orgId) {
384
+ const limitMicros = await this.resolveLimit(orgId);
385
+ if (!limitMicros)
386
+ return [];
387
+ return [{ system: 'ai', kind: 'budget', key: orgId, config: { limitMicros } }];
388
+ }
389
+ }
361
390
  /**
362
391
  * Whether an application counts as up, or on its way there, from its own
363
392
  * Coolify `status` (`` `running:healthy`, `running:unknown`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wtfalch/foundry",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "description": "Foundry's SDK: the declared org's types, the plan and apply contracts, and the state store's interface.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -42,6 +42,7 @@
42
42
  "dependencies": {
43
43
  "@wtfalch/audit": "0.6.0",
44
44
  "@wtfalch/auth": "0.16.0",
45
+ "@wtfalch/edge": "0.9.0",
45
46
  "@wtfalch/email": "^0.17.0",
46
47
  "@wtfalch/providers": "0.7.3",
47
48
  "ssh2": "1.17.0",