@agentshouse/mdruntime-adapter 0.1.0-ce5ef9afd7e9a → 0.1.0-ce61dee70c171

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 (80) hide show
  1. package/README.md +3 -3
  2. package/dist/actions.d.ts +7 -74
  3. package/dist/actions.d.ts.map +1 -1
  4. package/dist/actions.js +29 -322
  5. package/dist/adapter.d.ts +0 -1
  6. package/dist/adapter.d.ts.map +1 -1
  7. package/dist/adapter.js +209 -404
  8. package/dist/authored-path.d.ts +66 -0
  9. package/dist/authored-path.d.ts.map +1 -0
  10. package/dist/authored-path.js +166 -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 +44 -19
  16. package/dist/discovery.d.ts.map +1 -1
  17. package/dist/discovery.js +239 -72
  18. package/dist/history.d.ts +6 -0
  19. package/dist/history.d.ts.map +1 -0
  20. package/dist/history.js +85 -0
  21. package/dist/index.d.ts +10 -5
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +9 -3
  24. package/dist/map.d.ts +0 -1
  25. package/dist/model.d.ts +6 -6
  26. package/dist/model.d.ts.map +1 -1
  27. package/dist/model.js +31 -48
  28. package/dist/read.d.ts +23 -68
  29. package/dist/read.d.ts.map +1 -1
  30. package/dist/read.js +112 -366
  31. package/dist/refusal.d.ts +6 -5
  32. package/dist/refusal.d.ts.map +1 -1
  33. package/dist/refusal.js +27 -11
  34. package/dist/room-query.d.ts +4 -0
  35. package/dist/room-query.d.ts.map +1 -0
  36. package/dist/room-query.js +58 -0
  37. package/dist/search.d.ts +4 -0
  38. package/dist/search.d.ts.map +1 -0
  39. package/dist/search.js +47 -0
  40. package/dist/session-content/check.d.ts +17 -0
  41. package/dist/session-content/index.d.ts +6 -0
  42. package/dist/session-content/parts.d.ts +30 -0
  43. package/dist/session-content/state.d.ts +59 -0
  44. package/dist/session-content/turn.d.ts +137 -0
  45. package/dist/site.d.ts +0 -1
  46. package/dist/site.d.ts.map +1 -1
  47. package/dist/site.js +115 -191
  48. package/dist/space-schema.d.ts +6 -0
  49. package/dist/space-schema.d.ts.map +1 -0
  50. package/dist/space-schema.js +11 -0
  51. package/dist/stream.d.ts +15 -16
  52. package/dist/stream.d.ts.map +1 -1
  53. package/dist/stream.js +241 -431
  54. package/dist/transport.d.ts +85 -47
  55. package/dist/transport.d.ts.map +1 -1
  56. package/dist/transport.js +90 -12
  57. package/dist/uncertain.d.ts +5 -0
  58. package/dist/uncertain.d.ts.map +1 -0
  59. package/dist/uncertain.js +11 -0
  60. package/dist/upload.d.ts +7 -2
  61. package/dist/upload.d.ts.map +1 -1
  62. package/dist/upload.js +73 -19
  63. package/dist/version.d.ts +0 -1
  64. package/dist/write.d.ts +6 -3
  65. package/dist/write.d.ts.map +1 -1
  66. package/dist/write.js +47 -67
  67. package/package.json +9 -4
  68. package/AGENTS.md +0 -312
  69. package/dist/gather.d.ts +0 -4
  70. package/dist/gather.d.ts.map +0 -1
  71. package/dist/gather.js +0 -35
  72. package/dist/part.d.ts +0 -13
  73. package/dist/part.d.ts.map +0 -1
  74. package/dist/part.js +0 -80
  75. package/dist/referrer.d.ts +0 -9
  76. package/dist/referrer.d.ts.map +0 -1
  77. package/dist/referrer.js +0 -41
  78. package/dist/room-types.d.ts +0 -6
  79. package/dist/room-types.d.ts.map +0 -1
  80. package/dist/room-types.js +0 -66
