oh-my-opencode 4.9.1 → 4.10.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/.agents/skills/opencode-qa/SKILL.md +1 -0
- package/.agents/skills/opencode-qa/scripts/lib/common.sh +39 -1
- package/.agents/skills/opencode-qa/scripts/lib/fake-openai-branches.mjs +39 -0
- package/.agents/skills/opencode-qa/scripts/lib/fake-openai-events.mjs +106 -0
- package/.agents/skills/opencode-qa/scripts/lib/fake-openai-server.mjs +117 -0
- package/.agents/skills/opencode-qa/scripts/serve-wake-split-probe.sh +716 -0
- package/.agents/skills/tech-debt-audit/SKILL.md +277 -0
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/outputs/execution-plan.md +1 -1
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/outputs/execution-plan.md +1 -1
- package/bin/platform.js +5 -0
- package/bin/platform.test.ts +56 -0
- package/dist/agents/atlas/agent.d.ts +4 -3
- package/dist/agents/gpt-apply-patch-guard.d.ts +2 -2
- package/dist/agents/hephaestus/agent.d.ts +5 -0
- package/dist/agents/hephaestus/index.d.ts +1 -1
- package/dist/agents/metis.d.ts +1 -0
- package/dist/agents/prometheus/system-prompt.d.ts +1 -1
- package/dist/agents/sisyphus/kimi-k2-7.d.ts +17 -0
- package/dist/agents/sisyphus-junior/agent.d.ts +1 -1
- package/dist/agents/sisyphus-junior/kimi-k2-7.d.ts +11 -0
- package/dist/agents/types.d.ts +2 -2
- package/dist/cli/doctor/checks/codex-components.d.ts +13 -0
- package/dist/cli/doctor/checks/tui-plugin-config.d.ts +1 -0
- package/dist/cli/doctor/constants.d.ts +1 -1
- package/dist/cli/index.js +32329 -31437
- package/dist/cli/install-codex/codex-cleanup.d.ts +4 -0
- package/dist/cli/install-codex/install-codex-test-fixtures.d.ts +34 -0
- package/dist/cli/install-codex/link-cached-plugin-agents.d.ts +4 -0
- package/dist/cli/model-fallback.d.ts +1 -0
- package/dist/cli/provider-availability.d.ts +2 -0
- package/dist/cli-node/index.js +32329 -31437
- package/dist/config/schema/agent-overrides.d.ts +80 -16
- package/dist/config/schema/experimental.d.ts +1 -1
- package/dist/config/schema/hooks.d.ts +0 -1
- package/dist/config/schema/internal/permission.d.ts +5 -1
- package/dist/config/schema/oh-my-opencode-config.d.ts +76 -16
- package/dist/create-hooks.d.ts +0 -1
- package/dist/features/background-agent/index.d.ts +1 -1
- package/dist/features/background-agent/manager.d.ts +6 -0
- package/dist/features/background-agent/types.d.ts +2 -0
- package/dist/features/claude-code-plugin-loader/types.d.ts +3 -0
- package/dist/features/claude-code-session-state/state.d.ts +1 -0
- package/dist/features/skill-mcp-manager/manager.d.ts +11 -7
- package/dist/features/team-mode/team-mailbox/pending-delivery-recovery.d.ts +31 -0
- package/dist/features/team-mode/team-runtime/delete-team.d.ts +2 -1
- package/dist/features/team-mode/tools/lifecycle-inline-spec.d.ts +2 -2
- package/dist/features/tmux-subagent/stale-tmux-resource-sweeper.d.ts +12 -0
- package/dist/features/tool-metadata-store/store.d.ts +5 -0
- package/dist/hooks/anthropic-context-window-limit-recovery/storage/constants.d.ts +3 -0
- package/dist/hooks/{session-recovery → anthropic-context-window-limit-recovery}/storage/messages-reader.d.ts +1 -1
- package/dist/hooks/{session-recovery → anthropic-context-window-limit-recovery}/storage/part-content.d.ts +1 -1
- package/dist/hooks/{session-recovery → anthropic-context-window-limit-recovery}/storage/parts-reader.d.ts +1 -1
- package/dist/hooks/{session-recovery → anthropic-context-window-limit-recovery/storage}/types.d.ts +0 -13
- package/dist/hooks/auto-update-checker/checker/bundled-version.d.ts +1 -0
- package/dist/hooks/auto-update-checker/checker.d.ts +1 -0
- package/dist/hooks/auto-update-checker/constants.d.ts +3 -3
- package/dist/hooks/auto-update-checker/hook.d.ts +2 -1
- package/dist/hooks/claude-code-hooks/types.d.ts +4 -0
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/team-session-events/team-idle-wake-hint.d.ts +5 -0
- package/dist/index.js +6061 -3714
- package/dist/oh-my-opencode.schema.json +123 -18
- package/dist/plugin/build-team-idle-wake-hint-client.d.ts +2 -0
- package/dist/plugin/event-session-lifecycle.d.ts +0 -3
- package/dist/plugin/hooks/create-continuation-hooks.d.ts +0 -6
- package/dist/plugin/hooks/create-core-hooks.d.ts +0 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +1 -2
- package/dist/shared/command-executor/execute-hook-command.d.ts +7 -0
- package/dist/shared/internal-initiator-marker.d.ts +7 -0
- package/dist/shared/live-server-route.d.ts +24 -0
- package/dist/shared/plugin-identity.d.ts +2 -2
- package/dist/shared/prompt-async-gate/prompt-message-state.d.ts +1 -0
- package/dist/shared/tmux/tmux-utils/server-health.d.ts +2 -1
- package/dist/shared/tmux/tmux-utils/stale-attach-pane-sweep.d.ts +16 -0
- package/dist/shared/tmux/tmux-utils.d.ts +1 -0
- package/dist/testing/create-plugin-module.d.ts +4 -0
- package/dist/tools/background-task/clients.d.ts +2 -0
- package/dist/tools/background-task/full-session-format.d.ts +1 -0
- package/dist/tools/background-task/types.d.ts +1 -0
- package/dist/tools/delegate-task/sync-prompt-sender.d.ts +1 -1
- package/dist/tools/delegate-task/sync-session-lifecycle.d.ts +2 -1
- package/dist/tools/look-at/look-at-input-preparer.d.ts +6 -2
- package/dist/tools/look-at/look-at-prompt.d.ts +2 -1
- package/dist/tools/look-at/look-at-session-runner.d.ts +3 -4
- package/dist/tools/look-at/types.d.ts +2 -0
- package/dist/tools/session-manager/types.d.ts +1 -0
- package/dist/tools/skill-mcp/types.d.ts +1 -0
- package/package.json +14 -13
- package/packages/ast-grep-mcp/dist/cli.js +50 -17
- package/packages/lsp-daemon/dist/cli.js +8 -5
- package/packages/lsp-daemon/dist/index.js +8 -5
- package/packages/lsp-tools-mcp/dist/lsp/connection.js +1 -1
- package/packages/lsp-tools-mcp/dist/lsp/server-definitions.js +2 -2
- package/packages/lsp-tools-mcp/dist/lsp/transport.d.ts +10 -1
- package/packages/lsp-tools-mcp/dist/lsp/transport.js +6 -3
- package/packages/omo-codex/lazycodex-repository/.github/workflows/pr-source-guidance.yml +11 -12
- package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/dist/cli.js +2583 -0
- package/packages/omo-codex/plugin/components/bootstrap/hooks/hooks.json +17 -0
- package/packages/omo-codex/plugin/components/bootstrap/manifests/ast-grep.json +22 -0
- package/packages/omo-codex/plugin/components/bootstrap/manifests/node.json +10 -0
- package/packages/omo-codex/plugin/components/bootstrap/package.json +20 -0
- package/packages/omo-codex/plugin/components/bootstrap/scripts/bootstrap.ps1 +310 -0
- package/packages/omo-codex/plugin/components/bootstrap/scripts/build.mjs +35 -0
- package/packages/omo-codex/plugin/components/bootstrap/scripts/generate-manifests.mjs +115 -0
- package/packages/omo-codex/plugin/components/bootstrap/src/cli.ts +153 -0
- package/packages/omo-codex/plugin/components/bootstrap/src/download.ts +212 -0
- package/packages/omo-codex/plugin/components/bootstrap/src/environment.ts +286 -0
- package/packages/omo-codex/plugin/components/bootstrap/src/hook.ts +108 -0
- package/packages/omo-codex/plugin/components/bootstrap/src/provision.ts +243 -0
- package/packages/omo-codex/plugin/components/bootstrap/src/setup.ts +294 -0
- package/packages/omo-codex/plugin/components/bootstrap/src/worker.ts +279 -0
- package/packages/omo-codex/plugin/components/bootstrap/test/download.test.ts +295 -0
- package/packages/omo-codex/plugin/components/bootstrap/test/environment.test.ts +375 -0
- package/packages/omo-codex/plugin/components/bootstrap/test/provision.test.ts +464 -0
- package/packages/omo-codex/plugin/components/bootstrap/tsconfig.json +25 -0
- package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/package.json +4 -4
- package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/git-bash/package.json +2 -2
- package/packages/omo-codex/plugin/components/lsp/dist/codex-hook-cli.js +6 -10
- package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/lsp/package.json +4 -4
- package/packages/omo-codex/plugin/components/lsp/scripts/build-lsp-tools.test.mjs +8 -3
- package/packages/omo-codex/plugin/components/lsp/src/codex-hook-cli.ts +5 -8
- package/packages/omo-codex/plugin/components/lsp/test/codex-hook-cli.test.ts +24 -1
- package/packages/omo-codex/plugin/components/rules/bundled-rules/windows-git-bash.md +3 -1
- package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
- package/packages/omo-codex/plugin/components/rules/package.json +4 -4
- package/packages/omo-codex/plugin/components/rules/test/windows-git-bash-bundled-rule.test.ts +35 -1
- package/packages/omo-codex/plugin/components/start-work-continuation/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/start-work-continuation/package.json +4 -4
- package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/package.json +4 -4
- package/packages/omo-codex/plugin/components/ultrawork/biome.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/directive.md +155 -99
- package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/package.json +4 -4
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/SKILL.md +19 -51
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/references/full-workflow.md +46 -51
- package/packages/omo-codex/plugin/components/ultrawork/test/codex-hook.test.ts +19 -0
- package/packages/omo-codex/plugin/components/ultrawork/test/package-smoke.test.ts +0 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-commands.js +9 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-output.d.ts +1 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-output.js +18 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-crud.js +1 -3
- package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/ulw-loop/package.json +4 -4
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli-commands.ts +6 -2
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli-output.ts +19 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/plan-crud.ts +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-commands.test.ts +6 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-complete-goals.test.ts +26 -1
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-json-errors.test.ts +89 -0
- package/packages/omo-codex/plugin/hooks/hooks.json +27 -16
- package/packages/omo-codex/plugin/package-lock.json +193 -193
- package/packages/omo-codex/plugin/package.json +1 -1
- package/packages/omo-codex/plugin/scripts/auto-update-state.d.mts +20 -0
- package/packages/omo-codex/plugin/scripts/auto-update.mjs +28 -8
- package/packages/omo-codex/plugin/scripts/build-components.mjs +36 -5
- package/packages/omo-codex/plugin/scripts/install-flow.mjs +43 -0
- package/packages/omo-codex/plugin/skills/lcx-contribute-bug-fix/SKILL.md +79 -28
- package/packages/omo-codex/plugin/skills/lcx-contribute-bug-fix/agents/openai.yaml +2 -2
- package/packages/omo-codex/plugin/skills/lcx-report-bug/SKILL.md +7 -6
- package/packages/omo-codex/plugin/skills/lcx-report-bug/agents/openai.yaml +1 -1
- package/packages/omo-codex/plugin/skills/ulw-plan/SKILL.md +19 -51
- package/packages/omo-codex/plugin/skills/ulw-plan/references/full-workflow.md +46 -51
- package/packages/omo-codex/plugin/test/aggregate-manifest.test.mjs +1 -0
- package/packages/omo-codex/plugin/test/auto-update.test.mjs +145 -0
- package/packages/omo-codex/plugin/test/bootstrap-binlinks.test.mjs +250 -0
- package/packages/omo-codex/plugin/test/bootstrap-hooks.test.mjs +166 -0
- package/packages/omo-codex/plugin/test/bootstrap-orchestration.test.mjs +371 -0
- package/packages/omo-codex/plugin/test/bootstrap-ps-guard.test.mjs +134 -0
- package/packages/omo-codex/plugin/test/bootstrap-setup.test.mjs +249 -0
- package/packages/omo-codex/plugin/test/lcx-bug-skills.test.mjs +10 -1
- package/packages/omo-codex/plugin/test/ulw-plan-skill.test.mjs +46 -0
- package/packages/omo-codex/scripts/atomic-write.test.mjs +82 -0
- package/packages/omo-codex/scripts/install/agents.d.mts +18 -0
- package/packages/omo-codex/scripts/install/agents.mjs +78 -5
- package/packages/omo-codex/scripts/install/atomic-write.mjs +59 -0
- package/packages/omo-codex/scripts/install/bin-dir.d.mts +7 -0
- package/packages/omo-codex/scripts/install/bin-links.d.mts +18 -0
- package/packages/omo-codex/scripts/install/config.d.mts +35 -0
- package/packages/omo-codex/scripts/install/config.mjs +13 -3
- package/packages/omo-codex/scripts/install/git-bash-mcp-env.d.mts +5 -0
- package/packages/omo-codex/scripts/install/git-bash.d.mts +23 -0
- package/packages/omo-codex/scripts/install/hook-trust.d.mts +10 -0
- package/packages/omo-codex/scripts/install-agent-links.test.mjs +41 -0
- package/packages/omo-codex/scripts/install-local.mjs +3 -2
- package/packages/shared-skills/skills/lcx-contribute-bug-fix/SKILL.md +79 -28
- package/packages/shared-skills/skills/lcx-contribute-bug-fix/agents/openai.yaml +2 -2
- package/packages/shared-skills/skills/lcx-report-bug/SKILL.md +7 -6
- package/packages/shared-skills/skills/lcx-report-bug/agents/openai.yaml +1 -1
- package/dist/hooks/session-recovery/constants.d.ts +0 -4
- package/dist/hooks/session-recovery/detect-error-type.d.ts +0 -4
- package/dist/hooks/session-recovery/error-recovery.d.ts +0 -4
- package/dist/hooks/session-recovery/hook-types.d.ts +0 -22
- package/dist/hooks/session-recovery/hook.d.ts +0 -4
- package/dist/hooks/session-recovery/index.d.ts +0 -5
- package/dist/hooks/session-recovery/interrupted-idle-message-fetch-timeout.d.ts +0 -7
- package/dist/hooks/session-recovery/interrupted-tool-results.d.ts +0 -3
- package/dist/hooks/session-recovery/message-state.d.ts +0 -4
- package/dist/hooks/session-recovery/recover-thinking-block-order.d.ts +0 -5
- package/dist/hooks/session-recovery/recover-thinking-disabled-violation.d.ts +0 -5
- package/dist/hooks/session-recovery/recover-tool-result-missing.d.ts +0 -10
- package/dist/hooks/session-recovery/recover-unavailable-tool.d.ts +0 -5
- package/dist/hooks/session-recovery/resume.d.ts +0 -7
- package/dist/hooks/session-recovery/storage/latest-assistant-message.d.ts +0 -5
- package/dist/hooks/session-recovery/storage/orphan-thinking-search.d.ts +0 -2
- package/dist/hooks/session-recovery/storage/thinking-block-search.d.ts +0 -2
- package/dist/hooks/session-recovery/storage/thinking-prepend.d.ts +0 -33
- package/dist/hooks/session-recovery/storage/thinking-strip.d.ts +0 -11
- package/dist/hooks/session-recovery/storage.d.ts +0 -20
- package/dist/plugin/event-session-recovery.d.ts +0 -9
- package/dist/plugin/user-abort-interrupted-recovery-guard.d.ts +0 -6
- /package/dist/hooks/{session-recovery → anthropic-context-window-limit-recovery}/storage/empty-messages.d.ts +0 -0
- /package/dist/hooks/{session-recovery → anthropic-context-window-limit-recovery}/storage/empty-text.d.ts +0 -0
- /package/dist/hooks/{session-recovery → anthropic-context-window-limit-recovery}/storage/message-dir.d.ts +0 -0
- /package/dist/hooks/{session-recovery → anthropic-context-window-limit-recovery}/storage/part-id.d.ts +0 -0
- /package/dist/hooks/{session-recovery → anthropic-context-window-limit-recovery}/storage/text-part-injector.d.ts +0 -0
|
@@ -54,6 +54,7 @@ sandbox, free port, server start/stop, and an EXIT-trap cleanup). It requires
|
|
|
54
54
|
| Export a whole session as JSON | D | `scripts/export-roundtrip.sh <ses_id>` | `references/db-investigation.md` |
|
|
55
55
|
| Check the HTTP server / an endpoint | B | `scripts/server-smoke.sh` | `references/server-api.md` |
|
|
56
56
|
| Prove a hook / action / event fired | B | `scripts/sse-hook-probe.sh` | `references/events-hooks.md` |
|
|
57
|
+
| Prove serve-topology wake runner-split (reproduced/fixed) | B | `scripts/serve-wake-split-probe.sh --expect reproduced\|fixed --evidence-dir DIR` (self-test: `--self-test`; fake LLM: `scripts/lib/fake-openai-server.mjs`) | `references/events-hooks.md` |
|
|
57
58
|
| Smoke-test the TUI | C | `scripts/tui-smoke.sh` | `references/tui-tmux.md` |
|
|
58
59
|
| Write/run a test in the opencode source | - | (bun test) | `references/testing-harness.md` |
|
|
59
60
|
| Drive opencode from a Bun/TS script | - | (SDK) | `references/sdk.md` |
|
|
@@ -54,6 +54,16 @@ oqa_db_query() {
|
|
|
54
54
|
opencode db "$1" --format json 2>/dev/null
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
# Preserve HOME-based opencode shims after HOME is sandboxed. Some installed
|
|
58
|
+
# opencode wrappers resolve the real binary via "$HOME/.opencode/bin/opencode";
|
|
59
|
+
# after oqa_mk_isolated_xdg rewrites HOME, that path must still exist.
|
|
60
|
+
oqa_preserve_home_opencode_bin() {
|
|
61
|
+
local real_home="$1" sandbox_home="$2"
|
|
62
|
+
[ -d "$real_home/.opencode/bin" ] || return 0
|
|
63
|
+
mkdir -p "$sandbox_home/.opencode" || return 1
|
|
64
|
+
ln -s "$real_home/.opencode/bin" "$sandbox_home/.opencode/bin" 2>/dev/null || return 1
|
|
65
|
+
}
|
|
66
|
+
|
|
57
67
|
# Create an isolated XDG sandbox so a spawned opencode never touches the real
|
|
58
68
|
# DB. Sets globals OQA_XDG_ROOT + OQA_PROJ and exports XDG_*; registers the
|
|
59
69
|
# root for cleanup.
|
|
@@ -63,10 +73,12 @@ oqa_db_query() {
|
|
|
63
73
|
# oqa_mk_isolated_xdg # good
|
|
64
74
|
# root="$OQA_XDG_ROOT" # read the global afterwards
|
|
65
75
|
oqa_mk_isolated_xdg() {
|
|
66
|
-
local root
|
|
76
|
+
local root real_home
|
|
67
77
|
root="$(mktemp -d -t oqa-xdg.XXXXXX)" || return 1
|
|
78
|
+
real_home="$HOME"
|
|
68
79
|
OQA_TMPDIRS+=("$root")
|
|
69
80
|
mkdir -p "$root/data" "$root/config" "$root/cache" "$root/state" "$root/home" "$root/proj"
|
|
81
|
+
oqa_preserve_home_opencode_bin "$real_home" "$root/home" || return 1
|
|
70
82
|
export OQA_XDG_ROOT="$root"
|
|
71
83
|
export HOME="$root/home"
|
|
72
84
|
export OPENCODE_TEST_HOME="$root/home"
|
|
@@ -214,6 +226,32 @@ oqa__self_check() {
|
|
|
214
226
|
oqa_log "FAIL: sandbox HOME not isolated (HOME='$home' OPENCODE_TEST_HOME='$test_home' root='$isodir')"; fails=$((fails+1))
|
|
215
227
|
fi
|
|
216
228
|
|
|
229
|
+
local shim_marker shim_result
|
|
230
|
+
shim_marker="$(mktemp -t oqa-shim.XXXXXX)"
|
|
231
|
+
bash -c '
|
|
232
|
+
set -u
|
|
233
|
+
. "'"${BASH_SOURCE[0]}"'"
|
|
234
|
+
fake_home="$(mktemp -d -t oqa-fake-home.XXXXXX)"
|
|
235
|
+
mkdir -p "$fake_home/.local/bin" "$fake_home/.opencode/bin"
|
|
236
|
+
printf "%s\n" "#!/usr/bin/env bash" "exec \"\$HOME/.opencode/bin/opencode\" \"\$@\"" > "$fake_home/.local/bin/opencode"
|
|
237
|
+
printf "%s\n" "#!/usr/bin/env bash" "exec \"\$HOME/.opencode/bin/opencode-real\" \"\$@\"" > "$fake_home/.opencode/bin/opencode"
|
|
238
|
+
printf "%s\n" "#!/usr/bin/env bash" "printf fake-opencode-ok" > "$fake_home/.opencode/bin/opencode-real"
|
|
239
|
+
chmod +x "$fake_home/.local/bin/opencode" "$fake_home/.opencode/bin/opencode" "$fake_home/.opencode/bin/opencode-real"
|
|
240
|
+
HOME="$fake_home"
|
|
241
|
+
PATH="$fake_home/.local/bin:$PATH"
|
|
242
|
+
oqa_mk_isolated_xdg
|
|
243
|
+
opencode > "'"$shim_marker"'"
|
|
244
|
+
oqa_cleanup
|
|
245
|
+
rm -rf "$fake_home"
|
|
246
|
+
'
|
|
247
|
+
shim_result="$(cat "$shim_marker" 2>/dev/null)"
|
|
248
|
+
rm -f "$shim_marker"
|
|
249
|
+
if [ "$shim_result" = "fake-opencode-ok" ]; then
|
|
250
|
+
oqa_pass "isolated HOME preserves HOME-based opencode shim"
|
|
251
|
+
else
|
|
252
|
+
oqa_log "FAIL: HOME-based opencode shim returned '$shim_result'"; fails=$((fails+1))
|
|
253
|
+
fi
|
|
254
|
+
|
|
217
255
|
if [ "$fails" -eq 0 ]; then
|
|
218
256
|
oqa_pass "common.sh self-check"
|
|
219
257
|
return 0
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export const branchCounts = {
|
|
2
|
+
title: 0,
|
|
3
|
+
"parent-tool-call": 0,
|
|
4
|
+
"parent-hold": 0,
|
|
5
|
+
child: 0,
|
|
6
|
+
wake: 0,
|
|
7
|
+
default: 0,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const latches = {
|
|
11
|
+
parentToolCallIssued: false,
|
|
12
|
+
parentHoldIssued: false,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function hasToolResult(inputStr) {
|
|
16
|
+
return (
|
|
17
|
+
inputStr.includes('"type":"function_call_output"') ||
|
|
18
|
+
inputStr.includes('"type": "function_call_output"') ||
|
|
19
|
+
inputStr.includes('"type":"tool_result"') ||
|
|
20
|
+
inputStr.includes('"type": "tool_result"') ||
|
|
21
|
+
inputStr.includes('"role":"tool"') ||
|
|
22
|
+
inputStr.includes('"role": "tool"')
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function selectBranch(inputStr) {
|
|
27
|
+
const isTitle = inputStr.includes("Generate a title")
|
|
28
|
+
const isSplitProbe = inputStr.includes("Run the split probe")
|
|
29
|
+
const isChild = inputStr.includes("SPLIT_CHILD_TASK")
|
|
30
|
+
const isWake = inputStr.includes("[BACKGROUND TASK")
|
|
31
|
+
const hasResult = hasToolResult(inputStr)
|
|
32
|
+
|
|
33
|
+
if (isTitle) return "title"
|
|
34
|
+
if (isChild && !isSplitProbe) return "child"
|
|
35
|
+
if (isWake) return "wake"
|
|
36
|
+
if (isSplitProbe && !hasResult && !latches.parentToolCallIssued) return "parent-tool-call"
|
|
37
|
+
if (isSplitProbe && (hasResult || latches.parentToolCallIssued) && !latches.parentHoldIssued) return "parent-hold"
|
|
38
|
+
return "default"
|
|
39
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import fs from "node:fs"
|
|
2
|
+
|
|
3
|
+
export function completedUsage() {
|
|
4
|
+
return {
|
|
5
|
+
input_tokens: 10,
|
|
6
|
+
output_tokens: 5,
|
|
7
|
+
input_tokens_details: { cached_tokens: 0 },
|
|
8
|
+
output_tokens_details: { reasoning_tokens: 0 },
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function sendSse(res, events) {
|
|
13
|
+
res.writeHead(200, {
|
|
14
|
+
"content-type": "text/event-stream; charset=utf-8",
|
|
15
|
+
"cache-control": "no-cache",
|
|
16
|
+
connection: "keep-alive",
|
|
17
|
+
})
|
|
18
|
+
for (const event of events) {
|
|
19
|
+
res.write(`data: ${JSON.stringify(event)}\n\n`)
|
|
20
|
+
}
|
|
21
|
+
res.write("data: [DONE]\n\n")
|
|
22
|
+
res.end()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function textEvents(callCount, text) {
|
|
26
|
+
const id = `resp_${callCount}`
|
|
27
|
+
const item = `msg_${callCount}`
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
type: "response.created",
|
|
31
|
+
response: { id, created_at: Math.floor(Date.now() / 1000), model: "gpt-fake" },
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
type: "response.output_item.added",
|
|
35
|
+
output_index: 0,
|
|
36
|
+
item: { type: "message", id: item },
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: "response.output_text.delta",
|
|
40
|
+
item_id: item,
|
|
41
|
+
output_index: 0,
|
|
42
|
+
delta: text,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: "response.output_item.done",
|
|
46
|
+
output_index: 0,
|
|
47
|
+
item: { type: "message", id: item },
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
type: "response.completed",
|
|
51
|
+
response: { usage: completedUsage() },
|
|
52
|
+
},
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function toolCallEvents(callCount, name, callId, argsObj) {
|
|
57
|
+
const id = `resp_${callCount}`
|
|
58
|
+
const fcId = `fc_${callCount}`
|
|
59
|
+
const argsStr = JSON.stringify(argsObj)
|
|
60
|
+
return [
|
|
61
|
+
{
|
|
62
|
+
type: "response.created",
|
|
63
|
+
response: { id, created_at: Math.floor(Date.now() / 1000), model: "gpt-fake" },
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
type: "response.output_item.added",
|
|
67
|
+
output_index: 0,
|
|
68
|
+
item: {
|
|
69
|
+
type: "function_call",
|
|
70
|
+
id: fcId,
|
|
71
|
+
call_id: callId,
|
|
72
|
+
name,
|
|
73
|
+
arguments: "",
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type: "response.function_call_arguments.delta",
|
|
78
|
+
item_id: fcId,
|
|
79
|
+
output_index: 0,
|
|
80
|
+
delta: argsStr,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: "response.output_item.done",
|
|
84
|
+
output_index: 0,
|
|
85
|
+
item: {
|
|
86
|
+
type: "function_call",
|
|
87
|
+
id: fcId,
|
|
88
|
+
call_id: callId,
|
|
89
|
+
name,
|
|
90
|
+
arguments: argsStr,
|
|
91
|
+
status: "completed",
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
type: "response.completed",
|
|
96
|
+
response: { usage: completedUsage() },
|
|
97
|
+
},
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function appendLog(logFile, line) {
|
|
102
|
+
try {
|
|
103
|
+
fs.appendFileSync(logFile, line)
|
|
104
|
+
} catch {
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import http from "node:http"
|
|
3
|
+
import fs from "node:fs"
|
|
4
|
+
import path from "node:path"
|
|
5
|
+
import os from "node:os"
|
|
6
|
+
import { sendSse, textEvents, toolCallEvents, appendLog } from "./fake-openai-events.mjs"
|
|
7
|
+
import { branchCounts, latches, selectBranch } from "./fake-openai-branches.mjs"
|
|
8
|
+
|
|
9
|
+
const requestedPort = Number(process.env.FAKE_OPENAI_PORT ?? 0)
|
|
10
|
+
const logFile = process.env.FAKE_LLM_LOG ?? path.join(os.tmpdir(), "fake-llm.log")
|
|
11
|
+
|
|
12
|
+
let callCount = 0
|
|
13
|
+
|
|
14
|
+
function logBranch(branch, extra = {}) {
|
|
15
|
+
const now = new Date().toISOString()
|
|
16
|
+
const line = `[${now}] branch=${branch} call=${callCount}${Object.keys(extra).length ? " " + JSON.stringify(extra) : ""}\n`
|
|
17
|
+
appendLog(logFile, line)
|
|
18
|
+
process.stdout.write(line)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function readBody(req) {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
const chunks = []
|
|
24
|
+
req.on("data", (chunk) => chunks.push(chunk))
|
|
25
|
+
req.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")))
|
|
26
|
+
req.on("error", reject)
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function sleep(ms) {
|
|
31
|
+
return new Promise((resolve) => setTimeout(resolve, ms))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const server = http.createServer(async (req, res) => {
|
|
35
|
+
if (req.method === "GET" && req.url === "/health") {
|
|
36
|
+
res.writeHead(200, { "content-type": "text/plain" }).end("ok")
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (req.method !== "POST" || !req.url?.includes("/responses")) {
|
|
41
|
+
res.writeHead(404, { "content-type": "application/json" }).end(JSON.stringify({ error: "not found" }))
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
callCount++
|
|
46
|
+
const raw = await readBody(req)
|
|
47
|
+
let body
|
|
48
|
+
try { body = JSON.parse(raw) } catch { body = {} }
|
|
49
|
+
|
|
50
|
+
const inputStr = JSON.stringify(body.input ?? body.messages ?? body)
|
|
51
|
+
const branch = selectBranch(inputStr)
|
|
52
|
+
branchCounts[branch] = (branchCounts[branch] ?? 0) + 1
|
|
53
|
+
logBranch(branch)
|
|
54
|
+
|
|
55
|
+
if (branch === "title") {
|
|
56
|
+
sendSse(res, textEvents(callCount, "wake split probe session"))
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (branch === "child") {
|
|
61
|
+
sendSse(res, textEvents(callCount, "DONE"))
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (branch === "wake") {
|
|
66
|
+
await sleep(3000)
|
|
67
|
+
sendSse(res, textEvents(callCount, `WAKE_ACK ${callCount}`))
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (branch === "parent-tool-call") {
|
|
72
|
+
latches.parentToolCallIssued = true
|
|
73
|
+
sendSse(res, toolCallEvents(callCount, "task", `call_agent_${callCount}`, {
|
|
74
|
+
description: "split probe child",
|
|
75
|
+
prompt: "SPLIT_CHILD_TASK: reply exactly DONE",
|
|
76
|
+
subagent_type: "explore",
|
|
77
|
+
run_in_background: true,
|
|
78
|
+
load_skills: [],
|
|
79
|
+
}))
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (branch === "parent-hold") {
|
|
84
|
+
latches.parentHoldIssued = true
|
|
85
|
+
sendSse(res, toolCallEvents(callCount, "bash", `call_bash_${callCount}`, {
|
|
86
|
+
command: "i=0; while [ $i -lt 8 ]; do i=$((i+1)); sleep 1; done",
|
|
87
|
+
description: "hold turn",
|
|
88
|
+
}))
|
|
89
|
+
return
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (inputStr.includes("say exactly: TUI_NOREG_OK")) {
|
|
93
|
+
sendSse(res, textEvents(callCount, "TUI_NOREG_OK"))
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
sendSse(res, textEvents(callCount, `fake response ${callCount}`))
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
function logFinalCounts() {
|
|
100
|
+
const summary = Object.entries(branchCounts).map(([k, v]) => `${k}=${v}`).join(" ")
|
|
101
|
+
const line = `[${new Date().toISOString()}] FINAL_COUNTS ${summary}\n`
|
|
102
|
+
appendLog(logFile, line)
|
|
103
|
+
process.stdout.write(line)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
server.listen(requestedPort, "127.0.0.1", () => {
|
|
107
|
+
const addr = server.address()
|
|
108
|
+
const port = typeof addr === "object" && addr !== null ? addr.port : requestedPort
|
|
109
|
+
try {
|
|
110
|
+
fs.mkdirSync(path.dirname(logFile), { recursive: true })
|
|
111
|
+
appendLog(logFile, `[${new Date().toISOString()}] START port=${port}\n`)
|
|
112
|
+
} catch {}
|
|
113
|
+
process.stdout.write(`fake-openai listening on ${port}\n`)
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
process.on("SIGTERM", () => { logFinalCounts(); server.close(() => process.exit(0)) })
|
|
117
|
+
process.on("SIGINT", () => { logFinalCounts(); server.close(() => process.exit(0)) })
|