@assuredloop/orca-bot-kit 0.26.1 → 0.28.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/README.md +68 -41
- package/SETUP.md +26 -13
- package/package.json +1 -1
- package/rules/mail.md +8 -8
- package/skills/obk-bot-building/SKILL.md +24 -15
- package/skills/obk-grooming/SKILL.md +4 -3
- package/src/book.js +143 -23
- package/src/bot.js +246 -118
- package/src/clear.js +7 -3
- package/src/cli.js +129 -130
- package/src/commands.js +21 -14
- package/src/conversations.js +73 -40
- package/src/groom.js +27 -9
- package/src/health.js +79 -11
- package/src/hooks.js +42 -64
- package/src/init.js +36 -29
- package/src/launch.js +221 -20
- package/src/message.js +83 -335
- package/src/name.js +1 -1
- package/src/orca-reload.applescript +1 -1
- package/src/orca-runtime.cjs +1 -1
- package/src/orca.js +35 -42
- package/src/permissions.js +30 -16
- package/src/pi.js +55 -0
- package/src/processes.js +392 -0
- package/src/retire.js +43 -40
- package/src/rules.js +5 -2
- package/src/skills.js +51 -35
- package/src/sources.js +73 -4
- package/src/temp.js +65 -20
- package/src/up.js +80 -14
- package/src/unread.js +0 -160
package/src/init.js
CHANGED
|
@@ -10,7 +10,7 @@ import { existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, statSync,
|
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
import { parseDocument } from 'yaml';
|
|
12
12
|
|
|
13
|
-
import { BOT_GITIGNORE, changesExactly, YAML_OUT } from './bot.js';
|
|
13
|
+
import { BOT_GITIGNORE, changesExactly, refuseOutside, withBotTurn, writeWhole, YAML_OUT } from './bot.js';
|
|
14
14
|
import { RECORD, SKILL_DIRS } from './skills.js';
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -266,6 +266,11 @@ function checkBotFather(file, harness) {
|
|
|
266
266
|
if (bot.sessions !== undefined && bot.sessions !== null && !Array.isArray(bot.sessions)) {
|
|
267
267
|
throw new Error(`${file} has a sessions entry that is not a list, so init cannot add Bot Father's daily session to it. Fix it, then run init again.`);
|
|
268
268
|
}
|
|
269
|
+
// One init would complete is refused here, before init writes anything, when a
|
|
270
|
+
// link takes it out of the bot folder (#569).
|
|
271
|
+
if (bot.harness === undefined || !Array.isArray(bot.sessions) || bot.sessions.length === 0) {
|
|
272
|
+
refuseOutside(path.dirname(file), file);
|
|
273
|
+
}
|
|
269
274
|
}
|
|
270
275
|
|
|
271
276
|
/**
|
|
@@ -281,35 +286,37 @@ function checkBotFather(file, harness) {
|
|
|
281
286
|
* are theirs, and `up` brings up what it finds.
|
|
282
287
|
*/
|
|
283
288
|
function completeBotFather(file, harness) {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
289
|
+
return withBotTurn(path.dirname(file), () => {
|
|
290
|
+
const source = readFileSync(file, 'utf8');
|
|
291
|
+
const doc = parseDocument(source);
|
|
292
|
+
|
|
293
|
+
// What is missing is settled from the document, not from the text it is
|
|
294
|
+
// written back as: a file that needs nothing is not rewritten, however the
|
|
295
|
+
// library would have laid it out.
|
|
296
|
+
const sessions = doc.get('sessions', true);
|
|
297
|
+
const needsSession = sessions?.items === undefined || sessions.items.length === 0;
|
|
298
|
+
const needsHarness = doc.get('harness') === undefined;
|
|
299
|
+
if (!needsSession && !needsHarness) return [];
|
|
300
|
+
|
|
301
|
+
if (sessions?.items === undefined) {
|
|
302
|
+
doc.set('sessions', [{ name: DAILY_SESSION }]);
|
|
303
|
+
} else if (needsSession) {
|
|
304
|
+
sessions.flow = false;
|
|
305
|
+
doc.addIn(['sessions'], { name: DAILY_SESSION });
|
|
306
|
+
}
|
|
307
|
+
if (needsHarness) doc.set('harness', harness);
|
|
302
308
|
|
|
303
|
-
|
|
309
|
+
const text = doc.toString(YAML_OUT);
|
|
304
310
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
311
|
+
if (!changesExactly(source, text, (was) => ({
|
|
312
|
+
...was,
|
|
313
|
+
harness: was.harness ?? harness,
|
|
314
|
+
sessions: was.sessions?.length > 0 ? was.sessions : [{ name: DAILY_SESSION }],
|
|
315
|
+
}))) {
|
|
316
|
+
throw new Error(`${file} cannot be completed without changing something else in it, so nothing was written. Give it a harness and a session by hand, then run init again.`);
|
|
317
|
+
}
|
|
312
318
|
|
|
313
|
-
|
|
314
|
-
|
|
319
|
+
writeWhole(file, text);
|
|
320
|
+
return [BOT_FATHER_YAML];
|
|
321
|
+
});
|
|
315
322
|
}
|
package/src/launch.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// the harness up and carries the session's start prompt with it.
|
|
3
3
|
//
|
|
4
4
|
// The flag mapping is PRD 6.4 and ADR 0015, re-checked against the installed
|
|
5
|
-
// CLIs (Claude Code 2.1.278, Codex 0.155.1). Every session is given its
|
|
5
|
+
// CLIs (Claude Code 2.1.278, Codex 0.155.1, Pi 1.1.0). Every session is given its
|
|
6
6
|
// approval level explicitly, so a user's own global harness defaults cannot
|
|
7
7
|
// leak into a bot. The kit names no model: a session that sets none gets the
|
|
8
8
|
// harness's own.
|
|
@@ -27,6 +27,11 @@ const APPROVAL = {
|
|
|
27
27
|
ask: ['-a', 'on-request'],
|
|
28
28
|
'dangerously-skip': ['--dangerously-bypass-approvals-and-sandbox'],
|
|
29
29
|
},
|
|
30
|
+
// Pi asks before no tool call and has no rule for each command, so it has
|
|
31
|
+
// one level, and no flag for it (the owner, #547).
|
|
32
|
+
pi: {
|
|
33
|
+
'dangerously-skip': [],
|
|
34
|
+
},
|
|
30
35
|
};
|
|
31
36
|
|
|
32
37
|
export const APPROVALS = Object.keys(APPROVAL.claude);
|
|
@@ -44,39 +49,186 @@ export const HARNESSES = Object.keys(APPROVAL);
|
|
|
44
49
|
export const approvalRank = (level) => ['ask', 'auto', 'dangerously-skip'].indexOf(level);
|
|
45
50
|
|
|
46
51
|
/**
|
|
47
|
-
* The harness flags that set approval or permissions,
|
|
48
|
-
* `obk permission approval` may change, not an
|
|
49
|
-
* Codex's
|
|
52
|
+
* The harness flags that set approval or permissions, or widen what a session
|
|
53
|
+
* may write or run, which only `obk permission approval` may change, not an
|
|
54
|
+
* extra argument (ADR 0051, ADR 0049). Codex's short flags take their value
|
|
55
|
+
* glued on too. Pi's `--approve` and `-a` make it trust the folder's own
|
|
56
|
+
* files, which the kit's `--no-approve` keeps it from (#578).
|
|
50
57
|
*/
|
|
51
58
|
const APPROVAL_FLAGS = {
|
|
52
|
-
claude: [
|
|
53
|
-
|
|
59
|
+
claude: [
|
|
60
|
+
'--permission-mode', '--dangerously-skip-permissions', '--allow-dangerously-skip-permissions', '--allowedTools', '--allowed-tools',
|
|
61
|
+
'--add-dir', '--settings', '--setting-sources', '--plugin-dir', '--plugin-url', '--mcp-config', '--agents', '--agent', '--debug-file', '--bare', '--restricted',
|
|
62
|
+
],
|
|
63
|
+
codex: [
|
|
64
|
+
'-a', '--ask-for-approval', '--approve-for-me', '--dangerously-bypass-approvals-and-sandbox', '-s', '--sandbox',
|
|
65
|
+
'--add-dir', '-C', '--cd', '-p', '--profile', '--enable', '--disable', '--remote', '--remote-auth-token-env',
|
|
66
|
+
],
|
|
67
|
+
pi: ['--approve', '-a'],
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The Codex `-c` keys an extra argument may set, with any value or with only
|
|
72
|
+
* the values named. Every other key is refused: Codex 0.163.0's config has
|
|
73
|
+
* dozens that widen a session, and more in each release (ADR 0049).
|
|
74
|
+
*/
|
|
75
|
+
const CONFIG_KEYS = {
|
|
76
|
+
model: true,
|
|
77
|
+
model_reasoning_effort: true,
|
|
78
|
+
model_reasoning_summary: true,
|
|
79
|
+
model_verbosity: true,
|
|
80
|
+
model_context_window: true,
|
|
81
|
+
model_auto_compact_token_limit: true,
|
|
82
|
+
plan_mode_reasoning_effort: true,
|
|
83
|
+
service_tier: true,
|
|
84
|
+
hide_agent_reasoning: true,
|
|
85
|
+
show_raw_agent_reasoning: true,
|
|
86
|
+
tool_output_token_limit: true,
|
|
87
|
+
'tui.animations': true,
|
|
88
|
+
'tui.show_tooltips': true,
|
|
89
|
+
'tui.notifications': true,
|
|
90
|
+
'tui.notification_method': true,
|
|
91
|
+
'tui.notification_condition': true,
|
|
92
|
+
'tui.alternate_screen': true,
|
|
93
|
+
'tui.theme': true,
|
|
94
|
+
'tui.vim_mode_default': true,
|
|
95
|
+
'tui.status_line': true,
|
|
96
|
+
'tui.terminal_title': true,
|
|
97
|
+
'tui.raw_output_mode': true,
|
|
98
|
+
'tui.disable_paste_burst': true,
|
|
99
|
+
'tui.fullscreen_transcript': true,
|
|
100
|
+
'tui.mouse_scroll_speed': true,
|
|
101
|
+
'tui.show_server_version_notice': true,
|
|
102
|
+
// The network the kit turns on, which a user may turn off (NETWORK_ACCESS).
|
|
103
|
+
'sandbox_workspace_write.network_access': ['true', 'false'],
|
|
104
|
+
// These only narrow: `false` is Codex's default.
|
|
105
|
+
'sandbox_workspace_write.exclude_tmpdir_env_var': ['true', 'false'],
|
|
106
|
+
'sandbox_workspace_write.exclude_slash_tmp': ['true', 'false'],
|
|
107
|
+
'features.sleep_tool': ['false'],
|
|
108
|
+
// No update check at start, so no update offer (#581).
|
|
109
|
+
check_for_update_on_startup: ['false'],
|
|
54
110
|
};
|
|
55
111
|
|
|
112
|
+
/**
|
|
113
|
+
* The one trust a `-c` may give: one folder, an absolute path in a TOML basic
|
|
114
|
+
* string, trusted. It is what the kit's own answer to Codex's trust screen
|
|
115
|
+
* gives, for that run only and with nothing written to config.toml (ADR 0049).
|
|
116
|
+
*/
|
|
117
|
+
const TRUST = /^\{[ \t]*"([^"\\\x00-\x1f\x7f]*)"[ \t]*=[ \t]*\{[ \t]*trust_level[ \t]*=[ \t]*"trusted"[ \t]*\}[ \t]*\}$/;
|
|
118
|
+
|
|
119
|
+
/** Whether a Codex `-c` value, `key=value`, sets only what an extra argument may. */
|
|
120
|
+
function allowedConfig(setting) {
|
|
121
|
+
const at = setting.indexOf('=');
|
|
122
|
+
if (at === -1) return false;
|
|
123
|
+
const key = setting.slice(0, at).trim();
|
|
124
|
+
const value = setting.slice(at + 1).trim();
|
|
125
|
+
if (key === 'projects') {
|
|
126
|
+
const folder = TRUST.exec(value)?.[1];
|
|
127
|
+
return folder !== undefined && folder.startsWith('/') && !folder.split('/').includes('..');
|
|
128
|
+
}
|
|
129
|
+
if (!/^[A-Za-z0-9_-]+(\.[A-Za-z0-9_-]+)*$/.test(key) || !Object.hasOwn(CONFIG_KEYS, key)) return false;
|
|
130
|
+
return CONFIG_KEYS[key] === true || CONFIG_KEYS[key].includes(value);
|
|
131
|
+
}
|
|
132
|
+
|
|
56
133
|
/**
|
|
57
134
|
* Refuse extra arguments that set a session's approval or permissions on
|
|
58
|
-
* `harness`,
|
|
135
|
+
* `harness`, or widen what it may write or run, before anything is written,
|
|
136
|
+
* naming the command that does it (ADR 0051, ADR 0049).
|
|
137
|
+
* `args` is a list, or, as a user may write `extra_args` by hand, one string
|
|
138
|
+
* of shell text. The kit types such a string into the tab's shell as it
|
|
139
|
+
* stands, so the guard takes it only when it can be sure of the words the
|
|
140
|
+
* shell makes of it, and refuses it otherwise (#565).
|
|
59
141
|
*/
|
|
60
142
|
export function refuseApprovalArgs(harness, args) {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
143
|
+
const words = Array.isArray(args) ? args.map(String) : set(args) ? sureWords(String(args)) : [];
|
|
144
|
+
if (words === undefined) {
|
|
145
|
+
throw new Error(`extra_args is written as one string, ${quoted(String(args))}, with shell syntax the kit cannot be sure of the words of, so it cannot tell whether it sets the session's approval or permissions. Write extra_args as a list, one --extra-arg for each argument. Nothing was changed.`);
|
|
146
|
+
}
|
|
147
|
+
for (let at = 0; at < words.length; at += 1) {
|
|
148
|
+
const arg = words[at];
|
|
149
|
+
if ((APPROVAL_FLAGS[harness] ?? []).some((flag) => arg === flag
|
|
150
|
+
|| arg.startsWith(`${flag}=`)
|
|
151
|
+
|| (/^-[asCp]$/.test(flag) && arg.startsWith(flag) && !arg.startsWith('--')))) {
|
|
152
|
+
throw new Error(`--extra-arg=${arg} sets the session's approval or permissions on ${harness}, or widens what it may write or run, and only obk permission approval changes those, after the user's yes. Nothing was changed.`);
|
|
153
|
+
}
|
|
154
|
+
// Codex's config override: the value is the next word, or after `=`, or glued on.
|
|
155
|
+
const setting = harness !== 'codex' ? undefined
|
|
156
|
+
: arg === '-c' || arg === '--config' ? (at += 1, words[at] ?? '')
|
|
157
|
+
: arg.startsWith('--config=') ? arg.slice('--config='.length)
|
|
158
|
+
: arg.startsWith('-c') && !arg.startsWith('--') ? arg.slice(2).replace(/^=/, '')
|
|
159
|
+
: undefined;
|
|
160
|
+
if (setting !== undefined && !allowedConfig(setting)) {
|
|
161
|
+
throw new Error(`--extra-arg=-c ${setting} sets a Codex setting that an extra argument may not set: the kit takes -c only for the model, the display, the network switch and a few settings that narrow (ADR 0049). Set the others in your own ~/.codex/config.toml; the session's approval and sandbox change only through obk permission approval, after the user's yes. Nothing was changed.`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The words of the shell text `text`, when the kit can be sure they are the
|
|
168
|
+
* ones the tab's shell makes of it, and undefined when it cannot (#565). Sure
|
|
169
|
+
* means plain words of the characters `quoted` leaves bare, separated by
|
|
170
|
+
* spaces, with no unquoted `=` before any other character of its word, empty
|
|
171
|
+
* quotes included (zsh's equals expansion makes `''=sh` into /bin/sh); single quotes with no
|
|
172
|
+
* backslash (fish reads `\'` and `\\` there) and no control character; and
|
|
173
|
+
* double quotes with none of `$`, backquote, backslash or `!`, and no control
|
|
174
|
+
* character. Read so, it is the same words in zsh, bash and fish. Everything
|
|
175
|
+
* else, a newline or a tab included, is shell syntax this does not read.
|
|
176
|
+
*/
|
|
177
|
+
function sureWords(text) {
|
|
178
|
+
const words = [];
|
|
179
|
+
let word;
|
|
180
|
+
let quote;
|
|
181
|
+
for (const char of text) {
|
|
182
|
+
if (/[\x00-\x1f\x7f]/.test(char)) return undefined;
|
|
183
|
+
if (quote === "'") {
|
|
184
|
+
if (char === '\\') return undefined;
|
|
185
|
+
if (char === "'") quote = undefined;
|
|
186
|
+
else word += char;
|
|
187
|
+
} else if (quote === '"') {
|
|
188
|
+
if ('$`\\!'.includes(char)) return undefined;
|
|
189
|
+
if (char === '"') quote = undefined;
|
|
190
|
+
else word += char;
|
|
191
|
+
} else if (char === ' ') {
|
|
192
|
+
if (word !== undefined) words.push(word);
|
|
193
|
+
word = undefined;
|
|
194
|
+
} else if (char === "'" || char === '"') {
|
|
195
|
+
word ??= '';
|
|
196
|
+
quote = char;
|
|
197
|
+
} else if (/^[A-Za-z0-9,._+:@%/=-]$/.test(char) && !(char === '=' && !word)) {
|
|
198
|
+
word = (word ?? '') + char;
|
|
199
|
+
} else {
|
|
200
|
+
return undefined;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (quote !== undefined) return undefined;
|
|
204
|
+
if (word !== undefined) words.push(word);
|
|
205
|
+
return words;
|
|
66
206
|
}
|
|
67
207
|
|
|
68
208
|
/** The level a session that names none runs at (ADR 0015). */
|
|
69
209
|
export const DEFAULT_APPROVAL = 'auto';
|
|
70
210
|
|
|
211
|
+
/** The level a session on `harness` is written with when it names none: Pi has only one (#547). */
|
|
212
|
+
export const defaultApproval = (harness) => (harness === 'pi' ? 'dangerously-skip' : DEFAULT_APPROVAL);
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Why a level is refused on Pi, or undefined when it is taken there. The
|
|
216
|
+
* owner's decision (#547): every Pi session counts as dangerously-skip.
|
|
217
|
+
*/
|
|
218
|
+
export function piApprovalTrouble(level, who = 'this session') {
|
|
219
|
+
if (!set(level) || level === 'dangerously-skip') return undefined;
|
|
220
|
+
return `${who} runs on Pi and is set to approval ${level}. Pi has no approval prompt and no permission rules, so every Pi session runs as dangerously-skip (the owner's decision, #547); auto and ask are refused on Pi. Set it to dangerously-skip, or run the session on claude or codex.`;
|
|
221
|
+
}
|
|
222
|
+
|
|
71
223
|
/** A setting the user left out. An empty string is one too: it means the harness's own. */
|
|
72
|
-
const set = (value) => value !== undefined && value !== null && String(value).trim() !== '';
|
|
224
|
+
export const set = (value) => value !== undefined && value !== null && String(value).trim() !== '';
|
|
73
225
|
|
|
74
226
|
/** Which harness a session runs on: its own, or the bot's. */
|
|
75
227
|
export const harnessOf = (session, botHarness) => (set(session.harness) ? session.harness : botHarness);
|
|
76
228
|
|
|
77
229
|
/**
|
|
78
230
|
* A session's name on Claude Code, which is also the address another Claude
|
|
79
|
-
* session writes to (ADR
|
|
231
|
+
* session writes to (ADR 0042). It goes on the launch line as `-n`, and it is
|
|
80
232
|
* re-applied every time the session is started: a resume keeps the name by
|
|
81
233
|
* itself (tech notes, section 2), and the kit does not depend on that.
|
|
82
234
|
*
|
|
@@ -201,6 +353,22 @@ export function sessionTrouble(session, harness, home) {
|
|
|
201
353
|
if (set(session.approval) && !APPROVALS.includes(session.approval)) {
|
|
202
354
|
return `${where(session)} is set to approval ${session.approval}, and the levels are ${APPROVALS.join(', ')}.`;
|
|
203
355
|
}
|
|
356
|
+
if (harness === 'pi') {
|
|
357
|
+
const trouble = piApprovalTrouble(session.approval, where(session));
|
|
358
|
+
if (trouble !== undefined) return trouble;
|
|
359
|
+
// Pi has no context setting: a model's own name carries it, as in
|
|
360
|
+
// cursor/claude-opus-5-5@1m (tech notes, section 6).
|
|
361
|
+
if (set(session.context)) {
|
|
362
|
+
return `${where(session)} sets a context of ${session.context} on Pi, and Pi has no context setting: the model's name carries it, as in cursor/claude-opus-5-5@1m. Name such a model, or leave the context out.`;
|
|
363
|
+
}
|
|
364
|
+
// Pi 1.1.0 reads a word after `--` that starts with `@` as a file to
|
|
365
|
+
// attach, and has no escape for it, so such a prompt cannot arrive as
|
|
366
|
+
// written (tech notes, section 6). It is checked trimmed, as it is sent.
|
|
367
|
+
const said = set(session.prompt_file) ? readFileSync(promptFile(session, home), 'utf8') : session.prompt;
|
|
368
|
+
if (set(said) && String(said).trim().startsWith('@')) {
|
|
369
|
+
return `${where(session)} runs on Pi, and its prompt begins with @. Pi would read the prompt as a file to attach, not as text. Give it a prompt that does not begin with @.`;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
204
372
|
// Codex is given the context window as a number of tokens. `1m` is what a
|
|
205
373
|
// Claude session would say, and copying it here does not fail at the kit but
|
|
206
374
|
// in Codex, which exits with a type error the moment it starts.
|
|
@@ -231,16 +399,21 @@ const where = (session) => (set(session.name) ? `session ${session.name}` : 'thi
|
|
|
231
399
|
* send would land on that list and answer it. A prompt given as an argument is
|
|
232
400
|
* held by the harness until it is ready for it (tech notes, section 1).
|
|
233
401
|
*/
|
|
234
|
-
export function launchCommand(session, { harness, home, workDir, prompt, promptFile: fromFile, resume, address }) {
|
|
402
|
+
export function launchCommand(session, { harness, home, workDir, prompt, promptFile: fromFile, resume, address, kit, sessionId, name }) {
|
|
235
403
|
const trouble = sessionTrouble(session, harness, home);
|
|
236
404
|
if (trouble !== undefined) throw new Error(trouble);
|
|
405
|
+
// Pi is told which conversation it is, a new one too: the kit names it, and
|
|
406
|
+
// that is how the book knows it (tech notes, section 6).
|
|
407
|
+
if (harness === 'pi' && resume === undefined && sessionId === undefined) {
|
|
408
|
+
throw new Error(`${where(session)} runs on Pi, and a Pi session is started with the id the book gives it, so the kit names one before it launches. None was given.`);
|
|
409
|
+
}
|
|
237
410
|
|
|
238
411
|
const words = [harness];
|
|
239
412
|
// Codex resumes through a subcommand, which has to come first; Claude Code
|
|
240
413
|
// resumes through a flag, which goes with the session id at the end. Both
|
|
241
414
|
// take every other flag exactly as a fresh session does.
|
|
242
415
|
if (resume !== undefined && harness === 'codex') words.push('resume');
|
|
243
|
-
words.push(...APPROVAL[harness][set(session.approval) ? session.approval :
|
|
416
|
+
words.push(...APPROVAL[harness][set(session.approval) ? session.approval : defaultApproval(harness)]);
|
|
244
417
|
// Codex 0.157 shares one background server between sessions by default, and
|
|
245
418
|
// a resume through it was seen to fail; without it Codex runs as 0.156 did
|
|
246
419
|
// (tech notes, section 3, #330). Codex refuses the flag twice, so the user's
|
|
@@ -249,11 +422,21 @@ export function launchCommand(session, { harness, home, workDir, prompt, promptF
|
|
|
249
422
|
|
|
250
423
|
if (harness === 'claude') {
|
|
251
424
|
// The name is the address other Claude sessions write to, so it goes on
|
|
252
|
-
// every launch line, a resume included (ADR
|
|
425
|
+
// every launch line, a resume included (ADR 0042).
|
|
253
426
|
if (address !== undefined) words.push('-n', address);
|
|
254
427
|
// The context window rides on the model name: `sonnet[1m]`.
|
|
255
428
|
if (set(session.model)) words.push('--model', set(session.context) ? `${session.model}[${session.context}]` : session.model);
|
|
256
429
|
if (set(session.effort)) words.push('--effort', String(session.effort));
|
|
430
|
+
} else if (harness === 'pi') {
|
|
431
|
+
// Pi trusts none of the folder's own files (`.pi/`, `.agents/skills`), so it
|
|
432
|
+
// shows no trust screen and runs nothing the kit has not looked at (#578).
|
|
433
|
+
words.push('--no-approve');
|
|
434
|
+
// The id the book holds, resumed or new: Pi opens the conversation with it,
|
|
435
|
+
// and makes it when there is none (tech notes, section 6).
|
|
436
|
+
words.push('--session-id', resume ?? sessionId);
|
|
437
|
+
if (name !== undefined) words.push('--name', name);
|
|
438
|
+
if (set(session.model)) words.push('--model', session.model);
|
|
439
|
+
if (set(session.effort)) words.push('--thinking', String(session.effort));
|
|
257
440
|
} else {
|
|
258
441
|
// Without this the Orca CLI cannot reach Orca from inside the sandbox, so
|
|
259
442
|
// the session is in no fleet at all. The user's own setting of it wins.
|
|
@@ -265,6 +448,10 @@ export function launchCommand(session, { harness, home, workDir, prompt, promptF
|
|
|
265
448
|
// started in, and nowhere else (ADR 0015), so a work dir outside the bot
|
|
266
449
|
// home has to be named.
|
|
267
450
|
if (workDir !== undefined && !inside(home, workDir)) words.push('--add-dir', workDir);
|
|
451
|
+
// And the kit's own folders for this bot beside the bots folder: its long
|
|
452
|
+
// message bodies, its start prompts and its locks (#534). The bot's, and no
|
|
453
|
+
// other bot's: a session never gets to write another bot's mail.
|
|
454
|
+
if (kit !== undefined) for (const folder of Object.values(kit)) words.push('--add-dir', folder);
|
|
268
455
|
}
|
|
269
456
|
|
|
270
457
|
return [
|
|
@@ -309,7 +496,7 @@ export function startPrompt(session, { home, workDir }) {
|
|
|
309
496
|
}
|
|
310
497
|
|
|
311
498
|
/** Where a session's prompt file is: in the bot home, where the user put it. */
|
|
312
|
-
export const promptFile = (session, home) => path.resolve(home, session.prompt_file);
|
|
499
|
+
export const promptFile = (session, home) => path.resolve(home, String(session.prompt_file));
|
|
313
500
|
|
|
314
501
|
/**
|
|
315
502
|
* A prompt short and simple enough to type into the launch line as it is: one
|
|
@@ -332,13 +519,27 @@ function promptWords(prompt, fromFile) {
|
|
|
332
519
|
|
|
333
520
|
/**
|
|
334
521
|
* The session the harness is told to pick up again, when there is one: a flag
|
|
335
|
-
* on Claude Code, the argument of the `resume` subcommand on Codex.
|
|
522
|
+
* on Claude Code, the argument of the `resume` subcommand on Codex. Pi's is
|
|
523
|
+
* its `--session-id`, which goes with its other flags.
|
|
336
524
|
*/
|
|
337
525
|
const resumeWords = (harness, resume) => {
|
|
338
|
-
if (resume === undefined) return [];
|
|
526
|
+
if (resume === undefined || harness === 'pi') return [];
|
|
339
527
|
return harness === 'claude' ? ['--resume', quoted(resume)] : [quoted(resume)];
|
|
340
528
|
};
|
|
341
529
|
|
|
530
|
+
/**
|
|
531
|
+
* The kit's own folders for one bot, beside the bots folder: `messages` for
|
|
532
|
+
* the bodies of its long fleet mail, `prompts` for its sessions' start
|
|
533
|
+
* prompts, `locks` for its book's and its sessions' turns. Each is a folder of
|
|
534
|
+
* the bot's own, so that a Codex session, whose sandbox writes only where its
|
|
535
|
+
* launch line says, can be given its bot's and no other's (#534).
|
|
536
|
+
*/
|
|
537
|
+
export const kitFolders = (bots, bot) => ({
|
|
538
|
+
messages: path.join(`${bots}.messages`, bot),
|
|
539
|
+
prompts: path.join(`${bots}.prompts`, bot),
|
|
540
|
+
locks: path.join(`${bots}.locks`, bot),
|
|
541
|
+
});
|
|
542
|
+
|
|
342
543
|
/** Whether `target` is the folder at `home` or something inside it. */
|
|
343
544
|
const inside = (home, target) => target === home || target.startsWith(home + path.sep);
|
|
344
545
|
|