@synsci/sdk 2.0.77 → 2.0.78-test.34095579610

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.
@@ -0,0 +1,18 @@
1
+ /**
2
+ * JSON-friendly union that mirrors what Pinia Colada can hash.
3
+ */
4
+ export type JsonValue = null | string | number | boolean | JsonValue[] | {
5
+ [key: string]: JsonValue;
6
+ };
7
+ /**
8
+ * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
9
+ */
10
+ export declare const queryKeyJsonReplacer: (_key: string, value: unknown) => {} | null | undefined;
11
+ /**
12
+ * Safely stringifies a value and parses it back into a JsonValue.
13
+ */
14
+ export declare const stringifyToJsonValue: (input: unknown) => JsonValue | undefined;
15
+ /**
16
+ * Normalizes any accepted value into a JSON-friendly shape for query keys.
17
+ */
18
+ export declare const serializeQueryKeyValue: (value: unknown) => JsonValue | undefined;
@@ -0,0 +1,93 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ /**
3
+ * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
4
+ */
5
+ export const queryKeyJsonReplacer = (_key, value) => {
6
+ if (value === undefined || typeof value === "function" || typeof value === "symbol") {
7
+ return undefined;
8
+ }
9
+ if (typeof value === "bigint") {
10
+ return value.toString();
11
+ }
12
+ if (value instanceof Date) {
13
+ return value.toISOString();
14
+ }
15
+ return value;
16
+ };
17
+ /**
18
+ * Safely stringifies a value and parses it back into a JsonValue.
19
+ */
20
+ export const stringifyToJsonValue = (input) => {
21
+ try {
22
+ const json = JSON.stringify(input, queryKeyJsonReplacer);
23
+ if (json === undefined) {
24
+ return undefined;
25
+ }
26
+ return JSON.parse(json);
27
+ }
28
+ catch {
29
+ return undefined;
30
+ }
31
+ };
32
+ /**
33
+ * Detects plain objects (including objects with a null prototype).
34
+ */
35
+ const isPlainObject = (value) => {
36
+ if (value === null || typeof value !== "object") {
37
+ return false;
38
+ }
39
+ const prototype = Object.getPrototypeOf(value);
40
+ return prototype === Object.prototype || prototype === null;
41
+ };
42
+ /**
43
+ * Turns URLSearchParams into a sorted JSON object for deterministic keys.
44
+ */
45
+ const serializeSearchParams = (params) => {
46
+ const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b));
47
+ const result = {};
48
+ for (const [key, value] of entries) {
49
+ const existing = result[key];
50
+ if (existing === undefined) {
51
+ result[key] = value;
52
+ continue;
53
+ }
54
+ if (Array.isArray(existing)) {
55
+ ;
56
+ existing.push(value);
57
+ }
58
+ else {
59
+ result[key] = [existing, value];
60
+ }
61
+ }
62
+ return result;
63
+ };
64
+ /**
65
+ * Normalizes any accepted value into a JSON-friendly shape for query keys.
66
+ */
67
+ export const serializeQueryKeyValue = (value) => {
68
+ if (value === null) {
69
+ return null;
70
+ }
71
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
72
+ return value;
73
+ }
74
+ if (value === undefined || typeof value === "function" || typeof value === "symbol") {
75
+ return undefined;
76
+ }
77
+ if (typeof value === "bigint") {
78
+ return value.toString();
79
+ }
80
+ if (value instanceof Date) {
81
+ return value.toISOString();
82
+ }
83
+ if (Array.isArray(value)) {
84
+ return stringifyToJsonValue(value);
85
+ }
86
+ if (typeof URLSearchParams !== "undefined" && value instanceof URLSearchParams) {
87
+ return serializeSearchParams(value);
88
+ }
89
+ if (isPlainObject(value)) {
90
+ return stringifyToJsonValue(value);
91
+ }
92
+ return undefined;
93
+ };
@@ -6,6 +6,7 @@ export declare function createOpenScience(options?: ServerOptions): Promise<{
6
6
  client: import("./client.js").OpenScienceClient;
7
7
  server: {
8
8
  url: string;
9
- close(): void;
9
+ pid: number;
10
+ close: () => Promise<void>;
10
11
  };
11
12
  }>;
package/dist/src/index.js CHANGED
@@ -3,11 +3,14 @@ export * from "./server.js";
3
3
  export * from "./v2/runtime.js";
4
4
  import { createOpenScienceClient } from "./client.js";
5
5
  import { createOpenScienceServer } from "./server.js";
