@askdkc/kiokuko 0.1.17 → 0.1.20
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/README.ja.md +91 -112
- package/README.ko.md +90 -102
- package/README.md +103 -262
- package/README.zh-CN.md +88 -102
- package/dist/agent-file/atomic-write.d.ts +90 -3
- package/dist/agent-file/atomic-write.d.ts.map +1 -1
- package/dist/agent-file/atomic-write.js +990 -14
- package/dist/agent-file/atomic-write.js.map +1 -1
- package/dist/agent-file/managed-block.d.ts +12 -1
- package/dist/agent-file/managed-block.d.ts.map +1 -1
- package/dist/agent-file/managed-block.js +49 -4
- package/dist/agent-file/managed-block.js.map +1 -1
- package/dist/agent-file/render.d.ts +1 -1
- package/dist/agent-file/render.d.ts.map +1 -1
- package/dist/agent-file/render.js +10 -7
- package/dist/agent-file/render.js.map +1 -1
- package/dist/akinator/agent-task.d.ts +11 -22
- package/dist/akinator/agent-task.d.ts.map +1 -1
- package/dist/akinator/agent-task.js +454 -99
- package/dist/akinator/agent-task.js.map +1 -1
- package/dist/akinator/capabilities.d.ts +18 -6
- package/dist/akinator/capabilities.d.ts.map +1 -1
- package/dist/akinator/capabilities.js +72 -35
- package/dist/akinator/capabilities.js.map +1 -1
- package/dist/akinator/capability-binding.d.ts +11 -0
- package/dist/akinator/capability-binding.d.ts.map +1 -0
- package/dist/akinator/capability-binding.js +56 -0
- package/dist/akinator/capability-binding.js.map +1 -0
- package/dist/akinator/domain.js +2 -2
- package/dist/akinator/domain.js.map +1 -1
- package/dist/akinator/knowledge-path.d.ts.map +1 -1
- package/dist/akinator/knowledge-path.js +409 -39
- package/dist/akinator/knowledge-path.js.map +1 -1
- package/dist/akinator/orchestrator.d.ts +3 -4
- package/dist/akinator/orchestrator.d.ts.map +1 -1
- package/dist/akinator/orchestrator.js +1 -4
- package/dist/akinator/orchestrator.js.map +1 -1
- package/dist/akinator/service.d.ts +0 -4
- package/dist/akinator/service.d.ts.map +1 -1
- package/dist/akinator/service.js +19 -35
- package/dist/akinator/service.js.map +1 -1
- package/dist/akinator/skill-discovery-attempt.d.ts +20 -0
- package/dist/akinator/skill-discovery-attempt.d.ts.map +1 -0
- package/dist/akinator/skill-discovery-attempt.js +390 -0
- package/dist/akinator/skill-discovery-attempt.js.map +1 -0
- package/dist/akinator/store.d.ts.map +1 -1
- package/dist/akinator/store.js +107 -52
- package/dist/akinator/store.js.map +1 -1
- package/dist/akinator/types.d.ts +0 -12
- package/dist/akinator/types.d.ts.map +1 -1
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +560 -150
- package/dist/cli.js.map +1 -1
- package/dist/client/server-client.d.ts +5 -3
- package/dist/client/server-client.d.ts.map +1 -1
- package/dist/client/server-client.js +486 -181
- package/dist/client/server-client.js.map +1 -1
- package/dist/commands/agent.d.ts +2 -0
- package/dist/commands/agent.d.ts.map +1 -1
- package/dist/commands/agent.js +861 -86
- package/dist/commands/agent.js.map +1 -1
- package/dist/commands/backup.d.ts +2 -1
- package/dist/commands/backup.d.ts.map +1 -1
- package/dist/commands/backup.js +71 -8
- package/dist/commands/backup.js.map +1 -1
- package/dist/commands/doctor.d.ts +5 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +70 -26
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/export.d.ts +0 -4
- package/dist/commands/export.d.ts.map +1 -1
- package/dist/commands/export.js +191 -32
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/import.d.ts +10 -1
- package/dist/commands/import.d.ts.map +1 -1
- package/dist/commands/import.js +592 -113
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/init.d.ts +19 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +569 -22
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/purge.d.ts.map +1 -1
- package/dist/commands/purge.js +3 -0
- package/dist/commands/purge.js.map +1 -1
- package/dist/commands/setup.d.ts +37 -8
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +448 -86
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/skills.d.ts +9 -0
- package/dist/commands/skills.d.ts.map +1 -0
- package/dist/commands/skills.js +317 -0
- package/dist/commands/skills.js.map +1 -0
- package/dist/commands/use.d.ts +10 -2
- package/dist/commands/use.d.ts.map +1 -1
- package/dist/commands/use.js +851 -73
- package/dist/commands/use.js.map +1 -1
- package/dist/config/paths.d.ts +11 -1
- package/dist/config/paths.d.ts.map +1 -1
- package/dist/config/paths.js +64 -29
- package/dist/config/paths.js.map +1 -1
- package/dist/config/project-config.d.ts +1 -0
- package/dist/config/project-config.d.ts.map +1 -1
- package/dist/config/project-config.js +70 -32
- package/dist/config/project-config.js.map +1 -1
- package/dist/context/broker.d.ts +28 -14
- package/dist/context/broker.d.ts.map +1 -1
- package/dist/context/broker.js +604 -145
- package/dist/context/broker.js.map +1 -1
- package/dist/context/delivery.d.ts +6 -21
- package/dist/context/delivery.d.ts.map +1 -1
- package/dist/context/delivery.js +196 -147
- package/dist/context/delivery.js.map +1 -1
- package/dist/context/feedback.d.ts +11 -12
- package/dist/context/feedback.d.ts.map +1 -1
- package/dist/context/feedback.js +229 -261
- package/dist/context/feedback.js.map +1 -1
- package/dist/context/ranking.d.ts +1 -12
- package/dist/context/ranking.d.ts.map +1 -1
- package/dist/context/ranking.js +13 -4
- package/dist/context/ranking.js.map +1 -1
- package/dist/context/recommendations.d.ts +0 -5
- package/dist/context/recommendations.d.ts.map +1 -1
- package/dist/context/recommendations.js +0 -1
- package/dist/context/recommendations.js.map +1 -1
- package/dist/context/run-state.d.ts +26 -0
- package/dist/context/run-state.d.ts.map +1 -0
- package/dist/context/run-state.js +399 -0
- package/dist/context/run-state.js.map +1 -0
- package/dist/context/scoped-broker.d.ts +17 -5
- package/dist/context/scoped-broker.d.ts.map +1 -1
- package/dist/context/scoped-broker.js +512 -106
- package/dist/context/scoped-broker.js.map +1 -1
- package/dist/context/selection-state.d.ts +19 -0
- package/dist/context/selection-state.d.ts.map +1 -0
- package/dist/context/selection-state.js +250 -0
- package/dist/context/selection-state.js.map +1 -0
- package/dist/db/adapter.d.ts +5 -3
- package/dist/db/adapter.d.ts.map +1 -1
- package/dist/db/adapter.js +7 -3
- package/dist/db/adapter.js.map +1 -1
- package/dist/db/capabilities.d.ts.map +1 -1
- package/dist/db/capabilities.js +34 -16
- package/dist/db/capabilities.js.map +1 -1
- package/dist/db/connection.d.ts +8 -0
- package/dist/db/connection.d.ts.map +1 -1
- package/dist/db/connection.js +55 -26
- package/dist/db/connection.js.map +1 -1
- package/dist/db/migrate.d.ts +28 -7
- package/dist/db/migrate.d.ts.map +1 -1
- package/dist/db/migrate.js +106 -78
- package/dist/db/migrate.js.map +1 -1
- package/dist/db/sqlite-retry.d.ts +11 -0
- package/dist/db/sqlite-retry.d.ts.map +1 -0
- package/dist/db/sqlite-retry.js +66 -0
- package/dist/db/sqlite-retry.js.map +1 -0
- package/dist/db/transaction.d.ts +13 -0
- package/dist/db/transaction.d.ts.map +1 -1
- package/dist/db/transaction.js +53 -24
- package/dist/db/transaction.js.map +1 -1
- package/dist/db/upgrade-backup.d.ts +58 -2
- package/dist/db/upgrade-backup.d.ts.map +1 -1
- package/dist/db/upgrade-backup.js +758 -28
- package/dist/db/upgrade-backup.js.map +1 -1
- package/dist/errors.d.ts +4 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +29 -1
- package/dist/errors.js.map +1 -1
- package/dist/gateway/agent-service.d.ts +4 -1
- package/dist/gateway/agent-service.d.ts.map +1 -1
- package/dist/gateway/agent-service.js +71 -58
- package/dist/gateway/agent-service.js.map +1 -1
- package/dist/gateway/checkpoint-service.d.ts +1 -0
- package/dist/gateway/checkpoint-service.d.ts.map +1 -1
- package/dist/gateway/checkpoint-service.js +47 -24
- package/dist/gateway/checkpoint-service.js.map +1 -1
- package/dist/ledger/archive.d.ts +1 -4
- package/dist/ledger/archive.d.ts.map +1 -1
- package/dist/ledger/archive.js +77 -39
- package/dist/ledger/archive.js.map +1 -1
- package/dist/ledger/maintenance.d.ts +0 -11
- package/dist/ledger/maintenance.d.ts.map +1 -1
- package/dist/ledger/maintenance.js +24 -40
- package/dist/ledger/maintenance.js.map +1 -1
- package/dist/ledger/projection.d.ts +0 -1
- package/dist/ledger/projection.d.ts.map +1 -1
- package/dist/ledger/projection.js.map +1 -1
- package/dist/ledger/promotion.d.ts +0 -9
- package/dist/ledger/promotion.d.ts.map +1 -1
- package/dist/ledger/promotion.js.map +1 -1
- package/dist/ledger/query.d.ts +1 -15
- package/dist/ledger/query.d.ts.map +1 -1
- package/dist/ledger/query.js.map +1 -1
- package/dist/ledger/store.d.ts +0 -1
- package/dist/ledger/store.d.ts.map +1 -1
- package/dist/ledger/store.js +11 -8
- package/dist/ledger/store.js.map +1 -1
- package/dist/ledger/types.d.ts +0 -4
- package/dist/ledger/types.d.ts.map +1 -1
- package/dist/ledger/types.js.map +1 -1
- package/dist/ledger/validate.d.ts.map +1 -1
- package/dist/ledger/validate.js +0 -5
- package/dist/ledger/validate.js.map +1 -1
- package/dist/mcp/server.d.ts +4 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +105 -54
- package/dist/mcp/server.js.map +1 -1
- package/dist/memory/audit.d.ts +0 -1
- package/dist/memory/audit.d.ts.map +1 -1
- package/dist/memory/audit.js +0 -1
- package/dist/memory/audit.js.map +1 -1
- package/dist/memory/curator.d.ts.map +1 -1
- package/dist/memory/curator.js +172 -96
- package/dist/memory/curator.js.map +1 -1
- package/dist/memory/entries.d.ts +12 -2
- package/dist/memory/entries.d.ts.map +1 -1
- package/dist/memory/entries.js +199 -115
- package/dist/memory/entries.js.map +1 -1
- package/dist/memory/federated-retrieval.d.ts +12 -1
- package/dist/memory/federated-retrieval.d.ts.map +1 -1
- package/dist/memory/federated-retrieval.js +183 -70
- package/dist/memory/federated-retrieval.js.map +1 -1
- package/dist/memory/hybrid-retrieval.d.ts +5 -11
- package/dist/memory/hybrid-retrieval.d.ts.map +1 -1
- package/dist/memory/hybrid-retrieval.js +78 -58
- package/dist/memory/hybrid-retrieval.js.map +1 -1
- package/dist/memory/lifecycle.d.ts.map +1 -1
- package/dist/memory/lifecycle.js +17 -13
- package/dist/memory/lifecycle.js.map +1 -1
- package/dist/memory/rebuild-search.d.ts +5 -0
- package/dist/memory/rebuild-search.d.ts.map +1 -1
- package/dist/memory/rebuild-search.js +101 -76
- package/dist/memory/rebuild-search.js.map +1 -1
- package/dist/memory/retrieval-query.d.ts +0 -5
- package/dist/memory/retrieval-query.d.ts.map +1 -1
- package/dist/memory/retrieval-query.js +0 -5
- package/dist/memory/retrieval-query.js.map +1 -1
- package/dist/memory/retrieval.d.ts.map +1 -1
- package/dist/memory/retrieval.js +25 -131
- package/dist/memory/retrieval.js.map +1 -1
- package/dist/memory/revisions.d.ts +76 -1
- package/dist/memory/revisions.d.ts.map +1 -1
- package/dist/memory/revisions.js +540 -36
- package/dist/memory/revisions.js.map +1 -1
- package/dist/memory/scoped-memory.d.ts +16 -1
- package/dist/memory/scoped-memory.d.ts.map +1 -1
- package/dist/memory/scoped-memory.js +240 -107
- package/dist/memory/scoped-memory.js.map +1 -1
- package/dist/memory/secrets.d.ts +2 -0
- package/dist/memory/secrets.d.ts.map +1 -1
- package/dist/memory/secrets.js +36 -0
- package/dist/memory/secrets.js.map +1 -1
- package/dist/memory/structured-memory.d.ts +3 -2
- package/dist/memory/structured-memory.d.ts.map +1 -1
- package/dist/memory/structured-memory.js +54 -22
- package/dist/memory/structured-memory.js.map +1 -1
- package/dist/memory/workspaces.d.ts +9 -0
- package/dist/memory/workspaces.d.ts.map +1 -1
- package/dist/memory/workspaces.js +67 -0
- package/dist/memory/workspaces.js.map +1 -1
- package/dist/package-version.d.ts +2 -0
- package/dist/package-version.d.ts.map +1 -0
- package/dist/package-version.js +7 -0
- package/dist/package-version.js.map +1 -0
- package/dist/repository/binding.d.ts +5 -0
- package/dist/repository/binding.d.ts.map +1 -1
- package/dist/repository/binding.js +117 -17
- package/dist/repository/binding.js.map +1 -1
- package/dist/repository/framework-version.d.ts +8 -0
- package/dist/repository/framework-version.d.ts.map +1 -0
- package/dist/repository/framework-version.js +29 -0
- package/dist/repository/framework-version.js.map +1 -0
- package/dist/repository/identity-value.d.ts +4 -0
- package/dist/repository/identity-value.d.ts.map +1 -0
- package/dist/repository/identity-value.js +24 -0
- package/dist/repository/identity-value.js.map +1 -0
- package/dist/repository/identity.d.ts.map +1 -1
- package/dist/repository/identity.js +2 -0
- package/dist/repository/identity.js.map +1 -1
- package/dist/repository/project-fingerprint.d.ts +14 -2
- package/dist/repository/project-fingerprint.d.ts.map +1 -1
- package/dist/repository/project-fingerprint.js +312 -33
- package/dist/repository/project-fingerprint.js.map +1 -1
- package/dist/repository/remote-url.d.ts +0 -1
- package/dist/repository/remote-url.d.ts.map +1 -1
- package/dist/repository/remote-url.js +0 -1
- package/dist/repository/remote-url.js.map +1 -1
- package/dist/runtime-version.d.ts +2 -1
- package/dist/runtime-version.d.ts.map +1 -1
- package/dist/runtime-version.js +21 -4
- package/dist/runtime-version.js.map +1 -1
- package/dist/serialization/boundary-json.d.ts +20 -0
- package/dist/serialization/boundary-json.d.ts.map +1 -0
- package/dist/serialization/boundary-json.js +129 -0
- package/dist/serialization/boundary-json.js.map +1 -0
- package/dist/serialization/envelope.js +1 -1
- package/dist/serialization/envelope.js.map +1 -1
- package/dist/serialization/validate.d.ts +7 -0
- package/dist/serialization/validate.d.ts.map +1 -1
- package/dist/serialization/validate.js +53 -13
- package/dist/serialization/validate.js.map +1 -1
- package/dist/server/app.js +1 -1
- package/dist/server/app.js.map +1 -1
- package/dist/server/http.d.ts +4 -3
- package/dist/server/http.d.ts.map +1 -1
- package/dist/server/http.js +90 -50
- package/dist/server/http.js.map +1 -1
- package/dist/server/idempotency.d.ts +0 -6
- package/dist/server/idempotency.d.ts.map +1 -1
- package/dist/server/idempotency.js.map +1 -1
- package/dist/server/router.d.ts.map +1 -1
- package/dist/server/router.js +21 -4
- package/dist/server/router.js.map +1 -1
- package/dist/server/routes/agent-capability-gate.d.ts +40 -0
- package/dist/server/routes/agent-capability-gate.d.ts.map +1 -0
- package/dist/server/routes/agent-capability-gate.js +182 -0
- package/dist/server/routes/agent-capability-gate.js.map +1 -0
- package/dist/server/routes/agent-events.d.ts.map +1 -1
- package/dist/server/routes/agent-events.js +8 -1
- package/dist/server/routes/agent-events.js.map +1 -1
- package/dist/server/routes/agent-intake.d.ts.map +1 -1
- package/dist/server/routes/agent-intake.js +10 -2
- package/dist/server/routes/agent-intake.js.map +1 -1
- package/dist/server/routes/agent-promotions.d.ts.map +1 -1
- package/dist/server/routes/agent-promotions.js +5 -2
- package/dist/server/routes/agent-promotions.js.map +1 -1
- package/dist/server/routes/agent-runs.d.ts.map +1 -1
- package/dist/server/routes/agent-runs.js +18 -4
- package/dist/server/routes/agent-runs.js.map +1 -1
- package/dist/server/routes/request-binding.d.ts +5 -0
- package/dist/server/routes/request-binding.d.ts.map +1 -0
- package/dist/server/routes/request-binding.js +49 -0
- package/dist/server/routes/request-binding.js.map +1 -0
- package/dist/server/routes/task5-support.d.ts +1 -8
- package/dist/server/routes/task5-support.d.ts.map +1 -1
- package/dist/server/routes/task5-support.js +1 -17
- package/dist/server/routes/task5-support.js.map +1 -1
- package/dist/server/routes/task5.d.ts.map +1 -1
- package/dist/server/routes/task5.js +106 -36
- package/dist/server/routes/task5.js.map +1 -1
- package/dist/server/write-queue.js +2 -2
- package/dist/server/write-queue.js.map +1 -1
- package/dist/setup/claude-config.d.ts +4 -1
- package/dist/setup/claude-config.d.ts.map +1 -1
- package/dist/setup/claude-config.js +62 -4
- package/dist/setup/claude-config.js.map +1 -1
- package/dist/setup/client-detection.d.ts +7 -2
- package/dist/setup/client-detection.d.ts.map +1 -1
- package/dist/setup/client-detection.js +27 -9
- package/dist/setup/client-detection.js.map +1 -1
- package/dist/setup/hermes-config.d.ts +4 -1
- package/dist/setup/hermes-config.d.ts.map +1 -1
- package/dist/setup/hermes-config.js +71 -17
- package/dist/setup/hermes-config.js.map +1 -1
- package/dist/setup/legacy-client-cleanup.d.ts +6 -0
- package/dist/setup/legacy-client-cleanup.d.ts.map +1 -0
- package/dist/setup/legacy-client-cleanup.js +152 -0
- package/dist/setup/legacy-client-cleanup.js.map +1 -0
- package/dist/setup/managed-text.d.ts.map +1 -1
- package/dist/setup/managed-text.js +11 -1
- package/dist/setup/managed-text.js.map +1 -1
- package/dist/setup/mcp-conflict.d.ts +4 -0
- package/dist/setup/mcp-conflict.d.ts.map +1 -0
- package/dist/setup/mcp-conflict.js +15 -0
- package/dist/setup/mcp-conflict.js.map +1 -0
- package/dist/setup/opencode-config.d.ts +4 -1
- package/dist/setup/opencode-config.d.ts.map +1 -1
- package/dist/setup/opencode-config.js +65 -5
- package/dist/setup/opencode-config.js.map +1 -1
- package/dist/setup/render.d.ts +4 -1
- package/dist/setup/render.d.ts.map +1 -1
- package/dist/setup/render.js +168 -18
- package/dist/setup/render.js.map +1 -1
- package/dist/setup/standard-skills.d.ts +16 -2
- package/dist/setup/standard-skills.d.ts.map +1 -1
- package/dist/setup/standard-skills.js +37 -13
- package/dist/setup/standard-skills.js.map +1 -1
- package/dist/setup/strict-json.d.ts +7 -0
- package/dist/setup/strict-json.d.ts.map +1 -0
- package/dist/setup/strict-json.js +98 -0
- package/dist/setup/strict-json.js.map +1 -0
- package/dist/setup/strict-toml.d.ts +18 -0
- package/dist/setup/strict-toml.d.ts.map +1 -0
- package/dist/setup/strict-toml.js +491 -0
- package/dist/setup/strict-toml.js.map +1 -0
- package/dist/skills/cache.d.ts +15 -0
- package/dist/skills/cache.d.ts.map +1 -0
- package/dist/skills/cache.js +19 -0
- package/dist/skills/cache.js.map +1 -0
- package/dist/skills/candidate-ranking.d.ts +15 -0
- package/dist/skills/candidate-ranking.d.ts.map +1 -0
- package/dist/skills/candidate-ranking.js +52 -0
- package/dist/skills/candidate-ranking.js.map +1 -0
- package/dist/skills/chunking.d.ts +11 -0
- package/dist/skills/chunking.d.ts.map +1 -0
- package/dist/skills/chunking.js +291 -0
- package/dist/skills/chunking.js.map +1 -0
- package/dist/skills/config.d.ts +19 -0
- package/dist/skills/config.d.ts.map +1 -0
- package/dist/skills/config.js +103 -0
- package/dist/skills/config.js.map +1 -0
- package/dist/skills/discovery-service.d.ts +26 -0
- package/dist/skills/discovery-service.d.ts.map +1 -0
- package/dist/skills/discovery-service.js +921 -0
- package/dist/skills/discovery-service.js.map +1 -0
- package/dist/skills/external-transport.d.ts +2 -0
- package/dist/skills/external-transport.d.ts.map +1 -0
- package/dist/skills/external-transport.js +30 -0
- package/dist/skills/external-transport.js.map +1 -0
- package/dist/skills/find.d.ts +16 -0
- package/dist/skills/find.d.ts.map +1 -0
- package/dist/skills/find.js +58 -0
- package/dist/skills/find.js.map +1 -0
- package/dist/skills/gap-detection.d.ts +23 -0
- package/dist/skills/gap-detection.d.ts.map +1 -0
- package/dist/skills/gap-detection.js +62 -0
- package/dist/skills/gap-detection.js.map +1 -0
- package/dist/skills/import-preparation.d.ts +4 -0
- package/dist/skills/import-preparation.d.ts.map +1 -0
- package/dist/skills/import-preparation.js +20 -0
- package/dist/skills/import-preparation.js.map +1 -0
- package/dist/skills/materialization-authority.d.ts +11 -0
- package/dist/skills/materialization-authority.d.ts.map +1 -0
- package/dist/skills/materialization-authority.js +92 -0
- package/dist/skills/materialization-authority.js.map +1 -0
- package/dist/skills/materialization-service.d.ts +22 -0
- package/dist/skills/materialization-service.d.ts.map +1 -0
- package/dist/skills/materialization-service.js +101 -0
- package/dist/skills/materialization-service.js.map +1 -0
- package/dist/skills/official-catalog.d.ts +31 -0
- package/dist/skills/official-catalog.d.ts.map +1 -0
- package/dist/skills/official-catalog.js +110 -0
- package/dist/skills/official-catalog.js.map +1 -0
- package/dist/skills/providers/schema.d.ts +30 -0
- package/dist/skills/providers/schema.d.ts.map +1 -0
- package/dist/skills/providers/schema.js +354 -0
- package/dist/skills/providers/schema.js.map +1 -0
- package/dist/skills/providers/skills-sh-compat.d.ts +17 -0
- package/dist/skills/providers/skills-sh-compat.d.ts.map +1 -0
- package/dist/skills/providers/skills-sh-compat.js +71 -0
- package/dist/skills/providers/skills-sh-compat.js.map +1 -0
- package/dist/skills/providers/skills-sh-v1.d.ts +23 -0
- package/dist/skills/providers/skills-sh-v1.d.ts.map +1 -0
- package/dist/skills/providers/skills-sh-v1.js +134 -0
- package/dist/skills/providers/skills-sh-v1.js.map +1 -0
- package/dist/skills/query-builder.d.ts +18 -0
- package/dist/skills/query-builder.d.ts.map +1 -0
- package/dist/skills/query-builder.js +93 -0
- package/dist/skills/query-builder.js.map +1 -0
- package/dist/skills/source/errors.d.ts +9 -0
- package/dist/skills/source/errors.d.ts.map +1 -0
- package/dist/skills/source/errors.js +15 -0
- package/dist/skills/source/errors.js.map +1 -0
- package/dist/skills/source/frontmatter.d.ts +9 -0
- package/dist/skills/source/frontmatter.d.ts.map +1 -0
- package/dist/skills/source/frontmatter.js +77 -0
- package/dist/skills/source/frontmatter.js.map +1 -0
- package/dist/skills/source/github-fetcher.d.ts +20 -0
- package/dist/skills/source/github-fetcher.d.ts.map +1 -0
- package/dist/skills/source/github-fetcher.js +292 -0
- package/dist/skills/source/github-fetcher.js.map +1 -0
- package/dist/skills/source/snapshot-validator.d.ts +28 -0
- package/dist/skills/source/snapshot-validator.d.ts.map +1 -0
- package/dist/skills/source/snapshot-validator.js +186 -0
- package/dist/skills/source/snapshot-validator.js.map +1 -0
- package/dist/skills/store.d.ts +181 -0
- package/dist/skills/store.d.ts.map +1 -0
- package/dist/skills/store.js +1710 -0
- package/dist/skills/store.js.map +1 -0
- package/dist/skills/types.d.ts +169 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/skills/types.js +2 -0
- package/dist/skills/types.js.map +1 -0
- package/dist/web/i18n.d.ts +32 -0
- package/dist/web/i18n.d.ts.map +1 -1
- package/dist/web/i18n.js +128 -0
- package/dist/web/i18n.js.map +1 -1
- package/dist/web/server.d.ts.map +1 -1
- package/dist/web/server.js +386 -38
- package/dist/web/server.js.map +1 -1
- package/dist/web/ui.d.ts +4 -0
- package/dist/web/ui.d.ts.map +1 -1
- package/dist/web/ui.js +382 -6
- package/dist/web/ui.js.map +1 -1
- package/migrations/009_external_skill_discovery.sql +126 -0
- package/package.json +6 -3
- package/skills/kiokuko-single-purpose-functions/SKILL.md +288 -0
- package/skills/kiokuko-single-purpose-functions/references/kiokuko-patterns.md +344 -0
- package/skills/kiokuko-single-purpose-functions/references/review-checklist.md +97 -0
- package/skills/kiokuko-ui-design-soul/SKILL.md +1186 -28
- package/templates/AGENTS.md +8 -7
- package/dist/client/runtime-discovery.d.ts +0 -15
- package/dist/client/runtime-discovery.d.ts.map +0 -1
- package/dist/client/runtime-discovery.js +0 -45
- package/dist/client/runtime-discovery.js.map +0 -1
- package/dist/commands/call.d.ts +0 -7
- package/dist/commands/call.d.ts.map +0 -1
- package/dist/commands/call.js +0 -10
- package/dist/commands/call.js.map +0 -1
- package/dist/commands/link.d.ts +0 -6
- package/dist/commands/link.d.ts.map +0 -1
- package/dist/commands/link.js +0 -6
- package/dist/commands/link.js.map +0 -1
- package/dist/commands/promote.d.ts +0 -6
- package/dist/commands/promote.d.ts.map +0 -1
- package/dist/commands/promote.js +0 -6
- package/dist/commands/promote.js.map +0 -1
- package/dist/commands/read.d.ts +0 -6
- package/dist/commands/read.d.ts.map +0 -1
- package/dist/commands/read.js +0 -4
- package/dist/commands/read.js.map +0 -1
- package/dist/commands/recall.d.ts +0 -6
- package/dist/commands/recall.d.ts.map +0 -1
- package/dist/commands/recall.js +0 -4
- package/dist/commands/recall.js.map +0 -1
- package/dist/commands/record.d.ts +0 -6
- package/dist/commands/record.d.ts.map +0 -1
- package/dist/commands/record.js +0 -4
- package/dist/commands/record.js.map +0 -1
- package/dist/commands/search.d.ts +0 -6
- package/dist/commands/search.d.ts.map +0 -1
- package/dist/commands/search.js +0 -4
- package/dist/commands/search.js.map +0 -1
- package/dist/commands/supersede.d.ts +0 -6
- package/dist/commands/supersede.d.ts.map +0 -1
- package/dist/commands/supersede.js +0 -6
- package/dist/commands/supersede.js.map +0 -1
- package/dist/knowledge/sources.d.ts +0 -72
- package/dist/knowledge/sources.d.ts.map +0 -1
- package/dist/knowledge/sources.js +0 -388
- package/dist/knowledge/sources.js.map +0 -1
- package/dist/setup/opencode-evidence.d.ts +0 -37
- package/dist/setup/opencode-evidence.d.ts.map +0 -1
- package/dist/setup/opencode-evidence.js +0 -58
- package/dist/setup/opencode-evidence.js.map +0 -1
- package/dist/setup/opencode-loop-guard.d.ts +0 -9
- package/dist/setup/opencode-loop-guard.d.ts.map +0 -1
- package/dist/setup/opencode-loop-guard.js +0 -248
- package/dist/setup/opencode-loop-guard.js.map +0 -1
package/dist/context/feedback.js
CHANGED
|
@@ -1,13 +1,39 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
+
import { isProxy } from 'node:util/types';
|
|
2
3
|
import { withImmediateTransaction } from '../db/transaction.js';
|
|
3
4
|
import { KiokukoError } from '../errors.js';
|
|
4
5
|
import { sanitizeJson } from '../security/sanitize.js';
|
|
5
6
|
import { canonicalContentHash } from '../serialization/validate.js';
|
|
6
7
|
import { entryOriginMatchesWorkspace, isContextEntryOrigin } from './origin.js';
|
|
7
8
|
export const MAX_FEEDBACK_COMMENT_BYTES = 4 * 1024;
|
|
9
|
+
export const MAX_FEEDBACK_OUTCOME_BYTES = 4 * 1024;
|
|
8
10
|
export const MAX_FEEDBACK_IDENTIFIER_LENGTH = 256;
|
|
9
11
|
export const CONTEXT_FEEDBACK_VERDICTS = ['helpful', 'irrelevant', 'stale', 'conflicting'];
|
|
10
12
|
export const RUN_FEEDBACK_RECOMMENDATION_VERDICTS = ['accepted', 'dismissed', 'resolved'];
|
|
13
|
+
/** Shared cross-run feedback evidence for retrieval policy consumers. */
|
|
14
|
+
export function contextFeedbackSignals(database, entryId) {
|
|
15
|
+
const rows = database.prepare(`
|
|
16
|
+
SELECT verdict, COUNT(DISTINCT run_id) AS distinctRuns
|
|
17
|
+
FROM context_feedback
|
|
18
|
+
WHERE entry_id = ?
|
|
19
|
+
GROUP BY verdict
|
|
20
|
+
`).all(entryId);
|
|
21
|
+
const byVerdict = new Map();
|
|
22
|
+
for (const row of rows) {
|
|
23
|
+
if (typeof row.verdict !== 'string'
|
|
24
|
+
|| !CONTEXT_FEEDBACK_VERDICTS.includes(row.verdict)
|
|
25
|
+
|| typeof row.distinctRuns !== 'number'
|
|
26
|
+
|| !Number.isSafeInteger(row.distinctRuns)
|
|
27
|
+
|| row.distinctRuns < 1) {
|
|
28
|
+
throw new KiokukoError('INTEGRITY_ERROR', 'Stored context feedback aggregate is invalid');
|
|
29
|
+
}
|
|
30
|
+
byVerdict.set(row.verdict, row.distinctRuns);
|
|
31
|
+
}
|
|
32
|
+
return CONTEXT_FEEDBACK_VERDICTS.flatMap((verdict) => {
|
|
33
|
+
const distinctRuns = byVerdict.get(verdict);
|
|
34
|
+
return distinctRuns === undefined ? [] : [{ verdict, distinctRuns, boundedInfluence: Math.min(2, distinctRuns) }];
|
|
35
|
+
});
|
|
36
|
+
}
|
|
11
37
|
const CONTEXT_INPUT_FIELDS = new Set([
|
|
12
38
|
'workspace', 'feedbackId', 'deliveryId', 'entryId', 'entryRevision', 'runId', 'verdict',
|
|
13
39
|
'comment', 'actor', 'idempotencyKey', 'createdAt',
|
|
@@ -42,20 +68,75 @@ function databaseFailure() {
|
|
|
42
68
|
return fail('DATABASE_ERROR', DATABASE_MESSAGE);
|
|
43
69
|
}
|
|
44
70
|
function isPlainObject(value) {
|
|
45
|
-
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
71
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value) || isProxy(value))
|
|
46
72
|
return false;
|
|
47
73
|
const prototype = Object.getPrototypeOf(value);
|
|
48
74
|
return prototype === Object.prototype || prototype === null;
|
|
49
75
|
}
|
|
76
|
+
function inputFields(value, allowed, exact = false) {
|
|
77
|
+
if (!isPlainObject(value))
|
|
78
|
+
validation();
|
|
79
|
+
const keys = Reflect.ownKeys(value);
|
|
80
|
+
if (exact && keys.length !== allowed.size)
|
|
81
|
+
validation();
|
|
82
|
+
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
83
|
+
const result = Object.create(null);
|
|
84
|
+
for (const key of keys) {
|
|
85
|
+
if (typeof key !== 'string' || !allowed.has(key))
|
|
86
|
+
validation();
|
|
87
|
+
const descriptor = descriptors[key];
|
|
88
|
+
if (!descriptor || !('value' in descriptor) || descriptor.enumerable !== true)
|
|
89
|
+
validation();
|
|
90
|
+
result[key] = descriptor.value;
|
|
91
|
+
}
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
50
94
|
function isKiokukoError(error) {
|
|
51
95
|
return error instanceof KiokukoError;
|
|
52
96
|
}
|
|
53
|
-
|
|
97
|
+
const SQLITE_CONSTRAINT_PRIMARY_KEY = 1_555;
|
|
98
|
+
const SQLITE_CONSTRAINT_UNIQUE = 2_067;
|
|
99
|
+
const NO_UNIQUENESS_FAILURES = new Set();
|
|
100
|
+
const SQLITE_OPERATIONAL_PRIMARY_CODES = new Set([5, 6, 7, 8, 9, 10, 13, 14, 15, 22, 23]);
|
|
101
|
+
const SQLITE_INTEGRITY_PRIMARY_CODES = new Set([11, 24, 26]);
|
|
102
|
+
const CONTEXT_FEEDBACK_UNIQUENESS_FAILURES = new Set([
|
|
103
|
+
'UNIQUE constraint failed: context_feedback.feedback_id',
|
|
104
|
+
'UNIQUE constraint failed: context_feedback.run_id, context_feedback.actor, context_feedback.idempotency_key',
|
|
105
|
+
]);
|
|
106
|
+
const RUN_FEEDBACK_UNIQUENESS_FAILURES = new Set([
|
|
107
|
+
'UNIQUE constraint failed: run_feedback.feedback_id',
|
|
108
|
+
'UNIQUE constraint failed: run_feedback.run_id, run_feedback.actor, run_feedback.idempotency_key',
|
|
109
|
+
]);
|
|
110
|
+
const INTAKE_FEEDBACK_UNIQUENESS_FAILURES = new Set([
|
|
111
|
+
'UNIQUE constraint failed: intake_feedback.feedback_id',
|
|
112
|
+
'UNIQUE constraint failed: intake_feedback.run_id, intake_feedback.actor, intake_feedback.idempotency_key',
|
|
113
|
+
]);
|
|
114
|
+
function nodeSqliteFailure(error) {
|
|
115
|
+
if (!(error instanceof Error))
|
|
116
|
+
return null;
|
|
117
|
+
const failure = error;
|
|
118
|
+
if (failure.code !== 'ERR_SQLITE_ERROR'
|
|
119
|
+
|| typeof failure.errcode !== 'number'
|
|
120
|
+
|| !Number.isSafeInteger(failure.errcode)
|
|
121
|
+
|| failure.errcode < 0)
|
|
122
|
+
return null;
|
|
123
|
+
return failure;
|
|
124
|
+
}
|
|
125
|
+
function normalizeDatabaseError(error, uniquenessFailures = NO_UNIQUENESS_FAILURES) {
|
|
54
126
|
if (isKiokukoError(error))
|
|
55
127
|
throw error;
|
|
56
|
-
|
|
128
|
+
const failure = nodeSqliteFailure(error);
|
|
129
|
+
if (failure === null)
|
|
130
|
+
throw error;
|
|
131
|
+
if ((failure.errcode === SQLITE_CONSTRAINT_PRIMARY_KEY || failure.errcode === SQLITE_CONSTRAINT_UNIQUE)
|
|
132
|
+
&& uniquenessFailures.has(failure.message))
|
|
57
133
|
conflict();
|
|
58
|
-
|
|
134
|
+
const primaryResultCode = failure.errcode & 0xff;
|
|
135
|
+
if (SQLITE_INTEGRITY_PRIMARY_CODES.has(primaryResultCode))
|
|
136
|
+
integrity();
|
|
137
|
+
if (SQLITE_OPERATIONAL_PRIMARY_CODES.has(primaryResultCode))
|
|
138
|
+
databaseFailure();
|
|
139
|
+
throw error;
|
|
59
140
|
}
|
|
60
141
|
function requiredString(value) {
|
|
61
142
|
if (typeof value !== 'string' || value.length === 0 || value.length > MAX_FEEDBACK_IDENTIFIER_LENGTH)
|
|
@@ -69,13 +150,23 @@ function optionalText(value, maximum) {
|
|
|
69
150
|
validation();
|
|
70
151
|
return value;
|
|
71
152
|
}
|
|
72
|
-
function
|
|
73
|
-
if (
|
|
153
|
+
function optionalUtf8Text(value, maximumBytes) {
|
|
154
|
+
if (value === undefined || value === null)
|
|
155
|
+
return null;
|
|
156
|
+
if (typeof value !== 'string' || value.length === 0 || Buffer.byteLength(value, 'utf8') > maximumBytes)
|
|
74
157
|
validation();
|
|
75
|
-
|
|
76
|
-
|
|
158
|
+
return value;
|
|
159
|
+
}
|
|
160
|
+
function isCanonicalFeedbackTimestamp(value) {
|
|
161
|
+
if (typeof value !== 'string' || !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(value))
|
|
162
|
+
return false;
|
|
163
|
+
const parsed = Date.parse(value);
|
|
164
|
+
return Number.isFinite(parsed) && new Date(parsed).toISOString() === value;
|
|
165
|
+
}
|
|
166
|
+
export function validateFeedbackTimestamp(value) {
|
|
167
|
+
if (!isCanonicalFeedbackTimestamp(value))
|
|
77
168
|
validation();
|
|
78
|
-
return
|
|
169
|
+
return value;
|
|
79
170
|
}
|
|
80
171
|
function normalizeComment(value, workspace) {
|
|
81
172
|
if (value === undefined || value === null)
|
|
@@ -84,13 +175,7 @@ function normalizeComment(value, workspace) {
|
|
|
84
175
|
validation();
|
|
85
176
|
if (value.trim().length === 0)
|
|
86
177
|
return null;
|
|
87
|
-
|
|
88
|
-
try {
|
|
89
|
-
sanitized = sanitizeJson(value, { workspace }).value;
|
|
90
|
-
}
|
|
91
|
-
catch {
|
|
92
|
-
validation();
|
|
93
|
-
}
|
|
178
|
+
const sanitized = sanitizeJson(value, { workspace }).value;
|
|
94
179
|
if (typeof sanitized !== 'string')
|
|
95
180
|
validation();
|
|
96
181
|
if (sanitized.trim().length === 0)
|
|
@@ -130,152 +215,104 @@ function runBodyHash(input) {
|
|
|
130
215
|
});
|
|
131
216
|
}
|
|
132
217
|
function validateContextFeedbackInput(value) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
? undefined
|
|
146
|
-
: typeof value.entryRevision === 'number' && Number.isSafeInteger(value.entryRevision) && value.entryRevision > 0
|
|
147
|
-
? value.entryRevision
|
|
148
|
-
: validation();
|
|
149
|
-
const runId = requiredString(value.runId);
|
|
150
|
-
if (typeof value.verdict !== 'string' || !CONTEXT_FEEDBACK_VERDICTS.includes(value.verdict))
|
|
151
|
-
validation();
|
|
152
|
-
const verdict = value.verdict;
|
|
153
|
-
const actor = requiredString(value.actor);
|
|
154
|
-
const idempotencyKey = requiredString(value.idempotencyKey);
|
|
155
|
-
const createdAt = normalizeTimestamp(value.createdAt);
|
|
156
|
-
const comment = normalizeComment(value.comment, workspace);
|
|
157
|
-
return {
|
|
158
|
-
feedbackId,
|
|
159
|
-
workspace,
|
|
160
|
-
deliveryId,
|
|
161
|
-
entryId,
|
|
162
|
-
...(entryRevision === undefined ? {} : { entryRevision }),
|
|
163
|
-
runId,
|
|
164
|
-
verdict,
|
|
165
|
-
comment,
|
|
166
|
-
actor,
|
|
167
|
-
idempotencyKeyHash: hashIdempotencyKey(idempotencyKey),
|
|
168
|
-
createdAt,
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
catch (error) {
|
|
172
|
-
if (isKiokukoError(error) && error.code === 'VALIDATION_ERROR')
|
|
173
|
-
validation();
|
|
218
|
+
const fields = inputFields(value, CONTEXT_INPUT_FIELDS);
|
|
219
|
+
const workspace = requiredString(fields.workspace);
|
|
220
|
+
const feedbackId = requiredString(fields.feedbackId);
|
|
221
|
+
const deliveryId = requiredString(fields.deliveryId);
|
|
222
|
+
const entryId = requiredString(fields.entryId);
|
|
223
|
+
const entryRevision = fields.entryRevision === undefined
|
|
224
|
+
? undefined
|
|
225
|
+
: typeof fields.entryRevision === 'number' && Number.isSafeInteger(fields.entryRevision) && fields.entryRevision > 0
|
|
226
|
+
? fields.entryRevision
|
|
227
|
+
: validation();
|
|
228
|
+
const runId = requiredString(fields.runId);
|
|
229
|
+
if (typeof fields.verdict !== 'string' || !CONTEXT_FEEDBACK_VERDICTS.includes(fields.verdict))
|
|
174
230
|
validation();
|
|
175
|
-
|
|
231
|
+
const verdict = fields.verdict;
|
|
232
|
+
const actor = requiredString(fields.actor);
|
|
233
|
+
const idempotencyKey = requiredString(fields.idempotencyKey);
|
|
234
|
+
const createdAt = validateFeedbackTimestamp(fields.createdAt);
|
|
235
|
+
const comment = normalizeComment(fields.comment, workspace);
|
|
236
|
+
return {
|
|
237
|
+
feedbackId,
|
|
238
|
+
workspace,
|
|
239
|
+
deliveryId,
|
|
240
|
+
entryId,
|
|
241
|
+
...(entryRevision === undefined ? {} : { entryRevision }),
|
|
242
|
+
runId,
|
|
243
|
+
verdict,
|
|
244
|
+
comment,
|
|
245
|
+
actor,
|
|
246
|
+
idempotencyKeyHash: hashIdempotencyKey(idempotencyKey),
|
|
247
|
+
createdAt,
|
|
248
|
+
};
|
|
176
249
|
}
|
|
177
250
|
function validateContextFeedbackListInput(value) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const workspace = requiredString(value.workspace);
|
|
186
|
-
const runId = value.runId === undefined ? undefined : requiredString(value.runId);
|
|
187
|
-
const deliveryId = value.deliveryId === undefined ? undefined : requiredString(value.deliveryId);
|
|
188
|
-
const entryId = value.entryId === undefined ? undefined : requiredString(value.entryId);
|
|
189
|
-
const limit = value.limit === undefined ? 100 : value.limit;
|
|
190
|
-
if (typeof limit !== 'number' || !Number.isInteger(limit) || limit < 1 || limit > 100)
|
|
191
|
-
validation();
|
|
192
|
-
return {
|
|
193
|
-
workspace,
|
|
194
|
-
...(runId === undefined ? {} : { runId }),
|
|
195
|
-
...(deliveryId === undefined ? {} : { deliveryId }),
|
|
196
|
-
...(entryId === undefined ? {} : { entryId }),
|
|
197
|
-
limit,
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
catch (error) {
|
|
201
|
-
if (isKiokukoError(error) && error.code === 'VALIDATION_ERROR')
|
|
202
|
-
validation();
|
|
251
|
+
const fields = inputFields(value, CONTEXT_LIST_FIELDS);
|
|
252
|
+
const workspace = requiredString(fields.workspace);
|
|
253
|
+
const runId = fields.runId === undefined ? undefined : requiredString(fields.runId);
|
|
254
|
+
const deliveryId = fields.deliveryId === undefined ? undefined : requiredString(fields.deliveryId);
|
|
255
|
+
const entryId = fields.entryId === undefined ? undefined : requiredString(fields.entryId);
|
|
256
|
+
const limit = fields.limit === undefined ? 100 : fields.limit;
|
|
257
|
+
if (typeof limit !== 'number' || !Number.isInteger(limit) || limit < 1 || limit > 100)
|
|
203
258
|
validation();
|
|
204
|
-
|
|
259
|
+
return {
|
|
260
|
+
workspace,
|
|
261
|
+
...(runId === undefined ? {} : { runId }),
|
|
262
|
+
...(deliveryId === undefined ? {} : { deliveryId }),
|
|
263
|
+
...(entryId === undefined ? {} : { entryId }),
|
|
264
|
+
limit,
|
|
265
|
+
};
|
|
205
266
|
}
|
|
206
267
|
function validateRunFeedbackListInput(value) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
validation();
|
|
213
|
-
}
|
|
214
|
-
const workspace = requiredString(value.workspace);
|
|
215
|
-
const runId = value.runId === undefined ? undefined : requiredString(value.runId);
|
|
216
|
-
const limit = value.limit === undefined ? 100 : value.limit;
|
|
217
|
-
if (typeof limit !== 'number' || !Number.isInteger(limit) || limit < 1 || limit > 100)
|
|
218
|
-
validation();
|
|
219
|
-
return { workspace, ...(runId === undefined ? {} : { runId }), limit };
|
|
220
|
-
}
|
|
221
|
-
catch (error) {
|
|
222
|
-
if (isKiokukoError(error) && error.code === 'VALIDATION_ERROR')
|
|
223
|
-
validation();
|
|
268
|
+
const fields = inputFields(value, RUN_LIST_FIELDS);
|
|
269
|
+
const workspace = requiredString(fields.workspace);
|
|
270
|
+
const runId = fields.runId === undefined ? undefined : requiredString(fields.runId);
|
|
271
|
+
const limit = fields.limit === undefined ? 100 : fields.limit;
|
|
272
|
+
if (typeof limit !== 'number' || !Number.isInteger(limit) || limit < 1 || limit > 100)
|
|
224
273
|
validation();
|
|
225
|
-
}
|
|
274
|
+
return { workspace, ...(runId === undefined ? {} : { runId }), limit };
|
|
226
275
|
}
|
|
227
276
|
function validateRunFeedbackInput(value) {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
const recommendationVerdict = rawRecommendationVerdict === undefined || rawRecommendationVerdict === null
|
|
242
|
-
? null
|
|
243
|
-
: typeof rawRecommendationVerdict === 'string' && RUN_FEEDBACK_RECOMMENDATION_VERDICTS.includes(rawRecommendationVerdict)
|
|
244
|
-
? rawRecommendationVerdict
|
|
245
|
-
: validation();
|
|
246
|
-
if ((recommendationCode === null) !== (recommendationVerdict === null))
|
|
247
|
-
validation();
|
|
248
|
-
const rawRating = value.rating;
|
|
249
|
-
const rating = rawRating === undefined || rawRating === null
|
|
250
|
-
? null
|
|
251
|
-
: typeof rawRating === 'number' && Number.isInteger(rawRating) && rawRating >= 1 && rawRating <= 5
|
|
252
|
-
? rawRating
|
|
253
|
-
: validation();
|
|
254
|
-
if (outcome === null && recommendationCode === null && rating === null)
|
|
255
|
-
validation();
|
|
256
|
-
const actor = requiredString(value.actor);
|
|
257
|
-
const idempotencyKey = requiredString(value.idempotencyKey);
|
|
258
|
-
const createdAt = normalizeTimestamp(value.createdAt);
|
|
259
|
-
const comment = normalizeComment(value.comment, workspace);
|
|
260
|
-
return {
|
|
261
|
-
feedbackId,
|
|
262
|
-
workspace,
|
|
263
|
-
runId,
|
|
264
|
-
outcome,
|
|
265
|
-
recommendationCode,
|
|
266
|
-
recommendationVerdict,
|
|
267
|
-
rating,
|
|
268
|
-
comment,
|
|
269
|
-
actor,
|
|
270
|
-
idempotencyKeyHash: hashIdempotencyKey(idempotencyKey),
|
|
271
|
-
createdAt,
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
catch (error) {
|
|
275
|
-
if (isKiokukoError(error) && error.code === 'VALIDATION_ERROR')
|
|
276
|
-
validation();
|
|
277
|
+
const fields = inputFields(value, RUN_INPUT_FIELDS);
|
|
278
|
+
const workspace = requiredString(fields.workspace);
|
|
279
|
+
const feedbackId = requiredString(fields.feedbackId);
|
|
280
|
+
const runId = requiredString(fields.runId);
|
|
281
|
+
const outcome = optionalUtf8Text(fields.outcome, MAX_FEEDBACK_OUTCOME_BYTES);
|
|
282
|
+
const recommendationCode = optionalText(fields.recommendationCode, MAX_FEEDBACK_IDENTIFIER_LENGTH);
|
|
283
|
+
const rawRecommendationVerdict = fields.recommendationVerdict;
|
|
284
|
+
const recommendationVerdict = rawRecommendationVerdict === undefined || rawRecommendationVerdict === null
|
|
285
|
+
? null
|
|
286
|
+
: typeof rawRecommendationVerdict === 'string' && RUN_FEEDBACK_RECOMMENDATION_VERDICTS.includes(rawRecommendationVerdict)
|
|
287
|
+
? rawRecommendationVerdict
|
|
288
|
+
: validation();
|
|
289
|
+
if ((recommendationCode === null) !== (recommendationVerdict === null))
|
|
277
290
|
validation();
|
|
278
|
-
|
|
291
|
+
const rawRating = fields.rating;
|
|
292
|
+
const rating = rawRating === undefined || rawRating === null
|
|
293
|
+
? null
|
|
294
|
+
: typeof rawRating === 'number' && Number.isInteger(rawRating) && rawRating >= 1 && rawRating <= 5
|
|
295
|
+
? rawRating
|
|
296
|
+
: validation();
|
|
297
|
+
if (outcome === null && recommendationCode === null && rating === null)
|
|
298
|
+
validation();
|
|
299
|
+
const actor = requiredString(fields.actor);
|
|
300
|
+
const idempotencyKey = requiredString(fields.idempotencyKey);
|
|
301
|
+
const createdAt = validateFeedbackTimestamp(fields.createdAt);
|
|
302
|
+
const comment = normalizeComment(fields.comment, workspace);
|
|
303
|
+
return {
|
|
304
|
+
feedbackId,
|
|
305
|
+
workspace,
|
|
306
|
+
runId,
|
|
307
|
+
outcome,
|
|
308
|
+
recommendationCode,
|
|
309
|
+
recommendationVerdict,
|
|
310
|
+
rating,
|
|
311
|
+
comment,
|
|
312
|
+
actor,
|
|
313
|
+
idempotencyKeyHash: hashIdempotencyKey(idempotencyKey),
|
|
314
|
+
createdAt,
|
|
315
|
+
};
|
|
279
316
|
}
|
|
280
317
|
function assertContextTarget(database, input) {
|
|
281
318
|
const target = database.prepare(`
|
|
@@ -341,13 +378,7 @@ function storedHash(value) {
|
|
|
341
378
|
return value;
|
|
342
379
|
}
|
|
343
380
|
function storedTimestamp(value) {
|
|
344
|
-
if (
|
|
345
|
-
integrity();
|
|
346
|
-
const date = new Date(value);
|
|
347
|
-
if (Number.isNaN(date.getTime()))
|
|
348
|
-
integrity();
|
|
349
|
-
const normalized = date.toISOString();
|
|
350
|
-
if (normalized !== value)
|
|
381
|
+
if (!isCanonicalFeedbackTimestamp(value))
|
|
351
382
|
integrity();
|
|
352
383
|
return value;
|
|
353
384
|
}
|
|
@@ -383,13 +414,7 @@ function rowToContextFeedback(row, workspace) {
|
|
|
383
414
|
else if (typeof row.comment === 'string') {
|
|
384
415
|
if (row.comment.length === 0 || Buffer.byteLength(row.comment, 'utf8') > MAX_FEEDBACK_COMMENT_BYTES)
|
|
385
416
|
integrity();
|
|
386
|
-
|
|
387
|
-
try {
|
|
388
|
-
sanitized = normalizeComment(row.comment, workspace);
|
|
389
|
-
}
|
|
390
|
-
catch {
|
|
391
|
-
integrity();
|
|
392
|
-
}
|
|
417
|
+
const sanitized = normalizeComment(row.comment, workspace);
|
|
393
418
|
if (sanitized !== row.comment)
|
|
394
419
|
integrity();
|
|
395
420
|
comment = row.comment;
|
|
@@ -410,7 +435,7 @@ function rowToContextFeedback(row, workspace) {
|
|
|
410
435
|
createdAt: storedTimestamp(row.created_at),
|
|
411
436
|
};
|
|
412
437
|
}
|
|
413
|
-
function
|
|
438
|
+
function preflightContextFeedbackWrite(database, input) {
|
|
414
439
|
assertContextTarget(database, input);
|
|
415
440
|
const existingByKey = selectContextByKey(database, input);
|
|
416
441
|
if (existingByKey) {
|
|
@@ -421,6 +446,22 @@ function writeContextFeedback(database, input) {
|
|
|
421
446
|
}
|
|
422
447
|
if (hasContextFeedbackId(database, input.feedbackId))
|
|
423
448
|
conflict();
|
|
449
|
+
return undefined;
|
|
450
|
+
}
|
|
451
|
+
/** Validate a context-feedback write and its exact persisted target without mutating state. */
|
|
452
|
+
export function assertContextFeedbackRecordable(database, input) {
|
|
453
|
+
const validated = validateContextFeedbackInput(input);
|
|
454
|
+
try {
|
|
455
|
+
preflightContextFeedbackWrite(database, validated);
|
|
456
|
+
}
|
|
457
|
+
catch (error) {
|
|
458
|
+
normalizeDatabaseError(error, CONTEXT_FEEDBACK_UNIQUENESS_FAILURES);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
function writeContextFeedback(database, input) {
|
|
462
|
+
const existing = preflightContextFeedbackWrite(database, input);
|
|
463
|
+
if (existing !== undefined)
|
|
464
|
+
return existing;
|
|
424
465
|
database.prepare(`
|
|
425
466
|
INSERT INTO context_feedback (
|
|
426
467
|
feedback_id, delivery_id, entry_id, run_id, verdict, comment, actor, idempotency_key, created_at
|
|
@@ -437,7 +478,7 @@ export function recordContextFeedbackInTransaction(database, input) {
|
|
|
437
478
|
return writeContextFeedback(database, validated);
|
|
438
479
|
}
|
|
439
480
|
catch (error) {
|
|
440
|
-
normalizeDatabaseError(error);
|
|
481
|
+
normalizeDatabaseError(error, CONTEXT_FEEDBACK_UNIQUENESS_FAILURES);
|
|
441
482
|
}
|
|
442
483
|
}
|
|
443
484
|
export function recordContextFeedback(database, input) {
|
|
@@ -446,7 +487,7 @@ export function recordContextFeedback(database, input) {
|
|
|
446
487
|
return withImmediateTransaction(database, () => writeContextFeedback(database, validated));
|
|
447
488
|
}
|
|
448
489
|
catch (error) {
|
|
449
|
-
normalizeDatabaseError(error);
|
|
490
|
+
normalizeDatabaseError(error, CONTEXT_FEEDBACK_UNIQUENESS_FAILURES);
|
|
450
491
|
}
|
|
451
492
|
}
|
|
452
493
|
function runOptionalStoredText(value, maximum) {
|
|
@@ -456,18 +497,19 @@ function runOptionalStoredText(value, maximum) {
|
|
|
456
497
|
integrity();
|
|
457
498
|
return value;
|
|
458
499
|
}
|
|
500
|
+
function runOptionalStoredUtf8Text(value, maximumBytes) {
|
|
501
|
+
if (value === null)
|
|
502
|
+
return null;
|
|
503
|
+
if (typeof value !== 'string' || value.length === 0 || Buffer.byteLength(value, 'utf8') > maximumBytes)
|
|
504
|
+
integrity();
|
|
505
|
+
return value;
|
|
506
|
+
}
|
|
459
507
|
function runStoredComment(value, workspace) {
|
|
460
508
|
if (value === null)
|
|
461
509
|
return null;
|
|
462
510
|
if (typeof value !== 'string' || value.length === 0 || Buffer.byteLength(value, 'utf8') > MAX_FEEDBACK_COMMENT_BYTES)
|
|
463
511
|
integrity();
|
|
464
|
-
|
|
465
|
-
try {
|
|
466
|
-
sanitized = normalizeComment(value, workspace);
|
|
467
|
-
}
|
|
468
|
-
catch {
|
|
469
|
-
integrity();
|
|
470
|
-
}
|
|
512
|
+
const sanitized = normalizeComment(value, workspace);
|
|
471
513
|
if (sanitized !== value)
|
|
472
514
|
integrity();
|
|
473
515
|
return value;
|
|
@@ -500,7 +542,7 @@ function rowToRunFeedback(row, workspace) {
|
|
|
500
542
|
const runWorkspace = storedString(row.run_workspace);
|
|
501
543
|
if (runWorkspace !== workspace)
|
|
502
544
|
integrity();
|
|
503
|
-
const outcome =
|
|
545
|
+
const outcome = runOptionalStoredUtf8Text(row.outcome, MAX_FEEDBACK_OUTCOME_BYTES);
|
|
504
546
|
const recommendationCode = runOptionalStoredText(row.recommendation_code, MAX_FEEDBACK_IDENTIFIER_LENGTH);
|
|
505
547
|
let recommendationVerdict;
|
|
506
548
|
if (row.recommendation_verdict === null) {
|
|
@@ -565,7 +607,7 @@ export function recordRunFeedbackInTransaction(database, input) {
|
|
|
565
607
|
return writeRunFeedback(database, validated);
|
|
566
608
|
}
|
|
567
609
|
catch (error) {
|
|
568
|
-
normalizeDatabaseError(error);
|
|
610
|
+
normalizeDatabaseError(error, RUN_FEEDBACK_UNIQUENESS_FAILURES);
|
|
569
611
|
}
|
|
570
612
|
}
|
|
571
613
|
export function recordRunFeedback(database, input) {
|
|
@@ -574,7 +616,7 @@ export function recordRunFeedback(database, input) {
|
|
|
574
616
|
return withImmediateTransaction(database, () => writeRunFeedback(database, validated));
|
|
575
617
|
}
|
|
576
618
|
catch (error) {
|
|
577
|
-
normalizeDatabaseError(error);
|
|
619
|
+
normalizeDatabaseError(error, RUN_FEEDBACK_UNIQUENESS_FAILURES);
|
|
578
620
|
}
|
|
579
621
|
}
|
|
580
622
|
export function listRunFeedback(database, input) {
|
|
@@ -659,59 +701,23 @@ const INTAKE_FEEDBACK_FIELDS = new Set([
|
|
|
659
701
|
'verdict', 'comment', 'actor', 'idempotencyKey', 'createdAt',
|
|
660
702
|
]);
|
|
661
703
|
const INTAKE_PROFILE_FIELDS = new Set(['taskType', 'target', 'expected', 'constraints']);
|
|
662
|
-
function initialInputFields(value) {
|
|
663
|
-
try {
|
|
664
|
-
if (!isPlainObject(value))
|
|
665
|
-
validation();
|
|
666
|
-
const keys = Reflect.ownKeys(value);
|
|
667
|
-
if (keys.length !== INTAKE_FEEDBACK_FIELDS.size || keys.some((key) => typeof key !== 'string' || !INTAKE_FEEDBACK_FIELDS.has(key)))
|
|
668
|
-
validation();
|
|
669
|
-
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
670
|
-
const result = {};
|
|
671
|
-
for (const field of INTAKE_FEEDBACK_FIELDS) {
|
|
672
|
-
const descriptor = descriptors[field];
|
|
673
|
-
if (!descriptor || !('value' in descriptor) || descriptor.enumerable !== true)
|
|
674
|
-
validation();
|
|
675
|
-
result[field] = descriptor.value;
|
|
676
|
-
}
|
|
677
|
-
structuredClone(value);
|
|
678
|
-
return result;
|
|
679
|
-
}
|
|
680
|
-
catch {
|
|
681
|
-
validation();
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
704
|
function initialInputIdentifier(value) {
|
|
685
705
|
if (typeof value !== 'string' || value.length === 0 || Buffer.byteLength(value, 'utf8') > MAX_FEEDBACK_IDENTIFIER_LENGTH || /\p{Cc}/u.test(value))
|
|
686
706
|
validation();
|
|
687
707
|
return value;
|
|
688
708
|
}
|
|
689
|
-
function initialInputTimestamp(value) {
|
|
690
|
-
if (typeof value !== 'string' || !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(value))
|
|
691
|
-
validation();
|
|
692
|
-
const date = new Date(value);
|
|
693
|
-
if (Number.isNaN(date.getTime()) || date.toISOString() !== value)
|
|
694
|
-
validation();
|
|
695
|
-
return value;
|
|
696
|
-
}
|
|
697
709
|
function initialInputComment(value, workspace) {
|
|
698
710
|
if (value === null)
|
|
699
711
|
return null;
|
|
700
712
|
if (typeof value !== 'string' || value.length === 0)
|
|
701
713
|
validation();
|
|
702
|
-
|
|
703
|
-
try {
|
|
704
|
-
sanitized = sanitizeJson(value, { workspace }).value;
|
|
705
|
-
}
|
|
706
|
-
catch {
|
|
707
|
-
validation();
|
|
708
|
-
}
|
|
714
|
+
const sanitized = sanitizeJson(value, { workspace }).value;
|
|
709
715
|
if (typeof sanitized !== 'string' || sanitized.length === 0 || Buffer.byteLength(sanitized, 'utf8') > MAX_FEEDBACK_COMMENT_BYTES)
|
|
710
716
|
validation();
|
|
711
717
|
return sanitized;
|
|
712
718
|
}
|
|
713
719
|
function validateInitialIntakeFeedbackInput(value) {
|
|
714
|
-
const fields =
|
|
720
|
+
const fields = inputFields(value, INTAKE_FEEDBACK_FIELDS, true);
|
|
715
721
|
const workspace = initialInputIdentifier(fields.workspace);
|
|
716
722
|
const feedbackId = initialInputIdentifier(fields.feedbackId);
|
|
717
723
|
const runId = initialInputIdentifier(fields.runId);
|
|
@@ -743,7 +749,7 @@ function validateInitialIntakeFeedbackInput(value) {
|
|
|
743
749
|
comment: initialInputComment(fields.comment, workspace),
|
|
744
750
|
actor,
|
|
745
751
|
idempotencyKeyHash: hashIdempotencyKey(idempotencyKey),
|
|
746
|
-
createdAt:
|
|
752
|
+
createdAt: validateFeedbackTimestamp(fields.createdAt),
|
|
747
753
|
};
|
|
748
754
|
}
|
|
749
755
|
function initialIntakeTarget(database, input) {
|
|
@@ -827,26 +833,12 @@ function initialStoredHash(value) {
|
|
|
827
833
|
integrity();
|
|
828
834
|
return value;
|
|
829
835
|
}
|
|
830
|
-
function initialStoredTimestamp(value) {
|
|
831
|
-
if (typeof value !== 'string' || !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(value))
|
|
832
|
-
integrity();
|
|
833
|
-
const date = new Date(value);
|
|
834
|
-
if (Number.isNaN(date.getTime()) || date.toISOString() !== value)
|
|
835
|
-
integrity();
|
|
836
|
-
return value;
|
|
837
|
-
}
|
|
838
836
|
function initialStoredComment(value, workspace) {
|
|
839
837
|
if (value === null)
|
|
840
838
|
return null;
|
|
841
839
|
if (typeof value !== 'string' || value.length === 0 || Buffer.byteLength(value, 'utf8') > MAX_FEEDBACK_COMMENT_BYTES)
|
|
842
840
|
integrity();
|
|
843
|
-
|
|
844
|
-
try {
|
|
845
|
-
sanitized = normalizeComment(value, workspace);
|
|
846
|
-
}
|
|
847
|
-
catch {
|
|
848
|
-
integrity();
|
|
849
|
-
}
|
|
841
|
+
const sanitized = initialInputComment(value, workspace);
|
|
850
842
|
if (sanitized !== value)
|
|
851
843
|
integrity();
|
|
852
844
|
return value;
|
|
@@ -889,7 +881,7 @@ function rowToInitialIntakeFeedback(row, workspace) {
|
|
|
889
881
|
comment: initialStoredComment(row.comment, workspace),
|
|
890
882
|
actor,
|
|
891
883
|
idempotencyKeyHash: initialStoredHash(row.idempotency_key),
|
|
892
|
-
createdAt:
|
|
884
|
+
createdAt: storedTimestamp(row.created_at),
|
|
893
885
|
};
|
|
894
886
|
}
|
|
895
887
|
function recordInitialIntakeFeedback(database, input) {
|
|
@@ -919,7 +911,7 @@ export function recordIntakeFeedback(database, input) {
|
|
|
919
911
|
return withImmediateTransaction(database, () => recordInitialIntakeFeedback(database, validated));
|
|
920
912
|
}
|
|
921
913
|
catch (error) {
|
|
922
|
-
normalizeDatabaseError(error);
|
|
914
|
+
normalizeDatabaseError(error, INTAKE_FEEDBACK_UNIQUENESS_FAILURES);
|
|
923
915
|
}
|
|
924
916
|
}
|
|
925
917
|
export function recordIntakeFeedbackInTransaction(database, input) {
|
|
@@ -928,36 +920,12 @@ export function recordIntakeFeedbackInTransaction(database, input) {
|
|
|
928
920
|
return recordInitialIntakeFeedback(database, validated);
|
|
929
921
|
}
|
|
930
922
|
catch (error) {
|
|
931
|
-
normalizeDatabaseError(error);
|
|
923
|
+
normalizeDatabaseError(error, INTAKE_FEEDBACK_UNIQUENESS_FAILURES);
|
|
932
924
|
}
|
|
933
925
|
}
|
|
934
926
|
const INTAKE_FEEDBACK_LIST_FIELDS = new Set(['workspace', 'runId', 'sessionId', 'questionId', 'profileField', 'limit']);
|
|
935
|
-
function initialListInputFields(value) {
|
|
936
|
-
try {
|
|
937
|
-
if (!isPlainObject(value))
|
|
938
|
-
validation();
|
|
939
|
-
const keys = Reflect.ownKeys(value);
|
|
940
|
-
if (keys.some((key) => typeof key !== 'string' || !INTAKE_FEEDBACK_LIST_FIELDS.has(key)))
|
|
941
|
-
validation();
|
|
942
|
-
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
943
|
-
const result = {};
|
|
944
|
-
for (const key of keys) {
|
|
945
|
-
if (typeof key !== 'string')
|
|
946
|
-
validation();
|
|
947
|
-
const descriptor = descriptors[key];
|
|
948
|
-
if (!descriptor || !('value' in descriptor) || descriptor.enumerable !== true)
|
|
949
|
-
validation();
|
|
950
|
-
result[key] = descriptor.value;
|
|
951
|
-
}
|
|
952
|
-
structuredClone(value);
|
|
953
|
-
return result;
|
|
954
|
-
}
|
|
955
|
-
catch {
|
|
956
|
-
validation();
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
927
|
function validateInitialIntakeFeedbackListInput(value) {
|
|
960
|
-
const fields =
|
|
928
|
+
const fields = inputFields(value, INTAKE_FEEDBACK_LIST_FIELDS);
|
|
961
929
|
const workspace = initialInputIdentifier(fields.workspace);
|
|
962
930
|
const runId = fields.runId === undefined ? undefined : initialInputIdentifier(fields.runId);
|
|
963
931
|
const sessionId = fields.sessionId === undefined ? undefined : initialInputIdentifier(fields.sessionId);
|