@mapomodule/mcp 1.0.0-beta.2 → 1.0.0-experimental.1

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.
Files changed (50) hide show
  1. package/README.md +26 -24
  2. package/dist/build.mjs +66 -4
  3. package/dist/cli.mjs +8 -1
  4. package/dist/knowledge/api.json +1 -1
  5. package/dist/knowledge/docs.json +1 -1
  6. package/dist/module.json +1 -1
  7. package/dist/runtime/core/ai-setup/catalog.d.ts +0 -0
  8. package/dist/runtime/core/ai-setup/catalog.js +411 -0
  9. package/dist/runtime/core/ai-setup/index.d.ts +0 -0
  10. package/dist/runtime/core/ai-setup/index.js +20 -0
  11. package/dist/runtime/core/ai-setup/plan.d.ts +0 -0
  12. package/dist/runtime/core/ai-setup/plan.js +640 -0
  13. package/dist/runtime/core/ai-setup/questions.d.ts +0 -0
  14. package/dist/runtime/core/ai-setup/questions.js +237 -0
  15. package/dist/runtime/core/indexer.js +10 -3
  16. package/dist/runtime/core/instructions.js +3 -2
  17. package/dist/runtime/core/prompts.js +25 -1
  18. package/dist/runtime/core/recipes.js +408 -4
  19. package/dist/runtime/core/search.js +2 -1
  20. package/dist/runtime/core/tools/ai.d.ts +0 -0
  21. package/dist/runtime/core/tools/ai.js +125 -0
  22. package/dist/runtime/core/tools/api.js +7 -1
  23. package/dist/runtime/mcp/handlers/mapo/prompts/ai-setup.js +3 -0
  24. package/dist/runtime/mcp/handlers/mapo/tools/ai-setup.js +3 -0
  25. package/package.json +1 -1
  26. package/src/__tests__/aiSetup.test.ts +330 -0
  27. package/src/__tests__/cli.test.ts +1 -0
  28. package/src/__tests__/composables.test.ts +95 -0
  29. package/src/__tests__/indexer.test.ts +19 -0
  30. package/src/__tests__/knowledge.test.ts +48 -0
  31. package/src/__tests__/overview.test.ts +11 -0
  32. package/src/__tests__/recipes.test.ts +69 -0
  33. package/src/__tests__/search.test.ts +16 -0
  34. package/src/__tests__/tools.test.ts +27 -1
  35. package/src/build/extract-components.ts +33 -5
  36. package/src/build/extract-composables.ts +65 -2
  37. package/src/cli.ts +8 -1
  38. package/src/runtime/core/ai-setup/catalog.ts +475 -0
  39. package/src/runtime/core/ai-setup/index.ts +29 -0
  40. package/src/runtime/core/ai-setup/plan.ts +706 -0
  41. package/src/runtime/core/ai-setup/questions.ts +290 -0
  42. package/src/runtime/core/indexer.ts +16 -4
  43. package/src/runtime/core/instructions.ts +3 -2
  44. package/src/runtime/core/prompts.ts +28 -0
  45. package/src/runtime/core/recipes.ts +429 -4
  46. package/src/runtime/core/search.ts +4 -1
  47. package/src/runtime/core/tools/ai.ts +209 -0
  48. package/src/runtime/core/tools/api.ts +8 -0
  49. package/src/runtime/mcp/handlers/mapo/prompts/ai-setup.ts +4 -0
  50. package/src/runtime/mcp/handlers/mapo/tools/ai-setup.ts +4 -0
@@ -95,6 +95,42 @@ export const RECIPES: Recipe[] = [
95
95
  summary:
96
96
  "MapoDetail wired to useCrud, with body/sidebar field descriptors and save flow.",
97
97
  },
