taskquoin 0.0.0-stage → 2026.12.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/CHANGELOG.md +62 -0
- package/LICENSE +55 -0
- package/README.md +227 -2
- package/SECURITY.md +26 -0
- package/adapters/git/src/git.js +250 -0
- package/adapters/git/src/index.js +1 -0
- package/adapters/hooks-claude/src/canonical.js +45 -0
- package/adapters/hooks-claude/src/index.js +2 -0
- package/adapters/hooks-claude/src/main.js +58 -0
- package/adapters/hooks-claude/src/payload.js +40 -0
- package/adapters/host-probe/src/index.js +2 -0
- package/adapters/host-probe/src/ollama.js +18 -0
- package/adapters/host-probe/src/probe.js +107 -0
- package/adapters/local-tool/src/fingerprint.js +56 -0
- package/adapters/local-tool/src/index.js +4 -0
- package/adapters/local-tool/src/local-tool.js +22 -0
- package/adapters/local-tool/src/sandboxed.js +105 -0
- package/adapters/local-tool/src/scan.js +52 -0
- package/adapters/memory-claude-mem/src/claude-mem.js +115 -0
- package/adapters/memory-claude-mem/src/index.js +1 -0
- package/adapters/process-runner/src/index.js +1 -0
- package/adapters/process-runner/src/runner.js +123 -0
- package/adapters/runtime-api/src/capabilities.json +116 -0
- package/adapters/runtime-api/src/executor.js +131 -0
- package/adapters/runtime-api/src/index.js +1 -0
- package/adapters/runtime-claude/src/capabilities.json +375 -0
- package/adapters/runtime-claude/src/command.js +34 -0
- package/adapters/runtime-claude/src/executor.js +162 -0
- package/adapters/runtime-claude/src/index.js +4 -0
- package/adapters/runtime-claude/src/permissions.js +76 -0
- package/adapters/runtime-claude/src/stream.js +60 -0
- package/adapters/runtime-codex/src/capabilities.json +192 -0
- package/adapters/runtime-codex/src/command.js +36 -0
- package/adapters/runtime-codex/src/executor.js +83 -0
- package/adapters/runtime-codex/src/index.js +4 -0
- package/adapters/runtime-codex/src/scratch.js +32 -0
- package/adapters/runtime-codex/src/stream.js +39 -0
- package/adapters/runtime-opencode/src/capabilities.json +149 -0
- package/adapters/runtime-opencode/src/config.js +33 -0
- package/adapters/runtime-opencode/src/credentials.js +130 -0
- package/adapters/runtime-opencode/src/executor.js +127 -0
- package/adapters/runtime-opencode/src/facts.js +43 -0
- package/adapters/runtime-opencode/src/hosts.js +16 -0
- package/adapters/runtime-opencode/src/hosts.json +3 -0
- package/adapters/runtime-opencode/src/index.js +6 -0
- package/adapters/runtime-opencode/src/mounts.js +58 -0
- package/adapters/runtime-opencode/src/stream.js +63 -0
- package/adapters/skill-store/src/index.js +1 -0
- package/adapters/skill-store/src/skill-store.js +162 -0
- package/adapters/store-fs/src/index.js +2 -0
- package/adapters/store-fs/src/store.js +201 -0
- package/adapters/store-fs/src/trusted-dir.js +37 -0
- package/apps/cli/src/console.js +432 -0
- package/apps/cli/src/dashboard-approve.js +259 -0
- package/apps/cli/src/dashboard-data.js +424 -0
- package/apps/cli/src/dashboard.js +500 -0
- package/apps/cli/src/history.js +35 -0
- package/apps/cli/src/home.js +18 -0
- package/apps/cli/src/i18n/en.js +527 -0
- package/apps/cli/src/i18n/index.js +90 -0
- package/apps/cli/src/i18n/languages.js +25 -0
- package/apps/cli/src/i18n/locales/ar.json +526 -0
- package/apps/cli/src/i18n/locales/de.json +505 -0
- package/apps/cli/src/i18n/locales/es.json +505 -0
- package/apps/cli/src/i18n/locales/fa.json +505 -0
- package/apps/cli/src/i18n/locales/fr.json +505 -0
- package/apps/cli/src/i18n/locales/he.json +505 -0
- package/apps/cli/src/i18n/locales/hi.json +505 -0
- package/apps/cli/src/i18n/locales/id.json +491 -0
- package/apps/cli/src/i18n/locales/it.json +505 -0
- package/apps/cli/src/i18n/locales/ja.json +491 -0
- package/apps/cli/src/i18n/locales/ko.json +491 -0
- package/apps/cli/src/i18n/locales/nl.json +505 -0
- package/apps/cli/src/i18n/locales/pl.json +512 -0
- package/apps/cli/src/i18n/locales/pt-BR.json +505 -0
- package/apps/cli/src/i18n/locales/ru.json +512 -0
- package/apps/cli/src/i18n/locales/th.json +491 -0
- package/apps/cli/src/i18n/locales/tr.json +505 -0
- package/apps/cli/src/i18n/locales/uk.json +512 -0
- package/apps/cli/src/i18n/locales/vi.json +491 -0
- package/apps/cli/src/i18n/locales/zh-CN.json +491 -0
- package/apps/cli/src/i18n/locales/zh-TW.json +491 -0
- package/apps/cli/src/i18n/width.js +40 -0
- package/apps/cli/src/layout.js +18 -0
- package/apps/cli/src/main.js +830 -0
- package/apps/cli/src/preferences.js +46 -0
- package/apps/cli/src/runtime-notices.js +41 -0
- package/apps/cli/src/safe-text.js +3 -0
- package/apps/cli/src/shortcut.js +82 -0
- package/apps/cli/src/skills-cli.js +112 -0
- package/apps/cli/src/tui/caps.js +31 -0
- package/apps/cli/src/tui/components/agent-list.js +58 -0
- package/apps/cli/src/tui/components/approval-center.js +145 -0
- package/apps/cli/src/tui/components/approval.js +95 -0
- package/apps/cli/src/tui/components/dashboard-frame.js +293 -0
- package/apps/cli/src/tui/components/diff-viewer.js +549 -0
- package/apps/cli/src/tui/components/event-viewer.js +46 -0
- package/apps/cli/src/tui/components/help-panel.js +59 -0
- package/apps/cli/src/tui/components/home.js +185 -0
- package/apps/cli/src/tui/components/logo.js +67 -0
- package/apps/cli/src/tui/components/panel.js +70 -0
- package/apps/cli/src/tui/components/status-bar.js +96 -0
- package/apps/cli/src/tui/components/timeline.js +120 -0
- package/apps/cli/src/tui/keys.js +139 -0
- package/apps/cli/src/tui/neutral.js +68 -0
- package/apps/cli/src/tui/screen.js +111 -0
- package/apps/cli/src/tui/text.js +165 -0
- package/apps/cli/src/tui/tokens.js +89 -0
- package/apps/cli/src/tui/view.js +64 -0
- package/apps/cli/src/upgrade-check.js +86 -0
- package/apps/cli/src/upgrade-cli.js +168 -0
- package/apps/cli/src/workflow-cli.js +674 -0
- package/package.json +29 -4
- package/packages/application/src/index.js +8 -0
- package/packages/application/src/lib/digest.js +7 -0
- package/packages/application/src/ports/memory.js +1 -0
- package/packages/application/src/ports/runtime-executor.js +1 -0
- package/packages/application/src/projection/run-view.js +194 -0
- package/packages/application/src/projection/squad-view.js +33 -0
- package/packages/application/src/use-cases/prepare-run.js +68 -0
- package/packages/application/src/workflow/feature-governed.js +420 -0
- package/packages/application/src/workflow/gate-signals.js +40 -0
- package/packages/application/src/workflow/prompts.js +81 -0
- package/packages/config/src/config.js +372 -0
- package/packages/config/src/index.js +1 -0
- package/packages/domain/src/capabilities.js +13 -0
- package/packages/domain/src/capability-matrix.js +63 -0
- package/packages/domain/src/enforcement.js +95 -0
- package/packages/domain/src/index.js +4 -0
- package/packages/domain/src/policy.js +32 -0
- package/packages/rules/src/glob.js +47 -0
- package/packages/rules/src/index.js +5 -0
- package/packages/rules/src/inherit.js +19 -0
- package/packages/rules/src/lists.js +41 -0
- package/packages/rules/src/rules.js +79 -0
- package/packages/rules/src/shell.js +83 -0
- package/packages/skills/src/index.js +1 -0
- package/packages/skills/src/skills.js +108 -0
- package/skills/code-review/SKILL.md +51 -0
- package/skills/egm-design/LICENSE +202 -0
- package/skills/egm-design/SKILL.md +68 -0
- package/skills/egm-design/references/feature-spec-standard.md +39 -0
- package/skills/egm-implementation-readiness/LICENSE +202 -0
- package/skills/egm-implementation-readiness/SKILL.md +67 -0
- package/skills/egm-implementation-readiness/references/implementation-readiness-standard.md +37 -0
- package/skills/first-party.lock.json +10 -0
- package/skills/planning-contract/SKILL.md +51 -0
- package/skills/ponytail/LICENSE +21 -0
- package/skills/ponytail/SKILL.md +56 -0
- package/skills/security-review/SKILL.md +58 -0
- package/skills/tdd/SKILL.md +52 -0
- package/skills/unslop/LICENSE +396 -0
- package/skills/unslop/SKILL.md +239 -0
- package/skills/unslop/references/cjk.md +34 -0
- package/skills/unslop/references/effects.md +113 -0
- package/skills/unslop/references/refs.md +17 -0
- package/skills/unslop/references/rtl.md +111 -0
- package/skills/unslop/references/signs.md +122 -0
- package/skills/unslop/references/tokens.md +139 -0
- package/skills/unslop/references/visuals.md +84 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const MAX_TOOL_OUTPUT = 64 * 1024;
|
|
2
|
+
const isObj = (x) => typeof x === 'object' && x !== null && !Array.isArray(x);
|
|
3
|
+
const strs = (x) => Array.isArray(x) ? x.filter((v) => typeof v === 'string') : [];
|
|
4
|
+
const names = (x) => Array.isArray(x) ? x.map(v => (isObj(v) && typeof v.name === 'string' ? v.name : typeof v === 'string' ? v : undefined)).filter((v) => !!v) : [];
|
|
5
|
+
const text = (c) => {
|
|
6
|
+
if (typeof c === 'string')
|
|
7
|
+
return c;
|
|
8
|
+
if (Array.isArray(c))
|
|
9
|
+
return c.map(b => (isObj(b) && typeof b.text === 'string' ? b.text : '')).join('');
|
|
10
|
+
return '';
|
|
11
|
+
};
|
|
12
|
+
export function parseClaudeStream(lines) {
|
|
13
|
+
let inventory;
|
|
14
|
+
const calls = new Map();
|
|
15
|
+
let terminal = { status: 'unknown', permissionDenials: [] };
|
|
16
|
+
for (const line of lines) {
|
|
17
|
+
let ev;
|
|
18
|
+
try {
|
|
19
|
+
ev = JSON.parse(line);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (!isObj(ev))
|
|
25
|
+
continue;
|
|
26
|
+
if (ev.type === 'system' && ev.subtype === 'init') {
|
|
27
|
+
inventory = {
|
|
28
|
+
tools: strs(ev.tools), mcpServers: names(ev.mcp_servers), plugins: names(ev.plugins), skills: names(ev.skills), agents: names(ev.agents),
|
|
29
|
+
...(typeof ev.model === 'string' ? { model: ev.model } : {}),
|
|
30
|
+
...(typeof ev.permissionMode === 'string' ? { permissionMode: ev.permissionMode } : {}),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
else if ((ev.type === 'assistant' || ev.type === 'user') && isObj(ev.message) && Array.isArray(ev.message.content)) {
|
|
34
|
+
for (const b of ev.message.content) {
|
|
35
|
+
if (!isObj(b))
|
|
36
|
+
continue;
|
|
37
|
+
if (b.type === 'tool_use' && typeof b.id === 'string' && typeof b.name === 'string')
|
|
38
|
+
calls.set(b.id, { id: b.id, name: b.name, input: b.input });
|
|
39
|
+
if (b.type === 'tool_result' && typeof b.tool_use_id === 'string') {
|
|
40
|
+
const c = calls.get(b.tool_use_id);
|
|
41
|
+
if (c) {
|
|
42
|
+
c.isError = b.is_error === true;
|
|
43
|
+
c.output = text(b.content).slice(0, MAX_TOOL_OUTPUT);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else if (ev.type === 'result' && typeof ev.subtype === 'string' && typeof ev.is_error === 'boolean') {
|
|
49
|
+
terminal = {
|
|
50
|
+
status: ev.is_error ? 'failed' : 'completed', subtype: ev.subtype,
|
|
51
|
+
costUsd: typeof ev.total_cost_usd === 'number' ? ev.total_cost_usd : undefined,
|
|
52
|
+
numTurns: typeof ev.num_turns === 'number' ? ev.num_turns : undefined,
|
|
53
|
+
resultText: typeof ev.result === 'string' ? ev.result : undefined,
|
|
54
|
+
permissionDenials: Array.isArray(ev.permission_denials)
|
|
55
|
+
? ev.permission_denials.filter(isObj).map(d => ({ tool: String(d.tool_name), input: d.tool_input })) : [],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return { inventory, toolCalls: [...calls.values()], terminal };
|
|
60
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
{
|
|
2
|
+
"runtime": "codex",
|
|
3
|
+
"runtimeVersion": "0.157.1",
|
|
4
|
+
"measuredOn": "2026-11-15",
|
|
5
|
+
"evidence": "docs/reports/evidence-live-contract-R1.2-2026-11-15.txt (current mechanisms). Network evidence (curl to example.com failing) is a weak negative and does not certify (Codex R1.1 review). Every Codex agent has a shell: the model reads files through it. R3: docs/reports/evidence-live-R3-2026-11-15.txt. Codex --json aggregated_output measured UNRELIABLE (lines lost / empty in ~1/3 runs): never used as evidence. R3.1 rerun of every live suite after the Codex R3 fixes: docs/reports/evidence-live-R3.1-2026-11-15.txt.",
|
|
6
|
+
"entries": {
|
|
7
|
+
"fs.read": [
|
|
8
|
+
{
|
|
9
|
+
"class": "ADVISORY",
|
|
10
|
+
"granularity": "workspace",
|
|
11
|
+
"evidence": "inferred",
|
|
12
|
+
"mechanism": "the OS sandbox does not restrict reads of user-readable files, inside or outside the workspace",
|
|
13
|
+
"holdsFor": [
|
|
14
|
+
"deny-all",
|
|
15
|
+
"scoped",
|
|
16
|
+
"workspace"
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"fs.write": [
|
|
21
|
+
{
|
|
22
|
+
"when": {
|
|
23
|
+
"sandbox": "read-only"
|
|
24
|
+
},
|
|
25
|
+
"class": "ENFORCED",
|
|
26
|
+
"granularity": "workspace",
|
|
27
|
+
"evidence": "measured",
|
|
28
|
+
"mechanism": "read-only sandbox: no filesystem writes",
|
|
29
|
+
"holdsFor": [
|
|
30
|
+
"deny-all",
|
|
31
|
+
"workspace"
|
|
32
|
+
],
|
|
33
|
+
"evidenceRef": "docs/reports/evidence-live-R3-2026-11-15.txt M2: read-only — writes inside and outside the workspace absent"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"class": "ENFORCED",
|
|
37
|
+
"granularity": "workspace",
|
|
38
|
+
"evidence": "measured",
|
|
39
|
+
"mechanism": "workspace-write sandbox: writes confined to the workspace PLUS the per-run scratch dir (writable_roots, outside the repository, removed after the run); /tmp and $TMPDIR excluded. R1.1 measured an earlier form (TMPDIR inside the workspace) — re-measure",
|
|
40
|
+
"holdsFor": [
|
|
41
|
+
"workspace"
|
|
42
|
+
],
|
|
43
|
+
"evidenceRef": "docs/reports/evidence-live-R3.1-2026-11-15.txt (rerun) — R1.2 codex (fix/r1.2-hardening): workspace write ok, outside write failed, /tmp write failed, per-run scratch TMPDIR usable"
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"shell.run": [
|
|
47
|
+
{
|
|
48
|
+
"class": "ADVISORY",
|
|
49
|
+
"granularity": "workspace",
|
|
50
|
+
"evidence": "inferred",
|
|
51
|
+
"mechanism": "shell is always available to Codex (it reads files through it); command patterns are not enforced; effects are bounded by the sandbox",
|
|
52
|
+
"holdsFor": [
|
|
53
|
+
"deny-all",
|
|
54
|
+
"scoped",
|
|
55
|
+
"workspace"
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"net.egress": [
|
|
60
|
+
{
|
|
61
|
+
"when": {
|
|
62
|
+
"scope": "scoped"
|
|
63
|
+
},
|
|
64
|
+
"class": "UNSUPPORTED",
|
|
65
|
+
"granularity": "workspace",
|
|
66
|
+
"evidence": "inferred",
|
|
67
|
+
"mechanism": "network is all-or-nothing in the sandbox; no per-host allow",
|
|
68
|
+
"holdsFor": [
|
|
69
|
+
"deny-all",
|
|
70
|
+
"scoped",
|
|
71
|
+
"workspace"
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"class": "ENFORCED",
|
|
76
|
+
"granularity": "workspace",
|
|
77
|
+
"evidence": "measured",
|
|
78
|
+
"mechanism": "network_access=false (measured: loopback HTTP 0 hits in read-only and workspace-write); web_search disabled and plugin/app/browser/computer-use features off by flag (documented, not separately measured)",
|
|
79
|
+
"holdsFor": [
|
|
80
|
+
"deny-all"
|
|
81
|
+
],
|
|
82
|
+
"evidenceRef": "docs/reports/evidence-live-R3-2026-11-15.txt M2 (read-only) and M3 (workspace-write): curl to a 127.0.0.1 server failed, 0 hits"
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
"vcs.commit": [
|
|
86
|
+
{
|
|
87
|
+
"class": "ENFORCED",
|
|
88
|
+
"granularity": "workspace",
|
|
89
|
+
"evidence": "measured",
|
|
90
|
+
"mechanism": "the sandbox keeps .git read-only in both modes: git commit fails (measured)",
|
|
91
|
+
"holdsFor": [
|
|
92
|
+
"deny-all"
|
|
93
|
+
],
|
|
94
|
+
"evidenceRef": "docs/reports/evidence-live-R3-2026-11-15.txt M2 + M3: git commit exit 128, history unchanged"
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
"vcs.push": [
|
|
98
|
+
{
|
|
99
|
+
"class": "ENFORCED",
|
|
100
|
+
"granularity": "workspace",
|
|
101
|
+
"evidence": "measured",
|
|
102
|
+
"mechanism": "no network and no writable root outside the workspace/scratch ⇒ a push reaches neither a network remote nor a local-path remote outside them (measured M3); a bare remote created INSIDE the workspace stays reachable (within the boundary)",
|
|
103
|
+
"holdsFor": [
|
|
104
|
+
"deny-all"
|
|
105
|
+
],
|
|
106
|
+
"evidenceRef": "docs/reports/evidence-live-R3-2026-11-15.txt M3: push to a local bare remote outside the workspace failed, remote refs empty; no network (0 hits)"
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
"connector.read": [
|
|
110
|
+
{
|
|
111
|
+
"when": {
|
|
112
|
+
"scope": "scoped"
|
|
113
|
+
},
|
|
114
|
+
"class": "UNSUPPORTED",
|
|
115
|
+
"granularity": "workspace",
|
|
116
|
+
"evidence": "inferred",
|
|
117
|
+
"mechanism": "no reviewed connector mechanism before R6",
|
|
118
|
+
"holdsFor": [
|
|
119
|
+
"deny-all",
|
|
120
|
+
"scoped",
|
|
121
|
+
"workspace"
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"class": "ENFORCED",
|
|
126
|
+
"granularity": "workspace",
|
|
127
|
+
"evidence": "inferred",
|
|
128
|
+
"mechanism": "--ignore-user-config drops user [mcp_servers]; project .codex/config.toml must not load (sentinel test)",
|
|
129
|
+
"holdsFor": [
|
|
130
|
+
"deny-all"
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
"connector.write": [
|
|
135
|
+
{
|
|
136
|
+
"when": {
|
|
137
|
+
"scope": "scoped"
|
|
138
|
+
},
|
|
139
|
+
"class": "BROKERED",
|
|
140
|
+
"granularity": "workspace",
|
|
141
|
+
"evidence": "inferred",
|
|
142
|
+
"requires": [
|
|
143
|
+
"broker-available"
|
|
144
|
+
],
|
|
145
|
+
"mechanism": "Action Broker (ADR-0004) — not implemented before R6",
|
|
146
|
+
"holdsFor": [
|
|
147
|
+
"deny-all",
|
|
148
|
+
"scoped",
|
|
149
|
+
"workspace"
|
|
150
|
+
]
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"class": "ENFORCED",
|
|
154
|
+
"granularity": "workspace",
|
|
155
|
+
"evidence": "inferred",
|
|
156
|
+
"mechanism": "no MCP servers configured for agent runs",
|
|
157
|
+
"holdsFor": [
|
|
158
|
+
"deny-all"
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
],
|
|
162
|
+
"config.modify": [
|
|
163
|
+
{
|
|
164
|
+
"when": {
|
|
165
|
+
"sandbox": "read-only"
|
|
166
|
+
},
|
|
167
|
+
"class": "ENFORCED",
|
|
168
|
+
"granularity": "workspace",
|
|
169
|
+
"evidence": "measured",
|
|
170
|
+
"mechanism": "read-only sandbox: no writes at all",
|
|
171
|
+
"holdsFor": [
|
|
172
|
+
"deny-all",
|
|
173
|
+
"scoped",
|
|
174
|
+
"workspace"
|
|
175
|
+
],
|
|
176
|
+
"evidenceRef": "docs/reports/evidence-live-R3-2026-11-15.txt M2: read-only — .codex/config.toml write absent"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"class": "ADVISORY",
|
|
180
|
+
"granularity": "workspace",
|
|
181
|
+
"evidence": "measured",
|
|
182
|
+
"evidenceRef": "docs/reports/evidence-live-R3.1-2026-11-15.txt (rerun) — R1.2 codex: forbidden/ inside workspace written; .codex/ and .git/hooks writes failed",
|
|
183
|
+
"mechanism": "writers: .codex/ and .git/ protected by the sandbox, other config paths inside the workspace (taskquoin.yaml, .claude/, AGENTS.md) are not",
|
|
184
|
+
"holdsFor": [
|
|
185
|
+
"deny-all",
|
|
186
|
+
"scoped",
|
|
187
|
+
"workspace"
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Model-side tools/features that act outside the OS sandbox or install code. */
|
|
2
|
+
export const CODEX_DISABLED_FEATURES = [
|
|
3
|
+
'plugins', 'apps', 'remote_plugin', 'browser_use', 'browser_use_external', 'computer_use', 'in_app_browser',
|
|
4
|
+
'image_generation', 'skill_mcp_dependency_install', 'tool_suggest', 'goals', 'multi_agent',
|
|
5
|
+
];
|
|
6
|
+
const MODEL_RE = /^[A-Za-z0-9._:-]{1,64}$/;
|
|
7
|
+
const SAFE_PATH_RE = /^\/[^"\\\u0000-\u001f]*$/;
|
|
8
|
+
/** Codex has no per-run system prompt flag that we trust; role instructions travel with the task on stdin. */
|
|
9
|
+
export function codexStdin(agentPrompt, task) {
|
|
10
|
+
return agentPrompt.trim() ? `<agent-instructions>\n${agentPrompt}\n</agent-instructions>\n\n<task>\n${task}\n</task>\n` : task;
|
|
11
|
+
}
|
|
12
|
+
export function buildCodexCommand(r) {
|
|
13
|
+
if (r.sandbox !== 'read-only' && r.sandbox !== 'workspace-write') {
|
|
14
|
+
throw new Error(`refusing sandbox "${String(r.sandbox)}": only read-only|workspace-write are allowed (danger-full-access is never used)`);
|
|
15
|
+
}
|
|
16
|
+
if (r.model !== undefined && !MODEL_RE.test(r.model))
|
|
17
|
+
throw new Error(`invalid model name ${JSON.stringify(r.model)}`);
|
|
18
|
+
// --strict-config: an unknown/misspelt -c key fails the run instead of being silently ignored (verified on 0.157.1).
|
|
19
|
+
const args = ['exec', '--strict-config', '--json', '--ignore-user-config', '--ignore-rules', '--ephemeral',
|
|
20
|
+
'--sandbox', r.sandbox, '-C', r.cwd, '-o', r.lastMessageFile,
|
|
21
|
+
'-c', 'approval_policy="never"', '-c', 'web_search="disabled"',
|
|
22
|
+
'-c', 'project_doc_max_bytes=0', '-c', 'skills.include_instructions=false',
|
|
23
|
+
// ADR-0010 no-leak: no product analytics, no OpenTelemetry export.
|
|
24
|
+
'-c', 'analytics.enabled=false', '-c', 'otel.exporter="none"'];
|
|
25
|
+
if (r.sandbox === 'workspace-write') {
|
|
26
|
+
if (!r.scratchDir || !SAFE_PATH_RE.test(r.scratchDir))
|
|
27
|
+
throw new Error(`workspace-write requires an absolute, TOML-safe scratchDir (got ${JSON.stringify(r.scratchDir)})`);
|
|
28
|
+
args.push('-c', 'sandbox_workspace_write.network_access=false', '-c', 'sandbox_workspace_write.exclude_slash_tmp=true', '-c', 'sandbox_workspace_write.exclude_tmpdir_env_var=true', '-c', `sandbox_workspace_write.writable_roots=[${JSON.stringify(r.scratchDir)}]`);
|
|
29
|
+
}
|
|
30
|
+
for (const f of CODEX_DISABLED_FEATURES)
|
|
31
|
+
args.push('--disable', f);
|
|
32
|
+
if (r.model)
|
|
33
|
+
args.push('-c', `model="${r.model}"`);
|
|
34
|
+
args.push('-');
|
|
35
|
+
return { bin: 'codex', args, cwd: r.cwd, stdin: codexStdin(r.agentPrompt, r.task) };
|
|
36
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { closeSync, mkdtempSync, openSync, readSync, rmSync, existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { normalizeGrants } from '../../../packages/domain/src/index.js';
|
|
4
|
+
import { assertTicket, invocationDigest } from '../../../packages/application/src/index.js';
|
|
5
|
+
import { runProcess, verifyBinaryVersion } from '../../process-runner/src/index.js';
|
|
6
|
+
import { buildCodexCommand } from "./command.js";
|
|
7
|
+
import { parseCodexStream } from "./stream.js";
|
|
8
|
+
import { createScratch, defaultScratchBase } from "./scratch.js";
|
|
9
|
+
const MAX_LAST_MESSAGE = 1024 * 1024;
|
|
10
|
+
function readBounded(file) {
|
|
11
|
+
if (!existsSync(file))
|
|
12
|
+
return undefined;
|
|
13
|
+
const fd = openSync(file, 'r');
|
|
14
|
+
try {
|
|
15
|
+
const buf = Buffer.alloc(MAX_LAST_MESSAGE);
|
|
16
|
+
const n = readSync(fd, buf, 0, MAX_LAST_MESSAGE, 0);
|
|
17
|
+
return buf.subarray(0, n).toString('utf8');
|
|
18
|
+
}
|
|
19
|
+
finally {
|
|
20
|
+
closeSync(fd);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** Single source of truth for the sandbox mode — used by the executor AND to build HostFacts (review H2). */
|
|
24
|
+
export function codexSandboxFor(grants) {
|
|
25
|
+
return normalizeGrants(grants)['fs.write'] ? 'workspace-write' : 'read-only';
|
|
26
|
+
}
|
|
27
|
+
export class CodexExecutor {
|
|
28
|
+
runtime = 'codex';
|
|
29
|
+
binary;
|
|
30
|
+
scratchBase;
|
|
31
|
+
version;
|
|
32
|
+
constructor(binary, opts = {}) { this.binary = binary; this.scratchBase = opts.scratchBase ?? defaultScratchBase(); }
|
|
33
|
+
async run(req, signal) {
|
|
34
|
+
this.version ??= verifyBinaryVersion(this.binary.bin, this.binary.prefixArgs, req.env);
|
|
35
|
+
const verified = await this.version;
|
|
36
|
+
if (verified !== this.binary.version)
|
|
37
|
+
throw new Error(`codex binary is ${verified}, declared ${this.binary.version}`);
|
|
38
|
+
assertTicket(req.ticket, 'codex', verified, req.agent.capabilities, req.agent.id);
|
|
39
|
+
const sandbox = codexSandboxFor(req.agent.capabilities);
|
|
40
|
+
// ADR-0014: Codex's workspace-write sandbox has no per-path deny — it cannot keep inherited dependencies read-only.
|
|
41
|
+
if (req.frozenPaths?.length && sandbox !== 'read-only')
|
|
42
|
+
throw new Error('refusing: codex workspace-write cannot keep frozen paths read-only (ADR-0014) — use a read-only Codex role or a Claude implementer');
|
|
43
|
+
const scratch = createScratch(this.scratchBase, req.cwd);
|
|
44
|
+
const cleanupErrors = [];
|
|
45
|
+
let lastMessageDir;
|
|
46
|
+
let result;
|
|
47
|
+
try {
|
|
48
|
+
// Sibling of the run dir, NOT inside it: the scratch dir is a writable root, the message must not be forgeable by the agent.
|
|
49
|
+
lastMessageDir = mkdtempSync(join(this.scratchBase, 'msg-'));
|
|
50
|
+
const lastMessageFile = join(lastMessageDir, 'last-message.md');
|
|
51
|
+
const cmd = buildCodexCommand({ agentPrompt: req.agent.prompt, task: req.task, cwd: req.cwd, sandbox, lastMessageFile, model: req.agent.model,
|
|
52
|
+
...(sandbox === 'workspace-write' ? { scratchDir: scratch.dir } : {}) });
|
|
53
|
+
const env = sandbox === 'workspace-write' ? { ...req.env, TMPDIR: scratch.dir } : req.env;
|
|
54
|
+
const args = [...(this.binary.prefixArgs ?? []), ...cmd.args];
|
|
55
|
+
const p = await runProcess({ bin: this.binary.bin, args, cwd: req.cwd, env, timeoutMs: req.timeoutMs, maxOutputBytes: req.maxOutputBytes, stdin: cmd.stdin }, signal);
|
|
56
|
+
const s = parseCodexStream(p.stdout.split('\n'));
|
|
57
|
+
const message = readBounded(lastMessageFile);
|
|
58
|
+
const status = p.status === 'timeout' || p.status === 'cancelled' ? p.status
|
|
59
|
+
: p.status === 'failed' || s.turnFailed ? 'failed'
|
|
60
|
+
: s.turnCompleted && message && message.trim() ? 'completed' : 'unknown';
|
|
61
|
+
result = {
|
|
62
|
+
status, runtime: 'codex', runtimeVersion: this.binary.version, exitCode: p.exitCode, terminalMessage: message,
|
|
63
|
+
usage: s.usage, command: { bin: this.binary.bin, args, cwd: req.cwd }, effectiveConfigDigest: invocationDigest(this.binary.bin, args, env),
|
|
64
|
+
commandExecutions: s.commandExecutions, unsupported: req.agent.maxTurns !== undefined ? ['maxTurns'] : [],
|
|
65
|
+
stdoutTruncated: p.truncated, stderr: p.stderr, durationMs: p.durationMs,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
if (lastMessageDir) {
|
|
70
|
+
try {
|
|
71
|
+
rmSync(lastMessageDir, { recursive: true, force: true });
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
cleanupErrors.push(`message dir cleanup failed: ${e.message}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const err = scratch.remove();
|
|
78
|
+
if (err)
|
|
79
|
+
cleanupErrors.push(err);
|
|
80
|
+
}
|
|
81
|
+
return cleanupErrors.length ? { ...result, cleanupErrors } : result;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { lstatSync, mkdtempSync, realpathSync, rmSync } from 'node:fs';
|
|
2
|
+
import { ensureTrustedDir } from '../../store-fs/src/index.js';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
/** Default trusted base for per-run scratch dirs: never inside a repository. */
|
|
6
|
+
export function defaultScratchBase() {
|
|
7
|
+
return join(process.env.XDG_STATE_HOME || join(homedir(), '.local', 'state'), 'taskquoin', 'scratch');
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Create a per-run scratch dir under `base` (Codex R1.1 P1: never follow repository-controlled paths).
|
|
11
|
+
* Refuses a symlinked base, a base not owned by the current user, or a base inside the workspace.
|
|
12
|
+
*/
|
|
13
|
+
export function createScratch(base, workspace) {
|
|
14
|
+
const realBase = ensureTrustedDir(base, workspace); // symlink / owner / permissions / inside-workspace checks
|
|
15
|
+
const dir = mkdtempSync(join(base, 'run-'));
|
|
16
|
+
return {
|
|
17
|
+
dir,
|
|
18
|
+
/** Never throws; returns a description of the problem, if any. */
|
|
19
|
+
remove: () => {
|
|
20
|
+
try {
|
|
21
|
+
const b = lstatSync(base);
|
|
22
|
+
if (b.isSymbolicLink() || realpathSync(base) !== realBase)
|
|
23
|
+
return `scratch base ${base} changed during the run; not removing ${dir}`;
|
|
24
|
+
rmSync(dir, { recursive: true, force: true });
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
return `scratch cleanup failed: ${e.message}`;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const MAX_OUTPUT = 64 * 1024;
|
|
2
|
+
const isObj = (x) => typeof x === 'object' && x !== null && !Array.isArray(x);
|
|
3
|
+
export function parseCodexStream(lines) {
|
|
4
|
+
const commandExecutions = [];
|
|
5
|
+
let turnCompleted = false;
|
|
6
|
+
let turnFailed = false;
|
|
7
|
+
let usage;
|
|
8
|
+
for (const line of lines) {
|
|
9
|
+
let ev;
|
|
10
|
+
try {
|
|
11
|
+
ev = JSON.parse(line);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (!isObj(ev))
|
|
17
|
+
continue;
|
|
18
|
+
if (ev.type === 'item.completed' && isObj(ev.item) && ev.item.type === 'command_execution' && typeof ev.item.command === 'string') {
|
|
19
|
+
const it = ev.item;
|
|
20
|
+
commandExecutions.push({
|
|
21
|
+
command: it.command, exitCode: typeof it.exit_code === 'number' ? it.exit_code : null,
|
|
22
|
+
status: typeof it.status === 'string' ? it.status : 'unknown',
|
|
23
|
+
output: typeof it.aggregated_output === 'string' ? it.aggregated_output.slice(0, MAX_OUTPUT) : '',
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
else if (ev.type === 'turn.completed') {
|
|
27
|
+
turnCompleted = true;
|
|
28
|
+
if (isObj(ev.usage))
|
|
29
|
+
usage = {
|
|
30
|
+
...(typeof ev.usage.input_tokens === 'number' ? { inputTokens: ev.usage.input_tokens } : {}),
|
|
31
|
+
...(typeof ev.usage.output_tokens === 'number' ? { outputTokens: ev.usage.output_tokens } : {}),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
else if (ev.type === 'turn.failed' || ev.type === 'error') {
|
|
35
|
+
turnFailed = true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return { commandExecutions, turnCompleted, turnFailed, usage };
|
|
39
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
{
|
|
2
|
+
"runtime": "opencode",
|
|
3
|
+
"runtimeVersion": "1.19.5",
|
|
4
|
+
"measuredOn": "2026-11-16",
|
|
5
|
+
"evidence": "Measured 2026-11-16 on the reference machine with the owner's ChatGPT sign-in (Taskquoin's own OpenCode connection), model openai/gpt-6-astra: docs/reports/evidence-live-opencode-2026-11-16.txt (L1 write + hostile repository ignored, L2 outside write / .env / shell / loopback refused, L3 read-only, L4 hosts = chatgpt.com only); adapters/runtime-opencode/test/executor.test.ts (fake OpenCode in the real sandbox: HOME hidden, secrets and instruction files masked, .git and frozen paths read-only, control store masked); docs/reports/opencode-interface-1.19.5.md (tools disabled by the generated config, project config ignored, ask rejected in run mode). Not measured: runtime honouring of agent.build.steps (maxTurns) — documented only.",
|
|
6
|
+
"entries": {
|
|
7
|
+
"fs.read": [
|
|
8
|
+
{
|
|
9
|
+
"class": "ENFORCED",
|
|
10
|
+
"granularity": "workspace",
|
|
11
|
+
"holdsFor": [
|
|
12
|
+
"workspace"
|
|
13
|
+
],
|
|
14
|
+
"requires": [
|
|
15
|
+
"file-sandbox"
|
|
16
|
+
],
|
|
17
|
+
"evidence": "measured",
|
|
18
|
+
"mechanism": "bubblewrap: HOME hidden, project secret files, instruction files and what secret-named or outward links point to masked, control store masked; OpenCode read rules allow the whole repository and deny secrets — a scoped or deny-all read restriction is NOT enforced (only the whole repository)",
|
|
19
|
+
"evidenceRef": "docs/reports/evidence-live-opencode-2026-11-16.txt L2: .env read refused, MARKER-LIVE-ENV absent from the result; adapters/runtime-opencode/test/executor.test.ts: HOME hidden, secret and instruction files masked"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"fs.write": [
|
|
23
|
+
{
|
|
24
|
+
"when": {
|
|
25
|
+
"absent": [
|
|
26
|
+
"fs.write"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
"class": "ENFORCED",
|
|
30
|
+
"granularity": "workspace",
|
|
31
|
+
"holdsFor": [
|
|
32
|
+
"deny-all"
|
|
33
|
+
],
|
|
34
|
+
"requires": [
|
|
35
|
+
"file-sandbox"
|
|
36
|
+
],
|
|
37
|
+
"evidence": "measured",
|
|
38
|
+
"mechanism": "read-only agent: the repository is bound read-only and OpenCode's edit/write tools are disabled",
|
|
39
|
+
"evidenceRef": "docs/reports/evidence-live-opencode-2026-11-16.txt L3: read-only agent wrote nothing (no edit tool); adapters/runtime-opencode/test/executor.test.ts: read-only agent cannot write"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"class": "ENFORCED",
|
|
43
|
+
"granularity": "workspace",
|
|
44
|
+
"holdsFor": [
|
|
45
|
+
"workspace"
|
|
46
|
+
],
|
|
47
|
+
"requires": [
|
|
48
|
+
"file-sandbox"
|
|
49
|
+
],
|
|
50
|
+
"evidence": "measured",
|
|
51
|
+
"mechanism": "bubblewrap: only the repository and the per-run OpenCode dir are writable; .git and frozen dependency dirs read-only",
|
|
52
|
+
"evidenceRef": "docs/reports/evidence-live-opencode-2026-11-16.txt L1 write ok, L2 outside write refused; adapters/runtime-opencode/test/executor.test.ts: outside, .git and frozen paths unwritable"
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"shell.run": [
|
|
56
|
+
{
|
|
57
|
+
"class": "ENFORCED",
|
|
58
|
+
"granularity": "pattern",
|
|
59
|
+
"holdsFor": [
|
|
60
|
+
"deny-all"
|
|
61
|
+
],
|
|
62
|
+
"evidence": "measured",
|
|
63
|
+
"mechanism": "no command tool: the generated config denies every action but read/list/glob/grep(/edit) — bash is absent (debug agent build)",
|
|
64
|
+
"evidenceRef": "docs/reports/evidence-live-opencode-2026-11-16.txt L2: shell marker absent, no shell tool called"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"net.egress": [
|
|
68
|
+
{
|
|
69
|
+
"class": "ENFORCED",
|
|
70
|
+
"granularity": "pattern",
|
|
71
|
+
"holdsFor": [
|
|
72
|
+
"deny-all"
|
|
73
|
+
],
|
|
74
|
+
"evidence": "measured",
|
|
75
|
+
"mechanism": "no network tool (webfetch/websearch absent); the OpenCode process itself reaches only the provider's hosts (hosts.json), catalogue and plugin SDK fetched at connect time",
|
|
76
|
+
"evidenceRef": "docs/reports/evidence-live-opencode-2026-11-16.txt L2: loopback server 0 hits; L4: hosts = chatgpt.com:443 only (no-network sandbox + logging proxy)"
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"vcs.commit": [
|
|
80
|
+
{
|
|
81
|
+
"class": "ENFORCED",
|
|
82
|
+
"granularity": "workspace",
|
|
83
|
+
"holdsFor": [
|
|
84
|
+
"deny-all"
|
|
85
|
+
],
|
|
86
|
+
"requires": [
|
|
87
|
+
"file-sandbox"
|
|
88
|
+
],
|
|
89
|
+
"evidence": "measured",
|
|
90
|
+
"mechanism": "no command tool and .git bound read-only",
|
|
91
|
+
"evidenceRef": "adapters/runtime-opencode/test/executor.test.ts: .git read-only inside the sandbox; docs/reports/evidence-live-opencode-2026-11-16.txt L2: no shell"
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
"vcs.push": [
|
|
95
|
+
{
|
|
96
|
+
"class": "ENFORCED",
|
|
97
|
+
"granularity": "workspace",
|
|
98
|
+
"holdsFor": [
|
|
99
|
+
"deny-all"
|
|
100
|
+
],
|
|
101
|
+
"requires": [
|
|
102
|
+
"file-sandbox"
|
|
103
|
+
],
|
|
104
|
+
"evidence": "measured",
|
|
105
|
+
"mechanism": "no command tool and .git bound read-only",
|
|
106
|
+
"evidenceRef": "adapters/runtime-opencode/test/executor.test.ts: .git read-only inside the sandbox; docs/reports/evidence-live-opencode-2026-11-16.txt L2: no shell"
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
"connector.read": [
|
|
110
|
+
{
|
|
111
|
+
"class": "ENFORCED",
|
|
112
|
+
"granularity": "pattern",
|
|
113
|
+
"holdsFor": [
|
|
114
|
+
"deny-all"
|
|
115
|
+
],
|
|
116
|
+
"evidence": "measured",
|
|
117
|
+
"mechanism": "no MCP server (mcp: {}), no external plugin (OPENCODE_PURE)",
|
|
118
|
+
"evidenceRef": "docs/reports/evidence-live-opencode-2026-11-16.txt L1-L3: only apply_patch/read tools observed; adapters/runtime-opencode/test/config.test.ts: mcp {}, plugin []"
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
"connector.write": [
|
|
122
|
+
{
|
|
123
|
+
"class": "ENFORCED",
|
|
124
|
+
"granularity": "pattern",
|
|
125
|
+
"holdsFor": [
|
|
126
|
+
"deny-all"
|
|
127
|
+
],
|
|
128
|
+
"evidence": "measured",
|
|
129
|
+
"mechanism": "no MCP server (mcp: {}), no external plugin (OPENCODE_PURE)",
|
|
130
|
+
"evidenceRef": "docs/reports/evidence-live-opencode-2026-11-16.txt L1-L3: only apply_patch/read tools observed; adapters/runtime-opencode/test/config.test.ts: mcp {}, plugin []"
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
"config.modify": [
|
|
134
|
+
{
|
|
135
|
+
"class": "ENFORCED",
|
|
136
|
+
"granularity": "pattern",
|
|
137
|
+
"holdsFor": [
|
|
138
|
+
"deny-all"
|
|
139
|
+
],
|
|
140
|
+
"requires": [
|
|
141
|
+
"landing-gate"
|
|
142
|
+
],
|
|
143
|
+
"evidence": "measured",
|
|
144
|
+
"mechanism": "OpenCode edit rules deny protected config; the repository's OpenCode config is masked; a protected change never lands (landing gate)",
|
|
145
|
+
"evidenceRef": "docs/reports/evidence-live-opencode-2026-11-16.txt L1: hostile opencode.json/.opencode/AGENTS.md ignored (pwned=[]); adapters/runtime-opencode/test/config.test.ts: edits of protected config denied; adapters/runtime-opencode/test/executor.test.ts: repository OpenCode config masked"
|
|
146
|
+
}
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The OpenCode config Taskquoin generates for every run (passed in OPENCODE_CONFIG_CONTENT; the repository's and the
|
|
3
|
+
* user's configs are ignored). OpenCode 1.19.5 appends this `permission` object AFTER its built-in agent rules and the
|
|
4
|
+
* last matching rule wins (measured), so `"*": "deny"` first, then the few allows, then the denies they must not cover.
|
|
5
|
+
* No rule can resolve to `ask` (spec anti-goal) — test/config.test.ts replays the measured evaluation order.
|
|
6
|
+
*/
|
|
7
|
+
import { PROTECTED_WRITE_GLOBS, SECRET_READ_GLOBS } from '../../../packages/rules/src/index.js';
|
|
8
|
+
import { stepLimit } from "./facts.js";
|
|
9
|
+
/** Taskquoin globs → OpenCode wildcards (`*` spans `/`): as given (relative) and under any prefix (absolute paths). */
|
|
10
|
+
function patterns(globs) {
|
|
11
|
+
const out = new Set();
|
|
12
|
+
for (const g of globs) {
|
|
13
|
+
const w = g.replace(/\*\*\/?/g, '*');
|
|
14
|
+
out.add(w);
|
|
15
|
+
if (!w.startsWith('*'))
|
|
16
|
+
out.add(`*/${w}`);
|
|
17
|
+
}
|
|
18
|
+
return [...out];
|
|
19
|
+
}
|
|
20
|
+
const deny = (globs) => Object.fromEntries(patterns(globs).map(p => [p, 'deny']));
|
|
21
|
+
export function opencodeConfig(o) {
|
|
22
|
+
return {
|
|
23
|
+
$schema: 'https://opencode.ai/config.json',
|
|
24
|
+
autoupdate: false, share: 'disabled', lsp: false, formatter: false, mcp: {}, plugin: [], instructions: [],
|
|
25
|
+
permission: {
|
|
26
|
+
'*': 'deny',
|
|
27
|
+
read: { '*': 'allow', ...deny(SECRET_READ_GLOBS) },
|
|
28
|
+
list: 'allow', glob: 'allow', grep: 'allow',
|
|
29
|
+
...(o.write ? { edit: { '*': 'allow', ...deny([...PROTECTED_WRITE_GLOBS, ...SECRET_READ_GLOBS]) } } : {}),
|
|
30
|
+
},
|
|
31
|
+
...(o.maxTurns ? stepLimit(o.maxTurns) : {}),
|
|
32
|
+
};
|
|
33
|
+
}
|