ghost-api-cli 0.2.0__py3-none-any.whl

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.
Files changed (125) hide show
  1. ghost_api/__init__.py +3 -0
  2. ghost_api/__main__.py +5 -0
  3. ghost_api/adopt.py +173 -0
  4. ghost_api/agent/__init__.py +0 -0
  5. ghost_api/agent/orchestrator.py +413 -0
  6. ghost_api/agent/prompts.py +149 -0
  7. ghost_api/agent/tools.py +84 -0
  8. ghost_api/analysis/__init__.py +0 -0
  9. ghost_api/analysis/analyzer.py +130 -0
  10. ghost_api/analysis/detectors.py +188 -0
  11. ghost_api/analysis/exposure.py +80 -0
  12. ghost_api/analysis/graphql.py +67 -0
  13. ghost_api/analysis/models.py +64 -0
  14. ghost_api/analysis/schema.py +109 -0
  15. ghost_api/analysis/url_grouping.py +217 -0
  16. ghost_api/api.py +264 -0
  17. ghost_api/audit.py +78 -0
  18. ghost_api/browser/__init__.py +0 -0
  19. ghost_api/browser/auth_state.py +172 -0
  20. ghost_api/browser/driver.py +273 -0
  21. ghost_api/browser/egress.py +183 -0
  22. ghost_api/browser/gate.py +127 -0
  23. ghost_api/browser/install.py +28 -0
  24. ghost_api/browser/snapshot.py +221 -0
  25. ghost_api/capture/__init__.py +0 -0
  26. ghost_api/capture/filters.py +255 -0
  27. ghost_api/capture/har.py +148 -0
  28. ghost_api/capture/models.py +41 -0
  29. ghost_api/capture/personal.py +188 -0
  30. ghost_api/capture/recorder.py +181 -0
  31. ghost_api/cli/__init__.py +44 -0
  32. ghost_api/cli/_common.py +219 -0
  33. ghost_api/cli/client.py +487 -0
  34. ghost_api/cli/data.py +492 -0
  35. ghost_api/cli/explore.py +379 -0
  36. ghost_api/cli/manage.py +437 -0
  37. ghost_api/config.py +132 -0
  38. ghost_api/drift.py +344 -0
  39. ghost_api/drive.py +211 -0
  40. ghost_api/errors.py +106 -0
  41. ghost_api/events.py +213 -0
  42. ghost_api/exitcodes.py +21 -0
  43. ghost_api/export/__init__.py +71 -0
  44. ghost_api/export/confidence.py +45 -0
  45. ghost_api/export/html.py +41 -0
  46. ghost_api/export/openapi.py +201 -0
  47. ghost_api/export/report.py +227 -0
  48. ghost_api/export/site_data.py +196 -0
  49. ghost_api/export/tabular.py +88 -0
  50. ghost_api/export/viewer/report.html +286 -0
  51. ghost_api/generator/__init__.py +221 -0
  52. ghost_api/generator/cassettes.py +80 -0
  53. ghost_api/generator/models_gen.py +144 -0
  54. ghost_api/generator/naming.py +174 -0
  55. ghost_api/generator/package.py +197 -0
  56. ghost_api/generator/python_gen.py +172 -0
  57. ghost_api/generator/spec.py +486 -0
  58. ghost_api/generator/templates/client.py.j2 +518 -0
  59. ghost_api/generator/templates/client.test.ts.j2 +106 -0
  60. ghost_api/generator/templates/client.ts.j2 +339 -0
  61. ghost_api/generator/templates/models.py.j2 +45 -0
  62. ghost_api/generator/templates/package_readme.md.j2 +111 -0
  63. ghost_api/generator/templates/pyproject.toml.j2 +22 -0
  64. ghost_api/generator/templates/test_client.py.j2 +105 -0
  65. ghost_api/generator/ts_gen.py +232 -0
  66. ghost_api/integrations/__init__.py +0 -0
  67. ghost_api/integrations/claude_code/commands/ghost-data.md +10 -0
  68. ghost_api/integrations/claude_code/commands/ghost-diff.md +10 -0
  69. ghost_api/integrations/claude_code/commands/ghost-explore.md +10 -0
  70. ghost_api/integrations/claude_code/skills/ghost-api/SKILL.md +46 -0
  71. ghost_api/integrations/setup.py +84 -0
  72. ghost_api/llm/__init__.py +0 -0
  73. ghost_api/llm/doctor.py +60 -0
  74. ghost_api/llm/gateway.py +476 -0
  75. ghost_api/llm/providers.py +124 -0
  76. ghost_api/memory/__init__.py +0 -0
  77. ghost_api/memory/knowledge.py +157 -0
  78. ghost_api/memory/store.py +883 -0
  79. ghost_api/net.py +235 -0
  80. ghost_api/netguard.py +203 -0
  81. ghost_api/pipeline.py +745 -0
  82. ghost_api/probe/__init__.py +0 -0
  83. ghost_api/probe/prober.py +311 -0
  84. ghost_api/probe/replay.py +313 -0
  85. ghost_api/project.py +186 -0
  86. ghost_api/py.typed +0 -0
  87. ghost_api/runtime.py +397 -0
  88. ghost_api/serve/__init__.py +101 -0
  89. ghost_api/serve/explorer_mcp.py +305 -0
  90. ghost_api/serve/mcp.py +121 -0
  91. ghost_api/serve/mock.py +130 -0
  92. ghost_api/serve/rest.py +132 -0
  93. ghost_api/site.py +84 -0
  94. ghost_api/specdiff.py +122 -0
  95. ghost_api/ui/__init__.py +0 -0
  96. ghost_api/ui/keys.py +134 -0
  97. ghost_api/ui/repl.py +453 -0
  98. ghost_api/ui/terminal.py +573 -0
  99. ghost_api/verify/__init__.py +0 -0
  100. ghost_api/verify/classify.py +84 -0
  101. ghost_api/verify/repair.py +40 -0
  102. ghost_api/verify/runner.py +110 -0
  103. ghost_api/verify/verifier.py +291 -0
  104. ghost_api/watch.py +313 -0
  105. ghost_api/web/__init__.py +1 -0
  106. ghost_api/web/server.py +690 -0
  107. ghost_api/web/static/assets/Endpoints-zPnjlcM8.js +46 -0
  108. ghost_api/web/static/assets/Run-D85zWHey.js +91 -0
  109. ghost_api/web/static/assets/Settings-D0aWHFAt.js +11 -0
  110. ghost_api/web/static/assets/Site-a88shEmP.js +71 -0
  111. ghost_api/web/static/assets/Watches-CqZWIa9G.js +16 -0
  112. ghost_api/web/static/assets/circle-x-BcTE_1tr.js +11 -0
  113. ghost_api/web/static/assets/index-Ds2e5B9f.js +141 -0
  114. ghost_api/web/static/assets/index-xQpyIBbG.css +1 -0
  115. ghost_api/web/static/assets/minus-C2xqP1eQ.js +6 -0
  116. ghost_api/web/static/assets/refresh-cw-CxdR_8Oi.js +6 -0
  117. ghost_api/web/static/favicon.svg +1 -0
  118. ghost_api/web/static/index.html +26 -0
  119. ghost_api/workflows.py +203 -0
  120. ghost_api_cli-0.2.0.dist-info/METADATA +1019 -0
  121. ghost_api_cli-0.2.0.dist-info/RECORD +125 -0
  122. ghost_api_cli-0.2.0.dist-info/WHEEL +5 -0
  123. ghost_api_cli-0.2.0.dist-info/entry_points.txt +2 -0
  124. ghost_api_cli-0.2.0.dist-info/licenses/LICENSE +21 -0
  125. ghost_api_cli-0.2.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,46 @@
