@onesi/genesis 0.0.1-stage → 0.2.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.
Files changed (113) hide show
  1. package/README.md +29 -0
  2. package/dist/auto.d.ts +1010 -0
  3. package/dist/auto.js +125 -0
  4. package/dist/beacons.d.ts +145 -0
  5. package/dist/beacons.js +148 -0
  6. package/dist/blinds-owner-enrollment.d.ts +280 -0
  7. package/dist/blinds-owner-enrollment.js +169 -0
  8. package/dist/client.d.ts +52 -0
  9. package/dist/client.js +384 -0
  10. package/dist/context.d.ts +50 -0
  11. package/dist/context.js +153 -0
  12. package/dist/dials.d.ts +299 -0
  13. package/dist/dials.js +100 -0
  14. package/dist/errors.d.ts +35 -0
  15. package/dist/errors.js +66 -0
  16. package/dist/flares.d.ts +202 -0
  17. package/dist/flares.js +61 -0
  18. package/dist/fleets.d.ts +218 -0
  19. package/dist/fleets.js +189 -0
  20. package/dist/flocks.d.ts +439 -0
  21. package/dist/flocks.js +98 -0
  22. package/dist/foundry-billing.d.ts +97 -0
  23. package/dist/foundry-billing.js +107 -0
  24. package/dist/foundry.d.ts +424 -0
  25. package/dist/foundry.js +133 -0
  26. package/dist/garden.d.ts +754 -0
  27. package/dist/garden.js +76 -0
  28. package/dist/gateway.d.ts +365 -0
  29. package/dist/gateway.js +82 -0
  30. package/dist/gears.d.ts +226 -0
  31. package/dist/gears.js +42 -0
  32. package/dist/generated/operations.d.ts +4 -0
  33. package/dist/generated/operations.js +65134 -0
  34. package/dist/generated/schema.d.ts +87658 -0
  35. package/dist/generated/schema.js +1 -0
  36. package/dist/genesis.d.ts +9574 -0
  37. package/dist/genesis.js +271 -0
  38. package/dist/genesis.openapi.json +128522 -0
  39. package/dist/henry.d.ts +369 -0
  40. package/dist/henry.js +268 -0
  41. package/dist/hives-cells.d.ts +127 -0
  42. package/dist/hives-cells.js +151 -0
  43. package/dist/hives-environment.d.ts +37 -0
  44. package/dist/hives-environment.js +80 -0
  45. package/dist/hives-functions.d.ts +36 -0
  46. package/dist/hives-functions.js +185 -0
  47. package/dist/hives-marketplace.d.ts +128 -0
  48. package/dist/hives-marketplace.js +187 -0
  49. package/dist/hives-node.d.ts +9 -0
  50. package/dist/hives-node.js +155 -0
  51. package/dist/hives-operations.d.ts +451 -0
  52. package/dist/hives-operations.js +43 -0
  53. package/dist/hives-platform.d.ts +149 -0
  54. package/dist/hives-platform.js +183 -0
  55. package/dist/hives-queue-consumer.d.ts +56 -0
  56. package/dist/hives-queue-consumer.js +95 -0
  57. package/dist/hives-queue-funding.d.ts +28 -0
  58. package/dist/hives-queue-funding.js +81 -0
  59. package/dist/hives-queues.d.ts +137 -0
  60. package/dist/hives-queues.js +143 -0
  61. package/dist/hives-resources-transport.d.ts +23 -0
  62. package/dist/hives-resources-transport.js +204 -0
  63. package/dist/hives-response.d.ts +2 -0
  64. package/dist/hives-response.js +32 -0
  65. package/dist/hives-runtimes.d.ts +34 -0
  66. package/dist/hives-runtimes.js +32 -0
  67. package/dist/hives-sse.d.ts +24 -0
  68. package/dist/hives-sse.js +111 -0
  69. package/dist/hives-topics.d.ts +51 -0
  70. package/dist/hives-topics.js +79 -0
  71. package/dist/hives-upload.d.ts +9 -0
  72. package/dist/hives-upload.js +23 -0
  73. package/dist/hives-volumes.d.ts +64 -0
  74. package/dist/hives-volumes.js +117 -0
  75. package/dist/iam-directory.d.ts +8 -0
  76. package/dist/iam-directory.js +23 -0
  77. package/dist/iam.d.ts +391 -0
  78. package/dist/iam.js +92 -0
  79. package/dist/idempotency.d.ts +7 -0
  80. package/dist/idempotency.js +39 -0
  81. package/dist/index.d.ts +47 -0
  82. package/dist/index.js +37 -0
  83. package/dist/instances.d.ts +200 -0
  84. package/dist/instances.js +43 -0
  85. package/dist/lanes.d.ts +267 -0
  86. package/dist/lanes.js +41 -0
  87. package/dist/minds-agent.d.ts +88 -0
  88. package/dist/minds-agent.js +233 -0
  89. package/dist/minds-engine.d.ts +394 -0
  90. package/dist/minds-engine.js +555 -0
  91. package/dist/minds-owner.d.ts +110 -0
  92. package/dist/minds-owner.js +226 -0
  93. package/dist/minds.d.ts +377 -0
  94. package/dist/minds.js +228 -0
  95. package/dist/orgs.d.ts +405 -0
  96. package/dist/orgs.js +63 -0
  97. package/dist/relays-enrollment.d.ts +33 -0
  98. package/dist/relays-enrollment.js +115 -0
  99. package/dist/runner-grant.d.ts +10 -0
  100. package/dist/runner-grant.js +133 -0
  101. package/dist/runner.d.ts +72 -0
  102. package/dist/runner.js +117 -0
  103. package/dist/scopes.d.ts +310 -0
  104. package/dist/scopes.js +40 -0
  105. package/dist/taps.d.ts +118 -0
  106. package/dist/taps.js +45 -0
  107. package/dist/traces.d.ts +574 -0
  108. package/dist/traces.js +97 -0
  109. package/dist/types.d.ts +98 -0
  110. package/dist/types.js +1 -0
  111. package/dist/urls.d.ts +6 -0
  112. package/dist/urls.js +31 -0
  113. package/package.json +49 -1
