@zmeel/server 0.3.1
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/LICENSE +21 -0
- package/dist/adapters/codex-models.d.ts +4 -0
- package/dist/adapters/codex-models.d.ts.map +1 -0
- package/dist/adapters/codex-models.js +98 -0
- package/dist/adapters/codex-models.js.map +1 -0
- package/dist/adapters/cursor-models.d.ts +13 -0
- package/dist/adapters/cursor-models.d.ts.map +1 -0
- package/dist/adapters/cursor-models.js +148 -0
- package/dist/adapters/cursor-models.js.map +1 -0
- package/dist/adapters/http/execute.d.ts +3 -0
- package/dist/adapters/http/execute.d.ts.map +1 -0
- package/dist/adapters/http/execute.js +39 -0
- package/dist/adapters/http/execute.js.map +1 -0
- package/dist/adapters/http/index.d.ts +3 -0
- package/dist/adapters/http/index.d.ts.map +1 -0
- package/dist/adapters/http/index.js +20 -0
- package/dist/adapters/http/index.js.map +1 -0
- package/dist/adapters/http/test.d.ts +3 -0
- package/dist/adapters/http/test.d.ts.map +1 -0
- package/dist/adapters/http/test.js +106 -0
- package/dist/adapters/http/test.js.map +1 -0
- package/dist/adapters/index.d.ts +4 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +3 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/process/execute.d.ts +3 -0
- package/dist/adapters/process/execute.d.ts.map +1 -0
- package/dist/adapters/process/execute.js +70 -0
- package/dist/adapters/process/execute.js.map +1 -0
- package/dist/adapters/process/index.d.ts +3 -0
- package/dist/adapters/process/index.d.ts.map +1 -0
- package/dist/adapters/process/index.js +23 -0
- package/dist/adapters/process/index.js.map +1 -0
- package/dist/adapters/process/test.d.ts +3 -0
- package/dist/adapters/process/test.d.ts.map +1 -0
- package/dist/adapters/process/test.js +77 -0
- package/dist/adapters/process/test.js.map +1 -0
- package/dist/adapters/registry.d.ts +14 -0
- package/dist/adapters/registry.d.ts.map +1 -0
- package/dist/adapters/registry.js +164 -0
- package/dist/adapters/registry.js.map +1 -0
- package/dist/adapters/types.d.ts +2 -0
- package/dist/adapters/types.d.ts.map +1 -0
- package/dist/adapters/types.js +2 -0
- package/dist/adapters/types.js.map +1 -0
- package/dist/adapters/utils.d.ts +41 -0
- package/dist/adapters/utils.d.ts.map +1 -0
- package/dist/adapters/utils.js +51 -0
- package/dist/adapters/utils.js.map +1 -0
- package/dist/agent-auth-jwt.d.ts +14 -0
- package/dist/agent-auth-jwt.d.ts.map +1 -0
- package/dist/agent-auth-jwt.js +117 -0
- package/dist/agent-auth-jwt.js.map +1 -0
- package/dist/app.d.ts +32 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +281 -0
- package/dist/app.js.map +1 -0
- package/dist/attachment-types.d.ts +33 -0
- package/dist/attachment-types.d.ts.map +1 -0
- package/dist/attachment-types.js +67 -0
- package/dist/attachment-types.js.map +1 -0
- package/dist/auth/better-auth.d.ts +24 -0
- package/dist/auth/better-auth.d.ts.map +1 -0
- package/dist/auth/better-auth.js +108 -0
- package/dist/auth/better-auth.js.map +1 -0
- package/dist/board-claim.d.ts +23 -0
- package/dist/board-claim.d.ts.map +1 -0
- package/dist/board-claim.js +115 -0
- package/dist/board-claim.js.map +1 -0
- package/dist/config-file.d.ts +3 -0
- package/dist/config-file.d.ts.map +1 -0
- package/dist/config-file.js +16 -0
- package/dist/config-file.js.map +1 -0
- package/dist/config.d.ts +41 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +173 -0
- package/dist/config.js.map +1 -0
- package/dist/dev-server-status.d.ts +27 -0
- package/dist/dev-server-status.d.ts.map +1 -0
- package/dist/dev-server-status.js +70 -0
- package/dist/dev-server-status.js.map +1 -0
- package/dist/dev-watch-ignore.d.ts +2 -0
- package/dist/dev-watch-ignore.d.ts.map +1 -0
- package/dist/dev-watch-ignore.js +33 -0
- package/dist/dev-watch-ignore.js.map +1 -0
- package/dist/errors.d.ts +12 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +28 -0
- package/dist/errors.js.map +1 -0
- package/dist/home-paths.d.ts +17 -0
- package/dist/home-paths.d.ts.map +1 -0
- package/dist/home-paths.js +75 -0
- package/dist/home-paths.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +627 -0
- package/dist/index.js.map +1 -0
- package/dist/log-redaction.d.ts +11 -0
- package/dist/log-redaction.d.ts.map +1 -0
- package/dist/log-redaction.js +118 -0
- package/dist/log-redaction.js.map +1 -0
- package/dist/middleware/auth.d.ts +12 -0
- package/dist/middleware/auth.d.ts.map +1 -0
- package/dist/middleware/auth.js +144 -0
- package/dist/middleware/auth.js.map +1 -0
- package/dist/middleware/board-mutation-guard.d.ts +3 -0
- package/dist/middleware/board-mutation-guard.d.ts.map +1 -0
- package/dist/middleware/board-mutation-guard.js +60 -0
- package/dist/middleware/board-mutation-guard.js.map +1 -0
- package/dist/middleware/error-handler.d.ts +17 -0
- package/dist/middleware/error-handler.d.ts.map +1 -0
- package/dist/middleware/error-handler.js +45 -0
- package/dist/middleware/error-handler.js.map +1 -0
- package/dist/middleware/index.d.ts +4 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +4 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/logger.d.ts +4 -0
- package/dist/middleware/logger.d.ts.map +1 -0
- package/dist/middleware/logger.js +87 -0
- package/dist/middleware/logger.js.map +1 -0
- package/dist/middleware/private-hostname-guard.d.ts +11 -0
- package/dist/middleware/private-hostname-guard.d.ts.map +1 -0
- package/dist/middleware/private-hostname-guard.js +78 -0
- package/dist/middleware/private-hostname-guard.js.map +1 -0
- package/dist/middleware/validate.d.ts +4 -0
- package/dist/middleware/validate.d.ts.map +1 -0
- package/dist/middleware/validate.js +7 -0
- package/dist/middleware/validate.js.map +1 -0
- package/dist/onboarding-assets/ceo/AGENTS.md +54 -0
- package/dist/onboarding-assets/ceo/HEARTBEAT.md +72 -0
- package/dist/onboarding-assets/ceo/SOUL.md +33 -0
- package/dist/onboarding-assets/ceo/TOOLS.md +3 -0
- package/dist/onboarding-assets/default/AGENTS.md +3 -0
- package/dist/paths.d.ts +3 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +31 -0
- package/dist/paths.js.map +1 -0
- package/dist/realtime/live-events-ws.d.ts +28 -0
- package/dist/realtime/live-events-ws.d.ts.map +1 -0
- package/dist/realtime/live-events-ws.js +187 -0
- package/dist/realtime/live-events-ws.js.map +1 -0
- package/dist/redaction.d.ts +4 -0
- package/dist/redaction.d.ts.map +1 -0
- package/dist/redaction.js +63 -0
- package/dist/redaction.js.map +1 -0
- package/dist/routes/access.d.ts +62 -0
- package/dist/routes/access.d.ts.map +1 -0
- package/dist/routes/access.js +2296 -0
- package/dist/routes/access.js.map +1 -0
- package/dist/routes/activity.d.ts +3 -0
- package/dist/routes/activity.d.ts.map +1 -0
- package/dist/routes/activity.js +78 -0
- package/dist/routes/activity.js.map +1 -0
- package/dist/routes/agents.d.ts +3 -0
- package/dist/routes/agents.d.ts.map +1 -0
- package/dist/routes/agents.js +1918 -0
- package/dist/routes/agents.js.map +1 -0
- package/dist/routes/approvals.d.ts +3 -0
- package/dist/routes/approvals.d.ts.map +1 -0
- package/dist/routes/approvals.js +275 -0
- package/dist/routes/approvals.js.map +1 -0
- package/dist/routes/assets.d.ts +4 -0
- package/dist/routes/assets.d.ts.map +1 -0
- package/dist/routes/assets.js +309 -0
- package/dist/routes/assets.js.map +1 -0
- package/dist/routes/authz.d.ts +16 -0
- package/dist/routes/authz.d.ts.map +1 -0
- package/dist/routes/authz.js +47 -0
- package/dist/routes/authz.js.map +1 -0
- package/dist/routes/companies.d.ts +4 -0
- package/dist/routes/companies.d.ts.map +1 -0
- package/dist/routes/companies.js +356 -0
- package/dist/routes/companies.js.map +1 -0
- package/dist/routes/company-skills.d.ts +3 -0
- package/dist/routes/company-skills.d.ts.map +1 -0
- package/dist/routes/company-skills.js +228 -0
- package/dist/routes/company-skills.js.map +1 -0
- package/dist/routes/costs.d.ts +3 -0
- package/dist/routes/costs.d.ts.map +1 -0
- package/dist/routes/costs.js +268 -0
- package/dist/routes/costs.js.map +1 -0
- package/dist/routes/dashboard.d.ts +3 -0
- package/dist/routes/dashboard.d.ts.map +1 -0
- package/dist/routes/dashboard.js +15 -0
- package/dist/routes/dashboard.js.map +1 -0
- package/dist/routes/execution-workspaces.d.ts +3 -0
- package/dist/routes/execution-workspaces.d.ts.map +1 -0
- package/dist/routes/execution-workspaces.js +367 -0
- package/dist/routes/execution-workspaces.js.map +1 -0
- package/dist/routes/goals.d.ts +3 -0
- package/dist/routes/goals.d.ts.map +1 -0
- package/dist/routes/goals.js +95 -0
- package/dist/routes/goals.js.map +1 -0
- package/dist/routes/health.d.ts +9 -0
- package/dist/routes/health.d.ts.map +1 -0
- package/dist/routes/health.js +80 -0
- package/dist/routes/health.js.map +1 -0
- package/dist/routes/index.d.ts +18 -0
- package/dist/routes/index.d.ts.map +1 -0
- package/dist/routes/index.js +18 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/routes/instance-settings.d.ts +3 -0
- package/dist/routes/instance-settings.d.ts.map +1 -0
- package/dist/routes/instance-settings.js +79 -0
- package/dist/routes/instance-settings.js.map +1 -0
- package/dist/routes/issues-checkout-wakeup.d.ts +9 -0
- package/dist/routes/issues-checkout-wakeup.d.ts.map +1 -0
- package/dist/routes/issues-checkout-wakeup.js +12 -0
- package/dist/routes/issues-checkout-wakeup.js.map +1 -0
- package/dist/routes/issues.d.ts +4 -0
- package/dist/routes/issues.d.ts.map +1 -0
- package/dist/routes/issues.js +1834 -0
- package/dist/routes/issues.js.map +1 -0
- package/dist/routes/llms.d.ts +3 -0
- package/dist/routes/llms.d.ts.map +1 -0
- package/dist/routes/llms.js +78 -0
- package/dist/routes/llms.js.map +1 -0
- package/dist/routes/org-chart-svg.d.ts +25 -0
- package/dist/routes/org-chart-svg.d.ts.map +1 -0
- package/dist/routes/org-chart-svg.js +656 -0
- package/dist/routes/org-chart-svg.js.map +1 -0
- package/dist/routes/plugin-ui-static.d.ts +69 -0
- package/dist/routes/plugin-ui-static.d.ts.map +1 -0
- package/dist/routes/plugin-ui-static.js +411 -0
- package/dist/routes/plugin-ui-static.js.map +1 -0
- package/dist/routes/plugins.d.ts +120 -0
- package/dist/routes/plugins.d.ts.map +1 -0
- package/dist/routes/plugins.js +1784 -0
- package/dist/routes/plugins.js.map +1 -0
- package/dist/routes/projects.d.ts +3 -0
- package/dist/routes/projects.d.ts.map +1 -0
- package/dist/routes/projects.js +386 -0
- package/dist/routes/projects.js.map +1 -0
- package/dist/routes/routines.d.ts +3 -0
- package/dist/routes/routines.d.ts.map +1 -0
- package/dist/routes/routines.js +277 -0
- package/dist/routes/routines.js.map +1 -0
- package/dist/routes/secrets.d.ts +3 -0
- package/dist/routes/secrets.d.ts.map +1 -0
- package/dist/routes/secrets.js +128 -0
- package/dist/routes/secrets.js.map +1 -0
- package/dist/routes/sidebar-badges.d.ts +3 -0
- package/dist/routes/sidebar-badges.d.ts.map +1 -0
- package/dist/routes/sidebar-badges.js +45 -0
- package/dist/routes/sidebar-badges.js.map +1 -0
- package/dist/secrets/external-stub-providers.d.ts +5 -0
- package/dist/secrets/external-stub-providers.d.ts.map +1 -0
- package/dist/secrets/external-stub-providers.js +21 -0
- package/dist/secrets/external-stub-providers.js.map +1 -0
- package/dist/secrets/local-encrypted-provider.d.ts +3 -0
- package/dist/secrets/local-encrypted-provider.d.ts.map +1 -0
- package/dist/secrets/local-encrypted-provider.js +116 -0
- package/dist/secrets/local-encrypted-provider.js.map +1 -0
- package/dist/secrets/provider-registry.d.ts +5 -0
- package/dist/secrets/provider-registry.d.ts.map +1 -0
- package/dist/secrets/provider-registry.js +20 -0
- package/dist/secrets/provider-registry.js.map +1 -0
- package/dist/secrets/types.d.ts +21 -0
- package/dist/secrets/types.d.ts.map +1 -0
- package/dist/secrets/types.js +2 -0
- package/dist/secrets/types.js.map +1 -0
- package/dist/services/access.d.ts +113 -0
- package/dist/services/access.d.ts.map +1 -0
- package/dist/services/access.js +247 -0
- package/dist/services/access.js.map +1 -0
- package/dist/services/activity-log.d.ts +17 -0
- package/dist/services/activity-log.d.ts.map +1 -0
- package/dist/services/activity-log.js +74 -0
- package/dist/services/activity-log.js.map +1 -0
- package/dist/services/activity.d.ts +764 -0
- package/dist/services/activity.d.ts.map +1 -0
- package/dist/services/activity.js +105 -0
- package/dist/services/activity.js.map +1 -0
- package/dist/services/agent-instructions.d.ts +91 -0
- package/dist/services/agent-instructions.d.ts.map +1 -0
- package/dist/services/agent-instructions.js +580 -0
- package/dist/services/agent-instructions.js.map +1 -0
- package/dist/services/agent-permissions.d.ts +6 -0
- package/dist/services/agent-permissions.d.ts.map +1 -0
- package/dist/services/agent-permissions.js +18 -0
- package/dist/services/agent-permissions.js.map +1 -0
- package/dist/services/agents.d.ts +1670 -0
- package/dist/services/agents.d.ts.map +1 -0
- package/dist/services/agents.js +566 -0
- package/dist/services/agents.js.map +1 -0
- package/dist/services/approvals.d.ts +546 -0
- package/dist/services/approvals.d.ts.map +1 -0
- package/dist/services/approvals.js +212 -0
- package/dist/services/approvals.js.map +1 -0
- package/dist/services/assets.d.ts +33 -0
- package/dist/services/assets.d.ts.map +1 -0
- package/dist/services/assets.js +17 -0
- package/dist/services/assets.js.map +1 -0
- package/dist/services/board-auth.d.ts +234 -0
- package/dist/services/board-auth.d.ts.map +1 -0
- package/dist/services/board-auth.js +295 -0
- package/dist/services/board-auth.js.map +1 -0
- package/dist/services/budgets.d.ts +38 -0
- package/dist/services/budgets.d.ts.map +1 -0
- package/dist/services/budgets.js +784 -0
- package/dist/services/budgets.js.map +1 -0
- package/dist/services/companies.d.ts +148 -0
- package/dist/services/companies.d.ts.map +1 -0
- package/dist/services/companies.js +260 -0
- package/dist/services/companies.js.map +1 -0
- package/dist/services/company-export-readme.d.ts +17 -0
- package/dist/services/company-export-readme.d.ts.map +1 -0
- package/dist/services/company-export-readme.js +148 -0
- package/dist/services/company-export-readme.js.map +1 -0
- package/dist/services/company-portability.d.ts +24 -0
- package/dist/services/company-portability.d.ts.map +1 -0
- package/dist/services/company-portability.js +3807 -0
- package/dist/services/company-portability.js.map +1 -0
- package/dist/services/company-skills.d.ts +77 -0
- package/dist/services/company-skills.d.ts.map +1 -0
- package/dist/services/company-skills.js +2063 -0
- package/dist/services/company-skills.js.map +1 -0
- package/dist/services/costs.d.ts +114 -0
- package/dist/services/costs.d.ts.map +1 -0
- package/dist/services/costs.js +294 -0
- package/dist/services/costs.js.map +1 -0
- package/dist/services/cron.d.ts +80 -0
- package/dist/services/cron.d.ts.map +1 -0
- package/dist/services/cron.js +300 -0
- package/dist/services/cron.js.map +1 -0
- package/dist/services/dashboard.d.ts +26 -0
- package/dist/services/dashboard.d.ts.map +1 -0
- package/dist/services/dashboard.js +98 -0
- package/dist/services/dashboard.js.map +1 -0
- package/dist/services/default-agent-instructions.d.ts +9 -0
- package/dist/services/default-agent-instructions.d.ts.map +1 -0
- package/dist/services/default-agent-instructions.js +20 -0
- package/dist/services/default-agent-instructions.js.map +1 -0
- package/dist/services/documents.d.ts +195 -0
- package/dist/services/documents.d.ts.map +1 -0
- package/dist/services/documents.js +409 -0
- package/dist/services/documents.js.map +1 -0
- package/dist/services/execution-workspace-policy.d.ts +21 -0
- package/dist/services/execution-workspace-policy.d.ts.map +1 -0
- package/dist/services/execution-workspace-policy.js +177 -0
- package/dist/services/execution-workspace-policy.js.map +1 -0
- package/dist/services/execution-workspaces.d.ts +22 -0
- package/dist/services/execution-workspaces.d.ts.map +1 -0
- package/dist/services/execution-workspaces.js +551 -0
- package/dist/services/execution-workspaces.js.map +1 -0
- package/dist/services/feedback-redaction.d.ts +23 -0
- package/dist/services/feedback-redaction.d.ts.map +1 -0
- package/dist/services/feedback-redaction.js +150 -0
- package/dist/services/feedback-redaction.js.map +1 -0
- package/dist/services/feedback-share-client.d.ts +9 -0
- package/dist/services/feedback-share-client.d.ts.map +1 -0
- package/dist/services/feedback-share-client.js +42 -0
- package/dist/services/feedback-share-client.js.map +1 -0
- package/dist/services/feedback.d.ts +91 -0
- package/dist/services/feedback.d.ts.map +1 -0
- package/dist/services/feedback.js +1662 -0
- package/dist/services/feedback.js.map +1 -0
- package/dist/services/finance.d.ts +93 -0
- package/dist/services/finance.d.ts.map +1 -0
- package/dist/services/finance.js +120 -0
- package/dist/services/finance.js.map +1 -0
- package/dist/services/github-fetch.d.ts +4 -0
- package/dist/services/github-fetch.d.ts.map +1 -0
- package/dist/services/github-fetch.js +23 -0
- package/dist/services/github-fetch.js.map +1 -0
- package/dist/services/goals.d.ts +433 -0
- package/dist/services/goals.d.ts.map +1 -0
- package/dist/services/goals.js +54 -0
- package/dist/services/goals.js.map +1 -0
- package/dist/services/heartbeat-run-summary.d.ts +2 -0
- package/dist/services/heartbeat-run-summary.d.ts.map +1 -0
- package/dist/services/heartbeat-run-summary.js +30 -0
- package/dist/services/heartbeat-run-summary.js.map +1 -0
- package/dist/services/heartbeat.d.ts +839 -0
- package/dist/services/heartbeat.d.ts.map +1 -0
- package/dist/services/heartbeat.js +3287 -0
- package/dist/services/heartbeat.js.map +1 -0
- package/dist/services/hire-hook.d.ts +14 -0
- package/dist/services/hire-hook.d.ts.map +1 -0
- package/dist/services/hire-hook.js +85 -0
- package/dist/services/hire-hook.js.map +1 -0
- package/dist/services/index.d.ts +34 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +34 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/instance-settings.d.ts +11 -0
- package/dist/services/instance-settings.d.ts.map +1 -0
- package/dist/services/instance-settings.js +120 -0
- package/dist/services/instance-settings.js.map +1 -0
- package/dist/services/issue-approvals.d.ts +56 -0
- package/dist/services/issue-approvals.d.ts.map +1 -0
- package/dist/services/issue-approvals.js +153 -0
- package/dist/services/issue-approvals.js.map +1 -0
- package/dist/services/issue-assignment-wakeup.d.ts +29 -0
- package/dist/services/issue-assignment-wakeup.d.ts.map +1 -0
- package/dist/services/issue-assignment-wakeup.js +22 -0
- package/dist/services/issue-assignment-wakeup.js.map +1 -0
- package/dist/services/issue-goal-fallback.d.ts +18 -0
- package/dist/services/issue-goal-fallback.d.ts.map +1 -0
- package/dist/services/issue-goal-fallback.js +33 -0
- package/dist/services/issue-goal-fallback.js.map +1 -0
- package/dist/services/issues.d.ts +568 -0
- package/dist/services/issues.d.ts.map +1 -0
- package/dist/services/issues.js +1671 -0
- package/dist/services/issues.js.map +1 -0
- package/dist/services/live-events.d.ts +17 -0
- package/dist/services/live-events.d.ts.map +1 -0
- package/dist/services/live-events.js +33 -0
- package/dist/services/live-events.js.map +1 -0
- package/dist/services/local-service-supervisor.d.ts +55 -0
- package/dist/services/local-service-supervisor.d.ts.map +1 -0
- package/dist/services/local-service-supervisor.js +240 -0
- package/dist/services/local-service-supervisor.js.map +1 -0
- package/dist/services/plugin-capability-validator.d.ts +108 -0
- package/dist/services/plugin-capability-validator.d.ts.map +1 -0
- package/dist/services/plugin-capability-validator.js +269 -0
- package/dist/services/plugin-capability-validator.js.map +1 -0
- package/dist/services/plugin-config-validator.d.ts +26 -0
- package/dist/services/plugin-config-validator.d.ts.map +1 -0
- package/dist/services/plugin-config-validator.js +41 -0
- package/dist/services/plugin-config-validator.js.map +1 -0
- package/dist/services/plugin-dev-watcher.d.ts +30 -0
- package/dist/services/plugin-dev-watcher.d.ts.map +1 -0
- package/dist/services/plugin-dev-watcher.js +241 -0
- package/dist/services/plugin-dev-watcher.js.map +1 -0
- package/dist/services/plugin-event-bus.d.ts +149 -0
- package/dist/services/plugin-event-bus.d.ts.map +1 -0
- package/dist/services/plugin-event-bus.js +258 -0
- package/dist/services/plugin-event-bus.js.map +1 -0
- package/dist/services/plugin-host-service-cleanup.d.ts +14 -0
- package/dist/services/plugin-host-service-cleanup.d.ts.map +1 -0
- package/dist/services/plugin-host-service-cleanup.js +37 -0
- package/dist/services/plugin-host-service-cleanup.js.map +1 -0
- package/dist/services/plugin-host-services.d.ts +13 -0
- package/dist/services/plugin-host-services.d.ts.map +1 -0
- package/dist/services/plugin-host-services.js +983 -0
- package/dist/services/plugin-host-services.js.map +1 -0
- package/dist/services/plugin-job-coordinator.d.ts +81 -0
- package/dist/services/plugin-job-coordinator.d.ts.map +1 -0
- package/dist/services/plugin-job-coordinator.js +172 -0
- package/dist/services/plugin-job-coordinator.js.map +1 -0
- package/dist/services/plugin-job-scheduler.d.ts +163 -0
- package/dist/services/plugin-job-scheduler.d.ts.map +1 -0
- package/dist/services/plugin-job-scheduler.js +454 -0
- package/dist/services/plugin-job-scheduler.js.map +1 -0
- package/dist/services/plugin-job-store.d.ts +208 -0
- package/dist/services/plugin-job-store.d.ts.map +1 -0
- package/dist/services/plugin-job-store.js +350 -0
- package/dist/services/plugin-job-store.js.map +1 -0
- package/dist/services/plugin-lifecycle.d.ts +203 -0
- package/dist/services/plugin-lifecycle.d.ts.map +1 -0
- package/dist/services/plugin-lifecycle.js +476 -0
- package/dist/services/plugin-lifecycle.js.map +1 -0
- package/dist/services/plugin-loader.d.ts +441 -0
- package/dist/services/plugin-loader.d.ts.map +1 -0
- package/dist/services/plugin-loader.js +1192 -0
- package/dist/services/plugin-loader.js.map +1 -0
- package/dist/services/plugin-log-retention.d.ts +20 -0
- package/dist/services/plugin-log-retention.d.ts.map +1 -0
- package/dist/services/plugin-log-retention.js +63 -0
- package/dist/services/plugin-log-retention.js.map +1 -0
- package/dist/services/plugin-manifest-validator.d.ts +79 -0
- package/dist/services/plugin-manifest-validator.d.ts.map +1 -0
- package/dist/services/plugin-manifest-validator.js +84 -0
- package/dist/services/plugin-manifest-validator.js.map +1 -0
- package/dist/services/plugin-registry.d.ts +2542 -0
- package/dist/services/plugin-registry.d.ts.map +1 -0
- package/dist/services/plugin-registry.js +539 -0
- package/dist/services/plugin-registry.js.map +1 -0
- package/dist/services/plugin-runtime-sandbox.d.ts +40 -0
- package/dist/services/plugin-runtime-sandbox.d.ts.map +1 -0
- package/dist/services/plugin-runtime-sandbox.js +154 -0
- package/dist/services/plugin-runtime-sandbox.js.map +1 -0
- package/dist/services/plugin-secrets-handler.d.ts +81 -0
- package/dist/services/plugin-secrets-handler.d.ts.map +1 -0
- package/dist/services/plugin-secrets-handler.js +275 -0
- package/dist/services/plugin-secrets-handler.js.map +1 -0
- package/dist/services/plugin-state-store.d.ts +92 -0
- package/dist/services/plugin-state-store.d.ts.map +1 -0
- package/dist/services/plugin-state-store.js +190 -0
- package/dist/services/plugin-state-store.js.map +1 -0
- package/dist/services/plugin-stream-bus.d.ts +29 -0
- package/dist/services/plugin-stream-bus.d.ts.map +1 -0
- package/dist/services/plugin-stream-bus.js +48 -0
- package/dist/services/plugin-stream-bus.js.map +1 -0
- package/dist/services/plugin-tool-dispatcher.d.ts +180 -0
- package/dist/services/plugin-tool-dispatcher.d.ts.map +1 -0
- package/dist/services/plugin-tool-dispatcher.js +224 -0
- package/dist/services/plugin-tool-dispatcher.js.map +1 -0
- package/dist/services/plugin-tool-registry.d.ts +192 -0
- package/dist/services/plugin-tool-registry.d.ts.map +1 -0
- package/dist/services/plugin-tool-registry.js +224 -0
- package/dist/services/plugin-tool-registry.js.map +1 -0
- package/dist/services/plugin-worker-manager.d.ts +260 -0
- package/dist/services/plugin-worker-manager.d.ts.map +1 -0
- package/dist/services/plugin-worker-manager.js +835 -0
- package/dist/services/plugin-worker-manager.js.map +1 -0
- package/dist/services/project-workspace-runtime-config.d.ts +4 -0
- package/dist/services/project-workspace-runtime-config.d.ts.map +1 -0
- package/dist/services/project-workspace-runtime-config.js +43 -0
- package/dist/services/project-workspace-runtime-config.js.map +1 -0
- package/dist/services/projects.d.ts +88 -0
- package/dist/services/projects.d.ts.map +1 -0
- package/dist/services/projects.js +669 -0
- package/dist/services/projects.js.map +1 -0
- package/dist/services/quota-windows.d.ts +9 -0
- package/dist/services/quota-windows.d.ts.map +1 -0
- package/dist/services/quota-windows.js +56 -0
- package/dist/services/quota-windows.js.map +1 -0
- package/dist/services/routines.d.ts +136 -0
- package/dist/services/routines.d.ts.map +1 -0
- package/dist/services/routines.js +1268 -0
- package/dist/services/routines.js.map +1 -0
- package/dist/services/run-log-store.d.ts +34 -0
- package/dist/services/run-log-store.d.ts.map +1 -0
- package/dist/services/run-log-store.js +109 -0
- package/dist/services/run-log-store.js.map +1 -0
- package/dist/services/secrets.d.ts +511 -0
- package/dist/services/secrets.d.ts.map +1 -0
- package/dist/services/secrets.js +289 -0
- package/dist/services/secrets.js.map +1 -0
- package/dist/services/sidebar-badges.d.ts +9 -0
- package/dist/services/sidebar-badges.d.ts.map +1 -0
- package/dist/services/sidebar-badges.js +33 -0
- package/dist/services/sidebar-badges.js.map +1 -0
- package/dist/services/work-products.d.ts +14 -0
- package/dist/services/work-products.d.ts.map +1 -0
- package/dist/services/work-products.js +100 -0
- package/dist/services/work-products.js.map +1 -0
- package/dist/services/workspace-operation-log-store.d.ts +33 -0
- package/dist/services/workspace-operation-log-store.d.ts.map +1 -0
- package/dist/services/workspace-operation-log-store.js +110 -0
- package/dist/services/workspace-operation-log-store.js.map +1 -0
- package/dist/services/workspace-operations.d.ts +44 -0
- package/dist/services/workspace-operations.d.ts.map +1 -0
- package/dist/services/workspace-operations.js +211 -0
- package/dist/services/workspace-operations.js.map +1 -0
- package/dist/services/workspace-runtime.d.ts +188 -0
- package/dist/services/workspace-runtime.d.ts.map +1 -0
- package/dist/services/workspace-runtime.js +1705 -0
- package/dist/services/workspace-runtime.js.map +1 -0
- package/dist/startup-banner.d.ts +31 -0
- package/dist/startup-banner.d.ts.map +1 -0
- package/dist/startup-banner.js +117 -0
- package/dist/startup-banner.js.map +1 -0
- package/dist/storage/index.d.ts +6 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +29 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/local-disk-provider.d.ts +3 -0
- package/dist/storage/local-disk-provider.d.ts.map +1 -0
- package/dist/storage/local-disk-provider.js +79 -0
- package/dist/storage/local-disk-provider.js.map +1 -0
- package/dist/storage/provider-registry.d.ts +4 -0
- package/dist/storage/provider-registry.d.ts.map +1 -0
- package/dist/storage/provider-registry.js +15 -0
- package/dist/storage/provider-registry.js.map +1 -0
- package/dist/storage/s3-provider.d.ts +11 -0
- package/dist/storage/s3-provider.d.ts.map +1 -0
- package/dist/storage/s3-provider.js +123 -0
- package/dist/storage/s3-provider.js.map +1 -0
- package/dist/storage/service.d.ts +3 -0
- package/dist/storage/service.d.ts.map +1 -0
- package/dist/storage/service.js +120 -0
- package/dist/storage/service.js.map +1 -0
- package/dist/storage/types.d.ts +55 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/storage/types.js +2 -0
- package/dist/storage/types.js.map +1 -0
- package/dist/telemetry.d.ts +6 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +20 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/ui-branding.d.ts +13 -0
- package/dist/ui-branding.d.ts.map +1 -0
- package/dist/ui-branding.js +187 -0
- package/dist/ui-branding.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/dist/worktree-config.d.ts +19 -0
- package/dist/worktree-config.d.ts.map +1 -0
- package/dist/worktree-config.js +365 -0
- package/dist/worktree-config.js.map +1 -0
- package/package.json +90 -0
- package/ui-dist/android-chrome-192x192.png +0 -0
- package/ui-dist/android-chrome-512x512.png +0 -0
- package/ui-dist/apple-touch-icon.png +0 -0
- package/ui-dist/assets/_basePickBy-D2fZf0o0.js +1 -0
- package/ui-dist/assets/_baseUniq-CWLG_Xqf.js +1 -0
- package/ui-dist/assets/apl-B4CMkyY2.js +1 -0
- package/ui-dist/assets/arc-DeECLtLk.js +1 -0
- package/ui-dist/assets/architectureDiagram-VXUJARFQ-a4Gzo-8u.js +36 -0
- package/ui-dist/assets/asciiarmor-Df11BRmG.js +1 -0
- package/ui-dist/assets/asn1-EdZsLKOL.js +1 -0
- package/ui-dist/assets/asterisk-B-8jnY81.js +1 -0
- package/ui-dist/assets/blockDiagram-VD42YOAC-tsACr-ke.js +122 -0
- package/ui-dist/assets/brainfuck-C4LP7Hcl.js +1 -0
- package/ui-dist/assets/c4Diagram-YG6GDRKO-CxIEiGp0.js +10 -0
- package/ui-dist/assets/channel-B8aOlvkH.js +1 -0
- package/ui-dist/assets/chunk-4BX2VUAB-DXyq1OVE.js +1 -0
- package/ui-dist/assets/chunk-55IACEB6-DE0IJwCp.js +1 -0
- package/ui-dist/assets/chunk-B4BG7PRW-C4VgkuRm.js +165 -0
- package/ui-dist/assets/chunk-DI55MBZ5-DUnVODLP.js +220 -0
- package/ui-dist/assets/chunk-FMBD7UC4-D14U1wU8.js +15 -0
- package/ui-dist/assets/chunk-QN33PNHL--9Fa_-d7.js +1 -0
- package/ui-dist/assets/chunk-QZHKN3VN-6vF9hrbB.js +1 -0
- package/ui-dist/assets/chunk-TZMSLE5B-BOKdVMfQ.js +1 -0
- package/ui-dist/assets/classDiagram-2ON5EDUG-CNtVQyHf.js +1 -0
- package/ui-dist/assets/classDiagram-v2-WZHVMYZB-CNtVQyHf.js +1 -0
- package/ui-dist/assets/clike-B9uivgTg.js +1 -0
- package/ui-dist/assets/clojure-BMjYHr_A.js +1 -0
- package/ui-dist/assets/clone-DbnZAhBs.js +1 -0
- package/ui-dist/assets/cmake-BQqOBYOt.js +1 -0
- package/ui-dist/assets/cobol-CWcv1MsR.js +1 -0
- package/ui-dist/assets/coffeescript-S37ZYGWr.js +1 -0
- package/ui-dist/assets/commonlisp-DBKNyK5s.js +1 -0
- package/ui-dist/assets/cose-bilkent-S5V4N54A-BSFYrItZ.js +1 -0
- package/ui-dist/assets/crystal-SjHAIU92.js +1 -0
- package/ui-dist/assets/css-BnMrqG3P.js +1 -0
- package/ui-dist/assets/cypher-C_CwsFkJ.js +1 -0
- package/ui-dist/assets/cytoscape.esm-BQaXIfA_.js +331 -0
- package/ui-dist/assets/d-pRatUO7H.js +1 -0
- package/ui-dist/assets/dagre-6UL2VRFP-D8xEb_jz.js +4 -0
- package/ui-dist/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/ui-dist/assets/diagram-PSM6KHXK-kkdfif_P.js +24 -0
- package/ui-dist/assets/diagram-QEK2KX5R-BOA1wTkn.js +43 -0
- package/ui-dist/assets/diagram-S2PKOQOG-BMxIrdD_.js +24 -0
- package/ui-dist/assets/diff-DbItnlRl.js +1 -0
- package/ui-dist/assets/dockerfile-BKs6k2Af.js +1 -0
- package/ui-dist/assets/dtd-DF_7sFjM.js +1 -0
- package/ui-dist/assets/dylan-DwRh75JA.js +1 -0
- package/ui-dist/assets/ebnf-CDyGwa7X.js +1 -0
- package/ui-dist/assets/ecl-Cabwm37j.js +1 -0
- package/ui-dist/assets/eiffel-CnydiIhH.js +1 -0
- package/ui-dist/assets/elm-vLlmbW-K.js +1 -0
- package/ui-dist/assets/erDiagram-Q2GNP2WA-O1OwJuJt.js +60 -0
- package/ui-dist/assets/erlang-BNw1qcRV.js +1 -0
- package/ui-dist/assets/factor-kuTfRLto.js +1 -0
- package/ui-dist/assets/fcl-Kvtd6kyn.js +1 -0
- package/ui-dist/assets/flowDiagram-NV44I4VS-Ca9TsVEe.js +162 -0
- package/ui-dist/assets/forth-Ffai-XNe.js +1 -0
- package/ui-dist/assets/fortran-DYz_wnZ1.js +1 -0
- package/ui-dist/assets/ganttDiagram-JELNMOA3-CZ3k4lR4.js +267 -0
- package/ui-dist/assets/gas-Bneqetm1.js +1 -0
- package/ui-dist/assets/gherkin-heZmZLOM.js +1 -0
- package/ui-dist/assets/gitGraphDiagram-V2S2FVAM-CYXpu5VF.js +65 -0
- package/ui-dist/assets/graph-Ct1Mwc2w.js +1 -0
- package/ui-dist/assets/groovy-D9Dt4D0W.js +1 -0
- package/ui-dist/assets/haskell-Cw1EW3IL.js +1 -0
- package/ui-dist/assets/haxe-H-WmDvRZ.js +1 -0
- package/ui-dist/assets/http-DBlCnlav.js +1 -0
- package/ui-dist/assets/idl-BEugSyMb.js +1 -0
- package/ui-dist/assets/index-1-xGTyG8.js +1 -0
- package/ui-dist/assets/index-2BV3lexL.js +1 -0
- package/ui-dist/assets/index-7nZVjhgZ.js +1227 -0
- package/ui-dist/assets/index-B3cKIXfV.js +1 -0
- package/ui-dist/assets/index-BKVrlVnm.js +1 -0
- package/ui-dist/assets/index-BoQp7qpa.js +6 -0
- package/ui-dist/assets/index-Bso7Ph2z.js +1 -0
- package/ui-dist/assets/index-C016T1QA.js +1 -0
- package/ui-dist/assets/index-CKShy7qg.js +1 -0
- package/ui-dist/assets/index-CTeTAOP4.js +2 -0
- package/ui-dist/assets/index-CU0xjnJx.js +1 -0
- package/ui-dist/assets/index-CX3xG_nU.js +1 -0
- package/ui-dist/assets/index-ChGANpP5.js +1 -0
- package/ui-dist/assets/index-Cyi4EPvJ.js +13 -0
- package/ui-dist/assets/index-D4ERoZ49.js +1 -0
- package/ui-dist/assets/index-DAhE9Tae.js +1 -0
- package/ui-dist/assets/index-DYf-Vmt-.js +1 -0
- package/ui-dist/assets/index-DZ5z-1W5.js +1 -0
- package/ui-dist/assets/index-Dbx0Jq5s.js +1 -0
- package/ui-dist/assets/index-DcJU9_Xw.js +3 -0
- package/ui-dist/assets/index-DzvAUKSy.js +1 -0
- package/ui-dist/assets/index-Ip5TfL79.css +1 -0
- package/ui-dist/assets/index-b-wjeoWr.js +7 -0
- package/ui-dist/assets/index-zAFj8SiW.js +1 -0
- package/ui-dist/assets/infoDiagram-HS3SLOUP-BBoge3td.js +2 -0
- package/ui-dist/assets/init-Gi6I4Gst.js +1 -0
- package/ui-dist/assets/javascript-iXu5QeM3.js +1 -0
- package/ui-dist/assets/journeyDiagram-XKPGCS4Q-D6qBxJvS.js +139 -0
- package/ui-dist/assets/julia-DuME0IfC.js +1 -0
- package/ui-dist/assets/kanban-definition-3W4ZIXB7-BKw70hff.js +89 -0
- package/ui-dist/assets/katex-O9d3_IXG.js +261 -0
- package/ui-dist/assets/layout-C-MelZ5a.js +1 -0
- package/ui-dist/assets/linear-BDJBF_lN.js +1 -0
- package/ui-dist/assets/livescript-BwQOo05w.js +1 -0
- package/ui-dist/assets/lua-BgMRiT3U.js +1 -0
- package/ui-dist/assets/mathematica-DTrFuWx2.js +1 -0
- package/ui-dist/assets/mbox-CNhZ1qSd.js +1 -0
- package/ui-dist/assets/mermaid.core-C_LSSro9.js +256 -0
- package/ui-dist/assets/mindmap-definition-VGOIOE7T-DKTz8YjL.js +68 -0
- package/ui-dist/assets/mirc-CjQqDB4T.js +1 -0
- package/ui-dist/assets/mllike-CXdrOF99.js +1 -0
- package/ui-dist/assets/modelica-Dc1JOy9r.js +1 -0
- package/ui-dist/assets/mscgen-BA5vi2Kp.js +1 -0
- package/ui-dist/assets/mumps-BT43cFF4.js +1 -0
- package/ui-dist/assets/nginx-DdIZxoE0.js +1 -0
- package/ui-dist/assets/nsis-LdVXkNf5.js +1 -0
- package/ui-dist/assets/ntriples-BfvgReVJ.js +1 -0
- package/ui-dist/assets/octave-Ck1zUtKM.js +1 -0
- package/ui-dist/assets/ordinal-Cboi1Yqb.js +1 -0
- package/ui-dist/assets/oz-BzwKVEFT.js +1 -0
- package/ui-dist/assets/pascal--L3eBynH.js +1 -0
- package/ui-dist/assets/perl-CdXCOZ3F.js +1 -0
- package/ui-dist/assets/pieDiagram-ADFJNKIX-COzMH2F2.js +30 -0
- package/ui-dist/assets/pig-CevX1Tat.js +1 -0
- package/ui-dist/assets/powershell-CFHJl5sT.js +1 -0
- package/ui-dist/assets/properties-C78fOPTZ.js +1 -0
- package/ui-dist/assets/protobuf-ChK-085T.js +1 -0
- package/ui-dist/assets/pug-DeIclll2.js +1 -0
- package/ui-dist/assets/puppet-DMA9R1ak.js +1 -0
- package/ui-dist/assets/python-BuPzkPfP.js +1 -0
- package/ui-dist/assets/q-pXgVlZs6.js +1 -0
- package/ui-dist/assets/quadrantDiagram-AYHSOK5B-I8FRTFaI.js +7 -0
- package/ui-dist/assets/r-B6wPVr8A.js +1 -0
- package/ui-dist/assets/requirementDiagram-UZGBJVZJ-DI3nQy2l.js +64 -0
- package/ui-dist/assets/rpm-CTu-6PCP.js +1 -0
- package/ui-dist/assets/ruby-B2Rjki9n.js +1 -0
- package/ui-dist/assets/sankeyDiagram-TZEHDZUN-Pf_PmYIt.js +10 -0
- package/ui-dist/assets/sas-B4kiWyti.js +1 -0
- package/ui-dist/assets/scheme-C41bIUwD.js +1 -0
- package/ui-dist/assets/sequenceDiagram-WL72ISMW-DLgaS7kB.js +145 -0
- package/ui-dist/assets/shell-CjFT_Tl9.js +1 -0
- package/ui-dist/assets/sieve-C3Gn_uJK.js +1 -0
- package/ui-dist/assets/simple-mode-GW_nhZxv.js +1 -0
- package/ui-dist/assets/smalltalk-CnHTOXQT.js +1 -0
- package/ui-dist/assets/solr-DehyRSwq.js +1 -0
- package/ui-dist/assets/sparql-DkYu6x3z.js +1 -0
- package/ui-dist/assets/spreadsheet-BCZA_wO0.js +1 -0
- package/ui-dist/assets/sql-D0XecflT.js +1 -0
- package/ui-dist/assets/stateDiagram-FKZM4ZOC-BvMa1uU-.js +1 -0
- package/ui-dist/assets/stateDiagram-v2-4FDKWEC3-BKAZNp5l.js +1 -0
- package/ui-dist/assets/stex-C3f8Ysf7.js +1 -0
- package/ui-dist/assets/stylus-B533Al4x.js +1 -0
- package/ui-dist/assets/swift-BzpIVaGY.js +1 -0
- package/ui-dist/assets/tcl-DVfN8rqt.js +1 -0
- package/ui-dist/assets/textile-CnDTJFAw.js +1 -0
- package/ui-dist/assets/tiddlywiki-DO-Gjzrf.js +1 -0
- package/ui-dist/assets/tiki-DGYXhP31.js +1 -0
- package/ui-dist/assets/timeline-definition-IT6M3QCI-JQUCAkOQ.js +61 -0
- package/ui-dist/assets/toml-Bm5Em-hy.js +1 -0
- package/ui-dist/assets/treemap-GDKQZRPO-BK87qA0V.js +162 -0
- package/ui-dist/assets/troff-wAsdV37c.js +1 -0
- package/ui-dist/assets/ttcn-CfJYG6tj.js +1 -0
- package/ui-dist/assets/ttcn-cfg-B9xdYoR4.js +1 -0
- package/ui-dist/assets/turtle-B1tBg_DP.js +1 -0
- package/ui-dist/assets/vb-CmGdzxic.js +1 -0
- package/ui-dist/assets/vbscript-BuJXcnF6.js +1 -0
- package/ui-dist/assets/velocity-D8B20fx6.js +1 -0
- package/ui-dist/assets/verilog-C6RDOZhf.js +1 -0
- package/ui-dist/assets/vhdl-lSbBsy5d.js +1 -0
- package/ui-dist/assets/webidl-ZXfAyPTL.js +1 -0
- package/ui-dist/assets/xquery-DzFWVndE.js +1 -0
- package/ui-dist/assets/xychartDiagram-PRI3JC2R-UI3XP-6x.js +7 -0
- package/ui-dist/assets/yacas-BJ4BC0dw.js +1 -0
- package/ui-dist/assets/z80-Hz9HOZM7.js +1 -0
- package/ui-dist/brands/opencode-logo-dark-square.svg +18 -0
- package/ui-dist/brands/opencode-logo-light-square.svg +18 -0
- package/ui-dist/favicon-16x16.png +0 -0
- package/ui-dist/favicon-32x32.png +0 -0
- package/ui-dist/favicon.ico +0 -0
- package/ui-dist/favicon.svg +9 -0
- package/ui-dist/index.html +49 -0
- package/ui-dist/site.webmanifest +30 -0
- package/ui-dist/sw.js +42 -0
- package/ui-dist/worktree-favicon-16x16.png +0 -0
- package/ui-dist/worktree-favicon-32x32.png +0 -0
- package/ui-dist/worktree-favicon.ico +0 -0
- package/ui-dist/worktree-favicon.svg +9 -0
|
@@ -0,0 +1,1662 @@
|
|
|
1
|
+
import { readFile, readdir } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { and, asc, desc, eq, getTableColumns, gte, lte, ne, or } from "drizzle-orm";
|
|
4
|
+
import { agents, companies, companySkills, costEvents, documentRevisions, documents, feedbackExports, feedbackVotes, heartbeatRunEvents, heartbeatRuns, instanceSettings, issueComments, issueDocuments, issues, } from "@zmeel/db";
|
|
5
|
+
import { readzmeelSkillSyncPreference } from "@zmeel/adapter-utils/server-utils";
|
|
6
|
+
import { claudeConfigDir, parseClaudeStreamJson } from "@zmeel/adapter-claude-local/server";
|
|
7
|
+
import { codexHomeDir, parseCodexJsonl } from "@zmeel/adapter-codex-local/server";
|
|
8
|
+
import { parseOpenCodeJsonl } from "@zmeel/adapter-opencode-local/server";
|
|
9
|
+
import { DEFAULT_FEEDBACK_DATA_SHARING_PREFERENCE, DEFAULT_FEEDBACK_DATA_SHARING_TERMS_VERSION, instanceGeneralSettingsSchema, } from "@zmeel/shared";
|
|
10
|
+
import { resolveHomeAwarePath, resolvezmeelInstanceRoot } from "../home-paths.js";
|
|
11
|
+
import { notFound, unprocessable } from "../errors.js";
|
|
12
|
+
import { agentInstructionsService } from "./agent-instructions.js";
|
|
13
|
+
import { createFeedbackRedactionState, finalizeFeedbackRedactionSummary, sanitizeFeedbackText, sanitizeFeedbackValue, sha256Digest, } from "./feedback-redaction.js";
|
|
14
|
+
import { getRunLogStore } from "./run-log-store.js";
|
|
15
|
+
const FEEDBACK_SCHEMA_VERSION = "zmeel-feedback-envelope-v2";
|
|
16
|
+
const FEEDBACK_BUNDLE_VERSION = "zmeel-feedback-bundle-v2";
|
|
17
|
+
const FEEDBACK_PAYLOAD_VERSION = "zmeel-feedback-v1";
|
|
18
|
+
const FEEDBACK_DESTINATION = "zmeel_labs_feedback_v1";
|
|
19
|
+
const FEEDBACK_CONTEXT_WINDOW = 3;
|
|
20
|
+
const MAX_EXCERPT_CHARS = 200;
|
|
21
|
+
const MAX_PRIMARY_CONTENT_CHARS = 8_000;
|
|
22
|
+
const MAX_CONTEXT_ITEM_BODY_CHARS = 3_000;
|
|
23
|
+
const MAX_TOTAL_CONTEXT_CHARS = 12_000;
|
|
24
|
+
const MAX_DESCRIPTION_CHARS = 1_200;
|
|
25
|
+
const MAX_INSTRUCTIONS_BODY_CHARS = 8_000;
|
|
26
|
+
const MAX_PATH_CHARS = 600;
|
|
27
|
+
const MAX_SKILLS = 20;
|
|
28
|
+
const MAX_INSTRUCTION_FILES = 20;
|
|
29
|
+
const MAX_TRACE_FILE_CHARS = 10_000_000;
|
|
30
|
+
const DEFAULT_INSTANCE_SETTINGS_SINGLETON_KEY = "default";
|
|
31
|
+
const feedbackExportColumns = getTableColumns(feedbackExports);
|
|
32
|
+
const instructionsSvc = agentInstructionsService();
|
|
33
|
+
function asRecord(value) {
|
|
34
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
35
|
+
return null;
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
function asString(value) {
|
|
39
|
+
if (typeof value !== "string")
|
|
40
|
+
return null;
|
|
41
|
+
const trimmed = value.trim();
|
|
42
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
43
|
+
}
|
|
44
|
+
function asNumber(value) {
|
|
45
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
46
|
+
return null;
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
function asBoolean(value) {
|
|
50
|
+
return typeof value === "boolean" ? value : null;
|
|
51
|
+
}
|
|
52
|
+
function uniqueNonEmpty(values) {
|
|
53
|
+
return Array.from(new Set(values.map((value) => value?.trim() ?? "").filter(Boolean)));
|
|
54
|
+
}
|
|
55
|
+
function truncateExcerpt(text, max = MAX_EXCERPT_CHARS) {
|
|
56
|
+
const normalized = text.replace(/\s+/g, " ").trim();
|
|
57
|
+
if (!normalized)
|
|
58
|
+
return null;
|
|
59
|
+
return normalized.length <= max ? normalized : `${normalized.slice(0, max - 1)}...`;
|
|
60
|
+
}
|
|
61
|
+
function contentTypeForPath(filePath) {
|
|
62
|
+
const lower = filePath.toLowerCase();
|
|
63
|
+
if (lower.endsWith(".jsonl") || lower.endsWith(".ndjson"))
|
|
64
|
+
return "application/x-ndjson";
|
|
65
|
+
if (lower.endsWith(".json"))
|
|
66
|
+
return "application/json";
|
|
67
|
+
if (lower.endsWith(".md"))
|
|
68
|
+
return "text/markdown; charset=utf-8";
|
|
69
|
+
return "text/plain; charset=utf-8";
|
|
70
|
+
}
|
|
71
|
+
function normalizeInstanceGeneralSettings(raw) {
|
|
72
|
+
const parsed = instanceGeneralSettingsSchema.safeParse(raw ?? {});
|
|
73
|
+
if (parsed.success)
|
|
74
|
+
return parsed.data;
|
|
75
|
+
return {
|
|
76
|
+
censorUsernameInLogs: false,
|
|
77
|
+
feedbackDataSharingPreference: DEFAULT_FEEDBACK_DATA_SHARING_PREFERENCE,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function buildIssuePath(identifier) {
|
|
81
|
+
if (!identifier)
|
|
82
|
+
return null;
|
|
83
|
+
const prefix = identifier.split("-")[0]?.trim();
|
|
84
|
+
if (!prefix)
|
|
85
|
+
return null;
|
|
86
|
+
return `/${prefix}/issues/${identifier}`;
|
|
87
|
+
}
|
|
88
|
+
function buildTargetSummary(input) {
|
|
89
|
+
return {
|
|
90
|
+
label: input.label,
|
|
91
|
+
excerpt: input.excerpt,
|
|
92
|
+
authorAgentId: input.authorAgentId,
|
|
93
|
+
authorUserId: input.authorUserId,
|
|
94
|
+
createdAt: input.createdAt,
|
|
95
|
+
documentKey: input.documentKey ?? null,
|
|
96
|
+
documentTitle: input.documentTitle ?? null,
|
|
97
|
+
revisionNumber: input.revisionNumber ?? null,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function normalizeReason(vote, reason) {
|
|
101
|
+
if (vote !== "down" || typeof reason !== "string")
|
|
102
|
+
return null;
|
|
103
|
+
const trimmed = reason.trim();
|
|
104
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
105
|
+
}
|
|
106
|
+
function normalizeSkillReference(value) {
|
|
107
|
+
return value.trim().toLowerCase();
|
|
108
|
+
}
|
|
109
|
+
function matchesSkillReference(skill, reference) {
|
|
110
|
+
const normalized = normalizeSkillReference(reference);
|
|
111
|
+
if (!normalized)
|
|
112
|
+
return false;
|
|
113
|
+
if (skill.key.toLowerCase() === normalized)
|
|
114
|
+
return true;
|
|
115
|
+
if (skill.slug.toLowerCase() === normalized)
|
|
116
|
+
return true;
|
|
117
|
+
if (skill.name.toLowerCase() === normalized)
|
|
118
|
+
return true;
|
|
119
|
+
const keyTail = skill.key.split("/").pop()?.toLowerCase();
|
|
120
|
+
return keyTail === normalized;
|
|
121
|
+
}
|
|
122
|
+
function buildExportId(feedbackVoteId, sharedAt) {
|
|
123
|
+
return `fbexp_${sha256Digest(`${feedbackVoteId}:${sharedAt.toISOString()}`).slice(0, 24)}`;
|
|
124
|
+
}
|
|
125
|
+
function resolveSourceRunId(payloadSnapshot) {
|
|
126
|
+
const targetRunId = asString(asRecord(payloadSnapshot?.target)?.createdByRunId);
|
|
127
|
+
if (targetRunId)
|
|
128
|
+
return targetRunId;
|
|
129
|
+
const bundle = asRecord(payloadSnapshot?.bundle);
|
|
130
|
+
const agentContext = asRecord(bundle?.agentContext);
|
|
131
|
+
const runtime = asRecord(agentContext?.runtime);
|
|
132
|
+
return asString(asRecord(runtime?.sourceRun)?.id);
|
|
133
|
+
}
|
|
134
|
+
function makeBundleFile(input) {
|
|
135
|
+
return {
|
|
136
|
+
path: input.path,
|
|
137
|
+
contentType: input.contentType,
|
|
138
|
+
encoding: "utf8",
|
|
139
|
+
byteLength: Buffer.byteLength(input.contents, "utf8"),
|
|
140
|
+
sha256: sha256Digest(input.contents),
|
|
141
|
+
source: input.source,
|
|
142
|
+
contents: input.contents,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function appendNote(notes, note) {
|
|
146
|
+
if (note.trim().length === 0 || notes.includes(note))
|
|
147
|
+
return;
|
|
148
|
+
notes.push(note);
|
|
149
|
+
}
|
|
150
|
+
async function readTextFileIfPresent(filePath, state, fieldPath) {
|
|
151
|
+
if (!filePath)
|
|
152
|
+
return null;
|
|
153
|
+
const raw = await readFile(filePath, "utf8").catch(() => null);
|
|
154
|
+
if (raw == null)
|
|
155
|
+
return null;
|
|
156
|
+
return sanitizeFeedbackText(raw, state, fieldPath, MAX_TRACE_FILE_CHARS);
|
|
157
|
+
}
|
|
158
|
+
async function listChildFiles(dirPath) {
|
|
159
|
+
const entries = await readdir(dirPath, { withFileTypes: true }).catch(() => []);
|
|
160
|
+
return entries
|
|
161
|
+
.filter((entry) => entry.isFile())
|
|
162
|
+
.map((entry) => path.join(dirPath, entry.name))
|
|
163
|
+
.sort((left, right) => left.localeCompare(right));
|
|
164
|
+
}
|
|
165
|
+
async function listNestedFiles(dirPath, maxDepth = 4) {
|
|
166
|
+
async function walk(currentPath, depth) {
|
|
167
|
+
const entries = await readdir(currentPath, { withFileTypes: true }).catch(() => []);
|
|
168
|
+
const files = entries
|
|
169
|
+
.filter((entry) => entry.isFile())
|
|
170
|
+
.map((entry) => path.join(currentPath, entry.name))
|
|
171
|
+
.sort((left, right) => left.localeCompare(right));
|
|
172
|
+
if (depth >= maxDepth)
|
|
173
|
+
return files;
|
|
174
|
+
const childDirs = entries
|
|
175
|
+
.filter((entry) => entry.isDirectory())
|
|
176
|
+
.map((entry) => path.join(currentPath, entry.name))
|
|
177
|
+
.sort((left, right) => left.localeCompare(right));
|
|
178
|
+
const nested = await Promise.all(childDirs.map((childDir) => walk(childDir, depth + 1)));
|
|
179
|
+
return [...files, ...nested.flat()];
|
|
180
|
+
}
|
|
181
|
+
return walk(dirPath, 0);
|
|
182
|
+
}
|
|
183
|
+
async function findMatchingFile(rootDir, matcher, maxDepth = 5) {
|
|
184
|
+
async function search(dirPath, depth) {
|
|
185
|
+
const entries = await readdir(dirPath, { withFileTypes: true }).catch(() => []);
|
|
186
|
+
for (const entry of entries) {
|
|
187
|
+
const absolutePath = path.join(dirPath, entry.name);
|
|
188
|
+
if (entry.isFile() && matcher(absolutePath, entry.name)) {
|
|
189
|
+
return absolutePath;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (depth >= maxDepth)
|
|
193
|
+
return null;
|
|
194
|
+
for (const entry of entries) {
|
|
195
|
+
if (!entry.isDirectory())
|
|
196
|
+
continue;
|
|
197
|
+
const found = await search(path.join(dirPath, entry.name), depth + 1);
|
|
198
|
+
if (found)
|
|
199
|
+
return found;
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
return search(rootDir, 0);
|
|
204
|
+
}
|
|
205
|
+
async function readFullRunLog(run) {
|
|
206
|
+
if (run.logStore !== "local_file" || !run.logRef)
|
|
207
|
+
return null;
|
|
208
|
+
const store = getRunLogStore();
|
|
209
|
+
let offset = 0;
|
|
210
|
+
let combined = "";
|
|
211
|
+
while (true) {
|
|
212
|
+
const result = await store.read({ store: "local_file", logRef: run.logRef }, {
|
|
213
|
+
offset,
|
|
214
|
+
limitBytes: 512_000,
|
|
215
|
+
}).catch(() => null);
|
|
216
|
+
if (!result)
|
|
217
|
+
return combined || null;
|
|
218
|
+
combined += result.content;
|
|
219
|
+
if (result.nextOffset == null)
|
|
220
|
+
break;
|
|
221
|
+
offset = result.nextOffset;
|
|
222
|
+
}
|
|
223
|
+
return combined || null;
|
|
224
|
+
}
|
|
225
|
+
function parseRunLogEntries(logText) {
|
|
226
|
+
if (!logText)
|
|
227
|
+
return [];
|
|
228
|
+
const entries = [];
|
|
229
|
+
for (const rawLine of logText.split(/\r?\n/)) {
|
|
230
|
+
const line = rawLine.trim();
|
|
231
|
+
if (!line)
|
|
232
|
+
continue;
|
|
233
|
+
try {
|
|
234
|
+
const parsed = JSON.parse(line);
|
|
235
|
+
const ts = asString(parsed.ts) ?? new Date(0).toISOString();
|
|
236
|
+
const stream = asString(parsed.stream) ?? "stdout";
|
|
237
|
+
const chunk = typeof parsed.chunk === "string" ? parsed.chunk : "";
|
|
238
|
+
entries.push({ ts, stream, chunk });
|
|
239
|
+
}
|
|
240
|
+
catch {
|
|
241
|
+
// Keep malformed lines out of the normalized bundle but preserve the raw log file separately.
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return entries;
|
|
245
|
+
}
|
|
246
|
+
function captureStatusFromFiles(files) {
|
|
247
|
+
const sources = new Set(files.map((file) => file.source));
|
|
248
|
+
if (sources.has("codex_session"))
|
|
249
|
+
return "full";
|
|
250
|
+
if (sources.has("claude_project_session") || sources.has("claude_debug_log"))
|
|
251
|
+
return "full";
|
|
252
|
+
if (sources.has("opencode_session") &&
|
|
253
|
+
sources.has("opencode_message") &&
|
|
254
|
+
sources.has("opencode_message_part")) {
|
|
255
|
+
return "full";
|
|
256
|
+
}
|
|
257
|
+
const hasAdapterFiles = files.some((file) => file.source !== "zmeel_run" &&
|
|
258
|
+
file.source !== "zmeel_run_events" &&
|
|
259
|
+
file.source !== "zmeel_run_log");
|
|
260
|
+
if (hasAdapterFiles)
|
|
261
|
+
return "partial";
|
|
262
|
+
return files.length > 0 ? "partial" : "unavailable";
|
|
263
|
+
}
|
|
264
|
+
async function buildCodexTraceFiles(input) {
|
|
265
|
+
const files = [];
|
|
266
|
+
if (!input.sessionId) {
|
|
267
|
+
appendNote(input.notes, "codex_session_id_missing");
|
|
268
|
+
return { files, raw: null, normalized: null };
|
|
269
|
+
}
|
|
270
|
+
const managedRoot = path.join(resolvezmeelInstanceRoot(), "companies", input.companyId, "codex-home", "sessions");
|
|
271
|
+
const sharedRoot = path.join(codexHomeDir(), "sessions");
|
|
272
|
+
const sessionFile = await findMatchingFile(managedRoot, (_absolutePath, name) => name.includes(input.sessionId), 6) ??
|
|
273
|
+
await findMatchingFile(sharedRoot, (_absolutePath, name) => name.includes(input.sessionId), 6);
|
|
274
|
+
const sessionText = await readTextFileIfPresent(sessionFile, input.state, "bundle.rawAdapterTrace.codex.session");
|
|
275
|
+
if (!sessionText) {
|
|
276
|
+
appendNote(input.notes, "codex_session_file_missing");
|
|
277
|
+
return { files, raw: null, normalized: null };
|
|
278
|
+
}
|
|
279
|
+
files.push(makeBundleFile({
|
|
280
|
+
path: "adapter/codex/session.jsonl",
|
|
281
|
+
contentType: "application/x-ndjson",
|
|
282
|
+
source: "codex_session",
|
|
283
|
+
contents: sessionText,
|
|
284
|
+
}));
|
|
285
|
+
return {
|
|
286
|
+
files,
|
|
287
|
+
raw: {
|
|
288
|
+
adapterType: "codex_local",
|
|
289
|
+
sessionId: input.sessionId,
|
|
290
|
+
sessionFile: sessionFile ? path.basename(sessionFile) : null,
|
|
291
|
+
},
|
|
292
|
+
normalized: sanitizeFeedbackValue({
|
|
293
|
+
adapterType: "codex_local",
|
|
294
|
+
sessionId: input.sessionId,
|
|
295
|
+
summary: parseCodexJsonl(sessionText),
|
|
296
|
+
}, input.state, "bundle.normalizedAdapterTrace.codex", MAX_TRACE_FILE_CHARS),
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
async function buildClaudeTraceFiles(input) {
|
|
300
|
+
const files = [];
|
|
301
|
+
const sanitizedStdout = sanitizeFeedbackText(input.stdoutText, input.state, "bundle.rawAdapterTrace.claude.stdout", MAX_TRACE_FILE_CHARS);
|
|
302
|
+
if (sanitizedStdout.trim().length > 0) {
|
|
303
|
+
files.push(makeBundleFile({
|
|
304
|
+
path: "adapter/claude/stream-json.ndjson",
|
|
305
|
+
contentType: "application/x-ndjson",
|
|
306
|
+
source: "claude_stream_json",
|
|
307
|
+
contents: sanitizedStdout,
|
|
308
|
+
}));
|
|
309
|
+
}
|
|
310
|
+
const projectsRoot = path.join(claudeConfigDir(), "projects");
|
|
311
|
+
const projectSessionFile = input.sessionId
|
|
312
|
+
? await findMatchingFile(projectsRoot, (_absolutePath, name) => name === `${input.sessionId}.jsonl`, 6)
|
|
313
|
+
: null;
|
|
314
|
+
const projectSessionText = await readTextFileIfPresent(projectSessionFile, input.state, "bundle.rawAdapterTrace.claude.projectSession");
|
|
315
|
+
if (projectSessionText) {
|
|
316
|
+
files.push(makeBundleFile({
|
|
317
|
+
path: "adapter/claude/session.jsonl",
|
|
318
|
+
contentType: "application/x-ndjson",
|
|
319
|
+
source: "claude_project_session",
|
|
320
|
+
contents: projectSessionText,
|
|
321
|
+
}));
|
|
322
|
+
}
|
|
323
|
+
else if (input.sessionId) {
|
|
324
|
+
appendNote(input.notes, "claude_project_session_missing");
|
|
325
|
+
}
|
|
326
|
+
const projectSessionArtifactsDir = projectSessionFile
|
|
327
|
+
? path.join(path.dirname(projectSessionFile), input.sessionId ?? "")
|
|
328
|
+
: null;
|
|
329
|
+
const projectSessionArtifactFiles = projectSessionArtifactsDir
|
|
330
|
+
? await listNestedFiles(projectSessionArtifactsDir, 4)
|
|
331
|
+
: [];
|
|
332
|
+
for (const filePath of projectSessionArtifactFiles) {
|
|
333
|
+
const relativePath = path.relative(projectSessionArtifactsDir, filePath).split(path.sep).join("/");
|
|
334
|
+
const fileText = await readTextFileIfPresent(filePath, input.state, `bundle.rawAdapterTrace.claude.projectArtifacts.${relativePath}`);
|
|
335
|
+
if (!fileText)
|
|
336
|
+
continue;
|
|
337
|
+
files.push(makeBundleFile({
|
|
338
|
+
path: `adapter/claude/session/${relativePath}`,
|
|
339
|
+
contentType: contentTypeForPath(filePath),
|
|
340
|
+
source: "claude_project_artifact",
|
|
341
|
+
contents: fileText,
|
|
342
|
+
}));
|
|
343
|
+
}
|
|
344
|
+
const debugLogText = await readTextFileIfPresent(input.sessionId ? path.join(claudeConfigDir(), "debug", `${input.sessionId}.txt`) : null, input.state, "bundle.rawAdapterTrace.claude.debugLog");
|
|
345
|
+
if (debugLogText) {
|
|
346
|
+
files.push(makeBundleFile({
|
|
347
|
+
path: "adapter/claude/debug.txt",
|
|
348
|
+
contentType: "text/plain; charset=utf-8",
|
|
349
|
+
source: "claude_debug_log",
|
|
350
|
+
contents: debugLogText,
|
|
351
|
+
}));
|
|
352
|
+
}
|
|
353
|
+
const taskDir = input.sessionId ? path.join(claudeConfigDir(), "tasks", input.sessionId) : null;
|
|
354
|
+
const taskFiles = taskDir ? await listChildFiles(taskDir) : [];
|
|
355
|
+
const metadataPieces = [];
|
|
356
|
+
for (const filePath of taskFiles) {
|
|
357
|
+
const fileText = await readTextFileIfPresent(filePath, input.state, `bundle.rawAdapterTrace.claude.taskMetadata.${path.basename(filePath)}`);
|
|
358
|
+
if (!fileText)
|
|
359
|
+
continue;
|
|
360
|
+
metadataPieces.push(`# ${path.basename(filePath)}\n${fileText}`);
|
|
361
|
+
}
|
|
362
|
+
if (metadataPieces.length > 0) {
|
|
363
|
+
files.push(makeBundleFile({
|
|
364
|
+
path: "adapter/claude/task-metadata.txt",
|
|
365
|
+
contentType: "text/plain; charset=utf-8",
|
|
366
|
+
source: "claude_task_metadata",
|
|
367
|
+
contents: `${metadataPieces.join("\n\n")}\n`,
|
|
368
|
+
}));
|
|
369
|
+
}
|
|
370
|
+
else if (input.sessionId) {
|
|
371
|
+
appendNote(input.notes, "claude_task_metadata_missing");
|
|
372
|
+
}
|
|
373
|
+
if (files.length === 0) {
|
|
374
|
+
appendNote(input.notes, "claude_stream_trace_missing");
|
|
375
|
+
}
|
|
376
|
+
return {
|
|
377
|
+
files,
|
|
378
|
+
raw: {
|
|
379
|
+
adapterType: "claude_local",
|
|
380
|
+
sessionId: input.sessionId,
|
|
381
|
+
projectSessionFound: Boolean(projectSessionText),
|
|
382
|
+
projectArtifactsCount: projectSessionArtifactFiles.length,
|
|
383
|
+
debugLogFound: Boolean(debugLogText),
|
|
384
|
+
taskDirPresent: taskFiles.length > 0,
|
|
385
|
+
},
|
|
386
|
+
normalized: sanitizeFeedbackValue({
|
|
387
|
+
adapterType: "claude_local",
|
|
388
|
+
sessionId: input.sessionId,
|
|
389
|
+
summary: parseClaudeStreamJson(input.stdoutText),
|
|
390
|
+
}, input.state, "bundle.normalizedAdapterTrace.claude", MAX_TRACE_FILE_CHARS),
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
async function buildOpenCodeTraceFiles(input) {
|
|
394
|
+
const files = [];
|
|
395
|
+
if (!input.sessionId) {
|
|
396
|
+
appendNote(input.notes, "opencode_session_id_missing");
|
|
397
|
+
return {
|
|
398
|
+
files,
|
|
399
|
+
raw: null,
|
|
400
|
+
normalized: sanitizeFeedbackValue({
|
|
401
|
+
adapterType: "opencode_local",
|
|
402
|
+
summary: parseOpenCodeJsonl(input.stdoutText),
|
|
403
|
+
}, input.state, "bundle.normalizedAdapterTrace.opencode", MAX_TRACE_FILE_CHARS),
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
const opencodeRoot = resolveHomeAwarePath(process.env.ZMEEL_OPENCODE_STORAGE_DIR ?? "~/.local/share/opencode");
|
|
407
|
+
const sessionRoot = path.join(opencodeRoot, "storage", "session");
|
|
408
|
+
const diffRoot = path.join(opencodeRoot, "storage", "session_diff");
|
|
409
|
+
const messageRoot = path.join(opencodeRoot, "storage", "message");
|
|
410
|
+
const partRoot = path.join(opencodeRoot, "storage", "part");
|
|
411
|
+
const todoRoot = path.join(opencodeRoot, "storage", "todo");
|
|
412
|
+
const projectRoot = path.join(opencodeRoot, "storage", "project");
|
|
413
|
+
const sessionFile = await findMatchingFile(sessionRoot, (_absolutePath, name) => name === `${input.sessionId}.json`, 6);
|
|
414
|
+
const diffFile = path.join(diffRoot, `${input.sessionId}.json`);
|
|
415
|
+
const sessionRaw = sessionFile ? await readFile(sessionFile, "utf8").catch(() => null) : null;
|
|
416
|
+
const sessionText = sessionRaw == null
|
|
417
|
+
? null
|
|
418
|
+
: sanitizeFeedbackText(sessionRaw, input.state, "bundle.rawAdapterTrace.opencode.session", MAX_TRACE_FILE_CHARS);
|
|
419
|
+
if (sessionText) {
|
|
420
|
+
files.push(makeBundleFile({
|
|
421
|
+
path: "adapter/opencode/session.json",
|
|
422
|
+
contentType: "application/json",
|
|
423
|
+
source: "opencode_session",
|
|
424
|
+
contents: sessionText,
|
|
425
|
+
}));
|
|
426
|
+
}
|
|
427
|
+
else {
|
|
428
|
+
appendNote(input.notes, "opencode_session_file_missing");
|
|
429
|
+
}
|
|
430
|
+
const diffText = await readTextFileIfPresent(diffFile, input.state, "bundle.rawAdapterTrace.opencode.sessionDiff");
|
|
431
|
+
if (diffText) {
|
|
432
|
+
files.push(makeBundleFile({
|
|
433
|
+
path: "adapter/opencode/session-diff.json",
|
|
434
|
+
contentType: "application/json",
|
|
435
|
+
source: "opencode_session_diff",
|
|
436
|
+
contents: diffText,
|
|
437
|
+
}));
|
|
438
|
+
}
|
|
439
|
+
const messageFiles = await listChildFiles(path.join(messageRoot, input.sessionId));
|
|
440
|
+
const messageIds = [];
|
|
441
|
+
for (const filePath of messageFiles) {
|
|
442
|
+
const messageText = await readTextFileIfPresent(filePath, input.state, `bundle.rawAdapterTrace.opencode.messages.${path.basename(filePath)}`);
|
|
443
|
+
if (!messageText)
|
|
444
|
+
continue;
|
|
445
|
+
messageIds.push(path.basename(filePath, path.extname(filePath)));
|
|
446
|
+
files.push(makeBundleFile({
|
|
447
|
+
path: `adapter/opencode/messages/${path.basename(filePath)}`,
|
|
448
|
+
contentType: "application/json",
|
|
449
|
+
source: "opencode_message",
|
|
450
|
+
contents: messageText,
|
|
451
|
+
}));
|
|
452
|
+
}
|
|
453
|
+
if (messageFiles.length === 0) {
|
|
454
|
+
appendNote(input.notes, "opencode_message_files_missing");
|
|
455
|
+
}
|
|
456
|
+
let partFilesCount = 0;
|
|
457
|
+
for (const messageId of messageIds) {
|
|
458
|
+
const partFiles = await listChildFiles(path.join(partRoot, messageId));
|
|
459
|
+
for (const filePath of partFiles) {
|
|
460
|
+
const partText = await readTextFileIfPresent(filePath, input.state, `bundle.rawAdapterTrace.opencode.parts.${messageId}.${path.basename(filePath)}`);
|
|
461
|
+
if (!partText)
|
|
462
|
+
continue;
|
|
463
|
+
partFilesCount += 1;
|
|
464
|
+
files.push(makeBundleFile({
|
|
465
|
+
path: `adapter/opencode/parts/${messageId}/${path.basename(filePath)}`,
|
|
466
|
+
contentType: "application/json",
|
|
467
|
+
source: "opencode_message_part",
|
|
468
|
+
contents: partText,
|
|
469
|
+
}));
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
if (messageIds.length > 0 && partFilesCount === 0) {
|
|
473
|
+
appendNote(input.notes, "opencode_message_parts_missing");
|
|
474
|
+
}
|
|
475
|
+
const parsedSession = (() => {
|
|
476
|
+
if (!sessionRaw)
|
|
477
|
+
return null;
|
|
478
|
+
try {
|
|
479
|
+
return JSON.parse(sessionRaw);
|
|
480
|
+
}
|
|
481
|
+
catch {
|
|
482
|
+
return null;
|
|
483
|
+
}
|
|
484
|
+
})();
|
|
485
|
+
const projectId = asString(parsedSession?.projectID) ?? asString(parsedSession?.projectId);
|
|
486
|
+
const projectText = await readTextFileIfPresent(projectId ? path.join(projectRoot, `${projectId}.json`) : null, input.state, "bundle.rawAdapterTrace.opencode.project");
|
|
487
|
+
if (projectText) {
|
|
488
|
+
files.push(makeBundleFile({
|
|
489
|
+
path: "adapter/opencode/project.json",
|
|
490
|
+
contentType: "application/json",
|
|
491
|
+
source: "opencode_project",
|
|
492
|
+
contents: projectText,
|
|
493
|
+
}));
|
|
494
|
+
}
|
|
495
|
+
const todoText = await readTextFileIfPresent(path.join(todoRoot, `${input.sessionId}.json`), input.state, "bundle.rawAdapterTrace.opencode.todo");
|
|
496
|
+
if (todoText) {
|
|
497
|
+
files.push(makeBundleFile({
|
|
498
|
+
path: "adapter/opencode/todo.json",
|
|
499
|
+
contentType: "application/json",
|
|
500
|
+
source: "opencode_todo",
|
|
501
|
+
contents: todoText,
|
|
502
|
+
}));
|
|
503
|
+
}
|
|
504
|
+
return {
|
|
505
|
+
files,
|
|
506
|
+
raw: {
|
|
507
|
+
adapterType: "opencode_local",
|
|
508
|
+
sessionId: input.sessionId,
|
|
509
|
+
sessionFileFound: Boolean(sessionText),
|
|
510
|
+
sessionDiffFound: Boolean(diffText),
|
|
511
|
+
messageFilesCount: messageFiles.length,
|
|
512
|
+
partFilesCount,
|
|
513
|
+
projectFound: Boolean(projectText),
|
|
514
|
+
todoFound: Boolean(todoText),
|
|
515
|
+
},
|
|
516
|
+
normalized: sanitizeFeedbackValue({
|
|
517
|
+
adapterType: "opencode_local",
|
|
518
|
+
sessionId: input.sessionId,
|
|
519
|
+
summary: parseOpenCodeJsonl(input.stdoutText),
|
|
520
|
+
}, input.state, "bundle.normalizedAdapterTrace.opencode", MAX_TRACE_FILE_CHARS),
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
function truncateFailureReason(error) {
|
|
524
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
525
|
+
return message.trim().slice(0, 1_000) || "Feedback export failed";
|
|
526
|
+
}
|
|
527
|
+
function mapTraceRow(row, includePayload) {
|
|
528
|
+
const targetSummary = asRecord(row.targetSummary);
|
|
529
|
+
return {
|
|
530
|
+
id: row.id,
|
|
531
|
+
companyId: row.companyId,
|
|
532
|
+
feedbackVoteId: row.feedbackVoteId,
|
|
533
|
+
issueId: row.issueId,
|
|
534
|
+
projectId: row.projectId ?? null,
|
|
535
|
+
issueIdentifier: row.issueIdentifier,
|
|
536
|
+
issueTitle: row.issueTitle,
|
|
537
|
+
authorUserId: row.authorUserId,
|
|
538
|
+
targetType: row.targetType,
|
|
539
|
+
targetId: row.targetId,
|
|
540
|
+
vote: row.vote,
|
|
541
|
+
status: row.status,
|
|
542
|
+
destination: row.destination ?? null,
|
|
543
|
+
exportId: row.exportId ?? null,
|
|
544
|
+
consentVersion: row.consentVersion ?? null,
|
|
545
|
+
schemaVersion: row.schemaVersion,
|
|
546
|
+
bundleVersion: row.bundleVersion,
|
|
547
|
+
payloadVersion: row.payloadVersion,
|
|
548
|
+
payloadDigest: row.payloadDigest ?? null,
|
|
549
|
+
payloadSnapshot: includePayload ? asRecord(row.payloadSnapshot) : null,
|
|
550
|
+
targetSummary: targetSummary ?? buildTargetSummary({
|
|
551
|
+
label: row.targetType,
|
|
552
|
+
excerpt: null,
|
|
553
|
+
authorAgentId: null,
|
|
554
|
+
authorUserId: null,
|
|
555
|
+
createdAt: null,
|
|
556
|
+
}),
|
|
557
|
+
redactionSummary: asRecord(row.redactionSummary),
|
|
558
|
+
attemptCount: row.attemptCount,
|
|
559
|
+
lastAttemptedAt: row.lastAttemptedAt ?? null,
|
|
560
|
+
exportedAt: row.exportedAt ?? null,
|
|
561
|
+
failureReason: row.failureReason ?? null,
|
|
562
|
+
createdAt: row.createdAt,
|
|
563
|
+
updatedAt: row.updatedAt,
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
async function resolveFeedbackTarget(db, issue, targetType, targetId) {
|
|
567
|
+
const issuePath = buildIssuePath(issue.identifier);
|
|
568
|
+
if (targetType === "issue_comment") {
|
|
569
|
+
const targetComment = await db
|
|
570
|
+
.select({
|
|
571
|
+
id: issueComments.id,
|
|
572
|
+
issueId: issueComments.issueId,
|
|
573
|
+
companyId: issueComments.companyId,
|
|
574
|
+
authorAgentId: issueComments.authorAgentId,
|
|
575
|
+
authorUserId: issueComments.authorUserId,
|
|
576
|
+
createdByRunId: issueComments.createdByRunId,
|
|
577
|
+
body: issueComments.body,
|
|
578
|
+
createdAt: issueComments.createdAt,
|
|
579
|
+
})
|
|
580
|
+
.from(issueComments)
|
|
581
|
+
.where(eq(issueComments.id, targetId))
|
|
582
|
+
.then((rows) => rows[0] ?? null);
|
|
583
|
+
if (!targetComment || targetComment.issueId !== issue.id || targetComment.companyId !== issue.companyId) {
|
|
584
|
+
throw notFound("Feedback target not found");
|
|
585
|
+
}
|
|
586
|
+
if (!targetComment.authorAgentId) {
|
|
587
|
+
throw unprocessable("Feedback voting is only available on agent-authored issue comments");
|
|
588
|
+
}
|
|
589
|
+
const record = {
|
|
590
|
+
targetType,
|
|
591
|
+
targetId,
|
|
592
|
+
label: "Comment",
|
|
593
|
+
body: targetComment.body,
|
|
594
|
+
createdAt: targetComment.createdAt,
|
|
595
|
+
authorAgentId: targetComment.authorAgentId,
|
|
596
|
+
authorUserId: targetComment.authorUserId,
|
|
597
|
+
createdByRunId: targetComment.createdByRunId ?? null,
|
|
598
|
+
documentId: null,
|
|
599
|
+
documentKey: null,
|
|
600
|
+
documentTitle: null,
|
|
601
|
+
revisionNumber: null,
|
|
602
|
+
issuePath,
|
|
603
|
+
targetPath: issuePath ? `${issuePath}#comment-${targetComment.id}` : null,
|
|
604
|
+
payloadTarget: {
|
|
605
|
+
type: targetType,
|
|
606
|
+
id: targetComment.id,
|
|
607
|
+
createdAt: targetComment.createdAt.toISOString(),
|
|
608
|
+
authorAgentId: targetComment.authorAgentId,
|
|
609
|
+
authorUserId: targetComment.authorUserId,
|
|
610
|
+
createdByRunId: targetComment.createdByRunId ?? null,
|
|
611
|
+
issuePath,
|
|
612
|
+
targetPath: issuePath ? `${issuePath}#comment-${targetComment.id}` : null,
|
|
613
|
+
},
|
|
614
|
+
};
|
|
615
|
+
return record;
|
|
616
|
+
}
|
|
617
|
+
if (targetType === "issue_document_revision") {
|
|
618
|
+
const targetRevision = await db
|
|
619
|
+
.select({
|
|
620
|
+
id: documentRevisions.id,
|
|
621
|
+
companyId: documentRevisions.companyId,
|
|
622
|
+
documentId: documentRevisions.documentId,
|
|
623
|
+
revisionNumber: documentRevisions.revisionNumber,
|
|
624
|
+
body: documentRevisions.body,
|
|
625
|
+
createdByAgentId: documentRevisions.createdByAgentId,
|
|
626
|
+
createdByUserId: documentRevisions.createdByUserId,
|
|
627
|
+
createdByRunId: documentRevisions.createdByRunId,
|
|
628
|
+
createdAt: documentRevisions.createdAt,
|
|
629
|
+
issueId: issueDocuments.issueId,
|
|
630
|
+
key: issueDocuments.key,
|
|
631
|
+
title: documents.title,
|
|
632
|
+
})
|
|
633
|
+
.from(documentRevisions)
|
|
634
|
+
.innerJoin(documents, eq(documentRevisions.documentId, documents.id))
|
|
635
|
+
.innerJoin(issueDocuments, eq(issueDocuments.documentId, documents.id))
|
|
636
|
+
.where(eq(documentRevisions.id, targetId))
|
|
637
|
+
.then((rows) => rows.find((row) => row.issueId === issue.id) ?? null);
|
|
638
|
+
if (!targetRevision || targetRevision.companyId !== issue.companyId) {
|
|
639
|
+
throw notFound("Feedback target not found");
|
|
640
|
+
}
|
|
641
|
+
if (!targetRevision.createdByAgentId) {
|
|
642
|
+
throw unprocessable("Feedback voting is only available on agent-authored document revisions");
|
|
643
|
+
}
|
|
644
|
+
const record = {
|
|
645
|
+
targetType,
|
|
646
|
+
targetId,
|
|
647
|
+
label: `${targetRevision.key} rev ${targetRevision.revisionNumber}`,
|
|
648
|
+
body: targetRevision.body,
|
|
649
|
+
createdAt: targetRevision.createdAt,
|
|
650
|
+
authorAgentId: targetRevision.createdByAgentId,
|
|
651
|
+
authorUserId: targetRevision.createdByUserId,
|
|
652
|
+
createdByRunId: targetRevision.createdByRunId ?? null,
|
|
653
|
+
documentId: targetRevision.documentId,
|
|
654
|
+
documentKey: targetRevision.key,
|
|
655
|
+
documentTitle: targetRevision.title ?? null,
|
|
656
|
+
revisionNumber: targetRevision.revisionNumber,
|
|
657
|
+
issuePath,
|
|
658
|
+
targetPath: issuePath ? `${issuePath}#document-${encodeURIComponent(targetRevision.key)}` : null,
|
|
659
|
+
payloadTarget: {
|
|
660
|
+
type: targetType,
|
|
661
|
+
id: targetRevision.id,
|
|
662
|
+
documentId: targetRevision.documentId,
|
|
663
|
+
documentKey: targetRevision.key,
|
|
664
|
+
documentTitle: targetRevision.title ?? null,
|
|
665
|
+
revisionNumber: targetRevision.revisionNumber,
|
|
666
|
+
createdAt: targetRevision.createdAt.toISOString(),
|
|
667
|
+
authorAgentId: targetRevision.createdByAgentId,
|
|
668
|
+
authorUserId: targetRevision.createdByUserId,
|
|
669
|
+
createdByRunId: targetRevision.createdByRunId ?? null,
|
|
670
|
+
issuePath,
|
|
671
|
+
targetPath: issuePath ? `${issuePath}#document-${encodeURIComponent(targetRevision.key)}` : null,
|
|
672
|
+
},
|
|
673
|
+
};
|
|
674
|
+
return record;
|
|
675
|
+
}
|
|
676
|
+
throw unprocessable("Unsupported feedback target type");
|
|
677
|
+
}
|
|
678
|
+
async function listIssueContextItems(db, issue) {
|
|
679
|
+
const [commentRows, revisionRows] = await Promise.all([
|
|
680
|
+
db
|
|
681
|
+
.select({
|
|
682
|
+
targetId: issueComments.id,
|
|
683
|
+
body: issueComments.body,
|
|
684
|
+
createdAt: issueComments.createdAt,
|
|
685
|
+
authorAgentId: issueComments.authorAgentId,
|
|
686
|
+
authorUserId: issueComments.authorUserId,
|
|
687
|
+
createdByRunId: issueComments.createdByRunId,
|
|
688
|
+
})
|
|
689
|
+
.from(issueComments)
|
|
690
|
+
.where(and(eq(issueComments.companyId, issue.companyId), eq(issueComments.issueId, issue.id))),
|
|
691
|
+
db
|
|
692
|
+
.select({
|
|
693
|
+
targetId: documentRevisions.id,
|
|
694
|
+
body: documentRevisions.body,
|
|
695
|
+
createdAt: documentRevisions.createdAt,
|
|
696
|
+
authorAgentId: documentRevisions.createdByAgentId,
|
|
697
|
+
authorUserId: documentRevisions.createdByUserId,
|
|
698
|
+
createdByRunId: documentRevisions.createdByRunId,
|
|
699
|
+
documentId: documentRevisions.documentId,
|
|
700
|
+
documentKey: issueDocuments.key,
|
|
701
|
+
documentTitle: documents.title,
|
|
702
|
+
revisionNumber: documentRevisions.revisionNumber,
|
|
703
|
+
})
|
|
704
|
+
.from(documentRevisions)
|
|
705
|
+
.innerJoin(documents, eq(documentRevisions.documentId, documents.id))
|
|
706
|
+
.innerJoin(issueDocuments, eq(issueDocuments.documentId, documents.id))
|
|
707
|
+
.where(and(eq(documentRevisions.companyId, issue.companyId), eq(issueDocuments.issueId, issue.id))),
|
|
708
|
+
]);
|
|
709
|
+
const issuePath = buildIssuePath(issue.identifier);
|
|
710
|
+
const items = [
|
|
711
|
+
...commentRows.map((row) => ({
|
|
712
|
+
targetType: "issue_comment",
|
|
713
|
+
targetId: row.targetId,
|
|
714
|
+
label: "Comment",
|
|
715
|
+
body: row.body,
|
|
716
|
+
createdAt: row.createdAt,
|
|
717
|
+
authorAgentId: row.authorAgentId,
|
|
718
|
+
authorUserId: row.authorUserId,
|
|
719
|
+
createdByRunId: row.createdByRunId ?? null,
|
|
720
|
+
documentId: null,
|
|
721
|
+
documentKey: null,
|
|
722
|
+
documentTitle: null,
|
|
723
|
+
revisionNumber: null,
|
|
724
|
+
issuePath,
|
|
725
|
+
targetPath: issuePath ? `${issuePath}#comment-${row.targetId}` : null,
|
|
726
|
+
})),
|
|
727
|
+
...revisionRows.map((row) => ({
|
|
728
|
+
targetType: "issue_document_revision",
|
|
729
|
+
targetId: row.targetId,
|
|
730
|
+
label: `${row.documentKey} rev ${row.revisionNumber}`,
|
|
731
|
+
body: row.body,
|
|
732
|
+
createdAt: row.createdAt,
|
|
733
|
+
authorAgentId: row.authorAgentId,
|
|
734
|
+
authorUserId: row.authorUserId,
|
|
735
|
+
createdByRunId: row.createdByRunId ?? null,
|
|
736
|
+
documentId: row.documentId,
|
|
737
|
+
documentKey: row.documentKey,
|
|
738
|
+
documentTitle: row.documentTitle ?? null,
|
|
739
|
+
revisionNumber: row.revisionNumber,
|
|
740
|
+
issuePath,
|
|
741
|
+
targetPath: issuePath ? `${issuePath}#document-${encodeURIComponent(row.documentKey)}` : null,
|
|
742
|
+
})),
|
|
743
|
+
];
|
|
744
|
+
return items.sort((left, right) => {
|
|
745
|
+
const byDate = left.createdAt.getTime() - right.createdAt.getTime();
|
|
746
|
+
if (byDate !== 0)
|
|
747
|
+
return byDate;
|
|
748
|
+
return left.targetId.localeCompare(right.targetId);
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
async function buildIssueContext(db, issue, target, state) {
|
|
752
|
+
const items = await listIssueContextItems(db, issue);
|
|
753
|
+
const targetIndex = items.findIndex((item) => item.targetType === target.targetType && item.targetId === target.targetId);
|
|
754
|
+
const before = targetIndex >= 0
|
|
755
|
+
? items.slice(Math.max(0, targetIndex - FEEDBACK_CONTEXT_WINDOW), targetIndex)
|
|
756
|
+
: [];
|
|
757
|
+
const after = targetIndex >= 0
|
|
758
|
+
? items.slice(targetIndex + 1, targetIndex + 1 + FEEDBACK_CONTEXT_WINDOW)
|
|
759
|
+
: [];
|
|
760
|
+
let remainingChars = MAX_TOTAL_CONTEXT_CHARS;
|
|
761
|
+
const serializedItems = [...before, ...after].map((item, index) => {
|
|
762
|
+
const relation = index < before.length ? "before" : "after";
|
|
763
|
+
if (remainingChars <= 0) {
|
|
764
|
+
state.omittedFields.add("bundle.issueContext.items");
|
|
765
|
+
return null;
|
|
766
|
+
}
|
|
767
|
+
const maxChars = Math.min(MAX_CONTEXT_ITEM_BODY_CHARS, remainingChars);
|
|
768
|
+
const body = sanitizeFeedbackText(item.body, state, `bundle.issueContext.items.${index}.body`, maxChars);
|
|
769
|
+
remainingChars -= body.length;
|
|
770
|
+
return {
|
|
771
|
+
type: item.targetType,
|
|
772
|
+
id: item.targetId,
|
|
773
|
+
label: item.label,
|
|
774
|
+
relation,
|
|
775
|
+
createdAt: item.createdAt.toISOString(),
|
|
776
|
+
authorAgentId: item.authorAgentId,
|
|
777
|
+
authorUserId: item.authorUserId,
|
|
778
|
+
createdByRunId: item.createdByRunId,
|
|
779
|
+
documentKey: item.documentKey,
|
|
780
|
+
documentTitle: item.documentTitle,
|
|
781
|
+
revisionNumber: item.revisionNumber,
|
|
782
|
+
targetPath: item.targetPath,
|
|
783
|
+
body,
|
|
784
|
+
excerpt: truncateExcerpt(body),
|
|
785
|
+
};
|
|
786
|
+
}).filter((item) => item !== null);
|
|
787
|
+
const descriptionExcerpt = issue.description
|
|
788
|
+
? sanitizeFeedbackText(issue.description, state, "bundle.issueContext.issue.description", MAX_DESCRIPTION_CHARS)
|
|
789
|
+
: null;
|
|
790
|
+
return {
|
|
791
|
+
issue: {
|
|
792
|
+
id: issue.id,
|
|
793
|
+
identifier: issue.identifier,
|
|
794
|
+
title: issue.title,
|
|
795
|
+
projectId: issue.projectId,
|
|
796
|
+
path: buildIssuePath(issue.identifier),
|
|
797
|
+
descriptionExcerpt: descriptionExcerpt ? truncateExcerpt(descriptionExcerpt, MAX_DESCRIPTION_CHARS) : null,
|
|
798
|
+
},
|
|
799
|
+
items: serializedItems,
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
async function buildAgentContext(db, companyId, authorAgentId, createdByRunId, state) {
|
|
803
|
+
if (!authorAgentId) {
|
|
804
|
+
state.notes.add("author_agent_missing");
|
|
805
|
+
return null;
|
|
806
|
+
}
|
|
807
|
+
const agent = await db
|
|
808
|
+
.select({
|
|
809
|
+
id: agents.id,
|
|
810
|
+
companyId: agents.companyId,
|
|
811
|
+
name: agents.name,
|
|
812
|
+
role: agents.role,
|
|
813
|
+
title: agents.title,
|
|
814
|
+
status: agents.status,
|
|
815
|
+
adapterType: agents.adapterType,
|
|
816
|
+
adapterConfig: agents.adapterConfig,
|
|
817
|
+
runtimeConfig: agents.runtimeConfig,
|
|
818
|
+
})
|
|
819
|
+
.from(agents)
|
|
820
|
+
.where(eq(agents.id, authorAgentId))
|
|
821
|
+
.then((rows) => rows[0] ?? null);
|
|
822
|
+
if (!agent || agent.companyId !== companyId) {
|
|
823
|
+
state.notes.add("author_agent_unavailable");
|
|
824
|
+
return null;
|
|
825
|
+
}
|
|
826
|
+
const adapterConfig = asRecord(agent.adapterConfig) ?? {};
|
|
827
|
+
const runtimeConfig = asRecord(agent.runtimeConfig) ?? {};
|
|
828
|
+
const desiredSkillRefs = uniqueNonEmpty(readzmeelSkillSyncPreference(adapterConfig).desiredSkills).slice(0, MAX_SKILLS);
|
|
829
|
+
const availableSkills = desiredSkillRefs.length === 0
|
|
830
|
+
? []
|
|
831
|
+
: await db
|
|
832
|
+
.select()
|
|
833
|
+
.from(companySkills)
|
|
834
|
+
.where(eq(companySkills.companyId, companyId));
|
|
835
|
+
const matchedSkills = availableSkills
|
|
836
|
+
.filter((skill) => desiredSkillRefs.some((reference) => matchesSkillReference(skill, reference)))
|
|
837
|
+
.slice(0, MAX_SKILLS);
|
|
838
|
+
const unresolvedSkillRefs = desiredSkillRefs.filter((reference) => !matchedSkills.some((skill) => matchesSkillReference(skill, reference)));
|
|
839
|
+
if (availableSkills.length > MAX_SKILLS || desiredSkillRefs.length > MAX_SKILLS) {
|
|
840
|
+
state.omittedFields.add("bundle.agentContext.skills");
|
|
841
|
+
}
|
|
842
|
+
const run = createdByRunId
|
|
843
|
+
? await db
|
|
844
|
+
.select({
|
|
845
|
+
id: heartbeatRuns.id,
|
|
846
|
+
companyId: heartbeatRuns.companyId,
|
|
847
|
+
agentId: heartbeatRuns.agentId,
|
|
848
|
+
invocationSource: heartbeatRuns.invocationSource,
|
|
849
|
+
status: heartbeatRuns.status,
|
|
850
|
+
startedAt: heartbeatRuns.startedAt,
|
|
851
|
+
finishedAt: heartbeatRuns.finishedAt,
|
|
852
|
+
usageJson: heartbeatRuns.usageJson,
|
|
853
|
+
sessionIdBefore: heartbeatRuns.sessionIdBefore,
|
|
854
|
+
sessionIdAfter: heartbeatRuns.sessionIdAfter,
|
|
855
|
+
externalRunId: heartbeatRuns.externalRunId,
|
|
856
|
+
})
|
|
857
|
+
.from(heartbeatRuns)
|
|
858
|
+
.where(eq(heartbeatRuns.id, createdByRunId))
|
|
859
|
+
.then((rows) => rows[0] ?? null)
|
|
860
|
+
: null;
|
|
861
|
+
const runCosts = run
|
|
862
|
+
? await db
|
|
863
|
+
.select({
|
|
864
|
+
provider: costEvents.provider,
|
|
865
|
+
biller: costEvents.biller,
|
|
866
|
+
billingType: costEvents.billingType,
|
|
867
|
+
model: costEvents.model,
|
|
868
|
+
inputTokens: costEvents.inputTokens,
|
|
869
|
+
cachedInputTokens: costEvents.cachedInputTokens,
|
|
870
|
+
outputTokens: costEvents.outputTokens,
|
|
871
|
+
costCents: costEvents.costCents,
|
|
872
|
+
})
|
|
873
|
+
.from(costEvents)
|
|
874
|
+
.where(and(eq(costEvents.companyId, companyId), eq(costEvents.heartbeatRunId, run.id)))
|
|
875
|
+
: [];
|
|
876
|
+
const usage = asRecord(run?.usageJson) ?? {};
|
|
877
|
+
const runtime = {
|
|
878
|
+
configuredModel: asString(adapterConfig.model),
|
|
879
|
+
configuredInstructionsBundleMode: asString(adapterConfig.instructionsBundleMode),
|
|
880
|
+
configuredInstructionsEntryFile: asString(adapterConfig.instructionsEntryFile),
|
|
881
|
+
configuredInstructionsFilePath: asString(adapterConfig.instructionsFilePath),
|
|
882
|
+
configuredInstructionsRootPath: asString(adapterConfig.instructionsRootPath),
|
|
883
|
+
heartbeatPolicy: sanitizeFeedbackValue(runtimeConfig.heartbeat ?? null, state, "bundle.agentContext.runtime.heartbeatPolicy", 400),
|
|
884
|
+
provenanceMode: run ? "source_run" : "vote_time_snapshot",
|
|
885
|
+
sourceRun: run
|
|
886
|
+
? sanitizeFeedbackValue({
|
|
887
|
+
id: run.id,
|
|
888
|
+
invocationSource: run.invocationSource,
|
|
889
|
+
status: run.status,
|
|
890
|
+
startedAt: run.startedAt?.toISOString() ?? null,
|
|
891
|
+
finishedAt: run.finishedAt?.toISOString() ?? null,
|
|
892
|
+
externalRunId: run.externalRunId ?? null,
|
|
893
|
+
sessionIdBefore: run.sessionIdBefore ?? null,
|
|
894
|
+
sessionIdAfter: run.sessionIdAfter ?? null,
|
|
895
|
+
usage: {
|
|
896
|
+
provider: asString(usage.provider),
|
|
897
|
+
biller: asString(usage.biller),
|
|
898
|
+
billingType: asString(usage.billingType),
|
|
899
|
+
model: asString(usage.model),
|
|
900
|
+
inputTokens: asNumber(usage.inputTokens) ?? asNumber(usage.rawInputTokens),
|
|
901
|
+
cachedInputTokens: asNumber(usage.cachedInputTokens) ?? asNumber(usage.rawCachedInputTokens),
|
|
902
|
+
outputTokens: asNumber(usage.outputTokens) ?? asNumber(usage.rawOutputTokens),
|
|
903
|
+
costUsd: asNumber(usage.costUsd),
|
|
904
|
+
usageSource: asString(usage.usageSource),
|
|
905
|
+
sessionReused: asBoolean(usage.sessionReused),
|
|
906
|
+
taskSessionReused: asBoolean(usage.taskSessionReused),
|
|
907
|
+
freshSession: asBoolean(usage.freshSession),
|
|
908
|
+
sessionRotated: asBoolean(usage.sessionRotated),
|
|
909
|
+
sessionRotationReason: asString(usage.sessionRotationReason),
|
|
910
|
+
},
|
|
911
|
+
}, state, "bundle.agentContext.runtime.sourceRun", 400)
|
|
912
|
+
: null,
|
|
913
|
+
costSummary: runCosts.length > 0
|
|
914
|
+
? {
|
|
915
|
+
providers: uniqueNonEmpty(runCosts.map((row) => row.provider)),
|
|
916
|
+
billers: uniqueNonEmpty(runCosts.map((row) => row.biller)),
|
|
917
|
+
billingTypes: uniqueNonEmpty(runCosts.map((row) => row.billingType)),
|
|
918
|
+
models: uniqueNonEmpty(runCosts.map((row) => row.model)),
|
|
919
|
+
inputTokens: runCosts.reduce((sum, row) => sum + row.inputTokens, 0),
|
|
920
|
+
cachedInputTokens: runCosts.reduce((sum, row) => sum + row.cachedInputTokens, 0),
|
|
921
|
+
outputTokens: runCosts.reduce((sum, row) => sum + row.outputTokens, 0),
|
|
922
|
+
costCents: runCosts.reduce((sum, row) => sum + row.costCents, 0),
|
|
923
|
+
}
|
|
924
|
+
: null,
|
|
925
|
+
};
|
|
926
|
+
const instructionsBundle = await instructionsSvc.getBundle({
|
|
927
|
+
id: agent.id,
|
|
928
|
+
companyId: agent.companyId,
|
|
929
|
+
name: agent.name,
|
|
930
|
+
adapterConfig: agent.adapterConfig,
|
|
931
|
+
}).catch(() => null);
|
|
932
|
+
let entryDigest = null;
|
|
933
|
+
let entryBody = null;
|
|
934
|
+
if (instructionsBundle) {
|
|
935
|
+
const readableEntryPath = instructionsBundle.files.find((file) => file.path === instructionsBundle.entryFile)?.path
|
|
936
|
+
?? instructionsBundle.files[0]?.path
|
|
937
|
+
?? null;
|
|
938
|
+
if (readableEntryPath) {
|
|
939
|
+
const entryFile = await instructionsSvc.readFile({
|
|
940
|
+
id: agent.id,
|
|
941
|
+
companyId: agent.companyId,
|
|
942
|
+
name: agent.name,
|
|
943
|
+
adapterConfig: agent.adapterConfig,
|
|
944
|
+
}, readableEntryPath).catch(() => null);
|
|
945
|
+
if (entryFile) {
|
|
946
|
+
entryDigest = sha256Digest(entryFile.content);
|
|
947
|
+
entryBody = sanitizeFeedbackText(entryFile.content, state, "bundle.agentContext.instructions.entryBody", MAX_INSTRUCTIONS_BODY_CHARS);
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
if (instructionsBundle.files.length > MAX_INSTRUCTION_FILES) {
|
|
951
|
+
state.omittedFields.add("bundle.agentContext.instructions.files");
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
return {
|
|
955
|
+
agent: {
|
|
956
|
+
id: agent.id,
|
|
957
|
+
name: agent.name,
|
|
958
|
+
role: agent.role,
|
|
959
|
+
title: agent.title,
|
|
960
|
+
status: agent.status,
|
|
961
|
+
adapterType: agent.adapterType,
|
|
962
|
+
},
|
|
963
|
+
runtime: sanitizeFeedbackValue(runtime, state, "bundle.agentContext.runtime", 400),
|
|
964
|
+
skills: {
|
|
965
|
+
desiredRefs: desiredSkillRefs,
|
|
966
|
+
unresolvedRefs: unresolvedSkillRefs,
|
|
967
|
+
items: matchedSkills.map((skill, index) => ({
|
|
968
|
+
key: skill.key,
|
|
969
|
+
slug: skill.slug,
|
|
970
|
+
name: skill.name,
|
|
971
|
+
sourceType: skill.sourceType,
|
|
972
|
+
sourceLocator: skill.sourceLocator == null
|
|
973
|
+
? null
|
|
974
|
+
: skill.sourceType === "github" || skill.sourceType === "skills_sh" || skill.sourceType === "url"
|
|
975
|
+
? skill.sourceLocator
|
|
976
|
+
: sanitizeFeedbackText(skill.sourceLocator, state, `bundle.agentContext.skills.items.${index}.sourceLocator`, MAX_PATH_CHARS),
|
|
977
|
+
sourceRef: skill.sourceRef,
|
|
978
|
+
trustLevel: skill.trustLevel,
|
|
979
|
+
compatibility: skill.compatibility,
|
|
980
|
+
fileInventory: skill.fileInventory,
|
|
981
|
+
})),
|
|
982
|
+
},
|
|
983
|
+
instructions: instructionsBundle
|
|
984
|
+
? {
|
|
985
|
+
mode: instructionsBundle.mode,
|
|
986
|
+
entryFile: instructionsBundle.entryFile,
|
|
987
|
+
resolvedEntryPath: instructionsBundle.resolvedEntryPath
|
|
988
|
+
? sanitizeFeedbackText(instructionsBundle.resolvedEntryPath, state, "bundle.agentContext.instructions.resolvedEntryPath", MAX_PATH_CHARS)
|
|
989
|
+
: null,
|
|
990
|
+
warnings: instructionsBundle.warnings.map((warning, index) => sanitizeFeedbackText(warning, state, `bundle.agentContext.instructions.warnings.${index}`, 400)),
|
|
991
|
+
legacyPromptTemplateActive: instructionsBundle.legacyPromptTemplateActive,
|
|
992
|
+
legacyBootstrapPromptTemplateActive: instructionsBundle.legacyBootstrapPromptTemplateActive,
|
|
993
|
+
fileCount: instructionsBundle.files.length,
|
|
994
|
+
files: instructionsBundle.files.slice(0, MAX_INSTRUCTION_FILES).map((file) => ({
|
|
995
|
+
path: file.path,
|
|
996
|
+
size: file.size,
|
|
997
|
+
language: file.language,
|
|
998
|
+
markdown: file.markdown,
|
|
999
|
+
isEntryFile: file.isEntryFile,
|
|
1000
|
+
virtual: file.virtual,
|
|
1001
|
+
})),
|
|
1002
|
+
entryDigest,
|
|
1003
|
+
entryBody,
|
|
1004
|
+
}
|
|
1005
|
+
: null,
|
|
1006
|
+
zmeel: {
|
|
1007
|
+
schemaVersion: FEEDBACK_SCHEMA_VERSION,
|
|
1008
|
+
bundleVersion: FEEDBACK_BUNDLE_VERSION,
|
|
1009
|
+
},
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
async function buildPayloadArtifacts(db, input) {
|
|
1013
|
+
const state = createFeedbackRedactionState();
|
|
1014
|
+
const primaryBody = sanitizeFeedbackText(input.target.body, state, "bundle.primaryContent.body", MAX_PRIMARY_CONTENT_CHARS);
|
|
1015
|
+
const primaryContent = {
|
|
1016
|
+
type: input.target.targetType,
|
|
1017
|
+
id: input.target.targetId,
|
|
1018
|
+
label: input.target.label,
|
|
1019
|
+
createdAt: input.target.createdAt.toISOString(),
|
|
1020
|
+
authorAgentId: input.target.authorAgentId,
|
|
1021
|
+
authorUserId: input.target.authorUserId,
|
|
1022
|
+
createdByRunId: input.target.createdByRunId,
|
|
1023
|
+
documentId: input.target.documentId,
|
|
1024
|
+
documentKey: input.target.documentKey,
|
|
1025
|
+
documentTitle: input.target.documentTitle,
|
|
1026
|
+
revisionNumber: input.target.revisionNumber,
|
|
1027
|
+
targetPath: input.target.targetPath,
|
|
1028
|
+
body: primaryBody,
|
|
1029
|
+
excerpt: truncateExcerpt(primaryBody),
|
|
1030
|
+
};
|
|
1031
|
+
const targetSummary = buildTargetSummary({
|
|
1032
|
+
label: input.target.label,
|
|
1033
|
+
excerpt: primaryContent.excerpt,
|
|
1034
|
+
authorAgentId: input.target.authorAgentId,
|
|
1035
|
+
authorUserId: input.target.authorUserId,
|
|
1036
|
+
createdAt: input.target.createdAt,
|
|
1037
|
+
documentKey: input.target.documentKey,
|
|
1038
|
+
documentTitle: input.target.documentTitle,
|
|
1039
|
+
revisionNumber: input.target.revisionNumber,
|
|
1040
|
+
});
|
|
1041
|
+
const basePayload = {
|
|
1042
|
+
schemaVersion: FEEDBACK_SCHEMA_VERSION,
|
|
1043
|
+
bundleVersion: FEEDBACK_BUNDLE_VERSION,
|
|
1044
|
+
sourceApp: "zmeel",
|
|
1045
|
+
capturedAt: input.now.toISOString(),
|
|
1046
|
+
consentVersion: input.consentVersion,
|
|
1047
|
+
vote: {
|
|
1048
|
+
id: input.voteId,
|
|
1049
|
+
value: input.vote,
|
|
1050
|
+
reason: input.reason,
|
|
1051
|
+
authorUserId: input.authorUserId,
|
|
1052
|
+
sharedWithLabs: input.sharedWithLabs,
|
|
1053
|
+
sharedAt: input.sharedWithLabs ? input.now.toISOString() : null,
|
|
1054
|
+
},
|
|
1055
|
+
target: input.target.payloadTarget,
|
|
1056
|
+
};
|
|
1057
|
+
if (!input.sharedWithLabs) {
|
|
1058
|
+
state.notes.add("local_only_trace_stores_metadata_only");
|
|
1059
|
+
const payloadSnapshot = {
|
|
1060
|
+
...basePayload,
|
|
1061
|
+
exportId: null,
|
|
1062
|
+
exportEligible: false,
|
|
1063
|
+
bundle: null,
|
|
1064
|
+
};
|
|
1065
|
+
const redactionSummary = finalizeFeedbackRedactionSummary(state);
|
|
1066
|
+
return {
|
|
1067
|
+
exportId: null,
|
|
1068
|
+
targetSummary,
|
|
1069
|
+
redactionSummary,
|
|
1070
|
+
payloadSnapshot: {
|
|
1071
|
+
...payloadSnapshot,
|
|
1072
|
+
redactionSummary,
|
|
1073
|
+
},
|
|
1074
|
+
payloadDigest: sha256Digest({
|
|
1075
|
+
...payloadSnapshot,
|
|
1076
|
+
redactionSummary,
|
|
1077
|
+
}),
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
1080
|
+
const exportId = buildExportId(input.voteId, input.now);
|
|
1081
|
+
const [issueContext, agentContext] = await Promise.all([
|
|
1082
|
+
buildIssueContext(db, input.issue, input.target, state),
|
|
1083
|
+
buildAgentContext(db, input.issue.companyId, input.target.authorAgentId, input.target.createdByRunId, state),
|
|
1084
|
+
]);
|
|
1085
|
+
const payloadSnapshot = {
|
|
1086
|
+
...basePayload,
|
|
1087
|
+
exportId,
|
|
1088
|
+
exportEligible: true,
|
|
1089
|
+
bundle: {
|
|
1090
|
+
primaryContent,
|
|
1091
|
+
issueContext,
|
|
1092
|
+
agentContext,
|
|
1093
|
+
},
|
|
1094
|
+
};
|
|
1095
|
+
const redactionSummary = finalizeFeedbackRedactionSummary(state);
|
|
1096
|
+
const payloadWithSummary = {
|
|
1097
|
+
...payloadSnapshot,
|
|
1098
|
+
redactionSummary,
|
|
1099
|
+
};
|
|
1100
|
+
return {
|
|
1101
|
+
exportId,
|
|
1102
|
+
targetSummary,
|
|
1103
|
+
redactionSummary,
|
|
1104
|
+
payloadSnapshot: payloadWithSummary,
|
|
1105
|
+
payloadDigest: sha256Digest(payloadWithSummary),
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
async function buildFeedbackTraceBundleFromRow(db, row) {
|
|
1109
|
+
const trace = mapTraceRow(row, true);
|
|
1110
|
+
const payloadSnapshot = asRecord(trace.payloadSnapshot);
|
|
1111
|
+
const notes = [];
|
|
1112
|
+
const state = createFeedbackRedactionState();
|
|
1113
|
+
const files = [];
|
|
1114
|
+
const sourceRunId = resolveSourceRunId(payloadSnapshot);
|
|
1115
|
+
let zmeelRun = null;
|
|
1116
|
+
let rawAdapterTrace = null;
|
|
1117
|
+
let normalizedAdapterTrace = null;
|
|
1118
|
+
let adapterType = null;
|
|
1119
|
+
if (!sourceRunId) {
|
|
1120
|
+
appendNote(notes, "source_run_missing");
|
|
1121
|
+
}
|
|
1122
|
+
else {
|
|
1123
|
+
const run = await db
|
|
1124
|
+
.select({
|
|
1125
|
+
id: heartbeatRuns.id,
|
|
1126
|
+
companyId: heartbeatRuns.companyId,
|
|
1127
|
+
agentId: heartbeatRuns.agentId,
|
|
1128
|
+
invocationSource: heartbeatRuns.invocationSource,
|
|
1129
|
+
status: heartbeatRuns.status,
|
|
1130
|
+
startedAt: heartbeatRuns.startedAt,
|
|
1131
|
+
finishedAt: heartbeatRuns.finishedAt,
|
|
1132
|
+
createdAt: heartbeatRuns.createdAt,
|
|
1133
|
+
updatedAt: heartbeatRuns.updatedAt,
|
|
1134
|
+
error: heartbeatRuns.error,
|
|
1135
|
+
errorCode: heartbeatRuns.errorCode,
|
|
1136
|
+
usageJson: heartbeatRuns.usageJson,
|
|
1137
|
+
resultJson: heartbeatRuns.resultJson,
|
|
1138
|
+
sessionIdBefore: heartbeatRuns.sessionIdBefore,
|
|
1139
|
+
sessionIdAfter: heartbeatRuns.sessionIdAfter,
|
|
1140
|
+
externalRunId: heartbeatRuns.externalRunId,
|
|
1141
|
+
contextSnapshot: heartbeatRuns.contextSnapshot,
|
|
1142
|
+
logStore: heartbeatRuns.logStore,
|
|
1143
|
+
logRef: heartbeatRuns.logRef,
|
|
1144
|
+
logBytes: heartbeatRuns.logBytes,
|
|
1145
|
+
logSha256: heartbeatRuns.logSha256,
|
|
1146
|
+
agentName: agents.name,
|
|
1147
|
+
agentRole: agents.role,
|
|
1148
|
+
agentTitle: agents.title,
|
|
1149
|
+
adapterType: agents.adapterType,
|
|
1150
|
+
})
|
|
1151
|
+
.from(heartbeatRuns)
|
|
1152
|
+
.innerJoin(agents, eq(heartbeatRuns.agentId, agents.id))
|
|
1153
|
+
.where(eq(heartbeatRuns.id, sourceRunId))
|
|
1154
|
+
.then((rows) => rows[0] ?? null);
|
|
1155
|
+
if (!run || run.companyId !== row.companyId) {
|
|
1156
|
+
appendNote(notes, "source_run_unavailable");
|
|
1157
|
+
}
|
|
1158
|
+
else {
|
|
1159
|
+
adapterType = run.adapterType;
|
|
1160
|
+
const events = await db
|
|
1161
|
+
.select()
|
|
1162
|
+
.from(heartbeatRunEvents)
|
|
1163
|
+
.where(eq(heartbeatRunEvents.runId, run.id))
|
|
1164
|
+
.orderBy(asc(heartbeatRunEvents.seq));
|
|
1165
|
+
const logText = await readFullRunLog(run);
|
|
1166
|
+
const logEntries = parseRunLogEntries(logText);
|
|
1167
|
+
const stdoutText = logEntries
|
|
1168
|
+
.filter((entry) => entry.stream === "stdout")
|
|
1169
|
+
.map((entry) => entry.chunk)
|
|
1170
|
+
.join("");
|
|
1171
|
+
zmeelRun = sanitizeFeedbackValue({
|
|
1172
|
+
id: run.id,
|
|
1173
|
+
companyId: run.companyId,
|
|
1174
|
+
agentId: run.agentId,
|
|
1175
|
+
agentName: run.agentName,
|
|
1176
|
+
agentRole: run.agentRole,
|
|
1177
|
+
agentTitle: run.agentTitle,
|
|
1178
|
+
adapterType: run.adapterType,
|
|
1179
|
+
invocationSource: run.invocationSource,
|
|
1180
|
+
status: run.status,
|
|
1181
|
+
startedAt: run.startedAt?.toISOString() ?? null,
|
|
1182
|
+
finishedAt: run.finishedAt?.toISOString() ?? null,
|
|
1183
|
+
createdAt: run.createdAt.toISOString(),
|
|
1184
|
+
updatedAt: run.updatedAt.toISOString(),
|
|
1185
|
+
error: run.error,
|
|
1186
|
+
errorCode: run.errorCode,
|
|
1187
|
+
usage: asRecord(run.usageJson),
|
|
1188
|
+
result: asRecord(run.resultJson),
|
|
1189
|
+
sessionIdBefore: run.sessionIdBefore,
|
|
1190
|
+
sessionIdAfter: run.sessionIdAfter,
|
|
1191
|
+
externalRunId: run.externalRunId,
|
|
1192
|
+
contextSnapshot: asRecord(run.contextSnapshot),
|
|
1193
|
+
logStore: run.logStore,
|
|
1194
|
+
logRef: run.logRef,
|
|
1195
|
+
logBytes: run.logBytes,
|
|
1196
|
+
logSha256: run.logSha256,
|
|
1197
|
+
eventCount: events.length,
|
|
1198
|
+
}, state, "bundle.zmeelRun", MAX_TRACE_FILE_CHARS);
|
|
1199
|
+
files.push(makeBundleFile({
|
|
1200
|
+
path: "zmeel/run.json",
|
|
1201
|
+
contentType: "application/json",
|
|
1202
|
+
source: "zmeel_run",
|
|
1203
|
+
contents: `${JSON.stringify(zmeelRun, null, 2)}\n`,
|
|
1204
|
+
}));
|
|
1205
|
+
const sanitizedEvents = sanitizeFeedbackValue(events, state, "bundle.zmeelRun.events", MAX_TRACE_FILE_CHARS);
|
|
1206
|
+
files.push(makeBundleFile({
|
|
1207
|
+
path: "zmeel/run-events.json",
|
|
1208
|
+
contentType: "application/json",
|
|
1209
|
+
source: "zmeel_run_events",
|
|
1210
|
+
contents: `${JSON.stringify(sanitizedEvents, null, 2)}\n`,
|
|
1211
|
+
}));
|
|
1212
|
+
if (logText) {
|
|
1213
|
+
files.push(makeBundleFile({
|
|
1214
|
+
path: "zmeel/run-log.ndjson",
|
|
1215
|
+
contentType: "application/x-ndjson",
|
|
1216
|
+
source: "zmeel_run_log",
|
|
1217
|
+
contents: `${sanitizeFeedbackText(logText, state, "bundle.zmeelRun.log", MAX_TRACE_FILE_CHARS)}\n`,
|
|
1218
|
+
}));
|
|
1219
|
+
}
|
|
1220
|
+
else {
|
|
1221
|
+
appendNote(notes, "run_log_missing");
|
|
1222
|
+
}
|
|
1223
|
+
if (run.adapterType === "codex_local") {
|
|
1224
|
+
const adapter = await buildCodexTraceFiles({
|
|
1225
|
+
companyId: row.companyId,
|
|
1226
|
+
sessionId: run.sessionIdAfter ?? run.sessionIdBefore,
|
|
1227
|
+
state,
|
|
1228
|
+
notes,
|
|
1229
|
+
});
|
|
1230
|
+
files.push(...adapter.files);
|
|
1231
|
+
rawAdapterTrace = adapter.raw;
|
|
1232
|
+
normalizedAdapterTrace = adapter.normalized;
|
|
1233
|
+
}
|
|
1234
|
+
else if (run.adapterType === "claude_local") {
|
|
1235
|
+
const adapter = await buildClaudeTraceFiles({
|
|
1236
|
+
sessionId: run.sessionIdAfter ?? run.sessionIdBefore,
|
|
1237
|
+
stdoutText,
|
|
1238
|
+
state,
|
|
1239
|
+
notes,
|
|
1240
|
+
});
|
|
1241
|
+
files.push(...adapter.files);
|
|
1242
|
+
rawAdapterTrace = adapter.raw;
|
|
1243
|
+
normalizedAdapterTrace = adapter.normalized;
|
|
1244
|
+
}
|
|
1245
|
+
else if (run.adapterType === "opencode_local") {
|
|
1246
|
+
const adapter = await buildOpenCodeTraceFiles({
|
|
1247
|
+
sessionId: run.sessionIdAfter ?? run.sessionIdBefore,
|
|
1248
|
+
stdoutText,
|
|
1249
|
+
state,
|
|
1250
|
+
notes,
|
|
1251
|
+
});
|
|
1252
|
+
files.push(...adapter.files);
|
|
1253
|
+
rawAdapterTrace = adapter.raw;
|
|
1254
|
+
normalizedAdapterTrace = adapter.normalized;
|
|
1255
|
+
}
|
|
1256
|
+
else {
|
|
1257
|
+
appendNote(notes, "adapter_specific_trace_not_supported");
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
const privacy = {
|
|
1262
|
+
...(asRecord(trace.redactionSummary) ?? {}),
|
|
1263
|
+
bundleRedactionSummary: finalizeFeedbackRedactionSummary(state),
|
|
1264
|
+
};
|
|
1265
|
+
const captureStatus = captureStatusFromFiles(files);
|
|
1266
|
+
if (captureStatus !== "full" && files.length > 0) {
|
|
1267
|
+
appendNote(notes, "adapter_trace_partial");
|
|
1268
|
+
}
|
|
1269
|
+
const envelope = sanitizeFeedbackValue({
|
|
1270
|
+
traceId: trace.id,
|
|
1271
|
+
exportId: trace.exportId,
|
|
1272
|
+
companyId: trace.companyId,
|
|
1273
|
+
feedbackVoteId: trace.feedbackVoteId,
|
|
1274
|
+
issueId: trace.issueId,
|
|
1275
|
+
issueIdentifier: trace.issueIdentifier,
|
|
1276
|
+
issueTitle: trace.issueTitle,
|
|
1277
|
+
projectId: trace.projectId,
|
|
1278
|
+
authorUserId: trace.authorUserId,
|
|
1279
|
+
targetType: trace.targetType,
|
|
1280
|
+
targetId: trace.targetId,
|
|
1281
|
+
vote: trace.vote,
|
|
1282
|
+
status: trace.status,
|
|
1283
|
+
destination: trace.destination,
|
|
1284
|
+
consentVersion: trace.consentVersion,
|
|
1285
|
+
schemaVersion: trace.schemaVersion,
|
|
1286
|
+
bundleVersion: trace.bundleVersion,
|
|
1287
|
+
payloadVersion: trace.payloadVersion,
|
|
1288
|
+
payloadDigest: trace.payloadDigest,
|
|
1289
|
+
createdAt: trace.createdAt.toISOString(),
|
|
1290
|
+
exportedAt: trace.exportedAt?.toISOString() ?? null,
|
|
1291
|
+
}, state, "bundle.envelope", MAX_TRACE_FILE_CHARS);
|
|
1292
|
+
const surface = sanitizeFeedbackValue({
|
|
1293
|
+
target: asRecord(payloadSnapshot?.target),
|
|
1294
|
+
summary: trace.targetSummary,
|
|
1295
|
+
}, state, "bundle.surface", MAX_TRACE_FILE_CHARS);
|
|
1296
|
+
const bundle = {
|
|
1297
|
+
traceId: trace.id,
|
|
1298
|
+
exportId: trace.exportId,
|
|
1299
|
+
companyId: trace.companyId,
|
|
1300
|
+
issueId: trace.issueId,
|
|
1301
|
+
issueIdentifier: trace.issueIdentifier,
|
|
1302
|
+
adapterType,
|
|
1303
|
+
captureStatus,
|
|
1304
|
+
notes,
|
|
1305
|
+
envelope,
|
|
1306
|
+
surface,
|
|
1307
|
+
zmeelRun,
|
|
1308
|
+
rawAdapterTrace,
|
|
1309
|
+
normalizedAdapterTrace,
|
|
1310
|
+
privacy,
|
|
1311
|
+
integrity: {
|
|
1312
|
+
payloadDigest: trace.payloadDigest,
|
|
1313
|
+
bundleDigest: sha256Digest({
|
|
1314
|
+
traceId: trace.id,
|
|
1315
|
+
files: files.map((file) => ({
|
|
1316
|
+
path: file.path,
|
|
1317
|
+
source: file.source,
|
|
1318
|
+
sha256: file.sha256,
|
|
1319
|
+
})),
|
|
1320
|
+
captureStatus,
|
|
1321
|
+
}),
|
|
1322
|
+
},
|
|
1323
|
+
files,
|
|
1324
|
+
};
|
|
1325
|
+
return bundle;
|
|
1326
|
+
}
|
|
1327
|
+
export function feedbackService(db, options = {}) {
|
|
1328
|
+
return {
|
|
1329
|
+
listIssueVotesForUser: async (issueId, authorUserId) => db
|
|
1330
|
+
.select()
|
|
1331
|
+
.from(feedbackVotes)
|
|
1332
|
+
.where(and(eq(feedbackVotes.issueId, issueId), eq(feedbackVotes.authorUserId, authorUserId))),
|
|
1333
|
+
listFeedbackTraces: async (input) => {
|
|
1334
|
+
const filters = [eq(feedbackExports.companyId, input.companyId)];
|
|
1335
|
+
if (input.issueId)
|
|
1336
|
+
filters.push(eq(feedbackExports.issueId, input.issueId));
|
|
1337
|
+
if (input.projectId)
|
|
1338
|
+
filters.push(eq(feedbackExports.projectId, input.projectId));
|
|
1339
|
+
if (input.targetType)
|
|
1340
|
+
filters.push(eq(feedbackExports.targetType, input.targetType));
|
|
1341
|
+
if (input.vote)
|
|
1342
|
+
filters.push(eq(feedbackExports.vote, input.vote));
|
|
1343
|
+
if (input.status)
|
|
1344
|
+
filters.push(eq(feedbackExports.status, input.status));
|
|
1345
|
+
if (input.sharedOnly)
|
|
1346
|
+
filters.push(ne(feedbackExports.status, "local_only"));
|
|
1347
|
+
if (input.from)
|
|
1348
|
+
filters.push(gte(feedbackExports.createdAt, input.from));
|
|
1349
|
+
if (input.to)
|
|
1350
|
+
filters.push(lte(feedbackExports.createdAt, input.to));
|
|
1351
|
+
const rows = await db
|
|
1352
|
+
.select({
|
|
1353
|
+
...feedbackExportColumns,
|
|
1354
|
+
issueIdentifier: issues.identifier,
|
|
1355
|
+
issueTitle: issues.title,
|
|
1356
|
+
})
|
|
1357
|
+
.from(feedbackExports)
|
|
1358
|
+
.innerJoin(issues, eq(feedbackExports.issueId, issues.id))
|
|
1359
|
+
.where(and(...filters))
|
|
1360
|
+
.orderBy(desc(feedbackExports.createdAt));
|
|
1361
|
+
return rows.map((row) => mapTraceRow(row, input.includePayload === true));
|
|
1362
|
+
},
|
|
1363
|
+
getFeedbackTraceById: async (traceId, includePayload = true) => {
|
|
1364
|
+
const row = await db
|
|
1365
|
+
.select({
|
|
1366
|
+
...feedbackExportColumns,
|
|
1367
|
+
issueIdentifier: issues.identifier,
|
|
1368
|
+
issueTitle: issues.title,
|
|
1369
|
+
})
|
|
1370
|
+
.from(feedbackExports)
|
|
1371
|
+
.innerJoin(issues, eq(feedbackExports.issueId, issues.id))
|
|
1372
|
+
.where(eq(feedbackExports.id, traceId))
|
|
1373
|
+
.then((rows) => rows[0] ?? null);
|
|
1374
|
+
return row ? mapTraceRow(row, includePayload) : null;
|
|
1375
|
+
},
|
|
1376
|
+
getFeedbackTraceBundle: async (traceId) => {
|
|
1377
|
+
const row = await db
|
|
1378
|
+
.select({
|
|
1379
|
+
...feedbackExportColumns,
|
|
1380
|
+
issueIdentifier: issues.identifier,
|
|
1381
|
+
issueTitle: issues.title,
|
|
1382
|
+
})
|
|
1383
|
+
.from(feedbackExports)
|
|
1384
|
+
.innerJoin(issues, eq(feedbackExports.issueId, issues.id))
|
|
1385
|
+
.where(eq(feedbackExports.id, traceId))
|
|
1386
|
+
.then((rows) => rows[0] ?? null);
|
|
1387
|
+
return row ? buildFeedbackTraceBundleFromRow(db, row) : null;
|
|
1388
|
+
},
|
|
1389
|
+
flushPendingFeedbackTraces: async (input) => {
|
|
1390
|
+
const shareClient = options.shareClient;
|
|
1391
|
+
if (!shareClient) {
|
|
1392
|
+
return {
|
|
1393
|
+
attempted: 0,
|
|
1394
|
+
sent: 0,
|
|
1395
|
+
failed: 0,
|
|
1396
|
+
};
|
|
1397
|
+
}
|
|
1398
|
+
const limit = Math.max(1, Math.min(input?.limit ?? 25, 200));
|
|
1399
|
+
const filters = [
|
|
1400
|
+
or(eq(feedbackExports.status, "pending"), eq(feedbackExports.status, "failed")),
|
|
1401
|
+
];
|
|
1402
|
+
if (input?.companyId) {
|
|
1403
|
+
filters.push(eq(feedbackExports.companyId, input.companyId));
|
|
1404
|
+
}
|
|
1405
|
+
const rows = await db
|
|
1406
|
+
.select({
|
|
1407
|
+
...feedbackExportColumns,
|
|
1408
|
+
issueIdentifier: issues.identifier,
|
|
1409
|
+
issueTitle: issues.title,
|
|
1410
|
+
})
|
|
1411
|
+
.from(feedbackExports)
|
|
1412
|
+
.innerJoin(issues, eq(feedbackExports.issueId, issues.id))
|
|
1413
|
+
.where(and(...filters))
|
|
1414
|
+
.orderBy(asc(feedbackExports.createdAt), asc(feedbackExports.id))
|
|
1415
|
+
.limit(limit);
|
|
1416
|
+
let attempted = 0;
|
|
1417
|
+
let sent = 0;
|
|
1418
|
+
let failed = 0;
|
|
1419
|
+
for (const row of rows) {
|
|
1420
|
+
const attemptAt = input?.now ?? new Date();
|
|
1421
|
+
attempted += 1;
|
|
1422
|
+
try {
|
|
1423
|
+
const bundle = await buildFeedbackTraceBundleFromRow(db, row);
|
|
1424
|
+
await shareClient.uploadTraceBundle(bundle);
|
|
1425
|
+
await db
|
|
1426
|
+
.update(feedbackExports)
|
|
1427
|
+
.set({
|
|
1428
|
+
status: "sent",
|
|
1429
|
+
attemptCount: row.attemptCount + 1,
|
|
1430
|
+
lastAttemptedAt: attemptAt,
|
|
1431
|
+
exportedAt: attemptAt,
|
|
1432
|
+
failureReason: null,
|
|
1433
|
+
updatedAt: attemptAt,
|
|
1434
|
+
})
|
|
1435
|
+
.where(eq(feedbackExports.id, row.id));
|
|
1436
|
+
sent += 1;
|
|
1437
|
+
}
|
|
1438
|
+
catch (error) {
|
|
1439
|
+
await db
|
|
1440
|
+
.update(feedbackExports)
|
|
1441
|
+
.set({
|
|
1442
|
+
status: "failed",
|
|
1443
|
+
attemptCount: row.attemptCount + 1,
|
|
1444
|
+
lastAttemptedAt: attemptAt,
|
|
1445
|
+
failureReason: truncateFailureReason(error),
|
|
1446
|
+
updatedAt: attemptAt,
|
|
1447
|
+
})
|
|
1448
|
+
.where(eq(feedbackExports.id, row.id));
|
|
1449
|
+
failed += 1;
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
return {
|
|
1453
|
+
attempted,
|
|
1454
|
+
sent,
|
|
1455
|
+
failed,
|
|
1456
|
+
};
|
|
1457
|
+
},
|
|
1458
|
+
saveIssueVote: async (input) => db.transaction(async (tx) => {
|
|
1459
|
+
const issue = await tx
|
|
1460
|
+
.select({
|
|
1461
|
+
id: issues.id,
|
|
1462
|
+
companyId: issues.companyId,
|
|
1463
|
+
projectId: issues.projectId,
|
|
1464
|
+
identifier: issues.identifier,
|
|
1465
|
+
title: issues.title,
|
|
1466
|
+
description: issues.description,
|
|
1467
|
+
})
|
|
1468
|
+
.from(issues)
|
|
1469
|
+
.where(eq(issues.id, input.issueId))
|
|
1470
|
+
.then((rows) => rows[0] ?? null);
|
|
1471
|
+
if (!issue)
|
|
1472
|
+
throw notFound("Issue not found");
|
|
1473
|
+
const target = await resolveFeedbackTarget(tx, issue, input.targetType, input.targetId);
|
|
1474
|
+
const existingCompany = await tx
|
|
1475
|
+
.select({
|
|
1476
|
+
feedbackDataSharingEnabled: companies.feedbackDataSharingEnabled,
|
|
1477
|
+
feedbackDataSharingTermsVersion: companies.feedbackDataSharingTermsVersion,
|
|
1478
|
+
})
|
|
1479
|
+
.from(companies)
|
|
1480
|
+
.where(eq(companies.id, issue.companyId))
|
|
1481
|
+
.then((rows) => rows[0] ?? null);
|
|
1482
|
+
if (!existingCompany)
|
|
1483
|
+
throw notFound("Company not found");
|
|
1484
|
+
const now = new Date();
|
|
1485
|
+
const normalizedReason = normalizeReason(input.vote, input.reason);
|
|
1486
|
+
const sharedWithLabs = input.allowSharing === true;
|
|
1487
|
+
let consentEnabledNow = false;
|
|
1488
|
+
let consentVersion = existingCompany.feedbackDataSharingTermsVersion ?? null;
|
|
1489
|
+
let persistedSharingPreference = null;
|
|
1490
|
+
if (sharedWithLabs && !existingCompany.feedbackDataSharingEnabled) {
|
|
1491
|
+
consentEnabledNow = true;
|
|
1492
|
+
consentVersion = DEFAULT_FEEDBACK_DATA_SHARING_TERMS_VERSION;
|
|
1493
|
+
await tx
|
|
1494
|
+
.update(companies)
|
|
1495
|
+
.set({
|
|
1496
|
+
feedbackDataSharingEnabled: true,
|
|
1497
|
+
feedbackDataSharingConsentAt: now,
|
|
1498
|
+
feedbackDataSharingConsentByUserId: input.authorUserId,
|
|
1499
|
+
feedbackDataSharingTermsVersion: consentVersion,
|
|
1500
|
+
updatedAt: now,
|
|
1501
|
+
})
|
|
1502
|
+
.where(eq(companies.id, issue.companyId));
|
|
1503
|
+
}
|
|
1504
|
+
const existingInstanceSettings = await tx
|
|
1505
|
+
.select({
|
|
1506
|
+
id: instanceSettings.id,
|
|
1507
|
+
general: instanceSettings.general,
|
|
1508
|
+
})
|
|
1509
|
+
.from(instanceSettings)
|
|
1510
|
+
.where(eq(instanceSettings.singletonKey, DEFAULT_INSTANCE_SETTINGS_SINGLETON_KEY))
|
|
1511
|
+
.then((rows) => rows[0] ?? null);
|
|
1512
|
+
const currentInstanceSettings = existingInstanceSettings ??
|
|
1513
|
+
(await tx
|
|
1514
|
+
.insert(instanceSettings)
|
|
1515
|
+
.values({
|
|
1516
|
+
singletonKey: DEFAULT_INSTANCE_SETTINGS_SINGLETON_KEY,
|
|
1517
|
+
general: {},
|
|
1518
|
+
experimental: {},
|
|
1519
|
+
createdAt: now,
|
|
1520
|
+
updatedAt: now,
|
|
1521
|
+
})
|
|
1522
|
+
.onConflictDoUpdate({
|
|
1523
|
+
target: [instanceSettings.singletonKey],
|
|
1524
|
+
set: {
|
|
1525
|
+
updatedAt: now,
|
|
1526
|
+
},
|
|
1527
|
+
})
|
|
1528
|
+
.returning({
|
|
1529
|
+
id: instanceSettings.id,
|
|
1530
|
+
general: instanceSettings.general,
|
|
1531
|
+
})
|
|
1532
|
+
.then((rows) => rows[0] ?? null));
|
|
1533
|
+
const currentGeneral = normalizeInstanceGeneralSettings(currentInstanceSettings?.general);
|
|
1534
|
+
if (currentInstanceSettings && currentGeneral.feedbackDataSharingPreference === "prompt") {
|
|
1535
|
+
const nextSharingPreference = sharedWithLabs ? "allowed" : "not_allowed";
|
|
1536
|
+
const currentGeneralRaw = asRecord(currentInstanceSettings.general) ?? {};
|
|
1537
|
+
await tx
|
|
1538
|
+
.update(instanceSettings)
|
|
1539
|
+
.set({
|
|
1540
|
+
general: {
|
|
1541
|
+
...currentGeneralRaw,
|
|
1542
|
+
censorUsernameInLogs: currentGeneral.censorUsernameInLogs,
|
|
1543
|
+
feedbackDataSharingPreference: nextSharingPreference,
|
|
1544
|
+
},
|
|
1545
|
+
updatedAt: now,
|
|
1546
|
+
})
|
|
1547
|
+
.where(eq(instanceSettings.id, currentInstanceSettings.id));
|
|
1548
|
+
persistedSharingPreference = nextSharingPreference;
|
|
1549
|
+
}
|
|
1550
|
+
const [savedVote] = await tx
|
|
1551
|
+
.insert(feedbackVotes)
|
|
1552
|
+
.values({
|
|
1553
|
+
companyId: issue.companyId,
|
|
1554
|
+
issueId: issue.id,
|
|
1555
|
+
targetType: input.targetType,
|
|
1556
|
+
targetId: input.targetId,
|
|
1557
|
+
authorUserId: input.authorUserId,
|
|
1558
|
+
vote: input.vote,
|
|
1559
|
+
reason: normalizedReason,
|
|
1560
|
+
sharedWithLabs,
|
|
1561
|
+
sharedAt: sharedWithLabs ? now : null,
|
|
1562
|
+
consentVersion: sharedWithLabs ? (consentVersion ?? DEFAULT_FEEDBACK_DATA_SHARING_TERMS_VERSION) : null,
|
|
1563
|
+
redactionSummary: null,
|
|
1564
|
+
updatedAt: now,
|
|
1565
|
+
})
|
|
1566
|
+
.onConflictDoUpdate({
|
|
1567
|
+
target: [
|
|
1568
|
+
feedbackVotes.companyId,
|
|
1569
|
+
feedbackVotes.targetType,
|
|
1570
|
+
feedbackVotes.targetId,
|
|
1571
|
+
feedbackVotes.authorUserId,
|
|
1572
|
+
],
|
|
1573
|
+
set: {
|
|
1574
|
+
vote: input.vote,
|
|
1575
|
+
reason: normalizedReason,
|
|
1576
|
+
sharedWithLabs,
|
|
1577
|
+
sharedAt: sharedWithLabs ? now : null,
|
|
1578
|
+
consentVersion: sharedWithLabs ? (consentVersion ?? DEFAULT_FEEDBACK_DATA_SHARING_TERMS_VERSION) : null,
|
|
1579
|
+
redactionSummary: null,
|
|
1580
|
+
updatedAt: now,
|
|
1581
|
+
},
|
|
1582
|
+
})
|
|
1583
|
+
.returning();
|
|
1584
|
+
const artifacts = await buildPayloadArtifacts(tx, {
|
|
1585
|
+
issue,
|
|
1586
|
+
target,
|
|
1587
|
+
voteId: savedVote.id,
|
|
1588
|
+
vote: input.vote,
|
|
1589
|
+
reason: normalizedReason,
|
|
1590
|
+
authorUserId: input.authorUserId,
|
|
1591
|
+
consentVersion: sharedWithLabs ? (consentVersion ?? DEFAULT_FEEDBACK_DATA_SHARING_TERMS_VERSION) : null,
|
|
1592
|
+
sharedWithLabs,
|
|
1593
|
+
now,
|
|
1594
|
+
});
|
|
1595
|
+
await tx
|
|
1596
|
+
.update(feedbackVotes)
|
|
1597
|
+
.set({
|
|
1598
|
+
redactionSummary: artifacts.redactionSummary,
|
|
1599
|
+
updatedAt: now,
|
|
1600
|
+
})
|
|
1601
|
+
.where(eq(feedbackVotes.id, savedVote.id));
|
|
1602
|
+
await tx
|
|
1603
|
+
.insert(feedbackExports)
|
|
1604
|
+
.values({
|
|
1605
|
+
companyId: issue.companyId,
|
|
1606
|
+
feedbackVoteId: savedVote.id,
|
|
1607
|
+
issueId: issue.id,
|
|
1608
|
+
projectId: issue.projectId,
|
|
1609
|
+
authorUserId: input.authorUserId,
|
|
1610
|
+
targetType: input.targetType,
|
|
1611
|
+
targetId: input.targetId,
|
|
1612
|
+
vote: input.vote,
|
|
1613
|
+
status: sharedWithLabs ? "pending" : "local_only",
|
|
1614
|
+
destination: sharedWithLabs ? FEEDBACK_DESTINATION : null,
|
|
1615
|
+
exportId: artifacts.exportId,
|
|
1616
|
+
consentVersion: sharedWithLabs ? (consentVersion ?? DEFAULT_FEEDBACK_DATA_SHARING_TERMS_VERSION) : null,
|
|
1617
|
+
schemaVersion: FEEDBACK_SCHEMA_VERSION,
|
|
1618
|
+
bundleVersion: FEEDBACK_BUNDLE_VERSION,
|
|
1619
|
+
payloadVersion: FEEDBACK_PAYLOAD_VERSION,
|
|
1620
|
+
payloadDigest: artifacts.payloadDigest,
|
|
1621
|
+
payloadSnapshot: artifacts.payloadSnapshot,
|
|
1622
|
+
targetSummary: artifacts.targetSummary,
|
|
1623
|
+
redactionSummary: artifacts.redactionSummary,
|
|
1624
|
+
updatedAt: now,
|
|
1625
|
+
})
|
|
1626
|
+
.onConflictDoUpdate({
|
|
1627
|
+
target: [feedbackExports.feedbackVoteId],
|
|
1628
|
+
set: {
|
|
1629
|
+
issueId: issue.id,
|
|
1630
|
+
projectId: issue.projectId,
|
|
1631
|
+
authorUserId: input.authorUserId,
|
|
1632
|
+
targetType: input.targetType,
|
|
1633
|
+
targetId: input.targetId,
|
|
1634
|
+
vote: input.vote,
|
|
1635
|
+
status: sharedWithLabs ? "pending" : "local_only",
|
|
1636
|
+
destination: sharedWithLabs ? FEEDBACK_DESTINATION : null,
|
|
1637
|
+
exportId: artifacts.exportId,
|
|
1638
|
+
consentVersion: sharedWithLabs ? (consentVersion ?? DEFAULT_FEEDBACK_DATA_SHARING_TERMS_VERSION) : null,
|
|
1639
|
+
schemaVersion: FEEDBACK_SCHEMA_VERSION,
|
|
1640
|
+
bundleVersion: FEEDBACK_BUNDLE_VERSION,
|
|
1641
|
+
payloadVersion: FEEDBACK_PAYLOAD_VERSION,
|
|
1642
|
+
payloadDigest: artifacts.payloadDigest,
|
|
1643
|
+
payloadSnapshot: artifacts.payloadSnapshot,
|
|
1644
|
+
targetSummary: artifacts.targetSummary,
|
|
1645
|
+
redactionSummary: artifacts.redactionSummary,
|
|
1646
|
+
failureReason: null,
|
|
1647
|
+
updatedAt: now,
|
|
1648
|
+
},
|
|
1649
|
+
});
|
|
1650
|
+
return {
|
|
1651
|
+
vote: {
|
|
1652
|
+
...savedVote,
|
|
1653
|
+
redactionSummary: artifacts.redactionSummary,
|
|
1654
|
+
},
|
|
1655
|
+
consentEnabledNow,
|
|
1656
|
+
persistedSharingPreference,
|
|
1657
|
+
sharingEnabled: sharedWithLabs,
|
|
1658
|
+
};
|
|
1659
|
+
}),
|
|
1660
|
+
};
|
|
1661
|
+
}
|
|
1662
|
+
//# sourceMappingURL=feedback.js.map
|