@agentshouse/mdruntime-adapter 0.1.0-c9bc183fae1e1 → 0.1.0-c9c0fc93e45c2

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 +4 -48
  3. package/dist/actions.d.ts.map +1 -1
  4. package/dist/actions.js +26 -231
  5. package/dist/adapter.d.ts +0 -1
  6. package/dist/adapter.d.ts.map +1 -1
  7. package/dist/adapter.js +159 -395
  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 +289 -0
  14. package/dist/digest.d.ts +0 -1
  15. package/dist/discovery.d.ts +19 -9
  16. package/dist/discovery.d.ts.map +1 -1
  17. package/dist/discovery.js +65 -32
  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 +7 -7
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +6 -5
  24. package/dist/map.d.ts +0 -1
  25. package/dist/model.d.ts +5 -9
  26. package/dist/model.d.ts.map +1 -1
  27. package/dist/model.js +28 -34
  28. package/dist/read.d.ts +21 -60
  29. package/dist/read.d.ts.map +1 -1
  30. package/dist/read.js +48 -330
  31. package/dist/refusal.d.ts +3 -5
  32. package/dist/refusal.d.ts.map +1 -1
  33. package/dist/refusal.js +17 -12
  34. package/dist/search.d.ts +4 -0
  35. package/dist/search.d.ts.map +1 -0
  36. package/dist/search.js +47 -0
  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 +80 -174
  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 +15 -16
  50. package/dist/stream.d.ts.map +1 -1
  51. package/dist/stream.js +247 -425
  52. package/dist/transport.d.ts +58 -43
  53. package/dist/transport.d.ts.map +1 -1
  54. package/dist/transport.js +55 -12
  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 +10 -8
  61. package/dist/version.d.ts +0 -1
  62. package/dist/write.d.ts +2 -3
  63. package/dist/write.d.ts.map +1 -1
  64. package/dist/write.js +27 -42
  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/gather.d.ts +0 -4
  73. package/dist/gather.d.ts.map +0 -1
  74. package/dist/gather.js +0 -35
  75. package/dist/house-model.d.ts +0 -2
  76. package/dist/house-model.d.ts.map +0 -1
  77. package/dist/house-model.js +0 -485
  78. package/dist/part.d.ts +0 -15
  79. package/dist/part.d.ts.map +0 -1
  80. package/dist/part.js +0 -82
  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/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,7 +0,0 @@
