@bakers-build/addon-opencode 0.5.1-next.826 → 0.5.1-next.841
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/src/index.d.ts +4 -2
- package/dist/src/index.js +24 -2
- package/package.json +3 -3
package/dist/src/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type AgentFootprint, type AgentPlugin, type AgentRunIdentity, type BbAgent } from '@bakers-build/conductor/contract';
|
|
1
|
+
import { type AgentFootprint, type AgentPlugin, type AgentRunIdentity, type BbAgent, type RunEnvPolicy, type SecurityOptions } from '@bakers-build/conductor/contract';
|
|
2
2
|
export { parseOpencodeTranscript } from './footprint.js';
|
|
3
|
-
export interface OpencodeAgentOptions {
|
|
3
|
+
export interface OpencodeAgentOptions extends SecurityOptions {
|
|
4
4
|
model?: string;
|
|
5
5
|
effort?: string;
|
|
6
6
|
args?: string[];
|
|
@@ -17,6 +17,8 @@ export declare class OpencodeAgent implements BbAgent {
|
|
|
17
17
|
private readonly args;
|
|
18
18
|
private readonly model;
|
|
19
19
|
private readonly overrides;
|
|
20
|
+
private readonly security;
|
|
21
|
+
readonly runEnvPolicy: RunEnvPolicy;
|
|
20
22
|
constructor(options?: OpencodeAgentOptions, storageRoot?: string);
|
|
21
23
|
launchCommand(prompt: string, _run?: AgentRunIdentity): string;
|
|
22
24
|
/**
|
package/dist/src/index.js
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { readdir, readFile } from 'node:fs/promises';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
import { resolveAgentCliOptions, } from '@bakers-build/conductor/contract';
|
|
4
|
+
import { resolveAgentCliOptions, resolveSecurityOptions, } from '@bakers-build/conductor/contract';
|
|
5
5
|
import { shellQuote } from '@bakers-build/core';
|
|
6
6
|
import { parseOpencodeTranscript } from './footprint.js';
|
|
7
7
|
export { parseOpencodeTranscript } from './footprint.js';
|
|
8
8
|
const OPENCODE_RESERVED = ['--prompt', '--auto'];
|
|
9
|
+
/** Only satisfies the shared resolver: sandbox mode is rejected before any key is used. */
|
|
10
|
+
const SANDBOX_DEFAULTS = {
|
|
11
|
+
trusted_commands: [],
|
|
12
|
+
deny_read: [],
|
|
13
|
+
allow_write: [],
|
|
14
|
+
network: ['*'],
|
|
15
|
+
mcp_servers: {},
|
|
16
|
+
};
|
|
9
17
|
const OPENCODE_KNOWN = [
|
|
10
18
|
{ kind: 'model', flags: ['--model', '-m'] },
|
|
11
19
|
];
|
|
@@ -45,8 +53,19 @@ export class OpencodeAgent {
|
|
|
45
53
|
args;
|
|
46
54
|
model;
|
|
47
55
|
overrides;
|
|
56
|
+
security;
|
|
57
|
+
runEnvPolicy;
|
|
48
58
|
constructor(options = {}, storageRoot = defaultOpencodeStorageRoot()) {
|
|
49
59
|
this.storageRoot = storageRoot;
|
|
60
|
+
// OpenCode has no OS sandbox, so its default is system, not the shared sandbox.
|
|
61
|
+
this.security = resolveSecurityOptions({ ...options, security: options.security ?? 'system' }, SANDBOX_DEFAULTS);
|
|
62
|
+
this.runEnvPolicy = this.security.runEnvPolicy;
|
|
63
|
+
if (this.security.mode === 'sandbox') {
|
|
64
|
+
throw new Error("OpenCode has no OS sandbox, so security: 'sandbox' cannot be enforced; leave security unset or set 'system' (your own OpenCode configuration) or 'yolo'");
|
|
65
|
+
}
|
|
66
|
+
if (this.security.mode === 'custom') {
|
|
67
|
+
throw new Error("OpenCode has no config hand-off for security: 'custom'; use security: 'system' with your own OpenCode configuration");
|
|
68
|
+
}
|
|
50
69
|
const cli = resolveAgentCliOptions(options, OPENCODE_RESERVED, OPENCODE_KNOWN);
|
|
51
70
|
this.args = cli.args;
|
|
52
71
|
this.model = cli.model;
|
|
@@ -67,7 +86,10 @@ export class OpencodeAgent {
|
|
|
67
86
|
if (this.model !== undefined && !this.overrides.model) {
|
|
68
87
|
parts.push('--model', shellQuote(this.model));
|
|
69
88
|
}
|
|
70
|
-
|
|
89
|
+
// Auto-approval is not protection: only yolo gets it.
|
|
90
|
+
if (this.security.mode === 'yolo') {
|
|
91
|
+
parts.push('--auto');
|
|
92
|
+
}
|
|
71
93
|
parts.push(...this.args.map(shellQuote));
|
|
72
94
|
return parts.join(' ');
|
|
73
95
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bakers-build/addon-opencode",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.841",
|
|
4
4
|
"description": "bakers.build agent plugin for the OpenCode CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"directory": "bakers-cli/addons/opencode"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@bakers-build/conductor": "^0.5.1-next.
|
|
24
|
-
"@bakers-build/core": "^0.5.1-next.
|
|
23
|
+
"@bakers-build/conductor": "^0.5.1-next.841",
|
|
24
|
+
"@bakers-build/core": "^0.5.1-next.841"
|
|
25
25
|
}
|
|
26
26
|
}
|