--- created: 2026-03-28 tags: [cli-jaw, infra, runtime, core] aliases: [CLI-JAW Infra, infrastructure modules, core runtime] --- > ๐Ÿ“š [INDEX](INDEX.md) ยท [์—์ด์ „ํŠธ ์‹คํ–‰ โ†—](agent_spawn.md) ยท [์„œ๋ฒ„ API โ†—](server_api.md) ยท **์ธํ”„๋ผ ๋ชจ๋“ˆ** # ์ธํ”„๋ผ ๋ชจ๋“ˆ โ€” core/ ยท messaging/ ยท telegram/ ยท discord/ ยท memory/ ยท browser/ ยท routes/ ยท security/ ยท http/ ยท lib/mcp-sync > ์˜์กด 0 ๋ชจ๋“ˆ + ๋ฐ์ดํ„ฐ ๋ ˆ์ด์–ด + ๋ฉ€ํ‹ฐ ์ฑ„๋„ ๋ฉ”์‹œ์ง• + ์™ธ๋ถ€ ๋„๊ตฌ ํ†ตํ•ฉ > ํ˜„์žฌ tree ๊ธฐ์ค€์œผ๋กœ `src/core/`๋Š” support cluster, `src/messaging/`๋Š” Telegram/Discord ๊ณตํ†ต ๋Ÿฐํƒ€์ž„, `src/telegram/`ยท`src/discord/`๋Š” ๊ฐ ์ฑ„๋„ transport ๊ตฌํ˜„์œผ๋กœ ๋ถ„๋ฆฌ๋จ --- ## ์‹ค์ œ ์‹คํ–‰/๋ฐฐํฌ ํ‘œ๋ฉด โ€” `package.json` ยท Docker ยท CLI Print observation reuses the existing journal; `merge-tool-log.ts` is a pure merge owner, not another store. `getTraceToolEntry` recovers only an exact existing tool row through the established decoder/safe path and contains read errors. Snapshot hydration's explicit `knownOmitted` sanitizer option reserves the warning slot and retains a conservative prior loss count without double-counting overlapping reconstructed rows; default sanitizer callers preserve their previous additive append semantics. Native terminal updates remain frozen unless the print-only caller explicitly opts in. Activity persistence uses the existing SQLite trace tables: nullable `trace_runs.session_id/scope_key`, a session index, a runtime-row partial index and one unique control row per run. `activity-journal.ts` owns transactional append/read, `activity-control.ts` is the DB-only control leaf, and `activity-retention.ts` prunes raw rows before whole canonical prefixes. `store.ts` uses control/retention without importing the journal, avoiding a new store/journal cycle. Startup migration backfills only original message owners; chat deletion removes owned trace headers transactionally. Completed events are immutable; late conditional finalization cannot rewrite completed control. Spill cleanup never follows symlinked roots/directories. See `runtime-integration.md` for budgets/loss and `server_api.md` for owner-bound reads. ### Package metadata | ํ•ญ๋ชฉ | ํ˜„์žฌ ๊ฐ’ | | --- | --- | | package | `cli-jaw` | | version | `2.2.4` | | type | `module` | | Node engine | `>=22.4.0` | | bin | `cli-jaw` โ†’ `dist/bin/cli-jaw.js`, `jaw` โ†’ `dist/bin/cli-jaw.js` | | published files | `dist/`, `public/`, `scripts/`, `package.json` | ### `package.json` scripts | script | command | | --- | --- | | `dev` | `tsx --env-file=.env server.ts` | | `ensure:native` | `node scripts/ensure-native-modules.cjs` | | `rebuild:native` | `npm rebuild better-sqlite3` | | `postinstall` | `node scripts/postinstall-guard.cjs` | | `clean:dist` | `node -e "const fs=require('fs');fs.rmSync('dist',{recursive:true,force:true});"` | | `check:copilot-gap` | `tsx scripts/check-copilot-gap.ts` | | `check:deps` | `tsx scripts/check-deps-offline.ts` | | `check:frontend-build-output` | `tsx scripts/check-web-ui-build-output.ts` | | `check:strict-baseline` | `node scripts/check-strict-baseline.mjs` | | `gate:redaction-sinks` | `node scripts/release-gates.mjs redaction-sinks` โ€” channel replies/sends/loggers must route through a credential masker | | `gate:electron-version` | `node scripts/release-gates.mjs electron-version` โ€” `electron/package.json` version must equal the root `package.json` so desktop artifacts carry the release version | | `sync:electron-version` | `node scripts/sync-electron-version.cjs` โ€” writes the root version into `electron/package.json` and its lockfile; called by `release.sh` before `gate:all` | | `gate:gate-docs` | `node scripts/release-gates.mjs gate-docs` โ€” `structure/INDEX.md` must list exactly the live gates, with the right count, and each must have its `gate:` npm script | | `gate:sidecar-prune-safety` | `node scripts/release-gates.mjs sidecar-prune-safety` โ€” the sidecar prune list must never delete a package the server imports (a packaged app died on `node-fetch`) | | `gate:native-load` | `node scripts/release-gates.mjs native-load` โ€” `node-pty` must actually `dlopen` and `spawn-helper` must genuinely execute. Both are resolved from `build/Release` or `prebuilds/-`: node-pty's install is `prebuild.js \|\| node-gyp rebuild`, so a matching prebuild skips the source build and `build/Release` is never created. Electron postinstall restores helper execute bits with `scripts/ensure-pty-spawn-helper.cjs`. Needs `electron/node_modules`, so it reports `SKIPPED` (exit 3) when absent and only hard-fails under `JAW_GATE_REQUIRE_NATIVE=1`, which `desktop-release.yml` sets after `npm ci --prefix electron` | | `gate:sidecar-smoke` | `node scripts/release-gates.mjs sidecar-smoke` โ€” target Node executes a byte-verified isolated artifact copy; finite imports and server import/listener/HTTP/stop/close have separate checks. Default absent bundle is `SKIPPED` (exit 3), never verified; explicit `--server-root` or `JAW_GATE_REQUIRE_SIDECAR=1` requires a real artifact. `--report NEW_FILE` selects retained evidence outside the artifact. | | `scripts/pick-gyp-python.sh` | prints a `python3` that can `import distutils`, which node-gyp still requires; wired into `electron:dist:mac` because Homebrew Python 3.12+ breaks the node-pty rebuild | | `i18n:registry` | `tsx scripts/i18n-registry.ts` | | `check:deps:online` | `bash scripts/check-deps-online.sh` | | `prebuild`, `pretest`, `pretest:all`, `pretest:integration`, `pretest:smoke` | `npm run ensure:native` | | `test` | `tsx --experimental-test-module-mocks tests/run.mts` โ€” programmatic driver, `isolation:'process'` + `concurrency:true`, fresh `CLI_JAW_HOME` per child, never `forceExit` (#661), per-file stall watchdog armed at a file's first result and bounded by `JAW_TEST_FILE_STALL_MS` (default 180000) unless `--watch`. Options: `--scope root,unit,integration,manager,browser,bin` (default `root,unit`), `--shard i/N` (byte-ordered round-robin, `tests/setup/shard.ts`), `--list` (print selection, exit 0) | | `test:shard` | `tsx --experimental-test-module-mocks tests/run.mts --scope root,unit --shard` โ€” `npm run test:shard -- 1/4` runs exactly what CI's `test 1/4` job runs | | `test:integration:all` | `tsx --experimental-test-module-mocks tests/run.mts --scope integration,manager,bin` โ€” CI's `integration` job set; `api-smoke` needs a server on `TEST_PORT` and fails closed when `CI` is set | | `test:all` | `tsx --experimental-test-module-mocks tests/run.mts --all` | | `test:integration` | `tsx --experimental-test-module-mocks --test tests/integration/*.test.ts` | | `test:coverage` | `tsx --experimental-test-module-mocks --experimental-test-coverage tests/run.mts --all` โ€” the driver turns the flag into `run({ coverage: true })` (node:test โ‰ฅ 22.10); the flag alone is ignored by the programmatic API | | `test:watch` | `tsx --experimental-test-module-mocks tests/run.mts --watch` | | `test:web-ui-runtime` | `tsx --import ./tests/setup/test-home.ts --experimental-test-module-mocks --test tests/unit/web-ui-runtime-*.test.ts tests/unit/web-ui-processblock-runtime.test.ts tests/unit/web-ui-mermaid-runtime.test.ts tests/unit/web-ui-sanitizer.test.ts tests/unit/web-ui-build-output-guard.test.ts` | | `test:events` | `tsx --test tests/events.test.ts` | | `test:telegram` | `tsx --test tests/telegram-forwarding.test.ts` | | `test:manager:browser` | `tsx --test tests/browser/manager-layout-smoke.test.ts` | | `test:smoke` | `node scripts/run-with-env.mjs TEST_PORT=3457 -- tsx --test tests/integration/api-smoke.test.ts` | | `smoke:opencode` | `tsx scripts/smoke/opencode-external-dir-smoke.ts` | | `verify:fresh-install` | `bash scripts/verify-fresh-install.sh` | | `collect:fresh-install-evidence` | `bash scripts/collect-fresh-install-evidence.sh` | | `audit:fresh-install-evidence` | `node scripts/audit-fresh-install-evidence.mjs` | | `verify:release-evidence` | `node scripts/verify-release-evidence.mjs` | | `test:fresh-install` | `tsx scripts/fresh-install-smoke.ts` | | `test:install-risk` | `node scripts/install-risk-gate.mjs` | | `check:cli-bin-links` | `node scripts/check-cli-bin-links.cjs` | | `build` | `bash scripts/atomic-build.sh` โ€” staged `dist/bin/cli-jaw.js` ์‹คํ–‰๊ถŒํ•œ์„ ๋ณด์žฅํ•œ ๋’ค atomic swap | | `postbuild` | `node scripts/link-current-nvm-bin.cjs` โ€” non-NVM Node์—์„œ๋Š” ๋งํฌ๋ฅผ skipํ•˜๋˜ `dist/bin/cli-jaw.js` chmod repair๋Š” ๋จผ์ € ์ˆ˜ํ–‰ | | `build:frontend` | `vite build --config vite.config.ts` | | `qa:manager-frontend` | `npm run build:frontend && npm run typecheck:frontend` | | `dev:frontend` | `vite --config vite.config.ts` | | `preview:frontend` | `vite preview --config vite.config.ts` | | `typecheck` | `tsc --noEmit` | | `typecheck:frontend` | `tsc --noEmit -p tsconfig.frontend.json` | | `gate:typecheck` / `gate:tests` / `gate:*` | `node scripts/release-gates.mjs ` | | `gate:all` | `node scripts/release-gates.mjs` | | `prepublishOnly` | `npm run build && npm run build:frontend && npm run check:frontend-build-output` | | `electron:dev` | `concurrently -k -n jaw,electron "node scripts/electron-dev-manager.mjs" "npm --prefix electron run dev"` | | `electron:dist:mac:signed` | Opt-in local Developer ID build with operator-provided signing configuration and `APPLE_ID`/`APPLE_APP_SPECIFIC_PASSWORD`/`APPLE_TEAM_ID`. Requests app notarization and a signed DMG, notarizes and staples the DMG (`scripts/notarize-mac-dmg.mjs`), then runs the packaged-sidecar smoke plus artifact, update-metadata, app and DMG signature verification. The default local command remains ad-hoc; the canonical desktop release workflow requires Team `U9ATA49N28` signing/notarization and fails closed. | | `verify:mac-signature` | Checks the built macOS app's Developer ID authority, hardened runtime, secure timestamp, nested signature, Gatekeeper assessment and stapled ticket. Source tests alone do not certify an artifact. | | `verify:mac-dmg` | Checks the single `electron/dist/*.dmg`: Developer ID authority and team, secure timestamp, `codesign --verify --strict`, Gatekeeper `--type open` primary-signature verdict reporting `Notarized Developer ID`, and a stapled ticket. | | `verify:electron-update-metadata` / `verify:electron-update-metadata:win` | The default macOS mode verifies the GitHub provider's per-release `latest-mac.yml`: version, safe ZIP name, size, SHA-512, blockmap, every other listed artifact (the post-staple DMG), and packaged provider. `--platform win` verifies `latest.yml`, exactly one basename-safe NSIS `.exe`, its size/SHA-512 and blockmap, matching legacy fields, and `win-unpacked/resources/app-update.yml`. The Windows feed is published, but the updater client stays disabled until Authenticode signing supplies a matching `publisherName`. | | `electron:build` | `npm --prefix electron run build` | | `sidecar:bundle` | `bash scripts/bundle-sidecar.sh darwin arm64` | | `electron:dist:mac` | `npm run build:frontend && npm run sidecar:bundle && npm --prefix electron run build && CSC_IDENTITY_AUTO_DISCOVERY=false npm --prefix electron run dist:mac && npm run electron:resign:mac && npm run check:electron-dist-mac-no-jwc && npm run check:electron-dist-mac-smoke && npm run check:app-icons`. With no signing identity configured, electron-builder skips mac signing and `afterSign`; the following re-sign step creates the final plain ad-hoc local artifact. The packaged smoke runs against `Contents/Resources/server`, after electron-builder's `extraResources` copy. | | `electron:resign:mac` | `codesign --force --deep --sign - electron/dist/mac-arm64/cli-jaw.app` โ€” plain ad-hoc only: no Developer ID authority, hardened-runtime option or secure timestamp. It is not a signed-release rehearsal. | | `electron:start` | `npm --prefix electron run start` | | `check:electron-sidecar-no-jwc` | `node scripts/check-electron-sidecar-no-jwc.cjs` | | `check:electron-dist-mac-no-jwc` | `node scripts/check-electron-sidecar-no-jwc.cjs --server-root electron/dist/mac-arm64/cli-jaw.app/Contents/Resources/server` | | `check:electron-dist-win-no-jwc` | `node scripts/check-electron-sidecar-no-jwc.cjs --server-root electron/dist/win-unpacked/resources/server` | | `check:electron-dist-linux-no-jwc` | `node scripts/check-electron-sidecar-no-jwc.cjs --server-root electron/dist/linux-unpacked/resources/server` | | `check:electron-dist-{mac,win,linux}-smoke` | Runs `scripts/check-sidecar-smoke.mjs` against the OS-specific packaged `Resources/server`/`resources/server` tree. These checks prove electron-builder retained the production dependency tree and that the packaged sidecar starts and serves; the release workflow runs them before either Actions-artifact or GitHub Release upload. | | `check:app-icons` | `node scripts/check-app-icon-assets.cjs` | | `check:electron-no-native` | `node scripts/check-electron-no-native.cjs` | For release preparation in a fresh clone, `(cd electron && npm ci)` runs Electronโ€™s project postinstall to restore `node-pty` spawn-helper execute bits. The manual equivalent from the repository root is `node scripts/ensure-pty-spawn-helper.cjs electron/node_modules/node-pty`. node-pty 1.1.0 prebuild helpers ship as `0644`; npm 11.20 and later `allowScripts` may skip dependency install scripts while the project postinstall still runs. > ํ˜„์žฌ `package.json`์—๋Š” `lint` script๊ฐ€ ์—†๋‹ค. ### Windows npm install integrity and PowerShell shims npm 12+ may block dependency lifecycle scripts unless `cli-jaw` is explicitly approved. The supported one-shot recovery is `npm install -g cli-jaw --allow-scripts=cli-jaw`; persist the narrow approval with `npm config set allow-scripts=cli-jaw --location=user`. Do not use npm's package-less printed variant or a wildcard approval. Run `jaw doctor` after recovery: the install receipt check distinguishes completed, stale, blocked, safe-mode, failed, and receipt-free `.git` development clones. Doctor also lists verified `.cli-jaw-*` npm staging leftovers so a user can close the locking process and remove them manually. On native Windows npm may generate both `jaw.ps1` and `jaw.cmd`. PowerShell execution policy applies to `jaw.ps1`, but not to `jaw.cmd`. Doctor probes `Get-ExecutionPolicy` with a three-second bound: `Restricted`, `AllSigned`, and `Undefined` warn; `RemoteSigned`, `Bypass`, and `Unrestricted` pass; probe failure is informational. Recovery choices are: ```powershell Set-ExecutionPolicy -Scope CurrentUser RemoteSigned jaw.cmd doctor node "$(npm prefix -g)\node_modules\cli-jaw\dist\bin\cli-jaw.js" doctor ``` The policy change is user-scoped. Operators who must not change policy can use the cmd shim or direct Node entry point instead. ### Direct smoke utilities ### CI job graph (`.github/workflows/test.yml`, #565) `scripts/check-private-boundary.mjs` checks indexed paths by default; the local `.githooks/pre-push` uses `--pre-push` to inspect outgoing commit trees before upload. See [contributor setup](../CONTRIBUTING.md#local-private-path-check) for checkout-local activation and manual `--range` checks. CI and publish checks are backstops after upload, not pre-disclosure guards. npm packaging uses explicit private-path exclusions in `package.json`'s `files` allowlist because root `.npmignore` alone does not override that allowlist. opencodex `ci.yml` ์˜ ์ƒค๋”ฉ ๊ตฌ์กฐ๋ฅผ ์ด์‹ํ–ˆ๋‹ค. ํ•˜๋‚˜์˜ ์ง๋ ฌ `node-tests` ์žก(9m51s, 34128612867)์ด ์•„๋ž˜ ๊ทธ๋ž˜ํ”„๋กœ ๋ฐ”๋€Œ์—ˆ๊ณ , ๊ฐ™์€ ์ปค๋ฐ‹ ๊ธฐ์ค€ ์ „์ฒด ๋ฒฝ์‹œ๊ณ„ 5m00s (34139039203). ``` changes โ”€โ”€โ”ฌโ”€โ”€ test 1/4 โ€ฆ test 4/4 tsc + tests/run.mts --scope root,unit --shard i/4 (fail-fast: false, 5-min step limit) โ”œโ”€โ”€ integration npm run build โ†’ build:frontend โ†’ server :3457 โ†’ --scope integration,manager,bin (CI=1) โ†’ fresh-install smoke โ”œโ”€โ”€ gates gate:all ยท check:deps ยท check:deps:audit ยท copilot gap ยท file size ยท windows manifest validate โ”œโ”€โ”€ windows-unit scripts/ci/windows-unit-manifest.txt via windows-unit-manifest.mjs --print (pwsh, one argv array) โ””โ”€โ”€ coverage (advisory) dev push / workflow_dispatch only; continue-on-error; not in the aggregate โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ ci-aggregate bash scripts/ci/aggregate-check.sh ``` `Hosted Manager QA` is a separate manual-event job in this same workflow. Run `gh workflow run test.yml --ref dev` for the selected candidate, then match the run's `headSha` to that candidate and inspect the QA job itself. Push/PR runs skip this opt-in job; that skip is not browser verification. Existing required producer and aggregate rules are unchanged. The workflow's shared-ref concurrency can cancel an earlier run, so finish the push run before dispatching manual QA. The hosted job installs the locked Playwright Chromium under Node 24.18.0, which includes the stream compatibility fix for the older ZIP extractor. Browser provisioning has an eight-minute deadline. It switches to Node 24.17.0 before native ABI preparation, backend/frontend builds and QA, preserving the target runtime. Then `tests/helpers/hosted-manager-qa.mjs` owns isolated Manager/worker fixtures and browser processes under an exclusive short `/tmp/jaw-qa-*` root so Chromium's Unix socket paths fit Linux limits. Artifacts remain in the explicit runner artifact directory. It runs native Code, retired settings and Manager layout files sequentially: seven named tests, including 16 native Code scenarios, two retirement widths and five layout scenarios. Structured results reject skipped or missing cases; logs, screenshots, traces and process-exit receipts are uploaded even on failure. The retirement fixture serves standalone instance settings through the Manager proxy; the layout fixture serves owned worker HTML through the production Preview proxy. This proves deterministic Linux browser integration; it does not certify live provider authentication or packaged Electron behavior on other platforms. ์ง‘๊ณ„ ๊ทœ์น™ (`scripts/ci/aggregate-check.sh`, ์ง„๋ฆฌํ‘œ๋Š” `tests/unit/ci-aggregate-rules.test.ts`): | `changes` | `code` | producer ๊ฒฐ๊ณผ | ํŒ์ • | |---|---|---|---| | success | true | ์ „๋ถ€ success | pass | | success | true | ํ•˜๋‚˜๋ผ๋„ skipped | **fail** (์žก์ด ๋–จ์–ด์ ธ ๋‚˜๊ฐ„ ๊ฒƒ) | | success | false | success ๋˜๋Š” skipped | pass (docs-only) | | โ€” | โ€” | failure / cancelled / ๋นˆ ๊ฐ’ / ๋ฏธ์ง€ ๊ฐ’ | fail | | โ‰  success | ๋˜๋Š” true/false ์ด์™ธ | โ€” | fail | `ci-aggregate` ์ด๋ฆ„์€ ๋ธŒ๋žœ์น˜ ruleset์ด ๋ฌธ์ž ๊ทธ๋Œ€๋กœ ๋งค์นญํ•˜๋ฏ€๋กœ ๋ฐ”๊พธ์ง€ ์•Š๋Š”๋‹ค. `publish.yml`๊ณผ ๋ฆด๋ฆฌ์Šค ์Šคํฌ๋ฆฝํŠธ๋Š” ์ •ํ™•ํ•œ SHA์˜ ์„ฑ๊ณตํ•œ `dev` push `test.yml` ๋Ÿฐ์„ ์ธ์ฆ์— ์‚ฌ์šฉํ•œ๋‹ค. Postinstall Platform Checks๋Š” ์ด๋ฒคํŠธยท๋ธŒ๋žœ์น˜์™€ ๊ด€๊ณ„์—†์ด ๊ฐ™์€ SHA์˜ ์„ฑ๊ณตํ•œ ๋Ÿฐ์ด ํ•ญ์ƒ ํ•„์š”ํ•˜๋‹ค. Tests์˜ `workflow_dispatch` ๋Ÿฐ์€ ์ธ์ฆํ•  ์ˆ˜ ์—†๋‹ค. CI ์—์„œ skip ์€ ์‹คํŒจ๋‹ค: `api-smoke` ๋Š” ์„œ๋ฒ„๊ฐ€ ์—†์œผ๋ฉด `CI` ์•„๋ž˜์—์„œ assert-fail ํ•œ๋‹ค. ๊ฒฉ๋ฆฌ(quarantine) ๋ชฉ๋ก โ€” provider ์ธ์ฆ๊ณผ ์‹ค์ œ ์ถ”๋ก ์ด ํ•„์š”ํ•ด opt-in ์œผ๋กœ๋งŒ ๋„๋Š” ํŒŒ์ผ: | file | opt-in | reason | |---|---|---| | `tests/integration/agy-print-smoke.test.ts` | `JAW_AGY_SMOKE=1` + AGY ์ธ์ฆ | ์‹ค์ œ AGY print ๋ชจ๋“œ ์ถ”๋ก  | | `tests/integration/codex-app-multiplex-activation.test.ts` | activation flag + `CODEX_HOME/auth.json` | ์ •ํ™•ํ•œ codex-cli ๋ฒ„์ „๊ณผ ์‹ค์ œ ์ถ”๋ก  | integration ์žก์˜ skip ๋ชฉ๋ก์ด ์ด ํ‘œ์™€ ๋‹ฌ๋ผ์ง€๋ฉด ์ƒˆ ๊ฒฉ๋ฆฌ๊ฐ€ ์•„๋‹ˆ๋ผ ํšŒ๊ท€๋‹ค. ์ƒค๋“œ ๋ถ„ํ• ์€ `tests/setup/shard.ts`: ์„ ํƒ ํŒŒ์ผ์„ `Buffer.compare`(LC_ALL=C ๋ฐ”์ดํŠธ ์ˆœ)๋กœ ์ •๋ ฌํ•˜๊ณ  `index % N === i-1` ์„ ์ทจํ•œ๋‹ค โ€” `node --test-shard` ๋ฐ opencodex helper ์™€ ๊ฐ™์€ ๊ทœ์น™์ด๋ผ ๋Ÿฌ๋„ˆ๋งˆ๋‹ค ๊ฐ™์€ ๋ถ„ํ• ์ด ๋‚˜์˜จ๋‹ค. ํŒŒ์ผ ์ˆ˜ ๊ท ํ˜• โ‰  ์‹œ๊ฐ„ ๊ท ํ˜•: 34139039203 ๊ธฐ์ค€ 72/83/104/89s. ํ•œ ์ƒค๋“œ๊ฐ€ 240s ๋ฅผ ๋„˜๊ฑฐ๋‚˜ ์ตœ๋Œ€/์ตœ์†Œ๊ฐ€ 2๋ฐฐ๋ฅผ ๋„˜์œผ๋ฉด N ์„ ์˜ฌ๋ฆฐ๋‹ค. ๋ฉˆ์ถ˜ ํŒŒ์ผ์€ `forceExit` ๊ฐ€ ์•„๋‹ˆ๋ผ ๋“œ๋ผ์ด๋ฒ„์˜ ์ง„ํ–‰ ๊ฐ์‹œ๊ฐ€ ๋ง‰๋Š”๋‹ค: `forceExit` ๋Š” ์ž์‹๋งˆ๋‹ค `--test-force-exit` ๋ฅผ ๋ถ™์—ฌ ๋ฃจํŠธ๊ฐ€ "์ด๋ฏธ ์•„๋Š”" ํ…Œ์ŠคํŠธ๋งŒ ๋๋‚˜๋ฉด ์ฆ‰์‹œ ํ”„๋กœ์„ธ์Šค๋ฅผ ๋๋ƒˆ๊ณ , ๊ทธ๋ž˜์„œ top-level await ๋’ค์— ๋“ฑ๋ก๋œ ํ…Œ์ŠคํŠธ๊ฐ€ ์‹คํ–‰๋งŒ ๋˜๊ณ  ๋ณด๊ณ ๋˜์ง€ ์•Š์•˜๋‹ค(#661, ํšŒ์ฐจ๋งˆ๋‹ค 4~62๊ฐœ). ์ง€๊ธˆ์€ ๊ฒฐ๊ณผ๋ฅผ ๋‚ด๊ธฐ ์‹œ์ž‘ํ•œ ๋’ค `JAW_TEST_FILE_STALL_MS`(๊ธฐ๋ณธ 180000ms) ๋™์•ˆ ์กฐ์šฉํ•œ ํŒŒ์ผ์„ ์ด๋ฆ„๊ณผ ํ•จ๊ป˜ ์‹คํŒจ๋กœ ๋ณด๊ณ ํ•˜๊ณ  ๋‚˜๋จธ์ง€๋ฅผ abort ํ•œ๋‹ค โ€” 34138235928 shard 3/4 ๊ฐ€ 4๋ถ„ ๋ฐ˜ ์นจ๋ฌตํ•˜๋‹ค ์Šคํ… ํƒ€์ž„์•„์›ƒ์œผ๋กœ ์ฃฝ์—ˆ์„ ๋•Œ ์—†๋˜ ๊ท€์† ์ •๋ณด๋‹ค. dequeue ๋ถ€ํ„ฐ ์žฌ์ง€ ์•Š๋Š” ์ด์œ ๋Š” 500๊ฐœ ์ž์‹์ด ์ฝ”์–ด๋ฅผ ๋‹คํˆฌ๋Š” ๋™์•ˆ ์ •์ƒ ํŒŒ์ผ๋„ ์ฒซ ์ด๋ฒคํŠธ๊นŒ์ง€ 60s ๋ฅผ ๊ธฐ๋‹ค๋ฆด ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๊ณ (์ธก์ •), ์ฒซ ๊ฒฐ๊ณผ ์ดํ›„ ๊ด€์ธก๋œ ์ตœ๋Œ€ ๊ฐ„๊ฒฉ์€ 9.5s ๋‹ค. ํšŒ๊ท€ ๊ฐ€๋“œ๋Š” `tests/unit/test-runner-driver.test.ts` ์™€ `tests/fixtures/test-runner/*.fixture.ts`. `test.yml` ์˜ shard ์Šคํ… ํ•œ๋„๋Š” 480s ๋‹ค โ€” ๊ฐ์‹œ(180s)๊ฐ€ Actions ๋ณด๋‹ค ๋จผ์ € ์šธ๋ ค์„œ ํŒŒ์ผ ์ด๋ฆ„์„ ๋‚จ๊ธธ ์—ฌ์œ ๋ฅผ ์ฃผ๊ธฐ ์œ„ํ•ด์„œ๋‹ค. ์ •์ง€ ๋ฉ”์‹œ์ง€๋Š” ํŒŒ์ผ๋งˆ๋‹ค ๋งˆ์ง€๋ง‰ ์ด๋ฒคํŠธ ์ข…๋ฅ˜ยท๊ฐœ์ˆ˜ยท๊ฒฝ๊ณผ๋ฅผ ํ•จ๊ป˜ ์ฐ๋Š”๋‹ค. `test.yml`์˜ `windows-unit`์€ ๊ธฐ์กด Windows ์„œ๋น„์Šคยท์„ค์น˜ยท์‹คํ–‰ ๊ฒ€์‚ฌ์— ๋”ํ•ด `claude-sdk-windows-launch`, `claude-sdk-session`, `claude-sdk-control`, `claude-sdk-core-hardening`, `claude-sdk-deferred-core`์˜ ๋ช…์‹œ์  ํ…Œ์ŠคํŠธ ํŒŒ์ผ์„ ์‹คํ–‰ํ•œ๋‹ค. SDK query์™€ ํ”„๋กœ์„ธ์Šค ๊ฒฝ๊ณ„๋Š” fixture๋กœ ๊ฒฉ๋ฆฌํ•˜๋ฉฐ, macOS์—์„œ ๊ฐ™์€ ํŒŒ์ผ์„ ์‹คํ–‰ํ•œ ๊ฒฐ๊ณผ๋Š” ์‹ค์ œ Windows job์˜ ์„ฑ๊ณต ์ฆ๊ฑฐ๋ฅผ ๋Œ€์‹ ํ•˜์ง€ ์•Š๋Š”๋‹ค. ํŒŒ์ผ ๋ชฉ๋ก์€ ์ธ๋ผ์ธ์ด ์•„๋‹ˆ๋ผ `scripts/ci/windows-unit-manifest.txt` ์— ์žˆ๊ณ , `scripts/ci/windows-unit-manifest.mjs` ๊ฐ€ Linux(`gates` ์žก + `tests/unit/windows-unit-manifest.test.ts`)์™€ Windows ์–‘์ชฝ์—์„œ ๊ฐ™์€ ๊ทœ์น™(๋นˆ ๋ชฉ๋กยท์ค‘๋ณตยท`tests/unit/` ๋ฐ–ยท์—†๋Š” ํŒŒ์ผ ๊ฑฐ๋ถ€)์œผ๋กœ ๊ฒ€์ฆํ•œ๋‹ค. Node 22ยทaggregate ๊ฒ€์ฆ๊ณผ code-change skip ๊ฑฐ๋ถ€ ์กฐ๊ฑด์€ ์œ ์ง€ํ•œ๋‹ค. #### ํ…Œ์ŠคํŠธ ๊ฒฉ๋ฆฌ๋Š” ํ”„๋กœ์„ธ์Šค ๋‹จ์œ„์ง€ DB ๋‹จ์œ„๊ฐ€ ์•„๋‹ˆ๋‹ค `tests/run.mts` ๋Š” `isolation:'process'` ๋กœ ํŒŒ์ผ๋งˆ๋‹ค ์ž์‹ ํ”„๋กœ์„ธ์Šค๋ฅผ ๋„์šฐ๊ณ , #564 ๋ถ€ํ„ฐ๋Š” `run({ execArgv: ['--import', tests/setup/test-home.ts] })` ๋กœ **์ž์‹๋งˆ๋‹ค ์ƒˆ `CLI_JAW_HOME` = ์ƒˆ `jaw.db`** ๋ฅผ ์ค€๋‹ค (๊ทธ ์ „์—๋Š” ๋ถ€๋ชจ๊ฐ€ ํ•œ ๋ฒˆ ์ •ํ•œ ํ™ˆ์„ ๋ชจ๋‘ ์ƒ์†ํ•ด ํ•˜๋‚˜์˜ `jaw.db` ๋ฅผ ๊ณต์œ ํ–ˆ๊ณ , ์ƒค๋”ฉ์œผ๋กœ ๋ฐฐ์น˜ ๊ตฌ์„ฑ์ด ๋ฐ”๋€Œ์ž ๋‘ ํŒŒ์ผ์ด ์ฒซ open ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜์„ ๊ฒฝ์Ÿํ•ด `SqliteError: duplicate column name` ์œผ๋กœ ์ฃฝ์—ˆ๋‹ค). ํŒŒ์ผ **์•ˆ**์˜ ๊ฒฉ๋ฆฌ๋Š” ์—ฌ์ „ํžˆ ์—†๋‹ค โ€” ํ•œ ํŒŒ์ผ์˜ ์—ฌ๋Ÿฌ ์ผ€์ด์Šค๋Š” ๊ฐ™์€ DB ๋ฅผ ๋ณธ๋‹ค. ์ด ๋ฌธ์žฅ์„ ์ผ€์ด์Šค ๋‹จ์œ„ "subprocess DB isolation" ์œผ๋กœ ์ฝ์œผ๋ฉด ์—†๋Š” ๋ณด์žฅ์„ ์žˆ๋‹ค๊ณ  ๋ฏฟ๊ฒŒ ๋œ๋‹ค (#521 ์กฐ์‚ฌ์—์„œ ์‹ค์ œ๋กœ ๊ทธ ์˜ค๋…์œผ๋กœ ์ž˜๋ชป๋œ ๊ฐ€์„ค์„ ์„ธ์› ๋‹ค). ํŒŒ์ผ ์•ˆ์—์„œ ์Šค์œ„ํŠธ๋ฅผ ์ง€์ผœ์ฃผ๋Š” ๊ฒƒ์€ ๋‘ ๊ฐ€์ง€๋‹ค: - `src/core/db.ts` ์˜ `journal_mode = WAL` + `busy_timeout = 5000`. WAL ์—์„œ ๋ฆฌ๋”๋Š” ๋ผ์ดํ„ฐ๋ฅผ ๋ง‰์ง€ ์•Š์œผ๋ฏ€๋กœ ํ‰๋ฒ”ํ•œ ๋™์‹œ ์ ‘๊ทผ์€ ์ž ๊ธˆ์ด ๋˜์ง€ ์•Š๋Š”๋‹ค. - ํŒŒ์ผ๋ณ„ opt-in ๊ฒฉ๋ฆฌ `tests/setup/isolated-home.ts`. ์ด๊ฑด ์ข๊ณ  ๊ตฌ์ฒด์ ์ธ ์œ„ํ—˜ โ€” `isAlive` ๋ฅผ ์Šคํ…ํ•œ ์ „์—ญ ํŒŒ๊ดด์  sweep ์ด ๋‹ค๋ฅธ ํ”„๋กœ์„ธ์Šค์˜ ํ–‰์„ ์ง€์šฐ๊ฑฐ๋‚˜, session singleton์„ sentinel๋กœ ๊ต์ฒดยท๋ณต์›ํ•˜๋Š” ๊ฒ€์‚ฌ๊ฐ€ ๋‹ค๋ฅธ ํŒŒ์ผ์„ ๋ฎ๋Š” ๊ฒฝ์šฐ โ€” ์—๋งŒ ํ•„์š”ํ•˜๋ฉฐ, DB ๋ฅผ ์—ฌ๋Š” ํŒŒ์ผ ์ „๋ถ€๊ฐ€ ์•„๋‹ˆ๋ผ ์ด๋Ÿฐ ๊ณต์œ  ์ƒํƒœ ์œ„ํ—˜์ด ์žˆ๋Š” ํŒŒ์ผ์— ๋„ฃ๋Š”๋‹ค. ๋กœ๊ทธ์—์„œ `database is locked` ๋ฅผ ๋ดค๋‹ค๊ณ  ๊ณง์žฅ ๊ฒฝํ•ฉ์ด๋ผ๊ณ  ๊ฒฐ๋ก ๋‚ด์ง€ ๋ง ๊ฒƒ. `tests/unit/memory-search-provider.test.ts` ๋Š” `BEGIN IMMEDIATE` ๋ฅผ 4.2์ดˆ ์žก๋Š” ์ž์‹์„ **์˜๋„์ ์œผ๋กœ** ๋„์›Œ ์žฌ์‹œ๋„ ๊ฒฝ๋กœ๋ฅผ ๊ฒ€์ฆํ•˜๋ฉฐ, ๊ทธ๊ฑด `jaw.db` ๊ฐ€ ์•„๋‹ˆ๋ผ ๋ฉ”๋ชจ๋ฆฌ ์ธ๋ฑ์Šค DB๋‹ค. ํ†ต๊ณผํ•˜๋Š” ํ…Œ์ŠคํŠธ์˜ ์ •์ƒ ์ถœ๋ ฅ์ด๋‹ค. | utility | command | purpose | | --- | --- | --- | | Fullscreen TUI `/quit` PTY smoke | `JAW_TUI_SMOKE_TIMEOUT=15 COLUMNS=100 LINES=30 scripts/smoke/tui-quit-smoke.exp` | built `dist/bin/cli-jaw.js chat`๊ฐ€ raw-mode fullscreen composer์—์„œ `/quit`๋กœ ์ •์ƒ ์ข…๋ฃŒ๋˜๋Š”์ง€ ๊ฒ€์ฆ | | Fullscreen TUI frame resize stress | `npx tsx --import ./tests/setup/test-home.ts scripts/smoke/tui-frame-resize-stress.ts` | live/committed/expanded tool rows + final answer๊ฐ€ resize ํ›„์—๋„ width-safe์ด๊ณ  bottom composer cluster๊ฐ€ ๊ณ ์ •๋˜๋Š”์ง€ ๊ฒ€์ฆ | | Fullscreen TUI WS sequence stress | `npx tsx --import ./tests/setup/test-home.ts scripts/smoke/tui-ws-sequence-stress.ts` | synthetic WS ์ด๋ฒคํŠธ๋กœ live tool, final answer, Ctrl-O expansion, resize-safe frame์„ ์„œ๋ฒ„/๋ชจ๋ธ ์—†์ด ๊ฒ€์ฆ | | Native Activity deterministic POSIX PTY | `node_modules/.bin/tsx tests/smoke/tui-activity-pty.mts --built-head --build-report --evidence ` | ์ปดํŒŒ์ผ๋œ CLIยท๊ฐ€์งœ HTTP/SSEยท์‹ค์ œ POSIX PTY๋กœ ์ œ์ถœ/Stop, saved MESSAGE ๋ณต๊ตฌ, F6ยทresizeยทpaste, raw NDJSON๊ณผ ์ข…๋ฃŒ๋ฅผ ๊ฒ€์ฆ. ์‹ค์ œ provider/DB ์˜์†์„ฑ ์ฆ๊ฑฐ๋Š” ์•„๋‹˜ | PTY ๋„๊ตฌ๋Š” ์„ค์น˜๋œ Node/tsx/xterm๊ณผ Python 3 POSIX ํ‘œ์ค€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉฐ, ์ƒˆ ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•˜์ง€ ์•Š๋Š”๋‹ค. `--build-report`๋Š” ํ˜ธ์ถœ์ž๊ฐ€ ์‹ค์ œ ์‹คํ–‰ํ•œ `npm run build --ignore-scripts`์˜ `command`, `exitCode`, `timedOut`, `overflow`, `groupLive`, `rootRemoved` ๊ฒฐ๊ณผ๋ฅผ ๊ฐ€์ง„ JSON์ด๋‹ค. ์„ฑ๊ณต ๊ธฐ๋ก๋งŒ์œผ๋กœ ๋นŒ๋“œ ์ถœ์ฒ˜๋ฅผ ์ถ”์ •ํ•˜์ง€ ๋ง๊ณ  ํ•ด๋‹น ์†Œ์Šคยทdist์™€์˜ ์ผ์น˜๋„ ํ™•์ธํ•œ๋‹ค. ๋„๊ตฌ๋Š” ํ˜„์žฌ HEAD์™€ ์†Œ์Šค/dist ๋ณ€๊ฒฝ ์—ฌ๋ถ€๋ฅผ ์ถ”๊ฐ€ ๊ฒ€์‚ฌํ•œ๋‹ค. `--ownership-self-test --evidence `๋Š” ์‹ค์ œ PID ์žฌ์‚ฌ์šฉ ์—†์ด ์‹ ํ˜ธ ๊ถŒํ•œยท๋ถˆํ™•์‹คํ•œ ์ •๋ฆฌ ๊ฒฐ๊ณผ๋ฅผ ๊ฒ€์ฆํ•œ๋‹ค. ํšŒ์ˆ˜๋œ PID/PGID์—๋Š” ํŒŒ๊ดด์  ์‹ ํ˜ธ๋ฅผ ๋ณด๋‚ด์ง€ ์•Š์œผ๋ฉฐ, ์†Œ์œ ๊ถŒ์ด ๋ถˆ๋ถ„๋ช…ํ•˜๋ฉด ์‹คํŒจ์™€ ์ž„์‹œ ๋ฃจํŠธ ๋ณด์กด์œผ๋กœ ๋๋‚œ๋‹ค. ์ด ๋ณด์กด์„ ๋ฌดํšจํ™”ํ•˜๋Š” ์ƒ์œ„ ์ž„์‹œ ๋””๋ ‰ํ„ฐ๋ฆฌ ์ž๋™ ์‚ญ์ œ wrapper๋กœ ๊ฐ์‹ธ์ง€ ์•Š๋Š”๋‹ค. #### ์ƒˆ ์›ŒํฌํŠธ๋ฆฌ์˜ ๋„ค์ดํ‹ฐ๋ธŒ ๋ฐ”์ด๋„ˆ๋ฆฌ๊ฐ€ Windows Application Control ์— ๋ง‰ํžŒ๋‹ค ์ฆ์ƒ์€ ํ…Œ์ŠคํŠธ ํ•˜๋„ค์Šค ๋ฒ„๊ทธ์ฒ˜๋Ÿผ ๋ณด์ธ๋‹ค. `npm ci` ์งํ›„ ํ•˜ํŠธ๋น„ํŠธ ์Šค์œ„ํŠธ๋ฅผ ๋Œ๋ฆฌ๋ฉด 18 ๊ฐœ ์ค‘ 11 ๊ฐœ๊ฐ€ **ํŒŒ์ผ ๋‹จ์œ„๋กœ** `tests/unit/X.test.ts:1:1` ์—์„œ ์‹คํŒจํ•˜๋Š”๋ฐ, ๊ฐ ํŒŒ์ผ ์•ˆ์˜ ๊ฐœ๋ณ„ ์ผ€์ด์Šค๋Š” ์ „๋ถ€ ํ†ต๊ณผํ•œ ๊ฒƒ์œผ๋กœ ์ฐํžŒ๋‹ค. DB ๋ฅผ ๊ฑด๋“œ๋ฆฌ๋Š” ํŒŒ์ผ๋งŒ ๊ณจ๋ผ์„œ ์‹คํŒจํ•˜๋ฏ€๋กœ ์œ„์˜ ํ”„๋กœ์„ธ์Šค ๊ฒฉ๋ฆฌ ์ด์•ผ๊ธฐ์™€ ์—ฎ์–ด ์ฝ๊ธฐ ์‰ฝ๋‹ค โ€” ๊ทธ๊ฑด ์›์ธ์ด ์•„๋‹ˆ๋‹ค. ์‹ค์ œ ์›์ธ์€ import ๋‹จ๊ณ„์—์„œ ์ฃฝ๋Š” ๊ฒƒ์ด๋‹ค: ``` Error: An Application Control policy has blocked this file. ...\node_modules\better-sqlite3\prebuilds\win32-x64.node at getBinding (node_modules/better-sqlite3/lib/binding.js:30) at new Database (node_modules/better-sqlite3/lib/database.js:46) at (src/core/db.ts:29) ``` ์ง„๋‹จํ•  ๋•Œ ๋‘ ๊ฐ€์ง€ ํ•จ์ •์ด ์žˆ๋‹ค. - `require('better-sqlite3')` ๋Š” ์ด ์˜ค๋ฅ˜๋ฅผ ๋‚ด์ง€ ์•Š๋Š”๋‹ค. `getBinding` ์€ `Database` ์ƒ์„ฑ์ž ์•ˆ์—์„œ ๋Œ๊ธฐ ๋•Œ๋ฌธ์—, ์ฐจ๋‹จ๋œ ๋ฐ”์ด๋„ˆ๋ฆฌ์—์„œ๋„ bare require ๋Š” ์„ฑ๊ณตํ•œ๋‹ค. ํ™•์ธํ•˜๋ ค๋ฉด ๋ฐ˜๋“œ์‹œ `new Database(':memory:')` ๊นŒ์ง€ ํ•ด์•ผ ํ•œ๋‹ค. - ํ•œ ์ฒดํฌ์•„์›ƒ์— ๋‘” ํ”„๋กœ๋ธŒ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ๋‹ค๋ฅธ ์ฒดํฌ์•„์›ƒ์˜ cwd ์—์„œ ์‹คํ–‰ํ•˜๋ฉด, Node ๋Š” cwd ๊ฐ€ ์•„๋‹ˆ๋ผ **์Šคํฌ๋ฆฝํŠธ ์œ„์น˜** ๊ธฐ์ค€์œผ๋กœ ๋ชจ๋“ˆ์„ ์ฐพ๋Š”๋‹ค. ์„ธ ์ฒดํฌ์•„์›ƒ์ด ์ „๋ถ€ ๊ฐ™์€ ํŒŒ์ผ์„ ๋กœ๋“œํ•ด ๋˜‘๊ฐ™์ด ๊ณ ์žฅ๋‚œ ๊ฒƒ์ฒ˜๋Ÿผ ๋ณด์ธ๋‹ค. ํ”„๋กœ๋ธŒ๋Š” ์ฒดํฌ์•„์›ƒ๋งˆ๋‹ค ์ ˆ๋Œ€ ๊ฒฝ๋กœ๋กœ require ํ•  ๊ฒƒ. ์ฐจ๋‹จ์€ ๋‚ด์šฉ์ด๋‚˜ ๋ฒ„์ „์ด ์•„๋‹ˆ๋ผ **๊ฒฝ๋กœ** ๊ธฐ์ค€์ด๋‹ค. ๊ฐ™์€ `better-sqlite3` 13.0.2 ๊ฐ€ ์˜ค๋ž˜๋œ ์ฒดํฌ์•„์›ƒ์—์„œ๋Š” ๋กœ๋“œ๋˜๊ณ , ๊ทธ ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ ์ƒˆ ์›ŒํฌํŠธ๋ฆฌ๋กœ ๋ฐ”์ดํŠธ ๋‹จ์œ„ ๋ณต์‚ฌํ•ด๋„ ์—ฌ์ „ํžˆ ๊ฑฐ๋ถ€๋œ๋‹ค. `Unblock-File` ๋„ ๋“ฃ์ง€ ์•Š๋Š”๋‹ค (Zone.Identifier ์ŠคํŠธ๋ฆผ์ด ์• ์ดˆ์— ์—†๋‹ค). ์šฐํšŒ๋Š” ํ—ˆ์šฉ๋œ ๊ฒฝ๋กœ๋ฅผ ์ œ์ž๋ฆฌ์— ๋ผ์›Œ ๋„ฃ๋Š” ๊ฒƒ์ด๋‹ค. ์ถ”์  ํŒŒ์ผ์€ ๊ฑด๋“œ๋ฆฌ์ง€ ์•Š์œผ๋ฉฐ `node_modules` ๋Š” gitignore ๋Œ€์ƒ์ด๋ผ `npm ci` ๋กœ ์›๋ณต๋œ๋‹ค: ```powershell Rename-Item node_modules\better-sqlite3\prebuilds prebuilds.blocked-by-appcontrol New-Item -ItemType Junction -Path node_modules\better-sqlite3\prebuilds -Target <ํ—ˆ์šฉ๋œ-์ฒดํฌ์•„์›ƒ>\node_modules\better-sqlite3\prebuilds ``` ํŒจํ‚ค์ง€ ๋””๋ ‰ํ„ฐ๋ฆฌ๋ฅผ `Remove-Item -Recurse` ๋กœ ์ง€์šฐ๊ณ  ๋‹ค์‹œ ๋งŒ๋“ค๋ ค ํ•˜์ง€ ๋ง ๊ฒƒ. ๊ด€๋ฆฌํ˜• ์›ŒํฌํŠธ๋ฆฌ ์•ˆ์˜ ๊ฒฝ๋กœ๋ผ ๊ฐ€๋“œ๊ฐ€ ๋ง‰๊ณ , ์• ์ดˆ์— ์‚ญ์ œ๊ฐ€ ํ•„์š” ์—†๋‹ค. ### ์‹คํ–‰ ๋ชจ๋“œ | ๋ชจ๋“œ | ๋ช…๋ น/์—”ํŠธ๋ฆฌ | ์‹ค์ œ ๋™์ž‘ | | --- | --- | --- | | Source server dev | `npm run dev` | `tsx --env-file=.env server.ts`๋กœ source server ์‹คํ–‰ | | CLI serve | `jaw serve` / `cli-jaw serve` | `bin/commands/serve.ts`๊ฐ€ source๋ฉด `tsx server.ts`, dist๋ฉด `node --dns-result-order=ipv4first server.js` spawn | | CLI serve options | `--port`, `--host`, `--no-open`, `--lan`, `--remote`, `--trust-proxy`, `--trust-forwarded` | env๋กœ `PORT`, `HOST`, `JAW_OPEN_BROWSER`, `JAW_LAN_MODE`, `JAW_REMOTE_ACCESS_MODE`, `JAW_TRUST_PROXY`, `JAW_TRUST_FORWARDED` ์ฃผ์ž… | | Frontend dev | `npm run dev:frontend` | Vite dev server port `5173`, `/api` proxy๋Š” `http://localhost:3458` | | Frontend build | `npm run build:frontend` | Vite๊ฐ€ `public/index.html` + `public/manager/index.html`์„ `public/dist`๋กœ ๋นŒ๋“œ | | Manager dashboard | `jaw dashboard serve` | `src/manager/server.ts` ๋˜๋Š” `dist/src/manager/server.js` ์‹คํ–‰, ๊ธฐ๋ณธ port `24576` | | Electron manager dashboard | Electron implicit spawn | Web/CLI lane `24576`๊ณผ ๋ถ„๋ฆฌ๋œ manager port `24577` ๊ธฐ๋ณธ๊ฐ’, fallback `24578-24590`; packaged app prefers bundled sidecar `server/bin/jaw` | | Docker npm image | `Dockerfile` | `npm install -g cli-jaw@${CLI_JAW_VERSION}` โ†’ `jaw serve --no-open` | | Docker local source | `Dockerfile.dev` | local source copy โ†’ `npm run build` + `npm run build:frontend` โ†’ `node dist/server.js` | | Compose | `docker-compose.yml` | ๋‹จ์ผ `jaw` service, `${PORT:-3457}:3457`, `.env`, named volume `jaw-data` | ### Sidecar build and smoke ownership `scripts/bundle-sidecar.sh ` is a matching-host runtime-verified build, not implicit cross-compilation or release. It validates target/lockfile and output provenance before work, takes an exclusive `.server-build.lock`, and uses a unique source/dependency snapshot plus staging tree. Root backend build skips global-link lifecycle hooks but runs the existing compiled-asset checker explicitly; locked dependencies, prune, native-load and no-JWC checks remain. Original `dist` is not rebuilt in place. Relative contained source links retain their text; external/absolute links and unrecognized output refuse adoption. The smoke parent `scripts/check-sidecar-smoke.mjs` and child `scripts/sidecar-smoke-probe.mjs` execute the artifact's Node against the three fixed critical targets. The execution copy lives outside checkout dependency ancestors so missing packages cannot borrow repository `node_modules`. Copied module/binary identity, private IPC, actual primary listener and HTTP identity, bounded errors/output and physical close are checked. Controlled metadata commands retain a scrubbed environment; provider/credential probes are not authentication evidence. A timeout, non-module exception, unexpected delegation or uncertain cleanup is failure, not successful import. Smoke reports are exclusive, outside the input artifact, and durable before payload-home deletion; paired cleanup is separate. Default report directories are intentionally retained evidence. The original artifact remains unchanged. The bundler binds its runtime candidate through smoke and sealing, then promotes only a completed, locally fingerprinted output. `.jaw-sidecar-build.json` is local provenance/integrity metadata, not a cryptographic signature. The smoke CLI exits `0` only for verified runtime success, `1` for a required missing artifact or operational failure, `2` for invalid arguments, and `3` for an optional absent default bundle (explicitly unverified). Sole help exits `0` without probing. CI alone does not require a bundle; an explicit `--server-root` or `JAW_GATE_REQUIRE_SIDECAR=1` does. The release wrapper may accept a skip as policy success but retains its SKIPPED/nothing-imported detail. Successful build snapshots/reports and actual previous-output backups remain available for inspection. Interrupted/failed work retains staging/extraction/ lock when completion is uncertain; do not blindly remove a lock or signal old numeric PIDs. Cleanup failure after promotion is not a rollback. Final Electron QA must still test the builder-filtered `.app` resources and native UI; these gates alone do not certify live providers or every platform. ### Isolated desktop QA `CLI_JAW_ISOLATED_QA_ROOT` is an explicit controlled-launch profile, not a normal user setting. Absence retains existing behavior; present-empty, malformed paths or conflicting ports reject rather than falling back. The supervisor must create canonical existing directories and scrub the environment **before** Node/CLI probes, application imports or Electron starts. `src/shared/isolated-qa.ts` is pure on import and owns validation/construction; it does not initialize stores. | Fixed layout below canonical root R | Environment / role | | --- | --- | | `home`, `tmp` | `HOME`, `TMPDIR`; constructed `USERPROFILE=home`, `TEMP=tmp`, `TMP=tmp` (Node on Windows uses TEMP/TMP) | | `xdg/config`, `xdg/cache`, `xdg/data`, `xdg/state` | Matching `XDG_*_HOME`; constructed `LOCALAPPDATA=xdg/cache`, `APPDATA=xdg/data` | | `worker`, `manager`, `dashboard` | Worker `CLI_JAW_HOME=worker`; Manager/Electron `CLI_JAW_HOME=manager`; `CLI_JAW_DASHBOARD_HOME=dashboard` | | `providers/codex`, `providers/claude`, `providers/pi` | `CODEX_HOME`, `CLAUDE_CONFIG_DIR`, `PI_CODING_AGENT_DIR` | | `electron/userData`, `electron/sessionData`, `electron/logs`, `electron/crashDumps` | Electron path adapter, applied before lock/session creation | All layout directories must exist inside R. Set distinct decimal ports W/M/P: `DASHBOARD_SCAN_FROM=W`, `DASHBOARD_PORT=M`, `DASHBOARD_PREVIEW_FROM=P`, `DASHBOARD_SCAN_COUNT=1`; worker also requires `PORT=W`. Electron requires the exact explicit `http://127.0.0.1:M/` Manager URL. Conflicting/invalid CLI flags, including earlier duplicate values, reject before default normalization. Observed 2026-09-08 on a packaged 2.17.40 bundle: launching with the layout above but without `providers/*` directories and without `--manager-url` exits silently (stdout empty, no window) โ€” the isolated launcher refuses before any logging. Create every row of the layout, including `providers/codex`, `providers/claude`, `providers/pi`, and pass `--manager-url http://127.0.0.1:M/` explicitly. The child environment is a fresh allowlist, not an ambient overlay. Initial supervisors remove inherited renderer tokens; only the app-generated IPC token is deliberately forwarded along the Electron-to-Manager chain. QA Electron suppresses protocol/login/shortcut/Automation/CLI-install actions, including menu callbacks and repeated startup. Packaged startup uses the exact sidecar Node/CLI, never shell PATH repair, global jaw or picker fallback. Dashboard CLI preserves W/M/1/P at its Manager child. Manager rejects foreign stored/custom/single scan ranges before fetch/cache/preview/service effects, never enumerates peer dashboards, and refuses HTTP/direct lifecycle actions; the supervisor owns process teardown. Existing normal-mode behavior remains. This covers controlled entrypoints, not arbitrary CLI commands, raw imports, shell/browser actions or malicious same-user filesystem replacement. Empty task-owned messaging/jobs/MCP fixtures are prerequisites, not copied personal settings. Import-time DB containment belongs to the supervisor. A built module, mocked startup test or this profile alone does not certify the builder-filtered packaged resources, actual native UI, provider authentication or OS-wide behavior. ### ํ™˜๊ฒฝ๋ณ€์ˆ˜ | ๋ณ€์ˆ˜ | ์‹ค์ œ ์‚ฌ์šฉ์ฒ˜ | ์˜๋ฏธ | | --- | --- | --- | | `CLI_JAW_HOME` | `src/core/config.ts`, `bin/cli-jaw.ts`, `bin/postinstall.ts` | ๋ฐ์ดํ„ฐ ํ™ˆ override. ๊ธฐ๋ณธ `~/.cli-jaw` | | `PORT` | `server.ts`, `bin/commands/serve.ts`, CLI API commands | server port. ๊ธฐ๋ณธ `3457` | | `HOST` | `bin/commands/serve.ts` | serve child env๋กœ ์ „๋‹ฌ | | `JAW_OPEN_BROWSER` | `server.ts`, `serve.ts` | `serve` ์‹คํ–‰ ํ›„ ๋ธŒ๋ผ์šฐ์ € open ์—ฌ๋ถ€ | | `JAW_LAN_MODE` | `server.ts`, `serve.ts` | LAN host/origin bypass ํ™œ์„ฑํ™” | | `JAW_REMOTE_ACCESS_MODE` | `serve.ts` | `--remote`์—์„œ `direct`๋กœ ์ฃผ์ž… | | `JAW_TRUST_PROXY` | `server.ts`, `serve.ts` | Express trust proxy ์„ค์ • | | `JAW_TRUST_FORWARDED` | `server.ts`, `serve.ts` | forwarded host/proto ์‹ ๋ขฐ | | `JAW_AUTH_TOKEN` | `server.ts`, `doctor.ts` | loopback ์™ธ API bearer auth token | | `JAW_BOSS_TOKEN` | `src/core/boss-auth.ts`, `bin/commands/dispatch.ts` | boss-only employee dispatch token | | `JAW_EMPLOYEE_MODE` | `bin/commands/dispatch.ts` | employee ๋‚ด๋ถ€ dispatch ์ฐจ๋‹จ | | `TELEGRAM_TOKEN`, `TELEGRAM_ALLOWED_CHAT_IDS` | `src/core/config.ts` | Telegram settings override | | `JAW_HUB_CALLBACK_URL` | `src/telegram/hub-callback.ts`, `src/manager/lifecycle.ts` | Telegram Hub member outbound callback override (loopback http only; manager spawn sets `http://127.0.0.1:${DASHBOARD_DEFAULT_PORT}`) | | `DISCORD_TOKEN`, `DISCORD_GUILD_ID`, `DISCORD_CHANNEL_IDS` | `src/core/config.ts` | Discord settings override | | `DASHBOARD_PORT`, `DASHBOARD_SCAN_FROM`, `DASHBOARD_SCAN_COUNT`, `JAW_DASHBOARD_OPEN` | `bin/commands/dashboard.ts`, `src/manager/server.ts` | Manager dashboard ์‹คํ–‰/scan ์„ค์ • | | `LOG_LEVEL` | `src/core/logger.ts` | logger verbosity | | `OFFICECLI_REPO` | `scripts/install-officecli.sh`, `scripts/install-officecli.ps1` | install ์Šคํฌ๋ฆฝํŠธ ์†Œ์Šค repo override (`lidge-jun/OfficeCLI` ๊ธฐ๋ณธ) | | `JAW_SAFE`, `npm_config_jaw_safe` | `bin/postinstall.ts` | postinstall safe mode | | `CLI_JAW_MIGRATE_SHARED_PATHS`, `npm_config_jaw_migrate_shared_paths` | `bin/postinstall.ts` | shared path migration opt-in | | `TEST_PORT` | `package.json` `test:smoke` | smoke test target port | ### Docker ์„ค์ • | ํŒŒ์ผ | ์‹ค์ œ ๋‚ด์šฉ | | --- | --- | | `Dockerfile` | `node:22-slim`, `python3 make g++ chromium curl`, non-root `jaw`, npm global `cli-jaw@${CLI_JAW_VERSION}` (`ARG CLI_JAW_VERSION=latest`), `CLI_JAW_HOME=/home/jaw/.cli-jaw`, `PORT=3457`, entrypoint `jaw serve --no-open` | | `Dockerfile.dev` | `node:22-slim`, local source copy, `npm ci --ignore-scripts` (better-sqlite3 13์€ prebuild ๋™๋ด‰์ด๋ผ rebuild ๋ถˆํ•„์š”), `npm run build && npm run build:frontend`, `node dist/bin/postinstall.js`, `CLI_JAW_HOME=/home/jaw/.cli-jaw`, `PORT=3457`, entrypoint `node dist/server.js` | | `docker-compose.yml` | `jaw` service, `build: .`, `container_name: cli-jaw`, `${PORT:-3457}:3457`, `env_file: .env`, `jaw-data:/home/jaw/.cli-jaw`, `restart: unless-stopped`, `/dev/shm` tmpfs 512m | ### `scripts/` ์‹ค์ œ ํŒŒ์ผ `atomic-build.sh`, `audit-fresh-install-evidence.mjs`, `bundle-sidecar.sh`, `capture-agy-quota-fixture.mjs`, `check-app-icon-assets.cjs`, `check-cli-bin-links.cjs`, `check-copilot-gap.ts`, `check-deps-offline.ts`, `check-deps-online.sh`, `check-electron-no-native.cjs`, `check-electron-sidecar-no-jwc.cjs`, `check-redaction-sinks.mjs`, `check-sidecar-prune-safety.mjs`, `check-strict-baseline.mjs`, `check-web-ui-build-output.ts`, `claim-audit.mjs`, `collect-fresh-install-evidence.sh`, `electron-dev-manager.mjs`, `ensure-native-modules.cjs`, `fresh-install-smoke.ts`, `i18n-registry.ts`, `install-officecli.ps1`, `install-officecli.sh`, `install-risk-gate.mjs`, `install-wsl.sh`, `install.sh`, `retired-runtime-package-smoke.mjs`, `link-current-nvm-bin.cjs`, `pi-rpc-probe.mts`, `postinstall-guard.cjs`, `prepare-sidecar-package-json.cjs`, `release-1.6.0.sh`, `release-gates.mjs`, `release.sh`, `release-version.mjs`, `release-preview.sh` (thin wrapper for `release.sh --preview`), `verify-npm-provenance.mjs`, `pick-gyp-python.sh`, `require-release-evidence.mjs`, `signal-dashboard-restart.mjs`, `sync-electron-version.cjs`, `verify-fresh-install.sh`, `verify-release-evidence.mjs`, `ci/aggregate-check.sh`, `ci/windows-unit-manifest.mjs`, `ci/windows-unit-manifest.txt`, `smoke/opencode-external-dir-smoke.ts`, `smoke/tui-frame-resize-stress.ts`, `smoke/tui-fullscreen-frame-smoke.ts`, `smoke/tui-ws-sequence-stress.ts`. --- ## ๋ฆด๋ฆฌ์Šค ํŒŒ์ดํ”„๋ผ์ธ๊ณผ ๋ถ€๋ถ„ ์‹คํŒจ ๋ณต๊ตฌ `dev`๋Š” ์œ ์ผํ•œ ์žฅ๊ธฐ ๋ธŒ๋žœ์น˜์ด์ž ๊ธฐ๋ณธ ๋ฐ ๋ฆด๋ฆฌ์Šค ๋ธŒ๋žœ์น˜๋‹ค. ํ”ผ์ฒ˜ ๋ธŒ๋žœ์น˜๋ฅผ PR๋กœ `dev`์— ๋ณ‘ํ•ฉํ•˜๊ณ , stable๊ณผ preview ๋ชจ๋‘ `scripts/release.sh`๋กœ ์‹œ์ž‘ํ•œ๋‹ค. ๋ฆด๋ฆฌ์Šค ๋ฒ„์ „์€ ์žฌ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š”๋‹ค. ### ์ •์ƒ ๊ฒฝ๋กœ | ๋‹จ๊ณ„ | ์‹คํ–‰ ๋ฐ ์ฆ๋ช… | | --- | --- | | 1. ์ค€๋น„ | `bash scripts/release.sh` ๋˜๋Š” `bash scripts/release.sh --preview`. `--major`, `--minor`, `--patch` ๋˜๋Š” `X.Y.Z` base๋ฅผ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋‹ค. ๊นจ๋—ํ•˜๊ณ  ์›๊ฒฉ๊ณผ ์ผ์น˜ํ•˜๋Š” dev, ๋ฏธ๊ฒŒ์‹œ ๋ฒ„์ „ ๋ฐ dist-tag ์ˆœ์„œ๋ฅผ ํ™•์ธํ•˜๊ณ  ๋ฒ„์ „ manifests๋ฅผ ๊ฐฑ์‹ ํ•œ๋‹ค. | | 2. ๋นŒ๋“œ์™€ ํ‘ธ์‹œ | ๋นŒ๋“œ, Electron ๊ฒ€์‚ฌ, `gate:all` ๋ฐ pack ๊ฒ€์‚ฌ๋ฅผ ํ†ต๊ณผํ•œ ๋ฒ„์ „ ์ปค๋ฐ‹์„ non-force๋กœ dev์— ํ‘ธ์‹œํ•œ๋‹ค. ์›๊ฒฉ์ด ์›€์ง์ด๋ฉด ๋ฉˆ์ถ˜๋‹ค. | | 3. ์ธ์ฆ๊ณผ ์ฆ๊ฑฐ | ์ •ํ™•ํ•œ ์ปค๋ฐ‹ SHA์˜ ์„ฑ๊ณตํ•œ `test.yml` dev push ๋Ÿฐ๊ณผ ์„ฑ๊ณตํ•œ Postinstall Platform Checks ๋Ÿฐ์„ ๊ธฐ๋‹ค๋ฆฐ๋‹ค. stable์€ ํ•„์š”ํ•œ ์„ค์น˜ ์ฆ๊ฑฐ๋ฅผ ํ•„์ˆ˜ ๊ฒ€์‚ฌํ•˜๊ณ , preview๋Š” `--require-evidence`๋กœ ํ•„์ˆ˜ํ™”ํ•  ์ˆ˜ ์žˆ๋‹ค. | | 4. ํƒœ๊ทธ์™€ ๊ฒŒ์‹œ | ์ธ์ฆ๋œ SHA์— ๋ถˆ๋ณ€ `v` ํƒœ๊ทธ๋ฅผ ๋งŒ๋“ค๊ณ  `publish.yml`์„ ๊ทธ ํƒœ๊ทธ์—์„œ dispatchํ•œ๋‹ค. request-id๋กœ ํ•ด๋‹น ๊ฒŒ์‹œ ๋Ÿฐ์„ ์ฐพ์•„ ์™„๋ฃŒ์™€ ์„ฑ๊ณต์„ ๊ธฐ๋‹ค๋ฆฐ๋‹ค. | | 5. GitHub์™€ desktop | `publish.yml`์€ ๋‘ ์ฑ„๋„์˜ GitHub release๋ฅผ ๋งŒ๋“ค๊ฑฐ๋‚˜ ๊ฐฑ์‹ ํ•˜๊ณ  `desktop-release.yml`์— ํƒœ๊ทธ์™€ expected SHA๋ฅผ ์ „๋‹ฌํ•œ๋‹ค. Desktop์€ ์ฒดํฌ์•„์›ƒ SHA์™€ ์—…๋กœ๋“œ ์ „ ํƒœ๊ทธ๋ฅผ ํ™•์ธํ•œ๋‹ค. | ์‹ค์ œ publish๋Š” `refs/tags/v`๋งŒ ํ—ˆ์šฉํ•˜๊ณ  `dev` ref๋Š” dry-run์—๋งŒ ํ—ˆ์šฉํ•œ๋‹ค. ํƒœ๊ทธ์˜ ์ปค๋ฐ‹์€ dev์˜ ์กฐ์ƒ์ด์–ด์•ผ ํ•œ๋‹ค. Tests ์ธ์ฆ์€ dev push๋งŒ ๋ฐ›์•„๋“ค์ด๋ฉฐ ํ”Œ๋žซํผ ์ธ์ฆ์€ ๊ฐ™์€ SHA์˜ ์„ฑ๊ณตํ•œ ๋Ÿฐ์ด๋ฉด ์ด๋ฒคํŠธ์™€ ๊ด€๊ณ„์—†์ด ์ธ์ •ํ•œ๋‹ค. ๋‘ ์ธ์ฆ์€ ๋ชจ๋“  ๊ฒŒ์‹œ์— ํ•„์ˆ˜๋‹ค. ๋™์‹œ publish๋Š” ํ•˜๋‚˜์˜ ๊ทธ๋ฃน์œผ๋กœ ์ง๋ ฌํ™”ํ•˜๊ณ  ์ƒˆ ๊ฒŒ์‹œ์—์„œ๋Š” ์ฑ„๋„ dist-tag์˜ ๋‹จ์กฐ ์ฆ๊ฐ€๋ฅผ ๊ฒ€์‚ฌํ•œ๋‹ค. ๊ฒŒ์‹œ๊ฐ€ ์—†๋Š” pending ๋Ÿฐ๋„ ์ƒˆ pending ๋Ÿฐ์— ์˜ํ•ด ์ทจ์†Œ๋  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ ์Šคํฌ๋ฆฝํŠธ๋Š” ์ž๊ธฐ request-id์˜ ๊ฒฐ๊ณผ๋ฅผ ๊ธฐ๋‹ค๋ฆฌ๊ณ  ์ทจ์†Œยท์‹คํŒจ ์‹œ ์žฌ์‹คํ–‰ ๋ช…๋ น์„ ์ถœ๋ ฅํ•œ๋‹ค. stable release๊ฐ€ ์ƒˆ๋กœ ๊ฒŒ์‹œ๋˜๋ฉด GitHub Latest๋กœ ์ง€์ •ํ•œ๋‹ค. ์ด๋ฏธ ๊ฒŒ์‹œ๋œ stable ๋ณต๊ตฌ๋Š” npm `latest`์™€ ๋ฒ„์ „์ด ์ผ์น˜ํ•  ๋•Œ๋งŒ Latest๋ฅผ ์ง€์ •ํ•˜๋ฉฐ, preview๋Š” prerelease๋กœ ๋งŒ๋“ ๋‹ค. workflow์˜ `GITHUB_TOKEN`์œผ๋กœ ๋งŒ๋“  release๋Š” release ์ด๋ฒคํŠธ๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค์ง€ ์•Š์œผ๋ฏ€๋กœ publish workflow๊ฐ€ ๋‘ ์ฑ„๋„ ๋ชจ๋‘ desktop์„ ๋ช…์‹œ์ ์œผ๋กœ dispatchํ•œ๋‹ค. ### ๋ณต๊ตฌ 1 โ€” dev ํ‘ธ์‹œ ๋’ค CI ์‹คํŒจ ๋˜๋Š” publish ์‹คํŒจ CI๊ฐ€ ๋นจ๊ฐ›๋‹ค๋ฉด ์‹คํŒจํ•œ ๋Ÿฐ์„ `gh run rerun `๋กœ ๋‹ค์‹œ ์‹คํ–‰ํ•œ ๋’ค, ํ•ด๋‹น ๋ฏธ๊ฒŒ์‹œ ๋ฆด๋ฆฌ์Šค ์ปค๋ฐ‹์„ ์ฒดํฌ์•„์›ƒํ•˜๊ณ  `bash scripts/release.sh --resume `๋ฅผ ์‹คํ–‰ํ•œ๋‹ค. resume์€ SHA๊ฐ€ dev์— ์†ํ•˜๊ณ  HEAD๊ฐ€ ๊ทธ SHA์ด๋ฉฐ ์ปค๋ฐ‹ ๋ฐ manifests๊ฐ€ ๋ฆด๋ฆฌ์Šค ์กฐ๊ฑด์— ๋งž๋Š”์ง€ ๊ฒ€์‚ฌํ•œ๋‹ค. ๋˜๋Š” fix-forward ํ›„ ์ƒˆ ๋ฒ„์ „์„ ๋งŒ๋“ ๋‹ค. ํ”Œ๋žซํผ ๋Ÿฐ์ด ์•„์˜ˆ ์—†๋‹ค๋ฉด ๋จผ์ € ๊ธฐ์กด ํƒœ๊ทธ๊ฐ€ ์—†๊ฑฐ๋‚˜ ๊ฐ™์€ SHA๋ฅผ ๊ฐ€๋ฆฌํ‚ค๋Š”์ง€ ํ™•์ธํ•œ ๋’ค ์•„๋ž˜ ๋ช…๋ น์œผ๋กœ ํƒœ๊ทธ๋ฅผ ํ‘ธ์‹œํ•˜๊ณ  ํ”Œ๋žซํผ ๋Ÿฐ์„ dispatchํ•œ๋‹ค. ์„ฑ๊ณต ํ›„ resumeํ•œ๋‹ค: ```bash git push origin :refs/tags/v gh workflow run postinstall-platform.yml --ref v bash scripts/release.sh --resume ``` publish ๋Ÿฐ์ด ์‹คํŒจํ•˜๊ฑฐ๋‚˜ ์ทจ์†Œ๋๋‹ค๋ฉด ์Šคํฌ๋ฆฝํŠธ๊ฐ€ ์ถœ๋ ฅํ•œ `gh workflow run publish.yml` ๋ช…๋ น์„ ๊ฐ™์€ ํƒœ๊ทธ์™€ SHA๋กœ ๋‹ค์‹œ dispatchํ•œ๋‹ค. ๋Ÿฐ์˜ `headSha`, ์™„๋ฃŒ ๋ฐ ์„ฑ๊ณต ์ƒํƒœ๋ฅผ ํ™•์ธํ•œ๋‹ค. ์‹ค ๊ฒŒ์‹œ์—์„œ dev๋ฅผ dispatch ref๋กœ ์“ฐ์ง€ ์•Š๋Š”๋‹ค. ### ๋ณต๊ตฌ 2 โ€” npm ๊ฒŒ์‹œ ํ›„ GitHub release ๋˜๋Š” desktop ๋ˆ„๋ฝ ์ถœ๋ ฅ๋œ publish ๋ช…๋ น์„ ๊ฐ™์€ ํƒœ๊ทธ๋กœ ๋‹ค์‹œ dispatchํ•œ๋‹ค. ๊ธฐ์กด npm ๋ฒ„์ „์ด๋ฉด workflow๋Š” ์ƒˆ ๊ฒŒ์‹œ์™€ dist-tag ์ˆœ์„œ ๊ฒ€์‚ฌ๋ฅผ ๊ฑด๋„ˆ๋›ฐ๊ณ  provenance๋ฅผ ํ™•์ธํ•œ ๋’ค GitHub release์™€ desktop dispatch๋ฅผ ์ˆ˜ํ–‰ํ•œ๋‹ค. provenance๋Š” npm registry์˜ attestation๊ณผ ํŒจํ‚ค์ง€ integrity, ์ €์žฅ์†Œ, workflow ๊ฒฝ๋กœ ๋ฐ git commit์„ ๋Œ€์กฐํ•œ๋‹ค. DSSE ์„œ๋ช… ์ž์ฒด๋Š” ์•”ํ˜ธํ•™์ ์œผ๋กœ ๊ฒ€์ฆํ•˜์ง€ ์•Š์œผ๋ฉฐ npm registry๋ฅผ ์‹ ๋ขฐํ•œ๋‹ค. ํƒœ๊ทธ๊ฐ€ ์ด๋™ํ•˜๊ฑฐ๋‚˜ SHA๊ฐ€ ๋‹ค๋ฅด๋ฉด ๋ณต๊ตฌ๋ฅผ ๊ฑฐ๋ถ€ํ•œ๋‹ค. Desktop ์—…๋กœ๋“œ๋Š” ๊ฐ™์€ SHA์— ๋ฌถ์—ฌ ์žˆ๋‹ค. ### ๋ณต๊ตฌ 3 โ€” ์ž˜๋ชป๋œ ๋ฒ„์ „์ด npm `latest`์— ๋„๋‹ฌํ•จ `npm unpublish`๋Š” ์ •์ƒ์ ์ธ ๋กค๋ฐฑ ์ˆ˜๋‹จ์ด ์•„๋‹ˆ๋‹ค. ์ด๋ฏธ ํ•ด๊ฒฐ๋œ ๋ฒ„์ „์„ ์‚ฌ์šฉํ•˜๋Š” ์†Œ๋น„์ž๋ฅผ ๊นจ๋œจ๋ฆฌ๋ฉฐ ๋ฒ„์ „ ๋ฒˆํ˜ธ๋ฅผ ์žฌ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋‹ค. ๋น„๋ฐ€ ์œ ์ถœ์ด๋‚˜ ๋ฒ•์  ๋ฌธ์ œ ๊ฐ™์€ ๊ฒฝ์šฐ์—๋งŒ ํ˜„์žฌ npm ์ •์ฑ…์„ ํ™•์ธํ•˜๊ณ  ๊ณ ๋ คํ•œ๋‹ค. ๋ณดํ†ต์€ dist-tag๋ฅผ ์ด์ „ ๋ฒ„์ „์œผ๋กœ ์˜ฎ๊ธฐ๊ณ  ์ƒˆ ๋ฒ„์ „์œผ๋กœ ์ˆ˜์ •ํ•œ๋‹ค: ```bash npm dist-tag ls cli-jaw npm dist-tag add cli-jaw@ latest gh release edit "v" --latest ``` ์ด ์กฐ์น˜๋Š” ์ƒˆ `latest` ์„ค์น˜์™€ ์ƒˆ Docker ๋นŒ๋“œ์˜ ํ•ด์„๋งŒ ๋ฐ”๊พผ๋‹ค. ์ด๋ฏธ ์„ค์น˜ํ•œ ๋ฒ„์ „, ์ •ํ™•ํ•œ ๋ฒ„์ „ ์ง€์ •, lockfile๊ณผ ๊ธฐ์กด ์ด๋ฏธ์ง€์—๋Š” ์˜ํ–ฅ์„ ์ฃผ์ง€ ์•Š๋Š”๋‹ค. preview ์ฑ„๋„๋„ `npm dist-tag add cli-jaw@ preview`๋กœ ๋˜๋Œ๋ฆด ์ˆ˜ ์žˆ๋‹ค. ์ดํ›„ ์ •์ƒ ๊ฒฝ๋กœ๋กœ ์ƒˆ ๋ฒ„์ „์„ ๋ฆด๋ฆฌ์Šคํ•œ๋‹ค. ### ๋ณต๊ตฌ 4 โ€” ๊ฒ€์ฆ ์‹คํŒจํ•œ ์ปค๋ฐ‹์ด dev์— ๋„๋‹ฌํ•จ ๋ฌธ์ œ ์ปค๋ฐ‹์˜ ๋ถ€๋ชจ ๊ด€๊ณ„๋ฅผ ํ™•์ธํ•˜๊ณ  dev ๊ธฐ๋ฐ˜ ํ”ผ์ฒ˜ ๋ธŒ๋žœ์น˜์—์„œ revert PR์„ ๋งŒ๋“ ๋‹ค. ๋‹จ์ผ ๋ถ€๋ชจ ์ปค๋ฐ‹์€ `git revert `, ๋ณ‘ํ•ฉ ์ปค๋ฐ‹์€ ์˜ฌ๋ฐ”๋ฅธ mainline ๋ถ€๋ชจ๋ฅผ ํ™•์ธํ•œ ๋’ค `git revert -m 1 `๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. PR์„ dev์— ๋ณ‘ํ•ฉํ•˜๊ณ  ์ƒˆ ๋ฒ„์ „์„ ๋ฆด๋ฆฌ์Šคํ•œ๋‹ค. ์ด๋ฏธ ์ž˜๋ชป๋œ ๋ฒ„์ „์ด npm์— ์žˆ๋‹ค๋ฉด ๋ณต๊ตฌ 3๋„ ์ˆ˜ํ–‰ํ•œ๋‹ค. ๊ธฐ์กด ๊ฒŒ์‹œ ๋ฒ„์ „์ด๋‚˜ ํƒœ๊ทธ๋ฅผ ๋ฎ์–ด์“ฐ์ง€ ์•Š๋Š”๋‹ค. --- ## ์‹œ์ž‘ ๊ฒฝ๋กœ ์•ˆ์ •์„ฑ ๊ณ„์•ฝ (start-path reliability) `jaw ` ์‹คํ–‰ ์‹œ ๋„ค์ดํ‹ฐ๋ธŒ ์˜์กด์„ฑ ์ค€๋น„๋ฅผ ๋‹ด๋‹นํ•˜๋Š” ํ‘œ๋ฉด. ### ์‹คํ–‰ ๊ฒฝ๋กœ ``` jaw (์ „์—ญ bin ์‹ฌ๋งํฌ) โ†’ dist/bin/cli-jaw.js โ””โ”€ ensureNativeModulesReady(cmd) [bin/cli-jaw.ts] โ””โ”€ ์ž์‹ ํ”„๋กœ์„ธ์Šค: scripts/ensure-native-modules.cjs bin/jaw (๊ฐœ๋ฐœ ํด๋ก  / ์ง์ ‘ ํ˜ธ์ถœ ๋Ÿฐ์ฒ˜) โ””โ”€ argv ๊ธฐ๋ฐ˜ probe โ†’ ์‹คํŒจ ์‹œ ์œ„ ์Šคํฌ๋ฆฝํŠธ์— ์œ„์ž„ ``` ์ „์—ญ ์„ค์น˜ ์‚ฌ์šฉ์ž๋Š” `bin/jaw`๋ฅผ ๊ฑฐ์น˜์ง€ ์•Š๋Š”๋‹ค. `--help`/`--version` ๋“ฑ์€ ๊ฐ€๋“œ๋ฅผ ๊ฑด๋„ˆ๋›ด๋‹ค. ### `scripts/ensure-native-modules.cjs` ๊ณ„์•ฝ | ํ•ญ๋ชฉ | ๊ณ„์•ฝ | | --- | --- | | ์‹คํŒจ ๋ถ„๋ฅ˜ | `missing` (ํ•ด์„ ๋ถˆ๊ฐ€ **๋˜๋Š”** ๋กœ๋“œ ์‹œ `MODULE_NOT_FOUND`) / `abi` (dlopenยทNODE_MODULE_VERSION) / `other` โ€” `classifyNativeError()`๋กœ export | | ํ•ด์„ ๊ฒ€์‚ฌ | `createRequire(root/package.json).resolve()`. `node_modules` ๋””๋ ‰ํ„ฐ๋ฆฌ ์กด์žฌ ์—ฌ๋ถ€๋กœ ํŒ์ •ํ•˜์ง€ ์•Š์Œ (PnP ๋“ฑ) | | `missing` ํ–‰๋™ | rebuild ๊ธˆ์ง€. `npm install` ์•ˆ๋‚ด + exit 1 | | `abi` ํ–‰๋™ | ์ž ๊ธˆ ํš๋“ โ†’ ์žฌprobe โ†’ 1ํšŒ rebuild โ†’ ์žฌprobe | | `other` ํ–‰๋™ | rebuild ๊ธˆ์ง€. Node ๋ฒ„์ „/ABI/platform/arch ์ถœ๋ ฅ ํ›„ exit 1 | | ์ž ๊ธˆ ์œ„์น˜ | `tmpdir()/jaw-native-rebuild-.lock` โ€” **`node_modules` ๋ฐ–** (npm install์ด ์ง€์šธ ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ) | | ์ž ๊ธˆ ํš๋“ | `mkdirSync({recursive:false})` ์›์ž์„ฑ. ์ตœ๋Œ€ 5๋ถ„ ๋Œ€๊ธฐ | | ์ž ๊ธˆ ํšŒ์ˆ˜ | ์†Œ์œ ์ž PID๋ฅผ `process.kill(pid, 0)`๋กœ probe. `ESRCH`=ํšŒ์ˆ˜, `EPERM`=์‚ด์•„์žˆ์Œ. ์‹œ๊ฐ„(`LOCK_STALE_MS`)์€ PID๋ฅผ ๋ชป ์ฝ์„ ๋•Œ๋งŒ ์“ฐ๋Š” backstop | | ABI ํŒ์ • ๋ฒ”์œ„ | ์˜๋„์ ์œผ๋กœ **๋„“๊ฒŒ** ์œ ์ง€ (๊ธฐ์กด ์ž๋™๋ณต๊ตฌ ํ‡ดํ–‰ ๋ฐฉ์ง€). ์ขํžŒ ๊ฒƒ์€ `missing`๋ฟ | ํ˜„์žฌ ์„ค์น˜๋ณธ better-sqlite3 **12.8.0**์€ `install` ํ›…(`prebuild-install || node-gyp rebuild --release`)์ด ์žˆ์–ด `npm rebuild`๊ฐ€ ๋ณต๊ตฌ ๊ฒฝ๋กœ๋‹ค (๋กœ์ปฌ `node_modules`์—์„œ ํ™•์ธ). ์ƒ์œ„ ๋ฉ”์ด์ €์—์„œ ๋ฒˆ๋“ค prebuilds๋กœ ์ „ํ™˜๋˜๋ฉฐ ํ›…์ด ์‚ฌ๋ผ์ง„๋‹ค๋Š” ๋ณด๊ณ ๊ฐ€ ์žˆ์œผ๋ฏ€๋กœ โ€” ๋กœ์ปฌ์—์„œ ๊ฒ€์ฆ ๋ถˆ๊ฐ€ โ€” **์—…๊ทธ๋ ˆ์ด๋“œ ์‹œ ์ด ๊ฐ€์ •์„ ๋ฐ˜๋“œ์‹œ ์žฌํ™•์ธํ•  ๊ฒƒ.** ### `bin/jaw` ๋Ÿฐ์ฒ˜ ๊ทœ์น™ - ๊ฒฝ๋กœ๋ฅผ **JavaScript ์†Œ์Šค๋กœ ๋ณด๊ฐ„ํ•˜์ง€ ์•Š๋Š”๋‹ค** โ€” argv๋กœ ์ „๋‹ฌ (๊ณต๋ฐฑยท์•„ํฌ์ŠคํŠธ๋กœํ”ผยท์œ ๋‹ˆ์ฝ”๋“œ ์•ˆ์ „) - `readlink -f`๋ฅผ ์š”๊ตฌํ•˜์ง€ ์•Š๋Š”๋‹ค (GNU ํ™•์žฅ; stock macOS/BSD์— ์—†์Œ) โ€” `realpath` โ†’ Node `fs.realpathSync` - ๋ณต๊ตฌ ๋ถ„๊ธฐ์˜ `cd`๋Š” ์„œ๋ธŒ์…ธ์— ๊ฐ€๋‘”๋‹ค โ€” `exec`๋˜๋Š” CLI๊ฐ€ ํ˜ธ์ถœ์ž์˜ cwd๋ฅผ ์œ ์ง€ํ•ด์•ผ ํ•จ - ๋ณต๊ตฌ ์‹คํŒจ ์‹œ `exec`ํ•˜์ง€ ์•Š๋Š”๋‹ค โ€” ์ข…๋ฃŒ์ฝ”๋“œ ๊ฒ€์‚ฌ ํ›„ ์ง„๋‹จ๊ณผ ํ•จ๊ป˜ exit ### ํ”„๋กœ์„ธ์Šค ์ข…๋ฃŒ ๊ณ„์•ฝ (`src/agent/spawn/process-kill.ts`) ์ง€์—ฐ SIGKILL ์Šน๊ฒฉ์€ ๋ฐ˜๋“œ์‹œ `killProcessTreeIfAlive()`๋ฅผ ๊ฑฐ์นœ๋‹ค. ํŒ์ • ๊ธฐ์ค€์€ `exitCode !== null || signalCode !== null`์ด๋ฉฐ **`ChildProcess.killed`๊ฐ€ ์•„๋‹ˆ๋‹ค** โ€” `killed`๋Š” "์‹œ๊ทธ๋„์„ ๋ณด๋ƒˆ๋‹ค"๋Š” ๋œป์ด๋ผ ์•„์ง ์‹คํ–‰ ์ค‘์ธ ํ”„๋กœ์„ธ์Šค๋„ `true`๊ฐ€ ๋œ๋‹ค. ๊ฐ€๋“œ ์—†์ด ์Šน๊ฒฉํ•˜๋ฉด SIGTERM ํ›„ ์žฌ์‚ฌ์šฉ๋œ PID๋ฅผ ์ฃฝ์ผ ์ˆ˜ ์žˆ๊ณ , `killProcessTree`๊ฐ€ `pgrep -P`๋กœ ์žฌ๊ท€ํ•˜๋ฏ€๋กœ ๋ฌด๊ด€ํ•œ ํ”„๋กœ์„ธ์Šค์˜ ํ•˜์œ„ ํŠธ๋ฆฌ๊นŒ์ง€ ํ•จ๊ป˜ ์ฃฝ๋Š”๋‹ค. ### ํšŒ๊ท€ ๊ฐ€๋“œ ํ…Œ์ŠคํŠธ `tests/unit/cli-native-guard-contract.test.ts`, `launcher-portability.test.ts`, `native-repair-lock.test.ts`, `kill-escalation-liveness.test.ts`. ๋งˆ์ง€๋ง‰ ํŒŒ์ผ์—๋Š” ๊ฐ€๋“œ ์—†๋Š” ์ง€์—ฐ SIGKILL์ด ์ƒˆ๋กœ ์ถ”๊ฐ€๋˜๋ฉด ์‹คํŒจํ•˜๋Š” ์Šค์œ• ํ…Œ์ŠคํŠธ๊ฐ€ ์žˆ๋‹ค. --- ## ๋Ÿฐํƒ€์ž„ ์ˆ˜๋ช…์ฃผ๊ธฐ ๊ณ„์•ฝ (openclaw/hermes ํŒŒ๋ฆฌํ‹ฐ) ### ํ„ด ์ข…๋ฃŒ โ€” `close`์ด์ง€ `exit`์ด ์•„๋‹ˆ๋‹ค ํ„ด์€ `child.on('close')`์—์„œ resolve๋œ๋‹ค. `close`๋Š” ์ž์‹ ์ข…๋ฃŒ๊ฐ€ ์•„๋‹ˆ๋ผ **stdio ์ŠคํŠธ๋ฆผ์ด ์ „๋ถ€ ๋‹ซํ˜€์•ผ** ๋ฐœ์ƒํ•˜๋ฏ€๋กœ, stdio๋ฅผ ์ƒ์†ํ•œ ์ž์†์ด ์‚ด์•„์žˆ์œผ๋ฉด ์˜ค์ง€ ์•Š๋Š”๋‹ค. `src/agent/spawn/exit-drain.ts`์˜ `releaseChildOutputAfterExit()`๊ฐ€ ์ด ๋Œ€๊ธฐ๋ฅผ ๊ฒฝ๊ณ„ ์ง“๋Š”๋‹ค: | ์ƒ์ˆ˜ | ๊ฐ’ | ์—ญํ•  | |------|-----|------| | `EXIT_DRAIN_IDLE_MS` | 100ms | ๋งˆ์ง€๋ง‰ ๋ฐ์ดํ„ฐ ์ดํ›„ ์œ ํœด ์œ ์˜ˆ. ์ƒˆ ๋ฐ์ดํ„ฐ๊ฐ€ ์˜ค๋ฉด **์žฌ๋ฌด์žฅ** | | `EXIT_DRAIN_MAX_MS` | 1000ms | ์ ˆ๋Œ€ ์ƒํ•œ | idle ๋งŒ๋ฃŒ ์‹œ `setImmediate`๋กœ ์ด๋ฒคํŠธ ๋ฃจํ”„ poll ํ„ด์„ **ํ•œ ๋ฒˆ ์–‘๋ณด**ํ•œ ๋’ค destroyํ•œ๋‹ค โ€” ๋ถ€ํ•˜ ๊ฑธ๋ฆฐ ๋ฃจํ”„๋Š” ์ด๋ฏธ ๋ฒ„ํผ์— ์žˆ๋Š” ๋ฐ์ดํ„ฐ๋ณด๋‹ค ํƒ€์ด๋จธ๋ฅผ ๋จผ์ € ๊ด€์ธกํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ๋ชจ๋“  ํƒ€์ด๋จธ๋Š” `unref()`๋˜๊ณ , `close`/`error` ์–‘์ชฝ ๊ฒฝ๋กœ์—์„œ ์ •๋ฆฌ ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•œ๋‹ค. **์ฃผ์˜:** ์›Œ์น˜๋…์€ ์ด ์ƒํ™ฉ์„ ๊ตฌ์ œํ•˜์ง€ ๋ชปํ•œ๋‹ค. ์ž์‹์€ ์ด๋ฏธ ์ฃฝ์—ˆ๊ณ , PID ์žฌ์‚ฌ์šฉ ๊ฐ€๋“œ๊ฐ€ (์˜ฌ๋ฐ”๋ฅด๊ฒŒ) kill์„ ๊ฑด๋„ˆ๋›ด๋‹ค. ํŒŒ์ดํ”„ destroy๋งŒ์ด ์œ ์ผํ•œ ํ•ด์†Œ ์ˆ˜๋‹จ์ด๋‹ค. ### ์ถœ๋ ฅ ๋ˆ„์  ์ƒํ•œ โ€” ์›์‹œ stdout์—๋งŒ ํ•„์š”ํ•˜๋‹ค | ๋Œ€์ƒ | ์ƒํ•œ | ์ด์œ  | |------|------|------| | ๋ฏธ์™„ NDJSON ๋ผ์ธ (`spawn/line-buffer.ts`) | 8 MiB (pending cap = frame cap) | ๊ฐœํ–‰ ์—†๋Š” ์ŠคํŠธ๋ฆผ์ด ๋ผ์ธ ๋ฒ„ํผ๋ฅผ ๋ฌดํ•œํžˆ ํ‚ค์šด๋‹ค. ์‹ค์ธก 200 MiB ์ž…๋ ฅ โ†’ ํž™ 1.5 GiB | | agy/kiro `fullText` | 8 MiB / `maxBytes` | **์›์‹œ plain-text stdout**์„ ์ง์ ‘ ์ถ•์  | | ํŒŒ์‹ฑ๋œ assistant ์ด๋ฒคํŠธ ๊ฒฝ๋กœ | ์—†์Œ (์˜๋„์ ) | ์ƒ๋ฅ˜๊ฐ€ ์œ ํ•œ. ๊ณผ๊ฑฐ ์ƒํ•œ์ด ์‹ค์ œ ์ตœ์ข… ๋‹ต๋ณ€์„ ์ž˜๋ผ๋จน์€ ์‚ฌ๊ณ (`8b4ce983b`) | | `stderr` | 4000์ž (์ŠคํŠธ๋ฆฌ๋ฐ append ์ „๋ถ€) | ์ง„๋‹จ ์ „์šฉ | ์ ˆ๋‹จ์€ ํ•ญ์ƒ **๋ณด๊ณ **ํ•œ๋‹ค. ์กฐ์šฉํ•œ ์ ˆ๋‹จ์€ ๊ธˆ์ง€๋‹ค. NDJSON ํ”„๋ ˆ์ด๋จธ(`spawn/line-buffer.ts`)์˜ ๋‘ ์ƒํ•œ์€ ๊ตฌ๋ถ„๋œ๋‹ค: **pending cap**์€ ์ง„ํ–‰ ์ค‘์ธ ํ”„๋ ˆ์ž„์˜ ๋ฉ”๋ชจ๋ฆฌ ์ƒํ•œ์ด๊ณ , **frame cap**์€ ์™„์„ฑ ํ”„๋ ˆ์ž„์˜ ์ˆ˜๋ฝยท๊ฑฐ์ ˆ ๊ธฐ์ค€์ด๋‹ค. ๋‘˜์€ ๊ฐ™์€ ๊ฐ’(8 MiB)์„ ๊ณต์œ ํ•˜๋ฏ€๋กœ ์ˆ˜๋ฝ ์—ฌ๋ถ€๊ฐ€ chunk ๋ถ„ํ• ์— ๋”ฐ๋ผ ๋‹ฌ๋ผ์ง€์ง€ ์•Š๋Š”๋‹ค โ€” ์ƒํ•œ์„ ๋„˜๋Š” ํ”„๋ ˆ์ž„์€ ํ•œ chunk๋กœ ๋„์ฐฉํ•˜๋“  ์—ฌ๋Ÿฌ chunk๋กœ ๋‚˜๋‰˜๋“  ํ•ญ์ƒ ํ๊ธฐ๋œ๋‹ค. ํ๊ธฐ๋œ ํ”„๋ ˆ์ž„์€ ๊ฒฝ๊ณ„๊ฐ€ ๋˜๋Š” LF๊นŒ์ง€ drain๋˜๋ฉฐ ์ž˜๋ฆฐ head์— suffix๋ฅผ ๋ถ™์—ฌ ๋‹ค๋ฅธ payload๋กœ ์ „๋‹ฌํ•˜์ง€ ์•Š๋Š”๋‹ค(#784). print ๊ฒฝ๋กœ(`spawn.ts`)์˜ drop์€ `ndjson_overflow` trace ์ด๋ฒคํŠธ์™€ ๊ฒฝ๊ณ ๋กœ ๋ณด๊ณ ๋˜๊ณ (bounded head sample + ์ด ๊ธธ์ด), ๊ทธ LF ์ดํ›„์˜ ์ •์ƒ ํ”„๋ ˆ์ž„์€ ์˜ค์—ผ๋˜์ง€ ์•Š๋Š”๋‹ค. Pi RPC ๊ฒฝ๋กœ๋Š” ๊ฒฝ๊ณ ๋งŒ ๋‚จ๊ธฐ๊ณ , ํ”„๋กฌํ”„ํŠธ ์ง„ํ–‰ ์ค‘์˜ drop์€ ๊ทธ ํ„ด์„ ์ฆ‰์‹œ `error`๋กœ ๋๋‚ธ๋‹ค (ํ’€ ์„ธ์…˜์€ poison๋˜์–ด ์žฌ์‚ฌ์šฉ๋˜์ง€ ์•Š๋Š”๋‹ค). ### ์ง„ํ–‰(progress) ํŒ์ • ์›Œ์น˜๋…์€ ์ง„ํ–‰ ์‹ ํ˜ธ์— ์ข…๋ฅ˜๋ฅผ ๋ถ€์—ฌํ•œ๋‹ค: `output`(์›์‹œ ์ถœ๋ ฅ, ์•ฝํ•œ ์‹ ํ˜ธ) / `rate-limit` / `structured`. stall ์‚ฌ์œ ์— `lastProgress=`๋ฅผ ๋‚จ๊ธฐ๋ฏ€๋กœ, `lastProgress=output x47`์€ **ํ„ด์ด ์ „์ง„ํ–ˆ๋‹ค๋Š” ์ฆ๊ฑฐ ์—†์ด ์ถœ๋ ฅ๋งŒ ํ˜๋ €๋‹ค**๋Š” ๋œป์ด๋‹ค. deadline ๊ณ„์‚ฐ์€ ์ข…๋ฅ˜์™€ ๋ฌด๊ด€ํ•˜๋‹ค โ€” `markProgress()`๋Š” ์–ด๋–ค kind๋กœ ํ˜ธ์ถœ๋˜๋“  ๋™์ผํ•˜๊ฒŒ `absoluteDeadline`์„ ๊ฐฑ์‹ ํ•˜๋ฉฐ, `absoluteHardCapMs`(4์‹œ๊ฐ„)๊ฐ€ ์ƒํ•œ์ด๋‹ค. ์ฆ‰ ์ข…๋ฅ˜ ํƒœ๊น…์€ **์ง„๋‹จ ์ „์šฉ**์ด๊ณ  ํƒ€์ž„์•„์›ƒ ๋™์ž‘์„ ๋ฐ”๊พธ์ง€ ์•Š๋Š”๋‹ค. ํœด๋ฆฌ์Šคํ‹ฑ(`text.trim().length > 10`)์„ ์ขํžˆ์ง€ ์•Š์€ ์ด์œ ๋Š” ์ฃผ์š” ์—”์ง„(agyยทkiroยทgrok)์ด ๊ฐ์ž raw chunk ๋˜๋Š” ํŒŒ์‹ฑ ์ด๋ฒคํŠธ ๊ฒฝ๋กœ์—์„œ `markProgress`๋ฅผ ์ง์ ‘ ํ˜ธ์ถœํ•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. `watchdog.ts`๋งŒ ์ขํ˜€๋„ ๊ทธ ์—”์ง„๋“ค์˜ liveness๋Š” ๊ทธ๋Œ€๋กœ๋‹ค. ### ์žฌ์‹œ๋„ โ€” ๋ถ€์ž‘์šฉ ๊ฒŒ์ดํŠธ ํ”„๋กฌํ”„ํŠธ๋ฅผ ์žฌ์‹คํ–‰ํ•˜๋Š” **์„ธ ๊ฒฝ๋กœ**(main 429 / employee transient / **fallback**)๋Š” ๋ชจ๋‘ `performedSideEffects(ctx)`๋ฅผ ํ™•์ธํ•œ๋‹ค. ```ts const REPEATABLE_TOOL_TYPES = new Set(['search', 'thinking']); // search = grep/web-search/read-url, thinking = ์ถ”๋ก  ์ŠคํŠธ๋ฆผ // command/file/subagent + ๋ฏธ์ง€์˜ ํƒ€์ž… = ๋ถ€์ž‘์šฉ (fail closed) ``` ์žฌ์‹œ๋„๋Š” ๊ฐ™์€ ํ”„๋กฌํ”„ํŠธ๋ฅผ ๋‹ค์‹œ ๋Œ๋ฆฌ๋ฏ€๋กœ ์ด์ „ ์‹œ๋„๊ฐ€ ์‹คํ–‰ํ•œ ๋„๊ตฌ๊ฐ€ **๋‹ค์‹œ ์‹คํ–‰**๋œ๋‹ค. `_skipInsert`๋Š” ๋กœ์ปฌ DB ํ–‰๋งŒ ๋ง‰๊ณ  ์™ธ๋ถ€ ์ „์†กยท์ปค๋ฐ‹ยทํŒŒ์ผ ์“ฐ๊ธฐ๋Š” ๋ง‰์ง€ ๋ชปํ•œ๋‹ค. ๊ฑฐ๋ถ€๋œ ์žฌ์‹œ๋„๋Š” ์ด์œ ๋ฅผ ๋กœ๊ทธ๋กœ ๋‚จ๊ธด๋‹ค. `isTransientStartup`์€ **์ถœ๋ ฅ์ด ์—†์„ ๋•Œ๋งŒ** ์ธ์ •๋œ๋‹ค โ€” ์ด๋ฆ„์ด ์•ฝ์†ํ•˜๋Š” "์ž‘์—… ์‹œ์ž‘ ์ „"์„ ๊ตฌํ˜„์ด ๋ณด์žฅํ•˜๊ฒŒ ํ–ˆ๋‹ค. ### ํšŒ๊ท€ ๊ฐ€๋“œ ํ…Œ์ŠคํŠธ `exit-drain.test.ts`, `line-buffer-bound.test.ts`, `raw-stdout-capture-bound.test.ts`, `progress-semantics.test.ts`, `retry-side-effect-gate.test.ts`, `retry-stall-ordering.test.ts`. --- ### session-generation.ts / access-policy.ts / remote-command-context.ts (M4-A0) M4-A2a adds opaque `issueApprovalCallback` / `resolveApprovalCallback` on the in-memory `DispatchApprovalStore`. Telegram operator DMs attach Approve/Deny buttons (`appr:`/`aprd:` opaque ids). Discord operator DMs attach Approve/Deny buttons (same `appr:`/`aprd:` ids). Slack operator DMs attach Approve/Deny Block Kit buttons (same `appr:`/`aprd:` ids). Generic Slack `keyboard` send stays unsupported (`interactiveActions: false`). HTTP still has no approve endpoint. Store `generation` is the process boot UUID (`restart_void`); callback `sessionGeneration` is `chat_sessions.generation`. `src/core/session-generation.ts` owns persistent `chat_sessions.generation` (additive PRAGMA/ALTER). This integer is not `src/agent/session-persistence.ts` process-local spawn ownership. `replaceRemoteSessionGeneration` rebinds one conversation onto one session in a single transaction because `remote_session_bindings.chat_session_id` is UNIQUE. `src/messaging/access-policy.ts` is default-deny substrate (`deny` / `allowlist` / `paired` / `all`) with no production caller until M4-A1. `src/messaging/remote-command-context.ts` names `{channel, actorId, conversationKey, chatSessionId, generation}` so the three transports cannot invent three shapes. ## src/core/ โ€” runtime support cluster (30 files, 3803L) `boss-auth.ts`, `config.ts`, `codex-config.ts`, `instance.ts`, `runtime-path.ts`, `main-session.ts`, `message-summary.ts`, `path-expand.ts`, `runtime-settings.ts`, `runtime-settings-gate.ts`, `settings-merge.ts`, `db.ts`, `db-maintenance.ts`, `bus.ts`, `employees.ts`, `i18n.ts`, `compact.ts`, `logger.ts`, `claude-install.ts`, `launchd-cleanup.ts`, `launchd-plist.ts`, `tcc.ts`. | Module | ์—ญํ•  | | --- | --- | | `config.ts` | ๊ฒฝ๋กœ/์„ค์ •/CLI ํƒ์ง€ + `JAW_HOME`/`settings.json`/`skills_ref`/`messaging`/`network` defaults | | `codex-config.ts` | Codex `config.toml` read-only diagnostics (root `openai_base_url`) | | `instance.ts` | launchd/systemd์šฉ instance ID + node/jaw binary resolution | | `runtime-path.ts` | ์„œ๋น„์Šค/launchd ํ™˜๊ฒฝ์—์„œ PATH ์ •๊ทœํ™” (`~/.local/bin`, `~/.claude/local/bin`, nvm/fnm/asdf/bun/homebrew ํฌํ•จ) | | `main-session.ts` | active_cli/session_id/model/working_dir/effort sync + reset helpers | | `message-summary.ts` | message preview/summary helper | | `path-expand.ts` | shell-style path expansion helper | | `runtime-settings.ts` | `applyRuntimeSettingsPatch()` ์ง„์ž…์ , workingDir ์žฌ์ƒ์„ฑ, messaging restart | | `runtime-settings-gate.ts` | settings mutation in-flight gate | | `settings-merge.ts` | nested settings deep merge (`telegram`, `discord`, `messaging`, `memory`, `stt`, `tui`, `network`) | | `db.ts` | SQLite schema/prepared statements + one-time batched tool_log migration | | `db-maintenance.ts` | schema_migrations marker, page/freelist stats, explicit checkpoint+VACUUM | | `bus.ts` | broadcast hub + named listener lifecycle | | `employees.ts` | default employee seeding + static/virtual synthetic employee helpers + regenerate | | `i18n.ts` | locale normalize + `t()` | | `compact.ts` | compact marker / transcript helpers | | `logger.ts` | minimal console logger shim | | `boss-auth.ts` | boss/employee scope ๋ถ„๋ฆฌ์šฉ auth helper | | `claude-install.ts` | Claude CLI ์„ค์น˜ ์ƒํƒœ ์ ๊ฒ€ helper | | `launchd-cleanup.ts` | launchd stale plist / runtime cleanup | | `launchd-plist.ts` | launchd plist ์ƒ์„ฑ helper | | `tcc.ts` | macOS TCC / screen-recording ๊ถŒํ•œ ์ ๊ฒ€ | --- ## src/core/platform-kind.ts โ€” ํ”Œ๋žซํผ ๋ถ„๋ฅ˜ ๋‹จ์ผ ์†Œ์Šค `windows-native | wsl | linux | darwin | other` ๋ฅผ ํŒ์ •ํ•˜๋Š” ์œ ์ผํ•œ ๊ธฐ์ค€์ . ํ”Œ๋žซํผ์„ ๋‹ค์‹œ ์œ ์ถ”ํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ์ƒˆ๋กœ ๋งŒ๋“ค์ง€ ๋ง๊ณ  ์ด ๋ชจ๋“ˆ์„ ํ˜ธ์ถœํ•œ๋‹ค. ### ์—„๊ฒฉ ๊ทœ์น™ `process.platform` ์ด ๋จผ์ €๋‹ค. `win32` ํ”„๋กœ์„ธ์Šค๋Š” ์–ด๋–ค ํ™˜๊ฒฝ๋ณ€์ˆ˜๊ฐ€ ๋“ค์–ด์™€๋„ `windows-native` ์ด๊ณ , WSL ๋ถ„๊ธฐ๋Š” `linux` ์—์„œ๋งŒ ๋„๋‹ฌํ•  ์ˆ˜ ์žˆ๋‹ค. ๋‘ ๊ฐ’์€ ๊ตฌ์กฐ์ ์œผ๋กœ ๊ฒน์น˜์ง€ ์•Š๋Š”๋‹ค. **`WSLENV` ์€ ํŒ์ •์— ์“ฐ์ง€ ์•Š๋Š”๋‹ค.** Microsoft ๋ฌธ์„œ์ƒ ์ด ๋ณ€์ˆ˜๋Š” Windows ์ชฝ๊ณผ ๊ณต์œ ๋˜๋Š” ๊ฐ’์ด๋ผ WSL ์•ˆ์— ์žˆ๋‹ค๋Š” ์ฆ๊ฑฐ๊ฐ€ ๋ชป ๋œ๋‹ค. ์‹ค์ œ๋กœ doctor ์™€ postinstall ์ด ์ด ๋ณ€์ˆ˜๋ฅผ ๊ฒ€์‚ฌํ•˜๋Š” ๋ฐ”๋žŒ์—, WSL interop ์„ ์„ค์ •ํ•ด ๋‘” ๋„ค์ดํ‹ฐ๋ธŒ Windows ์‚ฌ์šฉ์ž์—๊ฒŒ "WSL ์•ˆ์—์„œ Windows Node ๋ฅผ ์“ฐ๊ณ  ์žˆ๋‹ค"๋Š” ๊ฒฝ๊ณ ๊ฐ€ ๋‚˜๊ฐ”๋‹ค. ### API | ํ•จ์ˆ˜ | ์—ญํ•  | | --- | --- | | `resolvePlatformKind(platform, env, probes)` | ํ”Œ๋žซํผ ๋ถ„๋ฅ˜. ๋ชจ๋“  ์ž…๋ ฅ์ด ์ฃผ์ž… ๊ฐ€๋Šฅํ•˜๋ฏ€๋กœ ํ•œ OS ์—์„œ ์ „์ฒด ๋งคํŠธ๋ฆญ์Šค๋ฅผ ํ…Œ์ŠคํŠธํ•  ์ˆ˜ ์žˆ๋‹ค | | `isWindowsNative(platform)` | `platform === 'win32'`. env ๋ฅผ ๋ฐ›์ง€ ์•Š๋Š” ๊ฒƒ์ด ์˜๋„๋‹ค | | `isWsl(platform, env, probes)` | WSL ์—ฌ๋ถ€ | | `isWindowsNodeLaunchedFromWsl(platform, cwd)` | WSL ๋””๋ ‰ํ„ฐ๋ฆฌ์—์„œ ์‹คํ–‰๋œ Windows Node. ํ™˜๊ฒฝ๋ณ€์ˆ˜๊ฐ€ ์•„๋‹ˆ๋ผ UNC ์ž‘์—… ๋””๋ ‰ํ„ฐ๋ฆฌ(`\\wsl$\`, `\\wsl.localhost\`)๋กœ ํŒ์ •ํ•œ๋‹ค | | `resolveInvocationCwd(env)` | `INIT_CWD` ์šฐ์„ . npm lifecycle script ๋Š” ํŒจํ‚ค์ง€ ๋ฃจํŠธ์—์„œ ๋Œ๊ธฐ ๋•Œ๋ฌธ์— `process.cwd()` ๋กœ๋Š” ์‚ฌ์šฉ์ž์˜ ๋””๋ ‰ํ„ฐ๋ฆฌ๋ฅผ ์•Œ ์ˆ˜ ์—†๋‹ค | WSL ์ฆ๊ฑฐ๋Š” `WSL_DISTRO_NAME`, `WSL_INTEROP`, `/run/WSL`, `/proc/sys/fs/binfmt_misc/WSLInterop`, ๊ทธ๋ฆฌ๊ณ  `osrelease`/`/proc/version` ์˜ `microsoft` ๋ฌธ์ž์—ด์ด๋‹ค. ๋งˆ์ง€๋ง‰ ํ•ญ๋ชฉ์€ ์ปค์Šคํ…€ ์ปค๋„์—์„œ ๋น ์งˆ ์ˆ˜ ์žˆ์–ด ๊ฒฝ๋กœ ๋งˆ์ปค๊ฐ€ ๋ฐฑ์—… ์—ญํ• ์„ ํ•œ๋‹ค. ### ์œ„์ž„ ์‚ฌ์ดํŠธ (4๊ณณ) `src/core/browser-open.ts`, `src/core/browser-open-default.ts`, `src/browser/connection.ts`, `bin/commands/doctor.ts` ๊ฐ€ ๋ชจ๋‘ ์ด ๋ชจ๋“ˆ๋กœ ์œ„์ž„ํ•œ๋‹ค. `tests/unit/platform-kind-delegation.test.ts` ๊ฐ€ ์ด ๋„ค ํŒŒ์ผ์— `WSL_DISTRO_NAME`/`WSL_INTEROP`/`WSLENV` ๋‚˜ `/proc/version` ์ง์ ‘ ์ฐธ์กฐ๊ฐ€ ์—†๋Š”์ง€ ๊ฒ€์‚ฌํ•œ๋‹ค. `bin/postinstall.ts` ๋Š” ์œ„์ž„ ์‚ฌ์ดํŠธ๊ฐ€ ์•„๋‹ˆ๋‹ค. "์ด Windows ํ”„๋กœ์„ธ์Šค๊ฐ€ WSL ๋””๋ ‰ํ„ฐ๋ฆฌ์—์„œ ์‹œ์ž‘๋๋Š”๊ฐ€"๋ผ๋Š” ๋‹ค๋ฅธ ์งˆ๋ฌธ์„ ํ•˜๋ฏ€๋กœ `isWindowsNodeLaunchedFromWsl` ์„ ์“ด๋‹ค. `src/lib/tui/terminal.ts` ๋Š” ์˜๋„์ ์œผ๋กœ ์ œ์™ธํ–ˆ๋‹ค. ๋ฃจํŠธ `tsconfig.json` ์ด `src/lib/tui` ๋ฅผ ์ œ์™ธํ•˜๊ณ  ์žˆ๊ณ  ๊ทธ ํŒŒ์ผ์˜ `$env` ๋Š” ๊ฐ์ฒด๊ฐ€ ์•„๋‹ˆ๋ผ ํ•จ์ˆ˜๋ผ์„œ, ํƒ€์ž… ๊ฒ€์‚ฌ๋„ ๋˜์ง€ ์•Š๋Š” vendored ๋ฒˆ๋“ค์„ ๊ตณ์ด ํ†ต๊ณผ์‹œํ‚ฌ ์ด์œ ๊ฐ€ ์—†๋‹ค. ๋ธŒ๋ผ์šฐ์ € ํ—ฌํผ๋“ค์€ `probes` ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ๋ฐ›๋Š”๋‹ค. ์ด๊ฒŒ ์—†์œผ๋ฉด desktop-linux ํ”ฝ์Šค์ฒ˜๊ฐ€ ์‹ค์ œ ํ˜ธ์ŠคํŠธ์˜ `/proc` ๋ฅผ ์ฝ์–ด์„œ WSL ๋Ÿฌ๋„ˆ์—์„œ ๊ฒฐ๊ณผ๊ฐ€ ๋’ค์ง‘ํžŒ๋‹ค. ### Windows serve ๋กœ๊น… `jaw serve` ๋Š” ์ƒ์†๋ฐ›์€ stdout/stderr ์ถœ๋ ฅ์„ ๊ทธ๋Œ€๋กœ ์œ ์ง€ํ•˜๋ฉด์„œ ๋‘ ์ŠคํŠธ๋ฆผ์„ `\logs\serve.log` ์— append ํ•œ๋‹ค. ์„œ๋ฒ„ ์‹œ์ž‘ ์‹œ ํŒŒ์ผ์ด 5 MiB ์ด์ƒ์ด๋ฉด ๊ธฐ์กด `serve.log.1` ์„ ๊ต์ฒดํ•˜๊ณ  ํ˜„์žฌ ํŒŒ์ผ์„ ๊ทธ ์ด๋ฆ„์œผ๋กœ ํ•œ ๋‹จ๊ณ„ rotate ํ•œ๋‹ค. PowerShell `Start-Process -RedirectStandardOutput/-RedirectStandardError` ๋Š” ๋Œ€์ƒ ํŒŒ์ผ์„ ์‹œ์ž‘๋งˆ๋‹ค ์ƒ์„ฑํ•˜๊ฑฐ๋‚˜ truncateํ•œ๋‹ค. ๋”ฐ๋ผ์„œ ์ด ์˜ต์…˜์„ instance-owned `serve.log` ์— ์—ฐ๊ฒฐํ•˜์ง€ ์•Š๋Š”๋‹ค. ๋ณ„๋„ ์šด์˜์ž ๋กœ๊ทธ๊ฐ€ ํ•„์š”ํ•˜๋ฉด child PowerShell์˜ append redirection์„ ์‚ฌ์šฉํ•œ๋‹ค. ```powershell $jawHome = 'C:\jaw\worker-a' $logDir = Join-Path $jawHome 'logs' $outLog = Join-Path $logDir 'serve.out.log' $errLog = Join-Path $logDir 'serve.err.log' New-Item -ItemType Directory -Force -Path $logDir | Out-Null $jaw = (Get-Command jaw.cmd -ErrorAction Stop).Source $command = "& '$jaw' --home '$jawHome' serve --no-open 1>> '$outLog' 2>> '$errLog'" $encoded = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($command)) Start-Process powershell.exe -ArgumentList '-NoProfile', '-EncodedCommand', $encoded -WindowStyle Hidden ``` --- ## src/cli/registry.ts โ€” CLI/๋ชจ๋ธ ๋‹จ์ผ ์†Œ์Šค (231L) **์˜์กด ์—†์Œ** โ€” `core/config.ts`, `cli/commands.ts`, `server.ts`, ํ”„๋ก ํŠธ์—”๋“œ๊ฐ€ ๋ชจ๋‘ ์ด ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ๋ฅผ ์ฐธ์กฐ. | Export | ์—ญํ•  | | --- | --- | | `CLI_REGISTRY` | 10๊ฐœ CLI ์ •์˜ (`pi`, `agy`, `claude`, `codex`, `codex-app`, `cursor`, `grok`, `kiro-code`, `opencode`, `copilot`; ๋‚˜๋จธ์ง€๋Š” ๋™์ผ) | | `CLI_KEYS` | `Object.keys(CLI_REGISTRY)` โ€” ์ˆœ์„œ ๋ณด์žฅ ๋ฐฐ์—ด | | `DEFAULT_CLI` | ๊ธฐ๋ณธ CLI (`claude` ์šฐ์„ , ์—†์œผ๋ฉด ์ฒซ ํ•ญ๋ชฉ) | | `buildDefaultPerCli()` | registry์—์„œ ๊ธฐ๋ณธ `perCli` ๊ฐ์ฒด ๋นŒ๋“œ | | `buildModelChoicesByCli()` | CLI๋ณ„ ๋ชจ๋ธ ๋ชฉ๋ก ๋งต ๋นŒ๋“œ | --- ## src/cli/api-auth.ts โ€” CLI Auth Helper (45L) CLI โ†’ ์„œ๋ฒ„ API ํ˜ธ์ถœ ์‹œ ์ธ์ฆ ํ† ํฐ์„ ๊ด€๋ฆฌํ•˜๋Š” ๊ฒฝ๋Ÿ‰ ํ—ฌํผ. ํฌํŠธ๋ณ„ ํ† ํฐ ์บ์‹ฑ์œผ๋กœ ๋ฉ€ํ‹ฐ ์ธ์Šคํ„ด์Šค๋ฅผ ์ง€์›ํ•œ๋‹ค. | Function | ์—ญํ•  | | --- | --- | | `getCliAuthToken(portOrBase?)` | `settings.json`์—์„œ `authToken` ์ฝ๊ธฐ. ํฌํŠธ๋ณ„ ์บ์‹œ | | `authHeaders(extra?)` | `{ Authorization: 'Bearer ', ...extra }` ํ—ค๋” ์ƒ์„ฑ | | `cliFetch(url, init?)` | `fetch()` + ์ž๋™ auth header ์ฃผ์ž… ๋ž˜ํผ | ์‚ฌ์šฉ์ฒ˜: `dispatch.ts`, `orchestrate.ts`, `reset.ts`, `employee.ts`, `memory.ts`, `browser.ts`, `tui/api.ts` --- ## src/core/config.ts โ€” ๊ฒฝ๋กœ, ์„ค์ •, CLI ํƒ์ง€ (528L) **์ƒ์ˆ˜**: `JAW_HOME` (`CLI_JAW_HOME` env || `~/.cli-jaw`) ยท `PROMPTS_DIR` ยท `DB_PATH` ยท `SETTINGS_PATH` ยท `HEARTBEAT_JOBS_PATH` (`heartbeat.json`) ยท `UPLOADS_DIR` ยท `SKILLS_DIR` ยท `SKILLS_REF_DIR` ยท `MIGRATION_MARKER` ยท `DEFAULT_PORT` (`3457`) ยท `CDP_PORT_OFFSET` (`5783`) ยท `APP_VERSION` (package.json) | Function | ์—ญํ•  | | --- | --- | | `ensureDirs()` | `prompts/`, `uploads/`, `skills/`, `skills_ref/` ์ƒ์„ฑ | | `runMigration()` | legacy `claw.db`/project-local settings โ†’ `~/.cli-jaw/` migration | | `loadSettings()` | settings.json ๋กœ๋“œ + normalize/migration | | `saveSettings(s)` | ์„ค์ • ์ €์žฅ | | `replaceSettings(s)` | ESM live binding ๋Œ€์ฒด | | `loadHeartbeatFile()` / `saveHeartbeatFile()` | `heartbeat.json` ์ฝ๊ธฐ/์“ฐ๊ธฐ | | `deriveCdpPort(serverPort?)` | server port + offset์œผ๋กœ browser CDP port ๊ณ„์‚ฐ; valid overflow๋Š” 1024โ€“65535 modular rotation์œผ๋กœ ๊ณ ์œ  wrap, invalid input์€ 9240 | | `getServerUrl(port)` | `http://localhost:${port || process.env.PORT || settings.port || DEFAULT_PORT}` | | `getWsUrl(port)` | websocket URL ์ƒ์„ฑ | | `detectCli(name)` | `buildServicePath()`๋ฅผ ์ ์šฉํ•œ `which`/`where` ๊ธฐ๋ฐ˜ ๋ฐ”์ด๋„ˆ๋ฆฌ ์กด์žฌ ํ™•์ธ | | `detectAllCli()` | registry ๊ธฐ๋ฐ˜ CLI ์ƒํƒœ ๋ฐ˜ํ™˜ | | `buildDefaultPerCli()` | registry์—์„œ ๊ธฐ๋ณธ perCli ๋นŒ๋“œ | `settings` ๊ธฐ๋ณธ๊ฐ’์—๋Š” `showReasoning`, `channel`, `telegram.forwardAll`, `discord.forwardAll`, `messaging.lastActive/latestSeen`, `memory.autoReflectAfterFlush`, `memory.flushMessageWindow`, `avatar.*`, `stt.*`, `network.bindHost/lanBypass/remoteAccess`๊ฐ€ ํฌํ•จ๋œ๋‹ค. `--home`์€ `cli-jaw.ts`์—์„œ `CLI_JAW_HOME`์œผ๋กœ ์ฃผ์ž…๋œ ๋’ค ์ด ๋ชจ๋“ˆ์ด ๋กœ๋“œ๋œ๋‹ค. ### Current registry defaults | CLI | Default Model | Notable model aliases | | --- | --- | --- | | `pi` | `grok-composer-2.5-fast` | Pi RPC runtime with isolated profile/model registration | | `agy` | AGY-selected | print-mode runtime; `--model` is capability-gated (observed in AGY 1.1.4); no separate effort flag. Model values must be the tier-bearing label form that `agy --model` accepts on its own, e.g. `Gemini 3.6 Flash (Medium)`. A bare tier-less slug such as `gemini-3.5-flash` is rejected (`requires --effort`) because cli-jaw never sends `--effort` for AGY. Note `agy models` prints effort-suffixed slugs (`gemini-3.6-flash-medium`), which is a different form โ€” do not copy that output into the registry | | `claude` | `claude-opus-5-5` (homes on the old `claude-opus-4-8` default move once the installed CLI supports it) | canonical choices include `opus`, `sonnet`, `sonnet[1m]`, `haiku`; pinned full IDs include `claude-opus-5`/`claude-opus-5[1m]`; legacy aliases normalize | | `codex` | `gpt-5.5` | inactive ocx fallback shows only `gpt-5.5`, `gpt-5.4`, `gpt-5.4-mini`, `gpt-5.3-codex-spark`; when ocx health is ok, `/model` completions and `/api/cli-registry` expand from ocx `/v1/models` including routed models | | `codex-app` | `gpt-5.5` | Codex app-server runtime using the same inactive fallback / active ocx model choices as `codex` | | `cursor` | `composer-2.5` | uses `cursor-agent --model `; effort resolves into model ids such as `composer-2.5-fast`, `gpt-5.5-medium-fast`, `claude-opus-5-xhigh`, or `claude-opus-4-7-thinking-high-fast` | | `grok` | `grok-build` | effort disabled because `grok-build` rejects `reasoningEffort`; auth/readiness via `grok models` | | `opencode` | `opencode-go/kimi-k2.6` | includes current opencode-go provider aliases such as `glm-5.1`, `kimi-k2.6`, `mimo-v2.5`, `minimax-m2.7`, `qwen3.6-plus`, `deepseek-v4-*` | | `copilot` | `claude-sonnet-4.6` | includes `gpt-5.5`, Claude 4.x aliases, `gpt-5.4*`, `gpt-5.3-codex`, `gpt-5.2-codex` | --- ## src/core/codex-config.ts โ€” Codex config.toml Read-only Diagnostics (26L) `~/.codex/config.toml`์„ ์ฝ๊ธฐ๋งŒ ํ•œ๋‹ค. ์ด ํŒŒ์ผ์€ cli-jaw ๋ฐ–์˜ Codex CLI/์•ฑ๊ณผ ๊ณต์œ ๋˜๋ฏ€๋กœ cli-jaw๋Š” ์“ฐ์ง€ ์•Š๋Š”๋‹ค. context window/auto-compact ๊ธฐ์ค€๊ฐ’์€ Codex ์ž์ฒด ๊ธฐ๋ณธ๊ฐ’์„ ๋”ฐ๋ฅธ๋‹ค(#815์—์„œ ๋™์ž‘ํ•˜์ง€ ์•Š๋˜ ์„ค์ • ํŽ˜์ด์ง€ ์Šฌ๋ผ์ด๋”์™€ config.toml ๋™๊ธฐํ™” ์ œ๊ฑฐ). | Function | ์—ญํ•  | | --- | --- | | `readCodexRootOpenAiBaseUrl(content?)` | TOML ํ…Œ์ด๋ธ” ๋ฐ– root `openai_base_url`๋งŒ ์ฝ์Œ | --- ## src/core/db.ts โ€” Database (388L) ```sql session (id='default', active_cli, session_id, model, permissions, working_dir, effort, updated_at) messages (id PK, role, content, cli, model, trace, tool_log, cost_usd, duration_ms, working_dir, created_at) memory (id PK, key UNIQUE, value, source, created_at, updated_at) employees (id PK, name, cli, model, role, status, created_at) employee_sessions (employee_id PK, session_id, cli, model, created_at) orc_state (id PK, state, ctx, updated_at) queued_messages (id PK, payload, created_at) jaw_ceo_transcript (id PK, at, role, text, source, created_at) schema_migrations (name PK, applied_at) ``` Virtual employees are not written to `employees` or `employee_sessions`. `src/core/employees.ts` emits `SyntheticEmployeeRow` values with `virtual:` IDs for one-off dispatch, and `src/orchestrator/distribute.ts` skips session resume/persist for those IDs. `trace`, `tool_log`, and `working_dir` are added by in-place migration if missing. Oversized legacy `tool_log` rows are re-sanitized in 25-row transactions once, tracked by `schema_migrations`; boot only warns above 30% free pages, while `jaw db maintain` owns checkpoint + VACUUM. `working_dir` also gets `idx_messages_wd`; Jaw CEO transcript rows are bounded by the coordinator persistence layer. | Prepared Statement | ์šฉ๋„ | | --- | --- | | `insertMessage` | `(role, content, cli, model, working_dir)` | | `insertMessageWithTrace` | `(role, content, cli, model, trace, tool_log, working_dir)` | | `getMessages` | working_dir ํฌํ•จ UI/API ์กฐํšŒ | | `getMessagesWithTrace` | full row ์กฐํšŒ | | `getRecentMessages` | `WHERE working_dir = ? OR working_dir IS NULL` ํžˆ์Šคํ† ๋ฆฌ ๋นŒ๋”์šฉ | | `insertQueuedMessage` / `listQueuedMessages` / `deleteQueuedMessage` | agent queue ์˜์†ํ™” | --- ## src/core/bus.ts โ€” Broadcast Bus (57L) ์ˆœํ™˜ ์˜์กด ๋ฐฉ์ง€ ํ—ˆ๋ธŒ. ์˜์กด 0. Public audience๋Š” `src/core/event-bus.ts`๋กœ SSE publishํ•˜๊ณ , internal listener fan-out์€ audience์™€ ๋ฌด๊ด€ํ•˜๊ฒŒ ์ˆ˜ํ–‰ํ•œ๋‹ค. X-01 ์ดํ›„ current server์—๋Š” public WebSocket broadcast registration์ด ์—†๋‹ค. | Function | ์—ญํ•  | | --- | --- | | `inferTopic(type)` | broadcast type โ†’ SSE topic ๋งคํ•‘ | | `broadcast(type, data, audience?)` | public audience๋Š” SSE publish, ๋ชจ๋“  audience๋Š” ๋‚ด๋ถ€ ๋ฆฌ์Šค๋„ˆ fan-out | | `addBroadcastListener(fn)` | ๋‚ด๋ถ€ ๋ฆฌ์Šค๋„ˆ ์ถ”๊ฐ€ | | `removeBroadcastListener(fn)` | ํŠน์ • ํ•ธ๋“ค๋Ÿฌ ์ œ๊ฑฐ | | `clearAllBroadcastListeners()` | ํ…Œ์ŠคํŠธ/์ดˆ๊ธฐํ™”์šฉ listener set ๋น„์šฐ๊ธฐ | > `removeBroadcastListener(fn)`๋Š” named handler lifecycle์— ๋งž์ถฐ ์ •ํ™•ํžˆ ํ•ด๋‹น ์ฐธ์กฐ๋งŒ ์ œ๊ฑฐํ•œ๋‹ค. --- ## src/messaging/ โ€” shared messaging runtime (44 files) ### ack-reaction.ts / queue-notice.ts ACK ๋ฆฌ์•ก์…˜๊ณผ ํ ์•ˆ๋‚ด ์ƒ๋ช…์ฃผ๊ธฐ๋Š” ์ฑ„๋„์ด ์•„๋‹ˆ๋ผ ์ด ๊ณ„์ธต์ด ์†Œ์œ ํ•œ๋‹ค (#410, #411). ์„ธ ์ฑ„๋„์ด ๊ฐ์ž ํด๋กœ์ €๋กœ ์ฒ˜๋ฆฌํ•˜๋˜ ๊ฒƒ์„ ์˜ฌ๋ฆฐ ๊ฒƒ์ด๊ณ , ์ด์œ ๋Š” ๊ทธ๋ ‡๊ฒŒ ๋‘๋ฉด ๋งค๋ฒˆ ์„ธ ๋ฒˆ ํ‹€๋ฆฌ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. `ack-reaction.ts` โ€” received/running -> success/failure ์ƒํƒœ๋จธ์‹ . ์ „์ด๋ฅผ ๋‚ด๋ถ€ promise chain์œผ๋กœ ์ง๋ ฌํ™”ํ•œ๋‹ค: lane runner๊ฐ€ task๋ฅผ ๋™๊ธฐ ์‹œ์ž‘ํ•  ์ˆ˜ ์žˆ์–ด(`orchestrator/session-lanes.ts`) settle์ด running์˜ ๋ฒค๋” ํ˜ธ์ถœ์„ ์ถ”์›”ํ•  ์ˆ˜ ์žˆ๋‹ค. terminal์€ ๋ฒค๋” ํ˜ธ์ถœ **์ „์—** settled๋ฅผ ์„ธ์›Œ ์ฒซ outcome์ด ์ด๊ธด๋‹ค. apply๊ฐ€ rejectํ•˜๋ฉด applied๋ฅผ ๊ฐฑ์‹ ํ•˜์ง€ ์•Š๋Š”๋‹ค โ€” Slack API๊ฐ€ ์‹คํŒจ๋ฅผ throwํ•˜์ง€ ์•Š๊ณ  {ok:false}๋กœ ๋Œ๋ ค์ฃผ๋ฏ€๋กœ transport๊ฐ€ ๊ฒ€์‚ฌํ•ด์„œ throwํ•ด์•ผ ํ•œ๋‹ค. `resolveAckEmoji`๊ฐ€ ์œ ์ผํ•œ ์ด๋ชจ์ง€ ๊ฒฐ์ • ์ง€์ ์ด๊ณ  ์ฑ„๋„ ์ œ์•ฝ์€ ๊ฐ transport์˜ coerce๊ฐ€ ์ฒ˜๋ฆฌํ•œ๋‹ค. ์ฑ„๋„๋ณ„ ๊ธฐ๋ณธ๊ฐ’๊ณผ `mergeAckSettings`(์ค‘์ฒฉ ๋ณ‘ํ•ฉ, boot/API/watch 3๊ฒฝ๋กœ ๊ณต์œ )๋„ ์—ฌ๊ธฐ์„œ. `queue-notice.ts` โ€” ์•ˆ๋‚ด ์ƒ๋ช…์ฃผ๊ธฐ. ํ•ต์‹ฌ์€ ์‚ญ์ œ๊ฐ€ ์•„๋‹ˆ๋ผ **์ˆœ์„œ**๋‹ค: ์•ˆ๋‚ด๋Š” await๋กœ ๊ฒŒ์‹œ๋˜๋Š”๋ฐ ๊ทธ ์‚ฌ์ด ํ ์ž‘์—…์ด ๋๋‚  ์ˆ˜ ์žˆ์–ด ์ •๋ฆฌ๊ฐ€ ๋Œ€์ƒ๋ณด๋‹ค ๋จผ์ € ๋„์ฐฉํ•œ๋‹ค. ํ•˜๋‚˜์˜ deferred completion์„ ๋ชจ๋“  close() ํ˜ธ์ถœ์ž๊ฐ€ ๊ณต์œ ํ•˜๊ณ , ๋Šฆ์€ bind()๊ฐ€ ๋ฒค๋” ์ž‘์—…์„ ๋๋‚ธ ๋’ค resolve ํ•œ๋‹ค โ€” ๋จผ์ € resolveํ•˜๋ฉด drain์ด ์š”์ฒญ ๋„์ค‘์— transport๋ฅผ ๋‚ด๋ฆฐ๋‹ค. answered๋Š” ์‚ญ์ œ, expired๋Š” ๋งŒ๋ฃŒ ๋ฌธ๊ตฌ๋กœ ํŽธ์ง‘(๋‹ต๋ณ€์ด ์˜์˜ ์•ˆ ์˜จ ํ„ด์˜ ํ”์ ์„ ์ง€์šฐ์ง€ ์•Š๋Š”๋‹ค). abandon()์€ post ์‹คํŒจ์šฉ. `QueueNoticeRegistry.drain(timeoutMs)`์ด ์…ง๋‹ค์šด์„ ์†Œ์œ ํ•˜๋ฉฐ deadline์—์„œ ์‹ค์ œ๋กœ abort ํ•œ๋‹ค โ€” race๋กœ ๋ฐ˜ํ™˜๋งŒ ํ•˜๋Š” ๊ฒƒ์€ ๊ธฐ๋‹ค๋ฆผ์„ ๋ฉˆ์ถœ ๋ฟ ์š”์ฒญ์„ ์ทจ์†Œํ•˜์ง€ ์•Š๋Š”๋‹ค. ์ฑ„๋„์€ transport ํŒฉํ† ๋ฆฌ๋งŒ ์ œ๊ณตํ•œ๋‹ค: Slack reactions.add/remove + chat.delete/update, Telegram setMessageReaction(replace ์˜๋ฏธ๋ก  + ReactionTypeEmoji ํ—ˆ์šฉ๋ชฉ๋ก 73๊ฐœ, ์ฒดํฌ/์—‘์Šค ํ‘œ์‹œ๋Š” ๋ชฉ๋ก์— ์—†์–ด ์—„์ง€ ์‚ฌ์šฉ), Discord ์ €์ˆ˜์ค€ client.rest(๊ณ ์ˆ˜์ค€ helper๊ฐ€ request options๋ฅผ ๋„˜๊ธฐ์ง€ ์•Š์•„ ์ทจ์†Œ ๋ถˆ๊ฐ€). ์„ธ ์ฑ„๋„ ๋ชจ๋‘ reaction: true ์ด๋ฉฐ payload/route ์บก์ฒ˜ ํ…Œ์ŠคํŠธ๊ฐ€ ๋’ท๋ฐ›์นจํ•œ๋‹ค. ### durable-ingress.ts / ingress-audit.ts `IngressJournal` rows stamp `session_generation`. A redelivery whose generation no longer matches is `stale_generation` and is not claimed. `IngressJournal` is the SQLite record of every inbound Telegram/Discord/Slack event. Transports call `admitIngress`/`settleIngress`. Slack ACK stays after preflight admit; Slack settle is handle early-returns plus the ingress lane around `processSlackMessageEvent`, and a Slack failure after ACK is `dead_letter` because Slack will not redeliver. Operators inspect and recover with `jaw messaging ingress list|show|replay|audit`. `requestReplay` is a state CAS back to `received`. Nothing in-process re-runs the handler โ€” vendor redelivery does. Replay audit is append-only JSONL at `$JAW_HOME/messaging-ingress-audit.jsonl`. `admitIngress` enters that row's existing `trace_id` into `MessagingTraceContext` so a later `log.event` on the same turn can stamp it; it does not mint a second id. `/api/health` adds `channels.ingress` from `IngressJournal.counts()` and this-process `channels.metrics`; `jaw messaging doctor --json` reads the same SQLite file locally and cannot see the server ring. `gate:messaging-conformance` is the 22nd release gate: it re-runs the existing three-channel contract suites and writes a `functional-certified` artifact. It is not a chaos matrix and it is not `release-certified`. A file-backed restart is `tests/integration/messaging-ingress-restart.test.ts`: a second `IngressJournal` on the same `jaw.db` path. Completed stays `already_handled`; mid-flight keeps the stored `trace_id`. `append` treats a primary-key clash from a second connection as `duplicate`. A locked or full database still throws so Slack can refuse ACK. `src/messaging/effect-once.ts` owns `effect_claims`. `src/messaging/outbound-outbox.ts` owns `outbound_attempts`. A row is reserved before the vendor call. `ambiguous` is reachable only from `sending` and is terminal for the automatic path. Non-terminal and `ambiguous` attempts block the ingress retention sweep. A claim is held by `owner_id` + `claim_token`; an expired lease lets a new owner claim the row but never re-runs the effect body, and `manual` is the terminal hold for an outcome nobody can determine. Non-terminal claims block the ingress retention sweep. `sendSlackText` waits a short Slack `ratelimited`/429 and retries that chunk once. A long Retry-After still surfaces. The chunk loop does not restart. `sendChannelOutput` emits `outbound.send` on the current messaging ALS. Empty ALS stays empty โ€” no second id. `forwarder-origin.ts` โ€” ์ฑ„๋„ forwarder์˜ ๊ณตํ†ต origin ํ•„ํ„ฐ๋‹ค. ์ž๊ธฐ ์ฑ„๋„์—์„œ ์‹œ์ž‘ํ•œ ํ„ด๊ณผ producer๊ฐ€ ์ง์ ‘ ๋ฐฐ๋‹ฌํ•˜๋Š” `heartbeat` ๊ฒฐ๊ณผ๋ฅผ ๊ฑด๋„ˆ๋›ด๋‹ค. ํ•˜ํŠธ๋น„ํŠธ๋Š” ์ง€์ • destination์œผ๋กœ ์ง์ ‘ ๋ณด๋‚ธ๋‹ค. Forwarder๋Š” last-active๋ฅผ ์ฝ์ง€ ์•Š๋Š”๋‹ค; ํ•€์ด ์—†์œผ๋ฉด ์นจ๋ฌต์ด๋‹ค. ํ•˜ํŠธ๋น„ํŠธ๋ฅผ forwarder์— ํƒœ์šฐ๋ฉด ์ง€์ • destination์— ์ค‘๋ณต ๋ฐœํ™”๊ฐ€ ์ƒ๊ธด๋‹ค. Telegram/Discord/Slack ์ฑ„๋„์˜ ํ™œ์„ฑ ํƒ€๊ฒŸ ์ƒํƒœ์™€ outbound routing์„ ๊ณต์œ ํ•œ๋‹ค. `settings.messaging.lastActive/latestSeen`๋ฅผ ์œ ์ง€ํ•˜๊ณ , `core/runtime-settings.ts`์˜ restart ๊ฒฝ๋กœ๊ฐ€ ์ด ๋ ˆ์ด์–ด๋ฅผ ๋‹ค์‹œ ์ดˆ๊ธฐํ™”ํ•œ๋‹ค. Persisted target์€ channel/target/peer kind์™€ optional thread/guild/parent ํ•„๋“œ๊นŒ์ง€ ๊ฒ€์ฆํ•œ ๋’ค ๋ณต์›ํ•œ๋‹ค. `thread-target.ts` โ€” `threadIdNumber(target)` extracts `message_thread_id` for programmatic Telegram sends (P0 forum topic support). ### ์ฑ„๋„ ๊ณตํ†ต ํ•˜๋“œ๋‹ ๋ชจ๋“ˆ (260802) Slack ์ฑ„๋„ ์œ ๋‹›์—์„œ ํ™•๋ฆฝํ•œ ์ „์†ก ๊ทœ์œจ์„ Discord/Telegram์— ์†Œ๊ธ‰ ์ ์šฉํ•˜๋ฉฐ ์ถ”๊ฐ€๋œ ๊ณต์œ  ๋ ˆ์ด์–ด. ์ฑ„๋„๋ณ„ ๊ตฌํ˜„์„ ๋‘๋ฉด ํ•œ์ชฝ๋งŒ ๊ณ ์ณ์ง€๋Š” ๋ฌธ์ œ๊ฐ€ ๋ฐ˜๋ณต๋˜์–ด, ์ „ ์ฑ„๋„์ด ์ง€๋‚˜๋Š” choke point๋กœ ๋ชจ์•˜๋‹ค. | ํŒŒ์ผ | ์—ญํ•  | | --- | --- | | `chunk.ts` | ๋ฌด์†์‹ค ๋ถ„ํ• . ์„œ๋กœ๊ฒŒ์ดํŠธ ํŽ˜์–ด๋ฅผ ์ชผ๊ฐœ์ง€ ์•Š๊ณ , ์ฝ”๋“œํŽœ์Šค ๊ท ํ˜•๊ณผ ์–ธ์–ด ํƒœ๊ทธ๋ฅผ ์œ ์ง€ํ•œ๋‹ค. Discord/Slack/Telegram์ด ๋ชจ๋‘ ์ด ์ฝ”์–ด๋ฅผ ์“ด๋‹ค. **๋‹จ์„œ**: delimiter ์ž์ฒด๊ฐ€ ์ฑ„๋„ ํ•œ๋„๋ณด๋‹ค ๊ธธ๋ฉด(๋ฐฑํ‹ฑ 2,001๊ฐœ์งœ๋ฆฌ ์œ ํšจ fence ๋“ฑ) ์žฌ๊ฐœ๊ฐ€ ํ•œ๋„๋ฅผ ๋„˜๊ธฐ๋ฏ€๋กœ ํŽœ์Šค ๋ณต๊ตฌ๋ฅผ ํฌ๊ธฐํ•œ๋‹ค โ€” ๋ฌด์†์‹คยท์„œ๋กœ๊ฒŒ์ดํŠธ ์•ˆ์ „ยทํ•œ๋„ ์ค€์ˆ˜๋Š” ๊ทธ๋Œ€๋กœ ์œ ์ง€๋˜๊ณ , continuation์ด prose๋กœ ๋ Œ๋”๋ง๋  ๋ฟ์ด๋‹ค. | | `fold.ts` | ์ •๊ทœํ™” ํด๋”ฉ. escape ๋””์ฝ”๋“œ + invisible ์ œ๊ฑฐ + NFKC๋ฅผ ๊ณ ์ •์ ๊นŒ์ง€ ๋ฐ˜๋ณตํ•˜๋ฉฐ, ๊ฐ ๋ฌธ์ž๊ฐ€ ์›๋ฌธ ์–ด๋””์„œ ์™”๋Š”์ง€ ์˜คํ”„์…‹ ๋งต์œผ๋กœ ์ถ”์ ํ•œ๋‹ค. **์ขŒํ‘œ๊ณ„๋Š” ์ „๋ถ€ UTF-16 code unit.** | | `redact.ts` | ํฌ๋ฆฌ๋ด์…œ ๋งˆ์Šคํ‚น. `redactOutboundText`(๋ณธ๋ฌธ), `redactOutboundPayload`(keyboard ๋“ฑ ๊ตฌ์กฐํ™” payload), `userErrorText`/`logErrorText`(์˜ค๋ฅ˜)๋ฅผ ์ œ๊ณตํ•œ๋‹ค. | | `dedupe.ts` | ๋ฐฐ๋‹ฌ ์ค‘๋ณต ์ œ๊ฑฐ. TTL seen-set์ด๋ฉฐ, sweep์€ **๋งŒ๋ฃŒ๋œ ํ•ญ๋ชฉ๋งŒ** ์ง€์šด๋‹ค โ€” ๋ฏธ๋งŒ๋ฃŒ ํ•ญ๋ชฉ์„ ํฌ๊ธฐ ๋งž์ถ”๋ ค ์ซ“์•„๋‚ด๋ฉด ๋ง‰์œผ๋ ค๋˜ ์ค‘๋ณต์ด ๋‹ค์‹œ ์ƒ๊ธด๋‹ค. | | `retry.ts` | ์ „์†ก ์‹คํŒจ ๋ถ„๋ฅ˜. `format`๋งŒ ํ˜•์‹ ํด๋ฐฑ์„ ์–ป๊ณ , `rate-limit`์€ ๋Œ€๊ธฐ ํ›„ ๊ฐ™์€ ํ˜•์‹ ์žฌ์‹œ๋„, `ambiguous`๋Š” ์ค‘๋ณต ์ „์†ก ์œ„ํ—˜์ด ์žˆ์–ด ์ค‘๋‹จํ•œ๋‹ค. | ๋งˆ์Šคํ‚น์€ **์ „์†ก ์ง์ „(last mile)**์— ๊ฑด๋‹ค. ํ˜ธ์ถœ๋ถ€๋งˆ๋‹ค ๊ฑธ๋ฉด ๋ฐ˜๋“œ์‹œ ํ•˜๋‚˜๊ฐ€ ๋ˆ„๋ฝ๋˜๊ณ , ์‹ค์ œ๋กœ ๊ฐ์‚ฌ ๊ณผ์ •์—์„œ ๋ฐ˜๋ณตํ•ด์„œ ๋ฐœ๊ฒฌ๋๋‹ค. ์˜ค๋ฅ˜ ๊ฒฝ๋กœ๋งŒ์œผ๋กœ๋Š” ๋ถ€์กฑํ•˜๋‹ค โ€” ํฌ๋ฆฌ๋ด์…œ์€ ํ‰๋ฒ”ํ•œ ๋ฉ”์‹œ์ง€ ๋ณธ๋ฌธยท์บก์…˜ยท๋ฒ„ํŠผ ๋ผ๋ฒจยท๋กœ๊ทธ preview๋กœ๋„ ํ๋ฅธ๋‹ค. ### runtime.ts (146L) | Function | ์—ญํ•  | | --- | --- | | `registerTransport()` | ์ฑ„๋„๋ณ„ init/shutdown ๋“ฑ๋ก | | `getEnabledChannels()` | ํ˜„์žฌ enabled ์ฑ„๋„ ๋ชฉ๋ก ๋ฐ˜ํ™˜ | | `getHomeChannel()` | ํ˜„์žฌ home ์ฑ„๋„ ๋ฐ˜ํ™˜ | | `initEnabledMessagingRuntimes()` | enabled ์ฑ„๋„ ๊ฐ๊ฐ transport init | | `shutdownMessagingRuntime()` | ์ „์ฒด transport shutdown | | `restartMessagingRuntime()` | enabled set, per-channel config, locale ๋ณ€๊ฒฝ ์‹œ ์˜ํ–ฅ ์ฑ„๋„๋งŒ restart (home-only ๋ณ€๊ฒฝ์€ restart ์—†์Œ) | | `setLastActiveTarget()` / `getLastActiveTarget()` | ๋งˆ์ง€๋ง‰ ํ™œ์„ฑ ํƒ€๊ฒŸ ์ถ”์  | | `setLatestSeenTarget()` / `getLatestSeenTarget()` | ์ตœ์‹  ๊ด€์ธก ํƒ€๊ฒŸ ์ถ”์  | | `clearTargetState()` | stale target ์ œ๊ฑฐ | | `hydrateTargetsFromSettings()` | persisted `settings.messaging` ๋ณต์› | ### send.ts (147L) ํŒŒ์ผ ์ „์†ก์€ `ok`(๋ฒค๋”๊ฐ€ ๋ฐ”์ดํŠธ๋ฅผ ๋ฐ›์•˜๋‹ค)์™€ `confirmation`(๋ฒค๋”๊ฐ€ ๋ฌด์—‡์„ ๋งŒ๋“ค์—ˆ๋Š”์ง€ ๋งํ–ˆ๋‹ค)์„ ๋ถ„๋ฆฌํ•œ๋‹ค. ์–ดํœ˜๋Š” `file-receipt.ts` ๊ฐ€ ๊ฐ–๊ณ , `confirmation` ์€ ๋ฐ˜๋“œ์‹œ **์ตœ์ƒ์œ„ ํ•„๋“œ**๋‹ค โ€” `sendChannelOutput` ์ด `isUnconfirmedSend(sanitized)` ๋กœ ๊ทธ๊ฑธ ์ฝ์–ด, unconfirmed ์ „์†ก์—๋„ caption ์ž๊ธฐ๋ฐฐ๋‹ฌ ์ฒญ๊ตฌ๋ฅผ ๋‚จ๊ธฐ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ์ค‘์ฒฉ๋œ ์˜์ˆ˜์ฆ์— ์ˆจ๊ธฐ๋ฉด ๊ทธ ์˜ˆ์™ธ๊ฐ€ ๋ฐœ๋™ํ•˜์ง€ ์•Š๊ณ  ๋””์ŠคํŒจ์น˜ ๊ฒฝ๋กœ๊ฐ€ ๊ฐ™์€ caption ์„ ํ•œ ๋ฒˆ ๋” ๊ฒŒ์‹œํ•œ๋‹ค. ํ™•์ • ์‹คํŒจ(400/413/auth)๋Š” ์ด ์˜ˆ์™ธ๋ฅผ ๋นŒ๋ฆฌ์ง€ ๋ชปํ•œ๋‹ค โ€” ์•„๋ฌด๊ฒƒ๋„ ๋ฐฐ๋‹ฌํ•˜์ง€ ์•Š์•˜์œผ๋ฏ€๋กœ ํ„ด์˜ ์ง„์งœ ๋‹ต๋ณ€์ด ๋‚˜๊ฐ€์•ผ ํ•œ๋‹ค. ์„ธ ์ฑ„๋„์˜ ๋ฏธํ™•์ธ ๊ธฐ์ค€์€ ๋ฒค๋” ๋ฌธ์„œ์—์„œ ์™”๋‹ค. Slack ์€ `files[]` echo ๊ฐ€ ์—†๋Š” completion, Telegram ์€ `message_id` ๊ฐ€ 0 ์ด๊ฑฐ๋‚˜ ์—†๋Š” ์‘๋‹ต(0 ์€ "์•„์ง ์‹ค์ œ๋กœ ์ „์†ก๋˜์ง€ ์•Š์•˜๋‹ค"๋Š” ๋ฒค๋” ์ •์˜), Discord ๋Š” Create Message ๊ฐ€ message id ๋ฅผ ๋Œ๋ ค์ฃผ์ง€ ์•Š์€ ๊ฒฝ์šฐ๋‹ค. **Discord ์˜ ๊ฑฐ์ ˆ์€ `sendDiscordFileRest` ์•ˆ์—๋งŒ ๋‘”๋‹ค** โ€” ๊ฐ™์€ `DiscordRestScheduler` ๊ฐ€ reaction/delete/unpin ๋„ ๋‚˜๋ฅด๊ณ  ๊ฑฐ๊ธฐ์„œ๋Š” 204 ๊ฐ€ ๋ฌธ์„œํ™”๋œ ์ •์ƒ ์„ฑ๊ณต์ด๋‹ค. ์ƒํƒœ ์ฝ”๋“œ๋Š” `FILE_UNCONFIRMED_STATUS`(502)์ด๊ณ  4xx ๊ฐ€ ์•„๋‹ˆ๋‹ค: ์š”์ฒญ์— ์ž˜๋ชป๋œ ๊ฒƒ์ด ์—†๊ณ , ์—์ด์ „ํŠธ๊ฐ€ ์žฌ์‹œ๋„ํ•ด์•ผ ํ•  ์ผ๋„ ์•„๋‹ˆ๋‹ค(์ด๋ฏธ ๋„์ฐฉํ–ˆ์„ ์ˆ˜ ์žˆ๋‹ค). `confirmation` ์€ ์ค‘๊ฐ„ ๊ณ„์ธต์ด ๋ฒ—๊ธฐ๋ฉด ์˜๋ฏธ๊ฐ€ ์—†๋‹ค. Telegram Hub ๋ฆด๋ ˆ์ด(`sendToTopic` โ†’ ํ—ˆ๋ธŒ ๋ผ์šฐํŠธ โ†’ ๋ฉค๋ฒ„ ํ•ธ๋“ค๋Ÿฌ)์™€ legacy `/api/telegram/send` ๊ฐ€ ๊ทธ ํ•„๋“œ๋ฅผ ํ†ต๊ณผ์‹œํ‚ค๋Š” ์ด์œ ๊ฐ€ ์ด๊ฒƒ๋ฟ์ด๋‹ค (#700). | Export | ์—ญํ•  | | --- | --- | | `ChannelSendRequest` | outbound request ํƒ€์ž… | | `registerSendTransport()` | ์ฑ„๋„๋ณ„ send ํ•จ์ˆ˜ ๋“ฑ๋ก | | `normalizeChannelSendRequest()` | HTTP body โ†’ request ์ •๊ทœํ™” | | `validateTarget()` | allowlist + full target shape ๊ฒ€์ฆ. ๋นˆ Slack allowlist์—์„œ explicit target์€ ๊ฒ€์ฆ๋œ `lastActive/latestSeen`์˜ ๊ฐ™์€ conversation/thread๋งŒ ์žฌ์‚ฌ์šฉ ๊ฐ€๋Šฅ | | `sendChannelOutput()` | explicit target > **validated turn address** > validated lastActive > validated latestSeen > configured fallback ์ˆœ์œผ๋กœ ์ „์†ก | ์ถ”๊ฐ€๋กœ `validateTarget()`์ด Telegram `allowedChatIds`์™€ Discord `channelIds`/thread parent๋ฅผ ๊ฐ™์ด ๊ฒ€์‚ฌํ•˜๊ณ , stale cached target์ด๋ฉด `clearTargetState()`๋กœ ๋ฐ”๋กœ ๋น„์šด๋‹ค. ### session-key.ts (27L) | Function | ์—ญํ•  | | --- | --- | | `buildRemoteSessionKey(target)` | ๋ฆฌ๋ชจํŠธ ์„ธ์…˜ ํ‚ค ์ƒ์„ฑ | | `groupQueueKey(origin, target)` | origin+target ํ ๊ทธ๋ฃน ํ‚ค ์ƒ์„ฑ | ### types.ts (27L) `MessengerChannel` (`telegram` | `discord`), `RemoteTarget`, `OutboundType`, `RuntimeOrigin` ํƒ€์ž… ์ •์˜. --- ## src/telegram/ โ€” Telegram transport (9 files) `bot.ts`, `forwarder.ts`, `rich-message.ts`, `telegram-file.ts`, `elicitation-buttons.ts`, `voice.ts`, `hub-callback.ts`, `status-update-buffer.ts`, `fetch-body.ts`. - `bot.ts` โ€” thread-aware programmatic send (P0) + hub-member outbound relay (P2b) - `rich-message.ts` โ€” Bot API 10.1 rich Markdown, the default outbound text path - `elicitation-buttons.ts` โ€” single_select fences rendered as inline keyboards - `hub-callback.ts` โ€” loopback-only SSRF guard for hub callback URL - `status-update-buffer.ts` โ€” coalesces tool-status edits - `fetch-body.ts` โ€” IPv4-pinned fetch body helper ### bot.ts (859L) Telegram transport main entry. `registerTransport('telegram', ...)`์™€ `registerSendTransport('telegram', ...)`๋ฅผ ๋“ฑ๋กํ•˜๊ณ , `settings.telegram.forwardAll`, allowlist, mention gating, voice, attachment, slash command ํ๋ฆ„์„ ๋ชจ๋‘ ์ฒ˜๋ฆฌํ•œ๋‹ค. ๋ฏธ๋“ค์›จ์–ด ์ˆœ์„œ๊ฐ€ ์ค‘์š”ํ•˜๋‹ค: self-echo ๊ฐ€๋“œ โ†’ ๋กœ๊น… โ†’ allowlist โ†’ mention gating โ†’ dedupe. dedupe์ด ๋งˆ์ง€๋ง‰์ธ ์ด์œ ๋Š” ์•ž ๊ฒŒ์ดํŠธ์—์„œ ๋ฒ„๋ ค์งˆ ํŠธ๋ž˜ํ”ฝ์ด seen-set์„ ์ฑ„์šฐ์ง€ ์•Š๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋‹ค โ€” ์ฒ˜๋ฆฌ ๋Œ€์ƒ์ธ ์ค‘๋ณต์€ ์–ด์ฐจํ”ผ ๊ฐ™์€ ๊ฒŒ์ดํŠธ๋ฅผ ํ†ต๊ณผํ•˜๋ฏ€๋กœ ๋ณด์žฅ์€ ๊ทธ๋Œ€๋กœ๋‹ค. self-echo ๊ฐ€๋“œ๋Š” `getMe()`๋กœ ์–ป์€ ๋ด‡ id๋ฅผ ์“ฐ๊ณ , ๊ทธ ํ˜ธ์ถœ์ด ๋๋‚˜๊ธฐ ์ „ ๊ตฌ๊ฐ„์€ `is_bot` ํ”Œ๋ž˜๊ทธ๋กœ ๋ฎ๋Š”๋‹ค. ๋กœ๊น…๋ณด๋‹ค ์•ž์— ๋‘์–ด ์ž๊ธฐ ์—์ฝ”๊ฐ€ ๋กœ๊ทธ๋ฅผ ์˜ค์—ผ์‹œํ‚ค์ง€ ์•Š๊ฒŒ ํ•œ๋‹ค. `settings.telegram.allowBots`๋Š” Discord์™€ ๋Œ€์นญ์ด๋ฉฐ ๊ธฐ๋ณธ false๋‹ค. P0: thread-aware programmatic send via `thread-target.ts`. P2b: hub-member outbound relay to Dashboard `/api/dashboard/telegram-hub/outbound`. | Function | ์—ญํ•  | | --- | --- | | `initTelegram()` | Bot ์ƒ์„ฑ + handler registration + forwarder lifecycle | | `shutdownTelegram()` | Bot/forwarder shutdown | | `makeTelegramCommandCtx()` | Telegram์šฉ ctx ์ƒ์„ฑ + `applyRuntimeSettingsPatch()` | | `syncTelegramCommands(bot)` | `getTelegramMenuCommands()` ๊ธฐ๋ฐ˜ `setMyCommands` | | `sendTelegramText()` | outbound text send | | `buildTelegramTarget()` | `RemoteTarget` ์ƒ์„ฑ (`threadId` when `message_thread_id` present) | ### forwarder.ts (105L) `createTelegramForwarder()`๋Š” `agent_done`๋งŒ forwardingํ•˜๊ณ , `shouldSkip`์œผ๋กœ Telegram-origin ๊ฒฐ๊ณผ๋ฅผ ์ œ์™ธํ•œ๋‹ค. `createForwarderLifecycle()`๋Š” detach/attach๋ฅผ ๊ด€๋ฆฌํ•œ๋‹ค. ### voice.ts (36L) `handleVoice(ctx)`๋Š” Telegram voice ํŒŒ์ผ์„ ๋‚ด๋ ค๋ฐ›์•„ `lib/stt.ts`๋กœ ์ „์‚ฌํ•œ ๋’ค `tgOrchestrate()`๋กœ ๋„˜๊ธด๋‹ค. ### telegram-file.ts (133L) Telegram file upload / retry helper. ํ…์ŠคํŠธ๊ฐ€ ์•„๋‹Œ media send์™€ attachment ์ „๋‹ฌ์— ์‚ฌ์šฉ๋œ๋‹ค. Optional `{ threadId }` for forum topics. ### hub-callback.ts (19L) `resolveHubCallback()` โ€” loopback-only SSRF guard for hub-member outbound callback URL. Default `http://127.0.0.1:24576`. ### shared runtime points - Telegram๊ณผ Discord๋Š” ๋ชจ๋‘ `src/messaging/runtime.ts`์— ์ž๊ธฐ transport๋ฅผ ๋“ฑ๋กํ•œ๋‹ค. - Telegram/Discord ์„ค์ • ๋ณ€๊ฒฝ์€ `core/runtime-settings.ts`๋ฅผ ํ†ตํ•ด ๊ฐ™์€ restart ๊ฒฝ๋กœ๋ฅผ ํƒ„๋‹ค. - `settings.messaging.lastActive/latestSeen`๋Š” Interactive omit-target ๊ณผ inbound vouch ์šฉ์ด๋‹ค. `agent_done` forward ๋Œ€์ƒ์ด ์•„๋‹ˆ๋‹ค. - **ํ„ด ์ฃผ์†Œ(`turnTarget`)๋Š” ์ €์žฅ๋˜์ง€ ์•Š๋Š”๋‹ค.** ์ธ๋ฐ”์šด๋“œ ํ„ด์˜ ํ”„๋กฌํ”„ํŠธ์— `reply_to=` ๋กœ ์‹ค๋ ค ๋‚˜๊ฐ€๊ณ  ์—์ด์ „ํŠธ๊ฐ€ `/api/channel/send` ์˜ `turn_conversation` ์œผ๋กœ ๋Œ๋ ค์ค€๋‹ค. `lastActive/latestSeen` ์€ ์ฑ„๋„๋‹น ํ•˜๋‚˜๋ฟ์ธ ํœ˜๋ฐœ ์Šฌ๋กฏ์ด๋ผ "๋ˆ„๊ฐ€ ๋งˆ์ง€๋ง‰์— ๋งํ–ˆ๋‚˜"๋ฅผ ๋‹ตํ•˜๋Š”๋ฐ, ๋ฉ€ํ‹ฐ์„ธ์…˜์—์„œ DM ํ„ด๊ณผ ์ฑ„๋„ ํ„ด์ด ๋™์‹œ์— ๋Œ๋ฉด ๊ทธ ๋‹ต์ด ์ด ๋Œ€ํ™”๊ฐ€ ์•„๋‹ˆ๊ฒŒ ๋œ๋‹ค (#474). ํ„ด ์ฃผ์†Œ๋Š” "์ง€๊ธˆ ๋ˆ„๊ตฌ์—๊ฒŒ ๋‹ตํ•˜๋Š” ์ค‘์ธ๊ฐ€"๋ฅผ ๋‹ตํ•˜๊ณ  ํ„ด์ด ์‚ฌ๋Š” ๋™์•ˆ ๋ฐ”๋€Œ์ง€ ์•Š๋Š”๋‹ค. ํ”„๋กœ์„ธ์Šค ํ™˜๊ฒฝ๋ณ€์ˆ˜๊ฐ€ ์•„๋‹Œ **ํ”„๋กฌํ”„ํŠธ** ๋กœ ์‹ค์–ด ๋‚˜๋ฅด๋Š” ์ด์œ ๋Š” `codex-app` ์ด ํ’€๋ง๋œ ํ”„๋กœ์„ธ์Šค๋ฅผ ์žฌ์‚ฌ์šฉํ•˜๋ฉด์„œ env ๋Š” ์ƒ์„ฑ ์‹œ์ ์—๋งŒ ์„ค์ •ํ•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค โ€” ์žฌ์‚ฌ์šฉ๋œ ํ”„๋กœ์„ธ์Šค๋Š” ์ž๊ธฐ๋ฅผ ์ฒ˜์Œ ๋„์šด ํ„ด์˜ ์ฃผ์†Œ๋ฅผ ๊ณ„์† ๋‹ตํ•˜๊ฒŒ ๋œ๋‹ค. ํ„ด ์ฃผ์†Œ๋„ `validateTarget()` ์„ ๊ฑฐ์นœ๋‹ค. - `src/orchestrator/pipeline.ts`๋Š” Telegram/Discord origin์—๋งŒ 21 Elicitation remote-channel guard๋ฅผ ๋™์ ์œผ๋กœ ๋ถ™์ธ๋‹ค. A1 system prompt๋Š” ์ˆ˜์ •ํ•˜์ง€ ์•Š์œผ๋ฉฐ, accidental `elicitation` / `choice-buttons` fence ์ถœ๋ ฅ์€ remote ์‘๋‹ต ์ง์ „์— plain text numbered question fallback์œผ๋กœ normalizeํ•œ๋‹ค. ### Dashboard Telegram Hub (`src/manager/telegram-hub/` โ€” 3 files) Forum supergroup topic โ†’ managed instance port routing. Config in `DashboardRegistry.telegramHub`. Routes at `/api/dashboard/telegram-hub` (loopback-only). `hub-bot.ts` owns single-bot long-poll; hub commands `/setthread`, `/threads`, `/hubhelp`. Manager UI: `TelegramHub.tsx`. See `telegram.md` ยง Telegram Hub. --- ## src/discord/ โ€” Discord transport (7 files, 858L) `bot.ts`, `forwarder.ts`, `commands.ts`, `discord-file.ts`, `send-only-client.ts`, `channel-types.ts`, `register.ts`. ### bot.ts (432L) Discord transport main entry. guild/DM message ingestion, `allowBots`, `mentionOnly`, channel allowlist, attachment handling, `registerTransport('discord', ...)`, `registerSendTransport('discord', ...)`๋ฅผ ๋‹ด๋‹นํ•œ๋‹ค. ### commands.ts (119L) Guild-scoped slash command registration + execution. `getVisibleCommands('discord')`์™€ `makeCommandCtx('discord', ...)`๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. `/orchestrate` ์Šคํ‹ฐ์–ด ๊ฒฝ๋กœ๋Š” Discord ์ฑ„๋„๋กœ collect ๊ฒฐ๊ณผ๋ฅผ ๋‹ค์‹œ ์ „์†กํ•œ๋‹ค. ### forwarder.ts (85L) `agent_done` ๊ฒฐ๊ณผ๋ฅผ Discord ์ฑ„๋„๋กœ chunked forwarding ํ•œ๋‹ค. ### discord-file.ts (67L) Discord attachment/file send helper. ### send-only-client.ts (88L) REST-only client for sends that must not require a gateway session. ### channel-types.ts (50L) ยท register.ts (17L) Channel narrowing helpers and slash-command registration. --- ## src/slack/ โ€” Slack transport ### inbound context (`bot.ts`, `history.ts`, `conversation.ts`, `context.ts`, `thread-tracker.ts`, `ingress.ts`) top-level ์ฑ„๋„์€ ํ˜„์žฌ event ts ์ง์ „์˜ `conversations.history`๋ฅผ ์„ธ์…˜ ์†Œ์œ  ์„ธ๋Œ€๋‹น ํ•œ ๋ฒˆ ํ”„๋กฌํ”„ํŠธ preamble์— ์ฃผ์ž…ํ•œ๋‹ค. thread๋Š” `conversations.replies` cursor๋ฅผ ์ตœ๋Œ€ 10ํŽ˜์ด์ง€ ๋”ฐ๋ผ๊ฐ€๋ฉฐ parent + ์ตœ์‹  50 replies๋งŒ ๋ณด์กดํ•œ๋‹ค. ํ•ฉ์„ฑ top-level reply ์ฃผ์†Œ๋Š” ์ฑ„๋„ session identity๋ฅผ ๊ณต์œ ํ•˜๋˜ `midRunPolicy: followup`์œผ๋กœ ์ง„ํ–‰ ์ค‘์ธ ๋‹ค๋ฅธ ์‚ฌ์šฉ์ž์˜ turn์„ steer/killํ•˜์ง€ ์•Š๋Š”๋‹ค. ### trusted bot triggers (`events.ts`) `slack.trustedBotTriggers`๋Š” ๋‹ค๋ฅธ ๋ด‡ ํ•˜๋‚˜๊ฐ€ ์ด ์ธ์Šคํ„ด์Šค์˜ ํ„ด์„ ์‹œ์ž‘ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋Š” ์šด์˜์ž ์„ ์–ธ ๋ชฉ๋ก์ด๋‹ค. ๊ทœ์น™์€ `{channelId, botId, userId, textMarker}` ๋„ค ํ•„์ˆ˜ ํ‚ค์™€ ์„ ํƒ์  `workflowSkill`๋งŒ ํ—ˆ์šฉํ•œ๋‹ค. ๋„ค ํ•„์ˆ˜ ๊ฐ’์€ ๊ฐ๊ฐ `^[CG][A-Z0-9]{2,}$`, `^B[A-Z0-9]{2,}$`, `^[UW][A-Z0-9]{2,}$`, `^[A-Z][A-Z0-9_]{2,63}$`๋ฅผ ๋งŒ์กฑํ•ด์•ผ ํ•œ๋‹ค. ๋ชฉ๋ก์€ ์ตœ๋Œ€ 16๊ฐœ์ด๊ณ  **ํ•˜๋‚˜๋ผ๋„ ์–ด๊ธ‹๋‚˜๋ฉด ์ „์ฒด๊ฐ€ ๋ฌดํšจ**๋‹ค โ€” ์ธ๋ฐ”์šด๋“œ ๊ถŒํ•œ ์„ค์ •์˜ ์˜คํƒ€๋Š” ์ ˆ๋ฐ˜๋งŒ ์‚ด์•„ ์žˆ๋Š” ์ƒํƒœ๋ณด๋‹ค ๋‹ซํžˆ๋Š” ์ชฝ์ด ๋‚ซ๋‹ค. ๋งค์นญ์€ ์ด๋ฒคํŠธ๊ฐ€ ์ž๊ธฐ ์ž์‹ ์„ ๋ฉ˜์…˜ํ•˜๊ณ , `bot_id`/`bot_profile.id`์™€ `user`/`bot_profile.user_id`๊ฐ€ ์„œ๋กœ ๋ชจ์ˆœ๋˜์ง€ ์•Š์œผ๋ฉฐ, ์‚ญ์ œ๋œ ํ”„๋กœํ•„์ด ์•„๋‹ˆ๊ณ , ์–ด๋–ค ๊ทœ์น™์ด ์ฑ„๋„ยท๋ด‡ยท๋ฐœ์‹ ์žยท๋งˆ์ปค ๋‹จ์–ด์™€ ์ •ํ™•ํžˆ ๋งž์„ ๋•Œ๋งŒ ์„ฑ๋ฆฝํ•œ๋‹ค. ๋งˆ์ปค๋Š” ๊ณต๋ฐฑ ๋‹จ์œ„ ๋‹จ์–ด ๋น„๊ต๋ผ `EXAMPLE_WORK_V1`์€ ๋” ๊ธด ๋‹จ์–ด์˜ ์ผ๋ถ€๋กœ ๋งค์นญ๋˜์ง€ ์•Š๋Š”๋‹ค. ์ผ์น˜๋Š” ์ •ํ™•ํžˆ ์„ธ ๊ฑฐ๋ถ€๋งŒ ์—ฐ๋‹ค: `bot_message` subtype ๋ฌด์‹œ, `allowBots:false` ๊ฑฐ๋ถ€, ๊ทธ๋ฆฌ๊ณ  `mention_via_app_mention` ์ค‘๋ณต ์ œ๊ฑฐ. self-echo, ์ฑ„๋„ ๋ˆ„๋ฝ, ๋Œ€ํ™” ํ—ˆ์šฉ๋ชฉ๋ก, `mentionOnly`, empty-event ๊ฒ€์‚ฌ๋Š” ๊ทธ๋Œ€๋กœ๋‹ค. ์ค‘๋ณต ์ œ๊ฑฐ๋ฅผ ์—ด์–ด๋„ ์‹คํ–‰์€ ํ•œ ๋ฒˆ์ธ๋ฐ, `bot.ts`๊ฐ€ dispatch ์ „์— `slackEventKey(teamId, channel, ts)`๋ฅผ ์„ ์ ํ•˜๋ฏ€๋กœ ๊ฐ™์€ ๊ธ€์˜ `app_mention`/`message` ๋‘ ๋ด‰ํˆฌ๊ฐ€ ํ•˜๋‚˜๋กœ ์ ‘ํžŒ๋‹ค. `isSlackMention()` ์ž์ฒด๋Š” ๋„“ํžˆ์ง€ ์•Š๋Š”๋‹ค โ€” ๊ทธ ํ•จ์ˆ˜๋Š” thread ์ฐธ์—ฌ ์†Œ์œ ๊ถŒ๋„ ์ •ํ•˜๊ธฐ ๋•Œ๋ฌธ์—, ๋„“ํžˆ๋ฉด #400์ด ๊ณ ์นœ ๊ณผ์ž‰ ์‘๋‹ต์ด ๋˜๋Œ์•„์˜จ๋‹ค. ์„ ํƒ์  `workflowSkill`์€ ์‹ค์ œ ์ด๋ฒคํŠธ์˜ ๋ฐœ์‹ ์žยท์ฑ„๋„ยท๋ด‡ ์‚ฌ์šฉ์žยท๋งˆ์ปค์™€ ์ž๊ธฐ ๋ฉ˜์…˜์ด ๋ชจ๋‘ ๋งž์€ ๋’ค ์šด์˜์ž๊ฐ€ ์„ค์ •ํ•œ ์‹คํ–‰ ๊ฒฝ๋กœ๋ฅผ ์„ ํƒํ•œ๋‹ค. ๋ฉ”์‹œ์ง€ ๋ณธ๋ฌธ์œผ๋กœ ๋‹ค๋ฅธ ์Šคํ‚ฌ์„ ๊ณ ๋ฅผ ์ˆ˜ ์—†๋‹ค. ๋„ค ํ‚ค๋งŒ ์žˆ๋Š” ๊ธฐ์กด ๊ทœ์น™์€ ๊ธฐ์กด ๋™์ž‘์„ ์œ ์ง€ํ•œ๋‹ค. ์„ ํƒ๋œ ํ™œ์„ฑ ์Šคํ‚ฌ๋งŒ ์ตœ๋Œ€ 64 KiB๋กœ ์ฝ์œผ๋ฉฐ, ๋ฐœ์‹ ยท์š”์ฒญ ์ •๋ณด๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์—†๊ฑฐ๋‚˜(`source_unavailable`), ์Šคํ‚ฌ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๊ฑฐ๋‚˜(`skill_unavailable`), ์„ ํƒ์ด ๋ชจํ˜ธํ•˜๋ฉด(`ambiguous`) `slack.workflow.unavailable`๋กœ ์ฐจ๋‹จ์„ ์•Œ๋ฆฌ๊ณ  ๋ชจ๋ธ๋กœ ๋Œ€์ฒดํ•˜์ง€ ์•Š๋Š”๋‹ค. ์ผ๋ฐ˜ ์Šน์ธยท๋„๊ตฌ ๊ถŒํ•œยท์›๋ณธ ์ ‘๊ทผ ๊ถŒํ•œ์€ ๊ทธ๋Œ€๋กœ๋‹ค. ์„ ํƒ๋œ ์Šคํ‚ฌ์€ ์š”์ฒญ ์ˆ˜๋ฝ(admission) ์‹œ์ ์— ์ฝ๊ณ , ์บก์ฒ˜ํ•œ ๋‚ด์šฉยทํ•ด์‹œยท์ถœ์ฒ˜ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ๋ฅผ ํ ๋Œ€๊ธฐ์™€ ์žฌ์‹œ์ž‘ ์ดํ›„์—๋„ ๋ณด์กดํ•œ๋‹ค. ์ด ๊ธฐ๋Šฅ์„ ์„ ํƒํ•œ ์›Œํฌํ”Œ๋กœ ์š”์ฒญ์€ busy ์ƒํƒœ์—์„œ `followup` ํ๋กœ ๋ณด๋‚ด๋ฉฐ, ๊ด€๋ จ ์—†๋Š” ์‹คํ–‰ ์ค‘ ํ„ด์— steerํ•˜๊ฑฐ๋‚˜ collect๋กœ ํ•ฉ์น˜์ง€ ์•Š๋Š”๋‹ค. ๋“ฑ๋ก ์›Œํฌํ”Œ๋กœ์˜ ๊ฒฐ๊ณผ๊ฐ€ ๋น„์—ˆ๊ฑฐ๋‚˜ ๋‹จ๋… `SILENT`์ด๋ฉด `slack.workflow.unconfirmed` ์•ˆ๋‚ด์™€ ์‹คํŒจ ACK๋กœ ๋๋‚ธ๋‹ค. ์›Œํฌํ”Œ๋กœ ์š”์ฒญ์€ unconfirmed/failed๋กœ ํŒ์ •ํ•˜๋˜ provider/native์˜ ์ตœ์ข… ํ…์ŠคํŠธ์™€ ์ƒํƒœ๋Š” ๋ณด์กดํ•œ๋‹ค. ์ด๋ฏธ ์ž‘์—…์ด ์‹œ์ž‘๋˜์—ˆ์„ ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ ์ž๋™ ์žฌ์‹คํ–‰ํ•˜์ง€ ์•Š๊ณ  ๊ธฐ๋ก์„ ํ™•์ธํ•œ ๋’ค ์žฌ์‹œ๋„ํ•œ๋‹ค. AI ๋‹ต๋ณ€ ์ˆ˜์‹ ๋งŒ์œผ๋กœ ์—…๋ฌด ์™„๋ฃŒ๋ฅผ ํŒ์ •ํ•˜์ง€ ์•Š๋Š”๋‹ค. ### app block actions (`events.ts`, `bot.ts`) `interactive` ๋ด‰ํˆฌ ์ค‘ `action_id`๊ฐ€ `agent:`๋กœ ์‹œ์ž‘ํ•˜๋Š” `block_actions` ํ•˜๋‚˜๋Š” `slackBlockActionEvent()`๊ฐ€ `type: 'block_actions'` ๋ฉ”์‹œ์ง€ ์ด๋ฒคํŠธ๋กœ ๋ฐ”๊พผ๋‹ค. ts๋Š” ํด๋ฆญ์˜ `action_ts`, thread๋Š” ํด๋ฆญ๋œ ๋ฉ”์‹œ์ง€(๋˜๋Š” ๊ทธ ๋ถ€๋ชจ)๋ผ์„œ preflight journal, `slackEventKey` ์ค‘๋ณต ์ œ๊ฑฐ, ๊ฒŒ์ดํŠธ, ํ„ด ์ˆ˜๋ฝ์ด ๋ฉ”์‹œ์ง€์™€ ๊ฐ™์€ ๊ฒฝ๋กœ๋ฅผ ํƒ„๋‹ค. ๋‹ต๋ณ€์€ ํด๋ฆญ๋œ ๋ฉ”์‹œ์ง€์˜ ์Šค๋ ˆ๋“œ๋กœ ๋ณด๋‚ด๋ฉฐ `replyInThread`๊ฐ€ ๊บผ์ ธ ์žˆ์œผ๋ฉด ์ฑ„๋„์— ๋ณด๋‚ธ๋‹ค. ํŒ€ ๋ถˆ์ผ์น˜, ephemeral, ๋ฉ”์‹œ์ง€ ๋ฐ– ์ปจํ…Œ์ด๋„ˆ, ๋‘ ๊ฐœ ์ด์ƒ์˜ ์•ก์…˜์€ ๊ฑฐ๋ถ€ํ•œ๋‹ค. ํ† ํฐ์œผ๋กœ ํ™•์ธํ•œ workspace๋Š” ํด๋ฆญ์˜ ํŒ€๊ณผ, ํ™•์ธํ•œ user๋Š” ์บก์ฒ˜ํ•œ ๋ด‡ user์™€ ๊ฐ™์•„์•ผ ํ•œ๋‹ค. ํด๋ฆญ ํ„ด์—๋Š” ํ™•์ธ๋œ ํด๋ฆญ์ž๋ฅผ ๋‹ด์€ Slack tool grant๋„ ํ•„์š”ํ•˜๋ฉฐ dispatch ์‹œ grant๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์—†์œผ๋ฉด ํ„ด์„ ์‹œ์ž‘ํ•˜์ง€ ์•Š๋Š”๋‹ค. ํด๋ฆญ๋œ ๋ฉ”์‹œ์ง€์˜ `bot_id`๋Š” `auth.test`๋กœ ํ™•์ธํ•œ ์šฐ๋ฆฌ ๋ด‡๊ณผ ๊ฐ™์•„์•ผ ํ•˜๋ฉฐ, ์กด์žฌํ•˜๋Š” `app_id`๋Š” `bots.info`๋กœ ๋ณ„๋„ ํ™•์ธํ•œ ์•ฑ๊ณผ ๊ฐ™์•„์•ผ ํ•œ๋‹ค. `bots.info` ์‹คํŒจ ์‹œ ์•ฑ ID๊ฐ€ ํ‘œ์‹œ๋œ ํด๋ฆญ์€ transport ์žฌ์‹œ์ž‘๊นŒ์ง€ ๊ฑฐ๋ถ€ํ•œ๋‹ค. ํด๋ฆญ์ž๋Š” journal๊ณผ ACK ์ „์— `users.info`(`users:read`)๋กœ ํ™•์ธํ•˜๊ณ  ์ผ๋ฐ˜ ์ž‘์„ฑ์ž ์ •์ฑ…์„ ์ ์šฉํ•œ๋‹ค. ์ž์‹ ์˜ ๋ด‡์€ ๊ฑฐ๋ถ€ํ•˜๋ฉฐ SlackbotยทworkflowยทAgentforceยทsidekick ๋ด‡์—๋Š” `allowBots`๊ฐ€ ํ•„์š”ํ•˜๋‹ค. `is_app_user`๋งŒ์œผ๋กœ๋Š” ๋ด‡์ด ์•„๋‹ˆ๊ณ  trusted bot trigger๋Š” ํด๋ฆญ์— ์ ์šฉํ•˜์ง€ ์•Š๋Š”๋‹ค. ์ˆ˜๋ฝ ์ „ ํ™•์ธ ์‹คํŒจ๋‚˜ ์ •์ฑ… ๊ฑฐ๋ถ€๋Š” ACK ํ›„ ์ €๋„๊ณผ dispatch ์—†์ด ๋ฒ„๋ฆฌ๋ฏ€๋กœ ์›์ธ์„ ๊ณ ์นœ ๋’ค ๋‹ค์‹œ ํด๋ฆญํ•œ๋‹ค. `appr:`/`aprd:`์™€ `jaw_choice_`๋Š” ๊ธฐ์กด ๊ฒฝ๋กœ๋ฅผ ์œ ์ง€ํ•œ๋‹ค. ๊ฒŒ์ดํŠธ๋Š” ํด๋ฆญ์„ ์ด๋ฏธ ์ง€๋ชฉ๋œ ๊ฒƒ์œผ๋กœ ๋ณด์•„ `mentionOnly`๋งŒ ๊ฑด๋„ˆ๋›ฐ๊ณ  ํ—ˆ์šฉ๋ชฉ๋ก์€ ์œ ์ง€ํ•œ๋‹ค. `payload.token`, `response_url`, `trigger_id`๋Š” ์ฝ์ง€ ์•Š๋Š”๋‹ค. ์„ค์ •๋œ ํŒ€์€ ํ™•์ธ ๋Œ€๊ธฐ ํ›„์™€ grant ์ค€๋น„ ์‹œ ๋‹ค์‹œ ๊ฒ€์‚ฌํ•œ๋‹ค. ํด๋ฆญ์€ ์ง„ํ–‰ ์ค‘์ธ ํ„ด์„ steerํ•˜์ง€ ์•Š๊ณ  ๋ณ„๋„ ํ„ด์œผ๋กœ ํ์— ๋“ค์–ด๊ฐ„๋‹ค. ํ”„๋กฌํ”„ํŠธ์˜ `action_ts`๊ฐ€ ๊ฐ ํด๋ฆญ์„ ๊ตฌ๋ณ„ํ•˜๋ฏ€๋กœ ๋”๋ธ” ํด๋ฆญ์€ ๋‘ ๋ฒˆ ์‹คํ–‰๋˜๋ฉฐ, ํ•œ ํด๋ฆญ์˜ ์žฌ์ „๋‹ฌ์€ ์ค‘๋ณต ์ œ๊ฑฐํ•œ๋‹ค. grant ์ค€๋น„ ์‹œ ํ† ํฐ, ๋ด‡ ์‹๋ณ„์ž, ๋Ÿฐํƒ€์ž„ ์„ธ๋Œ€์™€ ํŒ€์ด ํด๋ฆญ ๊ฒ€์ฆ ์‹œ์ ๊ณผ ๊ฐ™์•„์•ผ ํ•œ๋‹ค. ๊ฐ™์€ ํด๋ฆญ์˜ ์žฌ์ „๋‹ฌ์€ ์ตœ๋Œ€ 10์ดˆ ๋™์•ˆ ๊ฒ€์ฆ ์กฐํšŒ๋ฅผ ๊ณต์œ ํ•˜๋˜ ๊ฐ ์ „๋‹ฌ์€ ACK ์ „์— ํ˜„์žฌ ๊ฒŒ์ดํŠธ์™€ durable admission์„ ๋‹ค์‹œ ๊ฑฐ์นœ๋‹ค. ๊ธด ํ ๋Œ€๊ธฐ ๋˜๋Š” ์žฌ์‹œ์ž‘์œผ๋กœ ํด๋ฆญ ํ„ด์ด grant ๋งŒ๋ฃŒ ํ›„ ์‹œ์ž‘๋˜๋ฉด Slack ๋„๊ตฌ ๊ถŒํ•œ ์—†์ด ์‹คํ–‰๋˜๋ฏ€๋กœ ์นด๋“œ๋ฅผ ์ˆ˜์ •ํ•  ์ˆ˜ ์—†๋‹ค. ํด๋ฆญ ํ„ด์€ `preSendContext.jobKind = 'slack_block_action'`์„ ํ์™€ ์žฌ์‹œ์ž‘ ๋„ˆ๋จธ๊นŒ์ง€ ์‹ฃ๊ณ , ์ง„ํ–‰ ์นด๋“œ์™€ ๊ทธ queue notice ๊ธฐ๋ก์„ ๋งŒ๋“ค์ง€ ์•Š๋Š”๋‹ค(directยทqueued ๋ชจ๋‘, ๊ทธ๋ž˜์„œ ์žฌ์‹œ์ž‘ ๋’ค ๋ณต์›ํ•  ์นด๋“œ๋„ ์—†๋‹ค). ๋‹ต ์ „์ฒด๊ฐ€ `[SILENT]`์ด๋ฉด directยทqueuedยทorphan ์„ธ ๊ฒฝ๋กœ ๋ชจ๋‘ `tg.noResponse` ๋Œ€์‹  ์•„๋ฌด๊ฒƒ๋„ ๊ฒŒ์‹œํ•˜์ง€ ์•Š์•„ ๋‹ต๋ณ€ ์œ„์น˜์— ํ”์ ์ด ๋‚จ์ง€ ์•Š๋Š”๋‹ค. ### mention-watch.ts (345L) `scanSlackMentions()`๋Š” ๋ด‡์ด ๊ฐ€์ž…ํ•œ ๋ช…์‹œ์  ์ฑ„๋„์—์„œ ํŠน์ • ์‚ฌ์šฉ์ž๊ฐ€ ํƒœ๊ทธ๋œ ์ƒˆ ๋ฉ”์‹œ์ง€๋ฅผ ์ฐพ๋Š”๋‹ค. ๋ด‡ ํ† ํฐ์œผ๋กœ ์“ธ ์ˆ˜ ์—†๋Š” user-token ์ „์šฉ `search.messages` ๋Œ€์‹  `conversations.history`๋ฅผ newest์—์„œ ๊ณผ๊ฑฐ ๋ฐฉํ–ฅ์œผ๋กœ ์ฝ๋Š”๋‹ค. ์ปค์„œ๋Š” ์ฒ˜๋ฆฌ๊ฐ€ ๋๋‚œ ๋ฉ”์‹œ์ง€๊นŒ์ง€๋งŒ ์ „์ง„ํ•˜๊ณ , ๋๋‚ด์ง€ ๋ชปํ•œ backward walk๋Š” `resume_before`์—์„œ ์ด์–ด๊ฐ„๋‹ค. ์ฑ„๋„ ์‹œ์ž‘์ ์„ tick๋งˆ๋‹ค ํšŒ์ „ํ•ด hot channel์˜ ๋…์ ์„ ๋ง‰๊ณ , 429๊ฐ€ ์˜ค๋ฉด wrapper ์žฌ์‹œ๋„ ์—†์ด ๊ทธ tick์„ ๋ฉˆ์ถ˜๋‹ค. ํ•œ tick์˜ ์ฑ„๋„ ์ƒํ•œ์€ 60์ด๋ฉฐ ์ดˆ๊ณผ๋ถ„์€ `overflowChannels`๋กœ ๋ฐ˜ํ™˜ํ•œ๋‹ค. --- ## src/memory/ โ€” persistent + advanced memory runtime (14 files, 3391L) `memory.ts`, `runtime.ts`, `shared.ts`, `heartbeat.ts`, `heartbeat-schedule.ts`, `heartbeat-mention-watch.ts`, `indexing.ts`, `keyword-expand.ts`, `bootstrap.ts`, `injection.ts`, `identity.ts`, `reflect.ts`, `advanced.ts`, `worklog.ts`. ### memory.ts (154L) | Function | ์—ญํ•  | | --- | --- | | `search(query)` | grep-rni ๊ธฐ๋ฐ˜ ๊ฒ€์ƒ‰ | | `read(filename)` | ํŒŒ์ผ ์ฝ๊ธฐ | | `save(filename, content)` | append ์ €์žฅ | | `list()` | ํŒŒ์ผ ๋ชฉ๋ก | | `appendDaily(content)` | ์ผ๋ณ„ ๋ฉ”๋ชจ๋ฆฌ ์ถ”๊ฐ€ | | `loadMemoryForPrompt(maxChars)` | system prompt ์ฃผ์ž…์šฉ | ### runtime.ts (374L) Advanced memory runtime์˜ entry point. FTS5 ์ธ๋ฑ์Šค, search routing, task snapshot, bootstrap, reindex ์ œ์–ด๋ฅผ ๋ฌถ๋Š”๋‹ค. ### injection.ts / identity.ts / reflect.ts - `injection.ts`: ์—ญํ• ๋ณ„(`boss`/`employee`/`subagent`/`flush`/`read_only_tool`) memory injection ์ •์ฑ…๊ณผ search routing - `identity.ts`: `shared/soul.md` ๊ด€๋ฆฌ, soul read/update ๊ฒฝ๋กœ - `reflect.ts`: ์ตœ๊ทผ episode๋ฅผ `shared/*`, `procedures/runbooks.md`, `shared/soul.md`๋กœ ์Šน๊ฒฉ ### heartbeat.ts / heartbeat-schedule.ts ์ฃผ๊ธฐ ์ž‘์—…๊ณผ ์Šค์ผ€์ค„ ํŒŒ์‹ฑ/์‹คํ–‰์„ ๋‹ด๋‹นํ•œ๋‹ค. ํ˜„์žฌ ์†Œ์Šค ์˜ค๋ธŒ ํŠธ๋ฃจ์Šค๋Š” `~/.cli-jaw/heartbeat.json`์ด๋ฉฐ, schedule์€ `every`/`cron` + `timeZone`์„ ์ง€์›ํ•œ๋‹ค. PABCD ํ™œ์„ฑ, heartbeat ์ค‘์ฒฉ, main agent busy ์ƒํƒœ์—์„œ๋Š” `pendingJobs` ํ๋กœ ๋ฐ€์–ด๋‘๊ณ , user message queue๊ฐ€ ๋จผ์ € ๋น„์›Œ์ง„ ๋’ค heartbeat pending์„ drainํ•œ๋‹ค. ํ”„๋กฌํ”„ํŠธ ์•ž์—๋Š” memory search ์ง€์‹œ๋ฅผ ์ž๋™ ์ฃผ์ž…ํ•œ๋‹ค. (#252) job๋ณ„ opt-in `runner: main|employee|script`(๊ธฐ๋ณธ main; employee๋Š” `claimWorker`+`runSingleAgent`, busy ์‹œ `skipped: employee busy` ๊ฒฝ๊ณ  ๋ฆฌํฌํŠธ; script๋Š” argv `execFile` no-shell)์™€ `reportPolicy: always|anomaly_only|silent` + ๊ตฌ์กฐํ™” ๋ฆฌํฌํŠธ ๊ณ„์•ฝ(`heartbeat-report.ts`: status/changed/record_required/user_visible/summary/evidence/next_action)์„ ์ง€์›ํ•œ๋‹ค. `[SILENT]`/quiet marker๋Š” ์ •์ฑ…๊ณผ ๋ฌด๊ด€ํ•˜๊ฒŒ ์šฐ์„ ํ•˜๋ฉฐ, silent ์ •์ฑ… anchor๋Š” `delivered_at NULL` + "recorded (not sent)" ์ฃผ์ž… ๋ฌธ๊ตฌ๋กœ ๊ตฌ๋ถ„๋œ๋‹ค. main runner๋Š” `orchestrateAndCollectData`์˜ `agyPlannerOnly` ์‹ ํ˜ธ(#251)์— 1ํšŒ ํ•œ์ • ์žฌ์‹œ๋„ํ•œ๋‹ค. ๋ฐ”์ธ๋”ฉ๋œ ์ผ๋ฐ˜ destination send๋Š” `fullAccess: true`์™€ `allowActiveFallback: false`๋ฅผ ์“ฐ๋ฉฐ HTTP JSON์€ ๊ทธ flag๋ฅผ ์„ค์ •ํ•˜์ง€ ๋ชปํ•œ๋‹ค. `mentionWatch`๊ฐ€ ์žˆ์œผ๋ฉด ๊ฐ™์€ `runHeartbeatJob`์ด ์ผ๋ฐ˜ prompt path ๋Œ€์‹  ๋ฉ˜์…˜ ํ•ญ๋ชฉ ๋ฃจํ”„๋ฅผ ์‹คํ–‰ํ•œ๋‹ค. ์„ ํƒ `userIds`/`conditions`(mention|talk)๋Š” ๊ธฐ๋ณธ์„ `userId` ๋ฉ˜์…˜์œผ๋กœ ๋‘๊ณ  talk๋Š” opt-in์ด๋ฉฐ inbound `mentionOnly`๋ฅผ ๋ฐ”๊พธ์ง€ ์•Š๋Š”๋‹ค. ๋‹ต๋ณ€ ํ„ด์€ ๋‹ตํ•˜๋Š” ์Šค๋ ˆ๋“œ์˜ `chatSessionId`๋ฅผ ์“ฐ๋˜ ์‹คํ–‰ ์Šค์ฝ”ํ”„๋Š” ์ „์šฉ `mention-watch:`๋‹ค โ€” ์Šค๋ ˆ๋“œ ์Šค์ฝ”ํ”„๋ฅผ ๊ทธ๋Œ€๋กœ ์“ฐ๋ฉด ๊ทธ ํ„ด์ด busy๋กœ ๋ณด์—ฌ์„œ ๋‹ค์Œ ์‚ฌ๋žŒ ๋ฉ”์‹œ์ง€๊ฐ€ ์ƒˆ run ๋Œ€์‹  ์ด ๋ฐฐ๊ฒฝ ํ„ด์œผ๋กœ steer๋œ๋‹ค. ๊ทธ๋ž˜์„œ ์–‘๋ณด ํŒ์ •๋„ ๋Œ€ํ™” ๋‹จ์œ„๋‹ค: `getState(remoteKey)`๊ฐ€ IDLE์ด๊ณ , ๊ทธ ์„ธ์…˜์— ์ง„ํ–‰ ์ค‘ ์ž‘์—…์ด ์—†๊ณ , lane์ด ๋น„์–ด ์žˆ์–ด์•ผ ๋‹ตํ•œ๋‹ค. lane์€ ๊ฒ€์‚ฌ๋งŒ ํ•˜๊ณ  ๊ธฐ๋‹ค๋ฆฌ์ง€ ์•Š๋Š”๋‹ค โ€” lane ๋Œ€๊ธฐ๋Š” ์ƒํ•œ์ด ์—†๊ณ  ๊ทธ ์‚ฌ์ด heartbeat ์ „์ฒด๊ฐ€ ์ž ๊ธด๋‹ค. ์„ธ์…˜ row๋Š” ์‹ค์ œ๋กœ ๋‹ตํ•˜๊ธฐ๋กœ ์ •ํ•œ ๋’ค์—๋งŒ ๋งŒ๋“ ๋‹ค: remote-bound ์„ธ์…˜์€ ๋‚˜์ค‘์— ์ง€์šธ ์ˆ˜ ์—†๋‹ค. PUT `/api/heartbeat`๋Š” UI๊ฐ€ ๋ชจ๋ฅด๋Š” runner์™€ mentionWatch ํ•„๋“œ๋ฅผ job id ๊ธฐ์ค€ merge-by-id๋กœ ๋ณด์กดํ•œ๋‹ค. ### heartbeat-mention-watch.ts (244L) `runMentionWatchTick()`์€ ์„ค์ • ์ฑ„๋„๊ณผ tick ์‹œ์ ์˜ Slack allowlist๋ฅผ ๋‹ค์‹œ ๊ต์ง‘ํ•ฉํ•˜๊ณ  ํ•ญ๋ชฉ๋งˆ๋‹ค PABCD, agent busy, `messageQueue`, pending replay๋ฅผ ์žฌํ™•์ธํ•œ๋‹ค. ์—์ด์ „ํŠธ๋Š” ๋‹ต๋ณ€ ๋ณธ๋ฌธ๋งŒ ๋งŒ๋“ค๊ณ  ์„œ๋ฒ„๊ฐ€ `sendChannelOutput()`์œผ๋กœ ์›๋ฌธ ์Šค๋ ˆ๋“œ์— ๋ณด๋‚ธ๋‹ค. ์ „์†ก ์„ฑ๊ณต ๋’ค์—๋งŒ `mention_watch_seen`์„ ๊ธฐ๋กํ•˜๋ฏ€๋กœ ์‹คํŒจ ํ•ญ๋ชฉ์€ ๋‹ค์Œ tick์—์„œ ๋‹ค์‹œ ์‹œ๋„ํ•˜๋ฉฐ ๋ณด์žฅ ์ˆ˜์ค€์€ at-least-once๋‹ค. `mention_watch_cursor`์˜ `resume_before`๊ฐ€ ๋๋‚˜์ง€ ์•Š์€ history walk๋ฅผ ์ž‡๊ณ , `mention_watch_rotation`์ด ๋‹ค์Œ ์‹œ์ž‘ ์ฑ„๋„์„ ์ •ํ•œ๋‹ค. seen prune์€ ๊ฑด์ˆ˜๊ฐ€ ์•„๋‹ˆ๋ผ ์ „์ง„ํ•œ cursor๋ฅผ ๊ธฐ์ค€์œผ๋กœ ํ•œ๋‹ค. ### mention-watch-ledger.ts (104L) / legacy-mention-watch-quarantine.ts (115L) receipt/cursor/rotation ์žฅ๋ถ€์˜ ์œ ์ผํ•œ ์ ‘๊ทผ ๊ฒฝ๋กœ๋‹ค. ๋ชจ๋“  ์ฝ๊ธฐยท์“ฐ๊ธฐ๊ฐ€ `WatchNamespace = (jobId, workspaceId, userId)`๋ฅผ ๋ฐ›๊ณ  SQL predicate์— ์„ธ ํŒŒํŠธ๋ฅผ ์ „๋ถ€ ์‹ฃ๋Š”๋‹ค. Slack์€ ์‚ฌ๋žŒ์„ `(team_id, id)`๋กœ ์‹๋ณ„ํ•˜๊ณ  ํ•œ ๋Ÿฐํƒ€์ž„์ด ์žฌ์‹œ์ž‘ ์—†์ด ๋‹ค๋ฅธ workspace๋กœ ์žฌ์ธ์ฆํ•  ์ˆ˜ ์žˆ์–ด์„œ, job๋งŒ์œผ๋กœ ํ‚ค๋ฅผ ์žก์œผ๋ฉด ํ•œ ์‚ฌ๋žŒ์˜ cursor๊ฐ€ ๋‹ค๋ฅธ ์‚ฌ๋žŒ์—๊ฒŒ ๋„˜์–ด๊ฐ„๋‹ค. workspace id๋Š” `src/slack/verified-workspace.ts`๊ฐ€ bot token์œผ๋กœ `auth.test`๋ฅผ 1ํšŒ ํ˜ธ์ถœํ•ด ํ† ํฐ๋ณ„๋กœ ์บ์‹œํ•œ ๊ฐ’์ด๋ฉฐ `settings.slack.teamId`๋ฅผ ์‹ ๋ขฐํ•˜์ง€ ์•Š๋Š”๋‹ค(๊ทธ ๊ฐ’์€ ๋น„์–ด ์žˆ์„ ๋•Œ๋งŒ ๊ธฐ๋ก๋˜๊ณ  ์ดํ›„ ํ† ํฐ๊ณผ ๋Œ€์กฐ๋˜์ง€ ์•Š๋Š”๋‹ค). ์กฐํšŒ ์‹คํŒจ๋Š” ์ถ”์ธก ๋Œ€์‹  ๊ทธ tick์„ ๊ฑด๋„ˆ๋›ด๋‹ค. ๋ชจ๋“ˆ ๊ฒฝ์œ ๊ฐ€ predicate ๋ˆ„๋ฝ์„ ๊ตฌ์กฐ์ ์œผ๋กœ ๋ง‰์•„ ์ฃผ์ง€๋Š” ์•Š์œผ๋ฏ€๋กœ ์ตœ์ข… ๋ณด์ฆ์€ `tests/unit/mention-watch-ledger.test.ts`์˜ A/B ๋Œ€์นญ ํ…Œ์ŠคํŠธ๋‹ค โ€” ๊ฐ™์€ job/channel/ts ์œ„์— workspace๋‚˜ user๋งŒ ๋‹ค๋ฅธ ๋‘ namespace๋ฅผ ๋งŒ๋“ค์–ด ์„œ๋กœ๋ฅผ ๋ณด๊ฑฐ๋‚˜ ๊ฑด๋“œ๋ฆด ์ˆ˜ ์—†์Œ์„ ํ™•์ธํ•œ๋‹ค. v1 ์žฅ๋ถ€ ํ–‰์—๋Š” workspace/user๊ฐ€ ์—†์–ด์„œ v2 ํ‚ค๋กœ ์˜ฎ๊ธฐ๋ ค๋ฉด ์†Œ์œ ์ž๋ฅผ ์ถ”์ธกํ•ด์•ผ ํ•˜๊ณ , ๊ทธ ์ถ”์ธก์ด ๊ณง v2๊ฐ€ ๋ง‰์œผ๋ ค๋Š” ์˜ค๋ฐฐ์ •์ด๋‹ค. ๊ทธ๋ ‡๋‹ค๊ณ  ๊ทธ๋ƒฅ ์ƒˆ๋กœ ์‹œ์ž‘ํ•˜๋ฉด cursor ์—†๋Š” watch๊ฐ€ ๋„๋‹ฌ ๊ฐ€๋Šฅํ•œ history๋ฅผ ๊ฑฐ๊พธ๋กœ ํ›‘์–ด ์ด๋ฏธ ๋‹ตํ•œ ๊ฒƒ์„ ๋‹ค์‹œ ๋‹ตํ•œ๋‹ค. ๊ทธ๋ž˜์„œ v1 ํ–‰์ด ๋‚จ์€ job์€ `heartbeat.json`์˜ `enabled`์™€ ๋ฌด๊ด€ํ•˜๊ฒŒ ์Šค์ผ€์ค„์—์„œ ๋ณด๋ฅ˜๋œ๋‹ค. ๋ณด๋ฅ˜ marker๋Š” SQLite์— ์žˆ๋‹ค โ€” ํŒŒ์ผ์€ ์šด์˜์ž์˜ ์˜๋„์ด๊ณ  ๋ณด๋ฅ˜๋Š” ์‹œ์Šคํ…œ์˜ ํŒ๋‹จ์ด๋ผ, ํ•œ ๊ณณ์— ์ ์œผ๋ฉด ์„œ๋กœ๋ฅผ ๋ฎ์–ด์“ฐ๊ณ  ํŒŒ์ผ ์žฌ์ž‘์„ฑ์„ ํƒ์ง€ ์‹œ์ ์˜ ํ…Œ์ด๋ธ” ์ƒ์„ฑ๊ณผ ์›์ž์ ์œผ๋กœ ๋ฌถ์„ ์ˆ˜๋„ ์—†๋‹ค. ํƒ์ง€๋Š” `INSERT OR IGNORE`๋กœ ๋งค load๋งˆ๋‹ค ๋Œ๋ฉฐ(์—…๊ทธ๋ ˆ์ด๋“œ ๋‹น์‹œ ์—†๋˜ job์ด ๊ฐ™์€ id๋กœ ๋Œ์•„์˜ค๋Š” ๊ฒฝ๋กœ๋ฅผ one-shot ๊ฒ€์‚ฌ๋Š” ๋†“์นœ๋‹ค), ๊ตฌ๋ฒ„์ „์œผ๋กœ downgradeํ•ด v1 ํ–‰์ด ๋‹ค์‹œ ์ƒ๊ธฐ๋ฉด `resolved`๋ฅผ `pending`์œผ๋กœ ์žฌ๊ฒฉ๋ฆฌํ•œ๋‹ค. ํ•ด์ œ๋Š” `POST /api/heartbeat/:jobId/mention-watch-fresh-start`๋ฟ์ด๊ณ  ์ƒˆ `since`๋ฅผ ์š”๊ตฌํ•˜๋ฉฐ, ํ•œ ํŠธ๋žœ์žญ์…˜์—์„œ CAS๋ฅผ ๋จผ์ € claimํ•œ ๋’ค v1 ํ–‰์„ archiveํ•˜๊ณ  ์‚ญ์ œํ•œ๋‹ค. ์ˆœ์„œ๊ฐ€ ์ค‘์š”ํ•œ ์ด์œ ๋Š” better-sqlite3 transaction์ด `return`์œผ๋กœ๋Š” rollback๋˜์ง€ ์•Š์•„์„œ๋‹ค โ€” ํŒŒ๊ดด์  ๋‹จ๊ณ„๋ฅผ ๋จผ์ € ๋‘๋ฉด ์‹คํŒจ๋ฅผ ๋ณด๊ณ ํ•œ ์Šน์ธ์˜ archive/delete๊ฐ€ ๊ทธ๋Œ€๋กœ commit๋œ๋‹ค. ### indexing.ts / keyword-expand.ts / bootstrap.ts index ์ค€๋น„, BM25/expansion, bootstrapping/import ํ๋ฆ„์„ ๋‹ด๋‹นํ•œ๋‹ค. ### worklog.ts / shared.ts ์ž‘์—… ์Šค๋ƒ…์ƒท, ๊ณตํ†ต ํƒ€์ž…/ํ—ฌํผ, history persistence์— ์“ฐ์ธ๋‹ค. ### advanced.ts ์ด๊ด€ ํ˜ธํ™˜์šฉ 1-line shim. --- ## src/browser/ โ€” Chrome CDP ์ œ์–ด Chrome CDP ์ œ์–ด, ์™„์ „ ๋…๋ฆฝ ๋ชจ๋“ˆ. | connection.ts (215L) | actions.ts (179L) | | --- | --- | | `findChrome()` | `snapshot(port, opts)` | | `launchChrome(port)` | `screenshot(port, opts)` +dpr | | `connectCdp(port)` | `click(port, ref, opts)` | | `getActivePage(port)` | `type(port, ref, text)` | | `getCdpSession(port)` | `press(port, key)` | | `listTabs(port)` | `hover(port, ref)` | | `getBrowserStatus(port)` | `navigate(port, url)` | | `closeBrowser()` | `evaluate(port, expr)` | | | `getPageText(port, fmt)` | | | `mouseClick(port, x, y)` | ### vision.ts (204L) โ€” Vision Click pipeline | Function | ์—ญํ•  | | --- | --- | | `extractCoordinates(path, target)` | provider ๋ถ„๊ธฐ ์ขŒํ‘œ ์ถ”์ถœ | | `codexVision(path, target)` | Codex exec -i + NDJSON parse | | `visionClick(port, target, opts)` | screenshot โ†’ vision โ†’ DPR ๋ณด์ • โ†’ click โ†’ verify | ### launch-policy.ts (51L) โ€” Browser launch policy module-level policy๋กœ `browser start` mode ์ •๊ทœํ™” + agent/debug/manual launch policy๋ฅผ ๊ด€๋ฆฌํ•œ๋‹ค. `index.ts` (13L) โ€” re-export hub (mouseClick + visionClick ํฌํ•จ) --- ## lib/mcp-sync.ts โ€” MCP ํ†ตํ•ฉ ๊ด€๋ฆฌ (1212L) ์†Œ์Šค: `~/.cli-jaw/mcp.json` | Function | ์—ญํ•  | | --- | --- | | `loadUnifiedMcp()` | ํ†ตํ•ฉ MCP ์„ค์ • ๋กœ๋“œ | | `toClaudeMcp(config)` | Claude/Gemini `.mcp.json` ๋ณ€ํ™˜ | | `toCodexToml(config)` | Codex `config.toml` ๋ณ€ํ™˜ | | `toOpenCodeMcp(config)` | OpenCode `opencode.json` ๋ณ€ํ™˜ | | `toCopilotMcp(config)` | Copilot `~/.copilot/mcp-config.json` ๋ณ€ํ™˜ | | `syncToAll(config, workDir)` | ํ†ตํ•ฉ โ†’ ์ง€์› MCP-aware CLI ์„ค์ • ๋™๊ธฐํ™” | | `copyDefaultSkills()` | 2ร—3 ๋ถ„๋ฅ˜ + Codex ํด๋ฐฑ + registry.json ๋™๊ธฐํ™” | | `propagateSkillsToInstances()` | base `skills_ref`๋ฅผ `~/.cli-jaw-*` instances๋กœ ๋™๊ธฐํ™”ํ•˜๊ณ , ๊ฐ instance์˜ synced `skills_ref` ๊ธฐ์ค€์œผ๋กœ default active skills๋ฅผ ํ™œ์„ฑํ™” (`baseActive` fallback ํฌํ•จ) | | `installMcpServers(config)` | npm -g / uv tool install | | `ensureSymlinkSafe(target, linkPath, opts)` | symlink ๋ณดํ˜ธ ๋ชจ๋“œ | | `safeMoveToBackup(pathToMove)` | ์ถฉ๋Œ ๋””๋ ‰ํ† ๋ฆฌ ๋ฐฑ์—… ์ด๋™ | | `ensureSkillsSymlinks(workingDir, opts)` | ์Šคํ‚ฌ ์‹ฌ๋งํฌ + ๋ณดํ˜ธ ๊ฒฐ๊ณผ ๋ฐ˜ํ™˜ | Antigravity MCP sync is an existing config target at `~/.gemini/antigravity/mcp_config.json` via `lib/mcp/format-converters.ts`. It remains separate from the AGY runtime registry key `agy`; adding AGY runtime support does not register `agy` as a wrapper provider. ์„œ๋ฒ„ ์‹œ์ž‘ ์‹œ `ensureComputerUseMcp()`๋Š” Codex์˜ `unified-computer-use` ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ์ฐพ์œผ๋ฉด `jaw-computer-use` ํ”„๋ก์‹œ ํ•ญ๋ชฉ์„ ํ†ตํ•ฉ MCP ์„ค์ •๊ณผ ์ด๋ฏธ ์กด์žฌํ•˜๋Š” JSON ๋Œ€์ƒ์— ๋“ฑ๋กํ•œ๋‹ค. ๊ฐ ํŒŒ์ผ์€ ์—„๊ฒฉํžˆ ์ฝ๊ณ , ์ฝ์„ ์ˆ˜ ์—†๋Š” ํŒŒ์ผ๊ณผ ๊ฐ™์€ ์ด๋ฆ„์˜ ์‚ฌ์šฉ์ž ํ•ญ๋ชฉ์€ ๋ณด์กดํ•œ๋‹ค. ํ…Œ์ŠคํŠธ์šฉ Jaw home ๋˜๋Š” `NODE_ENV=test`์—์„œ๋Š” ์ „์—ญ ๋Œ€์ƒ ์„ค์ •์„ ๊ฑด๋“œ๋ฆฌ์ง€ ์•Š๋Š”๋‹ค. Codex `config.toml`์€ ์ด ๋“ฑ๋ก ๋‹จ๊ณ„์—์„œ ์ˆ˜์ •ํ•˜์ง€ ์•Š๋Š”๋‹ค. ํ”„๋ก์‹œ์˜ Computer Use ์Šน์ธ์€ ์‹คํ–‰๋งˆ๋‹ค ์ „๋‹ฌํ•˜๋Š” `JAW_COMPUTER_USE_APPROVAL` ๊ฐ’์ด ์ •ํ™•ํžˆ `auto`์ผ ๋•Œ๋งŒ ์ž๋™ ์ˆ˜๋ฝํ•œ๋‹ค. ์ผ๋ฐ˜ `syncToAll()`์€ Copilot, Cursor, Antigravity์˜ ๊ธฐ์กด `mcpServers`๋ฅผ ๋ณ‘ํ•ฉํ•˜๋ฉฐ, Codex์—์„œ๋Š” ์ด๋ฒˆ ๋™๊ธฐํ™”๊ฐ€ ์‹ค์ œ๋กœ ์ถœ๋ ฅํ•œ ์„œ๋ฒ„ ์ด๋ฆ„์˜ ์„น์…˜๊ณผ ํ•˜์œ„ ํ…Œ์ด๋ธ”๋งŒ ๊ต์ฒดํ•œ๋‹ค. Codex ์ž์ฒด์˜ `computer-use`, `node_repl`, ์‚ฌ์šฉ์ž `jaw-computer-use` ํ•ญ๋ชฉ์€ ๋ณด์กดํ•œ๋‹ค. ํ†ตํ•ฉ ์„ค์ •์—์„œ ์„œ๋ฒ„๋ฅผ ์ง€์›Œ๋„ ๊ฐ ๋Œ€์ƒ์˜ ๊ธฐ์กด ํ•ญ๋ชฉ์„ ์ž๋™ ์‚ญ์ œํ•˜์ง€ ์•Š๋Š”๋‹ค. ### symlink ๋ณดํ˜ธ ์ •์ฑ… - ์‹ค๋””๋ ‰ํ† ๋ฆฌ ์ถฉ๋Œ ์‹œ `fs.rmSync` ๋Œ€์‹  `renameSync`๋กœ ๋ฐฑ์—… - ๋ฐฑ์—… ๊ฒฝ๋กœ: `~/.cli-jaw/backups/skills-conflicts//` - ๊ฒฐ๊ณผ๊ฐ€ ๋กœ๊ทธ/API ์‘๋‹ต์— ๊ธฐ๋ก๋จ (`status: ok/skip`, `action: noop/backup/create/conflict`) ## lib/quota-copilot.ts โ€” Copilot Quota & Auth (328L) Copilot ํ• ๋‹น๋Ÿ‰ ์กฐํšŒ + ์ธ์ฆ ํ† ํฐ ๊ด€๋ฆฌ. env โ†’ file cache โ†’ `gh auth token` โ†’ macOS keychain 4๋‹จ๊ณ„ ํด๋ฐฑ. | Function | ์—ญํ•  | | --- | --- | | `hasCopilotAuthSync()` | ๋™๊ธฐ ์ธ์ฆ ์ƒํƒœ ํ™•์ธ | | `readCopilotTokenSync()` | ํ† ํฐ ์ฝ๊ธฐ | | `refreshCopilotFromKeychain()` | keychain ์‹คํŒจ ๋ฆฌ์…‹ + ์บ์‹œ ํด๋ฆฌ์–ด + ์žฌ์‹œ๋„ | ## lib/stt.ts โ€” Voice STT Engine (231L) ์Œ์„ฑ์ธ์‹ ์—”์ง„. Gemini REST API ์ง์ ‘ ํ˜ธ์ถœ โ†’ Whisper fallback. settings.json ์—ฐ๋™. | Function | ์—ญํ•  | | --- | --- | | `transcribeVoice(path, mimeType)` | ์Œ์„ฑ ํŒŒ์ผ โ†’ ํ…์ŠคํŠธ ๋ณ€ํ™˜ | | `getSttSettings()` | settings.json โ†’ env var ํด๋ฐฑ ์ฒด์ธ | ## lib/upload.ts (184L) ํŒŒ์ผ ์—…๋กœ๋“œ ์ฒ˜๋ฆฌ + Telegram ๋‹ค์šด๋กœ๋“œ. --- ## src/routes/ โ€” API registration cluster (36 files, 6700L) `server.ts`๋Š” ์ด์ œ ๋ณด์•ˆ ๋ฏธ๋“ค์›จ์–ด์™€ base routes๋งŒ ์œ ์ง€ํ•˜๊ณ , ์‹ค์ œ API surface๋Š” ์ด ๋””๋ ‰ํ„ฐ๋ฆฌ์˜ registrar/helper๋กœ ๋‚˜๋ˆˆ๋‹ค. | Module | ์—ญํ•  | | --- | --- | | `types.ts` | `AuthMiddleware` shared type | | `employees.ts` | employee CRUD | | `heartbeat.ts` | heartbeat read/write | | `skills.ts` | skill list/enable/disable/reset | | `jaw-memory.ts` | jaw memory search/read/list/save/init/reflect/flush/soul | | `avatar.ts` | avatar summary + image upload/delete/read | | `i18n.ts` | locale bundle endpoints | | `orchestrate.ts` | PABCD reset/state/workers/snapshot/queue steer/dispatch/worker result | | `memory.ts` | memory status/KV/files/settings | | `settings.ts` | settings/prompt/heartbeat-md/MCP/registry/status/quota/copilot | | `messaging.ts` | upload/file-open/voice/telegram/channel/discord send | | `browser.ts` | browser runtime endpoints | | `quota.ts` | `/api/quota` helper readers imported by `settings.ts` (direct provider usage where supported, wrapper runtime delegation for `codex-app`, reverse-engineered AGY Gem/Cla windows when `antigravity-usage --json` is available, and status-only metadata for Cursor/Grok/OpenCode or CLIs without quota windows) | ํ•ต์‹ฌ ํฌ์ธํŠธ: - `server.ts`๋Š” `register*Routes(app, requireAuth, ...)` ํ˜ธ์ถœ๋งŒ ๋‚จ๊ธฐ๊ณ  635L ๊ธ€๋ฃจ ๋ ˆ์ด์–ด๋กœ ์œ ์ง€๋œ๋‹ค. ํ˜„์žฌ mutation endpoint๋Š” ๋ชจ๋‘ `requireAuth` ๋ฏธ๋“ค์›จ์–ด๋ฅผ ๊ฑฐ์ณ ์ธ์ฆ ์—†๋Š” ์ƒํƒœ ๋ณ€๊ฒฝ์„ ์ฐจ๋‹จํ•œ๋‹ค. - `settings.ts`๊ฐ€ `/api/quota`๋ฅผ ์†Œ์œ ํ•˜๋ฉฐ, `quota.ts`๋Š” route registrar๊ฐ€ ์•„๋‹ˆ๋ผ helper module์ด๋‹ค. - `messaging.ts`๊ฐ€ `assertSendFilePath()`์™€ `execFileSync()` ๊ธฐ๋ฐ˜ file open/send ๋ณด์•ˆ์„ ๋‹ด๋‹นํ•œ๋‹ค. --- ## src/security/ โ€” ๋ณด์•ˆ ์ž…๋ ฅ ๊ฒ€์ฆ [P9.1] **์˜์กด ์—†์Œ** โ€” server.ts์—์„œ ๋ผ์šฐํŠธ ํ•ธ๋“ค๋Ÿฌ ์ง„์ž… ์‹œ ํ˜ธ์ถœ. ### path-guards.ts (111L) | Function | ์—ญํ•  | | --- | --- | | `assertSkillId(id)` | skill id ๊ฒ€์ฆ + path segment ์ฐจ๋‹จ | | `assertFilename(f, opts)` | ํ™•์žฅ์ž ํ™”์ดํŠธ๋ฆฌ์ŠคํŠธ + path separator ์ฐจ๋‹จ + ๊ธธ์ด ์ œํ•œ | | `assertMemoryRelPath(input, opts)` | nested relative path ํ—ˆ์šฉ + traversal ์ฐจ๋‹จ | | `assertSendFilePath(filePath, workingDir?)` | `JAW_HOME`/`workingDir`/OS temp ์•„๋ž˜ ํŒŒ์ผ๋งŒ ์ „์†ก ํ—ˆ์šฉ | | `safeResolveUnder(base, rel)` | `path.resolve` ํ›„ base ๋””๋ ‰ํ† ๋ฆฌ ํƒˆ์ถœ ๊ฒ€์ฆ | ### decode.ts (21L) | Function | ์—ญํ•  | | --- | --- | | `decodeFilenameSafe(s)` | `decodeURIComponent` + ๊ธธ์ด ์ œํ•œ (512) + ์—๋Ÿฌ ์‹œ ์›๋ณธ ๋ฐ˜ํ™˜ | #### ์ ์šฉ ๋ผ์šฐํŠธ | ๋ผ์šฐํŠธ | ์ ์šฉ guard | | --- | --- | | `/api/memory-files/:filename` | `assertFilename` + `safeResolveUnder` | | `/api/upload` | `decodeFilenameSafe` | | `/api/skills/enable`, `disable` | `assertSkillId` | | `/api/jaw-memory/read`, `save` | `assertMemoryRelPath` + `normalizeAdvancedReadPath` | | `/api/telegram/send`, `/api/channel/send` | `assertSendFilePath` | --- ## src/http/ โ€” ์‘๋‹ต ๊ณ„์•ฝ [P9.2] **์˜์กด ์—†์Œ** โ€” Express ๋ผ์šฐํŠธ์—์„œ ์ง์ ‘ ์‚ฌ์šฉ. ### response.ts (25L) | Function | ์—ญํ•  | | --- | --- | | `ok(res, data)` | `{ ok: true, ...data }` 200 ์‘๋‹ต | | `fail(res, status, error, extra)` | `{ ok: false, error, ...extra }` ์—๋Ÿฌ ์‘๋‹ต | ### async-handler.ts (14L) | Function | ์—ญํ•  | | --- | --- | | `asyncHandler(fn)` | `Promise.catch(next)` ๋ž˜ํผ | ### error-middleware.ts (26L) | Function | ์—ญํ•  | | --- | --- | | `notFoundHandler` | 404 โ†’ `fail(res, 404, 'not_found')` | | `errorHandler` | ๊ธ€๋กœ๋ฒŒ ์—๋Ÿฌ โ†’ 500 + ๋กœ๊น… | --- ## bin/commands/ โ€” CLI Subcommands ### bin/cli-jaw.ts โ€” CLI Entrypoint > ์„œ๋ธŒ์ปค๋งจ๋“œ ๋ผ์šฐํ„ฐ + `--home` flag ์ฒ˜๋ฆฌ (manual `indexOf`, NOT parseArgs) > `--home` โ†’ `process.env.CLI_JAW_HOME` ์„ค์ • ํ›„ config.ts ๋™์  import > known-command guard: `--home` ์‚ฌ์šฉ ์‹œ ์•Œ๋ ค์ง„ ๋ช…๋ น์–ด๋Š” `bin/cli-jaw.ts`์˜ `_knownCmds`์™€ ๊ฐ™๋‹ค (`serve` โ€ฆ `slack`, `messaging` ํฌํ•จ). ๊ฒฝ๋กœ ๋ˆ„๋ฝ๊ณผ ์„œ๋ธŒ์ปค๋งจ๋“œ๋ฅผ ๊ตฌ๋ถ„ํ•œ๋‹ค ํ˜„์žฌ subcommand router๋Š” `bin/cli-jaw.ts` switch์™€ ๊ฐ™๋‹ค. Messaging operator surface: `jaw messaging ingress list|show|replay|audit`. SQLite maintenance surface: `jaw db maintain` (manual only). ### bin/commands/serve.ts > Source/dist ์ž๋™ ๊ฐ์ง€ foreground server ์‹คํ–‰. | Option | Env | | --- | --- | | `--port` | `PORT` | | `--host` | `HOST` | | `--open` / `--no-open` | `JAW_OPEN_BROWSER` | | `--lan` | `JAW_LAN_MODE` | | `--remote` | `JAW_REMOTE_ACCESS_MODE=direct` | | `--trust-proxy` | `JAW_TRUST_PROXY` | | `--trust-forwarded` | `JAW_TRUST_FORWARDED` | ### bin/commands/dashboard.ts > `jaw dashboard serve [--port 24576] [--from 3457] [--count 50] [--no-open]`. > `jaw dashboard service`๋Š” ํ˜„์žฌ โ€œlater phaseโ€๋กœ ๊ฑฐ์ ˆ๋œ๋‹ค. > Electron app์˜ implicit manager spawn์€ `24577-24590` lane์„ ์‚ฌ์šฉํ•˜๋ฉฐ Web/CLI ๊ธฐ๋ณธ manager `24576`์„ ์Šค์บ”ํ•˜๊ฑฐ๋‚˜ ๊ณต์œ ํ•˜์ง€ ์•Š๋Š”๋‹ค. | Option | Env | | --- | --- | | `--port` | `DASHBOARD_PORT` | | `--from` | `DASHBOARD_SCAN_FROM` | | `--count` | `DASHBOARD_SCAN_COUNT` | | `--open` / `--no-open` | `JAW_DASHBOARD_OPEN` | ### bin/commands/clone.ts (165L) > `jaw clone` โ€” JAW_HOME ํ™˜๊ฒฝ ๋ณต์ œ. source ๋””๋ ‰ํ† ๋ฆฌ ๊ฒ€์ฆ(์กด์žฌ + settings.json ํฌํ•จ). > `--from `: ์†Œ์Šค ์ง€์ •. `--with-memory`: memory/ ๋””๋ ‰ํ† ๋ฆฌ๋„ ๋ณต์‚ฌ. `--link-ref`: skills_ref/ ์‹ฌ๋ณผ๋ฆญ ๋งํฌ. > ๋ณต์ œ ํ›„ subprocess `regenerateB` ํ˜ธ์ถœ๋กœ ํ”„๋กฌํ”„ํŠธ/์Šคํ‚ฌ ์žฌ์ƒ์„ฑ. | Function | ์—ญํ•  | | --- | --- | | `cloneHome(args)` | ์†Œ์Šค ๊ฒ€์ฆ โ†’ ๋””๋ ‰ํ† ๋ฆฌ ๋ณต์‚ฌ โ†’ regenerateB ํ˜ธ์ถœ | ### bin/commands/launchd.ts (163L) > macOS launchd ์„œ๋น„์Šค ๊ด€๋ฆฌ. Multi-instance ์ง€์›. | Function | ์—ญํ•  | | --- | --- | | `instanceId()` | JAW_HOME โ†’ label ์‹๋ณ„์ž (`default` / `-`) | | `xmlEsc(s)` | XML ํŠน์ˆ˜๋ฌธ์ž ์ด์Šค์ผ€์ดํ”„ | | `generatePlist(port)` | launchd plist XML ์ƒ์„ฑ | - `parseArgs({ strict: false })` + manual unknown-key guard - PLIST_PATH ๋”๋ธ”-์ฟผํŒ…์œผ๋กœ ๊ฒฝ๋กœ ๊ณต๋ฐฑ ์•ˆ์ „ ์ฒ˜๋ฆฌ - `launchctl load/unload` ๋ช…๋ น์œผ๋กœ ์„œ๋น„์Šค ์‹œ์ž‘/์ค‘์ง€ ### bin/commands/browser.ts / memory.ts - `getServerUrl(undefined)` ํŒจํ„ด: PORT env ์šฐ์„ , ์—†์œผ๋ฉด DEFAULT_PORT(`3457`) - memory.ts: init ๊ฒฝ๋กœ `${JAW_HOME}/memory/` (ํ•˜๋“œ์ฝ”๋”ฉ `~/.cli-jaw` ์ œ๊ฑฐ) ### Saved permission policy at startup Server startup loads and preserves the configured `permissions` value (`auto`, `safe` or a custom list). The selectors display `auto` as Auto (YOLO). The obsolete Safe-to-Auto coercion is removed so an explicit sidebar choice survives a restart. `tests/unit/server-permission-startup.test.ts` executes the startup source with isolated persistence and stubbed external effects across two starts. ### Draft pull request CI Tests and Postinstall Platform Checks skip every job on draft pull requests, including their aggregates. Skipped jobs are not passing test evidence. `ready_for_review` restores normal PR validation. Existing push and manual `workflow_dispatch` behavior is unchanged. A dependent draft chain can defer hosted verification until its completed top branch, then dispatch the workflows on that exact ref and verify each run's head SHA and producer conclusions. ### Retired runtime package boundary The build no longer copies Jawcode TUI bundles, Bun shims or `pi_natives` payloads. The obsolete Electron Jawcode source tree and `jaw jwc` installer module are gone. The retired-runtime package smoke and staged/platform sidecar absence guards check forbidden payloads while preserving ordinary Node/Jaw/native dependency checks. Negative fixtures prove the guards reject a forbidden payload. An absent staged sidecar is unverified and must not be reported as package absence proof. Existing external installations and user files are never cleaned by retirement.