@datalayer/reactor-excalidraw 0.0.0 → 1.3.11
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/LICENSE +29 -0
- package/README.md +113 -1
- package/lib/definitions.d.ts +30 -0
- package/lib/definitions.d.ts.map +1 -0
- package/lib/definitions.js +186 -0
- package/lib/definitions.js.map +1 -0
- package/lib/handlers.d.ts +128 -0
- package/lib/handlers.d.ts.map +1 -0
- package/lib/handlers.js +570 -0
- package/lib/handlers.js.map +1 -0
- package/lib/host.d.ts +88 -0
- package/lib/host.d.ts.map +1 -0
- package/lib/host.js +73 -0
- package/lib/host.js.map +1 -0
- package/lib/index.d.ts +21 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +26 -0
- package/lib/index.js.map +1 -0
- package/lib/operations.d.ts +73 -0
- package/lib/operations.d.ts.map +1 -0
- package/lib/operations.js +85 -0
- package/lib/operations.js.map +1 -0
- package/lib/plugin.d.ts +10 -0
- package/lib/plugin.d.ts.map +1 -0
- package/lib/plugin.js +66 -0
- package/lib/plugin.js.map +1 -0
- package/lib/scene.d.ts +101 -0
- package/lib/scene.d.ts.map +1 -0
- package/lib/scene.js +168 -0
- package/lib/scene.js.map +1 -0
- package/lib/schemas.d.ts +230 -0
- package/lib/schemas.d.ts.map +1 -0
- package/lib/schemas.js +209 -0
- package/lib/schemas.js.map +1 -0
- package/lib/tools.d.ts +33 -0
- package/lib/tools.d.ts.map +1 -0
- package/lib/tools.js +92 -0
- package/lib/tools.js.map +1 -0
- package/package.json +44 -4
package/lib/tools.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026-Present Datalayer, Inc.
|
|
3
|
+
*
|
|
4
|
+
* BSD 3-Clause License
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The Excalidraw tools, as one thing a host can hand over.
|
|
8
|
+
*
|
|
9
|
+
* Definitions, operations and handlers travel together because they are three
|
|
10
|
+
* views of the same eleven tools, and a set that has drifted — a definition
|
|
11
|
+
* pointing at an operation nobody wrote, a handler nobody advertises — is a
|
|
12
|
+
* tool that fails at call time rather than at build time. Keeping them
|
|
13
|
+
* adjacent is what {@link excalidrawToolMismatches} is able to exploit.
|
|
14
|
+
*
|
|
15
|
+
* @module tools
|
|
16
|
+
*/
|
|
17
|
+
import { defineAgentTools } from '@datalayer/reactor';
|
|
18
|
+
import { excalidrawToolDefinitions } from './definitions.js';
|
|
19
|
+
import { excalidrawToolOperations } from './operations.js';
|
|
20
|
+
/** The plugin's short name: the tools bundle's id and the commands' namespace. */
|
|
21
|
+
export const EXCALIDRAW_TOOLS_NAME = 'excalidraw';
|
|
22
|
+
/** What a host registers with an agent: what exists, and what runs it. */
|
|
23
|
+
export const excalidrawTools = {
|
|
24
|
+
name: EXCALIDRAW_TOOLS_NAME,
|
|
25
|
+
definitions: excalidrawToolDefinitions,
|
|
26
|
+
operations: excalidrawToolOperations,
|
|
27
|
+
};
|
|
28
|
+
/** The reactor command a tool's operation runs as: `excalidraw.excalidrawReadScene`. */
|
|
29
|
+
export const excalidrawCommandOf = (operation) => `${EXCALIDRAW_TOOLS_NAME}.${operation}`;
|
|
30
|
+
/**
|
|
31
|
+
* The executor the operations hand their validated calls to, over a set of
|
|
32
|
+
* handlers. Refuses an operation it has no handler for.
|
|
33
|
+
*/
|
|
34
|
+
export function createExcalidrawExecutor(handlers) {
|
|
35
|
+
return {
|
|
36
|
+
execute: async (operationName, args) => {
|
|
37
|
+
const handler = handlers[operationName];
|
|
38
|
+
if (!handler) {
|
|
39
|
+
throw new Error(`No Excalidraw handler for '${operationName}'.`);
|
|
40
|
+
}
|
|
41
|
+
return handler((args ?? {}));
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The tools as a reactor `AgentTools` bundle: each tool is the plugin's
|
|
47
|
+
* command of its operation, with the tool's name, description and
|
|
48
|
+
* parameters.
|
|
49
|
+
*/
|
|
50
|
+
export const EXCALIDRAW_AGENT_TOOLS = defineAgentTools({
|
|
51
|
+
id: EXCALIDRAW_TOOLS_NAME,
|
|
52
|
+
name: 'Excalidraw',
|
|
53
|
+
description: 'Draw diagrams in Excalidraw: insert a drawing, read it, add, change, connect and delete its shapes, and turn Mermaid source into shapes.',
|
|
54
|
+
plugin: '@datalayer/reactor-excalidraw',
|
|
55
|
+
commands: excalidrawToolDefinitions.map((definition) => ({
|
|
56
|
+
name: definition.name,
|
|
57
|
+
command: excalidrawCommandOf(definition.operation),
|
|
58
|
+
description: definition.description,
|
|
59
|
+
parameters: definition.parameters,
|
|
60
|
+
})),
|
|
61
|
+
});
|
|
62
|
+
/**
|
|
63
|
+
* The operation names the three halves disagree about, if any.
|
|
64
|
+
*
|
|
65
|
+
* A definition without an operation is a tool the model can call and nothing
|
|
66
|
+
* answers; an operation without a handler is a call that reaches the executor
|
|
67
|
+
* and finds nothing to run. Neither shows up until an agent tries it, which
|
|
68
|
+
* is far too late — so this is checked in the tests, where it is cheap.
|
|
69
|
+
*/
|
|
70
|
+
export function excalidrawToolMismatches(handlers) {
|
|
71
|
+
const problems = [];
|
|
72
|
+
for (const definition of excalidrawToolDefinitions) {
|
|
73
|
+
if (!excalidrawToolOperations[definition.operation]) {
|
|
74
|
+
problems.push(`${definition.name} points at operation '${definition.operation}', which does not exist`);
|
|
75
|
+
}
|
|
76
|
+
if (!definition.toolReferenceName.startsWith('excalidraw')) {
|
|
77
|
+
problems.push(`${definition.name} is not named for the plugin it belongs to`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
for (const name of Object.keys(excalidrawToolOperations)) {
|
|
81
|
+
if (!handlers[name]) {
|
|
82
|
+
problems.push(`operation '${name}' has no handler`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
for (const name of Object.keys(handlers)) {
|
|
86
|
+
if (!excalidrawToolOperations[name]) {
|
|
87
|
+
problems.push(`handler '${name}' has no operation`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return problems;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=tools.js.map
|
package/lib/tools.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAExD,kFAAkF;AAClF,MAAM,CAAC,MAAM,qBAAqB,GAAG,YAAY,CAAC;AAElD,0EAA0E;AAC1E,MAAM,CAAC,MAAM,eAAe,GAIxB;IACF,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,yBAAyB;IACtC,UAAU,EAAE,wBAAwB;CACrC,CAAC;AAEF,wFAAwF;AACxF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,SAAiB,EAAU,EAAE,CAC/D,GAAG,qBAAqB,IAAI,SAAS,EAAE,CAAC;AAE1C;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACtC,QAA+C;IAE/C,OAAO;QACL,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,EAAE;YACrC,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;YACxC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,MAAM,IAAI,KAAK,CAAC,8BAA8B,aAAa,IAAI,CAAC,CAAC;YACnE,CAAC;YACD,OAAO,OAAO,CAAC,CAAC,IAAI,IAAI,EAAE,CAA4B,CAAC,CAAC;QAC1D,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;IACrD,EAAE,EAAE,qBAAqB;IACzB,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CAAC,IAAI,CAAC,YAAY,IAAI,oBAAoB,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datalayer/reactor-excalidraw",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
3
|
+
"version": "1.3.11",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/datalayer/reactor.git",
|
|
7
|
+
"directory": "plugins/excalidraw"
|
|
8
|
+
},
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"description": "Excalidraw drawings as AI agent tools for a Datalayer Reactor platform: the tool definitions, their schemas and operations, and a pure scene model, over any host that keeps drawings.",
|
|
5
13
|
"license": "BSD-3-Clause",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "lib/index.js",
|
|
16
|
+
"types": "lib/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./lib/index.d.ts",
|
|
20
|
+
"import": "./lib/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"lib"
|
|
25
|
+
],
|
|
26
|
+
"keywords": [
|
|
27
|
+
"datalayer",
|
|
28
|
+
"reactor",
|
|
29
|
+
"plugins",
|
|
30
|
+
"excalidraw",
|
|
31
|
+
"agent",
|
|
32
|
+
"tools"
|
|
33
|
+
],
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"typescript": "5.9.3",
|
|
36
|
+
"zod": "^4.1.13"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc -p tsconfig.json && node ../../scripts/fully-specify-lib.mjs lib",
|
|
40
|
+
"check:pack": "node ../../scripts/check-npm-pack.mjs",
|
|
41
|
+
"typecheck": "tsc -p tsconfig.typecheck.json",
|
|
42
|
+
"clean": "rm -rf lib"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@datalayer/reactor": "^1.3.0",
|
|
46
|
+
"zod": ">=3.23"
|
|
47
|
+
}
|
|
8
48
|
}
|