@anchrd/intel 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +496 -0
- package/bin/intel.mjs +134 -0
- package/dist/adapters/cloudflare/cloudflare-flow-workflow.d.ts +42 -0
- package/dist/adapters/cloudflare/cloudflare-flow-workflow.js +89 -0
- package/dist/adapters/cloudflare/cloudflare.d.ts +29 -0
- package/dist/adapters/cloudflare/cloudflare.js +416 -0
- package/dist/adapters/cloudflare/cloudflare.types.d.ts +31 -0
- package/dist/adapters/cloudflare/cloudflare.types.js +1 -0
- package/dist/adapters/content/content.d.ts +3 -0
- package/dist/adapters/content/content.js +128 -0
- package/dist/adapters/content/content.types.d.ts +38 -0
- package/dist/adapters/content/content.types.js +1 -0
- package/dist/adapters/db/db-audit.d.ts +62 -0
- package/dist/adapters/db/db-audit.js +150 -0
- package/dist/adapters/db/db-boards.d.ts +6 -0
- package/dist/adapters/db/db-boards.js +324 -0
- package/dist/adapters/db/db-feed.d.ts +30 -0
- package/dist/adapters/db/db-feed.js +276 -0
- package/dist/adapters/db/db-flows.d.ts +42 -0
- package/dist/adapters/db/db-flows.js +1311 -0
- package/dist/adapters/db/db-grants.d.ts +133 -0
- package/dist/adapters/db/db-grants.js +269 -0
- package/dist/adapters/db/db-indexing.d.ts +3 -0
- package/dist/adapters/db/db-indexing.js +200 -0
- package/dist/adapters/db/db-oauth.d.ts +3 -0
- package/dist/adapters/db/db-oauth.js +26 -0
- package/dist/adapters/db/db-prompts.d.ts +46 -0
- package/dist/adapters/db/db-prompts.js +144 -0
- package/dist/adapters/db/db.d.ts +6 -0
- package/dist/adapters/db/db.js +1687 -0
- package/dist/adapters/db/db.types.d.ts +16 -0
- package/dist/adapters/db/db.types.js +1 -0
- package/dist/adapters/document-converter/document-converter.d.ts +2 -0
- package/dist/adapters/document-converter/document-converter.js +26 -0
- package/dist/adapters/document-converter/document-converter.types.d.ts +17 -0
- package/dist/adapters/document-converter/document-converter.types.js +1 -0
- package/dist/adapters/flow-runtime/flow-runtime.d.ts +3 -0
- package/dist/adapters/flow-runtime/flow-runtime.js +22 -0
- package/dist/adapters/flow-runtime/flow-runtime.types.d.ts +19 -0
- package/dist/adapters/flow-runtime/flow-runtime.types.js +1 -0
- package/dist/adapters/index-queue/index-queue.d.ts +10 -0
- package/dist/adapters/index-queue/index-queue.js +12 -0
- package/dist/adapters/index-queue/index-queue.types.d.ts +11 -0
- package/dist/adapters/index-queue/index-queue.types.js +1 -0
- package/dist/adapters/json-schema/json-schema.d.ts +2 -0
- package/dist/adapters/json-schema/json-schema.js +77 -0
- package/dist/adapters/openid/openid.d.ts +5 -0
- package/dist/adapters/openid/openid.js +301 -0
- package/dist/adapters/portal-tokens/portal-tokens.d.ts +8 -0
- package/dist/adapters/portal-tokens/portal-tokens.js +79 -0
- package/dist/adapters/remote-tools/remote-tools.d.ts +5 -0
- package/dist/adapters/remote-tools/remote-tools.js +129 -0
- package/dist/adapters/semantic-index/semantic-index.d.ts +2 -0
- package/dist/adapters/semantic-index/semantic-index.js +139 -0
- package/dist/adapters/semantic-index/semantic-index.types.d.ts +56 -0
- package/dist/adapters/semantic-index/semantic-index.types.js +1 -0
- package/dist/adapters/session-cookie/session-cookie.d.ts +5 -0
- package/dist/adapters/session-cookie/session-cookie.js +87 -0
- package/dist/adapters/tool-source-policy/tool-source-policy.d.ts +1 -0
- package/dist/adapters/tool-source-policy/tool-source-policy.js +22 -0
- package/dist/audit/audit.d.ts +2 -0
- package/dist/audit/audit.js +87 -0
- package/dist/audit/audit.types.d.ts +23 -0
- package/dist/audit/audit.types.js +1 -0
- package/dist/auth/auth.d.ts +2 -0
- package/dist/auth/auth.js +284 -0
- package/dist/auth/auth.types.d.ts +108 -0
- package/dist/auth/auth.types.js +1 -0
- package/dist/boards/boards.d.ts +44 -0
- package/dist/boards/boards.js +447 -0
- package/dist/boards/boards.types.d.ts +117 -0
- package/dist/boards/boards.types.js +1 -0
- package/dist/build/build.d.ts +2 -0
- package/dist/build/build.js +192 -0
- package/dist/build/build.types.d.ts +17 -0
- package/dist/build/build.types.js +1 -0
- package/dist/bundle/bundle.d.ts +4 -0
- package/dist/bundle/bundle.js +1194 -0
- package/dist/bundle/bundle.types.d.ts +33 -0
- package/dist/bundle/bundle.types.js +1 -0
- package/dist/cli/cli.d.ts +4 -0
- package/dist/cli/cli.js +262 -0
- package/dist/cli/cli.types.d.ts +14 -0
- package/dist/cli/cli.types.js +1 -0
- package/dist/contract/audit.d.ts +50 -0
- package/dist/contract/audit.js +72 -0
- package/dist/contract/board.d.ts +150 -0
- package/dist/contract/board.js +262 -0
- package/dist/contract/bundle.d.ts +147 -0
- package/dist/contract/bundle.js +139 -0
- package/dist/contract/contract.d.ts +112 -0
- package/dist/contract/contract.js +143 -0
- package/dist/contract/feed.d.ts +126 -0
- package/dist/contract/feed.js +149 -0
- package/dist/contract/flow-run.d.ts +346 -0
- package/dist/contract/flow-run.js +194 -0
- package/dist/contract/flow.d.ts +1057 -0
- package/dist/contract/flow.js +552 -0
- package/dist/contract/node.d.ts +551 -0
- package/dist/contract/node.js +456 -0
- package/dist/contract/share.d.ts +216 -0
- package/dist/contract/share.js +134 -0
- package/dist/contract/table.d.ts +171 -0
- package/dist/contract/table.js +117 -0
- package/dist/contract/tool.d.ts +122 -0
- package/dist/contract/tool.js +172 -0
- package/dist/feed/feed.d.ts +2 -0
- package/dist/feed/feed.js +77 -0
- package/dist/feed/feed.types.d.ts +23 -0
- package/dist/feed/feed.types.js +1 -0
- package/dist/flows/flows.d.ts +41 -0
- package/dist/flows/flows.js +2216 -0
- package/dist/flows/flows.types.d.ts +339 -0
- package/dist/flows/flows.types.js +1 -0
- package/dist/http/http.d.ts +9 -0
- package/dist/http/http.js +874 -0
- package/dist/http/http.types.d.ts +22 -0
- package/dist/http/http.types.js +1 -0
- package/dist/indexing/indexing.d.ts +6 -0
- package/dist/indexing/indexing.js +239 -0
- package/dist/indexing/indexing.types.d.ts +11 -0
- package/dist/indexing/indexing.types.js +1 -0
- package/dist/intel/intel.d.ts +3 -0
- package/dist/intel/intel.js +194 -0
- package/dist/intel/intel.types.d.ts +24 -0
- package/dist/intel/intel.types.js +1 -0
- package/dist/mcp/mcp.d.ts +2 -0
- package/dist/mcp/mcp.js +1292 -0
- package/dist/mcp/mcp.types.d.ts +25 -0
- package/dist/mcp/mcp.types.js +1 -0
- package/dist/nodes/document-links/document-links.d.ts +20 -0
- package/dist/nodes/document-links/document-links.js +57 -0
- package/dist/nodes/nodes.d.ts +2 -0
- package/dist/nodes/nodes.js +1667 -0
- package/dist/nodes/nodes.types.d.ts +511 -0
- package/dist/nodes/nodes.types.js +1 -0
- package/dist/prepare/prepare.d.ts +4 -0
- package/dist/prepare/prepare.js +16 -0
- package/dist/prepare/prepare.types.d.ts +9 -0
- package/dist/prepare/prepare.types.js +1 -0
- package/dist/prompts/prompts.d.ts +2 -0
- package/dist/prompts/prompts.js +65 -0
- package/dist/prompts/prompts.types.d.ts +71 -0
- package/dist/prompts/prompts.types.js +1 -0
- package/dist/shared/callers/callers.d.ts +28 -0
- package/dist/shared/callers/callers.js +30 -0
- package/dist/shared/csv/csv.d.ts +13 -0
- package/dist/shared/csv/csv.js +85 -0
- package/dist/shared/document-text/document-text.d.ts +21 -0
- package/dist/shared/document-text/document-text.js +31 -0
- package/dist/shared/gate-authorization/gate-authorization.d.ts +5 -0
- package/dist/shared/gate-authorization/gate-authorization.js +26 -0
- package/dist/shared/grant-expiry/grant-expiry.d.ts +19 -0
- package/dist/shared/grant-expiry/grant-expiry.js +26 -0
- package/dist/shared/intel-error/intel-error.d.ts +22 -0
- package/dist/shared/intel-error/intel-error.js +27 -0
- package/dist/shared/plain-title/plain-title.d.ts +16 -0
- package/dist/shared/plain-title/plain-title.js +45 -0
- package/dist/shared/problem-details/problem-details.d.ts +30 -0
- package/dist/shared/problem-details/problem-details.js +18 -0
- package/dist/shared/report-unexpected-error/report-unexpected-error.d.ts +1 -0
- package/dist/shared/report-unexpected-error/report-unexpected-error.js +37 -0
- package/dist/shared/safe-return-path/safe-return-path.d.ts +2 -0
- package/dist/shared/safe-return-path/safe-return-path.js +11 -0
- package/dist/shared/sha256/sha256.d.ts +2 -0
- package/dist/shared/sha256/sha256.js +14 -0
- package/dist/tools/tool-servers/tool-servers.d.ts +46 -0
- package/dist/tools/tool-servers/tool-servers.js +177 -0
- package/dist/tools/tools.d.ts +2 -0
- package/dist/tools/tools.js +207 -0
- package/dist/tools/tools.types.d.ts +56 -0
- package/dist/tools/tools.types.js +1 -0
- package/examples/branding/favicon.svg +5 -0
- package/examples/branding/logo.svg +5 -0
- package/examples/branding/theme.css +16 -0
- package/examples/dev.vars.example +7 -0
- package/examples/intel.json +9 -0
- package/migrations/0000_intel_foundation.sql +203 -0
- package/migrations/0001_portal_native_tools.sql +21 -0
- package/migrations/0002_flows_in_the_knowledge_tree.sql +34 -0
- package/migrations/0003_folder_permissions.sql +211 -0
- package/migrations/0004_subflow_runs.sql +14 -0
- package/migrations/0005_flow_node_cleanup.sql +28 -0
- package/migrations/0005_tables_in_the_knowledge_tree.sql +68 -0
- package/migrations/0006_links_are_written_in_the_text.sql +20 -0
- package/migrations/0007_no_node_waits.sql +69 -0
- package/migrations/0008_three_layers.sql +130 -0
- package/migrations/0009_no_context_policy.sql +48 -0
- package/migrations/0010_no_run_waits_a_year.sql +27 -0
- package/migrations/0011_one_name_for_the_tree.sql +53 -0
- package/migrations/0012_table_snapshots.sql +29 -0
- package/migrations/0017_a_vector_per_card.sql +38 -0
- package/migrations/0018_no_context_policy_at_last.sql +97 -0
- package/migrations/0019_one_name_for_the_grants.sql +52 -0
- package/migrations/0020_cascade_purge_replay.sql +11 -0
- package/migrations/0021_a_flow_carries_its_own_grant.sql +44 -0
- package/migrations/0022_a_cursor_over_the_journal.sql +14 -0
- package/migrations/0023_a_board_and_its_tasks.sql +116 -0
- package/migrations/0024_the_archive_is_a_column.sql +33 -0
- package/migrations/0025_archiving_takes_the_subtree.sql +29 -0
- package/migrations/0026_one_feed_over_two_kinds.sql +23 -0
- package/migrations/0027_the_runs_of_every_flow.sql +27 -0
- package/migrations/0028_a_prompt_name_over_two_kinds.sql +70 -0
- package/package.json +118 -0
- package/src/contract/CLAUDE.md +152 -0
- package/src/contract/README.md +102 -0
- package/src/contract/audit.ts +85 -0
- package/src/contract/board.ts +306 -0
- package/src/contract/bundle.ts +157 -0
- package/src/contract/contract.ts +161 -0
- package/src/contract/feed.ts +165 -0
- package/src/contract/flow-run.ts +241 -0
- package/src/contract/flow.ts +675 -0
- package/src/contract/node.ts +583 -0
- package/src/contract/share.ts +196 -0
- package/src/contract/table.ts +178 -0
- package/src/contract/tool.ts +202 -0
- package/ui/README.md +110 -0
- package/ui/components.json +21 -0
- package/ui/index.html +13 -0
- package/ui/package.json +11 -0
- package/ui/scripts/lint-tokens.mjs +187 -0
- package/ui/src/access-summary/access-summary.tsx +385 -0
- package/ui/src/app/action-slot/action-slot.tsx +27 -0
- package/ui/src/app/app-sidebar/app-sidebar.tsx +71 -0
- package/ui/src/app/app-tree/app-tree.tsx +1175 -0
- package/ui/src/app/app.tsx +87 -0
- package/ui/src/app/header-search/header-search.tsx +294 -0
- package/ui/src/app/reindex-dialog/reindex-dialog.tsx +79 -0
- package/ui/src/app/settings-dialog/settings-dialog.tsx +135 -0
- package/ui/src/app/sidebar-preferences/sidebar-preferences.ts +68 -0
- package/ui/src/app/sidebar-preferences/sidebar-preferences.types.ts +15 -0
- package/ui/src/app/sidebar-resize-handle/sidebar-resize-handle.tsx +86 -0
- package/ui/src/app/tree-expansion/tree-expansion.ts +107 -0
- package/ui/src/app/tree-expansion/tree-expansion.types.ts +31 -0
- package/ui/src/app/tree-move/tree-move.tsx +427 -0
- package/ui/src/app/tree-reveal/tree-reveal.ts +64 -0
- package/ui/src/app/tree-reveal/tree-reveal.types.ts +16 -0
- package/ui/src/app/user-footer/user-footer.tsx +188 -0
- package/ui/src/app/view-menu/view-menu.tsx +115 -0
- package/ui/src/app-root/app-root.tsx +109 -0
- package/ui/src/app-root/app-root.types.ts +27 -0
- package/ui/src/archive/archive.tsx +417 -0
- package/ui/src/attachment-detail/attachment-detail.ts +52 -0
- package/ui/src/attachment-viewer/attachment-viewer.tsx +166 -0
- package/ui/src/blocknote-view/blocknote-view.tsx +30 -0
- package/ui/src/board/board-assignee/board-assignee-picker.tsx +132 -0
- package/ui/src/board/board-assignee/board-assignee.ts +48 -0
- package/ui/src/board/board-assignee/board-assignee.tsx +75 -0
- package/ui/src/board/board-chip/board-chip.tsx +46 -0
- package/ui/src/board/board-crumbs/board-crumbs.ts +56 -0
- package/ui/src/board/board-crumbs/board-crumbs.tsx +111 -0
- package/ui/src/board/board-data/board-data.ts +195 -0
- package/ui/src/board/board-data/board-data.types.ts +38 -0
- package/ui/src/board/board-dates/board-dates.ts +40 -0
- package/ui/src/board/board-dates/board-dates.tsx +105 -0
- package/ui/src/board/board-kanban/board-kanban.ts +162 -0
- package/ui/src/board/board-kanban/board-kanban.tsx +680 -0
- package/ui/src/board/board-open-task/board-open-task.ts +32 -0
- package/ui/src/board/board-panel/board-panel.tsx +259 -0
- package/ui/src/board/board-settings/board-settings.tsx +226 -0
- package/ui/src/board/board-status/board-status.tsx +60 -0
- package/ui/src/board/board-stripes/board-stripes.ts +128 -0
- package/ui/src/board/board-table/board-table.ts +53 -0
- package/ui/src/board/board-table/board-table.tsx +610 -0
- package/ui/src/board/board-task/board-task.ts +108 -0
- package/ui/src/board/board-task/board-task.tsx +335 -0
- package/ui/src/board/board-title-row/board-title-row.tsx +66 -0
- package/ui/src/branding/branding.tsx +17 -0
- package/ui/src/branding/custom-logo.ts +1 -0
- package/ui/src/branding/favicon.default.svg +5 -0
- package/ui/src/branding/favicon.svg +5 -0
- package/ui/src/components/ui/avatar.tsx +39 -0
- package/ui/src/components/ui/button.tsx +64 -0
- package/ui/src/components/ui/collapsible.tsx +20 -0
- package/ui/src/components/ui/command.tsx +160 -0
- package/ui/src/components/ui/dialog.tsx +143 -0
- package/ui/src/components/ui/dropdown-menu.tsx +187 -0
- package/ui/src/components/ui/input.tsx +21 -0
- package/ui/src/components/ui/popover.tsx +41 -0
- package/ui/src/components/ui/select.tsx +163 -0
- package/ui/src/components/ui/separator.tsx +26 -0
- package/ui/src/components/ui/sheet.tsx +136 -0
- package/ui/src/components/ui/sidebar.tsx +693 -0
- package/ui/src/components/ui/skeleton.tsx +13 -0
- package/ui/src/components/ui/switch.tsx +25 -0
- package/ui/src/components/ui/table.tsx +82 -0
- package/ui/src/components/ui/tabs.tsx +52 -0
- package/ui/src/components/ui/tooltip.tsx +51 -0
- package/ui/src/data/intel-data-provider/intel-data-provider.ts +685 -0
- package/ui/src/data/intel-data-provider/intel-data-provider.types.ts +266 -0
- package/ui/src/data/query-client.ts +18 -0
- package/ui/src/data/request-refusal/refusal-notice.tsx +36 -0
- package/ui/src/data/request-refusal/request-refusal.ts +51 -0
- package/ui/src/data/sign-in/sign-in.ts +97 -0
- package/ui/src/data/sign-in/sign-in.types.ts +15 -0
- package/ui/src/document-link/document-link.tsx +114 -0
- package/ui/src/document-markdown/document-markdown.ts +195 -0
- package/ui/src/editor-schema/editor-schema.ts +23 -0
- package/ui/src/entry-picker/entry-picker.tsx +238 -0
- package/ui/src/feed/feed.tsx +344 -0
- package/ui/src/file-preview/file-preview-view.tsx +496 -0
- package/ui/src/file-preview/file-preview.tsx +28 -0
- package/ui/src/file-preview/pdf-file-preview.tsx +5 -0
- package/ui/src/file-preview/presentation-file-preview.tsx +21 -0
- package/ui/src/file-preview/spreadsheet-file-preview.tsx +5 -0
- package/ui/src/file-preview/word-file-preview.tsx +5 -0
- package/ui/src/flow-runs/flow-runs.tsx +238 -0
- package/ui/src/flows/flows.tsx +1646 -0
- package/ui/src/flows/node-icon/node-icon.ts +34 -0
- package/ui/src/flows/node-palette/node-palette.tsx +214 -0
- package/ui/src/flows/node-palette/node-palette.types.ts +15 -0
- package/ui/src/folder-contents/folder-contents.tsx +321 -0
- package/ui/src/folder-index/folder-index.ts +55 -0
- package/ui/src/frontmatter/frontmatter.tsx +193 -0
- package/ui/src/graph-pane/graph-pane.tsx +53 -0
- package/ui/src/hooks/use-mobile.ts +19 -0
- package/ui/src/i18n/custom.json +4 -0
- package/ui/src/i18n/de.json +609 -0
- package/ui/src/i18n/en.json +609 -0
- package/ui/src/i18n/es.json +609 -0
- package/ui/src/i18n/i18n-context.tsx +65 -0
- package/ui/src/i18n/i18n-languages/i18n-languages.ts +83 -0
- package/ui/src/i18n/i18n.ts +32 -0
- package/ui/src/i18n/i18n.types.ts +49 -0
- package/ui/src/kind-icon.ts +97 -0
- package/ui/src/lib/utils.ts +6 -0
- package/ui/src/main.tsx +68 -0
- package/ui/src/modal/modal.tsx +53 -0
- package/ui/src/node-details/node-details.tsx +545 -0
- package/ui/src/node-editor/node-editor.tsx +304 -0
- package/ui/src/node-graph/graph-notice.tsx +21 -0
- package/ui/src/node-graph/node-graph.ts +214 -0
- package/ui/src/node-graph/node-graph.tsx +295 -0
- package/ui/src/node-import/node-import.tsx +418 -0
- package/ui/src/node-save-error.ts +46 -0
- package/ui/src/node-source/node-source.tsx +128 -0
- package/ui/src/node-table/node-table.tsx +107 -0
- package/ui/src/nodes/nodes.tsx +240 -0
- package/ui/src/rename-resource/rename-resource.ts +80 -0
- package/ui/src/resolved-names/resolved-names.tsx +67 -0
- package/ui/src/resource-error.ts +33 -0
- package/ui/src/resource-menu/resource-menu.tsx +1156 -0
- package/ui/src/router/router-context.ts +6 -0
- package/ui/src/router/router.tsx +67 -0
- package/ui/src/router/router.types.ts +8 -0
- package/ui/src/router/selection-search.ts +88 -0
- package/ui/src/save-button/save-button.tsx +94 -0
- package/ui/src/section-hint/section-hint.tsx +40 -0
- package/ui/src/sign-in-refused/sign-in-refused.tsx +35 -0
- package/ui/src/styles.css +189 -0
- package/ui/src/table-columns/table-columns.tsx +379 -0
- package/ui/src/theme/custom.css +1 -0
- package/ui/src/theme/theme-context.tsx +89 -0
- package/ui/src/theme/theme.ts +70 -0
- package/ui/src/time/relative-time.tsx +41 -0
- package/ui/src/time/time-context.tsx +78 -0
- package/ui/src/time/time.ts +165 -0
- package/ui/src/title-row/title-row.tsx +185 -0
- package/ui/src/tools/tools.tsx +546 -0
- package/ui/src/user-name/user-name.ts +61 -0
- package/ui/src/verbatim/verbatim.tsx +68 -0
- package/ui/tsconfig.json +17 -0
- package/ui/vite.config.ts +129 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Actor } from "../../nodes/nodes.types.js";
|
|
2
|
+
import type { PromptNameHolder, PromptRepository } from "../../prompts/prompts.types.js";
|
|
3
|
+
import type { D1Database } from "./db.types.js";
|
|
4
|
+
/**
|
|
5
|
+
* The documents this actor may read that are offered as a slash command (#775).
|
|
6
|
+
*
|
|
7
|
+
* ⚠️ **Two statements rather than one `UNION`, and the reason is the visibility walk.** A document
|
|
8
|
+
* is visible through `allowed`; a flow is visible through `flowInSubtree`, which is a different
|
|
9
|
+
* predicate over different tables and needs its own bindings in its own order. Welded into one
|
|
10
|
+
* statement the two would share a placeholder sequence that nobody can read back — and the failure
|
|
11
|
+
* that produces is a shifted binding, which does not throw: it answers the wrong list.
|
|
12
|
+
*
|
|
13
|
+
* ⚠️ **`archived_at IS NULL` is part of being offered.** Archiving is what "delete" means here, and
|
|
14
|
+
* a command that starts an archived document is a command onto something the tree no longer shows.
|
|
15
|
+
* The name stays taken while it is archived — a restore brings the command back rather than finding
|
|
16
|
+
* its name given away in the meantime.
|
|
17
|
+
*
|
|
18
|
+
* ⚠️ The `kind = 'document'` is redundant against the CHECK in `0028` and stays anyway: it is the
|
|
19
|
+
* one line that keeps this query honest if that CHECK is ever loosened, and it costs nothing on a
|
|
20
|
+
* partial index that only holds the offered rows.
|
|
21
|
+
*/
|
|
22
|
+
export declare const offeredDocumentsQuery: string;
|
|
23
|
+
/**
|
|
24
|
+
* The published flows this actor may read that are offered as a slash command.
|
|
25
|
+
*
|
|
26
|
+
* ⚠️ **`published_version_id IS NOT NULL` is the switch, and it is the whole of it** (#775).
|
|
27
|
+
* Publishing is already the decision that a flow is for other people, so `flow_publish` sets the
|
|
28
|
+
* name and nothing else asks again. A flow that is withdrawn KEEPS its name and leaves this list:
|
|
29
|
+
* the name is what makes republishing it the same command rather than a new one, and a client that
|
|
30
|
+
* stored it is not left pointing at a command that has since become somebody else's.
|
|
31
|
+
*
|
|
32
|
+
* ⚠️ `read`, not `execute`, and that is not the obvious choice. A flow in the library — runnable by
|
|
33
|
+
* people who may not open it (ADR-0004 §2/§3) — is deliberately NOT listed: a catalogue entry
|
|
34
|
+
* carries a title and a description, and those are the readable half. Somebody who may only run it
|
|
35
|
+
* still can, through `flow_run_start` with the id they were given; what they do not get is a
|
|
36
|
+
* listing that names it.
|
|
37
|
+
*/
|
|
38
|
+
export declare const offeredFlowsQuery: string;
|
|
39
|
+
export declare function promptNameHolder(deps: {
|
|
40
|
+
db: D1Database;
|
|
41
|
+
now(): Date;
|
|
42
|
+
}, actor: Actor, name: string): Promise<PromptNameHolder | null>;
|
|
43
|
+
export declare function createPromptRepository(deps: {
|
|
44
|
+
db: D1Database;
|
|
45
|
+
now(): Date;
|
|
46
|
+
}): PromptRepository;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { flowInSubtree, flowInSubtreeBindings, subtreeBindings, subtreeCte } from "./db-grants.js";
|
|
2
|
+
/**
|
|
3
|
+
* The documents this actor may read that are offered as a slash command (#775).
|
|
4
|
+
*
|
|
5
|
+
* ⚠️ **Two statements rather than one `UNION`, and the reason is the visibility walk.** A document
|
|
6
|
+
* is visible through `allowed`; a flow is visible through `flowInSubtree`, which is a different
|
|
7
|
+
* predicate over different tables and needs its own bindings in its own order. Welded into one
|
|
8
|
+
* statement the two would share a placeholder sequence that nobody can read back — and the failure
|
|
9
|
+
* that produces is a shifted binding, which does not throw: it answers the wrong list.
|
|
10
|
+
*
|
|
11
|
+
* ⚠️ **`archived_at IS NULL` is part of being offered.** Archiving is what "delete" means here, and
|
|
12
|
+
* a command that starts an archived document is a command onto something the tree no longer shows.
|
|
13
|
+
* The name stays taken while it is archived — a restore brings the command back rather than finding
|
|
14
|
+
* its name given away in the meantime.
|
|
15
|
+
*
|
|
16
|
+
* ⚠️ The `kind = 'document'` is redundant against the CHECK in `0028` and stays anyway: it is the
|
|
17
|
+
* one line that keeps this query honest if that CHECK is ever loosened, and it costs nothing on a
|
|
18
|
+
* partial index that only holds the offered rows.
|
|
19
|
+
*/
|
|
20
|
+
export const offeredDocumentsQuery = `${subtreeCte}
|
|
21
|
+
SELECT n.prompt_name, n.id, n.title, n.description
|
|
22
|
+
FROM nodes n
|
|
23
|
+
JOIN allowed ON allowed.id = n.id
|
|
24
|
+
WHERE n.prompt_name IS NOT NULL
|
|
25
|
+
AND n.kind = 'document'
|
|
26
|
+
AND n.archived_at IS NULL
|
|
27
|
+
ORDER BY n.prompt_name`;
|
|
28
|
+
/**
|
|
29
|
+
* The published flows this actor may read that are offered as a slash command.
|
|
30
|
+
*
|
|
31
|
+
* ⚠️ **`published_version_id IS NOT NULL` is the switch, and it is the whole of it** (#775).
|
|
32
|
+
* Publishing is already the decision that a flow is for other people, so `flow_publish` sets the
|
|
33
|
+
* name and nothing else asks again. A flow that is withdrawn KEEPS its name and leaves this list:
|
|
34
|
+
* the name is what makes republishing it the same command rather than a new one, and a client that
|
|
35
|
+
* stored it is not left pointing at a command that has since become somebody else's.
|
|
36
|
+
*
|
|
37
|
+
* ⚠️ `read`, not `execute`, and that is not the obvious choice. A flow in the library — runnable by
|
|
38
|
+
* people who may not open it (ADR-0004 §2/§3) — is deliberately NOT listed: a catalogue entry
|
|
39
|
+
* carries a title and a description, and those are the readable half. Somebody who may only run it
|
|
40
|
+
* still can, through `flow_run_start` with the id they were given; what they do not get is a
|
|
41
|
+
* listing that names it.
|
|
42
|
+
*/
|
|
43
|
+
export const offeredFlowsQuery = `${subtreeCte}
|
|
44
|
+
SELECT flow.prompt_name, flow.id, flow.title, flow.description
|
|
45
|
+
FROM flows flow
|
|
46
|
+
WHERE flow.prompt_name IS NOT NULL
|
|
47
|
+
AND flow.published_version_id IS NOT NULL
|
|
48
|
+
AND flow.archived_at IS NULL
|
|
49
|
+
AND ${flowInSubtree}
|
|
50
|
+
ORDER BY flow.prompt_name`;
|
|
51
|
+
/**
|
|
52
|
+
* Who holds one name, asked of both tables at once, for the refusal a taken name gets.
|
|
53
|
+
*
|
|
54
|
+
* ⚠️ **Existence is answered to everybody; the TITLE only to those entitled to it.** The question
|
|
55
|
+
* "is this name free" has to be answered truthfully or the caller can do nothing — they are refused
|
|
56
|
+
* by an index they cannot see and told the node was changed by another editor. What must not travel
|
|
57
|
+
* is the title: naming the document that holds `payroll` tells somebody without access that a
|
|
58
|
+
* document by that title exists, and ADR-0004 §3 is explicit that a refusal must not become a way
|
|
59
|
+
* of reading the tree. The `CASE` below is where the two halves part.
|
|
60
|
+
*
|
|
61
|
+
* ⚠️ **One function, called from both repositories, rather than one query per repository.** A node
|
|
62
|
+
* write and a flow publish refuse for the same reason and have to say the same sentence; two
|
|
63
|
+
* spellings of this would drift, and the one that drifts is the one whose surface is used less.
|
|
64
|
+
* `destructive.md` calls it by name: two queries with similar names are two different questions.
|
|
65
|
+
*/
|
|
66
|
+
const holderQuery = `${subtreeCte}
|
|
67
|
+
SELECT 'document' AS kind, CASE WHEN allowed.id IS NULL THEN NULL ELSE n.title END AS title
|
|
68
|
+
FROM nodes n
|
|
69
|
+
LEFT JOIN allowed ON allowed.id = n.id
|
|
70
|
+
WHERE n.prompt_name = ?
|
|
71
|
+
UNION ALL
|
|
72
|
+
SELECT 'flow' AS kind, CASE WHEN ${flowInSubtree} THEN flow.title ELSE NULL END AS title
|
|
73
|
+
FROM flows flow
|
|
74
|
+
WHERE flow.prompt_name = ?`;
|
|
75
|
+
export async function promptNameHolder(deps, actor, name) {
|
|
76
|
+
const now = deps.now().toISOString();
|
|
77
|
+
const row = await deps.db
|
|
78
|
+
.prepare(holderQuery)
|
|
79
|
+
.bind(...subtreeBindings(actor, "read", now), name, ...flowInSubtreeBindings(actor, "read", now), name)
|
|
80
|
+
.first();
|
|
81
|
+
return row === null ? null : { kind: row.kind, title: row.title };
|
|
82
|
+
}
|
|
83
|
+
function mapEntry(row, kind) {
|
|
84
|
+
return {
|
|
85
|
+
name: row.prompt_name,
|
|
86
|
+
kind,
|
|
87
|
+
targetId: row.id,
|
|
88
|
+
title: row.title,
|
|
89
|
+
description: row.description,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
export function createPromptRepository(deps) {
|
|
93
|
+
return {
|
|
94
|
+
async listOffered(actor) {
|
|
95
|
+
const now = deps.now().toISOString();
|
|
96
|
+
/**
|
|
97
|
+
* ⚠️ **A half the actor has no capability for is not asked for at all** (#775, following
|
|
98
|
+
* #774). Running the statement and discarding its rows would be the same answer at the cost
|
|
99
|
+
* of a walk over the tree — and worse, it would put the decision in the mapping step, where
|
|
100
|
+
* the next reader of this function cannot see it.
|
|
101
|
+
*
|
|
102
|
+
* ⚠️ **Each statement carries its own kind, rather than the two being read back out of fixed
|
|
103
|
+
* positions.** With only `flows/read` the flow query is the ONLY element, so it arrives as
|
|
104
|
+
* result zero: a `const [documents, flows]` here puts the flows in a variable called
|
|
105
|
+
* `documents`, and the name is then a lie in one of the four branches. It answers correctly
|
|
106
|
+
* today and mis-binds the moment somebody adds a third conditional query — which is exactly
|
|
107
|
+
* the kind of edit this list invites.
|
|
108
|
+
*/
|
|
109
|
+
const asked = [];
|
|
110
|
+
if (actor.canReadNodes) {
|
|
111
|
+
asked.push({
|
|
112
|
+
kind: "document",
|
|
113
|
+
statement: deps.db
|
|
114
|
+
.prepare(offeredDocumentsQuery)
|
|
115
|
+
.bind(...subtreeBindings(actor, "read", now)),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (actor.canReadFlows) {
|
|
119
|
+
asked.push({
|
|
120
|
+
kind: "flow",
|
|
121
|
+
statement: deps.db
|
|
122
|
+
.prepare(offeredFlowsQuery)
|
|
123
|
+
.bind(...subtreeBindings(actor, "read", now), ...flowInSubtreeBindings(actor, "read", now)),
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
const results = await deps.db.batch(asked.map((each) => each.statement));
|
|
127
|
+
return (asked
|
|
128
|
+
.flatMap((each, index) => (results[index]?.results ?? []).map((row) => mapEntry(row, each.kind)))
|
|
129
|
+
// ⚠️ Sorted over the MERGED list rather than relying on the two `ORDER BY` clauses. Each
|
|
130
|
+
// statement orders its own half, and concatenating two ordered halves gives an unordered
|
|
131
|
+
// whole — `prompts/list` would then be alphabetical within documents and again within
|
|
132
|
+
// flows, which reads as "unsorted with a pattern" to anybody scrolling it.
|
|
133
|
+
.sort((left, right) => left.name.localeCompare(right.name)));
|
|
134
|
+
},
|
|
135
|
+
async findOffered(actor, name) {
|
|
136
|
+
// The catalogue is the list this actor may see, so looking one entry up is looking in that
|
|
137
|
+
// list. A separate statement with its own `WHERE prompt_name = ?` would be a second walk to
|
|
138
|
+
// keep in step with the first, for a set that is small by construction: the offered rows are
|
|
139
|
+
// a curated handful, not the tree.
|
|
140
|
+
const offered = await this.listOffered(actor);
|
|
141
|
+
return offered.find((entry) => entry.name === name) ?? null;
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
}
|