@workerdeck/server 1.0.0 → 1.2.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/build/index.d.mts +6 -4
- package/build/index.mjs +15 -12
- package/build/index.mjs.map +1 -1
- package/package.json +13 -13
package/build/index.d.mts
CHANGED
|
@@ -2,7 +2,6 @@ import { IncomingMessage, Server, ServerResponse } from "node:http";
|
|
|
2
2
|
import { AttachmentInput, BridgeAnswer, BrowserBridgeExecutor, ClaudeAuthProbe, EngineAdapter, EngineSessionOptions, HostToolDefinition, LanguageModel, McpConnection, ParkedExecution, Runner, RunnerSnapshot, SessionRunnerConfig, ToolExecutionCall, ToolExecutionResult, ToolExecutor, ToolSet } from "@workerdeck/core";
|
|
3
3
|
import { JobQueue, QueueAdapter } from "@workerdeck/queue";
|
|
4
4
|
import { CreateSessionRequest, JobEvent, MessageAttachment, ProfileEngine, ProfileInfo, ProfileUsage, ProviderConfig, SdkSessionSummary, ServerFrame, SessionCapability, SessionInfo, SessionNotification, SessionWebhookConfig } from "@workerdeck/protocol";
|
|
5
|
-
|
|
6
5
|
//#region src/services/bridge.d.ts
|
|
7
6
|
type BridgeHubOptions = {
|
|
8
7
|
timeoutMs?: number;
|
|
@@ -219,16 +218,19 @@ type QueueServerOptions = {
|
|
|
219
218
|
};
|
|
220
219
|
/** A point-in-time answer to "is it safe to stop yet?", as reported while draining. */
|
|
221
220
|
type DrainReport = {
|
|
222
|
-
/** Sessions mid-turn. These resolve on their own, so the drain waits for them. */
|
|
221
|
+
/** Sessions mid-turn. These resolve on their own, so the drain waits for them. */
|
|
222
|
+
working: string[];
|
|
223
223
|
/**
|
|
224
224
|
* Sessions blocked on a human — a pending approval. The drain names these but never waits for them: nothing about
|
|
225
225
|
* shutting down will answer the prompt, so waiting is a hang with better manners.
|
|
226
226
|
*/
|
|
227
|
-
awaitingHuman: string[];
|
|
227
|
+
awaitingHuman: string[];
|
|
228
|
+
/** True when the deadline passed with work still running. */
|
|
228
229
|
timedOut: boolean;
|
|
229
230
|
};
|
|
230
231
|
type DrainOptions = {
|
|
231
|
-
/** Overall budget. The drain gives up and reports rather than blocking shutdown forever. */
|
|
232
|
+
/** Overall budget. The drain gives up and reports rather than blocking shutdown forever. */
|
|
233
|
+
timeoutMs?: number;
|
|
232
234
|
pollMs?: number;
|
|
233
235
|
onProgress?: (report: DrainReport) => void;
|
|
234
236
|
};
|
package/build/index.mjs
CHANGED
|
@@ -56,7 +56,8 @@ function asUtf8(bytes) {
|
|
|
56
56
|
return Buffer.from(text, "utf8").equals(bytes) ? text : null;
|
|
57
57
|
}
|
|
58
58
|
function contentTypeFor(filename) {
|
|
59
|
-
|
|
59
|
+
const ext = filename.includes(".") ? filename.split(".").pop().toLowerCase() : "";
|
|
60
|
+
return CONTENT_TYPES[ext] ?? "text/plain; charset=utf-8";
|
|
60
61
|
}
|
|
61
62
|
//#endregion
|
|
62
63
|
//#region src/lib/profile-env.ts
|
|
@@ -963,14 +964,16 @@ async function handleSdkSessions(ctx, req, res, auth) {
|
|
|
963
964
|
});
|
|
964
965
|
};
|
|
965
966
|
try {
|
|
966
|
-
if (roots && roots.length > 0)
|
|
967
|
-
if (
|
|
968
|
-
|
|
967
|
+
if (roots && roots.length > 0) {
|
|
968
|
+
if (dir) {
|
|
969
|
+
if (!cwdAllowed(dir, roots)) {
|
|
970
|
+
json(res, 403, { error: "dir is outside the allowed roots" });
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
} else {
|
|
974
|
+
json(res, 200, { sdkSessions: withinRoots(await lister({}), roots, limit, offset) });
|
|
969
975
|
return;
|
|
970
976
|
}
|
|
971
|
-
} else {
|
|
972
|
-
json(res, 200, { sdkSessions: withinRoots(await lister({}), roots, limit, offset) });
|
|
973
|
-
return;
|
|
974
977
|
}
|
|
975
978
|
json(res, 200, { sdkSessions: await lister({
|
|
976
979
|
dir,
|
|
@@ -1269,7 +1272,7 @@ async function handleProducedFiles(ctx, req, res, sessionId, fileId) {
|
|
|
1269
1272
|
//#endregion
|
|
1270
1273
|
//#region src/services/project-info.ts
|
|
1271
1274
|
const PROJECT_FILE = ".workerdeck.json";
|
|
1272
|
-
const MAX_PROJECT_FILE_BYTES =
|
|
1275
|
+
const MAX_PROJECT_FILE_BYTES = 65536;
|
|
1273
1276
|
const MAX_NAME_CHARS = 80;
|
|
1274
1277
|
const GLYPH_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
1275
1278
|
const DEFAULT_TTL_MS = 3e4;
|
|
@@ -1738,8 +1741,8 @@ async function handleCommand(ctx, frame, runner) {
|
|
|
1738
1741
|
}
|
|
1739
1742
|
//#endregion
|
|
1740
1743
|
//#region src/services/attachments.ts
|
|
1741
|
-
const DEFAULT_MAX_FILE_BYTES =
|
|
1742
|
-
const DEFAULT_MAX_SESSION_BYTES =
|
|
1744
|
+
const DEFAULT_MAX_FILE_BYTES = 10485760;
|
|
1745
|
+
const DEFAULT_MAX_SESSION_BYTES = 67108864;
|
|
1743
1746
|
var AttachmentStore = class {
|
|
1744
1747
|
#bySession = /* @__PURE__ */ new Map();
|
|
1745
1748
|
#maxFileBytes;
|
|
@@ -2926,7 +2929,7 @@ function createWorkerServer(options = {}) {
|
|
|
2926
2929
|
const basePath = options.basePath ?? "/v1";
|
|
2927
2930
|
const fallback = options.fallback;
|
|
2928
2931
|
const corsOrigins = options.cors?.origins.length ? new Set(options.cors.origins) : void 0;
|
|
2929
|
-
const maxBodyBytes = options.maxBodyBytes ??
|
|
2932
|
+
const maxBodyBytes = options.maxBodyBytes ?? 1048576;
|
|
2930
2933
|
const adapterFor = (engine) => options.engines?.[engine ?? "claude"] ?? getEngineAdapter(engine);
|
|
2931
2934
|
const profileDefaultModels = /* @__PURE__ */ new Map();
|
|
2932
2935
|
const profileUsage = new ProfileUsageTracker();
|
|
@@ -3074,7 +3077,7 @@ function createWorkerServer(options = {}) {
|
|
|
3074
3077
|
producedFiles,
|
|
3075
3078
|
hostFiles,
|
|
3076
3079
|
hostFilesWritable: options.hostFiles?.write === true,
|
|
3077
|
-
maxHostFileBytes: options.hostFiles?.maxFileBytes ??
|
|
3080
|
+
maxHostFileBytes: options.hostFiles?.maxFileBytes ?? 1048576,
|
|
3078
3081
|
maxHostDirEntries: options.hostFiles?.maxEntries ?? 5e3
|
|
3079
3082
|
};
|
|
3080
3083
|
const handleRequest = async (req, res) => {
|