@proveanything/smartlinks 2.1.38 → 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.
@@ -261,95 +261,6 @@ export interface AIModelListResponse {
261
261
  object: 'list';
262
262
  data: AIModel[];
263
263
  }
264
- /** Document chunk with embedding */
265
- export interface DocumentChunk {
266
- text: string;
267
- embedding: number[];
268
- metadata: {
269
- chunkIndex: number;
270
- documentId: string;
271
- [key: string]: any;
272
- };
273
- }
274
- /** Index document request */
275
- export interface IndexDocumentRequest {
276
- productId: string;
277
- text?: string;
278
- documentUrl?: string;
279
- metadata?: Record<string, any>;
280
- chunkSize?: number;
281
- overlap?: number;
282
- provider?: 'openai' | 'gemini';
283
- }
284
- /** Index document response */
285
- export interface IndexDocumentResponse {
286
- success: boolean;
287
- productId: string;
288
- documentId: string;
289
- chunks: number;
290
- metadata: {
291
- textLength: number;
292
- chunkSize: number;
293
- overlap: number;
294
- embeddingDimensions: number;
295
- };
296
- sample?: {
297
- text: string;
298
- chunkIndex: number;
299
- };
300
- }
301
- /** Configure assistant request */
302
- export interface ConfigureAssistantRequest {
303
- productId: string;
304
- systemPrompt?: string;
305
- model?: string;
306
- maxTokensPerResponse?: number;
307
- temperature?: number;
308
- rateLimitPerUser?: number;
309
- allowedTopics?: string[];
310
- customInstructions?: {
311
- tone?: string;
312
- additionalRules?: string;
313
- [key: string]: any;
314
- };
315
- }
316
- /** Configure assistant response */
317
- export interface ConfigureAssistantResponse {
318
- success: boolean;
319
- configuration: {
320
- productId: string;
321
- systemPrompt: string;
322
- model: string;
323
- maxTokensPerResponse: number;
324
- temperature: number;
325
- rateLimitPerUser: number;
326
- allowedTopics: string[];
327
- customInstructions?: Record<string, any>;
328
- updatedAt: string;
329
- };
330
- }
331
- /** Public chat request */
332
- export interface PublicChatRequest {
333
- productId: string;
334
- userId: string;
335
- message: string;
336
- sessionId?: string;
337
- stream?: boolean;
338
- }
339
- /** Public chat response */
340
- export interface PublicChatResponse {
341
- message: string;
342
- sessionId: string;
343
- usage: {
344
- prompt_tokens: number;
345
- completion_tokens: number;
346
- total_tokens: number;
347
- };
348
- context?: {
349
- chunksUsed: number;
350
- topSimilarity: number;
351
- };
352
- }
353
264
  /** Session information */
