@hugex/artifact 0.6.0 → 0.6.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 +12 -2
- package/dist/artifact/host.d.ts +3 -0
- package/dist/artifact/limits.d.ts +4 -0
- package/dist/artifact/mcp/authz.d.ts +1 -0
- package/dist/artifact/mcp/context.d.ts +10 -0
- package/dist/artifact/mcp/index.d.ts +1 -1
- package/dist/artifact/mcp/oauth/provider.d.ts +2 -1
- package/dist/artifact/mcp/tools.d.ts +9 -0
- package/dist/artifact/types.d.ts +33 -0
- package/dist/common/flow-graph/schema.d.ts +6 -6
- package/dist/common/types/node-types.d.ts +3 -2
- package/dist/common/types/web-actions-types.d.ts +206 -0
- package/dist/common/utils/webActions.d.ts +31 -0
- package/dist/index.js +51 -45
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DurableObject } from "cloudflare:workers";
|
|
2
|
-
import type { AllowsWorkerInput, AllowsWorkerResult, ArtifactEnv, ArtifactFile, ArtifactLogEntry, ArtifactMeta, ArtifactRpc, ArtifactVersion, CreateArtifactInput, QueryResult, SettingsInput, WorkerGrant, WriteInput, WriteResult } from "../types";
|
|
2
|
+
import type { AllowsWorkerInput, AllowsWorkerResult, ArtifactEnv, ArtifactFile, ArtifactLogEntry, ArtifactMeta, ArtifactRpc, ArtifactStats, ArtifactVersion, CreateArtifactInput, QueryResult, SettingsInput, WorkerGrant, WriteInput, WriteResult } from "../types";
|
|
3
3
|
/**
|
|
4
4
|
* One instance per artifact (`idFromName(slug)`).
|
|
5
|
-
* Supervisor SQLite holds meta, files, versions, logs, and
|
|
5
|
+
* Supervisor SQLite holds meta, files, versions, logs, Worker grants, and daily usage counters.
|
|
6
6
|
* `server.js` runs in a facet named `app`, loaded with `globalOutbound: null`. Its `env` is
|
|
7
7
|
* `{ HX }` (the tenant's `ArtifactWorkerGateway`, from `ctx.exports`) when the tenant exports
|
|
8
8
|
* it, and `{}` otherwise.
|
|
@@ -10,6 +10,8 @@ import type { AllowsWorkerInput, AllowsWorkerResult, ArtifactEnv, ArtifactFile,
|
|
|
10
10
|
export declare class ArtifactDO extends DurableObject<ArtifactEnv> implements ArtifactRpc {
|
|
11
11
|
/** Bumped when an activation window expires so a late health check cannot publish. */
|
|
12
12
|
private activationGen;
|
|
13
|
+
/** UTC day of the last `daily_stat` prune, so `bump()` prunes at most once per day per instance. */
|
|
14
|
+
private statsPrunedDay;
|
|
13
15
|
constructor(ctx: DurableObjectState, env: ArtifactEnv);
|
|
14
16
|
alarm(): Promise<void>;
|
|
15
17
|
create(input: CreateArtifactInput): Promise<{
|
|
@@ -48,6 +50,7 @@ export declare class ArtifactDO extends DurableObject<ArtifactEnv> implements Ar
|
|
|
48
50
|
oraSyncFailed?: boolean;
|
|
49
51
|
} | null>;
|
|
50
52
|
allowsWorker(input: AllowsWorkerInput): Promise<AllowsWorkerResult>;
|
|
53
|
+
private checkWorker;
|
|
51
54
|
listWorkerGrants(): Promise<WorkerGrant[] | null>;
|
|
52
55
|
grantWorker(input: {
|
|
53
56
|
flowId: string;
|
|
@@ -61,6 +64,9 @@ export declare class ArtifactDO extends DurableObject<ArtifactEnv> implements Ar
|
|
|
61
64
|
}): Promise<{
|
|
62
65
|
removed: boolean;
|
|
63
66
|
} | null>;
|
|
67
|
+
stats(opts?: {
|
|
68
|
+
days?: number;
|
|
69
|
+
}): Promise<ArtifactStats | null>;
|
|
64
70
|
/** Harness / diagnostics: supervisor SQLite size and row counts. */
|
|
65
71
|
storageStats(): Promise<{
|
|
66
72
|
databaseSize: number;
|
|
@@ -108,6 +114,10 @@ export declare class ArtifactDO extends DurableObject<ArtifactEnv> implements Ar
|
|
|
108
114
|
private destroyFacet;
|
|
109
115
|
private browserLogAllowed;
|
|
110
116
|
private writeLog;
|
|
117
|
+
/** One daily counter. Like `writeLog`, a counter must never break a response. */
|
|
118
|
+
private bump;
|
|
119
|
+
/** Drops counters older than `LIMITS.statsDays` UTC days (today included). */
|
|
120
|
+
private pruneStats;
|
|
111
121
|
/**
|
|
112
122
|
* Push `meta` to the local index and, when hx-ora is configured, to
|
|
113
123
|
* `PUT /internal/artifacts/:uuid`. The two dirty flags retry independently.
|
package/dist/artifact/host.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { artifactDevPrefix } from "./dev-prefix";
|
|
2
|
+
import type { WorkerConnectionSupport } from "./mcp/context";
|
|
2
3
|
import type { ArtifactEnv, ArtifactHostOptions } from "./types";
|
|
3
4
|
export { artifactDevPrefix };
|
|
4
5
|
/**
|
|
@@ -8,3 +9,5 @@ export { artifactDevPrefix };
|
|
|
8
9
|
* `options.agentProxy` turns on `<base>/__hx/agent/<flowId>/<sessionId>`.
|
|
9
10
|
*/
|
|
10
11
|
export declare function handleArtifactHost(request: Request, env: ArtifactEnv, ctx: ExecutionContext, options?: ArtifactHostOptions): Promise<Response | null>;
|
|
12
|
+
/** Reports the tenant wiring that artifact Worker calls depend on (see `WorkerConnectionSupport`). */
|
|
13
|
+
export declare function workerConnectionSupport(ctx: ExecutionContext, options?: ArtifactHostOptions): WorkerConnectionSupport;
|
|
@@ -12,6 +12,10 @@ export declare const LIMITS: {
|
|
|
12
12
|
readonly healthTimeoutMs: 5000;
|
|
13
13
|
/** Non-active version rows kept by created_at (plus active and log-referenced versions). */
|
|
14
14
|
readonly keepVersions: 50;
|
|
15
|
+
/** UTC days kept in `daily_stat` (today included). Also the maximum `stats({ days })`. */
|
|
16
|
+
readonly statsDays: 90;
|
|
17
|
+
/** Default window for `stats()`. */
|
|
18
|
+
readonly statsDefaultDays: 30;
|
|
15
19
|
};
|
|
16
20
|
/**
|
|
17
21
|
* compatibilityDate pinned on every Dynamic Worker.
|
|
@@ -35,6 +35,7 @@ export declare const TOOL_PERMISSION: {
|
|
|
35
35
|
readonly artifact_rollback: 'manage';
|
|
36
36
|
readonly artifact_settings: 'manage';
|
|
37
37
|
readonly artifact_versions: 'use';
|
|
38
|
+
readonly artifact_stats: 'use';
|
|
38
39
|
};
|
|
39
40
|
export type ArtifactToolName = keyof typeof TOOL_PERMISSION;
|
|
40
41
|
export declare function isArtifactToolName(name: string): name is ArtifactToolName;
|
|
@@ -2,6 +2,15 @@ import type { ArtifactEnv } from '../types';
|
|
|
2
2
|
import type { ArtifactAccess } from './authz';
|
|
3
3
|
import type { ArtifactIdentity } from './auth';
|
|
4
4
|
import type { ConnectionSummary } from './oauth/contract';
|
|
5
|
+
/**
|
|
6
|
+
* Which artifact-to-Worker paths this tenant wires. `server`: the tenant exports
|
|
7
|
+
* `ArtifactWorkerGateway` (artifact `env.HX`); `browser`: `handleArtifactHost` got an
|
|
8
|
+
* `agentProxy` (`window.hx.worker`). Undefined means unknown, so no warning is emitted.
|
|
9
|
+
*/
|
|
10
|
+
export interface WorkerConnectionSupport {
|
|
11
|
+
server: boolean;
|
|
12
|
+
browser: boolean;
|
|
13
|
+
}
|
|
5
14
|
export interface McpRequestContext {
|
|
6
15
|
env: ArtifactEnv;
|
|
7
16
|
identity: ArtifactIdentity;
|
|
@@ -16,4 +25,5 @@ export interface McpRequestContext {
|
|
|
16
25
|
cursor?: string;
|
|
17
26
|
}>;
|
|
18
27
|
revokeConnection?: (grantId: string) => Promise<boolean>;
|
|
28
|
+
workerConnections?: WorkerConnectionSupport;
|
|
19
29
|
}
|
|
@@ -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.2.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';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { ArtifactEnv } from '../../types';
|
|
2
|
+
import type { WorkerConnectionSupport } from '../context';
|
|
2
3
|
export type { McpAccessTokenProps } from './contract';
|
|
3
|
-
export declare function handleOAuthRequest(request: Request, env: ArtifactEnv, ctx: ExecutionContext): Promise<Response>;
|
|
4
|
+
export declare function handleOAuthRequest(request: Request, env: ArtifactEnv, ctx: ExecutionContext, workerConnections?: WorkerConnectionSupport): Promise<Response>;
|
|
@@ -5,6 +5,7 @@ import { buildArtifactUrl } from '../url';
|
|
|
5
5
|
export { isSingleSelect };
|
|
6
6
|
export { artifactIndexRpc, artifactRpc, buildArtifactUrl };
|
|
7
7
|
import type { ArtifactIdentity } from './auth';
|
|
8
|
+
import type { WorkerConnectionSupport } from './context';
|
|
8
9
|
import { type ArtifactAccess } from './authz';
|
|
9
10
|
interface ToolDeps {
|
|
10
11
|
env: ArtifactEnv;
|
|
@@ -13,6 +14,7 @@ interface ToolDeps {
|
|
|
13
14
|
access: ArtifactAccess | null;
|
|
14
15
|
/** Verified upstream Keycloak token, never the opaque MCP credential. */
|
|
15
16
|
upstreamToken?: string;
|
|
17
|
+
workerConnections?: WorkerConnectionSupport;
|
|
16
18
|
}
|
|
17
19
|
export interface ToolDefinition {
|
|
18
20
|
name: string;
|
|
@@ -42,3 +44,10 @@ export declare function initialArtifactFiles(title: string): {
|
|
|
42
44
|
content: string;
|
|
43
45
|
}[];
|
|
44
46
|
export declare function executeTool(name: string, args: Record<string, unknown>, deps: ToolDeps): Promise<ToolTextResult>;
|
|
47
|
+
/** Warnings for the artifact Worker paths this tenant does not wire; empty when support is unknown. */
|
|
48
|
+
export declare function connectionWarnings(support: WorkerConnectionSupport | undefined): string[];
|
|
49
|
+
/** Only warns when a written file actually uses a Worker path the tenant does not wire. */
|
|
50
|
+
export declare function writeConnectionWarnings(changes: ReadonlyArray<{
|
|
51
|
+
path: string;
|
|
52
|
+
content: string | null;
|
|
53
|
+
}>, support: WorkerConnectionSupport | undefined): string[];
|
package/dist/artifact/types.d.ts
CHANGED
|
@@ -73,6 +73,35 @@ export interface WorkerGrant {
|
|
|
73
73
|
grantedBy: string;
|
|
74
74
|
grantedAt: string;
|
|
75
75
|
}
|
|
76
|
+
/** Daily counters kept by ArtifactDO in `daily_stat` (UTC days, 90 days retained). */
|
|
77
|
+
export type ArtifactStatMetric = 'view' | 'view_key' | 'api' | 'api_error' | 'error' | 'browser_error' | 'worker_browser' | 'worker_server' | 'worker_denied';
|
|
78
|
+
export declare const ARTIFACT_STAT_METRICS: readonly ArtifactStatMetric[];
|
|
79
|
+
export interface ArtifactStats {
|
|
80
|
+
days: number;
|
|
81
|
+
/** 'YYYY-MM-DD' UTC, inclusive. */
|
|
82
|
+
from: string;
|
|
83
|
+
/** 'YYYY-MM-DD' UTC (today), inclusive. */
|
|
84
|
+
to: string;
|
|
85
|
+
/** Ascending, one row per day, zeros included. */
|
|
86
|
+
series: Array<{
|
|
87
|
+
day: string;
|
|
88
|
+
} & Record<ArtifactStatMetric, number>>;
|
|
89
|
+
totals: Record<ArtifactStatMetric, number>;
|
|
90
|
+
/** Last day with view > 0 within the 90 retained days. */
|
|
91
|
+
lastViewDay: string | null;
|
|
92
|
+
storage: {
|
|
93
|
+
databaseSize: number;
|
|
94
|
+
blobCount: number;
|
|
95
|
+
versionCount: number;
|
|
96
|
+
};
|
|
97
|
+
versions: {
|
|
98
|
+
total: number;
|
|
99
|
+
failed: number;
|
|
100
|
+
lastAt: string | null;
|
|
101
|
+
};
|
|
102
|
+
/** Current Worker grants. */
|
|
103
|
+
workers: number;
|
|
104
|
+
}
|
|
76
105
|
export type AllowsWorkerInput = {
|
|
77
106
|
flowId: string;
|
|
78
107
|
key?: string | null;
|
|
@@ -261,6 +290,10 @@ export interface ArtifactRpc {
|
|
|
261
290
|
expectUuid: string;
|
|
262
291
|
expectOwner: string;
|
|
263
292
|
}): Promise<WorkerGrant | null>;
|
|
293
|
+
/** Daily usage counters for the last `days` UTC days (default 30, clamped to 1..90). Null when the artifact does not exist. */
|
|
294
|
+
stats(opts?: {
|
|
295
|
+
days?: number;
|
|
296
|
+
}): Promise<ArtifactStats | null>;
|
|
264
297
|
/** Null when the artifact does not exist or its UUID no longer matches. */
|
|
265
298
|
revokeWorker(input: {
|
|
266
299
|
flowId: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type NodeTypeName = 'startNode' | 'classifierNode' | 'memoNode' | 'llmNode' | 'answerNode' | 'apiNode' | 'toolNode' | 'workerNode' | 'crawlNode';
|
|
1
|
+
export type NodeTypeName = 'startNode' | 'classifierNode' | 'memoNode' | 'llmNode' | 'answerNode' | 'apiNode' | 'toolNode' | 'workerNode' | 'crawlNode' | 'webActionsNode';
|
|
2
2
|
export interface AuthoringNode {
|
|
3
3
|
id: string;
|
|
4
4
|
type: string;
|
|
@@ -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';
|
|
40
|
+
export type InsertNodeType = 'memoNode' | 'llmNode' | 'apiNode' | 'toolNode' | 'workerNode' | 'crawlNode' | 'webActionsNode';
|
|
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'];
|
|
128
|
+
readonly enum: readonly ['startNode', 'classifierNode', 'memoNode', 'llmNode', 'answerNode', 'apiNode', 'toolNode', 'workerNode', 'crawlNode', 'webActionsNode'];
|
|
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'];
|
|
218
|
+
readonly enum: readonly ['startNode', 'classifierNode', 'memoNode', 'llmNode', 'answerNode', 'apiNode', 'toolNode', 'workerNode', 'crawlNode', 'webActionsNode'];
|
|
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'];
|
|
339
|
+
readonly enum: readonly ['startNode', 'classifierNode', 'memoNode', 'llmNode', 'answerNode', 'apiNode', 'toolNode', 'workerNode', 'crawlNode', 'webActionsNode'];
|
|
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'];
|
|
427
|
+
readonly enum: readonly ['memoNode', 'llmNode', 'apiNode', 'toolNode', 'workerNode', 'crawlNode', 'webActionsNode'];
|
|
428
428
|
};
|
|
429
429
|
readonly id: {
|
|
430
430
|
readonly $ref: '#/$defs/newId';
|
|
@@ -7,6 +7,7 @@ export declare enum NodeType {
|
|
|
7
7
|
API_NODE = "apiNode",
|
|
8
8
|
TOOL_NODE = "toolNode",
|
|
9
9
|
WORKER_NODE = "workerNode",
|
|
10
|
-
CRAWL_NODE = "crawlNode"
|
|
10
|
+
CRAWL_NODE = "crawlNode",
|
|
11
|
+
WEB_ACTIONS_NODE = "webActionsNode"
|
|
11
12
|
}
|
|
12
|
-
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;
|
|
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;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import type { OutVar } from './var-scope';
|
|
2
|
+
/**
|
|
3
|
+
* How a WebActions step finds its element. Mirrors Playwright locators so the
|
|
4
|
+
* runtime can map each one directly (`getByTestId`, `getByRole`, ... , `locator`).
|
|
5
|
+
*/
|
|
6
|
+
export type WebActionLocator = {
|
|
7
|
+
by: 'testId';
|
|
8
|
+
value: string;
|
|
9
|
+
} | {
|
|
10
|
+
by: 'role';
|
|
11
|
+
role: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
exact?: boolean;
|
|
14
|
+
} | {
|
|
15
|
+
by: 'label';
|
|
16
|
+
value: string;
|
|
17
|
+
exact?: boolean;
|
|
18
|
+
} | {
|
|
19
|
+
by: 'placeholder';
|
|
20
|
+
value: string;
|
|
21
|
+
exact?: boolean;
|
|
22
|
+
} | {
|
|
23
|
+
by: 'text';
|
|
24
|
+
value: string;
|
|
25
|
+
exact?: boolean;
|
|
26
|
+
} | {
|
|
27
|
+
by: 'css';
|
|
28
|
+
value: string;
|
|
29
|
+
};
|
|
30
|
+
export type WebActionLocatorKind = WebActionLocator['by'];
|
|
31
|
+
/** Element picked in the builder: a primary locator, ordered fallbacks and a display hint. */
|
|
32
|
+
export interface WebActionTarget {
|
|
33
|
+
locator: WebActionLocator;
|
|
34
|
+
fallbacks?: WebActionLocator[];
|
|
35
|
+
/** What the builder showed when the element was picked. Display only. */
|
|
36
|
+
hint?: {
|
|
37
|
+
tag?: string;
|
|
38
|
+
type?: string;
|
|
39
|
+
role?: string;
|
|
40
|
+
name?: string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
interface WebActionBase {
|
|
44
|
+
/** Stable id of the step inside the node (UI keys and per-step results). */
|
|
45
|
+
id: string;
|
|
46
|
+
label?: string;
|
|
47
|
+
}
|
|
48
|
+
export type WebActionSelectMatch = 'exact' | 'startsWith' | 'contains';
|
|
49
|
+
export type WebAction = (WebActionBase & {
|
|
50
|
+
op: 'goto';
|
|
51
|
+
url: string;
|
|
52
|
+
}) | (WebActionBase & {
|
|
53
|
+
op: 'click';
|
|
54
|
+
target: WebActionTarget;
|
|
55
|
+
waitForNavigation?: boolean;
|
|
56
|
+
}) | (WebActionBase & {
|
|
57
|
+
op: 'fill';
|
|
58
|
+
target: WebActionTarget;
|
|
59
|
+
value: string;
|
|
60
|
+
}) | (WebActionBase & {
|
|
61
|
+
op: 'select';
|
|
62
|
+
target: WebActionTarget;
|
|
63
|
+
value: string;
|
|
64
|
+
match?: WebActionSelectMatch;
|
|
65
|
+
}) | (WebActionBase & {
|
|
66
|
+
op: 'check';
|
|
67
|
+
target: WebActionTarget;
|
|
68
|
+
checked: boolean | string;
|
|
69
|
+
}) | (WebActionBase & {
|
|
70
|
+
op: 'wait';
|
|
71
|
+
target?: WebActionTarget;
|
|
72
|
+
ms?: number;
|
|
73
|
+
}) | (WebActionBase & {
|
|
74
|
+
op: 'extract';
|
|
75
|
+
target: WebActionTarget;
|
|
76
|
+
as: WebActionExtractAs;
|
|
77
|
+
attribute?: string;
|
|
78
|
+
/** Key under data.extracted. */
|
|
79
|
+
key: string;
|
|
80
|
+
});
|
|
81
|
+
export type WebActionOp = WebAction['op'];
|
|
82
|
+
export type WebActionExtractAs = 'text' | 'value' | 'attribute' | 'html';
|
|
83
|
+
export interface WebActionsNodeData {
|
|
84
|
+
/** Initial page. http(s) when it contains no template. */
|
|
85
|
+
url: string;
|
|
86
|
+
actions: WebAction[];
|
|
87
|
+
/** Budget for the whole node run, in milliseconds. */
|
|
88
|
+
timeoutMs?: number;
|
|
89
|
+
outVars?: OutVar[];
|
|
90
|
+
/** Reuse the browser state (cookies, storage) across runs and skip the login steps while it still works. */
|
|
91
|
+
session?: WebActionsSessionConfig;
|
|
92
|
+
/** Headers the site owner agreed to. Values are templates and are never logged. */
|
|
93
|
+
headers?: {
|
|
94
|
+
name: string;
|
|
95
|
+
value: string;
|
|
96
|
+
}[];
|
|
97
|
+
}
|
|
98
|
+
export interface WebActionsSessionConfig {
|
|
99
|
+
enabled: boolean;
|
|
100
|
+
/** Steps [0, loginSteps) are the login block. */
|
|
101
|
+
loginSteps: number;
|
|
102
|
+
/** Bumped by "forget saved session": a new generation starts from an empty browser state. */
|
|
103
|
+
generation?: number;
|
|
104
|
+
}
|
|
105
|
+
export interface WebActionStepResult {
|
|
106
|
+
id: string;
|
|
107
|
+
op: WebActionOp;
|
|
108
|
+
ok: boolean;
|
|
109
|
+
ms: number;
|
|
110
|
+
error?: string;
|
|
111
|
+
/** Not executed now: 'session' = skipped thanks to a saved session; 'live' = already ran on the live inspector page. */
|
|
112
|
+
skipped?: 'session' | 'live';
|
|
113
|
+
/** Set when the failure is a bot-manager block or challenge. The run stops. */
|
|
114
|
+
blocked?: {
|
|
115
|
+
vendor: string;
|
|
116
|
+
kind: 'block' | 'challenge';
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
export interface WebActionsNodeResult {
|
|
120
|
+
ok: boolean;
|
|
121
|
+
error: string | null;
|
|
122
|
+
data: {
|
|
123
|
+
url: string;
|
|
124
|
+
title: string;
|
|
125
|
+
extracted: Record<string, unknown>;
|
|
126
|
+
steps: WebActionStepResult[];
|
|
127
|
+
} | null;
|
|
128
|
+
}
|
|
129
|
+
/** POST /ai/api/flow/web-actions/inspect body. */
|
|
130
|
+
export interface WebActionsInspectRequest {
|
|
131
|
+
/** Initial page. Templates allowed; resolved like the runtime. */
|
|
132
|
+
url: string;
|
|
133
|
+
actions: WebAction[];
|
|
134
|
+
/** Run actions[0..uptoIndex) before inspecting. Default: all actions. */
|
|
135
|
+
uptoIndex?: number;
|
|
136
|
+
/** Test values for non-secret refs, keyed by ref text (e.g. "start.email"). Never persisted. */
|
|
137
|
+
testValues?: Record<string, string>;
|
|
138
|
+
timeoutMs?: number;
|
|
139
|
+
/** Token of a live inspector browser: continue on its page when the already-run steps are unchanged. */
|
|
140
|
+
live?: string;
|
|
141
|
+
/** Close the live browser of `live` and return without inspecting. */
|
|
142
|
+
close?: boolean;
|
|
143
|
+
/** Same optional headers as the node. `{{ secrets.* }}` resolves like step values. */
|
|
144
|
+
headers?: {
|
|
145
|
+
name: string;
|
|
146
|
+
value: string;
|
|
147
|
+
}[];
|
|
148
|
+
}
|
|
149
|
+
export interface WebInspectBox {
|
|
150
|
+
x: number;
|
|
151
|
+
y: number;
|
|
152
|
+
width: number;
|
|
153
|
+
height: number;
|
|
154
|
+
}
|
|
155
|
+
export type WebInspectElementKind = 'text' | 'select' | 'checkbox' | 'radio' | 'button' | 'link' | 'other';
|
|
156
|
+
export interface WebInspectElement {
|
|
157
|
+
/** Stable within one response: "e1", "e2", ... */
|
|
158
|
+
id: string;
|
|
159
|
+
kind: WebInspectElementKind;
|
|
160
|
+
tag: string;
|
|
161
|
+
type?: string;
|
|
162
|
+
role?: string;
|
|
163
|
+
name?: string;
|
|
164
|
+
label?: string;
|
|
165
|
+
placeholder?: string;
|
|
166
|
+
text?: string;
|
|
167
|
+
/** Only for kind "select". */
|
|
168
|
+
options?: {
|
|
169
|
+
value: string;
|
|
170
|
+
label: string;
|
|
171
|
+
}[];
|
|
172
|
+
checked?: boolean;
|
|
173
|
+
/** CSS pixels relative to the screenshot (viewport) origin. */
|
|
174
|
+
box: WebInspectBox;
|
|
175
|
+
/** Locators that matched exactly this one element, best first. Never empty. */
|
|
176
|
+
candidates: WebActionLocator[];
|
|
177
|
+
/** Ops the picker offers for this element. */
|
|
178
|
+
ops: WebActionOp[];
|
|
179
|
+
}
|
|
180
|
+
export interface WebActionsInspectResponse {
|
|
181
|
+
ok: boolean;
|
|
182
|
+
/** Error of the step that failed while replaying, or of the inspection. */
|
|
183
|
+
error: string | null;
|
|
184
|
+
url: string;
|
|
185
|
+
title: string;
|
|
186
|
+
/** Viewport screenshot. width/height are CSS pixels (1280x800 by default). */
|
|
187
|
+
screenshot: {
|
|
188
|
+
mime: 'image/jpeg';
|
|
189
|
+
data: string;
|
|
190
|
+
width: number;
|
|
191
|
+
height: number;
|
|
192
|
+
} | null;
|
|
193
|
+
elements: WebInspectElement[];
|
|
194
|
+
steps: WebActionStepResult[];
|
|
195
|
+
/** Live browser kept open for the next request; null when it was closed or could not be kept. */
|
|
196
|
+
live?: {
|
|
197
|
+
token: string;
|
|
198
|
+
reusedSteps: number;
|
|
199
|
+
} | null;
|
|
200
|
+
/** Bot-manager block/challenge on the page, or a cookie-name hint. Null when absent. */
|
|
201
|
+
protection?: {
|
|
202
|
+
vendor: string;
|
|
203
|
+
kind: 'block' | 'challenge';
|
|
204
|
+
} | null;
|
|
205
|
+
}
|
|
206
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { WebActionExtractAs, WebActionLocatorKind, WebActionOp, WebActionSelectMatch } from '../types/web-actions-types';
|
|
2
|
+
export declare const WEB_ACTIONS_DEFAULTS: {
|
|
3
|
+
readonly timeoutMs: 30000;
|
|
4
|
+
};
|
|
5
|
+
export declare const WEB_ACTIONS_LIMITS: {
|
|
6
|
+
readonly actions: 50;
|
|
7
|
+
readonly timeoutMs: {
|
|
8
|
+
readonly min: 1000;
|
|
9
|
+
readonly max: 120000;
|
|
10
|
+
};
|
|
11
|
+
readonly waitMs: {
|
|
12
|
+
readonly min: 0;
|
|
13
|
+
readonly max: 30000;
|
|
14
|
+
};
|
|
15
|
+
readonly fallbacks: 5;
|
|
16
|
+
readonly headers: 10;
|
|
17
|
+
readonly headerValueBytes: 4096;
|
|
18
|
+
};
|
|
19
|
+
export declare const WEB_ACTION_OPS: readonly WebActionOp[];
|
|
20
|
+
export declare const WEB_ACTION_LOCATOR_KINDS: readonly WebActionLocatorKind[];
|
|
21
|
+
export declare const WEB_ACTION_EXTRACT_AS: readonly WebActionExtractAs[];
|
|
22
|
+
export declare const WEB_ACTION_SELECT_MATCH: readonly WebActionSelectMatch[];
|
|
23
|
+
export interface WebActionsIssue {
|
|
24
|
+
code: 'field_type' | 'field_required' | 'field_range' | 'field_enum';
|
|
25
|
+
field: string;
|
|
26
|
+
message: string;
|
|
27
|
+
}
|
|
28
|
+
/** Structural checks for webActionsNode data shared by graph validation and the runner. URL format is checked by the caller. */
|
|
29
|
+
export declare function validateWebActionsData(data: Record<string, unknown>): WebActionsIssue[];
|
|
30
|
+
/** Index of the first step with a target in [from, to), or -1. */
|
|
31
|
+
export declare function firstTargetStep(actions: readonly unknown[], from: number, to?: number): number;
|