@tensorlakeai/tensorlake 0.5.159 → 0.5.161

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.
Files changed (29) hide show
  1. package/dist/applications/index.cjs +7 -2
  2. package/dist/applications/index.cjs.map +1 -1
  3. package/dist/applications/index.js +7 -2
  4. package/dist/applications/index.js.map +1 -1
  5. package/dist/function-agent/main.cjs +1 -1
  6. package/dist/function-agent/main.cjs.map +1 -1
  7. package/dist/function-agent/main.js +1 -1
  8. package/dist/function-agent/main.js.map +1 -1
  9. package/dist/function-executor/main.cjs +2 -2
  10. package/dist/function-executor/main.cjs.map +1 -1
  11. package/dist/function-executor/main.js +2 -2
  12. package/dist/function-executor/main.js.map +1 -1
  13. package/dist/index.cjs +66 -2
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +145 -1
  16. package/dist/index.d.ts +145 -1
  17. package/dist/index.js +65 -2
  18. package/dist/index.js.map +1 -1
  19. package/package.json +7 -7
  20. package/runtime/function-executor/manifest.json +7 -7
  21. package/runtime/function-executor/package/dist/function-executor/main.js +2 -2
  22. package/runtime/function-executor/package/dist/function-executor/main.js.map +1 -1
  23. package/runtime/function-executor/package/npm-shrinkwrap.json +2 -2
  24. package/runtime/function-executor/package/package.json +1 -1
  25. package/runtime/typescript-function-runner/manifest.json +7 -7
  26. package/runtime/typescript-function-runner/package/dist/function-agent/main.js +1 -1
  27. package/runtime/typescript-function-runner/package/dist/function-agent/main.js.map +1 -1
  28. package/runtime/typescript-function-runner/package/npm-shrinkwrap.json +26 -26
  29. package/runtime/typescript-function-runner/package/package.json +7 -7
package/dist/index.d.cts CHANGED
@@ -2078,6 +2078,150 @@ declare class RepositoryClient {
2078
2078
  private tracedJson;
2079
2079
  }
2080
2080
 
