@agentshouse/mdruntime-adapter 0.1.0-c19cd0fd6cd22 → 0.1.0-c1a4aa648b216

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 (83) hide show
  1. package/README.md +2 -2
  2. package/dist/actions.d.ts +2 -1
  3. package/dist/actions.d.ts.map +1 -1
  4. package/dist/actions.js +20 -7
  5. package/dist/adapter.d.ts +0 -1
  6. package/dist/adapter.d.ts.map +1 -1
  7. package/dist/adapter.js +118 -121
  8. package/dist/authored-path.d.ts +9 -0
  9. package/dist/authored-path.d.ts.map +1 -0
  10. package/dist/authored-path.js +34 -0
  11. package/dist/chunks.d.ts +36 -0
  12. package/dist/chunks.d.ts.map +1 -0
  13. package/dist/chunks.js +281 -0
  14. package/dist/digest.d.ts +0 -1
  15. package/dist/discovery.d.ts +23 -7
  16. package/dist/discovery.d.ts.map +1 -1
  17. package/dist/discovery.js +163 -16
  18. package/dist/history.d.ts +1 -7
  19. package/dist/history.d.ts.map +1 -1
  20. package/dist/history.js +22 -29
  21. package/dist/index.d.ts +5 -6
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +4 -4
  24. package/dist/map.d.ts +0 -1
  25. package/dist/model.d.ts +6 -9
  26. package/dist/model.d.ts.map +1 -1
  27. package/dist/model.js +28 -26
  28. package/dist/read.d.ts +15 -24
  29. package/dist/read.d.ts.map +1 -1
  30. package/dist/read.js +66 -190
  31. package/dist/refusal.d.ts +3 -2
  32. package/dist/refusal.d.ts.map +1 -1
  33. package/dist/refusal.js +17 -7
  34. package/dist/search.d.ts +0 -1
  35. package/dist/search.d.ts.map +1 -1
  36. package/dist/search.js +5 -5
  37. package/dist/session-content/bounds.d.ts +7 -0
  38. package/dist/session-content/check.d.ts +18 -0
  39. package/dist/session-content/index.d.ts +7 -0
  40. package/dist/session-content/parts.d.ts +103 -0
  41. package/dist/session-content/state.d.ts +61 -0
  42. package/dist/session-content/turn.d.ts +328 -0
  43. package/dist/site.d.ts +0 -1
  44. package/dist/site.d.ts.map +1 -1
  45. package/dist/site.js +44 -58
  46. package/dist/space-schema.d.ts +6 -0
  47. package/dist/space-schema.d.ts.map +1 -0
  48. package/dist/space-schema.js +11 -0
  49. package/dist/stream.d.ts +4 -4
  50. package/dist/stream.d.ts.map +1 -1
  51. package/dist/stream.js +145 -72
  52. package/dist/transport.d.ts +46 -27
  53. package/dist/transport.d.ts.map +1 -1
  54. package/dist/transport.js +15 -14
  55. package/dist/uncertain.d.ts +5 -0
  56. package/dist/uncertain.d.ts.map +1 -0
  57. package/dist/uncertain.js +11 -0
  58. package/dist/upload.d.ts +3 -2
  59. package/dist/upload.d.ts.map +1 -1
  60. package/dist/upload.js +8 -6
  61. package/dist/version.d.ts +0 -1
  62. package/dist/write.d.ts +0 -2
  63. package/dist/write.d.ts.map +1 -1
  64. package/dist/write.js +22 -29
  65. package/package.json +3 -2
  66. package/dist/app-reference.d.ts +0 -2
  67. package/dist/app-reference.d.ts.map +0 -1
  68. package/dist/app-reference.js +0 -2
  69. package/dist/crockford.d.ts +0 -4
  70. package/dist/crockford.d.ts.map +0 -1
  71. package/dist/crockford.js +0 -3
  72. package/dist/house-model.d.ts +0 -892
  73. package/dist/house-model.d.ts.map +0 -1
  74. package/dist/house-model.js +0 -482
  75. package/dist/part.d.ts +0 -14
  76. package/dist/part.d.ts.map +0 -1
  77. package/dist/part.js +0 -90
  78. package/dist/room-stream.d.ts +0 -20
  79. package/dist/room-stream.d.ts.map +0 -1
  80. package/dist/room-stream.js +0 -78
  81. package/dist/room-types.d.ts +0 -7
  82. package/dist/room-types.d.ts.map +0 -1
  83. package/dist/room-types.js +0 -125
