@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.
- package/README.md +29 -0
- package/dist/auto.d.ts +1010 -0
- package/dist/auto.js +125 -0
- package/dist/beacons.d.ts +145 -0
- package/dist/beacons.js +148 -0
- package/dist/blinds-owner-enrollment.d.ts +280 -0
- package/dist/blinds-owner-enrollment.js +169 -0
- package/dist/client.d.ts +52 -0
- package/dist/client.js +384 -0
- package/dist/context.d.ts +50 -0
- package/dist/context.js +153 -0
- package/dist/dials.d.ts +299 -0
- package/dist/dials.js +100 -0
- package/dist/errors.d.ts +35 -0
- package/dist/errors.js +66 -0
- package/dist/flares.d.ts +202 -0
- package/dist/flares.js +61 -0
- package/dist/fleets.d.ts +218 -0
- package/dist/fleets.js +189 -0
- package/dist/flocks.d.ts +439 -0
- package/dist/flocks.js +98 -0
- package/dist/foundry-billing.d.ts +97 -0
- package/dist/foundry-billing.js +107 -0
- package/dist/foundry.d.ts +424 -0
- package/dist/foundry.js +133 -0
- package/dist/garden.d.ts +754 -0
- package/dist/garden.js +76 -0
- package/dist/gateway.d.ts +365 -0
- package/dist/gateway.js +82 -0
- package/dist/gears.d.ts +226 -0
- package/dist/gears.js +42 -0
- package/dist/generated/operations.d.ts +4 -0
- package/dist/generated/operations.js +65134 -0
- package/dist/generated/schema.d.ts +87658 -0
- package/dist/generated/schema.js +1 -0
- package/dist/genesis.d.ts +9574 -0
- package/dist/genesis.js +271 -0
- package/dist/genesis.openapi.json +128522 -0
- package/dist/henry.d.ts +369 -0
- package/dist/henry.js +268 -0
- package/dist/hives-cells.d.ts +127 -0
- package/dist/hives-cells.js +151 -0
- package/dist/hives-environment.d.ts +37 -0
- package/dist/hives-environment.js +80 -0
- package/dist/hives-functions.d.ts +36 -0
- package/dist/hives-functions.js +185 -0
- package/dist/hives-marketplace.d.ts +128 -0
- package/dist/hives-marketplace.js +187 -0
- package/dist/hives-node.d.ts +9 -0
- package/dist/hives-node.js +155 -0
- package/dist/hives-operations.d.ts +451 -0
- package/dist/hives-operations.js +43 -0
- package/dist/hives-platform.d.ts +149 -0
- package/dist/hives-platform.js +183 -0
- package/dist/hives-queue-consumer.d.ts +56 -0
- package/dist/hives-queue-consumer.js +95 -0
- package/dist/hives-queue-funding.d.ts +28 -0
- package/dist/hives-queue-funding.js +81 -0
- package/dist/hives-queues.d.ts +137 -0
- package/dist/hives-queues.js +143 -0
- package/dist/hives-resources-transport.d.ts +23 -0
- package/dist/hives-resources-transport.js +204 -0
- package/dist/hives-response.d.ts +2 -0
- package/dist/hives-response.js +32 -0
- package/dist/hives-runtimes.d.ts +34 -0
- package/dist/hives-runtimes.js +32 -0
- package/dist/hives-sse.d.ts +24 -0
- package/dist/hives-sse.js +111 -0
- package/dist/hives-topics.d.ts +51 -0
- package/dist/hives-topics.js +79 -0
- package/dist/hives-upload.d.ts +9 -0
- package/dist/hives-upload.js +23 -0
- package/dist/hives-volumes.d.ts +64 -0
- package/dist/hives-volumes.js +117 -0
- package/dist/iam-directory.d.ts +8 -0
- package/dist/iam-directory.js +23 -0
- package/dist/iam.d.ts +391 -0
- package/dist/iam.js +92 -0
- package/dist/idempotency.d.ts +7 -0
- package/dist/idempotency.js +39 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +37 -0
- package/dist/instances.d.ts +200 -0
- package/dist/instances.js +43 -0
- package/dist/lanes.d.ts +267 -0
- package/dist/lanes.js +41 -0
- package/dist/minds-agent.d.ts +88 -0
- package/dist/minds-agent.js +233 -0
- package/dist/minds-engine.d.ts +394 -0
- package/dist/minds-engine.js +555 -0
- package/dist/minds-owner.d.ts +110 -0
- package/dist/minds-owner.js +226 -0
- package/dist/minds.d.ts +377 -0
- package/dist/minds.js +228 -0
- package/dist/orgs.d.ts +405 -0
- package/dist/orgs.js +63 -0
- package/dist/relays-enrollment.d.ts +33 -0
- package/dist/relays-enrollment.js +115 -0
- package/dist/runner-grant.d.ts +10 -0
- package/dist/runner-grant.js +133 -0
- package/dist/runner.d.ts +72 -0
- package/dist/runner.js +117 -0
- package/dist/scopes.d.ts +310 -0
- package/dist/scopes.js +40 -0
- package/dist/taps.d.ts +118 -0
- package/dist/taps.js +45 -0
- package/dist/traces.d.ts +574 -0
- package/dist/traces.js +97 -0
- package/dist/types.d.ts +98 -0
- package/dist/types.js +1 -0
- package/dist/urls.d.ts +6 -0
- package/dist/urls.js +31 -0
- package/package.json +49 -1
package/dist/genesis.js
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { selectGenesisContext } from './context.js';
|
|
2
|
+
import { mindsModule } from './minds.js';
|
|
3
|
+
import { mindsEngineModule } from './minds-engine.js';
|
|
4
|
+
import { foundryBilling } from './foundry-billing.js';
|
|
5
|
+
import { foundryModule, foundryRegistry } from './foundry.js';
|
|
6
|
+
import { relaysEnrollment } from './relays-enrollment.js';
|
|
7
|
+
import { blindsModule } from './blinds-owner-enrollment.js';
|
|
8
|
+
import { beaconsModule } from './beacons.js';
|
|
9
|
+
import { dialsModule } from './dials.js';
|
|
10
|
+
import { GenesisClient } from './client.js';
|
|
11
|
+
import { henryModule } from './henry.js';
|
|
12
|
+
import { fleetsModule } from './fleets.js';
|
|
13
|
+
import { flocksModule } from './flocks.js';
|
|
14
|
+
import { rigsModule, panesModule, shellsModule } from './instances.js';
|
|
15
|
+
import { gearsModule } from './gears.js';
|
|
16
|
+
import { autoModule } from './auto.js';
|
|
17
|
+
import { scopesModule } from './scopes.js';
|
|
18
|
+
import { gardenModule } from './garden.js';
|
|
19
|
+
import { tapsModule } from './taps.js';
|
|
20
|
+
import { lanesModule } from './lanes.js';
|
|
21
|
+
import { flaresModule } from './flares.js';
|
|
22
|
+
import { tracesModule } from './traces.js';
|
|
23
|
+
import { billingModule, gatewayModule, orgsModule } from './gateway.js';
|
|
24
|
+
import { orgsEntitiesModule } from './orgs.js';
|
|
25
|
+
import { iamModule } from './iam.js';
|
|
26
|
+
import { hivesUploadBody } from './hives-upload.js';
|
|
27
|
+
import { runnerModule } from './runner.js';
|
|
28
|
+
import { hivesOperations } from './hives-operations.js';
|
|
29
|
+
import { hivesMarketplace } from './hives-marketplace.js';
|
|
30
|
+
import { hivesVolumes } from './hives-volumes.js';
|
|
31
|
+
import { hivesInvokeHeaders, hivesOperationStatus } from './hives-functions.js';
|
|
32
|
+
/**
|
|
33
|
+
* The Genesis SDK: one client, every service.
|
|
34
|
+
* const genesis = new Genesis(); // GENESIS_API_KEY or `genesis login`
|
|
35
|
+
* await genesis.hives.projects.list();
|
|
36
|
+
* await genesis.foundry.chat({ model: 'x', messages: [{ role: 'user', content: 'hi' }] });
|
|
37
|
+
*/
|
|
38
|
+
export class Genesis extends GenesisClient {
|
|
39
|
+
constructor(opts = {}) { super(opts); }
|
|
40
|
+
/** Generic escape hatch: genesis.call('hives_list_projects', {...}) */
|
|
41
|
+
// Typed as request's own signature: `.bind` over a generic with ~1260 operation ids exceeds tsc's union limit (TS2590).
|
|
42
|
+
call = (operationId, input, init) => this.request(operationId, input, init);
|
|
43
|
+
context = { select: (selection, options = {}) => selectGenesisContext(selection, { credential: () => this.credential(), fetch: this.contextFetch, signal: options.signal }) };
|
|
44
|
+
/** minds.engine: every tenant Minds engine (Akasha daemon) route, one capability per call. */
|
|
45
|
+
minds = { ...mindsModule(this), engine: mindsEngineModule(this) };
|
|
46
|
+
blinds = blindsModule(this);
|
|
47
|
+
dials = dialsModule(this);
|
|
48
|
+
henry = henryModule(this);
|
|
49
|
+
fleets = fleetsModule(this);
|
|
50
|
+
runner = runnerModule(this);
|
|
51
|
+
beacons = beaconsModule(this);
|
|
52
|
+
flocks = flocksModule(this);
|
|
53
|
+
rigs = rigsModule(this);
|
|
54
|
+
panes = panesModule(this);
|
|
55
|
+
shells = shellsModule(this);
|
|
56
|
+
gears = gearsModule(this);
|
|
57
|
+
auto = autoModule(this);
|
|
58
|
+
scopes = scopesModule(this);
|
|
59
|
+
garden = gardenModule(this);
|
|
60
|
+
lanes = lanesModule(this);
|
|
61
|
+
flares = flaresModule(this);
|
|
62
|
+
gateway = gatewayModule(this);
|
|
63
|
+
/** Your organization's usage and billing reads, and Orgs: legal entities, seats, resolutions, documents, filings, formation and the record. */
|
|
64
|
+
orgs = { ...orgsModule(this), ...orgsEntitiesModule(this) };
|
|
65
|
+
billing = billingModule(this);
|
|
66
|
+
/** IAM v4: organizations, fleets, agents, roles, grants, capabilities and checks (login or org API key with iam:read / iam:write). */
|
|
67
|
+
iam = iamModule(this);
|
|
68
|
+
taps = tapsModule(this);
|
|
69
|
+
foundry = {
|
|
70
|
+
...foundryModule(this),
|
|
71
|
+
billing: foundryBilling(this),
|
|
72
|
+
models: {
|
|
73
|
+
list: () => this.request('foundry_listModels'),
|
|
74
|
+
},
|
|
75
|
+
/** OpenAI-compatible chat completion (non-streaming). */
|
|
76
|
+
chat: (body) => this.request('foundry_createChatCompletion', { body: { ...body, stream: false } }),
|
|
77
|
+
/** Streaming chat: yields content deltas parsed from the SSE stream. */
|
|
78
|
+
chatStream: (body) => this.streamChat(body),
|
|
79
|
+
embeddings: (body) => this.request('foundry_createEmbedding', { body }),
|
|
80
|
+
registry: foundryRegistry(this),
|
|
81
|
+
};
|
|
82
|
+
hives = {
|
|
83
|
+
...hivesOperations(this),
|
|
84
|
+
volumes: hivesVolumes(this),
|
|
85
|
+
marketplace: hivesMarketplace(this),
|
|
86
|
+
/** The gateway resolves the current authorized selection from an interactive One account session. */
|
|
87
|
+
context: {
|
|
88
|
+
get: () => this.request('hives_get_context_project'),
|
|
89
|
+
set: (body) => this.request('hives_set_context_project', { body }),
|
|
90
|
+
/** Detach this selection; the service project and customer resources are retained. */
|
|
91
|
+
detach: () => this.request('hives_detach_context_project'),
|
|
92
|
+
},
|
|
93
|
+
environment: {
|
|
94
|
+
list: (project_id, q = {}) => this.request('hives_list_project_environment', { ...q, project_id }),
|
|
95
|
+
upsert: (project_id, body) => this.request('hives_update_project_environment', { project_id, body }),
|
|
96
|
+
/** Explicit KMS reveal with a persisted names-only audit. Do not log the plaintext. */
|
|
97
|
+
reveal: (project_id, key) => this.request('hives_reveal_project_environment', { project_id, key }),
|
|
98
|
+
},
|
|
99
|
+
projects: {
|
|
100
|
+
list: (q = {}) => this.request('hives_list_projects', q),
|
|
101
|
+
get: (project_id) => this.request('hives_get_project', { project_id }),
|
|
102
|
+
create: (body) => this.request('hives_create_project', { body }),
|
|
103
|
+
update: (project_id, body) => this.request('hives_update_project', { project_id, body }),
|
|
104
|
+
activity: (project_id, q = {}) => this.request('hives_get_project_activity', { ...q, project_id }),
|
|
105
|
+
delete: (project_id) => this.request('hives_delete_project', { project_id }),
|
|
106
|
+
},
|
|
107
|
+
secrets: {
|
|
108
|
+
list: (project_id, q = {}) => this.request('hives_list_secrets', { ...q, project_id }),
|
|
109
|
+
get: (project_id, secret_id) => this.request('hives_get_secret', { project_id, secret_id }),
|
|
110
|
+
create: (project_id, body) => this.request('hives_create_secret', { project_id, body }),
|
|
111
|
+
update: (project_id, secret_id, body) => this.request('hives_update_secret', { project_id, secret_id, body }),
|
|
112
|
+
delete: (project_id, secret_id) => this.request('hives_delete_secret', { project_id, secret_id }),
|
|
113
|
+
/** Explicit sensitive operation. Do not log or retain the returned plaintext. */
|
|
114
|
+
reveal: (project_id, secret_id) => this.request('hives_reveal_secret', { project_id, secret_id }),
|
|
115
|
+
bulkUpsert: (project_id, body) => this.request('hives_bulk_upsert_secrets', { project_id, body }),
|
|
116
|
+
},
|
|
117
|
+
deployments: {
|
|
118
|
+
list: (project_id, q = {}) => this.request('hives_list_deployments', { ...q, project_id }),
|
|
119
|
+
get: (project_id, deployment_id) => this.request('hives_get_deployment', { project_id, deployment_id }),
|
|
120
|
+
upload: async (project_id, file, options = {}) => this.request('hives_upload_deployment', { project_id, body: await hivesUploadBody(file, options) }),
|
|
121
|
+
create: (project_id, body) => this.request('hives_create_deployment', { project_id, body }),
|
|
122
|
+
promote: (project_id, deployment_id) => this.request('hives_promote_deployment', { project_id, deployment_id }),
|
|
123
|
+
rollback: (project_id, deployment_id, body = {}) => this.request('hives_rollback_deployment', { project_id, deployment_id, body }),
|
|
124
|
+
cancel: (project_id, deployment_id) => this.request('hives_cancel_deployment', { project_id, deployment_id }),
|
|
125
|
+
stop: (project_id, deployment_id, init = {}) => this.request('hives_stop_deployment', { project_id, deployment_id }, init),
|
|
126
|
+
delete: (project_id, deployment_id) => this.request('hives_delete_deployment', { project_id, deployment_id }),
|
|
127
|
+
logs: (project_id, deployment_id, q = {}) => this.request('hives_query_deployment_logs', { ...q, project_id, deployment_id }),
|
|
128
|
+
invoke: (project_id, deployment_id, body = {}, init = {}) => this.raw('hives_invoke_deployment', { project_id, deployment_id, body }, init),
|
|
129
|
+
},
|
|
130
|
+
functions: {
|
|
131
|
+
list: (project_id, q = {}) => this.request('hives_list_functions', { ...q, project_id }),
|
|
132
|
+
get: (project_id, function_id) => this.request('hives_get_function', { project_id, function_id }),
|
|
133
|
+
create: (project_id, body) => this.request('hives_create_function', { project_id, body }),
|
|
134
|
+
update: (project_id, function_id, body) => this.request('hives_update_function', { project_id, function_id, body }),
|
|
135
|
+
delete: (project_id, function_id) => this.request('hives_delete_function', { project_id, function_id }),
|
|
136
|
+
/** Completed raw guest response; parse text/JSON/bytes explicitly. Never follows redirects. */
|
|
137
|
+
invoke: (project_id, function_id, body = {}, init = {}) => this.raw('hives_invoke_function', { project_id, function_id, body }, { signal: init.signal, headers: hivesInvokeHeaders(init) }),
|
|
138
|
+
/** Compatibility alias of invoke: the same completed raw guest response, no durable queue. */
|
|
139
|
+
invokeAsync: (project_id, function_id, body = {}, init = {}) => this.raw('hives_invoke_function_async', { project_id, function_id, body }, { signal: init.signal, headers: hivesInvokeHeaders(init) }),
|
|
140
|
+
operations: {
|
|
141
|
+
get: async (project_id, function_id, operation_id, init = {}) => hivesOperationStatus(await this.request('hives_get_function_operation', { project_id, function_id, operation_id }, init), operation_id),
|
|
142
|
+
release: async (project_id, function_id, operation_id, init = {}) => hivesOperationStatus(await this.request('hives_release_function_operation', { project_id, function_id, operation_id }, init), operation_id),
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
regions: { list: () => this.request('hives_list_regions') },
|
|
146
|
+
};
|
|
147
|
+
silos = {
|
|
148
|
+
/** Silos queries, compute time and storage of the selected Genesis project, last 30 days. */
|
|
149
|
+
usage: () => this.request('silos_getUsage'),
|
|
150
|
+
/** Regions Silos instances are created in. */
|
|
151
|
+
regions: { list: () => this.request('silos_listRegions') },
|
|
152
|
+
/** Database instances in the selected Genesis project; Silos verifies the signed selection. */
|
|
153
|
+
instances: {
|
|
154
|
+
list: () => this.request('silos_listInstances'),
|
|
155
|
+
create: (body) => this.request('silos_createInstance', { body }),
|
|
156
|
+
get: (instance_id) => this.request('silos_getInstance', { instance_id }),
|
|
157
|
+
/** Rename within the selected project; 409 when the name is taken. */
|
|
158
|
+
update: (instance_id, body) => this.request('silos_updateInstance', { instance_id, body }),
|
|
159
|
+
/** Removes the instance from the project and stops it; resolves with no body (204). */
|
|
160
|
+
delete: (instance_id) => this.request('silos_deleteInstance', { instance_id }),
|
|
161
|
+
/** Checkpoint, then stop. A later statement or resume starts it again. */
|
|
162
|
+
suspend: (instance_id) => this.request('silos_suspendInstance', { instance_id }),
|
|
163
|
+
resume: (instance_id) => this.request('silos_resumeInstance', { instance_id }),
|
|
164
|
+
/** One SQL statement, run once (never replayed) and metered on success. */
|
|
165
|
+
query: (instance_id, body) => this.request('silos_queryInstance', { instance_id, body }),
|
|
166
|
+
/** Up to 50 statements in one transaction: all commit or none do. */
|
|
167
|
+
batch: (instance_id, body) => this.request('silos_queryInstanceBatch', { instance_id, body }),
|
|
168
|
+
metrics: (instance_id) => this.request('silos_getInstanceMetrics', { instance_id }),
|
|
169
|
+
/** Waits up to waitMs (≤ 15000) for NOTIFY on the channels; call again to keep listening. */
|
|
170
|
+
listen: (instance_id, body) => this.request('silos_listenInstance', { instance_id, body }),
|
|
171
|
+
branches: {
|
|
172
|
+
list: (instance_id) => this.request('silos_listInstanceBranches', { instance_id }),
|
|
173
|
+
/** Copies the parent's latest checkpoint (the default branch when no parent is given). */
|
|
174
|
+
create: (instance_id, body) => this.request('silos_createInstanceBranch', { instance_id, body }),
|
|
175
|
+
get: (instance_id, branch_id) => this.request('silos_getInstanceBranch', { instance_id, branch_id }),
|
|
176
|
+
update: (instance_id, branch_id, body) => this.request('silos_updateInstanceBranch', { instance_id, branch_id, body }),
|
|
177
|
+
delete: (instance_id, branch_id) => this.request('silos_deleteInstanceBranch', { instance_id, branch_id }),
|
|
178
|
+
/** Replaces the branch's data with a stored snapshot. */
|
|
179
|
+
restore: (instance_id, branch_id, body) => this.request('silos_restoreInstanceBranch', { instance_id, branch_id, body }),
|
|
180
|
+
},
|
|
181
|
+
snapshots: {
|
|
182
|
+
list: (instance_id) => this.request('silos_listInstanceSnapshots', { instance_id }),
|
|
183
|
+
create: (instance_id, body = {}) => this.request('silos_createInstanceSnapshot', { instance_id, body }),
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
traces = tracesModule(this);
|
|
188
|
+
relays = {
|
|
189
|
+
enrollment: relaysEnrollment(this),
|
|
190
|
+
zones: {
|
|
191
|
+
list: (q = {}) => this.request('relays_listZones', q),
|
|
192
|
+
get: (zone) => this.request('relays_getZone', { zone }),
|
|
193
|
+
dnssec: (zone) => this.request('relays_getDnssec', { zone }),
|
|
194
|
+
create: (body) => this.request('relays_createZone', { body }),
|
|
195
|
+
update: (zone, body) => this.request('relays_updateZone', { zone, body }),
|
|
196
|
+
delete: (zone) => this.request('relays_deleteZone', { zone }),
|
|
197
|
+
},
|
|
198
|
+
records: {
|
|
199
|
+
list: (zone, q = {}) => this.request('relays_listRecords', { zone, ...q }),
|
|
200
|
+
get: (zone, recordId) => this.request('relays_getRecord', { zone, recordId }),
|
|
201
|
+
/** One record, or up to 100 with { records: [...] }. */
|
|
202
|
+
create: (zone, body) => this.request('relays_createRecord', { zone, body }),
|
|
203
|
+
update: (zone, recordId, body) => this.request('relays_updateRecord', { zone, recordId, body }),
|
|
204
|
+
delete: (zone, recordId) => this.request('relays_deleteRecord', { zone, recordId }),
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
/** One account org API keys (WorkOS). custody 'blinds' = key goes straight to Blinds, never shown. */
|
|
208
|
+
keys = {
|
|
209
|
+
list: (org_id) => this.request('iam_listOrgApiKeys', { org_id }),
|
|
210
|
+
create: (org_id, body) => this.request('iam_createOrgApiKey', { org_id, body }),
|
|
211
|
+
revoke: (key_id) => this.request('iam_revokeApiKey', { key_id }),
|
|
212
|
+
};
|
|
213
|
+
/** IAM organization directory: projects. One account login (human session) only; writes need iam:write and owner/admin. */
|
|
214
|
+
projects = {
|
|
215
|
+
list: (org_id) => this.request('iam_listProjects', { org_id }),
|
|
216
|
+
get: (org_id, project_id) => this.request('iam_getProject', { org_id, project_id }),
|
|
217
|
+
/** Reuse the same idempotencyKey to replay an uncertain create instead of making a second project. */
|
|
218
|
+
create: (org_id, body, idempotencyKey) => this.request('iam_createProject', { org_id, body }, { headers: { 'idempotency-key': idempotencyKey } }),
|
|
219
|
+
update: (org_id, project_id, body) => this.request('iam_updateProject', { org_id, project_id, body }),
|
|
220
|
+
rename: (org_id, project_id, name) => this.request('iam_updateProject', { org_id, project_id, body: { name } }),
|
|
221
|
+
/** Permanent; IAM refuses while workspaces, fleets or grants reference the project. */
|
|
222
|
+
delete: (org_id, project_id) => this.request('iam_deleteProject', { org_id, project_id }),
|
|
223
|
+
};
|
|
224
|
+
/** IAM organization directory: workspaces. One account login (human session) only; writes need iam:write and owner/admin. */
|
|
225
|
+
workspaces = {
|
|
226
|
+
list: (org_id) => this.request('iam_listWorkspaces', { org_id }),
|
|
227
|
+
get: (org_id, workspace_id) => this.request('iam_getWorkspace', { org_id, workspace_id }),
|
|
228
|
+
create: (org_id, body, idempotencyKey) => this.request('iam_createWorkspace', { org_id, body }, { headers: { 'idempotency-key': idempotencyKey } }),
|
|
229
|
+
update: (org_id, workspace_id, body) => this.request('iam_updateWorkspace', { org_id, workspace_id, body }),
|
|
230
|
+
rename: (org_id, workspace_id, name) => this.request('iam_updateWorkspace', { org_id, workspace_id, body: { name } }),
|
|
231
|
+
/** Permanent; IAM refuses while fleets or grants reference the workspace. */
|
|
232
|
+
delete: (org_id, workspace_id) => this.request('iam_deleteWorkspace', { org_id, workspace_id }),
|
|
233
|
+
};
|
|
234
|
+
/** Who is this credential? (One account verify: org, principal, scopes, kind) */
|
|
235
|
+
async whoami() {
|
|
236
|
+
const credential_value = await this.credential();
|
|
237
|
+
if (!credential_value)
|
|
238
|
+
throw new Error('No Genesis credential. Run `genesis login`, or set GENESIS_API_KEY.');
|
|
239
|
+
return this.request('iam_verifyCredential', { body: { credential_value } });
|
|
240
|
+
}
|
|
241
|
+
async *streamChat(body) {
|
|
242
|
+
const res = await this.raw('foundry_createChatCompletion', { body: { ...body, stream: true } }, { headers: { accept: 'text/event-stream' } });
|
|
243
|
+
if (!res.body)
|
|
244
|
+
return;
|
|
245
|
+
const reader = res.body.getReader();
|
|
246
|
+
const dec = new TextDecoder();
|
|
247
|
+
let buf = '';
|
|
248
|
+
for (;;) {
|
|
249
|
+
const { done, value } = await reader.read();
|
|
250
|
+
if (done)
|
|
251
|
+
break;
|
|
252
|
+
buf += dec.decode(value, { stream: true });
|
|
253
|
+
let i;
|
|
254
|
+
while ((i = buf.indexOf('\n')) >= 0) {
|
|
255
|
+
const line = buf.slice(0, i).trim();
|
|
256
|
+
buf = buf.slice(i + 1);
|
|
257
|
+
if (!line.startsWith('data:'))
|
|
258
|
+
continue;
|
|
259
|
+
const data = line.slice(5).trim();
|
|
260
|
+
if (data === '[DONE]')
|
|
261
|
+
return;
|
|
262
|
+
try {
|
|
263
|
+
const d = JSON.parse(data).choices?.[0]?.delta?.content;
|
|
264
|
+
if (d)
|
|
265
|
+
yield d;
|
|
266
|
+
}
|
|
267
|
+
catch { /* ignore keepalives */ }
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|