@bakers-build/addon-pi 0.5.1-next.847 → 0.5.1-next.849
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 +11 -2
- package/dist/src/index.js +50 -2
- package/package.json +4 -4
package/dist/src/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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 { parsePiTranscript } from './footprint.js';
|
|
3
3
|
/**
|
|
4
4
|
* The relative `--session-dir` pin — the single source of truth shared by
|
|
@@ -25,7 +25,11 @@ export declare function piSessionDir(run?: AgentRunIdentity): string;
|
|
|
25
25
|
* `--home-cw-projects-bakers--`.
|
|
26
26
|
*/
|
|
27
27
|
export declare function encodePiHomeSessionSlug(cwd: string): string;
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* `security` is `system` (default) or `custom`; `custom`'s `config` is
|
|
30
|
+
* `{ extensions: string[] }`, each passed as `-e`. Pi has no OS sandbox.
|
|
31
|
+
*/
|
|
32
|
+
export interface PiAgentOptions extends SecurityOptions {
|
|
29
33
|
model?: string;
|
|
30
34
|
provider?: string;
|
|
31
35
|
thinking?: string;
|
|
@@ -42,14 +46,19 @@ export interface PiAgentOptions {
|
|
|
42
46
|
export declare class PiAgent implements BbAgent {
|
|
43
47
|
private readonly home;
|
|
44
48
|
readonly id = "pi";
|
|
49
|
+
readonly runEnvPolicy: RunEnvPolicy;
|
|
45
50
|
private readonly args;
|
|
46
51
|
private readonly model;
|
|
47
52
|
private readonly provider;
|
|
48
53
|
private readonly thinking;
|
|
49
54
|
private readonly approve;
|
|
55
|
+
/** `custom` mode's extensions; `undefined` in `system` mode. */
|
|
56
|
+
private readonly extensions;
|
|
50
57
|
private readonly overrides;
|
|
51
58
|
constructor(options?: PiAgentOptions, home?: string);
|
|
52
59
|
launchCommand(prompt: string, run?: AgentRunIdentity): string;
|
|
60
|
+
/** `custom` only: just the configured extensions load (explicit -e survives --no-extensions). */
|
|
61
|
+
private extensionFlags;
|
|
53
62
|
getRunLog(worktreePath: string, run?: AgentRunIdentity): Promise<string>;
|
|
54
63
|
parseFootprint(log: string): AgentFootprint;
|
|
55
64
|
}
|
package/dist/src/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readdir, readFile, stat } from 'node:fs/promises';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
import { resolveAgentCliOptions, validateOptionalBoolean, validateOptionalString, } from '@bakers-build/conductor/contract';
|
|
4
|
+
import { resolveAgentCliOptions, resolveSecurityOptions, validateOptionalBoolean, validateOptionalString, } from '@bakers-build/conductor/contract';
|
|
5
5
|
import { shellQuote } from '@bakers-build/core';
|
|
6
6
|
import { parsePiTranscript } from './footprint.js';
|
|
7
7
|
export { parsePiTranscript } from './footprint.js';
|
|
@@ -90,17 +90,55 @@ async function newestJsonl(dir, minMtimeMs) {
|
|
|
90
90
|
return '';
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
+
const NO_SANDBOX_DEFAULTS = {
|
|
94
|
+
trusted_commands: [],
|
|
95
|
+
deny_read: [],
|
|
96
|
+
allow_write: [],
|
|
97
|
+
network: [],
|
|
98
|
+
mcp_servers: {},
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Pi has no OS sandbox and no permission gate, so only `system` (the default)
|
|
102
|
+
* and `custom` exist; `custom` loads the operator's own extensions, e.g. one
|
|
103
|
+
* that sandboxes Pi's tools.
|
|
104
|
+
*/
|
|
105
|
+
function piSecurity(options) {
|
|
106
|
+
const { mode, config, runEnvPolicy } = resolveSecurityOptions({
|
|
107
|
+
...options,
|
|
108
|
+
security: (validateOptionalString(options.security, 'security') ??
|
|
109
|
+
'system'),
|
|
110
|
+
}, NO_SANDBOX_DEFAULTS);
|
|
111
|
+
if (mode === 'system')
|
|
112
|
+
return { extensions: undefined, runEnvPolicy };
|
|
113
|
+
if (mode !== 'custom') {
|
|
114
|
+
throw new Error(`Pi does not support security: '${mode}'; use 'system' or 'custom'`);
|
|
115
|
+
}
|
|
116
|
+
const keys = Object.keys(config ?? {});
|
|
117
|
+
const extensions = config?.extensions;
|
|
118
|
+
if (keys.some((key) => key !== 'extensions') ||
|
|
119
|
+
!Array.isArray(extensions) ||
|
|
120
|
+
extensions.length === 0 ||
|
|
121
|
+
extensions.some((e) => typeof e !== 'string' || e === '' || e.includes('\0'))) {
|
|
122
|
+
throw new Error("Pi security: 'custom' needs config: { extensions: ['<path or builtin:name>', ...] } and nothing else");
|
|
123
|
+
}
|
|
124
|
+
return { extensions: [...extensions], runEnvPolicy };
|
|
125
|
+
}
|
|
93
126
|
export class PiAgent {
|
|
94
127
|
home;
|
|
95
128
|
id = 'pi';
|
|
129
|
+
runEnvPolicy;
|
|
96
130
|
args;
|
|
97
131
|
model;
|
|
98
132
|
provider;
|
|
99
133
|
thinking;
|
|
100
134
|
approve;
|
|
135
|
+
/** `custom` mode's extensions; `undefined` in `system` mode. */
|
|
136
|
+
extensions;
|
|
101
137
|
overrides;
|
|
102
138
|
constructor(options = {}, home = homedir()) {
|
|
103
139
|
this.home = home;
|
|
140
|
+
({ extensions: this.extensions, runEnvPolicy: this.runEnvPolicy } =
|
|
141
|
+
piSecurity(options));
|
|
104
142
|
const cli = resolveAgentCliOptions(options, PI_RESERVED, PI_KNOWN);
|
|
105
143
|
this.args = cli.args;
|
|
106
144
|
this.model = cli.model;
|
|
@@ -112,7 +150,7 @@ export class PiAgent {
|
|
|
112
150
|
}
|
|
113
151
|
launchCommand(prompt, run) {
|
|
114
152
|
if (prompt === '') {
|
|
115
|
-
return 'pi';
|
|
153
|
+
return ['pi', ...this.extensionFlags()].join(' ');
|
|
116
154
|
}
|
|
117
155
|
// Positional prompt → an attachable interactive TUI (no `-p`/`--print`,
|
|
118
156
|
// which would leave the herdr pane without a session to attach to). Order:
|
|
@@ -136,9 +174,19 @@ export class PiAgent {
|
|
|
136
174
|
if (this.approve) {
|
|
137
175
|
parts.push('--approve');
|
|
138
176
|
}
|
|
177
|
+
parts.push(...this.extensionFlags());
|
|
139
178
|
parts.push(...this.args.map(shellQuote));
|
|
140
179
|
return parts.join(' ');
|
|
141
180
|
}
|
|
181
|
+
/** `custom` only: just the configured extensions load (explicit -e survives --no-extensions). */
|
|
182
|
+
extensionFlags() {
|
|
183
|
+
if (this.extensions === undefined)
|
|
184
|
+
return [];
|
|
185
|
+
return [
|
|
186
|
+
'--no-extensions',
|
|
187
|
+
...this.extensions.flatMap((extension) => ['-e', shellQuote(extension)]),
|
|
188
|
+
];
|
|
189
|
+
}
|
|
142
190
|
async getRunLog(worktreePath, run) {
|
|
143
191
|
// Primary: the relative --session-dir pinned at launch (per-run scoped
|
|
144
192
|
// when `run` is given), joined onto the worktree — the deterministic
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bakers-build/addon-pi",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.849",
|
|
4
4
|
"description": "bakers.build agent plugin for the pi coding CLI, with a real transcript footprint.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"directory": "bakers-cli/addons/pi"
|
|
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.849",
|
|
24
|
+
"@bakers-build/core": "^0.5.1-next.849"
|
|
25
25
|
},
|
|
26
26
|
"bakersBuild": {
|
|
27
|
-
"commit": "
|
|
27
|
+
"commit": "6405d5033ed2d034f264fc341db06ada455168a9",
|
|
28
28
|
"channel": "next"
|
|
29
29
|
}
|
|
30
30
|
}
|