@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.
Files changed (113) hide show
  1. package/README.md +29 -0
  2. package/dist/auto.d.ts +1010 -0
  3. package/dist/auto.js +125 -0
  4. package/dist/beacons.d.ts +145 -0
  5. package/dist/beacons.js +148 -0
  6. package/dist/blinds-owner-enrollment.d.ts +280 -0
  7. package/dist/blinds-owner-enrollment.js +169 -0
  8. package/dist/client.d.ts +52 -0
  9. package/dist/client.js +384 -0
  10. package/dist/context.d.ts +50 -0
  11. package/dist/context.js +153 -0
  12. package/dist/dials.d.ts +299 -0
  13. package/dist/dials.js +100 -0
  14. package/dist/errors.d.ts +35 -0
  15. package/dist/errors.js +66 -0
  16. package/dist/flares.d.ts +202 -0
  17. package/dist/flares.js +61 -0
  18. package/dist/fleets.d.ts +218 -0
  19. package/dist/fleets.js +189 -0
  20. package/dist/flocks.d.ts +439 -0
  21. package/dist/flocks.js +98 -0
  22. package/dist/foundry-billing.d.ts +97 -0
  23. package/dist/foundry-billing.js +107 -0
  24. package/dist/foundry.d.ts +424 -0
  25. package/dist/foundry.js +133 -0
  26. package/dist/garden.d.ts +754 -0
  27. package/dist/garden.js +76 -0
  28. package/dist/gateway.d.ts +365 -0
  29. package/dist/gateway.js +82 -0
  30. package/dist/gears.d.ts +226 -0
  31. package/dist/gears.js +42 -0
  32. package/dist/generated/operations.d.ts +4 -0
  33. package/dist/generated/operations.js +65134 -0
  34. package/dist/generated/schema.d.ts +87658 -0
  35. package/dist/generated/schema.js +1 -0
  36. package/dist/genesis.d.ts +9574 -0
  37. package/dist/genesis.js +271 -0
  38. package/dist/genesis.openapi.json +128522 -0
  39. package/dist/henry.d.ts +369 -0
  40. package/dist/henry.js +268 -0
  41. package/dist/hives-cells.d.ts +127 -0
  42. package/dist/hives-cells.js +151 -0
  43. package/dist/hives-environment.d.ts +37 -0
  44. package/dist/hives-environment.js +80 -0
  45. package/dist/hives-functions.d.ts +36 -0
  46. package/dist/hives-functions.js +185 -0
  47. package/dist/hives-marketplace.d.ts +128 -0
  48. package/dist/hives-marketplace.js +187 -0
  49. package/dist/hives-node.d.ts +9 -0
  50. package/dist/hives-node.js +155 -0
  51. package/dist/hives-operations.d.ts +451 -0
  52. package/dist/hives-operations.js +43 -0
  53. package/dist/hives-platform.d.ts +149 -0
  54. package/dist/hives-platform.js +183 -0
  55. package/dist/hives-queue-consumer.d.ts +56 -0
  56. package/dist/hives-queue-consumer.js +95 -0
  57. package/dist/hives-queue-funding.d.ts +28 -0
  58. package/dist/hives-queue-funding.js +81 -0
  59. package/dist/hives-queues.d.ts +137 -0
  60. package/dist/hives-queues.js +143 -0
  61. package/dist/hives-resources-transport.d.ts +23 -0
  62. package/dist/hives-resources-transport.js +204 -0
  63. package/dist/hives-response.d.ts +2 -0
  64. package/dist/hives-response.js +32 -0
  65. package/dist/hives-runtimes.d.ts +34 -0
  66. package/dist/hives-runtimes.js +32 -0
  67. package/dist/hives-sse.d.ts +24 -0
  68. package/dist/hives-sse.js +111 -0
  69. package/dist/hives-topics.d.ts +51 -0
  70. package/dist/hives-topics.js +79 -0
  71. package/dist/hives-upload.d.ts +9 -0
  72. package/dist/hives-upload.js +23 -0
  73. package/dist/hives-volumes.d.ts +64 -0
  74. package/dist/hives-volumes.js +117 -0
  75. package/dist/iam-directory.d.ts +8 -0
  76. package/dist/iam-directory.js +23 -0
  77. package/dist/iam.d.ts +391 -0
  78. package/dist/iam.js +92 -0
  79. package/dist/idempotency.d.ts +7 -0
  80. package/dist/idempotency.js +39 -0
  81. package/dist/index.d.ts +47 -0
  82. package/dist/index.js +37 -0
  83. package/dist/instances.d.ts +200 -0
  84. package/dist/instances.js +43 -0
  85. package/dist/lanes.d.ts +267 -0
  86. package/dist/lanes.js +41 -0
  87. package/dist/minds-agent.d.ts +88 -0
  88. package/dist/minds-agent.js +233 -0
  89. package/dist/minds-engine.d.ts +394 -0
  90. package/dist/minds-engine.js +555 -0
  91. package/dist/minds-owner.d.ts +110 -0
  92. package/dist/minds-owner.js +226 -0
  93. package/dist/minds.d.ts +377 -0
  94. package/dist/minds.js +228 -0
  95. package/dist/orgs.d.ts +405 -0
  96. package/dist/orgs.js +63 -0
  97. package/dist/relays-enrollment.d.ts +33 -0
  98. package/dist/relays-enrollment.js +115 -0
  99. package/dist/runner-grant.d.ts +10 -0
  100. package/dist/runner-grant.js +133 -0
  101. package/dist/runner.d.ts +72 -0
  102. package/dist/runner.js +117 -0
  103. package/dist/scopes.d.ts +310 -0
  104. package/dist/scopes.js +40 -0
  105. package/dist/taps.d.ts +118 -0
  106. package/dist/taps.js +45 -0
  107. package/dist/traces.d.ts +574 -0
  108. package/dist/traces.js +97 -0
  109. package/dist/types.d.ts +98 -0
  110. package/dist/types.js +1 -0
  111. package/dist/urls.d.ts +6 -0
  112. package/dist/urls.js +31 -0
  113. package/package.json +49 -1
