@lifesi/genesis 0.0.0-stage → 0.1.1
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/dist/beacons.d.ts +19 -0
- package/dist/beacons.js +10 -0
- package/dist/client.d.ts +8261 -0
- package/dist/client.js +179 -0
- package/dist/dials.d.ts +129 -0
- package/dist/dials.js +59 -0
- package/dist/errors.d.ts +19 -0
- package/dist/errors.js +35 -0
- package/dist/fleets.d.ts +71 -0
- package/dist/fleets.js +44 -0
- package/dist/generated/operations.d.ts +8216 -0
- package/dist/generated/operations.js +9657 -0
- package/dist/generated/schema.d.ts +12834 -0
- package/dist/generated/schema.js +1 -0
- package/dist/genesis.d.ts +830 -0
- package/dist/genesis.js +136 -0
- package/dist/genesis.openapi.json +18131 -0
- package/dist/henry.d.ts +155 -0
- package/dist/henry.js +14 -0
- package/dist/hives-functions.d.ts +15 -0
- package/dist/hives-functions.js +94 -0
- package/dist/hives-node.d.ts +9 -0
- package/dist/hives-node.js +150 -0
- package/dist/hives-response.d.ts +2 -0
- package/dist/hives-response.js +32 -0
- package/dist/hives-upload.d.ts +9 -0
- package/dist/hives-upload.js +23 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +10 -0
- package/dist/runner.d.ts +52 -0
- package/dist/runner.js +112 -0
- package/dist/types.d.ts +80 -0
- package/dist/types.js +1 -0
- package/package.json +26 -3
- package/README.md +0 -3
package/dist/genesis.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { beaconsModule } from './beacons.js';
|
|
2
|
+
import { dialsModule } from './dials.js';
|
|
3
|
+
import { GenesisClient } from './client.js';
|
|
4
|
+
import { henryModule } from './henry.js';
|
|
5
|
+
import { fleetsModule } from './fleets.js';
|
|
6
|
+
import { hivesUploadBody } from './hives-upload.js';
|
|
7
|
+
import { runnerModule } from './runner.js';
|
|
8
|
+
/**
|
|
9
|
+
* The Genesis SDK: one client, every service.
|
|
10
|
+
* const genesis = new Genesis(); // GENESIS_API_KEY or `genesis login`
|
|
11
|
+
* await genesis.hives.projects.list();
|
|
12
|
+
* await genesis.foundry.chat({ model: 'x', messages: [{ role: 'user', content: 'hi' }] });
|
|
13
|
+
*/
|
|
14
|
+
export class Genesis extends GenesisClient {
|
|
15
|
+
constructor(opts = {}) { super(opts); }
|
|
16
|
+
/** Generic escape hatch: genesis.call('hives_list_projects', {...}) */
|
|
17
|
+
call = this.request.bind(this);
|
|
18
|
+
dials = dialsModule(this);
|
|
19
|
+
henry = henryModule(this);
|
|
20
|
+
fleets = fleetsModule(this);
|
|
21
|
+
runner = runnerModule(this);
|
|
22
|
+
beacons = beaconsModule(this);
|
|
23
|
+
foundry = {
|
|
24
|
+
models: {
|
|
25
|
+
list: () => this.request('foundry_listModels'),
|
|
26
|
+
},
|
|
27
|
+
/** OpenAI-compatible chat completion (non-streaming). */
|
|
28
|
+
chat: (body) => this.request('foundry_createChatCompletion', { body: { ...body, stream: false } }),
|
|
29
|
+
/** Streaming chat: yields content deltas parsed from the SSE stream. */
|
|
30
|
+
chatStream: (body) => this.streamChat(body),
|
|
31
|
+
embeddings: (body) => this.request('foundry_createEmbedding', { body }),
|
|
32
|
+
registry: {
|
|
33
|
+
models: (q = {}) => this.request('foundry_listRegistryModels', q),
|
|
34
|
+
model: (canonical_model_id) => this.request('foundry_getRegistryModel', { canonical_model_id }),
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
hives = {
|
|
38
|
+
projects: {
|
|
39
|
+
list: (q = {}) => this.request('hives_list_projects', q),
|
|
40
|
+
get: (project_id) => this.request('hives_get_project', { project_id }),
|
|
41
|
+
create: (body) => this.request('hives_create_project', { body }),
|
|
42
|
+
update: (project_id, body) => this.request('hives_update_project', { project_id, body }),
|
|
43
|
+
activity: (project_id, q = {}) => this.request('hives_get_project_activity', { ...q, project_id }),
|
|
44
|
+
delete: (project_id) => this.request('hives_delete_project', { project_id }),
|
|
45
|
+
},
|
|
46
|
+
secrets: {
|
|
47
|
+
list: (project_id, q = {}) => this.request('hives_list_secrets', { ...q, project_id }),
|
|
48
|
+
get: (project_id, secret_id) => this.request('hives_get_secret', { project_id, secret_id }),
|
|
49
|
+
create: (project_id, body) => this.request('hives_create_secret', { project_id, body }),
|
|
50
|
+
update: (project_id, secret_id, body) => this.request('hives_update_secret', { project_id, secret_id, body }),
|
|
51
|
+
delete: (project_id, secret_id) => this.request('hives_delete_secret', { project_id, secret_id }),
|
|
52
|
+
/** Explicit sensitive operation. Do not log or retain the returned plaintext. */
|
|
53
|
+
reveal: (project_id, secret_id) => this.request('hives_reveal_secret', { project_id, secret_id }),
|
|
54
|
+
bulkUpsert: (project_id, body) => this.request('hives_bulk_upsert_secrets', { project_id, body }),
|
|
55
|
+
},
|
|
56
|
+
deployments: {
|
|
57
|
+
list: (project_id, q = {}) => this.request('hives_list_deployments', { ...q, project_id }),
|
|
58
|
+
get: (project_id, deployment_id) => this.request('hives_get_deployment', { project_id, deployment_id }),
|
|
59
|
+
upload: async (project_id, file, options = {}) => this.request('hives_upload_deployment', { project_id, body: await hivesUploadBody(file, options) }),
|
|
60
|
+
create: (project_id, body) => this.request('hives_create_deployment', { project_id, body }),
|
|
61
|
+
promote: (project_id, deployment_id) => this.request('hives_promote_deployment', { project_id, deployment_id }),
|
|
62
|
+
rollback: (project_id, deployment_id, body = {}) => this.request('hives_rollback_deployment', { project_id, deployment_id, body }),
|
|
63
|
+
cancel: (project_id, deployment_id) => this.request('hives_cancel_deployment', { project_id, deployment_id }),
|
|
64
|
+
delete: (project_id, deployment_id) => this.request('hives_delete_deployment', { project_id, deployment_id }),
|
|
65
|
+
logs: (project_id, deployment_id, q = {}) => this.request('hives_query_deployment_logs', { ...q, project_id, deployment_id }),
|
|
66
|
+
invoke: (project_id, deployment_id, body = {}, init = {}) => this.raw('hives_invoke_deployment', { project_id, deployment_id, body }, init),
|
|
67
|
+
},
|
|
68
|
+
functions: {
|
|
69
|
+
list: (project_id, q = {}) => this.request('hives_list_functions', { ...q, project_id }),
|
|
70
|
+
get: (project_id, function_id) => this.request('hives_get_function', { project_id, function_id }),
|
|
71
|
+
create: (project_id, body) => this.request('hives_create_function', { project_id, body }),
|
|
72
|
+
update: (project_id, function_id, body) => this.request('hives_update_function', { project_id, function_id, body }),
|
|
73
|
+
delete: (project_id, function_id) => this.request('hives_delete_function', { project_id, function_id }),
|
|
74
|
+
/** Completed raw guest response; parse text/JSON/bytes explicitly. Never follows redirects. */
|
|
75
|
+
invoke: (project_id, function_id, body = {}, init = {}) => this.raw('hives_invoke_function', { project_id, function_id, body }, init),
|
|
76
|
+
},
|
|
77
|
+
regions: { list: () => this.request('hives_list_regions') },
|
|
78
|
+
};
|
|
79
|
+
relays = {
|
|
80
|
+
zones: {
|
|
81
|
+
list: (q = {}) => this.request('relays_listZones', q),
|
|
82
|
+
get: (zone) => this.request('relays_getZone', { zone }),
|
|
83
|
+
create: (body) => this.request('relays_createZone', { body }),
|
|
84
|
+
delete: (zone) => this.request('relays_deleteZone', { zone }),
|
|
85
|
+
},
|
|
86
|
+
records: {
|
|
87
|
+
list: (zone, q = {}) => this.request('relays_listRecords', { zone, ...q }),
|
|
88
|
+
create: (zone, body) => this.request('relays_createRecord', { zone, body }),
|
|
89
|
+
update: (zone, recordId, body) => this.request('relays_updateRecord', { zone, recordId, body }),
|
|
90
|
+
delete: (zone, recordId) => this.request('relays_deleteRecord', { zone, recordId }),
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
/** LifeID org API keys (WorkOS). custody 'blinds' = key goes straight to Blinds, never shown. */
|
|
94
|
+
keys = {
|
|
95
|
+
list: (org_id) => this.request('iam_listOrgApiKeys', { org_id }),
|
|
96
|
+
create: (org_id, body) => this.request('iam_createOrgApiKey', { org_id, body }),
|
|
97
|
+
revoke: (key_id) => this.request('iam_revokeApiKey', { key_id }),
|
|
98
|
+
};
|
|
99
|
+
/** Who is this credential? (LifeID verify: org, principal, scopes, kind) */
|
|
100
|
+
async whoami() {
|
|
101
|
+
const credential_value = await this.credential();
|
|
102
|
+
if (!credential_value)
|
|
103
|
+
throw new Error('No Genesis credential. Run `genesis login`, or set GENESIS_API_KEY.');
|
|
104
|
+
return this.request('iam_verifyCredential', { body: { credential_value } });
|
|
105
|
+
}
|
|
106
|
+
async *streamChat(body) {
|
|
107
|
+
const res = await this.raw('foundry_createChatCompletion', { body: { ...body, stream: true } }, { headers: { accept: 'text/event-stream' } });
|
|
108
|
+
if (!res.body)
|
|
109
|
+
return;
|
|
110
|
+
const reader = res.body.getReader();
|
|
111
|
+
const dec = new TextDecoder();
|
|
112
|
+
let buf = '';
|
|
113
|
+
for (;;) {
|
|
114
|
+
const { done, value } = await reader.read();
|
|
115
|
+
if (done)
|
|
116
|
+
break;
|
|
117
|
+
buf += dec.decode(value, { stream: true });
|
|
118
|
+
let i;
|
|
119
|
+
while ((i = buf.indexOf('\n')) >= 0) {
|
|
120
|
+
const line = buf.slice(0, i).trim();
|
|
121
|
+
buf = buf.slice(i + 1);
|
|
122
|
+
if (!line.startsWith('data:'))
|
|
123
|
+
continue;
|
|
124
|
+
const data = line.slice(5).trim();
|
|
125
|
+
if (data === '[DONE]')
|
|
126
|
+
return;
|
|
127
|
+
try {
|
|
128
|
+
const d = JSON.parse(data).choices?.[0]?.delta?.content;
|
|
129
|
+
if (d)
|
|
130
|
+
yield d;
|
|
131
|
+
}
|
|
132
|
+
catch { /* ignore keepalives */ }
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|