@agentshouse/mdruntime 0.1.0-cd507e16e5fc0 → 0.1.0-cd71aba4d0215
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 +8 -8
- package/dist/acceptance.d.ts +0 -3
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +74 -145
- package/dist/act-lanes.d.ts +33 -0
- package/dist/act-lanes.d.ts.map +1 -0
- package/dist/act-lanes.js +177 -0
- package/dist/actions.d.ts +7 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +40 -30
- package/dist/adapter.d.ts +27 -45
- package/dist/adapter.d.ts.map +1 -1
- package/dist/bootstrap.d.ts +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +6 -19
- package/dist/change-set.d.ts +4 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +6 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +4 -2
- package/dist/client.d.ts +7 -12
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +29 -14
- package/dist/collection.d.ts +22 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +12 -2
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +15 -21
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +26 -16
- package/dist/conversation-live.d.ts +8 -6
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +7 -6
- package/dist/conversation.d.ts +23 -10
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +127 -102
- package/dist/declaration.d.ts +10 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +24 -0
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +18 -40
- package/dist/durability.d.ts +3 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/expectation.d.ts +4 -2
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +33 -11
- package/dist/failure.d.ts +3 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +6 -0
- package/dist/host.d.ts +17 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +39 -9
- package/dist/index.d.ts +9 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/install.d.ts +1 -3
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +48 -65
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +38 -27
- package/dist/listing.d.ts +6 -11
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +25 -62
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +3 -3
- package/dist/locks.d.ts +2 -4
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +10 -38
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +10 -21
- package/dist/media.d.ts +1 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +4 -4
- package/dist/memory.d.ts +4 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +38 -21
- package/dist/messages.d.ts +0 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +13 -31
- package/dist/model.d.ts +0 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -5
- package/dist/models.d.ts +4 -8
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +97 -136
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +12 -17
- package/dist/opened.d.ts +1 -1
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +5 -5
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +6 -4
- package/dist/outcome.d.ts +3 -0
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +15 -0
- package/dist/overlay.d.ts +2 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +32 -21
- package/dist/page-metadata.d.ts +8 -0
- package/dist/page-metadata.d.ts.map +1 -0
- package/dist/page-metadata.js +19 -0
- package/dist/parts.d.ts +3 -51
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +14 -111
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +22 -15
- package/dist/presence.d.ts +52 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +220 -0
- package/dist/queries.d.ts +1 -1
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +5 -7
- package/dist/query.d.ts +0 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.js +1 -1
- package/dist/queue.d.ts +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +455 -0
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +27 -8
- package/dist/react.d.ts +11 -0
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +15 -1
- package/dist/reads.d.ts +3 -1
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +9 -2
- package/dist/recovery.d.ts +3 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +29 -7
- package/dist/refresh.js +2 -2
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +5 -4
- package/dist/replica.d.ts +5 -11
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +13 -15
- package/dist/retried.d.ts +30 -0
- package/dist/retried.d.ts.map +1 -0
- package/dist/retried.js +72 -0
- package/dist/room-draft.d.ts +4 -6
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +36 -52
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +17 -16
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +3 -4
- package/dist/runtime.d.ts +9 -16
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +41 -90
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +233 -116
- package/dist/saves.d.ts +2 -40
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +107 -702
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +2 -3
- package/dist/shared.d.ts +0 -5
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +4 -90
- package/dist/shown.d.ts +4 -3
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +26 -31
- package/dist/socket/lanes.d.ts +2 -1
- package/dist/socket/lanes.d.ts.map +1 -1
- package/dist/socket/lanes.js +5 -2
- package/dist/socket/session.d.ts +0 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket.d.ts +2 -4
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +4 -8
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +5 -4
- package/dist/store/records.d.ts +3 -3
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +4 -5
- package/dist/store/space.d.ts +1 -1
- package/dist/store/space.d.ts.map +1 -1
- package/dist/store/space.js +0 -2
- package/dist/store/watchers.js +1 -2
- package/dist/store.d.ts +10 -5
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +38 -13
- package/dist/stored.d.ts +1 -1
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +6 -6
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +8 -8
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +86 -78
- package/dist/tables.d.ts +0 -5
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +8 -11
- package/dist/tallies.js +5 -5
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +2 -2
- package/dist/wire.d.ts +40 -4
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +12 -3
- package/package.json +3 -2
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/job.d.ts +0 -33
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -54
- package/dist/socket/rooms.d.ts +0 -44
- package/dist/socket/rooms.d.ts.map +0 -1
- package/dist/socket/rooms.js +0 -90
- package/dist/store/fences.d.ts +0 -16
- package/dist/store/fences.d.ts.map +0 -1
- package/dist/store/fences.js +0 -26
package/dist/conversation.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type Part, type SessionState } from '@agentshouse/session-content';
|
|
2
|
+
import type { AgentEnvironment, ConversationEvent, ConversationMessage, ProcessCommand, SessionOption } from './adapter.js';
|
|
2
3
|
import { type ChangeSet } from './change-set.js';
|
|
3
4
|
import { type LiveConversations } from './conversation-live.js';
|
|
4
5
|
import { type ConversationHeld } from './conversation-row.js';
|
|
5
|
-
import type { OpenJob } from './job.js';
|
|
6
6
|
import type { Open } from './open.js';
|
|
7
7
|
import { type CallResult, type Offline } from './outcome.js';
|
|
8
|
+
import type { ChatRequest } from './source.js';
|
|
8
9
|
import type { CycleProgress } from './status.js';
|
|
9
10
|
import type { RuntimeStore } from './store.js';
|
|
10
11
|
export type ConversationState = Open<'working' | 'asking' | 'idle'>;
|
|
@@ -29,12 +30,13 @@ export type ConversationEntry = ConversationHeld & {
|
|
|
29
30
|
export type ConversationAgent = {
|
|
30
31
|
identity: string;
|
|
31
32
|
name: string;
|
|
33
|
+
cli?: string;
|
|
34
|
+
environment?: AgentEnvironment;
|
|
32
35
|
};
|
|
33
36
|
export type RunningTurn = {
|
|
34
37
|
turn: string;
|
|
35
38
|
started: string | null;
|
|
36
|
-
parts: readonly
|
|
37
|
-
context: TurnContext | null;
|
|
39
|
+
parts: readonly Part[];
|
|
38
40
|
};
|
|
39
41
|
export type ChatDraft = {
|
|
40
42
|
text: string;
|
|
@@ -61,25 +63,35 @@ export type ConversationView = {
|
|
|
61
63
|
commands: readonly ProcessCommand[];
|
|
62
64
|
options: readonly SessionOption[];
|
|
63
65
|
starting: string | null;
|
|
64
|
-
|
|
66
|
+
state: SessionState | null;
|
|
65
67
|
link: {
|
|
66
68
|
connected: boolean;
|
|
67
69
|
} | null;
|
|
70
|
+
deliveryWaiting: readonly string[];
|
|
68
71
|
deliveryUnknown: readonly string[];
|
|
69
72
|
chatDraft: (ChatDraft & {
|
|
70
73
|
readonly revision: string;
|
|
71
74
|
}) | null;
|
|
72
|
-
jobs: readonly OpenJob[];
|
|
73
75
|
};
|
|
76
|
+
export type RequestDecision = 'approve' | 'decline';
|
|
74
77
|
export type ConversationSurface = {
|
|
75
78
|
list(): Promise<readonly ConversationEntry[]>;
|
|
76
79
|
read(conversation: string, options?: ConversationRead): Promise<ConversationView>;
|
|
77
80
|
create(input: unknown): Promise<CallResult>;
|
|
78
81
|
send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
|
|
79
|
-
answer(conversation: string, answer: ConversationAnswer): Promise<CallResult>;
|
|
80
|
-
interrupt(conversation: string): Promise<CallResult>;
|
|
81
|
-
kill(conversation: string): Promise<CallResult>;
|
|
82
|
-
delete(conversation: string): Promise<CallResult>;
|
|
82
|
+
answer(conversation: string, answer: ConversationAnswer, operation: string): Promise<CallResult>;
|
|
83
|
+
interrupt(conversation: string, operation: string): Promise<CallResult>;
|
|
84
|
+
kill(conversation: string, operation: string): Promise<CallResult>;
|
|
85
|
+
delete(conversation: string, operation: string): Promise<CallResult>;
|
|
86
|
+
takeOut(conversation: string, message: string, operation: string): Promise<CallResult>;
|
|
87
|
+
decide(request: ChatRequest, decision: RequestDecision, operation: string): Promise<CallResult>;
|
|
88
|
+
rename(conversation: string, name: string, operation: string): Promise<CallResult>;
|
|
89
|
+
option(conversation: string, option: string, value: string | boolean, operation: string): Promise<CallResult>;
|
|
90
|
+
retry(conversation: string, message: string, operation: string): Promise<CallResult>;
|
|
91
|
+
pins(): Promise<readonly string[]>;
|
|
92
|
+
pin(figures: readonly string[]): Promise<void>;
|
|
93
|
+
openedTurns(): Promise<Readonly<Record<string, string>>>;
|
|
94
|
+
openTurn(conversation: string, turn: string): Promise<void>;
|
|
83
95
|
};
|
|
84
96
|
export type ConversationAnswer = {
|
|
85
97
|
interaction_id: string;
|
|
@@ -92,6 +104,7 @@ export type ChatDraftSurface = {
|
|
|
92
104
|
};
|
|
93
105
|
export declare function unheldView(conversation: string): ConversationView;
|
|
94
106
|
export declare const SESSION_STARTED = "Session started";
|
|
107
|
+
export declare const CATCHING_UP = "catching-up";
|
|
95
108
|
export declare const HISTORY_CONVERSATIONS = 64;
|
|
96
109
|
export declare function newChat(agent: string): string;
|
|
97
110
|
export type Asked = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../src/conversation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../src/conversation.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,IAAI,EACT,KAAK,YAAY,EAClB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAEV,gBAAgB,EAEhB,iBAAiB,EAEjB,mBAAmB,EAEnB,cAAc,EACd,aAAa,EAEd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAIL,KAAK,iBAAiB,EAEvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIzE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAW,KAAK,UAAU,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAMtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAqD,YAAY,EAAE,MAAM,YAAY,CAAC;AAGlG,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC,CAAC;AAEpE,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,GAAG;IACjD,YAAY,EAAE,MAAM,CAAC;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,CA8HjF;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,GAAG,gBAAgB,CA0B3E;AAED,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,YAAY,iBAKtF;AAED,wBAAsB,sBAAsB,CAAC,KAAK,EAAE,iBAAiB,iBAgCpE;AAED,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,aAAa,iBAyB3F;AAED,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,aAAa,iBAuB1F;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,iBAAiB,EACxB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,GACxC,MAAM,IAAI,CAmCZ;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,iBAAiB,EACxB,OAAO,EAAE,CAAC,OAAO,EAAE,SAAS,iBAAiB,EAAE,KAAK,IAAI,GACvD,MAAM,IAAI,CAIZ;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,iBAAiB,EACxB,OAAO,EAAE,CAAC,MAAM,EAAE,SAAS,iBAAiB,EAAE,KAAK,IAAI,GACtD,MAAM,IAAI,CAKZ;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,iBAAiB,EAAE,GAAG,EAAE,SAAS,GAAG,IAAI,CAEnF;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,iBAAiB,GAAG,IAAI,CA0BjG"}
|
package/dist/conversation.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { cursorOf, decodedCursor } from '@agentshouse/mdmodel';
|
|
2
|
+
import { applied, isTurn, standingState, } from '@agentshouse/session-content';
|
|
2
3
|
import { conversationChangeSet } from './change-set.js';
|
|
3
4
|
import { FACTS, QUIET, } from './conversation-live.js';
|
|
4
5
|
import { heldFacts } from './conversation-row.js';
|
|
5
|
-
import { runtimeError } from './failure.js';
|
|
6
|
+
import { runtimeError, uncaught } from './failure.js';
|
|
6
7
|
import { refusedForSpace } from './durability.js';
|
|
7
8
|
import { changeBatchIdentity, chatDraftRevision } from './identity.js';
|
|
8
9
|
import { OFFLINE } from './outcome.js';
|
|
9
|
-
import {
|
|
10
|
+
import { runningLine } from './parts.js';
|
|
11
|
+
import { record, text } from './read.js';
|
|
10
12
|
import { openQuestion, questionAsked } from './questions.js';
|
|
11
13
|
import { untilAnswered } from './recovery.js';
|
|
14
|
+
import { retrying } from './retried.js';
|
|
12
15
|
import { capped, FROM_START, messageOrder, precedes } from './windows.js';
|
|
13
16
|
export function unheldView(conversation) {
|
|
14
17
|
return {
|
|
@@ -21,15 +24,18 @@ export function unheldView(conversation) {
|
|
|
21
24
|
commands: [],
|
|
22
25
|
options: [],
|
|
23
26
|
starting: null,
|
|
24
|
-
|
|
27
|
+
state: null,
|
|
25
28
|
link: null,
|
|
29
|
+
deliveryWaiting: [],
|
|
26
30
|
deliveryUnknown: [],
|
|
27
31
|
chatDraft: null,
|
|
28
|
-
jobs: [],
|
|
29
32
|
};
|
|
30
33
|
}
|
|
31
34
|
export const SESSION_STARTED = 'Session started';
|
|
32
35
|
const NEW_CHAT = 'new:';
|
|
36
|
+
const LISTING = 'listing';
|
|
37
|
+
const AGENTS = 'agents';
|
|
38
|
+
export const CATCHING_UP = 'catching-up';
|
|
33
39
|
export const HISTORY_CONVERSATIONS = 64;
|
|
34
40
|
export function newChat(agent) {
|
|
35
41
|
return `${NEW_CHAT}${agent}`;
|
|
@@ -42,52 +48,15 @@ function creationOf(input) {
|
|
|
42
48
|
}
|
|
43
49
|
function startedTurn(turn, operation) {
|
|
44
50
|
if (operation.op === 'begin')
|
|
45
|
-
return { turn, started: operation.at, parts: []
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
turn,
|
|
49
|
-
started: null,
|
|
50
|
-
parts: [],
|
|
51
|
-
context: { used: operation.used, window: operation.window },
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
return operation.op === 'start' && operation.index === 0
|
|
55
|
-
? { turn, started: null, parts: [structuredClone(operation.part)], context: null }
|
|
56
|
-
: null;
|
|
57
|
-
}
|
|
58
|
-
function changedFields(part, operation) {
|
|
59
|
-
if (operation.op === 'append') {
|
|
60
|
-
return { text: `${String(part.text ?? '')}${operation.text}` };
|
|
61
|
-
}
|
|
62
|
-
if (operation.op === 'status') {
|
|
63
|
-
return { status: operation.status, result: structuredClone(operation.result) };
|
|
64
|
-
}
|
|
65
|
-
if (operation.op === 'count')
|
|
66
|
-
return { count: operation.count };
|
|
67
|
-
return { entries: structuredClone(operation.entries) };
|
|
51
|
+
return { turn, started: operation.at, parts: [] };
|
|
52
|
+
const parts = applied([], operation);
|
|
53
|
+
return parts === null ? null : { turn, started: null, parts };
|
|
68
54
|
}
|
|
69
55
|
function appliedTurn(held, operation) {
|
|
70
56
|
if (operation.op === 'begin')
|
|
71
57
|
return { ...held, started: operation.at };
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
if (operation.op === 'start') {
|
|
76
|
-
if (operation.index !== 0 && operation.index !== held.parts.length)
|
|
77
|
-
return null;
|
|
78
|
-
return {
|
|
79
|
-
...held,
|
|
80
|
-
parts: [...held.parts.slice(0, operation.index), structuredClone(operation.part)],
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
const part = held.parts[operation.index];
|
|
84
|
-
if (typeof part !== 'object' || part === null)
|
|
85
|
-
return null;
|
|
86
|
-
const changed = { ...part, ...changedFields(part, operation) };
|
|
87
|
-
return {
|
|
88
|
-
...held,
|
|
89
|
-
parts: held.parts.map((kept, at) => (at === operation.index ? changed : kept)),
|
|
90
|
-
};
|
|
58
|
+
const parts = applied(held.parts, operation);
|
|
59
|
+
return parts === null ? null : { ...held, parts };
|
|
91
60
|
}
|
|
92
61
|
function windowOf(held, arriving, limit) {
|
|
93
62
|
const byIdentity = new Map(held.map((message) => [message.identity, message]));
|
|
@@ -110,7 +79,7 @@ function frameOf(asked, messages, more, total) {
|
|
|
110
79
|
};
|
|
111
80
|
}
|
|
112
81
|
function newestOf(arriving, from) {
|
|
113
|
-
return arriving.reduce((top, message) => (top === null || message.
|
|
82
|
+
return arriving.reduce((top, message) => (top === null || message.change > top ? message.change : top), from);
|
|
114
83
|
}
|
|
115
84
|
function acceptedMessage(value) {
|
|
116
85
|
if (typeof value !== 'object' || value === null)
|
|
@@ -119,6 +88,7 @@ function acceptedMessage(value) {
|
|
|
119
88
|
if (typeof record.identity !== 'string' ||
|
|
120
89
|
typeof record.turn !== 'string' ||
|
|
121
90
|
typeof record.position !== 'string' ||
|
|
91
|
+
typeof record.change !== 'string' ||
|
|
122
92
|
typeof record.text !== 'string') {
|
|
123
93
|
return null;
|
|
124
94
|
}
|
|
@@ -126,6 +96,7 @@ function acceptedMessage(value) {
|
|
|
126
96
|
identity: record.identity,
|
|
127
97
|
turn: record.turn,
|
|
128
98
|
position: record.position,
|
|
99
|
+
change: record.change,
|
|
129
100
|
text: record.text,
|
|
130
101
|
message: structuredClone(record.message),
|
|
131
102
|
};
|
|
@@ -237,7 +208,7 @@ function returned(draft, submission, others) {
|
|
|
237
208
|
revision: chatDraftRevision(),
|
|
238
209
|
}, others);
|
|
239
210
|
}
|
|
240
|
-
function viewOf(alive, conversation, held, frame, draft, ended
|
|
211
|
+
function viewOf(alive, conversation, held, frame, draft, ended) {
|
|
241
212
|
const facts = alive.liveOf(conversation);
|
|
242
213
|
return {
|
|
243
214
|
conversation,
|
|
@@ -255,26 +226,37 @@ function viewOf(alive, conversation, held, frame, draft, ended, marked) {
|
|
|
255
226
|
commands: structuredClone(facts.commands),
|
|
256
227
|
options: structuredClone(facts.options),
|
|
257
228
|
starting: facts.starting,
|
|
258
|
-
|
|
229
|
+
state: sessionOf(facts, held, ended),
|
|
259
230
|
link: facts.link === null ? null : { ...facts.link },
|
|
231
|
+
deliveryWaiting: [...facts.deliveryWaiting],
|
|
260
232
|
deliveryUnknown: [...facts.deliveryUnknown],
|
|
261
233
|
chatDraft: draft === null || unwritten(draft) ? null : { text: draft.text, revision: draft.revision },
|
|
262
|
-
jobs: facts.process?.running === false
|
|
263
|
-
? []
|
|
264
|
-
: jobsOf(marked.filter(({ at }) => ended === null || at > ended), facts.turn),
|
|
265
234
|
};
|
|
266
235
|
}
|
|
236
|
+
function sessionOf(facts, held, ended) {
|
|
237
|
+
if (facts.state !== null)
|
|
238
|
+
return structuredClone(facts.state);
|
|
239
|
+
const saved = [...held]
|
|
240
|
+
.reverse()
|
|
241
|
+
.map(({ message }) => record(message))
|
|
242
|
+
.find(({ content }) => isTurn(content));
|
|
243
|
+
const at = saved === undefined ? null : text(saved, 'accepted_at');
|
|
244
|
+
if (saved === undefined || !isTurn(saved.content) || at === null)
|
|
245
|
+
return null;
|
|
246
|
+
const down = facts.process?.running === false;
|
|
247
|
+
return structuredClone(standingState(saved.content.state, at, down ? at : ended));
|
|
248
|
+
}
|
|
267
249
|
function emit(alive, conversation) {
|
|
268
250
|
if (alive.deps.closed())
|
|
269
251
|
return;
|
|
270
252
|
for (const view of alive.views()) {
|
|
271
|
-
const { window, draft, ended
|
|
253
|
+
const { window, draft, ended } = view.held.now();
|
|
272
254
|
if (view.conversation !== conversation || window === null)
|
|
273
255
|
continue;
|
|
274
256
|
const ready = view.ready();
|
|
275
257
|
if (ready.length === 0)
|
|
276
258
|
continue;
|
|
277
|
-
const value = viewOf(alive, conversation, window, sharedFrame(view, window), draft, ended
|
|
259
|
+
const value = viewOf(alive, conversation, window, sharedFrame(view, window), draft, ended);
|
|
278
260
|
for (const watcher of ready)
|
|
279
261
|
watcher.notify(value);
|
|
280
262
|
}
|
|
@@ -285,23 +267,18 @@ function sharedFrame(view, window) {
|
|
|
285
267
|
}
|
|
286
268
|
async function slide(alive, local, conversation, arriving) {
|
|
287
269
|
let count;
|
|
288
|
-
let marked;
|
|
289
270
|
for (const view of alive.views()) {
|
|
290
271
|
const { held } = view;
|
|
291
272
|
const { window, total } = held.now();
|
|
292
273
|
if (view.conversation !== conversation || window === null)
|
|
293
274
|
continue;
|
|
294
275
|
if (arriving === null) {
|
|
295
|
-
held.set({ window: [],
|
|
276
|
+
held.set({ window: [], more: false, total: total === null ? null : 0 });
|
|
296
277
|
continue;
|
|
297
278
|
}
|
|
298
279
|
const joining = arriving.filter((message) => precedes(message, view.asked.before));
|
|
299
280
|
const next = windowOf(window, joining, view.asked.limit);
|
|
300
281
|
held.set({ window: next.messages, more: held.now().more || next.dropped });
|
|
301
|
-
if (arriving.length > 0) {
|
|
302
|
-
marked ??= await local.jobMarkers(conversation);
|
|
303
|
-
held.set({ marked });
|
|
304
|
-
}
|
|
305
282
|
if (held.now().total !== null && arriving.length > 0) {
|
|
306
283
|
count ??= await local.messageCount(conversation);
|
|
307
284
|
held.set({ total: count });
|
|
@@ -399,7 +376,7 @@ function listChanged(alive, change) {
|
|
|
399
376
|
list.some(({ conversation }) => !replicated.has(conversation)))) {
|
|
400
377
|
alive.deps.again();
|
|
401
378
|
}
|
|
402
|
-
},
|
|
379
|
+
}, uncaught);
|
|
403
380
|
}
|
|
404
381
|
function endedAnew(alive, list) {
|
|
405
382
|
const entries = new Map(list.map((entry) => [entry.conversation, entry]));
|
|
@@ -415,7 +392,10 @@ function endedAnew(alive, list) {
|
|
|
415
392
|
function shownList(alive, work) {
|
|
416
393
|
const reading = heldList(alive);
|
|
417
394
|
alive.inOrder(async () => {
|
|
418
|
-
const list = await reading.catch(() =>
|
|
395
|
+
const list = await reading.catch((error) => {
|
|
396
|
+
uncaught(error);
|
|
397
|
+
return null;
|
|
398
|
+
});
|
|
419
399
|
if (list === null || alive.deps.closed())
|
|
420
400
|
return;
|
|
421
401
|
work(list);
|
|
@@ -425,7 +405,7 @@ async function told(alive) {
|
|
|
425
405
|
try {
|
|
426
406
|
while (alive.held.now().listOwed && !alive.deps.closed()) {
|
|
427
407
|
alive.held.set({ listOwed: false });
|
|
428
|
-
const value = await untilAnswered(() => entries(alive), alive.closing);
|
|
408
|
+
const value = await untilAnswered(retrying(alive.deps.retries, 'conversations', LISTING, () => entries(alive)), alive.closing, () => true, alive.deps.recovery);
|
|
429
409
|
if (alive.deps.closed())
|
|
430
410
|
return;
|
|
431
411
|
if (value === null)
|
|
@@ -468,15 +448,24 @@ export function conversationsLearned(alive) {
|
|
|
468
448
|
shownList(alive, (list) => alive.agentListeners.welcome(agents(alive, list)));
|
|
469
449
|
}
|
|
470
450
|
function agents(alive, list) {
|
|
471
|
-
const
|
|
472
|
-
|
|
473
|
-
named.set(agent.agent, agent);
|
|
451
|
+
const read = new Map((alive.held.now().listedAgents ?? []).map((one) => [one.agent, one]));
|
|
452
|
+
const named = new Map(read);
|
|
474
453
|
for (const entry of list) {
|
|
475
454
|
named.set(entry.agent, { name: entry.agentName, retired: entry.agentRetired });
|
|
476
455
|
}
|
|
477
456
|
return [...named]
|
|
478
457
|
.filter(([, agent]) => !agent.retired)
|
|
479
|
-
.map(([identity, agent]) =>
|
|
458
|
+
.map(([identity, agent]) => {
|
|
459
|
+
const held = read.get(identity);
|
|
460
|
+
return held === undefined
|
|
461
|
+
? { identity, name: agent.name }
|
|
462
|
+
: {
|
|
463
|
+
identity,
|
|
464
|
+
name: agent.name,
|
|
465
|
+
cli: held.cli,
|
|
466
|
+
environment: structuredClone(held.environment),
|
|
467
|
+
};
|
|
468
|
+
})
|
|
480
469
|
.sort((left, right) => left.name === right.name
|
|
481
470
|
? left.identity.localeCompare(right.identity)
|
|
482
471
|
: left.name.localeCompare(right.name));
|
|
@@ -493,7 +482,7 @@ function readAgents(alive) {
|
|
|
493
482
|
if (!alive.deps.online() || (!agentListeners.waiting() && !agentListeners.told())) {
|
|
494
483
|
return 'done';
|
|
495
484
|
}
|
|
496
|
-
const listed = await read();
|
|
485
|
+
const listed = await retrying(alive.deps.retries, 'conversations', AGENTS, read)();
|
|
497
486
|
if (listed === null)
|
|
498
487
|
return 'done';
|
|
499
488
|
alive.held.set({ listedAgents: listed });
|
|
@@ -550,8 +539,9 @@ function openingEnded(alive) {
|
|
|
550
539
|
commands: facts.has('commands') ? QUIET.commands : held.commands,
|
|
551
540
|
options: facts.has('options') ? QUIET.options : held.options,
|
|
552
541
|
starting: facts.has('starting') ? QUIET.starting : held.starting,
|
|
553
|
-
|
|
542
|
+
state: facts.has('state') ? QUIET.state : held.state,
|
|
554
543
|
link: facts.has('link') ? QUIET.link : held.link,
|
|
544
|
+
deliveryWaiting: facts.has('deliveryWaiting') ? QUIET.deliveryWaiting : held.deliveryWaiting,
|
|
555
545
|
deliveryUnknown: facts.has('deliveryUnknown') ? QUIET.deliveryUnknown : held.deliveryUnknown,
|
|
556
546
|
});
|
|
557
547
|
emit(alive, conversation);
|
|
@@ -634,7 +624,7 @@ function retiredDrafts(alive, list) {
|
|
|
634
624
|
held.some(({ conversation }) => retiredChat(conversation, list))) {
|
|
635
625
|
alive.deps.again();
|
|
636
626
|
}
|
|
637
|
-
},
|
|
627
|
+
}, uncaught);
|
|
638
628
|
}
|
|
639
629
|
function settleBehind(alive, list) {
|
|
640
630
|
void alive.deps
|
|
@@ -660,21 +650,19 @@ function settleBehind(alive, list) {
|
|
|
660
650
|
alive.deps.settled();
|
|
661
651
|
if (owed)
|
|
662
652
|
alive.deps.again();
|
|
663
|
-
},
|
|
653
|
+
}, uncaught);
|
|
664
654
|
}
|
|
665
655
|
function keep(alive, conversation, message) {
|
|
666
656
|
return alive.deps.durably(async (local) => {
|
|
667
657
|
if (!alive.held.now().replicated.has(conversation))
|
|
668
658
|
return;
|
|
669
659
|
const read = (await readsOf(local, [conversation])).get(conversation)?.read;
|
|
670
|
-
const advances = read !== undefined &&
|
|
671
|
-
!alive.behind(conversation) &&
|
|
672
|
-
(read === null || message.position > read);
|
|
660
|
+
const advances = read !== undefined && !alive.behind(conversation) && (read === null || message.change > read);
|
|
673
661
|
await sealed(alive, local, conversation, new Set([message.turn]));
|
|
674
662
|
await local.keepMessages({
|
|
675
663
|
conversation,
|
|
676
664
|
messages: [message],
|
|
677
|
-
...(advances ? { read: { at: message.
|
|
665
|
+
...(advances ? { read: { at: message.change, partial: false } } : {}),
|
|
678
666
|
});
|
|
679
667
|
sealTurns(alive, conversation, new Set([message.turn]));
|
|
680
668
|
await slide(alive, local, conversation, [message]);
|
|
@@ -786,8 +774,8 @@ function heard(alive, event) {
|
|
|
786
774
|
live(alive, conversation, { starting: event.step });
|
|
787
775
|
return;
|
|
788
776
|
}
|
|
789
|
-
if (event.kind === '
|
|
790
|
-
live(alive, conversation, {
|
|
777
|
+
if (event.kind === 'state') {
|
|
778
|
+
live(alive, conversation, { state: structuredClone(event.state) });
|
|
791
779
|
return;
|
|
792
780
|
}
|
|
793
781
|
if (event.kind === 'link') {
|
|
@@ -795,13 +783,16 @@ function heard(alive, event) {
|
|
|
795
783
|
return;
|
|
796
784
|
}
|
|
797
785
|
if (event.kind === 'deliveries') {
|
|
798
|
-
live(alive, conversation, {
|
|
786
|
+
live(alive, conversation, {
|
|
787
|
+
deliveryWaiting: [...event.waiting],
|
|
788
|
+
deliveryUnknown: [...event.unknown],
|
|
789
|
+
});
|
|
799
790
|
return;
|
|
800
791
|
}
|
|
801
792
|
const arriving = acceptedMessage(event.message);
|
|
802
793
|
if (arriving === null)
|
|
803
794
|
return;
|
|
804
|
-
alive.heardAt(conversation, arriving.
|
|
795
|
+
alive.heardAt(conversation, arriving.change);
|
|
805
796
|
if (alive.held.now().replicated.has(conversation)) {
|
|
806
797
|
if (alive.deps.full()) {
|
|
807
798
|
alive.gapOpened(conversation);
|
|
@@ -810,6 +801,8 @@ function heard(alive, event) {
|
|
|
810
801
|
void keep(alive, conversation, arriving).catch((error) => {
|
|
811
802
|
if (refusedForSpace(error))
|
|
812
803
|
alive.gapOpened(conversation);
|
|
804
|
+
else
|
|
805
|
+
uncaught(error);
|
|
813
806
|
});
|
|
814
807
|
return;
|
|
815
808
|
}
|
|
@@ -896,10 +889,7 @@ async function submitted(alive, conversation, operation, draft) {
|
|
|
896
889
|
async function dispatched(alive, conversation, submission) {
|
|
897
890
|
const dispatch = alive.sendingBegan(submission.operation);
|
|
898
891
|
try {
|
|
899
|
-
const result = await invoke(alive, 'conversations/send', conversation, {
|
|
900
|
-
operation_id: submission.operation,
|
|
901
|
-
text: submission.text,
|
|
902
|
-
});
|
|
892
|
+
const result = await invoke(alive, 'conversations/send', conversation, submission.operation, { text: submission.text }, { step: 'sending', instance: `message ${submission.operation}` });
|
|
903
893
|
dispatch.set({ answered: result.kind !== 'transport-uncertainty' });
|
|
904
894
|
if (result.kind === 'revoked-authorization')
|
|
905
895
|
return result;
|
|
@@ -926,8 +916,8 @@ async function dispatched(alive, conversation, submission) {
|
|
|
926
916
|
alive.sendingEnded(submission.operation, dispatch);
|
|
927
917
|
}
|
|
928
918
|
}
|
|
929
|
-
function invoke(alive, name, conversation, extra = {
|
|
930
|
-
return alive.deps.call(name, { conversation_id: conversation, ...extra });
|
|
919
|
+
function invoke(alive, name, conversation, operation, extra = {}, attempt) {
|
|
920
|
+
return alive.deps.call(name, { conversation_id: conversation, operation_id: operation, ...extra }, attempt);
|
|
931
921
|
}
|
|
932
922
|
export function conversationSurface(alive) {
|
|
933
923
|
return {
|
|
@@ -948,8 +938,7 @@ export function conversationSurface(alive) {
|
|
|
948
938
|
return alive.deps.durably(async (local) => {
|
|
949
939
|
const { messages, more } = await local.messageWindow(conversation, asked.limit, asked.before, phrase);
|
|
950
940
|
const total = asked.total ? await local.messageCount(conversation, phrase) : null;
|
|
951
|
-
|
|
952
|
-
return structuredClone(viewOf(alive, conversation, messages, frameOf(asked, messages, more, total), (await local.chatDraft(conversation)) ?? null, await endedIn(alive, conversation), marked));
|
|
941
|
+
return structuredClone(viewOf(alive, conversation, messages, frameOf(asked, messages, more, total), (await local.chatDraft(conversation)) ?? null, await endedIn(alive, conversation)));
|
|
953
942
|
});
|
|
954
943
|
},
|
|
955
944
|
async create(input) {
|
|
@@ -986,20 +975,57 @@ export function conversationSurface(alive) {
|
|
|
986
975
|
}
|
|
987
976
|
return OFFLINE;
|
|
988
977
|
},
|
|
989
|
-
answer(conversation, answer) {
|
|
990
|
-
return invoke(alive, 'conversations/interaction/answer', conversation,
|
|
991
|
-
|
|
992
|
-
|
|
978
|
+
answer(conversation, answer, operation) {
|
|
979
|
+
return invoke(alive, 'conversations/interaction/answer', conversation, operation, answer);
|
|
980
|
+
},
|
|
981
|
+
interrupt(conversation, operation) {
|
|
982
|
+
return invoke(alive, 'conversations/interrupt', conversation, operation);
|
|
983
|
+
},
|
|
984
|
+
kill(conversation, operation) {
|
|
985
|
+
return invoke(alive, 'conversations/kill', conversation, operation);
|
|
986
|
+
},
|
|
987
|
+
delete(conversation, operation) {
|
|
988
|
+
return invoke(alive, 'conversations/delete', conversation, operation);
|
|
989
|
+
},
|
|
990
|
+
takeOut(conversation, message, operation) {
|
|
991
|
+
return invoke(alive, 'conversations/take-out', conversation, operation, {
|
|
992
|
+
message_id: message,
|
|
993
993
|
});
|
|
994
994
|
},
|
|
995
|
-
|
|
996
|
-
return
|
|
995
|
+
decide({ request, room, message }, decision, operation) {
|
|
996
|
+
return alive.deps.call('agent-functions/decide', {
|
|
997
|
+
room_ref: room,
|
|
998
|
+
request,
|
|
999
|
+
...(message === undefined ? {} : { message }),
|
|
1000
|
+
decision,
|
|
1001
|
+
operation_id: operation,
|
|
1002
|
+
});
|
|
1003
|
+
},
|
|
1004
|
+
rename(conversation, name, operation) {
|
|
1005
|
+
return invoke(alive, 'conversations/rename', conversation, operation, { name });
|
|
1006
|
+
},
|
|
1007
|
+
option(conversation, option, value, operation) {
|
|
1008
|
+
return invoke(alive, 'conversations/option/set', conversation, operation, { option, value });
|
|
1009
|
+
},
|
|
1010
|
+
retry(conversation, message, operation) {
|
|
1011
|
+
return invoke(alive, 'conversations/retry', conversation, operation, {
|
|
1012
|
+
message_id: message,
|
|
1013
|
+
});
|
|
997
1014
|
},
|
|
998
|
-
|
|
999
|
-
return
|
|
1015
|
+
async pins() {
|
|
1016
|
+
return (await (await alive.deps.local()).facts()).chatPins;
|
|
1000
1017
|
},
|
|
1001
|
-
|
|
1002
|
-
return
|
|
1018
|
+
pin(figures) {
|
|
1019
|
+
return alive.deps.durably((local) => local.fact('chatPins', [...figures]));
|
|
1020
|
+
},
|
|
1021
|
+
async openedTurns() {
|
|
1022
|
+
return (await (await alive.deps.local()).facts()).openedTurns;
|
|
1023
|
+
},
|
|
1024
|
+
openTurn(conversation, turn) {
|
|
1025
|
+
return alive.deps.durably(async (local) => {
|
|
1026
|
+
const { openedTurns } = await local.facts();
|
|
1027
|
+
await local.fact('openedTurns', { ...openedTurns, [conversation]: turn });
|
|
1028
|
+
});
|
|
1003
1029
|
},
|
|
1004
1030
|
};
|
|
1005
1031
|
}
|
|
@@ -1119,23 +1145,22 @@ export function watchConversation(alive, conversation, options, deliver) {
|
|
|
1119
1145
|
const { view, watcher } = alive.viewJoined(key, conversation, asked, deliver);
|
|
1120
1146
|
const { held } = view;
|
|
1121
1147
|
const reading = new AbortController();
|
|
1122
|
-
void untilAnswered(() => alive.deps.durably(async (local) => {
|
|
1148
|
+
void untilAnswered(retrying(alive.deps.retries, 'reading', `window ${key}`, () => alive.deps.durably(async (local) => {
|
|
1123
1149
|
if (held.now().window !== null)
|
|
1124
1150
|
return;
|
|
1125
1151
|
const { messages, more } = await local.messageWindow(conversation, asked.limit, asked.before);
|
|
1126
1152
|
held.set({ draft: (await local.chatDraft(conversation)) ?? null });
|
|
1127
1153
|
held.set({ ended: await endedIn(alive, conversation) });
|
|
1128
1154
|
held.set({ window: messages });
|
|
1129
|
-
held.set({ marked: await local.jobMarkers(conversation) });
|
|
1130
1155
|
held.set({ more });
|
|
1131
1156
|
held.set({ total: asked.total ? await local.messageCount(conversation) : null });
|
|
1132
|
-
}), reading.signal)
|
|
1157
|
+
})), reading.signal)
|
|
1133
1158
|
.then(() => {
|
|
1134
1159
|
if (alive.deps.closed() || !view.admit(watcher))
|
|
1135
1160
|
return;
|
|
1136
|
-
const { window, draft, ended
|
|
1161
|
+
const { window, draft, ended } = held.now();
|
|
1137
1162
|
const shown = window ?? [];
|
|
1138
|
-
watcher.notify(viewOf(alive, conversation, shown, sharedFrame(view, shown), draft, ended
|
|
1163
|
+
watcher.notify(viewOf(alive, conversation, shown, sharedFrame(view, shown), draft, ended));
|
|
1139
1164
|
})
|
|
1140
1165
|
.catch(() => { });
|
|
1141
1166
|
return () => {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DiscoveredRoom, OperationScopes, PathRule, RoomDeclaration } from './adapter.js';
|
|
2
|
+
export type WriteRefusal = {
|
|
3
|
+
readonly code: 'room-root' | 'provider-owned-path' | 'invalid-path' | `${keyof OperationScopes}-grant`;
|
|
4
|
+
readonly path: string;
|
|
5
|
+
};
|
|
6
|
+
export type WriteRule = (path: string, needs: readonly (keyof OperationScopes)[]) => WriteRefusal | null;
|
|
7
|
+
export declare function declared({ locator: _locator, roomVersion: _roomVersion, ...declaration }: DiscoveredRoom): RoomDeclaration;
|
|
8
|
+
export declare function sameDeclaration(left: RoomDeclaration, right: RoomDeclaration): boolean;
|
|
9
|
+
export declare function writeRule({ operations, providerOwnedPaths, authoredPaths, }: Pick<RoomDeclaration, 'operations' | 'providerOwnedPaths' | 'authoredPaths'>, pathRule: PathRule, local: boolean): WriteRule;
|
|
10
|
+
//# sourceMappingURL=declaration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../src/declaration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/F,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,IAAI,EACT,WAAW,GACX,qBAAqB,GACrB,cAAc,GACd,GAAG,MAAM,eAAe,QAAQ,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,CACtB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,CAAC,MAAM,eAAe,CAAC,EAAE,KACtC,YAAY,GAAG,IAAI,CAAC;AAEzB,wBAAgB,QAAQ,CAAC,EACvB,OAAO,EAAE,QAAQ,EACjB,WAAW,EAAE,YAAY,EACzB,GAAG,WAAW,EACf,EAAE,cAAc,GAAG,eAAe,CAElC;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAEtF;AAED,wBAAgB,SAAS,CACvB,EACE,UAAU,EACV,kBAAkB,EAClB,aAAa,GACd,EAAE,IAAI,CAAC,eAAe,EAAE,YAAY,GAAG,oBAAoB,GAAG,eAAe,CAAC,EAC/E,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,OAAO,GACb,SAAS,CAYX"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { equalValue } from '@agentshouse/mdmodel';
|
|
2
|
+
import { authoredAt, covered, normalize } from './paths.js';
|
|
3
|
+
export function declared({ locator: _locator, roomVersion: _roomVersion, ...declaration }) {
|
|
4
|
+
return declaration;
|
|
5
|
+
}
|
|
6
|
+
export function sameDeclaration(left, right) {
|
|
7
|
+
return equalValue(left, right);
|
|
8
|
+
}
|
|
9
|
+
export function writeRule({ operations, providerOwnedPaths, authoredPaths, }, pathRule, local) {
|
|
10
|
+
return (path, needs) => {
|
|
11
|
+
const normalized = normalize(path);
|
|
12
|
+
if (normalized === null || normalized === '')
|
|
13
|
+
return { code: 'room-root', path };
|
|
14
|
+
if (covered(providerOwnedPaths, normalized) || !authoredAt(authoredPaths, normalized)) {
|
|
15
|
+
return { code: 'provider-owned-path', path: normalized };
|
|
16
|
+
}
|
|
17
|
+
if (!pathRule(normalized))
|
|
18
|
+
return { code: 'invalid-path', path: normalized };
|
|
19
|
+
if (local)
|
|
20
|
+
return null;
|
|
21
|
+
const missing = needs.find((operation) => !covered(operations[operation], normalized));
|
|
22
|
+
return missing === undefined ? null : { code: `${missing}-grant`, path: normalized };
|
|
23
|
+
};
|
|
24
|
+
}
|
package/dist/discovery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,SAAS,EACT,cAAc,EACd,MAAM,EAEP,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,SAAS,EACT,cAAc,EACd,MAAM,EAEP,MAAM,cAAc,CAAC;AAOtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAkB/C,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,GAAG,IAAI,CAsB1E;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,GACvB,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC,CA0CpC;AAYD,wBAAsB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,iBAI1F;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,GAAG,IAAI,GACtB,OAAO,CAAC,SAAS,cAAc,EAAE,GAAG,IAAI,CAAC,CAkE3C"}
|