@proveanything/smartlinks 2.1.39 → 2.1.40

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.
@@ -0,0 +1,102 @@
1
+ ---
2
+ title: Knowledge search
3
+ description: Make a collection's content searchable by meaning and keywords, for people and for AI agents.
4
+ category: AI
5
+ ---
6
+
7
+ # Knowledge search
8
+
9
+ Knowledge search makes a business's own content searchable by meaning and by keywords: product manuals,
10
+ help articles, FAQs, docs, or anything your app holds. People search it from a website, Portal or Hub, and
11
+ AI agents search it with the `knowledge.search` tool. Because it matches meaning and exact words together,
12
+ "how do I clean it" finds a "Descaling" section, and a model number or error code still finds itself.
13
+
14
+ ## How it fits together
15
+
16
+ - **Sets.** A collection has knowledge sets, such as "Product manuals" or "Help articles". Each set is
17
+ `public` (anyone), `customer` (signed-in people) or `staff` (the business and its assistants).
18
+ - **Sources.** A set points at sources instead of holding copies:
19
+ - `markdown_feed`: a Markdown bundle at an address (documents separated by `---`, each with a
20
+ `Source: <url>` line).
21
+ - `url`: one web page or document.
22
+ - `documents`: documents your app pushes with `knowledge.upsertDocuments`.
23
+ - **Passages.** The platform splits each document into passages along its headings. Each passage keeps its
24
+ heading path ("Settings › Email footer") and a link to its section. Feeds and pages are re-read on a
25
+ schedule (every 24 hours by default), and only changed text is processed again.
26
+
27
+ ## Set it up (admin)
28
+
29
+ ```typescript
30
+ import { knowledge } from '@proveanything/smartlinks'
31
+
32
+ await knowledge.saveSet('coll_123', { key: 'manuals', name: 'Product manuals', visibility: 'public' })
33
+
34
+ // Documents your app pushes. The same ref replaces its earlier version.
35
+ const src = await knowledge.addSource('coll_123', 'manuals', { kind: 'documents' })
36
+ await knowledge.upsertDocuments('coll_123', src.id, [
37
+ {
38
+ ref: 'kettle-k200',
39
+ title: 'K200 kettle manual',
40
+ body: '## Descaling\n\nDescale every month with citric acid…',
41
+ url: 'https://brand.example/manuals/k200',
42
+ meta: { productId: 'prod_k200' },
43
+ },
44
+ ])
45
+
46
+ // Or a page / a Markdown feed, re-read every 24 hours
47
+ await knowledge.addSource('coll_123', 'manuals', {
48
+ kind: 'url',
49
+ config: { url: 'https://brand.example/support/k200' },
50
+ })
51
+ ```
52
+
53
+ A source's `status` shows whether it's `ready`, still `indexing`, or `failed` (with `error` saying why). A
54
+ failed re-read keeps the previous passages searchable. `knowledge.reindex` reads a source again now.
55
+
56
+ ## Search
57
+
58
+ ```typescript
59
+ // From a website, Portal or Hub: public sets, plus customer sets for a signed-in person
60
+ const { results } = await knowledge.publicSearch('coll_123', {
61
+ query: 'how do I descale',
62
+ filters: { productId: 'prod_k200' }, // exact matches on a document's meta
63
+ k: 5,
64
+ })
65
+ for (const r of results) console.log(r.title, r.heading, r.url, r.snippet)
66
+
67
+ // Staff: every set
68
+ await knowledge.search('coll_123', { query: 'refund policy for damaged items' })
69
+ ```
70
+
71
+ Each result has `title` (the document), `heading` (its section), `url` (a link to the section), `snippet`
72
+ (for a results list) and `text` (the whole passage, for an AI to read). `mode` says how the search ran:
73
+ `hybrid` (meaning and keywords) or `keywords`.
74
+
75
+ ## For AI agents
76
+
77
+ Give an agent the `knowledge.search` tool, and it searches before it answers and can cite the links:
78
+
79
+ ```typescript
80
+ const run = await ai.agent.run('coll_123', {
81
+ input: 'A customer asks how to descale the K200. Draft a reply with the steps.',
82
+ toolbelt: { builtins: ['knowledge.search'] },
83
+ })
84
+ ```
85
+
86
+ On the public surface (`ai.public.agentRun`), built-in tools are off, so public assistants don't get this
87
+ tool yet. A cited-answer call for public use is planned.
88
+
89
+ ## Who sees what
90
+
91
+ | Caller | Sets searched |
92
+ |---|---|
93
+ | Anyone (`publicSearch`, no sign-in) | `public` |
94
+ | A signed-in person (`publicSearch`) | `public`, `customer` |
95
+ | Staff (`search`, agents in Studio) | `public`, `customer`, `staff` |
96
+
97
+ Naming a set the caller may not read in `sets` returns nothing from it.
98
+
99
+ ## Costs
100
+
101
+ Making passages searchable by meaning, and searching by meaning, use AI. That use is counted against the
102
+ collection's AI credits like any other AI call. Unchanged text is never processed twice.
package/dist/openapi.yaml CHANGED
@@ -24,8 +24,6 @@ tags:
24
24
  description: Reusable agent skills.
