@proteos/sdk 0.18.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.
- package/LICENSE +40 -0
- package/dist/chunk-7RGN4E22.cjs +1185 -0
- package/dist/chunk-7RGN4E22.cjs.map +1 -0
- package/dist/chunk-XJP5WCRZ.js +1125 -0
- package/dist/chunk-XJP5WCRZ.js.map +1 -0
- package/dist/index.cjs +2384 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +5225 -0
- package/dist/index.d.ts +5225 -0
- package/dist/index.js +2146 -0
- package/dist/index.js.map +1 -0
- package/dist/meta/index.cjs +204 -0
- package/dist/meta/index.cjs.map +1 -0
- package/dist/meta/index.d.cts +2 -0
- package/dist/meta/index.d.ts +2 -0
- package/dist/meta/index.js +3 -0
- package/dist/meta/index.js.map +1 -0
- package/dist/types-BNsjfU8N.d.cts +3299 -0
- package/dist/types-BNsjfU8N.d.ts +3299 -0
- package/package.json +86 -0
- package/src/agent/agents.ts +53 -0
- package/src/agent/index.ts +134 -0
- package/src/agent/mcp-servers.ts +102 -0
- package/src/agent/prompts.ts +80 -0
- package/src/agent/session-types.ts +397 -0
- package/src/agent/sessions.ts +197 -0
- package/src/agent/skills.ts +89 -0
- package/src/agent/tools.ts +53 -0
- package/src/agent/types.ts +362 -0
- package/src/auth/index.ts +111 -0
- package/src/auth/me.ts +46 -0
- package/src/auth/organizations.ts +128 -0
- package/src/auth/platform-entities.ts +78 -0
- package/src/auth/roles.ts +213 -0
- package/src/auth/types.ts +294 -0
- package/src/auth/users.ts +226 -0
- package/src/client.ts +441 -0
- package/src/connector/index.ts +120 -0
- package/src/connector/types.ts +150 -0
- package/src/conversation/index.ts +297 -0
- package/src/conversation/types.ts +590 -0
- package/src/conversation/voice.ts +123 -0
- package/src/data/index.ts +53 -0
- package/src/data/queries.ts +66 -0
- package/src/data/records.ts +122 -0
- package/src/data/types.ts +89 -0
- package/src/errors.ts +148 -0
- package/src/events/index.ts +172 -0
- package/src/events/types.ts +77 -0
- package/src/functions/actions.ts +95 -0
- package/src/functions/index.ts +32 -0
- package/src/functions/types.ts +71 -0
- package/src/http/index.ts +2 -0
- package/src/http/query-params.ts +106 -0
- package/src/index.ts +598 -0
- package/src/iterator.ts +183 -0
- package/src/knowledge/graph.ts +35 -0
- package/src/knowledge/index.ts +104 -0
- package/src/knowledge/labels.ts +70 -0
- package/src/knowledge/links.ts +65 -0
- package/src/knowledge/nodes.ts +198 -0
- package/src/knowledge/record-links.ts +66 -0
- package/src/knowledge/types.ts +569 -0
- package/src/meta/apps.ts +107 -0
- package/src/meta/components.ts +124 -0
- package/src/meta/currency/index.ts +202 -0
- package/src/meta/entities.ts +193 -0
- package/src/meta/filters.ts +76 -0
- package/src/meta/index.ts +227 -0
- package/src/meta/layout/common-props.ts +93 -0
- package/src/meta/layout/control-registry.json +70 -0
- package/src/meta/layout/control-registry.ts +92 -0
- package/src/meta/layout/elements.ts +203 -0
- package/src/meta/layout/index.ts +41 -0
- package/src/meta/layout/page-layout.ts +35 -0
- package/src/meta/layout/size-value.ts +27 -0
- package/src/meta/list-views.ts +109 -0
- package/src/meta/lists.ts +104 -0
- package/src/meta/menu-configurations.ts +128 -0
- package/src/meta/modules.ts +159 -0
- package/src/meta/pages.ts +106 -0
- package/src/meta/types.ts +1115 -0
- package/src/meta/variables.ts +98 -0
- package/src/storage/files.ts +183 -0
- package/src/storage/index.ts +33 -0
- package/src/storage/types.ts +70 -0
- package/src/types/common.ts +143 -0
- package/src/types/index.ts +28 -0
- package/src/types/options.ts +95 -0
- package/src/workflow/executions.ts +99 -0
- package/src/workflow/index.ts +109 -0
- package/src/workflow/node-types.ts +50 -0
- package/src/workflow/types.ts +658 -0
- package/src/workflow/workflows.ts +152 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ProteosClient } from '../client.js'
|
|
2
|
+
import { PageIterator } from '../iterator.js'
|
|
3
|
+
import type { ListResult } from '../types/common.js'
|
|
4
|
+
import type {
|
|
5
|
+
CreateRecordLinkRequest,
|
|
6
|
+
KnowledgeRecordLink,
|
|
7
|
+
ListRecordLinksOptions,
|
|
8
|
+
} from './types.js'
|
|
9
|
+
|
|
10
|
+
const RECORD_LINKS_BASE_PATH = '/knowledge/v1/record-links'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Service for node→record edges: links from a knowledge node to a business
|
|
14
|
+
* record (data-service, identified by `entity_slug` + `record_id`). Immutable —
|
|
15
|
+
* create / delete only, no update. Filter by `node_id` (a node's records) or by
|
|
16
|
+
* `entity_slug` + `record_id` (a record's nodes).
|
|
17
|
+
*/
|
|
18
|
+
export interface RecordLinkService {
|
|
19
|
+
/** Lists record links as an async iterator (pages are 0-indexed). */
|
|
20
|
+
list(options?: ListRecordLinksOptions): PageIterator<KnowledgeRecordLink, ListRecordLinksOptions>
|
|
21
|
+
|
|
22
|
+
/** Fetches a single page of record links. */
|
|
23
|
+
listPage(options?: ListRecordLinksOptions): Promise<ListResult<KnowledgeRecordLink>>
|
|
24
|
+
|
|
25
|
+
/** Gets a single record link by id. */
|
|
26
|
+
get(id: string): Promise<KnowledgeRecordLink>
|
|
27
|
+
|
|
28
|
+
/** Links a node to a business record. */
|
|
29
|
+
create(request: CreateRecordLinkRequest): Promise<KnowledgeRecordLink>
|
|
30
|
+
|
|
31
|
+
/** Removes a record link. */
|
|
32
|
+
delete(id: string): Promise<void>
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Implementation of RecordLinkService.
|
|
37
|
+
*/
|
|
38
|
+
export class RecordLinkServiceImpl implements RecordLinkService {
|
|
39
|
+
constructor(private readonly client: ProteosClient) {}
|
|
40
|
+
|
|
41
|
+
list(
|
|
42
|
+
options: ListRecordLinksOptions = {},
|
|
43
|
+
): PageIterator<KnowledgeRecordLink, ListRecordLinksOptions> {
|
|
44
|
+
return new PageIterator((opts) => this.listPage(opts), options)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async listPage(options: ListRecordLinksOptions = {}): Promise<ListResult<KnowledgeRecordLink>> {
|
|
48
|
+
return this.client.requestWithQuery<ListResult<KnowledgeRecordLink>>(
|
|
49
|
+
'GET',
|
|
50
|
+
RECORD_LINKS_BASE_PATH,
|
|
51
|
+
options,
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async get(id: string): Promise<KnowledgeRecordLink> {
|
|
56
|
+
return this.client.request<KnowledgeRecordLink>('GET', `${RECORD_LINKS_BASE_PATH}/${id}`)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async create(request: CreateRecordLinkRequest): Promise<KnowledgeRecordLink> {
|
|
60
|
+
return this.client.request<KnowledgeRecordLink>('POST', RECORD_LINKS_BASE_PATH, request)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async delete(id: string): Promise<void> {
|
|
64
|
+
await this.client.request<void>('DELETE', `${RECORD_LINKS_BASE_PATH}/${id}`)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import {
|
|
3
|
+
type AuditFields,
|
|
4
|
+
AuditFieldsSchema,
|
|
5
|
+
type ListOptions,
|
|
6
|
+
type UserRef,
|
|
7
|
+
UserRefSchema,
|
|
8
|
+
} from '../types/common.js'
|
|
9
|
+
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Enums
|
|
12
|
+
// ============================================================================
|
|
13
|
+
|
|
14
|
+
/** A node's kind. `markdown` is authored; `file`/`url` bodies are derived. */
|
|
15
|
+
export type NodeType = 'markdown' | 'file' | 'url'
|
|
16
|
+
|
|
17
|
+
/** Lifecycle state of a node. */
|
|
18
|
+
export type NodeStatus = 'draft' | 'published' | 'archived'
|
|
19
|
+
|
|
20
|
+
/** Typed edge kinds in the knowledge graph. */
|
|
21
|
+
export type LinkType =
|
|
22
|
+
| 'references'
|
|
23
|
+
| 'relates_to'
|
|
24
|
+
| 'depends_on'
|
|
25
|
+
| 'part_of'
|
|
26
|
+
| 'derived_from'
|
|
27
|
+
| 'contradicts'
|
|
28
|
+
| 'supports'
|
|
29
|
+
| 'duplicates'
|
|
30
|
+
| 'superseded_by'
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Retrieval mode for `nodes.search`. Only `keyword` is wired today; `semantic`
|
|
34
|
+
* and `hybrid` are reserved (the server returns 501 until embeddings land).
|
|
35
|
+
*/
|
|
36
|
+
export type MatchMode = 'hybrid' | 'semantic' | 'keyword'
|
|
37
|
+
|
|
38
|
+
/** Traversal direction for `nodes.neighbors`. */
|
|
39
|
+
export type NeighborDirection = 'out' | 'in' | 'both'
|
|
40
|
+
|
|
41
|
+
// ============================================================================
|
|
42
|
+
// Entity Types
|
|
43
|
+
// ============================================================================
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A node's metadata — everything except the (potentially huge) `content` body
|
|
47
|
+
* and the derived embedding vector. This is what list / get / search / neighbors
|
|
48
|
+
* return by default.
|
|
49
|
+
*/
|
|
50
|
+
export interface KnowledgeNodeMetadata extends AuditFields {
|
|
51
|
+
id: string
|
|
52
|
+
org_id: string
|
|
53
|
+
title: string
|
|
54
|
+
type: NodeType
|
|
55
|
+
status: NodeStatus
|
|
56
|
+
/** Embedding provenance (null until ingestion runs). */
|
|
57
|
+
embedding_model?: string | null
|
|
58
|
+
embedded_at?: string | null
|
|
59
|
+
/** Source pointer for `file` nodes (storage-service file id). */
|
|
60
|
+
file_id?: string | null
|
|
61
|
+
/** Source pointer for `url` nodes. */
|
|
62
|
+
url?: string | null
|
|
63
|
+
summary?: string | null
|
|
64
|
+
/**
|
|
65
|
+
* Temporal validity window (RFC3339), decoupled from `created_at`. `valid_from`
|
|
66
|
+
* is when the asserted fact starts being true, `valid_until` when it stops.
|
|
67
|
+
* Either null = unbounded on that side (both null = always valid). Half-open
|
|
68
|
+
* `[valid_from, valid_until)`.
|
|
69
|
+
*/
|
|
70
|
+
valid_from?: string | null
|
|
71
|
+
valid_until?: string | null
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** A full node: its metadata plus the markdown `content` body. */
|
|
75
|
+
export interface KnowledgeNode extends KnowledgeNodeMetadata {
|
|
76
|
+
content: string
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** A node returned by search, with its relevance `score`. */
|
|
80
|
+
export interface KnowledgeNodeSearchResult extends KnowledgeNodeMetadata {
|
|
81
|
+
score: number
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** A typed, directed edge between two nodes. */
|
|
85
|
+
export interface KnowledgeLink extends AuditFields {
|
|
86
|
+
id: string
|
|
87
|
+
org_id: string
|
|
88
|
+
from_id: string
|
|
89
|
+
to_id: string
|
|
90
|
+
type: LinkType
|
|
91
|
+
description?: string | null
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* A directed edge from a knowledge node to a business record (data-service,
|
|
96
|
+
* identified by `entity_slug` + `record_id`). Immutable once created — only
|
|
97
|
+
* `created_*` audit fields, no update path — so it does NOT extend AuditFields
|
|
98
|
+
* (which carries `updated_*`).
|
|
99
|
+
*/
|
|
100
|
+
export interface KnowledgeRecordLink {
|
|
101
|
+
id: string
|
|
102
|
+
org_id: string
|
|
103
|
+
node_id: string
|
|
104
|
+
entity_slug: string
|
|
105
|
+
record_id: string
|
|
106
|
+
created_at: string
|
|
107
|
+
created_by: UserRef
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** A categorization handle. `slug` is unique within an org. */
|
|
111
|
+
export interface KnowledgeLabel extends AuditFields {
|
|
112
|
+
id: string
|
|
113
|
+
org_id: string
|
|
114
|
+
name: string
|
|
115
|
+
slug: string
|
|
116
|
+
description?: string | null
|
|
117
|
+
color?: string | null
|
|
118
|
+
icon?: string | null
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** The node↔label association row. */
|
|
122
|
+
export interface KnowledgeNodeLabel {
|
|
123
|
+
org_id: string
|
|
124
|
+
node_id: string
|
|
125
|
+
label_id: string
|
|
126
|
+
created_at: string
|
|
127
|
+
created_by: UserRef
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// ============================================================================
|
|
131
|
+
// Node requests
|
|
132
|
+
// ============================================================================
|
|
133
|
+
|
|
134
|
+
/** A typed edge from a node being created to an existing node (create-and-connect). */
|
|
135
|
+
export interface InlineLinkRequest {
|
|
136
|
+
to_id: string
|
|
137
|
+
type: LinkType
|
|
138
|
+
description?: string
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Create a node, optionally connecting it to the graph in one call. `label_ids`
|
|
143
|
+
* attaches existing labels; `links` creates edges FROM the new node. Both are
|
|
144
|
+
* applied atomically with the node insert.
|
|
145
|
+
*/
|
|
146
|
+
export interface CreateNodeRequest {
|
|
147
|
+
title: string
|
|
148
|
+
type: NodeType
|
|
149
|
+
status: NodeStatus
|
|
150
|
+
content?: string
|
|
151
|
+
file_id?: string
|
|
152
|
+
url?: string
|
|
153
|
+
summary?: string
|
|
154
|
+
/** Validity window (RFC3339). Omitted = unbounded (NULL). */
|
|
155
|
+
valid_from?: string
|
|
156
|
+
valid_until?: string
|
|
157
|
+
label_ids?: string[]
|
|
158
|
+
links?: InlineLinkRequest[]
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Partial metadata update. Content is updated via the content methods, not here. */
|
|
162
|
+
export interface UpdateNodeRequest {
|
|
163
|
+
title?: string
|
|
164
|
+
status?: NodeStatus
|
|
165
|
+
summary?: string
|
|
166
|
+
/**
|
|
167
|
+
* Validity window (RFC3339), tri-state: omit the key to leave unchanged, pass
|
|
168
|
+
* `null` to clear it back to unbounded (re-open validity), or a timestamp to
|
|
169
|
+
* set it. Setting `valid_until` to an instant ends a fact's validity.
|
|
170
|
+
*/
|
|
171
|
+
valid_from?: string | null
|
|
172
|
+
valid_until?: string | null
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Filters for listing nodes. */
|
|
176
|
+
export interface ListNodesOptions extends ListOptions {
|
|
177
|
+
type?: NodeType
|
|
178
|
+
status?: NodeStatus
|
|
179
|
+
title?: string
|
|
180
|
+
'title[contains]'?: string
|
|
181
|
+
/** Keep only nodes carrying ANY of these labels (union). */
|
|
182
|
+
label_ids?: string[]
|
|
183
|
+
/** Created on/after this RFC3339 timestamp (inclusive). */
|
|
184
|
+
created_after?: string
|
|
185
|
+
/** Created on/before this RFC3339 timestamp (inclusive). */
|
|
186
|
+
created_before?: string
|
|
187
|
+
/** Updated on/after this RFC3339 timestamp (inclusive). */
|
|
188
|
+
updated_after?: string
|
|
189
|
+
/** Updated on/before this RFC3339 timestamp (inclusive). */
|
|
190
|
+
updated_before?: string
|
|
191
|
+
/** Validity boundary range filters (RFC3339) — filter on where a node's window start/end falls. */
|
|
192
|
+
valid_from_after?: string
|
|
193
|
+
valid_from_before?: string
|
|
194
|
+
valid_until_after?: string
|
|
195
|
+
valid_until_before?: string
|
|
196
|
+
/**
|
|
197
|
+
* Point-in-time validity filter (RFC3339): keep only nodes valid AT this
|
|
198
|
+
* instant (null-aware, half-open). Set `is_valid: false` to invert it (nodes
|
|
199
|
+
* INVALID at the instant). `is_valid` defaults to true.
|
|
200
|
+
*/
|
|
201
|
+
is_valid_at?: string
|
|
202
|
+
is_valid?: boolean
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// ── Content sub-resource ────────────────────────────────────────────────
|
|
206
|
+
|
|
207
|
+
/** A node's raw body plus its line count. */
|
|
208
|
+
export interface ContentResponse {
|
|
209
|
+
id: string
|
|
210
|
+
content: string
|
|
211
|
+
lines_total: number
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface WriteContentResponse {
|
|
215
|
+
id: string
|
|
216
|
+
lines_total: number
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** A surgical anchored edit (mirrors Claude Code's `Edit`). */
|
|
220
|
+
export interface EditContentRequest {
|
|
221
|
+
old_string: string
|
|
222
|
+
new_string: string
|
|
223
|
+
replace_all?: boolean
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface EditContentResponse {
|
|
227
|
+
id: string
|
|
228
|
+
replacements: number
|
|
229
|
+
lines_total: number
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// ── Within-node navigation: outline & grep ─────────────────────────────────
|
|
233
|
+
|
|
234
|
+
/** One markdown heading in a node's outline, with the line range of its section. */
|
|
235
|
+
export interface OutlineHeading {
|
|
236
|
+
level: number
|
|
237
|
+
title: string
|
|
238
|
+
line_start: number
|
|
239
|
+
line_end: number
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** One node's structural map. `headings` is empty for a body with no headings. */
|
|
243
|
+
export interface NodeOutline {
|
|
244
|
+
node_id: string
|
|
245
|
+
title: string
|
|
246
|
+
lines_total: number
|
|
247
|
+
headings: OutlineHeading[]
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** Outline one or several nodes' bodies in a single call. */
|
|
251
|
+
export interface OutlineRequest {
|
|
252
|
+
node_ids: string[]
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export interface OutlineResponse {
|
|
256
|
+
results: NodeOutline[]
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** One grep hit: the matching line, the snippet's line range, and the cat -n snippet. */
|
|
260
|
+
export interface ContentMatch {
|
|
261
|
+
line: number
|
|
262
|
+
line_start: number
|
|
263
|
+
line_end: number
|
|
264
|
+
snippet: string
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** One node's grep result. `match_count` is the true total; `matches` is capped. */
|
|
268
|
+
export interface NodeContentMatches {
|
|
269
|
+
node_id: string
|
|
270
|
+
title: string
|
|
271
|
+
lines_total: number
|
|
272
|
+
match_count: number
|
|
273
|
+
truncated: boolean
|
|
274
|
+
matches: ContentMatch[]
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** Grep one or several node bodies. Substring by default; set `is_regex` for a regex. */
|
|
278
|
+
export interface SearchContentRequest {
|
|
279
|
+
node_ids: string[]
|
|
280
|
+
pattern: string
|
|
281
|
+
is_regex?: boolean
|
|
282
|
+
is_case_sensitive?: boolean
|
|
283
|
+
context_lines?: number
|
|
284
|
+
max_matches_per_node?: number
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export interface SearchContentResponse {
|
|
288
|
+
results: NodeContentMatches[]
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// ── Search ───────────────────────────────────────────────────────────────
|
|
292
|
+
|
|
293
|
+
/** Hybrid retrieval request. `match_mode` defaults to `keyword`. */
|
|
294
|
+
export interface SearchNodesRequest {
|
|
295
|
+
query: string
|
|
296
|
+
match_mode?: MatchMode
|
|
297
|
+
type?: NodeType
|
|
298
|
+
status?: NodeStatus
|
|
299
|
+
/** Match nodes carrying ANY of these labels. */
|
|
300
|
+
label_ids?: string[]
|
|
301
|
+
/** Match nodes connected (either direction) to this node. */
|
|
302
|
+
linked_to_id?: string
|
|
303
|
+
/**
|
|
304
|
+
* Date-range filters (RFC3339). These only narrow the candidate set; results
|
|
305
|
+
* stay relevance-ordered, so a date filter never reorders hits.
|
|
306
|
+
*/
|
|
307
|
+
created_after?: string
|
|
308
|
+
created_before?: string
|
|
309
|
+
updated_after?: string
|
|
310
|
+
updated_before?: string
|
|
311
|
+
/**
|
|
312
|
+
* Point-in-time validity filter (RFC3339): restrict hits to nodes valid AT
|
|
313
|
+
* this instant (or INVALID when `is_valid` is false; defaults to true). Narrows
|
|
314
|
+
* the candidate set only — ordering stays relevance-based.
|
|
315
|
+
*/
|
|
316
|
+
is_valid_at?: string
|
|
317
|
+
is_valid?: boolean
|
|
318
|
+
page?: number
|
|
319
|
+
page_size?: number
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// ── Neighbors ──────────────────────────────────────────────────────────────
|
|
323
|
+
|
|
324
|
+
/** Options for a neighbors graph walk. */
|
|
325
|
+
export interface NeighborsOptions {
|
|
326
|
+
direction?: NeighborDirection
|
|
327
|
+
/** Comma-separated link types to follow (e.g. "part_of,depends_on"). */
|
|
328
|
+
link_types?: string
|
|
329
|
+
depth?: number
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export interface NeighborNode {
|
|
333
|
+
id: string
|
|
334
|
+
title: string
|
|
335
|
+
type: NodeType
|
|
336
|
+
status: NodeStatus
|
|
337
|
+
distance: number
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export interface NeighborEdge {
|
|
341
|
+
id: string
|
|
342
|
+
from_id: string
|
|
343
|
+
to_id: string
|
|
344
|
+
type: LinkType
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export interface NodeNeighborhood {
|
|
348
|
+
nodes: NeighborNode[]
|
|
349
|
+
edges: NeighborEdge[]
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// ============================================================================
|
|
353
|
+
// Graph (whole-org bulk read for the radiant graph view)
|
|
354
|
+
// ============================================================================
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* A lean node in the whole-graph payload — only what the graph renderer needs.
|
|
358
|
+
* `label_ids` are ordered by attachment time, so `label_ids[0]` is the "first"
|
|
359
|
+
* label (the one the UI colours the node by). `degree` is the in+out link count
|
|
360
|
+
* within the returned graph (drives node size).
|
|
361
|
+
*/
|
|
362
|
+
export interface KnowledgeGraphNode {
|
|
363
|
+
id: string
|
|
364
|
+
title: string
|
|
365
|
+
type: NodeType
|
|
366
|
+
status: NodeStatus
|
|
367
|
+
label_ids: string[]
|
|
368
|
+
degree: number
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/** A lean directed edge in the whole-graph payload. */
|
|
372
|
+
export interface KnowledgeGraphLink {
|
|
373
|
+
id: string
|
|
374
|
+
from_id: string
|
|
375
|
+
to_id: string
|
|
376
|
+
type: LinkType
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* The whole org graph in one payload: lean nodes + links, the full org label set
|
|
381
|
+
* (sent once — colours every node and powers the filter bar even when the graph
|
|
382
|
+
* is pruned), and `total`, the unfiltered org node count (lets the client decide
|
|
383
|
+
* whether to load the whole graph or switch to progressive/LOD loading).
|
|
384
|
+
*/
|
|
385
|
+
export interface KnowledgeGraph {
|
|
386
|
+
nodes: KnowledgeGraphNode[]
|
|
387
|
+
links: KnowledgeGraphLink[]
|
|
388
|
+
labels: KnowledgeLabel[]
|
|
389
|
+
total: number
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Options for `getGraph`. `label_ids` prunes the graph to nodes carrying ANY of
|
|
394
|
+
* the given labels (union); omitted/empty returns the whole org graph.
|
|
395
|
+
*/
|
|
396
|
+
export interface GetGraphOptions {
|
|
397
|
+
label_ids?: string[]
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// ============================================================================
|
|
401
|
+
// Link requests
|
|
402
|
+
// ============================================================================
|
|
403
|
+
|
|
404
|
+
export interface CreateLinkRequest {
|
|
405
|
+
from_id: string
|
|
406
|
+
to_id: string
|
|
407
|
+
type: LinkType
|
|
408
|
+
description?: string
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
export interface UpdateLinkRequest {
|
|
412
|
+
type?: LinkType
|
|
413
|
+
description?: string
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
export interface ListLinksOptions extends ListOptions {
|
|
417
|
+
from_id?: string
|
|
418
|
+
to_id?: string
|
|
419
|
+
type?: LinkType
|
|
420
|
+
/** Created on/after this RFC3339 timestamp (inclusive). */
|
|
421
|
+
created_after?: string
|
|
422
|
+
/** Created on/before this RFC3339 timestamp (inclusive). */
|
|
423
|
+
created_before?: string
|
|
424
|
+
/** Updated on/after this RFC3339 timestamp (inclusive). */
|
|
425
|
+
updated_after?: string
|
|
426
|
+
/** Updated on/before this RFC3339 timestamp (inclusive). */
|
|
427
|
+
updated_before?: string
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// ============================================================================
|
|
431
|
+
// Record-link requests
|
|
432
|
+
// ============================================================================
|
|
433
|
+
|
|
434
|
+
export interface CreateRecordLinkRequest {
|
|
435
|
+
node_id: string
|
|
436
|
+
entity_slug: string
|
|
437
|
+
record_id: string
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
export interface ListRecordLinksOptions extends ListOptions {
|
|
441
|
+
node_id?: string
|
|
442
|
+
entity_slug?: string
|
|
443
|
+
record_id?: string
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// ============================================================================
|
|
447
|
+
// Label requests
|
|
448
|
+
// ============================================================================
|
|
449
|
+
|
|
450
|
+
export interface CreateLabelRequest {
|
|
451
|
+
name: string
|
|
452
|
+
slug: string
|
|
453
|
+
description?: string
|
|
454
|
+
color?: string
|
|
455
|
+
icon?: string
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
export interface UpdateLabelRequest {
|
|
459
|
+
name?: string
|
|
460
|
+
description?: string
|
|
461
|
+
color?: string
|
|
462
|
+
icon?: string
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
export interface ListLabelsOptions extends ListOptions {
|
|
466
|
+
slug?: string
|
|
467
|
+
name?: string
|
|
468
|
+
'name[contains]'?: string
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// ============================================================================
|
|
472
|
+
// Zod schemas (optional runtime validation for consumers who want it)
|
|
473
|
+
// ============================================================================
|
|
474
|
+
|
|
475
|
+
export const KnowledgeNodeMetadataSchema = z
|
|
476
|
+
.object({
|
|
477
|
+
id: z.string(),
|
|
478
|
+
org_id: z.string(),
|
|
479
|
+
title: z.string(),
|
|
480
|
+
type: z.enum(['markdown', 'file', 'url']),
|
|
481
|
+
status: z.enum(['draft', 'published', 'archived']),
|
|
482
|
+
embedding_model: z.string().nullish(),
|
|
483
|
+
embedded_at: z.string().nullish(),
|
|
484
|
+
file_id: z.string().nullish(),
|
|
485
|
+
url: z.string().nullish(),
|
|
486
|
+
summary: z.string().nullish(),
|
|
487
|
+
valid_from: z.string().nullish(),
|
|
488
|
+
valid_until: z.string().nullish(),
|
|
489
|
+
})
|
|
490
|
+
.merge(AuditFieldsSchema)
|
|
491
|
+
|
|
492
|
+
export const KnowledgeNodeSchema = KnowledgeNodeMetadataSchema.extend({
|
|
493
|
+
content: z.string(),
|
|
494
|
+
})
|
|
495
|
+
|
|
496
|
+
export const KnowledgeNodeSearchResultSchema = KnowledgeNodeMetadataSchema.extend({
|
|
497
|
+
score: z.number(),
|
|
498
|
+
})
|
|
499
|
+
|
|
500
|
+
export const KnowledgeLinkSchema = z
|
|
501
|
+
.object({
|
|
502
|
+
id: z.string(),
|
|
503
|
+
org_id: z.string(),
|
|
504
|
+
from_id: z.string(),
|
|
505
|
+
to_id: z.string(),
|
|
506
|
+
type: z.enum([
|
|
507
|
+
'references',
|
|
508
|
+
'relates_to',
|
|
509
|
+
'depends_on',
|
|
510
|
+
'part_of',
|
|
511
|
+
'derived_from',
|
|
512
|
+
'contradicts',
|
|
513
|
+
'supports',
|
|
514
|
+
'duplicates',
|
|
515
|
+
'superseded_by',
|
|
516
|
+
]),
|
|
517
|
+
description: z.string().nullish(),
|
|
518
|
+
})
|
|
519
|
+
.merge(AuditFieldsSchema)
|
|
520
|
+
|
|
521
|
+
export const KnowledgeRecordLinkSchema = z.object({
|
|
522
|
+
id: z.string(),
|
|
523
|
+
org_id: z.string(),
|
|
524
|
+
node_id: z.string(),
|
|
525
|
+
entity_slug: z.string(),
|
|
526
|
+
record_id: z.string(),
|
|
527
|
+
created_at: z.string(),
|
|
528
|
+
created_by: UserRefSchema,
|
|
529
|
+
})
|
|
530
|
+
|
|
531
|
+
export const KnowledgeLabelSchema = z
|
|
532
|
+
.object({
|
|
533
|
+
id: z.string(),
|
|
534
|
+
org_id: z.string(),
|
|
535
|
+
name: z.string(),
|
|
536
|
+
slug: z.string(),
|
|
537
|
+
description: z.string().nullish(),
|
|
538
|
+
color: z.string().nullish(),
|
|
539
|
+
icon: z.string().nullish(),
|
|
540
|
+
})
|
|
541
|
+
.merge(AuditFieldsSchema)
|
|
542
|
+
|
|
543
|
+
export const KnowledgeNodeLabelSchema = z.object({
|
|
544
|
+
org_id: z.string(),
|
|
545
|
+
node_id: z.string(),
|
|
546
|
+
label_id: z.string(),
|
|
547
|
+
created_at: z.string(),
|
|
548
|
+
created_by: UserRefSchema,
|
|
549
|
+
})
|
|
550
|
+
|
|
551
|
+
export const NodeNeighborhoodSchema = z.object({
|
|
552
|
+
nodes: z.array(
|
|
553
|
+
z.object({
|
|
554
|
+
id: z.string(),
|
|
555
|
+
title: z.string(),
|
|
556
|
+
type: z.enum(['markdown', 'file', 'url']),
|
|
557
|
+
status: z.enum(['draft', 'published', 'archived']),
|
|
558
|
+
distance: z.number(),
|
|
559
|
+
}),
|
|
560
|
+
),
|
|
561
|
+
edges: z.array(
|
|
562
|
+
z.object({
|
|
563
|
+
id: z.string(),
|
|
564
|
+
from_id: z.string(),
|
|
565
|
+
to_id: z.string(),
|
|
566
|
+
type: z.string(),
|
|
567
|
+
}),
|
|
568
|
+
),
|
|
569
|
+
})
|