package/dist/part.d.ts DELETED
@@ -1,13 +0,0 @@
1
- import type { ScopedRefusal } from '@agentshouse/mdruntime';
2
- export declare const PART_ATTEMPTS = 3;
3
- export declare const PART_UNVERIFIED = "part_unverified";
4
- export type HousePart = {
5
- part: string;
6
- bytes: number;
7
- sha256: string;
8
- };
9
- export declare function parsePart(value: unknown): HousePart | null;
10
- export declare function checkedPayload(body: unknown, listed: HousePart): Promise<Uint8Array<ArrayBuffer> | null>;
11
- export declare function gunzipped(payload: Uint8Array<ArrayBuffer>): Promise<string | null>;
12
- export declare function unverifiedPart(locator: string): ScopedRefusal;
13
- //# sourceMappingURL=part.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"part.d.ts","sourceRoot":"","sources":["../src/part.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAU5D,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B,eAAO,MAAM,eAAe,oBAAoB,CAAC;AAEjD,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAO1D;AAoBD,wBAAsB,cAAc,CAClC,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,SAAS,GAChB,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,CAiBzC;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAOxF;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAS7D"}
package/dist/part.js DELETED
@@ -1,80 +0,0 @@
1
- const PART_MAGIC = 0x48505431;
2
- const PART_HEAD_BYTES = 8;
3
- const PART_DIGEST_BYTES = 32;
4
- const PART_SHA256 = /^[0-9a-f]{64}$/u;
5
- export const PART_ATTEMPTS = 3;
6
- export const PART_UNVERIFIED = 'part_unverified';
7
- export function parsePart(value) {
8
- if (typeof value !== 'object' || value === null)
9
- return null;
10
- const { part, bytes, sha256 } = value;
11
- if (typeof part !== 'string' || part.length === 0)
12
- return null;
13
- if (typeof bytes !== 'number' || !Number.isSafeInteger(bytes) || bytes <= 0)
14
- return null;
15
- if (typeof sha256 !== 'string' || !PART_SHA256.test(sha256))
16
- return null;
17
- return { part, bytes, sha256 };
18
- }
19
- function decoded(text) {
20
- let binary;
21
- try {
22
- binary = atob(text);
23
- }
24
- catch {
25
- return null;
26
- }
27
- const bytes = new Uint8Array(binary.length);
28
- for (let at = 0; at < binary.length; at += 1)
29
- bytes[at] = binary.charCodeAt(at);
30
- return bytes;
31
- }
32
- function hex(bytes) {
33
- let text = '';
34
- for (const byte of bytes)
35
- text += byte.toString(16).padStart(2, '0');
36
- return text;
37
- }
38
- export async function checkedPayload(body, listed) {
39
- if (typeof body !== 'object' || body === null)
40
- return null;
41
- const { part } = body;
42
- if (typeof part !== 'string')
43
- return null;
44
- const frame = decoded(part);
45
- if (frame === null || frame.length !== listed.bytes)
46
- return null;
47
- if (frame.length < PART_HEAD_BYTES + PART_DIGEST_BYTES)
48
- return null;
49
- const view = new DataView(frame.buffer, frame.byteOffset, frame.byteLength);
50
- if (view.getUint32(0) !== PART_MAGIC)
51
- return null;
52
- const length = view.getUint32(4);
53
- if (PART_HEAD_BYTES + length + PART_DIGEST_BYTES !== frame.length)
54
- return null;
55
- const payload = frame.subarray(PART_HEAD_BYTES, PART_HEAD_BYTES + length);
56
- const digest = hex(new Uint8Array(await crypto.subtle.digest('SHA-256', payload)));
57
- if (digest !== listed.sha256 || hex(frame.subarray(PART_HEAD_BYTES + length)) !== digest) {
58
- return null;
59
- }
60
- return payload;
61
- }
62
- export async function gunzipped(payload) {
63
- try {
64
- const stream = new Blob([payload]).stream().pipeThrough(new DecompressionStream('gzip'));
65
- return await new Response(stream).text();
66
- }
67
- catch {
68
- return null;
69
- }
70
- }
71
- export function unverifiedPart(locator) {
72
- return {
73
- kind: 'scoped-refusal',
74
- locator,
75
- scope: 'undisclosed',
76
- code: PART_UNVERIFIED,
77
- fields: {},
78
- retryable: true,
79
- };
80
- }
@@ -1,9 +0,0 @@
1
- import type { ReferrerScope } from '@agentshouse/mdruntime';
2
- import type { TrackedAuthority } from './discovery.js';
3
- export type HouseReferrer = {
4
- locator: string;
5
- referrer: Readonly<Record<string, string>>;
6
- };
7
- export declare function houseReferrer(referrer: unknown, tracked: ReadonlyMap<string, TrackedAuthority>): HouseReferrer | null;
8
- export declare function houseReferrerScope(referrer: unknown, tracked: ReadonlyMap<string, TrackedAuthority>): ReferrerScope | null;
9
- //# sourceMappingURL=referrer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"referrer.d.ts","sourceRoot":"","sources":["../src/referrer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,MAAM,MAAM,aAAa,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAAE,CAAC;AAgB5F,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAC7C,aAAa,GAAG,IAAI,CAoBtB;AAED,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAC7C,aAAa,GAAG,IAAI,CAOtB"}
package/dist/referrer.js DELETED
@@ -1,41 +0,0 @@
1
- function fields(value) {
2
- return typeof value === 'object' && value !== null && !Array.isArray(value)
3
- ? value
4
- : null;
5
- }
6
- function named(held, ...keys) {
7
- const present = Object.keys(held);
8
- return (present.length === keys.length &&
9
- keys.every((key) => typeof held[key] === 'string' && held[key] !== ''));
10
- }
11
- export function houseReferrer(referrer, tracked) {
12
- const held = fields(referrer);
13
- if (held === null)
14
- return null;
15
- if (named(held, 'room', 'path')) {
16
- const entry = tracked.get(held.room);
17
- if (entry === undefined)
18
- return null;
19
- return {
20
- locator: entry.locator,
21
- referrer: { room_ref: entry.authority, path: held.path },
22
- };
23
- }
24
- if (named(held, 'room_ref', 'record')) {
25
- const roomRef = held.room_ref;
26
- const entry = [...tracked.values()].find((candidate) => candidate.authority === roomRef);
27
- return {
28
- locator: entry?.locator ?? roomRef,
29
- referrer: { room_ref: roomRef, record: held.record },
30
- };
31
- }
32
- return null;
33
- }
34
- export function houseReferrerScope(referrer, tracked) {
35
- const held = fields(referrer);
36
- if (held !== null && named(held, 'room', 'path')) {
37
- return { locator: held.room, path: held.path };
38
- }
39
- const found = houseReferrer(referrer, tracked);
40
- return found === null ? null : { locator: found.locator };
41
- }
@@ -1,6 +0,0 @@
1
- export declare const INBOX_CHANNEL_KINDS: readonly ['telegram-bot'];
2
- export type InboxChannelKind = (typeof INBOX_CHANNEL_KINDS)[number];
3
- export declare const INBOX_CHAT_TYPE = "inbox-chat";
4
- export declare const INBOX_MESSAGE_TYPE = "inbox-message";
5
- export declare const HOUSE_ROOM_TYPES: string;
6
- //# sourceMappingURL=room-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"room-types.d.ts","sourceRoot":"","sources":["../src/room-types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,YAAI,cAAc,CAAU,CAAC;AAE7D,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpE,eAAO,MAAM,eAAe,eAAe,CAAC;AAE5C,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAalD,eAAO,MAAM,gBAAgB,QAsDjB,CAAC"}
@@ -1,66 +0,0 @@
1
- export const INBOX_CHANNEL_KINDS = ['telegram-bot'];
2
- export const INBOX_CHAT_TYPE = 'inbox-chat';
3
- export const INBOX_MESSAGE_TYPE = 'inbox-message';
4
- const IDENTITY = "{ type: string, pattern: '^\\S+$' }";
5
- const AGENT = [' agent: { type: string, format: uuid }', ' name: { type: string }'];
6
- const ASSIGNEE = [
7
- ' type: object',
8
- ' properties:',
9
- ' user: { type: string, format: uuid }',
10
- ...AGENT,
11
- ];
12
- export const HOUSE_ROOM_TYPES = [
13
- `${INBOX_CHAT_TYPE}:`,
14
- ' properties:',
15
- ' inbox: { type: string, format: uuid }',
16
- ` channel: { enum: [${INBOX_CHANNEL_KINDS.join(', ')}] }`,
17
- ` chat: ${IDENTITY}`,
18
- ' customer:',
19
- ' type: object',
20
- ' properties:',
21
- ' name: { type: string }',
22
- ` username: ${IDENTITY}`,
23
- ` phone: ${IDENTITY}`,
24
- ' assignee:',
25
- ...ASSIGNEE,
26
- ' return_to:',
27
- ' type: object',
28
- ' properties:',
29
- ...AGENT,
30
- ' conversation: { type: string, format: uuid }',
31
- ' required: [inbox, channel, chat, customer]',
32
- `${INBOX_MESSAGE_TYPE}:`,
33
- ' properties:',
34
- ' direction: { enum: [in, out] }',
35
- ' sender:',
36
- ' type: object',
37
- ' properties:',
38
- ' name: { type: string }',
39
- ` username: ${IDENTITY}`,
40
- ' sent_at: { type: string, format: date-time }',
41
- ` channel_message: ${IDENTITY}`,
42
- ' state: { enum: [sending, sent, failed] }',
43
- ' reason: { type: string }',
44
- ' reactions:',
45
- ' type: array',
46
- ' items:',
47
- ' type: object',
48
- ' properties:',
49
- ' reaction: { type: string, minLength: 1 }',
50
- ' sender:',
51
- ' type: object',
52
- ' properties:',
53
- ` id: ${IDENTITY}`,
54
- ' name: { type: string }',
55
- ` username: ${IDENTITY}`,
56
- ' count: { type: integer, minimum: 1 }',
57
- ' required: [reaction]',
58
- ` post: ${IDENTITY}`,
59
- ' assignee:',
60
- ...ASSIGNEE,
61
- ' sent_outside: { const: true }',
62
- ' required: [direction]',
63
- ' if: { properties: { direction: { const: in } } }',
64
- ' then: { required: [sent_at] }',
65
- '',
66
- ].join('\n');