@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,172 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
function normalizedHostname(url) {
|
|
3
|
+
return url.hostname.toLowerCase().replace(/^\[|\]$/g, "");
|
|
4
|
+
}
|
|
5
|
+
function isPrivateIpv4(hostname) {
|
|
6
|
+
const parts = hostname.split(".").map(Number);
|
|
7
|
+
if (parts.length !== 4 ||
|
|
8
|
+
parts.some((part) => !Number.isInteger(part) || part < 0 || part > 255)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const [first = 0, second = 0] = parts;
|
|
12
|
+
return (first === 0 ||
|
|
13
|
+
first === 10 ||
|
|
14
|
+
first === 127 ||
|
|
15
|
+
(first === 100 && second >= 64 && second <= 127) ||
|
|
16
|
+
(first === 169 && second === 254) ||
|
|
17
|
+
(first === 172 && second >= 16 && second <= 31) ||
|
|
18
|
+
(first === 192 && second === 168) ||
|
|
19
|
+
(first === 198 && (second === 18 || second === 19)) ||
|
|
20
|
+
first >= 224);
|
|
21
|
+
}
|
|
22
|
+
function isPublicToolHost(url) {
|
|
23
|
+
const hostname = normalizedHostname(url);
|
|
24
|
+
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1") {
|
|
25
|
+
return url.protocol === "http:";
|
|
26
|
+
}
|
|
27
|
+
if (!hostname.includes(".") ||
|
|
28
|
+
hostname.endsWith(".local") ||
|
|
29
|
+
hostname.endsWith(".localhost") ||
|
|
30
|
+
hostname.endsWith(".internal") ||
|
|
31
|
+
isPrivateIpv4(hostname) ||
|
|
32
|
+
hostname.includes(":")) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
return url.protocol === "https:";
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* One MCP server as the portal names it. The handle is what the portal puts in front of every tool
|
|
39
|
+
* that server offers (`notion_notion-search` belongs to `notion`), and it is the only identifier
|
|
40
|
+
* Intel can both store and recognise again in a live `tools/list`.
|
|
41
|
+
*
|
|
42
|
+
* ⚠️ A handle is never invented from a tool name. Which servers exist is the portal's answer
|
|
43
|
+
* (`portal_list_servers`), and the prefix is only used to attribute a tool to a server that answer
|
|
44
|
+
* already named — see `packages/intel/src/tools/tool-servers` for why splitting on the underscore
|
|
45
|
+
* alone would be ambiguous.
|
|
46
|
+
*/
|
|
47
|
+
export const ToolServerHandle = z
|
|
48
|
+
.string()
|
|
49
|
+
.trim()
|
|
50
|
+
.min(1)
|
|
51
|
+
.max(120)
|
|
52
|
+
.regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/, "A server handle is the portal's own identifier");
|
|
53
|
+
export const ToolSourceUrl = z.url().refine((value) => {
|
|
54
|
+
try {
|
|
55
|
+
const url = new URL(value);
|
|
56
|
+
return !url.username && !url.password && isPublicToolHost(url);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}, "The portal must use an approved public HTTPS host without embedded credentials");
|
|
62
|
+
// The portal namespaces every upstream tool, so the name alone identifies the target server. The
|
|
63
|
+
// portal is still the one that resolves it and attaches the credentials — Intel never holds an
|
|
64
|
+
// upstream credential. Since D30 Intel does read the namespace for one purpose: attributing a tool
|
|
65
|
+
// to a server the portal's own `portal_list_servers` already named, so a delegation can be cut to
|
|
66
|
+
// whole servers. That is attribution, not routing.
|
|
67
|
+
export const ToolName = z.string().min(1).max(240);
|
|
68
|
+
export const ToolAnnotations = z.strictObject({
|
|
69
|
+
title: z.string().max(240).optional(),
|
|
70
|
+
readOnlyHint: z.boolean().optional(),
|
|
71
|
+
destructiveHint: z.boolean().optional(),
|
|
72
|
+
idempotentHint: z.boolean().optional(),
|
|
73
|
+
openWorldHint: z.boolean().optional(),
|
|
74
|
+
});
|
|
75
|
+
export const ToolCapability = z.strictObject({
|
|
76
|
+
name: ToolName,
|
|
77
|
+
title: z.string().max(240).nullable(),
|
|
78
|
+
description: z.string().max(10_000).nullable(),
|
|
79
|
+
inputSchema: z.record(z.string(), z.unknown()),
|
|
80
|
+
outputSchema: z.record(z.string(), z.unknown()).nullable(),
|
|
81
|
+
annotations: ToolAnnotations,
|
|
82
|
+
fingerprint: z.string().regex(/^[a-f0-9]{64}$/),
|
|
83
|
+
});
|
|
84
|
+
// The catalog reflects one live tools/list for the requesting user. It is never stored as a
|
|
85
|
+
// permission mirror, so there is no per-source state and no Intel-owned connection status.
|
|
86
|
+
export const ToolCatalog = z.strictObject({
|
|
87
|
+
portalConnected: z.boolean(),
|
|
88
|
+
items: z.array(ToolCapability),
|
|
89
|
+
/**
|
|
90
|
+
* Which delegated servers actually contributed a tool to this catalog (#289).
|
|
91
|
+
*
|
|
92
|
+
* ⚠️ Present only where the attribution was actually made — a delegated caller whose catalog was
|
|
93
|
+
* read. It is absent for an ordinary user, and absent as well when the answer comes from one of
|
|
94
|
+
* the short paths that never reach the portal (nothing delegated, no portal sign-in, connection
|
|
95
|
+
* dropped). Absent therefore means "not stated", never "nothing arrived"; `[]` is the second one.
|
|
96
|
+
*
|
|
97
|
+
* That it is missing rather than empty on those paths is deliberate rather than half-finished:
|
|
98
|
+
* the attribution already happens for a delegation — `capabilities` has to make it to cut the
|
|
99
|
+
* list — so naming it costs nothing there, while computing the same thing for an ordinary user
|
|
100
|
+
* would mean a second portal request per call, for a question their screen does not ask.
|
|
101
|
+
*
|
|
102
|
+
* ⚠️ It is the answer to "what arrived", never to "what was granted". A server missing here has
|
|
103
|
+
* been switched off, revoked, or is failing right now; the delegation in the definition is
|
|
104
|
+
* unchanged. Reading it the other way round would turn an outage into a permission change.
|
|
105
|
+
*/
|
|
106
|
+
reached: z.array(ToolServerHandle).optional(),
|
|
107
|
+
});
|
|
108
|
+
/**
|
|
109
|
+
* One MCP server the asking user reaches right now, as the portal itself names it (D30).
|
|
110
|
+
*
|
|
111
|
+
* ⚠️ `toolCount` is a fact about this moment and this user, not a size. It exists so a picker can
|
|
112
|
+
* say "9 tools" instead of showing a handle alone, and it must never be read as what an agent will
|
|
113
|
+
* get: the delegated run asks the portal again, with the delegator's token.
|
|
114
|
+
*/
|
|
115
|
+
export const ToolServer = z.strictObject({
|
|
116
|
+
handle: ToolServerHandle,
|
|
117
|
+
name: z.string().min(1).max(240),
|
|
118
|
+
toolCount: z.number().int().min(0),
|
|
119
|
+
});
|
|
120
|
+
// The same live-query rule as the tool catalog, one level up. `portalConnected: false` is the state
|
|
121
|
+
// of somebody who has not signed into the portal yet, and it is not an error.
|
|
122
|
+
export const ToolServerCatalog = z.strictObject({
|
|
123
|
+
portalConnected: z.boolean(),
|
|
124
|
+
items: z.array(ToolServer),
|
|
125
|
+
});
|
|
126
|
+
/**
|
|
127
|
+
* Which of the named servers a tool belongs to, or `null` for none of them.
|
|
128
|
+
*
|
|
129
|
+
* ⚠️ THE TRAP: a tool name does not say where its server name ends.
|
|
130
|
+
*
|
|
131
|
+
* The portal writes `<server>_<tool>`, and both halves may contain underscores — `intel_flow_get`
|
|
132
|
+
* reads equally well as server `intel` with tool `flow_get` and as a server called `intel_flow`
|
|
133
|
+
* with tool `get`. Splitting on the first underscore is therefore a guess that is wrong the day
|
|
134
|
+
* somebody adds a server whose name contains one, and on the API side being wrong means an agent
|
|
135
|
+
* delegated server A quietly reaching server B.
|
|
136
|
+
*
|
|
137
|
+
* So the prefix is never split. It is only ever MATCHED against handles the portal itself named,
|
|
138
|
+
* and the longest match wins: with `intel` and `intel_flow` both declared, `intel_flow_get` belongs
|
|
139
|
+
* to `intel_flow`, which is the only reading in which both declarations stay true.
|
|
140
|
+
*
|
|
141
|
+
* ⚠️ This lives in the contract because HOW A NAME IS READ is a property of the wire, and both
|
|
142
|
+
* surfaces read the same wire: `packages/intel` cuts a delegation with it, `packages/intel/ui` groups the
|
|
143
|
+
* tools screen with it (#212). A second implementation in the browser would be the third answer to
|
|
144
|
+
* one question — the underscore rule has already been answered differently in two places once
|
|
145
|
+
* (#106, #107), and the copies disagreed. What deliberately stays OUT of here is everything about
|
|
146
|
+
* reach: which handles are declared, which are enabled, which may be delegated and which one owns
|
|
147
|
+
* the portal's own management tools are decisions with consequences, and they belong to
|
|
148
|
+
* `packages/intel/src/tools/tool-servers`. This function only reads a name.
|
|
149
|
+
*/
|
|
150
|
+
export function serverOf(toolName, handles) {
|
|
151
|
+
let best = null;
|
|
152
|
+
for (const handle of handles) {
|
|
153
|
+
if (!toolName.startsWith(`${handle}_`))
|
|
154
|
+
continue;
|
|
155
|
+
if (best === null || handle.length > best.length)
|
|
156
|
+
best = handle;
|
|
157
|
+
}
|
|
158
|
+
return best;
|
|
159
|
+
}
|
|
160
|
+
export const TestToolInput = z.strictObject({
|
|
161
|
+
name: ToolName.describe("The tool's full name as tool_list reported it, including the server handle it is prefixed with. The portal routes on that prefix, so a bare name reaches nothing."),
|
|
162
|
+
arguments: z
|
|
163
|
+
.record(z.string(), z.unknown())
|
|
164
|
+
.default({})
|
|
165
|
+
.describe("The arguments, shaped by that tool's own inputSchema from tool_list. Validated against it before anything is sent, so a wrong shape is refused here rather than by the far side."),
|
|
166
|
+
});
|
|
167
|
+
export const ExecuteToolInput = TestToolInput;
|
|
168
|
+
export const ToolTestResult = z.strictObject({
|
|
169
|
+
isError: z.boolean(),
|
|
170
|
+
content: z.array(z.unknown()),
|
|
171
|
+
structuredContent: z.unknown().optional(),
|
|
172
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { IntelError } from "../shared/intel-error/intel-error.js";
|
|
2
|
+
// The separator inside the encoded cursor. `\0` cannot occur in either half: an ISO timestamp is
|
|
3
|
+
// digits and punctuation, an Intel id is Crockford base32.
|
|
4
|
+
const SEPARATOR = "\0";
|
|
5
|
+
// ⚠️ The marker is what keeps an audit cursor out of this door and a feed cursor out of that one.
|
|
6
|
+
// Both encode the same pair, and without it each would decode the other's position happily — then
|
|
7
|
+
// read on from the wrong END of the journal. The damage would not look like an error: the feed
|
|
8
|
+
// would simply start somewhere in the past and quietly leave out everything since.
|
|
9
|
+
const MARKER = "f1";
|
|
10
|
+
/**
|
|
11
|
+
* The pair, made into one string a reader cannot take apart by accident.
|
|
12
|
+
*
|
|
13
|
+
* ⚠️ This is not encryption and does not pretend to be. Anyone determined can decode base64url and
|
|
14
|
+
* read a timestamp. The point is the accident, not the attacker: a cursor that LOOKS like a
|
|
15
|
+
* timestamp invites a caller to send a timestamp, and a timestamp alone loses every second event
|
|
16
|
+
* written in the same millisecond.
|
|
17
|
+
*/
|
|
18
|
+
function encodeCursor(position) {
|
|
19
|
+
const raw = `${MARKER}${SEPARATOR}${position.occurredAt}${SEPARATOR}${position.id}`;
|
|
20
|
+
return btoa(String.fromCharCode(...new TextEncoder().encode(raw)))
|
|
21
|
+
.replaceAll("+", "-")
|
|
22
|
+
.replaceAll("/", "_")
|
|
23
|
+
.replaceAll("=", "");
|
|
24
|
+
}
|
|
25
|
+
function decodeCursor(cursor) {
|
|
26
|
+
// A cursor comes back from a consumer that stored it, possibly weeks ago, possibly truncated by
|
|
27
|
+
// whatever stored it, possibly meant for the other door. Every failure below is the same answer:
|
|
28
|
+
// this is not a cursor this door handed out. Guessing a position from a damaged one would move
|
|
29
|
+
// the reader in silence — past unread events, or back into ones already shown.
|
|
30
|
+
const refuse = () => new IntelError(400, "invalid_cursor", "The cursor is not one the feed issued. Pass back the nextCursor from a previous feed response unchanged, or omit it to start at the most recent event. A cursor from audit_list is not one of these.");
|
|
31
|
+
let raw;
|
|
32
|
+
try {
|
|
33
|
+
const padded = cursor.replaceAll("-", "+").replaceAll("_", "/");
|
|
34
|
+
const binary = atob(padded + "=".repeat((4 - (padded.length % 4)) % 4));
|
|
35
|
+
raw = new TextDecoder().decode(Uint8Array.from(binary, (c) => c.charCodeAt(0)));
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
throw refuse();
|
|
39
|
+
}
|
|
40
|
+
const parts = raw.split(SEPARATOR);
|
|
41
|
+
if (parts.length !== 3)
|
|
42
|
+
throw refuse();
|
|
43
|
+
const [marker, occurredAt, id] = parts;
|
|
44
|
+
if (marker !== MARKER)
|
|
45
|
+
throw refuse();
|
|
46
|
+
// ⚠️ Both halves are checked, not just the split. A cursor whose timestamp decoded to an empty
|
|
47
|
+
// string would compare as "before everything" and answer with an empty page forever.
|
|
48
|
+
if (occurredAt === undefined || occurredAt.length === 0)
|
|
49
|
+
throw refuse();
|
|
50
|
+
if (id === undefined || id.length === 0)
|
|
51
|
+
throw refuse();
|
|
52
|
+
return { occurredAt, id };
|
|
53
|
+
}
|
|
54
|
+
export function createFeed(deps) {
|
|
55
|
+
return {
|
|
56
|
+
async list(actor, input) {
|
|
57
|
+
const before = input.before === undefined ? null : decodeCursor(input.before);
|
|
58
|
+
// One more than asked for, so "is there another page" is answered by the same authorized
|
|
59
|
+
// query instead of a second one that could disagree with it.
|
|
60
|
+
const page = await deps.feed.listEvents(actor, {
|
|
61
|
+
before,
|
|
62
|
+
actor: input.actor ?? null,
|
|
63
|
+
limit: input.limit + 1,
|
|
64
|
+
});
|
|
65
|
+
const hasMore = page.events.length > input.limit;
|
|
66
|
+
const events = hasMore ? page.events.slice(0, input.limit) : page.events;
|
|
67
|
+
const last = events.at(-1);
|
|
68
|
+
return {
|
|
69
|
+
events,
|
|
70
|
+
// ⚠️ The cursor is the LAST DELIVERED row, never the probe row that was dropped. Taking it
|
|
71
|
+
// from the probe would skip exactly one event per page — the off-by-one that shows up as a
|
|
72
|
+
// change nobody saw, not as an error.
|
|
73
|
+
nextCursor: hasMore && last !== undefined ? encodeCursor(last) : null,
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { FeedEvent, FeedListRequest, FeedListResponse } from "../contract/feed.js";
|
|
2
|
+
import type { Actor } from "../nodes/nodes.types.js";
|
|
3
|
+
export interface FeedPosition {
|
|
4
|
+
occurredAt: string;
|
|
5
|
+
id: string;
|
|
6
|
+
}
|
|
7
|
+
export interface FeedQuery {
|
|
8
|
+
before: FeedPosition | null;
|
|
9
|
+
actor: string | null;
|
|
10
|
+
limit: number;
|
|
11
|
+
}
|
|
12
|
+
export interface FeedPage {
|
|
13
|
+
events: FeedEvent[];
|
|
14
|
+
}
|
|
15
|
+
export interface FeedRepository {
|
|
16
|
+
listEvents(actor: Actor, query: FeedQuery): Promise<FeedPage>;
|
|
17
|
+
}
|
|
18
|
+
export interface FeedDeps {
|
|
19
|
+
feed: FeedRepository;
|
|
20
|
+
}
|
|
21
|
+
export interface FeedService {
|
|
22
|
+
list(actor: Actor, input: FeedListRequest): Promise<FeedListResponse>;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { FlowGraph, FlowNode } from "../contract/flow.js";
|
|
2
|
+
import type { CompiledFlow, FlowDeps, FlowService } from "./flows.types.js";
|
|
3
|
+
type SubflowNode = Extract<FlowNode, {
|
|
4
|
+
kind: "subflow";
|
|
5
|
+
}>;
|
|
6
|
+
type TreeLinkNode = Extract<FlowNode, {
|
|
7
|
+
kind: TreeLinkKind;
|
|
8
|
+
}>;
|
|
9
|
+
type ToolStepNode = Extract<FlowNode, {
|
|
10
|
+
kind: "tool";
|
|
11
|
+
}>;
|
|
12
|
+
export declare const treeLinkKinds: readonly ["folder", "document", "upload", "table"];
|
|
13
|
+
type TreeLinkKind = (typeof treeLinkKinds)[number];
|
|
14
|
+
/**
|
|
15
|
+
* One place reads a graph for each kind of step it contains, and everything else is derived from
|
|
16
|
+
* these three. The publish-time rule, the freeze, the sidebar, the relation graph, the requirements
|
|
17
|
+
* list and the repository's cycle walk all ask about the same nodes; a second `kind === "…"` walk
|
|
18
|
+
* beside them would drift quietly, because both would keep returning something plausible.
|
|
19
|
+
*/
|
|
20
|
+
export declare function subflowNodes(graph: FlowGraph): SubflowNode[];
|
|
21
|
+
export declare function treeLinkNodes(graph: FlowGraph): TreeLinkNode[];
|
|
22
|
+
export declare function toolNodes(graph: FlowGraph): ToolStepNode[];
|
|
23
|
+
export declare function resourceIdOf(node: TreeLinkNode): string;
|
|
24
|
+
export declare function calleeIds(graph: FlowGraph): string[];
|
|
25
|
+
/**
|
|
26
|
+
* The documents a graph names and the tool SERVERS it reaches for, flattened and without repetition.
|
|
27
|
+
* The requirements list, the publish-time check and the run's first tool check read this one answer,
|
|
28
|
+
* so they cannot disagree about what a flow touches. A caller that needs to know *which step* names
|
|
29
|
+
* a document reads the node lists above instead — the relation graph draws exactly that edge.
|
|
30
|
+
*
|
|
31
|
+
* ⚠️ Servers, not functions, since #489. A step no longer names one function, so "what does this
|
|
32
|
+
* flow need" cannot be answered with a function list any more — and answering it with the functions
|
|
33
|
+
* a step MIGHT call would be a guess about a choice that is made while the flow runs.
|
|
34
|
+
*/
|
|
35
|
+
export declare function graphReferences(graph: FlowGraph): {
|
|
36
|
+
nodes: string[];
|
|
37
|
+
servers: string[];
|
|
38
|
+
};
|
|
39
|
+
export declare function compileFlow(graph: FlowGraph): CompiledFlow;
|
|
40
|
+
export declare function createFlows(deps: FlowDeps): FlowService;
|
|
41
|
+
export {};
|