@nia-teams/workbuddy-plugin 0.0.0-stage → 0.1.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 +220 -2
- package/README_CN.md +222 -0
- package/bin/nia-workbuddy.mjs +3 -0
- package/dist/branding.d.ts +5 -0
- package/dist/branding.js +6 -0
- package/dist/branding.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +35 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/runner.d.ts +9 -0
- package/dist/runner.js +241 -0
- package/dist/runner.js.map +1 -0
- package/docs/SPECIFICATION.md +36 -0
- package/docs/assets/agent-pairing.png +0 -0
- package/docs/assets/group-chat-overview.png +0 -0
- package/docs/assets/taskbar-approval.png +0 -0
- package/docs/upstream/codebuddy-help.txt +106 -0
- package/docs/upstream/sdk-types.txt +1602 -0
- package/package.json +50 -4
- package/skills/nia-teams-workbuddy/SKILL.md +43 -0
package/dist/runner.js
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { query, createSdkMcpServer, tool } from '@tencent-ai/agent-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { consumeSdkQuery, GROUP_CHAT_INSTRUCTIONS, findExecutable } from '@nia-teams/agent-bridge-core';
|
|
4
|
+
import { homedir, platform } from 'node:os';
|
|
5
|
+
import { execFile } from 'node:child_process';
|
|
6
|
+
import { constants, existsSync } from 'node:fs';
|
|
7
|
+
import { access, readFile, readdir, realpath, stat } from 'node:fs/promises';
|
|
8
|
+
import { basename, dirname, join } from 'node:path';
|
|
9
|
+
export async function resolveCodeBuddyBinary(explicit) {
|
|
10
|
+
const selected = explicit ?? process.env.CODEBUDDY_BIN;
|
|
11
|
+
// SDK scripts are read by Node, not executed by the OS; dist/*.mjs need no +x.
|
|
12
|
+
if (selected && /\.(?:mjs|cjs|js)$/i.test(selected)) {
|
|
13
|
+
const script = await realpath(selected);
|
|
14
|
+
await access(script, constants.R_OK);
|
|
15
|
+
if (!(await stat(script)).isFile())
|
|
16
|
+
throw new Error(`CodeBuddy script is not a file: ${script}`);
|
|
17
|
+
return script;
|
|
18
|
+
}
|
|
19
|
+
const binary = await findExecutable('codebuddy', selected, [
|
|
20
|
+
'/Applications/WorkBuddy.app/Contents/Resources/app.asar.unpacked/cli/bin/codebuddy',
|
|
21
|
+
join(homedir(), 'Applications/WorkBuddy.app/Contents/Resources/app.asar.unpacked/cli/bin/codebuddy'),
|
|
22
|
+
...(process.env.LOCALAPPDATA ? [join(process.env.LOCALAPPDATA, 'Programs/WorkBuddy/resources/app.asar.unpacked/cli/bin/codebuddy.exe')] : []),
|
|
23
|
+
'/opt/homebrew/bin/codebuddy', '/usr/local/bin/codebuddy',
|
|
24
|
+
]);
|
|
25
|
+
if (/\.(?:cmd|bat)$/i.test(binary))
|
|
26
|
+
throw new Error('CodeBuddy SDK cannot run a custom batch wrapper; pass --codebuddy-bin with the underlying .js, .mjs, .cjs, or .exe entrypoint');
|
|
27
|
+
// agent-sdk unconditionally rewrites bin/codebuddy to dist/codebuddy-headless.js.
|
|
28
|
+
// Desktop WorkBuddy ships only this ESM bundle. Select its real entrypoint before
|
|
29
|
+
// handing the path to the SDK, including when discovery followed a PATH symlink.
|
|
30
|
+
if (basename(binary) === 'codebuddy' && basename(dirname(binary)) === 'bin') {
|
|
31
|
+
const lite = join(dirname(binary), '../dist/codebuddy-lite-wb.mjs');
|
|
32
|
+
try {
|
|
33
|
+
if (!(await stat(lite)).isFile())
|
|
34
|
+
throw new Error(`CodeBuddy bundle is not a file: ${lite}`);
|
|
35
|
+
await access(lite, constants.R_OK);
|
|
36
|
+
return await realpath(lite);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
if (error.code !== 'ENOENT')
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return binary;
|
|
44
|
+
}
|
|
45
|
+
async function workBuddyBundleEnvironment(binary) {
|
|
46
|
+
const defaultConfigDir = join(homedir(), '.workbuddy');
|
|
47
|
+
if (!binary.includes('WorkBuddy.app') && !existsSync(defaultConfigDir))
|
|
48
|
+
return undefined;
|
|
49
|
+
const configDir = process.env.CODEBUDDY_CONFIG_DIR || process.env.WORKBUDDY_CONFIG_DIR || defaultConfigDir;
|
|
50
|
+
const env = {
|
|
51
|
+
CODEBUDDY_FORCE_LITE_WB_BUNDLE: '1',
|
|
52
|
+
CODEBUDDY_FORCE_HEADLESS_BUNDLE: '1',
|
|
53
|
+
CODEBUDDY_CONFIG_DIR: configDir,
|
|
54
|
+
WORKBUDDY_CONFIG_DIR: configDir,
|
|
55
|
+
};
|
|
56
|
+
if (!process.env.ACC_PRODUCT_CONFIG_PATH) {
|
|
57
|
+
const cacheDir = join(configDir, 'cache');
|
|
58
|
+
const entries = await readdir(cacheDir, { withFileTypes: true }).catch((error) => {
|
|
59
|
+
if (error.code === 'ENOENT')
|
|
60
|
+
return [];
|
|
61
|
+
throw error;
|
|
62
|
+
});
|
|
63
|
+
const configs = await Promise.all(entries
|
|
64
|
+
.filter(entry => entry.isFile() && /^acc-product-config-v3-.*\.json$/.test(entry.name))
|
|
65
|
+
.map(async (entry) => {
|
|
66
|
+
const path = join(cacheDir, entry.name);
|
|
67
|
+
return { path, mtime: (await stat(path)).mtimeMs };
|
|
68
|
+
}));
|
|
69
|
+
configs.sort((a, b) => b.mtime - a.mtime || a.path.localeCompare(b.path));
|
|
70
|
+
if (configs[0])
|
|
71
|
+
env.ACC_PRODUCT_CONFIG_PATH = configs[0].path;
|
|
72
|
+
}
|
|
73
|
+
return env;
|
|
74
|
+
}
|
|
75
|
+
// Electron NodeMain exposes the storage binding without starting the desktop UI.
|
|
76
|
+
// Only the existing credential file path is passed in argv; keys/tokens stay in memory.
|
|
77
|
+
const decryptDesktopTokenScript = String.raw `
|
|
78
|
+
const crypto = require('node:crypto');
|
|
79
|
+
try {
|
|
80
|
+
const rawKey = JSON.parse(process._linkedBinding('electron_browser_workbuddy_storage').loggerGet());
|
|
81
|
+
if (typeof rawKey.atRestSecretKey !== 'string' || !rawKey.atRestSecretKey) throw new Error();
|
|
82
|
+
const key = crypto.createHash('sha256').update(rawKey.atRestSecretKey, 'utf8').digest();
|
|
83
|
+
const keyId = crypto.createHash('sha256').update(key).digest('hex').slice(0, 16);
|
|
84
|
+
const doc = JSON.parse(require('node:fs').readFileSync(process.argv[1], 'utf8'));
|
|
85
|
+
const accessToken = doc?.auth?.accessToken;
|
|
86
|
+
if (accessToken?.$wbEncrypted !== 1 || typeof accessToken.envelope !== 'string') throw new Error();
|
|
87
|
+
const env = JSON.parse(Buffer.from(accessToken.envelope, 'base64').toString('utf8'));
|
|
88
|
+
function encodeUint32(v) { const b = Buffer.allocUnsafe(4); b.writeUInt32BE(v, 0); return b; }
|
|
89
|
+
function encodeLP(s) { const b = Buffer.from(s, 'utf8'); return Buffer.concat([encodeUint32(b.length), b]); }
|
|
90
|
+
const aad = Buffer.concat([
|
|
91
|
+
Buffer.from('WB-AAD\0', 'ascii'), Buffer.from([1]), encodeLP('WBEV1'), encodeLP('sym-v1'),
|
|
92
|
+
encodeUint32(env.suite), encodeLP(keyId), Buffer.from([2]), Buffer.from([0]), Buffer.from([0]),
|
|
93
|
+
]);
|
|
94
|
+
const nonce = Buffer.from(env.nonce, 'base64'), tag = Buffer.from(env.authTag, 'base64');
|
|
95
|
+
if (nonce.length !== 12 || tag.length !== 16) throw new Error();
|
|
96
|
+
const decipher = crypto.createDecipheriv('aes-256-gcm', key, nonce, { authTagLength: 16 });
|
|
97
|
+
decipher.setAAD(aad); decipher.setAuthTag(tag);
|
|
98
|
+
const token = Buffer.concat([decipher.update(Buffer.from(env.ciphertext, 'base64')), decipher.final()]).toString('utf8');
|
|
99
|
+
if (!token.trim()) throw new Error();
|
|
100
|
+
process.stdout.write(JSON.stringify({ token }) + '\n', () => process.exit(0));
|
|
101
|
+
} catch { process.exit(1); }
|
|
102
|
+
`;
|
|
103
|
+
const desktopTokenCache = new Map();
|
|
104
|
+
function desktopAuthDirectory() {
|
|
105
|
+
switch (platform()) {
|
|
106
|
+
case 'darwin': return join(homedir(), 'Library/Application Support/CodeBuddyExtension/Data/Public/auth');
|
|
107
|
+
case 'win32': return process.env.LOCALAPPDATA ? join(process.env.LOCALAPPDATA, 'CodeBuddyExtension/Data/Public/auth') : undefined;
|
|
108
|
+
default: return join(homedir(), '.local/share/CodeBuddyExtension/Data/Public/auth');
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function workBuddyElectron(binary) {
|
|
112
|
+
const app = binary.indexOf('WorkBuddy.app');
|
|
113
|
+
if (app !== -1) {
|
|
114
|
+
const electron = join(binary.slice(0, app + 'WorkBuddy.app'.length), 'Contents/MacOS/Electron');
|
|
115
|
+
if (existsSync(electron))
|
|
116
|
+
return electron;
|
|
117
|
+
}
|
|
118
|
+
if (platform() === 'darwin')
|
|
119
|
+
return '/Applications/WorkBuddy.app/Contents/MacOS/Electron';
|
|
120
|
+
// resources/app.asar.unpacked/cli/bin/codebuddy is inside the desktop install.
|
|
121
|
+
return join(dirname(binary), '../../../..', platform() === 'win32' ? 'WorkBuddy.exe' : 'workbuddy');
|
|
122
|
+
}
|
|
123
|
+
async function decryptDesktopToken(binary, authFilePath, signal) {
|
|
124
|
+
const env = { ...process.env, ELECTRON_RUN_AS_NODE: '1', NODE_OPTIONS: '' };
|
|
125
|
+
return new Promise((resolve, reject) => {
|
|
126
|
+
const child = execFile(workBuddyElectron(binary), ['-e', decryptDesktopTokenScript, authFilePath], { env, signal, timeout: 15_000, killSignal: 'SIGKILL', maxBuffer: 1024 * 1024, windowsHide: true }, (error, stdout) => {
|
|
127
|
+
// execFile errors include captured output: do not propagate them or their cause.
|
|
128
|
+
if (error) {
|
|
129
|
+
reject(new Error('Unable to decrypt WorkBuddy desktop credentials; log in to WorkBuddy or set CODEBUDDY_AUTH_TOKEN'));
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
const result = JSON.parse(stdout);
|
|
134
|
+
if (typeof result.token !== 'string' || !result.token.trim())
|
|
135
|
+
throw new Error();
|
|
136
|
+
resolve(result.token);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
reject(new Error('WorkBuddy desktop credential decryption returned no token'));
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
child.stdin?.end();
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
async function workBuddyEnvironment(binary, signal) {
|
|
146
|
+
const env = await workBuddyBundleEnvironment(binary);
|
|
147
|
+
if (process.env.CODEBUDDY_AUTH_TOKEN)
|
|
148
|
+
return env;
|
|
149
|
+
const authDir = desktopAuthDirectory();
|
|
150
|
+
if (!authDir)
|
|
151
|
+
return env;
|
|
152
|
+
const files = await readdir(authDir, { withFileTypes: true }).catch((error) => {
|
|
153
|
+
if (error.code === 'ENOENT')
|
|
154
|
+
return [];
|
|
155
|
+
throw new Error('Unable to read WorkBuddy desktop auth directory');
|
|
156
|
+
});
|
|
157
|
+
const names = files.filter(file => file.isFile() && file.name.endsWith('.info')).map(file => file.name)
|
|
158
|
+
.sort((a, b) => Number(b === 'workbuddy-desktop.info') - Number(a === 'workbuddy-desktop.info') || a.localeCompare(b));
|
|
159
|
+
for (const name of names) {
|
|
160
|
+
signal.throwIfAborted();
|
|
161
|
+
const path = join(authDir, name);
|
|
162
|
+
let text, mtimeMs;
|
|
163
|
+
try {
|
|
164
|
+
mtimeMs = (await stat(path)).mtimeMs;
|
|
165
|
+
text = await readFile(path, 'utf8');
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
throw new Error('Unable to read WorkBuddy desktop credentials');
|
|
169
|
+
}
|
|
170
|
+
let doc;
|
|
171
|
+
try {
|
|
172
|
+
doc = JSON.parse(text);
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const accessToken = doc?.auth?.accessToken;
|
|
178
|
+
let token;
|
|
179
|
+
if (typeof accessToken === 'string' && accessToken.trim())
|
|
180
|
+
token = accessToken;
|
|
181
|
+
else if (accessToken?.$wbEncrypted === 1 && typeof accessToken.envelope === 'string') {
|
|
182
|
+
const cacheKey = JSON.stringify([path, binary]);
|
|
183
|
+
let cached = desktopTokenCache.get(cacheKey);
|
|
184
|
+
if (!cached || cached.mtimeMs !== mtimeMs) {
|
|
185
|
+
const token = decryptDesktopToken(binary, path, signal);
|
|
186
|
+
cached = { mtimeMs, token };
|
|
187
|
+
desktopTokenCache.set(cacheKey, cached);
|
|
188
|
+
void token.catch(() => { if (desktopTokenCache.get(cacheKey) === cached)
|
|
189
|
+
desktopTokenCache.delete(cacheKey); });
|
|
190
|
+
}
|
|
191
|
+
token = await cached.token;
|
|
192
|
+
}
|
|
193
|
+
else
|
|
194
|
+
continue;
|
|
195
|
+
const result = { ...env, CODEBUDDY_AUTH_TOKEN: token };
|
|
196
|
+
const uid = doc?.account?.uid;
|
|
197
|
+
if (!process.env.ACC_USER_ID && (typeof uid === 'string' || typeof uid === 'number') && String(uid)) {
|
|
198
|
+
return { ...result, ACC_USER_ID: String(uid) };
|
|
199
|
+
}
|
|
200
|
+
return result;
|
|
201
|
+
}
|
|
202
|
+
return env;
|
|
203
|
+
}
|
|
204
|
+
export function createWorkBuddyRunner(options) {
|
|
205
|
+
return async (context) => {
|
|
206
|
+
const binary = await resolveCodeBuddyBinary(options.codebuddyBin);
|
|
207
|
+
context.signal.throwIfAborted();
|
|
208
|
+
const env = await workBuddyEnvironment(binary, context.signal);
|
|
209
|
+
context.signal.throwIfAborted();
|
|
210
|
+
const controller = new AbortController();
|
|
211
|
+
const abort = () => controller.abort(context.signal.reason);
|
|
212
|
+
context.signal.addEventListener('abort', abort, { once: true });
|
|
213
|
+
if (context.signal.aborted)
|
|
214
|
+
abort();
|
|
215
|
+
const server = createSdkMcpServer({ name: 'nia', version: '0.1.0', tools: [
|
|
216
|
+
tool('nia_group_chat_send_message', 'Send an interim update to this GroupChat', { content: z.string().trim().min(1) }, async ({ content }) => { await context.send(content); return { content: [{ type: 'text', text: 'Sent' }] }; }),
|
|
217
|
+
tool('nia_group_chat_history', 'Read older messages in this GroupChat', { limit: z.number().int().min(1).max(100).optional(), offset: z.number().int().min(0).optional() }, async ({ limit, offset }) => ({ content: [{ type: 'text', text: JSON.stringify(await context.history(limit, offset)) }] })),
|
|
218
|
+
] });
|
|
219
|
+
try {
|
|
220
|
+
return await consumeSdkQuery(query({ prompt: context.prompt, options: {
|
|
221
|
+
pathToCodebuddyCode: binary, env, cwd: options.cwd, model: options.model, resume: context.resume,
|
|
222
|
+
abortController: controller, permissionMode: options.fullAuto ? 'bypassPermissions' : 'default', allowDangerouslySkipPermissions: Boolean(options.fullAuto),
|
|
223
|
+
settingSources: ['user', 'project', 'local'], systemPrompt: { append: GROUP_CHAT_INSTRUCTIONS },
|
|
224
|
+
mcpServers: { nia: server },
|
|
225
|
+
canUseTool: async (name, input, detail) => {
|
|
226
|
+
// These two scoped collaboration tools need no separate TaskBar approval.
|
|
227
|
+
if (name === 'mcp__nia__nia_group_chat_send_message' || name === 'mcp__nia__nia_group_chat_history')
|
|
228
|
+
return { behavior: 'allow', updatedInput: input };
|
|
229
|
+
const result = await context.permission(name, input, detail.signal);
|
|
230
|
+
return result.behavior === 'allow' ? { behavior: 'allow', updatedInput: result.updatedInput ?? input } : { behavior: 'deny', message: result.message ?? 'Denied' };
|
|
231
|
+
},
|
|
232
|
+
stderr: data => process.stderr.write(data),
|
|
233
|
+
} }), context);
|
|
234
|
+
}
|
|
235
|
+
finally {
|
|
236
|
+
context.signal.removeEventListener('abort', abort);
|
|
237
|
+
await server.instance.close();
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["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AAM,CAAC,KAAK,CAAC,IAAI,CAAC;iBAC3C,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;QACjB,CAAC;gBAAS,CAAC;YAAC,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QAAC,CAAC;IAClG,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# WorkBuddy / CodeBuddy upstream contract
|
|
2
|
+
|
|
3
|
+
Inspected npm `@tencent-ai/agent-sdk@0.3.300` and `@tencent-ai/codebuddy-code@2.180.0`. SDK declarations and live CLI help are retained in `upstream/`.
|
|
4
|
+
|
|
5
|
+
- `query({ prompt, options })` is AsyncIterable of system/assistant/result messages. `session_id` identifies the durable runtime conversation; `resume` restores it. Success carries `type: "result", subtype: "success", result: string`; errors carry `is_error`/`errors`.
|
|
6
|
+
- Executable override: `pathToCodebuddyCode`. There is no `pathToCodeBuddyExecutable` option. Options include `cwd`, `model`, `abortController`, `canUseTool`, `mcpServers`, `permissionMode`, `settingSources`, `env`.
|
|
7
|
+
- SDK transport uses `--input-format=stream-json --output-format=stream-json --verbose`, `--resume`, `--setting-sources`, `--permission-mode`; it chooses Node for JS launchers and direct execution for `.exe`.
|
|
8
|
+
- SDK initialize control request carries `sdkMcpServers` and `capabilities.askUserQuestion: true`. In-process tools use `createSdkMcpServer` and `tool` from the same SDK, with Zod schemas and MCP content results.
|
|
9
|
+
- CLI → SDK `control_request.request.subtype: "can_use_tool"` includes `tool_name`, `input`, `tool_use_id`. Callback is `(toolName, input, { signal, toolUseID, ... })`. SDK callbacks return `{ behavior: "allow", updatedInput }` or `{ behavior: "deny", message }`; SDK translates these to its own `{ allowed, ... }` wire response. Do not substitute Claude's control response shape.
|
|
10
|
+
- Cancellation sets AbortController and calls query `interrupt()`; upstream returns a terminal result and cleans up the transport. Cancellation is cooperative with the selected CLI.
|
|
11
|
+
- `AskUserQuestion` can surface through this callback. Answers are supplied in `updatedInput.answers`, keyed by question text.
|
|
12
|
+
- SDK defaults setting sources to `none`; bridge explicitly enables user/project/local to preserve local settings. `CODEBUDDY_CONFIG_DIR`, `WORKBUDDY_CONFIG_DIR`, `CODEBUDDY_AUTH_TOKEN`, `CODEBUDDY_API_KEY` and the selected build's product authentication are inherited, not synthesized. CodeBuddy standard data is `.codebuddy`; WorkBuddy product-specific configuration uses `.workbuddy` (including models.json). Sharing Desktop auth is not presumed for a different CodeBuddy build.
|
|
13
|
+
|
|
14
|
+
SHA256:
|
|
15
|
+
|
|
16
|
+
```text
|
|
17
|
+
a1bd88faf1f7c28d27d5975d2882ccd91d9b9206fdb0c5014d899519619a6aa9 tencent-ai-agent-sdk-0.3.300.tgz
|
|
18
|
+
602071561129a332c88b628650a3e15925a84a82f5cccce7b5cc4fbfbb0509a2 tencent-ai-codebuddy-code-2.180.0.tgz
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
TaskBar cards bind the full tool/input, active turn identity, and card ID through core `verifyCardApproval`, tool `workbuddy.approval`, server `agent-bridge`. UI clicks alone grant nothing. GroupChat tool calls are scoped by host context, not a model-supplied chat/session identifier.
|
|
22
|
+
|
|
23
|
+
## Desktop entrypoint interoperability
|
|
24
|
+
|
|
25
|
+
`agent-sdk@0.3.300` passes `pathToCodebuddyCode` to its process transport as `executablePath`. The transport rewrites any Unix `bin/codebuddy` suffix to `dist/codebuddy-headless.js` without checking existence, even with `executable`/`executableArgs` specified. It does not rewrite `.mjs`/`.js` entrypoints or dereference symlinks. WorkBuddy.app distributions may ship only `dist/codebuddy-lite-wb.mjs`, so executable discovery normalizes the installation to that readable ESM entrypoint before the single SDK query path. Standard CLI distributions without that bundle retain their original entrypoint. Explicit script entrypoints require readability, not an OS executable bit.
|
|
26
|
+
|
|
27
|
+
The SDK merges `{ ...process.env, ...options.env }`; desktop overrides do not remove PATH/HOME. Desktop credential decryption locates `Contents/MacOS/Electron` from the `WorkBuddy.app` root, which is unchanged by selecting `cli/dist` instead of `cli/bin`. Tests cover the real SDK spawn/initialize/MCP/permission/resume/result/error protocol using a desktop-only mock distribution, plus encrypted desktop auth and standalone preview installation.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
Desktop credential decryption invokes `Electron -e <inline-script> <auth-file-path>` with `ELECTRON_RUN_AS_NODE=1` and `NODE_OPTIONS=''`. The WorkBuddy storage linked binding is available in this build's NodeMain mode, avoiding browser/NSApplication startup and desktop focus activation. The child reads the existing credential file; only its path (not the envelope, token, or at-rest key) travels in argv. JSON token output is captured in memory. No temporary scripts, stdin envelopes, or output files are used. Child errors/output are never attached to reported errors. The existing in-memory `(auth path, CLI path, mtimeMs)` promise cache deduplicates concurrent decryptions, refreshes on mtime changes, and evicts rejected promises. Plaintext desktop credentials and explicit `CODEBUDDY_AUTH_TOKEN` bypass Electron decryption.
|
|
31
|
+
|
|
32
|
+
## GroupChat sender identity and mentions
|
|
33
|
+
|
|
34
|
+
Incoming messages carry sender metadata, for example `[chat:<chatId>] Alice (<userId>): ...`, or `senderId` in structured channel payloads. This bridge's raw `thread.message` uses `messages[].authorId`; its formatted prompt lists `Alice (<userId>)` and member IDs. Use the received sender/member ID, not the display name.
|
|
35
|
+
|
|
36
|
+
To notify a member with a native Nia Teams highlight, emit `<mention userId="<userId>" />` in the published reply. Plain `@Name` is text, not a real mention. Do not invent IDs; consult the member list/history if needed.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Usage: codebuddy|cbc [options] [command] [prompt]
|
|
2
|
+
|
|
3
|
+
CodeBuddy Code - starts an interactive session by default, use -p/--print for
|
|
4
|
+
non-interactive output
|
|
5
|
+
|
|
6
|
+
Arguments:
|
|
7
|
+
prompt Your prompt
|
|
8
|
+
|
|
9
|
+
Options:
|
|
10
|
+
-V, --version output the version number
|
|
11
|
+
-d, --debug [filter] Enable debug mode with optional category filtering (e.g., "api,hooks" or "!statsig,!file") (default: false)
|
|
12
|
+
--verbose Override verbose mode setting from config (default: false)
|
|
13
|
+
-p, --print Print response and exit (useful for pipes) (default: false)
|
|
14
|
+
--output-format <format> Output format (only works with --print): "text" (default), "json" (single result), or "stream-json" (realtime streaming) (default: "text")
|
|
15
|
+
--input-format <format> Input format (only works with --print): "text" (default), or "stream-json" (realtime streaming input) (choices: "text", "stream-json") (default: "text")
|
|
16
|
+
--json-schema <schema> JSON Schema for structured output validation. Example: {"type":"object","properties":{"name":{"type":"string"}},"required":["name"]}
|
|
17
|
+
--include-partial-messages Output raw SSE incremental messages from model requests (only works with --output-format stream-json) (default: false)
|
|
18
|
+
-y, --dangerously-skip-permissions Bypass permission prompts (HIGH/CRITICAL still ask). Isolated-sandbox full pass: CODEBUDDY_IS_SANDBOX=1 (process env only; high-risk). (default: false)
|
|
19
|
+
--permission-mode <mode> Default permission mode for this process (TUI, --serve Web, ACP). Choices: acceptEdits, bypassPermissions, default, plan, dontAsk, auto. Does not write settings.
|
|
20
|
+
--permission-mode-before-plan <mode> Permission mode to restore when exiting plan mode
|
|
21
|
+
--subagent-permission-mode <mode> Default permission mode for subagents/teammates (choices: "acceptEdits", "bypassPermissions", "default", "plan", "dontAsk", "auto"). Overrides inheritance from main session.
|
|
22
|
+
--tools <value> Restrict which built-in tools CodeBuddy can use. Use "" to disable all, "default" for all, or comma-separated tool names like "Bash,Edit,Read".
|
|
23
|
+
--allowedTools <tools...> Comma or space-separated list of tool names to allow (e.g. "Bash(git:*) Edit")
|
|
24
|
+
--disallowedTools <tools...> Comma or space-separated list of tool names to deny (e.g. "Bash(git:*) Edit")
|
|
25
|
+
--mcp-config <fileOrString> Load MCP servers from a JSON file or string
|
|
26
|
+
--channels <value> Enable specific channels (comma-separated: plugin:name@marketplace or server:configName)
|
|
27
|
+
--dangerously-load-development-channels <value> During research preview: bypass allowlist for specific channels (development only, requires confirmation)
|
|
28
|
+
-c, --continue Continue the most recent conversation (default: false)
|
|
29
|
+
-r, --resume [sessionId] Resume a conversation - provide a session ID or interactively select a conversation to resume (default: false)
|
|
30
|
+
-w, --worktree [name] Create a git worktree and start the session in it (optionally specify a name, PR number like "#123", or PR URL)
|
|
31
|
+
--worktree-branch <branch> Base branch for the worktree (defaults to remote default branch, requires --worktree)
|
|
32
|
+
--tmux Create worktree in a new tmux session (requires --worktree) (default: false)
|
|
33
|
+
--tmux-classic Use classic tmux mode instead of iTerm2 integration (requires --tmux) (default: false)
|
|
34
|
+
--model <model> Model for the current session. Please provide the model ID. Currently supported: (default-model, fast-model, balanced-model, primary-model, deep-model, hy4-preview, hy3, deepseek-v4.1-flash, gpt-6-astra, gpt-5.6-sol, gpt-5.6-terra, gpt-5.6-luna, gpt-5.5, gpt-5.4, gemini-3.5-flash, glm-5.3-flash, glm-5.3, glm-5.2, kimi-k3, kimi-k2.6, kimi-k2.8-preview)
|
|
35
|
+
--text-to-image-model <model> Model for text-to-image generation
|
|
36
|
+
--image-to-image-model <model> Model for image-to-image editing
|
|
37
|
+
--fallback-model <model> Enable automatic fallback to specified model when default model is overloaded (only works with --print)
|
|
38
|
+
--add-dir <directories...> Additional directories to allow tool access to
|
|
39
|
+
--ide Automatically connect to IDE on startup if exactly one valid IDE is available (default: false)
|
|
40
|
+
-v, --version Output the version number (default: false)
|
|
41
|
+
--strict-mcp-config Only use MCP servers from --mcp-config, ignoring all other MCP configurations (default: false)
|
|
42
|
+
--session-id <uuid> Use a specific session ID for the conversation (supports letters, numbers, hyphens, underscores, and colons, but must start with a letter or number)
|
|
43
|
+
--resume-create-missing With --resume: when the target session no longer exists, start a new empty session with the same id instead of failing (job worker respawn recovery path; explicit user --resume still errors)
|
|
44
|
+
--no-session-persistence Disable session persistence - sessions stay in memory and are not saved to disk
|
|
45
|
+
-H, --header <headers...> Custom HTTP headers for model requests (format: "Header-Key: Header-Value")
|
|
46
|
+
--serve Start HTTP server (Web UI, REST API, ACP over HTTP SSE). Without --acp, ACP does not use stdio. (default: false)
|
|
47
|
+
--open Open Web UI in browser after startup (default: false)
|
|
48
|
+
--port <number> Port for HTTP server (default: auto-assign; interactive mode reuses a stable port)
|
|
49
|
+
--host <string> Host address to bind HTTP server (default: 127.0.0.1) (default: "127.0.0.1")
|
|
50
|
+
--base-path <path> Public URL path prefix for the Web UI (e.g. /cnb-5gg-1k09dqp5v-001). Also CODEBUDDY_GATEWAY_BASE_PATH.
|
|
51
|
+
--auth <mode> HTTP server authentication mode (only applies with --serve). Defaults to "password"; "none" disables auth and lets any local process execute commands and read/write files through the server (choices: "password", "none")
|
|
52
|
+
--brief Enable SendUserMessage tool for agent-to-user communication (default: false)
|
|
53
|
+
--acp Start in ACP (Agent Client Protocol) mode - enables communication via stdin/stdout using ndJsonStream (default: false)
|
|
54
|
+
--acp-transport <transport> ACP transport (only works with --acp): "stdio" (default) or "streamable-http" (default: "stdio")
|
|
55
|
+
--sandbox [url] Run CodeBuddy in sandbox: "container" for Docker/Podman, or E2B API URL (must be complete URL like https://api.e2b.dev)
|
|
56
|
+
--sandbox-upload-dir Upload current working directory to sandbox (E2B only) (default: false)
|
|
57
|
+
--sandbox-new Force create a new sandbox (ignore cached sandbox) (default: false)
|
|
58
|
+
--sandbox-id <id> Connect to specific sandbox ID
|
|
59
|
+
--sandbox-kill Kill sandbox on exit (default: keep alive for reuse) (default: false)
|
|
60
|
+
--teleport <value> Teleport to existing sandbox (format: session_{cliSessionId})
|
|
61
|
+
--max-turns <number> Limit the number of agentic turns
|
|
62
|
+
--effort <level> Reasoning effort level (minimal, low, medium, high, xhigh, max)
|
|
63
|
+
--autocompact <auto|tokens> Auto-compact window size: "auto" follows the model window, or a token count (e.g. 400000, 400k, 1m; clamped to 100k-1M)
|
|
64
|
+
--teleport <value> Teleport to existing sandbox (format: 0010${sandboxId}${randomNumber} for e2b, 0020${sandboxId}${randomNumber} for cvm)
|
|
65
|
+
--system-prompt <prompt> Override the system prompt for this session
|
|
66
|
+
--system-prompt-file <path> Load system prompt from a file
|
|
67
|
+
--append-system-prompt <prompt> Append additional content to the system prompt
|
|
68
|
+
--prompt-vars-file <path> Load prompt template variables from a JSON file
|
|
69
|
+
--agent <agent> Default main agent for this process (TUI, --print/headless, --serve Web, ACP). Headless tool use must be pre-authorized (for example with -y). Overrides lastUsed for new sessions; does not write settings.
|
|
70
|
+
--tool-mode <mode> 选择独立工具策略,不改变代理角色或权限 (choices: "cli", "ptc", "minimal", "create")
|
|
71
|
+
--multitask Turn on Multitask overlay (normalized to --agent multitask). Not available in Minimal. Does not change Standard/PTC/Create. Interactive TTY only. (default: false)
|
|
72
|
+
--agents <json> JSON object defining custom agents (e.g. '{"reviewer": {"description": "Reviews code", "prompt": "You are a code reviewer"}}')
|
|
73
|
+
--settings <file-or-json> Path to a settings JSON file or a JSON string to load additional settings from
|
|
74
|
+
--setting-sources <sources> Comma-separated list of setting sources to load (user, project, local). Default: user,project,local
|
|
75
|
+
--fork-session When resuming, create a new session ID instead of reusing the original (use with --resume or --continue)
|
|
76
|
+
--replay-user-messages Re-emit user messages from stdin back on stdout for acknowledgment (only works with --input-format=stream-json and --output-format=stream-json)
|
|
77
|
+
--remote-control [client] Connect to remote control service. Without args: AgentOS mode. With client type (e.g. wecom): auto-connect specified client
|
|
78
|
+
--plugin-dir <dirs...> Load plugins from local directories (for development/testing). Can specify multiple paths.
|
|
79
|
+
--bg Run the session in the background (detached) (default: false)
|
|
80
|
+
--background Alias for --bg (default: false)
|
|
81
|
+
--name <name> Name for background session (used with --bg)
|
|
82
|
+
--exec <command> With --bg: run a shell command as a background job instead of a model session
|
|
83
|
+
--swarm Enable swarm mode: teammates run as independent processes (tmux visualization if available, otherwise background with Web UI) (default: false)
|
|
84
|
+
-h, --help display help for command
|
|
85
|
+
|
|
86
|
+
Commands:
|
|
87
|
+
config Manage configuration (eg. codebuddy config set -g theme dark)
|
|
88
|
+
mcp Configure and manage MCP servers
|
|
89
|
+
sandbox Manage sandboxes
|
|
90
|
+
plugin [options] Manage CodeBuddy Code plugins
|
|
91
|
+
project Manage CodeBuddy Code project state
|
|
92
|
+
doctor Check the health of your CodeBuddy Code auto-updater
|
|
93
|
+
update Check for updates and install if available
|
|
94
|
+
install [target] Install CodeBuddy Code native build. Use [target] to specify version (latest, or specific version)
|
|
95
|
+
cleanup [options] Clean up expired local CodeBuddy data
|
|
96
|
+
daemon Manage the daemon supervisor process
|
|
97
|
+
ps [options] List all active sessions (interactive, background, daemon)
|
|
98
|
+
logs [options] <pidOrName> Show logs for a background session
|
|
99
|
+
attach <pidOrName> Attach to a running background session
|
|
100
|
+
kill <pidOrName> Terminate a background session
|
|
101
|
+
stop <pidOrName> Stop a background session (alias for kill)
|
|
102
|
+
rm <idOrName> Remove a background session from agent view (the transcript stays on your machine)
|
|
103
|
+
respawn [options] [idOrName] Restart a background session with its conversation intact
|
|
104
|
+
agents [options] Open agent view to dispatch and manage background sessions
|
|
105
|
+
auto-mode Inspect the auto mode reviewer policy
|
|
106
|
+
agents [options] List configured agents grouped by source (user, project, managed, plugin, cli-arg, built-in); requires --json
|