@granular-software/sdk 0.4.13 → 0.4.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -86,11 +86,15 @@ interface Subject {
86
86
  updatedAt: number;
87
87
  }
88
88
  /**
89
- * Options for connecting to a sandbox
89
+ * Options for connecting to an ontology environment
90
90
  */
91
91
  interface ConnectOptions {
92
- /** The sandbox name or ID to connect to */
93
- sandbox: string;
92
+ /** The ontology name or ID to connect to */
93
+ ontology: string;
94
+ /** Named environment slot such as `dev` or `prod` */
95
+ environment: string;
96
+ /** Advanced override for the version tag/channel to follow. In the common case, omit this. */
97
+ tagName?: string;
94
98
  /**
95
99
  * External user identifier from your app. This is the primary input for
96
100
  * connecting to a sandbox and the only required user field in the common case.
@@ -211,11 +215,30 @@ interface AssignmentListResponse {
211
215
  items: Assignment[];
212
216
  }
213
217
  /**
214
- * Build policy for environments
218
+ * Version tracking policy for environments.
219
+ *
220
+ * Environments either follow a version tag such as `dev` or `prod`, or they
221
+ * pin themselves to one immutable ontology version.
215
222
  */
216
223
  interface BuildPolicy {
217
- mode: 'current' | 'pinned';
224
+ mode: 'tag' | 'current' | 'pinned';
218
225
  buildId?: string;
226
+ versionId?: string;
227
+ tagId?: string;
228
+ tagName?: string;
229
+ }
230
+ type VersionTracking = BuildPolicy;
231
+ interface VersionTag {
232
+ tagId: string;
233
+ sandboxId: string;
234
+ name: string;
235
+ kind: 'channel' | 'release' | 'system';
236
+ targetBuildId?: string | null;
237
+ targetVersionId?: string | null;
238
+ description?: string | null;
239
+ protected?: boolean;
240
+ createdAt: number;
241
+ updatedAt: number;
219
242
  }
220
243
  /**
221
244
  * An environment links a user (subject) to a sandbox with specific permissions
@@ -223,10 +246,18 @@ interface BuildPolicy {
223
246
  interface EnvironmentData {
224
247
  environmentId: string;
225
248
  sandboxId: string;
249
+ ontologyId?: string;
226
250
  buildId: string;
251
+ versionId: string;
227
252
  subjectId: string;
253
+ envName: string;
254
+ environment?: string;
228
255
  permissionProfileId: string;
256
+ tagId?: string | null;
257
+ tag?: VersionTag | null;
258
+ tracking?: BuildPolicy;
229
259
  buildPolicy: BuildPolicy;
260
+ updateState?: 'up_to_date' | 'update_available' | 'upgrading' | 'failed';
230
261
  createdAt: number;
231
262
  updatedAt: number;
232
263
  }
@@ -236,9 +267,19 @@ interface EnvironmentData {
236
267
  interface CreateEnvironmentData {
237
268
  /** The user/subject ID to create the environment for */
238
269
  subjectId: string;
270
+ /** Named environment slot such as dev or prod */
271
+ environment?: string;
272
+ /** @deprecated Use `environment` instead. */
273
+ envName?: string;
239
274
  /** The permission profile to apply (optional - uses assignment if not specified) */
240
275
  permissionProfileId?: string | null;
241
- /** Build policy (defaults to current build) */
276
+ /** Follow a tag directly */
277
+ tagId?: string;
278
+ /** Follow a tag by name, typically dev or prod */
279
+ tagName?: string;
280
+ /** Pin the environment to a specific version */
281
+ versionId?: string;
282
+ /** Legacy/compat environment tracking input */
242
283
  buildPolicy?: BuildPolicy;
243
284
  }
244
285
  /**
@@ -267,25 +308,58 @@ interface ManifestListResponse {
267
308
  }
268
309
  type BuildStatus = 'queued' | 'building' | 'completed' | 'failed' | 'canceled';
269
310
  /**
270
- * A build represents a compiled version of a manifest
311
+ * An immutable ontology version derived from a specific manifest revision.
312
+ *
313
+ * The same version may have multiple build runs over time when the manifest
314
+ * content is unchanged but the compilation process is re-executed.
271
315
  */
