@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
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { GenesisClient } from './client.js';
|
|
2
|
+
import { type HivesResourceOptions } from './hives-resources-transport.js';
|
|
3
|
+
export interface HivesTopic {
|
|
4
|
+
id: string;
|
|
5
|
+
projectId: string;
|
|
6
|
+
name: string;
|
|
7
|
+
createdAt: string;
|
|
8
|
+
}
|
|
9
|
+
export interface HivesTopicSubscription {
|
|
10
|
+
id: string;
|
|
11
|
+
projectId: string;
|
|
12
|
+
topicId: string;
|
|
13
|
+
queueId: string;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
}
|
|
16
|
+
export interface HivesTopicPublish {
|
|
17
|
+
body?: unknown;
|
|
18
|
+
body_base64?: string;
|
|
19
|
+
attributes?: Record<string, string>;
|
|
20
|
+
}
|
|
21
|
+
export interface HivesTopicPublication {
|
|
22
|
+
publication_id: string;
|
|
23
|
+
deliveries: {
|
|
24
|
+
subscription_id: string;
|
|
25
|
+
queue_id: string;
|
|
26
|
+
message_id: string;
|
|
27
|
+
}[];
|
|
28
|
+
}
|
|
29
|
+
export declare function hivesTopics(client: GenesisClient): {
|
|
30
|
+
list(project: string, options?: HivesResourceOptions): Promise<{
|
|
31
|
+
data: HivesTopic[];
|
|
32
|
+
}>;
|
|
33
|
+
get(project: string, id: string, options?: HivesResourceOptions): Promise<HivesTopic>;
|
|
34
|
+
create(project: string, body: {
|
|
35
|
+
name: string;
|
|
36
|
+
}, options?: HivesResourceOptions): Promise<HivesTopic>;
|
|
37
|
+
remove(project: string, id: string, options?: HivesResourceOptions): Promise<{
|
|
38
|
+
deleted: true;
|
|
39
|
+
}>;
|
|
40
|
+
subscriptions: {
|
|
41
|
+
list(project: string, id: string, options?: HivesResourceOptions): Promise<{
|
|
42
|
+
data: HivesTopicSubscription[];
|
|
43
|
+
}>;
|
|
44
|
+
add(project: string, id: string, queueId: string, options?: HivesResourceOptions): Promise<HivesTopicSubscription>;
|
|
45
|
+
remove(project: string, id: string, subscriptionId: string, options?: HivesResourceOptions): Promise<{
|
|
46
|
+
deleted: true;
|
|
47
|
+
}>;
|
|
48
|
+
};
|
|
49
|
+
/** Persists one delivery per subscription atomically. Never retried after an unknown outcome. */
|
|
50
|
+
publish(project: string, id: string, body: HivesTopicPublish, options?: HivesResourceOptions): Promise<HivesTopicPublication>;
|
|
51
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { hivesQueueBody } from './hives-queues.js';
|
|
2
|
+
import { HIVES_QUEUE_BYTES, hivesResourceCall, hivesResourceId, resourceError } from './hives-resources-transport.js';
|
|
3
|
+
const invalid = () => resourceError(0);
|
|
4
|
+
const object = (v) => { if (!v || typeof v !== 'object' || Array.isArray(v))
|
|
5
|
+
throw invalid(); return v; };
|
|
6
|
+
function nativeId(value, prefix) { if (typeof value !== 'string' || !new RegExp(`^${prefix}_[a-f0-9]{32}$`).test(value))
|
|
7
|
+
throw invalid(); return value; }
|
|
8
|
+
function date(value) { if (typeof value !== 'string' || !Number.isFinite(Date.parse(value)))
|
|
9
|
+
throw invalid(); return value; }
|
|
10
|
+
function name(value) { if (typeof value !== 'string' || !/^[A-Za-z0-9_-]{1,128}$/.test(value))
|
|
11
|
+
throw invalid(); return value; }
|
|
12
|
+
function topic(value, project, id) {
|
|
13
|
+
const v = object(value);
|
|
14
|
+
if (v.projectId !== project || id !== undefined && v.id !== id)
|
|
15
|
+
throw invalid();
|
|
16
|
+
return { id: nativeId(v.id, 'top'), projectId: project, name: name(v.name), createdAt: date(v.createdAt) };
|
|
17
|
+
}
|
|
18
|
+
function subscription(value, project, topicId, queueId) {
|
|
19
|
+
const v = object(value);
|
|
20
|
+
if (v.projectId !== project || v.topicId !== topicId || queueId !== undefined && v.queueId !== queueId)
|
|
21
|
+
throw invalid();
|
|
22
|
+
return { id: nativeId(v.id, 'sub'), projectId: project, topicId, queueId: hivesResourceId(v.queueId), createdAt: date(v.createdAt) };
|
|
23
|
+
}
|
|
24
|
+
function publishInput(value) {
|
|
25
|
+
const v = object(value);
|
|
26
|
+
if (Object.keys(v).some(k => !['body', 'body_base64', 'attributes'].includes(k)) || (v.body != null) === (v.body_base64 != null))
|
|
27
|
+
throw invalid();
|
|
28
|
+
if (v.body_base64 != null)
|
|
29
|
+
hivesQueueBody(v.body_base64);
|
|
30
|
+
else {
|
|
31
|
+
let encoded;
|
|
32
|
+
try {
|
|
33
|
+
encoded = typeof v.body === 'string' ? v.body : JSON.stringify(v.body);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
throw invalid();
|
|
37
|
+
}
|
|
38
|
+
if (encoded === undefined || new TextEncoder().encode(encoded).length > HIVES_QUEUE_BYTES)
|
|
39
|
+
throw invalid();
|
|
40
|
+
}
|
|
41
|
+
if (v.attributes !== undefined) {
|
|
42
|
+
const attrs = object(v.attributes);
|
|
43
|
+
if (Object.keys(attrs).length > 61 || Object.entries(attrs).some(([k, a]) => !k || new TextEncoder().encode(k).length > 128 || k.startsWith('buzz.') || typeof a !== 'string') || new TextEncoder().encode(JSON.stringify(attrs)).length > 8192)
|
|
44
|
+
throw invalid();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function hivesTopics(client) {
|
|
48
|
+
const ids = (project, id) => ({ project_id: hivesResourceId(project), ...(id === undefined ? {} : { topic_id: hivesResourceId(id) }) });
|
|
49
|
+
const call = (operation, input, options, status = 200) => hivesResourceCall(client, operation, input, options, 'json', 2 * 1024 * 1024, 20_000, status);
|
|
50
|
+
const removed = (value) => { if (object(value).deleted !== true)
|
|
51
|
+
throw invalid(); return { deleted: true }; };
|
|
52
|
+
return {
|
|
53
|
+
async list(project, options) { const v = object(await call('hives_list_native_topic', ids(project), options)); if (!Array.isArray(v.data) || v.data.length > 16)
|
|
54
|
+
throw invalid(); const data = v.data.map(row => topic(row, project)); if (new Set(data.map(x => x.id)).size !== data.length)
|
|
55
|
+
throw invalid(); return { data }; },
|
|
56
|
+
async get(project, id, options) { return topic(await call('hives_inspect_native_topic', ids(project, id), options), project, id); },
|
|
57
|
+
async create(project, body, options) { const v = object(body); if (Object.keys(v).length !== 1)
|
|
58
|
+
throw invalid(); name(v.name); return topic(await call('hives_create_native_topic', { ...ids(project), body }, options, 201), project); },
|
|
59
|
+
async remove(project, id, options) { return removed(await call('hives_delete_native_topic', ids(project, id), options)); },
|
|
60
|
+
subscriptions: {
|
|
61
|
+
async list(project, id, options) { const v = object(await call('hives_subscriptions_native_topic', ids(project, id), options)); if (!Array.isArray(v.data) || v.data.length > 32)
|
|
62
|
+
throw invalid(); const data = v.data.map(row => subscription(row, project, id)); if (new Set(data.map(x => x.id)).size !== data.length || new Set(data.map(x => x.queueId)).size !== data.length)
|
|
63
|
+
throw invalid(); return { data }; },
|
|
64
|
+
async add(project, id, queueId, options) { const queue = hivesResourceId(queueId); return subscription(await call('hives_subscribe_native_topic', { ...ids(project, id), body: { queueId: queue } }, options, 201), project, id, queue); },
|
|
65
|
+
async remove(project, id, subscriptionId, options) { return removed(await call('hives_unsubscribe_native_topic', { ...ids(project, id), subscription_id: hivesResourceId(subscriptionId) }, options)); },
|
|
66
|
+
},
|
|
67
|
+
/** Persists one delivery per subscription atomically. Never retried after an unknown outcome. */
|
|
68
|
+
async publish(project, id, body, options) {
|
|
69
|
+
publishInput(body);
|
|
70
|
+
const v = object(await call('hives_publish_native_topic', { ...ids(project, id), body }, options, 201));
|
|
71
|
+
if (!Array.isArray(v.deliveries) || v.deliveries.length > 32)
|
|
72
|
+
throw invalid();
|
|
73
|
+
const deliveries = v.deliveries.map(raw => { const d = object(raw); return { subscription_id: nativeId(d.subscription_id, 'sub'), queue_id: hivesResourceId(d.queue_id), message_id: hivesResourceId(d.message_id) }; });
|
|
74
|
+
if (new Set(deliveries.map(x => x.subscription_id)).size !== deliveries.length || new Set(deliveries.map(x => x.queue_id)).size !== deliveries.length || new Set(deliveries.map(x => x.message_id)).size !== deliveries.length)
|
|
75
|
+
throw invalid();
|
|
76
|
+
return { publication_id: nativeId(v.publication_id, 'pub'), deliveries };
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const MAX_WASM_BYTES: number;
|
|
2
|
+
export interface HivesUploadOptions {
|
|
3
|
+
filename?: string;
|
|
4
|
+
git_sha?: string;
|
|
5
|
+
git_branch?: string;
|
|
6
|
+
git_message?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Real multipart binary; the org and digest are resolved by the authenticated backend. */
|
|
9
|
+
export declare function hivesUploadBody(file: Blob, options?: HivesUploadOptions): Promise<FormData>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const MAX_WASM_BYTES = 10 * 1024 * 1024;
|
|
2
|
+
/** Real multipart binary; the org and digest are resolved by the authenticated backend. */
|
|
3
|
+
export async function hivesUploadBody(file, options = {}) {
|
|
4
|
+
if (!(file instanceof Blob) || file.size < 4 || file.size > MAX_WASM_BYTES)
|
|
5
|
+
throw new Error('Choose a WebAssembly binary of 4 bytes to 10 MiB.');
|
|
6
|
+
const magic = new Uint8Array(await file.slice(0, 4).arrayBuffer());
|
|
7
|
+
if (magic[0] !== 0 || magic[1] !== 97 || magic[2] !== 115 || magic[3] !== 109)
|
|
8
|
+
throw new Error('The file must be a WebAssembly binary.');
|
|
9
|
+
const limits = { git_sha: 40, git_branch: 255, git_message: 1000 };
|
|
10
|
+
if (options.filename !== undefined && (typeof options.filename !== 'string' || !options.filename.length || options.filename.length > 255 || /[\r\n]/.test(options.filename)))
|
|
11
|
+
throw new Error('WASM filename must contain 1–255 characters without newlines.');
|
|
12
|
+
const form = new FormData();
|
|
13
|
+
form.append('file', file, options.filename ?? 'module.wasm');
|
|
14
|
+
for (const key of Object.keys(limits)) {
|
|
15
|
+
const value = options[key];
|
|
16
|
+
if (value === undefined)
|
|
17
|
+
continue;
|
|
18
|
+
if (typeof value !== 'string' || value.length > limits[key] || (key === 'git_sha' && value.length < 7))
|
|
19
|
+
throw new Error('Invalid deployment Git metadata.');
|
|
20
|
+
form.append(key, value);
|
|
21
|
+
}
|
|
22
|
+
return form;
|
|
23
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { GenesisClient } from './client.js';
|
|
2
|
+
import { type HivesResourceOptions } from './hives-resources-transport.js';
|
|
3
|
+
declare const states: readonly ["creating", "available", "attaching", "attached", "detaching", "deleting", "failed"];
|
|
4
|
+
export interface HivesVolume {
|
|
5
|
+
id: string;
|
|
6
|
+
project_id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
size_gib: number;
|
|
9
|
+
backing_bytes: number;
|
|
10
|
+
capacity_bytes: number | null;
|
|
11
|
+
used_bytes: number | null;
|
|
12
|
+
storage_class: 'local';
|
|
13
|
+
access_mode: 'read_write_once';
|
|
14
|
+
state: typeof states[number];
|
|
15
|
+
operation_pending: boolean;
|
|
16
|
+
generation: number;
|
|
17
|
+
mount_path: string | null;
|
|
18
|
+
attached_to: string | null;
|
|
19
|
+
read_only: boolean | null;
|
|
20
|
+
created_at: string;
|
|
21
|
+
updated_at: string;
|
|
22
|
+
}
|
|
23
|
+
export type HivesVolumeCreate = {
|
|
24
|
+
name: string;
|
|
25
|
+
storage_class?: 'local';
|
|
26
|
+
access_mode?: 'read_write_once';
|
|
27
|
+
} & ({
|
|
28
|
+
size_mib: number;
|
|
29
|
+
size_gib?: never;
|
|
30
|
+
} | {
|
|
31
|
+
size_gib: 1;
|
|
32
|
+
size_mib?: never;
|
|
33
|
+
});
|
|
34
|
+
export interface HivesVolumeMount {
|
|
35
|
+
target_id: string;
|
|
36
|
+
mount_path: string;
|
|
37
|
+
read_only: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface HivesVolumePage {
|
|
40
|
+
volumes: HivesVolume[];
|
|
41
|
+
pagination: {
|
|
42
|
+
page: number;
|
|
43
|
+
per_page: number;
|
|
44
|
+
total: number;
|
|
45
|
+
total_pages: number;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** Persisted project storage. A failed acknowledgement never triggers an automatic write retry. */
|
|
49
|
+
export declare function hivesVolumes(client: GenesisClient): {
|
|
50
|
+
list(project: string, query?: {
|
|
51
|
+
page?: number;
|
|
52
|
+
per_page?: number;
|
|
53
|
+
}, options?: HivesResourceOptions): Promise<HivesVolumePage>;
|
|
54
|
+
get(project: string, id: string, options?: HivesResourceOptions): Promise<HivesVolume>;
|
|
55
|
+
create(project: string, input: HivesVolumeCreate, options?: HivesResourceOptions): Promise<HivesVolume>;
|
|
56
|
+
mount(project: string, id: string, input: HivesVolumeMount, options?: HivesResourceOptions): Promise<HivesVolume>;
|
|
57
|
+
unmount(project: string, id: string, options?: HivesResourceOptions): Promise<HivesVolume>;
|
|
58
|
+
remove(project: string, id: string, options?: HivesResourceOptions): Promise<{
|
|
59
|
+
success: true;
|
|
60
|
+
id: string;
|
|
61
|
+
message: string;
|
|
62
|
+
}>;
|
|
63
|
+
};
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { hivesResourceCall, hivesResourceId, resourceError } from './hives-resources-transport.js';
|
|
2
|
+
const MIB = 1024 * 1024;
|
|
3
|
+
const states = ['creating', 'available', 'attaching', 'attached', 'detaching', 'deleting', 'failed'];
|
|
4
|
+
function object(value) {
|
|
5
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
6
|
+
throw resourceError(0);
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
function text(value, max = 128) {
|
|
10
|
+
if (typeof value !== 'string' || !value || value.length > max || /[\u0000-\u001f\u007f]/.test(value))
|
|
11
|
+
throw resourceError(0);
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
function count(value) {
|
|
15
|
+
if (!Number.isSafeInteger(value) || value < 0)
|
|
16
|
+
throw resourceError(0);
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
function date(value) { const result = text(value, 64); if (!Number.isFinite(Date.parse(result)))
|
|
20
|
+
throw resourceError(0); return result; }
|
|
21
|
+
function volume(value, project, expectedId) {
|
|
22
|
+
const row = object(value);
|
|
23
|
+
if (row.project_id !== project || row.storage_class !== 'local' || row.access_mode !== 'read_write_once'
|
|
24
|
+
|| !states.includes(row.state) || typeof row.operation_pending !== 'boolean')
|
|
25
|
+
throw resourceError(0);
|
|
26
|
+
const id = hivesResourceId(text(row.id));
|
|
27
|
+
if (expectedId && id !== expectedId)
|
|
28
|
+
throw resourceError(0);
|
|
29
|
+
const backing = count(row.backing_bytes);
|
|
30
|
+
const capacity = row.capacity_bytes === null ? null : count(row.capacity_bytes);
|
|
31
|
+
const used = row.used_bytes === null ? null : count(row.used_bytes);
|
|
32
|
+
if (backing < 32 * MIB || backing > 1024 * MIB || row.size_gib !== backing / (1024 * MIB)
|
|
33
|
+
|| capacity !== null && capacity > backing || used !== null && (capacity === null || used > capacity))
|
|
34
|
+
throw resourceError(0);
|
|
35
|
+
const path = row.mount_path === null ? null : text(row.mount_path, 512);
|
|
36
|
+
const attached = row.attached_to === null ? null : hivesResourceId(text(row.attached_to));
|
|
37
|
+
if ((path === null) !== (attached === null) || (attached === null ? row.read_only !== null : typeof row.read_only !== 'boolean'))
|
|
38
|
+
throw resourceError(0);
|
|
39
|
+
const generation = count(row.generation);
|
|
40
|
+
if (generation < 1)
|
|
41
|
+
throw resourceError(0);
|
|
42
|
+
return { id, project_id: project, name: text(row.name, 64), size_gib: backing / (1024 * MIB), backing_bytes: backing,
|
|
43
|
+
capacity_bytes: capacity, used_bytes: used, storage_class: 'local', access_mode: 'read_write_once',
|
|
44
|
+
state: row.state, operation_pending: row.operation_pending, generation,
|
|
45
|
+
mount_path: path, attached_to: attached, read_only: row.read_only,
|
|
46
|
+
created_at: date(row.created_at), updated_at: date(row.updated_at) };
|
|
47
|
+
}
|
|
48
|
+
/** Persisted project storage. A failed acknowledgement never triggers an automatic write retry. */
|
|
49
|
+
export function hivesVolumes(client) {
|
|
50
|
+
const ids = (project, id) => ({ project_id: hivesResourceId(project), ...(id === undefined ? {} : { volume_id: hivesResourceId(id) }) });
|
|
51
|
+
const call = (id, input, options) => hivesResourceCall(client, id, input, options);
|
|
52
|
+
return {
|
|
53
|
+
async list(project, query = {}, options) {
|
|
54
|
+
const page = query.page ?? 1;
|
|
55
|
+
const perPage = query.per_page ?? 25;
|
|
56
|
+
if (Object.keys(query).some(key => !['page', 'per_page'].includes(key)) || !Number.isSafeInteger(page) || page < 1 || page > 10000
|
|
57
|
+
|| !Number.isSafeInteger(perPage) || perPage < 1 || perPage > 100)
|
|
58
|
+
throw resourceError(0);
|
|
59
|
+
const result = object(await call('hives_list_volumes', { ...ids(project), page, per_page: perPage }, options));
|
|
60
|
+
const pagination = object(result.pagination);
|
|
61
|
+
const total = count(pagination.total);
|
|
62
|
+
const pages = count(pagination.total_pages);
|
|
63
|
+
if (pagination.page !== page || pagination.per_page !== perPage || pages !== Math.ceil(total / perPage)
|
|
64
|
+
|| !Array.isArray(result.volumes) || result.volumes.length > perPage)
|
|
65
|
+
throw resourceError(0);
|
|
66
|
+
const volumes = result.volumes.map(row => volume(row, project));
|
|
67
|
+
if (new Set(volumes.map(row => row.id)).size !== volumes.length)
|
|
68
|
+
throw resourceError(0);
|
|
69
|
+
return { volumes, pagination: { page, per_page: perPage, total, total_pages: pages } };
|
|
70
|
+
},
|
|
71
|
+
async get(project, id, options) { return volume(await call('hives_get_volume', ids(project, id), options), project, id); },
|
|
72
|
+
async create(project, input, options) {
|
|
73
|
+
const body = object(input);
|
|
74
|
+
const name = text(body.name, 64);
|
|
75
|
+
let size;
|
|
76
|
+
if (body.size_mib !== undefined && body.size_gib === undefined)
|
|
77
|
+
size = count(body.size_mib);
|
|
78
|
+
else if (body.size_mib === undefined && body.size_gib === 1)
|
|
79
|
+
size = 1024;
|
|
80
|
+
else
|
|
81
|
+
throw resourceError(0);
|
|
82
|
+
if (name.trim() !== name || size < 32 || size > 1024 || body.storage_class !== undefined && body.storage_class !== 'local'
|
|
83
|
+
|| body.access_mode !== undefined && body.access_mode !== 'read_write_once'
|
|
84
|
+
|| Object.keys(body).some(key => !['name', 'size_mib', 'size_gib', 'storage_class', 'access_mode'].includes(key)))
|
|
85
|
+
throw resourceError(0);
|
|
86
|
+
const result = volume(await call('hives_create_volume', { ...ids(project), body: { name, size_mib: size, storage_class: 'local', access_mode: 'read_write_once' } }, options), project);
|
|
87
|
+
if (result.name !== name || result.backing_bytes !== size * MIB)
|
|
88
|
+
throw resourceError(0);
|
|
89
|
+
return result;
|
|
90
|
+
},
|
|
91
|
+
async mount(project, id, input, options) {
|
|
92
|
+
const body = object(input);
|
|
93
|
+
const target = hivesResourceId(text(body.target_id));
|
|
94
|
+
const path = text(body.mount_path, 128);
|
|
95
|
+
if (!/^\/[A-Za-z0-9_-]+(?:\/[A-Za-z0-9_-]+)*$/.test(path) || typeof body.read_only !== 'boolean'
|
|
96
|
+
|| Object.keys(body).some(key => !['target_id', 'mount_path', 'read_only'].includes(key)))
|
|
97
|
+
throw resourceError(0);
|
|
98
|
+
const readOnly = body.read_only;
|
|
99
|
+
const result = volume(await call('hives_mount_volume', { ...ids(project, id), body: { target_id: target, mount_path: path, read_only: readOnly } }, options), project, id);
|
|
100
|
+
if (result.attached_to !== target || result.mount_path !== path || result.read_only !== readOnly)
|
|
101
|
+
throw resourceError(0);
|
|
102
|
+
return result;
|
|
103
|
+
},
|
|
104
|
+
async unmount(project, id, options) {
|
|
105
|
+
const result = volume(await call('hives_unmount_volume', ids(project, id), options), project, id);
|
|
106
|
+
if (result.state !== 'available' || result.operation_pending || result.attached_to !== null || result.mount_path !== null || result.read_only !== null)
|
|
107
|
+
throw resourceError(0);
|
|
108
|
+
return result;
|
|
109
|
+
},
|
|
110
|
+
async remove(project, id, options) {
|
|
111
|
+
const result = object(await call('hives_delete_volume', ids(project, id), options));
|
|
112
|
+
if (result.id !== id || result.success !== true)
|
|
113
|
+
throw resourceError(0);
|
|
114
|
+
return { success: true, id, message: text(result.message, 256) };
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type OperationId } from './generated/operations.js';
|
|
2
|
+
/** The Idempotency-Key header an operation's spec declares. A required key is refused locally when missing
|
|
3
|
+
* or malformed, before any request is sent; reuse the same key to replay instead of acting twice. */
|
|
4
|
+
export declare function idempotencyHeaders(operationId: OperationId, key: string | undefined): Record<string, string>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GenesisError } from './errors.js';
|
|
2
|
+
import { operationTable } from './generated/operations.js';
|
|
3
|
+
const REQUIRED = /^[\x21-\x7e]{8,128}$/;
|
|
4
|
+
const OPTIONAL = /^[\x21-\x7e]{1,256}$/;
|
|
5
|
+
/** The Idempotency-Key header an operation's spec declares. A required key is refused locally when missing
|
|
6
|
+
* or malformed, before any request is sent; reuse the same key to replay instead of acting twice. */
|
|
7
|
+
export function idempotencyHeaders(operationId, key) {
|
|
8
|
+
const need = operationTable[operationId].idempotencyKey;
|
|
9
|
+
if (key === undefined && need !== 'required')
|
|
10
|
+
return {};
|
|
11
|
+
if (!need || typeof key !== 'string' || !(need === 'required' ? REQUIRED : OPTIONAL).test(key)) {
|
|
12
|
+
throw new GenesisError({ status: 0, type: 'invalid_request', operationId,
|
|
13
|
+
message: need === 'required' ? `${operationId} needs a stable idempotency key (8-128 printable ASCII characters)`
|
|
14
|
+
: need ? `${operationId} idempotency key must be 1-256 printable ASCII characters` : `${operationId} does not take an idempotency key` });
|
|
15
|
+
}
|
|
16
|
+
return { 'idempotency-key': key };
|
|
17
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export { Genesis, type ChatMessage } from './genesis.js';
|
|
2
|
+
export { GenesisClient, DEFAULT_BASE_URL, type GenesisOptions, type CredentialProvider } from './client.js';
|
|
3
|
+
export { GenesisError, errorCatalog, errorToken, errorOutcome } from './errors.js';
|
|
4
|
+
export { requireSecureUrl } from './urls.js';
|
|
5
|
+
export { operationTable, services, type OperationId } from './generated/operations.js';
|
|
6
|
+
export type { OperationInput, OperationOutput, OperationMeta, ServiceMeta } from './types.js';
|
|
7
|
+
export type { paths, operations, components } from './generated/schema.js';
|
|
8
|
+
export { hivesUploadBody, MAX_WASM_BYTES, type HivesUploadOptions } from './hives-upload.js';
|
|
9
|
+
export { validateHivesInvocation, hivesFunctionResponseHeaders, HivesOperationError, MAX_FUNCTION_BODY_BYTES, MAX_FUNCTION_JSON_BYTES, type HivesInvokeRequest, type HivesInvokeOptions, type HivesOperationStatus } from './hives-functions.js';
|
|
10
|
+
export { hivesResponseBytes } from './hives-response.js';
|
|
11
|
+
export { runnerModule, type RunnerStartInput, type RunnerSnapshot, type RunnerCatalog, type RunnerEvent, type RunnerProviderResult, type RunnerRequestOptions } from './runner.js';
|
|
12
|
+
export type { RunnerSelfExecutionGrantInput, RunnerSelfExecutionGrant } from './runner-grant.js';
|
|
13
|
+
export { beaconsModule } from './beacons.js';
|
|
14
|
+
export { rigsModule, panesModule, shellsModule } from './instances.js';
|
|
15
|
+
export { gearsModule } from './gears.js';
|
|
16
|
+
export { lanesModule } from './lanes.js';
|
|
17
|
+
export { flaresModule } from './flares.js';
|
|
18
|
+
export { idempotencyHeaders } from './idempotency.js';
|
|
19
|
+
export { dialsModule, dialsEmergencyAddressFeedback, type DialsEmergencyAddressFeedback, type DialsScope, type DialsOutboundCall, type DialsCallControl, type DialsEmergencyAddress, type DialsCallListItem, type DialsCallDispatchState, type DialsMessage, type DialsMessageTemplate, type DialsMessagingBrand, type DialsMessagingCampaign, type DialsWorkflowDocument, type DialsRoutingAction, type DialsRoutingRule, type DialsRoutingRuleReceipt, type DialsOutboundCallReceipt, type DialsRecoveredOutboundCallReceipt } from './dials.js';
|
|
20
|
+
export { hivesObjectKey, type HivesBucket, type HivesObject, type HivesObjectAcknowledgement, type HivesObjectList, type HivesCorsRule, type HivesCreateBucket, type HivesPresign, type HivesPresignedUrl } from './hives-cells.js';
|
|
21
|
+
export { hivesQueueBody, type HivesQueue, type HivesQueueConfig, type HivesQueueCreate, type HivesQueueSend, type HivesQueueDelivery, type HivesDeadLetter, type HivesDeadLetterStats } from './hives-queues.js';
|
|
22
|
+
export type { HivesRuntime, HivesRuntimeSelection } from './hives-runtimes.js';
|
|
23
|
+
export type { HivesVolume, HivesVolumeCreate, HivesVolumeMount, HivesVolumePage } from './hives-volumes.js';
|
|
24
|
+
export { HIVES_OBJECT_BYTES, HIVES_QUEUE_BYTES, type HivesResourceOptions } from './hives-resources-transport.js';
|
|
25
|
+
export type { HivesMarketplacePackage, HivesMarketplaceVersion, HivesMarketplaceInstallation, HivesMarketplaceCategory, HivesMarketplacePage, HivesMarketplacePublish, HivesMarketplaceInstall, HivesMarketplaceSearch, HivesMarketplaceDetail } from './hives-marketplace.js';
|
|
26
|
+
export type { HivesQueueConsumerConfig, HivesQueueConsumerBinding, HivesQueueConsumerAttempt, HivesQueueConsumerStatus } from './hives-queue-consumer.js';
|
|
27
|
+
export { foundryBillingOperations, isFoundryBillingOperation } from './foundry-billing.js';
|
|
28
|
+
export type { HivesTopic, HivesTopicSubscription, HivesTopicPublish, HivesTopicPublication } from './hives-topics.js';
|
|
29
|
+
export { mindsModule, mindsOperations, isMindsOperation, type MindsCreateOptions, type MindsResumeOptions, type MindsStopOptions, type MindsWakeReason, type MindsRequestOptions, type MindsUsage, type MindsEventInput } from './minds.js';
|
|
30
|
+
export { MindsAgentError, mindsAgentOperations, isMindsAgentOperation, type MindsAgentOptions, type MindsAgentEventInput } from './minds-agent.js';
|
|
31
|
+
export { MindsOwnerError, mindsOwnerOperations, isMindsOwnerOperation, type MindsOwnerOptions, type MindsOwnerVersion, type MindsAttachmentSubject, type MindsAttachInput } from './minds-owner.js';
|
|
32
|
+
export { selectGenesisContext, checkedGenesisContextSession, type GenesisContextSelection, type GenesisContextSession } from './context.js';
|
|
33
|
+
export { HivesQueueOperationError, hivesQueueOperationId, type HivesQueueOperation, type HivesQueueSendOptions } from './hives-queue-funding.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export { Genesis } from './genesis.js';
|
|
2
|
+
export { GenesisClient, DEFAULT_BASE_URL } from './client.js';
|
|
3
|
+
export { GenesisError, errorCatalog, errorToken, errorOutcome } from './errors.js';
|
|
4
|
+
export { requireSecureUrl } from './urls.js';
|
|
5
|
+
export { operationTable, services } from './generated/operations.js';
|
|
6
|
+
export { hivesUploadBody, MAX_WASM_BYTES } from './hives-upload.js';
|
|
7
|
+
export { validateHivesInvocation, hivesFunctionResponseHeaders, HivesOperationError, MAX_FUNCTION_BODY_BYTES, MAX_FUNCTION_JSON_BYTES } from './hives-functions.js';
|
|
8
|
+
export { hivesResponseBytes } from './hives-response.js';
|
|
9
|
+
export { runnerModule } from './runner.js';
|
|
10
|
+
export { beaconsModule } from './beacons.js';
|
|
11
|
+
export { rigsModule, panesModule, shellsModule } from './instances.js';
|
|
12
|
+
export { gearsModule } from './gears.js';
|
|
13
|
+
export { lanesModule } from './lanes.js';
|
|
14
|
+
export { flaresModule } from './flares.js';
|
|
15
|
+
export { idempotencyHeaders } from './idempotency.js';
|
|
16
|
+
export { dialsModule, dialsEmergencyAddressFeedback } from './dials.js';
|
|
17
|
+
export { hivesObjectKey } from './hives-cells.js';
|
|
18
|
+
export { hivesQueueBody } from './hives-queues.js';
|
|
19
|
+
export { HIVES_OBJECT_BYTES, HIVES_QUEUE_BYTES } from './hives-resources-transport.js';
|
|
20
|
+
export { foundryBillingOperations, isFoundryBillingOperation } from './foundry-billing.js';
|
|
21
|
+
export { mindsModule, mindsOperations, isMindsOperation } from './minds.js';
|
|
22
|
+
export { MindsAgentError, mindsAgentOperations, isMindsAgentOperation } from './minds-agent.js';
|
|
23
|
+
export { MindsOwnerError, mindsOwnerOperations, isMindsOwnerOperation } from './minds-owner.js';
|
|
24
|
+
export { selectGenesisContext, checkedGenesisContextSession } from './context.js';
|
|
25
|
+
export { HivesQueueOperationError, hivesQueueOperationId } from './hives-queue-funding.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { GenesisClient } from './client.js';
|
|
2
|
+
/** Read-only instance inventories. Each needs an interactive One account login with a selected
|
|
3
|
+
* organization and project; the gateway admits nothing else on these products. */
|
|
4
|
+
export declare function rigsModule(client: GenesisClient): {
|
|
5
|
+
list: () => Promise<{
|
|
6
|
+
product: "rigs";
|
|
7
|
+
instances: import("./index.js").components["schemas"]["Rigs.Instance"][];
|
|
8
|
+
}>;
|
|
9
|
+
};
|
|
10
|
+
export declare function panesModule(client: GenesisClient): {
|
|
11
|
+
list: () => Promise<{
|
|
12
|
+
product: "panes";
|
|
13
|
+
instances: import("./index.js").components["schemas"]["Panes.Instance"][];
|
|
14
|
+
} & {
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}>;
|
|
17
|
+
};
|
|
18
|
+
export declare function shellsModule(client: GenesisClient): {
|
|
19
|
+
list: () => Promise<{
|
|
20
|
+
product: "shells";
|
|
21
|
+
instances: import("./index.js").components["schemas"]["Shells.Instance"][];
|
|
22
|
+
} & {
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}>;
|
|
25
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Read-only instance inventories. Each needs an interactive One account login with a selected
|
|
2
|
+
* organization and project; the gateway admits nothing else on these products. */
|
|
3
|
+
export function rigsModule(client) {
|
|
4
|
+
return { list: () => client.request('rigs_listRigs') };
|
|
5
|
+
}
|
|
6
|
+
export function panesModule(client) {
|
|
7
|
+
return { list: () => client.request('panes_listPanes') };
|
|
8
|
+
}
|
|
9
|
+
export function shellsModule(client) {
|
|
10
|
+
return { list: () => client.request('shells_listShells') };
|
|
11
|
+
}
|