@hugex/artifact 0.12.0 → 0.12.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/artifact/do/ArtifactDO.d.ts +4 -2
- package/dist/artifact/host-route.d.ts +8 -0
- package/dist/artifact/thumbnail.d.ts +42 -10
- package/dist/artifact/types.d.ts +7 -13
- package/dist/common/flow-graph/schema.d.ts +7 -7
- package/dist/common/flow-graph/validate.d.ts +2 -0
- package/dist/common/types/artifact-bridge.d.ts +35 -0
- package/dist/common/types/media.d.ts +105 -0
- package/dist/common/types/node-types.d.ts +3 -2
- package/dist/common/types/var-scope.d.ts +3 -1
- package/dist/common/utils/outVars.d.ts +3 -1
- package/dist/index.js +107 -85
- package/package.json +1 -1
|
@@ -95,8 +95,10 @@ export declare class ArtifactDO extends DurableObject<ArtifactEnv> implements Ar
|
|
|
95
95
|
}): Promise<{
|
|
96
96
|
removed: boolean;
|
|
97
97
|
} | null>;
|
|
98
|
-
/** Encola la captura de la versión activa. Si ya está `ready` en hx-core, no recaptura
|
|
99
|
-
enqueueThumbnail(
|
|
98
|
+
/** Encola la captura de la versión activa. Si ya está `ready` en hx-core, no recaptura, salvo `force`. */
|
|
99
|
+
enqueueThumbnail(input?: {
|
|
100
|
+
force?: boolean;
|
|
101
|
+
}): Promise<{
|
|
100
102
|
queued: boolean;
|
|
101
103
|
version: string | null;
|
|
102
104
|
} | null>;
|
|
@@ -21,6 +21,14 @@ export type ArtifactRoute = {
|
|
|
21
21
|
key: string;
|
|
22
22
|
flowId: string;
|
|
23
23
|
sessionId: string;
|
|
24
|
+
}
|
|
25
|
+
/** `<base>/__hx/media/<id>` or `<base>/__hx/media/<id>/share`. */
|
|
26
|
+
| {
|
|
27
|
+
kind: "media";
|
|
28
|
+
slug: string;
|
|
29
|
+
key: string;
|
|
30
|
+
mediaId: string;
|
|
31
|
+
action: "stream" | "share";
|
|
24
32
|
};
|
|
25
33
|
export interface RouteInput {
|
|
26
34
|
pathname: string;
|
|
@@ -4,7 +4,7 @@ export declare const THUMB_WIDTH = 640;
|
|
|
4
4
|
export declare const THUMB_HEIGHT = 400;
|
|
5
5
|
export declare const CAPTURE_QUERY = "__hx_capture";
|
|
6
6
|
export declare const CAPTURE_COOKIE = "__hx_capture";
|
|
7
|
-
export type ThumbFail = "timeout" | "navigation" | "no_browser" | "too_large";
|
|
7
|
+
export type ThumbFail = "timeout" | "navigation" | "no_browser" | "too_large" | "delivery";
|
|
8
8
|
export type ThumbStatusName = "pending" | "ready" | "failed";
|
|
9
9
|
export interface ThumbCoreEnv {
|
|
10
10
|
HX_CORE_URL?: string;
|
|
@@ -30,15 +30,18 @@ export declare function readCaptureCookie(header: string | null): string | null;
|
|
|
30
30
|
export declare function getThumbStatus(env: ThumbCoreEnv, uuid: string, version: string): Promise<ThumbStatusName | null>;
|
|
31
31
|
export declare function putThumbStatus(env: ThumbCoreEnv, uuid: string, version: string, body: {
|
|
32
32
|
status: "pending";
|
|
33
|
+
force?: boolean;
|
|
33
34
|
} | {
|
|
34
35
|
status: "failed";
|
|
35
36
|
reason: ThumbFail;
|
|
37
|
+
force?: boolean;
|
|
36
38
|
}): Promise<boolean>;
|
|
37
39
|
export declare function putThumbImage(env: ThumbCoreEnv, uuid: string, version: string, bytes: Uint8Array): Promise<{
|
|
38
40
|
ok: true;
|
|
39
41
|
} | {
|
|
40
42
|
ok: false;
|
|
41
|
-
reason:
|
|
43
|
+
reason: "too_large" | "delivery";
|
|
44
|
+
detail: string;
|
|
42
45
|
}>;
|
|
43
46
|
export interface ThumbBrowser {
|
|
44
47
|
newContext(opts: {
|
|
@@ -54,12 +57,32 @@ export interface ThumbBrowser {
|
|
|
54
57
|
}>;
|
|
55
58
|
close(): Promise<void>;
|
|
56
59
|
}
|
|
60
|
+
export interface ThumbRequestFailed {
|
|
61
|
+
url(): string;
|
|
62
|
+
failure(): {
|
|
63
|
+
errorText?: string;
|
|
64
|
+
} | null;
|
|
65
|
+
}
|
|
66
|
+
export interface ThumbResponse {
|
|
67
|
+
status(): number;
|
|
68
|
+
url(): string;
|
|
69
|
+
}
|
|
57
70
|
export interface ThumbPage {
|
|
58
71
|
goto(url: string, opts: {
|
|
59
72
|
waitUntil: "load";
|
|
60
73
|
timeout: number;
|
|
61
74
|
}): Promise<unknown>;
|
|
62
75
|
waitForTimeout(ms: number): Promise<unknown>;
|
|
76
|
+
waitForLoadState?(state: "networkidle", opts: {
|
|
77
|
+
timeout: number;
|
|
78
|
+
}): Promise<unknown>;
|
|
79
|
+
on?(event: "requestfailed", handler: (request: ThumbRequestFailed) => void): void;
|
|
80
|
+
on?(event: "response", handler: (response: ThumbResponse) => void): void;
|
|
81
|
+
on?(event: "console", handler: (message: {
|
|
82
|
+
type(): string;
|
|
83
|
+
text(): string;
|
|
84
|
+
}) => void): void;
|
|
85
|
+
evaluate?(fn: () => void): Promise<unknown>;
|
|
63
86
|
context(): {
|
|
64
87
|
newCDPSession(page: ThumbPage): Promise<{
|
|
65
88
|
send(method: string, params?: unknown): Promise<{
|
|
@@ -68,17 +91,26 @@ export interface ThumbPage {
|
|
|
68
91
|
}>;
|
|
69
92
|
};
|
|
70
93
|
}
|
|
71
|
-
export
|
|
72
|
-
url: string;
|
|
73
|
-
binding: unknown;
|
|
74
|
-
launch?: (binding: unknown) => Promise<ThumbBrowser>;
|
|
75
|
-
deadlineMs?: number;
|
|
76
|
-
}): Promise<{
|
|
94
|
+
export interface CaptureShot {
|
|
77
95
|
ok: true;
|
|
78
96
|
bytes: Uint8Array;
|
|
79
97
|
width: number;
|
|
80
98
|
height: number;
|
|
81
|
-
|
|
99
|
+
detail: string;
|
|
100
|
+
}
|
|
101
|
+
export interface CaptureMiss {
|
|
82
102
|
ok: false;
|
|
83
103
|
reason: ThumbFail;
|
|
84
|
-
|
|
104
|
+
detail: string;
|
|
105
|
+
}
|
|
106
|
+
/** Width and height from a WebP RIFF header. Browser Run ignores `deviceScaleFactor`. */
|
|
107
|
+
export declare function webpSize(bytes: Uint8Array): {
|
|
108
|
+
width: number;
|
|
109
|
+
height: number;
|
|
110
|
+
} | null;
|
|
111
|
+
export declare function captureThumbnail(opts: {
|
|
112
|
+
url: string;
|
|
113
|
+
binding: unknown;
|
|
114
|
+
launch?: (binding: unknown) => Promise<ThumbBrowser>;
|
|
115
|
+
deadlineMs?: number;
|
|
116
|
+
}): Promise<CaptureShot | CaptureMiss>;
|
package/dist/artifact/types.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { AllowsWorkerResult, ArtifactAgentProxyTarget } from '../common/types/artifact-bridge';
|
|
1
2
|
import type { ToolRunAdmitInput, ToolRunAdmitResult, ToolRunExecutor, ToolRunFinishInput, ToolRunLogEntry } from './mcp/toolRunContract';
|
|
3
|
+
export type { AllowsWorkerResult, ArtifactAgentProxyTarget };
|
|
2
4
|
/**
|
|
3
5
|
* Contract shared by the @hugex/artifact runtime (ArtifactDO, ArtifactIndexDO, host routing) and the MCP layer.
|
|
4
6
|
* Owned by the orchestrator: workers must not change these shapes without updating plans/notes/artifacts-design.md (§10 contract, workspace root).
|
|
@@ -58,11 +60,8 @@ export interface ArtifactEnv {
|
|
|
58
60
|
* capture is marked `failed` / `no_browser` and the artifact keeps working.
|
|
59
61
|
*/
|
|
60
62
|
BROWSER?: unknown;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
export interface ArtifactAgentProxyTarget {
|
|
64
|
-
flowId: string;
|
|
65
|
-
sessionId: string;
|
|
63
|
+
/** Public origin of the tenant used to build absolute `/m/<token>` share URLs. */
|
|
64
|
+
MEDIA_SHARE_ORIGIN?: string;
|
|
66
65
|
}
|
|
67
66
|
/**
|
|
68
67
|
* Injected by the tenant (for example `artifactAgentProxy` from `@hugex/ai`). Runs the tenant's
|
|
@@ -141,12 +140,6 @@ export type AllowsWorkerInput = {
|
|
|
141
140
|
mode: 'browser' | 'server';
|
|
142
141
|
artifactUuid?: string;
|
|
143
142
|
};
|
|
144
|
-
export type AllowsWorkerResult = {
|
|
145
|
-
ok: true;
|
|
146
|
-
owner: string;
|
|
147
|
-
} | {
|
|
148
|
-
ok: false;
|
|
149
|
-
};
|
|
150
143
|
export type ArtifactGroup = 'none' | 'all' | (string & {});
|
|
151
144
|
export type VersionState = 'provisional' | 'activa' | 'fallida' | 'anterior';
|
|
152
145
|
export interface ArtifactMeta {
|
|
@@ -516,7 +509,9 @@ export interface ArtifactRpc {
|
|
|
516
509
|
* Queues a capture of the active version. Already-`ready` thumbnails are not recaptured.
|
|
517
510
|
* Null when the artifact does not exist.
|
|
518
511
|
*/
|
|
519
|
-
enqueueThumbnail(
|
|
512
|
+
enqueueThumbnail(input?: {
|
|
513
|
+
force?: boolean;
|
|
514
|
+
}): Promise<{
|
|
520
515
|
queued: boolean;
|
|
521
516
|
version: string | null;
|
|
522
517
|
} | null>;
|
|
@@ -551,4 +546,3 @@ export declare const HX_HEADER_KEY = "x-hx-artifact-key";
|
|
|
551
546
|
export declare const HX_HEADER_VISIT = "x-hx-artifact-visit";
|
|
552
547
|
/** Public base path of the artifact including trailing slash, e.g. `/demo/k/abc/` or `/app/demo/`. */
|
|
553
548
|
export declare const HX_HEADER_BASE = "x-hx-artifact-base";
|
|
554
|
-
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type NodeTypeName = 'startNode' | 'classifierNode' | 'memoNode' | 'llmNode' | 'answerNode' | 'apiNode' | 'toolNode' | 'workerNode' | 'crawlNode' | 'webActionsNode';
|
|
1
|
+
export type NodeTypeName = 'startNode' | 'classifierNode' | 'memoNode' | 'llmNode' | 'answerNode' | 'apiNode' | 'toolNode' | 'workerNode' | 'crawlNode' | 'webActionsNode' | 'mediaNode';
|
|
2
2
|
export interface AuthoringNode {
|
|
3
3
|
id: string;
|
|
4
4
|
type: string;
|
|
@@ -23,7 +23,7 @@ export interface WorkerGraph {
|
|
|
23
23
|
}
|
|
24
24
|
export type IssueSeverity = 'error' | 'warning';
|
|
25
25
|
export type CredentialKind = 'bearer_token' | 'basic_auth' | 'known_token' | 'url_userinfo' | 'url_query' | 'sensitive_key' | 'high_entropy';
|
|
26
|
-
export type IssueCode = 'missing_state' | 'schema_version' | 'var_mapping' | 'classifier_invalid' | 'classifier_edge_missing' | 'out_vars_invalid' | 'start_count' | 'answer_missing' | 'dead_end' | 'unknown_node_type' | 'duplicate_node_id' | 'invalid_node_id' | 'node_id_collides_with_input' | 'edge_unknown_node' | 'edge_bad_handle' | 'edge_duplicate' | 'start_has_input' | 'answer_has_output' | 'multiple_outgoing' | 'field_type' | 'field_required' | 'field_range' | 'field_enum' | 'ref_syntax' | 'ref_unknown_node' | 'ref_out_of_scope' | 'ref_unknown_output' | 'ref_binary_not_allowed' | 'start_input_invalid' | 'answer_mapping_invalid' | 'worker_self_reference' | 'classifier_error_unrouted' | 'classifier_handle_inactive' | 'unreachable_node' | 'graph_cycle' | 'crawl_prompt_literal' | 'model_unknown' | 'param_unsupported' | 'reasoning_effort_unsupported' | 'tool_unavailable' | 'tool_kind_mismatch' | 'skill_unavailable' | 'builtin_unknown' | 'tool_args_invalid' | 'tool_args_unknown' | 'composio_slug_disabled' | 'composio_schema_missing' | 'memo_unavailable' | 'worker_unavailable' | 'worker_child_no_output' | 'worker_inputs_mismatch' | 'worker_child_inactive_forbidden' | 'worker_child_inactive' | 'secret_unknown' | 'secret_check_skipped' | 'personal_memory_inactive' | 'client_tool_unknown' | 'client_tool_inactive' | 'desktop_tools_unknown_family' | 'inline_credential' | 'op_invalid' | 'op_unknown_node' | 'already_connected' | 'edge_not_found' | 'edge_ambiguous' | 'cannot_remove_start';
|
|
26
|
+
export type IssueCode = 'missing_state' | 'schema_version' | 'var_mapping' | 'classifier_invalid' | 'classifier_edge_missing' | 'out_vars_invalid' | 'start_count' | 'answer_missing' | 'dead_end' | 'unknown_node_type' | 'duplicate_node_id' | 'invalid_node_id' | 'node_id_collides_with_input' | 'edge_unknown_node' | 'edge_bad_handle' | 'edge_duplicate' | 'start_has_input' | 'answer_has_output' | 'multiple_outgoing' | 'field_type' | 'field_required' | 'field_range' | 'field_enum' | 'ref_syntax' | 'ref_unknown_node' | 'ref_out_of_scope' | 'ref_unknown_output' | 'ref_binary_not_allowed' | 'start_input_invalid' | 'answer_mapping_invalid' | 'worker_self_reference' | 'classifier_error_unrouted' | 'classifier_handle_inactive' | 'unreachable_node' | 'graph_cycle' | 'crawl_prompt_literal' | 'model_unknown' | 'param_unsupported' | 'reasoning_effort_unsupported' | 'tool_unavailable' | 'tool_kind_mismatch' | 'skill_unavailable' | 'builtin_unknown' | 'tool_args_invalid' | 'tool_args_unknown' | 'composio_slug_disabled' | 'composio_schema_missing' | 'memo_unavailable' | 'worker_unavailable' | 'worker_child_no_output' | 'worker_inputs_mismatch' | 'worker_child_inactive_forbidden' | 'worker_child_inactive' | 'secret_unknown' | 'secret_check_skipped' | 'personal_memory_inactive' | 'client_tool_unknown' | 'client_tool_inactive' | 'desktop_tools_unknown_family' | 'inline_credential' | 'op_invalid' | 'op_unknown_node' | 'already_connected' | 'edge_not_found' | 'edge_ambiguous' | 'cannot_remove_start' | 'media_node_public';
|
|
27
27
|
export interface GraphIssue {
|
|
28
28
|
code: IssueCode;
|
|
29
29
|
severity: IssueSeverity;
|
|
@@ -37,7 +37,7 @@ export interface GraphIssue {
|
|
|
37
37
|
kind?: CredentialKind;
|
|
38
38
|
suggestedSecret?: string;
|
|
39
39
|
}
|
|
40
|
-
export type InsertNodeType = 'memoNode' | 'llmNode' | 'apiNode' | 'toolNode' | 'workerNode' | 'crawlNode' | 'webActionsNode';
|
|
40
|
+
export type InsertNodeType = 'memoNode' | 'llmNode' | 'apiNode' | 'toolNode' | 'workerNode' | 'crawlNode' | 'webActionsNode' | 'mediaNode';
|
|
41
41
|
export type WorkerOp = {
|
|
42
42
|
op: 'add_node';
|
|
43
43
|
type: NodeTypeName;
|
|
@@ -125,7 +125,7 @@ export interface JsonSchema {
|
|
|
125
125
|
/** Six definitions merged into any tool schema that accepts `graph` (N3). */
|
|
126
126
|
export declare const WORKER_GRAPH_DEFS: {
|
|
127
127
|
nodeType: {
|
|
128
|
-
readonly enum: readonly ['startNode', 'classifierNode', 'memoNode', 'llmNode', 'answerNode', 'apiNode', 'toolNode', 'workerNode', 'crawlNode', 'webActionsNode'];
|
|
128
|
+
readonly enum: readonly ['startNode', 'classifierNode', 'memoNode', 'llmNode', 'answerNode', 'apiNode', 'toolNode', 'workerNode', 'crawlNode', 'webActionsNode', 'mediaNode'];
|
|
129
129
|
};
|
|
130
130
|
nodeId: {
|
|
131
131
|
readonly type: 'string';
|
|
@@ -215,7 +215,7 @@ export declare const WORKER_GRAPH_SCHEMA: {
|
|
|
215
215
|
readonly $schema: 'https://json-schema.org/draft/2020-12/schema';
|
|
216
216
|
readonly $defs: {
|
|
217
217
|
nodeType: {
|
|
218
|
-
readonly enum: readonly ['startNode', 'classifierNode', 'memoNode', 'llmNode', 'answerNode', 'apiNode', 'toolNode', 'workerNode', 'crawlNode', 'webActionsNode'];
|
|
218
|
+
readonly enum: readonly ['startNode', 'classifierNode', 'memoNode', 'llmNode', 'answerNode', 'apiNode', 'toolNode', 'workerNode', 'crawlNode', 'webActionsNode', 'mediaNode'];
|
|
219
219
|
};
|
|
220
220
|
nodeId: {
|
|
221
221
|
readonly type: 'string';
|
|
@@ -336,7 +336,7 @@ export declare const WORKER_OP_SCHEMA: {
|
|
|
336
336
|
};
|
|
337
337
|
readonly $defs: {
|
|
338
338
|
readonly nodeType: {
|
|
339
|
-
readonly enum: readonly ['startNode', 'classifierNode', 'memoNode', 'llmNode', 'answerNode', 'apiNode', 'toolNode', 'workerNode', 'crawlNode', 'webActionsNode'];
|
|
339
|
+
readonly enum: readonly ['startNode', 'classifierNode', 'memoNode', 'llmNode', 'answerNode', 'apiNode', 'toolNode', 'workerNode', 'crawlNode', 'webActionsNode', 'mediaNode'];
|
|
340
340
|
};
|
|
341
341
|
readonly existingId: {
|
|
342
342
|
readonly type: 'string';
|
|
@@ -424,7 +424,7 @@ export declare const WORKER_OP_SCHEMA: {
|
|
|
424
424
|
readonly const: 'insert_node';
|
|
425
425
|
};
|
|
426
426
|
readonly type: {
|
|
427
|
-
readonly enum: readonly ['memoNode', 'llmNode', 'apiNode', 'toolNode', 'workerNode', 'crawlNode', 'webActionsNode'];
|
|
427
|
+
readonly enum: readonly ['memoNode', 'llmNode', 'apiNode', 'toolNode', 'workerNode', 'crawlNode', 'webActionsNode', 'mediaNode'];
|
|
428
428
|
};
|
|
429
429
|
readonly id: {
|
|
430
430
|
readonly $ref: '#/$defs/newId';
|
|
@@ -66,12 +66,14 @@ export declare const ISSUE_SEVERITY: {
|
|
|
66
66
|
readonly edge_not_found: 'blocking';
|
|
67
67
|
readonly edge_ambiguous: 'blocking';
|
|
68
68
|
readonly cannot_remove_start: 'blocking';
|
|
69
|
+
readonly media_node_public: 'blocking';
|
|
69
70
|
};
|
|
70
71
|
/** L1, same order and same messages as FlowEngine.validateFlowStart. */
|
|
71
72
|
export declare function validateFlowStructure(graph: unknown): GraphIssue[];
|
|
72
73
|
/** L2 authoring issues, with intrinsic severity. Final severity is classifyIssues. */
|
|
73
74
|
export declare function validateAuthoring(graph: WorkerGraph, opts?: {
|
|
74
75
|
flowType?: string;
|
|
76
|
+
visibility?: string;
|
|
75
77
|
}): GraphIssue[];
|
|
76
78
|
/** Fingerprint of code, node, field, ref, and credential kind. Message and op are excluded. */
|
|
77
79
|
export declare function issueFingerprint(issue: GraphIssue): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge between the artifact host and the agent runtime.
|
|
3
|
+
* `artifactUuid` / `artifactPublic` stay optional: `host.ts` and the proxy tests still
|
|
4
|
+
* build a target with only `flowId` and `sessionId`. Callers that know the artifact set them.
|
|
5
|
+
*/
|
|
6
|
+
export interface ArtifactAgentProxyTarget {
|
|
7
|
+
flowId: string;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
artifactUuid?: string;
|
|
10
|
+
artifactPublic?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* `ArtifactDO.allowsWorker`. Keeps the `{ ok: true, owner }` / `{ ok: false }` shape.
|
|
14
|
+
* `uuid` and `public` are optional until `checkWorker` fills them.
|
|
15
|
+
*/
|
|
16
|
+
export type AllowsWorkerResult = {
|
|
17
|
+
ok: true;
|
|
18
|
+
owner: string;
|
|
19
|
+
uuid?: string;
|
|
20
|
+
public?: boolean;
|
|
21
|
+
} | {
|
|
22
|
+
ok: false;
|
|
23
|
+
uuid?: string;
|
|
24
|
+
public?: boolean;
|
|
25
|
+
};
|
|
26
|
+
/** Artifact identity carried into a flow turn (`SessionEnv`, `/message` body, `x-hx-artifact`). */
|
|
27
|
+
export interface ArtifactPrincipal {
|
|
28
|
+
uuid: string;
|
|
29
|
+
public: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** Internal header. Client `x-*` headers are stripped before this one is set. */
|
|
32
|
+
export declare const ARTIFACT_HEADER = "x-hx-artifact";
|
|
33
|
+
/** `<uuid>;public=<0|1>`. */
|
|
34
|
+
export declare function formatArtifactHeader(principal: ArtifactPrincipal): string;
|
|
35
|
+
export declare function parseArtifactHeader(value: string | null | undefined): ArtifactPrincipal | null;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/** Shared media-generation contract. Events match `FlowEngineEvent`: `{ type, content, timestamp? }`. */
|
|
2
|
+
export type MediaKind = 'image' | 'video';
|
|
3
|
+
/** Reference to one persisted generated asset. Never includes the prompt or a provider URL. */
|
|
4
|
+
export interface MediaRef {
|
|
5
|
+
kind: 'media';
|
|
6
|
+
/** uuid v4 of the `generated_media` row. */
|
|
7
|
+
id: string;
|
|
8
|
+
mediaType: MediaKind;
|
|
9
|
+
/** `image/png` | `image/jpeg` | `image/webp` | `video/mp4`. */
|
|
10
|
+
mimeType: string;
|
|
11
|
+
bytes?: number;
|
|
12
|
+
width?: number;
|
|
13
|
+
height?: number;
|
|
14
|
+
durationMs?: number;
|
|
15
|
+
}
|
|
16
|
+
export declare function isMediaRef(value: unknown): value is MediaRef;
|
|
17
|
+
export type MediaErrorCode = 'moderated' | 'timeout' | 'provider_error' | 'too_large' | 'cancelled' | 'media_node_public' | 'model_invalid' | 'reference_invalid' | 'ingest_failed' | 'snapshot_too_large' | 'media_job_pending';
|
|
18
|
+
export type MediaEvent = {
|
|
19
|
+
type: 'media:start';
|
|
20
|
+
content: {
|
|
21
|
+
nodeId: string;
|
|
22
|
+
jobId?: string;
|
|
23
|
+
kind: MediaKind;
|
|
24
|
+
modelId: string;
|
|
25
|
+
n: number;
|
|
26
|
+
};
|
|
27
|
+
timestamp?: number;
|
|
28
|
+
} | {
|
|
29
|
+
type: 'media:progress';
|
|
30
|
+
content: {
|
|
31
|
+
nodeId: string;
|
|
32
|
+
jobId: string;
|
|
33
|
+
elapsedMs: number;
|
|
34
|
+
};
|
|
35
|
+
timestamp?: number;
|
|
36
|
+
} | {
|
|
37
|
+
type: 'media:done';
|
|
38
|
+
content: {
|
|
39
|
+
nodeId: string;
|
|
40
|
+
jobId?: string;
|
|
41
|
+
media: MediaRef[];
|
|
42
|
+
};
|
|
43
|
+
timestamp?: number;
|
|
44
|
+
} | {
|
|
45
|
+
type: 'media:error';
|
|
46
|
+
content: {
|
|
47
|
+
nodeId: string;
|
|
48
|
+
jobId?: string;
|
|
49
|
+
code: MediaErrorCode;
|
|
50
|
+
message: string;
|
|
51
|
+
};
|
|
52
|
+
timestamp?: number;
|
|
53
|
+
};
|
|
54
|
+
/** Runtime route that streams a generated asset after flow authorization. */
|
|
55
|
+
export declare const MEDIA_API_PATH = "/api/media";
|
|
56
|
+
export declare function mediaApiUrl(id: string): string;
|
|
57
|
+
/** Path under an artifact base (`<base>/__hx/media/:id`). No leading slash. */
|
|
58
|
+
export declare const ARTIFACT_MEDIA_PATH = "__hx/media";
|
|
59
|
+
export declare function artifactMediaPath(id: string): string;
|
|
60
|
+
/** Public share pages (`/m/:token`). */
|
|
61
|
+
export declare const MEDIA_SHARE_PATH = "/m";
|
|
62
|
+
/** Media ids attached to a start turn (`M::`, `/message`, gateway `ask`). */
|
|
63
|
+
export type StartMediaInput = {
|
|
64
|
+
id: string;
|
|
65
|
+
}[];
|
|
66
|
+
/** Engine context key. Distinct from the `media` outVar of `mediaNode`. */
|
|
67
|
+
export declare const USER_MEDIA_CONTEXT_KEY = "user_media";
|
|
68
|
+
/**
|
|
69
|
+
* Start-node outVar that exposes `StartMediaInput`.
|
|
70
|
+
* `media` is reserved for `mediaNode` and collides with a user input of that name.
|
|
71
|
+
*/
|
|
72
|
+
export declare const USER_MEDIA_OUT_VAR = "user_media";
|
|
73
|
+
/** Body of `/message` and of the artifact worker gateway after a run. */
|
|
74
|
+
export interface MediaRunResult {
|
|
75
|
+
answer: string;
|
|
76
|
+
media: MediaRef[];
|
|
77
|
+
outputs?: Record<string, unknown>;
|
|
78
|
+
runId?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* `mediaNode.data`. `prompt` is always a string.
|
|
82
|
+
* With no references the runner sends that string to the provider (the object form requires `images`).
|
|
83
|
+
*/
|
|
84
|
+
export interface MediaNodeData {
|
|
85
|
+
kind: MediaKind;
|
|
86
|
+
/** Catalog id. Modality must equal `kind`. */
|
|
87
|
+
model: string;
|
|
88
|
+
/** `{{ }}` template. */
|
|
89
|
+
prompt: string;
|
|
90
|
+
/** Upstream outVars of type `image`, or `media` with `mediaType: 'image'`. */
|
|
91
|
+
references?: string[];
|
|
92
|
+
params: {
|
|
93
|
+
aspectRatio?: string;
|
|
94
|
+
seed?: number;
|
|
95
|
+
/** Image: 1..capabilities.media.maxN. Video: always 1. */
|
|
96
|
+
n?: number;
|
|
97
|
+
duration?: number;
|
|
98
|
+
resolution?: string;
|
|
99
|
+
generateAudio?: boolean;
|
|
100
|
+
};
|
|
101
|
+
/** Filtered by `capabilities.media.providerOptionsAllow`. */
|
|
102
|
+
providerOptions?: Record<string, unknown>;
|
|
103
|
+
/** Default `capabilities.media.timeoutMs`. Cap 600_000. */
|
|
104
|
+
timeoutMs?: number;
|
|
105
|
+
}
|
|
@@ -8,6 +8,7 @@ export declare enum NodeType {
|
|
|
8
8
|
TOOL_NODE = "toolNode",
|
|
9
9
|
WORKER_NODE = "workerNode",
|
|
10
10
|
CRAWL_NODE = "crawlNode",
|
|
11
|
-
WEB_ACTIONS_NODE = "webActionsNode"
|
|
11
|
+
WEB_ACTIONS_NODE = "webActionsNode",
|
|
12
|
+
MEDIA_NODE = "mediaNode"
|
|
12
13
|
}
|
|
13
|
-
export type NODETYPES = NodeType.START_NODE | NodeType.CLASSIFIER_NODE | NodeType.MEMO_NODE | NodeType.LLM_NODE | NodeType.ANSWER_NODE | NodeType.API_NODE | NodeType.TOOL_NODE | NodeType.WORKER_NODE | NodeType.CRAWL_NODE | NodeType.WEB_ACTIONS_NODE;
|
|
14
|
+
export type NODETYPES = NodeType.START_NODE | NodeType.CLASSIFIER_NODE | NodeType.MEMO_NODE | NodeType.LLM_NODE | NodeType.ANSWER_NODE | NodeType.API_NODE | NodeType.TOOL_NODE | NodeType.WORKER_NODE | NodeType.CRAWL_NODE | NodeType.WEB_ACTIONS_NODE | NodeType.MEDIA_NODE;
|
|
@@ -8,13 +8,15 @@ export interface FlowEdge {
|
|
|
8
8
|
target: string;
|
|
9
9
|
sourceHandle?: string | null;
|
|
10
10
|
}
|
|
11
|
-
export type OutVarType = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'image' | 'file';
|
|
11
|
+
export type OutVarType = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'image' | 'file' | 'media';
|
|
12
12
|
/** A named, public value exposed by a node result. */
|
|
13
13
|
export interface OutVar {
|
|
14
14
|
name: string;
|
|
15
15
|
path?: string;
|
|
16
16
|
type?: OutVarType;
|
|
17
17
|
description?: string;
|
|
18
|
+
/** Set by `mediaNode` from `data.kind`. Image uploads stay `type: 'image'` and omit this. */
|
|
19
|
+
mediaType?: 'image' | 'video';
|
|
18
20
|
}
|
|
19
21
|
export interface EffectiveOutVar extends OutVar {
|
|
20
22
|
source: 'default' | 'user';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { NodeType } from '../types/node-types';
|
|
2
2
|
import type { EffectiveOutVar, FlowNode, OutVar } from '../types/var-scope';
|
|
3
|
-
export declare function getDefaultOutVars(nodeType: NodeType
|
|
3
|
+
export declare function getDefaultOutVars(nodeType: NodeType, data?: {
|
|
4
|
+
kind?: unknown;
|
|
5
|
+
} | null): OutVar[];
|
|
4
6
|
/** Validates every public output name, including collisions with built-ins and Start inputs. */
|
|
5
7
|
export declare function validateOutVars(node: FlowNode): string[];
|
|
6
8
|
export declare function getEffectiveOutVars(node: FlowNode): EffectiveOutVar[];
|