@agentshouse/mdruntime 0.1.0-alpha.9 → 0.1.0-c0105dbd22806
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 +299 -0
- package/README.md +54 -0
- package/dist/adapter.d.ts +246 -40
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +1 -10
- package/dist/attached-model.d.ts +11 -0
- package/dist/attached-model.d.ts.map +1 -0
- package/dist/attached-model.js +47 -0
- package/dist/attempt.d.ts +16 -0
- package/dist/attempt.d.ts.map +1 -0
- package/dist/attempt.js +70 -0
- package/dist/binary.d.ts +23 -0
- package/dist/binary.d.ts.map +1 -0
- package/dist/binary.js +8 -0
- package/dist/bootstrap.d.ts +17 -7
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +97 -41
- package/dist/change-set.d.ts +33 -0
- package/dist/change-set.d.ts.map +1 -0
- package/dist/change-set.js +90 -0
- package/dist/change.d.ts +24 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +31 -5
- package/dist/chat/acts.d.ts +34 -0
- package/dist/chat/acts.d.ts.map +1 -0
- package/dist/chat/acts.js +36 -0
- package/dist/chat/context.d.ts +3 -0
- package/dist/chat/context.d.ts.map +1 -0
- package/dist/chat/context.js +10 -0
- package/dist/chat/input.d.ts +9 -0
- package/dist/chat/input.d.ts.map +1 -0
- package/dist/chat/input.js +99 -0
- package/dist/chat/kit.d.ts +60 -0
- package/dist/chat/kit.d.ts.map +1 -0
- package/dist/chat/kit.js +123 -0
- package/dist/chat/lasting.d.ts +6 -0
- package/dist/chat/lasting.d.ts.map +1 -0
- package/dist/chat/lasting.js +19 -0
- package/dist/chat/list.d.ts +26 -0
- package/dist/chat/list.d.ts.map +1 -0
- package/dist/chat/list.js +62 -0
- package/dist/chat/markdown.d.ts +20 -0
- package/dist/chat/markdown.d.ts.map +1 -0
- package/dist/chat/markdown.js +188 -0
- package/dist/chat/message.d.ts +6 -0
- package/dist/chat/message.d.ts.map +1 -0
- package/dist/chat/message.js +192 -0
- package/dist/chat/messages.d.ts +21 -0
- package/dist/chat/messages.d.ts.map +1 -0
- package/dist/chat/messages.js +151 -0
- package/dist/chat/name.d.ts +6 -0
- package/dist/chat/name.d.ts.map +1 -0
- package/dist/chat/name.js +37 -0
- package/dist/chat/opened.d.ts +11 -0
- package/dist/chat/opened.d.ts.map +1 -0
- package/dist/chat/opened.js +17 -0
- package/dist/chat/overlay.d.ts +31 -0
- package/dist/chat/overlay.d.ts.map +1 -0
- package/dist/chat/overlay.js +97 -0
- package/dist/chat/parts.d.ts +57 -0
- package/dist/chat/parts.d.ts.map +1 -0
- package/dist/chat/parts.js +119 -0
- package/dist/chat/process.d.ts +20 -0
- package/dist/chat/process.d.ts.map +1 -0
- package/dist/chat/process.js +32 -0
- package/dist/chat/provider.d.ts +63 -0
- package/dist/chat/provider.d.ts.map +1 -0
- package/dist/chat/provider.js +645 -0
- package/dist/chat/question.d.ts +9 -0
- package/dist/chat/question.d.ts.map +1 -0
- package/dist/chat/question.js +80 -0
- package/dist/chat/questions.d.ts +31 -0
- package/dist/chat/questions.d.ts.map +1 -0
- package/dist/chat/questions.js +111 -0
- package/dist/chat/read.d.ts +5 -0
- package/dist/chat/read.d.ts.map +1 -0
- package/dist/chat/read.js +13 -0
- package/dist/chat/ready.d.ts +33 -0
- package/dist/chat/ready.d.ts.map +1 -0
- package/dist/chat/ready.js +91 -0
- package/dist/chat/style.d.ts +4 -0
- package/dist/chat/style.d.ts.map +1 -0
- package/dist/chat/style.js +302 -0
- package/dist/chat.d.ts +14 -0
- package/dist/chat.d.ts.map +1 -0
- package/dist/chat.js +8 -0
- package/dist/client.d.ts +49 -33
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +164 -183
- package/dist/collection.d.ts +9 -17
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +83 -89
- package/dist/connection.d.ts +66 -48
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +1964 -1173
- package/dist/conversation.d.ts +65 -24
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +675 -334
- package/dist/durability.js +6 -6
- package/dist/entry.d.ts +17 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +156 -0
- package/dist/expectation.d.ts +21 -0
- package/dist/expectation.d.ts.map +1 -0
- package/dist/expectation.js +70 -0
- package/dist/failure.d.ts +13 -0
- package/dist/failure.d.ts.map +1 -0
- package/dist/failure.js +19 -0
- package/dist/fence.d.ts +6 -0
- package/dist/fence.d.ts.map +1 -0
- package/dist/fence.js +10 -0
- package/dist/file.d.ts +2 -2
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +48 -71
- package/dist/host.d.ts +15 -3
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +109 -127
- package/dist/identity.d.ts +4 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +22 -9
- package/dist/index.d.ts +17 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/log.js +5 -6
- package/dist/memory.d.ts +19 -8
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +304 -216
- package/dist/model.d.ts +16 -30
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +21 -21
- package/dist/observation.d.ts +27 -0
- package/dist/observation.d.ts.map +1 -0
- package/dist/observation.js +95 -0
- package/dist/open.d.ts +2 -0
- package/dist/open.d.ts.map +1 -0
- package/dist/open.js +1 -0
- package/dist/outcome.d.ts +37 -31
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +36 -18
- package/dist/overlay.d.ts +22 -4
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +236 -54
- package/dist/paths.d.ts +0 -2
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +6 -29
- package/dist/query.d.ts +219 -10
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +462 -15
- package/dist/reach.d.ts +42 -0
- package/dist/reach.d.ts.map +1 -0
- package/dist/reach.js +294 -0
- package/dist/react.d.ts +41 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +64 -0
- package/dist/read-side.d.ts +18 -0
- package/dist/read-side.d.ts.map +1 -0
- package/dist/read-side.js +440 -0
- package/dist/refresh.d.ts +15 -5
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +64 -41
- package/dist/replica.d.ts +28 -5
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +249 -40
- package/dist/room-draft.d.ts +144 -0
- package/dist/room-draft.d.ts.map +1 -0
- package/dist/room-draft.js +438 -0
- package/dist/rows.d.ts +46 -0
- package/dist/rows.d.ts.map +1 -0
- package/dist/rows.js +145 -0
- package/dist/save.d.ts +33 -5
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +630 -366
- package/dist/search.d.ts +62 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +125 -0
- package/dist/status.d.ts +6 -8
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +8 -20
- package/dist/store.d.ts +89 -34
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +513 -132
- package/dist/transfer.d.ts +5 -0
- package/dist/transfer.d.ts.map +1 -1
- package/dist/transfer.js +1 -5
- package/dist/wire.d.ts +59 -19
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +88 -105
- package/package.json +34 -16
- package/dist/adapter.js.map +0 -1
- package/dist/bootstrap.js.map +0 -1
- package/dist/change.js.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/collection.js.map +0 -1
- package/dist/connection.js.map +0 -1
- package/dist/conversation.js.map +0 -1
- package/dist/durability.js.map +0 -1
- package/dist/file.js.map +0 -1
- package/dist/host.js.map +0 -1
- package/dist/identity.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/log.js.map +0 -1
- package/dist/memory.js.map +0 -1
- package/dist/model.js.map +0 -1
- package/dist/outcome.js.map +0 -1
- package/dist/overlay.js.map +0 -1
- package/dist/paths.js.map +0 -1
- package/dist/query.js.map +0 -1
- package/dist/refresh.js.map +0 -1
- package/dist/replica.js.map +0 -1
- package/dist/save.js.map +0 -1
- package/dist/status.js.map +0 -1
- package/dist/store.js.map +0 -1
- package/dist/transfer.js.map +0 -1
- package/dist/wire.js.map +0 -1
package/dist/transfer.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import type { Refusal } from '@agentshouse/mdmodel';
|
|
1
2
|
export type Unconfirmed = {
|
|
2
3
|
kind: 'unconfirmed';
|
|
3
4
|
};
|
|
5
|
+
export type Refused = {
|
|
6
|
+
kind: 'refused';
|
|
7
|
+
refusal: Refusal;
|
|
8
|
+
};
|
|
4
9
|
export declare const unconfirmed: Unconfirmed;
|
|
5
10
|
//# sourceMappingURL=transfer.d.ts.map
|
package/dist/transfer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../src/transfer.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC;AAElD,eAAO,MAAM,WAAW,EAAE,WAAqC,CAAC"}
|
|
1
|
+
{"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../src/transfer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC;AAElD,MAAM,MAAM,OAAO,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAE5D,eAAO,MAAM,WAAW,EAAE,WAAqC,CAAC"}
|
package/dist/transfer.js
CHANGED
package/dist/wire.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ConnectionRefusal } from './connection.js';
|
|
2
|
-
|
|
3
|
-
export declare const PROTOCOL_MISMATCH: ConnectionRefusal;
|
|
2
|
+
import type { Described } from './failure.js';
|
|
4
3
|
export type RuntimePort = {
|
|
5
4
|
postMessage(message: unknown): void;
|
|
6
5
|
addEventListener(type: 'message' | 'close', listener: (event: {
|
|
@@ -8,10 +7,61 @@ export type RuntimePort = {
|
|
|
8
7
|
}) => void): void;
|
|
9
8
|
start(): void;
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
declare const
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
export type WireReach = 'within' | 'app' | 'runtime' | 'actions' | 'whole';
|
|
11
|
+
declare const MEMBERS: {
|
|
12
|
+
readonly rooms: 'within';
|
|
13
|
+
readonly query: 'within';
|
|
14
|
+
readonly search: 'within';
|
|
15
|
+
readonly types: 'within';
|
|
16
|
+
readonly save: 'within';
|
|
17
|
+
readonly history: 'within';
|
|
18
|
+
readonly 'binaryFile.read': 'within';
|
|
19
|
+
readonly 'binaryFile.readReference': 'within';
|
|
20
|
+
readonly call: 'actions';
|
|
21
|
+
readonly reached: 'within';
|
|
22
|
+
readonly log: 'whole';
|
|
23
|
+
readonly persistence: 'runtime';
|
|
24
|
+
readonly reauthorize: 'runtime';
|
|
25
|
+
readonly 'roomDraft.list': 'within';
|
|
26
|
+
readonly 'roomDraft.read': 'within';
|
|
27
|
+
readonly 'roomDraft.write': 'within';
|
|
28
|
+
readonly 'roomDraft.discard': 'within';
|
|
29
|
+
readonly 'presentation.read': 'app';
|
|
30
|
+
readonly 'presentation.write': 'app';
|
|
31
|
+
readonly 'conversation.list': 'within';
|
|
32
|
+
readonly 'conversation.read': 'within';
|
|
33
|
+
readonly 'conversation.create': 'within';
|
|
34
|
+
readonly 'conversation.send': 'within';
|
|
35
|
+
readonly 'conversation.answer': 'within';
|
|
36
|
+
readonly 'conversation.interrupt': 'within';
|
|
37
|
+
readonly 'conversation.kill': 'within';
|
|
38
|
+
readonly 'conversation.cancel': 'within';
|
|
39
|
+
readonly 'conversation.delete': 'within';
|
|
40
|
+
readonly 'chatDraft.write': 'within';
|
|
41
|
+
readonly 'chatDraft.discard': 'within';
|
|
42
|
+
};
|
|
43
|
+
declare const TOPICS: {
|
|
44
|
+
readonly rooms: 'within';
|
|
45
|
+
readonly 'connection-refusal': 'runtime';
|
|
46
|
+
readonly 'storage-loss': 'runtime';
|
|
47
|
+
readonly 'deployment-facts': 'runtime';
|
|
48
|
+
readonly 'sync-status': 'within';
|
|
49
|
+
readonly 'service-mode': 'runtime';
|
|
50
|
+
readonly member: 'runtime';
|
|
51
|
+
readonly query: 'within';
|
|
52
|
+
readonly queue: 'within';
|
|
53
|
+
readonly 'room-drafts': 'within';
|
|
54
|
+
readonly presentation: 'app';
|
|
55
|
+
readonly conversation: 'within';
|
|
56
|
+
readonly conversations: 'within';
|
|
57
|
+
readonly agents: 'within';
|
|
58
|
+
};
|
|
59
|
+
export declare const WIRE_REACH: {
|
|
60
|
+
readonly members: Readonly<Record<string, WireReach>>;
|
|
61
|
+
readonly topics: Readonly<Record<string, WireReach>>;
|
|
62
|
+
};
|
|
63
|
+
export type WireMember = keyof typeof MEMBERS;
|
|
64
|
+
export type WireTopic = keyof typeof TOPICS;
|
|
15
65
|
export type WireRequest = {
|
|
16
66
|
kind: 'hello';
|
|
17
67
|
} | {
|
|
@@ -32,11 +82,10 @@ export type WireAnswer = {
|
|
|
32
82
|
kind: 'result';
|
|
33
83
|
id: number;
|
|
34
84
|
value: unknown;
|
|
35
|
-
} | {
|
|
85
|
+
} | ({
|
|
36
86
|
kind: 'failure';
|
|
37
87
|
id: number;
|
|
38
|
-
|
|
39
|
-
} | {
|
|
88
|
+
} & Described) | {
|
|
40
89
|
kind: 'event';
|
|
41
90
|
id: number;
|
|
42
91
|
value: unknown;
|
|
@@ -47,16 +96,7 @@ export type WireAnswer = {
|
|
|
47
96
|
kind: 'ended';
|
|
48
97
|
};
|
|
49
98
|
export declare const AUTHORIZATION_ENDED = "the host authorization ended";
|
|
50
|
-
export
|
|
51
|
-
mdRuntime: number;
|
|
52
|
-
message: WireRequest | WireAnswer;
|
|
53
|
-
};
|
|
54
|
-
export type Carried = {
|
|
55
|
-
matching: boolean;
|
|
56
|
-
message: unknown;
|
|
57
|
-
};
|
|
58
|
-
export declare function envelope(message: WireRequest | WireAnswer): WireEnvelope;
|
|
59
|
-
export declare function carried(data: unknown): Carried | null;
|
|
99
|
+
export declare const PORT_CLOSED = "the port closed";
|
|
60
100
|
export declare function request(message: unknown): WireRequest | null;
|
|
61
101
|
export declare function answer(message: unknown): WireAnswer | null;
|
|
62
102
|
export {};
|
package/dist/wire.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACpC,gBAAgB,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IACjG,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAE3E,QAAA,MAAM,OAAO;oBACJ,QAAQ;oBACR,QAAQ;qBACP,QAAQ;oBACT,QAAQ;mBACT,QAAQ;sBACL,QAAQ;gCACE,QAAQ;yCACC,QAAQ;mBAC9B,SAAS;s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AAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjC,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAC9C,CAAC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAAC,GAC7C;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAC7C;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,iBAAiB,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAEtB,eAAO,MAAM,mBAAmB,iCAAiC,CAAC;AAElE,eAAO,MAAM,WAAW,oBAAoB,CAAC;AAQ7C,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAiC5D;AAED,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAgC1D"}
|
package/dist/wire.js
CHANGED
|
@@ -1,139 +1,122 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const MEMBERS = {
|
|
2
|
+
rooms: 'within',
|
|
3
|
+
query: 'within',
|
|
4
|
+
search: 'within',
|
|
5
|
+
types: 'within',
|
|
6
|
+
save: 'within',
|
|
7
|
+
history: 'within',
|
|
8
|
+
'binaryFile.read': 'within',
|
|
9
|
+
'binaryFile.readReference': 'within',
|
|
10
|
+
call: 'actions',
|
|
11
|
+
reached: 'within',
|
|
12
|
+
log: 'whole',
|
|
13
|
+
persistence: 'runtime',
|
|
14
|
+
reauthorize: 'runtime',
|
|
15
|
+
'roomDraft.list': 'within',
|
|
16
|
+
'roomDraft.read': 'within',
|
|
17
|
+
'roomDraft.write': 'within',
|
|
18
|
+
'roomDraft.discard': 'within',
|
|
19
|
+
'presentation.read': 'app',
|
|
20
|
+
'presentation.write': 'app',
|
|
21
|
+
'conversation.list': 'within',
|
|
22
|
+
'conversation.read': 'within',
|
|
23
|
+
'conversation.create': 'within',
|
|
24
|
+
'conversation.send': 'within',
|
|
25
|
+
'conversation.answer': 'within',
|
|
26
|
+
'conversation.interrupt': 'within',
|
|
27
|
+
'conversation.kill': 'within',
|
|
28
|
+
'conversation.cancel': 'within',
|
|
29
|
+
'conversation.delete': 'within',
|
|
30
|
+
'chatDraft.write': 'within',
|
|
31
|
+
'chatDraft.discard': 'within',
|
|
6
32
|
};
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
'
|
|
10
|
-
'
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
'queue.discard',
|
|
25
|
-
'presentation.read',
|
|
26
|
-
'presentation.write',
|
|
27
|
-
'conversation.list',
|
|
28
|
-
'conversation.read',
|
|
29
|
-
'conversation.older',
|
|
30
|
-
'conversation.compose',
|
|
31
|
-
'conversation.discard',
|
|
32
|
-
'conversation.create',
|
|
33
|
-
'conversation.send',
|
|
34
|
-
'conversation.answer',
|
|
35
|
-
'conversation.interrupt',
|
|
36
|
-
'conversation.kill',
|
|
37
|
-
'conversation.cancel',
|
|
38
|
-
'conversation.delete'
|
|
39
|
-
];
|
|
40
|
-
const TOPICS = [
|
|
41
|
-
'rooms',
|
|
42
|
-
'connection-refusal',
|
|
43
|
-
'storage-loss',
|
|
44
|
-
'sync-status',
|
|
45
|
-
'query',
|
|
46
|
-
'queue',
|
|
47
|
-
'drafts',
|
|
48
|
-
'presentation',
|
|
49
|
-
'conversation'
|
|
50
|
-
];
|
|
33
|
+
const TOPICS = {
|
|
34
|
+
rooms: 'within',
|
|
35
|
+
'connection-refusal': 'runtime',
|
|
36
|
+
'storage-loss': 'runtime',
|
|
37
|
+
'deployment-facts': 'runtime',
|
|
38
|
+
'sync-status': 'within',
|
|
39
|
+
'service-mode': 'runtime',
|
|
40
|
+
member: 'runtime',
|
|
41
|
+
query: 'within',
|
|
42
|
+
queue: 'within',
|
|
43
|
+
'room-drafts': 'within',
|
|
44
|
+
presentation: 'app',
|
|
45
|
+
conversation: 'within',
|
|
46
|
+
conversations: 'within',
|
|
47
|
+
agents: 'within',
|
|
48
|
+
};
|
|
49
|
+
export const WIRE_REACH = { members: MEMBERS, topics: TOPICS };
|
|
51
50
|
export const AUTHORIZATION_ENDED = 'the host authorization ended';
|
|
52
|
-
export
|
|
53
|
-
return {
|
|
54
|
-
mdRuntime: RUNTIME_WIRE_PROTOCOL,
|
|
55
|
-
message
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
export function carried(data) {
|
|
59
|
-
if (typeof data !== 'object' || data === null || !('mdRuntime' in data)) return null;
|
|
60
|
-
const record = data;
|
|
61
|
-
return {
|
|
62
|
-
matching: record.mdRuntime === RUNTIME_WIRE_PROTOCOL,
|
|
63
|
-
message: record.message
|
|
64
|
-
};
|
|
65
|
-
}
|
|
51
|
+
export const PORT_CLOSED = 'the port closed';
|
|
66
52
|
function body(message) {
|
|
67
|
-
if (typeof message !== 'object' || message === null)
|
|
53
|
+
if (typeof message !== 'object' || message === null)
|
|
54
|
+
return null;
|
|
68
55
|
const record = message;
|
|
69
|
-
return {
|
|
70
|
-
kind: record.kind,
|
|
71
|
-
id: record.id
|
|
72
|
-
};
|
|
56
|
+
return { kind: record.kind, id: record.id };
|
|
73
57
|
}
|
|
74
58
|
export function request(message) {
|
|
75
59
|
const shape = body(message);
|
|
76
|
-
if (shape === null)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (typeof shape.id !== 'number')
|
|
60
|
+
if (shape === null)
|
|
61
|
+
return null;
|
|
62
|
+
if (shape.kind === 'hello')
|
|
63
|
+
return { kind: 'hello' };
|
|
64
|
+
if (typeof shape.id !== 'number')
|
|
65
|
+
return null;
|
|
81
66
|
const record = message;
|
|
82
|
-
if (shape.kind === 'stop')
|
|
83
|
-
kind: 'stop',
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (
|
|
87
|
-
|
|
67
|
+
if (shape.kind === 'stop')
|
|
68
|
+
return { kind: 'stop', id: shape.id };
|
|
69
|
+
if (!Array.isArray(record.input))
|
|
70
|
+
return null;
|
|
71
|
+
if (shape.kind === 'call' &&
|
|
72
|
+
typeof record.member === 'string' &&
|
|
73
|
+
Object.hasOwn(MEMBERS, record.member)) {
|
|
88
74
|
return {
|
|
89
75
|
kind: 'call',
|
|
90
76
|
id: shape.id,
|
|
91
77
|
member: record.member,
|
|
92
|
-
input: record.input
|
|
78
|
+
input: record.input,
|
|
93
79
|
};
|
|
94
80
|
}
|
|
95
|
-
if (shape.kind === 'observe' &&
|
|
81
|
+
if (shape.kind === 'observe' &&
|
|
82
|
+
typeof record.topic === 'string' &&
|
|
83
|
+
Object.hasOwn(TOPICS, record.topic)) {
|
|
96
84
|
return {
|
|
97
85
|
kind: 'observe',
|
|
98
86
|
id: shape.id,
|
|
99
87
|
topic: record.topic,
|
|
100
|
-
input: record.input
|
|
88
|
+
input: record.input,
|
|
101
89
|
};
|
|
102
90
|
}
|
|
103
91
|
return null;
|
|
104
92
|
}
|
|
105
93
|
export function answer(message) {
|
|
106
94
|
const shape = body(message);
|
|
107
|
-
if (shape === null)
|
|
95
|
+
if (shape === null)
|
|
96
|
+
return null;
|
|
108
97
|
const record = message;
|
|
109
98
|
if (shape.kind === 'refusal') {
|
|
110
|
-
return {
|
|
111
|
-
kind: 'refusal',
|
|
112
|
-
refusal: record.refusal
|
|
113
|
-
};
|
|
99
|
+
return { kind: 'refusal', refusal: record.refusal };
|
|
114
100
|
}
|
|
115
|
-
if (shape.kind === 'ended')
|
|
116
|
-
kind: 'ended'
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (shape.kind === 'result')
|
|
120
|
-
kind: 'result',
|
|
121
|
-
|
|
122
|
-
value: record.value
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
value: record.value
|
|
128
|
-
};
|
|
129
|
-
if (shape.kind === 'failure' && typeof record.message === 'string') {
|
|
101
|
+
if (shape.kind === 'ended')
|
|
102
|
+
return { kind: 'ended' };
|
|
103
|
+
if (typeof shape.id !== 'number')
|
|
104
|
+
return null;
|
|
105
|
+
if (shape.kind === 'result')
|
|
106
|
+
return { kind: 'result', id: shape.id, value: record.value };
|
|
107
|
+
if (shape.kind === 'event')
|
|
108
|
+
return { kind: 'event', id: shape.id, value: record.value };
|
|
109
|
+
if (shape.kind === 'failure' &&
|
|
110
|
+
typeof record.message === 'string' &&
|
|
111
|
+
typeof record.code === 'string' &&
|
|
112
|
+
typeof record.retryable === 'boolean') {
|
|
130
113
|
return {
|
|
131
114
|
kind: 'failure',
|
|
132
115
|
id: shape.id,
|
|
133
|
-
message: record.message
|
|
116
|
+
message: record.message,
|
|
117
|
+
code: record.code,
|
|
118
|
+
retryable: record.retryable,
|
|
134
119
|
};
|
|
135
120
|
}
|
|
136
121
|
return null;
|
|
137
122
|
}
|
|
138
|
-
|
|
139
|
-
//# sourceMappingURL=wire.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentshouse/mdruntime",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-c0105dbd22806",
|
|
4
4
|
"description": "The headless core of MD App",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,37 +14,55 @@
|
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
|
-
"
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
18
|
},
|
|
19
19
|
"./host": {
|
|
20
20
|
"types": "./dist/host.d.ts",
|
|
21
|
-
"
|
|
21
|
+
"default": "./dist/host.js"
|
|
22
22
|
},
|
|
23
23
|
"./client": {
|
|
24
24
|
"types": "./dist/client.d.ts",
|
|
25
|
-
"
|
|
25
|
+
"default": "./dist/client.js"
|
|
26
|
+
},
|
|
27
|
+
"./entry": {
|
|
28
|
+
"types": "./dist/entry.d.ts",
|
|
29
|
+
"default": "./dist/entry.js"
|
|
26
30
|
},
|
|
27
31
|
"./memory": {
|
|
28
32
|
"types": "./dist/memory.d.ts",
|
|
29
|
-
"
|
|
33
|
+
"default": "./dist/memory.js"
|
|
34
|
+
},
|
|
35
|
+
"./react": {
|
|
36
|
+
"types": "./dist/react.d.ts",
|
|
37
|
+
"default": "./dist/react.js"
|
|
38
|
+
},
|
|
39
|
+
"./chat": {
|
|
40
|
+
"types": "./dist/chat.d.ts",
|
|
41
|
+
"default": "./dist/chat.js"
|
|
30
42
|
},
|
|
31
43
|
"./package.json": "./package.json"
|
|
32
44
|
},
|
|
33
45
|
"files": [
|
|
34
46
|
"dist",
|
|
47
|
+
"AGENTS.md",
|
|
48
|
+
"README.md",
|
|
35
49
|
"LICENSE"
|
|
36
50
|
],
|
|
37
|
-
"repository": {
|
|
38
|
-
"type": "git",
|
|
39
|
-
"url": "git+https://github.com/agentshouse/mdruntime.git",
|
|
40
|
-
"directory": "packages/mdruntime"
|
|
41
|
-
},
|
|
42
|
-
"homepage": "https://github.com/agentshouse/mdruntime#readme",
|
|
43
|
-
"bugs": {
|
|
44
|
-
"url": "https://github.com/agentshouse/mdruntime/issues"
|
|
45
|
-
},
|
|
46
51
|
"dependencies": {
|
|
47
|
-
"@agentshouse/mdmodel": "0.1.0-
|
|
48
|
-
"@
|
|
52
|
+
"@agentshouse/mdmodel": "0.1.0-c6e675bb19980",
|
|
53
|
+
"@assistant-ui/react-markdown": "0.14.20",
|
|
54
|
+
"@tanstack/db": "0.9.2",
|
|
55
|
+
"lucide-react": "1.47.0",
|
|
56
|
+
"mdast-util-from-markdown": "2.0.3",
|
|
57
|
+
"mdast-util-gfm": "3.1.0",
|
|
58
|
+
"micromark-extension-gfm": "3.0.0",
|
|
59
|
+
"minisearch": "7.2.0",
|
|
60
|
+
"radix-ui": "1.8.0",
|
|
61
|
+
"remark-gfm": "4.0.1"
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"@assistant-ui/react": "^0.15.22",
|
|
65
|
+
"react": ">=18",
|
|
66
|
+
"react-dom": ">=18"
|
|
49
67
|
}
|
|
50
68
|
}
|
package/dist/adapter.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime/src/adapter.ts"],"sourcesContent":["import type { ModelIdentity, ModelResult } from './model.js';\nimport type { ChangeBatch } from './change.js';\n\nexport type Authorization = object;\n\nexport const ROOM_CONTRACT_VERSION = 1;\n\nexport const VERSION_1_CAPABILITIES = [\n 'stable-file-ids',\n 'ranked-provider-search',\n 'room-version-notifications',\n 'room-history',\n 'provider-actions',\n] as const;\n\nexport type MdModelIdentity = {\n identity: string;\n version: string;\n};\n\nexport type TypedSelection = {\n roots: readonly string[];\n attachedModel: ModelIdentity | null;\n};\n\nexport type OperationScopes = {\n read: readonly string[];\n sync: readonly string[];\n write: readonly string[];\n delete: readonly string[];\n};\nexport type ReplicaAdmission = { selection: string; admission: 'admitted' | 'unavailable' };\n\nexport type DiscoveredRoom = {\n collectionRoot: string;\n name: string;\n locator: string;\n roomVersion: string;\n operations: OperationScopes;\n replica: ReplicaAdmission;\n attachedModel: ModelIdentity | null;\n typedSelection?: TypedSelection;\n providerOwnedPaths: readonly string[];\n};\n\nexport type Capability = {\n name: string;\n limits?: readonly ProviderLimit[];\n actions?: readonly ActionDeclaration[];\n conversationCards?: ConversationCards;\n};\n\nexport type ConversationCards = {\n locator: string;\n type: string;\n identity: string;\n agent: string;\n};\n\nexport type ConversationAction =\n | 'conversation.create'\n | 'conversation.send'\n | 'conversation.answer'\n | 'conversation.interrupt'\n | 'conversation.kill'\n | 'conversation.cancel'\n | 'conversation.delete'\n | 'conversation.history';\n\nexport type ConversationMessage = {\n turn: string;\n message: unknown;\n};\n\nexport type ConversationEvent =\n | { kind: 'growing-text'; conversation: string; turn: string; text: string }\n | { kind: 'accepted-message'; conversation: string; message: ConversationMessage }\n | { kind: 'session-summary'; conversation: string; summary: unknown };\n\nexport type ViewedConversations = {\n view(conversations: readonly string[]): void;\n observe(notify: (event: ConversationEvent) => void): () => void;\n};\n\nexport type ActionDeclaration = {\n name: string;\n inputShape: unknown;\n resultKind: unknown;\n};\n\nexport type ProviderLimit = {\n name: string;\n value?: number | string;\n};\n\nexport type HistoryRetention =\n | { kind: 'duration'; seconds: number }\n | { kind: 'no-declared-time-bound' };\n\nexport type Retention = {\n history: HistoryRetention;\n outcome: number;\n refreshHorizon: number;\n};\n\nexport type Discovery = {\n kind: 'discovery';\n supportedVersions: readonly number[];\n mdModel: MdModelIdentity;\n rooms: readonly DiscoveredRoom[];\n capabilities: readonly Capability[];\n providerLimits: readonly ProviderLimit[];\n retention: Retention;\n};\n\nexport type TransportUncertainty = { kind: 'transport-uncertainty' };\nexport type RoomNotReadable = { kind: 'room-not-readable'; locator: string };\nexport type RevokedAuthorization = { kind: 'revoked-authorization' };\n\nexport type ProviderRefusal = {\n code: string;\n fields: Readonly<Record<string, unknown>>;\n};\n\nexport type ScopedRefusal = ProviderRefusal & {\n kind: 'scoped-refusal';\n locator: string;\n scope: 'content' | 'sync' | 'model' | 'operation' | 'undisclosed';\n};\nexport type AdapterFailure =\n | TransportUncertainty\n | RoomNotReadable\n | RevokedAuthorization\n | ScopedRefusal;\n\nexport type ContractUnavailable = ProviderRefusal & { kind: 'contract-unavailable' };\n\nexport type DiscoverResult =\n | Discovery\n | TransportUncertainty\n | RevokedAuthorization\n | ContractUnavailable;\n\nexport type PageToken = string;\n\nexport type BootstrapRequest = {\n locator: string;\n selection: string;\n pageToken?: PageToken;\n};\n\nexport type BootstrapPage = {\n kind: 'bootstrap';\n roomVersion: string;\n documents: Readonly<Record<string, string>>;\n revisions: Readonly<Record<string, string>>;\n binaryTargets: readonly string[];\n pageToken?: PageToken;\n};\n\nexport type BootstrapResult = BootstrapPage | AdapterFailure;\n\nexport type RefreshRequest = {\n locator: string;\n selection: string;\n fromRoomVersion: string;\n pageToken?: PageToken;\n};\n\nexport type RefreshPage = {\n kind: 'net-advancement';\n roomVersion: string;\n documents: Readonly<Record<string, string>>;\n revisions: Readonly<Record<string, string>>;\n binaryTargets: readonly string[];\n removals: readonly string[];\n pageToken?: PageToken;\n};\n\nexport type RefreshResult =\n | { kind: 'still-current' }\n | RefreshPage\n | { kind: 'beyond-horizon' }\n | AdapterFailure;\n\nexport type MutationRequest = {\n locator: string;\n changeBatch: ChangeBatch;\n};\n\nexport type RetryableRefusal = ProviderRefusal & {\n kind: 'retryable-refusal';\n reset?: string;\n};\n\nexport type MutationResult =\n | {\n kind: 'accepted';\n roomVersion: string;\n documents: Readonly<Record<string, string>>;\n revisions: Readonly<Record<string, string>>;\n removals: readonly string[];\n author?: string;\n time?: string;\n }\n | (ProviderRefusal & {\n kind: 'conflicted';\n roomVersion?: string;\n affected: Readonly<Record<string, string>>;\n })\n | (ProviderRefusal & {\n kind: 'rejected';\n affected: Readonly<Record<string, string>>;\n })\n | RetryableRefusal\n | { kind: 'expired' }\n | AdapterFailure;\n\nexport type HistoryRevision = {\n revision: string;\n author: string;\n time: string;\n};\n\nexport type HistoryRequest = {\n locator: string;\n path: string;\n revision?: string;\n pageToken?: PageToken;\n};\n\nexport type HistoryResult =\n | {\n kind: 'history';\n revisions: readonly HistoryRevision[];\n pageToken?: PageToken;\n }\n | {\n kind: 'revision';\n content: string;\n }\n | { kind: 'no-history' }\n | AdapterFailure;\n\nexport type ActionRequest = {\n name: string;\n input: unknown;\n};\n\nexport type ActionResult =\n | { kind: 'action'; result: unknown }\n | (ProviderRefusal & { kind: 'rejected' })\n | AdapterFailure;\n\nexport type ModelRequest =\n | { locator: string; attached: 'collection'; collectionRoot: string; model: ModelIdentity | null }\n | {\n locator: string;\n attached: 'typed-selection';\n roots: readonly string[];\n model: ModelIdentity | null;\n };\n\nexport type RoomVersionNotification = {\n locator: string;\n roomVersion: string;\n};\n\nexport type SelectedRooms = {\n select(locators: readonly string[]): void;\n observe(notify: (notification: RoomVersionNotification) => void): () => void;\n};\n\nexport type Adapter = {\n model(authorization: Authorization, request: ModelRequest): Promise<ModelResult>;\n authorize(): Promise<Authorization>;\n discover(authorization: Authorization): Promise<DiscoverResult>;\n bootstrap(authorization: Authorization, request: BootstrapRequest): Promise<BootstrapResult>;\n refresh(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;\n mutate(authorization: Authorization, request: MutationRequest): Promise<MutationResult>;\n history(authorization: Authorization, request: HistoryRequest): Promise<HistoryResult>;\n action(authorization: Authorization, request: ActionRequest): Promise<ActionResult>;\n roomVersions?: SelectedRooms;\n conversations?: ViewedConversations;\n};\n"],"names":["ROOM_CONTRACT_VERSION","VERSION_1_CAPABILITIES"],"mappings":"AAKA,OAAO,MAAMA,wBAAwB,EAAE;AAEvC,OAAO,MAAMC,yBAAyB;IACpC;IACA;IACA;IACA;IACA;CACD,CAAU"}
|
package/dist/bootstrap.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime/src/bootstrap.ts"],"sourcesContent":["import type { AttachedModelBinding } from './model.js';\nimport type { ModelState } from './model.js';\nimport type { Adapter, AdapterFailure, Authorization, DiscoveredRoom } from './adapter.js';\nimport { readStaged, type ConfirmedLayer } from './replica.js';\nimport { unconfirmed, type Unconfirmed } from './transfer.js';\n\nexport type BootstrapOutcome =\n | { kind: 'staged'; confirmed: ConfirmedLayer }\n | Unconfirmed\n | AdapterFailure;\n\nexport async function bootstrapRoom(\n adapter: Adapter,\n authorization: Authorization,\n room: DiscoveredRoom,\n models: { collection: ModelState; selection: ModelState },\n binding: AttachedModelBinding | null,\n): Promise<BootstrapOutcome> {\n const first = await adapter.bootstrap(authorization, {\n locator: room.locator,\n selection: room.replica.selection,\n });\n if (first.kind !== 'bootstrap') return first;\n const roomVersion = first.roomVersion;\n const documents: Record<string, string> = { ...first.documents };\n const revisions: Record<string, string> = { ...first.revisions };\n const binaryTargets = new Set(first.binaryTargets);\n let pageToken = first.pageToken;\n while (pageToken !== undefined) {\n const page = await adapter.bootstrap(authorization, {\n locator: room.locator,\n selection: room.replica.selection,\n pageToken,\n });\n if (page.kind !== 'bootstrap') return page;\n if (page.roomVersion !== roomVersion) return unconfirmed;\n Object.assign(documents, page.documents);\n Object.assign(revisions, page.revisions);\n for (const target of page.binaryTargets) binaryTargets.add(target);\n pageToken = page.pageToken;\n }\n const confirmed = readStaged(\n {\n locator: room.locator,\n collectionRoot: room.collectionRoot,\n name: room.name,\n operations: room.operations,\n replica: room.replica,\n attachedModel: room.attachedModel,\n model: models.collection,\n typedSelection: room.typedSelection ?? null,\n selectionModel: models.selection,\n providerOwnedPaths: room.providerOwnedPaths,\n roomVersion,\n documents,\n binaryTargets: [...binaryTargets].sort(),\n revisions,\n },\n binding,\n );\n return confirmed === null ? unconfirmed : { kind: 'staged', confirmed };\n}\n"],"names":["readStaged","unconfirmed","bootstrapRoom","adapter","authorization","room","models","binding","first","bootstrap","locator","selection","replica","kind","roomVersion","documents","revisions","binaryTargets","Set","pageToken","undefined","page","Object","assign","target","add","confirmed","collectionRoot","name","operations","attachedModel","model","collection","typedSelection","selectionModel","providerOwnedPaths","sort"],"mappings":"AAGA,SAASA,UAAU,QAA6B,eAAe;AAC/D,SAASC,WAAW,QAA0B,gBAAgB;AAO9D,OAAO,eAAeC,cACpBC,OAAgB,EAChBC,aAA4B,EAC5BC,IAAoB,EACpBC,MAAyD,EACzDC,OAAoC;IAEpC,MAAMC,QAAQ,MAAML,QAAQM,SAAS,CAACL,eAAe;QACnDM,SAASL,KAAKK,OAAO;Q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QAAUa;IAAU;AACxE"}
|
package/dist/change.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime/src/change.ts"],"sourcesContent":["export type Change =\n | {\n readonly kind: 'field';\n readonly path: string;\n readonly name: string;\n readonly value: unknown;\n }\n | {\n readonly kind: 'section';\n readonly path: string;\n readonly name: string;\n readonly value: string;\n }\n | { readonly kind: 'preamble'; readonly path: string; readonly value: string }\n | {\n readonly kind: 'create';\n readonly path: string;\n readonly fields: Readonly<Record<string, unknown>>;\n readonly sections: Readonly<Record<string, string>>;\n }\n | { readonly kind: 'replace'; readonly path: string; readonly content: string }\n | { readonly kind: 'move'; readonly path: string; readonly to: string }\n | { readonly kind: 'remove'; readonly path: string };\n\nexport type Precondition =\n | {\n readonly kind: 'field';\n readonly path: string;\n readonly name: string;\n readonly value: unknown;\n }\n | {\n readonly kind: 'section';\n readonly path: string;\n readonly name: string;\n readonly value: string;\n }\n | { readonly kind: 'preamble'; readonly path: string; readonly value: string }\n | { readonly kind: 'revision'; readonly path: string; readonly revision: string }\n | { readonly kind: 'present'; readonly path: string }\n | { readonly kind: 'absent'; readonly path: string };\n\nexport type ChangeBatch = {\n validation?: import('./model.js').ValidationReceipt;\n readonly id: string;\n readonly baseRoomVersion: string;\n readonly changes: readonly Change[];\n readonly preconditions: readonly Precondition[];\n};\n\nfunction frozen<T>(value: T): T {\n if (Array.isArray(value)) return Object.freeze(value.map((item) => frozen(item))) as T;\n if (value === null || typeof value !== 'object') return value;\n const copy: Record<string, unknown> = {};\n for (const [name, item] of Object.entries(value)) copy[name] = frozen(item);\n return Object.freeze(copy) as T;\n}\n\nexport function immutable(batch: ChangeBatch): ChangeBatch {\n return frozen(batch);\n}\n"],"names":["frozen","value","Array","isArray","Object","freeze","map","item","copy","name","entries","immutable","batch"],"mappings":"AAkDA,SAASA,OAAUC,KAAQ;IACzB,IAAIC,MAAMC,OAAO,CAACF,QAAQ,OAAOG,OAAOC,MAAM,CAACJ,MAAMK,GAAG,CAAC,CAACC,OAASP,OAAOO;IAC1E,IAAIN,UAAU,QAAQ,OAAOA,UAAU,UAAU,OAAOA;IACxD,MAAMO,OAAgC,CAAC;IACvC,KAAK,MAAM,CAACC,MAAMF,KAAK,IAAIH,OAAOM,OAAO,CAACT,OAAQO,IAAI,CAACC,KAAK,GAAGT,OAAOO;IACtE,OAAOH,OAAOC,MAAM,CAACG;AACvB;AAEA,OAAO,SAASG,UAAUC,KAAkB;IAC1C,OAAOZ,OAAOY;AAChB"}
|
package/dist/client.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime/src/client.ts"],"sourcesContent":["import type { QueryOptions, QueryResult } from '@agentshouse/query';\nimport type { Change } from './change.js';\nimport type {\n AppRoom,\n ConnectionRefusal,\n DraftEntry,\n HistoryQuery,\n RoomTypes,\n SaveResult,\n} from './connection.js';\nimport type { HistoryResult } from './adapter.js';\nimport type { ConversationEntry, ConversationView, UnsentInstruction } from './conversation.js';\nimport type { CallResult, QueueEntry, SubmissionOutcome } from './outcome.js';\nimport type { SyncStatus } from './status.js';\nimport {\n answer,\n AUTHORIZATION_ENDED,\n carried,\n envelope,\n PROTOCOL_MISMATCH,\n type RuntimePort,\n type WireMember,\n type WireRequest,\n type WireTopic,\n} from './wire.js';\n\nexport type MdRuntimeClient = {\n rooms(): Promise<readonly AppRoom[]>;\n query(options?: QueryOptions): Promise<QueryResult>;\n types(locator: string): Promise<RoomTypes>;\n syncStatus(): Promise<SyncStatus>;\n draft: {\n list(): Promise<readonly DraftEntry[]>;\n read(locator: string, path: string): Promise<unknown>;\n replace(locator: string, path: string, content: unknown): Promise<void>;\n discard(locator: string, path: string): Promise<void>;\n };\n save(locator: string, changes: readonly Change[], replacing?: string): Promise<SaveResult>;\n outcome(identifier: string): Promise<SubmissionOutcome | null>;\n queue: { discard(locator: string, identifier: string): Promise<void> };\n presentation: {\n read(): Promise<unknown>;\n write(value: unknown): Promise<void>;\n };\n conversation: {\n list(): Promise<readonly ConversationEntry[]>;\n read(conversation: string): Promise<ConversationView>;\n older(conversation: string): Promise<CallResult | null>;\n compose(conversation: string, instruction: UnsentInstruction): Promise<void>;\n discard(conversation: string): Promise<void>;\n create(input: unknown): Promise<CallResult>;\n send(conversation: string): Promise<CallResult>;\n answer(conversation: string, answer: unknown): Promise<CallResult>;\n interrupt(conversation: string): Promise<CallResult>;\n kill(conversation: string): Promise<CallResult>;\n cancel(conversation: string, turn: string): Promise<CallResult>;\n delete(conversation: string): Promise<CallResult>;\n };\n history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryResult>;\n call(name: string, input: unknown): Promise<CallResult>;\n log(): Promise<string>;\n storageLoss(): Promise<string | null>;\n persistence(): Promise<boolean>;\n observe: {\n (topic: 'rooms', listener: (rooms: readonly AppRoom[]) => void): Promise<() => void>;\n (\n topic: 'connection-refusal',\n listener: (refusal: ConnectionRefusal | null) => void,\n ): Promise<() => void>;\n (topic: 'storage-loss', listener: (statement: string | null) => void): Promise<() => void>;\n (topic: 'sync-status', listener: (status: SyncStatus) => void): Promise<() => void>;\n (\n topic: 'query',\n query: QueryOptions,\n listener: (result: QueryResult) => void,\n ): Promise<() => void>;\n (\n topic: 'queue',\n locator: string,\n listener: (entries: readonly QueueEntry[]) => void,\n ): Promise<() => void>;\n (topic: 'drafts', listener: (drafts: readonly DraftEntry[]) => void): Promise<() => void>;\n (topic: 'presentation', listener: (value: unknown) => void): Promise<() => void>;\n (\n topic: 'conversation',\n conversation: string,\n listener: (view: ConversationView) => void,\n ): Promise<() => void>;\n };\n reauthorize(): Promise<void>;\n};\n\nexport function connectMdRuntime(port: RuntimePort): MdRuntimeClient {\n let sequence = 0;\n let refusal: ConnectionRefusal | null = null;\n let ended = false;\n const calls = new Map<\n number,\n { settle: (value: unknown) => void; fail: (error: Error) => void }\n >();\n const acks = new Map<number, { settle: () => void; fail: (error: Error) => void }>();\n const listeners = new Map<number, { topic: WireTopic; notify: (value: unknown) => void }>();\n\n const send = (message: WireRequest) => {\n port.postMessage(envelope(message));\n };\n\n function refuse(reported: ConnectionRefusal) {\n refusal = reported;\n for (const waiting of acks.values()) waiting.settle();\n acks.clear();\n const failure = new Error(reported.reason);\n for (const waiting of calls.values()) waiting.fail(failure);\n calls.clear();\n for (const listener of listeners.values()) {\n if (listener.topic === 'connection-refusal') listener.notify(reported);\n }\n }\n\n function end() {\n ended = true;\n const failure = new Error(AUTHORIZATION_ENDED);\n for (const waiting of acks.values()) waiting.fail(failure);\n acks.clear();\n for (const waiting of calls.values()) waiting.fail(failure);\n calls.clear();\n listeners.clear();\n }\n\n port.addEventListener('message', (event) => {\n const wire = carried(event.data);\n if (wire === null) return;\n if (!wire.matching) {\n refuse(PROTOCOL_MISMATCH);\n return;\n }\n const message = answer(wire.message);\n if (message === null) return;\n if (message.kind === 'refusal') {\n refuse(message.refusal);\n return;\n }\n if (message.kind === 'ended') {\n end();\n return;\n }\n if (message.kind === 'event') {\n listeners.get(message.id)?.notify(message.value);\n return;\n }\n const subscribing = acks.get(message.id);\n if (subscribing !== undefined) {\n acks.delete(message.id);\n if (message.kind === 'failure') {\n listeners.delete(message.id);\n subscribing.fail(new Error(message.message));\n } else subscribing.settle();\n return;\n }\n const waiting = calls.get(message.id);\n if (waiting === undefined) return;\n calls.delete(message.id);\n if (message.kind === 'failure') waiting.fail(new Error(message.message));\n else waiting.settle(message.value);\n });\n port.start();\n send({ kind: 'hello' });\n\n function ask<T>(member: WireMember, input: readonly unknown[]): Promise<T> {\n if (ended) return Promise.reject(new Error(AUTHORIZATION_ENDED));\n if (refusal !== null) return Promise.reject(new Error(refusal.reason));\n const id = (sequence += 1);\n return new Promise<T>((settle, fail) => {\n calls.set(id, { settle: settle as (value: unknown) => void, fail });\n send({ kind: 'call', id, member, input });\n });\n }\n\n function watch(\n topic: WireTopic,\n input: readonly unknown[],\n notify: (value: unknown) => void,\n ): Promise<() => void> {\n if (ended) return Promise.reject(new Error(AUTHORIZATION_ENDED));\n const id = (sequence += 1);\n listeners.set(id, { topic, notify });\n const end = () => {\n if (!listeners.delete(id)) return;\n if (refusal === null) send({ kind: 'stop', id });\n };\n if (refusal !== null) {\n if (topic === 'connection-refusal') notify(refusal);\n return Promise.resolve(end);\n }\n return new Promise<() => void>((settle, fail) => {\n acks.set(id, { settle: () => settle(end), fail });\n send({ kind: 'observe', id, topic, input });\n });\n }\n\n return {\n rooms: () => ask<readonly AppRoom[]>('rooms', []),\n query: (options?: QueryOptions) => ask<QueryResult>('query', [options]),\n types: (locator: string) => ask<RoomTypes>('types', [locator]),\n syncStatus: () => ask<SyncStatus>('syncStatus', []),\n draft: {\n list: () => ask<readonly DraftEntry[]>('draft.list', []),\n read: (locator: string, path: string) => ask<unknown>('draft.read', [locator, path]),\n replace: (locator: string, path: string, content: unknown) =>\n ask<void>('draft.replace', [locator, path, content]),\n discard: (locator: string, path: string) => ask<void>('draft.discard', [locator, path]),\n },\n save: (locator: string, changes: readonly Change[], replacing?: string) =>\n ask<SaveResult>('save', [locator, changes, replacing]),\n outcome: (identifier: string) => ask<SubmissionOutcome | null>('outcome', [identifier]),\n queue: {\n discard: (locator: string, identifier: string) =>\n ask<void>('queue.discard', [locator, identifier]),\n },\n presentation: {\n read: () => ask<unknown>('presentation.read', []),\n write: (value: unknown) => ask<void>('presentation.write', [value]),\n },\n conversation: {\n list: () => ask<readonly ConversationEntry[]>('conversation.list', []),\n read: (conversation: string) => ask<ConversationView>('conversation.read', [conversation]),\n older: (conversation: string) => ask<CallResult | null>('conversation.older', [conversation]),\n compose: (conversation: string, instruction: UnsentInstruction) =>\n ask<void>('conversation.compose', [conversation, instruction]),\n discard: (conversation: string) => ask<void>('conversation.discard', [conversation]),\n create: (input: unknown) => ask<CallResult>('conversation.create', [input]),\n send: (conversation: string) => ask<CallResult>('conversation.send', [conversation]),\n answer: (conversation: string, answer: unknown) =>\n ask<CallResult>('conversation.answer', [conversation, answer]),\n interrupt: (conversation: string) =>\n ask<CallResult>('conversation.interrupt', [conversation]),\n kill: (conversation: string) => ask<CallResult>('conversation.kill', [conversation]),\n cancel: (conversation: string, turn: string) =>\n ask<CallResult>('conversation.cancel', [conversation, turn]),\n delete: (conversation: string) => ask<CallResult>('conversation.delete', [conversation]),\n },\n history: (locator: string, path: string, query?: HistoryQuery) =>\n ask<HistoryResult>('history', [locator, path, query]),\n call: (name: string, input: unknown) => ask<CallResult>('call', [name, input]),\n log: () => ask<string>('log', []),\n storageLoss: () => ask<string | null>('storageLoss', []),\n persistence: () => ask<boolean>('persistence', []),\n observe(\n topic: WireTopic,\n second: QueryOptions | string | ((value: never) => void),\n third?: (value: never) => void,\n ) {\n const positional = topic === 'query' || topic === 'queue' || topic === 'conversation';\n const notify = (positional ? third : second) as (value: unknown) => void;\n return watch(topic, positional ? [second] : [], notify);\n },\n reauthorize: () => ask<void>('reauthorize', []),\n };\n}\n\nexport type { RuntimePort } from './wire.js';\n"],"names":["answer","AUTHORIZATION_ENDED","carried","envelope","PROTOCOL_MISMATCH","connectMdRuntime","port","sequence","refusal","ended","calls","Map","acks","listeners","send","message","postMessage","refuse","reported","waiting","values","settle","clear","failure","Error","reason","fail","listener","topic","notify","end","addEventListener","event","wire","data","matching","kind","get","id","value","subscribing","undefined","delete","start","ask","member","input","Promise","reject","set","watch","resolve","rooms","query","options","types","locator","syncStatus","draft","list","read","path","replace","content","discard","save","changes","replacing","outcome","identifier","queue","presentation","write","conversation","older","compose","instruction","create","interrupt","kill","cancel","turn","history","call","name","log","storageLoss","persistence","observe","second","third","positional","reauthorize"],"mappings":"AAcA,SACEA,MAAM,EACNC,mBAAmB,EACnBC,OAAO,EACPC,QAAQ,EACRC,iBAAiB,QAKZ,YAAY;AAoEnB,OAAO,SAASC,iBAAiBC,IAAiB;IAChD,IAAIC,WAAW;IACf,IAAIC,UAAoC;IACxC,IAAIC,QAAQ;IACZ,MAAMC,QAAQ,IAAIC;IAIlB,MAAMC,OAAO,IAAID;IACjB,MAAME,YAAY,IAAIF;IAE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AU;YACvE,MAAMC,SAAU8D,aAAaD,QAAQD;YACrC,OAAOvC,MAAMtB,OAAO+D,aAAa;gBAACF;aAAO,GAAG,EAAE,EAAE5D;QAClD;QACA+D,aAAa,IAAMhD,IAAU,eAAe,EAAE;IAChD;AACF"}
|
package/dist/collection.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime/src/collection.ts"],"sourcesContent":["import { parse, validate, VERSION, type Document, type Validation } from '@agentshouse/mdmodel';\nimport type { Selector } from '@agentshouse/query';\nimport { beneath, normalize } from './paths.js';\nimport type { AttachedModelBinding, ModelState } from './model.js';\nimport type { MdModelIdentity } from './adapter.js';\n\nexport const MD_MODEL: MdModelIdentity = { identity: '@agentshouse/mdmodel', version: VERSION };\n\nexport const PRESENTED: Selector = { path: { $regex: '\\\\.md$' } };\n\nexport type MdType = {\n name: string;\n path: string;\n fields: Readonly<Record<string, unknown>>;\n sections: Readonly<Record<string, unknown>>;\n};\n\nexport type Collection = {\n documents: Readonly<Record<string, Document>>;\n composition: Composition;\n};\n\nexport type Composition = {\n collectionRoot: string;\n model: ModelState;\n selection: { roots: readonly string[]; model: ModelState } | null;\n};\n\nfunction selected(composition: Composition, path: string): boolean {\n return (\n composition.selection !== null &&\n composition.selection.roots.some((root) => beneath(root, path))\n );\n}\n\nexport function governing(composition: Composition, path: string): ModelState {\n return composition.selection !== null && selected(composition, path)\n ? composition.selection.model\n : composition.model;\n}\n\nexport function typesAt(composition: Composition, path: string): readonly MdType[] {\n const model = governing(composition, path);\n return model.status === 'unavailable' ? [] : model.types;\n}\n\nexport function parseCollection(\n text: Readonly<Record<string, string>>,\n composition: Composition,\n): Collection {\n const documents: Record<string, Document> = {};\n for (const path of Object.keys(text).sort()) {\n const parsed = parse(text[path], path);\n if (parsed.ok) documents[path] = parsed.document;\n }\n return { documents, composition };\n}\n\nexport function readCollection(\n text: Readonly<Record<string, string>>,\n composition: Composition,\n): Collection | null {\n if (!validRoot(composition.collectionRoot)) return null;\n const collection = parseCollection(text, composition);\n if (Object.keys(collection.documents).length !== Object.keys(text).length) return null;\n if (\n Object.entries(collection.documents).some(\n ([path, document]) =>\n !member(path, composition.collectionRoot) &&\n !selected(composition, path) &&\n document.type !== undefined &&\n document.type !== 'any',\n )\n )\n return null;\n return collection;\n}\n\nexport function validRoot(root: unknown): root is string {\n return typeof root === 'string' && normalize(root) === root;\n}\n\nfunction member(path: string, root: string): boolean {\n return root === '' || path.startsWith(`${root}/`);\n}\n\ntype Refusal = Extract<Validation, { verdict: 'refuse' }> & { source?: 'content' | 'model' };\n\nfunction validateAgainst(\n documents: Readonly<Record<string, string>>,\n binaryTargets: readonly string[],\n prefix: string,\n model: ModelState,\n binding: AttachedModelBinding | null,\n): Validation & { source?: 'content' | 'model' } {\n if (model.status === 'unavailable' || binding === null) {\n const typed = Object.entries(documents).find(([, content]) => {\n const parsed = parse(content);\n return parsed.ok && parsed.document.type !== undefined && parsed.document.type !== 'any';\n });\n if (typed !== undefined)\n return {\n verdict: 'refuse',\n rule: 'model-unavailable',\n file: `${prefix}${typed[0]}`,\n version: VERSION,\n };\n return validate(documents, { binaryTargets });\n }\n const verdict = binding.validate({ model: model.snapshot, documents, binaryTargets });\n if (verdict.verdict === 'refuse' && verdict.source === 'model') return verdict;\n if (verdict.verdict === 'accept') return verdict;\n return {\n ...verdict,\n file: `${prefix}${verdict.file}`,\n ...(verdict.referrers === undefined\n ? {}\n : { referrers: verdict.referrers.map((path) => `${prefix}${path}`) }),\n };\n}\n\nexport function validateCollection(\n text: Readonly<Record<string, string>>,\n binaryTargets: readonly string[],\n composition: Composition,\n binding: AttachedModelBinding | null,\n): Validation & { source?: 'content' | 'model' } {\n const prefix = composition.collectionRoot === '' ? '' : `${composition.collectionRoot}/`;\n const collection: Record<string, string> = {};\n const selection: Record<string, string> = {};\n for (const [path, content] of Object.entries(text)) {\n if (member(path, composition.collectionRoot)) {\n collection[path.slice(prefix.length)] = content;\n continue;\n }\n if (selected(composition, path)) {\n selection[path] = content;\n continue;\n }\n const parsed = parse(content, path);\n if (!parsed.ok) return { verdict: 'refuse', ...parsed.refusal };\n if (Object.hasOwn(parsed.document.fields, 'type') && parsed.document.fields.type !== 'any') {\n return { verdict: 'refuse', rule: 'outside-collection-type', file: path, version: VERSION };\n }\n }\n const verdicts = [\n validateAgainst(\n collection,\n binaryTargets\n .filter((path) => member(path, composition.collectionRoot))\n .map((path) => path.slice(prefix.length)),\n prefix,\n composition.model,\n binding,\n ),\n ];\n if (composition.selection !== null) {\n verdicts.push(\n validateAgainst(\n selection,\n binaryTargets.filter((path) => selected(composition, path)),\n '',\n composition.selection.model,\n binding,\n ),\n );\n }\n const refusals = verdicts.filter((verdict): verdict is Refusal => verdict.verdict === 'refuse');\n if (refusals.length === 0) return verdicts[0];\n return refusals.find((refusal) => refusal.rule !== 'model-unavailable') ?? refusals[0];\n}\n"],"names":["parse","validate","VERSION","beneath","normalize","MD_MODEL","identity","version","PRESENTED","path","$regex","selected","composition","selection","roots","some","root","governing","model","typesAt","status","types","parseCollection","text","documents","Object","keys","sort","parsed","ok","document","readCollection","validRoot","collectionRoot","collection","length","entries","member","type","undefined","startsWith","validateAgainst","binaryTargets","prefix","binding","typed","find","content","verdict","rule","file","snapshot","source","referrers","map","validateCollection","slice","refusal","hasOwn","fields","verdicts","filter","push","refusals"],"mappings":"AAAA,SAASA,KAAK,EAAEC,QAAQ,EAAEC,OAAO,QAAwC,uBAAuB;AAEhG,SAASC,OAAO,EAAEC,SAAS,QAAQ,aAAa;AAIhD,OAAO,MAAMC,WAA4B;IAAEC,UAAU;IAAwBC,SAASL;AAAQ,EAAE;AAEhG,OAAO,MAAMM,YAAsB;IAAEC,MAAM;QAAEC,QAAQ;IAAS;AAAE,EAAE;AAoBlE,SAASC,SAASC,WAAwB,EAAEH,IAAY;IACtD,OACEG,YAAYC,SAAS,KAAK,QAC1BD,YAAYC,SAAS,CAACC,KAAK,CAACC,IAAI,CAAC,CAACC,OAASb,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