@mcsherrylabs/evolver-mcp 0.11.0 → 0.13.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/deploy/release.json +1 -1
- package/dist/application-signer.d.ts +16 -0
- package/dist/application-signer.d.ts.map +1 -0
- package/dist/application-signer.js +55 -0
- package/dist/application-signer.js.map +1 -0
- package/dist/approved-request.d.ts +30 -0
- package/dist/approved-request.d.ts.map +1 -0
- package/dist/approved-request.js +167 -0
- package/dist/approved-request.js.map +1 -0
- package/dist/attachment-tools.d.ts +3 -0
- package/dist/attachment-tools.d.ts.map +1 -0
- package/dist/attachment-tools.js +32 -0
- package/dist/attachment-tools.js.map +1 -0
- package/dist/attachments.d.ts +41 -0
- package/dist/attachments.d.ts.map +1 -0
- package/dist/attachments.js +458 -0
- package/dist/attachments.js.map +1 -0
- package/dist/content-file-tools.d.ts +3 -0
- package/dist/content-file-tools.d.ts.map +1 -0
- package/dist/content-file-tools.js +67 -0
- package/dist/content-file-tools.js.map +1 -0
- package/dist/content-files.d.ts +32 -0
- package/dist/content-files.d.ts.map +1 -0
- package/dist/content-files.js +79 -0
- package/dist/content-files.js.map +1 -0
- package/dist/content-ranges.d.ts +41 -0
- package/dist/content-ranges.d.ts.map +1 -0
- package/dist/content-ranges.js +75 -0
- package/dist/content-ranges.js.map +1 -0
- package/dist/content.d.ts +62 -19
- package/dist/content.d.ts.map +1 -1
- package/dist/content.js +180 -25
- package/dist/content.js.map +1 -1
- package/dist/files.d.ts +60 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +355 -0
- package/dist/files.js.map +1 -0
- package/dist/group-crypto-tools.d.ts +3 -0
- package/dist/group-crypto-tools.d.ts.map +1 -0
- package/dist/group-crypto-tools.js +47 -0
- package/dist/group-crypto-tools.js.map +1 -0
- package/dist/group-crypto.d.ts +24 -0
- package/dist/group-crypto.d.ts.map +1 -0
- package/dist/group-crypto.js +135 -0
- package/dist/group-crypto.js.map +1 -0
- package/dist/group-key-provider.d.ts +30 -0
- package/dist/group-key-provider.d.ts.map +1 -0
- package/dist/group-key-provider.js +72 -0
- package/dist/group-key-provider.js.map +1 -0
- package/dist/group-keys.d.ts +34 -0
- package/dist/group-keys.d.ts.map +1 -0
- package/dist/group-keys.js +88 -0
- package/dist/group-keys.js.map +1 -0
- package/dist/group-ownership.d.ts +78 -0
- package/dist/group-ownership.d.ts.map +1 -0
- package/dist/group-ownership.js +324 -0
- package/dist/group-ownership.js.map +1 -0
- package/dist/group.d.ts +2 -2
- package/dist/group.js +3 -3
- package/dist/group.js.map +1 -1
- package/dist/http-profiles.d.ts +47 -0
- package/dist/http-profiles.d.ts.map +1 -0
- package/dist/http-profiles.js +161 -0
- package/dist/http-profiles.js.map +1 -0
- package/dist/human-approval.d.ts +14 -0
- package/dist/human-approval.d.ts.map +1 -0
- package/dist/human-approval.js +34 -0
- package/dist/human-approval.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +94 -40
- package/dist/index.js.map +1 -1
- package/dist/login-profiles.d.ts +25 -0
- package/dist/login-profiles.d.ts.map +1 -0
- package/dist/login-profiles.js +77 -0
- package/dist/login-profiles.js.map +1 -0
- package/dist/login-tools.d.ts +3 -0
- package/dist/login-tools.d.ts.map +1 -0
- package/dist/login-tools.js +27 -0
- package/dist/login-tools.js.map +1 -0
- package/dist/login.d.ts +36 -0
- package/dist/login.d.ts.map +1 -0
- package/dist/login.js +144 -0
- package/dist/login.js.map +1 -0
- package/dist/mcp.d.ts +1 -0
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +22 -6
- package/dist/mcp.js.map +1 -1
- package/dist/node-transport.d.ts +14 -0
- package/dist/node-transport.d.ts.map +1 -0
- package/dist/node-transport.js +54 -0
- package/dist/node-transport.js.map +1 -0
- package/dist/p2p-tools.d.ts +3 -0
- package/dist/p2p-tools.d.ts.map +1 -0
- package/dist/p2p-tools.js +52 -0
- package/dist/p2p-tools.js.map +1 -0
- package/dist/p2p.d.ts +67 -0
- package/dist/p2p.d.ts.map +1 -0
- package/dist/p2p.js +326 -0
- package/dist/p2p.js.map +1 -0
- package/dist/proof-attempts.d.ts +19 -0
- package/dist/proof-attempts.d.ts.map +1 -0
- package/dist/proof-attempts.js +30 -0
- package/dist/proof-attempts.js.map +1 -0
- package/dist/read.d.ts +60 -1
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +97 -5
- package/dist/read.js.map +1 -1
- package/dist/signed-http-tools.d.ts +3 -0
- package/dist/signed-http-tools.d.ts.map +1 -0
- package/dist/signed-http-tools.js +33 -0
- package/dist/signed-http-tools.js.map +1 -0
- package/dist/signed-http.d.ts +30 -0
- package/dist/signed-http.d.ts.map +1 -0
- package/dist/signed-http.js +114 -0
- package/dist/signed-http.js.map +1 -0
- package/dist/tools.d.ts +27 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +243 -32
- package/dist/tools.js.map +1 -1
- package/dist/transaction-interchange-tools.d.ts +3 -0
- package/dist/transaction-interchange-tools.d.ts.map +1 -0
- package/dist/transaction-interchange-tools.js +41 -0
- package/dist/transaction-interchange-tools.js.map +1 -0
- package/dist/transaction-interchange.d.ts +141 -0
- package/dist/transaction-interchange.d.ts.map +1 -0
- package/dist/transaction-interchange.js +502 -0
- package/dist/transaction-interchange.js.map +1 -0
- package/dist/transaction-policy.d.ts +32 -0
- package/dist/transaction-policy.d.ts.map +1 -0
- package/dist/transaction-policy.js +89 -0
- package/dist/transaction-policy.js.map +1 -0
- package/dist/write.d.ts +52 -13
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +95 -25
- package/dist/write.js.map +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
// File-backed SDK attachment envelopes only. No cipher/nonce/header encoder or HTTP here.
|
|
2
|
+
// Public registry SDK0.22 owns every header, offset and cryptographic transform below.
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import { ATTACHMENT_HEADER_BYTES, SEG_BYTES, ctSize, parseAttachmentHeader, planAttachmentRange, encryptStream, decryptStream } from "@mcsherrylabs/evolver-client";
|
|
5
|
+
import { parseAccess, OPEN_NOTE, RESTRICTED_NOTE } from "./content.js";
|
|
6
|
+
import { byteInterval } from "./content-ranges.js";
|
|
7
|
+
import { FileAccessError, fileName } from "./files.js";
|
|
8
|
+
import { validScope } from "./group-key-provider.js";
|
|
9
|
+
import { ok, partial, misconfigured } from "./result.js";
|
|
10
|
+
export const ATTACHMENT_PLAINTEXT_CONFIRMATION = "write plaintext file in the authorized file root";
|
|
11
|
+
export const PUBLISHED_ATTACHMENT_SDK = Object.freeze({
|
|
12
|
+
ATTACHMENT_HEADER_BYTES, SEG_BYTES, ctSize, parseAttachmentHeader, planAttachmentRange, encryptStream, decryptStream,
|
|
13
|
+
});
|
|
14
|
+
class AttachmentError extends Error {
|
|
15
|
+
code;
|
|
16
|
+
constructor(code) {
|
|
17
|
+
super(`attachment: ${code}`);
|
|
18
|
+
this.code = code;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function refuse(code) { throw new AttachmentError(code); }
|
|
22
|
+
const nat = (n) => typeof n === "number" && Number.isSafeInteger(n) && n >= 0;
|
|
23
|
+
const contentKey = (key) => {
|
|
24
|
+
if (typeof key !== "string" || !/^[0-9a-f]{64}$/.test(key))
|
|
25
|
+
return refuse("invalid_request");
|
|
26
|
+
return key;
|
|
27
|
+
};
|
|
28
|
+
const disabled = () => misconfigured("attachment encryption unavailable", "requires an explicitly authorized EVOLVER_FILE_ROOT and independent group-crypto provider in this MCP process; configure both host capabilities and reload. Public SDK0.22 is installed; no fallback codec or live mutation.");
|
|
29
|
+
function authorized(deps, scope) {
|
|
30
|
+
if (!validScope(scope) || !deps.groupCrypto.provider.scopes.includes(scope))
|
|
31
|
+
refuse("scope_denied");
|
|
32
|
+
}
|
|
33
|
+
function plaintextAllowed(deps, confirmation) {
|
|
34
|
+
if (!deps.groupCrypto.provider.allowPlaintext || confirmation !== ATTACHMENT_PLAINTEXT_CONFIRMATION)
|
|
35
|
+
refuse("plaintext_denied");
|
|
36
|
+
}
|
|
37
|
+
function failure(e, uploading = false, uploadStarted = false) {
|
|
38
|
+
const cleanup = e instanceof FileAccessError && e.cleanupWarning ? "; staging_cleanup_failed; protected staging may remain" : "";
|
|
39
|
+
if (e instanceof FileAccessError && e.code === "commit_unconfirmed")
|
|
40
|
+
return partial("attachment", "output_commit_unconfirmed; a plaintext target may have become visible or remain present; removal was attempted if authorization failed after linking. Inspect the authorized file root; do not automatically retry." + cleanup);
|
|
41
|
+
if (e instanceof FileAccessError && e.code === "publication_unknown")
|
|
42
|
+
return partial("attachment", "output_publication_unknown; target may exist or have been visible; NOT a no-write refusal. Inspect the authorized file root; do not retry or automatically delete the final target." + cleanup);
|
|
43
|
+
const aftermath = uploading ? (uploadStarted ? "ciphertext storage may have completed; not retried or republished open" : "upload was not started; not retried or republished open") : "no completed plaintext output returned; not retried";
|
|
44
|
+
if (e instanceof AttachmentError)
|
|
45
|
+
return partial("attachment", `${e.code}; ${aftermath}`);
|
|
46
|
+
if (e instanceof FileAccessError)
|
|
47
|
+
return partial("attachment", `file_${e.code}; ${aftermath}${cleanup}`);
|
|
48
|
+
if (e instanceof Error && e.name === "AbortError")
|
|
49
|
+
return partial("attachment", `cancelled; ${aftermath}`);
|
|
50
|
+
const status = e instanceof Error ? /^(?:postContentStream|getContentStream(?: [0-9a-f]{1,12})?): HTTP ([1-5][0-9]{2})\b/.exec(e.message)?.[1] : undefined;
|
|
51
|
+
if (status)
|
|
52
|
+
return partial("attachment", `content_http_${status}; ${aftermath}`);
|
|
53
|
+
return partial("attachment", `transport_or_key_failure; ${aftermath}`);
|
|
54
|
+
}
|
|
55
|
+
/** Manual signal chaining keeps the Node20 surface small. The key callback spans every read,
|
|
56
|
+
* transform, write and commit; no deferred stream outlives a wiped temporary key copy. */
|
|
57
|
+
async function leased(deps, scope, handle, caller, job) {
|
|
58
|
+
if (typeof handle !== "string")
|
|
59
|
+
return refuse("key_unavailable");
|
|
60
|
+
let leaseSignal, entered = false;
|
|
61
|
+
try {
|
|
62
|
+
return await deps.groupCrypto.handles.withLease(scope, handle, async (key, lease) => {
|
|
63
|
+
entered = true;
|
|
64
|
+
leaseSignal = lease.signal;
|
|
65
|
+
const controller = new AbortController();
|
|
66
|
+
const forward = () => controller.abort();
|
|
67
|
+
const sources = caller ? [caller, lease.signal] : [lease.signal];
|
|
68
|
+
for (const source of sources)
|
|
69
|
+
source.addEventListener("abort", forward, { once: true });
|
|
70
|
+
if (sources.some(s => s.aborted))
|
|
71
|
+
controller.abort();
|
|
72
|
+
try {
|
|
73
|
+
return await deps.files.transfer(files => job(key, lease, files), controller.signal);
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
for (const source of sources)
|
|
77
|
+
source.removeEventListener("abort", forward);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
if (e instanceof FileAccessError && (e.code === "commit_unconfirmed" || e.code === "publication_unknown" || e.cleanupWarning))
|
|
83
|
+
throw e;
|
|
84
|
+
if (!entered)
|
|
85
|
+
refuse("key_unavailable");
|
|
86
|
+
if (leaseSignal?.aborted)
|
|
87
|
+
refuse("lease_invalid");
|
|
88
|
+
throw e;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** Exact streamed bytes and incremental hash, never a proportional buffer. Retains underlying
|
|
92
|
+
* transport failure separately because the shared file writer deliberately scrubs stream errors. */
|
|
93
|
+
function measured(source, size, signal, problem, readFailure) {
|
|
94
|
+
const reader = source.getReader(), hash = createHash("sha256");
|
|
95
|
+
let count = 0, complete = false, digest = "", released = false;
|
|
96
|
+
const onAbort = () => { void reader.cancel().catch(() => undefined); };
|
|
97
|
+
const release = () => { if (!released) {
|
|
98
|
+
signal.removeEventListener("abort", onAbort);
|
|
99
|
+
reader.releaseLock();
|
|
100
|
+
released = true;
|
|
101
|
+
} };
|
|
102
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
103
|
+
if (signal.aborted)
|
|
104
|
+
onAbort();
|
|
105
|
+
const stream = new ReadableStream({
|
|
106
|
+
async pull(ctrl) {
|
|
107
|
+
try {
|
|
108
|
+
if (signal.aborted)
|
|
109
|
+
throw new FileAccessError("cancelled");
|
|
110
|
+
const { done, value } = await reader.read();
|
|
111
|
+
if (signal.aborted)
|
|
112
|
+
throw new FileAccessError("cancelled");
|
|
113
|
+
if (done) {
|
|
114
|
+
if (count !== size)
|
|
115
|
+
refuse("incomplete_transfer");
|
|
116
|
+
complete = true;
|
|
117
|
+
digest = hash.digest("hex");
|
|
118
|
+
release();
|
|
119
|
+
ctrl.close();
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (!(value instanceof Uint8Array) || value.length > size - count)
|
|
123
|
+
refuse("incomplete_transfer");
|
|
124
|
+
count += value.length;
|
|
125
|
+
hash.update(value);
|
|
126
|
+
ctrl.enqueue(value);
|
|
127
|
+
}
|
|
128
|
+
catch (e) {
|
|
129
|
+
if (!signal.aborted)
|
|
130
|
+
problem.error ??= e instanceof AttachmentError ? e : new AttachmentError(readFailure);
|
|
131
|
+
await reader.cancel().catch(() => undefined);
|
|
132
|
+
release();
|
|
133
|
+
ctrl.error(e);
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
async cancel() { await reader.cancel().catch(() => undefined); release(); },
|
|
137
|
+
}, { highWaterMark: 0 });
|
|
138
|
+
return { stream, metadata() { if (!complete)
|
|
139
|
+
return refuse("incomplete_transfer"); return { size: count, sha256: digest }; } };
|
|
140
|
+
}
|
|
141
|
+
/** Observe SDK failures without reflecting its exception text. Pipe cancellation propagates to
|
|
142
|
+
* the actual client stream. Only the shared file writer ever publishes a final basename. */
|
|
143
|
+
function authenticated(source, signal, problem) {
|
|
144
|
+
const reader = source.getReader();
|
|
145
|
+
let released = false;
|
|
146
|
+
const release = () => { if (!released) {
|
|
147
|
+
reader.releaseLock();
|
|
148
|
+
released = true;
|
|
149
|
+
} };
|
|
150
|
+
return new ReadableStream({
|
|
151
|
+
async pull(ctrl) {
|
|
152
|
+
try {
|
|
153
|
+
if (signal.aborted)
|
|
154
|
+
throw new FileAccessError("cancelled");
|
|
155
|
+
const { done, value } = await reader.read();
|
|
156
|
+
if (done) {
|
|
157
|
+
release();
|
|
158
|
+
ctrl.close();
|
|
159
|
+
}
|
|
160
|
+
else
|
|
161
|
+
ctrl.enqueue(value);
|
|
162
|
+
}
|
|
163
|
+
catch (e) {
|
|
164
|
+
if (!signal.aborted)
|
|
165
|
+
problem.error ??= new AttachmentError("authentication_or_incomplete");
|
|
166
|
+
await reader.cancel().catch(() => undefined);
|
|
167
|
+
release();
|
|
168
|
+
ctrl.error(e);
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
async cancel() { await reader.cancel().catch(() => undefined); release(); },
|
|
172
|
+
}, { highWaterMark: 0 });
|
|
173
|
+
}
|
|
174
|
+
/** Read only the small SDK-authoritative prefix, keeping at most the current source chunk. */
|
|
175
|
+
async function prefixOf(source, size) {
|
|
176
|
+
const reader = source.getReader(), prefix = new Uint8Array(size);
|
|
177
|
+
let used = 0, remainder;
|
|
178
|
+
try {
|
|
179
|
+
while (used < size) {
|
|
180
|
+
const next = await reader.read();
|
|
181
|
+
if (next.done)
|
|
182
|
+
refuse("invalid_envelope");
|
|
183
|
+
const n = Math.min(next.value.length, size - used);
|
|
184
|
+
prefix.set(next.value.subarray(0, n), used);
|
|
185
|
+
used += n;
|
|
186
|
+
if (n < next.value.length)
|
|
187
|
+
remainder = next.value.subarray(n);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
catch (e) {
|
|
191
|
+
await reader.cancel().catch(() => undefined);
|
|
192
|
+
reader.releaseLock();
|
|
193
|
+
throw e;
|
|
194
|
+
}
|
|
195
|
+
let first = true, released = false;
|
|
196
|
+
const release = () => { if (!released) {
|
|
197
|
+
reader.releaseLock();
|
|
198
|
+
released = true;
|
|
199
|
+
} };
|
|
200
|
+
const stream = new ReadableStream({
|
|
201
|
+
async pull(ctrl) {
|
|
202
|
+
try {
|
|
203
|
+
if (first) {
|
|
204
|
+
first = false;
|
|
205
|
+
ctrl.enqueue(prefix);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if (remainder) {
|
|
209
|
+
ctrl.enqueue(remainder);
|
|
210
|
+
remainder = undefined;
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const next = await reader.read();
|
|
214
|
+
if (next.done) {
|
|
215
|
+
release();
|
|
216
|
+
ctrl.close();
|
|
217
|
+
}
|
|
218
|
+
else
|
|
219
|
+
ctrl.enqueue(next.value);
|
|
220
|
+
}
|
|
221
|
+
catch (e) {
|
|
222
|
+
await reader.cancel().catch(() => undefined);
|
|
223
|
+
release();
|
|
224
|
+
ctrl.error(e);
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
async cancel() { await reader.cancel().catch(() => undefined); release(); },
|
|
228
|
+
}, { highWaterMark: 0 });
|
|
229
|
+
return { prefix, stream };
|
|
230
|
+
}
|
|
231
|
+
function prepend(prefix, source) {
|
|
232
|
+
return source.pipeThrough(new TransformStream({
|
|
233
|
+
start(ctrl) { ctrl.enqueue(prefix); },
|
|
234
|
+
transform(chunk, ctrl) { ctrl.enqueue(chunk); },
|
|
235
|
+
}));
|
|
236
|
+
}
|
|
237
|
+
function trimmed(source, offset, length, decryptedBytes) {
|
|
238
|
+
let seen = 0, kept = 0;
|
|
239
|
+
return source.pipeThrough(new TransformStream({
|
|
240
|
+
transform(bytes, ctrl) {
|
|
241
|
+
if (bytes.length > decryptedBytes - seen)
|
|
242
|
+
refuse("incomplete_transfer");
|
|
243
|
+
const from = Math.max(0, offset - seen), to = Math.min(bytes.length, offset + length - seen);
|
|
244
|
+
if (to > from) {
|
|
245
|
+
ctrl.enqueue(bytes.subarray(from, to));
|
|
246
|
+
kept += to - from;
|
|
247
|
+
}
|
|
248
|
+
seen += bytes.length;
|
|
249
|
+
// Do NOT stop/cancel after requested bytes: authenticate/drain ALL covering segments.
|
|
250
|
+
},
|
|
251
|
+
flush() { if (seen !== decryptedBytes || kept !== length)
|
|
252
|
+
refuse("incomplete_transfer"); },
|
|
253
|
+
}));
|
|
254
|
+
}
|
|
255
|
+
export async function encryptUploadAttachment(deps, req, signal) {
|
|
256
|
+
const access = parseAccess(req.access, req.authorizedPrincipals);
|
|
257
|
+
if ("kind" in access)
|
|
258
|
+
return access;
|
|
259
|
+
if (!deps)
|
|
260
|
+
return disabled();
|
|
261
|
+
let held;
|
|
262
|
+
let uploadStarted = false;
|
|
263
|
+
const problem = {};
|
|
264
|
+
try {
|
|
265
|
+
authorized(deps, req.scope);
|
|
266
|
+
const scope = req.scope, file = fileName(req.file);
|
|
267
|
+
if (!Array.isArray(req.recipients) || req.recipients.length < 1 || req.recipients.length > 64)
|
|
268
|
+
refuse("invalid_request");
|
|
269
|
+
// GroupCrypto.wrap is the sole validator/resolver of registered, host-approved recipients.
|
|
270
|
+
const created = await deps.groupCrypto.create(scope);
|
|
271
|
+
if (created.kind !== "ok")
|
|
272
|
+
refuse("key_unavailable");
|
|
273
|
+
held = created.value;
|
|
274
|
+
const wrappedKeys = [];
|
|
275
|
+
for (const recipient of req.recipients) {
|
|
276
|
+
const wrapped = await deps.groupCrypto.wrap(scope, held.handle, recipient);
|
|
277
|
+
if (wrapped.kind !== "ok")
|
|
278
|
+
refuse("key_unavailable");
|
|
279
|
+
wrappedKeys.push(wrapped.value);
|
|
280
|
+
}
|
|
281
|
+
return await leased(deps, scope, held.handle, signal, async (key, lease, files) => files.withInput(file, async (input) => {
|
|
282
|
+
const size = deps.sdk.ctSize(input.size);
|
|
283
|
+
if (!nat(size) || size > files.maxBytes)
|
|
284
|
+
throw new FileAccessError("too_large");
|
|
285
|
+
lease.check();
|
|
286
|
+
const cipher = measured(input.stream.pipeThrough(deps.sdk.encryptStream(key).transform, { signal: files.signal }), size, files.signal, problem, "incomplete_transfer");
|
|
287
|
+
try {
|
|
288
|
+
uploadStarted = true;
|
|
289
|
+
const stored = await deps.client.postContentStream(cipher.stream, { size, signal: files.signal,
|
|
290
|
+
...(access.mode === "restricted" ? { authorizedPrincipals: access.principals } : {}) });
|
|
291
|
+
const ciphertext = cipher.metadata(), plaintext = input.metadata();
|
|
292
|
+
if (stored.size !== size)
|
|
293
|
+
refuse("incomplete_transfer");
|
|
294
|
+
const storedKey = contentKey(stored.key);
|
|
295
|
+
lease.check();
|
|
296
|
+
return ok({ ...held, key: storedKey, file, format: "sdk-attachment-v2", plaintextBytes: plaintext.size,
|
|
297
|
+
plaintextSha256: plaintext.sha256, plaintextHashScope: "full-plaintext", ciphertextBytes: size,
|
|
298
|
+
ciphertextSha256: ciphertext.sha256, ciphertextHashScope: "full-ciphertext", wrappedKeys,
|
|
299
|
+
access: access.mode, ...(access.mode === "restricted" ? { authorizedPrincipals: access.principals } : {}),
|
|
300
|
+
note: (access.mode === "restricted" ? RESTRICTED_NOTE : OPEN_NOTE) + " Encryption is independent of serving ACLs/availability; wrapped metadata is not publisher or membership proof." });
|
|
301
|
+
}
|
|
302
|
+
finally {
|
|
303
|
+
await cipher.stream.cancel().catch(() => undefined);
|
|
304
|
+
}
|
|
305
|
+
}));
|
|
306
|
+
}
|
|
307
|
+
catch (e) {
|
|
308
|
+
if (held) {
|
|
309
|
+
try {
|
|
310
|
+
deps.groupCrypto.handles.dispose(held.scope, held.handle);
|
|
311
|
+
}
|
|
312
|
+
catch { /* expired/disposed already */ }
|
|
313
|
+
}
|
|
314
|
+
return failure(e instanceof FileAccessError && (e.code === "commit_unconfirmed" || e.code === "publication_unknown" || e.cleanupWarning) ? e : problem.error ?? e, true, uploadStarted);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
export async function decryptAttachmentFile(deps, req, signal) {
|
|
318
|
+
if (!deps)
|
|
319
|
+
return disabled();
|
|
320
|
+
const problem = {};
|
|
321
|
+
try {
|
|
322
|
+
authorized(deps, req.scope);
|
|
323
|
+
plaintextAllowed(deps, req.confirmation);
|
|
324
|
+
const key = contentKey(req.key), file = fileName(req.file);
|
|
325
|
+
return await leased(deps, req.scope, req.handle, signal, async (held, lease, files) => {
|
|
326
|
+
const got = await deps.client.getContentStream(key, { signal: files.signal });
|
|
327
|
+
if (got === null)
|
|
328
|
+
return ok(null);
|
|
329
|
+
if (got.status !== 200 || got.range !== null || !nat(got.size)) {
|
|
330
|
+
await got.stream.cancel().catch(() => undefined);
|
|
331
|
+
refuse("incomplete_transfer");
|
|
332
|
+
}
|
|
333
|
+
if (got.size > files.maxBytes) {
|
|
334
|
+
await got.stream.cancel().catch(() => undefined);
|
|
335
|
+
throw new FileAccessError("too_large");
|
|
336
|
+
}
|
|
337
|
+
const cipher = measured(got.stream, got.size, files.signal, problem, "transport_failure");
|
|
338
|
+
let joined;
|
|
339
|
+
try {
|
|
340
|
+
const head = await prefixOf(cipher.stream, deps.sdk.ATTACHMENT_HEADER_BYTES);
|
|
341
|
+
joined = head.stream;
|
|
342
|
+
try {
|
|
343
|
+
deps.sdk.parseAttachmentHeader(head.prefix);
|
|
344
|
+
}
|
|
345
|
+
catch {
|
|
346
|
+
refuse("invalid_envelope");
|
|
347
|
+
}
|
|
348
|
+
lease.check();
|
|
349
|
+
const verified = authenticated(joined.pipeThrough(deps.sdk.decryptStream(held), { signal: files.signal }), files.signal, problem);
|
|
350
|
+
const saved = await files.writeNew(file, verified, undefined, { check: () => lease.check(), commit: () => lease.commit() });
|
|
351
|
+
const ciphertext = cipher.metadata();
|
|
352
|
+
return ok({ ...saved, key, scope: req.scope, format: "sdk-attachment-v2", integrity: "full-envelope",
|
|
353
|
+
hashScope: "full-plaintext", ciphertextBytes: ciphertext.size, ciphertextSha256: ciphertext.sha256,
|
|
354
|
+
ciphertextHashScope: "full-ciphertext", note: "Authenticated envelope finality, not publisher identity, chain membership, availability or serving ACLs." });
|
|
355
|
+
}
|
|
356
|
+
finally {
|
|
357
|
+
await joined?.cancel().catch(() => undefined);
|
|
358
|
+
await cipher.stream.cancel().catch(() => undefined);
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
catch (e) {
|
|
363
|
+
return failure(e instanceof FileAccessError && (e.code === "commit_unconfirmed" || e.code === "publication_unknown" || e.cleanupWarning) ? e : problem.error ?? e);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
async function requireRange(got, requested, total) {
|
|
367
|
+
const r = got.range;
|
|
368
|
+
if (got.status !== 206 || !r || !nat(r.totalSize) || r.totalSize < 1 || (total !== undefined && r.totalSize !== total) ||
|
|
369
|
+
r.from !== requested.from || r.toInclusive !== requested.toInclusive || r.toInclusive >= r.totalSize ||
|
|
370
|
+
!nat(got.size) || got.size !== requested.toInclusive - requested.from + 1) {
|
|
371
|
+
await got.stream.cancel().catch(() => undefined);
|
|
372
|
+
refuse("range_metadata_invalid");
|
|
373
|
+
}
|
|
374
|
+
return r.totalSize;
|
|
375
|
+
}
|
|
376
|
+
export async function decryptAttachmentRangeFile(deps, req, signal) {
|
|
377
|
+
if (!deps)
|
|
378
|
+
return disabled();
|
|
379
|
+
const problem = {};
|
|
380
|
+
try {
|
|
381
|
+
authorized(deps, req.scope);
|
|
382
|
+
plaintextAllowed(deps, req.confirmation);
|
|
383
|
+
const key = contentKey(req.key), file = fileName(req.file);
|
|
384
|
+
const requested = byteInterval(req.from, req.toInclusive, deps.files.maxBytes);
|
|
385
|
+
if ("kind" in requested)
|
|
386
|
+
return requested;
|
|
387
|
+
return await leased(deps, req.scope, req.handle, signal, async (held, lease, files) => {
|
|
388
|
+
const headerRange = { from: 0, toInclusive: deps.sdk.ATTACHMENT_HEADER_BYTES - 1 };
|
|
389
|
+
const head = await deps.client.getContentStream(key, { range: headerRange, signal: files.signal });
|
|
390
|
+
if (head === null)
|
|
391
|
+
return ok(null);
|
|
392
|
+
const total = await requireRange(head, headerRange);
|
|
393
|
+
if (total > files.maxBytes) {
|
|
394
|
+
await head.stream.cancel().catch(() => undefined);
|
|
395
|
+
throw new FileAccessError("too_large");
|
|
396
|
+
}
|
|
397
|
+
const header = new Uint8Array(deps.sdk.ATTACHMENT_HEADER_BYTES);
|
|
398
|
+
const headerInput = measured(head.stream, header.length, files.signal, problem, "transport_failure");
|
|
399
|
+
const reader = headerInput.stream.getReader();
|
|
400
|
+
let used = 0;
|
|
401
|
+
try {
|
|
402
|
+
for (;;) {
|
|
403
|
+
const next = await reader.read();
|
|
404
|
+
if (next.done)
|
|
405
|
+
break;
|
|
406
|
+
header.set(next.value, used);
|
|
407
|
+
used += next.value.length;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
finally {
|
|
411
|
+
await reader.cancel().catch(() => undefined);
|
|
412
|
+
reader.releaseLock();
|
|
413
|
+
}
|
|
414
|
+
try {
|
|
415
|
+
deps.sdk.parseAttachmentHeader(header);
|
|
416
|
+
}
|
|
417
|
+
catch {
|
|
418
|
+
refuse("invalid_envelope");
|
|
419
|
+
}
|
|
420
|
+
let plan;
|
|
421
|
+
try {
|
|
422
|
+
plan = deps.sdk.planAttachmentRange(header, total, requested);
|
|
423
|
+
}
|
|
424
|
+
catch {
|
|
425
|
+
return refuse("invalid_range_or_layout");
|
|
426
|
+
}
|
|
427
|
+
lease.check();
|
|
428
|
+
const selected = await deps.client.getContentStream(key, { range: plan.ciphertextRange, signal: files.signal });
|
|
429
|
+
// Missing between the two reads is not an empty range or a partial success.
|
|
430
|
+
if (selected === null)
|
|
431
|
+
return partial("attachment", "content_missing_during_range; no completed plaintext output returned");
|
|
432
|
+
await requireRange(selected, plan.ciphertextRange, total);
|
|
433
|
+
const cipher = measured(selected.stream, selected.size, files.signal, problem, "transport_failure");
|
|
434
|
+
let verified;
|
|
435
|
+
try {
|
|
436
|
+
verified = authenticated(prepend(header, cipher.stream).pipeThrough(deps.sdk.decryptStream(held, { rangeMode: plan.rangeMode }), { signal: files.signal }), files.signal, problem);
|
|
437
|
+
const output = trimmed(verified, plan.trim.offset, plan.trim.length, plan.decryptedBytes);
|
|
438
|
+
const saved = await files.writeNew(file, output, plan.trim.length, lease);
|
|
439
|
+
cipher.metadata();
|
|
440
|
+
return ok({ file: saved.file, size: saved.size, sha256: saved.sha256,
|
|
441
|
+
...(saved.cleanupWarning ? { cleanupWarning: saved.cleanupWarning } : {}), key, scope: req.scope,
|
|
442
|
+
format: "sdk-attachment-v2", hashScope: "selected-plaintext-range", integrity: "selected-segments",
|
|
443
|
+
complete: false, rangeComplete: true, fileComplete: true, requested, ciphertextRange: plan.ciphertextRange,
|
|
444
|
+
ciphertextBytesDeclared: total, plaintextBytesInferred: plan.plaintextBytesInferred,
|
|
445
|
+
firstSegIndex: plan.firstSegIndex, lastSegIndex: plan.lastSegIndex,
|
|
446
|
+
note: "Selected segments authenticated only, EVEN for an all-selected range. Declared layout/inferred size is untrusted; no whole-file finality/hash, publisher identity, membership or availability proof." });
|
|
447
|
+
}
|
|
448
|
+
finally {
|
|
449
|
+
await verified?.cancel().catch(() => undefined);
|
|
450
|
+
await cipher.stream.cancel().catch(() => undefined);
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
catch (e) {
|
|
455
|
+
return failure(e instanceof FileAccessError && (e.code === "commit_unconfirmed" || e.code === "publication_unknown" || e.cleanupWarning) ? e : problem.error ?? e);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
//# sourceMappingURL=attachments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachments.js","sourceRoot":"","sources":["../src/attachments.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,uFAAuF;AACvF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,EAAE,qBAAqB,EAAE,mBAAmB,EAC7F,aAAa,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,c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AE,KAAK,EAAE,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;oBACnF,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY;oBAClE,IAAI,EAAE,sMAAsM,EAAE,CAAC,CAAC;YACpN,CAAC;oBAAS,CAAC;gBAAC,MAAM,QAAQ,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;gBAAC,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YAAC,CAAC;QACrH,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QAAC,OAAO,OAAO,CAAC,CAAC,YAAY,eAAe,IAAI,CAAC,CAAC,CAAC,IAAI,KAAK,oBAAoB,IAAI,CAAC,CAAC,IAAI,KAAK,qBAAqB,IAAI,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;IAAC,CAAC;AACrL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-file-tools.d.ts","sourceRoot":"","sources":["../src/content-file-tools.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAe3C,eAAO,MAAM,kBAAkB,EAAE,QAAQ,EAqDxC,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { publishFile, fetchFile } from "./content-files.js";
|
|
3
|
+
import { fetchRangeFile } from "./content-ranges.js";
|
|
4
|
+
import { CONTENT_MAX_PRINCIPALS } from "./content.js";
|
|
5
|
+
import { UNTRUSTED } from "./mcp.js";
|
|
6
|
+
const FILE_POLICY = " file is one server-local basename (1-128 ASCII letters/digits/._-, starting letter/digit), " +
|
|
7
|
+
"not a client path; nested paths, traversal, symlinks, hardlinked/nonregular inputs are refused. " +
|
|
8
|
+
"Requires operator EVOLVER_FILE_ROOT (dedicated Linux0700 directory, procfs) and reload; " +
|
|
9
|
+
"client-declared MCP roots are not authorization. Default64MiB, operator bound up to1GiB, " +
|
|
10
|
+
"one transfer per session root. Hash is SHA-256 of actual transferred bytes, separate from key " +
|
|
11
|
+
"(a key can name a manifest). No binary/base64 payload is returned. Cancellation retires local " +
|
|
12
|
+
"resources; an upload may already have reached node storage. No total transfer deadline." + UNTRUSTED;
|
|
13
|
+
export const FILE_CONTENT_TOOLS = [
|
|
14
|
+
{
|
|
15
|
+
name: "evolver_content_put_file", label: "Publish content from host file",
|
|
16
|
+
description: "Stream an explicitly authorized host file into the node's separate content listener. " +
|
|
17
|
+
"access MUST be open or restricted; restricted needs1-32 valid identity/group authorizedPrincipals. " +
|
|
18
|
+
"Never retries open after an ACL error. ACLs control honest peer NODES, not the trusted local " +
|
|
19
|
+
"listener, storage operator or prior recipients; not encryption. Identical-byte grants merge " +
|
|
20
|
+
"by union: a narrower re-publication cannot retract an earlier open/wider grant. Returns only " +
|
|
21
|
+
"key,file,size,sha256,complete,access and grant metadata. It signs/submits no transaction." + FILE_POLICY,
|
|
22
|
+
parameters: Type.Object({
|
|
23
|
+
file: Type.String({ description: "Approved input basename under the operator's server-local file root" }),
|
|
24
|
+
access: Type.String({ description: 'Required: "open" or "restricted"; never inferred' }),
|
|
25
|
+
authorizedPrincipals: Type.Optional(Type.Array(Type.String(), { maxItems: CONTENT_MAX_PRINCIPALS,
|
|
26
|
+
description: "Only with restricted:1-32 identity/group principal names (duplicates collapse)" })),
|
|
27
|
+
}, { additionalProperties: false }),
|
|
28
|
+
run: async (ctx, params) => publishFile(ctx.contentFiles, params, ctx.signal),
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "evolver_content_get_file", label: "Download content into new host file",
|
|
32
|
+
description: "Stream a COMPLETE object by64-lowercase-hex content key into a NEW host file. " +
|
|
33
|
+
"Protected0600 staging is atomically promoted without overwriting ANY existing target only " +
|
|
34
|
+
"after exact byte-count verification and incremental hashing. Failure/cancellation cleans " +
|
|
35
|
+
"staging; no incomplete file is returned as complete. ok:null means SDK no-reachable-holder " +
|
|
36
|
+
"HTTP404, not a global absence proof; transport failure is unreachable, not null. " +
|
|
37
|
+
"Output metadata is key,file,size,sha256,complete:true. No partial/range object is accepted." + FILE_POLICY,
|
|
38
|
+
parameters: Type.Object({
|
|
39
|
+
key: Type.String({ description: "Exactly64 lowercase hex characters; immutable content identity, not assumed whole-object SHA-256" }),
|
|
40
|
+
file: Type.String({ description: "New output basename; existing files and symlinks are never overwritten" }),
|
|
41
|
+
}, { additionalProperties: false }),
|
|
42
|
+
run: async (ctx, params) => fetchFile(ctx.contentFiles, params, ctx.signal),
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "evolver_content_get_range_file", label: "Download one content byte range into new file",
|
|
46
|
+
description: "Retrieve one INCLUSIVE [from,toInclusive] byte interval into a NEW host file, " +
|
|
47
|
+
"using validated SDK206 status/served offsets/total. Bounds must be non-negative safe integers, " +
|
|
48
|
+
"from <= toInclusive; requested count must fit the configured file byte cap BEFORE I/O. " +
|
|
49
|
+
"An end past EOF is clipped by the node when the start is satisfiable; requested and served " +
|
|
50
|
+
"intervals plus clipped flag are distinct. An ignored Range/full200 is refused and cancelled, " +
|
|
51
|
+
"never silently saved, retried full or labeled range success. HTTP416 returns status:" +
|
|
52
|
+
"unsatisfiable with known totalSize or null (never inferred); ok:null means no reachable holder, " +
|
|
53
|
+
"not global absence. Transport/integrity failure is not an unsatisfiable/missing interval. " +
|
|
54
|
+
"Success reports key,file,size,sha256,hashScope:served-range,complete:false(original object), " +
|
|
55
|
+
"rangeComplete:true(served interval),fileComplete:true,requested,served and clipped. The hash " +
|
|
56
|
+
"describes ONLY selected bytes, not the whole object. Atomic no-overwrite and cleanup reuse " +
|
|
57
|
+
"the full-file policy; no append/merge/resume orchestration or payload returned." + FILE_POLICY,
|
|
58
|
+
parameters: Type.Object({
|
|
59
|
+
key: Type.String({ description: "Exactly64 lowercase hex characters identifying the immutable original content" }),
|
|
60
|
+
file: Type.String({ description: "New output basename; no overwrite or append" }),
|
|
61
|
+
from: Type.Number({ description: "Inclusive first byte offset, integer0..Number.MAX_SAFE_INTEGER" }),
|
|
62
|
+
toInclusive: Type.Number({ description: "Inclusive final requested offset, safe integer >=from; requested length bounded before I/O" }),
|
|
63
|
+
}, { additionalProperties: false }),
|
|
64
|
+
run: async (ctx, params) => fetchRangeFile(ctx.contentFiles, params, ctx.signal),
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
//# sourceMappingURL=content-file-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-file-tools.js","sourceRoot":"","sources":["../src/content-file-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,WAAW,GACf,8FAA8F;IAC9F,kGAAkG;IAClG,0FAA0F;IAC1F,2FAA2F;IAC3F,gGAAgG;IAChG,gGAAgG;IAChG,yFAAyF,GAAG,SAAS,CAAC;AAExG,MAAM,CAAC,MAAM,kBAAkB,GAAe;IAC5C;QACE,IAAI,EAAE,0BAA0B,EAAE,KAAK,EAAE,gCAAgC;QACzE,WAAW,EAAE,uFAAuF;YAClG,qGAAqG;YACrG,+FAA+F;YAC/F,8FAA8F;YAC9F,+FAA+F;YAC/F,2FAA2F,GAAG,WAAW;QAC3G,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC;YACtB,IAAI,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FAA+F;YAC/F,sFAAsF;YACtF,kGAAkG;YAClG,4FAA4F;YAC5F,+FAA+F;YAC/F,+FAA+F;YAC/F,6FAA6F;YAC7F,iFAAiF,GAAG,WAAW;QACjG,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC;YACtB,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,+EAA+E,EAAE,CAAC;YAClH,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,6CAA6C,EAAE,CAAC;YACjF,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,gEAAgE,EAAE,CAAC;YACpG,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,4FAA4F,EAAE,CAAC;SACxI,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;QACnC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC;KACjF;CACF,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { NodeClient } from "@mcsherrylabs/evolver-client";
|
|
2
|
+
import type { FileRoot, FileMetadata } from "./files.js";
|
|
3
|
+
import type { ToolResult } from "./result.js";
|
|
4
|
+
export type FileContentClient = Pick<NodeClient, "postContentStream" | "getContentStream">;
|
|
5
|
+
export interface FileContentDeps {
|
|
6
|
+
readonly files: FileRoot;
|
|
7
|
+
readonly client: FileContentClient;
|
|
8
|
+
readonly contentUrl: string;
|
|
9
|
+
}
|
|
10
|
+
export type FilePublished = FileMetadata & {
|
|
11
|
+
key: string;
|
|
12
|
+
access: "open" | "restricted";
|
|
13
|
+
authorizedPrincipals?: string[];
|
|
14
|
+
note: string;
|
|
15
|
+
};
|
|
16
|
+
export type FileFetched = FileMetadata & {
|
|
17
|
+
key: string;
|
|
18
|
+
};
|
|
19
|
+
/** Deliberately do not echo exceptions/response text/host paths: a server can reflect content,
|
|
20
|
+
* and some TLS errors include certificate details. A completed HTTP refusal is not transport loss. */
|
|
21
|
+
export declare function contentFileFailure(e: unknown, url: string, operation: "publish" | "download" | "range"): ToolResult<never>;
|
|
22
|
+
export declare const contentFileDisabled: () => ToolResult<never>;
|
|
23
|
+
export declare function publishFile(deps: FileContentDeps | undefined, req: {
|
|
24
|
+
file?: unknown;
|
|
25
|
+
access?: unknown;
|
|
26
|
+
authorizedPrincipals?: unknown;
|
|
27
|
+
}, signal?: AbortSignal): Promise<ToolResult<FilePublished>>;
|
|
28
|
+
export declare function fetchFile(deps: FileContentDeps | undefined, req: {
|
|
29
|
+
key?: unknown;
|
|
30
|
+
file?: unknown;
|
|
31
|
+
}, signal?: AbortSignal): Promise<ToolResult<FileFetched | null>>;
|
|
32
|
+
//# sourceMappingURL=content-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-files.d.ts","sourceRoot":"","sources":["../src/content-files.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,UAAU,EAAE,mBAAmB,GAAG,kBAAkB,CAAC,CAAC;AAC3F,MAAM,WAAW,eAAe;IAAG,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE;AAC9H,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAAC;IAAC,oBAAoB,CAA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