@granular-software/sdk 0.4.14 → 0.4.15

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
@@ -122,6 +122,24 @@ interface ConnectOptions {
122
122
  id: string;
123
123
  }>;
124
124
  }
125
+ /**
126
+ * Control-plane session row: one real-time conversation thread with the agent for an environment.
127
+ */
128
+ interface ConversationSessionInfo {
129
+ sessionId: string;
130
+ tenantId?: string;
131
+ environmentId: string;
132
+ versionId?: string | null;
133
+ docId: string;
134
+ status: 'active' | 'closed' | 'expired';
135
+ createdAt: string;
136
+ lastSeenAt: string;
137
+ summary?: string | null;
138
+ summaryUpdatedAt?: string | null;
139
+ subjectId?: string | null;
140
+ jobCount?: number;
141
+ toolCallCount?: number;
142
+ }
125
143
  /**
126
144
  * A sandbox container
127
145
  */
@@ -1742,6 +1760,49 @@ declare class Granular {
1742
1760
  * ```
1743
1761
  */
1744
1762
  connect(options: ConnectOptions): Promise<Environment>;
1763
+ /**
1764
+ * List active (open) sessions for an environment — each session is one agent conversation thread.
1765
+ */
1766
+ listOpenSessions(filters: {
1767
+ environmentId: string;
1768
+ }): Promise<ConversationSessionInfo[]>;
1769
+ /**
1770
+ * List closed sessions for an environment (conversations that have disconnected).
1771
+ */
1772
+ listClosedSessions(filters: {
1773
+ environmentId: string;
1774
+ }): Promise<ConversationSessionInfo[]>;
1775
+ private listSessionsForEnvironment;
1776
+ private normalizeConversationSession;
1777
+ private static coerceIsoDate;
1778
+ /**
1779
+ * Create a new session (conversation) for an existing environment and connect to it.
1780
+ * The runtime graph is shared across all sessions for the same environment.
1781
+ */
1782
+ createSession(options: {
1783
+ environmentId: string;
1784
+ clientId?: string;
1785
+ initialHeap?: ConnectOptions['initialHeap'];
1786
+ }): Promise<Environment>;
1787
+ /**
1788
+ * Connect to an existing open session (same conversation thread) using a freshly minted WebSocket token.
1789
+ */
1790
+ connectSession(options: {
1791
+ sessionId: string;
1792
+ clientId?: string;
1793
+ }): Promise<Environment>;
1794
+ /**
1795
+ * Mark a session closed in the control plane. If `environment` is the connected handle for that
1796
+ * `sessionId`, disconnects the WebSocket so the runtime tears down cleanly.
1797
+ */
1798
+ closeSession(sessionId: string, environment?: Environment | null): Promise<void>;
1799
+ /**
1800
+ * Re-open a closed session in the index and connect to its existing runtime document.
1801
+ */
1802
+ reopenSession(sessionId: string, options?: {
1803
+ clientId?: string;
1804
+ }): Promise<Environment>;
1805
+ private bindWebSocketEnvironment;
1745
1806
  private activateEnvironment;
1746
1807
  private getSandboxEffectMap;
1747
1808
  private serializeEffect;
@@ -1859,4 +1920,4 @@ type EffectRuntimeRequest = {
1859
1920
  declare function normalizeEffectBehaviors(value?: ManifestEffectMetamodelSpec | ResolvedEffectBehaviors | null): ResolvedEffectBehaviors;
1860
1921
  declare function invokeRegisteredEffect(effectMap: Map<string, ToolWithHandler>, request: EffectRuntimeRequest): Promise<unknown>;
1861
1922
 
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 };
1923
+ export { type APIError, type AccessTokenProvider, type Assignment, type AssignmentListResponse, type Build, type BuildListResponse, type BuildPolicy, type BuildStatus, type ConnectOptions, type ConversationSessionInfo, 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
@@ -122,6 +122,24 @@ interface ConnectOptions {
122
122
  id: string;
123
123
  }>;
124
124
  }
125
+ /**
126
+ * Control-plane session row: one real-time conversation thread with the agent for an environment.
127
+ */
128
+ interface ConversationSessionInfo {
129
+ sessionId: string;
130
+ tenantId?: string;
131
+ environmentId: string;
132
+ versionId?: string | null;
133
+ docId: string;
134
+ status: 'active' | 'closed' | 'expired';
135
+ createdAt: string;
136
+ lastSeenAt: string;
137
+ summary?: string | null;
138
+ summaryUpdatedAt?: string | null;
139
+ subjectId?: string | null;
140
+ jobCount?: number;
141
+ toolCallCount?: number;
142
+ }
125
143
  /**
126
144
  * A sandbox container
127
145
  */
@@ -1742,6 +1760,49 @@ declare class Granular {
1742
1760
  * ```
1743
1761
  */
1744
1762
  connect(options: ConnectOptions): Promise<Environment>;
1763
+ /**
1764
+ * List active (open) sessions for an environment — each session is one agent conversation thread.
1765
+ */
1766
+ listOpenSessions(filters: {
1767
+ environmentId: string;
1768
+ }): Promise<ConversationSessionInfo[]>;
1769
+ /**
1770
+ * List closed sessions for an environment (conversations that have disconnected).
1771
+ */
1772
+ listClosedSessions(filters: {
1773
+ environmentId: string;
1774
+ }): Promise<ConversationSessionInfo[]>;
1775
+ private listSessionsForEnvironment;
1776
+ private normalizeConversationSession;
1777
+ private static coerceIsoDate;
1778
+ /**
1779
+ * Create a new session (conversation) for an existing environment and connect to it.
1780
+ * The runtime graph is shared across all sessions for the same environment.
1781
+ */
1782
+ createSession(options: {
1783
+ environmentId: string;
1784
+ clientId?: string;
1785
+ initialHeap?: ConnectOptions['initialHeap'];
1786
+ }): Promise<Environment>;
1787
+ /**
1788
+ * Connect to an existing open session (same conversation thread) using a freshly minted WebSocket token.
1789
+ */
1790
+ connectSession(options: {
1791
+ sessionId: string;
1792
+ clientId?: string;
1793
+ }): Promise<Environment>;
1794
+ /**
1795
+ * Mark a session closed in the control plane. If `environment` is the connected handle for that
1796
+ * `sessionId`, disconnects the WebSocket so the runtime tears down cleanly.
1797
+ */
1798
+ closeSession(sessionId: string, environment?: Environment | null): Promise<void>;
1799
+ /**
1800
+ * Re-open a closed session in the index and connect to its existing runtime document.
1801
+ */
1802
+ reopenSession(sessionId: string, options?: {
1803
+ clientId?: string;
1804
+ }): Promise<Environment>;
1805
+ private bindWebSocketEnvironment;
1745
1806
  private activateEnvironment;
1746
1807
  private getSandboxEffectMap;
1747
1808
  private serializeEffect;
@@ -1859,4 +1920,4 @@ type EffectRuntimeRequest = {
1859
1920
  declare function normalizeEffectBehaviors(value?: ManifestEffectMetamodelSpec | ResolvedEffectBehaviors | null): ResolvedEffectBehaviors;
1860
1921
  declare function invokeRegisteredEffect(effectMap: Map<string, ToolWithHandler>, request: EffectRuntimeRequest): Promise<unknown>;
1861
1922
 
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 };
1923
+ export { type APIError, type AccessTokenProvider, type Assignment, type AssignmentListResponse, type Build, type BuildListResponse, type BuildPolicy, type BuildStatus, type ConnectOptions, type ConversationSessionInfo, 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
@@ -5747,7 +5747,8 @@ var Environment = class extends Session {
5747
5747
  "Authorization": `Bearer ${this._apiKey}`
5748
5748
  },
5749
5749
  body: JSON.stringify({
5750
- reason: "sdk_disconnect_http_fallback"
5750
+ reason: "sdk_disconnect_http_fallback",
5751
+ sessionId: this.client.currentSessionId
5751
5752
  })
5752
5753
  }
5753
5754
  );