1
+ import{c as d,j as e,b as x,P as u,r as j,E as S,v as L,p as g,M as v,w as b,x as C,B as A}from"./index-Ds2e5B9f.js";/**
2
+ * @license lucide-react v0.468.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const D=d("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
7
+ * @license lucide-react v0.468.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const P=d("ArrowRightLeft",[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);/**
12
+ * @license lucide-react v0.468.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const G=d("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
17
+ * @license lucide-react v0.468.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const z=d("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
22
+ * @license lucide-react v0.468.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const M=d("Layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]);/**
27
+ * @license lucide-react v0.468.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const E=d("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/**
32
+ * @license lucide-react v0.468.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const k=d("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/**
37
+ * @license lucide-react v0.468.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const H=d("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
42
+ * @license lucide-react v0.468.0 - ISC
43
+ *
44
+ * This source code is licensed under the ISC license.
45
+ * See the LICENSE file in the root directory of this source tree.
46
+ */const q=d("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),$={pan:"PAN number",gstin:"GST number",aadhaar:"Aadhaar number",bank_account:"bank account number",card:"card number",upi:"UPI ID",email:"email address",phone:"phone number",date_of_birth:"date of birth",account_holder:"account holder's name"},I=s=>$[s]??s;function R({exposure:s}){return e.jsxs(u,{className:s.severity==="high"?"bg-bad/15 text-bad":"bg-warn/15 text-warn",title:`Returns ${s.kinds.join(", ")}${s.open?" without a login":""}`,children:[e.jsx(k,{className:"size-3"})," Personal data"]})}function B({exposure:s}){const n=s.severity==="high";return e.jsxs("section",{"aria-label":"Personal data exposed",className:x("rounded-xl border p-3 sm:p-4",n?"border-bad/40 bg-bad/5":"border-warn/40 bg-warn/5"),children:[e.jsxs("h4",{className:x("flex items-center gap-2 text-sm font-semibold",n?"text-bad":"text-warn"),children:[e.jsx(k,{className:"size-4","aria-hidden":!0}),"Personal data ",s.open?"exposed without a login":"in this endpoint's replies"]}),e.jsx("p",{className:"mt-1 text-sm text-muted",children:"Ghost API hid these values: they are not stored, shown or exported. Examples are masked."}),e.jsx("div",{className:"mt-3 overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"text-left text-xs text-muted",children:e.jsxs("tr",{children:[e.jsx("th",{className:"py-1.5 pr-3 font-medium",children:"Field"}),e.jsx("th",{className:"py-1.5 pr-3 font-medium",children:"What"}),e.jsx("th",{className:"py-1.5 pr-3 font-medium",children:"Seen"}),e.jsx("th",{className:"py-1.5 font-medium",children:"Example"})]})}),e.jsx("tbody",{children:s.fields.map(r=>e.jsxs("tr",{className:"border-t border-line/70 align-top",children:[e.jsx("td",{className:"py-1.5 pr-3 font-mono text-xs break-all",children:r.path}),e.jsxs("td",{className:"py-1.5 pr-3",children:[I(r.kind),r.severity==="high"&&e.jsx("span",{className:"ml-1 text-xs text-bad",children:"(sensitive)"})]}),e.jsx("td",{className:"py-1.5 pr-3 tabular-nums",children:r.count}),e.jsx("td",{className:"py-1.5 font-mono text-xs text-muted",children:r.example})]},`${r.path}-${r.kind}`))})]})}),e.jsx("p",{className:"mt-3 text-xs text-muted",children:"If this is your site, stop returning these fields or require a login. If it isn't, don't collect or share them, and consider telling the site owner privately."})]})}function O(s,n){const r=s===1?"1 endpoint":`${s} endpoints`;return n?`${r} ${s===1?"exposes":"expose"} personal data without a login`:`${r} ${s===1?"returns":"return"} personal data`}function V({endpoints:s}){const n=s.map(l=>l.exposure).filter(l=>!!l);if(!n.length)return null;const r=n.filter(l=>l.open),a=[...new Set((r.length?r:n).flatMap(l=>l.kinds))].sort(),t=n.some(l=>l.severity==="high");return e.jsxs("div",{role:"alert",className:x("flex items-start gap-3 rounded-xl border px-4 py-3 text-sm",t?"border-bad/40 bg-bad/10":"border-warn/40 bg-warn/10"),children:[e.jsx(k,{className:x("mt-0.5 size-5 shrink-0",t?"text-bad":"text-warn"),"aria-hidden":!0}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-semibold",children:[O(r.length||n.length,r.length>0),": ",a.join(", ")]}),e.jsx("p",{className:"mt-0.5 text-muted",children:'Ghost API hid these values. Open an endpoint marked "Personal data" to see which fields.'})]})]})}function y(s){var r;if((r=s.anyOf)!=null&&r.length)return s.anyOf.map(y).join(" | ");const n=Array.isArray(s.type)?s.type.join(" | "):s.type??"any";return n==="array"&&s.items?`array of ${y(s.items)}`:n}function N(s){if(s.properties)return s;if(s.items)return N(s.items);for(const n of s.anyOf??[]){const r=N(n);if(r)return r}return null}function _({name:s,schema:n,required:r,depth:a}){const t=N(n),[l,h]=j.useState(a<1),m=Object.entries((t==null?void 0:t.properties)??{});return e.jsxs("li",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",style:{paddingLeft:`${a*14}px`},children:[m.length?e.jsx("button",{type:"button",onClick:()=>h(!l),"aria-expanded":l,"aria-label":`${l?"Collapse":"Expand"} ${s}`,className:"rounded p-0.5 text-muted hover:bg-surface-2 hover:text-fg",children:e.jsx(z,{className:x("size-3.5 transition",l&&"rotate-90")})}):e.jsx("span",{className:"w-[18px]"}),e.jsx("span",{className:"font-mono text-[13px]",children:s}),!r&&e.jsx("span",{className:"text-xs text-muted",children:"optional"}),e.jsx("span",{className:"ml-auto truncate pl-2 font-mono text-xs text-accent",children:y(n)})]}),l&&m.length>0&&e.jsx("ul",{children:m.map(([c,p])=>{var i;return e.jsx(_,{name:c,schema:p,required:((i=t==null?void 0:t.required)==null?void 0:i.includes(c))??!1,depth:a+1},c)})})]})}function w({schema:s,rootName:n="response"}){return e.jsx("ul",{className:"rounded-lg border border-line bg-surface-2/40 p-2","aria-label":`${n} fields`,children:e.jsx(_,{name:n,schema:s,required:!0,depth:0})})}function F({endpoint:s,selected:n,onSelect:r,compact:a}){const t=s;return e.jsxs("button",{type:"button",onClick:r,"aria-pressed":n,className:x("w-full rounded-xl border bg-surface p-3 text-left transition",n?"border-accent ring-2 ring-accent/20":"border-line hover:border-accent/50"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{method:t.method}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-sm",title:t.path,children:t.path})]}),!a&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:[e.jsx(b,{status:t.status,title:t.status_note}),e.jsx(C,{confidence:t.confidence}),t.pagination&&e.jsxs(u,{children:[e.jsx(M,{className:"size-3"})," ",t.pagination.style]}),t.auth_type&&e.jsxs(u,{children:[e.jsx(E,{className:"size-3"})," ",t.auth_type]}),t.third_party&&e.jsx(u,{children:t.host}),t.exposure&&e.jsx(R,{exposure:t.exposure})]}),t.fields&&e.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-muted",children:t.fields})]}),a&&e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[e.jsx(b,{status:t.status}),e.jsx("span",{className:"text-xs text-muted",children:g(t.samples,"sample")})]})]})}function U({endpoints:s,selected:n,onSelect:r,compact:a}){const[t,l]=j.useState(""),[h,m]=j.useState(!1),c=s.filter(i=>i.third_party).length,p=j.useMemo(()=>{const i=t.trim().toLowerCase();return s.filter(f=>(h||!f.third_party)&&(!i||f.label.toLowerCase().includes(i)||f.fields.toLowerCase().includes(i)))},[s,t,h]);return s.length?e.jsxs("div",{className:"space-y-2",children:[s.length>4&&e.jsxs("label",{className:"flex items-center gap-2 rounded-lg border border-line bg-surface px-2.5 py-1.5",children:[e.jsx(L,{className:"size-4 text-muted","aria-hidden":!0}),e.jsx("input",{value:t,onChange:i=>l(i.target.value),placeholder:"Filter endpoints","aria-label":"Filter endpoints",className:"w-full bg-transparent text-sm outline-none placeholder:text-muted"})]}),c>0&&e.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted",children:[e.jsx("input",{type:"checkbox",checked:h,onChange:i=>m(i.target.checked)}),"Show ",g(c,"third-party endpoint")]}),e.jsx("ul",{className:"space-y-2",children:p.map(i=>e.jsx("li",{children:e.jsx(F,{endpoint:i,compact:a,selected:n===i.key,onSelect:r?()=>r(i.key):void 0})},i.key))}),!p.length&&e.jsx("p",{className:"py-4 text-center text-sm text-muted",children:"No endpoint matches."})]}):e.jsx(S,{icon:e.jsx(P,{className:"size-7"}),title:"No endpoints yet",children:"API calls the site makes appear here as they are captured."})}function o({label:s,children:n}){return e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted",children:s}),e.jsx("dd",{className:"mt-0.5 text-sm break-words",children:n})]})}function X({endpoint:s,onClose:n,tryIt:r}){const a=s;return e.jsxs("article",{className:"space-y-5","aria-label":a.label,children:[e.jsxs("header",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{method:a.method}),e.jsx("h3",{className:"min-w-0 font-mono text-base font-semibold break-all",children:a.path})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[e.jsx(b,{status:a.status}),e.jsx(C,{confidence:a.confidence})]}),a.status_note&&e.jsx("p",{className:"mt-2 text-sm text-muted",children:a.status_note})]}),n&&e.jsx(A,{variant:"ghost",onClick:n,"aria-label":"Close details",className:"px-2",children:e.jsx(q,{className:"size-4"})})]}),e.jsxs("dl",{className:"grid grid-cols-2 gap-3 rounded-xl border border-line p-3 sm:grid-cols-4",children:[e.jsx(o,{label:"Host",children:a.host}),e.jsx(o,{label:"Seen",children:g(a.samples,"time")}),e.jsx(o,{label:"Statuses",children:a.statuses.join(", ")||"none"}),e.jsx(o,{label:"Auth",children:a.auth_type??"none"}),a.pagination&&e.jsxs(o,{label:"Pagination",children:[a.pagination.style," by ",e.jsx("span",{className:"font-mono",children:a.pagination.param}),a.pagination.confirmed?" (tested)":""]}),a.required_headers.length>0&&e.jsx(o,{label:"Required headers",children:e.jsx("span",{className:"font-mono",children:a.required_headers.join(", ")})})]}),a.exposure&&e.jsx(B,{exposure:a.exposure}),a.params.length>0&&e.jsxs("section",{children:[e.jsx("h4",{className:"mb-2 text-sm font-semibold",children:"Parameters"}),e.jsx("div",{className:"overflow-x-auto rounded-xl border border-line",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-surface-2/60 text-left text-xs text-muted",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 font-medium",children:"Name"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"In"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Type"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Examples"})]})}),e.jsx("tbody",{children:a.params.map(t=>e.jsxs("tr",{className:"border-t border-line",children:[e.jsx("td",{className:"px-3 py-2 font-mono",children:t.name}),e.jsx("td",{className:"px-3 py-2 text-muted",children:t.location}),e.jsx("td",{className:"px-3 py-2 font-mono text-accent",children:t.type}),e.jsx("td",{className:"px-3 py-2 font-mono text-xs text-muted",children:t.sensitive?"hidden":t.examples.slice(0,3).join(", ")})]},t.name))})]})})]}),a.request_schema&&e.jsxs("section",{children:[e.jsx("h4",{className:"mb-2 text-sm font-semibold",children:"Request body"}),e.jsx(w,{schema:a.request_schema,rootName:"body"})]}),a.response_schema&&e.jsxs("section",{children:[e.jsx("h4",{className:"mb-2 text-sm font-semibold",children:"Response"}),e.jsx(w,{schema:a.response_schema})]}),a.example_urls.length>0&&e.jsxs("section",{children:[e.jsx("h4",{className:"mb-2 text-sm font-semibold",children:"Seen at"}),e.jsx("ul",{className:"space-y-1 font-mono text-xs text-muted",children:a.example_urls.slice(0,5).map(t=>e.jsx("li",{className:"break-all",children:t},t))})]}),r&&e.jsxs("section",{children:[e.jsx("h4",{className:"mb-2 text-sm font-semibold",children:"Use this endpoint"}),r]})]})}export{D as A,G as C,U as E,H as S,z as a,V as b,X as c};
@@ -0,0 +1,91 @@
1
+ import{c as d,r as h,j as e,a as C,E as $,b as u,p as g,P as j,G as P,A as N,u as R,d as T,e as I,f as z,B as w,C as S,S as E,g as v,T as F,L as V,h as O,s as B}from"./index-Ds2e5B9f.js";import{C as H,S as G,A as K,a as U,E as Q}from"./Endpoints-zPnjlcM8.js";import{M as D}from"./minus-C2xqP1eQ.js";import{C as X,a as J}from"./circle-x-BcTE_1tr.js";/**
2
+ * @license lucide-react v0.468.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const W=d("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
7
+ * @license lucide-react v0.468.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const Z=d("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
12
+ * @license lucide-react v0.468.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const Y=d("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
17
+ * @license lucide-react v0.468.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const ee=d("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);/**
22
+ * @license lucide-react v0.468.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const se=d("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/**
27
+ * @license lucide-react v0.468.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const te=d("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/**
32
+ * @license lucide-react v0.468.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const ne=d("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/**
37
+ * @license lucide-react v0.468.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const ae=d("FlaskConical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]);/**
42
+ * @license lucide-react v0.468.0 - ISC
43
+ *
44
+ * This source code is licensed under the ISC license.
45
+ * See the LICENSE file in the root directory of this source tree.
46
+ */const re=d("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
47
+ * @license lucide-react v0.468.0 - ISC
48
+ *
49
+ * This source code is licensed under the ISC license.
50
+ * See the LICENSE file in the root directory of this source tree.
51
+ */const ie=d("Keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);/**
52
+ * @license lucide-react v0.468.0 - ISC
53
+ *
54
+ * This source code is licensed under the ISC license.
55
+ * See the LICENSE file in the root directory of this source tree.
56
+ */const le=d("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
57
+ * @license lucide-react v0.468.0 - ISC
58
+ *
59
+ * This source code is licensed under the ISC license.
60
+ * See the LICENSE file in the root directory of this source tree.
61
+ */const ce=d("MonitorPlay",[["path",{d:"M10 7.75a.75.75 0 0 1 1.142-.638l3.664 2.249a.75.75 0 0 1 0 1.278l-3.664 2.25a.75.75 0 0 1-1.142-.64z",key:"1pctta"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}]]);/**
62
+ * @license lucide-react v0.468.0 - ISC
63
+ *
64
+ * This source code is licensed under the ISC license.
65
+ * See the LICENSE file in the root directory of this source tree.
66
+ */const oe=d("MousePointerClick",[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]);/**
67
+ * @license lucide-react v0.468.0 - ISC
68
+ *
69
+ * This source code is licensed under the ISC license.
70
+ * See the LICENSE file in the root directory of this source tree.
71
+ */const de=d("MoveVertical",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m8 18 4 4 4-4",key:"bh5tu3"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}]]);/**
72
+ * @license lucide-react v0.468.0 - ISC
73
+ *
74
+ * This source code is licensed under the ISC license.
75
+ * See the LICENSE file in the root directory of this source tree.
76
+ */const he=d("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/**
77
+ * @license lucide-react v0.468.0 - ISC
78
+ *
79
+ * This source code is licensed under the ISC license.
80
+ * See the LICENSE file in the root directory of this source tree.
81
+ */const pe=d("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);/**
82
+ * @license lucide-react v0.468.0 - ISC
83
+ *
84
+ * This source code is licensed under the ISC license.
85
+ * See the LICENSE file in the root directory of this source tree.
86
+ */const xe=d("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
87
+ * @license lucide-react v0.468.0 - ISC
88
+ *
89
+ * This source code is licensed under the ISC license.
90
+ * See the LICENSE file in the root directory of this source tree.
91
+ */const ue=d("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);function me({runId:i,shot:t,url:s,live:a}){const[l,n]=h.useState(null),r=(t==null?void 0:t.box)??null;return e.jsxs("div",{className:"overflow-hidden rounded-xl border border-line bg-surface",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-line bg-surface-2/60 px-3 py-2",children:[e.jsxs("span",{className:"flex gap-1","aria-hidden":!0,children:[e.jsx("span",{className:"size-2.5 rounded-full bg-bad/60"}),e.jsx("span",{className:"size-2.5 rounded-full bg-warn/60"}),e.jsx("span",{className:"size-2.5 rounded-full bg-ok/60"})]}),e.jsx("span",{className:"min-w-0 flex-1 truncate rounded-md bg-surface px-2 py-0.5 font-mono text-xs text-muted",children:s||"about:blank"}),a&&e.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium text-bad",children:[e.jsx("span",{className:"size-1.5 animate-pulse rounded-full bg-bad"}),"LIVE"]})]}),e.jsx("div",{className:"relative aspect-video bg-surface-2",children:i!==null&&t&&l!==t.name?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:C.screenUrl(i,t.name),alt:`What the agent saw (${t.name})`,onError:()=>n(t.name),className:"absolute inset-0 size-full object-contain"},t.name),r&&r.viewport_width>0&&e.jsx("div",{className:"pointer-events-none absolute rounded-md border-2 border-accent shadow-[0_0_0_4px_color-mix(in_oklab,var(--accent)_25%,transparent)]",style:{left:`${r.x/r.viewport_width*100}%`,top:`${r.y/r.viewport_height*100}%`,width:`${r.width/r.viewport_width*100}%`,height:`${r.height/r.viewport_height*100}%`},"aria-hidden":!0})]}):e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx($,{icon:e.jsx(ce,{className:"size-8"}),title:"No screenshot yet",children:"The agent's view of the page appears here as it works."})})})]})}const A={runId:null,domain:"",startUrl:"",goal:"",mode:"",lang:"python",phase:"checks",phasesSeen:[],timeline:[],endpoints:[],requests:0,thirdParty:0,screenshot:null,usage:null,client:null,rounds:[],probes:null,finished:null,lastSeq:0};function ge(i,t){if(t.type==="reset")return A;const s=t.event;if(s.seq&&s.seq<=i.lastSeq)return i;const a={...i,lastSeq:s.seq||i.lastSeq},l=n=>({...a,timeline:[...a.timeline,n]});switch(s.type){case"run_started":return{...a,runId:s.run_id,domain:s.domain,startUrl:s.start_url,goal:s.goal,mode:s.mode,lang:s.lang};case"phase":return{...a,phase:s.phase,phasesSeen:a.phasesSeen.includes(s.phase)?a.phasesSeen:[...a.phasesSeen,s.phase]};case"notice":return l({id:s.seq,kind:"notice",text:s.text,level:s.level,detail:s.detail});case"request":return{...a,requests:a.requests+1,thirdParty:a.thirdParty+(s.third_party?1:0)};case"step":{const n=l({id:s.seq,kind:"step",step:s.step,action:s.action,args:s.args,thought:s.thought,result:s.result,newEndpoints:s.new_endpoints,requests:s.requests,screenshot:s.screenshot,box:s.box});return s.screenshot?{...n,screenshot:{name:s.screenshot,box:s.box}}:n}case"screenshot":return{...a,screenshot:{name:s.name,box:null}};case"endpoints":return{...a,endpoints:s.endpoints};case"hypothesis":return l({id:s.seq,kind:"hypothesis",endpoint:s.endpoint,text:s.text,result:s.result,evidence:s.evidence});case"probe_done":return{...a,probes:{endpoints:s.endpoints,directCalls:s.direct_calls}};case"verify_round":return{...l({id:s.seq,kind:"round",round:s}),rounds:[...a.rounds,s]};case"client":return{...l({id:s.seq,kind:"client",client:s}),client:s};case"usage":return{...a,usage:s};case"run_finished":return{...a,finished:s,phase:"done",phasesSeen:a.phasesSeen.includes("done")?a.phasesSeen:[...a.phasesSeen,"done"]};default:return a}}const M=[{phase:"explore",label:"Explore"},{phase:"test",label:"Test"},{phase:"generate",label:"Generate"},{phase:"verify",label:"Verify"},{phase:"learn",label:"Learn"}];function ye(i){const t=["checks",...M.map(a=>a.phase),"done"],s=t.indexOf(i.phase);return M.map(({phase:a})=>{const l=t.indexOf(a);return i.finished||l<s?i.phasesSeen.includes(a)?"done":"skipped":l===s?"active":"todo"})}const fe={done:H,active:le,todo:Z,skipped:D};function je({states:i}){return e.jsx("ol",{className:"flex flex-wrap items-center gap-x-1 gap-y-2","aria-label":"Run progress",children:M.map((t,s)=>{const a=i[s]??"todo",l=fe[a];return e.jsxs("li",{className:"flex items-center gap-1",children:[s>0&&e.jsx("span",{className:u("h-px w-4 sm:w-6",a==="todo"?"bg-line":"bg-accent/50")}),e.jsxs("span",{"aria-current":a==="active"?"step":void 0,className:u("flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium",a==="done"&&"bg-ok/15 text-ok",a==="active"&&"bg-accent-soft text-accent",a==="todo"&&"bg-surface-2 text-muted",a==="skipped"&&"text-muted line-through decoration-muted/50"),children:[e.jsx(l,{className:u("size-3.5",a==="active"&&"animate-spin"),"aria-hidden":!0}),t.label,e.jsxs("span",{className:"sr-only",children:["(",a,")"]})]})]},t.phase)})})}const ke={click:oe,type:ie,scroll:de,navigate:P,go_back:K,call_endpoint:pe,ask_user:W,finish:ne},be={info:{icon:re,className:"text-muted"},success:{icon:J,className:"text-ok"},warning:{icon:ue,className:"text-warn"},error:{icon:X,className:"text-bad"}};function ve(i,t){const s=t;switch(i){case"click":return`Click element #${String(s.element_id??"?")}`;case"type":return`Type "${String(s.text??"")}"${s.submit?" and press Enter":""}`;case"scroll":return`Scroll ${String(s.direction??"down")}`;case"navigate":return`Open ${String(s.url??"")}`;case"go_back":return"Go back";case"call_endpoint":return`Call ${String(s.endpoint??"")}`;case"ask_user":return`Ask: ${String(s.question??"")}`;case"finish":return"Finish";default:return i}}function m({icon:i,iconClass:t,title:s,children:a,details:l,onSelect:n,selected:r}){const[c,o]=h.useState(!1);return e.jsxs("li",{className:u("relative flex gap-3 rounded-lg px-2 py-2 transition",r&&"bg-accent-soft/60",n&&"cursor-pointer hover:bg-surface-2"),onClick:n,children:[e.jsx("span",{className:u("mt-0.5 shrink-0",t??"text-accent"),children:i}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium break-words",children:s}),a&&e.jsx("div",{className:"mt-0.5 text-sm text-muted break-words",children:a}),l&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:x=>{x.stopPropagation(),o(!c)},"aria-expanded":c,className:"mt-1 inline-flex items-center gap-0.5 text-xs text-muted hover:text-fg",children:[e.jsx(U,{className:u("size-3 transition",c&&"rotate-90")}),c?"Hide details":"Details"]}),c&&e.jsx("div",{className:"mt-1 text-xs text-muted",children:l})]})]})]})}function Ne({items:i,selectedShot:t,onSelectShot:s,follow:a=!0}){const l=h.useRef(null);return h.useEffect(()=>{const n=l.current;if(!a||!n)return;n.scrollHeight-n.scrollTop-n.clientHeight<160&&(n.scrollTop=n.scrollHeight)},[i.length,a]),e.jsx("div",{ref:l,className:"h-full overflow-y-auto px-2 py-2",children:e.jsx("ol",{"aria-live":"polite","aria-relevant":"additions",className:"space-y-0.5",children:i.map(n=>{switch(n.kind){case"notice":{const{icon:r,className:c}=be[n.level];return e.jsx(m,{icon:e.jsx(r,{className:"size-4"}),iconClass:c,title:e.jsx("span",{className:n.level==="info"?"font-normal":"",children:e.jsx(N,{text:n.text})}),details:n.detail?e.jsx("pre",{className:"font-mono whitespace-pre-wrap",children:n.detail}):void 0},n.id)}case"step":{const r=ke[n.action]??P,c=n.screenshot;return e.jsxs(m,{icon:e.jsx(r,{className:"size-4"}),title:e.jsxs("span",{className:"flex flex-wrap items-center gap-x-2",children:[e.jsxs("span",{className:"text-xs font-semibold text-muted",children:["Step ",n.step]}),ve(n.action,n.args)]}),selected:!!c&&c===t,onSelect:c&&s?()=>s({name:c,box:n.box}):void 0,details:n.result?e.jsx("pre",{className:"font-mono whitespace-pre-wrap",children:n.result}):void 0,children:[n.thought&&e.jsxs("p",{className:"italic",children:["“",e.jsx(N,{text:n.thought}),"”"]}),e.jsxs("p",{className:"mt-1 flex flex-wrap items-center gap-1.5 text-xs",children:[e.jsx("span",{children:g(n.requests,"new request")}),n.newEndpoints.map(o=>e.jsxs(j,{className:"bg-accent-soft text-accent",children:["+ ",o]},o))]})]},n.id)}case"hypothesis":{const r=n.result==="confirmed",c=n.result==="rejected";return e.jsx(m,{icon:e.jsx(ae,{className:"size-4"}),iconClass:r?"text-ok":c?"text-bad":"text-warn",title:e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs",children:n.endpoint}),e.jsx(j,{className:r?"bg-ok/15 text-ok":c?"bg-bad/15 text-bad":"bg-warn/15 text-warn",children:n.result})]}),details:n.evidence?e.jsx("span",{children:n.evidence}):void 0,children:n.text},n.id)}case"round":{const r=n.round,c=r.failed===0;return e.jsx(m,{icon:e.jsx(G,{className:"size-4"}),iconClass:c?"text-ok":"text-warn",title:`Verification round ${r.number}: ${r.passed} passed, ${r.failed} failed${r.skipped?`, ${r.skipped} skipped`:""}`,details:r.failures.length||r.repairs.length?e.jsxs("ul",{className:"space-y-1",children:[r.failures.map(o=>e.jsxs("li",{children:[e.jsx("span",{className:"font-mono text-bad",children:o.name}),": ",o.message]},o.name)),r.repairs.map(o=>e.jsxs("li",{children:["Repaired ",e.jsx("span",{className:"font-mono",children:o.method})," (",o.kind,"): ",o.action]},`${o.method}-${o.kind}`))]}):void 0},n.id)}case"client":{const r=n.client;return e.jsxs(m,{icon:e.jsx(ee,{className:"size-4"}),iconClass:"text-info",title:e.jsxs("span",{children:["Generated ",e.jsx("span",{className:"font-mono",children:r.class_name})," (",r.lang,") with"," ",g(r.methods.length,"method")]}),children:[r.methods.slice(0,6).map(c=>c.name).join(", "),r.methods.length>6?"…":""]},n.id)}}})})})}function we(i){const[t,s]=h.useReducer(ge,A),[a,l]=h.useState("connecting");return h.useEffect(()=>{if(s({type:"reset"}),i===null)return;l("connecting");const n=new EventSource(C.eventsUrl(i));return n.onopen=()=>l("live"),n.onmessage=r=>{try{s({type:"event",event:JSON.parse(r.data)})}catch{}},n.addEventListener("end",()=>{l("ended"),n.close()}),n.onerror=()=>l(r=>r==="ended"?r:"error"),()=>n.close()},[i]),{state:t,status:a}}function f({icon:i,label:t,value:s}){return e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-surface-2/60 px-3 py-2",children:[e.jsx("span",{className:"text-muted",children:i}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] text-muted",children:t}),e.jsx("div",{className:"text-sm font-semibold tabular-nums",children:s})]})]})}function Se({state:i}){const t=i.finished;if(!t)return null;const s=!["failed","interrupted"].includes(t.status);return e.jsx(S,{className:u("p-4",s?"border-ok/40":"border-warn/40"),children:e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("h2",{className:"font-semibold",children:[s?"Done":"Stopped",": ",g(t.endpoints,"endpoint")," found in ",Math.round(t.seconds)," s"]}),e.jsxs("p",{className:"text-sm text-muted",children:[t.status,t.reason&&e.jsxs(e.Fragment,{children:[" · ",e.jsx(N,{text:t.reason})]}),t.lessons_learned?` · ${g(t.lessons_learned,"lesson")} saved for next time`:""]}),t.generation_error&&e.jsx("p",{className:"mt-1 text-sm text-bad",children:t.generation_error})]}),e.jsx(V,{to:`/sites/${B(i.domain)}`,children:e.jsxs(w,{variant:"primary",children:["Open results ",e.jsx(O,{className:"size-4"})]})})]})})}function ze(){const i=Number(R().id),{state:t,status:s}=we(Number.isFinite(i)?i:null),[a,l]=h.useState(null),[n,r]=h.useState("timeline"),c=T(),o=t.finished!==null||s==="ended";h.useEffect(()=>{o&&(c.invalidateQueries({queryKey:["state"]}),c.invalidateQueries({queryKey:["sites"]}),c.invalidateQueries({queryKey:["site",t.domain]}))},[o,s,c,t.domain]);const x=I({mutationFn:()=>C.stopRun(i)}),k=!o,L=a??t.screenshot,p=t.usage;if(!Number.isFinite(i))return e.jsx(z,{error:"Not a run number."});const q=e.jsxs("div",{className:"space-y-3",children:[e.jsx(me,{runId:t.runId,shot:L,url:t.startUrl,live:k}),a&&e.jsx(w,{variant:"ghost",onClick:()=>l(null),className:"text-xs",children:"Back to latest screenshot"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(f,{icon:e.jsx(he,{className:"size-4"}),label:"Requests",value:t.requests}),e.jsx(f,{icon:e.jsx(te,{className:"size-4"}),label:"LLM calls",value:(p==null?void 0:p.answered)??0}),e.jsx(f,{icon:e.jsx(se,{className:"size-4"}),label:"Tokens · cost",value:`${((p==null?void 0:p.tokens)??0).toLocaleString()} · $0.00`}),e.jsx(f,{icon:e.jsx(Y,{className:"size-4"}),label:"Direct calls",value:t.probes?t.probes.directCalls:"n/a"})]}),p&&p.problems.length>0&&e.jsx("ul",{className:"space-y-1 text-xs text-warn",children:p.problems.map(y=>e.jsx("li",{children:y},y))})]}),_=e.jsxs(S,{className:"flex h-[32rem] flex-col lg:h-[calc(100vh-15rem)]",children:[e.jsx(E,{right:e.jsx(j,{children:g(t.timeline.length,"event")}),children:"Activity"}),e.jsx("div",{className:"min-h-0 flex-1",children:t.timeline.length?e.jsx(Ne,{items:t.timeline,selectedShot:a==null?void 0:a.name,onSelectShot:l}):s==="error"?e.jsx($,{title:"Can't reach the run",children:"Is `ghost-api ui` still running?"}):e.jsxs("div",{className:"space-y-2 p-4",children:[e.jsx(v,{className:"h-10"}),e.jsx(v,{className:"h-10 w-4/5"}),e.jsx(v,{className:"h-10 w-3/5"})]})})]}),b=e.jsxs(S,{className:"flex max-h-[32rem] flex-col lg:h-[calc(100vh-15rem)] lg:max-h-none",children:[e.jsx(E,{right:e.jsx(j,{children:t.endpoints.filter(y=>!y.third_party).length}),children:"Endpoints"}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-3",children:e.jsx(Q,{endpoints:t.endpoints,compact:!0})})]});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("header",{className:"flex flex-wrap items-start gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted",children:[e.jsxs("span",{children:["Run #",i]}),k?e.jsxs("span",{className:"flex items-center gap-1 text-accent",children:[e.jsx("span",{className:"size-1.5 animate-pulse rounded-full bg-accent"})," running"]}):e.jsx("span",{children:"finished"})]}),e.jsx("h1",{className:"text-xl font-bold break-all",children:t.domain||"Starting…"}),t.goal&&e.jsxs("p",{className:"truncate text-sm text-muted",children:["Goal: ",t.goal]})]}),k&&t.runId!==null&&e.jsxs(w,{variant:"danger",onClick:()=>x.mutate(),disabled:x.isPending||x.isSuccess,children:[e.jsx(xe,{className:"size-3.5"}),x.isSuccess?"Stopping…":"Stop"]})]}),e.jsx(je,{states:ye(t)}),x.error&&e.jsx(z,{error:x.error}),e.jsx(Se,{state:t}),e.jsxs("div",{className:"md:hidden",children:[e.jsx(F,{className:"mb-3",value:n,onChange:r,tabs:[{id:"timeline",label:"Activity"},{id:"browser",label:"Browser"},{id:"endpoints",label:"Endpoints",count:t.endpoints.length}]}),n==="browser"&&q,n==="timeline"&&_,n==="endpoints"&&b]}),e.jsxs("div",{className:"hidden gap-4 md:grid md:grid-cols-2 lg:grid-cols-[minmax(0,1.15fr)_minmax(0,1fr)_minmax(0,0.8fr)]",children:[e.jsxs("div",{className:"space-y-4",children:[q,e.jsx("div",{className:"lg:hidden",children:b})]}),_,e.jsx("div",{className:"hidden lg:block",children:b})]})]})}export{ze as Run};
@@ -0,0 +1,11 @@
1
+ import{c as x,o as m,e as h,j as e,C as d,S as r,B as p,f as j,P as l,a as n}from"./index-Ds2e5B9f.js";import{a as u,C as y}from"./circle-x-BcTE_1tr.js";/**
2
+ * @license lucide-react v0.468.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const N=x("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/**
7
+ * @license lucide-react v0.468.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const f=x("Stethoscope",[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]]);function g(){var i,o,c;const a=m({queryKey:["state"],queryFn:n.state}),t=h({mutationFn:n.doctor});return e.jsxs("div",{className:"mx-auto max-w-3xl space-y-5",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Settings"}),e.jsxs(d,{children:[e.jsx(r,{right:e.jsxs(p,{onClick:()=>t.mutate(),disabled:t.isPending,children:[e.jsx(f,{className:"size-4"}),t.isPending?"Checking…":"Check providers"]}),children:"LLM providers"}),e.jsxs("div",{className:"space-y-3 p-4 text-sm",children:[e.jsx("p",{className:"text-muted",children:"Sends one tiny request to each configured provider to check the key and model. This uses one LLM call per provider."}),t.error&&e.jsx(j,{error:t.error}),t.data&&e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"text-left text-xs text-muted",children:e.jsxs("tr",{children:[e.jsx("th",{className:"py-2 pr-3 font-medium",children:"Provider"}),e.jsx("th",{className:"py-2 pr-3 font-medium",children:"Model"}),e.jsx("th",{className:"py-2 pr-3 font-medium",children:"Status"}),e.jsx("th",{className:"py-2 font-medium",children:"Detail"})]})}),e.jsx("tbody",{children:t.data.map(s=>e.jsxs("tr",{className:"border-t border-line align-top",children:[e.jsx("td",{className:"py-2 pr-3 font-medium",children:s.provider}),e.jsx("td",{className:"py-2 pr-3 font-mono text-xs",children:s.model}),e.jsx("td",{className:"py-2 pr-3",children:s.key?s.ok?e.jsxs(l,{className:"bg-ok/15 text-ok",children:[e.jsx(u,{className:"size-3"})," OK · ",s.seconds.toFixed(1)," s"]}):e.jsxs(l,{className:"bg-bad/15 text-bad",children:[e.jsx(y,{className:"size-3"})," failed"]}):e.jsx(l,{children:"no key"})}),e.jsx("td",{className:"py-2 text-xs text-muted",children:s.detail})]},`${s.provider}-${s.model}`))})]})}),a.data&&!a.data.has_llm&&e.jsxs("p",{className:"flex items-start gap-2 rounded-lg bg-warn/10 px-3 py-2 text-warn",children:[e.jsx(N,{className:"mt-0.5 size-4 shrink-0"}),"No API key found. Add one (for example GEMINI_API_KEY or GROQ_API_KEY) to the .env file in the project folder, then restart ",e.jsx("code",{className:"font-mono",children:"ghost-api ui"}),"."]})]})]}),e.jsxs(d,{children:[e.jsx(r,{children:"Being a polite visitor"}),e.jsxs("div",{className:"space-y-2 p-4 text-sm text-muted",children:[e.jsxs("p",{children:["Some sites (like Wikipedia) ask automated tools to say who runs them. Set"," ",e.jsx("code",{className:"font-mono text-fg",children:"GHOST_API_CONTACT"})," in .env to your email or a URL and Ghost API adds it to its user agent. It is never filled in for you."]}),e.jsx("p",{children:"Ghost API always follows robots.txt from the dashboard and stops at logins and bot checks."})]})]}),e.jsxs(d,{children:[e.jsx(r,{children:"Where your data lives"}),e.jsxs("dl",{className:"grid gap-3 p-4 text-sm sm:grid-cols-[8rem_1fr]",children:[e.jsx("dt",{className:"text-muted",children:"Database"}),e.jsx("dd",{className:"font-mono text-xs break-all",children:((i=a.data)==null?void 0:i.db)??"…"}),e.jsx("dt",{className:"text-muted",children:"Output folder"}),e.jsx("dd",{className:"font-mono text-xs break-all",children:((o=a.data)==null?void 0:o.out)??"…"}),e.jsx("dt",{className:"text-muted",children:"Version"}),e.jsx("dd",{children:((c=a.data)==null?void 0:c.version)??"…"})]})]})]})}export{g as Settings};