25
25
  - name: models
26
26
  description: Available AI models and their metadata.
27
- - name: rag
28
- description: Retrieval-augmented generation and document indexing.
29
27
  - name: sessions
30
28
  description: Conversation session management.
31
29
  - name: podcast
@@ -810,39 +808,6 @@ paths:
810
808
  description: Unauthorized
811
809
  404:
812
810
  description: Not found
813
- /admin/collection/{collectionId}/ai/configureAssistant:
814
- post:
815
- tags:
816
- - rag
817
- summary: Configure AI assistant behavior
818
- operationId: rag_configureAssistant
819
- security:
820
- - bearerAuth: []
821
- parameters:
822
- - name: collectionId
823
- in: path
824
- required: true
825
- schema:
826
- type: string
827
- responses:
828
- 200:
829
- description: Success
830
- content:
831
- application/json:
832
- schema:
833
- $ref: "#/components/schemas/ConfigureAssistantResponse"
834
- 400:
835
- description: Bad request
836
- 401:
837
- description: Unauthorized
838
- 404:
839
- description: Not found
840
- requestBody:
841
- required: true
842
- content:
843
- application/json:
844
- schema:
845
- $ref: "#/components/schemas/ConfigureAssistantRequest"
846
811
  /admin/collection/{collectionId}/ai/createCache:
847
812
  post:
848
813
  tags:
@@ -936,39 +901,6 @@ paths:
936
901
  application/json:
937
902
  schema:
938
903
  $ref: "#/components/schemas/GeneratePodcastRequest"
939
- /admin/collection/{collectionId}/ai/indexDocument:
940
- post:
941
- tags:
942
- - rag
943
- summary: Index a document for RAG
944
- operationId: rag_indexDocument
945
- security:
946
- - bearerAuth: []
947
- parameters:
948
- - name: collectionId
949
- in: path
950
- required: true
951
- schema:
952
- type: string
953
- responses:
954
- 200:
955
- description: Success
956
- content:
957
- application/json:
958
- schema:
959
- $ref: "#/components/schemas/IndexDocumentResponse"
960
- 400:
961
- description: Bad request
962
- 401:
963
- description: Unauthorized
964
- 404:
965
- description: Not found
966
- requestBody:
967
- required: true
968
- content:
969
- application/json:
970
- schema:
971
- $ref: "#/components/schemas/IndexDocumentRequest"
972
904
  /admin/collection/{collectionId}/ai/models:
973
905
  get:
974
906
  tags:
@@ -11750,38 +11682,6 @@ paths:
11750
11682
  application/json:
11751
11683
  schema:
11752
11684
  $ref: "#/components/schemas/PublicAgentRunRequest"
11753
- /public/collection/{collectionId}/ai/chat:
11754
- post:
11755
- tags:
11756
- - publicClient
11757
- summary: Chat with product assistant (RAG)
11758
- operationId: publicClient_chat
11759
- security: []
11760
- parameters:
11761
- - name: collectionId
11762
- in: path
11763
- required: true
11764
- schema:
11765
- type: string
11766
- responses:
11767
- 200:
11768
- description: Success
11769
- content:
11770
- application/json:
11771
- schema:
11772
- $ref: "#/components/schemas/PublicChatResponse"
11773
- 400:
11774
- description: Bad request
11775
- 401:
11776
- description: Unauthorized
11777
- 404:
11778
- description: Not found
11779
- requestBody:
11780
- required: true
11781
- content:
11782
- application/json:
11783
- schema:
11784
- $ref: "#/components/schemas/PublicChatRequest"
11785
11685
  /public/collection/{collectionId}/ai/rate-limit/{userId}:
