unfazed 0.6.0 → 0.6.1
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/README.md +101 -29
- package/dist/cli/login.d.ts +129 -0
- package/dist/cli/login.js +596 -0
- package/dist/cli/login.js.map +1 -0
- package/dist/cli/workflow.d.ts +31 -0
- package/dist/cli/workflow.js +157 -0
- package/dist/cli/workflow.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +173 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +26 -5
- package/dist/client.js +93 -48
- package/dist/client.js.map +1 -1
- package/dist/credentials.d.ts +123 -0
- package/dist/credentials.js +317 -0
- package/dist/credentials.js.map +1 -0
- package/dist/index.d.ts +12 -2
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/remote/app.js +2 -1
- package/dist/remote/app.js.map +1 -1
- package/dist/remote/world.d.ts +2 -2
- package/dist/remote/world.js +32 -16
- package/dist/remote/world.js.map +1 -1
- package/dist/unfazed.d.ts +1 -1
- package/dist/unfazed.js +1 -1
- package/dist/unfazed.js.map +1 -1
- package/package.json +18 -6
package/dist/remote/world.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"world.js","sourceRoot":"","sources":["../../src/remote/world.ts"],"names":[],"mappings":"AA+CA,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAkB,MAAM,cAAc,CAAC;AACvG,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC5G,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,SAAS,EACT,KAAK,EACL,eAAe,EACf,eAAe,EACf,MAA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AI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3B,IAAI,IAAI;QAAE,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;AAC/B,CAAC;AAED,SAAS,UAAU,CAAC,MAA+B,EAAE,GAAW,EAAE,KAAc;IAC9E,IAAI,KAAK,KAAK,SAAS;QAAE,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAC/C,CAAC;AAED,sEAAsE;AACtE,KAAK,UAAU,QAAQ,CAAO,KAAmB,EAAE,KAAa,EAAE,EAA2B;IAC3F,MAAM,OAAO,GAAG,IAAI,KAAK,CAAI,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3C,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,MAAM,MAAM,GAAG,KAAK,IAAI,EAAE;QACxB,OAAO,IAAI,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;YAC3B,MAAM,KAAK,GAAG,IAAI,EAAE,CAAC;YACrB,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,KAAK,CAAE,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC,CAAC;IACF,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IACjF,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/**\n * The `unfazed` backend of Workflow SDK's CLI: a World that reads an app's\n * workflow runs through the platform's inspection API, so\n *\n * ```sh\n * UNFZ_APP=birthday-card npx workflow inspect runs --backend unfazed\n * ```\n *\n * works like `--backend vercel` does. The CLI imports `unfazed` from the\n * project and calls `createWorld()` (see `../index.ts`), which lazily loads\n * this module.\n *\n * Every read is one GraphQL call to the control plane, which relays it to the\n * app's own inspection route over the worker (unfazed docs/workflow-inspect.md):\n * the app reads its runs through its own World and sends display data, which\n * `./values.ts` turns back into the serialized data Workflow SDK's tooling\n * hydrates. Writes are refused, except the two the inspection API offers:\n * cancelling a run (`workflow cancel`, the web UI) and waking a sleeping one\n * (the web UI's \"Wake up\").\n *\n * Only type imports from `@workflow/world`: the root entry stays free of\n * runtime dependencies.\n */\nimport type {\n AnyEventRequest,\n BulkCancelWorkflowRunResult,\n BulkCancelWorkflowRunsRequest,\n BulkCancelWorkflowRunsResult,\n Event,\n GetChunksOptions,\n GetEventParams,\n GetStepParams,\n GetWorkflowRunParams,\n Hook,\n ListEventsByCorrelationIdParams,\n ListEventsParams,\n ListHooksParams,\n ListWorkflowRunsParams,\n ListWorkflowRunStepsParams,\n PaginatedResponse,\n PaginationOptions,\n Step,\n StreamChunksResponse,\n StreamInfoResponse,\n World,\n WorkflowRun,\n} from \"@workflow/world\";\nimport { ENDPOINT_ENV_VAR, TOKEN_ENV_VAR, UnfazedClient, VERSION, type FetchLike } from \"../client.js\";\nimport { UnfazedAuthError, UnfazedGraphQLError, UnfazedHTTPError, UnfazedInspectError } from \"../errors.js\";\nimport { APP_ENV_VAR, currentDirectory, resolveAlias } from \"./app.js\";\nimport * as docs from \"./documents.js\";\nimport {\n chunkValue,\n EVENT_PAYLOAD_FIELDS,\n eventData,\n frame,\n serializedValue,\n structuredError,\n toDate,\n} from \"./values.js\";\n\nexport interface RemoteWorldOptions {\n /** The app's alias. Default: `UNFZ_APP`, else the `alias` (or single `apps[]` entry) of `unfazed.json` in `cwd`. */\n alias?: string;\n /** Bearer token. Default: `UNFZ_API_TOKEN`. Get one at https://unfazed.dev/auth.md. */\n token?: string;\n /** Full GraphQL endpoint. Default: `UNFZ_API_URL`, else https://unfazed.dev/query. */\n endpoint?: string;\n /** Where the defaults above are read from. Default: `process.env`. */\n env?: Record<string, string | undefined>;\n /** Directory whose `unfazed.json` names the app. Default: the current directory. */\n cwd?: string;\n /** Per-request timeout in ms. Default 60 000 (a relay may include the app's cold start). */\n timeoutMs?: number;\n /**\n * How long `streams.get` waits between reads of a stream still being\n * written, at most: it starts at 1 s and doubles up to this. Default 5 000.\n */\n streamPollMs?: number;\n /** Injection point for tests. */\n fetch?: FetchLike;\n}\n\n/**\n * The World `createWorld()` from `unfazed` returns: Workflow SDK's `World`\n * interface over the inspection API. Typed loosely here so the root entry's\n * declarations need no `@workflow/world`; cast to its `World` when you call\n * it from code.\n */\nexport interface RemoteWorld {\n /** The app it reads. */\n readonly alias: string;\n readonly specVersion: number;\n readonly runs: object;\n readonly steps: object;\n readonly events: object;\n readonly hooks: object;\n readonly streams: object;\n close(): Promise<void>;\n}\n\n/**\n * `SPEC_VERSION_CURRENT` of the `@workflow/world` this backend was written\n * against (a test keeps the two equal). Informational: this World creates\n * and replays nothing.\n */\nexport const REMOTE_SPEC_VERSION = 8;\n\n/** A run page is reused for this long, so one CLI or web UI view costs one relay. */\nconst RUN_PAGE_TTL_MS = 2_000;\n/** Active runs searched for a hook that no run page read so far named. */\nconst HOOK_SCAN_RUNS = 20;\n/** Pages of 200 steps read to serve `steps.list` newest first (the API lists oldest first). */\nconst STEP_PAGES_MAX = 10;\nconst STREAM_PAGE = 50;\nconst STREAM_POLL_MIN_MS = 1_000;\nconst CONCURRENCY = 4;\n/** A wake-up's own re-enqueue happens inside the app; the SDK's follow-up `queue()` within this window is a no-op. */\nconst WAKE_QUEUE_WINDOW_MS = 60_000;\n/** Hook tokens never leave the app (contract: hooks are shown by ID, kind and state). */\nconst REDACTED = \"[redacted]\";\n\ntype Env = Record<string, string | undefined>;\n\n/**\n * Creates the CLI backend's World for one app. Throws when there is no token\n * or no app to read, saying what to set.\n */\nexport function createRemoteWorld(options: RemoteWorldOptions = {}): RemoteWorld {\n const env: Env = options.env ?? (globalThis as { process?: { env?: Env } }).process?.env ?? {};\n const token = options.token ?? env[TOKEN_ENV_VAR];\n if (!token?.trim()) {\n const inApp = env[\"UNFZ_STATE_URL\"]\n ? ' Inside an unfazed app the World is unfazed/workflow (its Nitro module, or setWorld(createWorld()) from \"unfazed/workflow\"); ' +\n \"WORKFLOW_TARGET_WORLD=unfazed selects this read-only CLI backend instead.\"\n : \"\";\n throw new UnfazedAuthError(\n `unfazed: no API token. Set ${TOKEN_ENV_VAR} to inspect an app's workflow runs ` +\n `(a token with the unfz:read scope; unfz:deploy too for cancel and wake). Get one at https://unfazed.dev/auth.md.${inApp}`,\n );\n }\n const alias = resolveAlias({ alias: options.alias, env, cwd: options.cwd ?? currentDirectory() });\n const endpointEnv = env[ENDPOINT_ENV_VAR];\n const client = new UnfazedClient({\n token,\n endpoint: options.endpoint ?? (endpointEnv ? normalizeEndpoint(endpointEnv) : undefined),\n timeoutMs: options.timeoutMs ?? 60_000,\n userAgent: `unfazed-sdk/${VERSION} (workflow-cli-backend)`,\n ...(options.fetch ? { fetch: options.fetch } : {}),\n });\n const pollMaxMs = Math.max(1, options.streamPollMs ?? 5_000);\n const pollMinMs = Math.min(STREAM_POLL_MIN_MS, pollMaxMs);\n\n let closed = false;\n /** Pending waits of stream readers; `close()` ends them so no timer outlives the World. */\n const sleepers = new Set<() => void>();\n const sleep = (ms: number) =>\n new Promise<void>((resolve) => {\n const wake = () => {\n clearTimeout(timer);\n sleepers.delete(wake);\n resolve();\n };\n const timer = setTimeout(wake, ms);\n sleepers.add(wake);\n });\n\n // ---- Transport and errors ----\n\n async function call<T>(document: string, variables: Record<string, unknown>, runId?: string): Promise<T> {\n try {\n return await client.request<T>(document, variables);\n } catch (error) {\n throw translate(error, alias, runId);\n }\n }\n\n // ---- Run pages: one relay serves runs.get, hooks, streams.list ----\n\n const runPages = new Map<string, { expires: number; page: Promise<docs.WorkflowRunPage> }>();\n /** hookId → runId, from every run page read: how `hooks.get(hookId)` finds the run. */\n const hookRuns = new Map<string, string>();\n\n function runPage(runId: string): Promise<docs.WorkflowRunPage> {\n const cached = runPages.get(runId);\n if (cached && cached.expires > Date.now()) return cached.page;\n // Never expires while in flight (a relay may wait out a cold start); reused for a moment after.\n const entry = { expires: Number.POSITIVE_INFINITY } as { expires: number; page: Promise<docs.WorkflowRunPage> };\n entry.page = call<docs.RunResult>(docs.RUN, { alias, runID: runId }, runId).then(\n ({ workflowRun }) => {\n for (const hook of workflowRun.hooks) hookRuns.set(hook.hookID, runId);\n entry.expires = Date.now() + RUN_PAGE_TTL_MS;\n return workflowRun;\n },\n (error: unknown) => {\n if (runPages.get(runId) === entry) runPages.delete(runId);\n throw error;\n },\n );\n runPages.set(runId, entry);\n return entry.page;\n }\n\n // ---- Records in the World's shapes ----\n\n function runRecord(run: docs.WorkflowRunSummary, page?: docs.WorkflowRunPage, withData = false): WorkflowRun {\n const record: Record<string, unknown> = {\n runId: run.runID,\n status: run.status.toLowerCase(),\n deploymentId: run.deploymentID,\n workflowName: run.workflowName,\n attributes: Object.fromEntries(run.attributes.map(({ key, value }) => [key, value])),\n createdAt: toDate(run.createdAt),\n updatedAt: toDate(run.updatedAt),\n };\n setDate(record, \"startedAt\", run.startedAt);\n setDate(record, \"completedAt\", run.completedAt);\n setDate(record, \"expiredAt\", run.expiredAt);\n if (run.errorCode !== null) record.errorCode = run.errorCode;\n if (page && withData) {\n setDefined(record, \"input\", serializedValue(page.input));\n setDefined(record, \"output\", serializedValue(page.output));\n }\n if (page?.error) record.error = structuredError(page.error);\n return record as unknown as WorkflowRun;\n }\n\n function stepRecord(\n runId: string,\n step: docs.WorkflowStep,\n detail?: docs.StepResult[\"workflowStep\"],\n withData = false,\n ): Step {\n const record: Record<string, unknown> = {\n runId,\n stepId: step.stepID,\n stepName: step.stepName,\n status: step.status,\n attempt: step.attempt,\n createdAt: toDate(step.createdAt),\n updatedAt: toDate(step.updatedAt),\n };\n setDate(record, \"startedAt\", step.startedAt);\n setDate(record, \"completedAt\", step.completedAt);\n setDate(record, \"retryAfter\", step.retryAfter);\n if (detail && withData) {\n setDefined(record, \"input\", serializedValue(detail.input));\n setDefined(record, \"output\", serializedValue(detail.output));\n }\n if (detail?.error) record.error = structuredError(detail.error);\n return record as unknown as Step;\n }\n\n function eventRecord(runId: string, event: docs.WorkflowEvent, data?: docs.WorkflowValue | null): Event {\n const record: Record<string, unknown> = {\n runId,\n eventId: event.eventID,\n eventType: event.eventType,\n createdAt: toDate(event.createdAt),\n eventData: eventData(event.info),\n };\n if (event.correlationID !== null) record.correlationId = event.correlationID;\n const field = EVENT_PAYLOAD_FIELDS[event.eventType];\n if (field && data) (record.eventData as Record<string, unknown>)[field] = serializedValue(data);\n return record as unknown as Event;\n }\n\n function hookRecord(runId: string, hook: docs.WorkflowHook): Hook {\n const record: Record<string, unknown> = {\n runId,\n hookId: hook.hookID,\n token: REDACTED,\n ownerId: \"\",\n projectId: alias,\n environment: \"production\",\n createdAt: toDate(hook.createdAt),\n isWebhook: hook.kind === \"webhook\",\n isSystem: hook.kind === \"system\",\n // What the inspection API adds: the hook's state from its run's events.\n status: hook.status,\n receivedCount: hook.receivedCount,\n };\n setDate(record, \"lastReceivedAt\", hook.lastReceivedAt);\n setDate(record, \"disposedAt\", hook.disposedAt);\n return record as unknown as Hook;\n }\n\n // ---- Lists ----\n\n async function allSteps(runId: string): Promise<docs.WorkflowStep[]> {\n const steps: docs.WorkflowStep[] = [];\n let cursor: string | null = null;\n for (let page = 0; page < STEP_PAGES_MAX; page++) {\n const { workflowSteps }: docs.StepsResult = await call<docs.StepsResult>(\n docs.STEPS,\n { alias, runID: runId, limit: 200, cursor },\n runId,\n );\n steps.push(...workflowSteps.steps);\n if (!workflowSteps.hasMore || !workflowSteps.nextCursor) break;\n cursor = workflowSteps.nextCursor;\n }\n return steps;\n }\n\n async function activeRuns(limit: number, cursor: string | null) {\n const { workflowRuns } = await call<docs.RunsResult>(docs.RUNS, {\n alias,\n status: [\"RUNNING\", \"PENDING\"],\n limit,\n cursor,\n });\n const pages = await mapLimit(workflowRuns.runs, CONCURRENCY, (run) => runPage(run.runID));\n return { pages, nextCursor: workflowRuns.nextCursor, hasMore: workflowRuns.hasMore };\n }\n\n function hooksOf(page: docs.WorkflowRunPage, onlyActive: boolean): Hook[] {\n return page.hooks\n .filter((hook) => !onlyActive || hook.status === \"active\")\n .map((hook) => hookRecord(page.run.runID, hook));\n }\n\n // ---- Writes the inspection API offers ----\n\n /** Runs woken through this World, for the SDK's follow-up `queue()` (see {@link WAKE_QUEUE_WINDOW_MS}). */\n const woken = new Map<string, number>();\n\n /**\n * Cancels a run; resolves `\"already_cancelled\"` for a run cancelled before,\n * which, as in the upstream Worlds, is not an error. A run that completed or\n * failed is refused with the platform's \"run … already ended (…)\".\n */\n async function cancel(runId: string, reason?: string): Promise<\"cancelled\" | \"already_cancelled\"> {\n try {\n await call<docs.CancelResult>(\n docs.CANCEL,\n // The platform takes at most 512 characters (code points); cut on a character boundary.\n { input: { alias, runID: runId, ...(reason !== undefined ? { reason: Array.from(reason).slice(0, 512).join(\"\") } : {}) } },\n runId,\n );\n return \"cancelled\";\n } catch (error) {\n if (endedAs(error) === \"cancelled\") return \"already_cancelled\";\n throw error;\n } finally {\n runPages.delete(runId);\n }\n }\n\n // ---- The World ----\n\n const world = {\n alias,\n specVersion: REMOTE_SPEC_VERSION,\n capabilities: {},\n\n runs: {\n async get(id: string, params?: GetWorkflowRunParams) {\n const page = await runPage(id);\n return runRecord(page.run, page, params?.resolveData !== \"none\");\n },\n\n async list(params: ListWorkflowRunsParams = {}): Promise<PaginatedResponse<WorkflowRun>> {\n if ((params.pagination?.sortOrder ?? \"desc\") !== \"desc\") {\n throw invalidArgument(\"runs.list\", \"sortOrder\", \"the unfazed backend lists runs newest first only; drop --sort asc\");\n }\n const status =\n params.status === undefined\n ? null\n : (Array.isArray(params.status) ? params.status : [params.status]).map((s) => s.toUpperCase());\n const { workflowRuns } = await call<docs.RunsResult>(docs.RUNS, {\n alias,\n status,\n workflowName: params.workflowName ?? null,\n limit: clamp(params.pagination?.limit ?? 20, 1, 100),\n cursor: params.pagination?.cursor || null,\n });\n return {\n data: workflowRuns.runs.map((run) => runRecord(run)),\n cursor: workflowRuns.hasMore ? workflowRuns.nextCursor : null,\n hasMore: workflowRuns.hasMore,\n };\n },\n\n async cancelMany(request: BulkCancelWorkflowRunsRequest): Promise<BulkCancelWorkflowRunsResult> {\n const results = await mapLimit(request.runIds, CONCURRENCY, async (runId): Promise<BulkCancelWorkflowRunResult> => {\n try {\n return { runId, outcome: await cancel(runId, request.cancelReason) };\n } catch (error) {\n if (error instanceof UnfazedInspectError && (error.status === 401 || error.status === 403)) throw error;\n const ended = endedAs(error);\n if (ended) return { runId, outcome: \"not_cancellable\", status: ended };\n if (error instanceof UnfazedInspectError && error.name === \"WorkflowRunNotFoundError\") {\n return { runId, outcome: \"not_found\" };\n }\n return { runId, outcome: \"failed\", code: \"internal_error\", retryable: true };\n }\n });\n const count = (outcome: BulkCancelWorkflowRunResult[\"outcome\"]) => results.filter((r) => r.outcome === outcome).length;\n return {\n summary: {\n requested: results.length,\n cancelled: count(\"cancelled\"),\n alreadyCancelled: count(\"already_cancelled\"),\n notCancellable: count(\"not_cancellable\"),\n notFound: count(\"not_found\"),\n failed: count(\"failed\"),\n },\n results,\n };\n },\n },\n\n steps: {\n async get(runId: string, stepId: string, params?: GetStepParams) {\n const { workflowStep } = await call<docs.StepResult>(docs.STEP_DETAIL, { alias, runID: runId, stepID: stepId }, runId);\n return stepRecord(runId, workflowStep.step, workflowStep, params?.resolveData !== \"none\");\n },\n\n async list(params: ListWorkflowRunStepsParams): Promise<PaginatedResponse<Step>> {\n const { runId, pagination } = params;\n const limit = clamp(pagination?.limit ?? 20, 1, 200);\n if ((pagination?.sortOrder ?? \"desc\") === \"asc\") {\n if (pagination?.cursor?.startsWith(CURSOR_PREFIX)) throw badCursor(\"steps.list\");\n const { workflowSteps } = await call<docs.StepsResult>(\n docs.STEPS,\n { alias, runID: runId, limit, cursor: pagination?.cursor || null },\n runId,\n );\n return {\n data: workflowSteps.steps.map((step) => stepRecord(runId, step)),\n cursor: workflowSteps.hasMore ? workflowSteps.nextCursor : null,\n hasMore: workflowSteps.hasMore,\n };\n }\n // Newest first: the API pages oldest first, so read the run's steps and page them here.\n const offset = decodeOffset(pagination?.cursor, \"steps.list\");\n const steps = (await allSteps(runId)).reverse();\n return offsetPage(\n steps.map((step) => stepRecord(runId, step)),\n offset,\n limit,\n );\n },\n },\n\n events: {\n async get(runId: string, eventId: string, params?: GetEventParams) {\n const { workflowEvent } = await call<docs.EventResult>(docs.EVENT_DETAIL, { alias, runID: runId, eventID: eventId }, runId);\n return eventRecord(runId, workflowEvent.event, params?.resolveData === \"none\" ? null : workflowEvent.data);\n },\n\n async list(params: ListEventsParams) {\n return listEvents(params.runId, null, params.pagination);\n },\n\n async listByCorrelationId(params: ListEventsByCorrelationIdParams) {\n if (!params.runId) {\n throw invalidArgument(\"events.listByCorrelationId\", \"runId\", \"the unfazed backend reads events per run: pass the run ID\");\n }\n return listEvents(params.runId, params.correlationId, params.pagination);\n },\n\n async create(runId: string | null, data: AnyEventRequest) {\n if (runId && data.eventType === \"run_cancelled\") {\n const reason = (data.eventData as { cancelReason?: unknown } | undefined)?.cancelReason;\n await cancel(runId, typeof reason === \"string\" ? reason : undefined);\n return { event: syntheticEvent(runId, data) };\n }\n if (runId && data.eventType === \"wait_completed\" && data.correlationId) {\n await call<docs.WakeResult>(docs.WAKE, { input: { alias, runID: runId, correlationIDs: [data.correlationId] } }, runId);\n woken.set(runId, Date.now() + WAKE_QUEUE_WINDOW_MS);\n runPages.delete(runId);\n return { event: syntheticEvent(runId, data) };\n }\n throw readOnly(`write a ${data.eventType} event`);\n },\n },\n\n hooks: {\n async get(hookId: string) {\n const known = hookRuns.get(hookId);\n if (known) {\n const hook = (await runPage(known)).hooks.find((h) => h.hookID === hookId);\n if (hook) return hookRecord(known, hook);\n }\n const { pages } = await activeRuns(HOOK_SCAN_RUNS, null);\n for (const page of pages) {\n const hook = page.hooks.find((h) => h.hookID === hookId);\n if (hook) return hookRecord(page.run.runID, hook);\n }\n throw new UnfazedInspectError(\n `Hook ${hookId} not found. The unfazed backend finds a hook through its run, and no run read so far, ` +\n `nor any of the ${HOOK_SCAN_RUNS} newest active runs, has it. List a run's hooks with ` +\n \"`workflow inspect hooks --runId <run-id>`.\",\n { name: \"HookNotFoundError\", status: 404 },\n );\n },\n\n async getByToken(): Promise<Hook> {\n throw readOnly(\"look a hook up by its token (hook tokens never leave the app)\");\n },\n\n async list(params: ListHooksParams): Promise<PaginatedResponse<Hook>> {\n const { runId, pagination } = params;\n const desc = pagination?.sortOrder === \"desc\";\n const byCreated = (a: Hook, b: Hook) => (a.createdAt.getTime() - b.createdAt.getTime()) * (desc ? -1 : 1);\n if (runId) {\n const hooks = hooksOf(await runPage(runId), false).sort(byCreated);\n return offsetPage(hooks, decodeOffset(pagination?.cursor, \"hooks.list\"), clamp(pagination?.limit ?? 100, 1, 500));\n }\n // Every hook of the app: those of its active runs (a finished run's hooks are gone), a page of runs at a time.\n const runsCursor = decodeWrapped(pagination?.cursor, \"runs\", \"hooks.list\");\n const { pages, nextCursor, hasMore } = await activeRuns(clamp(pagination?.limit ?? 20, 1, HOOK_SCAN_RUNS), runsCursor);\n return {\n data: pages.flatMap((page) => hooksOf(page, true)).sort(byCreated),\n cursor: hasMore && nextCursor ? `${CURSOR_PREFIX}runs:${nextCursor}` : null,\n hasMore: hasMore && nextCursor !== null,\n };\n },\n },\n\n streams: {\n async list(runId: string) {\n return (await runPage(runId)).streams.map((stream) => stream.name);\n },\n\n async getInfo(runId: string, name: string): Promise<StreamInfoResponse> {\n const { workflowStream } = await call<docs.StreamResult>(docs.STREAM, { alias, runID: runId, name, limit: 1 }, runId);\n return { tailIndex: workflowStream.tailIndex, done: workflowStream.done };\n },\n\n async getChunks(runId: string, name: string, options?: GetChunksOptions): Promise<StreamChunksResponse> {\n const { workflowStream } = await call<docs.StreamResult>(\n docs.STREAM,\n { alias, runID: runId, name, limit: clamp(options?.limit ?? 100, 1, 200), cursor: options?.cursor || null },\n runId,\n );\n return {\n data: workflowStream.chunks.map((chunk) => ({ index: chunk.index, data: frame(chunkValue(chunk)) })),\n cursor: workflowStream.hasMore ? workflowStream.nextCursor : null,\n hasMore: workflowStream.hasMore,\n done: workflowStream.done,\n };\n },\n\n /**\n * The stream from `startIndex` (negative: from the end), each chunk one\n * frame, read a page at a time and, while the run is still writing it,\n * polled (1 s, doubling up to `streamPollMs`) until it is done.\n */\n async get(runId: string, name: string, startIndex = 0): Promise<ReadableStream<Uint8Array>> {\n let pageCursor: string | null = null;\n let position: number | undefined;\n let delay = pollMinMs;\n let cancelled = false;\n return new ReadableStream<Uint8Array>({\n async pull(controller) {\n for (;;) {\n if (cancelled || closed) {\n controller.close();\n return;\n }\n const { workflowStream } = await call<docs.StreamResult>(\n docs.STREAM,\n { alias, runID: runId, name, limit: STREAM_PAGE, cursor: pageCursor },\n runId,\n );\n position ??= startIndex < 0 ? Math.max(0, workflowStream.tailIndex + 1 + startIndex) : startIndex;\n const fresh = workflowStream.chunks.filter((chunk) => chunk.index >= position!);\n // A page with more after it is never read again; the last page is re-read for new chunks.\n if (workflowStream.hasMore && workflowStream.nextCursor) pageCursor = workflowStream.nextCursor;\n if (fresh.length > 0) {\n for (const chunk of fresh) controller.enqueue(frame(chunkValue(chunk)));\n position = fresh[fresh.length - 1]!.index + 1;\n delay = pollMinMs;\n return;\n }\n if (workflowStream.hasMore) continue;\n if (workflowStream.done) {\n controller.close();\n return;\n }\n await sleep(delay);\n delay = Math.min(delay * 2, pollMaxMs);\n }\n },\n cancel() {\n cancelled = true;\n },\n });\n },\n\n async write(): Promise<void> {\n throw readOnly(\"write to a stream\");\n },\n async writeMulti(): Promise<void> {\n throw readOnly(\"write to a stream\");\n },\n async close(): Promise<void> {\n throw readOnly(\"close a stream\");\n },\n },\n\n async getDeploymentId(): Promise<string> {\n throw readOnly(\"start runs (it has no deployment of its own)\");\n },\n\n async queue(_queueName: string, message: unknown) {\n const runId = (message as { runId?: unknown } | null)?.runId;\n const until = typeof runId === \"string\" ? woken.get(runId) : undefined;\n // `wakeUp()` re-enqueues the run after completing its waits; the app already did both.\n if (until !== undefined && until > Date.now()) return { messageId: null };\n throw readOnly(\"enqueue messages\");\n },\n\n createQueueHandler(): (req: Request) => Promise<Response> {\n throw readOnly(\"handle queue deliveries\");\n },\n\n async close() {\n closed = true;\n for (const wake of [...sleepers]) wake();\n },\n };\n\n async function listEvents(runId: string, correlationId: string | null, pagination?: PaginationOptions): Promise<PaginatedResponse<Event>> {\n const { workflowEvents } = await call<docs.EventsResult>(\n docs.EVENTS,\n {\n alias,\n runID: runId,\n correlationID: correlationId,\n newestFirst: pagination?.sortOrder === \"desc\",\n limit: clamp(pagination?.limit ?? 100, 1, 500),\n cursor: pagination?.cursor || null,\n },\n runId,\n );\n return {\n data: workflowEvents.events.map((event) => eventRecord(runId, event)),\n cursor: workflowEvents.hasMore ? workflowEvents.nextCursor : null,\n hasMore: workflowEvents.hasMore,\n };\n }\n\n // Every member exists on Workflow SDK's World (no misspelt or invented method); parameters\n // are the World's own types above. The overloaded return types are not checked here.\n const keys: Implements<typeof world, World & { alias: string }> = true;\n const namespaces: [\n Implements<typeof world.runs, World[\"runs\"]>,\n Implements<typeof world.steps, World[\"steps\"]>,\n Implements<typeof world.events, World[\"events\"]>,\n Implements<typeof world.hooks, World[\"hooks\"]>,\n Implements<typeof world.streams, World[\"streams\"]>,\n ] = [true, true, true, true, true];\n void keys;\n void namespaces;\n return world as unknown as RemoteWorld;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers.\n// ---------------------------------------------------------------------------\n\n/** `true` when every key of `T` is a key of `U`. */\ntype Implements<T, U> = Exclude<keyof T, keyof U> extends never ? true : never;\n\n/** Cursors this backend mints itself (offset pages, wrapped run cursors); the API's own pass through untouched. */\nconst CURSOR_PREFIX = \"unfz:\";\n\nfunction offsetPage<T>(items: T[], offset: number, limit: number): PaginatedResponse<T> {\n const end = offset + limit;\n const hasMore = end < items.length;\n return { data: items.slice(offset, end), cursor: hasMore ? `${CURSOR_PREFIX}offset:${end}` : null, hasMore };\n}\n\nfunction decodeOffset(cursor: string | undefined, method: string): number {\n if (!cursor) return 0;\n const match = /^unfz:offset:(\\d{1,9})$/.exec(cursor);\n if (!match) throw badCursor(method);\n return Number(match[1]);\n}\n\nfunction decodeWrapped(cursor: string | undefined, kind: string, method: string): string | null {\n if (!cursor) return null;\n const prefix = `${CURSOR_PREFIX}${kind}:`;\n if (!cursor.startsWith(prefix) || cursor.length === prefix.length) throw badCursor(method);\n return cursor.slice(prefix.length);\n}\n\nfunction badCursor(method: string): UnfazedInspectError {\n return invalidArgument(method, \"cursor\", \"this cursor came from another listing or sort order\");\n}\n\nfunction invalidArgument(method: string, field: string, why: string): UnfazedInspectError {\n return new UnfazedInspectError(`unfazed: ${method}: ${field}: ${why}.`, { code: \"INVALID_ARGUMENT\" });\n}\n\nfunction readOnly(what: string): UnfazedInspectError {\n return new UnfazedInspectError(\n `unfazed: the \\`unfazed\\` CLI backend is read-only and cannot ${what}. It inspects an app's runs from your ` +\n \"terminal (workflow inspect, workflow cancel, the web UI). Apps use unfazed/workflow: its Nitro module, \" +\n 'or setWorld(createWorld()) from \"unfazed/workflow\", not WORKFLOW_TARGET_WORLD=unfazed.',\n { code: \"READ_ONLY\" },\n );\n}\n\nfunction syntheticEvent(runId: string, data: AnyEventRequest): Event {\n const { correlationId, eventData } = data as { correlationId?: string; eventData?: unknown };\n return {\n runId,\n eventId: \"\",\n eventType: data.eventType,\n createdAt: new Date(),\n ...(correlationId ? { correlationId } : {}),\n ...(eventData ? { eventData } : {}),\n } as unknown as Event;\n}\n\n/**\n * The platform's error as Workflow SDK's tooling expects a World's: a\n * missing run is `WorkflowRunNotFoundError` (404), a refused token says how\n * to get one, a token without the deploy scope says what needs it.\n */\nfunction translate(error: unknown, alias: string, runId: string | undefined): unknown {\n const refused = (status: number, cause: unknown) =>\n new UnfazedInspectError(\n `unfazed: the platform refused the API token (HTTP ${status}). Check ${TOKEN_ENV_VAR}; ` +\n \"get a token at https://unfazed.dev/auth.md.\",\n { status, cause },\n );\n if (error instanceof UnfazedHTTPError) {\n if (error.status === 401 || error.status === 403) return refused(error.status, error);\n return new UnfazedInspectError(error.message, { status: error.status, cause: error });\n }\n if (!(error instanceof UnfazedGraphQLError)) return error;\n const message = error.errors.map((e) => e.message).join(\"; \");\n if (message.trim() === \"authentication required\") return refused(401, error);\n if (/^no such run\\b/.test(message)) {\n return new UnfazedInspectError(runId ? `Workflow run \"${runId}\" not found` : `unfazed: ${message}`, {\n name: \"WorkflowRunNotFoundError\",\n status: 404,\n runId,\n cause: error,\n });\n }\n if (/^no such (step|event|stream)\\b/.test(message)) {\n return new UnfazedInspectError(`unfazed: ${message}`, { status: 404, cause: error });\n }\n if (message.trim() === \"deployment was not found\") {\n return new UnfazedInspectError(\n `unfazed: no app \"${alias}\" that this token can see. Check ${APP_ENV_VAR} (the app's alias) and that ` +\n \"the token's account owns the app or shares its team.\",\n { status: 404, cause: error },\n );\n }\n const scope = /missing OAuth scope (\\S+)/.exec(message);\n if (scope) {\n const needs = scope[1] === \"unfz:deploy\" ? \" (cancel and wake need it, like restarting the app)\" : \"\";\n return new UnfazedInspectError(`unfazed: this API token lacks the ${scope[1]} scope${needs}.`, { status: 403, cause: error });\n }\n return new UnfazedInspectError(`unfazed: ${message}`, { cause: error });\n}\n\n/** The status of the \"run … already ended (<status>)\" refusal (409 `run_terminal`), else undefined. */\nfunction endedAs(error: unknown): string | undefined {\n return /already ended \\(([a-z]+)\\)/.exec(error instanceof Error ? error.message : \"\")?.[1];\n}\n\nfunction normalizeEndpoint(value: string): string {\n const trimmed = value.replace(/\\/+$/, \"\");\n return /\\/query$|\\/graphql$/.test(trimmed) ? trimmed : `${trimmed}/query`;\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n return Number.isFinite(value) ? Math.min(max, Math.max(min, Math.trunc(value))) : min;\n}\n\nfunction setDate(record: Record<string, unknown>, key: string, value: string | null): void {\n const date = toDate(value);\n if (date) record[key] = date;\n}\n\nfunction setDefined(record: Record<string, unknown>, key: string, value: unknown): void {\n if (value !== undefined) record[key] = value;\n}\n\n/** `fn` over `items`, at most `limit` at a time, results in order. */\nasync function mapLimit<T, R>(items: readonly T[], limit: number, fn: (item: T) => Promise<R>): Promise<R[]> {\n const results = new Array<R>(items.length);\n let next = 0;\n const worker = async () => {\n while (next < items.length) {\n const index = next++;\n results[index] = await fn(items[index]!);\n }\n };\n await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));\n return results;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"world.js","sourceRoot":"","sources":["../../src/remote/world.ts"],"names":[],"mappings":"AA+CA,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAkB,MAAM,cAAc,CAAC;AACvG,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC5G,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,SAAS,EACT,KAAK,EACL,eAAe,EACf,eAAe,EACf,MAAM,GACP,MAAM,aAAa,CAAC;AA0CrB;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAErC,qFAAqF;AACrF,MAAM,eAAe,GAAG,KAAK,CAAC;AAC9B,0EAA0E;AAC1E,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,+FAA+F;AAC/F,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,kBAAkB,GAAG,KAAK,CAAC;AACjC,MAAM,WAAW,GAAG,CAAC,CAAC;AACtB,sHAAsH;AACtH,MAAM,oBAAoB,GAAG,MAAM,CAAC;AACpC,yFAAyF;AACzF,MAAM,QAAQ,GAAG,YAAY,CAAC;AAI9B;;;GAGG;AACH,MAAM,UAAU,iBAAi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SAAS,OAAO,CAAC,MAA+B,EAAE,GAAW,EAAE,KAAoB;IACjF,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3B,IAAI,IAAI;QAAE,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;AAC/B,CAAC;AAED,SAAS,UAAU,CAAC,MAA+B,EAAE,GAAW,EAAE,KAAc;IAC9E,IAAI,KAAK,KAAK,SAAS;QAAE,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAC/C,CAAC;AAED,sEAAsE;AACtE,KAAK,UAAU,QAAQ,CAAO,KAAmB,EAAE,KAAa,EAAE,EAA2B;IAC3F,MAAM,OAAO,GAAG,IAAI,KAAK,CAAI,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3C,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,MAAM,MAAM,GAAG,KAAK,IAAI,EAAE;QACxB,OAAO,IAAI,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;YAC3B,MAAM,KAAK,GAAG,IAAI,EAAE,CAAC;YACrB,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,KAAK,CAAE,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC,CAAC;IACF,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IACjF,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/**\n * The `unfazed` backend of Workflow SDK's CLI: a World that reads an app's\n * workflow runs through the platform's inspection API, so\n *\n * ```sh\n * UNFZ_APP=birthday-card npx workflow inspect runs --backend unfazed\n * ```\n *\n * works like `--backend vercel` does. The CLI imports `unfazed` from the\n * project and calls `createWorld()` (see `../index.ts`), which lazily loads\n * this module.\n *\n * Every read is one GraphQL call to the control plane, which relays it to the\n * app's own inspection route over the worker (unfazed docs/workflow-inspect.md):\n * the app reads its runs through its own World and sends display data, which\n * `./values.ts` turns back into the serialized data Workflow SDK's tooling\n * hydrates. Writes are refused, except the two the inspection API offers:\n * cancelling a run (`workflow cancel`, the web UI) and waking a sleeping one\n * (the web UI's \"Wake up\").\n *\n * Only type imports from `@workflow/world`: the root entry stays free of\n * runtime dependencies.\n */\nimport type {\n AnyEventRequest,\n BulkCancelWorkflowRunResult,\n BulkCancelWorkflowRunsRequest,\n BulkCancelWorkflowRunsResult,\n Event,\n GetChunksOptions,\n GetEventParams,\n GetStepParams,\n GetWorkflowRunParams,\n Hook,\n ListEventsByCorrelationIdParams,\n ListEventsParams,\n ListHooksParams,\n ListWorkflowRunsParams,\n ListWorkflowRunStepsParams,\n PaginatedResponse,\n PaginationOptions,\n Step,\n StreamChunksResponse,\n StreamInfoResponse,\n World,\n WorkflowRun,\n} from \"@workflow/world\";\nimport { ENDPOINT_ENV_VAR, TOKEN_ENV_VAR, UnfazedClient, VERSION, type FetchLike } from \"../client.js\";\nimport { LOGIN_COMMAND } from \"../credentials.js\";\nimport { UnfazedAuthError, UnfazedGraphQLError, UnfazedHTTPError, UnfazedInspectError } from \"../errors.js\";\nimport { APP_ENV_VAR, currentDirectory, resolveAlias } from \"./app.js\";\nimport * as docs from \"./documents.js\";\nimport {\n chunkValue,\n EVENT_PAYLOAD_FIELDS,\n eventData,\n frame,\n serializedValue,\n structuredError,\n toDate,\n} from \"./values.js\";\n\nexport interface RemoteWorldOptions {\n /** The app's alias. Default: `UNFZ_APP`, else the `alias` (or single `apps[]` entry) of `unfazed.json` in `cwd`. */\n alias?: string;\n /** Bearer token. Default: `UNFZ_API_TOKEN`, else the stored login of `npx unfazed login`. */\n token?: string;\n /** Full GraphQL endpoint. Default: `UNFZ_API_URL`, else https://unfazed.dev/query. */\n endpoint?: string;\n /** Where the defaults above (and the stored login's location) are read from. Default: `process.env`. */\n env?: Record<string, string | undefined>;\n /** Directory whose `unfazed.json` names the app. Default: the current directory. */\n cwd?: string;\n /** Per-request timeout in ms. Default 60 000 (a relay may include the app's cold start). */\n timeoutMs?: number;\n /**\n * How long `streams.get` waits between reads of a stream still being\n * written, at most: it starts at 1 s and doubles up to this. Default 5 000.\n */\n streamPollMs?: number;\n /** Injection point for tests. */\n fetch?: FetchLike;\n}\n\n/**\n * The World `createWorld()` from `unfazed` returns: Workflow SDK's `World`\n * interface over the inspection API. Typed loosely here so the root entry's\n * declarations need no `@workflow/world`; cast to its `World` when you call\n * it from code.\n */\nexport interface RemoteWorld {\n /** The app it reads. */\n readonly alias: string;\n readonly specVersion: number;\n readonly runs: object;\n readonly steps: object;\n readonly events: object;\n readonly hooks: object;\n readonly streams: object;\n close(): Promise<void>;\n}\n\n/**\n * `SPEC_VERSION_CURRENT` of the `@workflow/world` this backend was written\n * against (a test keeps the two equal). Informational: this World creates\n * and replays nothing.\n */\nexport const REMOTE_SPEC_VERSION = 8;\n\n/** A run page is reused for this long, so one CLI or web UI view costs one relay. */\nconst RUN_PAGE_TTL_MS = 2_000;\n/** Active runs searched for a hook that no run page read so far named. */\nconst HOOK_SCAN_RUNS = 20;\n/** Pages of 200 steps read to serve `steps.list` newest first (the API lists oldest first). */\nconst STEP_PAGES_MAX = 10;\nconst STREAM_PAGE = 50;\nconst STREAM_POLL_MIN_MS = 1_000;\nconst CONCURRENCY = 4;\n/** A wake-up's own re-enqueue happens inside the app; the SDK's follow-up `queue()` within this window is a no-op. */\nconst WAKE_QUEUE_WINDOW_MS = 60_000;\n/** Hook tokens never leave the app (contract: hooks are shown by ID, kind and state). */\nconst REDACTED = \"[redacted]\";\n\ntype Env = Record<string, string | undefined>;\n\n/**\n * Creates the CLI backend's World for one app. Throws when there is no token\n * or no app to read, saying what to set.\n */\nexport function createRemoteWorld(options: RemoteWorldOptions = {}): RemoteWorld {\n const env: Env = options.env ?? (globalThis as { process?: { env?: Env } }).process?.env ?? {};\n const endpointEnv = env[ENDPOINT_ENV_VAR];\n let client: UnfazedClient;\n try {\n // The token is `token`, else UNFZ_API_TOKEN, else the stored login of\n // `npx unfazed login` (refreshed as it expires), all read from `env`.\n client = new UnfazedClient({\n ...(options.token ? { token: options.token } : {}),\n env,\n endpoint: options.endpoint ?? (endpointEnv ? normalizeEndpoint(endpointEnv) : undefined),\n timeoutMs: options.timeoutMs ?? 60_000,\n userAgent: `unfazed-sdk/${VERSION} (workflow-cli-backend)`,\n ...(options.fetch ? { fetch: options.fetch } : {}),\n });\n } catch (error) {\n if (!(error instanceof UnfazedAuthError)) throw error;\n const inApp = env[\"UNFZ_STATE_URL\"]\n ? ' Inside an unfazed app the World is unfazed/workflow (its Nitro module, or setWorld(createWorld()) from \"unfazed/workflow\"); ' +\n \"WORKFLOW_TARGET_WORLD=unfazed selects this read-only CLI backend instead.\"\n : \"\";\n // A login for another control plane says which command fixes it; keep that.\n const message = error.message.includes(\"the stored login is for\")\n ? error.message\n : `unfazed: not signed in. Run \\`${LOGIN_COMMAND}\\` to inspect your apps' workflow runs with your own account, ` +\n `or set ${TOKEN_ENV_VAR} (a token with the unfz:read scope; unfz:deploy too for cancel and wake; ` +\n `an agent gets one at https://unfazed.dev/auth.md).`;\n throw new UnfazedAuthError(message + inApp, { cause: error });\n }\n const alias = resolveAlias({ alias: options.alias, env, cwd: options.cwd ?? currentDirectory() });\n const authSource = client.authSource;\n const pollMaxMs = Math.max(1, options.streamPollMs ?? 5_000);\n const pollMinMs = Math.min(STREAM_POLL_MIN_MS, pollMaxMs);\n\n let closed = false;\n /** Pending waits of stream readers; `close()` ends them so no timer outlives the World. */\n const sleepers = new Set<() => void>();\n const sleep = (ms: number) =>\n new Promise<void>((resolve) => {\n const wake = () => {\n clearTimeout(timer);\n sleepers.delete(wake);\n resolve();\n };\n const timer = setTimeout(wake, ms);\n sleepers.add(wake);\n });\n\n // ---- Transport and errors ----\n\n async function call<T>(document: string, variables: Record<string, unknown>, runId?: string): Promise<T> {\n try {\n return await client.request<T>(document, variables);\n } catch (error) {\n throw translate(error, alias, runId, authSource);\n }\n }\n\n // ---- Run pages: one relay serves runs.get, hooks, streams.list ----\n\n const runPages = new Map<string, { expires: number; page: Promise<docs.WorkflowRunPage> }>();\n /** hookId → runId, from every run page read: how `hooks.get(hookId)` finds the run. */\n const hookRuns = new Map<string, string>();\n\n function runPage(runId: string): Promise<docs.WorkflowRunPage> {\n const cached = runPages.get(runId);\n if (cached && cached.expires > Date.now()) return cached.page;\n // Never expires while in flight (a relay may wait out a cold start); reused for a moment after.\n const entry = { expires: Number.POSITIVE_INFINITY } as { expires: number; page: Promise<docs.WorkflowRunPage> };\n entry.page = call<docs.RunResult>(docs.RUN, { alias, runID: runId }, runId).then(\n ({ workflowRun }) => {\n for (const hook of workflowRun.hooks) hookRuns.set(hook.hookID, runId);\n entry.expires = Date.now() + RUN_PAGE_TTL_MS;\n return workflowRun;\n },\n (error: unknown) => {\n if (runPages.get(runId) === entry) runPages.delete(runId);\n throw error;\n },\n );\n runPages.set(runId, entry);\n return entry.page;\n }\n\n // ---- Records in the World's shapes ----\n\n function runRecord(run: docs.WorkflowRunSummary, page?: docs.WorkflowRunPage, withData = false): WorkflowRun {\n const record: Record<string, unknown> = {\n runId: run.runID,\n status: run.status.toLowerCase(),\n deploymentId: run.deploymentID,\n workflowName: run.workflowName,\n attributes: Object.fromEntries(run.attributes.map(({ key, value }) => [key, value])),\n createdAt: toDate(run.createdAt),\n updatedAt: toDate(run.updatedAt),\n };\n setDate(record, \"startedAt\", run.startedAt);\n setDate(record, \"completedAt\", run.completedAt);\n setDate(record, \"expiredAt\", run.expiredAt);\n if (run.errorCode !== null) record.errorCode = run.errorCode;\n if (page && withData) {\n setDefined(record, \"input\", serializedValue(page.input));\n setDefined(record, \"output\", serializedValue(page.output));\n }\n if (page?.error) record.error = structuredError(page.error);\n return record as unknown as WorkflowRun;\n }\n\n function stepRecord(\n runId: string,\n step: docs.WorkflowStep,\n detail?: docs.StepResult[\"workflowStep\"],\n withData = false,\n ): Step {\n const record: Record<string, unknown> = {\n runId,\n stepId: step.stepID,\n stepName: step.stepName,\n status: step.status,\n attempt: step.attempt,\n createdAt: toDate(step.createdAt),\n updatedAt: toDate(step.updatedAt),\n };\n setDate(record, \"startedAt\", step.startedAt);\n setDate(record, \"completedAt\", step.completedAt);\n setDate(record, \"retryAfter\", step.retryAfter);\n if (detail && withData) {\n setDefined(record, \"input\", serializedValue(detail.input));\n setDefined(record, \"output\", serializedValue(detail.output));\n }\n if (detail?.error) record.error = structuredError(detail.error);\n return record as unknown as Step;\n }\n\n function eventRecord(runId: string, event: docs.WorkflowEvent, data?: docs.WorkflowValue | null): Event {\n const record: Record<string, unknown> = {\n runId,\n eventId: event.eventID,\n eventType: event.eventType,\n createdAt: toDate(event.createdAt),\n eventData: eventData(event.info),\n };\n if (event.correlationID !== null) record.correlationId = event.correlationID;\n const field = EVENT_PAYLOAD_FIELDS[event.eventType];\n if (field && data) (record.eventData as Record<string, unknown>)[field] = serializedValue(data);\n return record as unknown as Event;\n }\n\n function hookRecord(runId: string, hook: docs.WorkflowHook): Hook {\n const record: Record<string, unknown> = {\n runId,\n hookId: hook.hookID,\n token: REDACTED,\n ownerId: \"\",\n projectId: alias,\n environment: \"production\",\n createdAt: toDate(hook.createdAt),\n isWebhook: hook.kind === \"webhook\",\n isSystem: hook.kind === \"system\",\n // What the inspection API adds: the hook's state from its run's events.\n status: hook.status,\n receivedCount: hook.receivedCount,\n };\n setDate(record, \"lastReceivedAt\", hook.lastReceivedAt);\n setDate(record, \"disposedAt\", hook.disposedAt);\n return record as unknown as Hook;\n }\n\n // ---- Lists ----\n\n async function allSteps(runId: string): Promise<docs.WorkflowStep[]> {\n const steps: docs.WorkflowStep[] = [];\n let cursor: string | null = null;\n for (let page = 0; page < STEP_PAGES_MAX; page++) {\n const { workflowSteps }: docs.StepsResult = await call<docs.StepsResult>(\n docs.STEPS,\n { alias, runID: runId, limit: 200, cursor },\n runId,\n );\n steps.push(...workflowSteps.steps);\n if (!workflowSteps.hasMore || !workflowSteps.nextCursor) break;\n cursor = workflowSteps.nextCursor;\n }\n return steps;\n }\n\n async function activeRuns(limit: number, cursor: string | null) {\n const { workflowRuns } = await call<docs.RunsResult>(docs.RUNS, {\n alias,\n status: [\"RUNNING\", \"PENDING\"],\n limit,\n cursor,\n });\n const pages = await mapLimit(workflowRuns.runs, CONCURRENCY, (run) => runPage(run.runID));\n return { pages, nextCursor: workflowRuns.nextCursor, hasMore: workflowRuns.hasMore };\n }\n\n function hooksOf(page: docs.WorkflowRunPage, onlyActive: boolean): Hook[] {\n return page.hooks\n .filter((hook) => !onlyActive || hook.status === \"active\")\n .map((hook) => hookRecord(page.run.runID, hook));\n }\n\n // ---- Writes the inspection API offers ----\n\n /** Runs woken through this World, for the SDK's follow-up `queue()` (see {@link WAKE_QUEUE_WINDOW_MS}). */\n const woken = new Map<string, number>();\n\n /**\n * Cancels a run; resolves `\"already_cancelled\"` for a run cancelled before,\n * which, as in the upstream Worlds, is not an error. A run that completed or\n * failed is refused with the platform's \"run … already ended (…)\".\n */\n async function cancel(runId: string, reason?: string): Promise<\"cancelled\" | \"already_cancelled\"> {\n try {\n await call<docs.CancelResult>(\n docs.CANCEL,\n // The platform takes at most 512 characters (code points); cut on a character boundary.\n { input: { alias, runID: runId, ...(reason !== undefined ? { reason: Array.from(reason).slice(0, 512).join(\"\") } : {}) } },\n runId,\n );\n return \"cancelled\";\n } catch (error) {\n if (endedAs(error) === \"cancelled\") return \"already_cancelled\";\n throw error;\n } finally {\n runPages.delete(runId);\n }\n }\n\n // ---- The World ----\n\n const world = {\n alias,\n specVersion: REMOTE_SPEC_VERSION,\n capabilities: {},\n\n runs: {\n async get(id: string, params?: GetWorkflowRunParams) {\n const page = await runPage(id);\n return runRecord(page.run, page, params?.resolveData !== \"none\");\n },\n\n async list(params: ListWorkflowRunsParams = {}): Promise<PaginatedResponse<WorkflowRun>> {\n if ((params.pagination?.sortOrder ?? \"desc\") !== \"desc\") {\n throw invalidArgument(\"runs.list\", \"sortOrder\", \"the unfazed backend lists runs newest first only; drop --sort asc\");\n }\n const status =\n params.status === undefined\n ? null\n : (Array.isArray(params.status) ? params.status : [params.status]).map((s) => s.toUpperCase());\n const { workflowRuns } = await call<docs.RunsResult>(docs.RUNS, {\n alias,\n status,\n workflowName: params.workflowName ?? null,\n limit: clamp(params.pagination?.limit ?? 20, 1, 100),\n cursor: params.pagination?.cursor || null,\n });\n return {\n data: workflowRuns.runs.map((run) => runRecord(run)),\n cursor: workflowRuns.hasMore ? workflowRuns.nextCursor : null,\n hasMore: workflowRuns.hasMore,\n };\n },\n\n async cancelMany(request: BulkCancelWorkflowRunsRequest): Promise<BulkCancelWorkflowRunsResult> {\n const results = await mapLimit(request.runIds, CONCURRENCY, async (runId): Promise<BulkCancelWorkflowRunResult> => {\n try {\n return { runId, outcome: await cancel(runId, request.cancelReason) };\n } catch (error) {\n if (error instanceof UnfazedInspectError && (error.status === 401 || error.status === 403)) throw error;\n const ended = endedAs(error);\n if (ended) return { runId, outcome: \"not_cancellable\", status: ended };\n if (error instanceof UnfazedInspectError && error.name === \"WorkflowRunNotFoundError\") {\n return { runId, outcome: \"not_found\" };\n }\n return { runId, outcome: \"failed\", code: \"internal_error\", retryable: true };\n }\n });\n const count = (outcome: BulkCancelWorkflowRunResult[\"outcome\"]) => results.filter((r) => r.outcome === outcome).length;\n return {\n summary: {\n requested: results.length,\n cancelled: count(\"cancelled\"),\n alreadyCancelled: count(\"already_cancelled\"),\n notCancellable: count(\"not_cancellable\"),\n notFound: count(\"not_found\"),\n failed: count(\"failed\"),\n },\n results,\n };\n },\n },\n\n steps: {\n async get(runId: string, stepId: string, params?: GetStepParams) {\n const { workflowStep } = await call<docs.StepResult>(docs.STEP_DETAIL, { alias, runID: runId, stepID: stepId }, runId);\n return stepRecord(runId, workflowStep.step, workflowStep, params?.resolveData !== \"none\");\n },\n\n async list(params: ListWorkflowRunStepsParams): Promise<PaginatedResponse<Step>> {\n const { runId, pagination } = params;\n const limit = clamp(pagination?.limit ?? 20, 1, 200);\n if ((pagination?.sortOrder ?? \"desc\") === \"asc\") {\n if (pagination?.cursor?.startsWith(CURSOR_PREFIX)) throw badCursor(\"steps.list\");\n const { workflowSteps } = await call<docs.StepsResult>(\n docs.STEPS,\n { alias, runID: runId, limit, cursor: pagination?.cursor || null },\n runId,\n );\n return {\n data: workflowSteps.steps.map((step) => stepRecord(runId, step)),\n cursor: workflowSteps.hasMore ? workflowSteps.nextCursor : null,\n hasMore: workflowSteps.hasMore,\n };\n }\n // Newest first: the API pages oldest first, so read the run's steps and page them here.\n const offset = decodeOffset(pagination?.cursor, \"steps.list\");\n const steps = (await allSteps(runId)).reverse();\n return offsetPage(\n steps.map((step) => stepRecord(runId, step)),\n offset,\n limit,\n );\n },\n },\n\n events: {\n async get(runId: string, eventId: string, params?: GetEventParams) {\n const { workflowEvent } = await call<docs.EventResult>(docs.EVENT_DETAIL, { alias, runID: runId, eventID: eventId }, runId);\n return eventRecord(runId, workflowEvent.event, params?.resolveData === \"none\" ? null : workflowEvent.data);\n },\n\n async list(params: ListEventsParams) {\n return listEvents(params.runId, null, params.pagination);\n },\n\n async listByCorrelationId(params: ListEventsByCorrelationIdParams) {\n if (!params.runId) {\n throw invalidArgument(\"events.listByCorrelationId\", \"runId\", \"the unfazed backend reads events per run: pass the run ID\");\n }\n return listEvents(params.runId, params.correlationId, params.pagination);\n },\n\n async create(runId: string | null, data: AnyEventRequest) {\n if (runId && data.eventType === \"run_cancelled\") {\n const reason = (data.eventData as { cancelReason?: unknown } | undefined)?.cancelReason;\n await cancel(runId, typeof reason === \"string\" ? reason : undefined);\n return { event: syntheticEvent(runId, data) };\n }\n if (runId && data.eventType === \"wait_completed\" && data.correlationId) {\n await call<docs.WakeResult>(docs.WAKE, { input: { alias, runID: runId, correlationIDs: [data.correlationId] } }, runId);\n woken.set(runId, Date.now() + WAKE_QUEUE_WINDOW_MS);\n runPages.delete(runId);\n return { event: syntheticEvent(runId, data) };\n }\n throw readOnly(`write a ${data.eventType} event`);\n },\n },\n\n hooks: {\n async get(hookId: string) {\n const known = hookRuns.get(hookId);\n if (known) {\n const hook = (await runPage(known)).hooks.find((h) => h.hookID === hookId);\n if (hook) return hookRecord(known, hook);\n }\n const { pages } = await activeRuns(HOOK_SCAN_RUNS, null);\n for (const page of pages) {\n const hook = page.hooks.find((h) => h.hookID === hookId);\n if (hook) return hookRecord(page.run.runID, hook);\n }\n throw new UnfazedInspectError(\n `Hook ${hookId} not found. The unfazed backend finds a hook through its run, and no run read so far, ` +\n `nor any of the ${HOOK_SCAN_RUNS} newest active runs, has it. List a run's hooks with ` +\n \"`workflow inspect hooks --runId <run-id>`.\",\n { name: \"HookNotFoundError\", status: 404 },\n );\n },\n\n async getByToken(): Promise<Hook> {\n throw readOnly(\"look a hook up by its token (hook tokens never leave the app)\");\n },\n\n async list(params: ListHooksParams): Promise<PaginatedResponse<Hook>> {\n const { runId, pagination } = params;\n const desc = pagination?.sortOrder === \"desc\";\n const byCreated = (a: Hook, b: Hook) => (a.createdAt.getTime() - b.createdAt.getTime()) * (desc ? -1 : 1);\n if (runId) {\n const hooks = hooksOf(await runPage(runId), false).sort(byCreated);\n return offsetPage(hooks, decodeOffset(pagination?.cursor, \"hooks.list\"), clamp(pagination?.limit ?? 100, 1, 500));\n }\n // Every hook of the app: those of its active runs (a finished run's hooks are gone), a page of runs at a time.\n const runsCursor = decodeWrapped(pagination?.cursor, \"runs\", \"hooks.list\");\n const { pages, nextCursor, hasMore } = await activeRuns(clamp(pagination?.limit ?? 20, 1, HOOK_SCAN_RUNS), runsCursor);\n return {\n data: pages.flatMap((page) => hooksOf(page, true)).sort(byCreated),\n cursor: hasMore && nextCursor ? `${CURSOR_PREFIX}runs:${nextCursor}` : null,\n hasMore: hasMore && nextCursor !== null,\n };\n },\n },\n\n streams: {\n async list(runId: string) {\n return (await runPage(runId)).streams.map((stream) => stream.name);\n },\n\n async getInfo(runId: string, name: string): Promise<StreamInfoResponse> {\n const { workflowStream } = await call<docs.StreamResult>(docs.STREAM, { alias, runID: runId, name, limit: 1 }, runId);\n return { tailIndex: workflowStream.tailIndex, done: workflowStream.done };\n },\n\n async getChunks(runId: string, name: string, options?: GetChunksOptions): Promise<StreamChunksResponse> {\n const { workflowStream } = await call<docs.StreamResult>(\n docs.STREAM,\n { alias, runID: runId, name, limit: clamp(options?.limit ?? 100, 1, 200), cursor: options?.cursor || null },\n runId,\n );\n return {\n data: workflowStream.chunks.map((chunk) => ({ index: chunk.index, data: frame(chunkValue(chunk)) })),\n cursor: workflowStream.hasMore ? workflowStream.nextCursor : null,\n hasMore: workflowStream.hasMore,\n done: workflowStream.done,\n };\n },\n\n /**\n * The stream from `startIndex` (negative: from the end), each chunk one\n * frame, read a page at a time and, while the run is still writing it,\n * polled (1 s, doubling up to `streamPollMs`) until it is done.\n */\n async get(runId: string, name: string, startIndex = 0): Promise<ReadableStream<Uint8Array>> {\n let pageCursor: string | null = null;\n let position: number | undefined;\n let delay = pollMinMs;\n let cancelled = false;\n return new ReadableStream<Uint8Array>({\n async pull(controller) {\n for (;;) {\n if (cancelled || closed) {\n controller.close();\n return;\n }\n const { workflowStream } = await call<docs.StreamResult>(\n docs.STREAM,\n { alias, runID: runId, name, limit: STREAM_PAGE, cursor: pageCursor },\n runId,\n );\n position ??= startIndex < 0 ? Math.max(0, workflowStream.tailIndex + 1 + startIndex) : startIndex;\n const fresh = workflowStream.chunks.filter((chunk) => chunk.index >= position!);\n // A page with more after it is never read again; the last page is re-read for new chunks.\n if (workflowStream.hasMore && workflowStream.nextCursor) pageCursor = workflowStream.nextCursor;\n if (fresh.length > 0) {\n for (const chunk of fresh) controller.enqueue(frame(chunkValue(chunk)));\n position = fresh[fresh.length - 1]!.index + 1;\n delay = pollMinMs;\n return;\n }\n if (workflowStream.hasMore) continue;\n if (workflowStream.done) {\n controller.close();\n return;\n }\n await sleep(delay);\n delay = Math.min(delay * 2, pollMaxMs);\n }\n },\n cancel() {\n cancelled = true;\n },\n });\n },\n\n async write(): Promise<void> {\n throw readOnly(\"write to a stream\");\n },\n async writeMulti(): Promise<void> {\n throw readOnly(\"write to a stream\");\n },\n async close(): Promise<void> {\n throw readOnly(\"close a stream\");\n },\n },\n\n async getDeploymentId(): Promise<string> {\n throw readOnly(\"start runs (it has no deployment of its own)\");\n },\n\n async queue(_queueName: string, message: unknown) {\n const runId = (message as { runId?: unknown } | null)?.runId;\n const until = typeof runId === \"string\" ? woken.get(runId) : undefined;\n // `wakeUp()` re-enqueues the run after completing its waits; the app already did both.\n if (until !== undefined && until > Date.now()) return { messageId: null };\n throw readOnly(\"enqueue messages\");\n },\n\n createQueueHandler(): (req: Request) => Promise<Response> {\n throw readOnly(\"handle queue deliveries\");\n },\n\n async close() {\n closed = true;\n for (const wake of [...sleepers]) wake();\n },\n };\n\n async function listEvents(runId: string, correlationId: string | null, pagination?: PaginationOptions): Promise<PaginatedResponse<Event>> {\n const { workflowEvents } = await call<docs.EventsResult>(\n docs.EVENTS,\n {\n alias,\n runID: runId,\n correlationID: correlationId,\n newestFirst: pagination?.sortOrder === \"desc\",\n limit: clamp(pagination?.limit ?? 100, 1, 500),\n cursor: pagination?.cursor || null,\n },\n runId,\n );\n return {\n data: workflowEvents.events.map((event) => eventRecord(runId, event)),\n cursor: workflowEvents.hasMore ? workflowEvents.nextCursor : null,\n hasMore: workflowEvents.hasMore,\n };\n }\n\n // Every member exists on Workflow SDK's World (no misspelt or invented method); parameters\n // are the World's own types above. The overloaded return types are not checked here.\n const keys: Implements<typeof world, World & { alias: string }> = true;\n const namespaces: [\n Implements<typeof world.runs, World[\"runs\"]>,\n Implements<typeof world.steps, World[\"steps\"]>,\n Implements<typeof world.events, World[\"events\"]>,\n Implements<typeof world.hooks, World[\"hooks\"]>,\n Implements<typeof world.streams, World[\"streams\"]>,\n ] = [true, true, true, true, true];\n void keys;\n void namespaces;\n return world as unknown as RemoteWorld;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers.\n// ---------------------------------------------------------------------------\n\n/** `true` when every key of `T` is a key of `U`. */\ntype Implements<T, U> = Exclude<keyof T, keyof U> extends never ? true : never;\n\n/** Cursors this backend mints itself (offset pages, wrapped run cursors); the API's own pass through untouched. */\nconst CURSOR_PREFIX = \"unfz:\";\n\nfunction offsetPage<T>(items: T[], offset: number, limit: number): PaginatedResponse<T> {\n const end = offset + limit;\n const hasMore = end < items.length;\n return { data: items.slice(offset, end), cursor: hasMore ? `${CURSOR_PREFIX}offset:${end}` : null, hasMore };\n}\n\nfunction decodeOffset(cursor: string | undefined, method: string): number {\n if (!cursor) return 0;\n const match = /^unfz:offset:(\\d{1,9})$/.exec(cursor);\n if (!match) throw badCursor(method);\n return Number(match[1]);\n}\n\nfunction decodeWrapped(cursor: string | undefined, kind: string, method: string): string | null {\n if (!cursor) return null;\n const prefix = `${CURSOR_PREFIX}${kind}:`;\n if (!cursor.startsWith(prefix) || cursor.length === prefix.length) throw badCursor(method);\n return cursor.slice(prefix.length);\n}\n\nfunction badCursor(method: string): UnfazedInspectError {\n return invalidArgument(method, \"cursor\", \"this cursor came from another listing or sort order\");\n}\n\nfunction invalidArgument(method: string, field: string, why: string): UnfazedInspectError {\n return new UnfazedInspectError(`unfazed: ${method}: ${field}: ${why}.`, { code: \"INVALID_ARGUMENT\" });\n}\n\nfunction readOnly(what: string): UnfazedInspectError {\n return new UnfazedInspectError(\n `unfazed: the \\`unfazed\\` CLI backend is read-only and cannot ${what}. It inspects an app's runs from your ` +\n \"terminal (workflow inspect, workflow cancel, the web UI). Apps use unfazed/workflow: its Nitro module, \" +\n 'or setWorld(createWorld()) from \"unfazed/workflow\", not WORKFLOW_TARGET_WORLD=unfazed.',\n { code: \"READ_ONLY\" },\n );\n}\n\nfunction syntheticEvent(runId: string, data: AnyEventRequest): Event {\n const { correlationId, eventData } = data as { correlationId?: string; eventData?: unknown };\n return {\n runId,\n eventId: \"\",\n eventType: data.eventType,\n createdAt: new Date(),\n ...(correlationId ? { correlationId } : {}),\n ...(eventData ? { eventData } : {}),\n } as unknown as Event;\n}\n\n/**\n * The platform's error as Workflow SDK's tooling expects a World's: a\n * missing run is `WorkflowRunNotFoundError` (404), a refused token says how\n * to get one, a token without the deploy scope says what needs it.\n */\nfunction translate(error: unknown, alias: string, runId: string | undefined, authSource: \"token\" | \"login\"): unknown {\n const refused = (status: number, cause: unknown) =>\n new UnfazedInspectError(\n authSource === \"login\"\n ? `unfazed: the platform refused the stored login (HTTP ${status}). Run \\`${LOGIN_COMMAND}\\` again.`\n : `unfazed: the platform refused the API token (HTTP ${status}). Check ${TOKEN_ENV_VAR}; ` +\n `sign in with \\`${LOGIN_COMMAND}\\` instead, or get an agent token at https://unfazed.dev/auth.md.`,\n { status, cause },\n );\n if (error instanceof UnfazedHTTPError) {\n if (error.status === 401 || error.status === 403) return refused(error.status, error);\n return new UnfazedInspectError(error.message, { status: error.status, cause: error });\n }\n if (!(error instanceof UnfazedGraphQLError)) return error;\n const message = error.errors.map((e) => e.message).join(\"; \");\n if (message.trim() === \"authentication required\") return refused(401, error);\n if (/^no such run\\b/.test(message)) {\n return new UnfazedInspectError(runId ? `Workflow run \"${runId}\" not found` : `unfazed: ${message}`, {\n name: \"WorkflowRunNotFoundError\",\n status: 404,\n runId,\n cause: error,\n });\n }\n if (/^no such (step|event|stream)\\b/.test(message)) {\n return new UnfazedInspectError(`unfazed: ${message}`, { status: 404, cause: error });\n }\n if (message.trim() === \"deployment was not found\") {\n return new UnfazedInspectError(\n `unfazed: no app \"${alias}\" that this token can see. Check ${APP_ENV_VAR} (the app's alias) and that ` +\n \"the token's account owns the app or shares its team.\",\n { status: 404, cause: error },\n );\n }\n const scope = /missing OAuth scope (\\S+)/.exec(message);\n if (scope) {\n const needs = scope[1] === \"unfz:deploy\" ? \" (cancel and wake need it, like restarting the app)\" : \"\";\n return new UnfazedInspectError(`unfazed: this API token lacks the ${scope[1]} scope${needs}.`, { status: 403, cause: error });\n }\n return new UnfazedInspectError(`unfazed: ${message}`, { cause: error });\n}\n\n/** The status of the \"run … already ended (<status>)\" refusal (409 `run_terminal`), else undefined. */\nfunction endedAs(error: unknown): string | undefined {\n return /already ended \\(([a-z]+)\\)/.exec(error instanceof Error ? error.message : \"\")?.[1];\n}\n\nfunction normalizeEndpoint(value: string): string {\n const trimmed = value.replace(/\\/+$/, \"\");\n return /\\/query$|\\/graphql$/.test(trimmed) ? trimmed : `${trimmed}/query`;\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n return Number.isFinite(value) ? Math.min(max, Math.max(min, Math.trunc(value))) : min;\n}\n\nfunction setDate(record: Record<string, unknown>, key: string, value: string | null): void {\n const date = toDate(value);\n if (date) record[key] = date;\n}\n\nfunction setDefined(record: Record<string, unknown>, key: string, value: unknown): void {\n if (value !== undefined) record[key] = value;\n}\n\n/** `fn` over `items`, at most `limit` at a time, results in order. */\nasync function mapLimit<T, R>(items: readonly T[], limit: number, fn: (item: T) => Promise<R>): Promise<R[]> {\n const results = new Array<R>(items.length);\n let next = 0;\n const worker = async () => {\n while (next < items.length) {\n const index = next++;\n results[index] = await fn(items[index]!);\n }\n };\n await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));\n return results;\n}\n"]}
|
package/dist/unfazed.d.ts
CHANGED
|
@@ -265,7 +265,7 @@ export interface UnfazedOptions extends ClientOptions {
|
|
|
265
265
|
* wrapped.
|
|
266
266
|
*
|
|
267
267
|
* ```ts
|
|
268
|
-
* const unfazed = new Unfazed();
|
|
268
|
+
* const unfazed = new Unfazed(); // UNFZ_API_TOKEN, else your `npx unfazed login`
|
|
269
269
|
* const ws = await unfazed.createWorkspace("hello");
|
|
270
270
|
* await unfazed.writeFiles(ws.id, { "server.ts": code });
|
|
271
271
|
* const app = await unfazed.deployService({ workspaceId: ws.id, alias: "hello", wait: true });
|
package/dist/unfazed.js
CHANGED
|
@@ -12,7 +12,7 @@ import { pollWithBackoff, resolveWaitOptions } from "./wait.js";
|
|
|
12
12
|
* wrapped.
|
|
13
13
|
*
|
|
14
14
|
* ```ts
|
|
15
|
-
* const unfazed = new Unfazed();
|
|
15
|
+
* const unfazed = new Unfazed(); // UNFZ_API_TOKEN, else your `npx unfazed login`
|
|
16
16
|
* const ws = await unfazed.createWorkspace("hello");
|
|
17
17
|
* await unfazed.writeFiles(ws.id, { "server.ts": code });
|
|
18
18
|
* const app = await unfazed.deployService({ workspaceId: ws.id, alias: "hello", wait: true });
|