officepals 0.0.0-stage → 0.3.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/LICENSE +21 -0
- package/README.md +122 -2
- package/bin/officepals.mjs +196 -0
- package/package.json +39 -4
- package/src/hook.mjs +370 -0
- package/src/install.mjs +197 -0
- package/src/paths.mjs +20 -0
- package/src/server.mjs +244 -0
- package/src/sessions.mjs +73 -0
- package/src/state.mjs +295 -0
- package/src/stats.mjs +72 -0
- package/src/title.mjs +100 -0
- package/web/index.html +2947 -0
- package/web/tool-kinds.js +43 -0
- package/web/vendor/three/CSS2DRenderer.js +238 -0
- package/web/vendor/three/LICENSE +21 -0
- package/web/vendor/three/OrbitControls.js +1523 -0
- package/web/vendor/three/README.md +5 -0
- package/web/vendor/three/RoundedBoxGeometry.js +155 -0
- package/web/vendor/three/three.module.min.js +6 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// What a tool call is for, by its name: the office uses the kind to pick a
|
|
2
|
+
// label and a place. Shared by the page and the tests.
|
|
3
|
+
//
|
|
4
|
+
// MCP tools arrive as mcp__<server>__<tool>; they're matched on "server tool",
|
|
5
|
+
// first hit wins. Built-in tools the page doesn't already know are listed.
|
|
6
|
+
|
|
7
|
+
/** Built-in tools by kind. */
|
|
8
|
+
export const BUILTIN_KIND = {
|
|
9
|
+
TodoWrite: 'note', TaskCreate: 'note', TaskUpdate: 'note', TaskList: 'note', TaskGet: 'note', EnterPlanMode: 'note',
|
|
10
|
+
CronCreate: 'note', CronDelete: 'note', ScheduleWakeup: 'note', SendMessage: 'msg', SendUserFile: 'file',
|
|
11
|
+
Skill: 'skill', ToolSearch: 'skill', TaskStop: 'stop', KillShell: 'stop', KillBash: 'stop', Monitor: 'watch',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const MCP_KINDS = [
|
|
15
|
+
[/wrap_?up|summar/, 'sum'],
|
|
16
|
+
[/update_plan|todo|task|plan\b|chapter|schedul|cron|reminder/, 'note'],
|
|
17
|
+
[/screenshot/, 'shot'],
|
|
18
|
+
[/browser|playwright|puppeteer|preview|chrome|webpage|navigate/, 'browse'],
|
|
19
|
+
[/sentry|bugsnag|rollbar|datadog|crash/, 'bugs'],
|
|
20
|
+
[/github|gitlab|bitbucket|pull_?request|issue/, 'repo'],
|
|
21
|
+
[/postgres|mysql|sqlite|\bsql|supabase|database|\bdb\b|mongo|redis|bigquery|snowflake|clickhouse/, 'db'],
|
|
22
|
+
[/slack|discord|telegram|gmail|email|\bmail|message|notify/, 'msg'],
|
|
23
|
+
[/terminal|shell|\bexec|command|bash/, 'term'],
|
|
24
|
+
[/figma|sketch|canva|design/, 'design'],
|
|
25
|
+
[/context7|docs|documentation|search|fetch|\bweb|exa\b|tavily|brave|perplexity|wiki/, 'docs'],
|
|
26
|
+
[/notion|linear|jira|asana|trello|calendar/, 'note'],
|
|
27
|
+
[/memory|knowledge|filesystem|\bfile/, 'files'],
|
|
28
|
+
[/view|window|pane|layout|editor|reveal|directory|sidebar/, 'ui'],
|
|
29
|
+
[/session/, 'session'],
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
/** Quick bookkeeping: changes the label only, nobody walks anywhere. */
|
|
33
|
+
export const STAY_KINDS = new Set(['note', 'sum', 'ui', 'session']);
|
|
34
|
+
|
|
35
|
+
/** The kind of a tool: listed built-ins and every MCP tool ('other' when
|
|
36
|
+
* nothing matches); null for the core tools the page handles itself. */
|
|
37
|
+
export function kindOfTool(tool) {
|
|
38
|
+
if (BUILTIN_KIND[tool]) return BUILTIN_KIND[tool];
|
|
39
|
+
if (typeof tool !== 'string' || !tool.startsWith('mcp__')) return null;
|
|
40
|
+
const [, server = '', name = ''] = tool.split('__');
|
|
41
|
+
const hay = `${server} ${name}`.toLowerCase();
|
|
42
|
+
return MCP_KINDS.find(([re]) => re.test(hay))?.[1] ?? 'other';
|
|
43
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Matrix4,
|
|
3
|
+
Object3D,
|
|
4
|
+
Vector2,
|
|
5
|
+
Vector3
|
|
6
|
+
} from 'three';
|
|
7
|
+
|
|
8
|
+
class CSS2DObject extends Object3D {
|
|
9
|
+
|
|
10
|
+
constructor( element = document.createElement( 'div' ) ) {
|
|
11
|
+
|
|
12
|
+
super();
|
|
13
|
+
|
|
14
|
+
this.isCSS2DObject = true;
|
|
15
|
+
|
|
16
|
+
this.element = element;
|
|
17
|
+
|
|
18
|
+
this.element.style.position = 'absolute';
|
|
19
|
+
this.element.style.userSelect = 'none';
|
|
20
|
+
|
|
21
|
+
this.element.setAttribute( 'draggable', false );
|
|
22
|
+
|
|
23
|
+
this.center = new Vector2( 0.5, 0.5 ); // ( 0, 0 ) is the lower left; ( 1, 1 ) is the top right
|
|
24
|
+
|
|
25
|
+
this.addEventListener( 'removed', function () {
|
|
26
|
+
|
|
27
|
+
this.traverse( function ( object ) {
|
|
28
|
+
|
|
29
|
+
if (
|
|
30
|
+
object.element instanceof object.element.ownerDocument.defaultView.Element &&
|
|
31
|
+
object.element.parentNode !== null
|
|
32
|
+
) {
|
|
33
|
+
|
|
34
|
+
object.element.remove();
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
} );
|
|
39
|
+
|
|
40
|
+
} );
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
copy( source, recursive ) {
|
|
45
|
+
|
|
46
|
+
super.copy( source, recursive );
|
|
47
|
+
|
|
48
|
+
this.element = source.element.cloneNode( true );
|
|
49
|
+
|
|
50
|
+
this.center = source.center;
|
|
51
|
+
|
|
52
|
+
return this;
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
//
|
|
59
|
+
|
|
60
|
+
const _vector = new Vector3();
|
|
61
|
+
const _viewMatrix = new Matrix4();
|
|
62
|
+
const _viewProjectionMatrix = new Matrix4();
|
|
63
|
+
const _a = new Vector3();
|
|
64
|
+
const _b = new Vector3();
|
|
65
|
+
|
|
66
|
+
class CSS2DRenderer {
|
|
67
|
+
|
|
68
|
+
constructor( parameters = {} ) {
|
|
69
|
+
|
|
70
|
+
const _this = this;
|
|
71
|
+
|
|
72
|
+
let _width, _height;
|
|
73
|
+
let _widthHalf, _heightHalf;
|
|
74
|
+
|
|
75
|
+
const cache = {
|
|
76
|
+
objects: new WeakMap()
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const domElement = parameters.element !== undefined ? parameters.element : document.createElement( 'div' );
|
|
80
|
+
|
|
81
|
+
domElement.style.overflow = 'hidden';
|
|
82
|
+
|
|
83
|
+
this.domElement = domElement;
|
|
84
|
+
|
|
85
|
+
this.getSize = function () {
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
width: _width,
|
|
89
|
+
height: _height
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
this.render = function ( scene, camera ) {
|
|
95
|
+
|
|
96
|
+
if ( scene.matrixWorldAutoUpdate === true ) scene.updateMatrixWorld();
|
|
97
|
+
if ( camera.parent === null && camera.matrixWorldAutoUpdate === true ) camera.updateMatrixWorld();
|
|
98
|
+
|
|
99
|
+
_viewMatrix.copy( camera.matrixWorldInverse );
|
|
100
|
+
_viewProjectionMatrix.multiplyMatrices( camera.projectionMatrix, _viewMatrix );
|
|
101
|
+
|
|
102
|
+
renderObject( scene, scene, camera );
|
|
103
|
+
zOrder( scene );
|
|
104
|
+
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
this.setSize = function ( width, height ) {
|
|
108
|
+
|
|
109
|
+
_width = width;
|
|
110
|
+
_height = height;
|
|
111
|
+
|
|
112
|
+
_widthHalf = _width / 2;
|
|
113
|
+
_heightHalf = _height / 2;
|
|
114
|
+
|
|
115
|
+
domElement.style.width = width + 'px';
|
|
116
|
+
domElement.style.height = height + 'px';
|
|
117
|
+
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
function hideObject( object ) {
|
|
121
|
+
|
|
122
|
+
if ( object.isCSS2DObject ) object.element.style.display = 'none';
|
|
123
|
+
|
|
124
|
+
for ( let i = 0, l = object.children.length; i < l; i ++ ) {
|
|
125
|
+
|
|
126
|
+
hideObject( object.children[ i ] );
|
|
127
|
+
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function renderObject( object, scene, camera ) {
|
|
133
|
+
|
|
134
|
+
if ( object.visible === false ) {
|
|
135
|
+
|
|
136
|
+
hideObject( object );
|
|
137
|
+
|
|
138
|
+
return;
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if ( object.isCSS2DObject ) {
|
|
143
|
+
|
|
144
|
+
_vector.setFromMatrixPosition( object.matrixWorld );
|
|
145
|
+
_vector.applyMatrix4( _viewProjectionMatrix );
|
|
146
|
+
|
|
147
|
+
const visible = ( _vector.z >= - 1 && _vector.z <= 1 ) && ( object.layers.test( camera.layers ) === true );
|
|
148
|
+
|
|
149
|
+
const element = object.element;
|
|
150
|
+
element.style.display = visible === true ? '' : 'none';
|
|
151
|
+
|
|
152
|
+
if ( visible === true ) {
|
|
153
|
+
|
|
154
|
+
object.onBeforeRender( _this, scene, camera );
|
|
155
|
+
|
|
156
|
+
element.style.transform = 'translate(' + ( - 100 * object.center.x ) + '%,' + ( - 100 * object.center.y ) + '%)' + 'translate(' + ( _vector.x * _widthHalf + _widthHalf ) + 'px,' + ( - _vector.y * _heightHalf + _heightHalf ) + 'px)';
|
|
157
|
+
|
|
158
|
+
if ( element.parentNode !== domElement ) {
|
|
159
|
+
|
|
160
|
+
domElement.appendChild( element );
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
object.onAfterRender( _this, scene, camera );
|
|
165
|
+
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const objectData = {
|
|
169
|
+
distanceToCameraSquared: getDistanceToSquared( camera, object )
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
cache.objects.set( object, objectData );
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
for ( let i = 0, l = object.children.length; i < l; i ++ ) {
|
|
177
|
+
|
|
178
|
+
renderObject( object.children[ i ], scene, camera );
|
|
179
|
+
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function getDistanceToSquared( object1, object2 ) {
|
|
185
|
+
|
|
186
|
+
_a.setFromMatrixPosition( object1.matrixWorld );
|
|
187
|
+
_b.setFromMatrixPosition( object2.matrixWorld );
|
|
188
|
+
|
|
189
|
+
return _a.distanceToSquared( _b );
|
|
190
|
+
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function filterAndFlatten( scene ) {
|
|
194
|
+
|
|
195
|
+
const result = [];
|
|
196
|
+
|
|
197
|
+
scene.traverseVisible( function ( object ) {
|
|
198
|
+
|
|
199
|
+
if ( object.isCSS2DObject ) result.push( object );
|
|
200
|
+
|
|
201
|
+
} );
|
|
202
|
+
|
|
203
|
+
return result;
|
|
204
|
+
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function zOrder( scene ) {
|
|
208
|
+
|
|
209
|
+
const sorted = filterAndFlatten( scene ).sort( function ( a, b ) {
|
|
210
|
+
|
|
211
|
+
if ( a.renderOrder !== b.renderOrder ) {
|
|
212
|
+
|
|
213
|
+
return b.renderOrder - a.renderOrder;
|
|
214
|
+
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const distanceA = cache.objects.get( a ).distanceToCameraSquared;
|
|
218
|
+
const distanceB = cache.objects.get( b ).distanceToCameraSquared;
|
|
219
|
+
|
|
220
|
+
return distanceA - distanceB;
|
|
221
|
+
|
|
222
|
+
} );
|
|
223
|
+
|
|
224
|
+
const zMax = sorted.length;
|
|
225
|
+
|
|
226
|
+
for ( let i = 0, l = sorted.length; i < l; i ++ ) {
|
|
227
|
+
|
|
228
|
+
sorted[ i ].element.style.zIndex = zMax - i;
|
|
229
|
+
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export { CSS2DObject, CSS2DRenderer };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright © 2010-2024 three.js authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|