@@ -0,0 +1,107 @@
1
+ import { errorOutcome, errorToken, GenesisError } from './errors.js';
2
+ export const foundryBillingOperations = ['foundry_readBillingProfile', 'foundry_ensureBillingProfile', 'foundry_createNativeCreditCheckout', 'foundry_readNativeCreditBalance'];
3
+ export const isFoundryBillingOperation = (id) => foundryBillingOperations.includes(id);
4
+ const writes = new Set(['foundry_ensureBillingProfile', 'foundry_createNativeCreditCheckout']);
5
+ const keyValid = (key) => typeof key === 'string' && /^[\x21-\x7e]{1,255}(?![\s\S])/.test(key) && !key.includes(',');
6
+ /** One gateway dispatch, no redirect or automatic retry. Native billing always
7
+ * uses the caller's original human credential; customer/provider selectors are absent. */
8
+ export async function foundryBillingTransport(options) {
9
+ const write = writes.has(options.operationId), key = options.headers?.['idempotency-key'];
10
+ const error = (status, type, body) => new GenesisError({ status, type, body, operationId: options.operationId,
11
+ message: 'Native Foundry billing was not confirmed. Preserve the operation key and reconcile an unknown result before retrying.' });
12
+ const body = options.input.body;
13
+ if (options.routing !== 'gateway' || !isFoundryBillingOperation(options.operationId) || Object.keys(options.input).some(k => k !== 'body')
14
+ || (write ? !keyValid(key) || !body || typeof body !== 'object' || Array.isArray(body) || Object.keys(body).length > 0 : Object.keys(options.input).length > 0))
15
+ throw error(0, 'invalid_request');
16
+ const controller = new AbortController(), cancel = () => controller.abort(options.signal?.reason);
17
+ if (options.signal?.aborted)
18
+ cancel();
19
+ else
20
+ options.signal?.addEventListener('abort', cancel, { once: true });
21
+ const timer = setTimeout(() => controller.abort(), 20_000);
22
+ async function bounded(work) {
23
+ controller.signal.throwIfAborted();
24
+ let abort = () => { };
25
+ try {
26
+ return await Promise.race([work, new Promise((_, reject) => { abort = () => reject(error(0, 'outcome_unknown', write ? { outcome: 'unknown' } : undefined)); controller.signal.addEventListener('abort', abort, { once: true }); })]);
27
+ }
28
+ finally {
29
+ controller.signal.removeEventListener('abort', abort);
30
+ }
31
+ }
32
+ try {
33
+ controller.signal.throwIfAborted();
34
+ const credential = await bounded(options.credential());
35
+ controller.signal.throwIfAborted();
36
+ if (!credential)
37
+ throw error(401, 'unauthenticated');
38
+ const response = await bounded(options.fetch(options.url, { method: write ? 'POST' : 'GET', headers: { authorization: `Bearer ${credential}`, accept: 'application/json', ...(write ? { 'content-type': 'application/json', 'idempotency-key': key } : {}) },
39
+ ...(write ? { body: '{}' } : {}), signal: controller.signal, redirect: 'error', cache: 'no-store' }).then(response => { if (controller.signal.aborted) {
40
+ void response.body?.cancel().catch(() => { });
41
+ throw error(0, 'outcome_unknown', write ? { outcome: 'unknown' } : undefined);
42
+ } return response; }));
43
+ if (!response.body || !/^application\/json(?:;|$)/i.test(response.headers.get('content-type') ?? ''))
44
+ throw error(response.status, 'invalid_response', write ? { outcome: 'unknown' } : undefined);
45
+ const reader = response.body.getReader(), parts = [];
46
+ let size = 0;
47
+ const stop = () => { void reader.cancel().catch(() => { }); };
48
+ controller.signal.addEventListener('abort', stop, { once: true });
49
+ try {
50
+ for (;;) {
51
+ const next = await bounded(reader.read());
52
+ if (next.done)
53
+ break;
54
+ size += next.value.length;
55
+ if (size > 16384)
56
+ throw error(response.status, 'invalid_response', write ? { outcome: 'unknown' } : undefined);
57
+ parts.push(next.value);
58
+ }
59
+ }
60
+ finally {
61
+ controller.signal.removeEventListener('abort', stop);
62
+ stop();
63
+ try {
64
+ reader.releaseLock();
65
+ }
66
+ catch { /* pending read was cancelled */ }
67
+ }
68
+ const bytes = new Uint8Array(size);
69
+ let at = 0;
70
+ for (const part of parts) {
71
+ bytes.set(part, at);
72
+ at += part.length;
73
+ }
74
+ let value;
75
+ try {
76
+ value = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes));
77
+ }
78
+ catch {
79
+ throw error(response.status, 'invalid_response', write ? { outcome: 'unknown' } : undefined);
80
+ }
81
+ if (!response.ok) {
82
+ const fields = value && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
83
+ // Envelope (error.code / error.outcome) or legacy string form; only an explicit not_dispatched 400 is safe to fix and resend.
84
+ const outcome = response.status === 400 && errorToken(fields) === 'invalid_billing_request' && errorOutcome(fields) === 'not_dispatched' ? 'not_dispatched' : 'unknown';
85
+ throw error(response.status, 'billing_unconfirmed', write ? { ...fields, outcome } : value);
86
+ }
87
+ return Response.json(value, { status: response.status, headers: { 'cache-control': 'no-store' } });
88
+ }
89
+ catch (e) {
90
+ if (e instanceof GenesisError)
91
+ throw e;
92
+ throw error(0, 'outcome_unknown', write ? { outcome: 'unknown' } : undefined);
93
+ }
94
+ finally {
95
+ clearTimeout(timer);
96
+ controller.abort();
97
+ options.signal?.removeEventListener('abort', cancel);
98
+ }
99
+ }
100
+ export function foundryBilling(client) {
101
+ const read = (id, options = {}) => client.request(id, {}, options);
102
+ const write = (id, key, options = {}) => client.request(id, { body: {} }, { ...options, headers: { 'idempotency-key': key } });
103
+ return { profile: (options) => read('foundry_readBillingProfile', options),
104
+ ensureProfile: (operationKey, options) => write('foundry_ensureBillingProfile', operationKey, options),
105
+ checkoutCredits: (purchaseKey, options) => write('foundry_createNativeCreditCheckout', purchaseKey, options),
106
+ creditBalance: (options) => read('foundry_readNativeCreditBalance', options) };
107
+ }
@@ -0,0 +1,424 @@
1
+ import type { GenesisClient } from './client.js';
2
+ import type { OperationInput as In } from './types.js';
3
+ /** Foundry through the gateway (gateway/src/foundry-native.ts). Inference, receipts and key info are delegated for a
4
+ * login session; an org API key gets 403 FOUNDRY_HUMAN_SESSION_REQUIRED until Foundry admits key principals. A One app
5
+ * sign-in (`pf_one`) gets the prepaid child, which Foundry admits only for chat, responses, embeddings and messages;
6
+ * `universal`, `routing`, `tools`, `workloads`, `generation` and `keys.current` work today with a Console login (`pf_console`). Registry reads are public. Key writes are gateway-native and need an idempotency key.
7
+ * Canonical model ids are `vendor/name`: their `/` is sent as a path separator. */
8
+ export declare function foundryModule(client: GenesisClient): {
9
+ /** Anthropic Messages (Foundry /api/v1/messages). */
10
+ messages: (body: In<"foundry_createMessage">["body"]) => Promise<{
11
+ id: string;
12
+ model?: string;
13
+ content: {
14
+ [key: string]: unknown;
15
+ }[];
16
+ usage?: import("./index.js").components["schemas"]["Foundry.Usage"];
17
+ foundry?: import("./index.js").components["schemas"]["Foundry.RequestMetadata"];
18
+ } & {
19
+ [key: string]: unknown;
20
+ }>;
21
+ responses: (body: In<"foundry_createResponse">["body"]) => Promise<{
22
+ id: string;
23
+ object?: string;
24
+ model?: string;
25
+ output?: {
26
+ [key: string]: unknown;
27
+ }[];
28
+ usage?: import("./index.js").components["schemas"]["Foundry.Usage"];
29
+ foundry?: import("./index.js").components["schemas"]["Foundry.RequestMetadata"];
30
+ } & {
31
+ [key: string]: unknown;
32
+ }>;
33
+ rerank: (body: In<"foundry_createRerank">["body"]) => Promise<unknown>;
34
+ images: {
35
+ create: (body: In<"foundry_createImage">["body"]) => Promise<unknown>;
36
+ models: () => Promise<{
37
+ data: {
38
+ [key: string]: unknown;
39
+ }[];
40
+ } & {
41
+ [key: string]: unknown;
42
+ }>;
43
+ };
44
+ transcribe: (body: In<"foundry_createAudioTranscription">["body"]) => Promise<unknown>;
45
+ receipts: {
46
+ get: (receipt_id: string) => Promise<{
47
+ version?: string;
48
+ receipt_id: string;
49
+ request_id: string;
50
+ model_id?: string;
51
+ provider_id?: string;
52
+ lane?: "pay_as_you_go" | "subscription_entitled" | "byok";
53
+ usage?: import("./index.js").components["schemas"]["Foundry.Usage"];
54
+ signature?: string;
55
+ } & {
56
+ [key: string]: unknown;
57
+ }>;
58
+ byRequest: (request_id: string) => Promise<{
59
+ version?: string;
60
+ receipt_id: string;
61
+ request_id: string;
62
+ model_id?: string;
63
+ provider_id?: string;
64
+ lane?: "pay_as_you_go" | "subscription_entitled" | "byok";
65
+ usage?: import("./index.js").components["schemas"]["Foundry.Usage"];
66
+ signature?: string;
67
+ } & {
68
+ [key: string]: unknown;
69
+ }>;
70
+ verificationKey: () => Promise<{
71
+ [key: string]: unknown;
72
+ }>;
73
+ };
74
+ keys: {
75
+ list: () => Promise<{
76
+ [key: string]: unknown;
77
+ }>;
78
+ create: (body: In<"foundry_createApiKey">["body"], idempotencyKey: string) => Promise<{
79
+ [key: string]: unknown;
80
+ }>;
81
+ delete: (key_id: string, idempotencyKey: string) => Promise<{
82
+ [key: string]: unknown;
83
+ }>;
84
+ rotate: (key_id: string, idempotencyKey: string) => Promise<{
85
+ [key: string]: unknown;
86
+ }>;
87
+ /** The Foundry credential the call carried (through the gateway: your login's delegated identity). */
88
+ current: () => Promise<{
89
+ [key: string]: unknown;
90
+ }>;
91
+ };
92
+ reporting: {
93
+ requestLogs: (q?: In<"foundry_listRequestLogs">) => Promise<{
94
+ data: {
95
+ id: string;
96
+ timestamp: string;
97
+ model: string;
98
+ provider: string;
99
+ status: number;
100
+ prompt_tokens: number;
101
+ completion_tokens: number;
102
+ total_tokens: number;
103
+ latency_ms: number;
104
+ estimated_cost_microdollars: number;
105
+ }[];
106
+ scope: import("./index.js").components["schemas"]["Foundry.ReportingScope"];
107
+ meta: {
108
+ limit: number;
109
+ offset: number;
110
+ total_count: number;
111
+ has_more: boolean;
112
+ };
113
+ }>;
114
+ providerCredentials: () => Promise<{
115
+ data: {
116
+ object: "provider_credential_summary";
117
+ source: string;
118
+ generated_at: string;
119
+ complete: boolean;
120
+ consistency: string;
121
+ configuration_only: boolean;
122
+ health_verified: boolean;
123
+ execution_verified: boolean;
124
+ default_credential_mode: string;
125
+ credential_count: number;
126
+ enabled_credential_count: number;
127
+ credentials: {
128
+ provider_id: string;
129
+ enabled?: boolean;
130
+ created_at: string;
131
+ updated_at: string;
132
+ credential_mode: "platform" | "prefer_byok" | "require_byok";
133
+ }[];
134
+ policies: {
135
+ provider_id: string;
136
+ enabled?: boolean;
137
+ created_at: string;
138
+ updated_at: string;
139
+ credential_mode: "platform" | "prefer_byok" | "require_byok";
140
+ }[];
141
+ };
142
+ scope: import("./index.js").components["schemas"]["Foundry.ReportingScope"];
143
+ }>;
144
+ };
145
+ /** Refused to every caller today: Foundry gates these on its `admin` scope (403 SCOPE_MISSING). */
146
+ activity: {
147
+ list: (q?: In<"foundry_getActivity">) => Promise<{
148
+ [key: string]: unknown;
149
+ }>;
150
+ export: (q?: In<"foundry_exportActivity">) => Promise<{
151
+ [key: string]: unknown;
152
+ }>;
153
+ };
154
+ analytics: {
155
+ meta: () => Promise<{
156
+ [key: string]: unknown;
157
+ }>;
158
+ query: (body: In<"foundry_queryAnalytics">["body"]) => Promise<{
159
+ [key: string]: unknown;
160
+ }>;
161
+ };
162
+ /** Foundry universal API (/foundry/v1/*): `infer` for any modality, or a task wrapper. Paid. */
163
+ universal: {
164
+ infer: (body: In<"foundry_createInference">["body"]) => Promise<{
165
+ [key: string]: unknown;
166
+ }>;
167
+ /** Server-sent events: the raw Response. */
168
+ inferStream: (body: In<"foundry_streamInference">["body"]) => Promise<unknown>;
169
+ classify: (body: In<"foundry_classifyText">["body"]) => Promise<{
170
+ [key: string]: unknown;
171
+ }>;
172
+ detect: (body: In<"foundry_detectObjects">["body"]) => Promise<{
173
+ [key: string]: unknown;
174
+ }>;
175
+ segment: (body: In<"foundry_segmentImage">["body"]) => Promise<{
176
+ [key: string]: unknown;
177
+ }>;
178
+ embed: (body: In<"foundry_embedTexts">["body"]) => Promise<{
179
+ [key: string]: unknown;
180
+ }>;
181
+ transcribe: (body: In<"foundry_transcribeAudio">["body"]) => Promise<{
182
+ [key: string]: unknown;
183
+ }>;
184
+ speak: (body: In<"foundry_synthesizeSpeech">["body"]) => Promise<{
185
+ [key: string]: unknown;
186
+ }>;
187
+ generateImage: (body: In<"foundry_generateImage">["body"]) => Promise<{
188
+ [key: string]: unknown;
189
+ }>;
190
+ predict: (body: In<"foundry_predictTabular">["body"]) => Promise<{
191
+ [key: string]: unknown;
192
+ }>;
193
+ forecast: (body: In<"foundry_forecastSeries">["body"]) => Promise<{
194
+ [key: string]: unknown;
195
+ }>;
196
+ recommend: (body: In<"foundry_recommendItems">["body"]) => Promise<{
197
+ [key: string]: unknown;
198
+ }>;
199
+ annotate: (body: In<"foundry_annotateText">["body"]) => Promise<{
200
+ [key: string]: unknown;
201
+ }>;
202
+ summarize: (body: In<"foundry_summarizeText">["body"]) => Promise<{
203
+ [key: string]: unknown;
204
+ }>;
205
+ };
206
+ /** Routing preview, explanation and eval planning: compute only. */
207
+ routing: {
208
+ preview: (body: In<"foundry_previewRoute">["body"]) => Promise<{
209
+ candidates?: {
210
+ [key: string]: unknown;
211
+ }[];
212
+ selected?: {
213
+ [key: string]: unknown;
214
+ };
215
+ executable?: boolean;
216
+ billing_lane?: string;
217
+ } & {
218
+ [key: string]: unknown;
219
+ }>;
220
+ explain: (id: string) => Promise<{
221
+ [key: string]: unknown;
222
+ }>;
223
+ evals: {
224
+ plan: (body: In<"foundry_planRoutingEval">["body"]) => Promise<{
225
+ [key: string]: unknown;
226
+ }>;
227
+ dispatchPlan: (body: In<"foundry_dispatchRoutingEvalPlan">["body"]) => Promise<{
228
+ [key: string]: unknown;
229
+ }>;
230
+ aggregateDispatch: (body: In<"foundry_aggregateRoutingEvalDispatch">["body"]) => Promise<{
231
+ [key: string]: unknown;
232
+ }>;
233
+ aggregatePlanned: (body: In<"foundry_aggregatePlannedRoutingEval">["body"]) => Promise<{
234
+ [key: string]: unknown;
235
+ }>;
236
+ aggregate: (body: In<"foundry_aggregateRoutingEval">["body"]) => Promise<{
237
+ [key: string]: unknown;
238
+ }>;
239
+ claimReadiness: (body: In<"foundry_checkRoutingEvalClaimReadiness">["body"]) => Promise<{
240
+ [key: string]: unknown;
241
+ }>;
242
+ };
243
+ };
244
+ /** Cost and model comparison estimates: compute only, no provider call. */
245
+ tools: {
246
+ costEstimate: (body: In<"foundry_estimateCost">["body"]) => Promise<{
247
+ [key: string]: unknown;
248
+ }>;
249
+ compare: (body: In<"foundry_compareModels">["body"]) => Promise<{
250
+ [key: string]: unknown;
251
+ }>;
252
+ benchmark: (body: In<"foundry_benchmarkModels">["body"]) => Promise<{
253
+ [key: string]: unknown;
254
+ }>;
255
+ };
256
+ workloads: {
257
+ status: (workload_id: string) => Promise<{
258
+ [key: string]: unknown;
259
+ }>;
260
+ terminate: (workload_id: string) => Promise<{
261
+ [key: string]: unknown;
262
+ }>;
263
+ };
264
+ /** OpenRouter-style generation lookup by request id; content and feedback need Foundry `admin` (refused today). */
265
+ generation: {
266
+ get: (id: string) => Promise<{
267
+ data: {
268
+ id?: string;
269
+ request_id?: string;
270
+ model?: string;
271
+ provider_name?: string;
272
+ is_byok?: boolean;
273
+ total_cost?: number;
274
+ foundry_receipt?: import("./index.js").components["schemas"]["Foundry.JsonObject"];
275
+ } & {
276
+ [key: string]: unknown;
277
+ };
278
+ } & {
279
+ [key: string]: unknown;
280
+ }>;
281
+ content: (id: string) => Promise<{
282
+ [key: string]: unknown;
283
+ }>;
284
+ feedback: (body: In<"foundry_submitGenerationFeedback">["body"]) => Promise<{
285
+ [key: string]: unknown;
286
+ }>;
287
+ };
288
+ batches: {
289
+ create: (body: In<"foundry_createBatch">["body"]) => Promise<{
290
+ id: string;
291
+ status: string;
292
+ endpoint?: string;
293
+ input_file_id?: string;
294
+ output_file_id?: string | null;
295
+ request_counts?: {
296
+ [key: string]: unknown;
297
+ };
298
+ metadata?: {
299
+ [key: string]: unknown;
300
+ };
301
+ } & {
302
+ [key: string]: unknown;
303
+ }>;
304
+ get: (batch_id: string) => Promise<{
305
+ id: string;
306
+ status: string;
307
+ endpoint?: string;
308
+ input_file_id?: string;
309
+ output_file_id?: string | null;
310
+ request_counts?: {
311
+ [key: string]: unknown;
312
+ };
313
+ metadata?: {
314
+ [key: string]: unknown;
315
+ };
316
+ } & {
317
+ [key: string]: unknown;
318
+ }>;
319
+ };
320
+ };
321
+ /** Public registry reads, V1 and paginated V2. */
322
+ export declare function foundryRegistry(client: GenesisClient): {
323
+ models: (q?: In<"foundry_listRegistryModels">) => Promise<{
324
+ [key: string]: unknown;
325
+ }>;
326
+ model: (canonical_model_id: string) => Promise<{
327
+ [key: string]: unknown;
328
+ }>;
329
+ offers: (canonical_model_id: string) => Promise<{
330
+ [key: string]: unknown;
331
+ }>;
332
+ dossier: (canonical_model_id: string) => Promise<{
333
+ [key: string]: unknown;
334
+ }>;
335
+ benchmarks: (canonical_model_id: string) => Promise<{
336
+ [key: string]: unknown;
337
+ }>;
338
+ sources: (canonical_model_id: string) => Promise<{
339
+ [key: string]: unknown;
340
+ }>;
341
+ providers: () => Promise<{
342
+ [key: string]: unknown;
343
+ }>;
344
+ provider: (provider_id: string) => Promise<{
345
+ [key: string]: unknown;
346
+ }>;
347
+ providerDossier: (provider_id: string) => Promise<{
348
+ [key: string]: unknown;
349
+ }>;
350
+ facets: () => Promise<{
351
+ [key: string]: unknown;
352
+ }>;
353
+ modelBase: () => Promise<{
354
+ [key: string]: unknown;
355
+ }>;
356
+ modelBaseReleases: () => Promise<{
357
+ [key: string]: unknown;
358
+ }>;
359
+ labs: () => Promise<{
360
+ [key: string]: unknown;
361
+ }>;
362
+ lab: (lab_id: string) => Promise<{
363
+ [key: string]: unknown;
364
+ }>;
365
+ compare: (q?: In<"foundry_compareRegistryModels">) => Promise<{
366
+ [key: string]: unknown;
367
+ }>;
368
+ v2: {
369
+ models: (q?: In<"foundry_listRegistryModelsV2">) => Promise<{
370
+ [key: string]: unknown;
371
+ }>;
372
+ model: (canonical_model_id: string) => Promise<{
373
+ [key: string]: unknown;
374
+ }>;
375
+ dossier: (canonical_model_id: string) => Promise<{
376
+ [key: string]: unknown;
377
+ }>;
378
+ providers: (q?: In<"foundry_listRegistryProvidersV2">) => Promise<{
379
+ [key: string]: unknown;
380
+ }>;
381
+ provider: (provider_id: string) => Promise<{
382
+ [key: string]: unknown;
383
+ }>;
384
+ facets: () => Promise<{
385
+ [key: string]: unknown;
386
+ }>;
387
+ modelBase: () => Promise<{
388
+ [key: string]: unknown;
389
+ }>;
390
+ modelBaseReleases: () => Promise<{
391
+ [key: string]: unknown;
392
+ }>;
393
+ labs: (q?: In<"foundry_listRegistryLabsV2">) => Promise<{
394
+ [key: string]: unknown;
395
+ }>;
396
+ lab: (lab_id: string) => Promise<{
397
+ [key: string]: unknown;
398
+ }>;
399
+ compare: () => Promise<{
400
+ [key: string]: unknown;
401
+ }>;
402
+ benchmarks: (q?: In<"foundry_listRegistryBenchmarksV2">) => Promise<{
403
+ version: 2;
404
+ snapshot: {
405
+ [key: string]: unknown;
406
+ };
407
+ data: import("./index.js").components["schemas"]["Foundry.PublicBenchmarkV2"][];
408
+ count: number;
409
+ page: {
410
+ count: number;
411
+ total: number;
412
+ limit: number;
413
+ next_cursor?: string | null;
414
+ has_more: boolean;
415
+ };
416
+ }>;
417
+ sources: (q?: In<"foundry_listRegistrySourcesV2">) => Promise<{
418
+ [key: string]: unknown;
419
+ }>;
420
+ provenance: (q?: In<"foundry_listRegistryProvenanceV2">) => Promise<{
421
+ [key: string]: unknown;
422
+ }>;
423
+ };
424
+ };
@@ -0,0 +1,133 @@
1
+ import { idempotencyHeaders } from './idempotency.js';
2
+ /** Foundry through the gateway (gateway/src/foundry-native.ts). Inference, receipts and key info are delegated for a
3
+ * login session; an org API key gets 403 FOUNDRY_HUMAN_SESSION_REQUIRED until Foundry admits key principals. A One app
4
+ * sign-in (`pf_one`) gets the prepaid child, which Foundry admits only for chat, responses, embeddings and messages;
5
+ * `universal`, `routing`, `tools`, `workloads`, `generation` and `keys.current` work today with a Console login (`pf_console`). Registry reads are public. Key writes are gateway-native and need an idempotency key.
6
+ * Canonical model ids are `vendor/name`: their `/` is sent as a path separator. */
7
+ export function foundryModule(client) {
8
+ const key = (id, k) => ({ headers: idempotencyHeaders(id, k) });
9
+ return {
10
+ /** Anthropic Messages (Foundry /api/v1/messages). */
11
+ messages: (body) => client.request('foundry_createMessage', { body }),
12
+ responses: (body) => client.request('foundry_createResponse', { body }),
13
+ rerank: (body) => client.request('foundry_createRerank', { body }),
14
+ images: {
15
+ create: (body) => client.request('foundry_createImage', { body }),
16
+ models: () => client.request('foundry_listImageModels'),
17
+ },
18
+ transcribe: (body) => client.request('foundry_createAudioTranscription', { body }),
19
+ receipts: {
20
+ get: (receipt_id) => client.request('foundry_getGenerationReceipt', { receipt_id }),
21
+ byRequest: (request_id) => client.request('foundry_getGenerationReceiptByRequest', { request_id }),
22
+ verificationKey: () => client.request('foundry_getReceiptVerificationKey'),
23
+ },
24
+ keys: {
25
+ list: () => client.request('foundry_listApiKeys'),
26
+ create: async (body, idempotencyKey) => client.request('foundry_createApiKey', { body }, key('foundry_createApiKey', idempotencyKey)),
27
+ delete: async (key_id, idempotencyKey) => client.request('foundry_deleteApiKey', { key_id }, key('foundry_deleteApiKey', idempotencyKey)),
28
+ rotate: async (key_id, idempotencyKey) => client.request('foundry_rotateApiKey', { key_id }, key('foundry_rotateApiKey', idempotencyKey)),
29
+ /** The Foundry credential the call carried (through the gateway: your login's delegated identity). */
30
+ current: () => client.request('foundry_getCurrentApiKey'),
31
+ },
32
+ reporting: {
33
+ requestLogs: (q = {}) => client.request('foundry_listRequestLogs', q),
34
+ providerCredentials: () => client.request('foundry_getProviderCredentialSummary'),
35
+ },
36
+ /** Refused to every caller today: Foundry gates these on its `admin` scope (403 SCOPE_MISSING). */
37
+ activity: {
38
+ list: (q = {}) => client.request('foundry_getActivity', q),
39
+ export: (q = {}) => client.request('foundry_exportActivity', q),
40
+ },
41
+ analytics: {
42
+ meta: () => client.request('foundry_getAnalyticsMeta'),
43
+ query: (body) => client.request('foundry_queryAnalytics', { body }),
44
+ },
45
+ /** Foundry universal API (/foundry/v1/*): `infer` for any modality, or a task wrapper. Paid. */
46
+ universal: {
47
+ infer: (body) => client.request('foundry_createInference', { body }),
48
+ /** Server-sent events: the raw Response. */
49
+ inferStream: (body) => client.request('foundry_streamInference', { body }),
50
+ classify: (body) => client.request('foundry_classifyText', { body }),
51
+ detect: (body) => client.request('foundry_detectObjects', { body }),
52
+ segment: (body) => client.request('foundry_segmentImage', { body }),
53
+ embed: (body) => client.request('foundry_embedTexts', { body }),
54
+ transcribe: (body) => client.request('foundry_transcribeAudio', { body }),
55
+ speak: (body) => client.request('foundry_synthesizeSpeech', { body }),
56
+ generateImage: (body) => client.request('foundry_generateImage', { body }),
57
+ predict: (body) => client.request('foundry_predictTabular', { body }),
58
+ forecast: (body) => client.request('foundry_forecastSeries', { body }),
59
+ recommend: (body) => client.request('foundry_recommendItems', { body }),
60
+ annotate: (body) => client.request('foundry_annotateText', { body }),
61
+ summarize: (body) => client.request('foundry_summarizeText', { body }),
62
+ },
63
+ /** Routing preview, explanation and eval planning: compute only. */
64
+ routing: {
65
+ preview: (body) => client.request('foundry_previewRoute', { body }),
66
+ explain: (id) => client.request('foundry_explainRoutingInvocation', { id }),
67
+ evals: {
68
+ plan: (body) => client.request('foundry_planRoutingEval', { body }),
69
+ dispatchPlan: (body) => client.request('foundry_dispatchRoutingEvalPlan', { body }),
70
+ aggregateDispatch: (body) => client.request('foundry_aggregateRoutingEvalDispatch', { body }),
71
+ aggregatePlanned: (body) => client.request('foundry_aggregatePlannedRoutingEval', { body }),
72
+ aggregate: (body) => client.request('foundry_aggregateRoutingEval', { body }),
73
+ claimReadiness: (body) => client.request('foundry_checkRoutingEvalClaimReadiness', { body }),
74
+ },
75
+ },
76
+ /** Cost and model comparison estimates: compute only, no provider call. */
77
+ tools: {
78
+ costEstimate: (body) => client.request('foundry_estimateCost', { body }),
79
+ compare: (body) => client.request('foundry_compareModels', { body }),
80
+ benchmark: (body) => client.request('foundry_benchmarkModels', { body }),
81
+ },
82
+ workloads: {
83
+ status: (workload_id) => client.request('foundry_getWorkloadStatus', { workload_id }),
84
+ terminate: (workload_id) => client.request('foundry_terminateWorkload', { workload_id }),
85
+ },
86
+ /** OpenRouter-style generation lookup by request id; content and feedback need Foundry `admin` (refused today). */
87
+ generation: {
88
+ get: (id) => client.request('foundry_getGeneration', { id }),
89
+ content: (id) => client.request('foundry_getGenerationContent', { id }),
90
+ feedback: (body) => client.request('foundry_submitGenerationFeedback', { body }),
91
+ },
92
+ batches: {
93
+ create: (body) => client.request('foundry_createBatch', { body }),
94
+ get: (batch_id) => client.request('foundry_getBatch', { batch_id }),
95
+ },
96
+ };
97
+ }
98
+ /** Public registry reads, V1 and paginated V2. */
99
+ export function foundryRegistry(client) {
100
+ return {
101
+ models: (q = {}) => client.request('foundry_listRegistryModels', q),
102
+ model: (canonical_model_id) => client.request('foundry_getRegistryModel', { canonical_model_id }),
103
+ offers: (canonical_model_id) => client.request('foundry_listModelOffers', { canonical_model_id }),
104
+ dossier: (canonical_model_id) => client.request('foundry_getModelDossier', { canonical_model_id }),
105
+ benchmarks: (canonical_model_id) => client.request('foundry_listModelBenchmarks', { canonical_model_id }),
106
+ sources: (canonical_model_id) => client.request('foundry_listModelSources', { canonical_model_id }),
107
+ providers: () => client.request('foundry_listRegistryProviders'),
108
+ provider: (provider_id) => client.request('foundry_getRegistryProvider', { provider_id }),
109
+ providerDossier: (provider_id) => client.request('foundry_getProviderDossier', { provider_id }),
110
+ facets: () => client.request('foundry_listRegistryFacets'),
111
+ modelBase: () => client.request('foundry_getCurrentModelBase'),
112
+ modelBaseReleases: () => client.request('foundry_listModelBaseReleases'),
113
+ labs: () => client.request('foundry_listRegistryLabs'),
114
+ lab: (lab_id) => client.request('foundry_getRegistryLab', { lab_id }),
115
+ compare: (q = {}) => client.request('foundry_compareRegistryModels', q),
116
+ v2: {
117
+ models: (q = {}) => client.request('foundry_listRegistryModelsV2', q),
118
+ model: (canonical_model_id) => client.request('foundry_getRegistryModelV2', { canonical_model_id }),
119
+ dossier: (canonical_model_id) => client.request('foundry_getModelDossierV2', { canonical_model_id }),
120
+ providers: (q = {}) => client.request('foundry_listRegistryProvidersV2', q),
121
+ provider: (provider_id) => client.request('foundry_getProviderDossierV2', { provider_id }),
122
+ facets: () => client.request('foundry_listRegistryFacetsV2'),
123
+ modelBase: () => client.request('foundry_getCurrentModelBaseV2'),
124
+ modelBaseReleases: () => client.request('foundry_listModelBaseReleasesV2'),
125
+ labs: (q = {}) => client.request('foundry_listRegistryLabsV2', q),
126
+ lab: (lab_id) => client.request('foundry_getRegistryLabV2', { lab_id }),
127
+ compare: () => client.request('foundry_compareRegistryModelsV2'),
128
+ benchmarks: (q = {}) => client.request('foundry_listRegistryBenchmarksV2', q),
129
+ sources: (q = {}) => client.request('foundry_listRegistrySourcesV2', q),
130
+ provenance: (q = {}) => client.request('foundry_listRegistryProvenanceV2', q),
131
+ },
132
+ };
133
+ }