@kvman/kvcoder 0.1.6 → 0.1.8
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/dist/api.d.ts +49 -3
- package/dist/api.d.ts.map +1 -1
- package/dist/calls/run-shell.d.ts.map +1 -1
- package/dist/calls/run-shell.js +39 -9
- package/dist/calls/run-shell.js.map +1 -1
- package/dist/connector-call.d.ts +1 -1
- package/dist/connector-call.d.ts.map +1 -1
- package/dist/connector-call.js +4 -2
- package/dist/connector-call.js.map +1 -1
- package/dist/connectors/artifact.d.ts +1 -1
- package/dist/connectors/artifact.d.ts.map +1 -1
- package/dist/connectors/artifact.js +4 -4
- package/dist/connectors/artifact.js.map +1 -1
- package/dist/connectors/ask.d.ts +24 -0
- package/dist/connectors/ask.d.ts.map +1 -1
- package/dist/connectors/ask.js +20 -11
- package/dist/connectors/ask.js.map +1 -1
- package/dist/connectors/background.d.ts +14 -1
- package/dist/connectors/background.d.ts.map +1 -1
- package/dist/connectors/background.js +53 -23
- package/dist/connectors/background.js.map +1 -1
- package/dist/connectors/builtin-connectors.d.ts +110 -0
- package/dist/connectors/builtin-connectors.d.ts.map +1 -1
- package/dist/connectors/builtin-connectors.js +4 -1
- package/dist/connectors/builtin-connectors.js.map +1 -1
- package/dist/connectors/delegate.d.ts +3 -2
- package/dist/connectors/delegate.d.ts.map +1 -1
- package/dist/connectors/delegate.js +27 -9
- package/dist/connectors/delegate.js.map +1 -1
- package/dist/connectors/execution-map.d.ts +62 -0
- package/dist/connectors/execution-map.d.ts.map +1 -0
- package/dist/connectors/execution-map.js +142 -0
- package/dist/connectors/execution-map.js.map +1 -0
- package/dist/connectors/fs.d.ts +32 -1
- package/dist/connectors/fs.d.ts.map +1 -1
- package/dist/connectors/fs.js +76 -45
- package/dist/connectors/fs.js.map +1 -1
- package/dist/connectors/mcp.d.ts +18 -1
- package/dist/connectors/mcp.d.ts.map +1 -1
- package/dist/connectors/mcp.js +54 -6
- package/dist/connectors/mcp.js.map +1 -1
- package/dist/connectors/payload-fields.d.ts.map +1 -1
- package/dist/connectors/payload-fields.js +1 -1
- package/dist/connectors/payload-fields.js.map +1 -1
- package/dist/delegate/approved-run.d.ts +4 -6
- package/dist/delegate/approved-run.d.ts.map +1 -1
- package/dist/delegate/approved-run.js +74 -34
- package/dist/delegate/approved-run.js.map +1 -1
- package/dist/delegate/git-staging.d.ts +12 -0
- package/dist/delegate/git-staging.d.ts.map +1 -0
- package/dist/delegate/git-staging.js +54 -0
- package/dist/delegate/git-staging.js.map +1 -0
- package/dist/delegate/permission.d.ts +240 -0
- package/dist/delegate/permission.d.ts.map +1 -0
- package/dist/delegate/permission.js +78 -0
- package/dist/delegate/permission.js.map +1 -0
- package/dist/delegate/program-permission.d.ts +27 -0
- package/dist/delegate/program-permission.d.ts.map +1 -0
- package/dist/delegate/program-permission.js +53 -0
- package/dist/delegate/program-permission.js.map +1 -0
- package/dist/delegate/register-worker-run.d.ts.map +1 -1
- package/dist/delegate/register-worker-run.js +27 -11
- package/dist/delegate/register-worker-run.js.map +1 -1
- package/dist/delegate/run-program.d.ts.map +1 -1
- package/dist/delegate/run-program.js +29 -8
- package/dist/delegate/run-program.js.map +1 -1
- package/dist/delegate/runs.d.ts +14 -4
- package/dist/delegate/runs.d.ts.map +1 -1
- package/dist/delegate/runs.js +49 -19
- package/dist/delegate/runs.js.map +1 -1
- package/dist/delegate/staging-guard.d.ts +9 -0
- package/dist/delegate/staging-guard.d.ts.map +1 -0
- package/dist/delegate/staging-guard.js +55 -0
- package/dist/delegate/staging-guard.js.map +1 -0
- package/dist/delegate/start-background.d.ts +7 -0
- package/dist/delegate/start-background.d.ts.map +1 -0
- package/dist/delegate/start-background.js +32 -0
- package/dist/delegate/start-background.js.map +1 -0
- package/dist/delegate/start-pending.d.ts +5 -0
- package/dist/delegate/start-pending.d.ts.map +1 -0
- package/dist/delegate/start-pending.js +42 -0
- package/dist/delegate/start-pending.js.map +1 -0
- package/dist/delegate/workers.d.ts +5 -2
- package/dist/delegate/workers.d.ts.map +1 -1
- package/dist/delegate/workers.js +44 -8
- package/dist/delegate/workers.js.map +1 -1
- package/dist/files/file-change.d.ts +28 -0
- package/dist/files/file-change.d.ts.map +1 -0
- package/dist/files/file-change.js +125 -0
- package/dist/files/file-change.js.map +1 -0
- package/dist/files/file-parts.d.ts +18 -0
- package/dist/files/file-parts.d.ts.map +1 -0
- package/dist/files/file-parts.js +40 -0
- package/dist/files/file-parts.js.map +1 -0
- package/dist/files/read-file.d.ts +9 -1
- package/dist/files/read-file.d.ts.map +1 -1
- package/dist/files/read-file.js +35 -13
- package/dist/files/read-file.js.map +1 -1
- package/dist/files/search-text.d.ts +12 -2
- package/dist/files/search-text.d.ts.map +1 -1
- package/dist/files/search-text.js +87 -23
- package/dist/files/search-text.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/jobs/job-rows.d.ts +11 -2
- package/dist/jobs/job-rows.d.ts.map +1 -1
- package/dist/jobs/job-rows.js +24 -13
- package/dist/jobs/job-rows.js.map +1 -1
- package/dist/jobs/process-handlers.d.ts.map +1 -1
- package/dist/jobs/process-handlers.js +12 -1
- package/dist/jobs/process-handlers.js.map +1 -1
- package/dist/jobs/process-report.d.ts.map +1 -1
- package/dist/jobs/process-report.js +2 -1
- package/dist/jobs/process-report.js.map +1 -1
- package/dist/jobs/process-run.d.ts.map +1 -1
- package/dist/jobs/process-run.js +2 -1
- package/dist/jobs/process-run.js.map +1 -1
- package/dist/jobs/register-jobs.d.ts.map +1 -1
- package/dist/jobs/register-jobs.js +1 -0
- package/dist/jobs/register-jobs.js.map +1 -1
- package/dist/maps/map-reminder.d.ts +7 -0
- package/dist/maps/map-reminder.d.ts.map +1 -0
- package/dist/maps/map-reminder.js +24 -0
- package/dist/maps/map-reminder.js.map +1 -0
- package/dist/maps/map-rules.d.ts +36 -0
- package/dist/maps/map-rules.d.ts.map +1 -0
- package/dist/maps/map-rules.js +86 -0
- package/dist/maps/map-rules.js.map +1 -0
- package/dist/maps/map-schema.d.ts +55 -0
- package/dist/maps/map-schema.d.ts.map +1 -0
- package/dist/maps/map-schema.js +27 -0
- package/dist/maps/map-schema.js.map +1 -0
- package/dist/maps/register-maps.d.ts +3 -0
- package/dist/maps/register-maps.d.ts.map +1 -0
- package/dist/maps/register-maps.js +21 -0
- package/dist/maps/register-maps.js.map +1 -0
- package/dist/mcp/connect.d.ts +2 -0
- package/dist/mcp/connect.d.ts.map +1 -1
- package/dist/mcp/connect.js +16 -4
- package/dist/mcp/connect.js.map +1 -1
- package/dist/mcp/oauth-provider.d.ts +8 -5
- package/dist/mcp/oauth-provider.d.ts.map +1 -1
- package/dist/mcp/oauth-provider.js +31 -22
- package/dist/mcp/oauth-provider.js.map +1 -1
- package/dist/mcp/secrets.d.ts +2 -0
- package/dist/mcp/secrets.d.ts.map +1 -1
- package/dist/mcp/secrets.js +6 -0
- package/dist/mcp/secrets.js.map +1 -1
- package/dist/mcp/sign-in.d.ts.map +1 -1
- package/dist/mcp/sign-in.js +12 -4
- package/dist/mcp/sign-in.js.map +1 -1
- package/dist/messages/receive-message.d.ts +2 -1
- package/dist/messages/receive-message.d.ts.map +1 -1
- package/dist/messages/receive-message.js +34 -9
- package/dist/messages/receive-message.js.map +1 -1
- package/dist/messages/register-messages.d.ts.map +1 -1
- package/dist/messages/register-messages.js +13 -8
- package/dist/messages/register-messages.js.map +1 -1
- package/dist/messages/send-receipt.d.ts +10 -0
- package/dist/messages/send-receipt.d.ts.map +1 -0
- package/dist/messages/send-receipt.js +14 -0
- package/dist/messages/send-receipt.js.map +1 -0
- package/dist/prompt/build-prompt.d.ts +1 -0
- package/dist/prompt/build-prompt.d.ts.map +1 -1
- package/dist/prompt/build-prompt.js +5 -1
- package/dist/prompt/build-prompt.js.map +1 -1
- package/dist/prompt/project-rules.d.ts +6 -0
- package/dist/prompt/project-rules.d.ts.map +1 -0
- package/dist/prompt/project-rules.js +37 -0
- package/dist/prompt/project-rules.js.map +1 -0
- package/dist/prompt/session-grants.d.ts +209 -0
- package/dist/prompt/session-grants.d.ts.map +1 -0
- package/dist/prompt/session-grants.js +50 -0
- package/dist/prompt/session-grants.js.map +1 -0
- package/dist/prompt/session-prompt.d.ts +3 -2
- package/dist/prompt/session-prompt.d.ts.map +1 -1
- package/dist/prompt/session-prompt.js +24 -40
- package/dist/prompt/session-prompt.js.map +1 -1
- package/dist/prompt/working-method.d.ts.map +1 -1
- package/dist/prompt/working-method.js +23 -17
- package/dist/prompt/working-method.js.map +1 -1
- package/dist/register-settings.d.ts +3 -1
- package/dist/register-settings.d.ts.map +1 -1
- package/dist/register-settings.js +5 -4
- package/dist/register-settings.js.map +1 -1
- package/dist/registry/register-connectors.d.ts +9 -0
- package/dist/registry/register-connectors.d.ts.map +1 -1
- package/dist/registry/register-connectors.js +20 -12
- package/dist/registry/register-connectors.js.map +1 -1
- package/dist/result-text.d.ts +4 -0
- package/dist/result-text.d.ts.map +1 -1
- package/dist/result-text.js +9 -0
- package/dist/result-text.js.map +1 -1
- package/dist/schemas/records.d.ts +142 -0
- package/dist/schemas/records.d.ts.map +1 -1
- package/dist/schemas/records.js +60 -2
- package/dist/schemas/records.js.map +1 -1
- package/dist/sessions/execution-root.d.ts +8 -0
- package/dist/sessions/execution-root.d.ts.map +1 -0
- package/dist/sessions/execution-root.js +25 -0
- package/dist/sessions/execution-root.js.map +1 -0
- package/dist/sessions/new-session.d.ts +5 -1
- package/dist/sessions/new-session.d.ts.map +1 -1
- package/dist/sessions/new-session.js +17 -4
- package/dist/sessions/new-session.js.map +1 -1
- package/dist/sessions/register-context.d.ts.map +1 -1
- package/dist/sessions/register-context.js +6 -5
- package/dist/sessions/register-context.js.map +1 -1
- package/dist/sessions/register-fork-export.d.ts.map +1 -1
- package/dist/sessions/register-fork-export.js +5 -3
- package/dist/sessions/register-fork-export.js.map +1 -1
- package/dist/sessions/register-lifecycle.d.ts.map +1 -1
- package/dist/sessions/register-lifecycle.js +14 -5
- package/dist/sessions/register-lifecycle.js.map +1 -1
- package/dist/sessions/register-sessions.d.ts.map +1 -1
- package/dist/sessions/register-sessions.js +0 -2
- package/dist/sessions/register-sessions.js.map +1 -1
- package/dist/sessions/session-view.d.ts +23 -0
- package/dist/sessions/session-view.d.ts.map +1 -1
- package/dist/sessions/session-view.js +4 -1
- package/dist/sessions/session-view.js.map +1 -1
- package/dist/store/all-docs.d.ts +4 -0
- package/dist/store/all-docs.d.ts.map +1 -0
- package/dist/store/all-docs.js +14 -0
- package/dist/store/all-docs.js.map +1 -0
- package/dist/store/collections.d.ts +230 -0
- package/dist/store/collections.d.ts.map +1 -1
- package/dist/store/collections.js +16 -1
- package/dist/store/collections.js.map +1 -1
- package/dist/turns/answer-fingerprint.d.ts +4 -0
- package/dist/turns/answer-fingerprint.d.ts.map +1 -0
- package/dist/turns/answer-fingerprint.js +18 -0
- package/dist/turns/answer-fingerprint.js.map +1 -0
- package/dist/turns/apply-answer.d.ts +19 -0
- package/dist/turns/apply-answer.d.ts.map +1 -0
- package/dist/turns/apply-answer.js +47 -0
- package/dist/turns/apply-answer.js.map +1 -0
- package/dist/turns/background.d.ts +3 -0
- package/dist/turns/background.d.ts.map +1 -1
- package/dist/turns/background.js +13 -12
- package/dist/turns/background.js.map +1 -1
- package/dist/turns/call-permission.d.ts +22 -0
- package/dist/turns/call-permission.d.ts.map +1 -0
- package/dist/turns/call-permission.js +49 -0
- package/dist/turns/call-permission.js.map +1 -0
- package/dist/turns/cancel-step-job.d.ts +14 -0
- package/dist/turns/cancel-step-job.d.ts.map +1 -0
- package/dist/turns/cancel-step-job.js +35 -0
- package/dist/turns/cancel-step-job.js.map +1 -0
- package/dist/turns/child-result.d.ts +7 -0
- package/dist/turns/child-result.d.ts.map +1 -0
- package/dist/turns/child-result.js +24 -0
- package/dist/turns/child-result.js.map +1 -0
- package/dist/turns/compaction.d.ts +15 -1
- package/dist/turns/compaction.d.ts.map +1 -1
- package/dist/turns/compaction.js +44 -16
- package/dist/turns/compaction.js.map +1 -1
- package/dist/turns/end-turn-state.d.ts +42 -0
- package/dist/turns/end-turn-state.d.ts.map +1 -0
- package/dist/turns/end-turn-state.js +64 -0
- package/dist/turns/end-turn-state.js.map +1 -0
- package/dist/turns/end-turn.d.ts +7 -8
- package/dist/turns/end-turn.d.ts.map +1 -1
- package/dist/turns/end-turn.js +52 -55
- package/dist/turns/end-turn.js.map +1 -1
- package/dist/turns/helper-calls.d.ts +6 -0
- package/dist/turns/helper-calls.d.ts.map +1 -0
- package/dist/turns/helper-calls.js +8 -0
- package/dist/turns/helper-calls.js.map +1 -0
- package/dist/turns/history.d.ts +3 -1
- package/dist/turns/history.d.ts.map +1 -1
- package/dist/turns/history.js +15 -7
- package/dist/turns/history.js.map +1 -1
- package/dist/turns/lost-reply.d.ts +7 -0
- package/dist/turns/lost-reply.d.ts.map +1 -1
- package/dist/turns/lost-reply.js +12 -0
- package/dist/turns/lost-reply.js.map +1 -1
- package/dist/turns/message-blocks.d.ts +2 -0
- package/dist/turns/message-blocks.d.ts.map +1 -1
- package/dist/turns/message-blocks.js +7 -0
- package/dist/turns/message-blocks.js.map +1 -1
- package/dist/turns/model-context.d.ts +2 -0
- package/dist/turns/model-context.d.ts.map +1 -1
- package/dist/turns/model-context.js +23 -4
- package/dist/turns/model-context.js.map +1 -1
- package/dist/turns/model-retry.d.ts +2 -1
- package/dist/turns/model-retry.d.ts.map +1 -1
- package/dist/turns/model-retry.js +5 -1
- package/dist/turns/model-retry.js.map +1 -1
- package/dist/turns/read-only.d.ts +6 -0
- package/dist/turns/read-only.d.ts.map +1 -0
- package/dist/turns/read-only.js +12 -0
- package/dist/turns/read-only.js.map +1 -0
- package/dist/turns/receipt-job.d.ts +5 -0
- package/dist/turns/receipt-job.d.ts.map +1 -0
- package/dist/turns/receipt-job.js +40 -0
- package/dist/turns/receipt-job.js.map +1 -0
- package/dist/turns/recover-workspace.d.ts +9 -0
- package/dist/turns/recover-workspace.d.ts.map +1 -0
- package/dist/turns/recover-workspace.js +79 -0
- package/dist/turns/recover-workspace.js.map +1 -0
- package/dist/turns/recovery-state.d.ts +19 -0
- package/dist/turns/recovery-state.d.ts.map +1 -0
- package/dist/turns/recovery-state.js +87 -0
- package/dist/turns/recovery-state.js.map +1 -0
- package/dist/turns/register-interruptions.d.ts.map +1 -1
- package/dist/turns/register-interruptions.js +19 -8
- package/dist/turns/register-interruptions.js.map +1 -1
- package/dist/turns/register-turns.d.ts.map +1 -1
- package/dist/turns/register-turns.js +42 -31
- package/dist/turns/register-turns.js.map +1 -1
- package/dist/turns/resolve.d.ts +4 -0
- package/dist/turns/resolve.d.ts.map +1 -1
- package/dist/turns/resolve.js +19 -17
- package/dist/turns/resolve.js.map +1 -1
- package/dist/turns/retry-turn.d.ts +4 -0
- package/dist/turns/retry-turn.d.ts.map +1 -0
- package/dist/turns/retry-turn.js +20 -0
- package/dist/turns/retry-turn.js.map +1 -0
- package/dist/turns/run-calls.d.ts +21 -4
- package/dist/turns/run-calls.d.ts.map +1 -1
- package/dist/turns/run-calls.js +157 -41
- package/dist/turns/run-calls.js.map +1 -1
- package/dist/turns/run-command.d.ts +5 -3
- package/dist/turns/run-command.d.ts.map +1 -1
- package/dist/turns/run-command.js +21 -12
- package/dist/turns/run-command.js.map +1 -1
- package/dist/turns/settle-calls.d.ts +2 -8
- package/dist/turns/settle-calls.d.ts.map +1 -1
- package/dist/turns/settle-calls.js +26 -35
- package/dist/turns/settle-calls.js.map +1 -1
- package/dist/turns/start-turn.d.ts +8 -83
- package/dist/turns/start-turn.d.ts.map +1 -1
- package/dist/turns/start-turn.js +35 -24
- package/dist/turns/start-turn.js.map +1 -1
- package/dist/turns/step-claim.d.ts +39 -0
- package/dist/turns/step-claim.d.ts.map +1 -0
- package/dist/turns/step-claim.js +72 -0
- package/dist/turns/step-claim.js.map +1 -0
- package/dist/turns/step-intents.d.ts +31 -0
- package/dist/turns/step-intents.d.ts.map +1 -0
- package/dist/turns/step-intents.js +101 -0
- package/dist/turns/step-intents.js.map +1 -0
- package/dist/turns/step-next.d.ts +17 -0
- package/dist/turns/step-next.d.ts.map +1 -0
- package/dist/turns/step-next.js +25 -0
- package/dist/turns/step-next.js.map +1 -0
- package/dist/turns/step.d.ts +1 -1
- package/dist/turns/step.d.ts.map +1 -1
- package/dist/turns/step.js +108 -88
- package/dist/turns/step.js.map +1 -1
- package/dist/turns/summary-facts.d.ts +25 -0
- package/dist/turns/summary-facts.d.ts.map +1 -0
- package/dist/turns/summary-facts.js +63 -0
- package/dist/turns/summary-facts.js.map +1 -0
- package/dist/turns/usage.d.ts +7 -0
- package/dist/turns/usage.d.ts.map +1 -0
- package/dist/turns/usage.js +18 -0
- package/dist/turns/usage.js.map +1 -0
- package/dist/ui/register-ui.js +3 -3
- package/dist/ui/register-ui.js.map +1 -1
- package/dist/web/components/approval.css +2 -0
- package/dist/web/components/approval.js +233 -0
- package/dist/web/components/call.css +1 -1
- package/dist/web/components/call.js +430 -304
- package/dist/web/components/connectors.css +1 -1
- package/dist/web/components/connectors.js +595 -592
- package/dist/web/components/conversation.css +1 -1
- package/dist/web/components/conversation.js +2978 -1637
- package/dist/web/components/mcp-sign-in.css +1 -1
- package/dist/web/components/model.css +1 -1
- package/dist/web/components/model.js +138 -134
- package/dist/web/components/question.css +1 -1
- package/dist/web/components/question.js +148 -78
- package/dist/web/components/sessions.css +1 -1
- package/docs/connectors.md +3 -3
- package/locales/ar.json +95 -13
- package/locales/en.json +95 -13
- package/package.json +6 -6
- package/dist/turns/cancel-turn.d.ts +0 -3
- package/dist/turns/cancel-turn.d.ts.map +0 -1
- package/dist/turns/cancel-turn.js +0 -31
- package/dist/turns/cancel-turn.js.map +0 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SendReceiptDoc } from '../schemas/records.ts';
|
|
2
|
+
export type Sent = {
|
|
3
|
+
sendId: string;
|
|
4
|
+
sessionId: string;
|
|
5
|
+
messageFingerprint: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function sentBy(sendId: string, sessionId: string, text: string, fileIds: readonly string[]): Sent;
|
|
8
|
+
/** Whether the receipt already accepted this send; another message or session under its id is a conflict. */
|
|
9
|
+
export declare function acknowledged(receipt: SendReceiptDoc | undefined, sent: Sent): boolean;
|
|
10
|
+
//# sourceMappingURL=send-receipt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-receipt.d.ts","sourceRoot":"","sources":["../../src/messages/send-receipt.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAK5D,MAAM,MAAM,IAAI,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,MAAM,CAAA;CAAE,CAAC;AAErF,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAExG;AAED,6GAA6G;AAC7G,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAIrF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { invalid } from "../problems.js";
|
|
3
|
+
export function sentBy(sendId, sessionId, text, fileIds) {
|
|
4
|
+
return { sendId, sessionId, messageFingerprint: createHash('sha256').update(JSON.stringify([text, fileIds])).digest('hex') };
|
|
5
|
+
}
|
|
6
|
+
/** Whether the receipt already accepted this send; another message or session under its id is a conflict. */
|
|
7
|
+
export function acknowledged(receipt, sent) {
|
|
8
|
+
if (receipt === undefined)
|
|
9
|
+
return false;
|
|
10
|
+
if (receipt.sessionId !== sent.sessionId || receipt.messageFingerprint !== sent.messageFingerprint)
|
|
11
|
+
throw invalid('This sendId was already used for another message.', {});
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=send-receipt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-receipt.js","sourceRoot":"","sources":["../../src/messages/send-receipt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAQzC,MAAM,UAAU,MAAM,CAAC,MAAc,EAAE,SAAiB,EAAE,IAAY,EAAE,OAA0B;IAChG,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AAC/H,CAAC;AAED,6GAA6G;AAC7G,MAAM,UAAU,YAAY,CAAC,OAAmC,EAAE,IAAU;IAC1E,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACxC,IAAI,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC,kBAAkB,KAAK,IAAI,CAAC,kBAAkB;QAAE,MAAM,OAAO,CAAC,mDAAmD,EAAE,EAAE,CAAC,CAAC;IAC3K,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-prompt.d.ts","sourceRoot":"","sources":["../../src/prompt/build-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAEhE,OAAO,EAA+B,KAAK,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAK7E,MAAM,MAAM,WAAW,GAAG;IACxB,8GAA8G;IAC9G,IAAI,EAAE,IAAI,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC,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E,CAAC;AAyDvG,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW,CAO3D"}
|
|
@@ -14,7 +14,7 @@ function basePrompt(input) {
|
|
|
14
14
|
'Each message from the person starts with the date and time it was sent, in brackets; the newest one is the current time.',
|
|
15
15
|
].join('\n');
|
|
16
16
|
const tool = 'Your one tool is run: it runs one command of a connector, as { description, connector, command, payload }. description is one sentence for the person, saying what the call does. Below, `fs write` means the connector fs and its command write.';
|
|
17
|
-
const connectors = `Connectors are the only way you act. When a connector other than shell covers a task, use it instead of a shell line: it checks its input, returns structured results, and is shown to the person. Use shell only for what no other connector does. Every connector has the command help. A command listed below with its payload needs no help call; for any other command, or for what a field means, call the connector's help with { "command": "<name>" } before the first use. \`shell exec\`, \`fs write\`, \`fs edit\`, and \`mcp
|
|
17
|
+
const connectors = `Connectors are the only way you act. When a connector other than shell covers a task, use it instead of a shell line: it checks its input, returns structured results, and is shown to the person. Use shell only for what no other connector does. Every connector has the command help. A command listed below with its payload needs no help call; for any other command, or for what a field means, call the connector's help with { "command": "<name>" } before the first use. \`shell exec\`, \`fs write\`, \`fs edit\`, \`mcp call\`, and \`mcp run\` take risky, which you always send and judge for each call from what the call does, not from which command it is. It is false for the ordinary work of the task: creating, editing, or rewriting a file inside the workspace folder that the task needs, whoever made it (\`fs undo\` takes such a change back), running the project's own build, tests, and tools, and a tool that only reads. It is true, and the person is then asked first, only when the call could do what is hard to take back or reaches past the task: anything outside the workspace folder; deleting files, or overwriting them with a shell line; a file that holds secrets, such as .env or a key; rewriting or discarding git history or uncommitted work (push --force, reset --hard, clean); sudo, or an install outside the project; sending something out (a push, a publish, a deploy, a message, a write to a remote service); and the Commands section of AGENTS.md. When you can't tell whether a call can be taken back, it is true. Each \`shell exec\` starts in the workspace folder, so cd doesn't carry over to the next call; the shell is ${shell}.`;
|
|
18
18
|
return [identity, tool, connectors, workingMethod(input.role)].join('\n\n');
|
|
19
19
|
}
|
|
20
20
|
// A connector's entry: its owner's description, then its commands, which kvcoder adds (ADR 0009, 164; ADR 0011, 3). A
|
|
@@ -49,11 +49,15 @@ function keptSections(sections) {
|
|
|
49
49
|
}
|
|
50
50
|
return { kept, left };
|
|
51
51
|
}
|
|
52
|
+
/** What a read-only worker's helper is told (ADR 0056, 4). */
|
|
53
|
+
const readOnlyNote = 'You are read-only here: you read and search, and you report your findings in your answer. A call that could change something is refused, so don\'t make one; say what should change and why.';
|
|
52
54
|
export function buildPrompt(input) {
|
|
53
55
|
const { kept, left } = keptSections(input.sections);
|
|
54
56
|
const parts = [basePrompt(input), ...kept.map((section) => `## ${section.title}\n${section.content}`)];
|
|
55
57
|
if (input.worker !== undefined && input.worker.instructions !== '')
|
|
56
58
|
parts.push(`## Worker: ${input.worker.name}\n${input.worker.instructions}`);
|
|
59
|
+
if (input.worker?.readOnly === true)
|
|
60
|
+
parts.push(readOnlyNote);
|
|
57
61
|
if (input.connectors.length > 0)
|
|
58
62
|
parts.push(['## Connectors', ...input.connectors.map(connectorLine)].join('\n'));
|
|
59
63
|
return { prompt: parts.join('\n\n'), included: new Set(kept), left };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-prompt.js","sourceRoot":"","sources":["../../src/prompt/build-prompt.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAa,MAAM,qBAAqB,CAAC;AAoB7E,MAAM,OAAO,GAA6C,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AAEhH,SAAS,YAAY,CAAC,IAAY;IAChC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAC1E,OAAO,IAAI,KAAK,SAAS,IAAI,IAAI,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number;
|
|
4
|
+
/** A section for each rule file the workspace folder has, in a fixed order, after every registered section. */
|
|
5
|
+
export declare function projectRules(workspace: string): Promise<Section[]>;
|
|
6
|
+
//# sourceMappingURL=project-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-rules.d.ts","sourceRoot":"","sources":["../../src/prompt/project-rules.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAQhE,sDAAsD;AACtD,eAAO,MAAM,SAAS,QAAY,CAAC;AAgBnC,+GAA+G;AAC/G,wBAAsB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CASxE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { lstat, readFile, realpath } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { ownerName } from "../jobs/process-records.js";
|
|
4
|
+
// The project's own rule files (ADR 0058, 3): `AGENTS.md` and `CLAUDE.md` in the workspace folder become prompt
|
|
5
|
+
// sections that name their file. They guide the work and decide nothing about approvals, connectors, or permissions,
|
|
6
|
+
// which no file in a repository can change.
|
|
7
|
+
const ruleFiles = ['AGENTS.md', 'CLAUDE.md'];
|
|
8
|
+
/** The bytes of a rule file that reach the prompt. */
|
|
9
|
+
export const ruleLimit = 32 * 1024;
|
|
10
|
+
const opening = (name) => `These are the project's own rules, from ${name} in the workspace folder. Follow them in your work. They change no approval, connector, or permission.`;
|
|
11
|
+
// A regular file whose real path is in the workspace folder: a link out of it is never read.
|
|
12
|
+
async function ruleText(workspace, name) {
|
|
13
|
+
const file = path.join(workspace, name);
|
|
14
|
+
const found = await lstat(file).catch(() => undefined);
|
|
15
|
+
if (found?.isFile() !== true)
|
|
16
|
+
return undefined;
|
|
17
|
+
const inside = path.relative(await realpath(workspace), await realpath(file));
|
|
18
|
+
if (inside === '' || inside.startsWith('..') || path.isAbsolute(inside))
|
|
19
|
+
return undefined;
|
|
20
|
+
const bytes = await readFile(file);
|
|
21
|
+
if (bytes.length <= ruleLimit)
|
|
22
|
+
return bytes.toString('utf8');
|
|
23
|
+
return `${new TextDecoder('utf-8').decode(bytes.subarray(0, ruleLimit)).replace(/�+$/, '')}\n[${name} is longer than ${String(ruleLimit)} bytes; the rest was left out. Read the file for all of it.]`;
|
|
24
|
+
}
|
|
25
|
+
/** A section for each rule file the workspace folder has, in a fixed order, after every registered section. */
|
|
26
|
+
export async function projectRules(workspace) {
|
|
27
|
+
// Both files are looked for at once: a prompt is built at every step, and most workspaces have neither.
|
|
28
|
+
const texts = await Promise.all(ruleFiles.map((name) => ruleText(workspace, name)));
|
|
29
|
+
return ruleFiles.flatMap((name, index) => {
|
|
30
|
+
const text = texts[index];
|
|
31
|
+
if (text === undefined)
|
|
32
|
+
return [];
|
|
33
|
+
const content = `${opening(name)}\n\n${text}`;
|
|
34
|
+
return [{ id: `project-rules-${name.toLowerCase().replace('.md', '')}`, title: `Project rules: ${name}`, order: Number.MAX_SAFE_INTEGER - ruleFiles.length + index, owner: ownerName, global: false, sessionId: null, content, size: Buffer.byteLength(content, 'utf8') }];
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=project-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-rules.js","sourceRoot":"","sources":["../../src/prompt/project-rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAGvD,gHAAgH;AAChH,qHAAqH;AACrH,4CAA4C;AAE5C,MAAM,SAAS,GAAG,CAAC,WAAW,EAAE,WAAW,CAAU,CAAC;AAEtD,sDAAsD;AACtD,MAAM,CAAC,MAAM,SAAS,GAAG,EAAE,GAAG,IA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AG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACpF,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACvC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;QAC9C,OAAO,CAAC,EAAE,EAAE,EAAE,iBAAiB,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,kBAAkB,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,gBAAgB,GAAG,SAAS,CAAC,MAAM,GAAG,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;IAC7Q,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import type { Ctx, Stored } from '@kvman/sdk';
|
|
2
|
+
import type { SessionDoc } from '../schemas/records.ts';
|
|
3
|
+
import { type TxRecords } from '../store/collections.ts';
|
|
4
|
+
/** Await external data before the caller's final canonical store validation, not afterwards. */
|
|
5
|
+
export declare function prepareGrants(ctx: Ctx): Promise<{
|
|
6
|
+
connectors: import("../registry/register-connectors.ts").ConnectorPreparation;
|
|
7
|
+
servers: ({
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
command: string;
|
|
11
|
+
args: string[];
|
|
12
|
+
env: string[];
|
|
13
|
+
} | {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
url: string;
|
|
17
|
+
headers: string[];
|
|
18
|
+
})[];
|
|
19
|
+
workers: ({
|
|
20
|
+
kind: "opencode";
|
|
21
|
+
model: string | null;
|
|
22
|
+
agent: string | null;
|
|
23
|
+
autoApprove: boolean;
|
|
24
|
+
approval: "ask" | "auto";
|
|
25
|
+
timeoutMs: number;
|
|
26
|
+
name: string;
|
|
27
|
+
description: string;
|
|
28
|
+
enabled: boolean;
|
|
29
|
+
instructions: string;
|
|
30
|
+
} | {
|
|
31
|
+
kind: "claude";
|
|
32
|
+
model: string | null;
|
|
33
|
+
effort: "low" | "medium" | "high" | "xhigh" | "max" | null;
|
|
34
|
+
permissionMode: "auto" | "bypassPermissions" | "dontAsk" | "acceptEdits" | "plan";
|
|
35
|
+
approval: "ask" | "auto";
|
|
36
|
+
timeoutMs: number;
|
|
37
|
+
name: string;
|
|
38
|
+
description: string;
|
|
39
|
+
enabled: boolean;
|
|
40
|
+
instructions: string;
|
|
41
|
+
} | {
|
|
42
|
+
kind: "subagent";
|
|
43
|
+
readOnly: boolean;
|
|
44
|
+
connectors: string[] | null;
|
|
45
|
+
model: string | null;
|
|
46
|
+
thinking: "off" | "minimal" | "low" | "medium" | "high" | null;
|
|
47
|
+
name: string;
|
|
48
|
+
description: string;
|
|
49
|
+
enabled: boolean;
|
|
50
|
+
instructions: string;
|
|
51
|
+
} | {
|
|
52
|
+
kind: "pi";
|
|
53
|
+
model: string | null;
|
|
54
|
+
thinking: "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | null;
|
|
55
|
+
tools: string[] | null;
|
|
56
|
+
approval: "ask" | "auto";
|
|
57
|
+
timeoutMs: number;
|
|
58
|
+
name: string;
|
|
59
|
+
description: string;
|
|
60
|
+
enabled: boolean;
|
|
61
|
+
instructions: string;
|
|
62
|
+
})[];
|
|
63
|
+
disabled: Set<string>;
|
|
64
|
+
}>;
|
|
65
|
+
export type GrantPreparation = Awaited<ReturnType<typeof prepareGrants>>;
|
|
66
|
+
/** Canonical session/root/registry grant decision in the SAME tx as the caller's authority proof. */
|
|
67
|
+
export declare function grantsInTx(store: TxRecords, session: Stored<SessionDoc>, prepared: GrantPreparation): {
|
|
68
|
+
session: Stored<{
|
|
69
|
+
title: string;
|
|
70
|
+
autoTitle: boolean;
|
|
71
|
+
deleting: boolean;
|
|
72
|
+
status: "idle" | "running" | "waiting";
|
|
73
|
+
parentId: string | null;
|
|
74
|
+
worker: {
|
|
75
|
+
name: string;
|
|
76
|
+
instructions: string;
|
|
77
|
+
readOnly: boolean;
|
|
78
|
+
} | null;
|
|
79
|
+
model: string | null;
|
|
80
|
+
thinking: "off" | "minimal" | "low" | "medium" | "high";
|
|
81
|
+
usageBy: {
|
|
82
|
+
summary: {
|
|
83
|
+
input: number;
|
|
84
|
+
output: number;
|
|
85
|
+
cacheRead: number;
|
|
86
|
+
cacheWrite: number;
|
|
87
|
+
cost: number;
|
|
88
|
+
};
|
|
89
|
+
title: {
|
|
90
|
+
input: number;
|
|
91
|
+
output: number;
|
|
92
|
+
cacheRead: number;
|
|
93
|
+
cacheWrite: number;
|
|
94
|
+
cost: number;
|
|
95
|
+
};
|
|
96
|
+
helpers: {
|
|
97
|
+
input: number;
|
|
98
|
+
output: number;
|
|
99
|
+
cacheRead: number;
|
|
100
|
+
cacheWrite: number;
|
|
101
|
+
cost: number;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
stepJobId: string | null;
|
|
105
|
+
stepGeneration: number;
|
|
106
|
+
stepIntentId: string | null;
|
|
107
|
+
turnId: string | null;
|
|
108
|
+
endedTurns: number;
|
|
109
|
+
nextSeq: number;
|
|
110
|
+
usage: {
|
|
111
|
+
input: number;
|
|
112
|
+
output: number;
|
|
113
|
+
cacheRead: number;
|
|
114
|
+
cacheWrite: number;
|
|
115
|
+
cost: number;
|
|
116
|
+
};
|
|
117
|
+
durationMs: number;
|
|
118
|
+
checks: {
|
|
119
|
+
name: string;
|
|
120
|
+
passed: boolean;
|
|
121
|
+
}[] | null;
|
|
122
|
+
connectors: string[] | null;
|
|
123
|
+
optedIn: string[];
|
|
124
|
+
createdAt: string;
|
|
125
|
+
updatedAt: string;
|
|
126
|
+
}>;
|
|
127
|
+
connectors: {
|
|
128
|
+
name: string;
|
|
129
|
+
description: string;
|
|
130
|
+
owner: string;
|
|
131
|
+
kind: "commands" | "binary";
|
|
132
|
+
optIn: boolean;
|
|
133
|
+
commands?: {
|
|
134
|
+
name: string;
|
|
135
|
+
command: string;
|
|
136
|
+
examples: {
|
|
137
|
+
description: string;
|
|
138
|
+
input: import("zod").JSONType;
|
|
139
|
+
}[];
|
|
140
|
+
asks: boolean;
|
|
141
|
+
}[];
|
|
142
|
+
binary?: {
|
|
143
|
+
check: string;
|
|
144
|
+
install?: string;
|
|
145
|
+
help?: string;
|
|
146
|
+
};
|
|
147
|
+
}[];
|
|
148
|
+
disabled: Set<string>;
|
|
149
|
+
names: string[];
|
|
150
|
+
workers: ({
|
|
151
|
+
kind: "opencode";
|
|
152
|
+
model: string | null;
|
|
153
|
+
agent: string | null;
|
|
154
|
+
autoApprove: boolean;
|
|
155
|
+
approval: "ask" | "auto";
|
|
156
|
+
timeoutMs: number;
|
|
157
|
+
name: string;
|
|
158
|
+
description: string;
|
|
159
|
+
enabled: boolean;
|
|
160
|
+
instructions: string;
|
|
161
|
+
} | {
|
|
162
|
+
kind: "claude";
|
|
163
|
+
model: string | null;
|
|
164
|
+
effort: "low" | "medium" | "high" | "xhigh" | "max" | null;
|
|
165
|
+
permissionMode: "auto" | "bypassPermissions" | "dontAsk" | "acceptEdits" | "plan";
|
|
166
|
+
approval: "ask" | "auto";
|
|
167
|
+
timeoutMs: number;
|
|
168
|
+
name: string;
|
|
169
|
+
description: string;
|
|
170
|
+
enabled: boolean;
|
|
171
|
+
instructions: string;
|
|
172
|
+
} | {
|
|
173
|
+
kind: "subagent";
|
|
174
|
+
readOnly: boolean;
|
|
175
|
+
connectors: string[] | null;
|
|
176
|
+
model: string | null;
|
|
177
|
+
thinking: "off" | "minimal" | "low" | "medium" | "high" | null;
|
|
178
|
+
name: string;
|
|
179
|
+
description: string;
|
|
180
|
+
enabled: boolean;
|
|
181
|
+
instructions: string;
|
|
182
|
+
} | {
|
|
183
|
+
kind: "pi";
|
|
184
|
+
model: string | null;
|
|
185
|
+
thinking: "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | null;
|
|
186
|
+
tools: string[] | null;
|
|
187
|
+
approval: "ask" | "auto";
|
|
188
|
+
timeoutMs: number;
|
|
189
|
+
name: string;
|
|
190
|
+
description: string;
|
|
191
|
+
enabled: boolean;
|
|
192
|
+
instructions: string;
|
|
193
|
+
})[];
|
|
194
|
+
servers: ({
|
|
195
|
+
name: string;
|
|
196
|
+
description: string;
|
|
197
|
+
command: string;
|
|
198
|
+
args: string[];
|
|
199
|
+
env: string[];
|
|
200
|
+
} | {
|
|
201
|
+
name: string;
|
|
202
|
+
description: string;
|
|
203
|
+
url: string;
|
|
204
|
+
headers: string[];
|
|
205
|
+
})[];
|
|
206
|
+
} | undefined;
|
|
207
|
+
export type SessionGrants = NonNullable<ReturnType<typeof grantsInTx>>;
|
|
208
|
+
export declare function sessionGrants(ctx: Ctx, sessionId: string): Promise<SessionGrants | undefined>;
|
|
209
|
+
//# sourceMappingURL=session-grants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-grants.d.ts","sourceRoot":"","sources":["../../src/prompt/session-grants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAM9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAYpE,gGAAgG;AAChG,wBAAsB,aAAa,CAAC,GAAG,EAAE,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAM3C;AACD,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC;AAEzE,qGAAqG;AACrG,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAenG;AACD,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC;AAEvE,wBAAsB,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAMnG"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { builtinConnectors } from "../connector-call.js";
|
|
2
|
+
import { isProgram, listedWorkers, workerCheckName } from "../delegate/workers.js";
|
|
3
|
+
import { mcpServers } from "../mcp/servers.js";
|
|
4
|
+
import { connectorsInTx, prepareConnectors } from "../registry/register-connectors.js";
|
|
5
|
+
import { disabledConnectors } from "../register-settings.js";
|
|
6
|
+
import { executionRootInTx } from "../sessions/execution-root.js";
|
|
7
|
+
import { txRecords } from "../store/collections.js";
|
|
8
|
+
const leadOnly = new Set(['ask', 'delegate', 'execution-map']);
|
|
9
|
+
/** The existing connector scope predicate, shared by prompt and execution (ADR0044). */
|
|
10
|
+
function allowedNames(session, connectors, disabled) {
|
|
11
|
+
const names = [...builtinConnectors, ...connectors.map(connector => connector.name)].filter(name => !disabled.has(name));
|
|
12
|
+
if (session.parentId === null)
|
|
13
|
+
return new Set(names);
|
|
14
|
+
// A helper hands work to no one, asks the person nothing (ADR 0063, 2), and keeps no map: the lead's is the chat's (ADR 0064, 1).
|
|
15
|
+
return new Set(names.filter(name => !leadOnly.has(name) && (session.connectors === null || session.connectors.includes(name))));
|
|
16
|
+
}
|
|
17
|
+
/** Await external data before the caller's final canonical store validation, not afterwards. */
|
|
18
|
+
export async function prepareGrants(ctx) {
|
|
19
|
+
const connectors = await prepareConnectors(ctx);
|
|
20
|
+
const servers = await mcpServers(ctx);
|
|
21
|
+
const workers = await listedWorkers(ctx);
|
|
22
|
+
const disabled = await disabledConnectors(ctx);
|
|
23
|
+
return { connectors, servers, workers, disabled };
|
|
24
|
+
}
|
|
25
|
+
/** Canonical session/root/registry grant decision in the SAME tx as the caller's authority proof. */
|
|
26
|
+
export function grantsInTx(store, session, prepared) {
|
|
27
|
+
const root = executionRootInTx(store, session.id);
|
|
28
|
+
if (root === undefined)
|
|
29
|
+
return undefined;
|
|
30
|
+
const connectors = connectorsInTx(store, prepared.connectors);
|
|
31
|
+
const disabled = new Set([...prepared.disabled, ...connectors.filter(connector => connector.optIn && !root.optedIn.includes(connector.name)).map(connector => connector.name)]);
|
|
32
|
+
const allowed = allowedNames(session, connectors, disabled);
|
|
33
|
+
const passed = new Set((session.checks ?? []).filter(check => check.passed).map(check => check.name));
|
|
34
|
+
const workers = prepared.workers.filter(worker => worker.enabled && (!isProgram(worker) || passed.has(workerCheckName(worker.name))));
|
|
35
|
+
const servers = prepared.servers;
|
|
36
|
+
const present = { mcp: servers.length > 0, delegate: workers.length > 0 };
|
|
37
|
+
const names = [
|
|
38
|
+
...builtinConnectors.filter(name => allowed.has(name) && present[name] !== false),
|
|
39
|
+
...connectors.filter(connector => allowed.has(connector.name) && (connector.kind === 'commands' || passed.has(connector.name))).map(connector => connector.name),
|
|
40
|
+
];
|
|
41
|
+
return { session, connectors, disabled, names, workers, servers };
|
|
42
|
+
}
|
|
43
|
+
export async function sessionGrants(ctx, sessionId) {
|
|
44
|
+
const prepared = await prepareGrants(ctx);
|
|
45
|
+
return ctx.store.transaction(tx => {
|
|
46
|
+
const store = txRecords(tx), session = store.sessions.get(sessionId);
|
|
47
|
+
return session === undefined ? undefined : grantsInTx(store, session, prepared);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=session-grants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-grants.js","sourceRoot":"","sources":["../../src/prompt/session-grants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAqB,MAAM,oCAAoC,CAAC;AAC1G,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,SAAS,EAAkB,MAAM,yBAAyB,CAAC;AAEpE,MAAM,QAAQ,GAAwB,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC;AAEpF,wFAAwF;AACxF,SAAS,YAAY,CAAC,OAAmB,EAAE,UAAmC,EAAE,QAA6B;IAC3G,MAAM,KAAK,GAAG,CAAC,GAAG,iBAAiB,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACzH,IAAI,OAAO,CAAC,QAAQ,KAAK,IAAI;QAAE,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IACrD,kIAAkI;IAClI,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,C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OAAO,EAAE,CAAC;AACpE,CAAC;AAGD,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,GAAQ,EAAE,SAAiB;IAC7D,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC;IAC1C,OAAO,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE;QAChC,MAAM,KAAK,GAAG,SAAS,CAAC,EAAE,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACrE,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAClF,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Ctx, type Stored } from '@kvman/sdk';
|
|
2
2
|
import type { ShellCommand } from '../calls/shell-command.ts';
|
|
3
|
-
import {
|
|
3
|
+
import type { ConnectorRow } from '../registry/register-connectors.ts';
|
|
4
4
|
import type { SessionDoc } from '../schemas/records.ts';
|
|
5
5
|
import { type BuiltPrompt } from './build-prompt.ts';
|
|
6
6
|
/** A connector the session's agent can call: its entry in the prompt's index and in the `run` tool's enum. */
|
|
@@ -17,8 +17,9 @@ export type SessionTools = {
|
|
|
17
17
|
connectors: ConnectorRow[];
|
|
18
18
|
/** The connectors the session may call, in the prompt's order. */
|
|
19
19
|
listed: ListedConnector[];
|
|
20
|
-
/**
|
|
20
|
+
/** Disabled names, including optIn connectors this chat never enabled. */
|
|
21
21
|
disabled: ReadonlySet<string>;
|
|
22
22
|
};
|
|
23
|
+
/** Prompt-time listing shares the execution predicate but never serves as later execution authority (ADR0044). */
|
|
23
24
|
export declare function sessionTools(ctx: Ctx, session: Stored<SessionDoc>): Promise<SessionTools>;
|
|
24
25
|
//# sourceMappingURL=session-prompt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-prompt.d.ts","sourceRoot":"","sources":["../../src/prompt/session-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAK,KAAK,GAAG,EAAE,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"session-prompt.d.ts","sourceRoot":"","sources":["../../src/prompt/session-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAK,KAAK,GAAG,EAAE,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAM9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAKvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGlE,8GAA8G;AAC9G,MAAM,MAAM,eAAe,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAExH,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,WAAW,CAAC;IACnB,KAAK,EAAE,YAAY,CAAC;IACpB,8DAA8D;IAC9D,UAAU,EAAE,YAAY,EAAE,CAAC;IAC3B,kEAAkE;IAClE,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,0EAA0E;IAC1E,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC/B,CAAC;AAEF,kHAAkH;AAClH,wBAAsB,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CA+B/F"}
|
|
@@ -4,58 +4,42 @@ import { shellFor } from "../calls/shell-program.js";
|
|
|
4
4
|
import { builtinConnectors } from "../connector-call.js";
|
|
5
5
|
import { delegateIndexDescription } from "../connectors/delegate.js";
|
|
6
6
|
import { mcpIndexDescription } from "../connectors/mcp.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { disabledConnectors } from "../register-settings.js";
|
|
7
|
+
import { projectRules } from "./project-rules.js";
|
|
8
|
+
import { helperAllows } from "../turns/helper-calls.js";
|
|
9
|
+
import { readOnlyAllows } from "../turns/read-only.js";
|
|
11
10
|
import { sectionsFor } from "../registry/register-sections.js";
|
|
12
|
-
import {
|
|
11
|
+
import { invalid } from "../problems.js";
|
|
13
12
|
import { buildPrompt } from "./build-prompt.js";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
function allowedNames(session, connectors, disabled) {
|
|
17
|
-
const names = [...builtinConnectors, ...connectors.map((connector) => connector.name)].filter((name) => !disabled.has(name));
|
|
18
|
-
if (session.parentId === null)
|
|
19
|
-
return new Set(names);
|
|
20
|
-
return new Set(names.filter((name) => name === 'ask' || (name !== 'delegate' && (session.connectors === null || session.connectors.includes(name)))));
|
|
21
|
-
}
|
|
22
|
-
// The chat (a subagent's top-level session) a session's optIn connectors are taken from, walking `parentId` up (ADR 0027, 10).
|
|
23
|
-
async function topLevelSession(ctx, session) {
|
|
24
|
-
let current = session;
|
|
25
|
-
while (current.parentId !== null) {
|
|
26
|
-
const parent = await records(ctx.store).sessions.get(current.parentId);
|
|
27
|
-
if (parent === undefined)
|
|
28
|
-
return current;
|
|
29
|
-
current = parent;
|
|
30
|
-
}
|
|
31
|
-
return current;
|
|
32
|
-
}
|
|
13
|
+
import { sessionGrants } from "./session-grants.js";
|
|
14
|
+
/** Prompt-time listing shares the execution predicate but never serves as later execution authority (ADR0044). */
|
|
33
15
|
export async function sessionTools(ctx, session) {
|
|
16
|
+
const rules = projectRules(ctx.job.workspace.path);
|
|
34
17
|
const shell = await shellFor(ctx);
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
const allowed = allowedNames(session, connectors, disabled);
|
|
40
|
-
const passed = new Set((session.checks ?? []).filter((check) => check.passed).map((check) => check.name));
|
|
41
|
-
const servers = await mcpServers(ctx);
|
|
42
|
-
const workers = await availableWorkers(ctx, session.checks);
|
|
18
|
+
const grants = await sessionGrants(ctx, session.id);
|
|
19
|
+
if (grants === undefined)
|
|
20
|
+
throw invalid('The session ancestry is no longer available.');
|
|
21
|
+
const { connectors, disabled, names, workers, servers } = grants;
|
|
43
22
|
const descriptions = { ...builtinDescriptions(shell.kind), delegate: delegateIndexDescription(workers), mcp: mcpIndexDescription(servers) };
|
|
44
|
-
const
|
|
23
|
+
const current = grants.session;
|
|
24
|
+
// A helper is shown only what it may run (ADR 0063, 1), and a read-only worker's helper less (ADR 0056, 4).
|
|
25
|
+
const readOnly = current.worker?.readOnly === true;
|
|
26
|
+
const helper = current.parentId !== null;
|
|
27
|
+
const builtins = builtinConnectors.filter(name => names.includes(name)).map(name => {
|
|
28
|
+
const shown = Object.entries(commandsOf(name)).map(([command, entry], index) => ({ command, signature: builtinSignatures[name][index] ?? '', allowed: (!helper || helperAllows(entry)) && (!readOnly || readOnlyAllows(command, entry)) })).filter(row => row.allowed);
|
|
29
|
+
return { name, description: descriptions[name], commands: shown.map(row => row.command), signatures: shown.map(row => row.signature) };
|
|
30
|
+
});
|
|
45
31
|
const listed = [
|
|
46
|
-
...
|
|
47
|
-
...connectors
|
|
48
|
-
.filter((connector) => allowed.has(connector.name) && (connector.kind === 'commands' || passed.has(connector.name)))
|
|
49
|
-
.map((connector) => ({ name: connector.name, description: connector.description, commands: connector.commands?.map((command) => command.name) ?? ['exec'] })),
|
|
32
|
+
...builtins.filter(connector => connector.commands.length > 0),
|
|
33
|
+
...(readOnly ? [] : connectors.filter(connector => names.includes(connector.name)).map(connector => ({ name: connector.name, description: connector.description, commands: connector.commands?.map(command => command.name) ?? ['exec'] }))),
|
|
50
34
|
];
|
|
51
35
|
const built = buildPrompt({
|
|
52
|
-
role:
|
|
36
|
+
role: current.parentId === null ? 'lead' : 'worker',
|
|
53
37
|
workspacePath: ctx.job.workspace.path,
|
|
54
38
|
platform: process.platform,
|
|
55
39
|
shell: shell.kind,
|
|
56
40
|
language: z.string().parse(await ctx.settings.get('kernel.language')),
|
|
57
|
-
sections: await sectionsFor(ctx,
|
|
58
|
-
...(
|
|
41
|
+
sections: [...(await sectionsFor(ctx, current.id)), ...(await rules)],
|
|
42
|
+
...(current.worker === null ? {} : { worker: current.worker }),
|
|
59
43
|
connectors: listed,
|
|
60
44
|
});
|
|
61
45
|
for (const section of built.left)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-prompt.js","sourceRoot":"","sources":["../../src/prompt/session-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAyB,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAEzG,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"session-prompt.js","sourceRoot":"","sources":["../../src/prompt/session-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAyB,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAEzG,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,C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AAO,CAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;IACvJ,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACxD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"working-method.d.ts","sourceRoot":"","sources":["../../src/prompt/working-method.ts"],"names":[],"mappings":"AAGA,wFAAwF;AACxF,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"working-method.d.ts","sourceRoot":"","sources":["../../src/prompt/working-method.ts"],"names":[],"mappings":"AAGA,wFAAwF;AACxF,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,QAAQ,CAAC;AAmDrC,0EAA0E;AAC1E,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAG9D;AAED,0CAA0C;AAC1C,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAEhD"}
|