create-principles-disciple 1.146.4 → 1.146.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_release/product-identity.json +1 -1
- package/codex-adapter/package.json +1 -1
- package/core/dist/runtime-v2/evidence-triage/index.d.ts +1 -3
- package/core/dist/runtime-v2/evidence-triage/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/evidence-triage/index.js +1 -2
- package/core/dist/runtime-v2/evidence-triage/index.js.map +1 -1
- package/core/dist/runtime-v2/evidence-triage/observation-resolver.d.ts +0 -19
- package/core/dist/runtime-v2/evidence-triage/observation-resolver.d.ts.map +1 -1
- package/core/dist/runtime-v2/evidence-triage/observation-resolver.js +0 -25
- package/core/dist/runtime-v2/evidence-triage/observation-resolver.js.map +1 -1
- package/core/dist/runtime-v2/index.d.ts +2 -2
- package/core/dist/runtime-v2/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/index.js +1 -1
- package/core/dist/runtime-v2/index.js.map +1 -1
- package/core/dist/telemetry-event.d.ts +2 -2
- package/core/dist/telemetry-event.d.ts.map +1 -1
- package/core/dist/telemetry-event.js +4 -5
- package/core/dist/telemetry-event.js.map +1 -1
- package/core/dist/trajectory-store.d.ts.map +1 -1
- package/core/dist/trajectory-store.js +4 -44
- package/core/dist/trajectory-store.js.map +1 -1
- package/core/package.json +1 -1
- package/host-runtime/package.json +1 -1
- package/package.json +4 -4
- package/plugin/dist/bundle.js +460 -460
- package/plugin/dist/core/config.d.ts +0 -2
- package/plugin/dist/core/trajectory.d.ts +0 -6
- package/plugin/dist/hooks/llm.d.ts +0 -1
- package/plugin/dist/hooks/prompt-helpers.d.ts +2 -1
- package/plugin/dist/hooks/raw-observation-adapter.d.ts +6 -4
- package/plugin/dist/hooks/triage-adapter.d.ts +1 -1
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/dist/rulehost-evidence.js +6 -6
- package/plugin/dist/templates/pain_settings.json +0 -2
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/plugin/templates/pain_settings.json +0 -2
- package/release-manager/package.json +4 -4
- package/workbuddy-adapter/package.json +1 -1
- package/console/dist/ui/App.d.ts +0 -1
- package/console/dist/ui/App.js +0 -172
- package/console/dist/ui/api.d.ts +0 -611
- package/console/dist/ui/api.js +0 -1094
- package/console/dist/ui/components/auth/login-form.d.ts +0 -4
- package/console/dist/ui/components/auth/login-form.js +0 -142
- package/console/dist/ui/components/auth/splash-screen.d.ts +0 -9
- package/console/dist/ui/components/auth/splash-screen.js +0 -22
- package/console/dist/ui/components/error-boundary.d.ts +0 -15
- package/console/dist/ui/components/error-boundary.js +0 -30
- package/console/dist/ui/components/focus/daily-thought-card.d.ts +0 -1
- package/console/dist/ui/components/focus/daily-thought-card.js +0 -41
- package/console/dist/ui/components/language-switcher.d.ts +0 -2
- package/console/dist/ui/components/language-switcher.js +0 -17
- package/console/dist/ui/components/layout/app-sidebar.d.ts +0 -27
- package/console/dist/ui/components/layout/app-sidebar.js +0 -128
- package/console/dist/ui/components/layout/page-loading.d.ts +0 -13
- package/console/dist/ui/components/layout/page-loading.js +0 -14
- package/console/dist/ui/components/layout/page-shell.d.ts +0 -12
- package/console/dist/ui/components/layout/page-shell.js +0 -11
- package/console/dist/ui/components/layout/section-title.d.ts +0 -10
- package/console/dist/ui/components/layout/section-title.js +0 -9
- package/console/dist/ui/components/notifications/NotificationProvider.d.ts +0 -14
- package/console/dist/ui/components/notifications/NotificationProvider.js +0 -136
- package/console/dist/ui/components/notifications/favicon-badge.d.ts +0 -3
- package/console/dist/ui/components/notifications/favicon-badge.js +0 -68
- package/console/dist/ui/components/notifications/notification-reducer.d.ts +0 -9
- package/console/dist/ui/components/notifications/notification-reducer.js +0 -9
- package/console/dist/ui/components/notifications/sound-storage.d.ts +0 -3
- package/console/dist/ui/components/notifications/sound-storage.js +0 -37
- package/console/dist/ui/components/notifications/useNotifications.d.ts +0 -1
- package/console/dist/ui/components/notifications/useNotifications.js +0 -9
- package/console/dist/ui/components/onboarding/CircuitDiagram.d.ts +0 -8
- package/console/dist/ui/components/onboarding/CircuitDiagram.js +0 -18
- package/console/dist/ui/components/onboarding/DemoResultView.d.ts +0 -22
- package/console/dist/ui/components/onboarding/DemoResultView.js +0 -33
- package/console/dist/ui/components/onboarding/SlashCommandsCard.d.ts +0 -16
- package/console/dist/ui/components/onboarding/SlashCommandsCard.js +0 -20
- package/console/dist/ui/components/onboarding/slashCommands.d.ts +0 -20
- package/console/dist/ui/components/onboarding/slashCommands.js +0 -22
- package/console/dist/ui/components/receipts/ReceiptCoverageDisclosure.d.ts +0 -6
- package/console/dist/ui/components/receipts/ReceiptCoverageDisclosure.js +0 -66
- package/console/dist/ui/components/theme-provider.d.ts +0 -14
- package/console/dist/ui/components/theme-provider.js +0 -40
- package/console/dist/ui/components/theme-toggle.d.ts +0 -2
- package/console/dist/ui/components/theme-toggle.js +0 -11
- package/console/dist/ui/components/ui/alert-dialog.d.ts +0 -20
- package/console/dist/ui/components/ui/alert-dialog.js +0 -26
- package/console/dist/ui/components/ui/badge.d.ts +0 -9
- package/console/dist/ui/components/ui/badge.js +0 -22
- package/console/dist/ui/components/ui/button.d.ts +0 -11
- package/console/dist/ui/components/ui/button.js +0 -34
- package/console/dist/ui/components/ui/card.d.ts +0 -8
- package/console/dist/ui/components/ui/card.js +0 -16
- package/console/dist/ui/components/ui/charts.d.ts +0 -51
- package/console/dist/ui/components/ui/charts.js +0 -72
- package/console/dist/ui/components/ui/dialog.d.ts +0 -19
- package/console/dist/ui/components/ui/dialog.js +0 -22
- package/console/dist/ui/components/ui/input.d.ts +0 -3
- package/console/dist/ui/components/ui/input.js +0 -8
- package/console/dist/ui/components/ui/markdown.d.ts +0 -24
- package/console/dist/ui/components/ui/markdown.js +0 -119
- package/console/dist/ui/components/ui/progress-bar.d.ts +0 -20
- package/console/dist/ui/components/ui/progress-bar.js +0 -38
- package/console/dist/ui/components/ui/select.d.ts +0 -13
- package/console/dist/ui/components/ui/select.js +0 -26
- package/console/dist/ui/components/ui/separator.d.ts +0 -3
- package/console/dist/ui/components/ui/separator.js +0 -6
- package/console/dist/ui/components/ui/sheet.d.ts +0 -25
- package/console/dist/ui/components/ui/sheet.js +0 -37
- package/console/dist/ui/components/ui/shiny-text.d.ts +0 -28
- package/console/dist/ui/components/ui/shiny-text.js +0 -46
- package/console/dist/ui/components/ui/skeleton.d.ts +0 -3
- package/console/dist/ui/components/ui/skeleton.js +0 -6
- package/console/dist/ui/components/ui/sonner.d.ts +0 -3
- package/console/dist/ui/components/ui/sonner.js +0 -13
- package/console/dist/ui/components/ui/tooltip.d.ts +0 -7
- package/console/dist/ui/components/ui/tooltip.js +0 -10
- package/console/dist/ui/data/daily-thoughts.d.ts +0 -15
- package/console/dist/ui/data/daily-thoughts.js +0 -164
- package/console/dist/ui/hooks/useNotificationSound.d.ts +0 -12
- package/console/dist/ui/hooks/useNotificationSound.js +0 -74
- package/console/dist/ui/i18n/en.json +0 -2399
- package/console/dist/ui/i18n/index.d.ts +0 -2
- package/console/dist/ui/i18n/index.js +0 -32
- package/console/dist/ui/i18n/zh-CN.json +0 -2399
- package/console/dist/ui/main.d.ts +0 -1
- package/console/dist/ui/main.js +0 -9
- package/console/dist/ui/pages/ReportProblemValidators.d.ts +0 -144
- package/console/dist/ui/pages/ReportProblemValidators.js +0 -418
- package/console/dist/ui/pages/activation/ActivationPage.d.ts +0 -1
- package/console/dist/ui/pages/activation/ActivationPage.js +0 -512
- package/console/dist/ui/pages/activation/ActivationValidators.d.ts +0 -20
- package/console/dist/ui/pages/activation/ActivationValidators.js +0 -160
- package/console/dist/ui/pages/control-center/AgentCard.d.ts +0 -31
- package/console/dist/ui/pages/control-center/AgentCard.js +0 -212
- package/console/dist/ui/pages/control-center/AgentGroup.d.ts +0 -26
- package/console/dist/ui/pages/control-center/AgentGroup.js +0 -38
- package/console/dist/ui/pages/control-center/ControlCenterPage.d.ts +0 -1
- package/console/dist/ui/pages/control-center/ControlCenterPage.js +0 -509
- package/console/dist/ui/pages/control-center/DesignGatePanel.d.ts +0 -1
- package/console/dist/ui/pages/control-center/DesignGatePanel.js +0 -137
- package/console/dist/ui/pages/control-center/RuntimeProfileManager.d.ts +0 -31
- package/console/dist/ui/pages/control-center/RuntimeProfileManager.js +0 -199
- package/console/dist/ui/pages/control-center/WorkflowDiagram.d.ts +0 -17
- package/console/dist/ui/pages/control-center/WorkflowDiagram.js +0 -55
- package/console/dist/ui/pages/debt/DebtPage.d.ts +0 -2
- package/console/dist/ui/pages/debt/DebtPage.js +0 -222
- package/console/dist/ui/pages/design-system/DesignSystemPage.d.ts +0 -2
- package/console/dist/ui/pages/design-system/DesignSystemPage.js +0 -30
- package/console/dist/ui/pages/examiner/ExaminerPage.d.ts +0 -15
- package/console/dist/ui/pages/examiner/ExaminerPage.js +0 -158
- package/console/dist/ui/pages/failed-tasks/FailedTasksPage.d.ts +0 -1
- package/console/dist/ui/pages/failed-tasks/FailedTasksPage.js +0 -421
- package/console/dist/ui/pages/focus/ApprovalSubjectReading.d.ts +0 -24
- package/console/dist/ui/pages/focus/ApprovalSubjectReading.js +0 -133
- package/console/dist/ui/pages/focus/FocusPage.d.ts +0 -123
- package/console/dist/ui/pages/focus/FocusPage.js +0 -567
- package/console/dist/ui/pages/focus/OwnerDecisionCard.d.ts +0 -9
- package/console/dist/ui/pages/focus/OwnerDecisionCard.js +0 -111
- package/console/dist/ui/pages/focus/OwnerWorkbench.d.ts +0 -19
- package/console/dist/ui/pages/focus/OwnerWorkbench.js +0 -75
- package/console/dist/ui/pages/focus/RuleCandidateBindingPanel.d.ts +0 -34
- package/console/dist/ui/pages/focus/RuleCandidateBindingPanel.js +0 -298
- package/console/dist/ui/pages/focus/focus-validation.d.ts +0 -40
- package/console/dist/ui/pages/focus/focus-validation.js +0 -211
- package/console/dist/ui/pages/intent/IntentOnboarding.d.ts +0 -67
- package/console/dist/ui/pages/intent/IntentOnboarding.js +0 -289
- package/console/dist/ui/pages/intent/IntentPage.d.ts +0 -1
- package/console/dist/ui/pages/intent/IntentPage.js +0 -252
- package/console/dist/ui/pages/pain/PainEvidenceValidators.d.ts +0 -59
- package/console/dist/ui/pages/pain/PainEvidenceValidators.js +0 -125
- package/console/dist/ui/pages/pain/PainPage.d.ts +0 -1
- package/console/dist/ui/pages/pain/PainPage.js +0 -420
- package/console/dist/ui/pages/pain/pain-card-helpers.d.ts +0 -175
- package/console/dist/ui/pages/pain/pain-card-helpers.js +0 -181
- package/console/dist/ui/pages/principles/CorePrinciplesPage.d.ts +0 -10
- package/console/dist/ui/pages/principles/CorePrinciplesPage.js +0 -59
- package/console/dist/ui/pages/principles/PrincipleDetailPage.d.ts +0 -60
- package/console/dist/ui/pages/principles/PrincipleDetailPage.js +0 -602
- package/console/dist/ui/pages/principles/PrinciplesPage.d.ts +0 -1
- package/console/dist/ui/pages/principles/PrinciplesPage.js +0 -327
- package/console/dist/ui/pages/principles/PrinciplesViewNav.d.ts +0 -8
- package/console/dist/ui/pages/principles/PrinciplesViewNav.js +0 -15
- package/console/dist/ui/pages/report-problem/ReportProblemPage.d.ts +0 -1
- package/console/dist/ui/pages/report-problem/ReportProblemPage.js +0 -467
- package/console/dist/ui/pages/settings/SettingsPage.d.ts +0 -4
- package/console/dist/ui/pages/settings/SettingsPage.js +0 -457
- package/console/dist/ui/pages/settings/UpdatePage.d.ts +0 -1
- package/console/dist/ui/pages/settings/UpdatePage.js +0 -215
- package/console/dist/ui/pages/welcome/WelcomePage.d.ts +0 -5
- package/console/dist/ui/pages/welcome/WelcomePage.js +0 -187
- package/console/dist/ui/utils/agent-metadata.d.ts +0 -71
- package/console/dist/ui/utils/agent-metadata.js +0 -284
- package/console/dist/ui/utils/approval-review.d.ts +0 -30
- package/console/dist/ui/utils/approval-review.js +0 -50
- package/console/dist/ui/utils/approval-warning-localization.d.ts +0 -34
- package/console/dist/ui/utils/approval-warning-localization.js +0 -148
- package/console/dist/ui/utils/attention-presentation.d.ts +0 -35
- package/console/dist/ui/utils/attention-presentation.js +0 -46
- package/console/dist/ui/utils/blocker-localization.d.ts +0 -23
- package/console/dist/ui/utils/blocker-localization.js +0 -36
- package/console/dist/ui/utils/control-center-helpers.d.ts +0 -79
- package/console/dist/ui/utils/control-center-helpers.js +0 -189
- package/console/dist/ui/utils/enum-labels.d.ts +0 -50
- package/console/dist/ui/utils/enum-labels.js +0 -171
- package/console/dist/ui/utils/format-date.d.ts +0 -11
- package/console/dist/ui/utils/format-date.js +0 -17
- package/console/dist/ui/utils/onboarding-state.d.ts +0 -25
- package/console/dist/ui/utils/onboarding-state.js +0 -77
- package/console/dist/ui/utils/reading-layout.d.ts +0 -20
- package/console/dist/ui/utils/reading-layout.js +0 -46
- package/console/dist/ui/utils/rule-binding-validators.d.ts +0 -13
- package/console/dist/ui/utils/rule-binding-validators.js +0 -188
- package/console/dist/ui/utils/runtime-mode.d.ts +0 -11
- package/console/dist/ui/utils/runtime-mode.js +0 -11
- package/console/dist/ui/utils/token-storage.d.ts +0 -22
- package/console/dist/ui/utils/token-storage.js +0 -47
- package/console/dist/ui/utils/validators.d.ts +0 -1178
- package/console/dist/ui/utils/validators.js +0 -3297
- package/core/dist/runtime-v2/evidence-triage/admission-events.d.ts +0 -126
- package/core/dist/runtime-v2/evidence-triage/admission-events.d.ts.map +0 -1
- package/core/dist/runtime-v2/evidence-triage/admission-events.js +0 -159
- package/core/dist/runtime-v2/evidence-triage/admission-events.js.map +0 -1
- package/plugin/dist/core/detection-funnel.d.ts +0 -47
- package/plugin/dist/core/detection-service.d.ts +0 -15
- package/release-manager/dist/bootstrap-entry.d.ts +0 -2
- package/release-manager/dist/bootstrap-entry.d.ts.map +0 -1
- package/release-manager/dist/bootstrap-entry.js.map +0 -1
- package/release-manager/dist/i18n.d.ts +0 -6
- package/release-manager/dist/i18n.d.ts.map +0 -1
- package/release-manager/dist/i18n.js.map +0 -1
- package/release-manager/dist/index.d.ts +0 -7
- package/release-manager/dist/index.d.ts.map +0 -1
- package/release-manager/dist/index.js +0 -656
- package/release-manager/dist/index.js.map +0 -1
- package/release-manager/dist/installer.d.ts +0 -629
- package/release-manager/dist/installer.d.ts.map +0 -1
- package/release-manager/dist/installer.js.map +0 -1
- package/release-manager/dist/installers/codex-host-installer.d.ts +0 -39
- package/release-manager/dist/installers/codex-host-installer.d.ts.map +0 -1
- package/release-manager/dist/installers/codex-host-installer.js.map +0 -1
- package/release-manager/dist/installers/index.d.ts +0 -51
- package/release-manager/dist/installers/index.d.ts.map +0 -1
- package/release-manager/dist/installers/index.js.map +0 -1
- package/release-manager/dist/installers/openclaw-host-installer.d.ts +0 -14
- package/release-manager/dist/installers/openclaw-host-installer.d.ts.map +0 -1
- package/release-manager/dist/installers/openclaw-host-installer.js.map +0 -1
- package/release-manager/dist/installers/workbuddy-host-installer.d.ts +0 -335
- package/release-manager/dist/installers/workbuddy-host-installer.d.ts.map +0 -1
- package/release-manager/dist/installers/workbuddy-host-installer.js.map +0 -1
- package/release-manager/dist/mvp-config.d.ts +0 -233
- package/release-manager/dist/mvp-config.d.ts.map +0 -1
- package/release-manager/dist/mvp-config.js.map +0 -1
- package/release-manager/dist/prompts.d.ts +0 -43
- package/release-manager/dist/prompts.d.ts.map +0 -1
- package/release-manager/dist/prompts.js +0 -268
- package/release-manager/dist/prompts.js.map +0 -1
- package/release-manager/dist/skill-language.d.ts +0 -32
- package/release-manager/dist/skill-language.d.ts.map +0 -1
- package/release-manager/dist/skill-language.js.map +0 -1
- package/release-manager/dist/uninstaller.d.ts +0 -68
- package/release-manager/dist/uninstaller.d.ts.map +0 -1
- package/release-manager/dist/uninstaller.js +0 -746
- package/release-manager/dist/uninstaller.js.map +0 -1
- package/release-manager/dist/update/apply-payload.d.ts +0 -143
- package/release-manager/dist/update/apply-payload.d.ts.map +0 -1
- package/release-manager/dist/update/apply-payload.js.map +0 -1
- package/release-manager/dist/update/atomic-file.d.ts +0 -35
- package/release-manager/dist/update/atomic-file.d.ts.map +0 -1
- package/release-manager/dist/update/atomic-file.js.map +0 -1
- package/release-manager/dist/update/bootstrap-executor.d.ts +0 -21
- package/release-manager/dist/update/bootstrap-executor.d.ts.map +0 -1
- package/release-manager/dist/update/bootstrap-executor.js.map +0 -1
- package/release-manager/dist/update/bootstrap-protocol.d.ts +0 -56
- package/release-manager/dist/update/bootstrap-protocol.d.ts.map +0 -1
- package/release-manager/dist/update/bootstrap-protocol.js.map +0 -1
- package/release-manager/dist/update/channel-metadata.d.ts +0 -28
- package/release-manager/dist/update/channel-metadata.d.ts.map +0 -1
- package/release-manager/dist/update/channel-metadata.js.map +0 -1
- package/release-manager/dist/update/channel-promotion.d.ts +0 -39
- package/release-manager/dist/update/channel-promotion.d.ts.map +0 -1
- package/release-manager/dist/update/channel-promotion.js +0 -55
- package/release-manager/dist/update/channel-promotion.js.map +0 -1
- package/release-manager/dist/update/console-surface.d.ts +0 -19
- package/release-manager/dist/update/console-surface.d.ts.map +0 -1
- package/release-manager/dist/update/console-surface.js.map +0 -1
- package/release-manager/dist/update/data-compatibility.d.ts +0 -35
- package/release-manager/dist/update/data-compatibility.d.ts.map +0 -1
- package/release-manager/dist/update/data-compatibility.js +0 -45
- package/release-manager/dist/update/data-compatibility.js.map +0 -1
- package/release-manager/dist/update/install-layout.d.ts +0 -105
- package/release-manager/dist/update/install-layout.d.ts.map +0 -1
- package/release-manager/dist/update/install-layout.js.map +0 -1
- package/release-manager/dist/update/product-identity.d.ts +0 -70
- package/release-manager/dist/update/product-identity.d.ts.map +0 -1
- package/release-manager/dist/update/product-identity.js.map +0 -1
- package/release-manager/dist/update/release-asset-manifest.d.ts +0 -31
- package/release-manager/dist/update/release-asset-manifest.d.ts.map +0 -1
- package/release-manager/dist/update/release-asset-manifest.js.map +0 -1
- package/release-manager/dist/update/release-identity.d.ts +0 -33
- package/release-manager/dist/update/release-identity.d.ts.map +0 -1
- package/release-manager/dist/update/release-identity.js.map +0 -1
- package/release-manager/dist/update/release-manager-authority.d.ts +0 -39
- package/release-manager/dist/update/release-manager-authority.d.ts.map +0 -1
- package/release-manager/dist/update/release-manager-authority.js.map +0 -1
- package/release-manager/dist/update/release-manager.d.ts +0 -156
- package/release-manager/dist/update/release-manager.d.ts.map +0 -1
- package/release-manager/dist/update/release-manager.js.map +0 -1
- package/release-manager/dist/update/release-metadata-publisher.d.ts +0 -199
- package/release-manager/dist/update/release-metadata-publisher.d.ts.map +0 -1
- package/release-manager/dist/update/release-metadata-publisher.js +0 -478
- package/release-manager/dist/update/release-metadata-publisher.js.map +0 -1
- package/release-manager/dist/update/release-metadata-source.d.ts +0 -85
- package/release-manager/dist/update/release-metadata-source.d.ts.map +0 -1
- package/release-manager/dist/update/release-metadata-source.js.map +0 -1
- package/release-manager/dist/update/release-metadata.d.ts +0 -60
- package/release-manager/dist/update/release-metadata.d.ts.map +0 -1
- package/release-manager/dist/update/release-metadata.js.map +0 -1
- package/release-manager/dist/update/release-policy.d.ts +0 -51
- package/release-manager/dist/update/release-policy.d.ts.map +0 -1
- package/release-manager/dist/update/release-policy.js.map +0 -1
- package/release-manager/dist/update/rollback-policy.d.ts +0 -56
- package/release-manager/dist/update/rollback-policy.d.ts.map +0 -1
- package/release-manager/dist/update/rollback-policy.js +0 -61
- package/release-manager/dist/update/rollback-policy.js.map +0 -1
- package/release-manager/dist/update/transaction-journal.d.ts +0 -212
- package/release-manager/dist/update/transaction-journal.d.ts.map +0 -1
- package/release-manager/dist/update/transaction-journal.js.map +0 -1
- package/release-manager/dist/update/trust-metadata.d.ts +0 -55
- package/release-manager/dist/update/trust-metadata.d.ts.map +0 -1
- package/release-manager/dist/update/trust-metadata.js.map +0 -1
- package/release-manager/dist/update/trust-root-provisioning.d.ts +0 -99
- package/release-manager/dist/update/trust-root-provisioning.d.ts.map +0 -1
- package/release-manager/dist/update/trust-root-provisioning.js.map +0 -1
- package/release-manager/dist/update/update-history.d.ts +0 -46
- package/release-manager/dist/update/update-history.d.ts.map +0 -1
- package/release-manager/dist/update/update-history.js +0 -123
- package/release-manager/dist/update/update-history.js.map +0 -1
- package/release-manager/dist/utils/config-file-io.d.ts +0 -34
- package/release-manager/dist/utils/config-file-io.d.ts.map +0 -1
- package/release-manager/dist/utils/config-file-io.js.map +0 -1
- package/release-manager/dist/utils/env.d.ts +0 -94
- package/release-manager/dist/utils/env.d.ts.map +0 -1
- package/release-manager/dist/utils/env.js.map +0 -1
- package/release-manager/dist/utils/logger.d.ts +0 -15
- package/release-manager/dist/utils/logger.d.ts.map +0 -1
- package/release-manager/dist/utils/logger.js.map +0 -1
- package/release-manager/dist/utils/workspace-divergence.d.ts +0 -36
- package/release-manager/dist/utils/workspace-divergence.d.ts.map +0 -1
- package/release-manager/dist/utils/workspace-divergence.js.map +0 -1
|
@@ -34,13 +34,11 @@ export interface PainSettings {
|
|
|
34
34
|
thresholds: {
|
|
35
35
|
pain_trigger: number;
|
|
36
36
|
cognitive_paralysis_input: number;
|
|
37
|
-
stuck_loops_trigger: number;
|
|
38
37
|
semantic_min_score: number;
|
|
39
38
|
promotion_count_threshold: number;
|
|
40
39
|
promotion_similarity_threshold: number;
|
|
41
40
|
};
|
|
42
41
|
scores: {
|
|
43
|
-
paralysis: number;
|
|
44
42
|
default_confusion: number;
|
|
45
43
|
default_loop: number;
|
|
46
44
|
tool_failure_friction: number;
|
|
@@ -265,12 +265,6 @@ export declare class TrajectoryDatabase {
|
|
|
265
265
|
correctionCue: string | null;
|
|
266
266
|
}[];
|
|
267
267
|
reviewCorrectionSample(sampleId: string, status: Exclude<CorrectionSampleReviewStatus, 'pending'>, note?: string): CorrectionSampleRecord;
|
|
268
|
-
/**
|
|
269
|
-
* When a correction sample is rejected, emit a pain event to the trajectory.
|
|
270
|
-
* This feeds rejected corrections into the nocturnal pipeline as a high-fidelity
|
|
271
|
-
* violation signal (human-verified, unlike heuristic pain detection).
|
|
272
|
-
*/
|
|
273
|
-
private recordCorrectionRejectedPain;
|
|
274
268
|
/**
|
|
275
269
|
* 入队一条待确认信号。幂等:UNIQUE(user_turn_rowid) 兜底,重复入队是 no-op
|
|
276
270
|
* (同一轮消息只会在队列里出现一次)。id 由 (sessionId, rowid) 确定性派生。
|
|
@@ -7,7 +7,6 @@ export interface EmpathySignal {
|
|
|
7
7
|
mode?: 'structured' | 'legacy_tag';
|
|
8
8
|
}
|
|
9
9
|
export declare function extractEmpathySignal(text: string): EmpathySignal;
|
|
10
|
-
export declare function isEmpathyAuditPayload(text: string): boolean;
|
|
11
10
|
/**
|
|
12
11
|
* Extract enhanced fields from lastAssistant (complete AssistantMessage) in hook payload.
|
|
13
12
|
* Pure function — no I/O, no side effects. ERR-001 compliant.
|
|
@@ -49,7 +49,8 @@ export declare function buildGovernanceContext(): string;
|
|
|
49
49
|
* A main agent emitting them itself would corrupt that evidence channel, so
|
|
50
50
|
* normal output must keep them out. (PRI-819: the stale claim that "the
|
|
51
51
|
* empathy observer subagent" handles detection was removed — detection is
|
|
52
|
-
* owned by signal-collector-host
|
|
52
|
+
* owned by signal-collector-host; the DetectionService funnel was retired in
|
|
53
|
+
* Pain Phase 0.)
|
|
53
54
|
*
|
|
54
55
|
* Pure logic — returns a constant string.
|
|
55
56
|
*/
|
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
* migrated to principles-core (runtime-v2/evidence-triage/observation-resolver.ts).
|
|
6
6
|
*
|
|
7
7
|
* This file is now a thin re-export adapter. It preserves the original export
|
|
8
|
-
* names (resolveSourceKind, buildToolFailureObservation,
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* names (resolveSourceKind, buildToolFailureObservation, RawObservation) so
|
|
9
|
+
* all existing import sites and the source-string characterization tests keep
|
|
10
|
+
* working without changes. Pain Phase 0 removed the retired
|
|
11
|
+
* buildLlmDetectionObservation / buildEmpathyObservation re-exports (zero
|
|
12
|
+
* production callers).
|
|
11
13
|
*
|
|
12
14
|
* ERR checklist:
|
|
13
15
|
* - ERR-011: re-export adapter, not a local re-definition of migrated logic.
|
|
14
16
|
*/
|
|
15
|
-
export { resolveSourceKind, buildToolFailureObservation,
|
|
17
|
+
export { resolveSourceKind, buildToolFailureObservation, buildManualPainObservation, } from '@principles/core/runtime-v2';
|
|
16
18
|
export type { RawObservation } from './raw-observation-types.js';
|
|
@@ -28,7 +28,7 @@ import { type TriageResult, type SourceKind } from '@principles/core/runtime-v2'
|
|
|
28
28
|
*
|
|
29
29
|
* PRI-360 S1: All source-kind resolution now goes through this single entry point.
|
|
30
30
|
*/
|
|
31
|
-
export { resolveSourceKind, buildToolFailureObservation,
|
|
31
|
+
export { resolveSourceKind, buildToolFailureObservation, type RawObservation } from './raw-observation-adapter.js';
|
|
32
32
|
/**
|
|
33
33
|
* Evaluate evidence triage for a given source kind and context.
|
|
34
34
|
*
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "principles-disciple",
|
|
3
3
|
"name": "Principles Disciple",
|
|
4
4
|
"description": "Principles Disciple is an AI Agent Governance System. Stop correcting the same AI behavior across sessions. Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles.",
|
|
5
|
-
"version": "2.2.
|
|
5
|
+
"version": "2.2.13",
|
|
6
6
|
"activation": {
|
|
7
7
|
"onStartup": true,
|
|
8
8
|
"onCapabilities": [
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
var De=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var ne=Object.freeze([Object.freeze({capabilityId:"pd_status",channel:"cli",cliCommand:"pd activation list --json"}),Object.freeze({capabilityId:"rulecode_deactivate",channel:"cli",cliCommand:"pd activation deactivate --activation-id recovery-probe"}),Object.freeze({capabilityId:"rulecode_global_pause",channel:"console",consoleRoute:"/api/v1/activations/emergency-pause"}),Object.freeze({capabilityId:"owner_review_access",channel:"console",consoleRoute:"/api/v1/activations/{activationId}/owner-review"})]);var se="",Me="|;&<>()";function
|
|
2
|
+
var De=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var ne=Object.freeze([Object.freeze({capabilityId:"pd_status",channel:"cli",cliCommand:"pd activation list --json"}),Object.freeze({capabilityId:"rulecode_deactivate",channel:"cli",cliCommand:"pd activation deactivate --activation-id recovery-probe"}),Object.freeze({capabilityId:"rulecode_global_pause",channel:"console",consoleRoute:"/api/v1/activations/emergency-pause"}),Object.freeze({capabilityId:"owner_review_access",channel:"console",consoleRoute:"/api/v1/activations/{activationId}/owner-review"})]);var se="",Me="|;&<>()";function k(n){return Me.includes(n)?`${se}${n}`:n}function re(n){if(n.includes(se))return null;let e=[],t="",r=!1,s=0,o=n.length,i="plain";for(;s<o;){let c=n[s];if(c===void 0)break;if(i==="single"){c==="'"?i="plain":t+=k(c),s+=1;continue}if(i==="double"){if(c==='"')i="plain";else if(c==="\\"&&s+1<o&&'"\\$`'.includes(n[s+1]??"")){t+=k(n[s+1]??""),s+=2;continue}else t+=k(c);s+=1;continue}if(c==="'"){i="single",r=!0,s+=1;continue}if(c==='"'){i="double",r=!0,s+=1;continue}if(c==="\\"&&s+1<o){t+=k(n[s+1]??""),r=!0,s+=2;continue}if(c==="\r"||c===`
|
|
3
3
|
`){(r||t)&&(e.push(t),t="",r=!1),c==="\r"&&n[s+1]===`
|
|
4
4
|
`&&(s+=1),e.push(`
|
|
5
|
-
`),s+=1;continue}if(" ".includes(c)){(r||t)&&(e.push(t),t="",r=!1),s+=1;continue}if("|;&<>()".includes(c)){(r||t)&&(e.push(t),t="",r=!1);let a=c,d=n[s+1];c==="<"&&d===">"?a="<>":(c==="|"||c==="&"||c===">"||c==="<")&&d===c&&(a+=d),(c===">"||c==="<")&&d==="("&&(a+=d),e.push(a),s+=a.length;continue}t+=c,r=!0,s+=1}return i!=="plain"?null:((r||t)&&e.push(t),e)}function oe(n){if(/[\\$`|;&<>()*?~{}]/.test(n)||[...n].some(s=>s.charCodeAt(0)<32))return;let e=re(n);if(!e)return;let t=[...e],r=t.findIndex(s=>s==="-w"||s==="--workspace");if(r!==-1){let s=t[r+1];if(r!==t.length-2||!s||s.startsWith("-"))return;t.splice(r,2)}for(let s of ne){if(s.channel!=="cli"||!s.cliCommand||s.capabilityId!=="pd_status"&&s.capabilityId!=="rulecode_deactivate")continue;let o=re(s.cliCommand);if(!o||o.length!==t.length)continue;if(o.every((c,a)=>s.capabilityId==="rulecode_deactivate"&&o[a-1]==="--activation-id"?/^[a-zA-Z0-9][a-zA-Z0-9_.:-]*$/.test(t[a]??""):c===t[a]))return s.capabilityId}}var Pe=["verbose","debug"],je=["erroraction","warningaction","informationaction","progressaction","errorvariable","warningvariable","informationvariable","outvariable","outbuffer","pipelinevariable"];function S(n,e){return{switches:new Set([...Pe,...n]),valued:new Set([...je,...e])}}var qt=Object.freeze({"get-content":S(["raw","force","wait","asbytestream"],["path","literalpath","totalcount","first","tail","last","encoding","delimiter","readcount","stream","credential"]),"get-childitem":S(["recurse","force","name","file","directory","hidden","readonly","system","followsymlink"],["path","literalpath","filter","include","exclude","depth","attributes","credential"]),"get-item":S(["force","followsymlink"],["path","literalpath","filter","include","exclude","stream","credential"]),"get-itemproperty":S(["force"],["path","literalpath","name","filter","include","exclude","credential"]),"select-string":S(["simplematch","casesensitive","notmatch","allmatches","quiet","list","raw"],["pattern","path","literalpath","inputobject","encoding","context","include","exclude","credential"]),"test-path":S(["isvalid"],["path","literalpath","pathtype","filter","credential"]),"resolve-path":S(["relative"],["path","literalpath","relativebasepath","credential"]),"get-location":S(["stack"],["psprovider","psdrive"])});function C(n,e=!1){let t=[];for(let r of n.split("/").filter(s=>s.length>0))r!=="."&&(r===".."?t.length>0&&t[t.length-1]!==".."?t.pop():e&&t.push(".."):t.push(r));return t}function X(n){let e=/^([a-zA-Z]):(?:\/|$)/.exec(n);if(e)return{kind:"drive",root:`drive:${(e[1]??"").toUpperCase()}`,segments:C(n.slice(2))};if(/^[a-zA-Z]:/.test(n))return{kind:"drive-relative",root:n.slice(0,2).toUpperCase(),segments:[]};if(/^\/\/[^/]+(?:\/|$)/.test(n)){let t=n.slice(2).split("/").filter(o=>o.length>0),r=t[0]??"",s=t[1]??"";return{kind:"unc",root:`unc:${r}/${s}`,segments:C(t.slice(2).join("/"))}}return n.startsWith("/")?{kind:"posix",root:"posix:/",segments:C(n)}:{kind:"relative",root:"",segments:C(n,!0)}}function ie(n,e,t){return n.length<e.length?!1:e.every((r,s)=>{let o=n[s]??"";return t?o.toLowerCase()===r.toLowerCase():o===r})}function Ue(n,e,t){let r=0;for(;r<n.length&&r<e.length;){let o=n[r]??"",i=e[r]??"";if(!(t?o.toLowerCase()===i.toLowerCase():o===i))break;r++}return[...Array.from({length:n.length-r},()=>".."),...e.slice(r)].join("/")||"."}function ae(n){let[e,t]=n.root.slice(4).split("/"),r=n.segments.join("/");return`//${e??""}/${t??""}${r?`/${r}`:""}`}function ce(n,e,t){if(n.kind==="drive-relative"||n.kind==="unc"&&n.root.endsWith("/"))return t;if(n.kind!=="relative")return!(n.kind===e.kind&&(n.kind==="unc"?n.root.toLowerCase()===e.root.toLowerCase():n.root===e.root))||!ie(n.segments,e.segments,n.kind==="drive"||n.kind==="unc")?n.kind==="unc"?ae(n):t:n.segments.slice(e.segments.length).join("/")||".";let r=[...e.segments];for(let o of t.split("/").filter(i=>i.length>0))o!=="."&&(o===".."?r.length>0&&r[r.length-1]!==".."?r.pop():e.kind==="relative"&&r.push(".."):r.push(o));let s=e.kind==="drive"||e.kind==="unc";return ie(r,e.segments,s)?r.slice(e.segments.length).join("/")||".":Ue(e.segments,r,s)}function Be(n,e){if(!n||typeof n!="string")return"";let t=n.replace(/\\/g,"/"),r=e.replace(/\\/g,"/");if(t.startsWith("<tool:")&&t.endsWith(">"))return t;let s=X(t),o=X(r);if(s.kind==="drive"&&o.kind!=="drive"&&o.kind!=="unc"){let c=`/mnt/${s.root.slice(-1).toLowerCase()}/${s.segments.join("/")}`;return s=X(c),ce(s,o,c)}return ce(s,o,t)}function Fe(n,e){let t=n.file_path||n.path||n.file||n.target;if(typeof t=="string"&&t.length>0)return{value:t,isPath:!0};if(e.isBashTool){let r=String(n.command||n.args||"");if(r){let s=/(?:>|>>|sed\s+-i|rm|mv|mkdir|touch|cp)\s+(?:-[a-zA-Z]+\s+)*([^\s;&|<>]+)/.exec(r);return s&&s[1]?{value:s[1],isPath:!0}:{value:r,isPath:!1}}}return e.isWriteTool&&e.toolName?{value:`<tool:${e.toolName}>`,isPath:!0}:{value:null,isPath:!0}}function We(n){return{isBashTool:n==="execute",isWriteTool:n==="write"}}function Xe(n){if(n.canonicalKind===void 0)return n;let e=We(n.canonicalKind);return{...n,isBashTool:n.isBashTool??e.isBashTool,isWriteTool:n.isWriteTool??e.isWriteTool}}function D(n,e,t,r={}){let s=Xe(r),o=Fe(e,{...s,toolName:n}),i=o.isPath?Be(o.value,t):o.value,c=e.command??e.args,a=s.isBashTool&&typeof c=="string"?oe(c):void 0;return{toolName:n,normalizedPath:i,...a?{recoveryControl:a}:{},paramsSummary:{...e},...s.canonicalKind!==void 0?{canonicalKind:s.canonicalKind}:{}}}var $=new Set(["read","search","write","execute","agent","other"]);function le(n){return typeof n=="string"&&$.has(n)}var M=Object.freeze({read:"read",read_file:"read",read_many_files:"read",grep:"search",grep_search:"search",search_file_content:"search",glob:"search",write:"write",write_file:"write",edit:"write",edit_file:"write",replace:"write",apply_patch:"write",bash:"execute",exec:"execute",execute:"execute",run_shell_command:"execute",execute_command:"execute",run_script:"execute",code_interpreter:"execute",sessions_spawn:"agent"});function ue(n,e,t){if(n.status==="unavailable")return{priorReadOfTarget:"unknown",readCount:null,writeCount:null,uniqueWritePathCount:null,sameActionBlockCount:null};let r=0,s=0,o=new Set,i=e===null?"unknown":"no",{calls:c}=n;for(let a of c){let d=a.canonicalKind;d==="read"||d==="search"?(r++,e!==null&&a.normalizedPath===e&&(i="yes")):d==="write"&&(s++,typeof a.normalizedPath=="string"&&o.add(a.normalizedPath))}return{priorReadOfTarget:i,readCount:r,writeCount:s,uniqueWritePathCount:o.size,sameActionBlockCount:t}}var de={priorReadOfTarget:"unknown",readCount:null,writeCount:null,uniqueWritePathCount:null,sameActionBlockCount:null};Object.freeze(de);var H={status:"unavailable",unavailableReason:"host did not provide a history window",truncated:!1,calls:[]};Object.freeze(H.calls);Object.freeze(H);var $e={version:2,history:H,facts:de};Object.freeze($e);var He=new Set(["__proto__","constructor","prototype"]),pe=3,Ye=5,Ke=new Set(["allow","block","propose_correction"]),Ge={valid:!0,errors:[]};function Y(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function me(n){for(let e of Object.keys(n))if(He.has(e))return!1;return!0}function qe(n){return n.length===0?Ge:{valid:!1,errors:n}}function K(n){return typeof n=="string"&&n.trim().length>0}function fe(n,e,t){let r=[];return Y(n)?me(n)?((!Object.hasOwn(n,"caseId")||!K(n.caseId))&&r.push(`${e}.caseId must be a non-empty string`),(!Object.hasOwn(n,"kind")||n.kind!==t)&&r.push(`${e}.kind must be '${t}'`),(!Object.hasOwn(n,"toolName")||!K(n.toolName))&&r.push(`${e}.toolName must be a non-empty string`),(!Object.hasOwn(n,"params")||!Y(n.params))&&r.push(`${e}.params must be a plain object`),!Object.hasOwn(n,"expectedDecision")||typeof n.expectedDecision!="string"||!Ke.has(n.expectedDecision)?r.push(`${e}.expectedDecision must be one of allow|block|propose_correction`):t==="positive"&&n.expectedDecision!=="allow"&&r.push(`${e}: positive cases must expect allow`),r):(r.push(`${e} must not carry prototype-pollution keys`),r):(r.push(`${e} must be a plain object`),r)}function _e(n,e){let{fieldName:t,maxLength:r,requireNonEmpty:s}=e,o=[];if(!Array.isArray(n))return o.push(`${t} must be an array`),o;s&&n.length===0&&o.push(`${t} must contain at least 1 item`),r!==void 0&&n.length>r&&o.push(`${t} must contain at most ${r} items, got ${n.length}`);for(let i=0;i<n.length;i++)typeof n[i]!="string"&&o.push(`${t}[${i}] must be a string`);return o}function P(n){return Array.isArray(n)?`[${n.map(e=>P(e)).join(",")}]`:typeof n=="object"&&n!==null?`{${Object.keys(n).filter(t=>t!=="__proto__"&&t!=="constructor"&&t!=="prototype").sort().map(t=>`${JSON.stringify(t)}:${P(n[t])}`).join(",")}}`:JSON.stringify(n)??"null"}function G(n){if(!Y(n))return{valid:!1,errors:["BehaviorExamplePack must be a plain object"]};if(!me(n))return{valid:!1,errors:["BehaviorExamplePack must not carry prototype-pollution keys"]};let e=[];if(Object.hasOwn(n,"sourceNegativeCase")?e.push(...fe(n.sourceNegativeCase,"sourceNegativeCase","negative")):e.push("sourceNegativeCase is required"),(!Object.hasOwn(n,"ownerDesiredOutcome")||!K(n.ownerDesiredOutcome))&&e.push("ownerDesiredOutcome must be a non-empty string"),!Object.hasOwn(n,"positiveCounterexamples"))e.push("positiveCounterexamples is required");else if(!Array.isArray(n.positiveCounterexamples))e.push("positiveCounterexamples must be an array");else{let t=n.positiveCounterexamples;t.length===0&&e.push("positiveCounterexamples must contain at least 1 item"),t.length>pe&&e.push(`positiveCounterexamples must contain at most ${pe} items, got ${t.length}`);for(let r=0;r<t.length;r++)e.push(...fe(t[r],`positiveCounterexamples[${r}]`,"positive"))}if(Object.hasOwn(n,"evidenceRefs")?e.push(..._e(n.evidenceRefs,{fieldName:"evidenceRefs",maxLength:Ye,requireNonEmpty:!0})):e.push("evidenceRefs is required"),Object.hasOwn(n,"redactionNotes")?e.push(..._e(n.redactionNotes,{fieldName:"redactionNotes"})):e.push("redactionNotes is required"),e.length===0){let t=n.sourceNegativeCase,r=n.positiveCounterexamples,s=P({toolName:t.toolName,params:t.params,ruleContext:t.ruleContext});for(let o=0;o<r.length;o++){let i=r[o];i!==void 0&&P({toolName:i.toolName,params:i.params,ruleContext:i.ruleContext})===s&&e.push(`positiveCounterexamples[${o}] conflicting_label: identical effective input (toolName + params + ruleContext) as sourceNegativeCase but opposite expectedDecision \u2014 same input cannot carry both labels`)}}return qe(e)}var ze="OwnerEvidenceScopeError";function A(n,e){let t=new Error(e);return t.name=ze,Object.assign(t,{ownerEvidenceScopeKind:n}),t}var Ve=new Set(["success","failure","blocked"]);function Je(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Ze(n){return typeof n=="string"&&Ve.has(n)}function I(n){return{status:"unavailable",unavailableReason:n,truncated:!1,calls:[]}}function Ee(n,e,t){let{projectDir:r,toolSemantics:s}=t,o=[];for(let i of n){let{toolName:c}=i;if(typeof c!="string"||c.length===0)return I(`row id=${i.id}: tool_name must be a non-empty string`);let{outcome:a}=i;if(!Ze(a))return I(`row id=${i.id}: outcome "${i.outcome}" is not a valid RuleToolOutcome`);let d=i.paramsJson;if(typeof d!="string")return I(`row id=${i.id}: params_json must be a string`);let T;try{T=JSON.parse(d)}catch{return I(`row id=${i.id}: params_json is not valid JSON`)}if(!Je(T))return I(`row id=${i.id}: params_json must parse to a non-array object`);let m=s.resolve(c),{normalizedPath:g}=D(c,T,r,{canonicalKind:m});o.push({sequenceId:i.id,toolName:c,canonicalKind:m,normalizedPath:g===""?null:g,paramsSummary:T,outcome:a})}return{status:"available",truncated:e,calls:o}}var Qe=3,et=5,tt=100,Te=new Set(["__proto__","constructor","prototype"]);function j(n,e){try{return e()}catch(t){let r=t instanceof Error?t.message:String(t);throw A("evidence_source_error",`[BehaviorExamplePackAssembler] trajectory store ${n} failed (evidence source error, SPEC-PD-IAER-001 \xA76.2): ${r}`)}}function nt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function rt(n){for(let e of Object.keys(n))if(Te.has(e))return!1;return!0}function st(n){if(!Number.isSafeInteger(n.sourceNegativeToolCallId)||n.sourceNegativeToolCallId<=0)throw new Error("[BehaviorExamplePackAssembler] sourceNegativeToolCallId must be a positive integer");if(!Array.isArray(n.positiveToolCallIds)||n.positiveToolCallIds.length===0||n.positiveToolCallIds.length>Qe)throw new Error("[BehaviorExamplePackAssembler] positiveToolCallIds must contain 1 to at most 3 IDs");let e=[n.sourceNegativeToolCallId,...n.positiveToolCallIds];if(e.some(t=>!Number.isSafeInteger(t)||t<=0)||new Set(e).size!==e.length)throw new Error("[BehaviorExamplePackAssembler] selected tool call IDs must be unique positive integers")}function he(n,e){if(!n)throw A("tool_call_not_found",`[BehaviorExamplePackAssembler] selected tool call id=${e} not found`);return n}function ot(n,e,t){if(typeof n.toolName!="string"||n.toolName.length===0)throw new Error(`[BehaviorExamplePackAssembler] row id=${n.id}: toolName must be a non-empty string (rc-9 fail loud)`);if(typeof n.paramsJson!="string")throw new Error(`[BehaviorExamplePackAssembler] row id=${n.id}: paramsJson must be a string (rc-9 fail loud)`);let r;try{r=JSON.parse(n.paramsJson)}catch{throw new Error(`[BehaviorExamplePackAssembler] row id=${n.id}: paramsJson is not valid JSON (rc-9 fail loud)`)}if(!nt(r))throw new Error(`[BehaviorExamplePackAssembler] row id=${n.id}: paramsJson must parse to a non-array object (rc-9 fail loud)`);if(!rt(r))throw new Error(`[BehaviorExamplePackAssembler] row id=${n.id}: paramsJson must not carry prototype-pollution keys (ERR-076, rc-9 fail loud)`);return{caseId:`case-${e}-${n.id}`,kind:e,toolName:n.toolName,params:r,expectedDecision:t}}function it(n){return n.startsWith("/")||/^[A-Za-z]:[\\/]/.test(n)}var at=[/AKIA[0-9A-Z]{16}/,/[A-Za-z0-9+/]{40,}/];function ct(n){if(n.length<20)return!1;for(let e of at)if(e.test(n))return!0;return!1}function lt(n,e){let t=[],r={};for(let s of Object.keys(n)){if(Te.has(s))continue;let o=n[s];if(typeof o!="string"){r[s]=o;continue}if(it(o)&&!o.startsWith(e)){r[s]="<redacted:absolute-path>",t.push(`redacted absolute path in field "${s}" (outside project tree)`);continue}if(ct(o)){r[s]="<redacted:secret>",t.push(`redacted possible secret in field "${s}"`);continue}r[s]=o}return{redacted:r,notes:t}}var U=class{db;toolSemantics;constructor(e){this.db=e.source,this.toolSemantics=e.toolSemantics}assemble(e){let t=j(`pain lineage read for canonical_pain_id="${e.sourcePainId}"`,()=>this.db.getPainEventByCanonicalId(e.sourcePainId));if(!t)throw A("pain_not_found",`[BehaviorExamplePackAssembler] pain event not found for canonical_pain_id="${e.sourcePainId}" (ERR-069 fail loud)`);st(e);let r=he(j(`evidence row read for id=${e.sourceNegativeToolCallId}`,()=>this.db.getRuleHostEvidenceRow(e.sourceNegativeToolCallId)),e.sourceNegativeToolCallId),s=e.positiveToolCallIds.map(m=>he(j(`evidence row read for id=${m}`,()=>this.db.getRuleHostEvidenceRow(m)),m));for(let m of[r,...s])if(m.sessionId!==t.sessionId)throw A("session_mismatch",`[BehaviorExamplePackAssembler] selected tool call ${m.id} session mismatch; all examples must belong to pain session ${t.sessionId}`);let o=[],i={projectDir:e.projectDir,redactionNotes:o},c=this.buildSelectedCase(r,"negative",i),a=s.map(m=>this.buildSelectedCase(m,"positive",i)),d={sourceNegativeCase:c,ownerDesiredOutcome:e.ownerDesiredOutcome,positiveCounterexamples:a,evidenceRefs:[`pain:${t.id}`,`tool_call:${r.id}`,...s.map(m=>`tool_call:${m.id}`)].slice(0,et),redactionNotes:o},T=G(d);if(!T.valid)throw new Error(`[BehaviorExamplePackAssembler] assembled pack failed validateBehaviorExamplePack: ${T.errors.join("; ")} (ERR-069 fail loud)`);return d}buildSelectedCase(e,t,r){let{projectDir:s,redactionNotes:o}=r,i=ot(e,t,t==="negative"?"block":"allow"),c=lt(i.params,s);o.push(...c.notes);let a=j(`context history read for session=${e.sessionId} before id=${e.id}`,()=>this.db.getRuleHostContextRowsBefore(e.sessionId,e.id,tt)),d=Ee(a.rows,a.truncated,{projectDir:s,toolSemantics:this.toolSemantics}),T=D(e.toolName,c.redacted,s,{canonicalKind:this.toolSemantics.resolve(e.toolName)}),m={version:2,history:d,facts:ue(d,T.normalizedPath||null,null)};return{...i,params:c.redacted,ruleContext:m}}};import vt from"better-sqlite3";import f from"fs";import h from"path";import Z from"crypto";import*as p from"fs";import*as Se from"path";var q=class extends Error{filePath;lockPath;constructor(e,t,r){super(e),this.name="LockAcquisitionError",this.filePath=t,this.lockPath=r}},ut={maxRetries:50,baseRetryDelayMs:10,maxRetryDelayMs:500,lockStaleMs:1e4,lockSuffix:".lock"};function ye(n){try{return process.kill(n,0),!0}catch{return!1}}function ge(n,e){try{let t=Se.dirname(n);p.existsSync(t)||p.mkdirSync(t,{recursive:!0});let r=p.constants.O_WRONLY|p.constants.O_CREAT|p.constants.O_EXCL,s=p.openSync(n,r);return p.writeSync(s,String(e)),p.fsyncSync(s),p.closeSync(s),!0}catch(t){if(t.code==="EEXIST")return!1;throw t}}function w(n){try{let e=p.readFileSync(n,"utf8"),t=parseInt(e.trim(),10);return Number.isNaN(t)?null:t}catch{return null}}function dt(n,e){try{w(n)===e&&p.unlinkSync(n)}catch{}}function pt(n,e){try{let t=p.statSync(n),r=w(n),s=Date.now()-t.mtimeMs>e,o=r===null||!ye(r);if(s||o)try{return p.unlinkSync(n),!0}catch{return!1}return!1}catch{return!1}}function ft(n,e,t){let r=Math.min(e*Math.pow(2,n),t),s=r*.2*Math.random();return Math.floor(r+s)}function _t(n){let e=Date.now()+n;for(;Date.now()<e;);}function mt(n,e){let t=w(e),r=t!==null?ye(t)?`alive (PID ${t})`:`dead (PID ${t})`:"unknown";return new q(`Failed to acquire lock for ${n}. Lock holder: ${r}.`,n,e)}function Et(n,e,t){let r=n+e.lockSuffix;return ge(r,t)&&w(r)===t?{lockPath:r,pid:t,acquiredAt:Date.now()}:(pt(r,e.lockStaleMs),ge(r,t)&&w(r)===t?{lockPath:r,pid:t,acquiredAt:Date.now()}:null)}function ht(n,e={}){let t={...ut,...e},{pid:r}=process;for(let s=0;s<t.maxRetries;s++){let o=Et(n,t,r);if(o)return o;if(s<t.maxRetries-1){let i=ft(s,t.baseRetryDelayMs,t.maxRetryDelayMs);_t(i)}}throw mt(n,n+t.lockSuffix)}function Tt(n){dt(n.lockPath,n.pid)}function be(n,e,t={}){let r=ht(n,t);try{return e()}finally{Tt(r)}}import*as O from"fs";var Oe=3,gt=50;function B(n,e){let t=n+".tmp";O.writeFileSync(t,e,"utf8");let r;for(let s=0;s<Oe;s++)try{O.renameSync(t,n);return}catch(o){r=o;let i=o.code;if(i==="EPERM"||i==="EBUSY"||i==="EACCES"){if(s<Oe-1){let c=gt*Math.pow(2,s),a=Date.now()+c,d=!1;for(;Date.now()<a;)if(!d&&Date.now()>=a-10){try{De("fs").accessSync?.(t)}catch{}d=!0}}continue}break}try{O.unlinkSync(t)}catch{}throw r}import*as y from"path";var l=(...n)=>y.posix.join(...n);function St(n){return/^[A-Za-z]:[\\/]/.test(n)||n.startsWith("\\\\")}function yt(n,e){return St(n)?y.win32.join(n,e):n.startsWith("/")?y.posix.join(n,e):y.join(n,e)}var u={IDENTITY:".principles",MODELS:l(".principles","models"),STATE:".state",MEMORY:"memory",OKR:l("memory","okr"),LOGS:l("memory","logs"),SESSIONS:l(".state","sessions"),PAIN_SAMPLES:l("memory","pain"),LOCKS:l("memory",".locks"),IMPL_CODE_DIR:l(".state","principles","implementations")},bt={PROFILE:l(u.IDENTITY,"PROFILE.json"),PRINCIPLES:l(u.IDENTITY,"PRINCIPLES.md"),THINKING_OS:l(u.IDENTITY,"THINKING_OS.md"),DECISION_POLICY:l(u.IDENTITY,"DECISION_POLICY.json"),MODELS_DIR:u.MODELS,STATE_DIR:u.STATE,WORKBOARD:l(u.STATE,"WORKBOARD.json"),AGENT_SCORECARD:l(u.STATE,"AGENT_SCORECARD.json"),PAIN_FLAG:l(u.STATE,".pain_flag"),SYSTEM_CAPABILITIES:l(u.STATE,"SYSTEM_CAPABILITIES.json"),PAIN_SETTINGS:l(u.STATE,"pain_settings.json"),PAIN_CANDIDATES:l(u.STATE,"pain_candidates.json"),TRAJECTORY_DB:l(u.STATE,"trajectory.db"),TRAJECTORY_BLOBS_DIR:l(u.STATE,"blobs"),EXPORTS_DIR:l(u.STATE,"exports"),SESSION_DIR:u.SESSIONS,DICTIONARY:l(u.STATE,"pain_dictionary.json"),PRINCIPLE_BLACKLIST:l(u.STATE,"principle_blacklist.json"),WORKFLOWS_YAML:l(u.STATE,"workflows.yaml"),IMPL_CODE_DIR:u.IMPL_CODE_DIR,MEMORY_MD:"MEMORY.md",HEARTBEAT:"HEARTBEAT.md",SYSTEM_LOG:l(u.LOGS,"SYSTEM.log"),REFLECTION_LOG:l(u.MEMORY,"reflection-log.md"),USER_CONTEXT:l(u.MEMORY,"USER_CONTEXT.md"),OKR_DIR:u.OKR,CURRENT_FOCUS:l(u.OKR,"CURRENT_FOCUS.md"),WEEK_STATE:l(u.OKR,"WEEK_STATE.json"),EVOLUTION_STREAM:l(u.MEMORY,"evolution.jsonl"),EVOLUTION_LOCK:l(u.LOCKS,"evolution")};function b(n,e){return yt(n,bt[e])}var Ot={LOCK_UNAVAILABLE:"lease_conflict",PATH_RESOLUTION_ERROR:"workspace_invalid",WORKSPACE_NOT_FOUND:"workspace_invalid",SAMPLE_NOT_FOUND:"storage_unavailable",CONFIGURATION_ERROR:"input_invalid",DEPENDENCY_ERROR:"runtime_unavailable",EVOLUTION_PROCESSING_ERROR:"execution_failed",TRAJECTORY_ERROR:"storage_unavailable"},z=class extends Error{constructor(t,r,s){super(t,s);this.code=r;this.name="PdError",this.category=Ot[r]??"execution_failed"}code;category};var v=class extends z{constructor(e,t){super(`[PD:Sample] Correction sample not found: ${e}`,"SAMPLE_NOT_FOUND",t),this.name="SampleNotFoundError"}};var Rt=["schema_version","ingest_checkpoint","sessions","assistant_turns","user_turns","tool_calls","pain_events","gate_blocks","trust_changes","principle_events","task_outcomes","correction_samples","sample_reviews","signal_confirmations","exports_audit"];function E(n){let e=n instanceof Error?n.message:String(n);return e.includes("duplicate column name")||e.includes("no column named")}function Nt(n,e){return n.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?").get(e)!==void 0}function Re(n,e={}){let t=[],r=[...Rt];n.exec("CREATE TABLE IF NOT EXISTS schema_version (version INTEGER NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS ingest_checkpoint (source_key TEXT PRIMARY KEY, imported_at TEXT NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS sessions (session_id TEXT PRIMARY KEY, started_at TEXT NOT NULL, updated_at TEXT NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS assistant_turns (id INTEGER PRIMARY KEY AUTOINCREMENT, session_id TEXT NOT NULL, run_id TEXT NOT NULL, provider TEXT NOT NULL, model TEXT NOT NULL, raw_text TEXT, sanitized_text TEXT NOT NULL, usage_json TEXT NOT NULL, empathy_signal_json TEXT NOT NULL, blob_ref TEXT, raw_excerpt TEXT, stop_reason TEXT, thinking_blocks_count INTEGER, created_at TEXT NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS user_turns (id INTEGER PRIMARY KEY AUTOINCREMENT, session_id TEXT NOT NULL, turn_index INTEGER NOT NULL, raw_text TEXT, blob_ref TEXT, raw_excerpt TEXT, correction_detected INTEGER NOT NULL DEFAULT 0, correction_cue TEXT, references_assistant_turn_id INTEGER, created_at TEXT NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS tool_calls (id INTEGER PRIMARY KEY AUTOINCREMENT, session_id TEXT NOT NULL, tool_name TEXT NOT NULL, outcome TEXT NOT NULL, duration_ms INTEGER, exit_code INTEGER, error_type TEXT, error_message TEXT, gfi_before REAL, gfi_after REAL, params_json TEXT NOT NULL, result_preview TEXT, created_at TEXT NOT NULL, project_dir TEXT, host_kind TEXT)"),n.exec("CREATE TABLE IF NOT EXISTS pain_events (id INTEGER PRIMARY KEY AUTOINCREMENT, session_id TEXT NOT NULL, source TEXT NOT NULL, score REAL NOT NULL, reason TEXT, severity TEXT, origin TEXT, confidence REAL, text TEXT, canonical_pain_id TEXT, runtime_task_id TEXT, host_kind TEXT, created_at TEXT NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS gate_blocks (id INTEGER PRIMARY KEY AUTOINCREMENT, session_id TEXT, tool_name TEXT NOT NULL, file_path TEXT, reason TEXT NOT NULL, created_at TEXT NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS trust_changes (id INTEGER PRIMARY KEY AUTOINCREMENT, session_id TEXT, previous_score REAL NOT NULL, new_score REAL NOT NULL, delta REAL NOT NULL, reason TEXT NOT NULL, created_at TEXT NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS principle_events (id INTEGER PRIMARY KEY AUTOINCREMENT, principle_id TEXT, event_type TEXT NOT NULL, payload_json TEXT NOT NULL, created_at TEXT NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS task_outcomes (id INTEGER PRIMARY KEY AUTOINCREMENT, session_id TEXT NOT NULL, task_id TEXT, outcome TEXT NOT NULL, summary TEXT, principle_ids_json TEXT NOT NULL, created_at TEXT NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS correction_samples (sample_id TEXT PRIMARY KEY, session_id TEXT NOT NULL, bad_assistant_turn_id INTEGER NOT NULL, user_correction_turn_id INTEGER NOT NULL, recovery_tool_span_json TEXT NOT NULL, diff_excerpt TEXT NOT NULL, principle_ids_json TEXT NOT NULL, quality_score REAL NOT NULL, review_status TEXT NOT NULL, export_mode TEXT NOT NULL, created_at TEXT NOT NULL, updated_at TEXT NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS sample_reviews (id INTEGER PRIMARY KEY AUTOINCREMENT, sample_id TEXT NOT NULL, review_status TEXT NOT NULL, note TEXT, created_at TEXT NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS signal_confirmations (id TEXT PRIMARY KEY, session_id TEXT NOT NULL, user_turn_rowid INTEGER NOT NULL UNIQUE, occurrence_id TEXT NOT NULL, excerpt TEXT NOT NULL, terms_json TEXT NOT NULL, suggested_type TEXT NOT NULL, status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending','confirmed','rejected','abandoned')), attempts INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL, resolved_at TEXT, resolution TEXT)"),n.exec("CREATE TABLE IF NOT EXISTS exports_audit (id INTEGER PRIMARY KEY AUTOINCREMENT, export_kind TEXT NOT NULL, mode TEXT NOT NULL, approved_only INTEGER NOT NULL, file_path TEXT NOT NULL, row_count INTEGER NOT NULL, created_at TEXT NOT NULL)");try{n.exec("ALTER TABLE pain_events ADD COLUMN text TEXT")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE pain_events ADD COLUMN canonical_pain_id TEXT")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE pain_events ADD COLUMN runtime_task_id TEXT")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE pain_events ADD COLUMN host_kind TEXT")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE assistant_turns ADD COLUMN stop_reason TEXT")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE assistant_turns ADD COLUMN thinking_blocks_count INTEGER")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE tool_calls ADD COLUMN result_preview TEXT")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE tool_calls ADD COLUMN tool_use_id TEXT")}catch(s){if(!E(s))throw s}n.exec("CREATE INDEX IF NOT EXISTS idx_tool_calls_session_tool_use_id ON tool_calls(session_id, tool_use_id)");try{n.exec("ALTER TABLE tool_calls ADD COLUMN project_dir TEXT")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE tool_calls ADD COLUMN host_kind TEXT")}catch(s){if(!E(s))throw s}if(n.exec("CREATE UNIQUE INDEX IF NOT EXISTS idx_pain_events_canonical_pain_id ON pain_events(canonical_pain_id) WHERE canonical_pain_id IS NOT NULL"),Nt(n,"evolution_tasks")){try{n.exec("ALTER TABLE evolution_tasks ADD COLUMN task_kind TEXT")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE evolution_tasks ADD COLUMN priority TEXT")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE evolution_tasks ADD COLUMN retry_count INTEGER")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE evolution_tasks ADD COLUMN max_retries INTEGER")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE evolution_tasks ADD COLUMN last_error TEXT")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE evolution_tasks ADD COLUMN result_ref TEXT")}catch(s){if(!E(s))throw s}}return n.exec("CREATE INDEX IF NOT EXISTS idx_assistant_turns_session_id ON assistant_turns(session_id)"),n.exec("CREATE INDEX IF NOT EXISTS idx_assistant_turns_created_at ON assistant_turns(created_at)"),n.exec("CREATE INDEX IF NOT EXISTS idx_assistant_turns_provider_model ON assistant_turns(provider, model)"),n.exec("CREATE INDEX IF NOT EXISTS idx_user_turns_session_id ON user_turns(session_id)"),n.exec("CREATE INDEX IF NOT EXISTS idx_tool_calls_session_id ON tool_calls(session_id)"),n.exec("CREATE INDEX IF NOT EXISTS idx_tool_calls_created_at ON tool_calls(created_at)"),n.exec("CREATE INDEX IF NOT EXISTS idx_pain_events_session_id ON pain_events(session_id)"),n.exec("CREATE INDEX IF NOT EXISTS idx_correction_samples_review_status ON correction_samples(review_status)"),n.exec("CREATE INDEX IF NOT EXISTS idx_signal_confirmations_status ON signal_confirmations(status, attempts)"),e.views===!0&&(n.exec("CREATE VIEW IF NOT EXISTS v_error_clusters AS SELECT tool_name, COALESCE(error_type, 'unknown') AS error_type, COUNT(*) AS occurrences FROM tool_calls WHERE outcome = 'failure' GROUP BY tool_name, COALESCE(error_type, 'unknown') ORDER BY occurrences DESC"),n.exec("CREATE VIEW IF NOT EXISTS v_principle_effectiveness AS SELECT event_type, COUNT(*) AS total FROM principle_events GROUP BY event_type ORDER BY total DESC"),n.exec("CREATE VIEW IF NOT EXISTS v_sample_queue AS SELECT review_status, COUNT(*) AS total FROM correction_samples GROUP BY review_status")),{tables:r,warnings:t}}import*as V from"path";import*as Ne from"os";var At=[/(^|[/\\])fake[/\\]/i,/(^|[/\\])mock[/\\]/i,/(^|[/\\])tmp[/\\]fake-/i],It=V.join(Ne.tmpdir(),".pd-test-quarantine");function wt(n){if(!n)return!1;let e=n.replace(/\\/g,"/");return At.some(t=>t.test(e))}function Ae(n){if(!n||!(process.env.NODE_ENV==="test"||!!process.env.VITEST)||!wt(n))return n;let t=n.replace(/[:*?"<>|]/g,"_").replace(/[/\\]/g,"_");for(;t.startsWith("_");)t=t.slice(1);for(;t.endsWith("_");)t=t.slice(0,-1);return V.join(It,t)}var xt=16*1024,kt=5e3,Lt=7;function ve(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Ct(n){return!ve(n)||typeof n.id!="number"||typeof n.session_id!="string"?!1:Object.hasOwn(n,"source")&&Object.hasOwn(n,"score")&&Object.hasOwn(n,"reason")&&Object.hasOwn(n,"severity")&&Object.hasOwn(n,"origin")&&Object.hasOwn(n,"confidence")&&Object.hasOwn(n,"text")&&Object.hasOwn(n,"canonical_pain_id")&&Object.hasOwn(n,"runtime_task_id")&&Object.hasOwn(n,"created_at")}function Dt(n){let e=Re(n,{views:!0});return{tables:e.tables,warnings:e.warnings}}function _(){return new Date().toISOString()}function R(n){return JSON.stringify(n??{})}function Ie(n){try{return f.existsSync(n)?f.statSync(n).size:0}catch{return 0}}function Mt(n){return n.length>240?`${n.slice(0,237)}...`:n}function we(n){return n.replace(/[A-Za-z]:\\[^\s"'`]+/g,"<WINDOWS_PATH>").replace(/\/[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+/g,"<PATH>").replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi,"<EMAIL>").replace(/\b(sk|rk|pk)_[A-Za-z0-9]+\b/g,"<TOKEN>")}function Pt(n){let e=[],t=!1;try{let r=JSON.parse(String(n.terms_json??"[]"));if(Array.isArray(r))e=r.filter(s=>typeof s=="string");else if(r!==null&&typeof r=="object"){let s=r;if(Object.hasOwn(s,"correction")){let o=s.correction;Array.isArray(o)&&(e=o.filter(i=>typeof i=="string"),t=!0)}}}catch{e=[],t=!1}return{id:String(n.id),sessionId:String(n.session_id),userTurnRowid:Number(n.user_turn_rowid),occurrenceId:String(n.occurrence_id),excerpt:String(n.excerpt),terms:e,termsVerified:t,suggestedType:String(n.suggested_type),status:String(n.status),attempts:Number(n.attempts??0),createdAt:String(n.created_at),resolvedAt:n.resolved_at===null||n.resolved_at===void 0?null:String(n.resolved_at),resolution:n.resolution===null||n.resolution===void 0?null:String(n.resolution)}}var F=class{workspaceDir;stateDir;dbPath;blobDir;exportDir;blobInlineThresholdBytes;orphanBlobGraceMs;db;constructor(e){this.workspaceDir=Ae(h.resolve(e.workspaceDir)),this.stateDir=b(this.workspaceDir,"STATE_DIR"),this.dbPath=b(this.workspaceDir,"TRAJECTORY_DB"),this.blobDir=b(this.workspaceDir,"TRAJECTORY_BLOBS_DIR"),this.exportDir=b(this.workspaceDir,"EXPORTS_DIR"),this.blobInlineThresholdBytes=e.blobInlineThresholdBytes??xt,this.orphanBlobGraceMs=Math.max(0,(e.orphanBlobGraceDays??Lt)*24*60*60*1e3),f.mkdirSync(this.stateDir,{recursive:!0}),f.mkdirSync(this.blobDir,{recursive:!0}),f.mkdirSync(this.exportDir,{recursive:!0}),this.db=new vt(this.dbPath),this.db.pragma("journal_mode = WAL"),this.db.pragma("foreign_keys = ON"),this.db.pragma("synchronous = NORMAL"),this.db.pragma(`busy_timeout = ${Math.max(0,e.busyTimeoutMs??kt)}`),this.initSchema(),this.importLegacyArtifacts(),this.pruneUnreferencedBlobs()}dispose(){this.db.close()}get isOpen(){return this.db.open}recordSession(e){let t=e.startedAt??_();this.withWrite(()=>{this.upsertSessionUnlocked(e.sessionId,t)})}upsertSessionUnlocked(e,t){this.db.prepare(`
|
|
5
|
+
`),s+=1;continue}if(" ".includes(c)){(r||t)&&(e.push(t),t="",r=!1),s+=1;continue}if("|;&<>()".includes(c)){(r||t)&&(e.push(t),t="",r=!1);let a=c,d=n[s+1];c==="<"&&d===">"?a="<>":(c==="|"||c==="&"||c===">"||c==="<")&&d===c&&(a+=d),(c===">"||c==="<")&&d==="("&&(a+=d),e.push(a),s+=a.length;continue}t+=c,r=!0,s+=1}return i!=="plain"?null:((r||t)&&e.push(t),e)}function oe(n){if(/[\\$`|;&<>()*?~{}]/.test(n)||[...n].some(s=>s.charCodeAt(0)<32))return;let e=re(n);if(!e)return;let t=[...e],r=t.findIndex(s=>s==="-w"||s==="--workspace");if(r!==-1){let s=t[r+1];if(r!==t.length-2||!s||s.startsWith("-"))return;t.splice(r,2)}for(let s of ne){if(s.channel!=="cli"||!s.cliCommand||s.capabilityId!=="pd_status"&&s.capabilityId!=="rulecode_deactivate")continue;let o=re(s.cliCommand);if(!o||o.length!==t.length)continue;if(o.every((c,a)=>s.capabilityId==="rulecode_deactivate"&&o[a-1]==="--activation-id"?/^[a-zA-Z0-9][a-zA-Z0-9_.:-]*$/.test(t[a]??""):c===t[a]))return s.capabilityId}}var Pe=["verbose","debug"],je=["erroraction","warningaction","informationaction","progressaction","errorvariable","warningvariable","informationvariable","outvariable","outbuffer","pipelinevariable"];function S(n,e){return{switches:new Set([...Pe,...n]),valued:new Set([...je,...e])}}var qt=Object.freeze({"get-content":S(["raw","force","wait","asbytestream"],["path","literalpath","totalcount","first","tail","last","encoding","delimiter","readcount","stream","credential"]),"get-childitem":S(["recurse","force","name","file","directory","hidden","readonly","system","followsymlink"],["path","literalpath","filter","include","exclude","depth","attributes","credential"]),"get-item":S(["force","followsymlink"],["path","literalpath","filter","include","exclude","stream","credential"]),"get-itemproperty":S(["force"],["path","literalpath","name","filter","include","exclude","credential"]),"select-string":S(["simplematch","casesensitive","notmatch","allmatches","quiet","list","raw"],["pattern","path","literalpath","inputobject","encoding","context","include","exclude","credential"]),"test-path":S(["isvalid"],["path","literalpath","pathtype","filter","credential"]),"resolve-path":S(["relative"],["path","literalpath","relativebasepath","credential"]),"get-location":S(["stack"],["psprovider","psdrive"])});function C(n,e=!1){let t=[];for(let r of n.split("/").filter(s=>s.length>0))r!=="."&&(r===".."?t.length>0&&t[t.length-1]!==".."?t.pop():e&&t.push(".."):t.push(r));return t}function X(n){let e=/^([a-zA-Z]):(?:\/|$)/.exec(n);if(e)return{kind:"drive",root:`drive:${(e[1]??"").toUpperCase()}`,segments:C(n.slice(2))};if(/^[a-zA-Z]:/.test(n))return{kind:"drive-relative",root:n.slice(0,2).toUpperCase(),segments:[]};if(/^\/\/[^/]+(?:\/|$)/.test(n)){let t=n.slice(2).split("/").filter(o=>o.length>0),r=t[0]??"",s=t[1]??"";return{kind:"unc",root:`unc:${r}/${s}`,segments:C(t.slice(2).join("/"))}}return n.startsWith("/")?{kind:"posix",root:"posix:/",segments:C(n)}:{kind:"relative",root:"",segments:C(n,!0)}}function ie(n,e,t){return n.length<e.length?!1:e.every((r,s)=>{let o=n[s]??"";return t?o.toLowerCase()===r.toLowerCase():o===r})}function Ue(n,e,t){let r=0;for(;r<n.length&&r<e.length;){let o=n[r]??"",i=e[r]??"";if(!(t?o.toLowerCase()===i.toLowerCase():o===i))break;r++}return[...Array.from({length:n.length-r},()=>".."),...e.slice(r)].join("/")||"."}function ae(n){let[e,t]=n.root.slice(4).split("/"),r=n.segments.join("/");return`//${e??""}/${t??""}${r?`/${r}`:""}`}function ce(n,e,t){if(n.kind==="drive-relative"||n.kind==="unc"&&n.root.endsWith("/"))return t;if(n.kind!=="relative")return!(n.kind===e.kind&&(n.kind==="unc"?n.root.toLowerCase()===e.root.toLowerCase():n.root===e.root))||!ie(n.segments,e.segments,n.kind==="drive"||n.kind==="unc")?n.kind==="unc"?ae(n):t:n.segments.slice(e.segments.length).join("/")||".";let r=[...e.segments];for(let o of t.split("/").filter(i=>i.length>0))o!=="."&&(o===".."?r.length>0&&r[r.length-1]!==".."?r.pop():e.kind==="relative"&&r.push(".."):r.push(o));let s=e.kind==="drive"||e.kind==="unc";return ie(r,e.segments,s)?r.slice(e.segments.length).join("/")||".":Ue(e.segments,r,s)}function Be(n,e){if(!n||typeof n!="string")return"";let t=n.replace(/\\/g,"/"),r=e.replace(/\\/g,"/");if(t.startsWith("<tool:")&&t.endsWith(">"))return t;let s=X(t),o=X(r);if(s.kind==="drive"&&o.kind!=="drive"&&o.kind!=="unc"){let c=`/mnt/${s.root.slice(-1).toLowerCase()}/${s.segments.join("/")}`;return s=X(c),ce(s,o,c)}return ce(s,o,t)}function Fe(n,e){let t=n.file_path||n.path||n.file||n.target;if(typeof t=="string"&&t.length>0)return{value:t,isPath:!0};if(e.isBashTool){let r=String(n.command||n.args||"");if(r){let s=/(?:>|>>|sed\s+-i|rm|mv|mkdir|touch|cp)\s+(?:-[a-zA-Z]+\s+)*([^\s;&|<>]+)/.exec(r);return s&&s[1]?{value:s[1],isPath:!0}:{value:r,isPath:!1}}}return e.isWriteTool&&e.toolName?{value:`<tool:${e.toolName}>`,isPath:!0}:{value:null,isPath:!0}}function We(n){return{isBashTool:n==="execute",isWriteTool:n==="write"}}function Xe(n){if(n.canonicalKind===void 0)return n;let e=We(n.canonicalKind);return{...n,isBashTool:n.isBashTool??e.isBashTool,isWriteTool:n.isWriteTool??e.isWriteTool}}function D(n,e,t,r={}){let s=Xe(r),o=Fe(e,{...s,toolName:n}),i=o.isPath?Be(o.value,t):o.value,c=e.command??e.args,a=s.isBashTool&&typeof c=="string"?oe(c):void 0;return{toolName:n,normalizedPath:i,...a?{recoveryControl:a}:{},paramsSummary:{...e},...s.canonicalKind!==void 0?{canonicalKind:s.canonicalKind}:{}}}var $=new Set(["read","search","write","execute","agent","other"]);function le(n){return typeof n=="string"&&$.has(n)}var M=Object.freeze({read:"read",read_file:"read",read_many_files:"read",grep:"search",grep_search:"search",search_file_content:"search",glob:"search",write:"write",write_file:"write",edit:"write",edit_file:"write",replace:"write",apply_patch:"write",bash:"execute",exec:"execute",execute:"execute",run_shell_command:"execute",execute_command:"execute",run_script:"execute",code_interpreter:"execute",sessions_spawn:"agent"});function ue(n,e,t){if(n.status==="unavailable")return{priorReadOfTarget:"unknown",readCount:null,writeCount:null,uniqueWritePathCount:null,sameActionBlockCount:null};let r=0,s=0,o=new Set,i=e===null?"unknown":"no",{calls:c}=n;for(let a of c){let d=a.canonicalKind;d==="read"||d==="search"?(r++,e!==null&&a.normalizedPath===e&&(i="yes")):d==="write"&&(s++,typeof a.normalizedPath=="string"&&o.add(a.normalizedPath))}return{priorReadOfTarget:i,readCount:r,writeCount:s,uniqueWritePathCount:o.size,sameActionBlockCount:t}}var de={priorReadOfTarget:"unknown",readCount:null,writeCount:null,uniqueWritePathCount:null,sameActionBlockCount:null};Object.freeze(de);var H={status:"unavailable",unavailableReason:"host did not provide a history window",truncated:!1,calls:[]};Object.freeze(H.calls);Object.freeze(H);var $e={version:2,history:H,facts:de};Object.freeze($e);var He=new Set(["__proto__","constructor","prototype"]),pe=3,Ye=5,Ke=new Set(["allow","block","propose_correction"]),Ge={valid:!0,errors:[]};function Y(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function me(n){for(let e of Object.keys(n))if(He.has(e))return!1;return!0}function qe(n){return n.length===0?Ge:{valid:!1,errors:n}}function K(n){return typeof n=="string"&&n.trim().length>0}function fe(n,e,t){let r=[];return Y(n)?me(n)?((!Object.hasOwn(n,"caseId")||!K(n.caseId))&&r.push(`${e}.caseId must be a non-empty string`),(!Object.hasOwn(n,"kind")||n.kind!==t)&&r.push(`${e}.kind must be '${t}'`),(!Object.hasOwn(n,"toolName")||!K(n.toolName))&&r.push(`${e}.toolName must be a non-empty string`),(!Object.hasOwn(n,"params")||!Y(n.params))&&r.push(`${e}.params must be a plain object`),!Object.hasOwn(n,"expectedDecision")||typeof n.expectedDecision!="string"||!Ke.has(n.expectedDecision)?r.push(`${e}.expectedDecision must be one of allow|block|propose_correction`):t==="positive"&&n.expectedDecision!=="allow"&&r.push(`${e}: positive cases must expect allow`),r):(r.push(`${e} must not carry prototype-pollution keys`),r):(r.push(`${e} must be a plain object`),r)}function _e(n,e){let{fieldName:t,maxLength:r,requireNonEmpty:s}=e,o=[];if(!Array.isArray(n))return o.push(`${t} must be an array`),o;s&&n.length===0&&o.push(`${t} must contain at least 1 item`),r!==void 0&&n.length>r&&o.push(`${t} must contain at most ${r} items, got ${n.length}`);for(let i=0;i<n.length;i++)typeof n[i]!="string"&&o.push(`${t}[${i}] must be a string`);return o}function P(n){return Array.isArray(n)?`[${n.map(e=>P(e)).join(",")}]`:typeof n=="object"&&n!==null?`{${Object.keys(n).filter(t=>t!=="__proto__"&&t!=="constructor"&&t!=="prototype").sort().map(t=>`${JSON.stringify(t)}:${P(n[t])}`).join(",")}}`:JSON.stringify(n)??"null"}function G(n){if(!Y(n))return{valid:!1,errors:["BehaviorExamplePack must be a plain object"]};if(!me(n))return{valid:!1,errors:["BehaviorExamplePack must not carry prototype-pollution keys"]};let e=[];if(Object.hasOwn(n,"sourceNegativeCase")?e.push(...fe(n.sourceNegativeCase,"sourceNegativeCase","negative")):e.push("sourceNegativeCase is required"),(!Object.hasOwn(n,"ownerDesiredOutcome")||!K(n.ownerDesiredOutcome))&&e.push("ownerDesiredOutcome must be a non-empty string"),!Object.hasOwn(n,"positiveCounterexamples"))e.push("positiveCounterexamples is required");else if(!Array.isArray(n.positiveCounterexamples))e.push("positiveCounterexamples must be an array");else{let t=n.positiveCounterexamples;t.length===0&&e.push("positiveCounterexamples must contain at least 1 item"),t.length>pe&&e.push(`positiveCounterexamples must contain at most ${pe} items, got ${t.length}`);for(let r=0;r<t.length;r++)e.push(...fe(t[r],`positiveCounterexamples[${r}]`,"positive"))}if(Object.hasOwn(n,"evidenceRefs")?e.push(..._e(n.evidenceRefs,{fieldName:"evidenceRefs",maxLength:Ye,requireNonEmpty:!0})):e.push("evidenceRefs is required"),Object.hasOwn(n,"redactionNotes")?e.push(..._e(n.redactionNotes,{fieldName:"redactionNotes"})):e.push("redactionNotes is required"),e.length===0){let t=n.sourceNegativeCase,r=n.positiveCounterexamples,s=P({toolName:t.toolName,params:t.params,ruleContext:t.ruleContext});for(let o=0;o<r.length;o++){let i=r[o];i!==void 0&&P({toolName:i.toolName,params:i.params,ruleContext:i.ruleContext})===s&&e.push(`positiveCounterexamples[${o}] conflicting_label: identical effective input (toolName + params + ruleContext) as sourceNegativeCase but opposite expectedDecision \u2014 same input cannot carry both labels`)}}return qe(e)}var ze="OwnerEvidenceScopeError";function A(n,e){let t=new Error(e);return t.name=ze,Object.assign(t,{ownerEvidenceScopeKind:n}),t}var Ve=new Set(["success","failure","blocked"]);function Je(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Ze(n){return typeof n=="string"&&Ve.has(n)}function I(n){return{status:"unavailable",unavailableReason:n,truncated:!1,calls:[]}}function Ee(n,e,t){let{projectDir:r,toolSemantics:s}=t,o=[];for(let i of n){let{toolName:c}=i;if(typeof c!="string"||c.length===0)return I(`row id=${i.id}: tool_name must be a non-empty string`);let{outcome:a}=i;if(!Ze(a))return I(`row id=${i.id}: outcome "${i.outcome}" is not a valid RuleToolOutcome`);let d=i.paramsJson;if(typeof d!="string")return I(`row id=${i.id}: params_json must be a string`);let T;try{T=JSON.parse(d)}catch{return I(`row id=${i.id}: params_json is not valid JSON`)}if(!Je(T))return I(`row id=${i.id}: params_json must parse to a non-array object`);let m=s.resolve(c),{normalizedPath:g}=D(c,T,r,{canonicalKind:m});o.push({sequenceId:i.id,toolName:c,canonicalKind:m,normalizedPath:g===""?null:g,paramsSummary:T,outcome:a})}return{status:"available",truncated:e,calls:o}}var Qe=3,et=5,tt=100,Te=new Set(["__proto__","constructor","prototype"]);function j(n,e){try{return e()}catch(t){let r=t instanceof Error?t.message:String(t);throw A("evidence_source_error",`[BehaviorExamplePackAssembler] trajectory store ${n} failed (evidence source error, SPEC-PD-IAER-001 \xA76.2): ${r}`)}}function nt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function rt(n){for(let e of Object.keys(n))if(Te.has(e))return!1;return!0}function st(n){if(!Number.isSafeInteger(n.sourceNegativeToolCallId)||n.sourceNegativeToolCallId<=0)throw new Error("[BehaviorExamplePackAssembler] sourceNegativeToolCallId must be a positive integer");if(!Array.isArray(n.positiveToolCallIds)||n.positiveToolCallIds.length===0||n.positiveToolCallIds.length>Qe)throw new Error("[BehaviorExamplePackAssembler] positiveToolCallIds must contain 1 to at most 3 IDs");let e=[n.sourceNegativeToolCallId,...n.positiveToolCallIds];if(e.some(t=>!Number.isSafeInteger(t)||t<=0)||new Set(e).size!==e.length)throw new Error("[BehaviorExamplePackAssembler] selected tool call IDs must be unique positive integers")}function he(n,e){if(!n)throw A("tool_call_not_found",`[BehaviorExamplePackAssembler] selected tool call id=${e} not found`);return n}function ot(n,e,t){if(typeof n.toolName!="string"||n.toolName.length===0)throw new Error(`[BehaviorExamplePackAssembler] row id=${n.id}: toolName must be a non-empty string (rc-9 fail loud)`);if(typeof n.paramsJson!="string")throw new Error(`[BehaviorExamplePackAssembler] row id=${n.id}: paramsJson must be a string (rc-9 fail loud)`);let r;try{r=JSON.parse(n.paramsJson)}catch{throw new Error(`[BehaviorExamplePackAssembler] row id=${n.id}: paramsJson is not valid JSON (rc-9 fail loud)`)}if(!nt(r))throw new Error(`[BehaviorExamplePackAssembler] row id=${n.id}: paramsJson must parse to a non-array object (rc-9 fail loud)`);if(!rt(r))throw new Error(`[BehaviorExamplePackAssembler] row id=${n.id}: paramsJson must not carry prototype-pollution keys (ERR-076, rc-9 fail loud)`);return{caseId:`case-${e}-${n.id}`,kind:e,toolName:n.toolName,params:r,expectedDecision:t}}function it(n){return n.startsWith("/")||/^[A-Za-z]:[\\/]/.test(n)}var at=[/AKIA[0-9A-Z]{16}/,/[A-Za-z0-9+/]{40,}/];function ct(n){if(n.length<20)return!1;for(let e of at)if(e.test(n))return!0;return!1}function lt(n,e){let t=[],r={};for(let s of Object.keys(n)){if(Te.has(s))continue;let o=n[s];if(typeof o!="string"){r[s]=o;continue}if(it(o)&&!o.startsWith(e)){r[s]="<redacted:absolute-path>",t.push(`redacted absolute path in field "${s}" (outside project tree)`);continue}if(ct(o)){r[s]="<redacted:secret>",t.push(`redacted possible secret in field "${s}"`);continue}r[s]=o}return{redacted:r,notes:t}}var U=class{db;toolSemantics;constructor(e){this.db=e.source,this.toolSemantics=e.toolSemantics}assemble(e){let t=j(`pain lineage read for canonical_pain_id="${e.sourcePainId}"`,()=>this.db.getPainEventByCanonicalId(e.sourcePainId));if(!t)throw A("pain_not_found",`[BehaviorExamplePackAssembler] pain event not found for canonical_pain_id="${e.sourcePainId}" (ERR-069 fail loud)`);st(e);let r=he(j(`evidence row read for id=${e.sourceNegativeToolCallId}`,()=>this.db.getRuleHostEvidenceRow(e.sourceNegativeToolCallId)),e.sourceNegativeToolCallId),s=e.positiveToolCallIds.map(m=>he(j(`evidence row read for id=${m}`,()=>this.db.getRuleHostEvidenceRow(m)),m));for(let m of[r,...s])if(m.sessionId!==t.sessionId)throw A("session_mismatch",`[BehaviorExamplePackAssembler] selected tool call ${m.id} session mismatch; all examples must belong to pain session ${t.sessionId}`);let o=[],i={projectDir:e.projectDir,redactionNotes:o},c=this.buildSelectedCase(r,"negative",i),a=s.map(m=>this.buildSelectedCase(m,"positive",i)),d={sourceNegativeCase:c,ownerDesiredOutcome:e.ownerDesiredOutcome,positiveCounterexamples:a,evidenceRefs:[`pain:${t.id}`,`tool_call:${r.id}`,...s.map(m=>`tool_call:${m.id}`)].slice(0,et),redactionNotes:o},T=G(d);if(!T.valid)throw new Error(`[BehaviorExamplePackAssembler] assembled pack failed validateBehaviorExamplePack: ${T.errors.join("; ")} (ERR-069 fail loud)`);return d}buildSelectedCase(e,t,r){let{projectDir:s,redactionNotes:o}=r,i=ot(e,t,t==="negative"?"block":"allow"),c=lt(i.params,s);o.push(...c.notes);let a=j(`context history read for session=${e.sessionId} before id=${e.id}`,()=>this.db.getRuleHostContextRowsBefore(e.sessionId,e.id,tt)),d=Ee(a.rows,a.truncated,{projectDir:s,toolSemantics:this.toolSemantics}),T=D(e.toolName,c.redacted,s,{canonicalKind:this.toolSemantics.resolve(e.toolName)}),m={version:2,history:d,facts:ue(d,T.normalizedPath||null,null)};return{...i,params:c.redacted,ruleContext:m}}};import vt from"better-sqlite3";import f from"fs";import h from"path";import Z from"crypto";import*as p from"fs";import*as Se from"path";var q=class extends Error{filePath;lockPath;constructor(e,t,r){super(e),this.name="LockAcquisitionError",this.filePath=t,this.lockPath=r}},ut={maxRetries:50,baseRetryDelayMs:10,maxRetryDelayMs:500,lockStaleMs:1e4,lockSuffix:".lock"};function be(n){try{return process.kill(n,0),!0}catch{return!1}}function ge(n,e){try{let t=Se.dirname(n);p.existsSync(t)||p.mkdirSync(t,{recursive:!0});let r=p.constants.O_WRONLY|p.constants.O_CREAT|p.constants.O_EXCL,s=p.openSync(n,r);return p.writeSync(s,String(e)),p.fsyncSync(s),p.closeSync(s),!0}catch(t){if(t.code==="EEXIST")return!1;throw t}}function w(n){try{let e=p.readFileSync(n,"utf8"),t=parseInt(e.trim(),10);return Number.isNaN(t)?null:t}catch{return null}}function dt(n,e){try{w(n)===e&&p.unlinkSync(n)}catch{}}function pt(n,e){try{let t=p.statSync(n),r=w(n),s=Date.now()-t.mtimeMs>e,o=r===null||!be(r);if(s||o)try{return p.unlinkSync(n),!0}catch{return!1}return!1}catch{return!1}}function ft(n,e,t){let r=Math.min(e*Math.pow(2,n),t),s=r*.2*Math.random();return Math.floor(r+s)}function _t(n){let e=Date.now()+n;for(;Date.now()<e;);}function mt(n,e){let t=w(e),r=t!==null?be(t)?`alive (PID ${t})`:`dead (PID ${t})`:"unknown";return new q(`Failed to acquire lock for ${n}. Lock holder: ${r}.`,n,e)}function Et(n,e,t){let r=n+e.lockSuffix;return ge(r,t)&&w(r)===t?{lockPath:r,pid:t,acquiredAt:Date.now()}:(pt(r,e.lockStaleMs),ge(r,t)&&w(r)===t?{lockPath:r,pid:t,acquiredAt:Date.now()}:null)}function ht(n,e={}){let t={...ut,...e},{pid:r}=process;for(let s=0;s<t.maxRetries;s++){let o=Et(n,t,r);if(o)return o;if(s<t.maxRetries-1){let i=ft(s,t.baseRetryDelayMs,t.maxRetryDelayMs);_t(i)}}throw mt(n,n+t.lockSuffix)}function Tt(n){dt(n.lockPath,n.pid)}function ye(n,e,t={}){let r=ht(n,t);try{return e()}finally{Tt(r)}}import*as O from"fs";var Oe=3,gt=50;function B(n,e){let t=n+".tmp";O.writeFileSync(t,e,"utf8");let r;for(let s=0;s<Oe;s++)try{O.renameSync(t,n);return}catch(o){r=o;let i=o.code;if(i==="EPERM"||i==="EBUSY"||i==="EACCES"){if(s<Oe-1){let c=gt*Math.pow(2,s),a=Date.now()+c,d=!1;for(;Date.now()<a;)if(!d&&Date.now()>=a-10){try{De("fs").accessSync?.(t)}catch{}d=!0}}continue}break}try{O.unlinkSync(t)}catch{}throw r}import*as b from"path";var l=(...n)=>b.posix.join(...n);function St(n){return/^[A-Za-z]:[\\/]/.test(n)||n.startsWith("\\\\")}function bt(n,e){return St(n)?b.win32.join(n,e):n.startsWith("/")?b.posix.join(n,e):b.join(n,e)}var u={IDENTITY:".principles",MODELS:l(".principles","models"),STATE:".state",MEMORY:"memory",OKR:l("memory","okr"),LOGS:l("memory","logs"),SESSIONS:l(".state","sessions"),PAIN_SAMPLES:l("memory","pain"),LOCKS:l("memory",".locks"),IMPL_CODE_DIR:l(".state","principles","implementations")},yt={PROFILE:l(u.IDENTITY,"PROFILE.json"),PRINCIPLES:l(u.IDENTITY,"PRINCIPLES.md"),THINKING_OS:l(u.IDENTITY,"THINKING_OS.md"),DECISION_POLICY:l(u.IDENTITY,"DECISION_POLICY.json"),MODELS_DIR:u.MODELS,STATE_DIR:u.STATE,WORKBOARD:l(u.STATE,"WORKBOARD.json"),AGENT_SCORECARD:l(u.STATE,"AGENT_SCORECARD.json"),PAIN_FLAG:l(u.STATE,".pain_flag"),SYSTEM_CAPABILITIES:l(u.STATE,"SYSTEM_CAPABILITIES.json"),PAIN_SETTINGS:l(u.STATE,"pain_settings.json"),PAIN_CANDIDATES:l(u.STATE,"pain_candidates.json"),TRAJECTORY_DB:l(u.STATE,"trajectory.db"),TRAJECTORY_BLOBS_DIR:l(u.STATE,"blobs"),EXPORTS_DIR:l(u.STATE,"exports"),SESSION_DIR:u.SESSIONS,DICTIONARY:l(u.STATE,"pain_dictionary.json"),PRINCIPLE_BLACKLIST:l(u.STATE,"principle_blacklist.json"),WORKFLOWS_YAML:l(u.STATE,"workflows.yaml"),IMPL_CODE_DIR:u.IMPL_CODE_DIR,MEMORY_MD:"MEMORY.md",HEARTBEAT:"HEARTBEAT.md",SYSTEM_LOG:l(u.LOGS,"SYSTEM.log"),REFLECTION_LOG:l(u.MEMORY,"reflection-log.md"),USER_CONTEXT:l(u.MEMORY,"USER_CONTEXT.md"),OKR_DIR:u.OKR,CURRENT_FOCUS:l(u.OKR,"CURRENT_FOCUS.md"),WEEK_STATE:l(u.OKR,"WEEK_STATE.json"),EVOLUTION_STREAM:l(u.MEMORY,"evolution.jsonl"),EVOLUTION_LOCK:l(u.LOCKS,"evolution")};function y(n,e){return bt(n,yt[e])}var Ot={LOCK_UNAVAILABLE:"lease_conflict",PATH_RESOLUTION_ERROR:"workspace_invalid",WORKSPACE_NOT_FOUND:"workspace_invalid",SAMPLE_NOT_FOUND:"storage_unavailable",CONFIGURATION_ERROR:"input_invalid",DEPENDENCY_ERROR:"runtime_unavailable",EVOLUTION_PROCESSING_ERROR:"execution_failed",TRAJECTORY_ERROR:"storage_unavailable"},z=class extends Error{constructor(t,r,s){super(t,s);this.code=r;this.name="PdError",this.category=Ot[r]??"execution_failed"}code;category};var v=class extends z{constructor(e,t){super(`[PD:Sample] Correction sample not found: ${e}`,"SAMPLE_NOT_FOUND",t),this.name="SampleNotFoundError"}};var Rt=["schema_version","ingest_checkpoint","sessions","assistant_turns","user_turns","tool_calls","pain_events","gate_blocks","trust_changes","principle_events","task_outcomes","correction_samples","sample_reviews","signal_confirmations","exports_audit"];function E(n){let e=n instanceof Error?n.message:String(n);return e.includes("duplicate column name")||e.includes("no column named")}function Nt(n,e){return n.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?").get(e)!==void 0}function Re(n,e={}){let t=[],r=[...Rt];n.exec("CREATE TABLE IF NOT EXISTS schema_version (version INTEGER NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS ingest_checkpoint (source_key TEXT PRIMARY KEY, imported_at TEXT NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS sessions (session_id TEXT PRIMARY KEY, started_at TEXT NOT NULL, updated_at TEXT NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS assistant_turns (id INTEGER PRIMARY KEY AUTOINCREMENT, session_id TEXT NOT NULL, run_id TEXT NOT NULL, provider TEXT NOT NULL, model TEXT NOT NULL, raw_text TEXT, sanitized_text TEXT NOT NULL, usage_json TEXT NOT NULL, empathy_signal_json TEXT NOT NULL, blob_ref TEXT, raw_excerpt TEXT, stop_reason TEXT, thinking_blocks_count INTEGER, created_at TEXT NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS user_turns (id INTEGER PRIMARY KEY AUTOINCREMENT, session_id TEXT NOT NULL, turn_index INTEGER NOT NULL, raw_text TEXT, blob_ref TEXT, raw_excerpt TEXT, correction_detected INTEGER NOT NULL DEFAULT 0, correction_cue TEXT, references_assistant_turn_id INTEGER, created_at TEXT NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS tool_calls (id INTEGER PRIMARY KEY AUTOINCREMENT, session_id TEXT NOT NULL, tool_name TEXT NOT NULL, outcome TEXT NOT NULL, duration_ms INTEGER, exit_code INTEGER, error_type TEXT, error_message TEXT, gfi_before REAL, gfi_after REAL, params_json TEXT NOT NULL, result_preview TEXT, created_at TEXT NOT NULL, project_dir TEXT, host_kind TEXT)"),n.exec("CREATE TABLE IF NOT EXISTS pain_events (id INTEGER PRIMARY KEY AUTOINCREMENT, session_id TEXT NOT NULL, source TEXT NOT NULL, score REAL NOT NULL, reason TEXT, severity TEXT, origin TEXT, confidence REAL, text TEXT, canonical_pain_id TEXT, runtime_task_id TEXT, host_kind TEXT, created_at TEXT NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS gate_blocks (id INTEGER PRIMARY KEY AUTOINCREMENT, session_id TEXT, tool_name TEXT NOT NULL, file_path TEXT, reason TEXT NOT NULL, created_at TEXT NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS trust_changes (id INTEGER PRIMARY KEY AUTOINCREMENT, session_id TEXT, previous_score REAL NOT NULL, new_score REAL NOT NULL, delta REAL NOT NULL, reason TEXT NOT NULL, created_at TEXT NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS principle_events (id INTEGER PRIMARY KEY AUTOINCREMENT, principle_id TEXT, event_type TEXT NOT NULL, payload_json TEXT NOT NULL, created_at TEXT NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS task_outcomes (id INTEGER PRIMARY KEY AUTOINCREMENT, session_id TEXT NOT NULL, task_id TEXT, outcome TEXT NOT NULL, summary TEXT, principle_ids_json TEXT NOT NULL, created_at TEXT NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS correction_samples (sample_id TEXT PRIMARY KEY, session_id TEXT NOT NULL, bad_assistant_turn_id INTEGER NOT NULL, user_correction_turn_id INTEGER NOT NULL, recovery_tool_span_json TEXT NOT NULL, diff_excerpt TEXT NOT NULL, principle_ids_json TEXT NOT NULL, quality_score REAL NOT NULL, review_status TEXT NOT NULL, export_mode TEXT NOT NULL, created_at TEXT NOT NULL, updated_at TEXT NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS sample_reviews (id INTEGER PRIMARY KEY AUTOINCREMENT, sample_id TEXT NOT NULL, review_status TEXT NOT NULL, note TEXT, created_at TEXT NOT NULL)"),n.exec("CREATE TABLE IF NOT EXISTS signal_confirmations (id TEXT PRIMARY KEY, session_id TEXT NOT NULL, user_turn_rowid INTEGER NOT NULL UNIQUE, occurrence_id TEXT NOT NULL, excerpt TEXT NOT NULL, terms_json TEXT NOT NULL, suggested_type TEXT NOT NULL, status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending','confirmed','rejected','abandoned')), attempts INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL, resolved_at TEXT, resolution TEXT)"),n.exec("CREATE TABLE IF NOT EXISTS exports_audit (id INTEGER PRIMARY KEY AUTOINCREMENT, export_kind TEXT NOT NULL, mode TEXT NOT NULL, approved_only INTEGER NOT NULL, file_path TEXT NOT NULL, row_count INTEGER NOT NULL, created_at TEXT NOT NULL)");try{n.exec("ALTER TABLE pain_events ADD COLUMN text TEXT")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE pain_events ADD COLUMN canonical_pain_id TEXT")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE pain_events ADD COLUMN runtime_task_id TEXT")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE pain_events ADD COLUMN host_kind TEXT")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE assistant_turns ADD COLUMN stop_reason TEXT")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE assistant_turns ADD COLUMN thinking_blocks_count INTEGER")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE tool_calls ADD COLUMN result_preview TEXT")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE tool_calls ADD COLUMN tool_use_id TEXT")}catch(s){if(!E(s))throw s}n.exec("CREATE INDEX IF NOT EXISTS idx_tool_calls_session_tool_use_id ON tool_calls(session_id, tool_use_id)");try{n.exec("ALTER TABLE tool_calls ADD COLUMN project_dir TEXT")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE tool_calls ADD COLUMN host_kind TEXT")}catch(s){if(!E(s))throw s}if(n.exec("CREATE UNIQUE INDEX IF NOT EXISTS idx_pain_events_canonical_pain_id ON pain_events(canonical_pain_id) WHERE canonical_pain_id IS NOT NULL"),Nt(n,"evolution_tasks")){try{n.exec("ALTER TABLE evolution_tasks ADD COLUMN task_kind TEXT")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE evolution_tasks ADD COLUMN priority TEXT")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE evolution_tasks ADD COLUMN retry_count INTEGER")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE evolution_tasks ADD COLUMN max_retries INTEGER")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE evolution_tasks ADD COLUMN last_error TEXT")}catch(s){if(!E(s))throw s}try{n.exec("ALTER TABLE evolution_tasks ADD COLUMN result_ref TEXT")}catch(s){if(!E(s))throw s}}return n.exec("CREATE INDEX IF NOT EXISTS idx_assistant_turns_session_id ON assistant_turns(session_id)"),n.exec("CREATE INDEX IF NOT EXISTS idx_assistant_turns_created_at ON assistant_turns(created_at)"),n.exec("CREATE INDEX IF NOT EXISTS idx_assistant_turns_provider_model ON assistant_turns(provider, model)"),n.exec("CREATE INDEX IF NOT EXISTS idx_user_turns_session_id ON user_turns(session_id)"),n.exec("CREATE INDEX IF NOT EXISTS idx_tool_calls_session_id ON tool_calls(session_id)"),n.exec("CREATE INDEX IF NOT EXISTS idx_tool_calls_created_at ON tool_calls(created_at)"),n.exec("CREATE INDEX IF NOT EXISTS idx_pain_events_session_id ON pain_events(session_id)"),n.exec("CREATE INDEX IF NOT EXISTS idx_correction_samples_review_status ON correction_samples(review_status)"),n.exec("CREATE INDEX IF NOT EXISTS idx_signal_confirmations_status ON signal_confirmations(status, attempts)"),e.views===!0&&(n.exec("CREATE VIEW IF NOT EXISTS v_error_clusters AS SELECT tool_name, COALESCE(error_type, 'unknown') AS error_type, COUNT(*) AS occurrences FROM tool_calls WHERE outcome = 'failure' GROUP BY tool_name, COALESCE(error_type, 'unknown') ORDER BY occurrences DESC"),n.exec("CREATE VIEW IF NOT EXISTS v_principle_effectiveness AS SELECT event_type, COUNT(*) AS total FROM principle_events GROUP BY event_type ORDER BY total DESC"),n.exec("CREATE VIEW IF NOT EXISTS v_sample_queue AS SELECT review_status, COUNT(*) AS total FROM correction_samples GROUP BY review_status")),{tables:r,warnings:t}}import*as V from"path";import*as Ne from"os";var At=[/(^|[/\\])fake[/\\]/i,/(^|[/\\])mock[/\\]/i,/(^|[/\\])tmp[/\\]fake-/i],It=V.join(Ne.tmpdir(),".pd-test-quarantine");function wt(n){if(!n)return!1;let e=n.replace(/\\/g,"/");return At.some(t=>t.test(e))}function Ae(n){if(!n||!(process.env.NODE_ENV==="test"||!!process.env.VITEST)||!wt(n))return n;let t=n.replace(/[:*?"<>|]/g,"_").replace(/[/\\]/g,"_");for(;t.startsWith("_");)t=t.slice(1);for(;t.endsWith("_");)t=t.slice(0,-1);return V.join(It,t)}var xt=16*1024,Lt=5e3,kt=7;function ve(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Ct(n){return!ve(n)||typeof n.id!="number"||typeof n.session_id!="string"?!1:Object.hasOwn(n,"source")&&Object.hasOwn(n,"score")&&Object.hasOwn(n,"reason")&&Object.hasOwn(n,"severity")&&Object.hasOwn(n,"origin")&&Object.hasOwn(n,"confidence")&&Object.hasOwn(n,"text")&&Object.hasOwn(n,"canonical_pain_id")&&Object.hasOwn(n,"runtime_task_id")&&Object.hasOwn(n,"created_at")}function Dt(n){let e=Re(n,{views:!0});return{tables:e.tables,warnings:e.warnings}}function _(){return new Date().toISOString()}function R(n){return JSON.stringify(n??{})}function Ie(n){try{return f.existsSync(n)?f.statSync(n).size:0}catch{return 0}}function Mt(n){return n.length>240?`${n.slice(0,237)}...`:n}function we(n){return n.replace(/[A-Za-z]:\\[^\s"'`]+/g,"<WINDOWS_PATH>").replace(/\/[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+/g,"<PATH>").replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi,"<EMAIL>").replace(/\b(sk|rk|pk)_[A-Za-z0-9]+\b/g,"<TOKEN>")}function Pt(n){let e=[],t=!1;try{let r=JSON.parse(String(n.terms_json??"[]"));if(Array.isArray(r))e=r.filter(s=>typeof s=="string");else if(r!==null&&typeof r=="object"){let s=r;if(Object.hasOwn(s,"correction")){let o=s.correction;Array.isArray(o)&&(e=o.filter(i=>typeof i=="string"),t=!0)}}}catch{e=[],t=!1}return{id:String(n.id),sessionId:String(n.session_id),userTurnRowid:Number(n.user_turn_rowid),occurrenceId:String(n.occurrence_id),excerpt:String(n.excerpt),terms:e,termsVerified:t,suggestedType:String(n.suggested_type),status:String(n.status),attempts:Number(n.attempts??0),createdAt:String(n.created_at),resolvedAt:n.resolved_at===null||n.resolved_at===void 0?null:String(n.resolved_at),resolution:n.resolution===null||n.resolution===void 0?null:String(n.resolution)}}var F=class{workspaceDir;stateDir;dbPath;blobDir;exportDir;blobInlineThresholdBytes;orphanBlobGraceMs;db;constructor(e){this.workspaceDir=Ae(h.resolve(e.workspaceDir)),this.stateDir=y(this.workspaceDir,"STATE_DIR"),this.dbPath=y(this.workspaceDir,"TRAJECTORY_DB"),this.blobDir=y(this.workspaceDir,"TRAJECTORY_BLOBS_DIR"),this.exportDir=y(this.workspaceDir,"EXPORTS_DIR"),this.blobInlineThresholdBytes=e.blobInlineThresholdBytes??xt,this.orphanBlobGraceMs=Math.max(0,(e.orphanBlobGraceDays??kt)*24*60*60*1e3),f.mkdirSync(this.stateDir,{recursive:!0}),f.mkdirSync(this.blobDir,{recursive:!0}),f.mkdirSync(this.exportDir,{recursive:!0}),this.db=new vt(this.dbPath),this.db.pragma("journal_mode = WAL"),this.db.pragma("foreign_keys = ON"),this.db.pragma("synchronous = NORMAL"),this.db.pragma(`busy_timeout = ${Math.max(0,e.busyTimeoutMs??Lt)}`),this.initSchema(),this.importLegacyArtifacts(),this.pruneUnreferencedBlobs()}dispose(){this.db.close()}get isOpen(){return this.db.open}recordSession(e){let t=e.startedAt??_();this.withWrite(()=>{this.upsertSessionUnlocked(e.sessionId,t)})}upsertSessionUnlocked(e,t){this.db.prepare(`
|
|
6
6
|
INSERT INTO sessions (session_id, started_at, updated_at)
|
|
7
7
|
VALUES (?, ?, ?)
|
|
8
8
|
ON CONFLICT(session_id) DO UPDATE SET updated_at = excluded.updated_at
|
|
@@ -162,7 +162,7 @@ var De=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(
|
|
|
162
162
|
review_status, export_mode, created_at, updated_at
|
|
163
163
|
FROM correction_samples
|
|
164
164
|
WHERE sample_id = ?
|
|
165
|
-
`).get(e);if(!i)throw new v(`${e} (after update)`);return
|
|
165
|
+
`).get(e);if(!i)throw new v(`${e} (after update)`);return{sampleId:String(i.sample_id),sessionId:String(i.session_id),badAssistantTurnId:Number(i.bad_assistant_turn_id),userCorrectionTurnId:Number(i.user_correction_turn_id),recoveryToolSpanJson:String(i.recovery_tool_span_json),diffExcerpt:String(i.diff_excerpt??""),principleIdsJson:String(i.principle_ids_json??"[]"),qualityScore:Number(i.quality_score),reviewStatus:i.review_status,exportMode:i.export_mode,createdAt:String(i.created_at),updatedAt:String(i.updated_at)}}enqueueSignalConfirmation(e){let t=`sq_${Z.createHash("sha256").update(`${e.sessionId}:${e.userTurnRowid}`).digest("hex").slice(0,12)}`;this.withWrite(()=>{this.db.prepare(`
|
|
166
166
|
INSERT OR IGNORE INTO signal_confirmations (
|
|
167
167
|
id, session_id, user_turn_rowid, occurrence_id, excerpt,
|
|
168
168
|
terms_json, suggested_type, status, attempts, created_at
|
|
@@ -222,8 +222,8 @@ var De=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(
|
|
|
222
222
|
COALESCE(correction_daily.user_corrections, 0) AS user_corrections
|
|
223
223
|
FROM tool_daily
|
|
224
224
|
LEFT JOIN correction_daily ON correction_daily.day = tool_daily.day;
|
|
225
|
-
`)}dailyMetrics(){return this.db.prepare("SELECT * FROM v_daily_metrics ORDER BY day ASC").all()}importLegacySessions(){let e="legacy:sessions";if(this.isImported(e))return;let t=
|
|
226
|
-
`))try{let o=JSON.parse(s);o.type==="pain_signal"&&o.sessionId&&this.recordPainEvent({sessionId:o.sessionId,source:String(o.data?.source??"legacy"),score:Number(o.data?.score??0),reason:typeof o.data?.reason=="string"?o.data.reason:null,severity:typeof o.data?.severity=="string"?o.data.severity:null,origin:typeof o.data?.origin=="string"?o.data.origin:null,confidence:typeof o.data?.confidence=="number"?o.data.confidence:null,createdAt:o.ts}),o.type==="trust_change"&&this.recordTrustChange({sessionId:o.sessionId,previousScore:Number(o.data?.previousScore??0),newScore:Number(o.data?.newScore??0),delta:Number(o.data?.delta??0),reason:String(o.data?.reason??"legacy"),createdAt:o.ts}),o.type==="gate_block"&&this.recordGateBlock({sessionId:o.sessionId,toolName:String(o.data?.toolName??"unknown"),filePath:typeof o.data?.filePath=="string"?o.data.filePath:null,reason:String(o.data?.reason??"legacy"),createdAt:o.ts})}catch{}this.markImported(e)}importLegacyEvolution(){let e="legacy:evolution";if(this.isImported(e))return;let t=
|
|
225
|
+
`)}dailyMetrics(){return this.db.prepare("SELECT * FROM v_daily_metrics ORDER BY day ASC").all()}importLegacySessions(){let e="legacy:sessions";if(this.isImported(e))return;let t=y(this.workspaceDir,"SESSION_DIR");if(f.existsSync(t)){for(let r of f.readdirSync(t).filter(s=>s.endsWith(".json")))try{let s=JSON.parse(f.readFileSync(h.join(t,r),"utf8"));if(s.sessionId){let o=typeof s.lastActivityAt=="number"?new Date(s.lastActivityAt).toISOString():_();this.recordSession({sessionId:s.sessionId,startedAt:o})}}catch{}this.markImported(e)}}importLegacyEvents(){let e="legacy:events";if(this.isImported(e))return;let t=h.join(this.stateDir,"logs","events.jsonl");if(!f.existsSync(t))return;let r=f.readFileSync(t,"utf8").trim();if(!r){this.markImported(e);return}for(let s of r.split(`
|
|
226
|
+
`))try{let o=JSON.parse(s);o.type==="pain_signal"&&o.sessionId&&this.recordPainEvent({sessionId:o.sessionId,source:String(o.data?.source??"legacy"),score:Number(o.data?.score??0),reason:typeof o.data?.reason=="string"?o.data.reason:null,severity:typeof o.data?.severity=="string"?o.data.severity:null,origin:typeof o.data?.origin=="string"?o.data.origin:null,confidence:typeof o.data?.confidence=="number"?o.data.confidence:null,createdAt:o.ts}),o.type==="trust_change"&&this.recordTrustChange({sessionId:o.sessionId,previousScore:Number(o.data?.previousScore??0),newScore:Number(o.data?.newScore??0),delta:Number(o.data?.delta??0),reason:String(o.data?.reason??"legacy"),createdAt:o.ts}),o.type==="gate_block"&&this.recordGateBlock({sessionId:o.sessionId,toolName:String(o.data?.toolName??"unknown"),filePath:typeof o.data?.filePath=="string"?o.data.filePath:null,reason:String(o.data?.reason??"legacy"),createdAt:o.ts})}catch{}this.markImported(e)}importLegacyEvolution(){let e="legacy:evolution";if(this.isImported(e))return;let t=y(this.workspaceDir,"EVOLUTION_STREAM");if(!f.existsSync(t))return;let r=f.readFileSync(t,"utf8").trim();if(!r){this.markImported(e);return}for(let s of r.split(`
|
|
227
227
|
`))try{let o=JSON.parse(s);this.recordPrincipleEvent({principleId:typeof o.data?.principleId=="string"?o.data.principleId:null,eventType:String(o.type??"legacy"),payload:o.data??{},createdAt:o.ts})}catch{}this.markImported(e)}markImported(e){this.withWrite(()=>{this.db.prepare(`
|
|
228
228
|
INSERT INTO ingest_checkpoint (source_key, imported_at)
|
|
229
229
|
VALUES (?, ?)
|
|
@@ -264,4 +264,4 @@ var De=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(
|
|
|
264
264
|
SELECT blob_ref FROM assistant_turns WHERE blob_ref IS NOT NULL
|
|
265
265
|
UNION
|
|
266
266
|
SELECT blob_ref FROM user_turns WHERE blob_ref IS NOT NULL
|
|
267
|
-
`).all();for(let i of t)i.blob_ref&&e.add(String(i.blob_ref));let r=Date.now(),s=0,o=0;for(let i of f.readdirSync(this.blobDir)){if(e.has(i))continue;let c=h.join(this.blobDir,i),a;try{a=f.statSync(c)}catch{continue}a.isFile()&&(this.orphanBlobGraceMs>0&&r-a.mtimeMs<this.orphanBlobGraceMs||(o+=a.size,s+=1,f.rmSync(c,{force:!0})))}return{removedFiles:s,reclaimedBytes:o}}withWrite(e){return
|
|
267
|
+
`).all();for(let i of t)i.blob_ref&&e.add(String(i.blob_ref));let r=Date.now(),s=0,o=0;for(let i of f.readdirSync(this.blobDir)){if(e.has(i))continue;let c=h.join(this.blobDir,i),a;try{a=f.statSync(c)}catch{continue}a.isFile()&&(this.orphanBlobGraceMs>0&&r-a.mtimeMs<this.orphanBlobGraceMs||(o+=a.size,s+=1,f.rmSync(c,{force:!0})))}return{removedFiles:s,reclaimedBytes:o}}withWrite(e){return ye(this.dbPath,e,{lockSuffix:".trajectory.lock",lockStaleMs:3e4})}},x=class{static instances=new Map;static get(e,t={}){let r=h.resolve(e),s=this.instances.get(r);if(s)return s;let o=new F({workspaceDir:r,...t});return this.instances.set(r,o),o}static dispose(e){let t=h.resolve(e),r=this.instances.get(t);r&&(r.dispose(),this.instances.delete(t))}static clear(){for(let e of this.instances.values())e.dispose();this.instances.clear()}static use(e,t,r={}){let s=h.resolve(e),o=this.instances.get(s);if(o)return t(o);let i=new F({workspaceDir:s,...r});try{return t(i)}finally{i.dispose()}}};var jt=new Set(["__proto__","constructor","prototype"]);function Ut(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Bt(n){if(!Array.isArray(n))return{valid:!1,errors:["toolSemanticMappings must be an array"]};let e=[],t=new Map;return n.forEach((r,s)=>{if(!Ut(r)){e.push(`toolSemanticMappings[${s}] must be a plain object`);return}if(!Object.hasOwn(r,"rawToolName")||typeof r.rawToolName!="string"||r.rawToolName.trim()===""){e.push(`toolSemanticMappings[${s}].rawToolName must be a non-empty string`);return}if(jt.has(r.rawToolName)){e.push(`toolSemanticMappings[${s}].rawToolName must not be a prototype-pollution key`);return}let o=r.canonicalKind;if(!le(o)){e.push(`toolSemanticMappings[${s}].canonicalKind must be one of ${[...$].join("|")}, got ${String(o)}`);return}let i=t.get(r.rawToolName);if(i!==void 0&&i!==o){e.push(`toolSemanticMappings[${s}]: rawToolName '${r.rawToolName}' declared twice with conflicting kinds (${i} vs ${o})`);return}t.set(r.rawToolName,o)}),{valid:e.length===0,errors:e}}function xe(n){let e,t=new Set,r=[];if(n===void 0)e=M;else{let s=Bt(n);if(!s.valid)return{ok:!1,errors:s.errors};let o={...M};for(let i of n)o[i.rawToolName]=i.canonicalKind,t.add(i.rawToolName);r=Object.freeze(n.map(i=>Object.freeze({rawToolName:i.rawToolName,canonicalKind:i.canonicalKind}))),e=Object.freeze(o)}return{ok:!0,registry:{version:1,hasHostLayer:t.size>0,hasHostTool(s){return typeof s!="string"?!1:t.has(s)},hostMappings(){return r},lookup(s){return typeof s!="string"||!Object.hasOwn(e,s)?null:e[s]??null},resolve(s){return this.lookup(s)??"other"}}}}var Le=["read","read_file","read_many_files","image_read","search_file_content","grep","grep_search","list_directory","ls","glob","lsp_hover","lsp_goto_definition","lsp_find_references","web_fetch","web_search","ref_search_documentation","ref_read_url","resolve-library-id","get-library-docs","memory_recall","save_memory","todo_read","todo_write","ask_user","ask_user_question","pd-status","report"],N=["write","edit","apply_patch"],L=["exec"],Ft=[...L],W=["sessions_spawn"],Wt=[...N],Xt=[...N,...L,...W],$t=[...Le],Bn=new Set(Le),Fn=new Set(N),Wn=new Set(Ft),Xn=new Set(L),$n=new Set(W),Hn=new Set(Wt),Yn=new Set(Xt),Kn=new Set($t),Gn=new Set([...N]);function Q(n,e){return n.map(t=>({rawToolName:t,canonicalKind:e}))}var Ht=Object.freeze([...Q(L,"execute"),...Q(N,"write"),...Q(W,"agent")]),ee=xe(Ht);if(!ee.ok)throw new Error(`[PD] OpenClaw tool semantic declaration is invalid: ${ee.errors.join("; ")}`);var ke=ee.registry;var te=class extends U{constructor(e){super({source:x.get(e.workspaceDir),toolSemantics:ke})}};export{te as BehaviorExamplePackAssembler,x as RuleHostEvidenceRegistry};
|
|
@@ -3,13 +3,11 @@
|
|
|
3
3
|
"thresholds": {
|
|
4
4
|
"pain_trigger": 40,
|
|
5
5
|
"cognitive_paralysis_input": 4000,
|
|
6
|
-
"stuck_loops_trigger": 4,
|
|
7
6
|
"semantic_min_score": 0.7,
|
|
8
7
|
"promotion_count_threshold": 3,
|
|
9
8
|
"promotion_similarity_threshold": 0.8
|
|
10
9
|
},
|
|
11
10
|
"scores": {
|
|
12
|
-
"paralysis": 30,
|
|
13
11
|
"default_confusion": 30,
|
|
14
12
|
"default_loop": 40,
|
|
15
13
|
"tool_failure_friction": 15,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "principles-disciple",
|
|
3
3
|
"name": "Principles Disciple",
|
|
4
4
|
"description": "Principles Disciple is an AI Agent Governance System. Stop correcting the same AI behavior across sessions. Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles.",
|
|
5
|
-
"version": "2.2.
|
|
5
|
+
"version": "2.2.13",
|
|
6
6
|
"activation": {
|
|
7
7
|
"onStartup": true,
|
|
8
8
|
"onCapabilities": [
|
package/plugin/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "principles-disciple",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.13",
|
|
4
4
|
"description": "Principles Disciple is an AI Agent Governance System. Stop correcting the same AI behavior across sessions. Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -3,13 +3,11 @@
|
|
|
3
3
|
"thresholds": {
|
|
4
4
|
"pain_trigger": 40,
|
|
5
5
|
"cognitive_paralysis_input": 4000,
|
|
6
|
-
"stuck_loops_trigger": 4,
|
|
7
6
|
"semantic_min_score": 0.7,
|
|
8
7
|
"promotion_count_threshold": 3,
|
|
9
8
|
"promotion_similarity_threshold": 0.8
|
|
10
9
|
},
|
|
11
10
|
"scores": {
|
|
12
|
-
"paralysis": 30,
|
|
13
11
|
"default_confusion": 30,
|
|
14
12
|
"default_loop": 40,
|
|
15
13
|
"tool_failure_friction": 15,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-principles-disciple",
|
|
3
|
-
"version": "1.146.
|
|
3
|
+
"version": "1.146.7",
|
|
4
4
|
"description": "Interactive CLI installer for Principles Disciple OpenClaw plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"license": "Apache-2.0",
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@earendil-works/pi-agent-core": "1.2.0",
|
|
62
|
-
"@earendil-works/pi-ai": "1.
|
|
62
|
+
"@earendil-works/pi-ai": "1.4.0",
|
|
63
63
|
"@principles/install-layout": "file:../install-layout",
|
|
64
64
|
"@sinclair/typebox": "^0.34.52",
|
|
65
65
|
"@tufjs/models": "3.0.1",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"semver": "^7.8.5",
|
|
75
75
|
"tar": "^7.5.22",
|
|
76
76
|
"typebox": "^1.3.16",
|
|
77
|
-
"tuf-js": "6.0.
|
|
77
|
+
"tuf-js": "6.0.1",
|
|
78
78
|
"undici": "^7.25.0"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
@@ -96,6 +96,6 @@
|
|
|
96
96
|
"directory": "packages/create-principles-disciple"
|
|
97
97
|
},
|
|
98
98
|
"pd": {
|
|
99
|
-
"bundledPluginVersion": "2.2.
|
|
99
|
+
"bundledPluginVersion": "2.2.13"
|
|
100
100
|
}
|
|
101
101
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@principles/workbuddy-adapter",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17",
|
|
4
4
|
"description": "WorkBuddy host adapter for Principles Disciple — implements the HostAdapter interface for WorkBuddy's Git Bash command-hook model (ADR-0020 third host, SPEC workbuddy-host-adapter v0.3.0).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
package/console/dist/ui/App.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function App(): import("react").JSX.Element;
|
package/console/dist/ui/App.js
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useEffect, useCallback } from "react";
|
|
3
|
-
import { HashRouter, Routes, Route, Navigate, useLocation, useNavigate } from "react-router-dom";
|
|
4
|
-
import { I18nextProvider, useTranslation } from "react-i18next";
|
|
5
|
-
import i18n from "./i18n/index.js";
|
|
6
|
-
import { ThemeProvider } from "./components/theme-provider.js";
|
|
7
|
-
import { AppSidebar, MobileNav } from "./components/layout/app-sidebar.js";
|
|
8
|
-
import { SplashScreen } from "./components/auth/splash-screen.js";
|
|
9
|
-
import { LoginForm } from "./components/auth/login-form.js";
|
|
10
|
-
import { ErrorBoundary } from "./components/error-boundary.js";
|
|
11
|
-
import { checkAuth, fetchConfigSummary, fetchWorkspaces } from "./api.js";
|
|
12
|
-
import { NotificationProvider } from "./components/notifications/NotificationProvider.js";
|
|
13
|
-
import { Toaster } from "./components/ui/sonner.js";
|
|
14
|
-
// New page imports (CR2 directory structure)
|
|
15
|
-
import { FocusPage } from "./pages/focus/FocusPage.js";
|
|
16
|
-
import { PainPage } from "./pages/pain/PainPage.js";
|
|
17
|
-
import { PrinciplesPage } from "./pages/principles/PrinciplesPage.js";
|
|
18
|
-
import { CorePrinciplesPage } from "./pages/principles/CorePrinciplesPage.js";
|
|
19
|
-
import { PrincipleDetailPage } from "./pages/principles/PrincipleDetailPage.js";
|
|
20
|
-
import { ActivationPage } from "./pages/activation/ActivationPage.js";
|
|
21
|
-
import { DebtPage } from "./pages/debt/DebtPage.js";
|
|
22
|
-
import { ExaminerPage } from "./pages/examiner/ExaminerPage.js";
|
|
23
|
-
import { ControlCenterPage } from "./pages/control-center/ControlCenterPage.js";
|
|
24
|
-
import { SettingsPage } from "./pages/settings/SettingsPage.js";
|
|
25
|
-
import { UpdatePage } from "./pages/settings/UpdatePage.js";
|
|
26
|
-
import { ReportProblemPage } from "./pages/report-problem/ReportProblemPage.js";
|
|
27
|
-
import { FailedTasksPage } from "./pages/failed-tasks/FailedTasksPage.js";
|
|
28
|
-
import { IntentPage } from "./pages/intent/IntentPage.js";
|
|
29
|
-
import { DesignSystemPage } from "./pages/design-system/DesignSystemPage.js";
|
|
30
|
-
import { WelcomePage } from "./pages/welcome/WelcomePage.js";
|
|
31
|
-
import { getOnboardingState } from "./utils/onboarding-state.js";
|
|
32
|
-
// Vite replaces import.meta.env.DEV with a boolean literal at build time, so a
|
|
33
|
-
// production bundle resolves this to false and dead-code elimination drops the
|
|
34
|
-
// DEV-only routes from the shipped UI. `utils/runtime-mode.ts` exports the same
|
|
35
|
-
// value for components rendered outside this module; both read the same define.
|
|
36
|
-
const IS_DEV = import.meta.env.DEV;
|
|
37
|
-
/**
|
|
38
|
-
* SPEC-PD-UIUX-001 R4: the skip control must NOT touch the URL hash — the app
|
|
39
|
-
* routes through HashRouter, so an `#main-content` anchor navigates away and
|
|
40
|
-
* blanks the page. Focus main programmatically instead; the route is kept.
|
|
41
|
-
*/
|
|
42
|
-
function skipToMainContent() {
|
|
43
|
-
const main = document.getElementById("main-content");
|
|
44
|
-
if (main instanceof HTMLElement) {
|
|
45
|
-
main.focus({ preventScroll: true });
|
|
46
|
-
main.scrollIntoView({ block: "start", behavior: "auto" });
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function AuthenticatedShell({ children, featureFlags }) {
|
|
50
|
-
const { t } = useTranslation();
|
|
51
|
-
return (_jsxs("div", { className: "min-h-screen bg-paper text-ink", children: [_jsx("button", { type: "button", onClick: skipToMainContent, "data-testid": "skip-to-main", className: "sr-only focus:not-sr-only focus:absolute focus:z-50 focus:p-4 focus:bg-paper focus:text-ink focus:font-medium", children: t("common.skipToMain", { defaultValue: "跳到正文" }) }), _jsx(MobileNav, { featureFlags: featureFlags }), _jsx(AppSidebar, { featureFlags: featureFlags }), _jsx("main", { id: "main-content", tabIndex: -1, "data-testid": "main-content", className: "min-h-screen overflow-y-auto pt-14 lg:pt-0 lg:ml-[256px] focus:outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-gov", children: children })] }));
|
|
52
|
-
}
|
|
53
|
-
function AuthRoutes() {
|
|
54
|
-
const [authed, setAuthed] = useState(null);
|
|
55
|
-
const [showSplash, setShowSplash] = useState(() => window.location.hash.startsWith("#/splash"));
|
|
56
|
-
// Onboarding redirect needs workspaceId (for onboarding-state lookup) and
|
|
57
|
-
// feature flags (to gate the redirect). Both are fetched after auth.
|
|
58
|
-
const [currentWorkspaceId, setCurrentWorkspaceId] = useState("default");
|
|
59
|
-
const [featureFlags, setFeatureFlags] = useState(null);
|
|
60
|
-
// P2-C: tracks whether workspace fetch succeeded. If it failed, we skip
|
|
61
|
-
// the onboarding redirect so state isn't saved under a fake "default" key.
|
|
62
|
-
const [workspaceReady, setWorkspaceReady] = useState(false);
|
|
63
|
-
const navigate = useNavigate();
|
|
64
|
-
const location = useLocation();
|
|
65
|
-
const verifyAuth = useCallback(async () => {
|
|
66
|
-
const valid = await checkAuth();
|
|
67
|
-
setAuthed(valid);
|
|
68
|
-
}, []);
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
verifyAuth();
|
|
71
|
-
}, [verifyAuth]);
|
|
72
|
-
// PRI-643: verifyAuth otherwise runs only on mount. If the server switches
|
|
73
|
-
// auth mode (or the token expires) while the page stays open, re-verify
|
|
74
|
-
// when the tab becomes visible or the window regains focus; a 401 from the
|
|
75
|
-
// probe also triggers api.ts's global redirect to the login route.
|
|
76
|
-
useEffect(() => {
|
|
77
|
-
const recheck = () => {
|
|
78
|
-
if (document.visibilityState === "visible")
|
|
79
|
-
verifyAuth();
|
|
80
|
-
};
|
|
81
|
-
window.addEventListener("focus", recheck);
|
|
82
|
-
document.addEventListener("visibilitychange", recheck);
|
|
83
|
-
return () => {
|
|
84
|
-
window.removeEventListener("focus", recheck);
|
|
85
|
-
document.removeEventListener("visibilitychange", recheck);
|
|
86
|
-
};
|
|
87
|
-
}, [verifyAuth]);
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
if (!showSplash)
|
|
90
|
-
return;
|
|
91
|
-
if (authed === null)
|
|
92
|
-
return; // still checking
|
|
93
|
-
// Wait for splash animation to complete before navigating
|
|
94
|
-
// SplashScreen has its own 2200ms timer; we wait for it to call onComplete
|
|
95
|
-
// This effect only handles the case where auth resolves after splash is done
|
|
96
|
-
}, [authed, showSplash, navigate]);
|
|
97
|
-
// Fetch workspace list + feature flags after auth for onboarding redirect.
|
|
98
|
-
// P2-5: use Promise.all so both states update together — prevents the
|
|
99
|
-
// redirect effect from firing with the wrong workspaceId (race condition).
|
|
100
|
-
// rc-9: on fetch failure, set featureFlags to {} so the redirect effect
|
|
101
|
-
// fires (defaults to /focus — safe, no onboarding forced).
|
|
102
|
-
useEffect(() => {
|
|
103
|
-
if (authed !== true)
|
|
104
|
-
return;
|
|
105
|
-
Promise.all([
|
|
106
|
-
fetchWorkspaces().catch(() => null),
|
|
107
|
-
fetchConfigSummary().catch(() => null),
|
|
108
|
-
]).then(([wsResult, cfgResult]) => {
|
|
109
|
-
// Update workspaceId first (if we have a real workspace)
|
|
110
|
-
if (wsResult &&
|
|
111
|
-
wsResult.success &&
|
|
112
|
-
Array.isArray(wsResult.data) &&
|
|
113
|
-
wsResult.data.length > 0) {
|
|
114
|
-
const firstWorkspace = wsResult.data[0];
|
|
115
|
-
if (firstWorkspace) {
|
|
116
|
-
setCurrentWorkspaceId(firstWorkspace.name);
|
|
117
|
-
// P2-C: only mark workspaceReady when we have a real workspace name.
|
|
118
|
-
setWorkspaceReady(true);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
// Then update featureFlags — the redirect effect waits for this.
|
|
122
|
-
// rc-9: on any failure, default to {} so redirect fires to /focus.
|
|
123
|
-
const flags = {};
|
|
124
|
-
if (cfgResult &&
|
|
125
|
-
cfgResult.success &&
|
|
126
|
-
cfgResult.data) {
|
|
127
|
-
const summary = cfgResult.data;
|
|
128
|
-
for (const f of summary.features) {
|
|
129
|
-
flags[f.id] = { enabled: f.enabled };
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
setFeatureFlags(flags);
|
|
133
|
-
});
|
|
134
|
-
}, [authed]);
|
|
135
|
-
// P1-4: After splash finishes, if user is not authenticated, go to login.
|
|
136
|
-
// (The authed === true case is handled by the redirect effect below.)
|
|
137
|
-
useEffect(() => {
|
|
138
|
-
if (showSplash || authed !== false)
|
|
139
|
-
return;
|
|
140
|
-
navigate('/login', { replace: true });
|
|
141
|
-
}, [showSplash, authed, navigate]);
|
|
142
|
-
// First-visit redirect: check new_user_onboarding flag + onboarding state.
|
|
143
|
-
// P1-4: Only redirect AFTER splash is done AND featureFlags are loaded.
|
|
144
|
-
// This prevents the race where splash navigates to /focus before flags
|
|
145
|
-
// load, which would bypass the onboarding redirect entirely.
|
|
146
|
-
useEffect(() => {
|
|
147
|
-
if (authed !== true || featureFlags === null || showSplash)
|
|
148
|
-
return;
|
|
149
|
-
if (!['/', '/login', '/splash'].includes(location.pathname))
|
|
150
|
-
return;
|
|
151
|
-
const flagEnabled = featureFlags?.new_user_onboarding?.enabled === true;
|
|
152
|
-
// P2-C: if workspace fetch failed, don't force onboarding under "default" key.
|
|
153
|
-
if (flagEnabled && workspaceReady) {
|
|
154
|
-
const onboardingState = getOnboardingState(currentWorkspaceId);
|
|
155
|
-
navigate(onboardingState.completed ? '/focus' : '/welcome', { replace: true });
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
navigate('/focus', { replace: true });
|
|
159
|
-
}
|
|
160
|
-
}, [authed, featureFlags, showSplash, currentWorkspaceId, workspaceReady, location.pathname, navigate]);
|
|
161
|
-
const handleAuthSuccess = useCallback(() => {
|
|
162
|
-
setAuthed(true);
|
|
163
|
-
// Post-auth redirect is handled by the authed + featureFlags effect above,
|
|
164
|
-
// which fires once feature flags have loaded.
|
|
165
|
-
}, []);
|
|
166
|
-
return (_jsxs(Routes, { children: [_jsx(Route, { path: "/splash", element: _jsx(SplashScreen, { onComplete: () => {
|
|
167
|
-
setShowSplash(false);
|
|
168
|
-
} }) }), _jsx(Route, { path: "/login", element: _jsx(LoginForm, { onAuthSuccess: handleAuthSuccess }) }), _jsx(Route, { path: "/*", element: authed === null ? (_jsx("div", { className: "min-h-screen bg-paper flex items-center justify-center", children: _jsxs("div", { className: "flex flex-col items-center gap-4", children: [_jsx("div", { className: "w-8 h-8 border-2 border-gov border-t-transparent rounded-full animate-spin" }), _jsx("span", { className: "text-[12px] font-mono tracking-wider text-ink-3 uppercase", children: "Verifying Session..." })] }) })) : authed ? (_jsx(NotificationProvider, { children: _jsx(AuthenticatedShell, { featureFlags: featureFlags ?? undefined, children: _jsx(ErrorBoundary, { children: _jsxs(Routes, { children: [_jsx(Route, { path: "/", element: _jsx(Navigate, { to: "/focus", replace: true }) }), _jsx(Route, { path: "/welcome", element: _jsx(WelcomePage, { workspaceId: currentWorkspaceId }) }), _jsx(Route, { path: "/focus", element: _jsx(FocusPage, { featureFlags: featureFlags ?? undefined }) }), _jsx(Route, { path: "/pain", element: _jsx(PainPage, {}) }), _jsx(Route, { path: "/principles", element: _jsx(PrinciplesPage, {}) }), _jsx(Route, { path: "/principles/core", element: _jsx(CorePrinciplesPage, {}) }), _jsx(Route, { path: "/principles/:id", element: _jsx(PrincipleDetailPage, {}) }), _jsx(Route, { path: "/activation", element: _jsx(ActivationPage, {}) }), _jsx(Route, { path: "/debt", element: _jsx(DebtPage, {}) }), _jsx(Route, { path: "/examiner", element: _jsx(ExaminerPage, {}) }), _jsx(Route, { path: "/control-center", element: _jsx(ControlCenterPage, {}) }), _jsx(Route, { path: "/settings", element: _jsx(SettingsPage, {}) }), _jsx(Route, { path: "/update", element: _jsx(UpdatePage, {}) }), _jsx(Route, { path: "/report-problem", element: _jsx(ReportProblemPage, {}) }), _jsx(Route, { path: "/failed-tasks", element: _jsx(FailedTasksPage, {}) }), _jsx(Route, { path: "/intent", element: _jsx(IntentPage, {}) }), IS_DEV && (_jsx(Route, { path: "/design-system", element: _jsx(DesignSystemPage, {}) })), !IS_DEV && (_jsx(Route, { path: "/design-system", element: _jsx(Navigate, { to: "/focus", replace: true }) }))] }) }) }) })) : (_jsx(Navigate, { to: "/login", replace: true })) })] }));
|
|
169
|
-
}
|
|
170
|
-
export function App() {
|
|
171
|
-
return (_jsx(ThemeProvider, { children: _jsxs(I18nextProvider, { i18n: i18n, children: [_jsx(HashRouter, { children: _jsx(AuthRoutes, {}) }), _jsx(Toaster, {})] }) }));
|
|
172
|
-
}
|