@hugex/artifact 0.6.5 → 0.6.7
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/domains/guide.d.ts +1 -0
- package/dist/artifact/mcp/domains/worker-flow-access.d.ts +5 -0
- package/dist/artifact/mcp/domains/worker-write.d.ts +4 -1
- package/dist/artifact/mcp/index.d.ts +1 -1
- package/dist/artifact/types.d.ts +42 -4
- package/dist/index.js +149 -56
- 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, SchemaOptions, 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(opts?: SchemaOptions): 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;
|
|
@@ -6,6 +6,7 @@ export declare const guideLimits: {
|
|
|
6
6
|
cacheTtlMs: number;
|
|
7
7
|
maxFileBytes: number;
|
|
8
8
|
};
|
|
9
|
+
export declare const PERSONAL_AGENT_GUIDANCE = "Para leer o editar agentes personales por ID se requiere el m\u00F3dulo flow y el rol de admin del tenant o superadmin. Para buscarlos, usa worker_list con type \"personal-agent\". Para crearlos, usa el mismo type en worker_create. Listar con ese filtro y crear tambi\u00E9n exigen el m\u00F3dulo personal-agents a los admins del tenant. Los agentes nuevos quedan con group \"none\". Al editar se conserva el tipo. worker_run ejecuta flows de tipo agent-flow.";
|
|
9
10
|
export declare const guideDomain: McpDomain;
|
|
10
11
|
export declare function clearGuideCache(): void;
|
|
11
12
|
export declare function executeGuideTool(name: string, args: Record<string, unknown>, context: McpRequestContext, serverVersion: string): Promise<import("../tools").ToolTextResult>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { McpRequestContext } from '../context';
|
|
2
|
+
export declare const WORKER_FLOW_TYPES: readonly ['agent-flow', 'personal-agent'];
|
|
3
|
+
export type WorkerFlowType = typeof WORKER_FLOW_TYPES[number];
|
|
4
|
+
export declare function canAccessPersonalAgent(context: McpRequestContext): boolean;
|
|
5
|
+
export declare function canListOrCreatePersonalAgent(context: McpRequestContext): boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type WorkerGraph } from '../../../common/flow-graph';
|
|
2
2
|
import type { McpRequestContext } from '../context';
|
|
3
3
|
import { type Row } from './read';
|
|
4
|
+
import { type WorkerFlowType } from './worker-flow-access';
|
|
4
5
|
export declare const WRITE_HINT = "Call worker_get_graph with this flowId before retrying.";
|
|
5
6
|
export type WritePhase = 'create' | 'save' | 'activate' | 'metadata' | 'status';
|
|
6
7
|
export type WriteCleanup = 'deleted' | 'failed' | 'skipped' | 'not_needed';
|
|
@@ -23,7 +24,7 @@ export type FlowSummary = {
|
|
|
23
24
|
group: string;
|
|
24
25
|
org: string;
|
|
25
26
|
blocked: boolean;
|
|
26
|
-
type:
|
|
27
|
+
type: WorkerFlowType;
|
|
27
28
|
};
|
|
28
29
|
export type ReadRowResult = {
|
|
29
30
|
ok: true;
|
|
@@ -73,6 +74,7 @@ export declare function createWorker(context: McpRequestContext, input: {
|
|
|
73
74
|
name: string;
|
|
74
75
|
description: string;
|
|
75
76
|
graph: WorkerGraph;
|
|
77
|
+
type?: WorkerFlowType;
|
|
76
78
|
}): Promise<CreateResult>;
|
|
77
79
|
export type UpdateResult = {
|
|
78
80
|
ok: true;
|
|
@@ -105,5 +107,6 @@ export type StatusResult = {
|
|
|
105
107
|
error: 'forbidden' | 'unavailable';
|
|
106
108
|
} | WriteFailure;
|
|
107
109
|
export declare function setWorkerStatus(context: McpRequestContext, flowId: string, status: 'active' | 'inactive'): Promise<StatusResult>;
|
|
110
|
+
/** Authorize the flow type before loading or modifying its graph. */
|
|
108
111
|
export declare function readWorkerRow(context: McpRequestContext, flowId: string): Promise<ReadRowResult>;
|
|
109
112
|
export declare function readFreshEnvelope(context: McpRequestContext, flowId: string): Promise<FreshEnvelope>;
|
|
@@ -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,37 @@ 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 SchemaOptions {
|
|
235
|
+
counts?: boolean;
|
|
236
|
+
}
|
|
237
|
+
export interface SchemaTable {
|
|
238
|
+
name: string;
|
|
239
|
+
columns: SchemaColumn[];
|
|
240
|
+
rows: number | null;
|
|
241
|
+
rowsCapped: boolean;
|
|
242
|
+
}
|
|
243
|
+
export type SchemaResult = {
|
|
244
|
+
ok: true;
|
|
245
|
+
tables: SchemaTable[];
|
|
213
246
|
} | {
|
|
214
247
|
ok: false;
|
|
215
248
|
error: string;
|
|
@@ -245,10 +278,14 @@ export interface ArtifactRpc {
|
|
|
245
278
|
public: boolean;
|
|
246
279
|
key: string | null;
|
|
247
280
|
} | null>;
|
|
248
|
-
/**
|
|
249
|
-
|
|
281
|
+
/** File listing of a version (defaults to active), ordered by path, without content. */
|
|
282
|
+
listFiles(opts?: {
|
|
283
|
+
version?: string;
|
|
284
|
+
}): Promise<ArtifactFileSummary[] | null>;
|
|
285
|
+
/** Reads a single file of a version (defaults to active). Returns [] when missing, null when version is missing. */
|
|
286
|
+
readFiles(opts: {
|
|
250
287
|
version?: string;
|
|
251
|
-
path
|
|
288
|
+
path: string;
|
|
252
289
|
}): Promise<ArtifactFile[] | null>;
|
|
253
290
|
write(input: WriteInput): Promise<WriteResult>;
|
|
254
291
|
/** Re-activates an older version's code (data is untouched). Same result shape as write. */
|
|
@@ -267,7 +304,8 @@ export interface ArtifactRpc {
|
|
|
267
304
|
limit?: number;
|
|
268
305
|
source?: ArtifactLogEntry['source'];
|
|
269
306
|
}): Promise<ArtifactLogEntry[] | null>;
|
|
270
|
-
query(sql: string): Promise<QueryResult>;
|
|
307
|
+
query(sql: string, opts?: QueryOptions): Promise<QueryResult>;
|
|
308
|
+
schema(opts?: SchemaOptions): Promise<SchemaResult>;
|
|
271
309
|
/** Removes the artifact, index row, and hx-ora tombstone. Returns null if the slug was never created. */
|
|
272
310
|
delete(input: {
|
|
273
311
|
author: string;
|