@@ -6531,7 +6532,7 @@ var Environment = class extends Session {
6531
6532
  return super.unpublishAllEffects();
6532
6533
  }
6533
6534
  };
6534
- var Granular = class {
6535
+ var Granular = class _Granular {
6535
6536
  apiKey;
6536
6537
  apiUrl;
6537
6538
  httpUrl;
@@ -6701,6 +6702,120 @@ var Granular = class {
6701
6702
  initialHeap: options.initialHeap
6702
6703
  })
6703
6704
  });
6705
+ return this.bindWebSocketEnvironment(envData, clientId, session);
6706
+ }
6707
+ /**
6708
+ * List active (open) sessions for an environment — each session is one agent conversation thread.
6709
+ */
6710
+ async listOpenSessions(filters) {
6711
+ return this.listSessionsForEnvironment(filters.environmentId, "active");
6712
+ }
6713
+ /**
6714
+ * List closed sessions for an environment (conversations that have disconnected).
6715
+ */
6716
+ async listClosedSessions(filters) {
6717
+ return this.listSessionsForEnvironment(filters.environmentId, "closed");
6718
+ }
6719
+ async listSessionsForEnvironment(environmentId, status) {
6720
+ const query = new URLSearchParams({ environmentId, status });
6721
+ const res = await this.request(
6722
+ `/control/sessions?${query.toString()}`
6723
+ );
6724
+ const items = Array.isArray(res.items) ? res.items : [];
6725
+ return items.map((row) => this.normalizeConversationSession(row));
6726
+ }
6727
+ normalizeConversationSession(row) {
6728
+ const sessionId = String(row.sessionId ?? row.session_id ?? "");
6729
+ const environmentId = String(row.environmentId ?? row.environment_id ?? "");
6730
+ return {
6731
+ sessionId,
6732
+ tenantId: row.tenantId != null ? String(row.tenantId) : void 0,
6733
+ environmentId,
6734
+ versionId: row.versionId != null ? String(row.versionId) : null,
6735
+ docId: String(row.docId ?? row.doc_id ?? ""),
6736
+ status: row.status || "active",
6737
+ createdAt: _Granular.coerceIsoDate(row.createdAt ?? row.created_at),
6738
+ lastSeenAt: _Granular.coerceIsoDate(row.lastSeenAt ?? row.last_seen_at),
6739
+ summary: row.summary != null ? String(row.summary) : null,
6740
+ summaryUpdatedAt: row.summaryUpdatedAt != null || row.summary_updated_at != null ? _Granular.coerceIsoDate(row.summaryUpdatedAt ?? row.summary_updated_at) : null,
6741
+ subjectId: row.subjectId != null ? String(row.subjectId) : null,
6742
+ jobCount: typeof row.jobCount === "number" ? row.jobCount : void 0,
6743
+ toolCallCount: typeof row.toolCallCount === "number" ? row.toolCallCount : void 0
6744
+ };
6745
+ }
6746
+ static coerceIsoDate(value) {
6747
+ if (value instanceof Date) {
6748
+ return value.toISOString();
6749
+ }
6750
+ if (typeof value === "number") {
6751
+ return new Date(value).toISOString();
6752
+ }
6753
+ if (typeof value === "string") {
6754
+ return value;
6755
+ }
6756
+ return (/* @__PURE__ */ new Date(0)).toISOString();
6757
+ }
6758
+ /**
6759
+ * Create a new session (conversation) for an existing environment and connect to it.
6760
+ * The runtime graph is shared across all sessions for the same environment.
6761
+ */
6762
+ async createSession(options) {
6763
+ const clientId = options.clientId || `client_${Date.now()}`;
6764
+ await this.activateEnvironment(options.environmentId);
6765
+ const envData = await this.environments.get(options.environmentId);
6766
+ const session = await this.request("/ws/sessions", {
6767
+ method: "POST",
6768
+ body: JSON.stringify({
6769
+ environmentId: options.environmentId,
6770
+ clientId,
6771
+ initialHeap: options.initialHeap
6772
+ })
6773
+ });
6774
+ return this.bindWebSocketEnvironment(envData, clientId, session);
6775
+ }
6776
+ /**
6777
+ * Connect to an existing open session (same conversation thread) using a freshly minted WebSocket token.
6778
+ */
6779
+ async connectSession(options) {
6780
+ const clientId = options.clientId || `client_${Date.now()}`;
6781
+ const minted = await this.request(`/ws/sessions/${encodeURIComponent(options.sessionId)}/token`, {
6782
+ method: "POST",
6783
+ body: JSON.stringify({})
6784
+ });
6785
+ const envData = await this.environments.get(minted.environmentId);
6786
+ return this.bindWebSocketEnvironment(envData, clientId, minted);
6787
+ }
6788
+ /**
6789
+ * Mark a session closed in the control plane. If `environment` is the connected handle for that
6790
+ * `sessionId`, disconnects the WebSocket so the runtime tears down cleanly.
6791
+ */
6792
+ async closeSession(sessionId, environment) {
6793
+ if (environment && environment.sessionId === sessionId) {
6794
+ await environment.disconnect();
6795
+ return;
6796
+ }
6797
+ await this.request(`/control/sessions/${encodeURIComponent(sessionId)}`, {
6798
+ method: "PATCH",
6799
+ body: JSON.stringify({
6800
+ status: "closed",
6801
+ lastSeenAt: (/* @__PURE__ */ new Date()).toISOString()
6802
+ })
6803
+ });
6804
+ }
6805
+ /**
6806
+ * Re-open a closed session in the index and connect to its existing runtime document.
6807
+ */
6808
+ async reopenSession(sessionId, options) {
6809
+ await this.request(`/control/sessions/${encodeURIComponent(sessionId)}`, {
6810
+ method: "PATCH",
6811
+ body: JSON.stringify({
6812
+ status: "active",
6813
+ lastSeenAt: (/* @__PURE__ */ new Date()).toISOString()
6814
+ })
6815
+ });
6816
+ return this.connectSession({ sessionId, clientId: options?.clientId });
6817
+ }
6818
+ async bindWebSocketEnvironment(envData, clientId, session) {
6704
6819
  const client = new WSClient({
6705
6820
  url: session.wsUrl,
6706
6821
  sessionId: session.sessionId,