98
+ {
99
+ id: "detail-context",
100
+ task: "Use the record and state of a detail page from a component inside it",
101
+ keywords: [
102
+ "useMapoDetail",
103
+ "detail context",
104
+ "inside MapoDetail",
105
+ "current record",
106
+ "record being edited",
107
+ "shared OPTIONS",
108
+ "state in the draft",
109
+ "draft part",
110
+ ],
111
+ doc: "uikit/detail.md",
112
+ heading: "How to: read the detail from a component inside it",
113
+ seeAlso: ["uikit/form/annotations.md"],
114
+ summary:
115
+ "useMapoDetail() gives a component inside MapoDetail the record, the fields rendered, languages, state, save(), onSaved(), an annotations channel and draft.part(), which keeps the component's own state in the page's draft, restored, discarded and cleared with the record's values.",
116
+ },
117
+ {
118
+ id: "detail-extensions",
119
+ task: "Add an action or a section to every detail page",
120
+ keywords: [
121
+ "defineDetailExtension",
122
+ "detail extension",
123
+ "every detail page",
124
+ "action above save",
125
+ "MapoDetailExtensions",
126
+ "extensions prop",
127
+ ],
128
+ doc: "uikit/detail.md",
129
+ heading: "How to: add an action to every detail page",
130
+ seeAlso: ["uikit/api.md"],
131
+ summary:
132
+ "defineDetailExtension(), from a plugin, adds a component above Save or above the form of every MapoDetail; pages pick them with the extensions prop.",
133
+ },
98
134
  {
99
135
  id: "standalone-form",
100
136
  task: "Use the form engine outside a detail page",
@@ -132,6 +168,24 @@ export const RECIPES: Recipe[] = [
132
168
  summary:
133
169
  "Every built-in field type, the component behind it and its attrs.",
134
170
  },
171
+ {
172
+ id: "block-editor",
173
+ task: "Build a block editor with a block picker (repeater with templates)",
174
+ keywords: [
175
+ "block editor",
176
+ "block picker",
177
+ "repeater templates",
178
+ "page builder",
179
+ "RepeaterTemplate",
180
+ "picker",
181
+ "content blocks",
182
+ ],
183
+ doc: "howto/form-advanced.md",
184
+ heading: "Describe blocks and choose them in a picker",
185
+ seeAlso: ["uikit/form/api.md", "uikit/form/add-fields.md"],
186
+ summary:
187
+ "attrs.templates with label, icon, image and category, and attrs.picker (select or modal).",
188
+ },
135
189
  {
136
190
  id: "custom-field",
137
191
  task: "Create and register a custom field type",
@@ -340,11 +394,19 @@ export const RECIPES: Recipe[] = [
340
394
  {
341
395
  id: "form-draft",
342
396
  task: "Autosave form drafts",
343
- keywords: ["draft", "autosave", "useFormDraft", "restore", "unsaved"],
397
+ keywords: [
398
+ "draft",
399
+ "autosave",
400
+ "useFormDraft",
401
+ "restore",
402
+ "unsaved",
403
+ "noDraft",
404
+ "saved draft",
405
+ ],
344
406
  doc: "uikit/form/draft.md",
345
- seeAlso: ["howto/crud-detail.md"],
407
+ seeAlso: ["uikit/detail.md", "howto/crud-detail.md"],
346
408
  summary:
347
- "useFormDraft keeps unsaved edits in localStorage and offers to restore them on the next visit.",
409
+ 'useFormDraft keeps unsaved edits in localStorage and offers to restore them on the next visit. MapoDetail does it with :draft="true", and useMapoForm with draftKey: per user, without the fields marked noDraft wherever their value is (every language, dotted keys, repeater items), new records included once they hold a value.',
348
410
  },
349
411
  {
350
412
  id: "schema-to-form",
@@ -362,6 +424,60 @@ export const RECIPES: Recipe[] = [
362
424
  summary:
363
425
  "useFormFromSchema turns a JSON Schema (DRF, Pydantic) into field descriptors you can extend.",
364
426
  },
427
+ {
428
+ id: "form-to-schema",
429
+ task: "Describe a form as JSON Schema",
430
+ keywords: [
431
+ "fieldsToJsonSchema",
432
+ "form to json schema",
433
+ "export the fields",
434
+ "serialize the form",
435
+ "round trip",
436
+ "x-mapo-field",
437
+ "x-mapo-attrs",
438
+ ],
439
+ doc: "uikit/form/schema-to-form.md",
440
+ heading: "From form to JSON Schema",
441
+ seeAlso: ["uikit/form/custom-fields.md"],
442
+ summary:
443
+ "fieldsToJsonSchema writes a form's descriptors as JSON Schema, and useFormFromSchema reads it back into the same descriptors.",
444
+ },
445
+ {
446
+ id: "schema-sources",
447
+ task: "Build a form from DRF OPTIONS metadata or an OpenAPI document",
448
+ keywords: [
449
+ "drf metadata",
450
+ "options metadata",
451
+ "actions.POST",
452
+ "drfMetadataToJsonSchema",
453
+ "openApiToJsonSchema",
454
+ "metadataToJsonSchema",
455
+ "schemaFromMetadata",
456
+ "placeholder field",
457
+ ],
458
+ doc: "uikit/form/schema-to-form.md",
459
+ heading: "From DRF metadata and OpenAPI",
460
+ seeAlso: ["uikit/detail.md"],
461
+ summary:
462
+ "drfMetadataToJsonSchema and openApiToJsonSchema read what a DRF backend publishes as JSON Schema; MapoDetail derives its fields from the OPTIONS metadata.",
463
+ },
464
+ {
465
+ id: "descriptor-extensions",
466
+ task: "Add typed properties of your own to field descriptors",
467
+ keywords: [
468
+ "FieldExtensions",
469
+ "extend the descriptor",
470
+ "declare module",
471
+ "module augmentation",
472
+ "custom descriptor property",
473
+ "typed property",
474
+ ],
475
+ doc: "uikit/form/custom-fields.md",
476
+ heading: "Add your own descriptor properties",
477
+ seeAlso: ["uikit/form/schema-to-form.md"],
478
+ summary:
479
+ "FieldExtensions adds typed properties of your own to every descriptor through module augmentation; the property option of fieldsToJsonSchema writes them into the schema.",
480
+ },
365
481
  {
366
482
  id: "form-slots",
367
483
  task: "Customize how a form field renders with slots",
@@ -393,6 +509,27 @@ export const RECIPES: Recipe[] = [
393
509
  summary:
394
510
  "Open a repeater item in a fullscreen view, or expand a single field in place.",
395
511
  },
512
+ {
513
+ id: "field-annotations",
514
+ task: "Annotate the fields an assistant filled or that need a review",
515
+ keywords: [
516
+ "annotations",
517
+ "annotate",
518
+ "mark a field",
519
+ "field badge",
520
+ "tab count",
521
+ "suggested value",
522
+ "imported value",
523
+ "review note",
524
+ "outside the descriptor",
525
+ "MapoFormAnnotation",
526
+ "useFieldAnnotation",
527
+ ],
528
+ doc: "uikit/form/annotations.md",
529
+ seeAlso: ["uikit/form/slots.md", "uikit/form/api.md"],
530
+ summary:
531
+ "A reactive map keyed by value path on MapoForm, MapoDetail or useMapoForm: a mark with a popover next to the label and badges on tabs and repeater items, without remounting the fields.",
532
+ },
396
533
  {
397
534
  id: "sidebar-navigation",
398
535
  task: "Build the sidebar navigation",
@@ -403,12 +540,14 @@ export const RECIPES: Recipe[] = [
403
540
  "icon",
404
541
  "label",
405
542
  "sidebarFooter",
543
+ "sidebarOrder",
544
+ "reorder menu",
406
545
  "route meta",
407
546
  ],
408
547
  doc: "uikit/sidebar.md",
409
548
  seeAlso: ["howto/first-admin-page.md"],
410
549
  summary:
411
- "Route metadata (label, icon, parent, sidebarFooter) builds the sidebar tree, with no menu config.",
550
+ "Route metadata builds the sidebar tree without menu config; use sidebarOrder to sort sibling entries.",
412
551
  },
413
552
  {
414
553
  id: "login-page",
@@ -513,6 +652,292 @@ export const RECIPES: Recipe[] = [
513
652
  summary:
514
653
  "The Mapo Forms tab: the module config and the live field registry your forms read.",
515
654
  },
655
+ {
656
+ id: "ai-setup",
657
+ task: "Turn on the AI module and Magic Fill with a guided setup",
658
+ keywords: [
659
+ "set up the ai",
660
+ "configure the ai",
661
+ "enable the ai module",
662
+ "guided setup",
663
+ "what can the ai do",
664
+ "mapo_ai_setup",
665
+ "mapo-ai-setup",
666
+ "ai tokens",
667
+ "experimental",
668
+ ],
669
+ doc: "modules/ai.md",
670
+ heading: "Enable the module",
671
+ seeAlso: ["modules/mcp.md", "howto/magic-fill.md"],
672
+ summary:
673
+ "Experimental, on npm's experimental dist-tag only (pnpm add mapomodule@experimental): setting mapo.ai in nuxt.config.ts installs @mapomodule/ai, and a provider turns Magic Fill on in every MapoDetail. The mapo_ai_setup tool, or the mapo-ai-setup prompt, asks the developer what the AI is for, says what the module can and cannot do for it, and proposes the configuration, the environment variables (names only), the keys and tokens, and the server plugins.",
674
+ },
675
+ {
676
+ id: "ai-run",
677
+ task: "Ask the AI to fill a record from a source",
678
+ keywords: [
679
+ "mapo.ai",
680
+ "language model",
681
+ "_mapo/ai/run",
682
+ "extract records",
683
+ "field outcomes",
684
+ "experimental",
685
+ ],
686
+ doc: "modules/ai.md",
687
+ heading: "Ask the AI",
688
+ seeAlso: ["uikit/form/schema-to-form.md"],
689
+ summary:
690
+ "Experimental, opt-in with mapo.ai: POST /_mapo/ai/run sends a record's backend schema and form fields with a source to an enabled provider and answers one checked outcome per field; useMapoAiFill() applies it to a detail form.",
691
+ },
692
+ {
693
+ id: "ai-fill",
694
+ task: "Fill a detail form with the AI from a pasted text",
695
+ keywords: [
696
+ "useMapoAiFill",
697
+ "pasted text",
698
+ "fill the form",
699
+ "detail extension",
700
+ "verified values",
701
+ "undo",
702
+ "already holds",
703
+ "related records",
704
+ "relationChoices",
705
+ "experimental",
706
+ ],
707
+ doc: "modules/ai.md",
708
+ heading: "Fill a detail form",
709
+ seeAlso: ["uikit/detail.md", "uikit/form/annotations.md"],
710
+ summary:
711
+ "Experimental: in a detail extension, useMapoAiFill(detail), with the context of useMapoDetail(), sends the form's fields and the backend schema from OPTIONS with a source to run, writes each value a quote verifies into an empty field it shows and marks the others to apply, pick, set by hand or ignore, each mark with the words of the source that prove it; the mark of a replacement says what it replaces, and a value the field already holds is unchanged. Related records (fks and m2m fields with an endpoint) are looked up with the operator's session: the AI picks from the records of a relation that has 50 at most, or writes a name searched with ?search=; a record found with the AI's very name goes in as a verified value, one under another name waits with Apply, several are candidates to pick on the field's mark (choose()), and an m2m adds the records found after the field's own. The answers of a session add up: keep() or a change in the field makes a value the operator's, undo() puts back every answer's values, newest first, and a save of the record ends the session. snapshot() and resume() keep the session in a draft and take it back, read as outside data.",
712
+ },
713
+ {
714
+ id: "ai-field-options",
715
+ task: "Guide the AI on one field, keep a field from it, or keep a relation's records from the provider",
716
+ keywords: [
717
+ "x-mapo-ai",
718
+ "ai.hint",
719
+ "hint",
720
+ "ai.exclude",
721
+ "list: false",
722
+ "keep a field from the ai",
723
+ "relation names",
724
+ "relationChoices",
725
+ "mapoAiFieldsSchema",
726
+ "privacy",
727
+ "experimental",
728
+ ],
729
+ doc: "modules/ai.md",
730
+ heading: "Guide a field",
731
+ seeAlso: ["howto/magic-fill.md", "uikit/form/custom-fields.md"],
732
+ summary:
733
+ "Experimental: with @mapomodule/ai installed, a field descriptor takes ai (declared on FieldExtensions): { hint } tells the model what to take and how, { exclude: true } keeps the field away from the AI, { list: false } keeps a relation's records from the provider (they are never listed, even when 50 or fewer; the AI writes the name it reads and Magic Fill searches it with ?search= after the answer). A backend's schema says the same with x-mapo-ai; what either side says holds, inside a repeater's items too, and the gateway leaves out the records of an unlisted relation even from a request that lists them. Magic Fill and useMapoAiFill() send them; a page that calls POST /_mapo/ai/run itself sends its fields with mapoAiFieldsSchema(fields), auto-imported, since fieldsToJsonSchema(fields) leaves them out.",
734
+ },
735
+ {
736
+ id: "ai-magic-fill",
737
+ task: "Use Magic Fill, the AI panel of detail pages",
738
+ keywords: [
739
+ "magic fill",
740
+ "magicFill",
741
+ "disable",
742
+ "useMapoAiMagicFill",
743
+ "MapoAiMagicFillPanel",
744
+ "what i send to the ai",
745
+ "run/preview",
746
+ "cancel the call",
747
+ "undo all",
748
+ "proposals without proof",
749
+ "apply selected",
750
+ "before and after",
751
+ "items of a list",
752
+ "after a reload",
753
+ "related records",
754
+ "no quotes",
755
+ "evidence",
756
+ "next to check",
757
+ "magic fill error",
758
+ "experimental",
759
+ ],
760
+ doc: "howto/magic-fill.md",
761
+ seeAlso: ["modules/ai.md", "uikit/detail.md", "uikit/mapoverride.md"],
762
+ summary:
763
+ "Experimental: with mapo.ai and uikit, every MapoDetail gets Magic Fill: a button in the sidebar card opens a panel (a text or files read through read, the operator's instructions, What I send to the AI from run/preview, the provider and model, Extract), and a banner above the form follows the call, with Cancel, and sums up the session, with Undo all: a second extraction keeps the first one's marks, Keep or a change makes a value the operator's, and Save ends the session. Below the summary, the preview lists the values that wait, each with a tick: to fill (empty fields, ticked), to replace (shown before and after, never ticked from the start) and proposals without proof; Apply selected writes the ticked ones, the others keep waiting, and Ignore all ignores them. A value the record already holds is no replacement: the summary counts it. A list of items, as a repeater's, is chosen item by item, its verified items ticked from the start; the chosen items go after the record's own, never one it holds already. Related records show by their names: one found under another name waits unticked, and a record to pick inside an item gets its own mark once the item is in. definePageMeta({ magicFill: { evidence: false } }) asks the AI for no quotes on a page: every value then waits, marked. On a page with drafts, the session goes into MapoDetail's draft: after a reload, Restore brings back the marks with their quotes, the summary and Undo all, never the source. What I send to the AI shows every user of the AI the rules as the model reads them, the app's, the mapo-ai:prompt hooks' and the admins' included. Next to check, in the banner, takes the operator to each mark that waits, in the order of the form: the tab, group or list item that holds the field opens and the field takes the focus (revealField of the detail's context). The banner's errors say what to do: a key or a model taken away while the page was open (run answers data.reason) makes Magic Fill ask status again. Fields are prepared with their labels, help texts and ai on the descriptor: hint, exclude, and list: false for a relation whose names must not reach the provider. mapo.ai.magicFill: false, definePageMeta({ magicFill: false }) or MapoDetail's extensions prop turn it off; the components can be replaced with MapoOverride, and useMapoAiMagicFill(detail, { part }) gives their state and tells the other parts an override is there.",
764
+ },
765
+ {
766
+ id: "ai-read-files",
767
+ task: "Give the AI a file, a web page, a CSV or an Excel sheet, instead of a pasted text",
768
+ keywords: [
769
+ "useMapoAiRead",
770
+ "_mapo/ai/read",
771
+ "upload a file",
772
+ "file input",
773
+ "excel",
774
+ "xlsx",
775
+ "csv",
776
+ "spreadsheet",
777
+ "html page",
778
+ "markdown",
779
+ "experimental",
780
+ ],
781
+ doc: "modules/ai.md",
782
+ heading: "Read a file",
783
+ summary:
784
+ "Experimental: useMapoAiRead().read(file) posts one file to POST /_mapo/ai/read, which reads text, Markdown, JSON, HTML (into Markdown) and CSV or XLSX (each sheet whole, as a Markdown table) into the text parts run takes, without calling any AI; pass answer.parts to useMapoAiFill().fill(). The answer's status says when there are none: unsupported, empty, too-long (more than limits.maxSourceChars) or failed; files up to limits.maxFileBytes, 10 MB by default.",
785
+ },
786
+ {
787
+ id: "ai-readers",
788
+ task: "Replace how the AI gateway reads a file format, add a format, or turn one off",
789
+ keywords: [
790
+ "registerMapoAiReader",
791
+ "mapo-ai:read",
792
+ "mapo.ai.readers",
793
+ "custom reader",
794
+ "reader",
795
+ "file format",
796
+ "turn off",
797
+ "redact",
798
+ "experimental",
799
+ ],
800
+ doc: "modules/ai.md",
801
+ heading: "Replace or add a reader",
802
+ summary:
803
+ "Experimental: in a Nitro plugin, registerMapoAiReader({ id, extensions, types?, read(file) }) puts the app's reader in place of Mapo's with the same id (text, markdown, json, html, csv, xlsx) or adds a format; the mapo-ai:read hook touches up the parts any reader read (context.parts), files only, never pasted text; mapo.ai.readers turns a reader off by id ({ xlsx: false }, or NUXT_MAPO_AI_READERS_XLSX=false).",
804
+ },
805
+ {
806
+ id: "ai-providers",
807
+ task: "Add an AI provider, or answer with the mock",
808
+ keywords: [
809
+ "registerMapoAiProvider",
810
+ "MapoAiProviderError",
811
+ "registerMapoAiMockFixtures",
812
+ "mapo.ai.providers",
813
+ "mock provider",
814
+ "fixtures",
815
+ "llm",
816
+ ],
817
+ doc: "modules/ai.md",
818
+ heading: "Providers",
819
+ seeAlso: ["modules/api.md"],
820
+ summary:
821
+ "mapo.ai.providers enables what run may call: Mapo's mock, which answers without a network from fixtures or Label: value lines, Mapo's providers for OpenAI, Anthropic and local models, or a provider the app registers in a Nitro plugin with registerMapoAiProvider().",
822
+ },
823
+ {
824
+ id: "ai-keys",
825
+ task: "Assign AI provider keys and models to groups or users, or let operators use their own token",
826
+ keywords: [
827
+ "_mapo/ai/keys",
828
+ "_mapo/ai/token",
829
+ "assign a key",
830
+ "key per group",
831
+ "group",
832
+ "personal token",
833
+ "own token",
834
+ "key level",
835
+ "experimental",
836
+ ],
837
+ doc: "modules/ai.md",
838
+ heading: "Keys",
839
+ summary:
840
+ "Experimental: each call uses the key nearest the user: their own token where an admin's assignment allows it (PUT /_mapo/ai/token), else the first key up the admins' assignments (the user's, their groups' by the admins' order, everyone's: PUT /_mapo/ai/keys, PUT /_mapo/ai/keys/groups), else the project's in the environment. The nearest assignment also narrows the models; personal tokens are off unless allowed; status says the level and the last four characters, never the key; a provider with no key at any level answers 503.",
841
+ },
842
+ {
843
+ id: "ai-settings",
844
+ task: "Give users and admins a page to choose AI providers and models, manage keys and check the connection",
845
+ keywords: [
846
+ "MapoAiSettings",
847
+ "ai-settings",
848
+ "mapo.ai.settings",
849
+ "settings page",
850
+ "usersApi",
851
+ "groupsApi",
852
+ "preference",
853
+ "check the connection",
854
+ "experimental",
855
+ ],
856
+ doc: "modules/ai.md",
857
+ heading: "AI settings",
858
+ summary:
859
+ "Experimental: the module adds an AI settings page at /ai-settings (mapo.ai.settings.path moves it, false leaves it out for <MapoAiSettings /> in a page of the app). Each user saves their provider and model (PUT /_mapo/ai/preferences), sees their key, saves their own token where allowed and checks the connection (POST /_mapo/ai/test, which lists the provider's models with their key, at no cost); admins assign keys, searching the backend's users and groups through mapo.ai.settings.usersApi and groupsApi.",
860
+ },
861
+ {
862
+ id: "ai-admin-settings",
863
+ task: "Let the AI's admins change its instructions, verification rules, secret fields and models without a deploy",
864
+ keywords: [
865
+ "secretWords",
866
+ "adminModels",
867
+ "fallbacks",
868
+ "admin instructions",
869
+ "verification rules",
870
+ "secret field",
871
+ "add a model",
872
+ "how the AI works",
873
+ "experimental",
874
+ ],
875
+ doc: "modules/ai.md",
876
+ heading: "How the AI works",
877
+ summary:
878
+ "Experimental: on the AI settings page the AI's admins change how the AI works in the whole app (GET/PUT /_mapo/ai/settings, POST /_mapo/ai/settings/preview): their instructions (layer 3 of the prompt, after Mapo's and the app's; every user of the AI reads them in Magic Fill's What I send to the AI), the rules of verification over mapo.ai.verification, words that keep a field from the AI besides Mapo's and mapo.ai.secretWords, the prompt cache of openai and anthropic, Anthropic's fallbacks (off; on only where the app's anthropic.fallbacks leaves them on), and models they add where the app sets providers.<id>.adminModels: true, saved once the provider's server lists them. The app's options stay the defaults; changes are audited, and an unreadable record closes the AI with 503.",
879
+ },
880
+ {
881
+ id: "ai-usage",
882
+ task: "See how much the AI is used and what it costs, by user, model and day",
883
+ keywords: [
884
+ "usage",
885
+ "tokens",
886
+ "cost",
887
+ "prices",
888
+ "mapo.ai.prices",
889
+ "audit",
890
+ "changes",
891
+ "experimental",
892
+ ],
893
+ doc: "modules/ai.md",
894
+ heading: "Usage",
895
+ summary:
896
+ "Experimental: the AI settings page shows the usage summed from the audit when it is read: the AI's admins see every user's calls of a period (GET /_mapo/ai/usage?days=, 1 to 3650, 30 unless set; the page offers 7, 30 and 90) by user, model and day, the latest 50 calls and the changes of keys and settings (GET /_mapo/ai/actions); each user their own (GET /_mapo/ai/usage/mine). Tokens always; a cost only for the models the app prices in mapo.ai.prices ({ currency, providers: { [provider]: { [model]: { input, output, cacheRead?, cacheWrite? } } } }, per million tokens): Mapo keeps no price list. Never what was sent.",
897
+ },
898
+ {
899
+ id: "ai-cloud-models",
900
+ task: "Use OpenAI or Anthropic (Claude) models for the AI",
901
+ keywords: [
902
+ "openai",
903
+ "anthropic",
904
+ "claude",
905
+ "gpt",
906
+ "api key",
907
+ "prompt cache",
908
+ "promptCache",
909
+ "effort",
910
+ "reasoning",
911
+ "fallbacks",
912
+ "structured outputs",
913
+ ],
914
+ doc: "modules/ai.md",
915
+ heading: "OpenAI",
916
+ summary:
917
+ "Experimental: enable openai (Responses API, gpt-6.1-sol and gpt-6-luna unless models says otherwise) or anthropic (Messages API, claude-opus-5-5, claude-sonnet-5-5 and claude-haiku-5-5) in mapo.ai.providers, with the project's key in NUXT_MAPO_AI_PROVIDERS_OPENAI_API_KEY or NUXT_MAPO_AI_PROVIDERS_ANTHROPIC_API_KEY, never in the config (the AI's admins can assign their own over it); effort is \"low\" unless set, promptCache is off unless set, timeout 300 seconds; Anthropic retries a request its safety filters decline on a fallback model, which the answer's provider.model names.",
918
+ },
919
+ {
920
+ id: "ai-local-models",
921
+ task: "Use a local model, served by Ollama, LM Studio or vLLM, for the AI",
922
+ keywords: [
923
+ "ollama",
924
+ "local model",
925
+ "openai-compatible",
926
+ "lm studio",
927
+ "vllm",
928
+ "llama.cpp",
929
+ "self-hosted",
930
+ "server",
931
+ "api key",
932
+ "baseURL",
933
+ "contextTokens",
934
+ "num_ctx",
935
+ ],
936
+ doc: "modules/ai.md",
937
+ heading: "Ollama",
938
+ summary:
939
+ "Experimental: enable ollama (Ollama 0.40.13 or later, through its own API, http://localhost:11434 unless baseURL says otherwise) or openai-compatible (baseURL up to /v1, contextTokens when the server's list does not say the context) in mapo.ai.providers, with the models to allow; keys go in NUXT_MAPO_AI_PROVIDERS_OLLAMA_API_KEY or NUXT_MAPO_AI_PROVIDERS_OPENAI_COMPATIBLE_API_KEY; a prompt the model cannot read whole answers 413, a cut answer 502.",
940
+ },
516
941
  ];
517
942
 
518
943
  export interface RecipeMatch extends Recipe {
@@ -109,7 +109,10 @@ export function searchDocs(
109
109
  if (seenTerms.has(term)) continue;
110
110
  seenTerms.add(term);
111
111
 
112
- const postings = index.terms[term];
112
+ // The table is plain JSON once loaded: a word like `constructor` must
113
+ // be one of its own keys, not a property every object inherits.
114
+ const isIndexed = Object.hasOwn(index.terms, term);
115
+ const postings = isIndexed ? index.terms[term] : undefined;
113
116
  if (!postings) continue;
114
117
 
115
118
  // Standard BM25 idf, floored so very common terms still contribute a little.