@fungi.computer/oyster 0.50.0 → 0.50.1
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/dist/agents.js +8 -17
- package/dist/auth.js +3 -5
- package/dist/body-limit.d.ts +8 -0
- package/dist/body-limit.js +14 -0
- package/dist/build/job-log.d.ts +3 -1
- package/dist/build/job-log.js +5 -3
- package/dist/embed-metafiles.js +1 -1
- package/dist/embed-scripts.js +1 -1
- package/dist/files.js +9 -10
- package/package.json +3 -3
package/dist/agents.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { bodyAtMost } from "./body-limit.js";
|
|
1
2
|
import { destinationsSchema, subjectSchema, } from "@fungi.computer/veil/connections";
|
|
2
3
|
import { agent, agents as agentCollection, owner, routes, } from "./authorization.js";
|
|
3
4
|
import * as Schema from "effect/Schema";
|
|
@@ -510,9 +511,6 @@ export function modelKeyRoutes(agents, computerSetup) {
|
|
|
510
511
|
...(await computerSetup?.()),
|
|
511
512
|
}))
|
|
512
513
|
.post("/api/model-keys", owner("direct"), async (context) => {
|
|
513
|
-
const length = Number(context.req.header("content-length") ?? "0");
|
|
514
|
-
if (length > 32 * 1024)
|
|
515
|
-
return refusal(413, "Request too large");
|
|
516
514
|
const input = Schema.decodeUnknownOption(Schema.fromJsonString(sealRequestSchema), { onExcessProperty: "error" })(await context.req.text());
|
|
517
515
|
if (input._tag === "None")
|
|
518
516
|
return refusal(400, "Choose a provider, name the key and paste it");
|
|
@@ -520,7 +518,7 @@ export function modelKeyRoutes(agents, computerSetup) {
|
|
|
520
518
|
return "error" in sealed
|
|
521
519
|
? refusal(modelKeyRefusalStatus[sealed.error], sealed.error)
|
|
522
520
|
: Response.json(sealed, { status: 201 });
|
|
523
|
-
})
|
|
521
|
+
}, bodyAtMost(32 * 1024))
|
|
524
522
|
.delete("/api/model-keys/:keyId", owner("direct"), async (context) => {
|
|
525
523
|
const keyId = context.req.param("keyId");
|
|
526
524
|
if (!keyIdPattern.test(keyId))
|
|
@@ -584,9 +582,8 @@ function vaultRoutes(agents) {
|
|
|
584
582
|
headers: { "cache-control": "private, no-store" },
|
|
585
583
|
});
|
|
586
584
|
};
|
|
585
|
+
const vaultBodyLimit = bodyAtMost(64 * 1024);
|
|
587
586
|
const body = async (request, schema) => {
|
|
588
|
-
if (Number(request.headers.get("content-length") ?? "0") > 64 * 1024)
|
|
589
|
-
return null;
|
|
590
587
|
const decoded = Schema.decodeUnknownOption(Schema.fromJsonString(schema), {
|
|
591
588
|
onExcessProperty: "error",
|
|
592
589
|
})(await request.text());
|
|
@@ -605,7 +602,7 @@ function vaultRoutes(agents) {
|
|
|
605
602
|
return input === null
|
|
606
603
|
? refusal(400, "Name the secret, bind it to hosts and paste its value")
|
|
607
604
|
: answer({ op: "addSecret", ...input }, 201);
|
|
608
|
-
})
|
|
605
|
+
}, vaultBodyLimit)
|
|
609
606
|
.put("/api/vault/credentials/:connectionId", owner("direct"), async (context) => {
|
|
610
607
|
const connectionId = context.req.param("connectionId");
|
|
611
608
|
const input = await body(context.req.raw, updateCredentialSchema);
|
|
@@ -614,7 +611,7 @@ function vaultRoutes(agents) {
|
|
|
614
611
|
return input === null
|
|
615
612
|
? refusal(400, "invalid_input")
|
|
616
613
|
: answer({ op: "updateCredential", connectionId, ...input });
|
|
617
|
-
})
|
|
614
|
+
}, vaultBodyLimit)
|
|
618
615
|
.delete("/api/vault/credentials/:connectionId", owner("direct"), async (context) => {
|
|
619
616
|
const connectionId = context.req.param("connectionId");
|
|
620
617
|
const input = await body(context.req.raw, revokeCredentialSchema);
|
|
@@ -623,7 +620,7 @@ function vaultRoutes(agents) {
|
|
|
623
620
|
return input === null
|
|
624
621
|
? refusal(400, "invalid_input")
|
|
625
622
|
: answer({ op: "revokeCredential", connectionId, ...input });
|
|
626
|
-
})
|
|
623
|
+
}, vaultBodyLimit)
|
|
627
624
|
.put("/api/vault/credentials/:connectionId/subjects/:kind/:subjectId", owner("direct"), (context) => {
|
|
628
625
|
const connectionId = context.req.param("connectionId");
|
|
629
626
|
const subject = subjectOf(context.req.param("kind"), context.req.param("subjectId"));
|
|
@@ -684,9 +681,6 @@ export function connectionRoutes(agents) {
|
|
|
684
681
|
});
|
|
685
682
|
})
|
|
686
683
|
.post("/api/connections", owner("direct"), async (context) => {
|
|
687
|
-
const length = Number(context.req.header("content-length") ?? "0");
|
|
688
|
-
if (length > 16 * 1024)
|
|
689
|
-
return refusal(413, "Request too large");
|
|
690
684
|
const input = Schema.decodeUnknownOption(Schema.fromJsonString(connectionInputSchema), { onExcessProperty: "error" })(await context.req.text());
|
|
691
685
|
if (input._tag === "None")
|
|
692
686
|
return refusal(400, "Name the server (lowercase letters, digits, _) and give its https:// endpoint");
|
|
@@ -696,7 +690,7 @@ export function connectionRoutes(agents) {
|
|
|
696
690
|
return "error" in added
|
|
697
691
|
? refusal(connectionRefusalStatus[added.error], added.error)
|
|
698
692
|
: Response.json(added, { status: 201 });
|
|
699
|
-
})
|
|
693
|
+
}, bodyAtMost(16 * 1024))
|
|
700
694
|
// The authorization server's redirect: the owner's browser, signed in.
|
|
701
695
|
.get("/api/connections/callback", owner("direct"), async (context) => {
|
|
702
696
|
const query = context.req.query();
|
|
@@ -728,9 +722,6 @@ export function connectionRoutes(agents) {
|
|
|
728
722
|
if (!connectionIdPattern.test(connectionId) ||
|
|
729
723
|
!agentIdPattern.test(agentId))
|
|
730
724
|
return refusal(404, "No such connection");
|
|
731
|
-
const length = Number(context.req.header("content-length") ?? "0");
|
|
732
|
-
if (length > 64 * 1024)
|
|
733
|
-
return refusal(413, "Request too large");
|
|
734
725
|
const input = Schema.decodeUnknownOption(Schema.fromJsonString(accessSchema), { onExcessProperty: "error" })(await context.req.text());
|
|
735
726
|
if (input._tag === "None")
|
|
736
727
|
return refusal(400, "Choose all, read, or a list of tools");
|
|
@@ -738,7 +729,7 @@ export function connectionRoutes(agents) {
|
|
|
738
729
|
return "error" in granted
|
|
739
730
|
? refusal(connectionRefusalStatus[granted.error], granted.error)
|
|
740
731
|
: new Response(null, { status: 204 });
|
|
741
|
-
})
|
|
732
|
+
}, bodyAtMost(64 * 1024))
|
|
742
733
|
.delete("/api/connections/:connectionId/agents/:agentId", owner("direct"), async (context) => {
|
|
743
734
|
const connectionId = context.req.param("connectionId");
|
|
744
735
|
const agentId = context.req.param("agentId");
|
package/dist/auth.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as Option from "effect/Option";
|
|
2
2
|
import * as Schema from "effect/Schema";
|
|
3
|
+
import { parse } from "hono/utils/cookie";
|
|
3
4
|
import { presentedGitKey } from "./git-auth.js";
|
|
4
5
|
import { sha256 } from "./release.js";
|
|
5
6
|
import { isLoopbackHttp } from "./tenancy/registry-record.js";
|
|
@@ -48,12 +49,9 @@ export function ownerKeyAuth(ownerKey, ownerId = "owner") {
|
|
|
48
49
|
? owner
|
|
49
50
|
: { kind: "refused", status: 401 };
|
|
50
51
|
}
|
|
51
|
-
const cookie = (request.headers.get("Cookie") ?? "")
|
|
52
|
-
.split(";")
|
|
53
|
-
.map((part) => part.trim())
|
|
54
|
-
.find((part) => part.startsWith(`${ownerKeyCookieName}=`));
|
|
52
|
+
const cookie = parse(request.headers.get("Cookie") ?? "", ownerKeyCookieName)[ownerKeyCookieName];
|
|
55
53
|
if (cookie !== undefined &&
|
|
56
|
-
(await constantTimeEqual(cookie
|
|
54
|
+
(await constantTimeEqual(cookie, await sessionValue)))
|
|
57
55
|
return owner;
|
|
58
56
|
return { kind: "refused", status: 401 };
|
|
59
57
|
},
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refuse a request body over `maxSize` bytes while it is read, with a 413.
|
|
3
|
+
* Content-Length is not trusted: a chunked body is counted as it arrives and
|
|
4
|
+
* never buffered past the limit. Pass the result as a route's options.
|
|
5
|
+
*/
|
|
6
|
+
export declare const bodyAtMost: (maxSize: number, error?: string) => {
|
|
7
|
+
middleware: import("hono").MiddlewareHandler[];
|
|
8
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { bodyLimit } from "hono/body-limit";
|
|
2
|
+
/**
|
|
3
|
+
* Refuse a request body over `maxSize` bytes while it is read, with a 413.
|
|
4
|
+
* Content-Length is not trusted: a chunked body is counted as it arrives and
|
|
5
|
+
* never buffered past the limit. Pass the result as a route's options.
|
|
6
|
+
*/
|
|
7
|
+
export const bodyAtMost = (maxSize, error = "Request too large") => ({
|
|
8
|
+
middleware: [
|
|
9
|
+
bodyLimit({
|
|
10
|
+
maxSize,
|
|
11
|
+
onError: () => Response.json({ error }, { status: 413 }),
|
|
12
|
+
}),
|
|
13
|
+
],
|
|
14
|
+
});
|
package/dist/build/job-log.d.ts
CHANGED
|
@@ -22,8 +22,10 @@ export declare const keyWithheld = "[output withheld until the key ends]";
|
|
|
22
22
|
* (S3's gitleaks rules) runs before a byte is retained, so the stored log and
|
|
23
23
|
* every `?log` read of it are already scrubbed. `loadRedactor` is Veil's
|
|
24
24
|
* loader unless a caller wraps it (a test that counts scanned characters).
|
|
25
|
+
* `pendingCeiling` is the held-text ceiling; only tests lower it, so ceiling
|
|
26
|
+
* cases run on a few windows of text instead of megabytes.
|
|
25
27
|
*/
|
|
26
|
-
export declare function createBuildJobLog(loadRedactor?: () => Promise<PatternRedactor
|
|
28
|
+
export declare function createBuildJobLog(loadRedactor?: () => Promise<PatternRedactor>, pendingCeiling?: number): Promise<{
|
|
27
29
|
/** Retained buffer capacity, distinct from the transient encoded result. */
|
|
28
30
|
readonly allocatedBytes: number;
|
|
29
31
|
append(bytes: Uint8Array): void;
|
package/dist/build/job-log.js
CHANGED
|
@@ -126,8 +126,10 @@ async function loadRedactorOrWithhold(load) {
|
|
|
126
126
|
* (S3's gitleaks rules) runs before a byte is retained, so the stored log and
|
|
127
127
|
* every `?log` read of it are already scrubbed. `loadRedactor` is Veil's
|
|
128
128
|
* loader unless a caller wraps it (a test that counts scanned characters).
|
|
129
|
+
* `pendingCeiling` is the held-text ceiling; only tests lower it, so ceiling
|
|
130
|
+
* cases run on a few windows of text instead of megabytes.
|
|
129
131
|
*/
|
|
130
|
-
export async function createBuildJobLog(loadRedactor = loadPatternRedactor) {
|
|
132
|
+
export async function createBuildJobLog(loadRedactor = loadPatternRedactor, pendingCeiling = maxPendingText) {
|
|
131
133
|
const ring = createBoundedLog();
|
|
132
134
|
// A rule table that cannot load stores the withheld notice, never the output.
|
|
133
135
|
const { redactor } = await loadRedactorOrWithhold(loadRedactor);
|
|
@@ -151,7 +153,7 @@ export async function createBuildJobLog(loadRedactor = loadPatternRedactor) {
|
|
|
151
153
|
// whole if the output ends first, or through its end if the held text
|
|
152
154
|
// reaches the ceiling first.
|
|
153
155
|
const open = redactor.openFrom(pending);
|
|
154
|
-
const ceiling = pending.length >
|
|
156
|
+
const ceiling = pending.length > pendingCeiling;
|
|
155
157
|
// Still held from the start: nothing can leave, so skip the full scan.
|
|
156
158
|
if (!final && !ceiling && open?.opener.start === 0) {
|
|
157
159
|
scannedLength = pending.length;
|
|
@@ -230,7 +232,7 @@ export async function createBuildJobLog(loadRedactor = loadPatternRedactor) {
|
|
|
230
232
|
pending += text;
|
|
231
233
|
// Held text doubles before its next rescan, so holding stays linear.
|
|
232
234
|
if (pending.length >=
|
|
233
|
-
Math.min(
|
|
235
|
+
Math.min(pendingCeiling + 1, Math.max(2 * scanWindow, scannedLength + Math.max(scanWindow, scannedLength))))
|
|
234
236
|
scan(false);
|
|
235
237
|
},
|
|
236
238
|
finish() {
|