fauna-api 0.0.0-stage → 1.0.676

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 (171) hide show
  1. package/dist/brands.d.ts +2 -0
  2. package/dist/brands.js +2 -0
  3. package/dist/index.d.ts +64 -0
  4. package/dist/index.js +121 -0
  5. package/dist/src/ant/chat.d.ts +130 -0
  6. package/dist/src/ant/chat.js +467 -0
  7. package/dist/src/ant/format.d.ts +40 -0
  8. package/dist/src/ant/format.js +143 -0
  9. package/dist/src/ant/graph.d.ts +130 -0
  10. package/dist/src/ant/graph.js +449 -0
  11. package/dist/src/ant/index.d.ts +16 -0
  12. package/dist/src/ant/index.js +61 -0
  13. package/dist/src/ant/persona.d.ts +151 -0
  14. package/dist/src/ant/persona.js +136 -0
  15. package/dist/src/ant/timeline.d.ts +283 -0
  16. package/dist/src/ant/timeline.js +1025 -0
  17. package/dist/src/authentification.d.ts +45 -0
  18. package/dist/src/authentification.js +194 -0
  19. package/dist/src/billing.d.ts +135 -0
  20. package/dist/src/billing.js +128 -0
  21. package/dist/src/calendar.d.ts +83 -0
  22. package/dist/src/calendar.js +133 -0
  23. package/dist/src/chats.d.ts +113 -0
  24. package/dist/src/chats.js +100 -0
  25. package/dist/src/cicada/contacts.d.ts +31 -0
  26. package/dist/src/cicada/contacts.js +28 -0
  27. package/dist/src/cicada/conversations.d.ts +73 -0
  28. package/dist/src/cicada/conversations.js +236 -0
  29. package/dist/src/cicada/inboxes.d.ts +48 -0
  30. package/dist/src/cicada/inboxes.js +82 -0
  31. package/dist/src/cicada/index.d.ts +16 -0
  32. package/dist/src/cicada/index.js +61 -0
  33. package/dist/src/cicada/phone.d.ts +48 -0
  34. package/dist/src/cicada/phone.js +306 -0
  35. package/dist/src/drive.d.ts +80 -0
  36. package/dist/src/drive.js +472 -0
  37. package/dist/src/extensions/index.d.ts +4 -0
  38. package/dist/src/extensions/index.js +5 -0
  39. package/dist/src/extensions/web/index.d.ts +6 -0
  40. package/dist/src/extensions/web/index.js +7 -0
  41. package/dist/src/extensions/web/session.d.ts +106 -0
  42. package/dist/src/extensions/web/session.js +469 -0
  43. package/dist/src/extensions/web/tools.d.ts +13 -0
  44. package/dist/src/extensions/web/tools.js +72 -0
  45. package/dist/src/friends.d.ts +39 -0
  46. package/dist/src/friends.js +119 -0
  47. package/dist/src/groups.d.ts +82 -0
  48. package/dist/src/groups.js +269 -0
  49. package/dist/src/inbox.d.ts +11 -0
  50. package/dist/src/inbox.js +35 -0
  51. package/dist/src/integrations.d.ts +52 -0
  52. package/dist/src/integrations.js +205 -0
  53. package/dist/src/magpie/explorer.d.ts +14 -0
  54. package/dist/src/magpie/explorer.js +36 -0
  55. package/dist/src/magpie/index.d.ts +16 -0
  56. package/dist/src/magpie/index.js +61 -0
  57. package/dist/src/magpie/portfolio.d.ts +52 -0
  58. package/dist/src/magpie/portfolio.js +179 -0
  59. package/dist/src/magpie/quotes.d.ts +35 -0
  60. package/dist/src/magpie/quotes.js +47 -0
  61. package/dist/src/magpie/room.d.ts +61 -0
  62. package/dist/src/magpie/room.js +238 -0
  63. package/dist/src/maps.d.ts +159 -0
  64. package/dist/src/maps.js +171 -0
  65. package/dist/src/marmot/browser.d.ts +139 -0
  66. package/dist/src/marmot/browser.js +389 -0
  67. package/dist/src/marmot/index.d.ts +20 -0
  68. package/dist/src/marmot/index.js +65 -0
  69. package/dist/src/marmot/media.d.ts +56 -0
  70. package/dist/src/marmot/media.js +265 -0
  71. package/dist/src/marmot/research.d.ts +337 -0
  72. package/dist/src/marmot/research.js +1138 -0
  73. package/dist/src/marmot/scraper.d.ts +59 -0
  74. package/dist/src/marmot/scraper.js +94 -0
  75. package/dist/src/marmot/web.d.ts +402 -0
  76. package/dist/src/marmot/web.js +2586 -0
  77. package/dist/src/marmot/workspace.d.ts +81 -0
  78. package/dist/src/marmot/workspace.js +263 -0
  79. package/dist/src/parrot/agent.d.ts +53 -0
  80. package/dist/src/parrot/agent.js +93 -0
  81. package/dist/src/parrot/chat.d.ts +84 -0
  82. package/dist/src/parrot/chat.js +237 -0
  83. package/dist/src/parrot/format.d.ts +128 -0
  84. package/dist/src/parrot/format.js +639 -0
  85. package/dist/src/parrot/generative.d.ts +261 -0
  86. package/dist/src/parrot/generative.js +185 -0
  87. package/dist/src/parrot/index.d.ts +22 -0
  88. package/dist/src/parrot/index.js +67 -0
  89. package/dist/src/parrot/room.d.ts +225 -0
  90. package/dist/src/parrot/room.js +466 -0
  91. package/dist/src/parrot/routing.d.ts +90 -0
  92. package/dist/src/parrot/routing.js +78 -0
  93. package/dist/src/parrot/share.d.ts +126 -0
  94. package/dist/src/parrot/share.js +261 -0
  95. package/dist/src/parrot/socket.d.ts +41 -0
  96. package/dist/src/parrot/socket.js +478 -0
  97. package/dist/src/payments.d.ts +73 -0
  98. package/dist/src/payments.js +107 -0
  99. package/dist/src/private/cards.css +75 -0
  100. package/dist/src/rooms.d.ts +76 -0
  101. package/dist/src/rooms.js +168 -0
  102. package/dist/src/shared/schema.d.ts +24 -0
  103. package/dist/src/shared/schema.js +1 -0
  104. package/dist/src/shared/server.d.ts +65 -0
  105. package/dist/src/shared/server.js +302 -0
  106. package/dist/src/termite/environment.d.ts +110 -0
  107. package/dist/src/termite/environment.js +263 -0
  108. package/dist/src/termite/index.d.ts +14 -0
  109. package/dist/src/termite/index.js +59 -0
  110. package/dist/src/termite/os.d.ts +326 -0
  111. package/dist/src/termite/os.js +572 -0
  112. package/dist/src/termite/versioning.d.ts +94 -0
  113. package/dist/src/termite/versioning.js +217 -0
  114. package/dist/src/tickets.d.ts +43 -0
  115. package/dist/src/tickets.js +138 -0
  116. package/dist/src/travel.d.ts +85 -0
  117. package/dist/src/travel.js +44 -0
  118. package/dist/src/ui/authentification.d.ts +24 -0
  119. package/dist/src/ui/authentification.js +177 -0
  120. package/dist/src/ui/brands.css +11 -0
  121. package/dist/src/ui/brands.d.ts +7 -0
  122. package/dist/src/ui/brands.js +14 -0
  123. package/dist/src/ui/browser.d.ts +74 -0
  124. package/dist/src/ui/browser.js +470 -0
  125. package/dist/src/ui/chat.d.ts +183 -0
  126. package/dist/src/ui/chat.js +2379 -0
  127. package/dist/src/ui/chatPanel.d.ts +109 -0
  128. package/dist/src/ui/chatPanel.js +768 -0
  129. package/dist/src/ui/chatSequence.d.ts +36 -0
  130. package/dist/src/ui/chatSequence.js +42 -0
  131. package/dist/src/ui/crown.d.ts +19 -0
  132. package/dist/src/ui/crown.js +199 -0
  133. package/dist/src/ui/cursor.d.ts +73 -0
  134. package/dist/src/ui/cursor.js +175 -0
  135. package/dist/src/ui/device.d.ts +33 -0
  136. package/dist/src/ui/device.js +49 -0
  137. package/dist/src/ui/drive.d.ts +69 -0
  138. package/dist/src/ui/drive.js +1243 -0
  139. package/dist/src/ui/generative.d.ts +39 -0
  140. package/dist/src/ui/generative.js +313 -0
  141. package/dist/src/ui/hover.d.ts +6 -0
  142. package/dist/src/ui/hover.js +210 -0
  143. package/dist/src/ui/index.d.ts +42 -0
  144. package/dist/src/ui/index.js +87 -0
  145. package/dist/src/ui/integrations.d.ts +13 -0
  146. package/dist/src/ui/integrations.js +175 -0
  147. package/dist/src/ui/maps.d.ts +87 -0
  148. package/dist/src/ui/maps.js +547 -0
  149. package/dist/src/ui/roster.d.ts +32 -0
  150. package/dist/src/ui/roster.js +163 -0
  151. package/dist/src/ui/talk.d.ts +12 -0
  152. package/dist/src/ui/talk.js +560 -0
  153. package/dist/src/ui/tickets.d.ts +13 -0
  154. package/dist/src/ui/tickets.js +966 -0
  155. package/dist/src/ui/toast.d.ts +7 -0
  156. package/dist/src/ui/toast.js +258 -0
  157. package/dist/src/ui/tokenText.d.ts +18 -0
  158. package/dist/src/ui/tokenText.js +96 -0
  159. package/dist/src/ui/tokenized.d.ts +42 -0
  160. package/dist/src/ui/tokenized.js +622 -0
  161. package/dist/src/ui/ui.css +4763 -0
  162. package/dist/src/ui/view.d.ts +23 -0
  163. package/dist/src/ui/view.js +584 -0
  164. package/dist/src/view.d.ts +113 -0
  165. package/dist/src/view.js +386 -0
  166. package/dist/src/webhooks.d.ts +66 -0
  167. package/dist/src/webhooks.js +78 -0
  168. package/dist/ui.d.ts +1 -0
  169. package/dist/ui.js +1 -0
  170. package/package.json +89 -6
  171. package/README.md +0 -3
