@granular-software/sdk 0.4.37 → 0.4.39

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.
@@ -1,2483 +0,0 @@
1
- import { PermissionProfileFile } from '@granular-software/policy-engine';
2
- import * as Automerge from '@automerge/automerge';
3
- import { Doc } from '@automerge/automerge/slim';
4
-
5
- /**
6
- * @module @granular-software/sdk/types
7
- * Type definitions for the Granular SDK
8
- */
9
-
10
- /**
11
- * Configuration for the Granular client
12
- */
13
- type AccessTokenProvider = () => Promise<string | null | undefined> | string | null | undefined;
14
- type EndpointMode = "auto" | "local" | "production";
15
- interface GranularOptions {
16
- /** Your Granular API key (for service/CLI auth; use with GRANULAR_API_KEY) */
17
- apiKey?: string;
18
- /** Application/session JWT (for user-context auth; use from simulator or getAccessToken) */
19
- token?: string;
20
- /** Optional provider used to refresh JWT before WebSocket (re)connect attempts */
21
- tokenProvider?: AccessTokenProvider;
22
- /** Optional API URL (for on-prem or testing) */
23
- apiUrl?: string;
24
- /** Optional live effect-host WebSocket/base URL override (for local/on-prem routing) */
25
- effectHostUrl?: string;
26
- /** Optional endpoint mode when apiUrl is not explicitly provided */
27
- endpointMode?: EndpointMode;
28
- /** Optional WebSocket constructor (for Node.js environments) */
29
- WebSocketCtor?: any;
30
- /**
31
- * Optional callback invoked when a connected WebSocket closes unexpectedly.
32
- * Useful for forwarding close diagnostics to monitoring (e.g., Sentry).
33
- */
34
- onUnexpectedClose?: (info: WSDisconnectInfo) => void;
35
- /**
36
- * Optional callback invoked when automatic reconnect fails.
37
- * Useful to capture auth or gateway rejection causes.
38
- */
39
- onReconnectError?: (info: WSReconnectErrorInfo) => void;
40
- }
41
- /** Resolved auth credential: either apiKey or token must be provided */
42
- type GranularAuth = string;
43
- /**
44
- * A user/subject object returned from recordUser()
45
- */
46
- interface User {
47
- /** Internal Granular user identifier */
48
- granularId: string;
49
- /** External user identifier from your app */
50
- userId: string;
51
- /** @deprecated Use `granularId` instead */
52
- subjectId: string;
53
- /** @deprecated Use `userId` instead */
54
- identityId: string;
55
- /** User's display name */
56
- name?: string;
57
- /** User's email */
58
- email?: string;
59
- /** Permission profile IDs to be assigned when connecting */
60
- permissions: string[];
61
- }
62
- /**
63
- * Options for recording a user
64
- */
65
- interface RecordUserOptions {
66
- /** External user/identity ID (e.g. your Auth0 or database user ID) */
67
- userId: string;
68
- /** User's display name */
69
- name?: string;
70
- /** User's email */
71
- email?: string;
72
- /** Permission profile IDs to assign when connecting to sandboxes */
73
- permissions?: string[];
74
- }
75
- /**
76
- * Subject as returned from the API
77
- */
78
- interface Subject {
79
- /** Internal Granular user identifier */
80
- granularId: string;
81
- /** External user identifier from your app */
82
- userId: string;
83
- subjectId: string;
84
- tenantId: string;
85
- identityId: string;
86
- email?: string | null;
87
- name?: string | null;
88
- metadata?: Record<string, unknown>;
89
- createdAt: number;
90
- updatedAt: number;
91
- }
92
- /**
93
- * Options for opening an ontology environment for one delegated subject.
94
- *
95
- * This does not open a live runtime session. Use
96
- * `environment.sessions.create()` or `granular.createSession({ environmentId })`
97
- * when you need a conversation/session with jobs, prompts, heap, and effects.
98
- */
99
- interface OpenEnvironmentOptions {
100
- /** The ontology name or ID to open. */
101
- ontology: string;
102
- /** Version channel to follow, typically `dev` or `prod`. */
103
- tag?: string;
104
- /**
105
- * External user identifier from your app.
106
- *
107
- * Exactly one of `userId`, `granularId`, or `user` should be provided.
108
- */
109
- userId?: string;
110
- /**
111
- * Internal Granular user identifier.
112
- *
113
- * Exactly one of `userId`, `granularId`, or `user` should be provided.
114
- */
115
- granularId?: string;
116
- /** Optional display name used when upserting the user. */
117
- name?: string;
118
- /** Optional email used when upserting the user. */
119
- email?: string;
120
- /**
121
- * Permission profile names or IDs to ensure before opening the environment.
122
- * This should be provided even for existing users so the SDK can guarantee
123
- * assignments for first-time environment creation.
124
- */
125
- permissions: string[];
126
- /**
127
- * When true, if the latest environment for this ontology/user/tag is marked
128
- * outdated relative to the current tag target, create a fresh environment on
129
- * the newest tag target instead of reusing the outdated one.
130
- */
131
- createFreshIfOutdated?: boolean;
132
- /** Backwards-compatible user object returned from `recordUser()`. */
133
- user?: User;
134
- }
135
- /**
136
- * Deprecated compatibility alias for the legacy `connect()` entry point.
137
- *
138
- * `connect()` now resolves an environment handle and no longer opens a runtime
139
- * session automatically. Prefer `openEnvironment()` for new code.
140
- */
141
- interface ConnectOptions extends OpenEnvironmentOptions {
142
- /** @deprecated Legacy explicit environment slot name. Prefer `tag`. */
143
- environment?: string;
144
- /** @deprecated Legacy tag field. Prefer `tag`. */
145
- tagName?: string;
146
- /** @deprecated Ignored by `connect()` now that it no longer opens sessions. */
147
- clientId?: string;
148
- /**
149
- * @deprecated Ignored by `connect()` now that it no longer opens sessions.
150
- * Uses application record identity: class name plus the record id from the
151
- * customer's own system. Granular resolves the internal graph path.
152
- */
153
- initialHeap?: Array<{
154
- className: string;
155
- id: string;
156
- }>;
157
- }
158
- /**
159
- * Options for creating a live runtime session from an opened environment.
160
- */
161
- interface CreateSessionOptions {
162
- /** Optional stable client ID. Defaults to `client_${Date.now()}`. */
163
- clientId?: string;
164
- /**
165
- * Optional session heap seed. Each item uses application record identity:
166
- * class name plus the record id from the customer's own system. Granular
167
- * resolves and hydrates the corresponding internal graph record on connect.
168
- */
169
- initialHeap?: Array<{
170
- className: string;
171
- id: string;
172
- }>;
173
- }
174
- /**
175
- * Control-plane session row: one real-time conversation thread with the agent for an environment.
176
- */
177
- interface ConversationSessionInfo {
178
- sessionId: string;
179
- tenantId?: string;
180
- environmentId: string;
181
- versionId?: string | null;
182
- docId: string;
183
- status: "active" | "closed" | "expired";
184
- createdAt: string;
185
- lastSeenAt: string;
186
- summary?: string | null;
187
- summaryUpdatedAt?: string | null;
188
- subjectId?: string | null;
189
- jobCount?: number;
190
- toolCallCount?: number;
191
- }
192
- /**
193
- * A sandbox container
194
- */
195
- interface Sandbox {
196
- sandboxId: string;
197
- tenantId: string;
198
- name: string;
199
- description?: string | null;
200
- createdAt: number;
201
- updatedAt: number;
202
- }
203
- /**
204
- * Data for creating a new sandbox
205
- */
206
- interface CreateSandboxData {
207
- name: string;
208
- description?: string;
209
- }
210
- /**
211
- * List response for sandboxes
212
- */
213
- interface SandboxListResponse {
214
- items: Sandbox[];
215
- }
216
- /**
217
- * Rules defining what effects and resources are allowed or denied.
218
- */
219
- interface PermissionRules {
220
- /** Effect access rules */
221
- effects?: {
222
- /** Patterns for allowed effects (e.g. ["*"] for all, ["read_*"] for prefix match) */
223
- allow?: string[];
224
- /** Patterns for denied effects */
225
- deny?: string[];
226
- };
227
- /** Legacy alias accepted by the backend while migrating to `effects`. */
228
- tools?: {
229
- /** Patterns for allowed effects (e.g. ["*"] for all, ["read_*"] for prefix match) */
230
- allow?: string[];
231
- /** Patterns for denied effects */
232
- deny?: string[];
233
- };
234
- /** Resource access rules */
235
- resources?: {
236
- /** Patterns for allowed resources */
237
- allow?: string[];
238
- /** Patterns for denied resources */
239
- deny?: string[];
240
- };
241
- }
242
- /**
243
- * A permission profile defines access controls for an environment
244
- */
245
- interface PermissionProfile {
246
- permissionProfileId: string;
247
- sandboxId: string;
248
- name: string;
249
- description?: string;
250
- rules?: PermissionProfileFile;
251
- profile?: PermissionProfileFile;
252
- createdAt: number;
253
- updatedAt: number;
254
- }
255
- /**
256
- * Data for creating a new permission profile
257
- */
258
- interface CreatePermissionProfileData {
259
- name: string;
260
- rules: PermissionProfileFile;
261
- }
262
- /**
263
- * List response for permission profiles
264
- */
265
- interface PermissionProfileListResponse {
266
- items: PermissionProfile[];
267
- }
268
- /**
269
- * An assignment links a subject to a sandbox with a permission profile
270
- */
271
- interface Assignment {
272
- assignmentId: string;
273
- tenantId: string;
274
- subjectId: string;
275
- sandboxId: string;
276
- permissionProfileId: string;
277
- createdAt: number;
278
- createdBy?: string | null;
279
- }
280
- /**
281
- * List response for assignments
282
- */
283
- interface AssignmentListResponse {
284
- items: Assignment[];
285
- }
286
- /**
287
- * Version tracking policy for environments.
288
- *
289
- * Environments either follow a version tag such as `dev` or `prod`, or they
290
- * pin themselves to one immutable ontology version.
291
- */
292
- interface BuildPolicy {
293
- mode: "tag" | "current" | "pinned";
294
- buildId?: string;
295
- versionId?: string;
296
- tagId?: string;
297
- tagName?: string;
298
- }
299
- type VersionTracking = BuildPolicy;
300
- interface VersionTag {
301
- tagId: string;
302
- sandboxId: string;
303
- name: string;
304
- kind: "channel" | "release" | "system";
305
- targetBuildId?: string | null;
306
- targetVersionId?: string | null;
307
- description?: string | null;
308
- protected?: boolean;
309
- createdAt: number;
310
- updatedAt: number;
311
- }
312
- /**
313
- * An environment links a user (subject) to a sandbox with specific permissions
314
- */
315
- interface EnvironmentData {
316
- environmentId: string;
317
- sandboxId: string;
318
- ontologyId?: string;
319
- buildId: string;
320
- versionNumber?: number | null;
321
- versionId: string;
322
- subjectId: string;
323
- envName: string;
324
- environment?: string;
325
- permissionProfileId: string;
326
- tagId?: string | null;
327
- tag?: VersionTag | null;
328
- tracking?: BuildPolicy;
329
- buildPolicy: BuildPolicy;
330
- setup?: EnvironmentSetupSummary | null;
331
- updateState?: "up_to_date" | "update_available" | "upgrading" | "failed";
332
- createdAt: number;
333
- updatedAt: number;
334
- }
335
- /**
336
- * Data for creating a new environment
337
- */
338
- interface CreateEnvironmentData {
339
- /** The user/subject ID to create the environment for */
340
- subjectId: string;
341
- /** Named environment slot such as dev or prod */
342
- environment?: string;
343
- /** @deprecated Use `environment` instead. */
344
- envName?: string;
345
- /** The permission profile to apply (optional - uses assignment if not specified) */
346
- permissionProfileId?: string | null;
347
- /** Follow a tag directly */
348
- tagId?: string;
349
- /** Follow a tag by name, typically dev or prod */
350
- tagName?: string;
351
- /** Pin the environment to a specific version */
352
- versionId?: string;
353
- /** Legacy/compat environment tracking input */
354
- buildPolicy?: BuildPolicy;
355
- }
356
- /**
357
- * List response for environments
358
- */
359
- interface EnvironmentListResponse {
360
- items: EnvironmentData[];
361
- }
362
- /**
363
- * A manifest describes the structure and behavior of a sandbox
364
- */
365
- interface Manifest {
366
- manifestId: string;
367
- sandboxId: string;
368
- version: string;
369
- digest: string;
370
- content?: Record<string, unknown>;
371
- createdAt: number;
372
- locked?: boolean;
373
- }
374
- /**
375
- * List response for manifests
376
- */
377
- interface ManifestListResponse {
378
- items: Manifest[];
379
- }
380
- type BuildStatus = "queued" | "building" | "completed" | "failed" | "canceled";
381
- /**
382
- * An immutable ontology version derived from a specific manifest revision.
383
- *
384
- * The same version may have multiple build runs over time when the manifest
385
- * content is unchanged but the compilation process is re-executed.
386
- */
387
- interface Build {
388
- buildId: string;
389
- sandboxId: string;
390
- manifestId: string;
391
- manifestDigest?: string;
392
- versionNumber?: number;
393
- status: BuildStatus;
394
- graphBinaryId?: string | null;
395
- logsUri?: string | null;
396
- latestBuildRunId?: string | null;
397
- buildRunId?: string;
398
- createdNewVersion?: boolean;
399
- environmentCount?: number;
400
- laggingEnvironmentCount?: number;
401
- sessionCount?: number;
402
- createdAt: number;
403
- updatedAt: number;
404
- isCurrent?: boolean;
405
- }
406
- type Version = Build;
407
- /**
408
- * List response for versions
409
- */
410
- interface BuildListResponse {
411
- items: Build[];
412
- }
413
- interface SemanticVersionDiffEntry {
414
- operationId: string;
415
- kind: "create" | "update" | "relationship" | "effect" | "eventStream" | "unknown";
416
- changeType: "added" | "removed" | "changed";
417
- label: string;
418
- additive: boolean;
419
- breaking: boolean;
420
- before?: Record<string, unknown>;
421
- after?: Record<string, unknown>;
422
- }
423
- interface SemanticVersionDiff {
424
- summary: {
425
- added: number;
426
- removed: number;
427
- changed: number;
428
- additive: number;
429
- breaking: number;
430
- onlyAdditiveChanges: boolean;
431
- };
432
- entries: SemanticVersionDiffEntry[];
433
- }
434
- /**
435
- * Effect handler for static/global effects: receives (input, context)
436
- */
437
- interface EffectHandlerContext {
438
- effectClientId: string;
439
- sandboxId: string;
440
- environmentId: string;
441
- buildId?: string;
442
- buildVersionNumber?: number;
443
- sessionId: string;
444
- tenantId?: string;
445
- principalId?: string;
446
- permissionProfileId?: string;
447
- user: {
448
- granularId?: string;
449
- userId?: string;
450
- subjectId: string;
451
- identityId?: string;
452
- principalId?: string;
453
- };
454
- behaviors?: ResolvedEffectBehaviors;
455
- invocation?: EffectInvocationMetadata;
456
- }
457
- interface ResolvedEffectPostCondition {
458
- condition: string;
459
- description?: string;
460
- }
461
- interface ResolvedEffectDryRun {
462
- enabled: boolean;
463
- description?: string;
464
- }
465
- interface ResolvedEffectReverse {
466
- handler?: string;
467
- description?: string;
468
- }
469
- interface ResolvedEffectApprovalRequired {
470
- required: boolean;
471
- reason?: string;
472
- mode?: string;
473
- }
474
- interface ResolvedEffectBehaviors {
475
- postCondition?: ResolvedEffectPostCondition;
476
- dryRun?: ResolvedEffectDryRun;
477
- reverse?: ResolvedEffectReverse;
478
- approvalRequired?: ResolvedEffectApprovalRequired;
479
- }
480
- type EffectInvocationMode = "execute" | "dryRun" | "reverse";
481
- interface EffectInvocationMetadata {
482
- mode?: EffectInvocationMode;
483
- reverseHandler?: string;
484
- sourceEffectKey?: string;
485
- sourceEffectName?: string;
486
- }
487
- type ToolHandler = (input: any, context: EffectHandlerContext) => Promise<unknown>;
488
- /**
489
- * Effect handler for instance methods: receives (objectId, input, context)
490
- */
491
- type InstanceToolHandler = (id: string, input: any, context: EffectHandlerContext) => Promise<unknown>;
492
- /**
493
- * Effect schema for declaring or registering an effect.
494
- *
495
- * Effects come in three flavours:
496
- *
497
- * 1. **Instance methods** — set `className`, omit `static`.
498
- * In the sandbox: `tolkien.get_bio({ detailed: true })`
499
- * Handler signature: `(objectId: string, params: any) => any`
500
- *
501
- * 2. **Static methods** — set `className` + `static: true`.
502
- * In the sandbox: `Author.search({ query: 'tolkien' })`
503
- * Handler signature: `(params: any) => any`
504
- *
505
- * 3. **Global effects** — omit `className`.
506
- * In the sandbox: `global_search({ query: 'rings' })`
507
- * Handler signature: `(params: any) => any`
508
- *
509
- * Both `inputSchema` and `outputSchema` accept JSON Schema objects.
510
- * The `outputSchema` drives the return type in the auto-generated
511
- * TypeScript declarations that sandbox code imports from `./sandbox-tools`.
512
- */
513
- interface ToolSchema {
514
- effectKey?: string;
515
- name: string;
516
- description: string;
517
- /** JSON Schema for the effect input parameters */
518
- inputSchema: Record<string, unknown>;
519
- /**
520
- * JSON Schema for the tool's return value.
521
- * Used to generate typed return types in the sandbox TypeScript declarations.
522
- *
523
- * @example
524
- * ```typescript
525
- * outputSchema: {
526
- * type: 'object',
527
- * properties: {
528
- * bio: { type: 'string', description: 'The biography text' },
529
- * source: { type: 'string', description: 'Source of the bio' },
530
- * },
531
- * required: ['bio'],
532
- * }
533
- * // Generates: Promise<{ bio: string; source?: string }>
534
- * ```
535
- */
536
- outputSchema?: Record<string, unknown>;
537
- stability?: "stable" | "experimental" | "deprecated";
538
- provenance?: {
539
- source: "mcp" | "custom";
540
- };
541
- tags?: string[];
542
- /**
543
- * The class this effect belongs to (e.g., `'author'`, `'book'`).
544
- * When set, the effect becomes a method on the auto-generated class.
545
- * Omit for global effects (standalone exported functions).
546
- */
547
- className?: string;
548
- /**
549
- * If `true`, this is a static/class-level method (no object ID required).
550
- * If `false` or omitted and `className` is set, this is an instance method
551
- * that operates on a specific object (the object's real-world ID is
552
- * passed as the first argument to the handler).
553
- */
554
- static?: boolean;
555
- /**
556
- * Optional build-version selector for this live effect binding.
557
- *
558
- * When omitted, the binding applies to all build versions for the sandbox.
559
- */
560
- versionSelector?: EffectVersionSelector;
561
- /** Declarative runtime behaviors attached to the effect. */
562
- metamodels?: ManifestEffectMetamodelSpec;
563
- }
564
- type EffectSchema = ToolSchema;
565
- /**
566
- * Effect with handler — what users provide to `registerEffect()`.
567
- *
568
- * - **Instance methods** (`className` set, `static` omitted):
569
- * handler receives `(objectId: string, params: any)`
570
- * - **Static methods** (`className` set, `static: true`):
571
- * handler receives `(params: any)`
572
- * - **Global tools** (no `className`):
573
- * handler receives `(params: any)`
574
- */
575
- interface ToolWithHandler extends ToolSchema {
576
- handler: ToolHandler | InstanceToolHandler;
577
- dryRunHandler?: ToolHandler | InstanceToolHandler;
578
- reverseHandler?: ToolHandler | InstanceToolHandler;
579
- }
580
- type EffectWithHandler = ToolWithHandler;
581
- /**
582
- * Result from publishing or synchronizing effects
583
- */
584
- interface PublishToolsResult {
585
- accepted: boolean;
586
- domainRevision: string;
587
- rejected?: Array<{
588
- name: string;
589
- reason: string;
590
- }>;
591
- }
592
- type PublishEffectsResult = PublishToolsResult;
593
- type EffectVersionSelector = {
594
- mode: "all";
595
- } | {
596
- mode: "exact";
597
- versionNumber: number;
598
- } | {
599
- mode: "before";
600
- versionNumber: number;
601
- } | {
602
- mode: "after";
603
- versionNumber: number;
604
- };
605
- /**
606
- * Domain state response
607
- */
608
- interface DomainState {
609
- activeDomainRevision?: string;
610
- tools?: Array<{
611
- name: string;
612
- description?: string;
613
- inputSchema?: Record<string, unknown>;
614
- outputSchema?: Record<string, unknown>;
615
- metamodels?: ManifestEffectMetamodelSpec;
616
- }>;
617
- [key: string]: unknown;
618
- }
619
- /**
620
- * Information about a live or declared effect
621
- */
622
- interface ToolInfo {
623
- effectKey?: string;
624
- /** Unique name of the effect */
625
- name: string;
626
- /** Description of what the effect does */
627
- description?: string;
628
- /** JSON Schema for effect input */
629
- inputSchema?: Record<string, unknown>;
630
- /** JSON Schema for effect output */
631
- outputSchema?: Record<string, unknown>;
632
- /** Client ID that published this effect (absent for domain-only entries) */
633
- clientId?: string;
634
- /** Whether the effect is ready for use (has a registered handler) */
635
- ready: boolean;
636
- /** Timestamp when the effect was published */
637
- publishedAt?: number;
638
- /** Class this effect belongs to (instance/static method) */
639
- className?: string;
640
- /** Whether this is a static method */
641
- static?: boolean;
642
- /** Optional build-version selector associated with the live binding. */
643
- versionSelector?: EffectVersionSelector;
644
- /** Declarative runtime behaviors attached to the effect. */
645
- metamodels?: ManifestEffectMetamodelSpec;
646
- }
647
- interface EffectInfo extends ToolInfo {
648
- }
649
- /**
650
- * Event data when the list of available effects changes
651
- */
652
- interface ToolsChangedEvent {
653
- /** The current list of all available effects */
654
- tools: ToolInfo[];
655
- /** Names of effects that were added or updated */
656
- added: string[];
657
- /** Names of effects that were removed */
658
- removed: string[];
659
- }
660
- interface EffectsChangedEvent extends ToolsChangedEvent {
661
- /** The current list of all available effects */
662
- effects: EffectInfo[];
663
- }
664
- type EffectHandler = ToolHandler;
665
- type InstanceEffectHandler = InstanceToolHandler;
666
- type JobStatus = "queued" | "running" | "awaitingTool" | "awaitingHuman" | "succeeded" | "failed" | "timeout" | "canceled";
667
- type JobFeedbackSentiment = "good" | "bad";
668
- interface JobFeedbackToolCall {
669
- callId?: string;
670
- toolName?: string;
671
- input?: unknown;
672
- output?: unknown;
673
- error?: string;
674
- startedAt?: number;
675
- completedAt?: number;
676
- durationMs?: number | null;
677
- }
678
- interface JobFeedbackMetadata {
679
- source: "sdk";
680
- status: JobStatus;
681
- code: string;
682
- domainRevision?: string;
683
- createdAt: number;
684
- startedAt?: number;
685
- completedAt?: number;
686
- durationMs?: number | null;
687
- result?: unknown;
688
- error?: string;
689
- stdout: string[];
690
- stderr: string[];
691
- toolCalls: JobFeedbackToolCall[];
692
- }
693
- interface JobFeedbackInput {
694
- sentiment: JobFeedbackSentiment;
695
- comment?: string | null;
696
- }
697
- interface JobFeedbackRecord {
698
- feedbackId: string;
699
- tenantId?: string;
700
- sessionId: string;
701
- environmentId: string;
702
- sandboxId?: string;
703
- buildId?: string;
704
- subjectId?: string;
705
- jobId: string;
706
- sentiment: JobFeedbackSentiment;
707
- comment?: string | null;
708
- metadata: JobFeedbackMetadata & Record<string, unknown>;
709
- createdAt: number;
710
- updatedAt: number;
711
- }
712
- /**
713
- * Persisted feedback row listed at the environment level.
714
- */
715
- interface EnvironmentFeedbackRecord {
716
- feedbackId: string;
717
- sessionId: string;
718
- jobId: string;
719
- sentiment: JobFeedbackSentiment;
720
- comment?: string | null;
721
- metadata?: Record<string, unknown> | null;
722
- createdAt: string | null;
723
- }
724
- /**
725
- * Result from submitting a job
726
- */
727
- interface JobSubmitResult {
728
- jobId: string;
729
- }
730
- /**
731
- * Represents a job executed in the sandbox
732
- */
733
- interface Job {
734
- /** Unique Job ID */
735
- id: string;
736
- /** Current status of the job */
737
- status: JobStatus;
738
- /** Promise that resolves with the job result */
739
- result: Promise<unknown>;
740
- /** Attach user feedback to this job and persist it with job/session metadata */
741
- leaveFeedback(input: JobFeedbackInput): Promise<JobFeedbackRecord>;
742
- /** Subscribe to job events */
743
- on(event: string, handler: (data: unknown) => void): () => void;
744
- }
745
- interface Prompt {
746
- id: string;
747
- type: "confirm" | "choice" | "input";
748
- title: string;
749
- message: string;
750
- options?: Array<string | {
751
- value: string;
752
- label: string;
753
- description?: string;
754
- }>;
755
- defaultValue?: unknown;
756
- placeholder?: string;
757
- allowEmpty?: boolean;
758
- metadata?: Record<string, unknown>;
759
- }
760
- interface ConversationMessageShowRefs {
761
- entryPaths?: string[];
762
- listNames?: string[];
763
- variableNames?: string[];
764
- }
765
- interface ConversationMessageInput {
766
- role: "user" | "assistant";
767
- content?: string;
768
- show?: ConversationMessageShowRefs;
769
- jobId?: string;
770
- promptId?: string;
771
- timestamp?: number;
772
- }
773
- interface ConversationAppendResult {
774
- ok: boolean;
775
- messageId: string;
776
- timestamp: number;
777
- jobId?: string;
778
- promptId?: string;
779
- }
780
- interface SessionConversationMessage {
781
- id: string;
782
- role: "user" | "assistant";
783
- content?: string;
784
- show?: ConversationMessageShowRefs;
785
- jobId?: string;
786
- promptId?: string;
787
- ts: number;
788
- [key: string]: unknown;
789
- }
790
- interface SessionTimelineEvent {
791
- id?: string;
792
- eventId?: string;
793
- kind?: string;
794
- type?: string;
795
- status?: string | null;
796
- message?: string;
797
- summary?: string;
798
- title?: string;
799
- ts?: number;
800
- timestamp?: number;
801
- at?: number;
802
- createdAt?: number;
803
- [key: string]: unknown;
804
- }
805
- interface SessionJobRecord {
806
- jobId: string;
807
- status: string;
808
- code?: string;
809
- createdAt?: number;
810
- startedAt?: number;
811
- completedAt?: number;
812
- durationMs?: number | null;
813
- progressPercent?: number | null;
814
- progressMessage?: string | null;
815
- stdout?: string[];
816
- stderr?: string[];
817
- result?: unknown;
818
- error?: string | null;
819
- toolCalls?: JobFeedbackToolCall[];
820
- prompts?: Record<string, unknown>;
821
- actionSummary?: string[];
822
- actionTrace?: Array<Record<string, unknown>>;
823
- agentMessages?: Array<Record<string, unknown>>;
824
- [key: string]: unknown;
825
- }
826
- interface SessionTranscriptEntry {
827
- id: string;
828
- role: "user" | "assistant";
829
- content: string;
830
- timestamp: number;
831
- jobId?: string;
832
- promptId?: string;
833
- code?: string;
834
- jobStatus?: string;
835
- jobResultPreview?: string;
836
- error?: string;
837
- show?: ConversationMessageShowRefs;
838
- historyContent?: string;
839
- source: "conversation" | "job_code" | "job_result" | "job_prompt" | "job_agent_message";
840
- }
841
- type SessionHeapFieldType = "string" | "number" | "boolean" | "null" | "unknown";
842
- interface SessionHeapFieldValue {
843
- name: string;
844
- type: SessionHeapFieldType;
845
- value: string | number | boolean | null;
846
- }
847
- interface SessionHeapEntry {
848
- path: string;
849
- className: string;
850
- id: string;
851
- label?: string | null;
852
- description?: string | null;
853
- prototypes: string[];
854
- fields: SessionHeapFieldValue[];
855
- relatedJobIds: string[];
856
- source: string;
857
- createdAt: number;
858
- updatedAt: number;
859
- }
860
- interface SessionHeapList {
861
- name: string;
862
- className: string;
863
- paths: string[];
864
- relatedJobIds: string[];
865
- updatedAt: number;
866
- }
867
- interface SessionHeapVariable {
868
- name: string;
869
- kind: "entry" | "list" | "scalar";
870
- entryPath?: string;
871
- listName?: string;
872
- value?: string | number | boolean | null;
873
- className?: string;
874
- updatedAt: number;
875
- }
876
- interface SessionHeapSnapshot {
877
- entriesByPath: Record<string, SessionHeapEntry>;
878
- listsByName: Record<string, SessionHeapList>;
879
- variablesByName: Record<string, SessionHeapVariable>;
880
- updatedAt: number;
881
- }
882
- interface RecordSearchResult {
883
- path: string;
884
- className: string;
885
- id: string;
886
- label: string;
887
- description?: string | null;
888
- fields: SessionHeapFieldValue[];
889
- }
890
- interface RecordSearchOptions {
891
- limit?: number;
892
- offset?: number;
893
- classNames?: string[];
894
- }
895
- interface RecordMentionInput {
896
- className: string;
897
- id?: string;
898
- path?: string;
899
- }
900
- interface SessionDocumentResult {
901
- sessionState: Record<string, unknown> | null;
902
- document: Record<string, unknown> | null;
903
- savedAt: number;
904
- }
905
- interface SessionCollectionListOptions {
906
- limit?: number;
907
- cursor?: string | null;
908
- }
909
- interface SessionJobListOptions extends SessionCollectionListOptions {
910
- status?: string | null;
911
- }
912
- interface SessionCollectionListResult<T = unknown> {
913
- items: T[];
914
- nextCursor: string | null;
915
- totalCount: number;
916
- }
917
- interface WSDisconnectInfo {
918
- code?: number;
919
- reason?: string;
920
- wasClean?: boolean;
921
- unexpected: boolean;
922
- timestamp: number;
923
- reconnectScheduled: boolean;
924
- reconnectDelayMs?: number;
925
- }
926
- interface WSReconnectErrorInfo {
927
- sessionId: string;
928
- error: string;
929
- timestamp: number;
930
- }
931
- interface WSClientOptions {
932
- url: string;
933
- sessionId: string;
934
- token: string;
935
- tokenProvider?: AccessTokenProvider;
936
- WebSocketCtor?: any;
937
- onUnexpectedClose?: (info: WSDisconnectInfo) => void;
938
- onReconnectError?: (info: WSReconnectErrorInfo) => void;
939
- }
940
- interface RPCRequest {
941
- type: "rpc";
942
- method: string;
943
- params: unknown;
944
- id: string;
945
- }
946
- interface RPCResponse {
947
- type: "rpc_result" | "rpc_error";
948
- id: string;
949
- result?: unknown;
950
- error?: {
951
- code: number;
952
- message: string;
953
- data?: unknown;
954
- };
955
- }
956
- interface SyncMessage {
957
- type: "sync";
958
- message?: string | number[] | Uint8Array;
959
- data?: number[];
960
- }
961
- interface RPCRequestFromServer {
962
- type: "rpc";
963
- method: string;
964
- params: unknown;
965
- id: string;
966
- }
967
- interface ToolInvokeParams {
968
- callId: string;
969
- toolName: string;
970
- input: unknown;
971
- }
972
- interface ToolResultParams {
973
- callId: string;
974
- result?: unknown;
975
- error?: string | {
976
- code: string;
977
- message: string;
978
- };
979
- }
980
- /**
981
- * A model reference as returned from relationship queries
982
- */
983
- interface ModelRef {
984
- path: string;
985
- label?: string;
986
- }
987
- /**
988
- * Relationship info as returned from the GraphQL API.
989
- * Represents a typed, bidirectional relationship between two model types,
990
- * seen from one model's perspective.
991
- */
992
- interface RelationshipInfo {
993
- /** Unique name of this relationship definition */
994
- name: string;
995
- /** The submodel on this model that holds the relationship */
996
- local_submodel: ModelRef;
997
- /** Whether this side is a "many" collection */
998
- local_is_many: boolean;
999
- /** The submodel on the foreign model */
1000
- foreign_submodel: ModelRef;
1001
- /** Whether the foreign side is a "many" collection */
1002
- foreign_is_many: boolean;
1003
- /** The foreign model type */
1004
- foreign_model: ModelRef;
1005
- /** Computed relationship kind: "one_to_one" | "one_to_many" | "many_to_one" | "many_to_many" */
1006
- relationship_kind: "one_to_one" | "one_to_many" | "many_to_one" | "many_to_many";
1007
- }
1008
- /**
1009
- * Options for defining a relationship between two model types
1010
- */
1011
- interface DefineRelationshipOptions {
1012
- /** The model to define the relationship on (the "left" / "local" type) */
1013
- model: string;
1014
- /** The submodel name on the local model (e.g., "books") */
1015
- localSubmodel: string;
1016
- /** Whether the local side is "many" */
1017
- localIsMany: boolean;
1018
- /** The foreign model type (e.g., "book") */
1019
- foreignModel: string;
1020
- /** The submodel name on the foreign model (e.g., "author") */
1021
- foreignSubmodel: string;
1022
- /** Whether the foreign side is "many" */
1023
- foreignIsMany: boolean;
1024
- /** Optional relationship name (auto-generated if omitted) */
1025
- name?: string;
1026
- }
1027
- /**
1028
- * Options for creating or updating a class instance in the graph.
1029
- *
1030
- * `recordObject` uses the graph's `instantiate` (find-or-create) semantics:
1031
- * if an instance with the given `id` already exists under the class, its
1032
- * fields are updated in place; otherwise a new instance is created.
1033
- */
1034
- interface RecordObjectOptions {
1035
- /** The class to instantiate (e.g., "author") */
1036
- className: string;
1037
- /**
1038
- * Real-world object ID. Unique within its class, but two objects of
1039
- * different classes may share the same ID. Internally the SDK derives
1040
- * a unique graph path as `{className}__{id}`.
1041
- */
1042
- id: string;
1043
- /** Optional display label (defaults to `id`) */
1044
- label?: string;
1045
- /** Scalar field values to set on the instance */
1046
- fields?: Record<string, string | number | boolean | null>;
1047
- /**
1048
- * Relationship attachments.
1049
- * Keys are relationship submodel names. Values are real-world IDs
1050
- * (not graph paths) — the SDK resolves them using the foreign class
1051
- * derived from the relationship definition.
1052
- * - For a "one" side: pass a single target ID (string)
1053
- * - For a "many" side: pass an array of target IDs
1054
- */
1055
- relationships?: Record<string, string | string[]>;
1056
- }
1057
- /**
1058
- * Return value from `recordObject()`
1059
- */
1060
- interface RecordObjectResult {
1061
- /** The internal graph path (e.g., "author__tolkien") */
1062
- path: string;
1063
- /** The real-world object ID as provided by the caller (e.g., "tolkien") */
1064
- id: string;
1065
- /** Whether the instance was newly created (false = updated) */
1066
- created: boolean;
1067
- }
1068
- /**
1069
- * Metadata for one completed HTTP chunk in `recordObjects()`.
1070
- * Chunk indices follow input order; when concurrency is greater than 1, completion order may differ.
1071
- */
1072
- interface RecordObjectsChunkInfo {
1073
- /** Zero-based chunk index */
1074
- chunkIndex: number;
1075
- totalChunks: number;
1076
- /** Zero-based offset into the original `records` array */
1077
- offset: number;
1078
- /** Number of records in this chunk */
1079
- recordCount: number;
1080
- /** Wall time for this chunk’s POST (including retries) */
1081
- durationMs: number;
1082
- /** Acknowledgements for this chunk, in the same order as the slice sent */
1083
- results: RecordObjectResult[];
1084
- }
1085
- /**
1086
- * Optional tuning for `recordObjects()` — batching, parallelism, and progress hooks.
1087
- */
1088
- interface RecordObjectsOptions {
1089
- /**
1090
- * Max records per HTTP POST to the control-plane batch endpoint. Default 100.
1091
- * Smaller values: more round trips and finer `onChunkComplete` updates.
1092
- * Larger values: fewer requests (watch request size/timeouts).
1093
- */
1094
- batchSize?: number;
1095
- /**
1096
- * How many chunk POSTs may run concurrently. Default 1 (strictly sequential).
1097
- * Values above 1 can reduce wall time when the server can overlap work; capped at 16.
1098
- */
1099
- concurrency?: number;
1100
- /**
1101
- * Called after each chunk succeeds (after retries). Useful for UI progress bars.
1102
- */
1103
- onChunkComplete?: (info: RecordObjectsChunkInfo) => void | Promise<void>;
1104
- }
1105
- type RecordImportWriteMode = "adaptive" | "batched" | "per_record" | "parallel_5";
1106
- interface RecordImportOptions {
1107
- batchSize?: number;
1108
- setupRunId?: string;
1109
- writeMode?: RecordImportWriteMode;
1110
- }
1111
- type RecordImportStatus = "queued" | "processing" | "completed" | "failed" | "canceled";
1112
- type RecordImportItemStatus = "queued" | "processing" | "completed" | "failed" | "canceled";
1113
- interface RecordImportStats {
1114
- totalRecords: number;
1115
- queuedRecords: number;
1116
- processingRecords: number;
1117
- completedRecords: number;
1118
- failedRecords: number;
1119
- canceledRecords: number;
1120
- awaitingRecords: number;
1121
- }
1122
- interface RecordImportItem {
1123
- itemId: string;
1124
- importId: string;
1125
- tenantId: string;
1126
- environmentId: string;
1127
- className: string;
1128
- id: string;
1129
- label: string | null;
1130
- fields: Record<string, string | number | boolean | null> | null;
1131
- relationships: Record<string, string | string[]> | null;
1132
- status: RecordImportItemStatus;
1133
- attempts: number;
1134
- errorMessage: string | null;
1135
- resultPath: string | null;
1136
- resultCreated: boolean | null;
1137
- createdAt: number;
1138
- updatedAt: number;
1139
- processedAt: number | null;
1140
- }
1141
- interface RecordImport {
1142
- importId: string;
1143
- tenantId: string;
1144
- environmentId: string;
1145
- sandboxId: string;
1146
- subjectId: string;
1147
- setupRunId?: string | null;
1148
- status: RecordImportStatus;
1149
- batchSize: number;
1150
- errorMessage: string | null;
1151
- createdAt: number;
1152
- updatedAt: number;
1153
- startedAt: number | null;
1154
- finishedAt: number | null;
1155
- canceledAt: number | null;
1156
- stats: RecordImportStats;
1157
- }
1158
- interface EnvironmentRecordImportSummary extends RecordImportStats {
1159
- environmentId: string;
1160
- totalImports: number;
1161
- activeImports: number;
1162
- updatedAt: number;
1163
- }
1164
- type EnvironmentSetupTriggerReason = "new_environment" | "fresh_after_version_update";
1165
- interface RunEnvironmentImporterOptions {
1166
- /**
1167
- * Ontology name/id used to resolve the registered importer. Defaults to the
1168
- * environment sandbox id.
1169
- */
1170
- ontology?: string;
1171
- /**
1172
- * Reason recorded on the setup run. Defaults to `new_environment`.
1173
- */
1174
- reason?: EnvironmentSetupTriggerReason;
1175
- }
1176
- type EnvironmentSetupLifecycleStatus = "running" | "completed" | "failed";
1177
- interface EnvironmentSetupSummary extends RecordImportStats {
1178
- setupRunId: string;
1179
- environmentId: string;
1180
- sandboxId: string;
1181
- subjectId: string;
1182
- triggerReason: EnvironmentSetupTriggerReason;
1183
- lifecycleStatus: EnvironmentSetupLifecycleStatus;
1184
- stage: string | null;
1185
- totalObjectsToImport: number;
1186
- totalImports: number;
1187
- activeImports: number;
1188
- errorMessage: string | null;
1189
- startedAt: number;
1190
- hookCompletedAt: number | null;
1191
- finishedAt: number | null;
1192
- updatedAt: number;
1193
- }
1194
- interface EnvironmentImporterImportOptions {
1195
- batchSize?: number;
1196
- writeMode?: RecordImportWriteMode;
1197
- }
1198
- interface EnvironmentImporter {
1199
- environmentId: string;
1200
- sandboxId: string;
1201
- subjectId: string;
1202
- reason: EnvironmentSetupTriggerReason;
1203
- incrementTotalObjectsToImportCount: (n: number) => Promise<void>;
1204
- setStage: (stage: string | null) => Promise<void>;
1205
- importRecords: (records: RecordObjectOptions[], options?: EnvironmentImporterImportOptions) => Promise<RecordImport>;
1206
- }
1207
- /**
1208
- * Property specification in a manifest operation
1209
- */
1210
- interface ManifestPropertySpec {
1211
- value?: string | number | boolean;
1212
- ref?: string;
1213
- instanceOf?: string;
1214
- create?: string;
1215
- has?: Record<string, ManifestPropertySpec>;
1216
- type?: string;
1217
- description?: string;
1218
- required?: boolean;
1219
- note?: string | string[];
1220
- enum?: string[] | ManifestEnumRuleSpec;
1221
- filterBy?: boolean | string[] | ManifestFilterBySpec;
1222
- validate?: ManifestValidationRuleSpec[];
1223
- }
1224
- type ManifestValidationOperator = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "true" | "false" | "regex" | "contains" | "not_contains" | "starts_with" | "ends_with";
1225
- interface ManifestEnumRuleSpec {
1226
- values: string[];
1227
- message?: string;
1228
- }
1229
- interface ManifestFilterBySpec {
1230
- operators: string[];
1231
- scalarType?: string;
1232
- }
1233
- interface ManifestValidationRuleSpec {
1234
- operator: ManifestValidationOperator;
1235
- stringValue?: string;
1236
- numberValue?: number;
1237
- booleanValue?: boolean;
1238
- message?: string;
1239
- }
1240
- interface ManifestStateMachineStateSpec {
1241
- name: string;
1242
- isFinal?: boolean;
1243
- }
1244
- interface ManifestStateMachineTransitionSpec {
1245
- name: string;
1246
- from: string;
1247
- to: string;
1248
- }
1249
- interface ManifestStateMachineSpec {
1250
- name: string;
1251
- entryState: string;
1252
- states: Array<string | ManifestStateMachineStateSpec>;
1253
- transitions: ManifestStateMachineTransitionSpec[];
1254
- finalStates?: string[];
1255
- }
1256
- interface ManifestPostConditionSpec {
1257
- condition: string;
1258
- description?: string;
1259
- }
1260
- interface ManifestDryRunSpec {
1261
- enabled?: boolean;
1262
- description?: string;
1263
- }
1264
- interface ManifestReverseSpec {
1265
- handler?: string;
1266
- description?: string;
1267
- }
1268
- interface ManifestApprovalRequiredSpec {
1269
- required?: boolean;
1270
- reason?: string;
1271
- mode?: string;
1272
- }
1273
- interface ManifestEffectMetamodelSpec {
1274
- postCondition?: string | ManifestPostConditionSpec;
1275
- dryRun?: boolean | ManifestDryRunSpec;
1276
- reverse?: string | ManifestReverseSpec;
1277
- approvalRequired?: boolean | ManifestApprovalRequiredSpec;
1278
- }
1279
- /**
1280
- * Relationship definition between two classes
1281
- */
1282
- interface ManifestRelationshipDef {
1283
- /** Optional name (auto-generated from left_right if omitted) */
1284
- name?: string;
1285
- /** Left model path */
1286
- left: string;
1287
- /** Right model path */
1288
- right: string;
1289
- /** Submodel name on the left model */
1290
- leftSubmodel: string;
1291
- /** Submodel name on the right model */
1292
- rightSubmodel: string;
1293
- /** Whether the left side is a collection */
1294
- leftIsMany: boolean;
1295
- /** Whether the right side is a collection */
1296
- rightIsMany: boolean;
1297
- }
1298
- interface ManifestEffectSchema {
1299
- type: string;
1300
- properties?: Record<string, unknown>;
1301
- required?: string[];
1302
- items?: unknown;
1303
- description?: string;
1304
- [key: string]: unknown;
1305
- }
1306
- interface ManifestEffectDeclaration {
1307
- name: string;
1308
- description?: string;
1309
- attachedClass?: string;
1310
- isStatic?: boolean;
1311
- inputSchema: ManifestEffectSchema;
1312
- outputSchema?: ManifestEffectSchema;
1313
- stability?: "stable" | "experimental" | "deprecated";
1314
- tags?: string[];
1315
- metamodels?: ManifestEffectMetamodelSpec;
1316
- }
1317
- /**
1318
- * An event type within an event stream definition
1319
- */
1320
- interface ManifestEventTypeDef {
1321
- name: string;
1322
- description?: string;
1323
- payloadSchema: ManifestEffectSchema;
1324
- }
1325
- /**
1326
- * Event stream definition for outgoing typed events
1327
- */
1328
- interface ManifestEventStreamDef {
1329
- name: string;
1330
- description?: string;
1331
- eventTypes: ManifestEventTypeDef[];
1332
- }
1333
- /**
1334
- * A single operation in a manifest volume
1335
- */
1336
- interface ManifestOperation {
1337
- /** Create a new model/class */
1338
- create?: string;
1339
- /** Target an existing model for modification */
1340
- on?: string;
1341
- /** Extend from a parent class */
1342
- extends?: string;
1343
- /** Instantiate a type */
1344
- instanceOf?: string;
1345
- /** Define submodels/fields */
1346
- has?: Record<string, ManifestPropertySpec>;
1347
- /** Advisory notes attached to the model/class itself */
1348
- note?: string | string[];
1349
- /** State machines attached to the created or targeted class */
1350
- stateMachines?: ManifestStateMachineSpec[];
1351
- /** Define a relationship between two classes */
1352
- defineRelationship?: ManifestRelationshipDef;
1353
- /** Declare a build-owned effect */
1354
- withEffect?: ManifestEffectDeclaration;
1355
- /** Define an outgoing event stream with typed events */
1356
- defineEventStream?: ManifestEventStreamDef;
1357
- }
1358
- /**
1359
- * A volume in a manifest
1360
- */
1361
- /**
1362
- * Import descriptor for referencing modules
1363
- */
1364
- interface ManifestImport {
1365
- /** Alias prefix used in operations (e.g., "@std") */
1366
- alias: string;
1367
- /** Module name (e.g., "standard_modules") */
1368
- name: string;
1369
- /** Version label (e.g., "prod", "v1.2.3") */
1370
- label?: string;
1371
- }
1372
- interface ManifestVolume {
1373
- name: string;
1374
- scope: "sandbox" | "build" | "user";
1375
- imports?: ManifestImport[];
1376
- operations: ManifestOperation[];
1377
- }
1378
- /**
1379
- * A manifest defines the structure of a sandbox's data model
1380
- */
1381
- interface ManifestContent {
1382
- schemaVersion: 2;
1383
- name: string;
1384
- description?: string;
1385
- volumes: ManifestVolume[];
1386
- }
1387
- /**
1388
- * Result from a GraphQL query execution
1389
- */
1390
- interface GraphQLResult<T = any> {
1391
- data?: T;
1392
- errors?: Array<{
1393
- message: string;
1394
- locations?: Array<{
1395
- line: number;
1396
- column: number;
1397
- }>;
1398
- path?: Array<string | number>;
1399
- extensions?: Record<string, any>;
1400
- }>;
1401
- }
1402
- interface APIError {
1403
- error: string;
1404
- message?: string;
1405
- }
1406
- interface DeleteResponse {
1407
- deleted: boolean;
1408
- }
1409
- interface StreamEvent {
1410
- eventId: string;
1411
- streamName: string;
1412
- eventType: string;
1413
- payload: Record<string, unknown>;
1414
- environmentId: string;
1415
- sessionId?: string;
1416
- subjectId?: string;
1417
- source: "sandbox" | "api";
1418
- isAcked: boolean;
1419
- createdAt: number;
1420
- }
1421
- interface StreamSubscription {
1422
- unsubscribe(): void;
1423
- }
1424
- interface StreamStats {
1425
- streamName: string;
1426
- eventType: string;
1427
- total: number;
1428
- last1h: number;
1429
- last24h: number;
1430
- unacked: number;
1431
- }
1432
-
1433
- declare class WSClient {
1434
- private ws;
1435
- private url;
1436
- private sessionId;
1437
- private token;
1438
- private messageQueue;
1439
- private syncHandlers;
1440
- private rpcHandlers;
1441
- private eventHandlers;
1442
- private nextRpcId;
1443
- doc: Automerge.Doc<Record<string, unknown>>;
1444
- private syncState;
1445
- private reconnectTimer;
1446
- private tokenRefreshTimer;
1447
- private isExplicitlyDisconnected;
1448
- private options;
1449
- constructor(options: WSClientOptions);
1450
- get currentSessionId(): string;
1451
- private clearTokenRefreshTimer;
1452
- private decodeBase64Url;
1453
- private getTokenExpiryMs;
1454
- private scheduleTokenRefresh;
1455
- private refreshTokenInBackground;
1456
- private resolveTokenForConnect;
1457
- /**
1458
- * Connect to the WebSocket server
1459
- * @returns {Promise<void>} Resolves when connection is open
1460
- */
1461
- connect(): Promise<void>;
1462
- private normalizeReason;
1463
- private rejectPending;
1464
- private buildDisconnectError;
1465
- private handleDisconnect;
1466
- private handleMessage;
1467
- /**
1468
- * Make an RPC call to the server
1469
- * @param {string} method - RPC method name
1470
- * @param {unknown} params - Request parameters
1471
- * @returns {Promise<unknown>} Response result
1472
- * @throws {Error} If connection is closed or timeout occurs
1473
- */
1474
- call(method: string, params: unknown): Promise<unknown>;
1475
- private handleIncomingRpc;
1476
- /**
1477
- * Subscribe to client events
1478
- * @param {string} event - Event name
1479
- * @param {Function} handler - Event handler
1480
- */
1481
- on(event: string, handler: (params: unknown) => void): void;
1482
- /**
1483
- * Register an RPC handler for incoming server requests
1484
- * @param {string} method - RPC method name
1485
- * @param {Function} handler - Handler function
1486
- */
1487
- registerRpcHandler(method: string, handler: (params: unknown) => Promise<unknown>): void;
1488
- /**
1489
- * Unsubscribe from client events
1490
- * @param {string} event - Event name
1491
- * @param {Function} handler - Handler to remove
1492
- */
1493
- off(event: string, handler: (params: unknown) => void): void;
1494
- /**
1495
- * Emit an event locally
1496
- * @param {string} event - Event name
1497
- * @param params - Event data
1498
- */
1499
- emit(event: string, params: unknown): void;
1500
- /**
1501
- * Disconnect the WebSocket and clear state
1502
- */
1503
- disconnect(): void;
1504
- }
1505
-
1506
- declare class Session {
1507
- protected client: WSClient;
1508
- private clientId;
1509
- private jobsMap;
1510
- private pendingAgentMessagesByJobId;
1511
- private eventListeners;
1512
- private toolHandlers;
1513
- /** Tracks which tools are instance methods (className set, not static) */
1514
- private instanceTools;
1515
- private currentDomainRevision;
1516
- /** Local effect registry: name → full ToolWithHandler */
1517
- private effects;
1518
- /** Last known tools for diffing */
1519
- private lastKnownTools;
1520
- /** Last seen live prompts, keyed by prompt id, for answer normalization */
1521
- private promptCache;
1522
- /** Prompt ids locally answered before the document sync catches up. */
1523
- private hiddenPromptIds;
1524
- constructor(client: WSClient, clientId?: string);
1525
- private extractDomainRevisionFromDoc;
1526
- private buildLegacyEffectContext;
1527
- private stringifyConversationValue;
1528
- get document(): Doc<Record<string, unknown>>;
1529
- get sessionId(): string;
1530
- get domainRevision(): string | null;
1531
- /**
1532
- * Make a raw RPC call to the session's Durable Object.
1533
- *
1534
- * Use this when you need to call an RPC method that doesn't have a
1535
- * dedicated wrapper method on the Session/Environment class.
1536
- *
1537
- * @param method - RPC method name (e.g. 'domain.fetchPackagePart')
1538
- * @param params - Request parameters
1539
- * @returns The raw RPC response
1540
- *
1541
- * @example
1542
- * ```typescript
1543
- * const result = await env.rpc('domain.fetchPackagePart', {
1544
- * moduleSpecifier: '@sandbox/domain',
1545
- * part: 'types',
1546
- * });
1547
- * ```
1548
- */
1549
- rpc<T = unknown>(method: string, params?: Record<string, unknown>): Promise<T>;
1550
- /**
1551
- * Send client hello to establish the session
1552
- */
1553
- hello(): Promise<{
1554
- ok: boolean;
1555
- environmentId?: string;
1556
- docId?: string;
1557
- graphContainerStatus?: {
1558
- lastKeepAliveAt: number;
1559
- status: "warming" | "hot" | "unknown";
1560
- };
1561
- }>;
1562
- publishTools(tools: ToolWithHandler[], revision?: string): Promise<PublishToolsResult>;
1563
- publishEffect(effect: ToolWithHandler): Promise<PublishToolsResult>;
1564
- publishEffects(effects: ToolWithHandler[]): Promise<PublishToolsResult>;
1565
- unpublishEffect(name: string): Promise<PublishToolsResult>;
1566
- unpublishAllEffects(): Promise<PublishToolsResult>;
1567
- /**
1568
- * Submit a job to execute code in the sandbox.
1569
- *
1570
- * The code can import typed classes from `./sandbox-tools`:
1571
- * ```typescript
1572
- * import { Author, Book, global_search } from './sandbox-tools';
1573
- *
1574
- * const totalAuthors = await Author.count();
1575
- * const firstAuthorsPage = await Author.page({ page: 1, perPage: 10, saveAs: 'recent_authors' });
1576
- * const authors = firstAuthorsPage.items;
1577
- * const tolkien = await Author.get({ path: 'author_tolkien' });
1578
- * const bio = await tolkien.get_bio({ detailed: true });
1579
- * const books = await tolkien.get_books();
1580
- * for await (const author of Author.iterate({ perPage: 100, maxItems: 500 })) {
1581
- * console.log(author.id);
1582
- * }
1583
- * ```
1584
- *
1585
- * Effect calls (instance methods, static methods, global functions) trigger
1586
- * `effect.invoke` RPC back to the sandbox effect host, where the registered handlers
1587
- * execute locally and return the result to the sandbox.
1588
- */
1589
- submitJob(code: string, domainRevisionOrOptions?: string | {
1590
- domainRevision?: string;
1591
- metadata?: Record<string, unknown>;
1592
- agent?: Record<string, unknown>;
1593
- }): Promise<Job>;
1594
- /**
1595
- * Register a handler for a specific tool.
1596
- * @param isInstance - If true, handler will receive (id, params) for instance method dispatch.
1597
- */
1598
- registerToolHandler(name: string, handler: ToolHandler | InstanceToolHandler, isInstance?: boolean): void;
1599
- /**
1600
- * Respond to a prompt request from the sandbox
1601
- */
1602
- answerPrompt(promptId: string, answer: unknown): Promise<void>;
1603
- appendConversationMessage(input: ConversationMessageInput): Promise<ConversationAppendResult>;
1604
- /**
1605
- * Get the current list of available effects.
1606
- * Consolidates effect declarations and live availability for the session.
1607
- */
1608
- getEffects(): EffectInfo[];
1609
- /**
1610
- * Return the currently open prompt payloads known to this session.
1611
- *
1612
- * These come from live `prompt` / `prompt.request` websocket events and
1613
- * preserve the exact shape used by `answerPrompt(...)`.
1614
- */
1615
- getPrompts(): Prompt[];
1616
- getHiddenPromptIds(): string[];
1617
- /**
1618
- * Backwards-compatible alias for `getEffects()`.
1619
- */
1620
- getTools(): ToolInfo[];
1621
- /**
1622
- * Subscribe to effect changes (added, removed, updated).
1623
- * @param callback - Function called with change events
1624
- * @returns Unsubscribe function
1625
- */
1626
- onEffectsChanged(callback: (event: EffectsChangedEvent) => void): () => void;
1627
- /**
1628
- * Backwards-compatible alias for `onEffectsChanged()`.
1629
- */
1630
- onToolsChanged(callback: (event: ToolsChangedEvent) => void): () => void;
1631
- /**
1632
- * Get the current domain state and available tools
1633
- */
1634
- getDomain(): Promise<DomainState>;
1635
- /**
1636
- * Fetch a domain package part from the backend (no fallback).
1637
- */
1638
- private fetchDomainPart;
1639
- /**
1640
- * Get TypeScript class declarations for the current domain (for LLM/code gen).
1641
- */
1642
- getDomainTypes(): Promise<string>;
1643
- /**
1644
- * Get Markdown documentation for the current domain (human-readable).
1645
- */
1646
- getDomainDocs(): Promise<string>;
1647
- /**
1648
- * Get domain documentation for LLMs. Returns types (preferred) or fallback.
1649
- */
1650
- getDomainDocumentation(): Promise<string>;
1651
- /**
1652
- * Generate markdown documentation from the domain summary.
1653
- * Class-aware: groups tools by class with property/relationship info.
1654
- */
1655
- private generateFallbackDocs;
1656
- /**
1657
- * Close the session and disconnect from the sandbox
1658
- */
1659
- disconnect(): Promise<void>;
1660
- /**
1661
- * Subscribe to session events
1662
- */
1663
- on(event: string, handler: (data: unknown) => void): () => void;
1664
- /**
1665
- * Unsubscribe from session events
1666
- */
1667
- off(event: string, handler: (data: unknown) => void): void;
1668
- private setupToolInvokeHandler;
1669
- private setupEventHandlers;
1670
- protected emit(event: string, data: unknown): void;
1671
- /**
1672
- * Check for changes in the effect catalog and emit change events if needed.
1673
- */
1674
- private checkForToolChanges;
1675
- }
1676
-
1677
- type EnvironmentImporterHandler = (importer: EnvironmentImporter) => Promise<void> | void;
1678
- /**
1679
- * Environment is the sessionless handle for one resolved ontology environment.
1680
- *
1681
- * Use it to query or mutate environment data directly, or to open live runtime
1682
- * sessions through `environment.sessions.*` when you need jobs, prompts, or a
1683
- * synced Automerge document.
1684
- */
1685
- declare class Environment {
1686
- private granular;
1687
- private envData;
1688
- private _apiKey;
1689
- private _apiEndpoint;
1690
- constructor(granular: Granular, envData: EnvironmentData, apiKey: string, apiEndpoint: string);
1691
- /** The environment ID */
1692
- get environmentId(): string;
1693
- /** The sandbox ID */
1694
- get sandboxId(): string;
1695
- /** The ontology ID */
1696
- get ontologyId(): string;
1697
- /** The subject ID */
1698
- get subjectId(): string;
1699
- /** The named environment slot, such as dev or prod */
1700
- get envName(): string;
1701
- /** The named environment slot, such as dev or prod */
1702
- get environment(): string;
1703
- /** The resolved ontology version backing this environment */
1704
- get versionId(): string;
1705
- /** Internal Granular user identifier for this environment */
1706
- get granularId(): string;
1707
- /** The permission profile ID */
1708
- get permissionProfileId(): string;
1709
- /** The current build policy backing this environment */
1710
- get buildPolicy(): BuildPolicy;
1711
- /** The current update state relative to the followed tag */
1712
- get updateState(): EnvironmentData["updateState"];
1713
- /** The latest setup/import run summary for this environment, when available. */
1714
- get setup(): EnvironmentSetupSummary | null;
1715
- /** Convenience flag for whether this environment trails the current tag target */
1716
- get isOutdated(): boolean;
1717
- /** The followed tag name when this environment is tag-tracked */
1718
- get tag(): string | null;
1719
- /** The GraphQL API endpoint URL */
1720
- get apiEndpoint(): string;
1721
- /** Internal auth token used for control-plane and runtime fallback requests */
1722
- get authToken(): string;
1723
- /** Base runtime URL derived from the GraphQL endpoint */
1724
- get runtimeBaseUrl(): string;
1725
- syncEnvironmentData(envData: EnvironmentData): void;
1726
- get sessions(): {
1727
- list: (options?: {
1728
- status?: "active" | "closed" | "all";
1729
- }) => Promise<ConversationSessionInfo[]>;
1730
- create: (options?: CreateSessionOptions) => Promise<EnvironmentSession>;
1731
- connect: (sessionId: string, options?: {
1732
- clientId?: string;
1733
- }) => Promise<EnvironmentSession>;
1734
- reopen: (sessionId: string, options?: {
1735
- clientId?: string;
1736
- }) => Promise<EnvironmentSession>;
1737
- close: (sessionId: string, session?: EnvironmentSession | null) => Promise<void>;
1738
- };
1739
- get data(): {
1740
- record: (record: RecordObjectOptions) => Promise<RecordObjectResult>;
1741
- recordMany: (records: RecordObjectOptions[], options?: RecordObjectsOptions) => Promise<RecordObjectResult[]>;
1742
- import: (records: RecordObjectOptions[], options?: {
1743
- batchSize?: number;
1744
- }) => Promise<RecordImport>;
1745
- listImports: (status?: RecordImportStatus) => Promise<RecordImport[]>;
1746
- getImport: (importId: string) => Promise<RecordImport>;
1747
- getImportSummary: () => Promise<EnvironmentRecordImportSummary>;
1748
- cancelImport: (importId: string) => Promise<RecordImport>;
1749
- getAwaitingCount: () => Promise<number>;
1750
- };
1751
- get feedback(): {
1752
- list: () => Promise<EnvironmentFeedbackRecord[]>;
1753
- };
1754
- /**
1755
- * Sessionless environments do not own a live transport, so disconnecting the
1756
- * environment handle itself is a no-op. This keeps the public surface
1757
- * symmetric with `EnvironmentSession.disconnect()` and lets callers always
1758
- * clean up safely without tracking whether they currently hold an environment
1759
- * or a session.
1760
- */
1761
- disconnect(): Promise<void>;
1762
- listSessions(status?: "active" | "closed" | "all"): Promise<ConversationSessionInfo[]>;
1763
- createSession(options?: CreateSessionOptions): Promise<EnvironmentSession>;
1764
- connectSession(sessionId: string, options?: {
1765
- clientId?: string;
1766
- }): Promise<EnvironmentSession>;
1767
- reopenSession(sessionId: string, options?: {
1768
- clientId?: string;
1769
- }): Promise<EnvironmentSession>;
1770
- closeSession(sessionId: string, session?: EnvironmentSession | null): Promise<void>;
1771
- listFeedback(): Promise<EnvironmentFeedbackRecord[]>;
1772
- private getRuntimeBaseUrl;
1773
- private controlPlaneRequest;
1774
- private static normalizeGraphPathSegment;
1775
- /**
1776
- * Convert a class name + application record ID into Granular's graph path.
1777
- *
1778
- * This mirrors the record-write path normalization used by the control plane.
1779
- * Keep the original customer/system ID in `real_id`; graph paths are stable
1780
- * internal addresses, not the source of truth for business identity.
1781
- */
1782
- static toGraphPath(className: string, id: string): string;
1783
- /**
1784
- * Best-effort extraction of an ID-like suffix from a graph path.
1785
- *
1786
- * Prefer the record's `real_id` field whenever exact customer/system IDs
1787
- * matter, because graph path normalization is intentionally lossy.
1788
- */
1789
- static extractIdFromGraphPath(graphPath: string, className: string): string;
1790
- /**
1791
- * Execute a GraphQL query against the environment's graph.
1792
- *
1793
- * The query uses the Granular graph query language (based on Cypher/GraphQL).
1794
- * Authentication is handled automatically using the SDK's API key.
1795
- *
1796
- * @param query - The GraphQL query string
1797
- * @param variables - Optional variables for the query
1798
- * @returns The query result data
1799
- *
1800
- * @example
1801
- * ```typescript
1802
- * // Read the workspace
1803
- * const result = await env.graphql(
1804
- * `query { model(path: "workspace") { path label submodels { path label } } }`
1805
- * );
1806
- * console.log(result.data);
1807
- *
1808
- * // Create a model
1809
- * const created = await env.graphql(
1810
- * `mutation { at(path: "workspace") { create_submodel(subpath: "my_node", label: "My Node", prototype: "Model") { model { path label } } } }`
1811
- * );
1812
- * ```
1813
- */
1814
- graphql<T = any>(query: string, variables?: Record<string, any>): Promise<GraphQLResult<T>>;
1815
- searchRecords(query: string, options?: RecordSearchOptions): Promise<RecordSearchResult[]>;
1816
- /**
1817
- * Define a relationship between two model types.
1818
- *
1819
- * Creates both submodels (if they don't exist) and links them with
1820
- * a RelationshipDef node that encodes cardinality.
1821
- *
1822
- * @example
1823
- * ```typescript
1824
- * // Author has many Books, Book has one Author
1825
- * const rel = await env.defineRelationship({
1826
- * model: 'author',
1827
- * localSubmodel: 'books',
1828
- * localIsMany: true,
1829
- * foreignModel: 'book',
1830
- * foreignSubmodel: 'author',
1831
- * foreignIsMany: false,
1832
- * });
1833
- * console.log(rel.relationship_kind); // "one_to_many"
1834
- * ```
1835
- */
1836
- defineRelationship(options: DefineRelationshipOptions): Promise<RelationshipInfo>;
1837
- /**
1838
- * Get all relationships for a model type.
1839
- *
1840
- * @param modelPath - The model type path (e.g., "author")
1841
- * @returns Array of relationships from this model's perspective
1842
- *
1843
- * @example
1844
- * ```typescript
1845
- * const rels = await env.getRelationships('author');
1846
- * for (const rel of rels) {
1847
- * console.log(`${rel.local_submodel.path} -> ${rel.foreign_model.path} (${rel.relationship_kind})`);
1848
- * }
1849
- * ```
1850
- */
1851
- getRelationships(modelPath: string): Promise<RelationshipInfo[]>;
1852
- /**
1853
- * Attach a target model to a relationship submodel.
1854
- *
1855
- * Handles cardinality automatically:
1856
- * - "One" side: sets/replaces the reference
1857
- * - "Many" side: adds the target to the collection
1858
- *
1859
- * If the target model doesn't exist, it's created as an instance of the foreign type.
1860
- * Bidirectional sync is automatic.
1861
- *
1862
- * @param modelPath - The model instance path (e.g., "tolkien")
1863
- * @param submodelPath - The relationship submodel (e.g., "books")
1864
- * @param targetPath - The target model to attach (e.g., "lord_of_the_rings")
1865
- *
1866
- * @example
1867
- * ```typescript
1868
- * // Attach a book to an author (many side)
1869
- * await env.attach('tolkien', 'books', 'lord_of_the_rings');
1870
- * // This also automatically sets lord_of_the_rings:author -> tolkien
1871
- * ```
1872
- */
1873
- attach(modelPath: string, submodelPath: string, targetPath: string): Promise<void>;
1874
- /**
1875
- * Detach a target model from a relationship submodel.
1876
- *
1877
- * Handles bidirectional cleanup automatically.
1878
- *
1879
- * @param modelPath - The model instance path
1880
- * @param submodelPath - The relationship submodel
1881
- * @param targetPath - The target to detach (optional for "one" side; omit on "many" side to detach all)
1882
- *
1883
- * @example
1884
- * ```typescript
1885
- * // Detach a specific book
1886
- * await env.detach('tolkien', 'books', 'lord_of_the_rings');
1887
- *
1888
- * // Detach all books
1889
- * await env.detach('tolkien', 'books');
1890
- * ```
1891
- */
1892
- detach(modelPath: string, submodelPath: string, targetPath?: string): Promise<void>;
1893
- /**
1894
- * List all related models through a relationship submodel.
1895
- *
1896
- * @param modelPath - The model instance path
1897
- * @param submodelPath - The relationship submodel
1898
- * @returns Array of related model references
1899
- *
1900
- * @example
1901
- * ```typescript
1902
- * const books = await env.listRelated('tolkien', 'books');
1903
- * console.log(books); // [{ path: "lord_of_the_rings", label: "Lord of the Rings" }, ...]
1904
- * ```
1905
- */
1906
- listRelated(modelPath: string, submodelPath: string): Promise<ModelRef[]>;
1907
- /**
1908
- * Apply a manifest to the current environment's graph.
1909
- *
1910
- * Translates each manifest operation into GraphQL mutations and executes them
1911
- * in order. This is the core mechanism for creating classes, fields, and
1912
- * relationships from a declarative manifest.
1913
- *
1914
- * @param manifest - The manifest content to apply
1915
- * @returns Summary of applied operations
1916
- *
1917
- * @example
1918
- * ```typescript
1919
- * await environment.applyManifest({
1920
- * schemaVersion: 2,
1921
- * name: 'my-app',
1922
- * volumes: [{
1923
- * name: 'schema',
1924
- * scope: 'sandbox',
1925
- * operations: [
1926
- * { create: 'author', extends: 'class', has: { name: { type: 'string' } } },
1927
- * { create: 'book', extends: 'class', has: { title: { type: 'string' } } },
1928
- * { defineRelationship: {
1929
- * left: 'author', right: 'book',
1930
- * leftSubmodel: 'books', rightSubmodel: 'author',
1931
- * leftIsMany: true, rightIsMany: false,
1932
- * }},
1933
- * ],
1934
- * }],
1935
- * });
1936
- * ```
1937
- */
1938
- applyManifest(manifest: ManifestContent): Promise<{
1939
- applied: number;
1940
- errors: string[];
1941
- }>;
1942
- /**
1943
- * Resolve an alias reference like "@std/class" → "class"
1944
- * Strips the alias prefix, returning the bare model path.
1945
- */
1946
- private _resolveAlias;
1947
- private _runGraphql;
1948
- private _applyFieldMetamodels;
1949
- private _applyModelMetamodels;
1950
- private _ensureWorkspaceToolsRoot;
1951
- private _storeEffectSchemas;
1952
- private _applyEffectMetamodels;
1953
- private _ensureWorkspaceStreamsRoot;
1954
- private _applyEventStreamDeclaration;
1955
- private _applyEffectDeclaration;
1956
- /**
1957
- * Apply a single manifest operation via GraphQL
1958
- */
1959
- private _applyOperation;
1960
- /**
1961
- * Apply field definitions (has) to a model via GraphQL
1962
- */
1963
- private _applyFields;
1964
- /**
1965
- * Create or update an instance of a class in the graph.
1966
- *
1967
- * Uses `instantiate` under the hood, which has find-or-create semantics:
1968
- * if an instance with the given `id` already exists for the class it is
1969
- * returned; otherwise a new instance is created. Fields are then set
1970
- * (overwriting previous values) and relationships are attached.
1971
- *
1972
- * The graph path is derived as `{className}_{id}` to ensure uniqueness
1973
- * across classes (two objects of different classes may share the same
1974
- * real-world ID). Relationship targets are also resolved automatically
1975
- * using the foreign class from the relationship definition.
1976
- *
1977
- * @param options - The object specification
1978
- * @returns The graph path, real-world ID, and creation status
1979
- *
1980
- * @example
1981
- * ```typescript
1982
- * // Create an author with fields
1983
- * const result = await env.recordObject({
1984
- * className: 'author',
1985
- * id: 'tolkien',
1986
- * label: 'J.R.R. Tolkien',
1987
- * fields: { name: 'J.R.R. Tolkien', birth_year: 1892 },
1988
- * relationships: { books: ['lotr', 'silmarillion'] },
1989
- * });
1990
- * // result.path → 'author_tolkien' (internal graph path)
1991
- * // result.id → 'tolkien' (real-world ID)
1992
- * // result.created → true
1993
- * ```
1994
- */
1995
- recordObject(options: RecordObjectOptions): Promise<RecordObjectResult>;
1996
- /**
1997
- * Batch version of `recordObject()`.
1998
- *
1999
- * Sends rows through the control-plane **`/records/batch`** endpoint in **chunks** (default
2000
- * **100** records per HTTP request) so individual requests stay bounded and gateway timeouts are
2001
- * unlikely. Each chunk is retried on transient network / worker errors.
2002
- *
2003
- * Use the optional second argument to:
2004
- * - **`batchSize`** — rows per POST (smaller = more progress events; larger = fewer round trips).
2005
- * - **`concurrency`** — run up to N chunk POSTs in parallel (capped at 16) when you want lower wall time.
2006
- * - **`onChunkComplete`** — hook for UIs after each chunk succeeds (row order in the returned array
2007
- * always matches `records`; chunk **completion** order may differ when `concurrency > 1`).
2008
- *
2009
- * For **asynchronous** ingestion with worker-side batching and aggregate counters (`queued`,
2010
- * `completed`, …), use **`enqueueRecordImport`** and poll **`getRecordImport`** /
2011
- * **`getRecordImportSummary`** — best for very large fire-and-forget loads when immediate
2012
- * synchronous commit of every row is not required.
2013
- */
2014
- recordObjects(records: RecordObjectOptions[], options?: RecordObjectsOptions): Promise<RecordObjectResult[]>;
2015
- private executeRecordObjectsChunk;
2016
- /**
2017
- * Queue a background record import for this environment (async worker pipeline).
2018
- *
2019
- * **vs `recordObjects`:** this path accepts the full payload in one request, returns an
2020
- * **`importId`**, and processes rows in the background — use **`getRecordImport`** /
2021
- * **`getRecordImportSummary`** for progress. Choose it for large bulk loads where you do not
2022
- * need every row committed before the HTTP call returns. Use **`recordObjects`** when you need
2023
- * synchronous upserts and fine-grained chunk progress via **`onChunkComplete`**.
2024
- */
2025
- enqueueRecordImport(records: RecordObjectOptions[], options?: RecordImportOptions): Promise<RecordImport>;
2026
- /**
2027
- * List queued or completed record imports for this environment.
2028
- */
2029
- listRecordImports(status?: RecordImportStatus): Promise<RecordImport[]>;
2030
- /**
2031
- * Fetch the latest aggregate import counters for this environment.
2032
- */
2033
- getRecordImportSummary(): Promise<EnvironmentRecordImportSummary>;
2034
- /**
2035
- * Convenience helper returning queued + processing records for this environment.
2036
- */
2037
- getAwaitingRecordCount(): Promise<number>;
2038
- /**
2039
- * Fetch a single record import by id.
2040
- */
2041
- getRecordImport(importId: string): Promise<RecordImport>;
2042
- /**
2043
- * Cancel a queued/background record import.
2044
- */
2045
- cancelRecordImport(importId: string): Promise<RecordImport>;
2046
- }
2047
- /**
2048
- * Live runtime session attached to one opened environment.
2049
- *
2050
- * This is the object returned by `environment.sessions.create()` and friends.
2051
- * It owns websocket state, prompts, job execution, and the synced Automerge
2052
- * document while delegating environment-level data APIs back to
2053
- * `session.environment`.
2054
- */
2055
- declare class EnvironmentSession extends Session {
2056
- readonly environment: Environment;
2057
- private readonly sessionDataRoutePrefix;
2058
- /** The last known graph container status, updated by checkReadiness() or on heartbeat */
2059
- graphContainerStatus: {
2060
- lastKeepAliveAt: number;
2061
- status: "warming" | "hot" | "unknown";
2062
- } | null;
2063
- constructor(client: WSClient, environment: Environment, clientId: string, options?: {
2064
- sessionDataRoutePrefix?: string;
2065
- });
2066
- get environmentId(): string;
2067
- get sandboxId(): string;
2068
- get ontologyId(): string;
2069
- get subjectId(): string;
2070
- get envName(): string;
2071
- get tag(): string | null;
2072
- get versionId(): string;
2073
- get granularId(): string;
2074
- get permissionProfileId(): string;
2075
- get apiEndpoint(): string;
2076
- get data(): {
2077
- record: (record: RecordObjectOptions) => Promise<RecordObjectResult>;
2078
- recordMany: (records: RecordObjectOptions[], options?: RecordObjectsOptions) => Promise<RecordObjectResult[]>;
2079
- import: (records: RecordObjectOptions[], options?: {
2080
- batchSize?: number;
2081
- } | undefined) => Promise<RecordImport>;
2082
- listImports: (status?: RecordImportStatus) => Promise<RecordImport[]>;
2083
- getImport: (importId: string) => Promise<RecordImport>;
2084
- getImportSummary: () => Promise<EnvironmentRecordImportSummary>;
2085
- cancelImport: (importId: string) => Promise<RecordImport>;
2086
- getAwaitingCount: () => Promise<number>;
2087
- };
2088
- get feedback(): {
2089
- list: () => Promise<EnvironmentFeedbackRecord[]>;
2090
- };
2091
- /**
2092
- * Return a plain JS copy of the synced session heap.
2093
- */
2094
- getHeap(): SessionHeapSnapshot;
2095
- private sessionDataRequest;
2096
- private collectAllSessionItems;
2097
- /**
2098
- * Fetch the live session document from the runtime DO.
2099
- *
2100
- * For history and saved artifacts, prefer the collection APIs on
2101
- * `messages`, `timeline`, `jobs`, and `heap`.
2102
- */
2103
- getDocument(): Promise<SessionDocumentResult>;
2104
- get messages(): {
2105
- list: (options?: SessionCollectionListOptions) => Promise<SessionCollectionListResult<SessionConversationMessage>>;
2106
- };
2107
- get timeline(): {
2108
- list: (options?: SessionCollectionListOptions) => Promise<SessionCollectionListResult<SessionTimelineEvent>>;
2109
- };
2110
- get jobs(): {
2111
- list: (options?: SessionJobListOptions) => Promise<SessionCollectionListResult<SessionJobRecord>>;
2112
- get: (jobId: string) => Promise<SessionJobRecord>;
2113
- };
2114
- get heap(): {
2115
- entries: {
2116
- list: (options?: SessionCollectionListOptions) => Promise<SessionCollectionListResult<SessionHeapEntry>>;
2117
- get: (path: string) => Promise<SessionHeapEntry>;
2118
- };
2119
- lists: {
2120
- list: (options?: SessionCollectionListOptions) => Promise<SessionCollectionListResult<SessionHeapList>>;
2121
- get: (name: string) => Promise<SessionHeapList>;
2122
- };
2123
- variables: {
2124
- list: (options?: SessionCollectionListOptions) => Promise<SessionCollectionListResult<SessionHeapVariable>>;
2125
- get: (name: string) => Promise<SessionHeapVariable>;
2126
- delete: (name: string) => Promise<{
2127
- deleted: boolean;
2128
- name: string;
2129
- }>;
2130
- };
2131
- };
2132
- get transcript(): {
2133
- list: (options?: SessionCollectionListOptions) => Promise<SessionCollectionListResult<SessionTranscriptEntry>>;
2134
- };
2135
- graphql<T = any>(query: string, variables?: Record<string, any>): Promise<GraphQLResult<T>>;
2136
- searchRecords(query: string, options?: RecordSearchOptions): Promise<RecordSearchResult[]>;
2137
- mentionRecord(input: RecordMentionInput): Promise<SessionHeapEntry>;
2138
- defineRelationship(options: DefineRelationshipOptions): Promise<RelationshipInfo>;
2139
- getRelationships(modelPath: string): Promise<RelationshipInfo[]>;
2140
- attach(modelPath: string, submodelPath: string, targetPath: string): Promise<void>;
2141
- detach(modelPath: string, submodelPath: string, targetPath?: string): Promise<void>;
2142
- listRelated(modelPath: string, submodelPath: string): Promise<ModelRef[]>;
2143
- applyManifest(manifest: ManifestContent): Promise<{
2144
- applied: number;
2145
- errors: string[];
2146
- }>;
2147
- recordObject(options: RecordObjectOptions): Promise<RecordObjectResult>;
2148
- recordObjects(records: RecordObjectOptions[], options?: RecordObjectsOptions): Promise<RecordObjectResult[]>;
2149
- enqueueRecordImport(records: RecordObjectOptions[], options?: RecordImportOptions): Promise<RecordImport>;
2150
- listRecordImports(status?: RecordImportStatus): Promise<RecordImport[]>;
2151
- getRecordImportSummary(): Promise<EnvironmentRecordImportSummary>;
2152
- getAwaitingRecordCount(): Promise<number>;
2153
- getRecordImport(importId: string): Promise<RecordImport>;
2154
- cancelRecordImport(importId: string): Promise<RecordImport>;
2155
- listFeedback(): Promise<EnvironmentFeedbackRecord[]>;
2156
- /**
2157
- * Close the session and disconnect from the sandbox.
2158
- *
2159
- * Sends `client.goodbye` over WebSocket first, then issues an HTTP fallback
2160
- * to the runtime goodbye endpoint if no definitive WS-side runtime notify
2161
- * acknowledgement was observed.
2162
- */
2163
- disconnect(): Promise<void>;
2164
- /**
2165
- * Close only the socket transport without sending `client.goodbye`.
2166
- */
2167
- disconnectTransport(): void;
2168
- /**
2169
- * Backwards-compatible alias for `disconnect()`.
2170
- */
2171
- close(): Promise<void>;
2172
- /**
2173
- * Check if the graph container is ready and warm.
2174
- */
2175
- checkReadiness(): Promise<{
2176
- lastKeepAliveAt: number;
2177
- status: "warming" | "hot" | "unknown";
2178
- }>;
2179
- }
2180
- declare class OntologyHandle {
2181
- private granular;
2182
- private ontologyNameOrId;
2183
- constructor(granular: Granular, ontologyNameOrId: string);
2184
- get effects(): {
2185
- register: (effect: ToolWithHandler) => Promise<void>;
2186
- registerMany: (effects: ToolWithHandler[]) => Promise<void>;
2187
- unregister: (name: string) => Promise<void>;
2188
- clear: () => Promise<void>;
2189
- disconnect: () => Promise<void>;
2190
- };
2191
- get importer(): {
2192
- onEnvironmentCreate: (handler: EnvironmentImporterHandler) => void;
2193
- clear: () => void;
2194
- };
2195
- }
2196
- declare class Granular {
2197
- private apiKey;
2198
- private apiUrl;
2199
- private httpUrl;
2200
- private tokenProvider?;
2201
- private WebSocketCtor?;
2202
- private onUnexpectedClose?;
2203
- private onReconnectError?;
2204
- private effectHostUrl?;
2205
- private debugHttp;
2206
- /** Sandbox-level effect registry: sandboxId → (effectKey@selector → ToolWithHandler) */
2207
- private sandboxEffects;
2208
- /** Live sandbox-scoped effect hosts keyed by sandboxId */
2209
- private sandboxEffectHosts;
2210
- /** In-flight host connection promises to avoid duplicate concurrent connects */
2211
- private sandboxEffectHostPromises;
2212
- /** Ontology-bound environment importer hooks keyed by the caller's ontology identifier. */
2213
- private ontologyImporters;
2214
- /** Resolved importer hooks keyed by sandboxId for fast lookups during openEnvironment(). */
2215
- private sandboxImporters;
2216
- /**
2217
- * Create a new Granular client
2218
- * @param options - Client configuration
2219
- */
2220
- constructor(options: GranularOptions);
2221
- /**
2222
- * Return an ontology-scoped handle for effects and other ontology-level APIs.
2223
- */
2224
- ontology(ontologyNameOrId: string): OntologyHandle;
2225
- registerEnvironmentImporter(ontologyNameOrId: string, handler: EnvironmentImporterHandler): void;
2226
- clearEnvironmentImporter(ontologyNameOrId: string): void;
2227
- /**
2228
- * Records/upserts a user and prepares them for sandbox connections
2229
- *
2230
- * @param options - User options
2231
- * @returns The recorded user with both `userId` and `granularId`
2232
- *
2233
- * @example
2234
- * ```typescript
2235
- * const user = await granular.recordUser({
2236
- * userId: 'user_123',
2237
- * name: 'John Doe',
2238
- * permissions: ['agent'],
2239
- * });
2240
- * ```
2241
- */
2242
- recordUser(options: RecordUserOptions): Promise<User>;
2243
- /**
2244
- * Alias for `recordUser()` with user-facing naming that matches upsert semantics.
2245
- */
2246
- upsertUser(options: RecordUserOptions): Promise<User>;
2247
- private resolveConnectUser;
2248
- /**
2249
- * Open or resolve an ontology environment for one user without opening a session.
2250
- *
2251
- * @example
2252
- * ```typescript
2253
- * const environment = await granular.openEnvironment({
2254
- * ontology: 'my-ontology',
2255
- * tag: 'dev',
2256
- * userId: 'user_123',
2257
- * permissions: ['agent'],
2258
- * });
2259
- *
2260
- * await environment.data.record({
2261
- * className: 'customer',
2262
- * id: 'acme',
2263
- * fields: { name: 'Acme' },
2264
- * });
2265
- *
2266
- * const session = await environment.sessions.create();
2267
- * const job = await session.submitJob(`return "hello";`);
2268
- * console.log(await job.result);
2269
- * ```
2270
- */
2271
- openEnvironment(options: OpenEnvironmentOptions): Promise<Environment>;
2272
- /**
2273
- * Deprecated compatibility alias for `openEnvironment()`.
2274
- *
2275
- * `connect()` no longer opens a runtime session automatically.
2276
- */
2277
- connect(options: ConnectOptions): Promise<Environment>;
2278
- /**
2279
- * Run a registered environment importer against an environment that was
2280
- * opened outside this SDK instance, for example by a delegated browser flow.
2281
- *
2282
- * This uses the same setup-run and queued record-import plumbing as
2283
- * `openEnvironment()`: importer stages, expected object counts, and queued
2284
- * import counters remain visible through `environment.setup` and
2285
- * `getRecordImportSummary()`.
2286
- */
2287
- runEnvironmentImporterForEnvironment(environmentId: string, options?: RunEnvironmentImporterOptions): Promise<EnvironmentSetupSummary | null>;
2288
- private resolveRequestedTag;
2289
- private buildManagedEnvironmentName;
2290
- private matchesTagTrackedEnvironment;
2291
- private sortEnvironmentsByRecency;
2292
- private resolveOpenEnvironmentData;
2293
- /**
2294
- * List active (open) sessions for an environment — each session is one agent conversation thread.
2295
- */
2296
- listOpenSessions(filters: {
2297
- environmentId: string;
2298
- }): Promise<ConversationSessionInfo[]>;
2299
- /**
2300
- * List closed sessions for an environment (conversations that have disconnected).
2301
- */
2302
- listClosedSessions(filters: {
2303
- environmentId: string;
2304
- }): Promise<ConversationSessionInfo[]>;
2305
- private listSessionsForEnvironment;
2306
- private normalizeConversationSession;
2307
- private static coerceIsoDate;
2308
- /**
2309
- * Create a new session (conversation) for an existing environment and connect to it.
2310
- * The runtime graph is shared across all sessions for the same environment.
2311
- */
2312
- createSession(options: {
2313
- environmentId: string;
2314
- clientId?: string;
2315
- initialHeap?: CreateSessionOptions["initialHeap"];
2316
- }): Promise<EnvironmentSession>;
2317
- /**
2318
- * Connect to an existing open session (same conversation thread) using a freshly minted WebSocket token.
2319
- */
2320
- connectSession(options: {
2321
- sessionId: string;
2322
- clientId?: string;
2323
- }): Promise<EnvironmentSession>;
2324
- /**
2325
- * Mark a session closed in the control plane. If `environment` is the connected handle for that
2326
- * `sessionId`, disconnects the WebSocket so the runtime tears down cleanly.
2327
- */
2328
- closeSession(sessionId: string, environment?: EnvironmentSession | null): Promise<void>;
2329
- /**
2330
- * Re-open a closed session in the index and connect to its existing runtime document.
2331
- */
2332
- reopenSession(sessionId: string, options?: {
2333
- clientId?: string;
2334
- }): Promise<EnvironmentSession>;
2335
- private resolveEnvironmentImporter;
2336
- private maybeRunEnvironmentImporter;
2337
- private runEnvironmentImporter;
2338
- private bindEnvironmentHandle;
2339
- private bindWebSocketEnvironmentSession;
2340
- private activateEnvironment;
2341
- private getSandboxEffectMap;
2342
- private serializeEffect;
2343
- private publishSandboxEffectCatalog;
2344
- private syncSandboxEffectCatalog;
2345
- private recoverEffectHost;
2346
- private startEffectHostHeartbeat;
2347
- private stopEffectHostHeartbeat;
2348
- private synchronizeEffectHost;
2349
- private ensureSandboxEffectHost;
2350
- private disconnectSandboxEffectHost;
2351
- /**
2352
- * Register an effect (tool) for a specific sandbox.
2353
- *
2354
- * @param sandboxNameOrId - The name or ID of the sandbox
2355
- * @param effect - The tool definition and handler
2356
- */
2357
- registerEffect(sandboxNameOrId: string, effect: ToolWithHandler): Promise<void>;
2358
- /**
2359
- * Register multiple effects (tools) for a specific sandbox.
2360
- *
2361
- * batch version of `registerEffect`.
2362
- */
2363
- registerEffects(sandboxNameOrId: string, effects: ToolWithHandler[]): Promise<void>;
2364
- /**
2365
- * Unregister an effect from a sandbox.
2366
- *
2367
- * Removes it from the local sandbox registry and updates the
2368
- * sandbox-scoped live catalog.
2369
- */
2370
- unregisterEffect(sandboxNameOrId: string, name: string): Promise<void>;
2371
- /**
2372
- * Disconnect one sandbox-scoped effect host, or all of them when no sandbox is provided.
2373
- *
2374
- * This is primarily useful for long-lived helper processes such as generated
2375
- * `granular-effects.ts` scripts that need to shut down cleanly on SIGINT/SIGTERM.
2376
- */
2377
- disconnectEffects(sandboxNameOrId?: string): Promise<void>;
2378
- /**
2379
- * Unregister all effects for a sandbox.
2380
- */
2381
- unregisterAllEffects(sandboxNameOrId: string): Promise<void>;
2382
- /**
2383
- * Find a sandbox by name or create it if it doesn't exist
2384
- */
2385
- private findOrCreateSandbox;
2386
- /**
2387
- * Ensure a permission profile exists for a sandbox, creating it if needed.
2388
- * If profileName matches an existing profile name, returns its ID.
2389
- * Otherwise, creates a v1 source-profile file shape with an allow default.
2390
- */
2391
- private ensurePermissionProfile;
2392
- /**
2393
- * Ensure an assignment exists for a subject in a sandbox with a permission profile
2394
- */
2395
- private ensureAssignment;
2396
- /**
2397
- * Sandbox management API
2398
- */
2399
- get sandboxes(): {
2400
- list: () => Promise<SandboxListResponse>;
2401
- get: (id: string) => Promise<Sandbox>;
2402
- create: (data: CreateSandboxData) => Promise<Sandbox>;
2403
- update: (id: string, data: Partial<CreateSandboxData>) => Promise<Sandbox>;
2404
- delete: (id: string) => Promise<DeleteResponse>;
2405
- };
2406
- /**
2407
- * Permission Profile management for sandboxes
2408
- */
2409
- get permissionProfiles(): {
2410
- list: (sandboxId: string) => Promise<PermissionProfile[]>;
2411
- get: (sandboxId: string, profileId: string) => Promise<PermissionProfile>;
2412
- create: (sandboxId: string, data: CreatePermissionProfileData) => Promise<PermissionProfile>;
2413
- delete: (_sandboxId: string, _profileId: string) => Promise<DeleteResponse>;
2414
- };
2415
- /**
2416
- * Environment management
2417
- */
2418
- get environments(): {
2419
- list: (sandboxId: string) => Promise<EnvironmentData[]>;
2420
- get: (environmentId: string) => Promise<EnvironmentData>;
2421
- create: (sandboxId: string, data: CreateEnvironmentData) => Promise<EnvironmentData>;
2422
- delete: (environmentId: string) => Promise<DeleteResponse>;
2423
- };
2424
- /**
2425
- * Event stream operations: query, subscribe, and acknowledge stream events
2426
- */
2427
- get streams(): {
2428
- getEvents: (params: {
2429
- ontology: string;
2430
- stream: string;
2431
- environment?: string;
2432
- session?: string;
2433
- eventTypes?: string[];
2434
- since?: Date;
2435
- until?: Date;
2436
- isAcked?: boolean;
2437
- limit?: number;
2438
- offset?: number;
2439
- }) => Promise<StreamEvent[]>;
2440
- subscribe: (params: {
2441
- ontology: string;
2442
- stream: string;
2443
- environment?: string;
2444
- session?: string;
2445
- eventTypes?: string[];
2446
- since?: Date;
2447
- onEvent: (event: StreamEvent) => void;
2448
- onError?: (err: Error) => void;
2449
- pollIntervalMs?: number;
2450
- }) => StreamSubscription;
2451
- ack: (eventId: string) => Promise<void>;
2452
- ackBatch: (eventIds: string[]) => Promise<void>;
2453
- getStats: (params: {
2454
- ontology: string;
2455
- environment?: string;
2456
- }) => Promise<StreamStats[]>;
2457
- };
2458
- /**
2459
- * Subject management
2460
- */
2461
- get subjects(): {
2462
- get: (subjectId: string) => Promise<Subject>;
2463
- listAssignments: (subjectId: string) => Promise<AssignmentListResponse>;
2464
- };
2465
- /**
2466
- * @deprecated Use recordUser() instead
2467
- */
2468
- get users(): {
2469
- create: (data: {
2470
- id: string;
2471
- name?: string;
2472
- email?: string;
2473
- }) => Promise<Subject>;
2474
- get: (id: string) => Promise<Subject>;
2475
- };
2476
- private _resolveSandboxId;
2477
- /**
2478
- * Make an authenticated API request
2479
- */
2480
- private request;
2481
- }
2482
-
2483
- export { type SemanticVersionDiff as $, type AccessTokenProvider as A, type BuildPolicy as B, type ConnectOptions as C, type DomainState as D, type EndpointMode as E, type VersionTag as F, Granular as G, type EnvironmentData as H, type InstanceToolHandler as I, type CreateEnvironmentData as J, type EnvironmentListResponse as K, type Manifest as L, type ManifestEffectMetamodelSpec as M, type ManifestListResponse as N, OntologyHandle as O, type Prompt as P, type BuildStatus as Q, type ResolvedEffectBehaviors as R, type SessionHeapEntry as S, type ToolWithHandler as T, type User as U, type VersionTracking as V, WSClient as W, type Build as X, type Version as Y, type BuildListResponse as Z, type SemanticVersionDiffEntry as _, type EffectHandlerContext as a, type RecordImport as a$, type ResolvedEffectPostCondition as a0, type ResolvedEffectDryRun as a1, type ResolvedEffectReverse as a2, type ResolvedEffectApprovalRequired as a3, type EffectInvocationMode as a4, type EffectInvocationMetadata as a5, type EffectSchema as a6, type EffectWithHandler as a7, type PublishEffectsResult as a8, type EffectVersionSelector as a9, type RecordMentionInput as aA, type SessionDocumentResult as aB, type SessionCollectionListOptions as aC, type SessionJobListOptions as aD, type SessionCollectionListResult as aE, type WSDisconnectInfo as aF, type WSReconnectErrorInfo as aG, type WSClientOptions as aH, type RPCRequest as aI, type RPCResponse as aJ, type SyncMessage as aK, type RPCRequestFromServer as aL, type ToolInvokeParams as aM, type ToolResultParams as aN, type ModelRef as aO, type RelationshipInfo as aP, type DefineRelationshipOptions as aQ, type RecordObjectOptions as aR, type RecordObjectResult as aS, type RecordObjectsChunkInfo as aT, type RecordObjectsOptions as aU, type RecordImportWriteMode as aV, type RecordImportOptions as aW, type RecordImportStatus as aX, type RecordImportItemStatus as aY, type RecordImportStats as aZ, type RecordImportItem as a_, type ToolInfo as aa, type EffectInfo as ab, type ToolsChangedEvent as ac, type EffectsChangedEvent as ad, type EffectHandler as ae, type InstanceEffectHandler as af, type JobStatus as ag, type JobFeedbackSentiment as ah, type JobFeedbackToolCall as ai, type JobFeedbackMetadata as aj, type JobFeedbackInput as ak, type JobFeedbackRecord as al, type EnvironmentFeedbackRecord as am, type JobSubmitResult as an, type Job as ao, type ConversationMessageShowRefs as ap, type ConversationMessageInput as aq, type ConversationAppendResult as ar, type SessionConversationMessage as as, type SessionTimelineEvent as at, type SessionJobRecord as au, type SessionHeapFieldType as av, type SessionHeapFieldValue as aw, type SessionHeapVariable as ax, type RecordSearchResult as ay, type RecordSearchOptions as az, type SessionHeapList as b, type EnvironmentRecordImportSummary as b0, type EnvironmentSetupTriggerReason as b1, type RunEnvironmentImporterOptions as b2, type EnvironmentSetupLifecycleStatus as b3, type EnvironmentSetupSummary as b4, type EnvironmentImporterImportOptions as b5, type EnvironmentImporter as b6, type ManifestPropertySpec as b7, type ManifestValidationOperator as b8, type ManifestEnumRuleSpec as b9, type ManifestFilterBySpec as ba, type ManifestValidationRuleSpec as bb, type ManifestStateMachineStateSpec as bc, type ManifestStateMachineTransitionSpec as bd, type ManifestStateMachineSpec as be, type ManifestPostConditionSpec as bf, type ManifestDryRunSpec as bg, type ManifestReverseSpec as bh, type ManifestApprovalRequiredSpec as bi, type ManifestRelationshipDef as bj, type ManifestEffectSchema as bk, type ManifestEffectDeclaration as bl, type ManifestEventTypeDef as bm, type ManifestEventStreamDef as bn, type ManifestOperation as bo, type ManifestImport as bp, type ManifestVolume as bq, type ManifestContent as br, type GraphQLResult as bs, type APIError as bt, type DeleteResponse as bu, type StreamEvent as bv, type StreamSubscription as bw, type StreamStats as bx, type SessionHeapSnapshot as c, type SessionTranscriptEntry as d, Environment as e, EnvironmentSession as f, Session as g, type ToolSchema as h, type PublishToolsResult as i, type ToolHandler as j, type GranularOptions as k, type GranularAuth as l, type RecordUserOptions as m, type Subject as n, type OpenEnvironmentOptions as o, type CreateSessionOptions as p, type ConversationSessionInfo as q, type Sandbox as r, type CreateSandboxData as s, type SandboxListResponse as t, type PermissionRules as u, type PermissionProfile as v, type CreatePermissionProfileData as w, type PermissionProfileListResponse as x, type Assignment as y, type AssignmentListResponse as z };