@agentshouse/mdruntime-adapter 0.1.0-c8cad855cc8e8 → 0.1.0-c8d6935639fda
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 -74
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +25 -333
- package/dist/adapter.d.ts +0 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +209 -394
- package/dist/authored-path.d.ts +9 -0
- package/dist/authored-path.d.ts.map +1 -0
- package/dist/authored-path.js +34 -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 +35 -19
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +199 -59
- 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 +10 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -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 +18 -64
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +76 -358
- package/dist/refusal.d.ts +3 -5
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +17 -12
- 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/bounds.d.ts +7 -0
- package/dist/session-content/check.d.ts +18 -0
- package/dist/session-content/index.d.ts +7 -0
- package/dist/session-content/parts.d.ts +103 -0
- package/dist/session-content/state.d.ts +61 -0
- package/dist/session-content/turn.d.ts +328 -0
- package/dist/site.d.ts +0 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +87 -191
- 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 +242 -426
- package/dist/transport.d.ts +75 -45
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +56 -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 +13 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +65 -0
- 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 +39 -57
- package/package.json +9 -4
- package/AGENTS.md +0 -312
- 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 -13
- package/dist/part.d.ts.map +0 -1
- package/dist/part.js +0 -80
- package/dist/referrer.d.ts +0 -9
- package/dist/referrer.d.ts.map +0 -1
- package/dist/referrer.js +0 -41
- 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.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
|
-
}
|
package/dist/referrer.d.ts
DELETED
|
@@ -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
|
package/dist/referrer.d.ts.map
DELETED
|
@@ -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
|
-
}
|
package/dist/room-types.d.ts
DELETED
|
@@ -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
|
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,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"}
|
package/dist/room-types.js
DELETED
|
@@ -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');
|