2081
+ /** How far back to read instead of the current billing period. */
2082
+ type UsageLookback = "1d" | "7d" | "30d";
2083
+ interface UsageClientOptions {
2084
+ /** Tensorlake API key. Defaults to `TENSORLAKE_API_KEY`. */
2085
+ apiKey?: string;
2086
+ /** Organization to read. Defaults to `TENSORLAKE_ORGANIZATION_ID`. */
2087
+ organizationId?: string;
2088
+ /** Cloud API URL. Defaults to `TENSORLAKE_API_URL`. */
2089
+ apiUrl?: string;
2090
+ }
2091
+ interface UsageReadOptions {
2092
+ /** Read the last `1d`, `7d` or `30d` instead of the current billing period. */
2093
+ last?: UsageLookback;
2094
+ /**
2095
+ * Range start, as a `Date` or an RFC 3339 string. Can't be combined with
2096
+ * `last`. The server serves ranges that start inside the current billing
2097
+ * period or the last 30 days, whichever starts earlier.
2098
+ */
2099
+ fromDate?: Date | string;
2100
+ /** Range end. Requires `fromDate`; defaults to now. */
2101
+ toDate?: Date | string;
2102
+ }
2103
+ /** Metered usage, excluding subscription fees and tax. */
2104
+ interface UsageCharge {
2105
+ currency: string;
2106
+ amountMinor: string;
2107
+ resources: {
2108
+ cpuAmountMinor: string;
2109
+ memoryAmountMinor: string;
2110
+ sandboxStorageAmountMinor: string;
2111
+ snapshotStorageAmountMinor: string;
2112
+ };
2113
+ }
2114
+ /** Plan allowance consumption, valued at the overage rate. */
2115
+ interface IncludedUsage {
2116
+ currency: string;
2117
+ includedAmountMinor: string;
2118
+ periodUsedAmountMinor: string;
2119
+ rangeUsageAmountMinor: string;
2120
+ periodStart: string;
2121
+ periodEnd: string;
2122
+ }
2123
+ /** Organization usage totals for a window. */
2124
+ interface UsageSummary {
2125
+ windowStart: string;
2126
+ windowEnd: string;
2127
+ computeUnits: string;
2128
+ /**
2129
+ * `null` when the organization has no metered price, and on plans with
2130
+ * included usage (Pro, Enterprise) when the window is not inside the current
2131
+ * billing period. Use `usageValue` then.
2132
+ */
2133
+ usageCharge: UsageCharge | null;
2134
+ includedUsage: IncludedUsage | null;
2135
+ /**
2136
+ * Usage valued at the plan's overage rate, before included usage. Set for
2137
+ * every window on plans with included usage, `null` otherwise.
2138
+ */
2139
+ usageValue: UsageCharge | null;
2140
+ runningSandboxes: number;
2141
+ projects: Array<{
2142
+ projectId: string;
2143
+ projectName: string;
2144
+ computeUnits: string;
2145
+ }>;
2146
+ }
2147
+ interface ResourceUsage {
2148
+ quantity: string;
2149
+ /** `vCPU-hour`, `GiB-hour` or `GiB`. */
2150
+ unit: string;
2151
+ attributedAmountMinor: string | null;
2152
+ usageValueAmountMinor: string | null;
2153
+ }
2154
+ /** Usage of one sandbox and its share of the organization's usage charge. */
2155
+ interface SandboxUsage {
2156
+ sandboxId: string;
2157
+ /** `null` for usage whose project no longer exists. */
2158
+ project: {
2159
+ projectId: string;
2160
+ projectName: string;
2161
+ } | null;
2162
+ attributedAmountMinor: string | null;
2163
+ usageValueAmountMinor: string | null;
2164
+ resources: {
2165
+ cpu: ResourceUsage;
2166
+ memory: ResourceUsage;
2167
+ sandboxStorage: ResourceUsage;
2168
+ snapshotStorage: ResourceUsage;
2169
+ networkEgress: ResourceUsage;
2170
+ };
2171
+ }
2172
+ /** A share of the organization's pooled usage charge. */
2173
+ interface AttributedUsageCharge {
2174
+ currency: string;
2175
+ amountMinor: string;
2176
+ /** `invoice` for a finalized invoice, `current_price_estimate` otherwise. */
2177
+ basis: "invoice" | "current_price_estimate" | "unknown";
2178
+ }
2179
+ /** Every sandbox of a window with its usage and attributed charge. */
2180
+ interface SandboxUsageExport {
2181
+ windowStart: string;
2182
+ windowEnd: string;
2183
+ /**
2184
+ * The organization's usage charge; the sandboxes' attributed amounts add up
2185
+ * to it exactly. `null` when the organization has no metered price, and on
2186
+ * plans with included usage when the window is not inside the current
2187
+ * billing period.
2188
+ */
2189
+ attributedUsageCharge: AttributedUsageCharge | null;
2190
+ includedUsage: IncludedUsage | null;
2191
+ /**
2192
+ * The organization's usage at the plan's overage rate; the sandboxes' usage
2193
+ * values add up to it exactly. Set for every window on plans with included
2194
+ * usage.
2195
+ */
2196
+ attributedUsageValue: {
2197
+ currency: string;
2198
+ amountMinor: string;
2199
+ } | null;
2200
+ sandboxes: SandboxUsage[];
2201
+ }
2202
+ /**
2203
+ * Read an organization's sandbox usage and cost.
2204
+ *
2205
+ * Every read covers the current billing period, unless you set either `last`
2206
+ * (`1d`, `7d` or `30d`) or a range with `fromDate` and an optional `toDate`.
2207
+ * Requests, windows and response parsing are done
2208
+ * by the Rust SDK, the same as for Python and the CLI.
2209
+ */
2210
+ declare class UsageClient {
2211
+ private readonly native;
2212
+ constructor(options?: UsageClientOptions);
2213
+ close(): void;
2214
+ /** Organization usage totals for the window. */
2215
+ summary(options?: UsageReadOptions): Promise<UsageSummary>;
2216
+ /**
2217
+ * Usage and attributed cost of every sandbox that ran in the window.
2218
+ *
2219
+ * The server computes the attribution once and returns every sandbox in one
2220
+ * response.
2221
+ */
2222
+ sandboxes(options?: UsageReadOptions): Promise<SandboxUsageExport>;
2223
+ }
2224
+
2081
2225
  /**
2082
2226
  * Build operations for CAS sandbox images.
2083
2227
  *
@@ -2847,4 +2991,4 @@ declare class RequestExecutionError extends Error {
2847
2991
  constructor(message: string, functionName?: string);
2848
2992
  }
2849
2993
 
2850
- export { ApplicationBuildContext, ApplicationBuildResponse, ApplicationManifest, ApplicationSummary, type ArchivedSandboxInfo, type AttachFileSystemOptions, BinaryPayload, type Branch, BuildInfo, BuildLogEntry, type CancelImageBuildOutcome, type CancelImageBuildSelector, type CheckpointOptions, type CheckpointType, type ClaimSandboxOptions, CliNotFoundError, CloudClient, CloudClientOptions, CommandExitReason, type CommandResult, type CommitJobError, type CommitJobReadBack, type CommitJobStatus, type ConflictPath, type ConflictTerm, type ConnectDesktopOptions, type ConnectOptions, type ContainerResourcesInfo, ContainerState, type CopiedSandboxResponse, type CopySandboxOptions, type CopySandboxResponse, type CreateAndConnectOptions, CreateApplicationBuildRequest, type CreatePoolOptions, type CreatePtyOptions, type CreatePtySessionOptions, type CreateSandboxOptions, type CreateSandboxPoolResponse, type CreateSandboxResponse, type CreateSnapshotResponse, type CreateTunnelOptions, type DaemonInfo, Desktop, type DesktopDoubleClickOptions, type DesktopPointerOptions, type DirectoryEntry, type FileEntry, FileNotFoundInFilesystemError, FileSystem, type FileSystemMount, Filesystem, FilesystemAPIError, FilesystemClient, type FilesystemClientOptions, FilesystemError, type FilesystemFileRead, type FilesystemInfo, FilesystemMount, FilesystemNotFoundError, type FilesystemReadOptions, type FilesystemSnapshot, type FilesystemSnapshotInfo, type FilesystemStatus, type FilesystemVersion, type GPUResources, type GetOrCreateOptions, type GetOrCreateOutcome, type GetSandboxLogsOptions, type GitCredential, type GitRef, type GitRepository, type GpuModel, type GpuRequest, type HealthResponse, Image, ImageBuildCancellationOutcome, ImageBuildCancelledError, ImageBuildError, ImageBuildErrorCode, type ImageBuildErrorDetails, type ImageBuildEvent, ImageBuildFailedError, ImageBuildHandle, ImageBuildInProgressError, type ImageBuildInfo, ImageBuildInterruptedError, ImageBuildKind, ImageBuildNotFoundError, ImageBuildPhase, type ImageBuildResult, ImageBuildStatus, ImageBuildTimeoutError, type ImageBuildWaitOptions, type ListArchivedSandboxesOptions, type ListArchivedSandboxesResponse, type ListDirectoryResponse, type ManagedProcessExit, type ManagedProcessHealthStatus, type ManagedProcessInfo, type ManagedProcessStatus, type MergeConflict, type MergeConflictRecord, type MergeEntry, type MergeOptions, type MergeReport, type MergeStats, MountError, type MountStatus, type MouseButton, type NetworkConfig, NewSecret, type Operation, type OperationRef, type OutputEvent, OutputMode, type OutputResponse, PendingSandbox, type PendingSandboxRecord, type PoolContainerInfo, PoolInUseError, PoolNotFoundError, type ProcessHealthCheck, type ProcessHealthCheckType, type ProcessInfo, ProcessStatus, type ProcessUser, type ProcessUserSpec, Pty, type PtyConnectionOptions, type PtyDataHandler, type PtyExitHandler, type PtySessionInfo, type PushReport, type PushWorktreeOptions, ReadOnlyMountNotSupportedError, type ReadyOptions, RemoteAPIError, RepositoryClient, type RepositoryClientOptions, type RepositoryHandle, type RepositoryInfo, RepositoryMount, type RepositoryMountOptions, type RepositoryMountStatus, type RepositoryUnmountOptions, RequestExecutionError, RequestFailedError, RequestInput, RequestMetadata, RequestNotFinishedError, RequestOutput, ResizeErrorReason, ResizeStatus, type ResourceResizeWaitOptions, type RestartPolicy, type RestartPolicyConfig, type RunOptions, Sandbox, SandboxClient, type SandboxClientOptions, SandboxConnectionError, SandboxError, SandboxException, type SandboxInfo, type SandboxLogLevel, type SandboxLogSignal, type SandboxLogsResponse, SandboxNotFoundError, type SandboxOptions, SandboxPending, SandboxPendingReason, type SandboxPoolInfo, type SandboxPortAccess, type SandboxProcessLogFilter, type SandboxProcessLogFiltersResponse, SandboxResizeError, type SandboxResourceResizeInfo, SandboxStatus, SandboxTemplate, Secret, SecretsList, type SendSignalResponse, type SnapshotAndWaitOptions, type SnapshotInfo, type SnapshotOptions, SnapshotStatus, type SnapshotType, type SnapshotWaitCondition, type StartImageBuildOptions, StartImageBuildRequest, type StartImageImportOptions, type StartProcessOptions, StdinMode, type SuspendResumeOptions, TERMINATION_REASON_CANCELLED, TERMINATION_REASON_NO_CAPACITY, TcpTunnel, type TunnelAddress, type UpdatePoolOptions, type UpdateSandboxOptions, UpsertSecretResponse, cancelImageBuild, createFileSystem, deleteFileSystem, getImageBuild, isSandboxPending, listFileSystems, sandboxUrlFromIngressEndpoint, startImageBuild, startImageImport, waitImageBuild };
2994
+ export { ApplicationBuildContext, ApplicationBuildResponse, ApplicationManifest, ApplicationSummary, type ArchivedSandboxInfo, type AttachFileSystemOptions, type AttributedUsageCharge, BinaryPayload, type Branch, BuildInfo, BuildLogEntry, type CancelImageBuildOutcome, type CancelImageBuildSelector, type CheckpointOptions, type CheckpointType, type ClaimSandboxOptions, CliNotFoundError, CloudClient, CloudClientOptions, CommandExitReason, type CommandResult, type CommitJobError, type CommitJobReadBack, type CommitJobStatus, type ConflictPath, type ConflictTerm, type ConnectDesktopOptions, type ConnectOptions, type ContainerResourcesInfo, ContainerState, type CopiedSandboxResponse, type CopySandboxOptions, type CopySandboxResponse, type CreateAndConnectOptions, CreateApplicationBuildRequest, type CreatePoolOptions, type CreatePtyOptions, type CreatePtySessionOptions, type CreateSandboxOptions, type CreateSandboxPoolResponse, type CreateSandboxResponse, type CreateSnapshotResponse, type CreateTunnelOptions, type DaemonInfo, Desktop, type DesktopDoubleClickOptions, type DesktopPointerOptions, type DirectoryEntry, type FileEntry, FileNotFoundInFilesystemError, FileSystem, type FileSystemMount, Filesystem, FilesystemAPIError, FilesystemClient, type FilesystemClientOptions, FilesystemError, type FilesystemFileRead, type FilesystemInfo, FilesystemMount, FilesystemNotFoundError, type FilesystemReadOptions, type FilesystemSnapshot, type FilesystemSnapshotInfo, type FilesystemStatus, type FilesystemVersion, type GPUResources, type GetOrCreateOptions, type GetOrCreateOutcome, type GetSandboxLogsOptions, type GitCredential, type GitRef, type GitRepository, type GpuModel, type GpuRequest, type HealthResponse, Image, ImageBuildCancellationOutcome, ImageBuildCancelledError, ImageBuildError, ImageBuildErrorCode, type ImageBuildErrorDetails, type ImageBuildEvent, ImageBuildFailedError, ImageBuildHandle, ImageBuildInProgressError, type ImageBuildInfo, ImageBuildInterruptedError, ImageBuildKind, ImageBuildNotFoundError, ImageBuildPhase, type ImageBuildResult, ImageBuildStatus, ImageBuildTimeoutError, type ImageBuildWaitOptions, type IncludedUsage, type ListArchivedSandboxesOptions, type ListArchivedSandboxesResponse, type ListDirectoryResponse, type ManagedProcessExit, type ManagedProcessHealthStatus, type ManagedProcessInfo, type ManagedProcessStatus, type MergeConflict, type MergeConflictRecord, type MergeEntry, type MergeOptions, type MergeReport, type MergeStats, MountError, type MountStatus, type MouseButton, type NetworkConfig, NewSecret, type Operation, type OperationRef, type OutputEvent, OutputMode, type OutputResponse, PendingSandbox, type PendingSandboxRecord, type PoolContainerInfo, PoolInUseError, PoolNotFoundError, type ProcessHealthCheck, type ProcessHealthCheckType, type ProcessInfo, ProcessStatus, type ProcessUser, type ProcessUserSpec, Pty, type PtyConnectionOptions, type PtyDataHandler, type PtyExitHandler, type PtySessionInfo, type PushReport, type PushWorktreeOptions, ReadOnlyMountNotSupportedError, type ReadyOptions, RemoteAPIError, RepositoryClient, type RepositoryClientOptions, type RepositoryHandle, type RepositoryInfo, RepositoryMount, type RepositoryMountOptions, type RepositoryMountStatus, type RepositoryUnmountOptions, RequestExecutionError, RequestFailedError, RequestInput, RequestMetadata, RequestNotFinishedError, RequestOutput, ResizeErrorReason, ResizeStatus, type ResourceResizeWaitOptions, type ResourceUsage, type RestartPolicy, type RestartPolicyConfig, type RunOptions, Sandbox, SandboxClient, type SandboxClientOptions, SandboxConnectionError, SandboxError, SandboxException, type SandboxInfo, type SandboxLogLevel, type SandboxLogSignal, type SandboxLogsResponse, SandboxNotFoundError, type SandboxOptions, SandboxPending, SandboxPendingReason, type SandboxPoolInfo, type SandboxPortAccess, type SandboxProcessLogFilter, type SandboxProcessLogFiltersResponse, SandboxResizeError, type SandboxResourceResizeInfo, SandboxStatus, SandboxTemplate, type SandboxUsage, type SandboxUsageExport, Secret, SecretsList, type SendSignalResponse, type SnapshotAndWaitOptions, type SnapshotInfo, type SnapshotOptions, SnapshotStatus, type SnapshotType, type SnapshotWaitCondition, type StartImageBuildOptions, StartImageBuildRequest, type StartImageImportOptions, type StartProcessOptions, StdinMode, type SuspendResumeOptions, TERMINATION_REASON_CANCELLED, TERMINATION_REASON_NO_CAPACITY, TcpTunnel, type TunnelAddress, type UpdatePoolOptions, type UpdateSandboxOptions, UpsertSecretResponse, type UsageCharge, UsageClient, type UsageClientOptions, type UsageLookback, type UsageReadOptions, type UsageSummary, cancelImageBuild, createFileSystem, deleteFileSystem, getImageBuild, isSandboxPending, listFileSystems, sandboxUrlFromIngressEndpoint, startImageBuild, startImageImport, waitImageBuild };
package/dist/index.d.ts CHANGED
@@ -2078,6 +2078,150 @@ declare class RepositoryClient {
2078
2078
  private tracedJson;
2079
2079
  }
2080
2080
 
2081
+ /** How far back to read instead of the current billing period. */
2082
+ type UsageLookback = "1d" | "7d" | "30d";
2083
+ interface UsageClientOptions {
2084
+ /** Tensorlake API key. Defaults to `TENSORLAKE_API_KEY`. */
2085
+ apiKey?: string;
2086
+ /** Organization to read. Defaults to `TENSORLAKE_ORGANIZATION_ID`. */
2087
+ organizationId?: string;
2088
+ /** Cloud API URL. Defaults to `TENSORLAKE_API_URL`. */
2089
+ apiUrl?: string;
2090
+ }
2091
+ interface UsageReadOptions {
2092
+ /** Read the last `1d`, `7d` or `30d` instead of the current billing period. */
2093
+ last?: UsageLookback;
2094
+ /**
2095
+ * Range start, as a `Date` or an RFC 3339 string. Can't be combined with
2096
+ * `last`. The server serves ranges that start inside the current billing
2097
+ * period or the last 30 days, whichever starts earlier.
2098
+ */
2099
+ fromDate?: Date | string;
2100
+ /** Range end. Requires `fromDate`; defaults to now. */
2101
+ toDate?: Date | string;
2102
+ }
2103
+ /** Metered usage, excluding subscription fees and tax. */
2104
+ interface UsageCharge {
2105
+ currency: string;
2106
+ amountMinor: string;
2107
+ resources: {
2108
+ cpuAmountMinor: string;
2109
+ memoryAmountMinor: string;
2110
+ sandboxStorageAmountMinor: string;
2111
+ snapshotStorageAmountMinor: string;
2112
+ };
2113
+ }
2114
+ /** Plan allowance consumption, valued at the overage rate. */
2115
+ interface IncludedUsage {
2116
+ currency: string;
2117
+ includedAmountMinor: string;
2118
+ periodUsedAmountMinor: string;
2119
+ rangeUsageAmountMinor: string;
2120
+ periodStart: string;
2121
+ periodEnd: string;
2122
+ }
2123
+ /** Organization usage totals for a window. */
2124
+ interface UsageSummary {
2125
+ windowStart: string;
2126
+ windowEnd: string;
2127
+ computeUnits: string;
2128
+ /**
2129
+ * `null` when the organization has no metered price, and on plans with
2130
+ * included usage (Pro, Enterprise) when the window is not inside the current
2131
+ * billing period. Use `usageValue` then.
2132
+ */
2133
+ usageCharge: UsageCharge | null;
2134
+ includedUsage: IncludedUsage | null;
2135
+ /**
2136
+ * Usage valued at the plan's overage rate, before included usage. Set for
2137
+ * every window on plans with included usage, `null` otherwise.
2138
+ */
2139
+ usageValue: UsageCharge | null;
2140
+ runningSandboxes: number;
2141
+ projects: Array<{
2142
+ projectId: string;
2143
+ projectName: string;
2144
+ computeUnits: string;
2145
+ }>;
2146
+ }
2147
+ interface ResourceUsage {
2148
+ quantity: string;
2149
+ /** `vCPU-hour`, `GiB-hour` or `GiB`. */
2150
+ unit: string;
2151
+ attributedAmountMinor: string | null;
2152
+ usageValueAmountMinor: string | null;
2153
+ }
2154
+ /** Usage of one sandbox and its share of the organization's usage charge. */
2155
+ interface SandboxUsage {
2156
+ sandboxId: string;
2157
+ /** `null` for usage whose project no longer exists. */
2158
+ project: {
2159
+ projectId: string;
2160
+ projectName: string;
2161
+ } | null;
2162
+ attributedAmountMinor: string | null;
2163
+ usageValueAmountMinor: string | null;
2164
+ resources: {
2165
+ cpu: ResourceUsage;
2166
+ memory: ResourceUsage;
2167
+ sandboxStorage: ResourceUsage;
2168
+ snapshotStorage: ResourceUsage;
2169
+ networkEgress: ResourceUsage;
2170
+ };
2171
+ }
2172
+ /** A share of the organization's pooled usage charge. */
2173
+ interface AttributedUsageCharge {
2174
+ currency: string;
2175
+ amountMinor: string;
2176
+ /** `invoice` for a finalized invoice, `current_price_estimate` otherwise. */
2177
+ basis: "invoice" | "current_price_estimate" | "unknown";
2178
+ }
2179
+ /** Every sandbox of a window with its usage and attributed charge. */
2180
+ interface SandboxUsageExport {
2181
+ windowStart: string;
2182
+ windowEnd: string;
2183
+ /**
2184
+ * The organization's usage charge; the sandboxes' attributed amounts add up
2185
+ * to it exactly. `null` when the organization has no metered price, and on
2186
+ * plans with included usage when the window is not inside the current
2187
+ * billing period.
2188
+ */
2189
+ attributedUsageCharge: AttributedUsageCharge | null;
2190
+ includedUsage: IncludedUsage | null;
2191
+ /**
2192
+ * The organization's usage at the plan's overage rate; the sandboxes' usage
2193
+ * values add up to it exactly. Set for every window on plans with included
2194
+ * usage.
2195
+ */
2196
+ attributedUsageValue: {
2197
+ currency: string;
2198
+ amountMinor: string;
2199
+ } | null;
2200
+ sandboxes: SandboxUsage[];
2201
+ }
2202
+ /**
2203
+ * Read an organization's sandbox usage and cost.
2204
+ *
2205
+ * Every read covers the current billing period, unless you set either `last`
2206
+ * (`1d`, `7d` or `30d`) or a range with `fromDate` and an optional `toDate`.
2207
+ * Requests, windows and response parsing are done
2208
+ * by the Rust SDK, the same as for Python and the CLI.
2209
+ */
2210
+ declare class UsageClient {
2211
+ private readonly native;
2212
+ constructor(options?: UsageClientOptions);
2213
+ close(): void;
2214
+ /** Organization usage totals for the window. */
2215
+ summary(options?: UsageReadOptions): Promise<UsageSummary>;
2216
+ /**
2217
+ * Usage and attributed cost of every sandbox that ran in the window.
2218
+ *
2219
+ * The server computes the attribution once and returns every sandbox in one
2220
+ * response.
2221
+ */
2222
+ sandboxes(options?: UsageReadOptions): Promise<SandboxUsageExport>;
2223
+ }
2224
+
2081
2225
  /**
2082
2226
  * Build operations for CAS sandbox images.
2083
2227
  *
@@ -2847,4 +2991,4 @@ declare class RequestExecutionError extends Error {
2847
2991
  constructor(message: string, functionName?: string);
2848
2992
  }
2849
2993
 
2850
- export { ApplicationBuildContext, ApplicationBuildResponse, ApplicationManifest, ApplicationSummary, type ArchivedSandboxInfo, type AttachFileSystemOptions, BinaryPayload, type Branch, BuildInfo, BuildLogEntry, type CancelImageBuildOutcome, type CancelImageBuildSelector, type CheckpointOptions, type CheckpointType, type ClaimSandboxOptions, CliNotFoundError, CloudClient, CloudClientOptions, CommandExitReason, type CommandResult, type CommitJobError, type CommitJobReadBack, type CommitJobStatus, type ConflictPath, type ConflictTerm, type ConnectDesktopOptions, type ConnectOptions, type ContainerResourcesInfo, ContainerState, type CopiedSandboxResponse, type CopySandboxOptions, type CopySandboxResponse, type CreateAndConnectOptions, CreateApplicationBuildRequest, type CreatePoolOptions, type CreatePtyOptions, type CreatePtySessionOptions, type CreateSandboxOptions, type CreateSandboxPoolResponse, type CreateSandboxResponse, type CreateSnapshotResponse, type CreateTunnelOptions, type DaemonInfo, Desktop, type DesktopDoubleClickOptions, type DesktopPointerOptions, type DirectoryEntry, type FileEntry, FileNotFoundInFilesystemError, FileSystem, type FileSystemMount, Filesystem, FilesystemAPIError, FilesystemClient, type FilesystemClientOptions, FilesystemError, type FilesystemFileRead, type FilesystemInfo, FilesystemMount, FilesystemNotFoundError, type FilesystemReadOptions, type FilesystemSnapshot, type FilesystemSnapshotInfo, type FilesystemStatus, type FilesystemVersion, type GPUResources, type GetOrCreateOptions, type GetOrCreateOutcome, type GetSandboxLogsOptions, type GitCredential, type GitRef, type GitRepository, type GpuModel, type GpuRequest, type HealthResponse, Image, ImageBuildCancellationOutcome, ImageBuildCancelledError, ImageBuildError, ImageBuildErrorCode, type ImageBuildErrorDetails, type ImageBuildEvent, ImageBuildFailedError, ImageBuildHandle, ImageBuildInProgressError, type ImageBuildInfo, ImageBuildInterruptedError, ImageBuildKind, ImageBuildNotFoundError, ImageBuildPhase, type ImageBuildResult, ImageBuildStatus, ImageBuildTimeoutError, type ImageBuildWaitOptions, type ListArchivedSandboxesOptions, type ListArchivedSandboxesResponse, type ListDirectoryResponse, type ManagedProcessExit, type ManagedProcessHealthStatus, type ManagedProcessInfo, type ManagedProcessStatus, type MergeConflict, type MergeConflictRecord, type MergeEntry, type MergeOptions, type MergeReport, type MergeStats, MountError, type MountStatus, type MouseButton, type NetworkConfig, NewSecret, type Operation, type OperationRef, type OutputEvent, OutputMode, type OutputResponse, PendingSandbox, type PendingSandboxRecord, type PoolContainerInfo, PoolInUseError, PoolNotFoundError, type ProcessHealthCheck, type ProcessHealthCheckType, type ProcessInfo, ProcessStatus, type ProcessUser, type ProcessUserSpec, Pty, type PtyConnectionOptions, type PtyDataHandler, type PtyExitHandler, type PtySessionInfo, type PushReport, type PushWorktreeOptions, ReadOnlyMountNotSupportedError, type ReadyOptions, RemoteAPIError, RepositoryClient, type RepositoryClientOptions, type RepositoryHandle, type RepositoryInfo, RepositoryMount, type RepositoryMountOptions, type RepositoryMountStatus, type RepositoryUnmountOptions, RequestExecutionError, RequestFailedError, RequestInput, RequestMetadata, RequestNotFinishedError, RequestOutput, ResizeErrorReason, ResizeStatus, type ResourceResizeWaitOptions, type RestartPolicy, type RestartPolicyConfig, type RunOptions, Sandbox, SandboxClient, type SandboxClientOptions, SandboxConnectionError, SandboxError, SandboxException, type SandboxInfo, type SandboxLogLevel, type SandboxLogSignal, type SandboxLogsResponse, SandboxNotFoundError, type SandboxOptions, SandboxPending, SandboxPendingReason, type SandboxPoolInfo, type SandboxPortAccess, type SandboxProcessLogFilter, type SandboxProcessLogFiltersResponse, SandboxResizeError, type SandboxResourceResizeInfo, SandboxStatus, SandboxTemplate, Secret, SecretsList, type SendSignalResponse, type SnapshotAndWaitOptions, type SnapshotInfo, type SnapshotOptions, SnapshotStatus, type SnapshotType, type SnapshotWaitCondition, type StartImageBuildOptions, StartImageBuildRequest, type StartImageImportOptions, type StartProcessOptions, StdinMode, type SuspendResumeOptions, TERMINATION_REASON_CANCELLED, TERMINATION_REASON_NO_CAPACITY, TcpTunnel, type TunnelAddress, type UpdatePoolOptions, type UpdateSandboxOptions, UpsertSecretResponse, cancelImageBuild, createFileSystem, deleteFileSystem, getImageBuild, isSandboxPending, listFileSystems, sandboxUrlFromIngressEndpoint, startImageBuild, startImageImport, waitImageBuild };
2994
+ export { ApplicationBuildContext, ApplicationBuildResponse, ApplicationManifest, ApplicationSummary, type ArchivedSandboxInfo, type AttachFileSystemOptions, type AttributedUsageCharge, BinaryPayload, type Branch, BuildInfo, BuildLogEntry, type CancelImageBuildOutcome, type CancelImageBuildSelector, type CheckpointOptions, type CheckpointType, type ClaimSandboxOptions, CliNotFoundError, CloudClient, CloudClientOptions, CommandExitReason, type CommandResult, type CommitJobError, type CommitJobReadBack, type CommitJobStatus, type ConflictPath, type ConflictTerm, type ConnectDesktopOptions, type ConnectOptions, type ContainerResourcesInfo, ContainerState, type CopiedSandboxResponse, type CopySandboxOptions, type CopySandboxResponse, type CreateAndConnectOptions, CreateApplicationBuildRequest, type CreatePoolOptions, type CreatePtyOptions, type CreatePtySessionOptions, type CreateSandboxOptions, type CreateSandboxPoolResponse, type CreateSandboxResponse, type CreateSnapshotResponse, type CreateTunnelOptions, type DaemonInfo, Desktop, type DesktopDoubleClickOptions, type DesktopPointerOptions, type DirectoryEntry, type FileEntry, FileNotFoundInFilesystemError, FileSystem, type FileSystemMount, Filesystem, FilesystemAPIError, FilesystemClient, type FilesystemClientOptions, FilesystemError, type FilesystemFileRead, type FilesystemInfo, FilesystemMount, FilesystemNotFoundError, type FilesystemReadOptions, type FilesystemSnapshot, type FilesystemSnapshotInfo, type FilesystemStatus, type FilesystemVersion, type GPUResources, type GetOrCreateOptions, type GetOrCreateOutcome, type GetSandboxLogsOptions, type GitCredential, type GitRef, type GitRepository, type GpuModel, type GpuRequest, type HealthResponse, Image, ImageBuildCancellationOutcome, ImageBuildCancelledError, ImageBuildError, ImageBuildErrorCode, type ImageBuildErrorDetails, type ImageBuildEvent, ImageBuildFailedError, ImageBuildHandle, ImageBuildInProgressError, type ImageBuildInfo, ImageBuildInterruptedError, ImageBuildKind, ImageBuildNotFoundError, ImageBuildPhase, type ImageBuildResult, ImageBuildStatus, ImageBuildTimeoutError, type ImageBuildWaitOptions, type IncludedUsage, type ListArchivedSandboxesOptions, type ListArchivedSandboxesResponse, type ListDirectoryResponse, type ManagedProcessExit, type ManagedProcessHealthStatus, type ManagedProcessInfo, type ManagedProcessStatus, type MergeConflict, type MergeConflictRecord, type MergeEntry, type MergeOptions, type MergeReport, type MergeStats, MountError, type MountStatus, type MouseButton, type NetworkConfig, NewSecret, type Operation, type OperationRef, type OutputEvent, OutputMode, type OutputResponse, PendingSandbox, type PendingSandboxRecord, type PoolContainerInfo, PoolInUseError, PoolNotFoundError, type ProcessHealthCheck, type ProcessHealthCheckType, type ProcessInfo, ProcessStatus, type ProcessUser, type ProcessUserSpec, Pty, type PtyConnectionOptions, type PtyDataHandler, type PtyExitHandler, type PtySessionInfo, type PushReport, type PushWorktreeOptions, ReadOnlyMountNotSupportedError, type ReadyOptions, RemoteAPIError, RepositoryClient, type RepositoryClientOptions, type RepositoryHandle, type RepositoryInfo, RepositoryMount, type RepositoryMountOptions, type RepositoryMountStatus, type RepositoryUnmountOptions, RequestExecutionError, RequestFailedError, RequestInput, RequestMetadata, RequestNotFinishedError, RequestOutput, ResizeErrorReason, ResizeStatus, type ResourceResizeWaitOptions, type ResourceUsage, type RestartPolicy, type RestartPolicyConfig, type RunOptions, Sandbox, SandboxClient, type SandboxClientOptions, SandboxConnectionError, SandboxError, SandboxException, type SandboxInfo, type SandboxLogLevel, type SandboxLogSignal, type SandboxLogsResponse, SandboxNotFoundError, type SandboxOptions, SandboxPending, SandboxPendingReason, type SandboxPoolInfo, type SandboxPortAccess, type SandboxProcessLogFilter, type SandboxProcessLogFiltersResponse, SandboxResizeError, type SandboxResourceResizeInfo, SandboxStatus, SandboxTemplate, type SandboxUsage, type SandboxUsageExport, Secret, SecretsList, type SendSignalResponse, type SnapshotAndWaitOptions, type SnapshotInfo, type SnapshotOptions, SnapshotStatus, type SnapshotType, type SnapshotWaitCondition, type StartImageBuildOptions, StartImageBuildRequest, type StartImageImportOptions, type StartProcessOptions, StdinMode, type SuspendResumeOptions, TERMINATION_REASON_CANCELLED, TERMINATION_REASON_NO_CAPACITY, TcpTunnel, type TunnelAddress, type UpdatePoolOptions, type UpdateSandboxOptions, UpsertSecretResponse, type UsageCharge, UsageClient, type UsageClientOptions, type UsageLookback, type UsageReadOptions, type UsageSummary, cancelImageBuild, createFileSystem, deleteFileSystem, getImageBuild, isSandboxPending, listFileSystems, sandboxUrlFromIngressEndpoint, startImageBuild, startImageImport, waitImageBuild };
package/dist/index.js CHANGED
@@ -46,7 +46,7 @@ var init_defaults = __esm({
46
46
  "src/defaults.ts"() {
47
47
  "use strict";
48
48
  init_esm_shims();
49
- SDK_VERSION = "0.5.159";
49
+ SDK_VERSION = "0.5.161";
50
50
  API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
51
51
  API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
52
52
  NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
@@ -332,6 +332,11 @@ function createWorkerBinding(runtime) {
332
332
  return runtime.handle("NativeRepositoryClient", args);
333
333
  }
334
334
  },
335
+ NativeUsageClient: class {
336
+ constructor(...args) {
337
+ return runtime.handle("NativeUsageClient", args);
338
+ }
339
+ },
335
340
  NativeTcpTunnel: class {
336
341
  constructor() {
337
342
  return runtime.handle("NativeTcpTunnel", []);
@@ -514,7 +519,7 @@ var init_native_worker_client = __esm({
514
519
  }
515
520
  };
516
521
  runtimeKey = /* @__PURE__ */ Symbol.for(
517
- `tensorlake.native.worker.${false ? "source" : "0.5.159"}.v1`
522
+ `tensorlake.native.worker.${false ? "source" : "0.5.161"}.v1`
518
523
  );
