@abraca/orchestrator 2.90.0 → 2.91.0
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/package.json +5 -11
- package/src/actions/awareness.ts +0 -101
- package/src/actions/chat.ts +0 -30
- package/src/actions/connect.ts +0 -16
- package/src/actions/content.ts +0 -46
- package/src/actions/cursor.ts +0 -30
- package/src/actions/document.ts +0 -120
- package/src/actions/flow.ts +0 -46
- package/src/actions/index.ts +0 -197
- package/src/actions/navigate.ts +0 -15
- package/src/actions/type.ts +0 -113
- package/src/actor-connection.ts +0 -230
- package/src/define.ts +0 -147
- package/src/easing.ts +0 -15
- package/src/index.ts +0 -105
- package/src/orchestrator.ts +0 -153
- package/src/timeline-runner.ts +0 -84
- package/src/types.ts +0 -245
- package/src/utils.ts +0 -18
- package/src/yjs-utils.ts +0 -238
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abraca/orchestrator",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.91.0",
|
|
4
4
|
"description": "CouShell commercial director — orchestrate simulated actors on Abracadabra for screen recording",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,21 +14,15 @@
|
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
16
|
"exports": {
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"default": {
|
|
21
|
-
"import": "./dist/abracadabra-orchestrator.esm.js",
|
|
22
|
-
"require": "./dist/abracadabra-orchestrator.cjs",
|
|
23
|
-
"types": "./dist/index.d.ts"
|
|
24
|
-
}
|
|
17
|
+
"import": "./dist/abracadabra-orchestrator.esm.js",
|
|
18
|
+
"require": "./dist/abracadabra-orchestrator.cjs",
|
|
19
|
+
"types": "./dist/index.d.ts"
|
|
25
20
|
},
|
|
26
21
|
"files": [
|
|
27
|
-
"src",
|
|
28
22
|
"dist"
|
|
29
23
|
],
|
|
30
24
|
"dependencies": {
|
|
31
|
-
"@abraca/convert": "2.
|
|
25
|
+
"@abraca/convert": "2.91.0"
|
|
32
26
|
},
|
|
33
27
|
"peerDependencies": {
|
|
34
28
|
"@abraca/dabra": ">=1.0.0",
|
package/src/actions/awareness.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Awareness actions: setStatus, setAwareness, clearAwareness, pointerMove, scrollTo,
|
|
3
|
-
* kanbanHover, kanbanDrag.
|
|
4
|
-
*/
|
|
5
|
-
import type { ActorConnection } from '../actor-connection.ts'
|
|
6
|
-
import type {
|
|
7
|
-
SetStatusAction,
|
|
8
|
-
SetAwarenessAction,
|
|
9
|
-
ClearAwarenessAction,
|
|
10
|
-
PointerMoveAction,
|
|
11
|
-
ScrollToAction,
|
|
12
|
-
KanbanHoverAction,
|
|
13
|
-
KanbanDragAction,
|
|
14
|
-
} from '../types.ts'
|
|
15
|
-
import { sleep } from '../utils.ts'
|
|
16
|
-
import { getEasing } from '../easing.ts'
|
|
17
|
-
|
|
18
|
-
export async function executeSetStatus(
|
|
19
|
-
actor: ActorConnection,
|
|
20
|
-
action: SetStatusAction
|
|
21
|
-
): Promise<void> {
|
|
22
|
-
actor.setRootAwareness('status', action.status)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export async function executeSetAwareness(
|
|
26
|
-
actor: ActorConnection,
|
|
27
|
-
action: SetAwarenessAction
|
|
28
|
-
): Promise<void> {
|
|
29
|
-
if (action.docId) {
|
|
30
|
-
// Ensure child provider is loaded
|
|
31
|
-
await actor.getChildProvider(action.docId)
|
|
32
|
-
for (const [key, value] of Object.entries(action.fields)) {
|
|
33
|
-
actor.setChildAwareness(action.docId, key, value)
|
|
34
|
-
}
|
|
35
|
-
} else {
|
|
36
|
-
for (const [key, value] of Object.entries(action.fields)) {
|
|
37
|
-
actor.setRootAwareness(key, value)
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export async function executeClearAwareness(
|
|
43
|
-
actor: ActorConnection,
|
|
44
|
-
action: ClearAwarenessAction
|
|
45
|
-
): Promise<void> {
|
|
46
|
-
if (action.docId) {
|
|
47
|
-
for (const field of action.fields) {
|
|
48
|
-
actor.setChildAwareness(action.docId, field, null)
|
|
49
|
-
}
|
|
50
|
-
} else {
|
|
51
|
-
for (const field of action.fields) {
|
|
52
|
-
actor.setRootAwareness(field, null)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export async function executePointerMove(
|
|
58
|
-
actor: ActorConnection,
|
|
59
|
-
action: PointerMoveAction
|
|
60
|
-
): Promise<void> {
|
|
61
|
-
const easing = getEasing(action.easing)
|
|
62
|
-
const steps = Math.max(1, Math.round(action.duration / 16)) // ~60fps
|
|
63
|
-
const stepDuration = action.duration / steps
|
|
64
|
-
|
|
65
|
-
for (let i = 0; i <= steps; i++) {
|
|
66
|
-
const t = easing(i / steps)
|
|
67
|
-
const x = action.from.x + (action.to.x - action.from.x) * t
|
|
68
|
-
const y = action.from.y + (action.to.y - action.from.y) * t
|
|
69
|
-
actor.setChildAwareness(action.docId, 'pos', { x, y })
|
|
70
|
-
if (i < steps) await sleep(stepDuration)
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export async function executeScrollTo(
|
|
75
|
-
actor: ActorConnection,
|
|
76
|
-
action: ScrollToAction
|
|
77
|
-
): Promise<void> {
|
|
78
|
-
actor.setChildAwareness(action.docId, 'doc:scroll', action.position)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export async function executeKanbanHover(
|
|
82
|
-
actor: ActorConnection,
|
|
83
|
-
action: KanbanHoverAction
|
|
84
|
-
): Promise<void> {
|
|
85
|
-
actor.setChildAwareness(action.docId, 'kanban:hovering', action.cardId)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export async function executeKanbanDrag(
|
|
89
|
-
actor: ActorConnection,
|
|
90
|
-
action: KanbanDragAction
|
|
91
|
-
): Promise<void> {
|
|
92
|
-
// Set drag state
|
|
93
|
-
actor.setChildAwareness(action.docId, 'kanban:dragging', {
|
|
94
|
-
cardId: action.cardId,
|
|
95
|
-
toColumnId: action.toColumnId,
|
|
96
|
-
})
|
|
97
|
-
// Hold for duration
|
|
98
|
-
await sleep(action.duration)
|
|
99
|
-
// Clear drag state
|
|
100
|
-
actor.setChildAwareness(action.docId, 'kanban:dragging', null)
|
|
101
|
-
}
|
package/src/actions/chat.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Chat action — send a stateless message via the provider.
|
|
3
|
-
*
|
|
4
|
-
* Routes through the unified `messages:send` protocol. `action.channel` is
|
|
5
|
-
* interpreted as a doc id (the channel/dm doc UUID); legacy `group:<docId>`
|
|
6
|
-
* strings are accepted with the prefix stripped.
|
|
7
|
-
*/
|
|
8
|
-
import type { ActorConnection } from '../actor-connection.ts'
|
|
9
|
-
import type { SendChatAction } from '../types.ts'
|
|
10
|
-
|
|
11
|
-
export async function executeSendChat(
|
|
12
|
-
actor: ActorConnection,
|
|
13
|
-
action: SendChatAction
|
|
14
|
-
): Promise<void> {
|
|
15
|
-
const rootProvider = actor.rootProvider
|
|
16
|
-
if (!rootProvider) throw new Error(`${actor.actor.name}: not connected`)
|
|
17
|
-
|
|
18
|
-
const channel_doc_id = action.channel.startsWith('group:')
|
|
19
|
-
? action.channel.slice(6)
|
|
20
|
-
: action.channel
|
|
21
|
-
|
|
22
|
-
const payload = JSON.stringify({
|
|
23
|
-
type: 'messages:send',
|
|
24
|
-
channel_doc_id,
|
|
25
|
-
content: action.message,
|
|
26
|
-
mentions: [],
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
rootProvider.sendStateless(payload)
|
|
30
|
-
}
|
package/src/actions/connect.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Connect / disconnect actions.
|
|
3
|
-
*/
|
|
4
|
-
import type { ActorConnection } from '../actor-connection.ts'
|
|
5
|
-
import type { ServerConfig } from '../types.ts'
|
|
6
|
-
|
|
7
|
-
export async function executeConnect(
|
|
8
|
-
actor: ActorConnection,
|
|
9
|
-
serverConfig: ServerConfig
|
|
10
|
-
): Promise<void> {
|
|
11
|
-
await actor.connect(serverConfig)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export async function executeDisconnect(actor: ActorConnection): Promise<void> {
|
|
15
|
-
await actor.disconnect()
|
|
16
|
-
}
|
package/src/actions/content.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Content actions: writeContent (markdown → Y.js), deleteContent.
|
|
3
|
-
*
|
|
4
|
-
* Preserves TipTap schema nodes (documentHeader, documentMeta) —
|
|
5
|
-
* only body content is cleared/replaced.
|
|
6
|
-
*/
|
|
7
|
-
import type { ActorConnection } from '../actor-connection.ts'
|
|
8
|
-
import type { WriteContentAction, DeleteContentAction } from '../types.ts'
|
|
9
|
-
import { populateYDocFromMarkdown } from '@abraca/convert'
|
|
10
|
-
import { bodyStartIndex } from '../yjs-utils.ts'
|
|
11
|
-
|
|
12
|
-
export async function executeWriteContent(
|
|
13
|
-
actor: ActorConnection,
|
|
14
|
-
action: WriteContentAction
|
|
15
|
-
): Promise<void> {
|
|
16
|
-
const provider = await actor.getChildProvider(action.docId)
|
|
17
|
-
const fragment = provider.document.getXmlFragment('default')
|
|
18
|
-
|
|
19
|
-
// Clear entire fragment (schema nodes + body) — populateYDocFromMarkdown rebuilds them
|
|
20
|
-
provider.document.transact(() => {
|
|
21
|
-
while (fragment.length > 0) {
|
|
22
|
-
fragment.delete(0, 1)
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
// Populate from markdown (creates fresh documentHeader + documentMeta + body)
|
|
27
|
-
populateYDocFromMarkdown(fragment, action.markdown)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export async function executeDeleteContent(
|
|
31
|
-
actor: ActorConnection,
|
|
32
|
-
action: DeleteContentAction
|
|
33
|
-
): Promise<void> {
|
|
34
|
-
const provider = await actor.getChildProvider(action.docId)
|
|
35
|
-
const fragment = provider.document.getXmlFragment('default')
|
|
36
|
-
|
|
37
|
-
provider.document.transact(() => {
|
|
38
|
-
// Offset from by the schema nodes to protect them
|
|
39
|
-
const start = bodyStartIndex(fragment)
|
|
40
|
-
const adjustedFrom = start + action.from
|
|
41
|
-
const count = Math.min(action.length, fragment.length - adjustedFrom)
|
|
42
|
-
if (count > 0) {
|
|
43
|
-
fragment.delete(adjustedFrom, count)
|
|
44
|
-
}
|
|
45
|
-
})
|
|
46
|
-
}
|
package/src/actions/cursor.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cursor actions: moveCursor (animated), select.
|
|
3
|
-
*/
|
|
4
|
-
import type { ActorConnection } from '../actor-connection.ts'
|
|
5
|
-
import type { MoveCursorAction, SelectAction } from '../types.ts'
|
|
6
|
-
import { sleep } from '../utils.ts'
|
|
7
|
-
import { getEasing } from '../easing.ts'
|
|
8
|
-
|
|
9
|
-
export async function executeMoveCursor(
|
|
10
|
-
actor: ActorConnection,
|
|
11
|
-
action: MoveCursorAction
|
|
12
|
-
): Promise<void> {
|
|
13
|
-
const easing = getEasing(action.easing)
|
|
14
|
-
const steps = Math.max(1, Math.round(action.duration / 16))
|
|
15
|
-
const stepDuration = action.duration / steps
|
|
16
|
-
|
|
17
|
-
for (let i = 0; i <= steps; i++) {
|
|
18
|
-
const t = easing(i / steps)
|
|
19
|
-
const pos = Math.round(action.from + (action.to - action.from) * t)
|
|
20
|
-
actor.setCursor(action.docId, pos)
|
|
21
|
-
if (i < steps) await sleep(stepDuration)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export async function executeSelect(
|
|
26
|
-
actor: ActorConnection,
|
|
27
|
-
action: SelectAction
|
|
28
|
-
): Promise<void> {
|
|
29
|
-
actor.setSelection(action.docId, action.anchor, action.head)
|
|
30
|
-
}
|
package/src/actions/document.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Document management actions: createDocument, moveDocument, setMeta.
|
|
3
|
-
* These operate on the Y.js doc-tree map (same as the dashboard and MCP do).
|
|
4
|
-
*/
|
|
5
|
-
import type { ActorConnection } from '../actor-connection.ts'
|
|
6
|
-
import type { CreateDocumentAction, MoveDocumentAction, SetMetaAction, RenameDocumentAction } from '../types.ts'
|
|
7
|
-
import { log } from '../utils.ts'
|
|
8
|
-
|
|
9
|
-
export async function executeCreateDocument(
|
|
10
|
-
actor: ActorConnection,
|
|
11
|
-
action: CreateDocumentAction,
|
|
12
|
-
vars: Map<string, string>
|
|
13
|
-
): Promise<void> {
|
|
14
|
-
const rootProvider = actor.rootProvider
|
|
15
|
-
if (!rootProvider) throw new Error(`${actor.actor.name}: not connected`)
|
|
16
|
-
|
|
17
|
-
const treeMap = rootProvider.document.getMap('doc-tree')
|
|
18
|
-
const id = crypto.randomUUID()
|
|
19
|
-
const now = Date.now()
|
|
20
|
-
|
|
21
|
-
// Normalize parentId: if it matches the root doc, use null (top-level)
|
|
22
|
-
const normalizedParent = action.parentId === actor.rootDocId ? null : action.parentId
|
|
23
|
-
|
|
24
|
-
rootProvider.document.transact(() => {
|
|
25
|
-
treeMap.set(id, {
|
|
26
|
-
label: action.label,
|
|
27
|
-
parentId: normalizedParent,
|
|
28
|
-
order: now,
|
|
29
|
-
type: action.docType,
|
|
30
|
-
meta: action.meta,
|
|
31
|
-
createdAt: now,
|
|
32
|
-
updatedAt: now,
|
|
33
|
-
})
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
log(`${actor.actor.name}: created document "${action.label}" (${id})`)
|
|
37
|
-
|
|
38
|
-
// Store the created ID for later reference in the script
|
|
39
|
-
if (action.assignId) {
|
|
40
|
-
vars.set(action.assignId, id)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export async function executeMoveDocument(
|
|
45
|
-
actor: ActorConnection,
|
|
46
|
-
action: MoveDocumentAction
|
|
47
|
-
): Promise<void> {
|
|
48
|
-
const rootProvider = actor.rootProvider
|
|
49
|
-
if (!rootProvider) throw new Error(`${actor.actor.name}: not connected`)
|
|
50
|
-
|
|
51
|
-
const treeMap = rootProvider.document.getMap('doc-tree')
|
|
52
|
-
const entry = treeMap.get(action.docId) as Record<string, unknown> | undefined
|
|
53
|
-
if (!entry) {
|
|
54
|
-
log(`${actor.actor.name}: document ${action.docId} not found in tree`)
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Normalize parentId
|
|
59
|
-
const normalizedParent = action.newParentId === actor.rootDocId ? null : action.newParentId
|
|
60
|
-
|
|
61
|
-
rootProvider.document.transact(() => {
|
|
62
|
-
treeMap.set(action.docId, {
|
|
63
|
-
...entry,
|
|
64
|
-
parentId: normalizedParent,
|
|
65
|
-
order: action.order ?? Date.now(),
|
|
66
|
-
updatedAt: Date.now(),
|
|
67
|
-
})
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
log(`${actor.actor.name}: moved document ${action.docId} to ${action.newParentId}`)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export async function executeSetMeta(
|
|
74
|
-
actor: ActorConnection,
|
|
75
|
-
action: SetMetaAction
|
|
76
|
-
): Promise<void> {
|
|
77
|
-
const rootProvider = actor.rootProvider
|
|
78
|
-
if (!rootProvider) throw new Error(`${actor.actor.name}: not connected`)
|
|
79
|
-
|
|
80
|
-
const treeMap = rootProvider.document.getMap('doc-tree')
|
|
81
|
-
const entry = treeMap.get(action.docId) as Record<string, unknown> | undefined
|
|
82
|
-
if (!entry) {
|
|
83
|
-
log(`${actor.actor.name}: document ${action.docId} not found in tree`)
|
|
84
|
-
return
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
rootProvider.document.transact(() => {
|
|
88
|
-
const currentMeta = (entry.meta as Record<string, unknown>) ?? {}
|
|
89
|
-
treeMap.set(action.docId, {
|
|
90
|
-
...entry,
|
|
91
|
-
meta: { ...currentMeta, ...action.meta },
|
|
92
|
-
updatedAt: Date.now(),
|
|
93
|
-
})
|
|
94
|
-
})
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export async function executeRenameDocument(
|
|
98
|
-
actor: ActorConnection,
|
|
99
|
-
action: RenameDocumentAction
|
|
100
|
-
): Promise<void> {
|
|
101
|
-
const rootProvider = actor.rootProvider
|
|
102
|
-
if (!rootProvider) throw new Error(`${actor.actor.name}: not connected`)
|
|
103
|
-
|
|
104
|
-
const treeMap = rootProvider.document.getMap('doc-tree')
|
|
105
|
-
const entry = treeMap.get(action.docId) as Record<string, unknown> | undefined
|
|
106
|
-
if (!entry) {
|
|
107
|
-
log(`${actor.actor.name}: document ${action.docId} not found in tree`)
|
|
108
|
-
return
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
rootProvider.document.transact(() => {
|
|
112
|
-
treeMap.set(action.docId, {
|
|
113
|
-
...entry,
|
|
114
|
-
label: action.label,
|
|
115
|
-
updatedAt: Date.now(),
|
|
116
|
-
})
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
log(`${actor.actor.name}: renamed ${action.docId} to "${action.label}"`)
|
|
120
|
-
}
|
package/src/actions/flow.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flow control actions: wait, parallel, sequence.
|
|
3
|
-
*/
|
|
4
|
-
import type { WaitAction, ParallelAction, SequenceAction, RepeatAction, TimelineEntry } from '../types.ts'
|
|
5
|
-
import { sleep } from '../utils.ts'
|
|
6
|
-
import type { ActionExecutor } from './index.ts'
|
|
7
|
-
|
|
8
|
-
export async function executeWait(action: WaitAction): Promise<void> {
|
|
9
|
-
await sleep(action.duration)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export async function executeParallel(
|
|
13
|
-
action: ParallelAction,
|
|
14
|
-
execute: ActionExecutor
|
|
15
|
-
): Promise<void> {
|
|
16
|
-
const promises = action.actions.map(async (entry) => {
|
|
17
|
-
const delay = entry.at ?? 0
|
|
18
|
-
if (delay > 0) await sleep(delay)
|
|
19
|
-
await execute(entry)
|
|
20
|
-
})
|
|
21
|
-
await Promise.all(promises)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export async function executeSequence(
|
|
25
|
-
action: SequenceAction,
|
|
26
|
-
execute: ActionExecutor
|
|
27
|
-
): Promise<void> {
|
|
28
|
-
for (const entry of action.actions) {
|
|
29
|
-
const delay = entry.at ?? 0
|
|
30
|
-
if (delay > 0) await sleep(delay)
|
|
31
|
-
await execute(entry)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export async function executeRepeat(
|
|
36
|
-
action: RepeatAction,
|
|
37
|
-
execute: ActionExecutor
|
|
38
|
-
): Promise<void> {
|
|
39
|
-
for (let n = 0; n < action.times; n++) {
|
|
40
|
-
for (const entry of action.actions) {
|
|
41
|
-
const delay = entry.at ?? 0
|
|
42
|
-
if (delay > 0) await sleep(delay)
|
|
43
|
-
await execute(entry)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
package/src/actions/index.ts
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Action dispatcher — routes Action.type to the correct executor.
|
|
3
|
-
*/
|
|
4
|
-
import type { ActorConnection } from '../actor-connection.ts'
|
|
5
|
-
import type { Action, TimelineEntry, ServerConfig } from '../types.ts'
|
|
6
|
-
import { executeConnect, executeDisconnect } from './connect.ts'
|
|
7
|
-
import { executeNavigate } from './navigate.ts'
|
|
8
|
-
import { executeType, executeTypeDelete } from './type.ts'
|
|
9
|
-
import { executeMoveCursor, executeSelect } from './cursor.ts'
|
|
10
|
-
import { executeWriteContent, executeDeleteContent } from './content.ts'
|
|
11
|
-
import {
|
|
12
|
-
executeSetStatus,
|
|
13
|
-
executeSetAwareness,
|
|
14
|
-
executeClearAwareness,
|
|
15
|
-
executePointerMove,
|
|
16
|
-
executeScrollTo,
|
|
17
|
-
executeKanbanHover,
|
|
18
|
-
executeKanbanDrag,
|
|
19
|
-
} from './awareness.ts'
|
|
20
|
-
import { executeCreateDocument, executeMoveDocument, executeSetMeta, executeRenameDocument } from './document.ts'
|
|
21
|
-
import { executeSendChat } from './chat.ts'
|
|
22
|
-
import { executeWait, executeParallel, executeSequence, executeRepeat } from './flow.ts'
|
|
23
|
-
|
|
24
|
-
export type ActionExecutor = (entry: TimelineEntry) => Promise<void>
|
|
25
|
-
|
|
26
|
-
export interface ActionContext {
|
|
27
|
-
actors: Map<string, ActorConnection>
|
|
28
|
-
serverConfig: ServerConfig
|
|
29
|
-
vars: Map<string, string>
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Resolve variable references in string values.
|
|
34
|
-
* Replaces ${varName} with the value from vars map.
|
|
35
|
-
*/
|
|
36
|
-
function resolveVars(value: string, vars: Map<string, string>): string {
|
|
37
|
-
return value.replace(/\$\{(\w+)\}/g, (_, key) => vars.get(key) ?? `\${${key}}`)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function resolveActionVars(action: Action, vars: Map<string, string>): Action {
|
|
41
|
-
if (vars.size === 0) return action
|
|
42
|
-
|
|
43
|
-
// Clone to avoid mutating the original scene definition
|
|
44
|
-
const a = { ...action } as any
|
|
45
|
-
|
|
46
|
-
// Resolve ID fields
|
|
47
|
-
if (a.docId && typeof a.docId === 'string') a.docId = resolveVars(a.docId, vars)
|
|
48
|
-
if (a.parentId && typeof a.parentId === 'string') a.parentId = resolveVars(a.parentId, vars)
|
|
49
|
-
if (a.newParentId && typeof a.newParentId === 'string') a.newParentId = resolveVars(a.newParentId, vars)
|
|
50
|
-
if (a.cardId && typeof a.cardId === 'string') a.cardId = resolveVars(a.cardId, vars)
|
|
51
|
-
if (a.toColumnId && typeof a.toColumnId === 'string') a.toColumnId = resolveVars(a.toColumnId, vars)
|
|
52
|
-
|
|
53
|
-
// Resolve content fields
|
|
54
|
-
if (a.text && typeof a.text === 'string') a.text = resolveVars(a.text, vars)
|
|
55
|
-
if (a.label && typeof a.label === 'string') a.label = resolveVars(a.label, vars)
|
|
56
|
-
if (a.markdown && typeof a.markdown === 'string') a.markdown = resolveVars(a.markdown, vars)
|
|
57
|
-
if (a.channel && typeof a.channel === 'string') a.channel = resolveVars(a.channel, vars)
|
|
58
|
-
if (a.message && typeof a.message === 'string') a.message = resolveVars(a.message, vars)
|
|
59
|
-
|
|
60
|
-
return a
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function createExecutor(ctx: ActionContext): ActionExecutor {
|
|
64
|
-
const execute: ActionExecutor = async (entry: TimelineEntry) => {
|
|
65
|
-
const action = resolveActionVars(entry.action, ctx.vars)
|
|
66
|
-
const actor = entry.actor ? ctx.actors.get(entry.actor) : undefined
|
|
67
|
-
|
|
68
|
-
switch (action.type) {
|
|
69
|
-
case 'connect': {
|
|
70
|
-
if (!actor) throw new Error('connect requires an actor')
|
|
71
|
-
await executeConnect(actor, ctx.serverConfig)
|
|
72
|
-
break
|
|
73
|
-
}
|
|
74
|
-
case 'disconnect': {
|
|
75
|
-
if (!actor) throw new Error('disconnect requires an actor')
|
|
76
|
-
await executeDisconnect(actor)
|
|
77
|
-
break
|
|
78
|
-
}
|
|
79
|
-
case 'navigate': {
|
|
80
|
-
if (!actor) throw new Error('navigate requires an actor')
|
|
81
|
-
await executeNavigate(actor, action)
|
|
82
|
-
break
|
|
83
|
-
}
|
|
84
|
-
case 'type': {
|
|
85
|
-
if (!actor) throw new Error('type requires an actor')
|
|
86
|
-
await executeType(actor, action)
|
|
87
|
-
break
|
|
88
|
-
}
|
|
89
|
-
case 'typeDelete': {
|
|
90
|
-
if (!actor) throw new Error('typeDelete requires an actor')
|
|
91
|
-
await executeTypeDelete(actor, action)
|
|
92
|
-
break
|
|
93
|
-
}
|
|
94
|
-
case 'select': {
|
|
95
|
-
if (!actor) throw new Error('select requires an actor')
|
|
96
|
-
await executeSelect(actor, action)
|
|
97
|
-
break
|
|
98
|
-
}
|
|
99
|
-
case 'moveCursor': {
|
|
100
|
-
if (!actor) throw new Error('moveCursor requires an actor')
|
|
101
|
-
await executeMoveCursor(actor, action)
|
|
102
|
-
break
|
|
103
|
-
}
|
|
104
|
-
case 'setStatus': {
|
|
105
|
-
if (!actor) throw new Error('setStatus requires an actor')
|
|
106
|
-
await executeSetStatus(actor, action)
|
|
107
|
-
break
|
|
108
|
-
}
|
|
109
|
-
case 'setAwareness': {
|
|
110
|
-
if (!actor) throw new Error('setAwareness requires an actor')
|
|
111
|
-
await executeSetAwareness(actor, action)
|
|
112
|
-
break
|
|
113
|
-
}
|
|
114
|
-
case 'clearAwareness': {
|
|
115
|
-
if (!actor) throw new Error('clearAwareness requires an actor')
|
|
116
|
-
await executeClearAwareness(actor, action)
|
|
117
|
-
break
|
|
118
|
-
}
|
|
119
|
-
case 'createDocument': {
|
|
120
|
-
if (!actor) throw new Error('createDocument requires an actor')
|
|
121
|
-
await executeCreateDocument(actor, action, ctx.vars)
|
|
122
|
-
break
|
|
123
|
-
}
|
|
124
|
-
case 'moveDocument': {
|
|
125
|
-
if (!actor) throw new Error('moveDocument requires an actor')
|
|
126
|
-
await executeMoveDocument(actor, action)
|
|
127
|
-
break
|
|
128
|
-
}
|
|
129
|
-
case 'renameDocument': {
|
|
130
|
-
if (!actor) throw new Error('renameDocument requires an actor')
|
|
131
|
-
await executeRenameDocument(actor, action)
|
|
132
|
-
break
|
|
133
|
-
}
|
|
134
|
-
case 'writeContent': {
|
|
135
|
-
if (!actor) throw new Error('writeContent requires an actor')
|
|
136
|
-
await executeWriteContent(actor, action)
|
|
137
|
-
break
|
|
138
|
-
}
|
|
139
|
-
case 'deleteContent': {
|
|
140
|
-
if (!actor) throw new Error('deleteContent requires an actor')
|
|
141
|
-
await executeDeleteContent(actor, action)
|
|
142
|
-
break
|
|
143
|
-
}
|
|
144
|
-
case 'setMeta': {
|
|
145
|
-
if (!actor) throw new Error('setMeta requires an actor')
|
|
146
|
-
await executeSetMeta(actor, action)
|
|
147
|
-
break
|
|
148
|
-
}
|
|
149
|
-
case 'pointerMove': {
|
|
150
|
-
if (!actor) throw new Error('pointerMove requires an actor')
|
|
151
|
-
await executePointerMove(actor, action)
|
|
152
|
-
break
|
|
153
|
-
}
|
|
154
|
-
case 'scrollTo': {
|
|
155
|
-
if (!actor) throw new Error('scrollTo requires an actor')
|
|
156
|
-
await executeScrollTo(actor, action)
|
|
157
|
-
break
|
|
158
|
-
}
|
|
159
|
-
case 'kanbanHover': {
|
|
160
|
-
if (!actor) throw new Error('kanbanHover requires an actor')
|
|
161
|
-
await executeKanbanHover(actor, action)
|
|
162
|
-
break
|
|
163
|
-
}
|
|
164
|
-
case 'kanbanDrag': {
|
|
165
|
-
if (!actor) throw new Error('kanbanDrag requires an actor')
|
|
166
|
-
await executeKanbanDrag(actor, action)
|
|
167
|
-
break
|
|
168
|
-
}
|
|
169
|
-
case 'sendChat': {
|
|
170
|
-
if (!actor) throw new Error('sendChat requires an actor')
|
|
171
|
-
await executeSendChat(actor, action)
|
|
172
|
-
break
|
|
173
|
-
}
|
|
174
|
-
case 'wait': {
|
|
175
|
-
await executeWait(action)
|
|
176
|
-
break
|
|
177
|
-
}
|
|
178
|
-
case 'parallel': {
|
|
179
|
-
await executeParallel(action, execute)
|
|
180
|
-
break
|
|
181
|
-
}
|
|
182
|
-
case 'sequence': {
|
|
183
|
-
await executeSequence(action, execute)
|
|
184
|
-
break
|
|
185
|
-
}
|
|
186
|
-
case 'repeat': {
|
|
187
|
-
await executeRepeat(action, execute)
|
|
188
|
-
break
|
|
189
|
-
}
|
|
190
|
-
default: {
|
|
191
|
-
throw new Error(`Unknown action type: ${(action as any).type}`)
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return execute
|
|
197
|
-
}
|
package/src/actions/navigate.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Navigate action — sets which document an actor is viewing.
|
|
3
|
-
*/
|
|
4
|
-
import type { ActorConnection } from '../actor-connection.ts'
|
|
5
|
-
import type { NavigateAction } from '../types.ts'
|
|
6
|
-
|
|
7
|
-
export async function executeNavigate(
|
|
8
|
-
actor: ActorConnection,
|
|
9
|
-
action: NavigateAction
|
|
10
|
-
): Promise<void> {
|
|
11
|
-
// Set docId in root awareness (this is what the dashboard watches for presence)
|
|
12
|
-
actor.setRootAwareness('docId', action.docId)
|
|
13
|
-
// Pre-load the child provider so subsequent actions on this doc are fast
|
|
14
|
-
await actor.getChildProvider(action.docId)
|
|
15
|
-
}
|