@hugex/artifact 0.6.4 → 0.6.6
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/artifact/do/ArtifactDO.d.ts +12 -6
- package/dist/artifact/do/file-storage.d.ts +16 -2
- package/dist/artifact/hash.d.ts +10 -0
- package/dist/artifact/limits.d.ts +6 -3
- package/dist/artifact/mcp/index.d.ts +1 -1
- package/dist/artifact/types.d.ts +38 -4
- package/dist/index.js +547 -59
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DurableObject } from "cloudflare:workers";
|
|
2
|
-
import type { AllowsWorkerInput, AllowsWorkerResult, ArtifactEnv, ArtifactFile, ArtifactLogEntry, ArtifactMeta, ArtifactRpc, ArtifactStats, ArtifactVersion, CreateArtifactInput, QueryResult, SettingsInput, WorkerGrant, WriteInput, WriteResult } from "../types";
|
|
2
|
+
import type { AllowsWorkerInput, AllowsWorkerResult, ArtifactEnv, ArtifactFile, ArtifactFileSummary, ArtifactLogEntry, ArtifactMeta, ArtifactRpc, ArtifactStats, ArtifactVersion, CreateArtifactInput, QueryOptions, QueryResult, SchemaResult, SettingsInput, WorkerGrant, WriteInput, WriteResult } from "../types";
|
|
3
3
|
/**
|
|
4
4
|
* One instance per artifact (`idFromName(slug)`).
|
|
5
5
|
* Supervisor SQLite holds meta, files, versions, logs, Worker grants, and daily usage counters.
|
|
@@ -23,9 +23,12 @@ export declare class ArtifactDO extends DurableObject<ArtifactEnv> implements Ar
|
|
|
23
23
|
public: boolean;
|
|
24
24
|
key: string | null;
|
|
25
25
|
} | null>;
|
|
26
|
-
|
|
26
|
+
listFiles(opts?: {
|
|
27
27
|
version?: string;
|
|
28
|
-
|
|
28
|
+
}): Promise<ArtifactFileSummary[] | null>;
|
|
29
|
+
readFiles(opts: {
|
|
30
|
+
version?: string;
|
|
31
|
+
path: string;
|
|
29
32
|
}): Promise<ArtifactFile[] | null>;
|
|
30
33
|
write(input: WriteInput): Promise<WriteResult>;
|
|
31
34
|
rollback(input: {
|
|
@@ -73,7 +76,9 @@ export declare class ArtifactDO extends DurableObject<ArtifactEnv> implements Ar
|
|
|
73
76
|
blobCount: number;
|
|
74
77
|
versionCount: number;
|
|
75
78
|
} | null>;
|
|
76
|
-
|
|
79
|
+
private startFacetForDb;
|
|
80
|
+
query(sql: string, opts?: QueryOptions): Promise<QueryResult>;
|
|
81
|
+
schema(): Promise<SchemaResult>;
|
|
77
82
|
fetch(request: Request): Promise<Response>;
|
|
78
83
|
webSocketMessage(_ws: WebSocket, message: string | ArrayBuffer): Promise<void>;
|
|
79
84
|
webSocketClose(_ws: WebSocket, _code: number, _reason: string, _wasClean: boolean): Promise<void>;
|
|
@@ -87,7 +92,7 @@ export declare class ArtifactDO extends DurableObject<ArtifactEnv> implements Ar
|
|
|
87
92
|
private activationLive;
|
|
88
93
|
/** Starts `serverJs`, or stops the facet when the version has no server. Load, health, and restore share `session`. */
|
|
89
94
|
private activateCode;
|
|
90
|
-
/** Version row + files, or nothing. Hashes are already computed. Quota is checked before the inserts. */
|
|
95
|
+
/** Version row + files, or nothing. Hashes and sizes are already computed. Quota is checked before the inserts. */
|
|
91
96
|
private persistNewVersion;
|
|
92
97
|
private runRetention;
|
|
93
98
|
private markFailed;
|
|
@@ -133,7 +138,8 @@ export declare class ArtifactDO extends DurableObject<ArtifactEnv> implements Ar
|
|
|
133
138
|
private toPublic;
|
|
134
139
|
private secure;
|
|
135
140
|
private toVersion;
|
|
136
|
-
private
|
|
141
|
+
private fileMetaFor;
|
|
142
|
+
private hasFile;
|
|
137
143
|
private readFile;
|
|
138
144
|
private rows;
|
|
139
145
|
private notFound;
|
|
@@ -13,6 +13,11 @@ export declare function fileTableHasContentColumn(columnNames: string[]): boolea
|
|
|
13
13
|
* Idempotent when `content` is already gone.
|
|
14
14
|
*/
|
|
15
15
|
export declare function migrateLegacyFileStorage(exec: SqlExec, query: SqlQuery, columnNames: string[]): void;
|
|
16
|
+
/**
|
|
17
|
+
* Adds `blob.size` (UTF-8 byte length) and backfills existing rows.
|
|
18
|
+
* Idempotent when `size` is already present.
|
|
19
|
+
*/
|
|
20
|
+
export declare function migrateBlobSize(exec: SqlExec, blobColumnNames: string[]): void;
|
|
16
21
|
/** Version ids that must survive retention pruning. */
|
|
17
22
|
export declare function versionIdsToKeep(input: {
|
|
18
23
|
activeVersion: string | null;
|
|
@@ -23,6 +28,15 @@ export declare function versionIdsToKeep(input: {
|
|
|
23
28
|
logVersionIds: string[];
|
|
24
29
|
keepVersions: number;
|
|
25
30
|
}): Set<string>;
|
|
26
|
-
/** Estimated byte growth from new blob rows only (for quota projection). */
|
|
27
|
-
export declare function newBlobFootprint(files: ReadonlyMap<string,
|
|
31
|
+
/** Estimated byte growth from new blob rows only (for quota projection), without loading blob contents. */
|
|
32
|
+
export declare function newBlobFootprint(files: ReadonlyMap<string, {
|
|
33
|
+
hash: string;
|
|
34
|
+
size: number;
|
|
35
|
+
}>, existingBlobHashes: ReadonlySet<string>): number;
|
|
28
36
|
export declare function pruneOldVersions(exec: SqlExec, query: SqlQuery, activeVersion: string | null, keepVersions?: number): void;
|
|
37
|
+
/**
|
|
38
|
+
* Removes the single oldest non-protected version (protecting `activeVersion` and
|
|
39
|
+
* log-referenced versions) and prunes any orphaned blobs. Returns `true` if a version
|
|
40
|
+
* was removed, `false` when no eligible version remains.
|
|
41
|
+
*/
|
|
42
|
+
export declare function pruneOldestNonProtectedVersion(exec: SqlExec, query: SqlQuery, activeVersion: string | null): boolean;
|
package/dist/artifact/hash.d.ts
CHANGED
|
@@ -5,12 +5,22 @@ export declare function utf8Length(text: string): number;
|
|
|
5
5
|
/** Replace `/k/<key>/` so a capability URL never lands in a log or error string. */
|
|
6
6
|
export declare function redactArtifactKey(text: string): string;
|
|
7
7
|
export declare function truncateUtf8(text: string, maxBytes: number): string;
|
|
8
|
+
/**
|
|
9
|
+
* sha256(JSON.stringify(sorted [[path, hash], ...])) from precomputed per-file sha256 hashes.
|
|
10
|
+
* Produces the exact same version id as `hashFileSet` without loading file contents.
|
|
11
|
+
*/
|
|
12
|
+
export declare function hashFileHashes(hashes: ReadonlyMap<string, string> | Record<string, string>): Promise<string>;
|
|
8
13
|
/**
|
|
9
14
|
* sha256(JSON.stringify(sorted [[path, sha256(content)], ...])).
|
|
10
15
|
* Key order does not change the digest. The JSON array is unambiguous:
|
|
11
16
|
* a newline or NUL inside a file cannot alias another path.
|
|
12
17
|
*/
|
|
13
18
|
export declare function hashFileSet(files: ReadonlyMap<string, string> | Record<string, string>): Promise<string>;
|
|
19
|
+
export declare function sameHashSet(a: ReadonlyMap<string, {
|
|
20
|
+
hash: string;
|
|
21
|
+
}>, b: ReadonlyMap<string, {
|
|
22
|
+
hash: string;
|
|
23
|
+
}>): boolean;
|
|
14
24
|
export declare function sameFileSet(a: ReadonlyMap<string, string>, b: ReadonlyMap<string, string>): boolean;
|
|
15
25
|
/** Name of the tenant entrypoint the loader binds as `env.HX` when `ctx.exports` has it. */
|
|
16
26
|
export declare const ARTIFACT_GATEWAY_EXPORT = "ArtifactWorkerGateway";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/** MVP caps from plans/notes/artifacts-design.md section 10 (workspace root). Byte counts are decimal MB as in the spike. */
|
|
2
2
|
export declare const LIMITS: {
|
|
3
|
-
readonly fileBytes:
|
|
4
|
-
readonly
|
|
5
|
-
readonly
|
|
3
|
+
readonly fileBytes: 7000000;
|
|
4
|
+
readonly writeBytes: number;
|
|
5
|
+
readonly versionBytes: number;
|
|
6
|
+
readonly supervisorBytes: 2000000000;
|
|
6
7
|
readonly logRows: 1000;
|
|
7
8
|
/** 2 KB, truncated on insert. */
|
|
8
9
|
readonly logMessageBytes: 2048;
|
|
@@ -24,3 +25,5 @@ export declare const LIMITS: {
|
|
|
24
25
|
* date the Fase 1 integration worker uses.
|
|
25
26
|
*/
|
|
26
27
|
export declare const ARTIFACT_COMPATIBILITY_DATE = "2025-05-15";
|
|
28
|
+
/** Formats a byte limit for error messages and tool descriptions (64 MiB → "64 MiB", 7_000_000 → "7 MB"). */
|
|
29
|
+
export declare function formatMb(bytes: number): string;
|
|
@@ -5,7 +5,7 @@ import type { ArtifactEnv } from '../types';
|
|
|
5
5
|
import type { McpRequestContext } from './context';
|
|
6
6
|
export declare const MAX_BODY_BYTES: number;
|
|
7
7
|
export declare const SERVER_NAME = "hugex";
|
|
8
|
-
export declare const SERVER_VERSION = "2.
|
|
8
|
+
export declare const SERVER_VERSION = "2.3.0";
|
|
9
9
|
export declare const DEFAULT_PROTOCOL_VERSION = "2025-11-25";
|
|
10
10
|
export declare const SUPPORTED_PROTOCOL_VERSIONS: readonly ['2024-11-05', '2025-03-26', '2025-06-18', '2025-11-25'];
|
|
11
11
|
export type AccessMode = 'phase1' | 'rbac';
|
package/dist/artifact/types.d.ts
CHANGED
|
@@ -142,6 +142,11 @@ export interface ArtifactFile {
|
|
|
142
142
|
path: string;
|
|
143
143
|
content: string;
|
|
144
144
|
}
|
|
145
|
+
export interface ArtifactFileSummary {
|
|
146
|
+
path: string;
|
|
147
|
+
size: number;
|
|
148
|
+
hash: string;
|
|
149
|
+
}
|
|
145
150
|
/** A file change in artifact_write. `content: null` deletes the path. */
|
|
146
151
|
export interface ArtifactFileChange {
|
|
147
152
|
path: string;
|
|
@@ -207,9 +212,33 @@ export interface SettingsInput {
|
|
|
207
212
|
public?: boolean;
|
|
208
213
|
rotateKey?: boolean;
|
|
209
214
|
}
|
|
215
|
+
export interface QueryOptions {
|
|
216
|
+
limit?: number;
|
|
217
|
+
offset?: number;
|
|
218
|
+
}
|
|
210
219
|
export type QueryResult = {
|
|
211
220
|
ok: true;
|
|
221
|
+
columns: string[];
|
|
212
222
|
rows: Record<string, unknown>[];
|
|
223
|
+
truncated: boolean;
|
|
224
|
+
} | {
|
|
225
|
+
ok: false;
|
|
226
|
+
error: string;
|
|
227
|
+
};
|
|
228
|
+
export interface SchemaColumn {
|
|
229
|
+
name: string;
|
|
230
|
+
type: string;
|
|
231
|
+
notnull: boolean;
|
|
232
|
+
pk: boolean;
|
|
233
|
+
}
|
|
234
|
+
export interface SchemaTable {
|
|
235
|
+
name: string;
|
|
236
|
+
columns: SchemaColumn[];
|
|
237
|
+
rows: number;
|
|
238
|
+
}
|
|
239
|
+
export type SchemaResult = {
|
|
240
|
+
ok: true;
|
|
241
|
+
tables: SchemaTable[];
|
|
213
242
|
} | {
|
|
214
243
|
ok: false;
|
|
215
244
|
error: string;
|
|
@@ -245,10 +274,14 @@ export interface ArtifactRpc {
|
|
|
245
274
|
public: boolean;
|
|
246
275
|
key: string | null;
|
|
247
276
|
} | null>;
|
|
248
|
-
/**
|
|
249
|
-
|
|
277
|
+
/** File listing of a version (defaults to active), ordered by path, without content. */
|
|
278
|
+
listFiles(opts?: {
|
|
279
|
+
version?: string;
|
|
280
|
+
}): Promise<ArtifactFileSummary[] | null>;
|
|
281
|
+
/** Reads a single file of a version (defaults to active). Returns [] when missing, null when version is missing. */
|
|
282
|
+
readFiles(opts: {
|
|
250
283
|
version?: string;
|
|
251
|
-
path
|
|
284
|
+
path: string;
|
|
252
285
|
}): Promise<ArtifactFile[] | null>;
|
|
253
286
|
write(input: WriteInput): Promise<WriteResult>;
|
|
254
287
|
/** Re-activates an older version's code (data is untouched). Same result shape as write. */
|
|
@@ -267,7 +300,8 @@ export interface ArtifactRpc {
|
|
|
267
300
|
limit?: number;
|
|
268
301
|
source?: ArtifactLogEntry['source'];
|
|
269
302
|
}): Promise<ArtifactLogEntry[] | null>;
|
|
270
|
-
query(sql: string): Promise<QueryResult>;
|
|
303
|
+
query(sql: string, opts?: QueryOptions): Promise<QueryResult>;
|
|
304
|
+
schema(): Promise<SchemaResult>;
|
|
271
305
|
/** Removes the artifact, index row, and hx-ora tombstone. Returns null if the slug was never created. */
|
|
272
306
|
delete(input: {
|
|
273
307
|
author: string;
|