@proletariat/cli 0.3.69 → 0.3.70

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.
Files changed (53) hide show
  1. package/dist/commands/session/health.d.ts +11 -0
  2. package/dist/commands/session/health.js +1 -1
  3. package/dist/commands/session/health.js.map +1 -1
  4. package/dist/lib/execution/runners/cloud.d.ts +16 -0
  5. package/dist/lib/execution/runners/cloud.js +88 -0
  6. package/dist/lib/execution/runners/cloud.js.map +1 -0
  7. package/dist/lib/execution/runners/devcontainer-terminal.d.ts +13 -0
  8. package/dist/lib/execution/runners/devcontainer-terminal.js +184 -0
  9. package/dist/lib/execution/runners/devcontainer-terminal.js.map +1 -0
  10. package/dist/lib/execution/runners/devcontainer-tmux.d.ts +16 -0
  11. package/dist/lib/execution/runners/devcontainer-tmux.js +270 -0
  12. package/dist/lib/execution/runners/devcontainer-tmux.js.map +1 -0
  13. package/dist/lib/execution/runners/devcontainer.d.ts +19 -0
  14. package/dist/lib/execution/runners/devcontainer.js +261 -0
  15. package/dist/lib/execution/runners/devcontainer.js.map +1 -0
  16. package/dist/lib/execution/runners/docker-credentials.d.ts +51 -0
  17. package/dist/lib/execution/runners/docker-credentials.js +175 -0
  18. package/dist/lib/execution/runners/docker-credentials.js.map +1 -0
  19. package/dist/lib/execution/runners/docker-management.d.ts +49 -0
  20. package/dist/lib/execution/runners/docker-management.js +300 -0
  21. package/dist/lib/execution/runners/docker-management.js.map +1 -0
  22. package/dist/lib/execution/runners/docker.d.ts +13 -0
  23. package/dist/lib/execution/runners/docker.js +75 -0
  24. package/dist/lib/execution/runners/docker.js.map +1 -0
  25. package/dist/lib/execution/runners/executor.d.ts +41 -0
  26. package/dist/lib/execution/runners/executor.js +108 -0
  27. package/dist/lib/execution/runners/executor.js.map +1 -0
  28. package/dist/lib/execution/runners/host.d.ts +14 -0
  29. package/dist/lib/execution/runners/host.js +437 -0
  30. package/dist/lib/execution/runners/host.js.map +1 -0
  31. package/dist/lib/execution/runners/index.d.ts +29 -0
  32. package/dist/lib/execution/runners/index.js +79 -0
  33. package/dist/lib/execution/runners/index.js.map +1 -0
  34. package/dist/lib/execution/runners/orchestrator.d.ts +30 -0
  35. package/dist/lib/execution/runners/orchestrator.js +332 -0
  36. package/dist/lib/execution/runners/orchestrator.js.map +1 -0
  37. package/dist/lib/execution/runners/prompt-builder.d.ts +12 -0
  38. package/dist/lib/execution/runners/prompt-builder.js +337 -0
  39. package/dist/lib/execution/runners/prompt-builder.js.map +1 -0
  40. package/dist/lib/execution/runners/sandbox.d.ts +34 -0
  41. package/dist/lib/execution/runners/sandbox.js +108 -0
  42. package/dist/lib/execution/runners/sandbox.js.map +1 -0
  43. package/dist/lib/execution/runners/shared.d.ts +62 -0
  44. package/dist/lib/execution/runners/shared.js +141 -0
  45. package/dist/lib/execution/runners/shared.js.map +1 -0
  46. package/dist/lib/execution/runners.d.ts +12 -272
  47. package/dist/lib/execution/runners.js +12 -3200
  48. package/dist/lib/execution/runners.js.map +1 -1
  49. package/dist/lib/external-issues/outbound-sync.d.ts +15 -0
  50. package/dist/lib/external-issues/outbound-sync.js +11 -1
  51. package/dist/lib/external-issues/outbound-sync.js.map +1 -1
  52. package/oclif.manifest.json +1426 -1426
  53. package/package.json +1 -1
