@granular-software/sdk 0.4.51 → 0.4.52

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.
@@ -224,9 +224,28 @@ interface OpenEnvironmentOptions {
224
224
  * the newest tag target instead of reusing the outdated one.
225
225
  */
226
226
  createFreshIfOutdated?: boolean;
227
+ /**
228
+ * Create a fresh environment on the current tag target. Reusing this key is
229
+ * safe: it returns the environment created by the original operation.
230
+ */
231
+ resetKey?: string;
232
+ /** Canonical active-environment slot. Defaults to `default`. */
233
+ slot?: string;
227
234
  /** Backwards-compatible user object returned from `recordUser()`. */
228
235
  user?: User;
229
236
  }
237
+ /**
238
+ * One-time administrative migration of a known existing environment into
239
+ * Granular's active-environment map. The environment id must be obtained from
240
+ * a reviewed baseline; this API intentionally has no name-based lookup.
241
+ */
242
+ interface AdoptEnvironmentOptions {
243
+ sandboxId: string;
244
+ tag: string;
245
+ userId: string;
246
+ environmentId: string;
247
+ slot?: string;
248
+ }
230
249
  /**
231
250
  * Deprecated compatibility alias for the legacy `connect()` entry point.
232
251
  *
@@ -1768,6 +1787,8 @@ type RecordImportWriteMode = "adaptive" | "batched" | "per_record" | "parallel_5
1768
1787
  interface RecordImportOptions {
1769
1788
  batchSize?: number;
1770
1789
  setupRunId?: string;
1790
+ /** Stable key for retrying one logical durable import exactly once. */
1791
+ operationKey?: string;
1771
1792
  writeMode?: RecordImportWriteMode;
1772
1793
  }
1773
1794
  type RecordImportStatus = "queued" | "processing" | "completed" | "failed" | "canceled";