11786
11686
  get:
11787
11687
  tags:
@@ -18319,209 +18219,6 @@ components:
18319
18219
  required:
18320
18220
  - object
18321
18221
  - data
18322
- DocumentChunk:
18323
- type: object
18324
- properties:
18325
- text:
18326
- type: string
18327
- embedding:
18328
- type: array
18329
- items:
18330
- type: number
18331
- metadata:
18332
- type: object
18333
- additionalProperties: true
18334
- chunkIndex:
18335
- type: number
18336
- documentId:
18337
- type: string
18338
- required:
18339
- - text
18340
- - embedding
18341
- - metadata
18342
- - chunkIndex
18343
- - documentId
18344
- IndexDocumentRequest:
18345
- type: object
18346
- properties:
18347
- productId:
18348
- type: string
18349
- text:
18350
- type: string
18351
- documentUrl:
18352
- type: string
18353
- metadata:
18354
- type: object
18355
- additionalProperties: true
18356
- chunkSize:
18357
- type: number
18358
- overlap:
18359
- type: number
18360
- provider:
18361
- type: string
18362
- enum:
18363
- - openai
18364
- - gemini
18365
- required:
18366
- - productId
18367
- IndexDocumentResponse:
18368
- type: object
18369
- properties:
18370
- success:
18371
- type: boolean
18372
- productId:
18373
- type: string
18374
- documentId:
18375
- type: string
18376
- chunks:
18377
- type: number
18378
- metadata:
18379
- type: object
18380
- additionalProperties: true
18381
- textLength:
18382
- type: number
18383
- chunkSize:
18384
- type: number
18385
- overlap:
18386
- type: number
18387
- embeddingDimensions:
18388
- type: number
18389
- sample:
18390
- type: object
18391
- additionalProperties: true
18392
- text:
18393
- type: string
18394
- chunkIndex:
18395
- type: number
18396
- required:
18397
- - success
18398
- - productId
18399
- - documentId
18400
- - chunks
18401
- - metadata
18402
- - textLength
18403
- - chunkSize
18404
- - overlap
18405
- - embeddingDimensions
18406
- - text
18407
- - chunkIndex
18408
- ConfigureAssistantRequest:
18409
- type: object
18410
- properties:
18411
- productId:
18412
- type: string
18413
- systemPrompt:
18414
- type: string
18415
- model:
18416
- type: string
18417
- maxTokensPerResponse:
18418
- type: number
18419
- temperature:
18420
- type: number
18421
- rateLimitPerUser:
18422
- type: number
18423
- allowedTopics:
18424
- type: array
18425
- items:
18426
- type: string
18427
- customInstructions:
18428
- type: object
18429
- additionalProperties: true
18430
- tone:
18431
- type: string
18432
- additionalRules:
18433
- type: string
18434
- required:
18435
- - productId
18436
- ConfigureAssistantResponse:
18437
- type: object
18438
- properties:
18439
- success:
18440
- type: boolean
18441
- configuration:
18442
- type: object
18443
- additionalProperties: true
18444
- productId:
18445
- type: string
18446
- systemPrompt:
18447
- type: string
18448
- model:
18449
- type: string
18450
- maxTokensPerResponse:
18451
- type: number
18452
- temperature:
18453
- type: number
18454
- rateLimitPerUser:
18455
- type: number
18456
- allowedTopics:
18457
- type: array
18458
- items:
18459
- type: string
18460
- customInstructions:
18461
- type: object
18462
- additionalProperties: true
18463
- updatedAt:
18464
- type: string
18465
- required:
18466
- - success
18467
- - configuration
18468
- - productId
18469
- - systemPrompt
18470
- - model
18471
- - maxTokensPerResponse
18472
- - temperature
18473
- - rateLimitPerUser
18474
- - allowedTopics
18475
- - updatedAt
18476
- PublicChatRequest:
18477
- type: object
18478
- properties:
18479
- productId:
18480
- type: string
18481
- userId:
18482
- type: string
18483
- message:
18484
- type: string
18485
- sessionId:
18486
- type: string
18487
- stream:
18488
- type: boolean
18489
- required:
18490
- - productId
18491
- - userId
18492
- - message
18493
- PublicChatResponse:
18494
- type: object
18495
- properties:
18496
- message:
18497
- type: string
18498
- sessionId:
18499
- type: string
18500
- usage:
18501
- type: object
18502
- additionalProperties: true
18503
- prompt_tokens:
18504
- type: number
18505
- completion_tokens:
18506
- type: number
18507
- total_tokens:
18508
- type: number
18509
- context:
18510
- type: object
18511
- additionalProperties: true
18512
- chunksUsed:
18513
- type: number
18514
- topSimilarity:
18515
- type: number
18516
- required:
18517
- - message
18518
- - sessionId
18519
- - usage
18520
- - prompt_tokens
18521
- - completion_tokens
18522
- - total_tokens
18523
- - chunksUsed
18524
- - topSimilarity
18525
18222
  Session:
