@hugex/artifact 0.10.0 → 0.12.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/dist/artifact/do/ArtifactDO.d.ts +20 -0
- package/dist/artifact/mcp/domains/groups.d.ts +92 -0
- package/dist/artifact/mcp/domains/guide.d.ts +1 -0
- package/dist/artifact/mcp/registry.d.ts +3 -1
- package/dist/artifact/mcp/scopes.d.ts +1 -0
- package/dist/artifact/thumbnail.d.ts +84 -0
- package/dist/artifact/types.d.ts +13 -0
- package/dist/artifact/version.d.ts +1 -1
- package/dist/common/constants/client-tools.d.ts +42 -0
- package/dist/index.js +99 -83
- package/package.json +3 -2
|
@@ -28,6 +28,8 @@ export declare class ArtifactDO extends DurableObject<ArtifactEnv> implements Ar
|
|
|
28
28
|
private oraRetryAt;
|
|
29
29
|
/** `expiresAt` of the salt whose alarm was successfully armed. Null means the next view must try again. */
|
|
30
30
|
private saltAlarmExpiresAt;
|
|
31
|
+
/** One Browser Run session at a time for this artifact. */
|
|
32
|
+
private thumbRunning;
|
|
31
33
|
constructor(ctx: DurableObjectState, env: ArtifactEnv);
|
|
32
34
|
alarm(): Promise<void>;
|
|
33
35
|
create(input: CreateArtifactInput): Promise<{
|
|
@@ -93,6 +95,11 @@ export declare class ArtifactDO extends DurableObject<ArtifactEnv> implements Ar
|
|
|
93
95
|
}): Promise<{
|
|
94
96
|
removed: boolean;
|
|
95
97
|
} | null>;
|
|
98
|
+
/** Encola la captura de la versión activa. Si ya está `ready` en hx-core, no recaptura. */
|
|
99
|
+
enqueueThumbnail(): Promise<{
|
|
100
|
+
queued: boolean;
|
|
101
|
+
version: string | null;
|
|
102
|
+
} | null>;
|
|
96
103
|
stats(opts?: {
|
|
97
104
|
days?: number;
|
|
98
105
|
}): Promise<ArtifactStats | null>;
|
|
@@ -229,6 +236,19 @@ export declare class ArtifactDO extends DurableObject<ArtifactEnv> implements Ar
|
|
|
229
236
|
private indexEntry;
|
|
230
237
|
private readMeta;
|
|
231
238
|
private toPublic;
|
|
239
|
+
private afterActivation;
|
|
240
|
+
/**
|
|
241
|
+
* Valida el token firmado (un solo uso) o la cookie de esa visita.
|
|
242
|
+
* `reject` es un token presente pero inválido. `null` es una visita normal.
|
|
243
|
+
*/
|
|
244
|
+
private resolveCapture;
|
|
245
|
+
private thumbSecret;
|
|
246
|
+
private issueCaptureToken;
|
|
247
|
+
private capturePageUrl;
|
|
248
|
+
/** @returns whether a capture was queued (false when it was already ready or core is unset). */
|
|
249
|
+
private scheduleThumb;
|
|
250
|
+
private drainThumbs;
|
|
251
|
+
private captureVersion;
|
|
232
252
|
private secure;
|
|
233
253
|
private toVersion;
|
|
234
254
|
private fileMetaFor;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { ArtifactEnv } from '../../types';
|
|
2
|
+
import type { McpRequestContext } from '../context';
|
|
3
|
+
import type { ToolTextResult } from '../tools';
|
|
4
|
+
import type { McpDomain } from './artifacts';
|
|
5
|
+
export declare const FAVORITES_GROUP_ID = "favorites";
|
|
6
|
+
export declare const FAVORITES_GROUP_NAME = "Favoritos";
|
|
7
|
+
export declare const PERSONAL_GROUPS_BUDGET_BYTES: number;
|
|
8
|
+
export type GroupKind = 'worker' | 'artifact';
|
|
9
|
+
export type MemberField = 'workerIds' | 'artifactIds';
|
|
10
|
+
export interface PersonalGroupBase {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
isSystem?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export type PersonalGroup<F extends MemberField = MemberField> = PersonalGroupBase & Record<F, string[]>;
|
|
16
|
+
export interface PersonalGroupsDocument<F extends MemberField = MemberField> {
|
|
17
|
+
version: 1;
|
|
18
|
+
groups: PersonalGroup<F>[];
|
|
19
|
+
}
|
|
20
|
+
export interface GroupSummary {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
system: boolean;
|
|
24
|
+
count: number;
|
|
25
|
+
memberIds: string[];
|
|
26
|
+
}
|
|
27
|
+
export declare function fieldForKind(kind: GroupKind): MemberField;
|
|
28
|
+
export declare function preferenceKeyForKind(kind: GroupKind, tenant: string): string;
|
|
29
|
+
export declare function uniqueIds(ids: unknown): string[];
|
|
30
|
+
export declare function memberIds<F extends MemberField>(group: PersonalGroup<F> | undefined, field: F): string[];
|
|
31
|
+
export declare function emptyPersonalGroupsDocument<F extends MemberField>(): PersonalGroupsDocument<F>;
|
|
32
|
+
export declare function normalizePersonalGroupsDocument<F extends MemberField>(raw: unknown, field: F): PersonalGroupsDocument<F>;
|
|
33
|
+
export declare function withFavoritesGroup<F extends MemberField>(doc: PersonalGroupsDocument<F>, field: F, favoriteIds?: readonly string[], favoritesName?: string): PersonalGroupsDocument<F>;
|
|
34
|
+
export declare function seedFavoritesFromLegacy<F extends MemberField>(field: F, legacyIds: readonly string[]): PersonalGroupsDocument<F>;
|
|
35
|
+
export declare function generateGroupId(): string;
|
|
36
|
+
export declare function createGroup<F extends MemberField>(doc: PersonalGroupsDocument<F>, field: F, name: string): PersonalGroupsDocument<F>;
|
|
37
|
+
export declare function renameGroup<F extends MemberField>(doc: PersonalGroupsDocument<F>, groupId: string, name: string): PersonalGroupsDocument<F>;
|
|
38
|
+
export declare function addMembersToGroup<F extends MemberField>(doc: PersonalGroupsDocument<F>, field: F, groupId: string, incomingIds: readonly string[]): PersonalGroupsDocument<F>;
|
|
39
|
+
export declare function removeMembersFromGroup<F extends MemberField>(doc: PersonalGroupsDocument<F>, field: F, groupId: string, outgoingIds: readonly string[]): PersonalGroupsDocument<F>;
|
|
40
|
+
export declare function documentUtf8Bytes(doc: unknown): number;
|
|
41
|
+
export declare function summarizeGroup<F extends MemberField>(group: PersonalGroup<F>, field: F): GroupSummary;
|
|
42
|
+
export declare function findGroupByIdOrName<F extends MemberField>(doc: PersonalGroupsDocument<F>, ref: {
|
|
43
|
+
groupId?: string;
|
|
44
|
+
name?: string;
|
|
45
|
+
}): PersonalGroup<F> | undefined;
|
|
46
|
+
export declare function membershipsForMember<F extends MemberField>(doc: PersonalGroupsDocument<F>, field: F, memberId: string): Array<{
|
|
47
|
+
id: string;
|
|
48
|
+
name: string;
|
|
49
|
+
}>;
|
|
50
|
+
export declare const groupsDomain: McpDomain;
|
|
51
|
+
export type LoadDocResult<F extends MemberField> = {
|
|
52
|
+
ok: true;
|
|
53
|
+
doc: PersonalGroupsDocument<F>;
|
|
54
|
+
} | {
|
|
55
|
+
ok: false;
|
|
56
|
+
error: 'unavailable';
|
|
57
|
+
};
|
|
58
|
+
export declare function loadPersonalGroups<K extends GroupKind>(kind: K, deps: {
|
|
59
|
+
env: Pick<ArtifactEnv, 'HX_CORE_URL' | 'TENANT'>;
|
|
60
|
+
upstreamToken: string;
|
|
61
|
+
tenant?: string;
|
|
62
|
+
}): Promise<LoadDocResult<K extends 'worker' ? 'workerIds' : 'artifactIds'>>;
|
|
63
|
+
export declare function savePersonalGroups<F extends MemberField>(kind: GroupKind, doc: PersonalGroupsDocument<F>, deps: {
|
|
64
|
+
env: Pick<ArtifactEnv, 'HX_CORE_URL' | 'TENANT'>;
|
|
65
|
+
upstreamToken: string;
|
|
66
|
+
tenant?: string;
|
|
67
|
+
}): Promise<{
|
|
68
|
+
ok: true;
|
|
69
|
+
doc: PersonalGroupsDocument<F>;
|
|
70
|
+
} | {
|
|
71
|
+
ok: false;
|
|
72
|
+
error: 'budget_exceeded' | 'unavailable';
|
|
73
|
+
}>;
|
|
74
|
+
/** Best-effort read for enriching worker_list / worker_get / artifact_list without failing the main read. */
|
|
75
|
+
export declare function tryLoadPersonalGroups<K extends GroupKind>(kind: K, deps: {
|
|
76
|
+
env: Pick<ArtifactEnv, 'HX_CORE_URL' | 'TENANT'>;
|
|
77
|
+
upstreamToken: string;
|
|
78
|
+
tenant?: string;
|
|
79
|
+
}): Promise<PersonalGroupsDocument<K extends 'worker' ? 'workerIds' : 'artifactIds'> | null>;
|
|
80
|
+
/** Add a newly created worker or artifact to groups specified by id or name. Returns warnings for missing groups. */
|
|
81
|
+
export declare function assignCreatedToGroups(kind: GroupKind, memberId: string, groupRefs: string[], deps: {
|
|
82
|
+
env: Pick<ArtifactEnv, 'HX_CORE_URL' | 'TENANT'>;
|
|
83
|
+
upstreamToken: string;
|
|
84
|
+
tenant?: string;
|
|
85
|
+
}): Promise<{
|
|
86
|
+
assigned: Array<{
|
|
87
|
+
id: string;
|
|
88
|
+
name: string;
|
|
89
|
+
}>;
|
|
90
|
+
warnings: string[];
|
|
91
|
+
}>;
|
|
92
|
+
export declare function executeGroupTool(name: string, args: Record<string, unknown>, context: McpRequestContext): Promise<ToolTextResult>;
|
|
@@ -10,5 +10,6 @@ export declare const guideLimits: {
|
|
|
10
10
|
};
|
|
11
11
|
export declare const clearGuideCache: typeof clearSkillsCatalogCache;
|
|
12
12
|
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.";
|
|
13
|
+
export declare const PERSONAL_GROUPS_GUIDANCE = "group_list, group_create, group_add, group_remove y group_rename gestionan los grupos personales por usuario (preferencias) para kind \"worker\" o \"artifact\", incluido el grupo de sistema \"favorites\". No hay borrado de grupos. worker_create y artifact_create aceptan groups opcional para a\u00F1adir el recurso reci\u00E9n creado.";
|
|
13
14
|
export declare const guideDomain: McpDomain;
|
|
14
15
|
export declare function executeGuideTool(name: string, args: Record<string, unknown>, context: McpRequestContext, serverVersion: string): Promise<import("../tools").ToolTextResult>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type McpDomain } from './domains/artifacts';
|
|
2
|
+
export declare const GROUPS_DOMAIN_ID: string;
|
|
2
3
|
export declare const GUIDE_DOMAIN_ID: string;
|
|
3
4
|
/**
|
|
4
5
|
* `guide` is attached to `/mcp` and to every `/mcp/<domain>`.
|
|
6
|
+
* `groups` (`group_*`) is attached to `/mcp`, `/mcp/artifacts`, and `/mcp/workers`.
|
|
5
7
|
* `/mcp/guide` is not a route: the entry gate would demand `guide:read`, and that
|
|
6
8
|
* scope does not exist. A session that can open any domain can call `hugex_guide`.
|
|
7
9
|
*/
|
|
@@ -9,5 +11,5 @@ export declare function domainForPath(pathname: string, resourcePath: string): M
|
|
|
9
11
|
/** OAuth read scopes that open a path. Authoring shares `workers:read`. */
|
|
10
12
|
export declare function entryReadScopes(domains: readonly McpDomain[]): string[];
|
|
11
13
|
export declare function domainForTool(name: string): McpDomain | null;
|
|
12
|
-
/** Sorted tool names from every domain, including `hugex_guide
|
|
14
|
+
/** Sorted tool names from every domain, including `hugex_guide` and `group_*`. */
|
|
13
15
|
export declare function registeredToolNames(): string[];
|
|
@@ -22,6 +22,7 @@ export declare const GUIDE_TOOL_NAME = "hugex_guide";
|
|
|
22
22
|
* Callers must not send it as a `WWW-Authenticate` scope.
|
|
23
23
|
*/
|
|
24
24
|
export declare const NO_OAUTH_SCOPE = "";
|
|
25
|
+
export declare const GROUP_WRITE_TOOLS: Set<string>;
|
|
25
26
|
export declare const SKILL_WRITE_TOOLS: Set<string>;
|
|
26
27
|
/** Authoring tools. Each one needs the workers:read + workers:write pair. */
|
|
27
28
|
export declare const WORKER_WRITE_TOOLS: Set<string>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export declare const CAPTURE_TTL_MS = 60000;
|
|
2
|
+
export declare const THUMB_MAX_BYTES: number;
|
|
3
|
+
export declare const THUMB_WIDTH = 640;
|
|
4
|
+
export declare const THUMB_HEIGHT = 400;
|
|
5
|
+
export declare const CAPTURE_QUERY = "__hx_capture";
|
|
6
|
+
export declare const CAPTURE_COOKIE = "__hx_capture";
|
|
7
|
+
export type ThumbFail = "timeout" | "navigation" | "no_browser" | "too_large";
|
|
8
|
+
export type ThumbStatusName = "pending" | "ready" | "failed";
|
|
9
|
+
export interface ThumbCoreEnv {
|
|
10
|
+
HX_CORE_URL?: string;
|
|
11
|
+
HX_API_KEY?: string;
|
|
12
|
+
TENANT?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function coreConfigured(env: ThumbCoreEnv): boolean;
|
|
15
|
+
/** Tras el intento `attempt` (0 = el primero), espera o se rinde. Dos reintentos: 1 min y 10 min. */
|
|
16
|
+
export declare function thumbRetry(attempt: number): {
|
|
17
|
+
delayMs: number;
|
|
18
|
+
} | {
|
|
19
|
+
failed: true;
|
|
20
|
+
};
|
|
21
|
+
export declare function randomHex(bytes?: number): string;
|
|
22
|
+
export declare function signCaptureToken(secret: string, uuid: string, version: string, exp: number, nonce: string): Promise<string>;
|
|
23
|
+
export declare function verifyCaptureToken(secret: string, token: string, uuid: string): Promise<{
|
|
24
|
+
version: string;
|
|
25
|
+
exp: number;
|
|
26
|
+
nonce: string;
|
|
27
|
+
} | null>;
|
|
28
|
+
export declare function captureCookieHeader(token: string): string;
|
|
29
|
+
export declare function readCaptureCookie(header: string | null): string | null;
|
|
30
|
+
export declare function getThumbStatus(env: ThumbCoreEnv, uuid: string, version: string): Promise<ThumbStatusName | null>;
|
|
31
|
+
export declare function putThumbStatus(env: ThumbCoreEnv, uuid: string, version: string, body: {
|
|
32
|
+
status: "pending";
|
|
33
|
+
} | {
|
|
34
|
+
status: "failed";
|
|
35
|
+
reason: ThumbFail;
|
|
36
|
+
}): Promise<boolean>;
|
|
37
|
+
export declare function putThumbImage(env: ThumbCoreEnv, uuid: string, version: string, bytes: Uint8Array): Promise<{
|
|
38
|
+
ok: true;
|
|
39
|
+
} | {
|
|
40
|
+
ok: false;
|
|
41
|
+
reason: ThumbFail;
|
|
42
|
+
}>;
|
|
43
|
+
export interface ThumbBrowser {
|
|
44
|
+
newContext(opts: {
|
|
45
|
+
viewport: {
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
|
+
};
|
|
49
|
+
deviceScaleFactor: number;
|
|
50
|
+
colorScheme: "light";
|
|
51
|
+
}): Promise<{
|
|
52
|
+
newPage(): Promise<ThumbPage>;
|
|
53
|
+
close?: () => Promise<void>;
|
|
54
|
+
}>;
|
|
55
|
+
close(): Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
export interface ThumbPage {
|
|
58
|
+
goto(url: string, opts: {
|
|
59
|
+
waitUntil: "load";
|
|
60
|
+
timeout: number;
|
|
61
|
+
}): Promise<unknown>;
|
|
62
|
+
waitForTimeout(ms: number): Promise<unknown>;
|
|
63
|
+
context(): {
|
|
64
|
+
newCDPSession(page: ThumbPage): Promise<{
|
|
65
|
+
send(method: string, params?: unknown): Promise<{
|
|
66
|
+
data?: string;
|
|
67
|
+
}>;
|
|
68
|
+
}>;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export declare function captureThumbnail(opts: {
|
|
72
|
+
url: string;
|
|
73
|
+
binding: unknown;
|
|
74
|
+
launch?: (binding: unknown) => Promise<ThumbBrowser>;
|
|
75
|
+
deadlineMs?: number;
|
|
76
|
+
}): Promise<{
|
|
77
|
+
ok: true;
|
|
78
|
+
bytes: Uint8Array;
|
|
79
|
+
width: number;
|
|
80
|
+
height: number;
|
|
81
|
+
} | {
|
|
82
|
+
ok: false;
|
|
83
|
+
reason: ThumbFail;
|
|
84
|
+
}>;
|
package/dist/artifact/types.d.ts
CHANGED
|
@@ -53,6 +53,11 @@ export interface ArtifactEnv {
|
|
|
53
53
|
* Without it, granting a Worker fails; list and revoke still work.
|
|
54
54
|
*/
|
|
55
55
|
HX_CORE_URL?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Browser Run binding. Required to capture a version thumbnail. Without it the
|
|
58
|
+
* capture is marked `failed` / `no_browser` and the artifact keeps working.
|
|
59
|
+
*/
|
|
60
|
+
BROWSER?: unknown;
|
|
56
61
|
}
|
|
57
62
|
/** Target of the same-origin agent route `<base>/__hx/agent/<flowId>/<sessionId>`. */
|
|
58
63
|
export interface ArtifactAgentProxyTarget {
|
|
@@ -507,6 +512,14 @@ export interface ArtifactRpc {
|
|
|
507
512
|
}): Promise<{
|
|
508
513
|
removed: boolean;
|
|
509
514
|
} | null>;
|
|
515
|
+
/**
|
|
516
|
+
* Queues a capture of the active version. Already-`ready` thumbnails are not recaptured.
|
|
517
|
+
* Null when the artifact does not exist.
|
|
518
|
+
*/
|
|
519
|
+
enqueueThumbnail(): Promise<{
|
|
520
|
+
queued: boolean;
|
|
521
|
+
version: string | null;
|
|
522
|
+
} | null>;
|
|
510
523
|
}
|
|
511
524
|
/** RPC surface of ArtifactIndexDO (stub = env.ARTIFACT_INDEX.get(env.ARTIFACT_INDEX.idFromName('index'))). */
|
|
512
525
|
export interface ArtifactIndexRpc {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Package version mixed into `runtimeId`. Bump when the Dynamic Worker contract changes. */
|
|
2
|
-
export declare const ARTIFACT_PKG_VERSION = "0.
|
|
2
|
+
export declare const ARTIFACT_PKG_VERSION = "0.11.0";
|
|
@@ -117,6 +117,48 @@ export declare const CLIENT_TOOL_FAMILIES: {
|
|
|
117
117
|
};
|
|
118
118
|
};
|
|
119
119
|
};
|
|
120
|
+
readonly skills: {
|
|
121
|
+
readonly version: 1;
|
|
122
|
+
readonly label: 'Skills';
|
|
123
|
+
readonly summary: 'Read skill instructions and reference files provided by the desktop app.';
|
|
124
|
+
readonly tools: {
|
|
125
|
+
readonly desktop_skills: {
|
|
126
|
+
readonly sinceVersion: 1;
|
|
127
|
+
readonly tokenBudget: 250;
|
|
128
|
+
readonly description: string;
|
|
129
|
+
readonly actions: {
|
|
130
|
+
readonly read: {
|
|
131
|
+
readonly risk: 'allow';
|
|
132
|
+
};
|
|
133
|
+
readonly ref: {
|
|
134
|
+
readonly risk: 'allow';
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
readonly inputSchema: {
|
|
138
|
+
readonly type: 'object';
|
|
139
|
+
readonly additionalProperties: false;
|
|
140
|
+
readonly required: readonly ["action", "skill"];
|
|
141
|
+
readonly properties: {
|
|
142
|
+
readonly action: {
|
|
143
|
+
readonly type: 'string';
|
|
144
|
+
readonly enum: readonly ["read", "ref"];
|
|
145
|
+
};
|
|
146
|
+
readonly skill: {
|
|
147
|
+
readonly type: 'string';
|
|
148
|
+
readonly minLength: 1;
|
|
149
|
+
readonly maxLength: 128;
|
|
150
|
+
};
|
|
151
|
+
readonly ref: {
|
|
152
|
+
readonly type: 'string';
|
|
153
|
+
readonly minLength: 1;
|
|
154
|
+
readonly maxLength: 256;
|
|
155
|
+
readonly description: 'Reference file path when action is "ref".';
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
};
|
|
120
162
|
};
|
|
121
163
|
export type ClientToolFamilyId = keyof typeof CLIENT_TOOL_FAMILIES;
|
|
122
164
|
export interface ResolvedClientTool {
|