@@ -1807,6 +1828,7 @@ interface RecordImport {
1807
1828
  sandboxId: string;
1808
1829
  subjectId: string;
1809
1830
  setupRunId?: string | null;
1831
+ operationKey?: string | null;
1810
1832
  status: RecordImportStatus;
1811
1833
  batchSize: number;
1812
1834
  errorMessage: string | null;
@@ -1823,7 +1845,7 @@ interface EnvironmentRecordImportSummary extends RecordImportStats {
1823
1845
  activeImports: number;
1824
1846
  updatedAt: number;
1825
1847
  }
1826
- type EnvironmentSetupTriggerReason = "new_environment" | "fresh_after_version_update";
1848
+ type EnvironmentSetupTriggerReason = "new_environment" | "fresh_after_version_update" | "explicit_reset";
1827
1849
  interface RunEnvironmentImporterOptions {
1828
1850
  /**
1829
1851
  * Ontology name/id used to resolve the registered importer. Defaults to the
@@ -1834,6 +1856,8 @@ interface RunEnvironmentImporterOptions {
1834
1856
  * Reason recorded on the setup run. Defaults to `new_environment`.
1835
1857
  */
1836
1858
  reason?: EnvironmentSetupTriggerReason;
1859
+ /** Stable caller operation key. Use for explicit reset retries. */
1860
+ operationKey?: string;
1837
1861
  }
1838
1862
  type EnvironmentSetupLifecycleStatus = "running" | "completed" | "failed";
1839
1863
  interface EnvironmentSetupSummary extends RecordImportStats {
@@ -1842,6 +1866,7 @@ interface EnvironmentSetupSummary extends RecordImportStats {
1842
1866
  sandboxId: string;
1843
1867
  subjectId: string;
1844
1868
  triggerReason: EnvironmentSetupTriggerReason;
1869
+ operationKey?: string | null;
1845
1870
  lifecycleStatus: EnvironmentSetupLifecycleStatus;
1846
1871
  stage: string | null;
1847
1872
  totalObjectsToImport: number;
@@ -1852,6 +1877,14 @@ interface EnvironmentSetupSummary extends RecordImportStats {
1852
1877
  hookCompletedAt: number | null;
1853
1878
  finishedAt: number | null;
1854
1879
  updatedAt: number;
1880
+ /** `false` when an idempotent setup operation already exists. */
1881
+ created?: boolean;
1882
+ }
1883
+ /** Result of claiming the importer portion of a durable setup run. */
1884
+ interface EnvironmentSetupImporterClaim {
1885
+ action: "run" | "submitted" | "busy" | "terminal";
1886
+ summary: EnvironmentSetupSummary;
1887
+ retryAfterMs?: number;
1855
1888
  }
1856
1889
  interface EnvironmentImporterImportOptions {
1857
1890
  batchSize?: number;
@@ -1861,6 +1894,8 @@ interface EnvironmentImporter {
1861
1894
  environmentId: string;
1862
1895
  sandboxId: string;
1863
1896
  subjectId: string;
1897
+ /** Application identity originally supplied as `openEnvironment({ userId })`. */
1898
+ externalUserId: string;
1864
1899
  reason: EnvironmentSetupTriggerReason;
1865
1900
  incrementTotalObjectsToImportCount: (n: number) => Promise<void>;
1866
1901
  setStage: (stage: string | null) => Promise<void>;
@@ -2272,4 +2307,4 @@ declare function toGranularHttpBase(apiUrl: string): string;
2272
2307
  declare function buildOpenAISpendEventId(usage: Pick<OpenAIUsageSpendEvent, "requestId">, context?: GranularSpendContext): string | undefined;
2273
2308
  declare function recordOpenAIUsageSpend(options: RecordOpenAIUsageSpendOptions): Promise<RecordOpenAIUsageSpendResult>;
2274
2309
 
2275
- export { type QuotaLineItemFilter as $, type AccessTokenProvider as A, type RecordUserOptions as B, type ConditionIR as C, type DomainState as D, type EndpointMode as E, type Subject as F, type GranularSpendContext as G, type OpenEnvironmentOptions as H, type InstanceToolHandler as I, type ConnectOptions as J, type CreateSessionOptions as K, type ConversationSessionInfo as L, type ManifestEffectMetamodelSpec as M, type NormalizedOpenAIUsage as N, type OpenAIModelPricing as O, type Prompt as P, type ConversationSessionListStatus as Q, type ResolvedEffectBehaviors as R, type SessionHeapEntry as S, type ToolWithHandler as T, type User as U, type ConversationSessionListOptions as V, type SpendLineItemType as W, type QuotaScopeType as X, type QuotaPeriod as Y, type QuotaStatus as Z, type SpendSummary as _, type EffectHandlerContext as a, type SessionFileSource as a$, type GranularQuotaPolicy as a0, type GranularQuotaProgress as a1, type Sandbox as a2, type CreateSandboxData as a3, type SandboxListResponse as a4, type PermissionRules as a5, type PermissionProfile as a6, type CreatePermissionProfileData as a7, type PermissionProfileListResponse as a8, type Assignment as a9, type EffectInfo as aA, type ToolsChangedEvent as aB, type EffectsChangedEvent as aC, type EffectHandler as aD, type InstanceEffectHandler as aE, type JobStatus as aF, type JobFeedbackSentiment as aG, type JobFeedbackToolCall as aH, type JobFeedbackMetadata as aI, type JobFeedbackInput as aJ, type JobFeedbackRecord as aK, type EnvironmentFeedbackRecord as aL, type JobSubmitResult as aM, type Job as aN, type ConversationMessageShowRefs as aO, type ConversationTableCell as aP, type ConversationTableColumn as aQ, type ConversationTableRowReference as aR, type ConversationTableRow as aS, type ConversationTableProjection as aT, type ConversationActionSuggestion as aU, type ConversationMessageAction as aV, type ConversationMessagePart as aW, type ConversationMessageInput as aX, type ConversationAppendResult as aY, type SessionConversationMessage as aZ, type SessionTimelineEvent as a_, type AssignmentListResponse as aa, type BuildPolicy as ab, type VersionTracking as ac, type VersionTag as ad, type EnvironmentData as ae, type CreateEnvironmentData as af, type EnvironmentListResponse as ag, type Manifest as ah, type ManifestListResponse as ai, type BuildStatus as aj, type Build as ak, type Version as al, type BuildListResponse as am, type SemanticVersionDiffEntry as an, type SemanticVersionDiff as ao, type ResolvedEffectPostCondition as ap, type ResolvedEffectDryRun as aq, type ResolvedEffectReverse as ar, type ResolvedEffectApprovalRequired as as, type EffectInvocationMode as at, type EffectInvocationMetadata as au, type EffectSchema as av, type EffectWithHandler as aw, type PublishEffectsResult as ax, type EffectVersionSelector as ay, type ToolInfo as az, type SessionHeapList as b, type EnvironmentStateProxy as b$, type SessionFileKind as b0, type SessionFileStatus as b1, type SessionFileRecord as b2, type SessionArtifactStatus as b3, type SessionArtifactKind as b4, type SessionArtifactAutonomyPolicy as b5, type SessionArtifactRecord as b6, type SessionArtifactListOptions as b7, type SessionArtifactValidationResult as b8, type SessionArtifactExecutionResult as b9, type SessionCollectionListOptions as bA, type SessionJobListOptions as bB, type SessionCollectionListResult as bC, type UserEnvironmentPrompt as bD, type UserEnvironmentMessagePreview as bE, type UserEnvironmentSessionState as bF, type UserEnvironmentState as bG, type UserEnvironmentStateOptions as bH, type MarkUserEnvironmentReadOptions as bI, type WSDisconnectInfo as bJ, type WSReconnectErrorInfo as bK, type WSClientOptions as bL, type RPCRequest as bM, type RPCResponse as bN, type SyncMessage as bO, type RPCRequestFromServer as bP, type ToolInvokeParams as bQ, type ToolResultParams as bR, type ModelRef as bS, type RelationshipInfo as bT, type DefineRelationshipOptions as bU, type RecordObjectOptions as bV, type RecordObjectStateValue as bW, type EnvironmentStateTarget as bX, type EnvironmentStateObservationInput as bY, type EnvironmentStateUpdateInput as bZ, type EnvironmentStateMachineProxy as b_, type SessionArtifactExecutionOptions as ba, type SessionArtifactApprovalOptions as bb, type ArtifactApprovalTaskStatus as bc, type ArtifactApprovalTask as bd, type ArtifactApprovalTaskListOptions as be, type ArtifactApprovalDecisionInput as bf, type ArtifactApprovalDecisionResult as bg, type ManualActionStatus as bh, type ManualActionSource as bi, type ManualActionTarget as bj, type ManualActionRelatedRecord as bk, type RecordManualActionInput as bl, type ManualActionOccurrence as bm, type ManualActionRecordResult as bn, type ManualActionListOptions as bo, type ManualActionSuggestion as bp, type ManualActionSuggestionOptions as bq, type SessionFileUploadOptions as br, type SessionJobRecord as bs, type SessionHeapFieldType as bt, type SessionHeapFieldValue as bu, type SessionHeapVariable as bv, type RecordSearchResult as bw, type RecordSearchOptions as bx, type RecordMentionInput as by, type SessionDocumentResult as bz, type SessionHeapSnapshot as c, type RecordObjectResult as c0, type RecordObjectsChunkInfo as c1, type RecordObjectsOptions as c2, type RecordImportWriteMode as c3, type RecordImportOptions as c4, type RecordImportStatus as c5, type RecordImportItemStatus as c6, type RecordImportStats as c7, type RecordImportItem as c8, type RecordImport as c9, type ManifestCreatesSpec as cA, type ManifestRelationshipDef as cB, type ManifestEffectSchema as cC, type ManifestEffectDeclaration as cD, type ManifestEventTypeDef as cE, type ManifestEventStreamDef as cF, type ManifestOperation as cG, type ManifestImport as cH, type ManifestVolume as cI, type ManifestContent as cJ, type GraphQLResult as cK, type APIError as cL, type DeleteResponse as cM, type StreamEvent as cN, type StreamSubscription as cO, type StreamStats as cP, type EnvironmentRecordImportSummary as ca, type EnvironmentSetupTriggerReason as cb, type RunEnvironmentImporterOptions as cc, type EnvironmentSetupLifecycleStatus as cd, type EnvironmentSetupSummary as ce, type EnvironmentImporterImportOptions as cf, type EnvironmentImporter as cg, type ManifestPropertySpec as ch, type ManifestValidationOperator as ci, type ManifestEnumRuleSpec as cj, type ManifestFilterBySpec as ck, type ManifestValidationRuleSpec as cl, type ManifestStateMachineStateSpec as cm, type ManifestStateTransitionInputBinding as cn, type ManifestStateTransitionActionSpec as co, type ManifestStateTransitionAssigneeSpec as cp, type ManifestStateTransitionRelatedStateRequirementSpec as cq, type ManifestStateTransitionRequirementsSpec as cr, type ManifestStateTransitionPermissionSpec as cs, type ManifestStateTransitionExpectedOutcomeSpec as ct, type ManifestStateMachineTransitionSpec as cu, type ManifestStateMachineSpec as cv, type ManifestPostConditionSpec as cw, type ManifestDryRunSpec as cx, type ManifestReverseSpec as cy, type ManifestApprovalRequiredSpec as cz, type SessionTranscriptEntry as d, type ToolSchema as e, type PublishToolsResult as f, type ToolHandler as g, type OpenAITokenSpend as h, OPENAI_MODEL_PRICING_USD_PER_MILLION as i, getOpenAIModelPricing as j, calculateOpenAITokenSpend as k, type OpenAIUsageSpendEvent as l, type RecordOpenAIUsageSpendOptions as m, normalizeOpenAIUsage as n, type RecordOpenAIUsageSpendResult as o, buildOpenAISpendEventId as p, type PolicySource as q, recordOpenAIUsageSpend as r, type PolicyPredicateSource as s, toGranularHttpBase as t, type PolicyOperator as u, type PolicyOrigin as v, type PolicyRuleIR as w, type MatchedPolicy as x, type GranularOptions as y, type GranularAuth as z };
2310
+ export { type SpendSummary as $, type AccessTokenProvider as A, type RecordUserOptions as B, type ConditionIR as C, type DomainState as D, type EndpointMode as E, type Subject as F, type GranularSpendContext as G, type OpenEnvironmentOptions as H, type InstanceToolHandler as I, type AdoptEnvironmentOptions as J, type ConnectOptions as K, type CreateSessionOptions as L, type ManifestEffectMetamodelSpec as M, type NormalizedOpenAIUsage as N, type OpenAIModelPricing as O, type Prompt as P, type ConversationSessionInfo as Q, type ResolvedEffectBehaviors as R, type SessionHeapEntry as S, type ToolWithHandler as T, type User as U, type ConversationSessionListStatus as V, type ConversationSessionListOptions as W, type SpendLineItemType as X, type QuotaScopeType as Y, type QuotaPeriod as Z, type QuotaStatus as _, type EffectHandlerContext as a, type SessionTimelineEvent as a$, type QuotaLineItemFilter as a0, type GranularQuotaPolicy as a1, type GranularQuotaProgress as a2, type Sandbox as a3, type CreateSandboxData as a4, type SandboxListResponse as a5, type PermissionRules as a6, type PermissionProfile as a7, type CreatePermissionProfileData as a8, type PermissionProfileListResponse as a9, 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 ConversationTableCell as aQ, type ConversationTableColumn as aR, type ConversationTableRowReference as aS, type ConversationTableRow as aT, type ConversationTableProjection as aU, type ConversationActionSuggestion as aV, type ConversationMessageAction as aW, type ConversationMessagePart as aX, type ConversationMessageInput as aY, type ConversationAppendResult as aZ, type SessionConversationMessage as a_, type Assignment as aa, type AssignmentListResponse as ab, type BuildPolicy as ac, type VersionTracking as ad, type VersionTag as ae, type EnvironmentData as af, type CreateEnvironmentData as ag, type EnvironmentListResponse as ah, type Manifest as ai, type ManifestListResponse as aj, type BuildStatus as ak, type Build as al, type Version as am, type BuildListResponse as an, type SemanticVersionDiffEntry as ao, type SemanticVersionDiff as ap, type ResolvedEffectPostCondition as aq, type ResolvedEffectDryRun as ar, type ResolvedEffectReverse as as, type ResolvedEffectApprovalRequired as at, type EffectInvocationMode as au, type EffectInvocationMetadata as av, type EffectSchema as aw, type EffectWithHandler as ax, type PublishEffectsResult as ay, type EffectVersionSelector as az, type SessionHeapList as b, type EnvironmentStateMachineProxy as b$, type SessionFileSource as b0, type SessionFileKind as b1, type SessionFileStatus as b2, type SessionFileRecord as b3, type SessionArtifactStatus as b4, type SessionArtifactKind as b5, type SessionArtifactAutonomyPolicy as b6, type SessionArtifactRecord as b7, type SessionArtifactListOptions as b8, type SessionArtifactValidationResult as b9, type SessionDocumentResult as bA, type SessionCollectionListOptions as bB, type SessionJobListOptions as bC, type SessionCollectionListResult as bD, type UserEnvironmentPrompt as bE, type UserEnvironmentMessagePreview as bF, type UserEnvironmentSessionState as bG, type UserEnvironmentState as bH, type UserEnvironmentStateOptions as bI, type MarkUserEnvironmentReadOptions as bJ, type WSDisconnectInfo as bK, type WSReconnectErrorInfo as bL, type WSClientOptions as bM, type RPCRequest as bN, type RPCResponse as bO, type SyncMessage as bP, type RPCRequestFromServer as bQ, type ToolInvokeParams as bR, type ToolResultParams as bS, type ModelRef as bT, type RelationshipInfo as bU, type DefineRelationshipOptions as bV, type RecordObjectOptions as bW, type RecordObjectStateValue as bX, type EnvironmentStateTarget as bY, type EnvironmentStateObservationInput as bZ, type EnvironmentStateUpdateInput as b_, type SessionArtifactExecutionResult as ba, type SessionArtifactExecutionOptions as bb, type SessionArtifactApprovalOptions as bc, type ArtifactApprovalTaskStatus as bd, type ArtifactApprovalTask as be, type ArtifactApprovalTaskListOptions as bf, type ArtifactApprovalDecisionInput as bg, type ArtifactApprovalDecisionResult as bh, type ManualActionStatus as bi, type ManualActionSource as bj, type ManualActionTarget as bk, type ManualActionRelatedRecord as bl, type RecordManualActionInput as bm, type ManualActionOccurrence as bn, type ManualActionRecordResult as bo, type ManualActionListOptions as bp, type ManualActionSuggestion as bq, type ManualActionSuggestionOptions as br, type SessionFileUploadOptions as bs, type SessionJobRecord as bt, type SessionHeapFieldType as bu, type SessionHeapFieldValue as bv, type SessionHeapVariable as bw, type RecordSearchResult as bx, type RecordSearchOptions as by, type RecordMentionInput as bz, type SessionHeapSnapshot as c, type EnvironmentStateProxy as c0, type RecordObjectResult as c1, type RecordObjectsChunkInfo as c2, type RecordObjectsOptions as c3, type RecordImportWriteMode as c4, type RecordImportOptions as c5, type RecordImportStatus as c6, type RecordImportItemStatus as c7, type RecordImportStats as c8, type RecordImportItem as c9, type ManifestReverseSpec as cA, type ManifestApprovalRequiredSpec as cB, type ManifestCreatesSpec as cC, type ManifestRelationshipDef as cD, type ManifestEffectSchema as cE, type ManifestEffectDeclaration as cF, type ManifestEventTypeDef as cG, type ManifestEventStreamDef as cH, type ManifestOperation as cI, type ManifestImport as cJ, type ManifestVolume as cK, type ManifestContent as cL, type GraphQLResult as cM, type APIError as cN, type DeleteResponse as cO, type StreamEvent as cP, type StreamSubscription as cQ, type StreamStats as cR, type RecordImport as ca, type EnvironmentRecordImportSummary as cb, type EnvironmentSetupTriggerReason as cc, type RunEnvironmentImporterOptions as cd, type EnvironmentSetupLifecycleStatus as ce, type EnvironmentSetupSummary as cf, type EnvironmentSetupImporterClaim as cg, type EnvironmentImporterImportOptions as ch, type EnvironmentImporter as ci, type ManifestPropertySpec as cj, type ManifestValidationOperator as ck, type ManifestEnumRuleSpec as cl, type ManifestFilterBySpec as cm, type ManifestValidationRuleSpec as cn, type ManifestStateMachineStateSpec as co, type ManifestStateTransitionInputBinding as cp, type ManifestStateTransitionActionSpec as cq, type ManifestStateTransitionAssigneeSpec as cr, type ManifestStateTransitionRelatedStateRequirementSpec as cs, type ManifestStateTransitionRequirementsSpec as ct, type ManifestStateTransitionPermissionSpec as cu, type ManifestStateTransitionExpectedOutcomeSpec as cv, type ManifestStateMachineTransitionSpec as cw, type ManifestStateMachineSpec as cx, type ManifestPostConditionSpec as cy, type ManifestDryRunSpec as cz, type SessionTranscriptEntry as d, type ToolSchema as e, type PublishToolsResult as f, type ToolHandler as g, type OpenAITokenSpend as h, OPENAI_MODEL_PRICING_USD_PER_MILLION as i, getOpenAIModelPricing as j, calculateOpenAITokenSpend as k, type OpenAIUsageSpendEvent as l, type RecordOpenAIUsageSpendOptions as m, normalizeOpenAIUsage as n, type RecordOpenAIUsageSpendResult as o, buildOpenAISpendEventId as p, type PolicySource as q, recordOpenAIUsageSpend as r, type PolicyPredicateSource as s, toGranularHttpBase as t, type PolicyOperator as u, type PolicyOrigin as v, type PolicyRuleIR as w, type MatchedPolicy as x, type GranularOptions as y, type GranularAuth as z };
@@ -224,9 +224,28 @@ interface OpenEnvironmentOptions {
224
224
  * the newest tag target instead of reusing the outdated one.
225
225
  */
226
226
  createFreshIfOutdated?: boolean;
227
+ /**
228
+ * Create a fresh environment on the current tag target. Reusing this key is
229
+ * safe: it returns the environment created by the original operation.
230
+ */
231
+ resetKey?: string;
232
+ /** Canonical active-environment slot. Defaults to `default`. */
233
+ slot?: string;
227
234
  /** Backwards-compatible user object returned from `recordUser()`. */
228
235
  user?: User;
229
236
  }
237
+ /**
238
+ * One-time administrative migration of a known existing environment into
239
+ * Granular's active-environment map. The environment id must be obtained from
240
+ * a reviewed baseline; this API intentionally has no name-based lookup.
241
+ */
242
+ interface AdoptEnvironmentOptions {
243
+ sandboxId: string;
244
+ tag: string;
245
+ userId: string;
246
+ environmentId: string;
247
+ slot?: string;
248
+ }
230
249
  /**
231
250
  * Deprecated compatibility alias for the legacy `connect()` entry point.
232
251
  *
@@ -1768,6 +1787,8 @@ type RecordImportWriteMode = "adaptive" | "batched" | "per_record" | "parallel_5
1768
1787
  interface RecordImportOptions {
1769
1788
  batchSize?: number;
1770
1789
  setupRunId?: string;
1790
+ /** Stable key for retrying one logical durable import exactly once. */
1791
+ operationKey?: string;
1771
1792
  writeMode?: RecordImportWriteMode;
1772
1793
  }
1773
1794
  type RecordImportStatus = "queued" | "processing" | "completed" | "failed" | "canceled";
@@ -1807,6 +1828,7 @@ interface RecordImport {
1807
1828
  sandboxId: string;
1808
1829
  subjectId: string;
1809
1830
  setupRunId?: string | null;
1831
+ operationKey?: string | null;
1810
1832
  status: RecordImportStatus;
1811
1833
  batchSize: number;
1812
1834
  errorMessage: string | null;
@@ -1823,7 +1845,7 @@ interface EnvironmentRecordImportSummary extends RecordImportStats {
1823
1845
  activeImports: number;
1824
1846
  updatedAt: number;
1825
1847
  }
1826
- type EnvironmentSetupTriggerReason = "new_environment" | "fresh_after_version_update";
1848
+ type EnvironmentSetupTriggerReason = "new_environment" | "fresh_after_version_update" | "explicit_reset";
1827
1849
  interface RunEnvironmentImporterOptions {
1828
1850
  /**
1829
1851
  * Ontology name/id used to resolve the registered importer. Defaults to the
@@ -1834,6 +1856,8 @@ interface RunEnvironmentImporterOptions {
1834
1856
  * Reason recorded on the setup run. Defaults to `new_environment`.
1835
1857
  */
1836
1858
  reason?: EnvironmentSetupTriggerReason;
1859
+ /** Stable caller operation key. Use for explicit reset retries. */
1860
+ operationKey?: string;
1837
1861
  }
1838
1862
  type EnvironmentSetupLifecycleStatus = "running" | "completed" | "failed";
1839
1863
  interface EnvironmentSetupSummary extends RecordImportStats {
@@ -1842,6 +1866,7 @@ interface EnvironmentSetupSummary extends RecordImportStats {
1842
1866
  sandboxId: string;
1843
1867
  subjectId: string;
1844
1868
  triggerReason: EnvironmentSetupTriggerReason;
1869
+ operationKey?: string | null;
1845
1870
  lifecycleStatus: EnvironmentSetupLifecycleStatus;
1846
1871
  stage: string | null;
1847
1872
  totalObjectsToImport: number;
@@ -1852,6 +1877,14 @@ interface EnvironmentSetupSummary extends RecordImportStats {
1852
1877
  hookCompletedAt: number | null;
1853
1878
  finishedAt: number | null;
1854
1879
  updatedAt: number;
1880
+ /** `false` when an idempotent setup operation already exists. */
1881
+ created?: boolean;
1882
+ }
1883
+ /** Result of claiming the importer portion of a durable setup run. */
1884
+ interface EnvironmentSetupImporterClaim {
1885
+ action: "run" | "submitted" | "busy" | "terminal";
1886
+ summary: EnvironmentSetupSummary;
1887
+ retryAfterMs?: number;
1855
1888
  }
1856
1889
  interface EnvironmentImporterImportOptions {
1857
1890
  batchSize?: number;
@@ -1861,6 +1894,8 @@ interface EnvironmentImporter {
1861
1894
  environmentId: string;
1862
1895
  sandboxId: string;
1863
1896
  subjectId: string;
1897
+ /** Application identity originally supplied as `openEnvironment({ userId })`. */
1898
+ externalUserId: string;
1864
1899
  reason: EnvironmentSetupTriggerReason;
1865
1900
  incrementTotalObjectsToImportCount: (n: number) => Promise<void>;
1866
1901
  setStage: (stage: string | null) => Promise<void>;
@@ -2272,4 +2307,4 @@ declare function toGranularHttpBase(apiUrl: string): string;
2272
2307
  declare function buildOpenAISpendEventId(usage: Pick<OpenAIUsageSpendEvent, "requestId">, context?: GranularSpendContext): string | undefined;
2273
2308
  declare function recordOpenAIUsageSpend(options: RecordOpenAIUsageSpendOptions): Promise<RecordOpenAIUsageSpendResult>;
2274
2309
 
2275
- export { type QuotaLineItemFilter as $, type AccessTokenProvider as A, type RecordUserOptions as B, type ConditionIR as C, type DomainState as D, type EndpointMode as E, type Subject as F, type GranularSpendContext as G, type OpenEnvironmentOptions as H, type InstanceToolHandler as I, type ConnectOptions as J, type CreateSessionOptions as K, type ConversationSessionInfo as L, type ManifestEffectMetamodelSpec as M, type NormalizedOpenAIUsage as N, type OpenAIModelPricing as O, type Prompt as P, type ConversationSessionListStatus as Q, type ResolvedEffectBehaviors as R, type SessionHeapEntry as S, type ToolWithHandler as T, type User as U, type ConversationSessionListOptions as V, type SpendLineItemType as W, type QuotaScopeType as X, type QuotaPeriod as Y, type QuotaStatus as Z, type SpendSummary as _, type EffectHandlerContext as a, type SessionFileSource as a$, type GranularQuotaPolicy as a0, type GranularQuotaProgress as a1, type Sandbox as a2, type CreateSandboxData as a3, type SandboxListResponse as a4, type PermissionRules as a5, type PermissionProfile as a6, type CreatePermissionProfileData as a7, type PermissionProfileListResponse as a8, type Assignment as a9, type EffectInfo as aA, type ToolsChangedEvent as aB, type EffectsChangedEvent as aC, type EffectHandler as aD, type InstanceEffectHandler as aE, type JobStatus as aF, type JobFeedbackSentiment as aG, type JobFeedbackToolCall as aH, type JobFeedbackMetadata as aI, type JobFeedbackInput as aJ, type JobFeedbackRecord as aK, type EnvironmentFeedbackRecord as aL, type JobSubmitResult as aM, type Job as aN, type ConversationMessageShowRefs as aO, type ConversationTableCell as aP, type ConversationTableColumn as aQ, type ConversationTableRowReference as aR, type ConversationTableRow as aS, type ConversationTableProjection as aT, type ConversationActionSuggestion as aU, type ConversationMessageAction as aV, type ConversationMessagePart as aW, type ConversationMessageInput as aX, type ConversationAppendResult as aY, type SessionConversationMessage as aZ, type SessionTimelineEvent as a_, type AssignmentListResponse as aa, type BuildPolicy as ab, type VersionTracking as ac, type VersionTag as ad, type EnvironmentData as ae, type CreateEnvironmentData as af, type EnvironmentListResponse as ag, type Manifest as ah, type ManifestListResponse as ai, type BuildStatus as aj, type Build as ak, type Version as al, type BuildListResponse as am, type SemanticVersionDiffEntry as an, type SemanticVersionDiff as ao, type ResolvedEffectPostCondition as ap, type ResolvedEffectDryRun as aq, type ResolvedEffectReverse as ar, type ResolvedEffectApprovalRequired as as, type EffectInvocationMode as at, type EffectInvocationMetadata as au, type EffectSchema as av, type EffectWithHandler as aw, type PublishEffectsResult as ax, type EffectVersionSelector as ay, type ToolInfo as az, type SessionHeapList as b, type EnvironmentStateProxy as b$, type SessionFileKind as b0, type SessionFileStatus as b1, type SessionFileRecord as b2, type SessionArtifactStatus as b3, type SessionArtifactKind as b4, type SessionArtifactAutonomyPolicy as b5, type SessionArtifactRecord as b6, type SessionArtifactListOptions as b7, type SessionArtifactValidationResult as b8, type SessionArtifactExecutionResult as b9, type SessionCollectionListOptions as bA, type SessionJobListOptions as bB, type SessionCollectionListResult as bC, type UserEnvironmentPrompt as bD, type UserEnvironmentMessagePreview as bE, type UserEnvironmentSessionState as bF, type UserEnvironmentState as bG, type UserEnvironmentStateOptions as bH, type MarkUserEnvironmentReadOptions as bI, type WSDisconnectInfo as bJ, type WSReconnectErrorInfo as bK, type WSClientOptions as bL, type RPCRequest as bM, type RPCResponse as bN, type SyncMessage as bO, type RPCRequestFromServer as bP, type ToolInvokeParams as bQ, type ToolResultParams as bR, type ModelRef as bS, type RelationshipInfo as bT, type DefineRelationshipOptions as bU, type RecordObjectOptions as bV, type RecordObjectStateValue as bW, type EnvironmentStateTarget as bX, type EnvironmentStateObservationInput as bY, type EnvironmentStateUpdateInput as bZ, type EnvironmentStateMachineProxy as b_, type SessionArtifactExecutionOptions as ba, type SessionArtifactApprovalOptions as bb, type ArtifactApprovalTaskStatus as bc, type ArtifactApprovalTask as bd, type ArtifactApprovalTaskListOptions as be, type ArtifactApprovalDecisionInput as bf, type ArtifactApprovalDecisionResult as bg, type ManualActionStatus as bh, type ManualActionSource as bi, type ManualActionTarget as bj, type ManualActionRelatedRecord as bk, type RecordManualActionInput as bl, type ManualActionOccurrence as bm, type ManualActionRecordResult as bn, type ManualActionListOptions as bo, type ManualActionSuggestion as bp, type ManualActionSuggestionOptions as bq, type SessionFileUploadOptions as br, type SessionJobRecord as bs, type SessionHeapFieldType as bt, type SessionHeapFieldValue as bu, type SessionHeapVariable as bv, type RecordSearchResult as bw, type RecordSearchOptions as bx, type RecordMentionInput as by, type SessionDocumentResult as bz, type SessionHeapSnapshot as c, type RecordObjectResult as c0, type RecordObjectsChunkInfo as c1, type RecordObjectsOptions as c2, type RecordImportWriteMode as c3, type RecordImportOptions as c4, type RecordImportStatus as c5, type RecordImportItemStatus as c6, type RecordImportStats as c7, type RecordImportItem as c8, type RecordImport as c9, type ManifestCreatesSpec as cA, type ManifestRelationshipDef as cB, type ManifestEffectSchema as cC, type ManifestEffectDeclaration as cD, type ManifestEventTypeDef as cE, type ManifestEventStreamDef as cF, type ManifestOperation as cG, type ManifestImport as cH, type ManifestVolume as cI, type ManifestContent as cJ, type GraphQLResult as cK, type APIError as cL, type DeleteResponse as cM, type StreamEvent as cN, type StreamSubscription as cO, type StreamStats as cP, type EnvironmentRecordImportSummary as ca, type EnvironmentSetupTriggerReason as cb, type RunEnvironmentImporterOptions as cc, type EnvironmentSetupLifecycleStatus as cd, type EnvironmentSetupSummary as ce, type EnvironmentImporterImportOptions as cf, type EnvironmentImporter as cg, type ManifestPropertySpec as ch, type ManifestValidationOperator as ci, type ManifestEnumRuleSpec as cj, type ManifestFilterBySpec as ck, type ManifestValidationRuleSpec as cl, type ManifestStateMachineStateSpec as cm, type ManifestStateTransitionInputBinding as cn, type ManifestStateTransitionActionSpec as co, type ManifestStateTransitionAssigneeSpec as cp, type ManifestStateTransitionRelatedStateRequirementSpec as cq, type ManifestStateTransitionRequirementsSpec as cr, type ManifestStateTransitionPermissionSpec as cs, type ManifestStateTransitionExpectedOutcomeSpec as ct, type ManifestStateMachineTransitionSpec as cu, type ManifestStateMachineSpec as cv, type ManifestPostConditionSpec as cw, type ManifestDryRunSpec as cx, type ManifestReverseSpec as cy, type ManifestApprovalRequiredSpec as cz, type SessionTranscriptEntry as d, type ToolSchema as e, type PublishToolsResult as f, type ToolHandler as g, type OpenAITokenSpend as h, OPENAI_MODEL_PRICING_USD_PER_MILLION as i, getOpenAIModelPricing as j, calculateOpenAITokenSpend as k, type OpenAIUsageSpendEvent as l, type RecordOpenAIUsageSpendOptions as m, normalizeOpenAIUsage as n, type RecordOpenAIUsageSpendResult as o, buildOpenAISpendEventId as p, type PolicySource as q, recordOpenAIUsageSpend as r, type PolicyPredicateSource as s, toGranularHttpBase as t, type PolicyOperator as u, type PolicyOrigin as v, type PolicyRuleIR as w, type MatchedPolicy as x, type GranularOptions as y, type GranularAuth as z };
2310
+ export { type SpendSummary as $, type AccessTokenProvider as A, type RecordUserOptions as B, type ConditionIR as C, type DomainState as D, type EndpointMode as E, type Subject as F, type GranularSpendContext as G, type OpenEnvironmentOptions as H, type InstanceToolHandler as I, type AdoptEnvironmentOptions as J, type ConnectOptions as K, type CreateSessionOptions as L, type ManifestEffectMetamodelSpec as M, type NormalizedOpenAIUsage as N, type OpenAIModelPricing as O, type Prompt as P, type ConversationSessionInfo as Q, type ResolvedEffectBehaviors as R, type SessionHeapEntry as S, type ToolWithHandler as T, type User as U, type ConversationSessionListStatus as V, type ConversationSessionListOptions as W, type SpendLineItemType as X, type QuotaScopeType as Y, type QuotaPeriod as Z, type QuotaStatus as _, type EffectHandlerContext as a, type SessionTimelineEvent as a$, type QuotaLineItemFilter as a0, type GranularQuotaPolicy as a1, type GranularQuotaProgress as a2, type Sandbox as a3, type CreateSandboxData as a4, type SandboxListResponse as a5, type PermissionRules as a6, type PermissionProfile as a7, type CreatePermissionProfileData as a8, type PermissionProfileListResponse as a9, 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 ConversationTableCell as aQ, type ConversationTableColumn as aR, type ConversationTableRowReference as aS, type ConversationTableRow as aT, type ConversationTableProjection as aU, type ConversationActionSuggestion as aV, type ConversationMessageAction as aW, type ConversationMessagePart as aX, type ConversationMessageInput as aY, type ConversationAppendResult as aZ, type SessionConversationMessage as a_, type Assignment as aa, type AssignmentListResponse as ab, type BuildPolicy as ac, type VersionTracking as ad, type VersionTag as ae, type EnvironmentData as af, type CreateEnvironmentData as ag, type EnvironmentListResponse as ah, type Manifest as ai, type ManifestListResponse as aj, type BuildStatus as ak, type Build as al, type Version as am, type BuildListResponse as an, type SemanticVersionDiffEntry as ao, type SemanticVersionDiff as ap, type ResolvedEffectPostCondition as aq, type ResolvedEffectDryRun as ar, type ResolvedEffectReverse as as, type ResolvedEffectApprovalRequired as at, type EffectInvocationMode as au, type EffectInvocationMetadata as av, type EffectSchema as aw, type EffectWithHandler as ax, type PublishEffectsResult as ay, type EffectVersionSelector as az, type SessionHeapList as b, type EnvironmentStateMachineProxy as b$, type SessionFileSource as b0, type SessionFileKind as b1, type SessionFileStatus as b2, type SessionFileRecord as b3, type SessionArtifactStatus as b4, type SessionArtifactKind as b5, type SessionArtifactAutonomyPolicy as b6, type SessionArtifactRecord as b7, type SessionArtifactListOptions as b8, type SessionArtifactValidationResult as b9, type SessionDocumentResult as bA, type SessionCollectionListOptions as bB, type SessionJobListOptions as bC, type SessionCollectionListResult as bD, type UserEnvironmentPrompt as bE, type UserEnvironmentMessagePreview as bF, type UserEnvironmentSessionState as bG, type UserEnvironmentState as bH, type UserEnvironmentStateOptions as bI, type MarkUserEnvironmentReadOptions as bJ, type WSDisconnectInfo as bK, type WSReconnectErrorInfo as bL, type WSClientOptions as bM, type RPCRequest as bN, type RPCResponse as bO, type SyncMessage as bP, type RPCRequestFromServer as bQ, type ToolInvokeParams as bR, type ToolResultParams as bS, type ModelRef as bT, type RelationshipInfo as bU, type DefineRelationshipOptions as bV, type RecordObjectOptions as bW, type RecordObjectStateValue as bX, type EnvironmentStateTarget as bY, type EnvironmentStateObservationInput as bZ, type EnvironmentStateUpdateInput as b_, type SessionArtifactExecutionResult as ba, type SessionArtifactExecutionOptions as bb, type SessionArtifactApprovalOptions as bc, type ArtifactApprovalTaskStatus as bd, type ArtifactApprovalTask as be, type ArtifactApprovalTaskListOptions as bf, type ArtifactApprovalDecisionInput as bg, type ArtifactApprovalDecisionResult as bh, type ManualActionStatus as bi, type ManualActionSource as bj, type ManualActionTarget as bk, type ManualActionRelatedRecord as bl, type RecordManualActionInput as bm, type ManualActionOccurrence as bn, type ManualActionRecordResult as bo, type ManualActionListOptions as bp, type ManualActionSuggestion as bq, type ManualActionSuggestionOptions as br, type SessionFileUploadOptions as bs, type SessionJobRecord as bt, type SessionHeapFieldType as bu, type SessionHeapFieldValue as bv, type SessionHeapVariable as bw, type RecordSearchResult as bx, type RecordSearchOptions as by, type RecordMentionInput as bz, type SessionHeapSnapshot as c, type EnvironmentStateProxy as c0, type RecordObjectResult as c1, type RecordObjectsChunkInfo as c2, type RecordObjectsOptions as c3, type RecordImportWriteMode as c4, type RecordImportOptions as c5, type RecordImportStatus as c6, type RecordImportItemStatus as c7, type RecordImportStats as c8, type RecordImportItem as c9, type ManifestReverseSpec as cA, type ManifestApprovalRequiredSpec as cB, type ManifestCreatesSpec as cC, type ManifestRelationshipDef as cD, type ManifestEffectSchema as cE, type ManifestEffectDeclaration as cF, type ManifestEventTypeDef as cG, type ManifestEventStreamDef as cH, type ManifestOperation as cI, type ManifestImport as cJ, type ManifestVolume as cK, type ManifestContent as cL, type GraphQLResult as cM, type APIError as cN, type DeleteResponse as cO, type StreamEvent as cP, type StreamSubscription as cQ, type StreamStats as cR, type RecordImport as ca, type EnvironmentRecordImportSummary as cb, type EnvironmentSetupTriggerReason as cc, type RunEnvironmentImporterOptions as cd, type EnvironmentSetupLifecycleStatus as ce, type EnvironmentSetupSummary as cf, type EnvironmentSetupImporterClaim as cg, type EnvironmentImporterImportOptions as ch, type EnvironmentImporter as ci, type ManifestPropertySpec as cj, type ManifestValidationOperator as ck, type ManifestEnumRuleSpec as cl, type ManifestFilterBySpec as cm, type ManifestValidationRuleSpec as cn, type ManifestStateMachineStateSpec as co, type ManifestStateTransitionInputBinding as cp, type ManifestStateTransitionActionSpec as cq, type ManifestStateTransitionAssigneeSpec as cr, type ManifestStateTransitionRelatedStateRequirementSpec as cs, type ManifestStateTransitionRequirementsSpec as ct, type ManifestStateTransitionPermissionSpec as cu, type ManifestStateTransitionExpectedOutcomeSpec as cv, type ManifestStateMachineTransitionSpec as cw, type ManifestStateMachineSpec as cx, type ManifestPostConditionSpec as cy, type ManifestDryRunSpec as cz, type SessionTranscriptEntry as d, type ToolSchema as e, type PublishToolsResult as f, type ToolHandler as g, type OpenAITokenSpend as h, OPENAI_MODEL_PRICING_USD_PER_MILLION as i, getOpenAIModelPricing as j, calculateOpenAITokenSpend as k, type OpenAIUsageSpendEvent as l, type RecordOpenAIUsageSpendOptions as m, normalizeOpenAIUsage as n, type RecordOpenAIUsageSpendResult as o, buildOpenAISpendEventId as p, type PolicySource as q, recordOpenAIUsageSpend as r, type PolicyPredicateSource as s, toGranularHttpBase as t, type PolicyOperator as u, type PolicyOrigin as v, type PolicyRuleIR as w, type MatchedPolicy as x, type GranularOptions as y, type GranularAuth as z };
package/dist/spend.d.mts CHANGED
@@ -1 +1 @@
1
- export { G as GranularSpendContext, l as OpenAIUsageSpendEvent, m as RecordOpenAIUsageSpendOptions, o as RecordOpenAIUsageSpendResult, p as buildOpenAISpendEventId, r as recordOpenAIUsageSpend, t as toGranularHttpBase } from './spend-BA-jZwZ0.mjs';
1
+ export { G as GranularSpendContext, l as OpenAIUsageSpendEvent, m as RecordOpenAIUsageSpendOptions, o as RecordOpenAIUsageSpendResult, p as buildOpenAISpendEventId, r as recordOpenAIUsageSpend, t as toGranularHttpBase } from './spend-DpRRCrAr.mjs';
package/dist/spend.d.ts CHANGED
@@ -1 +1 @@
1
- export { G as GranularSpendContext, l as OpenAIUsageSpendEvent, m as RecordOpenAIUsageSpendOptions, o as RecordOpenAIUsageSpendResult, p as buildOpenAISpendEventId, r as recordOpenAIUsageSpend, t as toGranularHttpBase } from './spend-BA-jZwZ0.js';
1
+ export { G as GranularSpendContext, l as OpenAIUsageSpendEvent, m as RecordOpenAIUsageSpendOptions, o as RecordOpenAIUsageSpendResult, p as buildOpenAISpendEventId, r as recordOpenAIUsageSpend, t as toGranularHttpBase } from './spend-DpRRCrAr.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@granular-software/sdk",
3
- "version": "0.4.51",
3
+ "version": "0.4.52",
4
4
  "description": "TypeScript SDK and CLI for Granular - define, build, and deploy AI sandboxes",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",