@pstdio/sdk 0.40.0 → 0.42.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/README.md +1 -1
- package/dist/api/index.js +454 -31
- package/dist/api.d.ts +4 -4
- package/dist/client/index.js +203 -24
- package/dist/client.d.ts +2 -2
- package/dist/data.d.ts +1 -1
- package/dist/extensions/index.js +313 -18
- package/dist/extensions.d.ts +2 -2
- package/dist/hooks.d.ts +4 -4
- package/dist/{index-BU8PNmuX.d.ts → index-CBZam0c-.d.ts} +1 -1
- package/dist/index-COPyc9eO.d.ts +644 -0
- package/dist/index-DKb6w-4h.d.ts +15865 -0
- package/dist/resources/index.js +451 -30
- package/dist/resources.d.ts +2 -2
- package/dist/sessions-D3MhZWKe.d.ts +2 -0
- package/dist/skills-D3MhZWKe.d.ts +2 -0
- package/dist/testing/index.js +60 -3
- package/dist/testing.d.ts +15 -4
- package/package.json +1 -1
- package/dist/index-1twOhV2h.d.ts +0 -434
- package/dist/index-Cbt2YiR-.d.ts +0 -8336
- package/dist/sessions-46B897Gi.d.ts +0 -2
- package/dist/skills-46B897Gi.d.ts +0 -2
package/dist/api.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import "./sessions-
|
|
3
|
-
import "./skills-
|
|
1
|
+
import { $ as WorkbenchExtensionAutomationRecord, A as InstallExtensionRequest, B as UpgradeProjectExtensionResponse, Bd as ListNotificationsResponse, C as ExtensionSettingsPanelRecord, Cd as BoardViewUpdate, D as ExtensionCommandPaletteResourceRecord, E as ExtensionKeybindingRecord, G as ExtensionConnectionRecord, Gd as NotificationOrigin, H as CommandExecuteResponse, Hd as NotificationAction, I as InstallMarketplaceExtensionResponse, J as ExtensionRecord, Jd as UpdateNotificationInput, K as ListExtensionConnectionsResponse, Kd as NotificationPriority, L as ListProjectExtensionsResponse, Ld as UpdateSkillInput, M as InstalledExtensionSource, N as AddLocalExtensionFolderResponse, O as WorkbenchExtensionCommandPaletteResourceRecord, Q as ExtensionMenuContribution, Qu as FollowUpInput, R as MarketplaceExtension, Rd as CreateNotificationInput, S as ExtensionSettingValueRecord, Sd as BoardViewCreate, T as UpdateExtensionSettingRequest, Ud as NotificationActorType, V as CommandExecuteRequest, Vd as Notification, W as ConfigureExtensionConnectionInput, Wd as NotificationKind, X as ExtensionCommandPaletteContribution, Xu as CreateSessionInput, Y as LocalizableString, Yu as ApprovalInput, Z as ExtensionCommandRecord, _ as CreateProjectInput, _d as UpdateQueuedFollowUpInput, _f as TerminalSessionOperation, _t as ListAutomationTokensResponse, a as RemoveWorktreeResponse$1, ad as SessionAttachment, af as ResourceRef, at as WorkbenchExtensionMetadata, bd as BoardSummary, c as WorkspaceFileContent$1, cd as SessionConversationSources, ct as AutomationRun, dd as CombineQueuedFollowUpsInput, dt as AutomationRunStatus, et as findViewFilterProblem, f as WorkspaceProviderDescriptor, fd as PendingQueuedFollowUpsResponse, ff as TerminalHostEvent, ft as AutomationTokenRecord, g as sessionAttachmentMimeTypesByExtension, gd as SteerQueuedFollowUpInput, gt as ListAutomationRunEventsResponse, h as UpdateSettingsInput, hd as QueuedSteeringResult, hf as TerminalSessionExit, ht as IssueAutomationTokenResponse, i as ListWorkspaceFilesInput$1, it as WorkbenchExtensionHarnessRecord, j as InstallExtensionResponse, k as ExtensionDiagnosticsResponse, l as WorkspaceFileEntry$1, ld as SessionQueuedMessagesResponse, lt as AutomationRunError, m as Settings, md as QueuedFollowUpUpdateResponse, mf as TerminalSessionError, mt as IssueAutomationTokenInput, nd as ResolveSessionIdInput, nt as ListExtensionAppearanceResponse, o as RenameWorkspaceInput$1, od as SessionAttachmentRef, ot as WorkbenchExtensionViewBody, p as WriteWorkspaceFileInput$1, pd as QueuedFollowUpRequest, pf as TerminalSessionAdapter, pt as CreateAutomationRunInput, q as ExtensionDiagnostic, qd as NotificationStatus, rd as ResolveSessionIdResponse, rt as ListExtensionCommandsResponse, sd as SessionConversationResponse, st as WorkbenchExtensionViewRecord, t as CreateWorkspaceInput$1, tt as viewFilterValueKind, u as WorkspaceFilesResponse$1, uf as TerminalBridge, ut as AutomationRunEvent, vf as TerminalSessionRequest, w as ListExtensionSettingsResponse, wd as BoardViews, x as ExtensionSettingDefinitionRecord, xd as BoardView, y as UpdateProjectInput, yd as BoardField, yf as TerminalSessionResult, z as ProjectExtensionInstance, zd as ListNotificationsQuery } from "./index-DKb6w-4h.js";
|
|
2
|
+
import "./sessions-D3MhZWKe.js";
|
|
3
|
+
import "./skills-D3MhZWKe.js";
|
|
4
4
|
//#region src/api/workspaces.d.ts
|
|
5
5
|
type CreateWorkspaceInput = CreateWorkspaceInput$1;
|
|
6
6
|
type RemoveWorktreeResponse = RemoveWorktreeResponse$1;
|
|
@@ -11,5 +11,5 @@ type WorkspaceFileEntry = WorkspaceFileEntry$1;
|
|
|
11
11
|
type WorkspaceFilesResponse = WorkspaceFilesResponse$1;
|
|
12
12
|
type WriteWorkspaceFileInput = WriteWorkspaceFileInput$1;
|
|
13
13
|
//#endregion
|
|
14
|
-
export { type AddLocalExtensionFolderResponse, type ApprovalInput, type AutomationRun, type AutomationRunError, type AutomationRunEvent, type AutomationRunStatus, type AutomationTokenRecord, type BoardField, type BoardSummary, type BoardView, type BoardViewCreate, type BoardViewUpdate, type BoardViews, type CommandExecuteRequest, type CommandExecuteResponse, type ConfigureExtensionConnectionInput, type CreateAutomationRunInput, type CreateNotificationInput, type CreateProjectInput, type CreateSessionInput, type CreateWorkspaceInput, type ExtensionCommandPaletteContribution, type ExtensionCommandPaletteResourceRecord, type ExtensionCommandRecord, type ExtensionConnectionRecord, type ExtensionDiagnostic, type ExtensionKeybindingRecord, type ExtensionMenuContribution, type ExtensionRecord, type ExtensionSettingDefinitionRecord, type ExtensionSettingValueRecord, type ExtensionSettingsPanelRecord, type FollowUpInput, type InstallMarketplaceExtensionResponse, type IssueAutomationTokenInput, type IssueAutomationTokenResponse, type ListAutomationRunEventsResponse, type ListAutomationTokensResponse, type ListExtensionAppearanceResponse, type ListExtensionCommandsResponse, type ListExtensionConnectionsResponse, type ListExtensionSettingsResponse, type ListNotificationsQuery, type ListNotificationsResponse, type ListProjectExtensionsResponse, type ListWorkspaceFilesInput, type LocalizableString, type MarketplaceExtension, type Notification, type NotificationAction, type NotificationActorType, type NotificationKind, type NotificationOrigin, type NotificationPriority, type NotificationStatus, type ProjectExtensionInstance, type RemoveWorktreeResponse, type RenameWorkspaceInput, type ResolveSessionIdInput, type ResolveSessionIdResponse, type ResourceRef, type SessionAttachment, type SessionAttachmentRef, type SessionConversationResponse, type SessionConversationSources, type SessionQueuedMessagesResponse, type Settings, type TerminalHostEvent, type TerminalSessionOperation, type TerminalSessionRequest, type TerminalSessionResult, type UpdateExtensionSettingRequest, type UpdateNotificationInput, type UpdateProjectInput, type UpdateSettingsInput, type UpdateSkillInput, type UpgradeProjectExtensionResponse, type WorkbenchExtensionAutomationRecord, type WorkbenchExtensionCommandPaletteResourceRecord, type WorkbenchExtensionHarnessRecord, type WorkbenchExtensionMetadata, type WorkbenchExtensionViewBody, type WorkbenchExtensionViewRecord, type WorkspaceFileContent, type WorkspaceFileEntry, type WorkspaceFilesResponse, type WorkspaceProviderDescriptor, type WriteWorkspaceFileInput, sessionAttachmentMimeTypesByExtension };
|
|
14
|
+
export { type AddLocalExtensionFolderResponse, type ApprovalInput, type AutomationRun, type AutomationRunError, type AutomationRunEvent, type AutomationRunStatus, type AutomationTokenRecord, type BoardField, type BoardSummary, type BoardView, type BoardViewCreate, type BoardViewUpdate, type BoardViews, type CombineQueuedFollowUpsInput, type CommandExecuteRequest, type CommandExecuteResponse, type ConfigureExtensionConnectionInput, type CreateAutomationRunInput, type CreateNotificationInput, type CreateProjectInput, type CreateSessionInput, type CreateWorkspaceInput, type ExtensionCommandPaletteContribution, type ExtensionCommandPaletteResourceRecord, type ExtensionCommandRecord, type ExtensionConnectionRecord, type ExtensionDiagnostic, type ExtensionDiagnosticsResponse, type ExtensionKeybindingRecord, type ExtensionMenuContribution, type ExtensionRecord, type ExtensionSettingDefinitionRecord, type ExtensionSettingValueRecord, type ExtensionSettingsPanelRecord, type FollowUpInput, type InstallExtensionRequest, type InstallExtensionResponse, type InstallMarketplaceExtensionResponse, type InstalledExtensionSource, type IssueAutomationTokenInput, type IssueAutomationTokenResponse, type ListAutomationRunEventsResponse, type ListAutomationTokensResponse, type ListExtensionAppearanceResponse, type ListExtensionCommandsResponse, type ListExtensionConnectionsResponse, type ListExtensionSettingsResponse, type ListNotificationsQuery, type ListNotificationsResponse, type ListProjectExtensionsResponse, type ListWorkspaceFilesInput, type LocalizableString, type MarketplaceExtension, type Notification, type NotificationAction, type NotificationActorType, type NotificationKind, type NotificationOrigin, type NotificationPriority, type NotificationStatus, type PendingQueuedFollowUpsResponse, type ProjectExtensionInstance, type QueuedFollowUpRequest, type QueuedFollowUpUpdateResponse, type QueuedSteeringResult, type RemoveWorktreeResponse, type RenameWorkspaceInput, type ResolveSessionIdInput, type ResolveSessionIdResponse, type ResourceRef, type SessionAttachment, type SessionAttachmentRef, type SessionConversationResponse, type SessionConversationSources, type SessionQueuedMessagesResponse, type Settings, type SteerQueuedFollowUpInput, type TerminalBridge, type TerminalHostEvent, type TerminalSessionAdapter, type TerminalSessionError, type TerminalSessionExit, type TerminalSessionOperation, type TerminalSessionRequest, type TerminalSessionResult, type UpdateExtensionSettingRequest, type UpdateNotificationInput, type UpdateProjectInput, type UpdateQueuedFollowUpInput, type UpdateSettingsInput, type UpdateSkillInput, type UpgradeProjectExtensionResponse, type WorkbenchExtensionAutomationRecord, type WorkbenchExtensionCommandPaletteResourceRecord, type WorkbenchExtensionHarnessRecord, type WorkbenchExtensionMetadata, type WorkbenchExtensionViewBody, type WorkbenchExtensionViewRecord, type WorkspaceFileContent, type WorkspaceFileEntry, type WorkspaceFilesResponse, type WorkspaceProviderDescriptor, type WriteWorkspaceFileInput, findViewFilterProblem, sessionAttachmentMimeTypesByExtension, viewFilterValueKind };
|
|
15
15
|
export {};
|
package/dist/client/index.js
CHANGED
|
@@ -36,8 +36,132 @@ var createBoardViewsClient = (request) => ({
|
|
|
36
36
|
setDefault: (projectId, boardId, viewId) => request(`${boardPath(projectId, boardId)}/default`, { method: "PUT", body: { viewId } })
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
+
// src/internal/stream-buffer.ts
|
|
40
|
+
var createStreamBuffer = (input) => {
|
|
41
|
+
const queue = [];
|
|
42
|
+
let bytes = 0;
|
|
43
|
+
let ended = false;
|
|
44
|
+
let error;
|
|
45
|
+
let wake = () => {};
|
|
46
|
+
let consumed = false;
|
|
47
|
+
const finish = (reason) => {
|
|
48
|
+
ended = true;
|
|
49
|
+
error = reason;
|
|
50
|
+
if (reason) {
|
|
51
|
+
queue.length = 0;
|
|
52
|
+
bytes = 0;
|
|
53
|
+
}
|
|
54
|
+
wake();
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
push(value) {
|
|
58
|
+
if (ended)
|
|
59
|
+
return true;
|
|
60
|
+
const size = input.size(value);
|
|
61
|
+
if (bytes + size > input.limit)
|
|
62
|
+
return false;
|
|
63
|
+
queue.push({ value, bytes: size });
|
|
64
|
+
bytes += size;
|
|
65
|
+
wake();
|
|
66
|
+
return true;
|
|
67
|
+
},
|
|
68
|
+
finish,
|
|
69
|
+
clear() {
|
|
70
|
+
queue.length = 0;
|
|
71
|
+
bytes = 0;
|
|
72
|
+
finish();
|
|
73
|
+
},
|
|
74
|
+
iterable: {
|
|
75
|
+
[Symbol.asyncIterator]() {
|
|
76
|
+
if (consumed)
|
|
77
|
+
throw new Error("Command streams support one consumer");
|
|
78
|
+
consumed = true;
|
|
79
|
+
return {
|
|
80
|
+
async next() {
|
|
81
|
+
while (!queue.length && !ended)
|
|
82
|
+
await new Promise((resolve) => {
|
|
83
|
+
wake = resolve;
|
|
84
|
+
});
|
|
85
|
+
const item = queue.shift();
|
|
86
|
+
if (item) {
|
|
87
|
+
bytes -= item.bytes;
|
|
88
|
+
input.onConsume?.(item.bytes);
|
|
89
|
+
return { done: false, value: item.value };
|
|
90
|
+
}
|
|
91
|
+
if (error)
|
|
92
|
+
throw error;
|
|
93
|
+
return { done: true, value: undefined };
|
|
94
|
+
},
|
|
95
|
+
async return() {
|
|
96
|
+
queue.length = 0;
|
|
97
|
+
bytes = 0;
|
|
98
|
+
await input.onCancel();
|
|
99
|
+
finish();
|
|
100
|
+
return { done: true, value: undefined };
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
var streamError = (code, message = code) => Object.assign(new Error(message), { code });
|
|
108
|
+
var jsonBytes = (value) => new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
109
|
+
|
|
110
|
+
// src/client/extension-stream.ts
|
|
111
|
+
var streamExtensionCommand = (transport, commandId, input, options) => {
|
|
112
|
+
let close = () => {};
|
|
113
|
+
const cleanup = () => {
|
|
114
|
+
close();
|
|
115
|
+
options?.signal?.removeEventListener("abort", abort);
|
|
116
|
+
};
|
|
117
|
+
const fail = (error) => {
|
|
118
|
+
cleanup();
|
|
119
|
+
buffer.finish(error);
|
|
120
|
+
};
|
|
121
|
+
const abort = () => fail(streamError("command_stream_cancelled"));
|
|
122
|
+
const buffer = createStreamBuffer({
|
|
123
|
+
size: jsonBytes,
|
|
124
|
+
limit: 8 * 1024 * 1024,
|
|
125
|
+
onCancel: cleanup
|
|
126
|
+
});
|
|
127
|
+
if (options?.signal?.aborted) {
|
|
128
|
+
abort();
|
|
129
|
+
return buffer.iterable;
|
|
130
|
+
}
|
|
131
|
+
const { projectId, ...body } = input;
|
|
132
|
+
const subscription = transport.subscribe({ command: { project_id: projectId, command_id: commandId, body } }, {
|
|
133
|
+
onEvent(event, data) {
|
|
134
|
+
if (event === "chunk") {
|
|
135
|
+
if (!buffer.push({ type: "data", data }))
|
|
136
|
+
fail(streamError("command_stream_overflow"));
|
|
137
|
+
} else if (event === "end") {
|
|
138
|
+
if (!buffer.push({ type: "end", response: data })) {
|
|
139
|
+
fail(streamError("command_stream_overflow"));
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
cleanup();
|
|
143
|
+
buffer.finish();
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
onError(error) {
|
|
147
|
+
const code = error?.code ?? "command_stream_disconnected";
|
|
148
|
+
fail(streamError(code, error instanceof Error ? error.message : String(error)));
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
close = subscription.close;
|
|
152
|
+
options?.signal?.addEventListener("abort", abort, { once: true });
|
|
153
|
+
return buffer.iterable;
|
|
154
|
+
};
|
|
155
|
+
|
|
39
156
|
// src/client/extensions.ts
|
|
40
|
-
var createExtensionClient = (request) => ({
|
|
157
|
+
var createExtensionClient = (request, streams) => ({
|
|
158
|
+
install: (projectId, input, options) => request(`/v1/projects/${projectId}/extensions/install`, {
|
|
159
|
+
method: "POST",
|
|
160
|
+
body: "upload" in input ? input.upload : input,
|
|
161
|
+
signal: options?.signal
|
|
162
|
+
}),
|
|
163
|
+
diagnostics: (projectId, options) => request(`/v1/projects/${projectId}/extensions/diagnostics${options?.scope ? `?scope=${options.scope}` : ""}`),
|
|
164
|
+
stream: (commandId, input, options) => streamExtensionCommand(streams, commandId, input, options),
|
|
41
165
|
enableInstalled: (projectId, installName, body) => request(`/v1/projects/${projectId}/extensions/installed/${encodeURIComponent(installName)}/enable`, {
|
|
42
166
|
method: "POST",
|
|
43
167
|
body
|
|
@@ -139,13 +263,22 @@ var createProjectClient = (request) => ({
|
|
|
139
263
|
|
|
140
264
|
// src/client/request.ts
|
|
141
265
|
class PstdioApiError extends Error {
|
|
266
|
+
code;
|
|
142
267
|
status;
|
|
143
|
-
constructor(message, status) {
|
|
268
|
+
constructor(message, status, code) {
|
|
144
269
|
super(message);
|
|
270
|
+
this.code = code;
|
|
145
271
|
this.name = "PstdioApiError";
|
|
146
272
|
this.status = status;
|
|
147
273
|
}
|
|
148
274
|
}
|
|
275
|
+
|
|
276
|
+
class PstdioConnectionError extends Error {
|
|
277
|
+
constructor(cause) {
|
|
278
|
+
super("Could not connect to the backend.", { cause });
|
|
279
|
+
this.name = "PstdioConnectionError";
|
|
280
|
+
}
|
|
281
|
+
}
|
|
149
282
|
var formatZodIssues = (issues) => issues.map((issue) => {
|
|
150
283
|
const path = Array.isArray(issue.path) ? issue.path.filter((part) => part !== "").join(".") : "";
|
|
151
284
|
const message = typeof issue.message === "string" ? issue.message : JSON.stringify(issue);
|
|
@@ -222,28 +355,54 @@ var createRequest = (options) => {
|
|
|
222
355
|
});
|
|
223
356
|
if (!isSameOriginTarget(baseUrl, path, url))
|
|
224
357
|
headers.delete("authorization");
|
|
225
|
-
const
|
|
358
|
+
const requestInit = {
|
|
226
359
|
method: reqOpts.method ?? "GET",
|
|
227
360
|
headers: Object.fromEntries(headers.entries()),
|
|
228
361
|
body: reqOpts.body !== undefined ? serializeRequestBody(reqOpts.body) : undefined,
|
|
229
362
|
signal: reqOpts.signal,
|
|
230
363
|
cache: reqOpts.cache,
|
|
231
364
|
credentials: "same-origin"
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
365
|
+
};
|
|
366
|
+
try {
|
|
367
|
+
const response = await fetchFn(url, requestInit);
|
|
368
|
+
if (!response.ok) {
|
|
369
|
+
const errorBody = await response.json().catch(() => null);
|
|
370
|
+
const message = readErrorMessage(errorBody, response.status);
|
|
371
|
+
const code = errorBody && typeof errorBody === "object" && "code" in errorBody && typeof errorBody.code === "string" ? errorBody.code : undefined;
|
|
372
|
+
throw new PstdioApiError(message, response.status, code);
|
|
373
|
+
}
|
|
374
|
+
if (response.status === 204)
|
|
375
|
+
return;
|
|
376
|
+
return await response.json();
|
|
377
|
+
} catch (error) {
|
|
378
|
+
reqOpts.signal?.throwIfAborted();
|
|
379
|
+
if (error instanceof PstdioApiError || error instanceof SyntaxError)
|
|
380
|
+
throw error;
|
|
381
|
+
throw new PstdioConnectionError(error);
|
|
237
382
|
}
|
|
238
|
-
if (response.status === 204)
|
|
239
|
-
return;
|
|
240
|
-
return response.json();
|
|
241
383
|
};
|
|
242
384
|
};
|
|
243
385
|
|
|
386
|
+
// src/client/resource-anchors.ts
|
|
387
|
+
var createResourceAnchorsClient = (request) => ({
|
|
388
|
+
addAnchors: async (projectId, resource, anchors) => {
|
|
389
|
+
await request(`/v1/projects/${encodeURIComponent(projectId)}/resource-anchors/add`, {
|
|
390
|
+
method: "POST",
|
|
391
|
+
body: { resource, anchors }
|
|
392
|
+
});
|
|
393
|
+
},
|
|
394
|
+
removeAnchors: async (projectId, resource, refs) => {
|
|
395
|
+
await request(`/v1/projects/${encodeURIComponent(projectId)}/resource-anchors/remove`, {
|
|
396
|
+
method: "POST",
|
|
397
|
+
body: { resource, refs }
|
|
398
|
+
});
|
|
399
|
+
},
|
|
400
|
+
listAnchors: (projectId, input) => request(`/v1/projects/${encodeURIComponent(projectId)}/resource-anchors/query`, { method: "POST", body: input })
|
|
401
|
+
});
|
|
402
|
+
|
|
244
403
|
// src/client/runtime.ts
|
|
245
404
|
var createRuntimeClient = (request) => ({
|
|
246
|
-
|
|
405
|
+
createBrowserLogin: () => request("/runtime/browser-login", { method: "POST" })
|
|
247
406
|
});
|
|
248
407
|
|
|
249
408
|
// src/client/sse.ts
|
|
@@ -305,7 +464,7 @@ var createSessionStreamTransport = (request, clientOptions) => {
|
|
|
305
464
|
const subscribe = (connectionId, id, subscription) => {
|
|
306
465
|
subscription.started = request(`/v1/session-stream/${connectionId}/subscriptions`, {
|
|
307
466
|
method: "POST",
|
|
308
|
-
body: { subscription_id: id,
|
|
467
|
+
body: { subscription_id: id, ...subscription.input }
|
|
309
468
|
}).then(() => {}, (error) => {
|
|
310
469
|
if (subscriptions.get(id) !== subscription)
|
|
311
470
|
return;
|
|
@@ -329,6 +488,8 @@ var createSessionStreamTransport = (request, clientOptions) => {
|
|
|
329
488
|
started.then(() => request(path, { method: "DELETE" })).catch(() => {});
|
|
330
489
|
};
|
|
331
490
|
const dispatch = (current, event, payload) => {
|
|
491
|
+
if (connection !== current)
|
|
492
|
+
return;
|
|
332
493
|
if (event === "connected") {
|
|
333
494
|
current.id = payload.connection_id;
|
|
334
495
|
for (const [id, subscription] of subscriptions)
|
|
@@ -341,7 +502,9 @@ var createSessionStreamTransport = (request, clientOptions) => {
|
|
|
341
502
|
if (event === "end" || event === "error")
|
|
342
503
|
release(payload.subscription_id, false);
|
|
343
504
|
if (event === "error")
|
|
344
|
-
subscription.onError(new Error(payload.data.message)
|
|
505
|
+
subscription.onError(Object.assign(new Error(payload.data.message), {
|
|
506
|
+
code: payload.data.code
|
|
507
|
+
}));
|
|
345
508
|
else
|
|
346
509
|
subscription.onEvent(event, payload.data);
|
|
347
510
|
};
|
|
@@ -372,9 +535,9 @@ var createSessionStreamTransport = (request, clientOptions) => {
|
|
|
372
535
|
return current;
|
|
373
536
|
};
|
|
374
537
|
return {
|
|
375
|
-
subscribe(
|
|
538
|
+
subscribe(input, listener) {
|
|
376
539
|
const id = crypto.randomUUID();
|
|
377
|
-
const subscription = { ...listener,
|
|
540
|
+
const subscription = { ...listener, input: typeof input === "string" ? { session_id: input } : input };
|
|
378
541
|
subscriptions.set(id, subscription);
|
|
379
542
|
const current = connection ?? open();
|
|
380
543
|
if (current.id)
|
|
@@ -423,9 +586,9 @@ var dispatchSessionStreamEvent = (event, data, handlers) => {
|
|
|
423
586
|
handlers.onEnd?.(data);
|
|
424
587
|
}
|
|
425
588
|
};
|
|
426
|
-
var createSessionClient = (request, clientOptions) => {
|
|
427
|
-
const streams = createSessionStreamTransport(request, clientOptions);
|
|
589
|
+
var createSessionClient = (request, clientOptions, streams = createSessionStreamTransport(request, clientOptions)) => {
|
|
428
590
|
return {
|
|
591
|
+
getDraftHarnessCommands: (input, signal) => request("/v1/sessions/harness-command-state", { method: "POST", body: input, signal }),
|
|
429
592
|
listActivity: (sessionId, input = {}) => {
|
|
430
593
|
const params = new URLSearchParams;
|
|
431
594
|
if (input.event_type)
|
|
@@ -442,6 +605,8 @@ var createSessionClient = (request, clientOptions) => {
|
|
|
442
605
|
return request(`/v1/sessions/${sessionId}/activity${query ? `?${query}` : ""}`);
|
|
443
606
|
},
|
|
444
607
|
list: (projectId, input) => request(`/v1/sessions?${buildSessionsQuery(projectId, input)}`),
|
|
608
|
+
getHarnessCommands: (sessionId, signal) => request(`/v1/sessions/${sessionId}/harness-commands`, { signal }),
|
|
609
|
+
invokeHarnessOperation: (sessionId, operation, harnessId) => request(`/v1/sessions/${sessionId}/harness-commands`, { method: "POST", body: { operation, harnessId } }),
|
|
445
610
|
get: (sessionId) => request(`/v1/sessions/${sessionId}`),
|
|
446
611
|
uploadAttachment: (projectId, input) => request(`/v1/projects/${encodeURIComponent(projectId)}/session-attachments`, {
|
|
447
612
|
method: "POST",
|
|
@@ -461,8 +626,13 @@ var createSessionClient = (request, clientOptions) => {
|
|
|
461
626
|
getConversation: (sessionId, signal) => request(`/v1/sessions/${sessionId}/conversation`, { signal }),
|
|
462
627
|
getConversationSources: (sessionId, signal) => request(`/v1/sessions/${sessionId}/conversation/sources`, { signal }),
|
|
463
628
|
getQueuedMessages: (sessionId, options) => request(`/v1/sessions/${sessionId}/queued-messages`, options),
|
|
629
|
+
steerQueuedFollowUp: (sessionId, queuePosition, input) => request(`/v1/sessions/${sessionId}/queued-follow-ups/${queuePosition}/steer`, { method: "POST", body: input }),
|
|
630
|
+
getQueuedFollowUps: (sessionId) => request(`/v1/sessions/${sessionId}/queued-follow-ups`),
|
|
631
|
+
updateQueuedFollowUp: (sessionId, queuePosition, input) => request(`/v1/sessions/${sessionId}/queued-follow-ups/${queuePosition}`, { method: "PATCH", body: input }),
|
|
632
|
+
combineQueuedFollowUps: (sessionId, queuePosition, input) => request(`/v1/sessions/${sessionId}/queued-follow-ups/${queuePosition}/combine`, { method: "POST", body: input }),
|
|
464
633
|
resolveSessionId: (input) => request("/v1/sessions/resolve-session-id", { method: "POST", body: input }),
|
|
465
634
|
updateStatus: (sessionId, status) => request(`/v1/sessions/${sessionId}/status`, { method: "PATCH", body: { status } }),
|
|
635
|
+
rename: (sessionId, title) => request(`/v1/sessions/${sessionId}/title`, { method: "PATCH", body: { title } }),
|
|
466
636
|
stream: (sessionId, onEvent, options = {}) => new Promise((resolve, reject) => {
|
|
467
637
|
const subscription = streams.subscribe(sessionId, {
|
|
468
638
|
onEvent: (event, data) => {
|
|
@@ -546,7 +716,7 @@ var createHeartbeatMonitor = (input) => {
|
|
|
546
716
|
start: () => {
|
|
547
717
|
timer = setInterval(() => {
|
|
548
718
|
missedHeartbeats += 1;
|
|
549
|
-
if (missedHeartbeats
|
|
719
|
+
if (missedHeartbeats === input.threshold) {
|
|
550
720
|
input.onConnectionLost?.();
|
|
551
721
|
}
|
|
552
722
|
}, input.intervalMs);
|
|
@@ -569,9 +739,15 @@ var createSyncClient = (clientOptions) => ({
|
|
|
569
739
|
const heartbeatMonitor = createHeartbeatMonitor({
|
|
570
740
|
intervalMs: input.heartbeatIntervalMs ?? DEFAULT_HEARTBEAT_INTERVAL_MS,
|
|
571
741
|
threshold: input.heartbeatThreshold ?? DEFAULT_HEARTBEAT_THRESHOLD,
|
|
572
|
-
onConnectionLost:
|
|
742
|
+
onConnectionLost: () => {
|
|
743
|
+
heartbeatMonitor.recordHeartbeat();
|
|
744
|
+
setDisconnected();
|
|
745
|
+
input.onConnectionLost?.();
|
|
746
|
+
abortController?.abort();
|
|
747
|
+
}
|
|
573
748
|
});
|
|
574
749
|
const setConnected = () => {
|
|
750
|
+
heartbeatMonitor.recordHeartbeat();
|
|
575
751
|
const wasConnected = state.connected;
|
|
576
752
|
state.connected = true;
|
|
577
753
|
if (!wasConnected)
|
|
@@ -611,8 +787,8 @@ var createSyncClient = (clientOptions) => ({
|
|
|
611
787
|
abortController = new AbortController;
|
|
612
788
|
try {
|
|
613
789
|
await readConnection(abortController.signal);
|
|
614
|
-
} catch
|
|
615
|
-
if (closed
|
|
790
|
+
} catch {
|
|
791
|
+
if (closed)
|
|
616
792
|
return;
|
|
617
793
|
}
|
|
618
794
|
if (closed)
|
|
@@ -712,17 +888,19 @@ var createWorkspaceClient = (request) => ({
|
|
|
712
888
|
// src/client/client.ts
|
|
713
889
|
var createClient = (options = {}) => {
|
|
714
890
|
const request = createRequest(options);
|
|
891
|
+
const streams = createSessionStreamTransport(request, options);
|
|
715
892
|
return {
|
|
893
|
+
resources: createResourceAnchorsClient(request),
|
|
716
894
|
views: createBoardViewsClient(request),
|
|
717
895
|
projects: createProjectClient(request),
|
|
718
896
|
filesystem: createFilesystemClient(request),
|
|
719
897
|
workspaces: createWorkspaceClient(request),
|
|
720
|
-
sessions: createSessionClient(request, options),
|
|
898
|
+
sessions: createSessionClient(request, options, streams),
|
|
721
899
|
skills: createSkillClient(request),
|
|
722
900
|
agents: createAgentClient(request),
|
|
723
901
|
automation: createAutomationClient(request),
|
|
724
902
|
notifications: createNotificationsClient(request),
|
|
725
|
-
extensions: createExtensionClient(request),
|
|
903
|
+
extensions: createExtensionClient(request, streams),
|
|
726
904
|
settings: createSettingsClient(request),
|
|
727
905
|
sync: createSyncClient(options),
|
|
728
906
|
runtime: createRuntimeClient(request)
|
|
@@ -730,6 +908,7 @@ var createClient = (options = {}) => {
|
|
|
730
908
|
};
|
|
731
909
|
export {
|
|
732
910
|
PstdioApiError,
|
|
911
|
+
PstdioConnectionError,
|
|
733
912
|
applySyncEvent,
|
|
734
913
|
createClient,
|
|
735
914
|
createRequest,
|
package/dist/client.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { type AgentClient, type AutomationClient, type BoardViewsClient, type ClientOptions, type DirectoryEntry, type ExtensionClient, type FilesystemClient, type ListSessionsInput, type NotificationsClient, type ProjectClient, PstdioApiError, type PstdioClient, type RequestFn, type RequestOptions, type RuntimeClient, type SessionClient, type SessionStreamConnection, type SessionStreamHandlers, type SettingsClient, type SkillClient, type SseEvent, type StartSyncInput, type SyncClient, type SyncConnection, type SyncRow, type SyncWriter, type SyncWriterProvider, type WorkspaceClient, applySyncEvent, createClient, createRequest, createRuntimeClient, parseSyncDeleteEvent };
|
|
1
|
+
import { A as AgentClient, C as NotificationsClient, D as CommandStreamClientEvent, E as ExtensionClient, F as RequestOptions, I as createRequest, M as PstdioApiError, N as PstdioConnectionError, O as BoardViewsClient, P as RequestFn, S as ProjectClient, T as FilesystemClient, _ as SessionStreamHandlers, a as SyncClient, b as createRuntimeClient, c as SyncWriter, d as parseSyncDeleteEvent, f as SkillClient, g as SessionStreamConnection, h as SessionClient, i as StartSyncInput, j as ClientOptions, k as AutomationClient, l as SyncWriterProvider, m as ListSessionsInput, n as createClient, o as SyncConnection, p as SettingsClient, r as WorkspaceClient, s as SyncRow, t as PstdioClient, u as applySyncEvent, v as SseEvent, w as DirectoryEntry, x as ResourceAnchorsClient, y as RuntimeClient } from "./index-COPyc9eO.js";
|
|
2
|
+
export { type AgentClient, type AutomationClient, type BoardViewsClient, type ClientOptions, type CommandStreamClientEvent, type DirectoryEntry, type ExtensionClient, type FilesystemClient, type ListSessionsInput, type NotificationsClient, type ProjectClient, PstdioApiError, type PstdioClient, PstdioConnectionError, type RequestFn, type RequestOptions, type ResourceAnchorsClient, type RuntimeClient, type SessionClient, type SessionStreamConnection, type SessionStreamHandlers, type SettingsClient, type SkillClient, type SseEvent, type StartSyncInput, type SyncClient, type SyncConnection, type SyncRow, type SyncWriter, type SyncWriterProvider, type WorkspaceClient, applySyncEvent, createClient, createRequest, createRuntimeClient, parseSyncDeleteEvent };
|
|
3
3
|
export {};
|
package/dist/data.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ki as ArtifactMount } from "./index-DKb6w-4h.js";
|
|
2
2
|
//#region src/data/draft-layout.d.ts
|
|
3
3
|
export declare const assertSafePathSegment: (value: string) => void;
|
|
4
4
|
export declare const requireRepoFiles: (projectFiles: ArtifactMount | undefined) => ArtifactMount;
|