@vostride/agent-qa-plugin-kit 0.0.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["z","z","existsSync","join","dirname","readFileSync","format","isRecord","dirname","realpathSync","inspect","z","z","join","readFileSync","isDeepStrictEqual"],"sources":["../src/credential.ts","../src/protocol/messages.ts","../src/define-plugin.ts","../src/package-root.ts","../src/protocol/framing.ts","../src/run-plugin.ts","../src/protocol/manifest.ts","../src/emit.ts"],"sourcesContent":["import { z } from 'zod'\n\n// No pattern or format: a config holds a secret reference here, not the secret itself.\nexport function credential(description?: string) {\n return z.string().meta({ credential: true, ...(description ? { description } : {}) })\n}\n","import { z } from 'zod'\n\nexport const PLUGIN_PROTOCOL_VERSION = 1\n\nexport const PLUGIN_METHODS = [\n 'initialize',\n 'check',\n 'acquire',\n 'uploadApp',\n 'started',\n 'end',\n 'release',\n 'shutdown',\n] as const\nexport type PluginMethod = (typeof PLUGIN_METHODS)[number]\n\nexport const OPTIONAL_PLUGIN_METHODS = ['check', 'uploadApp', 'started', 'end'] as const\nexport type OptionalPluginMethod = (typeof OPTIONAL_PLUGIN_METHODS)[number]\n\nexport const PLUGIN_SERVES = ['playwright', 'cdp', 'appium'] as const\nexport type PluginServe = (typeof PLUGIN_SERVES)[number]\n\nexport const PLUGIN_RUN_FACTS = ['testName', 'runId', 'failure'] as const\nexport type PluginRunFact = (typeof PLUGIN_RUN_FACTS)[number]\n\nexport const PLUGIN_FAILURE_KINDS = [\n 'unreachable',\n 'auth',\n 'capacity',\n 'timeout',\n 'version',\n 'refused',\n 'ended',\n 'lost',\n] as const\nexport type PluginFailureKind = (typeof PLUGIN_FAILURE_KINDS)[number]\n\nexport const PLUGIN_ERROR_CODES = {\n parse: -32700,\n invalidRequest: -32600,\n methodNotFound: -32601,\n invalidParams: -32602,\n plugin: -32000,\n cancelled: -32800,\n} as const\n\nexport const CANCEL_METHOD = '$/cancel'\nexport const PROGRESS_METHOD = '$/progress'\n\nexport const MAX_MESSAGE_BYTES = 1024 * 1024\n\nconst JsonObjectSchema = z.record(z.string(), z.unknown())\nconst HandleSchema = z.json()\nconst RequestIdSchema = z.union([z.string(), z.number()])\n\nexport const InitializeParamsSchema = z.object({\n protocolVersions: z.array(z.number().int()),\n host: z.object({\n pid: z.number().int(),\n agentQaVersion: z.string(),\n playwrightVersion: z.string(),\n webdriverioVersion: z.string(),\n }),\n entry: z.string(),\n options: JsonObjectSchema,\n runFacts: z.object({ runId: z.string().optional() }).optional(),\n})\nexport type InitializeParams = z.infer<typeof InitializeParamsSchema>\n\nexport const InitializeResultSchema = z.object({\n protocolVersion: z.number().int(),\n plugin: z.object({ name: z.string(), version: z.string() }),\n serves: z.array(z.enum(PLUGIN_SERVES)),\n methods: z.array(z.enum(OPTIONAL_PLUGIN_METHODS)),\n})\nexport type InitializeResult = z.infer<typeof InitializeResultSchema>\n\nexport const CheckParamsSchema = z.object({\n remotes: z.array(z.object({ name: z.string(), settings: JsonObjectSchema })),\n})\nexport type CheckParams = z.infer<typeof CheckParamsSchema>\n\nexport const CheckResultSchema = z.object({\n state: z.enum(['ok', 'warn']),\n lines: z.array(z.string()),\n})\nexport type CheckResult = z.infer<typeof CheckResultSchema>\n\nconst WebSessionSchema = z.object({\n platform: z.literal('web'),\n engine: z.enum(['chromium', 'firefox', 'webkit']),\n context: z.enum(['new', 'reuse']),\n})\n\nconst DeviceSessionSchema = z.object({\n platform: z.enum(['android', 'ios']),\n capabilities: JsonObjectSchema,\n})\n\nexport const AcquireParamsSchema = z.object({\n remote: z.string(),\n settings: JsonObjectSchema,\n session: z.discriminatedUnion('platform', [WebSessionSchema, DeviceSessionSchema]),\n run: z.object({ testName: z.string().optional() }).optional(),\n})\nexport type AcquireParams = z.infer<typeof AcquireParamsSchema>\n\nexport const AcquireResultSchema = z.object({\n handle: HandleSchema,\n protocol: z.enum(PLUGIN_SERVES),\n url: z.string(),\n headers: z.record(z.string(), z.string()).optional(),\n capabilities: JsonObjectSchema.optional(),\n mask: z.array(z.string()).optional(),\n link: z.string().optional(),\n})\nexport type AcquireResult = z.infer<typeof AcquireResultSchema>\n\nexport const UploadAppParamsSchema = z.object({\n remote: z.string(),\n settings: JsonObjectSchema,\n platform: z.enum(['android', 'ios']),\n path: z.string(),\n sha256: z.string(),\n size: z.number().int().nonnegative(),\n})\nexport type UploadAppParams = z.infer<typeof UploadAppParamsSchema>\n\nexport const UploadAppResultSchema = z.object({ ref: z.string() })\nexport type UploadAppResult = z.infer<typeof UploadAppResultSchema>\n\nexport const StartedParamsSchema = z.object({\n handle: HandleSchema,\n sessionId: z.string().optional(),\n})\nexport type StartedParams = z.infer<typeof StartedParamsSchema>\n\nexport const StartedResultSchema = z.object({\n link: z.string().optional(),\n appiumVersion: z.string().optional(),\n})\nexport type StartedResult = z.infer<typeof StartedResultSchema>\n\nexport const EndParamsSchema = z.object({\n handle: HandleSchema,\n outcome: z.enum(['passed', 'failed', 'error', 'cancelled']),\n reason: z.string().optional(),\n})\nexport type EndParams = z.infer<typeof EndParamsSchema>\n\nexport const ReleaseParamsSchema = z.object({ handle: HandleSchema })\nexport type ReleaseParams = z.infer<typeof ReleaseParamsSchema>\n\nexport const CancelParamsSchema = z.object({ id: RequestIdSchema })\nexport type CancelParams = z.infer<typeof CancelParamsSchema>\n\nexport const ProgressParamsSchema = z.object({\n id: RequestIdSchema,\n message: z.string(),\n queued: z.number().int().nonnegative().optional(),\n percent: z.number().min(0).max(100).optional(),\n})\nexport type ProgressParams = z.infer<typeof ProgressParamsSchema>\n\nexport const PluginErrorDataSchema = z.object({\n kind: z.enum(PLUGIN_FAILURE_KINDS),\n path: z.string().optional(),\n handle: HandleSchema.optional(),\n supported: z.array(z.number().int()).optional(),\n requested: z.array(z.number().int()).optional(),\n})\nexport type PluginErrorData = z.infer<typeof PluginErrorDataSchema>\n","import type { z } from 'zod'\nimport {\n OPTIONAL_PLUGIN_METHODS,\n type AcquireParams,\n type AcquireResult,\n type CheckResult,\n type EndParams,\n type InitializeParams,\n type OptionalPluginMethod,\n type PluginFailureKind,\n type PluginRunFact,\n type PluginServe,\n type StartedParams,\n type StartedResult,\n type UploadAppParams,\n type UploadAppResult,\n} from './protocol/messages.js'\n\ntype Json = z.core.util.JSONType\ntype Awaitable<T> = T | Promise<T>\n\nexport interface PluginErrorOptions {\n kind: PluginFailureKind\n path?: string\n handle?: Json\n}\n\nexport class PluginError extends Error {\n readonly kind: PluginFailureKind\n readonly path: string | undefined\n readonly handle: Json | undefined\n\n constructor(message: string, options: PluginErrorOptions) {\n super(message)\n this.name = 'PluginError'\n this.kind = options.kind\n this.path = options.path\n this.handle = options.handle\n }\n}\n\nexport interface InitializeInput<Options> {\n options: Options\n host: InitializeParams['host']\n entry: string\n runFacts: InitializeParams['runFacts']\n}\n\nexport interface CheckInput<Options, Settings> {\n options: Options\n remotes: { name: string; settings: Settings }[]\n}\n\nexport interface AcquireInput<Options, Settings> extends Omit<AcquireParams, 'settings'> {\n options: Options\n settings: Settings\n}\n\nexport interface UploadAppInput<Options, Settings> extends Omit<UploadAppParams, 'settings'> {\n options: Options\n settings: Settings\n}\n\nexport interface StartedInput<Options> extends StartedParams {\n options: Options\n}\n\nexport interface EndInput<Options> extends EndParams {\n options: Options\n}\n\nexport interface ReleaseInput<Options> {\n options: Options\n handle: Json\n}\n\nexport interface ShutdownInput<Options> {\n options: Options\n}\n\nexport interface PluginProgress {\n message: string\n queued?: number\n percent?: number\n}\n\nexport interface PluginCallContext {\n signal: AbortSignal\n progress(update: PluginProgress): void\n runFacts: InitializeParams['runFacts']\n}\n\nexport interface PluginSpec<OptionsSchema extends z.ZodType, SettingsSchema extends z.ZodType> {\n options: OptionsSchema\n settings: SettingsSchema\n serves: readonly PluginServe[]\n runFacts?: readonly PluginRunFact[]\n skill?: string\n initialize?(\n input: InitializeInput<z.output<OptionsSchema>>,\n ctx: PluginCallContext,\n ): Awaitable<void>\n check?(\n input: CheckInput<z.output<OptionsSchema>, z.output<SettingsSchema>>,\n ctx: PluginCallContext,\n ): Awaitable<CheckResult>\n acquire(\n input: AcquireInput<z.output<OptionsSchema>, z.output<SettingsSchema>>,\n ctx: PluginCallContext,\n ): Awaitable<AcquireResult>\n uploadApp?(\n input: UploadAppInput<z.output<OptionsSchema>, z.output<SettingsSchema>>,\n ctx: PluginCallContext,\n ): Awaitable<UploadAppResult>\n started?(\n input: StartedInput<z.output<OptionsSchema>>,\n ctx: PluginCallContext,\n ): Awaitable<StartedResult>\n end?(input: EndInput<z.output<OptionsSchema>>, ctx: PluginCallContext): Awaitable<void>\n release(input: ReleaseInput<z.output<OptionsSchema>>, ctx: PluginCallContext): Awaitable<void>\n shutdown?(input: ShutdownInput<z.output<OptionsSchema>>, ctx: PluginCallContext): Awaitable<void>\n}\n\nexport interface PluginDefinition<\n OptionsSchema extends z.ZodType = z.ZodType,\n SettingsSchema extends z.ZodType = z.ZodType,\n> extends PluginSpec<OptionsSchema, SettingsSchema> {\n methods: readonly OptionalPluginMethod[]\n}\n\nexport function definePlugin<OptionsSchema extends z.ZodType, SettingsSchema extends z.ZodType>(\n spec: PluginSpec<OptionsSchema, SettingsSchema>,\n): PluginDefinition<OptionsSchema, SettingsSchema> {\n const methods = OPTIONAL_PLUGIN_METHODS.filter((method) => typeof spec[method] === 'function')\n return { ...spec, methods }\n}\n","import { existsSync, readFileSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\n\nexport function findPackageRoot(fromDir: string): string | undefined {\n let dir = fromDir\n for (;;) {\n if (existsSync(join(dir, 'package.json'))) return dir\n const parent = dirname(dir)\n if (parent === dir) return undefined\n dir = parent\n }\n}\n\nexport function readPackageJson(packageRoot: string): Record<string, unknown> {\n const parsed: unknown = JSON.parse(readFileSync(join(packageRoot, 'package.json'), 'utf8'))\n return typeof parsed === 'object' && parsed !== null ? (parsed as Record<string, unknown>) : {}\n}\n","export function encodeMessage(message: unknown): string {\n return `${JSON.stringify(message)}\\n`\n}\n\nexport interface LineDecoderOptions {\n maxLineBytes: number\n onLine: (line: string) => void\n onOverflow: () => void\n}\n\nexport interface LineDecoder {\n push(chunk: Uint8Array | string): void\n end(): void\n}\n\nconst NEWLINE = 0x0a\n\nexport function createLineDecoder({\n maxLineBytes,\n onLine,\n onOverflow,\n}: LineDecoderOptions): LineDecoder {\n const encoder = new TextEncoder()\n const decoder = new TextDecoder()\n let parts: Uint8Array[] = []\n let size = 0\n let discarding = false\n\n const append = (segment: Uint8Array) => {\n if (discarding || segment.length === 0) return\n if (size + segment.length > maxLineBytes) {\n discarding = true\n parts = []\n size = 0\n onOverflow()\n return\n }\n parts.push(new Uint8Array(segment))\n size += segment.length\n }\n\n const finishLine = () => {\n const wasDiscarding = discarding\n const lineParts = parts\n const lineSize = size\n parts = []\n size = 0\n discarding = false\n if (wasDiscarding || lineSize === 0) return\n const bytes = new Uint8Array(lineSize)\n let offset = 0\n for (const part of lineParts) {\n bytes.set(part, offset)\n offset += part.length\n }\n const line = decoder.decode(bytes).replace(/\\r$/, '')\n if (line.trim() !== '') onLine(line)\n }\n\n return {\n push(chunk) {\n const bytes = typeof chunk === 'string' ? encoder.encode(chunk) : chunk\n let start = 0\n while (start <= bytes.length) {\n const newline = bytes.indexOf(NEWLINE, start)\n if (newline === -1) {\n append(bytes.subarray(start))\n return\n }\n append(bytes.subarray(start, newline))\n finishLine()\n start = newline + 1\n }\n },\n end() {\n finishLine()\n },\n }\n}\n","import { realpathSync, writeSync } from 'node:fs'\nimport { dirname } from 'node:path'\nimport { format, inspect } from 'node:util'\nimport type { z } from 'zod'\nimport { PluginError, type PluginCallContext, type PluginDefinition } from './define-plugin.js'\nimport { findPackageRoot, readPackageJson } from './package-root.js'\nimport { createLineDecoder, encodeMessage } from './protocol/framing.js'\nimport {\n AcquireParamsSchema,\n AcquireResultSchema,\n CANCEL_METHOD,\n CancelParamsSchema,\n CheckParamsSchema,\n CheckResultSchema,\n EndParamsSchema,\n InitializeParamsSchema,\n MAX_MESSAGE_BYTES,\n OPTIONAL_PLUGIN_METHODS,\n PLUGIN_ERROR_CODES,\n PLUGIN_METHODS,\n PLUGIN_PROTOCOL_VERSION,\n PROGRESS_METHOD,\n ReleaseParamsSchema,\n StartedParamsSchema,\n StartedResultSchema,\n UploadAppParamsSchema,\n UploadAppResultSchema,\n type InitializeParams,\n type InitializeResult,\n type OptionalPluginMethod,\n type PluginMethod,\n} from './protocol/messages.js'\n\nexport interface PluginIo {\n stdin: {\n on(event: 'data', listener: (chunk: Uint8Array | string) => void): unknown\n on(event: 'end' | 'error', listener: () => void): unknown\n }\n stdout: { write(chunk: string, callback?: (error?: Error | null) => void): unknown }\n exit(code: number): void\n entryPath?: string\n cancelAnswerGraceMs: number\n hostPidPollMs: number\n}\n\ntype RequestId = string | number\ntype Json = z.core.util.JSONType\n\nexport const CANCEL_ANSWER_GRACE_MS = 4_000\nexport const HOST_PID_POLL_MS = 1_000\nconst RELEASE_ON_CLOSE_BOUND_MS = 30_000\nconst RELEASE_ON_SIGTERM_BOUND_MS = 4_000\n\nconst SUPPORTED_PROTOCOL_VERSIONS = [PLUGIN_PROTOCOL_VERSION]\n\nclass ProtocolFailure extends Error {\n constructor(\n readonly code: number,\n message: string,\n readonly data?: Record<string, unknown>,\n ) {\n super(message)\n }\n}\n\nfunction resolveIo(io: Partial<PluginIo>): PluginIo {\n return {\n stdin: io.stdin ?? process.stdin,\n stdout: io.stdout ?? process.stdout,\n exit: io.exit ?? ((code) => process.exit(code)),\n entryPath: io.entryPath ?? process.argv[1],\n cancelAnswerGraceMs: io.cancelAnswerGraceMs ?? CANCEL_ANSWER_GRACE_MS,\n hostPidPollMs: io.hostPidPollMs ?? HOST_PID_POLL_MS,\n }\n}\n\nfunction routeStrayOutputToStderr() {\n const toLog = (...args: unknown[]) => {\n process.stderr.write(`${format(...args)}\\n`)\n }\n console.log = toLog\n console.info = toLog\n console.debug = toLog\n console.warn = toLog\n process.stdout.write = process.stderr.write.bind(process.stderr) as typeof process.stdout.write\n}\n\nfunction hostGone(hostPid: number, startPpid: number): boolean {\n if (process.ppid !== startPpid) return true\n try {\n process.kill(hostPid, 0)\n return false\n } catch (error) {\n return (error as NodeJS.ErrnoException).code === 'ESRCH'\n }\n}\n\n// Handles are JSON; two handles are the same session when their JSON is equal.\nfunction handleKey(handle: Json): string {\n const canonical = (value: Json): Json => {\n if (Array.isArray(value)) return value.map(canonical)\n if (value === null || typeof value !== 'object') return value\n return Object.fromEntries(\n Object.keys(value)\n .sort()\n .map((key) => [key, canonical(value[key] as Json)]),\n )\n }\n return JSON.stringify(canonical(handle))\n}\n\nfunction within<T>(work: Promise<T>, boundMs: number): Promise<T | undefined> {\n let timer: NodeJS.Timeout | undefined\n const bound = new Promise<undefined>((resolve) => {\n timer = setTimeout(() => resolve(undefined), boundMs)\n })\n return Promise.race([work, bound]).finally(() => clearTimeout(timer))\n}\n\ntype Outcome = { ok: true; value: unknown } | { ok: false; error: unknown }\n\ninterface PendingCall {\n method: string\n controller: AbortController\n answered: boolean\n graceTimer?: NodeJS.Timeout\n}\n\nfunction firstLine(message: string): string {\n return message.split(/\\r?\\n/, 1)[0] ?? ''\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction isRequestId(value: unknown): value is RequestId {\n return typeof value === 'string' || typeof value === 'number'\n}\n\nfunction isPluginMethod(method: string): method is PluginMethod {\n return (PLUGIN_METHODS as readonly string[]).includes(method)\n}\n\nfunction isOptionalMethod(method: PluginMethod): method is OptionalPluginMethod {\n return (OPTIONAL_PLUGIN_METHODS as readonly string[]).includes(method)\n}\n\nfunction issuePath(issue: z.core.$ZodIssue): string {\n return issue.path.map(String).join('.')\n}\n\nfunction parseParams<Schema extends z.ZodType>(\n schema: Schema,\n params: unknown,\n method: string,\n): z.output<Schema> {\n const parsed = schema.safeParse(params ?? {})\n if (parsed.success) return parsed.data\n const issue = parsed.error.issues[0]\n const where = issue === undefined ? '' : issuePath(issue)\n throw new ProtocolFailure(\n PLUGIN_ERROR_CODES.invalidParams,\n `${method} params${where === '' ? '' : ` at ${where}`}: ${issue?.message ?? 'invalid'}`,\n )\n}\n\n// A refusal's path starts with options. or settings., naming the block that holds the field.\nfunction refuse(schema: z.ZodType, value: unknown, prefix: 'options' | 'settings'): unknown {\n const parsed = schema.safeParse(value)\n if (parsed.success) return parsed.data\n const issue = parsed.error.issues[0]\n const inner = issue === undefined ? '' : issuePath(issue)\n const path = inner === '' ? undefined : `${prefix}.${inner}`\n throw new PluginError(`${path ?? prefix}: ${issue?.message ?? 'invalid'}`, {\n kind: 'refused',\n ...(path === undefined ? {} : { path }),\n })\n}\n\nfunction checkedResult(schema: z.ZodType, value: unknown, method: string): unknown {\n const parsed = schema.safeParse(value)\n if (parsed.success) return value\n const issue = parsed.error.issues[0]\n const where = issue === undefined ? '' : issuePath(issue)\n const handle =\n method === 'acquire' && isRecord(value) && value.handle !== undefined\n ? (value.handle as Json)\n : undefined\n throw new PluginError(\n `${method} answered a malformed result${where === '' ? '' : ` at ${where}`}: ${issue?.message ?? 'invalid'}`,\n { kind: 'refused', ...(handle === undefined ? {} : { handle }) },\n )\n}\n\nfunction pluginIdentity(entryPath: string | undefined): InitializeResult['plugin'] {\n const unknown = { name: 'unknown', version: 'unknown' }\n if (entryPath === undefined) return unknown\n try {\n const root = findPackageRoot(dirname(realpathSync(entryPath)))\n if (root === undefined) return unknown\n const pkg = readPackageJson(root)\n return {\n name: typeof pkg.name === 'string' ? pkg.name : unknown.name,\n version: typeof pkg.version === 'string' ? pkg.version : unknown.version,\n }\n } catch {\n return unknown\n }\n}\n\nexport function runPlugin<OptionsSchema extends z.ZodType, SettingsSchema extends z.ZodType>(\n definition: PluginDefinition<OptionsSchema, SettingsSchema>,\n ioInput: Partial<PluginIo> = {},\n): void {\n const io = resolveIo(ioInput)\n const write = io.stdout.write.bind(io.stdout)\n // A caller that brings its own stdout keeps the process's console, streams and signals.\n const ownsProcess = ioInput.stdout === undefined\n if (ownsProcess) {\n routeStrayOutputToStderr()\n // Once the host is gone its pipes have no reader; EPIPE must not stop the releases.\n process.stdout.on('error', () => {})\n process.stderr.on('error', () => {})\n process.on('SIGINT', () => {})\n // Node's own report starts with the throwing source line, and the host takes stderr's first\n // line as the crash's reason.\n process.on('uncaughtException', (error) => {\n try {\n writeSync(2, `${inspect(error)}\\n`)\n } catch {}\n process.exit(1)\n })\n }\n\n const send = (message: Record<string, unknown>) => {\n if (leaving) return\n write(encodeMessage(message))\n }\n const answer = (id: RequestId, result: unknown) => send({ jsonrpc: '2.0', id, result })\n const fail = (\n id: RequestId | null,\n code: number,\n message: string,\n data?: Record<string, unknown>,\n ) =>\n send({\n jsonrpc: '2.0',\n id,\n error: { code, message: firstLine(message), ...(data === undefined ? {} : { data }) },\n })\n\n let options: z.output<OptionsSchema> | undefined\n let runFacts: InitializeParams['runFacts']\n let initialized = false\n let initializing = false\n let shutdownRan = false\n let leaving = false\n let hostPoll: NodeJS.Timeout | undefined\n const startPpid = process.ppid\n const pending = new Map<RequestId, PendingCall>()\n const inFlight = new Set<Promise<void>>()\n const held = new Map<string, Json>()\n const releasing = new Map<string, Promise<void>>()\n\n const detachedContext = (): PluginCallContext => ({\n signal: new AbortController().signal,\n progress: () => {},\n runFacts,\n })\n\n const hold = (handle: Json) => held.set(handleKey(handle), handle)\n\n // One release per handle at a time, whether the host or the kit asked for it.\n const releaseOnce = (handle: Json, ctx: PluginCallContext): Promise<void> => {\n const key = handleKey(handle)\n const running = releasing.get(key)\n if (running !== undefined) return running\n const work = (async () => {\n try {\n await definition.release({ handle, options: options as z.output<OptionsSchema> }, ctx)\n held.delete(key)\n } finally {\n releasing.delete(key)\n }\n })()\n releasing.set(key, work)\n return work\n }\n\n const releaseHeld = (attempted: Set<string>) =>\n Promise.allSettled(\n [...held]\n .filter(([key]) => !attempted.has(key))\n .map(([key, handle]) => {\n attempted.add(key)\n return releaseOnce(handle, detachedContext())\n }),\n )\n\n const settings = (value: unknown) =>\n refuse(definition.settings, value, 'settings') as z.output<SettingsSchema>\n\n const leave = async (boundMs: number) => {\n if (leaving) return\n leaving = true\n clearInterval(hostPoll)\n const sequence = async () => {\n if (!initialized) return\n for (const entry of pending.values()) {\n if (entry.method !== 'release' && entry.method !== 'shutdown') entry.controller.abort()\n }\n // A call still running may yet create a session; it lands in held and is released here.\n const attempted = new Set<string>()\n await Promise.allSettled([releaseHeld(attempted), ...inFlight])\n await releaseHeld(attempted)\n if (shutdownRan) return\n shutdownRan = true\n await definition.shutdown?.(\n { options: options as z.output<OptionsSchema> },\n detachedContext(),\n )\n }\n await within(\n sequence().catch(() => {}),\n boundMs,\n )\n write('', () => io.exit(0))\n }\n\n const watchHost = (hostPid: number) => {\n hostPoll = setInterval(() => {\n if (hostGone(hostPid, startPpid)) void leave(RELEASE_ON_CLOSE_BOUND_MS)\n }, io.hostPidPollMs)\n hostPoll.unref()\n }\n\n const initialize = async (params: unknown, ctx: PluginCallContext): Promise<InitializeResult> => {\n if (initialized || initializing) {\n throw new ProtocolFailure(PLUGIN_ERROR_CODES.invalidRequest, 'initialize was already called')\n }\n const input = parseParams(InitializeParamsSchema, params, 'initialize')\n const offered = input.protocolVersions.filter((version) =>\n SUPPORTED_PROTOCOL_VERSIONS.includes(version),\n )\n if (offered.length === 0) {\n throw new ProtocolFailure(\n PLUGIN_ERROR_CODES.plugin,\n `this plugin speaks protocol ${SUPPORTED_PROTOCOL_VERSIONS.join(', ')}, and the host offered ${input.protocolVersions.join(', ') || 'none'}`,\n {\n kind: 'version',\n supported: SUPPORTED_PROTOCOL_VERSIONS,\n requested: input.protocolVersions,\n },\n )\n }\n const parsedOptions = refuse(definition.options, input.options, 'options') as z.output<OptionsSchema>\n initializing = true\n try {\n await definition.initialize?.(\n {\n options: parsedOptions,\n host: input.host,\n entry: input.entry,\n runFacts: input.runFacts,\n },\n { ...ctx, runFacts: input.runFacts },\n )\n } finally {\n initializing = false\n }\n options = parsedOptions\n runFacts = input.runFacts\n initialized = true\n watchHost(input.host.pid)\n return {\n protocolVersion: Math.max(...offered),\n plugin: pluginIdentity(io.entryPath),\n serves: [...definition.serves],\n methods: [...definition.methods],\n }\n }\n\n const call = async (\n method: string,\n params: unknown,\n ctx: PluginCallContext,\n ): Promise<unknown> => {\n if (method === 'initialize') return initialize(params, ctx)\n if (\n !isPluginMethod(method) ||\n (isOptionalMethod(method) &&\n (!definition.methods.includes(method) || typeof definition[method] !== 'function'))\n ) {\n throw new ProtocolFailure(\n PLUGIN_ERROR_CODES.methodNotFound,\n `${method} is not a method of this plugin`,\n )\n }\n if (!initialized) {\n throw new ProtocolFailure(\n PLUGIN_ERROR_CODES.invalidRequest,\n `${method} came before initialize`,\n )\n }\n const current = options as z.output<OptionsSchema>\n switch (method) {\n case 'acquire': {\n const input = parseParams(AcquireParamsSchema, params, method)\n const result = await definition.acquire(\n { ...input, settings: settings(input.settings), options: current },\n ctx,\n )\n return checkedResult(AcquireResultSchema, result, method)\n }\n case 'release': {\n const input = parseParams(ReleaseParamsSchema, params, method)\n await releaseOnce(input.handle, ctx)\n return {}\n }\n case 'shutdown': {\n shutdownRan = true\n // A handle whose release failed is still held; shutdown may dispose what releasing needs.\n await releaseHeld(new Set())\n await definition.shutdown?.({ options: current }, ctx)\n return {}\n }\n case 'check': {\n const input = parseParams(CheckParamsSchema, params, method)\n const remotes = input.remotes.map((remote) => ({\n name: remote.name,\n settings: settings(remote.settings),\n }))\n const result = await definition.check?.({ remotes, options: current }, ctx)\n return checkedResult(CheckResultSchema, result, method)\n }\n case 'uploadApp': {\n const input = parseParams(UploadAppParamsSchema, params, method)\n const result = await definition.uploadApp?.(\n { ...input, settings: settings(input.settings), options: current },\n ctx,\n )\n return checkedResult(UploadAppResultSchema, result, method)\n }\n case 'started': {\n const input = parseParams(StartedParamsSchema, params, method)\n const result = await definition.started?.({ ...input, options: current }, ctx)\n return checkedResult(StartedResultSchema, result, method)\n }\n case 'end': {\n const input = parseParams(EndParamsSchema, params, method)\n await definition.end?.({ ...input, options: current }, ctx)\n return {}\n }\n default:\n throw new ProtocolFailure(\n PLUGIN_ERROR_CODES.methodNotFound,\n `${method} is not a method of this plugin`,\n )\n }\n }\n\n const createdHandle = (method: string, outcome: Outcome): Json | undefined => {\n if (outcome.ok) {\n if (method !== 'acquire' || !isRecord(outcome.value)) return undefined\n return outcome.value.handle as Json | undefined\n }\n return outcome.error instanceof PluginError ? outcome.error.handle : undefined\n }\n\n const answerFailure = (id: RequestId, error: unknown) => {\n if (error instanceof ProtocolFailure) {\n fail(id, error.code, error.message, error.data)\n } else if (error instanceof PluginError) {\n fail(id, PLUGIN_ERROR_CODES.plugin, error.message, {\n kind: error.kind,\n ...(error.path === undefined ? {} : { path: error.path }),\n ...(error.handle === undefined ? {} : { handle: error.handle }),\n })\n } else {\n const message = error instanceof Error ? error.message : String(error)\n fail(id, PLUGIN_ERROR_CODES.plugin, message, { kind: 'unreachable' })\n }\n }\n\n const dispatch = async (id: RequestId, method: string, params: unknown) => {\n const entry: PendingCall = { method, controller: new AbortController(), answered: false }\n pending.set(id, entry)\n const ctx: PluginCallContext = {\n signal: entry.controller.signal,\n progress: (update) => {\n if (entry.answered) return\n send({ jsonrpc: '2.0', method: PROGRESS_METHOD, params: { id, ...update } })\n },\n runFacts,\n }\n let outcome: Outcome\n try {\n outcome = { ok: true, value: await call(method, params, ctx) }\n } catch (error) {\n outcome = { ok: false, error }\n }\n clearTimeout(entry.graceTimer)\n if (pending.get(id) === entry) pending.delete(id)\n const handle = createdHandle(method, outcome)\n const tracked = initialized ? handle : undefined\n if (tracked !== undefined) hold(tracked)\n if (entry.answered) {\n // The cancel was already answered without this handle, so nobody else will release it.\n if (tracked !== undefined) await releaseOnce(tracked, detachedContext()).catch(() => {})\n return\n }\n if (leaving) return\n entry.answered = true\n if (outcome.ok) {\n answer(id, outcome.value)\n } else if (entry.controller.signal.aborted) {\n const message = outcome.error instanceof Error ? outcome.error.message : String(outcome.error)\n fail(id, PLUGIN_ERROR_CODES.cancelled, message, {\n kind: 'timeout',\n ...(handle === undefined ? {} : { handle }),\n })\n } else {\n answerFailure(id, outcome.error)\n }\n }\n\n const cancel = (params: unknown) => {\n const parsed = CancelParamsSchema.safeParse(params)\n if (!parsed.success) return\n const { id } = parsed.data\n const entry = pending.get(id)\n if (entry === undefined || entry.controller.signal.aborted) return\n entry.controller.abort()\n entry.graceTimer = setTimeout(() => {\n if (entry.answered) return\n entry.answered = true\n fail(\n id,\n PLUGIN_ERROR_CODES.cancelled,\n `${entry.method} did not stop within ${io.cancelAnswerGraceMs} ms of its cancel`,\n { kind: 'timeout' },\n )\n }, io.cancelAnswerGraceMs)\n }\n\n const handleLine = (line: string) => {\n let message: unknown\n try {\n message = JSON.parse(line)\n } catch {\n fail(null, PLUGIN_ERROR_CODES.parse, 'the line is not JSON')\n return\n }\n if (!isRecord(message)) {\n fail(null, PLUGIN_ERROR_CODES.invalidRequest, 'a message must be a JSON-RPC 2.0 object')\n return\n }\n const id = isRequestId(message.id) ? message.id : null\n if (message.method === undefined && ('result' in message || 'error' in message)) return\n if (message.jsonrpc !== '2.0' || typeof message.method !== 'string') {\n fail(id, PLUGIN_ERROR_CODES.invalidRequest, 'a request needs jsonrpc \"2.0\" and a method')\n return\n }\n if (!('id' in message)) {\n if (message.method === CANCEL_METHOD) cancel(message.params)\n return\n }\n if (id === null) {\n fail(null, PLUGIN_ERROR_CODES.invalidRequest, 'a request id is a string or a number')\n return\n }\n if (leaving) return\n const run = dispatch(id, message.method, message.params)\n inFlight.add(run)\n void run.catch(() => {}).finally(() => inFlight.delete(run))\n }\n\n const decoder = createLineDecoder({\n maxLineBytes: MAX_MESSAGE_BYTES,\n onLine: handleLine,\n onOverflow: () =>\n fail(\n null,\n PLUGIN_ERROR_CODES.invalidRequest,\n `a message is longer than ${MAX_MESSAGE_BYTES} bytes`,\n ),\n })\n\n const stdinClosed = () => {\n if (leaving) return\n decoder.end()\n void leave(RELEASE_ON_CLOSE_BOUND_MS)\n }\n\n if (ownsProcess) process.on('SIGTERM', () => void leave(RELEASE_ON_SIGTERM_BOUND_MS))\n io.stdin.on('data', (chunk) => decoder.push(chunk))\n io.stdin.on('end', stdinClosed)\n io.stdin.on('error', stdinClosed)\n}\n","import { z } from 'zod'\nimport { OPTIONAL_PLUGIN_METHODS, PLUGIN_RUN_FACTS, PLUGIN_SERVES } from './messages.js'\n\n// The manifest sits at package.json[\"agent-qa\"].plugin.\nexport const PLUGIN_MANIFEST_FIELD = 'agent-qa'\n\nconst PackagePathSchema = z.string().min(1)\n\nconst RemotePluginManifestSchema = z.strictObject({\n kind: z.literal('remote'),\n runs: z.literal('process'),\n protocol: z.number().int().positive(),\n entry: PackagePathSchema,\n serves: z.array(z.enum(PLUGIN_SERVES)).nonempty(),\n methods: z.array(z.enum(OPTIONAL_PLUGIN_METHODS)),\n options: PackagePathSchema,\n settings: PackagePathSchema,\n runFacts: z.array(z.enum(PLUGIN_RUN_FACTS)).optional(),\n skill: PackagePathSchema.optional(),\n})\n\nconst ModelAuthManifestSchema = z.strictObject({\n kind: z.literal('model-auth'),\n runs: z.literal('in-process'),\n entry: PackagePathSchema,\n options: PackagePathSchema.optional(),\n})\n\nconst ModelProviderManifestSchema = z.strictObject({\n kind: z.literal('model-provider'),\n runs: z.literal('in-process'),\n entry: PackagePathSchema,\n options: PackagePathSchema.optional(),\n})\n\nexport const PluginManifestSchema = z.discriminatedUnion('kind', [\n RemotePluginManifestSchema,\n ModelAuthManifestSchema,\n ModelProviderManifestSchema,\n])\nexport type PluginManifest = z.infer<typeof PluginManifestSchema>\nexport type RemotePluginManifest = z.infer<typeof RemotePluginManifestSchema>\n","import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { isDeepStrictEqual } from 'node:util'\nimport { z } from 'zod'\nimport type { PluginDefinition } from './define-plugin.js'\nimport {\n PLUGIN_MANIFEST_FIELD,\n PluginManifestSchema,\n type RemotePluginManifest,\n} from './protocol/manifest.js'\nimport { PLUGIN_PROTOCOL_VERSION } from './protocol/messages.js'\n\nexport interface EmitPluginFilesInput<\n OptionsSchema extends z.ZodType,\n SettingsSchema extends z.ZodType,\n> {\n definition: PluginDefinition<OptionsSchema, SettingsSchema>\n packageDir: string\n}\n\nexport interface EmittedPluginFiles {\n manifest: RemotePluginManifest\n optionsSchemaFile: string\n settingsSchemaFile: string\n packageJsonChanged: boolean\n}\n\nconst OPTIONS_SCHEMA_PATH = './dist/options.schema.json'\nconst SETTINGS_SCHEMA_PATH = './dist/settings.schema.json'\n\nexport function pluginManifest<OptionsSchema extends z.ZodType, SettingsSchema extends z.ZodType>(\n definition: PluginDefinition<OptionsSchema, SettingsSchema>,\n): RemotePluginManifest {\n const manifest = PluginManifestSchema.parse({\n protocol: PLUGIN_PROTOCOL_VERSION,\n kind: 'remote',\n runs: 'process',\n entry: './dist/main.js',\n serves: [...definition.serves],\n methods: [...definition.methods],\n options: OPTIONS_SCHEMA_PATH,\n settings: SETTINGS_SCHEMA_PATH,\n ...(definition.runFacts === undefined ? {} : { runFacts: [...definition.runFacts] }),\n ...(definition.skill === undefined ? {} : { skill: definition.skill }),\n })\n if (manifest.kind !== 'remote') throw new Error('a plugin built with the kit is remote')\n return manifest\n}\n\nfunction schemaText(schema: z.ZodType): string {\n return `${JSON.stringify(z.toJSONSchema(schema, { io: 'input', target: 'draft-2020-12' }), null, 2)}\\n`\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nexport function emitPluginFiles<OptionsSchema extends z.ZodType, SettingsSchema extends z.ZodType>(\n input: EmitPluginFilesInput<OptionsSchema, SettingsSchema>,\n): EmittedPluginFiles {\n const { definition, packageDir } = input\n const manifest = pluginManifest(definition)\n const optionsSchemaFile = join(packageDir, OPTIONS_SCHEMA_PATH)\n const settingsSchemaFile = join(packageDir, SETTINGS_SCHEMA_PATH)\n mkdirSync(join(packageDir, 'dist'), { recursive: true })\n writeFileSync(optionsSchemaFile, schemaText(definition.options))\n writeFileSync(settingsSchemaFile, schemaText(definition.settings))\n\n const packageJsonFile = join(packageDir, 'package.json')\n const parsed: unknown = JSON.parse(readFileSync(packageJsonFile, 'utf8'))\n if (!isRecord(parsed)) throw new Error(`${packageJsonFile} is not a JSON object`)\n const field = isRecord(parsed[PLUGIN_MANIFEST_FIELD]) ? parsed[PLUGIN_MANIFEST_FIELD] : {}\n const packageJsonChanged = !isDeepStrictEqual(field.plugin, manifest)\n if (packageJsonChanged) {\n const next = { ...parsed, [PLUGIN_MANIFEST_FIELD]: { ...field, plugin: manifest } }\n writeFileSync(packageJsonFile, `${JSON.stringify(next, null, 2)}\\n`)\n }\n return { manifest, optionsSchemaFile, settingsSchemaFile, packageJsonChanged }\n}\n"],"mappings":";;;;;;AAGA,SAAgB,WAAW,aAAsB;CAC/C,OAAOA,IAAAA,EAAE,OAAO,CAAC,CAAC,KAAK;EAAE,YAAY;EAAM,GAAI,cAAc,EAAE,YAAY,IAAI,CAAC;CAAG,CAAC;AACtF;;ACDA,MAAa,iBAAiB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAGA,MAAa,0BAA0B;CAAC;CAAS;CAAa;CAAW;AAAK;AAG9E,MAAa,gBAAgB;CAAC;CAAc;CAAO;AAAQ;AAG3D,MAAa,mBAAmB;CAAC;CAAY;CAAS;AAAS;AAG/D,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAGA,MAAa,qBAAqB;CAChC,OAAO;CACP,gBAAgB;CAChB,gBAAgB;CAChB,eAAe;CACf,QAAQ;CACR,WAAW;AACb;AAGA,MAAa,kBAAkB;AAE/B,MAAa,oBAAoB;AAEjC,MAAM,mBAAmBC,IAAAA,EAAE,OAAOA,IAAAA,EAAE,OAAO,GAAGA,IAAAA,EAAE,QAAQ,CAAC;AACzD,MAAM,eAAeA,IAAAA,EAAE,KAAK;AAC5B,MAAM,kBAAkBA,IAAAA,EAAE,MAAM,CAACA,IAAAA,EAAE,OAAO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OAAO,yBAAyB,CAAC;CACzF,MAAM,qBAAqB,EAAA,GAACC,UAAAA,kBAAAA,CAAkB,MAAM,QAAQ,QAAQ;CACpE,IAAI,oBAAoB;EACtB,MAAM,OAAO;GAAE,GAAG;IAAS,wBAAwB;IAAE,GAAG;IAAO,QAAQ;GAAS;EAAE;EAClF,CAAA,GAAA,QAAA,cAAA,CAAc,iBAAiB,GAAG,KAAK,UAAU,MAAM,MAAM,CAAC,EAAE,GAAG;CACrE;CACA,OAAO;EAAE;EAAU;EAAmB;EAAoB;CAAmB;AAC/E"}
@@ -0,0 +1,241 @@
1
+ import { z, z as z$1 } from "zod";
2
+ export declare function credential(description?: string): z$1.ZodString;
3
+ declare const OPTIONAL_PLUGIN_METHODS: readonly ['check', 'uploadApp', 'started', 'end'];
4
+ type OptionalPluginMethod = (typeof OPTIONAL_PLUGIN_METHODS)[number];
5
+ declare const PLUGIN_SERVES: readonly ['playwright', 'cdp', 'appium'];
6
+ type PluginServe = (typeof PLUGIN_SERVES)[number];
7
+ declare const PLUGIN_RUN_FACTS: readonly ['testName', 'runId', 'failure'];
8
+ type PluginRunFact = (typeof PLUGIN_RUN_FACTS)[number];
9
+ declare const PLUGIN_FAILURE_KINDS: readonly ['unreachable', 'auth', 'capacity', 'timeout', 'version', 'refused', 'ended', 'lost'];
10
+ type PluginFailureKind = (typeof PLUGIN_FAILURE_KINDS)[number];
11
+ declare const InitializeParamsSchema: z$1.ZodObject<{
12
+ protocolVersions: z$1.ZodArray<z$1.ZodNumber>;
13
+ host: z$1.ZodObject<{
14
+ pid: z$1.ZodNumber;
15
+ agentQaVersion: z$1.ZodString;
16
+ playwrightVersion: z$1.ZodString;
17
+ webdriverioVersion: z$1.ZodString;
18
+ }, z$1.core.$strip>;
19
+ entry: z$1.ZodString;
20
+ options: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
21
+ runFacts: z$1.ZodOptional<z$1.ZodObject<{
22
+ runId: z$1.ZodOptional<z$1.ZodString>;
23
+ }, z$1.core.$strip>>;
24
+ }, z$1.core.$strip>;
25
+ type InitializeParams = z$1.infer<typeof InitializeParamsSchema>;
26
+ declare const CheckResultSchema: z$1.ZodObject<{
27
+ state: z$1.ZodEnum<{
28
+ ok: "ok";
29
+ warn: "warn";
30
+ }>;
31
+ lines: z$1.ZodArray<z$1.ZodString>;
32
+ }, z$1.core.$strip>;
33
+ type CheckResult = z$1.infer<typeof CheckResultSchema>;
34
+ declare const AcquireParamsSchema: z$1.ZodObject<{
35
+ remote: z$1.ZodString;
36
+ settings: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
37
+ session: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
38
+ platform: z$1.ZodLiteral<"web">;
39
+ engine: z$1.ZodEnum<{
40
+ chromium: "chromium";
41
+ firefox: "firefox";
42
+ webkit: "webkit";
43
+ }>;
44
+ context: z$1.ZodEnum<{
45
+ new: "new";
46
+ reuse: "reuse";
47
+ }>;
48
+ }, z$1.core.$strip>, z$1.ZodObject<{
49
+ platform: z$1.ZodEnum<{
50
+ android: "android";
51
+ ios: "ios";
52
+ }>;
53
+ capabilities: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
54
+ }, z$1.core.$strip>], "platform">;
55
+ run: z$1.ZodOptional<z$1.ZodObject<{
56
+ testName: z$1.ZodOptional<z$1.ZodString>;
57
+ }, z$1.core.$strip>>;
58
+ }, z$1.core.$strip>;
59
+ type AcquireParams = z$1.infer<typeof AcquireParamsSchema>;
60
+ declare const AcquireResultSchema: z$1.ZodObject<{
61
+ handle: z$1.ZodJSONSchema;
62
+ protocol: z$1.ZodEnum<{
63
+ appium: "appium";
64
+ cdp: "cdp";
65
+ playwright: "playwright";
66
+ }>;
67
+ url: z$1.ZodString;
68
+ headers: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
69
+ capabilities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
70
+ mask: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
71
+ link: z$1.ZodOptional<z$1.ZodString>;
72
+ }, z$1.core.$strip>;
73
+ type AcquireResult = z$1.infer<typeof AcquireResultSchema>;
74
+ declare const UploadAppParamsSchema: z$1.ZodObject<{
75
+ remote: z$1.ZodString;
76
+ settings: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
77
+ platform: z$1.ZodEnum<{
78
+ android: "android";
79
+ ios: "ios";
80
+ }>;
81
+ path: z$1.ZodString;
82
+ sha256: z$1.ZodString;
83
+ size: z$1.ZodNumber;
84
+ }, z$1.core.$strip>;
85
+ type UploadAppParams = z$1.infer<typeof UploadAppParamsSchema>;
86
+ declare const UploadAppResultSchema: z$1.ZodObject<{
87
+ ref: z$1.ZodString;
88
+ }, z$1.core.$strip>;
89
+ type UploadAppResult = z$1.infer<typeof UploadAppResultSchema>;
90
+ declare const StartedParamsSchema: z$1.ZodObject<{
91
+ handle: z$1.ZodJSONSchema;
92
+ sessionId: z$1.ZodOptional<z$1.ZodString>;
93
+ }, z$1.core.$strip>;
94
+ type StartedParams = z$1.infer<typeof StartedParamsSchema>;
95
+ declare const StartedResultSchema: z$1.ZodObject<{
96
+ link: z$1.ZodOptional<z$1.ZodString>;
97
+ appiumVersion: z$1.ZodOptional<z$1.ZodString>;
98
+ }, z$1.core.$strip>;
99
+ type StartedResult = z$1.infer<typeof StartedResultSchema>;
100
+ declare const EndParamsSchema: z$1.ZodObject<{
101
+ handle: z$1.ZodJSONSchema;
102
+ outcome: z$1.ZodEnum<{
103
+ cancelled: "cancelled";
104
+ error: "error";
105
+ failed: "failed";
106
+ passed: "passed";
107
+ }>;
108
+ reason: z$1.ZodOptional<z$1.ZodString>;
109
+ }, z$1.core.$strip>;
110
+ type EndParams = z$1.infer<typeof EndParamsSchema>;
111
+ type Json = z$1.core.util.JSONType;
112
+ type Awaitable<T> = T | Promise<T>;
113
+ interface PluginErrorOptions {
114
+ kind: PluginFailureKind;
115
+ path?: string;
116
+ handle?: Json;
117
+ }
118
+ export declare class PluginError extends Error {
119
+ readonly kind: PluginFailureKind;
120
+ readonly path: string | undefined;
121
+ readonly handle: Json | undefined;
122
+ constructor(message: string, options: PluginErrorOptions);
123
+ }
124
+ interface InitializeInput<Options> {
125
+ options: Options;
126
+ host: InitializeParams['host'];
127
+ entry: string;
128
+ runFacts: InitializeParams['runFacts'];
129
+ }
130
+ interface CheckInput<Options, Settings> {
131
+ options: Options;
132
+ remotes: {
133
+ name: string;
134
+ settings: Settings;
135
+ }[];
136
+ }
137
+ interface AcquireInput<Options, Settings> extends Omit<AcquireParams, 'settings'> {
138
+ options: Options;
139
+ settings: Settings;
140
+ }
141
+ interface UploadAppInput<Options, Settings> extends Omit<UploadAppParams, 'settings'> {
142
+ options: Options;
143
+ settings: Settings;
144
+ }
145
+ interface StartedInput<Options> extends StartedParams {
146
+ options: Options;
147
+ }
148
+ interface EndInput<Options> extends EndParams {
149
+ options: Options;
150
+ }
151
+ interface ReleaseInput<Options> {
152
+ options: Options;
153
+ handle: Json;
154
+ }
155
+ interface ShutdownInput<Options> {
156
+ options: Options;
157
+ }
158
+ interface PluginProgress {
159
+ message: string;
160
+ queued?: number;
161
+ percent?: number;
162
+ }
163
+ interface PluginCallContext {
164
+ signal: AbortSignal;
165
+ progress(update: PluginProgress): void;
166
+ runFacts: InitializeParams['runFacts'];
167
+ }
168
+ interface PluginSpec<OptionsSchema extends z$1.ZodType, SettingsSchema extends z$1.ZodType> {
169
+ options: OptionsSchema;
170
+ settings: SettingsSchema;
171
+ serves: readonly PluginServe[];
172
+ runFacts?: readonly PluginRunFact[];
173
+ skill?: string;
174
+ initialize?(input: InitializeInput<z$1.output<OptionsSchema>>, ctx: PluginCallContext): Awaitable<void>;
175
+ check?(input: CheckInput<z$1.output<OptionsSchema>, z$1.output<SettingsSchema>>, ctx: PluginCallContext): Awaitable<CheckResult>;
176
+ acquire(input: AcquireInput<z$1.output<OptionsSchema>, z$1.output<SettingsSchema>>, ctx: PluginCallContext): Awaitable<AcquireResult>;
177
+ uploadApp?(input: UploadAppInput<z$1.output<OptionsSchema>, z$1.output<SettingsSchema>>, ctx: PluginCallContext): Awaitable<UploadAppResult>;
178
+ started?(input: StartedInput<z$1.output<OptionsSchema>>, ctx: PluginCallContext): Awaitable<StartedResult>;
179
+ end?(input: EndInput<z$1.output<OptionsSchema>>, ctx: PluginCallContext): Awaitable<void>;
180
+ release(input: ReleaseInput<z$1.output<OptionsSchema>>, ctx: PluginCallContext): Awaitable<void>;
181
+ shutdown?(input: ShutdownInput<z$1.output<OptionsSchema>>, ctx: PluginCallContext): Awaitable<void>;
182
+ }
183
+ interface PluginDefinition<OptionsSchema extends z$1.ZodType = z$1.ZodType, SettingsSchema extends z$1.ZodType = z$1.ZodType> extends PluginSpec<OptionsSchema, SettingsSchema> {
184
+ methods: readonly OptionalPluginMethod[];
185
+ }
186
+ export declare function definePlugin<OptionsSchema extends z$1.ZodType, SettingsSchema extends z$1.ZodType>(spec: PluginSpec<OptionsSchema, SettingsSchema>): PluginDefinition<OptionsSchema, SettingsSchema>;
187
+ interface PluginIo {
188
+ stdin: {
189
+ on(event: 'data', listener: (chunk: Uint8Array | string) => void): unknown;
190
+ on(event: 'end' | 'error', listener: () => void): unknown;
191
+ };
192
+ stdout: {
193
+ write(chunk: string, callback?: (error?: Error | null) => void): unknown;
194
+ };
195
+ exit(code: number): void;
196
+ entryPath?: string;
197
+ cancelAnswerGraceMs: number;
198
+ hostPidPollMs: number;
199
+ }
200
+ export declare const CANCEL_ANSWER_GRACE_MS = 4000;
201
+ export declare const HOST_PID_POLL_MS = 1000;
202
+ export declare function runPlugin<OptionsSchema extends z$1.ZodType, SettingsSchema extends z$1.ZodType>(definition: PluginDefinition<OptionsSchema, SettingsSchema>, ioInput?: Partial<PluginIo>): void;
203
+ declare const RemotePluginManifestSchema: z$1.ZodObject<{
204
+ kind: z$1.ZodLiteral<"remote">;
205
+ runs: z$1.ZodLiteral<"process">;
206
+ protocol: z$1.ZodNumber;
207
+ entry: z$1.ZodString;
208
+ serves: z$1.ZodArray<z$1.ZodEnum<{
209
+ appium: "appium";
210
+ cdp: "cdp";
211
+ playwright: "playwright";
212
+ }>>;
213
+ methods: z$1.ZodArray<z$1.ZodEnum<{
214
+ check: "check";
215
+ end: "end";
216
+ started: "started";
217
+ uploadApp: "uploadApp";
218
+ }>>;
219
+ options: z$1.ZodString;
220
+ settings: z$1.ZodString;
221
+ runFacts: z$1.ZodOptional<z$1.ZodArray<z$1.ZodEnum<{
222
+ failure: "failure";
223
+ runId: "runId";
224
+ testName: "testName";
225
+ }>>>;
226
+ skill: z$1.ZodOptional<z$1.ZodString>;
227
+ }, z$1.core.$strict>;
228
+ type RemotePluginManifest = z$1.infer<typeof RemotePluginManifestSchema>;
229
+ interface EmitPluginFilesInput<OptionsSchema extends z$1.ZodType, SettingsSchema extends z$1.ZodType> {
230
+ definition: PluginDefinition<OptionsSchema, SettingsSchema>;
231
+ packageDir: string;
232
+ }
233
+ interface EmittedPluginFiles {
234
+ manifest: RemotePluginManifest;
235
+ optionsSchemaFile: string;
236
+ settingsSchemaFile: string;
237
+ packageJsonChanged: boolean;
238
+ }
239
+ export declare function pluginManifest<OptionsSchema extends z$1.ZodType, SettingsSchema extends z$1.ZodType>(definition: PluginDefinition<OptionsSchema, SettingsSchema>): RemotePluginManifest;
240
+ export declare function emitPluginFiles<OptionsSchema extends z$1.ZodType, SettingsSchema extends z$1.ZodType>(input: EmitPluginFilesInput<OptionsSchema, SettingsSchema>): EmittedPluginFiles;
241
+ export { type AcquireInput, type CheckInput, type EmitPluginFilesInput, type EmittedPluginFiles, type EndInput, type InitializeInput, type PluginCallContext, type PluginDefinition, type PluginErrorOptions, type PluginIo, type PluginProgress, type PluginSpec, type ReleaseInput, type ShutdownInput, type StartedInput, type UploadAppInput, z };
@@ -0,0 +1,241 @@
1
+ import { z, z as z$1 } from "zod";
2
+ export declare function credential(description?: string): z$1.ZodString;
3
+ declare const OPTIONAL_PLUGIN_METHODS: readonly ['check', 'uploadApp', 'started', 'end'];
4
+ type OptionalPluginMethod = (typeof OPTIONAL_PLUGIN_METHODS)[number];
5
+ declare const PLUGIN_SERVES: readonly ['playwright', 'cdp', 'appium'];
6
+ type PluginServe = (typeof PLUGIN_SERVES)[number];
7
+ declare const PLUGIN_RUN_FACTS: readonly ['testName', 'runId', 'failure'];
8
+ type PluginRunFact = (typeof PLUGIN_RUN_FACTS)[number];
9
+ declare const PLUGIN_FAILURE_KINDS: readonly ['unreachable', 'auth', 'capacity', 'timeout', 'version', 'refused', 'ended', 'lost'];
10
+ type PluginFailureKind = (typeof PLUGIN_FAILURE_KINDS)[number];
11
+ declare const InitializeParamsSchema: z$1.ZodObject<{
12
+ protocolVersions: z$1.ZodArray<z$1.ZodNumber>;
13
+ host: z$1.ZodObject<{
14
+ pid: z$1.ZodNumber;
15
+ agentQaVersion: z$1.ZodString;
16
+ playwrightVersion: z$1.ZodString;
17
+ webdriverioVersion: z$1.ZodString;
18
+ }, z$1.core.$strip>;
19
+ entry: z$1.ZodString;
20
+ options: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
21
+ runFacts: z$1.ZodOptional<z$1.ZodObject<{
22
+ runId: z$1.ZodOptional<z$1.ZodString>;
23
+ }, z$1.core.$strip>>;
24
+ }, z$1.core.$strip>;
25
+ type InitializeParams = z$1.infer<typeof InitializeParamsSchema>;
26
+ declare const CheckResultSchema: z$1.ZodObject<{
27
+ state: z$1.ZodEnum<{
28
+ ok: "ok";
29
+ warn: "warn";
30
+ }>;
31
+ lines: z$1.ZodArray<z$1.ZodString>;
32
+ }, z$1.core.$strip>;
33
+ type CheckResult = z$1.infer<typeof CheckResultSchema>;
34
+ declare const AcquireParamsSchema: z$1.ZodObject<{
35
+ remote: z$1.ZodString;
36
+ settings: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
37
+ session: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
38
+ platform: z$1.ZodLiteral<"web">;
39
+ engine: z$1.ZodEnum<{
40
+ chromium: "chromium";
41
+ firefox: "firefox";
42
+ webkit: "webkit";
43
+ }>;
44
+ context: z$1.ZodEnum<{
45
+ new: "new";
46
+ reuse: "reuse";
47
+ }>;
48
+ }, z$1.core.$strip>, z$1.ZodObject<{
49
+ platform: z$1.ZodEnum<{
50
+ android: "android";
51
+ ios: "ios";
52
+ }>;
53
+ capabilities: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
54
+ }, z$1.core.$strip>], "platform">;
55
+ run: z$1.ZodOptional<z$1.ZodObject<{
56
+ testName: z$1.ZodOptional<z$1.ZodString>;
57
+ }, z$1.core.$strip>>;
58
+ }, z$1.core.$strip>;
59
+ type AcquireParams = z$1.infer<typeof AcquireParamsSchema>;
60
+ declare const AcquireResultSchema: z$1.ZodObject<{
61
+ handle: z$1.ZodJSONSchema;
62
+ protocol: z$1.ZodEnum<{
63
+ appium: "appium";
64
+ cdp: "cdp";
65
+ playwright: "playwright";
66
+ }>;
67
+ url: z$1.ZodString;
68
+ headers: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
69
+ capabilities: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
70
+ mask: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
71
+ link: z$1.ZodOptional<z$1.ZodString>;
72
+ }, z$1.core.$strip>;
73
+ type AcquireResult = z$1.infer<typeof AcquireResultSchema>;
74
+ declare const UploadAppParamsSchema: z$1.ZodObject<{
75
+ remote: z$1.ZodString;
76
+ settings: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
77
+ platform: z$1.ZodEnum<{
78
+ android: "android";
79
+ ios: "ios";
80
+ }>;
81
+ path: z$1.ZodString;
82
+ sha256: z$1.ZodString;
83
+ size: z$1.ZodNumber;
84
+ }, z$1.core.$strip>;
85
+ type UploadAppParams = z$1.infer<typeof UploadAppParamsSchema>;
86
+ declare const UploadAppResultSchema: z$1.ZodObject<{
87
+ ref: z$1.ZodString;
88
+ }, z$1.core.$strip>;
89
+ type UploadAppResult = z$1.infer<typeof UploadAppResultSchema>;
90
+ declare const StartedParamsSchema: z$1.ZodObject<{
91
+ handle: z$1.ZodJSONSchema;
92
+ sessionId: z$1.ZodOptional<z$1.ZodString>;
93
+ }, z$1.core.$strip>;
94
+ type StartedParams = z$1.infer<typeof StartedParamsSchema>;
95
+ declare const StartedResultSchema: z$1.ZodObject<{
96
+ link: z$1.ZodOptional<z$1.ZodString>;
97
+ appiumVersion: z$1.ZodOptional<z$1.ZodString>;
98
+ }, z$1.core.$strip>;
99
+ type StartedResult = z$1.infer<typeof StartedResultSchema>;
100
+ declare const EndParamsSchema: z$1.ZodObject<{
101
+ handle: z$1.ZodJSONSchema;
102
+ outcome: z$1.ZodEnum<{
103
+ cancelled: "cancelled";
104
+ error: "error";
105
+ failed: "failed";
106
+ passed: "passed";
107
+ }>;
108
+ reason: z$1.ZodOptional<z$1.ZodString>;
109
+ }, z$1.core.$strip>;
110
+ type EndParams = z$1.infer<typeof EndParamsSchema>;
111
+ type Json = z$1.core.util.JSONType;
112
+ type Awaitable<T> = T | Promise<T>;
113
+ interface PluginErrorOptions {
114
+ kind: PluginFailureKind;
115
+ path?: string;
116
+ handle?: Json;
117
+ }
118
+ export declare class PluginError extends Error {
119
+ readonly kind: PluginFailureKind;
120
+ readonly path: string | undefined;
121
+ readonly handle: Json | undefined;
122
+ constructor(message: string, options: PluginErrorOptions);
123
+ }
124
+ interface InitializeInput<Options> {
125
+ options: Options;
126
+ host: InitializeParams['host'];
127
+ entry: string;
128
+ runFacts: InitializeParams['runFacts'];
129
+ }
130
+ interface CheckInput<Options, Settings> {
131
+ options: Options;
132
+ remotes: {
133
+ name: string;
134
+ settings: Settings;
135
+ }[];
136
+ }
137
+ interface AcquireInput<Options, Settings> extends Omit<AcquireParams, 'settings'> {
138
+ options: Options;
139
+ settings: Settings;
140
+ }
141
+ interface UploadAppInput<Options, Settings> extends Omit<UploadAppParams, 'settings'> {
142
+ options: Options;
143
+ settings: Settings;
144
+ }
145
+ interface StartedInput<Options> extends StartedParams {
146
+ options: Options;
147
+ }
148
+ interface EndInput<Options> extends EndParams {
149
+ options: Options;
150
+ }
151
+ interface ReleaseInput<Options> {
152
+ options: Options;
153
+ handle: Json;
154
+ }
155
+ interface ShutdownInput<Options> {
156
+ options: Options;
157
+ }
158
+ interface PluginProgress {
159
+ message: string;
160
+ queued?: number;
161
+ percent?: number;
162
+ }
163
+ interface PluginCallContext {
164
+ signal: AbortSignal;
165
+ progress(update: PluginProgress): void;
166
+ runFacts: InitializeParams['runFacts'];
167
+ }
168
+ interface PluginSpec<OptionsSchema extends z$1.ZodType, SettingsSchema extends z$1.ZodType> {
169
+ options: OptionsSchema;
170
+ settings: SettingsSchema;
171
+ serves: readonly PluginServe[];
172
+ runFacts?: readonly PluginRunFact[];
173
+ skill?: string;
174
+ initialize?(input: InitializeInput<z$1.output<OptionsSchema>>, ctx: PluginCallContext): Awaitable<void>;
175
+ check?(input: CheckInput<z$1.output<OptionsSchema>, z$1.output<SettingsSchema>>, ctx: PluginCallContext): Awaitable<CheckResult>;
176
+ acquire(input: AcquireInput<z$1.output<OptionsSchema>, z$1.output<SettingsSchema>>, ctx: PluginCallContext): Awaitable<AcquireResult>;
177
+ uploadApp?(input: UploadAppInput<z$1.output<OptionsSchema>, z$1.output<SettingsSchema>>, ctx: PluginCallContext): Awaitable<UploadAppResult>;
178
+ started?(input: StartedInput<z$1.output<OptionsSchema>>, ctx: PluginCallContext): Awaitable<StartedResult>;
179
+ end?(input: EndInput<z$1.output<OptionsSchema>>, ctx: PluginCallContext): Awaitable<void>;
180
+ release(input: ReleaseInput<z$1.output<OptionsSchema>>, ctx: PluginCallContext): Awaitable<void>;
181
+ shutdown?(input: ShutdownInput<z$1.output<OptionsSchema>>, ctx: PluginCallContext): Awaitable<void>;
182
+ }
183
+ interface PluginDefinition<OptionsSchema extends z$1.ZodType = z$1.ZodType, SettingsSchema extends z$1.ZodType = z$1.ZodType> extends PluginSpec<OptionsSchema, SettingsSchema> {
184
+ methods: readonly OptionalPluginMethod[];
185
+ }
186
+ export declare function definePlugin<OptionsSchema extends z$1.ZodType, SettingsSchema extends z$1.ZodType>(spec: PluginSpec<OptionsSchema, SettingsSchema>): PluginDefinition<OptionsSchema, SettingsSchema>;
187
+ interface PluginIo {
188
+ stdin: {
189
+ on(event: 'data', listener: (chunk: Uint8Array | string) => void): unknown;
190
+ on(event: 'end' | 'error', listener: () => void): unknown;
191
+ };
192
+ stdout: {
193
+ write(chunk: string, callback?: (error?: Error | null) => void): unknown;
194
+ };
195
+ exit(code: number): void;
196
+ entryPath?: string;
197
+ cancelAnswerGraceMs: number;
198
+ hostPidPollMs: number;
199
+ }
200
+ export declare const CANCEL_ANSWER_GRACE_MS = 4000;
201
+ export declare const HOST_PID_POLL_MS = 1000;
202
+ export declare function runPlugin<OptionsSchema extends z$1.ZodType, SettingsSchema extends z$1.ZodType>(definition: PluginDefinition<OptionsSchema, SettingsSchema>, ioInput?: Partial<PluginIo>): void;
203
+ declare const RemotePluginManifestSchema: z$1.ZodObject<{
204
+ kind: z$1.ZodLiteral<"remote">;
205
+ runs: z$1.ZodLiteral<"process">;
206
+ protocol: z$1.ZodNumber;
207
+ entry: z$1.ZodString;
208
+ serves: z$1.ZodArray<z$1.ZodEnum<{
209
+ appium: "appium";
210
+ cdp: "cdp";
211
+ playwright: "playwright";
212
+ }>>;
213
+ methods: z$1.ZodArray<z$1.ZodEnum<{
214
+ check: "check";
215
+ end: "end";
216
+ started: "started";
217
+ uploadApp: "uploadApp";
218
+ }>>;
219
+ options: z$1.ZodString;
220
+ settings: z$1.ZodString;
221
+ runFacts: z$1.ZodOptional<z$1.ZodArray<z$1.ZodEnum<{
222
+ failure: "failure";
223
+ runId: "runId";
224
+ testName: "testName";
225
+ }>>>;
226
+ skill: z$1.ZodOptional<z$1.ZodString>;
227
+ }, z$1.core.$strict>;
228
+ type RemotePluginManifest = z$1.infer<typeof RemotePluginManifestSchema>;
229
+ interface EmitPluginFilesInput<OptionsSchema extends z$1.ZodType, SettingsSchema extends z$1.ZodType> {
230
+ definition: PluginDefinition<OptionsSchema, SettingsSchema>;
231
+ packageDir: string;
232
+ }
233
+ interface EmittedPluginFiles {
234
+ manifest: RemotePluginManifest;
235
+ optionsSchemaFile: string;
236
+ settingsSchemaFile: string;
237
+ packageJsonChanged: boolean;
238
+ }
239
+ export declare function pluginManifest<OptionsSchema extends z$1.ZodType, SettingsSchema extends z$1.ZodType>(definition: PluginDefinition<OptionsSchema, SettingsSchema>): RemotePluginManifest;
240
+ export declare function emitPluginFiles<OptionsSchema extends z$1.ZodType, SettingsSchema extends z$1.ZodType>(input: EmitPluginFilesInput<OptionsSchema, SettingsSchema>): EmittedPluginFiles;
241
+ export { type AcquireInput, type CheckInput, type EmitPluginFilesInput, type EmittedPluginFiles, type EndInput, type InitializeInput, type PluginCallContext, type PluginDefinition, type PluginErrorOptions, type PluginIo, type PluginProgress, type PluginSpec, type ReleaseInput, type ShutdownInput, type StartedInput, type UploadAppInput, z };