@@ -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,8 @@
1
+ export declare const iamDirectoryOperations: readonly string[];
2
+ export declare const isIamDirectoryOperation: (operationId: string) => boolean;
3
+ /**
4
+ * The actionable form of a directory refusal; any other error is returned unchanged. The gateway, not the client, exchanges
5
+ * the One account session for an organization context at Auth and forwards the short-lived child to IAM. The client sends
6
+ * one request, never changes a session or its selected context, and only explains what came back.
7
+ */
8
+ export declare function iamDirectoryFailure(e: unknown, org: string, operationId: string): unknown;
@@ -0,0 +1,23 @@
1
+ import { GenesisError, errorCatalog } from './errors.js';
2
+ /** The IAM v4 organization directory: projects and workspaces at /v1/iam/orgs/{org_id}/... */
3
+ const READS = ['iam_listProjects', 'iam_getProject', 'iam_listWorkspaces', 'iam_getWorkspace'];
4
+ const WRITES = ['iam_createProject', 'iam_updateProject', 'iam_deleteProject', 'iam_createWorkspace', 'iam_updateWorkspace', 'iam_deleteWorkspace'];
5
+ export const iamDirectoryOperations = [...READS, ...WRITES];
6
+ export const isIamDirectoryOperation = (operationId) => iamDirectoryOperations.includes(operationId);
7
+ const codeOf = (e) => errorCatalog(e).code?.toUpperCase();
8
+ /**
9
+ * The actionable form of a directory refusal; any other error is returned unchanged. The gateway, not the client, exchanges
10
+ * the One account session for an organization context at Auth and forwards the short-lived child to IAM. The client sends
11
+ * one request, never changes a session or its selected context, and only explains what came back.
12
+ */
13
+ export function iamDirectoryFailure(e, org, operationId) {
14
+ if (!(e instanceof GenesisError))
15
+ return e;
16
+ const keep = (message) => new GenesisError({ status: e.status, type: e.type, code: e.code, requestId: e.requestId, operationId, body: e.body, message });
17
+ const code = codeOf(e);
18
+ if (code === 'TENANT_REQUIRED')
19
+ return keep(`IAM sees no organization on your One account session for ${org}. Use the Console to manage projects and workspaces for now.`);
20
+ if (WRITES.includes(operationId) && code === 'SCOPE_MISSING' && errorCatalog(e).required_scope === 'iam:write')
21
+ return keep(`This credential cannot change projects and workspaces in ${org}: a login needs the organization owner or manager role in IAM, and an API key needs iam:write. Use the Console.`);
22
+ return e;
23
+ }