@onesi/genesis 0.0.0-stage → 0.1.13
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 +28 -2
- package/dist/beacons.d.ts +103 -0
- package/dist/beacons.js +77 -0
- package/dist/blinds-owner-enrollment.d.ts +171 -0
- package/dist/blinds-owner-enrollment.js +150 -0
- package/dist/client.d.ts +19996 -0
- package/dist/client.js +277 -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 +170 -0
- package/dist/flares.js +56 -0
- package/dist/fleets.d.ts +186 -0
- package/dist/fleets.js +136 -0
- package/dist/flocks.d.ts +155 -0
- package/dist/flocks.js +39 -0
- package/dist/foundry-billing.d.ts +97 -0
- package/dist/foundry-billing.js +107 -0
- package/dist/gears.d.ts +107 -0
- package/dist/gears.js +20 -0
- package/dist/generated/operations.d.ts +19949 -0
- package/dist/generated/operations.js +23846 -0
- package/dist/generated/schema.d.ts +35413 -0
- package/dist/generated/schema.js +1 -0
- package/dist/genesis.d.ts +2926 -0
- package/dist/genesis.js +206 -0
- package/dist/genesis.openapi.json +49321 -0
- package/dist/henry.d.ts +168 -0
- package/dist/henry.js +45 -0
- package/dist/hives-cells.d.ts +127 -0
- package/dist/hives-cells.js +151 -0
- package/dist/hives-environment.d.ts +28 -0
- package/dist/hives-environment.js +58 -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 +152 -0
- package/dist/hives-operations.d.ts +337 -0
- package/dist/hives-operations.js +41 -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-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/idempotency.d.ts +4 -0
- package/dist/idempotency.js +17 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +25 -0
- package/dist/instances.d.ts +25 -0
- package/dist/instances.js +11 -0
- package/dist/lanes.d.ts +267 -0
- package/dist/lanes.js +41 -0
- package/dist/minds-agent.d.ts +60 -0
- package/dist/minds-agent.js +190 -0
- package/dist/minds-owner.d.ts +110 -0
- package/dist/minds-owner.js +226 -0
- package/dist/minds.d.ts +269 -0
- package/dist/minds.js +193 -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 +68 -0
- package/dist/runner.js +116 -0
- package/dist/types.d.ts +87 -0
- package/dist/types.js +1 -0
- package/dist/urls.d.ts +6 -0
- package/dist/urls.js +31 -0
- package/package.json +46 -3
package/dist/runner.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { RUNNER_SELF_GRANT_OPERATION } from './runner-grant.js';
|
|
2
|
+
const requestOptions = (options) => ({ signal: options.signal });
|
|
3
|
+
const opaqueId = (v) => typeof v === 'string' && /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(v);
|
|
4
|
+
const pathLike = (v) => /^[A-Za-z]:/.test(v) || v.includes('..');
|
|
5
|
+
const invalid = () => new TypeError('Runner input must match the bounded runner/task-client/v0 contract');
|
|
6
|
+
function checkedJobId(value) {
|
|
7
|
+
if (!opaqueId(value) || pathLike(value)
|
|
8
|
+
|| /^(?:https?|ftp|file|data|javascript|bearer|basic):|^(?:sk[-_]|pk[-_]|gh[pousr]_|github_pat_|xox[baprs]-|eyJ)/i.test(value)) {
|
|
9
|
+
throw invalid();
|
|
10
|
+
}
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
function closed(value, required, optional = []) {
|
|
14
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
15
|
+
&& required.every((key) => Object.hasOwn(value, key))
|
|
16
|
+
&& Object.keys(value).every((key) => required.includes(key) || optional.includes(key));
|
|
17
|
+
}
|
|
18
|
+
// Match the core's input bounds and copy once so a caller cannot mutate a validated request
|
|
19
|
+
// while the asynchronous credential provider runs. Identity is never an input property.
|
|
20
|
+
function copyBoundedInput(value) {
|
|
21
|
+
let nodes = 0;
|
|
22
|
+
let chars = 0;
|
|
23
|
+
const ancestors = new Set();
|
|
24
|
+
const countText = (text) => {
|
|
25
|
+
chars += text.length;
|
|
26
|
+
if (text.length > 32768 || chars > 65536)
|
|
27
|
+
throw invalid();
|
|
28
|
+
return text;
|
|
29
|
+
};
|
|
30
|
+
const walk = (v, depth) => {
|
|
31
|
+
if (++nodes > 256)
|
|
32
|
+
throw invalid();
|
|
33
|
+
if (v === null || typeof v === 'boolean')
|
|
34
|
+
return v;
|
|
35
|
+
if (typeof v === 'string')
|
|
36
|
+
return countText(v);
|
|
37
|
+
if (typeof v === 'number' && Number.isFinite(v))
|
|
38
|
+
return v;
|
|
39
|
+
if (typeof v !== 'object' || depth >= 6 || ancestors.has(v))
|
|
40
|
+
throw invalid();
|
|
41
|
+
ancestors.add(v);
|
|
42
|
+
try {
|
|
43
|
+
if (Array.isArray(v)) {
|
|
44
|
+
if (Object.getPrototypeOf(v) !== Array.prototype || v.length > 64 || Reflect.ownKeys(v).length !== v.length + 1)
|
|
45
|
+
throw invalid();
|
|
46
|
+
return Array.from({ length: v.length }, (_, index) => {
|
|
47
|
+
const d = Object.getOwnPropertyDescriptor(v, String(index));
|
|
48
|
+
if (!d || !('value' in d) || !d.enumerable)
|
|
49
|
+
throw invalid();
|
|
50
|
+
return walk(d.value, depth + 1);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const prototype = Object.getPrototypeOf(v);
|
|
54
|
+
if (prototype !== null && prototype !== Object.prototype)
|
|
55
|
+
throw invalid();
|
|
56
|
+
const keys = Reflect.ownKeys(v);
|
|
57
|
+
if (keys.length > 32)
|
|
58
|
+
throw invalid();
|
|
59
|
+
const out = Object.create(null);
|
|
60
|
+
for (const key of keys) {
|
|
61
|
+
if (typeof key !== 'string')
|
|
62
|
+
throw invalid();
|
|
63
|
+
countText(key);
|
|
64
|
+
const d = Object.getOwnPropertyDescriptor(v, key);
|
|
65
|
+
if (!('value' in d) || !d.enumerable)
|
|
66
|
+
throw invalid();
|
|
67
|
+
out[key] = walk(d.value, depth + 1);
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
ancestors.delete(v);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
return walk(value, 0);
|
|
76
|
+
}
|
|
77
|
+
function checkedStartInput(input) {
|
|
78
|
+
const v = copyBoundedInput(input);
|
|
79
|
+
if (!closed(v, ['task', 'workspaceRef', 'executionRef', 'limits', 'idempotencyKey'])
|
|
80
|
+
|| !closed(v.task, ['id', 'text'], ['meta']) || !opaqueId(v.task.id)
|
|
81
|
+
|| typeof v.task.text !== 'string' || !v.task.text.trim()
|
|
82
|
+
|| (Object.hasOwn(v.task, 'meta') && (v.task.meta === null || typeof v.task.meta !== 'object' || Array.isArray(v.task.meta)))
|
|
83
|
+
|| !opaqueId(v.workspaceRef) || pathLike(v.workspaceRef)
|
|
84
|
+
|| !closed(v.executionRef, ['kind', 'routeId'])
|
|
85
|
+
|| !['external-harness', 'internal-model'].includes(v.executionRef.kind) || !opaqueId(v.executionRef.routeId)
|
|
86
|
+
|| !closed(v.limits, ['maxDurationMs', 'maxOutputBytes'], ['maxEvents']) || !opaqueId(v.idempotencyKey))
|
|
87
|
+
throw invalid();
|
|
88
|
+
const limit = (n, maximum) => Number.isInteger(n) && n > 0 && n <= maximum;
|
|
89
|
+
if (!limit(v.limits.maxDurationMs, 86400000) || !limit(v.limits.maxOutputBytes, 67108864)
|
|
90
|
+
|| (Object.hasOwn(v.limits, 'maxEvents') && !limit(v.limits.maxEvents, 1000)))
|
|
91
|
+
throw invalid();
|
|
92
|
+
if (new TextEncoder().encode(JSON.stringify(v)).byteLength > 65536)
|
|
93
|
+
throw invalid();
|
|
94
|
+
return v;
|
|
95
|
+
}
|
|
96
|
+
/** Runner routes use the Genesis client's credential; the backend owns org/subject scoping. */
|
|
97
|
+
export function runnerModule(client) {
|
|
98
|
+
return Object.freeze({
|
|
99
|
+
permission: Object.freeze({
|
|
100
|
+
grant: (input, opts = {}) => client.request(RUNNER_SELF_GRANT_OPERATION, { body: input }, requestOptions(opts)),
|
|
101
|
+
}),
|
|
102
|
+
catalog: (opts = {}) => client.request('runner_getCatalog', undefined, requestOptions(opts)),
|
|
103
|
+
jobs: Object.freeze({
|
|
104
|
+
list: (opts = {}) => client.request('runner_listJobs', undefined, requestOptions(opts)),
|
|
105
|
+
start: (input, opts = {}) => client.request('runner_startJob', { body: checkedStartInput(input) }, requestOptions(opts)),
|
|
106
|
+
get: (jobId, opts = {}) => client.request('runner_getJob', { jobId: checkedJobId(jobId) }, requestOptions(opts)),
|
|
107
|
+
events: (jobId, afterSeq = 0, opts = {}) => {
|
|
108
|
+
if (!Number.isSafeInteger(afterSeq) || afterSeq < 0)
|
|
109
|
+
throw invalid();
|
|
110
|
+
return client.request('runner_getJobEvents', { jobId: checkedJobId(jobId), afterSeq }, requestOptions(opts));
|
|
111
|
+
},
|
|
112
|
+
result: (jobId, opts = {}) => client.request('runner_getJobResult', { jobId: checkedJobId(jobId) }, requestOptions(opts)),
|
|
113
|
+
cancel: (jobId, opts = {}) => client.request('runner_cancelJob', { jobId: checkedJobId(jobId) }, requestOptions(opts)),
|
|
114
|
+
}),
|
|
115
|
+
});
|
|
116
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { operations } from './generated/schema.js';
|
|
2
|
+
export interface ServiceMeta {
|
|
3
|
+
name: string;
|
|
4
|
+
title: string;
|
|
5
|
+
upstream: string;
|
|
6
|
+
operations: number;
|
|
7
|
+
/** @deprecated No longer shipped; always undefined. Read live state from `GET /v1/status` (`genesis status`). */
|
|
8
|
+
status?: string;
|
|
9
|
+
/** @deprecated No longer shipped; always undefined. */
|
|
10
|
+
statusNote?: string;
|
|
11
|
+
/** `dedicated`: the gateway admits this service only through its own composition, never a default registry route. */
|
|
12
|
+
gatewayRoute?: 'dedicated';
|
|
13
|
+
}
|
|
14
|
+
export interface OperationMeta {
|
|
15
|
+
method: string;
|
|
16
|
+
path: string;
|
|
17
|
+
service: string;
|
|
18
|
+
summary: string;
|
|
19
|
+
upstream: {
|
|
20
|
+
base: string;
|
|
21
|
+
method: string;
|
|
22
|
+
path: string;
|
|
23
|
+
/** @deprecated No longer shipped; always undefined. Read live state from `GET /v1/status`. */
|
|
24
|
+
status?: string;
|
|
25
|
+
};
|
|
26
|
+
mcp: boolean;
|
|
27
|
+
internal: boolean;
|
|
28
|
+
public: boolean;
|
|
29
|
+
pathParams: readonly string[];
|
|
30
|
+
queryParams: readonly string[];
|
|
31
|
+
hasBody: boolean;
|
|
32
|
+
requestContentType?: string;
|
|
33
|
+
rawResponse?: boolean;
|
|
34
|
+
/** The operation reads an Idempotency-Key header: `required` refuses without one. */
|
|
35
|
+
idempotencyKey?: 'required' | 'optional';
|
|
36
|
+
inputSchema: Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
type Ops = operations;
|
|
39
|
+
type Clean<T> = [T] extends [never] ? {} : [NonNullable<T>] extends [never] ? {} : NonNullable<T>;
|
|
40
|
+
type Part<K extends keyof Ops, L extends 'path' | 'query'> = Ops[K] extends {
|
|
41
|
+
parameters: infer P;
|
|
42
|
+
} ? (P extends {
|
|
43
|
+
[X in L]?: infer T;
|
|
44
|
+
} ? Clean<T> : {}) : {};
|
|
45
|
+
type Body<K extends keyof Ops> = Ops[K] extends {
|
|
46
|
+
requestBody?: infer B;
|
|
47
|
+
} ? [NonNullable<B>] extends [never] ? {} : NonNullable<B> extends {
|
|
48
|
+
content: {
|
|
49
|
+
'application/json': infer J;
|
|
50
|
+
};
|
|
51
|
+
} ? (undefined extends B ? {
|
|
52
|
+
body?: J;
|
|
53
|
+
} : {
|
|
54
|
+
body: J;
|
|
55
|
+
}) : NonNullable<B> extends {
|
|
56
|
+
content: {
|
|
57
|
+
'multipart/form-data': unknown;
|
|
58
|
+
};
|
|
59
|
+
} ? (undefined extends B ? {
|
|
60
|
+
body?: FormData;
|
|
61
|
+
} : {
|
|
62
|
+
body: FormData;
|
|
63
|
+
}) : {} : {};
|
|
64
|
+
/** Flat input for an operation: path params + query params + `body`. */
|
|
65
|
+
export type OperationInput<K extends keyof Ops> = Part<K, 'path'> & Part<K, 'query'> & Body<K>;
|
|
66
|
+
type Ok<R> = R extends {
|
|
67
|
+
200: infer X;
|
|
68
|
+
} ? X : R extends {
|
|
69
|
+
201: infer X;
|
|
70
|
+
} ? X : R extends {
|
|
71
|
+
202: infer X;
|
|
72
|
+
} ? X : R extends {
|
|
73
|
+
204: unknown;
|
|
74
|
+
} ? {
|
|
75
|
+
content: {
|
|
76
|
+
'application/json': void;
|
|
77
|
+
};
|
|
78
|
+
} : unknown;
|
|
79
|
+
/** Parsed JSON success body for an operation. */
|
|
80
|
+
export type OperationOutput<K extends keyof Ops> = K extends 'hives_invoke_function' | 'hives_invoke_function_async' | 'hives_invoke_deployment' ? Response : Ops[K] extends {
|
|
81
|
+
responses: infer R;
|
|
82
|
+
} ? (Ok<R> extends {
|
|
83
|
+
content: {
|
|
84
|
+
'application/json': infer J;
|
|
85
|
+
};
|
|
86
|
+
} ? J : unknown) : unknown;
|
|
87
|
+
export {};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/urls.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Transport-safety checks for configured endpoints (mirrors sdk/python/src/lifesi_genesis/_urls.py). */
|
|
2
|
+
/**
|
|
3
|
+
* Return `value` if it is https, or http on a loopback host; throw otherwise.
|
|
4
|
+
* Credentials ride on every request, so a plain-http endpoint off the local machine is refused.
|
|
5
|
+
*/
|
|
6
|
+
export declare function requireSecureUrl(value: string, what: string): string;
|
package/dist/urls.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Transport-safety checks for configured endpoints (mirrors sdk/python/src/lifesi_genesis/_urls.py). */
|
|
2
|
+
function isLoopback(hostname) {
|
|
3
|
+
const host = hostname.replace(/^\[|\]$/g, '').toLowerCase();
|
|
4
|
+
// Exact names only: *.localhost is not guaranteed to resolve to loopback.
|
|
5
|
+
if (host === 'localhost')
|
|
6
|
+
return true;
|
|
7
|
+
if (host === '::1')
|
|
8
|
+
return true;
|
|
9
|
+
const v4 = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(host);
|
|
10
|
+
return !!v4 && v4.slice(1).every((o) => Number(o) <= 255) && v4[1] === '127';
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Return `value` if it is https, or http on a loopback host; throw otherwise.
|
|
14
|
+
* Credentials ride on every request, so a plain-http endpoint off the local machine is refused.
|
|
15
|
+
*/
|
|
16
|
+
export function requireSecureUrl(value, what) {
|
|
17
|
+
let url;
|
|
18
|
+
try {
|
|
19
|
+
url = new URL(value);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
throw new Error(`${what} must be an absolute https URL`);
|
|
23
|
+
}
|
|
24
|
+
if (!url.hostname)
|
|
25
|
+
throw new Error(`${what} must be an absolute https URL`);
|
|
26
|
+
if (url.protocol === 'https:')
|
|
27
|
+
return value;
|
|
28
|
+
if (url.protocol === 'http:' && isLoopback(url.hostname))
|
|
29
|
+
return value;
|
|
30
|
+
throw new Error(`${what} must use https (http is allowed only on loopback hosts)`);
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onesi/genesis",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
|
|
3
|
+
"version": "0.1.13",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/l1felabs/genesis-api.git",
|
|
7
|
+
"directory": "packages/sdk"
|
|
8
|
+
},
|
|
9
|
+
"description": "One typed SDK for every Genesis service (Foundry, Hives, Relays, IAM...) via the Genesis API gateway",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"types": "dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./spec.json": "./dist/genesis.openapi.json",
|
|
19
|
+
"./hives-node": {
|
|
20
|
+
"types": "./dist/hives-node.d.ts",
|
|
21
|
+
"default": "./dist/hives-node.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"genesis",
|
|
26
|
+
"oneos",
|
|
27
|
+
"sdk",
|
|
28
|
+
"cli",
|
|
29
|
+
"mcp",
|
|
30
|
+
"model-context-protocol",
|
|
31
|
+
"ai-agents",
|
|
32
|
+
"api"
|
|
33
|
+
],
|
|
34
|
+
"author": "One Superintelligence, Inc.",
|
|
35
|
+
"homepage": "https://os.one.ml/docs",
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=20.19"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist"
|
|
41
|
+
],
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"undici": "6.29.0"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"gen": "node scripts/gen.mjs",
|
|
47
|
+
"build": "tsc -p tsconfig.json && cp ../../openapi/genesis.openapi.json dist/"
|
|
48
|
+
}
|
|
6
49
|
}
|