519
524
  runtimes = globalThis;
520
525
  }
@@ -8795,6 +8800,63 @@ function validateTimeoutMs2(timeoutMs) {
8795
8800
  }
8796
8801
  }
8797
8802
 
8803
+ // src/usage.ts
8804
+ init_esm_shims();
8805
+ init_defaults();
8806
+ init_errors();
8807
+ init_native_sandbox();
8808
+ init_native_worker_client();
8809
+ function nativeWindow(options) {
8810
+ const iso = (value) => value === void 0 ? null : value instanceof Date ? value.toISOString() : value;
8811
+ return [options?.last ?? null, iso(options?.fromDate), iso(options?.toDate)];
8812
+ }
8813
+ var UsageClient = class {
8814
+ native;
8815
+ constructor(options) {
8816
+ const apiKey = options?.apiKey ?? API_KEY;
8817
+ if (!apiKey) {
8818
+ throw new SandboxError("Missing TENSORLAKE_API_KEY credentials.");
8819
+ }
8820
+ const organizationId = options?.organizationId ?? process.env.TENSORLAKE_ORGANIZATION_ID;
8821
+ if (!organizationId) {
8822
+ throw new SandboxError(
8823
+ "An organization ID is required. Pass organizationId or set TENSORLAKE_ORGANIZATION_ID."
8824
+ );
8825
+ }
8826
+ const binding = loadNativeSandboxBinding();
8827
+ if (typeof binding.NativeUsageClient !== "function") {
8828
+ throw new SandboxError(
8829
+ "native binding does not export the usage client; rebuild with 'npm run build:native'"
8830
+ );
8831
+ }
8832
+ this.native = new binding.NativeUsageClient(
8833
+ options?.apiUrl ?? API_URL,
8834
+ apiKey,
8835
+ organizationId,
8836
+ `tensorlake-typescript-sdk/${SDK_VERSION}`,
8837
+ DEFAULT_HTTP_TIMEOUT_MS / 1e3
8838
+ );
8839
+ }
8840
+ close() {
8841
+ releaseNativeHandle(this.native);
8842
+ }
8843
+ /** Organization usage totals for the window. */
8844
+ async summary(options) {
8845
+ const { json } = await callNative(() => this.native.summary(...nativeWindow(options)));
8846
+ return JSON.parse(json);
8847
+ }
8848
+ /**
8849
+ * Usage and attributed cost of every sandbox that ran in the window.
8850
+ *
8851
+ * The server computes the attribution once and returns every sandbox in one
8852
+ * response.
8853
+ */
8854
+ async sandboxes(options) {
8855
+ const { json } = await callNative(() => this.native.sandboxes(...nativeWindow(options)));
8856
+ return JSON.parse(json);
8857
+ }
8858
+ };
8859
+
8798
8860
  // src/index.ts
8799
8861
  init_sandbox_image();
8800
8862
  init_image_builds();
@@ -10707,6 +10769,7 @@ export {
10707
10769
  TERMINATION_REASON_CANCELLED,
10708
10770
  TERMINATION_REASON_NO_CAPACITY,
10709
10771
  TcpTunnel,
10772
+ UsageClient,
10710
10773
  cancelImageBuild,
10711
10774
  createFileSystem,
10712
10775
  createSandboxImage,