@coro-ai/runner 0.1.34 → 0.1.36
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/dashboard-dist/assets/{index-C7l2FOsX.js → index-DVdRvXW2.js} +1 -1
- package/dashboard-dist/index.html +1 -1
- package/dist/src/clients/github.d.ts +21 -10
- package/dist/src/clients/github.js +48 -40
- package/dist/src/clients/github.js.map +1 -1
- package/dist/src/cloud/db/postgres-backend.js +21 -13
- package/dist/src/cloud/db/postgres-backend.js.map +1 -1
- package/dist/src/cloud/db/schema.d.ts +1 -1
- package/dist/src/intake/system-prompt.js +3 -0
- package/dist/src/intake/system-prompt.js.map +1 -1
- package/dist/src/jobs/phase-assignment.d.ts +42 -0
- package/dist/src/jobs/phase-assignment.js +46 -43
- package/dist/src/jobs/phase-assignment.js.map +1 -1
- package/dist/src/jobs/runner.js +63 -34
- package/dist/src/jobs/runner.js.map +1 -1
- package/dist/src/plugins/refs.d.ts +50 -1
- package/dist/src/plugins/refs.js +97 -1
- package/dist/src/plugins/refs.js.map +1 -1
- package/dist/src/plugins/registry.d.ts +6 -0
- package/dist/src/plugins/registry.js +11 -2
- package/dist/src/plugins/registry.js.map +1 -1
- package/dist/src/plugins/types.d.ts +1 -1
- package/dist/src/prompt/builder.d.ts +2 -1
- package/dist/src/prompt/builder.js +42 -1
- package/dist/src/prompt/builder.js.map +1 -1
- package/dist/src/runner/build-settings.js +16 -4
- package/dist/src/runner/build-settings.js.map +1 -1
- package/dist/src/state/polling-transport.d.ts +41 -12
- package/dist/src/state/polling-transport.js +95 -56
- package/dist/src/state/polling-transport.js.map +1 -1
- package/dist/src/state/sqlite-backend.js +19 -13
- package/dist/src/state/sqlite-backend.js.map +1 -1
- package/dist/src/tools/run-subagent.js +10 -5
- package/dist/src/tools/run-subagent.js.map +1 -1
- package/node_modules/@coro-ai/cloud-protocol/package.json +1 -1
- package/node_modules/@coro-ai/intelligence-base/layer/agents/coder.md +1 -1
- package/node_modules/@coro-ai/intelligence-base/layer/agents/planner.md +1 -1
- package/node_modules/@coro-ai/intelligence-base/package.json +1 -1
- package/node_modules/@coro-ai/llm-anthropic/dist/credential-store.d.ts +58 -0
- package/node_modules/@coro-ai/llm-anthropic/dist/credential-store.d.ts.map +1 -0
- package/node_modules/@coro-ai/llm-anthropic/dist/credential-store.js +278 -0
- package/node_modules/@coro-ai/llm-anthropic/dist/credential-store.js.map +1 -0
- package/node_modules/@coro-ai/llm-anthropic/dist/executor.d.ts +12 -1
- package/node_modules/@coro-ai/llm-anthropic/dist/executor.d.ts.map +1 -1
- package/node_modules/@coro-ai/llm-anthropic/dist/executor.js +67 -44
- package/node_modules/@coro-ai/llm-anthropic/dist/executor.js.map +1 -1
- package/node_modules/@coro-ai/llm-anthropic/dist/http-routes.d.ts.map +1 -1
- package/node_modules/@coro-ai/llm-anthropic/dist/http-routes.js +4 -0
- package/node_modules/@coro-ai/llm-anthropic/dist/http-routes.js.map +1 -1
- package/node_modules/@coro-ai/llm-anthropic/dist/index.d.ts +2 -1
- package/node_modules/@coro-ai/llm-anthropic/dist/index.d.ts.map +1 -1
- package/node_modules/@coro-ai/llm-anthropic/dist/index.js +6 -2
- package/node_modules/@coro-ai/llm-anthropic/dist/index.js.map +1 -1
- package/node_modules/@coro-ai/llm-anthropic/dist/sandbox-probe.d.ts +11 -0
- package/node_modules/@coro-ai/llm-anthropic/dist/sandbox-probe.d.ts.map +1 -0
- package/node_modules/@coro-ai/llm-anthropic/dist/sandbox-probe.js +112 -0
- package/node_modules/@coro-ai/llm-anthropic/dist/sandbox-probe.js.map +1 -0
- package/node_modules/@coro-ai/llm-anthropic/dist/test-connection.d.ts +0 -26
- package/node_modules/@coro-ai/llm-anthropic/dist/test-connection.d.ts.map +1 -1
- package/node_modules/@coro-ai/llm-anthropic/dist/test-connection.js +40 -106
- package/node_modules/@coro-ai/llm-anthropic/dist/test-connection.js.map +1 -1
- package/node_modules/@coro-ai/llm-anthropic/package.json +1 -1
- package/node_modules/@coro-ai/llm-openai/dist/executor.d.ts.map +1 -1
- package/node_modules/@coro-ai/llm-openai/dist/executor.js +13 -10
- package/node_modules/@coro-ai/llm-openai/dist/executor.js.map +1 -1
- package/node_modules/@coro-ai/llm-openai/dist/models.d.ts.map +1 -1
- package/node_modules/@coro-ai/llm-openai/dist/models.js +3 -0
- package/node_modules/@coro-ai/llm-openai/dist/models.js.map +1 -1
- package/node_modules/@coro-ai/llm-openai/package.json +1 -1
- package/node_modules/@coro-ai/plugin-sdk/dist/chat-mcp.d.ts +10 -1
- package/node_modules/@coro-ai/plugin-sdk/dist/chat-mcp.d.ts.map +1 -1
- package/node_modules/@coro-ai/plugin-sdk/dist/chat-mcp.js +16 -2
- package/node_modules/@coro-ai/plugin-sdk/dist/chat-mcp.js.map +1 -1
- package/node_modules/@coro-ai/plugin-sdk/dist/helpers.d.ts +27 -1
- package/node_modules/@coro-ai/plugin-sdk/dist/helpers.d.ts.map +1 -1
- package/node_modules/@coro-ai/plugin-sdk/dist/helpers.js +47 -0
- package/node_modules/@coro-ai/plugin-sdk/dist/helpers.js.map +1 -1
- package/node_modules/@coro-ai/plugin-sdk/dist/types.d.ts +65 -4
- package/node_modules/@coro-ai/plugin-sdk/dist/types.d.ts.map +1 -1
- package/node_modules/@coro-ai/plugin-sdk/package.json +1 -1
- package/node_modules/@hono/node-server/README.md +104 -25
- package/node_modules/@hono/node-server/dist/conninfo.cjs +22 -0
- package/node_modules/@hono/node-server/dist/{conninfo.d.ts → conninfo.d.cts} +4 -3
- package/node_modules/@hono/node-server/dist/conninfo.d.mts +4 -3
- package/node_modules/@hono/node-server/dist/conninfo.mjs +19 -16
- package/node_modules/@hono/node-server/dist/constants-BLSFu_RU.mjs +5 -0
- package/node_modules/@hono/node-server/dist/constants-BXAKTxRC.cjs +11 -0
- package/node_modules/@hono/node-server/dist/early-hints.cjs +35 -0
- package/node_modules/@hono/node-server/dist/early-hints.d.cts +16 -0
- package/node_modules/@hono/node-server/dist/early-hints.d.mts +16 -0
- package/node_modules/@hono/node-server/dist/early-hints.mjs +33 -0
- package/node_modules/@hono/node-server/dist/index.cjs +1176 -0
- package/node_modules/@hono/node-server/dist/index.d.cts +101 -0
- package/node_modules/@hono/node-server/dist/index.d.mts +101 -8
- package/node_modules/@hono/node-server/dist/index.mjs +1146 -637
- package/node_modules/@hono/node-server/dist/serve-static.cjs +151 -0
- package/node_modules/@hono/node-server/dist/serve-static.d.cts +18 -0
- package/node_modules/@hono/node-server/dist/serve-static.d.mts +14 -13
- package/node_modules/@hono/node-server/dist/serve-static.mjs +143 -145
- package/node_modules/@hono/node-server/dist/utils/response.cjs +8 -0
- package/node_modules/@hono/node-server/dist/utils/response.d.cts +4 -0
- package/node_modules/@hono/node-server/dist/utils/response.d.mts +3 -2
- package/node_modules/@hono/node-server/dist/utils/response.mjs +6 -9
- package/node_modules/@hono/node-server/dist/utils/stream.cjs +65 -0
- package/node_modules/@hono/node-server/dist/utils/stream.d.cts +6 -0
- package/node_modules/@hono/node-server/dist/utils/stream.d.mts +6 -0
- package/node_modules/@hono/node-server/dist/utils/stream.mjs +64 -0
- package/node_modules/@hono/node-server/package.json +78 -54
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.js +1 -12
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.d.ts +7 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.js +9 -3
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.js +5 -3
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/index.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/index.js +1 -12
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/index.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.d.ts +5 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.d.ts.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.js +17 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.js.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.d.ts +9 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.js +10 -4
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.d.ts +21 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.js +239 -41
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/zod-compat.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/zod-compat.js +25 -6
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/zod-compat.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.d.ts +32 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.d.ts.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.js +64 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.js.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.d.ts +5 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.js +10 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js +2 -13
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.d.ts +7 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js +9 -3
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js +5 -3
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +2 -13
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.d.ts +5 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.d.ts.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js +13 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.d.ts +9 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js +10 -4
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.d.ts +21 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js +239 -41
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +25 -6
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.d.ts +32 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.d.ts.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js +57 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.d.ts +5 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js +9 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/media-typer/README.md +15 -14
- package/node_modules/@modelcontextprotocol/sdk/node_modules/media-typer/index.js +0 -8
- package/node_modules/@modelcontextprotocol/sdk/node_modules/media-typer/package.json +16 -12
- package/node_modules/@modelcontextprotocol/sdk/package.json +4 -3
- package/node_modules/express-rate-limit/dist/index.cjs +6 -1
- package/node_modules/express-rate-limit/dist/index.d.cts +10 -12
- package/node_modules/express-rate-limit/dist/index.d.mts +10 -12
- package/node_modules/express-rate-limit/dist/index.d.ts +10 -12
- package/node_modules/express-rate-limit/dist/index.mjs +6 -1
- package/node_modules/express-rate-limit/package.json +8 -8
- package/node_modules/express-rate-limit/readme.md +2 -2
- package/node_modules/fast-uri/index.js +54 -1
- package/node_modules/fast-uri/package.json +1 -1
- package/node_modules/fast-uri/test/security.test.js +198 -0
- package/node_modules/hono/dist/cjs/context.js +28 -13
- package/node_modules/hono/dist/cjs/helper/proxy/index.js +4 -0
- package/node_modules/hono/dist/cjs/helper/streaming/sse.js +5 -4
- package/node_modules/hono/dist/cjs/hono-base.js +3 -2
- package/node_modules/hono/dist/cjs/jsx/base.js +27 -23
- package/node_modules/hono/dist/cjs/jsx/hooks/index.js +16 -13
- package/node_modules/hono/dist/cjs/middleware/cache/index.js +103 -8
- package/node_modules/hono/dist/cjs/middleware/compress/index.js +5 -0
- package/node_modules/hono/dist/cjs/middleware/cors/index.js +2 -2
- package/node_modules/hono/dist/cjs/middleware/etag/index.js +4 -1
- package/node_modules/hono/dist/cjs/middleware/jwk/jwk.js +9 -4
- package/node_modules/hono/dist/cjs/middleware/jwt/jwt.js +9 -4
- package/node_modules/hono/dist/cjs/middleware/language/language.js +10 -6
- package/node_modules/hono/dist/cjs/middleware/method-not-allowed/index.js +90 -0
- package/node_modules/hono/dist/cjs/middleware/secure-headers/secure-headers.js +10 -4
- package/node_modules/hono/dist/cjs/request.js +14 -11
- package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +55 -56
- package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +64 -85
- package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +13 -5
- package/node_modules/hono/dist/cjs/router/trie-router/node.js +1 -1
- package/node_modules/hono/dist/cjs/router.js +1 -1
- package/node_modules/hono/dist/cjs/utils/accept.js +1 -1
- package/node_modules/hono/dist/cjs/utils/body.js +6 -0
- package/node_modules/hono/dist/cjs/utils/cookie.js +3 -2
- package/node_modules/hono/dist/cjs/utils/stream.js +5 -2
- package/node_modules/hono/dist/cjs/utils/url.js +8 -8
- package/node_modules/hono/dist/context.js +28 -13
- package/node_modules/hono/dist/helper/proxy/index.js +4 -0
- package/node_modules/hono/dist/helper/streaming/sse.js +5 -4
- package/node_modules/hono/dist/hono-base.js +3 -2
- package/node_modules/hono/dist/jsx/base.js +27 -23
- package/node_modules/hono/dist/jsx/hooks/index.js +16 -13
- package/node_modules/hono/dist/middleware/cache/index.js +103 -8
- package/node_modules/hono/dist/middleware/compress/index.js +5 -0
- package/node_modules/hono/dist/middleware/cors/index.js +2 -2
- package/node_modules/hono/dist/middleware/etag/index.js +4 -1
- package/node_modules/hono/dist/middleware/jwk/jwk.js +9 -4
- package/node_modules/hono/dist/middleware/jwt/jwt.js +9 -4
- package/node_modules/hono/dist/middleware/language/language.js +10 -6
- package/node_modules/hono/dist/middleware/method-not-allowed/index.js +68 -0
- package/node_modules/hono/dist/middleware/secure-headers/secure-headers.js +10 -4
- package/node_modules/hono/dist/request.js +15 -12
- package/node_modules/hono/dist/router/reg-exp-router/node.js +55 -56
- package/node_modules/hono/dist/router/reg-exp-router/router.js +64 -85
- package/node_modules/hono/dist/router/reg-exp-router/trie.js +13 -5
- package/node_modules/hono/dist/router/trie-router/node.js +1 -1
- package/node_modules/hono/dist/router.js +1 -1
- package/node_modules/hono/dist/types/adapter/aws-lambda/types.d.ts +9 -0
- package/node_modules/hono/dist/types/client/types.d.ts +1 -1
- package/node_modules/hono/dist/types/hono-base.d.ts +4 -3
- package/node_modules/hono/dist/types/jsx/base.d.ts +4 -2
- package/node_modules/hono/dist/types/jsx/dom/index.d.ts +5 -5
- package/node_modules/hono/dist/types/jsx/dom/intrinsic-element/components.d.ts +2 -2
- package/node_modules/hono/dist/types/jsx/dom/server.d.ts +5 -5
- package/node_modules/hono/dist/types/jsx/hooks/index.d.ts +8 -6
- package/node_modules/hono/dist/types/jsx/index.d.ts +5 -5
- package/node_modules/hono/dist/types/middleware/cache/index.d.ts +6 -4
- package/node_modules/hono/dist/types/middleware/combine/index.d.ts +1 -1
- package/node_modules/hono/dist/types/middleware/cors/index.d.ts +1 -1
- package/node_modules/hono/dist/types/middleware/jsx-renderer/index.d.ts +2 -2
- package/node_modules/hono/dist/types/middleware/jwk/jwk.d.ts +2 -0
- package/node_modules/hono/dist/types/middleware/jwt/jwt.d.ts +2 -0
- package/node_modules/hono/dist/types/middleware/method-not-allowed/index.d.ts +49 -0
- package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +1 -1
- package/node_modules/hono/dist/types/router/reg-exp-router/trie.d.ts +2 -1
- package/node_modules/hono/dist/types/router.d.ts +1 -1
- package/node_modules/hono/dist/types/utils/headers.d.ts +2 -2
- package/node_modules/hono/dist/types/utils/url.d.ts +1 -0
- package/node_modules/hono/dist/utils/accept.js +1 -1
- package/node_modules/hono/dist/utils/body.js +6 -0
- package/node_modules/hono/dist/utils/cookie.js +4 -3
- package/node_modules/hono/dist/utils/stream.js +5 -2
- package/node_modules/hono/dist/utils/url.js +6 -7
- package/node_modules/hono/package.json +10 -3
- package/node_modules/ip-address/README.md +146 -126
- package/node_modules/ip-address/dist/common.d.ts +29 -0
- package/node_modules/ip-address/dist/common.js +44 -5
- package/node_modules/ip-address/dist/common.js.map +1 -1
- package/node_modules/ip-address/dist/ipv4.d.ts +8 -1
- package/node_modules/ip-address/dist/ipv4.js +24 -20
- package/node_modules/ip-address/dist/ipv4.js.map +1 -1
- package/node_modules/ip-address/dist/ipv6.d.ts +68 -3
- package/node_modules/ip-address/dist/ipv6.js +180 -53
- package/node_modules/ip-address/dist/ipv6.js.map +1 -1
- package/node_modules/ip-address/dist/v4/constants.js +5 -1
- package/node_modules/ip-address/dist/v4/constants.js.map +1 -1
- package/node_modules/ip-address/dist/v6/constants.js +3 -2
- package/node_modules/ip-address/dist/v6/constants.js.map +1 -1
- package/node_modules/ip-address/package.json +6 -4
- package/node_modules/jose/README.md +13 -16
- package/node_modules/jose/dist/types/index.d.ts +6 -5
- package/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +17 -11
- package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +7 -19
- package/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +17 -11
- package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +7 -19
- package/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +18 -13
- package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +20 -21
- package/node_modules/jose/dist/types/jwk/embedded.d.ts +8 -12
- package/node_modules/jose/dist/types/jwk/thumbprint.d.ts +0 -15
- package/node_modules/jose/dist/types/jwks/local.d.ts +12 -21
- package/node_modules/jose/dist/types/jwks/remote.d.ts +34 -165
- package/node_modules/jose/dist/types/jws/compact/sign.d.ts +2 -13
- package/node_modules/jose/dist/types/jws/compact/verify.d.ts +17 -13
- package/node_modules/jose/dist/types/jws/flattened/sign.d.ts +2 -13
- package/node_modules/jose/dist/types/jws/flattened/verify.d.ts +17 -13
- package/node_modules/jose/dist/types/jws/general/sign.d.ts +16 -17
- package/node_modules/jose/dist/types/jws/general/verify.d.ts +18 -15
- package/node_modules/jose/dist/types/jwt/decrypt.d.ts +17 -11
- package/node_modules/jose/dist/types/jwt/encrypt.d.ts +10 -34
- package/node_modules/jose/dist/types/jwt/sign.d.ts +2 -13
- package/node_modules/jose/dist/types/jwt/unsecured.d.ts +4 -13
- package/node_modules/jose/dist/types/jwt/verify.d.ts +14 -13
- package/node_modules/jose/dist/types/key/export.d.ts +0 -14
- package/node_modules/jose/dist/types/key/generate_key_pair.d.ts +7 -14
- package/node_modules/jose/dist/types/key/generate_secret.d.ts +16 -14
- package/node_modules/jose/dist/types/key/import.d.ts +18 -28
- package/node_modules/jose/dist/types/types.d.ts +239 -222
- package/node_modules/jose/dist/types/util/base64url.d.ts +11 -4
- package/node_modules/jose/dist/types/util/decode_jwt.d.ts +1 -9
- package/node_modules/jose/dist/types/util/decode_protected_header.d.ts +0 -8
- package/node_modules/jose/dist/types/util/errors.d.ts +128 -121
- package/node_modules/jose/dist/webapi/jwe/compact/decrypt.js +4 -22
- package/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +5 -153
- package/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +16 -111
- package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +23 -3
- package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +66 -82
- package/node_modules/jose/dist/webapi/jwk/embedded.js +5 -3
- package/node_modules/jose/dist/webapi/jwks/local.js +32 -73
- package/node_modules/jose/dist/webapi/jwks/remote.js +19 -28
- package/node_modules/jose/dist/webapi/jws/compact/sign.js +5 -2
- package/node_modules/jose/dist/webapi/jws/compact/verify.js +4 -16
- package/node_modules/jose/dist/webapi/jws/flattened/sign.js +7 -65
- package/node_modules/jose/dist/webapi/jws/flattened/verify.js +3 -89
- package/node_modules/jose/dist/webapi/jws/general/sign.js +19 -15
- package/node_modules/jose/dist/webapi/jws/general/verify.js +29 -9
- package/node_modules/jose/dist/webapi/jwt/decrypt.js +5 -5
- package/node_modules/jose/dist/webapi/jwt/sign.js +2 -3
- package/node_modules/jose/dist/webapi/jwt/unsecured.js +4 -3
- package/node_modules/jose/dist/webapi/jwt/verify.js +6 -6
- package/node_modules/jose/dist/webapi/key/export.js +37 -4
- package/node_modules/jose/dist/webapi/key/generate_key_pair.js +33 -82
- package/node_modules/jose/dist/webapi/key/generate_secret.js +2 -2
- package/node_modules/jose/dist/webapi/key/import.js +8 -8
- package/node_modules/jose/dist/webapi/lib/asn1.js +53 -122
- package/node_modules/jose/dist/webapi/lib/buffer_utils.js +1 -0
- package/node_modules/jose/dist/webapi/lib/content_encryption.js +34 -109
- package/node_modules/jose/dist/webapi/lib/crypto_key.js +18 -126
- package/node_modules/jose/dist/webapi/lib/helpers.js +23 -0
- package/node_modules/jose/dist/webapi/lib/invalid_key_input.js +0 -1
- package/node_modules/jose/dist/webapi/lib/jwe_algorithms.js +107 -0
- package/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +186 -0
- package/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +110 -0
- package/node_modules/jose/dist/webapi/lib/jwk_to_key.js +8 -98
- package/node_modules/jose/dist/webapi/lib/jws_algorithms.js +73 -0
- package/node_modules/jose/dist/webapi/lib/jws_sign.js +74 -0
- package/node_modules/jose/dist/webapi/lib/jws_verify.js +107 -0
- package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +68 -109
- package/node_modules/jose/dist/webapi/lib/key.js +132 -0
- package/node_modules/jose/dist/webapi/lib/key_algorithm.js +10 -0
- package/node_modules/jose/dist/webapi/lib/key_descriptor.js +7 -0
- package/node_modules/jose/dist/webapi/lib/key_management.js +162 -92
- package/node_modules/jose/dist/webapi/lib/options.js +48 -0
- package/node_modules/jose/dist/webapi/lib/signing.js +14 -56
- package/node_modules/jose/dist/webapi/lib/type_checks.js +13 -18
- package/node_modules/jose/dist/webapi/util/base64url.js +13 -4
- package/node_modules/jose/dist/webapi/util/decode_jwt.js +2 -2
- package/node_modules/jose/dist/webapi/util/decode_protected_header.js +5 -15
- package/node_modules/jose/dist/webapi/util/errors.js +1 -1
- package/node_modules/jose/package.json +2 -4
- package/node_modules/js-yaml/dist/js-yaml.js +5 -2
- package/node_modules/js-yaml/dist/js-yaml.js.map +1 -1
- package/node_modules/js-yaml/dist/js-yaml.min.js +1 -1
- package/node_modules/js-yaml/dist/js-yaml.min.js.map +1 -1
- package/node_modules/js-yaml/dist/js-yaml.mjs +3 -3
- package/node_modules/js-yaml/dist/js-yaml.mjs.map +1 -1
- package/node_modules/js-yaml/lib/type/omap.js +3 -3
- package/node_modules/js-yaml/package.json +1 -1
- package/node_modules/openai/CHANGELOG.md +32 -0
- package/node_modules/openai/azure.d.mts.map +1 -1
- package/node_modules/openai/azure.d.ts.map +1 -1
- package/node_modules/openai/azure.js +5 -1
- package/node_modules/openai/azure.js.map +1 -1
- package/node_modules/openai/azure.mjs +5 -1
- package/node_modules/openai/azure.mjs.map +1 -1
- package/node_modules/openai/helpers/standard-schema.d.mts +104 -0
- package/node_modules/openai/helpers/standard-schema.d.mts.map +1 -0
- package/node_modules/openai/helpers/standard-schema.d.ts +104 -0
- package/node_modules/openai/helpers/standard-schema.d.ts.map +1 -0
- package/node_modules/openai/helpers/standard-schema.js +320 -0
- package/node_modules/openai/helpers/standard-schema.js.map +1 -0
- package/node_modules/openai/helpers/standard-schema.mjs +314 -0
- package/node_modules/openai/helpers/standard-schema.mjs.map +1 -0
- package/node_modules/openai/helpers/zod.d.mts +26 -3
- package/node_modules/openai/helpers/zod.d.mts.map +1 -1
- package/node_modules/openai/helpers/zod.d.ts +26 -3
- package/node_modules/openai/helpers/zod.d.ts.map +1 -1
- package/node_modules/openai/helpers/zod.js +97 -7
- package/node_modules/openai/helpers/zod.js.map +1 -1
- package/node_modules/openai/helpers/zod.mjs +96 -7
- package/node_modules/openai/helpers/zod.mjs.map +1 -1
- package/node_modules/openai/lib/AbstractChatCompletionRunner.d.mts.map +1 -1
- package/node_modules/openai/lib/AbstractChatCompletionRunner.d.ts.map +1 -1
- package/node_modules/openai/lib/AbstractChatCompletionRunner.js +43 -1
- package/node_modules/openai/lib/AbstractChatCompletionRunner.js.map +1 -1
- package/node_modules/openai/lib/AbstractChatCompletionRunner.mjs +43 -1
- package/node_modules/openai/lib/AbstractChatCompletionRunner.mjs.map +1 -1
- package/node_modules/openai/lib/ChatCompletionStream.d.mts +2 -1
- package/node_modules/openai/lib/ChatCompletionStream.d.mts.map +1 -1
- package/node_modules/openai/lib/ChatCompletionStream.d.ts +2 -1
- package/node_modules/openai/lib/ChatCompletionStream.d.ts.map +1 -1
- package/node_modules/openai/lib/ChatCompletionStream.js +53 -14
- package/node_modules/openai/lib/ChatCompletionStream.js.map +1 -1
- package/node_modules/openai/lib/ChatCompletionStream.mjs +53 -14
- package/node_modules/openai/lib/ChatCompletionStream.mjs.map +1 -1
- package/node_modules/openai/lib/ResponsesParser.d.mts.map +1 -1
- package/node_modules/openai/lib/ResponsesParser.d.ts.map +1 -1
- package/node_modules/openai/lib/ResponsesParser.js +3 -5
- package/node_modules/openai/lib/ResponsesParser.js.map +1 -1
- package/node_modules/openai/lib/ResponsesParser.mjs +3 -5
- package/node_modules/openai/lib/ResponsesParser.mjs.map +1 -1
- package/node_modules/openai/lib/jsonschema.d.mts +3 -0
- package/node_modules/openai/lib/jsonschema.d.mts.map +1 -1
- package/node_modules/openai/lib/jsonschema.d.ts +3 -0
- package/node_modules/openai/lib/jsonschema.d.ts.map +1 -1
- package/node_modules/openai/lib/transform.d.mts +25 -1
- package/node_modules/openai/lib/transform.d.mts.map +1 -1
- package/node_modules/openai/lib/transform.d.ts +25 -1
- package/node_modules/openai/lib/transform.d.ts.map +1 -1
- package/node_modules/openai/lib/transform.js +1521 -82
- package/node_modules/openai/lib/transform.js.map +1 -1
- package/node_modules/openai/lib/transform.mjs +1515 -82
- package/node_modules/openai/lib/transform.mjs.map +1 -1
- package/node_modules/openai/package.json +1 -1
- package/node_modules/openai/resources/admin/organization/index.d.mts +1 -0
- package/node_modules/openai/resources/admin/organization/index.d.mts.map +1 -1
- package/node_modules/openai/resources/admin/organization/index.d.ts +1 -0
- package/node_modules/openai/resources/admin/organization/index.d.ts.map +1 -1
- package/node_modules/openai/resources/admin/organization/index.js +3 -1
- package/node_modules/openai/resources/admin/organization/index.js.map +1 -1
- package/node_modules/openai/resources/admin/organization/index.mjs +1 -0
- package/node_modules/openai/resources/admin/organization/index.mjs.map +1 -1
- package/node_modules/openai/resources/admin/organization/organization.d.mts +4 -0
- package/node_modules/openai/resources/admin/organization/organization.d.mts.map +1 -1
- package/node_modules/openai/resources/admin/organization/organization.d.ts +4 -0
- package/node_modules/openai/resources/admin/organization/organization.d.ts.map +1 -1
- package/node_modules/openai/resources/admin/organization/organization.js +4 -0
- package/node_modules/openai/resources/admin/organization/organization.js.map +1 -1
- package/node_modules/openai/resources/admin/organization/organization.mjs +4 -0
- package/node_modules/openai/resources/admin/organization/organization.mjs.map +1 -1
- package/node_modules/openai/resources/admin/organization/projects/index.d.mts +1 -0
- package/node_modules/openai/resources/admin/organization/projects/index.d.mts.map +1 -1
- package/node_modules/openai/resources/admin/organization/projects/index.d.ts +1 -0
- package/node_modules/openai/resources/admin/organization/projects/index.d.ts.map +1 -1
- package/node_modules/openai/resources/admin/organization/projects/index.js +3 -1
- package/node_modules/openai/resources/admin/organization/projects/index.js.map +1 -1
- package/node_modules/openai/resources/admin/organization/projects/index.mjs +1 -0
- package/node_modules/openai/resources/admin/organization/projects/index.mjs.map +1 -1
- package/node_modules/openai/resources/admin/organization/projects/projects.d.mts +4 -0
- package/node_modules/openai/resources/admin/organization/projects/projects.d.mts.map +1 -1
- package/node_modules/openai/resources/admin/organization/projects/projects.d.ts +4 -0
- package/node_modules/openai/resources/admin/organization/projects/projects.d.ts.map +1 -1
- package/node_modules/openai/resources/admin/organization/projects/projects.js +4 -0
- package/node_modules/openai/resources/admin/organization/projects/projects.js.map +1 -1
- package/node_modules/openai/resources/admin/organization/projects/projects.mjs +4 -0
- package/node_modules/openai/resources/admin/organization/projects/projects.mjs.map +1 -1
- package/node_modules/openai/resources/admin/organization/projects/spend-limit.d.mts +115 -0
- package/node_modules/openai/resources/admin/organization/projects/spend-limit.d.mts.map +1 -0
- package/node_modules/openai/resources/admin/organization/projects/spend-limit.d.ts +115 -0
- package/node_modules/openai/resources/admin/organization/projects/spend-limit.d.ts.map +1 -0
- package/node_modules/openai/resources/admin/organization/projects/spend-limit.js +67 -0
- package/node_modules/openai/resources/admin/organization/projects/spend-limit.js.map +1 -0
- package/node_modules/openai/resources/admin/organization/projects/spend-limit.mjs +63 -0
- package/node_modules/openai/resources/admin/organization/projects/spend-limit.mjs.map +1 -0
- package/node_modules/openai/resources/admin/organization/spend-limit.d.mts +108 -0
- package/node_modules/openai/resources/admin/organization/spend-limit.d.mts.map +1 -0
- package/node_modules/openai/resources/admin/organization/spend-limit.d.ts +108 -0
- package/node_modules/openai/resources/admin/organization/spend-limit.d.ts.map +1 -0
- package/node_modules/openai/resources/admin/organization/spend-limit.js +59 -0
- package/node_modules/openai/resources/admin/organization/spend-limit.js.map +1 -0
- package/node_modules/openai/resources/admin/organization/spend-limit.mjs +55 -0
- package/node_modules/openai/resources/admin/organization/spend-limit.mjs.map +1 -0
- package/node_modules/openai/resources/beta/responses/input-tokens.d.mts +6 -2
- package/node_modules/openai/resources/beta/responses/input-tokens.d.mts.map +1 -1
- package/node_modules/openai/resources/beta/responses/input-tokens.d.ts +6 -2
- package/node_modules/openai/resources/beta/responses/input-tokens.d.ts.map +1 -1
- package/node_modules/openai/resources/beta/responses/responses.d.mts +21 -11
- package/node_modules/openai/resources/beta/responses/responses.d.mts.map +1 -1
- package/node_modules/openai/resources/beta/responses/responses.d.ts +21 -11
- package/node_modules/openai/resources/beta/responses/responses.d.ts.map +1 -1
- package/node_modules/openai/resources/beta/responses/responses.js.map +1 -1
- package/node_modules/openai/resources/beta/responses/responses.mjs.map +1 -1
- package/node_modules/openai/resources/chat/completions/completions.d.mts +4 -3
- package/node_modules/openai/resources/chat/completions/completions.d.mts.map +1 -1
- package/node_modules/openai/resources/chat/completions/completions.d.ts +4 -3
- package/node_modules/openai/resources/chat/completions/completions.d.ts.map +1 -1
- package/node_modules/openai/resources/chat/completions/completions.js.map +1 -1
- package/node_modules/openai/resources/chat/completions/completions.mjs.map +1 -1
- package/node_modules/openai/resources/responses/input-tokens.d.mts +2 -1
- package/node_modules/openai/resources/responses/input-tokens.d.mts.map +1 -1
- package/node_modules/openai/resources/responses/input-tokens.d.ts +2 -1
- package/node_modules/openai/resources/responses/input-tokens.d.ts.map +1 -1
- package/node_modules/openai/resources/responses/responses.d.mts +9 -8
- package/node_modules/openai/resources/responses/responses.d.mts.map +1 -1
- package/node_modules/openai/resources/responses/responses.d.ts +9 -8
- package/node_modules/openai/resources/responses/responses.d.ts.map +1 -1
- package/node_modules/openai/resources/responses/responses.js.map +1 -1
- package/node_modules/openai/resources/responses/responses.mjs.map +1 -1
- package/node_modules/openai/resources/shared.d.mts +4 -1
- package/node_modules/openai/resources/shared.d.mts.map +1 -1
- package/node_modules/openai/resources/shared.d.ts +4 -1
- package/node_modules/openai/resources/shared.d.ts.map +1 -1
- package/node_modules/openai/src/azure.ts +5 -1
- package/node_modules/openai/src/helpers/standard-schema.ts +570 -0
- package/node_modules/openai/src/helpers/zod.ts +158 -29
- package/node_modules/openai/src/lib/AbstractChatCompletionRunner.ts +43 -1
- package/node_modules/openai/src/lib/ChatCompletionStream.ts +56 -8
- package/node_modules/openai/src/lib/ResponsesParser.ts +7 -5
- package/node_modules/openai/src/lib/jsonschema.ts +3 -0
- package/node_modules/openai/src/lib/transform.ts +1930 -103
- package/node_modules/openai/src/resources/admin/organization/index.ts +6 -0
- package/node_modules/openai/src/resources/admin/organization/organization.ts +16 -0
- package/node_modules/openai/src/resources/admin/organization/projects/index.ts +6 -0
- package/node_modules/openai/src/resources/admin/organization/projects/projects.ts +16 -0
- package/node_modules/openai/src/resources/admin/organization/projects/spend-limit.ts +156 -0
- package/node_modules/openai/src/resources/admin/organization/spend-limit.ts +144 -0
- package/node_modules/openai/src/resources/beta/responses/input-tokens.ts +6 -2
- package/node_modules/openai/src/resources/beta/responses/responses.ts +21 -10
- package/node_modules/openai/src/resources/chat/completions/completions.ts +4 -3
- package/node_modules/openai/src/resources/responses/input-tokens.ts +2 -1
- package/node_modules/openai/src/resources/responses/responses.ts +9 -7
- package/node_modules/openai/src/resources/shared.ts +4 -1
- package/node_modules/openai/src/version.ts +1 -1
- package/node_modules/openai/version.d.mts +1 -1
- package/node_modules/openai/version.d.ts +1 -1
- package/node_modules/openai/version.js +1 -1
- package/node_modules/openai/version.mjs +1 -1
- package/node_modules/process-warning/LICENSE +1 -1
- package/node_modules/process-warning/README.md +41 -2
- package/node_modules/process-warning/index.js +85 -17
- package/node_modules/process-warning/package.json +6 -7
- package/node_modules/process-warning/test/emit-once-only.test.js +3 -3
- package/node_modules/process-warning/test/emit-reset.test.js +4 -4
- package/node_modules/process-warning/test/emit-unlimited.test.js +2 -2
- package/node_modules/process-warning/test/spy-warning.test.js +143 -0
- package/node_modules/process-warning/types/index.d.ts +15 -1
- package/node_modules/process-warning/types/index.tst.ts +48 -0
- package/node_modules/ws/package.json +1 -1
- package/package.json +6 -6
- package/node_modules/@hono/node-server/dist/conninfo.js +0 -42
- package/node_modules/@hono/node-server/dist/globals.d.mts +0 -2
- package/node_modules/@hono/node-server/dist/globals.d.ts +0 -2
- package/node_modules/@hono/node-server/dist/globals.js +0 -29
- package/node_modules/@hono/node-server/dist/globals.mjs +0 -5
- package/node_modules/@hono/node-server/dist/index.d.ts +0 -8
- package/node_modules/@hono/node-server/dist/index.js +0 -702
- package/node_modules/@hono/node-server/dist/listener.d.mts +0 -13
- package/node_modules/@hono/node-server/dist/listener.d.ts +0 -13
- package/node_modules/@hono/node-server/dist/listener.js +0 -670
- package/node_modules/@hono/node-server/dist/listener.mjs +0 -635
- package/node_modules/@hono/node-server/dist/request.d.mts +0 -25
- package/node_modules/@hono/node-server/dist/request.d.ts +0 -25
- package/node_modules/@hono/node-server/dist/request.js +0 -238
- package/node_modules/@hono/node-server/dist/request.mjs +0 -206
- package/node_modules/@hono/node-server/dist/response.d.mts +0 -26
- package/node_modules/@hono/node-server/dist/response.d.ts +0 -26
- package/node_modules/@hono/node-server/dist/response.js +0 -112
- package/node_modules/@hono/node-server/dist/response.mjs +0 -85
- package/node_modules/@hono/node-server/dist/serve-static.d.ts +0 -17
- package/node_modules/@hono/node-server/dist/serve-static.js +0 -177
- package/node_modules/@hono/node-server/dist/server.d.mts +0 -10
- package/node_modules/@hono/node-server/dist/server.d.ts +0 -10
- package/node_modules/@hono/node-server/dist/server.js +0 -696
- package/node_modules/@hono/node-server/dist/server.mjs +0 -660
- package/node_modules/@hono/node-server/dist/types.d.mts +0 -44
- package/node_modules/@hono/node-server/dist/types.d.ts +0 -44
- package/node_modules/@hono/node-server/dist/types.js +0 -18
- package/node_modules/@hono/node-server/dist/types.mjs +0 -0
- package/node_modules/@hono/node-server/dist/utils/response/constants.d.mts +0 -3
- package/node_modules/@hono/node-server/dist/utils/response/constants.d.ts +0 -3
- package/node_modules/@hono/node-server/dist/utils/response/constants.js +0 -30
- package/node_modules/@hono/node-server/dist/utils/response/constants.mjs +0 -5
- package/node_modules/@hono/node-server/dist/utils/response.d.ts +0 -3
- package/node_modules/@hono/node-server/dist/utils/response.js +0 -37
- package/node_modules/@hono/node-server/dist/utils.d.mts +0 -9
- package/node_modules/@hono/node-server/dist/utils.d.ts +0 -9
- package/node_modules/@hono/node-server/dist/utils.js +0 -99
- package/node_modules/@hono/node-server/dist/utils.mjs +0 -71
- package/node_modules/@hono/node-server/dist/vercel.d.mts +0 -7
- package/node_modules/@hono/node-server/dist/vercel.d.ts +0 -7
- package/node_modules/@hono/node-server/dist/vercel.js +0 -677
- package/node_modules/@hono/node-server/dist/vercel.mjs +0 -640
- package/node_modules/jose/dist/webapi/lib/aesgcmkw.js +0 -15
- package/node_modules/jose/dist/webapi/lib/aeskw.js +0 -25
- package/node_modules/jose/dist/webapi/lib/check_key_type.js +0 -122
- package/node_modules/jose/dist/webapi/lib/ecdhes.js +0 -52
- package/node_modules/jose/dist/webapi/lib/key_to_jwk.js +0 -31
- package/node_modules/jose/dist/webapi/lib/normalize_key.js +0 -166
- package/node_modules/jose/dist/webapi/lib/pbes2kw.js +0 -42
- package/node_modules/jose/dist/webapi/lib/rsaes.js +0 -24
- package/node_modules/jose/dist/webapi/lib/validate_algorithms.js +0 -10
- package/node_modules/jose/dist/webapi/lib/validate_crit.js +0 -33
- package/node_modules/process-warning/types/index.test-d.ts +0 -36
|
@@ -58,7 +58,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
58
58
|
`),r=Gb.exec(t);if(r&&t.startsWith(r[0])){u(),c();let e=r[1];n.push(`<pre class="overflow-auto rounded-md border border-line bg-canvas/80 p-3 text-[11px] leading-5"><code data-lang="${Kb(e)}">${Kb(r[2])}</code></pre>`);let t=r[0].split(`
|
|
59
59
|
`).length;i+=t;continue}let d=/^(#{1,6})\s+(.+?)\s*$/.exec(e);if(d){u(),c();let e=Math.min(d[1].length,4),t=`h${e}`;n.push(`<${t} class="${[`text-lg font-semibold text-fg`,`text-base font-semibold text-fg`,`text-sm font-semibold text-fg`,`text-sm font-medium text-fg`][e-1]}">${qb(d[2])}</${t}>`),i++;continue}let f=/^[-*]\s+(.+)$/.exec(e);if(f){u(),o!==`ul`&&c(),o=`ul`,s.push(qb(f[1])),i++;continue}let p=/^\d+\.\s+(.+)$/.exec(e);if(p){u(),o!==`ol`&&c(),o=`ol`,s.push(qb(p[1])),i++;continue}if(e.trim()===``){u(),c(),i++;continue}c(),l.push(e.trim()),i++}return u(),c(),n.join(`
|
|
60
60
|
`)}var Yb=new Map;function Xb(e,t){return`${e}:${t}`}async function Zb(e,t){let n=Xb(e,t),r=Yb.get(n);if(typeof r==`string`||r)return r;let i=uo(`/jobs/${e}/artifacts/${t}/content`);Yb.set(n,i);try{let e=await i;return Yb.set(n,e),e}catch(e){throw Yb.delete(n),e}}async function Qb(e,t,n){let r=await q(`/jobs/${e}/artifacts/${t}/content`,J({content:n},{method:`PUT`}));return Yb.set(Xb(e,t),n),r.artifact}function $b(e,t){Yb.delete(Xb(e,t))}function ex(e){let t=e.data?.path;return typeof t==`string`&&t.trim().length>0}function tx(e){let t=e.data?.path;return(typeof t==`string`?t.toLowerCase():``).endsWith(`.md`)||e.kind.endsWith(`-md`)||e.kind.includes(`md`)}var nx=[`.md`,`.txt`,`.yml`,`.yaml`,`.json`];function rx(e){if(!ex(e))return!1;let t=e.data.path.toLowerCase();return nx.some(e=>t.endsWith(e))}function ix({jobId:e,artifacts:t,phaseLabel:n,onApprove:r,onRequestChanges:i,onCancel:a,onViewChanges:o,sending:s=!1}){let c=t.some(e=>e.kind===`pr-preview`),[l,u]=(0,x.useState)(t[0]?.id??``),[d,f]=(0,x.useState)(!1),[p,m]=(0,x.useState)(``),[h,g]=(0,x.useState)(null),[_,v]=(0,x.useState)(null);(0,x.useEffect)(()=>{t.length>0&&!t.some(e=>e.id===l)&&u(t[0].id)},[t,l]);let y=t.find(e=>e.id===l)??t[0],b=!!y&&h===y.id,S=s||h!==null;return(0,G.jsxs)(vv,{delayDuration:250,children:[(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-line bg-overlay/30`,children:[(0,G.jsxs)(`header`,{className:`space-y-1 border-b border-line px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`text-sm font-semibold text-fg`,children:[`Review what Coro produced in the `,(0,G.jsx)(`span`,{className:`font-mono`,children:n}),` phase`]}),(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Read the output below, edit it if needed, then approve or request changes.`})]}),t.length>1?(0,G.jsx)(ax,{artifacts:t,activeId:l,onChange:e=>{u(e),g(null)},editingId:h}):null,y?(0,G.jsx)(ox,{jobId:e,artifact:y,editing:b,disabled:s,onStartEdit:()=>g(y.id),onCancelEdit:()=>g(null),onSaved:()=>g(null),onOpenFullScreen:()=>v(y.id)}):null,(0,G.jsxs)(`div`,{className:`space-y-3 border-t border-line bg-overlay/40 px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsxs)(yv,{children:[(0,G.jsx)(bv,{asChild:!0,children:(0,G.jsx)(`span`,{children:(0,G.jsxs)(Y,{type:`button`,variant:`success`,size:`sm`,disabled:S,onClick:r,children:[(0,G.jsx)(fr,{}),`Approve and continue`]})})}),h===null?null:(0,G.jsx)(xv,{children:`Save or cancel your edit first.`})]}),c&&o?(0,G.jsxs)(Y,{type:`button`,variant:`secondary`,size:`sm`,disabled:s,onClick:o,children:[(0,G.jsx)(Ar,{}),`Review code changes`]}):null,(0,G.jsxs)(Y,{type:`button`,variant:`secondary`,size:`sm`,disabled:s,onClick:()=>f(e=>!e),children:[(0,G.jsx)(ni,{}),d?`Hide change request`:`Request changes`]}),(0,G.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:s,onClick:()=>{window.confirm(`Cancel this run?`)&&a()},children:[(0,G.jsx)(ir,{}),`Cancel run`]})]}),d?(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(bb,{rows:3,value:p,onChange:e=>m(e.target.value),placeholder:`Describe what should change before continuing…`,disabled:s}),(0,G.jsx)(`div`,{className:`flex justify-end`,children:(0,G.jsx)(Y,{type:`button`,size:`sm`,disabled:s||!p.trim(),onClick:()=>{i(p.trim()),m(``),f(!1)},children:`Send feedback`})})]}):(0,G.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:`You can also send any message to Coro using the message box below.`})]})]}),_&&y&&y.id===_?(0,G.jsx)(vx,{jobId:e,artifact:y,onClose:()=>v(null)}):null]})}function ax({artifacts:e,activeId:t,onChange:n,editingId:r}){return(0,G.jsx)(`div`,{className:`overflow-x-auto border-b border-line bg-overlay/20 px-2 py-2`,children:(0,G.jsx)(`div`,{className:`flex min-w-max items-center gap-1`,children:e.map(e=>{let i=e.id===t,a=r===e.id;return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),className:W(`group flex items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,i?`bg-overlay text-fg ring-1 ring-line-strong`:`text-fg-muted hover:bg-overlay/70 hover:text-fg`),children:[(0,G.jsx)(_x,{kind:e.kind}),(0,G.jsx)(`span`,{className:`max-w-[18ch] truncate font-medium`,children:e.title||e.kind||e.id}),(0,G.jsx)(vg,{variant:`neutral`,className:`text-[10px] uppercase`,children:e.kind}),a?(0,G.jsx)(`span`,{className:`rounded-full bg-warning-500/20 px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-warning-300`,children:`Editing`}):null]},e.id)})})})}function ox({jobId:e,artifact:t,editing:n,disabled:r,onStartEdit:i,onCancelEdit:a,onSaved:o,onOpenFullScreen:s}){return ex(t)?(0,G.jsx)(ux,{jobId:e,artifact:t,editing:n,disabled:r,onStartEdit:i,onCancelEdit:a,onSaved:o,onOpenFullScreen:s}):(0,G.jsxs)(`div`,{className:`space-y-3 px-4 py-4`,children:[(0,G.jsx)(sx,{artifact:t}),(0,G.jsx)(cx,{artifact:t})]})}function sx({artifact:e}){let t=typeof e.data.path==`string`?e.data.path:``;return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,G.jsx)(`span`,{className:`font-medium text-fg`,children:e.title||e.kind}),(0,G.jsx)(vg,{variant:`neutral`,children:e.kind}),t?(0,G.jsx)(`span`,{className:`truncate font-mono text-fg-subtle`,children:t}):null,(0,G.jsxs)(`span`,{className:`text-fg-subtle`,children:[`Posted `,Oy(e.createdAt)]}),e.editedAt?(0,G.jsxs)(`span`,{className:`text-warning-300`,children:[`Edited `,Oy(e.editedAt)]}):null]})}function cx({artifact:e}){if(e.kind===`pr-preview`)return(0,G.jsx)(lx,{data:e.data});let t=typeof e.data.url==`string`?e.data.url:null;return(e.kind===`pr-link`||e.kind===`url`)&&t?(0,G.jsxs)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,className:`group flex items-start gap-3 rounded-2xl border border-line bg-overlay/40 px-4 py-3 transition-colors hover:border-accent-500/30 hover:bg-overlay/60`,children:[(0,G.jsx)(`div`,{className:`rounded-lg border border-line bg-overlay p-2 text-fg-muted`,children:e.kind===`pr-link`?(0,G.jsx)(Hr,{className:`size-4`}):(0,G.jsx)(Zr,{className:`size-4`})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,G.jsx)(`div`,{className:`mt-0.5 truncate text-sm text-fg-muted`,children:t})]}),(0,G.jsx)(Er,{className:`mt-1 size-4 shrink-0 text-fg-subtle group-hover:text-accent-300`})]}):(0,G.jsx)(pc,{className:`h-[min(40vh,360px)] rounded-xl border border-line bg-canvas/60`,children:(0,G.jsx)(`pre`,{className:`whitespace-pre-wrap break-words p-4 font-mono text-xs leading-6 text-fg`,children:JSON.stringify(e.data,null,2)})})}function lx({data:e}){let t=t=>typeof e[t]==`string`?e[t]:void 0,n=t(`description`),r=t(`base`),i=t(`sourceBranch`),a=t(`workItem`);return(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`This is the pull request Coro will open once you approve. Use “Review code changes” to see the diff.`}),i||a?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[i?(0,G.jsxs)(vg,{variant:`neutral`,className:`font-mono`,children:[i,r?(0,G.jsxs)(`span`,{className:`text-fg-subtle`,children:[` → `,r]}):null]}):null,a?(0,G.jsx)(vg,{variant:`neutral`,children:a}):null]}):null,n?(0,G.jsx)(pc,{className:`h-[min(40vh,360px)] rounded-xl border border-line bg-canvas/40`,children:(0,G.jsx)(`div`,{className:`prose-coro space-y-2 p-4 text-sm leading-6 text-fg`,dangerouslySetInnerHTML:{__html:Jb(n)}})}):(0,G.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:`No PR description was provided.`})]})}function ux({jobId:e,artifact:t,editing:n,disabled:r,onStartEdit:i,onCancelEdit:a,onSaved:o,onOpenFullScreen:s}){let[c,l]=(0,x.useState)(null),[u,d]=(0,x.useState)(``),[f,p]=(0,x.useState)(!0),[m,h]=(0,x.useState)(null),[g,_]=(0,x.useState)(!1),[v,y]=(0,x.useState)(null),[b,S]=(0,x.useState)(!1),C=(0,x.useRef)(``),w=tx(t),T=rx(t);(0,x.useEffect)(()=>{let n=!1,r=`${t.id}:${t.editedAt??``}`;return C.current=r,p(!0),h(null),Zb(e,t.id).then(e=>{n||C.current!==r||(l(e),d(e),p(!1))}).catch(e=>{n||C.current!==r||(h(e instanceof Error?e.message:String(e)),p(!1))}),()=>{n=!0}},[e,t.id,t.editedAt]);let E=(0,x.useCallback)(async()=>{if(c!=null)try{await navigator.clipboard.writeText(c),S(!0),window.setTimeout(()=>S(!1),1500)}catch{}},[c]),D=(0,x.useCallback)(()=>{if(c==null)return;let e=(t.data.path??`${t.kind}.txt`).split(`/`).pop()??`${t.id}.txt`,n=new Blob([c],{type:`text/plain;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)},[c,t.data,t.id,t.kind]),O=(0,x.useCallback)(async()=>{if(c!=null){_(!0),y(null);try{await Qb(e,t.id,u),l(u),o()}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(!1)}}},[e,t.id,u,c,o]),k=(0,x.useCallback)(()=>{d(c??``),y(null),a()},[c,a]),A=(0,x.useCallback)(()=>{$b(e,t.id),l(null),p(!0),h(null),Zb(e,t.id).then(e=>{l(e),d(e),p(!1)}).catch(e=>{h(e instanceof Error?e.message:String(e)),p(!1)})},[e,t.id]),j=n&&u!==c,M=`h-[min(60vh,640px)]`;return(0,G.jsxs)(`div`,{className:`space-y-3 px-4 py-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsx)(sx,{artifact:t}),(0,G.jsx)(dx,{editing:n,editable:T,dirty:j,saving:g,disabled:r||f||!!m,copied:b,onCopy:E,onDownload:D,onOpenFullScreen:s,onStartEdit:i,onCancelEdit:k,onSave:O,onRevert:A})]}),f?(0,G.jsx)(`div`,{className:W(`flex items-center justify-center rounded-xl border border-line bg-canvas/40 text-sm text-fg-subtle`,M),children:(0,G.jsx)(`span`,{className:`animate-pulse`,children:`Loading artifact…`})}):m?(0,G.jsx)(gg,{title:`Could not load artifact`,message:m}):n?(0,G.jsx)(hx,{draft:u,onChange:d,disabled:g,heightClass:M,saveError:v}):w?(0,G.jsx)(px,{content:c??``,heightClass:M}):(0,G.jsx)(mx,{content:c??``,heightClass:M})]})}function dx({editing:e,editable:t,dirty:n,saving:r,disabled:i,copied:a,onCopy:o,onDownload:s,onOpenFullScreen:c,onStartEdit:l,onCancelEdit:u,onSave:d,onRevert:f}){return(0,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Y,{type:`button`,size:`sm`,variant:`primary`,onClick:d,disabled:r||!n,children:[(0,G.jsx)(vi,{}),r?`Saving…`:`Save edits`]}),(0,G.jsxs)(Y,{type:`button`,size:`sm`,variant:`ghost`,onClick:u,disabled:r,children:[(0,G.jsx)(Pi,{}),`Cancel edit`]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(fx,{tooltip:a?`Copied!`:`Copy contents`,onClick:o,disabled:i,children:(0,G.jsx)(Sr,{})}),(0,G.jsx)(fx,{tooltip:`Download`,onClick:s,disabled:i,children:(0,G.jsx)(wr,{})}),(0,G.jsx)(fx,{tooltip:`Re-fetch from disk`,onClick:f,disabled:i,children:(0,G.jsx)(gi,{})}),(0,G.jsx)(fx,{tooltip:`Open full screen`,onClick:c,disabled:i,children:(0,G.jsx)(ei,{})}),t?(0,G.jsx)(fx,{tooltip:`Edit this artifact`,onClick:l,disabled:i,children:(0,G.jsx)(ci,{})}):(0,G.jsx)(fx,{tooltip:`This file type is not editable from the dashboard`,onClick:()=>{},disabled:!0,children:(0,G.jsx)(ci,{})})]})})}function fx({children:e,tooltip:t,onClick:n,disabled:r}){return(0,G.jsxs)(yv,{children:[(0,G.jsx)(bv,{asChild:!0,children:(0,G.jsx)(`button`,{type:`button`,onClick:n,disabled:r,className:W(`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted transition-colors`,`hover:bg-overlay hover:text-fg disabled:pointer-events-none disabled:opacity-50`,`[&_svg]:size-4`),children:e})}),(0,G.jsx)(xv,{children:t})]})}function px({content:e,heightClass:t}){return(0,G.jsxs)(Bb,{defaultValue:`rendered`,children:[(0,G.jsxs)(Vb,{children:[(0,G.jsx)(Hb,{value:`rendered`,children:`Rendered`}),(0,G.jsx)(Hb,{value:`source`,children:`Source`})]}),(0,G.jsx)(Ub,{value:`rendered`,className:W(`rounded-xl border border-line bg-canvas/40`),children:(0,G.jsx)(pc,{className:t,children:(0,G.jsx)(`div`,{className:`prose-coro space-y-3 p-4 text-sm leading-6 text-fg`,dangerouslySetInnerHTML:{__html:Jb(e)}})})}),(0,G.jsx)(Ub,{value:`source`,className:W(`rounded-xl border border-line bg-canvas/60`),children:(0,G.jsx)(pc,{className:t,children:(0,G.jsx)(`pre`,{className:`whitespace-pre-wrap break-words p-4 font-mono text-xs leading-6 text-fg`,children:e})})})]})}function mx({content:e,heightClass:t}){let n=e.trim().startsWith(`{`)||e.trim().startsWith(`[`);return(0,G.jsx)(pc,{className:W(t,`rounded-xl border border-line bg-canvas/60`),children:(0,G.jsx)(`pre`,{className:`whitespace-pre-wrap break-words p-4 font-mono text-xs leading-6 text-fg`,children:n?gx(e):e})})}function hx({draft:e,onChange:t,disabled:n,heightClass:r,saveError:i}){return(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(bb,{value:e,onChange:e=>t(e.target.value),disabled:n,spellCheck:!1,className:W(`w-full resize-none rounded-xl border border-line bg-canvas/70 font-mono text-xs leading-6`,r)}),i?(0,G.jsx)(`div`,{className:`text-xs text-danger-400`,children:i}):null]})}function gx(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function _x({kind:e}){return e===`pr-preview`?(0,G.jsx)(Ar,{className:`size-3.5`}):e===`pr-link`?(0,G.jsx)(Hr,{className:`size-3.5`}):e===`url`?(0,G.jsx)(Zr,{className:`size-3.5`}):e.endsWith(`-md`)||e===`analysis-contract`?(0,G.jsx)(Ir,{className:`size-3.5`}):(0,G.jsx)(jr,{className:`size-3.5`})}function vx({jobId:e,artifact:t,onClose:n}){let[r,i]=(0,x.useState)(null),[a,o]=(0,x.useState)(null),s=tx(t);(0,x.useEffect)(()=>{let n=!1;return i(null),o(null),Zb(e,t.id).then(e=>{n||i(e)}).catch(e=>{n||o(e instanceof Error?e.message:String(e))}),()=>{n=!0}},[e,t.id,t.editedAt]);let c=t.data.path;return(0,G.jsx)(c_,{open:!0,onOpenChange:e=>{e||n()},children:(0,G.jsxs)(d_,{children:[(0,G.jsxs)(f_,{children:[(0,G.jsx)(p_,{children:t.title}),(0,G.jsxs)(`div`,{className:`space-y-1 text-sm text-fg-muted`,children:[c?(0,G.jsx)(`div`,{className:`font-mono text-xs text-fg-subtle`,children:c}):null,(0,G.jsxs)(`div`,{children:[`Posted `,Oy(t.createdAt),t.editedAt?(0,G.jsxs)(`span`,{className:`ml-2 text-warning-300`,children:[`· Edited `,Oy(t.editedAt)]}):null]})]})]}),(0,G.jsx)(h_,{children:a?(0,G.jsx)(gg,{title:`Could not load artifact`,message:a}):r?s?(0,G.jsxs)(Bb,{defaultValue:`rendered`,className:`space-y-3`,children:[(0,G.jsxs)(Vb,{children:[(0,G.jsx)(Hb,{value:`rendered`,children:`Rendered`}),(0,G.jsx)(Hb,{value:`source`,children:`Source`})]}),(0,G.jsx)(Ub,{value:`rendered`,className:`rounded-2xl border border-line bg-canvas/40`,children:(0,G.jsx)(pc,{className:`h-[70vh]`,children:(0,G.jsx)(`div`,{className:`prose-coro space-y-3 p-5 text-sm leading-6 text-fg`,dangerouslySetInnerHTML:{__html:Jb(r)}})})}),(0,G.jsx)(Ub,{value:`source`,className:`rounded-2xl border border-line bg-canvas/60`,children:(0,G.jsx)(pc,{className:`h-[70vh]`,children:(0,G.jsx)(`pre`,{className:`whitespace-pre-wrap break-words p-5 font-mono text-xs leading-6 text-fg`,children:r})})})]}):(0,G.jsx)(pc,{className:`h-[70vh] rounded-2xl border border-line bg-canvas/60`,children:(0,G.jsx)(`div`,{className:`p-5`,children:(0,G.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-6 text-fg`,children:r})})}):(0,G.jsx)(`div`,{className:`animate-pulse text-sm text-fg-subtle`,children:`Loading artifact content…`})})]})})}var yx=`Approved. Please continue to the next phase.`;function bx({job:e,onSend:t,onCancel:n,onViewChanges:r}){let[i,a]=(0,x.useState)(``),[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(null);if(e.status!==`awaiting-developer-input`)return null;let u=e.workflowPhases?.find(t=>t.name===e.phase);if(u&&u.agent===null)return null;let d=(e.artifacts??[]).filter(t=>t.phase===e.phase),f=d.length>0,p=xx(e.awaitingEvent),m=!e.awaitingNextPhase,h=f&&!m,g=async e=>{s(!0),l(null);try{await t(e),a(``)}catch(e){l(e instanceof Error?e.message:String(e))}finally{s(!1)}},_=async()=>{if(n){s(!0),l(null);try{await n()}catch(e){l(e instanceof Error?e.message:String(e))}finally{s(!1)}}};return(0,G.jsxs)(`div`,{className:`space-y-4 rounded-2xl border border-warning-500/25 bg-warning-500/8 p-5`,children:[h?(0,G.jsx)(ix,{jobId:e.id,artifacts:d,phaseLabel:e.phase,sending:o,onApprove:()=>void g(yx),onRequestChanges:e=>void g(e),onCancel:()=>void _(),onViewChanges:r}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl border border-warning-500/25 bg-warning-500/10 text-warning-400`,children:(0,G.jsx)(ti,{className:`size-4`})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`text-[15px] font-semibold text-fg`,children:m?`Agent paused for your input`:`Approval needed to continue`}),(0,G.jsx)(`div`,{className:`mt-0.5 text-sm text-fg-muted`,children:m?(0,G.jsxs)(G.Fragment,{children:[`Mid-phase in `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:e.phase}),p?(0,G.jsxs)(G.Fragment,{children:[` — `,(0,G.jsx)(`span`,{className:`italic`,children:p})]}):null]}):(0,G.jsxs)(G.Fragment,{children:[`After phase `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:e.phase}),e.awaitingNextPhase?(0,G.jsxs)(G.Fragment,{children:[` → next: `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:e.awaitingNextPhase})]}):null]})})]})]}),m?null:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,G.jsxs)(Y,{type:`button`,onClick:()=>void g(yx),disabled:o,variant:`success`,size:`sm`,children:[(0,G.jsx)(fr,{}),o?`Sending…`:`Approve & continue`]}),(0,G.jsx)(`span`,{className:`text-sm text-fg-muted`,children:`or send the agent back with changes below`})]}),(0,G.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&g(i.trim())},className:`space-y-3`,children:[(0,G.jsx)(bb,{rows:4,value:i,onChange:e=>a(e.target.value),placeholder:m?`Answer the agent or provide the missing detail it asked for…`:`Request changes, clarify the plan, or send additional guidance…`,disabled:o,className:`border-warning-500/20 focus-visible:ring-warning-500/40`}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[c?(0,G.jsx)(`span`,{className:`text-sm text-danger-400`,children:c}):(0,G.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`The agent will do the work and re-park for approval.`}),(0,G.jsx)(Y,{type:`submit`,disabled:o||!i.trim(),variant:`secondary`,size:`sm`,children:o?`Sending…`:`Send message`})]})]})]}),h&&c?(0,G.jsx)(`div`,{className:`text-sm text-danger-400`,children:c}):null]})}function xx(e){if(!e)return null;if(e.startsWith(`developer-input:`)){let t=e.slice(16).trim();return t.startsWith(`approval after `)?null:t||null}return null}function Sx({jobId:e,artifact:t,variant:n=`default`}){let{kind:r,title:i,data:a}=t,o=n===`compact`;if(r===`pr-link`||r===`url`){let e=a.url;if(e)return(0,G.jsxs)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:W(`group flex items-center gap-2.5 text-left transition-colors`,o?`px-3 py-2 hover:bg-overlay/50`:`items-start gap-3 rounded-2xl border border-line bg-overlay/40 px-4 py-3 hover:border-accent-500/30 hover:bg-overlay/60`),children:[(0,G.jsx)(Cx,{kind:r,compact:o}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:i}),(0,G.jsx)(vg,{variant:`neutral`,className:o?`shrink-0 text-[10px]`:void 0,children:r})]}),o?(0,G.jsx)(`div`,{className:`truncate font-mono text-[11px] text-fg-subtle`,children:e}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`mt-1 truncate text-sm text-fg-muted`,children:e}),(0,G.jsxs)(`div`,{className:`mt-1.5 text-[11px] uppercase tracking-[0.14em] text-fg-subtle`,children:[`Posted `,Oy(t.createdAt)]})]})]}),(0,G.jsx)(Er,{className:W(`size-4 shrink-0 text-fg-subtle group-hover:text-accent-300`,!o&&`mt-1`)})]})}return typeof a.path==`string`&&a.path.trim()?(0,G.jsx)(Tx,{jobId:e,artifact:t,compact:o}):(0,G.jsx)(Ox,{artifact:t,compact:o})}function Cx({kind:e,compact:t=!1}){return(0,G.jsx)(`div`,{className:W(`shrink-0 rounded-md border border-line bg-overlay text-fg-muted`,t?`p-1.5 [&_svg]:size-3.5`:`rounded-lg p-2`),children:wx(e)})}function wx(e){return e===`pr-link`?(0,G.jsx)(Hr,{className:`size-4`}):e===`url`?(0,G.jsx)(Zr,{className:`size-4`}):e.endsWith(`-md`)||e===`analysis-contract`?(0,G.jsx)(Ir,{className:`size-4`}):(0,G.jsx)(jr,{className:`size-4`})}function Tx({jobId:e,artifact:t,compact:n=!1}){let[r,i]=(0,x.useState)(!1),a=t.data.path;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:W(`group flex w-full items-center gap-2.5 text-left transition-colors`,n?`px-3 py-2 hover:bg-overlay/50`:`items-start gap-3 rounded-2xl border border-line bg-overlay/40 px-4 py-3 hover:border-accent-500/30 hover:bg-overlay/60`),children:[(0,G.jsx)(Cx,{kind:t.kind,compact:n}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:t.title}),(0,G.jsx)(vg,{variant:`neutral`,className:n?`shrink-0 text-[10px]`:void 0,children:t.kind}),t.editedAt?(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-warning-500/15 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-warning-300`,children:`Edited`}):null]}),n?(0,G.jsx)(`div`,{className:`truncate font-mono text-[11px] text-fg-subtle`,children:a}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`mt-1 truncate font-mono text-xs text-fg-subtle`,children:a}),(0,G.jsxs)(`div`,{className:`mt-1.5 text-[11px] uppercase tracking-[0.14em] text-fg-subtle`,children:[`Posted `,Oy(t.createdAt),t.editedAt?` · Edited ${Oy(t.editedAt)}`:``]})]})]}),(0,G.jsx)(Or,{className:W(`size-4 shrink-0 text-fg-subtle group-hover:text-accent-300`,!n&&`mt-1`)})]}),r?(0,G.jsx)(Ex,{jobId:e,artifact:t,onClose:()=>i(!1)}):null]})}function Ex({jobId:e,artifact:t,onClose:n}){let[r,i]=(0,x.useState)(null),[a,o]=(0,x.useState)(``),[s,c]=(0,x.useState)(!1),[l,u]=(0,x.useState)(!1),[d,f]=(0,x.useState)(null),[p,m]=(0,x.useState)(null),[h,g]=(0,x.useState)(!1),[_,v]=(0,x.useState)(t.editedAt),y=tx(t),b=rx(t);(0,x.useEffect)(()=>{let n=!1;return i(null),o(``),f(null),Zb(e,t.id).then(e=>{n||(i(e),o(e))}).catch(e=>{n||f(e instanceof Error?e.message:String(e))}),()=>{n=!0}},[e,t.id,_]),(0,x.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!s&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,s]);let S=(0,x.useCallback)(async()=>{if(r!=null)try{await navigator.clipboard.writeText(r),g(!0),window.setTimeout(()=>g(!1),1500)}catch{}},[r]),C=(0,x.useCallback)(()=>{if(r==null)return;let e=(t.data.path??`${t.kind}.txt`).split(`/`).pop()??`${t.id}.txt`,n=new Blob([r],{type:`text/plain;charset=utf-8`}),i=URL.createObjectURL(n),a=document.createElement(`a`);a.href=i,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)},[r,t.data,t.id,t.kind]),w=(0,x.useCallback)(async()=>{if(r!=null){u(!0),m(null);try{let n=await Qb(e,t.id,a);i(a),v(n.editedAt),c(!1)}catch(e){m(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[e,t.id,a,r]),T=(0,x.useCallback)(()=>{$b(e,t.id),i(null),o(``),f(null),Zb(e,t.id).then(e=>{i(e),o(e)}).catch(e=>{f(e instanceof Error?e.message:String(e))})},[e,t.id]),E=s&&a!==r,D=t.data.path;return(0,G.jsx)(vv,{delayDuration:250,children:(0,G.jsx)(c_,{open:!0,onOpenChange:e=>{!e&&!s&&n()},children:(0,G.jsxs)(d_,{children:[(0,G.jsxs)(f_,{children:[(0,G.jsx)(p_,{children:t.title}),(0,G.jsxs)(`div`,{className:`space-y-1 text-sm text-fg-muted`,children:[(0,G.jsx)(`div`,{className:`font-mono text-xs text-fg-subtle`,children:D}),(0,G.jsxs)(`div`,{children:[`Posted `,Oy(t.createdAt),_?(0,G.jsxs)(`span`,{className:`ml-2 text-warning-300`,children:[`· Edited `,Oy(_)]}):null]})]})]}),(0,G.jsxs)(h_,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsx)(`div`,{className:`flex items-center gap-1`,children:s?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Y,{type:`button`,size:`sm`,variant:`primary`,onClick:w,disabled:l||!E,children:[(0,G.jsx)(vi,{}),l?`Saving…`:`Save edits`]}),(0,G.jsxs)(Y,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{o(r??``),m(null),c(!1)},disabled:l,children:[(0,G.jsx)(Pi,{}),`Cancel edit`]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Dx,{tooltip:h?`Copied!`:`Copy contents`,onClick:S,disabled:!r,children:(0,G.jsx)(Sr,{})}),(0,G.jsx)(Dx,{tooltip:`Download`,onClick:C,disabled:!r,children:(0,G.jsx)(wr,{})}),(0,G.jsx)(Dx,{tooltip:`Re-fetch from disk`,onClick:T,disabled:!r,children:(0,G.jsx)(gi,{})}),b?(0,G.jsx)(Dx,{tooltip:`Edit this artifact`,onClick:()=>c(!0),disabled:!r,children:(0,G.jsx)(ci,{})}):(0,G.jsx)(Dx,{tooltip:`This file type is not editable from the dashboard`,disabled:!0,children:(0,G.jsx)(ci,{})})]})}),p?(0,G.jsx)(`div`,{className:`text-xs text-danger-400`,children:p}):null]}),d?(0,G.jsx)(gg,{title:`Could not load artifact`,message:d}):r?s?(0,G.jsx)(`div`,{className:`space-y-2`,children:(0,G.jsx)(bb,{value:a,onChange:e=>o(e.target.value),disabled:l,spellCheck:!1,className:`h-[60vh] w-full resize-none rounded-2xl border border-line bg-canvas/70 font-mono text-xs leading-6`})}):y?(0,G.jsxs)(Bb,{defaultValue:`rendered`,className:`space-y-3`,children:[(0,G.jsxs)(Vb,{children:[(0,G.jsx)(Hb,{value:`rendered`,children:`Rendered`}),(0,G.jsx)(Hb,{value:`source`,children:`Source`})]}),(0,G.jsx)(Ub,{value:`rendered`,className:`rounded-2xl border border-line bg-canvas/40`,children:(0,G.jsx)(pc,{className:`h-[60vh]`,children:(0,G.jsx)(`div`,{className:`prose-coro space-y-3 p-5 text-sm leading-6 text-fg`,dangerouslySetInnerHTML:{__html:Jb(r)}})})}),(0,G.jsx)(Ub,{value:`source`,className:`rounded-2xl border border-line bg-canvas/60`,children:(0,G.jsx)(pc,{className:`h-[60vh]`,children:(0,G.jsx)(`pre`,{className:`whitespace-pre-wrap break-words p-5 font-mono text-xs leading-6 text-fg`,children:r})})})]}):(0,G.jsx)(pc,{className:`h-[60vh] rounded-2xl border border-line bg-canvas/60`,children:(0,G.jsx)(`div`,{className:`p-5`,children:(0,G.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-6 text-fg`,children:r})})}):(0,G.jsx)(`div`,{className:`animate-pulse text-sm text-fg-subtle`,children:`Loading artifact content…`})]})]})})})}function Dx({children:e,tooltip:t,onClick:n,disabled:r}){return(0,G.jsxs)(yv,{children:[(0,G.jsx)(bv,{asChild:!0,children:(0,G.jsx)(`button`,{type:`button`,onClick:n,disabled:r,className:W(`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted transition-colors`,`hover:bg-overlay hover:text-fg disabled:pointer-events-none disabled:opacity-50`,`[&_svg]:size-4`),children:e})}),(0,G.jsx)(xv,{children:t})]})}function Ox({artifact:e,compact:t=!1}){let[n,r]=(0,x.useState)(!1);return(0,G.jsxs)(`div`,{className:W(`overflow-hidden`,t?`bg-transparent`:`rounded-2xl border border-line bg-overlay/40`),children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>r(!n),className:W(`flex w-full items-center justify-between gap-3 text-left transition-colors`,t?`px-3 py-2 hover:bg-overlay/50`:`px-4 py-3 hover:bg-overlay/60`),children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,G.jsx)(Cx,{kind:e.kind,compact:t}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,G.jsx)(`div`,{className:`text-[11px] uppercase tracking-[0.14em] text-fg-subtle`,children:e.kind})]})]}),(0,G.jsx)(lr,{className:W(`size-4 shrink-0 text-fg-subtle transition-transform`,n&&`rotate-180`)})]}),n?(0,G.jsx)(`pre`,{className:W(`overflow-auto border-t border-line bg-canvas/60 font-mono text-xs text-fg whitespace-pre-wrap break-words`,t?`max-h-48 px-3 py-2`:`max-h-80 p-4`),children:JSON.stringify(e.data,null,2)}):null]})}function kx({jobId:e,artifacts:t,phaseName:n}){let[r,i]=(0,x.useState)(!1),a=t.length,o=a===0?`No artifacts yet`:`${a} artifact${a===1?``:`s`}`;return(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-line bg-canvas/20`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),"aria-expanded":r,className:`flex w-full items-center justify-between gap-3 px-3 py-2.5 text-left transition-colors hover:bg-overlay/50`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-[11px] uppercase tracking-[0.14em] text-fg-subtle`,children:`Phase artifacts`}),(0,G.jsxs)(`div`,{className:`truncate text-[13px] text-fg-muted`,children:[o,a>0&&!r?(0,G.jsxs)(`span`,{className:`text-fg-subtle`,children:[` `,`· `,t.map(e=>e.title).join(`, `)]}):null]})]}),(0,G.jsx)(lr,{className:W(`size-4 shrink-0 text-fg-subtle transition-transform`,r&&`rotate-180`)})]}),r?(0,G.jsx)(`div`,{className:`border-t border-line`,children:a===0?(0,G.jsxs)(`div`,{className:`px-3 py-2.5 text-[13px] text-fg-subtle`,children:[`No artifacts have been posted for `,(0,G.jsx)(`span`,{className:`font-mono`,children:n}),` yet.`]}):(0,G.jsx)(`div`,{className:`max-h-[min(280px,40vh)] divide-y divide-line overflow-y-auto`,children:t.map(t=>(0,G.jsx)(Sx,{jobId:e,artifact:t,variant:`compact`},t.id))})}):null]})}function Ax({value:e,className:t,indicatorClassName:n}){return(0,G.jsx)(`div`,{className:W(`relative h-1.5 overflow-hidden rounded-full bg-overlay`,t),children:(0,G.jsx)(`div`,{className:W(`h-full rounded-full bg-accent-400 transition-[width]`,n),style:{width:`${Math.max(0,Math.min(100,e))}%`}})})}function jx({checked:e,onCheckedChange:t,disabled:n=!1,ariaLabel:r,size:i=`md`,className:a}){let o=()=>{n||t(!e)},s=i===`sm`?{track:`h-4 w-7`,thumb:`size-3`,translate:`translate-x-3`}:{track:`h-5 w-9`,thumb:`size-4`,translate:`translate-x-4`};return(0,G.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":r,disabled:n,onClick:o,className:W(`relative inline-flex shrink-0 items-center rounded-full transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-400/60`,`disabled:cursor-not-allowed disabled:opacity-50`,s.track,e?`bg-accent-500`:`bg-overlay ring-1 ring-line-strong`,a),children:(0,G.jsx)(`span`,{className:W(`inline-block transform rounded-full bg-white shadow transition-transform`,s.thumb,e?s.translate:`translate-x-0.5`)})})}function Mx(e){return e.summary?.status??e.status}function Nx(e){return e===`failed`||e===`escalated`}function Px({status:e,rateLimitInfo:t}){let n=ko(e),r=Fx(e===`awaiting-rate-limit`?t?.resumeAt:void 0);return(0,G.jsxs)(vg,{variant:`neutral`,className:zo(n.tone),children:[(0,G.jsx)(`span`,{className:W(`size-1.5 rounded-full`,Bo(n.tone),n.pulse&&`animate-pulse-dot`)}),n.label,r?(0,G.jsx)(`span`,{className:`ml-1 font-mono tabular-nums text-[10px] opacity-80`,children:r}):null]})}function Fx(e){let[t,n]=(0,x.useState)(()=>Date.now());if((0,x.useEffect)(()=>{if(e==null)return;let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),e==null)return null;let r=Math.max(0,Math.ceil((e-t)/1e3)),i=Math.floor(r/3600),a=Math.floor(r%3600/60),o=r%60,s=e=>e.toString().padStart(2,`0`);return`${s(i)}:${s(a)}:${s(o)}`}function Ix(e){return Ty(e)}function Lx(e){let t={inputTokens:0,outputTokens:0,cacheReadInputTokens:0,cacheCreationInputTokens:0,totalCostUsd:0,totalDurationMs:0};for(let n of e){let e=n.summary?.tokenUsage;e&&(t.inputTokens+=e.inputTokens??0,t.outputTokens+=e.outputTokens??0,t.cacheReadInputTokens+=e.cacheReadInputTokens??0,t.cacheCreationInputTokens+=e.cacheCreationInputTokens??0,t.totalCostUsd+=e.totalCostUsd??0),n.startedAt&&n.completedAt&&(t.totalDurationMs+=new Date(n.completedAt).getTime()-new Date(n.startedAt).getTime())}return t}function Rx({children:e}){let t=(0,x.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.name,n);let n=[],r=new Set,i=0;for(;t.size>0&&i<50;){let e=[];for(let n of t.values())n.dependsOn.every(e=>r.has(e)||!t.has(e))&&e.push(n);if(e.length===0){n.push(Array.from(t.values()));break}for(let n of e)r.add(n.name),t.delete(n.name);n.push(e),i++}return n},[e]);return t.length===0?null:(0,G.jsx)(`div`,{className:`flex flex-col gap-3 overflow-x-auto`,children:t.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsxs)(`div`,{className:`w-10 shrink-0 text-[10px] uppercase tracking-[0.16em] text-fg-subtle`,children:[`L`,t+1]}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.map(e=>{let t=Mx(e);return(0,G.jsxs)(`div`,{className:W(`flex items-center gap-2 rounded-lg border px-2.5 py-1.5 text-xs`,zo(ko(t).tone)),children:[(0,G.jsx)(Px,{status:t,rateLimitInfo:e.summary?.rateLimitInfo}),(0,G.jsx)(`span`,{className:`font-medium`,children:e.name}),e.dependsOn.length>0?(0,G.jsxs)(`span`,{className:`text-[10px] text-fg-subtle`,children:[`← `,e.dependsOn.join(`, `)]}):null]},e.name)})})]},t))})}function zx({jobId:e,child:t,onMutated:n}){let[r,i]=(0,x.useState)(null),[a,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(!1),[l,u]=(0,x.useState)(``),d=(0,x.useRef)(null),f=async(r,a,s)=>{i(s),o(null);try{await q(`/jobs/${e}/children/${encodeURIComponent(t.name)}/${r}`,J(a??{},{method:`POST`})),c(!1),u(``),n()}catch(e){o(e instanceof Error?e.message:`Action failed`)}finally{i(null)}},p=Nx(Mx(t));if(t.status===`complete`||t.status===`skipped`||t.status===`cancelled`)return null;let m=()=>{if(!s){c(!0),queueMicrotask(()=>d.current?.focus());return}f(`resume`,l.trim()?{note:l.trim()}:void 0,`resume`)},h=()=>{window.confirm(`Start a fresh job for "${t.name}"?\n\nThis DROPS the existing child Job (transcript, partial work, any open PR will be orphaned) and dispatches a brand-new Job from the original spec. Use "Resume" instead unless the current Job is genuinely unrecoverable.`)&&f(`rerun`,void 0,`rerun`)};return(0,G.jsxs)(`div`,{className:`flex flex-col items-end gap-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t.status===`ready`?(0,G.jsxs)(Y,{onClick:()=>void f(`start`,void 0,`start`),disabled:r!==null,size:`sm`,className:`h-7 px-2 text-[11px]`,title:`Start this child now. Dependencies are satisfied; this bypasses the parallelism cap and any halt-on-failure pause.`,children:[(0,G.jsx)(ui,{className:`size-3.5`}),r===`start`?`…`:`Start`]}):null,p?(0,G.jsxs)(Y,{onClick:m,disabled:r!==null,size:`sm`,className:`h-7 px-2 text-[11px]`,title:s?`Resume the existing child Job — optionally with the note as developer guidance`:`Resume the existing child Job at its last phase`,children:[(0,G.jsx)(ui,{className:`size-3.5`}),r===`resume`?`…`:`Resume`]}):null,(0,G.jsxs)(Y,{onClick:()=>void f(`abandon`,void 0,`abandon`),disabled:r!==null,variant:`ghost`,size:`sm`,className:`h-7 px-2 text-[11px] text-danger-400 hover:bg-danger-500/10 hover:text-danger-400`,title:p?`Abandon — mark as not-needed, unblocks dependents`:`Abandon this child — unblocks dependents, descopes the work`,children:[(0,G.jsx)(ki,{className:`size-3.5`}),r===`abandon`?`…`:`Abandon`]}),p?(0,G.jsxs)(Jh,{children:[(0,G.jsx)(Yh,{asChild:!0,children:(0,G.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-7 px-1.5 text-[11px]`,disabled:r!==null,"aria-label":`More actions`,title:`More actions`,children:(0,G.jsx)(Tr,{className:`size-3.5`})})}),(0,G.jsx)(Zh,{align:`end`,className:`min-w-56`,children:(0,G.jsxs)(Qh,{onSelect:e=>{e.preventDefault(),h()},className:`text-danger-400 focus:text-danger-400`,children:[(0,G.jsx)(gi,{className:`size-3.5`}),`Start fresh job…`]})})]}):(0,G.jsx)(`span`,{"aria-hidden":!0,className:`inline-block h-7 w-7`})]}),s&&p?(0,G.jsxs)(`div`,{className:`flex w-full max-w-md flex-col items-end gap-1.5`,children:[(0,G.jsx)(`textarea`,{ref:d,value:l,onChange:e=>u(e.target.value),placeholder:`Optional: tell the agent what changed (becomes developer-input for the next turn)`,rows:3,className:`w-full resize-y rounded-md border border-line bg-overlay/60 px-2 py-1.5 text-[11px] text-fg placeholder:text-fg-subtle focus:border-accent focus:outline-none`,disabled:r!==null}),(0,G.jsx)(`div`,{className:`flex items-center gap-1.5`,children:(0,G.jsx)(Y,{onClick:()=>{c(!1),u(``)},variant:`ghost`,size:`sm`,className:`h-7 px-2 text-[11px]`,disabled:r!==null,children:`Cancel`})})]}):null,a?(0,G.jsx)(`span`,{className:`text-[11px] text-danger-400`,title:a,children:a}):null]})}function Bx({label:e,value:t,detail:n}){return(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-overlay/40 p-3`,children:[(0,G.jsx)(`div`,{className:`text-[11px] uppercase tracking-[0.16em] text-fg-subtle`,children:e}),(0,G.jsx)(`div`,{className:`mt-1 text-lg font-semibold text-fg`,children:t}),n?(0,G.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:n}):null]})}function Vx({job:e,children:t,onMutated:n}){let[r,i]=(0,x.useState)(null),[a,o]=(0,x.useState)(null),s=(0,x.useMemo)(()=>t.filter(e=>Nx(Mx(e))),[t]);if(e.status!==`awaiting-developer-input`||s.length===0)return null;let c=async t=>{i(t),o(null);let r=[];for(let n of s)try{await q(`/jobs/${e.id}/children/${encodeURIComponent(n.name)}/${t}`,J({},{method:`POST`}))}catch(e){r.push(`${n.name}: ${e instanceof Error?e.message:`failed`}`)}i(null),r.length>0&&o(`${r.length} action(s) failed — ${r.slice(0,2).join(`; `)}${r.length>2?`…`:``}`),n()},l=s.length===1?By.singularLower:By.pluralLower,u=`${s.length} failed ${l}`;return(0,G.jsxs)(`div`,{className:`rounded-xl border border-warning-500/40 bg-warning-500/10 p-3`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(Mi,{className:`mt-0.5 size-4 shrink-0 text-warning-400`}),(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:`Campaign halted on failure`}),(0,G.jsxs)(`p`,{className:`text-[12px] leading-snug text-fg-muted`,children:[u,` — Resume retries each at its last phase, Abandon descopes them. Use per-row buttons below if you want to add a note or mix actions.`]}),(0,G.jsx)(`p`,{className:`text-[11px] font-mono text-fg-subtle`,children:s.map(e=>e.name).join(`, `)})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,G.jsxs)(Y,{onClick:()=>void c(`resume`),disabled:r!==null,size:`sm`,className:`h-7 px-2 text-[11px]`,title:`Resume all ${u} at their last phase`,children:[(0,G.jsx)(ui,{className:`size-3.5`}),r===`resume`?`…`:`Resume all (${s.length})`]}),(0,G.jsxs)(Y,{onClick:()=>void c(`abandon`),disabled:r!==null,variant:`outline`,size:`sm`,className:`h-7 px-2 text-[11px] text-danger-400 hover:bg-danger-500/10 hover:text-danger-400`,title:`Abandon all ${u} — descope and let the campaign continue`,children:[(0,G.jsx)(ki,{className:`size-3.5`}),r===`abandon`?`…`:`Abandon all (${s.length})`]})]})]}),a?(0,G.jsx)(`div`,{className:`mt-2 text-[11px] text-danger-400`,children:a}):null]})}function Hx({job:e,onMutated:t}){let n=e.campaignChildren??[],r=Lx(n),i=n.reduce((e,t)=>(e[t.status]=(e[t.status]??0)+1,e),{pending:0,ready:0,dispatched:0,complete:0,failed:0,escalated:0,skipped:0,cancelled:0}),a=(0,x.useMemo)(()=>{let e={};for(let t of n){let n=Mx(t);e[n]=(e[n]??0)+1}return e},[n]),[o,s]=(0,x.useState)(!0),c=(0,x.useMemo)(()=>o?n.filter(e=>e.status!==`cancelled`):n,[n,o]);if(n.length===0)return(0,G.jsx)(lg,{children:(0,G.jsxs)(ug,{children:[(0,G.jsx)(dg,{children:By.plural}),(0,G.jsx)(fg,{children:`No ${By.pluralLower} registered yet. The campaign planner is still defining the execution graph.`})]})});let l=n.reduce((e,t)=>e+(t.summary?.prMappings.length??0),0),u=n.length-i.cancelled,d=i.complete+i.skipped,f=u===0?0:d/u*100;return(0,G.jsxs)(lg,{children:[(0,G.jsxs)(ug,{className:`gap-4 border-b border-line pb-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(dg,{children:By.plural}),(0,G.jsx)(fg,{children:`Dependency-aware execution view with per-${By.singularLower} controls.`})]}),(0,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:Object.keys(a).filter(e=>a[e]>0).map(e=>(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px]`,children:[(0,G.jsx)(Px,{status:e}),(0,G.jsx)(`span`,{className:`tabular-nums text-fg-muted`,children:a[e]})]},e))})]}),(0,G.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,G.jsx)(Bx,{label:`Progress`,value:`${d}/${u}`,detail:`${Math.round(f)}% complete`}),(0,G.jsx)(Bx,{label:`Tokens`,value:Ix(r.inputTokens+r.outputTokens),detail:`Across all ${By.pluralLower}`}),(0,G.jsx)(Bx,{label:`Cost`,value:Ey(r.totalCostUsd),detail:`Aggregate ${By.singularLower} spend`}),(0,G.jsx)(Bx,{label:`Pull requests`,value:l.toString(),detail:`Opened across ${By.pluralLower}`})]}),(0,G.jsx)(Ax,{value:f})]}),(0,G.jsxs)(pg,{className:`space-y-5 pt-5`,children:[(0,G.jsx)(Vx,{job:e,children:n,onMutated:t}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-[11px] font-medium uppercase tracking-[0.16em] text-fg-subtle`,children:[(0,G.jsx)(Yr,{className:`size-3.5`}),`Dependency graph`]}),(0,G.jsx)(Rx,{children:c})]}),i.cancelled>0?(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-2 text-[11px] text-fg-muted`,children:[(0,G.jsxs)(`span`,{children:[`Hide cancelled (`,i.cancelled,`)`]}),(0,G.jsx)(jx,{size:`sm`,checked:o,onCheckedChange:s,ariaLabel:`Hide cancelled children`})]}):null,(0,G.jsx)(`div`,{className:`overflow-x-auto rounded-2xl border border-line`,children:(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{className:`bg-overlay/40 text-fg-subtle`,children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{className:`px-3 py-2 text-left font-medium`,children:`Name`}),(0,G.jsx)(`th`,{className:`px-3 py-2 text-left font-medium`,children:`Status`}),(0,G.jsx)(`th`,{className:`px-3 py-2 text-left font-medium`,children:`Phase`}),(0,G.jsx)(`th`,{className:`px-3 py-2 text-left font-medium`,children:`Tracker`}),(0,G.jsx)(`th`,{className:`px-3 py-2 text-left font-medium`,children:`Job`}),(0,G.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:`PRs`}),(0,G.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:`Tokens`}),(0,G.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:`Actions`})]})}),(0,G.jsx)(`tbody`,{className:`divide-y divide-line`,children:c.map(n=>{let r=n.summary?.phase??`—`,i=n.summary?.prMappings.length??0,a=(n.summary?.tokenUsage?.inputTokens??0)+(n.summary?.tokenUsage?.outputTokens??0);return(0,G.jsxs)(`tr`,{className:`transition-colors hover:bg-overlay/40`,children:[(0,G.jsxs)(`td`,{className:`px-3 py-2.5`,children:[(0,G.jsx)(`div`,{className:`font-medium text-fg`,children:n.name}),n.description?(0,G.jsx)(`div`,{className:`line-clamp-2 max-w-[280px] text-[11px] text-fg-subtle`,children:n.description}):null]}),(0,G.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,G.jsx)(Px,{status:Mx(n),rateLimitInfo:n.summary?.rateLimitInfo})}),(0,G.jsx)(`td`,{className:`px-3 py-2.5 text-fg-muted`,children:r}),(0,G.jsx)(`td`,{className:`px-3 py-2.5`,children:n.trackerRef?(0,G.jsx)(`a`,{href:n.trackerRef.url,target:`_blank`,rel:`noreferrer`,className:`text-accent-300 hover:text-accent-400`,children:n.trackerRef.key}):(0,G.jsx)(`span`,{className:`text-fg-subtle`,children:`—`})}),(0,G.jsx)(`td`,{className:`px-3 py-2.5`,children:n.jobId?(0,G.jsxs)(Dn,{to:`/jobs/${n.jobId}`,className:`font-mono text-[11px] text-accent-300 hover:text-accent-400`,title:`Open ${By.singularLower} detail`,children:[n.jobId.slice(0,18),`…`]}):(0,G.jsx)(`span`,{className:`text-fg-subtle`,children:`—`})}),(0,G.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums text-fg-muted`,children:i}),(0,G.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums text-fg-muted`,children:a>0?Ix(a):`—`}),(0,G.jsx)(`td`,{className:`px-3 py-2.5 text-right`,children:(0,G.jsx)(zx,{jobId:e.id,child:n,onMutated:t})})]},n.name)})})]})}),(0,G.jsxs)(`div`,{className:`grid gap-3 border-t border-line pt-4 text-sm sm:grid-cols-4`,children:[(0,G.jsx)(Ux,{label:`Tokens in / out`,value:`${Ix(r.inputTokens)} / ${Ix(r.outputTokens)}`}),(0,G.jsx)(Ux,{label:`Cache read`,value:Ix(r.cacheReadInputTokens)}),(0,G.jsx)(Ux,{label:`Latest update`,value:Cy(e.updatedAt)}),(0,G.jsx)(Ux,{label:`Running ${By.pluralLower}`,value:(i.dispatched+i.ready).toString()})]})]})]})}function Ux({label:e,value:t}){return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-[11px] uppercase tracking-[0.16em] text-fg-subtle`,children:e}),(0,G.jsx)(`div`,{className:`mt-1 font-medium text-fg`,children:t})]})}function Wx({status:e,lastHeartbeat:t}){let[n,r]=(0,x.useState)(0);(0,x.useEffect)(()=>{let e=setInterval(()=>{r(Math.floor((Date.now()-t)/1e3))},1e3);return()=>clearInterval(e)},[t]);let i=Ao(e);return(0,G.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border px-2.5 py-1 text-[11px] ${zo(i.tone)}`,children:[(0,G.jsx)(`span`,{className:`size-1.5 rounded-full ${Bo(i.tone)} ${i.pulse?`animate-pulse-dot`:``}`}),(0,G.jsx)(`span`,{className:`font-medium uppercase tracking-[0.16em]`,children:i.label}),e===`connected`&&n>0?(0,G.jsxs)(`span`,{className:`text-fg-muted normal-case tracking-normal`,children:[`· `,Cy(new Date(Date.now()-n*1e3))]}):null]})}var Gx=[{value:`tenant`,label:`Team`},{value:`repo`,label:`Repo`},{value:`evaluator`,label:`Let evaluator decide`}],Kx=[{value:`all`,label:`All`},{value:`pending`,label:`Pending`},{value:`approved`,label:`Approved`},{value:`rejected`,label:`Rejected`}];function qx(e){return e.status??`pending`}function Jx(e){return e.userLayer??e.suggestedLayer}function Yx(e){return e.userLayer===`tenant`?`tenant`:e.userLayer===`repo`?`repo`:`evaluator`}function Xx(e){return e===`approved`?`success`:e===`rejected`?`danger`:`warning`}function Zx({jobId:e,insights:t,onChanged:n}){let[r,i]=(0,x.useState)(t),[a,o]=(0,x.useState)(`all`),[s,c]=(0,x.useState)(null),[l,u]=(0,x.useState)(null),[d,f]=(0,x.useState)({summary:``,detail:``,suggestion:``}),[p,m]=(0,x.useState)(null),[h,g]=(0,x.useState)(null);async function _(){try{i((await q(`/jobs/${encodeURIComponent(e)}/insights`)).insights??[]),m(null)}catch(e){m(e instanceof K?`${e.status}: ${e.message}`:e.message)}}(0,x.useEffect)(()=>{_()},[e]),(0,x.useEffect)(()=>{t.length>r.length&&_()},[t.length]);let v=(0,x.useMemo)(()=>{let e={pending:0,approved:0,rejected:0};for(let t of r)e[qx(t)]++;return e},[r]),y=(0,x.useMemo)(()=>a===`all`?r:r.filter(e=>qx(e)===a),[r,a]),b=(0,x.useMemo)(()=>{let e=new Map,t=0;for(let n of r)qx(n)!==`rejected`&&(t++,e.set(n.id??`${n.phase}:${n.summary}`,t));return e},[r]);async function S(t,r){g(t),m(null);try{let a=await q(`/jobs/${encodeURIComponent(e)}/insights/${encodeURIComponent(t)}`,J(r,{method:`PATCH`}));a?.insight?i(e=>e.map(e=>e.id===t?a.insight:e)):await _(),n()}catch(e){m(e instanceof K?`${e.status}: ${e.message}`:e.message)}finally{g(null)}}function C(e){u(e.id??null),f({summary:e.editedSummary??e.summary,detail:e.editedDetail??e.detail,suggestion:e.editedSuggestion??e.suggestion??``})}async function w(e){if(!e.id)return;let t={};t.editedSummary=d.summary===e.summary?null:d.summary,t.editedDetail=d.detail===e.detail?null:d.detail;let n=e.suggestion??``;t.editedSuggestion=d.suggestion===n?null:d.suggestion||null,await S(e.id,t),u(null)}function T(){u(null)}async function E(e,t){e.id&&await S(e.id,{userLayer:t===`evaluator`?null:t})}async function D(e,t){e.id&&await S(e.id,{status:t})}return(0,G.jsxs)(lg,{children:[(0,G.jsxs)(ug,{className:`gap-3 border-b border-line pb-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(dg,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Xr,{className:`size-4 text-amber-500`,"aria-hidden":`true`}),`Insights`,(0,G.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,v.pending,` pending · `,v.approved,` approved · `,v.rejected,` rejected)`]})]}),(0,G.jsx)(fg,{children:`Findings recorded by agents during the run. Approve the ones you want the evaluator to ship as memory PRs and tag whether they belong in your team or repo intelligence layer. Rejected entries are kept for audit but skipped by the evaluator.`})]}),(0,G.jsx)(ab,{options:Kx,value:a,onChange:o,size:`sm`,ariaLabel:`Filter insights by status`})]}),(0,G.jsxs)(pg,{className:`space-y-3 pt-5`,children:[p?(0,G.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:p}):null,y.length===0?(0,G.jsx)(`div`,{className:`rounded-md border border-dashed border-line px-4 py-8 text-center text-sm text-muted-foreground`,children:r.length===0?`No insights have been recorded yet. Agents call add_insight during the run to surface findings here.`:`No insights match the "${a}" filter.`}):null,y.map(e=>{let t=qx(e),n=e.id??`${e.phase}:${e.summary}`,r=s===n,i=l===n,a=h===e.id,o=Jx(e),u=e.editedSummary||e.editedDetail||e.editedSuggestion,p=e.editedSummary??e.summary,m=e.editedDetail??e.detail,g=e.editedSuggestion??e.suggestion,_=b.get(n);return(0,G.jsxs)(`div`,{className:W(`rounded-md border border-line bg-overlay/40 transition-opacity`,t===`rejected`&&`opacity-60`,a&&`opacity-50`),children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3 p-3`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>c(r?null:n),className:`mt-0.5 text-muted-foreground hover:text-foreground`,"aria-label":r?`Collapse`:`Expand`,children:r?(0,G.jsx)(lr,{className:`size-4`}):(0,G.jsx)(ur,{className:`size-4`})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[_==null?null:(0,G.jsxs)(vg,{variant:`neutral`,className:`font-mono normal-case tracking-normal`,title:e.id?`Insight ${e.id}`:void 0,children:[`#`,_]}),(0,G.jsx)(vg,{variant:Xx(t),className:`capitalize`,children:t}),(0,G.jsx)(vg,{variant:`neutral`,className:`font-mono`,children:e.phase}),(0,G.jsx)(vg,{variant:`accent`,children:e.category}),o?(0,G.jsxs)(vg,{variant:`neutral`,children:[e.userLayer?`layer: `:`suggested: `,o===`tenant`?`team`:`repo`]}):null,e.sourceChildName?(0,G.jsxs)(vg,{variant:`neutral`,children:[`from `,e.sourceChildName]}):null,u?(0,G.jsx)(vg,{variant:`warning`,children:`edited`}):null]}),(0,G.jsx)(`p`,{className:`text-sm font-medium leading-snug`,children:p}),e.editedAt||e.decidedAt?(0,G.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[e.decidedAt?(0,G.jsxs)(G.Fragment,{children:[`decided `,Cy(e.decidedAt),e.decidedBy?` by ${e.decidedBy}`:``]}):null,e.decidedAt&&e.editedAt?` · `:``,e.editedAt?(0,G.jsxs)(G.Fragment,{children:[`edited `,Cy(e.editedAt),e.editedBy?` by ${e.editedBy}`:``]}):null]}):null]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[t===`approved`?null:(0,G.jsxs)(Y,{size:`sm`,variant:`success`,disabled:a,onClick:()=>void D(e,`approved`),children:[(0,G.jsx)(cr,{className:`size-3.5`}),` Approve`]}),t===`rejected`?null:(0,G.jsxs)(Y,{size:`sm`,variant:`ghost`,disabled:a,onClick:()=>void D(e,`rejected`),children:[(0,G.jsx)(Pi,{className:`size-3.5`}),` Reject`]}),t===`pending`?null:(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,disabled:a,onClick:()=>void D(e,`pending`),title:`Reset to pending`,children:(0,G.jsx)(gi,{className:`size-3.5`})})]})]}),r?(0,G.jsxs)(`div`,{className:`space-y-4 border-t border-line/60 px-3 py-4`,children:[i?(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Summary`}),(0,G.jsx)(bb,{rows:2,value:d.summary,onChange:e=>f({...d,summary:e.target.value})})]}),(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Detail`}),(0,G.jsx)(bb,{rows:6,value:d.detail,onChange:e=>f({...d,detail:e.target.value})})]}),(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Suggestion (optional)`}),(0,G.jsx)(bb,{rows:3,value:d.suggestion,onChange:e=>f({...d,suggestion:e.target.value})})]}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:T,children:`Cancel`}),(0,G.jsx)(Y,{size:`sm`,variant:`primary`,onClick:()=>void w(e),children:`Save edits`})]})]}):(0,G.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Detail`}),(0,G.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap leading-relaxed`,children:m})]}),g?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Suggestion`}),(0,G.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap leading-relaxed`,children:g})]}):null,u?(0,G.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,G.jsx)(`summary`,{className:`cursor-pointer`,children:`Show original (pre-edit)`}),(0,G.jsxs)(`div`,{className:`mt-2 space-y-2 rounded bg-muted/30 p-2`,children:[(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`span`,{className:`font-medium`,children:`Summary:`}),` `,e.summary]}),(0,G.jsxs)(`p`,{className:`whitespace-pre-wrap`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:`Detail:`}),` `,e.detail]}),e.suggestion?(0,G.jsxs)(`p`,{className:`whitespace-pre-wrap`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:`Suggestion:`}),` `,e.suggestion]}):null]})]}):null]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-line/40 pt-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Target layer:`}),(0,G.jsx)(ab,{options:Gx,value:Yx(e),onChange:t=>void E(e,t),size:`sm`,ariaLabel:`Target intelligence layer`})]}),i?null:(0,G.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>C(e),children:[(0,G.jsx)(li,{className:`size-3.5`}),` Edit`]})]})]}):null]},n)})]})]})}async function Qx(e,t={}){let n=new URLSearchParams;t.base&&n.set(`base`,t.base),t.head&&n.set(`head`,t.head);let r=n.toString();return q(`/jobs/${e}/diff${r?`?${r}`:``}`)}var $x=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;function eS(e){return e===`/dev/null`?e:e.startsWith(`a/`)||e.startsWith(`b/`)?e.slice(2):e}function tS(e){if(!e.trim())return[];let t=e.split(`
|
|
61
|
-
`),n=[],r=null,i=null,a=0,o=0,s=()=>{if(r){let e=r.status===`deleted`?r.oldPath:r.newPath||r.oldPath;r.path=e,n.push(r)}};for(let e of t){if(e.startsWith(`diff --git`)){s(),i=null;let t=e.match(/^diff --git (.+) (.+)$/),n=t?eS(t[1]):``,a=t?eS(t[2]):``;r={oldPath:n,newPath:a,path:a||n,status:`modified`,binary:!1,hunks:[],additions:0,deletions:0};continue}if(!r)continue;if(e.startsWith(`new file mode`)){r.status=`added`;continue}if(e.startsWith(`deleted file mode`)){r.status=`deleted`;continue}if(e.startsWith(`rename from `)){r.status=`renamed`,r.oldPath=e.slice(12);continue}if(e.startsWith(`rename to `)){r.status=`renamed`,r.newPath=e.slice(10);continue}if(e.startsWith(`Binary files`)||e.startsWith(`GIT binary patch`)){r.binary=!0;continue}if(e.startsWith(`--- `)){let t=eS(e.slice(4));t!==`/dev/null`&&(r.oldPath=t);continue}if(e.startsWith(`+++ `)){let t=eS(e.slice(4));t!==`/dev/null`&&(r.newPath=t);continue}let t=e.match($x);if(t){a=parseInt(t[1],10),o=parseInt(t[3],10),i={header:e,lines:[]},r.hunks.push(i);continue}if(i&&!e.startsWith(`\\`))if(e.startsWith(`+`))i.lines.push({type:`add`,text:e.slice(1),oldNo:null,newNo:o}),r.additions+=1,o+=1;else if(e.startsWith(`-`))i.lines.push({type:`del`,text:e.slice(1),oldNo:a,newNo:null}),r.deletions+=1,a+=1;else{let t=e.startsWith(` `)?e.slice(1):e;i.lines.push({type:`context`,text:t,oldNo:a,newNo:o}),a+=1,o+=1}}return s(),n}async function nS(){return q(`/system/editors`)}async function rS(e,t){return q(`/jobs/${e}/open`,J(t,{method:`POST`}))}var iS={code:`M23.15 2.587L18.21.21a1.494 1.494 0 0 0-1.705.29l-9.46 8.63-4.12-3.128a.999.999 0 0 0-1.276.057L.327 7.261A1 1 0 0 0 .326 8.74L3.899 12 .326 15.26a1 1 0 0 0 .001 1.479L1.65 17.94a.999.999 0 0 0 1.276.057l4.12-3.128 9.46 8.63a1.492 1.492 0 0 0 1.704.29l4.942-2.377A1.5 1.5 0 0 0 24 20.06V3.939a1.5 1.5 0 0 0-.85-1.352zm-5.146 14.861L10.826 12l7.178-5.448v10.896z`,cursor:`M11.503.131 1.891 5.678a.84.84 0 0 0-.42.726v11.188c0 .3.162.575.42.724l9.609 5.55a1 1 0 0 0 .998 0l9.61-5.55a.84.84 0 0 0 .42-.724V6.404a.84.84 0 0 0-.42-.726L12.497.131a1.01 1.01 0 0 0-.996 0M2.657 6.338h18.55c.263 0 .43.287.297.515L12.23 22.918c-.062.107-.229.064-.229-.06V12.335a.59.59 0 0 0-.295-.51l-9.11-5.257c-.109-.063-.064-.23.061-.23`,codium:`M11.583.54a1.467 1.467 0 0 0-.441 2.032c2.426 3.758 2.999 6.592 2.75 9.075-1.004 4.756-3.187 5.721-5.094 5.721-1.863 0-1.364-3.065.036-3.962.836-.522 1.906-.861 2.728-.861.814 0 1.474-.658 1.474-1.47 0-.812-.66-1.47-1.474-1.47-.96 0-1.901.202-2.78.545.18-.847.246-1.762.014-2.735-.352-1.477-1.367-2.889-3.128-4.257a1.476 1.476 0 0 0-2.069.256c-.5.64-.384 1.564.259 2.063 1.435 1.114 1.908 1.939 2.07 2.618.162.679.032 1.407-.293 2.408-.416 1.349-.9 2.553-1.11 3.708-.105.568-.114 1.187-.14 1.68-1.034-1.006-1.438-2.336-1.438-4.279 0-.811-.66-1.47-1.474-1.47-.814.001-1.473.659-1.473 1.47 0 2.654.776 5.179 2.855 6.863 1.883 1.793 6.67 1.13 6.67 4.01 0 .812 1.19 1.208 2.004 1.208.834 0 1.885-.558 1.885-1.208 0-3.267 3.443-5.253 9.11-5.244A1.472 1.472 0 0 0 24 15.773 1.472 1.472 0 0 0 22.53 14.3c-.388 0-.765.013-1.138.035.634-1.49.915-3.13.857-4.903a1.473 1.473 0 0 0-1.522-1.42 1.472 1.472 0 0 0-1.425 1.517c.076 2.32-.01 4.393-1.74 5.485-.49.31-1.062.58-1.604.58.42-1.145.738-2.353.869-3.655.083-.83.091-1.818-.003-2.585-.148-1.188-.325-2.535.126-3.55.405-.874 1.313-1.24 2.645-1.24.814 0 1.473-.659 1.473-1.47 0-.811-.659-1.47-1.473-1.47-1.98 0-3.481 1.042-4.332 2.3-.445-.95-.987-1.929-1.642-2.943a1.474 1.474 0 0 0-2.037-.44z`,windsurf:`M23.55 5.067c-1.2038-.002-2.1806.973-2.1806 2.1765v4.8676c0 .972-.8035 1.7594-1.7597 1.7594-.568 0-1.1352-.286-1.4718-.7659l-4.9713-7.1003c-.4125-.5896-1.0837-.941-1.8103-.941-1.1334 0-2.1533.9635-2.1533 2.153v4.8957c0 .972-.7969 1.7594-1.7596 1.7594-.57 0-1.1363-.286-1.4728-.7658L.4076 5.1598C.2822 4.9798 0 5.0688 0 5.2882v4.2452c0 .2147.0656.4228.1884.599l5.4748 7.8183c.3234.462.8006.8052 1.3509.9298 1.3771.313 2.6446-.747 2.6446-2.0977v-4.893c0-.972.7875-1.7593 1.7596-1.7593h.003a1.798 1.798 0 0 1 1.4718.7658l4.9723 7.0994c.4135.5905 1.05.941 1.8093.941 1.1587 0 2.1515-.9645 2.1515-2.153v-4.8948c0-.972.7875-1.7594 1.7596-1.7594h.194a.22.22 0 0 0 .2204-.2202v-4.622a.22.22 0 0 0-.2203-.2203Z`};iS[`code-insiders`]=iS.code;function aS({id:e,className:t}){let n=iS[e];return n?(0,G.jsx)(`svg`,{viewBox:`0 0 24 24`,className:t,fill:`currentColor`,"aria-hidden":`true`,role:`img`,children:(0,G.jsx)(`path`,{d:n})}):(0,G.jsx)(xr,{className:t})}function oS({files:e,truncated:t,showFileMap:n=!0}){let[r,i]=(0,x.useState)(()=>e.map(()=>!1));(0,x.useEffect)(()=>{i(e.map(()=>!1))},[e]);let a=(0,x.useRef)([]),o=(0,x.useCallback)(t=>i(e.map(()=>t)),[e]),s=(0,x.useCallback)(e=>i(t=>t.map((t,n)=>n===e?!t:t)),[]),c=(0,x.useCallback)(e=>{i(t=>t.map((t,n)=>n===e?!0:t)),requestAnimationFrame(()=>a.current[e]?.scrollIntoView({block:`nearest`,behavior:`smooth`}))},[]);if(e.length===0)return null;let l=r.length>0&&r.every(Boolean),u=r.every(e=>!e);return(0,G.jsxs)(`div`,{className:`space-y-3`,children:[n&&e.length>1?(0,G.jsx)(sS,{files:e,onJump:c,onExpandAll:()=>o(!0),onCollapseAll:()=>o(!1),allOpen:l,allClosed:u}):null,e.map((e,t)=>(0,G.jsx)(cS,{file:e,open:r[t]??!1,onToggle:()=>s(t),cardRef:e=>{a.current[t]=e}},t)),t?(0,G.jsx)(`p`,{className:`rounded-lg border border-warning-500/20 bg-warning-500/5 px-3 py-2 text-xs text-warning-300`,children:`This diff is very large and was truncated. Open the full PR on the SCM to review every line.`}):null]})}function sS({files:e,onJump:t,onExpandAll:n,onCollapseAll:r,allOpen:i,allClosed:a}){return(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-line bg-canvas/40`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-line px-3 py-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,G.jsx)(Qr,{className:`size-3.5 text-fg-subtle`}),e.length,` files changed`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:n,disabled:i,className:`text-fg-subtle transition-colors hover:text-fg disabled:opacity-40`,children:`Expand all`}),(0,G.jsx)(`span`,{className:`text-line`,children:`·`}),(0,G.jsx)(`button`,{type:`button`,onClick:r,disabled:a,className:`text-fg-subtle transition-colors hover:text-fg disabled:opacity-40`,children:`Collapse all`})]})]}),(0,G.jsx)(`ul`,{className:`max-h-56 overflow-y-auto py-1`,children:e.map((e,n)=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(n),className:`flex w-full items-center gap-2 px-3 py-1 text-left transition-colors hover:bg-overlay/40`,children:[(0,G.jsx)(uS,{status:e.status}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-fg-muted`,children:e.status===`renamed`&&e.oldPath!==e.newPath?`${e.oldPath} → ${e.newPath}`:e.path}),e.additions>0?(0,G.jsxs)(`span`,{className:`font-mono text-xs text-success-400`,children:[`+`,e.additions]}):null,e.deletions>0?(0,G.jsxs)(`span`,{className:`font-mono text-xs text-danger-400`,children:[`−`,e.deletions]}):null]})},n))})]})}function cS({file:e,open:t,onToggle:n,cardRef:r}){return(0,G.jsxs)(`div`,{ref:r,className:`scroll-mt-4 overflow-hidden rounded-xl border border-line bg-canvas/40`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:n,className:`flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-overlay/40`,children:[t?(0,G.jsx)(lr,{className:`size-3.5 shrink-0 text-fg-subtle`}):(0,G.jsx)(ur,{className:`size-3.5 shrink-0 text-fg-subtle`}),(0,G.jsx)(uS,{status:e.status}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-fg`,children:e.status===`renamed`&&e.oldPath!==e.newPath?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`span`,{className:`text-fg-subtle`,children:[e.oldPath,` → `]}),e.newPath]}):e.path}),e.additions>0?(0,G.jsxs)(`span`,{className:`font-mono text-xs text-success-400`,children:[`+`,e.additions]}):null,e.deletions>0?(0,G.jsxs)(`span`,{className:`font-mono text-xs text-danger-400`,children:[`−`,e.deletions]}):null]}),t?e.binary?(0,G.jsx)(`div`,{className:`border-t border-line px-3 py-3 text-xs text-fg-subtle`,children:`Binary file not shown.`}):e.hunks.length===0?(0,G.jsx)(`div`,{className:`border-t border-line px-3 py-3 text-xs text-fg-subtle`,children:`No textual changes.`}):(0,G.jsx)(`div`,{className:`overflow-x-auto border-t border-line`,children:(0,G.jsx)(`table`,{className:`w-full border-collapse font-mono text-xs leading-5`,children:(0,G.jsx)(`tbody`,{children:e.hunks.map((e,t)=>(0,G.jsx)(lS,{hunk:e},t))})})}):null]})}function lS({hunk:e}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`tr`,{className:`bg-overlay/40 text-fg-subtle`,children:[(0,G.jsx)(`td`,{className:`select-none px-2 text-right align-top`}),(0,G.jsx)(`td`,{className:`select-none px-2 text-right align-top`}),(0,G.jsx)(`td`,{className:`whitespace-pre-wrap break-words px-3 py-0.5`,children:e.header})]}),e.lines.map((e,t)=>(0,G.jsxs)(`tr`,{className:W(e.type===`add`&&`bg-success-500/10`,e.type===`del`&&`bg-danger-500/10`),children:[(0,G.jsx)(`td`,{className:`w-[1%] select-none whitespace-nowrap px-2 text-right align-top text-fg-subtle/70`,children:e.oldNo??``}),(0,G.jsx)(`td`,{className:`w-[1%] select-none whitespace-nowrap px-2 text-right align-top text-fg-subtle/70`,children:e.newNo??``}),(0,G.jsxs)(`td`,{className:W(`whitespace-pre-wrap break-words px-3 align-top`,e.type===`add`&&`text-success-400`,e.type===`del`&&`text-danger-400`,e.type===`context`&&`text-fg-muted`),children:[(0,G.jsx)(`span`,{className:`select-none text-fg-subtle/60`,children:e.type===`add`?`+`:e.type===`del`?`−`:` `}),e.text]})]},t))]})}function uS({status:e}){let t=`size-3.5 shrink-0`;switch(e){case`added`:return(0,G.jsx)(Nr,{className:W(t,`text-success-400`)});case`deleted`:return(0,G.jsx)(Mr,{className:W(t,`text-danger-400`)});case`renamed`:return(0,G.jsx)(Fr,{className:W(t,`text-accent-300`)});default:return(0,G.jsx)(Ar,{className:W(t,`text-fg-muted`)})}}var dS=4e3;function fS(e){let t=[],n=new Map;for(let r of e.artifacts??[]){if(r.kind!==`pr-preview`)continue;let e=r.data,i=t=>typeof e[t]==`string`?e[t]:void 0,a={title:i(`title`),description:i(`description`),base:i(`base`),sourceBranch:i(`sourceBranch`),workItem:i(`workItem`),createdAt:r.createdAt},o=a.sourceBranch;o&&n.has(o)?t[n.get(o)]=a:(o&&n.set(o,t.length),t.push(a))}return t.sort((e,t)=>t.createdAt.localeCompare(e.createdAt))}function pS(e,t){if(t.title)for(let n of e.artifacts??[]){if(n.kind!==`pr-link`)continue;let e=n.data;if(e.title!==t.title)continue;let r=typeof e.url==`string`?e.url:void 0,i=e.prId,a=typeof i==`number`?i:typeof i==`string`&&i.trim()?Number(i):void 0;return{url:r,prId:Number.isFinite(a)?a:void 0}}}function mS(e,t){let n=e.workItem,r=n?t.workItems?.find(e=>e.name===n):void 0,i=pS(t,e),a=i?.url,o=i?.prId==null?void 0:t.prMappings?.find(e=>e.prId===i.prId);return r?.status===`escalated`?{label:`Escalated`,variant:`danger`,prUrl:a}:o?.mergedAt?{label:`Merged`,variant:`success`,prUrl:a}:o&&!o.mergedAt?{label:`PR open`,variant:`accent`,prUrl:a}:r?.status===`complete`?{label:`Merged`,variant:`success`,prUrl:a}:n&&n===t.currentWorkItem?{label:`In progress`,variant:`warning`,prUrl:a}:{label:`Awaiting review`,variant:`neutral`,prUrl:a}}function hS(e){let t=e.params;for(let e of[`targetBranch`,`baseBranch`,`defaultBranch`]){let n=t[e];if(typeof n==`string`&&n.trim())return n.trim()}return`main`}function gS(e){if(e.length===0)return{base:`main`};let t=new Set(e.map(e=>e.sourceBranch).filter(Boolean)),n=e.map(e=>e.base).filter(e=>!!e),r=e[0].base??`main`;for(let n of e)if(n.base&&!t.has(n.base)){r=n.base;break}let i;for(let t of e)t.sourceBranch&&!n.includes(t.sourceBranch)&&(i=t.sourceBranch);return{base:r,head:i}}function _S(e,t){let n=e.currentWorkItem,r=n?t.filter(e=>e.workItem===n):t,i=r.filter(t=>{let{label:n}=mS(t,e);return n===`PR open`||n===`In progress`||n===`Awaiting review`}),a=i.length>0?i:r;if(a.length===0)return{base:hS(e)};let{base:o,head:s}=gS(a);return{base:o||hS(e),head:s}}function vS(e){return fS(e).some(t=>{let{label:n}=mS(t,e);return n!==`Merged`&&n!==`Escalated`})}function yS(e,t){let{base:n,head:r,live:i,enabled:a=!0}=t,[o,s]=(0,x.useState)(null),[c,l]=(0,x.useState)(!0),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(!1),m=(0,x.useRef)(!1),h=(0,x.useCallback)(async t=>{if(!m.current){m.current=!0,t&&p(!0);try{s(await Qx(e,{base:n,head:r})),d(null)}catch(e){d(e instanceof Error?e.message:`Failed to load changes`)}finally{m.current=!1,l(!1),t&&p(!1)}}},[e,n,r]);return(0,x.useEffect)(()=>{if(!a||(h(!1),!i))return;let e=window.setInterval(()=>void h(!1),dS);return()=>window.clearInterval(e)},[h,i,a]),{diff:o,loading:c,error:u,refresh:()=>h(!0),refreshing:f}}function bS({job:e,live:t}){let n=(0,x.useMemo)(()=>fS(e),[e]),r=(0,x.useMemo)(()=>_S(e,n),[e,n]),i=t||n.length===0;return(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsx)(xS,{jobId:e.id}),i?(0,G.jsx)(SS,{jobId:e.id,live:t,workItem:e.currentWorkItem,diffOpts:r,stackedPrCount:n.filter(t=>t.workItem===e.currentWorkItem&&mS(t,e).label===`PR open`).length}):null,n.length>0?(0,G.jsx)(CS,{jobId:e.id,job:e,live:t,previews:n}):null]})}function xS({jobId:e}){let[t,n]=(0,x.useState)(null),[r,i]=(0,x.useState)(!1),[a,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(null);(0,x.useEffect)(()=>{let e=!0;return nS().then(t=>{e&&(i(t.mode===`local`),n(t.editors))}).catch(()=>{e&&n([])}),()=>{e=!1}},[]);let l=(0,x.useCallback)(async(t,n)=>{o(n??t),c(null);try{await rS(e,{target:t,editor:n})}catch(e){c(e instanceof Error?e.message:`Could not open`)}finally{o(null)}},[e]);return r?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(t??[]).length>0?(0,G.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:`Open in`}):null,(t??[]).map(e=>(0,G.jsx)(Y,{type:`button`,variant:`secondary`,size:`icon`,className:`size-8`,onClick:()=>l(`editor`,e.id),disabled:a!==null,title:`Open in ${e.name}`,"aria-label":`Open in ${e.name}`,children:(0,G.jsx)(aS,{id:e.id})},e.id)),(0,G.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8`,onClick:()=>l(`folder`),disabled:a!==null,title:`Reveal folder in file manager`,"aria-label":`Reveal folder in file manager`,children:(0,G.jsx)(Rr,{})}),s?(0,G.jsx)(`span`,{className:`text-xs text-danger-400`,children:s}):null]}):null}function SS({jobId:e,live:t,workItem:n,diffOpts:r,stackedPrCount:i}){let{diff:a,loading:o,error:s,refresh:c,refreshing:l}=yS(e,{live:t,...r}),u=(0,x.useMemo)(()=>tS(a?.patch??``),[a?.patch]);return(0,G.jsxs)(`section`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Working now`}),n?(0,G.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:[`Work item: `,(0,G.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n}),i>1?` — cumulative diff across ${i} open PRs (stack tip vs ${r.base??`main`}).`:r.head?` — changes on ${r.head} vs ${r.base??`main`}.`:` — live changes in the repo checkout.`]}):(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:`Live changes in the cloned repository.`})]}),(0,G.jsxs)(lg,{children:[(0,G.jsxs)(ug,{className:`gap-3 border-b border-line pb-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,G.jsx)(fg,{className:`m-0`,children:(0,G.jsx)(ES,{diff:a})}),(0,G.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:c,disabled:l,children:[(0,G.jsx)(hi,{className:W(l&&`animate-spin`)}),`Refresh`]})]}),(0,G.jsx)(pg,{className:`pt-5`,children:o&&!a?(0,G.jsx)(`div`,{className:`animate-pulse text-sm text-fg-subtle`,children:`Loading changes…`}):s?(0,G.jsx)(gg,{title:`Could not load changes`,message:s}):!a||u.length===0?(0,G.jsx)(DS,{available:a?.available??!1}):(0,G.jsx)(oS,{files:u,truncated:a.truncated})})]})]})}function CS({jobId:e,job:t,live:n,previews:r}){return(0,G.jsxs)(`section`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Pull requests`}),(0,G.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:[r.length,` pull request`,r.length===1?``:`s`,` — expand to review each branch's changes (including stacked PRs).`]})]}),(0,G.jsx)(`div`,{className:`space-y-3`,children:r.map((r,i)=>(0,G.jsx)(wS,{jobId:e,live:n,preview:r,status:mS(r,t)},r.sourceBranch??`wi-${i}`))})]})}function wS({jobId:e,live:t,preview:n,status:r}){let[i,a]=(0,x.useState)(!1),{diff:o,loading:s,error:c,refresh:l,refreshing:u}=yS(e,{base:n.base,head:n.sourceBranch,live:t,enabled:i}),d=(0,x.useMemo)(()=>tS(o?.patch??``),[o?.patch]);return(0,G.jsxs)(lg,{className:`border-line`,children:[(0,G.jsx)(ug,{className:`gap-2 pb-3`,children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex w-full items-start gap-2 text-left`,children:[i?(0,G.jsx)(lr,{className:`mt-1 size-4 shrink-0 text-fg-subtle`}):(0,G.jsx)(ur,{className:`mt-1 size-4 shrink-0 text-fg-subtle`}),(0,G.jsx)(Hr,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(dg,{className:`truncate text-sm`,children:n.title||n.workItem||`Pull request`}),(0,G.jsx)(TS,{status:r})]}),(0,G.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-2 text-xs`,children:[n.workItem?(0,G.jsx)(vg,{variant:`neutral`,children:n.workItem}):null,n.sourceBranch?(0,G.jsxs)(vg,{variant:`neutral`,className:`font-mono normal-case tracking-normal`,children:[n.sourceBranch,n.base?(0,G.jsxs)(`span`,{className:`text-fg-subtle`,children:[` → `,n.base]}):null]}):null,r.prUrl?(0,G.jsxs)(`a`,{href:r.prUrl,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`inline-flex items-center gap-1 text-accent-300 hover:text-accent-200`,children:[`View PR`,(0,G.jsx)(Er,{className:`size-3`})]}):null,i?(0,G.jsx)(ES,{diff:o,compact:!0}):null]})]})]})}),i?(0,G.jsxs)(pg,{className:`space-y-4 border-t border-line pt-4`,children:[n.description?(0,G.jsx)(`div`,{className:`prose-coro space-y-2 text-sm leading-6 text-fg`,dangerouslySetInnerHTML:{__html:Jb(n.description)}}):null,r.label===`Merged`&&(!o||d.length===0)?(0,G.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:`This work item was merged. Expand showed no local diff — open the PR on the SCM for the final changes.`}):null,(0,G.jsx)(`div`,{className:`flex justify-end`,children:(0,G.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:l,disabled:u,children:[(0,G.jsx)(hi,{className:W(u&&`animate-spin`)}),`Refresh`]})}),s&&!o?(0,G.jsx)(`div`,{className:`animate-pulse text-sm text-fg-subtle`,children:`Loading changes…`}):c?(0,G.jsx)(gg,{title:`Could not load changes`,message:c}):!o||d.length===0?r.label===`Merged`?null:(0,G.jsx)(DS,{available:o?.available??!1}):(0,G.jsx)(oS,{files:d,truncated:o.truncated})]}):null]})}function TS({status:e}){return(0,G.jsx)(vg,{variant:e.variant,children:e.label})}function ES({diff:e,compact:t}){return!e||e.files.length===0?t?null:(0,G.jsx)(G.Fragment,{children:`Code the agent has written in the cloned repo, before any PR is opened.`}):(0,G.jsxs)(`span`,{className:W(t&&`text-fg-subtle`),children:[(0,G.jsx)(`span`,{className:`font-mono`,children:e.stats.files}),` file`,e.stats.files===1?``:`s`,` changed`,e.stats.insertions>0?(0,G.jsxs)(`span`,{className:`ml-2 text-success-400`,children:[`+`,e.stats.insertions]}):null,e.stats.deletions>0?(0,G.jsxs)(`span`,{className:`ml-2 text-danger-400`,children:[`−`,e.stats.deletions]}):null,(0,G.jsxs)(`span`,{className:`ml-2 text-fg-subtle`,children:[`vs `,e.base]})]})}function DS({available:e}){return(0,G.jsx)(`div`,{className:`rounded-xl border border-dashed border-line bg-canvas/30 px-4 py-8 text-center text-sm text-fg-subtle`,children:e?`No changes yet. They will appear here as the agent edits files.`:`No repository checkout yet. Changes appear once the agent clones the repo and starts coding.`})}var OS=x.forwardRef(function({className:e,children:t,...n},r){return(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`select`,{ref:r,className:W(`flex h-11 w-full appearance-none rounded-xl border border-line-strong bg-overlay px-3.5 py-2.5 pr-10 text-sm text-fg shadow-[inset_0_1px_0_rgba(255,255,255,0.03)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-400/60 disabled:cursor-not-allowed disabled:opacity-50`,e),...n,children:t}),(0,G.jsx)(lr,{"aria-hidden":!0,className:`pointer-events-none absolute right-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`})]})});function kS({job:e,workflowPhases:t,refreshing:n,onRefresh:r,cancelling:i,cancelError:a,onCancel:o,pausing:s,pauseError:c,onPause:l,resuming:u,resumeError:d,resumePhase:f,clearSession:p,onResumePhaseChange:m,onClearSessionChange:h,onResume:g,interactiveOverride:_,onInteractiveChange:v}){let y=Po(e.status),b=Fo(e.status),S=Lo(e.status,e.awaitingEvent),C=_??e.interactive,[w,T]=(0,x.useState)(!1),[E,D]=(0,x.useState)(null);(0,x.useEffect)(()=>{_===void 0&&D(null)},[_]);async function O(t){T(!0),D(null),v(t);try{await q(`/jobs/${e.id}/interactive`,J({interactive:t},{method:`PATCH`}))}catch(e){D(e instanceof Error?e.message:`Failed to update interactive mode`),v(!t)}finally{T(!1)}}return(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:W(`flex flex-wrap items-center gap-2 rounded-2xl border border-line bg-overlay/40 px-3 py-2`,`sm:gap-3 sm:px-4`),children:[(0,G.jsx)(AS,{label:`Controls`}),(0,G.jsxs)(Y,{variant:`secondary`,size:`sm`,onClick:()=>void r(),disabled:n||i,children:[n?(0,G.jsx)($r,{className:`animate-spin`}):(0,G.jsx)(mi,{}),`Refresh`]}),(0,G.jsxs)(Y,{variant:`secondary`,size:`sm`,onClick:()=>void o(),disabled:!b||i||u,children:[i?(0,G.jsx)($r,{className:`animate-spin`}):(0,G.jsx)(ir,{}),i?`Cancelling…`:`Cancel`]}),(0,G.jsxs)(Y,{variant:`secondary`,size:`sm`,onClick:()=>void l(),disabled:!S||s||i||u,title:S?`Park the run at the next safe boundary so you can think and steer`:void 0,children:[s?(0,G.jsx)($r,{className:`animate-spin`}):(0,G.jsx)(oi,{}),s?`Pausing…`:`Pause`]}),(0,G.jsx)(MS,{job:e,workflowPhases:t,canResume:y,resuming:u,resumePhase:f,clearSession:p,onResumePhaseChange:m,onClearSessionChange:h,onResume:g}),(0,G.jsx)(jS,{}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,G.jsx)(jx,{checked:C,onCheckedChange:O,disabled:w,ariaLabel:`Toggle interactive mode`}),(0,G.jsxs)(`div`,{className:`flex flex-col leading-tight`,children:[(0,G.jsx)(`span`,{className:`text-[12px] font-medium text-fg`,children:C?`Interactive`:`Autonomous`}),(0,G.jsx)(`span`,{className:`text-[11px] text-fg-subtle`,children:C?`Will park at checkpoints`:`Will run end-to-end`})]})]})]}),a||c||d||E?(0,G.jsxs)(`div`,{className:`space-y-2`,children:[a?(0,G.jsx)(gg,{title:`Cancel failed`,message:a}):null,c?(0,G.jsx)(gg,{title:`Pause failed`,message:c}):null,d?(0,G.jsx)(gg,{title:`Resume failed`,message:d}):null,E?(0,G.jsx)(gg,{title:`Interactive toggle failed`,message:E}):null]}):null]})}function AS({label:e}){return(0,G.jsx)(`span`,{className:`hidden text-[11px] font-medium uppercase tracking-[0.16em] text-fg-subtle sm:inline`,children:e})}function jS(){return(0,G.jsx)(`span`,{className:`hidden h-6 w-px bg-line sm:block`,"aria-hidden":!0})}function MS({job:e,workflowPhases:t,canResume:n,resuming:r,resumePhase:i,clearSession:a,onResumePhaseChange:o,onClearSessionChange:s,onResume:c}){let[l,u]=(0,x.useState)(!1);return n?(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsxs)(Y,{size:`sm`,onClick:()=>void c(i||void 0,a),disabled:r,children:[r?(0,G.jsx)($r,{className:`animate-spin`}):(0,G.jsx)(ui,{}),r?`Resuming…`:`Resume`]}),(0,G.jsxs)(Jh,{open:l,onOpenChange:u,children:[(0,G.jsx)(Yh,{asChild:!0,children:(0,G.jsx)(Y,{size:`sm`,variant:`secondary`,"aria-label":`Resume options`,className:`px-2`,children:(0,G.jsx)(lr,{})})}),(0,G.jsx)(Zh,{align:`start`,className:`min-w-72 p-3`,children:(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1.5 block text-[11px] uppercase tracking-[0.14em] text-fg-subtle`,children:`Resume from phase`}),(0,G.jsxs)(OS,{value:i,onChange:e=>o(e.target.value),children:[(0,G.jsxs)(`option`,{value:``,children:[`Current phase (`,e.phase,`)`]}),t.map(t=>(0,G.jsxs)(`option`,{value:t.name,children:[t.name,t.name===e.phase?` (current)`:``]},t.name))]})]}),(0,G.jsxs)(`label`,{className:`flex items-start gap-2 text-[13px] text-fg-muted`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>s(e.target.checked),className:`mt-0.5`}),(0,G.jsxs)(`span`,{children:[`Start with a fresh session.`,(0,G.jsx)(`span`,{className:`block text-[11px] text-fg-subtle`,children:`Use when the current conversation history is no longer useful.`})]})]}),(0,G.jsx)(`div`,{className:`flex justify-end pt-1`,children:(0,G.jsx)(Y,{size:`sm`,onClick:()=>{u(!1),c(i||void 0,a)},disabled:r,children:r?`Resuming…`:`Resume with options`})})]})})]})]}):(0,G.jsx)(`span`,{className:`rounded-md border border-dashed border-line px-2.5 py-1 text-[12px] text-fg-subtle`,title:`This ${zy.singularLower} can't be resumed from its current state.`,children:`Not resumable`})}var NS={text:{textClass:`text-fg`,iconClass:`text-fg-subtle`,icon:ar},tool_use:{textClass:`text-fg`,iconClass:`text-accent-300`,icon:rr,label:`Tool`},tool_summary:{textClass:`text-fg-muted`,iconClass:`text-fg-subtle`,icon:Yr,label:`Summary`,dimmed:!0},thinking:{textClass:`text-fg-muted`,iconClass:`text-fg-subtle`,icon:yi,label:`Thinking`,dimmed:!0},tool_progress:{textClass:`text-fg-muted`,iconClass:`text-warning-400`,icon:$r,label:`Progress`,dimmed:!0},error:{textClass:`text-danger-400`,iconClass:`text-danger-400`,icon:Mi,label:`Error`},guardrail:{textClass:`text-warning-400`,iconClass:`text-warning-400`,icon:wi,label:`Guardrail`},warning:{textClass:`text-warning-400`,iconClass:`text-warning-400`,icon:Mi,label:`Warning`},result:{textClass:`text-success-400`,iconClass:`text-success-400`,icon:fr,label:`Result`},phase:{textClass:`text-accent-300`,iconClass:`text-accent-300`,icon:Vr,label:`Phase`},insight:{textClass:`text-accent-300`,iconClass:`text-accent-300`,icon:ar,label:`Insight`},session_reset:{textClass:`text-warning-400`,iconClass:`text-warning-400`,icon:mi,label:`Reset`},webhook:{textClass:`text-warning-400`,iconClass:`text-warning-400`,icon:Ni,label:`Webhook`},human:{textClass:`text-fg`,iconClass:`text-accent-300`,icon:ti,label:`Developer`},system:{textClass:`text-fg-subtle`,iconClass:`text-fg-subtle`,icon:xi,label:`System`,dimmed:!0}};function PS(e){let t=e.content;return e.lineType===`tool_progress`?t.replace(/^⏳\s*/,``):e.lineType===`system`&&t.startsWith(`[event:`)?t.replace(/^\[event:([^\]]+)\]\s*/,`$1: `):e.lineType===`tool_use`||e.lineType===`text`||e.lineType===`phase`?t:t.replace(/^\[[^\]]+\]\s*/,``)}function FS({lineType:e,className:t=``}){let n=NS[e],r=n.icon;return(0,G.jsx)(r,{className:W(`mt-0.5 size-3.5 shrink-0`,n.iconClass,n.dimmed&&`opacity-60`,e===`tool_progress`&&`animate-spin`,t),"aria-hidden":`true`})}function IS(e){if(!e)return``;try{return new Date(e).toLocaleTimeString(`en-US`,{hour12:!1,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}catch{return``}}function LS({line:e}){let t=NS[e.lineType],n=PS(e);if(e.lineType===`phase`)return(0,G.jsxs)(`div`,{className:`my-2 flex items-center gap-3 py-1.5`,children:[(0,G.jsx)(`div`,{className:`h-px flex-1 bg-accent-500/20`}),(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-accent-500/25 bg-accent-500/10 px-3 py-0.5 text-[11px] font-semibold uppercase tracking-[0.16em] text-accent-300`,children:[(0,G.jsx)(FS,{lineType:e.lineType,className:`mt-0 size-3`}),n]}),(0,G.jsx)(`div`,{className:`h-px flex-1 bg-accent-500/20`})]});if(e.lineType===`error`||e.lineType===`warning`||e.lineType===`guardrail`)return(0,G.jsxs)(`div`,{className:W(`my-1 flex items-start gap-3 rounded-xl px-4 py-2.5`,e.lineType===`error`?`border border-danger-500/25 bg-danger-500/8`:`border border-warning-500/25 bg-warning-500/8`),children:[(0,G.jsx)(FS,{lineType:e.lineType}),(0,G.jsx)(`span`,{className:t.textClass,children:n})]});if(e.lineType===`result`)return(0,G.jsxs)(`div`,{className:`my-1 flex items-start gap-3 rounded-xl border border-success-500/25 bg-success-500/8 px-4 py-2.5`,children:[(0,G.jsx)(FS,{lineType:e.lineType}),(0,G.jsx)(`span`,{className:t.textClass,children:n})]});if(e.lineType===`human`)return(0,G.jsxs)(`div`,{className:`my-1 flex items-start gap-3 rounded-xl border border-accent-500/25 bg-accent-500/8 px-4 py-2.5`,children:[(0,G.jsx)(FS,{lineType:e.lineType}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mr-2 text-[11px] font-semibold uppercase tracking-[0.14em] text-accent-300`,children:`Developer`}),(0,G.jsx)(`span`,{className:`text-fg`,children:n})]})]});if(e.lineType===`tool_use`){let e=n.match(/^→ (\S+)(.*)/);if(e)return(0,G.jsxs)(`span`,{className:t.dimmed?`opacity-60`:``,children:[(0,G.jsx)(`span`,{className:`text-fg-subtle`,children:`→ `}),(0,G.jsx)(`span`,{className:`font-medium text-fg`,children:e[1]}),(0,G.jsx)(`span`,{className:`text-fg-subtle`,children:e[2]})]})}return(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(FS,{lineType:e.lineType}),(0,G.jsxs)(`span`,{className:W(t.textClass,t.dimmed&&`opacity-70`),children:[t.label?(0,G.jsx)(`span`,{className:`mr-2 text-[11px] font-semibold uppercase tracking-[0.14em] text-fg-subtle`,children:t.label}):null,n]})]})}function RS(e,t=`auto`){e&&e.scrollTo({top:e.scrollHeight,behavior:t})}function zS(e,t=64){let{scrollTop:n,scrollHeight:r,clientHeight:i}=e;return r-n-i<=t}var BS=[{value:`all`,label:`All`},{value:`main`,label:`Agent`},{value:`tools`,label:`Tools`}];function VS({lines:e,className:t=``}){let n=(0,x.useRef)(null),[r,i]=(0,x.useState)(!0),a=(0,x.useRef)(!0),[o,s]=(0,x.useState)(`all`),c=(0,x.useRef)(!1);(0,x.useEffect)(()=>{a.current=r},[r]);let l=()=>{let e=n.current;if(!e)return;if(c.current){c.current=!1;return}let t=zS(e);a.current=t,i(t)};(0,x.useEffect)(()=>{if(!r)return;let e=requestAnimationFrame(()=>{!a.current||!n.current||(c.current=!0,RS(n.current,`auto`))});return()=>{cancelAnimationFrame(e)}},[e,r,o]),(0,x.useEffect)(()=>{let e=n.current;if(!e||!r)return;let t=new ResizeObserver(()=>{!n.current||!a.current||(c.current=!0,RS(n.current,`auto`))});return t.observe(e),()=>{t.disconnect()}},[r]);let u=[`tool_use`,`tool_summary`,`tool_progress`,`thinking`,`system`],d=[`text`,`phase`,`error`,`guardrail`,`warning`,`result`,`insight`,`session_reset`,`webhook`,`human`],f=e.filter(e=>o===`all`?!0:o===`main`?d.includes(e.lineType):o===`tools`?u.includes(e.lineType):!0);return(0,G.jsxs)(`div`,{className:W(`flex flex-col overflow-hidden rounded-2xl border border-line bg-canvas/60`,t),children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-line px-3 py-2.5`,children:[(0,G.jsx)(ab,{options:BS,value:o,onChange:s,size:`sm`,ariaLabel:`Filter log lines`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsxs)(`span`,{className:`text-[11px] uppercase tracking-[0.14em] text-fg-subtle`,children:[f.length,` / `,e.length,` lines`]}),r?null:(0,G.jsxs)(Y,{type:`button`,size:`sm`,variant:`secondary`,onClick:()=>{a.current=!0,i(!0),n.current&&(c.current=!0,RS(n.current,`smooth`))},children:[(0,G.jsx)(er,{}),`Follow`]})]})]}),(0,G.jsx)(`div`,{ref:n,onScroll:l,className:`min-h-[280px] max-h-[calc(100vh-320px)] flex-1 overflow-y-auto p-4 font-mono text-[12.5px] leading-relaxed`,children:f.length===0?(0,G.jsx)(`div`,{className:`flex h-32 items-center justify-center text-sm text-fg-subtle`,children:`Waiting for log output…`}):f.map((e,t)=>(0,G.jsxs)(`div`,{className:W(`flex gap-3 animate-fade-in`,e.lineType===`phase`?``:`rounded-lg px-2 py-1 hover:bg-overlay/40`),children:[e.lineType===`phase`?null:(0,G.jsx)(`span`,{className:`shrink-0 select-none pt-0.5 text-[11px] tabular-nums text-fg-subtle/70`,children:IS(e.timestamp)}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1 break-words whitespace-pre-wrap`,children:(0,G.jsx)(LS,{line:e})})]},t))})]})}function HS(e,t){let n=e.findIndex(e=>e.name===t);if(n!==-1)return n;let r=t.toLowerCase();return e.findIndex(e=>e.name.toLowerCase()===r)}function US(e,t,n){let r=HS(t,n.phase),i=HS(t,e),a=(n.phaseUsage??[]).some(t=>t.phase===e);return i===-1?`pending`:i===r?n.status===`complete`?`complete`:Mo(n.status)?`awaiting-input`:`in-progress`:r!==-1&&i<r||a||n.status===`complete`?`complete`:`pending`}function WS(e,t){let n=`relative flex-1 min-w-[150px] rounded-xl border px-3.5 py-2.5 text-left transition-colors cursor-pointer`,r=t?`ring-2 ring-accent-400/60 ring-offset-2 ring-offset-canvas`:``;switch(e){case`complete`:return W(n,r,`border-success-500/25 bg-success-500/8 hover:border-success-500/40`);case`in-progress`:return W(n,r,`border-transparent bg-accent-500/10 hover:bg-accent-500/15 animate-border-travel`);case`awaiting-input`:return W(n,r,`border-warning-500/30 bg-warning-500/10 hover:border-warning-500/45 animate-pulse-slow`);default:return W(n,r,`border-line bg-overlay/40 hover:border-line-strong`)}}function GS({state:e}){switch(e){case`complete`:return(0,G.jsx)(cr,{className:`size-3.5 text-success-400`,strokeWidth:2.5});case`in-progress`:return(0,G.jsx)(`span`,{className:`size-1.5 rounded-full bg-accent-400 animate-pulse-dot`,"aria-hidden":!0});case`awaiting-input`:return(0,G.jsx)(Gr,{className:`size-3.5 text-warning-400`});default:return(0,G.jsx)(`span`,{className:`size-1.5 rounded-full bg-fg-subtle/60`,"aria-hidden":!0})}}function KS(e){switch(e){case`complete`:return`Complete`;case`in-progress`:return`Running`;case`awaiting-input`:return`Awaiting input`;case`pending`:return`Pending`}}function qS({job:e,phases:t,selectedPhase:n,onSelectPhase:r}){if(t.length===0)return(0,G.jsx)(`div`,{className:`px-2 py-3 text-sm italic text-fg-subtle`,children:`No workflow phases defined for this job.`});let i=new Map;for(let t of e.artifacts??[]){let e=i.get(t.phase)??[];e.push(t),i.set(t.phase,e)}let a=new Map;for(let t of e.phaseUsage??[])a.set(t.phase,(a.get(t.phase)??0)+1);return(0,G.jsx)(`div`,{className:`w-full overflow-x-auto py-1.5`,children:(0,G.jsx)(`div`,{className:`flex min-w-max items-stretch gap-2`,children:t.map((o,s)=>{let c=US(o.name,t,e),l=n===o.name,u=i.get(o.name)??[],d=a.get(o.name)??0;return(0,G.jsxs)(`div`,{className:`flex items-stretch`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>r(o.name),className:WS(c,l),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`flex size-4 items-center justify-center`,children:(0,G.jsx)(GS,{state:c})}),(0,G.jsx)(`span`,{className:`truncate text-[13px] font-medium text-fg`,children:o.name}),o.interactiveCheckpoint&&e.interactive?(0,G.jsx)(`span`,{title:`Interactive checkpoint — the job will park here for developer approval`,className:`inline-flex items-center rounded-full border border-warning-500/25 bg-warning-500/10 px-1 py-0.5 text-warning-400`,children:(0,G.jsx)(Ur,{className:`size-3`})}):null]}),(0,G.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.16em] text-fg-subtle`,children:KS(c)}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[d>1?(0,G.jsxs)(`span`,{title:`Phase ran ${d} times (loop-back)`,className:`inline-flex items-center gap-0.5 rounded-full border border-accent-500/25 bg-accent-500/10 px-1.5 py-0.5 text-[10px] text-accent-300`,children:[(0,G.jsx)(_i,{className:`size-2.5`}),d,`×`]}):null,u.length>0?(0,G.jsx)(`span`,{title:`${u.length} artifact${u.length===1?``:`s`}`,className:`rounded-full border border-line bg-overlay/60 px-1.5 py-0.5 text-[10px] text-fg-muted`,children:u.length}):null]})]})]}),s<t.length-1?(0,G.jsx)(`div`,{className:`flex shrink-0 items-center px-1 text-fg-subtle/60`,"aria-hidden":!0,children:(0,G.jsx)(ur,{className:`size-4`})}):null]},o.name)})})})}function JS(e){let t=[];for(let n of e.workItems??[]){let r=(e.phaseUsage??[]).filter(e=>e.workItem===n.name),i=[];for(let e of r)i.includes(e.phase)||i.push(e.phase);t.push({item:n,executions:r,distinctPhases:i,hasStarted:r.length>0})}return t}function YS(e){return e.status===`complete`?`Complete`:e.status===`in-progress`?`In progress`:e.status===`escalated`?`Escalated`:`Pending`}function XS(e){switch(e.status){case`complete`:return`bg-success-400`;case`in-progress`:return`bg-accent-400 animate-pulse-dot`;case`escalated`:return`bg-danger-400`;default:return`bg-fg-subtle/60`}}function ZS({phaseName:e,count:t,state:n,onClick:r}){return(0,G.jsxs)(`button`,{type:`button`,onClick:r,className:W(`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors cursor-pointer`,n===`in-progress`?`border-accent-500/35 bg-accent-500/10 text-fg hover:border-accent-500/55`:n===`complete`?`border-success-500/25 bg-success-500/8 text-fg hover:border-success-500/40`:`border-line bg-overlay/40 text-fg-muted hover:border-line-strong`),children:[n===`complete`?(0,G.jsx)(cr,{className:`size-3 text-success-400`,strokeWidth:2.5}):n===`in-progress`?(0,G.jsx)(`span`,{className:`size-1.5 rounded-full bg-accent-400 animate-pulse-dot`,"aria-hidden":!0}):(0,G.jsx)(`span`,{className:`size-1.5 rounded-full bg-fg-subtle/60`,"aria-hidden":!0}),(0,G.jsx)(`span`,{children:e}),t>1?(0,G.jsxs)(`span`,{title:`Ran ${t} times for this work item`,className:`inline-flex items-center gap-0.5 rounded-full bg-overlay/80 px-1 text-[10px] text-fg-muted`,children:[(0,G.jsx)(_i,{className:`size-2.5`}),t]}):null]})}function QS({job:e,phases:t,onSelectPhase:n}){if(!e.workItems||e.workItems.length===0)return null;let r=JS(e),i=new Set(t.map(e=>e.name)),a=r.find(e=>e.hasStarted)?.item.name??null;return(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`text-[11px] uppercase tracking-[0.14em] text-fg-subtle`,children:[`Work items `,(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[`(`,e.workItems.length,`)`]})]}),e.currentWorkItem?(0,G.jsxs)(`div`,{className:`text-[11px] text-fg-subtle`,children:[`current: `,(0,G.jsx)(`span`,{className:`text-fg`,children:e.currentWorkItem})]}):null]}),(0,G.jsx)(`div`,{className:`space-y-1.5`,children:r.map(t=>{let{item:r,executions:o,distinctPhases:s,hasStarted:c}=t,l=e.currentWorkItem===r.name,u=r.status===`complete`,d=!c&&u&&a!==null&&a!==r.name,f=s.map(e=>({name:e,count:o.filter(t=>t.phase===e).length}));return(0,G.jsxs)(`div`,{className:W(`flex flex-wrap items-center gap-3 rounded-xl border px-3 py-2`,l?`border-accent-500/30 bg-accent-500/8`:c||d?`border-line bg-overlay/40`:`border-line bg-overlay/20 opacity-70`),children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:W(`size-2 rounded-full shrink-0`,XS(r))}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`truncate text-[13px] font-medium text-fg`,children:r.name}),(0,G.jsxs)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-fg-subtle`,children:[YS(r),r.loopCount>0?(0,G.jsxs)(`span`,{className:`ml-2 normal-case tracking-normal text-fg-muted`,children:[`· `,r.loopCount,` retr`,r.loopCount===1?`y`:`ies`]}):null]})]})]}),c?(0,G.jsxs)(`div`,{className:`flex flex-1 flex-wrap items-center gap-1.5`,children:[f.map(({name:t,count:a})=>{let o=l&&e.phase===t&&No(e.status),s=i.has(t),c=o?`in-progress`:`complete`;return(0,G.jsx)(ZS,{phaseName:s?t:`${t} (ad-hoc)`,count:a,state:c,onClick:()=>n(t)},`${r.name}:${t}`)}),l&&No(e.status)&&e.phase&&!s.includes(e.phase)?(0,G.jsx)(ZS,{phaseName:e.phase,count:1,state:`in-progress`,onClick:()=>n(e.phase)}):null]}):d?(0,G.jsx)(`div`,{className:`flex flex-1 flex-wrap items-center gap-1.5`,children:(0,G.jsxs)(`span`,{title:`This work item was delivered together with "${a}" in a single execution cycle (one shared PR / verification run). The actual phase executions are attributed to that item above.`,className:`inline-flex items-center gap-1.5 rounded-full border border-success-500/20 bg-success-500/8 px-2.5 py-1 text-[11px] font-medium text-fg-muted`,children:[(0,G.jsx)(cr,{className:`size-3 text-success-400/80`,strokeWidth:2.5}),`delivered with `,(0,G.jsx)(`span`,{className:`text-fg`,children:a})]})}):(0,G.jsx)(`div`,{className:`text-[11px] italic text-fg-subtle`,children:l?`starting…`:`waiting`}),r.status===`escalated`?(0,G.jsxs)(`span`,{title:`This work item escalated and is waiting on a human`,className:`inline-flex items-center gap-1 rounded-full border border-danger-500/30 bg-danger-500/10 px-2 py-0.5 text-[10px] text-danger-400`,children:[(0,G.jsx)(Mi,{className:`size-3`}),`escalated`]}):null]},r.name)})})]})}function $S(e,t,n){if(!t||!n)return null;let r=e[t];return r?r.find(e=>e.id===n)??null:null}function eC(e){let t=nC(e);return t?`${t.symbol} ${t.label}`:null}function tC(e){return nC(e)?.symbol??``}function nC(e){let t=e?.pricing;if(!t)return null;let n=t.inputPerMTokens,r=t.outputPerMTokens;if(n==null&&r==null)return null;let i=n!=null&&r!=null?(n+r)/2:n??r??0,a,o;return i<=1?(a=1,o=`cheapest`):i<=5?(a=2,o=`low`):i<=20?(a=3,o=`mid`):i<=50?(a=4,o=`high`):(a=5,o=`frontier`),{symbol:`$`.repeat(a),label:o}}function rC(e,t){let n=e?.pricing;if(!n||!t)return null;let r=e=>(e??0)/1e6;return(t.inputTokens??0)*r(n.inputPerMTokens)+(t.outputTokens??0)*r(n.outputPerMTokens)+(t.cacheReadInputTokens??0)*r(n.cacheReadPerMTokens)+(t.cacheCreationInputTokens??0)*r(n.cacheCreationPerMTokens??n.inputPerMTokens)}function iC(e){return Number.isFinite(e)?e===0?`0.00`:Math.abs(e)<.01?e.toFixed(4):Math.abs(e)<1?e.toFixed(3):e.toFixed(2):`—`}var aC=`::`;function oC(e,t){return!e||!t?``:`${e}${aC}${t}`}function sC(e){let t=e.indexOf(aC);return t<0?{provider:``,model:``}:{provider:e.slice(0,t),model:e.slice(t+2)}}function cC({value:e,onChange:t,providers:n,modelsByProvider:r,loadModels:i,className:a,disabled:o=!1,hideLabel:s=!1,label:c=`Model`}){(0,x.useEffect)(()=>{for(let e of n)i(e.id)},[n.map(e=>e.id).join(`|`)]);let l=(0,x.useMemo)(()=>n.some(e=>r[e.id]===null||r[e.id]===void 0),[n,r]),u=(0,x.useMemo)(()=>n.reduce((e,t)=>e+(r[t.id]?.length??0),0),[n,r]),d=oC(e.provider,e.model),f=eC($S(r,e.provider,e.model)),p=!!e.provider&&!!e.model&&(r[e.provider]??[]).some(t=>t.id===e.model),m=!!e.model&&!p,h=n.length===0?`(no enabled providers)`:l&&u===0?`Loading…`:u===0?`(no models published)`:`(select a model)`;return(0,G.jsxs)(Sv,{label:s?``:c,className:a,children:[(0,G.jsxs)(`select`,{value:d,disabled:o||n.length===0,onChange:e=>t(sC(e.target.value)),className:`w-full rounded-xl border border-line bg-overlay px-3 py-2 text-sm text-fg disabled:opacity-60`,"aria-label":s?c:void 0,children:[(0,G.jsx)(`option`,{value:``,children:h}),m?(0,G.jsxs)(`option`,{value:d,children:[e.model,` · `,e.provider,` (saved)`]}):null,n.map(e=>{let t=r[e.id];return!t||t.length===0?null:(0,G.jsx)(`optgroup`,{label:e.displayName,children:t.map(t=>{let n=tC(t);return(0,G.jsx)(`option`,{value:oC(e.id,t.id),children:n?`${t.displayName} — ${n}`:t.displayName},`${e.id}::${t.id}`)})},e.id)})]}),f?(0,G.jsx)(`div`,{className:`mt-1 text-[11px] text-fg-subtle`,title:`Static pricing hint published by the provider plugin. Runtime accounting always uses actual reported cost.`,children:f}):null]})}function lC(){let[e,t]=(0,x.useState)([]),[n,r]=(0,x.useState)(!0),[i,a]=(0,x.useState)(null);return(0,x.useEffect)(()=>{let e=!1;return(async()=>{try{let n=await q(`/plugins`);if(e)return;t(n.plugins.filter(e=>e.manifest.kind===`executor`&&e.installed!==!1).map(e=>({id:e.manifest.id,displayName:e.manifest.displayName})).sort((e,t)=>e.displayName.localeCompare(t.displayName)))}catch(t){if(e)return;a(t instanceof K?t.message:String(t))}finally{e||r(!1)}})(),()=>{e=!0}},[]),{providers:e,loading:n,error:i}}function uC(){let[e,t]=(0,x.useState)({});return{modelsByProvider:e,loadModels:(0,x.useCallback)(async n=>{if(n&&e[n]===void 0){t(e=>({...e,[n]:null}));try{let e=await q(`/plugins/${encodeURIComponent(n)}/models`);t(t=>({...t,[n]:e.models??[]}))}catch(e){if(!(e instanceof K))throw e;t(e=>({...e,[n]:[]}))}}},[e])}}function dC({job:e,phase:t,onMutated:n}){let r=t===e.phase,i=e.status===`running`,a=e.phaseModelOverrides?.[t],{providers:o,loading:s}=lC(),{modelsByProvider:c,loadModels:l}=uC(),[u,d]=(0,x.useState)(()=>({provider:a?.provider??``,model:a?.model??``}));(0,x.useEffect)(()=>{d({provider:a?.provider??``,model:a?.model??``})},[t,a?.provider,a?.model]);let[f,p]=(0,x.useState)(null),[m,h]=(0,x.useState)(null),[g,_]=(0,x.useState)(!1),v=(0,x.useMemo)(()=>{let n=(e.phaseUsage??[]).filter(e=>e.phase===t);return n.length>0?n[n.length-1].model:null},[e.phaseUsage,t]),y=(0,x.useMemo)(()=>{let n=(e.phaseUsage??[]).filter(e=>e.phase===t);return n.length>0?n[n.length-1]:null},[e.phaseUsage,t]),b=rC($S(c,u.provider,u.model),y??void 0),S=y?.costUsd??null,C=b!=null&&S!=null?b-S:null,w=(0,x.useMemo)(()=>(u.provider||``)!==(a?.provider??``)||(u.model||``)!==(a?.model??``),[u,a]),T=async r=>{p(r),h(null);try{if(r===`apply`){if(!u.model)throw Error(`Pick a model first.`);await q(`/jobs/${encodeURIComponent(e.id)}/phase-overrides`,J({phase:t,model:u.model,provider:u.provider||void 0},{method:`PATCH`}))}else if(r===`clear`)await q(`/jobs/${encodeURIComponent(e.id)}/phase-overrides`,J({phase:t,clear:!0},{method:`PATCH`})),d({provider:``,model:``});else if(r===`rerun`){let n={};u.model&&(n.model=u.model),u.provider&&(n.provider=u.provider),await q(`/jobs/${encodeURIComponent(e.id)}/phases/${encodeURIComponent(t)}/rerun`,J(n,{method:`POST`}))}r!==`rerun`&&_(!1),n()}catch(e){h(e instanceof K||e instanceof Error?e.message:String(e))}finally{p(null)}},E=a?.model??v??null,D=a?`override`:v?`last-used`:`default`;return(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-[12px]`,children:[(0,G.jsx)(`span`,{className:`text-[11px] uppercase tracking-[0.14em] text-fg-subtle`,children:`Model`}),(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:E??(0,G.jsx)(`span`,{className:`text-fg-subtle`,children:`(workflow default)`})}),D===`override`?(0,G.jsx)(`span`,{className:`rounded-full border border-info-400/40 bg-info-500/10 px-1.5 py-0 text-[10px] uppercase tracking-wide text-info-200`,children:`override`}):D===`last-used`?(0,G.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-fg-subtle`,children:`last run`}):null,g?null:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>_(!0),className:`ml-auto inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] text-fg-muted transition-colors hover:bg-overlay hover:text-fg`,"aria-label":`Change model for this phase`,title:`Change model for this phase`,children:[(0,G.jsx)(li,{className:`size-3`}),`Change`]})]}),g?(0,G.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-line bg-canvas/40 p-3`,children:[s?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-[12px] text-fg-subtle`,children:[(0,G.jsx)($r,{className:`size-3 animate-spin`}),` Loading providers…`]}):o.length===0?(0,G.jsx)(`div`,{className:`text-[12px] text-fg-subtle`,children:`No LLM provider plugins are installed. Configure one in Settings → LLM Providers before overriding a phase model.`}):(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`min-w-[12rem] max-w-xs flex-1`,children:(0,G.jsx)(cC,{value:u,onChange:d,providers:o,modelsByProvider:c,loadModels:l,disabled:f!==null,hideLabel:!0})}),(0,G.jsxs)(Y,{type:`button`,size:`sm`,variant:`primary`,disabled:!w||!u.model||f!==null,onClick:()=>void T(`apply`),children:[f===`apply`?(0,G.jsx)($r,{className:`size-3 animate-spin`}):null,`Apply`]}),(0,G.jsxs)(Y,{type:`button`,size:`sm`,variant:`ghost`,disabled:!a||f!==null,onClick:()=>void T(`clear`),title:a?`Remove the per-phase override and revert to workflow default`:`No override to clear`,children:[(0,G.jsx)(Pi,{className:`size-3`}),` Clear`]}),(0,G.jsxs)(Y,{type:`button`,size:`sm`,variant:`secondary`,disabled:f!==null||r&&i,onClick:()=>void T(`rerun`),title:r&&i?`Pause the job before re-running the live phase`:`Re-enter this phase, optionally with the chosen model`,children:[f===`rerun`?(0,G.jsx)($r,{className:`size-3 animate-spin`}):(0,G.jsx)(_i,{className:`size-3`}),`Re-run`]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{_(!1),h(null),d({provider:a?.provider??``,model:a?.model??``})},className:`text-[11px] text-fg-subtle hover:text-fg`,children:`Cancel`})]}),b!=null&&S!=null&&y?(0,G.jsxs)(`div`,{className:`text-[11px] text-fg-subtle`,children:[`For this phase's last run (`,y.inputTokens.toLocaleString(),` in /`,` `,y.outputTokens.toLocaleString(),` out tokens):`,` `,(0,G.jsxs)(`span`,{className:`text-fg`,children:[`$`,iC(S)]}),` →`,` `,(0,G.jsxs)(`span`,{className:`text-fg`,children:[`$`,iC(b)]}),C==null?null:(0,G.jsxs)(`span`,{className:C>0?`ml-1 text-warning-400`:C<0?`ml-1 text-success-400`:`ml-1 text-fg-subtle`,children:[`(`,C>=0?`+`:`−`,`$`,iC(Math.abs(C)),`)`]})]}):null,r&&i?(0,G.jsx)(`div`,{className:`rounded-lg border border-warning-400/30 bg-warning-500/5 px-2.5 py-1.5 text-[11px] leading-4 text-warning-100`,children:`This phase is running now. The override applies on the next selectModel call — the in-flight turn keeps its original model. Use “Re-run” to apply immediately.`}):null,m?(0,G.jsx)(`div`,{className:`rounded-lg border border-danger-400/40 bg-danger-500/5 px-2.5 py-1.5 text-[11px] text-danger-200`,children:m}):null]}):null]})}var fC=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Jo(`Primitive.${t}`),r=x.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,G.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),pC=`Separator`,mC=`horizontal`,hC=[`horizontal`,`vertical`],gC=x.forwardRef((e,t)=>{let{decorative:n,orientation:r=mC,...i}=e,a=_C(r)?r:mC,o=n?{role:`none`}:{"aria-orientation":a===`vertical`?a:void 0,role:`separator`};return(0,G.jsx)(fC.div,{"data-orientation":a,...o,...i,ref:t})});gC.displayName=pC;function _C(e){return hC.includes(e)}var vC=gC;function yC({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,G.jsx)(vC,{decorative:n,orientation:t,className:W(`shrink-0 bg-line`,t===`horizontal`?`h-px w-full`:`h-full w-px`,e),...r})}function bC(e){let[t,n]=(0,x.useState)(null),[r,i]=(0,x.useState)(!0),[a,o]=(0,x.useState)(null),s=(0,x.useCallback)(async()=>{if(e)try{n(await q(`/jobs/${e}`)),o(null)}catch(e){o(e instanceof Error?e.message:`Failed to fetch job`)}finally{i(!1)}},[e]);return(0,x.useEffect)(()=>{s()},[s]),{job:t,loading:r,error:a,refetch:s}}var xC=/^(\d{4}-\d{2}-\d{2}T[\d:.]+Z)\s+/;function SC(e){let t=e.replace(xC,``),n=t.toLowerCase();return t.startsWith(`→ `)?{content:t,lineType:`tool_use`}:t.startsWith(`[thinking]`)?{content:t,lineType:`thinking`}:t.startsWith(`[tool_summary]`)?{content:t,lineType:`tool_summary`}:t.startsWith(`⏳`)?{content:t,lineType:`tool_progress`}:t.startsWith(`[error]`)?{content:t,lineType:`error`}:t.startsWith(`[guardrail]`)?{content:t,lineType:`guardrail`}:t.startsWith(`[warning]`)?{content:t,lineType:`warning`}:t.startsWith(`[result]`)?{content:t,lineType:`result`}:t.startsWith(`[insight]`)?{content:t,lineType:`insight`}:t.startsWith(`[session-reset]`)?{content:t,lineType:`session_reset`}:t.startsWith(`[webhook]`)?{content:t,lineType:`webhook`}:t.startsWith(`[human]`)?{content:t,lineType:`human`}:t.startsWith(`[init]`)||t.startsWith(`[usage]`)||t.startsWith(`[phase-end]`)||t.startsWith(`[artifact]`)||t.startsWith(`[repo-cloned]`)||t.startsWith(`[campaign]`)||t.startsWith(`[control]`)||t.startsWith(`[sdk-stderr]`)||t.startsWith(`[event:`)||t.startsWith(`System prompt:`)?{content:t,lineType:`system`}:t.startsWith(`Phase advanced`)||t.startsWith(`Runner started`)||t.startsWith(`Job parked`)||t.startsWith(`All phases complete`)?{content:t,lineType:`phase`}:t.startsWith(`Runner crashed`)?{content:t,lineType:`error`}:n.includes(`here's what was accomplished`)||/\bphase (is )?complete\b/.test(n)?{content:t,lineType:`result`}:/\bphase started\b/.test(n)?{content:t,lineType:`phase`}:{content:t,lineType:`text`}}function CC(e){let t=e.match(xC);return t?t[1]:``}function wC(e,t=!0){let[n,r]=(0,x.useState)([]),[i,a]=(0,x.useState)(`connecting`),[o,s]=(0,x.useState)(Date.now()),c=(0,x.useRef)(null),l=(0,x.useRef)(!1),u=(0,x.useRef)(void 0),d=(0,x.useRef)(!0),f=(0,x.useCallback)(()=>{l.current=!0,c.current&&=(c.current.close(),null)},[]);return(0,x.useEffect)(()=>{if(!e)return;let n=u.current,i=d.current,o=n!==e,p=!i&&t;if(u.current=e,d.current=t,(o||p)&&r([]),!t){f(),a(`disconnected`);return}a(`connecting`),l.current=!1;let m=new EventSource(`/jobs/${e}/stream`);return c.current=m,m.onopen=()=>{a(`connected`),s(Date.now())},m.onmessage=e=>{s(Date.now());let t=e.data;if(!t||t.trim()===``)return;let n=CC(t),{content:i,lineType:a}=SC(t);r(e=>[...e,{timestamp:n,content:i,lineType:a}])},m.onerror=()=>{m.close(),c.current=null,l.current=!0,a(`disconnected`)},()=>{m.close(),c.current=null}},[f,e,t]),{lines:n,status:i,lastHeartbeat:o,disconnect:f}}function TC({tone:e,children:t}){return(0,G.jsx)(`span`,{className:W(`ml-1 inline-flex h-4 min-w-[16px] items-center justify-center rounded-full px-1 text-[10px] font-medium tabular-nums ring-1`,e===`warning`?`bg-warning-500/15 text-warning-300 ring-warning-500/30`:`bg-overlay text-fg-muted ring-line`),children:t})}function EC(e){if(!e)return[];if(e.workflowPhases&&e.workflowPhases.length>0)return e.workflowPhases;let t=new Set,n=[];for(let r of e.phaseUsage??[])t.has(r.phase)||(t.add(r.phase),n.push({name:r.phase,status:r.phase}));return t.has(e.phase)||n.push({name:e.phase,status:e.phase}),n}function DC({parentRunId:e}){return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[13px]`,children:[(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-line bg-overlay px-1.5 py-0.5 text-[10px] uppercase tracking-[0.14em] text-fg-subtle`,title:By.singular,children:[(0,G.jsx)(Cr,{className:`size-2.5`,"aria-hidden":!0}),By.singularLower]}),(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[`of`,` `,(0,G.jsx)(Dn,{to:My({id:e}),className:`inline-block max-w-[min(100%,28rem)] truncate align-bottom font-mono text-[12px] font-medium text-accent-300 underline-offset-2 hover:text-accent-400 hover:underline`,title:e,children:e})]})]})}function OC({job:e}){let t=Iy(e),n=Py(e),r=qy(e);return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(Dn,{to:Zy,className:`inline-flex items-center gap-1.5 text-sm text-fg-muted transition-colors hover:text-fg`,children:[(0,G.jsx)(nr,{className:`size-4`}),Vy.backToRuns]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[r?(0,G.jsx)(DC,{parentRunId:r}):null,(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h1`,{className:`text-[1.75rem] font-semibold tracking-tight text-fg sm:text-[2rem]`,children:Ny(e)}),(0,G.jsx)(yg,{status:e.status})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[12px] text-fg-subtle`,children:[(0,G.jsx)(`span`,{className:`rounded-md border border-line bg-overlay px-1.5 py-0.5 uppercase tracking-[0.14em]`,title:`Workflow`,children:Yy(e)}),Ky(e)?(0,G.jsx)(`span`,{className:`rounded-md border border-line bg-overlay px-1.5 py-0.5 uppercase tracking-[0.14em]`,title:`Hosts ${By.pluralLower}`,children:By.pluralLower}):null,(0,G.jsx)(`span`,{className:`font-mono`,children:e.id}),t?(0,G.jsxs)(`span`,{children:[`· `,t]}):null,(0,G.jsxs)(`span`,{children:[`· updated `,Cy(e.updatedAt)]})]}),n?(0,G.jsx)(kC,{description:n}):null]})]})}function kC({description:e}){let[t,n]=(0,x.useState)(!1);return e.length>140||e.includes(`
|
|
61
|
+
`),n=[],r=null,i=null,a=0,o=0,s=()=>{if(r){let e=r.status===`deleted`?r.oldPath:r.newPath||r.oldPath;r.path=e,n.push(r)}};for(let e of t){if(e.startsWith(`diff --git`)){s(),i=null;let t=e.match(/^diff --git (.+) (.+)$/),n=t?eS(t[1]):``,a=t?eS(t[2]):``;r={oldPath:n,newPath:a,path:a||n,status:`modified`,binary:!1,hunks:[],additions:0,deletions:0};continue}if(!r)continue;if(e.startsWith(`new file mode`)){r.status=`added`;continue}if(e.startsWith(`deleted file mode`)){r.status=`deleted`;continue}if(e.startsWith(`rename from `)){r.status=`renamed`,r.oldPath=e.slice(12);continue}if(e.startsWith(`rename to `)){r.status=`renamed`,r.newPath=e.slice(10);continue}if(e.startsWith(`Binary files`)||e.startsWith(`GIT binary patch`)){r.binary=!0;continue}if(e.startsWith(`--- `)){let t=eS(e.slice(4));t!==`/dev/null`&&(r.oldPath=t);continue}if(e.startsWith(`+++ `)){let t=eS(e.slice(4));t!==`/dev/null`&&(r.newPath=t);continue}let t=e.match($x);if(t){a=parseInt(t[1],10),o=parseInt(t[3],10),i={header:e,lines:[]},r.hunks.push(i);continue}if(i&&!e.startsWith(`\\`))if(e.startsWith(`+`))i.lines.push({type:`add`,text:e.slice(1),oldNo:null,newNo:o}),r.additions+=1,o+=1;else if(e.startsWith(`-`))i.lines.push({type:`del`,text:e.slice(1),oldNo:a,newNo:null}),r.deletions+=1,a+=1;else{let t=e.startsWith(` `)?e.slice(1):e;i.lines.push({type:`context`,text:t,oldNo:a,newNo:o}),a+=1,o+=1}}return s(),n}async function nS(){return q(`/system/editors`)}async function rS(e,t){return q(`/jobs/${e}/open`,J(t,{method:`POST`}))}var iS={code:`M23.15 2.587L18.21.21a1.494 1.494 0 0 0-1.705.29l-9.46 8.63-4.12-3.128a.999.999 0 0 0-1.276.057L.327 7.261A1 1 0 0 0 .326 8.74L3.899 12 .326 15.26a1 1 0 0 0 .001 1.479L1.65 17.94a.999.999 0 0 0 1.276.057l4.12-3.128 9.46 8.63a1.492 1.492 0 0 0 1.704.29l4.942-2.377A1.5 1.5 0 0 0 24 20.06V3.939a1.5 1.5 0 0 0-.85-1.352zm-5.146 14.861L10.826 12l7.178-5.448v10.896z`,cursor:`M11.503.131 1.891 5.678a.84.84 0 0 0-.42.726v11.188c0 .3.162.575.42.724l9.609 5.55a1 1 0 0 0 .998 0l9.61-5.55a.84.84 0 0 0 .42-.724V6.404a.84.84 0 0 0-.42-.726L12.497.131a1.01 1.01 0 0 0-.996 0M2.657 6.338h18.55c.263 0 .43.287.297.515L12.23 22.918c-.062.107-.229.064-.229-.06V12.335a.59.59 0 0 0-.295-.51l-9.11-5.257c-.109-.063-.064-.23.061-.23`,codium:`M11.583.54a1.467 1.467 0 0 0-.441 2.032c2.426 3.758 2.999 6.592 2.75 9.075-1.004 4.756-3.187 5.721-5.094 5.721-1.863 0-1.364-3.065.036-3.962.836-.522 1.906-.861 2.728-.861.814 0 1.474-.658 1.474-1.47 0-.812-.66-1.47-1.474-1.47-.96 0-1.901.202-2.78.545.18-.847.246-1.762.014-2.735-.352-1.477-1.367-2.889-3.128-4.257a1.476 1.476 0 0 0-2.069.256c-.5.64-.384 1.564.259 2.063 1.435 1.114 1.908 1.939 2.07 2.618.162.679.032 1.407-.293 2.408-.416 1.349-.9 2.553-1.11 3.708-.105.568-.114 1.187-.14 1.68-1.034-1.006-1.438-2.336-1.438-4.279 0-.811-.66-1.47-1.474-1.47-.814.001-1.473.659-1.473 1.47 0 2.654.776 5.179 2.855 6.863 1.883 1.793 6.67 1.13 6.67 4.01 0 .812 1.19 1.208 2.004 1.208.834 0 1.885-.558 1.885-1.208 0-3.267 3.443-5.253 9.11-5.244A1.472 1.472 0 0 0 24 15.773 1.472 1.472 0 0 0 22.53 14.3c-.388 0-.765.013-1.138.035.634-1.49.915-3.13.857-4.903a1.473 1.473 0 0 0-1.522-1.42 1.472 1.472 0 0 0-1.425 1.517c.076 2.32-.01 4.393-1.74 5.485-.49.31-1.062.58-1.604.58.42-1.145.738-2.353.869-3.655.083-.83.091-1.818-.003-2.585-.148-1.188-.325-2.535.126-3.55.405-.874 1.313-1.24 2.645-1.24.814 0 1.473-.659 1.473-1.47 0-.811-.659-1.47-1.473-1.47-1.98 0-3.481 1.042-4.332 2.3-.445-.95-.987-1.929-1.642-2.943a1.474 1.474 0 0 0-2.037-.44z`,windsurf:`M23.55 5.067c-1.2038-.002-2.1806.973-2.1806 2.1765v4.8676c0 .972-.8035 1.7594-1.7597 1.7594-.568 0-1.1352-.286-1.4718-.7659l-4.9713-7.1003c-.4125-.5896-1.0837-.941-1.8103-.941-1.1334 0-2.1533.9635-2.1533 2.153v4.8957c0 .972-.7969 1.7594-1.7596 1.7594-.57 0-1.1363-.286-1.4728-.7658L.4076 5.1598C.2822 4.9798 0 5.0688 0 5.2882v4.2452c0 .2147.0656.4228.1884.599l5.4748 7.8183c.3234.462.8006.8052 1.3509.9298 1.3771.313 2.6446-.747 2.6446-2.0977v-4.893c0-.972.7875-1.7593 1.7596-1.7593h.003a1.798 1.798 0 0 1 1.4718.7658l4.9723 7.0994c.4135.5905 1.05.941 1.8093.941 1.1587 0 2.1515-.9645 2.1515-2.153v-4.8948c0-.972.7875-1.7594 1.7596-1.7594h.194a.22.22 0 0 0 .2204-.2202v-4.622a.22.22 0 0 0-.2203-.2203Z`};iS[`code-insiders`]=iS.code;function aS({id:e,className:t}){let n=iS[e];return n?(0,G.jsx)(`svg`,{viewBox:`0 0 24 24`,className:t,fill:`currentColor`,"aria-hidden":`true`,role:`img`,children:(0,G.jsx)(`path`,{d:n})}):(0,G.jsx)(xr,{className:t})}function oS({files:e,truncated:t,showFileMap:n=!0}){let[r,i]=(0,x.useState)(()=>e.map(()=>!1));(0,x.useEffect)(()=>{i(e.map(()=>!1))},[e]);let a=(0,x.useRef)([]),o=(0,x.useCallback)(t=>i(e.map(()=>t)),[e]),s=(0,x.useCallback)(e=>i(t=>t.map((t,n)=>n===e?!t:t)),[]),c=(0,x.useCallback)(e=>{i(t=>t.map((t,n)=>n===e?!0:t)),requestAnimationFrame(()=>a.current[e]?.scrollIntoView({block:`nearest`,behavior:`smooth`}))},[]);if(e.length===0)return null;let l=r.length>0&&r.every(Boolean),u=r.every(e=>!e);return(0,G.jsxs)(`div`,{className:`space-y-3`,children:[n&&e.length>1?(0,G.jsx)(sS,{files:e,onJump:c,onExpandAll:()=>o(!0),onCollapseAll:()=>o(!1),allOpen:l,allClosed:u}):null,e.map((e,t)=>(0,G.jsx)(cS,{file:e,open:r[t]??!1,onToggle:()=>s(t),cardRef:e=>{a.current[t]=e}},t)),t?(0,G.jsx)(`p`,{className:`rounded-lg border border-warning-500/20 bg-warning-500/5 px-3 py-2 text-xs text-warning-300`,children:`This diff is very large and was truncated. Open the full PR on the SCM to review every line.`}):null]})}function sS({files:e,onJump:t,onExpandAll:n,onCollapseAll:r,allOpen:i,allClosed:a}){return(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-line bg-canvas/40`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-line px-3 py-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,G.jsx)(Qr,{className:`size-3.5 text-fg-subtle`}),e.length,` files changed`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:n,disabled:i,className:`text-fg-subtle transition-colors hover:text-fg disabled:opacity-40`,children:`Expand all`}),(0,G.jsx)(`span`,{className:`text-line`,children:`·`}),(0,G.jsx)(`button`,{type:`button`,onClick:r,disabled:a,className:`text-fg-subtle transition-colors hover:text-fg disabled:opacity-40`,children:`Collapse all`})]})]}),(0,G.jsx)(`ul`,{className:`max-h-56 overflow-y-auto py-1`,children:e.map((e,n)=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(n),className:`flex w-full items-center gap-2 px-3 py-1 text-left transition-colors hover:bg-overlay/40`,children:[(0,G.jsx)(uS,{status:e.status}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-fg-muted`,children:e.status===`renamed`&&e.oldPath!==e.newPath?`${e.oldPath} → ${e.newPath}`:e.path}),e.additions>0?(0,G.jsxs)(`span`,{className:`font-mono text-xs text-success-400`,children:[`+`,e.additions]}):null,e.deletions>0?(0,G.jsxs)(`span`,{className:`font-mono text-xs text-danger-400`,children:[`−`,e.deletions]}):null]})},n))})]})}function cS({file:e,open:t,onToggle:n,cardRef:r}){return(0,G.jsxs)(`div`,{ref:r,className:`scroll-mt-4 overflow-hidden rounded-xl border border-line bg-canvas/40`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:n,className:`flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-overlay/40`,children:[t?(0,G.jsx)(lr,{className:`size-3.5 shrink-0 text-fg-subtle`}):(0,G.jsx)(ur,{className:`size-3.5 shrink-0 text-fg-subtle`}),(0,G.jsx)(uS,{status:e.status}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-fg`,children:e.status===`renamed`&&e.oldPath!==e.newPath?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`span`,{className:`text-fg-subtle`,children:[e.oldPath,` → `]}),e.newPath]}):e.path}),e.additions>0?(0,G.jsxs)(`span`,{className:`font-mono text-xs text-success-400`,children:[`+`,e.additions]}):null,e.deletions>0?(0,G.jsxs)(`span`,{className:`font-mono text-xs text-danger-400`,children:[`−`,e.deletions]}):null]}),t?e.binary?(0,G.jsx)(`div`,{className:`border-t border-line px-3 py-3 text-xs text-fg-subtle`,children:`Binary file not shown.`}):e.hunks.length===0?(0,G.jsx)(`div`,{className:`border-t border-line px-3 py-3 text-xs text-fg-subtle`,children:`No textual changes.`}):(0,G.jsx)(`div`,{className:`overflow-x-auto border-t border-line`,children:(0,G.jsx)(`table`,{className:`w-full border-collapse font-mono text-xs leading-5`,children:(0,G.jsx)(`tbody`,{children:e.hunks.map((e,t)=>(0,G.jsx)(lS,{hunk:e},t))})})}):null]})}function lS({hunk:e}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`tr`,{className:`bg-overlay/40 text-fg-subtle`,children:[(0,G.jsx)(`td`,{className:`select-none px-2 text-right align-top`}),(0,G.jsx)(`td`,{className:`select-none px-2 text-right align-top`}),(0,G.jsx)(`td`,{className:`whitespace-pre-wrap break-words px-3 py-0.5`,children:e.header})]}),e.lines.map((e,t)=>(0,G.jsxs)(`tr`,{className:W(e.type===`add`&&`bg-success-500/10`,e.type===`del`&&`bg-danger-500/10`),children:[(0,G.jsx)(`td`,{className:`w-[1%] select-none whitespace-nowrap px-2 text-right align-top text-fg-subtle/70`,children:e.oldNo??``}),(0,G.jsx)(`td`,{className:`w-[1%] select-none whitespace-nowrap px-2 text-right align-top text-fg-subtle/70`,children:e.newNo??``}),(0,G.jsxs)(`td`,{className:W(`whitespace-pre-wrap break-words px-3 align-top`,e.type===`add`&&`text-success-400`,e.type===`del`&&`text-danger-400`,e.type===`context`&&`text-fg-muted`),children:[(0,G.jsx)(`span`,{className:`select-none text-fg-subtle/60`,children:e.type===`add`?`+`:e.type===`del`?`−`:` `}),e.text]})]},t))]})}function uS({status:e}){let t=`size-3.5 shrink-0`;switch(e){case`added`:return(0,G.jsx)(Nr,{className:W(t,`text-success-400`)});case`deleted`:return(0,G.jsx)(Mr,{className:W(t,`text-danger-400`)});case`renamed`:return(0,G.jsx)(Fr,{className:W(t,`text-accent-300`)});default:return(0,G.jsx)(Ar,{className:W(t,`text-fg-muted`)})}}var dS=4e3;function fS(e){let t=[],n=new Map;for(let r of e.artifacts??[]){if(r.kind!==`pr-preview`)continue;let e=r.data,i=t=>typeof e[t]==`string`?e[t]:void 0,a={title:i(`title`),description:i(`description`),base:i(`base`),sourceBranch:i(`sourceBranch`),workItem:i(`workItem`),createdAt:r.createdAt},o=a.sourceBranch;o&&n.has(o)?t[n.get(o)]=a:(o&&n.set(o,t.length),t.push(a))}return t.sort((e,t)=>t.createdAt.localeCompare(e.createdAt))}function pS(e,t){if(t.title)for(let n of e.artifacts??[]){if(n.kind!==`pr-link`)continue;let e=n.data;if(e.title!==t.title)continue;let r=typeof e.url==`string`?e.url:void 0,i=e.prId,a=typeof i==`number`?i:typeof i==`string`&&i.trim()?Number(i):void 0;return{url:r,prId:Number.isFinite(a)?a:void 0}}}function mS(e,t){let n=e.workItem,r=n?t.workItems?.find(e=>e.name===n):void 0,i=pS(t,e),a=i?.url,o=i?.prId==null?void 0:t.prMappings?.find(e=>e.prId===i.prId);return r?.status===`escalated`?{label:`Escalated`,variant:`danger`,prUrl:a}:o?.mergedAt?{label:`Merged`,variant:`success`,prUrl:a}:o&&!o.mergedAt?{label:`PR open`,variant:`accent`,prUrl:a}:r?.status===`complete`?{label:`Merged`,variant:`success`,prUrl:a}:n&&n===t.currentWorkItem?{label:`In progress`,variant:`warning`,prUrl:a}:{label:`Awaiting review`,variant:`neutral`,prUrl:a}}function hS(e){let t=e.params;for(let e of[`targetBranch`,`baseBranch`,`defaultBranch`]){let n=t[e];if(typeof n==`string`&&n.trim())return n.trim()}return`main`}function gS(e){if(e.length===0)return{base:`main`};let t=new Set(e.map(e=>e.sourceBranch).filter(Boolean)),n=e.map(e=>e.base).filter(e=>!!e),r=e[0].base??`main`;for(let n of e)if(n.base&&!t.has(n.base)){r=n.base;break}let i;for(let t of e)t.sourceBranch&&!n.includes(t.sourceBranch)&&(i=t.sourceBranch);return{base:r,head:i}}function _S(e,t){let n=e.currentWorkItem,r=n?t.filter(e=>e.workItem===n):t,i=r.filter(t=>{let{label:n}=mS(t,e);return n===`PR open`||n===`In progress`||n===`Awaiting review`}),a=i.length>0?i:r;if(a.length===0)return{base:hS(e)};let{base:o,head:s}=gS(a);return{base:o||hS(e),head:s}}function vS(e){return fS(e).some(t=>{let{label:n}=mS(t,e);return n!==`Merged`&&n!==`Escalated`})}function yS(e,t){let{base:n,head:r,live:i,enabled:a=!0}=t,[o,s]=(0,x.useState)(null),[c,l]=(0,x.useState)(!0),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(!1),m=(0,x.useRef)(!1),h=(0,x.useCallback)(async t=>{if(!m.current){m.current=!0,t&&p(!0);try{s(await Qx(e,{base:n,head:r})),d(null)}catch(e){d(e instanceof Error?e.message:`Failed to load changes`)}finally{m.current=!1,l(!1),t&&p(!1)}}},[e,n,r]);return(0,x.useEffect)(()=>{if(!a||(h(!1),!i))return;let e=window.setInterval(()=>void h(!1),dS);return()=>window.clearInterval(e)},[h,i,a]),{diff:o,loading:c,error:u,refresh:()=>h(!0),refreshing:f}}function bS({job:e,live:t}){let n=(0,x.useMemo)(()=>fS(e),[e]),r=(0,x.useMemo)(()=>_S(e,n),[e,n]),i=t||n.length===0;return(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsx)(xS,{jobId:e.id}),i?(0,G.jsx)(SS,{jobId:e.id,live:t,workItem:e.currentWorkItem,diffOpts:r,stackedPrCount:n.filter(t=>t.workItem===e.currentWorkItem&&mS(t,e).label===`PR open`).length}):null,n.length>0?(0,G.jsx)(CS,{jobId:e.id,job:e,live:t,previews:n}):null]})}function xS({jobId:e}){let[t,n]=(0,x.useState)(null),[r,i]=(0,x.useState)(!1),[a,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(null);(0,x.useEffect)(()=>{let e=!0;return nS().then(t=>{e&&(i(t.mode===`local`),n(t.editors))}).catch(()=>{e&&n([])}),()=>{e=!1}},[]);let l=(0,x.useCallback)(async(t,n)=>{o(n??t),c(null);try{await rS(e,{target:t,editor:n})}catch(e){c(e instanceof Error?e.message:`Could not open`)}finally{o(null)}},[e]);return r?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(t??[]).length>0?(0,G.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:`Open in`}):null,(t??[]).map(e=>(0,G.jsx)(Y,{type:`button`,variant:`secondary`,size:`icon`,className:`size-8`,onClick:()=>l(`editor`,e.id),disabled:a!==null,title:`Open in ${e.name}`,"aria-label":`Open in ${e.name}`,children:(0,G.jsx)(aS,{id:e.id})},e.id)),(0,G.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8`,onClick:()=>l(`folder`),disabled:a!==null,title:`Reveal folder in file manager`,"aria-label":`Reveal folder in file manager`,children:(0,G.jsx)(Rr,{})}),s?(0,G.jsx)(`span`,{className:`text-xs text-danger-400`,children:s}):null]}):null}function SS({jobId:e,live:t,workItem:n,diffOpts:r,stackedPrCount:i}){let{diff:a,loading:o,error:s,refresh:c,refreshing:l}=yS(e,{live:t,...r}),u=(0,x.useMemo)(()=>tS(a?.patch??``),[a?.patch]);return(0,G.jsxs)(`section`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Working now`}),n?(0,G.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:[`Work item: `,(0,G.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n}),i>1?` — cumulative diff across ${i} open PRs (stack tip vs ${r.base??`main`}).`:r.head?` — changes on ${r.head} vs ${r.base??`main`}.`:` — live changes in the repo checkout.`]}):(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:`Live changes in the cloned repository.`})]}),(0,G.jsxs)(lg,{children:[(0,G.jsxs)(ug,{className:`gap-3 border-b border-line pb-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,G.jsx)(fg,{className:`m-0`,children:(0,G.jsx)(ES,{diff:a})}),(0,G.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:c,disabled:l,children:[(0,G.jsx)(hi,{className:W(l&&`animate-spin`)}),`Refresh`]})]}),(0,G.jsx)(pg,{className:`pt-5`,children:o&&!a?(0,G.jsx)(`div`,{className:`animate-pulse text-sm text-fg-subtle`,children:`Loading changes…`}):s?(0,G.jsx)(gg,{title:`Could not load changes`,message:s}):!a||u.length===0?(0,G.jsx)(DS,{available:a?.available??!1}):(0,G.jsx)(oS,{files:u,truncated:a.truncated})})]})]})}function CS({jobId:e,job:t,live:n,previews:r}){return(0,G.jsxs)(`section`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Pull requests`}),(0,G.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:[r.length,` pull request`,r.length===1?``:`s`,` — expand to review each branch's changes (including stacked PRs).`]})]}),(0,G.jsx)(`div`,{className:`space-y-3`,children:r.map((r,i)=>(0,G.jsx)(wS,{jobId:e,live:n,preview:r,status:mS(r,t)},r.sourceBranch??`wi-${i}`))})]})}function wS({jobId:e,live:t,preview:n,status:r}){let[i,a]=(0,x.useState)(!1),{diff:o,loading:s,error:c,refresh:l,refreshing:u}=yS(e,{base:n.base,head:n.sourceBranch,live:t,enabled:i}),d=(0,x.useMemo)(()=>tS(o?.patch??``),[o?.patch]);return(0,G.jsxs)(lg,{className:`border-line`,children:[(0,G.jsx)(ug,{className:`gap-2 pb-3`,children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex w-full items-start gap-2 text-left`,children:[i?(0,G.jsx)(lr,{className:`mt-1 size-4 shrink-0 text-fg-subtle`}):(0,G.jsx)(ur,{className:`mt-1 size-4 shrink-0 text-fg-subtle`}),(0,G.jsx)(Hr,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(dg,{className:`truncate text-sm`,children:n.title||n.workItem||`Pull request`}),(0,G.jsx)(TS,{status:r})]}),(0,G.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-2 text-xs`,children:[n.workItem?(0,G.jsx)(vg,{variant:`neutral`,children:n.workItem}):null,n.sourceBranch?(0,G.jsxs)(vg,{variant:`neutral`,className:`font-mono normal-case tracking-normal`,children:[n.sourceBranch,n.base?(0,G.jsxs)(`span`,{className:`text-fg-subtle`,children:[` → `,n.base]}):null]}):null,r.prUrl?(0,G.jsxs)(`a`,{href:r.prUrl,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`inline-flex items-center gap-1 text-accent-300 hover:text-accent-200`,children:[`View PR`,(0,G.jsx)(Er,{className:`size-3`})]}):null,i?(0,G.jsx)(ES,{diff:o,compact:!0}):null]})]})]})}),i?(0,G.jsxs)(pg,{className:`space-y-4 border-t border-line pt-4`,children:[n.description?(0,G.jsx)(`div`,{className:`prose-coro space-y-2 text-sm leading-6 text-fg`,dangerouslySetInnerHTML:{__html:Jb(n.description)}}):null,r.label===`Merged`&&(!o||d.length===0)?(0,G.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:`This work item was merged. Expand showed no local diff — open the PR on the SCM for the final changes.`}):null,(0,G.jsx)(`div`,{className:`flex justify-end`,children:(0,G.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:l,disabled:u,children:[(0,G.jsx)(hi,{className:W(u&&`animate-spin`)}),`Refresh`]})}),s&&!o?(0,G.jsx)(`div`,{className:`animate-pulse text-sm text-fg-subtle`,children:`Loading changes…`}):c?(0,G.jsx)(gg,{title:`Could not load changes`,message:c}):!o||d.length===0?r.label===`Merged`?null:(0,G.jsx)(DS,{available:o?.available??!1}):(0,G.jsx)(oS,{files:d,truncated:o.truncated})]}):null]})}function TS({status:e}){return(0,G.jsx)(vg,{variant:e.variant,children:e.label})}function ES({diff:e,compact:t}){return!e||e.files.length===0?t?null:(0,G.jsx)(G.Fragment,{children:`Code the agent has written in the cloned repo, before any PR is opened.`}):(0,G.jsxs)(`span`,{className:W(t&&`text-fg-subtle`),children:[(0,G.jsx)(`span`,{className:`font-mono`,children:e.stats.files}),` file`,e.stats.files===1?``:`s`,` changed`,e.stats.insertions>0?(0,G.jsxs)(`span`,{className:`ml-2 text-success-400`,children:[`+`,e.stats.insertions]}):null,e.stats.deletions>0?(0,G.jsxs)(`span`,{className:`ml-2 text-danger-400`,children:[`−`,e.stats.deletions]}):null,(0,G.jsxs)(`span`,{className:`ml-2 text-fg-subtle`,children:[`vs `,e.base]})]})}function DS({available:e}){return(0,G.jsx)(`div`,{className:`rounded-xl border border-dashed border-line bg-canvas/30 px-4 py-8 text-center text-sm text-fg-subtle`,children:e?`No changes yet. They will appear here as the agent edits files.`:`No repository checkout yet. Changes appear once the agent clones the repo and starts coding.`})}var OS=x.forwardRef(function({className:e,children:t,...n},r){return(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`select`,{ref:r,className:W(`flex h-11 w-full appearance-none rounded-xl border border-line-strong bg-overlay px-3.5 py-2.5 pr-10 text-sm text-fg shadow-[inset_0_1px_0_rgba(255,255,255,0.03)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-400/60 disabled:cursor-not-allowed disabled:opacity-50`,e),...n,children:t}),(0,G.jsx)(lr,{"aria-hidden":!0,className:`pointer-events-none absolute right-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`})]})});function kS({job:e,workflowPhases:t,refreshing:n,onRefresh:r,cancelling:i,cancelError:a,onCancel:o,pausing:s,pauseError:c,onPause:l,resuming:u,resumeError:d,resumePhase:f,clearSession:p,onResumePhaseChange:m,onClearSessionChange:h,onResume:g,interactiveOverride:_,onInteractiveChange:v}){let y=Po(e.status),b=Fo(e.status),S=Lo(e.status,e.awaitingEvent),C=_??e.interactive,[w,T]=(0,x.useState)(!1),[E,D]=(0,x.useState)(null);(0,x.useEffect)(()=>{_===void 0&&D(null)},[_]);async function O(t){T(!0),D(null),v(t);try{await q(`/jobs/${e.id}/interactive`,J({interactive:t},{method:`PATCH`}))}catch(e){D(e instanceof Error?e.message:`Failed to update interactive mode`),v(!t)}finally{T(!1)}}return(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:W(`flex flex-wrap items-center gap-2 rounded-2xl border border-line bg-overlay/40 px-3 py-2`,`sm:gap-3 sm:px-4`),children:[(0,G.jsx)(AS,{label:`Controls`}),(0,G.jsxs)(Y,{variant:`secondary`,size:`sm`,onClick:()=>void r(),disabled:n||i,children:[n?(0,G.jsx)($r,{className:`animate-spin`}):(0,G.jsx)(mi,{}),`Refresh`]}),(0,G.jsxs)(Y,{variant:`secondary`,size:`sm`,onClick:()=>void o(),disabled:!b||i||u,children:[i?(0,G.jsx)($r,{className:`animate-spin`}):(0,G.jsx)(ir,{}),i?`Cancelling…`:`Cancel`]}),(0,G.jsxs)(Y,{variant:`secondary`,size:`sm`,onClick:()=>void l(),disabled:!S||s||i||u,title:S?`Park the run at the next safe boundary so you can think and steer`:void 0,children:[s?(0,G.jsx)($r,{className:`animate-spin`}):(0,G.jsx)(oi,{}),s?`Pausing…`:`Pause`]}),(0,G.jsx)(MS,{job:e,workflowPhases:t,canResume:y,resuming:u,resumePhase:f,clearSession:p,onResumePhaseChange:m,onClearSessionChange:h,onResume:g}),(0,G.jsx)(jS,{}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,G.jsx)(jx,{checked:C,onCheckedChange:O,disabled:w,ariaLabel:`Toggle interactive mode`}),(0,G.jsxs)(`div`,{className:`flex flex-col leading-tight`,children:[(0,G.jsx)(`span`,{className:`text-[12px] font-medium text-fg`,children:C?`Interactive`:`Autonomous`}),(0,G.jsx)(`span`,{className:`text-[11px] text-fg-subtle`,children:C?`Will park at checkpoints`:`Will run end-to-end`})]})]})]}),a||c||d||E?(0,G.jsxs)(`div`,{className:`space-y-2`,children:[a?(0,G.jsx)(gg,{title:`Cancel failed`,message:a}):null,c?(0,G.jsx)(gg,{title:`Pause failed`,message:c}):null,d?(0,G.jsx)(gg,{title:`Resume failed`,message:d}):null,E?(0,G.jsx)(gg,{title:`Interactive toggle failed`,message:E}):null]}):null]})}function AS({label:e}){return(0,G.jsx)(`span`,{className:`hidden text-[11px] font-medium uppercase tracking-[0.16em] text-fg-subtle sm:inline`,children:e})}function jS(){return(0,G.jsx)(`span`,{className:`hidden h-6 w-px bg-line sm:block`,"aria-hidden":!0})}function MS({job:e,workflowPhases:t,canResume:n,resuming:r,resumePhase:i,clearSession:a,onResumePhaseChange:o,onClearSessionChange:s,onResume:c}){let[l,u]=(0,x.useState)(!1);return n?(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsxs)(Y,{size:`sm`,onClick:()=>void c(i||void 0,a),disabled:r,children:[r?(0,G.jsx)($r,{className:`animate-spin`}):(0,G.jsx)(ui,{}),r?`Resuming…`:`Resume`]}),(0,G.jsxs)(Jh,{open:l,onOpenChange:u,children:[(0,G.jsx)(Yh,{asChild:!0,children:(0,G.jsx)(Y,{size:`sm`,variant:`secondary`,"aria-label":`Resume options`,className:`px-2`,children:(0,G.jsx)(lr,{})})}),(0,G.jsx)(Zh,{align:`start`,className:`min-w-72 p-3`,children:(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1.5 block text-[11px] uppercase tracking-[0.14em] text-fg-subtle`,children:`Resume from phase`}),(0,G.jsxs)(OS,{value:i,onChange:e=>o(e.target.value),children:[(0,G.jsxs)(`option`,{value:``,children:[`Current phase (`,e.phase,`)`]}),t.map(t=>(0,G.jsxs)(`option`,{value:t.name,children:[t.name,t.name===e.phase?` (current)`:``]},t.name))]})]}),(0,G.jsxs)(`label`,{className:`flex items-start gap-2 text-[13px] text-fg-muted`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>s(e.target.checked),className:`mt-0.5`}),(0,G.jsxs)(`span`,{children:[`Start with a fresh session.`,(0,G.jsx)(`span`,{className:`block text-[11px] text-fg-subtle`,children:`Use when the current conversation history is no longer useful.`})]})]}),(0,G.jsx)(`div`,{className:`flex justify-end pt-1`,children:(0,G.jsx)(Y,{size:`sm`,onClick:()=>{u(!1),c(i||void 0,a)},disabled:r,children:r?`Resuming…`:`Resume with options`})})]})})]})]}):(0,G.jsx)(`span`,{className:`rounded-md border border-dashed border-line px-2.5 py-1 text-[12px] text-fg-subtle`,title:`This ${zy.singularLower} can't be resumed from its current state.`,children:`Not resumable`})}var NS={text:{textClass:`text-fg`,iconClass:`text-fg-subtle`,icon:ar},tool_use:{textClass:`text-fg`,iconClass:`text-accent-300`,icon:rr,label:`Tool`},tool_summary:{textClass:`text-fg-muted`,iconClass:`text-fg-subtle`,icon:Yr,label:`Summary`,dimmed:!0},thinking:{textClass:`text-fg-muted`,iconClass:`text-fg-subtle`,icon:yi,label:`Thinking`,dimmed:!0},tool_progress:{textClass:`text-fg-muted`,iconClass:`text-warning-400`,icon:$r,label:`Progress`,dimmed:!0},error:{textClass:`text-danger-400`,iconClass:`text-danger-400`,icon:Mi,label:`Error`},guardrail:{textClass:`text-warning-400`,iconClass:`text-warning-400`,icon:wi,label:`Guardrail`},warning:{textClass:`text-warning-400`,iconClass:`text-warning-400`,icon:Mi,label:`Warning`},result:{textClass:`text-success-400`,iconClass:`text-success-400`,icon:fr,label:`Result`},phase:{textClass:`text-accent-300`,iconClass:`text-accent-300`,icon:Vr,label:`Phase`},insight:{textClass:`text-accent-300`,iconClass:`text-accent-300`,icon:ar,label:`Insight`},session_reset:{textClass:`text-warning-400`,iconClass:`text-warning-400`,icon:mi,label:`Reset`},webhook:{textClass:`text-warning-400`,iconClass:`text-warning-400`,icon:Ni,label:`Webhook`},human:{textClass:`text-fg`,iconClass:`text-accent-300`,icon:ti,label:`Developer`},system:{textClass:`text-fg-subtle`,iconClass:`text-fg-subtle`,icon:xi,label:`System`,dimmed:!0}};function PS(e){let t=e.content;return e.lineType===`tool_progress`?t.replace(/^⏳\s*/,``):e.lineType===`system`&&t.startsWith(`[event:`)?t.replace(/^\[event:([^\]]+)\]\s*/,`$1: `):e.lineType===`tool_use`||e.lineType===`text`||e.lineType===`phase`?t:t.replace(/^\[[^\]]+\]\s*/,``)}function FS({lineType:e,className:t=``}){let n=NS[e],r=n.icon;return(0,G.jsx)(r,{className:W(`mt-0.5 size-3.5 shrink-0`,n.iconClass,n.dimmed&&`opacity-60`,e===`tool_progress`&&`animate-spin`,t),"aria-hidden":`true`})}function IS(e){if(!e)return``;try{return new Date(e).toLocaleTimeString(`en-US`,{hour12:!1,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}catch{return``}}function LS({line:e}){let t=NS[e.lineType],n=PS(e);if(e.lineType===`phase`)return(0,G.jsxs)(`div`,{className:`my-2 flex items-center gap-3 py-1.5`,children:[(0,G.jsx)(`div`,{className:`h-px flex-1 bg-accent-500/20`}),(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-accent-500/25 bg-accent-500/10 px-3 py-0.5 text-[11px] font-semibold uppercase tracking-[0.16em] text-accent-300`,children:[(0,G.jsx)(FS,{lineType:e.lineType,className:`mt-0 size-3`}),n]}),(0,G.jsx)(`div`,{className:`h-px flex-1 bg-accent-500/20`})]});if(e.lineType===`error`||e.lineType===`warning`||e.lineType===`guardrail`)return(0,G.jsxs)(`div`,{className:W(`my-1 flex items-start gap-3 rounded-xl px-4 py-2.5`,e.lineType===`error`?`border border-danger-500/25 bg-danger-500/8`:`border border-warning-500/25 bg-warning-500/8`),children:[(0,G.jsx)(FS,{lineType:e.lineType}),(0,G.jsx)(`span`,{className:t.textClass,children:n})]});if(e.lineType===`result`)return(0,G.jsxs)(`div`,{className:`my-1 flex items-start gap-3 rounded-xl border border-success-500/25 bg-success-500/8 px-4 py-2.5`,children:[(0,G.jsx)(FS,{lineType:e.lineType}),(0,G.jsx)(`span`,{className:t.textClass,children:n})]});if(e.lineType===`human`)return(0,G.jsxs)(`div`,{className:`my-1 flex items-start gap-3 rounded-xl border border-accent-500/25 bg-accent-500/8 px-4 py-2.5`,children:[(0,G.jsx)(FS,{lineType:e.lineType}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mr-2 text-[11px] font-semibold uppercase tracking-[0.14em] text-accent-300`,children:`Developer`}),(0,G.jsx)(`span`,{className:`text-fg`,children:n})]})]});if(e.lineType===`tool_use`){let e=n.match(/^→ (\S+)(.*)/);if(e)return(0,G.jsxs)(`span`,{className:t.dimmed?`opacity-60`:``,children:[(0,G.jsx)(`span`,{className:`text-fg-subtle`,children:`→ `}),(0,G.jsx)(`span`,{className:`font-medium text-fg`,children:e[1]}),(0,G.jsx)(`span`,{className:`text-fg-subtle`,children:e[2]})]})}return(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(FS,{lineType:e.lineType}),(0,G.jsxs)(`span`,{className:W(t.textClass,t.dimmed&&`opacity-70`),children:[t.label?(0,G.jsx)(`span`,{className:`mr-2 text-[11px] font-semibold uppercase tracking-[0.14em] text-fg-subtle`,children:t.label}):null,n]})]})}function RS(e,t=`auto`){e&&e.scrollTo({top:e.scrollHeight,behavior:t})}function zS(e,t=64){let{scrollTop:n,scrollHeight:r,clientHeight:i}=e;return r-n-i<=t}var BS=[{value:`all`,label:`All`},{value:`main`,label:`Agent`},{value:`tools`,label:`Tools`}];function VS({lines:e,className:t=``}){let n=(0,x.useRef)(null),[r,i]=(0,x.useState)(!0),a=(0,x.useRef)(!0),[o,s]=(0,x.useState)(`all`),c=(0,x.useRef)(!1);(0,x.useEffect)(()=>{a.current=r},[r]);let l=()=>{let e=n.current;if(!e)return;if(c.current){c.current=!1;return}let t=zS(e);a.current=t,i(t)};(0,x.useEffect)(()=>{if(!r)return;let e=requestAnimationFrame(()=>{!a.current||!n.current||(c.current=!0,RS(n.current,`auto`))});return()=>{cancelAnimationFrame(e)}},[e,r,o]),(0,x.useEffect)(()=>{let e=n.current;if(!e||!r)return;let t=new ResizeObserver(()=>{!n.current||!a.current||(c.current=!0,RS(n.current,`auto`))});return t.observe(e),()=>{t.disconnect()}},[r]);let u=[`tool_use`,`tool_summary`,`tool_progress`,`thinking`,`system`],d=[`text`,`phase`,`error`,`guardrail`,`warning`,`result`,`insight`,`session_reset`,`webhook`,`human`],f=e.filter(e=>o===`all`?!0:o===`main`?d.includes(e.lineType):o===`tools`?u.includes(e.lineType):!0);return(0,G.jsxs)(`div`,{className:W(`flex flex-col overflow-hidden rounded-2xl border border-line bg-canvas/60`,t),children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-line px-3 py-2.5`,children:[(0,G.jsx)(ab,{options:BS,value:o,onChange:s,size:`sm`,ariaLabel:`Filter log lines`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsxs)(`span`,{className:`text-[11px] uppercase tracking-[0.14em] text-fg-subtle`,children:[f.length,` / `,e.length,` lines`]}),r?null:(0,G.jsxs)(Y,{type:`button`,size:`sm`,variant:`secondary`,onClick:()=>{a.current=!0,i(!0),n.current&&(c.current=!0,RS(n.current,`smooth`))},children:[(0,G.jsx)(er,{}),`Follow`]})]})]}),(0,G.jsx)(`div`,{ref:n,onScroll:l,className:`min-h-[280px] max-h-[calc(100vh-320px)] flex-1 overflow-y-auto p-4 font-mono text-[12.5px] leading-relaxed`,children:f.length===0?(0,G.jsx)(`div`,{className:`flex h-32 items-center justify-center text-sm text-fg-subtle`,children:`Waiting for log output…`}):f.map((e,t)=>(0,G.jsxs)(`div`,{className:W(`flex gap-3 animate-fade-in`,e.lineType===`phase`?``:`rounded-lg px-2 py-1 hover:bg-overlay/40`),children:[e.lineType===`phase`?null:(0,G.jsx)(`span`,{className:`shrink-0 select-none pt-0.5 text-[11px] tabular-nums text-fg-subtle/70`,children:IS(e.timestamp)}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1 break-words whitespace-pre-wrap`,children:(0,G.jsx)(LS,{line:e})})]},t))})]})}function HS(e,t){let n=e.findIndex(e=>e.name===t);if(n!==-1)return n;let r=t.toLowerCase();return e.findIndex(e=>e.name.toLowerCase()===r)}function US(e,t,n){let r=HS(t,n.phase),i=HS(t,e),a=(n.phaseUsage??[]).some(t=>t.phase===e);return i===-1?`pending`:i===r?n.status===`complete`?`complete`:Mo(n.status)?`awaiting-input`:`in-progress`:r!==-1&&i<r||a||n.status===`complete`?`complete`:`pending`}function WS(e,t){let n=`relative flex-1 min-w-[150px] rounded-xl border px-3.5 py-2.5 text-left transition-colors cursor-pointer`,r=t?`ring-2 ring-accent-400/60 ring-offset-2 ring-offset-canvas`:``;switch(e){case`complete`:return W(n,r,`border-success-500/25 bg-success-500/8 hover:border-success-500/40`);case`in-progress`:return W(n,r,`border-transparent bg-accent-500/10 hover:bg-accent-500/15 animate-border-travel`);case`awaiting-input`:return W(n,r,`border-warning-500/30 bg-warning-500/10 hover:border-warning-500/45 animate-pulse-slow`);default:return W(n,r,`border-line bg-overlay/40 hover:border-line-strong`)}}function GS({state:e}){switch(e){case`complete`:return(0,G.jsx)(cr,{className:`size-3.5 text-success-400`,strokeWidth:2.5});case`in-progress`:return(0,G.jsx)(`span`,{className:`size-1.5 rounded-full bg-accent-400 animate-pulse-dot`,"aria-hidden":!0});case`awaiting-input`:return(0,G.jsx)(Gr,{className:`size-3.5 text-warning-400`});default:return(0,G.jsx)(`span`,{className:`size-1.5 rounded-full bg-fg-subtle/60`,"aria-hidden":!0})}}function KS(e){switch(e){case`complete`:return`Complete`;case`in-progress`:return`Running`;case`awaiting-input`:return`Awaiting input`;case`pending`:return`Pending`}}function qS({job:e,phases:t,selectedPhase:n,onSelectPhase:r}){if(t.length===0)return(0,G.jsx)(`div`,{className:`px-2 py-3 text-sm italic text-fg-subtle`,children:`No workflow phases defined for this job.`});let i=new Map;for(let t of e.artifacts??[]){let e=i.get(t.phase)??[];e.push(t),i.set(t.phase,e)}let a=new Map;for(let t of e.phaseUsage??[])a.set(t.phase,(a.get(t.phase)??0)+1);return(0,G.jsx)(`div`,{className:`w-full overflow-x-auto py-1.5`,children:(0,G.jsx)(`div`,{className:`flex min-w-max items-stretch gap-2`,children:t.map((o,s)=>{let c=US(o.name,t,e),l=n===o.name,u=i.get(o.name)??[],d=a.get(o.name)??0;return(0,G.jsxs)(`div`,{className:`flex items-stretch`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>r(o.name),className:WS(c,l),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`flex size-4 items-center justify-center`,children:(0,G.jsx)(GS,{state:c})}),(0,G.jsx)(`span`,{className:`truncate text-[13px] font-medium text-fg`,children:o.name}),o.interactiveCheckpoint&&e.interactive?(0,G.jsx)(`span`,{title:`Interactive checkpoint — the job will park here for developer approval`,className:`inline-flex items-center rounded-full border border-warning-500/25 bg-warning-500/10 px-1 py-0.5 text-warning-400`,children:(0,G.jsx)(Ur,{className:`size-3`})}):null]}),(0,G.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.16em] text-fg-subtle`,children:KS(c)}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[d>1?(0,G.jsxs)(`span`,{title:`Phase ran ${d} times (loop-back)`,className:`inline-flex items-center gap-0.5 rounded-full border border-accent-500/25 bg-accent-500/10 px-1.5 py-0.5 text-[10px] text-accent-300`,children:[(0,G.jsx)(_i,{className:`size-2.5`}),d,`×`]}):null,u.length>0?(0,G.jsx)(`span`,{title:`${u.length} artifact${u.length===1?``:`s`}`,className:`rounded-full border border-line bg-overlay/60 px-1.5 py-0.5 text-[10px] text-fg-muted`,children:u.length}):null]})]})]}),s<t.length-1?(0,G.jsx)(`div`,{className:`flex shrink-0 items-center px-1 text-fg-subtle/60`,"aria-hidden":!0,children:(0,G.jsx)(ur,{className:`size-4`})}):null]},o.name)})})})}function JS(e){let t=[];for(let n of e.workItems??[]){let r=(e.phaseUsage??[]).filter(e=>e.workItem===n.name),i=[];for(let e of r)i.includes(e.phase)||i.push(e.phase);t.push({item:n,executions:r,distinctPhases:i,hasStarted:r.length>0})}return t}function YS(e){return e.status===`complete`?`Complete`:e.status===`in-progress`?`In progress`:e.status===`escalated`?`Escalated`:`Pending`}function XS(e){switch(e.status){case`complete`:return`bg-success-400`;case`in-progress`:return`bg-accent-400 animate-pulse-dot`;case`escalated`:return`bg-danger-400`;default:return`bg-fg-subtle/60`}}function ZS({phaseName:e,count:t,state:n,onClick:r}){return(0,G.jsxs)(`button`,{type:`button`,onClick:r,className:W(`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors cursor-pointer`,n===`in-progress`?`border-accent-500/35 bg-accent-500/10 text-fg hover:border-accent-500/55`:n===`complete`?`border-success-500/25 bg-success-500/8 text-fg hover:border-success-500/40`:`border-line bg-overlay/40 text-fg-muted hover:border-line-strong`),children:[n===`complete`?(0,G.jsx)(cr,{className:`size-3 text-success-400`,strokeWidth:2.5}):n===`in-progress`?(0,G.jsx)(`span`,{className:`size-1.5 rounded-full bg-accent-400 animate-pulse-dot`,"aria-hidden":!0}):(0,G.jsx)(`span`,{className:`size-1.5 rounded-full bg-fg-subtle/60`,"aria-hidden":!0}),(0,G.jsx)(`span`,{children:e}),t>1?(0,G.jsxs)(`span`,{title:`Ran ${t} times for this work item`,className:`inline-flex items-center gap-0.5 rounded-full bg-overlay/80 px-1 text-[10px] text-fg-muted`,children:[(0,G.jsx)(_i,{className:`size-2.5`}),t]}):null]})}function QS({job:e,phases:t,onSelectPhase:n}){if(!e.workItems||e.workItems.length===0)return null;let r=JS(e),i=new Set(t.map(e=>e.name)),a=r.find(e=>e.hasStarted)?.item.name??null;return(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`text-[11px] uppercase tracking-[0.14em] text-fg-subtle`,children:[`Work items `,(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[`(`,e.workItems.length,`)`]})]}),e.currentWorkItem?(0,G.jsxs)(`div`,{className:`text-[11px] text-fg-subtle`,children:[`current: `,(0,G.jsx)(`span`,{className:`text-fg`,children:e.currentWorkItem})]}):null]}),(0,G.jsx)(`div`,{className:`space-y-1.5`,children:r.map(t=>{let{item:r,executions:o,distinctPhases:s,hasStarted:c}=t,l=e.currentWorkItem===r.name,u=r.status===`complete`,d=!c&&u&&a!==null&&a!==r.name,f=s.map(e=>({name:e,count:o.filter(t=>t.phase===e).length}));return(0,G.jsxs)(`div`,{className:W(`flex flex-wrap items-center gap-3 rounded-xl border px-3 py-2`,l?`border-accent-500/30 bg-accent-500/8`:c||d?`border-line bg-overlay/40`:`border-line bg-overlay/20 opacity-70`),children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:W(`size-2 rounded-full shrink-0`,XS(r))}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`truncate text-[13px] font-medium text-fg`,children:r.name}),(0,G.jsxs)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-fg-subtle`,children:[YS(r),r.loopCount>0?(0,G.jsxs)(`span`,{className:`ml-2 normal-case tracking-normal text-fg-muted`,children:[`· `,r.loopCount,` retr`,r.loopCount===1?`y`:`ies`]}):null]})]})]}),c?(0,G.jsxs)(`div`,{className:`flex flex-1 flex-wrap items-center gap-1.5`,children:[f.map(({name:t,count:a})=>{let o=l&&e.phase===t&&No(e.status),s=i.has(t),c=o?`in-progress`:`complete`;return(0,G.jsx)(ZS,{phaseName:s?t:`${t} (ad-hoc)`,count:a,state:c,onClick:()=>n(t)},`${r.name}:${t}`)}),l&&No(e.status)&&e.phase&&!s.includes(e.phase)?(0,G.jsx)(ZS,{phaseName:e.phase,count:1,state:`in-progress`,onClick:()=>n(e.phase)}):null]}):d?(0,G.jsx)(`div`,{className:`flex flex-1 flex-wrap items-center gap-1.5`,children:(0,G.jsxs)(`span`,{title:`This work item was delivered together with "${a}" in a single execution cycle (one shared PR / verification run). The actual phase executions are attributed to that item above.`,className:`inline-flex items-center gap-1.5 rounded-full border border-success-500/20 bg-success-500/8 px-2.5 py-1 text-[11px] font-medium text-fg-muted`,children:[(0,G.jsx)(cr,{className:`size-3 text-success-400/80`,strokeWidth:2.5}),`delivered with `,(0,G.jsx)(`span`,{className:`text-fg`,children:a})]})}):(0,G.jsx)(`div`,{className:`text-[11px] italic text-fg-subtle`,children:l?`starting…`:`waiting`}),r.status===`escalated`?(0,G.jsxs)(`span`,{title:`This work item escalated and is waiting on a human`,className:`inline-flex items-center gap-1 rounded-full border border-danger-500/30 bg-danger-500/10 px-2 py-0.5 text-[10px] text-danger-400`,children:[(0,G.jsx)(Mi,{className:`size-3`}),`escalated`]}):null]},r.name)})})]})}function $S(e,t,n){if(!t||!n)return null;let r=e[t];return r?r.find(e=>e.id===n)??null:null}function eC(e){let t=nC(e);return t?`${t.symbol} ${t.label}`:null}function tC(e){return nC(e)?.symbol??``}function nC(e){let t=e?.pricing;if(!t)return null;let n=t.inputPerMTokens,r=t.outputPerMTokens;if(n==null&&r==null)return null;let i=n!=null&&r!=null?(n+r)/2:n??r??0,a,o;return i<=1?(a=1,o=`cheapest`):i<=5?(a=2,o=`low`):i<=20?(a=3,o=`mid`):i<=50?(a=4,o=`high`):(a=5,o=`frontier`),{symbol:`$`.repeat(a),label:o}}function rC(e,t){let n=e?.pricing;if(!n||!t)return null;let r=e=>(e??0)/1e6;return(t.inputTokens??0)*r(n.inputPerMTokens)+(t.outputTokens??0)*r(n.outputPerMTokens)+(t.cacheReadInputTokens??0)*r(n.cacheReadPerMTokens)+(t.cacheCreationInputTokens??0)*r(n.cacheCreationPerMTokens??n.inputPerMTokens)}function iC(e){return Number.isFinite(e)?e===0?`0.00`:Math.abs(e)<.01?e.toFixed(4):Math.abs(e)<1?e.toFixed(3):e.toFixed(2):`—`}var aC=`::`;function oC(e,t){return!e||!t?``:`${e}${aC}${t}`}function sC(e){let t=e.indexOf(aC);return t<0?{provider:``,model:``}:{provider:e.slice(0,t),model:e.slice(t+2)}}function cC({value:e,onChange:t,providers:n,modelsByProvider:r,loadModels:i,className:a,disabled:o=!1,hideLabel:s=!1,label:c=`Model`}){(0,x.useEffect)(()=>{for(let e of n)i(e.id)},[n.map(e=>e.id).join(`|`)]);let l=(0,x.useMemo)(()=>n.some(e=>r[e.id]===null||r[e.id]===void 0),[n,r]),u=(0,x.useMemo)(()=>n.reduce((e,t)=>e+(r[t.id]?.length??0),0),[n,r]),d=oC(e.provider,e.model),f=eC($S(r,e.provider,e.model)),p=!!e.provider&&!!e.model&&(r[e.provider]??[]).some(t=>t.id===e.model),m=!!e.model&&!p,h=n.length===0?`(no enabled providers)`:l&&u===0?`Loading…`:u===0?`(no models published)`:`(select a model)`;return(0,G.jsxs)(Sv,{label:s?``:c,className:a,children:[(0,G.jsxs)(`select`,{value:d,disabled:o||n.length===0,onChange:e=>t(sC(e.target.value)),className:`w-full rounded-xl border border-line bg-overlay px-3 py-2 text-sm text-fg disabled:opacity-60`,"aria-label":s?c:void 0,children:[(0,G.jsx)(`option`,{value:``,children:h}),m?(0,G.jsxs)(`option`,{value:d,children:[e.model,` · `,e.provider,` (saved)`]}):null,n.map(e=>{let t=r[e.id];return!t||t.length===0?null:(0,G.jsx)(`optgroup`,{label:e.displayName,children:t.map(t=>{let n=tC(t);return(0,G.jsx)(`option`,{value:oC(e.id,t.id),children:n?`${t.displayName} — ${n}`:t.displayName},`${e.id}::${t.id}`)})},e.id)})]}),f?(0,G.jsx)(`div`,{className:`mt-1 text-[11px] text-fg-subtle`,title:`Static pricing hint published by the provider plugin. Runtime accounting always uses actual reported cost.`,children:f}):null]})}function lC(){let[e,t]=(0,x.useState)([]),[n,r]=(0,x.useState)(!0),[i,a]=(0,x.useState)(null);return(0,x.useEffect)(()=>{let e=!1;return(async()=>{try{let n=await q(`/plugins`);if(e)return;t(n.plugins.filter(e=>e.manifest.kind===`executor`&&(e.active!==!1||e.installed!==!1||e.source===`builtin`)).map(e=>({id:e.manifest.id,displayName:e.manifest.displayName})).sort((e,t)=>e.displayName.localeCompare(t.displayName)))}catch(t){if(e)return;a(t instanceof K?t.message:String(t))}finally{e||r(!1)}})(),()=>{e=!0}},[]),{providers:e,loading:n,error:i}}function uC(){let[e,t]=(0,x.useState)({});return{modelsByProvider:e,loadModels:(0,x.useCallback)(async n=>{if(n&&e[n]===void 0){t(e=>({...e,[n]:null}));try{let e=await q(`/plugins/${encodeURIComponent(n)}/models`);t(t=>({...t,[n]:e.models??[]}))}catch(e){if(!(e instanceof K))throw e;t(e=>({...e,[n]:[]}))}}},[e])}}function dC({job:e,phase:t,onMutated:n}){let r=t===e.phase,i=e.status===`running`,a=e.phaseModelOverrides?.[t],{providers:o,loading:s}=lC(),{modelsByProvider:c,loadModels:l}=uC(),[u,d]=(0,x.useState)(()=>({provider:a?.provider??``,model:a?.model??``}));(0,x.useEffect)(()=>{d({provider:a?.provider??``,model:a?.model??``})},[t,a?.provider,a?.model]);let[f,p]=(0,x.useState)(null),[m,h]=(0,x.useState)(null),[g,_]=(0,x.useState)(!1),v=(0,x.useMemo)(()=>{let n=(e.phaseUsage??[]).filter(e=>e.phase===t);return n.length>0?n[n.length-1].model:null},[e.phaseUsage,t]),y=(0,x.useMemo)(()=>{let n=(e.phaseUsage??[]).filter(e=>e.phase===t);return n.length>0?n[n.length-1]:null},[e.phaseUsage,t]),b=rC($S(c,u.provider,u.model),y??void 0),S=y?.costUsd??null,C=b!=null&&S!=null?b-S:null,w=(0,x.useMemo)(()=>(u.provider||``)!==(a?.provider??``)||(u.model||``)!==(a?.model??``),[u,a]),T=async r=>{p(r),h(null);try{if(r===`apply`){if(!u.model)throw Error(`Pick a model first.`);await q(`/jobs/${encodeURIComponent(e.id)}/phase-overrides`,J({phase:t,model:u.model,provider:u.provider||void 0},{method:`PATCH`}))}else if(r===`clear`)await q(`/jobs/${encodeURIComponent(e.id)}/phase-overrides`,J({phase:t,clear:!0},{method:`PATCH`})),d({provider:``,model:``});else if(r===`rerun`){let n={};u.model&&(n.model=u.model),u.provider&&(n.provider=u.provider),await q(`/jobs/${encodeURIComponent(e.id)}/phases/${encodeURIComponent(t)}/rerun`,J(n,{method:`POST`}))}r!==`rerun`&&_(!1),n()}catch(e){h(e instanceof K||e instanceof Error?e.message:String(e))}finally{p(null)}},E=a?.model??v??null,D=a?`override`:v?`last-used`:`default`;return(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-[12px]`,children:[(0,G.jsx)(`span`,{className:`text-[11px] uppercase tracking-[0.14em] text-fg-subtle`,children:`Model`}),(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:E??(0,G.jsx)(`span`,{className:`text-fg-subtle`,children:`(workflow default)`})}),D===`override`?(0,G.jsx)(`span`,{className:`rounded-full border border-info-400/40 bg-info-500/10 px-1.5 py-0 text-[10px] uppercase tracking-wide text-info-200`,children:`override`}):D===`last-used`?(0,G.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-fg-subtle`,children:`last run`}):null,g?null:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>_(!0),className:`ml-auto inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] text-fg-muted transition-colors hover:bg-overlay hover:text-fg`,"aria-label":`Change model for this phase`,title:`Change model for this phase`,children:[(0,G.jsx)(li,{className:`size-3`}),`Change`]})]}),g?(0,G.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-line bg-canvas/40 p-3`,children:[s?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-[12px] text-fg-subtle`,children:[(0,G.jsx)($r,{className:`size-3 animate-spin`}),` Loading providers…`]}):o.length===0?(0,G.jsx)(`div`,{className:`text-[12px] text-fg-subtle`,children:`No LLM provider plugins are installed. Configure one in Settings → LLM Providers before overriding a phase model.`}):(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`min-w-[12rem] max-w-xs flex-1`,children:(0,G.jsx)(cC,{value:u,onChange:d,providers:o,modelsByProvider:c,loadModels:l,disabled:f!==null,hideLabel:!0})}),(0,G.jsxs)(Y,{type:`button`,size:`sm`,variant:`primary`,disabled:!w||!u.model||f!==null,onClick:()=>void T(`apply`),children:[f===`apply`?(0,G.jsx)($r,{className:`size-3 animate-spin`}):null,`Apply`]}),(0,G.jsxs)(Y,{type:`button`,size:`sm`,variant:`ghost`,disabled:!a||f!==null,onClick:()=>void T(`clear`),title:a?`Remove the per-phase override and revert to workflow default`:`No override to clear`,children:[(0,G.jsx)(Pi,{className:`size-3`}),` Clear`]}),(0,G.jsxs)(Y,{type:`button`,size:`sm`,variant:`secondary`,disabled:f!==null||r&&i,onClick:()=>void T(`rerun`),title:r&&i?`Pause the job before re-running the live phase`:`Re-enter this phase, optionally with the chosen model`,children:[f===`rerun`?(0,G.jsx)($r,{className:`size-3 animate-spin`}):(0,G.jsx)(_i,{className:`size-3`}),`Re-run`]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{_(!1),h(null),d({provider:a?.provider??``,model:a?.model??``})},className:`text-[11px] text-fg-subtle hover:text-fg`,children:`Cancel`})]}),b!=null&&S!=null&&y?(0,G.jsxs)(`div`,{className:`text-[11px] text-fg-subtle`,children:[`For this phase's last run (`,y.inputTokens.toLocaleString(),` in /`,` `,y.outputTokens.toLocaleString(),` out tokens):`,` `,(0,G.jsxs)(`span`,{className:`text-fg`,children:[`$`,iC(S)]}),` →`,` `,(0,G.jsxs)(`span`,{className:`text-fg`,children:[`$`,iC(b)]}),C==null?null:(0,G.jsxs)(`span`,{className:C>0?`ml-1 text-warning-400`:C<0?`ml-1 text-success-400`:`ml-1 text-fg-subtle`,children:[`(`,C>=0?`+`:`−`,`$`,iC(Math.abs(C)),`)`]})]}):null,r&&i?(0,G.jsx)(`div`,{className:`rounded-lg border border-warning-400/30 bg-warning-500/5 px-2.5 py-1.5 text-[11px] leading-4 text-warning-100`,children:`This phase is running now. The override applies on the next selectModel call — the in-flight turn keeps its original model. Use “Re-run” to apply immediately.`}):null,m?(0,G.jsx)(`div`,{className:`rounded-lg border border-danger-400/40 bg-danger-500/5 px-2.5 py-1.5 text-[11px] text-danger-200`,children:m}):null]}):null]})}var fC=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Jo(`Primitive.${t}`),r=x.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,G.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),pC=`Separator`,mC=`horizontal`,hC=[`horizontal`,`vertical`],gC=x.forwardRef((e,t)=>{let{decorative:n,orientation:r=mC,...i}=e,a=_C(r)?r:mC,o=n?{role:`none`}:{"aria-orientation":a===`vertical`?a:void 0,role:`separator`};return(0,G.jsx)(fC.div,{"data-orientation":a,...o,...i,ref:t})});gC.displayName=pC;function _C(e){return hC.includes(e)}var vC=gC;function yC({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,G.jsx)(vC,{decorative:n,orientation:t,className:W(`shrink-0 bg-line`,t===`horizontal`?`h-px w-full`:`h-full w-px`,e),...r})}function bC(e){let[t,n]=(0,x.useState)(null),[r,i]=(0,x.useState)(!0),[a,o]=(0,x.useState)(null),s=(0,x.useCallback)(async()=>{if(e)try{n(await q(`/jobs/${e}`)),o(null)}catch(e){o(e instanceof Error?e.message:`Failed to fetch job`)}finally{i(!1)}},[e]);return(0,x.useEffect)(()=>{s()},[s]),{job:t,loading:r,error:a,refetch:s}}var xC=/^(\d{4}-\d{2}-\d{2}T[\d:.]+Z)\s+/;function SC(e){let t=e.replace(xC,``),n=t.toLowerCase();return t.startsWith(`→ `)?{content:t,lineType:`tool_use`}:t.startsWith(`[thinking]`)?{content:t,lineType:`thinking`}:t.startsWith(`[tool_summary]`)?{content:t,lineType:`tool_summary`}:t.startsWith(`⏳`)?{content:t,lineType:`tool_progress`}:t.startsWith(`[error]`)?{content:t,lineType:`error`}:t.startsWith(`[guardrail]`)?{content:t,lineType:`guardrail`}:t.startsWith(`[warning]`)?{content:t,lineType:`warning`}:t.startsWith(`[result]`)?{content:t,lineType:`result`}:t.startsWith(`[insight]`)?{content:t,lineType:`insight`}:t.startsWith(`[session-reset]`)?{content:t,lineType:`session_reset`}:t.startsWith(`[webhook]`)?{content:t,lineType:`webhook`}:t.startsWith(`[human]`)?{content:t,lineType:`human`}:t.startsWith(`[init]`)||t.startsWith(`[usage]`)||t.startsWith(`[phase-end]`)||t.startsWith(`[artifact]`)||t.startsWith(`[repo-cloned]`)||t.startsWith(`[campaign]`)||t.startsWith(`[control]`)||t.startsWith(`[sdk-stderr]`)||t.startsWith(`[event:`)||t.startsWith(`System prompt:`)?{content:t,lineType:`system`}:t.startsWith(`Phase advanced`)||t.startsWith(`Runner started`)||t.startsWith(`Job parked`)||t.startsWith(`All phases complete`)?{content:t,lineType:`phase`}:t.startsWith(`Runner crashed`)?{content:t,lineType:`error`}:n.includes(`here's what was accomplished`)||/\bphase (is )?complete\b/.test(n)?{content:t,lineType:`result`}:/\bphase started\b/.test(n)?{content:t,lineType:`phase`}:{content:t,lineType:`text`}}function CC(e){let t=e.match(xC);return t?t[1]:``}function wC(e,t=!0){let[n,r]=(0,x.useState)([]),[i,a]=(0,x.useState)(`connecting`),[o,s]=(0,x.useState)(Date.now()),c=(0,x.useRef)(null),l=(0,x.useRef)(!1),u=(0,x.useRef)(void 0),d=(0,x.useRef)(!0),f=(0,x.useCallback)(()=>{l.current=!0,c.current&&=(c.current.close(),null)},[]);return(0,x.useEffect)(()=>{if(!e)return;let n=u.current,i=d.current,o=n!==e,p=!i&&t;if(u.current=e,d.current=t,(o||p)&&r([]),!t){f(),a(`disconnected`);return}a(`connecting`),l.current=!1;let m=new EventSource(`/jobs/${e}/stream`);return c.current=m,m.onopen=()=>{a(`connected`),s(Date.now())},m.onmessage=e=>{s(Date.now());let t=e.data;if(!t||t.trim()===``)return;let n=CC(t),{content:i,lineType:a}=SC(t);r(e=>[...e,{timestamp:n,content:i,lineType:a}])},m.onerror=()=>{m.close(),c.current=null,l.current=!0,a(`disconnected`)},()=>{m.close(),c.current=null}},[f,e,t]),{lines:n,status:i,lastHeartbeat:o,disconnect:f}}function TC({tone:e,children:t}){return(0,G.jsx)(`span`,{className:W(`ml-1 inline-flex h-4 min-w-[16px] items-center justify-center rounded-full px-1 text-[10px] font-medium tabular-nums ring-1`,e===`warning`?`bg-warning-500/15 text-warning-300 ring-warning-500/30`:`bg-overlay text-fg-muted ring-line`),children:t})}function EC(e){if(!e)return[];if(e.workflowPhases&&e.workflowPhases.length>0)return e.workflowPhases;let t=new Set,n=[];for(let r of e.phaseUsage??[])t.has(r.phase)||(t.add(r.phase),n.push({name:r.phase,status:r.phase}));return t.has(e.phase)||n.push({name:e.phase,status:e.phase}),n}function DC({parentRunId:e}){return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[13px]`,children:[(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-line bg-overlay px-1.5 py-0.5 text-[10px] uppercase tracking-[0.14em] text-fg-subtle`,title:By.singular,children:[(0,G.jsx)(Cr,{className:`size-2.5`,"aria-hidden":!0}),By.singularLower]}),(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[`of`,` `,(0,G.jsx)(Dn,{to:My({id:e}),className:`inline-block max-w-[min(100%,28rem)] truncate align-bottom font-mono text-[12px] font-medium text-accent-300 underline-offset-2 hover:text-accent-400 hover:underline`,title:e,children:e})]})]})}function OC({job:e}){let t=Iy(e),n=Py(e),r=qy(e);return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(Dn,{to:Zy,className:`inline-flex items-center gap-1.5 text-sm text-fg-muted transition-colors hover:text-fg`,children:[(0,G.jsx)(nr,{className:`size-4`}),Vy.backToRuns]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[r?(0,G.jsx)(DC,{parentRunId:r}):null,(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h1`,{className:`text-[1.75rem] font-semibold tracking-tight text-fg sm:text-[2rem]`,children:Ny(e)}),(0,G.jsx)(yg,{status:e.status})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[12px] text-fg-subtle`,children:[(0,G.jsx)(`span`,{className:`rounded-md border border-line bg-overlay px-1.5 py-0.5 uppercase tracking-[0.14em]`,title:`Workflow`,children:Yy(e)}),Ky(e)?(0,G.jsx)(`span`,{className:`rounded-md border border-line bg-overlay px-1.5 py-0.5 uppercase tracking-[0.14em]`,title:`Hosts ${By.pluralLower}`,children:By.pluralLower}):null,(0,G.jsx)(`span`,{className:`font-mono`,children:e.id}),t?(0,G.jsxs)(`span`,{children:[`· `,t]}):null,(0,G.jsxs)(`span`,{children:[`· updated `,Cy(e.updatedAt)]})]}),n?(0,G.jsx)(kC,{description:n}):null]})]})}function kC({description:e}){let[t,n]=(0,x.useState)(!1);return e.length>140||e.includes(`
|
|
62
62
|
`)?(0,G.jsx)(`div`,{className:`max-w-3xl text-sm text-fg-muted`,children:(0,G.jsxs)(`div`,{className:W(`relative pr-9`,!t&&`line-clamp-2`),children:[(0,G.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:e}),(0,G.jsx)(`button`,{type:`button`,"aria-expanded":t,"aria-label":t?`Collapse description`:`Expand description`,onClick:()=>n(e=>!e),className:`absolute right-0 bottom-0 inline-flex size-6 items-center justify-center rounded-md border border-line bg-panel/95 text-fg-subtle shadow-[var(--shadow-card)] transition-[color,transform,background-color] hover:bg-panel-raised hover:text-fg`,children:(0,G.jsx)(lr,{className:W(`size-4 transition-transform`,t&&`rotate-180`)})})]})}):(0,G.jsx)(`p`,{className:`max-w-3xl text-sm text-fg-muted whitespace-pre-wrap break-words`,children:e})}function AC({label:e,value:t,detail:n}){return(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-overlay/40 p-4`,children:[(0,G.jsx)(`div`,{className:`text-[11px] uppercase tracking-[0.16em] text-fg-subtle`,children:e}),(0,G.jsx)(`div`,{className:`mt-1 text-xl font-semibold text-fg`,children:t}),n?(0,G.jsx)(`div`,{className:`mt-1 text-[12px] text-fg-muted`,children:n}):null]})}function jC({title:e,tone:t,children:n}){return(0,G.jsxs)(`div`,{className:W(`rounded-2xl border p-4`,{neutral:`border-line bg-overlay/40 text-fg`,accent:`border-accent-500/25 bg-accent-500/8 text-fg`,success:`border-success-500/25 bg-success-500/8 text-fg`,warning:`border-warning-500/25 bg-warning-500/8 text-fg`,danger:`border-danger-500/25 bg-danger-500/8 text-fg`}[t]),children:[(0,G.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:e}),(0,G.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:n})]})}function MC({usage:e}){if(!e)return(0,G.jsx)(lg,{children:(0,G.jsxs)(ug,{children:[(0,G.jsx)(dg,{children:`Token usage`}),(0,G.jsx)(fg,{children:`Token usage will populate once this job has run through at least one model turn.`})]})});let t=e.inputTokens+e.outputTokens,n=e.inputTokens+e.cacheCreationInputTokens,r=n>0?e.cacheReadInputTokens/n*100:0;return(0,G.jsxs)(lg,{children:[(0,G.jsxs)(ug,{children:[(0,G.jsx)(dg,{children:`Token usage`}),(0,G.jsx)(fg,{children:`Token footprint, cache efficiency, and spend for the full run.`})]}),(0,G.jsxs)(pg,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:[(0,G.jsx)(AC,{label:`Total`,value:wy(t),detail:`${wy(e.inputTokens)} in / ${wy(e.outputTokens)} out`}),(0,G.jsx)(AC,{label:`Cache read`,value:wy(e.cacheReadInputTokens),detail:`${wy(e.cacheCreationInputTokens)} cache writes`}),(0,G.jsx)(AC,{label:`Hit rate`,value:r>0?`${r.toFixed(0)}%`:`—`,detail:`Across cache-eligible requests`}),(0,G.jsx)(AC,{label:`Spend`,value:Ey(e.totalCostUsd),detail:`USD across all turns`})]})]})}function NC({phases:e}){return e.length?(0,G.jsxs)(lg,{children:[(0,G.jsxs)(ug,{children:[(0,G.jsx)(dg,{children:`Usage by phase`}),(0,G.jsx)(fg,{children:`Per-phase token consumption, wall time, and model selection.`})]}),(0,G.jsx)(pg,{className:`overflow-x-auto`,children:(0,G.jsxs)(`table`,{className:`w-full min-w-[680px] text-sm`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{className:`border-b border-line text-left text-[10px] uppercase tracking-[0.16em] text-fg-subtle`,children:[(0,G.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`Phase`}),(0,G.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`Input`}),(0,G.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`Output`}),(0,G.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`Duration`}),(0,G.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`Turns`}),(0,G.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:`Cost`}),(0,G.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:`Model`})]})}),(0,G.jsx)(`tbody`,{className:`divide-y divide-line text-fg`,children:e.map((e,t)=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`td`,{className:`px-2 py-3 font-medium text-fg`,children:e.phase}),(0,G.jsx)(`td`,{className:`px-2 py-3 text-right tabular-nums`,children:wy(e.inputTokens)}),(0,G.jsx)(`td`,{className:`px-2 py-3 text-right tabular-nums`,children:wy(e.outputTokens)}),(0,G.jsx)(`td`,{className:`px-2 py-3 text-right tabular-nums`,children:Dy(e.durationMs)}),(0,G.jsx)(`td`,{className:`px-2 py-3 text-right tabular-nums`,children:e.numTurns}),(0,G.jsx)(`td`,{className:`px-2 py-3 text-right tabular-nums`,children:Ey(e.costUsd)}),(0,G.jsx)(`td`,{className:`px-2 py-3 text-fg-muted`,children:e.model})]},`${e.phase}-${t}`))})]})})]}):(0,G.jsx)(lg,{children:(0,G.jsxs)(ug,{children:[(0,G.jsx)(dg,{children:`Usage by phase`}),(0,G.jsx)(fg,{children:`No phase-level usage snapshots have been recorded yet.`})]})})}function PC({job:e}){return!e.awaitingEvent&&!e.escalationMessage&&!e.rateLimitInfo?null:(0,G.jsxs)(`div`,{className:`space-y-3`,children:[e.status===`awaiting-rate-limit`&&e.rateLimitInfo?(0,G.jsx)(FC,{info:e.rateLimitInfo}):null,e.awaitingEvent&&e.status!==`awaiting-developer-input`&&e.status!==`awaiting-rate-limit`?(0,G.jsxs)(jC,{title:`Awaiting external event`,tone:`warning`,children:[e.awaitingEvent,e.awaitingPrId?` (PR #${e.awaitingPrId})`:``]}):null,e.escalationMessage?(0,G.jsx)(jC,{title:`Escalation message`,tone:`danger`,children:e.escalationMessage}):null]})}function FC({info:e}){let[t,n]=(0,x.useState)(()=>Date.now());(0,x.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]);let r=Math.max(0,e.resumeAt-t),i=Math.ceil(r/1e3),a=Math.floor(i/3600),o=Math.floor(i%3600/60),s=i%60,c=e=>e.toString().padStart(2,`0`),l=`${c(a)}:${c(o)}:${c(s)}`,u=e.kind===`overloaded`?`overloaded`:`rate-limit`;return(0,G.jsx)(jC,{title:r===0?`Provider ${u} — resuming…`:`Provider ${u} — auto-resume in ${l}`,tone:`warning`,children:(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsxs)(`div`,{children:[e.provider,` (attempt `,e.retryAttempt,`, source: `,e.source,`)`]}),e.lastErrorMessage?(0,G.jsx)(`div`,{className:`text-xs text-neutral-400 break-words`,children:e.lastErrorMessage}):null]})})}function IC({job:e,selectedPhase:t,phases:n,onSelectPhase:r,onMutated:i}){let a=t??e.phase,o=(e.artifacts??[]).filter(e=>e.phase===a),s=(e.phaseUsage??[]).find(e=>e.phase===a);return(0,G.jsxs)(lg,{children:[(0,G.jsx)(ug,{className:`border-b border-line pb-4`,children:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(dg,{children:jy(e.workflowPath)}),(0,G.jsxs)(fg,{children:[n.length,` phases · click any to inspect`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] uppercase tracking-[0.14em] text-fg-subtle`,children:[(0,G.jsx)(`span`,{children:`spend`}),(0,G.jsx)(vg,{variant:`neutral`,className:`border-line bg-overlay text-fg tabular-nums`,children:Ey(e.tokenUsage?.totalCostUsd??0)})]})]})}),(0,G.jsxs)(pg,{className:`space-y-5 pt-5`,children:[(0,G.jsx)(qS,{job:e,phases:n,selectedPhase:t,onSelectPhase:r}),(0,G.jsxs)(`div`,{className:`rounded-2xl border border-line bg-overlay/30 p-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,G.jsx)(`div`,{className:`text-[11px] uppercase tracking-[0.14em] text-fg-subtle`,children:`Selected phase`}),(0,G.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a})]}),s?(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-4 text-[12px] text-fg-muted`,children:[(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg-subtle`,children:`in`}),` `,(0,G.jsx)(`span`,{className:`tabular-nums text-fg`,children:wy(s.inputTokens)})]}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg-subtle`,children:`out`}),` `,(0,G.jsx)(`span`,{className:`tabular-nums text-fg`,children:wy(s.outputTokens)})]}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg-subtle`,children:`turns`}),` `,(0,G.jsx)(`span`,{className:`tabular-nums text-fg`,children:s.numTurns})]}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg-subtle`,children:`duration`}),` `,(0,G.jsx)(`span`,{className:`tabular-nums text-fg`,children:Dy(s.durationMs)})]})]}):null]}),(0,G.jsx)(`div`,{className:`mt-3`,children:(0,G.jsx)(kx,{jobId:e.id,artifacts:o,phaseName:a})}),(0,G.jsx)(`div`,{className:`mt-4`,children:(0,G.jsx)(dC,{job:e,phase:a,onMutated:i})})]}),(0,G.jsx)(QS,{job:e,phases:n,onSelectPhase:r})]})]})}function LC({title:e=`Send message`,description:t=`Send additional guidance into the live run. Multiple messages are allowed.`,submitLabel:n=`Send message`,value:r,onChange:i,onSend:a,error:o,onStepIn:s,steppedIn:c=!1,placeholder:l=`Tell the agent what changed, what to prioritize, or where to look next…`,textareaRef:u}){return(0,G.jsxs)(lg,{children:[(0,G.jsxs)(ug,{className:`gap-1.5 pb-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(dg,{children:e}),(0,G.jsx)(fg,{children:t})]}),s?(0,G.jsx)(Y,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>void s(),children:`Step in`}):null]}),c?(0,G.jsx)(`div`,{className:`rounded-lg border border-warning-500/25 bg-warning-500/8 px-3 py-2 text-xs text-warning-200`,children:`Paused — your next message will steer the run.`}):null]}),(0,G.jsxs)(pg,{className:`space-y-2.5 pt-0`,children:[o?(0,G.jsx)(gg,{message:o}):null,(0,G.jsx)(bb,{ref:u,rows:3,value:r,onChange:e=>i(e.target.value),placeholder:l,className:`min-h-24`}),(0,G.jsx)(`div`,{className:`flex justify-end`,children:(0,G.jsxs)(Y,{onClick:()=>void a(),disabled:!r.trim(),size:`sm`,children:[(0,G.jsx)(bi,{}),n]})})]})]})}function RC({messages:e}){return e.length===0?null:(0,G.jsxs)(`div`,{className:`border-t border-line pt-4`,children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-[11px] uppercase tracking-[0.14em] text-fg-subtle`,children:[(0,G.jsx)(yr,{className:`size-3.5`}),`Pending messages`]}),(0,G.jsx)(`div`,{className:`space-y-2`,children:e.map((e,t)=>(0,G.jsx)(`div`,{className:`rounded-xl border border-line bg-overlay/35 px-3 py-2.5`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,G.jsx)(yr,{className:`mt-0.5 size-3.5 shrink-0 text-warning-400`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`text-sm text-fg whitespace-pre-wrap break-words`,children:e.text}),(0,G.jsx)(`div`,{className:`mt-1 text-[11px] text-fg-subtle`,children:t===0?`Waiting for the next safe point. Queued ${Cy(e.queuedAt)}.`:`Queued behind ${t} earlier message${t===1?``:`s`} since ${Cy(e.queuedAt)}.`})]})]})},e.id))})]})}function zC({label:e,data:t,defaultOpen:n=!1}){let[r,i]=(0,x.useState)(n);return(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-line bg-overlay/30`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`flex w-full items-center justify-between gap-3 px-4 py-3 text-left transition-colors hover:bg-overlay/60`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e}),(0,G.jsx)(lr,{className:W(`size-4 text-fg-subtle transition-transform`,r&&`rotate-180`)})]}),r?(0,G.jsx)(`pre`,{className:`max-h-[420px] overflow-auto border-t border-line p-4 font-mono text-[12px] text-fg whitespace-pre-wrap break-words`,children:JSON.stringify(t,null,2)}):null]})}function BC({job:e}){let t=Fy(e),n=Iy(e),r=qy(e),i=[];return i.push({label:`Workflow`,value:Yy(e)}),i.push({label:`Phase`,value:e.phase}),n&&i.push({label:`Repository`,value:n}),t.length>0&&i.push({label:`Reviewers`,value:t.join(`, `)}),r&&i.push({label:Xy(),value:(0,G.jsx)(Dn,{to:My({id:r}),className:`font-mono text-accent-300 hover:text-accent-400`,children:r})}),e.prMappings&&e.prMappings.length>0&&i.push({label:`Pull requests`,value:(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-fg-muted`,children:[(0,G.jsx)(Hr,{className:`size-3.5`}),e.prMappings.length,` mapping`,e.prMappings.length===1?``:`s`]})}),(0,G.jsxs)(lg,{children:[(0,G.jsxs)(ug,{children:[(0,G.jsx)(dg,{children:`Context`}),(0,G.jsx)(fg,{children:`${zy.singular} metadata and coordination signals.`})]}),(0,G.jsx)(pg,{className:`space-y-3 text-sm`,children:i.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,G.jsx)(`span`,{className:`text-[11px] uppercase tracking-[0.14em] text-fg-subtle`,children:e.label}),(0,G.jsx)(`span`,{className:`text-right text-fg`,children:e.value})]},t))})]})}function VC(){let{jobId:e}=ot(),t=$e(),{job:n,loading:r,error:i,refetch:a}=bC(e),{lines:o,status:s,lastHeartbeat:c}=wC(e,n?!jo(n.status):!0),l=(0,x.useRef)(void 0),u=(0,x.useRef)(0),[d,f]=(0,x.useState)(`activity`),[p,m]=(0,x.useState)(null),[h,g]=(0,x.useState)(``),[_,v]=(0,x.useState)(!1),[y,b]=(0,x.useState)(!1),[S,C]=(0,x.useState)(null),[w,T]=(0,x.useState)(!1),[E,D]=(0,x.useState)(null),[O,k]=(0,x.useState)(!1),[A,j]=(0,x.useState)(null),[M,N]=(0,x.useState)(``),[ee,te]=(0,x.useState)(null),P=(0,x.useRef)(null),[F,I]=(0,x.useState)([]),[ne,re]=(0,x.useState)(!1),[ie,L]=(0,x.useState)(void 0),R=(0,x.useRef)([]),ae=(0,x.useRef)(!1),oe=(0,x.useRef)(0),se=n?Ay(n):!1;To(e?{id:e,kind:`run`,path:t.pathname,title:n?Ny(n):e,subtitle:n?.phase}:null),(0,x.useEffect)(()=>{l.current=void 0,u.current=0,m(null),oe.current+=1,R.current=[],ae.current=!1,I([])},[e]),(0,x.useEffect)(()=>{if(!n)return;let e=l.current;l.current=n.phase,m(t=>t===null||e===void 0||t===e?n.phase:t)},[n?.id,n?.phase]),(0,x.useEffect)(()=>{if(o.length<=u.current){u.current=o.length;return}let e=o.slice(u.current);u.current=o.length,e.some(e=>e.lineType===`phase`)&&a()},[o,a]),(0,x.useEffect)(()=>{if(!n||jo(n.status))return;let e=window.setInterval(()=>{a()},4e3);return()=>{window.clearInterval(e)}},[n?.id,n?.status,a]);let ce=(0,x.useMemo)(()=>EC(n??null),[n]);async function le(t,n=!1){if(e){k(!0),j(null);try{let r={};t&&(r.fromPhase=t),n&&(r.clearSession=!0),await q(`/jobs/${e}/resume`,J(r,{method:`POST`})),await a()}catch(e){j(e instanceof Error?e.message:`Resume failed`)}finally{k(!1)}}}async function ue(){if(e&&window.confirm(`Cancel this run? It will stop at the next safe boundary and will not auto-resume.`)){b(!0),C(null);try{await q(`/jobs/${e}/cancel`,J({},{method:`POST`})),await a()}catch(e){C(e instanceof Error?e.message:`Cancel failed`)}finally{b(!1)}}}async function de(){if(!e)return!1;T(!0),D(null);try{return await q(`/jobs/${e}/pause`,J({},{method:`POST`})),await a(),requestAnimationFrame(()=>P.current?.focus()),!0}catch(e){return D(e instanceof Error?e.message:`Pause failed`),!1}finally{T(!1)}}async function fe(){await de()}async function pe(){re(!0);try{await a()}finally{re(!1)}}(0,x.useEffect)(()=>{n&&ie!==void 0&&ie===n.interactive&&L(void 0)},[n?.interactive,ie]);function me(e){let t=e(R.current);R.current=t,I(t)}async function he(t){if(!e)throw Error(`No job id`);await q(`/jobs/${e}/message`,J({message:t},{method:`POST`})),a()}async function ge(){if(ae.current)return;ae.current=!0;let e=oe.current;try{for(;oe.current===e;){let t=R.current[0];if(!t)break;try{if(await he(t.text),oe.current!==e)return;te(null)}catch(t){if(oe.current!==e)return;te(t instanceof Error?t.message:`Failed to send message`)}finally{if(oe.current!==e)return;me(e=>e.filter(e=>e.id!==t.id))}}}finally{oe.current===e&&(ae.current=!1)}}async function _e(){let e=M.trim();e&&(te(null),N(``),me(t=>[...t,{id:crypto.randomUUID(),text:e,queuedAt:Date.now()}]),ge())}if(r)return(0,G.jsxs)(`div`,{className:`space-y-5`,children:[(0,G.jsx)(bg,{className:`h-32 w-full`}),(0,G.jsx)(bg,{className:`h-20 w-full`}),(0,G.jsx)(bg,{className:`h-12 w-full`}),(0,G.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(0,1fr)_320px]`,children:[(0,G.jsx)(bg,{className:`h-[520px] w-full`}),(0,G.jsx)(bg,{className:`h-[420px] w-full`})]})]});if(i||!n)return(0,G.jsx)(lg,{children:(0,G.jsxs)(pg,{className:`flex flex-col items-center gap-4 py-16 text-center`,children:[(0,G.jsx)(`div`,{className:`text-lg font-semibold text-fg`,children:i??`${zy.singular} not found`}),(0,G.jsx)(`p`,{className:`max-w-md text-sm text-fg-muted`,children:`The ${zy.singularLower} could not be loaded. It may have been deleted or the runner could not reach its backing state store.`}),(0,G.jsx)(Y,{asChild:!0,variant:`secondary`,children:(0,G.jsx)(Dn,{to:Zy,children:Vy.backToRuns})})]})});let ve=Io(n.status,n.awaitingEvent),ye=No(n.status)&&s!==`disconnected`||Mo(n.status)&&n.status!==`awaiting-developer-input`||ve,be=n.status===`escalated`;return(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsx)(OC,{job:n}),(0,G.jsx)(PC,{job:n}),(0,G.jsx)(kS,{job:n,workflowPhases:ce,refreshing:ne,onRefresh:pe,cancelling:y,cancelError:S,onCancel:ue,pausing:w,pauseError:E,onPause:de,resuming:O,resumeError:A,resumePhase:h,clearSession:_,onResumePhaseChange:g,onClearSessionChange:v,onResume:le,interactiveOverride:ie,onInteractiveChange:L}),(0,G.jsx)(IC,{job:n,selectedPhase:p,phases:ce,onSelectPhase:m,onMutated:()=>void a()}),se?(0,G.jsx)(Hx,{job:n,onMutated:()=>void a()}):null,(0,G.jsxs)(Bb,{value:d,onValueChange:e=>f(e),children:[(0,G.jsxs)(Vb,{children:[(0,G.jsxs)(Hb,{value:`activity`,children:[(0,G.jsx)($n,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),`Activity`,No(n.status)?(0,G.jsx)(`span`,{title:`Run is active`,className:`ml-1 inline-flex size-1.5 rounded-full bg-accent-400 animate-pulse-dot`}):null]}),(0,G.jsxs)(Hb,{value:`changes`,children:[(0,G.jsx)(Hr,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),`Changes`,vS(n)?(0,G.jsx)(`span`,{title:`A pull request is ready for your review`,className:`ml-1 inline-flex size-1.5 rounded-full bg-accent-400`}):null]}),(0,G.jsxs)(Hb,{value:`insights`,children:[(0,G.jsx)(Xr,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),`Insights`,(()=>{let e=(n.insights??[]).filter(e=>!e.sourceChildName&&(e.status??`pending`)===`pending`).length;return e>0?(0,G.jsx)(TC,{tone:`warning`,children:e}):null})()]}),(0,G.jsxs)(Hb,{value:`diagnostics`,children:[(0,G.jsx)(sr,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),`Diagnostics`,(()=>{let e=(n.tokenUsage?.inputTokens??0)+(n.tokenUsage?.outputTokens??0);return e>0?(0,G.jsx)(TC,{tone:`neutral`,children:wy(e)}):null})()]})]}),(0,G.jsx)(Ub,{value:`activity`,className:`space-y-5`,children:(0,G.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(0,1fr)_320px]`,children:[(0,G.jsxs)(`div`,{className:`space-y-5`,children:[n.status===`awaiting-developer-input`&&!ve?(0,G.jsx)(bx,{job:n,onSend:he,onCancel:ue,onViewChanges:()=>f(`changes`)}):null,be?(0,G.jsx)(LC,{title:`Reply to escalation`,description:`Send guidance back into the parked run. Your reply will resume the current phase in the existing job.`,submitLabel:`Send reply`,value:M,onChange:N,onSend:_e,error:ee}):null,(0,G.jsxs)(lg,{children:[(0,G.jsxs)(ug,{className:`gap-3 border-b border-line pb-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(dg,{children:`Live console`}),(0,G.jsx)(fg,{children:`Streaming runner output, tool execution summaries, and developer interventions.`})]}),(0,G.jsx)(Wx,{status:s,lastHeartbeat:c})]}),(0,G.jsxs)(pg,{className:`space-y-4 pt-5`,children:[(0,G.jsx)(VS,{lines:o}),(0,G.jsx)(RC,{messages:F})]})]}),ye?(0,G.jsx)(LC,{value:M,onChange:N,onSend:_e,error:ee,onStepIn:Lo(n.status,n.awaitingEvent)?fe:void 0,steppedIn:ve,placeholder:ve?`Tell Coro what to change before continuing…`:void 0,textareaRef:P}):null]}),(0,G.jsx)(`div`,{className:`space-y-4`,children:(0,G.jsx)(BC,{job:n})})]})}),(0,G.jsx)(Ub,{value:`changes`,className:`space-y-5`,children:(0,G.jsx)(bS,{job:n,live:!jo(n.status)})}),(0,G.jsx)(Ub,{value:`insights`,className:`space-y-5`,children:(0,G.jsx)(Zx,{jobId:n.id,insights:n.insights??[],onChanged:()=>void a()})}),(0,G.jsxs)(Ub,{value:`diagnostics`,className:`space-y-5`,children:[(0,G.jsx)(MC,{usage:n.tokenUsage}),(0,G.jsx)(NC,{phases:n.phaseUsage??[]}),(0,G.jsxs)(lg,{children:[(0,G.jsxs)(ug,{className:`border-b border-line pb-4`,children:[(0,G.jsx)(dg,{children:`Raw state`}),(0,G.jsx)(fg,{children:`Inspect the underlying job object, parameters, and PR mappings. Insights have moved to their own tab.`})]}),(0,G.jsxs)(pg,{className:`space-y-3 pt-5`,children:[(0,G.jsx)(zC,{label:`Job parameters`,data:n.params,defaultOpen:!0}),(0,G.jsx)(zC,{label:`Full job object`,data:n}),n.prMappings?.length>0?(0,G.jsx)(zC,{label:`PR mappings (${n.prMappings.length})`,data:n.prMappings}):null]})]})]})]}),(0,G.jsx)(yC,{className:`opacity-0`})]})}var HC={base:{label:`Coro`,Icon:ii,tone:`bg-fg/8 text-fg-muted ring-line`,description:`Ships with the Coro runner. Read-only — override in your Custom or Repo layer.`},tenant:{label:`Custom`,Icon:Yr,tone:`bg-accent-500/15 text-accent-200 ring-accent-500/30`,description:`Your custom overlay (~/.coro/intelligence). Edit here to apply across every repo.`},repo:{label:`Repo`,Icon:Si,tone:`bg-success/15 text-success ring-success/30`,description:`The target repo's .coro/ folder. Edit here for repo-local customisations.`}};function UC({layer:e,overrides:t,size:n=`md`,className:r}){let i=HC[e],a=i.Icon;return(0,G.jsxs)(`span`,{title:t?`${i.description}\nOverrides ${HC[t].label.toLowerCase()} layer.`:i.description,className:W(`inline-flex items-center gap-1 rounded-md font-medium uppercase tracking-wide ring-1`,n===`sm`?`px-1.5 py-0.5 text-[10px]`:`px-2 py-0.5 text-[11px]`,i.tone,r),children:[(0,G.jsx)(a,{className:n===`sm`?`size-2.5`:`size-3`}),i.label,t?(0,G.jsxs)(`span`,{className:`ml-0.5 normal-case text-[10px] opacity-70`,children:[`↳ overrides `,HC[t].label.toLowerCase()]}):null]})}function WC({tone:e,children:t,title:n}){let r={accent:`bg-accent-500/15 text-accent-200 ring-accent-500/30`,warning:`bg-warning-500/12 text-warning-200 ring-warning-500/30`,muted:`bg-overlay/60 text-fg-muted ring-line`,model:`bg-overlay/60 text-fg-muted ring-line`}[e];return(0,G.jsx)(`span`,{title:n,className:W(`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide ring-1`,r),children:t})}function GC({workflow:e,compact:t=!1}){let n=e.phases??[];return n.length===0?(0,G.jsx)(`div`,{className:`rounded-xl border border-line bg-overlay/30 p-3 text-xs text-fg-muted`,children:`No phase information available.`}):(0,G.jsx)(`ol`,{className:W(`space-y-1.5`,t&&`space-y-1`),children:n.map((r,i)=>{let a=r.name===e.initialPhase,o=i===n.length-1;return(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`div`,{className:W(`rounded-xl border px-3 transition-colors`,t?`py-2`:`py-3`,a?`border-accent-500/40 bg-accent-500/5`:`border-line bg-overlay/30`),children:(0,G.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,G.jsx)(`span`,{className:W(`mt-0.5 inline-flex size-5 shrink-0 items-center justify-center rounded-full text-[10px] font-mono ring-1`,a?`bg-accent-500/20 ring-accent-500/40 text-accent-200`:`bg-overlay/60 ring-line text-fg-muted`),children:i+1}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1`,children:[(0,G.jsx)(`span`,{className:W(`font-medium text-fg`,t?`text-xs`:`text-sm`),children:r.name}),a?(0,G.jsxs)(WC,{tone:`accent`,children:[(0,G.jsx)(pr,{className:`size-2.5`}),`Start`]}):null,(0,G.jsx)(WC,{tone:`model`,children:r.model}),r.interactiveCheckpoint?(0,G.jsxs)(WC,{tone:`warning`,title:`Runner pauses for your approval before advancing when interactive mode is on`,children:[(0,G.jsx)(hr,{className:`size-2.5`}),`Checkpoint`]}):null]}),t?null:(0,G.jsxs)(`div`,{className:`mt-1 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,G.jsx)(ar,{className:`size-3 shrink-0`}),r.agent?(0,G.jsx)(`span`,{className:`font-mono`,children:r.agent}):(0,G.jsx)(`span`,{className:`italic`,children:`Runner-managed`})]})]})]})}),o?null:(0,G.jsx)(`div`,{className:`flex justify-center py-0.5`,children:(0,G.jsx)(tr,{className:`size-3 text-fg-subtle`})})]},r.name)})})}function KC({workflow:e,open:t,onOpenChange:n}){return(0,G.jsx)(c_,{open:t,onOpenChange:n,children:(0,G.jsxs)(d_,{className:`flex max-w-2xl flex-col gap-0 max-h-[min(720px,calc(100vh-2rem))]`,children:[(0,G.jsx)(f_,{className:`shrink-0`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`span`,{className:`inline-flex size-9 shrink-0 items-center justify-center rounded-xl bg-accent-500/15 ring-1 ring-accent-500/30 text-accent-200`,children:(0,G.jsx)(B,{className:`size-4`})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(p_,{children:e?.name??`Workflow`}),e?.layer?(0,G.jsx)(UC,{layer:e.layer,overrides:e.overrides}):null]}),e?(0,G.jsx)(m_,{className:`font-mono text-[11px] text-fg-subtle`,children:e.workflowPath}):null]})]})}),(0,G.jsxs)(h_,{className:`flex-1 min-h-0 space-y-5`,children:[e?.description?(0,G.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:e.description}):null,e&&e.phases&&e.phases.length>0?(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,G.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-fg-subtle`,children:`Phases`}),(0,G.jsxs)(`span`,{className:`text-[11px] text-fg-subtle`,children:[e.phases.length,` phase`,e.phases.length===1?``:`s`]})]}),(0,G.jsx)(GC,{workflow:e})]}):(0,G.jsx)(`div`,{className:`rounded-xl border border-line bg-overlay/30 p-4 text-sm text-fg-muted`,children:`No phase information available for this workflow.`}),e?(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-line pt-4 text-xs text-fg-subtle`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{children:`From`}),e.layer?(0,G.jsx)(UC,{layer:e.layer,overrides:e.overrides,size:`sm`}):(0,G.jsx)(`span`,{className:`font-mono`,children:qC(e.source)}),e.layer&&e.source?(0,G.jsx)(`span`,{className:`font-mono text-[10px] opacity-60`,title:e.source,children:qC(e.source)}):null]}),e.kind===`job`?null:(0,G.jsxs)(WC,{tone:`muted`,children:[(0,G.jsx)(Er,{className:`size-2.5`}),e.kind]})]}):null]})]})})}function qC(e){if(!e)return`unknown`;let t=e.split(`/`).filter(Boolean);return t.length<=2?e:`…/`+t.slice(-2).join(`/`)}function JC({workflow:e,interactive:t,mode:n,serviceName:r,repo:i,ticketId:a,formValid:o,loading:s=!1}){if(s||!e)return(0,G.jsxs)(`div`,{className:`space-y-3 rounded-2xl border border-line bg-overlay/30 p-5`,children:[(0,G.jsx)(bg,{className:`h-5 w-2/3`}),(0,G.jsx)(bg,{className:`h-4 w-full`}),(0,G.jsx)(bg,{className:`h-32 w-full`})]});let c=e.phases?.[0]?.name??`the first phase`,l=e.phases?.length??0,u=t?`Coro starts at ${c} and pauses at every checkpoint for your approval.`:`Coro runs end-to-end and opens a PR. You can pause or message it mid-run.`,d=n===`manual`?r?.trim()||i?.trim()||`Your run details`:a?.trim()||`Tracker ticket run`;return(0,G.jsxs)(`div`,{className:W(`space-y-4 rounded-2xl border border-line bg-overlay/30 p-5 transition-opacity`,!o&&`opacity-50`),children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-[0.16em] text-fg-subtle`,children:`What will happen`}),(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:e.name}),e.layer?(0,G.jsx)(UC,{layer:e.layer,overrides:e.overrides,size:`sm`}):null,(0,G.jsx)(`span`,{className:`rounded-md border border-line bg-overlay/60 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-fg-muted`,children:e.kind})]}),e.description?(0,G.jsx)(`p`,{className:`mt-1.5 text-xs leading-relaxed text-fg-muted`,children:e.description}):null,(0,G.jsx)(`p`,{className:`mt-1 text-xs font-medium text-fg`,children:d})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-2 text-[11px] font-semibold uppercase tracking-wider text-fg-subtle`,children:`Phases`}),(0,G.jsx)(GC,{workflow:e,compact:!0})]}),(0,G.jsx)(`div`,{className:`rounded-xl border border-line bg-overlay/40 px-3 py-2.5 text-xs leading-relaxed text-fg-muted`,children:u}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,G.jsx)(br,{className:`size-3.5 shrink-0 text-fg-subtle`}),(0,G.jsx)(`span`,{children:ho(e.workflowPath,l)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-2 text-[11px] font-semibold uppercase tracking-wider text-fg-subtle`,children:`Mid-run controls`}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(YC,{icon:oi,label:`Pause`}),(0,G.jsx)(YC,{icon:ni,label:`Message`}),(0,G.jsx)(YC,{icon:ir,label:`Cancel`})]})]}),(0,G.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:`Token cost shows live on the run page.`})]})}function YC({icon:e,label:t}){return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-line bg-overlay/50 px-2.5 py-1 text-[11px] font-medium text-fg-muted`,children:[(0,G.jsx)(e,{className:`size-3 text-fg-subtle`}),t]})}var XC={"bug-fix":{label:`Bug fix`,icon:`🐛`,blurb:`Investigate and fix broken behaviour.`},refactor:{label:`Refactor`,icon:`♻️`,blurb:`Clean up structure without changing behaviour.`},"feature-small":{label:`Small feature`,icon:`✨`,blurb:`Scoped additions to existing code.`},"feature-medium":{label:`Medium feature`,icon:`🚀`,blurb:`Multi-file changes with clear acceptance criteria.`},tests:{label:`Tests`,icon:`🧪`,blurb:`Add or improve test coverage.`},docs:{label:`Documentation`,icon:`📝`,blurb:`Update README or inline docs.`},dependency:{label:`Dependency`,icon:`📦`,blurb:`Bump packages and fix breakage.`},"tracker-triage":{label:`Tracker ticket`,icon:`🎫`,blurb:`Start from an issue in your tracker.`}},ZC=[{id:`add-validation`,category:`feature-small`,title:`Add input validation`,preview:`Validate request payloads on an endpoint with clear error messages.`,description:"Add input validation to the `<endpoint>` endpoint. Return 400 with a structured error body when validation fails. Include unit tests for the happy path and at least two failure cases.",mode:`manual`,tags:[`validation`,`api`,`endpoint`]},{id:`fix-flaky-test`,category:`bug-fix`,title:`Fix a flaky test`,preview:`Investigate timing or ordering issues causing intermittent failures.`,description:"The test `<test file>` is flaky. Investigate the root cause, fix it, and add a brief comment explaining what made it unstable. The test must pass reliably when run 10 times in a row.",mode:`manual`,tags:[`test`,`flaky`,`ci`]},{id:`extract-helper`,category:`refactor`,title:`Extract a shared helper`,preview:`Pull repeated logic into a reusable function without changing behaviour.`,description:"Extract the repeated `<pattern>` block into a shared helper. Update all call sites to use it. Behaviour must remain identical — no functional changes. Add or update tests if coverage would drop.",mode:`manual`,tags:[`refactor`,`dedupe`]},{id:`add-rate-limit`,category:`feature-small`,title:`Add rate limiting`,preview:`Protect an endpoint with token-bucket or similar limiting.`,description:"Add rate limiting to `<endpoint>` using the existing `<library>` utility. Return clear retry-after headers when a caller exceeds the limit. Include acceptance criteria: limit applies per caller, headers are present, and existing tests still pass.",mode:`manual`,tags:[`rate-limit`,`api`,`security`]},{id:`bump-dependency`,category:`dependency`,title:`Bump a dependency`,preview:`Upgrade a package to the latest compatible version.`,description:"Bump `<package>` to the latest minor version compatible with our runtime. Fix any compile or test breakage. Summarise breaking API changes in the PR description.",mode:`manual`,tags:[`dependency`,`upgrade`]},{id:`improve-readme`,category:`docs`,title:`Update README`,preview:`Document a new feature or changed behaviour in the README.`,description:"Update the README to reflect the new `<feature>`. Include setup steps if they changed, and add a short usage example. Keep the tone consistent with the existing doc.",mode:`manual`,tags:[`docs`,`readme`]},{id:`add-unit-tests`,category:`tests`,title:`Add unit tests`,preview:`Cover a module with focused unit tests for edge cases.`,description:"Add unit-test coverage for `<module>` focusing on `<edge cases>`. Follow existing test conventions in the repo. Tests must be deterministic and not require network access.",mode:`manual`,tags:[`tests`,`coverage`]},{id:`triage-ticket`,category:`tracker-triage`,title:`Work from a tracker ticket`,preview:`Switch to ticket mode — Coro pulls scope from your issue tracker.`,description:``,mode:`ticket`,tags:[`jira`,`linear`,`ticket`]}],QC=`coro.promptTemplates.recent`;function $C(){if(typeof window>`u`)return[];try{let e=window.localStorage.getItem(QC);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`).slice(0,3):[]}catch{return[]}}function ew(e){if(typeof window>`u`)return;let t=$C().filter(t=>t!==e);window.localStorage.setItem(QC,JSON.stringify([e,...t].slice(0,3)))}function tw(e){let t=e.match(/<[^>]+>/);return!t||t.index===void 0?null:{start:t.index,end:t.index+t[0].length}}function nw({open:e,onOpenChange:t,onSelect:n,hasExistingDescription:r}){let[i,a]=(0,x.useState)(`feature-small`),[o,s]=(0,x.useState)(``),c=(0,x.useMemo)(()=>e?$C():[],[e]),l=(0,x.useMemo)(()=>{let e=o.trim().toLowerCase(),t=i===`recent`?c.map(e=>ZC.find(t=>t.id===e)).filter(e=>!!e):ZC.filter(e=>e.category===i);return e&&(t=ZC.filter(t=>t.title.toLowerCase().includes(e)||t.preview.toLowerCase().includes(e)||t.tags?.some(t=>t.includes(e)))),t},[i,o,c]);function u(e){r&&e.description&&!window.confirm(`Replace your current description with this example?`)||(ew(e.id),n(e),t(!1))}let d=Object.keys(XC);return(0,G.jsx)(c_,{open:e,onOpenChange:t,children:(0,G.jsxs)(d_,{className:`flex max-w-3xl flex-col gap-0 max-h-[min(720px,calc(100vh-2rem))]`,children:[(0,G.jsxs)(f_,{className:`shrink-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Di,{className:`size-4 text-accent-300`}),(0,G.jsx)(p_,{children:`Start from an example`})]}),(0,G.jsx)(m_,{children:`Pick a template to pre-fill your description. Swap in your repo, endpoints, and specifics.`})]}),(0,G.jsxs)(h_,{className:`flex min-h-0 flex-1 flex-col gap-4`,children:[(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(yi,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`}),(0,G.jsx)(O_,{value:o,onChange:e=>s(e.target.value),placeholder:`Search examples…`,className:`pl-9`})]}),(0,G.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-4 md:grid-cols-[180px_minmax(0,1fr)]`,children:[(0,G.jsxs)(`nav`,{className:`space-y-1 overflow-y-auto`,children:[c.length>0?(0,G.jsx)(rw,{active:i===`recent`,label:`Recent`,blurb:`Recently used`,onClick:()=>a(`recent`)}):null,d.map(e=>(0,G.jsx)(rw,{active:i===e,label:XC[e].label,blurb:XC[e].blurb,count:ZC.filter(t=>t.category===e).length,onClick:()=>a(e)},e))]}),(0,G.jsx)(`div`,{className:`min-h-0 space-y-2 overflow-y-auto pr-1`,children:l.length===0?(0,G.jsx)(`div`,{className:`rounded-xl border border-line bg-overlay/30 p-4 text-sm text-fg-muted`,children:`No examples match your search.`}):l.map(e=>(0,G.jsx)(`div`,{className:`rounded-xl border border-line bg-overlay/30 p-4 transition-colors hover:border-line-strong`,children:(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.title}),(0,G.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:e.preview})]}),(0,G.jsx)(Y,{type:`button`,size:`sm`,variant:`secondary`,onClick:()=>u(e),children:`Use this`})]})},e.id))})]})]})]})})}function rw({active:e,label:t,blurb:n,count:r,onClick:i}){return(0,G.jsxs)(`button`,{type:`button`,onClick:i,className:W(`w-full rounded-lg border px-3 py-2 text-left text-sm transition-colors`,e?`border-accent-500/40 bg-accent-500/10 text-fg`:`border-transparent text-fg-muted hover:bg-overlay/50 hover:text-fg`),children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:t}),r===void 0?null:(0,G.jsx)(`span`,{className:`text-[10px] tabular-nums text-fg-subtle`,children:r})]}),(0,G.jsx)(`div`,{className:`mt-0.5 text-[11px] leading-4 text-fg-subtle`,children:n})]})}function iw({onClick:e}){return(0,G.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:e,className:`shrink-0`,children:[(0,G.jsx)(Di,{className:`size-3.5`}),`Start from an example`]})}function aw(e){return e.split(`,`).map(e=>e.trim()).filter(Boolean)}function ow(e,t){let n=e.match(/<brief>\s*([\s\S]*?)\s*<\/brief>/i);if(!n?.[1])return null;let r;try{r=JSON.parse(n[1].trim())}catch{return null}if(!r||typeof r!=`object`)return null;let i=r,a=typeof i.repo==`string`?i.repo.trim():``,o=typeof i.serviceName==`string`?i.serviceName.trim():``,s=typeof i.description==`string`?i.description.trim():``,c=typeof i.workflowPath==`string`?i.workflowPath.trim():``,l=i.interactive!==!1;if(!a||s.length<20||!t.includes(c))return null;let u=``;return Array.isArray(i.reviewers)?u=i.reviewers.filter(e=>typeof e==`string`&&e.trim().length>0).join(`, `):typeof i.reviewers==`string`&&(u=i.reviewers.trim()),{repo:a,serviceName:o||a.split(`/`).pop()||a,description:s,reviewers:u,workflowPath:c,interactive:l}}function sw(e,t=5){let n=[],r=[],i=new Set,a=new Set,o=[...e].sort((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime());for(let e of o){let o=typeof e.params?.repo==`string`&&e.params.repo||typeof e.params?.repoSlug==`string`&&e.params.repoSlug||``;o&&!i.has(o)&&(i.add(o),n.push(o));let s=e.params?.reviewers;if(Array.isArray(s))for(let e of s)typeof e==`string`&&e.trim()&&!a.has(e.trim())&&(a.add(e.trim()),r.push(e.trim()));if(n.length>=t&&r.length>=t)break}return{recentRepos:n.slice(0,t),recentReviewers:r.slice(0,t)}}function cw(e,t,n,r=3){let i=t.toLowerCase().split(/\W+/).filter(e=>e.length>3);return i.length===0&&!n?[]:e.filter(e=>![`cancelled`,`canceled`].includes(e.status)).map(e=>{let t=0,r=typeof e.params?.repo==`string`&&e.params.repo||typeof e.params?.repoSlug==`string`&&e.params.repoSlug||``;n&&r===n&&(t+=5);let a=(typeof e.params?.description==`string`&&e.params.description||typeof e.params?.serviceName==`string`&&e.params.serviceName||``).toLowerCase();for(let e of i)a.includes(e)&&(t+=1);return{job:e,score:t}}).filter(e=>e.score>0).sort((e,t)=>t.score-e.score).slice(0,r).map(e=>e.job)}function lw(){let[e,t]=(0,x.useState)(!1),[n,r]=(0,x.useState)(null),[i,a]=(0,x.useState)(!1),[o,s]=(0,x.useState)([]),c=(0,x.useRef)(null),l=(0,x.useRef)(typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`intake-${Date.now()}`),[u,d]=(0,x.useState)(0),[f,p]=(0,x.useState)(0),m=(0,x.useCallback)(()=>{c.current?.abort(),c.current=null,t(!1),s([])},[]),h=(0,x.useCallback)(async(e,n,i,o,u)=>{r(null),a(!1),t(!0),s([]),c.current?.abort();let f=new AbortController;c.current=f;let m=``,h=[],g=()=>{s([...h]),u?.([...h])};try{let t=await fetch(`/intake/stream`,{...J({sessionId:l.current,messages:e.map(e=>({role:e.role,content:e.content})),...o?.model?.trim()?{model:o.model.trim(),...o.provider?.trim()?{provider:o.provider.trim()}:{}}:{},context:{recentRepos:n.recentRepos,recentReviewers:n.recentReviewers,availableWorkflows:n.availableWorkflows.map(e=>({id:e.id,name:e.name,workflowPath:e.workflowPath,description:e.description})),userLocale:n.userLocale??navigator.language}},{method:`POST`}),signal:f.signal});if(!t.ok){let e=await t.json().catch(()=>({}));if(t.status===503||e.reason===`no-llm`)return a(!0),{assistantText:``,toolCalls:[],noLlm:!0,error:e.error??`No LLM provider configured`};throw Error(e.error??`Plan mode failed (${t.status})`)}if(!t.body)throw Error(`No response body from plan mode stream`);let r=t.body.getReader(),c=new TextDecoder,u=``,_;for(;;){let{done:e,value:t}=await r.read();if(e)break;u+=c.decode(t,{stream:!0});let n=u.split(`
|
|
63
63
|
|
|
64
64
|
`);u=n.pop()??``;for(let e of n)for(let t of e.split(`
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<meta name="application-name" content="Coro" />
|
|
8
8
|
<meta name="apple-mobile-web-app-title" content="Coro" />
|
|
9
9
|
<title>Coro</title>
|
|
10
|
-
<script type="module" crossorigin src="/dashboard/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/dashboard/assets/index-DVdRvXW2.js"></script>
|
|
11
11
|
<link rel="stylesheet" crossorigin href="/dashboard/assets/index-V3YMhXZt.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body class="bg-zinc-950 text-zinc-100 antialiased">
|
|
@@ -70,18 +70,17 @@ export declare class GitHubClient {
|
|
|
70
70
|
private readonly baseUrl;
|
|
71
71
|
constructor(owner: string, token: string, baseUrl?: string);
|
|
72
72
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* - `owner/repo`
|
|
76
|
-
* - `https://github.com/owner/repo`
|
|
77
|
-
* - `https://github.com/owner/repo.git`
|
|
78
|
-
* - `git@github.com:owner/repo.git`
|
|
73
|
+
* Build the `<owner>/<repo>` segment of an API path from whatever shape
|
|
74
|
+
* the caller had on hand.
|
|
79
75
|
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
76
|
+
* Every method that addresses a repository MUST go through this. Jobs are
|
|
77
|
+
* routinely started with `--repo owner/repo`, and that string is stored
|
|
78
|
+
* verbatim as the external ref's `repoKey`. Interpolating it raw after the
|
|
79
|
+
* configured owner yields `/repos/<owner>/<owner>/<repo>/…`, which 404s —
|
|
80
|
+
* and because the poller reads those 404s as "the PR is gone", a job can
|
|
81
|
+
* be failed over a purely cosmetic difference in how the repo was named.
|
|
83
82
|
*/
|
|
84
|
-
private
|
|
83
|
+
private repoPath;
|
|
85
84
|
createRepo(opts: CreateRepoOptions): Promise<{
|
|
86
85
|
full_name: string;
|
|
87
86
|
}>;
|
|
@@ -121,6 +120,18 @@ export declare class GitHubClient {
|
|
|
121
120
|
content: string;
|
|
122
121
|
}>;
|
|
123
122
|
}>>;
|
|
123
|
+
/**
|
|
124
|
+
* Coerce any of these input shapes into an `{ owner, repo }` pair:
|
|
125
|
+
* - `repo` → configured owner
|
|
126
|
+
* - `owner/repo` → that owner (may differ from config)
|
|
127
|
+
* - `https://github.com/owner/repo` → that owner
|
|
128
|
+
* - `https://github.com/owner/repo.git` → that owner
|
|
129
|
+
* - `git@github.com:owner/repo.git` → that owner
|
|
130
|
+
*
|
|
131
|
+
* An explicit owner always wins over the configured one so cross-org
|
|
132
|
+
* repositories address correctly instead of being silently rewritten to
|
|
133
|
+
* the configured org.
|
|
134
|
+
*/
|
|
124
135
|
private parseRepo;
|
|
125
136
|
private request;
|
|
126
137
|
private listAll;
|