18526
18223
  type: object
18527
18224
  properties:
@@ -19772,6 +19469,14 @@ components:
19772
19469
  - HEAD
19773
19470
  required:
19774
19471
  - url
19472
+ KnowledgeSearchArgs:
19473
+ type: object
19474
+ properties:
19475
+ query:
19476
+ type: object
19477
+ additionalProperties: true
19478
+ required:
19479
+ - query
19775
19480
  TranslateArgs:
19776
19481
  type: object
19777
19482
  properties:
@@ -19835,6 +19540,8 @@ components:
19835
19540
  $ref: "#/components/schemas/HttpRequestArgs"
19836
19541
  translate:
19837
19542
  $ref: "#/components/schemas/TranslateArgs"
19543
+ knowledge.search:
19544
+ $ref: "#/components/schemas/KnowledgeSearchArgs"
19838
19545
  required:
19839
19546
  - web.fetchPage
19840
19547
  - web.extractSchema
@@ -19862,6 +19569,7 @@ components:
19862
19569
  - pdf.printReady
19863
19570
  - http.request
19864
19571
  - translate
19572
+ - knowledge.search
19865
19573
  WebSearchResultItem:
19866
19574
  type: object
19867
19575
  properties:
@@ -20293,6 +20001,7 @@ components:
20293
20001
  - "media:image"
20294
20002
  - "media:pdf"
20295
20003
  - "net:http"
20004
+ - "knowledge:read"
20296
20005
  AiToolName:
20297
20006
  type: string
20298
20007
  enum:
@@ -20322,6 +20031,7 @@ components:
20322
20031
  - pdf.printReady
20323
20032
  - http.request
20324
20033
  - translate
20034
+ - knowledge.search
20325
20035
  PdfColour:
20326
20036
  type: object
20327
20037
  additionalProperties: true
@@ -33404,6 +33114,233 @@ components:
33404
33114
  type: array
33405
33115
  items:
33406
33116
  type: string
