@shardflux/sdk 0.15.0 → 0.16.0
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/CHANGELOG.md +42 -22
- package/README.md +99 -1
- package/dist/account.d.ts +2 -0
- package/dist/account.js +6 -0
- package/dist/cell.d.ts +2 -0
- package/dist/cell.js +2 -0
- package/dist/client.d.ts +25 -1
- package/dist/client.js +44 -3
- package/dist/computer.d.ts +11 -1
- package/dist/computer.js +89 -6
- package/dist/errors.d.ts +5 -1
- package/dist/errors.js +9 -0
- package/dist/executions.d.ts +2 -6
- package/dist/executions.js +9 -0
- package/dist/exit-code.d.ts +7 -0
- package/dist/exit-code.js +12 -0
- package/dist/generated/app-api.d.ts +565 -13
- package/dist/generated/cell-api.d.ts +2 -0
- package/dist/http.d.ts +7 -1
- package/dist/http.js +34 -13
- package/dist/index.d.ts +8 -5
- package/dist/index.js +4 -2
- package/dist/ports.d.ts +7 -0
- package/dist/ports.js +1 -1
- package/dist/progress.d.ts +2 -2
- package/dist/progress.js +1 -1
- package/dist/testing/index.d.ts +62 -0
- package/dist/testing/index.js +585 -0
- package/dist/testing/seed.d.ts +433 -0
- package/dist/testing/seed.js +449 -0
- package/dist/tools.d.ts +5 -0
- package/dist/tools.js +4 -2
- package/dist/tunnel-assets/linux-amd64.gz +0 -0
- package/dist/tunnel-assets/linux-arm64.gz +0 -0
- package/dist/tunnel-assets.d.ts +10 -0
- package/dist/tunnel-assets.js +11 -0
- package/dist/tunnel-packet.d.ts +3 -0
- package/dist/tunnel-packet.js +43 -0
- package/dist/tunnel-pty.d.ts +86 -0
- package/dist/tunnel-pty.js +243 -0
- package/dist/tunnels.d.ts +47 -0
- package/dist/tunnels.js +454 -0
- package/dist/workspace-ref.d.ts +4 -0
- package/dist/workspace-ref.js +24 -0
- package/dist/workspace.d.ts +18 -1
- package/dist/workspace.js +76 -3
- package/package.json +7 -2
|
@@ -2260,6 +2260,8 @@ export interface operations {
|
|
|
2260
2260
|
parameters: {
|
|
2261
2261
|
query?: {
|
|
2262
2262
|
offset?: number;
|
|
2263
|
+
/** @description Opt-in output representation. binary sends a u64be log offset followed by up to 1 MiB raw bytes; control messages remain JSON. json (default) sends up to 64 KiB base64 chunks. */
|
|
2264
|
+
output_format?: "json" | "binary";
|
|
2263
2265
|
ticket?: string;
|
|
2264
2266
|
};
|
|
2265
2267
|
header?: never;
|
package/dist/http.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RetryRecord } from './progress.js';
|
|
2
|
-
export declare const SDK_VERSION = "0.
|
|
2
|
+
export declare const SDK_VERSION = "0.16.0";
|
|
3
3
|
export interface RequestOptions {
|
|
4
4
|
query?: Record<string, string | number | boolean | undefined | null>;
|
|
5
5
|
json?: unknown;
|
|
@@ -70,6 +70,12 @@ export declare const POOL_OPTIONS: {
|
|
|
70
70
|
* native pooling. An explicitly supplied fetch is untouched. Idle pooled sockets do not keep the process alive.
|
|
71
71
|
*/
|
|
72
72
|
export declare function defaultFetch(env?: Record<string, string | undefined> | undefined, undiciVersion?: string | undefined): typeof fetch;
|
|
73
|
+
/** Snapshot the caller's env; empty overrides keep a supplied env independent of process.env. */
|
|
74
|
+
export declare function proxyOptions(env: Record<string, string | undefined> | undefined): {
|
|
75
|
+
httpProxy: string;
|
|
76
|
+
httpsProxy: string;
|
|
77
|
+
noProxy: string;
|
|
78
|
+
};
|
|
73
79
|
export declare function buildUrl(base: string, path: string, query?: RequestOptions['query']): string;
|
|
74
80
|
/**
|
|
75
81
|
* True when fetch failed because its connection closed or reset before a response arrived: what a request sees when
|
package/dist/http.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { ShardfluxApiError, ShardfluxProtocolError, apiError, isErrorBody, isWorkingQuotaRefusal } from "./errors.js";
|
|
13
13
|
import { describeFailure } from "./progress.js";
|
|
14
|
-
export const SDK_VERSION = '0.
|
|
14
|
+
export const SDK_VERSION = '0.16.0';
|
|
15
15
|
export const defaultSleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
16
16
|
/**
|
|
17
17
|
* How long an idle pooled connection stays reusable (ms): 5 minutes, instead of undici's 4 s default, so the request
|
|
@@ -36,7 +36,7 @@ export const POOL_OPTIONS = {
|
|
|
36
36
|
connect: { keepAlive: true, keepAliveInitialDelay: TCP_KEEPALIVE_INITIAL_DELAY_MS },
|
|
37
37
|
};
|
|
38
38
|
/** One private HTTP/1.1 pool on Node 26+, shared by SDK clients. No global dispatcher changes. */
|
|
39
|
-
|
|
39
|
+
const nodeFetches = new Map();
|
|
40
40
|
/**
|
|
41
41
|
* Reuses TLS connections. Node 26's bundled undici 8.9 can stall reused connections: use pinned undici with a
|
|
42
42
|
* private HTTP/1.1-only dispatcher whose idle connections stay reusable for KEEP_ALIVE_TIMEOUT_MS. Other runtimes
|
|
@@ -46,27 +46,48 @@ let nodeFetch;
|
|
|
46
46
|
export function defaultFetch(env = globalThis.process?.env, undiciVersion = globalThis.process?.versions?.undici) {
|
|
47
47
|
// Why a fresh connection on Node 26 (its bundled HTTP client, measured): docs/progress/startup-latency.md.
|
|
48
48
|
const base = (input, init) => fetch(input, init);
|
|
49
|
-
|
|
49
|
+
const proxy = proxyOptions(env);
|
|
50
|
+
const useProxy = Boolean(proxy.httpProxy || proxy.httpsProxy || proxy.noProxy || env?.NODE_USE_ENV_PROXY === '1');
|
|
51
|
+
if (!useProxy && env?.SHARDFLUX_HTTP_KEEPALIVE === '0')
|
|
50
52
|
return (input, init) => {
|
|
51
53
|
const headers = new Headers(init?.headers);
|
|
52
54
|
headers.set('connection', 'close');
|
|
53
55
|
return base(input, { ...init, headers });
|
|
54
56
|
};
|
|
55
|
-
if (Number((undiciVersion ?? '').split('.')[0]) < 8 || !undiciVersion || env?.SHARDFLUX_HTTP_KEEPALIVE === '1')
|
|
57
|
+
if (!useProxy && (Number((undiciVersion ?? '').split('.')[0]) < 8 || !undiciVersion || env?.SHARDFLUX_HTTP_KEEPALIVE === '1'))
|
|
56
58
|
return base;
|
|
59
|
+
const poolKey = useProxy ? JSON.stringify(proxy) : 'direct';
|
|
57
60
|
return async (input, init) => {
|
|
58
|
-
nodeFetch
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
let nodeFetch = nodeFetches.get(poolKey);
|
|
62
|
+
if (!nodeFetch) {
|
|
63
|
+
nodeFetch = import('undici').then(({ Agent, EnvHttpProxyAgent, fetch: pooledFetch }) => {
|
|
64
|
+
const options = { ...POOL_OPTIONS, connect: { ...POOL_OPTIONS.connect } };
|
|
65
|
+
const dispatcher = useProxy ? new EnvHttpProxyAgent({ ...options, ...proxy }) : new Agent(options);
|
|
66
|
+
return async (input, init) => {
|
|
67
|
+
const response = await pooledFetch(input, { ...init, dispatcher });
|
|
68
|
+
// Web-standard runtime shape; undici and DOM iterator declarations differ.
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- Required by consumers compiling with lib.dom instead of only Node types.
|
|
70
|
+
return response;
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
nodeFetches.set(poolKey, nodeFetch);
|
|
74
|
+
}
|
|
75
|
+
if (env?.SHARDFLUX_HTTP_KEEPALIVE === '0') {
|
|
76
|
+
const headers = new Headers(init?.headers);
|
|
77
|
+
headers.set('connection', 'close');
|
|
78
|
+
init = { ...init, headers };
|
|
79
|
+
}
|
|
67
80
|
return (await nodeFetch)(input, init);
|
|
68
81
|
};
|
|
69
82
|
}
|
|
83
|
+
/** Snapshot the caller's env; empty overrides keep a supplied env independent of process.env. */
|
|
84
|
+
export function proxyOptions(env) {
|
|
85
|
+
return {
|
|
86
|
+
httpProxy: env?.http_proxy ?? env?.HTTP_PROXY ?? '',
|
|
87
|
+
httpsProxy: env?.https_proxy ?? env?.HTTPS_PROXY ?? '',
|
|
88
|
+
noProxy: env?.no_proxy ?? env?.NO_PROXY ?? '',
|
|
89
|
+
};
|
|
90
|
+
}
|
|
70
91
|
export function buildUrl(base, path, query) {
|
|
71
92
|
const u = new URL(base.replace(/\/+$/, '') + path);
|
|
72
93
|
for (const [k, v] of Object.entries(query ?? {})) {
|
package/dist/index.d.ts
CHANGED
|
@@ -14,10 +14,12 @@
|
|
|
14
14
|
*/
|
|
15
15
|
export type { components, operations, paths } from './generated/app-api.js';
|
|
16
16
|
export type { components as CellComponents, paths as CellPaths } from './generated/cell-api.js';
|
|
17
|
-
export { BillingApi, Shardflux, WorkspacesApi, fetchBillingCatalog, pickByKey, workspace } from './client.js';
|
|
17
|
+
export { ProjectsRetentionApi, BillingApi, Shardflux, WorkspacesApi, fetchBillingCatalog, pickByKey, workspace } from './client.js';
|
|
18
18
|
export { WorkspaceRef } from './workspace-ref.js';
|
|
19
|
+
export { ReverseTunnel, WorkspaceTunnels } from './tunnels.js';
|
|
20
|
+
export type { ReverseTunnelOptions, ReverseTunnelStats } from './tunnels.js';
|
|
19
21
|
export type { WorkspaceRefFiles, WorkspaceRefParams } from './workspace-ref.js';
|
|
20
|
-
export type { AgentSession, AllocationMode, ComputerUse, BillingCatalog, BillingSubscription, Caps, CheckoutSession, DiskLayout, Entitlements, FindByKeyOptions, ForkTarget, Invoice, InvoicePage, LifetimeFilter, ListParams, Me, OpenParams, OpenResponse, Operation, Page, PortalSession, PurposeFilter, ResetWorkspaceBody, ResizeAppliesAt, ResizeCpu, ResizeDeferReason, ResizeDisk, ResizeLimitReason, ResizeMemory, ResizeParams, ResizeResult, ResizeResponse, ResumeAnswer, ResumeRequestOptions, ResumeResponse, ShardfluxOptions, SuspendRequest, SuspendWhenIdleOptions, SuspendWhenIdleResponse, SuspendWhenIdleResult, WaitOptions, WorkspaceInputs, WorkspaceLifetime, WorkspaceMemory, WorkspaceOrigin, WorkspacePurpose, WorkspaceView, } from './client.js';
|
|
22
|
+
export type { AgentSession, AllocationMode, ComputerUse, BillingCatalog, BillingSubscription, Caps, CheckoutSession, DiskLayout, Entitlements, FindByKeyOptions, ForkTarget, Invoice, InvoicePage, LifetimeFilter, ListParams, Me, RetentionPolicy, ProjectRetentionPolicy, OpenParams, OpenResponse, Operation, Page, PortalSession, PurposeFilter, ResetWorkspaceBody, ResizeAppliesAt, ResizeCpu, ResizeDeferReason, ResizeDisk, ResizeLimitReason, ResizeMemory, ResizeParams, ResizeResult, ResizeResponse, ResumeAnswer, ResumeRequestOptions, ResumeResponse, ShardfluxOptions, SuspendRequest, SuspendWhenIdleOptions, SuspendWhenIdleResponse, SuspendWhenIdleResult, WaitOptions, WorkspaceInputs, WorkspaceLifetime, WorkspaceMemory, WorkspaceOrigin, WorkspacePurpose, WorkspaceView, } from './client.js';
|
|
21
23
|
export type { FinishedOperation, ForkOptions, LifecycleOptions, ResumeOptions, SuspendOptions, WaitedForkOptions, WaitedLifecycleOptions, WaitedResumeOptions, WaitedSuspendOptions } from './lifecycle.js';
|
|
22
24
|
export { COLD_BOOT_REASONS, durabilityOf, formatTiming, hostLostOf, isDurable, lostSuspendOf } from './progress.js';
|
|
23
25
|
export type { ColdBootReason, Durability, HostLost, LostSuspend, LifecycleAction, LifecyclePhase, LifecycleTiming, ProgressEvent, ProgressListener, RetryRecord, ServerTiming, TimingOutcome, TimingPhase, } from './progress.js';
|
|
@@ -32,9 +34,10 @@ export { tarEnd, tarHeader, tarPadding } from './tar.js';
|
|
|
32
34
|
export type { TarEntry, TarEntryType } from './tar.js';
|
|
33
35
|
export type { BuildFromFileEvent, BuildFromFileOptions, BuildFromFileResult, BuildFromRecipeOptions, BuilderAvailability, CreateDraftBody, CreateDraftParams, CreateTemplateBuildParams, CreateTestInstanceBody, CreateVersionTestInstanceBody, CreateVersionTestInstanceParams, DraftOpened, LocalUpload, DraftState, OpenTestInstanceParams, OrgTemplateStorage, PublishDraftBody, PublishDraftParams, PutUploadOptions, SaveAsTemplateBody, SaveAsTemplateParams, SaveAsTemplateResponse, TemplateBuild, TemplateBuildLogUrl, TemplateBuildRecipeV2, TemplateBuildRegistrationState, TemplateBuildState, TemplateCategory, TemplateDefaults, TemplateDefaultsInput, TemplateDetail, TemplateDiffChange, TemplateDiffEntry, TemplateDiffPage, TemplateDiffParams, TemplateDraft, TemplateDraftSummary, TemplateEgressDefault, TemplateFileEntry, TemplateFilePage, TemplateFilesParams, TemplateFilesSummary, TemplateInput, TemplateLanguage, TemplateLanguages, TemplateOwner, TemplatePackage, TemplatePackageEcosystem, TemplatePackagePage, TemplateRecipe, TemplateRecipeV2, TemplateRecipeV2File, TemplateService, TemplateSettings, TemplateSettingsInput, TemplateSource, TemplateStartCommand, TemplateStorage, TemplateStorageWarning, TemplateSummary, TemplateUpload, TemplateUploadRequest, TemplateUploadResponse, TemplateUploadResult, TemplateVersion, TemplateVersionImmutable, TemplateVersionRecipe, TemplateVersionState, UploadData, WaitForBuildOptions, WorkspaceStartup, } from './templates.js';
|
|
34
36
|
export { WorkspacePorts } from './ports.js';
|
|
37
|
+
export { exitCodePosix } from './exit-code.js';
|
|
35
38
|
export { COMPUTER_TOOLSET, WorkspaceComputer, computerToolset, decodeComputerImage } from './computer.js';
|
|
36
|
-
export type { ComputerActOptions, ComputerScreenshot, ComputerStream, ComputerStreamOptions, ComputerToolResult, ComputerToolsetOptions, ToolUseBlockLike } from './computer.js';
|
|
37
|
-
export type { ExposePortResult, ExposedPort, PortCallbackResponse, PortCallbackUrl, PortLink, PortLinkOptions, PortLinkResponse, PortToken, PortTokenOptions, PortTokenResponse, PortView } from './ports.js';
|
|
39
|
+
export type { BeforeComputerAction, ComputerActOptions, ComputerScreenshot, ComputerStream, ComputerStreamOptions, ComputerToolResult, ComputerToolsetOptions, ToolUseBlockLike } from './computer.js';
|
|
40
|
+
export type { ExposePortResult, ExposedPort, PortCallbackResponse, PortCallbackUrl, PortLink, PortEmbedOptions, PortLinkOptions, PortLinkResponse, PortToken, PortTokenOptions, PortTokenResponse, PortView } from './ports.js';
|
|
38
41
|
export { SecretsApi, WorkspaceSecrets } from './secrets.js';
|
|
39
42
|
export type { BoundSecretStatus, CreateOrganizationSecretParams, CreateSecretParams, Secret, SecretAccessEvent, SecretPermissions, SecretScope, SecretVersion, UpdateSecretParams, WorkspaceSecretBindings, } from './secrets.js';
|
|
40
43
|
export { EgressPolicyApi } from './egress.js';
|
|
@@ -56,7 +59,7 @@ export type { AnthropicToolDefinition, JsonSchema, OpenAIChatToolDefinition, Ope
|
|
|
56
59
|
export { CaptureError, ToolCallCapture, captureTool } from './capture.js';
|
|
57
60
|
export type { CallLike, CallRef, CaptureCall, CaptureErrorKind, CaptureEvent, CaptureFlushResult, CapturePart, CaptureSelector, CaptureSource, CaptureStats, CaptureStatus, DropReason, ToolCallCaptureOptions, WrapOptions, } from './capture.js';
|
|
58
61
|
export type { AiSdkAdapter, AiSdkToolEndEvent, AnthropicAdapter, ClaudeAdapter, ClaudeCaptureHooks, ClaudeHookCallback, ClaudeHookMatcher, LangChainAdapter, LangChainToolHandler, MastraAdapter, MastraAfterToolCallContext, McpAdapter, OpenAIAgentsAdapter, } from './capture-adapters.js';
|
|
59
|
-
export { DurabilityLostError, ExecStartError, NotSupportedForModeError, OperationFailedError, OperationTimeoutError, ShardfluxApiError, ShardfluxProtocolError, TreeRevisionMismatchError } from './errors.js';
|
|
62
|
+
export { FileNotFoundError, DurabilityLostError, ExecStartError, NotSupportedForModeError, OperationFailedError, OperationTimeoutError, ShardfluxApiError, ShardfluxProtocolError, TreeRevisionMismatchError } from './errors.js';
|
|
60
63
|
export type { AppErrorCode, CellErrorCode, ErrorCode, ErrorReason, KnownErrorReason, WorkspaceMode } from './errors.js';
|
|
61
64
|
export { SDK_VERSION } from './http.js';
|
|
62
65
|
export { API_KEY_TOOL_PERMISSIONS, AccountApiKeysApi, AccountAuditApi, AccountAuthApi, AccountBillingApi, AccountExportsApi, AccountInvitationsApi, AccountMembersApi, AccountOrganizationsApi, AccountProjectsApi, AccountTemplatesApi, AccountTotpApi, AccountUserApi, CheckoutTimeoutError, OrganizationExportsApi, SESSION_TOKEN_PATTERN, ShardfluxAccount, isSessionToken, parseEmailToken, } from './account.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { BillingApi, Shardflux, WorkspacesApi, fetchBillingCatalog, pickByKey, workspace } from "./client.js";
|
|
1
|
+
export { ProjectsRetentionApi, BillingApi, Shardflux, WorkspacesApi, fetchBillingCatalog, pickByKey, workspace } from "./client.js";
|
|
2
2
|
export { WorkspaceRef } from "./workspace-ref.js";
|
|
3
|
+
export { ReverseTunnel, WorkspaceTunnels } from "./tunnels.js";
|
|
3
4
|
export { COLD_BOOT_REASONS, durabilityOf, formatTiming, hostLostOf, isDurable, lostSuspendOf } from "./progress.js";
|
|
4
5
|
export { FEEDBACK_CATEGORIES, FEEDBACK_MESSAGE_MAX_LENGTH } from "./feedback.js";
|
|
5
6
|
export { UsageApi } from "./usage.js";
|
|
@@ -8,6 +9,7 @@ export { TemplateFileError, packDirectory, parseTemplateText, readTemplateFile }
|
|
|
8
9
|
export { tarEnd, tarHeader, tarPadding } from "./tar.js";
|
|
9
10
|
export { WorkspacePorts } from "./ports.js";
|
|
10
11
|
// Computer use (0.15.0+, contracts §45).
|
|
12
|
+
export { exitCodePosix } from "./exit-code.js";
|
|
11
13
|
export { COMPUTER_TOOLSET, WorkspaceComputer, computerToolset, decodeComputerImage } from "./computer.js";
|
|
12
14
|
export { SecretsApi, WorkspaceSecrets } from "./secrets.js";
|
|
13
15
|
export { EgressPolicyApi } from "./egress.js";
|
|
@@ -19,7 +21,7 @@ export { EXECUTION_ID, ExecutionResult, newExecutionId } from "./executions.js";
|
|
|
19
21
|
export { ToolTokenManager } from "./tokens.js";
|
|
20
22
|
export { ToolArgumentError, executeToolCall, toAnthropicTools, toOpenAITools, validateArgs, workspaceTools } from "./tools.js";
|
|
21
23
|
export { CaptureError, ToolCallCapture, captureTool } from "./capture.js";
|
|
22
|
-
export { DurabilityLostError, ExecStartError, NotSupportedForModeError, OperationFailedError, OperationTimeoutError, ShardfluxApiError, ShardfluxProtocolError, TreeRevisionMismatchError } from "./errors.js";
|
|
24
|
+
export { FileNotFoundError, DurabilityLostError, ExecStartError, NotSupportedForModeError, OperationFailedError, OperationTimeoutError, ShardfluxApiError, ShardfluxProtocolError, TreeRevisionMismatchError } from "./errors.js";
|
|
23
25
|
export { SDK_VERSION } from "./http.js";
|
|
24
26
|
export { API_KEY_TOOL_PERMISSIONS, AccountApiKeysApi, AccountAuditApi, AccountAuthApi, AccountBillingApi, AccountExportsApi, AccountInvitationsApi, AccountMembersApi, AccountOrganizationsApi, AccountProjectsApi, AccountTemplatesApi, AccountTotpApi, AccountUserApi, CheckoutTimeoutError, OrganizationExportsApi, SESSION_TOKEN_PATTERN, ShardfluxAccount, isSessionToken, parseEmailToken, } from "./account.js";
|
|
25
27
|
export { codexIdentityProof } from "./codex-proof.js";
|
package/dist/ports.d.ts
CHANGED
|
@@ -75,7 +75,14 @@ export interface PortTokenOptions {
|
|
|
75
75
|
/** Lifetime in seconds: 60-86400 (default 3600). */
|
|
76
76
|
ttlSeconds?: number;
|
|
77
77
|
}
|
|
78
|
+
/** Origins allowed to frame the linked port (§48). Validated by the API. */
|
|
79
|
+
export interface PortEmbedOptions {
|
|
80
|
+
/** 1–10 distinct canonical HTTPS origins, without paths or wildcards; 256 characters each, 2048 total. */
|
|
81
|
+
origins: string[];
|
|
82
|
+
}
|
|
78
83
|
export interface PortLinkOptions {
|
|
84
|
+
/** Opt in to a partitioned browser session and this frame allowlist. */
|
|
85
|
+
embed?: PortEmbedOptions;
|
|
79
86
|
/** Lifetime of the link and of the browser session it starts, in seconds: 60-604800 (default 86400). */
|
|
80
87
|
ttlSeconds?: number;
|
|
81
88
|
/** Where the link lands: a path starting with one `/`, printable ASCII, query allowed (default `/`). */
|
package/dist/ports.js
CHANGED
|
@@ -47,7 +47,7 @@ export class WorkspacePorts {
|
|
|
47
47
|
}
|
|
48
48
|
/** A signed link that opens the port in a browser. Share it like a password: anyone with it can open the port until it expires. */
|
|
49
49
|
async link(port, opts = {}) {
|
|
50
|
-
const body = await this.#ctx.http.json('POST', this.#path(port, '/links'), { json: { ...(opts.ttlSeconds !== undefined ? { ttl_seconds: opts.ttlSeconds } : {}), ...(opts.path !== undefined ? { path: opts.path } : {}) } }, this.#ctx.authorization);
|
|
50
|
+
const body = await this.#ctx.http.json('POST', this.#path(port, '/links'), { json: { ...(opts.embed !== undefined ? { embed: opts.embed } : {}), ...(opts.ttlSeconds !== undefined ? { ttl_seconds: opts.ttlSeconds } : {}), ...(opts.path !== undefined ? { path: opts.path } : {}) } }, this.#ctx.authorization);
|
|
51
51
|
return { url: body.url, expiresAt: body.expires_at };
|
|
52
52
|
}
|
|
53
53
|
/** Creates the port's callback URL, or replaces it (the previous one stops working). Its secret is shown only here. */
|
package/dist/progress.d.ts
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import type { components } from './generated/app-api.js';
|
|
19
19
|
type Operation = components['schemas']['Operation'];
|
|
20
20
|
/** The SDK call a trace follows. `wait` is a direct waitForOperation(); `token` a tool token fetched for tool calls. */
|
|
21
|
-
export type LifecycleAction = 'open' | 'suspend' | 'resume' | 'snapshot' | 'fork' | 'delete' | 'close' | 'reset' | 'resize' | 'wake' | 'wait' | 'token';
|
|
21
|
+
export type LifecycleAction = 'open' | 'suspend' | 'resume' | 'snapshot' | 'fork' | 'delete' | 'close' | 'reset' | 'resize' | 'upgrade' | 'wake' | 'wait' | 'token';
|
|
22
22
|
/**
|
|
23
23
|
* - `request`: an API request that starts or joins the operation. A held open (`Prefer: wait`) spends the server's
|
|
24
24
|
* hold here (reason `held`), so the states inside it show only in the server timing.
|
|
@@ -160,7 +160,7 @@ export interface LostSuspend {
|
|
|
160
160
|
*/
|
|
161
161
|
export type ColdBootReason = (typeof COLD_BOOT_REASONS)[number] | (string & {});
|
|
162
162
|
/** Every {@link ColdBootReason} this version knows (0.14.0+). */
|
|
163
|
-
export declare const COLD_BOOT_REASONS: readonly ["runtime_changed", "host_lost", "runtime_retired"];
|
|
163
|
+
export declare const COLD_BOOT_REASONS: readonly ["runtime_changed", "host_lost", "runtime_retired", "upgraded"];
|
|
164
164
|
/**
|
|
165
165
|
* `result.host_lost` (0.13.1+), camelCased: the machine the workspace ran on failed. The workspace was moved to
|
|
166
166
|
* `suspended` at that moment, and its next use (a resume, a tool call's wake, an open) restored it. See the lifecycle
|
package/dist/progress.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Every {@link ColdBootReason} this version knows (0.14.0+). */
|
|
2
|
-
export const COLD_BOOT_REASONS = ['runtime_changed', 'host_lost', 'runtime_retired'];
|
|
2
|
+
export const COLD_BOOT_REASONS = ['runtime_changed', 'host_lost', 'runtime_retired', 'upgraded'];
|
|
3
3
|
const DURABILITY_STATES = new Set(['pending', 'durable', 'lost']);
|
|
4
4
|
/**
|
|
5
5
|
* The durable copy of a suspend or fork operation (0.12.0+): `result.durability` camelCased, or null when the result has
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** In-memory transport for the real SDK. Import only from @shardflux/sdk/testing. */
|
|
2
|
+
import { Shardflux } from '../client.js';
|
|
3
|
+
import type { WorkspaceView } from '../client.js';
|
|
4
|
+
import type { ExecStartRequest } from '../cell.js';
|
|
5
|
+
export interface FakeExecResult {
|
|
6
|
+
stdout?: string;
|
|
7
|
+
stderr?: string;
|
|
8
|
+
exitCode?: number;
|
|
9
|
+
termSignal?: number;
|
|
10
|
+
timedOut?: boolean;
|
|
11
|
+
canceled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface FakeWorkspaceFaults {
|
|
14
|
+
busy?: boolean;
|
|
15
|
+
deleted?: boolean;
|
|
16
|
+
failed?: boolean;
|
|
17
|
+
legacyLayout?: boolean;
|
|
18
|
+
computerUnavailable?: boolean;
|
|
19
|
+
resizeRefusal?: 'shrink_not_supported' | 'resize_not_available' | null;
|
|
20
|
+
/** A plan clamps the requested size; it does not invent a validation error. */
|
|
21
|
+
memoryLimitMib?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface FakeShardfluxOptions {
|
|
24
|
+
/** Explicit command results. null leaves a command running until testing.completeCommand(). */
|
|
25
|
+
onExec?: (request: ExecStartRequest, workspace: WorkspaceView) => FakeExecResult | null;
|
|
26
|
+
nowMs?: number;
|
|
27
|
+
latencyMs?: number;
|
|
28
|
+
/** Replace the latency wait, e.g. advance a test runner's clock. */
|
|
29
|
+
sleep?: (ms: number) => Promise<void>;
|
|
30
|
+
quota?: 'retained_state' | 'concurrent_workspaces' | null;
|
|
31
|
+
faults?: FakeWorkspaceFaults;
|
|
32
|
+
templates?: Record<string, {
|
|
33
|
+
desktop: boolean;
|
|
34
|
+
memoryMib?: number;
|
|
35
|
+
cpuMillis?: number;
|
|
36
|
+
diskGib?: number;
|
|
37
|
+
}>;
|
|
38
|
+
}
|
|
39
|
+
export declare class FakeUnsupportedError extends Error {
|
|
40
|
+
constructor(operation: string);
|
|
41
|
+
}
|
|
42
|
+
/** Controls are separate from the customer client surface; inspect() returns a copy. */
|
|
43
|
+
export declare class FakeShardfluxTesting {
|
|
44
|
+
#private;
|
|
45
|
+
readonly requests: {
|
|
46
|
+
method: string;
|
|
47
|
+
path: string;
|
|
48
|
+
query: string;
|
|
49
|
+
}[];
|
|
50
|
+
quota: FakeShardfluxOptions['quota'];
|
|
51
|
+
latencyMs: number;
|
|
52
|
+
constructor(options: FakeShardfluxOptions);
|
|
53
|
+
inspect(id: string): WorkspaceView;
|
|
54
|
+
setFaults(id: string, faults: FakeWorkspaceFaults): void;
|
|
55
|
+
advance(ms: number): void;
|
|
56
|
+
completeCommand(id: string, sessionId: string, result?: FakeExecResult): void;
|
|
57
|
+
readonly fetch: typeof fetch;
|
|
58
|
+
}
|
|
59
|
+
/** A real Shardflux client using an isolated in-memory HTTP transport; no request reaches the network. */
|
|
60
|
+
export declare function createFakeShardflux(options?: FakeShardfluxOptions): Shardflux & {
|
|
61
|
+
testing: FakeShardfluxTesting;
|
|
62
|
+
};
|