@granular-software/sdk 0.4.2 → 0.4.4
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/README.md +3 -41
- package/dist/cli/index.js +42 -42
- package/dist/index.d.mts +726 -3
- package/dist/index.d.ts +726 -3
- package/dist/index.js +53 -45
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -45
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -52
- package/dist/adapters/anthropic.d.mts +0 -64
- package/dist/adapters/anthropic.d.ts +0 -64
- package/dist/adapters/anthropic.js +0 -77
- package/dist/adapters/anthropic.js.map +0 -1
- package/dist/adapters/anthropic.mjs +0 -72
- package/dist/adapters/anthropic.mjs.map +0 -1
- package/dist/adapters/langchain.d.mts +0 -31
- package/dist/adapters/langchain.d.ts +0 -31
- package/dist/adapters/langchain.js +0 -49
- package/dist/adapters/langchain.js.map +0 -1
- package/dist/adapters/langchain.mjs +0 -46
- package/dist/adapters/langchain.mjs.map +0 -1
- package/dist/adapters/mastra.d.mts +0 -23
- package/dist/adapters/mastra.d.ts +0 -23
- package/dist/adapters/mastra.js +0 -26
- package/dist/adapters/mastra.js.map +0 -1
- package/dist/adapters/mastra.mjs +0 -24
- package/dist/adapters/mastra.mjs.map +0 -1
- package/dist/adapters/openai.d.mts +0 -76
- package/dist/adapters/openai.d.ts +0 -76
- package/dist/adapters/openai.js +0 -81
- package/dist/adapters/openai.js.map +0 -1
- package/dist/adapters/openai.mjs +0 -76
- package/dist/adapters/openai.mjs.map +0 -1
- package/dist/types-C0AVRsVR.d.mts +0 -726
- package/dist/types-C0AVRsVR.d.ts +0 -726
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,731 @@
|
|
|
1
1
|
import * as Automerge from '@automerge/automerge';
|
|
2
|
-
import { W as WSClientOptions, T as ToolWithHandler, P as PublishToolsResult, J as Job, a as ToolHandler, I as InstanceToolHandler, E as EffectInfo, b as ToolInfo, c as EffectsChangedEvent, d as ToolsChangedEvent, D as DomainState, G as GranularOptions, R as RecordUserOptions, U as User, C as ConnectOptions, e as EnvironmentData, f as GraphQLResult, g as DefineRelationshipOptions, h as RelationshipInfo, M as ModelRef, i as ManifestContent, j as RecordObjectOptions, k as RecordObjectResult, S as SandboxListResponse, l as Sandbox, m as CreateSandboxData, n as DeleteResponse, o as PermissionProfile, p as CreatePermissionProfileData, q as CreateEnvironmentData, r as Subject, A as AssignmentListResponse } from './types-C0AVRsVR.js';
|
|
3
|
-
export { ag as APIError, t as AccessTokenProvider, y as Assignment, L as Build, N as BuildListResponse, B as BuildPolicy, K as BuildStatus, Y as EffectHandler, O as EffectHandlerContext, Q as EffectSchema, V as EffectWithHandler, u as EndpointMode, z as EnvironmentListResponse, v as GranularAuth, Z as InstanceEffectHandler, _ as JobStatus, $ as JobSubmitResult, F as Manifest, ac as ManifestEffectDeclaration, ab as ManifestEffectSchema, ae as ManifestImport, H as ManifestListResponse, ad as ManifestOperation, a9 as ManifestPropertySpec, aa as ManifestRelationshipDef, af as ManifestVolume, x as PermissionProfileListResponse, w as PermissionRules, a0 as Prompt, X as PublishEffectsResult, a3 as RPCRequest, a6 as RPCRequestFromServer, a4 as RPCResponse, a5 as SyncMessage, a7 as ToolInvokeParams, a8 as ToolResultParams, s as ToolSchema, a1 as WSDisconnectInfo, a2 as WSReconnectErrorInfo } from './types-C0AVRsVR.js';
|
|
4
2
|
import { Doc } from '@automerge/automerge/slim';
|
|
5
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @module @granular-software/sdk/types
|
|
6
|
+
* Type definitions for the Granular SDK
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Configuration for the Granular client
|
|
10
|
+
*/
|
|
11
|
+
type AccessTokenProvider = () => Promise<string | null | undefined> | string | null | undefined;
|
|
12
|
+
type EndpointMode = 'auto' | 'local' | 'production';
|
|
13
|
+
interface GranularOptions {
|
|
14
|
+
/** Your Granular API key (for service/CLI auth; use with GRANULAR_API_KEY) */
|
|
15
|
+
apiKey?: string;
|
|
16
|
+
/** Application/session JWT (for user-context auth; use from simulator or getAccessToken) */
|
|
17
|
+
token?: string;
|
|
18
|
+
/** Optional provider used to refresh JWT before WebSocket (re)connect attempts */
|
|
19
|
+
tokenProvider?: AccessTokenProvider;
|
|
20
|
+
/** Optional API URL (for on-prem or testing) */
|
|
21
|
+
apiUrl?: string;
|
|
22
|
+
/** Optional endpoint mode when apiUrl is not explicitly provided */
|
|
23
|
+
endpointMode?: EndpointMode;
|
|
24
|
+
/** Optional WebSocket constructor (for Node.js environments) */
|
|
25
|
+
WebSocketCtor?: any;
|
|
26
|
+
/**
|
|
27
|
+
* Optional callback invoked when a connected WebSocket closes unexpectedly.
|
|
28
|
+
* Useful for forwarding close diagnostics to monitoring (e.g., Sentry).
|
|
29
|
+
*/
|
|
30
|
+
onUnexpectedClose?: (info: WSDisconnectInfo) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Optional callback invoked when automatic reconnect fails.
|
|
33
|
+
* Useful to capture auth or gateway rejection causes.
|
|
34
|
+
*/
|
|
35
|
+
onReconnectError?: (info: WSReconnectErrorInfo) => void;
|
|
36
|
+
}
|
|
37
|
+
/** Resolved auth credential: either apiKey or token must be provided */
|
|
38
|
+
type GranularAuth = string;
|
|
39
|
+
/**
|
|
40
|
+
* A user/subject object returned from recordUser()
|
|
41
|
+
*/
|
|
42
|
+
interface User {
|
|
43
|
+
/** Internal subject ID */
|
|
44
|
+
subjectId: string;
|
|
45
|
+
/** External identity ID (e.g. Auth0 ID) */
|
|
46
|
+
identityId: string;
|
|
47
|
+
/** User's display name */
|
|
48
|
+
name?: string;
|
|
49
|
+
/** User's email */
|
|
50
|
+
email?: string;
|
|
51
|
+
/** Permission profile IDs to be assigned when connecting */
|
|
52
|
+
permissions: string[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Options for recording a user
|
|
56
|
+
*/
|
|
57
|
+
interface RecordUserOptions {
|
|
58
|
+
/** External user/identity ID (e.g. your Auth0 or database user ID) */
|
|
59
|
+
userId: string;
|
|
60
|
+
/** User's display name */
|
|
61
|
+
name?: string;
|
|
62
|
+
/** User's email */
|
|
63
|
+
email?: string;
|
|
64
|
+
/** Permission profile IDs to assign when connecting to sandboxes */
|
|
65
|
+
permissions?: string[];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Subject as returned from the API
|
|
69
|
+
*/
|
|
70
|
+
interface Subject {
|
|
71
|
+
subjectId: string;
|
|
72
|
+
tenantId: string;
|
|
73
|
+
identityId: string;
|
|
74
|
+
email?: string | null;
|
|
75
|
+
name?: string | null;
|
|
76
|
+
metadata?: Record<string, unknown>;
|
|
77
|
+
createdAt: number;
|
|
78
|
+
updatedAt: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Options for connecting to a sandbox
|
|
82
|
+
*/
|
|
83
|
+
interface ConnectOptions {
|
|
84
|
+
/** The sandbox name or ID to connect to */
|
|
85
|
+
sandbox: string;
|
|
86
|
+
/** The user to connect as (from recordUser()) */
|
|
87
|
+
user: User;
|
|
88
|
+
/** Optional stable client ID. Defaults to `client_${Date.now()}`. Use a fixed
|
|
89
|
+
* value for long-lived effect hosts so tool catalogs don't accumulate. */
|
|
90
|
+
clientId?: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* A sandbox container
|
|
94
|
+
*/
|
|
95
|
+
interface Sandbox {
|
|
96
|
+
sandboxId: string;
|
|
97
|
+
tenantId: string;
|
|
98
|
+
name: string;
|
|
99
|
+
description?: string | null;
|
|
100
|
+
createdAt: number;
|
|
101
|
+
updatedAt: number;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Data for creating a new sandbox
|
|
105
|
+
*/
|
|
106
|
+
interface CreateSandboxData {
|
|
107
|
+
name: string;
|
|
108
|
+
description?: string;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* List response for sandboxes
|
|
112
|
+
*/
|
|
113
|
+
interface SandboxListResponse {
|
|
114
|
+
items: Sandbox[];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Rules defining what effects and resources are allowed or denied.
|
|
118
|
+
*/
|
|
119
|
+
interface PermissionRules {
|
|
120
|
+
/** Effect access rules */
|
|
121
|
+
effects?: {
|
|
122
|
+
/** Patterns for allowed effects (e.g. ["*"] for all, ["read_*"] for prefix match) */
|
|
123
|
+
allow?: string[];
|
|
124
|
+
/** Patterns for denied effects */
|
|
125
|
+
deny?: string[];
|
|
126
|
+
};
|
|
127
|
+
/** Legacy alias accepted by the backend while migrating to `effects`. */
|
|
128
|
+
tools?: {
|
|
129
|
+
/** Patterns for allowed effects (e.g. ["*"] for all, ["read_*"] for prefix match) */
|
|
130
|
+
allow?: string[];
|
|
131
|
+
/** Patterns for denied effects */
|
|
132
|
+
deny?: string[];
|
|
133
|
+
};
|
|
134
|
+
/** Resource access rules */
|
|
135
|
+
resources?: {
|
|
136
|
+
/** Patterns for allowed resources */
|
|
137
|
+
allow?: string[];
|
|
138
|
+
/** Patterns for denied resources */
|
|
139
|
+
deny?: string[];
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* A permission profile defines access controls for an environment
|
|
144
|
+
*/
|
|
145
|
+
interface PermissionProfile {
|
|
146
|
+
permissionProfileId: string;
|
|
147
|
+
sandboxId: string;
|
|
148
|
+
name: string;
|
|
149
|
+
rules: PermissionRules;
|
|
150
|
+
createdAt: number;
|
|
151
|
+
updatedAt: number;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Data for creating a new permission profile
|
|
155
|
+
*/
|
|
156
|
+
interface CreatePermissionProfileData {
|
|
157
|
+
name: string;
|
|
158
|
+
rules: PermissionRules;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* List response for permission profiles
|
|
162
|
+
*/
|
|
163
|
+
interface PermissionProfileListResponse {
|
|
164
|
+
items: PermissionProfile[];
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* An assignment links a subject to a sandbox with a permission profile
|
|
168
|
+
*/
|
|
169
|
+
interface Assignment {
|
|
170
|
+
assignmentId: string;
|
|
171
|
+
tenantId: string;
|
|
172
|
+
subjectId: string;
|
|
173
|
+
sandboxId: string;
|
|
174
|
+
permissionProfileId: string;
|
|
175
|
+
createdAt: number;
|
|
176
|
+
createdBy?: string | null;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* List response for assignments
|
|
180
|
+
*/
|
|
181
|
+
interface AssignmentListResponse {
|
|
182
|
+
items: Assignment[];
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Build policy for environments
|
|
186
|
+
*/
|
|
187
|
+
interface BuildPolicy {
|
|
188
|
+
mode: 'current' | 'pinned';
|
|
189
|
+
buildId?: string;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* An environment links a user (subject) to a sandbox with specific permissions
|
|
193
|
+
*/
|
|
194
|
+
interface EnvironmentData {
|
|
195
|
+
environmentId: string;
|
|
196
|
+
sandboxId: string;
|
|
197
|
+
buildId: string;
|
|
198
|
+
subjectId: string;
|
|
199
|
+
permissionProfileId: string;
|
|
200
|
+
buildPolicy: BuildPolicy;
|
|
201
|
+
createdAt: number;
|
|
202
|
+
updatedAt: number;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Data for creating a new environment
|
|
206
|
+
*/
|
|
207
|
+
interface CreateEnvironmentData {
|
|
208
|
+
/** The user/subject ID to create the environment for */
|
|
209
|
+
subjectId: string;
|
|
210
|
+
/** The permission profile to apply (optional - uses assignment if not specified) */
|
|
211
|
+
permissionProfileId?: string | null;
|
|
212
|
+
/** Build policy (defaults to current build) */
|
|
213
|
+
buildPolicy?: BuildPolicy;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* List response for environments
|
|
217
|
+
*/
|
|
218
|
+
interface EnvironmentListResponse {
|
|
219
|
+
items: EnvironmentData[];
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* A manifest describes the structure and behavior of a sandbox
|
|
223
|
+
*/
|
|
224
|
+
interface Manifest {
|
|
225
|
+
manifestId: string;
|
|
226
|
+
sandboxId: string;
|
|
227
|
+
version: string;
|
|
228
|
+
digest: string;
|
|
229
|
+
content?: Record<string, unknown>;
|
|
230
|
+
createdAt: number;
|
|
231
|
+
locked?: boolean;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* List response for manifests
|
|
235
|
+
*/
|
|
236
|
+
interface ManifestListResponse {
|
|
237
|
+
items: Manifest[];
|
|
238
|
+
}
|
|
239
|
+
type BuildStatus = 'queued' | 'building' | 'completed' | 'failed' | 'canceled';
|
|
240
|
+
/**
|
|
241
|
+
* A build represents a compiled version of a manifest
|
|
242
|
+
*/
|
|
243
|
+
interface Build {
|
|
244
|
+
buildId: string;
|
|
245
|
+
sandboxId: string;
|
|
246
|
+
manifestId: string;
|
|
247
|
+
status: BuildStatus;
|
|
248
|
+
graphBinaryId?: string | null;
|
|
249
|
+
logsUri?: string | null;
|
|
250
|
+
createdAt: number;
|
|
251
|
+
updatedAt: number;
|
|
252
|
+
isCurrent?: boolean;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* List response for builds
|
|
256
|
+
*/
|
|
257
|
+
interface BuildListResponse {
|
|
258
|
+
items: Build[];
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Effect handler for static/global effects: receives (input, context)
|
|
262
|
+
*/
|
|
263
|
+
interface EffectHandlerContext {
|
|
264
|
+
effectClientId: string;
|
|
265
|
+
sandboxId: string;
|
|
266
|
+
environmentId: string;
|
|
267
|
+
sessionId: string;
|
|
268
|
+
tenantId?: string;
|
|
269
|
+
principalId?: string;
|
|
270
|
+
permissionProfileId?: string;
|
|
271
|
+
user: {
|
|
272
|
+
subjectId: string;
|
|
273
|
+
identityId?: string;
|
|
274
|
+
principalId?: string;
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
type ToolHandler = (input: any, context: EffectHandlerContext) => Promise<unknown>;
|
|
278
|
+
/**
|
|
279
|
+
* Effect handler for instance methods: receives (objectId, input, context)
|
|
280
|
+
*/
|
|
281
|
+
type InstanceToolHandler = (id: string, input: any, context: EffectHandlerContext) => Promise<unknown>;
|
|
282
|
+
/**
|
|
283
|
+
* Effect schema for declaring or registering an effect.
|
|
284
|
+
*
|
|
285
|
+
* Effects come in three flavours:
|
|
286
|
+
*
|
|
287
|
+
* 1. **Instance methods** — set `className`, omit `static`.
|
|
288
|
+
* In the sandbox: `tolkien.get_bio({ detailed: true })`
|
|
289
|
+
* Handler signature: `(objectId: string, params: any) => any`
|
|
290
|
+
*
|
|
291
|
+
* 2. **Static methods** — set `className` + `static: true`.
|
|
292
|
+
* In the sandbox: `Author.search({ query: 'tolkien' })`
|
|
293
|
+
* Handler signature: `(params: any) => any`
|
|
294
|
+
*
|
|
295
|
+
* 3. **Global effects** — omit `className`.
|
|
296
|
+
* In the sandbox: `global_search({ query: 'rings' })`
|
|
297
|
+
* Handler signature: `(params: any) => any`
|
|
298
|
+
*
|
|
299
|
+
* Both `inputSchema` and `outputSchema` accept JSON Schema objects.
|
|
300
|
+
* The `outputSchema` drives the return type in the auto-generated
|
|
301
|
+
* TypeScript declarations that sandbox code imports from `./sandbox-tools`.
|
|
302
|
+
*/
|
|
303
|
+
interface ToolSchema {
|
|
304
|
+
effectKey?: string;
|
|
305
|
+
name: string;
|
|
306
|
+
description: string;
|
|
307
|
+
/** JSON Schema for the effect input parameters */
|
|
308
|
+
inputSchema: Record<string, unknown>;
|
|
309
|
+
/**
|
|
310
|
+
* JSON Schema for the tool's return value.
|
|
311
|
+
* Used to generate typed return types in the sandbox TypeScript declarations.
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* ```typescript
|
|
315
|
+
* outputSchema: {
|
|
316
|
+
* type: 'object',
|
|
317
|
+
* properties: {
|
|
318
|
+
* bio: { type: 'string', description: 'The biography text' },
|
|
319
|
+
* source: { type: 'string', description: 'Source of the bio' },
|
|
320
|
+
* },
|
|
321
|
+
* required: ['bio'],
|
|
322
|
+
* }
|
|
323
|
+
* // Generates: Promise<{ bio: string; source?: string }>
|
|
324
|
+
* ```
|
|
325
|
+
*/
|
|
326
|
+
outputSchema?: Record<string, unknown>;
|
|
327
|
+
stability?: 'stable' | 'experimental' | 'deprecated';
|
|
328
|
+
provenance?: {
|
|
329
|
+
source: 'mcp' | 'custom';
|
|
330
|
+
};
|
|
331
|
+
tags?: string[];
|
|
332
|
+
/**
|
|
333
|
+
* The class this effect belongs to (e.g., `'author'`, `'book'`).
|
|
334
|
+
* When set, the effect becomes a method on the auto-generated class.
|
|
335
|
+
* Omit for global effects (standalone exported functions).
|
|
336
|
+
*/
|
|
337
|
+
className?: string;
|
|
338
|
+
/**
|
|
339
|
+
* If `true`, this is a static/class-level method (no object ID required).
|
|
340
|
+
* If `false` or omitted and `className` is set, this is an instance method
|
|
341
|
+
* that operates on a specific object (the object's real-world ID is
|
|
342
|
+
* passed as the first argument to the handler).
|
|
343
|
+
*/
|
|
344
|
+
static?: boolean;
|
|
345
|
+
}
|
|
346
|
+
type EffectSchema = ToolSchema;
|
|
347
|
+
/**
|
|
348
|
+
* Effect with handler — what users provide to `registerEffect()`.
|
|
349
|
+
*
|
|
350
|
+
* - **Instance methods** (`className` set, `static` omitted):
|
|
351
|
+
* handler receives `(objectId: string, params: any)`
|
|
352
|
+
* - **Static methods** (`className` set, `static: true`):
|
|
353
|
+
* handler receives `(params: any)`
|
|
354
|
+
* - **Global tools** (no `className`):
|
|
355
|
+
* handler receives `(params: any)`
|
|
356
|
+
*/
|
|
357
|
+
interface ToolWithHandler extends ToolSchema {
|
|
358
|
+
handler: ToolHandler | InstanceToolHandler;
|
|
359
|
+
}
|
|
360
|
+
type EffectWithHandler = ToolWithHandler;
|
|
361
|
+
/**
|
|
362
|
+
* Result from publishing or synchronizing effects
|
|
363
|
+
*/
|
|
364
|
+
interface PublishToolsResult {
|
|
365
|
+
accepted: boolean;
|
|
366
|
+
domainRevision: string;
|
|
367
|
+
rejected?: Array<{
|
|
368
|
+
name: string;
|
|
369
|
+
reason: string;
|
|
370
|
+
}>;
|
|
371
|
+
}
|
|
372
|
+
type PublishEffectsResult = PublishToolsResult;
|
|
373
|
+
/**
|
|
374
|
+
* Domain state response
|
|
375
|
+
*/
|
|
376
|
+
interface DomainState {
|
|
377
|
+
activeDomainRevision?: string;
|
|
378
|
+
tools?: Array<{
|
|
379
|
+
name: string;
|
|
380
|
+
description?: string;
|
|
381
|
+
inputSchema?: Record<string, unknown>;
|
|
382
|
+
outputSchema?: Record<string, unknown>;
|
|
383
|
+
}>;
|
|
384
|
+
[key: string]: unknown;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Information about a live or declared effect
|
|
388
|
+
*/
|
|
389
|
+
interface ToolInfo {
|
|
390
|
+
effectKey?: string;
|
|
391
|
+
/** Unique name of the effect */
|
|
392
|
+
name: string;
|
|
393
|
+
/** Description of what the effect does */
|
|
394
|
+
description?: string;
|
|
395
|
+
/** JSON Schema for effect input */
|
|
396
|
+
inputSchema?: Record<string, unknown>;
|
|
397
|
+
/** JSON Schema for effect output */
|
|
398
|
+
outputSchema?: Record<string, unknown>;
|
|
399
|
+
/** Client ID that published this effect (absent for domain-only entries) */
|
|
400
|
+
clientId?: string;
|
|
401
|
+
/** Whether the effect is ready for use (has a registered handler) */
|
|
402
|
+
ready: boolean;
|
|
403
|
+
/** Timestamp when the effect was published */
|
|
404
|
+
publishedAt?: number;
|
|
405
|
+
/** Class this effect belongs to (instance/static method) */
|
|
406
|
+
className?: string;
|
|
407
|
+
/** Whether this is a static method */
|
|
408
|
+
static?: boolean;
|
|
409
|
+
}
|
|
410
|
+
interface EffectInfo extends ToolInfo {
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Event data when the list of available effects changes
|
|
414
|
+
*/
|
|
415
|
+
interface ToolsChangedEvent {
|
|
416
|
+
/** The current list of all available effects */
|
|
417
|
+
tools: ToolInfo[];
|
|
418
|
+
/** Names of effects that were added or updated */
|
|
419
|
+
added: string[];
|
|
420
|
+
/** Names of effects that were removed */
|
|
421
|
+
removed: string[];
|
|
422
|
+
}
|
|
423
|
+
interface EffectsChangedEvent extends ToolsChangedEvent {
|
|
424
|
+
/** The current list of all available effects */
|
|
425
|
+
effects: EffectInfo[];
|
|
426
|
+
}
|
|
427
|
+
type EffectHandler = ToolHandler;
|
|
428
|
+
type InstanceEffectHandler = InstanceToolHandler;
|
|
429
|
+
type JobStatus = 'queued' | 'running' | 'succeeded' | 'failed' | 'timeout' | 'canceled';
|
|
430
|
+
/**
|
|
431
|
+
* Result from submitting a job
|
|
432
|
+
*/
|
|
433
|
+
interface JobSubmitResult {
|
|
434
|
+
jobId: string;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Represents a job executed in the sandbox
|
|
438
|
+
*/
|
|
439
|
+
interface Job {
|
|
440
|
+
/** Unique Job ID */
|
|
441
|
+
id: string;
|
|
442
|
+
/** Current status of the job */
|
|
443
|
+
status: JobStatus;
|
|
444
|
+
/** Promise that resolves with the job result */
|
|
445
|
+
result: Promise<unknown>;
|
|
446
|
+
/** Subscribe to job events */
|
|
447
|
+
on(event: string, handler: (data: unknown) => void): void;
|
|
448
|
+
}
|
|
449
|
+
interface Prompt {
|
|
450
|
+
id: string;
|
|
451
|
+
type: 'confirm' | 'choice' | 'input';
|
|
452
|
+
title: string;
|
|
453
|
+
message: string;
|
|
454
|
+
options?: string[];
|
|
455
|
+
defaultValue?: unknown;
|
|
456
|
+
}
|
|
457
|
+
interface WSDisconnectInfo {
|
|
458
|
+
code?: number;
|
|
459
|
+
reason?: string;
|
|
460
|
+
wasClean?: boolean;
|
|
461
|
+
unexpected: boolean;
|
|
462
|
+
timestamp: number;
|
|
463
|
+
reconnectScheduled: boolean;
|
|
464
|
+
reconnectDelayMs?: number;
|
|
465
|
+
}
|
|
466
|
+
interface WSReconnectErrorInfo {
|
|
467
|
+
sessionId: string;
|
|
468
|
+
error: string;
|
|
469
|
+
timestamp: number;
|
|
470
|
+
}
|
|
471
|
+
interface WSClientOptions {
|
|
472
|
+
url: string;
|
|
473
|
+
sessionId: string;
|
|
474
|
+
token: string;
|
|
475
|
+
tokenProvider?: AccessTokenProvider;
|
|
476
|
+
WebSocketCtor?: any;
|
|
477
|
+
onUnexpectedClose?: (info: WSDisconnectInfo) => void;
|
|
478
|
+
onReconnectError?: (info: WSReconnectErrorInfo) => void;
|
|
479
|
+
}
|
|
480
|
+
interface RPCRequest {
|
|
481
|
+
type: 'rpc';
|
|
482
|
+
method: string;
|
|
483
|
+
params: unknown;
|
|
484
|
+
id: string;
|
|
485
|
+
}
|
|
486
|
+
interface RPCResponse {
|
|
487
|
+
type: 'rpc_result' | 'rpc_error';
|
|
488
|
+
id: string;
|
|
489
|
+
result?: unknown;
|
|
490
|
+
error?: {
|
|
491
|
+
code: number;
|
|
492
|
+
message: string;
|
|
493
|
+
data?: unknown;
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
interface SyncMessage {
|
|
497
|
+
type: 'sync';
|
|
498
|
+
message?: string | number[] | Uint8Array;
|
|
499
|
+
data?: number[];
|
|
500
|
+
}
|
|
501
|
+
interface RPCRequestFromServer {
|
|
502
|
+
type: 'rpc';
|
|
503
|
+
method: string;
|
|
504
|
+
params: unknown;
|
|
505
|
+
id: string;
|
|
506
|
+
}
|
|
507
|
+
interface ToolInvokeParams {
|
|
508
|
+
callId: string;
|
|
509
|
+
toolName: string;
|
|
510
|
+
input: unknown;
|
|
511
|
+
}
|
|
512
|
+
interface ToolResultParams {
|
|
513
|
+
callId: string;
|
|
514
|
+
result?: unknown;
|
|
515
|
+
error?: string | {
|
|
516
|
+
code: string;
|
|
517
|
+
message: string;
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* A model reference as returned from relationship queries
|
|
522
|
+
*/
|
|
523
|
+
interface ModelRef {
|
|
524
|
+
path: string;
|
|
525
|
+
label?: string;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Relationship info as returned from the GraphQL API.
|
|
529
|
+
* Represents a typed, bidirectional relationship between two model types,
|
|
530
|
+
* seen from one model's perspective.
|
|
531
|
+
*/
|
|
532
|
+
interface RelationshipInfo {
|
|
533
|
+
/** Unique name of this relationship definition */
|
|
534
|
+
name: string;
|
|
535
|
+
/** The submodel on this model that holds the relationship */
|
|
536
|
+
local_submodel: ModelRef;
|
|
537
|
+
/** Whether this side is a "many" collection */
|
|
538
|
+
local_is_many: boolean;
|
|
539
|
+
/** The submodel on the foreign model */
|
|
540
|
+
foreign_submodel: ModelRef;
|
|
541
|
+
/** Whether the foreign side is a "many" collection */
|
|
542
|
+
foreign_is_many: boolean;
|
|
543
|
+
/** The foreign model type */
|
|
544
|
+
foreign_model: ModelRef;
|
|
545
|
+
/** Computed relationship kind: "one_to_one" | "one_to_many" | "many_to_one" | "many_to_many" */
|
|
546
|
+
relationship_kind: 'one_to_one' | 'one_to_many' | 'many_to_one' | 'many_to_many';
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Options for defining a relationship between two model types
|
|
550
|
+
*/
|
|
551
|
+
interface DefineRelationshipOptions {
|
|
552
|
+
/** The model to define the relationship on (the "left" / "local" type) */
|
|
553
|
+
model: string;
|
|
554
|
+
/** The submodel name on the local model (e.g., "books") */
|
|
555
|
+
localSubmodel: string;
|
|
556
|
+
/** Whether the local side is "many" */
|
|
557
|
+
localIsMany: boolean;
|
|
558
|
+
/** The foreign model type (e.g., "book") */
|
|
559
|
+
foreignModel: string;
|
|
560
|
+
/** The submodel name on the foreign model (e.g., "author") */
|
|
561
|
+
foreignSubmodel: string;
|
|
562
|
+
/** Whether the foreign side is "many" */
|
|
563
|
+
foreignIsMany: boolean;
|
|
564
|
+
/** Optional relationship name (auto-generated if omitted) */
|
|
565
|
+
name?: string;
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Options for creating or updating a class instance in the graph.
|
|
569
|
+
*
|
|
570
|
+
* `recordObject` uses the graph's `instantiate` (find-or-create) semantics:
|
|
571
|
+
* if an instance with the given `id` already exists under the class, its
|
|
572
|
+
* fields are updated in place; otherwise a new instance is created.
|
|
573
|
+
*/
|
|
574
|
+
interface RecordObjectOptions {
|
|
575
|
+
/** The class to instantiate (e.g., "author") */
|
|
576
|
+
className: string;
|
|
577
|
+
/**
|
|
578
|
+
* Real-world object ID. Unique within its class, but two objects of
|
|
579
|
+
* different classes may share the same ID. Internally the SDK derives
|
|
580
|
+
* a unique graph path as `{className}__{id}`.
|
|
581
|
+
*/
|
|
582
|
+
id: string;
|
|
583
|
+
/** Optional display label (defaults to `id`) */
|
|
584
|
+
label?: string;
|
|
585
|
+
/** Scalar field values to set on the instance */
|
|
586
|
+
fields?: Record<string, string | number | boolean | null>;
|
|
587
|
+
/**
|
|
588
|
+
* Relationship attachments.
|
|
589
|
+
* Keys are relationship submodel names. Values are real-world IDs
|
|
590
|
+
* (not graph paths) — the SDK resolves them using the foreign class
|
|
591
|
+
* derived from the relationship definition.
|
|
592
|
+
* - For a "one" side: pass a single target ID (string)
|
|
593
|
+
* - For a "many" side: pass an array of target IDs
|
|
594
|
+
*/
|
|
595
|
+
relationships?: Record<string, string | string[]>;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Return value from `recordObject()`
|
|
599
|
+
*/
|
|
600
|
+
interface RecordObjectResult {
|
|
601
|
+
/** The internal graph path (e.g., "author__tolkien") */
|
|
602
|
+
path: string;
|
|
603
|
+
/** The real-world object ID as provided by the caller (e.g., "tolkien") */
|
|
604
|
+
id: string;
|
|
605
|
+
/** Whether the instance was newly created (false = updated) */
|
|
606
|
+
created: boolean;
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* Property specification in a manifest operation
|
|
610
|
+
*/
|
|
611
|
+
interface ManifestPropertySpec {
|
|
612
|
+
value?: string | number | boolean;
|
|
613
|
+
ref?: string;
|
|
614
|
+
instanceOf?: string;
|
|
615
|
+
create?: string;
|
|
616
|
+
has?: Record<string, ManifestPropertySpec>;
|
|
617
|
+
type?: string;
|
|
618
|
+
description?: string;
|
|
619
|
+
required?: boolean;
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Relationship definition between two classes
|
|
623
|
+
*/
|
|
624
|
+
interface ManifestRelationshipDef {
|
|
625
|
+
/** Optional name (auto-generated from left_right if omitted) */
|
|
626
|
+
name?: string;
|
|
627
|
+
/** Left model path */
|
|
628
|
+
left: string;
|
|
629
|
+
/** Right model path */
|
|
630
|
+
right: string;
|
|
631
|
+
/** Submodel name on the left model */
|
|
632
|
+
leftSubmodel: string;
|
|
633
|
+
/** Submodel name on the right model */
|
|
634
|
+
rightSubmodel: string;
|
|
635
|
+
/** Whether the left side is a collection */
|
|
636
|
+
leftIsMany: boolean;
|
|
637
|
+
/** Whether the right side is a collection */
|
|
638
|
+
rightIsMany: boolean;
|
|
639
|
+
}
|
|
640
|
+
interface ManifestEffectSchema {
|
|
641
|
+
type: string;
|
|
642
|
+
properties?: Record<string, unknown>;
|
|
643
|
+
required?: string[];
|
|
644
|
+
items?: unknown;
|
|
645
|
+
description?: string;
|
|
646
|
+
[key: string]: unknown;
|
|
647
|
+
}
|
|
648
|
+
interface ManifestEffectDeclaration {
|
|
649
|
+
name: string;
|
|
650
|
+
description?: string;
|
|
651
|
+
attachedClass?: string;
|
|
652
|
+
isStatic?: boolean;
|
|
653
|
+
inputSchema: ManifestEffectSchema;
|
|
654
|
+
outputSchema?: ManifestEffectSchema;
|
|
655
|
+
stability?: 'stable' | 'experimental' | 'deprecated';
|
|
656
|
+
tags?: string[];
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* A single operation in a manifest volume
|
|
660
|
+
*/
|
|
661
|
+
interface ManifestOperation {
|
|
662
|
+
/** Create a new model/class */
|
|
663
|
+
create?: string;
|
|
664
|
+
/** Target an existing model for modification */
|
|
665
|
+
on?: string;
|
|
666
|
+
/** Extend from a parent class */
|
|
667
|
+
extends?: string;
|
|
668
|
+
/** Instantiate a type */
|
|
669
|
+
instanceOf?: string;
|
|
670
|
+
/** Define submodels/fields */
|
|
671
|
+
has?: Record<string, ManifestPropertySpec>;
|
|
672
|
+
/** Define a relationship between two classes */
|
|
673
|
+
defineRelationship?: ManifestRelationshipDef;
|
|
674
|
+
/** Declare a build-owned effect */
|
|
675
|
+
withEffect?: ManifestEffectDeclaration;
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* A volume in a manifest
|
|
679
|
+
*/
|
|
680
|
+
/**
|
|
681
|
+
* Import descriptor for referencing modules
|
|
682
|
+
*/
|
|
683
|
+
interface ManifestImport {
|
|
684
|
+
/** Alias prefix used in operations (e.g., "@std") */
|
|
685
|
+
alias: string;
|
|
686
|
+
/** Module name (e.g., "standard_modules") */
|
|
687
|
+
name: string;
|
|
688
|
+
/** Version label (e.g., "prod", "v1.2.3") */
|
|
689
|
+
label?: string;
|
|
690
|
+
}
|
|
691
|
+
interface ManifestVolume {
|
|
692
|
+
name: string;
|
|
693
|
+
scope: 'sandbox' | 'build' | 'user';
|
|
694
|
+
imports?: ManifestImport[];
|
|
695
|
+
operations: ManifestOperation[];
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* A manifest defines the structure of a sandbox's data model
|
|
699
|
+
*/
|
|
700
|
+
interface ManifestContent {
|
|
701
|
+
schemaVersion: 2;
|
|
702
|
+
name: string;
|
|
703
|
+
description?: string;
|
|
704
|
+
volumes: ManifestVolume[];
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Result from a GraphQL query execution
|
|
708
|
+
*/
|
|
709
|
+
interface GraphQLResult<T = any> {
|
|
710
|
+
data?: T;
|
|
711
|
+
errors?: Array<{
|
|
712
|
+
message: string;
|
|
713
|
+
locations?: Array<{
|
|
714
|
+
line: number;
|
|
715
|
+
column: number;
|
|
716
|
+
}>;
|
|
717
|
+
path?: Array<string | number>;
|
|
718
|
+
extensions?: Record<string, any>;
|
|
719
|
+
}>;
|
|
720
|
+
}
|
|
721
|
+
interface APIError {
|
|
722
|
+
error: string;
|
|
723
|
+
message?: string;
|
|
724
|
+
}
|
|
725
|
+
interface DeleteResponse {
|
|
726
|
+
deleted: boolean;
|
|
727
|
+
}
|
|
728
|
+
|
|
6
729
|
declare class WSClient {
|
|
7
730
|
private ws;
|
|
8
731
|
private url;
|
|
@@ -704,4 +1427,4 @@ declare class Granular {
|
|
|
704
1427
|
private request;
|
|
705
1428
|
}
|
|
706
1429
|
|
|
707
|
-
export { AssignmentListResponse, ConnectOptions, CreateEnvironmentData, CreatePermissionProfileData, CreateSandboxData, DefineRelationshipOptions, DeleteResponse, DomainState, EffectInfo, EffectsChangedEvent, Environment, EnvironmentData, Granular, GranularOptions, GraphQLResult, InstanceToolHandler, Job, ManifestContent, ModelRef, PermissionProfile, PublishToolsResult, RecordObjectOptions, RecordObjectResult, RecordUserOptions, RelationshipInfo, Sandbox, SandboxListResponse, Session, Subject, ToolHandler, ToolInfo, ToolWithHandler, ToolsChangedEvent, User, WSClient, WSClientOptions };
|
|
1430
|
+
export { type APIError, type AccessTokenProvider, type Assignment, type AssignmentListResponse, type Build, type BuildListResponse, type BuildPolicy, type BuildStatus, type ConnectOptions, type CreateEnvironmentData, type CreatePermissionProfileData, type CreateSandboxData, type DefineRelationshipOptions, type DeleteResponse, type DomainState, type EffectHandler, type EffectHandlerContext, type EffectInfo, type EffectSchema, type EffectWithHandler, type EffectsChangedEvent, type EndpointMode, Environment, type EnvironmentData, type EnvironmentListResponse, Granular, type GranularAuth, type GranularOptions, type GraphQLResult, type InstanceEffectHandler, type InstanceToolHandler, type Job, type JobStatus, type JobSubmitResult, type Manifest, type ManifestContent, type ManifestEffectDeclaration, type ManifestEffectSchema, type ManifestImport, type ManifestListResponse, type ManifestOperation, type ManifestPropertySpec, type ManifestRelationshipDef, type ManifestVolume, type ModelRef, type PermissionProfile, type PermissionProfileListResponse, type PermissionRules, type Prompt, type PublishEffectsResult, type PublishToolsResult, type RPCRequest, type RPCRequestFromServer, type RPCResponse, type RecordObjectOptions, type RecordObjectResult, type RecordUserOptions, type RelationshipInfo, type Sandbox, type SandboxListResponse, Session, type Subject, type SyncMessage, type ToolHandler, type ToolInfo, type ToolInvokeParams, type ToolResultParams, type ToolSchema, type ToolWithHandler, type ToolsChangedEvent, type User, WSClient, type WSClientOptions, type WSDisconnectInfo, type WSReconnectErrorInfo };
|