@midscene/test 1.12.4-beta-20260903111111.0 → 1.12.4
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/es/android/index.mjs +50 -106
- package/dist/es/android/index.mjs.map +1 -1
- package/dist/es/cli/index.mjs +99 -149
- package/dist/es/cli/index.mjs.map +1 -1
- package/dist/es/harmony/index.mjs +119 -0
- package/dist/es/harmony/index.mjs.map +1 -0
- package/dist/es/index.mjs +36 -87
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/ios/index.mjs +51 -101
- package/dist/es/ios/index.mjs.map +1 -1
- package/dist/es/midscene/index.mjs +37 -235
- package/dist/es/midscene/index.mjs.map +1 -1
- package/dist/es/playwright/index.mjs +14 -10
- package/dist/es/playwright/index.mjs.map +1 -1
- package/dist/es/test-cli.mjs +102 -150
- package/dist/es/test-cli.mjs.map +1 -1
- package/dist/lib/android/index.js +151 -178
- package/dist/lib/android/index.js.map +1 -1
- package/dist/lib/cli/index.js +99 -149
- package/dist/lib/cli/index.js.map +1 -1
- package/dist/lib/harmony/index.js +188 -0
- package/dist/lib/harmony/index.js.map +1 -0
- package/dist/lib/index.js +37 -100
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/ios/index.js +152 -173
- package/dist/lib/ios/index.js.map +1 -1
- package/dist/lib/midscene/index.js +264 -412
- package/dist/lib/midscene/index.js.map +1 -1
- package/dist/lib/playwright/index.js +14 -10
- package/dist/lib/playwright/index.js.map +1 -1
- package/dist/lib/test-cli.js +102 -150
- package/dist/lib/test-cli.js.map +1 -1
- package/dist/types/android/index.d.ts +27 -101
- package/dist/types/cli/index.d.ts +9 -32
- package/dist/types/harmony/index.d.ts +124 -0
- package/dist/types/index.d.ts +18 -45
- package/dist/types/ios/index.d.ts +28 -107
- package/dist/types/midscene/index.d.ts +54 -153
- package/dist/types/playwright/index.d.ts +9 -63
- package/package.json +25 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"midscene/index.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/errors.ts","../../../src/node/define-node.ts","../../../src/device/lifecycle.ts","../../../src/midscene/index.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { z } from 'zod/v4';\n\nexport interface WorkflowErrorOptions {\n code?: string;\n details?: unknown;\n cause?: unknown;\n}\n\nexport class WorkflowError extends Error {\n readonly code: string;\n readonly details?: unknown;\n\n constructor(message: string, options: WorkflowErrorOptions = {}) {\n super(message, { cause: options.cause });\n this.name = new.target.name;\n this.code = options.code ?? 'WORKFLOW_ERROR';\n this.details = options.details;\n }\n\n toJSON(): Record<string, unknown> {\n return {\n name: this.name,\n message: this.message,\n code: this.code,\n ...(this.details === undefined ? {} : { details: this.details }),\n };\n }\n}\n\nexport class WorkflowParseError extends WorkflowError {\n constructor(message: string, details?: unknown, cause?: unknown) {\n super(message, { code: 'WORKFLOW_PARSE_ERROR', details, cause });\n }\n}\n\nexport class NodeDefinitionError extends WorkflowError {\n constructor(message: string, details?: unknown) {\n super(message, { code: 'NODE_DEFINITION_ERROR', details });\n }\n}\n\nexport class DuplicateNodeError extends WorkflowError {\n readonly node: string;\n\n constructor(node: string) {\n super(`Node \"${node}\" is already registered.`, {\n code: 'DUPLICATE_NODE',\n details: { node },\n });\n this.node = node;\n }\n}\n\nexport class NodeNotFoundError extends WorkflowError {\n readonly node: string;\n\n constructor(node: string) {\n super(`Node \"${node}\" is not registered.`, {\n code: 'NODE_NOT_FOUND',\n details: { node },\n });\n this.node = node;\n }\n}\n\nexport class NodeInputValidationError extends WorkflowError {\n constructor(message: string, details?: unknown) {\n super(message, { code: 'NODE_INPUT_VALIDATION_ERROR', details });\n }\n\n static fromZod(node: string, error: z.ZodError): NodeInputValidationError {\n const issues = error.issues.map((issue) => ({\n code: issue.code,\n path: issue.path.map(String).join('.'),\n message: issue.message,\n }));\n const firstIssue = issues[0];\n const path = firstIssue?.path || '<root>';\n const message = firstIssue?.message ?? 'invalid input';\n return new NodeInputValidationError(\n `Node \"${node}\" input validation failed at \"${path}\": ${message}`,\n { node, issues },\n );\n }\n}\n\nexport class StepTimeoutError extends WorkflowError {\n readonly timeoutMs: number;\n readonly node?: string;\n\n constructor(timeoutMs: number, node?: string) {\n super(\n node\n ? `Node \"${node}\" timed out after ${timeoutMs}ms.`\n : `Step timed out after ${timeoutMs}ms.`,\n {\n code: 'STEP_TIMEOUT',\n details: { timeoutMs, ...(node === undefined ? {} : { node }) },\n },\n );\n this.timeoutMs = timeoutMs;\n this.node = node;\n }\n}\n\nexport class NodeExecutionError extends WorkflowError {\n readonly node: string;\n\n constructor(node: string, cause: unknown) {\n const causeMessage =\n cause instanceof Error ? cause.message : String(cause ?? 'Unknown error');\n super(`Node \"${node}\" failed: ${causeMessage}`, {\n code: 'NODE_EXECUTION_ERROR',\n details: { node },\n cause,\n });\n this.node = node;\n }\n}\n\nexport class WorkflowLifecycleError extends WorkflowError {\n constructor(message: string, details?: unknown) {\n super(message, { code: 'WORKFLOW_LIFECYCLE_ERROR', details });\n }\n}\n\nexport class ProjectSetupError extends WorkflowError {\n constructor(cause: unknown, details: { projectName: string }) {\n const causeMessage =\n cause instanceof Error ? cause.message : String(cause ?? 'Unknown error');\n super(`Project \"${details.projectName}\" setup failed: ${causeMessage}`, {\n code: 'PROJECT_SETUP_ERROR',\n details,\n cause,\n });\n }\n}\n\nexport class ProjectTeardownError extends WorkflowError {\n constructor(\n cause: unknown,\n details: { projectName: string; registrationIndex: number },\n ) {\n const causeMessage =\n cause instanceof Error ? cause.message : String(cause ?? 'Unknown error');\n super(`Project \"${details.projectName}\" teardown failed: ${causeMessage}`, {\n code: 'PROJECT_TEARDOWN_ERROR',\n details,\n cause,\n });\n }\n}\n\nexport class NodeScopeTeardownError extends WorkflowError {\n constructor(\n cause: unknown,\n details: {\n scope: 'case' | 'document';\n scopeId: string;\n node: string;\n registrationIndex: number;\n },\n ) {\n const causeMessage =\n cause instanceof Error ? cause.message : String(cause ?? 'Unknown error');\n super(\n `${details.scope === 'case' ? 'Case attempt' : 'Workflow document'} node teardown failed for \"${details.node}\": ${causeMessage}`,\n { code: 'NODE_SCOPE_TEARDOWN_ERROR', details, cause },\n );\n }\n}\n\nexport class FatalDeviceError extends WorkflowError {\n constructor(message: string, cause?: unknown) {\n super(message, { code: 'FATAL_DEVICE_ERROR', cause });\n }\n}\n\nexport const isFatalDeviceError = (error: unknown): boolean => {\n if (error instanceof FatalDeviceError) return true;\n if (error instanceof WorkflowError && error.code === 'FATAL_DEVICE_ERROR') {\n return true;\n }\n if (\n error instanceof Error &&\n /device offline|device not found|(?:adb|bdc|device) connection (?:was )?closed/i.test(\n error.message,\n )\n ) {\n return true;\n }\n return error instanceof Error && error.cause !== undefined\n ? isFatalDeviceError(error.cause)\n : false;\n};\n\nexport class CaseExecutionError extends WorkflowError {\n readonly result: import('./engine/types').CaseRunResult;\n\n constructor(result: import('./engine/types').CaseRunResult) {\n super(`Case \"${result.name}\" failed.`, {\n code: 'CASE_EXECUTION_FAILED',\n details: { caseId: result.caseId, runId: result.runId },\n });\n this.result = result;\n }\n}\n\nexport class WorkflowDocumentExecutionError extends WorkflowError {\n readonly result: import('./engine/types').WorkflowDocumentRunResult;\n\n constructor(result: import('./engine/types').WorkflowDocumentRunResult) {\n super(`Workflow document \"${result.sourcePath}\" failed.`, {\n code: 'WORKFLOW_DOCUMENT_EXECUTION_FAILED',\n details: {\n documentId: result.documentId,\n documentRunId: result.documentRunId,\n },\n });\n this.result = result;\n }\n}\n\nexport function normalizeNodeExecutionError(\n error: unknown,\n node: string,\n): WorkflowError {\n return error instanceof WorkflowError\n ? error\n : new NodeExecutionError(node, error);\n}\n","import { z } from 'zod/v4';\nimport { NodeDefinitionError } from '../errors';\nimport type {\n DefineNodeOptions,\n DefineNodeWithSchemaOptions,\n NodeDefinition,\n NodeDefinitionWithSchema,\n NodeInputSchema,\n} from './types';\n\nconst validateOptionalText = (\n value: unknown,\n field: 'title' | 'description',\n node: string,\n): void => {\n if (\n value !== undefined &&\n (typeof value !== 'string' || value.trim().length === 0)\n ) {\n throw new NodeDefinitionError(\n `Node \"${node}\" ${field} must be a non-empty string.`,\n { node, field },\n );\n }\n};\n\nconst validateInputSchema = (schema: unknown, node: string): void => {\n if (schema === undefined) return;\n if (!(schema instanceof z.ZodObject)) {\n throw new NodeDefinitionError(\n `Node \"${node}\" inputSchema must be a Zod object schema.`,\n { node, field: 'inputSchema' },\n );\n }\n if ('$' in schema.shape) {\n throw new NodeDefinitionError(\n `Node \"${node}\" inputSchema must not declare \"$\" as an input property.`,\n { node, field: 'inputSchema.$' },\n );\n }\n};\n\nconst validateDefinition = (options: {\n name: string;\n title?: unknown;\n description?: unknown;\n inputSchema?: unknown;\n execute: unknown;\n}): void => {\n if (!options || typeof options !== 'object') {\n throw new NodeDefinitionError('Node definition must be an object.');\n }\n\n if (typeof options.name !== 'string' || options.name.trim().length === 0) {\n throw new NodeDefinitionError('Node name must be a non-empty string.');\n }\n\n validateOptionalText(options.title, 'title', options.name);\n validateOptionalText(options.description, 'description', options.name);\n validateInputSchema(options.inputSchema, options.name);\n\n if (typeof options.execute !== 'function') {\n throw new NodeDefinitionError(\n `Node \"${options.name}\" must provide an execute function.`,\n { node: options.name },\n );\n }\n};\n\nexport function defineNode<\n TSchema extends NodeInputSchema,\n TData = unknown,\n TContext = unknown,\n>(\n options: DefineNodeWithSchemaOptions<TSchema, TData, TContext>,\n): NodeDefinitionWithSchema<TSchema, TData, TContext>;\n\nexport function defineNode<\n TInput = unknown,\n TData = unknown,\n TContext = unknown,\n>(\n options: DefineNodeOptions<TInput, TData, TContext>,\n): NodeDefinition<TInput, TData, TContext>;\n\nexport function defineNode(\n options: DefineNodeOptions<any, any, any>,\n): NodeDefinition<any, any, any> {\n validateDefinition(options);\n return options;\n}\n","import { z } from 'zod/v4';\nimport type { Awaitable } from '../engine/types';\nimport { NodeExecutionError } from '../errors';\nimport { defineNode } from '../node/define-node';\nimport type { NodeDefinition, NodeExecutionContext } from '../node/types';\n\ntype NodeContext<TContext> = NodeExecutionContext<unknown, TContext>;\ntype AgentGetter<TContext> = (ctx: NodeContext<TContext>) => Awaitable<unknown>;\ntype LifecycleMethod = 'launch' | 'terminate';\n\n/** Device capabilities required by Android and iOS lifecycle Nodes. */\nexport interface DeviceLifecycleAgent {\n launch(uri: string): Promise<void>;\n terminate(uri: string): Promise<void>;\n}\n\nconst lifecycleInputSchema = (\n operation: LifecycleMethod,\n description: string,\n) =>\n z\n .strictObject({\n prompt: z\n .string()\n .regex(/\\S/, 'prompt must contain a non-whitespace character')\n .optional()\n .describe(`String shorthand for the app to ${operation}.`),\n uri: z\n .string()\n .regex(/\\S/, 'uri must contain a non-whitespace character')\n .optional()\n .describe(description),\n })\n .superRefine((input, ctx) => {\n if ((input.prompt === undefined) === (input.uri === undefined)) {\n ctx.addIssue({\n code: 'custom',\n message: 'exactly one of prompt and uri is required',\n });\n }\n });\n\n/** Input schema for the device launch Node. */\nexport const launchInputSchema = lifecycleInputSchema(\n 'launch',\n 'The app, URL, URI, package name, or bundle identifier to launch.',\n);\n\n/** Input schema for the device terminate Node. */\nexport const terminateInputSchema = lifecycleInputSchema(\n 'terminate',\n 'The package name, bundle identifier, or app name to terminate.',\n);\n\nexport type LaunchNodeInput = z.infer<typeof launchInputSchema>;\nexport type TerminateNodeInput = z.infer<typeof terminateInputSchema>;\n\nconst requireLifecycleMethod = (\n agent: unknown,\n method: LifecycleMethod,\n agentName: string,\n): DeviceLifecycleAgent[LifecycleMethod] => {\n if (\n typeof agent !== 'object' ||\n agent === null ||\n typeof (agent as Record<LifecycleMethod, unknown>)[method] !== 'function'\n ) {\n throw new NodeExecutionError(\n method,\n new TypeError(`getAgent() must return ${agentName} with ${method}().`),\n );\n }\n return (agent as DeviceLifecycleAgent)[method];\n};\n\nexport const createLaunchNode = <TContext>(\n getAgent: AgentGetter<TContext>,\n agentName = 'an Agent',\n): NodeDefinition<any, any, TContext> =>\n defineNode<typeof launchInputSchema, unknown, TContext>({\n name: 'launch',\n description:\n 'Launch an app, URL, or URI through the current Midscene Agent. This Node does not install or manage applications.',\n inputSchema: launchInputSchema,\n async execute(ctx) {\n const uri = ctx.input.uri ?? ctx.input.prompt!;\n const agent = await getAgent(ctx);\n const launch = requireLifecycleMethod(agent, 'launch', agentName);\n await launch.call(agent, uri);\n return { summary: `Launched ${uri}` };\n },\n });\n\nconst createTerminateNode = <TContext>(\n getAgent: AgentGetter<TContext>,\n agentName: string,\n): NodeDefinition<any, any, TContext> =>\n defineNode<typeof terminateInputSchema, unknown, TContext>({\n name: 'terminate',\n description:\n 'Terminate an application through the current Midscene Agent. This Node does not uninstall the application or clear its data.',\n inputSchema: terminateInputSchema,\n async execute(ctx) {\n const uri = ctx.input.uri ?? ctx.input.prompt!;\n const agent = await getAgent(ctx);\n const terminate = requireLifecycleMethod(agent, 'terminate', agentName);\n await terminate.call(agent, uri);\n return { summary: `Terminated ${uri}` };\n },\n });\n\nexport const createDeviceLifecycleNodes = <TContext>(\n getAgent: (ctx: NodeContext<TContext>) => Awaitable<DeviceLifecycleAgent>,\n agentName: string,\n): readonly NodeDefinition<any, any, TContext>[] => [\n createLaunchNode(getAgent, agentName),\n createTerminateNode(getAgent, agentName),\n];\n","import { z } from 'zod/v4';\nimport { createLaunchNode } from '../device/lifecycle';\nexport type { LaunchNodeInput } from '../device/lifecycle';\nexport { launchInputSchema } from '../device/lifecycle';\nimport type { Awaitable, NodeHistoryEntry } from '../engine/types';\nimport { NodeDefinitionError, NodeExecutionError } from '../errors';\nimport { defineNode } from '../node/define-node';\nimport type {\n NodeDefinition,\n NodeExecutionContext,\n NodeResult,\n} from '../node/types';\n\nexport interface MidsceneAiActOptions {\n cacheable?: boolean;\n fileChooserAccept?: string | string[];\n deepThink?: 'unset' | boolean;\n deepLocate?: boolean;\n context?: string;\n abortSignal?: AbortSignal;\n}\n\nexport interface MidsceneAiAssertOptions {\n domIncluded?: boolean | 'visible-only';\n screenshotIncluded?: boolean;\n context?: string;\n abortSignal?: AbortSignal;\n keepRawResponse?: boolean;\n}\n\nexport interface MidscenePromptImage {\n name: string;\n url: string;\n}\n\nexport type MidsceneUserPrompt =\n | string\n | {\n prompt: string;\n images?: MidscenePromptImage[];\n convertHttpImage2Base64?: boolean;\n };\n\nexport interface MidsceneReportScreenshot {\n base64: string;\n description?: string;\n}\n\nexport interface MidsceneRecordToReportOptions {\n content?: string;\n screenshotBase64?: string;\n screenshots?: MidsceneReportScreenshot[];\n}\n\nexport interface MidsceneUIAgent {\n aiAct(\n prompt: MidsceneUserPrompt,\n options?: MidsceneAiActOptions,\n ): Promise<string | undefined>;\n aiAssert(\n prompt: MidsceneUserPrompt,\n message?: string,\n options?: MidsceneAiAssertOptions,\n ): Promise<unknown>;\n recordToReport(\n title?: string,\n options?: MidsceneRecordToReportOptions,\n ): Promise<unknown>;\n /** Available on device Agents that support launching an app, URL, or URI. */\n launch?(uri: string): Promise<void>;\n}\n\nexport interface AgentProvider<TContext> {\n getAgent(\n runId: string,\n ctx: NodeExecutionContext<unknown, TContext>,\n ): Awaitable<MidsceneUIAgent>;\n // biome-ignore lint/suspicious/noConfusingVoidType: providers without a report intentionally return void.\n releaseAgent?(runId: string): Awaitable<AgentReleaseResult | void>;\n dispose?(): Awaitable<void>;\n}\n\nexport interface AgentReleaseResult {\n /** Absolute path to the finalized report for this Agent scope. */\n reportPath?: string;\n}\n\nexport interface AgentExecutorInput<TContext> {\n prompt: string;\n history: readonly NodeHistoryEntry[];\n context: TContext;\n signal: AbortSignal;\n execution:\n | { scope: 'case'; runId: string }\n | { scope: 'document'; runId: string };\n}\n\nexport interface AgentExecutor<TContext> {\n // biome-ignore lint/suspicious/noConfusingVoidType: executors may perform side effects without returning a summary.\n execute(input: AgentExecutorInput<TContext>): Awaitable<NodeResult | void>;\n}\n\nconst nonBlankPrompt = (description: string) =>\n z\n .string()\n .regex(/\\S/, 'prompt must contain a non-whitespace character')\n .describe(description);\n\nconst promptImagesInputSchema = z\n .array(\n z.strictObject({\n name: nonBlankPrompt('The name used to identify this reference image.'),\n url: nonBlankPrompt(\n 'The URL, data URL, or file path of this reference image.',\n ),\n }),\n )\n .min(1)\n .optional();\n\nconst promptImageConversionInputSchema = z\n .boolean()\n .optional()\n .describe('Whether HTTP reference images are converted to base64 first.');\n\nconst aiActOptionsInputSchema = z.strictObject({\n cacheable: z\n .boolean()\n .optional()\n .describe('Whether this action may use the Midscene cache.'),\n fileChooserAccept: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Accepted file types for a file chooser.'),\n deepThink: z\n .union([z.literal('unset'), z.boolean()])\n .optional()\n .describe('Whether to enable deep thinking for this action.'),\n deepLocate: z\n .boolean()\n .optional()\n .describe('Whether to use deep element location.'),\n context: z\n .string()\n .optional()\n .describe('Additional context supplied to the UI Agent.'),\n});\n\nexport const aiActInputSchema = z.strictObject({\n prompt: nonBlankPrompt('The natural-language UI task to perform.'),\n images: promptImagesInputSchema,\n convertHttpImage2Base64: promptImageConversionInputSchema,\n options: aiActOptionsInputSchema.optional(),\n});\n\nconst aiAssertOptionsInputSchema = z.strictObject({\n domIncluded: z\n .union([z.boolean(), z.literal('visible-only')])\n .optional()\n .describe('How DOM information is included in the assertion.'),\n screenshotIncluded: z\n .boolean()\n .optional()\n .describe('Whether the assertion includes a screenshot.'),\n context: z\n .string()\n .optional()\n .describe('Additional context supplied to the UI Agent.'),\n});\n\nexport const aiAssertInputSchema = z.strictObject({\n prompt: nonBlankPrompt('The natural-language condition that must be true.'),\n images: promptImagesInputSchema,\n convertHttpImage2Base64: promptImageConversionInputSchema,\n message: z.string().optional().describe('The assertion failure message.'),\n options: aiAssertOptionsInputSchema.optional(),\n});\n\nconst reportScreenshotInputSchema = z.strictObject({\n base64: z.string().min(1).describe('A base64-encoded screenshot.'),\n description: z.string().optional().describe('What the screenshot shows.'),\n});\n\nexport const recordToReportInputSchema = z\n .strictObject({\n prompt: z.string().optional().describe('String shorthand for the title.'),\n title: z.string().optional().describe('The report section title.'),\n content: z.string().optional().describe('The report text content.'),\n screenshotBase64: z\n .string()\n .optional()\n .describe('One base64-encoded screenshot.'),\n screenshots: z\n .array(reportScreenshotInputSchema)\n .min(1)\n .optional()\n .describe('Screenshots attached to the report section.'),\n })\n .superRefine((input, ctx) => {\n if (input.prompt !== undefined && input.title !== undefined) {\n ctx.addIssue({\n code: 'custom',\n message: 'prompt and title are mutually exclusive',\n });\n }\n if (\n input.screenshotBase64 !== undefined &&\n input.screenshots !== undefined\n ) {\n ctx.addIssue({\n code: 'custom',\n message: 'screenshotBase64 and screenshots are mutually exclusive',\n });\n }\n });\n\nexport const waitInputSchema = z.strictObject({\n duration: z.number().positive().describe('How long to wait.'),\n unit: z\n .enum(['ms', 's', 'min'])\n .default('ms')\n .describe('Duration unit: milliseconds, seconds, or minutes.'),\n});\n\nexport const agentInputSchema = z.strictObject({\n prompt: nonBlankPrompt(\n 'A self-contained task, including allowed tools and success conditions.',\n ),\n});\n\nexport type AiActNodeInput = z.infer<typeof aiActInputSchema>;\nexport type AiAssertNodeInput = z.infer<typeof aiAssertInputSchema>;\nexport type RecordToReportNodeInput = z.infer<typeof recordToReportInputSchema>;\nexport type WaitNodeInput = z.infer<typeof waitInputSchema>;\nexport type AgentNodeInput = z.infer<typeof agentInputSchema>;\n\nexport interface CreateMidsceneNodesOptions<TContext> {\n getAgent?(\n ctx: NodeExecutionContext<unknown, TContext>,\n ): Awaitable<MidsceneUIAgent>;\n agentProvider?: AgentProvider<TContext>;\n /** Disable when a project registers its own platform-specific launch Node. */\n includeLaunch?: boolean;\n agentExecutor?: AgentExecutor<TContext>;\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst requireAgentMethod = <TMethod extends keyof MidsceneUIAgent>(\n agent: MidsceneUIAgent,\n method: TMethod,\n node: string,\n): NonNullable<MidsceneUIAgent[TMethod]> => {\n if (!isRecord(agent) || typeof agent[method] !== 'function') {\n throw new NodeExecutionError(\n node,\n new TypeError(`getAgent() must return an Agent with ${method}().`),\n );\n }\n return agent[method] as NonNullable<MidsceneUIAgent[TMethod]>;\n};\n\nconst maxHistoryContextCharacters = 64_000;\nconst maxHistoryValuePreviewCharacters = 8_000;\nconst maxHistoryEntryCharacters = 24_000;\nconst historyOmissionNoticeReserve = 256;\n\nconst compactHistoryContextValue = (value: unknown): unknown => {\n const serialized = JSON.stringify(value);\n if (\n serialized === undefined ||\n serialized.length <= maxHistoryValuePreviewCharacters\n ) {\n return value;\n }\n return {\n omittedFromContext: true,\n originalCharacters: serialized.length,\n preview:\n typeof value === 'string'\n ? value.slice(0, maxHistoryValuePreviewCharacters)\n : serialized.slice(0, maxHistoryValuePreviewCharacters),\n };\n};\n\nconst serializeHistoryEntryForContext = (\n entry: NodeHistoryEntry,\n index: number,\n): string => {\n const compacted = Object.fromEntries(\n Object.entries({ index, ...entry }).map(([key, value]) => [\n key,\n compactHistoryContextValue(value),\n ]),\n );\n const serialized = JSON.stringify(compacted);\n if (serialized.length <= maxHistoryEntryCharacters) return serialized;\n\n return JSON.stringify({\n index,\n scope: entry.scope,\n phase: entry.phase,\n stepIndex: entry.stepIndex,\n node: entry.node,\n status: entry.status,\n ...(entry.summary === undefined\n ? {}\n : { summary: compactHistoryContextValue(entry.summary) }),\n omittedFromContext: true,\n compactedCharacters: serialized.length,\n });\n};\n\nexport const renderNodeHistory = (\n history: readonly NodeHistoryEntry[],\n): string | undefined => {\n if (history.length === 0) return undefined;\n\n const heading = 'Previous workflow results (read-only):';\n const availableCharacters =\n maxHistoryContextCharacters - heading.length - historyOmissionNoticeReserve;\n const renderedEntries: string[] = [];\n let renderedCharacters = 0;\n\n for (let index = history.length - 1; index >= 0; index -= 1) {\n const rendered = serializeHistoryEntryForContext(history[index], index + 1);\n const separatorCharacters = renderedEntries.length === 0 ? 0 : 1;\n if (\n renderedCharacters + separatorCharacters + rendered.length >\n availableCharacters\n ) {\n break;\n }\n renderedEntries.unshift(rendered);\n renderedCharacters += separatorCharacters + rendered.length;\n }\n\n const omittedEntries = history.length - renderedEntries.length;\n return [\n heading,\n ...(omittedEntries === 0\n ? []\n : [\n `${omittedEntries} earlier history entr${omittedEntries === 1 ? 'y was' : 'ies were'} omitted from Agent context to stay within the size limit. Complete results remain available in the Test Runner output.`,\n ]),\n ...renderedEntries,\n ].join('\\n');\n};\n\nconst mergeContext = (\n explicit: string | undefined,\n history: readonly NodeHistoryEntry[],\n): string | undefined =>\n [explicit, renderNodeHistory(history)].filter(Boolean).join('\\n\\n') ||\n undefined;\n\nconst toAgentPrompt = (input: {\n prompt: string;\n images?: MidscenePromptImage[];\n convertHttpImage2Base64?: boolean;\n}): MidsceneUserPrompt => {\n if (\n input.images === undefined &&\n input.convertHttpImage2Base64 === undefined\n ) {\n return input.prompt;\n }\n return {\n prompt: input.prompt,\n ...(input.images === undefined ? {} : { images: input.images }),\n ...(input.convertHttpImage2Base64 === undefined\n ? {}\n : { convertHttpImage2Base64: input.convertHttpImage2Base64 }),\n };\n};\n\nconst waitFor = async (durationMs: number, signal: AbortSignal) => {\n if (signal.aborted) {\n throw signal.reason ?? new Error('Wait aborted.');\n }\n await new Promise<void>((resolve, reject) => {\n const timeout = setTimeout(() => {\n signal.removeEventListener('abort', abort);\n resolve();\n }, durationMs);\n const abort = () => {\n clearTimeout(timeout);\n reject(signal.reason ?? new Error('Wait aborted.'));\n };\n signal.addEventListener('abort', abort, { once: true });\n });\n};\n\nexport function createMidsceneNodes<TContext>(\n options: CreateMidsceneNodesOptions<TContext>,\n): readonly NodeDefinition<any, any, TContext>[] {\n if (!options || typeof options !== 'object') {\n throw new NodeDefinitionError(\n 'createMidsceneNodes() options must be an object.',\n );\n }\n if (\n typeof options.agentProvider?.getAgent !== 'function' &&\n typeof options.getAgent !== 'function'\n ) {\n throw new NodeDefinitionError(\n 'createMidsceneNodes() requires getAgent or agentProvider.getAgent.',\n );\n }\n\n const registeredAgentScopes = new Set<string>();\n const getExecutionId = (ctx: NodeExecutionContext<unknown, TContext>) =>\n ctx.scope === 'case' ? ctx.case.runId : ctx.document.documentRunId;\n const getAgent = async (\n ctx: NodeExecutionContext<unknown, TContext>,\n ): Promise<MidsceneUIAgent> => {\n if (!options.agentProvider) return options.getAgent!(ctx);\n const runId = getExecutionId(ctx);\n if (\n options.agentProvider.releaseAgent &&\n !registeredAgentScopes.has(runId)\n ) {\n registeredAgentScopes.add(runId);\n ctx.onTeardown(async () => {\n try {\n const released = await options.agentProvider!.releaseAgent!(runId);\n return released?.reportPath\n ? { reportPaths: [released.reportPath] }\n : undefined;\n } finally {\n registeredAgentScopes.delete(runId);\n }\n });\n }\n return options.agentProvider.getAgent(runId, ctx);\n };\n\n return [\n defineNode<typeof aiActInputSchema, unknown, TContext>({\n name: 'aiAct',\n description: 'Perform a natural-language task with a Midscene UI Agent.',\n inputSchema: aiActInputSchema,\n async execute(ctx) {\n const agent = await getAgent(ctx);\n const aiAct = requireAgentMethod(agent, 'aiAct', 'aiAct');\n const output = await aiAct.call(agent, toAgentPrompt(ctx.input), {\n ...ctx.input.options,\n context: mergeContext(ctx.input.options?.context, ctx.history),\n abortSignal: ctx.signal,\n });\n return output === undefined ? undefined : { summary: output };\n },\n }),\n defineNode<typeof aiAssertInputSchema, unknown, TContext>({\n name: 'aiAssert',\n description:\n 'Assert a natural-language condition with a Midscene UI Agent.',\n inputSchema: aiAssertInputSchema,\n async execute(ctx) {\n const agent = await getAgent(ctx);\n const aiAssert = requireAgentMethod(agent, 'aiAssert', 'aiAssert');\n await aiAssert.call(\n agent,\n toAgentPrompt(ctx.input),\n ctx.input.message,\n {\n ...ctx.input.options,\n context: mergeContext(ctx.input.options?.context, ctx.history),\n abortSignal: ctx.signal,\n },\n );\n return { summary: `Assertion passed: ${ctx.input.prompt}` };\n },\n }),\n defineNode<typeof recordToReportInputSchema, unknown, TContext>({\n name: 'recordToReport',\n description: 'Add text or screenshots to the current Midscene report.',\n inputSchema: recordToReportInputSchema,\n async execute(ctx) {\n const title = ctx.input.title ?? ctx.input.prompt;\n const reportOptions: MidsceneRecordToReportOptions = {\n ...(ctx.input.content === undefined\n ? {}\n : { content: ctx.input.content }),\n ...(ctx.input.screenshotBase64 === undefined\n ? {}\n : { screenshotBase64: ctx.input.screenshotBase64 }),\n ...(ctx.input.screenshots === undefined\n ? {}\n : { screenshots: ctx.input.screenshots }),\n };\n const agent = await getAgent(ctx);\n const recordToReport = requireAgentMethod(\n agent,\n 'recordToReport',\n 'recordToReport',\n );\n await recordToReport.call(agent, title, reportOptions);\n return { summary: `Recorded to report: ${title ?? 'untitled'}` };\n },\n }),\n ...(options.includeLaunch === false ? [] : [createLaunchNode(getAgent)]),\n defineNode<typeof waitInputSchema, unknown, TContext>({\n name: 'wait',\n description: 'Wait for a fixed duration while honoring cancellation.',\n inputSchema: waitInputSchema,\n async execute(ctx) {\n const multiplier =\n ctx.input.unit === 'min'\n ? 60_000\n : ctx.input.unit === 's'\n ? 1_000\n : 1;\n const durationMs = ctx.input.duration * multiplier;\n await waitFor(durationMs, ctx.signal);\n return { summary: `Waited ${durationMs}ms` };\n },\n }),\n defineNode<typeof agentInputSchema, unknown, TContext>({\n name: 'agent',\n description:\n 'Execute one self-contained natural-language task with an injected Agent executor.',\n inputSchema: agentInputSchema,\n async execute(ctx) {\n if (!options.agentExecutor) {\n throw new NodeExecutionError(\n 'agent',\n new TypeError('createMidsceneNodes() requires an agentExecutor.'),\n );\n }\n const execution =\n ctx.scope === 'case'\n ? { scope: 'case' as const, runId: ctx.case.runId }\n : {\n scope: 'document' as const,\n runId: ctx.document.documentRunId,\n };\n const result = await options.agentExecutor.execute({\n prompt: ctx.input.prompt,\n history: ctx.history,\n context: ctx.context,\n signal: ctx.signal,\n execution,\n });\n return result ?? { summary: 'Agent task completed.' };\n },\n }),\n ];\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","WorkflowError","Error","undefined","message","options","NodeDefinitionError","details","NodeExecutionError","node","cause","causeMessage","String","validateOptionalText","value","field","validateInputSchema","schema","z","validateDefinition","defineNode","lifecycleInputSchema","operation","description","input","ctx","launchInputSchema","requireLifecycleMethod","agent","method","agentName","TypeError","createLaunchNode","getAgent","uri","launch","nonBlankPrompt","promptImagesInputSchema","promptImageConversionInputSchema","aiActOptionsInputSchema","aiActInputSchema","aiAssertOptionsInputSchema","aiAssertInputSchema","reportScreenshotInputSchema","recordToReportInputSchema","waitInputSchema","agentInputSchema","isRecord","Array","requireAgentMethod","maxHistoryContextCharacters","maxHistoryValuePreviewCharacters","maxHistoryEntryCharacters","historyOmissionNoticeReserve","compactHistoryContextValue","serialized","JSON","serializeHistoryEntryForContext","entry","index","compacted","renderNodeHistory","history","heading","availableCharacters","renderedEntries","renderedCharacters","rendered","separatorCharacters","omittedEntries","mergeContext","explicit","Boolean","toAgentPrompt","waitFor","durationMs","signal","Promise","resolve","reject","timeout","setTimeout","abort","clearTimeout","createMidsceneNodes","registeredAgentScopes","Set","getExecutionId","runId","released","aiAct","output","aiAssert","title","reportOptions","recordToReport","multiplier","execution","result"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,G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AASA,IAAI,OAAO;oBACpB,QAAQA,IAAI,MAAM;oBAClBwE;gBACF;gBACA,OAAOC,UAAU;oBAAE,SAAS;gBAAwB;YACtD;QACF;KACD;AACH"}
|
|
1
|
+
{"version":3,"file":"midscene/index.js","sources":["../../../src/errors.ts","webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/node/define-node.ts","../../../src/midscene/index.ts"],"sourcesContent":["import type { z } from 'zod/v4';\n\nexport interface WorkflowErrorOptions {\n code?: string;\n details?: unknown;\n cause?: unknown;\n}\n\nexport class WorkflowError extends Error {\n readonly code: string;\n readonly details?: unknown;\n\n constructor(message: string, options: WorkflowErrorOptions = {}) {\n super(message, { cause: options.cause });\n this.name = new.target.name;\n this.code = options.code ?? 'WORKFLOW_ERROR';\n this.details = options.details;\n }\n\n toJSON(): Record<string, unknown> {\n return {\n name: this.name,\n message: this.message,\n code: this.code,\n ...(this.details === undefined ? {} : { details: this.details }),\n };\n }\n}\n\nexport class WorkflowParseError extends WorkflowError {\n constructor(message: string, details?: unknown, cause?: unknown) {\n super(message, { code: 'WORKFLOW_PARSE_ERROR', details, cause });\n }\n}\n\nexport class NodeDefinitionError extends WorkflowError {\n constructor(message: string, details?: unknown) {\n super(message, { code: 'NODE_DEFINITION_ERROR', details });\n }\n}\n\nexport class DuplicateNodeError extends WorkflowError {\n readonly node: string;\n\n constructor(node: string) {\n super(`Node \"${node}\" is already registered.`, {\n code: 'DUPLICATE_NODE',\n details: { node },\n });\n this.node = node;\n }\n}\n\nexport class NodeNotFoundError extends WorkflowError {\n readonly node: string;\n\n constructor(node: string) {\n super(`Node \"${node}\" is not registered.`, {\n code: 'NODE_NOT_FOUND',\n details: { node },\n });\n this.node = node;\n }\n}\n\nexport class NodeInputValidationError extends WorkflowError {\n constructor(message: string, details?: unknown) {\n super(message, { code: 'NODE_INPUT_VALIDATION_ERROR', details });\n }\n\n static fromZod(node: string, error: z.ZodError): NodeInputValidationError {\n const issues = error.issues.map((issue) => ({\n code: issue.code,\n path: issue.path.map(String).join('.'),\n message: issue.message,\n }));\n const firstIssue = issues[0];\n const path = firstIssue?.path || '<root>';\n const message = firstIssue?.message ?? 'invalid input';\n return new NodeInputValidationError(\n `Node \"${node}\" input validation failed at \"${path}\": ${message}`,\n { node, issues },\n );\n }\n}\n\nexport class StepTimeoutError extends WorkflowError {\n readonly timeoutMs: number;\n readonly node?: string;\n\n constructor(timeoutMs: number, node?: string) {\n super(\n node\n ? `Node \"${node}\" timed out after ${timeoutMs}ms.`\n : `Step timed out after ${timeoutMs}ms.`,\n {\n code: 'STEP_TIMEOUT',\n details: { timeoutMs, ...(node === undefined ? {} : { node }) },\n },\n );\n this.timeoutMs = timeoutMs;\n this.node = node;\n }\n}\n\nexport class NodeExecutionError extends WorkflowError {\n readonly node: string;\n\n constructor(node: string, cause: unknown) {\n const causeMessage =\n cause instanceof Error ? cause.message : String(cause ?? 'Unknown error');\n super(`Node \"${node}\" failed: ${causeMessage}`, {\n code: 'NODE_EXECUTION_ERROR',\n details: { node },\n cause,\n });\n this.node = node;\n }\n}\n\nexport class WorkflowLifecycleError extends WorkflowError {\n constructor(message: string, details?: unknown) {\n super(message, { code: 'WORKFLOW_LIFECYCLE_ERROR', details });\n }\n}\n\nexport class ProjectSetupError extends WorkflowError {\n constructor(cause: unknown, details: { projectName: string }) {\n const causeMessage =\n cause instanceof Error ? cause.message : String(cause ?? 'Unknown error');\n super(`Project \"${details.projectName}\" setup failed: ${causeMessage}`, {\n code: 'PROJECT_SETUP_ERROR',\n details,\n cause,\n });\n }\n}\n\nexport class ProjectTeardownError extends WorkflowError {\n constructor(\n cause: unknown,\n details: { projectName: string; registrationIndex: number },\n ) {\n const causeMessage =\n cause instanceof Error ? cause.message : String(cause ?? 'Unknown error');\n super(`Project \"${details.projectName}\" teardown failed: ${causeMessage}`, {\n code: 'PROJECT_TEARDOWN_ERROR',\n details,\n cause,\n });\n }\n}\n\nexport class NodeScopeTeardownError extends WorkflowError {\n constructor(\n cause: unknown,\n details: {\n scope: 'case' | 'document';\n scopeId: string;\n node: string;\n registrationIndex: number;\n },\n ) {\n const causeMessage =\n cause instanceof Error ? cause.message : String(cause ?? 'Unknown error');\n super(\n `${details.scope === 'case' ? 'Case attempt' : 'Workflow document'} node teardown failed for \"${details.node}\": ${causeMessage}`,\n { code: 'NODE_SCOPE_TEARDOWN_ERROR', details, cause },\n );\n }\n}\n\nexport class FatalDeviceError extends WorkflowError {\n constructor(message: string, cause?: unknown) {\n super(message, { code: 'FATAL_DEVICE_ERROR', cause });\n }\n}\n\nexport const isFatalDeviceError = (error: unknown): boolean => {\n if (error instanceof FatalDeviceError) return true;\n if (error instanceof WorkflowError && error.code === 'FATAL_DEVICE_ERROR') {\n return true;\n }\n if (\n error instanceof Error &&\n /device offline|device not found|(?:adb|bdc|device) connection (?:was )?closed/i.test(\n error.message,\n )\n ) {\n return true;\n }\n return error instanceof Error && error.cause !== undefined\n ? isFatalDeviceError(error.cause)\n : false;\n};\n\nexport class CaseExecutionError extends WorkflowError {\n readonly result: import('./engine/types').CaseRunResult;\n\n constructor(result: import('./engine/types').CaseRunResult) {\n super(`Case \"${result.name}\" failed.`, {\n code: 'CASE_EXECUTION_FAILED',\n details: { caseId: result.caseId, runId: result.runId },\n });\n this.result = result;\n }\n}\n\nexport class WorkflowDocumentExecutionError extends WorkflowError {\n readonly result: import('./engine/types').WorkflowDocumentRunResult;\n\n constructor(result: import('./engine/types').WorkflowDocumentRunResult) {\n super(`Workflow document \"${result.sourcePath}\" failed.`, {\n code: 'WORKFLOW_DOCUMENT_EXECUTION_FAILED',\n details: {\n documentId: result.documentId,\n documentRunId: result.documentRunId,\n },\n });\n this.result = result;\n }\n}\n\nexport function normalizeNodeExecutionError(\n error: unknown,\n node: string,\n): WorkflowError {\n return error instanceof WorkflowError\n ? error\n : new NodeExecutionError(node, error);\n}\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { z } from 'zod/v4';\nimport { NodeDefinitionError } from '../errors';\nimport type {\n DefineNodeOptions,\n DefineNodeWithSchemaOptions,\n NodeDefinition,\n NodeDefinitionWithSchema,\n NodeInputSchema,\n} from './types';\n\nconst validateOptionalText = (\n value: unknown,\n field: 'title' | 'description',\n node: string,\n): void => {\n if (\n value !== undefined &&\n (typeof value !== 'string' || value.trim().length === 0)\n ) {\n throw new NodeDefinitionError(\n `Node \"${node}\" ${field} must be a non-empty string.`,\n { node, field },\n );\n }\n};\n\nconst validateInputSchema = (schema: unknown, node: string): void => {\n if (schema === undefined) return;\n if (!(schema instanceof z.ZodObject)) {\n throw new NodeDefinitionError(\n `Node \"${node}\" inputSchema must be a Zod object schema.`,\n { node, field: 'inputSchema' },\n );\n }\n if ('$' in schema.shape) {\n throw new NodeDefinitionError(\n `Node \"${node}\" inputSchema must not declare \"$\" as an input property.`,\n { node, field: 'inputSchema.$' },\n );\n }\n};\n\nconst validateDefinition = (options: {\n name: string;\n title?: unknown;\n description?: unknown;\n stringInputKey?: unknown;\n inputSchema?: unknown;\n execute: unknown;\n}): void => {\n if (!options || typeof options !== 'object') {\n throw new NodeDefinitionError('Node definition must be an object.');\n }\n\n if (typeof options.name !== 'string' || options.name.trim().length === 0) {\n throw new NodeDefinitionError('Node name must be a non-empty string.');\n }\n\n validateOptionalText(options.title, 'title', options.name);\n validateOptionalText(options.description, 'description', options.name);\n if (\n options.stringInputKey !== undefined &&\n options.stringInputKey !== false &&\n (typeof options.stringInputKey !== 'string' ||\n options.stringInputKey.trim().length === 0)\n ) {\n throw new NodeDefinitionError(\n `Node \"${options.name}\" stringInputKey must be a non-empty string or false.`,\n { node: options.name, field: 'stringInputKey' },\n );\n }\n validateInputSchema(options.inputSchema, options.name);\n\n if (\n typeof options.stringInputKey === 'string' &&\n options.inputSchema instanceof z.ZodObject &&\n !(options.stringInputKey in options.inputSchema.shape)\n ) {\n throw new NodeDefinitionError(\n `Node \"${options.name}\" stringInputKey must reference a field in inputSchema.`,\n { node: options.name, field: 'stringInputKey' },\n );\n }\n\n if (typeof options.execute !== 'function') {\n throw new NodeDefinitionError(\n `Node \"${options.name}\" must provide an execute function.`,\n { node: options.name },\n );\n }\n};\n\nexport function defineNode<\n TSchema extends NodeInputSchema,\n TData = unknown,\n TContext = unknown,\n>(\n options: DefineNodeWithSchemaOptions<TSchema, TData, TContext>,\n): NodeDefinitionWithSchema<TSchema, TData, TContext>;\n\nexport function defineNode<\n TInput = unknown,\n TData = unknown,\n TContext = unknown,\n>(\n options: DefineNodeOptions<TInput, TData, TContext>,\n): NodeDefinition<TInput, TData, TContext>;\n\nexport function defineNode(\n options: DefineNodeOptions<any, any, any>,\n): NodeDefinition<any, any, any> {\n validateDefinition(options);\n return options;\n}\n","import {\n type AgentTestRunnerNodeDefinition,\n type AgentTestRunnerNodeProvider,\n type CommonAgentTestRunnerApi,\n aiActInputSchema,\n aiActOptionsInputSchema,\n aiAssertInputSchema,\n aiAssertOptionsInputSchema,\n aiTapInputSchema,\n insightInputSchema,\n insightOptionsInputSchema,\n locateOptionsInputSchema,\n promptImageInputSchema,\n recordToReportInputSchema,\n recordToReportOptionsInputSchema,\n reportScreenshotInputSchema,\n structuredUserPromptInputSchema,\n userPromptInputSchema,\n} from '@midscene/core/agent/test-runner';\nimport { z } from 'zod/v4';\nimport type { Awaitable } from '../engine/types';\nimport { NodeDefinitionError, NodeExecutionError } from '../errors';\nimport { defineNode } from '../node/define-node';\nimport type {\n NodeDefinition,\n NodeExecutionContext,\n NodeResult,\n} from '../node/types';\n\nexport type MidsceneUIAgent = CommonAgentTestRunnerApi;\n\nexport {\n aiActInputSchema,\n aiActOptionsInputSchema,\n aiAssertInputSchema,\n aiAssertOptionsInputSchema,\n aiTapInputSchema,\n insightInputSchema,\n insightOptionsInputSchema,\n locateOptionsInputSchema,\n promptImageInputSchema,\n recordToReportInputSchema,\n recordToReportOptionsInputSchema,\n reportScreenshotInputSchema,\n structuredUserPromptInputSchema,\n userPromptInputSchema,\n};\n\nexport interface AgentProvider<TContext> {\n getAgent(\n runId: string,\n ctx: NodeExecutionContext<unknown, TContext>,\n ): Awaitable<MidsceneUIAgent>;\n // biome-ignore lint/suspicious/noConfusingVoidType: providers without a report intentionally return void.\n releaseAgent?(runId: string): Awaitable<AgentReleaseResult | void>;\n dispose?(): Awaitable<void>;\n}\n\nexport interface AgentReleaseResult {\n /** Absolute path to the finalized report for this Agent scope. */\n reportPath?: string;\n}\n\nexport interface AgentExecutorInput<TContext> {\n prompt: string;\n context: TContext;\n signal: AbortSignal;\n execution:\n | { scope: 'case'; runId: string }\n | { scope: 'document'; runId: string };\n}\n\nexport interface AgentExecutor<TContext> {\n // biome-ignore lint/suspicious/noConfusingVoidType: executors may perform side effects without returning a summary.\n execute(input: AgentExecutorInput<TContext>): Awaitable<NodeResult | void>;\n}\n\nconst nonBlankPrompt = (description: string) =>\n z\n .string()\n .regex(/\\S/, 'prompt must contain a non-whitespace character')\n .describe(description);\n\nexport const waitInputSchema = z.strictObject({\n duration: z.number().positive().describe('How long to wait.'),\n unit: z\n .enum(['ms', 's', 'min'])\n .default('ms')\n .describe('Duration unit: milliseconds, seconds, or minutes.'),\n});\n\nexport const agentInputSchema = z.strictObject({\n prompt: nonBlankPrompt(\n 'A self-contained task, including allowed tools and success conditions.',\n ),\n});\n\nexport type AiActNodeInput = z.infer<typeof aiActInputSchema>;\nexport type AiAssertNodeInput = z.infer<typeof aiAssertInputSchema>;\nexport type AiTapNodeInput = z.infer<typeof aiTapInputSchema>;\nexport type InsightNodeInput = z.infer<typeof insightInputSchema>;\nexport type RecordToReportNodeInput = z.infer<typeof recordToReportInputSchema>;\nexport type WaitNodeInput = z.infer<typeof waitInputSchema>;\nexport type AgentNodeInput = z.infer<typeof agentInputSchema>;\n\nexport interface CreateMidsceneNodesOptions<TContext> {\n getAgent?(\n ctx: NodeExecutionContext<unknown, TContext>,\n ): Awaitable<MidsceneUIAgent>;\n agentProvider?: AgentProvider<TContext>;\n /** Agent class that declares the Agent-backed Nodes to register. */\n agentClass: AgentTestRunnerNodeProvider;\n agentExecutor?: AgentExecutor<TContext>;\n}\n\nconst waitFor = async (durationMs: number, signal: AbortSignal) => {\n if (signal.aborted) {\n throw signal.reason ?? new Error('Wait aborted.');\n }\n await new Promise<void>((resolve, reject) => {\n const timeout = setTimeout(() => {\n signal.removeEventListener('abort', abort);\n resolve();\n }, durationMs);\n const abort = () => {\n clearTimeout(timeout);\n reject(signal.reason ?? new Error('Wait aborted.'));\n };\n signal.addEventListener('abort', abort, { once: true });\n });\n};\n\n/** Adapt Agent-owned descriptions to executable Test Runner Nodes. */\nexport const createAgentTestRunnerNodes = <TContext>(\n definitions: readonly AgentTestRunnerNodeDefinition[],\n getAgent: (\n ctx: NodeExecutionContext<unknown, TContext>,\n ) => Awaitable<unknown>,\n): readonly NodeDefinition<any, any, TContext>[] =>\n definitions.map((definition) =>\n defineNode({\n name: definition.name,\n ...(definition.title === undefined ? {} : { title: definition.title }),\n ...(definition.description === undefined\n ? {}\n : { description: definition.description }),\n ...(definition.stringInputKey === undefined\n ? {}\n : { stringInputKey: definition.stringInputKey }),\n inputSchema: definition.inputSchema,\n async execute(ctx) {\n const agent = await getAgent(ctx);\n return definition.execute(agent, ctx.input, {\n signal: ctx.signal,\n });\n },\n }),\n );\n\nexport function createMidsceneNodes<TContext>(\n options: CreateMidsceneNodesOptions<TContext>,\n): readonly NodeDefinition<any, any, TContext>[] {\n if (!options || typeof options !== 'object') {\n throw new NodeDefinitionError(\n 'createMidsceneNodes() options must be an object.',\n );\n }\n if (\n typeof options.agentProvider?.getAgent !== 'function' &&\n typeof options.getAgent !== 'function'\n ) {\n throw new NodeDefinitionError(\n 'createMidsceneNodes() requires getAgent or agentProvider.getAgent.',\n );\n }\n if (\n !options.agentClass ||\n typeof options.agentClass.getTestRunnerNodeDefinitions !== 'function'\n ) {\n throw new NodeDefinitionError(\n 'createMidsceneNodes() requires agentClass.getTestRunnerNodeDefinitions().',\n );\n }\n\n const registeredAgentScopes = new Set<string>();\n const getExecutionId = (ctx: NodeExecutionContext<unknown, TContext>) =>\n ctx.scope === 'case' ? ctx.case.runId : ctx.document.documentRunId;\n const getAgent = async (\n ctx: NodeExecutionContext<unknown, TContext>,\n ): Promise<MidsceneUIAgent> => {\n if (!options.agentProvider) return options.getAgent!(ctx);\n const runId = getExecutionId(ctx);\n if (\n options.agentProvider.releaseAgent &&\n !registeredAgentScopes.has(runId)\n ) {\n registeredAgentScopes.add(runId);\n ctx.onTeardown(async () => {\n try {\n const released = await options.agentProvider!.releaseAgent!(runId);\n return released?.reportPath\n ? { reportPaths: [released.reportPath] }\n : undefined;\n } finally {\n registeredAgentScopes.delete(runId);\n }\n });\n }\n return options.agentProvider.getAgent(runId, ctx);\n };\n\n const agentDefinitions = options.agentClass.getTestRunnerNodeDefinitions();\n\n return [\n ...createAgentTestRunnerNodes(agentDefinitions, getAgent),\n defineNode<typeof waitInputSchema, unknown, TContext>({\n name: 'wait',\n description: 'Wait for a fixed duration while honoring cancellation.',\n stringInputKey: false,\n inputSchema: waitInputSchema,\n async execute(ctx) {\n const multiplier =\n ctx.input.unit === 'min'\n ? 60_000\n : ctx.input.unit === 's'\n ? 1_000\n : 1;\n const durationMs = ctx.input.duration * multiplier;\n await waitFor(durationMs, ctx.signal);\n return { summary: `Waited ${durationMs}ms` };\n },\n }),\n defineNode<typeof agentInputSchema, unknown, TContext>({\n name: 'agent',\n description:\n 'Execute one self-contained natural-language task with an injected Agent executor.',\n stringInputKey: 'prompt',\n inputSchema: agentInputSchema,\n async execute(ctx) {\n if (!options.agentExecutor) {\n throw new NodeExecutionError(\n 'agent',\n new TypeError('createMidsceneNodes() requires an agentExecutor.'),\n );\n }\n const execution =\n ctx.scope === 'case'\n ? { scope: 'case' as const, runId: ctx.case.runId }\n : {\n scope: 'document' as const,\n runId: ctx.document.documentRunId,\n };\n const result = await options.agentExecutor.execute({\n prompt: ctx.input.prompt,\n context: ctx.context,\n signal: ctx.signal,\n execution,\n });\n return result ?? { summary: 'Agent task completed.' };\n },\n }),\n ];\n}\n"],"names":["WorkflowError","Error","undefined","message","options","NodeDefinitionError","details","NodeExecutionError","node","cause","causeMessage","String","__webpack_require__","definition","key","Object","obj","prop","Symbol","validateOptionalText","value","field","validateInputSchema","schema","z","validateDefinition","defineNode","nonBlankPrompt","description","waitInputSchema","agentInputSchema","waitFor","durationMs","signal","Promise","resolve","reject","timeout","setTimeout","abort","clearTimeout","createAgentTestRunnerNodes","definitions","getAgent","ctx","agent","createMidsceneNodes","registeredAgentScopes","Set","getExecutionId","runId","released","agentDefinitions","multiplier","TypeError","execution","result"],"mappings":";;;;;;;;;;;;;;;;;QAQO,MAAMA,sBAAsBC;YAWjC,SAAkC;gBAChC,OAAO;oBACL,MAAM,IAAI,CAAC,IAAI;oBACf,SAAS,IAAI,CAAC,OAAO;oBACrB,MAAM,IAAI,CAAC,IAAI;oBACf,GAAI,AAAiBC,WAAjB,IAAI,CAAC,OAAO,GAAiB,CAAC,IAAI;wBAAE,SAAS,IAAI,CAAC,OAAO;oBAAC,CAAC;gBACjE;YACF;YAdA,YAAYC,OAAe,EAAEC,UAAgC,CAAC,CAAC,CAAE;gBAC/D,KAAK,CAACD,SAAS;oBAAE,OAAOC,QAAQ,KAAK;gBAAC,IAJxC,uBAAS,QAAT,SACA,uBAAS,WAAT;gBAIE,IAAI,CAAC,IAAI,GAAG,WAAW,IAAI;gBAC3B,IAAI,CAAC,IAAI,GAAGA,QAAQ,IAAI,IAAI;gBAC5B,IAAI,CAAC,OAAO,GAAGA,QAAQ,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ACN,aACE;gBACF,gBAAgB;gBAChB,aAAaI;gBACb,MAAM,SAAQc,GAAG;oBACf,IAAI,CAACxC,QAAQ,aAAa,EACxB,MAAM,IAAIG,OAAAA,EAAkBA,CAC1B,SACA,IAAI+C,UAAU;oBAGlB,MAAMC,YACJX,AAAc,WAAdA,IAAI,KAAK,GACL;wBAAE,OAAO;wBAAiB,OAAOA,IAAI,IAAI,CAAC,KAAK;oBAAC,IAChD;wBACE,OAAO;wBACP,OAAOA,IAAI,QAAQ,CAAC,aAAa;oBACnC;oBACN,MAAMY,SAAS,MAAMpD,QAAQ,aAAa,CAAC,OAAO,CAAC;wBACjD,QAAQwC,IAAI,KAAK,CAAC,MAAM;wBACxB,SAASA,IAAI,OAAO;wBACpB,QAAQA,IAAI,MAAM;wBAClBW;oBACF;oBACA,OAAOC,UAAU;wBAAE,SAAS;oBAAwB;gBACtD;YACF;SACD;IACH"}
|
|
@@ -91,7 +91,15 @@ const validateDefinition = (options)=>{
|
|
|
91
91
|
if ('string' != typeof options.name || 0 === options.name.trim().length) throw new NodeDefinitionError('Node name must be a non-empty string.');
|
|
92
92
|
validateOptionalText(options.title, 'title', options.name);
|
|
93
93
|
validateOptionalText(options.description, "description", options.name);
|
|
94
|
+
if (void 0 !== options.stringInputKey && false !== options.stringInputKey && ('string' != typeof options.stringInputKey || 0 === options.stringInputKey.trim().length)) throw new NodeDefinitionError(`Node "${options.name}" stringInputKey must be a non-empty string or false.`, {
|
|
95
|
+
node: options.name,
|
|
96
|
+
field: 'stringInputKey'
|
|
97
|
+
});
|
|
94
98
|
validateInputSchema(options.inputSchema, options.name);
|
|
99
|
+
if ('string' == typeof options.stringInputKey && options.inputSchema instanceof v4_namespaceObject.z.ZodObject && !(options.stringInputKey in options.inputSchema.shape)) throw new NodeDefinitionError(`Node "${options.name}" stringInputKey must reference a field in inputSchema.`, {
|
|
100
|
+
node: options.name,
|
|
101
|
+
field: 'stringInputKey'
|
|
102
|
+
});
|
|
95
103
|
if ('function' != typeof options.execute) throw new NodeDefinitionError(`Node "${options.name}" must provide an execute function.`, {
|
|
96
104
|
node: options.name
|
|
97
105
|
});
|
|
@@ -130,6 +138,7 @@ const createClearCookiesNode = (options)=>defineNode({
|
|
|
130
138
|
name: 'clearCookies',
|
|
131
139
|
title: 'Clear browser cookies',
|
|
132
140
|
description: 'Clear all cookies from the current Playwright BrowserContext, or only cookies matching name, domain, or path.',
|
|
141
|
+
stringInputKey: false,
|
|
133
142
|
inputSchema: clearCookiesInputSchema,
|
|
134
143
|
async execute (ctx) {
|
|
135
144
|
throwIfAborted(ctx.signal, 'clearCookies');
|
|
@@ -281,6 +290,7 @@ const createSetCookiesNode = (options)=>defineNode({
|
|
|
281
290
|
name: 'setCookies',
|
|
282
291
|
title: 'Set browser cookies',
|
|
283
292
|
description: 'Load cookies from an environment variable, configured profile, or Playwright storage-state file without persisting cookie values in workflow input or output.',
|
|
293
|
+
stringInputKey: false,
|
|
284
294
|
inputSchema: setCookiesInputSchema,
|
|
285
295
|
async execute (ctx) {
|
|
286
296
|
throwIfAborted(ctx.signal, 'setCookies');
|
|
@@ -309,8 +319,7 @@ const createSetCookiesNode = (options)=>defineNode({
|
|
|
309
319
|
const DEFAULT_NAVIGATION_TIMEOUT_MS = 60000;
|
|
310
320
|
const DEFAULT_WAIT_UNTIL = 'domcontentloaded';
|
|
311
321
|
const gotoUrlInputSchema = v4_namespaceObject.z.strictObject({
|
|
312
|
-
|
|
313
|
-
url: v4_namespaceObject.z.string().min(1).optional().describe('An absolute HTTP(S) URL or a path relative to baseUrl.'),
|
|
322
|
+
url: v4_namespaceObject.z.string().min(1).describe('An absolute HTTP(S) URL or a path relative to baseUrl.'),
|
|
314
323
|
waitUntil: v4_namespaceObject.z["enum"]([
|
|
315
324
|
'commit',
|
|
316
325
|
'domcontentloaded',
|
|
@@ -318,24 +327,18 @@ const gotoUrlInputSchema = v4_namespaceObject.z.strictObject({
|
|
|
318
327
|
'networkidle'
|
|
319
328
|
]).default(DEFAULT_WAIT_UNTIL).describe('The Playwright navigation lifecycle event to wait for.'),
|
|
320
329
|
timeoutMs: v4_namespaceObject.z.number().positive().default(DEFAULT_NAVIGATION_TIMEOUT_MS).describe('The navigation timeout in milliseconds.')
|
|
321
|
-
}).superRefine((input, ctx)=>{
|
|
322
|
-
if (void 0 === input.prompt === (void 0 === input.url)) ctx.addIssue({
|
|
323
|
-
code: 'custom',
|
|
324
|
-
message: 'exactly one of prompt and url is required'
|
|
325
|
-
});
|
|
326
330
|
});
|
|
327
331
|
const createGotoUrlNode = (options)=>defineNode({
|
|
328
332
|
name: 'gotoUrl',
|
|
329
333
|
title: 'Open a Web URL',
|
|
330
334
|
description: 'Navigate the current Playwright Page to an absolute HTTP(S) URL or a path relative to the configured baseUrl.',
|
|
335
|
+
stringInputKey: 'url',
|
|
331
336
|
inputSchema: gotoUrlInputSchema,
|
|
332
337
|
async execute (ctx) {
|
|
333
338
|
throwIfAborted(ctx.signal, 'gotoUrl');
|
|
334
339
|
const page = await options.getPage(ctx);
|
|
335
340
|
const baseUrl = await options.getBaseUrl?.(ctx);
|
|
336
|
-
const
|
|
337
|
-
if (void 0 === target) throw new TypeError('gotoUrl requires a URL.');
|
|
338
|
-
const url = resolveWebUrl(target, baseUrl, 'gotoUrl.url');
|
|
341
|
+
const url = resolveWebUrl(ctx.input.url, baseUrl, 'gotoUrl.url');
|
|
339
342
|
const response = await page.goto(url, {
|
|
340
343
|
waitUntil: ctx.input.waitUntil,
|
|
341
344
|
timeout: ctx.input.timeoutMs
|
|
@@ -360,6 +363,7 @@ const createSetViewportSizeNode = (options)=>defineNode({
|
|
|
360
363
|
name: 'setViewportSize',
|
|
361
364
|
title: 'Set the browser viewport size',
|
|
362
365
|
description: 'Set the current Playwright Page viewport size in CSS pixels and return the effective size.',
|
|
366
|
+
stringInputKey: false,
|
|
363
367
|
inputSchema: setViewportSizeInputSchema,
|
|
364
368
|
async execute (ctx) {
|
|
365
369
|
throwIfAborted(ctx.signal, 'setViewportSize');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playwright/index.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/errors.ts","../../../src/node/define-node.ts","../../../src/playwright/utils.ts","../../../src/playwright/clear-cookies.ts","../../../src/playwright/cookies.ts","../../../src/playwright/goto-url.ts","../../../src/playwright/viewport.ts","../../../src/playwright/index.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { z } from 'zod/v4';\n\nexport interface WorkflowErrorOptions {\n code?: string;\n details?: unknown;\n cause?: unknown;\n}\n\nexport class WorkflowError extends Error {\n readonly code: string;\n readonly details?: unknown;\n\n constructor(message: string, options: WorkflowErrorOptions = {}) {\n super(message, { cause: options.cause });\n this.name = new.target.name;\n this.code = options.code ?? 'WORKFLOW_ERROR';\n this.details = options.details;\n }\n\n toJSON(): Record<string, unknown> {\n return {\n name: this.name,\n message: this.message,\n code: this.code,\n ...(this.details === undefined ? {} : { details: this.details }),\n };\n }\n}\n\nexport class WorkflowParseError extends WorkflowError {\n constructor(message: string, details?: unknown, cause?: unknown) {\n super(message, { code: 'WORKFLOW_PARSE_ERROR', details, cause });\n }\n}\n\nexport class NodeDefinitionError extends WorkflowError {\n constructor(message: string, details?: unknown) {\n super(message, { code: 'NODE_DEFINITION_ERROR', details });\n }\n}\n\nexport class DuplicateNodeError extends WorkflowError {\n readonly node: string;\n\n constructor(node: string) {\n super(`Node \"${node}\" is already registered.`, {\n code: 'DUPLICATE_NODE',\n details: { node },\n });\n this.node = node;\n }\n}\n\nexport class NodeNotFoundError extends WorkflowError {\n readonly node: string;\n\n constructor(node: string) {\n super(`Node \"${node}\" is not registered.`, {\n code: 'NODE_NOT_FOUND',\n details: { node },\n });\n this.node = node;\n }\n}\n\nexport class NodeInputValidationError extends WorkflowError {\n constructor(message: string, details?: unknown) {\n super(message, { code: 'NODE_INPUT_VALIDATION_ERROR', details });\n }\n\n static fromZod(node: string, error: z.ZodError): NodeInputValidationError {\n const issues = error.issues.map((issue) => ({\n code: issue.code,\n path: issue.path.map(String).join('.'),\n message: issue.message,\n }));\n const firstIssue = issues[0];\n const path = firstIssue?.path || '<root>';\n const message = firstIssue?.message ?? 'invalid input';\n return new NodeInputValidationError(\n `Node \"${node}\" input validation failed at \"${path}\": ${message}`,\n { node, issues },\n );\n }\n}\n\nexport class StepTimeoutError extends WorkflowError {\n readonly timeoutMs: number;\n readonly node?: string;\n\n constructor(timeoutMs: number, node?: string) {\n super(\n node\n ? `Node \"${node}\" timed out after ${timeoutMs}ms.`\n : `Step timed out after ${timeoutMs}ms.`,\n {\n code: 'STEP_TIMEOUT',\n details: { timeoutMs, ...(node === undefined ? {} : { node }) },\n },\n );\n this.timeoutMs = timeoutMs;\n this.node = node;\n }\n}\n\nexport class NodeExecutionError extends WorkflowError {\n readonly node: string;\n\n constructor(node: string, cause: unknown) {\n const causeMessage =\n cause instanceof Error ? cause.message : String(cause ?? 'Unknown error');\n super(`Node \"${node}\" failed: ${causeMessage}`, {\n code: 'NODE_EXECUTION_ERROR',\n details: { node },\n cause,\n });\n this.node = node;\n }\n}\n\nexport class WorkflowLifecycleError extends WorkflowError {\n constructor(message: string, details?: unknown) {\n super(message, { code: 'WORKFLOW_LIFECYCLE_ERROR', details });\n }\n}\n\nexport class ProjectSetupError extends WorkflowError {\n constructor(cause: unknown, details: { projectName: string }) {\n const causeMessage =\n cause instanceof Error ? cause.message : String(cause ?? 'Unknown error');\n super(`Project \"${details.projectName}\" setup failed: ${causeMessage}`, {\n code: 'PROJECT_SETUP_ERROR',\n details,\n cause,\n });\n }\n}\n\nexport class ProjectTeardownError extends WorkflowError {\n constructor(\n cause: unknown,\n details: { projectName: string; registrationIndex: number },\n ) {\n const causeMessage =\n cause instanceof Error ? cause.message : String(cause ?? 'Unknown error');\n super(`Project \"${details.projectName}\" teardown failed: ${causeMessage}`, {\n code: 'PROJECT_TEARDOWN_ERROR',\n details,\n cause,\n });\n }\n}\n\nexport class NodeScopeTeardownError extends WorkflowError {\n constructor(\n cause: unknown,\n details: {\n scope: 'case' | 'document';\n scopeId: string;\n node: string;\n registrationIndex: number;\n },\n ) {\n const causeMessage =\n cause instanceof Error ? cause.message : String(cause ?? 'Unknown error');\n super(\n `${details.scope === 'case' ? 'Case attempt' : 'Workflow document'} node teardown failed for \"${details.node}\": ${causeMessage}`,\n { code: 'NODE_SCOPE_TEARDOWN_ERROR', details, cause },\n );\n }\n}\n\nexport class FatalDeviceError extends WorkflowError {\n constructor(message: string, cause?: unknown) {\n super(message, { code: 'FATAL_DEVICE_ERROR', cause });\n }\n}\n\nexport const isFatalDeviceError = (error: unknown): boolean => {\n if (error instanceof FatalDeviceError) return true;\n if (error instanceof WorkflowError && error.code === 'FATAL_DEVICE_ERROR') {\n return true;\n }\n if (\n error instanceof Error &&\n /device offline|device not found|(?:adb|bdc|device) connection (?:was )?closed/i.test(\n error.message,\n )\n ) {\n return true;\n }\n return error instanceof Error && error.cause !== undefined\n ? isFatalDeviceError(error.cause)\n : false;\n};\n\nexport class CaseExecutionError extends WorkflowError {\n readonly result: import('./engine/types').CaseRunResult;\n\n constructor(result: import('./engine/types').CaseRunResult) {\n super(`Case \"${result.name}\" failed.`, {\n code: 'CASE_EXECUTION_FAILED',\n details: { caseId: result.caseId, runId: result.runId },\n });\n this.result = result;\n }\n}\n\nexport class WorkflowDocumentExecutionError extends WorkflowError {\n readonly result: import('./engine/types').WorkflowDocumentRunResult;\n\n constructor(result: import('./engine/types').WorkflowDocumentRunResult) {\n super(`Workflow document \"${result.sourcePath}\" failed.`, {\n code: 'WORKFLOW_DOCUMENT_EXECUTION_FAILED',\n details: {\n documentId: result.documentId,\n documentRunId: result.documentRunId,\n },\n });\n this.result = result;\n }\n}\n\nexport function normalizeNodeExecutionError(\n error: unknown,\n node: string,\n): WorkflowError {\n return error instanceof WorkflowError\n ? error\n : new NodeExecutionError(node, error);\n}\n","import { z } from 'zod/v4';\nimport { NodeDefinitionError } from '../errors';\nimport type {\n DefineNodeOptions,\n DefineNodeWithSchemaOptions,\n NodeDefinition,\n NodeDefinitionWithSchema,\n NodeInputSchema,\n} from './types';\n\nconst validateOptionalText = (\n value: unknown,\n field: 'title' | 'description',\n node: string,\n): void => {\n if (\n value !== undefined &&\n (typeof value !== 'string' || value.trim().length === 0)\n ) {\n throw new NodeDefinitionError(\n `Node \"${node}\" ${field} must be a non-empty string.`,\n { node, field },\n );\n }\n};\n\nconst validateInputSchema = (schema: unknown, node: string): void => {\n if (schema === undefined) return;\n if (!(schema instanceof z.ZodObject)) {\n throw new NodeDefinitionError(\n `Node \"${node}\" inputSchema must be a Zod object schema.`,\n { node, field: 'inputSchema' },\n );\n }\n if ('$' in schema.shape) {\n throw new NodeDefinitionError(\n `Node \"${node}\" inputSchema must not declare \"$\" as an input property.`,\n { node, field: 'inputSchema.$' },\n );\n }\n};\n\nconst validateDefinition = (options: {\n name: string;\n title?: unknown;\n description?: unknown;\n inputSchema?: unknown;\n execute: unknown;\n}): void => {\n if (!options || typeof options !== 'object') {\n throw new NodeDefinitionError('Node definition must be an object.');\n }\n\n if (typeof options.name !== 'string' || options.name.trim().length === 0) {\n throw new NodeDefinitionError('Node name must be a non-empty string.');\n }\n\n validateOptionalText(options.title, 'title', options.name);\n validateOptionalText(options.description, 'description', options.name);\n validateInputSchema(options.inputSchema, options.name);\n\n if (typeof options.execute !== 'function') {\n throw new NodeDefinitionError(\n `Node \"${options.name}\" must provide an execute function.`,\n { node: options.name },\n );\n }\n};\n\nexport function defineNode<\n TSchema extends NodeInputSchema,\n TData = unknown,\n TContext = unknown,\n>(\n options: DefineNodeWithSchemaOptions<TSchema, TData, TContext>,\n): NodeDefinitionWithSchema<TSchema, TData, TContext>;\n\nexport function defineNode<\n TInput = unknown,\n TData = unknown,\n TContext = unknown,\n>(\n options: DefineNodeOptions<TInput, TData, TContext>,\n): NodeDefinition<TInput, TData, TContext>;\n\nexport function defineNode(\n options: DefineNodeOptions<any, any, any>,\n): NodeDefinition<any, any, any> {\n validateDefinition(options);\n return options;\n}\n","const SUPPORTED_WEB_PROTOCOLS = new Set(['http:', 'https:']);\n\nexport const throwIfAborted = (signal: AbortSignal, operation: string) => {\n if (signal.aborted) {\n throw signal.reason ?? new Error(`${operation} aborted.`);\n }\n};\n\nexport const resolveWebUrl = (\n target: string,\n baseUrl: string | undefined,\n label: string,\n): string => {\n const trimmed = target.trim();\n if (!trimmed) throw new TypeError(`${label} must not be blank.`);\n\n let resolved: URL;\n try {\n resolved =\n baseUrl === undefined ? new URL(trimmed) : new URL(trimmed, baseUrl);\n } catch (error) {\n throw new TypeError(\n baseUrl === undefined\n ? `${label} must be an absolute URL when getBaseUrl() is not configured.`\n : `${label} is not a valid URL.`,\n { cause: error },\n );\n }\n if (!SUPPORTED_WEB_PROTOCOLS.has(resolved.protocol)) {\n throw new TypeError(\n `${label} does not support the ${resolved.protocol} protocol.`,\n );\n }\n return resolved.toString();\n};\n","import type { BrowserContext } from 'playwright';\nimport { z } from 'zod/v4';\nimport { defineNode } from '../node/define-node';\nimport type { NodeDefinition } from '../node/types';\nimport type { CreatePlaywrightNodesOptions } from './types';\nimport { throwIfAborted } from './utils';\n\ntype CookieClearOptions = NonNullable<\n Parameters<BrowserContext['clearCookies']>[0]\n>;\n\n/** Input schema for the Playwright clearCookies Node. */\nexport const clearCookiesInputSchema = z.strictObject({\n name: z.string().regex(/\\S/).optional().describe('Cookie name to clear.'),\n domain: z.string().regex(/\\S/).optional().describe('Cookie domain to clear.'),\n path: z.string().regex(/\\S/).optional().describe('Cookie path to clear.'),\n});\n\n/** Validated input accepted by the Playwright clearCookies Node. */\nexport type ClearCookiesNodeInput = z.infer<typeof clearCookiesInputSchema>;\n\nexport const createClearCookiesNode = <TContext>(\n options: CreatePlaywrightNodesOptions<TContext>,\n): NodeDefinition<any, any, TContext> =>\n defineNode<\n typeof clearCookiesInputSchema,\n { filters: CookieClearOptions },\n TContext\n >({\n name: 'clearCookies',\n title: 'Clear browser cookies',\n description:\n 'Clear all cookies from the current Playwright BrowserContext, or only cookies matching name, domain, or path.',\n inputSchema: clearCookiesInputSchema,\n async execute(ctx) {\n throwIfAborted(ctx.signal, 'clearCookies');\n const page = await options.getPage(ctx);\n const filters: CookieClearOptions = {\n ...(ctx.input.name === undefined ? {} : { name: ctx.input.name }),\n ...(ctx.input.domain === undefined ? {} : { domain: ctx.input.domain }),\n ...(ctx.input.path === undefined ? {} : { path: ctx.input.path }),\n };\n await page.context().clearCookies(filters);\n const filterNames = Object.keys(filters);\n return {\n summary:\n filterNames.length === 0\n ? 'Cleared all browser cookies'\n : `Cleared browser cookies matching ${filterNames.join(', ')}`,\n data: { filters },\n };\n },\n });\n","import { readFile } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { z } from 'zod/v4';\nimport { defineNode } from '../node/define-node';\nimport type { NodeDefinition } from '../node/types';\nimport type {\n CreatePlaywrightNodesOptions,\n PlaywrightCookie,\n PlaywrightNodeContext,\n} from './types';\nimport { resolveWebUrl, throwIfAborted } from './utils';\n\ntype CookieSourceReference =\n | { kind: 'env'; name: string }\n | { kind: 'profile'; name: string }\n | { kind: 'storage-state'; name: string };\n\ninterface ResolvedCookieSource {\n reference: CookieSourceReference;\n cookies: unknown;\n}\n\n/** Input schema for the Playwright setCookies Node. */\nexport const setCookiesInputSchema = z\n .strictObject({\n cookiesEnv: z\n .string()\n .regex(/^[A-Za-z_][A-Za-z0-9_]*$/)\n .optional()\n .describe(\n 'The environment variable containing a Cookie header, cookie array JSON, or Playwright storage-state JSON.',\n ),\n profile: z\n .string()\n .regex(/\\S/)\n .optional()\n .describe('A cookie profile resolved by getCookieProfile().'),\n storageStatePath: z\n .string()\n .regex(/\\S/)\n .optional()\n .describe('A path to a Playwright storage-state JSON file.'),\n url: z\n .string()\n .url()\n .optional()\n .describe(\n 'The HTTP(S) URL used to scope Cookie-header values or cookies without domain/path.',\n ),\n })\n .superRefine((input, ctx) => {\n const sourceCount = [\n input.cookiesEnv,\n input.profile,\n input.storageStatePath,\n ].filter((value) => value !== undefined).length;\n if (sourceCount !== 1) {\n ctx.addIssue({\n code: 'custom',\n message:\n 'exactly one of cookiesEnv, profile, and storageStatePath is required',\n });\n }\n });\n\n/** Validated input accepted by the Playwright setCookies Node. */\nexport type SetCookiesNodeInput = z.infer<typeof setCookiesInputSchema>;\n\n/** Secret-free metadata returned by the Playwright setCookies Node. */\nexport interface SetCookiesNodeResult {\n /** Kind of configured reference used to resolve the cookies. */\n source: CookieSourceReference['kind'];\n /** Environment variable, profile, or storage-state reference name. */\n sourceName: string;\n /** Number of cookies passed to the BrowserContext. */\n count: number;\n}\n\nconst toCookieSourceReference = (\n input: SetCookiesNodeInput,\n): CookieSourceReference => {\n if (input.cookiesEnv !== undefined) {\n return { kind: 'env', name: input.cookiesEnv };\n }\n if (input.profile !== undefined) {\n return { kind: 'profile', name: input.profile };\n }\n if (input.storageStatePath !== undefined) {\n return { kind: 'storage-state', name: input.storageStatePath };\n }\n throw new TypeError('setCookies requires one cookie source.');\n};\n\nconst parseCookieHeader = (raw: string, url: string | undefined) => {\n if (url === undefined) {\n throw new TypeError(\n 'setCookies.url is required when cookiesEnv contains a Cookie header.',\n );\n }\n const segments = raw\n .split(';')\n .map((segment) => segment.trim())\n .filter(Boolean);\n if (segments.length === 0) {\n throw new TypeError('setCookies Cookie header contains no cookies.');\n }\n return segments.map((segment) => {\n const separator = segment.indexOf('=');\n if (separator <= 0) {\n throw new TypeError(\n 'setCookies Cookie header contains an invalid name/value pair.',\n );\n }\n const name = segment.slice(0, separator).trim();\n const value = segment.slice(separator + 1).trim();\n if (!name) {\n throw new TypeError('setCookies Cookie header contains an empty name.');\n }\n return { name, value, url } satisfies PlaywrightCookie;\n });\n};\n\nconst parseCookieJson = (raw: string): unknown => {\n try {\n return JSON.parse(raw);\n } catch {\n throw new TypeError(\n 'setCookies source must contain valid JSON or a Cookie header.',\n );\n }\n};\n\nconst resolveCookieSource = async <TContext>(\n reference: CookieSourceReference,\n defaultUrl: string | undefined,\n ctx: PlaywrightNodeContext<TContext>,\n options: CreatePlaywrightNodesOptions<TContext>,\n): Promise<ResolvedCookieSource> => {\n switch (reference.kind) {\n case 'env': {\n let env: Readonly<Record<string, string | undefined>>;\n try {\n env = (await options.getEnv?.(ctx)) ?? process.env;\n } catch {\n throw new Error(\n `Failed to resolve cookie environment ${reference.name}; the original error was redacted because it may contain cookie values.`,\n );\n }\n const raw = env[reference.name];\n if (!raw?.trim()) {\n throw new Error(\n `Environment variable ${reference.name} is missing or blank.`,\n );\n }\n const trimmed = raw.trim();\n return {\n reference,\n cookies: /^[\\[{]/.test(trimmed)\n ? parseCookieJson(trimmed)\n : parseCookieHeader(trimmed, defaultUrl),\n };\n }\n case 'profile': {\n if (!options.getCookieProfile) {\n throw new Error(\n 'setCookies.profile requires createPlaywrightNodes({ getCookieProfile }).',\n );\n }\n try {\n return {\n reference,\n cookies: await options.getCookieProfile({\n profile: reference.name,\n context: ctx.context,\n signal: ctx.signal,\n }),\n };\n } catch {\n throw new Error(\n `Failed to resolve cookie profile ${reference.name}; the original error was redacted because it may contain cookie values.`,\n );\n }\n }\n case 'storage-state': {\n const path = options.resolveStorageStatePath\n ? await options.resolveStorageStatePath(reference.name, ctx)\n : resolve(process.cwd(), reference.name);\n return {\n reference,\n cookies: parseCookieJson(await readFile(path, 'utf8')),\n };\n }\n }\n};\n\nconst normalizeCookie = (\n candidate: unknown,\n defaultUrl: string | undefined,\n index: number,\n): PlaywrightCookie => {\n if (!candidate || typeof candidate !== 'object' || Array.isArray(candidate)) {\n throw new TypeError(\n `setCookies cookie at index ${index} must be an object.`,\n );\n }\n const cookie = candidate as Record<string, unknown>;\n if (typeof cookie.name !== 'string' || !cookie.name.trim()) {\n throw new TypeError(\n `setCookies cookie at index ${index} requires a non-blank name.`,\n );\n }\n if (typeof cookie.value !== 'string') {\n throw new TypeError(\n `setCookies cookie at index ${index} requires a string value.`,\n );\n }\n\n const normalized = { ...cookie } as unknown as PlaywrightCookie;\n const hasUrl = typeof cookie.url === 'string' && cookie.url.length > 0;\n const hasDomain =\n typeof cookie.domain === 'string' && cookie.domain.length > 0;\n if (!hasUrl && !hasDomain) {\n if (defaultUrl === undefined) {\n throw new TypeError(\n `setCookies cookie at index ${index} requires url or domain, or setCookies.url must be provided.`,\n );\n }\n normalized.url = defaultUrl;\n }\n if (hasDomain && typeof cookie.path !== 'string') {\n normalized.path = '/';\n }\n return normalized;\n};\n\nconst normalizeCookies = (\n source: unknown,\n defaultUrl: string | undefined,\n): PlaywrightCookie[] => {\n const candidates = Array.isArray(source)\n ? source\n : source &&\n typeof source === 'object' &&\n Array.isArray((source as { cookies?: unknown }).cookies)\n ? (source as { cookies: unknown[] }).cookies\n : undefined;\n if (!candidates) {\n throw new TypeError(\n 'setCookies JSON must be a cookie array or an object with a cookies array.',\n );\n }\n if (candidates.length === 0) {\n throw new TypeError('setCookies source contains no cookies.');\n }\n return candidates.map((cookie, index) =>\n normalizeCookie(cookie, defaultUrl, index),\n );\n};\n\nexport const createSetCookiesNode = <TContext>(\n options: CreatePlaywrightNodesOptions<TContext>,\n): NodeDefinition<any, any, TContext> =>\n defineNode<typeof setCookiesInputSchema, SetCookiesNodeResult, TContext>({\n name: 'setCookies',\n title: 'Set browser cookies',\n description:\n 'Load cookies from an environment variable, configured profile, or Playwright storage-state file without persisting cookie values in workflow input or output.',\n inputSchema: setCookiesInputSchema,\n async execute(ctx) {\n throwIfAborted(ctx.signal, 'setCookies');\n const page = await options.getPage(ctx);\n const defaultUrl =\n ctx.input.url === undefined\n ? undefined\n : resolveWebUrl(ctx.input.url, undefined, 'setCookies.url');\n const reference = toCookieSourceReference(ctx.input);\n const resolved = await resolveCookieSource(\n reference,\n defaultUrl,\n ctx,\n options,\n );\n const cookies = normalizeCookies(resolved.cookies, defaultUrl);\n\n throwIfAborted(ctx.signal, 'setCookies');\n try {\n await page.context().addCookies(cookies);\n } catch {\n throw new Error(\n `Failed to set ${cookies.length} browser cookie(s); the browser error was redacted because it may contain cookie values.`,\n );\n }\n\n const result: SetCookiesNodeResult = {\n source: resolved.reference.kind,\n sourceName: resolved.reference.name,\n count: cookies.length,\n };\n return {\n summary: `Set ${result.count} browser cookie(s) from ${result.source} source ${result.sourceName}`,\n data: result,\n };\n },\n });\n","import { z } from 'zod/v4';\nimport { defineNode } from '../node/define-node';\nimport type { NodeDefinition } from '../node/types';\nimport type { CreatePlaywrightNodesOptions } from './types';\nimport { resolveWebUrl, throwIfAborted } from './utils';\n\nconst DEFAULT_NAVIGATION_TIMEOUT_MS = 60_000;\nconst DEFAULT_WAIT_UNTIL = 'domcontentloaded' as const;\n\n/** Input schema for the Playwright gotoUrl Node. */\nexport const gotoUrlInputSchema = z\n .strictObject({\n prompt: z\n .string()\n .min(1)\n .optional()\n .describe('String shorthand for the URL to open.'),\n url: z\n .string()\n .min(1)\n .optional()\n .describe('An absolute HTTP(S) URL or a path relative to baseUrl.'),\n waitUntil: z\n .enum(['commit', 'domcontentloaded', 'load', 'networkidle'])\n .default(DEFAULT_WAIT_UNTIL)\n .describe('The Playwright navigation lifecycle event to wait for.'),\n timeoutMs: z\n .number()\n .positive()\n .default(DEFAULT_NAVIGATION_TIMEOUT_MS)\n .describe('The navigation timeout in milliseconds.'),\n })\n .superRefine((input, ctx) => {\n if ((input.prompt === undefined) === (input.url === undefined)) {\n ctx.addIssue({\n code: 'custom',\n message: 'exactly one of prompt and url is required',\n });\n }\n });\n\n/** Validated input accepted by the Playwright gotoUrl Node. */\nexport type GotoUrlNodeInput = z.infer<typeof gotoUrlInputSchema>;\n\n/** Structured navigation details returned by the Playwright gotoUrl Node. */\nexport interface GotoUrlNodeResult {\n /** Final Page URL after navigation and redirects. */\n url: string;\n /** Main-resource HTTP status, or null when Playwright returns no response. */\n status: number | null;\n /** Document title after navigation completes. */\n title: string;\n}\n\nexport const createGotoUrlNode = <TContext>(\n options: CreatePlaywrightNodesOptions<TContext>,\n): NodeDefinition<any, any, TContext> =>\n defineNode<typeof gotoUrlInputSchema, GotoUrlNodeResult, TContext>({\n name: 'gotoUrl',\n title: 'Open a Web URL',\n description:\n 'Navigate the current Playwright Page to an absolute HTTP(S) URL or a path relative to the configured baseUrl.',\n inputSchema: gotoUrlInputSchema,\n async execute(ctx) {\n throwIfAborted(ctx.signal, 'gotoUrl');\n const page = await options.getPage(ctx);\n const baseUrl = await options.getBaseUrl?.(ctx);\n const target = ctx.input.url ?? ctx.input.prompt;\n if (target === undefined) {\n throw new TypeError('gotoUrl requires a URL.');\n }\n const url = resolveWebUrl(target, baseUrl, 'gotoUrl.url');\n const response = await page.goto(url, {\n waitUntil: ctx.input.waitUntil,\n timeout: ctx.input.timeoutMs,\n });\n const status = response?.status() ?? null;\n const result = {\n url: page.url(),\n status,\n title: await page.title(),\n };\n return { summary: `Navigated to ${result.url}`, data: result };\n },\n });\n","import { z } from 'zod/v4';\nimport { defineNode } from '../node/define-node';\nimport type { NodeDefinition } from '../node/types';\nimport type { CreatePlaywrightNodesOptions } from './types';\nimport { throwIfAborted } from './utils';\n\n/** Input schema for the Playwright setViewportSize Node. */\nexport const setViewportSizeInputSchema = z.strictObject({\n width: z.number().int().positive().describe('Viewport width in CSS pixels.'),\n height: z\n .number()\n .int()\n .positive()\n .describe('Viewport height in CSS pixels.'),\n});\n\n/** Validated input accepted by the Playwright setViewportSize Node. */\nexport type SetViewportSizeNodeInput = z.infer<\n typeof setViewportSizeInputSchema\n>;\n\nexport const createSetViewportSizeNode = <TContext>(\n options: CreatePlaywrightNodesOptions<TContext>,\n): NodeDefinition<any, any, TContext> =>\n defineNode<\n typeof setViewportSizeInputSchema,\n { width: number; height: number },\n TContext\n >({\n name: 'setViewportSize',\n title: 'Set the browser viewport size',\n description:\n 'Set the current Playwright Page viewport size in CSS pixels and return the effective size.',\n inputSchema: setViewportSizeInputSchema,\n async execute(ctx) {\n throwIfAborted(ctx.signal, 'setViewportSize');\n const page = await options.getPage(ctx);\n await page.setViewportSize({\n width: ctx.input.width,\n height: ctx.input.height,\n });\n const viewport = page.viewportSize();\n if (!viewport) {\n throw new Error(\n 'Playwright did not report an effective viewport size.',\n );\n }\n return {\n summary: `Set viewport to ${viewport.width}x${viewport.height}`,\n data: viewport,\n };\n },\n });\n","import { NodeDefinitionError } from '../errors';\nimport type { NodeDefinition } from '../node/types';\nimport { createClearCookiesNode } from './clear-cookies';\nimport { createSetCookiesNode } from './cookies';\nimport { createGotoUrlNode } from './goto-url';\nimport type { CreatePlaywrightNodesOptions } from './types';\nimport { createSetViewportSizeNode } from './viewport';\n\nexport { clearCookiesInputSchema } from './clear-cookies';\nexport type { ClearCookiesNodeInput } from './clear-cookies';\nexport { setCookiesInputSchema } from './cookies';\nexport type {\n SetCookiesNodeInput,\n SetCookiesNodeResult,\n} from './cookies';\nexport { gotoUrlInputSchema } from './goto-url';\nexport type { GotoUrlNodeInput, GotoUrlNodeResult } from './goto-url';\nexport type {\n CreatePlaywrightNodesOptions,\n PlaywrightCookieProfileContext,\n} from './types';\nexport { setViewportSizeInputSchema } from './viewport';\nexport type { SetViewportSizeNodeInput } from './viewport';\n\nconst requireOptions = <TContext>(\n options: CreatePlaywrightNodesOptions<TContext>,\n) => {\n if (!options || typeof options !== 'object') {\n throw new NodeDefinitionError(\n 'createPlaywrightNodes() options must be an object.',\n );\n }\n if (typeof options.getPage !== 'function') {\n throw new NodeDefinitionError(\n 'createPlaywrightNodes() requires getPage().',\n );\n }\n};\n\n/**\n * Create the P0 Playwright preset Nodes without assuming Project Context field\n * names. Cookie values must be resolved through configured references and are\n * never accepted as inline Node input.\n */\nexport function createPlaywrightNodes<TContext>(\n options: CreatePlaywrightNodesOptions<TContext>,\n): readonly NodeDefinition<any, any, TContext>[] {\n requireOptions(options);\n return [\n createGotoUrlNode(options),\n createSetCookiesNode(options),\n createClearCookiesNode(options),\n createSetViewportSizeNode(options),\n ];\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","WorkflowError","Error","undefined","message","options","NodeDefinitionError","details","validateOptionalText","value","field","node","validateInputSchema","schema","z","validateDefinition","defineNode","SUPPORTED_WEB_PROTOCOLS","Set","throwIfAborted","signal","operation","resolveWebUrl","target","baseUrl","label","trimmed","TypeError","resolved","URL","error","clearCookiesInputSchema","createClearCookiesNode","ctx","page","filters","filterNames","setCookiesInputSchema","input","sourceCount","toCookieSourceReference","parseCookieHeader","raw","url","segments","segment","Boolean","separator","name","parseCookieJson","JSON","resolveCookieSource","reference","defaultUrl","env","process","path","resolve","readFile","normalizeCookie","candidate","index","Array","cookie","normalized","hasUrl","hasDomain","normalizeCookies","source","candidates","createSetCookiesNode","cookies","result","DEFAULT_NAVIGATION_TIMEOUT_MS","DEFAULT_WAIT_UNTIL","gotoUrlInputSchema","createGotoUrlNode","response","status","setViewportSizeInputSchema","createSetViewportSizeNode","viewport","requireOptions","createPlaywrightNodes"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OA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,MACC,GACN,GAAG,GACH,QAAQ,GACR,QAAQ,CAAC;AACd;AAOO,MAAMkE,4BAA4B,CACvC3E,UAEAW,WAIE;QACA,MAAM;QACN,OAAO;QACP,aACE;QACF,aAAa+D;QACb,MAAM,SAAQ9C,GAAG;YACfd,eAAec,IAAI,MAAM,EAAE;YAC3B,MAAMC,OAAO,MAAM7B,QAAQ,OAAO,CAAC4B;YACnC,MAAMC,KAAK,eAAe,CAAC;gBACzB,OAAOD,IAAI,KAAK,CAAC,KAAK;gBACtB,QAAQA,IAAI,KAAK,CAAC,MAAM;YAC1B;YACA,MAAMgD,WAAW/C,KAAK,YAAY;YAClC,IAAI,CAAC+C,UACH,MAAM,IAAI/E,MACR;YAGJ,OAAO;gBACL,SAAS,CAAC,gBAAgB,EAAE+E,SAAS,KAAK,CAAC,CAAC,EAAEA,SAAS,MAAM,EAAE;gBAC/D,MAAMA;YACR;QACF;IACF;AC5BF,MAAMC,iBAAiB,CACrB7E;IAEA,IAAI,CAACA,WAAW,AAAmB,YAAnB,OAAOA,SACrB,MAAM,IAAIC,oBACR;IAGJ,IAAI,AAA2B,cAA3B,OAAOD,QAAQ,OAAO,EACxB,MAAM,IAAIC,oBACR;AAGN;AAOO,SAAS6E,sBACd9E,OAA+C;IAE/C6E,eAAe7E;IACf,OAAO;QACLuE,kBAAkBvE;QAClBiE,qBAAqBjE;QACrB2B,uBAAuB3B;QACvB2E,0BAA0B3E;KAC3B;AACH"}
|
|
1
|
+
{"version":3,"file":"playwright/index.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/errors.ts","../../../src/node/define-node.ts","../../../src/playwright/utils.ts","../../../src/playwright/clear-cookies.ts","../../../src/playwright/cookies.ts","../../../src/playwright/goto-url.ts","../../../src/playwright/viewport.ts","../../../src/playwright/index.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { z } from 'zod/v4';\n\nexport interface WorkflowErrorOptions {\n code?: string;\n details?: unknown;\n cause?: unknown;\n}\n\nexport class WorkflowError extends Error {\n readonly code: string;\n readonly details?: unknown;\n\n constructor(message: string, options: WorkflowErrorOptions = {}) {\n super(message, { cause: options.cause });\n this.name = new.target.name;\n this.code = options.code ?? 'WORKFLOW_ERROR';\n this.details = options.details;\n }\n\n toJSON(): Record<string, unknown> {\n return {\n name: this.name,\n message: this.message,\n code: this.code,\n ...(this.details === undefined ? {} : { details: this.details }),\n };\n }\n}\n\nexport class WorkflowParseError extends WorkflowError {\n constructor(message: string, details?: unknown, cause?: unknown) {\n super(message, { code: 'WORKFLOW_PARSE_ERROR', details, cause });\n }\n}\n\nexport class NodeDefinitionError extends WorkflowError {\n constructor(message: string, details?: unknown) {\n super(message, { code: 'NODE_DEFINITION_ERROR', details });\n }\n}\n\nexport class DuplicateNodeError extends WorkflowError {\n readonly node: string;\n\n constructor(node: string) {\n super(`Node \"${node}\" is already registered.`, {\n code: 'DUPLICATE_NODE',\n details: { node },\n });\n this.node = node;\n }\n}\n\nexport class NodeNotFoundError extends WorkflowError {\n readonly node: string;\n\n constructor(node: string) {\n super(`Node \"${node}\" is not registered.`, {\n code: 'NODE_NOT_FOUND',\n details: { node },\n });\n this.node = node;\n }\n}\n\nexport class NodeInputValidationError extends WorkflowError {\n constructor(message: string, details?: unknown) {\n super(message, { code: 'NODE_INPUT_VALIDATION_ERROR', details });\n }\n\n static fromZod(node: string, error: z.ZodError): NodeInputValidationError {\n const issues = error.issues.map((issue) => ({\n code: issue.code,\n path: issue.path.map(String).join('.'),\n message: issue.message,\n }));\n const firstIssue = issues[0];\n const path = firstIssue?.path || '<root>';\n const message = firstIssue?.message ?? 'invalid input';\n return new NodeInputValidationError(\n `Node \"${node}\" input validation failed at \"${path}\": ${message}`,\n { node, issues },\n );\n }\n}\n\nexport class StepTimeoutError extends WorkflowError {\n readonly timeoutMs: number;\n readonly node?: string;\n\n constructor(timeoutMs: number, node?: string) {\n super(\n node\n ? `Node \"${node}\" timed out after ${timeoutMs}ms.`\n : `Step timed out after ${timeoutMs}ms.`,\n {\n code: 'STEP_TIMEOUT',\n details: { timeoutMs, ...(node === undefined ? {} : { node }) },\n },\n );\n this.timeoutMs = timeoutMs;\n this.node = node;\n }\n}\n\nexport class NodeExecutionError extends WorkflowError {\n readonly node: string;\n\n constructor(node: string, cause: unknown) {\n const causeMessage =\n cause instanceof Error ? cause.message : String(cause ?? 'Unknown error');\n super(`Node \"${node}\" failed: ${causeMessage}`, {\n code: 'NODE_EXECUTION_ERROR',\n details: { node },\n cause,\n });\n this.node = node;\n }\n}\n\nexport class WorkflowLifecycleError extends WorkflowError {\n constructor(message: string, details?: unknown) {\n super(message, { code: 'WORKFLOW_LIFECYCLE_ERROR', details });\n }\n}\n\nexport class ProjectSetupError extends WorkflowError {\n constructor(cause: unknown, details: { projectName: string }) {\n const causeMessage =\n cause instanceof Error ? cause.message : String(cause ?? 'Unknown error');\n super(`Project \"${details.projectName}\" setup failed: ${causeMessage}`, {\n code: 'PROJECT_SETUP_ERROR',\n details,\n cause,\n });\n }\n}\n\nexport class ProjectTeardownError extends WorkflowError {\n constructor(\n cause: unknown,\n details: { projectName: string; registrationIndex: number },\n ) {\n const causeMessage =\n cause instanceof Error ? cause.message : String(cause ?? 'Unknown error');\n super(`Project \"${details.projectName}\" teardown failed: ${causeMessage}`, {\n code: 'PROJECT_TEARDOWN_ERROR',\n details,\n cause,\n });\n }\n}\n\nexport class NodeScopeTeardownError extends WorkflowError {\n constructor(\n cause: unknown,\n details: {\n scope: 'case' | 'document';\n scopeId: string;\n node: string;\n registrationIndex: number;\n },\n ) {\n const causeMessage =\n cause instanceof Error ? cause.message : String(cause ?? 'Unknown error');\n super(\n `${details.scope === 'case' ? 'Case attempt' : 'Workflow document'} node teardown failed for \"${details.node}\": ${causeMessage}`,\n { code: 'NODE_SCOPE_TEARDOWN_ERROR', details, cause },\n );\n }\n}\n\nexport class FatalDeviceError extends WorkflowError {\n constructor(message: string, cause?: unknown) {\n super(message, { code: 'FATAL_DEVICE_ERROR', cause });\n }\n}\n\nexport const isFatalDeviceError = (error: unknown): boolean => {\n if (error instanceof FatalDeviceError) return true;\n if (error instanceof WorkflowError && error.code === 'FATAL_DEVICE_ERROR') {\n return true;\n }\n if (\n error instanceof Error &&\n /device offline|device not found|(?:adb|bdc|device) connection (?:was )?closed/i.test(\n error.message,\n )\n ) {\n return true;\n }\n return error instanceof Error && error.cause !== undefined\n ? isFatalDeviceError(error.cause)\n : false;\n};\n\nexport class CaseExecutionError extends WorkflowError {\n readonly result: import('./engine/types').CaseRunResult;\n\n constructor(result: import('./engine/types').CaseRunResult) {\n super(`Case \"${result.name}\" failed.`, {\n code: 'CASE_EXECUTION_FAILED',\n details: { caseId: result.caseId, runId: result.runId },\n });\n this.result = result;\n }\n}\n\nexport class WorkflowDocumentExecutionError extends WorkflowError {\n readonly result: import('./engine/types').WorkflowDocumentRunResult;\n\n constructor(result: import('./engine/types').WorkflowDocumentRunResult) {\n super(`Workflow document \"${result.sourcePath}\" failed.`, {\n code: 'WORKFLOW_DOCUMENT_EXECUTION_FAILED',\n details: {\n documentId: result.documentId,\n documentRunId: result.documentRunId,\n },\n });\n this.result = result;\n }\n}\n\nexport function normalizeNodeExecutionError(\n error: unknown,\n node: string,\n): WorkflowError {\n return error instanceof WorkflowError\n ? error\n : new NodeExecutionError(node, error);\n}\n","import { z } from 'zod/v4';\nimport { NodeDefinitionError } from '../errors';\nimport type {\n DefineNodeOptions,\n DefineNodeWithSchemaOptions,\n NodeDefinition,\n NodeDefinitionWithSchema,\n NodeInputSchema,\n} from './types';\n\nconst validateOptionalText = (\n value: unknown,\n field: 'title' | 'description',\n node: string,\n): void => {\n if (\n value !== undefined &&\n (typeof value !== 'string' || value.trim().length === 0)\n ) {\n throw new NodeDefinitionError(\n `Node \"${node}\" ${field} must be a non-empty string.`,\n { node, field },\n );\n }\n};\n\nconst validateInputSchema = (schema: unknown, node: string): void => {\n if (schema === undefined) return;\n if (!(schema instanceof z.ZodObject)) {\n throw new NodeDefinitionError(\n `Node \"${node}\" inputSchema must be a Zod object schema.`,\n { node, field: 'inputSchema' },\n );\n }\n if ('$' in schema.shape) {\n throw new NodeDefinitionError(\n `Node \"${node}\" inputSchema must not declare \"$\" as an input property.`,\n { node, field: 'inputSchema.$' },\n );\n }\n};\n\nconst validateDefinition = (options: {\n name: string;\n title?: unknown;\n description?: unknown;\n stringInputKey?: unknown;\n inputSchema?: unknown;\n execute: unknown;\n}): void => {\n if (!options || typeof options !== 'object') {\n throw new NodeDefinitionError('Node definition must be an object.');\n }\n\n if (typeof options.name !== 'string' || options.name.trim().length === 0) {\n throw new NodeDefinitionError('Node name must be a non-empty string.');\n }\n\n validateOptionalText(options.title, 'title', options.name);\n validateOptionalText(options.description, 'description', options.name);\n if (\n options.stringInputKey !== undefined &&\n options.stringInputKey !== false &&\n (typeof options.stringInputKey !== 'string' ||\n options.stringInputKey.trim().length === 0)\n ) {\n throw new NodeDefinitionError(\n `Node \"${options.name}\" stringInputKey must be a non-empty string or false.`,\n { node: options.name, field: 'stringInputKey' },\n );\n }\n validateInputSchema(options.inputSchema, options.name);\n\n if (\n typeof options.stringInputKey === 'string' &&\n options.inputSchema instanceof z.ZodObject &&\n !(options.stringInputKey in options.inputSchema.shape)\n ) {\n throw new NodeDefinitionError(\n `Node \"${options.name}\" stringInputKey must reference a field in inputSchema.`,\n { node: options.name, field: 'stringInputKey' },\n );\n }\n\n if (typeof options.execute !== 'function') {\n throw new NodeDefinitionError(\n `Node \"${options.name}\" must provide an execute function.`,\n { node: options.name },\n );\n }\n};\n\nexport function defineNode<\n TSchema extends NodeInputSchema,\n TData = unknown,\n TContext = unknown,\n>(\n options: DefineNodeWithSchemaOptions<TSchema, TData, TContext>,\n): NodeDefinitionWithSchema<TSchema, TData, TContext>;\n\nexport function defineNode<\n TInput = unknown,\n TData = unknown,\n TContext = unknown,\n>(\n options: DefineNodeOptions<TInput, TData, TContext>,\n): NodeDefinition<TInput, TData, TContext>;\n\nexport function defineNode(\n options: DefineNodeOptions<any, any, any>,\n): NodeDefinition<any, any, any> {\n validateDefinition(options);\n return options;\n}\n","const SUPPORTED_WEB_PROTOCOLS = new Set(['http:', 'https:']);\n\nexport const throwIfAborted = (signal: AbortSignal, operation: string) => {\n if (signal.aborted) {\n throw signal.reason ?? new Error(`${operation} aborted.`);\n }\n};\n\nexport const resolveWebUrl = (\n target: string,\n baseUrl: string | undefined,\n label: string,\n): string => {\n const trimmed = target.trim();\n if (!trimmed) throw new TypeError(`${label} must not be blank.`);\n\n let resolved: URL;\n try {\n resolved =\n baseUrl === undefined ? new URL(trimmed) : new URL(trimmed, baseUrl);\n } catch (error) {\n throw new TypeError(\n baseUrl === undefined\n ? `${label} must be an absolute URL when getBaseUrl() is not configured.`\n : `${label} is not a valid URL.`,\n { cause: error },\n );\n }\n if (!SUPPORTED_WEB_PROTOCOLS.has(resolved.protocol)) {\n throw new TypeError(\n `${label} does not support the ${resolved.protocol} protocol.`,\n );\n }\n return resolved.toString();\n};\n","import type { BrowserContext } from 'playwright';\nimport { z } from 'zod/v4';\nimport { defineNode } from '../node/define-node';\nimport type { NodeDefinition } from '../node/types';\nimport type { CreatePlaywrightNodesOptions } from './types';\nimport { throwIfAborted } from './utils';\n\ntype CookieClearOptions = NonNullable<\n Parameters<BrowserContext['clearCookies']>[0]\n>;\n\n/** Input schema for the Playwright clearCookies Node. */\nexport const clearCookiesInputSchema = z.strictObject({\n name: z.string().regex(/\\S/).optional().describe('Cookie name to clear.'),\n domain: z.string().regex(/\\S/).optional().describe('Cookie domain to clear.'),\n path: z.string().regex(/\\S/).optional().describe('Cookie path to clear.'),\n});\n\n/** Validated input accepted by the Playwright clearCookies Node. */\nexport type ClearCookiesNodeInput = z.infer<typeof clearCookiesInputSchema>;\n\nexport const createClearCookiesNode = <TContext>(\n options: CreatePlaywrightNodesOptions<TContext>,\n): NodeDefinition<any, any, TContext> =>\n defineNode<\n typeof clearCookiesInputSchema,\n { filters: CookieClearOptions },\n TContext\n >({\n name: 'clearCookies',\n title: 'Clear browser cookies',\n description:\n 'Clear all cookies from the current Playwright BrowserContext, or only cookies matching name, domain, or path.',\n stringInputKey: false,\n inputSchema: clearCookiesInputSchema,\n async execute(ctx) {\n throwIfAborted(ctx.signal, 'clearCookies');\n const page = await options.getPage(ctx);\n const filters: CookieClearOptions = {\n ...(ctx.input.name === undefined ? {} : { name: ctx.input.name }),\n ...(ctx.input.domain === undefined ? {} : { domain: ctx.input.domain }),\n ...(ctx.input.path === undefined ? {} : { path: ctx.input.path }),\n };\n await page.context().clearCookies(filters);\n const filterNames = Object.keys(filters);\n return {\n summary:\n filterNames.length === 0\n ? 'Cleared all browser cookies'\n : `Cleared browser cookies matching ${filterNames.join(', ')}`,\n data: { filters },\n };\n },\n });\n","import { readFile } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { z } from 'zod/v4';\nimport { defineNode } from '../node/define-node';\nimport type { NodeDefinition } from '../node/types';\nimport type {\n CreatePlaywrightNodesOptions,\n PlaywrightCookie,\n PlaywrightNodeContext,\n} from './types';\nimport { resolveWebUrl, throwIfAborted } from './utils';\n\ntype CookieSourceReference =\n | { kind: 'env'; name: string }\n | { kind: 'profile'; name: string }\n | { kind: 'storage-state'; name: string };\n\ninterface ResolvedCookieSource {\n reference: CookieSourceReference;\n cookies: unknown;\n}\n\n/** Input schema for the Playwright setCookies Node. */\nexport const setCookiesInputSchema = z\n .strictObject({\n cookiesEnv: z\n .string()\n .regex(/^[A-Za-z_][A-Za-z0-9_]*$/)\n .optional()\n .describe(\n 'The environment variable containing a Cookie header, cookie array JSON, or Playwright storage-state JSON.',\n ),\n profile: z\n .string()\n .regex(/\\S/)\n .optional()\n .describe('A cookie profile resolved by getCookieProfile().'),\n storageStatePath: z\n .string()\n .regex(/\\S/)\n .optional()\n .describe('A path to a Playwright storage-state JSON file.'),\n url: z\n .string()\n .url()\n .optional()\n .describe(\n 'The HTTP(S) URL used to scope Cookie-header values or cookies without domain/path.',\n ),\n })\n .superRefine((input, ctx) => {\n const sourceCount = [\n input.cookiesEnv,\n input.profile,\n input.storageStatePath,\n ].filter((value) => value !== undefined).length;\n if (sourceCount !== 1) {\n ctx.addIssue({\n code: 'custom',\n message:\n 'exactly one of cookiesEnv, profile, and storageStatePath is required',\n });\n }\n });\n\n/** Validated input accepted by the Playwright setCookies Node. */\nexport type SetCookiesNodeInput = z.infer<typeof setCookiesInputSchema>;\n\n/** Secret-free metadata returned by the Playwright setCookies Node. */\nexport interface SetCookiesNodeResult {\n /** Kind of configured reference used to resolve the cookies. */\n source: CookieSourceReference['kind'];\n /** Environment variable, profile, or storage-state reference name. */\n sourceName: string;\n /** Number of cookies passed to the BrowserContext. */\n count: number;\n}\n\nconst toCookieSourceReference = (\n input: SetCookiesNodeInput,\n): CookieSourceReference => {\n if (input.cookiesEnv !== undefined) {\n return { kind: 'env', name: input.cookiesEnv };\n }\n if (input.profile !== undefined) {\n return { kind: 'profile', name: input.profile };\n }\n if (input.storageStatePath !== undefined) {\n return { kind: 'storage-state', name: input.storageStatePath };\n }\n throw new TypeError('setCookies requires one cookie source.');\n};\n\nconst parseCookieHeader = (raw: string, url: string | undefined) => {\n if (url === undefined) {\n throw new TypeError(\n 'setCookies.url is required when cookiesEnv contains a Cookie header.',\n );\n }\n const segments = raw\n .split(';')\n .map((segment) => segment.trim())\n .filter(Boolean);\n if (segments.length === 0) {\n throw new TypeError('setCookies Cookie header contains no cookies.');\n }\n return segments.map((segment) => {\n const separator = segment.indexOf('=');\n if (separator <= 0) {\n throw new TypeError(\n 'setCookies Cookie header contains an invalid name/value pair.',\n );\n }\n const name = segment.slice(0, separator).trim();\n const value = segment.slice(separator + 1).trim();\n if (!name) {\n throw new TypeError('setCookies Cookie header contains an empty name.');\n }\n return { name, value, url } satisfies PlaywrightCookie;\n });\n};\n\nconst parseCookieJson = (raw: string): unknown => {\n try {\n return JSON.parse(raw);\n } catch {\n throw new TypeError(\n 'setCookies source must contain valid JSON or a Cookie header.',\n );\n }\n};\n\nconst resolveCookieSource = async <TContext>(\n reference: CookieSourceReference,\n defaultUrl: string | undefined,\n ctx: PlaywrightNodeContext<TContext>,\n options: CreatePlaywrightNodesOptions<TContext>,\n): Promise<ResolvedCookieSource> => {\n switch (reference.kind) {\n case 'env': {\n let env: Readonly<Record<string, string | undefined>>;\n try {\n env = (await options.getEnv?.(ctx)) ?? process.env;\n } catch {\n throw new Error(\n `Failed to resolve cookie environment ${reference.name}; the original error was redacted because it may contain cookie values.`,\n );\n }\n const raw = env[reference.name];\n if (!raw?.trim()) {\n throw new Error(\n `Environment variable ${reference.name} is missing or blank.`,\n );\n }\n const trimmed = raw.trim();\n return {\n reference,\n cookies: /^[\\[{]/.test(trimmed)\n ? parseCookieJson(trimmed)\n : parseCookieHeader(trimmed, defaultUrl),\n };\n }\n case 'profile': {\n if (!options.getCookieProfile) {\n throw new Error(\n 'setCookies.profile requires createPlaywrightNodes({ getCookieProfile }).',\n );\n }\n try {\n return {\n reference,\n cookies: await options.getCookieProfile({\n profile: reference.name,\n context: ctx.context,\n signal: ctx.signal,\n }),\n };\n } catch {\n throw new Error(\n `Failed to resolve cookie profile ${reference.name}; the original error was redacted because it may contain cookie values.`,\n );\n }\n }\n case 'storage-state': {\n const path = options.resolveStorageStatePath\n ? await options.resolveStorageStatePath(reference.name, ctx)\n : resolve(process.cwd(), reference.name);\n return {\n reference,\n cookies: parseCookieJson(await readFile(path, 'utf8')),\n };\n }\n }\n};\n\nconst normalizeCookie = (\n candidate: unknown,\n defaultUrl: string | undefined,\n index: number,\n): PlaywrightCookie => {\n if (!candidate || typeof candidate !== 'object' || Array.isArray(candidate)) {\n throw new TypeError(\n `setCookies cookie at index ${index} must be an object.`,\n );\n }\n const cookie = candidate as Record<string, unknown>;\n if (typeof cookie.name !== 'string' || !cookie.name.trim()) {\n throw new TypeError(\n `setCookies cookie at index ${index} requires a non-blank name.`,\n );\n }\n if (typeof cookie.value !== 'string') {\n throw new TypeError(\n `setCookies cookie at index ${index} requires a string value.`,\n );\n }\n\n const normalized = { ...cookie } as unknown as PlaywrightCookie;\n const hasUrl = typeof cookie.url === 'string' && cookie.url.length > 0;\n const hasDomain =\n typeof cookie.domain === 'string' && cookie.domain.length > 0;\n if (!hasUrl && !hasDomain) {\n if (defaultUrl === undefined) {\n throw new TypeError(\n `setCookies cookie at index ${index} requires url or domain, or setCookies.url must be provided.`,\n );\n }\n normalized.url = defaultUrl;\n }\n if (hasDomain && typeof cookie.path !== 'string') {\n normalized.path = '/';\n }\n return normalized;\n};\n\nconst normalizeCookies = (\n source: unknown,\n defaultUrl: string | undefined,\n): PlaywrightCookie[] => {\n const candidates = Array.isArray(source)\n ? source\n : source &&\n typeof source === 'object' &&\n Array.isArray((source as { cookies?: unknown }).cookies)\n ? (source as { cookies: unknown[] }).cookies\n : undefined;\n if (!candidates) {\n throw new TypeError(\n 'setCookies JSON must be a cookie array or an object with a cookies array.',\n );\n }\n if (candidates.length === 0) {\n throw new TypeError('setCookies source contains no cookies.');\n }\n return candidates.map((cookie, index) =>\n normalizeCookie(cookie, defaultUrl, index),\n );\n};\n\nexport const createSetCookiesNode = <TContext>(\n options: CreatePlaywrightNodesOptions<TContext>,\n): NodeDefinition<any, any, TContext> =>\n defineNode<typeof setCookiesInputSchema, SetCookiesNodeResult, TContext>({\n name: 'setCookies',\n title: 'Set browser cookies',\n description:\n 'Load cookies from an environment variable, configured profile, or Playwright storage-state file without persisting cookie values in workflow input or output.',\n stringInputKey: false,\n inputSchema: setCookiesInputSchema,\n async execute(ctx) {\n throwIfAborted(ctx.signal, 'setCookies');\n const page = await options.getPage(ctx);\n const defaultUrl =\n ctx.input.url === undefined\n ? undefined\n : resolveWebUrl(ctx.input.url, undefined, 'setCookies.url');\n const reference = toCookieSourceReference(ctx.input);\n const resolved = await resolveCookieSource(\n reference,\n defaultUrl,\n ctx,\n options,\n );\n const cookies = normalizeCookies(resolved.cookies, defaultUrl);\n\n throwIfAborted(ctx.signal, 'setCookies');\n try {\n await page.context().addCookies(cookies);\n } catch {\n throw new Error(\n `Failed to set ${cookies.length} browser cookie(s); the browser error was redacted because it may contain cookie values.`,\n );\n }\n\n const result: SetCookiesNodeResult = {\n source: resolved.reference.kind,\n sourceName: resolved.reference.name,\n count: cookies.length,\n };\n return {\n summary: `Set ${result.count} browser cookie(s) from ${result.source} source ${result.sourceName}`,\n data: result,\n };\n },\n });\n","import { z } from 'zod/v4';\nimport { defineNode } from '../node/define-node';\nimport type { NodeDefinition } from '../node/types';\nimport type { CreatePlaywrightNodesOptions } from './types';\nimport { resolveWebUrl, throwIfAborted } from './utils';\n\nconst DEFAULT_NAVIGATION_TIMEOUT_MS = 60_000;\nconst DEFAULT_WAIT_UNTIL = 'domcontentloaded' as const;\n\n/** Input schema for the Playwright gotoUrl Node. */\nexport const gotoUrlInputSchema = z.strictObject({\n url: z\n .string()\n .min(1)\n .describe('An absolute HTTP(S) URL or a path relative to baseUrl.'),\n waitUntil: z\n .enum(['commit', 'domcontentloaded', 'load', 'networkidle'])\n .default(DEFAULT_WAIT_UNTIL)\n .describe('The Playwright navigation lifecycle event to wait for.'),\n timeoutMs: z\n .number()\n .positive()\n .default(DEFAULT_NAVIGATION_TIMEOUT_MS)\n .describe('The navigation timeout in milliseconds.'),\n});\n\n/** Validated input accepted by the Playwright gotoUrl Node. */\nexport type GotoUrlNodeInput = z.infer<typeof gotoUrlInputSchema>;\n\n/** Structured navigation details returned by the Playwright gotoUrl Node. */\nexport interface GotoUrlNodeResult {\n /** Final Page URL after navigation and redirects. */\n url: string;\n /** Main-resource HTTP status, or null when Playwright returns no response. */\n status: number | null;\n /** Document title after navigation completes. */\n title: string;\n}\n\nexport const createGotoUrlNode = <TContext>(\n options: CreatePlaywrightNodesOptions<TContext>,\n): NodeDefinition<any, any, TContext> =>\n defineNode<typeof gotoUrlInputSchema, GotoUrlNodeResult, TContext>({\n name: 'gotoUrl',\n title: 'Open a Web URL',\n description:\n 'Navigate the current Playwright Page to an absolute HTTP(S) URL or a path relative to the configured baseUrl.',\n stringInputKey: 'url',\n inputSchema: gotoUrlInputSchema,\n async execute(ctx) {\n throwIfAborted(ctx.signal, 'gotoUrl');\n const page = await options.getPage(ctx);\n const baseUrl = await options.getBaseUrl?.(ctx);\n const url = resolveWebUrl(ctx.input.url, baseUrl, 'gotoUrl.url');\n const response = await page.goto(url, {\n waitUntil: ctx.input.waitUntil,\n timeout: ctx.input.timeoutMs,\n });\n const status = response?.status() ?? null;\n const result = {\n url: page.url(),\n status,\n title: await page.title(),\n };\n return { summary: `Navigated to ${result.url}`, data: result };\n },\n });\n","import { z } from 'zod/v4';\nimport { defineNode } from '../node/define-node';\nimport type { NodeDefinition } from '../node/types';\nimport type { CreatePlaywrightNodesOptions } from './types';\nimport { throwIfAborted } from './utils';\n\n/** Input schema for the Playwright setViewportSize Node. */\nexport const setViewportSizeInputSchema = z.strictObject({\n width: z.number().int().positive().describe('Viewport width in CSS pixels.'),\n height: z\n .number()\n .int()\n .positive()\n .describe('Viewport height in CSS pixels.'),\n});\n\n/** Validated input accepted by the Playwright setViewportSize Node. */\nexport type SetViewportSizeNodeInput = z.infer<\n typeof setViewportSizeInputSchema\n>;\n\nexport const createSetViewportSizeNode = <TContext>(\n options: CreatePlaywrightNodesOptions<TContext>,\n): NodeDefinition<any, any, TContext> =>\n defineNode<\n typeof setViewportSizeInputSchema,\n { width: number; height: number },\n TContext\n >({\n name: 'setViewportSize',\n title: 'Set the browser viewport size',\n description:\n 'Set the current Playwright Page viewport size in CSS pixels and return the effective size.',\n stringInputKey: false,\n inputSchema: setViewportSizeInputSchema,\n async execute(ctx) {\n throwIfAborted(ctx.signal, 'setViewportSize');\n const page = await options.getPage(ctx);\n await page.setViewportSize({\n width: ctx.input.width,\n height: ctx.input.height,\n });\n const viewport = page.viewportSize();\n if (!viewport) {\n throw new Error(\n 'Playwright did not report an effective viewport size.',\n );\n }\n return {\n summary: `Set viewport to ${viewport.width}x${viewport.height}`,\n data: viewport,\n };\n },\n });\n","import { NodeDefinitionError } from '../errors';\nimport type { NodeDefinition } from '../node/types';\nimport { createClearCookiesNode } from './clear-cookies';\nimport { createSetCookiesNode } from './cookies';\nimport { createGotoUrlNode } from './goto-url';\nimport type { CreatePlaywrightNodesOptions } from './types';\nimport { createSetViewportSizeNode } from './viewport';\n\nexport { clearCookiesInputSchema } from './clear-cookies';\nexport type { ClearCookiesNodeInput } from './clear-cookies';\nexport { setCookiesInputSchema } from './cookies';\nexport type {\n SetCookiesNodeInput,\n SetCookiesNodeResult,\n} from './cookies';\nexport { gotoUrlInputSchema } from './goto-url';\nexport type { GotoUrlNodeInput, GotoUrlNodeResult } from './goto-url';\nexport type {\n CreatePlaywrightNodesOptions,\n PlaywrightCookieProfileContext,\n} from './types';\nexport { setViewportSizeInputSchema } from './viewport';\nexport type { SetViewportSizeNodeInput } from './viewport';\n\nconst requireOptions = <TContext>(\n options: CreatePlaywrightNodesOptions<TContext>,\n) => {\n if (!options || typeof options !== 'object') {\n throw new NodeDefinitionError(\n 'createPlaywrightNodes() options must be an object.',\n );\n }\n if (typeof options.getPage !== 'function') {\n throw new NodeDefinitionError(\n 'createPlaywrightNodes() requires getPage().',\n );\n }\n};\n\n/**\n * Create the P0 Playwright preset Nodes without assuming Project Context field\n * names. Cookie values must be resolved through configured references and are\n * never accepted as inline Node input.\n */\nexport function createPlaywrightNodes<TContext>(\n options: CreatePlaywrightNodesOptions<TContext>,\n): readonly NodeDefinition<any, any, TContext>[] {\n requireOptions(options);\n return [\n createGotoUrlNode(options),\n createSetCookiesNode(options),\n createClearCookiesNode(options),\n createSetViewportSizeNode(options),\n ];\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","WorkflowError","Error","undefined","message","options","NodeDefinitionError","details","validateOptionalText","value","field","node","validateInputSchema","schema","z","validateDefinition","defineNode","SUPPORTED_WEB_PROTOCOLS","Set","throwIfAborted","signal","operation","resolveWebUrl","target","baseUrl","label","trimmed","TypeError","resolved","URL","error","clearCookiesInputSchema","createClearCookiesNode","ctx","page","filters","filterNames","setCookiesInputSchema","input","sourceCount","toCookieSourceReference","parseCookieHeader","raw","url","segments","segment","Boolean","separator","name","parseCookieJson","JSON","resolveCookieSource","reference","defaultUrl","env","process","path","resolve","readFile","normalizeCookie","candidate","index","Array","cookie","normalized","hasUrl","hasDomain","normalizeCookies","source","candidates","createSetCookiesNode","cookies","result","DEFAULT_NAVIGATION_TIMEOUT_MS","DEFAULT_WAIT_UNTIL","gotoUrlInputSchema","createGotoUrlNode","response","status","setViewportSizeInputSchema","createSetViewportSizeNode","viewport","requireOptions","createPlaywrightNodes"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;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