@shoalrun/cli 0.0.0-stage → 0.1.0-alpha.11
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/AUTHORING.md +269 -0
- package/CHANGELOG.md +82 -0
- package/LICENSE +202 -0
- package/README.md +189 -2
- package/agent-docs/.well-known/shoalrun/navigation/changelog-tab-50f26fe22670.txt +33 -0
- package/agent-docs/.well-known/shoalrun/navigation/docs-50f26fe22670.txt +24 -0
- package/agent-docs/.well-known/shoalrun/navigation/project-updates-50f26fe22670.txt +9 -0
- package/agent-docs/SNAPSHOT.json +9 -0
- package/agent-docs/about.md +49 -0
- package/agent-docs/api-docs/focused-contracts.md +68 -0
- package/agent-docs/api-docs/generate.md +189 -0
- package/agent-docs/api-docs/generate.sections/add-useful-examples.md +47 -0
- package/agent-docs/api-docs/generate.sections/choose-generated-references-or-mdx.md +50 -0
- package/agent-docs/api-docs/generate.sections/describe-filters-that-do-not-use-their-openapi-parameter-name.md +52 -0
- package/agent-docs/api-docs/generate.sections/generate-many-pages-selectively.md +71 -0
- package/agent-docs/api-docs/generate.sections/link-guides-to-api-references.md +48 -0
- package/agent-docs/api-docs/generate.sections/map-extension-values-to-shoalrun-status.md +52 -0
- package/agent-docs/api-docs/generate.sections/override-generated-reference-order-in-navigation.md +60 -0
- package/agent-docs/api-docs/generate.sections/related-reading.md +38 -0
- package/agent-docs/api-docs/generate.sections/use-a-template-for-editorial-context.md +45 -0
- package/agent-docs/api-docs/support.md +97 -0
- package/agent-docs/author/add-page.md +124 -0
- package/agent-docs/author/agent-overview.md +59 -0
- package/agent-docs/author/agent-workflow.md +65 -0
- package/agent-docs/author/agents.md +53 -0
- package/agent-docs/author/analytics.md +286 -0
- package/agent-docs/author/analytics.sections/adapter-exports-and-consent.md +51 -0
- package/agent-docs/author/analytics.sections/built-in-events.md +52 -0
- package/agent-docs/author/analytics.sections/configure-an-adapter.md +51 -0
- package/agent-docs/author/analytics.sections/custom-interactions.md +57 -0
- package/agent-docs/author/analytics.sections/event-format.md +59 -0
- package/agent-docs/author/analytics.sections/html-markdown-and-agents.md +42 -0
- package/agent-docs/author/analytics.sections/inspect-events-locally.md +36 -0
- package/agent-docs/author/analytics.sections/map-events-to-your-service.md +42 -0
- package/agent-docs/author/analytics.sections/posthog-example.md +126 -0
- package/agent-docs/author/analytics.sections/related-reading.md +42 -0
- package/agent-docs/author/authoring-agent.md +102 -0
- package/agent-docs/author/coding-agent.md +90 -0
- package/agent-docs/author/components/action-link.md +41 -0
- package/agent-docs/author/components/api-embeds.md +263 -0
- package/agent-docs/author/components/api-embeds.sections/apiexample.md +117 -0
- package/agent-docs/author/components/api-embeds.sections/html-markdown-and-agents.md +37 -0
- package/agent-docs/author/components/api-embeds.sections/related-reading.md +37 -0
- package/agent-docs/author/components/badge.md +76 -0
- package/agent-docs/author/components/breadcrumbs.md +57 -0
- package/agent-docs/author/components/callout.md +131 -0
- package/agent-docs/author/components/cards.md +168 -0
- package/agent-docs/author/components/cards.sections/add-a-lucide-icon.md +50 -0
- package/agent-docs/author/components/cards.sections/build-a-collection.md +69 -0
- package/agent-docs/author/components/cards.sections/curate-a-reading-list.md +66 -0
- package/agent-docs/author/components/cards.sections/html-markdown-and-agents.md +37 -0
- package/agent-docs/author/components/cards.sections/link-to-one-document.md +45 -0
- package/agent-docs/author/components/cards.sections/override-card-text.md +58 -0
- package/agent-docs/author/components/cards.sections/related-reading.md +43 -0
- package/agent-docs/author/components/code-blocks.md +117 -0
- package/agent-docs/author/components/collapsible.md +99 -0
- package/agent-docs/author/components/cookbook-chooser.md +86 -0
- package/agent-docs/author/components/custom/react.md +190 -0
- package/agent-docs/author/components/custom/react.sections/html-markdown-and-agents.md +36 -0
- package/agent-docs/author/components/custom/react.sections/interactive-react-example.md +88 -0
- package/agent-docs/author/components/custom/react.sections/registration.md +41 -0
- package/agent-docs/author/components/custom/react.sections/related-reading.md +30 -0
- package/agent-docs/author/components/custom/react.sections/share-the-model-with-the-browser.md +47 -0
- package/agent-docs/author/components/custom/react.sections/where-the-content-lives.md +100 -0
- package/agent-docs/author/components/custom.md +183 -0
- package/agent-docs/author/components/definition-list.md +54 -0
- package/agent-docs/author/components/diagrams/d2-gallery.md +861 -0
- package/agent-docs/author/components/diagrams/d2-gallery.sections/basic-shapes.md +163 -0
- package/agent-docs/author/components/diagrams/d2-gallery.sections/flows-and-structures.md +375 -0
- package/agent-docs/author/components/diagrams/d2-gallery.sections/html-markdown-and-agents.md +33 -0
- package/agent-docs/author/components/diagrams/d2-gallery.sections/layout-engines.md +169 -0
- package/agent-docs/author/components/diagrams/d2-gallery.sections/related-reading.md +37 -0
- package/agent-docs/author/components/diagrams/d2-gallery.sections/sequences-and-grids.md +123 -0
- package/agent-docs/author/components/diagrams/d2-gallery.sections/styles-and-code.md +125 -0
- package/agent-docs/author/components/diagrams/pele-gallery.md +1317 -0
- package/agent-docs/author/components/diagrams/pele-gallery.sections/charts-and-planning.md +341 -0
- package/agent-docs/author/components/diagrams/pele-gallery.sections/flowchart-shapes.md +269 -0
- package/agent-docs/author/components/diagrams/pele-gallery.sections/flows-and-behavior.md +273 -0
- package/agent-docs/author/components/diagrams/pele-gallery.sections/html-markdown-and-agents.md +31 -0
- package/agent-docs/author/components/diagrams/pele-gallery.sections/related-reading.md +35 -0
- package/agent-docs/author/components/diagrams/pele-gallery.sections/specialized-diagrams.md +229 -0
- package/agent-docs/author/components/diagrams/pele-gallery.sections/systems-and-structures.md +291 -0
- package/agent-docs/author/components/diagrams.md +155 -0
- package/agent-docs/author/components/doc-link.md +58 -0
- package/agent-docs/author/components/fields.md +121 -0
- package/agent-docs/author/components/file-tree.md +84 -0
- package/agent-docs/author/components/images.md +103 -0
- package/agent-docs/author/components/info-hint.md +61 -0
- package/agent-docs/author/components/kbd.md +45 -0
- package/agent-docs/author/components/math.md +39 -0
- package/agent-docs/author/components/only.md +65 -0
- package/agent-docs/author/components/progress.md +53 -0
- package/agent-docs/author/components/related-reading.md +48 -0
- package/agent-docs/author/components/steps.md +121 -0
- package/agent-docs/author/components/tables.md +64 -0
- package/agent-docs/author/components/tabs.md +129 -0
- package/agent-docs/author/components/timeline.md +74 -0
- package/agent-docs/author/components/tooltips.md +58 -0
- package/agent-docs/author/components/walkthroughs.md +390 -0
- package/agent-docs/author/components/walkthroughs.sections/attributes.md +45 -0
- package/agent-docs/author/components/walkthroughs.sections/build-up-code.md +133 -0
- package/agent-docs/author/components/walkthroughs.sections/choose-a-layout.md +141 -0
- package/agent-docs/author/components/walkthroughs.sections/explain-one-file.md +126 -0
- package/agent-docs/author/components/walkthroughs.sections/html-markdown-and-agents.md +38 -0
- package/agent-docs/author/components/walkthroughs.sections/related-reading.md +36 -0
- package/agent-docs/author/components/walkthroughs.sections/take-code-from-a-file.md +53 -0
- package/agent-docs/author/components.md +78 -0
- package/agent-docs/author/content.md +74 -0
- package/agent-docs/author/cookbooks.md +119 -0
- package/agent-docs/author/css.md +238 -0
- package/agent-docs/author/css.sections/borders-fields-and-navigation-tokens.md +70 -0
- package/agent-docs/author/css.sections/core-color-tokens.md +71 -0
- package/agent-docs/author/css.sections/page-attributes.md +69 -0
- package/agent-docs/author/css.sections/page-transitions.md +60 -0
- package/agent-docs/author/css.sections/responsive-behavior.md +58 -0
- package/agent-docs/author/css.sections/status-code-and-callout-tokens.md +89 -0
- package/agent-docs/author/css.sections/typography-shape-and-width-tokens.md +71 -0
- package/agent-docs/author/custom-metadata.md +177 -0
- package/agent-docs/author/custom-metadata.sections/add-a-custom-page-field.md +68 -0
- package/agent-docs/author/custom-metadata.sections/choose-text-for-each-surface.md +54 -0
- package/agent-docs/author/custom-metadata.sections/preview-changes-to-metadata-providers.md +33 -0
- package/agent-docs/author/custom-metadata.sections/read-metadata-from-a-project-module.md +57 -0
- package/agent-docs/author/custom-metadata.sections/related-reading.md +29 -0
- package/agent-docs/author/design-templates.md +49 -0
- package/agent-docs/author/design-writing-guides.md +73 -0
- package/agent-docs/author/frontmatter-reference.md +146 -0
- package/agent-docs/author/frontmatter-reference.sections/choose-a-publication-and-visibility.md +44 -0
- package/agent-docs/author/frontmatter-reference.sections/control-output-details.md +41 -0
- package/agent-docs/author/frontmatter-reference.sections/global-defaults-and-enforced-values.md +31 -0
- package/agent-docs/author/frontmatter-reference.sections/identify-and-route-a-page.md +40 -0
- package/agent-docs/author/frontmatter-reference.sections/point-agents-to-it.md +37 -0
- package/agent-docs/author/frontmatter-reference.sections/project-defined-fields.md +41 -0
- package/agent-docs/author/frontmatter-reference.sections/related-reading.md +35 -0
- package/agent-docs/author/frontmatter-reference.sections/use-the-local-files-while-authoring.md +33 -0
- package/agent-docs/author/frontmatter-reference.sections/when-the-files-update.md +31 -0
- package/agent-docs/author/frontmatter.md +255 -0
- package/agent-docs/author/frontmatter.sections/audience-badges.md +66 -0
- package/agent-docs/author/frontmatter.sections/give-deprecation-guidance.md +88 -0
- package/agent-docs/author/frontmatter.sections/global-defaults-and-enforced-values.md +75 -0
- package/agent-docs/author/frontmatter.sections/optional-native-fields.md +90 -0
- package/agent-docs/author/frontmatter.sections/publication-fields.md +85 -0
- package/agent-docs/author/frontmatter.sections/publishing-policy.md +71 -0
- package/agent-docs/author/frontmatter.sections/related-metadata-tasks.md +72 -0
- package/agent-docs/author/frontmatter.sections/related-reading.md +72 -0
- package/agent-docs/author/frontmatter.sections/required-after-inheritance.md +84 -0
- package/agent-docs/author/frontmatter.sections/seo-fields.md +79 -0
- package/agent-docs/author/frontmatter.sections/validation-rules.md +75 -0
- package/agent-docs/author/markdown-metadata.md +207 -0
- package/agent-docs/author/navigation.md +269 -0
- package/agent-docs/author/navigation.sections/arrange-authored-pages.md +58 -0
- package/agent-docs/author/navigation.sections/fill-an-api-tag-group.md +48 -0
- package/agent-docs/author/navigation.sections/hide-group-page-counts.md +45 -0
- package/agent-docs/author/navigation.sections/html-markdown-and-agents.md +40 -0
- package/agent-docs/author/navigation.sections/local-api-preview.md +47 -0
- package/agent-docs/author/navigation.sections/mix-guides-and-api-references.md +65 -0
- package/agent-docs/author/navigation.sections/optionally-split-a-large-menu-into-files.md +97 -0
- package/agent-docs/author/navigation.sections/reach-navigation-while-reading.md +38 -0
- package/agent-docs/author/navigation.sections/related-reading.md +44 -0
- package/agent-docs/author/navigation.sections/split-navigation-into-tabs.md +67 -0
- package/agent-docs/author/navigation.sections/subject-lifecycle-labels.md +42 -0
- package/agent-docs/author/reader-views.md +200 -0
- package/agent-docs/author/reader-views.sections/configure-the-choices.md +65 -0
- package/agent-docs/author/reader-views.sections/connect-your-own-control.md +59 -0
- package/agent-docs/author/reader-views.sections/how-it-works-for-agents.md +41 -0
- package/agent-docs/author/reader-views.sections/mark-pages.md +49 -0
- package/agent-docs/author/reader-views.sections/mark-sections-and-add-an-entry-choice.md +49 -0
- package/agent-docs/author/reader-views.sections/place-filter-controls.md +43 -0
- package/agent-docs/author/reader-views.sections/try-the-controls-here.md +64 -0
- package/agent-docs/author/recipe-drafts.md +181 -0
- package/agent-docs/author/recipe-drafts.sections/1-write-one-reusable-step.md +82 -0
- package/agent-docs/author/recipe-drafts.sections/2-list-the-steps-for-one-complete-goal.md +60 -0
- package/agent-docs/author/recipe-drafts.sections/3-generate-a-draft-and-review-it.md +55 -0
- package/agent-docs/author/recipe-drafts.sections/4-maintain-shoalrun-s-published-recipe-snapshots.md +66 -0
- package/agent-docs/author/recipe-drafts.sections/related-reading.md +45 -0
- package/agent-docs/author/recipe-drafts.sections/start-an-ingredient-from-an-api-example.md +50 -0
- package/agent-docs/author/recipes.md +127 -0
- package/agent-docs/author/recipes.sections/how-agents-use-this.md +50 -0
- package/agent-docs/author/recipes.sections/one-example-from-shoalrun.md +64 -0
- package/agent-docs/author/recipes.sections/related-reading.md +36 -0
- package/agent-docs/author/recipes.sections/try-a-complete-workflow.md +42 -0
- package/agent-docs/author/recipes.sections/use-recipes-for-task-oriented-how-tos.md +52 -0
- package/agent-docs/author/recipes.sections/what-changing-an-ingredient-updates.md +44 -0
- package/agent-docs/author/recipes.sections/what-each-file-does.md +48 -0
- package/agent-docs/author/recipes.sections/what-happens-and-when.md +45 -0
- package/agent-docs/author/related-reading.md +143 -0
- package/agent-docs/author/related-reading.sections/automatic-footers.md +35 -0
- package/agent-docs/author/related-reading.sections/declare-relationships.md +68 -0
- package/agent-docs/author/related-reading.sections/display-related-documents.md +54 -0
- package/agent-docs/author/related-reading.sections/inspect-output-and-changes.md +32 -0
- package/agent-docs/author/related-reading.sections/reading-paths-in-section-markdown.md +32 -0
- package/agent-docs/author/related-reading.sections/related-reading.md +34 -0
- package/agent-docs/author/related-reading.sections/where-relationship-explanations-come-from.md +34 -0
- package/agent-docs/author/release-notes.md +153 -0
- package/agent-docs/author/search.md +299 -0
- package/agent-docs/author/search.sections/choose-a-provider.md +52 -0
- package/agent-docs/author/search.sections/cli-and-mcp-ranking-details.md +49 -0
- package/agent-docs/author/search.sections/hosted-semantic-search-limits.md +55 -0
- package/agent-docs/author/search.sections/html-markdown-and-agents.md +37 -0
- package/agent-docs/author/search.sections/lexical-search.md +78 -0
- package/agent-docs/author/search.sections/local-semantic-preview.md +43 -0
- package/agent-docs/author/search.sections/read-a-search-result-with-an-agent.md +41 -0
- package/agent-docs/author/search.sections/related-reading.md +45 -0
- package/agent-docs/author/search.sections/reuse-the-lexical-index.md +81 -0
- package/agent-docs/author/search.sections/turn-search-off.md +46 -0
- package/agent-docs/author/search.sections/use-the-search-box.md +39 -0
- package/agent-docs/author/search.sections/write-a-custom-provider.md +98 -0
- package/agent-docs/author/snippets.md +118 -0
- package/agent-docs/author/taxonomy.md +121 -0
- package/agent-docs/author/templates.md +231 -0
- package/agent-docs/author/templates.sections/built-in-feature-templates.md +52 -0
- package/agent-docs/author/templates.sections/built-in-templates.md +48 -0
- package/agent-docs/author/templates.sections/choose-formatting-enforcement-for-your-project.md +69 -0
- package/agent-docs/author/templates.sections/create-or-edit-a-project-template.md +76 -0
- package/agent-docs/author/templates.sections/keep-the-four-shapes-distinct.md +46 -0
- package/agent-docs/author/templates.sections/project-added-templates.md +39 -0
- package/agent-docs/author/templates.sections/related-reading.md +47 -0
- package/agent-docs/author/templates.sections/scaffold-a-page.md +53 -0
- package/agent-docs/author/templates.sections/short-cli-and-derived-values.md +56 -0
- package/agent-docs/author/templates.sections/what-every-template-gives-you.md +44 -0
- package/agent-docs/author/workspace/commands.md +92 -0
- package/agent-docs/author/workspace.md +104 -0
- package/agent-docs/author/writing-style.md +137 -0
- package/agent-docs/author/writing-style.sections/adapt-this-example.md +28 -0
- package/agent-docs/author/writing-style.sections/choose-components-by-reader-need.md +42 -0
- package/agent-docs/author/writing-style.sections/evidence-and-uncertainty.md +32 -0
- package/agent-docs/author/writing-style.sections/example-audience-and-scope.md +28 -0
- package/agent-docs/author/writing-style.sections/ingredients-recipes-and-cookbooks.md +36 -0
- package/agent-docs/author/writing-style.sections/page-purpose-and-structure.md +41 -0
- package/agent-docs/author/writing-style.sections/procedures-and-examples.md +32 -0
- package/agent-docs/author/writing-style.sections/related-reading.md +32 -0
- package/agent-docs/author/writing-style.sections/review-a-draft.md +30 -0
- package/agent-docs/author/writing-style.sections/reviewed-writing-examples.md +39 -0
- package/agent-docs/author/writing-style.sections/voice-and-explanations.md +39 -0
- package/agent-docs/changelog/2026-10-14-agent-readiness.md +29 -0
- package/agent-docs/changelog/2026-10-15-evaluation-builds.md +84 -0
- package/agent-docs/changelog/2026-10-16-navigation-layouts.md +72 -0
- package/agent-docs/changelog/2026-10-17-mcp-hosting.md +60 -0
- package/agent-docs/changelog/2026-10-18-search-and-tooltips.md +46 -0
- package/agent-docs/changelog/2026-10-19-visual-navigation.md +44 -0
- package/agent-docs/changelog/2026-10-25.md +45 -0
- package/agent-docs/changelog/2026-10-26.md +66 -0
- package/agent-docs/changelog/2026-10-27.md +85 -0
- package/agent-docs/changelog/authoring-preview.md +40 -0
- package/agent-docs/changelog/authoring-search.md +39 -0
- package/agent-docs/changelog/authoring-tools.md +34 -0
- package/agent-docs/changelog/working-tree-skill.md +38 -0
- package/agent-docs/changelog.md +115 -0
- package/agent-docs/chat/checks.md +175 -0
- package/agent-docs/chat/checks.sections/answer-ahead-of-time.md +38 -0
- package/agent-docs/chat/checks.sections/answer-for-one-audience.md +66 -0
- package/agent-docs/chat/checks.sections/answer-without-a-model.md +54 -0
- package/agent-docs/chat/checks.sections/follow-up-questions.md +54 -0
- package/agent-docs/chat/checks.sections/how-an-answer-is-checked.md +67 -0
- package/agent-docs/chat/checks.sections/questions-with-several-parts.md +44 -0
- package/agent-docs/chat/checks.sections/related-reading.md +42 -0
- package/agent-docs/chat/checks.sections/reuse-answers.md +50 -0
- package/agent-docs/chat/host.md +222 -0
- package/agent-docs/chat/host.sections/cap-the-daily-spend.md +78 -0
- package/agent-docs/chat/host.sections/keep-a-record-of-questions.md +64 -0
- package/agent-docs/chat/host.sections/related-reading.md +43 -0
- package/agent-docs/chat/passage-index.md +228 -0
- package/agent-docs/chat/passage-index.sections/build-the-index.md +72 -0
- package/agent-docs/chat/passage-index.sections/embed-passages.md +103 -0
- package/agent-docs/chat/passage-index.sections/how-the-default-chunker-splits-a-page.md +53 -0
- package/agent-docs/chat/passage-index.sections/limits.md +45 -0
- package/agent-docs/chat/passage-index.sections/passage-ids-and-links.md +52 -0
- package/agent-docs/chat/passage-index.sections/related-reading.md +42 -0
- package/agent-docs/chat/passage-index.sections/what-a-passage-contains.md +91 -0
- package/agent-docs/chat/prepared-answers.md +116 -0
- package/agent-docs/chat/settings.md +213 -0
- package/agent-docs/chat/settings.sections/choose-the-scorer.md +63 -0
- package/agent-docs/chat/settings.sections/configure-chat.md +80 -0
- package/agent-docs/chat/settings.sections/configure-retrieval.md +62 -0
- package/agent-docs/chat/settings.sections/related-reading.md +32 -0
- package/agent-docs/chat/settings.sections/send-extra-request-fields.md +42 -0
- package/agent-docs/chat/settings.sections/use-more-than-one-model.md +62 -0
- package/agent-docs/chat/settings.sections/when-the-scorer-is-down.md +42 -0
- package/agent-docs/chat/setup.md +97 -0
- package/agent-docs/chat.md +102 -0
- package/agent-docs/cli.md +445 -0
- package/agent-docs/cli.sections/audit-a-project-and-api-sources.md +102 -0
- package/agent-docs/cli.sections/author-pages.md +94 -0
- package/agent-docs/cli.sections/build-and-serve.md +144 -0
- package/agent-docs/cli.sections/inspect-config-and-operations.md +41 -0
- package/agent-docs/cli.sections/npm-scripts-in-this-repository.md +45 -0
- package/agent-docs/cli.sections/related-reading.md +33 -0
- package/agent-docs/cli.sections/search-and-chat.md +132 -0
- package/agent-docs/cli.sections/start-a-project.md +37 -0
- package/agent-docs/cli.sections/working-tree-authoring-tools.md +35 -0
- package/agent-docs/concepts.md +133 -0
- package/agent-docs/config/apis.md +136 -0
- package/agent-docs/config/content.md +264 -0
- package/agent-docs/config/content.sections/authoring.md +58 -0
- package/agent-docs/config/content.sections/badges.md +34 -0
- package/agent-docs/config/content.sections/callouts.md +34 -0
- package/agent-docs/config/content.sections/cookbooks.md +38 -0
- package/agent-docs/config/content.sections/frontmatter.md +75 -0
- package/agent-docs/config/content.sections/readerfilters.md +44 -0
- package/agent-docs/config/content.sections/related-reading.md +34 -0
- package/agent-docs/config/content.sections/relationships.md +76 -0
- package/agent-docs/config/content.sections/snippets.md +61 -0
- package/agent-docs/config/content.sections/templates.md +57 -0
- package/agent-docs/config/content.sections/variables.md +55 -0
- package/agent-docs/config/examples.md +354 -0
- package/agent-docs/config/examples.sections/feature-showcase.md +55 -0
- package/agent-docs/config/examples.sections/minimal-site.md +80 -0
- package/agent-docs/config/examples.sections/multilingual-help-center.md +110 -0
- package/agent-docs/config/examples.sections/parcel-api-documentation.md +153 -0
- package/agent-docs/config/examples.sections/related-reading.md +50 -0
- package/agent-docs/config/examples.sections/shared-company-preset.md +118 -0
- package/agent-docs/config/integrations.md +76 -0
- package/agent-docs/config/outputs.md +160 -0
- package/agent-docs/config/outputs.sections/exports.md +57 -0
- package/agent-docs/config/outputs.sections/metadata.md +42 -0
- package/agent-docs/config/outputs.sections/related-reading.md +34 -0
- package/agent-docs/config/publishing.md +219 -0
- package/agent-docs/config/publishing.sections/navigation.md +92 -0
- package/agent-docs/config/publishing.sections/redirects.md +79 -0
- package/agent-docs/config/publishing.sections/related-reading.md +33 -0
- package/agent-docs/config/site.md +193 -0
- package/agent-docs/config/site.sections/related-reading.md +33 -0
- package/agent-docs/config/site.sections/theme.md +74 -0
- package/agent-docs/config.md +195 -0
- package/agent-docs/configuration.md +384 -0
- package/agent-docs/configuration.sections/build-several-sites-from-shared-content.md +36 -0
- package/agent-docs/configuration.sections/change-inherited-lists-deliberately.md +76 -0
- package/agent-docs/configuration.sections/extract-a-section-with-include.md +75 -0
- package/agent-docs/configuration.sections/inspect-and-validate-changes.md +77 -0
- package/agent-docs/configuration.sections/related-reading.md +42 -0
- package/agent-docs/configuration.sections/separate-config-inheritance-from-page-metadata.md +54 -0
- package/agent-docs/configuration.sections/share-defaults-through-extends.md +121 -0
- package/agent-docs/configuration.sections/start-with-one-working-file.md +81 -0
- package/agent-docs/configuration.sections/understand-the-three-stages.md +59 -0
- package/agent-docs/configuration.sections/understand-where-paths-point.md +53 -0
- package/agent-docs/connect/mcp.md +85 -0
- package/agent-docs/contribute/agent-skills.md +72 -0
- package/agent-docs/cookbooks/authoring.md +68 -0
- package/agent-docs/cookbooks/site-workflows.md +59 -0
- package/agent-docs/cookbooks/welcome-email.md +55 -0
- package/agent-docs/documents.json +20058 -0
- package/agent-docs/example-api/cedar/create-enrollment-7af3e5d2.md +594 -0
- package/agent-docs/example-api/cedar/get-legacy-parcel-6758d051.md +122 -0
- package/agent-docs/example-api/cedar/get-parcel-edee10e6.md +122 -0
- package/agent-docs/example-api/cedar/list-parcels-0345fb5f.md +271 -0
- package/agent-docs/example-api/cedar/parcel-delivered-7d1ba6db.md +122 -0
- package/agent-docs/example-api/cedar/upload-manifest-1af17891.md +101 -0
- package/agent-docs/example-api/cedar.md +39 -0
- package/agent-docs/example-api/create-note.md +344 -0
- package/agent-docs/example-api/generated/get-note-cbedb319.md +165 -0
- package/agent-docs/example-api/write-note.md +55 -0
- package/agent-docs/explore.md +54 -0
- package/agent-docs/glossary.md +827 -0
- package/agent-docs/index.md +249 -0
- package/agent-docs/ingredients/audit-site.md +27 -0
- package/agent-docs/ingredients/build-site.md +29 -0
- package/agent-docs/ingredients/compile-framework.md +28 -0
- package/agent-docs/ingredients/complete-page.md +30 -0
- package/agent-docs/ingredients/inspect-agent-bundle.md +28 -0
- package/agent-docs/ingredients/inspect-build.md +41 -0
- package/agent-docs/ingredients/preview-site.md +31 -0
- package/agent-docs/ingredients/refresh-agent-bundle.md +29 -0
- package/agent-docs/ingredients/scaffold-page.md +28 -0
- package/agent-docs/non-goals.md +58 -0
- package/agent-docs/provenance.json +10 -0
- package/agent-docs/publish/agent-discovery.md +79 -0
- package/agent-docs/publish/agent-friendliness.md +201 -0
- package/agent-docs/publish/agent-friendliness.sections/discover-a-page-with-a-small-context-budget.md +61 -0
- package/agent-docs/publish/agent-friendliness.sections/distinguish-examples-from-a-real-service.md +48 -0
- package/agent-docs/publish/agent-friendliness.sections/evidence-has-a-scope.md +46 -0
- package/agent-docs/publish/agent-friendliness.sections/keep-shared-instructions-complete.md +48 -0
- package/agent-docs/publish/agent-friendliness.sections/related-reading.md +52 -0
- package/agent-docs/publish/agent-friendliness.sections/secret-handshake.md +50 -0
- package/agent-docs/publish/agent-friendliness.sections/try-the-page-controls.md +62 -0
- package/agent-docs/publish/agent-friendliness.sections/use-the-transport-your-client-supports.md +50 -0
- package/agent-docs/publish/agent-friendliness.sections/verify-the-page-and-detect-changes.md +58 -0
- package/agent-docs/publish/agent-friendliness.sections/what-an-agent-reads.md +68 -0
- package/agent-docs/publish/agent-friendliness.sections/what-happens-to-an-unsupported-component.md +60 -0
- package/agent-docs/publish/api-references.md +217 -0
- package/agent-docs/publish/api-references.sections/add-useful-examples.md +36 -0
- package/agent-docs/publish/api-references.sections/author-the-reference-page.md +65 -0
- package/agent-docs/publish/api-references.sections/build-and-verify-the-output.md +48 -0
- package/agent-docs/publish/api-references.sections/describe-filters-that-do-not-use-their-openapi-parameter-name.md +36 -0
- package/agent-docs/publish/api-references.sections/generate-many-pages-selectively.md +36 -0
- package/agent-docs/publish/api-references.sections/inspect-the-machine-readable-contract.md +36 -0
- package/agent-docs/publish/api-references.sections/link-guides-to-api-references.md +36 -0
- package/agent-docs/publish/api-references.sections/map-extension-values-to-shoalrun-status.md +36 -0
- package/agent-docs/publish/api-references.sections/preview-a-small-api-reference.md +38 -0
- package/agent-docs/publish/api-references.sections/publish-several-versions.md +36 -0
- package/agent-docs/publish/api-references.sections/put-the-spec-in-your-project.md +62 -0
- package/agent-docs/publish/api-references.sections/register-the-operation.md +64 -0
- package/agent-docs/publish/api-references.sections/related-reading.md +42 -0
- package/agent-docs/publish/api-references.sections/review-imported-content-before-publishing.md +54 -0
- package/agent-docs/publish/api-references.sections/use-a-template-for-editorial-context.md +36 -0
- package/agent-docs/publish/api-references.sections/what-readers-get.md +38 -0
- package/agent-docs/publish/audit.md +160 -0
- package/agent-docs/publish/audit.sections/add-project-tests.md +57 -0
- package/agent-docs/publish/audit.sections/check-agent-evaluation-reports.md +52 -0
- package/agent-docs/publish/audit.sections/check-before-pushing.md +80 -0
- package/agent-docs/publish/audit.sections/connect-a-documentation-test-suite.md +54 -0
- package/agent-docs/publish/audit.sections/read-the-report.md +67 -0
- package/agent-docs/publish/audit.sections/related-reading.md +47 -0
- package/agent-docs/publish/content-export.md +208 -0
- package/agent-docs/publish/content-export.sections/assets-downloads-and-notices.md +40 -0
- package/agent-docs/publish/content-export.sections/check-the-result.md +27 -0
- package/agent-docs/publish/content-export.sections/export-selected-pages.md +113 -0
- package/agent-docs/publish/content-export.sections/inspect-the-manifest.md +29 -0
- package/agent-docs/publish/content-export.sections/prerequisites.md +29 -0
- package/agent-docs/publish/content-export.sections/related-reading.md +35 -0
- package/agent-docs/publish/content-export.sections/review-exported-api-material.md +44 -0
- package/agent-docs/publish/content-export.sections/try-the-help-drawer-example.md +34 -0
- package/agent-docs/publish/content-export.sections/what-the-representations-retain.md +43 -0
- package/agent-docs/publish/content-negotiation.md +121 -0
- package/agent-docs/publish/content-negotiation.sections/hosting-contract.md +60 -0
- package/agent-docs/publish/content-negotiation.sections/missing-pages.md +51 -0
- package/agent-docs/publish/content-negotiation.sections/related-reading.md +45 -0
- package/agent-docs/publish/content-negotiation.sections/validators-and-manifest-links.md +49 -0
- package/agent-docs/publish/content-negotiation.sections/verify-the-deployed-url.md +62 -0
- package/agent-docs/publish/content-negotiation.sections/what-if-the-host-cannot-negotiate.md +47 -0
- package/agent-docs/publish/content-negotiation.sections/what-shoalrun-builds-and-what-the-host-does.md +49 -0
- package/agent-docs/publish/content-negotiation.sections/why-this-matters.md +47 -0
- package/agent-docs/publish/deployment-check.md +72 -0
- package/agent-docs/publish/evals.md +175 -0
- package/agent-docs/publish/evals.sections/add-the-audit-hook.md +63 -0
- package/agent-docs/publish/evals.sections/check-the-report.md +36 -0
- package/agent-docs/publish/evals.sections/define-a-task-file.md +47 -0
- package/agent-docs/publish/evals.sections/diagnose-a-different-build.md +42 -0
- package/agent-docs/publish/evals.sections/prepare-a-report-for-the-built-site.md +39 -0
- package/agent-docs/publish/evals.sections/related-reading.md +36 -0
- package/agent-docs/publish/evals.sections/run-and-review-the-tasks.md +54 -0
- package/agent-docs/publish/evals.sections/shoalrun-s-own-example.md +42 -0
- package/agent-docs/publish/host-adapters.md +60 -0
- package/agent-docs/publish/manni.md +227 -0
- package/agent-docs/publish/manni.sections/check-the-result.md +40 -0
- package/agent-docs/publish/manni.sections/how-this-site-uses-manni.md +83 -0
- package/agent-docs/publish/manni.sections/optional-custom-policies.md +42 -0
- package/agent-docs/publish/manni.sections/prerequisites.md +40 -0
- package/agent-docs/publish/mcp-analytics.md +356 -0
- package/agent-docs/publish/mcp-analytics.sections/adapter-exports.md +50 -0
- package/agent-docs/publish/mcp-analytics.sections/enable-analytics.md +45 -0
- package/agent-docs/publish/mcp-analytics.sections/event-fields-and-service-mappings.md +53 -0
- package/agent-docs/publish/mcp-analytics.sections/optionally-collect-intent-and-group-calls.md +62 -0
- package/agent-docs/publish/mcp-analytics.sections/optionally-identify-the-client-and-model.md +54 -0
- package/agent-docs/publish/mcp-analytics.sections/related-reading.md +36 -0
- package/agent-docs/publish/mcp-analytics.sections/safeguards-and-limits.md +46 -0
- package/agent-docs/publish/mcp.md +190 -0
- package/agent-docs/publish/mcp.sections/check-budgets-and-errors.md +52 -0
- package/agent-docs/publish/mcp.sections/choose-the-documentation-source.md +51 -0
- package/agent-docs/publish/mcp.sections/configure-the-client.md +55 -0
- package/agent-docs/publish/mcp.sections/generate-a-vercel-endpoint.md +50 -0
- package/agent-docs/publish/mcp.sections/related-reading.md +42 -0
- package/agent-docs/publish/mcp.sections/search-then-read.md +53 -0
- package/agent-docs/publish/mcp.sections/serve-a-public-endpoint-on-node.md +79 -0
- package/agent-docs/publish/mcp.sections/verify-the-connection.md +40 -0
- package/agent-docs/publish/mcp.sections/why-offer-mcp-for-public-docs.md +42 -0
- package/agent-docs/publish/openapi-extension-mappings.md +84 -0
- package/agent-docs/publish/output.md +220 -0
- package/agent-docs/publish/output.sections/api-contracts.md +48 -0
- package/agent-docs/publish/output.sections/code-highlighting.md +38 -0
- package/agent-docs/publish/output.sections/current-limits.md +40 -0
- package/agent-docs/publish/output.sections/incremental-sync.md +69 -0
- package/agent-docs/publish/output.sections/manifest-records-and-sections.md +46 -0
- package/agent-docs/publish/output.sections/navigation-section-indexes.md +42 -0
- package/agent-docs/publish/output.sections/page-formats.md +46 -0
- package/agent-docs/publish/output.sections/published-output-contract.md +58 -0
- package/agent-docs/publish/output.sections/reader-appearance-and-controls.md +44 -0
- package/agent-docs/publish/output.sections/related-reading.md +34 -0
- package/agent-docs/publish/output.sections/response-identity.md +38 -0
- package/agent-docs/publish/output.sections/site-files.md +64 -0
- package/agent-docs/publish/output.sections/validate-an-existing-build-locally.md +48 -0
- package/agent-docs/publish/output.sections/where-files-go.md +49 -0
- package/agent-docs/publish/publications.md +153 -0
- package/agent-docs/publish/revisions.md +104 -0
- package/agent-docs/publish/seo.md +119 -0
- package/agent-docs/publish/single-source-sites.md +168 -0
- package/agent-docs/publish/troubleshooting.md +112 -0
- package/agent-docs/publish/vercel.md +130 -0
- package/agent-docs/publish/vercel.sections/check-the-deployment.md +54 -0
- package/agent-docs/publish/vercel.sections/include-an-mcp-endpoint.md +38 -0
- package/agent-docs/publish/vercel.sections/prepare-your-project.md +52 -0
- package/agent-docs/publish/vercel.sections/related-reading.md +38 -0
- package/agent-docs/publish.md +95 -0
- package/agent-docs/recipes/add-page.md +194 -0
- package/agent-docs/recipes/add-page.sections/audit-the-shoalrun-docs-project.md +40 -0
- package/agent-docs/recipes/add-page.sections/before-you-start.md +33 -0
- package/agent-docs/recipes/add-page.sections/build-the-shoalrun-docs-site.md +42 -0
- package/agent-docs/recipes/add-page.sections/check-agent-search-and-page-lookup.md +42 -0
- package/agent-docs/recipes/add-page.sections/check-the-built-page-artifacts.md +54 -0
- package/agent-docs/recipes/add-page.sections/check-the-outcome.md +28 -0
- package/agent-docs/recipes/add-page.sections/complete-the-guide-and-add-navigation.md +42 -0
- package/agent-docs/recipes/add-page.sections/install-the-site-dependencies.md +41 -0
- package/agent-docs/recipes/add-page.sections/regenerate-the-agent-documentation-bundle.md +42 -0
- package/agent-docs/recipes/add-page.sections/related-reading.md +30 -0
- package/agent-docs/recipes/add-page.sections/scaffold-a-new-guide.md +42 -0
- package/agent-docs/recipes/audit-docs.md +122 -0
- package/agent-docs/recipes/build-docs.md +105 -0
- package/agent-docs/recipes/preview-hybrid-search.md +84 -0
- package/agent-docs/recipes/preview-page.md +124 -0
- package/agent-docs/recipes/queue-email.md +49 -0
- package/agent-docs/recipes/refresh-agent-docs.md +109 -0
- package/agent-docs/recipes/send-welcome-email.md +92 -0
- package/agent-docs/reference/agent-skills.md +73 -0
- package/agent-docs/search-and-chat.md +87 -0
- package/agent-docs/search-index.json +1 -0
- package/agent-docs/start.md +197 -0
- package/agent-docs/start.sections/add-the-page-to-navigation.md +50 -0
- package/agent-docs/start.sections/build-and-check-both-outputs.md +50 -0
- package/agent-docs/start.sections/build-this-site.md +35 -0
- package/agent-docs/start.sections/check-writing-style.md +35 -0
- package/agent-docs/start.sections/create-a-page.md +105 -0
- package/agent-docs/start.sections/make-it-yours.md +37 -0
- package/agent-docs/start.sections/prerequisites.md +37 -0
- package/agent-docs/start.sections/related-reading.md +45 -0
- package/agent-docs/start.sections/start-your-own-project.md +53 -0
- package/agent-docs/status.md +75 -0
- package/agent-docs/styling/color-modes.md +85 -0
- package/agent-docs/styling/footer.md +67 -0
- package/agent-docs/styling/header.md +65 -0
- package/agent-docs/styling/layouts.md +193 -0
- package/agent-docs/styling/layouts.sections/build-a-landing-page.md +61 -0
- package/agent-docs/styling/layouts.sections/build-a-splash-page.md +88 -0
- package/agent-docs/styling/layouts.sections/control-navigation-tabs.md +51 -0
- package/agent-docs/styling/layouts.sections/customize-the-hero.md +50 -0
- package/agent-docs/styling/layouts.sections/hero.md +83 -0
- package/agent-docs/styling/layouts.sections/related-reading.md +42 -0
- package/agent-docs/styling/palettes.md +140 -0
- package/agent-docs/styling/share-images.md +105 -0
- package/agent-docs/styling/themes.md +125 -0
- package/agent-docs/styling/try.md +106 -0
- package/agent-docs/what-is-shoalrun.md +56 -0
- package/assets/analytics.js +72 -0
- package/assets/ask-widget.js +320 -0
- package/assets/code-samples.js +28 -0
- package/assets/components.js +32 -0
- package/assets/cookbook-chooser.js +170 -0
- package/assets/copy-markdown.js +24 -0
- package/assets/example-panel.js +77 -0
- package/assets/file-tree.js +49 -0
- package/assets/image-viewer.js +41 -0
- package/assets/mode.js +26 -0
- package/assets/navigation.js +233 -0
- package/assets/reader-filters.js +305 -0
- package/assets/reader.js +111 -0
- package/assets/search-highlight.js +32 -0
- package/assets/search-lexical.js +66 -0
- package/assets/search.js +150 -0
- package/assets/table-filter.js +63 -0
- package/assets/tabs.js +80 -0
- package/assets/theme-preview.css +17 -0
- package/assets/theme-preview.js +135 -0
- package/assets/theme-switcher.js +113 -0
- package/assets/tooltips.js +81 -0
- package/assets/walkthrough.js +233 -0
- package/dist/agent-discovery.d.ts +11 -0
- package/dist/agent-discovery.js +37 -0
- package/dist/analytics.d.ts +2 -0
- package/dist/analytics.js +13 -0
- package/dist/answer-cache.d.ts +24 -0
- package/dist/answer-cache.js +55 -0
- package/dist/answer-cards.d.ts +71 -0
- package/dist/answer-cards.js +148 -0
- package/dist/api-embeds.d.ts +22 -0
- package/dist/api-embeds.js +84 -0
- package/dist/api-identity.d.ts +6 -0
- package/dist/api-identity.js +7 -0
- package/dist/api-materialize.d.ts +12 -0
- package/dist/api-materialize.js +120 -0
- package/dist/api-publication-plan.d.ts +86 -0
- package/dist/api-publication-plan.js +187 -0
- package/dist/api-publication-review.d.ts +23 -0
- package/dist/api-publication-review.js +58 -0
- package/dist/api-selection.d.ts +21 -0
- package/dist/api-selection.js +84 -0
- package/dist/api.d.ts +74 -0
- package/dist/api.js +782 -0
- package/dist/artifact-bundle.d.ts +96 -0
- package/dist/artifact-bundle.js +306 -0
- package/dist/ask-function.d.ts +19 -0
- package/dist/ask-function.js +139 -0
- package/dist/ask-handler.d.ts +38 -0
- package/dist/ask-handler.js +157 -0
- package/dist/ask-log-kv.d.ts +14 -0
- package/dist/ask-log-kv.js +69 -0
- package/dist/ask-log.d.ts +106 -0
- package/dist/ask-log.js +159 -0
- package/dist/ask-setup.d.ts +43 -0
- package/dist/ask-setup.js +99 -0
- package/dist/ask.d.ts +152 -0
- package/dist/ask.js +532 -0
- package/dist/audit.d.ts +29 -0
- package/dist/audit.js +171 -0
- package/dist/authored-change.d.ts +22 -0
- package/dist/authored-change.js +47 -0
- package/dist/authoring-api.d.ts +18 -0
- package/dist/authoring-api.js +15 -0
- package/dist/authoring-findings.d.ts +31 -0
- package/dist/authoring-findings.js +104 -0
- package/dist/authoring-guidance.d.ts +15 -0
- package/dist/authoring-guidance.js +57 -0
- package/dist/authoring-preview.d.ts +24 -0
- package/dist/authoring-preview.js +160 -0
- package/dist/authoring-project-command.d.ts +7 -0
- package/dist/authoring-project-command.js +52 -0
- package/dist/authoring-project.d.ts +104 -0
- package/dist/authoring-project.js +287 -0
- package/dist/authoring-review-command.d.ts +1 -0
- package/dist/authoring-review-command.js +68 -0
- package/dist/authoring-review.d.ts +72 -0
- package/dist/authoring-review.js +71 -0
- package/dist/authoring-snapshot.d.ts +66 -0
- package/dist/authoring-snapshot.js +293 -0
- package/dist/authoring-validation-command.d.ts +1 -0
- package/dist/authoring-validation-command.js +54 -0
- package/dist/authoring-validation.d.ts +101 -0
- package/dist/authoring-validation.js +348 -0
- package/dist/badges.d.ts +16 -0
- package/dist/badges.js +57 -0
- package/dist/budget-store.d.ts +21 -0
- package/dist/budget-store.js +90 -0
- package/dist/budget.d.ts +45 -0
- package/dist/budget.js +128 -0
- package/dist/build-info.d.ts +10 -0
- package/dist/build-info.js +15 -0
- package/dist/callouts.d.ts +18 -0
- package/dist/callouts.js +63 -0
- package/dist/cards.d.ts +35 -0
- package/dist/cards.js +237 -0
- package/dist/chat-config.d.ts +117 -0
- package/dist/chat-config.js +400 -0
- package/dist/chat-pause.d.ts +1 -0
- package/dist/chat-pause.js +3 -0
- package/dist/chat.d.ts +46 -0
- package/dist/chat.js +78 -0
- package/dist/cli-discovery.d.ts +4 -0
- package/dist/cli-discovery.js +86 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +750 -0
- package/dist/code-samples.d.ts +50 -0
- package/dist/code-samples.js +181 -0
- package/dist/compact-discovery.d.ts +15 -0
- package/dist/compact-discovery.js +78 -0
- package/dist/compiler-config.d.ts +67 -0
- package/dist/compiler-config.js +66 -0
- package/dist/compiler.d.ts +208 -0
- package/dist/compiler.js +524 -0
- package/dist/component-bundle.d.ts +4 -0
- package/dist/component-bundle.js +32 -0
- package/dist/component-content.d.ts +78 -0
- package/dist/component-content.js +47 -0
- package/dist/component-manifest.d.ts +15 -0
- package/dist/component-manifest.js +84 -0
- package/dist/component-names.d.ts +1 -0
- package/dist/component-names.js +1 -0
- package/dist/component-plugins.d.ts +28 -0
- package/dist/component-plugins.js +141 -0
- package/dist/component-transform.d.ts +10 -0
- package/dist/component-transform.js +697 -0
- package/dist/components.d.ts +2 -0
- package/dist/components.js +1 -0
- package/dist/config.d.ts +29 -0
- package/dist/config.js +149 -0
- package/dist/content-export-assets.d.ts +23 -0
- package/dist/content-export-assets.js +103 -0
- package/dist/content-export-command.d.ts +20 -0
- package/dist/content-export-command.js +57 -0
- package/dist/content-export-config.d.ts +16 -0
- package/dist/content-export-config.js +50 -0
- package/dist/content-export-render.d.ts +12 -0
- package/dist/content-export-render.js +132 -0
- package/dist/content-export.d.ts +30 -0
- package/dist/content-export.js +307 -0
- package/dist/content-filter.d.ts +4 -0
- package/dist/content-filter.js +16 -0
- package/dist/content-source.d.ts +100 -0
- package/dist/content-source.js +42 -0
- package/dist/content-workspace.d.ts +293 -0
- package/dist/content-workspace.js +69 -0
- package/dist/content.d.ts +41 -0
- package/dist/content.js +176 -0
- package/dist/cookbook-chooser.d.ts +19 -0
- package/dist/cookbook-chooser.js +56 -0
- package/dist/dev.d.ts +2 -0
- package/dist/dev.js +113 -0
- package/dist/diagram-svg.d.ts +1 -0
- package/dist/diagram-svg.js +44 -0
- package/dist/diagrams.d.ts +7 -0
- package/dist/diagrams.js +102 -0
- package/dist/docs-author.d.ts +86 -0
- package/dist/docs-author.js +380 -0
- package/dist/docs-command.d.ts +8 -0
- package/dist/docs-command.js +62 -0
- package/dist/docs-eval.d.ts +146 -0
- package/dist/docs-eval.js +231 -0
- package/dist/docs-mcp.d.ts +12 -0
- package/dist/docs-mcp.js +82 -0
- package/dist/docs-tool.d.ts +81 -0
- package/dist/docs-tool.js +7 -0
- package/dist/document-sync.d.ts +36 -0
- package/dist/document-sync.js +58 -0
- package/dist/documentation-core.d.ts +148 -0
- package/dist/documentation-core.js +160 -0
- package/dist/embeddings.d.ts +68 -0
- package/dist/embeddings.js +198 -0
- package/dist/focused-audit.d.ts +10 -0
- package/dist/focused-audit.js +69 -0
- package/dist/focused-openapi.d.ts +2 -0
- package/dist/focused-openapi.js +140 -0
- package/dist/fonts.d.ts +54 -0
- package/dist/fonts.js +92 -0
- package/dist/freshness.d.ts +7 -0
- package/dist/freshness.js +58 -0
- package/dist/frontmatter.d.ts +24 -0
- package/dist/frontmatter.js +342 -0
- package/dist/function-package.d.ts +1 -0
- package/dist/function-package.js +58 -0
- package/dist/highlight.d.ts +14 -0
- package/dist/highlight.js +114 -0
- package/dist/html-renderer.d.ts +10 -0
- package/dist/html-renderer.js +63 -0
- package/dist/icons.d.ts +8 -0
- package/dist/icons.js +40 -0
- package/dist/index-build.d.ts +55 -0
- package/dist/index-build.js +227 -0
- package/dist/ingredient-draft.d.ts +17 -0
- package/dist/ingredient-draft.js +94 -0
- package/dist/ingredient-workflow.d.ts +8 -0
- package/dist/ingredient-workflow.js +25 -0
- package/dist/init.d.ts +8 -0
- package/dist/init.js +66 -0
- package/dist/jev.d.ts +62 -0
- package/dist/jev.js +190 -0
- package/dist/link-audit.d.ts +12 -0
- package/dist/link-audit.js +146 -0
- package/dist/llms-discovery.d.ts +11 -0
- package/dist/llms-discovery.js +23 -0
- package/dist/markdown-sections.d.ts +15 -0
- package/dist/markdown-sections.js +60 -0
- package/dist/markdown-size.d.ts +7 -0
- package/dist/markdown-size.js +6 -0
- package/dist/mcp-analytics.d.ts +38 -0
- package/dist/mcp-analytics.js +35 -0
- package/dist/mcp-artifacts.d.ts +2 -0
- package/dist/mcp-artifacts.js +78 -0
- package/dist/mcp-client-metadata.d.ts +18 -0
- package/dist/mcp-client-metadata.js +69 -0
- package/dist/mcp-config.d.ts +23 -0
- package/dist/mcp-config.js +56 -0
- package/dist/mcp-http.d.ts +19 -0
- package/dist/mcp-http.js +157 -0
- package/dist/mcp-integrity.d.ts +3 -0
- package/dist/mcp-integrity.js +4 -0
- package/dist/mcp-node.d.ts +4 -0
- package/dist/mcp-node.js +68 -0
- package/dist/mcp-vercel-runtime.d.ts +3 -0
- package/dist/mcp-vercel-runtime.js +36 -0
- package/dist/mcp-vercel.d.ts +15 -0
- package/dist/mcp-vercel.js +65 -0
- package/dist/metadata-provider.d.ts +19 -0
- package/dist/metadata-provider.js +38 -0
- package/dist/negotiation.d.ts +10 -0
- package/dist/negotiation.js +35 -0
- package/dist/not-found.d.ts +16 -0
- package/dist/not-found.js +25 -0
- package/dist/output-commit.d.ts +1 -0
- package/dist/output-commit.js +133 -0
- package/dist/output-location.d.ts +3 -0
- package/dist/output-location.js +30 -0
- package/dist/page-materialization.d.ts +78 -0
- package/dist/page-materialization.js +132 -0
- package/dist/page-renderer.d.ts +71 -0
- package/dist/page-renderer.js +177 -0
- package/dist/palettes.d.ts +41 -0
- package/dist/palettes.js +160 -0
- package/dist/procedure-components.d.ts +2 -0
- package/dist/procedure-components.js +94 -0
- package/dist/project-navigation.d.ts +41 -0
- package/dist/project-navigation.js +190 -0
- package/dist/provider-http.d.ts +10 -0
- package/dist/provider-http.js +60 -0
- package/dist/publication-manifest.d.ts +229 -0
- package/dist/publication-manifest.js +53 -0
- package/dist/publication-plan.d.ts +34 -0
- package/dist/publication-plan.js +85 -0
- package/dist/publication-render.d.ts +71 -0
- package/dist/publication-render.js +92 -0
- package/dist/reader-filters.d.ts +30 -0
- package/dist/reader-filters.js +105 -0
- package/dist/recipe-draft.d.ts +17 -0
- package/dist/recipe-draft.js +147 -0
- package/dist/reference-audit.d.ts +18 -0
- package/dist/reference-audit.js +169 -0
- package/dist/remote-import.d.ts +62 -0
- package/dist/remote-import.js +292 -0
- package/dist/representation-tree.d.ts +3 -0
- package/dist/representation-tree.js +320 -0
- package/dist/retrieval-config.d.ts +30 -0
- package/dist/retrieval-config.js +83 -0
- package/dist/retrieval.d.ts +60 -0
- package/dist/retrieval.js +228 -0
- package/dist/scaffold.d.ts +39 -0
- package/dist/scaffold.js +167 -0
- package/dist/search-config.d.ts +8 -0
- package/dist/search-config.js +26 -0
- package/dist/search-handler.d.ts +16 -0
- package/dist/search-handler.js +111 -0
- package/dist/search-identifier.d.ts +3 -0
- package/dist/search-identifier.js +25 -0
- package/dist/search-literal.d.ts +1 -0
- package/dist/search-literal.js +28 -0
- package/dist/search-query.d.ts +54 -0
- package/dist/search-query.js +120 -0
- package/dist/search-results.d.ts +6 -0
- package/dist/search-results.js +45 -0
- package/dist/search-snippet.d.ts +11 -0
- package/dist/search-snippet.js +93 -0
- package/dist/search-synonyms.d.ts +8 -0
- package/dist/search-synonyms.js +46 -0
- package/dist/semantic-markdown.d.ts +10 -0
- package/dist/semantic-markdown.js +39 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.js +223 -0
- package/dist/share-images.d.ts +24 -0
- package/dist/share-images.js +187 -0
- package/dist/site-path.d.ts +2 -0
- package/dist/site-path.js +15 -0
- package/dist/sitemap.d.ts +8 -0
- package/dist/sitemap.js +58 -0
- package/dist/snippets.d.ts +19 -0
- package/dist/snippets.js +84 -0
- package/dist/structured-model-output.d.ts +6 -0
- package/dist/structured-model-output.js +21 -0
- package/dist/subject-deprecation.d.ts +21 -0
- package/dist/subject-deprecation.js +57 -0
- package/dist/surface-text.d.ts +4 -0
- package/dist/surface-text.js +42 -0
- package/dist/taxonomy.d.ts +14 -0
- package/dist/taxonomy.js +88 -0
- package/dist/turnstile.d.ts +21 -0
- package/dist/turnstile.js +52 -0
- package/dist/vale.d.ts +28 -0
- package/dist/vale.js +103 -0
- package/dist/vercel-function.d.ts +21 -0
- package/dist/vercel-function.js +108 -0
- package/dist/vercel.d.ts +11 -0
- package/dist/vercel.js +103 -0
- package/dist/walkthrough.d.ts +25 -0
- package/dist/walkthrough.js +336 -0
- package/dist/yaml-value.d.ts +2 -0
- package/dist/yaml-value.js +36 -0
- package/example-configs/api-docs/README.md +59 -0
- package/example-configs/api-docs/apis/cedar-parcel.yaml +413 -0
- package/example-configs/api-docs/content/create-enrollment.mdx +11 -0
- package/example-configs/api-docs/content/overview.mdx +36 -0
- package/example-configs/api-docs/content/quickstart.mdx +52 -0
- package/example-configs/api-docs/docs.config.yaml +104 -0
- package/example-configs/faceted-sites/README.md +31 -0
- package/example-configs/faceted-sites/base.yaml +30 -0
- package/example-configs/faceted-sites/content/api.md +12 -0
- package/example-configs/faceted-sites/content/home.md +10 -0
- package/example-configs/faceted-sites/content/operations.md +12 -0
- package/example-configs/faceted-sites/developers.config.yaml +8 -0
- package/example-configs/faceted-sites/docs.config.yaml +7 -0
- package/example-configs/faceted-sites/europe.config.yaml +9 -0
- package/example-configs/minimal/content/install.mdx +12 -0
- package/example-configs/minimal/content/welcome.mdx +8 -0
- package/example-configs/minimal/docs.config.yaml +31 -0
- package/example-configs/multilingual/content/de/home.mdx +9 -0
- package/example-configs/multilingual/content/de/reset-password.mdx +9 -0
- package/example-configs/multilingual/content/home.mdx +10 -0
- package/example-configs/multilingual/content/reset-password.mdx +12 -0
- package/example-configs/multilingual/docs.config.yaml +61 -0
- package/example-configs/multilingual/snippets/contact.mdx +1 -0
- package/example-configs/notifications/apis/notifications.yaml +132 -0
- package/example-configs/notifications/content/cookbook.mdx +17 -0
- package/example-configs/notifications/content/get-message.mdx +14 -0
- package/example-configs/notifications/content/queue-email.mdx +42 -0
- package/example-configs/notifications/content/queue-push.mdx +33 -0
- package/example-configs/notifications/content/queue-sms.mdx +33 -0
- package/example-configs/notifications/content/send-email.mdx +14 -0
- package/example-configs/notifications/content/send-push.mdx +14 -0
- package/example-configs/notifications/content/send-sms.mdx +14 -0
- package/example-configs/notifications/content/start.mdx +13 -0
- package/example-configs/notifications/content/welcome-cookbook.mdx +21 -0
- package/example-configs/notifications/content/welcome-email.mdx +82 -0
- package/example-configs/notifications/demo.mjs +43 -0
- package/example-configs/notifications/docs.config.yaml +88 -0
- package/example-configs/notifications/ingredient-drafts/README.md +41 -0
- package/example-configs/notifications/ingredient-drafts/check-delivery.mdx +13 -0
- package/example-configs/notifications/ingredient-drafts/queue-welcome-email.mdx +48 -0
- package/example-configs/notifications/ingredient-specs/queue-welcome-email.yaml +7 -0
- package/example-configs/notifications/ingredients/check-delivery.mdx +42 -0
- package/example-configs/notifications/ingredients/queue-welcome-email.mdx +37 -0
- package/example-configs/notifications/recipe-drafts/send-welcome-email.mdx +91 -0
- package/example-configs/notifications/recipe-specs/send-welcome-email.yaml +11 -0
- package/example-configs/reference-stress/README.md +32 -0
- package/example-configs/reference-stress/apis/cedar-parcel.yaml +413 -0
- package/example-configs/reference-stress/content/enrollment-shapes.mdx +16 -0
- package/example-configs/reference-stress/content/overview.mdx +14 -0
- package/example-configs/reference-stress/docs.config.yaml +55 -0
- package/example-configs/shared-preset/shared/company-docs.yaml +46 -0
- package/example-configs/shared-preset/shared/runbook.mdx +7 -0
- package/example-configs/shared-preset/site/content/failed-invoices.mdx +15 -0
- package/example-configs/shared-preset/site/content/start.mdx +9 -0
- package/example-configs/shared-preset/site/docs.config.yaml +18 -0
- package/example-configs/showcase/README.md +20 -0
- package/example-configs/showcase/apis/cedar-parcel.yaml +413 -0
- package/example-configs/showcase/content/assets/collection.svg +1 -0
- package/example-configs/showcase/content/code.mdx +100 -0
- package/example-configs/showcase/content/create-enrollment.mdx +11 -0
- package/example-configs/showcase/content/features.mdx +39 -0
- package/example-configs/showcase/content/landing.mdx +36 -0
- package/example-configs/showcase/content/overview.mdx +42 -0
- package/example-configs/showcase/content/personalization.mdx +38 -0
- package/example-configs/showcase/content/preview.mdx +35 -0
- package/example-configs/showcase/content/procedures.mdx +88 -0
- package/example-configs/showcase/content/quickstart.mdx +64 -0
- package/example-configs/showcase/content/reading.mdx +99 -0
- package/example-configs/showcase/content/verify.mdx +27 -0
- package/example-configs/showcase/content/visuals.mdx +47 -0
- package/example-configs/showcase/content/workflows.mdx +12 -0
- package/example-configs/showcase/docs.config.yaml +149 -0
- package/example-configs/showcase/snippets/sandbox.mdx +1 -0
- package/examples/analytics/README.md +56 -0
- package/examples/analytics/inspector.js +25 -0
- package/examples/analytics/posthog.js +36 -0
- package/examples/components/comparison.mjs +8 -0
- package/examples/components/components.json +6 -0
- package/examples/components/copy-text/LICENSE.react-dom.txt +21 -0
- package/examples/components/copy-text/LICENSE.react.txt +21 -0
- package/examples/components/copy-text/LICENSE.scheduler.txt +21 -0
- package/examples/components/copy-text/browser.jsx +21 -0
- package/examples/components/copy-text/components.json +6 -0
- package/examples/components/copy-text/package-lock.json +41 -0
- package/examples/components/copy-text/package.json +9 -0
- package/examples/components/copy-text/plugin.mjs +5 -0
- package/examples/components/retry-budget/LICENSE.react-dom.txt +21 -0
- package/examples/components/retry-budget/LICENSE.react.txt +21 -0
- package/examples/components/retry-budget/LICENSE.scheduler.txt +21 -0
- package/examples/components/retry-budget/browser.jsx +50 -0
- package/examples/components/retry-budget/components.json +6 -0
- package/examples/components/retry-budget/model.js +22 -0
- package/examples/components/retry-budget/package-lock.json +41 -0
- package/examples/components/retry-budget/package.json +9 -0
- package/examples/components/retry-budget/plugin.mjs +31 -0
- package/examples/components/retry-budget/policy.json +9 -0
- package/examples/components/retry-budget/style.css +25 -0
- package/examples/diagrams/d2-gallery.json +138 -0
- package/examples/diagrams/gallery.json +236 -0
- package/examples/help-drawer/README.md +44 -0
- package/examples/help-drawer/app.js +53 -0
- package/examples/help-drawer/components/components.json +1 -0
- package/examples/help-drawer/components/support.mjs +10 -0
- package/examples/help-drawer/content/account.md +8 -0
- package/examples/help-drawer/content/billing.mdx +29 -0
- package/examples/help-drawer/content/keys.mdx +46 -0
- package/examples/help-drawer/content/settings.svg +1 -0
- package/examples/help-drawer/docs.config.yaml +30 -0
- package/examples/help-drawer/index.html +26 -0
- package/examples/help-drawer/preview.mjs +33 -0
- package/examples/mcp-analytics/README.md +59 -0
- package/examples/mcp-analytics/posthog.mjs +159 -0
- package/package.json +100 -4
- package/schemas/content-export.schema.json +55 -0
- package/skills/shoalrun-author/SKILL.md +52 -0
- package/skills/shoalrun-component-author/SKILL.md +24 -0
- package/skills/shoalrun-recipes/SKILL.md +25 -0
- package/skills/shoalrun-setup/SKILL.md +34 -0
- package/skills/shoalrun-walkthrough/SKILL.md +18 -0
- package/styles/fonts/figtree-LICENSE.txt +93 -0
- package/styles/fonts/figtree-italic.woff2 +0 -0
- package/styles/fonts/figtree.woff2 +0 -0
- package/styles/fonts/inter-LICENSE.txt +93 -0
- package/styles/fonts/inter-italic.woff2 +0 -0
- package/styles/fonts/inter.woff2 +0 -0
- package/styles/fonts/jetbrains-mono-LICENSE.txt +93 -0
- package/styles/fonts/jetbrains-mono.woff2 +0 -0
- package/styles/fonts/jost-LICENSE.txt +93 -0
- package/styles/fonts/jost-italic.woff2 +0 -0
- package/styles/fonts/jost.woff2 +0 -0
- package/styles/fonts/share/figtree-400.ttf +0 -0
- package/styles/fonts/share/figtree-700.ttf +0 -0
- package/styles/fonts/share/inter-400.ttf +0 -0
- package/styles/fonts/share/inter-700.ttf +0 -0
- package/styles/fonts/share/jetbrains-mono-700.ttf +0 -0
- package/styles/fonts/share/jost-italic-800.ttf +0 -0
- package/styles/fonts/share/metrics.json +1 -0
- package/styles/fonts/share/source-serif-4-400.ttf +0 -0
- package/styles/fonts/source-serif-4-LICENSE.txt +93 -0
- package/styles/fonts/source-serif-4-italic.woff2 +0 -0
- package/styles/fonts/source-serif-4.woff2 +0 -0
- package/styles/header.css +56 -0
- package/styles/site.css +825 -0
- package/styles/themes/ledger.css +93 -0
- package/styles/themes/palettes/amethyst.yaml +127 -0
- package/styles/themes/palettes/coral.yaml +127 -0
- package/styles/themes/palettes/harbor.yaml +127 -0
- package/styles/themes/palettes/ink.yaml +127 -0
- package/styles/themes/palettes/kelp.yaml +127 -0
- package/styles/themes/palettes/vice.yaml +127 -0
- package/styles/themes/reef.css +68 -0
- package/styles/themes/vice.css +56 -0
- package/styles/tokens.css +91 -0
- package/templates/api-reference.mdx +133 -0
- package/templates/cookbook.mdx +38 -0
- package/templates/explanation.mdx +76 -0
- package/templates/guide.mdx +175 -0
- package/templates/how-to.mdx +171 -0
- package/templates/ingredient.mdx +53 -0
- package/templates/recipe.mdx +76 -0
- package/templates/reference.mdx +171 -0
- package/templates/troubleshooting.mdx +159 -0
- package/templates/tutorial.mdx +165 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { validLogReceipt } from './ask-log-kv.js';
|
|
3
|
+
// A `clientKey` that reads the caller's address from a header the host sets, such as `x-vercel-forwarded-for` on Vercel or
|
|
4
|
+
// `cf-connecting-ip` on Cloudflare. Use only a header your host sets itself. On a host that passes the header through, a caller can
|
|
5
|
+
// forge it and start a fresh personal cap, though the site-wide cap still holds. A missing header shares one key.
|
|
6
|
+
export const clientKeyFromHeader = (name) => (request) => request.headers.get(name)?.split(',')[0].trim() || 'unknown';
|
|
7
|
+
export const askLimits = { requestBytes: 16_384, question: 500, historyMessages: 10, historyMessage: 2000 };
|
|
8
|
+
class AnswerTimeout extends Error {
|
|
9
|
+
}
|
|
10
|
+
const json = (status, body, headers = {}) => new Response(JSON.stringify(body), { status, headers: { 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'no-store', ...headers } });
|
|
11
|
+
export function createAskHandler(options) {
|
|
12
|
+
const limit = options.maxRequestsPerMinute ?? 20;
|
|
13
|
+
const now = options.now ?? Date.now;
|
|
14
|
+
const seen = new Map();
|
|
15
|
+
return async (request) => {
|
|
16
|
+
if (request.method !== 'POST' && !(request.method === 'DELETE' && options.deleteRecord))
|
|
17
|
+
return json(405, { error: 'Use POST.' }, { Allow: options.deleteRecord ? 'POST, DELETE' : 'POST' });
|
|
18
|
+
const hosts = new Set(options.hosts.map(item => item.toLowerCase()));
|
|
19
|
+
const host = request.headers.get('host')?.toLowerCase();
|
|
20
|
+
const origin = request.headers.get('origin');
|
|
21
|
+
let originHost;
|
|
22
|
+
try {
|
|
23
|
+
originHost = origin ? new URL(origin).host.toLowerCase() : undefined;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return json(403, { error: 'This request is not allowed.' });
|
|
27
|
+
}
|
|
28
|
+
// A request from a browser always carries an Origin, and one from curl carries none. A cross-site page can send a text/plain
|
|
29
|
+
// POST without a preflight, so the JSON content type below is a second check, not the only one.
|
|
30
|
+
if (!host || !hosts.has(host) || (originHost !== undefined && !hosts.has(originHost)))
|
|
31
|
+
return json(403, { error: 'This request is not allowed.' });
|
|
32
|
+
if (!/^application\/json\b/i.test(request.headers.get('content-type') ?? ''))
|
|
33
|
+
return json(415, { error: 'Send application/json.' });
|
|
34
|
+
if (request.method === 'DELETE') {
|
|
35
|
+
const raw = await request.text();
|
|
36
|
+
if (Buffer.byteLength(raw) > 1024)
|
|
37
|
+
return json(413, { error: 'The request is too large.' });
|
|
38
|
+
let body;
|
|
39
|
+
try {
|
|
40
|
+
body = JSON.parse(raw);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return json(400, { error: 'The request body is not valid JSON.' });
|
|
44
|
+
}
|
|
45
|
+
if (!body || typeof body.receipt !== 'string' || !validLogReceipt(body.receipt))
|
|
46
|
+
return json(400, { error: 'A valid deletion receipt is required.' });
|
|
47
|
+
if (options.rateLimiter) {
|
|
48
|
+
const taken = await options.rateLimiter.take(options.clientKey?.(request) ?? 'shared');
|
|
49
|
+
if (!taken.allowed)
|
|
50
|
+
return json(429, { error: 'Too many requests. Wait a moment and try again.' }, { 'Retry-After': String(taken.retryAfterSeconds) });
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
return json(200, { deleted: await options.deleteRecord(body.receipt) });
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return json(503, { error: 'The question could not be deleted right now. Try again later.' });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (options.paused && await options.paused().catch(() => true))
|
|
60
|
+
return json(503, { error: 'The chat is paused right now. Please try again later.', paused: true }, { 'Retry-After': '300' });
|
|
61
|
+
const declared = Number(request.headers.get('content-length') ?? 0);
|
|
62
|
+
if (declared > askLimits.requestBytes)
|
|
63
|
+
return json(413, { error: 'The request is too large.' });
|
|
64
|
+
const raw = await request.text();
|
|
65
|
+
if (Buffer.byteLength(raw) > askLimits.requestBytes)
|
|
66
|
+
return json(413, { error: 'The request is too large.' });
|
|
67
|
+
let body;
|
|
68
|
+
try {
|
|
69
|
+
body = JSON.parse(raw);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return json(400, { error: 'The request body is not valid JSON.' });
|
|
73
|
+
}
|
|
74
|
+
if (!body || typeof body !== 'object' || Array.isArray(body))
|
|
75
|
+
return json(400, { error: 'The request body must be an object.' });
|
|
76
|
+
const question = typeof body.question === 'string' ? body.question.trim() : '';
|
|
77
|
+
if (!question)
|
|
78
|
+
return json(400, { error: 'Ask a question.' });
|
|
79
|
+
if (question.length > askLimits.question)
|
|
80
|
+
return json(400, { error: `Keep the question under ${askLimits.question} characters.` });
|
|
81
|
+
const history = [];
|
|
82
|
+
if (body.history !== undefined) {
|
|
83
|
+
if (!Array.isArray(body.history) || body.history.length > askLimits.historyMessages)
|
|
84
|
+
return json(400, { error: `History holds at most ${askLimits.historyMessages} messages.` });
|
|
85
|
+
for (const message of body.history) {
|
|
86
|
+
if (!message || (message.role !== 'user' && message.role !== 'assistant') || typeof message.content !== 'string')
|
|
87
|
+
return json(400, { error: 'Each history message needs a user or assistant role and text.' });
|
|
88
|
+
// An earlier answer can be long. Only its start is kept as context, so a follow-up is never refused for the length of what came before.
|
|
89
|
+
history.push({ role: message.role, content: message.content.slice(0, askLimits.historyMessage) });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const key = options.clientKey?.(request) ?? 'shared';
|
|
93
|
+
let passHeaders = {};
|
|
94
|
+
const held = Boolean(options.session?.valid(request.headers.get('cookie'), key));
|
|
95
|
+
if (options.challenge && !held && (!options.challengeNeeded || await options.challengeNeeded(key).catch(() => true))) {
|
|
96
|
+
const passed = await options.challenge({ token: typeof body.turnstileToken === 'string' ? body.turnstileToken : undefined, ip: key, request }).catch(() => false);
|
|
97
|
+
if (passed && options.session)
|
|
98
|
+
passHeaders = { 'Set-Cookie': options.session.header(key, new URL(request.url).protocol === 'https:') };
|
|
99
|
+
if (!passed)
|
|
100
|
+
return json(403, { error: 'The check did not pass. Reload the page and try again.', challenge: true });
|
|
101
|
+
}
|
|
102
|
+
// From here the visitor has passed, so every reply carries their pass when they were just given one.
|
|
103
|
+
const reply = (status, body, headers = {}) => json(status, body, { ...passHeaders, ...headers });
|
|
104
|
+
const current = now();
|
|
105
|
+
if (options.rateLimiter) {
|
|
106
|
+
const taken = await options.rateLimiter.take(key);
|
|
107
|
+
if (!taken.allowed)
|
|
108
|
+
return reply(429, { error: 'Too many questions. Wait a moment and try again.' }, { 'Retry-After': String(taken.retryAfterSeconds) });
|
|
109
|
+
}
|
|
110
|
+
const recent = options.rateLimiter ? [] : (seen.get(key) ?? []).filter(time => current - time < 60_000);
|
|
111
|
+
if (!options.rateLimiter && recent.length >= limit) {
|
|
112
|
+
seen.set(key, recent);
|
|
113
|
+
return reply(429, { error: 'Too many questions. Wait a moment and try again.' }, { 'Retry-After': String(Math.max(1, Math.ceil((60_000 - (current - recent[0])) / 1000))) });
|
|
114
|
+
}
|
|
115
|
+
if (!options.rateLimiter) {
|
|
116
|
+
seen.set(key, [...recent, current]);
|
|
117
|
+
// Callers who stopped asking would otherwise stay in the map for the life of the process.
|
|
118
|
+
if (seen.size > 10_000)
|
|
119
|
+
for (const [caller, times] of seen)
|
|
120
|
+
if (!times.some(time => current - time < 60_000))
|
|
121
|
+
seen.delete(caller);
|
|
122
|
+
}
|
|
123
|
+
let timer;
|
|
124
|
+
const controller = new AbortController();
|
|
125
|
+
try {
|
|
126
|
+
// A slot is taken before the question is answered, and given back if no model call was needed. If answering fails, the slot stays
|
|
127
|
+
// taken, because the model may already have been paid.
|
|
128
|
+
const reservation = options.budget ? await options.budget.reserveWithReceipt(key) : undefined;
|
|
129
|
+
const answering = options.answer(question, history, { modelAllowed: !options.budget || Boolean(reservation), signal: controller.signal });
|
|
130
|
+
let result;
|
|
131
|
+
if (options.answerTimeoutMs) {
|
|
132
|
+
answering.catch(() => { });
|
|
133
|
+
result = await Promise.race([answering, new Promise((_, reject) => { timer = setTimeout(() => { controller.abort(new AnswerTimeout()); reject(new AnswerTimeout()); }, options.answerTimeoutMs); })]);
|
|
134
|
+
}
|
|
135
|
+
else
|
|
136
|
+
result = await answering;
|
|
137
|
+
if (options.budget && reservation && result.usage.chatCalls === 0)
|
|
138
|
+
await options.budget.releaseReservation(reservation);
|
|
139
|
+
const recordedAt = new Date(now());
|
|
140
|
+
const receipt = options.record && options.response === 'public' ? `${recordedAt.toISOString().slice(0, 10)}.${randomBytes(16).toString('hex')}` : undefined;
|
|
141
|
+
if (options.record)
|
|
142
|
+
await Promise.resolve().then(() => options.record({ id: receipt, question, history, result, elapsedMs: now() - current, now: () => recordedAt })).catch(() => { });
|
|
143
|
+
if (options.response === 'public')
|
|
144
|
+
return reply(200, { answer: result.answer, decision: result.decision, sources: result.sources, uncited: result.uncited, unsupportedCode: result.unsupportedCode, unsupportedClaims: result.unsupportedClaims.map(claim => ({ text: claim.text })), ...(receipt ? { deletionReceipt: receipt } : {}) });
|
|
145
|
+
return reply(200, { answer: result.answer, decision: result.decision, mode: result.mode, sources: result.sources, notes: result.notes, jevBest: result.jevBest, standalone: result.standalone, uncited: result.uncited, unsupportedCode: result.unsupportedCode, verified: result.verified, unsupportedClaims: result.unsupportedClaims, routing: result.routing, cached: result.cached, usage: result.usage, timings: result.timings });
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
if (error instanceof AnswerTimeout)
|
|
149
|
+
return reply(504, { error: 'The answer took too long. Try again in a moment.' });
|
|
150
|
+
return reply(502, { error: options.exposeErrors ? error.message : 'The assistant is unavailable right now. Try again shortly.' });
|
|
151
|
+
}
|
|
152
|
+
finally {
|
|
153
|
+
if (timer)
|
|
154
|
+
clearTimeout(timer);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type AskEvent, type LogRecord } from './ask-log.js';
|
|
2
|
+
import type { RestRedis } from './budget-store.js';
|
|
3
|
+
export type KvLogOptions = {
|
|
4
|
+
retentionDays: number;
|
|
5
|
+
maxPerDay: number;
|
|
6
|
+
answers?: boolean;
|
|
7
|
+
now?: () => Date;
|
|
8
|
+
onError?: (error: Error) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare const logKey: (day: string) => string;
|
|
11
|
+
export declare function validLogReceipt(receipt: string): boolean;
|
|
12
|
+
export declare function deleteKvLogRecord(redis: Pick<RestRedis, 'command'>, receipt: string): Promise<boolean>;
|
|
13
|
+
export declare function kvLogSink(redis: Pick<RestRedis, 'pipeline'>, options: KvLogOptions): (event: AskEvent) => Promise<void>;
|
|
14
|
+
export declare function readKvLog(redis: Pick<RestRedis, 'pipeline'>, days: number, now?: () => Date): Promise<LogRecord[]>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { toRecord } from './ask-log.js';
|
|
2
|
+
export const logKey = (day) => `asklog:${day}`;
|
|
3
|
+
const dayOf = (date) => date.toISOString().slice(0, 10);
|
|
4
|
+
const receiptPattern = /^([0-9]{4}-[0-9]{2}-[0-9]{2})\.([a-f0-9]{32})$/;
|
|
5
|
+
// A receipt is a bearer capability. It names one daily list and one random record, without retaining an address or identity.
|
|
6
|
+
export function validLogReceipt(receipt) {
|
|
7
|
+
const match = receiptPattern.exec(receipt);
|
|
8
|
+
return Boolean(match && !Number.isNaN(Date.parse(`${match[1]}T00:00:00Z`)));
|
|
9
|
+
}
|
|
10
|
+
export async function deleteKvLogRecord(redis, receipt) {
|
|
11
|
+
if (!validLogReceipt(receipt))
|
|
12
|
+
throw new Error('Invalid question deletion receipt');
|
|
13
|
+
const day = receipt.slice(0, 10);
|
|
14
|
+
const lines = await redis.command(['LRANGE', logKey(day), '0', '-1']);
|
|
15
|
+
if (!Array.isArray(lines))
|
|
16
|
+
throw new Error('The question log could not be read');
|
|
17
|
+
const line = lines.find(raw => {
|
|
18
|
+
try {
|
|
19
|
+
return JSON.parse(String(raw)).id === receipt;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
if (line === undefined)
|
|
26
|
+
return false;
|
|
27
|
+
return Number(await redis.command(['LREM', logKey(day), '1', String(line)])) === 1;
|
|
28
|
+
}
|
|
29
|
+
export function kvLogSink(redis, options) {
|
|
30
|
+
if (!Number.isSafeInteger(options.retentionDays) || options.retentionDays < 1)
|
|
31
|
+
throw new Error('retentionDays must be a whole number of 1 or more');
|
|
32
|
+
if (!Number.isSafeInteger(options.maxPerDay) || options.maxPerDay < 1)
|
|
33
|
+
throw new Error('maxPerDay must be a whole number of 1 or more');
|
|
34
|
+
const now = options.now ?? (() => new Date());
|
|
35
|
+
return async (event) => {
|
|
36
|
+
try {
|
|
37
|
+
const at = event.now?.() ?? now();
|
|
38
|
+
const record = toRecord({ ...event, now: () => at }, { answers: options.answers });
|
|
39
|
+
const key = logKey(dayOf(at));
|
|
40
|
+
// Newest first, trimmed to the cap, with the list's lifetime set to the retention period from this write.
|
|
41
|
+
await redis.pipeline([['LPUSH', key, JSON.stringify(record)], ['LTRIM', key, '0', String(options.maxPerDay - 1)], ['EXPIRE', key, String(options.retentionDays * 86_400)]]);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
options.onError?.(error);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
// The records for the last `days` days, oldest first. A line that cannot be read is skipped.
|
|
49
|
+
export async function readKvLog(redis, days, now = () => new Date()) {
|
|
50
|
+
if (!Number.isSafeInteger(days) || days < 1 || days > 366)
|
|
51
|
+
throw new Error('days must be a whole number from 1 to 366');
|
|
52
|
+
const today = now();
|
|
53
|
+
const keys = Array.from({ length: days }, (_, back) => logKey(dayOf(new Date(today.getTime() - back * 86_400_000)))).reverse();
|
|
54
|
+
const lists = await redis.pipeline(keys.map(key => ['LRANGE', key, '0', '-1']));
|
|
55
|
+
const records = [];
|
|
56
|
+
for (const list of lists) {
|
|
57
|
+
if (!Array.isArray(list))
|
|
58
|
+
continue;
|
|
59
|
+
for (const line of [...list].reverse()) {
|
|
60
|
+
try {
|
|
61
|
+
const record = JSON.parse(String(line));
|
|
62
|
+
if (record?.v === 1 && typeof record.question === 'string')
|
|
63
|
+
records.push(record);
|
|
64
|
+
}
|
|
65
|
+
catch { /* skip */ }
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return records;
|
|
69
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { type AskResult, type Decision } from './ask.js';
|
|
2
|
+
export type LogRecord = {
|
|
3
|
+
v: 1;
|
|
4
|
+
id?: string;
|
|
5
|
+
at: string;
|
|
6
|
+
question: string;
|
|
7
|
+
followUp?: boolean;
|
|
8
|
+
standalone?: string;
|
|
9
|
+
decision: Decision;
|
|
10
|
+
mode: string;
|
|
11
|
+
cached?: boolean;
|
|
12
|
+
card?: string;
|
|
13
|
+
jevBest?: number;
|
|
14
|
+
model?: string;
|
|
15
|
+
chatCalls: number;
|
|
16
|
+
tokens: {
|
|
17
|
+
in: number;
|
|
18
|
+
out: number;
|
|
19
|
+
};
|
|
20
|
+
sources: Array<{
|
|
21
|
+
id: string;
|
|
22
|
+
title: string;
|
|
23
|
+
url: string;
|
|
24
|
+
}>;
|
|
25
|
+
closest?: Array<{
|
|
26
|
+
title: string;
|
|
27
|
+
url: string;
|
|
28
|
+
}>;
|
|
29
|
+
flags: {
|
|
30
|
+
uncited?: boolean;
|
|
31
|
+
invalidCitations?: number;
|
|
32
|
+
unsupportedCode?: number;
|
|
33
|
+
unsupportedClaims?: number;
|
|
34
|
+
};
|
|
35
|
+
verified: boolean;
|
|
36
|
+
notes: string[];
|
|
37
|
+
answer: string;
|
|
38
|
+
ms: number;
|
|
39
|
+
};
|
|
40
|
+
export type AskEvent = {
|
|
41
|
+
id?: string;
|
|
42
|
+
question: string;
|
|
43
|
+
history: unknown[];
|
|
44
|
+
result: AskResult;
|
|
45
|
+
elapsedMs: number;
|
|
46
|
+
now?: () => Date;
|
|
47
|
+
};
|
|
48
|
+
export declare function redact(text: string): string;
|
|
49
|
+
export declare function toRecord(event: AskEvent, options?: {
|
|
50
|
+
answers?: boolean;
|
|
51
|
+
}): LogRecord;
|
|
52
|
+
export declare function checkLogPath(file: string, siteDirectory: string): Promise<string>;
|
|
53
|
+
export declare class AskLog {
|
|
54
|
+
readonly file: string;
|
|
55
|
+
private readonly options;
|
|
56
|
+
private queue;
|
|
57
|
+
constructor(file: string, options?: {
|
|
58
|
+
maxBytes?: number;
|
|
59
|
+
answers?: boolean;
|
|
60
|
+
});
|
|
61
|
+
write(event: AskEvent): Promise<void>;
|
|
62
|
+
}
|
|
63
|
+
export declare function readLog(file: string): Promise<LogRecord[]>;
|
|
64
|
+
export type Gap = {
|
|
65
|
+
question: string;
|
|
66
|
+
count: number;
|
|
67
|
+
decisions: string[];
|
|
68
|
+
bestScore?: number;
|
|
69
|
+
offTopic: boolean;
|
|
70
|
+
closest: Array<{
|
|
71
|
+
title: string;
|
|
72
|
+
url: string;
|
|
73
|
+
}>;
|
|
74
|
+
};
|
|
75
|
+
export type CardCandidate = {
|
|
76
|
+
question: string;
|
|
77
|
+
count: number;
|
|
78
|
+
pages: string[];
|
|
79
|
+
};
|
|
80
|
+
export type Flagged = {
|
|
81
|
+
question: string;
|
|
82
|
+
count: number;
|
|
83
|
+
flags: string[];
|
|
84
|
+
model?: string;
|
|
85
|
+
};
|
|
86
|
+
export type LogReport = {
|
|
87
|
+
total: number;
|
|
88
|
+
from?: string;
|
|
89
|
+
to?: string;
|
|
90
|
+
byDecision: Record<string, number>;
|
|
91
|
+
modelCalls: number;
|
|
92
|
+
modelShare: number;
|
|
93
|
+
tokens: {
|
|
94
|
+
in: number;
|
|
95
|
+
out: number;
|
|
96
|
+
};
|
|
97
|
+
medianMs: number;
|
|
98
|
+
gaps: Gap[];
|
|
99
|
+
cards: CardCandidate[];
|
|
100
|
+
flagged: Flagged[];
|
|
101
|
+
paused: number;
|
|
102
|
+
};
|
|
103
|
+
export declare function analyzeLog(records: LogRecord[], options?: {
|
|
104
|
+
minRepeats?: number;
|
|
105
|
+
}): LogReport;
|
|
106
|
+
export declare function formatReport(report: LogReport, limit?: number): string;
|
package/dist/ask-log.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { appendFile, mkdir, readFile, realpath, rename, stat } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { normalizeQuestion } from './answer-cache.js';
|
|
4
|
+
import { closestFloor } from './ask.js';
|
|
5
|
+
// Best effort, not a guarantee: it removes the common ways a question carries a person's details or a credential. It leaves ordinary words alone.
|
|
6
|
+
export function redact(text) {
|
|
7
|
+
return text
|
|
8
|
+
.replace(/https?:\/\/[^\s)>\]]+/gi, url => url.replace(/[?#].*$/, ''))
|
|
9
|
+
.replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi, '[email]')
|
|
10
|
+
.replace(/\b(?:sk|pk|rk|pa|lsk|ghp|gho|xox[bpas])[-_][A-Za-z0-9_-]{12,}/g, '[secret]')
|
|
11
|
+
.replace(/\b[A-Za-z0-9_-]{32,}\b/g, '[secret]')
|
|
12
|
+
.replace(/\+?\d[\d\s().-]{7,}\d/g, match => match.replace(/\D/g, '').length >= 9 ? '[number]' : match);
|
|
13
|
+
}
|
|
14
|
+
const trim = (text, limit) => text.length > limit ? `${text.slice(0, limit)}…` : text;
|
|
15
|
+
export function toRecord(event, options = {}) {
|
|
16
|
+
const { result } = event;
|
|
17
|
+
const closest = result.decision === 'declined' ? [...result.answer.matchAll(/^- (.+?): (\/\S*)$/gm)].map(match => ({ title: redact(match[1]), url: match[2] })) : undefined;
|
|
18
|
+
return {
|
|
19
|
+
v: 1, ...(event.id ? { id: event.id } : {}), at: (event.now ?? (() => new Date()))().toISOString(), question: redact(event.question),
|
|
20
|
+
...(event.history.length ? { followUp: true } : {}), ...(result.standalone ? { standalone: redact(result.standalone) } : {}),
|
|
21
|
+
decision: result.decision, mode: result.mode, ...(result.cached ? { cached: true } : {}), ...(result.card ? { card: result.card.id } : {}),
|
|
22
|
+
...(result.jevBest !== undefined ? { jevBest: Number(result.jevBest.toFixed(3)) } : {}),
|
|
23
|
+
...(result.routing?.answeredBy ? { model: result.routing.answeredBy } : {}),
|
|
24
|
+
chatCalls: result.usage.chatCalls, tokens: { in: result.usage.promptTokens, out: result.usage.completionTokens },
|
|
25
|
+
sources: result.sources.map(source => ({ id: source.id, title: source.title, url: source.url })),
|
|
26
|
+
...(closest?.length ? { closest } : {}),
|
|
27
|
+
flags: { ...(result.uncited ? { uncited: true } : {}), ...(result.invalidCitations.length ? { invalidCitations: result.invalidCitations.length } : {}), ...(result.unsupportedCode.length ? { unsupportedCode: result.unsupportedCode.length } : {}), ...(result.unsupportedClaims.length ? { unsupportedClaims: result.unsupportedClaims.length } : {}) },
|
|
28
|
+
verified: result.verified, notes: result.notes.map(note => trim(redact(note), 300)),
|
|
29
|
+
answer: options.answers === false ? '' : trim(redact(result.answer), 4000), ms: Math.round(event.elapsedMs)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
// The log must not sit where a deploy could publish it. This resolves symlinks in the part of the path that exists.
|
|
33
|
+
export async function checkLogPath(file, siteDirectory) {
|
|
34
|
+
const target = path.resolve(file);
|
|
35
|
+
let existing = path.dirname(target);
|
|
36
|
+
const rest = [path.basename(target)];
|
|
37
|
+
for (;;) {
|
|
38
|
+
try {
|
|
39
|
+
existing = await realpath(existing);
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (error.code !== 'ENOENT')
|
|
44
|
+
throw error;
|
|
45
|
+
rest.unshift(path.basename(existing));
|
|
46
|
+
const parent = path.dirname(existing);
|
|
47
|
+
if (parent === existing)
|
|
48
|
+
break;
|
|
49
|
+
existing = parent;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const real = path.join(existing, ...rest);
|
|
53
|
+
const site = await realpath(path.resolve(siteDirectory));
|
|
54
|
+
if (real === site || real.startsWith(site + path.sep))
|
|
55
|
+
throw new Error('The log file must be outside the site directory, because a deploy could publish it');
|
|
56
|
+
return target;
|
|
57
|
+
}
|
|
58
|
+
export class AskLog {
|
|
59
|
+
file;
|
|
60
|
+
options;
|
|
61
|
+
queue = Promise.resolve();
|
|
62
|
+
constructor(file, options = {}) {
|
|
63
|
+
this.file = file;
|
|
64
|
+
this.options = options;
|
|
65
|
+
}
|
|
66
|
+
// Writes are queued so lines never interleave. A failure never reaches the reader who asked.
|
|
67
|
+
write(event) {
|
|
68
|
+
const line = `${JSON.stringify(toRecord(event, this.options))}\n`;
|
|
69
|
+
const next = this.queue.then(async () => {
|
|
70
|
+
await mkdir(path.dirname(this.file), { recursive: true, mode: 0o700 });
|
|
71
|
+
const size = await stat(this.file).then(info => info.size, () => 0);
|
|
72
|
+
if (size + line.length > (this.options.maxBytes ?? 5_000_000))
|
|
73
|
+
await rename(this.file, `${this.file}.1`);
|
|
74
|
+
await appendFile(this.file, line, { mode: 0o600 });
|
|
75
|
+
});
|
|
76
|
+
this.queue = next.catch(() => { });
|
|
77
|
+
return next.catch(() => { });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export async function readLog(file) {
|
|
81
|
+
const records = [];
|
|
82
|
+
for (const line of (await readFile(file, 'utf8')).split('\n')) {
|
|
83
|
+
if (!line.trim())
|
|
84
|
+
continue;
|
|
85
|
+
try {
|
|
86
|
+
const record = JSON.parse(line);
|
|
87
|
+
if (record?.v === 1 && typeof record.question === 'string')
|
|
88
|
+
records.push(record);
|
|
89
|
+
}
|
|
90
|
+
catch { /* a line cut off by a crash */ }
|
|
91
|
+
}
|
|
92
|
+
return records;
|
|
93
|
+
}
|
|
94
|
+
const median = (values) => { const sorted = [...values].sort((a, b) => a - b); return sorted.length ? sorted[Math.floor(sorted.length / 2)] : 0; };
|
|
95
|
+
const operational = (record) => record.decision === 'search' && record.notes.some(note => /daily budget|scorer that checks/.test(note));
|
|
96
|
+
// Turns the log into three lists. Gaps are questions the docs did not answer, most asked first. Card candidates are questions asked more than once
|
|
97
|
+
// that the model answered cleanly and no card covers, which would be free to serve from a card. Flagged answers are worth reading for the eval set.
|
|
98
|
+
// Questions are grouped by their normalized text, so a paraphrase counts as a separate question.
|
|
99
|
+
export function analyzeLog(records, options = {}) {
|
|
100
|
+
const minRepeats = options.minRepeats ?? 2;
|
|
101
|
+
const groups = new Map();
|
|
102
|
+
for (const record of records) {
|
|
103
|
+
const key = normalizeQuestion(record.standalone ?? record.question);
|
|
104
|
+
groups.set(key, [...(groups.get(key) ?? []), record]);
|
|
105
|
+
}
|
|
106
|
+
const byDecision = {};
|
|
107
|
+
for (const record of records)
|
|
108
|
+
byDecision[record.decision] = (byDecision[record.decision] ?? 0) + 1;
|
|
109
|
+
const modelCalls = records.reduce((total, record) => total + record.chatCalls, 0);
|
|
110
|
+
const gaps = [];
|
|
111
|
+
const cards = [];
|
|
112
|
+
const flagged = [];
|
|
113
|
+
for (const [question, group] of groups) {
|
|
114
|
+
const missed = group.filter(record => (record.decision === 'declined' || record.decision === 'hedged'));
|
|
115
|
+
if (missed.length) {
|
|
116
|
+
const scores = missed.map(record => record.jevBest).filter((score) => score !== undefined);
|
|
117
|
+
const closest = new Map();
|
|
118
|
+
for (const record of missed)
|
|
119
|
+
for (const page of record.closest ?? record.sources)
|
|
120
|
+
closest.set(page.url, { title: page.title, url: page.url });
|
|
121
|
+
gaps.push({ question, count: missed.length, decisions: [...new Set(missed.map(record => record.decision))], ...(scores.length ? { bestScore: Math.max(...scores) } : {}), offTopic: scores.length > 0 && Math.max(...scores) < closestFloor && missed.every(record => record.decision === 'declined'), closest: [...closest.values()].slice(0, 3) });
|
|
122
|
+
}
|
|
123
|
+
const covered = group.some(record => record.decision === 'card');
|
|
124
|
+
const clean = group.filter(record => record.decision === 'answered' && record.chatCalls > 0 && !Object.keys(record.flags).length && !record.followUp);
|
|
125
|
+
const demand = group.filter(record => !record.followUp && ['answered', 'excerpt', 'card'].includes(record.decision)).length;
|
|
126
|
+
if (!covered && clean.length && demand >= minRepeats)
|
|
127
|
+
cards.push({ question, count: demand, pages: [...new Set(clean.flatMap(record => record.sources.map(source => source.url.split('#')[0])))] });
|
|
128
|
+
const bad = group.filter(record => Object.keys(record.flags).length);
|
|
129
|
+
if (bad.length)
|
|
130
|
+
flagged.push({ question, count: bad.length, flags: [...new Set(bad.flatMap(record => Object.keys(record.flags)))], ...(bad[0].model ? { model: bad[0].model } : {}) });
|
|
131
|
+
}
|
|
132
|
+
const byCount = (items) => items.sort((a, b) => b.count - a.count);
|
|
133
|
+
return {
|
|
134
|
+
total: records.length, ...(records.length ? { from: records[0].at, to: records[records.length - 1].at } : {}), byDecision, modelCalls,
|
|
135
|
+
modelShare: records.length ? records.filter(record => record.chatCalls > 0).length / records.length : 0,
|
|
136
|
+
tokens: { in: records.reduce((total, record) => total + record.tokens.in, 0), out: records.reduce((total, record) => total + record.tokens.out, 0) },
|
|
137
|
+
medianMs: median(records.map(record => record.ms)), gaps: byCount(gaps), cards: byCount(cards), flagged: byCount(flagged), paused: records.filter(operational).length
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
export function formatReport(report, limit = 15) {
|
|
141
|
+
const lines = [];
|
|
142
|
+
const pct = (value) => `${Math.round(value * 100)}%`;
|
|
143
|
+
lines.push(`# Ask log: ${report.total} question${report.total === 1 ? '' : 's'}${report.from ? `, ${report.from.slice(0, 10)} to ${report.to?.slice(0, 10)}` : ''}`, '');
|
|
144
|
+
if (!report.total)
|
|
145
|
+
return `${lines.join('\n')}\nThe log is empty.\n`;
|
|
146
|
+
lines.push(`- How they were answered: ${Object.entries(report.byDecision).sort(([, a], [, b]) => b - a).map(([name, count]) => `${count} ${name}`).join(', ')}`);
|
|
147
|
+
lines.push(`- ${pct(report.modelShare)} of questions called the model (${report.modelCalls} calls, ${report.tokens.in} in and ${report.tokens.out} out tokens). Median time ${(report.medianMs / 1000).toFixed(1)}s.`);
|
|
148
|
+
if (report.paused)
|
|
149
|
+
lines.push(`- ${report.paused} question${report.paused === 1 ? '' : 's'} got only a list of pages, because the scorer was down or the daily budget was spent.`);
|
|
150
|
+
const section = (title, note, rows) => { lines.push('', `## ${title}`, note, ''); lines.push(...(rows.length ? rows : ['None.'])); };
|
|
151
|
+
const near = report.gaps.filter(gap => !gap.offTopic);
|
|
152
|
+
const off = report.gaps.filter(gap => gap.offTopic);
|
|
153
|
+
section('Gaps in the docs', 'Questions the docs came close to answering but did not, most asked first. Each is a page or a paragraph to write, or a question the docs should say they do not cover.', near.slice(0, limit).map(gap => `- ${gap.count}× "${gap.question}" (${gap.decisions.join(', ')}${gap.bestScore !== undefined ? `, best score ${gap.bestScore}` : ''})${gap.closest.length ? `. Closest: ${gap.closest.map(page => `${page.title} ${page.url}`).join('; ')}` : ''}`));
|
|
154
|
+
if (off.length)
|
|
155
|
+
lines.push('', `Off topic: ${off.reduce((total, gap) => total + gap.count, 0)} question${off.reduce((total, gap) => total + gap.count, 0) === 1 ? '' : 's'} that no page came close to answering, such as ${off.slice(0, 3).map(gap => `"${gap.question}"`).join(', ')}. They are probably not gaps.`);
|
|
156
|
+
section('Questions worth answering ahead of time', 'Asked more than once, answered cleanly by the model, and not served by a card. `--cards-out FILE` writes them in the format `shoalrun answers` reads.', report.cards.slice(0, limit).map(card => `- ${card.count}× "${card.question}"${card.pages.length ? ` (${card.pages.join(', ')})` : ''}`));
|
|
157
|
+
section('Flagged answers', 'Answers a check flagged. Read them, and add the good ones to the eval set.', report.flagged.slice(0, limit).map(item => `- ${item.count}× "${item.question}" (${item.flags.join(', ')}${item.model ? `, ${item.model}` : ''})`));
|
|
158
|
+
return `${lines.join('\n')}\n`;
|
|
159
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { AskOptions } from './ask.js';
|
|
2
|
+
import { type ChatProvider } from './chat.js';
|
|
3
|
+
import { type ReaderSelection } from './reader-filters.js';
|
|
4
|
+
import { DailyBudget, type BudgetStore } from './budget.js';
|
|
5
|
+
export declare function parseReaderView(specs: string[]): ReaderSelection | undefined;
|
|
6
|
+
export type AskSetupInput = {
|
|
7
|
+
sharedStore?: boolean;
|
|
8
|
+
siteDirectory: string;
|
|
9
|
+
configFile?: string;
|
|
10
|
+
settings?: Record<string, unknown>;
|
|
11
|
+
model?: string;
|
|
12
|
+
passages?: number;
|
|
13
|
+
channel?: string;
|
|
14
|
+
version?: string;
|
|
15
|
+
language?: string;
|
|
16
|
+
noRerank?: boolean;
|
|
17
|
+
noDirect?: boolean;
|
|
18
|
+
noEscalate?: boolean;
|
|
19
|
+
noCards?: boolean;
|
|
20
|
+
cache?: boolean;
|
|
21
|
+
direct?: {
|
|
22
|
+
threshold: number;
|
|
23
|
+
maxChars?: number;
|
|
24
|
+
};
|
|
25
|
+
jevCacheDir?: string;
|
|
26
|
+
readerView?: ReaderSelection;
|
|
27
|
+
maxTokens?: number;
|
|
28
|
+
};
|
|
29
|
+
export type AskSetup = {
|
|
30
|
+
budget?: DailyBudget;
|
|
31
|
+
budgetStore?: BudgetStore;
|
|
32
|
+
chat: ChatProvider;
|
|
33
|
+
options: Omit<AskOptions, 'question'>;
|
|
34
|
+
notes: string[];
|
|
35
|
+
embedTexts?: (texts: string[]) => Promise<Float32Array[]>;
|
|
36
|
+
embedding?: {
|
|
37
|
+
provider: string;
|
|
38
|
+
model: string;
|
|
39
|
+
space: string;
|
|
40
|
+
dimension: number;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export declare function prepareAsk(input: AskSetupInput): Promise<AskSetup>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { AnswerCache } from './answer-cache.js';
|
|
4
|
+
import { CardIndex, readCards } from './answer-cards.js';
|
|
5
|
+
import { chatProviderConfig, chatRoutes, validateChat } from './chat-config.js';
|
|
6
|
+
import { createChatProvider, fallbackChat } from './chat.js';
|
|
7
|
+
import { loadConfig } from './config.js';
|
|
8
|
+
import { validateReaderFilters, validateReaderSelection } from './reader-filters.js';
|
|
9
|
+
import { createProvider, readEmbeddings } from './embeddings.js';
|
|
10
|
+
import { DailyBudget, memoryBudgetStore } from './budget.js';
|
|
11
|
+
import { envBudgetStore } from './budget-store.js';
|
|
12
|
+
import { jevAvailable, jevEndpoint } from './jev.js';
|
|
13
|
+
import { queryProviderConfig, validateRetrieval } from './retrieval-config.js';
|
|
14
|
+
import { Retriever } from './retrieval.js';
|
|
15
|
+
// `--reader-view audience=authors,maintainers`, repeatable for more than one filter.
|
|
16
|
+
export function parseReaderView(specs) {
|
|
17
|
+
if (!specs.length)
|
|
18
|
+
return undefined;
|
|
19
|
+
const selection = {};
|
|
20
|
+
for (const spec of specs) {
|
|
21
|
+
const match = /^([a-z][a-z0-9-]*)=(.+)$/.exec(spec);
|
|
22
|
+
if (!match)
|
|
23
|
+
throw new Error(`--reader-view needs facet=choice[,choice], such as audience=authors; got ${JSON.stringify(spec)}`);
|
|
24
|
+
if (selection[match[1]])
|
|
25
|
+
throw new Error(`--reader-view names ${match[1]} twice`);
|
|
26
|
+
selection[match[1]] = match[2].split(',').map(choice => choice.trim()).filter(Boolean);
|
|
27
|
+
}
|
|
28
|
+
return selection;
|
|
29
|
+
}
|
|
30
|
+
// Everything `shoalrun ask` and the answer eval share: read the project's chat and retrieval settings, load the passages and any
|
|
31
|
+
// vectors, and wire up the optional layers. A layer that isn't configured is left out, and one that is configured but can't run
|
|
32
|
+
// (Jev without a key) is left out with a note.
|
|
33
|
+
export async function prepareAsk(input) {
|
|
34
|
+
if (!input.settings && !input.configFile)
|
|
35
|
+
throw new Error('prepareAsk needs a config file or settings');
|
|
36
|
+
const settings = input.settings ?? (await loadConfig(input.configFile)).value;
|
|
37
|
+
const readerFilters = validateReaderFilters(settings.readerFilters);
|
|
38
|
+
const chatConfig = validateChat(settings.chat, readerFilters);
|
|
39
|
+
const retrieval = validateRetrieval(settings.retrieval);
|
|
40
|
+
// --model replaces the main model only. Fallback and escalation models still inherit the config's settings.
|
|
41
|
+
const mainConfig = chatProviderConfig(chatConfig, { model: input.model });
|
|
42
|
+
const routes = chatRoutes(chatConfig, chatProviderConfig(chatConfig));
|
|
43
|
+
const chat = fallbackChat([createChatProvider(mainConfig), ...routes.fallbacks.map(createChatProvider)]);
|
|
44
|
+
let chunks;
|
|
45
|
+
try {
|
|
46
|
+
chunks = JSON.parse(await readFile(path.join(input.siteDirectory, 'ai', 'chunks.json'), 'utf8'));
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
throw error.code === 'ENOENT' ? new Error(`No ai/chunks.json in ${input.siteDirectory}; run shoalrun index first`) : error;
|
|
50
|
+
}
|
|
51
|
+
const embeddings = await readEmbeddings(input.siteDirectory);
|
|
52
|
+
const retriever = new Retriever(chunks, embeddings);
|
|
53
|
+
const variants = retriever.variants();
|
|
54
|
+
const variant = input.channel && input.version && input.language ? `${input.channel}|${input.version}|${input.language}` : variants.length === 1 ? variants[0] : undefined;
|
|
55
|
+
if (!variant)
|
|
56
|
+
throw new Error(`The site has several publications (${variants.join(', ')}); pass --channel, --version, and --language`);
|
|
57
|
+
let embedQuery;
|
|
58
|
+
let embedTexts;
|
|
59
|
+
let embedding;
|
|
60
|
+
if (embeddings) {
|
|
61
|
+
const queryProvider = createProvider(queryProviderConfig(retrieval, embeddings.meta));
|
|
62
|
+
if (queryProvider.space !== embeddings.meta.space || (embeddings.meta.backend && queryProvider.backend !== embeddings.meta.backend))
|
|
63
|
+
throw new Error(`${queryProvider.model} is not in the embedding space or backend of ${embeddings.meta.model}; set retrieval.embeddings.queryModel and baseUrl to compatible values`);
|
|
64
|
+
embedQuery = async (text, signal) => (await queryProvider.embed([text], 'query', signal))[0];
|
|
65
|
+
embedTexts = texts => queryProvider.embed(texts, 'query');
|
|
66
|
+
embedding = { provider: queryProvider.name, model: queryProvider.model, space: queryProvider.space, dimension: queryProvider.dimension };
|
|
67
|
+
}
|
|
68
|
+
// A reader view on the command line replaces the config's, so one run can answer for a different audience.
|
|
69
|
+
if (input.readerView && !readerFilters)
|
|
70
|
+
throw new Error('--reader-view needs readerFilters.facets in the site config');
|
|
71
|
+
const readerSelection = input.readerView ? validateReaderSelection(input.readerView, readerFilters, '--reader-view') : chatConfig?.readerView;
|
|
72
|
+
const notes = [];
|
|
73
|
+
const rerank = Boolean(chatConfig?.rerank) && !input.noRerank;
|
|
74
|
+
const scoring = chatConfig?.rerank;
|
|
75
|
+
const scorer = { ...(scoring?.endpoint ? { endpoint: jevEndpoint(scoring.endpoint) } : {}), ...(scoring?.model ? { model: scoring.model } : {}), ...(scoring?.keyEnv ? { keyEnv: scoring.keyEnv } : {}), ...(scoring?.stateFormat ? { stateFormat: scoring.stateFormat } : {}), ...(input.jevCacheDir ? { cacheDir: input.jevCacheDir } : {}) };
|
|
76
|
+
const scoringReady = jevAvailable(scoring?.keyEnv);
|
|
77
|
+
// A scorer that is configured but has no key counts as down, not as absent: it is what keeps off-topic questions from the model.
|
|
78
|
+
if (rerank && !scoringReady)
|
|
79
|
+
notes.push(`The relevance scorer has no key: set ${scoring?.keyEnv ?? 'JEV_API_KEY'}. Until then it counts as down, so ${scoring?.onError === 'answer' ? 'the model answers without the gate and the claim check' : 'questions get the closest pages and no model call'}`);
|
|
80
|
+
// Answer cards need semantic search and Jev. A configured but missing card file is a note, not an error, so the chat still answers.
|
|
81
|
+
let cards;
|
|
82
|
+
if (chatConfig?.cards && !input.noCards && rerank && scoringReady) {
|
|
83
|
+
const file = await readCards(input.siteDirectory);
|
|
84
|
+
if (!file)
|
|
85
|
+
notes.push('chat.cards is set but there is no ai/answers.json; run shoalrun answers to make it');
|
|
86
|
+
else if (!embedding || file.embedding.space !== embedding.space || file.embedding.dimension !== embedding.dimension)
|
|
87
|
+
notes.push('The answer cards were made with a different embedding model, so they are not used; run shoalrun answers again');
|
|
88
|
+
else
|
|
89
|
+
cards = { index: new CardIndex(file), threshold: chatConfig.cards.threshold, confirm: chatConfig.cards.confirm, jev: { ...scorer, maxCalls: 1 } };
|
|
90
|
+
}
|
|
91
|
+
// The shared store is for a hosted function. A local run keeps its counters in memory, so it never needs the store's keys.
|
|
92
|
+
const store = input.sharedStore && chatConfig?.budget?.store ? envBudgetStore(chatConfig.budget.store) : memoryBudgetStore();
|
|
93
|
+
const reported = new Set();
|
|
94
|
+
const onBudgetError = (error) => { if (!reported.has(error.message)) {
|
|
95
|
+
reported.add(error.message);
|
|
96
|
+
process.stderr.write(`Budget: ${error.message}. Questions get the closest pages, with no model call, until it works.\n`);
|
|
97
|
+
} };
|
|
98
|
+
return { ...(chatConfig?.budget ? { budget: new DailyBudget(store, chatConfig.budget, Date.now, onBudgetError), budgetStore: store } : {}), chat, notes, embedTexts, embedding, options: { ...(scoring?.onError ? { onScorerError: scoring.onError } : {}), retriever, chat, variant, readerSelection, embedQuery, passages: input.passages ?? chatConfig?.passages, gate: chatConfig?.gate, ...(input.maxTokens ? { maxTokens: input.maxTokens } : {}), ...(rerank ? { jev: { ...scorer, top: 24, maxCalls: 2 } } : {}), ...(cards ? { cards } : {}), ...(input.cache && chatConfig?.cache ? { cache: new AnswerCache({ maxEntries: chatConfig.cache.maxEntries, ttlMs: chatConfig.cache.ttlMinutes * 60_000 }) } : {}), ...(routes.escalate && !input.noEscalate ? { escalate: { chat: createChatProvider(routes.escalate.config), when: routes.escalate.when } } : {}), ...(rerank && scoringReady && !input.noDirect && (input.direct || chatConfig?.direct) ? { direct: { threshold: input.direct?.threshold ?? chatConfig.direct.threshold, maxChars: input.direct?.maxChars ?? chatConfig?.direct?.maxChars ?? 1200, margin: chatConfig?.direct?.margin ?? 0.1, others: chatConfig?.direct?.others ?? 1, jev: { ...scorer, maxCalls: 2 } } } : {}), ...(rerank && scoringReady && chatConfig?.verify ? { verify: { ...chatConfig.verify, jev: { ...scorer, maxCalls: 3 } } } : {}) } };
|
|
99
|
+
}
|