33117
+ KnowledgeSet:
33118
+ type: object
33119
+ properties:
33120
+ id:
33121
+ type: string
33122
+ key:
33123
+ type: string
33124
+ name:
33125
+ type: string
33126
+ description:
33127
+ type: string
33128
+ visibility:
33129
+ $ref: "#/components/schemas/KnowledgeVisibility"
33130
+ ownerAppId:
33131
+ type: string
33132
+ embedModel:
33133
+ type: string
33134
+ createdAt:
33135
+ type: string
33136
+ updatedAt:
33137
+ type: string
33138
+ sourceCount:
33139
+ type: number
33140
+ passageCount:
33141
+ type: number
33142
+ required:
33143
+ - id
33144
+ - key
33145
+ - name
33146
+ - description
33147
+ - visibility
33148
+ - ownerAppId
33149
+ - embedModel
33150
+ - createdAt
33151
+ - updatedAt
33152
+ SaveKnowledgeSetRequest:
33153
+ type: object
33154
+ properties:
33155
+ key:
33156
+ type: string
33157
+ name:
33158
+ type: string
33159
+ description:
33160
+ type: string
33161
+ visibility:
33162
+ $ref: "#/components/schemas/KnowledgeVisibility"
33163
+ required:
33164
+ - key
33165
+ - name
33166
+ UpdateKnowledgeSetRequest:
33167
+ type: object
33168
+ properties:
33169
+ name:
33170
+ type: string
33171
+ description:
33172
+ type: string
33173
+ visibility:
33174
+ $ref: "#/components/schemas/KnowledgeVisibility"
33175
+ KnowledgeSource:
33176
+ type: object
33177
+ properties:
33178
+ id:
33179
+ type: string
33180
+ setId:
33181
+ type: string
33182
+ kind:
33183
+ $ref: "#/components/schemas/KnowledgeSourceKind"
33184
+ name:
33185
+ type: string
33186
+ config:
33187
+ type: object
33188
+ additionalProperties: true
33189
+ refreshHours:
33190
+ type: number
33191
+ status:
33192
+ type: string
33193
+ enum:
33194
+ - pending
33195
+ - indexing
33196
+ - ready
33197
+ - failed
33198
+ error:
33199
+ type: string
33200
+ passageCount:
33201
+ type: number
33202
+ lastIndexedAt:
33203
+ type: string
33204
+ createdAt:
33205
+ type: string
33206
+ updatedAt:
33207
+ type: string
33208
+ required:
33209
+ - id
33210
+ - setId
33211
+ - kind
33212
+ - name
33213
+ - config
33214
+ - refreshHours
33215
+ - status
33216
+ - error
33217
+ - passageCount
33218
+ - lastIndexedAt
33219
+ - createdAt
33220
+ - updatedAt
33221
+ AddKnowledgeSourceRequest:
33222
+ type: object
33223
+ properties:
33224
+ kind:
33225
+ $ref: "#/components/schemas/KnowledgeSourceKind"
33226
+ config:
33227
+ type: object
33228
+ additionalProperties: true
33229
+ name:
33230
+ type: string
33231
+ refreshHours:
33232
+ type: number
33233
+ required:
33234
+ - kind
33235
+ UpdateKnowledgeSourceRequest:
33236
+ type: object
33237
+ properties:
33238
+ config:
33239
+ type: object
33240
+ additionalProperties: true
33241
+ name:
33242
+ type: string
33243
+ refreshHours:
33244
+ type: number
33245
+ KnowledgeDocument:
33246
+ type: object
33247
+ properties:
33248
+ ref:
33249
+ type: string
33250
+ title:
33251
+ type: string
33252
+ body:
33253
+ type: string
33254
+ url:
33255
+ type: string
33256
+ meta:
33257
+ type: object
33258
+ additionalProperties: true
33259
+ required:
33260
+ - ref
33261
+ - title
33262
+ - body
33263
+ KnowledgeSearchRequest:
33264
+ type: object
33265
+ properties:
33266
+ query:
33267
+ type: string
33268
+ sets:
33269
+ type: array
33270
+ items:
33271
+ type: string
33272
+ filters:
33273
+ type: object
33274
+ additionalProperties: true
33275
+ k:
33276
+ type: number
33277
+ required:
33278
+ - query
33279
+ KnowledgeSearchResult:
33280
+ type: object
33281
+ properties:
33282
+ id:
33283
+ type: string
33284
+ title:
33285
+ type: string
33286
+ heading:
33287
+ type: string
33288
+ url:
33289
+ type: string
33290
+ snippet:
33291
+ type: string
33292
+ text:
33293
+ type: string
33294
+ score:
33295
+ type: number
33296
+ set:
33297
+ type: object
33298
+ additionalProperties: true
33299
+ sourceId:
33300
+ type: string
33301
+ meta:
33302
+ type: object
33303
+ additionalProperties: true
33304
+ required:
33305
+ - id
33306
+ - title
33307
+ - heading
33308
+ - url
33309
+ - snippet
33310
+ - text
33311
+ - score
33312
+ - set
33313
+ - sourceId
33314
+ - meta
33315
+ KnowledgeSearchResponse:
33316
+ type: object
33317
+ properties:
33318
+ query:
33319
+ type: string
33320
+ results:
33321
+ type: array
33322
+ items:
33323
+ $ref: "#/components/schemas/KnowledgeSearchResult"
33324
+ mode:
33325
+ type: string
33326
+ enum:
33327
+ - hybrid
33328
+ - keywords
33329
+ - none
33330
+ required:
33331
+ - query
33332
+ - results
33333
+ - mode
33334
+ KnowledgeVisibility:
33335
+ type: string
33336
+ enum:
33337
+ - public
33338
+ - customer
33339
+ - staff
33340
+ KnowledgeSourceKind:
33341
+ type: string
33342
+ enum:
33343
+ - markdown_feed
33407
33344
  Location:
33408
33345
  type: object
33409
33346
  properties: