@commonlyai/cli 0.1.352 → 0.1.353
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 +1 -1
- package/src/lib/adapters/goose.js +39 -13
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/** Goose 1.54.0
|
|
1
|
+
/** Goose wrapper (public seats: 1.54.0, 1.59.0). Public seats expose only the Commonly MCP extension. */
|
|
2
2
|
import { requireSeatModel } from './seat-model.js';
|
|
3
3
|
import { probeVersion } from './tested-version.js';
|
|
4
4
|
import { spawn as childSpawn, spawnSync } from 'node:child_process';
|
|
5
|
-
import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
|
|
5
|
+
import { mkdir, mkdtemp, readFile, rm, symlink, writeFile } from 'node:fs/promises';
|
|
6
6
|
import { tmpdir } from 'node:os';
|
|
7
7
|
import { isAbsolute, join } from 'node:path';
|
|
8
8
|
import { StringDecoder } from 'node:string_decoder';
|
|
@@ -27,13 +27,23 @@ import { BRIDGE_PATH } from './codex-broker-bridge.mjs';
|
|
|
27
27
|
// A version enters this list only after a real headless turn with that binary.
|
|
28
28
|
// Each version here is proven by the real-binary smoke test on macOS and Linux
|
|
29
29
|
// (.github/workflows/goose-public-proof.yml carries one pinned row per version).
|
|
30
|
-
// 1.56.0
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
// From 1.56.0 the state-machine loop offers the model `load_skill` on every
|
|
31
|
+
// turn, which the extension allowlist cannot remove (F113c), and reads skills,
|
|
32
|
+
// plugin hooks and plugin settings from its working directory. A public turn
|
|
33
|
+
// therefore runs in an empty folder of its own, and a hook the adapter owns
|
|
34
|
+
// refuses every load_skill call (F113d). 1.56.0-1.58.x were never proven.
|
|
35
|
+
export const TESTED_GOOSE_VERSIONS = Object.freeze(['1.54.0', '1.59.0']);
|
|
36
|
+
// Advertised by an admitted Goose but refused on every call of a public turn.
|
|
37
|
+
export const SWITCHED_OFF_GOOSE_TOOLS = Object.freeze(['load_skill']);
|
|
38
|
+
const PUBLIC_HOOK_PLUGIN = 'commonly-public-seat';
|
|
39
|
+
// Goose 1.56+ (hooks/mod.rs) runs a PreToolUse command through `sh -c`: exit 2
|
|
40
|
+
// denies the call with stderr as the reason. `on_failure: block` denies it too
|
|
41
|
+
// when the hook cannot run at all, say because the jail refuses `sh`.
|
|
42
|
+
const publicHookConfig = () => ({ hooks: { PreToolUse: [{
|
|
43
|
+
matcher: `^(?:${SWITCHED_OFF_GOOSE_TOOLS.join('|')})$`,
|
|
44
|
+
hooks: [{ type: 'command', on_failure: 'block', timeout: 10,
|
|
45
|
+
command: "printf '%s' 'Skills are switched off on a public seat' >&2; exit 2" }],
|
|
46
|
+
}] } });
|
|
37
47
|
const DEFAULT_TIMEOUT_MS = 15 * 60 * 1000;
|
|
38
48
|
const TERMINATION_GRACE_MS = 5000;
|
|
39
49
|
const DEFAULT_PROVIDER_HOST = 'https://litellm.commonly.me';
|
|
@@ -398,6 +408,20 @@ export default {
|
|
|
398
408
|
// the recipe alone, never the credential file.
|
|
399
409
|
const recipeDir = join(tempDir, 'recipe');
|
|
400
410
|
const recipePath = join(recipeDir, 'public-recipe.json');
|
|
411
|
+
// F113d: Goose reads skills, plugins and plugin settings from its working
|
|
412
|
+
// directory, and a public Goose has no file tool that needs the seat's
|
|
413
|
+
// workspace. The jail and Goose start in an empty folder of this turn.
|
|
414
|
+
const turnWorkspace = isPublic ? join(home, 'workspace') : null;
|
|
415
|
+
if (turnWorkspace) {
|
|
416
|
+
await mkdir(turnWorkspace, { mode: 0o700 });
|
|
417
|
+
// The hook lives with the adapter's files, which the jail only reads;
|
|
418
|
+
// the user plugin folder in the seat home links to it.
|
|
419
|
+
const pluginDir = join(tempDir, 'plugins', PUBLIC_HOOK_PLUGIN);
|
|
420
|
+
await mkdir(join(pluginDir, 'hooks'), { recursive: true, mode: 0o700 });
|
|
421
|
+
await writeFile(join(pluginDir, 'hooks', 'hooks.json'), JSON.stringify(publicHookConfig()), { mode: 0o600 });
|
|
422
|
+
await mkdir(join(home, '.agents', 'plugins'), { recursive: true, mode: 0o700 });
|
|
423
|
+
await symlink(pluginDir, join(home, '.agents', 'plugins', PUBLIC_HOOK_PLUGIN));
|
|
424
|
+
}
|
|
401
425
|
const args = [
|
|
402
426
|
'run', '--no-session', ...(!isPublic ? ['--no-profile', '--with-builtin', 'developer'] : []),
|
|
403
427
|
...(isPublic ? ['--recipe', recipePath] : []),
|
|
@@ -453,14 +477,16 @@ export default {
|
|
|
453
477
|
...ctx.environment, sandbox: { ...sandbox, filesystem: {
|
|
454
478
|
...(sandbox.filesystem || {}), 'write-outside': [home],
|
|
455
479
|
} },
|
|
456
|
-
}, { workspacePath:
|
|
480
|
+
}, { workspacePath: turnWorkspace, homePath: home,
|
|
457
481
|
readOnlyPaths: [tempDir, binary, process.execPath, ...mcpReadDirectories] });
|
|
458
482
|
} else {
|
|
459
483
|
if ((ctx._platform || process.platform) !== 'darwin') throw new Error('goose adapter: Seatbelt requires macOS');
|
|
460
484
|
[executable, ...spawnArgs] = (ctx._wrapArgvWithSeatbelt || wrapArgvWithSeatbelt)([binary, ...args], {
|
|
461
|
-
|
|
485
|
+
// The turn folder sits in the home the jail writes, so read-only mode
|
|
486
|
+
// no longer narrows anything here (F113d); it is kept for the profile.
|
|
487
|
+
workspacePath: turnWorkspace, workspaceAccess: mode === 'read-only' ? 'read' : 'write',
|
|
462
488
|
executablePath: binary, statePath: home, mcpConfigDir: tempDir,
|
|
463
|
-
//
|
|
489
|
+
// The adapter made this folder for the turn, so it is pinned (F197).
|
|
464
490
|
pinWorkspace: true,
|
|
465
491
|
loopbackNetworkPorts: [proxy.port], readOnlyDirectories: mcpReadDirectories,
|
|
466
492
|
});
|
|
@@ -486,7 +512,7 @@ export default {
|
|
|
486
512
|
if (credentialRelease.error) throw credentialRelease.error;
|
|
487
513
|
}
|
|
488
514
|
const text = await runGoose({
|
|
489
|
-
binary: executable, args: spawnArgs, cwd: ctx.cwd, env, timeoutMs,
|
|
515
|
+
binary: executable, args: spawnArgs, cwd: turnWorkspace || ctx.cwd, env, timeoutMs,
|
|
490
516
|
credentials: [...spawnCredentials(ctx, [DEFAULT_PROVIDER_KEY]), key, env.OPENAI_API_KEY],
|
|
491
517
|
optionalExtensions: brokerExtensions,
|
|
492
518
|
spawnImpl,
|