@agentshouse/mdruntime-adapter 0.1.0-cdc1a38081f09 → 0.1.0-cdc4dd63f526f

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 (77) hide show
  1. package/README.md +3 -3
  2. package/dist/actions.d.ts +6 -60
  3. package/dist/actions.d.ts.map +1 -1
  4. package/dist/actions.js +26 -295
  5. package/dist/adapter.d.ts +0 -1
  6. package/dist/adapter.d.ts.map +1 -1
  7. package/dist/adapter.js +221 -399
  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 +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 +9 -4
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +8 -2
  24. package/dist/map.d.ts +0 -1
  25. package/dist/model.d.ts +6 -10
  26. package/dist/model.d.ts.map +1 -1
  27. package/dist/model.js +30 -54
  28. package/dist/read.d.ts +17 -70
  29. package/dist/read.d.ts.map +1 -1
  30. package/dist/read.js +70 -351
  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 +36 -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 +97 -173
  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 +242 -426
  54. package/dist/transport.d.ts +84 -43
  55. package/dist/transport.d.ts.map +1 -1
  56. package/dist/transport.js +89 -11
  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 +3 -2
  61. package/dist/upload.d.ts.map +1 -1
  62. package/dist/upload.js +10 -8
  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 +39 -48
  67. package/package.json +8 -3
  68. package/AGENTS.md +0 -317
  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 -15
  73. package/dist/part.d.ts.map +0 -1
  74. package/dist/part.js +0 -82
  75. package/dist/room-types.d.ts +0 -6
  76. package/dist/room-types.d.ts.map +0 -1
  77. package/dist/room-types.js +0 -83
package/dist/part.js DELETED
@@ -1,82 +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 function partArrival(listed, arriving) {
39
- if (arriving === undefined)
40
- return undefined;
41
- return (answered) => arriving(Math.min(listed.bytes, Math.floor((answered * 3) / 4)));
42
- }
43
- export function partFrame(body) {
44
- if (typeof body !== 'object' || body === null)
45
- return null;
46
- const { part } = body;
47
- return typeof part === 'string' ? decoded(part) : null;
48
- }
49
- export async function checkedPayload(frame, listed) {
50
- if (frame.length !== listed.bytes)
51
- return null;
52
- if (frame.length < PART_HEAD_BYTES + PART_DIGEST_BYTES)
53
- return null;
54
- const view = new DataView(frame.buffer, frame.byteOffset, frame.byteLength);
55
- if (view.getUint32(0) !== PART_MAGIC)
56
- return null;
57
- const length = view.getUint32(4);
58
- if (PART_HEAD_BYTES + length + PART_DIGEST_BYTES !== frame.length)
59
- return null;
60
- const payload = frame.subarray(PART_HEAD_BYTES, PART_HEAD_BYTES + length);
61
- const digest = hex(new Uint8Array(await crypto.subtle.digest('SHA-256', payload)));
62
- if (digest !== listed.sha256 || hex(frame.subarray(PART_HEAD_BYTES + length)) !== digest) {
63
- return null;
64
- }
65
- return payload;
66
- }
67
- export function gunzipped(payload) {
68
- return new Blob([payload])
69
- .stream()
70
- .pipeThrough(new DecompressionStream('gzip'))
71
- .pipeThrough(new TextDecoderStream());
72
- }
73
- export function unverifiedPart(locator) {
74
- return {
75
- kind: 'scoped-refusal',
76
- locator,
77
- scope: 'undisclosed',
78
- code: PART_UNVERIFIED,
79
- fields: {},
80
- retryable: true,
81
- };
82
- }
@@ -1,6 +0,0 @@
1
- export declare const INBOX_CHANNEL_KINDS: readonly ['telegram-bot', 'whatsapp', 'messenger', 'instagram', 'viber', 'tiktok'];
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,YAC9B,cAAc,EACd,UAAU,EACV,WAAW,EACX,WAAW,EACX,OAAO,EACP,QAAQ,CACA,CAAC;AAEX,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,QAgEjB,CAAC"}
@@ -1,83 +0,0 @@
1
- export const INBOX_CHANNEL_KINDS = [
2
- 'telegram-bot',
3
- 'whatsapp',
4
- 'messenger',
5
- 'instagram',
6
- 'viber',
7
- 'tiktok',
8
- ];
9
- export const INBOX_CHAT_TYPE = 'inbox-chat';
10
- export const INBOX_MESSAGE_TYPE = 'inbox-message';
11
- const IDENTITY = "{ type: string, pattern: '^\\S+$' }";
12
- const AGENT = [' agent: { type: string, format: uuid }', ' name: { type: string }'];
13
- const ASSIGNEE = [
14
- ' type: object',
15
- ' properties:',
16
- ' user: { type: string, format: uuid }',
17
- ...AGENT,
18
- ];
19
- export const HOUSE_ROOM_TYPES = [
20
- `${INBOX_CHAT_TYPE}:`,
21
- ' properties:',
22
- ' inbox: { type: string, format: uuid }',
23
- ` channel: { enum: [${INBOX_CHANNEL_KINDS.join(', ')}] }`,
24
- ` chat: ${IDENTITY}`,
25
- ' customer:',
26
- ' type: object',
27
- ' properties:',
28
- ' name: { type: string }',
29
- ` username: ${IDENTITY}`,
30
- ` phone: ${IDENTITY}`,
31
- ' assignee:',
32
- ...ASSIGNEE,
33
- ' return_to:',
34
- ' type: object',
35
- ' properties:',
36
- ...AGENT,
37
- ' conversation: { type: string, format: uuid }',
38
- ' required: [inbox, channel, chat, customer]',
39
- `${INBOX_MESSAGE_TYPE}:`,
40
- ' properties:',
41
- ' direction: { enum: [in, out] }',
42
- ' sender:',
43
- ' type: object',
44
- ' properties:',
45
- ' name: { type: string }',
46
- ` username: ${IDENTITY}`,
47
- ' sent_at: { type: string, format: date-time }',
48
- ` channel_message: ${IDENTITY}`,
49
- ' state: { enum: [sending, sent, failed] }',
50
- ' reason: { type: string }',
51
- ' reactions:',
52
- ' type: array',
53
- ' items:',
54
- ' type: object',
55
- ' properties:',
56
- ' reaction: { type: string, minLength: 1 }',
57
- ' sender:',
58
- ' type: object',
59
- ' properties:',
60
- ` id: ${IDENTITY}`,
61
- ' name: { type: string }',
62
- ` username: ${IDENTITY}`,
63
- ' count: { type: integer, minimum: 1 }',
64
- ' required: [reaction]',
65
- ` post: ${IDENTITY}`,
66
- ' assignee:',
67
- ...ASSIGNEE,
68
- ' sent_outside: { const: true }',
69
- ' template:',
70
- ' type: object',
71
- ' properties:',
72
- ' name: { type: string, minLength: 1 }',
73
- ' language: { type: string, minLength: 1 }',
74
- ' required: [name, language]',
75
- ' values:',
76
- ' type: object',
77
- ' additionalProperties: { type: string }',
78
- ' withheld: { const: true }',
79
- ' required: [direction]',
80
- ' if: { properties: { direction: { const: in } } }',
81
- ' then: { required: [sent_at] }',
82
- '',
83
- ].join('\n');