@granular-software/sdk 0.4.3 → 0.4.5

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/index.d.mts CHANGED
@@ -1,8 +1,777 @@
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.mjs';
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.mjs';
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
+ /** Optional session heap seed. Each item is eagerly hydrated into the session heap on connect. */
92
+ initialHeap?: Array<{
93
+ className: string;
94
+ id: string;
95
+ }>;
96
+ }
97
+ /**
98
+ * A sandbox container
99
+ */
100
+ interface Sandbox {
101
+ sandboxId: string;
102
+ tenantId: string;
103
+ name: string;
104
+ description?: string | null;
105
+ createdAt: number;
106
+ updatedAt: number;
107
+ }
108
+ /**
109
+ * Data for creating a new sandbox
110
+ */
111
+ interface CreateSandboxData {
112
+ name: string;
113
+ description?: string;
114
+ }
115
+ /**
116
+ * List response for sandboxes
117
+ */
118
+ interface SandboxListResponse {
119
+ items: Sandbox[];
120
+ }
121
+ /**
122
+ * Rules defining what effects and resources are allowed or denied.
123
+ */
124
+ interface PermissionRules {
125
+ /** Effect access rules */
126
+ effects?: {
127
+ /** Patterns for allowed effects (e.g. ["*"] for all, ["read_*"] for prefix match) */
128
+ allow?: string[];
129
+ /** Patterns for denied effects */
130
+ deny?: string[];
131
+ };
132
+ /** Legacy alias accepted by the backend while migrating to `effects`. */
133
+ tools?: {
134
+ /** Patterns for allowed effects (e.g. ["*"] for all, ["read_*"] for prefix match) */
135
+ allow?: string[];
136
+ /** Patterns for denied effects */
137
+ deny?: string[];
138
+ };
139
+ /** Resource access rules */
140
+ resources?: {
141
+ /** Patterns for allowed resources */
142
+ allow?: string[];
143
+ /** Patterns for denied resources */
144
+ deny?: string[];
145
+ };
146
+ }
147
+ /**
148
+ * A permission profile defines access controls for an environment
149
+ */
150
+ interface PermissionProfile {
151
+ permissionProfileId: string;
152
+ sandboxId: string;
153
+ name: string;
154
+ rules: PermissionRules;
155
+ createdAt: number;
156
+ updatedAt: number;
157
+ }
158
+ /**
159
+ * Data for creating a new permission profile
160
+ */
161
+ interface CreatePermissionProfileData {
162
+ name: string;
163
+ rules: PermissionRules;
164
+ }
165
+ /**
166
+ * List response for permission profiles
167
+ */
168
+ interface PermissionProfileListResponse {
169
+ items: PermissionProfile[];
170
+ }
171
+ /**
172
+ * An assignment links a subject to a sandbox with a permission profile
173
+ */
174
+ interface Assignment {
175
+ assignmentId: string;
176
+ tenantId: string;
177
+ subjectId: string;
178
+ sandboxId: string;
179
+ permissionProfileId: string;
180
+ createdAt: number;
181
+ createdBy?: string | null;
182
+ }
183
+ /**
184
+ * List response for assignments
185
+ */
186
+ interface AssignmentListResponse {
187
+ items: Assignment[];
188
+ }
189
+ /**
190
+ * Build policy for environments
191
+ */
192
+ interface BuildPolicy {
193
+ mode: 'current' | 'pinned';
194
+ buildId?: string;
195
+ }
196
+ /**
197
+ * An environment links a user (subject) to a sandbox with specific permissions
198
+ */
199
+ interface EnvironmentData {
200
+ environmentId: string;
201
+ sandboxId: string;
202
+ buildId: string;
203
+ subjectId: string;
204
+ permissionProfileId: string;
205
+ buildPolicy: BuildPolicy;
206
+ createdAt: number;
207
+ updatedAt: number;
208
+ }
209
+ /**
210
+ * Data for creating a new environment
211
+ */
212
+ interface CreateEnvironmentData {
213
+ /** The user/subject ID to create the environment for */
214
+ subjectId: string;
215
+ /** The permission profile to apply (optional - uses assignment if not specified) */
216
+ permissionProfileId?: string | null;
217
+ /** Build policy (defaults to current build) */
218
+ buildPolicy?: BuildPolicy;
219
+ }
220
+ /**
221
+ * List response for environments
222
+ */
223
+ interface EnvironmentListResponse {
224
+ items: EnvironmentData[];
225
+ }
226
+ /**
227
+ * A manifest describes the structure and behavior of a sandbox
228
+ */
229
+ interface Manifest {
230
+ manifestId: string;
231
+ sandboxId: string;
232
+ version: string;
233
+ digest: string;
234
+ content?: Record<string, unknown>;
235
+ createdAt: number;
236
+ locked?: boolean;
237
+ }
238
+ /**
239
+ * List response for manifests
240
+ */
241
+ interface ManifestListResponse {
242
+ items: Manifest[];
243
+ }
244
+ type BuildStatus = 'queued' | 'building' | 'completed' | 'failed' | 'canceled';
245
+ /**
246
+ * A build represents a compiled version of a manifest
247
+ */
248
+ interface Build {
249
+ buildId: string;
250
+ sandboxId: string;
251
+ manifestId: string;
252
+ status: BuildStatus;
253
+ graphBinaryId?: string | null;
254
+ logsUri?: string | null;
255
+ createdAt: number;
256
+ updatedAt: number;
257
+ isCurrent?: boolean;
258
+ }
259
+ /**
260
+ * List response for builds
261
+ */
262
+ interface BuildListResponse {
263
+ items: Build[];
264
+ }
265
+ /**
266
+ * Effect handler for static/global effects: receives (input, context)
267
+ */
268
+ interface EffectHandlerContext {
269
+ effectClientId: string;
270
+ sandboxId: string;
271
+ environmentId: string;
272
+ sessionId: string;
273
+ tenantId?: string;
274
+ principalId?: string;
275
+ permissionProfileId?: string;
276
+ user: {
277
+ subjectId: string;
278
+ identityId?: string;
279
+ principalId?: string;
280
+ };
281
+ }
282
+ type ToolHandler = (input: any, context: EffectHandlerContext) => Promise<unknown>;
283
+ /**
284
+ * Effect handler for instance methods: receives (objectId, input, context)
285
+ */
286
+ type InstanceToolHandler = (id: string, input: any, context: EffectHandlerContext) => Promise<unknown>;
287
+ /**
288
+ * Effect schema for declaring or registering an effect.
289
+ *
290
+ * Effects come in three flavours:
291
+ *
292
+ * 1. **Instance methods** — set `className`, omit `static`.
293
+ * In the sandbox: `tolkien.get_bio({ detailed: true })`
294
+ * Handler signature: `(objectId: string, params: any) => any`
295
+ *
296
+ * 2. **Static methods** — set `className` + `static: true`.
297
+ * In the sandbox: `Author.search({ query: 'tolkien' })`
298
+ * Handler signature: `(params: any) => any`
299
+ *
300
+ * 3. **Global effects** — omit `className`.
301
+ * In the sandbox: `global_search({ query: 'rings' })`
302
+ * Handler signature: `(params: any) => any`
303
+ *
304
+ * Both `inputSchema` and `outputSchema` accept JSON Schema objects.
305
+ * The `outputSchema` drives the return type in the auto-generated
306
+ * TypeScript declarations that sandbox code imports from `./sandbox-tools`.
307
+ */
308
+ interface ToolSchema {
309
+ effectKey?: string;
310
+ name: string;
311
+ description: string;
312
+ /** JSON Schema for the effect input parameters */
313
+ inputSchema: Record<string, unknown>;
314
+ /**
315
+ * JSON Schema for the tool's return value.
316
+ * Used to generate typed return types in the sandbox TypeScript declarations.
317
+ *
318
+ * @example
319
+ * ```typescript
320
+ * outputSchema: {
321
+ * type: 'object',
322
+ * properties: {
323
+ * bio: { type: 'string', description: 'The biography text' },
324
+ * source: { type: 'string', description: 'Source of the bio' },
325
+ * },
326
+ * required: ['bio'],
327
+ * }
328
+ * // Generates: Promise<{ bio: string; source?: string }>
329
+ * ```
330
+ */
331
+ outputSchema?: Record<string, unknown>;
332
+ stability?: 'stable' | 'experimental' | 'deprecated';
333
+ provenance?: {
334
+ source: 'mcp' | 'custom';
335
+ };
336
+ tags?: string[];
337
+ /**
338
+ * The class this effect belongs to (e.g., `'author'`, `'book'`).
339
+ * When set, the effect becomes a method on the auto-generated class.
340
+ * Omit for global effects (standalone exported functions).
341
+ */
342
+ className?: string;
343
+ /**
344
+ * If `true`, this is a static/class-level method (no object ID required).
345
+ * If `false` or omitted and `className` is set, this is an instance method
346
+ * that operates on a specific object (the object's real-world ID is
347
+ * passed as the first argument to the handler).
348
+ */
349
+ static?: boolean;
350
+ }
351
+ type EffectSchema = ToolSchema;
352
+ /**
353
+ * Effect with handler — what users provide to `registerEffect()`.
354
+ *
355
+ * - **Instance methods** (`className` set, `static` omitted):
356
+ * handler receives `(objectId: string, params: any)`
357
+ * - **Static methods** (`className` set, `static: true`):
358
+ * handler receives `(params: any)`
359
+ * - **Global tools** (no `className`):
360
+ * handler receives `(params: any)`
361
+ */
362
+ interface ToolWithHandler extends ToolSchema {
363
+ handler: ToolHandler | InstanceToolHandler;
364
+ }
365
+ type EffectWithHandler = ToolWithHandler;
366
+ /**
367
+ * Result from publishing or synchronizing effects
368
+ */
369
+ interface PublishToolsResult {
370
+ accepted: boolean;
371
+ domainRevision: string;
372
+ rejected?: Array<{
373
+ name: string;
374
+ reason: string;
375
+ }>;
376
+ }
377
+ type PublishEffectsResult = PublishToolsResult;
378
+ /**
379
+ * Domain state response
380
+ */
381
+ interface DomainState {
382
+ activeDomainRevision?: string;
383
+ tools?: Array<{
384
+ name: string;
385
+ description?: string;
386
+ inputSchema?: Record<string, unknown>;
387
+ outputSchema?: Record<string, unknown>;
388
+ }>;
389
+ [key: string]: unknown;
390
+ }
391
+ /**
392
+ * Information about a live or declared effect
393
+ */
394
+ interface ToolInfo {
395
+ effectKey?: string;
396
+ /** Unique name of the effect */
397
+ name: string;
398
+ /** Description of what the effect does */
399
+ description?: string;
400
+ /** JSON Schema for effect input */
401
+ inputSchema?: Record<string, unknown>;
402
+ /** JSON Schema for effect output */
403
+ outputSchema?: Record<string, unknown>;
404
+ /** Client ID that published this effect (absent for domain-only entries) */
405
+ clientId?: string;
406
+ /** Whether the effect is ready for use (has a registered handler) */
407
+ ready: boolean;
408
+ /** Timestamp when the effect was published */
409
+ publishedAt?: number;
410
+ /** Class this effect belongs to (instance/static method) */
411
+ className?: string;
412
+ /** Whether this is a static method */
413
+ static?: boolean;
414
+ }
415
+ interface EffectInfo extends ToolInfo {
416
+ }
417
+ /**
418
+ * Event data when the list of available effects changes
419
+ */
420
+ interface ToolsChangedEvent {
421
+ /** The current list of all available effects */
422
+ tools: ToolInfo[];
423
+ /** Names of effects that were added or updated */
424
+ added: string[];
425
+ /** Names of effects that were removed */
426
+ removed: string[];
427
+ }
428
+ interface EffectsChangedEvent extends ToolsChangedEvent {
429
+ /** The current list of all available effects */
430
+ effects: EffectInfo[];
431
+ }
432
+ type EffectHandler = ToolHandler;
433
+ type InstanceEffectHandler = InstanceToolHandler;
434
+ type JobStatus = 'queued' | 'running' | 'succeeded' | 'failed' | 'timeout' | 'canceled';
435
+ /**
436
+ * Result from submitting a job
437
+ */
438
+ interface JobSubmitResult {
439
+ jobId: string;
440
+ }
441
+ /**
442
+ * Represents a job executed in the sandbox
443
+ */
444
+ interface Job {
445
+ /** Unique Job ID */
446
+ id: string;
447
+ /** Current status of the job */
448
+ status: JobStatus;
449
+ /** Promise that resolves with the job result */
450
+ result: Promise<unknown>;
451
+ /** Subscribe to job events */
452
+ on(event: string, handler: (data: unknown) => void): void;
453
+ }
454
+ interface Prompt {
455
+ id: string;
456
+ type: 'confirm' | 'choice' | 'input';
457
+ title: string;
458
+ message: string;
459
+ options?: string[];
460
+ defaultValue?: unknown;
461
+ }
462
+ type SessionHeapFieldType = 'string' | 'number' | 'boolean' | 'null' | 'unknown';
463
+ interface SessionHeapFieldValue {
464
+ name: string;
465
+ type: SessionHeapFieldType;
466
+ value: string | number | boolean | null;
467
+ }
468
+ interface SessionHeapEntry {
469
+ path: string;
470
+ className: string;
471
+ id: string;
472
+ label?: string | null;
473
+ description?: string | null;
474
+ prototypes: string[];
475
+ fields: SessionHeapFieldValue[];
476
+ relatedJobIds: string[];
477
+ source: string;
478
+ createdAt: number;
479
+ updatedAt: number;
480
+ }
481
+ interface SessionHeapList {
482
+ name: string;
483
+ className: string;
484
+ paths: string[];
485
+ relatedJobIds: string[];
486
+ updatedAt: number;
487
+ }
488
+ interface SessionHeapVariable {
489
+ name: string;
490
+ kind: 'entry' | 'list' | 'scalar';
491
+ entryPath?: string;
492
+ listName?: string;
493
+ value?: string | number | boolean | null;
494
+ className?: string;
495
+ updatedAt: number;
496
+ }
497
+ interface SessionHeapSnapshot {
498
+ entriesByPath: Record<string, SessionHeapEntry>;
499
+ listsByName: Record<string, SessionHeapList>;
500
+ variablesByName: Record<string, SessionHeapVariable>;
501
+ updatedAt: number;
502
+ }
503
+ interface WSDisconnectInfo {
504
+ code?: number;
505
+ reason?: string;
506
+ wasClean?: boolean;
507
+ unexpected: boolean;
508
+ timestamp: number;
509
+ reconnectScheduled: boolean;
510
+ reconnectDelayMs?: number;
511
+ }
512
+ interface WSReconnectErrorInfo {
513
+ sessionId: string;
514
+ error: string;
515
+ timestamp: number;
516
+ }
517
+ interface WSClientOptions {
518
+ url: string;
519
+ sessionId: string;
520
+ token: string;
521
+ tokenProvider?: AccessTokenProvider;
522
+ WebSocketCtor?: any;
523
+ onUnexpectedClose?: (info: WSDisconnectInfo) => void;
524
+ onReconnectError?: (info: WSReconnectErrorInfo) => void;
525
+ }
526
+ interface RPCRequest {
527
+ type: 'rpc';
528
+ method: string;
529
+ params: unknown;
530
+ id: string;
531
+ }
532
+ interface RPCResponse {
533
+ type: 'rpc_result' | 'rpc_error';
534
+ id: string;
535
+ result?: unknown;
536
+ error?: {
537
+ code: number;
538
+ message: string;
539
+ data?: unknown;
540
+ };
541
+ }
542
+ interface SyncMessage {
543
+ type: 'sync';
544
+ message?: string | number[] | Uint8Array;
545
+ data?: number[];
546
+ }
547
+ interface RPCRequestFromServer {
548
+ type: 'rpc';
549
+ method: string;
550
+ params: unknown;
551
+ id: string;
552
+ }
553
+ interface ToolInvokeParams {
554
+ callId: string;
555
+ toolName: string;
556
+ input: unknown;
557
+ }
558
+ interface ToolResultParams {
559
+ callId: string;
560
+ result?: unknown;
561
+ error?: string | {
562
+ code: string;
563
+ message: string;
564
+ };
565
+ }
566
+ /**
567
+ * A model reference as returned from relationship queries
568
+ */
569
+ interface ModelRef {
570
+ path: string;
571
+ label?: string;
572
+ }
573
+ /**
574
+ * Relationship info as returned from the GraphQL API.
575
+ * Represents a typed, bidirectional relationship between two model types,
576
+ * seen from one model's perspective.
577
+ */
578
+ interface RelationshipInfo {
579
+ /** Unique name of this relationship definition */
580
+ name: string;
581
+ /** The submodel on this model that holds the relationship */
582
+ local_submodel: ModelRef;
583
+ /** Whether this side is a "many" collection */
584
+ local_is_many: boolean;
585
+ /** The submodel on the foreign model */
586
+ foreign_submodel: ModelRef;
587
+ /** Whether the foreign side is a "many" collection */
588
+ foreign_is_many: boolean;
589
+ /** The foreign model type */
590
+ foreign_model: ModelRef;
591
+ /** Computed relationship kind: "one_to_one" | "one_to_many" | "many_to_one" | "many_to_many" */
592
+ relationship_kind: 'one_to_one' | 'one_to_many' | 'many_to_one' | 'many_to_many';
593
+ }
594
+ /**
595
+ * Options for defining a relationship between two model types
596
+ */
597
+ interface DefineRelationshipOptions {
598
+ /** The model to define the relationship on (the "left" / "local" type) */
599
+ model: string;
600
+ /** The submodel name on the local model (e.g., "books") */
601
+ localSubmodel: string;
602
+ /** Whether the local side is "many" */
603
+ localIsMany: boolean;
604
+ /** The foreign model type (e.g., "book") */
605
+ foreignModel: string;
606
+ /** The submodel name on the foreign model (e.g., "author") */
607
+ foreignSubmodel: string;
608
+ /** Whether the foreign side is "many" */
609
+ foreignIsMany: boolean;
610
+ /** Optional relationship name (auto-generated if omitted) */
611
+ name?: string;
612
+ }
613
+ /**
614
+ * Options for creating or updating a class instance in the graph.
615
+ *
616
+ * `recordObject` uses the graph's `instantiate` (find-or-create) semantics:
617
+ * if an instance with the given `id` already exists under the class, its
618
+ * fields are updated in place; otherwise a new instance is created.
619
+ */
620
+ interface RecordObjectOptions {
621
+ /** The class to instantiate (e.g., "author") */
622
+ className: string;
623
+ /**
624
+ * Real-world object ID. Unique within its class, but two objects of
625
+ * different classes may share the same ID. Internally the SDK derives
626
+ * a unique graph path as `{className}__{id}`.
627
+ */
628
+ id: string;
629
+ /** Optional display label (defaults to `id`) */
630
+ label?: string;
631
+ /** Scalar field values to set on the instance */
632
+ fields?: Record<string, string | number | boolean | null>;
633
+ /**
634
+ * Relationship attachments.
635
+ * Keys are relationship submodel names. Values are real-world IDs
636
+ * (not graph paths) — the SDK resolves them using the foreign class
637
+ * derived from the relationship definition.
638
+ * - For a "one" side: pass a single target ID (string)
639
+ * - For a "many" side: pass an array of target IDs
640
+ */
641
+ relationships?: Record<string, string | string[]>;
642
+ }
643
+ /**
644
+ * Return value from `recordObject()`
645
+ */
646
+ interface RecordObjectResult {
647
+ /** The internal graph path (e.g., "author__tolkien") */
648
+ path: string;
649
+ /** The real-world object ID as provided by the caller (e.g., "tolkien") */
650
+ id: string;
651
+ /** Whether the instance was newly created (false = updated) */
652
+ created: boolean;
653
+ }
654
+ /**
655
+ * Property specification in a manifest operation
656
+ */
657
+ interface ManifestPropertySpec {
658
+ value?: string | number | boolean;
659
+ ref?: string;
660
+ instanceOf?: string;
661
+ create?: string;
662
+ has?: Record<string, ManifestPropertySpec>;
663
+ type?: string;
664
+ description?: string;
665
+ required?: boolean;
666
+ }
667
+ /**
668
+ * Relationship definition between two classes
669
+ */
670
+ interface ManifestRelationshipDef {
671
+ /** Optional name (auto-generated from left_right if omitted) */
672
+ name?: string;
673
+ /** Left model path */
674
+ left: string;
675
+ /** Right model path */
676
+ right: string;
677
+ /** Submodel name on the left model */
678
+ leftSubmodel: string;
679
+ /** Submodel name on the right model */
680
+ rightSubmodel: string;
681
+ /** Whether the left side is a collection */
682
+ leftIsMany: boolean;
683
+ /** Whether the right side is a collection */
684
+ rightIsMany: boolean;
685
+ }
686
+ interface ManifestEffectSchema {
687
+ type: string;
688
+ properties?: Record<string, unknown>;
689
+ required?: string[];
690
+ items?: unknown;
691
+ description?: string;
692
+ [key: string]: unknown;
693
+ }
694
+ interface ManifestEffectDeclaration {
695
+ name: string;
696
+ description?: string;
697
+ attachedClass?: string;
698
+ isStatic?: boolean;
699
+ inputSchema: ManifestEffectSchema;
700
+ outputSchema?: ManifestEffectSchema;
701
+ stability?: 'stable' | 'experimental' | 'deprecated';
702
+ tags?: string[];
703
+ }
704
+ /**
705
+ * A single operation in a manifest volume
706
+ */
707
+ interface ManifestOperation {
708
+ /** Create a new model/class */
709
+ create?: string;
710
+ /** Target an existing model for modification */
711
+ on?: string;
712
+ /** Extend from a parent class */
713
+ extends?: string;
714
+ /** Instantiate a type */
715
+ instanceOf?: string;
716
+ /** Define submodels/fields */
717
+ has?: Record<string, ManifestPropertySpec>;
718
+ /** Define a relationship between two classes */
719
+ defineRelationship?: ManifestRelationshipDef;
720
+ /** Declare a build-owned effect */
721
+ withEffect?: ManifestEffectDeclaration;
722
+ }
723
+ /**
724
+ * A volume in a manifest
725
+ */
726
+ /**
727
+ * Import descriptor for referencing modules
728
+ */
729
+ interface ManifestImport {
730
+ /** Alias prefix used in operations (e.g., "@std") */
731
+ alias: string;
732
+ /** Module name (e.g., "standard_modules") */
733
+ name: string;
734
+ /** Version label (e.g., "prod", "v1.2.3") */
735
+ label?: string;
736
+ }
737
+ interface ManifestVolume {
738
+ name: string;
739
+ scope: 'sandbox' | 'build' | 'user';
740
+ imports?: ManifestImport[];
741
+ operations: ManifestOperation[];
742
+ }
743
+ /**
744
+ * A manifest defines the structure of a sandbox's data model
745
+ */
746
+ interface ManifestContent {
747
+ schemaVersion: 2;
748
+ name: string;
749
+ description?: string;
750
+ volumes: ManifestVolume[];
751
+ }
752
+ /**
753
+ * Result from a GraphQL query execution
754
+ */
755
+ interface GraphQLResult<T = any> {
756
+ data?: T;
757
+ errors?: Array<{
758
+ message: string;
759
+ locations?: Array<{
760
+ line: number;
761
+ column: number;
762
+ }>;
763
+ path?: Array<string | number>;
764
+ extensions?: Record<string, any>;
765
+ }>;
766
+ }
767
+ interface APIError {
768
+ error: string;
769
+ message?: string;
770
+ }
771
+ interface DeleteResponse {
772
+ deleted: boolean;
773
+ }
774
+
6
775
  declare class WSClient {
7
776
  private ws;
8
777
  private url;
@@ -251,6 +1020,13 @@ declare class Environment extends Session {
251
1020
  get permissionProfileId(): string;
252
1021
  /** The GraphQL API endpoint URL */
253
1022
  get apiEndpoint(): string;
1023
+ /**
1024
+ * Return a plain JS snapshot of the synced session heap.
1025
+ *
1026
+ * The heap lives in the Automerge document, so this method does not perform
1027
+ * any extra network roundtrip.
1028
+ */
1029
+ getHeap(): SessionHeapSnapshot;
254
1030
  private getRuntimeBaseUrl;
255
1031
  /**
256
1032
  * Close the session and disconnect from the sandbox.
@@ -704,4 +1480,4 @@ declare class Granular {
704
1480
  private request;
705
1481
  }
706
1482
 
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 };
1483
+ 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 SessionHeapEntry, type SessionHeapFieldType, type SessionHeapFieldValue, type SessionHeapList, type SessionHeapSnapshot, type SessionHeapVariable, 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 };