@jaimevalasek/aioson 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +595 -595
- package/CODE_OF_CONDUCT.md +12 -12
- package/CONTRIBUTING.md +13 -13
- package/LICENSE +661 -661
- package/README.md +919 -919
- package/bin/aioson.js +4 -4
- package/docs/design-previews/aurora-command-ui-website.html +884 -884
- package/docs/design-previews/aurora-command-ui.html +682 -682
- package/docs/design-previews/bold-editorial-ui-website.html +658 -658
- package/docs/design-previews/bold-editorial-ui.html +717 -717
- package/docs/design-previews/clean-saas-ui-website.html +1202 -1202
- package/docs/design-previews/clean-saas-ui.html +549 -549
- package/docs/design-previews/cognitive-core-ui-website.html +1009 -1009
- package/docs/design-previews/cognitive-core-ui.html +463 -463
- package/docs/design-previews/glassmorphism-ui-website.html +572 -572
- package/docs/design-previews/glassmorphism-ui.html +886 -886
- package/docs/design-previews/index.html +699 -699
- package/docs/design-previews/interface-design-website.html +1187 -1187
- package/docs/design-previews/interface-design.html +513 -513
- package/docs/design-previews/neo-brutalist-ui-website.html +621 -621
- package/docs/design-previews/neo-brutalist-ui.html +797 -797
- package/docs/design-previews/premium-command-center-ui-website.html +1217 -1217
- package/docs/design-previews/premium-command-center-ui.html +552 -552
- package/docs/design-previews/pt.squarespace.com-homepage.html +889 -889
- package/docs/design-previews/warm-craft-ui-website.html +684 -684
- package/docs/design-previews/warm-craft-ui.html +739 -739
- package/docs/en/1-understand/ecosystem-map.md +228 -0
- package/docs/en/1-understand/glossary.md +288 -0
- package/docs/en/1-understand/what-is-aioson.md +94 -0
- package/docs/en/1-understand/why-it-exists.md +106 -0
- package/docs/en/2-start/existing-project.md +246 -0
- package/docs/en/2-start/first-project.md +307 -0
- package/docs/en/2-start/initial-decisions.md +223 -0
- package/docs/en/3-recipes/README.md +28 -0
- package/docs/en/3-recipes/continuity-between-sessions.md +303 -0
- package/docs/en/3-recipes/from-idea-to-prd-via-briefing.md +235 -0
- package/docs/en/3-recipes/full-feature-with-sheldon.md +338 -0
- package/docs/en/4-agents/README.md +56 -0
- package/docs/en/5-reference/README.md +60 -0
- package/docs/en/{cli-reference.md → 5-reference/cli-reference.md} +639 -464
- package/docs/en/{i18n.md → 5-reference/i18n.md} +52 -52
- package/docs/en/{json-schemas.md → 5-reference/json-schemas.md} +41 -41
- package/docs/en/{mcp.md → 5-reference/mcp.md} +56 -56
- package/docs/en/{parallel.md → 5-reference/parallel.md} +82 -82
- package/docs/en/{qa-browser.md → 5-reference/qa-browser.md} +339 -339
- package/docs/en/{release-flow.md → 5-reference/release-flow.md} +22 -22
- package/docs/en/{release-notes-template.md → 5-reference/release-notes-template.md} +41 -41
- package/docs/en/{release.md → 5-reference/release.md} +28 -28
- package/docs/en/{schemas → 5-reference/schemas}/agent-prompt.schema.json +17 -17
- package/docs/en/{schemas → 5-reference/schemas}/agents.schema.json +32 -32
- package/docs/en/{schemas → 5-reference/schemas}/context-validate.schema.json +36 -36
- package/docs/en/{schemas → 5-reference/schemas}/doctor.schema.json +89 -89
- package/docs/en/{schemas → 5-reference/schemas}/error.schema.json +24 -24
- package/docs/en/{schemas → 5-reference/schemas}/i18n-add.schema.json +15 -15
- package/docs/en/{schemas → 5-reference/schemas}/index.json +126 -126
- package/docs/en/{schemas → 5-reference/schemas}/info.schema.json +39 -39
- package/docs/en/{schemas → 5-reference/schemas}/init.schema.json +48 -48
- package/docs/en/{schemas → 5-reference/schemas}/install.schema.json +60 -60
- package/docs/en/{schemas → 5-reference/schemas}/locale-apply.schema.json +30 -30
- package/docs/en/{schemas → 5-reference/schemas}/mcp-doctor.schema.json +95 -95
- package/docs/en/{schemas → 5-reference/schemas}/mcp-init.schema.json +122 -122
- package/docs/en/{schemas → 5-reference/schemas}/package-test.schema.json +24 -24
- package/docs/en/{schemas → 5-reference/schemas}/parallel-assign.schema.json +66 -66
- package/docs/en/{schemas → 5-reference/schemas}/parallel-doctor.schema.json +122 -122
- package/docs/en/{schemas → 5-reference/schemas}/parallel-guard.schema.json +63 -63
- package/docs/en/{schemas → 5-reference/schemas}/parallel-init.schema.json +53 -53
- package/docs/en/{schemas → 5-reference/schemas}/parallel-merge.schema.json +84 -84
- package/docs/en/{schemas → 5-reference/schemas}/parallel-status.schema.json +184 -184
- package/docs/en/{schemas → 5-reference/schemas}/setup-context.schema.json +39 -39
- package/docs/en/{schemas → 5-reference/schemas}/smoke.schema.json +23 -23
- package/docs/en/{schemas → 5-reference/schemas}/update.schema.json +48 -48
- package/docs/en/{schemas → 5-reference/schemas}/workflow-plan.schema.json +30 -30
- package/docs/en/{squad-dashboard.md → 5-reference/squad-dashboard.md} +372 -372
- package/docs/en/{web3.md → 5-reference/web3.md} +54 -54
- package/docs/en/README.md +115 -0
- package/docs/en/active-learning-loop/README.md +117 -0
- package/docs/en/active-learning-loop/active-learning-loop.md +117 -0
- package/docs/en/active-learning-loop/cli-commands.md +320 -0
- package/docs/en/active-learning-loop/diagrams.md +225 -0
- package/docs/en/active-learning-loop/doctor-checks.md +151 -0
- package/docs/en/active-learning-loop/how-to-use.md +313 -0
- package/docs/en/active-learning-loop/troubleshooting.md +283 -0
- package/docs/en/deyvin-subtask-scout/README.md +109 -0
- package/docs/en/deyvin-subtask-scout/cli-commands.md +248 -0
- package/docs/en/deyvin-subtask-scout/diagrams.md +124 -0
- package/docs/en/deyvin-subtask-scout/how-to-use.md +221 -0
- package/docs/en/deyvin-subtask-scout/sub-task-scout.md +115 -0
- package/docs/en/deyvin-subtask-scout/troubleshooting.md +184 -0
- package/docs/integrations/apps-publish-marketplace.md +94 -94
- package/docs/integrations/sdlc-genius-boundary.md +76 -76
- package/docs/integrations/sdlc-genius-eval-matrix.md +75 -75
- package/docs/integrations/sdlc-genius-install-checklist.md +93 -93
- package/docs/integrations/sdlc-genius-review-samples.md +86 -86
- package/docs/openclaw-bridge.md +308 -308
- package/docs/pt/1-entender/glossario.md +288 -0
- package/docs/pt/1-entender/mapa-do-ecossistema.md +228 -0
- package/docs/pt/1-entender/o-que-e-aioson.md +94 -0
- package/docs/pt/1-entender/por-que-existe.md +107 -0
- package/docs/pt/2-comecar/decisoes-iniciais.md +223 -0
- package/docs/pt/2-comecar/primeiro-projeto.md +307 -0
- package/docs/pt/2-comecar/projeto-existente.md +245 -0
- package/docs/pt/3-receitas/README.md +28 -0
- package/docs/pt/3-receitas/app-saas-do-zero.md +324 -0
- package/docs/pt/3-receitas/auditoria-seguranca.md +254 -0
- package/docs/pt/3-receitas/clonar-design-de-site.md +211 -0
- package/docs/pt/3-receitas/continuidade-entre-sessoes.md +303 -0
- package/docs/pt/3-receitas/da-ideia-ao-prd-via-briefing.md +234 -0
- package/docs/pt/3-receitas/feature-completa-com-sheldon.md +338 -0
- package/docs/pt/3-receitas/integracao-em-codebase-grande.md +243 -0
- package/docs/pt/3-receitas/landing-page.md +281 -0
- package/docs/pt/3-receitas/plans-externos-para-product.md +191 -0
- package/docs/pt/3-receitas/publicar-no-aioson-com.md +219 -0
- package/docs/pt/3-receitas/refatoracao-grande.md +251 -0
- package/docs/pt/4-agentes/README.md +65 -0
- package/docs/pt/4-agentes/analyst.md +111 -0
- package/docs/pt/4-agentes/architect.md +113 -0
- package/docs/pt/4-agentes/briefing.md +95 -0
- package/docs/pt/4-agentes/committer.md +108 -0
- package/docs/pt/4-agentes/copywriter.md +279 -0
- package/docs/pt/4-agentes/design-hybrid-forge.md +116 -0
- package/docs/pt/4-agentes/dev.md +136 -0
- package/docs/pt/4-agentes/deyvin.md +99 -0
- package/docs/pt/4-agentes/discover.md +122 -0
- package/docs/pt/4-agentes/discovery-design-doc.md +91 -0
- package/docs/pt/4-agentes/genome.md +115 -0
- package/docs/pt/4-agentes/neo.md +93 -0
- package/docs/pt/4-agentes/orache.md +107 -0
- package/docs/pt/4-agentes/orchestrator.md +118 -0
- package/docs/pt/4-agentes/pentester.md +131 -0
- package/docs/pt/4-agentes/pm.md +97 -0
- package/docs/pt/4-agentes/product.md +114 -0
- package/docs/pt/4-agentes/profiler-enricher.md +93 -0
- package/docs/pt/4-agentes/profiler-forge.md +93 -0
- package/docs/pt/4-agentes/profiler-researcher.md +98 -0
- package/docs/pt/4-agentes/qa.md +124 -0
- package/docs/pt/4-agentes/setup.md +104 -0
- package/docs/pt/4-agentes/sheldon.md +95 -0
- package/docs/pt/4-agentes/site-forge.md +104 -0
- package/docs/pt/4-agentes/squad.md +127 -0
- package/docs/pt/4-agentes/tester.md +105 -0
- package/docs/pt/4-agentes/ux-ui.md +110 -0
- package/docs/pt/4-agentes/validator.md +118 -0
- package/docs/pt/5-referencia/README.md +88 -0
- package/docs/pt/5-referencia/agent-chain-continuity.md +124 -0
- package/docs/pt/{agent-sharding.md → 5-referencia/agent-sharding.md} +132 -132
- package/docs/pt/5-referencia/aioson-com-store.md +119 -0
- package/docs/pt/{automacao-squads.md → 5-referencia/automacao-squads.md} +407 -407
- package/docs/pt/{clientes-ai.md → 5-referencia/clientes-ai.md} +300 -290
- package/docs/pt/{comandos-cli.md → 5-referencia/comandos-cli.md} +1823 -1781
- package/docs/pt/{compress-agents.md → 5-referencia/compress-agents.md} +304 -304
- package/docs/pt/{design-docs-governance.md → 5-referencia/design-docs-governance.md} +59 -59
- package/docs/pt/{devlog-pipeline.md → 5-referencia/devlog-pipeline.md} +270 -270
- package/docs/pt/{feature-archive.md → 5-referencia/feature-archive.md} +199 -191
- package/docs/pt/5-referencia/feature-dossier.md +121 -0
- package/docs/pt/{fluxo-artefatos.md → 5-referencia/fluxo-artefatos.md} +179 -178
- package/docs/pt/{genome-3.0-spec.md → 5-referencia/genome-4.0-spec.md} +407 -407
- package/docs/pt/{genome-distribution.md → 5-referencia/genome-distribution.md} +232 -232
- package/docs/pt/{hooks-session-guard.md → 5-referencia/hooks-session-guard.md} +454 -454
- package/docs/pt/{inteligencia-adaptativa.md → 5-referencia/inteligencia-adaptativa.md} +324 -324
- package/docs/pt/5-referencia/live-sessions.md +144 -0
- package/docs/pt/5-referencia/memoria-e-contexto.md +340 -0
- package/docs/pt/{motor-hardening.md → 5-referencia/motor-hardening.md} +493 -492
- package/docs/pt/{output-strategy-delivery.md → 5-referencia/output-strategy-delivery.md} +655 -655
- package/docs/pt/{runner-system.md → 5-referencia/runner-system.md} +113 -113
- package/docs/pt/{runtime-observability.md → 5-referencia/runtime-observability.md} +76 -76
- package/docs/pt/{sandbox.md → 5-referencia/sandbox.md} +125 -125
- package/docs/pt/{sdd-automation-scripts.md → 5-referencia/sdd-automation-scripts.md} +559 -557
- package/docs/pt/5-referencia/sdd-framework.md +115 -0
- package/docs/pt/5-referencia/sdd-planos-e-estrutura.md +321 -0
- package/docs/pt/5-referencia/secure-by-default.md +117 -0
- package/docs/pt/{skills.md → 5-referencia/skills.md} +275 -267
- package/docs/pt/{spec-learnings-pipeline.md → 5-referencia/spec-learnings-pipeline.md} +265 -265
- package/docs/pt/{squad-dashboard.md → 5-referencia/squad-dashboard.md} +373 -373
- package/docs/pt/{web3.md → 5-referencia/web3.md} +797 -797
- package/docs/pt/README.md +111 -125
- package/docs/pt/_arquivo/README.md +130 -0
- package/docs/pt/{advisor-spec.md → _arquivo/advisor-spec.md} +343 -335
- package/docs/pt/{agentes-customizados.md → _arquivo/agentes-customizados.md} +678 -670
- package/docs/pt/{busca-de-contexto.md → _arquivo/busca-de-contexto.md} +136 -129
- package/docs/pt/{cache-de-contexto.md → _arquivo/cache-de-contexto.md} +163 -156
- package/docs/pt/{cenarios.md → _arquivo/cenarios.md} +1282 -1274
- package/docs/pt/{design-hybrid-forge.md → _arquivo/design-hybrid-forge.md} +365 -356
- package/docs/pt/{deyvin.md → _arquivo/deyvin.md} +123 -115
- package/docs/pt/{guia-engineer.md → _arquivo/guia-engineer.md} +234 -226
- package/docs/pt/{inicio-rapido.md → _arquivo/inicio-rapido.md} +261 -251
- package/docs/pt/{memoria-contexto.md → _arquivo/memoria-contexto.md} +262 -255
- package/docs/pt/{monitor-de-contexto.md → _arquivo/monitor-de-contexto.md} +165 -158
- package/docs/pt/{profiler-system.md → _arquivo/profiler-system.md} +222 -214
- package/docs/pt/{recuperacao-de-sessao.md → _arquivo/recuperacao-de-sessao.md} +134 -125
- package/docs/pt/{site-forge.md → _arquivo/site-forge.md} +318 -309
- package/docs/pt/{squad-genome.md → _arquivo/squad-genome.md} +793 -783
- package/docs/pt/active-learning-loop/README.md +117 -0
- package/docs/pt/active-learning-loop/ativo-learning-loop.md +117 -0
- package/docs/pt/active-learning-loop/comandos-cli.md +320 -0
- package/docs/pt/active-learning-loop/como-usar.md +313 -0
- package/docs/pt/active-learning-loop/diagramas.md +225 -0
- package/docs/pt/active-learning-loop/doctor-checks.md +151 -0
- package/docs/pt/active-learning-loop/troubleshooting.md +283 -0
- package/docs/pt/agentes.md +996 -993
- package/docs/pt/deyvin-subtask-scout/README.md +109 -0
- package/docs/pt/deyvin-subtask-scout/comandos-cli.md +248 -0
- package/docs/pt/deyvin-subtask-scout/como-usar.md +221 -0
- package/docs/pt/deyvin-subtask-scout/diagramas.md +124 -0
- package/docs/pt/deyvin-subtask-scout/sub-task-scout.md +113 -0
- package/docs/pt/deyvin-subtask-scout/troubleshooting.md +184 -0
- package/docs/pt/living-memory/README.md +81 -0
- package/docs/pt/living-memory/autonomy-contract.md +206 -0
- package/docs/pt/living-memory/diagramas.md +365 -0
- package/docs/pt/living-memory/memoria-viva.md +141 -0
- package/docs/pt/living-memory/notificacoes-info.md +142 -0
- package/docs/pt/living-memory/reflexao-in-harness.md +218 -0
- package/docs/pt/living-memory/troubleshooting.md +286 -0
- package/docs/testing/genome-2.0-manual-regression.md +23 -23
- package/docs/testing/genome-2.0-matrix.md +36 -36
- package/docs/testing/genome-2.0-rollout.md +184 -184
- package/package.json +51 -51
- package/src/a2a/client.js +165 -165
- package/src/a2a/server.js +223 -223
- package/src/agent-loader.js +280 -280
- package/src/agent-manifests.js +86 -66
- package/src/agents.js +92 -92
- package/src/autonomy-policy.js +163 -139
- package/src/backup-local.js +74 -74
- package/src/backup-provider.js +303 -303
- package/src/brain-query.js +171 -161
- package/src/cli.js +77 -4
- package/src/commands/agent-audit.js +397 -397
- package/src/commands/agent-export-skill.js +229 -229
- package/src/commands/agent-loader.js +85 -85
- package/src/commands/agents.js +273 -255
- package/src/commands/artifact-validate.js +218 -218
- package/src/commands/auth.js +298 -272
- package/src/commands/backup-local-cmd.js +25 -25
- package/src/commands/backup.js +533 -533
- package/src/commands/brain-query.js +44 -44
- package/src/commands/brief-gen.js +405 -405
- package/src/commands/brief-validate.js +65 -65
- package/src/commands/briefing.js +344 -344
- package/src/commands/classify.js +256 -256
- package/src/commands/cloud.js +1767 -1767
- package/src/commands/commit-prepare.js +610 -547
- package/src/commands/compress-agents.js +416 -416
- package/src/commands/config.js +90 -90
- package/src/commands/context-cache.js +90 -90
- package/src/commands/context-compact.js +49 -49
- package/src/commands/context-health.js +187 -177
- package/src/commands/context-load.js +219 -0
- package/src/commands/context-monitor.js +163 -163
- package/src/commands/context-pack.js +45 -45
- package/src/commands/context-search.js +66 -66
- package/src/commands/context-trim.js +183 -183
- package/src/commands/context-validate.js +91 -91
- package/src/commands/design-hybrid-options.js +385 -385
- package/src/commands/detect-test-runner.js +55 -55
- package/src/commands/dev-resume.js +32 -0
- package/src/commands/devlog-export-brains.js +27 -27
- package/src/commands/devlog-process.js +294 -294
- package/src/commands/devlog-watch.js +131 -131
- package/src/commands/doctor.js +123 -123
- package/src/commands/dossier-add-research.js +114 -0
- package/src/commands/dossier-audit.js +222 -0
- package/src/commands/dossier.js +423 -423
- package/src/commands/feature-archive.js +513 -513
- package/src/commands/feature-close.js +554 -270
- package/src/commands/gate-approve.js +198 -198
- package/src/commands/gate-check.js +247 -247
- package/src/commands/genome-doctor.js +489 -198
- package/src/commands/genome-migrate.js +49 -49
- package/src/commands/git-guard.js +170 -170
- package/src/commands/harness.js +307 -121
- package/src/commands/health.js +214 -214
- package/src/commands/hooks-emit.js +253 -253
- package/src/commands/hooks-install.js +347 -347
- package/src/commands/i18n-add.js +56 -56
- package/src/commands/implementation-plan.js +367 -367
- package/src/commands/info.js +41 -41
- package/src/commands/init.js +120 -120
- package/src/commands/install.js +162 -111
- package/src/commands/learning-auto-promote.js +197 -195
- package/src/commands/learning-evolve.js +364 -364
- package/src/commands/learning-export.js +103 -103
- package/src/commands/learning-rollback.js +164 -164
- package/src/commands/learning.js +134 -134
- package/src/commands/live.js +2101 -2082
- package/src/commands/locale-apply.js +54 -54
- package/src/commands/locale-diff.js +25 -25
- package/src/commands/mcp-doctor.js +407 -407
- package/src/commands/mcp-init.js +373 -373
- package/src/commands/memory-archive.js +193 -0
- package/src/commands/memory-reflect-commit.js +148 -0
- package/src/commands/memory-reflect-prepare.js +97 -0
- package/src/commands/memory-restore.js +177 -0
- package/src/commands/memory-search.js +135 -0
- package/src/commands/memory.js +299 -234
- package/src/commands/notify.js +68 -0
- package/src/commands/package-e2e.js +273 -273
- package/src/commands/parallel-assign.js +483 -483
- package/src/commands/parallel-doctor.js +850 -850
- package/src/commands/parallel-guard.js +241 -241
- package/src/commands/parallel-init.js +311 -311
- package/src/commands/parallel-merge.js +299 -299
- package/src/commands/parallel-status.js +434 -434
- package/src/commands/pattern-detect.js +33 -33
- package/src/commands/preflight-context.js +30 -30
- package/src/commands/preflight.js +267 -267
- package/src/commands/pulse-update.js +130 -130
- package/src/commands/qa-doctor.js +185 -185
- package/src/commands/qa-init.js +166 -166
- package/src/commands/qa-report.js +58 -58
- package/src/commands/qa-run.js +873 -873
- package/src/commands/qa-scan.js +337 -337
- package/src/commands/recovery.js +43 -43
- package/src/commands/revision.js +235 -235
- package/src/commands/runner-daemon.js +274 -274
- package/src/commands/runner-plan.js +70 -70
- package/src/commands/runner-queue-from-plan.js +166 -166
- package/src/commands/runner-queue.js +189 -189
- package/src/commands/runner-run.js +129 -129
- package/src/commands/runtime.js +2086 -2067
- package/src/commands/sandbox.js +37 -37
- package/src/commands/scaffold-complete.js +188 -188
- package/src/commands/scan-project.js +1371 -1371
- package/src/commands/scout-commit.js +163 -0
- package/src/commands/scout-prep.js +214 -0
- package/src/commands/scout-validate.js +112 -0
- package/src/commands/security-audit.js +275 -275
- package/src/commands/security-scan.js +376 -376
- package/src/commands/self-implement-loop.js +306 -300
- package/src/commands/session-guard.js +218 -218
- package/src/commands/setup-context.js +699 -699
- package/src/commands/setup.js +178 -178
- package/src/commands/sizing.js +165 -165
- package/src/commands/skill.js +670 -670
- package/src/commands/smoke.js +426 -426
- package/src/commands/spec-checkpoint.js +177 -177
- package/src/commands/spec-status.js +79 -79
- package/src/commands/spec-sync.js +190 -190
- package/src/commands/spec-tasks.js +288 -288
- package/src/commands/squad-agent-create.js +830 -830
- package/src/commands/squad-autorun.js +1220 -1220
- package/src/commands/squad-bus.js +217 -217
- package/src/commands/squad-card.js +149 -149
- package/src/commands/squad-daemon.js +343 -343
- package/src/commands/squad-dashboard.js +39 -39
- package/src/commands/squad-dependency-graph.js +164 -164
- package/src/commands/squad-deploy.js +64 -64
- package/src/commands/squad-doctor.js +460 -460
- package/src/commands/squad-export.js +77 -46
- package/src/commands/squad-investigate.js +314 -314
- package/src/commands/squad-learning.js +209 -209
- package/src/commands/squad-mcp.js +270 -270
- package/src/commands/squad-pipeline.js +343 -343
- package/src/commands/squad-plan.js +361 -361
- package/src/commands/squad-processes.js +56 -56
- package/src/commands/squad-recovery.js +42 -42
- package/src/commands/squad-repair-genomes.js +39 -39
- package/src/commands/squad-review.js +106 -106
- package/src/commands/squad-roi.js +291 -291
- package/src/commands/squad-scaffold.js +56 -56
- package/src/commands/squad-score.js +311 -307
- package/src/commands/squad-status.js +481 -481
- package/src/commands/squad-tool-register.js +157 -157
- package/src/commands/squad-validate.js +438 -438
- package/src/commands/squad-webhook.js +160 -160
- package/src/commands/squad-worker.js +191 -191
- package/src/commands/squad-worktrees.js +75 -75
- package/src/commands/state-save.js +122 -122
- package/src/commands/store-genome.js +667 -304
- package/src/commands/store-skill.js +247 -247
- package/src/commands/store-squad.js +431 -431
- package/src/commands/store-system.js +392 -392
- package/src/commands/sync-agents-preflight.js +176 -0
- package/src/commands/test-agents.js +199 -199
- package/src/commands/tool-capabilities.js +63 -63
- package/src/commands/tool-registry-cmd.js +232 -232
- package/src/commands/update.js +64 -64
- package/src/commands/verify-gate.js +612 -612
- package/src/commands/web-map.js +70 -70
- package/src/commands/web-scrape.js +71 -71
- package/src/commands/workflow-execute.js +730 -730
- package/src/commands/workflow-harden.js +231 -231
- package/src/commands/workflow-heal.js +136 -136
- package/src/commands/workflow-next.js +1279 -1039
- package/src/commands/workflow-plan.js +108 -108
- package/src/commands/workflow-status.js +440 -440
- package/src/commands/workspace.js +144 -144
- package/src/constants.js +413 -384
- package/src/context-cache.js +159 -159
- package/src/context-memory.js +975 -966
- package/src/context-parse-reason.js +22 -22
- package/src/context-search.js +326 -326
- package/src/context-writer.js +197 -197
- package/src/context.js +247 -247
- package/src/delivery-runner.js +319 -319
- package/src/design-variation-catalog.js +503 -503
- package/src/detector.js +261 -261
- package/src/doctor.js +760 -329
- package/src/dossier/codemap-store.js +267 -267
- package/src/dossier/dossier-bootstrap.js +222 -222
- package/src/dossier/dossier-compact.js +159 -159
- package/src/dossier/lock.js +128 -128
- package/src/dossier/research-index-store.js +233 -0
- package/src/dossier/revision-store.js +313 -313
- package/src/dossier/schema.js +162 -155
- package/src/dossier/scout-section.js +127 -0
- package/src/dossier/store.js +406 -400
- package/src/execution-gateway.js +464 -464
- package/src/friction-scanner.js +202 -202
- package/src/genome-files.js +198 -198
- package/src/genome-format.js +442 -442
- package/src/genome-schema.js +238 -238
- package/src/genomes/bindings.js +281 -281
- package/src/genomes.js +500 -500
- package/src/handoff-contract.js +417 -363
- package/src/handoff-validator.js +45 -45
- package/src/harness/circuit-breaker.js +135 -135
- package/src/i18n/index.js +103 -103
- package/src/i18n/messages/en.js +1541 -1434
- package/src/i18n/messages/es.js +1325 -1221
- package/src/i18n/messages/fr.js +1333 -1229
- package/src/i18n/messages/pt-BR.js +1561 -1457
- package/src/i18n/scaffold.js +64 -64
- package/src/install-animation.js +260 -260
- package/src/install-profile.js +127 -127
- package/src/install-wizard.js +475 -475
- package/src/installer-config-merge.js +207 -0
- package/src/installer.js +449 -358
- package/src/learning-loop-archive.js +595 -0
- package/src/learning-loop-doctor.js +217 -0
- package/src/learning-loop-engine.js +254 -0
- package/src/learning-loop-fts5.js +132 -0
- package/src/learning-loop-migration.js +163 -0
- package/src/lib/dev-resume.js +140 -0
- package/src/lib/dossier-telemetry.js +36 -0
- package/src/lib/genomes/compat.js +206 -206
- package/src/lib/genomes/migrate.js +90 -90
- package/src/lib/git-commit-guard.js +751 -691
- package/src/lib/health-check.js +158 -158
- package/src/lib/hook-protocol.js +76 -76
- package/src/lib/llm-content-sanitizer.js +44 -0
- package/src/lib/security/artifact-reader.js +167 -167
- package/src/lib/security/exit-codes.js +51 -51
- package/src/lib/security/findings-writer.js +176 -176
- package/src/lib/security/runtime-events.js +77 -77
- package/src/lib/security/secrets-regex.js +115 -115
- package/src/lib/squads/genome-repair.js +49 -49
- package/src/lib/store/security-scan.js +175 -173
- package/src/lib/terminal-checkbox.js +135 -130
- package/src/lib/terminal-picker.js +447 -0
- package/src/lib/tmux-launcher.js +163 -163
- package/src/lib/tool-capabilities.js +102 -102
- package/src/lib/webhook-server.js +328 -328
- package/src/locales.js +88 -88
- package/src/mcp/apps/squad-dashboard/app.js +163 -163
- package/src/mcp/apps/squad-dashboard/index.html +261 -261
- package/src/mcp/apps/squad-dashboard/mcp-manifest.json +23 -23
- package/src/mcp/resources/squad-state.js +130 -130
- package/src/mcp-connectors/registry.js +602 -602
- package/src/memory-reflect-engine.js +359 -0
- package/src/notify-renderer.js +32 -0
- package/src/onboarding.js +305 -305
- package/src/parallel-workspace.js +756 -756
- package/src/parser.js +66 -66
- package/src/path-guard.js +47 -47
- package/src/permissions-generator.js +400 -0
- package/src/preflight-engine.js +654 -654
- package/src/prompt-tool.js +20 -20
- package/src/qa-html-report.js +472 -472
- package/src/recovery-context-session.js +154 -154
- package/src/runner/cascade.js +97 -97
- package/src/runner/cli-launcher.js +109 -109
- package/src/runner/plan-importer.js +63 -63
- package/src/runner/queue-store.js +159 -159
- package/src/runtime-store.js +2720 -2676
- package/src/sandbox.js +194 -177
- package/src/self-healing.js +142 -142
- package/src/session-handoff.js +295 -187
- package/src/squad/agent-teams-adapter.js +270 -264
- package/src/squad/brief-validator.js +350 -350
- package/src/squad/bus-bridge.js +140 -140
- package/src/squad/context-compactor.js +265 -265
- package/src/squad/cross-ai-synthesizer.js +250 -250
- package/src/squad/external-session.js +180 -180
- package/src/squad/hooks-generator.js +196 -196
- package/src/squad/inter-squad-events.js +175 -175
- package/src/squad/inter-squad.js +74 -74
- package/src/squad/intra-bus.js +345 -345
- package/src/squad/learning-extractor.js +213 -213
- package/src/squad/pattern-detector.js +365 -365
- package/src/squad/preflight-context.js +296 -296
- package/src/squad/recovery-context.js +372 -372
- package/src/squad/reflection.js +365 -365
- package/src/squad/squad-scaffold.js +341 -341
- package/src/squad/state-manager.js +310 -310
- package/src/squad/task-decomposer.js +652 -652
- package/src/squad/verify-gate.js +303 -303
- package/src/squad/worktree-manager.js +114 -114
- package/src/squad-daemon.js +490 -490
- package/src/squad-dashboard/api.js +223 -223
- package/src/squad-dashboard/attachment-handler.js +93 -93
- package/src/squad-dashboard/context-monitor.js +157 -157
- package/src/squad-dashboard/execution-logs.js +115 -115
- package/src/squad-dashboard/hunk-review.js +209 -209
- package/src/squad-dashboard/metrics.js +133 -133
- package/src/squad-dashboard/process-monitor.js +125 -125
- package/src/squad-dashboard/renderer.js +858 -858
- package/src/squad-dashboard/server.js +232 -232
- package/src/squad-dashboard/styles.js +525 -525
- package/src/squad-dashboard/token-tracker.js +99 -99
- package/src/squads/apply-genome.js +21 -21
- package/src/squads/genome-binding-service.js +154 -154
- package/src/sub-task-engine.js +415 -0
- package/src/sub-task-schemas.js +150 -0
- package/src/sub-task-state.js +152 -0
- package/src/sub-task-telemetry.js +69 -0
- package/src/test-briefing.js +226 -226
- package/src/tool-executor.js +94 -94
- package/src/updater.js +39 -39
- package/src/utils.js +49 -49
- package/src/version.js +50 -50
- package/src/web.js +284 -284
- package/src/worker-runner.js +541 -524
- package/src/workflow-gates.js +185 -185
- package/template/.aioson/advisors/.gitkeep +1 -1
- package/template/.aioson/agents/analyst.md +333 -318
- package/template/.aioson/agents/architect.md +325 -305
- package/template/.aioson/agents/{cypher.md → briefing.md} +264 -252
- package/template/.aioson/agents/committer.md +161 -161
- package/template/.aioson/agents/copywriter.md +937 -463
- package/template/.aioson/agents/design-hybrid-forge.md +141 -141
- package/template/.aioson/agents/dev.md +295 -263
- package/template/.aioson/agents/deyvin.md +198 -87
- package/template/.aioson/agents/discover.md +235 -235
- package/template/.aioson/agents/discovery-design-doc.md +56 -29
- package/template/.aioson/agents/genome.md +1904 -364
- package/template/.aioson/agents/manifests/analyst.manifest.json +26 -26
- package/template/.aioson/agents/manifests/architect.manifest.json +23 -23
- package/template/.aioson/agents/manifests/committer.manifest.json +23 -23
- package/template/.aioson/agents/manifests/dev.manifest.json +54 -37
- package/template/.aioson/agents/manifests/deyvin.manifest.json +41 -0
- package/template/.aioson/agents/manifests/orchestrator.manifest.json +30 -30
- package/template/.aioson/agents/manifests/pentester.manifest.json +39 -39
- package/template/.aioson/agents/manifests/pm.manifest.json +26 -26
- package/template/.aioson/agents/manifests/product.manifest.json +23 -23
- package/template/.aioson/agents/manifests/qa.manifest.json +41 -25
- package/template/.aioson/agents/manifests/setup.manifest.json +20 -20
- package/template/.aioson/agents/manifests/ux-ui.manifest.json +24 -24
- package/template/.aioson/agents/neo.md +341 -231
- package/template/.aioson/agents/orache.md +430 -430
- package/template/.aioson/agents/orchestrator.md +274 -263
- package/template/.aioson/agents/pair.md +5 -5
- package/template/.aioson/agents/pentester.md +289 -235
- package/template/.aioson/agents/pm.md +141 -130
- package/template/.aioson/agents/product.md +351 -273
- package/template/.aioson/agents/profiler-enricher.md +331 -331
- package/template/.aioson/agents/profiler-forge.md +212 -212
- package/template/.aioson/agents/profiler-researcher.md +282 -282
- package/template/.aioson/agents/qa.md +432 -342
- package/template/.aioson/agents/setup.md +423 -423
- package/template/.aioson/agents/sheldon.md +259 -197
- package/template/.aioson/agents/site-forge.md +281 -281
- package/template/.aioson/agents/squad.md +160 -156
- package/template/.aioson/agents/tester.md +536 -473
- package/template/.aioson/agents/ux-ui.md +195 -162
- package/template/.aioson/agents/validator.md +101 -69
- package/template/.aioson/brains/README.md +132 -128
- package/template/.aioson/brains/_archived/.gitkeep +0 -0
- package/template/.aioson/brains/_index.json +34 -16
- package/template/.aioson/brains/dev/patterns.brain.json +79 -0
- package/template/.aioson/brains/scripts/query.js +107 -107
- package/template/.aioson/brains/sheldon/architecture-decisions.brain.json +79 -0
- package/template/.aioson/brains/site-forge/visual-patterns.brain.json +205 -205
- package/template/.aioson/config/autonomy-protocol.json +125 -43
- package/template/.aioson/config/learning-loop.json +10 -0
- package/template/.aioson/config/scout-engine.json +1 -0
- package/template/.aioson/config.md +410 -410
- package/template/.aioson/context/_archived/.gitkeep +0 -0
- package/template/.aioson/context/design-doc.md +136 -136
- package/template/.aioson/context/project-map.md +57 -57
- package/template/.aioson/context/project-pulse.md +34 -34
- package/template/.aioson/context/seeds/seed-example.md +27 -27
- package/template/.aioson/context/spec.md.template +54 -54
- package/template/.aioson/context/user-profile.md +42 -42
- package/template/.aioson/design-docs/code-reuse.md +48 -48
- package/template/.aioson/design-docs/componentization.md +47 -47
- package/template/.aioson/design-docs/file-size.md +52 -52
- package/template/.aioson/design-docs/folder-structure.md +51 -51
- package/template/.aioson/design-docs/naming.md +54 -54
- package/template/.aioson/docs/LAYERS.md +89 -89
- package/template/.aioson/docs/README.md +76 -76
- package/template/.aioson/docs/autonomy-protocol.md +80 -0
- package/template/.aioson/docs/briefing/briefing-craft.md +237 -0
- package/template/.aioson/docs/dev/execution-discipline.md +106 -106
- package/template/.aioson/docs/dev/stack-conventions.md +83 -83
- package/template/.aioson/docs/deyvin/continuity-recovery.md +57 -57
- package/template/.aioson/docs/deyvin/debugging-escalation.md +30 -30
- package/template/.aioson/docs/deyvin/pair-execution.md +44 -44
- package/template/.aioson/docs/deyvin/runtime-handoffs.md +36 -36
- package/template/.aioson/docs/example-external-api-context.md +72 -72
- package/template/.aioson/docs/pentester/app-playbooks.md +206 -0
- package/template/.aioson/docs/pentester/llm-supplychain.md +165 -0
- package/template/.aioson/docs/product/conversation-playbook.md +116 -116
- package/template/.aioson/docs/product/prd-contract.md +107 -107
- package/template/.aioson/docs/product/quality-lens.md +57 -57
- package/template/.aioson/docs/product/research-loop.md +65 -65
- package/template/.aioson/docs/sheldon/enrichment-paths.md +134 -134
- package/template/.aioson/docs/sheldon/harness-contract.md +118 -0
- package/template/.aioson/docs/sheldon/quality-lens.md +57 -57
- package/template/.aioson/docs/sheldon/research-loop.md +56 -56
- package/template/.aioson/docs/sheldon/web-intelligence.md +75 -75
- package/template/.aioson/docs/site-forge-build.md +195 -195
- package/template/.aioson/docs/site-forge-extraction.md +135 -135
- package/template/.aioson/docs/site-forge-qa.md +155 -155
- package/template/.aioson/docs/site-forge-recon.md +434 -434
- package/template/.aioson/docs/site-forge-transform.md +249 -249
- package/template/.aioson/docs/squad/content-output.md +91 -91
- package/template/.aioson/docs/squad/creation-flow.md +149 -135
- package/template/.aioson/docs/squad/domain-breadth.md +322 -0
- package/template/.aioson/docs/squad/domain-classification.md +117 -117
- package/template/.aioson/docs/squad/genome-bindings.md +47 -47
- package/template/.aioson/docs/squad/package-contract.md +260 -234
- package/template/.aioson/docs/squad/quality-lens.md +60 -56
- package/template/.aioson/docs/squad/research-loop.md +59 -59
- package/template/.aioson/docs/squad/session-operations.md +117 -117
- package/template/.aioson/docs/squad/workflow-quality.md +165 -165
- package/template/.aioson/docs/tester/coverage-quality.md +351 -0
- package/template/.aioson/docs/ux-ui/accessibility-audit.md +55 -55
- package/template/.aioson/docs/ux-ui/audit-mode.md +86 -86
- package/template/.aioson/docs/ux-ui/component-map.md +35 -35
- package/template/.aioson/docs/ux-ui/design-execution.md +111 -111
- package/template/.aioson/docs/ux-ui/design-gate.md +27 -27
- package/template/.aioson/docs/ux-ui/research-mode.md +39 -39
- package/template/.aioson/docs/ux-ui/site-delivery.md +156 -156
- package/template/.aioson/docs/ux-ui/token-contract.md +57 -57
- package/template/.aioson/genomes/INDEX.md +195 -0
- package/template/.aioson/genomes/copywriting/SKILL.md +137 -0
- package/template/.aioson/genomes/copywriting/manifest.json +140 -0
- package/template/.aioson/genomes/copywriting/references/application-notes.md +145 -0
- package/template/.aioson/genomes/copywriting/references/decision-weights.md +45 -0
- package/template/.aioson/genomes/copywriting/references/frameworks/5-act-narrative.md +184 -0
- package/template/.aioson/genomes/copywriting/references/frameworks/classical-formulas.md +164 -0
- package/template/.aioson/genomes/copywriting/references/frameworks/offer-stack.md +195 -0
- package/template/.aioson/genomes/copywriting/references/frameworks/one-belief.md +135 -0
- package/template/.aioson/genomes/copywriting/references/frameworks/pms-research.md +211 -0
- package/template/.aioson/genomes/copywriting/references/frameworks/two-paths-close.md +190 -0
- package/template/.aioson/genomes/copywriting/references/heuristics.md +114 -0
- package/template/.aioson/genomes/copywriting/references/meta-axioms.md +68 -0
- package/template/.aioson/genomes/copywriting/references/methodology.md +115 -0
- package/template/.aioson/genomes/copywriting-brunson/SKILL.md +133 -0
- package/template/.aioson/genomes/copywriting-brunson/manifest.json +152 -0
- package/template/.aioson/genomes/copywriting-brunson/references/application-notes.md +113 -0
- package/template/.aioson/genomes/copywriting-brunson/references/decision-weights.md +33 -0
- package/template/.aioson/genomes/copywriting-brunson/references/evidence-and-attribution.md +81 -0
- package/template/.aioson/genomes/copywriting-brunson/references/frameworks/6-part-structure.md +136 -0
- package/template/.aioson/genomes/copywriting-brunson/references/frameworks/origin-story.md +121 -0
- package/template/.aioson/genomes/copywriting-brunson/references/frameworks/perfect-webinar-script.md +139 -0
- package/template/.aioson/genomes/copywriting-brunson/references/frameworks/persuasive-storytelling-5-structures.md +164 -0
- package/template/.aioson/genomes/copywriting-brunson/references/frameworks/value-stack.md +136 -0
- package/template/.aioson/genomes/copywriting-brunson/references/frameworks/who-what-why-how.md +110 -0
- package/template/.aioson/genomes/copywriting-brunson/references/meta-axioms.md +36 -0
- package/template/.aioson/genomes/copywriting-brunson/references/methodology.md +112 -0
- package/template/.aioson/git-guard.json +12 -11
- package/template/.aioson/mcp/servers.md +23 -23
- package/template/.aioson/profiler-reports/.gitkeep +1 -1
- package/template/.aioson/rules/README.md +69 -69
- package/template/.aioson/rules/_archived/.gitkeep +0 -0
- package/template/.aioson/rules/agent-language-policy.md +93 -93
- package/template/.aioson/rules/aioson-context-boundary.md +63 -63
- package/template/.aioson/rules/canonical-path-contract.md +47 -47
- package/template/.aioson/rules/data-format-convention.md +74 -74
- package/template/.aioson/rules/disk-first-artifacts.md +44 -44
- package/template/.aioson/rules/example-monetary-values.md +30 -30
- package/template/.aioson/rules/output-brevity.md +44 -44
- package/template/.aioson/rules/prd-section-ownership.md +49 -49
- package/template/.aioson/rules/security-baseline.md +139 -139
- package/template/.aioson/rules/spec-level-ownership.md +61 -61
- package/template/.aioson/rules/squad/README.md +50 -50
- package/template/.aioson/rules/squad-driver-pattern.md +81 -81
- package/template/.aioson/schemas/content-blueprint.schema.json +30 -30
- package/template/.aioson/schemas/genome-meta.schema.json +150 -150
- package/template/.aioson/schemas/genome.schema.json +115 -115
- package/template/.aioson/schemas/readiness.schema.json +27 -27
- package/template/.aioson/schemas/squad-blueprint.schema.json +228 -228
- package/template/.aioson/schemas/squad-manifest.schema.json +874 -874
- package/template/.aioson/skills/design/aurora-command-ui/SKILL.md +243 -243
- package/template/.aioson/skills/design/aurora-command-ui/references/art-direction.md +293 -293
- package/template/.aioson/skills/design/aurora-command-ui/references/components.md +827 -827
- package/template/.aioson/skills/design/aurora-command-ui/references/dashboards.md +250 -250
- package/template/.aioson/skills/design/aurora-command-ui/references/design-tokens.md +585 -585
- package/template/.aioson/skills/design/aurora-command-ui/references/motion.md +365 -365
- package/template/.aioson/skills/design/aurora-command-ui/references/patterns.md +482 -482
- package/template/.aioson/skills/design/aurora-command-ui/references/websites.md +387 -387
- package/template/.aioson/skills/design/bold-editorial-ui/SKILL.md +205 -205
- package/template/.aioson/skills/design/bold-editorial-ui/references/art-direction.md +338 -338
- package/template/.aioson/skills/design/bold-editorial-ui/references/components.md +977 -977
- package/template/.aioson/skills/design/bold-editorial-ui/references/dashboards.md +218 -218
- package/template/.aioson/skills/design/bold-editorial-ui/references/design-tokens.md +326 -326
- package/template/.aioson/skills/design/bold-editorial-ui/references/motion.md +461 -461
- package/template/.aioson/skills/design/bold-editorial-ui/references/patterns.md +293 -293
- package/template/.aioson/skills/design/bold-editorial-ui/references/websites.md +352 -352
- package/template/.aioson/skills/design/clean-saas-ui/SKILL.md +210 -210
- package/template/.aioson/skills/design/clean-saas-ui/references/art-direction.md +319 -319
- package/template/.aioson/skills/design/clean-saas-ui/references/components.md +365 -365
- package/template/.aioson/skills/design/clean-saas-ui/references/dashboards.md +196 -196
- package/template/.aioson/skills/design/clean-saas-ui/references/design-tokens.md +244 -244
- package/template/.aioson/skills/design/clean-saas-ui/references/motion.md +235 -235
- package/template/.aioson/skills/design/clean-saas-ui/references/patterns.md +215 -215
- package/template/.aioson/skills/design/clean-saas-ui/references/websites.md +295 -295
- package/template/.aioson/skills/design/cognitive-core-ui/SKILL.md +203 -203
- package/template/.aioson/skills/design/cognitive-core-ui/references/art-direction.md +339 -339
- package/template/.aioson/skills/design/cognitive-core-ui/references/components.md +407 -407
- package/template/.aioson/skills/design/cognitive-core-ui/references/dashboards.md +272 -272
- package/template/.aioson/skills/design/cognitive-core-ui/references/design-tokens.md +524 -524
- package/template/.aioson/skills/design/cognitive-core-ui/references/motion.md +279 -279
- package/template/.aioson/skills/design/cognitive-core-ui/references/patterns.md +289 -289
- package/template/.aioson/skills/design/cognitive-core-ui/references/websites.md +437 -437
- package/template/.aioson/skills/design/glassmorphism-ui/SKILL.md +222 -222
- package/template/.aioson/skills/design/glassmorphism-ui/references/art-direction.md +159 -159
- package/template/.aioson/skills/design/glassmorphism-ui/references/components.md +498 -498
- package/template/.aioson/skills/design/glassmorphism-ui/references/dashboards.md +236 -236
- package/template/.aioson/skills/design/glassmorphism-ui/references/design-tokens.md +274 -274
- package/template/.aioson/skills/design/glassmorphism-ui/references/motion.md +355 -355
- package/template/.aioson/skills/design/glassmorphism-ui/references/patterns.md +198 -198
- package/template/.aioson/skills/design/glassmorphism-ui/references/websites.md +307 -307
- package/template/.aioson/skills/design/interface-design/SKILL.md +47 -47
- package/template/.aioson/skills/design/interface-design/references/components-and-states.md +105 -105
- package/template/.aioson/skills/design/interface-design/references/design-directions.md +101 -101
- package/template/.aioson/skills/design/interface-design/references/handoff-and-quality.md +71 -71
- package/template/.aioson/skills/design/interface-design/references/intent-and-domain.md +74 -74
- package/template/.aioson/skills/design/interface-design/references/tokens-and-depth.md +173 -173
- package/template/.aioson/skills/design/neo-brutalist-ui/SKILL.md +213 -213
- package/template/.aioson/skills/design/neo-brutalist-ui/references/art-direction.md +228 -228
- package/template/.aioson/skills/design/neo-brutalist-ui/references/components.md +855 -855
- package/template/.aioson/skills/design/neo-brutalist-ui/references/dashboards.md +334 -334
- package/template/.aioson/skills/design/neo-brutalist-ui/references/design-tokens.md +342 -342
- package/template/.aioson/skills/design/neo-brutalist-ui/references/motion.md +286 -286
- package/template/.aioson/skills/design/neo-brutalist-ui/references/patterns.md +458 -458
- package/template/.aioson/skills/design/neo-brutalist-ui/references/websites.md +723 -723
- package/template/.aioson/skills/design/premium-command-center-ui/SKILL.md +62 -62
- package/template/.aioson/skills/design/premium-command-center-ui/references/operations.md +74 -74
- package/template/.aioson/skills/design/premium-command-center-ui/references/patterns.md +116 -116
- package/template/.aioson/skills/design/premium-command-center-ui/references/validation.md +47 -47
- package/template/.aioson/skills/design/premium-command-center-ui/references/visual-system.md +215 -215
- package/template/.aioson/skills/design/pt.squarespace.com/.skill-meta.json +31 -31
- package/template/.aioson/skills/design/pt.squarespace.com/SKILL.md +66 -66
- package/template/.aioson/skills/design/pt.squarespace.com/references/components.md +368 -368
- package/template/.aioson/skills/design/pt.squarespace.com/references/design-tokens.md +150 -150
- package/template/.aioson/skills/design/pt.squarespace.com/references/motion.md +270 -270
- package/template/.aioson/skills/design/pt.squarespace.com/references/patterns.md +189 -189
- package/template/.aioson/skills/design/pt.squarespace.com/references/websites.md +165 -165
- package/template/.aioson/skills/design/warm-craft-ui/SKILL.md +209 -209
- package/template/.aioson/skills/design/warm-craft-ui/references/art-direction.md +324 -324
- package/template/.aioson/skills/design/warm-craft-ui/references/components.md +508 -508
- package/template/.aioson/skills/design/warm-craft-ui/references/dashboards.md +223 -223
- package/template/.aioson/skills/design/warm-craft-ui/references/design-tokens.md +374 -374
- package/template/.aioson/skills/design/warm-craft-ui/references/motion.md +356 -356
- package/template/.aioson/skills/design/warm-craft-ui/references/patterns.md +288 -288
- package/template/.aioson/skills/design/warm-craft-ui/references/websites.md +289 -289
- package/template/.aioson/skills/design-system/SKILL.md +92 -92
- package/template/.aioson/skills/design-system/components/SKILL.md +274 -274
- package/template/.aioson/skills/design-system/dashboards/SKILL.md +184 -184
- package/template/.aioson/skills/design-system/foundations/SKILL.md +250 -250
- package/template/.aioson/skills/design-system/motion/SKILL.md +197 -197
- package/template/.aioson/skills/design-system/patterns/SKILL.md +231 -231
- package/template/.aioson/skills/dynamic/README.md +30 -30
- package/template/.aioson/skills/dynamic/cardano-docs.md +16 -16
- package/template/.aioson/skills/dynamic/ethereum-docs.md +17 -17
- package/template/.aioson/skills/dynamic/flux-ui-docs.md +13 -13
- package/template/.aioson/skills/dynamic/laravel-docs.md +41 -41
- package/template/.aioson/skills/dynamic/npm-packages.md +16 -16
- package/template/.aioson/skills/dynamic/solana-docs.md +16 -16
- package/template/.aioson/skills/marketing/references/anti-patterns.md +254 -254
- package/template/.aioson/skills/marketing/references/cta-matrix.md +361 -0
- package/template/.aioson/skills/marketing/references/fascinations.md +192 -192
- package/template/.aioson/skills/marketing/references/five-acts.md +248 -248
- package/template/.aioson/skills/marketing/references/headline-matrix.md +358 -0
- package/template/.aioson/skills/marketing/references/market-intelligence.md +198 -198
- package/template/.aioson/skills/marketing/references/offer-structure.md +203 -203
- package/template/.aioson/skills/marketing/references/one-belief.md +149 -149
- package/template/.aioson/skills/marketing/references/patterns.md +218 -218
- package/template/.aioson/skills/marketing/references/platform-constraints.md +337 -0
- package/template/.aioson/skills/marketing/references/pms-research.md +193 -193
- package/template/.aioson/skills/marketing/vsl-craft.md +385 -385
- package/template/.aioson/skills/premium-visual-design/SKILL.md +83 -83
- package/template/.aioson/skills/premium-visual-design/components/agent-badge.md +92 -92
- package/template/.aioson/skills/premium-visual-design/components/dependency-node.md +102 -102
- package/template/.aioson/skills/premium-visual-design/components/mention-autocomplete.md +136 -136
- package/template/.aioson/skills/premium-visual-design/components/notification-center.md +136 -136
- package/template/.aioson/skills/premium-visual-design/components/review-action-bar.md +188 -188
- package/template/.aioson/skills/premium-visual-design/components/team-switcher.md +131 -131
- package/template/.aioson/skills/premium-visual-design/patterns/agent-message-thread.md +198 -198
- package/template/.aioson/skills/premium-visual-design/patterns/notification-panel.md +275 -275
- package/template/.aioson/skills/premium-visual-design/patterns/review-workflow-ui.md +234 -234
- package/template/.aioson/skills/premium-visual-design/patterns/task-dependency-graph.md +147 -147
- package/template/.aioson/skills/premium-visual-design/tokens/status-extended.md +142 -142
- package/template/.aioson/skills/process/aioson-spec-driven/SKILL.md +46 -46
- package/template/.aioson/skills/process/aioson-spec-driven/references/analyst.md +30 -30
- package/template/.aioson/skills/process/aioson-spec-driven/references/approval-gates.md +109 -109
- package/template/.aioson/skills/process/aioson-spec-driven/references/architect.md +23 -23
- package/template/.aioson/skills/process/aioson-spec-driven/references/artifact-map.md +44 -44
- package/template/.aioson/skills/process/aioson-spec-driven/references/classification-map.md +37 -37
- package/template/.aioson/skills/process/aioson-spec-driven/references/dev.md +47 -47
- package/template/.aioson/skills/process/aioson-spec-driven/references/deyvin.md +27 -27
- package/template/.aioson/skills/process/aioson-spec-driven/references/hardening-lane.md +49 -49
- package/template/.aioson/skills/process/aioson-spec-driven/references/maintenance-and-state.md +101 -101
- package/template/.aioson/skills/process/aioson-spec-driven/references/pm.md +30 -30
- package/template/.aioson/skills/process/aioson-spec-driven/references/product.md +25 -25
- package/template/.aioson/skills/process/aioson-spec-driven/references/qa.md +30 -30
- package/template/.aioson/skills/process/aioson-spec-driven/references/sheldon.md +25 -25
- package/template/.aioson/skills/process/aioson-spec-driven/references/ui-language.md +75 -75
- package/template/.aioson/skills/process/design-hybrid-forge/SKILL.md +147 -147
- package/template/.aioson/skills/process/design-hybrid-forge/references/crossover-protocol.md +221 -221
- package/template/.aioson/skills/process/design-hybrid-forge/references/naming-registry.md +88 -88
- package/template/.aioson/skills/process/design-hybrid-forge/references/output-contract.md +306 -306
- package/template/.aioson/skills/process/design-hybrid-forge/references/pair-compatibility.md +149 -149
- package/template/.aioson/skills/process/design-hybrid-forge/references/quality-gates.md +208 -208
- package/template/.aioson/skills/process/design-hybrid-forge/references/variation-library.md +125 -125
- package/template/.aioson/skills/process/secure-tdd/SKILL.md +97 -97
- package/template/.aioson/skills/process/simplify/SKILL.md +173 -173
- package/template/.aioson/skills/references/premium-command-center-ui/master-application-prompt.md +79 -79
- package/template/.aioson/skills/references/premium-command-center-ui/operational-ux-playbook.md +253 -253
- package/template/.aioson/skills/references/premium-command-center-ui/quality-validation-checklist.md +82 -82
- package/template/.aioson/skills/references/premium-command-center-ui/visual-system-and-component-patterns.md +270 -270
- package/template/.aioson/skills/squad/SKILL.md +58 -58
- package/template/.aioson/skills/squad/formats/catalog.json +15 -15
- package/template/.aioson/skills/squad/formats/content/blog-post.md +47 -47
- package/template/.aioson/skills/squad/formats/content/newsletter.md +47 -47
- package/template/.aioson/skills/squad/formats/creative/podcast-script.md +43 -43
- package/template/.aioson/skills/squad/formats/creative/video-script.md +41 -41
- package/template/.aioson/skills/squad/formats/social/instagram-feed.md +42 -42
- package/template/.aioson/skills/squad/formats/social/linkedin-post.md +42 -42
- package/template/.aioson/skills/squad/formats/social/tiktok.md +39 -39
- package/template/.aioson/skills/squad/formats/social/twitter-thread.md +39 -39
- package/template/.aioson/skills/squad/formats/social/youtube-long.md +47 -47
- package/template/.aioson/skills/squad/formats/social/youtube-shorts.md +39 -39
- package/template/.aioson/skills/squad/patterns/multi-platform-pattern.md +108 -108
- package/template/.aioson/skills/squad/patterns/persona-based-pattern.md +98 -98
- package/template/.aioson/skills/squad/patterns/pipeline-pattern.md +106 -106
- package/template/.aioson/skills/squad/patterns/review-loop-pattern.md +81 -81
- package/template/.aioson/skills/squad/references/checklist-templates.md +122 -122
- package/template/.aioson/skills/squad/references/executor-archetypes.md +123 -123
- package/template/.aioson/skills/squad/references/workflow-templates.md +169 -169
- package/template/.aioson/skills/static/context-budget-guide.md +46 -46
- package/template/.aioson/skills/static/debugging-protocol.md +42 -42
- package/template/.aioson/skills/static/django-patterns.md +342 -342
- package/template/.aioson/skills/static/fastapi-patterns.md +344 -344
- package/template/.aioson/skills/static/filament-patterns.md +267 -267
- package/template/.aioson/skills/static/flux-ui-components.md +262 -262
- package/template/.aioson/skills/static/git-conventions.md +227 -227
- package/template/.aioson/skills/static/git-worktrees.md +36 -36
- package/template/.aioson/skills/static/harness-sensors.md +74 -74
- package/template/.aioson/skills/static/harness-validate/SKILL.md +46 -46
- package/template/.aioson/skills/static/jetstream-setup.md +200 -200
- package/template/.aioson/skills/static/landing-page-deploy.md +192 -192
- package/template/.aioson/skills/static/landing-page-forge.md +730 -730
- package/template/.aioson/skills/static/laravel-conventions.md +491 -491
- package/template/.aioson/skills/static/multi-agent-patterns.md +43 -43
- package/template/.aioson/skills/static/nextjs-patterns.md +321 -321
- package/template/.aioson/skills/static/node-express-patterns.md +317 -317
- package/template/.aioson/skills/static/node-typescript-patterns.md +282 -282
- package/template/.aioson/skills/static/rails-conventions.md +307 -307
- package/template/.aioson/skills/static/react-motion-patterns.md +599 -599
- package/template/.aioson/skills/static/static-html-patterns/checklists.md +43 -43
- package/template/.aioson/skills/static/static-html-patterns/css-tokens.md +609 -609
- package/template/.aioson/skills/static/static-html-patterns/motion.md +193 -193
- package/template/.aioson/skills/static/static-html-patterns/premium.md +711 -711
- package/template/.aioson/skills/static/static-html-patterns/structure.md +209 -209
- package/template/.aioson/skills/static/static-html-patterns/utilities.md +190 -190
- package/template/.aioson/skills/static/static-html-patterns.md +80 -80
- package/template/.aioson/skills/static/tall-stack-patterns.md +286 -286
- package/template/.aioson/skills/static/threejs-patterns.md +929 -929
- package/template/.aioson/skills/static/ui-ux-modern.md +76 -76
- package/template/.aioson/skills/static/web-research-cache.md +115 -115
- package/template/.aioson/skills/static/web3-cardano-patterns.md +337 -337
- package/template/.aioson/skills/static/web3-ethereum-patterns.md +310 -310
- package/template/.aioson/skills/static/web3-security-checklist.md +284 -284
- package/template/.aioson/skills/static/web3-solana-patterns.md +324 -324
- package/template/.aioson/squads/memory.md +5 -5
- package/template/.aioson/tasks/implementation-plan.md +327 -327
- package/template/.aioson/tasks/squad-analyze.md +83 -83
- package/template/.aioson/tasks/squad-create.md +148 -148
- package/template/.aioson/tasks/squad-design.md +206 -206
- package/template/.aioson/tasks/squad-execution-plan.md +279 -279
- package/template/.aioson/tasks/squad-export.md +20 -20
- package/template/.aioson/tasks/squad-extend.md +68 -68
- package/template/.aioson/tasks/squad-investigate.md +57 -57
- package/template/.aioson/tasks/squad-learning-review.md +44 -44
- package/template/.aioson/tasks/squad-output-config.md +177 -177
- package/template/.aioson/tasks/squad-pipeline.md +122 -122
- package/template/.aioson/tasks/squad-profile.md +48 -48
- package/template/.aioson/tasks/squad-refresh.md +236 -0
- package/template/.aioson/tasks/squad-repair.md +85 -85
- package/template/.aioson/tasks/squad-review.md +61 -61
- package/template/.aioson/tasks/squad-task-decompose.md +66 -66
- package/template/.aioson/tasks/squad-validate.md +58 -58
- package/template/.aioson/templates/reflect-prompts/current-state.md +36 -0
- package/template/.aioson/templates/reflect-prompts/how-it-works.md +23 -0
- package/template/.aioson/templates/reflect-prompts/what-it-does.md +21 -0
- package/template/.aioson/templates/squads/content-basic/template.json +21 -21
- package/template/.aioson/templates/squads/digital-marketing-agency/template.json +96 -96
- package/template/.aioson/templates/squads/media-channel/template.json +24 -24
- package/template/.aioson/templates/squads/research-analysis/template.json +22 -22
- package/template/.aioson/templates/squads/software-delivery/template.json +21 -21
- package/template/.claude/commands/aioson/agent/analyst.md +5 -5
- package/template/.claude/commands/aioson/agent/architect.md +5 -5
- package/template/.claude/commands/aioson/agent/briefing.md +5 -0
- package/template/.claude/commands/aioson/agent/committer.md +5 -5
- package/template/.claude/commands/aioson/agent/copywriter.md +5 -5
- package/template/.claude/commands/aioson/agent/design-hybrid-forge.md +5 -5
- package/template/.claude/commands/aioson/agent/dev.md +5 -5
- package/template/.claude/commands/aioson/agent/deyvin.md +5 -5
- package/template/.claude/commands/aioson/agent/discover.md +5 -0
- package/template/.claude/commands/aioson/agent/discovery-design-doc.md +5 -5
- package/template/.claude/commands/aioson/agent/genome.md +5 -5
- package/template/.claude/commands/aioson/agent/neo.md +5 -5
- package/template/.claude/commands/aioson/agent/orache.md +5 -5
- package/template/.claude/commands/aioson/agent/orchestrator.md +5 -5
- package/template/.claude/commands/aioson/agent/pair.md +5 -5
- package/template/.claude/commands/aioson/agent/pentester.md +5 -0
- package/template/.claude/commands/aioson/agent/pm.md +5 -5
- package/template/.claude/commands/aioson/agent/product.md +5 -5
- package/template/.claude/commands/aioson/agent/profiler-enricher.md +5 -5
- package/template/.claude/commands/aioson/agent/profiler-forge.md +5 -5
- package/template/.claude/commands/aioson/agent/profiler-researcher.md +5 -5
- package/template/.claude/commands/aioson/agent/qa.md +5 -5
- package/template/.claude/commands/aioson/agent/setup.md +5 -5
- package/template/.claude/commands/aioson/agent/sheldon.md +5 -5
- package/template/.claude/commands/aioson/agent/site-forge.md +5 -5
- package/template/.claude/commands/aioson/agent/squad.md +5 -5
- package/template/.claude/commands/aioson/agent/tester.md +5 -5
- package/template/.claude/commands/aioson/agent/ux-ui.md +5 -5
- package/template/.claude/commands/aioson/agent/validator.md +5 -5
- package/template/.gemini/GEMINI.md +13 -13
- package/template/.gemini/commands/aios-analyst.toml +7 -7
- package/template/.gemini/commands/aios-architect.toml +8 -8
- package/template/.gemini/commands/aios-committer.toml +7 -7
- package/template/.gemini/commands/aios-copywriter.toml +7 -7
- package/template/.gemini/commands/aios-cypher.toml +7 -7
- package/template/.gemini/commands/aios-dev.toml +9 -9
- package/template/.gemini/commands/aios-deyvin.toml +7 -7
- package/template/.gemini/commands/aios-discover.toml +6 -0
- package/template/.gemini/commands/aios-discovery-design-doc.toml +7 -7
- package/template/.gemini/commands/aios-genome.toml +7 -7
- package/template/.gemini/commands/aios-neo.toml +6 -6
- package/template/.gemini/commands/aios-orache.toml +7 -7
- package/template/.gemini/commands/aios-orchestrator.toml +9 -9
- package/template/.gemini/commands/aios-pair.toml +7 -7
- package/template/.gemini/commands/aios-pm.toml +9 -9
- package/template/.gemini/commands/aios-product.toml +6 -6
- package/template/.gemini/commands/aios-qa.toml +7 -7
- package/template/.gemini/commands/aios-setup.toml +6 -6
- package/template/.gemini/commands/aios-sheldon.toml +7 -7
- package/template/.gemini/commands/aios-site-forge.toml +7 -7
- package/template/.gemini/commands/aios-squad.toml +7 -7
- package/template/.gemini/commands/aios-tester.toml +7 -7
- package/template/.gemini/commands/aios-ux-ui.toml +9 -9
- package/template/.gemini/commands/aios-validator.toml +7 -7
- package/template/AGENTS.md +184 -183
- package/template/CLAUDE.md +98 -97
- package/template/OPENCODE.md +35 -34
- package/template/aioson-models.json +40 -40
- package/template/.aioson/genomes/copywriting.md +0 -204
- package/template/.aioson/genomes/copywriting.meta.json +0 -48
- package/template/.aioson/skills/process/secure-tdd/references/nextjs.md +0 -81
- package/template/.aioson/skills/process/secure-tdd/references/node-express.md +0 -91
- package/template/.aioson/skills/process/secure-tdd/references/planned-stacks.md +0 -33
- package/template/.claude/commands/aioson/agent/cypher.md +0 -5
package/src/commands/runtime.js
CHANGED
|
@@ -1,2067 +1,2086 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const fs = require('node:fs/promises');
|
|
4
|
-
const path = require('node:path');
|
|
5
|
-
const {
|
|
6
|
-
resolveRuntimePaths,
|
|
7
|
-
openRuntimeDb,
|
|
8
|
-
runtimeStoreExists,
|
|
9
|
-
startTask,
|
|
10
|
-
updateTask,
|
|
11
|
-
startRun,
|
|
12
|
-
updateRun,
|
|
13
|
-
attachArtifact,
|
|
14
|
-
upsertContentItem,
|
|
15
|
-
getStatusSnapshot,
|
|
16
|
-
logAgentEvent,
|
|
17
|
-
appendRunEvent,
|
|
18
|
-
readAgentSession,
|
|
19
|
-
clearAgentSession
|
|
20
|
-
} = require('../runtime-store');
|
|
21
|
-
const { runAutoDelivery } = require('../delivery-runner');
|
|
22
|
-
const { writeHandoff, buildRuntimeLogHandoff } = require('../session-handoff');
|
|
23
|
-
const { backupAiosonDocs, isDocCreatingAgent } = require('../backup-local');
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (value ===
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
logger.log(`
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
absoluteJsonPath
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
.
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
.replace(
|
|
252
|
-
.replace(
|
|
253
|
-
.
|
|
254
|
-
.
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
.
|
|
261
|
-
.replace(
|
|
262
|
-
.
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
.replace(/<
|
|
275
|
-
.replace(/<[
|
|
276
|
-
.replace(
|
|
277
|
-
.
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
const
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
content.
|
|
405
|
-
content.meta?.
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
const
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
const
|
|
437
|
-
const
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
const
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
const
|
|
450
|
-
const
|
|
451
|
-
const
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
const
|
|
507
|
-
const
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
const
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
.
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
const
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
if (
|
|
526
|
-
if (
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
const
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
const
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
const
|
|
550
|
-
const
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
const
|
|
643
|
-
db
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
const
|
|
655
|
-
const
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
let
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
const
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
const
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
const
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
const
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
const
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
const
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
.
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
const
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
.
|
|
844
|
-
.
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
const
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
const
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
const
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
const
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
const
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
const
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
const
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
const
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
logger.log(t('runtime.
|
|
1004
|
-
logger.log(
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
*
|
|
1104
|
-
*
|
|
1105
|
-
*
|
|
1106
|
-
*
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
const
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
options.
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
*
|
|
1166
|
-
*
|
|
1167
|
-
* -
|
|
1168
|
-
* - If
|
|
1169
|
-
*
|
|
1170
|
-
*
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
const
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
const
|
|
1180
|
-
const
|
|
1181
|
-
const
|
|
1182
|
-
const
|
|
1183
|
-
const
|
|
1184
|
-
const
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
const
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
//
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
}
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
}
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
}
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
const
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
}
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
const
|
|
1552
|
-
const
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
}
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
const
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
}
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
}
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
const
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
*
|
|
1828
|
-
*
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
*
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
}
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
const
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
};
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
}
|
|
2042
|
-
}
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('node:fs/promises');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const {
|
|
6
|
+
resolveRuntimePaths,
|
|
7
|
+
openRuntimeDb,
|
|
8
|
+
runtimeStoreExists,
|
|
9
|
+
startTask,
|
|
10
|
+
updateTask,
|
|
11
|
+
startRun,
|
|
12
|
+
updateRun,
|
|
13
|
+
attachArtifact,
|
|
14
|
+
upsertContentItem,
|
|
15
|
+
getStatusSnapshot,
|
|
16
|
+
logAgentEvent,
|
|
17
|
+
appendRunEvent,
|
|
18
|
+
readAgentSession,
|
|
19
|
+
clearAgentSession
|
|
20
|
+
} = require('../runtime-store');
|
|
21
|
+
const { runAutoDelivery } = require('../delivery-runner');
|
|
22
|
+
const { writeHandoff, buildRuntimeLogHandoff } = require('../session-handoff');
|
|
23
|
+
const { backupAiosonDocs, isDocCreatingAgent } = require('../backup-local');
|
|
24
|
+
const { runMemoryReflectPrepare } = require('./memory-reflect-prepare');
|
|
25
|
+
|
|
26
|
+
const ALLOWED_LAYOUTS = new Set(['document', 'tabs', 'accordion', 'stack', 'mixed']);
|
|
27
|
+
const DEFAULT_TEXT_FIELDS = ['content', 'text', 'body', 'lyrics', 'markdown'];
|
|
28
|
+
|
|
29
|
+
function resolveTargetDir(args) {
|
|
30
|
+
return path.resolve(process.cwd(), args[0] || '.');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function requireOption(options, key, t) {
|
|
34
|
+
const value = options[key];
|
|
35
|
+
if (value === undefined || value === null || String(value).trim() === '') {
|
|
36
|
+
throw new Error(t('runtime.option_required', { option: `--${key}` }));
|
|
37
|
+
}
|
|
38
|
+
return String(value).trim();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function normalizeAgentHandle(value) {
|
|
42
|
+
const text = String(value || '').trim();
|
|
43
|
+
if (!text) return '';
|
|
44
|
+
return text.startsWith('@') ? text : `@${text}`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function makeDirectSessionKey(agentName) {
|
|
48
|
+
return `direct-session:${Date.now()}:${String(agentName || '').replace(/^@/, '')}`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function parseWatchSeconds(value) {
|
|
52
|
+
if (value === undefined || value === null || value === false) return null;
|
|
53
|
+
if (value === true || value === '') return 2;
|
|
54
|
+
|
|
55
|
+
const parsed = Number(value);
|
|
56
|
+
if (!Number.isFinite(parsed) || parsed <= 0) return 2;
|
|
57
|
+
return parsed;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function sleep(ms) {
|
|
61
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function collectRuntimeSessionSnapshot(db, runtimeDir, agentName, options = {}) {
|
|
65
|
+
const normalizedAgent = normalizeAgentHandle(agentName);
|
|
66
|
+
const eventLimit = Math.max(1, Math.min(Number(options.limit) || 8, 20));
|
|
67
|
+
const session = await readAgentSession(runtimeDir, normalizedAgent);
|
|
68
|
+
const activeSession = session && !session.finished ? session : null;
|
|
69
|
+
|
|
70
|
+
let run = null;
|
|
71
|
+
if (activeSession && activeSession.runKey) {
|
|
72
|
+
run = db.prepare(`
|
|
73
|
+
SELECT
|
|
74
|
+
run_key, task_key, agent_name, agent_kind, squad_slug, session_key, source,
|
|
75
|
+
title, status, summary, output_path, started_at, updated_at, finished_at
|
|
76
|
+
FROM agent_runs
|
|
77
|
+
WHERE run_key = ?
|
|
78
|
+
LIMIT 1
|
|
79
|
+
`).get(activeSession.runKey);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (!run) {
|
|
83
|
+
run = db.prepare(`
|
|
84
|
+
SELECT
|
|
85
|
+
run_key, task_key, agent_name, agent_kind, squad_slug, session_key, source,
|
|
86
|
+
title, status, summary, output_path, started_at, updated_at, finished_at
|
|
87
|
+
FROM agent_runs
|
|
88
|
+
WHERE agent_name = ?
|
|
89
|
+
ORDER BY updated_at DESC, started_at DESC
|
|
90
|
+
LIMIT 1
|
|
91
|
+
`).get(normalizedAgent);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const task = run && run.task_key
|
|
95
|
+
? db.prepare(`
|
|
96
|
+
SELECT
|
|
97
|
+
task_key, squad_slug, session_key, title, goal, status, created_by, created_at, updated_at, finished_at
|
|
98
|
+
FROM tasks
|
|
99
|
+
WHERE task_key = ?
|
|
100
|
+
LIMIT 1
|
|
101
|
+
`).get(run.task_key)
|
|
102
|
+
: null;
|
|
103
|
+
|
|
104
|
+
const recentEvents = run
|
|
105
|
+
? db.prepare(`
|
|
106
|
+
SELECT event_type, phase, status, message, created_at
|
|
107
|
+
FROM execution_events
|
|
108
|
+
WHERE run_key = ?
|
|
109
|
+
ORDER BY created_at DESC, id DESC
|
|
110
|
+
LIMIT ?
|
|
111
|
+
`).all(run.run_key, eventLimit).reverse()
|
|
112
|
+
: [];
|
|
113
|
+
|
|
114
|
+
const open = Boolean(activeSession && run && (run.status === 'running' || run.status === 'queued'));
|
|
115
|
+
const state = open ? 'open' : (run ? 'closed' : 'idle');
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
agent: normalizedAgent,
|
|
119
|
+
state,
|
|
120
|
+
open,
|
|
121
|
+
sessionKey: activeSession?.sessionKey || run?.session_key || task?.session_key || null,
|
|
122
|
+
startedAt: activeSession?.startedAt || run?.started_at || task?.created_at || null,
|
|
123
|
+
updatedAt: run?.updated_at || task?.updated_at || null,
|
|
124
|
+
session: activeSession,
|
|
125
|
+
run,
|
|
126
|
+
task,
|
|
127
|
+
recentEvents
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async function getRuntimeSessionSnapshot(targetDir, agentName, t, options = {}) {
|
|
132
|
+
const { dbPath, runtimeDir } = resolveRuntimePaths(targetDir);
|
|
133
|
+
|
|
134
|
+
if (!(await runtimeStoreExists(targetDir))) {
|
|
135
|
+
throw new Error(t('runtime.store_missing', { path: dbPath }));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const { db } = await openRuntimeDb(targetDir, { mustExist: true });
|
|
139
|
+
try {
|
|
140
|
+
const snapshot = await collectRuntimeSessionSnapshot(db, runtimeDir, agentName, options);
|
|
141
|
+
return {
|
|
142
|
+
ok: true,
|
|
143
|
+
targetDir,
|
|
144
|
+
dbPath,
|
|
145
|
+
...snapshot
|
|
146
|
+
};
|
|
147
|
+
} finally {
|
|
148
|
+
db.close();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function printRuntimeSessionSnapshot(snapshot, logger) {
|
|
153
|
+
logger.log(`Direct session: ${snapshot.agent}`);
|
|
154
|
+
logger.log(`State: ${snapshot.state}`);
|
|
155
|
+
|
|
156
|
+
if (snapshot.sessionKey) {
|
|
157
|
+
logger.log(`Session: ${snapshot.sessionKey}`);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (snapshot.task) {
|
|
161
|
+
logger.log(`Task: ${snapshot.task.task_key} | status: ${snapshot.task.status} | work: ${snapshot.task.title || '—'}`);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (snapshot.run) {
|
|
165
|
+
logger.log(`Run: ${snapshot.run.run_key} | status: ${snapshot.run.status} | work: ${snapshot.run.title || snapshot.run.summary || '—'}`);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (snapshot.startedAt) {
|
|
169
|
+
logger.log(`Started: ${snapshot.startedAt}`);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (snapshot.updatedAt) {
|
|
173
|
+
logger.log(`Updated: ${snapshot.updatedAt}`);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (snapshot.recentEvents.length === 0) {
|
|
177
|
+
logger.log('Recent events: none');
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
logger.log('Recent events:');
|
|
182
|
+
for (const event of snapshot.recentEvents) {
|
|
183
|
+
logger.log(`- ${event.created_at} | ${event.event_type} | ${event.message || '—'}`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
async function readJsonIfExists(filePath) {
|
|
188
|
+
try {
|
|
189
|
+
const raw = await fs.readFile(filePath, 'utf8');
|
|
190
|
+
return JSON.parse(raw);
|
|
191
|
+
} catch {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function maybeResolveContentPaths(targetDir, outputPath) {
|
|
197
|
+
if (!outputPath) return null;
|
|
198
|
+
|
|
199
|
+
const relative = String(outputPath).replace(/\\/g, '/').trim();
|
|
200
|
+
if (!/\/index\.html?$/i.test(relative)) return null;
|
|
201
|
+
|
|
202
|
+
const absoluteHtmlPath = path.isAbsolute(relative) ? relative : path.join(targetDir, relative);
|
|
203
|
+
const absoluteJsonPath = path.join(path.dirname(absoluteHtmlPath), 'content.json');
|
|
204
|
+
|
|
205
|
+
return {
|
|
206
|
+
relativeHtmlPath: path.isAbsolute(relative) ? path.relative(targetDir, absoluteHtmlPath).replace(/\\/g, '/') : relative,
|
|
207
|
+
relativeJsonPath: path.relative(targetDir, absoluteJsonPath).replace(/\\/g, '/'),
|
|
208
|
+
absoluteJsonPath
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function asObject(value) {
|
|
213
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : null;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function asString(value) {
|
|
217
|
+
return typeof value === 'string' ? value.trim() : '';
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function asArray(value) {
|
|
221
|
+
return Array.isArray(value) ? value : [];
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function normalizeStringArray(value) {
|
|
225
|
+
const values = Array.isArray(value)
|
|
226
|
+
? value
|
|
227
|
+
: typeof value === 'string'
|
|
228
|
+
? value.split(',')
|
|
229
|
+
: [];
|
|
230
|
+
|
|
231
|
+
return Array.from(
|
|
232
|
+
new Set(
|
|
233
|
+
values
|
|
234
|
+
.map((entry) => String(entry || '').trim())
|
|
235
|
+
.filter(Boolean)
|
|
236
|
+
)
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function parseJsonArray(value) {
|
|
241
|
+
if (!value) return [];
|
|
242
|
+
try {
|
|
243
|
+
return normalizeStringArray(JSON.parse(value));
|
|
244
|
+
} catch {
|
|
245
|
+
return [];
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function titleize(value) {
|
|
250
|
+
return String(value || '')
|
|
251
|
+
.replace(/\.[^.]+$/, '')
|
|
252
|
+
.replace(/[-_]+/g, ' ')
|
|
253
|
+
.replace(/\s+/g, ' ')
|
|
254
|
+
.trim()
|
|
255
|
+
.replace(/\b\w/g, (char) => char.toUpperCase());
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function makeContentKey(value) {
|
|
259
|
+
return String(value || 'content')
|
|
260
|
+
.toLowerCase()
|
|
261
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
262
|
+
.replace(/^-+|-+$/g, '')
|
|
263
|
+
.slice(0, 80) || `content-${Date.now()}`;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function truncateText(value, max = 12000) {
|
|
267
|
+
const text = String(value || '').trim();
|
|
268
|
+
if (text.length <= max) return text;
|
|
269
|
+
return `${text.slice(0, max).trim()}\n\n[...]`;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function stripHtml(html) {
|
|
273
|
+
return String(html || '')
|
|
274
|
+
.replace(/<script[\s\S]*?<\/script>/gi, ' ')
|
|
275
|
+
.replace(/<style[\s\S]*?<\/style>/gi, ' ')
|
|
276
|
+
.replace(/<[^>]+>/g, ' ')
|
|
277
|
+
.replace(/\s+/g, ' ')
|
|
278
|
+
.trim();
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function firstNonEmptyText(record, keys) {
|
|
282
|
+
for (const key of keys) {
|
|
283
|
+
const value = asString(record[key]);
|
|
284
|
+
if (value) return value;
|
|
285
|
+
}
|
|
286
|
+
return '';
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function normalizeSimpleContentBlocks(content) {
|
|
290
|
+
const text = firstNonEmptyText(content, DEFAULT_TEXT_FIELDS);
|
|
291
|
+
if (text) {
|
|
292
|
+
return [
|
|
293
|
+
{
|
|
294
|
+
type: 'rich-text',
|
|
295
|
+
content: truncateText(text)
|
|
296
|
+
}
|
|
297
|
+
];
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const html = asString(content.html);
|
|
301
|
+
if (html) {
|
|
302
|
+
const preview = stripHtml(html);
|
|
303
|
+
return [
|
|
304
|
+
{
|
|
305
|
+
type: 'callout',
|
|
306
|
+
title: 'Conteudo HTML indexado automaticamente',
|
|
307
|
+
content:
|
|
308
|
+
'Este item foi convertido para o indice de conteudos a partir de um arquivo HTML gerado pelo squad.'
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
type: 'rich-text',
|
|
312
|
+
content: truncateText(preview || 'Nao foi possivel extrair preview textual do HTML.')
|
|
313
|
+
}
|
|
314
|
+
];
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return [];
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function isValidBlock(value) {
|
|
321
|
+
const block = asObject(value);
|
|
322
|
+
if (!block) return false;
|
|
323
|
+
|
|
324
|
+
const type = asString(block.type);
|
|
325
|
+
if (!type) return false;
|
|
326
|
+
|
|
327
|
+
if (type === 'tabs') {
|
|
328
|
+
const items = asArray(block.items);
|
|
329
|
+
return items.every((item) => {
|
|
330
|
+
const tab = asObject(item);
|
|
331
|
+
if (!tab || !asString(tab.label)) return false;
|
|
332
|
+
return asArray(tab.blocks).every(isValidBlock);
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (type === 'accordion') {
|
|
337
|
+
const items = asArray(block.items);
|
|
338
|
+
return items.every((item) => {
|
|
339
|
+
const entry = asObject(item);
|
|
340
|
+
if (!entry || !asString(entry.title)) return false;
|
|
341
|
+
const content = asString(entry.content);
|
|
342
|
+
const nestedBlocks = asArray(entry.blocks);
|
|
343
|
+
if (!content && nestedBlocks.length === 0) return false;
|
|
344
|
+
return nestedBlocks.every(isValidBlock);
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
if (type === 'section') {
|
|
349
|
+
return asArray(block.blocks).every(isValidBlock);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
return true;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function validateContentPayload(payload) {
|
|
356
|
+
const content = asObject(payload);
|
|
357
|
+
if (!content) {
|
|
358
|
+
return { ok: false, reason: 'content.json must be an object' };
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const contentKey = asString(content.contentKey || content.content_key);
|
|
362
|
+
if (!contentKey) {
|
|
363
|
+
return { ok: false, reason: 'content.json is missing contentKey' };
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
const title = asString(content.title);
|
|
367
|
+
if (!title) {
|
|
368
|
+
return { ok: false, reason: 'content.json is missing title' };
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const contentType = asString(content.contentType || content.content_type);
|
|
372
|
+
if (!contentType) {
|
|
373
|
+
return { ok: false, reason: 'content.json is missing contentType' };
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
const layoutType = asString(content.layoutType || content.layout_type || 'document');
|
|
377
|
+
if (!ALLOWED_LAYOUTS.has(layoutType)) {
|
|
378
|
+
return { ok: false, reason: `content.json has unsupported layoutType: ${layoutType}` };
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
const blocks = asArray(content.blocks);
|
|
382
|
+
const normalizedBlocks = blocks.length > 0 ? blocks : normalizeSimpleContentBlocks(content);
|
|
383
|
+
|
|
384
|
+
if (normalizedBlocks.length === 0) {
|
|
385
|
+
return { ok: false, reason: 'content.json must include blocks or a simple text field' };
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (!normalizedBlocks.every(isValidBlock)) {
|
|
389
|
+
return { ok: false, reason: 'content.json contains invalid blocks' };
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
return {
|
|
393
|
+
ok: true,
|
|
394
|
+
normalized: {
|
|
395
|
+
...content,
|
|
396
|
+
contentKey,
|
|
397
|
+
title,
|
|
398
|
+
contentType,
|
|
399
|
+
layoutType,
|
|
400
|
+
blocks: normalizedBlocks,
|
|
401
|
+
blueprint: asString(content.blueprint || content.blueprintSlug || content.blueprint_slug),
|
|
402
|
+
usedSkills: normalizeStringArray(
|
|
403
|
+
content.usedSkills ||
|
|
404
|
+
content.used_skills ||
|
|
405
|
+
content.meta?.usedSkills ||
|
|
406
|
+
content.meta?.used_skills ||
|
|
407
|
+
[]
|
|
408
|
+
)
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
async function listFilesRecursive(rootDir) {
|
|
414
|
+
const result = [];
|
|
415
|
+
const queue = [rootDir];
|
|
416
|
+
|
|
417
|
+
while (queue.length > 0) {
|
|
418
|
+
const currentDir = queue.shift();
|
|
419
|
+
const entries = await fs.readdir(currentDir, { withFileTypes: true }).catch(() => []);
|
|
420
|
+
for (const entry of entries) {
|
|
421
|
+
const fullPath = path.join(currentDir, entry.name);
|
|
422
|
+
if (entry.isDirectory()) {
|
|
423
|
+
queue.push(fullPath);
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
if (entry.isFile()) {
|
|
427
|
+
result.push(fullPath);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return result;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
function inferSquadSlugFromOutputPath(targetDir, absolutePath) {
|
|
436
|
+
const outputRoot = path.join(targetDir, 'output');
|
|
437
|
+
const relativePath = path.relative(outputRoot, absolutePath).replace(/\\/g, '/');
|
|
438
|
+
const [slug] = relativePath.split('/');
|
|
439
|
+
return slug || '';
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function relativeContentKeyFromOutput(targetDir, absolutePath, squadSlug) {
|
|
443
|
+
const squadRoot = path.join(targetDir, 'output', squadSlug);
|
|
444
|
+
const relativeToSquad = path.relative(squadRoot, absolutePath).replace(/\\/g, '/');
|
|
445
|
+
return makeContentKey(relativeToSquad.replace(/\.[^.]+$/, ''));
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
function synthesizeContentPayload({ targetDir, absolutePath, squadSlug, rawContent }) {
|
|
449
|
+
const ext = path.extname(absolutePath).toLowerCase();
|
|
450
|
+
const relativePath = path.relative(targetDir, absolutePath).replace(/\\/g, '/');
|
|
451
|
+
const title = titleize(path.basename(absolutePath));
|
|
452
|
+
const contentKey = relativeContentKeyFromOutput(targetDir, absolutePath, squadSlug);
|
|
453
|
+
|
|
454
|
+
if (ext === '.md') {
|
|
455
|
+
return {
|
|
456
|
+
contentKey,
|
|
457
|
+
title,
|
|
458
|
+
contentType: 'text-content',
|
|
459
|
+
layoutType: 'document',
|
|
460
|
+
summary: `Conteudo indexado automaticamente de ${relativePath}.`,
|
|
461
|
+
blocks: [
|
|
462
|
+
{
|
|
463
|
+
type: 'rich-text',
|
|
464
|
+
content: truncateText(rawContent)
|
|
465
|
+
}
|
|
466
|
+
],
|
|
467
|
+
meta: {
|
|
468
|
+
autoIndexed: true,
|
|
469
|
+
sourceFormat: 'markdown',
|
|
470
|
+
sourcePath: relativePath
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
if (ext === '.html' || ext === '.htm') {
|
|
476
|
+
const preview = stripHtml(rawContent);
|
|
477
|
+
return {
|
|
478
|
+
contentKey,
|
|
479
|
+
title,
|
|
480
|
+
contentType: 'html-content',
|
|
481
|
+
layoutType: 'document',
|
|
482
|
+
summary: `Conteudo HTML indexado automaticamente de ${relativePath}.`,
|
|
483
|
+
blocks: [
|
|
484
|
+
{
|
|
485
|
+
type: 'callout',
|
|
486
|
+
title: 'Preview indexado automaticamente',
|
|
487
|
+
content: 'O arquivo HTML original continua no output do squad. Este viewer mostra uma versao textual para indexacao e sync.'
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
type: 'rich-text',
|
|
491
|
+
content: truncateText(preview || 'Nao foi possivel gerar preview textual deste HTML.')
|
|
492
|
+
}
|
|
493
|
+
],
|
|
494
|
+
meta: {
|
|
495
|
+
autoIndexed: true,
|
|
496
|
+
sourceFormat: 'html',
|
|
497
|
+
sourcePath: relativePath
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
return null;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
async function resolveIngestCandidates(targetDir, options = {}) {
|
|
506
|
+
const outputRoot = path.join(targetDir, 'output');
|
|
507
|
+
const scopedRoot = options.squad ? path.join(outputRoot, String(options.squad).trim()) : outputRoot;
|
|
508
|
+
const rootExists = await fs.stat(scopedRoot).then((stat) => stat.isDirectory()).catch(() => false);
|
|
509
|
+
|
|
510
|
+
if (!rootExists) {
|
|
511
|
+
return [];
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
const allFiles = await listFilesRecursive(scopedRoot);
|
|
515
|
+
const contentJsonDirs = new Set(
|
|
516
|
+
allFiles
|
|
517
|
+
.filter((filePath) => path.basename(filePath).toLowerCase() === 'content.json')
|
|
518
|
+
.map((filePath) => path.dirname(filePath))
|
|
519
|
+
);
|
|
520
|
+
|
|
521
|
+
return allFiles.filter((filePath) => {
|
|
522
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
523
|
+
const base = path.basename(filePath).toLowerCase();
|
|
524
|
+
|
|
525
|
+
if (base === 'content.json') return true;
|
|
526
|
+
if (ext !== '.md' && ext !== '.html' && ext !== '.htm') return false;
|
|
527
|
+
if (contentJsonDirs.has(path.dirname(filePath))) return false;
|
|
528
|
+
|
|
529
|
+
return true;
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
async function ingestContentCandidate(db, targetDir, absolutePath, options = {}) {
|
|
534
|
+
const baseName = path.basename(absolutePath).toLowerCase();
|
|
535
|
+
const relativePath = path.relative(targetDir, absolutePath).replace(/\\/g, '/');
|
|
536
|
+
const squadSlug = options.squad ? String(options.squad).trim() : inferSquadSlugFromOutputPath(targetDir, absolutePath);
|
|
537
|
+
|
|
538
|
+
if (!squadSlug) {
|
|
539
|
+
return { indexed: false, reason: 'missing_squad' };
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
if (baseName === 'content.json') {
|
|
543
|
+
const payload = await readJsonIfExists(absolutePath);
|
|
544
|
+
const validation = validateContentPayload(payload);
|
|
545
|
+
if (!validation.ok) {
|
|
546
|
+
return { indexed: false, reason: validation.reason };
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
const content = validation.normalized;
|
|
550
|
+
const siblingIndex = path.join(path.dirname(absolutePath), 'index.html');
|
|
551
|
+
const siblingHtmlExists = await fs.stat(siblingIndex).then((stat) => stat.isFile()).catch(() => false);
|
|
552
|
+
|
|
553
|
+
upsertContentItem(db, {
|
|
554
|
+
contentKey: content.contentKey,
|
|
555
|
+
taskKey: options.task || content.taskKey || content.task_key || null,
|
|
556
|
+
runKey: options.run || content.runKey || content.run_key || null,
|
|
557
|
+
squadSlug,
|
|
558
|
+
sessionKey: options.session || content.sessionKey || content.session_key || null,
|
|
559
|
+
title: content.title,
|
|
560
|
+
contentType: content.contentType,
|
|
561
|
+
layoutType: content.layoutType,
|
|
562
|
+
status: content.status || 'completed',
|
|
563
|
+
summary: content.summary || `Conteudo indexado automaticamente de ${relativePath}.`,
|
|
564
|
+
blueprintSlug: content.blueprint || null,
|
|
565
|
+
usedSkills: normalizeStringArray(options.usedSkills || content.usedSkills),
|
|
566
|
+
payload: content,
|
|
567
|
+
jsonPath: relativePath,
|
|
568
|
+
htmlPath: siblingHtmlExists
|
|
569
|
+
? path.relative(targetDir, siblingIndex).replace(/\\/g, '/')
|
|
570
|
+
: null,
|
|
571
|
+
createdByAgent: options.agent || content.createdByAgent || content.created_by_agent || null
|
|
572
|
+
});
|
|
573
|
+
|
|
574
|
+
// Fire auto-delivery if configured (non-blocking)
|
|
575
|
+
runAutoDelivery(db, {
|
|
576
|
+
projectDir: targetDir,
|
|
577
|
+
squadSlug,
|
|
578
|
+
contentKey: content.contentKey,
|
|
579
|
+
contentPayload: content
|
|
580
|
+
}).catch(() => {}); // Swallow errors — delivery failure should not break ingestion
|
|
581
|
+
|
|
582
|
+
return { indexed: true, kind: 'content-json', contentKey: content.contentKey };
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
const rawContent = await fs.readFile(absolutePath, 'utf8').catch(() => '');
|
|
586
|
+
if (!rawContent.trim()) {
|
|
587
|
+
return { indexed: false, reason: 'empty_file' };
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
const payload = synthesizeContentPayload({
|
|
591
|
+
targetDir,
|
|
592
|
+
absolutePath,
|
|
593
|
+
squadSlug,
|
|
594
|
+
rawContent
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
if (!payload) {
|
|
598
|
+
return { indexed: false, reason: 'unsupported_file' };
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
upsertContentItem(db, {
|
|
602
|
+
contentKey: payload.contentKey,
|
|
603
|
+
taskKey: options.task || null,
|
|
604
|
+
runKey: options.run || null,
|
|
605
|
+
squadSlug,
|
|
606
|
+
sessionKey: options.session || null,
|
|
607
|
+
title: payload.title,
|
|
608
|
+
contentType: payload.contentType,
|
|
609
|
+
layoutType: payload.layoutType,
|
|
610
|
+
status: 'completed',
|
|
611
|
+
summary: payload.summary,
|
|
612
|
+
blueprintSlug: payload.blueprint || null,
|
|
613
|
+
usedSkills: normalizeStringArray(options.usedSkills),
|
|
614
|
+
payload,
|
|
615
|
+
jsonPath: null,
|
|
616
|
+
htmlPath: path.extname(absolutePath).toLowerCase().startsWith('.ht')
|
|
617
|
+
? relativePath
|
|
618
|
+
: null,
|
|
619
|
+
createdByAgent: options.agent || null
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
// Fire auto-delivery if configured (non-blocking)
|
|
623
|
+
runAutoDelivery(db, {
|
|
624
|
+
projectDir: targetDir,
|
|
625
|
+
squadSlug,
|
|
626
|
+
contentKey: payload.contentKey,
|
|
627
|
+
contentPayload: payload
|
|
628
|
+
}).catch(() => {}); // Swallow errors — delivery failure should not break ingestion
|
|
629
|
+
|
|
630
|
+
return { indexed: true, kind: path.extname(absolutePath).toLowerCase(), contentKey: payload.contentKey };
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
async function withRuntimeDb(targetDir, t) {
|
|
634
|
+
const handle = await openRuntimeDb(targetDir, { mustExist: true });
|
|
635
|
+
if (!handle) {
|
|
636
|
+
throw new Error(t('runtime.store_missing', { path: resolveRuntimePaths(targetDir).dbPath }));
|
|
637
|
+
}
|
|
638
|
+
return handle;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
async function runRuntimeInit({ args, options = {}, logger, t }) {
|
|
642
|
+
const targetDir = resolveTargetDir(args);
|
|
643
|
+
const { db, dbPath, runtimeDir } = await openRuntimeDb(targetDir);
|
|
644
|
+
db.close();
|
|
645
|
+
|
|
646
|
+
if (!options.json) {
|
|
647
|
+
logger.log(t('runtime.init_ok', { path: dbPath }));
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
return { ok: true, targetDir, runtimeDir, dbPath };
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
async function runRuntimeIngest({ args, options = {}, logger, t }) {
|
|
654
|
+
const targetDir = resolveTargetDir(args);
|
|
655
|
+
const { db, dbPath } = await withRuntimeDb(targetDir, t);
|
|
656
|
+
const ingestOptions = {
|
|
657
|
+
...options,
|
|
658
|
+
usedSkills: normalizeStringArray(options['used-skills'] || options.usedSkills)
|
|
659
|
+
};
|
|
660
|
+
|
|
661
|
+
try {
|
|
662
|
+
const candidates = await resolveIngestCandidates(targetDir, ingestOptions);
|
|
663
|
+
let indexed = 0;
|
|
664
|
+
let skipped = 0;
|
|
665
|
+
const reasons = [];
|
|
666
|
+
|
|
667
|
+
for (const candidate of candidates) {
|
|
668
|
+
const result = await ingestContentCandidate(db, targetDir, candidate, ingestOptions);
|
|
669
|
+
if (result.indexed) {
|
|
670
|
+
indexed += 1;
|
|
671
|
+
continue;
|
|
672
|
+
}
|
|
673
|
+
skipped += 1;
|
|
674
|
+
if (result.reason) {
|
|
675
|
+
reasons.push(`${path.relative(targetDir, candidate).replace(/\\/g, '/')}: ${result.reason}`);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
if (!options.json) {
|
|
680
|
+
logger.log(
|
|
681
|
+
t('runtime.ingest_ok', {
|
|
682
|
+
indexed,
|
|
683
|
+
skipped,
|
|
684
|
+
path: dbPath
|
|
685
|
+
})
|
|
686
|
+
);
|
|
687
|
+
if (reasons.length > 0) {
|
|
688
|
+
for (const reason of reasons.slice(0, 10)) {
|
|
689
|
+
logger.log(`- ${reason}`);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
return {
|
|
695
|
+
ok: true,
|
|
696
|
+
targetDir,
|
|
697
|
+
dbPath,
|
|
698
|
+
indexed,
|
|
699
|
+
skipped,
|
|
700
|
+
reasons
|
|
701
|
+
};
|
|
702
|
+
} finally {
|
|
703
|
+
db.close();
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
async function runRuntimeTaskStart({ args, options = {}, logger, t }) {
|
|
708
|
+
const targetDir = resolveTargetDir(args);
|
|
709
|
+
const { db, dbPath } = await withRuntimeDb(targetDir, t);
|
|
710
|
+
|
|
711
|
+
try {
|
|
712
|
+
const taskKey = startTask(db, {
|
|
713
|
+
taskKey: options.task,
|
|
714
|
+
squadSlug: options.squad,
|
|
715
|
+
sessionKey: options.session,
|
|
716
|
+
title: requireOption(options, 'title', t),
|
|
717
|
+
goal: options.goal,
|
|
718
|
+
createdBy: options.by
|
|
719
|
+
});
|
|
720
|
+
|
|
721
|
+
if (!options.json) {
|
|
722
|
+
logger.log(t('runtime.task_start_ok', { task: taskKey, path: dbPath }));
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
return {
|
|
726
|
+
ok: true,
|
|
727
|
+
targetDir,
|
|
728
|
+
dbPath,
|
|
729
|
+
taskKey,
|
|
730
|
+
status: 'running'
|
|
731
|
+
};
|
|
732
|
+
} finally {
|
|
733
|
+
db.close();
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
async function runRuntimeStart({ args, options = {}, logger, t }) {
|
|
738
|
+
const targetDir = resolveTargetDir(args);
|
|
739
|
+
const { db, dbPath } = await withRuntimeDb(targetDir, t);
|
|
740
|
+
|
|
741
|
+
try {
|
|
742
|
+
const runKey = startRun(db, {
|
|
743
|
+
runKey: options.run,
|
|
744
|
+
taskKey: options.task,
|
|
745
|
+
agentName: requireOption(options, 'agent', t),
|
|
746
|
+
agentKind: options.kind,
|
|
747
|
+
squadSlug: options.squad,
|
|
748
|
+
sessionKey: options.session,
|
|
749
|
+
title: options.title,
|
|
750
|
+
message: options.message,
|
|
751
|
+
summary: options.summary,
|
|
752
|
+
usedSkills: normalizeStringArray(options['used-skills'] || options.usedSkills),
|
|
753
|
+
outputPath: options.output
|
|
754
|
+
});
|
|
755
|
+
|
|
756
|
+
const snapshot = getStatusSnapshot(db);
|
|
757
|
+
if (!options.json) {
|
|
758
|
+
logger.log(t('runtime.start_ok', { run: runKey, path: dbPath }));
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
return {
|
|
762
|
+
ok: true,
|
|
763
|
+
targetDir,
|
|
764
|
+
dbPath,
|
|
765
|
+
runKey,
|
|
766
|
+
status: 'running',
|
|
767
|
+
activeCount: snapshot.activeRuns.length
|
|
768
|
+
};
|
|
769
|
+
} finally {
|
|
770
|
+
db.close();
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
async function runRuntimeUpdate({ args, options = {}, logger, t }) {
|
|
775
|
+
const targetDir = resolveTargetDir(args);
|
|
776
|
+
const { db, dbPath } = await withRuntimeDb(targetDir, t);
|
|
777
|
+
|
|
778
|
+
try {
|
|
779
|
+
const runKey = requireOption(options, 'run', t);
|
|
780
|
+
const status = updateRun(db, {
|
|
781
|
+
runKey,
|
|
782
|
+
status: 'running',
|
|
783
|
+
taskKey: options.task,
|
|
784
|
+
eventType: 'progress',
|
|
785
|
+
message: options.message,
|
|
786
|
+
summary: options.summary,
|
|
787
|
+
usedSkills: normalizeStringArray(options['used-skills'] || options.usedSkills),
|
|
788
|
+
outputPath: options.output
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
if (!options.json) {
|
|
792
|
+
logger.log(t('runtime.update_ok', { run: runKey, path: dbPath }));
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
return {
|
|
796
|
+
ok: true,
|
|
797
|
+
targetDir,
|
|
798
|
+
dbPath,
|
|
799
|
+
runKey,
|
|
800
|
+
status
|
|
801
|
+
};
|
|
802
|
+
} finally {
|
|
803
|
+
db.close();
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
async function runRuntimeFinish({ args, options = {}, logger, t }) {
|
|
808
|
+
const targetDir = resolveTargetDir(args);
|
|
809
|
+
const { db, dbPath } = await withRuntimeDb(targetDir, t);
|
|
810
|
+
|
|
811
|
+
try {
|
|
812
|
+
const runKey = requireOption(options, 'run', t);
|
|
813
|
+
const status = updateRun(db, {
|
|
814
|
+
runKey,
|
|
815
|
+
status: 'completed',
|
|
816
|
+
taskKey: options.task,
|
|
817
|
+
eventType: 'finish',
|
|
818
|
+
message: options.message || options.summary || 'Run completed',
|
|
819
|
+
summary: options.summary,
|
|
820
|
+
usedSkills: normalizeStringArray(options['used-skills'] || options.usedSkills),
|
|
821
|
+
outputPath: options.output
|
|
822
|
+
});
|
|
823
|
+
|
|
824
|
+
const finishedRun = db
|
|
825
|
+
.prepare('SELECT run_key, task_key, squad_slug, session_key, agent_name, output_path, used_skills_json FROM agent_runs WHERE run_key = ?')
|
|
826
|
+
.get(runKey);
|
|
827
|
+
if (finishedRun && finishedRun.output_path) {
|
|
828
|
+
attachArtifact(db, {
|
|
829
|
+
taskKey: finishedRun.task_key,
|
|
830
|
+
runKey: finishedRun.run_key,
|
|
831
|
+
squadSlug: finishedRun.squad_slug,
|
|
832
|
+
agentName: finishedRun.agent_name,
|
|
833
|
+
filePath: finishedRun.output_path,
|
|
834
|
+
title: options.title || options.summary || 'Artifact generated'
|
|
835
|
+
});
|
|
836
|
+
|
|
837
|
+
const absoluteOutputPath = path.isAbsolute(finishedRun.output_path)
|
|
838
|
+
? finishedRun.output_path
|
|
839
|
+
: path.join(targetDir, finishedRun.output_path);
|
|
840
|
+
const contentPaths = maybeResolveContentPaths(targetDir, finishedRun.output_path);
|
|
841
|
+
const preferredCandidate = contentPaths
|
|
842
|
+
? (await fs
|
|
843
|
+
.stat(contentPaths.absoluteJsonPath)
|
|
844
|
+
.then((stat) => (stat.isFile() ? contentPaths.absoluteJsonPath : null))
|
|
845
|
+
.catch(() => null))
|
|
846
|
+
: absoluteOutputPath;
|
|
847
|
+
|
|
848
|
+
if (preferredCandidate) {
|
|
849
|
+
const ingestion = await ingestContentCandidate(db, targetDir, preferredCandidate, {
|
|
850
|
+
task: finishedRun.task_key,
|
|
851
|
+
run: finishedRun.run_key,
|
|
852
|
+
squad: finishedRun.squad_slug,
|
|
853
|
+
session: options.session || finishedRun.session_key,
|
|
854
|
+
agent: finishedRun.agent_name,
|
|
855
|
+
usedSkills: parseJsonArray(finishedRun.used_skills_json)
|
|
856
|
+
});
|
|
857
|
+
if (!ingestion.indexed && !options.json && logger?.log) {
|
|
858
|
+
logger.log(`[runtime] skipped content indexing for ${finishedRun.run_key}: ${ingestion.reason}`);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
if (!options.json) {
|
|
864
|
+
logger.log(t('runtime.finish_ok', { run: runKey, path: dbPath }));
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
return {
|
|
868
|
+
ok: true,
|
|
869
|
+
targetDir,
|
|
870
|
+
dbPath,
|
|
871
|
+
runKey,
|
|
872
|
+
status
|
|
873
|
+
};
|
|
874
|
+
} finally {
|
|
875
|
+
db.close();
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
async function runRuntimeTaskFinish({ args, options = {}, logger, t }) {
|
|
880
|
+
const targetDir = resolveTargetDir(args);
|
|
881
|
+
const { db, dbPath } = await withRuntimeDb(targetDir, t);
|
|
882
|
+
|
|
883
|
+
try {
|
|
884
|
+
const taskKey = requireOption(options, 'task', t);
|
|
885
|
+
const taskStatus = updateTask(db, {
|
|
886
|
+
taskKey,
|
|
887
|
+
status: 'completed',
|
|
888
|
+
goal: options.goal
|
|
889
|
+
});
|
|
890
|
+
|
|
891
|
+
if (!options.json) {
|
|
892
|
+
logger.log(t('runtime.task_finish_ok', { task: taskKey, path: dbPath }));
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
return {
|
|
896
|
+
ok: true,
|
|
897
|
+
targetDir,
|
|
898
|
+
dbPath,
|
|
899
|
+
taskKey,
|
|
900
|
+
status: taskStatus
|
|
901
|
+
};
|
|
902
|
+
} finally {
|
|
903
|
+
db.close();
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
async function runRuntimeFail({ args, options = {}, logger, t }) {
|
|
908
|
+
const targetDir = resolveTargetDir(args);
|
|
909
|
+
const { db, dbPath } = await withRuntimeDb(targetDir, t);
|
|
910
|
+
|
|
911
|
+
try {
|
|
912
|
+
const runKey = requireOption(options, 'run', t);
|
|
913
|
+
const status = updateRun(db, {
|
|
914
|
+
runKey,
|
|
915
|
+
taskKey: options.task,
|
|
916
|
+
status: 'failed',
|
|
917
|
+
eventType: 'fail',
|
|
918
|
+
message: options.message || options.summary || 'Run failed',
|
|
919
|
+
summary: options.summary,
|
|
920
|
+
outputPath: options.output
|
|
921
|
+
});
|
|
922
|
+
|
|
923
|
+
if (!options.json) {
|
|
924
|
+
logger.log(t('runtime.fail_ok', { run: runKey, path: dbPath }));
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
return {
|
|
928
|
+
ok: true,
|
|
929
|
+
targetDir,
|
|
930
|
+
dbPath,
|
|
931
|
+
runKey,
|
|
932
|
+
status
|
|
933
|
+
};
|
|
934
|
+
} finally {
|
|
935
|
+
db.close();
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
async function runRuntimeTaskFail({ args, options = {}, logger, t }) {
|
|
940
|
+
const targetDir = resolveTargetDir(args);
|
|
941
|
+
const { db, dbPath } = await withRuntimeDb(targetDir, t);
|
|
942
|
+
|
|
943
|
+
try {
|
|
944
|
+
const taskKey = requireOption(options, 'task', t);
|
|
945
|
+
const status = updateTask(db, {
|
|
946
|
+
taskKey,
|
|
947
|
+
status: 'failed',
|
|
948
|
+
goal: options.goal
|
|
949
|
+
});
|
|
950
|
+
|
|
951
|
+
if (!options.json) {
|
|
952
|
+
logger.log(t('runtime.task_fail_ok', { task: taskKey, path: dbPath }));
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
return {
|
|
956
|
+
ok: true,
|
|
957
|
+
targetDir,
|
|
958
|
+
dbPath,
|
|
959
|
+
taskKey,
|
|
960
|
+
status
|
|
961
|
+
};
|
|
962
|
+
} finally {
|
|
963
|
+
db.close();
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
async function runRuntimeStatus({ args, options = {}, logger, t }) {
|
|
968
|
+
const targetDir = resolveTargetDir(args);
|
|
969
|
+
const { dbPath } = resolveRuntimePaths(targetDir);
|
|
970
|
+
|
|
971
|
+
if (!(await runtimeStoreExists(targetDir))) {
|
|
972
|
+
if (options.json) {
|
|
973
|
+
return { ok: false, error: 'store_missing', dbPath };
|
|
974
|
+
}
|
|
975
|
+
throw new Error(t('runtime.store_missing', { path: dbPath }));
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
const { db } = await openRuntimeDb(targetDir, { mustExist: true });
|
|
979
|
+
|
|
980
|
+
try {
|
|
981
|
+
const snapshot = getStatusSnapshot(db);
|
|
982
|
+
const payload = {
|
|
983
|
+
ok: true,
|
|
984
|
+
targetDir,
|
|
985
|
+
dbPath,
|
|
986
|
+
taskCounts: snapshot.taskCounts,
|
|
987
|
+
counts: snapshot.counts,
|
|
988
|
+
activeTasks: snapshot.activeTasks,
|
|
989
|
+
recentTasks: snapshot.recentTasks,
|
|
990
|
+
activeRuns: snapshot.activeRuns,
|
|
991
|
+
recentRuns: snapshot.recentRuns,
|
|
992
|
+
activeLiveSessions: snapshot.activeLiveSessions,
|
|
993
|
+
activeMicroTasks: snapshot.activeMicroTasks,
|
|
994
|
+
recentLiveSessions: snapshot.recentLiveSessions,
|
|
995
|
+
recentMicroTasks: snapshot.recentMicroTasks,
|
|
996
|
+
recentHandoffs: snapshot.recentHandoffs,
|
|
997
|
+
recentArtifacts: snapshot.recentArtifacts,
|
|
998
|
+
recentContentItems: snapshot.recentContentItems,
|
|
999
|
+
recentExecutionEvents: snapshot.recentExecutionEvents
|
|
1000
|
+
};
|
|
1001
|
+
|
|
1002
|
+
if (!options.json) {
|
|
1003
|
+
logger.log(t('runtime.status_title', { path: targetDir }));
|
|
1004
|
+
logger.log(t('runtime.status_db', { path: dbPath }));
|
|
1005
|
+
logger.log(
|
|
1006
|
+
t('runtime.status_task_counts', {
|
|
1007
|
+
queued: payload.taskCounts.queued,
|
|
1008
|
+
running: payload.taskCounts.running,
|
|
1009
|
+
completed: payload.taskCounts.completed,
|
|
1010
|
+
failed: payload.taskCounts.failed
|
|
1011
|
+
})
|
|
1012
|
+
);
|
|
1013
|
+
logger.log(
|
|
1014
|
+
t('runtime.status_counts', {
|
|
1015
|
+
queued: payload.counts.queued,
|
|
1016
|
+
running: payload.counts.running,
|
|
1017
|
+
completed: payload.counts.completed,
|
|
1018
|
+
failed: payload.counts.failed
|
|
1019
|
+
})
|
|
1020
|
+
);
|
|
1021
|
+
if (snapshot.activeTasks.length === 0) {
|
|
1022
|
+
logger.log(t('runtime.status_no_active_tasks'));
|
|
1023
|
+
} else {
|
|
1024
|
+
logger.log(t('runtime.status_active_tasks_title'));
|
|
1025
|
+
for (const task of snapshot.activeTasks) {
|
|
1026
|
+
logger.log(
|
|
1027
|
+
t('runtime.status_active_task_line', {
|
|
1028
|
+
task: task.task_key,
|
|
1029
|
+
squad: task.squad_slug || '—',
|
|
1030
|
+
status: task.status,
|
|
1031
|
+
title: task.title
|
|
1032
|
+
})
|
|
1033
|
+
);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
if (snapshot.activeRuns.length === 0) {
|
|
1037
|
+
logger.log(t('runtime.status_no_active'));
|
|
1038
|
+
} else {
|
|
1039
|
+
logger.log(t('runtime.status_active_title'));
|
|
1040
|
+
for (const run of snapshot.activeRuns) {
|
|
1041
|
+
logger.log(
|
|
1042
|
+
t('runtime.status_active_line', {
|
|
1043
|
+
agent: run.agent_name,
|
|
1044
|
+
squad: run.squad_slug || '—',
|
|
1045
|
+
status: run.status,
|
|
1046
|
+
title: run.title || run.summary || '—'
|
|
1047
|
+
})
|
|
1048
|
+
);
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
if (snapshot.activeLiveSessions.length > 0) {
|
|
1052
|
+
logger.log(t('runtime.status_live_sessions_title'));
|
|
1053
|
+
for (const task of snapshot.activeLiveSessions) {
|
|
1054
|
+
logger.log(
|
|
1055
|
+
t('runtime.status_live_session_line', {
|
|
1056
|
+
task: task.task_key,
|
|
1057
|
+
agent: task.latest_agent_name || task.created_by || '—',
|
|
1058
|
+
status: task.status,
|
|
1059
|
+
plan: task.plan_steps_total > 0 ? `${task.plan_steps_done}/${task.plan_steps_total}` : '—',
|
|
1060
|
+
micro: `${task.completed_child_task_count || 0}/${task.child_task_count || 0}`,
|
|
1061
|
+
handoffs: task.handoff_count || 0,
|
|
1062
|
+
title: task.title || '—'
|
|
1063
|
+
})
|
|
1064
|
+
);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
if (snapshot.activeMicroTasks.length > 0) {
|
|
1068
|
+
logger.log(t('runtime.status_micro_tasks_title'));
|
|
1069
|
+
for (const task of snapshot.activeMicroTasks) {
|
|
1070
|
+
logger.log(
|
|
1071
|
+
t('runtime.status_micro_task_line', {
|
|
1072
|
+
task: task.task_key,
|
|
1073
|
+
parent: task.parent_task_key || '—',
|
|
1074
|
+
status: task.status,
|
|
1075
|
+
title: task.title || task.goal || '—'
|
|
1076
|
+
})
|
|
1077
|
+
);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
if (snapshot.recentHandoffs.length > 0) {
|
|
1081
|
+
logger.log(t('runtime.status_handoffs_title'));
|
|
1082
|
+
for (const event of snapshot.recentHandoffs.slice(0, 5)) {
|
|
1083
|
+
logger.log(
|
|
1084
|
+
t('runtime.status_handoff_line', {
|
|
1085
|
+
created: event.created_at,
|
|
1086
|
+
from: event.handoff_from || event.agent_name || '—',
|
|
1087
|
+
to: event.handoff_to || '—',
|
|
1088
|
+
session: event.session_key || '—',
|
|
1089
|
+
message: event.message || '—'
|
|
1090
|
+
})
|
|
1091
|
+
);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
return payload;
|
|
1097
|
+
} finally {
|
|
1098
|
+
db.close();
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
/**
|
|
1103
|
+
* aioson runtime-log --agent=<name> --message=<text> [--type=<event>] [--finish] [--status=completed|failed] [--summary=<text>] [--title=<task-title>]
|
|
1104
|
+
*
|
|
1105
|
+
* Stateful single-command logger for official AIOSON agents.
|
|
1106
|
+
* First call creates task + run in SQLite; subsequent calls add events.
|
|
1107
|
+
* --finish closes the run and clears the session.
|
|
1108
|
+
*/
|
|
1109
|
+
async function runRuntimeLog({ args, options = {}, logger, t }) {
|
|
1110
|
+
const targetDir = resolveTargetDir(args);
|
|
1111
|
+
const { db, dbPath, runtimeDir } = await openRuntimeDb(targetDir);
|
|
1112
|
+
|
|
1113
|
+
try {
|
|
1114
|
+
const agentName = options.agent;
|
|
1115
|
+
if (!agentName) {
|
|
1116
|
+
throw new Error(t('runtime.log_agent_required'));
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
const { runKey, taskKey } = await logAgentEvent(db, runtimeDir, {
|
|
1120
|
+
agentName,
|
|
1121
|
+
squadSlug: options.squad || null,
|
|
1122
|
+
message: options.message || '',
|
|
1123
|
+
type: options.type || 'status',
|
|
1124
|
+
taskTitle: options.title,
|
|
1125
|
+
finish: Boolean(options.finish),
|
|
1126
|
+
status: options.status,
|
|
1127
|
+
summary: options.summary,
|
|
1128
|
+
meta: options.meta ? (() => { try { return JSON.parse(options.meta); } catch { return { raw: options.meta }; } })() : undefined
|
|
1129
|
+
});
|
|
1130
|
+
|
|
1131
|
+
// Generate session handoff on --finish
|
|
1132
|
+
if (options.finish) {
|
|
1133
|
+
const handoffData = buildRuntimeLogHandoff(
|
|
1134
|
+
agentName,
|
|
1135
|
+
options.message || '',
|
|
1136
|
+
options.summary || ''
|
|
1137
|
+
);
|
|
1138
|
+
await writeHandoff(targetDir, handoffData);
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
if (!options.json) {
|
|
1142
|
+
const isFinish = Boolean(options.finish);
|
|
1143
|
+
logger.log(isFinish
|
|
1144
|
+
? t('runtime.log_finish_ok', { agent: agentName, run: runKey, path: dbPath })
|
|
1145
|
+
: t('runtime.log_ok', { agent: agentName, run: runKey, path: dbPath })
|
|
1146
|
+
);
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
return {
|
|
1150
|
+
ok: true,
|
|
1151
|
+
targetDir,
|
|
1152
|
+
dbPath,
|
|
1153
|
+
runKey,
|
|
1154
|
+
taskKey,
|
|
1155
|
+
agent: agentName,
|
|
1156
|
+
finished: Boolean(options.finish)
|
|
1157
|
+
};
|
|
1158
|
+
} finally {
|
|
1159
|
+
db.close();
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
|
|
1164
|
+
/**
|
|
1165
|
+
* aioson agent:done . --agent=<name> --summary="..." [--title="..."] [--status=completed|failed]
|
|
1166
|
+
*
|
|
1167
|
+
* Safe self-registration for official agents invoked directly (not via workflow:next or live:start).
|
|
1168
|
+
* - If an active live session exists for the agent: appends a completion event without closing the session.
|
|
1169
|
+
* - If no session exists: creates a standalone task+run and immediately marks it completed.
|
|
1170
|
+
*
|
|
1171
|
+
* Intended to be called ONCE at the very end of an agent session, after delivering the main artifact.
|
|
1172
|
+
*/
|
|
1173
|
+
async function runAgentDone({ args, options = {}, logger, t }) {
|
|
1174
|
+
const targetDir = resolveTargetDir(args);
|
|
1175
|
+
const agentName = String(options.agent || '').trim();
|
|
1176
|
+
if (!agentName) {
|
|
1177
|
+
throw new Error('--agent is required');
|
|
1178
|
+
}
|
|
1179
|
+
const normalizedAgent = agentName.startsWith('@') ? agentName : `@${agentName}`;
|
|
1180
|
+
const summary = String(options.summary || options.message || `${normalizedAgent} session completed`).trim();
|
|
1181
|
+
const title = options.title ? String(options.title).trim() : null;
|
|
1182
|
+
const status = options.status || 'completed';
|
|
1183
|
+
const verdict = options.verdict ? String(options.verdict).trim().toUpperCase() : null;
|
|
1184
|
+
const planStepId = options['plan-step'] ? String(options['plan-step']).trim() : null;
|
|
1185
|
+
const artifactPaths = options.artifacts
|
|
1186
|
+
? String(options.artifacts).split(',').map((p) => p.trim()).filter(Boolean)
|
|
1187
|
+
: [];
|
|
1188
|
+
|
|
1189
|
+
const { db, dbPath, runtimeDir } = await openRuntimeDb(targetDir);
|
|
1190
|
+
|
|
1191
|
+
try {
|
|
1192
|
+
const session = await readAgentSession(runtimeDir, normalizedAgent);
|
|
1193
|
+
const hasActiveSession = session && !session.finished && session.runKey;
|
|
1194
|
+
|
|
1195
|
+
if (hasActiveSession) {
|
|
1196
|
+
// Live or tracked session is already open — only append a completion note.
|
|
1197
|
+
// Do NOT close the session: live:handoff or live:close owns the lifecycle.
|
|
1198
|
+
appendRunEvent(db, {
|
|
1199
|
+
runKey: session.runKey,
|
|
1200
|
+
eventType: 'agent_done',
|
|
1201
|
+
phase: 'live',
|
|
1202
|
+
status: 'running',
|
|
1203
|
+
message: summary,
|
|
1204
|
+
verdict,
|
|
1205
|
+
planStepId
|
|
1206
|
+
});
|
|
1207
|
+
|
|
1208
|
+
if (artifactPaths.length > 0) {
|
|
1209
|
+
for (const filePath of artifactPaths) {
|
|
1210
|
+
try {
|
|
1211
|
+
attachArtifact(db, {
|
|
1212
|
+
runKey: session.runKey,
|
|
1213
|
+
agentName: normalizedAgent,
|
|
1214
|
+
kind: 'output',
|
|
1215
|
+
filePath
|
|
1216
|
+
});
|
|
1217
|
+
} catch { /* non-fatal */ }
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
if (!options.json) {
|
|
1222
|
+
logger.log(`agent:done — ${normalizedAgent} | live session active, event logged | run: ${session.runKey} (${dbPath})`);
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
if (isDocCreatingAgent(normalizedAgent)) {
|
|
1226
|
+
backupAiosonDocs(targetDir).catch(() => {});
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
// Living Memory: best-effort reflection (never blocks the close)
|
|
1230
|
+
try {
|
|
1231
|
+
await runMemoryReflectPrepare({
|
|
1232
|
+
args: [targetDir],
|
|
1233
|
+
options: { agent: normalizedAgent.replace(/^@/, ''), json: true },
|
|
1234
|
+
logger: { log: () => {}, error: () => {} }
|
|
1235
|
+
});
|
|
1236
|
+
} catch { /* ignore */ }
|
|
1237
|
+
|
|
1238
|
+
return { ok: true, targetDir, dbPath, agent: normalizedAgent, mode: 'live_event', runKey: session.runKey };
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
// No active session — create a standalone task+run and immediately complete it.
|
|
1242
|
+
const { runKey, taskKey } = await logAgentEvent(db, runtimeDir, {
|
|
1243
|
+
agentName: normalizedAgent,
|
|
1244
|
+
message: summary,
|
|
1245
|
+
type: 'completed',
|
|
1246
|
+
taskTitle: title || normalizedAgent,
|
|
1247
|
+
finish: true,
|
|
1248
|
+
status,
|
|
1249
|
+
summary
|
|
1250
|
+
});
|
|
1251
|
+
|
|
1252
|
+
if (verdict || planStepId) {
|
|
1253
|
+
appendRunEvent(db, {
|
|
1254
|
+
runKey,
|
|
1255
|
+
eventType: 'agent_done',
|
|
1256
|
+
phase: 'direct',
|
|
1257
|
+
status: 'completed',
|
|
1258
|
+
message: summary,
|
|
1259
|
+
verdict,
|
|
1260
|
+
planStepId
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
if (artifactPaths.length > 0) {
|
|
1265
|
+
for (const filePath of artifactPaths) {
|
|
1266
|
+
try {
|
|
1267
|
+
attachArtifact(db, {
|
|
1268
|
+
runKey,
|
|
1269
|
+
taskKey,
|
|
1270
|
+
agentName: normalizedAgent,
|
|
1271
|
+
kind: 'output',
|
|
1272
|
+
filePath
|
|
1273
|
+
});
|
|
1274
|
+
} catch { /* non-fatal */ }
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
if (!options.json) {
|
|
1279
|
+
logger.log(`agent:done — ${normalizedAgent} | task: ${taskKey} | run: ${runKey} (${dbPath})`);
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
if (isDocCreatingAgent(normalizedAgent)) {
|
|
1283
|
+
backupAiosonDocs(targetDir).catch(() => {});
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
// Living Memory: best-effort reflection (never blocks the close)
|
|
1287
|
+
try {
|
|
1288
|
+
await runMemoryReflectPrepare({
|
|
1289
|
+
args: [targetDir],
|
|
1290
|
+
options: { agent: normalizedAgent.replace(/^@/, ''), json: true },
|
|
1291
|
+
logger: { log: () => {}, error: () => {} }
|
|
1292
|
+
});
|
|
1293
|
+
} catch { /* ignore */ }
|
|
1294
|
+
|
|
1295
|
+
return { ok: true, targetDir, dbPath, agent: normalizedAgent, mode: 'standalone', runKey, taskKey };
|
|
1296
|
+
} finally {
|
|
1297
|
+
db.close();
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
|
|
1302
|
+
async function runRuntimeSessionStart({ args, options = {}, logger, t }) {
|
|
1303
|
+
const targetDir = resolveTargetDir(args);
|
|
1304
|
+
const { db, dbPath, runtimeDir } = await openRuntimeDb(targetDir);
|
|
1305
|
+
|
|
1306
|
+
try {
|
|
1307
|
+
const agentName = normalizeAgentHandle(requireOption(options, 'agent', t));
|
|
1308
|
+
const existingSnapshot = await collectRuntimeSessionSnapshot(db, runtimeDir, agentName, { limit: options.limit });
|
|
1309
|
+
|
|
1310
|
+
if (existingSnapshot.session && !existingSnapshot.open) {
|
|
1311
|
+
await clearAgentSession(runtimeDir, agentName);
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
if (existingSnapshot.open) {
|
|
1315
|
+
if (!options.json) {
|
|
1316
|
+
logger.log(`Direct session already active: ${agentName} | task: ${existingSnapshot.task?.task_key || '—'} | run: ${existingSnapshot.run?.run_key || '—'} (${dbPath})`);
|
|
1317
|
+
}
|
|
1318
|
+
return {
|
|
1319
|
+
ok: true,
|
|
1320
|
+
targetDir,
|
|
1321
|
+
dbPath,
|
|
1322
|
+
agent: agentName,
|
|
1323
|
+
taskKey: existingSnapshot.task?.task_key || existingSnapshot.session?.taskKey || null,
|
|
1324
|
+
runKey: existingSnapshot.run?.run_key || existingSnapshot.session?.runKey || null,
|
|
1325
|
+
sessionKey: existingSnapshot.sessionKey,
|
|
1326
|
+
status: existingSnapshot.run?.status || 'running',
|
|
1327
|
+
reused: true,
|
|
1328
|
+
open: true
|
|
1329
|
+
};
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
const sessionKey = options.session ? String(options.session).trim() : makeDirectSessionKey(agentName);
|
|
1333
|
+
const title = options.title ? String(options.title).trim() : `Direct session ${agentName}`;
|
|
1334
|
+
const message = options.message ? String(options.message).trim() : `Session started for ${agentName}`;
|
|
1335
|
+
const { runKey, taskKey } = await logAgentEvent(db, runtimeDir, {
|
|
1336
|
+
agentName,
|
|
1337
|
+
message,
|
|
1338
|
+
type: options.type || 'session.start',
|
|
1339
|
+
taskTitle: title,
|
|
1340
|
+
sessionKey,
|
|
1341
|
+
meta: options.meta ? (() => { try { return JSON.parse(options.meta); } catch { return { raw: options.meta }; } })() : undefined
|
|
1342
|
+
});
|
|
1343
|
+
|
|
1344
|
+
if (!options.json) {
|
|
1345
|
+
logger.log(`Direct session started: ${agentName} | task: ${taskKey} | run: ${runKey} (${dbPath})`);
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
return {
|
|
1349
|
+
ok: true,
|
|
1350
|
+
targetDir,
|
|
1351
|
+
dbPath,
|
|
1352
|
+
agent: agentName,
|
|
1353
|
+
taskKey,
|
|
1354
|
+
runKey,
|
|
1355
|
+
sessionKey,
|
|
1356
|
+
status: 'running',
|
|
1357
|
+
reused: false,
|
|
1358
|
+
open: true
|
|
1359
|
+
};
|
|
1360
|
+
} finally {
|
|
1361
|
+
db.close();
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
async function runRuntimeSessionLog({ args, options = {}, logger, t }) {
|
|
1366
|
+
const targetDir = resolveTargetDir(args);
|
|
1367
|
+
const { db, dbPath, runtimeDir } = await openRuntimeDb(targetDir);
|
|
1368
|
+
|
|
1369
|
+
try {
|
|
1370
|
+
const agentName = normalizeAgentHandle(requireOption(options, 'agent', t));
|
|
1371
|
+
const message = requireOption(options, 'message', t);
|
|
1372
|
+
const existingSnapshot = await collectRuntimeSessionSnapshot(db, runtimeDir, agentName, { limit: options.limit });
|
|
1373
|
+
|
|
1374
|
+
if (existingSnapshot.session && !existingSnapshot.open) {
|
|
1375
|
+
await clearAgentSession(runtimeDir, agentName);
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
const autoStarted = !existingSnapshot.open;
|
|
1379
|
+
const sessionKey = existingSnapshot.sessionKey || (options.session ? String(options.session).trim() : makeDirectSessionKey(agentName));
|
|
1380
|
+
const title = options.title ? String(options.title).trim() : `Direct session ${agentName}`;
|
|
1381
|
+
const { runKey, taskKey } = await logAgentEvent(db, runtimeDir, {
|
|
1382
|
+
agentName,
|
|
1383
|
+
message,
|
|
1384
|
+
type: options.type || 'session.log',
|
|
1385
|
+
taskTitle: title,
|
|
1386
|
+
sessionKey,
|
|
1387
|
+
meta: options.meta ? (() => { try { return JSON.parse(options.meta); } catch { return { raw: options.meta }; } })() : undefined
|
|
1388
|
+
});
|
|
1389
|
+
|
|
1390
|
+
if (!options.json) {
|
|
1391
|
+
logger.log(`Direct session log recorded: ${agentName} | run: ${runKey} (${dbPath})`);
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
return {
|
|
1395
|
+
ok: true,
|
|
1396
|
+
targetDir,
|
|
1397
|
+
dbPath,
|
|
1398
|
+
agent: agentName,
|
|
1399
|
+
taskKey,
|
|
1400
|
+
runKey,
|
|
1401
|
+
sessionKey,
|
|
1402
|
+
status: 'running',
|
|
1403
|
+
autoStarted,
|
|
1404
|
+
open: true
|
|
1405
|
+
};
|
|
1406
|
+
} finally {
|
|
1407
|
+
db.close();
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
async function runRuntimeSessionFinish({ args, options = {}, logger, t }) {
|
|
1412
|
+
const targetDir = resolveTargetDir(args);
|
|
1413
|
+
const { db, dbPath, runtimeDir } = await openRuntimeDb(targetDir);
|
|
1414
|
+
|
|
1415
|
+
try {
|
|
1416
|
+
const agentName = normalizeAgentHandle(requireOption(options, 'agent', t));
|
|
1417
|
+
const existingSnapshot = await collectRuntimeSessionSnapshot(db, runtimeDir, agentName, { limit: options.limit });
|
|
1418
|
+
|
|
1419
|
+
if (!existingSnapshot.open) {
|
|
1420
|
+
throw new Error(`No active direct session for ${agentName}.`);
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
const summary = options.summary ? String(options.summary).trim() : '';
|
|
1424
|
+
const message = options.message ? String(options.message).trim() : (summary || `Session finished for ${agentName}`);
|
|
1425
|
+
const { runKey, taskKey } = await logAgentEvent(db, runtimeDir, {
|
|
1426
|
+
agentName,
|
|
1427
|
+
message,
|
|
1428
|
+
type: options.type || 'session.finish',
|
|
1429
|
+
finish: true,
|
|
1430
|
+
status: options.status || 'completed',
|
|
1431
|
+
summary,
|
|
1432
|
+
meta: options.meta ? (() => { try { return JSON.parse(options.meta); } catch { return { raw: options.meta }; } })() : undefined
|
|
1433
|
+
});
|
|
1434
|
+
|
|
1435
|
+
if (!options.json) {
|
|
1436
|
+
logger.log(`Direct session finished: ${agentName} | run: ${runKey} (${dbPath})`);
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
return {
|
|
1440
|
+
ok: true,
|
|
1441
|
+
targetDir,
|
|
1442
|
+
dbPath,
|
|
1443
|
+
agent: agentName,
|
|
1444
|
+
taskKey,
|
|
1445
|
+
runKey,
|
|
1446
|
+
sessionKey: existingSnapshot.sessionKey,
|
|
1447
|
+
status: options.status || 'completed',
|
|
1448
|
+
finished: true,
|
|
1449
|
+
open: false
|
|
1450
|
+
};
|
|
1451
|
+
} finally {
|
|
1452
|
+
db.close();
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
async function runRuntimeSessionStatus({ args, options = {}, logger, t }) {
|
|
1457
|
+
const targetDir = resolveTargetDir(args);
|
|
1458
|
+
const agentName = normalizeAgentHandle(requireOption(options, 'agent', t));
|
|
1459
|
+
const watchSeconds = parseWatchSeconds(options.watch);
|
|
1460
|
+
|
|
1461
|
+
if (watchSeconds && options.json) {
|
|
1462
|
+
throw new Error('--watch cannot be combined with --json.');
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
if (!watchSeconds) {
|
|
1466
|
+
const snapshot = await getRuntimeSessionSnapshot(targetDir, agentName, t, { limit: options.limit });
|
|
1467
|
+
if (!options.json) {
|
|
1468
|
+
printRuntimeSessionSnapshot(snapshot, logger);
|
|
1469
|
+
}
|
|
1470
|
+
return snapshot;
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
while (true) {
|
|
1474
|
+
const snapshot = await getRuntimeSessionSnapshot(targetDir, agentName, t, { limit: options.limit });
|
|
1475
|
+
if (process.stdout && process.stdout.isTTY) {
|
|
1476
|
+
process.stdout.write('\x1Bc');
|
|
1477
|
+
}
|
|
1478
|
+
printRuntimeSessionSnapshot(snapshot, logger);
|
|
1479
|
+
await sleep(Math.round(watchSeconds * 1000));
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
async function runDeliver({ args, options = {}, logger, t }) {
|
|
1484
|
+
const targetDir = resolveTargetDir(args);
|
|
1485
|
+
const squadSlug = requireOption(options, 'squad', t);
|
|
1486
|
+
const contentKey = options['content-key'] || options.contentKey || null;
|
|
1487
|
+
const triggerType = options.trigger || 'manual';
|
|
1488
|
+
|
|
1489
|
+
const { db, dbPath } = await withRuntimeDb(targetDir, t);
|
|
1490
|
+
|
|
1491
|
+
try {
|
|
1492
|
+
const { runManualDelivery } = require('../delivery-runner');
|
|
1493
|
+
|
|
1494
|
+
// Optionally load content payload from DB
|
|
1495
|
+
let contentPayload = null;
|
|
1496
|
+
if (contentKey) {
|
|
1497
|
+
const row = db.prepare('SELECT payload_json FROM content_items WHERE content_key = ? AND squad_slug = ?').get(contentKey, squadSlug);
|
|
1498
|
+
if (row && row.payload_json) {
|
|
1499
|
+
try { contentPayload = JSON.parse(row.payload_json); } catch { /* ignore */ }
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
const result = await runManualDelivery(db, {
|
|
1504
|
+
projectDir: targetDir,
|
|
1505
|
+
squadSlug,
|
|
1506
|
+
contentKey,
|
|
1507
|
+
triggerType,
|
|
1508
|
+
contentPayload
|
|
1509
|
+
});
|
|
1510
|
+
|
|
1511
|
+
if (!result.delivered) {
|
|
1512
|
+
logger.log(`Delivery skipped: ${result.reason}`);
|
|
1513
|
+
return { ok: false, ...result };
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
for (const r of result.results || []) {
|
|
1517
|
+
const status = r.ok ? 'OK' : 'FAIL';
|
|
1518
|
+
logger.log(` ${status} ${r.webhookSlug} — ${r.statusCode || 'no response'} (${r.attempts} attempt${r.attempts > 1 ? 's' : ''})`);
|
|
1519
|
+
if (r.error) logger.log(` Error: ${r.error}`);
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
logger.log(`\nDelivery ${result.allOk ? 'completed' : 'completed with errors'}.`);
|
|
1523
|
+
return { ok: result.allOk, ...result };
|
|
1524
|
+
} finally {
|
|
1525
|
+
db.close();
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
async function findManifestPath(projectDir, slug) {
|
|
1530
|
+
const candidates = [
|
|
1531
|
+
path.join(projectDir, '.aioson', 'squads', slug, 'squad.manifest.json'),
|
|
1532
|
+
path.join(projectDir, 'agents', slug, 'squad.manifest.json')
|
|
1533
|
+
];
|
|
1534
|
+
for (const p of candidates) {
|
|
1535
|
+
try { await fs.stat(p); return p; } catch { continue; }
|
|
1536
|
+
}
|
|
1537
|
+
return null;
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
async function runOutputStrategyExport({ args, options = {}, logger, t }) {
|
|
1541
|
+
const projectDir = resolveTargetDir(args);
|
|
1542
|
+
const slug = requireOption(options, 'squad', t);
|
|
1543
|
+
const manifestPath = await findManifestPath(projectDir, slug);
|
|
1544
|
+
|
|
1545
|
+
if (!manifestPath) {
|
|
1546
|
+
logger.error(`Manifest not found for squad "${slug}"`);
|
|
1547
|
+
return { ok: false, error: 'Manifest not found' };
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
const raw = await fs.readFile(manifestPath, 'utf8');
|
|
1551
|
+
const manifest = JSON.parse(raw);
|
|
1552
|
+
const strategy = manifest.outputStrategy || null;
|
|
1553
|
+
|
|
1554
|
+
if (!strategy) {
|
|
1555
|
+
logger.log(`Squad "${slug}" has no outputStrategy configured.`);
|
|
1556
|
+
return { ok: false, error: 'No outputStrategy found' };
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
const exportsDir = path.join(projectDir, '.aioson', 'squads', 'exports');
|
|
1560
|
+
await fs.mkdir(exportsDir, { recursive: true });
|
|
1561
|
+
const outFile = path.join(exportsDir, `${slug}.output-strategy.json`);
|
|
1562
|
+
await fs.writeFile(outFile, JSON.stringify(strategy, null, 2) + '\n', 'utf8');
|
|
1563
|
+
|
|
1564
|
+
const relOut = path.relative(projectDir, outFile).replace(/\\/g, '/');
|
|
1565
|
+
logger.log(`Exported outputStrategy from "${slug}" → ${relOut}`);
|
|
1566
|
+
return { ok: true, file: relOut, strategy };
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
async function runOutputStrategyImport({ args, options = {}, logger, t }) {
|
|
1570
|
+
const projectDir = resolveTargetDir(args);
|
|
1571
|
+
const slug = requireOption(options, 'squad', t);
|
|
1572
|
+
const fromSlug = options.from || null;
|
|
1573
|
+
const fromFile = options.file || null;
|
|
1574
|
+
|
|
1575
|
+
if (!fromSlug && !fromFile) {
|
|
1576
|
+
logger.error('Usage: aioson output-strategy:import --squad=<target> --from=<source-slug> | --file=<path>');
|
|
1577
|
+
return { ok: false, error: 'Provide --from or --file' };
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
// Load source strategy
|
|
1581
|
+
let strategy;
|
|
1582
|
+
if (fromFile) {
|
|
1583
|
+
const absFile = path.resolve(projectDir, fromFile);
|
|
1584
|
+
const raw = await fs.readFile(absFile, 'utf8');
|
|
1585
|
+
strategy = JSON.parse(raw);
|
|
1586
|
+
} else {
|
|
1587
|
+
const srcPath = await findManifestPath(projectDir, fromSlug);
|
|
1588
|
+
if (!srcPath) {
|
|
1589
|
+
logger.error(`Source squad "${fromSlug}" manifest not found`);
|
|
1590
|
+
return { ok: false, error: 'Source manifest not found' };
|
|
1591
|
+
}
|
|
1592
|
+
const srcManifest = JSON.parse(await fs.readFile(srcPath, 'utf8'));
|
|
1593
|
+
strategy = srcManifest.outputStrategy || null;
|
|
1594
|
+
if (!strategy) {
|
|
1595
|
+
logger.error(`Source squad "${fromSlug}" has no outputStrategy`);
|
|
1596
|
+
return { ok: false, error: 'Source has no outputStrategy' };
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
// Write to target
|
|
1601
|
+
const targetPath = await findManifestPath(projectDir, slug);
|
|
1602
|
+
if (!targetPath) {
|
|
1603
|
+
logger.error(`Target squad "${slug}" manifest not found`);
|
|
1604
|
+
return { ok: false, error: 'Target manifest not found' };
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
const targetManifest = JSON.parse(await fs.readFile(targetPath, 'utf8'));
|
|
1608
|
+
targetManifest.outputStrategy = strategy;
|
|
1609
|
+
await fs.writeFile(targetPath, JSON.stringify(targetManifest, null, 2) + '\n', 'utf8');
|
|
1610
|
+
|
|
1611
|
+
logger.log(`Imported outputStrategy into "${slug}" from ${fromSlug || fromFile}`);
|
|
1612
|
+
return { ok: true, squad: slug, source: fromSlug || fromFile };
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
/**
|
|
1616
|
+
* aioson devlog:sync [targetDir]
|
|
1617
|
+
*
|
|
1618
|
+
* Parses aioson-logs/devlog-*.md files, imports them into SQLite as
|
|
1619
|
+
* task + run + events, then renames each file to .synced so it is not
|
|
1620
|
+
* re-imported on subsequent runs.
|
|
1621
|
+
*/
|
|
1622
|
+
async function runDevlogSync({ args, options = {}, logger, t }) {
|
|
1623
|
+
const targetDir = resolveTargetDir(args);
|
|
1624
|
+
const logsDir = path.join(targetDir, 'aioson-logs');
|
|
1625
|
+
|
|
1626
|
+
let entries;
|
|
1627
|
+
try {
|
|
1628
|
+
entries = await fs.readdir(logsDir);
|
|
1629
|
+
} catch {
|
|
1630
|
+
logger.log('No aioson-logs/ directory found — nothing to sync.');
|
|
1631
|
+
return { ok: true, synced: 0 };
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
const devlogFiles = entries
|
|
1635
|
+
.filter(f => f.startsWith('devlog-') && f.endsWith('.md'))
|
|
1636
|
+
.sort();
|
|
1637
|
+
|
|
1638
|
+
if (devlogFiles.length === 0) {
|
|
1639
|
+
logger.log('No devlog files to sync.');
|
|
1640
|
+
return { ok: true, synced: 0 };
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
const { db, dbPath } = await openRuntimeDb(targetDir);
|
|
1644
|
+
let synced = 0;
|
|
1645
|
+
const parsedDevlogs = [];
|
|
1646
|
+
|
|
1647
|
+
try {
|
|
1648
|
+
for (const file of devlogFiles) {
|
|
1649
|
+
const filePath = path.join(logsDir, file);
|
|
1650
|
+
const raw = await fs.readFile(filePath, 'utf8');
|
|
1651
|
+
|
|
1652
|
+
// Parse YAML frontmatter
|
|
1653
|
+
const fm = parseFrontmatter(raw);
|
|
1654
|
+
const agent = fm.agent || 'unknown';
|
|
1655
|
+
const summary = fm.summary || file;
|
|
1656
|
+
const sessionStart = fm.session_start || null;
|
|
1657
|
+
const sessionEnd = fm.session_end || null;
|
|
1658
|
+
const status = fm.status || 'completed';
|
|
1659
|
+
const body = raw.replace(/^---[\s\S]*?---\s*/, '');
|
|
1660
|
+
|
|
1661
|
+
parsedDevlogs.push({ filename: file, agent, summary, sessionStart, sessionEnd, status, body });
|
|
1662
|
+
|
|
1663
|
+
// Create task + run
|
|
1664
|
+
const taskKey = startTask(db, {
|
|
1665
|
+
title: `devlog: ${summary}`,
|
|
1666
|
+
squadSlug: null,
|
|
1667
|
+
status: status === 'partial' ? 'running' : 'completed',
|
|
1668
|
+
createdBy: agent
|
|
1669
|
+
});
|
|
1670
|
+
|
|
1671
|
+
const runKey = startRun(db, {
|
|
1672
|
+
taskKey,
|
|
1673
|
+
agentName: agent,
|
|
1674
|
+
agentKind: 'devlog',
|
|
1675
|
+
squadSlug: null,
|
|
1676
|
+
title: `@${agent} devlog`,
|
|
1677
|
+
message: summary
|
|
1678
|
+
});
|
|
1679
|
+
|
|
1680
|
+
// Extract body sections as events
|
|
1681
|
+
const sections = body.split(/^## /m).filter(Boolean);
|
|
1682
|
+
for (const section of sections) {
|
|
1683
|
+
const firstLine = section.split('\n')[0].trim();
|
|
1684
|
+
const content = section.slice(firstLine.length).trim();
|
|
1685
|
+
if (content) {
|
|
1686
|
+
appendRunEvent(db, {
|
|
1687
|
+
runKey,
|
|
1688
|
+
eventType: 'devlog',
|
|
1689
|
+
phase: firstLine.toLowerCase().replace(/\s+/g, '_'),
|
|
1690
|
+
status: 'completed',
|
|
1691
|
+
message: `## ${firstLine}\n${content}`,
|
|
1692
|
+
createdAt: sessionEnd || new Date().toISOString()
|
|
1693
|
+
});
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
// Close the run
|
|
1698
|
+
updateRun(db, runKey, {
|
|
1699
|
+
status: status === 'partial' ? 'running' : 'completed',
|
|
1700
|
+
summary,
|
|
1701
|
+
finishedAt: sessionEnd || new Date().toISOString()
|
|
1702
|
+
});
|
|
1703
|
+
|
|
1704
|
+
if (status !== 'partial') {
|
|
1705
|
+
updateTask(db, taskKey, {
|
|
1706
|
+
status: 'completed',
|
|
1707
|
+
finishedAt: sessionEnd || new Date().toISOString()
|
|
1708
|
+
});
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
// Rename to .synced
|
|
1712
|
+
await fs.rename(filePath, filePath.replace(/\.md$/, '.synced.md'));
|
|
1713
|
+
synced++;
|
|
1714
|
+
logger.log(` Synced: ${file} → task=${taskKey} run=${runKey}`);
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
logger.log(`Synced ${synced} devlog(s) into ${dbPath}`);
|
|
1718
|
+
|
|
1719
|
+
// Cloud sync
|
|
1720
|
+
if (options.cloud) {
|
|
1721
|
+
const cloudResult = await syncDevlogsToCloud(targetDir, parsedDevlogs, options, logger);
|
|
1722
|
+
return { ok: true, synced, dbPath, cloud: cloudResult };
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
return { ok: true, synced, dbPath };
|
|
1726
|
+
} finally {
|
|
1727
|
+
db.close();
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
/**
|
|
1732
|
+
* Sends parsed devlogs to the cloud endpoint.
|
|
1733
|
+
* Reads cloud config from .aioson/install.json or --url / --token options.
|
|
1734
|
+
*/
|
|
1735
|
+
async function syncDevlogsToCloud(targetDir, devlogs, options, logger) {
|
|
1736
|
+
const cloudUrl = options.url || options['cloud-url'] || await resolveCloudUrl(targetDir);
|
|
1737
|
+
const cloudToken = options.token || options['cloud-token'] || await resolveCloudToken(targetDir);
|
|
1738
|
+
|
|
1739
|
+
if (!cloudUrl) {
|
|
1740
|
+
logger.error('Cloud URL not configured. Use --url or set cloudBaseUrl in dashboard project settings.');
|
|
1741
|
+
return { ok: false, error: 'missing_cloud_url' };
|
|
1742
|
+
}
|
|
1743
|
+
if (!cloudToken) {
|
|
1744
|
+
logger.error('Cloud token not configured. Use --token or set cloudApiToken in dashboard project settings.');
|
|
1745
|
+
return { ok: false, error: 'missing_cloud_token' };
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
const endpoint = `${cloudUrl.replace(/\/+$/, '')}/api/publish/runtime`;
|
|
1749
|
+
const payload = {
|
|
1750
|
+
tasks: [],
|
|
1751
|
+
devlogs: devlogs.map(d => ({
|
|
1752
|
+
filename: d.filename,
|
|
1753
|
+
agent: d.agent,
|
|
1754
|
+
sessionStart: d.sessionStart,
|
|
1755
|
+
sessionEnd: d.sessionEnd,
|
|
1756
|
+
status: d.status,
|
|
1757
|
+
summary: d.summary,
|
|
1758
|
+
body: d.body
|
|
1759
|
+
}))
|
|
1760
|
+
};
|
|
1761
|
+
|
|
1762
|
+
logger.log(` Pushing ${devlogs.length} devlog(s) to ${endpoint}...`);
|
|
1763
|
+
|
|
1764
|
+
const response = await fetch(endpoint, {
|
|
1765
|
+
method: 'POST',
|
|
1766
|
+
headers: {
|
|
1767
|
+
'accept': 'application/json',
|
|
1768
|
+
'content-type': 'application/json',
|
|
1769
|
+
'authorization': `Bearer ${cloudToken}`
|
|
1770
|
+
},
|
|
1771
|
+
body: JSON.stringify(payload),
|
|
1772
|
+
signal: AbortSignal.timeout(15000)
|
|
1773
|
+
});
|
|
1774
|
+
|
|
1775
|
+
const text = await response.text();
|
|
1776
|
+
let result;
|
|
1777
|
+
try { result = JSON.parse(text); } catch { result = { ok: false, error: text }; }
|
|
1778
|
+
|
|
1779
|
+
if (result.ok) {
|
|
1780
|
+
logger.log(` Cloud sync OK: ${result.devlogsStored || 0} devlog(s) stored.`);
|
|
1781
|
+
} else {
|
|
1782
|
+
logger.error(` Cloud sync failed: ${result.error || response.status}`);
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
return result;
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
async function resolveCloudUrl(targetDir) {
|
|
1789
|
+
try {
|
|
1790
|
+
const raw = await fs.readFile(path.join(targetDir, '.aioson/install.json'), 'utf8');
|
|
1791
|
+
const meta = JSON.parse(raw);
|
|
1792
|
+
return meta.cloudBaseUrl || null;
|
|
1793
|
+
} catch { return null; }
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
async function resolveCloudToken(targetDir) {
|
|
1797
|
+
try {
|
|
1798
|
+
const raw = await fs.readFile(path.join(targetDir, '.aioson/install.json'), 'utf8');
|
|
1799
|
+
const meta = JSON.parse(raw);
|
|
1800
|
+
return meta.cloudApiToken || null;
|
|
1801
|
+
} catch { return null; }
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
/**
|
|
1805
|
+
* Minimal YAML frontmatter parser (no external deps).
|
|
1806
|
+
* Returns an object with frontmatter keys, or {} if none.
|
|
1807
|
+
*/
|
|
1808
|
+
function parseFrontmatter(content) {
|
|
1809
|
+
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
1810
|
+
if (!match) return {};
|
|
1811
|
+
const result = {};
|
|
1812
|
+
for (const line of match[1].split('\n')) {
|
|
1813
|
+
const idx = line.indexOf(':');
|
|
1814
|
+
if (idx === -1) continue;
|
|
1815
|
+
const key = line.slice(0, idx).trim();
|
|
1816
|
+
let val = line.slice(idx + 1).trim();
|
|
1817
|
+
// Strip surrounding quotes
|
|
1818
|
+
if ((val.startsWith('"') && val.endsWith('"')) || (val.startsWith("'") && val.endsWith("'"))) {
|
|
1819
|
+
val = val.slice(1, -1);
|
|
1820
|
+
}
|
|
1821
|
+
result[key] = val;
|
|
1822
|
+
}
|
|
1823
|
+
return result;
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
/**
|
|
1827
|
+
* Parses a duration string like "24h", "30m", "7d" into milliseconds.
|
|
1828
|
+
* Falls back to treating the raw value as hours.
|
|
1829
|
+
*/
|
|
1830
|
+
function parseDurationMs(value, defaultHours = 24) {
|
|
1831
|
+
const text = String(value || '').trim().toLowerCase();
|
|
1832
|
+
if (!text) return defaultHours * 60 * 60 * 1000;
|
|
1833
|
+
|
|
1834
|
+
const match = text.match(/^(\d+(?:\.\d+)?)\s*([hmd]?)$/);
|
|
1835
|
+
if (!match) return defaultHours * 60 * 60 * 1000;
|
|
1836
|
+
|
|
1837
|
+
const n = parseFloat(match[1]);
|
|
1838
|
+
const unit = match[2] || 'h';
|
|
1839
|
+
if (unit === 'd') return n * 24 * 60 * 60 * 1000;
|
|
1840
|
+
if (unit === 'm') return n * 60 * 1000;
|
|
1841
|
+
return n * 60 * 60 * 1000; // hours (default)
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
/**
|
|
1845
|
+
* aioson agent:recover [targetDir] [--older-than=<duration>] [--dry-run]
|
|
1846
|
+
*
|
|
1847
|
+
* Detects and closes agent sessions that were abandoned (Claude Code closed before
|
|
1848
|
+
* agent:done was called, or live:start session was never closed).
|
|
1849
|
+
*
|
|
1850
|
+
* Sources checked:
|
|
1851
|
+
* 1. Session files in .aioson/.sessions/ with finished=false older than threshold.
|
|
1852
|
+
* 2. agent_runs rows with status='running'/'queued' and started_at older than threshold
|
|
1853
|
+
* that have no corresponding live session file (orphaned DB records).
|
|
1854
|
+
*
|
|
1855
|
+
* --older-than Duration threshold. Accepts: 24h (default), 8h, 30m, 7d.
|
|
1856
|
+
* --dry-run Report what would be recovered without making any changes.
|
|
1857
|
+
* --json Output JSON result.
|
|
1858
|
+
*/
|
|
1859
|
+
async function runAgentRecover({ args, options = {}, logger }) {
|
|
1860
|
+
const targetDir = resolveTargetDir(args);
|
|
1861
|
+
const dryRun = Boolean(options['dry-run'] || options.dryRun);
|
|
1862
|
+
const olderThanMs = parseDurationMs(options['older-than'] || options.olderThan, 24);
|
|
1863
|
+
const cutoffMs = Date.now() - olderThanMs;
|
|
1864
|
+
const cutoffIso = new Date(cutoffMs).toISOString();
|
|
1865
|
+
const now = new Date().toISOString();
|
|
1866
|
+
|
|
1867
|
+
const { db, dbPath, runtimeDir } = await openRuntimeDb(targetDir);
|
|
1868
|
+
|
|
1869
|
+
const recovered = [];
|
|
1870
|
+
const skipped = [];
|
|
1871
|
+
|
|
1872
|
+
try {
|
|
1873
|
+
// ── 1. Scan session files ─────────────────────────────────────────────────
|
|
1874
|
+
const sessionsDir = path.join(runtimeDir, '.sessions');
|
|
1875
|
+
let sessionFiles = [];
|
|
1876
|
+
try {
|
|
1877
|
+
const entries = await fs.readdir(sessionsDir);
|
|
1878
|
+
sessionFiles = entries.filter((f) => f.endsWith('.json'));
|
|
1879
|
+
} catch {
|
|
1880
|
+
// .sessions dir may not exist — that's fine
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
for (const file of sessionFiles) {
|
|
1884
|
+
const filePath = path.join(sessionsDir, file);
|
|
1885
|
+
let session;
|
|
1886
|
+
try {
|
|
1887
|
+
session = JSON.parse(await fs.readFile(filePath, 'utf8'));
|
|
1888
|
+
} catch {
|
|
1889
|
+
continue;
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
if (session.finished) continue;
|
|
1893
|
+
|
|
1894
|
+
const startedAt = session.startedAt ? new Date(session.startedAt).getTime() : 0;
|
|
1895
|
+
if (startedAt > cutoffMs) {
|
|
1896
|
+
skipped.push({ source: 'session_file', file, reason: 'within_threshold', startedAt: session.startedAt });
|
|
1897
|
+
continue;
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
const agentName = file.replace(/\.json$/, '');
|
|
1901
|
+
const runKey = session.runKey || null;
|
|
1902
|
+
const taskKey = session.taskKey || null;
|
|
1903
|
+
|
|
1904
|
+
if (!dryRun) {
|
|
1905
|
+
// Mark run as abandoned
|
|
1906
|
+
if (runKey) {
|
|
1907
|
+
const runRow = db.prepare('SELECT run_key, status FROM agent_runs WHERE run_key = ?').get(runKey);
|
|
1908
|
+
if (runRow && (runRow.status === 'running' || runRow.status === 'queued')) {
|
|
1909
|
+
db.prepare(`
|
|
1910
|
+
UPDATE agent_runs
|
|
1911
|
+
SET status = 'abandoned', summary = 'Recovered: session abandoned without close', updated_at = ?, finished_at = ?
|
|
1912
|
+
WHERE run_key = ?
|
|
1913
|
+
`).run(now, now, runKey);
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
// Mark task as abandoned
|
|
1917
|
+
if (taskKey) {
|
|
1918
|
+
const taskRow = db.prepare('SELECT task_key, status FROM tasks WHERE task_key = ?').get(taskKey);
|
|
1919
|
+
if (taskRow && (taskRow.status === 'running' || taskRow.status === 'queued')) {
|
|
1920
|
+
db.prepare(`
|
|
1921
|
+
UPDATE tasks
|
|
1922
|
+
SET status = 'abandoned', updated_at = ?, finished_at = ?
|
|
1923
|
+
WHERE task_key = ?
|
|
1924
|
+
`).run(now, now, taskKey);
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
// Remove session file
|
|
1928
|
+
try { await fs.unlink(filePath); } catch { /* noop */ }
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
recovered.push({ source: 'session_file', agent: agentName, runKey, taskKey, startedAt: session.startedAt });
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
// ── 2. Scan DB for orphaned running runs (no session file) ────────────────
|
|
1935
|
+
const orphanedRuns = db.prepare(`
|
|
1936
|
+
SELECT run_key, task_key, agent_name, started_at
|
|
1937
|
+
FROM agent_runs
|
|
1938
|
+
WHERE status IN ('running', 'queued')
|
|
1939
|
+
AND source = 'direct'
|
|
1940
|
+
AND started_at < ?
|
|
1941
|
+
`).all(cutoffIso);
|
|
1942
|
+
|
|
1943
|
+
for (const run of orphanedRuns) {
|
|
1944
|
+
// Skip if already recovered via session file
|
|
1945
|
+
if (recovered.some((r) => r.runKey === run.run_key)) continue;
|
|
1946
|
+
|
|
1947
|
+
if (!dryRun) {
|
|
1948
|
+
db.prepare(`
|
|
1949
|
+
UPDATE agent_runs
|
|
1950
|
+
SET status = 'abandoned', summary = 'Recovered: orphaned run with no session file', updated_at = ?, finished_at = ?
|
|
1951
|
+
WHERE run_key = ?
|
|
1952
|
+
`).run(now, now, run.run_key);
|
|
1953
|
+
|
|
1954
|
+
if (run.task_key) {
|
|
1955
|
+
const taskRow = db.prepare('SELECT task_key, status FROM tasks WHERE task_key = ?').get(run.task_key);
|
|
1956
|
+
if (taskRow && (taskRow.status === 'running' || taskRow.status === 'queued')) {
|
|
1957
|
+
db.prepare(`
|
|
1958
|
+
UPDATE tasks
|
|
1959
|
+
SET status = 'abandoned', updated_at = ?, finished_at = ?
|
|
1960
|
+
WHERE task_key = ?
|
|
1961
|
+
`).run(now, now, run.task_key);
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
recovered.push({ source: 'orphaned_run', agent: run.agent_name, runKey: run.run_key, taskKey: run.task_key, startedAt: run.started_at });
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
// ── Output ────────────────────────────────────────────────────────────────
|
|
1970
|
+
const olderThanLabel = options['older-than'] || options.olderThan || '24h';
|
|
1971
|
+
if (recovered.length === 0) {
|
|
1972
|
+
logger.log(`agent:recover — no abandoned sessions found older than ${olderThanLabel} (${dbPath})`);
|
|
1973
|
+
} else {
|
|
1974
|
+
const verb = dryRun ? '[dry-run] would recover' : 'recovered';
|
|
1975
|
+
logger.log(`agent:recover — ${verb} ${recovered.length} abandoned session(s) older than ${olderThanLabel} (${dbPath})`);
|
|
1976
|
+
for (const r of recovered) {
|
|
1977
|
+
logger.log(` ${r.agent} started: ${r.startedAt || '?'} run: ${r.runKey || '—'} [${r.source}]`);
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
if (skipped.length > 0) {
|
|
1981
|
+
logger.log(` skipped ${skipped.length} session(s) within threshold.`);
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
return { ok: true, targetDir, dbPath, dryRun, cutoff: cutoffIso, recovered, skipped };
|
|
1985
|
+
} finally {
|
|
1986
|
+
db.close();
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
|
|
1991
|
+
/**
|
|
1992
|
+
* aioson runtime:prune [targetDir] --older-than=<days>
|
|
1993
|
+
*
|
|
1994
|
+
* Removes execution_events, agent_events, and completed agent_runs
|
|
1995
|
+
* older than the specified number of days. Tasks are kept but their
|
|
1996
|
+
* events are cleaned up.
|
|
1997
|
+
*/
|
|
1998
|
+
async function runRuntimePrune({ args, options = {}, logger, t }) {
|
|
1999
|
+
const targetDir = resolveTargetDir(args);
|
|
2000
|
+
const days = parseInt(options['older-than'] || options.olderThan || '30', 10);
|
|
2001
|
+
|
|
2002
|
+
if (isNaN(days) || days < 1) {
|
|
2003
|
+
logger.error('Usage: aioson runtime:prune --older-than=<days> (minimum 1)');
|
|
2004
|
+
return { ok: false, error: 'Invalid --older-than value' };
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
const { db, dbPath } = await withRuntimeDb(targetDir, t);
|
|
2008
|
+
|
|
2009
|
+
try {
|
|
2010
|
+
const cutoff = new Date(Date.now() - days * 24 * 60 * 60 * 1000).toISOString();
|
|
2011
|
+
|
|
2012
|
+
const execEvents = db.prepare(
|
|
2013
|
+
`DELETE FROM execution_events WHERE created_at < ?`
|
|
2014
|
+
).run(cutoff);
|
|
2015
|
+
|
|
2016
|
+
const agentEvents = db.prepare(
|
|
2017
|
+
`DELETE FROM agent_events WHERE created_at < ?`
|
|
2018
|
+
).run(cutoff);
|
|
2019
|
+
|
|
2020
|
+
const runs = db.prepare(
|
|
2021
|
+
`DELETE FROM agent_runs WHERE status IN ('completed', 'failed') AND finished_at < ?`
|
|
2022
|
+
).run(cutoff);
|
|
2023
|
+
|
|
2024
|
+
const tasks = db.prepare(
|
|
2025
|
+
`DELETE FROM tasks WHERE status IN ('completed', 'failed') AND finished_at < ?`
|
|
2026
|
+
).run(cutoff);
|
|
2027
|
+
|
|
2028
|
+
const deliveryLogs = db.prepare(
|
|
2029
|
+
`DELETE FROM delivery_log WHERE created_at < ?`
|
|
2030
|
+
).run(cutoff);
|
|
2031
|
+
|
|
2032
|
+
// Reclaim disk space
|
|
2033
|
+
db.pragma('wal_checkpoint(TRUNCATE)');
|
|
2034
|
+
|
|
2035
|
+
const total = execEvents.changes + agentEvents.changes + runs.changes + tasks.changes + deliveryLogs.changes;
|
|
2036
|
+
|
|
2037
|
+
logger.log(`Pruned ${total} records older than ${days} days from ${dbPath}:`);
|
|
2038
|
+
logger.log(` execution_events: ${execEvents.changes}`);
|
|
2039
|
+
logger.log(` agent_events: ${agentEvents.changes}`);
|
|
2040
|
+
logger.log(` agent_runs: ${runs.changes}`);
|
|
2041
|
+
logger.log(` tasks: ${tasks.changes}`);
|
|
2042
|
+
logger.log(` delivery_log: ${deliveryLogs.changes}`);
|
|
2043
|
+
|
|
2044
|
+
return {
|
|
2045
|
+
ok: true,
|
|
2046
|
+
dbPath,
|
|
2047
|
+
days,
|
|
2048
|
+
cutoff,
|
|
2049
|
+
deleted: {
|
|
2050
|
+
execution_events: execEvents.changes,
|
|
2051
|
+
agent_events: agentEvents.changes,
|
|
2052
|
+
agent_runs: runs.changes,
|
|
2053
|
+
tasks: tasks.changes,
|
|
2054
|
+
delivery_log: deliveryLogs.changes,
|
|
2055
|
+
total
|
|
2056
|
+
}
|
|
2057
|
+
};
|
|
2058
|
+
} finally {
|
|
2059
|
+
db.close();
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
|
|
2063
|
+
module.exports = {
|
|
2064
|
+
runRuntimeInit,
|
|
2065
|
+
runRuntimeIngest,
|
|
2066
|
+
runRuntimeTaskStart,
|
|
2067
|
+
runRuntimeStart,
|
|
2068
|
+
runRuntimeUpdate,
|
|
2069
|
+
runRuntimeTaskFinish,
|
|
2070
|
+
runRuntimeFinish,
|
|
2071
|
+
runRuntimeTaskFail,
|
|
2072
|
+
runRuntimeFail,
|
|
2073
|
+
runRuntimeStatus,
|
|
2074
|
+
runRuntimeLog,
|
|
2075
|
+
runAgentDone,
|
|
2076
|
+
runAgentRecover,
|
|
2077
|
+
runRuntimeSessionStart,
|
|
2078
|
+
runRuntimeSessionLog,
|
|
2079
|
+
runRuntimeSessionFinish,
|
|
2080
|
+
runRuntimeSessionStatus,
|
|
2081
|
+
runDeliver,
|
|
2082
|
+
runOutputStrategyExport,
|
|
2083
|
+
runOutputStrategyImport,
|
|
2084
|
+
runDevlogSync,
|
|
2085
|
+
runRuntimePrune
|
|
2086
|
+
};
|