1
- export declare const INBOX_CHANNEL_KINDS: readonly ['telegram-bot', 'telegram-business', '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_NAMEABLE_ROOM_TYPES: string[];
6
- export declare const HOUSE_ROOM_TYPES: string;
7
- //# 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":"AAGA,eAAO,MAAM,mBAAmB,YAC9B,cAAc,EACd,mBAAmB,EACnB,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;AAElD,eAAO,MAAM,yBAAyB,UAAwC,CAAC;AAyB/E,eAAO,MAAM,gBAAgB,QA6FjB,CAAC"}
@@ -1,125 +0,0 @@
1
- import { APP_REFERENCE_PATTERN } from './app-reference.js';
2
- import { HOUSE_MODEL_TYPES } from './house-model.js';
3
- export const INBOX_CHANNEL_KINDS = [
4
- 'telegram-bot',
5
- 'telegram-business',
6
- 'whatsapp',
7
- 'messenger',
8
- 'instagram',
9
- 'viber',
10
- 'tiktok',
11
- ];
12
- export const INBOX_CHAT_TYPE = 'inbox-chat';
13
- export const INBOX_MESSAGE_TYPE = 'inbox-message';
14
- export const HOUSE_NAMEABLE_ROOM_TYPES = [INBOX_CHAT_TYPE, INBOX_MESSAGE_TYPE];
15
- const WAYFINDING_MAP_TYPE = 'wayfinding-map';
16
- const WAYFINDING_TICKET_TYPE = 'wayfinding-ticket';
17
- const WAYFINDING_MAP_SECTIONS = [
18
- 'Destination',
19
- 'Notes',
20
- 'Decisions so far',
21
- 'Not yet specified',
22
- 'Out of scope',
23
- ];
24
- const IDENTITY = "{ type: string, pattern: '^\\S+$' }";
25
- const AGENT = [' agent: { type: string, format: uuid }', ' name: { type: string }'];
26
- const ASSIGNEE = [
27
- ' type: object',
28
- ' properties:',
29
- ' user: { type: string, format: uuid }',
30
- ...AGENT,
31
- ];
32
- export const HOUSE_ROOM_TYPES = [
33
- `${INBOX_CHAT_TYPE}:`,
34
- ' properties:',
35
- ' inbox: { type: string, format: uuid }',
36
- ` channel: { enum: [${INBOX_CHANNEL_KINDS.join(', ')}] }`,
37
- ` chat: ${IDENTITY}`,
38
- ' customer:',
39
- ' type: object',
40
- ' properties:',
41
- ' name: { type: string }',
42
- ` username: ${IDENTITY}`,
43
- ` phone: ${IDENTITY}`,
44
- ' assignee:',
45
- ...ASSIGNEE,
46
- ' return_to:',
47
- ' type: object',
48
- ' properties:',
49
- ...AGENT,
50
- ' conversation: { type: string, format: uuid }',
51
- ' required: [inbox, channel, chat, customer]',
52
- `${INBOX_MESSAGE_TYPE}:`,
53
- ' properties:',
54
- ' direction: { enum: [in, out] }',
55
- ' sender:',
56
- ' type: object',
57
- ' properties:',
58
- ' name: { type: string }',
59
- ` username: ${IDENTITY}`,
60
- ' sent_at: { type: string, format: date-time }',
61
- ` channel_message: ${IDENTITY}`,
62
- ' state: { enum: [sending, sent, failed] }',
63
- ' reason: { type: string }',
64
- ' reactions:',
65
- ' type: array',
66
- ' items:',
67
- ' type: object',
68
- ' properties:',
69
- ' reaction: { type: string, minLength: 1 }',
70
- ' sender:',
71
- ' type: object',
72
- ' properties:',
73
- ` id: ${IDENTITY}`,
74
- ' name: { type: string }',
75
- ` username: ${IDENTITY}`,
76
- ' count: { type: integer, minimum: 1 }',
77
- ' required: [reaction]',
78
- ` post: ${IDENTITY}`,
79
- ' assignee:',
80
- ...ASSIGNEE,
81
- ' sent_outside: { const: true }',
82
- ' template:',
83
- ' type: object',
84
- ' properties:',
85
- ' name: { type: string, minLength: 1 }',
86
- ' language: { type: string, minLength: 1 }',
87
- ' required: [name, language]',
88
- ' values:',
89
- ' type: object',
90
- ' additionalProperties: { type: string }',
91
- ' withheld: { const: true }',
92
- ' required: [direction]',
93
- ' if: { properties: { direction: { const: in } } }',
94
- ' then: { required: [sent_at] }',
95
- `${WAYFINDING_MAP_TYPE}:`,
96
- ' properties:',
97
- ' title: { type: string }',
98
- ' required: [title]',
99
- ' sections:',
100
- ...WAYFINDING_MAP_SECTIONS.map((name) => ` ${name}: { kind: text, required: true }`),
101
- `${WAYFINDING_TICKET_TYPE}:`,
102
- ' properties:',
103
- ' title: { type: string }',
104
- ' kind: { enum: [research, prototype, grilling, task] }',
105
- ' status: { enum: [open, in-progress, done, out-of-scope] }',
106
- ` map: { type: string, reference: ${WAYFINDING_MAP_TYPE} }`,
107
- ` blocked_by: { type: array, items: { type: string, reference: ${WAYFINDING_TICKET_TYPE} } }`,
108
- ' assignee:',
109
- ...ASSIGNEE,
110
- ' conversation: { type: string, format: uuid }',
111
- ` app: { type: string, pattern: '${APP_REFERENCE_PATTERN.source}' }`,
112
- ' required: [title, kind, status, map, blocked_by]',
113
- ' sections:',
114
- ' Question: { kind: text }',
115
- ' Answer: { kind: text }',
116
- ' allOf:',
117
- ' - if: { properties: { status: { enum: [in-progress, done, out-of-scope] } }, required: [status] }',
118
- ' then: { required: [assignee] }',
119
- ' else: { properties: { assignee: false } }',
120
- ' - if: { properties: { assignee: { required: [agent] } }, required: [assignee] }',
121
- ' else: { properties: { conversation: false } }',
122
- ' - if: { properties: { status: { enum: [done, out-of-scope] } }, required: [status] }',
123
- ' then: { sections: { Answer: { kind: text, required: true } } }',
124
- HOUSE_MODEL_TYPES,
125
- ].join('\n');