@sentropic/artifacts 0.2.12 → 0.2.14
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/CHANGELOG.md +93 -0
- package/README.md +45 -10
- package/dist/adapters/local-blob.d.ts +3 -0
- package/dist/adapters/local-blob.js +93 -0
- package/dist/adapters/postgres-management.js +3 -2
- package/dist/adapters/postgres-reader-consent.d.ts +11 -0
- package/dist/adapters/postgres-reader-consent.js +109 -0
- package/dist/adapters/postgres-uploads.d.ts +14 -0
- package/dist/adapters/postgres-uploads.js +174 -0
- package/dist/adapters/postgres.js +4 -3
- package/dist/adapters/s3-uploads.d.ts +33 -0
- package/dist/adapters/s3-uploads.js +105 -0
- package/dist/adapters/s3.js +23 -0
- package/dist/adapters/sqlite-activation.d.ts +20 -0
- package/dist/adapters/sqlite-activation.js +205 -0
- package/dist/adapters/sqlite-commit.d.ts +15 -0
- package/dist/adapters/sqlite-commit.js +89 -0
- package/dist/adapters/sqlite-management.d.ts +10 -0
- package/dist/adapters/sqlite-management.js +60 -0
- package/dist/adapters/sqlite-sql.d.ts +32 -0
- package/dist/adapters/sqlite-sql.js +36 -0
- package/dist/adapters/sqlite-store.d.ts +12 -0
- package/dist/adapters/sqlite-store.js +410 -0
- package/dist/adapters/sqlite.d.ts +33 -0
- package/dist/adapters/sqlite.js +95 -0
- package/dist/content/handler.d.ts +5 -0
- package/dist/content/handler.js +80 -9
- package/dist/content/headers.js +12 -0
- package/dist/http.d.ts +32 -2
- package/dist/http.js +615 -13
- package/dist/mcp-core.d.ts +3 -3
- package/dist/mcp-core.js +90 -4
- package/dist/profile/contracts.d.ts +1 -1
- package/dist/profile/contracts.js +7 -0
- package/dist/profile/index.js +43 -2
- package/dist/profile/radar.js +7 -0
- package/dist/profile/schemas.js +119 -0
- package/dist/profile/validation.d.ts +11 -0
- package/dist/profile/validation.js +98 -6
- package/dist/server/access.d.ts +2 -0
- package/dist/server/command-identity.d.ts +1 -1
- package/dist/server/command-identity.js +6 -3
- package/dist/server/consent.d.ts +65 -0
- package/dist/server/consent.js +42 -0
- package/dist/server/gc.d.ts +42 -0
- package/dist/server/gc.js +98 -0
- package/dist/server/management.d.ts +3 -1
- package/dist/server/management.js +48 -7
- package/dist/server/metrics.d.ts +21 -0
- package/dist/server/metrics.js +6 -0
- package/dist/server/mime.d.ts +26 -2
- package/dist/server/mime.js +124 -2
- package/dist/server/ports.d.ts +29 -0
- package/dist/server/ports.js +11 -0
- package/dist/server/publication-limits.d.ts +20 -0
- package/dist/server/publication-limits.js +27 -1
- package/dist/server/publication.d.ts +14 -0
- package/dist/server/publication.js +10 -2
- package/dist/server/reader-store.d.ts +58 -0
- package/dist/server/reader-store.js +109 -0
- package/dist/server/source-read.d.ts +12 -9
- package/dist/server/source-read.js +17 -5
- package/dist/server/templates.js +50 -2
- package/dist/server/upload-page.d.ts +157 -0
- package/dist/server/upload-page.js +438 -0
- package/dist/server/uploads.d.ts +229 -19
- package/dist/server/uploads.js +387 -80
- package/migrations/0007_uploads.sql +43 -0
- package/migrations/0008_reader_consent.sql +48 -0
- package/migrations/0009_upload_pages.sql +25 -0
- package/package.json +34 -1
- package/sql/reader-consent.sql +47 -0
- package/sql/sqlite/0001_artifacts.sql +156 -0
- package/sql/sqlite/0002_activation.sql +73 -0
package/dist/server/mime.js
CHANGED
|
@@ -1,7 +1,129 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Canonical text-mime pattern shared by publication input rules and source
|
|
3
|
-
* reads
|
|
4
|
-
*
|
|
3
|
+
* reads, plus the generic MIME ceiling and byte validation (files parity
|
|
4
|
+
* LOT 1). Leaf module: `http.ts`, `server/source-read.ts`, `server/uploads.ts`
|
|
5
|
+
* and `profile/index.ts` import it without an import cycle.
|
|
6
|
+
*
|
|
7
|
+
* The ceiling is the generic server maximum: a profile `mimeTypes` list must
|
|
8
|
+
* be a subset of it (checked at profile compile time). Validation at commit
|
|
9
|
+
* (upload commit and inline publish alike): magic bytes for binary types,
|
|
10
|
+
* strict UTF-8 for text types, and a script/handler/external-reference-free
|
|
11
|
+
* SVG. Declared type stays authoritative at serve time because it was
|
|
12
|
+
* verified against the bytes at commit (sniffing stays banned).
|
|
5
13
|
*/
|
|
6
14
|
export const TEXT_MIME_PATTERN = '^(?:text/[a-z0-9!#$&^_.+-]+|application/(?:javascript|ecmascript|json|xml|[a-z0-9!#$&^_.+-]+\\+(?:json|xml))|image/svg\\+xml)(?![\\s\\S])';
|
|
7
15
|
export const TEXT_MIME_RE = new RegExp(TEXT_MIME_PATTERN);
|
|
16
|
+
/**
|
|
17
|
+
* Generic MIME ceiling (server maximum). Profiles may only narrow it.
|
|
18
|
+
* No executables, no archives: the posture rests on this closed allowlist
|
|
19
|
+
* plus magic-byte verification, declared-type serving with `nosniff` on the
|
|
20
|
+
* single-label content origin, and sandbox CSP on SVG/PDF.
|
|
21
|
+
*/
|
|
22
|
+
export const SERVER_MIME_CEILING = Object.freeze([
|
|
23
|
+
'text/html', 'text/css', 'text/javascript', 'application/json',
|
|
24
|
+
'image/png', 'image/jpeg', 'image/gif', 'image/webp', 'image/avif',
|
|
25
|
+
'image/svg+xml', 'image/x-icon',
|
|
26
|
+
'application/pdf',
|
|
27
|
+
'font/woff', 'font/woff2', 'font/ttf', 'font/otf',
|
|
28
|
+
'video/mp4', 'video/webm',
|
|
29
|
+
]);
|
|
30
|
+
/** True when the MIME type is inside the generic ceiling. */
|
|
31
|
+
export function isWithinMimeCeiling(mimeType) {
|
|
32
|
+
return SERVER_MIME_CEILING.includes(mimeType);
|
|
33
|
+
}
|
|
34
|
+
/** Magic-byte signatures checked for binary types before any pin or release. */
|
|
35
|
+
const MAGIC_BYTES = Object.freeze({
|
|
36
|
+
'image/png': [[0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]],
|
|
37
|
+
'image/jpeg': [[0xff, 0xd8, 0xff]],
|
|
38
|
+
'image/gif': [[0x47, 0x49, 0x46, 0x38, 0x37, 0x61], [0x47, 0x49, 0x46, 0x38, 0x39, 0x61]],
|
|
39
|
+
'image/webp': [[0x52, 0x49, 0x46, 0x46]], // RIFF....WEBP checked below
|
|
40
|
+
'image/avif': [[0x66, 0x74, 0x79, 0x70, 0x61, 0x76, 0x69, 0x66]], // ftypavif
|
|
41
|
+
'image/x-icon': [[0x00, 0x00, 0x01, 0x00]],
|
|
42
|
+
'application/pdf': [[0x25, 0x50, 0x44, 0x46, 0x2d]], // %PDF-
|
|
43
|
+
'font/woff': [[0x77, 0x4f, 0x46, 0x46]], // wOFF
|
|
44
|
+
'font/woff2': [[0x77, 0x4f, 0x46, 0x32]], // wOF2
|
|
45
|
+
'font/ttf': [[0x00, 0x01, 0x00, 0x00]],
|
|
46
|
+
'font/otf': [[0x4f, 0x54, 0x54, 0x4f]], // OTTO
|
|
47
|
+
'video/mp4': [[0x66, 0x74, 0x79, 0x70]], // ftyp (brand checked loosely: isom/iso2/mp41/mp42/avc1/dash/msdh/m4v...)
|
|
48
|
+
'video/webm': [[0x1a, 0x45, 0xdf, 0xa3]], // EBML
|
|
49
|
+
});
|
|
50
|
+
function hasMagic(bytes, magic) {
|
|
51
|
+
if (bytes.length < magic.length)
|
|
52
|
+
return false;
|
|
53
|
+
return magic.every((byte, index) => bytes[index] === byte);
|
|
54
|
+
}
|
|
55
|
+
/** True for the RIFF....WEBP container (bytes 0-3 RIFF, 8-11 WEBP). */
|
|
56
|
+
function isWebp(bytes) {
|
|
57
|
+
return hasMagic(bytes, [0x52, 0x49, 0x46, 0x46]) && bytes.length >= 12 &&
|
|
58
|
+
hasMagic(bytes.subarray(8), [0x57, 0x45, 0x42, 0x50]);
|
|
59
|
+
}
|
|
60
|
+
/** True for an ISO-BMFF ftyp box whose major brand is an mp4 family brand. */
|
|
61
|
+
function isMp4(bytes) {
|
|
62
|
+
if (!hasMagic(bytes, [0x66, 0x74, 0x79, 0x70]) || bytes.length < 12)
|
|
63
|
+
return false;
|
|
64
|
+
const brand = String.fromCharCode(...bytes.subarray(8, 12));
|
|
65
|
+
return /^(isom|iso2|mp41|mp42|mp4v|avc1|dash|msdh|msix|m4v|m4a|3gp)/.test(brand);
|
|
66
|
+
}
|
|
67
|
+
/** True for an ISO-BMFF ftyp box whose major brand is avif/avis. */
|
|
68
|
+
function isAvif(bytes) {
|
|
69
|
+
if (!hasMagic(bytes, [0x66, 0x74, 0x79, 0x70]) || bytes.length < 12)
|
|
70
|
+
return false;
|
|
71
|
+
const brand = String.fromCharCode(...bytes.subarray(8, 12));
|
|
72
|
+
return brand === 'avif' || brand === 'avis';
|
|
73
|
+
}
|
|
74
|
+
const SVG_FORBIDDEN_RE = /<script|\son[a-z]+\s*=|href\s*=\s*["'](?!#)|xlink:href\s*=\s*["'](?!#)/i;
|
|
75
|
+
/**
|
|
76
|
+
* Validate file bytes against the declared MIME type. Throws on mismatch;
|
|
77
|
+
* callers map the failure to `verification_failed` (422) with no pin and no
|
|
78
|
+
* release. Text types must decode as strict UTF-8; SVG must be XML text
|
|
79
|
+
* without scripts, event handlers or external references.
|
|
80
|
+
*/
|
|
81
|
+
export function validateFileBytes(mimeType, bytes) {
|
|
82
|
+
if (!isWithinMimeCeiling(mimeType))
|
|
83
|
+
throw new Error(`MIME type outside the server ceiling: ${mimeType}`);
|
|
84
|
+
if (TEXT_MIME_RE.test(mimeType)) {
|
|
85
|
+
if (mimeType === 'image/svg+xml') {
|
|
86
|
+
let text;
|
|
87
|
+
try {
|
|
88
|
+
text = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
throw new Error('SVG is not strict UTF-8');
|
|
92
|
+
}
|
|
93
|
+
if (!/<svg[\s>]/i.test(text))
|
|
94
|
+
throw new Error('SVG has no root <svg> element');
|
|
95
|
+
if (SVG_FORBIDDEN_RE.test(text)) {
|
|
96
|
+
throw new Error('SVG contains a script, event handler or external reference');
|
|
97
|
+
}
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
throw new Error(`text type ${mimeType} is not strict UTF-8`);
|
|
105
|
+
}
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (mimeType === 'image/webp') {
|
|
109
|
+
if (!isWebp(bytes))
|
|
110
|
+
throw new Error('webp magic bytes mismatch');
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (mimeType === 'image/avif') {
|
|
114
|
+
if (!isAvif(bytes))
|
|
115
|
+
throw new Error('avif magic bytes mismatch');
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (mimeType === 'video/mp4') {
|
|
119
|
+
if (!isMp4(bytes))
|
|
120
|
+
throw new Error('mp4 magic bytes mismatch');
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const magics = MAGIC_BYTES[mimeType];
|
|
124
|
+
if (magics === undefined)
|
|
125
|
+
throw new Error(`no magic-byte rule for ${mimeType}`);
|
|
126
|
+
if (!magics.some((magic) => hasMagic(bytes, magic))) {
|
|
127
|
+
throw new Error(`${mimeType} magic bytes mismatch`);
|
|
128
|
+
}
|
|
129
|
+
}
|
package/dist/server/ports.d.ts
CHANGED
|
@@ -26,6 +26,35 @@ export declare function createCryptoUuid(): UuidPort;
|
|
|
26
26
|
export interface KeyMutex {
|
|
27
27
|
runSerialized<T>(key: string, fn: () => Promise<T>): Promise<T>;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* G2 principal directory port (converged-r2 §2.3). The host-trusted side of
|
|
31
|
+
* the model boundary: it knows internal principal ids and full emails; the
|
|
32
|
+
* package resolves opaque `userRef`s to internal principals and projects every
|
|
33
|
+
* model-visible output back to `userRef` + masked `emailHint`. Search and
|
|
34
|
+
* resolution are scope-filtered; approval is NOT part of resolution — every
|
|
35
|
+
* resolution/approval failure merges into the single `person_not_shareable`.
|
|
36
|
+
*/
|
|
37
|
+
export interface DirectoryPerson {
|
|
38
|
+
/** Opaque model-facing reference; the only principal form a model may see or send back. */
|
|
39
|
+
readonly userRef: string;
|
|
40
|
+
readonly displayName: string;
|
|
41
|
+
/** Full email, host-side only; never projected to a model payload. */
|
|
42
|
+
readonly email: string;
|
|
43
|
+
}
|
|
44
|
+
export interface PrincipalDirectoryPort {
|
|
45
|
+
/** Approved accounts of the scope matching the query (case/accent-insensitive on name and email). */
|
|
46
|
+
searchPeople(scope: string, query: string, limit: number): Promise<readonly DirectoryPerson[]>;
|
|
47
|
+
/** Resolve one opaque userRef to the internal principal id; undefined when unknown or out of scope. */
|
|
48
|
+
resolvePrincipal(scope: string, userRef: string): Promise<string | undefined>;
|
|
49
|
+
/** Inverse projection: internal principal id → directory person (userRef/displayName/email). */
|
|
50
|
+
describePrincipal(scope: string, principalId: string): Promise<DirectoryPerson | undefined>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Mask an email for model payloads: first local-part character kept, rest of
|
|
54
|
+
* the local part masked, domain visible — lifts homonyms without disclosing
|
|
55
|
+
* the directory. The package masks, so no full email can reach the wire.
|
|
56
|
+
*/
|
|
57
|
+
export declare function maskEmailHint(email: string): string;
|
|
29
58
|
/**
|
|
30
59
|
* G1 sharing policy port (converged-r2 §2.2, lock 2 of the double lock).
|
|
31
60
|
* Resolved by the host per storage scope, inside the commit transaction and
|
package/dist/server/ports.js
CHANGED
|
@@ -21,6 +21,17 @@ export function createCryptoUuid() {
|
|
|
21
21
|
},
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Mask an email for model payloads: first local-part character kept, rest of
|
|
26
|
+
* the local part masked, domain visible — lifts homonyms without disclosing
|
|
27
|
+
* the directory. The package masks, so no full email can reach the wire.
|
|
28
|
+
*/
|
|
29
|
+
export function maskEmailHint(email) {
|
|
30
|
+
const at = email.lastIndexOf('@');
|
|
31
|
+
if (at <= 0)
|
|
32
|
+
return '***';
|
|
33
|
+
return `${email.slice(0, 1)}***@${email.slice(at + 1)}`;
|
|
34
|
+
}
|
|
24
35
|
/** Fail-closed policy used whenever no well-formed answer exists. */
|
|
25
36
|
export const CLOSED_SHARING_POLICY = Object.freeze({ allowPublicSharing: false, policyRevision: 'none' });
|
|
26
37
|
/** Resolve the runtime lock fail-closed: absent port, throw or malformed answer ⇒ closed. */
|
|
@@ -4,6 +4,26 @@ export interface PublicationLimits {
|
|
|
4
4
|
maxFileBytes: number;
|
|
5
5
|
maxTotalBytes: number;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Generic server maxima (files parity LOT 1). A profile above any ceiling
|
|
9
|
+
* fails compilation, and `publicationLimits` refuses overrides above them:
|
|
10
|
+
* the ceiling is generic, the values are profile-owned below it.
|
|
11
|
+
* 255 files per release, 16 MiB per file, 64 MiB per release.
|
|
12
|
+
*/
|
|
13
|
+
export declare const SERVER_MAX_FILES_PER_RELEASE = 255;
|
|
14
|
+
export declare const SERVER_MAX_FILE_BYTES: number;
|
|
15
|
+
export declare const SERVER_MAX_TOTAL_BYTES: number;
|
|
16
|
+
/** Concurrent open upload sessions per principal (leaked-URL DoS bound). */
|
|
17
|
+
export declare const SERVER_MAX_UPLOAD_SESSIONS_PER_PRINCIPAL = 8;
|
|
18
|
+
/**
|
|
19
|
+
* Generic `get_source` server maxima (files parity LOT 2 §B.3): 32 files, 1 MiB
|
|
20
|
+
* per file, 2 MiB total. A profile may only narrow them; the frozen definition
|
|
21
|
+
* caps `paths` at 32, so larger listings belong to `artifacts_list_assets`.
|
|
22
|
+
*/
|
|
23
|
+
export declare const SERVER_MAX_SOURCE_FILES = 32;
|
|
24
|
+
export declare const SERVER_MAX_SOURCE_INLINE_BYTES: number;
|
|
25
|
+
export declare const SERVER_MAX_SOURCE_TOTAL_BYTES: number;
|
|
26
|
+
/** Generic defaults: 255 files, 16 MiB per file, 64 MiB total (files parity LOT 1). */
|
|
7
27
|
export declare const DEFAULT_PUBLICATION_LIMITS: Readonly<PublicationLimits>;
|
|
8
28
|
export declare function publicationLimits(overrides?: Partial<PublicationLimits>): Readonly<PublicationLimits>;
|
|
9
29
|
/** Validate before copying bytes, hashing, idempotency lookup or recording intents. */
|
|
@@ -1,11 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic server maxima (files parity LOT 1). A profile above any ceiling
|
|
3
|
+
* fails compilation, and `publicationLimits` refuses overrides above them:
|
|
4
|
+
* the ceiling is generic, the values are profile-owned below it.
|
|
5
|
+
* 255 files per release, 16 MiB per file, 64 MiB per release.
|
|
6
|
+
*/
|
|
7
|
+
export const SERVER_MAX_FILES_PER_RELEASE = 255;
|
|
8
|
+
export const SERVER_MAX_FILE_BYTES = 16 * 1024 * 1024;
|
|
9
|
+
export const SERVER_MAX_TOTAL_BYTES = 64 * 1024 * 1024;
|
|
10
|
+
/** Concurrent open upload sessions per principal (leaked-URL DoS bound). */
|
|
11
|
+
export const SERVER_MAX_UPLOAD_SESSIONS_PER_PRINCIPAL = 8;
|
|
12
|
+
/**
|
|
13
|
+
* Generic `get_source` server maxima (files parity LOT 2 §B.3): 32 files, 1 MiB
|
|
14
|
+
* per file, 2 MiB total. A profile may only narrow them; the frozen definition
|
|
15
|
+
* caps `paths` at 32, so larger listings belong to `artifacts_list_assets`.
|
|
16
|
+
*/
|
|
17
|
+
export const SERVER_MAX_SOURCE_FILES = 32;
|
|
18
|
+
export const SERVER_MAX_SOURCE_INLINE_BYTES = 1024 * 1024;
|
|
19
|
+
export const SERVER_MAX_SOURCE_TOTAL_BYTES = 2 * 1024 * 1024;
|
|
20
|
+
/** Generic defaults: 255 files, 16 MiB per file, 64 MiB total (files parity LOT 1). */
|
|
1
21
|
export const DEFAULT_PUBLICATION_LIMITS = Object.freeze({
|
|
2
|
-
maxFiles:
|
|
22
|
+
maxFiles: SERVER_MAX_FILES_PER_RELEASE,
|
|
23
|
+
maxFileBytes: SERVER_MAX_FILE_BYTES,
|
|
24
|
+
maxTotalBytes: SERVER_MAX_TOTAL_BYTES,
|
|
3
25
|
});
|
|
4
26
|
export function publicationLimits(overrides = {}) {
|
|
5
27
|
const limits = { ...DEFAULT_PUBLICATION_LIMITS, ...overrides };
|
|
6
28
|
if (Object.values(limits).some((value) => !Number.isSafeInteger(value) || value <= 0)) {
|
|
7
29
|
throw new Error('invalid publication limits');
|
|
8
30
|
}
|
|
31
|
+
if (limits.maxFiles > SERVER_MAX_FILES_PER_RELEASE || limits.maxFileBytes > SERVER_MAX_FILE_BYTES ||
|
|
32
|
+
limits.maxTotalBytes > SERVER_MAX_TOTAL_BYTES) {
|
|
33
|
+
throw new Error('publication limits above the server maxima');
|
|
34
|
+
}
|
|
9
35
|
return Object.freeze(limits);
|
|
10
36
|
}
|
|
11
37
|
/** Validate before copying bytes, hashing, idempotency lookup or recording intents. */
|
|
@@ -31,6 +31,11 @@ export interface PublicationStateStore {
|
|
|
31
31
|
export interface PublicationBlobStore {
|
|
32
32
|
putBlob(key: string, bytes: Uint8Array): Promise<void>;
|
|
33
33
|
getBlob(key: string): Promise<Uint8Array | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Files parity LOT 2 §B.4: byte-range read (inclusive bounds). Optional:
|
|
36
|
+
* the content handler falls back to getBlob + in-memory slicing.
|
|
37
|
+
*/
|
|
38
|
+
getBlobRange?(key: string, start: number, endInclusive: number): Promise<Uint8Array | undefined>;
|
|
34
39
|
/** List keys under a prefix (orphan enumeration for crash recovery/GC). */
|
|
35
40
|
listKeys(prefix: string): Promise<string[]>;
|
|
36
41
|
/** Delete a key (strict: unknown keys fail so callers notice). */
|
|
@@ -62,6 +67,11 @@ export interface PublishResult {
|
|
|
62
67
|
releaseId: string;
|
|
63
68
|
manifest: string;
|
|
64
69
|
}
|
|
70
|
+
/** Minimal shape needed for a read-back verification batch (uploads commit reuses this). */
|
|
71
|
+
export interface VerifyStagedBlobEntry {
|
|
72
|
+
readonly key: string;
|
|
73
|
+
readonly bytes: Uint8Array;
|
|
74
|
+
}
|
|
65
75
|
/** Default bounded in-flight blob operations per publish batch. */
|
|
66
76
|
export declare const DEFAULT_BLOB_CONCURRENCY = 6;
|
|
67
77
|
/** Hard ceiling for the configurable blob concurrency: no unbounded parallelism. */
|
|
@@ -91,6 +101,10 @@ export interface VerifyStagedOptions {
|
|
|
91
101
|
/** Shared deadline (epoch ms) for the whole read-back batch. */
|
|
92
102
|
readonly deadlineAt?: number;
|
|
93
103
|
}
|
|
104
|
+
/** Read-back verification shared by the split and finalized paths (bounded concurrency).
|
|
105
|
+
* Exported for files parity LOT 1: commit_upload re-verifies a promoted staging object
|
|
106
|
+
* through the same #907 bounded pool before pinning it. */
|
|
107
|
+
export declare function verifyStagedBlobs<T extends VerifyStagedBlobEntry>(blobs: PublicationBlobStore, entries: readonly T[], options?: VerifyStagedOptions): Promise<void>;
|
|
94
108
|
export interface PublicationService {
|
|
95
109
|
readonly limits?: Readonly<PublicationLimits>;
|
|
96
110
|
/** The host source store participates in the idempotent commit when a source is supplied. */
|
|
@@ -67,6 +67,12 @@ export function createMemoryBlobStore() {
|
|
|
67
67
|
getBlob(key) {
|
|
68
68
|
return Promise.resolve(blobs.get(key));
|
|
69
69
|
},
|
|
70
|
+
getBlobRange(key, start, endInclusive) {
|
|
71
|
+
const bytes = blobs.get(key);
|
|
72
|
+
if (bytes === undefined || start < 0 || endInclusive < start)
|
|
73
|
+
return Promise.resolve(undefined);
|
|
74
|
+
return Promise.resolve(bytes.slice(start, Math.min(endInclusive + 1, bytes.length)));
|
|
75
|
+
},
|
|
70
76
|
async listKeys(prefix) {
|
|
71
77
|
assertBlobPrefix(prefix);
|
|
72
78
|
return [...blobs.keys()].filter((key) => key.startsWith(prefix)).sort();
|
|
@@ -161,8 +167,10 @@ export async function runBlobPool(items, options, operation) {
|
|
|
161
167
|
if (fatal !== undefined)
|
|
162
168
|
throw fatal.error;
|
|
163
169
|
}
|
|
164
|
-
/** Read-back verification shared by the split and finalized paths (bounded concurrency).
|
|
165
|
-
|
|
170
|
+
/** Read-back verification shared by the split and finalized paths (bounded concurrency).
|
|
171
|
+
* Exported for files parity LOT 1: commit_upload re-verifies a promoted staging object
|
|
172
|
+
* through the same #907 bounded pool before pinning it. */
|
|
173
|
+
export async function verifyStagedBlobs(blobs, entries, options = {}) {
|
|
166
174
|
await runBlobPool(entries, {
|
|
167
175
|
concurrency: resolveBlobConcurrency(options.concurrency),
|
|
168
176
|
...(options.deadlineAt === undefined ? {} : { deadlineAt: options.deadlineAt }),
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lot 1a — host port for the personal reader store, consent slice
|
|
3
|
+
* (design-merged §1.3, §3.1). One identity, one store: consent rows key on
|
|
4
|
+
* the same `(storageScopeId, readerAccountId, artifactId)` tuple as the
|
|
5
|
+
* personal KV and the `me/` subtree of lots 2–3. Server only: the page can
|
|
6
|
+
* neither read, write nor enumerate consent; it learns only the binary
|
|
7
|
+
* outcome of its own call. Absent port ⇒ closed: hosts without a wired
|
|
8
|
+
* store refuse consent routes with `capability_unavailable`.
|
|
9
|
+
*/
|
|
10
|
+
import { type ConsentKey, type ReaderConsentEvent, type ReaderConsentRecord } from './consent.js';
|
|
11
|
+
export type ConsentRevokedBy = 'self' | 'admin' | 'cascade';
|
|
12
|
+
export interface ConsentRevokeAudit {
|
|
13
|
+
actor: string;
|
|
14
|
+
surface: 'screen' | 'api' | 'mcp' | 'cascade';
|
|
15
|
+
}
|
|
16
|
+
export interface PrincipalDataExport {
|
|
17
|
+
consents: readonly ReaderConsentRecord[];
|
|
18
|
+
/** Lot 2 fills the personal KV slice; empty until then. */
|
|
19
|
+
kv: readonly unknown[];
|
|
20
|
+
/** Lot 3 fills the me-documents slice; empty until then. */
|
|
21
|
+
meDocs: readonly unknown[];
|
|
22
|
+
/** Lot 3 fills shared-write references; empty until then. */
|
|
23
|
+
sharedWriteRefs: readonly unknown[];
|
|
24
|
+
}
|
|
25
|
+
export interface ArtifactReaderStore {
|
|
26
|
+
/** Lifecycle-filtered finder: live rows only, like the A4 grant finder. */
|
|
27
|
+
findLiveConsent(key: ConsentKey): Promise<ReaderConsentRecord | undefined>;
|
|
28
|
+
/** A live row for the key converges: the existing row is returned, no second row or event. */
|
|
29
|
+
grantConsent(record: ReaderConsentRecord): Promise<ReaderConsentRecord>;
|
|
30
|
+
revokeConsent(key: ConsentKey, by: ConsentRevokedBy, at: string, audit: ConsentRevokeAudit): Promise<{
|
|
31
|
+
changed: boolean;
|
|
32
|
+
revokedAt?: string;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* Self or admin revocation of every live row of one artifact, optionally
|
|
36
|
+
* restricted to one scope across all its versions (the MCP `scope`
|
|
37
|
+
* argument names a scope, never a version). Omitted scope revokes all.
|
|
38
|
+
*/
|
|
39
|
+
revokeAllConsents(key: Omit<ConsentKey, 'scopeId' | 'scopeVersion'> & {
|
|
40
|
+
scopeId?: string;
|
|
41
|
+
}, by: ConsentRevokedBy, at: string, audit: ConsentRevokeAudit): Promise<{
|
|
42
|
+
changed: boolean;
|
|
43
|
+
revoked: number;
|
|
44
|
+
}>;
|
|
45
|
+
/** All states, `grantedAt` then bytewise `consentId` ordering. */
|
|
46
|
+
listConsentsForReader(scope: string, reader: string): Promise<readonly ReaderConsentRecord[]>;
|
|
47
|
+
/** Append-only audit without content, same transaction as the mutation. */
|
|
48
|
+
listConsentEvents(scope: string, artifactId: string): Promise<readonly ReaderConsentEvent[]>;
|
|
49
|
+
purgeForArtifact(scope: string, artifactId: string): Promise<void>;
|
|
50
|
+
purgeByPrincipal(scope: string, principalId: string): Promise<{
|
|
51
|
+
consents: number;
|
|
52
|
+
kv: number;
|
|
53
|
+
docs: number;
|
|
54
|
+
}>;
|
|
55
|
+
exportByPrincipal(scope: string, principalId: string): Promise<PrincipalDataExport>;
|
|
56
|
+
}
|
|
57
|
+
/** In-memory double: single process, synchronous mutation plus audit, no clock (callers stamp). */
|
|
58
|
+
export declare function createMemoryReaderConsentStore(): ArtifactReaderStore;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lot 1a — host port for the personal reader store, consent slice
|
|
3
|
+
* (design-merged §1.3, §3.1). One identity, one store: consent rows key on
|
|
4
|
+
* the same `(storageScopeId, readerAccountId, artifactId)` tuple as the
|
|
5
|
+
* personal KV and the `me/` subtree of lots 2–3. Server only: the page can
|
|
6
|
+
* neither read, write nor enumerate consent; it learns only the binary
|
|
7
|
+
* outcome of its own call. Absent port ⇒ closed: hosts without a wired
|
|
8
|
+
* store refuse consent routes with `capability_unavailable`.
|
|
9
|
+
*/
|
|
10
|
+
import { assertConsentScopeId, assertConsentScopeVersion } from './consent.js';
|
|
11
|
+
const sameKey = (row, key) => row.storageScopeId === key.storageScopeId &&
|
|
12
|
+
row.readerAccountId === key.readerAccountId && row.artifactId === key.artifactId &&
|
|
13
|
+
row.scopeId === key.scopeId && row.scopeVersion === key.scopeVersion;
|
|
14
|
+
const byGrantedThenId = (left, right) => left.grantedAt < right.grantedAt ? -1 : left.grantedAt > right.grantedAt ? 1
|
|
15
|
+
: left.consentId < right.consentId ? -1 : left.consentId > right.consentId ? 1 : 0;
|
|
16
|
+
/** In-memory double: single process, synchronous mutation plus audit, no clock (callers stamp). */
|
|
17
|
+
export function createMemoryReaderConsentStore() {
|
|
18
|
+
const rows = new Map();
|
|
19
|
+
const events = [];
|
|
20
|
+
const copy = (row) => ({ ...row });
|
|
21
|
+
return {
|
|
22
|
+
async findLiveConsent(key) {
|
|
23
|
+
for (const row of rows.values()) {
|
|
24
|
+
if (sameKey(row, key) && row.revokedAt === undefined)
|
|
25
|
+
return copy(row);
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
},
|
|
29
|
+
async grantConsent(record) {
|
|
30
|
+
assertConsentScopeId(record.scopeId);
|
|
31
|
+
assertConsentScopeVersion(record.scopeVersion);
|
|
32
|
+
const live = await this.findLiveConsent(record);
|
|
33
|
+
if (live !== undefined)
|
|
34
|
+
return live;
|
|
35
|
+
rows.set(record.consentId, copy(record));
|
|
36
|
+
events.push({ consentId: record.consentId, storageScopeId: record.storageScopeId,
|
|
37
|
+
readerAccountId: record.readerAccountId, artifactId: record.artifactId, scopeId: record.scopeId,
|
|
38
|
+
scopeVersion: record.scopeVersion, action: 'grant', actor: record.readerAccountId,
|
|
39
|
+
surface: 'screen', at: record.grantedAt });
|
|
40
|
+
return copy(record);
|
|
41
|
+
},
|
|
42
|
+
async revokeConsent(key, by, at, audit) {
|
|
43
|
+
const live = await this.findLiveConsent(key);
|
|
44
|
+
if (live === undefined)
|
|
45
|
+
return { changed: false };
|
|
46
|
+
const stored = rows.get(live.consentId);
|
|
47
|
+
stored.revokedAt = at;
|
|
48
|
+
stored.revokedBy = by;
|
|
49
|
+
events.push({ consentId: live.consentId, storageScopeId: key.storageScopeId,
|
|
50
|
+
readerAccountId: key.readerAccountId, artifactId: key.artifactId, scopeId: key.scopeId,
|
|
51
|
+
scopeVersion: key.scopeVersion, action: 'revoke', actor: audit.actor, surface: audit.surface, at });
|
|
52
|
+
return { changed: true, revokedAt: at };
|
|
53
|
+
},
|
|
54
|
+
async revokeAllConsents(key, by, at, audit) {
|
|
55
|
+
let revoked = 0;
|
|
56
|
+
for (const row of [...rows.values()]) {
|
|
57
|
+
if (row.storageScopeId === key.storageScopeId && row.readerAccountId === key.readerAccountId &&
|
|
58
|
+
row.artifactId === key.artifactId && (key.scopeId === undefined || row.scopeId === key.scopeId) &&
|
|
59
|
+
row.revokedAt === undefined) {
|
|
60
|
+
const stored = rows.get(row.consentId);
|
|
61
|
+
stored.revokedAt = at;
|
|
62
|
+
stored.revokedBy = by;
|
|
63
|
+
events.push({ consentId: row.consentId, storageScopeId: row.storageScopeId,
|
|
64
|
+
readerAccountId: row.readerAccountId, artifactId: row.artifactId, scopeId: row.scopeId,
|
|
65
|
+
scopeVersion: row.scopeVersion, action: 'revoke', actor: audit.actor, surface: audit.surface, at });
|
|
66
|
+
revoked += 1;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return { changed: revoked > 0, revoked };
|
|
70
|
+
},
|
|
71
|
+
async listConsentsForReader(scope, reader) {
|
|
72
|
+
return [...rows.values()]
|
|
73
|
+
.filter((row) => row.storageScopeId === scope && row.readerAccountId === reader)
|
|
74
|
+
.sort(byGrantedThenId).map(copy);
|
|
75
|
+
},
|
|
76
|
+
async listConsentEvents(scope, artifactId) {
|
|
77
|
+
return events
|
|
78
|
+
.filter((event) => event.storageScopeId === scope && event.artifactId === artifactId)
|
|
79
|
+
.map((event) => ({ ...event }));
|
|
80
|
+
},
|
|
81
|
+
async purgeForArtifact(scope, artifactId) {
|
|
82
|
+
for (const row of [...rows.values()]) {
|
|
83
|
+
if (row.storageScopeId === scope && row.artifactId === artifactId)
|
|
84
|
+
rows.delete(row.consentId);
|
|
85
|
+
}
|
|
86
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
87
|
+
if (events[index].storageScopeId === scope && events[index].artifactId === artifactId)
|
|
88
|
+
events.splice(index, 1);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
async purgeByPrincipal(scope, principalId) {
|
|
92
|
+
let consents = 0;
|
|
93
|
+
for (const row of [...rows.values()]) {
|
|
94
|
+
if (row.storageScopeId === scope && row.readerAccountId === principalId) {
|
|
95
|
+
rows.delete(row.consentId);
|
|
96
|
+
consents += 1;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
100
|
+
if (events[index].storageScopeId === scope && events[index].readerAccountId === principalId)
|
|
101
|
+
events.splice(index, 1);
|
|
102
|
+
}
|
|
103
|
+
return { consents, kv: 0, docs: 0 };
|
|
104
|
+
},
|
|
105
|
+
async exportByPrincipal(scope, principalId) {
|
|
106
|
+
return { consents: await this.listConsentsForReader(scope, principalId), kv: [], meDocs: [], sharedWriteRefs: [] };
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
@@ -16,7 +16,11 @@ export interface SourceReadPorts {
|
|
|
16
16
|
tool: string;
|
|
17
17
|
version: string;
|
|
18
18
|
};
|
|
19
|
+
/** Data-file slots per call (`sourceFilesMax`, server ceiling 32). */
|
|
19
20
|
maxFiles: number;
|
|
21
|
+
/** Per-file raw-byte budget (`sourceInlineFileBytesMax`, server ceiling 1 MiB). */
|
|
22
|
+
maxInlineBytes: number;
|
|
23
|
+
/** Raw-byte budget for files with data (`sourceTotalBytesMax`, server ceiling 2 MiB). */
|
|
20
24
|
maxTotalBytes: number;
|
|
21
25
|
}
|
|
22
26
|
export interface SourceReadInput {
|
|
@@ -33,20 +37,19 @@ export declare function readArtifactSource(ports: SourceReadPorts, input: Source
|
|
|
33
37
|
digest: string;
|
|
34
38
|
manifest: string;
|
|
35
39
|
files: ({
|
|
36
|
-
text: string;
|
|
37
|
-
encoding: "utf8";
|
|
38
40
|
path: string;
|
|
39
41
|
mimeType: string;
|
|
40
|
-
digest: string;
|
|
41
42
|
size: number;
|
|
43
|
+
digest: string;
|
|
44
|
+
} & ({
|
|
45
|
+
text: string;
|
|
46
|
+
encoding: 'utf8';
|
|
42
47
|
} | {
|
|
43
48
|
base64: string;
|
|
44
|
-
encoding:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
size: number;
|
|
49
|
-
})[];
|
|
49
|
+
encoding: 'base64';
|
|
50
|
+
} | {
|
|
51
|
+
omitted: 'too_large' | 'over_total_budget';
|
|
52
|
+
}))[];
|
|
50
53
|
sourceRef: SourceRef | null;
|
|
51
54
|
guideRef: {
|
|
52
55
|
readonly tool: "artifacts_get_api_guide";
|
|
@@ -29,21 +29,17 @@ export async function readArtifactSource(ports, input) {
|
|
|
29
29
|
throw new ArtifactOperationError('verification_failed');
|
|
30
30
|
if (release.state === 'purged')
|
|
31
31
|
throw new ArtifactOperationError('release_unavailable', { publicDetails: { reason: 'purged' } });
|
|
32
|
-
if (!manifest.digest || !Array.isArray(manifest.files)
|
|
32
|
+
if (!manifest.digest || !Array.isArray(manifest.files)) {
|
|
33
33
|
throw new ArtifactOperationError('verification_failed');
|
|
34
34
|
}
|
|
35
35
|
const entries = [];
|
|
36
36
|
const paths = new Set();
|
|
37
|
-
let total = 0;
|
|
38
37
|
for (const value of manifest.files) {
|
|
39
38
|
const file = value;
|
|
40
39
|
if (!file || typeof file.path !== 'string' || typeof file.mimeType !== 'string' ||
|
|
41
40
|
!/^sha256:[0-9a-f]{64}$/.test(file.digest) || !Number.isSafeInteger(file.size) || file.size < 0 ||
|
|
42
41
|
paths.has(file.path))
|
|
43
42
|
throw new ArtifactOperationError('verification_failed');
|
|
44
|
-
total += file.size;
|
|
45
|
-
if (total > ports.maxTotalBytes)
|
|
46
|
-
throw new ArtifactOperationError('limit_exceeded');
|
|
47
43
|
paths.add(file.path);
|
|
48
44
|
entries.push(file);
|
|
49
45
|
}
|
|
@@ -52,8 +48,22 @@ export async function readArtifactSource(ports, input) {
|
|
|
52
48
|
throw new ArtifactOperationError('invalid_request');
|
|
53
49
|
}
|
|
54
50
|
const selected = input.paths === undefined ? entries : entries.filter((file) => input.paths.includes(file.path));
|
|
51
|
+
// LOT 2 §B.3: failure turns into data. Files are evaluated in manifest
|
|
52
|
+
// order against raw-byte budgets: above the per-file cap they are
|
|
53
|
+
// `too_large`; past the slot or total budget they are `over_total_budget`.
|
|
54
|
+
// Previously successful reads (within every budget) are byte-identical.
|
|
55
55
|
const files = [];
|
|
56
|
+
let dataFiles = 0;
|
|
57
|
+
let dataTotal = 0;
|
|
56
58
|
for (const file of selected) {
|
|
59
|
+
if (file.size > ports.maxInlineBytes) {
|
|
60
|
+
files.push({ ...file, omitted: 'too_large' });
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (dataFiles >= ports.maxFiles || dataTotal + file.size > ports.maxTotalBytes) {
|
|
64
|
+
files.push({ ...file, omitted: 'over_total_budget' });
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
57
67
|
const bytes = await ports.getBlob(`artifacts/${manifest.storageScopeId}/blobs/sha256/${file.digest.slice(7)}`);
|
|
58
68
|
if (!bytes)
|
|
59
69
|
throw new ArtifactOperationError('release_unavailable', { publicDetails: { reason: 'not_retained' } });
|
|
@@ -74,6 +84,8 @@ export async function readArtifactSource(ports, input) {
|
|
|
74
84
|
files.push({ ...file, ...(text !== undefined
|
|
75
85
|
? { text, encoding: 'utf8' }
|
|
76
86
|
: { base64: Buffer.from(bytes).toString('base64'), encoding: 'base64' }) });
|
|
87
|
+
dataFiles += 1;
|
|
88
|
+
dataTotal += file.size;
|
|
77
89
|
}
|
|
78
90
|
const sourceRef = await ports.getSource(input.artifactId) ?? null;
|
|
79
91
|
await ports.authorize();
|
package/dist/server/templates.js
CHANGED
|
@@ -62,8 +62,26 @@ const GUIDE_V1 = [
|
|
|
62
62
|
' the same key returns conflict with variant command_conflict.',
|
|
63
63
|
' MCP returns the complete artifacts-outcome/v2 JSON envelope: ok, invocationId,',
|
|
64
64
|
' commitState, replayed/output on success, or typed error details on failure.',
|
|
65
|
-
'- `artifacts_create_upload
|
|
66
|
-
' `
|
|
65
|
+
'- `artifacts_create_upload`: mint a presigned PUT for one staging key',
|
|
66
|
+
' (`artifacts/<scope>/staging/<uploadId>`, URL expiry <= 10 minutes). The',
|
|
67
|
+
' signature binds the content type and the exact declared content length;',
|
|
68
|
+
' the PUT must also carry `x-amz-checksum-sha256` (base64 SHA-256 of the',
|
|
69
|
+
' body) and S3 rejects a mismatching body. Perform the PUT yourself (curl,',
|
|
70
|
+
' SDK, CI) with exactly the returned `requiredHeaders` — no MCP call ever',
|
|
71
|
+
' carries file bytes. Open sessions per principal are quota-limited.',
|
|
72
|
+
'- `artifacts_commit_upload`: declare `{path, mimeType, digest, size}` for a',
|
|
73
|
+
' staged upload; the server re-reads the staged object once and re-verifies',
|
|
74
|
+
' size, SHA-256 digest and MIME (magic bytes / strict UTF-8 / SVG rules)',
|
|
75
|
+
' before promoting it to the digest-addressed blob store and pinning it.',
|
|
76
|
+
' A wrong size or digest is refused with `verification_failed` and nothing',
|
|
77
|
+
' is pinned. Commit creates no release by itself.',
|
|
78
|
+
'- `artifacts_publish_bundle`: one atomic release from inline `files` and/or',
|
|
79
|
+
' `assets` — each asset is `{path, uploadId}` (staged via create_upload +',
|
|
80
|
+
' PUT + commit_upload) or `{path, digest, size, mimeType}` (an already-pinned',
|
|
81
|
+
' blob of the same scope). `expectedCurrentReleaseId` is always required.',
|
|
82
|
+
' The release budget (files / bytes per file / total bytes) applies to the',
|
|
83
|
+
' union; a missing or digest-mismatched asset fails the whole publish and',
|
|
84
|
+
' commits nothing.',
|
|
67
85
|
'- `artifacts_list` / `artifacts_get`: discover (metadata included).',
|
|
68
86
|
'- `artifacts_list_versions`: full release history of one artifact —',
|
|
69
87
|
' per release: id, created at, author, state, whether it is current,',
|
|
@@ -78,6 +96,15 @@ const GUIDE_V1 = [
|
|
|
78
96
|
' history only grows. Purged releases are refused with `release_unavailable`.',
|
|
79
97
|
'- `artifacts_fork`: private independent copy (no ACL copied).',
|
|
80
98
|
'- `artifacts_set_access`: grant/revoke read or source, toggle public.',
|
|
99
|
+
' `principalId` is an opaque `userRef` from `artifacts_lookup_people`, or',
|
|
100
|
+
' a `sentropic:` sentinel: `sentropic:platform` = every approved account,',
|
|
101
|
+
' `sentropic:public` = anonymous (only while the sharing policy allows it).',
|
|
102
|
+
'- `artifacts_lookup_people`: search the host directory by name or email;',
|
|
103
|
+
' returns `userRef`s with masked email hints (approved callers only; ask the',
|
|
104
|
+
' user which entry to use when several match).',
|
|
105
|
+
'- `artifacts_list_access`: current sharing mode, owner and grant list of one',
|
|
106
|
+
' artifact; readers see only their own entry. A share covers all retained',
|
|
107
|
+
' versions of the artifact.',
|
|
81
108
|
'- `artifacts_promote`: explicit version selection (expected-current).',
|
|
82
109
|
'- `artifacts_renew`, `artifacts_delete`, `artifacts_restore`: lifecycle.',
|
|
83
110
|
'',
|
|
@@ -86,6 +113,27 @@ const GUIDE_V1 = [
|
|
|
86
113
|
'right. Pages never receive credentials; reader data access goes through',
|
|
87
114
|
'the host reader profile bound to the artifact and release.',
|
|
88
115
|
'',
|
|
116
|
+
'## Import an existing page',
|
|
117
|
+
'',
|
|
118
|
+
'Importing an already-built page (for example a 9.7 MB dossier of one HTML',
|
|
119
|
+
'file plus 40 screenshots) is a flow, not a single tool — the bytes never',
|
|
120
|
+
'enter the model context:',
|
|
121
|
+
'',
|
|
122
|
+
'1. `artifacts_ensure` to resolve the artifact.',
|
|
123
|
+
'2. Per file: `artifacts_create_upload {artifactId, mimeType, maxSize?}`,',
|
|
124
|
+
' then PUT the local file to the returned `uploadUrl` with exactly the',
|
|
125
|
+
' returned `requiredHeaders` plus `x-amz-checksum-sha256` (base64 SHA-256',
|
|
126
|
+
' of the body), then `artifacts_commit_upload {artifactId, uploadId, path,',
|
|
127
|
+
' mimeType, digest: "sha256:<hex>", size, idempotencyKey}`.',
|
|
128
|
+
'3. One `artifacts_publish_bundle {artifactId, idempotencyKey,',
|
|
129
|
+
' expectedCurrentReleaseId, assets: [{path, uploadId}, ...]}` — assets-only',
|
|
130
|
+
' is valid; put the page itself at `path: "index.html"`. The release is',
|
|
131
|
+
' atomic: all 41 files land in one release, or none do.',
|
|
132
|
+
'',
|
|
133
|
+
'Inline `files` in `artifacts_publish` / `artifacts_publish_bundle` stay',
|
|
134
|
+
'available for small text edits; the upload channel exists precisely so',
|
|
135
|
+
'bulk bytes skip the model.',
|
|
136
|
+
'',
|
|
89
137
|
'Tool definitions are stable: names, descriptions and schemas never change',
|
|
90
138
|
'between versions or profiles, so host permissions (for example claude.ai',
|
|
91
139
|
'"Always allow") survive upgrades. The active profile revision and result',
|