272
316
  interface Build {
273
317
  buildId: string;
274
318
  sandboxId: string;
275
319
  manifestId: string;
320
+ manifestDigest?: string;
321
+ versionNumber?: number;
276
322
  status: BuildStatus;
277
323
  graphBinaryId?: string | null;
278
324
  logsUri?: string | null;
325
+ latestBuildRunId?: string | null;
326
+ buildRunId?: string;
327
+ createdNewVersion?: boolean;
328
+ environmentCount?: number;
329
+ laggingEnvironmentCount?: number;
330
+ sessionCount?: number;
279
331
  createdAt: number;
280
332
  updatedAt: number;
281
333
  isCurrent?: boolean;
282
334
  }
335
+ type Version = Build;
283
336
  /**
284
- * List response for builds
337
+ * List response for versions
285
338
  */
286
339
  interface BuildListResponse {
287
340
  items: Build[];
288
341
  }
342
+ interface SemanticVersionDiffEntry {
343
+ operationId: string;
344
+ kind: 'create' | 'update' | 'relationship' | 'effect' | 'unknown';
345
+ changeType: 'added' | 'removed' | 'changed';
346
+ label: string;
347
+ additive: boolean;
348
+ breaking: boolean;
349
+ before?: Record<string, unknown>;
350
+ after?: Record<string, unknown>;
351
+ }
352
+ interface SemanticVersionDiff {
353
+ summary: {
354
+ added: number;
355
+ removed: number;
356
+ changed: number;
357
+ additive: number;
358
+ breaking: number;
359
+ onlyAdditiveChanges: boolean;
360
+ };
361
+ entries: SemanticVersionDiffEntry[];
362
+ }
289
363
  /**
290
364
  * Effect handler for static/global effects: receives (input, context)
291
365
  */
