{"version":3,"file":"apiRoutes.mjs","names":[],"sources":["../../../src/types/apiRoutes.ts"],"sourcesContent":["import { apiResponse, defineApiRoutes } from '@agimon-ai/doompi-core/web';\n\nimport type {\n  WorkflowArtifactContentResponse,\n  WorkflowArtifactsResponse,\n  WorkflowControlResponse,\n  WorkflowDeleteResponse,\n} from './webWorkflowTerminal';\n\n/**\n * This package's routes, as data.\n *\n * No scope and no base path. The build reads both off\n * `src/extensions/(backend)/api/workflow/`, so the mount is stated once, by the\n * folder that creates it. The same API answers at all three scopes, because a\n * global contribution cascades into workspace and session; the folder under\n * `workspaces/sessions/` only re-mounts it for a session's own server.\n *\n * This is the one file the routes, the Hono app and the browser all read, so a\n * path cannot move on one side alone. The page used to build the hub's own\n * absolute URL and then rewrite its plugin prefix with String.replace to reach\n * a session, which is exactly the kind of copy that can move by one character\n * without anything noticing.\n *\n * `:workspace` and `:runKey` are Hono's own parameter syntax, because the app\n * registers `path` verbatim.\n */\n\n/** One run, which every route below addresses. */\nconst RUN = '/runs/:workspace/:runKey';\n\n/**\n * The artifact route's parameter, as Hono spells a multi-segment match.\n *\n * An artifact is named by its path inside the run directory, so `reports/a.md`\n * is one parameter across two segments. The client's `params` substitution\n * fills a single segment and percent-encodes the slash with it, so the page\n * substitutes this one itself; see the page's `_lib/terminalApi.ts`.\n */\nexport const ARTIFACT_NAME_PARAM = ':name{.+}';\n\n/** Query parameters the artifact route reads, spelled once for both halves. */\nexport const ARTIFACT_RAW_PARAM = 'raw';\nexport const ARTIFACT_DOWNLOAD_PARAM = 'download';\n\nexport default defineApiRoutes({\n  /**\n   * The terminal, as server-sent events.\n   *\n   * `stream: true` gets a URL and no call method: the consumer is the browser's\n   * own `EventSource`, and a relayed call would buffer a stream that never ends.\n   */\n  screen: {\n    method: 'GET',\n    path: `${RUN}/screen/stream`,\n    stream: true,\n  },\n  control: {\n    method: 'POST',\n    path: `${RUN}/control`,\n    response: apiResponse<WorkflowControlResponse>(),\n  },\n  keys: {\n    method: 'POST',\n    path: `${RUN}/keys`,\n  },\n  resize: {\n    method: 'POST',\n    path: `${RUN}/resize`,\n    response: apiResponse<{ resized: boolean }>(),\n  },\n  remove: {\n    method: 'DELETE',\n    path: RUN,\n    response: apiResponse<WorkflowDeleteResponse>(),\n  },\n  artifacts: {\n    method: 'GET',\n    path: `${RUN}/artifacts`,\n    response: apiResponse<WorkflowArtifactsResponse>(),\n  },\n  /** One artifact: its metadata and text, or its raw bytes under `raw=1`. */\n  artifact: {\n    method: 'GET',\n    path: `${RUN}/artifacts/${ARTIFACT_NAME_PARAM}`,\n    query: [ARTIFACT_RAW_PARAM, ARTIFACT_DOWNLOAD_PARAM],\n    response: apiResponse<WorkflowArtifactContentResponse>(),\n  },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,MAAM;;;;;;;;;AAUZ,MAAa,sBAAsB;AAInC,MAAa,0BAA0B;AAEvC,IAAA,oBAAe,gBAAgB;;;;;;;CAO7B,QAAQ;EACN,QAAQ;EACR,MAAM,GAAG,IAAI;EACb,QAAQ;CACV;CACA,SAAS;EACP,QAAQ;EACR,MAAM,GAAG,IAAI;EACb,UAAU,YAAqC;CACjD;CACA,MAAM;EACJ,QAAQ;EACR,MAAM,GAAG,IAAI;CACf;CACA,QAAQ;EACN,QAAQ;EACR,MAAM,GAAG,IAAI;EACb,UAAU,YAAkC;CAC9C;CACA,QAAQ;EACN,QAAQ;EACR,MAAM;EACN,UAAU,YAAoC;CAChD;CACA,WAAW;EACT,QAAQ;EACR,MAAM,GAAG,IAAI;EACb,UAAU,YAAuC;CACnD;;CAEA,UAAU;EACR,QAAQ;EACR,MAAM,GAAG,IAAI,aAAa;EAC1B,OAAO,CAAA,OAAqB,uBAAuB;EACnD,UAAU,YAA6C;CACzD;AACF,CAAC"}