@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,110 @@
1
+ import type { GenesisClient } from './client.js';
2
+ import { GenesisError } from './errors.js';
3
+ export declare const mindsOwnerOperations: readonly ["minds_listAgentGroups", "minds_createAgentGroup", "minds_listAgentGroupMembers", "minds_addAgentGroupMember", "minds_removeAgentGroupMember", "minds_listMindAttachments", "minds_attachMind", "minds_detachMind"];
4
+ type OwnerOperation = typeof mindsOwnerOperations[number];
5
+ export declare const isMindsOwnerOperation: (id: string) => id is OwnerOperation;
6
+ export interface MindsOwnerOptions {
7
+ signal?: AbortSignal;
8
+ }
9
+ export interface MindsOwnerVersion {
10
+ operationId: string;
11
+ expectedVersion: number;
12
+ }
13
+ export type MindsAttachmentSubject = {
14
+ kind: 'agent';
15
+ agentId: string;
16
+ } | {
17
+ kind: 'group';
18
+ groupId: string;
19
+ };
20
+ export interface MindsAttachInput extends MindsOwnerVersion {
21
+ subject: MindsAttachmentSubject;
22
+ permissions: ['minds.agent_data.read'] | ['minds.agent_data.read', 'minds.agent_data.write'];
23
+ expiresAt: number;
24
+ }
25
+ export declare class MindsOwnerError extends GenesisError {
26
+ }
27
+ type Row = Record<string, unknown>;
28
+ /** Original-human owner operations. No context selection, token substitution or automatic retry. */
29
+ export declare function mindsOwnerTransport(options: {
30
+ operationId: string;
31
+ input: Row;
32
+ headers?: Record<string, string>;
33
+ routing: string;
34
+ url: string;
35
+ credential: () => Promise<string | undefined>;
36
+ fetch: typeof fetch;
37
+ signal?: AbortSignal;
38
+ }): Promise<Response>;
39
+ export declare function mindsOwnerModule(client: GenesisClient): {
40
+ groups: {
41
+ list: (options?: MindsOwnerOptions) => Promise<{
42
+ groups: import("./index.js").components["schemas"]["Minds.OwnerAgentGroup"][];
43
+ }>;
44
+ create: (body: {
45
+ operationId: string;
46
+ name: string;
47
+ }, options?: MindsOwnerOptions) => Promise<{
48
+ id: string;
49
+ organizationId: string;
50
+ ownerId: string;
51
+ organizationGeneration: number;
52
+ name: string;
53
+ version: number;
54
+ revokedAt: number | null;
55
+ }>;
56
+ members: {
57
+ list: (group_id: string, options?: MindsOwnerOptions) => Promise<{
58
+ members: import("./index.js").components["schemas"]["Minds.OwnerAgentGroupMember"][];
59
+ }>;
60
+ add: (group_id: string, body: MindsOwnerVersion & {
61
+ agentId: string;
62
+ }, options?: MindsOwnerOptions) => Promise<{
63
+ groupId: string;
64
+ agentId: string;
65
+ agentDid: string;
66
+ agentCreatedAt: number;
67
+ version: number;
68
+ revokedAt: number | null;
69
+ }>;
70
+ remove: (group_id: string, agent_id: string, body: MindsOwnerVersion, options?: MindsOwnerOptions) => Promise<{
71
+ groupId: string;
72
+ agentId: string;
73
+ agentDid: string;
74
+ agentCreatedAt: number;
75
+ version: number;
76
+ revokedAt: number | null;
77
+ }>;
78
+ };
79
+ };
80
+ attachments: {
81
+ list: (mind_id: string, options?: MindsOwnerOptions) => Promise<{
82
+ attachments: import("./index.js").components["schemas"]["Minds.MindAttachment"][];
83
+ }>;
84
+ attach: (mind_id: string, body: MindsAttachInput, options?: MindsOwnerOptions) => Promise<{
85
+ id: string;
86
+ version: number;
87
+ organizationId: string;
88
+ projectId: string;
89
+ mindId: string;
90
+ subject: import("./index.js").components["schemas"]["Minds.MindAttachmentSubject"];
91
+ permissions: ["minds.agent_data.read"] | ["minds.agent_data.read", "minds.agent_data.write"];
92
+ sharedNamespace: string | null;
93
+ expiresAt: number;
94
+ revokedAt: number | null;
95
+ }>;
96
+ detach: (mind_id: string, attachment_id: string, body: MindsOwnerVersion, options?: MindsOwnerOptions) => Promise<{
97
+ id: string;
98
+ version: number;
99
+ organizationId: string;
100
+ projectId: string;
101
+ mindId: string;
102
+ subject: import("./index.js").components["schemas"]["Minds.MindAttachmentSubject"];
103
+ permissions: ["minds.agent_data.read"] | ["minds.agent_data.read", "minds.agent_data.write"];
104
+ sharedNamespace: string | null;
105
+ expiresAt: number;
106
+ revokedAt: number | null;
107
+ }>;
108
+ };
109
+ };
110
+ export {};
@@ -0,0 +1,226 @@
1
+ import { envelopeExtrasValid, ENVELOPE_EXTRA_FIELDS, GenesisError } from './errors.js';
2
+ export const mindsOwnerOperations = ['minds_listAgentGroups', 'minds_createAgentGroup', 'minds_listAgentGroupMembers', 'minds_addAgentGroupMember',
3
+ 'minds_removeAgentGroupMember', 'minds_listMindAttachments', 'minds_attachMind', 'minds_detachMind'];
4
+ export const isMindsOwnerOperation = (id) => mindsOwnerOperations.includes(id);
5
+ export class MindsOwnerError extends GenesisError {
6
+ }
7
+ const row = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
8
+ const exact = (value, keys) => row(value)
9
+ && Object.keys(value).length === keys.length && keys.every(key => Object.hasOwn(value, key));
10
+ const canonical = (value, prefix) => typeof value === 'string' && new RegExp(`^${prefix}[0-7][0-9A-HJKMNP-TV-Z]{25}$`).test(value);
11
+ const uuid = (value) => typeof value === 'string' && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(value) && value !== '00000000-0000-0000-0000-000000000000';
12
+ const utf8 = (value) => new TextEncoder().encode(value).length;
13
+ const version = (value) => Number.isSafeInteger(value) && Number(value) >= 0 && Number(value) < Number.MAX_SAFE_INTEGER;
14
+ const positive = (value) => Number.isSafeInteger(value) && Number(value) > 0;
15
+ const tombstone = (value) => value === null || positive(value);
16
+ const name = (value) => typeof value === 'string' && !!value.trim() && utf8(value) <= 128;
17
+ const text = (value) => typeof value === 'string' && value.length > 0;
18
+ const permissions = (value) => JSON.stringify(value) === '["minds.agent_data.read"]'
19
+ || JSON.stringify(value) === '["minds.agent_data.read","minds.agent_data.write"]';
20
+ const subject = (value) => exact(value, ['kind', 'agentId']) && value.kind === 'agent' && canonical(value.agentId, 'a_')
21
+ || exact(value, ['kind', 'groupId']) && value.kind === 'group' && canonical(value.groupId, 'agp_');
22
+ const reads = new Set(['minds_listAgentGroups', 'minds_listAgentGroupMembers', 'minds_listMindAttachments']);
23
+ const removes = new Set(['minds_removeAgentGroupMember', 'minds_detachMind']);
24
+ function validBody(id, value) {
25
+ if (reads.has(id))
26
+ return value === undefined;
27
+ if (id === 'minds_createAgentGroup')
28
+ return exact(value, ['operationId', 'name']) && uuid(value.operationId) && name(value.name);
29
+ if (id === 'minds_addAgentGroupMember')
30
+ return exact(value, ['operationId', 'expectedVersion', 'agentId'])
31
+ && uuid(value.operationId) && version(value.expectedVersion) && canonical(value.agentId, 'a_');
32
+ if (removes.has(id))
33
+ return exact(value, ['operationId', 'expectedVersion']) && uuid(value.operationId) && version(value.expectedVersion);
34
+ return exact(value, ['operationId', 'expectedVersion', 'subject', 'permissions', 'expiresAt']) && uuid(value.operationId)
35
+ && version(value.expectedVersion) && subject(value.subject) && permissions(value.permissions) && Number.isSafeInteger(value.expiresAt)
36
+ && Number(value.expiresAt) > Date.now() && Number(value.expiresAt) <= Date.now() + 30 * 86400000;
37
+ }
38
+ function validResponse(id, input, value) {
39
+ const requested = row(input.body) ? input.body : undefined;
40
+ const group = (v) => exact(v, ['id', 'organizationId', 'ownerId', 'organizationGeneration', 'name', 'version', 'revokedAt'])
41
+ && canonical(v.id, 'agp_') && text(v.organizationId) && text(v.ownerId) && positive(v.organizationGeneration)
42
+ && name(v.name) && positive(v.version) && tombstone(v.revokedAt)
43
+ && (id !== 'minds_createAgentGroup' || v.name === requested?.name && v.version === 1 && v.revokedAt === null);
44
+ const member = (v) => exact(v, ['groupId', 'agentId', 'agentDid', 'agentCreatedAt', 'version', 'revokedAt'])
45
+ && v.groupId === input.group_id && canonical(v.agentId, 'a_') && (input.agent_id === undefined || v.agentId === input.agent_id)
46
+ && typeof v.agentDid === 'string' && /^did:[A-Za-z0-9:._%-]{1,512}$/.test(v.agentDid)
47
+ && positive(v.agentCreatedAt) && positive(v.version) && tombstone(v.revokedAt)
48
+ && (id !== 'minds_addAgentGroupMember' || v.agentId === requested?.agentId && v.version === Number(requested?.expectedVersion) + 1 && v.revokedAt === null)
49
+ && (id !== 'minds_removeAgentGroupMember' || v.version === Number(requested?.expectedVersion) + 1 && positive(v.revokedAt));
50
+ const attachment = (v) => {
51
+ if (!exact(v, ['id', 'version', 'organizationId', 'projectId', 'mindId', 'subject', 'permissions', 'sharedNamespace', 'expiresAt', 'revokedAt'])
52
+ || !canonical(v.id, 'mat_') || (input.attachment_id !== undefined && v.id !== input.attachment_id)
53
+ || !positive(v.version) || !text(v.organizationId) || !text(v.projectId) || v.mindId !== input.mind_id
54
+ || !subject(v.subject) || !permissions(v.permissions) || !positive(v.expiresAt) || !tombstone(v.revokedAt))
55
+ return false;
56
+ const s = v.subject;
57
+ if (v.sharedNamespace !== (s.kind === 'group' ? `group:${s.groupId}` : null))
58
+ return false;
59
+ if (id === 'minds_attachMind') {
60
+ const selected = requested?.subject;
61
+ return s.kind === selected.kind && (s.kind === 'agent' ? s.agentId === selected.agentId : s.groupId === selected.groupId)
62
+ && JSON.stringify(v.permissions) === JSON.stringify(requested?.permissions) && v.expiresAt === requested?.expiresAt
63
+ && v.version === Number(requested?.expectedVersion) + 1 && v.revokedAt === null;
64
+ }
65
+ return id !== 'minds_detachMind' || v.version === Number(requested?.expectedVersion) + 1 && positive(v.revokedAt);
66
+ };
67
+ const list = (key, valid) => exact(value, [key]) && Array.isArray(value[key]) && value[key].every(valid);
68
+ if (id === 'minds_listAgentGroups')
69
+ return list('groups', group);
70
+ if (id === 'minds_listAgentGroupMembers')
71
+ return list('members', member);
72
+ if (id === 'minds_listMindAttachments')
73
+ return list('attachments', attachment);
74
+ return id === 'minds_createAgentGroup' ? group(value) : id === 'minds_addAgentGroupMember' || id === 'minds_removeAgentGroupMember' ? member(value) : attachment(value);
75
+ }
76
+ /** Original-human owner operations. No context selection, token substitution or automatic retry. */
77
+ export async function mindsOwnerTransport(options) {
78
+ const id = options.operationId;
79
+ let dispatched = false;
80
+ const fail = (status, type, info = {}) => new MindsOwnerError({
81
+ status, type, operationId: id, code: info.code, requestId: info.requestId,
82
+ message: 'Minds owner operation was not confirmed. Preserve its operation ID and version when reconciling.',
83
+ ...(info.unknown || dispatched && (status === 0 || status >= 500 || type === 'invalid_response' && status >= 200 && status < 300) ? { body: { outcome: 'unknown' } } : {}),
84
+ });
85
+ if (!isMindsOwnerOperation(id) || options.routing !== 'gateway' || Object.keys(options.headers ?? {}).length)
86
+ throw fail(0, 'invalid_request');
87
+ const input = options.input, fields = id === 'minds_listAgentGroups' ? [] : id === 'minds_createAgentGroup' ? ['body']
88
+ : id === 'minds_removeAgentGroupMember' ? ['group_id', 'agent_id', 'body']
89
+ : id === 'minds_listAgentGroupMembers' ? ['group_id'] : id === 'minds_addAgentGroupMember' ? ['group_id', 'body']
90
+ : id === 'minds_listMindAttachments' ? ['mind_id'] : id === 'minds_detachMind' ? ['mind_id', 'attachment_id', 'body'] : ['mind_id', 'body'];
91
+ if (!exact(input, fields) || input.group_id !== undefined && !canonical(input.group_id, 'agp_')
92
+ || input.agent_id !== undefined && !canonical(input.agent_id, 'a_') || input.mind_id !== undefined && !uuid(input.mind_id)
93
+ || input.attachment_id !== undefined && !canonical(input.attachment_id, 'mat_') || !validBody(id, input.body))
94
+ throw fail(0, 'invalid_request');
95
+ const body = input.body === undefined ? undefined : JSON.stringify(input.body);
96
+ if (body !== undefined && utf8(body) > 8192)
97
+ throw fail(0, 'invalid_request');
98
+ const controller = new AbortController(), cancel = () => controller.abort(options.signal?.reason);
99
+ options.signal?.addEventListener('abort', cancel, { once: true });
100
+ if (options.signal?.aborted)
101
+ cancel();
102
+ const timer = setTimeout(() => controller.abort(), 35_000);
103
+ async function bounded(work) {
104
+ controller.signal.throwIfAborted();
105
+ let abort = () => { };
106
+ const cancelled = new Promise((_, reject) => { abort = () => reject(fail(0, 'transport_error')); controller.signal.addEventListener('abort', abort, { once: true }); });
107
+ try {
108
+ controller.signal.throwIfAborted();
109
+ let pending;
110
+ try {
111
+ pending = work();
112
+ }
113
+ catch (error) {
114
+ pending = Promise.reject(error);
115
+ }
116
+ return await Promise.race([cancelled, pending]);
117
+ }
118
+ finally {
119
+ controller.signal.removeEventListener('abort', abort);
120
+ }
121
+ }
122
+ try {
123
+ const credential = await bounded(options.credential);
124
+ controller.signal.throwIfAborted();
125
+ if (!text(credential) || utf8(credential) > 16384 || /[^\x21-\x7e]|,/.test(credential))
126
+ throw fail(401, 'unauthenticated');
127
+ const response = await bounded(() => {
128
+ dispatched = !reads.has(id);
129
+ return options.fetch(options.url, { method: reads.has(id) ? 'GET' : removes.has(id) ? 'DELETE' : 'POST',
130
+ headers: { authorization: `Bearer ${credential}`, accept: 'application/json', ...(body === undefined ? {} : { 'content-type': 'application/json' }) },
131
+ ...(body === undefined ? {} : { body }), signal: controller.signal, redirect: 'error', cache: 'no-store' }).then(response => {
132
+ if (controller.signal.aborted) {
133
+ void response.body?.cancel().catch(() => { });
134
+ throw fail(0, 'transport_error');
135
+ }
136
+ return response;
137
+ });
138
+ });
139
+ if (response.headers.get('content-type')?.split(';')[0].trim().toLowerCase() !== 'application/json')
140
+ throw fail(response.status, 'invalid_response');
141
+ const reader = response.body?.getReader();
142
+ if (!reader)
143
+ throw fail(response.status, 'invalid_response');
144
+ const chunks = [];
145
+ let size = 0;
146
+ const stop = () => { void reader.cancel().catch(() => { }); };
147
+ controller.signal.addEventListener('abort', stop, { once: true });
148
+ try {
149
+ for (;;) {
150
+ const next = await bounded(() => reader.read());
151
+ if (next.done)
152
+ break;
153
+ size += next.value.length;
154
+ if (size > 2 * 1024 * 1024)
155
+ throw fail(response.status, 'invalid_response');
156
+ chunks.push(next.value);
157
+ }
158
+ }
159
+ finally {
160
+ controller.signal.removeEventListener('abort', stop);
161
+ stop();
162
+ try {
163
+ reader.releaseLock();
164
+ }
165
+ catch { /* pending cancellation owns the reader */ }
166
+ }
167
+ const bytes = new Uint8Array(size);
168
+ let offset = 0;
169
+ for (const chunk of chunks) {
170
+ bytes.set(chunk, offset);
171
+ offset += chunk.length;
172
+ }
173
+ let value;
174
+ try {
175
+ value = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes));
176
+ }
177
+ catch {
178
+ throw fail(response.status, 'invalid_response');
179
+ }
180
+ if (!response.ok) {
181
+ if (!exact(value, ['error']) || !row(value.error) || !['code', 'request_id'].every(k => Object.hasOwn(value.error, k))
182
+ || Object.keys(value.error).some(k => !['code', 'request_id', 'outcome', ...ENVELOPE_EXTRA_FIELDS].includes(k)) || !envelopeExtrasValid(value.error) || typeof value.error.code !== 'string'
183
+ || !/^[A-Z][A-Z0-9_]{0,127}$/.test(value.error.code) || typeof value.error.request_id !== 'string'
184
+ || !/^[\x21-\x7e]{1,256}$/.test(value.error.request_id) || value.error.outcome !== undefined && value.error.outcome !== 'unknown')
185
+ throw fail(response.status, 'invalid_response');
186
+ throw fail(response.status, 'minds_owner_error', { code: value.error.code, requestId: value.error.request_id, unknown: !reads.has(id) && value.error.outcome === 'unknown' });
187
+ }
188
+ if (response.status !== 200 || !validResponse(id, input, value))
189
+ throw fail(response.status, 'invalid_response');
190
+ return Response.json(value, { status: 200, headers: { 'cache-control': 'private, no-store' } });
191
+ }
192
+ catch (error) {
193
+ if (error instanceof MindsOwnerError)
194
+ throw error;
195
+ throw fail(0, 'transport_error');
196
+ }
197
+ finally {
198
+ clearTimeout(timer);
199
+ controller.abort();
200
+ options.signal?.removeEventListener('abort', cancel);
201
+ }
202
+ }
203
+ export function mindsOwnerModule(client) {
204
+ const validOptions = (value) => exact(value, []) || exact(value, ['signal']);
205
+ const init = (options) => {
206
+ if (!validOptions(options))
207
+ throw new MindsOwnerError({ status: 0, type: 'invalid_request', message: 'Unknown Minds owner option.' });
208
+ return { signal: options.signal };
209
+ };
210
+ return {
211
+ groups: {
212
+ list: (options = {}) => client.request('minds_listAgentGroups', {}, init(options)),
213
+ create: (body, options = {}) => client.request('minds_createAgentGroup', { body }, init(options)),
214
+ members: {
215
+ list: (group_id, options = {}) => client.request('minds_listAgentGroupMembers', { group_id }, init(options)),
216
+ add: (group_id, body, options = {}) => client.request('minds_addAgentGroupMember', { group_id, body }, init(options)),
217
+ remove: (group_id, agent_id, body, options = {}) => client.request('minds_removeAgentGroupMember', { group_id, agent_id, body }, init(options)),
218
+ },
219
+ },
220
+ attachments: {
221
+ list: (mind_id, options = {}) => client.request('minds_listMindAttachments', { mind_id }, init(options)),
222
+ attach: (mind_id, body, options = {}) => client.request('minds_attachMind', { mind_id, body }, init(options)),
223
+ detach: (mind_id, attachment_id, body, options = {}) => client.request('minds_detachMind', { mind_id, attachment_id, body }, init(options)),
224
+ },
225
+ };
226
+ }