@@ -1253,8 +1327,16 @@ declare class Environment extends Session {
1253
1327
  get environmentId(): string;
1254
1328
  /** The sandbox ID */
1255
1329
  get sandboxId(): string;
1330
+ /** The ontology ID */
1331
+ get ontologyId(): string;
1256
1332
  /** The subject ID */
1257
1333
  get subjectId(): string;
1334
+ /** The named environment slot, such as dev or prod */
1335
+ get envName(): string;
1336
+ /** The named environment slot, such as dev or prod */
1337
+ get environment(): string;
1338
+ /** The resolved ontology version backing this environment */
1339
+ get versionId(): string;
1258
1340
  /** Internal Granular user identifier for this environment */
1259
1341
  get granularId(): string;
1260
1342
  /** The permission profile ID */
@@ -1625,7 +1707,7 @@ declare class Granular {
1625
1707
  recordUser(options: RecordUserOptions): Promise<User>;
1626
1708
  private resolveConnectUser;
1627
1709
  /**
1628
- * Connect to a sandbox and establish a real-time environment session.
1710
+ * Connect to an ontology environment and establish a real-time session.
1629
1711
  *
1630
1712
  * Effects are registered at the sandbox level via `granular.registerEffect()`
1631
1713
  * or `granular.registerEffects()`. Sessions pick up live availability from
@@ -1637,7 +1719,8 @@ declare class Granular {
1637
1719
  * @example
1638
1720
  * ```typescript
1639
1721
  * const environment = await granular.connect({
1640
- * sandbox: 'my-sandbox',
1722
+ * ontology: 'my-ontology',
1723
+ * environment: 'dev',
1641
1724
  * userId: 'user_123',
1642
1725
  * permissions: ['agent'],
1643
1726
  * });
@@ -1657,7 +1740,7 @@ declare class Granular {
1657
1740
  *
1658
1741
  * console.log(await job.result); // 'Hello!'
1659
1742
  * ```
1660
- */
1743
+ */
1661
1744
  connect(options: ConnectOptions): Promise<Environment>;
1662
1745
  private activateEnvironment;
1663
1746
  private getSandboxEffectMap;
@@ -1776,4 +1859,4 @@ type EffectRuntimeRequest = {
1776
1859
  declare function normalizeEffectBehaviors(value?: ManifestEffectMetamodelSpec | ResolvedEffectBehaviors | null): ResolvedEffectBehaviors;
1777
1860
  declare function invokeRegisteredEffect(effectMap: Map<string, ToolWithHandler>, request: EffectRuntimeRequest): Promise<unknown>;
1778
1861
 
1779
- export { type APIError, type AccessTokenProvider, type Assignment, type AssignmentListResponse, type Build, type BuildListResponse, type BuildPolicy, type BuildStatus, type ConnectOptions, type CreateEnvironmentData, type CreatePermissionProfileData, type CreateSandboxData, type DefineRelationshipOptions, type DeleteResponse, type DomainState, type EffectHandler, type EffectHandlerContext, type EffectInfo, type EffectInvocationMetadata, type EffectInvocationMode, type EffectSchema, type EffectWithHandler, type EffectsChangedEvent, type EndpointMode, Environment, type EnvironmentData, type EnvironmentListResponse, type EnvironmentRecordImportSummary, Granular, type GranularAuth, type GranularOptions, type GraphQLResult, type InstanceEffectHandler, type InstanceToolHandler, type Job, type JobFeedbackInput, type JobFeedbackMetadata, type JobFeedbackRecord, type JobFeedbackSentiment, type JobFeedbackToolCall, type JobStatus, type JobSubmitResult, type Manifest, type ManifestApprovalRequiredSpec, type ManifestContent, type ManifestDryRunSpec, type ManifestEffectDeclaration, type ManifestEffectMetamodelSpec, type ManifestEffectSchema, type ManifestEnumRuleSpec, type ManifestFilterBySpec, type ManifestImport, type ManifestListResponse, type ManifestOperation, type ManifestPostConditionSpec, type ManifestPropertySpec, type ManifestRelationshipDef, type ManifestReverseSpec, type ManifestStateMachineSpec, type ManifestStateMachineStateSpec, type ManifestStateMachineTransitionSpec, type ManifestValidationOperator, type ManifestValidationRuleSpec, type ManifestVolume, type ModelRef, type PermissionProfile, type PermissionProfileListResponse, type PermissionRules, type Prompt, type PublishEffectsResult, type PublishToolsResult, type RPCRequest, type RPCRequestFromServer, type RPCResponse, type RecordImport, type RecordImportItem, type RecordImportItemStatus, type RecordImportStats, type RecordImportStatus, type RecordObjectOptions, type RecordObjectResult, type RecordUserOptions, type RelationshipInfo, type ResolvedEffectApprovalRequired, type ResolvedEffectBehaviors, type ResolvedEffectDryRun, type ResolvedEffectPostCondition, type ResolvedEffectReverse, type Sandbox, type SandboxListResponse, Session, type SessionHeapEntry, type SessionHeapFieldType, type SessionHeapFieldValue, type SessionHeapList, type SessionHeapSnapshot, type SessionHeapVariable, type Subject, type SyncMessage, type ToolHandler, type ToolInfo, type ToolInvokeParams, type ToolResultParams, type ToolSchema, type ToolWithHandler, type ToolsChangedEvent, type User, WSClient, type WSClientOptions, type WSDisconnectInfo, type WSReconnectErrorInfo, invokeRegisteredEffect, normalizeEffectBehaviors };
1862
+ export { type APIError, type AccessTokenProvider, type Assignment, type AssignmentListResponse, type Build, type BuildListResponse, type BuildPolicy, type BuildStatus, type ConnectOptions, type CreateEnvironmentData, type CreatePermissionProfileData, type CreateSandboxData, type DefineRelationshipOptions, type DeleteResponse, type DomainState, type EffectHandler, type EffectHandlerContext, type EffectInfo, type EffectInvocationMetadata, type EffectInvocationMode, type EffectSchema, type EffectWithHandler, type EffectsChangedEvent, type EndpointMode, Environment, type EnvironmentData, type EnvironmentListResponse, type EnvironmentRecordImportSummary, Granular, type GranularAuth, type GranularOptions, type GraphQLResult, type InstanceEffectHandler, type InstanceToolHandler, type Job, type JobFeedbackInput, type JobFeedbackMetadata, type JobFeedbackRecord, type JobFeedbackSentiment, type JobFeedbackToolCall, type JobStatus, type JobSubmitResult, type Manifest, type ManifestApprovalRequiredSpec, type ManifestContent, type ManifestDryRunSpec, type ManifestEffectDeclaration, type ManifestEffectMetamodelSpec, type ManifestEffectSchema, type ManifestEnumRuleSpec, type ManifestFilterBySpec, type ManifestImport, type ManifestListResponse, type ManifestOperation, type ManifestPostConditionSpec, type ManifestPropertySpec, type ManifestRelationshipDef, type ManifestReverseSpec, type ManifestStateMachineSpec, type ManifestStateMachineStateSpec, type ManifestStateMachineTransitionSpec, type ManifestValidationOperator, type ManifestValidationRuleSpec, type ManifestVolume, type ModelRef, type PermissionProfile, type PermissionProfileListResponse, type PermissionRules, type Prompt, type PublishEffectsResult, type PublishToolsResult, type RPCRequest, type RPCRequestFromServer, type RPCResponse, type RecordImport, type RecordImportItem, type RecordImportItemStatus, type RecordImportStats, type RecordImportStatus, type RecordObjectOptions, type RecordObjectResult, type RecordUserOptions, type RelationshipInfo, type ResolvedEffectApprovalRequired, type ResolvedEffectBehaviors, type ResolvedEffectDryRun, type ResolvedEffectPostCondition, type ResolvedEffectReverse, type Sandbox, type SandboxListResponse, type SemanticVersionDiff, type SemanticVersionDiffEntry, Session, type SessionHeapEntry, type SessionHeapFieldType, type SessionHeapFieldValue, type SessionHeapList, type SessionHeapSnapshot, type SessionHeapVariable, type Subject, type SyncMessage, type ToolHandler, type ToolInfo, type ToolInvokeParams, type ToolResultParams, type ToolSchema, type ToolWithHandler, type ToolsChangedEvent, type User, type Version, type VersionTag, type VersionTracking, WSClient, type WSClientOptions, type WSDisconnectInfo, type WSReconnectErrorInfo, invokeRegisteredEffect, normalizeEffectBehaviors };
package/dist/index.d.ts CHANGED
@@ -86,11 +86,15 @@ interface Subject {
86
86
  updatedAt: number;
87
87
  }
88
88
  /**
89
- * Options for connecting to a sandbox
89
+ * Options for connecting to an ontology environment
90
90
  */
91
91
  interface ConnectOptions {
92
- /** The sandbox name or ID to connect to */
93
- sandbox: string;
92
+ /** The ontology name or ID to connect to */
93
+ ontology: string;
94
+ /** Named environment slot such as `dev` or `prod` */
95
+ environment: string;
96
+ /** Advanced override for the version tag/channel to follow. In the common case, omit this. */
97
+ tagName?: string;
94
98
  /**
95
99
  * External user identifier from your app. This is the primary input for
96
100
  * connecting to a sandbox and the only required user field in the common case.
@@ -211,11 +215,30 @@ interface AssignmentListResponse {
211
215
  items: Assignment[];
212
216
  }
213
217
  /**
214
- * Build policy for environments
218
+ * Version tracking policy for environments.
219
+ *
220
+ * Environments either follow a version tag such as `dev` or `prod`, or they
221
+ * pin themselves to one immutable ontology version.
215
222
  */
216
223
  interface BuildPolicy {
217
- mode: 'current' | 'pinned';
224
+ mode: 'tag' | 'current' | 'pinned';
218
225
  buildId?: string;
226
+ versionId?: string;
227
+ tagId?: string;
228
+ tagName?: string;
229
+ }
230
+ type VersionTracking = BuildPolicy;
231
+ interface VersionTag {
232
+ tagId: string;
233
+ sandboxId: string;
234
+ name: string;
235
+ kind: 'channel' | 'release' | 'system';
236
+ targetBuildId?: string | null;
237
+ targetVersionId?: string | null;
238
+ description?: string | null;
239
+ protected?: boolean;
240
+ createdAt: number;
241
+ updatedAt: number;
219
242
  }
220
243
  /**
221
244
  * An environment links a user (subject) to a sandbox with specific permissions
@@ -223,10 +246,18 @@ interface BuildPolicy {
223
246
  interface EnvironmentData {
224
247
  environmentId: string;
225
248
  sandboxId: string;
249
+ ontologyId?: string;
226
250
  buildId: string;
251
+ versionId: string;
227
252
  subjectId: string;
253
+ envName: string;
254
+ environment?: string;
228
255
  permissionProfileId: string;
256
+ tagId?: string | null;
257
+ tag?: VersionTag | null;
258
+ tracking?: BuildPolicy;
229
259
  buildPolicy: BuildPolicy;
260
+ updateState?: 'up_to_date' | 'update_available' | 'upgrading' | 'failed';
230
261
  createdAt: number;
231
262
  updatedAt: number;
232
263
  }
@@ -236,9 +267,19 @@ interface EnvironmentData {
236
267
  interface CreateEnvironmentData {
237
268
  /** The user/subject ID to create the environment for */
238
269
  subjectId: string;
270
+ /** Named environment slot such as dev or prod */
271
+ environment?: string;
272
+ /** @deprecated Use `environment` instead. */
273
+ envName?: string;
239
274
  /** The permission profile to apply (optional - uses assignment if not specified) */
240
275
  permissionProfileId?: string | null;
241
- /** Build policy (defaults to current build) */
276
+ /** Follow a tag directly */
277
+ tagId?: string;
278
+ /** Follow a tag by name, typically dev or prod */
279
+ tagName?: string;
280
+ /** Pin the environment to a specific version */
281
+ versionId?: string;
282
+ /** Legacy/compat environment tracking input */
242
283
  buildPolicy?: BuildPolicy;
243
284
  }
244
285
  /**
@@ -267,25 +308,58 @@ interface ManifestListResponse {
267
308
  }
268
309
  type BuildStatus = 'queued' | 'building' | 'completed' | 'failed' | 'canceled';
269
310
  /**
270
- * A build represents a compiled version of a manifest
311
+ * An immutable ontology version derived from a specific manifest revision.
312
+ *
313
+ * The same version may have multiple build runs over time when the manifest
314
+ * content is unchanged but the compilation process is re-executed.
271
315
  */
272
316
  interface Build {
273
317
  buildId: string;
274
318
  sandboxId: string;
275
319
  manifestId: string;
320
+ manifestDigest?: string;
321
+ versionNumber?: number;
276
322
  status: BuildStatus;
277
323
  graphBinaryId?: string | null;
278
324
  logsUri?: string | null;
325
+ latestBuildRunId?: string | null;
326
+ buildRunId?: string;
327
+ createdNewVersion?: boolean;
328
+ environmentCount?: number;
329
+ laggingEnvironmentCount?: number;
330
+ sessionCount?: number;
279
331
  createdAt: number;
280
332
  updatedAt: number;
281
333
  isCurrent?: boolean;
282
334
  }
335
+ type Version = Build;
283
336
  /**
284
- * List response for builds
337
+ * List response for versions
285
338
  */
286
339
  interface BuildListResponse {
287
340
  items: Build[];
288
341
  }
342
+ interface SemanticVersionDiffEntry {
343
+ operationId: string;
344
+ kind: 'create' | 'update' | 'relationship' | 'effect' | 'unknown';
345
+ changeType: 'added' | 'removed' | 'changed';
346
+ label: string;
347
+ additive: boolean;
348
+ breaking: boolean;
349
+ before?: Record<string, unknown>;
350
+ after?: Record<string, unknown>;
351
+ }
352
+ interface SemanticVersionDiff {
353
+ summary: {
354
+ added: number;
355
+ removed: number;
356
+ changed: number;
357
+ additive: number;
358
+ breaking: number;
359
+ onlyAdditiveChanges: boolean;
360
+ };
361
+ entries: SemanticVersionDiffEntry[];
362
+ }
289
363
  /**
290
364
  * Effect handler for static/global effects: receives (input, context)
291
365
  */
@@ -1253,8 +1327,16 @@ declare class Environment extends Session {
1253
1327
  get environmentId(): string;
1254
1328
  /** The sandbox ID */
1255
1329
  get sandboxId(): string;
1330
+ /** The ontology ID */
1331
+ get ontologyId(): string;
1256
1332
  /** The subject ID */
1257
1333
  get subjectId(): string;
1334
+ /** The named environment slot, such as dev or prod */
1335
+ get envName(): string;
1336
+ /** The named environment slot, such as dev or prod */
1337
+ get environment(): string;
1338
+ /** The resolved ontology version backing this environment */
1339
+ get versionId(): string;
1258
1340
  /** Internal Granular user identifier for this environment */
1259
1341
  get granularId(): string;
1260
1342
  /** The permission profile ID */
@@ -1625,7 +1707,7 @@ declare class Granular {
1625
1707
  recordUser(options: RecordUserOptions): Promise<User>;
1626
1708
  private resolveConnectUser;
1627
1709
  /**
1628
- * Connect to a sandbox and establish a real-time environment session.
1710
+ * Connect to an ontology environment and establish a real-time session.
1629
1711
  *
1630
1712
  * Effects are registered at the sandbox level via `granular.registerEffect()`
1631
1713
  * or `granular.registerEffects()`. Sessions pick up live availability from
@@ -1637,7 +1719,8 @@ declare class Granular {
1637
1719
  * @example
1638
1720
  * ```typescript
1639
1721
  * const environment = await granular.connect({
1640
- * sandbox: 'my-sandbox',
1722
+ * ontology: 'my-ontology',
1723
+ * environment: 'dev',
1641
1724
  * userId: 'user_123',
1642
1725
  * permissions: ['agent'],
1643
1726
  * });
@@ -1657,7 +1740,7 @@ declare class Granular {
1657
1740
  *
1658
1741
  * console.log(await job.result); // 'Hello!'
1659
1742
  * ```
1660
- */
1743
+ */
1661
1744
  connect(options: ConnectOptions): Promise<Environment>;
1662
1745
  private activateEnvironment;
1663
1746
  private getSandboxEffectMap;
@@ -1776,4 +1859,4 @@ type EffectRuntimeRequest = {
1776
1859
  declare function normalizeEffectBehaviors(value?: ManifestEffectMetamodelSpec | ResolvedEffectBehaviors | null): ResolvedEffectBehaviors;
1777
1860
  declare function invokeRegisteredEffect(effectMap: Map<string, ToolWithHandler>, request: EffectRuntimeRequest): Promise<unknown>;
1778
1861
 
1779
- export { type APIError, type AccessTokenProvider, type Assignment, type AssignmentListResponse, type Build, type BuildListResponse, type BuildPolicy, type BuildStatus, type ConnectOptions, type CreateEnvironmentData, type CreatePermissionProfileData, type CreateSandboxData, type DefineRelationshipOptions, type DeleteResponse, type DomainState, type EffectHandler, type EffectHandlerContext, type EffectInfo, type EffectInvocationMetadata, type EffectInvocationMode, type EffectSchema, type EffectWithHandler, type EffectsChangedEvent, type EndpointMode, Environment, type EnvironmentData, type EnvironmentListResponse, type EnvironmentRecordImportSummary, Granular, type GranularAuth, type GranularOptions, type GraphQLResult, type InstanceEffectHandler, type InstanceToolHandler, type Job, type JobFeedbackInput, type JobFeedbackMetadata, type JobFeedbackRecord, type JobFeedbackSentiment, type JobFeedbackToolCall, type JobStatus, type JobSubmitResult, type Manifest, type ManifestApprovalRequiredSpec, type ManifestContent, type ManifestDryRunSpec, type ManifestEffectDeclaration, type ManifestEffectMetamodelSpec, type ManifestEffectSchema, type ManifestEnumRuleSpec, type ManifestFilterBySpec, type ManifestImport, type ManifestListResponse, type ManifestOperation, type ManifestPostConditionSpec, type ManifestPropertySpec, type ManifestRelationshipDef, type ManifestReverseSpec, type ManifestStateMachineSpec, type ManifestStateMachineStateSpec, type ManifestStateMachineTransitionSpec, type ManifestValidationOperator, type ManifestValidationRuleSpec, type ManifestVolume, type ModelRef, type PermissionProfile, type PermissionProfileListResponse, type PermissionRules, type Prompt, type PublishEffectsResult, type PublishToolsResult, type RPCRequest, type RPCRequestFromServer, type RPCResponse, type RecordImport, type RecordImportItem, type RecordImportItemStatus, type RecordImportStats, type RecordImportStatus, type RecordObjectOptions, type RecordObjectResult, type RecordUserOptions, type RelationshipInfo, type ResolvedEffectApprovalRequired, type ResolvedEffectBehaviors, type ResolvedEffectDryRun, type ResolvedEffectPostCondition, type ResolvedEffectReverse, type Sandbox, type SandboxListResponse, Session, type SessionHeapEntry, type SessionHeapFieldType, type SessionHeapFieldValue, type SessionHeapList, type SessionHeapSnapshot, type SessionHeapVariable, type Subject, type SyncMessage, type ToolHandler, type ToolInfo, type ToolInvokeParams, type ToolResultParams, type ToolSchema, type ToolWithHandler, type ToolsChangedEvent, type User, WSClient, type WSClientOptions, type WSDisconnectInfo, type WSReconnectErrorInfo, invokeRegisteredEffect, normalizeEffectBehaviors };
1862
+ export { type APIError, type AccessTokenProvider, type Assignment, type AssignmentListResponse, type Build, type BuildListResponse, type BuildPolicy, type BuildStatus, type ConnectOptions, type CreateEnvironmentData, type CreatePermissionProfileData, type CreateSandboxData, type DefineRelationshipOptions, type DeleteResponse, type DomainState, type EffectHandler, type EffectHandlerContext, type EffectInfo, type EffectInvocationMetadata, type EffectInvocationMode, type EffectSchema, type EffectWithHandler, type EffectsChangedEvent, type EndpointMode, Environment, type EnvironmentData, type EnvironmentListResponse, type EnvironmentRecordImportSummary, Granular, type GranularAuth, type GranularOptions, type GraphQLResult, type InstanceEffectHandler, type InstanceToolHandler, type Job, type JobFeedbackInput, type JobFeedbackMetadata, type JobFeedbackRecord, type JobFeedbackSentiment, type JobFeedbackToolCall, type JobStatus, type JobSubmitResult, type Manifest, type ManifestApprovalRequiredSpec, type ManifestContent, type ManifestDryRunSpec, type ManifestEffectDeclaration, type ManifestEffectMetamodelSpec, type ManifestEffectSchema, type ManifestEnumRuleSpec, type ManifestFilterBySpec, type ManifestImport, type ManifestListResponse, type ManifestOperation, type ManifestPostConditionSpec, type ManifestPropertySpec, type ManifestRelationshipDef, type ManifestReverseSpec, type ManifestStateMachineSpec, type ManifestStateMachineStateSpec, type ManifestStateMachineTransitionSpec, type ManifestValidationOperator, type ManifestValidationRuleSpec, type ManifestVolume, type ModelRef, type PermissionProfile, type PermissionProfileListResponse, type PermissionRules, type Prompt, type PublishEffectsResult, type PublishToolsResult, type RPCRequest, type RPCRequestFromServer, type RPCResponse, type RecordImport, type RecordImportItem, type RecordImportItemStatus, type RecordImportStats, type RecordImportStatus, type RecordObjectOptions, type RecordObjectResult, type RecordUserOptions, type RelationshipInfo, type ResolvedEffectApprovalRequired, type ResolvedEffectBehaviors, type ResolvedEffectDryRun, type ResolvedEffectPostCondition, type ResolvedEffectReverse, type Sandbox, type SandboxListResponse, type SemanticVersionDiff, type SemanticVersionDiffEntry, Session, type SessionHeapEntry, type SessionHeapFieldType, type SessionHeapFieldValue, type SessionHeapList, type SessionHeapSnapshot, type SessionHeapVariable, type Subject, type SyncMessage, type ToolHandler, type ToolInfo, type ToolInvokeParams, type ToolResultParams, type ToolSchema, type ToolWithHandler, type ToolsChangedEvent, type User, type Version, type VersionTag, type VersionTracking, WSClient, type WSClientOptions, type WSDisconnectInfo, type WSReconnectErrorInfo, invokeRegisteredEffect, normalizeEffectBehaviors };
package/dist/index.js CHANGED
@@ -5613,6 +5613,19 @@ function normalizeUser(user) {
5613
5613
  permissions: Array.isArray(user.permissions) ? user.permissions : []
5614
5614
  };
5615
5615
  }
5616
+ function normalizeEnvironmentData(environment) {
5617
+ const buildPolicy = environment.buildPolicy || environment.tracking || (environment.tagId ? { mode: "tag", tagId: environment.tagId } : { mode: "pinned", versionId: environment.versionId || environment.buildId });
5618
+ const environmentName = environment.environment || environment.envName || "prod";
5619
+ return {
5620
+ ...environment,
5621
+ ontologyId: environment.ontologyId || environment.sandboxId,
5622
+ versionId: environment.versionId || environment.buildId,
5623
+ envName: environmentName,
5624
+ environment: environmentName,
5625
+ buildPolicy,
5626
+ tracking: environment.tracking || buildPolicy
5627
+ };
5628
+ }
5616
5629
  var Environment = class extends Session {
5617
5630
  envData;
5618
5631
  _apiKey;
@@ -5631,10 +5644,26 @@ var Environment = class extends Session {
5631
5644
  get sandboxId() {
5632
5645
  return this.envData.sandboxId;
5633
5646
  }
5647
+ /** The ontology ID */
5648
+ get ontologyId() {
5649
+ return this.envData.ontologyId || this.envData.sandboxId;
5650
+ }
5634
5651
  /** The subject ID */
5635
5652
  get subjectId() {
5636
5653
  return this.envData.subjectId;
5637
5654
  }
5655
+ /** The named environment slot, such as dev or prod */
5656
+ get envName() {
5657
+ return this.envData.envName;
5658
+ }
5659
+ /** The named environment slot, such as dev or prod */
5660
+ get environment() {
5661
+ return this.envData.environment || this.envData.envName;
5662
+ }
5663
+ /** The resolved ontology version backing this environment */
5664
+ get versionId() {
5665
+ return this.envData.versionId || this.envData.buildId;
5666
+ }
5638
5667
  /** Internal Granular user identifier for this environment */
5639
5668
  get granularId() {
5640
5669
  return this.envData.subjectId;
@@ -6606,7 +6635,7 @@ var Granular = class {
6606
6635
  throw new Error("connect() requires either userId, granularId, or a user object returned by recordUser().");
6607
6636
  }
6608
6637
  /**
6609
- * Connect to a sandbox and establish a real-time environment session.
6638
+ * Connect to an ontology environment and establish a real-time session.
6610
6639
  *
6611
6640
  * Effects are registered at the sandbox level via `granular.registerEffect()`
6612
6641
  * or `granular.registerEffects()`. Sessions pick up live availability from
@@ -6618,7 +6647,8 @@ var Granular = class {
6618
6647
  * @example
6619
6648
  * ```typescript
6620
6649
  * const environment = await granular.connect({
6621
- * sandbox: 'my-sandbox',
6650
+ * ontology: 'my-ontology',
6651
+ * environment: 'dev',
6622
6652
  * userId: 'user_123',
6623
6653
  * permissions: ['agent'],
6624
6654
  * });
@@ -6638,17 +6668,28 @@ var Granular = class {
6638
6668
  *
6639
6669
  * console.log(await job.result); // 'Hello!'
6640
6670
  * ```
6641
- */
6671
+ */
6642
6672
  async connect(options) {
6643
6673
  const clientId = options.clientId || `client_${Date.now()}`;
6674
+ const ontology = options.ontology;
6675
+ if (!ontology) {
6676
+ throw new Error("connect() requires `ontology`.");
6677
+ }
6678
+ const environmentName = options.environment;
6679
+ if (!environmentName) {
6680
+ throw new Error("connect() requires `environment`.");
6681
+ }
6682
+ const tagName = options.tagName?.trim() || void 0;
6644
6683
  const user = await this.resolveConnectUser(options);
6645
- const sandbox = await this.findOrCreateSandbox(options.sandbox);
6684
+ const sandbox = await this.findOrCreateSandbox(ontology);
6646
6685
  for (const profileName of user.permissions) {
6647
6686
  const profileId = await this.ensurePermissionProfile(sandbox.sandboxId, profileName);
6648
6687
  await this.ensureAssignment(user.granularId, sandbox.sandboxId, profileId);
6649
6688
  }
6650
6689
  const envData = await this.environments.create(sandbox.sandboxId, {
6651
6690
  subjectId: user.granularId,
6691
+ environment: environmentName,
6692
+ tagName,
6652
6693
  permissionProfileId: null
6653
6694
  });
6654
6695
  await this.activateEnvironment(envData.environmentId);
@@ -7083,16 +7124,22 @@ var Granular = class {
7083
7124
  const result = await this.request(
7084
7125
  `/control/sandboxes/${sandboxId}/environments`
7085
7126
  );
7086
- return result.items;
7127
+ return result.items.map(normalizeEnvironmentData);
7087
7128
  },
7088
7129
  get: async (environmentId) => {
7089
- return this.request(`/control/environments/${environmentId}`);
7130
+ return normalizeEnvironmentData(
7131
+ await this.request(`/control/environments/${environmentId}`)
7132
+ );
7090
7133
  },
7091
7134
  create: async (sandboxId, data) => {
7092
- return this.request(`/control/sandboxes/${sandboxId}/environments`, {
7135
+ const environmentName = data.environment || data.envName;
7136
+ return normalizeEnvironmentData(await this.request(`/control/sandboxes/${sandboxId}/environments`, {
7093
7137
  method: "POST",
7094
- body: JSON.stringify(data)
7095
- });
7138
+ body: JSON.stringify({
7139
+ ...data,
7140
+ envName: environmentName
7141
+ })
7142
+ }));
7096
7143
  },
7097
7144
  delete: async (environmentId) => {
7098
7145
  return this.request(`/control/environments/${environmentId}`, {