@soulcraft/sdk 1.7.0 → 2.0.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/dist/client/create-client-sdk.d.ts +16 -2
- package/dist/client/create-client-sdk.d.ts.map +1 -1
- package/dist/client/create-client-sdk.js +2 -7
- package/dist/client/create-client-sdk.js.map +1 -1
- package/dist/client/index.d.ts +44 -37
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +59 -44
- package/dist/client/index.js.map +1 -1
- package/dist/client/namespace-proxy.d.ts +108 -0
- package/dist/client/namespace-proxy.d.ts.map +1 -0
- package/dist/client/namespace-proxy.js +151 -0
- package/dist/client/namespace-proxy.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/modules/app-context/index.d.ts +15 -15
- package/dist/modules/app-context/index.d.ts.map +1 -1
- package/dist/modules/app-context/index.js +17 -17
- package/dist/modules/app-context/index.js.map +1 -1
- package/dist/namespaces.d.ts +2942 -0
- package/dist/namespaces.d.ts.map +1 -0
- package/dist/namespaces.js +37 -0
- package/dist/namespaces.js.map +1 -0
- package/dist/rpc.d.ts +156 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +26 -0
- package/dist/rpc.js.map +1 -0
- package/dist/server/create-sdk.d.ts.map +1 -1
- package/dist/server/create-sdk.js +3 -13
- package/dist/server/create-sdk.js.map +1 -1
- package/dist/server/handlers/annotations.d.ts +52 -0
- package/dist/server/handlers/annotations.d.ts.map +1 -0
- package/dist/server/handlers/annotations.js +204 -0
- package/dist/server/handlers/annotations.js.map +1 -0
- package/dist/server/handlers/auth.d.ts +53 -0
- package/dist/server/handlers/auth.d.ts.map +1 -0
- package/dist/server/handlers/auth.js +66 -0
- package/dist/server/handlers/auth.js.map +1 -0
- package/dist/server/handlers/certification.d.ts +32 -0
- package/dist/server/handlers/certification.d.ts.map +1 -0
- package/dist/server/handlers/certification.js +253 -0
- package/dist/server/handlers/certification.js.map +1 -0
- package/dist/server/handlers/chat/conversations.d.ts +91 -0
- package/dist/server/handlers/chat/conversations.d.ts.map +1 -0
- package/dist/server/handlers/chat/conversations.js +314 -0
- package/dist/server/handlers/chat/conversations.js.map +1 -0
- package/dist/server/handlers/chat/delegator.d.ts +144 -0
- package/dist/server/handlers/chat/delegator.d.ts.map +1 -0
- package/dist/server/handlers/chat/delegator.js +431 -0
- package/dist/server/handlers/chat/delegator.js.map +1 -0
- package/dist/server/handlers/chat/engine.d.ts +81 -0
- package/dist/server/handlers/chat/engine.d.ts.map +1 -0
- package/dist/server/handlers/chat/engine.js +446 -0
- package/dist/server/handlers/chat/engine.js.map +1 -0
- package/dist/server/handlers/chat/executor.d.ts +65 -0
- package/dist/server/handlers/chat/executor.d.ts.map +1 -0
- package/dist/server/handlers/chat/executor.js +375 -0
- package/dist/server/handlers/chat/executor.js.map +1 -0
- package/dist/server/handlers/chat/index.d.ts +62 -0
- package/dist/server/handlers/chat/index.d.ts.map +1 -0
- package/dist/server/handlers/chat/index.js +182 -0
- package/dist/server/handlers/chat/index.js.map +1 -0
- package/dist/server/handlers/chat/memory.d.ts +91 -0
- package/dist/server/handlers/chat/memory.d.ts.map +1 -0
- package/dist/server/handlers/chat/memory.js +293 -0
- package/dist/server/handlers/chat/memory.js.map +1 -0
- package/dist/server/handlers/chat/models.d.ts +180 -0
- package/dist/server/handlers/chat/models.d.ts.map +1 -0
- package/dist/server/handlers/chat/models.js +304 -0
- package/dist/server/handlers/chat/models.js.map +1 -0
- package/dist/server/handlers/chat/planner.d.ts +116 -0
- package/dist/server/handlers/chat/planner.d.ts.map +1 -0
- package/dist/server/handlers/chat/planner.js +344 -0
- package/dist/server/handlers/chat/planner.js.map +1 -0
- package/dist/server/handlers/chat/types.d.ts +515 -0
- package/dist/server/handlers/chat/types.d.ts.map +1 -0
- package/dist/server/handlers/chat/types.js +11 -0
- package/dist/server/handlers/chat/types.js.map +1 -0
- package/dist/server/handlers/collections.d.ts +67 -0
- package/dist/server/handlers/collections.d.ts.map +1 -0
- package/dist/server/handlers/collections.js +484 -0
- package/dist/server/handlers/collections.js.map +1 -0
- package/dist/server/handlers/commerce.d.ts +106 -0
- package/dist/server/handlers/commerce.d.ts.map +1 -0
- package/dist/server/handlers/commerce.js +62 -0
- package/dist/server/handlers/commerce.js.map +1 -0
- package/dist/server/handlers/config.d.ts +112 -0
- package/dist/server/handlers/config.d.ts.map +1 -0
- package/dist/server/handlers/config.js +122 -0
- package/dist/server/handlers/config.js.map +1 -0
- package/dist/server/handlers/export.d.ts +72 -0
- package/dist/server/handlers/export.d.ts.map +1 -0
- package/dist/server/handlers/export.js +175 -0
- package/dist/server/handlers/export.js.map +1 -0
- package/dist/server/handlers/formats.d.ts +77 -0
- package/dist/server/handlers/formats.d.ts.map +1 -0
- package/dist/server/handlers/formats.js +65 -0
- package/dist/server/handlers/formats.js.map +1 -0
- package/dist/server/handlers/graph.d.ts +31 -0
- package/dist/server/handlers/graph.d.ts.map +1 -0
- package/dist/server/handlers/graph.js +490 -0
- package/dist/server/handlers/graph.js.map +1 -0
- package/dist/server/handlers/import.d.ts +96 -0
- package/dist/server/handlers/import.d.ts.map +1 -0
- package/dist/server/handlers/import.js +108 -0
- package/dist/server/handlers/import.js.map +1 -0
- package/dist/server/handlers/index.d.ts +68 -0
- package/dist/server/handlers/index.d.ts.map +1 -0
- package/dist/server/handlers/index.js +71 -0
- package/dist/server/handlers/index.js.map +1 -0
- package/dist/server/handlers/media.d.ts +76 -0
- package/dist/server/handlers/media.d.ts.map +1 -0
- package/dist/server/handlers/media.js +53 -0
- package/dist/server/handlers/media.js.map +1 -0
- package/dist/server/handlers/project.d.ts +45 -0
- package/dist/server/handlers/project.d.ts.map +1 -0
- package/dist/server/handlers/project.js +181 -0
- package/dist/server/handlers/project.js.map +1 -0
- package/dist/server/handlers/publish.d.ts +102 -0
- package/dist/server/handlers/publish.d.ts.map +1 -0
- package/dist/server/handlers/publish.js +130 -0
- package/dist/server/handlers/publish.js.map +1 -0
- package/dist/server/handlers/pulse.d.ts +39 -0
- package/dist/server/handlers/pulse.d.ts.map +1 -0
- package/dist/server/handlers/pulse.js +78 -0
- package/dist/server/handlers/pulse.js.map +1 -0
- package/dist/server/handlers/realtime.d.ts +55 -0
- package/dist/server/handlers/realtime.d.ts.map +1 -0
- package/dist/server/handlers/realtime.js +49 -0
- package/dist/server/handlers/realtime.js.map +1 -0
- package/dist/server/handlers/search.d.ts +21 -0
- package/dist/server/handlers/search.d.ts.map +1 -0
- package/dist/server/handlers/search.js +237 -0
- package/dist/server/handlers/search.js.map +1 -0
- package/dist/server/handlers/session.d.ts +47 -0
- package/dist/server/handlers/session.d.ts.map +1 -0
- package/dist/server/handlers/session.js +286 -0
- package/dist/server/handlers/session.js.map +1 -0
- package/dist/server/handlers/settings.d.ts +97 -0
- package/dist/server/handlers/settings.d.ts.map +1 -0
- package/dist/server/handlers/settings.js +131 -0
- package/dist/server/handlers/settings.js.map +1 -0
- package/dist/server/handlers/workspace.d.ts +78 -0
- package/dist/server/handlers/workspace.d.ts.map +1 -0
- package/dist/server/handlers/workspace.js +270 -0
- package/dist/server/handlers/workspace.js.map +1 -0
- package/dist/server/hono-router.d.ts +66 -0
- package/dist/server/hono-router.d.ts.map +1 -0
- package/dist/server/hono-router.js +203 -0
- package/dist/server/hono-router.js.map +1 -0
- package/dist/server/index.d.ts +27 -19
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +30 -18
- package/dist/server/index.js.map +1 -1
- package/dist/server/namespace-router.d.ts +204 -0
- package/dist/server/namespace-router.d.ts.map +1 -0
- package/dist/server/namespace-router.js +262 -0
- package/dist/server/namespace-router.js.map +1 -0
- package/dist/transports/http-namespace.d.ts +210 -0
- package/dist/transports/http-namespace.d.ts.map +1 -0
- package/dist/transports/http-namespace.js +514 -0
- package/dist/transports/http-namespace.js.map +1 -0
- package/dist/types.d.ts +59 -65
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +7 -3
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,2942 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module namespaces
|
|
3
|
+
* @description The single source of truth for every SDK namespace and method.
|
|
4
|
+
*
|
|
5
|
+
* {@link SoulcraftNamespaces} defines the complete API surface that clients can
|
|
6
|
+
* call and servers must implement. Client proxies and server handlers are both
|
|
7
|
+
* derived from this contract.
|
|
8
|
+
*
|
|
9
|
+
* ## Namespace tiers
|
|
10
|
+
*
|
|
11
|
+
* - **Tier 1**: Already exists in SDK modules — the interface re-exports them.
|
|
12
|
+
* - **Tier 2**: New namespaces that absorb Workshop/Venue route handlers.
|
|
13
|
+
* - **Tier 3**: Inline endpoints absorbed into existing namespaces.
|
|
14
|
+
*
|
|
15
|
+
* ## Transport invariance
|
|
16
|
+
*
|
|
17
|
+
* Every method defined here works identically across PostMessage, HTTP, WebSocket,
|
|
18
|
+
* and local transports. The transport is the only variable — the API contract is
|
|
19
|
+
* constant.
|
|
20
|
+
*
|
|
21
|
+
* @example Client usage
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { createSoulcraftProxy } from '@soulcraft/sdk/client'
|
|
24
|
+
* const soulcraft = createSoulcraftProxy(transport)
|
|
25
|
+
* const results = await soulcraft.brainy.find({ query: 'candles' })
|
|
26
|
+
* const graph = await soulcraft.graph.getData()
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example Server handler
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { createSoulcraftRouter } from '@soulcraft/sdk/server'
|
|
32
|
+
* const router = createSoulcraftRouter({ resolveBrain, authenticate, providers })
|
|
33
|
+
* app.route('', router)
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
import type { SoulcraftBrainy } from './modules/brainy/types.js';
|
|
37
|
+
import type { AiModule } from './modules/ai/types.js';
|
|
38
|
+
import type { BillingModule } from './modules/billing/types.js';
|
|
39
|
+
import type { EventsModule } from './modules/events/types.js';
|
|
40
|
+
import type { SkillsModule } from './modules/skills/types.js';
|
|
41
|
+
import type { KitsModule } from './modules/kits/types.js';
|
|
42
|
+
import type { NotificationsModule } from './modules/notifications/types.js';
|
|
43
|
+
import type { HallModule } from './modules/hall/types.js';
|
|
44
|
+
/**
|
|
45
|
+
* @description A single frame in a streaming AI chat response.
|
|
46
|
+
*
|
|
47
|
+
* Discriminated on the `type` field. The stream emits zero or more `text`,
|
|
48
|
+
* `tool_use`, `tool_result`, and `status` chunks, followed by exactly one
|
|
49
|
+
* `done` or `error` chunk as the terminal frame.
|
|
50
|
+
*
|
|
51
|
+
* @example Processing a chat stream
|
|
52
|
+
* ```typescript
|
|
53
|
+
* for await (const chunk of soulcraft.chat.sendStreaming('Explain quantum entanglement')) {
|
|
54
|
+
* switch (chunk.type) {
|
|
55
|
+
* case 'text': process.stdout.write(chunk.text!); break
|
|
56
|
+
* case 'status': showSpinner(chunk.status!); break
|
|
57
|
+
* case 'done': console.log('Tokens:', chunk.usage); break
|
|
58
|
+
* case 'error': console.error(chunk.error); break
|
|
59
|
+
* }
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export interface ChatStreamChunk {
|
|
64
|
+
/** Discriminant — determines which optional fields are populated. */
|
|
65
|
+
type: 'text' | 'tool_use' | 'tool_result' | 'status' | 'done' | 'error';
|
|
66
|
+
/** Text content for `text` chunks. Each chunk is a partial token or sentence fragment. */
|
|
67
|
+
text?: string | undefined;
|
|
68
|
+
/** Tool call details for `tool_use` chunks. Claude is invoking a tool. */
|
|
69
|
+
toolCall?: {
|
|
70
|
+
id: string;
|
|
71
|
+
name: string;
|
|
72
|
+
input: Record<string, unknown>;
|
|
73
|
+
} | undefined;
|
|
74
|
+
/** Tool execution result for `tool_result` chunks. The server executed the tool. */
|
|
75
|
+
toolResult?: {
|
|
76
|
+
toolUseId: string;
|
|
77
|
+
content: string;
|
|
78
|
+
} | undefined;
|
|
79
|
+
/** Status message for `status` chunks (e.g. `'Searching entities...'`, `'Analyzing graph...'`). */
|
|
80
|
+
status?: string | undefined;
|
|
81
|
+
/** Token usage stats, present only on `done` chunks. */
|
|
82
|
+
usage?: {
|
|
83
|
+
inputTokens: number;
|
|
84
|
+
outputTokens: number;
|
|
85
|
+
model: string;
|
|
86
|
+
} | undefined;
|
|
87
|
+
/** Error message, present only on `error` chunks. */
|
|
88
|
+
error?: string | undefined;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* @description Summary metadata for a chat conversation.
|
|
92
|
+
*
|
|
93
|
+
* Returned by {@link ChatNamespace.listConversations} and
|
|
94
|
+
* {@link ChatNamespace.createConversation}. Does not include message bodies —
|
|
95
|
+
* use {@link ChatNamespace.getConversation} for full message history.
|
|
96
|
+
*/
|
|
97
|
+
export interface ChatConversation {
|
|
98
|
+
/** Unique conversation identifier (UUID). */
|
|
99
|
+
id: string;
|
|
100
|
+
/** User-visible title, auto-generated from the first message or set manually. */
|
|
101
|
+
title: string;
|
|
102
|
+
/** ISO 8601 timestamp when the conversation was created. */
|
|
103
|
+
createdAt: string;
|
|
104
|
+
/** ISO 8601 timestamp of the most recent message. */
|
|
105
|
+
updatedAt: string;
|
|
106
|
+
/** Total number of messages (user + assistant). */
|
|
107
|
+
messageCount: number;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* @description A single message within a chat conversation.
|
|
111
|
+
*/
|
|
112
|
+
export interface ChatMessage {
|
|
113
|
+
/** Who sent this message. */
|
|
114
|
+
role: 'user' | 'assistant';
|
|
115
|
+
/** The message text content. */
|
|
116
|
+
content: string;
|
|
117
|
+
/** ISO 8601 timestamp when the message was sent. */
|
|
118
|
+
timestamp: string;
|
|
119
|
+
/** The Claude model ID that generated this message (assistant messages only). */
|
|
120
|
+
model?: string | undefined;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* @description A full conversation including all messages.
|
|
124
|
+
*
|
|
125
|
+
* Extends {@link ChatConversation} with the complete message history.
|
|
126
|
+
* Returned by {@link ChatNamespace.getConversation}.
|
|
127
|
+
*/
|
|
128
|
+
export interface ChatConversationDetail extends ChatConversation {
|
|
129
|
+
/** Ordered array of all messages in this conversation. */
|
|
130
|
+
messages: ChatMessage[];
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* @description Graph visualization payload containing nodes and edges.
|
|
134
|
+
*
|
|
135
|
+
* Returned by all methods on {@link GraphNamespace}. The nodes and edges are
|
|
136
|
+
* assembled from Brainy entities and relationships, suitable for rendering
|
|
137
|
+
* with Cytoscape.js, D3, or any graph visualization library.
|
|
138
|
+
*/
|
|
139
|
+
export interface GraphData {
|
|
140
|
+
/** All nodes (entities) in the graph. */
|
|
141
|
+
nodes: GraphNode[];
|
|
142
|
+
/** All edges (relationships) between nodes. */
|
|
143
|
+
edges: GraphEdge[];
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* @description A single node in the graph visualization.
|
|
147
|
+
*
|
|
148
|
+
* Each node represents a Brainy entity with its display label and type.
|
|
149
|
+
*/
|
|
150
|
+
export interface GraphNode {
|
|
151
|
+
/** The entity's unique identifier (Brainy entity ID). */
|
|
152
|
+
id: string;
|
|
153
|
+
/** Display label (typically `metadata.name`). */
|
|
154
|
+
label: string;
|
|
155
|
+
/** The entity's NounType (e.g. `'Person'`, `'Document'`, `'Concept'`). */
|
|
156
|
+
type: string;
|
|
157
|
+
/** Additional entity metadata for tooltips, filtering, and styling. */
|
|
158
|
+
metadata?: Record<string, unknown> | undefined;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* @description A single edge in the graph visualization.
|
|
162
|
+
*
|
|
163
|
+
* Each edge represents a Brainy relationship between two entities.
|
|
164
|
+
*/
|
|
165
|
+
export interface GraphEdge {
|
|
166
|
+
/** Unique edge identifier (typically `{from}-{verbType}-{to}`). */
|
|
167
|
+
id: string;
|
|
168
|
+
/** Source node ID. */
|
|
169
|
+
source: string;
|
|
170
|
+
/** Target node ID. */
|
|
171
|
+
target: string;
|
|
172
|
+
/** Display label for the edge (the VerbType name). */
|
|
173
|
+
label: string;
|
|
174
|
+
/** The relationship's VerbType (e.g. `'relatedTo'`, `'partOf'`, `'createdBy'`). */
|
|
175
|
+
type: string;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* @description Aggregate statistics about the workspace's knowledge graph.
|
|
179
|
+
*
|
|
180
|
+
* Returned by {@link GraphNamespace.getStats}.
|
|
181
|
+
*/
|
|
182
|
+
export interface GraphStats {
|
|
183
|
+
/** Total number of entities in the workspace. */
|
|
184
|
+
nodeCount: number;
|
|
185
|
+
/** Total number of relationships in the workspace. */
|
|
186
|
+
edgeCount: number;
|
|
187
|
+
/** Count of entities per NounType (e.g. `{ Person: 42, Document: 15 }`). */
|
|
188
|
+
typeDistribution: Record<string, number>;
|
|
189
|
+
/** Count of relationships per VerbType (e.g. `{ relatedTo: 30, partOf: 12 }`). */
|
|
190
|
+
verbDistribution: Record<string, number>;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* @description A single result from semantic or unified search.
|
|
194
|
+
*
|
|
195
|
+
* Returned by {@link SearchNamespace.query} and {@link SearchNamespace.unified}.
|
|
196
|
+
*/
|
|
197
|
+
export interface SearchResult {
|
|
198
|
+
/** The entity's unique identifier. */
|
|
199
|
+
id: string;
|
|
200
|
+
/** The entity's display name. */
|
|
201
|
+
name: string;
|
|
202
|
+
/** The entity's NounType. */
|
|
203
|
+
type: string;
|
|
204
|
+
/** Relevance score (0–1, higher is more relevant). */
|
|
205
|
+
score: number;
|
|
206
|
+
/** A text snippet with the matching portion highlighted, if available. */
|
|
207
|
+
highlight?: string | undefined;
|
|
208
|
+
/** Additional entity metadata for display. */
|
|
209
|
+
metadata?: Record<string, unknown> | undefined;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* @description A view collection — a named group of entities used to filter
|
|
213
|
+
* graph views, boards, galleries, and other explore visualizations.
|
|
214
|
+
*
|
|
215
|
+
* Returned by {@link CollectionsNamespace} CRUD methods.
|
|
216
|
+
*/
|
|
217
|
+
export interface ViewCollection {
|
|
218
|
+
/** Unique collection identifier (Brainy entity ID). */
|
|
219
|
+
id: string;
|
|
220
|
+
/** User-visible collection name. */
|
|
221
|
+
name: string;
|
|
222
|
+
/** Collection type (e.g. `'manual'`, `'smart'`, `'virtual'`). */
|
|
223
|
+
type: string;
|
|
224
|
+
/** Number of entities currently in this collection. */
|
|
225
|
+
memberCount: number;
|
|
226
|
+
/** Additional collection metadata (filter criteria, display settings, etc.). */
|
|
227
|
+
metadata?: Record<string, unknown> | undefined;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* @description A code annotation — a developer note attached to a specific
|
|
231
|
+
* line range in a VFS file. Used by the Illuminate feature.
|
|
232
|
+
*
|
|
233
|
+
* Returned by {@link AnnotationsNamespace} CRUD methods.
|
|
234
|
+
*/
|
|
235
|
+
export interface Annotation {
|
|
236
|
+
/** Unique annotation identifier (Brainy entity ID). */
|
|
237
|
+
id: string;
|
|
238
|
+
/** The VFS file path this annotation is attached to. */
|
|
239
|
+
filePath: string;
|
|
240
|
+
/** First line of the annotated range (1-based). */
|
|
241
|
+
lineStart: number;
|
|
242
|
+
/** Last line of the annotated range (1-based, inclusive). */
|
|
243
|
+
lineEnd: number;
|
|
244
|
+
/** The annotation text (Markdown supported). */
|
|
245
|
+
content: string;
|
|
246
|
+
/** Annotation type (e.g. `'note'`, `'question'`, `'explanation'`). */
|
|
247
|
+
type: string;
|
|
248
|
+
/** ISO 8601 timestamp when the annotation was created. */
|
|
249
|
+
createdAt: string;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* @description Metadata about a workspace.
|
|
253
|
+
*
|
|
254
|
+
* Returned by {@link WorkspaceNamespace.list} and {@link WorkspaceNamespace.get}.
|
|
255
|
+
*/
|
|
256
|
+
export interface WorkspaceInfo {
|
|
257
|
+
/** Unique workspace identifier. */
|
|
258
|
+
id: string;
|
|
259
|
+
/** User-visible workspace name. */
|
|
260
|
+
name: string;
|
|
261
|
+
/** The kit used to initialize this workspace, if any. */
|
|
262
|
+
kitId?: string | undefined;
|
|
263
|
+
/** ISO 8601 timestamp when the workspace was created. */
|
|
264
|
+
createdAt: string;
|
|
265
|
+
/** ISO 8601 timestamp of the most recent modification. */
|
|
266
|
+
updatedAt: string;
|
|
267
|
+
/** Number of Brainy entities in the workspace. */
|
|
268
|
+
entityCount?: number | undefined;
|
|
269
|
+
/** Number of VFS files in the workspace. */
|
|
270
|
+
fileCount?: number | undefined;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* @description Workspace health and initialization status.
|
|
274
|
+
*
|
|
275
|
+
* Returned by {@link WorkspaceNamespace.getStatus}. The `status` field
|
|
276
|
+
* indicates whether the Brainy instance is ready to serve requests.
|
|
277
|
+
*/
|
|
278
|
+
export interface WorkspaceStatus {
|
|
279
|
+
/** Current state: `'ready'` (accepting requests), `'initializing'` (cold start), or `'error'`. */
|
|
280
|
+
status: 'ready' | 'initializing' | 'error';
|
|
281
|
+
/** The workspace identifier. */
|
|
282
|
+
workspaceId?: string | undefined;
|
|
283
|
+
/** The kit used to initialize this workspace, if any. */
|
|
284
|
+
kitId?: string | undefined;
|
|
285
|
+
/** Number of entities (available once status is `'ready'`). */
|
|
286
|
+
entityCount?: number | undefined;
|
|
287
|
+
/** Error description when status is `'error'`. */
|
|
288
|
+
error?: string | undefined;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* @description A published Living Link — a shareable URL pointing to workspace content.
|
|
292
|
+
*
|
|
293
|
+
* Returned by {@link PublishNamespace} link management methods.
|
|
294
|
+
*/
|
|
295
|
+
export interface PublishedLink {
|
|
296
|
+
/** Unique link identifier. */
|
|
297
|
+
id: string;
|
|
298
|
+
/** URL-safe slug for the link (e.g. `'my-project'`). */
|
|
299
|
+
slug: string;
|
|
300
|
+
/** The full public URL. */
|
|
301
|
+
url: string;
|
|
302
|
+
/** Link type (e.g. `'website'`, `'document'`, `'app'`). */
|
|
303
|
+
type: string;
|
|
304
|
+
/** ISO 8601 timestamp when the link was created. */
|
|
305
|
+
createdAt: string;
|
|
306
|
+
/** ISO 8601 timestamp when the link expires, or undefined for permanent links. */
|
|
307
|
+
expiresAt?: string | undefined;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* @description Progress event emitted during file or data import operations.
|
|
311
|
+
*
|
|
312
|
+
* Delivered as SSE chunks via {@link ImportNamespace.uploadFiles} and
|
|
313
|
+
* {@link ImportNamespace.importData}.
|
|
314
|
+
*/
|
|
315
|
+
export interface ImportProgress {
|
|
316
|
+
/** Current phase of the import pipeline. */
|
|
317
|
+
phase: 'parsing' | 'importing' | 'embedding' | 'done' | 'error';
|
|
318
|
+
/** Number of items processed so far in this phase. */
|
|
319
|
+
current: number;
|
|
320
|
+
/** Total items expected in this phase. */
|
|
321
|
+
total: number;
|
|
322
|
+
/** Human-readable status message (e.g. `'Importing entities...'`). */
|
|
323
|
+
message?: string | undefined;
|
|
324
|
+
/** Error description when phase is `'error'`. */
|
|
325
|
+
error?: string | undefined;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* @description Descriptor for a supported export format.
|
|
329
|
+
*
|
|
330
|
+
* Returned by {@link ExportNamespace.getExporters}.
|
|
331
|
+
*/
|
|
332
|
+
export interface ExportFormat {
|
|
333
|
+
/** Format identifier (e.g. `'json'`, `'graphml'`, `'csv'`). */
|
|
334
|
+
id: string;
|
|
335
|
+
/** Human-readable format name (e.g. `'GraphML (XML)'`). */
|
|
336
|
+
name: string;
|
|
337
|
+
/** File extension including the dot (e.g. `'.graphml'`). */
|
|
338
|
+
extension: string;
|
|
339
|
+
/** MIME type for the Content-Type header. */
|
|
340
|
+
mimeType: string;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* @description Platform-level configuration including feature flags, limits,
|
|
344
|
+
* maintenance mode, and announcements.
|
|
345
|
+
*
|
|
346
|
+
* Returned by {@link ConfigNamespace.get}.
|
|
347
|
+
*/
|
|
348
|
+
export interface PlatformConfig {
|
|
349
|
+
/** Feature flags — keys are feature names, values indicate enabled/disabled. */
|
|
350
|
+
features: Record<string, boolean>;
|
|
351
|
+
/** Numeric limits — keys are limit names (e.g. `'maxWorkspaces'`, `'maxFileSize'`). */
|
|
352
|
+
limits: Record<string, number>;
|
|
353
|
+
/** Maintenance mode state. When active, most API calls are blocked. */
|
|
354
|
+
maintenance?: {
|
|
355
|
+
active: boolean;
|
|
356
|
+
message?: string;
|
|
357
|
+
} | undefined;
|
|
358
|
+
/** Active platform announcements shown to users. */
|
|
359
|
+
announcements?: Array<{
|
|
360
|
+
id: string;
|
|
361
|
+
message: string;
|
|
362
|
+
type: string;
|
|
363
|
+
}> | undefined;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* @description Redacted API key information (the actual key is never returned).
|
|
367
|
+
*
|
|
368
|
+
* Returned by {@link SettingsNamespace.getApiKey}.
|
|
369
|
+
*/
|
|
370
|
+
export interface ApiKeyInfo {
|
|
371
|
+
/** The AI provider this key is for (e.g. `'anthropic'`). */
|
|
372
|
+
provider: string;
|
|
373
|
+
/** Last four characters of the key for identification. */
|
|
374
|
+
lastFour: string;
|
|
375
|
+
/** ISO 8601 timestamp when the key was saved. */
|
|
376
|
+
createdAt: string;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* @description Breakdown of storage consumption for the current workspace.
|
|
380
|
+
*
|
|
381
|
+
* Returned by {@link SettingsNamespace.getStorageUsage}.
|
|
382
|
+
*/
|
|
383
|
+
export interface StorageUsage {
|
|
384
|
+
/** Total bytes consumed across all categories. */
|
|
385
|
+
totalBytes: number;
|
|
386
|
+
/** Bytes consumed by Brainy entity data (the knowledge graph). */
|
|
387
|
+
entityBytes: number;
|
|
388
|
+
/** Bytes consumed by VFS files (documents, images, code, etc.). */
|
|
389
|
+
fileBytes: number;
|
|
390
|
+
/** Bytes consumed by vector indices and search metadata. */
|
|
391
|
+
indexBytes: number;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* @description Current state of a collaborative editing session.
|
|
395
|
+
*
|
|
396
|
+
* Returned by {@link SessionNamespace.join} and {@link SessionNamespace.getState}.
|
|
397
|
+
*/
|
|
398
|
+
export interface SessionState {
|
|
399
|
+
/** Unique session identifier. */
|
|
400
|
+
sessionId: string;
|
|
401
|
+
/** Currently connected participants. */
|
|
402
|
+
participants: Array<{
|
|
403
|
+
userId: string;
|
|
404
|
+
name: string;
|
|
405
|
+
joinedAt: string;
|
|
406
|
+
}>;
|
|
407
|
+
/** ISO 8601 timestamp when the session was created. */
|
|
408
|
+
createdAt: string;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* @description Result of a media upload operation.
|
|
412
|
+
*
|
|
413
|
+
* Returned by {@link MediaNamespace.upload}.
|
|
414
|
+
*/
|
|
415
|
+
export interface MediaUploadResult {
|
|
416
|
+
/** Unique media identifier. */
|
|
417
|
+
mediaId: string;
|
|
418
|
+
/** Public URL to access the media. */
|
|
419
|
+
url: string;
|
|
420
|
+
/** MIME type of the stored (possibly transcoded) media. */
|
|
421
|
+
mimeType: string;
|
|
422
|
+
/** File size in bytes. */
|
|
423
|
+
size: number;
|
|
424
|
+
/** Duration in seconds (audio/video only). */
|
|
425
|
+
duration?: number;
|
|
426
|
+
/** Dimensions in pixels (image/video only). */
|
|
427
|
+
dimensions?: {
|
|
428
|
+
width: number;
|
|
429
|
+
height: number;
|
|
430
|
+
};
|
|
431
|
+
/** Thumbnail URL if thumbnail generation was requested. */
|
|
432
|
+
thumbnailUrl?: string;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* @description Metadata about a stored media item.
|
|
436
|
+
*
|
|
437
|
+
* Returned by {@link MediaNamespace.getInfo}.
|
|
438
|
+
*/
|
|
439
|
+
export interface MediaInfo {
|
|
440
|
+
/** Unique media identifier. */
|
|
441
|
+
mediaId: string;
|
|
442
|
+
/** MIME type. */
|
|
443
|
+
mimeType: string;
|
|
444
|
+
/** File size in bytes. */
|
|
445
|
+
size: number;
|
|
446
|
+
/** Duration in seconds (audio/video only). */
|
|
447
|
+
duration?: number;
|
|
448
|
+
/** Dimensions in pixels (image/video only). */
|
|
449
|
+
dimensions?: {
|
|
450
|
+
width: number;
|
|
451
|
+
height: number;
|
|
452
|
+
};
|
|
453
|
+
/** Whether the media was transcoded from a different format. */
|
|
454
|
+
transcoded: boolean;
|
|
455
|
+
/** ISO 8601 timestamp when the media was uploaded. */
|
|
456
|
+
uploadedAt: string;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* @description A peer currently subscribed to a realtime topic.
|
|
460
|
+
*
|
|
461
|
+
* Returned as part of {@link RealtimeNamespace.presence}.
|
|
462
|
+
*/
|
|
463
|
+
export interface RealtimePeer {
|
|
464
|
+
/** Unique user identifier. */
|
|
465
|
+
id: string;
|
|
466
|
+
/** Display name. */
|
|
467
|
+
name: string;
|
|
468
|
+
/** ISO 8601 timestamp when the peer joined this topic. */
|
|
469
|
+
joinedAt: string;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* @description A subscription handle for a realtime topic.
|
|
473
|
+
*
|
|
474
|
+
* Returned by {@link RealtimeNamespace.subscribe}.
|
|
475
|
+
*/
|
|
476
|
+
export interface RealtimeSubscription {
|
|
477
|
+
/** Unsubscribe from the topic. */
|
|
478
|
+
unsubscribe(): void;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* @description A product available for purchase.
|
|
482
|
+
*
|
|
483
|
+
* Returned by {@link CommerceNamespace.getProduct} and {@link CommerceNamespace.listProducts}.
|
|
484
|
+
*/
|
|
485
|
+
export interface CommerceProduct {
|
|
486
|
+
/** Unique product identifier. */
|
|
487
|
+
id: string;
|
|
488
|
+
/** Product display name. */
|
|
489
|
+
name: string;
|
|
490
|
+
/** Product description. */
|
|
491
|
+
description: string;
|
|
492
|
+
/** Price in smallest currency unit (e.g. cents). */
|
|
493
|
+
priceAmount: number;
|
|
494
|
+
/** Three-letter ISO 4217 currency code (e.g. `'usd'`). */
|
|
495
|
+
currency: string;
|
|
496
|
+
/** Whether the product is currently available for purchase. */
|
|
497
|
+
active: boolean;
|
|
498
|
+
/** Optional product images. */
|
|
499
|
+
images?: string[];
|
|
500
|
+
/** Product metadata for application use. */
|
|
501
|
+
metadata?: Record<string, string>;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* @description Result of initiating a checkout session.
|
|
505
|
+
*
|
|
506
|
+
* Returned by {@link CommerceNamespace.checkout}.
|
|
507
|
+
*/
|
|
508
|
+
export interface CheckoutSession {
|
|
509
|
+
/** Checkout session identifier. */
|
|
510
|
+
sessionId: string;
|
|
511
|
+
/** URL to redirect the customer to for payment. */
|
|
512
|
+
checkoutUrl: string;
|
|
513
|
+
/** ISO 8601 expiration timestamp for this checkout session. */
|
|
514
|
+
expiresAt: string;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* @description A completed payment record.
|
|
518
|
+
*
|
|
519
|
+
* Returned by {@link CommerceNamespace.getPayment}.
|
|
520
|
+
*/
|
|
521
|
+
export interface PaymentRecord {
|
|
522
|
+
/** Payment identifier. */
|
|
523
|
+
id: string;
|
|
524
|
+
/** Amount in smallest currency unit. */
|
|
525
|
+
amount: number;
|
|
526
|
+
/** Three-letter ISO 4217 currency code. */
|
|
527
|
+
currency: string;
|
|
528
|
+
/** Payment status. */
|
|
529
|
+
status: 'succeeded' | 'pending' | 'failed' | 'refunded';
|
|
530
|
+
/** Customer email. */
|
|
531
|
+
customerEmail: string;
|
|
532
|
+
/** ISO 8601 timestamp. */
|
|
533
|
+
createdAt: string;
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* @description A verifiable credential with lineage tracing.
|
|
537
|
+
*
|
|
538
|
+
* Uses Brainy's graph model: the certification is a `contract` entity with
|
|
539
|
+
* `endorses`, `attributedTo`, and `dependsOn` relationships forming a lineage chain.
|
|
540
|
+
*
|
|
541
|
+
* @example Lineage chain
|
|
542
|
+
* ```
|
|
543
|
+
* Certifier ─[endorses]→ Certification ─[attributedTo]→ Learner
|
|
544
|
+
* ─[dependsOn]→ Upstream Cert
|
|
545
|
+
* ```
|
|
546
|
+
*/
|
|
547
|
+
export interface Certification {
|
|
548
|
+
/** Unique certification identifier (Brainy entity ID). */
|
|
549
|
+
id: string;
|
|
550
|
+
/** Certification name (e.g. `'Advanced Candle Making'`). */
|
|
551
|
+
name: string;
|
|
552
|
+
/** Who issued this certification (certifier user ID). */
|
|
553
|
+
certifierId: string;
|
|
554
|
+
/** Who received this certification (learner user ID). */
|
|
555
|
+
learnerId: string;
|
|
556
|
+
/** Assessment score (0.0–1.0). */
|
|
557
|
+
score: number;
|
|
558
|
+
/** Whether the certification was AI-issued (vs. human instructor). */
|
|
559
|
+
aiIssued: boolean;
|
|
560
|
+
/** Lineage depth — how many upstream certifications in the chain. */
|
|
561
|
+
lineageDepth: number;
|
|
562
|
+
/** ISO 8601 timestamp when the certification was issued. */
|
|
563
|
+
issuedAt: string;
|
|
564
|
+
/** Optional upstream certification ID (lineage link). */
|
|
565
|
+
upstreamCertificationId?: string;
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* @description Assessment result from the graph-native scoring system.
|
|
569
|
+
*
|
|
570
|
+
* Score = demonstrated competencies / total required competencies.
|
|
571
|
+
*/
|
|
572
|
+
export interface AssessmentResult {
|
|
573
|
+
/** Computed score (0.0–1.0). */
|
|
574
|
+
score: number;
|
|
575
|
+
/** Whether the learner passed the threshold. */
|
|
576
|
+
passed: boolean;
|
|
577
|
+
/** Passing threshold (default: 0.8). */
|
|
578
|
+
threshold: number;
|
|
579
|
+
/** Competency IDs the learner has demonstrated. */
|
|
580
|
+
demonstratedCompetencies: string[];
|
|
581
|
+
/** Competency IDs the learner still needs. */
|
|
582
|
+
missingCompetencies: string[];
|
|
583
|
+
/** Total number of required competencies. */
|
|
584
|
+
totalCompetencies: number;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* @description Supported output format for conversion.
|
|
588
|
+
*
|
|
589
|
+
* Returned by {@link FormatsNamespace.getOutputFormats}.
|
|
590
|
+
*/
|
|
591
|
+
export interface OutputFormat {
|
|
592
|
+
/** Format identifier (e.g. `'pdf'`, `'html'`, `'markdown'`). */
|
|
593
|
+
id: string;
|
|
594
|
+
/** Human-readable name. */
|
|
595
|
+
name: string;
|
|
596
|
+
/** MIME type of the output. */
|
|
597
|
+
mimeType: string;
|
|
598
|
+
/** Which source formats can convert to this output. */
|
|
599
|
+
sourceFormats: string[];
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* @description Result of a format validation.
|
|
603
|
+
*
|
|
604
|
+
* Returned by {@link FormatsNamespace.validate}.
|
|
605
|
+
*/
|
|
606
|
+
export interface FormatValidationResult {
|
|
607
|
+
/** Whether the document is valid. */
|
|
608
|
+
valid: boolean;
|
|
609
|
+
/** Validation errors (empty if valid). */
|
|
610
|
+
errors: Array<{
|
|
611
|
+
path: string;
|
|
612
|
+
message: string;
|
|
613
|
+
}>;
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* @description The complete Soulcraft SDK namespace surface.
|
|
617
|
+
*
|
|
618
|
+
* Every property is a namespace. Every method on a namespace is an RPC endpoint.
|
|
619
|
+
* Client proxies serialize calls as `{ ns, method, args }`. Server handlers
|
|
620
|
+
* dispatch based on this interface.
|
|
621
|
+
*
|
|
622
|
+
* Tier 1 namespaces reference existing module interfaces directly.
|
|
623
|
+
* Tier 2 namespaces define new methods that absorb Workshop/Venue route handlers.
|
|
624
|
+
*/
|
|
625
|
+
export interface SoulcraftNamespaces {
|
|
626
|
+
/**
|
|
627
|
+
* Full Brainy graph API — CRUD, search, embed, batch, relationships,
|
|
628
|
+
* analytics, sub-APIs (vfs, versions, neural, counts).
|
|
629
|
+
*
|
|
630
|
+
* Already implemented via recursive Proxy + LocalTransport dispatch.
|
|
631
|
+
* See {@link SoulcraftBrainy} for the full method list.
|
|
632
|
+
*/
|
|
633
|
+
brainy: SoulcraftBrainy;
|
|
634
|
+
/**
|
|
635
|
+
* Claude AI — single-shot completions and streaming.
|
|
636
|
+
* See {@link AiModule} for method signatures and tool call handling.
|
|
637
|
+
*/
|
|
638
|
+
ai: AiModule;
|
|
639
|
+
/**
|
|
640
|
+
* Usage metering, subscriptions, top-up credits, Stripe integration.
|
|
641
|
+
* See {@link BillingModule} for checkLimit, recordUsage, subscription management.
|
|
642
|
+
*/
|
|
643
|
+
billing: BillingModule;
|
|
644
|
+
/**
|
|
645
|
+
* Platform event bus — typed publish/subscribe for entity changes, VFS events,
|
|
646
|
+
* and custom application events. See {@link EventsModule}.
|
|
647
|
+
*/
|
|
648
|
+
events: EventsModule;
|
|
649
|
+
/**
|
|
650
|
+
* Skill loading and registry — load, list, install SKILL.md prompt files.
|
|
651
|
+
* See {@link SkillsModule}.
|
|
652
|
+
*/
|
|
653
|
+
skills: SkillsModule;
|
|
654
|
+
/**
|
|
655
|
+
* Kit registry — load kit manifests, list kits, resolve template file paths.
|
|
656
|
+
* See {@link KitsModule}.
|
|
657
|
+
*/
|
|
658
|
+
kits: KitsModule;
|
|
659
|
+
/**
|
|
660
|
+
* Email (Postmark) + SMS (Twilio) notifications with automatic dev fallback.
|
|
661
|
+
* See {@link NotificationsModule}.
|
|
662
|
+
*/
|
|
663
|
+
notifications: NotificationsModule;
|
|
664
|
+
/**
|
|
665
|
+
* Real-time communication — WebRTC SFU, chat, recording, transcription via Hall server.
|
|
666
|
+
* See {@link HallModule}.
|
|
667
|
+
*/
|
|
668
|
+
hall: HallModule;
|
|
669
|
+
/**
|
|
670
|
+
* AI conversation engine — full chat with streaming, tool use, conversations
|
|
671
|
+
* CRUD, memory, expertise profiles, tiered model routing, skill injection.
|
|
672
|
+
*
|
|
673
|
+
* Absorbs Workshop `routes/chat.ts` (~2000 lines).
|
|
674
|
+
*/
|
|
675
|
+
chat: ChatNamespace;
|
|
676
|
+
/**
|
|
677
|
+
* Graph visualization data — full graph, stats, focused subgraph, neighbors.
|
|
678
|
+
*
|
|
679
|
+
* Absorbs Workshop `routes/graph.ts`.
|
|
680
|
+
*/
|
|
681
|
+
graph: GraphNamespace;
|
|
682
|
+
/**
|
|
683
|
+
* Semantic and unified search, highlighting.
|
|
684
|
+
*
|
|
685
|
+
* Absorbs Workshop `routes/search.ts`.
|
|
686
|
+
*/
|
|
687
|
+
search: SearchNamespace;
|
|
688
|
+
/**
|
|
689
|
+
* View collections, virtual collections, collection members, sample data.
|
|
690
|
+
*
|
|
691
|
+
* Absorbs Workshop `routes/collections.ts`.
|
|
692
|
+
*/
|
|
693
|
+
collections: CollectionsNamespace;
|
|
694
|
+
/**
|
|
695
|
+
* Code annotations CRUD + AI-powered explanations.
|
|
696
|
+
*
|
|
697
|
+
* Absorbs Workshop `routes/annotations.ts`.
|
|
698
|
+
*/
|
|
699
|
+
annotations: AnnotationsNamespace;
|
|
700
|
+
/**
|
|
701
|
+
* Workspace CRUD, backup/restore, settings, health check.
|
|
702
|
+
*
|
|
703
|
+
* Absorbs Workshop `routes/workspace.ts` + `routes/workspaces.ts`.
|
|
704
|
+
*/
|
|
705
|
+
workspace: WorkspaceNamespace;
|
|
706
|
+
/**
|
|
707
|
+
* Publishing — Living Links, Venue deploy, Academy publish.
|
|
708
|
+
*
|
|
709
|
+
* Absorbs Workshop `routes/publish.ts`, `routes/deploy.ts`, `routes/academy-publish.ts`.
|
|
710
|
+
*/
|
|
711
|
+
publish: PublishNamespace;
|
|
712
|
+
/**
|
|
713
|
+
* File import — smart file upload with progress, knowledge graph format import.
|
|
714
|
+
*
|
|
715
|
+
* Absorbs Workshop `routes/import.ts` + `routes/import-data.ts`.
|
|
716
|
+
*/
|
|
717
|
+
import: ImportNamespace;
|
|
718
|
+
/**
|
|
719
|
+
* Export — project download, knowledge graph export, PDF export.
|
|
720
|
+
*
|
|
721
|
+
* Absorbs Workshop `routes/export.ts` + `routes/knowledge-graph.ts`.
|
|
722
|
+
*/
|
|
723
|
+
export: ExportNamespace;
|
|
724
|
+
/**
|
|
725
|
+
* Platform configuration — feature flags, limits, announcements, maintenance mode.
|
|
726
|
+
*
|
|
727
|
+
* Absorbs Workshop `routes/config.ts`.
|
|
728
|
+
*/
|
|
729
|
+
config: ConfigNamespace;
|
|
730
|
+
/**
|
|
731
|
+
* User settings — API key management, usage stats, storage usage.
|
|
732
|
+
*
|
|
733
|
+
* Absorbs Workshop `routes/settings.ts`.
|
|
734
|
+
*/
|
|
735
|
+
settings: SettingsNamespace;
|
|
736
|
+
/**
|
|
737
|
+
* Project context (Glass Box AI transparency) + metadata repair.
|
|
738
|
+
*
|
|
739
|
+
* Absorbs Workshop `routes/project.ts`.
|
|
740
|
+
*/
|
|
741
|
+
project: ProjectNamespace;
|
|
742
|
+
/**
|
|
743
|
+
* Collaborative session lifecycle — join, leave, state, history.
|
|
744
|
+
*
|
|
745
|
+
* Absorbs Workshop `routes/session.ts`.
|
|
746
|
+
*/
|
|
747
|
+
session: SessionNamespace;
|
|
748
|
+
/**
|
|
749
|
+
* Analytics event forwarding (fire-and-forget).
|
|
750
|
+
*
|
|
751
|
+
* Absorbs the pulse section of Workshop `routes/app-services.ts`.
|
|
752
|
+
*/
|
|
753
|
+
pulse: PulseNamespace;
|
|
754
|
+
/**
|
|
755
|
+
* Media pipeline — upload, transcode, stream audio/video/images.
|
|
756
|
+
* Backed by Hall server (hall.soulcraft.com).
|
|
757
|
+
*
|
|
758
|
+
* Enables podcast kits (record + transcribe + publish), video kits,
|
|
759
|
+
* gallery kits with image transforms.
|
|
760
|
+
*/
|
|
761
|
+
media: MediaNamespace;
|
|
762
|
+
/**
|
|
763
|
+
* Real-time pub/sub — topic-based subscribe, broadcast, and presence.
|
|
764
|
+
* Backed by Hall server (hall.soulcraft.com).
|
|
765
|
+
*
|
|
766
|
+
* Enables multiplayer games, live dashboards, collaborative editors,
|
|
767
|
+
* chat applications, and any feature requiring real-time data sync.
|
|
768
|
+
*/
|
|
769
|
+
realtime: RealtimeNamespace;
|
|
770
|
+
/**
|
|
771
|
+
* Commerce — products, checkout, payments. Stripe-first with pluggable
|
|
772
|
+
* provider interface for future payment processors.
|
|
773
|
+
*
|
|
774
|
+
* Enables e-commerce kits, booking kits, invoice kits with real
|
|
775
|
+
* payment processing.
|
|
776
|
+
*/
|
|
777
|
+
commerce: CommerceNamespace;
|
|
778
|
+
/**
|
|
779
|
+
* Certification — issue, verify, and trace credential lineage.
|
|
780
|
+
* Graph-native verifiable credentials using Brainy's relationship model.
|
|
781
|
+
*
|
|
782
|
+
* Moved from Academy to SDK so any product or kit can issue certifications:
|
|
783
|
+
* Workshop skill completion, Venue training, game achievements, course credentials.
|
|
784
|
+
*/
|
|
785
|
+
certification: CertificationNamespace;
|
|
786
|
+
/**
|
|
787
|
+
* Format conversion and validation — convert between Soulcraft portable
|
|
788
|
+
* formats (wdoc, wslide, wviz, wquiz) and output formats (PDF, HTML, etc.).
|
|
789
|
+
*
|
|
790
|
+
* Rendering stays in `@soulcraft/views`. SDK handles data conversion only.
|
|
791
|
+
*/
|
|
792
|
+
formats: FormatsNamespace;
|
|
793
|
+
/**
|
|
794
|
+
* Auth session and token operations.
|
|
795
|
+
*
|
|
796
|
+
* Absorbs inline endpoints from `server-hono.ts` and `ws-token.ts`.
|
|
797
|
+
*/
|
|
798
|
+
auth: AuthNamespace;
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* @description AI conversation engine with streaming, tool use, and conversation
|
|
802
|
+
* management. Handles tiered model routing (haiku → sonnet → opus based on
|
|
803
|
+
* complexity), workspace-aware skill injection, and persistent conversation state.
|
|
804
|
+
*
|
|
805
|
+
* @example Non-streaming chat
|
|
806
|
+
* ```typescript
|
|
807
|
+
* const { response, conversationId } = await soulcraft.chat.send('What entities are related to candles?', {
|
|
808
|
+
* conversationId: 'conv-123',
|
|
809
|
+
* })
|
|
810
|
+
* console.log(response)
|
|
811
|
+
* ```
|
|
812
|
+
*
|
|
813
|
+
* @example Streaming chat
|
|
814
|
+
* ```typescript
|
|
815
|
+
* for await (const chunk of soulcraft.chat.sendStreaming('Explain the graph structure')) {
|
|
816
|
+
* if (chunk.type === 'text') process.stdout.write(chunk.text!)
|
|
817
|
+
* }
|
|
818
|
+
* ```
|
|
819
|
+
*/
|
|
820
|
+
export interface ChatNamespace {
|
|
821
|
+
/**
|
|
822
|
+
* @description Send a message and receive the full response (non-streaming).
|
|
823
|
+
*
|
|
824
|
+
* The server selects the optimal Claude model based on message complexity,
|
|
825
|
+
* injects workspace-specific skills into the system prompt, and executes
|
|
826
|
+
* any tool calls (entity lookups, graph queries, etc.) before returning.
|
|
827
|
+
*
|
|
828
|
+
* @param message - The user's message text.
|
|
829
|
+
* @param options - Conversation context and configuration overrides.
|
|
830
|
+
* @param options.conversationId - Continue an existing conversation. If omitted, a new one is created.
|
|
831
|
+
* @param options.kitId - Kit to load skills from. Defaults to the workspace's kit.
|
|
832
|
+
* @param options.systemPrompt - Override the default system prompt (advanced use only).
|
|
833
|
+
* @param options.model - Force a specific Claude model ID instead of auto-selection.
|
|
834
|
+
* @returns The assistant's response with conversation ID and token usage.
|
|
835
|
+
*
|
|
836
|
+
* @example
|
|
837
|
+
* ```typescript
|
|
838
|
+
* const result = await soulcraft.chat.send('List all documents about candles')
|
|
839
|
+
* console.log(result.response)
|
|
840
|
+
* console.log(`Used ${result.usage.inputTokens + result.usage.outputTokens} tokens`)
|
|
841
|
+
* ```
|
|
842
|
+
*/
|
|
843
|
+
send(message: string, options?: {
|
|
844
|
+
conversationId?: string;
|
|
845
|
+
kitId?: string;
|
|
846
|
+
systemPrompt?: string;
|
|
847
|
+
model?: string;
|
|
848
|
+
}): Promise<{
|
|
849
|
+
response: string;
|
|
850
|
+
conversationId: string;
|
|
851
|
+
usage: {
|
|
852
|
+
inputTokens: number;
|
|
853
|
+
outputTokens: number;
|
|
854
|
+
model: string;
|
|
855
|
+
};
|
|
856
|
+
}>;
|
|
857
|
+
/**
|
|
858
|
+
* @description Send a message and stream the response as chunks.
|
|
859
|
+
*
|
|
860
|
+
* Returns an `AsyncIterable<ChatStreamChunk>` that yields text tokens,
|
|
861
|
+
* tool invocations, status updates, and a terminal `done` or `error` frame.
|
|
862
|
+
* The server performs tool calls in-band — you'll see `tool_use` → `tool_result`
|
|
863
|
+
* chunks interleaved with text.
|
|
864
|
+
*
|
|
865
|
+
* @param message - The user's message text.
|
|
866
|
+
* @param options - Same options as {@link ChatNamespace.send}.
|
|
867
|
+
* @returns An async iterable of {@link ChatStreamChunk} frames.
|
|
868
|
+
*
|
|
869
|
+
* @example
|
|
870
|
+
* ```typescript
|
|
871
|
+
* let fullText = ''
|
|
872
|
+
* for await (const chunk of soulcraft.chat.sendStreaming('Explain quantum entanglement')) {
|
|
873
|
+
* if (chunk.type === 'text') fullText += chunk.text
|
|
874
|
+
* if (chunk.type === 'done') console.log('Model:', chunk.usage?.model)
|
|
875
|
+
* }
|
|
876
|
+
* ```
|
|
877
|
+
*/
|
|
878
|
+
sendStreaming(message: string, options?: {
|
|
879
|
+
conversationId?: string;
|
|
880
|
+
kitId?: string;
|
|
881
|
+
systemPrompt?: string;
|
|
882
|
+
model?: string;
|
|
883
|
+
}): AsyncIterable<ChatStreamChunk>;
|
|
884
|
+
/**
|
|
885
|
+
* @description List all conversations for the current user in the active workspace.
|
|
886
|
+
*
|
|
887
|
+
* Returns summaries without message bodies — use {@link getConversation} for
|
|
888
|
+
* the full message history.
|
|
889
|
+
*
|
|
890
|
+
* @returns Array of conversation summaries, ordered by most recent first.
|
|
891
|
+
*
|
|
892
|
+
* @example
|
|
893
|
+
* ```typescript
|
|
894
|
+
* const conversations = await soulcraft.chat.listConversations()
|
|
895
|
+
* for (const conv of conversations) {
|
|
896
|
+
* console.log(`${conv.title} (${conv.messageCount} messages)`)
|
|
897
|
+
* }
|
|
898
|
+
* ```
|
|
899
|
+
*/
|
|
900
|
+
listConversations(): Promise<ChatConversation[]>;
|
|
901
|
+
/**
|
|
902
|
+
* @description Get a conversation with its full message history.
|
|
903
|
+
*
|
|
904
|
+
* @param conversationId - The conversation's unique identifier.
|
|
905
|
+
* @returns The full conversation with all messages, or `null` if not found.
|
|
906
|
+
*
|
|
907
|
+
* @example
|
|
908
|
+
* ```typescript
|
|
909
|
+
* const detail = await soulcraft.chat.getConversation('conv-abc123')
|
|
910
|
+
* if (detail) {
|
|
911
|
+
* for (const msg of detail.messages) {
|
|
912
|
+
* console.log(`[${msg.role}] ${msg.content.slice(0, 80)}...`)
|
|
913
|
+
* }
|
|
914
|
+
* }
|
|
915
|
+
* ```
|
|
916
|
+
*/
|
|
917
|
+
getConversation(conversationId: string): Promise<ChatConversationDetail | null>;
|
|
918
|
+
/**
|
|
919
|
+
* @description Create a new empty conversation.
|
|
920
|
+
*
|
|
921
|
+
* @param options - Optional title and kit association.
|
|
922
|
+
* @param options.title - Initial title. Auto-generated from the first message if omitted.
|
|
923
|
+
* @param options.kitId - Kit to associate with this conversation.
|
|
924
|
+
* @returns The newly created conversation metadata.
|
|
925
|
+
*
|
|
926
|
+
* @example
|
|
927
|
+
* ```typescript
|
|
928
|
+
* const conv = await soulcraft.chat.createConversation({ title: 'Research Notes' })
|
|
929
|
+
* const { response } = await soulcraft.chat.send('Hello!', { conversationId: conv.id })
|
|
930
|
+
* ```
|
|
931
|
+
*/
|
|
932
|
+
createConversation(options?: {
|
|
933
|
+
title?: string;
|
|
934
|
+
kitId?: string;
|
|
935
|
+
}): Promise<ChatConversation>;
|
|
936
|
+
/**
|
|
937
|
+
* @description Delete a conversation and all its messages permanently.
|
|
938
|
+
*
|
|
939
|
+
* @param conversationId - The conversation to delete.
|
|
940
|
+
*
|
|
941
|
+
* @example
|
|
942
|
+
* ```typescript
|
|
943
|
+
* await soulcraft.chat.deleteConversation('conv-abc123')
|
|
944
|
+
* ```
|
|
945
|
+
*/
|
|
946
|
+
deleteConversation(conversationId: string): Promise<void>;
|
|
947
|
+
/**
|
|
948
|
+
* @description Rename a conversation.
|
|
949
|
+
*
|
|
950
|
+
* @param conversationId - The conversation to rename.
|
|
951
|
+
* @param title - The new title.
|
|
952
|
+
*
|
|
953
|
+
* @example
|
|
954
|
+
* ```typescript
|
|
955
|
+
* await soulcraft.chat.renameConversation('conv-abc123', 'Candle Inventory Analysis')
|
|
956
|
+
* ```
|
|
957
|
+
*/
|
|
958
|
+
renameConversation(conversationId: string, title: string): Promise<void>;
|
|
959
|
+
/**
|
|
960
|
+
* @description Get the AI's learned expertise profile for the current workspace.
|
|
961
|
+
*
|
|
962
|
+
* The expertise is accumulated over time from conversations and reflects what
|
|
963
|
+
* the AI has learned about the user's domain, preferences, and workflow.
|
|
964
|
+
*
|
|
965
|
+
* @returns Topics, skills, and insights the AI has learned.
|
|
966
|
+
*
|
|
967
|
+
* @example
|
|
968
|
+
* ```typescript
|
|
969
|
+
* const { topics, skills, insights } = await soulcraft.chat.getExpertise()
|
|
970
|
+
* console.log('Topics:', topics.join(', '))
|
|
971
|
+
* ```
|
|
972
|
+
*/
|
|
973
|
+
getExpertise(): Promise<{
|
|
974
|
+
topics: string[];
|
|
975
|
+
skills: string[];
|
|
976
|
+
insights: string[];
|
|
977
|
+
}>;
|
|
978
|
+
/**
|
|
979
|
+
* @description Get the AI context summary for Glass Box transparency.
|
|
980
|
+
*
|
|
981
|
+
* Returns the system prompt, available tools, loaded skills, and memory items
|
|
982
|
+
* that the AI currently has access to. This powers the "Glass Box" feature
|
|
983
|
+
* that lets users see exactly what the AI knows and can do.
|
|
984
|
+
*
|
|
985
|
+
* @returns The full AI context.
|
|
986
|
+
*
|
|
987
|
+
* @example
|
|
988
|
+
* ```typescript
|
|
989
|
+
* const ctx = await soulcraft.chat.getContext()
|
|
990
|
+
* console.log(`Tools available: ${ctx.tools.length}`)
|
|
991
|
+
* console.log(`Skills loaded: ${ctx.skills.length}`)
|
|
992
|
+
* ```
|
|
993
|
+
*/
|
|
994
|
+
getContext(): Promise<{
|
|
995
|
+
systemPrompt: string;
|
|
996
|
+
tools: string[];
|
|
997
|
+
skills: string[];
|
|
998
|
+
memory: string[];
|
|
999
|
+
}>;
|
|
1000
|
+
}
|
|
1001
|
+
/**
|
|
1002
|
+
* @description Graph visualization data assembly from Brainy queries.
|
|
1003
|
+
*
|
|
1004
|
+
* Transforms raw Brainy entities and relationships into a format suitable for
|
|
1005
|
+
* graph rendering (Cytoscape.js, D3, etc.). Supports full-graph, focused
|
|
1006
|
+
* subgraph, and neighborhood queries.
|
|
1007
|
+
*
|
|
1008
|
+
* @example
|
|
1009
|
+
* ```typescript
|
|
1010
|
+
* const { nodes, edges } = await soulcraft.graph.getData({ limit: 500 })
|
|
1011
|
+
* renderCytoscapeGraph(nodes, edges)
|
|
1012
|
+
* ```
|
|
1013
|
+
*/
|
|
1014
|
+
export interface GraphNamespace {
|
|
1015
|
+
/**
|
|
1016
|
+
* @description Get the full graph (nodes + edges) for the current workspace.
|
|
1017
|
+
*
|
|
1018
|
+
* @param options - Filtering and pagination options.
|
|
1019
|
+
* @param options.limit - Maximum number of nodes to return. Default: all.
|
|
1020
|
+
* @param options.types - Filter to specific NounTypes (e.g. `['Person', 'Document']`).
|
|
1021
|
+
* @returns Graph data with nodes and edges.
|
|
1022
|
+
*
|
|
1023
|
+
* @example
|
|
1024
|
+
* ```typescript
|
|
1025
|
+
* const graph = await soulcraft.graph.getData({ limit: 200, types: ['Person'] })
|
|
1026
|
+
* console.log(`${graph.nodes.length} people, ${graph.edges.length} relationships`)
|
|
1027
|
+
* ```
|
|
1028
|
+
*/
|
|
1029
|
+
getData(options?: {
|
|
1030
|
+
limit?: number;
|
|
1031
|
+
types?: string[];
|
|
1032
|
+
}): Promise<GraphData>;
|
|
1033
|
+
/**
|
|
1034
|
+
* @description Get aggregate statistics about the workspace's knowledge graph.
|
|
1035
|
+
*
|
|
1036
|
+
* @returns Node/edge counts and type distributions.
|
|
1037
|
+
*
|
|
1038
|
+
* @example
|
|
1039
|
+
* ```typescript
|
|
1040
|
+
* const stats = await soulcraft.graph.getStats()
|
|
1041
|
+
* console.log(`${stats.nodeCount} entities, ${stats.edgeCount} relationships`)
|
|
1042
|
+
* ```
|
|
1043
|
+
*/
|
|
1044
|
+
getStats(): Promise<GraphStats>;
|
|
1045
|
+
/**
|
|
1046
|
+
* @description Get a focused subgraph centered on a specific entity.
|
|
1047
|
+
*
|
|
1048
|
+
* Returns the target entity plus all entities within `depth` hops,
|
|
1049
|
+
* and all relationships between them.
|
|
1050
|
+
*
|
|
1051
|
+
* @param entityId - The center entity's ID.
|
|
1052
|
+
* @param options - Traversal options.
|
|
1053
|
+
* @param options.depth - Maximum traversal depth (number of hops). Default: 2.
|
|
1054
|
+
* @returns The focused subgraph.
|
|
1055
|
+
*
|
|
1056
|
+
* @example
|
|
1057
|
+
* ```typescript
|
|
1058
|
+
* const subgraph = await soulcraft.graph.getFocused('entity-abc', { depth: 3 })
|
|
1059
|
+
* ```
|
|
1060
|
+
*/
|
|
1061
|
+
getFocused(entityId: string, options?: {
|
|
1062
|
+
depth?: number;
|
|
1063
|
+
}): Promise<GraphData>;
|
|
1064
|
+
/**
|
|
1065
|
+
* @description Get the immediate neighbors (1-hop) of an entity.
|
|
1066
|
+
*
|
|
1067
|
+
* Returns the target entity, all directly related entities, and the
|
|
1068
|
+
* relationships connecting them.
|
|
1069
|
+
*
|
|
1070
|
+
* @param entityId - The entity whose neighbors to fetch.
|
|
1071
|
+
* @returns Neighbor nodes and connecting edges.
|
|
1072
|
+
*
|
|
1073
|
+
* @example
|
|
1074
|
+
* ```typescript
|
|
1075
|
+
* const neighbors = await soulcraft.graph.getNeighbors('entity-abc')
|
|
1076
|
+
* console.log(`${neighbors.nodes.length} direct connections`)
|
|
1077
|
+
* ```
|
|
1078
|
+
*/
|
|
1079
|
+
getNeighbors(entityId: string): Promise<GraphData>;
|
|
1080
|
+
/**
|
|
1081
|
+
* @description Batch-fetch graph data for multiple entity IDs.
|
|
1082
|
+
*
|
|
1083
|
+
* Returns all specified entities as nodes and all relationships between them.
|
|
1084
|
+
* Useful for rendering a specific selection of entities.
|
|
1085
|
+
*
|
|
1086
|
+
* @param entityIds - Array of entity IDs to include.
|
|
1087
|
+
* @returns Graph containing the specified entities and their inter-relationships.
|
|
1088
|
+
*
|
|
1089
|
+
* @example
|
|
1090
|
+
* ```typescript
|
|
1091
|
+
* const batch = await soulcraft.graph.getBatch(['id-1', 'id-2', 'id-3'])
|
|
1092
|
+
* ```
|
|
1093
|
+
*/
|
|
1094
|
+
getBatch(entityIds: string[]): Promise<GraphData>;
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* @description Semantic search, unified search (Command Palette), and text highlighting.
|
|
1098
|
+
*
|
|
1099
|
+
* Uses Brainy's vector embeddings for semantic similarity and full-text indices
|
|
1100
|
+
* for keyword matching.
|
|
1101
|
+
*
|
|
1102
|
+
* @example
|
|
1103
|
+
* ```typescript
|
|
1104
|
+
* const results = await soulcraft.search.query('candle making techniques', { limit: 10 })
|
|
1105
|
+
* for (const r of results) console.log(`${r.name} (${r.score.toFixed(2)})`)
|
|
1106
|
+
* ```
|
|
1107
|
+
*/
|
|
1108
|
+
export interface SearchNamespace {
|
|
1109
|
+
/**
|
|
1110
|
+
* @description Execute a semantic search across entities in the workspace.
|
|
1111
|
+
*
|
|
1112
|
+
* Uses vector embeddings to find entities semantically similar to the query,
|
|
1113
|
+
* regardless of exact keyword matches.
|
|
1114
|
+
*
|
|
1115
|
+
* @param query - Natural language search query.
|
|
1116
|
+
* @param options - Search configuration.
|
|
1117
|
+
* @param options.types - Filter to specific NounTypes.
|
|
1118
|
+
* @param options.limit - Maximum results. Default: 20.
|
|
1119
|
+
* @param options.threshold - Minimum similarity score (0–1). Default: 0.0.
|
|
1120
|
+
* @returns Ranked search results with relevance scores.
|
|
1121
|
+
*
|
|
1122
|
+
* @example
|
|
1123
|
+
* ```typescript
|
|
1124
|
+
* const results = await soulcraft.search.query('how to make soy candles', {
|
|
1125
|
+
* types: ['Document', 'Note'],
|
|
1126
|
+
* limit: 5,
|
|
1127
|
+
* })
|
|
1128
|
+
* ```
|
|
1129
|
+
*/
|
|
1130
|
+
query(query: string, options?: {
|
|
1131
|
+
types?: string[];
|
|
1132
|
+
limit?: number;
|
|
1133
|
+
threshold?: number;
|
|
1134
|
+
}): Promise<SearchResult[]>;
|
|
1135
|
+
/**
|
|
1136
|
+
* @description Unified search for the Command Palette — searches entities, files, and commands.
|
|
1137
|
+
*
|
|
1138
|
+
* Provides fast, fuzzy matching suitable for interactive use. Results include
|
|
1139
|
+
* the category (entity, file, or command) in the metadata.
|
|
1140
|
+
*
|
|
1141
|
+
* @param query - Search query (can be partial/fuzzy).
|
|
1142
|
+
* @param options - Search configuration.
|
|
1143
|
+
* @param options.limit - Maximum results. Default: 10.
|
|
1144
|
+
* @param options.categories - Filter to specific categories (e.g. `['entity', 'file']`).
|
|
1145
|
+
* @returns Ranked search results across all categories.
|
|
1146
|
+
*
|
|
1147
|
+
* @example
|
|
1148
|
+
* ```typescript
|
|
1149
|
+
* const results = await soulcraft.search.unified('candle', { limit: 8 })
|
|
1150
|
+
* ```
|
|
1151
|
+
*/
|
|
1152
|
+
unified(query: string, options?: {
|
|
1153
|
+
limit?: number;
|
|
1154
|
+
categories?: string[];
|
|
1155
|
+
}): Promise<SearchResult[]>;
|
|
1156
|
+
/**
|
|
1157
|
+
* @description Get highlighted text matches for a search query within a specific entity.
|
|
1158
|
+
*
|
|
1159
|
+
* Returns the entity's text split into alternating match/non-match segments
|
|
1160
|
+
* for rendering search result previews with highlighted keywords.
|
|
1161
|
+
*
|
|
1162
|
+
* @param entityId - The entity to highlight within.
|
|
1163
|
+
* @param query - The search query to highlight.
|
|
1164
|
+
* @returns Array of text segments with match flags.
|
|
1165
|
+
*
|
|
1166
|
+
* @example
|
|
1167
|
+
* ```typescript
|
|
1168
|
+
* const { highlights } = await soulcraft.search.highlight('entity-abc', 'candle')
|
|
1169
|
+
* // highlights = [{ text: 'How to make ', isMatch: false }, { text: 'candle', isMatch: true }, ...]
|
|
1170
|
+
* ```
|
|
1171
|
+
*/
|
|
1172
|
+
highlight(entityId: string, query: string): Promise<{
|
|
1173
|
+
highlights: Array<{
|
|
1174
|
+
text: string;
|
|
1175
|
+
isMatch: boolean;
|
|
1176
|
+
}>;
|
|
1177
|
+
}>;
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* @description View collection management — named groups of entities used to
|
|
1181
|
+
* filter explore visualizations (graph, board, gallery, timeline, etc.).
|
|
1182
|
+
*
|
|
1183
|
+
* Also manages sample data — demo entities pre-populated for each kit type
|
|
1184
|
+
* so new users see a populated workspace immediately.
|
|
1185
|
+
*
|
|
1186
|
+
* @example
|
|
1187
|
+
* ```typescript
|
|
1188
|
+
* const collections = await soulcraft.collections.list()
|
|
1189
|
+
* const members = await soulcraft.collections.getMembers(collections[0].id)
|
|
1190
|
+
* ```
|
|
1191
|
+
*/
|
|
1192
|
+
export interface CollectionsNamespace {
|
|
1193
|
+
/**
|
|
1194
|
+
* @description List all view collections in the workspace.
|
|
1195
|
+
*
|
|
1196
|
+
* @param options - Filtering options.
|
|
1197
|
+
* @param options.type - Filter by collection type (e.g. `'manual'`, `'smart'`).
|
|
1198
|
+
* @returns All matching collections.
|
|
1199
|
+
*
|
|
1200
|
+
* @example
|
|
1201
|
+
* ```typescript
|
|
1202
|
+
* const collections = await soulcraft.collections.list({ type: 'manual' })
|
|
1203
|
+
* ```
|
|
1204
|
+
*/
|
|
1205
|
+
list(options?: {
|
|
1206
|
+
type?: string;
|
|
1207
|
+
}): Promise<ViewCollection[]>;
|
|
1208
|
+
/**
|
|
1209
|
+
* @description Get a specific collection by ID.
|
|
1210
|
+
*
|
|
1211
|
+
* @param collectionId - The collection's unique identifier.
|
|
1212
|
+
* @returns The collection, or `null` if not found.
|
|
1213
|
+
*
|
|
1214
|
+
* @example
|
|
1215
|
+
* ```typescript
|
|
1216
|
+
* const collection = await soulcraft.collections.get('col-abc123')
|
|
1217
|
+
* ```
|
|
1218
|
+
*/
|
|
1219
|
+
get(collectionId: string): Promise<ViewCollection | null>;
|
|
1220
|
+
/**
|
|
1221
|
+
* @description Create a new view collection.
|
|
1222
|
+
*
|
|
1223
|
+
* @param options - Collection properties.
|
|
1224
|
+
* @param options.name - Display name for the collection.
|
|
1225
|
+
* @param options.type - Collection type (e.g. `'manual'`).
|
|
1226
|
+
* @param options.metadata - Additional metadata (filter criteria, display settings).
|
|
1227
|
+
* @returns The newly created collection.
|
|
1228
|
+
*
|
|
1229
|
+
* @example
|
|
1230
|
+
* ```typescript
|
|
1231
|
+
* const col = await soulcraft.collections.create({ name: 'Key People', type: 'manual' })
|
|
1232
|
+
* ```
|
|
1233
|
+
*/
|
|
1234
|
+
create(options: {
|
|
1235
|
+
name: string;
|
|
1236
|
+
type: string;
|
|
1237
|
+
metadata?: Record<string, unknown>;
|
|
1238
|
+
}): Promise<ViewCollection>;
|
|
1239
|
+
/**
|
|
1240
|
+
* @description Update a collection's name or metadata.
|
|
1241
|
+
*
|
|
1242
|
+
* @param collectionId - The collection to update.
|
|
1243
|
+
* @param updates - Fields to update (only provided fields are changed).
|
|
1244
|
+
* @returns The updated collection.
|
|
1245
|
+
*
|
|
1246
|
+
* @example
|
|
1247
|
+
* ```typescript
|
|
1248
|
+
* await soulcraft.collections.update('col-abc', { name: 'Important People' })
|
|
1249
|
+
* ```
|
|
1250
|
+
*/
|
|
1251
|
+
update(collectionId: string, updates: {
|
|
1252
|
+
name?: string;
|
|
1253
|
+
metadata?: Record<string, unknown>;
|
|
1254
|
+
}): Promise<ViewCollection>;
|
|
1255
|
+
/**
|
|
1256
|
+
* @description Delete a collection. Does not delete the member entities themselves.
|
|
1257
|
+
*
|
|
1258
|
+
* @param collectionId - The collection to delete.
|
|
1259
|
+
*
|
|
1260
|
+
* @example
|
|
1261
|
+
* ```typescript
|
|
1262
|
+
* await soulcraft.collections.delete('col-abc123')
|
|
1263
|
+
* ```
|
|
1264
|
+
*/
|
|
1265
|
+
delete(collectionId: string): Promise<void>;
|
|
1266
|
+
/**
|
|
1267
|
+
* @description Get the entities that belong to a collection.
|
|
1268
|
+
*
|
|
1269
|
+
* @param collectionId - The collection whose members to list.
|
|
1270
|
+
* @returns Array of member entity summaries.
|
|
1271
|
+
*
|
|
1272
|
+
* @example
|
|
1273
|
+
* ```typescript
|
|
1274
|
+
* const members = await soulcraft.collections.getMembers('col-abc')
|
|
1275
|
+
* console.log(`${members.length} entities in collection`)
|
|
1276
|
+
* ```
|
|
1277
|
+
*/
|
|
1278
|
+
getMembers(collectionId: string): Promise<Array<{
|
|
1279
|
+
id: string;
|
|
1280
|
+
name: string;
|
|
1281
|
+
type: string;
|
|
1282
|
+
}>>;
|
|
1283
|
+
/**
|
|
1284
|
+
* @description Add an entity to a collection.
|
|
1285
|
+
*
|
|
1286
|
+
* @param collectionId - The collection to add to.
|
|
1287
|
+
* @param entityId - The entity to add.
|
|
1288
|
+
*
|
|
1289
|
+
* @example
|
|
1290
|
+
* ```typescript
|
|
1291
|
+
* await soulcraft.collections.addMember('col-abc', 'entity-xyz')
|
|
1292
|
+
* ```
|
|
1293
|
+
*/
|
|
1294
|
+
addMember(collectionId: string, entityId: string): Promise<void>;
|
|
1295
|
+
/**
|
|
1296
|
+
* @description Remove an entity from a collection. Does not delete the entity itself.
|
|
1297
|
+
*
|
|
1298
|
+
* @param collectionId - The collection to remove from.
|
|
1299
|
+
* @param entityId - The entity to remove.
|
|
1300
|
+
*
|
|
1301
|
+
* @example
|
|
1302
|
+
* ```typescript
|
|
1303
|
+
* await soulcraft.collections.removeMember('col-abc', 'entity-xyz')
|
|
1304
|
+
* ```
|
|
1305
|
+
*/
|
|
1306
|
+
removeMember(collectionId: string, entityId: string): Promise<void>;
|
|
1307
|
+
/**
|
|
1308
|
+
* @description Load sample data for a kit, populating the workspace with demo entities.
|
|
1309
|
+
*
|
|
1310
|
+
* Idempotent — calling again after sample data exists is a no-op.
|
|
1311
|
+
*
|
|
1312
|
+
* @param kitId - The kit whose sample data to load.
|
|
1313
|
+
* @returns The number of entities created.
|
|
1314
|
+
*
|
|
1315
|
+
* @example
|
|
1316
|
+
* ```typescript
|
|
1317
|
+
* const { count } = await soulcraft.collections.loadSampleData('wicks-and-whiskers')
|
|
1318
|
+
* console.log(`Created ${count} sample entities`)
|
|
1319
|
+
* ```
|
|
1320
|
+
*/
|
|
1321
|
+
loadSampleData(kitId: string): Promise<{
|
|
1322
|
+
count: number;
|
|
1323
|
+
}>;
|
|
1324
|
+
/**
|
|
1325
|
+
* @description Clear all sample data from the workspace.
|
|
1326
|
+
*
|
|
1327
|
+
* Removes only entities flagged as sample data — user-created entities are
|
|
1328
|
+
* never affected.
|
|
1329
|
+
*
|
|
1330
|
+
* @example
|
|
1331
|
+
* ```typescript
|
|
1332
|
+
* await soulcraft.collections.clearSampleData()
|
|
1333
|
+
* ```
|
|
1334
|
+
*/
|
|
1335
|
+
clearSampleData(): Promise<void>;
|
|
1336
|
+
}
|
|
1337
|
+
/**
|
|
1338
|
+
* @description Code annotation CRUD with AI-powered explanations.
|
|
1339
|
+
*
|
|
1340
|
+
* Annotations are developer notes attached to specific line ranges in VFS files.
|
|
1341
|
+
* The Illuminate feature uses AI to generate explanations of selected code.
|
|
1342
|
+
*
|
|
1343
|
+
* @example
|
|
1344
|
+
* ```typescript
|
|
1345
|
+
* const annotations = await soulcraft.annotations.list('/src/server.ts')
|
|
1346
|
+
* const { explanation } = await soulcraft.annotations.aiExplain({
|
|
1347
|
+
* filePath: '/src/server.ts', lineStart: 10, lineEnd: 25, code: '...'
|
|
1348
|
+
* })
|
|
1349
|
+
* ```
|
|
1350
|
+
*/
|
|
1351
|
+
export interface AnnotationsNamespace {
|
|
1352
|
+
/**
|
|
1353
|
+
* @description List all annotations for a specific file.
|
|
1354
|
+
*
|
|
1355
|
+
* @param filePath - VFS file path (e.g. `'/src/server.ts'`).
|
|
1356
|
+
* @returns All annotations attached to the file, ordered by line number.
|
|
1357
|
+
*
|
|
1358
|
+
* @example
|
|
1359
|
+
* ```typescript
|
|
1360
|
+
* const annotations = await soulcraft.annotations.list('/src/lib/utils.ts')
|
|
1361
|
+
* ```
|
|
1362
|
+
*/
|
|
1363
|
+
list(filePath: string): Promise<Annotation[]>;
|
|
1364
|
+
/**
|
|
1365
|
+
* @description Get a specific annotation by ID.
|
|
1366
|
+
*
|
|
1367
|
+
* @param annotationId - The annotation's unique identifier.
|
|
1368
|
+
* @returns The annotation, or `null` if not found.
|
|
1369
|
+
*
|
|
1370
|
+
* @example
|
|
1371
|
+
* ```typescript
|
|
1372
|
+
* const annotation = await soulcraft.annotations.get('ann-abc123')
|
|
1373
|
+
* ```
|
|
1374
|
+
*/
|
|
1375
|
+
get(annotationId: string): Promise<Annotation | null>;
|
|
1376
|
+
/**
|
|
1377
|
+
* @description Create a new annotation on a file.
|
|
1378
|
+
*
|
|
1379
|
+
* @param options - Annotation properties.
|
|
1380
|
+
* @param options.filePath - VFS file path to annotate.
|
|
1381
|
+
* @param options.lineStart - First line of the annotated range (1-based).
|
|
1382
|
+
* @param options.lineEnd - Last line of the annotated range (1-based, inclusive).
|
|
1383
|
+
* @param options.content - The annotation text (Markdown supported).
|
|
1384
|
+
* @param options.type - Annotation type (e.g. `'note'`, `'question'`). Default: `'note'`.
|
|
1385
|
+
* @returns The created annotation.
|
|
1386
|
+
*
|
|
1387
|
+
* @example
|
|
1388
|
+
* ```typescript
|
|
1389
|
+
* const ann = await soulcraft.annotations.create({
|
|
1390
|
+
* filePath: '/src/server.ts',
|
|
1391
|
+
* lineStart: 42,
|
|
1392
|
+
* lineEnd: 55,
|
|
1393
|
+
* content: 'This function handles the Brainy cold start timeout.',
|
|
1394
|
+
* })
|
|
1395
|
+
* ```
|
|
1396
|
+
*/
|
|
1397
|
+
create(options: {
|
|
1398
|
+
filePath: string;
|
|
1399
|
+
lineStart: number;
|
|
1400
|
+
lineEnd: number;
|
|
1401
|
+
content: string;
|
|
1402
|
+
type?: string;
|
|
1403
|
+
}): Promise<Annotation>;
|
|
1404
|
+
/**
|
|
1405
|
+
* @description Update an existing annotation's content or type.
|
|
1406
|
+
*
|
|
1407
|
+
* @param annotationId - The annotation to update.
|
|
1408
|
+
* @param updates - Fields to update (only provided fields are changed).
|
|
1409
|
+
* @returns The updated annotation.
|
|
1410
|
+
*
|
|
1411
|
+
* @example
|
|
1412
|
+
* ```typescript
|
|
1413
|
+
* await soulcraft.annotations.update('ann-abc', { content: 'Updated explanation' })
|
|
1414
|
+
* ```
|
|
1415
|
+
*/
|
|
1416
|
+
update(annotationId: string, updates: {
|
|
1417
|
+
content?: string;
|
|
1418
|
+
type?: string;
|
|
1419
|
+
}): Promise<Annotation>;
|
|
1420
|
+
/**
|
|
1421
|
+
* @description Delete an annotation permanently.
|
|
1422
|
+
*
|
|
1423
|
+
* @param annotationId - The annotation to delete.
|
|
1424
|
+
*
|
|
1425
|
+
* @example
|
|
1426
|
+
* ```typescript
|
|
1427
|
+
* await soulcraft.annotations.delete('ann-abc123')
|
|
1428
|
+
* ```
|
|
1429
|
+
*/
|
|
1430
|
+
delete(annotationId: string): Promise<void>;
|
|
1431
|
+
/**
|
|
1432
|
+
* @description Generate an AI explanation for a selected code range.
|
|
1433
|
+
*
|
|
1434
|
+
* Uses Claude to analyze the code and produce a clear, educational explanation.
|
|
1435
|
+
* The explanation is returned but NOT automatically saved as an annotation.
|
|
1436
|
+
*
|
|
1437
|
+
* @param options - The code selection to explain.
|
|
1438
|
+
* @param options.filePath - VFS file path containing the code.
|
|
1439
|
+
* @param options.lineStart - First line of the selection.
|
|
1440
|
+
* @param options.lineEnd - Last line of the selection.
|
|
1441
|
+
* @param options.code - The actual source code text to explain.
|
|
1442
|
+
* @returns The AI-generated explanation.
|
|
1443
|
+
*
|
|
1444
|
+
* @example
|
|
1445
|
+
* ```typescript
|
|
1446
|
+
* const { explanation } = await soulcraft.annotations.aiExplain({
|
|
1447
|
+
* filePath: '/src/server.ts',
|
|
1448
|
+
* lineStart: 42, lineEnd: 55,
|
|
1449
|
+
* code: 'export default { port: PORT, fetch: app.fetch, idleTimeout: 255 }',
|
|
1450
|
+
* })
|
|
1451
|
+
* ```
|
|
1452
|
+
*/
|
|
1453
|
+
aiExplain(options: {
|
|
1454
|
+
filePath: string;
|
|
1455
|
+
lineStart: number;
|
|
1456
|
+
lineEnd: number;
|
|
1457
|
+
code: string;
|
|
1458
|
+
}): Promise<{
|
|
1459
|
+
explanation: string;
|
|
1460
|
+
}>;
|
|
1461
|
+
}
|
|
1462
|
+
/**
|
|
1463
|
+
* @description Workspace CRUD, backup/restore, Venue connection, settings, and health checks.
|
|
1464
|
+
*
|
|
1465
|
+
* A workspace is an isolated Brainy instance + VFS store. Each user can have
|
|
1466
|
+
* multiple workspaces, optionally initialized from a kit template.
|
|
1467
|
+
*
|
|
1468
|
+
* @example
|
|
1469
|
+
* ```typescript
|
|
1470
|
+
* const workspaces = await soulcraft.workspace.list()
|
|
1471
|
+
* const status = await soulcraft.workspace.getStatus()
|
|
1472
|
+
* if (status.status === 'ready') console.log(`${status.entityCount} entities`)
|
|
1473
|
+
* ```
|
|
1474
|
+
*/
|
|
1475
|
+
export interface WorkspaceNamespace {
|
|
1476
|
+
/**
|
|
1477
|
+
* @description List all workspaces for the current user.
|
|
1478
|
+
*
|
|
1479
|
+
* @returns Array of workspace metadata.
|
|
1480
|
+
*
|
|
1481
|
+
* @example
|
|
1482
|
+
* ```typescript
|
|
1483
|
+
* const workspaces = await soulcraft.workspace.list()
|
|
1484
|
+
* for (const ws of workspaces) console.log(`${ws.name} (${ws.entityCount} entities)`)
|
|
1485
|
+
* ```
|
|
1486
|
+
*/
|
|
1487
|
+
list(): Promise<WorkspaceInfo[]>;
|
|
1488
|
+
/**
|
|
1489
|
+
* @description Get a specific workspace by ID.
|
|
1490
|
+
*
|
|
1491
|
+
* @param workspaceId - The workspace's unique identifier.
|
|
1492
|
+
* @returns The workspace metadata, or `null` if not found.
|
|
1493
|
+
*
|
|
1494
|
+
* @example
|
|
1495
|
+
* ```typescript
|
|
1496
|
+
* const ws = await soulcraft.workspace.get('ws-abc123')
|
|
1497
|
+
* ```
|
|
1498
|
+
*/
|
|
1499
|
+
get(workspaceId: string): Promise<WorkspaceInfo | null>;
|
|
1500
|
+
/**
|
|
1501
|
+
* @description Create a new workspace, optionally from a kit template.
|
|
1502
|
+
*
|
|
1503
|
+
* When `kitId` is provided, the workspace is initialized with the kit's
|
|
1504
|
+
* starter files, entity types, and AI skills.
|
|
1505
|
+
*
|
|
1506
|
+
* @param options - Workspace creation options.
|
|
1507
|
+
* @param options.name - Display name for the workspace.
|
|
1508
|
+
* @param options.kitId - Kit to initialize from (e.g. `'wicks-and-whiskers'`).
|
|
1509
|
+
* @returns The newly created workspace metadata.
|
|
1510
|
+
*
|
|
1511
|
+
* @example
|
|
1512
|
+
* ```typescript
|
|
1513
|
+
* const ws = await soulcraft.workspace.create({ name: 'My Candle Shop', kitId: 'wicks-and-whiskers' })
|
|
1514
|
+
* ```
|
|
1515
|
+
*/
|
|
1516
|
+
create(options: {
|
|
1517
|
+
name: string;
|
|
1518
|
+
kitId?: string;
|
|
1519
|
+
}): Promise<WorkspaceInfo>;
|
|
1520
|
+
/**
|
|
1521
|
+
* @description Update workspace metadata (currently only the name).
|
|
1522
|
+
*
|
|
1523
|
+
* @param workspaceId - The workspace to update.
|
|
1524
|
+
* @param updates - Fields to update.
|
|
1525
|
+
* @returns The updated workspace metadata.
|
|
1526
|
+
*
|
|
1527
|
+
* @example
|
|
1528
|
+
* ```typescript
|
|
1529
|
+
* await soulcraft.workspace.update('ws-abc', { name: 'Candle Empire' })
|
|
1530
|
+
* ```
|
|
1531
|
+
*/
|
|
1532
|
+
update(workspaceId: string, updates: {
|
|
1533
|
+
name?: string;
|
|
1534
|
+
}): Promise<WorkspaceInfo>;
|
|
1535
|
+
/**
|
|
1536
|
+
* @description Delete a workspace and all its data permanently.
|
|
1537
|
+
*
|
|
1538
|
+
* This removes all entities, files, versions, and settings. Cannot be undone.
|
|
1539
|
+
*
|
|
1540
|
+
* @param workspaceId - The workspace to delete.
|
|
1541
|
+
*
|
|
1542
|
+
* @example
|
|
1543
|
+
* ```typescript
|
|
1544
|
+
* await soulcraft.workspace.delete('ws-abc123')
|
|
1545
|
+
* ```
|
|
1546
|
+
*/
|
|
1547
|
+
delete(workspaceId: string): Promise<void>;
|
|
1548
|
+
/**
|
|
1549
|
+
* @description Get the workspace's current health and initialization status.
|
|
1550
|
+
*
|
|
1551
|
+
* Use this to check if the Brainy instance is ready before making data calls.
|
|
1552
|
+
* During cold start, status will be `'initializing'` for up to ~25 seconds.
|
|
1553
|
+
*
|
|
1554
|
+
* @returns The workspace status.
|
|
1555
|
+
*
|
|
1556
|
+
* @example
|
|
1557
|
+
* ```typescript
|
|
1558
|
+
* const status = await soulcraft.workspace.getStatus()
|
|
1559
|
+
* if (status.status === 'initializing') showSpinner('Loading workspace...')
|
|
1560
|
+
* ```
|
|
1561
|
+
*/
|
|
1562
|
+
getStatus(): Promise<WorkspaceStatus>;
|
|
1563
|
+
/**
|
|
1564
|
+
* @description Create a downloadable backup of the entire workspace.
|
|
1565
|
+
*
|
|
1566
|
+
* The backup includes all entities, relationships, VFS files, and settings.
|
|
1567
|
+
*
|
|
1568
|
+
* @returns A download URL and the backup size in bytes.
|
|
1569
|
+
*
|
|
1570
|
+
* @example
|
|
1571
|
+
* ```typescript
|
|
1572
|
+
* const { downloadUrl, size } = await soulcraft.workspace.backup()
|
|
1573
|
+
* console.log(`Backup ready: ${(size / 1024 / 1024).toFixed(1)} MB`)
|
|
1574
|
+
* ```
|
|
1575
|
+
*/
|
|
1576
|
+
backup(): Promise<{
|
|
1577
|
+
downloadUrl: string;
|
|
1578
|
+
size: number;
|
|
1579
|
+
}>;
|
|
1580
|
+
/**
|
|
1581
|
+
* @description Restore a workspace from a backup archive.
|
|
1582
|
+
*
|
|
1583
|
+
* Replaces all current workspace data with the backup contents.
|
|
1584
|
+
*
|
|
1585
|
+
* @param backupData - The backup archive as raw binary data.
|
|
1586
|
+
* @returns Counts of restored entities and files.
|
|
1587
|
+
*
|
|
1588
|
+
* @example
|
|
1589
|
+
* ```typescript
|
|
1590
|
+
* const backupBytes = await fetch(backupUrl).then(r => r.arrayBuffer())
|
|
1591
|
+
* const { entityCount, fileCount } = await soulcraft.workspace.restore(backupBytes)
|
|
1592
|
+
* ```
|
|
1593
|
+
*/
|
|
1594
|
+
restore(backupData: ArrayBuffer | Uint8Array): Promise<{
|
|
1595
|
+
entityCount: number;
|
|
1596
|
+
fileCount: number;
|
|
1597
|
+
}>;
|
|
1598
|
+
/**
|
|
1599
|
+
* @description Connect the workspace to a Venue site for live deployment.
|
|
1600
|
+
*
|
|
1601
|
+
* @param options - Venue connection details.
|
|
1602
|
+
* @param options.venueHandle - The Venue organization handle (e.g. `'acme-candles'`).
|
|
1603
|
+
* @param options.venueSlug - The Venue site slug (e.g. `'main'`).
|
|
1604
|
+
*
|
|
1605
|
+
* @example
|
|
1606
|
+
* ```typescript
|
|
1607
|
+
* await soulcraft.workspace.connectVenue({ venueHandle: 'acme-candles', venueSlug: 'main' })
|
|
1608
|
+
* ```
|
|
1609
|
+
*/
|
|
1610
|
+
connectVenue(options: {
|
|
1611
|
+
venueHandle: string;
|
|
1612
|
+
venueSlug: string;
|
|
1613
|
+
}): Promise<void>;
|
|
1614
|
+
/**
|
|
1615
|
+
* @description Get workspace-level settings (kit config, AI preferences, display options).
|
|
1616
|
+
*
|
|
1617
|
+
* @returns Key-value settings object.
|
|
1618
|
+
*
|
|
1619
|
+
* @example
|
|
1620
|
+
* ```typescript
|
|
1621
|
+
* const settings = await soulcraft.workspace.getSettings()
|
|
1622
|
+
* console.log('AI model:', settings.preferredModel)
|
|
1623
|
+
* ```
|
|
1624
|
+
*/
|
|
1625
|
+
getSettings(): Promise<Record<string, unknown>>;
|
|
1626
|
+
/**
|
|
1627
|
+
* @description Update workspace settings. Merges with existing settings.
|
|
1628
|
+
*
|
|
1629
|
+
* @param settings - Key-value pairs to merge into the current settings.
|
|
1630
|
+
*
|
|
1631
|
+
* @example
|
|
1632
|
+
* ```typescript
|
|
1633
|
+
* await soulcraft.workspace.updateSettings({ preferredModel: 'claude-sonnet-4-6' })
|
|
1634
|
+
* ```
|
|
1635
|
+
*/
|
|
1636
|
+
updateSettings(settings: Record<string, unknown>): Promise<void>;
|
|
1637
|
+
/**
|
|
1638
|
+
* @description Run a health check on the Brainy instance.
|
|
1639
|
+
*
|
|
1640
|
+
* Returns the instance status and round-trip latency in milliseconds.
|
|
1641
|
+
*
|
|
1642
|
+
* @returns Health status and latency.
|
|
1643
|
+
*
|
|
1644
|
+
* @example
|
|
1645
|
+
* ```typescript
|
|
1646
|
+
* const { status, latencyMs } = await soulcraft.workspace.healthCheck()
|
|
1647
|
+
* console.log(`Brainy is ${status}, latency: ${latencyMs}ms`)
|
|
1648
|
+
* ```
|
|
1649
|
+
*/
|
|
1650
|
+
healthCheck(): Promise<{
|
|
1651
|
+
status: 'ok' | 'error';
|
|
1652
|
+
latencyMs: number;
|
|
1653
|
+
}>;
|
|
1654
|
+
}
|
|
1655
|
+
/**
|
|
1656
|
+
* @description Publishing — create Living Links for sharing, deploy to Venue sites,
|
|
1657
|
+
* and publish content to Academy as courses.
|
|
1658
|
+
*
|
|
1659
|
+
* @example
|
|
1660
|
+
* ```typescript
|
|
1661
|
+
* const link = await soulcraft.publish.createLink({ type: 'website', slug: 'my-project' })
|
|
1662
|
+
* console.log(`Published at: ${link.url}`)
|
|
1663
|
+
* ```
|
|
1664
|
+
*/
|
|
1665
|
+
export interface PublishNamespace {
|
|
1666
|
+
/**
|
|
1667
|
+
* @description Create a Living Link for sharing workspace content publicly.
|
|
1668
|
+
*
|
|
1669
|
+
* @param options - Link configuration.
|
|
1670
|
+
* @param options.type - Content type: `'website'`, `'document'`, `'app'`, `'slideshow'`.
|
|
1671
|
+
* @param options.slug - URL-safe slug. Auto-generated if omitted.
|
|
1672
|
+
* @param options.entityIds - Specific entities to include. All entities if omitted.
|
|
1673
|
+
* @param options.expiresIn - Link expiration in seconds. Permanent if omitted.
|
|
1674
|
+
* @returns The created link with its public URL.
|
|
1675
|
+
*
|
|
1676
|
+
* @example
|
|
1677
|
+
* ```typescript
|
|
1678
|
+
* const link = await soulcraft.publish.createLink({
|
|
1679
|
+
* type: 'website',
|
|
1680
|
+
* slug: 'candle-catalog',
|
|
1681
|
+
* expiresIn: 86400 * 30, // 30 days
|
|
1682
|
+
* })
|
|
1683
|
+
* ```
|
|
1684
|
+
*/
|
|
1685
|
+
createLink(options: {
|
|
1686
|
+
type: string;
|
|
1687
|
+
slug?: string;
|
|
1688
|
+
entityIds?: string[];
|
|
1689
|
+
expiresIn?: number;
|
|
1690
|
+
}): Promise<PublishedLink>;
|
|
1691
|
+
/**
|
|
1692
|
+
* @description Get an existing published link by ID.
|
|
1693
|
+
*
|
|
1694
|
+
* @param linkId - The link's unique identifier.
|
|
1695
|
+
* @returns The link metadata, or `null` if not found or expired.
|
|
1696
|
+
*
|
|
1697
|
+
* @example
|
|
1698
|
+
* ```typescript
|
|
1699
|
+
* const link = await soulcraft.publish.getLink('link-abc123')
|
|
1700
|
+
* ```
|
|
1701
|
+
*/
|
|
1702
|
+
getLink(linkId: string): Promise<PublishedLink | null>;
|
|
1703
|
+
/**
|
|
1704
|
+
* @description Delete a published link, making the URL inactive.
|
|
1705
|
+
*
|
|
1706
|
+
* @param linkId - The link to delete.
|
|
1707
|
+
*
|
|
1708
|
+
* @example
|
|
1709
|
+
* ```typescript
|
|
1710
|
+
* await soulcraft.publish.deleteLink('link-abc123')
|
|
1711
|
+
* ```
|
|
1712
|
+
*/
|
|
1713
|
+
deleteLink(linkId: string): Promise<void>;
|
|
1714
|
+
/**
|
|
1715
|
+
* @description List all published links for the current workspace.
|
|
1716
|
+
*
|
|
1717
|
+
* @returns All active links.
|
|
1718
|
+
*
|
|
1719
|
+
* @example
|
|
1720
|
+
* ```typescript
|
|
1721
|
+
* const links = await soulcraft.publish.listLinks()
|
|
1722
|
+
* ```
|
|
1723
|
+
*/
|
|
1724
|
+
listLinks(): Promise<PublishedLink[]>;
|
|
1725
|
+
/**
|
|
1726
|
+
* @description Check if a URL slug is available for a new link.
|
|
1727
|
+
*
|
|
1728
|
+
* @param slug - The slug to check.
|
|
1729
|
+
* @returns Whether the slug is available.
|
|
1730
|
+
*
|
|
1731
|
+
* @example
|
|
1732
|
+
* ```typescript
|
|
1733
|
+
* const { available } = await soulcraft.publish.checkSlug('candle-catalog')
|
|
1734
|
+
* if (!available) console.log('Slug already taken')
|
|
1735
|
+
* ```
|
|
1736
|
+
*/
|
|
1737
|
+
checkSlug(slug: string): Promise<{
|
|
1738
|
+
available: boolean;
|
|
1739
|
+
}>;
|
|
1740
|
+
/**
|
|
1741
|
+
* @description Get project info relevant for publishing decisions.
|
|
1742
|
+
*
|
|
1743
|
+
* @returns Project name, kit, and content counts.
|
|
1744
|
+
*
|
|
1745
|
+
* @example
|
|
1746
|
+
* ```typescript
|
|
1747
|
+
* const info = await soulcraft.publish.getProjectInfo()
|
|
1748
|
+
* console.log(`Publishing "${info.name}" with ${info.entityCount} entities`)
|
|
1749
|
+
* ```
|
|
1750
|
+
*/
|
|
1751
|
+
getProjectInfo(): Promise<{
|
|
1752
|
+
name: string;
|
|
1753
|
+
kitId: string;
|
|
1754
|
+
entityCount: number;
|
|
1755
|
+
fileCount: number;
|
|
1756
|
+
}>;
|
|
1757
|
+
/**
|
|
1758
|
+
* @description Deploy the workspace as a Svelte Component Archive (SCA) to a Venue site.
|
|
1759
|
+
*
|
|
1760
|
+
* Bundles all workspace content and deploys it to the specified Venue site.
|
|
1761
|
+
* The deploy secret authenticates the Workshop server to the Venue server.
|
|
1762
|
+
*
|
|
1763
|
+
* @param options - Venue deployment configuration.
|
|
1764
|
+
* @param options.venueHandle - Venue organization handle.
|
|
1765
|
+
* @param options.venueSlug - Venue site slug.
|
|
1766
|
+
* @param options.deploySecret - Server-to-server deploy authentication secret.
|
|
1767
|
+
* @returns The deployed URL and timestamp.
|
|
1768
|
+
*
|
|
1769
|
+
* @example
|
|
1770
|
+
* ```typescript
|
|
1771
|
+
* const { url } = await soulcraft.publish.deployToVenue({
|
|
1772
|
+
* venueHandle: 'acme-candles', venueSlug: 'main', deploySecret: DEPLOY_SECRET,
|
|
1773
|
+
* })
|
|
1774
|
+
* ```
|
|
1775
|
+
*/
|
|
1776
|
+
deployToVenue(options: {
|
|
1777
|
+
venueHandle: string;
|
|
1778
|
+
venueSlug: string;
|
|
1779
|
+
deploySecret: string;
|
|
1780
|
+
}): Promise<{
|
|
1781
|
+
url: string;
|
|
1782
|
+
deployedAt: string;
|
|
1783
|
+
}>;
|
|
1784
|
+
/**
|
|
1785
|
+
* @description Publish workspace content to Academy as a course.
|
|
1786
|
+
*
|
|
1787
|
+
* Projects are mapped to courses: each WDOC file becomes a lesson, each
|
|
1788
|
+
* WQUIZ file becomes an assessment.
|
|
1789
|
+
*
|
|
1790
|
+
* @param options - Academy publish configuration.
|
|
1791
|
+
* @param options.academyUrl - Academy server URL.
|
|
1792
|
+
* @param options.publishSecret - Server-to-server authentication secret.
|
|
1793
|
+
* @param options.courseTitle - Override the course title (defaults to project name).
|
|
1794
|
+
* @param options.lessonIds - Cherry-pick specific entity IDs as lessons (all if omitted).
|
|
1795
|
+
* @returns The created course ID and URL.
|
|
1796
|
+
*
|
|
1797
|
+
* @example
|
|
1798
|
+
* ```typescript
|
|
1799
|
+
* const { courseId, url } = await soulcraft.publish.publishToAcademy({
|
|
1800
|
+
* academyUrl: 'https://academy.soulcraft.com',
|
|
1801
|
+
* publishSecret: ACADEMY_SECRET,
|
|
1802
|
+
* })
|
|
1803
|
+
* ```
|
|
1804
|
+
*/
|
|
1805
|
+
publishToAcademy(options: {
|
|
1806
|
+
academyUrl: string;
|
|
1807
|
+
publishSecret: string;
|
|
1808
|
+
courseTitle?: string;
|
|
1809
|
+
lessonIds?: string[];
|
|
1810
|
+
}): Promise<{
|
|
1811
|
+
courseId: string;
|
|
1812
|
+
url: string;
|
|
1813
|
+
}>;
|
|
1814
|
+
/**
|
|
1815
|
+
* @description Unified publish — send workspace content to any registered destination.
|
|
1816
|
+
*
|
|
1817
|
+
* This is the recommended high-level API for publishing. The server resolves the
|
|
1818
|
+
* destination's URL and authentication from its configuration — the client only
|
|
1819
|
+
* specifies the destination name and content options. Server-to-server secrets
|
|
1820
|
+
* are never exposed to the client.
|
|
1821
|
+
*
|
|
1822
|
+
* @param destination - Target product: `'venue'` (deploy as app), `'academy'` (publish as course).
|
|
1823
|
+
* @param options - Destination-specific publish options.
|
|
1824
|
+
* @param options.handle - Venue org handle (required for `'venue'`).
|
|
1825
|
+
* @param options.slug - Venue site slug (required for `'venue'`).
|
|
1826
|
+
* @param options.courseTitle - Override course title (optional for `'academy'`).
|
|
1827
|
+
* @param options.entityIds - Cherry-pick specific entities to publish. All entities if omitted.
|
|
1828
|
+
* @returns The published URL and destination-specific metadata.
|
|
1829
|
+
*
|
|
1830
|
+
* @example Publish to Venue
|
|
1831
|
+
* ```typescript
|
|
1832
|
+
* const result = await soulcraft.publish.to('venue', {
|
|
1833
|
+
* handle: 'acme-candles',
|
|
1834
|
+
* slug: 'main',
|
|
1835
|
+
* })
|
|
1836
|
+
* console.log(`Deployed: ${result.url}`)
|
|
1837
|
+
* ```
|
|
1838
|
+
*
|
|
1839
|
+
* @example Publish to Academy
|
|
1840
|
+
* ```typescript
|
|
1841
|
+
* const result = await soulcraft.publish.to('academy', {
|
|
1842
|
+
* courseTitle: 'Candle Making 101',
|
|
1843
|
+
* })
|
|
1844
|
+
* console.log(`Course: ${result.url}`)
|
|
1845
|
+
* ```
|
|
1846
|
+
*/
|
|
1847
|
+
to(destination: 'venue' | 'academy', options?: {
|
|
1848
|
+
handle?: string;
|
|
1849
|
+
slug?: string;
|
|
1850
|
+
courseTitle?: string;
|
|
1851
|
+
entityIds?: string[];
|
|
1852
|
+
}): Promise<{
|
|
1853
|
+
url: string;
|
|
1854
|
+
destinationId?: string;
|
|
1855
|
+
publishedAt: string;
|
|
1856
|
+
}>;
|
|
1857
|
+
}
|
|
1858
|
+
/**
|
|
1859
|
+
* @description File import with streaming progress — smart file upload and structured
|
|
1860
|
+
* data import (JSON, CSV, GraphML, GEXF, DOT, OPML, Obsidian, Turtle, JSON-LD, etc.).
|
|
1861
|
+
*
|
|
1862
|
+
* Both `uploadFiles` and `importData` return async iterables that stream
|
|
1863
|
+
* {@link ImportProgress} events as the import pipeline processes each phase.
|
|
1864
|
+
*
|
|
1865
|
+
* @example
|
|
1866
|
+
* ```typescript
|
|
1867
|
+
* for await (const progress of soulcraft.import.uploadFiles(files)) {
|
|
1868
|
+
* updateProgressBar(progress.current, progress.total, progress.phase)
|
|
1869
|
+
* }
|
|
1870
|
+
* ```
|
|
1871
|
+
*/
|
|
1872
|
+
export interface ImportNamespace {
|
|
1873
|
+
/**
|
|
1874
|
+
* @description Upload files for smart import with streaming progress.
|
|
1875
|
+
*
|
|
1876
|
+
* The server auto-detects file types and creates appropriate entities
|
|
1877
|
+
* (documents, images, code files, etc.). Progress is streamed as SSE.
|
|
1878
|
+
*
|
|
1879
|
+
* @param files - Array of files to import.
|
|
1880
|
+
* @returns An async iterable of {@link ImportProgress} events.
|
|
1881
|
+
*
|
|
1882
|
+
* @example
|
|
1883
|
+
* ```typescript
|
|
1884
|
+
* const files = [{ name: 'notes.md', content: '# My Notes\n...', mimeType: 'text/markdown' }]
|
|
1885
|
+
* for await (const p of soulcraft.import.uploadFiles(files)) {
|
|
1886
|
+
* console.log(`${p.phase}: ${p.current}/${p.total}`)
|
|
1887
|
+
* }
|
|
1888
|
+
* ```
|
|
1889
|
+
*/
|
|
1890
|
+
uploadFiles(files: Array<{
|
|
1891
|
+
name: string;
|
|
1892
|
+
content: string | ArrayBuffer;
|
|
1893
|
+
mimeType: string;
|
|
1894
|
+
}>): AsyncIterable<ImportProgress>;
|
|
1895
|
+
/**
|
|
1896
|
+
* @description Import structured data in a knowledge graph format.
|
|
1897
|
+
*
|
|
1898
|
+
* Parses the input data according to the specified format and creates
|
|
1899
|
+
* entities and relationships in the workspace.
|
|
1900
|
+
*
|
|
1901
|
+
* @param options - Import configuration.
|
|
1902
|
+
* @param options.format - Source format ID (e.g. `'json'`, `'csv'`, `'graphml'`, `'gexf'`, `'dot'`).
|
|
1903
|
+
* @param options.data - The raw data to import.
|
|
1904
|
+
* @param options.mappings - Column/field mappings for CSV or JSON (e.g. `{ name: 'title', type: 'category' }`).
|
|
1905
|
+
* @returns An async iterable of {@link ImportProgress} events.
|
|
1906
|
+
*
|
|
1907
|
+
* @example
|
|
1908
|
+
* ```typescript
|
|
1909
|
+
* const graphml = await fetch('graph.graphml').then(r => r.text())
|
|
1910
|
+
* for await (const p of soulcraft.import.importData({ format: 'graphml', data: graphml })) {
|
|
1911
|
+
* if (p.phase === 'done') console.log(`Imported ${p.current} entities`)
|
|
1912
|
+
* }
|
|
1913
|
+
* ```
|
|
1914
|
+
*/
|
|
1915
|
+
importData(options: {
|
|
1916
|
+
format: string;
|
|
1917
|
+
data: string | ArrayBuffer;
|
|
1918
|
+
mappings?: Record<string, string>;
|
|
1919
|
+
}): AsyncIterable<ImportProgress>;
|
|
1920
|
+
/**
|
|
1921
|
+
* @description List all supported import formats.
|
|
1922
|
+
*
|
|
1923
|
+
* @returns Array of format descriptors with IDs, names, and file extensions.
|
|
1924
|
+
*
|
|
1925
|
+
* @example
|
|
1926
|
+
* ```typescript
|
|
1927
|
+
* const formats = await soulcraft.import.getFormats()
|
|
1928
|
+
* // [{ id: 'graphml', name: 'GraphML', extensions: ['.graphml'], description: '...' }, ...]
|
|
1929
|
+
* ```
|
|
1930
|
+
*/
|
|
1931
|
+
getFormats(): Promise<Array<{
|
|
1932
|
+
id: string;
|
|
1933
|
+
name: string;
|
|
1934
|
+
extensions: string[];
|
|
1935
|
+
description: string;
|
|
1936
|
+
}>>;
|
|
1937
|
+
/**
|
|
1938
|
+
* @description Auto-detect the format of uploaded data.
|
|
1939
|
+
*
|
|
1940
|
+
* Inspects the data content to determine the most likely format and
|
|
1941
|
+
* a confidence score.
|
|
1942
|
+
*
|
|
1943
|
+
* @param data - The data to analyze (text content or first few KB).
|
|
1944
|
+
* @returns The detected format and confidence (0–1).
|
|
1945
|
+
*
|
|
1946
|
+
* @example
|
|
1947
|
+
* ```typescript
|
|
1948
|
+
* const { format, confidence } = await soulcraft.import.detectFormat(fileContent)
|
|
1949
|
+
* if (confidence > 0.8) console.log(`Detected: ${format}`)
|
|
1950
|
+
* ```
|
|
1951
|
+
*/
|
|
1952
|
+
detectFormat(data: string): Promise<{
|
|
1953
|
+
format: string;
|
|
1954
|
+
confidence: number;
|
|
1955
|
+
}>;
|
|
1956
|
+
/**
|
|
1957
|
+
* @description Get progress of an ongoing import by ID.
|
|
1958
|
+
*
|
|
1959
|
+
* @param importId - The import operation's identifier (returned in progress events).
|
|
1960
|
+
* @returns Current progress state.
|
|
1961
|
+
*
|
|
1962
|
+
* @example
|
|
1963
|
+
* ```typescript
|
|
1964
|
+
* const progress = await soulcraft.import.getProgress('imp-abc123')
|
|
1965
|
+
* ```
|
|
1966
|
+
*/
|
|
1967
|
+
getProgress(importId: string): Promise<ImportProgress>;
|
|
1968
|
+
/**
|
|
1969
|
+
* @description Cancel an in-progress import operation.
|
|
1970
|
+
*
|
|
1971
|
+
* @param importId - The import to cancel.
|
|
1972
|
+
*
|
|
1973
|
+
* @example
|
|
1974
|
+
* ```typescript
|
|
1975
|
+
* await soulcraft.import.cancel('imp-abc123')
|
|
1976
|
+
* ```
|
|
1977
|
+
*/
|
|
1978
|
+
cancel(importId: string): Promise<void>;
|
|
1979
|
+
}
|
|
1980
|
+
/**
|
|
1981
|
+
* @description Export — download the full project, export the knowledge graph in
|
|
1982
|
+
* standard formats (JSON, CSV, GraphML, GEXF, DOT), and generate PDFs.
|
|
1983
|
+
*
|
|
1984
|
+
* @example
|
|
1985
|
+
* ```typescript
|
|
1986
|
+
* const graphml = await soulcraft.export.exportKnowledgeGraph('graphml')
|
|
1987
|
+
* const zip = await soulcraft.export.downloadProject({ format: 'zip' })
|
|
1988
|
+
* ```
|
|
1989
|
+
*/
|
|
1990
|
+
export interface ExportNamespace {
|
|
1991
|
+
/**
|
|
1992
|
+
* @description List all available export formats.
|
|
1993
|
+
*
|
|
1994
|
+
* @returns Array of {@link ExportFormat} descriptors.
|
|
1995
|
+
*
|
|
1996
|
+
* @example
|
|
1997
|
+
* ```typescript
|
|
1998
|
+
* const formats = await soulcraft.export.getExporters()
|
|
1999
|
+
* console.log(formats.map(f => f.name).join(', '))
|
|
2000
|
+
* ```
|
|
2001
|
+
*/
|
|
2002
|
+
getExporters(): Promise<ExportFormat[]>;
|
|
2003
|
+
/**
|
|
2004
|
+
* @description Download the entire project as a zip or tar archive.
|
|
2005
|
+
*
|
|
2006
|
+
* Includes all VFS files, entity data, and workspace settings.
|
|
2007
|
+
*
|
|
2008
|
+
* @param options - Export options.
|
|
2009
|
+
* @param options.format - Archive format. Default: `'zip'`.
|
|
2010
|
+
* @returns The archive as raw binary data.
|
|
2011
|
+
*
|
|
2012
|
+
* @example
|
|
2013
|
+
* ```typescript
|
|
2014
|
+
* const zip = await soulcraft.export.downloadProject({ format: 'zip' })
|
|
2015
|
+
* saveFile('project.zip', zip)
|
|
2016
|
+
* ```
|
|
2017
|
+
*/
|
|
2018
|
+
downloadProject(options?: {
|
|
2019
|
+
format?: 'zip' | 'tar';
|
|
2020
|
+
}): Promise<ArrayBuffer>;
|
|
2021
|
+
/**
|
|
2022
|
+
* @description Export the knowledge graph in a standard interchange format.
|
|
2023
|
+
*
|
|
2024
|
+
* @param format - Target format: `'json'`, `'csv'`, `'graphml'`, `'gexf'`, or `'dot'`.
|
|
2025
|
+
* @param options - Export options.
|
|
2026
|
+
* @param options.types - Filter to specific NounTypes.
|
|
2027
|
+
* @returns The serialized graph as a string (text formats) or binary (binary formats).
|
|
2028
|
+
*
|
|
2029
|
+
* @example
|
|
2030
|
+
* ```typescript
|
|
2031
|
+
* const graphml = await soulcraft.export.exportKnowledgeGraph('graphml')
|
|
2032
|
+
* const csv = await soulcraft.export.exportKnowledgeGraph('csv', { types: ['Person'] })
|
|
2033
|
+
* ```
|
|
2034
|
+
*/
|
|
2035
|
+
exportKnowledgeGraph(format: string, options?: {
|
|
2036
|
+
types?: string[];
|
|
2037
|
+
}): Promise<string | ArrayBuffer>;
|
|
2038
|
+
/**
|
|
2039
|
+
* @description Generate a PDF export of selected entities.
|
|
2040
|
+
*
|
|
2041
|
+
* The PDF is generated server-side (via Puppeteer/Pandoc for high quality)
|
|
2042
|
+
* and made available for download.
|
|
2043
|
+
*
|
|
2044
|
+
* @param entityIds - Entities to include in the PDF.
|
|
2045
|
+
* @param options - PDF options.
|
|
2046
|
+
* @param options.template - PDF template name (default: the kit's default template).
|
|
2047
|
+
* @returns A download URL for the generated PDF.
|
|
2048
|
+
*
|
|
2049
|
+
* @example
|
|
2050
|
+
* ```typescript
|
|
2051
|
+
* const { downloadUrl } = await soulcraft.export.exportPdf(['entity-1', 'entity-2'])
|
|
2052
|
+
* window.open(downloadUrl)
|
|
2053
|
+
* ```
|
|
2054
|
+
*/
|
|
2055
|
+
exportPdf(entityIds: string[], options?: {
|
|
2056
|
+
template?: string;
|
|
2057
|
+
}): Promise<{
|
|
2058
|
+
downloadUrl: string;
|
|
2059
|
+
}>;
|
|
2060
|
+
/**
|
|
2061
|
+
* @description Download a previously generated PDF by export ID.
|
|
2062
|
+
*
|
|
2063
|
+
* @param exportId - The export operation's identifier.
|
|
2064
|
+
* @returns The PDF as raw binary data.
|
|
2065
|
+
*
|
|
2066
|
+
* @example
|
|
2067
|
+
* ```typescript
|
|
2068
|
+
* const pdfBytes = await soulcraft.export.downloadPdf('exp-abc123')
|
|
2069
|
+
* ```
|
|
2070
|
+
*/
|
|
2071
|
+
downloadPdf(exportId: string): Promise<ArrayBuffer>;
|
|
2072
|
+
}
|
|
2073
|
+
/**
|
|
2074
|
+
* @description Platform configuration — feature flags, limits, announcements,
|
|
2075
|
+
* and maintenance mode status.
|
|
2076
|
+
*
|
|
2077
|
+
* @example
|
|
2078
|
+
* ```typescript
|
|
2079
|
+
* const config = await soulcraft.config.get()
|
|
2080
|
+
* if (config.maintenance?.active) showMaintenanceBanner(config.maintenance.message)
|
|
2081
|
+
* ```
|
|
2082
|
+
*/
|
|
2083
|
+
export interface ConfigNamespace {
|
|
2084
|
+
/**
|
|
2085
|
+
* @description Get the full platform configuration.
|
|
2086
|
+
*
|
|
2087
|
+
* @returns Feature flags, numeric limits, maintenance state, and announcements.
|
|
2088
|
+
*
|
|
2089
|
+
* @example
|
|
2090
|
+
* ```typescript
|
|
2091
|
+
* const config = await soulcraft.config.get()
|
|
2092
|
+
* if (config.features.hallEnabled) showVideoButton()
|
|
2093
|
+
* ```
|
|
2094
|
+
*/
|
|
2095
|
+
get(): Promise<PlatformConfig>;
|
|
2096
|
+
/**
|
|
2097
|
+
* @description Get user-specific configuration overrides.
|
|
2098
|
+
*
|
|
2099
|
+
* @returns Key-value pairs of user-level settings.
|
|
2100
|
+
*
|
|
2101
|
+
* @example
|
|
2102
|
+
* ```typescript
|
|
2103
|
+
* const userConfig = await soulcraft.config.getUser()
|
|
2104
|
+
* const theme = userConfig.theme ?? 'system'
|
|
2105
|
+
* ```
|
|
2106
|
+
*/
|
|
2107
|
+
getUser(): Promise<Record<string, unknown>>;
|
|
2108
|
+
/**
|
|
2109
|
+
* @description Get current platform announcements to display to the user.
|
|
2110
|
+
*
|
|
2111
|
+
* @returns Array of active announcements.
|
|
2112
|
+
*
|
|
2113
|
+
* @example
|
|
2114
|
+
* ```typescript
|
|
2115
|
+
* const announcements = await soulcraft.config.getAnnouncements()
|
|
2116
|
+
* for (const a of announcements) showBanner(a.message, a.type)
|
|
2117
|
+
* ```
|
|
2118
|
+
*/
|
|
2119
|
+
getAnnouncements(): Promise<Array<{
|
|
2120
|
+
id: string;
|
|
2121
|
+
message: string;
|
|
2122
|
+
type: string;
|
|
2123
|
+
}>>;
|
|
2124
|
+
/**
|
|
2125
|
+
* @description Check if maintenance mode is currently active.
|
|
2126
|
+
*
|
|
2127
|
+
* When active, most API calls will fail — the UI should show a maintenance
|
|
2128
|
+
* banner and disable interactive features.
|
|
2129
|
+
*
|
|
2130
|
+
* @returns `true` if maintenance mode is active.
|
|
2131
|
+
*
|
|
2132
|
+
* @example
|
|
2133
|
+
* ```typescript
|
|
2134
|
+
* if (await soulcraft.config.isMaintenanceMode()) showMaintenancePage()
|
|
2135
|
+
* ```
|
|
2136
|
+
*/
|
|
2137
|
+
isMaintenanceMode(): Promise<boolean>;
|
|
2138
|
+
}
|
|
2139
|
+
/**
|
|
2140
|
+
* @description User settings — BYOK API key management, AI usage stats, and
|
|
2141
|
+
* workspace storage usage.
|
|
2142
|
+
*
|
|
2143
|
+
* @example
|
|
2144
|
+
* ```typescript
|
|
2145
|
+
* await soulcraft.settings.saveApiKey({ provider: 'anthropic', key: 'sk-ant-...' })
|
|
2146
|
+
* const usage = await soulcraft.settings.getStorageUsage()
|
|
2147
|
+
* ```
|
|
2148
|
+
*/
|
|
2149
|
+
export interface SettingsNamespace {
|
|
2150
|
+
/**
|
|
2151
|
+
* @description Save a BYOK (Bring Your Own Key) API key, encrypted at rest.
|
|
2152
|
+
*
|
|
2153
|
+
* @param options - The key to save.
|
|
2154
|
+
* @param options.provider - AI provider name (e.g. `'anthropic'`).
|
|
2155
|
+
* @param options.key - The raw API key string.
|
|
2156
|
+
*
|
|
2157
|
+
* @example
|
|
2158
|
+
* ```typescript
|
|
2159
|
+
* await soulcraft.settings.saveApiKey({ provider: 'anthropic', key: 'sk-ant-abc123...' })
|
|
2160
|
+
* ```
|
|
2161
|
+
*/
|
|
2162
|
+
saveApiKey(options: {
|
|
2163
|
+
provider: string;
|
|
2164
|
+
key: string;
|
|
2165
|
+
}): Promise<void>;
|
|
2166
|
+
/**
|
|
2167
|
+
* @description Get saved API key info (redacted — only last 4 chars shown).
|
|
2168
|
+
*
|
|
2169
|
+
* @param provider - The AI provider name.
|
|
2170
|
+
* @returns Redacted key info, or `null` if no key is saved for this provider.
|
|
2171
|
+
*
|
|
2172
|
+
* @example
|
|
2173
|
+
* ```typescript
|
|
2174
|
+
* const keyInfo = await soulcraft.settings.getApiKey('anthropic')
|
|
2175
|
+
* if (keyInfo) console.log(`Key ending in ${keyInfo.lastFour}`)
|
|
2176
|
+
* ```
|
|
2177
|
+
*/
|
|
2178
|
+
getApiKey(provider: string): Promise<ApiKeyInfo | null>;
|
|
2179
|
+
/**
|
|
2180
|
+
* @description Delete a saved API key.
|
|
2181
|
+
*
|
|
2182
|
+
* @param provider - The AI provider whose key to delete.
|
|
2183
|
+
*
|
|
2184
|
+
* @example
|
|
2185
|
+
* ```typescript
|
|
2186
|
+
* await soulcraft.settings.deleteApiKey('anthropic')
|
|
2187
|
+
* ```
|
|
2188
|
+
*/
|
|
2189
|
+
deleteApiKey(provider: string): Promise<void>;
|
|
2190
|
+
/**
|
|
2191
|
+
* @description Get AI usage statistics for the current user's billing period.
|
|
2192
|
+
*
|
|
2193
|
+
* @returns Message count, token totals, and the billing period identifier.
|
|
2194
|
+
*
|
|
2195
|
+
* @example
|
|
2196
|
+
* ```typescript
|
|
2197
|
+
* const stats = await soulcraft.settings.getUsageStats()
|
|
2198
|
+
* console.log(`${stats.messages} messages, ${stats.tokens.input + stats.tokens.output} tokens`)
|
|
2199
|
+
* ```
|
|
2200
|
+
*/
|
|
2201
|
+
getUsageStats(): Promise<{
|
|
2202
|
+
messages: number;
|
|
2203
|
+
tokens: {
|
|
2204
|
+
input: number;
|
|
2205
|
+
output: number;
|
|
2206
|
+
};
|
|
2207
|
+
period: string;
|
|
2208
|
+
}>;
|
|
2209
|
+
/**
|
|
2210
|
+
* @description Get storage consumption breakdown for the current workspace.
|
|
2211
|
+
*
|
|
2212
|
+
* @returns Storage usage across entities, files, and indices.
|
|
2213
|
+
*
|
|
2214
|
+
* @example
|
|
2215
|
+
* ```typescript
|
|
2216
|
+
* const usage = await soulcraft.settings.getStorageUsage()
|
|
2217
|
+
* console.log(`Total: ${(usage.totalBytes / 1024 / 1024).toFixed(1)} MB`)
|
|
2218
|
+
* ```
|
|
2219
|
+
*/
|
|
2220
|
+
getStorageUsage(): Promise<StorageUsage>;
|
|
2221
|
+
}
|
|
2222
|
+
/**
|
|
2223
|
+
* @description Project context for Glass Box AI transparency and metadata repair.
|
|
2224
|
+
*
|
|
2225
|
+
* Glass Box shows users exactly what the AI knows about their project:
|
|
2226
|
+
* entity type counts, relationship types, file count, and total tokens embedded.
|
|
2227
|
+
*
|
|
2228
|
+
* @example
|
|
2229
|
+
* ```typescript
|
|
2230
|
+
* const ctx = await soulcraft.project.getContext()
|
|
2231
|
+
* console.log(`Project uses kit "${ctx.kitName}" with ${ctx.fileCount} files`)
|
|
2232
|
+
* ```
|
|
2233
|
+
*/
|
|
2234
|
+
export interface ProjectNamespace {
|
|
2235
|
+
/**
|
|
2236
|
+
* @description Get the project context for AI transparency (Glass Box).
|
|
2237
|
+
*
|
|
2238
|
+
* @returns Kit info, entity/relation type distributions, file count, and total embedded tokens.
|
|
2239
|
+
*
|
|
2240
|
+
* @example
|
|
2241
|
+
* ```typescript
|
|
2242
|
+
* const ctx = await soulcraft.project.getContext()
|
|
2243
|
+
* console.log(`Entity types: ${Object.keys(ctx.entityTypes).join(', ')}`)
|
|
2244
|
+
* ```
|
|
2245
|
+
*/
|
|
2246
|
+
getContext(): Promise<{
|
|
2247
|
+
kitId: string;
|
|
2248
|
+
kitName: string;
|
|
2249
|
+
entityTypes: Record<string, number>;
|
|
2250
|
+
relationTypes: Record<string, number>;
|
|
2251
|
+
fileCount: number;
|
|
2252
|
+
totalTokens: number;
|
|
2253
|
+
}>;
|
|
2254
|
+
/**
|
|
2255
|
+
* @description Repair metadata inconsistencies in workspace entities.
|
|
2256
|
+
*
|
|
2257
|
+
* Scans all entities and fixes common issues: missing `metadata.name`,
|
|
2258
|
+
* orphaned relationships, duplicate embeddings, etc.
|
|
2259
|
+
*
|
|
2260
|
+
* @returns Counts of repaired entities and errors encountered.
|
|
2261
|
+
*
|
|
2262
|
+
* @example
|
|
2263
|
+
* ```typescript
|
|
2264
|
+
* const { repaired, errors } = await soulcraft.project.repairMetadata()
|
|
2265
|
+
* console.log(`Fixed ${repaired} entities, ${errors} errors`)
|
|
2266
|
+
* ```
|
|
2267
|
+
*/
|
|
2268
|
+
repairMetadata(): Promise<{
|
|
2269
|
+
repaired: number;
|
|
2270
|
+
errors: number;
|
|
2271
|
+
}>;
|
|
2272
|
+
}
|
|
2273
|
+
/**
|
|
2274
|
+
* @description Collaborative session lifecycle — multiple users editing the same
|
|
2275
|
+
* workspace in real-time via Y.js CRDT synchronization.
|
|
2276
|
+
*
|
|
2277
|
+
* @example
|
|
2278
|
+
* ```typescript
|
|
2279
|
+
* const state = await soulcraft.session.join('session-abc', { displayName: 'Alice' })
|
|
2280
|
+
* console.log(`${state.participants.length} people in session`)
|
|
2281
|
+
* ```
|
|
2282
|
+
*/
|
|
2283
|
+
export interface SessionNamespace {
|
|
2284
|
+
/**
|
|
2285
|
+
* @description Join a collaborative session.
|
|
2286
|
+
*
|
|
2287
|
+
* Registers the current user as a participant. If the session doesn't exist,
|
|
2288
|
+
* it is created. The returned state includes all current participants.
|
|
2289
|
+
*
|
|
2290
|
+
* @param sessionId - The session to join.
|
|
2291
|
+
* @param options - Join options.
|
|
2292
|
+
* @param options.displayName - Name shown to other participants.
|
|
2293
|
+
* @returns The current session state.
|
|
2294
|
+
*
|
|
2295
|
+
* @example
|
|
2296
|
+
* ```typescript
|
|
2297
|
+
* const state = await soulcraft.session.join('session-abc', { displayName: 'Alice' })
|
|
2298
|
+
* ```
|
|
2299
|
+
*/
|
|
2300
|
+
join(sessionId: string, options?: {
|
|
2301
|
+
displayName?: string;
|
|
2302
|
+
}): Promise<SessionState>;
|
|
2303
|
+
/**
|
|
2304
|
+
* @description Leave a collaborative session.
|
|
2305
|
+
*
|
|
2306
|
+
* Removes the current user from the participant list. When the last
|
|
2307
|
+
* participant leaves, the session is closed.
|
|
2308
|
+
*
|
|
2309
|
+
* @param sessionId - The session to leave.
|
|
2310
|
+
*
|
|
2311
|
+
* @example
|
|
2312
|
+
* ```typescript
|
|
2313
|
+
* await soulcraft.session.leave('session-abc')
|
|
2314
|
+
* ```
|
|
2315
|
+
*/
|
|
2316
|
+
leave(sessionId: string): Promise<void>;
|
|
2317
|
+
/**
|
|
2318
|
+
* @description Get the current state of a session.
|
|
2319
|
+
*
|
|
2320
|
+
* @param sessionId - The session to query.
|
|
2321
|
+
* @returns The session state, or `null` if the session doesn't exist or has ended.
|
|
2322
|
+
*
|
|
2323
|
+
* @example
|
|
2324
|
+
* ```typescript
|
|
2325
|
+
* const state = await soulcraft.session.getState('session-abc')
|
|
2326
|
+
* if (state) console.log(`${state.participants.length} participants`)
|
|
2327
|
+
* ```
|
|
2328
|
+
*/
|
|
2329
|
+
getState(sessionId: string): Promise<SessionState | null>;
|
|
2330
|
+
/**
|
|
2331
|
+
* @description Get the history of past collaborative sessions for this workspace.
|
|
2332
|
+
*
|
|
2333
|
+
* @param options - Pagination options.
|
|
2334
|
+
* @param options.limit - Maximum number of sessions to return. Default: 20.
|
|
2335
|
+
* @returns Array of past session summaries.
|
|
2336
|
+
*
|
|
2337
|
+
* @example
|
|
2338
|
+
* ```typescript
|
|
2339
|
+
* const history = await soulcraft.session.getHistory({ limit: 10 })
|
|
2340
|
+
* for (const s of history) console.log(`${s.participantCount} people on ${s.startedAt}`)
|
|
2341
|
+
* ```
|
|
2342
|
+
*/
|
|
2343
|
+
getHistory(options?: {
|
|
2344
|
+
limit?: number;
|
|
2345
|
+
}): Promise<Array<{
|
|
2346
|
+
sessionId: string;
|
|
2347
|
+
startedAt: string;
|
|
2348
|
+
endedAt: string;
|
|
2349
|
+
participantCount: number;
|
|
2350
|
+
}>>;
|
|
2351
|
+
}
|
|
2352
|
+
/**
|
|
2353
|
+
* @description Analytics event forwarding — fire-and-forget telemetry.
|
|
2354
|
+
*
|
|
2355
|
+
* Events are forwarded to the configured analytics sink (Pulse). The call
|
|
2356
|
+
* returns immediately; delivery is best-effort.
|
|
2357
|
+
*
|
|
2358
|
+
* @example
|
|
2359
|
+
* ```typescript
|
|
2360
|
+
* await soulcraft.pulse.track('page_view', { page: '/graph', kitId: 'wicks-and-whiskers' })
|
|
2361
|
+
* ```
|
|
2362
|
+
*/
|
|
2363
|
+
export interface PulseNamespace {
|
|
2364
|
+
/**
|
|
2365
|
+
* @description Track an analytics event.
|
|
2366
|
+
*
|
|
2367
|
+
* @param event - Event name (e.g. `'page_view'`, `'entity_created'`, `'export_started'`).
|
|
2368
|
+
* @param properties - Optional key-value metadata attached to the event.
|
|
2369
|
+
*
|
|
2370
|
+
* @example
|
|
2371
|
+
* ```typescript
|
|
2372
|
+
* await soulcraft.pulse.track('entity_created', { type: 'Document', kitId: 'blog-series' })
|
|
2373
|
+
* ```
|
|
2374
|
+
*/
|
|
2375
|
+
track(event: string, properties?: Record<string, unknown>): Promise<void>;
|
|
2376
|
+
}
|
|
2377
|
+
/**
|
|
2378
|
+
* @description Auth session and WebSocket token operations.
|
|
2379
|
+
*
|
|
2380
|
+
* @example
|
|
2381
|
+
* ```typescript
|
|
2382
|
+
* const { user, authenticated } = await soulcraft.auth.getSession()
|
|
2383
|
+
* if (authenticated) console.log(`Logged in as ${user!.name}`)
|
|
2384
|
+
* ```
|
|
2385
|
+
*/
|
|
2386
|
+
export interface AuthNamespace {
|
|
2387
|
+
/**
|
|
2388
|
+
* @description Get the current session user and authentication status.
|
|
2389
|
+
*
|
|
2390
|
+
* @returns The authenticated user (or `null` if not logged in) and a boolean flag.
|
|
2391
|
+
*
|
|
2392
|
+
* @example
|
|
2393
|
+
* ```typescript
|
|
2394
|
+
* const { user, authenticated } = await soulcraft.auth.getSession()
|
|
2395
|
+
* if (!authenticated) redirectToLogin()
|
|
2396
|
+
* ```
|
|
2397
|
+
*/
|
|
2398
|
+
getSession(): Promise<{
|
|
2399
|
+
user: {
|
|
2400
|
+
id: string;
|
|
2401
|
+
email: string;
|
|
2402
|
+
name: string;
|
|
2403
|
+
image?: string;
|
|
2404
|
+
role?: string;
|
|
2405
|
+
} | null;
|
|
2406
|
+
authenticated: boolean;
|
|
2407
|
+
}>;
|
|
2408
|
+
/**
|
|
2409
|
+
* @description Get a short-lived WebSocket capability token for real-time connections.
|
|
2410
|
+
*
|
|
2411
|
+
* The token is used by the {@link WsTransport} to authenticate the WebSocket
|
|
2412
|
+
* upgrade request. Tokens are scoped to the workspace and expire after a few minutes.
|
|
2413
|
+
*
|
|
2414
|
+
* @param options - Token options.
|
|
2415
|
+
* @param options.scope - Workspace scope identifier. Defaults to the active workspace.
|
|
2416
|
+
* @returns The token string and its ISO 8601 expiration timestamp.
|
|
2417
|
+
*
|
|
2418
|
+
* @example
|
|
2419
|
+
* ```typescript
|
|
2420
|
+
* const { token, expiresAt } = await soulcraft.auth.getWsToken({ scope: 'ws-abc123' })
|
|
2421
|
+
* const ws = new WsTransport(wsUrl, token, 'ws-abc123')
|
|
2422
|
+
* await ws.connect()
|
|
2423
|
+
* ```
|
|
2424
|
+
*/
|
|
2425
|
+
getWsToken(options?: {
|
|
2426
|
+
scope?: string;
|
|
2427
|
+
}): Promise<{
|
|
2428
|
+
token: string;
|
|
2429
|
+
expiresAt: string;
|
|
2430
|
+
}>;
|
|
2431
|
+
}
|
|
2432
|
+
/**
|
|
2433
|
+
* @description Media pipeline — upload, transcode, and stream audio, video, and images.
|
|
2434
|
+
*
|
|
2435
|
+
* Backed by the Hall server (hall.soulcraft.com). Supports transcoding between
|
|
2436
|
+
* formats (e.g. WAV → MP3, MOV → MP4), thumbnail generation for video/images,
|
|
2437
|
+
* and HTTP range-request streaming for delivery.
|
|
2438
|
+
*
|
|
2439
|
+
* @example Upload and transcode a podcast recording
|
|
2440
|
+
* ```typescript
|
|
2441
|
+
* const result = await soulcraft.media.upload(audioFile, {
|
|
2442
|
+
* transcode: 'audio/mp3',
|
|
2443
|
+
* thumbnail: false,
|
|
2444
|
+
* })
|
|
2445
|
+
* console.log(`Podcast at ${result.url}, ${result.duration}s`)
|
|
2446
|
+
* ```
|
|
2447
|
+
*
|
|
2448
|
+
* @example Stream media
|
|
2449
|
+
* ```typescript
|
|
2450
|
+
* const stream = soulcraft.media.stream(mediaId)
|
|
2451
|
+
* // Pipe to audio/video element
|
|
2452
|
+
* ```
|
|
2453
|
+
*/
|
|
2454
|
+
export interface MediaNamespace {
|
|
2455
|
+
/**
|
|
2456
|
+
* @description Upload a media file with optional transcoding.
|
|
2457
|
+
*
|
|
2458
|
+
* @param file - The media file content (ArrayBuffer or Blob).
|
|
2459
|
+
* @param options - Upload options.
|
|
2460
|
+
* @param options.filename - Original filename for format detection.
|
|
2461
|
+
* @param options.transcode - Target MIME type for transcoding (e.g. `'audio/mp3'`, `'video/mp4'`, `'image/webp'`).
|
|
2462
|
+
* @param options.thumbnail - Whether to generate a thumbnail (video/images only). Default: `false`.
|
|
2463
|
+
* @returns Upload result with media ID, URL, and metadata.
|
|
2464
|
+
*
|
|
2465
|
+
* @example
|
|
2466
|
+
* ```typescript
|
|
2467
|
+
* const result = await soulcraft.media.upload(videoBlob, {
|
|
2468
|
+
* filename: 'lecture.mov',
|
|
2469
|
+
* transcode: 'video/mp4',
|
|
2470
|
+
* thumbnail: true,
|
|
2471
|
+
* })
|
|
2472
|
+
* ```
|
|
2473
|
+
*/
|
|
2474
|
+
upload(file: ArrayBuffer, options?: {
|
|
2475
|
+
filename?: string;
|
|
2476
|
+
transcode?: string;
|
|
2477
|
+
thumbnail?: boolean;
|
|
2478
|
+
}): Promise<MediaUploadResult>;
|
|
2479
|
+
/**
|
|
2480
|
+
* @description Stream a stored media item.
|
|
2481
|
+
*
|
|
2482
|
+
* Returns an async iterable of binary chunks for progressive download.
|
|
2483
|
+
* For HTTP transports, the server uses range requests for seeking.
|
|
2484
|
+
*
|
|
2485
|
+
* @param mediaId - The media identifier from {@link upload}.
|
|
2486
|
+
* @returns Async iterable of binary chunks.
|
|
2487
|
+
*
|
|
2488
|
+
* @example
|
|
2489
|
+
* ```typescript
|
|
2490
|
+
* for await (const chunk of soulcraft.media.stream(mediaId)) {
|
|
2491
|
+
* audioBuffer.append(chunk)
|
|
2492
|
+
* }
|
|
2493
|
+
* ```
|
|
2494
|
+
*/
|
|
2495
|
+
stream(mediaId: string): AsyncIterable<ArrayBuffer>;
|
|
2496
|
+
/**
|
|
2497
|
+
* @description Get metadata about a stored media item.
|
|
2498
|
+
*
|
|
2499
|
+
* @param mediaId - The media identifier.
|
|
2500
|
+
* @returns Media metadata, or `null` if not found.
|
|
2501
|
+
*
|
|
2502
|
+
* @example
|
|
2503
|
+
* ```typescript
|
|
2504
|
+
* const info = await soulcraft.media.getInfo(mediaId)
|
|
2505
|
+
* if (info) console.log(`${info.mimeType}, ${info.duration}s`)
|
|
2506
|
+
* ```
|
|
2507
|
+
*/
|
|
2508
|
+
getInfo(mediaId: string): Promise<MediaInfo | null>;
|
|
2509
|
+
/**
|
|
2510
|
+
* @description Delete a stored media item.
|
|
2511
|
+
*
|
|
2512
|
+
* @param mediaId - The media identifier.
|
|
2513
|
+
*
|
|
2514
|
+
* @example
|
|
2515
|
+
* ```typescript
|
|
2516
|
+
* await soulcraft.media.delete(mediaId)
|
|
2517
|
+
* ```
|
|
2518
|
+
*/
|
|
2519
|
+
delete(mediaId: string): Promise<void>;
|
|
2520
|
+
}
|
|
2521
|
+
/**
|
|
2522
|
+
* @description Real-time pub/sub — topic-based messaging, presence tracking,
|
|
2523
|
+
* and broadcast. Backed by the Hall server (hall.soulcraft.com).
|
|
2524
|
+
*
|
|
2525
|
+
* Topics are ephemeral channels. Messages are fire-and-forget (no persistence).
|
|
2526
|
+
* Presence is tracked per-topic — subscribing makes you "present."
|
|
2527
|
+
*
|
|
2528
|
+
* @example Multiplayer game
|
|
2529
|
+
* ```typescript
|
|
2530
|
+
* // Subscribe to game moves
|
|
2531
|
+
* const sub = await soulcraft.realtime.subscribe('game-room-42', (data) => {
|
|
2532
|
+
* updateBoard(data.move)
|
|
2533
|
+
* })
|
|
2534
|
+
*
|
|
2535
|
+
* // Broadcast a move
|
|
2536
|
+
* await soulcraft.realtime.broadcast('game-room-42', { move: { x: 3, y: 5 } })
|
|
2537
|
+
*
|
|
2538
|
+
* // Check who's online
|
|
2539
|
+
* const peers = await soulcraft.realtime.presence('game-room-42')
|
|
2540
|
+
* ```
|
|
2541
|
+
*/
|
|
2542
|
+
export interface RealtimeNamespace {
|
|
2543
|
+
/**
|
|
2544
|
+
* @description Subscribe to a topic and receive messages.
|
|
2545
|
+
*
|
|
2546
|
+
* @param topic - Topic name (any string, e.g. `'game-room-42'`, `'inventory-updates'`).
|
|
2547
|
+
* @param handler - Callback invoked for each message on this topic.
|
|
2548
|
+
* @returns A subscription handle with an `unsubscribe()` method.
|
|
2549
|
+
*
|
|
2550
|
+
* @example
|
|
2551
|
+
* ```typescript
|
|
2552
|
+
* const sub = await soulcraft.realtime.subscribe('chat', (msg) => {
|
|
2553
|
+
* console.log(`${msg.user}: ${msg.text}`)
|
|
2554
|
+
* })
|
|
2555
|
+
* // Later:
|
|
2556
|
+
* sub.unsubscribe()
|
|
2557
|
+
* ```
|
|
2558
|
+
*/
|
|
2559
|
+
subscribe(topic: string, handler: (data: unknown) => void): Promise<RealtimeSubscription>;
|
|
2560
|
+
/**
|
|
2561
|
+
* @description Broadcast a message to all subscribers of a topic.
|
|
2562
|
+
*
|
|
2563
|
+
* Fire-and-forget — the message is delivered to all current subscribers
|
|
2564
|
+
* but not persisted. The sender does NOT receive their own broadcast.
|
|
2565
|
+
*
|
|
2566
|
+
* @param topic - Topic name.
|
|
2567
|
+
* @param data - The message payload (must be JSON-serializable).
|
|
2568
|
+
*
|
|
2569
|
+
* @example
|
|
2570
|
+
* ```typescript
|
|
2571
|
+
* await soulcraft.realtime.broadcast('inventory-updates', {
|
|
2572
|
+
* productId: 'candle-42',
|
|
2573
|
+
* stock: 7,
|
|
2574
|
+
* })
|
|
2575
|
+
* ```
|
|
2576
|
+
*/
|
|
2577
|
+
broadcast(topic: string, data: unknown): Promise<void>;
|
|
2578
|
+
/**
|
|
2579
|
+
* @description Get the list of peers currently subscribed to a topic.
|
|
2580
|
+
*
|
|
2581
|
+
* @param topic - Topic name.
|
|
2582
|
+
* @returns Array of currently present peers.
|
|
2583
|
+
*
|
|
2584
|
+
* @example
|
|
2585
|
+
* ```typescript
|
|
2586
|
+
* const peers = await soulcraft.realtime.presence('game-room-42')
|
|
2587
|
+
* console.log(`${peers.length} players online`)
|
|
2588
|
+
* ```
|
|
2589
|
+
*/
|
|
2590
|
+
presence(topic: string): Promise<RealtimePeer[]>;
|
|
2591
|
+
}
|
|
2592
|
+
/**
|
|
2593
|
+
* @description Commerce — product management, checkout, and payment processing.
|
|
2594
|
+
*
|
|
2595
|
+
* Stripe-first implementation with a pluggable `PaymentProvider` interface for
|
|
2596
|
+
* future payment processors (Square, PayPal, etc.). Products configure their
|
|
2597
|
+
* Stripe account via `providers.commerce` in the SDK server config.
|
|
2598
|
+
*
|
|
2599
|
+
* @example Create a product and initiate checkout
|
|
2600
|
+
* ```typescript
|
|
2601
|
+
* const product = await soulcraft.commerce.createProduct({
|
|
2602
|
+
* name: 'Lavender Candle Kit',
|
|
2603
|
+
* description: 'Everything you need to make lavender candles',
|
|
2604
|
+
* priceAmount: 2999,
|
|
2605
|
+
* currency: 'usd',
|
|
2606
|
+
* })
|
|
2607
|
+
*
|
|
2608
|
+
* const session = await soulcraft.commerce.checkout({
|
|
2609
|
+
* items: [{ productId: product.id, quantity: 1 }],
|
|
2610
|
+
* successUrl: '/order/success',
|
|
2611
|
+
* cancelUrl: '/shop',
|
|
2612
|
+
* })
|
|
2613
|
+
* window.location.href = session.checkoutUrl
|
|
2614
|
+
* ```
|
|
2615
|
+
*/
|
|
2616
|
+
export interface CommerceNamespace {
|
|
2617
|
+
/**
|
|
2618
|
+
* @description Create a new product.
|
|
2619
|
+
*
|
|
2620
|
+
* @param options - Product details.
|
|
2621
|
+
* @param options.name - Product display name.
|
|
2622
|
+
* @param options.description - Product description.
|
|
2623
|
+
* @param options.priceAmount - Price in smallest currency unit (e.g. cents).
|
|
2624
|
+
* @param options.currency - Three-letter ISO 4217 currency code.
|
|
2625
|
+
* @param options.images - Optional product image URLs.
|
|
2626
|
+
* @param options.metadata - Optional key-value metadata.
|
|
2627
|
+
* @returns The created product.
|
|
2628
|
+
*
|
|
2629
|
+
* @example
|
|
2630
|
+
* ```typescript
|
|
2631
|
+
* const product = await soulcraft.commerce.createProduct({
|
|
2632
|
+
* name: 'Workshop Pro Plan', priceAmount: 1999, currency: 'usd',
|
|
2633
|
+
* })
|
|
2634
|
+
* ```
|
|
2635
|
+
*/
|
|
2636
|
+
createProduct(options: {
|
|
2637
|
+
name: string;
|
|
2638
|
+
description?: string;
|
|
2639
|
+
priceAmount: number;
|
|
2640
|
+
currency: string;
|
|
2641
|
+
images?: string[];
|
|
2642
|
+
metadata?: Record<string, string>;
|
|
2643
|
+
}): Promise<CommerceProduct>;
|
|
2644
|
+
/**
|
|
2645
|
+
* @description List all products.
|
|
2646
|
+
*
|
|
2647
|
+
* @param options - Filter options.
|
|
2648
|
+
* @param options.active - Filter by active/inactive status.
|
|
2649
|
+
* @param options.limit - Maximum number of products to return. Default: 100.
|
|
2650
|
+
* @returns Array of products.
|
|
2651
|
+
*
|
|
2652
|
+
* @example
|
|
2653
|
+
* ```typescript
|
|
2654
|
+
* const products = await soulcraft.commerce.listProducts({ active: true })
|
|
2655
|
+
* ```
|
|
2656
|
+
*/
|
|
2657
|
+
listProducts(options?: {
|
|
2658
|
+
active?: boolean;
|
|
2659
|
+
limit?: number;
|
|
2660
|
+
}): Promise<CommerceProduct[]>;
|
|
2661
|
+
/**
|
|
2662
|
+
* @description Get a single product by ID.
|
|
2663
|
+
*
|
|
2664
|
+
* @param productId - The product identifier.
|
|
2665
|
+
* @returns The product, or `null` if not found.
|
|
2666
|
+
*
|
|
2667
|
+
* @example
|
|
2668
|
+
* ```typescript
|
|
2669
|
+
* const product = await soulcraft.commerce.getProduct('prod_abc123')
|
|
2670
|
+
* ```
|
|
2671
|
+
*/
|
|
2672
|
+
getProduct(productId: string): Promise<CommerceProduct | null>;
|
|
2673
|
+
/**
|
|
2674
|
+
* @description Initiate a checkout session.
|
|
2675
|
+
*
|
|
2676
|
+
* Creates a Stripe Checkout Session and returns the URL for redirect.
|
|
2677
|
+
*
|
|
2678
|
+
* @param options - Checkout details.
|
|
2679
|
+
* @param options.items - Line items with product IDs and quantities.
|
|
2680
|
+
* @param options.successUrl - URL to redirect after successful payment.
|
|
2681
|
+
* @param options.cancelUrl - URL to redirect if the customer cancels.
|
|
2682
|
+
* @param options.customerEmail - Pre-fill the customer email.
|
|
2683
|
+
* @returns The checkout session with redirect URL.
|
|
2684
|
+
*
|
|
2685
|
+
* @example
|
|
2686
|
+
* ```typescript
|
|
2687
|
+
* const session = await soulcraft.commerce.checkout({
|
|
2688
|
+
* items: [{ productId: 'prod_abc', quantity: 2 }],
|
|
2689
|
+
* successUrl: '/success',
|
|
2690
|
+
* cancelUrl: '/cart',
|
|
2691
|
+
* })
|
|
2692
|
+
* ```
|
|
2693
|
+
*/
|
|
2694
|
+
checkout(options: {
|
|
2695
|
+
items: Array<{
|
|
2696
|
+
productId: string;
|
|
2697
|
+
quantity: number;
|
|
2698
|
+
}>;
|
|
2699
|
+
successUrl: string;
|
|
2700
|
+
cancelUrl: string;
|
|
2701
|
+
customerEmail?: string;
|
|
2702
|
+
}): Promise<CheckoutSession>;
|
|
2703
|
+
/**
|
|
2704
|
+
* @description Get a payment record by ID.
|
|
2705
|
+
*
|
|
2706
|
+
* @param paymentId - The payment identifier.
|
|
2707
|
+
* @returns The payment record, or `null` if not found.
|
|
2708
|
+
*
|
|
2709
|
+
* @example
|
|
2710
|
+
* ```typescript
|
|
2711
|
+
* const payment = await soulcraft.commerce.getPayment('pi_abc123')
|
|
2712
|
+
* if (payment?.status === 'succeeded') showReceipt(payment)
|
|
2713
|
+
* ```
|
|
2714
|
+
*/
|
|
2715
|
+
getPayment(paymentId: string): Promise<PaymentRecord | null>;
|
|
2716
|
+
/**
|
|
2717
|
+
* @description List payments for the current user.
|
|
2718
|
+
*
|
|
2719
|
+
* @param options - Filter options.
|
|
2720
|
+
* @param options.limit - Maximum number of payments to return. Default: 20.
|
|
2721
|
+
* @returns Array of payment records.
|
|
2722
|
+
*
|
|
2723
|
+
* @example
|
|
2724
|
+
* ```typescript
|
|
2725
|
+
* const payments = await soulcraft.commerce.listPayments({ limit: 10 })
|
|
2726
|
+
* ```
|
|
2727
|
+
*/
|
|
2728
|
+
listPayments(options?: {
|
|
2729
|
+
limit?: number;
|
|
2730
|
+
}): Promise<PaymentRecord[]>;
|
|
2731
|
+
}
|
|
2732
|
+
/**
|
|
2733
|
+
* @description Certification — issue, verify, and trace credential lineage.
|
|
2734
|
+
*
|
|
2735
|
+
* Uses Brainy's graph model for verifiable credentials. Each certification is
|
|
2736
|
+
* a `contract` entity linked by `endorses` (certifier → cert), `attributedTo`
|
|
2737
|
+
* (cert → learner), and `dependsOn` (cert → upstream cert) relationships.
|
|
2738
|
+
*
|
|
2739
|
+
* Originally built for Academy (course completion credentials). Now a platform
|
|
2740
|
+
* primitive: Workshop can certify skill completion, Venue can certify training,
|
|
2741
|
+
* kit apps can issue achievement badges — all with verifiable lineage.
|
|
2742
|
+
*
|
|
2743
|
+
* @example Issue a certification
|
|
2744
|
+
* ```typescript
|
|
2745
|
+
* const cert = await soulcraft.certification.issue({
|
|
2746
|
+
* name: 'Advanced Candle Making',
|
|
2747
|
+
* learnerId: 'user-abc',
|
|
2748
|
+
* score: 0.95,
|
|
2749
|
+
* upstreamCertificationId: 'cert-basic',
|
|
2750
|
+
* })
|
|
2751
|
+
* console.log(`Certification ${cert.id} issued, lineage depth: ${cert.lineageDepth}`)
|
|
2752
|
+
* ```
|
|
2753
|
+
*
|
|
2754
|
+
* @example Verify a certification
|
|
2755
|
+
* ```typescript
|
|
2756
|
+
* const result = await soulcraft.certification.verify('cert-xyz')
|
|
2757
|
+
* if (result.valid) console.log(`Issued by ${result.certification.certifierId}`)
|
|
2758
|
+
* ```
|
|
2759
|
+
*/
|
|
2760
|
+
export interface CertificationNamespace {
|
|
2761
|
+
/**
|
|
2762
|
+
* @description Issue a new certification.
|
|
2763
|
+
*
|
|
2764
|
+
* Creates a `contract` entity in Brainy with `endorses`, `attributedTo`,
|
|
2765
|
+
* and optionally `dependsOn` relationships.
|
|
2766
|
+
*
|
|
2767
|
+
* @param options - Certification details.
|
|
2768
|
+
* @param options.name - Certification name.
|
|
2769
|
+
* @param options.learnerId - The user receiving the certification.
|
|
2770
|
+
* @param options.score - Assessment score (0.0–1.0).
|
|
2771
|
+
* @param options.aiIssued - Whether the certification was AI-issued. Default: `false`.
|
|
2772
|
+
* @param options.upstreamCertificationId - Optional upstream cert for lineage.
|
|
2773
|
+
* @returns The created certification.
|
|
2774
|
+
*
|
|
2775
|
+
* @example
|
|
2776
|
+
* ```typescript
|
|
2777
|
+
* const cert = await soulcraft.certification.issue({
|
|
2778
|
+
* name: 'Recipe Master', learnerId: 'user-abc', score: 0.92,
|
|
2779
|
+
* })
|
|
2780
|
+
* ```
|
|
2781
|
+
*/
|
|
2782
|
+
issue(options: {
|
|
2783
|
+
name: string;
|
|
2784
|
+
learnerId: string;
|
|
2785
|
+
score: number;
|
|
2786
|
+
aiIssued?: boolean;
|
|
2787
|
+
upstreamCertificationId?: string;
|
|
2788
|
+
}): Promise<Certification>;
|
|
2789
|
+
/**
|
|
2790
|
+
* @description Verify a certification's validity and retrieve its details.
|
|
2791
|
+
*
|
|
2792
|
+
* @param certificationId - The certification ID to verify.
|
|
2793
|
+
* @returns Verification result with the certification and lineage data.
|
|
2794
|
+
*
|
|
2795
|
+
* @example
|
|
2796
|
+
* ```typescript
|
|
2797
|
+
* const result = await soulcraft.certification.verify('cert-xyz')
|
|
2798
|
+
* if (result.valid) console.log(`Score: ${result.certification.score}`)
|
|
2799
|
+
* ```
|
|
2800
|
+
*/
|
|
2801
|
+
verify(certificationId: string): Promise<{
|
|
2802
|
+
valid: boolean;
|
|
2803
|
+
certification: Certification | null;
|
|
2804
|
+
}>;
|
|
2805
|
+
/**
|
|
2806
|
+
* @description Get a certification with its full lineage chain.
|
|
2807
|
+
*
|
|
2808
|
+
* Traverses the `dependsOn` relationships to build the complete
|
|
2809
|
+
* certification ancestry.
|
|
2810
|
+
*
|
|
2811
|
+
* @param certificationId - The certification ID.
|
|
2812
|
+
* @returns The certification and its ancestor chain.
|
|
2813
|
+
*
|
|
2814
|
+
* @example
|
|
2815
|
+
* ```typescript
|
|
2816
|
+
* const { certification, lineage } = await soulcraft.certification.getWithLineage('cert-xyz')
|
|
2817
|
+
* console.log(`Lineage: ${lineage.map(c => c.name).join(' → ')}`)
|
|
2818
|
+
* ```
|
|
2819
|
+
*/
|
|
2820
|
+
getWithLineage(certificationId: string): Promise<{
|
|
2821
|
+
certification: Certification | null;
|
|
2822
|
+
lineage: Certification[];
|
|
2823
|
+
}>;
|
|
2824
|
+
/**
|
|
2825
|
+
* @description Compute an assessment score for a learner against required competencies.
|
|
2826
|
+
*
|
|
2827
|
+
* Score = demonstrated competencies (via `learns` edges) / total required competencies.
|
|
2828
|
+
*
|
|
2829
|
+
* @param options - Assessment options.
|
|
2830
|
+
* @param options.learnerId - The learner user ID.
|
|
2831
|
+
* @param options.competencyIds - Required competency entity IDs.
|
|
2832
|
+
* @param options.threshold - Passing threshold (0.0–1.0). Default: 0.8.
|
|
2833
|
+
* @returns Assessment result with score, pass/fail, and gap analysis.
|
|
2834
|
+
*
|
|
2835
|
+
* @example
|
|
2836
|
+
* ```typescript
|
|
2837
|
+
* const result = await soulcraft.certification.assess({
|
|
2838
|
+
* learnerId: 'user-abc',
|
|
2839
|
+
* competencyIds: ['comp-1', 'comp-2', 'comp-3'],
|
|
2840
|
+
* threshold: 0.8,
|
|
2841
|
+
* })
|
|
2842
|
+
* if (result.passed) console.log('Ready for certification!')
|
|
2843
|
+
* ```
|
|
2844
|
+
*/
|
|
2845
|
+
assess(options: {
|
|
2846
|
+
learnerId: string;
|
|
2847
|
+
competencyIds: string[];
|
|
2848
|
+
threshold?: number;
|
|
2849
|
+
}): Promise<AssessmentResult>;
|
|
2850
|
+
/**
|
|
2851
|
+
* @description List certifications issued by or to a user.
|
|
2852
|
+
*
|
|
2853
|
+
* @param options - Filter options.
|
|
2854
|
+
* @param options.issuedBy - Filter by certifier user ID.
|
|
2855
|
+
* @param options.issuedTo - Filter by learner user ID.
|
|
2856
|
+
* @param options.limit - Maximum number of results. Default: 50.
|
|
2857
|
+
* @returns Array of certifications.
|
|
2858
|
+
*
|
|
2859
|
+
* @example
|
|
2860
|
+
* ```typescript
|
|
2861
|
+
* const myCerts = await soulcraft.certification.list({ issuedTo: userId })
|
|
2862
|
+
* ```
|
|
2863
|
+
*/
|
|
2864
|
+
list(options?: {
|
|
2865
|
+
issuedBy?: string;
|
|
2866
|
+
issuedTo?: string;
|
|
2867
|
+
limit?: number;
|
|
2868
|
+
}): Promise<Certification[]>;
|
|
2869
|
+
}
|
|
2870
|
+
/**
|
|
2871
|
+
* @description Format conversion and validation for Soulcraft portable formats.
|
|
2872
|
+
*
|
|
2873
|
+
* Handles server-side conversion between source formats (wdoc, wslide, wviz,
|
|
2874
|
+
* wquiz) and output formats (PDF, HTML, Markdown, etc.). Visual rendering
|
|
2875
|
+
* stays in `@soulcraft/views` — this namespace handles data transformation only.
|
|
2876
|
+
*
|
|
2877
|
+
* @example Convert a document to PDF
|
|
2878
|
+
* ```typescript
|
|
2879
|
+
* const pdfBytes = await soulcraft.formats.convert('wdoc', 'pdf', {
|
|
2880
|
+
* content: documentJson,
|
|
2881
|
+
* options: { pageSize: 'A4', margin: '2cm' },
|
|
2882
|
+
* })
|
|
2883
|
+
* ```
|
|
2884
|
+
*
|
|
2885
|
+
* @example Validate a visualization document
|
|
2886
|
+
* ```typescript
|
|
2887
|
+
* const result = await soulcraft.formats.validate('wviz', vizDocument)
|
|
2888
|
+
* if (!result.valid) console.error(result.errors)
|
|
2889
|
+
* ```
|
|
2890
|
+
*/
|
|
2891
|
+
export interface FormatsNamespace {
|
|
2892
|
+
/**
|
|
2893
|
+
* @description Convert a Soulcraft format document to an output format.
|
|
2894
|
+
*
|
|
2895
|
+
* @param sourceFormat - Source format identifier (e.g. `'wdoc'`, `'wslide'`, `'wviz'`).
|
|
2896
|
+
* @param outputFormat - Target format identifier (e.g. `'pdf'`, `'html'`, `'markdown'`).
|
|
2897
|
+
* @param options - Conversion options.
|
|
2898
|
+
* @param options.content - The source document (JSON object or string).
|
|
2899
|
+
* @param options.options - Format-specific conversion options (page size, margins, etc.).
|
|
2900
|
+
* @returns The converted content as an ArrayBuffer (binary formats) or string (text formats).
|
|
2901
|
+
*
|
|
2902
|
+
* @example
|
|
2903
|
+
* ```typescript
|
|
2904
|
+
* const html = await soulcraft.formats.convert('wslide', 'html', {
|
|
2905
|
+
* content: slideshowJson,
|
|
2906
|
+
* options: { includeNotes: false },
|
|
2907
|
+
* })
|
|
2908
|
+
* ```
|
|
2909
|
+
*/
|
|
2910
|
+
convert(sourceFormat: string, outputFormat: string, options: {
|
|
2911
|
+
content: unknown;
|
|
2912
|
+
options?: Record<string, unknown>;
|
|
2913
|
+
}): Promise<string | ArrayBuffer>;
|
|
2914
|
+
/**
|
|
2915
|
+
* @description Validate a document against its format schema.
|
|
2916
|
+
*
|
|
2917
|
+
* @param format - Format identifier (e.g. `'wdoc'`, `'wviz'`, `'wquiz'`).
|
|
2918
|
+
* @param document - The document to validate.
|
|
2919
|
+
* @returns Validation result with any errors.
|
|
2920
|
+
*
|
|
2921
|
+
* @example
|
|
2922
|
+
* ```typescript
|
|
2923
|
+
* const result = await soulcraft.formats.validate('wquiz', quizDocument)
|
|
2924
|
+
* if (!result.valid) console.error(result.errors)
|
|
2925
|
+
* ```
|
|
2926
|
+
*/
|
|
2927
|
+
validate(format: string, document: unknown): Promise<FormatValidationResult>;
|
|
2928
|
+
/**
|
|
2929
|
+
* @description List available output formats and which source formats can convert to them.
|
|
2930
|
+
*
|
|
2931
|
+
* @returns Array of output format descriptors.
|
|
2932
|
+
*
|
|
2933
|
+
* @example
|
|
2934
|
+
* ```typescript
|
|
2935
|
+
* const formats = await soulcraft.formats.getOutputFormats()
|
|
2936
|
+
* const pdfFormat = formats.find(f => f.id === 'pdf')
|
|
2937
|
+
* console.log(`PDF supports: ${pdfFormat.sourceFormats.join(', ')}`)
|
|
2938
|
+
* ```
|
|
2939
|
+
*/
|
|
2940
|
+
getOutputFormats(): Promise<OutputFormat[]>;
|
|
2941
|
+
}
|
|
2942
|
+
//# sourceMappingURL=namespaces.d.ts.map
|