teamshare-bridge 0.1.0 → 0.2.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/dist/bridge/daemon.js +239 -8
- package/dist/bridge/daemon.js.map +1 -1
- package/dist/bridge/index.js +10 -0
- package/dist/bridge/index.js.map +1 -1
- package/dist/bridge/local-server.d.ts +6 -1
- package/dist/bridge/local-server.js +24 -0
- package/dist/bridge/local-server.js.map +1 -1
- package/dist/bridge/protocol.js +33 -4
- package/dist/bridge/protocol.js.map +1 -1
- package/dist/bridge/spawn.d.ts +20 -4
- package/dist/bridge/spawn.js +93 -29
- package/dist/bridge/spawn.js.map +1 -1
- package/dist/cli/index.js +1102 -64
- package/dist/cli/index.js.map +1 -1
- package/dist/lib/api.d.ts +203 -5
- package/dist/lib/api.js +144 -3
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/chat-reply.d.ts +22 -2
- package/dist/lib/chat-reply.js +139 -67
- package/dist/lib/chat-reply.js.map +1 -1
- package/dist/lib/config.d.ts +103 -0
- package/dist/lib/config.js +272 -0
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/doc-reply.d.ts +11 -0
- package/dist/lib/doc-reply.js +18 -34
- package/dist/lib/doc-reply.js.map +1 -1
- package/dist/lib/harness.d.ts +38 -0
- package/dist/lib/harness.js +139 -0
- package/dist/lib/harness.js.map +1 -0
- package/dist/lib/llm.d.ts +30 -2
- package/dist/lib/llm.js +284 -30
- package/dist/lib/llm.js.map +1 -1
- package/dist/lib/lock.d.ts +1 -1
- package/dist/lib/models.d.ts +11 -0
- package/dist/lib/models.js +30 -1
- package/dist/lib/models.js.map +1 -1
- package/dist/lib/orchestrator/client.d.ts +27 -0
- package/dist/lib/orchestrator/client.js +135 -0
- package/dist/lib/orchestrator/client.js.map +1 -0
- package/dist/lib/orchestrator/index.d.ts +5 -0
- package/dist/lib/orchestrator/index.js +17 -0
- package/dist/lib/orchestrator/index.js.map +1 -0
- package/dist/lib/orchestrator/runner.d.ts +18 -0
- package/dist/lib/orchestrator/runner.js +177 -0
- package/dist/lib/orchestrator/runner.js.map +1 -0
- package/dist/lib/orchestrator/worktree.d.ts +43 -0
- package/dist/lib/orchestrator/worktree.js +243 -0
- package/dist/lib/orchestrator/worktree.js.map +1 -0
- package/dist/lib/session-stream.d.ts +1 -1
- package/dist/lib/skills.d.ts +21 -0
- package/dist/lib/skills.js +80 -0
- package/dist/lib/skills.js.map +1 -0
- package/dist/lib/usage.d.ts +52 -0
- package/dist/lib/usage.js +69 -0
- package/dist/lib/usage.js.map +1 -0
- package/package.json +3 -1
- package/skills/teamshare-auth-rbac/SKILL.md +79 -0
- package/skills/teamshare-cdd/SKILL.md +145 -0
- package/skills/teamshare-modularity/SKILL.md +92 -0
- package/tools/usage_report.py +223 -0
package/dist/lib/config.js
CHANGED
|
@@ -6,13 +6,26 @@ exports.defaultConfig = defaultConfig;
|
|
|
6
6
|
exports.loadConfig = loadConfig;
|
|
7
7
|
exports.saveConfig = saveConfig;
|
|
8
8
|
exports.upsertAgent = upsertAgent;
|
|
9
|
+
exports.preflightFolder = preflightFolder;
|
|
10
|
+
exports.linkProject = linkProject;
|
|
11
|
+
exports.unlinkProject = unlinkProject;
|
|
12
|
+
exports.projectCwd = projectCwd;
|
|
13
|
+
exports.linkHint = linkHint;
|
|
14
|
+
exports.setOpenCodeKey = setOpenCodeKey;
|
|
15
|
+
exports.agentOpenCodeKey = agentOpenCodeKey;
|
|
16
|
+
exports.setChatKey = setChatKey;
|
|
17
|
+
exports.chatKey = chatKey;
|
|
9
18
|
exports.msg = msg;
|
|
19
|
+
exports.wireOpencodeMcp = wireOpencodeMcp;
|
|
20
|
+
exports.unwireOpencodeMcp = unwireOpencodeMcp;
|
|
21
|
+
exports.mcpStatus = mcpStatus;
|
|
10
22
|
/**
|
|
11
23
|
* teamshare-bridge config: ~/.teamshare/config.json
|
|
12
24
|
*/
|
|
13
25
|
const node_fs_1 = require("node:fs");
|
|
14
26
|
const node_os_1 = require("node:os");
|
|
15
27
|
const node_path_1 = require("node:path");
|
|
28
|
+
const node_child_process_1 = require("node:child_process");
|
|
16
29
|
/** Ports the website probes to detect the bridge (contract section 5). */
|
|
17
30
|
exports.BRIDGE_CANDIDATE_PORTS = [
|
|
18
31
|
48231, 48242, 48253, 48264, 48275, 48286, 48297,
|
|
@@ -30,6 +43,7 @@ function defaultConfig() {
|
|
|
30
43
|
harness: 'auto',
|
|
31
44
|
quietHours: null,
|
|
32
45
|
wakeRules: null,
|
|
46
|
+
projects: {},
|
|
33
47
|
};
|
|
34
48
|
}
|
|
35
49
|
function loadConfig() {
|
|
@@ -45,6 +59,15 @@ function loadConfig() {
|
|
|
45
59
|
harness: raw.harness ?? def.harness,
|
|
46
60
|
quietHours: raw.quietHours ?? null,
|
|
47
61
|
wakeRules: raw.wakeRules ?? null,
|
|
62
|
+
projects: raw.projects && typeof raw.projects === 'object'
|
|
63
|
+
? raw.projects
|
|
64
|
+
: {},
|
|
65
|
+
opencodeKey: typeof raw.opencodeKey === 'string' && raw.opencodeKey.length > 0
|
|
66
|
+
? raw.opencodeKey
|
|
67
|
+
: undefined,
|
|
68
|
+
chatKey: typeof raw.chatKey === 'string' && raw.chatKey.length > 0
|
|
69
|
+
? raw.chatKey
|
|
70
|
+
: undefined,
|
|
48
71
|
};
|
|
49
72
|
}
|
|
50
73
|
}
|
|
@@ -75,7 +98,256 @@ function upsertAgent(agentId, apiKey) {
|
|
|
75
98
|
saveConfig(config);
|
|
76
99
|
return config;
|
|
77
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Preflight a folder before linking it (the permission gate, IMP-6xx):
|
|
103
|
+
* must exist, be a directory, be readable AND writable by this user, and
|
|
104
|
+
* must not be a network location (UNC or mapped drive), OneDrive, or
|
|
105
|
+
* outside the user profile. The link command IS the permission grant - the
|
|
106
|
+
* agent never runs anywhere but linked folders.
|
|
107
|
+
*/
|
|
108
|
+
function preflightFolder(rawPath) {
|
|
109
|
+
const abs = (0, node_path_1.resolve)(rawPath.trim().replace(/^"|"$/g, ''));
|
|
110
|
+
try {
|
|
111
|
+
if (!(0, node_fs_1.existsSync)(abs))
|
|
112
|
+
return { ok: false, reason: `Folder does not exist: ${abs}` };
|
|
113
|
+
if (!(0, node_fs_1.statSync)(abs).isDirectory()) {
|
|
114
|
+
return { ok: false, reason: `Not a folder: ${abs}` };
|
|
115
|
+
}
|
|
116
|
+
(0, node_fs_1.accessSync)(abs, node_fs_1.constants.R_OK | node_fs_1.constants.W_OK);
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
return { ok: false, reason: `Cannot read+write ${abs} with the current user: ${msg(err)}` };
|
|
120
|
+
}
|
|
121
|
+
if (/^(\\\\|\/\/)/.test(abs)) {
|
|
122
|
+
return { ok: false, reason: `Network (UNC) paths are blocked: ${abs}` };
|
|
123
|
+
}
|
|
124
|
+
const home = (0, node_os_1.homedir)();
|
|
125
|
+
const homeLower = home.toLowerCase();
|
|
126
|
+
const absLower = abs.toLowerCase();
|
|
127
|
+
const oneDrivePrefixes = [
|
|
128
|
+
process.env.OneDrive,
|
|
129
|
+
process.env.OneDriveConsumer,
|
|
130
|
+
(0, node_path_1.join)(home, 'OneDrive'),
|
|
131
|
+
(0, node_path_1.join)(home, 'OneDrive - '),
|
|
132
|
+
]
|
|
133
|
+
.filter((p) => !!p)
|
|
134
|
+
.map((p) => p.toLowerCase());
|
|
135
|
+
if (oneDrivePrefixes.some((prefix) => absLower.startsWith(prefix))) {
|
|
136
|
+
return { ok: false, reason: `OneDrive-synced folders are blocked (sync/encryption pitfalls): ${abs}` };
|
|
137
|
+
}
|
|
138
|
+
if (process.platform === 'win32') {
|
|
139
|
+
const mapped = mappedNetworkDrives();
|
|
140
|
+
const drive = abs.split(node_path_1.sep)[0]?.toUpperCase();
|
|
141
|
+
if (drive && mapped.has(drive)) {
|
|
142
|
+
return { ok: false, reason: `Network drive ${drive}:\\ is blocked (mapped to ${mapped.get(drive)}): ${abs}` };
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (!absLower.startsWith(homeLower + node_path_1.sep) && absLower !== homeLower) {
|
|
146
|
+
return {
|
|
147
|
+
ok: false,
|
|
148
|
+
reason: `Outside the user profile is blocked (${abs}). ` +
|
|
149
|
+
`Link folders under ${home} - the agent runs with your own user permissions only.`,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
return { ok: true, canonical: abs };
|
|
153
|
+
}
|
|
154
|
+
/** Mapped network drive letters (Windows `net use`), e.g. { Z: -> \\server\share }. */
|
|
155
|
+
function mappedNetworkDrives() {
|
|
156
|
+
const map = new Map();
|
|
157
|
+
try {
|
|
158
|
+
const res = (0, node_child_process_1.spawnSync)('net', ['use'], { encoding: 'utf8', windowsHide: true });
|
|
159
|
+
if (res.status !== 0 || !res.stdout)
|
|
160
|
+
return map;
|
|
161
|
+
for (const line of res.stdout.split(/\r?\n/)) {
|
|
162
|
+
const match = line.match(/^\s*([A-Z]):\s+(\\\\[^\s]+)/i);
|
|
163
|
+
if (match)
|
|
164
|
+
map.set(match[1].toUpperCase(), match[2]);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
/* best-effort - unknown drives are treated as local */
|
|
169
|
+
}
|
|
170
|
+
return map;
|
|
171
|
+
}
|
|
172
|
+
/** Links a project to a local folder (guard on by default). Returns the result. */
|
|
173
|
+
function linkProject(projectId, path, guard = true) {
|
|
174
|
+
const preflight = preflightFolder(path);
|
|
175
|
+
if (!preflight.ok)
|
|
176
|
+
return preflight;
|
|
177
|
+
const config = loadConfig();
|
|
178
|
+
config.projects[projectId] = { path: preflight.canonical, guard };
|
|
179
|
+
saveConfig(config);
|
|
180
|
+
return { ...preflight, config };
|
|
181
|
+
}
|
|
182
|
+
/** Removes a project link. */
|
|
183
|
+
function unlinkProject(projectId) {
|
|
184
|
+
const config = loadConfig();
|
|
185
|
+
delete config.projects[projectId];
|
|
186
|
+
saveConfig(config);
|
|
187
|
+
return config;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Working folder for a project, or null when it is not linked (hard block -
|
|
191
|
+
* the caller must refuse the session and explain how to link it).
|
|
192
|
+
*/
|
|
193
|
+
function projectCwd(projectId) {
|
|
194
|
+
const link = loadConfig().projects[projectId];
|
|
195
|
+
if (!link?.path)
|
|
196
|
+
return null;
|
|
197
|
+
try {
|
|
198
|
+
if (!(0, node_fs_1.existsSync)(link.path) || !(0, node_fs_1.statSync)(link.path).isDirectory()) {
|
|
199
|
+
console.warn(`[config] linked folder missing for project ${projectId}: ${link.path}`);
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
(0, node_fs_1.accessSync)(link.path, node_fs_1.constants.R_OK | node_fs_1.constants.W_OK);
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
return link.path;
|
|
208
|
+
}
|
|
209
|
+
/** The exact command shown when a project is not linked (guard message). */
|
|
210
|
+
function linkHint(projectId) {
|
|
211
|
+
return (`teamshare-agent link --project ${projectId} --path <folder>` +
|
|
212
|
+
`\n(Link a local folder first - the agent is hard-blocked until then.)`);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Sets the agent LLM provider key. Without `agentId` it is the GLOBAL
|
|
216
|
+
* default for every agent; with `agentId` it overrides that agent only.
|
|
217
|
+
* `null` clears it (global null falls back to the user's own credentials).
|
|
218
|
+
*/
|
|
219
|
+
function setOpenCodeKey(key, agentId) {
|
|
220
|
+
const config = loadConfig();
|
|
221
|
+
if (agentId) {
|
|
222
|
+
const agent = config.agents.find((a) => a.agentId === agentId);
|
|
223
|
+
if (!agent)
|
|
224
|
+
throw new Error(`agent not configured: ${agentId}`);
|
|
225
|
+
agent.opencodeKey = key ?? undefined;
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
config.opencodeKey = key ?? undefined;
|
|
229
|
+
}
|
|
230
|
+
saveConfig(config);
|
|
231
|
+
return config;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Resolves the LLM provider key for an agent: per-agent override >
|
|
235
|
+
* global default > an already-set OPENCODE_API_KEY env (leave untouched) >
|
|
236
|
+
* none (opencode falls back to the user's auth.json). The key itself is
|
|
237
|
+
* NEVER logged - callers only ever log which source won.
|
|
238
|
+
*/
|
|
239
|
+
function agentOpenCodeKey(agentId) {
|
|
240
|
+
if (process.env.OPENCODE_API_KEY)
|
|
241
|
+
return null; // env already wins
|
|
242
|
+
const config = loadConfig();
|
|
243
|
+
const agent = config.agents.find((a) => a.agentId === agentId);
|
|
244
|
+
return agent?.opencodeKey ?? config.opencodeKey ?? null;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Sets the chat model API key (DeepSeek key for chat replies). Stored in
|
|
248
|
+
* config.json as `chatKey`. `null` clears it. Chat always uses this key
|
|
249
|
+
* with deepseek:deepseek-chat at low settings, regardless of agent model.
|
|
250
|
+
*/
|
|
251
|
+
function setChatKey(key) {
|
|
252
|
+
const config = loadConfig();
|
|
253
|
+
config.chatKey = key ?? undefined;
|
|
254
|
+
saveConfig(config);
|
|
255
|
+
return config;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Resolves the chat model API key: config chatKey > CHAT_LLM_API_KEY env >
|
|
259
|
+
* LLM_API_KEY env > none.
|
|
260
|
+
*/
|
|
261
|
+
function chatKey() {
|
|
262
|
+
const config = loadConfig();
|
|
263
|
+
return config.chatKey ?? process.env.CHAT_LLM_API_KEY ?? process.env.LLM_API_KEY ?? null;
|
|
264
|
+
}
|
|
78
265
|
function msg(err) {
|
|
79
266
|
return err instanceof Error ? err.message : String(err);
|
|
80
267
|
}
|
|
268
|
+
// ── opencode MCP wiring ─────────────────────────────────────────────────────
|
|
269
|
+
const OPENCODE_CONFIG_DIR = (0, node_path_1.join)((0, node_os_1.homedir)(), '.config', 'opencode');
|
|
270
|
+
const OPENCODE_CONFIG_JSONC = (0, node_path_1.join)(OPENCODE_CONFIG_DIR, 'opencode.jsonc');
|
|
271
|
+
const OPENCODE_CONFIG_JSON = (0, node_path_1.join)(OPENCODE_CONFIG_DIR, 'opencode.json');
|
|
272
|
+
const TEAMSHARE_MCP_KEY = 'teamshare';
|
|
273
|
+
function opencodeConfigPath() {
|
|
274
|
+
if ((0, node_fs_1.existsSync)(OPENCODE_CONFIG_JSONC))
|
|
275
|
+
return OPENCODE_CONFIG_JSONC;
|
|
276
|
+
if ((0, node_fs_1.existsSync)(OPENCODE_CONFIG_JSON))
|
|
277
|
+
return OPENCODE_CONFIG_JSON;
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
/** Strip single-line // comments from JSONC before parsing. */
|
|
281
|
+
function stripJsoncComments(text) {
|
|
282
|
+
return text.replace(/^[ \t]*\/\/.*$/gm, '');
|
|
283
|
+
}
|
|
284
|
+
function readOpencodeConfig() {
|
|
285
|
+
const path = opencodeConfigPath();
|
|
286
|
+
if (!path)
|
|
287
|
+
return null;
|
|
288
|
+
try {
|
|
289
|
+
const raw = (0, node_fs_1.readFileSync)(path, 'utf8');
|
|
290
|
+
return JSON.parse(stripJsoncComments(raw));
|
|
291
|
+
}
|
|
292
|
+
catch {
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
function writeOpencodeConfig(config) {
|
|
297
|
+
const path = opencodeConfigPath() ?? OPENCODE_CONFIG_JSON;
|
|
298
|
+
const dir = (0, node_path_1.join)(path, '..');
|
|
299
|
+
if (!(0, node_fs_1.existsSync)(dir))
|
|
300
|
+
(0, node_fs_1.mkdirSync)(dir, { recursive: true });
|
|
301
|
+
(0, node_fs_1.writeFileSync)(path, JSON.stringify(config, null, 2) + '\n', 'utf8');
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Wires the TeamShare MCP server into opencode's config. Idempotent —
|
|
305
|
+
* skips if already wired. The entry is:
|
|
306
|
+
* mcp.teamshare = { type: "remote", url: "http://localhost:4000/api/mcp",
|
|
307
|
+
* headers: { "X-Api-Key": "<key>" } }
|
|
308
|
+
*
|
|
309
|
+
* Returns true if wired, false if already present.
|
|
310
|
+
*/
|
|
311
|
+
function wireOpencodeMcp(apiKey) {
|
|
312
|
+
const config = readOpencodeConfig() ?? {};
|
|
313
|
+
const mcp = (typeof config.mcp === 'object' && config.mcp !== null
|
|
314
|
+
? config.mcp
|
|
315
|
+
: {});
|
|
316
|
+
if (TEAMSHARE_MCP_KEY in mcp)
|
|
317
|
+
return false; // already wired
|
|
318
|
+
mcp[TEAMSHARE_MCP_KEY] = {
|
|
319
|
+
type: 'remote',
|
|
320
|
+
url: 'http://localhost:4000/api/mcp',
|
|
321
|
+
headers: { 'X-Api-Key': apiKey },
|
|
322
|
+
};
|
|
323
|
+
config.mcp = mcp;
|
|
324
|
+
writeOpencodeConfig(config);
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Removes the TeamShare MCP entry from opencode's config.
|
|
329
|
+
* Returns true if removed, false if not present.
|
|
330
|
+
*/
|
|
331
|
+
function unwireOpencodeMcp() {
|
|
332
|
+
const config = readOpencodeConfig();
|
|
333
|
+
if (!config)
|
|
334
|
+
return false;
|
|
335
|
+
const mcp = config.mcp;
|
|
336
|
+
if (!mcp || !(TEAMSHARE_MCP_KEY in mcp))
|
|
337
|
+
return false;
|
|
338
|
+
delete mcp[TEAMSHARE_MCP_KEY];
|
|
339
|
+
config.mcp = mcp;
|
|
340
|
+
writeOpencodeConfig(config);
|
|
341
|
+
return true;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Returns the current MCP wiring status for opencode.
|
|
345
|
+
*/
|
|
346
|
+
function mcpStatus() {
|
|
347
|
+
const path = opencodeConfigPath();
|
|
348
|
+
const config = readOpencodeConfig();
|
|
349
|
+
const mcp = config && typeof config.mcp === 'object' ? config.mcp : undefined;
|
|
350
|
+
const entry = mcp?.[TEAMSHARE_MCP_KEY];
|
|
351
|
+
return { wired: !!entry, configPath: path, entry };
|
|
352
|
+
}
|
|
81
353
|
//# sourceMappingURL=config.js.map
|
package/dist/lib/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":";;;AA4BA,gCAEC;AAED,sCAYC;AAED,gCAwBC;AAED,gCAOC;AAGD,kCAOC;AAED,kBAEC;AA7FD;;GAEG;AACH,qCAA6E;AAC7E,qCAAkC;AAClC,yCAAiC;AAEjC,0EAA0E;AAC7D,QAAA,sBAAsB,GAAG;IACpC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK;CACvC,CAAC;AAeX,MAAM,UAAU,GAAG,IAAA,gBAAI,EAAC,IAAA,iBAAO,GAAE,EAAE,YAAY,CAAC,CAAC;AACjD,MAAM,WAAW,GAAG,IAAA,gBAAI,EAAC,UAAU,EAAE,aAAa,CAAC,CAAC;AAEpD,SAAgB,UAAU;IACxB,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,SAAgB,aAAa;IAC3B,MAAM,IAAI,GACR,8BAAsB,CACpB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,8BAAsB,CAAC,MAAM,CAAC,CAC1D,CAAC;IACJ,OAAO;QACL,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,IAAI;QAChB,SAAS,EAAE,IAAI;KAChB,CAAC;AACJ,CAAC;AAED,SAAgB,UAAU;IACxB,IAAI,CAAC;QACH,IAAI,IAAA,oBAAU,EAAC,WAAW,CAAC,EAAE,CAAC;YAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,sBAAY,EAAC,WAAW,EAAE,MAAM,CAAC,CAEvD,CAAC;YACF,MAAM,GAAG,GAAG,aAAa,EAAE,CAAC;YAC5B,OAAO;gBACL,MAA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,KAAK,CAAC;IAC1B,MAAM,GAAG,GAAG,MAAM,CAAC,GAA0C,CAAC;IAC9D,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,iBAAiB,IAAI,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IACtD,OAAO,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC9B,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC5B,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,SAAgB,SAAS;IACvB,MAAM,IAAI,GAAG,kBAAkB,EAAE,CAAC;IAClC,MAAM,MAAM,GAAG,kBAAkB,EAAE,CAAC;IACpC,MAAM,GAAG,GAAG,MAAM,IAAI,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAE,MAAM,CAAC,GAA+B,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3G,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,iBAAiB,CAAC,CAAC;IACvC,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AACrD,CAAC"}
|
package/dist/lib/doc-reply.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase F document assistant (`teamshare-agent doc`): reads a document's
|
|
3
|
+
* extracted text (Word/PPT/Excel/PDF) plus its comment thread, and replies
|
|
4
|
+
* to every comment that @mentions the agent. The reply quotes the relevant
|
|
5
|
+
* context - the document text is included in the prompt so the model can
|
|
6
|
+
* answer questions about the document content.
|
|
7
|
+
*/
|
|
1
8
|
import { TeamshareApi } from './api';
|
|
2
9
|
export interface DocReplyOptions {
|
|
3
10
|
harness: 'auto' | 'opencode' | 'claude' | 'none';
|
|
@@ -11,6 +18,10 @@ export interface DocReplyOptions {
|
|
|
11
18
|
};
|
|
12
19
|
/** Debug/testing switch (TS_CHAT_ECHO=1): post canned acknowledgments. */
|
|
13
20
|
echo?: boolean;
|
|
21
|
+
/** Document being assisted - recorded as the session title for spend attribution. */
|
|
22
|
+
documentId?: string;
|
|
23
|
+
/** API client carrying the session agent's key (used to pin the harness MCP identity). */
|
|
24
|
+
api?: import('./api').TeamshareApi;
|
|
14
25
|
}
|
|
15
26
|
/**
|
|
16
27
|
* Runs the document reply loop: fetch the document + extract, find comments
|
package/dist/lib/doc-reply.js
CHANGED
|
@@ -1,52 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runDocReply = runDocReply;
|
|
4
|
-
|
|
5
|
-
* Phase F document assistant (`teamshare-agent doc`): reads a document's
|
|
6
|
-
* extracted text (Word/PPT/Excel/PDF) plus its comment thread, and replies
|
|
7
|
-
* to every comment that @mentions the agent. The reply quotes the relevant
|
|
8
|
-
* context - the document text is included in the prompt so the model can
|
|
9
|
-
* answer questions about the document content.
|
|
10
|
-
*/
|
|
11
|
-
const node_child_process_1 = require("node:child_process");
|
|
4
|
+
const harness_1 = require("./harness");
|
|
12
5
|
const llm_1 = require("./llm");
|
|
13
6
|
const MAX_TARGETS = 10;
|
|
14
7
|
const CONTEXT_WINDOW = 10;
|
|
15
8
|
const MAX_DOC_CHARS = 60_000;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
(0, node_child_process_1.execFileSync)(bin, ['--version'], { stdio: 'ignore' });
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
catch {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
9
|
+
/** Harness prompts go through argv (Windows limit: 32,767 chars) - keep headroom. */
|
|
10
|
+
const HARNESS_MAX_DOC_CHARS = 24_000;
|
|
25
11
|
function generateReply(agentName, target, prompt, opts) {
|
|
26
12
|
if (opts.echo) {
|
|
27
13
|
return Promise.resolve(`@${target.author?.name ?? 'there'} — this is an automated acknowledgment from ${agentName}. I read the document and I'm on it.`);
|
|
28
14
|
}
|
|
29
15
|
if (opts.selfMode || opts.harness === 'none') {
|
|
30
16
|
if (!opts.llm?.apiKey) {
|
|
31
|
-
throw new Error('--self / --harness none requires
|
|
17
|
+
throw new Error('--self / --harness none requires a provider API key (set it on the agent in TeamShare, or LLM_API_KEY / CHAT_LLM_API_KEY env)');
|
|
32
18
|
}
|
|
33
19
|
return (0, llm_1.complete)(prompt, opts.llm);
|
|
34
20
|
}
|
|
35
|
-
if (opts.harness === 'opencode' || (opts.harness === 'auto' && hasBin('opencode'))) {
|
|
36
|
-
return Promise.resolve((0,
|
|
37
|
-
encoding: 'utf8',
|
|
38
|
-
maxBuffer: 2 * 1024 * 1024,
|
|
39
|
-
}).trim());
|
|
21
|
+
if (opts.harness === 'opencode' || (opts.harness === 'auto' && (0, harness_1.hasBin)('opencode'))) {
|
|
22
|
+
return Promise.resolve((0, harness_1.runHarness)('opencode', ['run', '--title', `TeamShare doc ${opts.documentId}`, prompt], { opencodeAgentKey: opts.api?.apiKey, opencodeMcpUrl: opts.api?.baseUrl }));
|
|
40
23
|
}
|
|
41
|
-
if (opts.harness === 'claude' || (opts.harness === 'auto' && hasBin('claude'))) {
|
|
42
|
-
return Promise.resolve((0,
|
|
43
|
-
encoding: 'utf8',
|
|
44
|
-
maxBuffer: 2 * 1024 * 1024,
|
|
45
|
-
}).trim());
|
|
24
|
+
if (opts.harness === 'claude' || (opts.harness === 'auto' && (0, harness_1.hasBin)('claude'))) {
|
|
25
|
+
return Promise.resolve((0, harness_1.runHarness)('claude', ['-p', prompt]));
|
|
46
26
|
}
|
|
47
|
-
throw new Error('No harness found (install opencode or claude, or use --self with
|
|
27
|
+
throw new Error('No harness found (install opencode or claude, or use --self with a provider API key)');
|
|
48
28
|
}
|
|
49
|
-
function docPrompt(agentName, docName, docText, target, context) {
|
|
29
|
+
function docPrompt(agentName, docName, docText, target, context, maxChars) {
|
|
50
30
|
const thread = context
|
|
51
31
|
.map((c) => `[${c.createdAt}] ${c.author?.name ?? '?'}: ${c.body}`)
|
|
52
32
|
.join('\n');
|
|
@@ -54,8 +34,8 @@ function docPrompt(agentName, docName, docText, target, context) {
|
|
|
54
34
|
`You are ${agentName}, a TeamShare document assistant. The document "${docName}" contains:`,
|
|
55
35
|
'',
|
|
56
36
|
'--- DOCUMENT CONTENT ---',
|
|
57
|
-
docText.slice(0,
|
|
58
|
-
docText.length >
|
|
37
|
+
docText.slice(0, maxChars),
|
|
38
|
+
docText.length > maxChars ? '\n…[truncated]' : '',
|
|
59
39
|
'--- END DOCUMENT CONTENT ---',
|
|
60
40
|
'',
|
|
61
41
|
'The document comment thread looks like this:',
|
|
@@ -93,11 +73,15 @@ async function runDocReply(api, agentId, documentId, mentionToken, opts) {
|
|
|
93
73
|
if (!targets.length)
|
|
94
74
|
return { replied: 0, skipped: 0 };
|
|
95
75
|
let replied = 0;
|
|
76
|
+
const usesHarness = !opts.echo &&
|
|
77
|
+
!opts.selfMode &&
|
|
78
|
+
opts.harness !== 'none' &&
|
|
79
|
+
(opts.harness !== 'auto' || (0, harness_1.hasBin)('opencode') || (0, harness_1.hasBin)('claude'));
|
|
96
80
|
for (const target of targets.slice(0, MAX_TARGETS)) {
|
|
97
81
|
const targetIndex = rows.findIndex((r) => r.id === target.id);
|
|
98
82
|
const context = rows.slice(Math.max(0, targetIndex - CONTEXT_WINDOW), targetIndex + 1);
|
|
99
|
-
const prompt = docPrompt(selfName, doc.name, docText, target, context);
|
|
100
|
-
const reply = await generateReply(selfName, target, prompt, opts);
|
|
83
|
+
const prompt = docPrompt(selfName, doc.name, docText, target, context, usesHarness ? HARNESS_MAX_DOC_CHARS : MAX_DOC_CHARS);
|
|
84
|
+
const reply = await generateReply(selfName, target, prompt, { ...opts, documentId, api });
|
|
101
85
|
if (!reply)
|
|
102
86
|
continue;
|
|
103
87
|
await api.addComment({ documentId, body: reply });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doc-reply.js","sourceRoot":"","sources":["../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D,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface HarnessRunOptions {
|
|
2
|
+
maxBuffer?: number;
|
|
3
|
+
/**
|
|
4
|
+
* Agent API key injected into a per-session opencode config so the
|
|
5
|
+
* teamshare MCP server authenticates as THIS agent (never the global
|
|
6
|
+
* config's key - shared keys made agents act as each other).
|
|
7
|
+
*/
|
|
8
|
+
opencodeAgentKey?: string;
|
|
9
|
+
/** TeamShare API base URL for the MCP override (default http://localhost:4000/api). */
|
|
10
|
+
opencodeMcpUrl?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ResolvedBin {
|
|
13
|
+
file: string;
|
|
14
|
+
args?: string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resolves a PATH command to something Node can spawn without a shell.
|
|
18
|
+
* Windows npm shims (opencode.cmd / opencode.ps1, claude.cmd) cannot be
|
|
19
|
+
* spawned directly (ENOENT) and shell-joining truncates multi-line args at
|
|
20
|
+
* the first newline - so the shim's real target (opencode.exe or a JS entry
|
|
21
|
+
* run via node) is extracted from the shim file instead.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveBin(bin: string): ResolvedBin | null;
|
|
24
|
+
/**
|
|
25
|
+
* Writes a throwaway opencode config that overrides the teamshare MCP
|
|
26
|
+
* server's API key for this run (project/`OPENCODE_CONFIG` scope wins over
|
|
27
|
+
* the user's global config). Returns the config file path + cleanup.
|
|
28
|
+
*/
|
|
29
|
+
export declare function writeOpencodeMcpConfig(agentKey: string, apiBaseUrl: string): {
|
|
30
|
+
file: string;
|
|
31
|
+
cleanup: () => void;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Runs a harness binary non-interactively and returns its stdout.
|
|
35
|
+
* Spawned without a shell so multi-line prompts survive intact.
|
|
36
|
+
*/
|
|
37
|
+
export declare function runHarness(cmd: string, args: string[], opts?: HarnessRunOptions): string;
|
|
38
|
+
export declare function hasBin(bin: string): boolean;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveBin = resolveBin;
|
|
4
|
+
exports.writeOpencodeMcpConfig = writeOpencodeMcpConfig;
|
|
5
|
+
exports.runHarness = runHarness;
|
|
6
|
+
exports.hasBin = hasBin;
|
|
7
|
+
const node_child_process_1 = require("node:child_process");
|
|
8
|
+
const node_fs_1 = require("node:fs");
|
|
9
|
+
const node_os_1 = require("node:os");
|
|
10
|
+
const node_path_1 = require("node:path");
|
|
11
|
+
function tryExec(file, args) {
|
|
12
|
+
try {
|
|
13
|
+
(0, node_child_process_1.execFileSync)(file, args, { stdio: 'ignore' });
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function whereShim(bin) {
|
|
21
|
+
if (process.platform !== 'win32')
|
|
22
|
+
return null;
|
|
23
|
+
const res = (0, node_child_process_1.spawnSync)('where', [bin], { encoding: 'utf8' });
|
|
24
|
+
if (res.status !== 0)
|
|
25
|
+
return null;
|
|
26
|
+
const line = (res.stdout ?? '')
|
|
27
|
+
.split(/\r?\n/)
|
|
28
|
+
.map((s) => s.trim())
|
|
29
|
+
.find((s) => /\.(cmd|bat|ps1)$/i.test(s));
|
|
30
|
+
return line ?? null;
|
|
31
|
+
}
|
|
32
|
+
/** Expands shim placeholders (%dp0%, %~dp0%, %basedir%, $basedir, $PSScriptRoot). */
|
|
33
|
+
function expand(target, shimDir) {
|
|
34
|
+
return target
|
|
35
|
+
.replace(/%(?:~?dp0|basedir)%|\$basedir|\$PSScriptRoot/gi, shimDir)
|
|
36
|
+
.replace(/%\w+%/g, '')
|
|
37
|
+
.trim();
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Resolves a PATH command to something Node can spawn without a shell.
|
|
41
|
+
* Windows npm shims (opencode.cmd / opencode.ps1, claude.cmd) cannot be
|
|
42
|
+
* spawned directly (ENOENT) and shell-joining truncates multi-line args at
|
|
43
|
+
* the first newline - so the shim's real target (opencode.exe or a JS entry
|
|
44
|
+
* run via node) is extracted from the shim file instead.
|
|
45
|
+
*/
|
|
46
|
+
function resolveBin(bin) {
|
|
47
|
+
if (tryExec(bin, ['--version']))
|
|
48
|
+
return { file: bin };
|
|
49
|
+
const shim = whereShim(bin);
|
|
50
|
+
if (!shim)
|
|
51
|
+
return null;
|
|
52
|
+
const text = (0, node_fs_1.readFileSync)(shim, 'utf8');
|
|
53
|
+
const match = text.match(/"([^"]+\.(?:exe|js))"/i);
|
|
54
|
+
if (!match)
|
|
55
|
+
return null;
|
|
56
|
+
const expanded = expand(match[1], (0, node_path_1.dirname)(shim));
|
|
57
|
+
const file = (0, node_path_1.isAbsolute)(expanded) ? expanded : (0, node_path_1.join)((0, node_path_1.dirname)(shim), expanded);
|
|
58
|
+
if (!(0, node_fs_1.existsSync)(file))
|
|
59
|
+
return null;
|
|
60
|
+
if (/\.exe$/i.test(file))
|
|
61
|
+
return { file };
|
|
62
|
+
return { file: process.execPath, args: [file] };
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Writes a throwaway opencode config that overrides the teamshare MCP
|
|
66
|
+
* server's API key for this run (project/`OPENCODE_CONFIG` scope wins over
|
|
67
|
+
* the user's global config). Returns the config file path + cleanup.
|
|
68
|
+
*/
|
|
69
|
+
function writeOpencodeMcpConfig(agentKey, apiBaseUrl) {
|
|
70
|
+
const dir = (0, node_fs_1.mkdtempSync)((0, node_path_1.join)((0, node_os_1.tmpdir)(), 'teamshare-oc-'));
|
|
71
|
+
const file = (0, node_path_1.join)(dir, 'opencode.json');
|
|
72
|
+
const base = apiBaseUrl.replace(/\/+$/, '');
|
|
73
|
+
const mcpUrl = base.endsWith('/api') ? `${base}/mcp` : `${base}/api/mcp`;
|
|
74
|
+
(0, node_fs_1.writeFileSync)(file, JSON.stringify({
|
|
75
|
+
$schema: 'https://opencode.ai/config.json',
|
|
76
|
+
mcp: {
|
|
77
|
+
teamshare: {
|
|
78
|
+
type: 'remote',
|
|
79
|
+
url: mcpUrl,
|
|
80
|
+
headers: { 'X-Api-Key': agentKey },
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
}, null, 2), 'utf8');
|
|
84
|
+
return {
|
|
85
|
+
file,
|
|
86
|
+
cleanup: () => {
|
|
87
|
+
try {
|
|
88
|
+
(0, node_fs_1.rmSync)(dir, { recursive: true, force: true });
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
/* best-effort */
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Writes a throwaway opencode config that overrides the teamshare MCP
|
|
98
|
+
* server's API key for this run (project/`OPENCODE_CONFIG` scope wins over
|
|
99
|
+
* the user's global config). Returns the env to merge into the child spawn.
|
|
100
|
+
*/
|
|
101
|
+
function opencodeMcpEnv(agentKey, apiBaseUrl) {
|
|
102
|
+
const { file, cleanup } = writeOpencodeMcpConfig(agentKey, apiBaseUrl);
|
|
103
|
+
return { env: { OPENCODE_CONFIG: file }, cleanup };
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Runs a harness binary non-interactively and returns its stdout.
|
|
107
|
+
* Spawned without a shell so multi-line prompts survive intact.
|
|
108
|
+
*/
|
|
109
|
+
function runHarness(cmd, args, opts = {}) {
|
|
110
|
+
const bin = resolveBin(cmd);
|
|
111
|
+
if (!bin)
|
|
112
|
+
throw new Error(`No harness found (install ${cmd})`);
|
|
113
|
+
let mcpEnv = null;
|
|
114
|
+
if (cmd === 'opencode' && opts.opencodeAgentKey) {
|
|
115
|
+
mcpEnv = opencodeMcpEnv(opts.opencodeAgentKey, opts.opencodeMcpUrl ?? process.env.TEAMSHARE_API_URL ?? 'http://localhost:4000/api');
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const out = (0, node_child_process_1.execFileSync)(bin.file, [...(bin.args ?? []), ...args], {
|
|
119
|
+
encoding: 'utf8',
|
|
120
|
+
maxBuffer: opts.maxBuffer ?? 2 * 1024 * 1024,
|
|
121
|
+
env: mcpEnv ? { ...process.env, ...mcpEnv.env } : undefined,
|
|
122
|
+
});
|
|
123
|
+
return out.trim();
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
const err = e;
|
|
127
|
+
const detail = err.status !== undefined
|
|
128
|
+
? `exited with code ${err.status}${err.stderr ? `: ${String(err.stderr).trim()}` : ''}`
|
|
129
|
+
: (err.message ?? String(e));
|
|
130
|
+
throw new Error(`${cmd} ${detail}`);
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
mcpEnv?.cleanup();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function hasBin(bin) {
|
|
137
|
+
return resolveBin(bin) !== null;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=harness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"harness.js","sourceRoot":"","sources":["../../src/lib/harness.ts"],"names":[],"mappings":";;AAyDA,gCAgBC;AAOD,wDAoCC;AAmBD,gCA+BC;AAED,wBAEC;AA1KD,2DAA6D;AAC7D,qCAAuF;AACvF,qCAAiC;AACjC,yCAAsD;AAmBtD,SAAS,OAAO,CAAC,IAAY,EAAE,IAAc;IAC3C,IAAI,CAAC;QACH,IAAA,iCAAY,EAAC,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,GAAW;IAC5B,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO;QAAE,OAAO,IAAI,CAAC;IAC9C,MAAM,GAAG,GAAG,IAAA,8BAAS,EAAC,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,EAA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