@@ -0,0 +1,337 @@
1
+ /**
2
+ * Prompt Builder
3
+ *
4
+ * Functions for building agent prompts including:
5
+ * - Integration commands for connected services
6
+ * - Orchestrator prompt (system prompt + user message)
7
+ * - Ticket prompt (action + ticket content + completion instructions)
8
+ */
9
+ import * as fs from 'node:fs';
10
+ import * as path from 'node:path';
11
+ import { fileURLToPath } from 'node:url';
12
+ import { resolveToolsForSpawn } from '../../tool-registry/index.js';
13
+ import { getHostPrltVersion } from './docker-management.js';
14
+ const INTEGRATION_COMMANDS = [
15
+ {
16
+ provider: 'asana',
17
+ displayName: 'Asana',
18
+ commands: [
19
+ 'prlt asana connect — authenticate with Asana',
20
+ 'prlt asana sync --ticket TKT-XXX --create-missing --project <gid> — sync a PMO ticket to Asana',
21
+ 'prlt asana import — import Asana tasks into PMO',
22
+ ],
23
+ },
24
+ {
25
+ provider: 'linear',
26
+ displayName: 'Linear',
27
+ commands: [
28
+ 'prlt linear connect — authenticate with Linear',
29
+ 'prlt linear sync --ticket TKT-XXX --create-missing — sync a PMO ticket to Linear',
30
+ 'prlt linear import — import Linear issues into PMO',
31
+ ],
32
+ },
33
+ {
34
+ provider: 'jira',
35
+ displayName: 'Jira',
36
+ commands: [
37
+ 'prlt jira connect — authenticate with Jira',
38
+ 'prlt jira sync --ticket TKT-XXX --create-missing — sync a PMO ticket to Jira',
39
+ 'prlt jira import — import Jira issues into PMO',
40
+ ],
41
+ },
42
+ {
43
+ provider: 'shortcut',
44
+ displayName: 'Shortcut',
45
+ commands: [
46
+ 'prlt shortcut connect — authenticate with Shortcut',
47
+ 'prlt shortcut sync --ticket TKT-XXX --create-missing — sync a PMO ticket to Shortcut',
48
+ 'prlt shortcut import — import Shortcut stories into PMO',
49
+ ],
50
+ },
51
+ {
52
+ provider: 'monday',
53
+ displayName: 'Monday.com',
54
+ commands: [
55
+ 'prlt monday connect — authenticate with Monday.com',
56
+ 'prlt monday sync --ticket TKT-XXX --create-missing — sync a PMO ticket to Monday.com',
57
+ ],
58
+ },
59
+ ];
60
+ export function buildIntegrationCommandsSection(connectedIntegrations) {
61
+ if (!connectedIntegrations || connectedIntegrations.length === 0)
62
+ return '';
63
+ const connected = INTEGRATION_COMMANDS.filter(ic => connectedIntegrations.includes(ic.provider));
64
+ if (connected.length === 0)
65
+ return '';
66
+ let section = `## Integration Commands\n\n`;
67
+ section += `The following external integrations are connected. Use these prlt commands to interact with them.\n\n`;
68
+ for (const integration of connected) {
69
+ section += `### ${integration.displayName}\n`;
70
+ for (const cmd of integration.commands) {
71
+ section += `- \`${cmd.split(' — ')[0]}\` — ${cmd.split(' — ')[1] || ''}\n`;
72
+ }
73
+ section += '\n';
74
+ }
75
+ section += `**ANTI-PATTERN:** Never use curl, raw API calls, or shell scripts to interact with external services (Asana, Linear, Jira, Shortcut, Monday.com, etc.). Always use the corresponding \`prlt\` commands.\n\n`;
76
+ return section;
77
+ }
78
+ const ORCHESTRATOR_COMMAND_REGISTRY = [
79
+ {
80
+ title: 'Agent Lifecycle',
81
+ commands: [
82
+ { cmd: 'prlt work start <ticket> --ephemeral --skip-permissions --create-pr --display background --action implement --run-on-host --yes', desc: 'Spawn an agent for a ticket', checkPath: 'work/start' },
83
+ { cmd: 'prlt session list', desc: 'List running sessions', checkPath: 'session/list' },
84
+ { cmd: 'prlt session inspect <agent>', desc: 'Inspect session details', checkPath: 'session/inspect' },
85
+ { cmd: 'prlt session poke <agent> \'message\'', desc: 'Send message to agent', checkPath: 'session/poke' },
86
+ { cmd: 'prlt session peek <agent> --lines 200', desc: 'Read agent output', checkPath: 'session/peek' },
87
+ { cmd: 'prlt session health', desc: 'Check health of all sessions', checkPath: 'session/health' },
88
+ { cmd: 'prlt session restart <agent>', desc: 'Restart a stuck agent', checkPath: 'session/restart' },
89
+ { cmd: 'prlt session exec <agent> -- git status', desc: 'Run command in agent context', checkPath: 'session/exec' },
90
+ { cmd: 'prlt session prune', desc: 'Clean up dead sessions', checkPath: 'session/prune' },
91
+ ],
92
+ },
93
+ {
94
+ title: 'Board Management',
95
+ commands: [
96
+ { cmd: 'prlt board view', desc: 'View the board', checkPath: 'board/view' },
97
+ { cmd: 'prlt ticket list', desc: 'List tickets', checkPath: 'ticket/list' },
98
+ { cmd: 'prlt ticket show <id>', desc: 'Show ticket details', checkPath: 'ticket/show' },
99
+ { cmd: 'prlt ticket create --title \'x\' --description \'y\'', desc: 'Create a ticket', checkPath: 'ticket/create' },
100
+ { cmd: 'prlt ticket edit <id> --title \'...\' --add-ac \'...\'', desc: 'Edit ticket fields', checkPath: 'ticket/edit' },
101
+ ],
102
+ },
103
+ {
104
+ title: 'PR Workflow',
105
+ commands: [
106
+ { cmd: 'gh pr list', desc: 'List open PRs' },
107
+ { cmd: 'gh pr view <num>', desc: 'View PR details' },
108
+ { cmd: 'gh pr checks <num>', desc: 'Check CI status' },
109
+ { cmd: 'gh pr merge <num> --squash', desc: 'Merge PR (squash only)' },
110
+ ],
111
+ },
112
+ ];
113
+ const ORCHESTRATOR_ANTI_PATTERNS = [
114
+ { bad: 'docker exec <container> ...', good: 'prlt session exec', checkPath: 'session/exec' },
115
+ { bad: 'tmux send-keys ...', good: 'prlt session poke', checkPath: 'session/poke' },
116
+ { bad: 'tmux capture-pane ...', good: 'prlt session peek', checkPath: 'session/peek' },
117
+ { bad: 'Direct git operations on agent worktrees', good: 'prlt session exec', checkPath: 'session/exec' },
118
+ ];
119
+ let _commandsDir = null;
120
+ function getCommandsDir() {
121
+ if (_commandsDir === null) {
122
+ const currentFile = fileURLToPath(import.meta.url);
123
+ // From dist/lib/execution/runners/prompt-builder.js → dist/commands/
124
+ _commandsDir = path.resolve(path.dirname(currentFile), '..', '..', '..', 'commands');
125
+ }
126
+ return _commandsDir;
127
+ }
128
+ function isCommandAvailable(checkPath) {
129
+ const dir = getCommandsDir();
130
+ return fs.existsSync(path.join(dir, `${checkPath}.js`)) || fs.existsSync(path.join(dir, checkPath));
131
+ }
132
+ function buildOrchestratorCommandReference() {
133
+ let ref = '';
134
+ for (const category of ORCHESTRATOR_COMMAND_REGISTRY) {
135
+ const available = category.commands.filter(c => !c.checkPath || isCommandAvailable(c.checkPath));
136
+ if (available.length === 0)
137
+ continue;
138
+ ref += `### ${category.title}\n`;
139
+ for (const cmd of available) {
140
+ ref += `- \`${cmd.cmd}\` — ${cmd.desc}\n`;
141
+ }
142
+ ref += '\n';
143
+ }
144
+ return ref;
145
+ }
146
+ function buildOrchestratorAntiPatterns() {
147
+ const available = ORCHESTRATOR_ANTI_PATTERNS.filter(ap => !ap.checkPath || isCommandAvailable(ap.checkPath));
148
+ if (available.length === 0)
149
+ return '';
150
+ let section = `## Anti-Patterns — NEVER DO\n\n`;
151
+ for (const ap of available) {
152
+ section += `- \`${ap.bad}\` → use \`${ap.good}\` instead\n`;
153
+ }
154
+ section += `\n`;
155
+ return section;
156
+ }
157
+ function buildOrchestratorBody(hqName, context) {
158
+ let prompt = '';
159
+ const prltVersion = getHostPrltVersion();
160
+ prompt += `## Environment\n`;
161
+ if (prltVersion) {
162
+ prompt += `- **prlt version**: ${prltVersion}\n`;
163
+ }
164
+ prompt += `- **Available executors**: claude-code, codex\n`;
165
+ prompt += `- **Agent worktrees**: \`agents/temp/<agent-name>/<repo>\` — each agent gets an isolated git worktree\n`;
166
+ if (context.hqPath) {
167
+ prompt += `- **HQ path**: \`${context.hqPath}\`\n`;
168
+ }
169
+ prompt += `\n`;
170
+ prompt += `## prlt Is Your Orchestration Runtime\n\n`;
171
+ prompt += `prlt is your orchestration runtime. NEVER use raw docker exec, tmux send-keys, or direct container access. `;
172
+ prompt += `All orchestration goes through prlt. Every agent interaction, session management, and board operation `;
173
+ prompt += `has a dedicated prlt command. Using raw infrastructure commands bypasses session tracking, breaks `;
174
+ prompt += `health monitoring, and creates orphaned processes.\n\n`;
175
+ prompt += `## Your Role\n`;
176
+ prompt += `- Assess the current state of the board, running agents, and open PRs\n`;
177
+ prompt += `- Plan and prioritize work — decide what to tackle next and in what order\n`;
178
+ prompt += `- Delegate implementation to agents via \`prlt work start\`\n`;
179
+ prompt += `- Monitor agent progress via sessions and review completed work\n`;
180
+ prompt += `- Review and merge completed PRs via \`gh pr merge --squash\`\n`;
181
+ prompt += `- Coordinate parallel agents — handle rebases after merges\n`;
182
+ prompt += `- Never write code or make changes to source files yourself\n\n`;
183
+ prompt += `## Command Reference\n\n`;
184
+ prompt += buildOrchestratorCommandReference();
185
+ prompt += `## Spawning Agents\n`;
186
+ prompt += `\`\`\`\n`;
187
+ prompt += `script -q /dev/null prlt work start TKT-XXXX --ephemeral --skip-permissions --create-pr --display background --action implement --run-on-host --yes\n`;
188
+ prompt += `\`\`\`\n`;
189
+ prompt += `- Review: \`--action review-comment\`\n`;
190
+ prompt += `- Fix: \`--action review-fix\`\n\n`;
191
+ prompt += buildOrchestratorAntiPatterns();
192
+ prompt += buildIntegrationCommandsSection(context.connectedIntegrations);
193
+ prompt += `## Workflow\n`;
194
+ prompt += `- Squash merge only: \`gh pr merge --squash\`\n`;
195
+ prompt += `- After merging: subsequent PRs from parallel agents will need rebase\n`;
196
+ prompt += `- Kill stale sessions after their PRs are merged\n\n`;
197
+ if (context.hqPath) {
198
+ const toolsResult = resolveToolsForSpawn(context.hqPath, context.toolPolicy, path.join(context.hqPath, '.proletariat', 'scripts'));
199
+ if (toolsResult.promptSection) {
200
+ prompt += toolsResult.promptSection;
201
+ }
202
+ }
203
+ if (context.hqPath) {
204
+ const contextFilePath = path.join(context.hqPath, '.orchestrator-context.md');
205
+ if (fs.existsSync(contextFilePath)) {
206
+ try {
207
+ const contextContent = fs.readFileSync(contextFilePath, 'utf-8').trim();
208
+ if (contextContent) {
209
+ prompt += `## Workspace Context\n\n${contextContent}\n\n`;
210
+ }
211
+ }
212
+ catch {
213
+ // Ignore read errors
214
+ }
215
+ }
216
+ }
217
+ return prompt;
218
+ }
219
+ export function buildOrchestratorSystemPrompt(context) {
220
+ const hqName = context.hqName || 'workspace';
221
+ let prompt = `# Orchestrator: ${hqName}\n\n`;
222
+ prompt += `You are the orchestrator for the **${hqName}** headquarters — a technical project manager driving software delivery through delegated AI agents.\n\n`;
223
+ prompt += `**prlt** is an AI agent orchestration CLI. It manages software development by coordinating autonomous coding agents that work in isolated git worktrees. `;
224
+ prompt += `Your workspace (HQ) contains a PMO board for tracking tickets, agent worktrees under \`agents/temp/\`, and repo connections. `;
225
+ prompt += `Agents are spawned to implement, review, and fix code — you never write code yourself. `;
226
+ prompt += `Your job is to assess the state of the project, plan and prioritize work, delegate to agents, monitor their progress, review results, and merge completed PRs.\n\n`;
227
+ prompt += buildOrchestratorBody(hqName, context);
228
+ return prompt;
229
+ }
230
+ function buildOrchestratorPrompt(context) {
231
+ const hqName = context.hqName || 'workspace';
232
+ let prompt = `# Orchestrator: ${hqName}\n\n`;
233
+ prompt += `You are the orchestrator for the **${hqName}** headquarters — a technical project manager driving software delivery through delegated AI agents.\n\n`;
234
+ prompt += `**prlt** is an AI agent orchestration CLI. It manages software development by coordinating autonomous coding agents that work in isolated git worktrees. `;
235
+ prompt += `Your workspace (HQ) contains a PMO board for tracking tickets, agent worktrees under \`agents/temp/\`, and repo connections. `;
236
+ prompt += `Agents are spawned to implement, review, and fix code — you never write code yourself.\n\n`;
237
+ prompt += buildOrchestratorBody(hqName, context);
238
+ if (context.actionPrompt) {
239
+ prompt += `## Instructions\n\n${context.actionPrompt}\n`;
240
+ }
241
+ return prompt;
242
+ }
243
+ export function buildPrompt(context) {
244
+ if (context.isOrchestrator) {
245
+ return buildOrchestratorPrompt(context);
246
+ }
247
+ let prompt = '';
248
+ if (context.isRevision && context.prFeedback) {
249
+ prompt += `# Revision: Address PR Feedback\n\n`;
250
+ prompt += context.prFeedback;
251
+ prompt += `\n\n---\n\n`;
252
+ prompt += `## Original Ticket Context\n\n`;
253
+ }
254
+ if (context.actionPrompt) {
255
+ prompt += `# Action: ${context.actionName || 'Work'}\n\n`;
256
+ prompt += context.actionPrompt;
257
+ prompt += `\n\n---\n\n`;
258
+ }
259
+ prompt += `# Ticket: ${context.ticketId}\n\n`;
260
+ prompt += `**Title:** ${context.ticketTitle}\n\n`;
261
+ if (context.ticketPriority) {
262
+ prompt += `**Priority:** ${context.ticketPriority}\n`;
263
+ }
264
+ if (context.ticketCategory) {
265
+ prompt += `**Category:** ${context.ticketCategory}\n`;
266
+ }
267
+ if (context.epicTitle) {
268
+ prompt += `**Epic:** ${context.epicTitle}\n`;
269
+ }
270
+ if (context.ticketDescription) {
271
+ prompt += `\n## Description\n\n${context.ticketDescription}\n`;
272
+ }
273
+ if (context.ticketSubtasks && context.ticketSubtasks.length > 0) {
274
+ prompt += `\n## Subtasks\n\n`;
275
+ for (const subtask of context.ticketSubtasks) {
276
+ const checkbox = subtask.done ? '[x]' : '[ ]';
277
+ prompt += `- ${checkbox} ${subtask.title}\n`;
278
+ }
279
+ }
280
+ const integrationSection = buildIntegrationCommandsSection(context.connectedIntegrations);
281
+ if (integrationSection) {
282
+ prompt += `\n${integrationSection}`;
283
+ }
284
+ if (context.customMessage) {
285
+ prompt += `\n## Additional Instructions\n\n${context.customMessage}\n`;
286
+ }
287
+ if (context.hqPath) {
288
+ const toolsResult = resolveToolsForSpawn(context.hqPath, context.toolPolicy, path.join(context.hqPath, '.proletariat', 'scripts'));
289
+ if (toolsResult.promptSection) {
290
+ prompt += `\n${toolsResult.promptSection}`;
291
+ }
292
+ }
293
+ prompt += `\n---\n\n## When Complete\n\n`;
294
+ if (context.isRevision) {
295
+ prompt += `After addressing the feedback:\n`;
296
+ prompt += `1. Commit your changes using \`prlt commit "your message"\`\n`;
297
+ prompt += `2. Push your changes: \`git push\`\n`;
298
+ prompt += `\nThe PR will be updated automatically.`;
299
+ }
300
+ else if (context.actionEndPrompt) {
301
+ let endPrompt = context.actionEndPrompt.replace(/\{\{TICKET_ID\}\}/g, context.ticketId);
302
+ if (endPrompt.includes('--pr')) {
303
+ if (!context.createPR) {
304
+ endPrompt = endPrompt.replace(/--pr/g, '--no-pr');
305
+ }
306
+ }
307
+ prompt += endPrompt;
308
+ }
309
+ else {
310
+ if (context.modifiesCode) {
311
+ prompt += `1. **Commit your work** in each repository directory you modified:\n`;
312
+ prompt += ` \`\`\`bash\n`;
313
+ prompt += ` cd /workspace/<repo-name>\n`;
314
+ prompt += ` git add -A\n`;
315
+ prompt += ` prlt commit "describe your change"\n`;
316
+ prompt += ` git push\n`;
317
+ prompt += ` \`\`\`\n`;
318
+ prompt += ` This formats your commit as a conventional commit with the ticket ID.\n`;
319
+ prompt += `\n2. **Mark work as ready** by running:\n`;
320
+ const prFlag = context.createPR ? ' --pr' : ' --no-pr';
321
+ prompt += ` \`\`\`bash\n prlt work ready ${context.ticketId}${prFlag}\n \`\`\`\n`;
322
+ if (context.createPR) {
323
+ prompt += ` This moves the ticket to review and creates a pull request.\n`;
324
+ }
325
+ else {
326
+ prompt += ` This moves the ticket to review.\n`;
327
+ }
328
+ prompt += `\n**IMPORTANT:** Use the global \`prlt\` command (just type \`prlt\`). Do NOT use \`./bin/run.js\` or any local path.`;
329
+ }
330
+ else {
331
+ prompt += `When you have completed the task, provide a summary of what you did.`;
332
+ }
333
+ }
334
+ prompt += `\n\n---\n\n**STOP:** After providing your final summary, your task is complete. Do not take any further actions, do not verify your work again, and do not continue the conversation. Simply output your summary and stop.`;
335
+ return prompt;
336
+ }
337
+ //# sourceMappingURL=prompt-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-builder.js","sourceRoot":"","sources":["../../../../src/lib/execution/runners/prompt-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAY3D,MAAM,oBAAoB,GAA4B;IACpD;QACE,QAAQ,EAAE,OAAO;QACjB,WAAW,EAAE,OAAO;QACpB,QAAQ,EAAE;YACR,8CAA8C;YAC9C,gGAAgG;YAChG,iDAAiD;SAClD;KACF;IACD;QACE,QAAQ,EAAE,QAAQ;QAClB,WAAW,EAAE,QAAQ;QACrB,QAAQ,EAAE;YACR,gDAAgD;YAChD,kFAAkF;YAClF,oDAAoD;SACrD;KACF;IACD;QACE,QAAQ,EAAE,MAAM;QAChB,WAAW,EAAE,MAAM;QACnB,QAAQ,EAAE;YACR,4CAA4C;YAC5C,8EAA8E;YAC9E,gDAAgD;SACjD;KACF;IACD;QACE,QAAQ,EAAE,UAAU;QACpB,WAAW,EAAE,UAAU;QACvB,QAAQ,EAAE;YACR,oDAAoD;YACpD,sFAAsF;YACtF,yD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MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAA;YACtD,MAAM,IAAI,qCAAqC,OAAO,CAAC,QAAQ,GAAG,MAAM,eAAe,CAAA;YACvF,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;gBACrB,MAAM,IAAI,kEAAkE,CAAA;YAC9E,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,uCAAuC,CAAA;YACnD,CAAC;YACD,MAAM,IAAI,uHAAuH,CAAA;QACnI,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,sEAAsE,CAAA;QAClF,CAAC;IACH,CAAC;IAED,MAAM,IAAI,4NAA4N,CAAA;IAEtO,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Sandbox Runner - srt-based sandbox on host
3
+ *
4
+ * Runs commands in an srt sandbox for filesystem and network isolation.
5
+ * Falls back to host runner if srt is not installed.
6
+ */
7
+ import { DisplayMode, ExecutorType, ExecutionContext, ExecutionConfig } from './shared.js';
8
+ import { RunnerResult } from './shared.js';
9
+ /**
10
+ * Check if srt (sandbox-runtime) is installed on the host.
11
+ */
12
+ export declare function isSrtInstalled(): boolean;
13
+ /**
14
+ * Build the srt command with filesystem and network restrictions.
15
+ *
16
+ * Filesystem policy (read-restriction philosophy from claude-code-sandbox):
17
+ * - Read/write: agent worktree directory
18
+ * - Read-only: repo source (if different from worktree)
19
+ * - Read-only: additional configured read paths
20
+ * - Deny: home directory, system paths, other repos
21
+ *
22
+ * Network policy:
23
+ * - Allow: configured domains (GitHub, Anthropic API, npm registries, etc.)
24
+ * - Deny: everything else
25
+ */
26
+ export declare function buildSrtCommand(innerCommand: string, context: ExecutionContext, config: ExecutionConfig): string;
27
+ /**
28
+ * Run command in an srt sandbox on the host machine.
29
+ * Uses the same tmux session approach as the host runner, but wraps the
30
+ * executor command with srt for filesystem and network isolation.
31
+ *
32
+ * Falls back to host runner with warning if srt is not installed.
33
+ */
34
+ export declare function runSandbox(context: ExecutionContext, executor: ExecutorType, config: ExecutionConfig, displayMode?: DisplayMode): Promise<RunnerResult>;
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Sandbox Runner - srt-based sandbox on host
3
+ *
4
+ * Runs commands in an srt sandbox for filesystem and network isolation.
5
+ * Falls back to host runner if srt is not installed.
6
+ */
7
+ import { execSync, path, os, } from './shared.js';
8
+ import { runHost } from './host.js';
9
+ // =============================================================================
10
+ // Sandbox Utilities
11
+ // =============================================================================
12
+ /**
13
+ * Check if srt (sandbox-runtime) is installed on the host.
14
+ */
15
+ export function isSrtInstalled() {
16
+ try {
17
+ execSync('which srt', { stdio: 'pipe' });
18
+ return true;
19
+ }
20
+ catch {
21
+ return false;
22
+ }
23
+ }
24
+ /**
25
+ * Build the srt command with filesystem and network restrictions.
26
+ *
27
+ * Filesystem policy (read-restriction philosophy from claude-code-sandbox):
28
+ * - Read/write: agent worktree directory
29
+ * - Read-only: repo source (if different from worktree)
30
+ * - Read-only: additional configured read paths
31
+ * - Deny: home directory, system paths, other repos
32
+ *
33
+ * Network policy:
34
+ * - Allow: configured domains (GitHub, Anthropic API, npm registries, etc.)
35
+ * - Deny: everything else
36
+ */
37
+ export function buildSrtCommand(innerCommand, context, config) {
38
+ const args = ['srt'];
39
+ // Filesystem: always allow read/write to agent worktree
40
+ args.push(`--fs-write=${context.worktreePath}`);
41
+ // Allow read/write to the agent directory (parent of worktree, contains .devcontainer etc.)
42
+ if (context.agentDir && context.agentDir !== context.worktreePath) {
43
+ args.push(`--fs-write=${context.agentDir}`);
44
+ }
45
+ // Allow read/write to HQ scripts directory (for temp script files)
46
+ if (context.hqPath) {
47
+ const scriptsDir = path.join(context.hqPath, '.proletariat', 'scripts');
48
+ args.push(`--fs-write=${scriptsDir}`);
49
+ }
50
+ // Allow read access to additional configured paths
51
+ for (const readPath of config.sandbox.allowReadPaths) {
52
+ args.push(`--fs-read=${readPath}`);
53
+ }
54
+ // Allow write access to additional configured paths
55
+ for (const writePath of config.sandbox.allowWritePaths) {
56
+ args.push(`--fs-write=${writePath}`);
57
+ }
58
+ // Allow read to temp directory (needed for script execution)
59
+ args.push(`--fs-write=${os.tmpdir()}`);
60
+ // Network: merge sandbox domains with firewall allowlist
61
+ const allDomains = new Set([
62
+ ...config.sandbox.networkDomains,
63
+ ...config.firewall.allowlistDomains,
64
+ ]);
65
+ for (const domain of allDomains) {
66
+ args.push(`--net-allow=${domain}`);
67
+ }
68
+ // The inner command to execute inside the sandbox
69
+ args.push('--');
70
+ args.push(innerCommand);
71
+ return args.join(' ');
72
+ }
73
+ // =============================================================================
74
+ // Sandbox Runner
75
+ // =============================================================================
76
+ /**
77
+ * Run command in an srt sandbox on the host machine.
78
+ * Uses the same tmux session approach as the host runner, but wraps the
79
+ * executor command with srt for filesystem and network isolation.
80
+ *
81
+ * Falls back to host runner with warning if srt is not installed.
82
+ */
83
+ export async function runSandbox(context, executor, config, displayMode = 'terminal') {
84
+ // Check if srt is installed
85
+ if (!isSrtInstalled()) {
86
+ if (config.sandbox.fallbackToHost) {
87
+ // Log warning via stderr (will be visible in terminal)
88
+ process.stderr.write('\x1b[33m⚠️ srt (sandbox-runtime) not installed. Falling back to host execution.\n' +
89
+ ' Install srt for filesystem + network isolation: https://github.com/anthropic-experimental/sandbox-runtime\x1b[0m\n');
90
+ // Fall back to host runner
91
+ return runHost(context, executor, config, displayMode);
92
+ }
93
+ return {
94
+ success: false,
95
+ error: 'srt (sandbox-runtime) is not installed.\n\n' +
96
+ 'Install it from: https://github.com/anthropic-experimental/sandbox-runtime\n' +
97
+ 'Or set sandbox.fallbackToHost to true in execution config to fall back to host.',
98
+ };
99
+ }
100
+ // Delegate to host runner — the sandbox wrapping happens at the script level
101
+ // We set a flag on context so the host runner knows to wrap with srt
102
+ const sandboxContext = {
103
+ ...context,
104
+ executionEnvironment: 'sandbox',
105
+ };
106
+ return runHost(sandboxContext, executor, config, displayMode);
107
+ }
108
+ //# sourceMappingUR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,MAAM,EAAE,WAAW,CAAC,CAAA;QACxD,CAAC;QACD,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,6CAA6C;gBAClD,8EAA8E;gBAC9E,iFAAiF;SACpF,CAAA;IACH,CAAC;IAED,6EAA6E;IAC7E,qEAAqE;IACrE,MAAM,cAAc,GAAqB;QACvC,GAAG,OAAO;QACV,oBAAoB,EAAE,SAAS;KAChC,CAAA;IAED,OAAO,OAAO,CAAC,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,CAAA;AAC/D,CAAC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Shared Runner Utilities — Barrel Re-export
3
+ *
4
+ * This module re-exports all shared utilities from sub-modules.
5
+ * Runner modules import from this file for convenience.
6
+ *
7
+ * Sub-modules:
8
+ * - docker-credentials.ts — Credential volume + host creds + tmux keychain
9
+ * - executor.ts — Executor command building + preflight checks
10
+ * - docker-management.ts — Container lifecycle (create, setup, ensure, etc.)
11
+ * - prompt-builder.ts — Integration commands + orchestrator/ticket prompts
12
+ */
13
+ import { spawn, execSync } from 'node:child_process';
14
+ import * as fs from 'node:fs';
15
+ import * as path from 'node:path';
16
+ import * as os from 'node:os';
17
+ import { fileURLToPath } from 'node:url';
18
+ import { ExecutionEnvironment, DisplayMode, OutputMode, PermissionMode, SessionManager, ExecutorType, ExecutionContext, ExecutionConfig, DEFAULT_EXECUTION_CONFIG, normalizeEnvironment } from '../types.js';
19
+ import type { TerminalApp } from '../types.js';
20
+ import { getSetTitleCommands } from '../../terminal.js';
21
+ import { readDevcontainerJson, generateOrchestratorDockerfile } from '../devcontainer.js';
22
+ import type { OrchestratorDockerOptions } from '../devcontainer.js';
23
+ import { getCodexCommand, resolveCodexExecutionContext, validateCodexMode, CodexModeError } from '../codex-adapter.js';
24
+ import { resolveToolsForSpawn } from '../../tool-registry/index.js';
25
+ export interface RunnerResult {
26
+ success: boolean;
27
+ pid?: string;
28
+ containerId?: string;
29
+ sessionId?: string;
30
+ logPath?: string;
31
+ error?: string;
32
+ }
33
+ export type Runner = (context: ExecutionContext, executor: ExecutorType, config: ExecutionConfig) => Promise<RunnerResult>;
34
+ /**
35
+ * Build a unified name for tmux sessions, window names, and tab titles.
36
+ * Format: "{ticketId}-{action}-{agentName}"
37
+ */
38
+ export declare function buildSessionName(context: ExecutionContext): string;
39
+ export declare function buildWindowTitle(context: ExecutionContext): string;
40
+ export declare function buildTmuxWindowName(context: ExecutionContext): string;
41
+ export declare function shouldUseControlMode(terminalApp: TerminalApp, controlModeEnabled: boolean): boolean;
42
+ export declare function buildTmuxMouseOption(_useControlMode: boolean): string;
43
+ export declare function buildTmuxAttachCommand(useControlMode: boolean, includeUnicodeFlag?: boolean): string;
44
+ export declare function configureITermTmuxPreferences(mode: 'tab' | 'window'): void;
45
+ export declare function configureITermTmuxWindowMode(mode: 'tab' | 'window'): void;
46
+ export declare function getGitHubToken(): string | null;
47
+ export declare function isGitHubTokenAvailable(): boolean;
48
+ export type DockerDaemonStatus = {
49
+ available: boolean;
50
+ reason: 'ready' | 'not-installed' | 'daemon-not-ready';
51
+ message: string;
52
+ };
53
+ export declare function checkDockerDaemon(): DockerDaemonStatus;
54
+ export declare function isDockerRunning(): boolean;
55
+ /** @deprecated No longer required - we use raw Docker commands now */
56
+ export declare function isDevcontainerCliInstalled(): boolean;
57
+ export { CLAUDE_CREDENTIALS_VOLUME, credentialsVolumeExists, dockerCredentialsExist, getDockerCredentialInfo, hostCredentialsExist, ensureTmuxServerHasKeychainAccess, copyClaudeCredentials, } from './docker-credentials.js';
58
+ export { getExecutorCommand, isClaudeExecutor, getExecutorDisplayName, getExecutorPackage, PreflightResult, checkExecutorOnHost, checkExecutorInContainer, runExecutorPreflight, } from './executor.js';
59
+ export { getHostPrltVersion, getAgentContainerName, getContainerName, getImageName, containerExists, isContainerRunning, getContainerId, buildDockerImage, imageExists, createDockerContainer, runContainerSetup, ensureDockerContainer, } from './docker-management.js';
60
+ export { buildIntegrationCommandsSection, buildOrchestratorSystemPrompt, buildPrompt, } from './prompt-builder.js';
61
+ export { spawn, execSync, fs, path, os, fileURLToPath, ExecutionEnvironment, DisplayMode, OutputMode, PermissionMode, SessionManager, ExecutorType, ExecutionContext, ExecutionConfig, DEFAULT_EXECUTION_CONFIG, normalizeEnvironment, getSetTitleCommands, readDevcontainerJson, generateOrchestratorDockerfile, getCodexCommand, resolveCodexExecutionContext, validateCodexMode, CodexModeError, resolveToolsForSpawn, };
62
+ export type { TerminalApp, OrchestratorDockerOptions };