total-recall-brain 3.44.0 → 3.46.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/bin/total-recall.mjs +10 -6
- package/docs/ARCHITECTURE.md +10 -7
- package/docs/reference/cli-reference.md +13 -8
- package/frontend/dist/assets/index-BRYE1jmv.css +1 -0
- package/frontend/dist/assets/index-D1goIPjC.js +5598 -0
- package/frontend/dist/index.html +2 -2
- package/frontend/dist/sw.js +5 -4
- package/frontend/src/App.tsx +185 -238
- package/frontend/src/api/auth-inventory.ts +62 -0
- package/frontend/src/api/memory.ts +13 -8
- package/frontend/src/api/plugin-credentials.ts +23 -0
- package/frontend/src/api/plugins.ts +37 -53
- package/frontend/src/api/workspace-drawers.ts +97 -0
- package/frontend/src/components/BrainSelector.tsx +9 -3
- package/frontend/src/components/plugins/PluginPanel.tsx +83 -42
- package/frontend/src/components/plugins/PluginSettings.tsx +10 -20
- package/frontend/src/components/plugins/PluginWorkspace.tsx +367 -0
- package/frontend/src/components/plugins/ScopedPluginCommands.tsx +142 -0
- package/frontend/src/components/plugins/plugin-frame.ts +44 -33
- package/frontend/src/components/plugins/scoped-plugin-operations.ts +28 -0
- package/frontend/src/components/workspace/DrawerChat.tsx +110 -0
- package/frontend/src/components/workspace/DrawerLayout.tsx +196 -0
- package/frontend/src/components/workspace/DrawerMarkup.tsx +49 -0
- package/frontend/src/components/workspace/PluginChunkLibrary.tsx +92 -0
- package/frontend/src/components/workspace/PluginHome.tsx +76 -0
- package/frontend/src/components/workspace/WorkspaceDrawers.tsx +96 -0
- package/frontend/src/components/workspace/WorkspacePage.tsx +95 -0
- package/frontend/src/components/workspace/usePluginDesign.ts +38 -0
- package/frontend/src/index.css +409 -136
- package/frontend/src/pages/HelpPage.tsx +15 -46
- package/frontend/src/pages/MemoryPage.tsx +19 -36
- package/frontend/src/pages/SettingsPage.tsx +1 -1
- package/metadata.plugin.schema.json +53 -227
- package/package.json +1 -1
- package/scaffold/.agent/skills/plugin/SKILL.md +13 -11
- package/scaffold/.agent/skills/plugin/evals/README.md +14 -21
- package/scaffold/.agent/skills/plugin/evals/cases/01-fabricated-seed.mjs +15 -18
- package/scaffold/.agent/skills/plugin/evals/cases/02-reassuring-default.mjs +19 -24
- package/scaffold/.agent/skills/plugin/evals/cases/03-declared-template.mjs +12 -20
- package/scaffold/.agent/skills/plugin/evals/cases/04-home-collects-credential.mjs +35 -0
- package/scaffold/.agent/skills/plugin/evals/cases/05-host-leak-in-scaffold.mjs +8 -28
- package/scaffold/.agent/skills/plugin/evals/cases/06-correct-plugin.mjs +85 -47
- package/scaffold/.agent/skills/plugin/evals/run.mjs +17 -18
- package/scaffold/.agent/skills/plugin/prompts/05-credentials.md +4 -4
- package/scaffold/.agent/skills/plugin/prompts/07-scaffold.md +2 -2
- package/scaffold/.agent/skills/plugin/prompts/08-verify.md +4 -4
- package/scaffold/.agent/skills/plugin/references/anti-patterns.md +2 -2
- package/scaffold/.agent/skills/plugin/references/generative-home.md +38 -0
- package/scaffold/.agent/skills/plugin/references/scaffold.md +5 -5
- package/scaffold/.agent/skills/plugin/references/surfaces.md +13 -4
- package/scaffold/.agent/skills/plugin/scripts/record.mjs +75 -153
- package/scaffold/.agent/skills/plugin/subagents/plugin-reviewer.md +4 -4
- package/scaffold/.agent/skills/total-recall/plugins/auth/DESIGN.md +76 -0
- package/scaffold/.agent/skills/total-recall/plugins/auth/README.md +3 -1
- package/scaffold/.agent/skills/total-recall/plugins/auth/cli.mjs +20 -15
- package/scaffold/.agent/skills/total-recall/plugins/auth/package-lock.json +7 -7
- package/scaffold/.agent/skills/total-recall/plugins/auth/package.json +2 -1
- package/scaffold/.agent/skills/total-recall/plugins/auth/plugin.json +13 -51
- package/scaffold/.agent/skills/total-recall/plugins/auth/src/cli-secret.mjs +20 -1
- package/scaffold/.agent/skills/total-recall/plugins/auth/src/secrets-store.mjs +12 -1
- package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/access-overview.md +17 -0
- package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/agent-login.md +20 -0
- package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/baseline-audit.md +22 -0
- package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/credential-repository-binding.md +17 -0
- package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/credential-store-maintenance.md +17 -0
- package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/dashboard-password.md +18 -0
- package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/dashboard-sessions.md +18 -0
- package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/endpoint-probe.md +23 -0
- package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/google-sign-in.md +21 -0
- package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/mesh-machines.md +16 -0
- package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/passkey-enrollment.md +21 -0
- package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/registered-brains.md +16 -0
- package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/scoped-access-keys.md +17 -0
- package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/secret-inventory.md +25 -0
- package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/signing-key-rotation.md +22 -0
- package/scaffold/.agent/skills/total-recall/plugins/auth/ui/home.js +375 -0
- package/scaffold/.agent/skills/total-recall/plugins/automations/BRICK.md +7 -0
- package/scaffold/.agent/skills/total-recall/plugins/automations/DESIGN.md +53 -0
- package/scaffold/.agent/skills/total-recall/plugins/automations/LICENSE +21 -0
- package/scaffold/.agent/skills/total-recall/plugins/automations/README.md +66 -0
- package/scaffold/.agent/skills/total-recall/plugins/automations/adapters.mjs +247 -0
- package/scaffold/.agent/skills/total-recall/plugins/automations/capability/index.mjs +16 -0
- package/scaffold/.agent/skills/total-recall/plugins/automations/cli.mjs +130 -0
- package/{src/core/plugin-cron.mjs → scaffold/.agent/skills/total-recall/plugins/automations/cron.mjs} +1 -3
- package/scaffold/.agent/skills/total-recall/plugins/automations/inventory.mjs +88 -0
- package/scaffold/.agent/skills/total-recall/plugins/automations/package-lock.json +7661 -0
- package/scaffold/.agent/skills/total-recall/plugins/automations/package.json +36 -0
- package/scaffold/.agent/skills/total-recall/plugins/automations/plugin.json +151 -0
- package/scaffold/.agent/skills/total-recall/plugins/automations/scheduler.mjs +246 -0
- package/scaffold/.agent/skills/total-recall/plugins/automations/ui/automations.js +2 -0
- package/scaffold/.agent/skills/total-recall/plugins/automations/ui/chunks/control-ledger.md +42 -0
- package/scaffold/.agent/skills/total-recall/plugins/automations/ui/chunks/local-inventory-triage.md +17 -0
- package/scaffold/.agent/skills/total-recall/plugins/automations/ui/chunks/pending-control.md +39 -0
- package/scaffold/.agent/skills/total-recall/plugins/automations/ui/chunks/run-evidence.md +41 -0
- package/scaffold/.agent/skills/total-recall/plugins/automations/ui/chunks/schedule-vs-run-evidence.md +17 -0
- package/scaffold/.agent/skills/total-recall/plugins/automations/ui/chunks/source-coverage.md +41 -0
- package/scaffold/.agent/skills/total-recall/plugins/automations/ui/home.js +278 -0
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/DESIGN.md +53 -0
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/cli.mjs +23 -0
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/commands/run-core.mjs +5 -3
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/core/check.mjs +61 -7
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/core/report-data.mjs +40 -14
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/core/report.mjs +15 -40
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/package-lock.json +7 -7
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/package.json +2 -1
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/plugin.json +40 -40
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/chunks/config.md +15 -0
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/chunks/detect.md +15 -0
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/chunks/gate.md +15 -0
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/chunks/init.md +15 -0
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/chunks/report.md +17 -0
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/chunks/run.md +17 -0
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/chunks/snapshot.md +15 -0
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/code-quality-report.mjs +55 -23
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/home.mjs +214 -0
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/DESIGN.md +146 -0
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/package-lock.json +7 -7
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/package.json +2 -1
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/plugin.json +51 -34
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/src/command.mjs +1 -1
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/create.md +35 -0
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/history.md +35 -0
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/library.md +49 -0
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/list.md +42 -0
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/promote.md +40 -0
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/read.md +25 -0
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/remove.md +26 -0
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/rollback.md +26 -0
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/show.md +53 -0
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/status.md +40 -0
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/test-path.md +38 -0
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/test.md +46 -0
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/update.md +32 -0
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/home.js +533 -0
- package/scaffold/.agent/skills/total-recall/plugins/embeddings/DESIGN.md +110 -0
- package/scaffold/.agent/skills/total-recall/plugins/embeddings/package-lock.json +7 -7
- package/scaffold/.agent/skills/total-recall/plugins/embeddings/package.json +2 -1
- package/scaffold/.agent/skills/total-recall/plugins/embeddings/plugin.json +13 -10
- package/scaffold/.agent/skills/total-recall/plugins/embeddings/ui/chunks/benchmark.md +49 -0
- package/scaffold/.agent/skills/total-recall/plugins/embeddings/ui/chunks/coverage.md +53 -0
- package/scaffold/.agent/skills/total-recall/plugins/embeddings/ui/chunks/models.md +43 -0
- package/scaffold/.agent/skills/total-recall/plugins/embeddings/ui/chunks/pull.md +41 -0
- package/scaffold/.agent/skills/total-recall/plugins/embeddings/ui/chunks/status.md +59 -0
- package/scaffold/.agent/skills/total-recall/plugins/embeddings/ui/home.js +353 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/DESIGN.md +31 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/README.md +136 -0
- package/scaffold/.agent/skills/total-recall/plugins/{git-sentinel → git}/cli.mjs +140 -24
- package/scaffold/.agent/skills/total-recall/plugins/{git-sentinel → git}/package-lock.json +9 -9
- package/scaffold/.agent/skills/total-recall/plugins/{git-sentinel → git}/package.json +4 -2
- package/scaffold/.agent/skills/total-recall/plugins/git/plugin.json +151 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/src/lib/context.mjs +94 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/src/lib/phase3-spec-support.mjs +50 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/src/lib/runtime.mjs +40 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/src/lib/spec-support.mjs +51 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/_support.mjs +195 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/auth.mjs +201 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/bisect.mjs +40 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/cli-meta.mjs +159 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/commit-memory.mjs +54 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/commit.mjs +46 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/fleet.mjs +174 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/force-push.mjs +58 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/group.mjs +119 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/handoff.mjs +59 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/message.mjs +22 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/resolve.mjs +60 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/rules.mjs +81 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/secret-firewall.mjs +92 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/undo.mjs +156 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/unmerged.mjs +182 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/why.mjs +16 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/ui/chunks/change-comparison.md +27 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/ui/chunks/commit-identity.md +22 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/ui/chunks/create-worktree.md +25 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/ui/chunks/registered-worktrees.md +22 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/ui/chunks/remove-worktree.md +23 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/ui/chunks/repository-ledger.md +25 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/ui/chunks/unmerged-work.md +22 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/ui/chunks/upstream-divergence.md +17 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/ui/chunks/worktree-conflict-triage.md +17 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/ui/chunks/worktree-terminal.md +22 -0
- package/scaffold/.agent/skills/total-recall/plugins/git/ui/home.js +273 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/DESIGN.md +35 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/README.md +4 -5
- package/scaffold/.agent/skills/total-recall/plugins/mesh/cli.mjs +9 -3
- package/scaffold/.agent/skills/total-recall/plugins/mesh/package-lock.json +7 -7
- package/scaffold/.agent/skills/total-recall/plugins/mesh/package.json +2 -1
- package/scaffold/.agent/skills/total-recall/plugins/mesh/plugin.json +37 -39
- package/scaffold/.agent/skills/total-recall/plugins/mesh/src/cli/mesh.mjs +5 -3
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/active-device-dispatch.md +22 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/control-probe.md +25 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/control-server.md +22 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/credential-readiness.md +23 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/elected-leader.md +22 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/enrollment-key.md +22 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/file-receipt.md +25 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/fleet-execution.md +23 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/fleet-presence.md +23 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/interactive-ssh.md +22 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/local-enrollment.md +23 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/mesh-policy.md +23 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/network-atlas.md +25 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/node-roster.md +26 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/node-selection-proof.md +17 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/owner-observations.md +23 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/peer-path.md +23 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/pinned-leader.md +24 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/reachability-evidence-ladder.md +17 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/recorded-login.md +23 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/remote-execution.md +22 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/secret-grants.md +26 -0
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/{card.js → home.js} +93 -22
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/DESIGN.md +86 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/README.md +44 -9
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/capability/BRICK.md +1 -1
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/capability/index.mjs +18 -6
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/cli.mjs +128 -24
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/package-lock.json +7 -7
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/package.json +3 -2
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/plugin.json +188 -34
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/skills/meta-harness/SKILL.md +17 -3
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/adoption.mjs +2 -2
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/alerts.mjs +3 -3
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/cascade.mjs +92 -18
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/chat.mjs +80 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/control.mjs +145 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/coordinator.mjs +42 -21
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/dispatch-request.mjs +4 -2
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/dispatch.mjs +33 -9
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/documentation.mjs +55 -11
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/executor.mjs +26 -4
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/gate-adapters/hermes.mjs +29 -1
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/gate-adapters/index.mjs +1 -1
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/included-usage.mjs +1 -1
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/jobs.mjs +84 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/learner.mjs +3 -12
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/maintenance.mjs +17 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/mcp-server.mjs +228 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/process-manager.mjs +25 -2
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/reasoning.mjs +1 -1
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/remote-operation.mjs +5 -1
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/review.mjs +34 -3
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/reviews.mjs +25 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/router.mjs +1 -1
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/session/claude.mjs +319 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/session/codex.mjs +387 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/session/result.mjs +67 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/session/resume.mjs +373 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/session/run.mjs +223 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/session-jobs.mjs +72 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/setup.mjs +6 -3
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/termination.mjs +16 -12
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/threads.mjs +32 -1
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/usage-queue.mjs +1 -1
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/verify-ssss.mjs +3 -3
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/worker.mjs +285 -40
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/worktree.mjs +76 -9
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/adapter-docs-freshness.md +16 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/chat-handoff.md +26 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/fleet-maintenance.md +21 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/harness-inventory.md +21 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/included-access.md +18 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/included-usage-verification.md +15 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/independent-review.md +17 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/managed-execution.md +20 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/official-documentation.md +18 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/quota-recovery.md +21 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/review-routing-decision.md +16 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/route-work.md +18 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/routing-evidence.md +18 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/run-ledger.md +18 -0
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/home.js +198 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/DESIGN.md +75 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/README.md +2 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/cli.mjs +64 -32
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/package-lock.json +7 -7
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/package.json +2 -1
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/plugin.json +10 -44
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/generate.mjs +5 -4
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/graph.mjs +3 -4
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/ingest.mjs +23 -18
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/mesh-vaults.mjs +8 -3
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/refresh-diagnostics.mjs +44 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/refresh.mjs +123 -113
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/search.mjs +3 -5
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/token.mjs +21 -47
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/upstream-watcher.mjs +17 -6
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/auto-refresh.md +18 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/bootstrap-pages.md +18 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/generate-wiki.md +21 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/generator-settings.md +18 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/host-probe.md +18 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/ingest-preview.md +18 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/link-hygiene.md +21 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/link-topology.md +19 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/passage-search.md +19 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/propagation-plan.md +18 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/provider-credentials.md +18 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/refresh-report.md +18 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/task-evidence.md +22 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/upstream-record.md +18 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/watch-upstream.md +18 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/wiki-atlas.md +19 -0
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/panel.js +261 -513
- package/scaffold/.agent/skills/total-recall/plugins/security/DESIGN.md +84 -0
- package/scaffold/.agent/skills/total-recall/plugins/security/README.md +4 -2
- package/scaffold/.agent/skills/total-recall/plugins/security/cli.mjs +7 -19
- package/scaffold/.agent/skills/total-recall/plugins/security/package-lock.json +7 -7
- package/scaffold/.agent/skills/total-recall/plugins/security/package.json +2 -3
- package/scaffold/.agent/skills/total-recall/plugins/security/plugin.json +19 -52
- package/scaffold/.agent/skills/total-recall/plugins/security/ui/chunks/device-evidence.md +21 -0
- package/scaffold/.agent/skills/total-recall/plugins/security/ui/chunks/evidence-desk.md +18 -0
- package/scaffold/.agent/skills/total-recall/plugins/security/ui/chunks/guided-device-review.md +17 -0
- package/scaffold/.agent/skills/total-recall/plugins/security/ui/chunks/host-and-network.md +21 -0
- package/scaffold/.agent/skills/total-recall/plugins/security/ui/chunks/https-headers.md +17 -0
- package/scaffold/.agent/skills/total-recall/plugins/security/ui/chunks/mesh-coverage.md +18 -0
- package/scaffold/.agent/skills/total-recall/plugins/security/ui/chunks/private-security-tools.md +16 -0
- package/scaffold/.agent/skills/total-recall/plugins/security/ui/chunks/single-origin-header-check.md +17 -0
- package/scaffold/.agent/skills/total-recall/plugins/security/ui/chunks/source-review.md +21 -0
- package/scaffold/.agent/skills/total-recall/plugins/security/ui/chunks/ssh-permission-plan.md +17 -0
- package/scaffold/.agent/skills/total-recall/plugins/security/ui/home.js +283 -0
- package/scaffold/.agent/skills/total-recall/plugins/ssss/DESIGN.md +93 -0
- package/scaffold/.agent/skills/total-recall/plugins/ssss/package-lock.json +2 -2
- package/scaffold/.agent/skills/total-recall/plugins/ssss/package.json +2 -1
- package/scaffold/.agent/skills/total-recall/plugins/ssss/plugin.json +5 -3
- package/scaffold/.agent/skills/total-recall/plugins/ssss/ui/chunks/conformance.md +26 -0
- package/scaffold/.agent/skills/total-recall/plugins/ssss/ui/chunks/registry.md +37 -0
- package/scaffold/.agent/skills/total-recall/plugins/ssss/ui/chunks/repair.md +42 -0
- package/scaffold/.agent/skills/total-recall/plugins/ssss/ui/chunks/scaffold.md +33 -0
- package/scaffold/.agent/skills/total-recall/plugins/ssss/ui/chunks/status.md +43 -0
- package/scaffold/.agent/skills/total-recall/plugins/ssss/ui/chunks/validate.md +34 -0
- package/scaffold/.agent/skills/total-recall/plugins/ssss/ui/chunks/validation-diagnostics.md +17 -0
- package/scaffold/.agent/skills/total-recall/plugins/ssss/ui/chunks/workspace-registry-preflight.md +17 -0
- package/scaffold/.agent/skills/total-recall/plugins/ssss/ui/home.js +348 -0
- package/scaffold/.agent/skills/total-recall/references/operations.md +3 -1
- package/src/cli/agent.mjs +1 -1
- package/src/cli/api.mjs +3 -3
- package/src/cli/brief.mjs +3 -0
- package/src/cli/command.mjs +41 -2
- package/src/cli/config.mjs +16 -0
- package/src/cli/connect.mjs +2 -7
- package/src/cli/dream.mjs +93 -69
- package/src/cli/harness.mjs +4 -4
- package/src/cli/help.mjs +1 -1
- package/src/cli/init.mjs +0 -25
- package/src/cli/lessons.mjs +51 -0
- package/src/cli/memory-plugin.mjs +1 -1
- package/src/cli/plugin/chunks.mjs +145 -0
- package/src/cli/plugin/copies.mjs +64 -14
- package/src/cli/plugin/create.mjs +30 -59
- package/src/cli/plugin/index.mjs +31 -16
- package/src/cli/plugin/install.mjs +10 -15
- package/src/cli/plugin/remove.mjs +1 -1
- package/src/cli/plugin/search.mjs +2 -2
- package/src/cli/preflight.mjs +19 -6
- package/src/cli/proposals.mjs +1 -1
- package/src/cli/recall.mjs +66 -23
- package/src/cli/remember.mjs +3 -14
- package/src/cli/server.mjs +18 -0
- package/src/cli/setup.mjs +2 -9
- package/src/cli/start.mjs +1 -0
- package/src/cli/startup.mjs +19 -0
- package/src/cli/task.mjs +9 -2
- package/src/cli/update.mjs +6 -2
- package/src/core/access-ledger.mjs +78 -0
- package/src/core/agent-manager.mjs +2 -2
- package/src/core/app-deploy/design-tokens.mjs +14 -9
- package/src/core/app-deploy/ui-elements.mjs +1 -1
- package/src/core/brain-locate.mjs +15 -0
- package/src/core/brain-registry.mjs +5 -0
- package/src/core/brain-updates.mjs +35 -11
- package/src/core/claude-hooks.mjs +3 -1
- package/src/core/cleanup-task.mjs +15 -0
- package/src/core/cli-commands.mjs +2 -0
- package/src/core/cli-maintenance.mjs +4 -1
- package/src/core/cli-semantic-index.mjs +23 -3
- package/src/core/context-compiler.mjs +20 -0
- package/src/core/daemon-control.mjs +5 -1
- package/src/core/daemon-loop.mjs +39 -62
- package/src/core/dashboard-bundle.mjs +261 -0
- package/src/core/default-plugins.mjs +1 -1
- package/src/core/dream.mjs +33 -105
- package/src/core/ensure-dependencies.mjs +152 -0
- package/src/core/fast-recall.mjs +2 -2
- package/src/core/field-evaluation.mjs +23 -0
- package/src/core/gate-mode.mjs +1 -1
- package/src/core/harness-hooks.mjs +14 -2
- package/src/core/lesson-hooks.mjs +74 -0
- package/src/core/lesson-memory.mjs +24 -0
- package/src/core/lesson-sessions.mjs +52 -0
- package/src/core/lessons.mjs +96 -0
- package/src/core/memory-brain.mjs +30 -8
- package/src/core/meta-harness.mjs +2 -2
- package/src/core/optimizer.mjs +66 -165
- package/src/core/plugin-activation.mjs +63 -20
- package/src/core/plugin-contracts/{card.mjs → manifest.mjs} +26 -57
- package/src/core/plugin-contracts/startup-check.mjs +49 -0
- package/src/core/plugin-contracts/ui.mjs +9 -3
- package/src/core/plugin-distribution.mjs +6 -6
- package/src/core/plugin-lifecycle.mjs +58 -0
- package/src/core/plugin-loader.mjs +21 -8
- package/src/core/plugin-runner.mjs +21 -10
- package/src/core/plugin-runtime.mjs +40 -1
- package/src/core/plugin-startup-checks.mjs +44 -0
- package/src/core/plugin-state.mjs +19 -5
- package/src/core/plugin-store.mjs +64 -33
- package/src/core/post-mortem.mjs +52 -36
- package/src/core/preflight-gate.mjs +23 -2
- package/src/core/project-id.mjs +15 -5
- package/src/core/proposal-applier.mjs +31 -2
- package/src/core/repo-sync.mjs +4 -6
- package/src/core/required-plugins.mjs +57 -10
- package/src/core/rule-length.mjs +23 -0
- package/src/core/runtime.mjs +1 -1
- package/src/core/scheduler.mjs +35 -43
- package/src/core/schema.mjs +3 -2
- package/src/core/search.mjs +4 -3
- package/src/core/server-service.mjs +148 -0
- package/src/core/session-watcher.mjs +19 -1
- package/src/core/skill-gap.mjs +16 -0
- package/src/core/ssss-kernel-bridge.mjs +32 -4
- package/src/core/ssss-operation-service.mjs +1 -0
- package/src/core/startup-health.mjs +34 -4
- package/src/core/surface.mjs +65 -54
- package/src/core/task-executors.mjs +54 -106
- package/src/core/testing/plugin-fixture.mjs +22 -21
- package/src/core/throttled-fetch.mjs +25 -18
- package/src/core/ui-chunk-choice.mjs +77 -0
- package/src/core/ui-chunk.registry.json +23 -0
- package/src/core/ui-chunks.mjs +434 -0
- package/src/core/validated-write.mjs +1 -0
- package/src/core/vault-cache.mjs +58 -59
- package/src/core/vector-field.mjs +134 -192
- package/src/core/workspace-compositions.mjs +151 -0
- package/src/core/workspace-drawers.mjs +79 -0
- package/src/server/api.mjs +4 -27
- package/src/server/index.mjs +28 -21
- package/src/server/invoke-core-child.mjs +24 -0
- package/src/server/invoke-core-operations.mjs +102 -0
- package/src/server/memory-events.mjs +31 -0
- package/src/server/plugin-brain-targets.mjs +89 -0
- package/src/server/rest.mjs +2 -0
- package/src/server/route-inventory.mjs +3 -2
- package/src/server/route-manifest.json +47 -55
- package/src/server/routes/_shared.mjs +7 -14
- package/src/server/routes/brains.mjs +29 -62
- package/src/server/routes/context.mjs +0 -41
- package/src/server/routes/dashboard.mjs +26 -0
- package/src/server/routes/invoke.mjs +26 -1
- package/src/server/routes/plugins.mjs +154 -45
- package/src/server/routes/ssss.mjs +0 -169
- package/src/server/routes/system.mjs +0 -15
- package/src/server/routes/tasks.mjs +0 -26
- package/src/server/routes/ui-chunks.mjs +192 -0
- package/src/server/routes/vault.mjs +2 -23
- package/frontend/dist/assets/index-DD4qONvH.js +0 -5607
- package/frontend/dist/assets/index-DtwsDyFM.css +0 -1
- package/frontend/src/components/plugins/card/CardEngine.tsx +0 -108
- package/frontend/src/components/plugins/card/CardScenes.tsx +0 -103
- package/frontend/src/components/plugins/card/ExecutionPicker.tsx +0 -64
- package/frontend/src/components/plugins/card/args.ts +0 -28
- package/frontend/src/components/plugins/card/card.css +0 -32
- package/frontend/src/components/plugins/card/cli-line.ts +0 -13
- package/frontend/src/components/plugins/card/contract.ts +0 -91
- package/frontend/src/components/plugins/card/format.ts +0 -49
- package/frontend/src/components/plugins/card/runner-context.ts +0 -11
- package/frontend/src/components/plugins/card/runner.tsx +0 -43
- package/frontend/src/components/plugins/card/theme.ts +0 -35
- package/frontend/src/components/plugins/card/use-source.ts +0 -22
- package/frontend/src/components/plugins/card/widgets.tsx +0 -94
- package/frontend/src/components/plugins/workspace/WorkspaceHost.tsx +0 -23
- package/frontend/src/pages/PluginsPage.tsx +0 -1719
- package/scaffold/.agent/skills/plugin/evals/cases/04-card-collects-credential.mjs +0 -47
- package/scaffold/.agent/skills/plugin/prompts/06-card.md +0 -46
- package/scaffold/.agent/skills/plugin/references/card.md +0 -90
- package/scaffold/.agent/skills/plugin/subagents/card-designer.md +0 -60
- package/scaffold/.agent/skills/total-recall/plugins/auth/ui/DESIGN.md +0 -67
- package/scaffold/.agent/skills/total-recall/plugins/auth/ui/card.js +0 -1179
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/DESIGN.md +0 -32
- package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/card.js +0 -588
- package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/card.js +0 -575
- package/scaffold/.agent/skills/total-recall/plugins/embeddings/ui/DESIGN.md +0 -32
- package/scaffold/.agent/skills/total-recall/plugins/embeddings/ui/card.js +0 -482
- package/scaffold/.agent/skills/total-recall/plugins/git-sentinel/README.md +0 -53
- package/scaffold/.agent/skills/total-recall/plugins/git-sentinel/plugin.json +0 -129
- package/scaffold/.agent/skills/total-recall/plugins/git-sentinel/ui/DESIGN.md +0 -100
- package/scaffold/.agent/skills/total-recall/plugins/git-sentinel/ui/card.js +0 -637
- package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/DESIGN.md +0 -217
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/DESIGN.md +0 -32
- package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/card.js +0 -1276
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/DESIGN.md +0 -45
- package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/card.js +0 -1401
- package/scaffold/.agent/skills/total-recall/plugins/security/scripts/build-ui.mjs +0 -4
- package/scaffold/.agent/skills/total-recall/plugins/security/ui/DESIGN.md +0 -41
- package/scaffold/.agent/skills/total-recall/plugins/security/ui/card.js +0 -396
- package/scaffold/.agent/skills/total-recall/plugins/security/ui/panel.js +0 -98
- package/scaffold/.agent/skills/total-recall/plugins/ssss/ui/DESIGN.md +0 -15
- package/scaffold/.agent/skills/total-recall/plugins/ssss/ui/card.js +0 -182
- package/src/core/append-log.mjs +0 -131
- package/src/core/plugin-tasks.mjs +0 -173
- package/templates/onboarding-interview.md +0 -82
- /package/scaffold/.agent/skills/total-recall/plugins/{git-sentinel → git}/LICENSE +0 -0
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/** Local task capsules: explicit required rules, ranked supporting knowledge, complete-render accounting. */
|
|
2
2
|
|
|
3
|
+
import path from 'node:path';
|
|
3
4
|
import { getNodes } from './vault-cache.mjs';
|
|
5
|
+
import { recordAccess } from './access-ledger.mjs';
|
|
6
|
+
import { brainDir as globalBrainDir } from './local-config.mjs';
|
|
4
7
|
import crypto from 'node:crypto';
|
|
5
8
|
import { selectRules, assembleContext, curatedRules, ruleFingerprint, RULE_CATEGORIES } from './context-policy.mjs';
|
|
6
9
|
import { retrieveTaskKnowledge, summarizeRetrieval } from './task-context.mjs';
|
|
@@ -142,9 +145,26 @@ export async function compileContext({
|
|
|
142
145
|
result.stats.slots = { invariants: { nodes: rules.filter(n => n.category === 'invariants').length,
|
|
143
146
|
tokens: result.stats.required_tokens } };
|
|
144
147
|
result.stats.slots_filled = result.stats.contributions.length;
|
|
148
|
+
// DECAY-01: a capsule is a real use of the rules and memories it carries.
|
|
149
|
+
recordCapsuleAccess(derivedDir, rules, knowledge.contributions);
|
|
145
150
|
return result;
|
|
146
151
|
}
|
|
147
152
|
|
|
153
|
+
/**
|
|
154
|
+
* Record each rule and memory a capsule carries in the ledger of the brain that owns it, so
|
|
155
|
+
* decay in the global brain sees global rules used by every project.
|
|
156
|
+
*/
|
|
157
|
+
export function recordCapsuleAccess(derivedDir, rules = [], contributions = [], globalDerivedDir = path.join(globalBrainDir, 'memory-derived')) {
|
|
158
|
+
const owned = { project: [], global: [] };
|
|
159
|
+
for (const node of rules) (node._layer === 'global' ? owned.global : owned.project).push(node.slug);
|
|
160
|
+
for (const { id } of contributions || []) {
|
|
161
|
+
const match = /^vault:(global|project):(.+)$/.exec(String(id || ''));
|
|
162
|
+
if (match) owned[match[1]].push(match[2]);
|
|
163
|
+
}
|
|
164
|
+
if (derivedDir) recordAccess(derivedDir, owned.project);
|
|
165
|
+
recordAccess(derivedDir && path.resolve(derivedDir) === path.resolve(globalDerivedDir) ? derivedDir : globalDerivedDir, owned.global);
|
|
166
|
+
}
|
|
167
|
+
|
|
148
168
|
/**
|
|
149
169
|
* Second line of every text capsule, so output that is truncated or piped through
|
|
150
170
|
* `head` still carries the rule (the rule once sat at line 544 of the output and
|
|
@@ -33,7 +33,11 @@ export function getDaemonObservation() { return observeDaemon(brainDir); }
|
|
|
33
33
|
* @returns {'running'|'dead'|'not_started'|'conflict'|'unknown'}
|
|
34
34
|
*/
|
|
35
35
|
export function getDaemonStatus() {
|
|
36
|
-
|
|
36
|
+
// A supervised daemon can run from a different verified installation than the server.
|
|
37
|
+
const entry = process.env.TR_SUPERVISED_DAEMON_ENTRY;
|
|
38
|
+
const { status } = process.env.DISABLE_DAEMON === 'true' && entry && path.isAbsolute(entry)
|
|
39
|
+
? observeDaemon(brainDir, { expectedEntry: entry })
|
|
40
|
+
: getDaemonObservation();
|
|
37
41
|
return status === 'not-started' ? 'not_started' : status === 'stopped' ? 'dead' : status;
|
|
38
42
|
}
|
|
39
43
|
|
package/src/core/daemon-loop.mjs
CHANGED
|
@@ -4,8 +4,8 @@ import { loadPluginModule as __loadOwnedPlugin } from './plugin-runtime.mjs';
|
|
|
4
4
|
*
|
|
5
5
|
* Durable worker over the open task envelope queue.
|
|
6
6
|
* - Dispatches via executor registry (fail-loud on unknown)
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
7
|
+
* - Automations owns scheduled maintenance; empty queues stay empty
|
|
8
|
+
* - Executes dream tasks scheduled by the automations plugin
|
|
9
9
|
* - Ingests sessions on boot; recompiles surfaces every N ticks
|
|
10
10
|
* - Auto-syncs all .md files from registered repos into Total Recall
|
|
11
11
|
*
|
|
@@ -17,7 +17,7 @@ import { DAEMON_PID_FILE } from './daemon-control.mjs';
|
|
|
17
17
|
import fs from 'fs';
|
|
18
18
|
import { fileURLToPath } from 'node:url';
|
|
19
19
|
import { readProcessCommand, entryPathHint, shouldHonorPidLock } from './pid-lock.mjs';
|
|
20
|
-
import { createScheduler, updateTaskStatus
|
|
20
|
+
import { createScheduler, updateTaskStatus } from './scheduler.mjs';
|
|
21
21
|
import { scanAndIngest } from './session-watcher.mjs';
|
|
22
22
|
import { syncAllRepos } from './repo-sync.mjs';
|
|
23
23
|
import { refreshProviderUsage } from './usage-fetcher.mjs';
|
|
@@ -26,7 +26,7 @@ import { updateQueueItem } from './research-queue.mjs';
|
|
|
26
26
|
import { agentDir, brainDir, detectProjectBrain } from './config.mjs';
|
|
27
27
|
import { runCrons } from './crons.mjs';
|
|
28
28
|
import { dispatchTask as registryDispatch } from './task-executors.mjs';
|
|
29
|
-
import {
|
|
29
|
+
import { publishTaskSchedulerProtocol } from './task-envelope.mjs';
|
|
30
30
|
|
|
31
31
|
const AGENT_DIR = agentDir;
|
|
32
32
|
const BRAIN_DIR = brainDir;
|
|
@@ -61,8 +61,16 @@ const RECOMPILE_EVERY_N_TASKS = 20;
|
|
|
61
61
|
const TASK_SLEEP_MS = 10000;
|
|
62
62
|
const EMPTY_SLEEP_MS = 30000;
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
/** An empty queue only sleeps. Plugin services own recurring task creation. */
|
|
65
|
+
export async function nextDaemonTask(scheduler, { localOnly = false, sleep = ms => new Promise(resolve => setTimeout(resolve, ms)) } = {}) {
|
|
66
|
+
const next = scheduler.next({ localOnly });
|
|
67
|
+
if (!next.task) {
|
|
68
|
+
const sleepMs = localOnly ? TASK_SLEEP_MS : EMPTY_SLEEP_MS;
|
|
69
|
+
logger.info({ subsystem: 'daemon-loop', message: `Queue empty — sleeping ${sleepMs}ms` });
|
|
70
|
+
await sleep(sleepMs);
|
|
71
|
+
}
|
|
72
|
+
return next;
|
|
73
|
+
}
|
|
66
74
|
|
|
67
75
|
function executorContext(runtimeConfig) {
|
|
68
76
|
return {
|
|
@@ -242,6 +250,7 @@ let running = true;
|
|
|
242
250
|
let vaultWatcher = null;
|
|
243
251
|
let shuttingDown = false;
|
|
244
252
|
let schedulerProtocolActive = false;
|
|
253
|
+
let lastLessonScan = 0;
|
|
245
254
|
|
|
246
255
|
// Upper bound on a graceful stop. A loop iteration can be mid-task, so the
|
|
247
256
|
// signal cannot exit instantly — but it must exit *eventually*.
|
|
@@ -259,7 +268,7 @@ import { releaseLease } from './leader-election.mjs';
|
|
|
259
268
|
* daemon.log across three separate SIGTERMs. The fallback timer bounds that, so
|
|
260
269
|
* even a wedged iteration cannot keep the daemon alive indefinitely.
|
|
261
270
|
*/
|
|
262
|
-
let
|
|
271
|
+
let stopPluginServices = null;
|
|
263
272
|
let stopCliMaintenance = null;
|
|
264
273
|
let stopAutomaticUpdates = null;
|
|
265
274
|
|
|
@@ -269,7 +278,7 @@ function shutdown(signal) {
|
|
|
269
278
|
logger.info({ subsystem: 'daemon-loop', message: `${signal} received — shutting down gracefully` });
|
|
270
279
|
running = false;
|
|
271
280
|
if (vaultWatcher) vaultWatcher.stop();
|
|
272
|
-
if (
|
|
281
|
+
if (stopPluginServices) stopPluginServices();
|
|
273
282
|
stopCliMaintenance?.();
|
|
274
283
|
stopAutomaticUpdates?.();
|
|
275
284
|
|
|
@@ -451,15 +460,16 @@ async function main() {
|
|
|
451
460
|
}
|
|
452
461
|
}
|
|
453
462
|
|
|
454
|
-
let emptyTicks = 0;
|
|
455
463
|
|
|
456
|
-
//
|
|
457
|
-
//
|
|
464
|
+
// Per-node services owned by plugins (scheduled plugin tasks belong to
|
|
465
|
+
// automations) start here; core runs whatever active plugins declare.
|
|
458
466
|
try {
|
|
459
|
-
const {
|
|
460
|
-
|
|
467
|
+
const { startPluginDaemonServices } = await import('./plugin-runtime.mjs');
|
|
468
|
+
const services = await startPluginDaemonServices();
|
|
469
|
+
stopPluginServices = services.stop;
|
|
470
|
+
logger.info('daemon-loop', `Plugin daemon services started: ${services.started.join(', ') || 'none'}${services.failed.length ? `; failed: ${services.failed.join(', ')}` : ''}`);
|
|
461
471
|
} catch (err) {
|
|
462
|
-
logger.warn('daemon-loop', `Plugin
|
|
472
|
+
logger.warn('daemon-loop', `Plugin daemon services failed to start: ${err.message}`);
|
|
463
473
|
}
|
|
464
474
|
|
|
465
475
|
while (running) {
|
|
@@ -560,14 +570,20 @@ async function main() {
|
|
|
560
570
|
}
|
|
561
571
|
}
|
|
562
572
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
573
|
+
const localOnly = !await isLeader();
|
|
574
|
+
|
|
575
|
+
// Local transcripts stay on their node. Followers also queue and run reviews.
|
|
576
|
+
if (Date.now() - lastLessonScan >= 60_000) {
|
|
577
|
+
lastLessonScan = Date.now();
|
|
578
|
+
try {
|
|
579
|
+
scanAndIngest(SESSIONS_DIR);
|
|
580
|
+
const { enqueueSessionReviews } = await import('./lessons.mjs');
|
|
581
|
+
enqueueSessionReviews({ brainDir: BRAIN_DIR });
|
|
582
|
+
} catch (error) { logger.warn('daemon-loop', `Local lesson ingest failed: ${error.message}`); }
|
|
567
583
|
}
|
|
568
584
|
|
|
569
585
|
// Periodically recompile surfaces (LEADER ONLY)
|
|
570
|
-
if (taskCount > 0 && taskCount % RECOMPILE_EVERY_N_TASKS === 0) {
|
|
586
|
+
if (!localOnly && taskCount > 0 && taskCount % RECOMPILE_EVERY_N_TASKS === 0) {
|
|
571
587
|
logger.info({ subsystem: 'daemon-loop', message: 'Running scheduled surface recompile...' });
|
|
572
588
|
try {
|
|
573
589
|
const { compileSurface } = await import('./surface.mjs');
|
|
@@ -581,16 +597,6 @@ async function main() {
|
|
|
581
597
|
logger.info({ subsystem: 'daemon-loop', message: `Surface recompile error: ${err.message}` });
|
|
582
598
|
}
|
|
583
599
|
|
|
584
|
-
try {
|
|
585
|
-
const { compactAppendLogs } = await import('./append-log.mjs');
|
|
586
|
-
const compactResult = compactAppendLogs();
|
|
587
|
-
if (compactResult.logs_compacted > 0) {
|
|
588
|
-
logger.info({ subsystem: 'daemon-loop', message: `Compacted ${compactResult.logs_compacted} append logs (${compactResult.total_entries} entries)` });
|
|
589
|
-
}
|
|
590
|
-
} catch (err) {
|
|
591
|
-
logger.info({ subsystem: 'daemon-loop', message: `Append log compaction error: ${err.message}` });
|
|
592
|
-
}
|
|
593
|
-
|
|
594
600
|
try {
|
|
595
601
|
await runCrons({ vaultDir: VAULT_DIR, skillsDir: SKILLS_DIR, brainDir: BRAIN_DIR });
|
|
596
602
|
} catch (err) {
|
|
@@ -627,42 +633,13 @@ async function main() {
|
|
|
627
633
|
queueDir: QUEUE_DIR,
|
|
628
634
|
vaultDir: VAULT_DIR,
|
|
629
635
|
sessionsDir: SESSIONS_DIR,
|
|
636
|
+
localOnly,
|
|
630
637
|
});
|
|
631
638
|
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
// Empty queue: optional system dream, then sleep (no busy-work invention)
|
|
639
|
+
const { task, source } = await nextDaemonTask(scheduler, { localOnly });
|
|
635
640
|
if (!task) {
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
const dreamEnv = buildTaskEnvelope({
|
|
639
|
-
intent: 'Scheduled system dream cycle',
|
|
640
|
-
slug: `dream-system-${Date.now().toString(36)}`,
|
|
641
|
-
kind: 'system',
|
|
642
|
-
executor: 'dream',
|
|
643
|
-
category: 'memory-maintenance',
|
|
644
|
-
priority: 70,
|
|
645
|
-
system: true,
|
|
646
|
-
origin: { agent: 'daemon', created_by: 'daemon-system' },
|
|
647
|
-
capabilities: ['vault:read', 'vault:write'],
|
|
648
|
-
});
|
|
649
|
-
persistTaskToDisk(dreamEnv, QUEUE_DIR);
|
|
650
|
-
task = dreamEnv;
|
|
651
|
-
source = 'system';
|
|
652
|
-
logger.info({
|
|
653
|
-
subsystem: 'daemon-loop',
|
|
654
|
-
message: `Empty queue → enqueue system dream (${emptyTicks} empty ticks)`,
|
|
655
|
-
});
|
|
656
|
-
} else {
|
|
657
|
-
logger.info({
|
|
658
|
-
subsystem: 'daemon-loop',
|
|
659
|
-
message: `Queue empty (tick ${emptyTicks}) — sleeping ${EMPTY_SLEEP_MS}ms`,
|
|
660
|
-
});
|
|
661
|
-
await new Promise((r) => setTimeout(r, EMPTY_SLEEP_MS));
|
|
662
|
-
continue;
|
|
663
|
-
}
|
|
664
|
-
} else {
|
|
665
|
-
emptyTicks = 0;
|
|
641
|
+
if (localOnly) taskCount++;
|
|
642
|
+
continue;
|
|
666
643
|
}
|
|
667
644
|
|
|
668
645
|
taskCount++;
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The dashboard bundle a source checkout serves, kept as new as its sources.
|
|
3
|
+
*
|
|
4
|
+
* The server used to build `frontend/dist` only when `index.html` was missing,
|
|
5
|
+
* and auto-pull rebuilt it only when a pull from origin changed `frontend/`.
|
|
6
|
+
* A local merge or commit refreshed nothing, so the served dashboard silently
|
|
7
|
+
* stayed on an old build: the plugin workspace drawers committed on
|
|
8
|
+
* 2026-11-08 never appeared at localhost:3000 because the bundle there was
|
|
9
|
+
* built on 2026-11-09 from code without them, and nothing ever looked again.
|
|
10
|
+
*
|
|
11
|
+
* Here "stale" has one definition, shared with the publish gate
|
|
12
|
+
* (`scripts/check-dist-freshness.mjs`): a source file newer than the newest
|
|
13
|
+
* bundle file. The server checks on start and on an interval, rebuilds in the
|
|
14
|
+
* background with the frontend's own build script, and keeps serving the
|
|
15
|
+
* current bundle until the new one is complete. It never installs
|
|
16
|
+
* dependencies: missing build tools are reported, not repaired behind the
|
|
17
|
+
* operator's back. An npm tarball gives every file the same mtime, so an
|
|
18
|
+
* installed package is never stale and never builds.
|
|
19
|
+
*/
|
|
20
|
+
import { spawn } from 'node:child_process';
|
|
21
|
+
import fs from 'node:fs';
|
|
22
|
+
import { readdir, stat } from 'node:fs/promises';
|
|
23
|
+
import path from 'node:path';
|
|
24
|
+
|
|
25
|
+
const IGNORED_DIRS = new Set(['node_modules', '.git', 'dist']);
|
|
26
|
+
|
|
27
|
+
/** Sources must be untouched this long before a rebuild, so a half-written edit is not built. */
|
|
28
|
+
export const QUIET_MS = 60_000;
|
|
29
|
+
export const CHECK_INTERVAL_MS = 5 * 60_000;
|
|
30
|
+
export const BUILD_TIMEOUT_MS = 10 * 60_000;
|
|
31
|
+
const OUTPUT_TAIL_BYTES = 4096;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Newest mtime under a file or directory, and the path carrying it.
|
|
35
|
+
* Missing paths contribute nothing rather than failing: vite.config.ts and
|
|
36
|
+
* friends are allowed not to exist.
|
|
37
|
+
*/
|
|
38
|
+
export async function newestUnder(target) {
|
|
39
|
+
let info;
|
|
40
|
+
try {
|
|
41
|
+
info = await stat(target);
|
|
42
|
+
} catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (info.isFile()) return { path: target, mtimeMs: info.mtimeMs };
|
|
47
|
+
|
|
48
|
+
let best = null;
|
|
49
|
+
const entries = await readdir(target, { withFileTypes: true });
|
|
50
|
+
for (const entry of entries) {
|
|
51
|
+
if (entry.isDirectory() && IGNORED_DIRS.has(entry.name)) continue;
|
|
52
|
+
const found = await newestUnder(path.join(target, entry.name));
|
|
53
|
+
if (found && (!best || found.mtimeMs > best.mtimeMs)) best = found;
|
|
54
|
+
}
|
|
55
|
+
return best;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Whether the built bundle can be trusted to represent the sources.
|
|
60
|
+
* Returns { ok, reason, bundle, source }; never throws, never prints, so the
|
|
61
|
+
* decision can be tested apart from how it is reported.
|
|
62
|
+
*/
|
|
63
|
+
export async function checkDistFreshness({ distDir, sourcePaths }) {
|
|
64
|
+
const bundle = await newestUnder(distDir);
|
|
65
|
+
if (!bundle) return { ok: false, reason: 'missing-bundle', bundle: null, source: null };
|
|
66
|
+
|
|
67
|
+
let source = null;
|
|
68
|
+
for (const candidate of sourcePaths) {
|
|
69
|
+
const found = await newestUnder(candidate);
|
|
70
|
+
if (found && (!source || found.mtimeMs > source.mtimeMs)) source = found;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (source && source.mtimeMs > bundle.mtimeMs) {
|
|
74
|
+
return { ok: false, reason: 'stale-bundle', bundle, source };
|
|
75
|
+
}
|
|
76
|
+
return { ok: true, reason: 'current', bundle, source };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Every input whose change changes the built dashboard. */
|
|
80
|
+
export function dashboardTargets(root) {
|
|
81
|
+
const frontend = path.join(root, 'frontend');
|
|
82
|
+
let tsconfigs = [];
|
|
83
|
+
try {
|
|
84
|
+
tsconfigs = fs.readdirSync(frontend).filter(name => /^tsconfig.*\.json$/.test(name)).map(name => path.join(frontend, name));
|
|
85
|
+
} catch { /* no frontend directory: nothing to compare */ }
|
|
86
|
+
return {
|
|
87
|
+
distDir: path.join(frontend, 'dist'),
|
|
88
|
+
sourcePaths: [
|
|
89
|
+
path.join(frontend, 'src'),
|
|
90
|
+
path.join(frontend, 'public'),
|
|
91
|
+
path.join(frontend, 'index.html'),
|
|
92
|
+
path.join(frontend, 'vite.config.ts'),
|
|
93
|
+
path.join(frontend, 'package.json'),
|
|
94
|
+
...tsconfigs,
|
|
95
|
+
],
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** The build script needs vite and the TypeScript compiler, hoisted to the root or local to the frontend. */
|
|
100
|
+
export function buildToolsPresent(root) {
|
|
101
|
+
const frontend = path.join(root, 'frontend');
|
|
102
|
+
const has = rel => [root, frontend].some(dir => fs.existsSync(path.join(dir, 'node_modules', rel)));
|
|
103
|
+
return fs.existsSync(path.join(frontend, 'package.json')) && has(path.join('vite', 'bin', 'vite.js')) && has(path.join('typescript', 'bin', 'tsc'));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** npm installed beside the running node (Homebrew, nvm, system installs), else from PATH. */
|
|
107
|
+
function npmBinary() {
|
|
108
|
+
const beside = path.join(path.dirname(process.execPath), process.platform === 'win32' ? 'npm.cmd' : 'npm');
|
|
109
|
+
return fs.existsSync(beside) ? beside : 'npm';
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Run the frontend's own `build` script into `outDir`. npm appends the
|
|
114
|
+
* arguments after `--` to the script, so they reach `vite build`.
|
|
115
|
+
* @returns {Promise<{ code: number|null, output: string, timedOut: boolean }>}
|
|
116
|
+
*/
|
|
117
|
+
export function runFrontendBuild({ frontendDir, outDir, timeoutMs = BUILD_TIMEOUT_MS }) {
|
|
118
|
+
return new Promise(resolve => {
|
|
119
|
+
let output = '';
|
|
120
|
+
let timedOut = false;
|
|
121
|
+
const keep = chunk => { output = (output + chunk).slice(-OUTPUT_TAIL_BYTES); };
|
|
122
|
+
const env = { ...process.env, PATH: [path.dirname(process.execPath), process.env.PATH].filter(Boolean).join(path.delimiter) };
|
|
123
|
+
let child;
|
|
124
|
+
try {
|
|
125
|
+
child = spawn(npmBinary(), ['run', 'build', '--', '--outDir', outDir, '--emptyOutDir'], {
|
|
126
|
+
cwd: frontendDir, env, stdio: ['ignore', 'pipe', 'pipe'], shell: process.platform === 'win32', detached: process.platform !== 'win32',
|
|
127
|
+
});
|
|
128
|
+
} catch (error) {
|
|
129
|
+
resolve({ code: null, output: error.message, timedOut: false });
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
child.stdout.on('data', keep);
|
|
133
|
+
child.stderr.on('data', keep);
|
|
134
|
+
const timer = setTimeout(() => {
|
|
135
|
+
timedOut = true;
|
|
136
|
+
// The build runs in its own process group: end tsc and vite with npm.
|
|
137
|
+
try { process.kill(-child.pid, 'SIGTERM'); } catch { child.kill('SIGTERM'); }
|
|
138
|
+
}, timeoutMs);
|
|
139
|
+
timer.unref?.();
|
|
140
|
+
child.on('error', error => { clearTimeout(timer); resolve({ code: null, output: `${output}\n${error.message}`.trim(), timedOut }); });
|
|
141
|
+
child.on('close', code => { clearTimeout(timer); resolve({ code, output, timedOut }); });
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function processAlive(pid) {
|
|
146
|
+
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
147
|
+
try { process.kill(pid, 0); return true; } catch (error) { return error.code === 'EPERM'; }
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Hold the build lock, or report who holds it. A lock left by a process that
|
|
152
|
+
* no longer exists is reclaimed once.
|
|
153
|
+
*/
|
|
154
|
+
function acquireLock(file) {
|
|
155
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
156
|
+
try {
|
|
157
|
+
const fd = fs.openSync(file, 'wx', 0o600);
|
|
158
|
+
fs.writeSync(fd, `${process.pid}\n`);
|
|
159
|
+
fs.closeSync(fd);
|
|
160
|
+
return { held: true, release: () => { try { if (Number(fs.readFileSync(file, 'utf8').trim()) === process.pid) fs.unlinkSync(file); } catch { /* already gone */ } } };
|
|
161
|
+
} catch (error) {
|
|
162
|
+
if (error.code !== 'EEXIST') throw error;
|
|
163
|
+
const owner = Number(String(fs.readFileSync(file, 'utf8')).trim());
|
|
164
|
+
if (processAlive(owner)) return { held: false, owner };
|
|
165
|
+
fs.rmSync(file, { force: true });
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return { held: false, owner: null };
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Build the dashboard beside the served one and swap it in. The served bundle
|
|
173
|
+
* stays in place until the new one is complete; a failed build leaves it
|
|
174
|
+
* untouched.
|
|
175
|
+
* @returns {Promise<{ ok: boolean, status: string, reason?: string, durationMs?: number, output?: string }>}
|
|
176
|
+
*/
|
|
177
|
+
export async function rebuildDashboard({ root, run = runFrontendBuild, timeoutMs = BUILD_TIMEOUT_MS } = {}) {
|
|
178
|
+
const frontendDir = path.join(root, 'frontend');
|
|
179
|
+
const dist = path.join(frontendDir, 'dist');
|
|
180
|
+
const next = path.join(frontendDir, 'dist.next');
|
|
181
|
+
const prev = path.join(frontendDir, 'dist.prev');
|
|
182
|
+
const lock = acquireLock(path.join(frontendDir, '.dist-build.lock'));
|
|
183
|
+
if (!lock.held) return { ok: false, status: 'building-elsewhere', reason: `another process (pid ${lock.owner ?? 'unknown'}) is building the dashboard` };
|
|
184
|
+
const started = Date.now();
|
|
185
|
+
try {
|
|
186
|
+
fs.rmSync(next, { recursive: true, force: true });
|
|
187
|
+
const result = await run({ frontendDir, outDir: next, timeoutMs });
|
|
188
|
+
const built = result.code === 0 && !result.timedOut && fs.existsSync(path.join(next, 'index.html'));
|
|
189
|
+
if (!built) {
|
|
190
|
+
fs.rmSync(next, { recursive: true, force: true });
|
|
191
|
+
const reason = result.timedOut ? `build timed out after ${Math.round(timeoutMs / 1000)} s`
|
|
192
|
+
: result.code === 0 ? 'build finished without index.html' : `build exited ${result.code ?? 'without a status'}`;
|
|
193
|
+
return { ok: false, status: 'failed', reason, durationMs: Date.now() - started, output: result.output };
|
|
194
|
+
}
|
|
195
|
+
// Two renames: the served directory is absent only between them.
|
|
196
|
+
fs.rmSync(prev, { recursive: true, force: true });
|
|
197
|
+
const hadDist = fs.existsSync(dist);
|
|
198
|
+
if (hadDist) fs.renameSync(dist, prev);
|
|
199
|
+
try {
|
|
200
|
+
fs.renameSync(next, dist);
|
|
201
|
+
} catch (error) {
|
|
202
|
+
if (hadDist) fs.renameSync(prev, dist);
|
|
203
|
+
throw error;
|
|
204
|
+
}
|
|
205
|
+
fs.rmSync(prev, { recursive: true, force: true });
|
|
206
|
+
return { ok: true, status: 'built', durationMs: Date.now() - started };
|
|
207
|
+
} finally {
|
|
208
|
+
lock.release();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Check once and rebuild when needed. Returns the state to report and, when
|
|
214
|
+
* the sources are still being edited, how long to wait before checking again.
|
|
215
|
+
*/
|
|
216
|
+
export async function refreshDashboard({ root, now = Date.now, quietMs = QUIET_MS, rebuild = rebuildDashboard, toolsPresent = buildToolsPresent } = {}) {
|
|
217
|
+
const freshness = await checkDistFreshness(dashboardTargets(root));
|
|
218
|
+
if (freshness.ok) return { status: 'current', bundleBuiltAt: new Date(freshness.bundle.mtimeMs).toISOString() };
|
|
219
|
+
const state = freshness.reason === 'missing-bundle' ? 'missing' : 'stale';
|
|
220
|
+
if (!toolsPresent(root)) {
|
|
221
|
+
return { status: state, reason: `the build tools are not installed; run npm ci in ${root}`, source: freshness.source?.path ?? null };
|
|
222
|
+
}
|
|
223
|
+
if (freshness.source && now() - freshness.source.mtimeMs < quietMs) {
|
|
224
|
+
return { status: state, reason: 'sources are still changing', source: freshness.source.path, retryInMs: quietMs - (now() - freshness.source.mtimeMs) + 1000 };
|
|
225
|
+
}
|
|
226
|
+
const build = await rebuild({ root });
|
|
227
|
+
if (build.ok) return { status: 'current', rebuilt: true, durationMs: build.durationMs, was: state };
|
|
228
|
+
return { status: state, reason: build.reason, build };
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Keep a serving checkout's bundle current: check now, after the sources go
|
|
233
|
+
* quiet, and every `intervalMs`. `report` receives each state change.
|
|
234
|
+
* @returns {{ state: () => object, check: () => Promise<object>, stop: () => void }}
|
|
235
|
+
*/
|
|
236
|
+
export function watchDashboardBundle({ root, report = () => {}, intervalMs = CHECK_INTERVAL_MS, refresh = refreshDashboard } = {}) {
|
|
237
|
+
let current = { status: 'unchecked' };
|
|
238
|
+
let running = null;
|
|
239
|
+
let retry = null;
|
|
240
|
+
let lastKey = '';
|
|
241
|
+
const check = () => {
|
|
242
|
+
if (running) return running;
|
|
243
|
+
running = (async () => {
|
|
244
|
+
try {
|
|
245
|
+
current = { ...await refresh({ root }), checkedAt: new Date().toISOString() };
|
|
246
|
+
} catch (error) {
|
|
247
|
+
current = { status: 'error', reason: error.message, checkedAt: new Date().toISOString() };
|
|
248
|
+
}
|
|
249
|
+
const key = `${current.status}|${current.reason ?? ''}|${current.rebuilt ?? ''}`;
|
|
250
|
+
if (key !== lastKey || current.rebuilt) report(current);
|
|
251
|
+
lastKey = key;
|
|
252
|
+
clearTimeout(retry);
|
|
253
|
+
if (current.retryInMs) { retry = setTimeout(check, current.retryInMs); retry.unref?.(); }
|
|
254
|
+
return current;
|
|
255
|
+
})().finally(() => { running = null; });
|
|
256
|
+
return running;
|
|
257
|
+
};
|
|
258
|
+
const interval = setInterval(check, intervalMs);
|
|
259
|
+
interval.unref?.();
|
|
260
|
+
return { state: () => current, check, stop: () => { clearInterval(interval); clearTimeout(retry); } };
|
|
261
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Default runtime foundation and routine agent-development tools. */
|
|
2
2
|
export const DEFAULT_PLUGIN_IDS = Object.freeze([
|
|
3
3
|
'auth', 'ssss', 'mesh', 'openwiki', 'composable-cli', 'meta-harness',
|
|
4
|
-
'code-quality', 'security', 'embeddings', 'git
|
|
4
|
+
'code-quality', 'security', 'embeddings', 'git', 'automations',
|
|
5
5
|
]);
|
|
6
6
|
|
|
7
7
|
/** Required defaults that own additional installation payloads. */
|