package/dist/transport.js CHANGED
@@ -1,25 +1,25 @@
1
1
  export const HOUSE_RUNTIME_READS = {
2
2
  acts: [
3
- 'account/push',
4
- 'agents/read',
3
+ 'account/push/set',
5
4
  'apps/features/set',
6
5
  'apps/source/download',
7
- 'apps/source/top',
8
- 'batch',
9
- 'batch-upload',
10
- 'bootstrap',
11
- 'conversations/history',
12
- 'discover',
6
+ 'apps/source/top/read',
7
+ 'conversations/history/list',
13
8
  'files/attach',
9
+ 'files/batch',
10
+ 'files/batch-upload',
14
11
  'files/finish',
15
- 'files/get',
16
- 'revisions',
17
- 'search',
12
+ 'files/read',
13
+ 'files/revisions/list',
14
+ 'room-chunks/list',
15
+ 'rooms/discover',
16
+ 'rooms/search',
18
17
  'sites/screenshot/read',
19
18
  ],
20
19
  frames: [
20
+ 'agent',
21
21
  'app-message',
22
- 'app-release',
22
+ 'app-rooms',
23
23
  'authority_changed',
24
24
  'carried',
25
25
  'caught_up',
@@ -38,10 +38,11 @@ export const HOUSE_RUNTIME_READS = {
38
38
  'part',
39
39
  'process',
40
40
  'received',
41
+ 'report',
41
42
  'signal',
42
43
  'site',
43
44
  'starting',
44
- 'subagents',
45
+ 'state',
45
46
  'tab-icon',
46
47
  'turn',
47
48
  ],
@@ -52,6 +53,6 @@ export function houseDoorRoute(act) {
52
53
  export function houseSiteRoute(act) {
53
54
  return `/_house/door/${act}`;
54
55
  }
55
- export const SITE_SUBMISSION = 'site/submission';
56
+ export const SITES_SUBMISSIONS_CREATE = 'sites/submissions/create';
56
57
  export const SITE_DOOR_SUBMIT = '/_house/door/submit';
57
58
  export const SITE_FILES = '/_house/files/';
@@ -0,0 +1,5 @@
1
+ import { type ProviderRefusal, type TransportUncertainty } from '@agentshouse/mdruntime';
2
+ export declare const UNANSWERED: TransportUncertainty;
3
+ export declare function failedOn(failure: unknown): TransportUncertainty;
4
+ export declare function unusable(): TransportUncertainty;
5
+ export declare function refusedFor(refusal: ProviderRefusal): TransportUncertainty;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uncertain.d.ts","sourceRoot":"","sources":["../src/uncertain.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAC1B,MAAM,wBAAwB,CAAC;AAEhC,eAAO,MAAM,UAAU,EAAE,oBAAwD,CAAC;AAElF,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,oBAAoB,CAE/D;AAED,wBAAgB,QAAQ,IAAI,oBAAoB,CAE/C;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,oBAAoB,CAEzE"}
@@ -0,0 +1,11 @@
1
+ import { refusalError, } from '@agentshouse/mdruntime';
2
+ export const UNANSWERED = { kind: 'transport-uncertainty' };
3
+ export function failedOn(failure) {
4
+ return { kind: 'transport-uncertainty', failure };
5
+ }
6
+ export function unusable() {
7
+ return failedOn(new Error());
8
+ }
9
+ export function refusedFor(refusal) {
10
+ return failedOn(refusalError(refusal));
11
+ }
package/dist/upload.d.ts CHANGED
@@ -8,5 +8,6 @@ export type HouseUpload = {
8
8
  }[];
9
9
  };
10
10
  export declare function houseUpload(value: unknown): HouseUpload | null;
11
- export declare function finishedUpload(transport: HouseTransport, first: HouseUpload, blob: Blob): Promise<HouseDoorAnswer | null>;
12
- //# sourceMappingURL=upload.d.ts.map
11
+ export declare function finishedUpload(transport: HouseTransport, first: HouseUpload, blob: Blob): Promise<HouseDoorAnswer | {
12
+ readonly unfinished: number;
13
+ }>;
@@ -1 +1 @@
1
- {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE3F,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC5E,CAAC;AAeF,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAQ9D;AA8BD,wBAAsB,cAAc,CAClC,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAejC"}
1
+ {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE3F,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC5E,CAAC;AAeF,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAQ9D;AA+BD,wBAAsB,cAAc,CAClC,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,eAAe,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAgB5D"}
package/dist/upload.js CHANGED
@@ -37,17 +37,19 @@ async function sent(transport, upload, blob, digests) {
37
37
  for (const { part: number, url } of upload.parts) {
38
38
  const start = (number - 1) * upload.partBytes;
39
39
  const slice = blob.slice(start, start + upload.partBytes);
40
- if ((await transport.put(url, slice, checksum(digests[number - 1]))) !== 200)
41
- return false;
40
+ const stored = await transport.put(url, slice, checksum(digests[number - 1]));
41
+ if (stored !== 200)
42
+ return stored;
42
43
  }
43
- return true;
44
+ return 200;
44
45
  }
45
46
  export async function finishedUpload(transport, first, blob) {
46
47
  const digests = await partSha256(blob, first.partBytes);
47
48
  let upload = first;
48
49
  for (let round = 0; round < FINISHING_ROUNDS; round += 1) {
49
- if (!(await sent(transport, upload, blob, digests)))
50
- return null;
50
+ const stored = await sent(transport, upload, blob, digests);
51
+ if (stored !== 200)
52
+ return { unfinished: stored };
51
53
  const answer = await transport.door(houseDoorRoute('files/finish'), {
52
54
  upload: upload.id,
53
55
  part_sha256: digests,
@@ -59,5 +61,5 @@ export async function finishedUpload(transport, first, blob) {
59
61
  return answer;
60
62
  upload = missing;
61
63
  }
62
- return null;
64
+ return { unfinished: 200 };
63
65
  }
package/dist/version.d.ts CHANGED
@@ -14,4 +14,3 @@ export declare function presented(authority: string, at: LogPosition): Presented
14
14
  export declare const DECIMAL: RegExp;
15
15
  export declare function reachedVersion(roomVersion: string, target: string, currentEpoch: string | undefined): boolean;
16
16
  export declare function followsVersion(roomVersion: string, next: string): boolean;
17
- //# sourceMappingURL=version.d.ts.map
package/dist/write.d.ts CHANGED
@@ -56,7 +56,5 @@ export declare function revisionBody(input: {
56
56
  pageToken?: string;
57
57
  }): Record<string, unknown>;
58
58
  export declare function historyOutcome(status: number, body: unknown, locator: string, request: {
59
- path: string;
60
59
  revision?: string;
61
60
  }): HistoryResult;
62
- //# sourceMappingURL=write.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../src/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,WAAW,EAEhB,KAAK,aAAa,EAElB,KAAK,cAAc,EAEpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAOlD,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE/D,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAA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E,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAM1B;AA6BD,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7B,aAAa,CA8Cf"}
package/dist/write.js CHANGED
@@ -2,8 +2,9 @@ import { departure, partsChanges, ROW_WEIGHT, } from '@agentshouse/mdruntime';
2
2
  import { answered, answering, binaryFileOf, headChange, revised } from './read.js';
3
3
  import { sha256Hex, textBytes } from './digest.js';
4
4
  import { nativePath, roomLocalPath } from './map.js';
5
- import { classifyDoor, doorRefusal, scopedRefusal } from './refusal.js';
5
+ import { answeredFailure, classifyDoor, doorRefusal, resetOf, scopedRefusal } from './refusal.js';
6
6
  import { readPosition, roomVersion } from './version.js';
7
+ import { unusable } from './uncertain.js';
7
8
  function priorField(batch, path, name) {
8
9
  return batch.preconditions.find((precondition) => precondition.kind === 'field' && precondition.path === path && precondition.name === name);
9
10
  }
@@ -28,7 +29,7 @@ function created(change, path) {
28
29
  const { type, ...fields } = change.fields;
29
30
  if (typeof type !== 'string' || type.length === 0)
30
31
  return null;
31
- return { op: 'create_typed', path, type, fields, sections: change.sections };
32
+ return { op: 'create_typed', path, type, fields };
32
33
  }
33
34
  function operationOf(batch, change, handle) {
34
35
  const path = nativePath(change.path, handle);
@@ -230,7 +231,7 @@ function* acceptedOf(at, contents) {
230
231
  answer.changes.set(entry.path, entry.head);
231
232
  }
232
233
  const unbinaried = answer.binaryFiles.size === 0;
233
- const { binaryFiles, ...room } = yield* answered(answer);
234
+ const { binaryFiles, facts: _facts, ...room } = yield* answered(answer);
234
235
  return { roomVersion: roomVersion(at), ...room, ...(unbinaried ? {} : { binaryFiles }) };
235
236
  }
236
237
  function* movedOutcome(held, move) {
@@ -244,12 +245,12 @@ function* movedOutcome(held, move) {
244
245
  const left = at(move.source.authority);
245
246
  const arrived = at(move.destination.authority);
246
247
  if (left === null || arrived === null)
247
- return { kind: 'transport-uncertainty' };
248
+ return unusable();
248
249
  const under = (handle) => (path) => path.startsWith(`/rooms/${handle}/`);
249
250
  const leaving = yield* material(held.contents, move.source.handle, under(move.source.handle));
250
251
  const arriving = yield* material(held.contents, move.destination.handle, under(move.destination.handle));
251
252
  if (leaving === null || arriving === null)
252
- return { kind: 'transport-uncertainty' };
253
+ return unusable();
253
254
  return {
254
255
  kind: 'accepted',
255
256
  ...(yield* acceptedOf(left, leaving)),
@@ -261,11 +262,6 @@ export function* mutationOutcome(status, body, locator, handle, move) {
261
262
  if (refusal !== null && refusal.code === 'service_mode_write_halted') {
262
263
  return { kind: 'write-halted' };
263
264
  }
264
- if (refusal !== null && refusal.code === 'expired') {
265
- return refusal.fields.restored === true
266
- ? { kind: 'expired', restored: true }
267
- : { kind: 'expired' };
268
- }
269
265
  if (refusal !== null && refusal.code === 'edit_conflict') {
270
266
  const { current, ...fields } = refusal.fields;
271
267
  const held = (yield* material(current, handle)) ?? [];
@@ -281,10 +277,8 @@ export function* mutationOutcome(status, body, locator, handle, move) {
281
277
  return scopedRefusal(locator, 'undisclosed', refusal);
282
278
  }
283
279
  const classified = classifyDoor(status, body, locator);
284
- const reset = refusal?.fields.retry_at;
285
- if (refusal?.retryable === true &&
286
- typeof reset === 'string' &&
287
- classified?.kind === 'transport-uncertainty') {
280
+ const reset = resetOf(refusal);
281
+ if (refusal !== null && reset !== undefined && classified?.kind === 'transport-uncertainty') {
288
282
  return {
289
283
  kind: 'retryable-refusal',
290
284
  code: refusal.code,
@@ -307,18 +301,19 @@ export function* mutationOutcome(status, body, locator, handle, move) {
307
301
  retryable: refusal.retryable,
308
302
  };
309
303
  }
310
- if (status !== 200 || typeof body !== 'object' || body === null) {
311
- return { kind: 'transport-uncertainty' };
312
- }
304
+ if (status !== 200)
305
+ return answeredFailure(status, body);
306
+ if (typeof body !== 'object' || body === null)
307
+ return unusable();
313
308
  const held = body;
314
309
  if (move !== undefined)
315
310
  return yield* movedOutcome(held, move);
316
311
  const at = readPosition(held);
317
312
  if (at === null)
318
- return { kind: 'transport-uncertainty' };
313
+ return unusable();
319
314
  const contents = yield* material(held.contents, handle);
320
315
  if (contents === null)
321
- return { kind: 'transport-uncertainty' };
316
+ return unusable();
322
317
  return { kind: 'accepted', ...(yield* acceptedOf(at, contents)) };
323
318
  }
324
319
  export function rejectedMapping(mapping) {
@@ -367,25 +362,23 @@ export function historyOutcome(status, body, locator, request) {
367
362
  if (classified !== null)
368
363
  return classified;
369
364
  if (status !== 200 || typeof body !== 'object' || body === null) {
370
- return { kind: 'transport-uncertainty' };
365
+ return unusable();
371
366
  }
372
367
  const held = body;
373
368
  if (!Array.isArray(held.revisions))
374
- return { kind: 'transport-uncertainty' };
369
+ return unusable();
375
370
  const entries = [];
376
371
  for (const entry of held.revisions) {
377
372
  if (typeof entry !== 'object' || entry === null)
378
- return { kind: 'transport-uncertainty' };
373
+ return unusable();
379
374
  entries.push(entry);
380
375
  }
381
- if (request.revision !== undefined) {
382
- const named = entries[0];
376
+ const named = entries[0];
377
+ if (request.revision !== undefined && typeof named?.media_type !== 'string') {
383
378
  if (named === undefined)
384
379
  return { kind: 'no-history' };
385
- if (typeof named.media_type === 'string')
386
- return { kind: 'no-history' };
387
380
  if (typeof named.content !== 'string')
388
- return { kind: 'transport-uncertainty' };
381
+ return unusable();
389
382
  return { kind: 'revision', content: named.content };
390
383
  }
391
384
  if (entries.length === 0)
@@ -396,11 +389,11 @@ export function historyOutcome(status, body, locator, request) {
396
389
  if (typeof entry.revision !== 'string' ||
397
390
  author === null ||
398
391
  typeof entry.created_at !== 'string') {
399
- return { kind: 'transport-uncertainty' };
392
+ return unusable();
400
393
  }
401
394
  const binaryFile = binaryFileOf(entry);
402
395
  if (binaryFile === null)
403
- return { kind: 'transport-uncertainty' };
396
+ return unusable();
404
397
  revisions.push({
405
398
  revision: entry.revision,
406
399
  author,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/mdruntime-adapter",
3
- "version": "0.1.0-c19cd0fd6cd22",
3
+ "version": "0.1.0-c1a4aa648b216",
4
4
  "description": "Agents House Adapter for the MD Runtime",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -24,7 +24,8 @@
24
24
  "LICENSE"
25
25
  ],
26
26
  "dependencies": {
27
- "@agentshouse/mdruntime": "0.1.0-cb1f56e16291b"
27
+ "@agentshouse/mdmodel": "0.1.0-c18c3790f7f73",
28
+ "@agentshouse/mdruntime": "0.1.0-cd30853a1b15e"
28
29
  },
29
30
  "repository": {
30
31
  "type": "git",
@@ -1,2 +0,0 @@
1
- export declare const APP_REFERENCE_PATTERN: RegExp;
2
- //# sourceMappingURL=app-reference.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"app-reference.d.ts","sourceRoot":"","sources":["../src/app-reference.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB,QAEjC,CAAC"}
@@ -1,2 +0,0 @@
1
- import { CROCKFORD_CHARACTER } from './crockford.js';
2
- export const APP_REFERENCE_PATTERN = new RegExp(`^a_(${CROCKFORD_CHARACTER}+)\\.(${CROCKFORD_CHARACTER})$`);
@@ -1,4 +0,0 @@
1
- export declare const CROCKFORD_ALPHABET = "0123456789abcdefghjkmnpqrstvwxyz";
2
- export declare const CROCKFORD_CHARACTER = "[0123456789abcdefghjkmnpqrstvwxyz]";
3
- export declare const CROCKFORD_LEADING_CHARACTER: string;
4
- //# sourceMappingURL=crockford.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crockford.d.ts","sourceRoot":"","sources":["../src/crockford.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,qCAAqC,CAAC;AAErE,eAAO,MAAM,mBAAmB,uCAA4B,CAAC;AAE7D,eAAO,MAAM,2BAA2B,QAAqC,CAAC"}
package/dist/crockford.js DELETED
@@ -1,3 +0,0 @@
1
- export const CROCKFORD_ALPHABET = '0123456789abcdefghjkmnpqrstvwxyz';
2
- export const CROCKFORD_CHARACTER = `[${CROCKFORD_ALPHABET}]`;
3
- export const CROCKFORD_LEADING_CHARACTER = `[${CROCKFORD_ALPHABET.slice(1)}]`;