6
+ import { serverClientOptions } from "./server-process.js";
6
7
  export async function createOpenScience(options) {
8
+ const connection = serverClientOptions(options);
7
9
  const server = await createOpenScienceServer({
8
10
  ...options,
9
11
  });
10
12
  const client = createOpenScienceClient({
13
+ ...connection,
11
14
  baseUrl: server.url,
12
15
  });
13
16
  return {
@@ -0,0 +1,36 @@
1
+ export type ServerProcessOptions = {
2
+ /** The runtime is loopback-only. Other hostnames are rejected. */
3
+ hostname?: string;
4
+ port?: number;
5
+ signal?: AbortSignal;
6
+ /** Maximum time to start and pass the health check, in milliseconds. */
7
+ timeout?: number;
8
+ /** Grace period before an owned child is forcibly terminated. */
9
+ shutdownTimeout?: number;
10
+ executablePath?: string;
11
+ /** Arguments before `serve`, for example a Bun executable's source entrypoint. */
12
+ executableArgs?: string[];
13
+ cwd?: string;
14
+ /** Overrides inherited environment; undefined removes a variable. */
15
+ env?: Record<string, string | undefined>;
16
+ };
17
+ type Options = ServerProcessOptions & {
18
+ config?: {
19
+ logLevel?: string;
20
+ };
21
+ };
22
+ /** Snapshot the same connection scope and credential inherited by an owned child. */
23
+ export declare function serverClientOptions(options?: ServerProcessOptions): {
24
+ directory: string;
25
+ headers: {
26
+ authorization: string;
27
+ } | undefined;
28
+ };
29
+ /** Own exactly the child started here. Connecting a client to an existing
30
+ * server uses createOpenScienceClient and never enters this lifecycle. */
31
+ export declare function startServer(options?: Options): Promise<{
32
+ url: string;
33
+ pid: number;
34
+ close: () => Promise<void>;
35
+ }>;
36
+ export {};
@@ -0,0 +1,199 @@
1
+ import { spawn } from "node:child_process";
2
+ import path from "node:path";
3
+ /** Snapshot the same connection scope and credential inherited by an owned child. */
4
+ export function serverClientOptions(options = {}) {
5
+ const env = { ...process.env, ...options.env };
6
+ const token = env.OPENSCIENCE_AUTH_TOKEN;
7
+ return {
8
+ directory: path.resolve(options.cwd ?? process.cwd()),
9
+ headers: token ? { authorization: `Bearer ${token}` } : undefined,
10
+ };
11
+ }
12
+ function localURL(value) {
13
+ const url = new URL(value);
14
+ if (url.protocol !== "http:" ||
15
+ !["localhost", "127.0.0.1", "[::1]"].includes(url.hostname) ||
16
+ url.username ||
17
+ url.password ||
18
+ url.pathname !== "/" ||
19
+ url.search ||
20
+ url.hash) {
21
+ throw new Error("OpenScience announced an invalid local server URL");
22
+ }
23
+ return url.origin;
24
+ }
25
+ /** Own exactly the child started here. Connecting a client to an existing
26
+ * server uses createOpenScienceClient and never enters this lifecycle. */
27
+ export async function startServer(options = {}) {
28
+ options.signal?.throwIfAborted();
29
+ if (options.hostname && !["127.0.0.1", "localhost"].includes(options.hostname)) {
30
+ throw new Error("OpenScience servers can only bind to loopback");
31
+ }
32
+ const timeout = options.timeout ?? 5000;
33
+ const shutdown = options.shutdownTimeout ?? 10_000;
34
+ if (!Number.isFinite(timeout) || timeout <= 0 || !Number.isFinite(shutdown) || shutdown <= 0) {
35
+ throw new Error("Server startup and shutdown timeouts must be positive finite milliseconds");
36
+ }
37
+ const port = options.port ?? 4096;
38
+ if (!Number.isInteger(port) || port < 0 || port > 65535)
39
+ throw new Error("Invalid OpenScience server port");
40
+ const env = {
41
+ ...process.env,
42
+ ...options.env,
43
+ OPENSCIENCE_SERVER_READY_FORMAT: "json",
44
+ };
45
+ const args = [...(options.executableArgs ?? []), "serve", "--port", String(port)];
46
+ if (options.config?.logLevel)
47
+ args.push("--log-level", options.config.logLevel);
48
+ const proc = spawn(options.executablePath ?? "openscience", args, {
49
+ cwd: options.cwd,
50
+ env: {
51
+ ...env,
52
+ OPENSCIENCE_CONFIG_CONTENT: options.config === undefined ? (env.OPENSCIENCE_CONFIG_CONTENT ?? "{}") : JSON.stringify(options.config),
53
+ },
54
+ stdio: ["ignore", "pipe", "pipe"],
55
+ });
56
+ const state = {
57
+ exited: false,
58
+ announced: false,
59
+ buffer: "",
60
+ output: "",
61
+ closing: undefined,
62
+ };
63
+ const exited = new Promise((resolve) => {
64
+ proc.once("close", () => {
65
+ state.exited = true;
66
+ options.signal?.removeEventListener("abort", abort);
67
+ resolve();
68
+ });
69
+ });
70
+ const wait = async (duration) => {
71
+ const timer = { id: undefined };
72
+ try {
73
+ await Promise.race([
74
+ exited,
75
+ new Promise((resolve) => {
76
+ timer.id = setTimeout(resolve, duration);
77
+ }),
78
+ ]);
79
+ }
80
+ finally {
81
+ if (timer.id)
82
+ clearTimeout(timer.id);
83
+ }
84
+ };
85
+ const close = () => {
86
+ state.closing ??= (async () => {
87
+ if (state.exited)
88
+ return;
89
+ proc.kill("SIGTERM");
90
+ await wait(shutdown);
91
+ if (state.exited)
92
+ return;
93
+ proc.kill("SIGKILL");
94
+ await wait(Math.max(1000, shutdown));
95
+ if (!state.exited)
96
+ throw new Error("OpenScience child did not exit after forced shutdown");
97
+ })();
98
+ return state.closing;
99
+ };
100
+ const controller = new AbortController();
101
+ const timer = { id: undefined };
102
+ const abort = () => controller.abort(options.signal?.reason);
103
+ options.signal?.addEventListener("abort", abort, { once: true });
104
+ if (options.signal?.aborted)
105
+ abort();
106
+ try {
107
+ const url = await new Promise((resolve, reject) => {
108
+ const fail = (error) => reject(error);
109
+ proc.on("error", fail);
110
+ controller.signal.addEventListener("abort", () => fail(controller.signal.reason), { once: true });
111
+ if (controller.signal.aborted)
112
+ return fail(controller.signal.reason);
113
+ timer.id = setTimeout(() => controller.abort(new Error(`Timeout waiting for server to start after ${timeout}ms`)), timeout);
114
+ proc.once("exit", (code, signal) => {
115
+ fail(new Error(`OpenScience server exited before becoming ready (${signal ?? code})${state.output ? `\n${state.output}` : ""}`));
116
+ });
117
+ const check = async (value) => {
118
+ const url = localURL(value);
119
+ const token = env.OPENSCIENCE_AUTH_TOKEN;
120
+ const response = await fetch(`${url}/global/health`, {
121
+ signal: controller.signal,
122
+ redirect: "error",
123
+ headers: token ? { authorization: `Bearer ${token}` } : undefined,
124
+ });
125
+ const health = await response.json();
126
+ if (!response.ok ||
127
+ !health ||
128
+ typeof health !== "object" ||
129
+ !("healthy" in health) ||
130
+ health.healthy !== true ||
131
+ !("version" in health) ||
132
+ typeof health.version !== "string") {
133
+ throw new Error("OpenScience server did not pass its health check");
134
+ }
135
+ return url;
136
+ };
137
+ proc.stdout.on("data", (chunk) => {
138
+ if (state.announced)
139
+ return;
140
+ state.buffer += chunk.toString();
141
+ const lines = state.buffer.split("\n");
142
+ state.buffer = (lines.pop() ?? "").slice(-65_536);
143
+ for (const line of lines) {
144
+ try {
145
+ const value = (() => {
146
+ if (line.startsWith("{")) {
147
+ const value = JSON.parse(line);
148
+ if (!value || typeof value !== "object" || !("type" in value) || value.type !== "server.ready")
149
+ return;
150
+ if (!("schemaVersion" in value) ||
151
+ value.schemaVersion !== 1 ||
152
+ !("url" in value) ||
153
+ typeof value.url !== "string") {
154
+ throw new Error("Unsupported OpenScience server readiness record");
155
+ }
156
+ if (!("pid" in value) || value.pid !== proc.pid)
157
+ throw new Error("OpenScience server readiness process mismatch");
158
+ return value.url;
159
+ }
160
+ // Older runtimes ignore the readiness environment option. Their
161
+ // human announcement remains supported, followed by the same probe.
162
+ return line.match(/^openscience server listening on\s+(https?:\/\/[^\s]+)/)?.[1];
163
+ })();
164
+ if (!value)
165
+ continue;
166
+ state.announced = true;
167
+ void check(value).then(resolve, fail);
168
+ break;
169
+ }
170
+ catch (error) {
171
+ fail(error);
172
+ }
173
+ }
174
+ });
175
+ proc.stderr.on("data", (chunk) => {
176
+ state.output = (state.output + chunk.toString()).slice(-8192);
177
+ });
178
+ });
179
+ // Abort continues to own shutdown after startup; attached clients have no
180
+ // corresponding child or signal hook.
181
+ controller.signal.addEventListener("abort", () => void close().catch(() => undefined), { once: true });
182
+ if (controller.signal.aborted) {
183
+ await close();
184
+ controller.signal.throwIfAborted();
185
+ }
186
+ return { url, pid: proc.pid, close };
187
+ }
188
+ catch (error) {
189
+ controller.abort(error);
190
+ await close().catch((cleanup) => {
191
+ throw new AggregateError([error, cleanup], "Server startup and cleanup failed");
192
+ });
193
+ throw error;
194
+ }
195
+ finally {
196
+ if (timer.id)
197
+ clearTimeout(timer.id);
198
+ }
199
+ }
@@ -1,12 +1,10 @@
1
- import { type Config } from "./gen/types.gen.js";
2
- export type ServerOptions = {
3
- hostname?: string;
4
- port?: number;
5
- signal?: AbortSignal;
6
- timeout?: number;
1
+ import type { Config } from "./gen/types.gen.js";
2
+ import { type ServerProcessOptions } from "./server-process.js";
3
+ export type ServerOptions = ServerProcessOptions & {
7
4
  config?: Config;
8
5
  };
9
6
  export declare function createOpenScienceServer(options?: ServerOptions): Promise<{
10
7
  url: string;
11
- close(): void;
8
+ pid: number;
9
+ close: () => Promise<void>;
12
10
  }>;
@@ -1,68 +1,4 @@
1
- import { spawn } from "node:child_process";
2
- export async function createOpenScienceServer(options) {
3
- options = Object.assign({
4
- hostname: "127.0.0.1",
5
- port: 4096,
6
- timeout: 5000,
7
- }, options ?? {});
8
- const args = [`serve`, `--port=${options.port}`];
9
- if (options.config?.logLevel)
10
- args.push(`--log-level=${options.config.logLevel}`);
11
- const proc = spawn(`openscience`, args, {
12
- signal: options.signal,
13
- env: {
14
- ...process.env,
15
- OPENSCIENCE_CONFIG_CONTENT: JSON.stringify(options.config ?? {}),
16
- },
17
- });
18
- const url = await new Promise((resolve, reject) => {
19
- const id = setTimeout(() => {
20
- reject(new Error(`Timeout waiting for server to start after ${options.timeout}ms`));
21
- }, options.timeout);
22
- let output = "";
23
- proc.stdout?.on("data", (chunk) => {
24
- output += chunk.toString();
25
- const lines = output.split("\n");
26
- for (const line of lines) {
27
- if (line.startsWith("openscience server listening")) {
28
- const match = line.match(/on\s+(https?:\/\/[^\s]+)/);
29
- if (!match) {
30
- clearTimeout(id);
31
- reject(new Error(`Failed to parse server url from output: ${line}`));
32
- return;
33
- }
34
- clearTimeout(id);
35
- resolve(match[1]);
36
- return;
37
- }
38
- }
39
- });
40
- proc.stderr?.on("data", (chunk) => {
41
- output += chunk.toString();
42
- });
43
- proc.on("exit", (code) => {
44
- clearTimeout(id);
45
- let msg = `Server exited with code ${code}`;
46
- if (output.trim()) {
47
- msg += `\nServer output: ${output}`;
48
- }
49
- reject(new Error(msg));
50
- });
51
- proc.on("error", (error) => {
52
- clearTimeout(id);
53
- reject(error);
54
- });
55
- if (options.signal) {
56
- options.signal.addEventListener("abort", () => {
57
- clearTimeout(id);
58
- reject(new Error("Aborted"));
59
- });
60
- }
61
- });
62
- return {
63
- url,
64
- close() {
65
- proc.kill();
66
- },
67
- };
1
+ import { startServer } from "./server-process.js";
2
+ export function createOpenScienceServer(options) {
3
+ return startServer(options);
68
4
  }
@@ -1,5 +1,5 @@
1
1
  import { type Client, type Options as Options2, type TDataShape } from "./client/index.js";
2
- import type { AccountBalanceResponses, AccountBillingModeGetResponses, AccountBillingModeSetResponses, AccountDeviceRevokeResponses, AccountDevicesResponses, AccountFundingContextGetResponses, AccountFundingContextSetErrors, AccountFundingContextSetResponses, AccountGetResponses, AccountLoginBrowserResponses, AccountLoginKeyResponses, AccountLogoutResponses, AccountSessionResponses, AgentPartInput, ApiAuth, AppAgentsResponses, AppLogErrors, AppLogResponses, AppSkillDeleteResponses, AppSkillsResponses, AppSkillWriteResponses, Auth as Auth3, AuthOnboardingErrors, AuthOnboardingResponses, AuthRemoveErrors, AuthRemoveResponses, AuthSetErrors, AuthSetResponses, CommandListResponses, Config as Config4, ConfigGetResponses, ConfigProvidersResponses, ConfigUpdateErrors, ConfigUpdateResponses, ConversationPartInput, EventSubscribeResponse, EventSubscribeResponses, ExperimentalResourceListResponses, FileAnnotationsCreateResponses, FileAnnotationsDeleteResponses, FileAnnotationsHistoryResponses, FileAnnotationsListResponses, FileAnnotationsUpdateResponses, FileArtifactSaveErrors, FileArtifactSaveResponses, FileArtifactsResponses, FileArtifactStoreGetErrors, FileArtifactStoreGetResponses, FileArtifactStoreListResponses, FileArtifactStoreRawErrors, FileArtifactStoreRawResponses, FileArtifactStoreRenameErrors, FileArtifactStoreRenameResponses, FileArtifactStoreRestoreErrors, FileArtifactStoreRestoreResponses, FileArtifactStoreTrashErrors, FileArtifactStoreTrashResponses, FileInspectResponses, FileLineageResponses, FileListResponses, FileManifestResponses, FilePartInput, FilePartSource, FileProvenanceResponses, FilePublicationCapabilitiesResponses, FilePublicationErrors, FilePublicationResponses, FileRawErrors, FileRawResponses, FileReadErrors, FileReadResponses, FileRenameErrors, FileRenameResponses, FileReproducibilityResponses, FileResolveReferenceErrors, FileResolveReferenceResponses, FileReviewsCurrentErrors, FileReviewsCurrentResponses, FileReviewsFinalizeErrors, FileReviewsFinalizeResponses, FileReviewsHistoryErrors, FileReviewsHistoryResponses, FileReviewsResolveErrors, FileReviewsResolveResponses, FileReviewsRunErrors, FileReviewsRunResponses, FileStatusResponses, FileTrashCreateErrors, FileTrashCreateResponses, FileTrashListResponses, FileTrashPurgeErrors, FileTrashPurgeResponses, FileTrashRestoreErrors, FileTrashRestoreResponses, FileWriteErrors, FileWriteResponses, FindFilesResponses, FindSymbolsResponses, FindTextResponses, FormatterStatusResponses, GlobalConfigGetResponses, GlobalConfigRawGetResponses, GlobalConfigRawSetErrors, GlobalConfigRawSetResponses, GlobalConfigUnsetErrors, GlobalConfigUnsetResponses, GlobalConfigUpdateErrors, GlobalConfigUpdateResponses, GlobalDisposeResponses, GlobalEventResponse, GlobalEventResponses, GlobalHealthResponses, GlobalProjectCreateErrors, GlobalProjectCreateResponses, InstanceDisposeResponses, KernelsCommandsResponses, KernelsCommandStopErrors, KernelsCommandStopResponses, KernelsComputeResponses, KernelsDeleteResponses, KernelsExecuteResponses, KernelsInterruptByIdResponses, KernelsInterruptResponses, KernelsListResponses, KernelsRestartByIdResponses, KernelsRestartResponses, KernelsStatusResponses, KernelsStopByIdResponses, KernelsStopResponses, LspStatusResponses, McpAddErrors, McpAddResponses, McpAuthAuthenticateErrors, McpAuthAuthenticateResponses, McpAuthCallbackErrors, McpAuthCallbackResponses, McpAuthCancelErrors, McpAuthCancelResponses, McpAuthPendingResponses, McpAuthRemoveErrors, McpAuthRemoveResponses, McpAuthStartErrors, McpAuthStartResponses, McpAuthWaitErrors, McpAuthWaitResponses, McpConfigRemoveErrors, McpConfigRemoveResponses, McpConfigSetErrors, McpConfigSetResponses, McpConnectResponses, McpDisconnectResponses, McpInspectErrors, McpInspectResponses, McpLocalConfig, McpRemoteConfig, McpStatusResponses, NotebookCommandsResponses, NotebookCommandStopErrors, NotebookCommandStopResponses, NotebookComputeResponses, NotebookExecuteResponses, NotebookInterruptResponses, NotebookKernelDeleteResponses, NotebookKernelInterruptResponses, NotebookKernelRestartResponses, NotebookKernelsResponses, NotebookKernelStopResponses, NotebookRestartResponses, NotebookStatusResponses, NotebookStopResponses, Part as Part2, PartDeleteErrors, PartDeleteResponses, PartUpdateErrors, PartUpdateResponses, PathGetResponses, PermissionListResponses, PermissionReplyErrors, PermissionReplyResponses, PermissionRespondErrors, PermissionRespondResponses, PermissionRuleset, PermissionStandingListResponses, PermissionStandingRevokeResponses, PostSettingsLocalContextResponses, PostSettingsLocalModelsResponses, PostSettingsLocalResponses, PostSettingsLocalSshResponses, PostSettingsLocalStartResponses, ProjectAccessGetErrors, ProjectAccessGetResponses, ProjectAccessUpdateErrors, ProjectAccessUpdateResponses, ProjectCurrentResponses, ProjectExecutionErrors, ProjectExecutionResponses, ProjectListResponses, ProjectTrustGetErrors, ProjectTrustGetResponses, ProjectTrustUpdateErrors, ProjectTrustUpdateResponses, ProjectUpdateErrors, ProjectUpdateResponses, ProvenanceExecutionsResponses, ProvenanceExportResponses, ProvenanceListResponses, ProvenanceRecordErrors, ProvenanceRecordResponses, ProvenanceReviewsListResponses, ProvenanceTraceErrors, ProvenanceTraceResponses, ProviderAuthResponses, ProviderListResponses, ProviderOauthAuthorizeErrors, ProviderOauthAuthorizeResponses, ProviderOauthCallbackErrors, ProviderOauthCallbackResponses, PtyConnectErrors, PtyConnectResponses, PtyCreateErrors, PtyCreateResponses, PtyGetErrors, PtyGetResponses, PtyListResponses, PtyRemoveErrors, PtyRemoveResponses, PtyUpdateErrors, PtyUpdateResponses, PutSettingsSandboxResponses, QuestionAnswer, QuestionListResponses, QuestionRejectErrors, QuestionRejectResponses, QuestionReplyErrors, QuestionReplyResponses, ResearchEffort, RuntimePromptErrors, RuntimePromptResponses, RuntimeReplayErrors, RuntimeReplayResponses, RuntimeSubscribeResponse, RuntimeSubscribeResponses, SearchQueryResponses, SessionAbortErrors, SessionAbortResponses, SessionChildrenErrors, SessionChildrenResponses, SessionCommandErrors, SessionCommandResponses, SessionCreateErrors, SessionCreateResponses, SessionDeleteErrors, SessionDeleteResponses, SessionDiffResponses, SessionFilesystemGrantErrors, SessionFilesystemGrantResponses, SessionFilesystemListErrors, SessionFilesystemListResponses, SessionFilesystemRevokeErrors, SessionFilesystemRevokeResponses, SessionForkResponses, SessionGetErrors, SessionGetResponses, SessionInitErrors, SessionInitResponses, SessionListResponses, SessionMessageErrors, SessionMessageResponses, SessionMessagesErrors, SessionMessagesResponses, SessionPromptAsyncErrors, SessionPromptAsyncResponses, SessionPromptErrors, SessionPromptResponses, SessionRevertErrors, SessionRevertResponses, SessionShellErrors, SessionShellResponses, SessionStatusErrors, SessionStatusResponses, SessionSummarizeErrors, SessionSummarizeResponses, SessionTodoErrors, SessionTodoResponses, SessionTraceErrors, SessionTraceResponses, SessionUnrevertErrors, SessionUnrevertResponses, SessionUpdateErrors, SessionUpdateResponses, SettingsBillingGetResponses, SettingsBillingUpdateResponses, SettingsComputeEnvironmentsRepairResponses, SettingsComputeGetResponses, SettingsComputeJobsCancelErrors, SettingsComputeJobsCancelResponses, SettingsComputeJobsClearResponses, SettingsComputeJobsEventsErrors, SettingsComputeJobsEventsResponses, SettingsComputeJobsListResponses, SettingsComputeJobsLogErrors, SettingsComputeJobsLogResponses, SettingsComputeJobsPlanErrors, SettingsComputeJobsPlanResponses, SettingsComputeJobsReleaseErrors, SettingsComputeJobsReleaseResponses, SettingsComputeJobsRetryErrors, SettingsComputeJobsRetryResponses, SettingsComputeJobsStartErrors, SettingsComputeJobsStartResponses, SettingsComputeModalCheckErrors, SettingsComputeModalCheckResponses, SettingsComputeModalConfigureErrors, SettingsComputeModalConfigureResponses, SettingsComputeModalUpdateErrors, SettingsComputeModalUpdateResponses, SettingsComputeModalVolumeFileErrors, SettingsComputeModalVolumeFileResponses, SettingsComputeModalVolumeFilesErrors, SettingsComputeModalVolumeFilesResponses, SettingsComputeModalVolumesErrors, SettingsComputeModalVolumesResponses, SettingsComputeProviderConnectErrors, SettingsComputeProviderConnectResponses, SettingsComputeProviderDisconnectResponses, SettingsComputeProviderDoctorErrors, SettingsComputeProviderDoctorResponses, SettingsComputeProviderEnabledErrors, SettingsComputeProviderEnabledResponses, SettingsComputeSshAddErrors, SettingsComputeSshAddResponses, SettingsComputeSshRemoveResponses, SettingsComputeSshTestErrors, SettingsComputeSshTestResponses, SettingsComputeSshUpdateErrors, SettingsComputeSshUpdateResponses, SettingsCredentialsListResponses, SettingsCredentialsRemoveResponses, SettingsCredentialsSetResponses, SettingsNetworkGetResponses, SettingsNetworkSetResponses, SettingsPreferencesClearOnboardingOperationResponses, SettingsPreferencesGetResponses, SettingsPreferencesOnboardingOperationResponses, SettingsPreferencesUpdateResponses, SettingsScientificToolSetupErrors, SettingsScientificToolSetupResponses, SettingsScientificToolsResponses, SettingsSkillsInstallErrors, SettingsSkillsInstallResponses, SettingsStorageClearCacheResponses, SettingsStorageRelocateErrors, SettingsStorageRelocateResponses, SettingsStorageResetLocationErrors, SettingsStorageResetLocationResponses, SettingsStorageUsageResponses, SettingsUpdatesApplyErrors, SettingsUpdatesApplyResponses, SettingsUpdatesCancelResponses, SettingsUpdatesCheckResponses, SettingsUpdatesDisposeErrors, SettingsUpdatesDisposeResponses, SettingsUpdatesInstallErrors, SettingsUpdatesInstallResponses, SettingsUpdatesStageResponses, SettingsUpdatesStateResponses, SettingsWalletGetResponses, SubtaskPartInput, TextPartInput, ToolIdsErrors, ToolIdsResponses, ToolListErrors, ToolListResponses, VcsGetResponses, WorktreeCreateErrors, WorktreeCreateInput, WorktreeCreateResponses, WorktreeListResponses, WorktreeRemoveErrors, WorktreeRemoveInput, WorktreeRemoveResponses, WorktreeResetErrors, WorktreeResetInput, WorktreeResetResponses } from "./types.gen.js";
2
+ import type { AccountBalanceResponses, AccountBillingModeGetResponses, AccountBillingModeSetResponses, AccountDeviceRevokeResponses, AccountDevicesResponses, AccountFundingContextGetResponses, AccountFundingContextSetErrors, AccountFundingContextSetResponses, AccountGetResponses, AccountLoginBrowserResponses, AccountLoginKeyResponses, AccountLogoutResponses, AccountSessionResponses, AgentPartInput, ApiAuth, AppAgentsResponses, AppLogErrors, AppLogResponses, AppSkillDeleteResponses, AppSkillsResponses, AppSkillWriteResponses, Auth as Auth3, AuthOnboardingErrors, AuthOnboardingResponses, AuthRemoveErrors, AuthRemoveResponses, AuthSetErrors, AuthSetResponses, CommandListResponses, Config as Config4, ConfigGetResponses, ConfigProvidersResponses, ConfigUpdateErrors, ConfigUpdateResponses, ConversationPartInput, EventSubscribeResponse, EventSubscribeResponses, ExperimentalResourceListResponses, FileAnnotationsCreateResponses, FileAnnotationsDeleteResponses, FileAnnotationsHistoryResponses, FileAnnotationsListResponses, FileAnnotationsUpdateResponses, FileArtifactSaveErrors, FileArtifactSaveResponses, FileArtifactsResponses, FileArtifactStoreGetErrors, FileArtifactStoreGetResponses, FileArtifactStoreListResponses, FileArtifactStoreRawErrors, FileArtifactStoreRawResponses, FileArtifactStoreRenameErrors, FileArtifactStoreRenameResponses, FileArtifactStoreRestoreErrors, FileArtifactStoreRestoreResponses, FileArtifactStoreTrashErrors, FileArtifactStoreTrashResponses, FileInspectResponses, FileLineageResponses, FileListResponses, FileManifestResponses, FilePartInput, FilePartSource, FileProvenanceResponses, FilePublicationCapabilitiesResponses, FilePublicationErrors, FilePublicationResponses, FileRawErrors, FileRawResponses, FileReadErrors, FileReadResponses, FileRenameErrors, FileRenameResponses, FileReproducibilityResponses, FileResolveReferenceErrors, FileResolveReferenceResponses, FileReviewsCurrentErrors, FileReviewsCurrentResponses, FileReviewsFinalizeErrors, FileReviewsFinalizeResponses, FileReviewsHistoryErrors, FileReviewsHistoryResponses, FileReviewsResolveErrors, FileReviewsResolveResponses, FileReviewsRunErrors, FileReviewsRunResponses, FileStatusResponses, FileTrashCreateErrors, FileTrashCreateResponses, FileTrashListResponses, FileTrashPurgeErrors, FileTrashPurgeResponses, FileTrashRestoreErrors, FileTrashRestoreResponses, FileWriteErrors, FileWriteResponses, FindFilesResponses, FindSymbolsResponses, FindTextResponses, FormatterStatusResponses, GlobalConfigGetResponses, GlobalConfigRawGetResponses, GlobalConfigRawSetErrors, GlobalConfigRawSetResponses, GlobalConfigUnsetErrors, GlobalConfigUnsetResponses, GlobalConfigUpdateErrors, GlobalConfigUpdateResponses, GlobalDisposeResponses, GlobalEventResponse, GlobalEventResponses, GlobalHealthResponses, GlobalProjectCreateErrors, GlobalProjectCreateResponses, InstanceDisposeResponses, KernelsCommandsResponses, KernelsCommandStopErrors, KernelsCommandStopResponses, KernelsComputeResponses, KernelsDeleteResponses, KernelsExecuteResponses, KernelsInterruptByIdResponses, KernelsInterruptResponses, KernelsListResponses, KernelsRestartByIdResponses, KernelsRestartResponses, KernelsStatusResponses, KernelsStopByIdResponses, KernelsStopResponses, LspStatusResponses, McpAddErrors, McpAddResponses, McpAuthAuthenticateErrors, McpAuthAuthenticateResponses, McpAuthCallbackErrors, McpAuthCallbackResponses, McpAuthCancelErrors, McpAuthCancelResponses, McpAuthPendingResponses, McpAuthRemoveErrors, McpAuthRemoveResponses, McpAuthStartErrors, McpAuthStartResponses, McpAuthWaitErrors, McpAuthWaitResponses, McpConfigRemoveErrors, McpConfigRemoveResponses, McpConfigSetErrors, McpConfigSetResponses, McpConnectResponses, McpDisconnectResponses, McpInspectErrors, McpInspectResponses, McpLocalConfig, McpRemoteConfig, McpStatusResponses, NotebookCommandsResponses, NotebookCommandStopErrors, NotebookCommandStopResponses, NotebookComputeResponses, NotebookExecuteResponses, NotebookInterruptResponses, NotebookKernelDeleteResponses, NotebookKernelInterruptResponses, NotebookKernelRestartResponses, NotebookKernelsResponses, NotebookKernelStopResponses, NotebookRestartResponses, NotebookStatusResponses, NotebookStopResponses, Part as Part2, PartDeleteErrors, PartDeleteResponses, PartUpdateErrors, PartUpdateResponses, PathGetResponses, PermissionListResponses, PermissionReplyErrors, PermissionReplyResponses, PermissionRespondErrors, PermissionRespondResponses, PermissionRuleset, PermissionStandingListResponses, PermissionStandingRevokeResponses, PostSettingsLocalContextResponses, PostSettingsLocalModelsResponses, PostSettingsLocalResponses, PostSettingsLocalSshResponses, PostSettingsLocalStartResponses, ProjectAccessGetErrors, ProjectAccessGetResponses, ProjectAccessUpdateErrors, ProjectAccessUpdateResponses, ProjectCurrentResponses, ProjectExecutionErrors, ProjectExecutionResponses, ProjectListResponses, ProjectTrustGetErrors, ProjectTrustGetResponses, ProjectTrustUpdateErrors, ProjectTrustUpdateResponses, ProjectUpdateErrors, ProjectUpdateResponses, ProvenanceExecutionsResponses, ProvenanceExportResponses, ProvenanceListResponses, ProvenanceRecordErrors, ProvenanceRecordResponses, ProvenanceReviewsListResponses, ProvenanceTraceErrors, ProvenanceTraceResponses, ProviderAuthResponses, ProviderListResponses, ProviderOauthAuthorizeErrors, ProviderOauthAuthorizeResponses, ProviderOauthCallbackErrors, ProviderOauthCallbackResponses, PtyConnectErrors, PtyConnectResponses, PtyCreateErrors, PtyCreateResponses, PtyGetErrors, PtyGetResponses, PtyListResponses, PtyRemoveErrors, PtyRemoveResponses, PtyUpdateErrors, PtyUpdateResponses, PutSettingsSandboxResponses, QuestionAnswer, QuestionListResponses, QuestionRejectErrors, QuestionRejectResponses, QuestionReplyErrors, QuestionReplyResponses, ResearchEffort, RuntimeCancelErrors, RuntimeCancelResponses, RuntimeCapabilitiesResponses, RuntimeDecideErrors, RuntimeDecideResponses, RuntimeDecisionInput, RuntimeGetRunErrors, RuntimeGetRunResponses, RuntimePromptErrors, RuntimePromptResponses, RuntimeReplayErrors, RuntimeReplayResponses, RuntimeSnapshotErrors, RuntimeSnapshotResponses, RuntimeSubscribeResponse, RuntimeSubscribeResponses, SearchQueryResponses, SessionAbortErrors, SessionAbortResponses, SessionChildrenErrors, SessionChildrenResponses, SessionCommandErrors, SessionCommandResponses, SessionCreateErrors, SessionCreateResponses, SessionDeleteErrors, SessionDeleteResponses, SessionDiffResponses, SessionFilesystemGrantErrors, SessionFilesystemGrantResponses, SessionFilesystemListErrors, SessionFilesystemListResponses, SessionFilesystemRevokeErrors, SessionFilesystemRevokeResponses, SessionForkResponses, SessionGetErrors, SessionGetResponses, SessionInitErrors, SessionInitResponses, SessionListResponses, SessionMessageErrors, SessionMessageResponses, SessionMessagesErrors, SessionMessagesResponses, SessionPromptAsyncErrors, SessionPromptAsyncResponses, SessionPromptErrors, SessionPromptResponses, SessionRevertErrors, SessionRevertResponses, SessionShellErrors, SessionShellResponses, SessionStatusErrors, SessionStatusResponses, SessionSummarizeErrors, SessionSummarizeResponses, SessionTodoErrors, SessionTodoResponses, SessionTraceErrors, SessionTraceResponses, SessionUnrevertErrors, SessionUnrevertResponses, SessionUpdateErrors, SessionUpdateResponses, SettingsBillingGetResponses, SettingsBillingUpdateResponses, SettingsComputeEnvironmentsRepairResponses, SettingsComputeGetResponses, SettingsComputeJobsCancelErrors, SettingsComputeJobsCancelResponses, SettingsComputeJobsClearResponses, SettingsComputeJobsEventsErrors, SettingsComputeJobsEventsResponses, SettingsComputeJobsListResponses, SettingsComputeJobsLogErrors, SettingsComputeJobsLogResponses, SettingsComputeJobsPlanErrors, SettingsComputeJobsPlanResponses, SettingsComputeJobsReleaseErrors, SettingsComputeJobsReleaseResponses, SettingsComputeJobsRetryErrors, SettingsComputeJobsRetryResponses, SettingsComputeJobsStartErrors, SettingsComputeJobsStartResponses, SettingsComputeModalCheckErrors, SettingsComputeModalCheckResponses, SettingsComputeModalConfigureErrors, SettingsComputeModalConfigureResponses, SettingsComputeModalUpdateErrors, SettingsComputeModalUpdateResponses, SettingsComputeModalVolumeFileErrors, SettingsComputeModalVolumeFileResponses, SettingsComputeModalVolumeFilesErrors, SettingsComputeModalVolumeFilesResponses, SettingsComputeModalVolumesErrors, SettingsComputeModalVolumesResponses, SettingsComputeProviderConnectErrors, SettingsComputeProviderConnectResponses, SettingsComputeProviderDisconnectResponses, SettingsComputeProviderDoctorErrors, SettingsComputeProviderDoctorResponses, SettingsComputeProviderEnabledErrors, SettingsComputeProviderEnabledResponses, SettingsComputeSshAddErrors, SettingsComputeSshAddResponses, SettingsComputeSshRemoveResponses, SettingsComputeSshTestErrors, SettingsComputeSshTestResponses, SettingsComputeSshUpdateErrors, SettingsComputeSshUpdateResponses, SettingsCredentialsListResponses, SettingsCredentialsRemoveResponses, SettingsCredentialsSetResponses, SettingsNetworkGetResponses, SettingsNetworkSetResponses, SettingsPreferencesClearOnboardingOperationResponses, SettingsPreferencesGetResponses, SettingsPreferencesOnboardingOperationResponses, SettingsPreferencesUpdateResponses, SettingsScientificToolSetupErrors, SettingsScientificToolSetupResponses, SettingsScientificToolsResponses, SettingsSkillsInstallErrors, SettingsSkillsInstallResponses, SettingsStorageClearCacheResponses, SettingsStorageRelocateErrors, SettingsStorageRelocateResponses, SettingsStorageResetLocationErrors, SettingsStorageResetLocationResponses, SettingsStorageUsageResponses, SettingsUpdatesApplyErrors, SettingsUpdatesApplyResponses, SettingsUpdatesCancelResponses, SettingsUpdatesCheckResponses, SettingsUpdatesDisposeErrors, SettingsUpdatesDisposeResponses, SettingsUpdatesInstallErrors, SettingsUpdatesInstallResponses, SettingsUpdatesStageResponses, SettingsUpdatesStateResponses, SettingsWalletGetResponses, SubtaskPartInput, TextPartInput, ToolIdsErrors, ToolIdsResponses, ToolListErrors, ToolListResponses, VcsGetResponses, WorktreeCreateErrors, WorktreeCreateInput, WorktreeCreateResponses, WorktreeListResponses, WorktreeRemoveErrors, WorktreeRemoveInput, WorktreeRemoveResponses, WorktreeResetErrors, WorktreeResetInput, WorktreeResetResponses } from "./types.gen.js";
3
3
  export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
4
4
  /**
5
5
  * You can provide a client instance returned by `createClient()` instead of
@@ -1019,6 +1019,7 @@ export declare class Session extends HeyApiClient {
1019
1019
  parentID?: string;
1020
1020
  title?: string;
1021
1021
  permission?: PermissionRuleset;
1022
+ workspace?: "isolated" | "project";
1022
1023
  }, options?: Options<never, ThrowOnError>): import("./client/types.gen.js").RequestResult<SessionCreateResponses, SessionCreateErrors, ThrowOnError, "fields">;
1023
1024
  /**
1024
1025
  * Get session status
@@ -1386,9 +1387,72 @@ export declare class Runtime extends HeyApiClient {
1386
1387
  prompt<ThrowOnError extends boolean = false>(parameters: {
1387
1388
  directory?: string;
1388
1389
  sessionID: string;
1389
- message: string;
1390
+ messageID?: string;
1391
+ model?: {
1392
+ providerID: string;
1393
+ modelID: string;
1394
+ };
1395
+ variant?: string;
1396
+ tier?: string;
1397
+ context?: number;
1398
+ delegation?: boolean;
1399
+ delegationSettings?: {
1400
+ level?: "off" | "light" | "standard" | "high";
1401
+ workerModel?: {
1402
+ providerID: string;
1403
+ modelID: string;
1404
+ };
1405
+ autonomy?: "interactive" | "balanced" | "autonomous";
1406
+ };
1407
+ requestID?: string;
1408
+ message?: string;
1409
+ parts?: Array<TextPartInput | FilePartInput | AgentPartInput | ConversationPartInput | SubtaskPartInput>;
1390
1410
  effort: "normal" | "ultra";
1391
1411
  }, options?: Options<never, ThrowOnError>): import("./client/types.gen.js").RequestResult<RuntimePromptResponses, RuntimePromptErrors, ThrowOnError, "fields">;
1412
+ /**
1413
+ * Cancel one research run
1414
+ *
1415
+ * Cancellation is scoped to the run ID. Repeating it cannot stop a later run. Running tools may need time to settle; read the run receipt for terminal state.
1416
+ */
1417
+ cancel<ThrowOnError extends boolean = false>(parameters: {
1418
+ directory?: string;
1419
+ sessionID: string;
1420
+ runID: string;
1421
+ }, options?: Options<never, ThrowOnError>): import("./client/types.gen.js").RequestResult<RuntimeCancelResponses, RuntimeCancelErrors, ThrowOnError, "fields">;
1422
+ /**
1423
+ * Resolve a pending runtime decision
1424
+ *
1425
+ * Retries of an identical decision return its stored receipt. A conflicting response is rejected. Only live requests on the connected runtime can be resolved; an indeterminate receipt requires inspecting current state rather than repeating the action.
1426
+ */
1427
+ decide<ThrowOnError extends boolean = false>(parameters?: {
1428
+ directory?: string;
1429
+ runtimeDecisionInput?: RuntimeDecisionInput;
1430
+ }, options?: Options<never, ThrowOnError>): import("./client/types.gen.js").RequestResult<RuntimeDecideResponses, RuntimeDecideErrors, ThrowOnError, "fields">;
1431
+ /**
1432
+ * Get supported runtime protocol
1433
+ */
1434
+ capabilities<ThrowOnError extends boolean = false>(parameters?: {
1435
+ directory?: string;
1436
+ }, options?: Options<never, ThrowOnError>): import("./client/types.gen.js").RequestResult<RuntimeCapabilitiesResponses, unknown, ThrowOnError, "fields">;
1437
+ /**
1438
+ * Get a durable research run
1439
+ *
1440
+ * Returns the authoritative run receipt and terminal result reference, independently of event retention. A dead runtime is interrupted and never automatically retried.
1441
+ */
1442
+ getRun<ThrowOnError extends boolean = false>(parameters: {
1443
+ directory?: string;
1444
+ sessionID: string;
1445
+ runID: string;
1446
+ }, options?: Options<never, ThrowOnError>): import("./client/types.gen.js").RequestResult<RuntimeGetRunResponses, RuntimeGetRunErrors, ThrowOnError, "fields">;
1447
+ /**
1448
+ * Resynchronize a research session
1449
+ *
1450
+ * Returns durable run receipts, an event cursor and live pending decisions belonging to this server process. Replayed decision events are historical; only pending requests in a fresh snapshot are actionable.
1451
+ */
1452
+ snapshot<ThrowOnError extends boolean = false>(parameters: {
1453
+ directory?: string;
1454
+ sessionID: string;
1455
+ }, options?: Options<never, ThrowOnError>): import("./client/types.gen.js").RequestResult<RuntimeSnapshotResponses, RuntimeSnapshotErrors, ThrowOnError, "fields">;
1392
1456
  /**
1393
1457
  * Replay research run events
1394
1458
  *