elanous 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +10 -7
- package/README.md +4 -0
- package/apps/pwa/out/404/index.html +1 -1
- package/apps/pwa/out/404.html +1 -1
- package/apps/pwa/out/_next/static/chunks/1105-c473ed46272fba79.js +1 -0
- package/apps/pwa/out/_next/static/chunks/1201-09613bce624467c0.js +1 -0
- package/apps/pwa/out/_next/static/chunks/1377-1efeffbbac0963ff.js +1 -0
- package/apps/pwa/out/_next/static/chunks/1470.98a6ab61ccb4131c.js +1 -0
- package/apps/pwa/out/_next/static/chunks/216-5acd01cbde4acda7.js +1 -0
- package/apps/pwa/out/_next/static/chunks/2330-c2f07246c8788af1.js +1 -0
- package/apps/pwa/out/_next/static/chunks/{3995-bee512a7063036ce.js → 2375-cb6debea56cce4fb.js} +1 -1
- package/apps/pwa/out/_next/static/chunks/2415.ed6428ff334c7ce2.js +1 -0
- package/apps/pwa/out/_next/static/chunks/2929-617f1e66a55be184.js +1 -0
- package/apps/pwa/out/_next/static/chunks/2977-e38442e86289f1d3.js +1 -0
- package/apps/pwa/out/_next/static/chunks/2982-2a2df543be3d2e5a.js +25 -0
- package/apps/pwa/out/_next/static/chunks/{8d0d9faf-97887ff99713b84e.js → 2ea96958-e8c7e112de50b067.js} +1 -1
- package/apps/pwa/out/_next/static/chunks/{5329.8b7e4bca684b6eec.js → 3403.4bc97b4066945a94.js} +2 -2
- package/apps/pwa/out/_next/static/chunks/3441-a1dd4acfeda14488.js +1 -0
- package/apps/pwa/out/_next/static/chunks/371-4ad6af55dad02ced.js +1 -0
- package/apps/pwa/out/_next/static/chunks/4114-3e63117452378807.js +1 -0
- package/apps/pwa/out/_next/static/chunks/{7633.0654fe6ea259c1ee.js → 4323.c5dfb6f503304775.js} +1 -1
- package/apps/pwa/out/_next/static/chunks/4836-2eba6079f31b88d4.js +1 -0
- package/apps/pwa/out/_next/static/chunks/{2984-977cfa339fcd65a5.js → 5080-1613752891fcadb4.js} +3 -3
- package/apps/pwa/out/_next/static/chunks/5609-012bb3557211f07e.js +1 -0
- package/apps/pwa/out/_next/static/chunks/{763-7d0e1913b5074e98.js → 5791-bb82743fa6299562.js} +1 -1
- package/apps/pwa/out/_next/static/chunks/{4240-7153881b0b377306.js → 6062-73e68343a9814f6a.js} +1 -1
- package/apps/pwa/out/_next/static/chunks/6090-85a3f05f954e5697.js +1 -0
- package/apps/pwa/out/_next/static/chunks/6284-69db415193d5f8bd.js +1 -0
- package/apps/pwa/out/_next/static/chunks/6320-baac91d68843a9a6.js +1 -0
- package/apps/pwa/out/_next/static/chunks/6416-505ba707cacafbba.js +1 -0
- package/apps/pwa/out/_next/static/chunks/6725-68ab7cc0b1faf00d.js +1 -0
- package/apps/pwa/out/_next/static/chunks/6998-a654fe5c58271600.js +1 -0
- package/apps/pwa/out/_next/static/chunks/7647.2fcd30d894d5ee30.js +1 -0
- package/apps/pwa/out/_next/static/chunks/7673-2eda1507d38dadb8.js +1 -0
- package/apps/pwa/out/_next/static/chunks/7990-e12efba616f46e03.js +1 -0
- package/apps/pwa/out/_next/static/chunks/{91ff6dda-3b33d42d20657429.js → 8046cadf-211ca3c0e00f2b72.js} +1 -1
- package/apps/pwa/out/_next/static/chunks/8067-f74bf14d67ad98f1.js +1 -0
- package/apps/pwa/out/_next/static/chunks/8142-744998d65d7bb17e.js +1 -0
- package/apps/pwa/out/_next/static/chunks/8519-f6b5d8a5833a7603.js +1 -0
- package/apps/pwa/out/_next/static/chunks/8619-4365e03a2862830f.js +1 -0
- package/apps/pwa/out/_next/static/chunks/8894-e92491a164192cc1.js +1 -0
- package/apps/pwa/out/_next/static/chunks/920-f7dceb78f1c585ef.js +1 -0
- package/apps/pwa/out/_next/static/chunks/9454-a3e0953307216c58.js +1 -0
- package/apps/pwa/out/_next/static/chunks/9651-3cd291a6fa1370d2.js +1 -0
- package/apps/pwa/out/_next/static/chunks/9740-67051141115ce775.js +1 -0
- package/apps/pwa/out/_next/static/chunks/9804-64c02c3c127d5014.js +1 -0
- package/apps/pwa/out/_next/static/chunks/ae787e4c-f2998de7f1ba72a4.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/_not-found/page-859cea1570b6227a.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/approvals/page-d5ebde04844689e6.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/autopilot/page-10ed24f413ed66e9.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/board/page-211810b6c93ab66a.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/botlab/page-624f7a2f89b60c8f.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/bots/page-5a5fb385a4df0ffe.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/chat/page-80497e93a878ddc5.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/consult/page-7457f52683562161.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/control/page-cee86394de407aa6.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/design-check/page-4ff8edab44196b8c.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/editor/page-92e4f44428d5e290.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/exec/page-b7dcf5d48a854b76.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/field/page-51480757e7d68b92.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/healthz/route-859cea1570b6227a.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/intake/page-2a05dfe80c8bdf16.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/layout-d9979633aa82f8e6.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/live/page-30533117beb53625.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/market/page-f7857826c2f97ad7.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/missions/[id]/page-07267f1391b96aba.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/morning/page-55d50e9b0006a91d.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/not-found-9699b1786be6171d.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/observatory/page-43dd772aee8af75f.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/page-a7e37af7d0399cb8.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/reflection/page-973ab7af59c718b7.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/scheduler/page-a9f8d3865b91e436.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/sessions/page-15e5a15db84c56aa.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/settings/devices/page-a2e572e4511f2a16.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/settings/page-dd107bf1c7d52a90.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/setup/done/page-d42b99cdfb9f27c6.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/setup/layout-859cea1570b6227a.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/setup/page-2764ff40dad5a995.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/share/page-c5f1152db116ff96.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/showroom/page-f933bca81ea38a6f.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/tasks/page-c1c95739c0bff3b8.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/term/page-a7aaffcf771662d8.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/trace/page-71d18eec33b9c667.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/vault/page-56adbe1a1f1379bd.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/workflows/chat-ui/page-2c4e59079ee357ac.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/workflows/page-a81f113f3ef89d72.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/workspace/page-5d422f38c052967e.js +1 -0
- package/apps/pwa/out/_next/static/chunks/app/worktrees/page-fc27b00e20733146.js +1 -0
- package/apps/pwa/out/_next/static/chunks/framework-ea806bb57f2b8923.js +1 -0
- package/apps/pwa/out/_next/static/chunks/main-8d2302399c2c8f87.js +1 -0
- package/apps/pwa/out/_next/static/chunks/main-app-6870f30ea99f8346.js +1 -0
- package/apps/pwa/out/_next/static/chunks/pages/_app-b10928c60f0b8488.js +1 -0
- package/apps/pwa/out/_next/static/chunks/pages/_error-689039227d443fab.js +1 -0
- package/apps/pwa/out/_next/static/chunks/{webpack-37b8bf78a3c6eec5.js → webpack-e5bea36f183b25e6.js} +1 -1
- package/apps/pwa/out/_next/static/css/f537bdb19c69306a.css +1 -0
- package/apps/pwa/out/_next/static/keajW7DDyghEs1y8oJe6T/_buildManifest.js +1 -0
- package/apps/pwa/out/approvals/index.html +1 -1
- package/apps/pwa/out/approvals/index.txt +22 -22
- package/apps/pwa/out/autopilot/index.html +1 -1
- package/apps/pwa/out/autopilot/index.txt +22 -22
- package/apps/pwa/out/board/index.html +1 -1
- package/apps/pwa/out/board/index.txt +22 -22
- package/apps/pwa/out/botlab/index.html +1 -1
- package/apps/pwa/out/botlab/index.txt +21 -21
- package/apps/pwa/out/bots/index.html +1 -1
- package/apps/pwa/out/bots/index.txt +21 -21
- package/apps/pwa/out/chat/index.html +1 -1
- package/apps/pwa/out/chat/index.txt +21 -21
- package/apps/pwa/out/consult/index.html +1 -0
- package/apps/pwa/out/consult/index.txt +32 -0
- package/apps/pwa/out/control/index.html +1 -1
- package/apps/pwa/out/control/index.txt +22 -22
- package/apps/pwa/out/design-check/index.html +1 -1
- package/apps/pwa/out/design-check/index.txt +22 -22
- package/apps/pwa/out/editor/index.html +1 -1
- package/apps/pwa/out/editor/index.txt +22 -22
- package/apps/pwa/out/exec/index.html +1 -0
- package/apps/pwa/out/exec/index.txt +32 -0
- package/apps/pwa/out/field/index.html +1 -0
- package/apps/pwa/out/field/index.txt +32 -0
- package/apps/pwa/out/healthz +1 -1
- package/apps/pwa/out/index.html +1 -1
- package/apps/pwa/out/index.txt +21 -21
- package/apps/pwa/out/intake/index.html +1 -1
- package/apps/pwa/out/intake/index.txt +22 -22
- package/apps/pwa/out/live/index.html +1 -1
- package/apps/pwa/out/live/index.txt +22 -22
- package/apps/pwa/out/market/index.html +1 -1
- package/apps/pwa/out/market/index.txt +21 -21
- package/apps/pwa/out/missions/placeholder/index.html +1 -1
- package/apps/pwa/out/missions/placeholder/index.txt +21 -21
- package/apps/pwa/out/morning/index.html +1 -1
- package/apps/pwa/out/morning/index.txt +22 -22
- package/apps/pwa/out/observatory/index.html +1 -1
- package/apps/pwa/out/observatory/index.txt +22 -22
- package/apps/pwa/out/reflection/index.html +1 -1
- package/apps/pwa/out/reflection/index.txt +22 -22
- package/apps/pwa/out/scheduler/index.html +1 -1
- package/apps/pwa/out/scheduler/index.txt +22 -22
- package/apps/pwa/out/sessions/index.html +1 -1
- package/apps/pwa/out/sessions/index.txt +21 -21
- package/apps/pwa/out/settings/devices/index.html +1 -1
- package/apps/pwa/out/settings/devices/index.txt +22 -22
- package/apps/pwa/out/settings/index.html +1 -1
- package/apps/pwa/out/settings/index.txt +22 -22
- package/apps/pwa/out/setup/done/index.html +1 -1
- package/apps/pwa/out/setup/done/index.txt +22 -22
- package/apps/pwa/out/setup/index.html +1 -1
- package/apps/pwa/out/setup/index.txt +22 -22
- package/apps/pwa/out/share/index.html +1 -1
- package/apps/pwa/out/share/index.txt +22 -22
- package/apps/pwa/out/showroom/index.html +1 -1
- package/apps/pwa/out/showroom/index.txt +21 -21
- package/apps/pwa/out/tasks/index.html +1 -1
- package/apps/pwa/out/tasks/index.txt +22 -22
- package/apps/pwa/out/term/index.html +1 -1
- package/apps/pwa/out/term/index.txt +22 -22
- package/apps/pwa/out/trace/index.html +1 -1
- package/apps/pwa/out/trace/index.txt +22 -22
- package/apps/pwa/out/vault/index.html +1 -1
- package/apps/pwa/out/vault/index.txt +22 -22
- package/apps/pwa/out/workflows/chat-ui/index.html +1 -1
- package/apps/pwa/out/workflows/chat-ui/index.txt +22 -22
- package/apps/pwa/out/workflows/index.html +1 -1
- package/apps/pwa/out/workflows/index.txt +22 -22
- package/apps/pwa/out/workspace/index.html +1 -1
- package/apps/pwa/out/workspace/index.txt +22 -22
- package/apps/pwa/out/worktrees/index.html +1 -1
- package/apps/pwa/out/worktrees/index.txt +22 -22
- package/bin/elanous.cjs +107 -0
- package/graphs/field/field-feed.yaml +24 -0
- package/graphs/field/recipes.yaml +12 -0
- package/graphs/landing/landing-heal.yaml +3 -1
- package/graphs/landing/recipes.yaml +3 -0
- package/graphs/release/recipes.yaml +10 -0
- package/graphs/release/release-loop.yaml +10 -3
- package/package.json +5 -5
- package/plugins/card-followup/README.md +13 -4
- package/plugins/card-followup/graphs/card-followup.yaml +3 -1
- package/plugins/card-followup/graphs/recipes.yaml +5 -1
- package/plugins/card-followup/graphs/run-step.ts +122 -18
- package/plugins/card-followup/graphs/sales-strategy.ts +173 -0
- package/plugins/card-followup/plugin.json +1 -1
- package/plugins/doc-draft/README.md +13 -0
- package/plugins/doc-draft/examples/brief-sample.json +8 -0
- package/plugins/doc-draft/graphs/doc-draft.yaml +14 -0
- package/plugins/doc-draft/graphs/recipes.yaml +9 -0
- package/plugins/doc-draft/graphs/run-step.ts +113 -0
- package/plugins/doc-draft/plugin.json +24 -0
- package/plugins/geo-check/README.md +3 -1
- package/plugins/geo-check/graphs/run-step.ts +24 -3
- package/plugins/geo-check/plugin.json +1 -1
- package/plugins/job-coach/.codex-plugin/plugin.json +1 -1
- package/plugins/job-coach/README.md +1 -1
- package/plugins/job-coach/graphs/run-step.ts +2 -2
- package/plugins/job-coach/plugin.json +1 -1
- package/plugins/job-coach/plugin.ts +1 -1
- package/scripts/affinity/endcard.sh +3 -2
- package/scripts/affinity/reframe.sh +3 -1
- package/scripts/ci-public-export-leak-gate.ts +48 -0
- package/scripts/codex-quota-alert.ts +122 -258
- package/scripts/coord-tracks.json +4 -4
- package/scripts/field-feed/deliver-node.ts +52 -0
- package/scripts/field-feed/feed-node.ts +67 -0
- package/scripts/field-feed/lib.ts +162 -0
- package/scripts/field-feed/reel-node.ts +24 -0
- package/scripts/field-feed/start.ts +62 -0
- package/scripts/fixtures/vflow-sample.ndjson +6 -0
- package/scripts/install.sh +92 -13
- package/scripts/landing-heal/clean-checkout.ts +114 -0
- package/scripts/landing-heal/run-mission.ts +38 -3
- package/scripts/lib/pwa-scenarios/scenarios.ts +2 -1
- package/scripts/public-export.ts +8 -4
- package/scripts/release-loop/baseline-from-logs.ts +92 -0
- package/scripts/release-loop/env-known-failures.ts +31 -0
- package/scripts/release-loop/gate-node.ts +81 -19
- package/scripts/release-loop/known-issues-node.ts +159 -0
- package/scripts/release-loop/npm-publish-node.ts +118 -0
- package/scripts/release-loop/ops-upgrade-node.ts +87 -0
- package/scripts/release-loop/release-readiness.ts +58 -0
- package/scripts/release-loop/unattended-release.ts +93 -0
- package/scripts/ux/measure-first-text.ts +102 -0
- package/scripts/vflow-collect.ts +20 -7
- package/scripts/vflow-search.ts +73 -0
- package/scripts/video-free-line-test-walker.ts +36 -0
- package/scripts/video-pipeline.ts +2 -2
- package/skills/explainer-video/SKILL.md +12 -9
- package/skills/explainer-video/engine/build.mjs +1 -1
- package/skills/explainer-video/engine/reel.mjs +138 -31
- package/skills/explainer-video/engine/reel.sh +2 -1
- package/skills/explainer-video/examples/elanous-0.2.5/script.json +1 -1
- package/skills/grill-me/SKILL.md +1 -1
- package/skills/omni-digest/docs/diagrams/noncode-terminal-promotion-path-2026-08-13.mmd +1 -1
- package/src/a2a/server.ts +2 -0
- package/src/acp/elanous-aware-peers.ts +30 -0
- package/src/acp/server.ts +91 -15
- package/src/agent/monad-agent-turn.ts +25 -6
- package/src/agent/shared-app-tools.ts +5 -3
- package/src/agent-substrate/review-intent.ts +6 -2
- package/src/agent-substrate/shard-boundary-intent.ts +70 -0
- package/src/auth/github-app-token.ts +4 -1
- package/src/autopilot/track-agent-shadow.ts +151 -0
- package/src/autopilot/track-agent.ts +23 -3
- package/src/boot/acp-server-help.ts +16 -0
- package/src/boot/daemon-prompt-turn.ts +31 -10
- package/src/boot/daemon-tools/index.ts +7 -1
- package/src/budget/codex-credit-pace.ts +84 -0
- package/src/budget/codex-credit-plan.ts +154 -0
- package/src/budget/codex-reset-credit-state.ts +2 -0
- package/src/chat/chat-cli.ts +4 -1
- package/src/chat/short-question.ts +40 -0
- package/src/cli/agent-cli.ts +24 -15
- package/src/cli/ask-bare.ts +42 -0
- package/src/cli/cli-user-error.ts +25 -0
- package/src/cli/codex-credit-plan-view.ts +25 -0
- package/src/cli/dependence-gauge.ts +237 -0
- package/src/cli/doctor-cli.ts +5 -0
- package/src/cli/doctor-modes.ts +48 -0
- package/src/cli/intake-cli.ts +12 -2
- package/src/cli/intake-source-cli.ts +58 -0
- package/src/cli/machine-cli.ts +23 -0
- package/src/cli/msg-cli.ts +137 -0
- package/src/cli/plugin-cli.ts +25 -0
- package/src/cli/pr-cli.ts +36 -0
- package/src/cli/provider-cli.ts +5 -0
- package/src/cli/release-cli.ts +42 -1
- package/src/cli/release-run-if-ready.ts +48 -0
- package/src/cli/setup-cli.ts +27 -6
- package/src/cli/setup-recommend.ts +8 -0
- package/src/cli/usage-cli.ts +11 -1
- package/src/codex/setup.ts +27 -8
- package/src/dashboard/index.ts +1 -1
- package/src/discord.ts +56 -6
- package/src/domains/core-tools.ts +37 -14
- package/src/domains/outbound-alert.ts +50 -11
- package/src/exec-requests/planner.ts +140 -0
- package/src/exec-requests/runner.ts +338 -0
- package/src/exec-requests/store.ts +76 -0
- package/src/field/field-media.ts +8 -3
- package/src/field/field-reel.ts +196 -0
- package/src/grok/credential.ts +7 -5
- package/src/harness/aside-run-status.ts +33 -0
- package/src/harness/browser-verify.ts +48 -17
- package/src/harness/harness-cli-command.ts +25 -3
- package/src/harness/image-load-state.ts +21 -0
- package/src/harness/process-garbage.ts +45 -0
- package/src/index.ts +86 -14
- package/src/instance/leader.ts +13 -1
- package/src/intake-plane/collect-github.ts +5 -3
- package/src/intake-plane/collect-telegram-saved.ts +15 -3
- package/src/intake-plane/discord-seat-work.ts +56 -0
- package/src/intake-plane/intake-sources.ts +202 -0
- package/src/intake-plane/items.ts +28 -12
- package/src/intake-plane/seat-doc-route.ts +207 -0
- package/src/intake-plane/submit-intake-work.ts +9 -1
- package/src/intake-plane/telegram-seat-work.ts +72 -0
- package/src/llm/model-defaults.ts +24 -1
- package/src/llm.ts +5 -4
- package/src/machines/machine-ledger.ts +127 -0
- package/src/market/pack-internal-refs.ts +28 -0
- package/src/market/publish.ts +31 -4
- package/src/maturity/feature-maturity.ts +65 -0
- package/src/model-tier/turn-tier.ts +24 -0
- package/src/msg/msg-store.ts +149 -0
- package/src/native-tool-catalog.ts +2 -1
- package/src/nexus/api/chat-fast-path-config.ts +28 -0
- package/src/nexus/api/consult-requests.ts +117 -0
- package/src/nexus/api/discord-trigger-bot.ts +3 -0
- package/src/nexus/api/exec-requests.ts +51 -0
- package/src/nexus/api/field-uploads.ts +40 -3
- package/src/nexus/api/graph-approvals-feed.ts +140 -0
- package/src/nexus/api/graph-approvals.ts +71 -4
- package/src/nexus/api/http-server.ts +61 -7
- package/src/nexus/api/seat-requests.ts +254 -0
- package/src/nexus/api/trace-run-scan.ts +37 -0
- package/src/nexus/api/trace.ts +19 -3
- package/src/nexus/index.ts +3 -0
- package/src/nexus/setup-status.ts +4 -5
- package/src/notify/llm-budget-alert.ts +16 -10
- package/src/oauth/codex-account-rotation.ts +26 -4
- package/src/oauth/codex-account-store.ts +20 -2
- package/src/oauth/codex-browser-login.ts +173 -0
- package/src/oauth/codex.ts +4 -1
- package/src/oauth/fallback-chain.ts +5 -5
- package/src/oauth/store.ts +42 -5
- package/src/onboarding/continue-here.ts +29 -0
- package/src/onboarding/entry-hints.ts +8 -0
- package/src/onboarding/full-screen-io.ts +35 -3
- package/src/onboarding/help/skills.md +1 -1
- package/src/onboarding/non-interactive.ts +1 -0
- package/src/onboarding/subscription-hint.ts +27 -0
- package/src/onboarding/web-first.ts +83 -0
- package/src/onboarding.ts +230 -23
- package/src/plugins/maker/node-install.ts +92 -0
- package/src/plugins/maker/node-maker.ts +139 -0
- package/src/plugins/maker/plugin-maker.ts +19 -7
- package/src/policy/llm-policy.ts +268 -0
- package/src/prompt-library/session-guidance.ts +7 -1
- package/src/prompt-library/universal-preamble.ts +2 -2
- package/src/relay/relay-cli.ts +20 -0
- package/src/relay/relay-server.ts +220 -0
- package/src/release-loop/checklist.ts +9 -8
- package/src/self-dev/decompose.ts +1 -0
- package/src/self-dev/dev-pipeline.ts +6 -3
- package/src/self-dev/run-record-mirror.ts +44 -0
- package/src/self-dev/run-store.ts +12 -3
- package/src/self-implement/harness-policy-gates.ts +4 -1
- package/src/self-implement/report-origin.ts +12 -1
- package/src/session/chat.ts +17 -5
- package/src/skills/shared-agent-skill-roots.ts +25 -0
- package/src/steward/failure-streak.ts +78 -0
- package/src/steward/steward-cards.ts +24 -0
- package/src/steward/triage-budget.ts +127 -0
- package/src/steward/triage-plan.ts +75 -0
- package/src/steward/triage.ts +244 -42
- package/src/task-cards/card-store.ts +1 -1
- package/src/task-orchestrator/surfaces/pod-ledger-collect.ts +11 -5
- package/src/task-orchestrator/surfaces/pod-ledger-events.ts +68 -0
- package/src/task-orchestrator/surfaces/self-implement-pod.ts +78 -4
- package/src/telegram.ts +38 -2
- package/src/tool-runtime/elanous-skills-list-runtime.ts +3 -3
- package/src/tool-runtime/self-cognition-runtimes.ts +160 -2
- package/src/user-config.ts +80 -4
- package/src/version/packed-revision.json +1 -1
- package/src/video-pipeline/recipes/character.ts +42 -5
- package/src/video-pipeline/recipes/ffmpeg.ts +1 -1
- package/src/video-pipeline/recipes/free-line.ts +16 -3
- package/src/video-pipeline/recipes/remote.ts +7 -1
- package/src/video-pipeline/vflow-reference.ts +109 -0
- package/apps/pwa/out/_next/static/chunks/1169-696263ac7af8c4d4.js +0 -1
- package/apps/pwa/out/_next/static/chunks/1883.c91a2648af4842fd.js +0 -1
- package/apps/pwa/out/_next/static/chunks/1947-9d64872eeb9cfdec.js +0 -1
- package/apps/pwa/out/_next/static/chunks/2808-dc06482994b40f70.js +0 -1
- package/apps/pwa/out/_next/static/chunks/3165-95515ca5f299a120.js +0 -1
- package/apps/pwa/out/_next/static/chunks/3190-e9282753e7ebde85.js +0 -1
- package/apps/pwa/out/_next/static/chunks/4259-99614149577e77cb.js +0 -1
- package/apps/pwa/out/_next/static/chunks/4283-329eabeaf233e6cd.js +0 -1
- package/apps/pwa/out/_next/static/chunks/4328-cb5058b1acc2de5e.js +0 -25
- package/apps/pwa/out/_next/static/chunks/4801-ecee6ef62b349b18.js +0 -1
- package/apps/pwa/out/_next/static/chunks/5110-8058791dd25a2e14.js +0 -1
- package/apps/pwa/out/_next/static/chunks/5330-c41e9670f594c38f.js +0 -1
- package/apps/pwa/out/_next/static/chunks/5423-e95fd125d1794349.js +0 -1
- package/apps/pwa/out/_next/static/chunks/5478-b5eae07dc79ea619.js +0 -1
- package/apps/pwa/out/_next/static/chunks/5787-96ee6642b9a661e5.js +0 -1
- package/apps/pwa/out/_next/static/chunks/6448-79d72368589f98bc.js +0 -1
- package/apps/pwa/out/_next/static/chunks/6522-9866c002b5531836.js +0 -1
- package/apps/pwa/out/_next/static/chunks/6729-b4a558b7aa891e0c.js +0 -1
- package/apps/pwa/out/_next/static/chunks/6969-cb03f9410b7d2e03.js +0 -1
- package/apps/pwa/out/_next/static/chunks/7007-3b9861091bb8dd21.js +0 -1
- package/apps/pwa/out/_next/static/chunks/7930-8dc7e20fc6fc19ca.js +0 -1
- package/apps/pwa/out/_next/static/chunks/8071-187edbc22a86741f.js +0 -1
- package/apps/pwa/out/_next/static/chunks/8198-d4101ad70cb9a579.js +0 -1
- package/apps/pwa/out/_next/static/chunks/8250.4a2c5553a07cdf47.js +0 -1
- package/apps/pwa/out/_next/static/chunks/8293-123b91e7b0330dc0.js +0 -1
- package/apps/pwa/out/_next/static/chunks/8296-d6d5d87dfa911d41.js +0 -1
- package/apps/pwa/out/_next/static/chunks/8305-603963c33ee8eec3.js +0 -1
- package/apps/pwa/out/_next/static/chunks/8612-4a0066f20951b8fd.js +0 -1
- package/apps/pwa/out/_next/static/chunks/9181-cf4e1b61c4783f92.js +0 -1
- package/apps/pwa/out/_next/static/chunks/9262-26c2ecbd5a67e4a2.js +0 -1
- package/apps/pwa/out/_next/static/chunks/9328-45abdebce4fbecb7.js +0 -1
- package/apps/pwa/out/_next/static/chunks/9355-dbc67205adf8745f.js +0 -1
- package/apps/pwa/out/_next/static/chunks/9763.255b90dd69875689.js +0 -1
- package/apps/pwa/out/_next/static/chunks/9933-66d31ec25c0231af.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/_not-found/page-bd06fb55f4da0381.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/approvals/page-4e586142da455a25.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/autopilot/page-889ad5cddcf45b0d.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/board/page-47ba401d56572c27.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/botlab/page-0b54f9c83458e038.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/bots/page-4fcc296ef6c8ed90.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/chat/page-fe9fda494a87f4e5.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/control/page-f9642e25ce129590.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/design-check/page-e1063e8ba5f3e2e7.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/editor/page-9d0df30027d8aa9d.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/healthz/route-bd06fb55f4da0381.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/intake/page-d97adf2c9455b8d0.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/layout-236b80d202110362.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/live/page-21a30f35f1a276ad.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/market/page-b1a5be357c4fa25d.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/missions/[id]/page-1705a60303f7f573.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/morning/page-76b337c11ad0e237.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/not-found-7c0f85fbb56f64c6.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/observatory/page-65ca16b20617b44d.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/page-e7f9b8fc29411c1d.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/reflection/page-92ea6213d1aeec04.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/scheduler/page-a913a005aacb5476.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/sessions/page-2d78804a40dfdef6.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/settings/devices/page-08a99148e780ac00.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/settings/page-deb674e7ed36f815.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/setup/done/page-49f8de0534d192d7.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/setup/layout-bd06fb55f4da0381.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/setup/page-ba162a28d2176e18.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/share/page-1ff1a37b550ab41a.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/showroom/page-ccaa698f56c0fbdb.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/tasks/page-53b944082de1d7db.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/term/page-9b70adf1552789bf.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/trace/page-30d482aa63241fe8.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/vault/page-aecf786f54651d8a.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/workflows/chat-ui/page-6ab9b62c7b6e08f2.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/workflows/page-08949735455e0c9a.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/workspace/page-a1479005234a46c2.js +0 -1
- package/apps/pwa/out/_next/static/chunks/app/worktrees/page-c3890e90bd232732.js +0 -1
- package/apps/pwa/out/_next/static/chunks/beb5cf10-9adcc10b83930090.js +0 -1
- package/apps/pwa/out/_next/static/chunks/framework-d68d41c88e05c801.js +0 -1
- package/apps/pwa/out/_next/static/chunks/main-app-11c63971b7a9593b.js +0 -1
- package/apps/pwa/out/_next/static/chunks/main-d09452353bd0d9cc.js +0 -1
- package/apps/pwa/out/_next/static/chunks/pages/_app-184d727cebeca767.js +0 -1
- package/apps/pwa/out/_next/static/chunks/pages/_error-21bbbbac99b720b1.js +0 -1
- package/apps/pwa/out/_next/static/css/eaa74e8bb2f62269.css +0 -1
- package/apps/pwa/out/_next/static/qMI0jnlZaBjjm4aIDYNGM/_buildManifest.js +0 -1
- /package/apps/pwa/out/_next/static/{qMI0jnlZaBjjm4aIDYNGM → keajW7DDyghEs1y8oJe6T}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { existsSync, readFileSync, realpathSync, statSync } from 'node:fs';
|
|
2
|
+
import { basename, dirname, isAbsolute, join, resolve, sep } from 'node:path';
|
|
3
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
4
|
+
import { debug } from '../debug/log.js';
|
|
5
|
+
import { effectiveInstanceRoot } from '../instance/resolve.js';
|
|
6
|
+
import { lastJsonObject, runGraph, type GraphRunState } from '../graph-runner/runner.js';
|
|
7
|
+
import { installedGraphs, planExecRequest, type ExecPlanItem, type InstalledGraph } from './planner.js';
|
|
8
|
+
import { ExecRequestStore, type ExecRequest, type ExecResult, type ExecSeat } from './store.js';
|
|
9
|
+
|
|
10
|
+
export interface ExecRunnerDeps {
|
|
11
|
+
store?: ExecRequestStore;
|
|
12
|
+
graphs?: () => Promise<InstalledGraph[]>;
|
|
13
|
+
plan?: (text: string) => Promise<ExecPlanItem[]>;
|
|
14
|
+
run?: typeof runGraph;
|
|
15
|
+
root?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const active = new Set<string>();
|
|
19
|
+
const SEGMENT = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
20
|
+
const kinds: Record<string, ExecResult['kind']> = {
|
|
21
|
+
'.pdf': 'pdf', '.mp4': 'video', '.mov': 'video', '.webm': 'video', '.png': 'image', '.jpg': 'image',
|
|
22
|
+
'.jpeg': 'image', '.webp': 'image', '.md': 'report', '.txt': 'text',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function safeFile(path: string, root: string, graphId: string, runId: string): string | null {
|
|
26
|
+
if (!SEGMENT.test(graphId) || !SEGMENT.test(runId)) return null;
|
|
27
|
+
// Only run-prefixed files or the run artifact directory, never a sibling run's output.
|
|
28
|
+
const allowed = join(root, 'graph-runs', graphId);
|
|
29
|
+
const candidate = isAbsolute(path) ? path : resolve(allowed, path);
|
|
30
|
+
try {
|
|
31
|
+
const real = realpathSync(candidate);
|
|
32
|
+
const base = realpathSync(allowed);
|
|
33
|
+
const runPrefix = `${runId}.json.`;
|
|
34
|
+
const local = dirname(real) === base && basename(real).startsWith(runPrefix)
|
|
35
|
+
&& !/\.(?:decision\.json|tmp)$/.test(real);
|
|
36
|
+
const artifactsDir = join(allowed, `${runId}.json.artifacts`);
|
|
37
|
+
const realArtifactsDir = existsSync(artifactsDir) && statSync(artifactsDir).isDirectory()
|
|
38
|
+
? realpathSync(artifactsDir) : null;
|
|
39
|
+
const inRunDirectory = realArtifactsDir === join(base, `${runId}.json.artifacts`)
|
|
40
|
+
&& real.startsWith(`${realArtifactsDir}${sep}`);
|
|
41
|
+
if ((!local && !inRunDirectory) || !statSync(real).isFile()) return null;
|
|
42
|
+
return real;
|
|
43
|
+
} catch { return null; }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function publicLink(value: unknown): string | null {
|
|
47
|
+
if (typeof value !== 'string') return null;
|
|
48
|
+
try {
|
|
49
|
+
const url = new URL(value);
|
|
50
|
+
return (url.protocol === 'https:' || url.protocol === 'http:') && url.hostname && !url.username && !url.password ? value : null;
|
|
51
|
+
} catch { return null; }
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function fileName(path: string, runId: string): string {
|
|
55
|
+
const digest = createHash('sha256').update(path).digest('hex');
|
|
56
|
+
return `${runId}--${digest}--${basename(path)}`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function resultOf(output: Record<string, unknown>, seat: ExecSeat, id: string, root: string): ExecResult | null {
|
|
60
|
+
const candidate = typeof output.file === 'string' ? output.file : typeof output.path === 'string' ? output.path : null;
|
|
61
|
+
let url: string;
|
|
62
|
+
let kind: ExecResult['kind'];
|
|
63
|
+
let name: string;
|
|
64
|
+
if (candidate !== null) {
|
|
65
|
+
const path = safeFile(candidate, root, seat.graphId, seat.runId);
|
|
66
|
+
if (!path) return null;
|
|
67
|
+
const fileKind = kinds[basename(path).slice(basename(path).lastIndexOf('.')).toLowerCase()];
|
|
68
|
+
if (!fileKind) return null;
|
|
69
|
+
kind = fileKind;
|
|
70
|
+
name = basename(path);
|
|
71
|
+
url = `/v1/exec-requests/${id}/files/${encodeURIComponent(fileName(path, seat.runId))}`;
|
|
72
|
+
} else {
|
|
73
|
+
const link = publicLink(output.url);
|
|
74
|
+
if (!link) return null;
|
|
75
|
+
kind = 'link';
|
|
76
|
+
name = link;
|
|
77
|
+
url = link;
|
|
78
|
+
}
|
|
79
|
+
const sources = Array.isArray(output.sources) ? output.sources.flatMap((source: unknown) => {
|
|
80
|
+
if (!source || typeof source !== 'object') return [];
|
|
81
|
+
const entry = source as { title?: unknown; url?: unknown };
|
|
82
|
+
const sourceUrl = publicLink(entry.url);
|
|
83
|
+
return typeof entry.title === 'string' && sourceUrl ? [{ title: entry.title, url: sourceUrl }] : [];
|
|
84
|
+
}) : [];
|
|
85
|
+
return { seat: seat.seat, kind, title: typeof output.title === 'string' ? output.title : name,
|
|
86
|
+
url, ...(sources.length ? { sources } : {}) };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function syncRun(item: ExecRequest, seat: ExecSeat, state: GraphRunState, root: string): void {
|
|
90
|
+
const previous = seat.status;
|
|
91
|
+
seat.status = state.status === 'done' ? 'done' : state.status === 'failed' || state.status === 'budget-exceeded' ? 'failed' : 'running';
|
|
92
|
+
if (previous !== seat.status) debug.log('exec-requests', 'seat-status', { id: item.id, seat: seat.seat, from: previous, to: seat.status, graphId: seat.graphId, runId: seat.runId });
|
|
93
|
+
const claim = state.status === 'awaiting-approval' && state.pending
|
|
94
|
+
? `${join(root, 'graph-runs', seat.graphId, `${seat.runId}.json`)}.${state.path.length}.decision.json` : '';
|
|
95
|
+
if (state.status === 'awaiting-approval' && state.pending && !state.pending.decision && !existsSync(claim)) {
|
|
96
|
+
if (!item.approvals.some(a => a.graphId === seat.graphId && a.runId === seat.runId)) {
|
|
97
|
+
item.approvals.push({ graphId: seat.graphId, runId: seat.runId, message: state.pending.message });
|
|
98
|
+
}
|
|
99
|
+
} else item.approvals = item.approvals.filter(a => a.graphId !== seat.graphId || a.runId !== seat.runId);
|
|
100
|
+
for (const node of state.nodes ?? []) {
|
|
101
|
+
const output = lastJsonObject(node.output);
|
|
102
|
+
if (!output) continue;
|
|
103
|
+
const entries = Array.isArray(output.artifacts) ? output.artifacts : [output];
|
|
104
|
+
for (const entry of entries) {
|
|
105
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) continue;
|
|
106
|
+
const result = resultOf(entry as Record<string, unknown>, seat, item.id, root);
|
|
107
|
+
if (result && !item.results.some(existing => existing.seat === result.seat && existing.url === result.url)) item.results.push(result);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const summary = [...(state.nodes ?? [])].reverse().map(node => lastJsonObject(node.output)?.summary).find(value => typeof value === 'string');
|
|
111
|
+
if (typeof summary === 'string') item.summary = summary;
|
|
112
|
+
if (seat.status === 'failed') seat.reason = state.nodes?.at(-1)?.error ?? `그래프 런 ${state.status}`;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function aggregate(item: ExecRequest): void {
|
|
116
|
+
if (item.status === 'planning' || item.seats.length === 0) return;
|
|
117
|
+
if (item.seats.some(seat => seat.status === 'waiting' || seat.status === 'running')) item.status = 'running';
|
|
118
|
+
else item.status = item.seats.some(seat => seat.status === 'failed') ? 'failed' : 'done';
|
|
119
|
+
// 실패면 요약은 «실패 사유»가 이긴다 — 먼저 끝난 자리의 산출 설명이 남아 있어도 덮는다(혼합 결과에서 성공처럼 보이지 않게).
|
|
120
|
+
if (item.status === 'failed') {
|
|
121
|
+
const reasons = item.seats.filter(seat => seat.status === 'failed').map(seat => seat.reason ?? `${seat.seat}: 그래프 실행 실패`);
|
|
122
|
+
if (reasons.length > 0) item.summary = reasons.join('; ');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export class ExecRequestRunner {
|
|
127
|
+
readonly store: ExecRequestStore;
|
|
128
|
+
private readonly root: string;
|
|
129
|
+
constructor(private readonly deps: ExecRunnerDeps = {}) {
|
|
130
|
+
this.store = deps.store ?? new ExecRequestStore();
|
|
131
|
+
this.root = deps.root ?? effectiveInstanceRoot();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** 데몬 «시작» 때 한 번만 부른다(`startNexusHttpServer`). 생성자에서 부르면 모듈을 import 만 한 다른 프로세스
|
|
135
|
+
* (시험·CLI·동시 서버)가 살아 있는 요청을 «재시작 중단»으로 실패 처리한다(리뷰 3라운드 must-fix). */
|
|
136
|
+
reconcileInterrupted(): void {
|
|
137
|
+
for (const item of this.store.list()) {
|
|
138
|
+
if (item.status !== 'planning' && item.status !== 'running') continue;
|
|
139
|
+
if (item.status === 'planning') {
|
|
140
|
+
item.status = 'failed';
|
|
141
|
+
item.summary = '데몬 재시작으로 COO 계획이 중단됐습니다';
|
|
142
|
+
} else {
|
|
143
|
+
if (item.seats.length === 0) {
|
|
144
|
+
item.status = 'failed';
|
|
145
|
+
item.summary = '데몬 재시작으로 자리 배정이 중단됐습니다';
|
|
146
|
+
}
|
|
147
|
+
for (const seat of item.seats) {
|
|
148
|
+
if (seat.status === 'done' || seat.status === 'failed') continue;
|
|
149
|
+
const reason = '데몬 재시작으로 그래프 실행이 중단됐습니다';
|
|
150
|
+
if (SEGMENT.test(seat.graphId) && SEGMENT.test(seat.runId)) {
|
|
151
|
+
try {
|
|
152
|
+
const file = join(this.root, 'graph-runs', seat.graphId, `${seat.runId}.json`);
|
|
153
|
+
const state = JSON.parse(readFileSync(file, 'utf8')) as GraphRunState;
|
|
154
|
+
if (state.graphId === seat.graphId && state.runId === seat.runId) {
|
|
155
|
+
if (state.status === 'done' || state.status === 'failed' || state.status === 'budget-exceeded'
|
|
156
|
+
|| (state.status === 'awaiting-approval' && state.pending)) {
|
|
157
|
+
syncRun(item, seat, state, this.root);
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
} catch { /* No trustworthy completed or approval-pending run to recover. */ }
|
|
162
|
+
}
|
|
163
|
+
const previous = seat.status;
|
|
164
|
+
seat.status = 'failed';
|
|
165
|
+
seat.reason = reason;
|
|
166
|
+
item.approvals = item.approvals.filter(a => a.graphId !== seat.graphId || a.runId !== seat.runId);
|
|
167
|
+
debug.log('exec-requests', 'seat-status', { id: item.id, seat: seat.seat, from: previous, to: 'failed', reason });
|
|
168
|
+
}
|
|
169
|
+
aggregate(item);
|
|
170
|
+
if (item.status === 'failed' && item.seats.length > 0) item.summary = item.seats.filter(seat => seat.status === 'failed')
|
|
171
|
+
.map(seat => seat.reason ?? `${seat.seat}: 그래프 실행 실패`).join('; ');
|
|
172
|
+
}
|
|
173
|
+
this.store.save(item);
|
|
174
|
+
if (item.status === 'failed') debug.log('exec-requests', 'failed', { id: item.id, reason: item.summary });
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
submit(text: string): ExecRequest {
|
|
179
|
+
const item = this.store.create(text);
|
|
180
|
+
void this.execute(item.id).catch(error => {
|
|
181
|
+
const current = this.store.get(item.id);
|
|
182
|
+
if (!current) return;
|
|
183
|
+
current.status = 'failed';
|
|
184
|
+
current.summary = error instanceof Error ? error.message : String(error);
|
|
185
|
+
this.store.save(current);
|
|
186
|
+
debug.log('exec-requests', 'failed', { id: item.id, reason: current.summary });
|
|
187
|
+
});
|
|
188
|
+
return item;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
private async execute(id: string): Promise<void> {
|
|
192
|
+
const item = this.store.get(id);
|
|
193
|
+
if (!item) return;
|
|
194
|
+
const graphs = await (this.deps.graphs ?? installedGraphs)();
|
|
195
|
+
const plans = await (this.deps.plan ?? ((text: string) => planExecRequest(text, { graphs: async () => graphs })))(item.text);
|
|
196
|
+
const byId = new Map(graphs.map(graph => [graph.id, graph]));
|
|
197
|
+
item.seats = plans.map(plan => ({ seat: plan.seat, title: plan.title, status: plan.reason || !byId.has(plan.graphId) ? 'failed' : 'waiting', graphId: plan.graphId,
|
|
198
|
+
runId: plan.reason || !byId.has(plan.graphId) ? '' : randomUUID(), inputs: plan.inputs,
|
|
199
|
+
...(plan.reason || !byId.has(plan.graphId) ? { reason: plan.reason ?? `${plan.seat}: 요청에 맞는 설치된 실행 그래프가 없습니다` } : {}) }));
|
|
200
|
+
item.status = 'running';
|
|
201
|
+
debug.log('exec-requests', 'planned', { id, seats: item.seats.map(seat => ({ seat: seat.seat, graphId: seat.graphId, status: seat.status })) });
|
|
202
|
+
this.store.save(item);
|
|
203
|
+
await Promise.all(item.seats.map(async (seat, index) => {
|
|
204
|
+
const graph = byId.get(seat.graphId);
|
|
205
|
+
if (!graph || seat.status === 'failed') return;
|
|
206
|
+
const starting = this.store.get(id)!;
|
|
207
|
+
starting.seats[index]!.status = 'running';
|
|
208
|
+
this.store.save(starting);
|
|
209
|
+
debug.log('exec-requests', 'started', { id, seat: seat.seat, graphId: seat.graphId, runId: seat.runId });
|
|
210
|
+
debug.log('exec-requests', 'seat-status', { id, seat: seat.seat, from: 'waiting', to: 'running' });
|
|
211
|
+
try {
|
|
212
|
+
const state = await (this.deps.run ?? runGraph)(graph.path, { input: seat.inputs, runId: seat.runId, deps: { root: this.root } });
|
|
213
|
+
const current = this.store.get(id)!;
|
|
214
|
+
syncRun(current, current.seats[index]!, state, this.root);
|
|
215
|
+
aggregate(current);
|
|
216
|
+
this.store.save(current);
|
|
217
|
+
} catch (error) {
|
|
218
|
+
const current = this.store.get(id)!;
|
|
219
|
+
current.seats[index]!.status = 'failed';
|
|
220
|
+
current.seats[index]!.reason = error instanceof Error ? error.message : String(error);
|
|
221
|
+
debug.log('exec-requests', 'seat-status', { id, seat: seat.seat, to: 'failed', reason: current.seats[index]!.reason });
|
|
222
|
+
aggregate(current);
|
|
223
|
+
this.store.save(current);
|
|
224
|
+
}
|
|
225
|
+
}));
|
|
226
|
+
const finished = this.store.get(id)!;
|
|
227
|
+
aggregate(finished);
|
|
228
|
+
this.store.save(finished);
|
|
229
|
+
if (finished.status === 'done' || finished.status === 'failed') debug.log('exec-requests', finished.status, { id, results: finished.results.length });
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
get(id: string): ExecRequest | null {
|
|
233
|
+
const item = this.store.get(id);
|
|
234
|
+
if (!item) return null;
|
|
235
|
+
if (item.status === 'planning' || item.status === 'done' || item.status === 'failed') return item;
|
|
236
|
+
for (const seat of item.seats) {
|
|
237
|
+
// An approved decision triggers a resume; failures are terminal and never retried on reads.
|
|
238
|
+
// A terminal seat is never re-synced from a stale awaiting-approval snapshot.
|
|
239
|
+
if (seat.status === 'done' || seat.status === 'failed' || !seat.runId || !SEGMENT.test(seat.graphId) || !SEGMENT.test(seat.runId)) continue;
|
|
240
|
+
const file = join(this.root, 'graph-runs', seat.graphId, `${seat.runId}.json`);
|
|
241
|
+
if (!existsSync(file)) continue;
|
|
242
|
+
try {
|
|
243
|
+
const state = JSON.parse(readFileSync(file, 'utf8')) as GraphRunState;
|
|
244
|
+
if (state.graphId !== seat.graphId || state.runId !== seat.runId) continue;
|
|
245
|
+
syncRun(item, seat, state, this.root);
|
|
246
|
+
if (state.status === 'awaiting-approval' && state.pending && !state.pending.decision) {
|
|
247
|
+
const decision = `${file}.${state.path.length}.decision.json`;
|
|
248
|
+
if (existsSync(decision)) {
|
|
249
|
+
item.approvals = item.approvals.filter(a => a.runId !== seat.runId);
|
|
250
|
+
const key = `${seat.graphId}/${seat.runId}`;
|
|
251
|
+
if (!active.has(key)) {
|
|
252
|
+
active.add(key);
|
|
253
|
+
const launch = async () => {
|
|
254
|
+
try {
|
|
255
|
+
const graphs = await (this.deps.graphs ?? installedGraphs)();
|
|
256
|
+
const graph = graphs.find(candidate => candidate.id === seat.graphId);
|
|
257
|
+
if (!graph) throw new Error('설치된 그래프가 없습니다');
|
|
258
|
+
const resumed = await (this.deps.run ?? runGraph)(graph.path, { resumeRunId: seat.runId, deps: { root: this.root } });
|
|
259
|
+
const current = this.store.get(id);
|
|
260
|
+
const target = current?.seats.find(s => s.runId === seat.runId);
|
|
261
|
+
if (current && target) { syncRun(current, target, resumed, this.root); aggregate(current); this.store.save(current); }
|
|
262
|
+
} catch (error) {
|
|
263
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
264
|
+
const current = this.store.get(id);
|
|
265
|
+
const target = current?.seats.find(s => s.graphId === seat.graphId && s.runId === seat.runId);
|
|
266
|
+
if (current && target && target.status !== 'done') {
|
|
267
|
+
target.status = 'failed';
|
|
268
|
+
target.reason = `그래프 재개 실패: ${reason}`;
|
|
269
|
+
current.approvals = current.approvals.filter(a => a.graphId !== seat.graphId || a.runId !== seat.runId);
|
|
270
|
+
aggregate(current);
|
|
271
|
+
this.store.save(current);
|
|
272
|
+
debug.log('exec-requests', 'seat-status', { id, seat: seat.seat, to: 'failed', reason: target.reason });
|
|
273
|
+
}
|
|
274
|
+
debug.log('exec-requests', 'failed', { id, seat: seat.seat, reason });
|
|
275
|
+
} finally { active.delete(key); }
|
|
276
|
+
};
|
|
277
|
+
void launch();
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
} catch (error) { debug.log('exec-requests', 'failed', { id, seat: seat.seat, reason: String(error) }); }
|
|
282
|
+
}
|
|
283
|
+
const current = this.store.get(id) ?? item;
|
|
284
|
+
for (const seat of item.seats) {
|
|
285
|
+
const target = current.seats.find(candidate => candidate.runId && candidate.runId === seat.runId);
|
|
286
|
+
if (target && target.status !== 'done' && target.status !== 'failed') {
|
|
287
|
+
target.status = seat.status;
|
|
288
|
+
if (seat.reason) target.reason = seat.reason;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
const approvals = new Map(current.approvals.map(approval => [`${approval.graphId}/${approval.runId}`, approval]));
|
|
292
|
+
for (const approval of item.approvals) approvals.set(`${approval.graphId}/${approval.runId}`, approval);
|
|
293
|
+
current.approvals = [...approvals.values()].filter(approval => {
|
|
294
|
+
const seat = current.seats.find(candidate => candidate.graphId === approval.graphId && candidate.runId === approval.runId);
|
|
295
|
+
if (!seat || seat.status === 'done' || seat.status === 'failed') return false;
|
|
296
|
+
const file = join(this.root, 'graph-runs', approval.graphId, `${approval.runId}.json`);
|
|
297
|
+
try {
|
|
298
|
+
const state = JSON.parse(readFileSync(file, 'utf8')) as GraphRunState;
|
|
299
|
+
return state.status === 'awaiting-approval' && !!state.pending && !state.pending.decision
|
|
300
|
+
&& !existsSync(`${file}.${state.path.length}.decision.json`);
|
|
301
|
+
} catch { return false; }
|
|
302
|
+
});
|
|
303
|
+
for (const result of item.results) {
|
|
304
|
+
if (!current.results.some(existing => existing.url === result.url)) current.results.push(result);
|
|
305
|
+
}
|
|
306
|
+
if (item.summary && !current.summary) current.summary = item.summary;
|
|
307
|
+
aggregate(current);
|
|
308
|
+
this.store.save(current);
|
|
309
|
+
return current;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
file(id: string, name: string): string | null {
|
|
313
|
+
// Artifact names may contain spaces and Unicode; only a single safe path component is accepted.
|
|
314
|
+
if (!name || name === '.' || name === '..' || name !== basename(name) || /[\\/\x00-\x1f\x7f]/.test(name)) return null;
|
|
315
|
+
const item = this.get(id);
|
|
316
|
+
const result = item?.results.find(entry => entry.url === `/v1/exec-requests/${id}/files/${encodeURIComponent(name)}`);
|
|
317
|
+
if (!result) return null;
|
|
318
|
+
const seat = item!.seats.find(entry => name.startsWith(`${entry.runId}--`) && entry.seat === result.seat);
|
|
319
|
+
if (!seat) return null;
|
|
320
|
+
try {
|
|
321
|
+
const state = JSON.parse(readFileSync(join(this.root, 'graph-runs', seat.graphId, `${seat.runId}.json`), 'utf8')) as GraphRunState;
|
|
322
|
+
if (state.graphId !== seat.graphId || state.runId !== seat.runId) return null;
|
|
323
|
+
for (const node of state.nodes ?? []) {
|
|
324
|
+
const output = lastJsonObject(node.output);
|
|
325
|
+
if (!output) continue;
|
|
326
|
+
for (const entry of Array.isArray(output.artifacts) ? output.artifacts : [output]) {
|
|
327
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) continue;
|
|
328
|
+
const artifact = entry as Record<string, unknown>;
|
|
329
|
+
const candidate = typeof artifact.file === 'string' ? artifact.file : artifact.path;
|
|
330
|
+
if (typeof candidate !== 'string') continue;
|
|
331
|
+
const path = safeFile(candidate, this.root, seat.graphId, seat.runId);
|
|
332
|
+
if (path && fileName(path, seat.runId) === name) return path;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
} catch { return null; }
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { mkdirSync, readFileSync, readdirSync, renameSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { getElanousConfigDir } from '../elanous-config-dir.js';
|
|
5
|
+
|
|
6
|
+
export type SeatStatus = 'waiting' | 'running' | 'done' | 'failed';
|
|
7
|
+
export interface ExecSeat {
|
|
8
|
+
seat: string;
|
|
9
|
+
title: string;
|
|
10
|
+
status: SeatStatus;
|
|
11
|
+
graphId: string;
|
|
12
|
+
runId: string;
|
|
13
|
+
inputs?: Record<string, unknown>;
|
|
14
|
+
reason?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ExecResult {
|
|
17
|
+
seat: string;
|
|
18
|
+
kind: 'report' | 'pdf' | 'video' | 'image' | 'text' | 'link';
|
|
19
|
+
title: string;
|
|
20
|
+
url: string;
|
|
21
|
+
sources?: Array<{ title: string; url: string }>;
|
|
22
|
+
}
|
|
23
|
+
export interface ExecRequest {
|
|
24
|
+
id: string;
|
|
25
|
+
text: string;
|
|
26
|
+
createdAt: string;
|
|
27
|
+
status: 'planning' | 'running' | 'done' | 'failed';
|
|
28
|
+
summary: string;
|
|
29
|
+
seats: ExecSeat[];
|
|
30
|
+
results: ExecResult[];
|
|
31
|
+
approvals: Array<{ graphId: string; runId: string; message: string }>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const validId = (id: string) => /^[a-f0-9-]{36}$/.test(id);
|
|
35
|
+
|
|
36
|
+
export class ExecRequestStore {
|
|
37
|
+
readonly dir: string;
|
|
38
|
+
constructor(configDir = getElanousConfigDir()) { this.dir = join(configDir, 'exec-requests'); }
|
|
39
|
+
|
|
40
|
+
create(text: string): ExecRequest {
|
|
41
|
+
const item: ExecRequest = { id: randomUUID(), text, createdAt: new Date().toISOString(), status: 'planning', summary: '', seats: [], results: [], approvals: [] };
|
|
42
|
+
this.save(item);
|
|
43
|
+
return item;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get(id: string): ExecRequest | null {
|
|
47
|
+
if (!validId(id)) return null;
|
|
48
|
+
try {
|
|
49
|
+
const item = JSON.parse(readFileSync(join(this.dir, `${id}.json`), 'utf8')) as ExecRequest;
|
|
50
|
+
return item.id === id ? item : null;
|
|
51
|
+
} catch (error) {
|
|
52
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT') return null;
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
list(): ExecRequest[] {
|
|
58
|
+
try {
|
|
59
|
+
return readdirSync(this.dir).filter(file => /^[a-f0-9-]{36}\.json$/.test(file))
|
|
60
|
+
.flatMap(file => { const item = this.get(file.slice(0, -5)); return item ? [item] : []; })
|
|
61
|
+
.sort((a, b) => b.createdAt.localeCompare(a.createdAt) || b.id.localeCompare(a.id));
|
|
62
|
+
} catch (error) {
|
|
63
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT') return [];
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
save(item: ExecRequest): void {
|
|
69
|
+
if (!validId(item.id)) throw new Error('invalid exec request id');
|
|
70
|
+
mkdirSync(this.dir, { recursive: true, mode: 0o700 });
|
|
71
|
+
const target = join(this.dir, `${item.id}.json`);
|
|
72
|
+
const temp = join(this.dir, `${item.id}.${randomUUID()}.tmp`);
|
|
73
|
+
writeFileSync(temp, JSON.stringify(item) + '\n', { flag: 'wx', mode: 0o600 });
|
|
74
|
+
renameSync(temp, target);
|
|
75
|
+
}
|
|
76
|
+
}
|
package/src/field/field-media.ts
CHANGED
|
@@ -52,6 +52,8 @@ export interface FieldMediaInput {
|
|
|
52
52
|
bytes: Uint8Array;
|
|
53
53
|
/** 촬영 시각(ISO 문자열·epoch ms). 못 읽으면 업로드 시각. */
|
|
54
54
|
capturedAt?: string | number | Date;
|
|
55
|
+
/** 이 파일에 붙일 자막. */
|
|
56
|
+
caption?: string;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
export interface FieldSaveOptions {
|
|
@@ -178,7 +180,7 @@ export function saveFieldMedia(inputs: FieldMediaInput[], opts: FieldSaveOptions
|
|
|
178
180
|
total += size;
|
|
179
181
|
if (total > FIELD_MAX_REQUEST_BYTES) throw new FieldUploadError('too-large', 'the request exceeds 250 MB');
|
|
180
182
|
const name = `${fieldTimestamp(input.capturedAt, now)}-${opts.device}-${sanitizeFieldName(input.originalName, mime)}`;
|
|
181
|
-
return { name, bytes: input.bytes };
|
|
183
|
+
return { name, bytes: input.bytes, caption: input.caption };
|
|
182
184
|
});
|
|
183
185
|
|
|
184
186
|
mkdirSync(dir, { recursive: true });
|
|
@@ -190,8 +192,11 @@ export function saveFieldMedia(inputs: FieldMediaInput[], opts: FieldSaveOptions
|
|
|
190
192
|
atomicWrite(dir, name, item.bytes);
|
|
191
193
|
saved.push({ name, bytes: item.bytes.byteLength });
|
|
192
194
|
}
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
+
const lines = planned.flatMap((item, i) => {
|
|
196
|
+
const line = normalizeFieldCaption(item.caption ?? (i === 0 ? opts.caption : undefined));
|
|
197
|
+
return line ? [`${saved[i]!.name} | ${line}\n`] : [];
|
|
198
|
+
});
|
|
199
|
+
if (lines.length) appendFileSync(join(dir, FIELD_CAPTIONS_FILE), lines.join(''));
|
|
195
200
|
const count = refreshFieldReady(dir);
|
|
196
201
|
return { event: opts.event, dir, saved, count };
|
|
197
202
|
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
// 한 행사 폴더의 업로드 디바운스와 직렬 렌더. 프로세스 안의 폴더별 단일 실행기.
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { join, resolve } from 'node:path';
|
|
4
|
+
import { randomUUID } from 'node:crypto';
|
|
5
|
+
import { spawn, execFileSync } from 'node:child_process';
|
|
6
|
+
import { debug } from '../debug/log.js';
|
|
7
|
+
import { listFieldMedia } from './field-media.js';
|
|
8
|
+
|
|
9
|
+
export interface FieldReelResult { ok: boolean; file?: string; seconds: number; error?: string }
|
|
10
|
+
export type FieldReelRunner = (dir: string, opts: { title: string; sub: string }) => Promise<FieldReelResult>;
|
|
11
|
+
export interface FieldReelStatus {
|
|
12
|
+
state: 'waiting' | 'rendering' | 'done' | 'failed';
|
|
13
|
+
items: number;
|
|
14
|
+
updatedAt: string;
|
|
15
|
+
startedAt?: string;
|
|
16
|
+
finishedAt?: string;
|
|
17
|
+
seconds?: number;
|
|
18
|
+
file?: string;
|
|
19
|
+
error?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface FieldReelOptions {
|
|
22
|
+
quietMs?: number;
|
|
23
|
+
title?: string;
|
|
24
|
+
sub?: string;
|
|
25
|
+
runner?: FieldReelRunner;
|
|
26
|
+
onDone?: (result: FieldReelResult) => void | Promise<void>;
|
|
27
|
+
/** 같은 수신자가 앨범 항목마다 예약해도 한 렌더당 한 번만 통지한다. */
|
|
28
|
+
notificationKey?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const REEL_FILE = 'reel-9x16.mp4';
|
|
32
|
+
interface Job {
|
|
33
|
+
timer?: ReturnType<typeof setTimeout>;
|
|
34
|
+
running: boolean;
|
|
35
|
+
dirty: boolean;
|
|
36
|
+
lastUploadAt: number;
|
|
37
|
+
opts: FieldReelOptions;
|
|
38
|
+
callbacks: Map<string, NonNullable<FieldReelOptions['onDone']>>;
|
|
39
|
+
}
|
|
40
|
+
const jobs = new Map<string, Job>();
|
|
41
|
+
|
|
42
|
+
export function fieldReelFile(dir: string): string { return join(dir, 'reel', REEL_FILE); }
|
|
43
|
+
|
|
44
|
+
/** 요청 경로용 싼 검사 — 파일이 있고 비어 있지 않다. 디코딩 검사는 렌더가 끝날 때 한 번(`isValidFieldReelFile`)만 한다. */
|
|
45
|
+
export function hasFieldReelFile(file: string): boolean {
|
|
46
|
+
try {
|
|
47
|
+
const stat = statSync(file);
|
|
48
|
+
return stat.isFile() && stat.size > 0;
|
|
49
|
+
} catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Publish only a reel with a decodable video frame, not merely valid-looking MP4 boxes.
|
|
55
|
+
* 렌더 완료 때 한 번만 부른다 — 첫 영상 프레임 하나만 읽는다(`-read_intervals %+#1`) · 긴 영상도 출력이 작다. */
|
|
56
|
+
export function isValidFieldReelFile(file: string): boolean {
|
|
57
|
+
try {
|
|
58
|
+
if (!hasFieldReelFile(file)) return false;
|
|
59
|
+
const probe = JSON.parse(execFileSync('ffprobe', [
|
|
60
|
+
'-v', 'error', '-select_streams', 'v:0', '-read_intervals', '%+#1', '-show_streams', '-show_frames',
|
|
61
|
+
'-show_entries', 'stream=codec_type:frame=media_type', '-of', 'json', file,
|
|
62
|
+
], { encoding: 'utf8', timeout: 30_000, maxBuffer: 2 * 1024 * 1024, stdio: ['ignore', 'pipe', 'ignore'] })) as {
|
|
63
|
+
streams?: Array<{ codec_type?: string }>;
|
|
64
|
+
frames?: Array<{ media_type?: string }>;
|
|
65
|
+
};
|
|
66
|
+
return probe.streams?.some((stream) => stream.codec_type === 'video') === true
|
|
67
|
+
&& probe.frames?.some((frame) => frame.media_type === 'video') === true;
|
|
68
|
+
} catch {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** 상태 파일은 `reel/` «밖»에 둔다 — `reel.sh` 가 시작할 때 `reel/` 을 지우므로 안에 두면 렌더 중에 사라진다. */
|
|
73
|
+
export function fieldReelStatusPath(dir: string): string { return join(dir, '.reel-status.json'); }
|
|
74
|
+
const statusPath = fieldReelStatusPath;
|
|
75
|
+
function writeStatus(dir: string, status: Omit<FieldReelStatus, 'updatedAt'>): void {
|
|
76
|
+
mkdirSync(dir, { recursive: true });
|
|
77
|
+
const tmp = join(dir, `.reel-status-${randomUUID()}`);
|
|
78
|
+
try {
|
|
79
|
+
writeFileSync(tmp, JSON.stringify({ ...status, updatedAt: new Date().toISOString() }));
|
|
80
|
+
renameSync(tmp, statusPath(dir));
|
|
81
|
+
} finally {
|
|
82
|
+
if (existsSync(tmp)) unlinkSync(tmp);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function readFieldReelStatus(dir: string): FieldReelStatus | null {
|
|
87
|
+
try { return JSON.parse(readFileSync(statusPath(dir), 'utf8')) as FieldReelStatus; }
|
|
88
|
+
catch (err) {
|
|
89
|
+
if ((err as NodeJS.ErrnoException).code === 'ENOENT') return null;
|
|
90
|
+
throw err;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export const defaultFieldReelRunner: FieldReelRunner = (dir, { title, sub }) => new Promise((finish) => {
|
|
95
|
+
const script = resolve(import.meta.dir, '../../skills/explainer-video/engine/reel.sh');
|
|
96
|
+
const started = Date.now();
|
|
97
|
+
const child = spawn('zsh', [script, dir, '--title', title, '--sub', sub], { stdio: 'ignore' });
|
|
98
|
+
let settled = false;
|
|
99
|
+
const done = (error?: string) => {
|
|
100
|
+
if (settled) return;
|
|
101
|
+
settled = true;
|
|
102
|
+
const file = fieldReelFile(dir);
|
|
103
|
+
const seconds = Math.round((Date.now() - started) / 1000);
|
|
104
|
+
// 디코딩 검사(ffprobe)는 `render()` 한 곳에서만 한다 — 여기선 존재만 본다(리뷰: 검사 두 번 금지).
|
|
105
|
+
finish(error || !hasFieldReelFile(file)
|
|
106
|
+
? { ok: false, seconds, error: error ?? `invalid or missing MP4 output: ${file}` }
|
|
107
|
+
: { ok: true, file, seconds });
|
|
108
|
+
};
|
|
109
|
+
child.once('error', (err) => done(err.message));
|
|
110
|
+
child.once('close', (code) => done(code === 0 ? undefined : `reel.sh exited ${code ?? 'unknown'}`));
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
function arm(dir: string, job: Job): void {
|
|
114
|
+
if (job.timer) clearTimeout(job.timer);
|
|
115
|
+
job.timer = setTimeout(() => {
|
|
116
|
+
job.timer = undefined;
|
|
117
|
+
if (!job.running) void render(dir, job);
|
|
118
|
+
}, Math.max(0, (job.opts.quietMs ?? 20_000) - (Date.now() - job.lastUploadAt)));
|
|
119
|
+
job.timer.unref?.();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async function render(dir: string, job: Job): Promise<void> {
|
|
123
|
+
job.running = true;
|
|
124
|
+
job.dirty = false;
|
|
125
|
+
const items = listFieldMedia(dir).length;
|
|
126
|
+
const startedAt = new Date().toISOString();
|
|
127
|
+
const event = dir.split(/[\\/]/).at(-1)!;
|
|
128
|
+
// 현재 렌더의 수신자 스냅샷. 렌더 중 업로드의 수신자는 다음 렌더로 넘긴다.
|
|
129
|
+
const callbacks = job.callbacks;
|
|
130
|
+
const renderOpts = job.opts;
|
|
131
|
+
job.callbacks = new Map();
|
|
132
|
+
writeStatus(dir, { state: 'rendering', items, startedAt });
|
|
133
|
+
mkdirSync(join(dir, 'reel'), { recursive: true }); // 실행기 계약 — 산출 폴더는 있다(reel.sh 는 스스로 다시 만든다)
|
|
134
|
+
debug.log('field.reel', 'started', { event, items });
|
|
135
|
+
let result: FieldReelResult;
|
|
136
|
+
try {
|
|
137
|
+
const date = new Date();
|
|
138
|
+
const sub = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
|
|
139
|
+
let titleLines: string[] = [];
|
|
140
|
+
try { titleLines = readFileSync(join(dir, 'title.txt'), 'utf8').split(/\r?\n/); }
|
|
141
|
+
catch (err) { if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err; }
|
|
142
|
+
result = await (renderOpts.runner ?? defaultFieldReelRunner)(dir, {
|
|
143
|
+
title: titleLines[0]?.trim() || renderOpts.title || event,
|
|
144
|
+
sub: titleLines[1]?.trim() || renderOpts.sub || sub,
|
|
145
|
+
});
|
|
146
|
+
} catch (err) {
|
|
147
|
+
result = { ok: false, seconds: 0, error: err instanceof Error ? err.message : String(err) };
|
|
148
|
+
}
|
|
149
|
+
if (result.ok && (!result.file || resolve(result.file) !== fieldReelFile(dir) || !isValidFieldReelFile(result.file))) {
|
|
150
|
+
result = { ok: false, seconds: result.seconds, error: 'render output invalid or missing' };
|
|
151
|
+
}
|
|
152
|
+
const finishedAt = new Date().toISOString();
|
|
153
|
+
writeStatus(dir, { state: result.ok ? 'done' : 'failed', items, startedAt, finishedAt,
|
|
154
|
+
seconds: result.seconds, ...(result.ok ? { file: result.file } : { error: result.error ?? 'render failed' }) });
|
|
155
|
+
debug.log('field.reel', result.ok ? 'done' : 'failed', { event, items, seconds: result.seconds });
|
|
156
|
+
if (result.ok) {
|
|
157
|
+
// EV10b: 엔진이 timeline.json 에 남긴 비전 호출 수·성공·«현장 N» 강등·걸린 ms — codex 잔량과 겹치므로 관측한다(OP 10-01).
|
|
158
|
+
try {
|
|
159
|
+
const t = JSON.parse(readFileSync(join(dir, 'reel', 'timeline.json'), 'utf8')) as { vision?: Record<string, unknown>; music?: unknown };
|
|
160
|
+
if (t.vision) debug.log('field.reel', 'vision', { event, ...t.vision, music: t.music === true });
|
|
161
|
+
} catch { debug.log('field.reel', 'vision-unread', { event }); }
|
|
162
|
+
}
|
|
163
|
+
job.running = false;
|
|
164
|
+
if (job.dirty) {
|
|
165
|
+
writeStatus(dir, { state: 'waiting', items: listFieldMedia(dir).length });
|
|
166
|
+
arm(dir, job);
|
|
167
|
+
} else {
|
|
168
|
+
jobs.delete(dir);
|
|
169
|
+
}
|
|
170
|
+
for (const cb of callbacks.values()) {
|
|
171
|
+
void Promise.resolve().then(() => cb(result)).catch((err) => {
|
|
172
|
+
debug.log('field.reel', 'delivery-failed', { event, error: String(err) });
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** 저장 성공 직후 호출한다. quiet 기간의 연속 업로드를 합치고 렌더 중 변경은 뒤이어 다시 렌더한다. */
|
|
178
|
+
export function scheduleFieldReel(dir: string, opts: FieldReelOptions = {}): void {
|
|
179
|
+
dir = resolve(dir);
|
|
180
|
+
const event = dir.split(/[\\/]/).at(-1)!;
|
|
181
|
+
let job = jobs.get(dir);
|
|
182
|
+
if (!job) {
|
|
183
|
+
job = { running: false, dirty: false, lastUploadAt: Date.now(), opts, callbacks: new Map() };
|
|
184
|
+
jobs.set(dir, job);
|
|
185
|
+
}
|
|
186
|
+
job.opts = { ...opts, runner: opts.runner ?? job.opts.runner, quietMs: opts.quietMs ?? job.opts.quietMs };
|
|
187
|
+
job.lastUploadAt = Date.now();
|
|
188
|
+
if (opts.onDone) job.callbacks.set(opts.notificationKey ?? 'default', opts.onDone);
|
|
189
|
+
const items = listFieldMedia(dir).length;
|
|
190
|
+
if (job.running) job.dirty = true;
|
|
191
|
+
else {
|
|
192
|
+
writeStatus(dir, { state: 'waiting', items });
|
|
193
|
+
arm(dir, job);
|
|
194
|
+
}
|
|
195
|
+
debug.log('field.reel', 'scheduled', { event, items });
|
|
196
|
+
}
|
package/src/grok/credential.ts
CHANGED
|
@@ -35,11 +35,13 @@ export const GROK_SUBSCRIPTION_BASE_URL = 'https://cli-chat-proxy.grok.com/v1';
|
|
|
35
35
|
/** API 키 경로 베이스(토큰 과금). */
|
|
36
36
|
export const GROK_API_BASE_URL = 'https://api.x.ai/v1';
|
|
37
37
|
|
|
38
|
-
/** 프록시가 요구하는 최소 CLI 버전(실측 426 문면). 이보다 낮으면 거절된다.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
/** 프록시가 요구하는 최소 CLI 버전(실측 426 문면). 이보다 낮으면 거절된다.
|
|
39
|
+
* 2026-10-01 실측: «Your Grok CLI version (0.1.202) is outdated. Please update to version 1.0.13 or later». */
|
|
40
|
+
export const GROK_PROXY_MIN_CLI_VERSION = '1.0.13';
|
|
41
|
+
/** 설치본을 못 읽었을 때(grok CLI 없는 기계 · 파드) 신고할 값 — 하한이 아니라 실측된 최근 설치본.
|
|
42
|
+
* ⛔ 하한을 쓰면 프록시가 하한을 «올리는» 날 전부 426 이 된다(10-01 파드 자식이 0.1.202 로 전부 거절됨).
|
|
43
|
+
* 그래서 아래 `detectGrokCliVersion()` 이 1순위다. */
|
|
44
|
+
const GROK_PROXY_FALLBACK_CLI_VERSION = '1.0.41';
|
|
43
45
|
|
|
44
46
|
/** 설치된 grok CLI 의 버전. ⭐ 하드코딩 하한 대신 «실제 설치본»을 신고한다.
|
|
45
47
|
*
|