@agentshouse/mdruntime-adapter 0.1.0-alpha.9 → 0.1.0-c023d3564cb7c
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/AGENTS.md +312 -74
- package/README.md +32 -0
- package/dist/actions.d.ts +57 -13
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +274 -397
- package/dist/adapter.d.ts +1 -0
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +525 -216
- package/dist/digest.js +1 -5
- package/dist/discovery.d.ts +27 -36
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +173 -228
- package/dist/gather.d.ts +4 -0
- package/dist/gather.d.ts.map +1 -0
- package/dist/gather.js +35 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/map.d.ts +2 -2
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +6 -7
- package/dist/model.d.ts +7 -18
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +60 -57
- package/dist/part.d.ts +15 -0
- package/dist/part.d.ts.map +1 -0
- package/dist/part.js +85 -0
- package/dist/read.d.ts +93 -35
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +415 -245
- package/dist/refusal.d.ts +5 -7
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +47 -68
- package/dist/room-types.d.ts +6 -0
- package/dist/room-types.d.ts.map +1 -0
- package/dist/room-types.js +66 -0
- package/dist/site.d.ts +1 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +219 -161
- package/dist/stream.d.ts +18 -6
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +556 -214
- package/dist/transport.d.ts +131 -38
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +4 -3
- package/dist/upload.d.ts +12 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +52 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +32 -18
- package/dist/write.d.ts +18 -8
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +259 -228
- package/package.json +4 -13
- package/dist/actions.js.map +0 -1
- package/dist/adapter.js.map +0 -1
- package/dist/digest.js.map +0 -1
- package/dist/discovery.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/map.js.map +0 -1
- package/dist/model.js.map +0 -1
- package/dist/read.js.map +0 -1
- package/dist/refusal.js.map +0 -1
- package/dist/site.js.map +0 -1
- package/dist/stream.js.map +0 -1
- package/dist/transport.js.map +0 -1
- package/dist/version.js.map +0 -1
- package/dist/write.js.map +0 -1
package/dist/refusal.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { AdapterFailure, DiscoverResult, ProviderRefusal, ScopedRefusal } from '@agentshouse/mdruntime';
|
|
2
|
-
export
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
2
|
+
export declare function doorRefusal(body: unknown): ProviderRefusal | null;
|
|
3
|
+
export declare function scopedRefusal(locator: string, scope: ScopedRefusal['scope'], refusal: ProviderRefusal): ScopedRefusal;
|
|
4
|
+
export declare function classifyDoor(status: number, body: unknown, locator: string): AdapterFailure | null;
|
|
5
|
+
export declare function classifyRead(status: number, body: unknown, locator: string): AdapterFailure | {
|
|
6
6
|
kind: 'beyond-horizon';
|
|
7
7
|
} | null;
|
|
8
|
-
export declare function discoveryFailure(
|
|
9
|
-
kind: 'beyond-horizon';
|
|
10
|
-
}): DiscoverResult;
|
|
8
|
+
export declare function discoveryFailure(status: number, body: unknown): DiscoverResult | null;
|
|
11
9
|
//# sourceMappingURL=refusal.d.ts.map
|
package/dist/refusal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../src/refusal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,EACd,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../src/refusal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,EACd,MAAM,wBAAwB,CAAC;AAEhC,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAOjE;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,EAC7B,OAAO,EAAE,eAAe,GACvB,aAAa,CAEf;AAqBD,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,GACd,cAAc,GAAG,IAAI,CAMvB;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,GACd,cAAc,GAAG;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAAG,IAAI,CAGpD;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CAQrF"}
|
package/dist/refusal.js
CHANGED
|
@@ -1,78 +1,57 @@
|
|
|
1
|
-
const RETRYABLE_CODES = new Set([
|
|
2
|
-
'auth_unavailable',
|
|
3
|
-
'replica_behind',
|
|
4
|
-
'read_replica_unavailable',
|
|
5
|
-
'read_replica_lagging',
|
|
6
|
-
'read_pool_acquisition_timed_out',
|
|
7
|
-
'sync_unavailable',
|
|
8
|
-
'sync_failed',
|
|
9
|
-
'rate_limited',
|
|
10
|
-
'operation_contended',
|
|
11
|
-
'service_mode_write_halted',
|
|
12
|
-
'transaction_budget_exceeded'
|
|
13
|
-
]);
|
|
14
1
|
export function doorRefusal(body) {
|
|
15
|
-
if (typeof body !== 'object' || body === null)
|
|
16
|
-
|
|
2
|
+
if (typeof body !== 'object' || body === null)
|
|
3
|
+
return null;
|
|
4
|
+
if (!('error' in body) || typeof body.error !== 'object' || body.error === null)
|
|
5
|
+
return null;
|
|
17
6
|
const error = body.error;
|
|
18
|
-
if (typeof error.code !== 'string')
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
fields
|
|
23
|
-
};
|
|
7
|
+
if (typeof error.code !== 'string')
|
|
8
|
+
return null;
|
|
9
|
+
const { code, retryable, ...fields } = error;
|
|
10
|
+
return { code, fields, retryable: retryable === true };
|
|
24
11
|
}
|
|
25
12
|
export function scopedRefusal(locator, scope, refusal) {
|
|
26
|
-
return {
|
|
27
|
-
kind: 'scoped-refusal',
|
|
28
|
-
locator,
|
|
29
|
-
scope,
|
|
30
|
-
code: refusal.code,
|
|
31
|
-
fields: refusal.fields
|
|
32
|
-
};
|
|
13
|
+
return { kind: 'scoped-refusal', locator, scope, ...refusal };
|
|
33
14
|
}
|
|
34
|
-
|
|
35
|
-
if (status === 0)
|
|
36
|
-
kind: 'transport-uncertainty'
|
|
37
|
-
};
|
|
15
|
+
function doorFailure(status, body) {
|
|
16
|
+
if (status === 0)
|
|
17
|
+
return { kind: 'transport-uncertainty' };
|
|
38
18
|
const refusal = doorRefusal(body);
|
|
39
|
-
if (status === 401)
|
|
40
|
-
kind: 'revoked-authorization'
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
kind: 'transport-uncertainty'
|
|
44
|
-
};
|
|
45
|
-
if (refusal !== null && refusal.code === 'position_expired') return {
|
|
46
|
-
kind: 'beyond-horizon'
|
|
47
|
-
};
|
|
48
|
-
if (status === 404 || refusal?.code === 'room_not_found') {
|
|
49
|
-
return {
|
|
50
|
-
kind: 'room-not-readable',
|
|
51
|
-
locator
|
|
52
|
-
};
|
|
19
|
+
if (status === 401)
|
|
20
|
+
return { kind: 'revoked-authorization' };
|
|
21
|
+
if (refusal?.retryable === true || refusal?.code === 'update_required') {
|
|
22
|
+
return { kind: 'transport-uncertainty' };
|
|
53
23
|
}
|
|
54
|
-
if (status
|
|
55
|
-
kind: '
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (refusal === null)
|
|
59
|
-
kind: 'transport-uncertainty'
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
|
|
24
|
+
if (status === 404 || refusal?.code === 'room_not_found')
|
|
25
|
+
return { kind: 'room-not-readable' };
|
|
26
|
+
if (status < 400)
|
|
27
|
+
return null;
|
|
28
|
+
if (refusal === null)
|
|
29
|
+
return { kind: 'transport-uncertainty' };
|
|
30
|
+
return { kind: 'refused', scope: status === 403 ? 'operation' : 'undisclosed', refusal };
|
|
31
|
+
}
|
|
32
|
+
export function classifyDoor(status, body, locator) {
|
|
33
|
+
const failure = doorFailure(status, body);
|
|
34
|
+
if (failure === null)
|
|
35
|
+
return null;
|
|
36
|
+
if (failure.kind === 'room-not-readable')
|
|
37
|
+
return { kind: 'room-not-readable', locator };
|
|
38
|
+
if (failure.kind === 'refused')
|
|
39
|
+
return scopedRefusal(locator, failure.scope, failure.refusal);
|
|
40
|
+
return failure;
|
|
41
|
+
}
|
|
42
|
+
export function classifyRead(status, body, locator) {
|
|
43
|
+
if (doorRefusal(body)?.code === 'expired')
|
|
44
|
+
return { kind: 'beyond-horizon' };
|
|
45
|
+
return classifyDoor(status, body, locator);
|
|
63
46
|
}
|
|
64
|
-
export function discoveryFailure(
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
return
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
};
|
|
47
|
+
export function discoveryFailure(status, body) {
|
|
48
|
+
const failure = doorFailure(status, body);
|
|
49
|
+
if (failure === null)
|
|
50
|
+
return null;
|
|
51
|
+
if (failure.kind === 'revoked-authorization')
|
|
52
|
+
return failure;
|
|
53
|
+
if (failure.kind === 'refused') {
|
|
54
|
+
return { kind: 'contract-unavailable', ...failure.refusal };
|
|
72
55
|
}
|
|
73
|
-
return {
|
|
74
|
-
kind: 'transport-uncertainty'
|
|
75
|
-
};
|
|
56
|
+
return { kind: 'transport-uncertainty' };
|
|
76
57
|
}
|
|
77
|
-
|
|
78
|
-
//# sourceMappingURL=refusal.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,66 @@
|
|
|
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');
|
package/dist/site.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Adapter } from '@agentshouse/mdruntime';
|
|
2
2
|
import { type HouseSiteTransport } from './transport.js';
|
|
3
|
-
export declare function createSiteAdapter(transport: HouseSiteTransport): Adapter;
|
|
3
|
+
export declare function createSiteAdapter(transport: HouseSiteTransport, snapshot?: boolean): Adapter;
|
|
4
4
|
//# sourceMappingURL=site.d.ts.map
|
package/dist/site.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,
|
|
1
|
+
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAWR,MAAM,wBAAwB,CAAC;AA+BhC,OAAO,EAML,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAoCxB,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,EAAE,QAAQ,UAAQ,GAAG,OAAO,CAoP1F"}
|