354
265
  export interface Session {
355
266
  sessionId: string;
@@ -843,9 +754,9 @@ export interface CatalogResponse {
843
754
  skills: SkillDescriptor[];
844
755
  }
845
756
  /** Capability tags a tool requires; scope a run with `allowCapabilities`. */
846
- export type AiToolCapability = 'web:read' | 'ai:vision' | 'ai:image' | 'ai:text' | 'media:image' | 'media:pdf' | 'net:http';
757
+ export type AiToolCapability = 'web:read' | 'ai:vision' | 'ai:image' | 'ai:text' | 'media:image' | 'media:pdf' | 'net:http' | 'knowledge:read';
847
758
  /** The names of the built-in server-side agent tools (run via `server_tools`). */
848
- export type AiToolName = 'web.fetchPage' | 'web.extractSchema' | 'web.screenshot' | 'web.search' | 'brand.assets' | 'document.read' | 'data.extract' | 'image.describe' | 'image.generate' | 'image.fromReference' | 'image.searchStock' | 'image.transform' | 'image.ocr' | 'pdf.create' | 'pdf.fill' | 'pdf.merge' | 'pdf.inspect' | 'pdf.render' | 'pdf.extract' | 'pdf.decodeBarcodes' | 'pdf.inspectGraphics' | 'pdf.edit' | 'pdf.preflight' | 'pdf.printReady' | 'http.request' | 'translate';
759
+ export type AiToolName = 'web.fetchPage' | 'web.extractSchema' | 'web.screenshot' | 'web.search' | 'brand.assets' | 'document.read' | 'data.extract' | 'image.describe' | 'image.generate' | 'image.fromReference' | 'image.searchStock' | 'image.transform' | 'image.ocr' | 'pdf.create' | 'pdf.fill' | 'pdf.merge' | 'pdf.inspect' | 'pdf.render' | 'pdf.extract' | 'pdf.decodeBarcodes' | 'pdf.inspectGraphics' | 'pdf.edit' | 'pdf.preflight' | 'pdf.printReady' | 'http.request' | 'translate' | 'knowledge.search';
849
760
  export interface WebFetchPageArgs {
850
761
  url: string;
851
762
  type?: string;
@@ -1131,6 +1042,12 @@ export interface HttpRequestArgs {
1131
1042
  headers?: Record<string, string>;
1132
1043
  body?: any;
1133
1044
  }
1045
+ export interface KnowledgeSearchArgs {
1046
+ query: string;
1047
+ sets?: string[];
1048
+ filters?: Record<string, any>;
1049
+ k?: number;
1050
+ }
1134
1051
  export interface TranslateArgs {
1135
1052
  text: string;
1136
1053
  targetLanguages: string[];
@@ -1164,6 +1081,7 @@ export interface AiToolArgsMap {
1164
1081
  'pdf.printReady': PdfPrintReadyArgs;
1165
1082
  'http.request': HttpRequestArgs;
1166
1083
  'translate': TranslateArgs;
1084
+ 'knowledge.search': KnowledgeSearchArgs;
1167
1085
  }
1168
1086
  export interface WebSearchResultItem {
1169
1087
  url: string | null;
@@ -98,6 +98,18 @@ export interface Asset {
98
98
  /** Upload token used for public uploads */
99
99
  uploadTokenId: string | null;
100
100
  uploaderIp: string | null;
101
+ /** `temporary` files are removed at `expiresAt` and stay out of asset lists. Default `permanent`. */
102
+ retention?: 'permanent' | 'temporary';
103
+ /** When a temporary file goes. */
104
+ expiresAt?: string | null;
105
+ /** Where it came from: uploaded, fetched from an address, extracted from another file, or made by something. */
106
+ origin?: 'upload' | 'fetched' | 'derived' | 'generated';
107
+ /** What it is a copy or extract of (an address key, or `<fileId>:<variant>:<version>`). */
108
+ sourceKey?: string | null;
109
+ /** The file this was extracted from. */
110
+ derivedFromId?: string | null;
111
+ /** How it was extracted: `text`, `markdown`, `ocr`, `json`. */
112
+ variant?: string | null;
101
113
  status: 'active' | 'pending_review' | 'deleted';
102
114
  createdAt: string;
103
115
  updatedAt: string;
@@ -239,6 +251,11 @@ export interface AdminListAssetsOptions {
239
251
  order?: 'asc' | 'desc';
240
252
  limit?: number;
241
253
  offset?: number;
254
+ /**
255
+ * Also list files that are normally left out: `temporary` (not kept yet) and `derived` (text, Markdown or fields
256
+ * extracted from another file). Lists show only what people put there unless asked.
257
+ */
258
+ include?: Array<'temporary' | 'derived'>;
242
259
  }
243
260
  export interface AdminListAssetsResponse {
244
261
  data: Asset[];
@@ -0,0 +1,78 @@
1
+ import type { Asset } from "./asset.js";
2
+ /**
3
+ * A file: an asset that's temporary, fetched from an address, extracted from another file, or made by something.
4
+ * Files are private until kept, and stay out of asset lists (pickers, the Hub, the portal) unless kept.
5
+ */
6
+ export type FileRecord = Asset;
7
+ /** How long a file lives: `1h` to `30d` (default `1d`). Kept files are permanent (see `files.keep`). */
8
+ export type FileTtl = `${number}h` | `${number}d` | number;
9
+ export type FileExtractVariant = "text" | "markdown" | "ocr" | "json";
10
+ export interface PutFileRequest {
11
+ name: string;
12
+ /** One of text, base64 or json. */
13
+ text?: string;
14
+ base64?: string;
15
+ json?: unknown;
16
+ contentType?: string;
17
+ ttl?: FileTtl;
18
+ appId?: string;
19
+ }
20
+ export interface FetchFileRequest {
21
+ /** A public web address (http/https). Private and internal addresses are refused. */
22
+ url: string;
23
+ ttl?: FileTtl;
24
+ /** How old a cached copy can be before the source is asked again (default: the ttl). */
25
+ maxAge?: FileTtl;
26
+ /** Ask the source again now (an unchanged page keeps the same file). */
27
+ force?: boolean;
28
+ appId?: string;
29
+ }
30
+ export interface FetchedFile extends FileRecord {
31
+ /** True when this address was already here and fresh enough, or the source said it hasn't changed. */
32
+ cached: boolean;
33
+ /** True when the source answered "not changed" (the same file is returned). */
34
+ unchanged?: boolean;
35
+ }
36
+ export interface ListFilesQuery {
37
+ origin?: "upload" | "fetched" | "derived" | "generated";
38
+ retention?: "temporary" | "permanent";
39
+ appId?: string;
40
+ /** The results extracted from one file. */
41
+ derivedFromId?: string;
42
+ limit?: number;
43
+ }
44
+ export interface ExtractFileRequest {
45
+ variant: FileExtractVariant;
46
+ /** For `json`: a JSON schema of the fields to pull out. */
47
+ schema?: Record<string, any>;
48
+ /** For `json`: what to look for, in words. */
49
+ prompt?: string;
50
+ /** Read the file again even if it was already read this way. */
51
+ force?: boolean;
52
+ }
53
+ export interface ExtractFileResponse {
54
+ ok: true;
55
+ /** The derived file holding the result (hidden from lists; lives as long as its source). */
56
+ file: FileRecord;
57
+ /** text / markdown / ocr */
58
+ text?: string;
59
+ /** json */
60
+ data?: any;
61
+ /** True when this file had already been read this way. */
62
+ cached: boolean;
63
+ }
64
+ export interface ReadFileResponse {
65
+ ok: true;
66
+ text?: string;
67
+ base64?: string;
68
+ contentType: string | null;
69
+ size: number;
70
+ }
71
+ export interface FileLinkResponse {
72
+ ok: true;
73
+ url: string;
74
+ /** When the signed link stops working (private files). */
75
+ expiresAt?: string;
76
+ /** True for a kept file: `url` is its permanent address. */
77
+ permanent?: boolean;
78
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -53,3 +53,5 @@ export * from "./headless.js";
53
53
  export * from "./appOptions.js";
54
54
  export * from "./clientLog.js";
55
55
  export * from "./wallet.js";
56
+ export * from "./files.js";
57
+ export * from "./knowledge.js";
@@ -55,3 +55,5 @@ export * from "./headless.js";
55
55
  export * from "./appOptions.js";
56
56
  export * from "./clientLog.js";
57
57
  export * from "./wallet.js";
58
+ export * from "./files.js";
59
+ export * from "./knowledge.js";
@@ -0,0 +1,120 @@
1
+ /** Who may search a set: anyone, signed-in people, or the business's own staff and assistants. */
2
+ export type KnowledgeVisibility = 'public' | 'customer' | 'staff';
3
+ /** Where a set's passages come from. */
4
+ export type KnowledgeSourceKind =
5
+ /** A Markdown bundle: documents separated by `---`, each with a `Source: <url>` line (the llms-full format). */
6
+ 'markdown_feed'
7
+ /** One web page or document at an address. */
8
+ | 'url'
9
+ /** Documents an app pushes itself with `knowledge.upsertDocuments`. */
10
+ | 'documents';
11
+ export interface KnowledgeSet {
12
+ id: string;
13
+ /** Lower-case key, unique in the collection: "docs", "manuals". */
14
+ key: string;
15
+ name: string;
16
+ description: string | null;
17
+ visibility: KnowledgeVisibility;
18
+ /** The app that declared the set, if any. */
19
+ ownerAppId: string | null;
20
+ /** The embedding model its passages were embedded with (null until embedded). */
21
+ embedModel: string | null;
22
+ createdAt: string;
23
+ updatedAt: string;
24
+ /** On list: how many sources and passages it has. */
25
+ sourceCount?: number;
26
+ passageCount?: number;
27
+ }
28
+ export interface SaveKnowledgeSetRequest {
29
+ key: string;
30
+ name: string;
31
+ description?: string | null;
32
+ /** Default `staff`. */
33
+ visibility?: KnowledgeVisibility;
34
+ }
35
+ export interface UpdateKnowledgeSetRequest {
36
+ name?: string;
37
+ description?: string | null;
38
+ visibility?: KnowledgeVisibility;
39
+ }
40
+ export interface KnowledgeSource {
41
+ id: string;
42
+ setId: string;
43
+ kind: KnowledgeSourceKind;
44
+ name: string | null;
45
+ /** `markdown_feed` and `url`: `{ url }` (https). */
46
+ config: Record<string, any>;
47
+ /** Re-read every this many hours (default 24 for feeds and pages; null = only when asked). */
48
+ refreshHours: number | null;
49
+ status: 'pending' | 'indexing' | 'ready' | 'failed';
50
+ /** Why the last read failed (the previous passages stay searchable meanwhile). */
51
+ error: string | null;
52
+ passageCount: number;
53
+ lastIndexedAt: string | null;
54
+ createdAt: string;
55
+ updatedAt: string;
56
+ }
57
+ export interface AddKnowledgeSourceRequest {
58
+ kind: KnowledgeSourceKind;
59
+ config?: {
60
+ url?: string;
61
+ [key: string]: any;
62
+ };
63
+ name?: string;
64
+ refreshHours?: number | null;
65
+ }
66
+ export interface UpdateKnowledgeSourceRequest {
67
+ config?: {
68
+ url?: string;
69
+ [key: string]: any;
70
+ };
71
+ name?: string;
72
+ refreshHours?: number | null;
73
+ }
74
+ /** A document an app pushes into a `documents` source. Re-pushing the same `ref` replaces it. */
75
+ export interface KnowledgeDocument {
76
+ ref: string;
77
+ title: string;
78
+ /** Markdown. Split into passages along its headings. */
79
+ body: string;
80
+ /** The link to show with an answer. */
81
+ url?: string;
82
+ /** Details to filter searches on, e.g. `{ productId: 'p1' }`. */
83
+ meta?: Record<string, any>;
84
+ }
85
+ export interface KnowledgeSearchRequest {
86
+ query: string;
87
+ /** Only these sets (ids or keys). Default: every set the caller may read. */
88
+ sets?: string[];
89
+ /** Exact matches on a passage's details, e.g. `{ productId: 'p1' }`. */
90
+ filters?: Record<string, any>;
91
+ /** How many results (default 8, at most 25). */
92
+ k?: number;
93
+ }
94
+ export interface KnowledgeSearchResult {
95
+ id: string;
96
+ /** The document it came from. */
97
+ title: string;
98
+ /** Its section: "Settings › Email footer". */
99
+ heading: string | null;
100
+ /** A link to the section. */
101
+ url: string | null;
102
+ /** A short piece around the match, for a results list. */
103
+ snippet: string;
104
+ /** The whole passage, for an AI to read. */
105
+ text: string;
106
+ score: number;
107
+ set: {
108
+ id: string;
109
+ key: string;
110
+ name: string;
111
+ };
112
+ sourceId: string;
113
+ meta: Record<string, any>;
114
+ }
115
+ export interface KnowledgeSearchResponse {
116
+ query: string;
117
+ results: KnowledgeSearchResult[];
118
+ /** `hybrid` (meaning + keywords), `keywords` (where vectors aren't available) or `none` (no sets to search). */
119
+ mode: 'hybrid' | 'keywords' | 'none';
120
+ }
@@ -0,0 +1,2 @@
1
+ // Knowledge search: a collection's AI-searchable content (prove docs/design/knowledge-search.md).
2
+ export {};