@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,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
|
+
}
|
package/dist/gears.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { GenesisClient } from './client.js';
|
|
2
|
+
import type { OperationInput as In } from './types.js';
|
|
3
|
+
/** Gears durable workflows: exactly the gateway-admitted reads, register, start and signal.
|
|
4
|
+
* Writes take an optional idempotency key; with one, a retry returns the original result. */
|
|
5
|
+
export declare function gearsModule(client: GenesisClient): {
|
|
6
|
+
workflows: {
|
|
7
|
+
list: () => Promise<{
|
|
8
|
+
scope?: import("./index.js").components["schemas"]["Gears.Scope"];
|
|
9
|
+
workflowId: string;
|
|
10
|
+
workflowVersion: string;
|
|
11
|
+
name: string;
|
|
12
|
+
definitionRef: string;
|
|
13
|
+
registeredBy: string;
|
|
14
|
+
}[]>;
|
|
15
|
+
get: (id: string) => Promise<{
|
|
16
|
+
scope?: import("./index.js").components["schemas"]["Gears.Scope"];
|
|
17
|
+
workflowId: string;
|
|
18
|
+
workflowVersion: string;
|
|
19
|
+
name: string;
|
|
20
|
+
definitionRef: string;
|
|
21
|
+
registeredBy: string;
|
|
22
|
+
}>;
|
|
23
|
+
register: (body: In<"gears_registerWorkflow">["body"], idempotencyKey?: string) => Promise<{
|
|
24
|
+
scope?: import("./index.js").components["schemas"]["Gears.Scope"];
|
|
25
|
+
workflowId: string;
|
|
26
|
+
workflowVersion: string;
|
|
27
|
+
name: string;
|
|
28
|
+
definitionRef: string;
|
|
29
|
+
registeredBy: string;
|
|
30
|
+
}>;
|
|
31
|
+
};
|
|
32
|
+
runs: {
|
|
33
|
+
list: () => Promise<{
|
|
34
|
+
id: string;
|
|
35
|
+
scope?: import("./index.js").components["schemas"]["Gears.Scope"];
|
|
36
|
+
workflowId: string;
|
|
37
|
+
workflowVersion: string;
|
|
38
|
+
status: "Running" | "Succeeded" | "Failed" | "Cancelled";
|
|
39
|
+
actorId: string;
|
|
40
|
+
inputRef: string;
|
|
41
|
+
contextFrameId?: string | null;
|
|
42
|
+
stationSessionId?: string | null;
|
|
43
|
+
}[]>;
|
|
44
|
+
get: (id: string) => Promise<{
|
|
45
|
+
id: string;
|
|
46
|
+
scope?: import("./index.js").components["schemas"]["Gears.Scope"];
|
|
47
|
+
workflowId: string;
|
|
48
|
+
workflowVersion: string;
|
|
49
|
+
status: "Running" | "Succeeded" | "Failed" | "Cancelled";
|
|
50
|
+
actorId: string;
|
|
51
|
+
inputRef: string;
|
|
52
|
+
contextFrameId?: string | null;
|
|
53
|
+
stationSessionId?: string | null;
|
|
54
|
+
}>;
|
|
55
|
+
history: (id: string) => Promise<{
|
|
56
|
+
sequence: number;
|
|
57
|
+
runId: string;
|
|
58
|
+
kind: string;
|
|
59
|
+
actorId?: string;
|
|
60
|
+
detailRef?: string | null;
|
|
61
|
+
}[]>;
|
|
62
|
+
start: (body: In<"gears_startRun">["body"], idempotencyKey?: string) => Promise<{
|
|
63
|
+
id: string;
|
|
64
|
+
scope?: import("./index.js").components["schemas"]["Gears.Scope"];
|
|
65
|
+
workflowId: string;
|
|
66
|
+
workflowVersion: string;
|
|
67
|
+
status: "Running" | "Succeeded" | "Failed" | "Cancelled";
|
|
68
|
+
actorId: string;
|
|
69
|
+
inputRef: string;
|
|
70
|
+
contextFrameId?: string | null;
|
|
71
|
+
stationSessionId?: string | null;
|
|
72
|
+
}>;
|
|
73
|
+
signal: (id: string, body: In<"gears_signalRun">["body"], idempotencyKey?: string) => Promise<Record<string, never>>;
|
|
74
|
+
};
|
|
75
|
+
records: () => Promise<{
|
|
76
|
+
meterRecords?: {
|
|
77
|
+
product?: string;
|
|
78
|
+
gardenMeter?: string;
|
|
79
|
+
quantity?: number;
|
|
80
|
+
scopeKey?: string;
|
|
81
|
+
}[];
|
|
82
|
+
auditRecords?: {
|
|
83
|
+
product?: string;
|
|
84
|
+
auditAction?: string;
|
|
85
|
+
actorId?: string;
|
|
86
|
+
targetRef?: string;
|
|
87
|
+
}[];
|
|
88
|
+
evidenceRecords?: {
|
|
89
|
+
product?: string;
|
|
90
|
+
evidenceRef?: string;
|
|
91
|
+
evidenceKind?: string;
|
|
92
|
+
}[];
|
|
93
|
+
replayEvidence?: {
|
|
94
|
+
product?: string;
|
|
95
|
+
replayEngine?: string;
|
|
96
|
+
runId?: string;
|
|
97
|
+
journalSequence?: number;
|
|
98
|
+
evidenceRef?: string;
|
|
99
|
+
}[];
|
|
100
|
+
probeEvents?: {
|
|
101
|
+
product?: string;
|
|
102
|
+
eventType?: string;
|
|
103
|
+
actorId?: string;
|
|
104
|
+
targetRef?: string;
|
|
105
|
+
}[];
|
|
106
|
+
}>;
|
|
107
|
+
};
|
package/dist/gears.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { idempotencyHeaders } from './idempotency.js';
|
|
2
|
+
/** Gears durable workflows: exactly the gateway-admitted reads, register, start and signal.
|
|
3
|
+
* Writes take an optional idempotency key; with one, a retry returns the original result. */
|
|
4
|
+
export function gearsModule(client) {
|
|
5
|
+
return {
|
|
6
|
+
workflows: {
|
|
7
|
+
list: () => client.request('gears_listWorkflows'),
|
|
8
|
+
get: (id) => client.request('gears_getWorkflow', { id }),
|
|
9
|
+
register: async (body, idempotencyKey) => client.request('gears_registerWorkflow', { body }, { headers: idempotencyHeaders('gears_registerWorkflow', idempotencyKey) }),
|
|
10
|
+
},
|
|
11
|
+
runs: {
|
|
12
|
+
list: () => client.request('gears_listRuns'),
|
|
13
|
+
get: (id) => client.request('gears_getRun', { id }),
|
|
14
|
+
history: (id) => client.request('gears_getRunHistory', { id }),
|
|
15
|
+
start: async (body, idempotencyKey) => client.request('gears_startRun', { body }, { headers: idempotencyHeaders('gears_startRun', idempotencyKey) }),
|
|
16
|
+
signal: async (id, body, idempotencyKey) => client.request('gears_signalRun', { id, body }, { headers: idempotencyHeaders('gears_signalRun', idempotencyKey) }),
|
|
17
|
+
},
|
|
18
|
+
records: () => client.request('gears_listOperationalRecords'),
|
|
19
|
+
};
|
|
20
|
+
}
|