@agentshouse/mdruntime-adapter 0.1.0-cd36fe2bc9d48 → 0.1.0-cd4595ba399a4
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.
- package/README.md +3 -3
- package/dist/actions.d.ts +6 -58
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +26 -296
- package/dist/adapter.d.ts +0 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +226 -400
- package/dist/authored-path.d.ts +65 -0
- package/dist/authored-path.d.ts.map +1 -0
- package/dist/authored-path.js +164 -0
- package/dist/chunks.d.ts +36 -0
- package/dist/chunks.d.ts.map +1 -0
- package/dist/chunks.js +281 -0
- package/dist/digest.d.ts +0 -1
- package/dist/discovery.d.ts +44 -19
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +239 -72
- package/dist/history.d.ts +6 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +85 -0
- package/dist/index.d.ts +9 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/map.d.ts +0 -1
- package/dist/model.d.ts +6 -6
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +31 -48
- package/dist/read.d.ts +23 -69
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +109 -329
- package/dist/refusal.d.ts +6 -5
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +27 -11
- package/dist/room-query.d.ts +4 -0
- package/dist/room-query.d.ts.map +1 -0
- package/dist/room-query.js +51 -0
- package/dist/search.d.ts +4 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +47 -0
- package/dist/session-content/check.d.ts +17 -0
- package/dist/session-content/index.d.ts +6 -0
- package/dist/session-content/parts.d.ts +30 -0
- package/dist/session-content/state.d.ts +59 -0
- package/dist/session-content/turn.d.ts +137 -0
- package/dist/site.d.ts +0 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +111 -171
- package/dist/space-schema.d.ts +6 -0
- package/dist/space-schema.d.ts.map +1 -0
- package/dist/space-schema.js +11 -0
- package/dist/stream.d.ts +15 -16
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +240 -431
- package/dist/transport.d.ts +86 -47
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +91 -11
- package/dist/uncertain.d.ts +5 -0
- package/dist/uncertain.d.ts.map +1 -0
- package/dist/uncertain.js +11 -0
- package/dist/upload.d.ts +3 -2
- package/dist/upload.d.ts.map +1 -1
- package/dist/upload.js +32 -19
- package/dist/version.d.ts +0 -1
- package/dist/write.d.ts +6 -3
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +47 -56
- package/package.json +9 -4
- package/AGENTS.md +0 -317
- package/dist/gather.d.ts +0 -4
- package/dist/gather.d.ts.map +0 -1
- package/dist/gather.js +0 -35
- package/dist/part.d.ts +0 -15
- package/dist/part.d.ts.map +0 -1
- package/dist/part.js +0 -85
- package/dist/room-types.d.ts +0 -6
- package/dist/room-types.d.ts.map +0 -1
- package/dist/room-types.js +0 -66
package/dist/part.d.ts.map
DELETED
|
@@ -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,wBAAgB,WAAW,CACzB,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,GAC9C,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAG1C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAIvE;AAED,wBAAsB,cAAc,CAClC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,EAC9B,MAAM,EAAE,SAAS,GAChB,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,CAazC;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,85 +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 async function gunzipped(payload) {
|
|
68
|
-
try {
|
|
69
|
-
const stream = new Blob([payload]).stream().pipeThrough(new DecompressionStream('gzip'));
|
|
70
|
-
return await new Response(stream).text();
|
|
71
|
-
}
|
|
72
|
-
catch {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
export function unverifiedPart(locator) {
|
|
77
|
-
return {
|
|
78
|
-
kind: 'scoped-refusal',
|
|
79
|
-
locator,
|
|
80
|
-
scope: 'undisclosed',
|
|
81
|
-
code: PART_UNVERIFIED,
|
|
82
|
-
fields: {},
|
|
83
|
-
retryable: true,
|
|
84
|
-
};
|
|
85
|
-
}
|
package/dist/room-types.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const INBOX_CHANNEL_KINDS: readonly ['telegram-bot', 'whatsapp', 'messenger', 'instagram'];
|
|
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
|
package/dist/room-types.d.ts.map
DELETED
|
@@ -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,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,CAAU,CAAC;AAEnG,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"}
|
package/dist/room-types.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
export const INBOX_CHANNEL_KINDS = ['telegram-bot', 'whatsapp', 'messenger', 'instagram'];
|
|
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');
|