@@ -0,0 +1,302 @@
1
+ export class Presence {
2
+ constructor(room, id, profile) {
3
+ Object.defineProperty(this, "room", {
4
+ enumerable: true,
5
+ configurable: true,
6
+ writable: true,
7
+ value: void 0
8
+ });
9
+ Object.defineProperty(this, "id", {
10
+ enumerable: true,
11
+ configurable: true,
12
+ writable: true,
13
+ value: void 0
14
+ });
15
+ Object.defineProperty(this, "profile", {
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true,
19
+ value: void 0
20
+ });
21
+ Object.defineProperty(this, "_position", {
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true,
25
+ value: void 0
26
+ });
27
+ Object.defineProperty(this, "_status", {
28
+ enumerable: true,
29
+ configurable: true,
30
+ writable: true,
31
+ value: void 0
32
+ });
33
+ this.room = room;
34
+ this.id = id;
35
+ this.profile = profile;
36
+ this._position = [0, 0, 0];
37
+ this._status = undefined;
38
+ }
39
+ get position() {
40
+ return this._position;
41
+ }
42
+ get status() {
43
+ return this._status ?? '';
44
+ }
45
+ move(position) {
46
+ this._position = position;
47
+ this.room.post({
48
+ event: 'update-client',
49
+ client: this.toJSON()
50
+ });
51
+ }
52
+ setStatus(status) {
53
+ this._status = status;
54
+ this.room.post({
55
+ event: 'update-client',
56
+ client: this.toJSON()
57
+ });
58
+ }
59
+ update(patch) {
60
+ this._position = patch.position ?? this._position;
61
+ this._status = patch.status ?? this._status;
62
+ }
63
+ toJSON() {
64
+ return {
65
+ id: this.id,
66
+ profile: this.profile,
67
+ position: this._position,
68
+ status: this.status
69
+ };
70
+ }
71
+ }
72
+ export class Room {
73
+ constructor(endpoint, ws, authorization, id) {
74
+ Object.defineProperty(this, "endpoint", {
75
+ enumerable: true,
76
+ configurable: true,
77
+ writable: true,
78
+ value: void 0
79
+ });
80
+ Object.defineProperty(this, "ws", {
81
+ enumerable: true,
82
+ configurable: true,
83
+ writable: true,
84
+ value: void 0
85
+ });
86
+ Object.defineProperty(this, "authorization", {
87
+ enumerable: true,
88
+ configurable: true,
89
+ writable: true,
90
+ value: void 0
91
+ });
92
+ Object.defineProperty(this, "id", {
93
+ enumerable: true,
94
+ configurable: true,
95
+ writable: true,
96
+ value: void 0
97
+ });
98
+ Object.defineProperty(this, "presences", {
99
+ enumerable: true,
100
+ configurable: true,
101
+ writable: true,
102
+ value: void 0
103
+ });
104
+ this.endpoint = endpoint;
105
+ this.ws = ws;
106
+ this.authorization = authorization;
107
+ this.id = id;
108
+ this.presences = [];
109
+ }
110
+ getPresences() {
111
+ return this.presences;
112
+ }
113
+ /** The caller's Credentials or ApiKey from the live authorization pack. */
114
+ getAuthorization() {
115
+ return this.authorization.authorization;
116
+ }
117
+ // Send a raw frame to the room edge.
118
+ post(packet) {
119
+ if (this.ws.readyState !== WebSocket.OPEN)
120
+ return;
121
+ this.ws.send(JSON.stringify(packet));
122
+ }
123
+ disconnect() {
124
+ this.presences.length = 0;
125
+ this.ws.close();
126
+ }
127
+ async generateAccessCode() {
128
+ const auth = this.authorization;
129
+ const response = await fetch(`${this.endpoint.endsWith('/') ? this.endpoint.slice(0, -1) : this.endpoint}/access-code`, {
130
+ method: "POST",
131
+ headers: {
132
+ ...('email' in auth.authorization ? {
133
+ Authorization: `Token ${auth.authorization.token}`
134
+ } : {
135
+ Authorization: `ApiKey ${auth.authorization.id}`
136
+ }),
137
+ // Mint resolves the room the same way live connect does: Server
138
+ // (+ optional Group for group-hosted rooms).
139
+ ...('server' in auth ? { Server: auth.server } : {}),
140
+ ...('server' in auth && auth.group ? { Group: auth.group } : {}),
141
+ }
142
+ });
143
+ if (!response.ok) {
144
+ throw new Error(await response.text());
145
+ }
146
+ return (await response.text());
147
+ }
148
+ }
149
+ export async function connect(authorization, endpoint, hooks = {}) {
150
+ // Build WebSocket URL
151
+ const authParam = encodeURIComponent(JSON.stringify({
152
+ Authorization: 'email' in authorization.authorization ? `Token ${authorization.authorization.token}` : `ApiKey ${authorization.authorization.id}`,
153
+ ...('server' in authorization ? {
154
+ Server: authorization.server,
155
+ ...('group' in authorization ? {
156
+ Group: authorization.group
157
+ } : {})
158
+ } : {
159
+ AccessCode: authorization.accessCode
160
+ })
161
+ }));
162
+ const wsURL = endpoint.replace(/^http:\/\//, 'ws://').replace(/^https:\/\//, 'wss://').replace(/\/$/, '');
163
+ const ws = new WebSocket(`${wsURL}?authorization=${authParam}`);
164
+ var room = undefined;
165
+ var selfId = undefined;
166
+ // Wait for connection
167
+ return await new Promise((resolve, reject) => {
168
+ let settled = false;
169
+ const settle = (fn) => {
170
+ if (settled)
171
+ return;
172
+ settled = true;
173
+ clearTimeout(timer);
174
+ fn();
175
+ };
176
+ const fail = (message) => {
177
+ settle(() => {
178
+ try {
179
+ ws.close();
180
+ }
181
+ catch { /* noop */ }
182
+ reject(new Error(message));
183
+ });
184
+ };
185
+ const timer = setTimeout(() => fail(`Timed out waiting for the room (${wsURL}).`), 15000);
186
+ ws.onmessage = (msg) => {
187
+ try {
188
+ const json = JSON.parse(typeof msg.data === 'string' ? msg.data : String(msg.data));
189
+ if (json.event === 'error') {
190
+ fail(typeof json.message === 'string' && json.message ? json.message : 'Room connection failed');
191
+ return;
192
+ }
193
+ switch (json.event) {
194
+ case 'connection': {
195
+ const client = json.data?.client;
196
+ if (!client?.id) {
197
+ fail('Room connection missing self.');
198
+ return;
199
+ }
200
+ selfId = client.id;
201
+ const id = json.data.server.id;
202
+ const state = json.data.state;
203
+ room = hooks.createRoom ? hooks.createRoom(endpoint, ws, authorization, id, state) : new Room(endpoint, ws, authorization, id);
204
+ const self = hooks.createPresence ? hooks.createPresence(room, client) : new Presence(room, client.id, client.profile);
205
+ self.update(client);
206
+ for (const presence of json.data.clients ?? []) {
207
+ if (presence.id === client.id) {
208
+ continue;
209
+ }
210
+ const other = hooks.createPresence ? hooks.createPresence(room, presence) : new Presence(room, presence.id, presence.profile);
211
+ other.update(presence);
212
+ room.getPresences().push(other);
213
+ }
214
+ if (hooks.onConnection) {
215
+ hooks.onConnection(room, state);
216
+ }
217
+ settle(() => resolve(self));
218
+ break;
219
+ }
220
+ case 'add-client': {
221
+ if (!room) {
222
+ fail('Room not found');
223
+ return;
224
+ }
225
+ if (json.data.client.id === selfId) {
226
+ break;
227
+ }
228
+ const presence = hooks.createPresence ? hooks.createPresence(room, json.data.client) : new Presence(room, json.data.client.id, json.data.client.profile);
229
+ presence.update(json.data.client);
230
+ room.getPresences().push(presence);
231
+ hooks.onPresence?.(room);
232
+ break;
233
+ }
234
+ case 'update-client': {
235
+ if (!room) {
236
+ fail('Room not found');
237
+ return;
238
+ }
239
+ if (json.data.client.id === selfId) {
240
+ break;
241
+ }
242
+ const presence = room.getPresences().find(p => p.id === json.data.client.id);
243
+ if (!presence) {
244
+ fail('Presence not found');
245
+ return;
246
+ }
247
+ presence.update(json.data.client);
248
+ hooks.onPresence?.(room);
249
+ break;
250
+ }
251
+ case 'remove-client': {
252
+ if (!room) {
253
+ fail('Room not found');
254
+ return;
255
+ }
256
+ const id = json.data.client.id;
257
+ const presence = room.getPresences().find(p => p.id === id);
258
+ if (hooks.removePresence && presence) {
259
+ hooks.removePresence(room, presence);
260
+ }
261
+ if (presence) {
262
+ room.getPresences().splice(room.getPresences().indexOf(presence), 1);
263
+ }
264
+ hooks.onPresence?.(room);
265
+ break;
266
+ }
267
+ case 'server-closed': {
268
+ if (!room) {
269
+ fail('Room closed before connect');
270
+ return;
271
+ }
272
+ const reason = typeof json.data?.reason === 'string' ? json.data.reason : undefined;
273
+ room.getPresences().length = 0;
274
+ hooks.onClosed?.(room, reason ? { reason } : undefined);
275
+ try {
276
+ ws.close();
277
+ }
278
+ catch { /* noop */ }
279
+ break;
280
+ }
281
+ default: {
282
+ if (hooks.onEvent && room) {
283
+ hooks.onEvent(room, json);
284
+ }
285
+ break;
286
+ }
287
+ }
288
+ }
289
+ catch (err) {
290
+ if (!settled) {
291
+ fail(err instanceof Error ? err.message : 'Room connection failed');
292
+ }
293
+ }
294
+ };
295
+ ws.onerror = () => {
296
+ fail(`WebSocket connection failed (${wsURL})`);
297
+ };
298
+ ws.onclose = () => {
299
+ fail(`WebSocket closed before the room connected (${wsURL})`);
300
+ };
301
+ });
302
+ }
@@ -0,0 +1,110 @@
1
+ import { Text } from "../parrot/generative.js";
2
+ import type { Content } from "../parrot/generative.js";
3
+ import { Authorization, Room } from "../shared/server.js";
4
+ import { Repository, type Route } from "./versioning.js";
5
+ export type Terms = number | {
6
+ total: number;
7
+ upfront: number;
8
+ duration: number;
9
+ interval: number;
10
+ };
11
+ export type Ticket = {
12
+ id: number;
13
+ date: Date;
14
+ issue: string;
15
+ status: 'ACTIVE' | 'REJECTED' | 'FULFILLED';
16
+ };
17
+ export declare class Constitution {
18
+ readonly text: string;
19
+ readonly articles: string[];
20
+ private readonly room;
21
+ constructor(room: RuntimeRoom, text: string, articles?: string[]);
22
+ amend(article: string): Promise<void>;
23
+ }
24
+ export declare class RuntimeRoom extends Room {
25
+ readonly name: string;
26
+ readonly constitution: Constitution;
27
+ readonly model: Text;
28
+ readonly agents: Map<string, Agent>;
29
+ constructor(endpoint: string, ws: WebSocket, authorization: Authorization, id: string, state?: any);
30
+ update(json: unknown): void;
31
+ }
32
+ export declare class Agent {
33
+ readonly parent: Agent | null;
34
+ readonly id: string;
35
+ readonly children: Agent[];
36
+ readonly bible: string;
37
+ private _status;
38
+ readonly repository: Repository;
39
+ constructor(parent: Agent | null, id: string, bible: string, repository: Repository, status?: 'ACTIVE' | 'IDLE' | 'DELETED');
40
+ get status(): 'ACTIVE' | 'IDLE' | 'DELETED';
41
+ ticket(_issue: string): Promise<Ticket>;
42
+ delete(): Promise<void>;
43
+ balance(_query: {
44
+ start: Date;
45
+ end: Date;
46
+ max: number;
47
+ } | {
48
+ cursor: number;
49
+ max: number;
50
+ }): Promise<{
51
+ balanceMicros: number;
52
+ date: Date;
53
+ }[]>;
54
+ contracts(_query: {
55
+ start: Date;
56
+ end: Date;
57
+ } | {
58
+ cursor: number;
59
+ max: number;
60
+ }): Promise<Contract[]>;
61
+ loans(_query: {
62
+ start: Date;
63
+ end: Date;
64
+ } | {
65
+ cursor: number;
66
+ max: number;
67
+ }): Promise<Loan[]>;
68
+ tickets(_query: {
69
+ start: Date;
70
+ end: Date;
71
+ } | {
72
+ cursor: number;
73
+ max: number;
74
+ }): Promise<Ticket[]>;
75
+ }
76
+ export declare class Contract {
77
+ readonly parent: RuntimeRoom;
78
+ readonly id: string;
79
+ principal: Agent;
80
+ contractor: Agent;
81
+ description: string;
82
+ settlement: Terms;
83
+ status: 'PROPOSED' | 'ACTIVE' | 'REJECTED' | 'COUNTERED' | 'DEFAULTED' | 'FULFILLED';
84
+ content: (Content | Contract)[];
85
+ validation: {
86
+ repository: Repository;
87
+ route: Route;
88
+ };
89
+ date: Date;
90
+ constructor(parent: RuntimeRoom, id: string, principal: Agent, contractor: Agent, description: string, settlement: Terms, validation: {
91
+ repository: Repository;
92
+ route: Route;
93
+ }, date?: Date);
94
+ }
95
+ export declare class Loan {
96
+ readonly parent: RuntimeRoom;
97
+ readonly id: string;
98
+ lender: Agent;
99
+ borrower: Agent;
100
+ terms: {
101
+ lender: Terms;
102
+ borrower: Terms;
103
+ };
104
+ status: 'PROPOSED' | 'ACTIVE' | 'REJECTED' | 'DEFAULTED' | 'FULFILLED';
105
+ date: Date;
106
+ constructor(parent: RuntimeRoom, id: string, lender: Agent, borrower: Agent, terms: {
107
+ lender: Terms;
108
+ borrower: Terms;
109
+ }, date?: Date);
110
+ }
@@ -0,0 +1,263 @@
1
+ import { Text } from "../parrot/generative.js";
2
+ import { Room } from "../shared/server.js";
3
+ export class Constitution {
4
+ constructor(room, text, articles = []) {
5
+ Object.defineProperty(this, "text", {
6
+ enumerable: true,
7
+ configurable: true,
8
+ writable: true,
9
+ value: void 0
10
+ });
11
+ Object.defineProperty(this, "articles", {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value: void 0
16
+ });
17
+ Object.defineProperty(this, "room", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: void 0
22
+ });
23
+ this.room = room;
24
+ this.text = text;
25
+ this.articles = [...articles];
26
+ }
27
+ async amend(article) {
28
+ this.articles.push(article);
29
+ this.room.update({ event: 'amend-constitution', article });
30
+ }
31
+ }
32
+ export class RuntimeRoom extends Room {
33
+ constructor(endpoint, ws, authorization, id, state) {
34
+ super(endpoint, ws, authorization, id);
35
+ Object.defineProperty(this, "name", {
36
+ enumerable: true,
37
+ configurable: true,
38
+ writable: true,
39
+ value: void 0
40
+ });
41
+ Object.defineProperty(this, "constitution", {
42
+ enumerable: true,
43
+ configurable: true,
44
+ writable: true,
45
+ value: void 0
46
+ });
47
+ Object.defineProperty(this, "model", {
48
+ enumerable: true,
49
+ configurable: true,
50
+ writable: true,
51
+ value: void 0
52
+ });
53
+ Object.defineProperty(this, "agents", {
54
+ enumerable: true,
55
+ configurable: true,
56
+ writable: true,
57
+ value: void 0
58
+ });
59
+ this.name = typeof state?.name === "string" ? state.name : "";
60
+ this.model = state?.model ?? Text.AUTO;
61
+ this.constitution = new Constitution(this, typeof state?.constitution?.text === "string" ? state.constitution.text : "", Array.isArray(state?.constitution?.articles) ? state.constitution.articles : []);
62
+ this.agents = new Map();
63
+ }
64
+ update(json) {
65
+ this.post(json);
66
+ }
67
+ }
68
+ export class Agent {
69
+ constructor(parent, id, bible, repository, status = 'IDLE') {
70
+ Object.defineProperty(this, "parent", {
71
+ enumerable: true,
72
+ configurable: true,
73
+ writable: true,
74
+ value: void 0
75
+ });
76
+ Object.defineProperty(this, "id", {
77
+ enumerable: true,
78
+ configurable: true,
79
+ writable: true,
80
+ value: void 0
81
+ });
82
+ Object.defineProperty(this, "children", {
83
+ enumerable: true,
84
+ configurable: true,
85
+ writable: true,
86
+ value: void 0
87
+ });
88
+ Object.defineProperty(this, "bible", {
89
+ enumerable: true,
90
+ configurable: true,
91
+ writable: true,
92
+ value: void 0
93
+ });
94
+ Object.defineProperty(this, "_status", {
95
+ enumerable: true,
96
+ configurable: true,
97
+ writable: true,
98
+ value: void 0
99
+ });
100
+ Object.defineProperty(this, "repository", {
101
+ enumerable: true,
102
+ configurable: true,
103
+ writable: true,
104
+ value: void 0
105
+ });
106
+ this.parent = parent;
107
+ this.id = id;
108
+ this.children = [];
109
+ this.bible = bible;
110
+ this._status = status;
111
+ this.repository = repository;
112
+ if (parent)
113
+ parent.children.push(this);
114
+ }
115
+ get status() {
116
+ return this._status;
117
+ }
118
+ async ticket(_issue) {
119
+ throw new Error("Termite routes are not implemented.");
120
+ }
121
+ async delete() {
122
+ throw new Error("Termite routes are not implemented.");
123
+ }
124
+ async balance(_query) {
125
+ throw new Error("Termite routes are not implemented.");
126
+ }
127
+ async contracts(_query) {
128
+ throw new Error("Termite routes are not implemented.");
129
+ }
130
+ async loans(_query) {
131
+ throw new Error("Termite routes are not implemented.");
132
+ }
133
+ async tickets(_query) {
134
+ throw new Error("Termite routes are not implemented.");
135
+ }
136
+ }
137
+ export class Contract {
138
+ constructor(parent, id, principal, contractor, description, settlement, validation, date = new Date()) {
139
+ Object.defineProperty(this, "parent", {
140
+ enumerable: true,
141
+ configurable: true,
142
+ writable: true,
143
+ value: void 0
144
+ });
145
+ Object.defineProperty(this, "id", {
146
+ enumerable: true,
147
+ configurable: true,
148
+ writable: true,
149
+ value: void 0
150
+ });
151
+ Object.defineProperty(this, "principal", {
152
+ enumerable: true,
153
+ configurable: true,
154
+ writable: true,
155
+ value: void 0
156
+ });
157
+ Object.defineProperty(this, "contractor", {
158
+ enumerable: true,
159
+ configurable: true,
160
+ writable: true,
161
+ value: void 0
162
+ });
163
+ Object.defineProperty(this, "description", {
164
+ enumerable: true,
165
+ configurable: true,
166
+ writable: true,
167
+ value: void 0
168
+ });
169
+ Object.defineProperty(this, "settlement", {
170
+ enumerable: true,
171
+ configurable: true,
172
+ writable: true,
173
+ value: void 0
174
+ });
175
+ Object.defineProperty(this, "status", {
176
+ enumerable: true,
177
+ configurable: true,
178
+ writable: true,
179
+ value: void 0
180
+ });
181
+ Object.defineProperty(this, "content", {
182
+ enumerable: true,
183
+ configurable: true,
184
+ writable: true,
185
+ value: void 0
186
+ });
187
+ Object.defineProperty(this, "validation", {
188
+ enumerable: true,
189
+ configurable: true,
190
+ writable: true,
191
+ value: void 0
192
+ });
193
+ Object.defineProperty(this, "date", {
194
+ enumerable: true,
195
+ configurable: true,
196
+ writable: true,
197
+ value: void 0
198
+ });
199
+ this.parent = parent;
200
+ this.id = id;
201
+ this.principal = principal;
202
+ this.contractor = contractor;
203
+ this.description = description;
204
+ this.settlement = settlement;
205
+ this.status = 'PROPOSED';
206
+ this.content = [];
207
+ this.validation = validation;
208
+ this.date = date;
209
+ }
210
+ }
211
+ export class Loan {
212
+ constructor(parent, id, lender, borrower, terms, date = new Date()) {
213
+ Object.defineProperty(this, "parent", {
214
+ enumerable: true,
215
+ configurable: true,
216
+ writable: true,
217
+ value: void 0
218
+ });
219
+ Object.defineProperty(this, "id", {
220
+ enumerable: true,
221
+ configurable: true,
222
+ writable: true,
223
+ value: void 0
224
+ });
225
+ Object.defineProperty(this, "lender", {
226
+ enumerable: true,
227
+ configurable: true,
228
+ writable: true,
229
+ value: void 0
230
+ });
231
+ Object.defineProperty(this, "borrower", {
232
+ enumerable: true,
233
+ configurable: true,
234
+ writable: true,
235
+ value: void 0
236
+ });
237
+ Object.defineProperty(this, "terms", {
238
+ enumerable: true,
239
+ configurable: true,
240
+ writable: true,
241
+ value: void 0
242
+ });
243
+ Object.defineProperty(this, "status", {
244
+ enumerable: true,
245
+ configurable: true,
246
+ writable: true,
247
+ value: void 0
248
+ });
249
+ Object.defineProperty(this, "date", {
250
+ enumerable: true,
251
+ configurable: true,
252
+ writable: true,
253
+ value: void 0
254
+ });
255
+ this.parent = parent;
256
+ this.id = id;
257
+ this.lender = lender;
258
+ this.borrower = borrower;
259
+ this.terms = terms;
260
+ this.status = 'PROPOSED';
261
+ this.date = date;
262
+ }
263
+ }
@@ -0,0 +1,14 @@
1
+ import * as EnvironmentAPI from "./environment.js";
2
+ import * as OSAPI from "./os.js";
3
+ import * as VersioningAPI from "./versioning.js";
4
+ export declare namespace Termite {
5
+ function setRoute(route: string): void;
6
+ function getIP(): string;
7
+ function getPort(): number;
8
+ function getRoute(): string;
9
+ function getURL(): string;
10
+ function ping(): Promise<number>;
11
+ export import Environment = EnvironmentAPI;
12
+ export import OS = OSAPI;
13
+ export import Versioning = VersioningAPI;
14
+ }