@hugex/artifact 0.1.0 → 0.1.2
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/catalog.d.ts +34 -3
- package/dist/do/ArtifactDO.d.ts +36 -3
- package/dist/do/file-storage.d.ts +28 -0
- package/dist/do/ora-index.d.ts +9 -0
- package/dist/hash.d.ts +11 -3
- package/dist/host-route.d.ts +8 -0
- package/dist/host.d.ts +3 -2
- package/dist/index.js +183 -107
- package/dist/inject.d.ts +26 -7
- package/dist/limits.d.ts +3 -1
- package/dist/mcp/authz.d.ts +1 -0
- package/dist/mcp/tools.d.ts +2 -4
- package/dist/types.d.ts +68 -1
- package/dist/validate.d.ts +8 -0
- package/dist/worker-client.d.ts +2 -0
- package/package.json +1 -1
package/dist/inject.d.ts
CHANGED
|
@@ -3,10 +3,19 @@ export declare function artifactCsp(frameAncestors?: string): string;
|
|
|
3
3
|
/** Default CSP when `ARTIFACT_FRAME_ANCESTORS` is empty: `frame-ancestors 'none'`. */
|
|
4
4
|
export declare const ARTIFACT_CSP: string;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* Artifact pages have no build step, so the tokens ship as a string.
|
|
6
|
+
* Font override for HugeX theme.
|
|
8
7
|
*/
|
|
9
|
-
export declare const
|
|
8
|
+
export declare const THEME_FONTS_CSS = " --font-sans: \"PolySans\", ui-sans-serif, system-ui, sans-serif;\n --font-inter: \"Inter\", ui-sans-serif, system-ui, sans-serif;";
|
|
9
|
+
/**
|
|
10
|
+
* Color and surface tokens copied from hx-base/packages/ui/base.css.
|
|
11
|
+
* These are additive and safe to keep active across all artifacts.
|
|
12
|
+
*/
|
|
13
|
+
export declare const THEME_TOKENS_CSS = " --color-primary-50: var(--theme-primary-50);\n --color-primary-100: var(--theme-primary-100);\n --color-primary-200: var(--theme-primary-200);\n --color-primary-300: var(--theme-primary-300);\n --color-primary-400: var(--theme-primary-400);\n --color-primary-500: var(--theme-primary-500);\n --color-primary-600: var(--theme-primary-600);\n --color-primary-700: var(--theme-primary-700);\n --color-primary-800: var(--theme-primary-800);\n --color-primary-900: var(--theme-primary-900);\n\n --color-secondary-50: var(--theme-secondary-50);\n --color-secondary-100: var(--theme-secondary-100);\n --color-secondary-200: var(--theme-secondary-200);\n --color-secondary-300: var(--theme-secondary-300);\n --color-secondary-400: var(--theme-secondary-400);\n --color-secondary-500: var(--theme-secondary-500);\n --color-secondary-600: var(--theme-secondary-600);\n --color-secondary-700: var(--theme-secondary-700);\n --color-secondary-800: var(--theme-secondary-800);\n --color-secondary-900: var(--theme-secondary-900);\n\n --color-warning-50: var(--theme-warning-50);\n --color-warning-100: var(--theme-warning-100);\n --color-warning-200: var(--theme-warning-200);\n --color-warning-300: var(--theme-warning-300);\n --color-warning-400: var(--theme-warning-400);\n --color-warning-500: var(--theme-warning-500);\n --color-warning-600: var(--theme-warning-600);\n --color-warning-700: var(--theme-warning-700);\n --color-warning-800: var(--theme-warning-800);\n --color-warning-900: var(--theme-warning-900);\n\n --color-danger-50: var(--theme-danger-50);\n --color-danger-100: var(--theme-danger-100);\n --color-danger-200: var(--theme-danger-200);\n --color-danger-300: var(--theme-danger-300);\n --color-danger-400: var(--theme-danger-400);\n --color-danger-500: var(--theme-danger-500);\n --color-danger-600: var(--theme-danger-600);\n --color-danger-700: var(--theme-danger-700);\n --color-danger-800: var(--theme-danger-800);\n --color-danger-900: var(--theme-danger-900);\n\n --color-bg-base: var(--theme-bg-base);\n --color-bg-surface: var(--theme-bg-surface);\n --color-border-subtle: var(--theme-border-subtle);\n --color-text-base: var(--theme-text-base);\n --color-text-muted: var(--theme-text-muted);";
|
|
14
|
+
export declare function buildThemeCss(theme?: "hugex" | "none"): string;
|
|
15
|
+
/**
|
|
16
|
+
* Default THEME_CSS (backward compatible full theme including fonts).
|
|
17
|
+
*/
|
|
18
|
+
export declare const THEME_CSS: string;
|
|
10
19
|
/**
|
|
11
20
|
* Light `:root` variables copied from hx-base/packages/ui/base.css.
|
|
12
21
|
* `@theme` references these; without them the color utilities do not resolve.
|
|
@@ -19,11 +28,21 @@ export interface InjectOptions {
|
|
|
19
28
|
integrity: Record<string, string>;
|
|
20
29
|
tailwindUrl: string;
|
|
21
30
|
tailwindIntegrity: string;
|
|
31
|
+
theme?: "hugex" | "none";
|
|
32
|
+
stylesheets?: {
|
|
33
|
+
url: string;
|
|
34
|
+
integrity: string;
|
|
35
|
+
}[];
|
|
36
|
+
scripts?: {
|
|
37
|
+
url: string;
|
|
38
|
+
integrity: string;
|
|
39
|
+
defer?: boolean;
|
|
40
|
+
}[];
|
|
22
41
|
}
|
|
23
|
-
/** Insert `<base>`, the process shim, the import map, Tailwind, theme tokens, and the reload client. */
|
|
42
|
+
/** Insert `<base>`, the process shim, the import map, stylesheets, scripts, Tailwind, theme tokens, and the reload client. */
|
|
24
43
|
export declare function injectHtml(html: string, options: InjectOptions): string;
|
|
25
|
-
/** Resolve `libs` from artifact.json and inject. Unknown libs are ignored here; write() reports them. */
|
|
26
|
-
export declare function injectArtifactHtml(html: string, baseHref: string, libs: readonly string[]): string;
|
|
44
|
+
/** Resolve `libs` and `theme` from artifact.json and inject. Unknown libs are ignored here; write() reports them. */
|
|
45
|
+
export declare function injectArtifactHtml(html: string, baseHref: string, libs: readonly string[], theme?: "hugex" | "none"): string;
|
|
27
46
|
export declare function contentType(path: string): string;
|
|
28
|
-
/** Referrer-Policy, nosniff, and the artifact CSP on every response. No Set-Cookie. */
|
|
47
|
+
/** Referrer-Policy, nosniff, no-transform, and the artifact CSP on every response. No Set-Cookie. */
|
|
29
48
|
export declare function applySecurityHeaders(response: Response, frameAncestors?: string): Response;
|
package/dist/limits.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** MVP caps from
|
|
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
3
|
readonly fileBytes: 1000000;
|
|
4
4
|
readonly versionBytes: 5000000;
|
|
@@ -10,6 +10,8 @@ export declare const LIMITS: {
|
|
|
10
10
|
readonly pathMaxChars: 200;
|
|
11
11
|
/** Shared deadline for facet load, health, and restore. An expired activation cannot publish. */
|
|
12
12
|
readonly healthTimeoutMs: 5000;
|
|
13
|
+
/** Non-active version rows kept by created_at (plus active and log-referenced versions). */
|
|
14
|
+
readonly keepVersions: 50;
|
|
13
15
|
};
|
|
14
16
|
/**
|
|
15
17
|
* compatibilityDate pinned on every Dynamic Worker.
|
package/dist/mcp/authz.d.ts
CHANGED
package/dist/mcp/tools.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP tool definitions and handlers for @hugex/artifact.
|
|
3
|
-
* Authorization happens before any mutating RPC. The Durable Object does not authorize.
|
|
4
|
-
*/
|
|
5
1
|
import { isSingleSelect } from '../sql';
|
|
6
2
|
import { artifactIndexRpc, artifactRpc } from '../rpc';
|
|
7
3
|
import type { ArtifactEnv } from '../types';
|
|
@@ -15,6 +11,8 @@ interface ToolDeps {
|
|
|
15
11
|
identity: ArtifactIdentity;
|
|
16
12
|
requestUrl: string;
|
|
17
13
|
access: ArtifactAccess | null;
|
|
14
|
+
/** Verified MCP bearer token, forwarded only to hx-core. */
|
|
15
|
+
token?: string;
|
|
18
16
|
}
|
|
19
17
|
export interface ToolDefinition {
|
|
20
18
|
name: string;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Contract shared by the @hugex/artifact runtime (ArtifactDO, ArtifactIndexDO, host routing) and the MCP layer.
|
|
3
|
-
* Owned by the orchestrator: workers must not change these shapes without updating
|
|
3
|
+
* Owned by the orchestrator: workers must not change these shapes without updating plans/notes/artifacts-design.md (§10 contract, workspace root).
|
|
4
4
|
*/
|
|
5
5
|
/** Bindings and vars a tenant worker must provide to mount @hugex/artifact. */
|
|
6
6
|
export interface ArtifactEnv {
|
|
@@ -35,7 +35,45 @@ export interface ArtifactEnv {
|
|
|
35
35
|
HX_ORA_URL?: string;
|
|
36
36
|
/** Tenant API key sent as the `Authorization` header to hx-ora internal routes (no `Bearer` prefix). */
|
|
37
37
|
HX_API_KEY?: string;
|
|
38
|
+
/**
|
|
39
|
+
* hx-core base URL, e.g. `http://localhost:3001`. Same variable the ora worker already uses.
|
|
40
|
+
* `artifact_workers grant` needs it (with `HX_API_KEY`) to check that the owner can use the flow.
|
|
41
|
+
* Without it, granting a Worker fails; list and revoke still work.
|
|
42
|
+
*/
|
|
43
|
+
HX_CORE_URL?: string;
|
|
44
|
+
}
|
|
45
|
+
/** Target of the same-origin agent route `<base>/__hx/agent/<flowId>/<sessionId>`. */
|
|
46
|
+
export interface ArtifactAgentProxyTarget {
|
|
47
|
+
flowId: string;
|
|
48
|
+
sessionId: string;
|
|
38
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Injected by the tenant (for example `artifactAgentProxy` from `@hugex/ai`). Runs the tenant's
|
|
52
|
+
* flow chat handler for the visitor. `@hugex/artifact` does not depend on the agent runtime.
|
|
53
|
+
*/
|
|
54
|
+
export type ArtifactAgentProxy = (request: Request, env: any, ctx: ExecutionContext, target: ArtifactAgentProxyTarget) => Promise<Response>;
|
|
55
|
+
export interface ArtifactHostOptions {
|
|
56
|
+
/** Without it, `__hx/agent/...` is a 404. */
|
|
57
|
+
agentProxy?: ArtifactAgentProxy;
|
|
58
|
+
}
|
|
59
|
+
/** A flow the artifact owner allowed this artifact to talk to. */
|
|
60
|
+
export interface WorkerGrant {
|
|
61
|
+
flowId: string;
|
|
62
|
+
grantedBy: string;
|
|
63
|
+
grantedAt: string;
|
|
64
|
+
}
|
|
65
|
+
export type AllowsWorkerInput = {
|
|
66
|
+
flowId: string;
|
|
67
|
+
key?: string | null;
|
|
68
|
+
mode: 'browser' | 'server';
|
|
69
|
+
artifactUuid?: string;
|
|
70
|
+
};
|
|
71
|
+
export type AllowsWorkerResult = {
|
|
72
|
+
ok: true;
|
|
73
|
+
owner: string;
|
|
74
|
+
} | {
|
|
75
|
+
ok: false;
|
|
76
|
+
};
|
|
39
77
|
export type ArtifactGroup = 'none' | 'all' | (string & {});
|
|
40
78
|
export type VersionState = 'provisional' | 'activa' | 'fallida' | 'anterior';
|
|
41
79
|
export interface ArtifactMeta {
|
|
@@ -190,6 +228,35 @@ export interface ArtifactRpc {
|
|
|
190
228
|
source?: ArtifactLogEntry['source'];
|
|
191
229
|
}): Promise<ArtifactLogEntry[] | null>;
|
|
192
230
|
query(sql: string): Promise<QueryResult>;
|
|
231
|
+
/** Removes the artifact, index row, and hx-ora tombstone. Returns null if the slug was never created. */
|
|
232
|
+
delete(input: {
|
|
233
|
+
author: string;
|
|
234
|
+
}): Promise<{
|
|
235
|
+
ok: true;
|
|
236
|
+
oraSyncFailed?: boolean;
|
|
237
|
+
} | null>;
|
|
238
|
+
/**
|
|
239
|
+
* May this artifact talk to the Worker `flowId`? `browser` also requires access to the artifact
|
|
240
|
+
* (public, or a valid key). `server` requires artifactUuid to match the current artifact and checks the grant.
|
|
241
|
+
* In browser mode artifactUuid is optional; when supplied it must also match.
|
|
242
|
+
*/
|
|
243
|
+
allowsWorker(input: AllowsWorkerInput): Promise<AllowsWorkerResult>;
|
|
244
|
+
/** Grants, oldest first. Null when the artifact does not exist. */
|
|
245
|
+
listWorkerGrants(): Promise<WorkerGrant[] | null>;
|
|
246
|
+
/** Upsert. The caller validated the owner and flow. Null when UUID or owner no longer matches. */
|
|
247
|
+
grantWorker(input: {
|
|
248
|
+
flowId: string;
|
|
249
|
+
grantedBy: string;
|
|
250
|
+
expectUuid: string;
|
|
251
|
+
expectOwner: string;
|
|
252
|
+
}): Promise<WorkerGrant | null>;
|
|
253
|
+
/** Null when the artifact does not exist or its UUID no longer matches. */
|
|
254
|
+
revokeWorker(input: {
|
|
255
|
+
flowId: string;
|
|
256
|
+
expectUuid: string;
|
|
257
|
+
}): Promise<{
|
|
258
|
+
removed: boolean;
|
|
259
|
+
} | null>;
|
|
193
260
|
}
|
|
194
261
|
/** RPC surface of ArtifactIndexDO (stub = env.ARTIFACT_INDEX.get(env.ARTIFACT_INDEX.idFromName('index'))). */
|
|
195
262
|
export interface ArtifactIndexRpc {
|
package/dist/validate.d.ts
CHANGED
|
@@ -8,9 +8,17 @@ export declare function validateSlug(slug: string): string | null;
|
|
|
8
8
|
* Rejects `..`, a leading `/`, backslashes, empty segments, and paths over 200 chars.
|
|
9
9
|
*/
|
|
10
10
|
export declare function validateFilePath(path: string): string | null;
|
|
11
|
+
/** Same flow id grammar as the tenant's flow chat route. */
|
|
12
|
+
export declare const WORKER_FLOW_ID_RE: RegExp;
|
|
13
|
+
/** Browser sessions are `crypto.randomUUID()` values (UUID v4). */
|
|
14
|
+
export declare const WORKER_SESSION_ID_RE: RegExp;
|
|
15
|
+
export declare function isWorkerFlowId(value: unknown): value is string;
|
|
16
|
+
export declare function isWorkerSessionId(value: unknown): value is string;
|
|
17
|
+
export type ArtifactTheme = "hugex" | "none";
|
|
11
18
|
export type ArtifactManifest = {
|
|
12
19
|
title: string;
|
|
13
20
|
libs: string[];
|
|
21
|
+
theme: ArtifactTheme;
|
|
14
22
|
};
|
|
15
23
|
export declare function parseArtifactManifest(text: string): {
|
|
16
24
|
ok: true;
|