@exla/rudder 5.0.14 → 5.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,37 @@
1
+ export type AccountBackend = "claude" | "codex";
2
+ export declare const ACCOUNT_BACKENDS: readonly AccountBackend[];
3
+ export declare const MAIN_ACCOUNT = "main";
4
+ export type AgentAccount = {
5
+ backend: AccountBackend;
6
+ /** "main", or the extra account's id. */
7
+ id: string;
8
+ dir: string;
9
+ /** New agents on this backend start here. */
10
+ default: boolean;
11
+ };
12
+ type Env = NodeJS.ProcessEnv;
13
+ /** The variable each CLI reads its config dir from. */
14
+ export declare const ACCOUNT_ENV: Record<AccountBackend, string>;
15
+ export declare function isAccountBackend(value: unknown): value is AccountBackend;
16
+ /** The CLI's own config dir under `env`: the main account. */
17
+ export declare function mainAccountDir(backend: AccountBackend, env: Env): string;
18
+ export declare function accountDir(backend: AccountBackend, id: string, env: Env): string;
19
+ /** The env an agent on this account runs with, added to `env`. */
20
+ export declare function accountEnv(backend: AccountBackend, id: string, env: Env): Env;
21
+ /** Every account of every backend, main first, then the others oldest first. */
22
+ export declare function listAccounts(env: Env): Promise<Record<AccountBackend, AgentAccount[]>>;
23
+ /**
24
+ * A new, signed-out account: its dir with the shared parts linked to the main
25
+ * dir. The caller signs it in (the CLI's own login with `accountEnv`) and
26
+ * removes it again if that does not finish.
27
+ */
28
+ export declare function createAccount(backend: AccountBackend, env: Env): Promise<AgentAccount>;
29
+ /**
30
+ * Deletes an extra account's dir (its links go, never what they point at). New
31
+ * agents that started on it move back to main as the default. Sign it out
32
+ * first: on macOS the CLI's keychain entry outlives the dir.
33
+ */
34
+ export declare function removeAccount(backend: AccountBackend, id: string, env: Env): Promise<void>;
35
+ /** Makes `id` the account new agents on `backend` start on. */
36
+ export declare function setDefaultAccount(backend: AccountBackend, id: string, env: Env): Promise<void>;
37
+ export {};
@@ -0,0 +1,231 @@
1
+ /**
2
+ * Several signed-in accounts per agent CLI. An account is a config dir the CLI
3
+ * officially supports moving: `CLAUDE_CONFIG_DIR` for Claude Code, `CODEX_HOME`
4
+ * for Codex.
5
+ *
6
+ * - "main" is the CLI's own dir (`~/.claude`, `~/.codex`, or what the env
7
+ * already points them at). Agents on it run with the env unchanged.
8
+ * - Every other account is `<rudder home>/accounts/<backend>/<id>/`, and its
9
+ * agents run with the CLI's variable set to that dir (native signals.rs).
10
+ *
11
+ * An extra dir holds its own sign-in and links the rest to the main dir: the
12
+ * user's settings, memory, skills and hooks, and the conversation logs. So a
13
+ * chat started on one account resumes on another, and everything that reads
14
+ * transcripts, plans or usage keeps reading the main dir only.
15
+ *
16
+ * The default account of a backend (what new agents start on) is
17
+ * `backends.<backend>.account` in config.json; absent means main.
18
+ *
19
+ * Every function takes the env it resolves paths from: the Cloud home's own
20
+ * process has RUDDER_HOME set to a flag, not a dir (cloud/worker/home.mjs), so
21
+ * it passes the agents' env.
22
+ */
23
+ import fs from "node:fs";
24
+ import fsp from "node:fs/promises";
25
+ import os from "node:os";
26
+ import path from "node:path";
27
+ import { defaultConfig } from "./state.js";
28
+ import { readJson, updateJson } from "./util.js";
29
+ export const ACCOUNT_BACKENDS = ["claude", "codex"];
30
+ export const MAIN_ACCOUNT = "main";
31
+ /** The variable each CLI reads its config dir from. */
32
+ export const ACCOUNT_ENV = {
33
+ claude: "CLAUDE_CONFIG_DIR",
34
+ codex: "CODEX_HOME",
35
+ };
36
+ const ACCOUNT_ID = /^[a-z0-9]{1,32}$/;
37
+ /**
38
+ * What an extra dir links to the main dir, and nothing else: anything not
39
+ * named here is the account's own, so a file a newer CLI adds starts out
40
+ * separate. Dirs are created in the main dir when missing, so the CLI's first
41
+ * write lands in the shared one; files are linked when they exist.
42
+ *
43
+ * None of these holds a sign-in. What does, as of the versions the image pins
44
+ * (claude 2.1.328, codex 0.170.0), stays in each account's own dir:
45
+ * - Claude Code: `.credentials.json` (on macOS the keychain entry named after
46
+ * the dir, src/usage.ts claudeKeychainService), `.claude.json` (oauthAccount,
47
+ * userID, primaryApiKey, customApiKeyResponses and the org caches),
48
+ * `backups` (copies of it), `mcp-needs-auth-cache.json`, `mcp-oauth-tokens*.json`.
49
+ * - Codex: `auth.json`, `auth.lock`, `auth.json.lock`, `.credentials.json` (MCP
50
+ * OAuth), `gateway_oauth.json`, `gateway_oauth.lock`, `installation_id`, the
51
+ * app-server daemon dirs and the sqlite state (the keyring entry is keyed by
52
+ * the dir already).
53
+ */
54
+ const SHARED = {
55
+ claude: {
56
+ dirs: ["projects", "plans", "tasks", "teams", "todos", "file-history", "session-env", "shell-snapshots", "skills", "commands", "agents", "plugins", "hooks", "rules", "output-styles"],
57
+ files: ["settings.json", "CLAUDE.md", "AGENTS.md", "keybindings.json", "history.jsonl"],
58
+ },
59
+ codex: {
60
+ dirs: ["sessions", "archived_sessions", "skills", "rules", "prompts"],
61
+ files: ["config.toml", "AGENTS.md", "hooks.json", "history.jsonl", ".hook-trust"],
62
+ },
63
+ };
64
+ /**
65
+ * The parts of the main `.claude.json` a new Claude account starts with: the
66
+ * user's choices (onboarding done, theme, MCP servers, folder trust), never
67
+ * the signed-in account or its caches.
68
+ */
69
+ const CLAUDE_STATE_KEYS = [
70
+ "hasCompletedOnboarding",
71
+ "theme",
72
+ "bypassPermissionsModeAccepted",
73
+ "remoteDialogSeen",
74
+ "mcpServers",
75
+ "projects",
76
+ "autoCompactEnabled",
77
+ "editorMode",
78
+ "verbose",
79
+ "installMethod",
80
+ "autoUpdates",
81
+ ];
82
+ export function isAccountBackend(value) {
83
+ return value === "claude" || value === "codex";
84
+ }
85
+ function rudderHomeOf(env) {
86
+ return path.resolve(env.RUDDER_HOME?.trim() || path.join(os.homedir(), ".rudder"));
87
+ }
88
+ function configPath(env) {
89
+ return path.join(rudderHomeOf(env), "config.json");
90
+ }
91
+ /** The CLI's own config dir under `env`: the main account. */
92
+ export function mainAccountDir(backend, env) {
93
+ const configured = env[ACCOUNT_ENV[backend]]?.trim();
94
+ return path.resolve(configured || path.join(os.homedir(), backend === "claude" ? ".claude" : ".codex"));
95
+ }
96
+ function checkId(id) {
97
+ if (id === MAIN_ACCOUNT || !ACCOUNT_ID.test(id)) {
98
+ throw new Error(`not an account id: ${JSON.stringify(id)}`);
99
+ }
100
+ }
101
+ function extraDir(backend, id, env) {
102
+ checkId(id);
103
+ return path.join(rudderHomeOf(env), "accounts", backend, id);
104
+ }
105
+ export function accountDir(backend, id, env) {
106
+ return id === MAIN_ACCOUNT ? mainAccountDir(backend, env) : extraDir(backend, id, env);
107
+ }
108
+ const BACKEND_NAME = { claude: "Claude Code", codex: "Codex" };
109
+ function requireExtra(backend, id, env) {
110
+ const dir = extraDir(backend, id, env);
111
+ if (!fs.statSync(dir, { throwIfNoEntry: false })?.isDirectory()) {
112
+ throw new Error(`There is no ${BACKEND_NAME[backend]} account ${id}.`);
113
+ }
114
+ return dir;
115
+ }
116
+ /** The env an agent on this account runs with, added to `env`. */
117
+ export function accountEnv(backend, id, env) {
118
+ if (id === MAIN_ACCOUNT) {
119
+ return { ...env };
120
+ }
121
+ return { ...env, [ACCOUNT_ENV[backend]]: requireExtra(backend, id, env) };
122
+ }
123
+ function defaultIdOf(config, backend) {
124
+ const id = config?.backends?.[backend]?.account;
125
+ return typeof id === "string" && id ? id : MAIN_ACCOUNT;
126
+ }
127
+ /** Every account of every backend, main first, then the others oldest first. */
128
+ export async function listAccounts(env) {
129
+ const config = await readJson(configPath(env));
130
+ const out = {};
131
+ for (const backend of ACCOUNT_BACKENDS) {
132
+ const root = path.join(rudderHomeOf(env), "accounts", backend);
133
+ let entries = [];
134
+ try {
135
+ entries = await fsp.readdir(root, { withFileTypes: true });
136
+ }
137
+ catch (error) {
138
+ if (error.code !== "ENOENT")
139
+ throw error;
140
+ }
141
+ // Ids are base-36 creation times of one length, so name order is age order.
142
+ const ids = entries.filter((entry) => entry.isDirectory() && ACCOUNT_ID.test(entry.name) && entry.name !== MAIN_ACCOUNT)
143
+ .map((entry) => entry.name)
144
+ .sort();
145
+ const chosen = defaultIdOf(config, backend);
146
+ out[backend] = [MAIN_ACCOUNT, ...ids].map((id) => ({
147
+ backend,
148
+ id,
149
+ dir: accountDir(backend, id, env),
150
+ default: id === chosen,
151
+ }));
152
+ }
153
+ return out;
154
+ }
155
+ /**
156
+ * A new, signed-out account: its dir with the shared parts linked to the main
157
+ * dir. The caller signs it in (the CLI's own login with `accountEnv`) and
158
+ * removes it again if that does not finish.
159
+ */
160
+ export async function createAccount(backend, env) {
161
+ const id = Date.now().toString(36);
162
+ const dir = extraDir(backend, id, env);
163
+ const main = mainAccountDir(backend, env);
164
+ await fsp.mkdir(path.dirname(dir), { recursive: true, mode: 0o700 });
165
+ // Not recursive: an id already taken is an error, never a shared dir.
166
+ await fsp.mkdir(dir, { mode: 0o700 });
167
+ try {
168
+ await fsp.mkdir(main, { recursive: true });
169
+ for (const name of SHARED[backend].dirs) {
170
+ await fsp.mkdir(path.join(main, name), { recursive: true });
171
+ await fsp.symlink(path.join(main, name), path.join(dir, name));
172
+ }
173
+ for (const name of SHARED[backend].files) {
174
+ if (fs.existsSync(path.join(main, name))) {
175
+ await fsp.symlink(path.join(main, name), path.join(dir, name));
176
+ }
177
+ }
178
+ if (backend === "claude") {
179
+ await seedClaudeState(dir, env);
180
+ }
181
+ }
182
+ catch (error) {
183
+ await fsp.rm(dir, { recursive: true, force: true });
184
+ throw error;
185
+ }
186
+ const config = await readJson(configPath(env));
187
+ return { backend, id, dir, default: defaultIdOf(config, backend) === id };
188
+ }
189
+ async function seedClaudeState(dir, env) {
190
+ // Claude keeps `.claude.json` in its config dir only when CLAUDE_CONFIG_DIR
191
+ // names one; otherwise it is ~/.claude.json.
192
+ const configured = env.CLAUDE_CONFIG_DIR?.trim();
193
+ const mainState = configured ? path.join(path.resolve(configured), ".claude.json") : path.join(os.homedir(), ".claude.json");
194
+ const state = (await readJson(mainState)) ?? {};
195
+ const seed = {};
196
+ for (const key of CLAUDE_STATE_KEYS) {
197
+ if (key in state)
198
+ seed[key] = state[key];
199
+ }
200
+ await fsp.writeFile(path.join(dir, ".claude.json"), `${JSON.stringify(seed, null, 2)}\n`, { mode: 0o600 });
201
+ }
202
+ /**
203
+ * Deletes an extra account's dir (its links go, never what they point at). New
204
+ * agents that started on it move back to main as the default. Sign it out
205
+ * first: on macOS the CLI's keychain entry outlives the dir.
206
+ */
207
+ export async function removeAccount(backend, id, env) {
208
+ const dir = requireExtra(backend, id, env);
209
+ await fsp.rm(dir, { recursive: true });
210
+ await updateJson(configPath(env), (config) => {
211
+ if (!config || defaultIdOf(config, backend) !== id)
212
+ return undefined;
213
+ const { account: _removed, ...rest } = config.backends?.[backend] ?? {};
214
+ return { ...config, backends: { ...config.backends, [backend]: rest } };
215
+ });
216
+ }
217
+ /** Makes `id` the account new agents on `backend` start on. */
218
+ export async function setDefaultAccount(backend, id, env) {
219
+ if (id !== MAIN_ACCOUNT) {
220
+ requireExtra(backend, id, env);
221
+ }
222
+ await updateJson(configPath(env), (config) => {
223
+ // A machine nothing has configured yet starts from the defaults, as the
224
+ // dashboard's own first write does (native config.rs).
225
+ const base = (config ?? defaultConfig());
226
+ const { account: _old, ...rest } = base.backends?.[backend] ?? {};
227
+ const next = id === MAIN_ACCOUNT ? rest : { ...rest, account: id };
228
+ return { ...base, backends: { ...base.backends, [backend]: next } };
229
+ });
230
+ }
231
+ //# sourceMappingURL=accounts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts.js","sourceRoot":"","sources":["../src/accounts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,GAAG,MAAM,kBAAkB,CAAC;AACnC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGjD,M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M,UAAU,CAAc,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE;QACxD,wEAAwE;QACxE,uDAAuD;QACvD,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,aAAa,EAAE,CAAgB,CAAC;QACxD,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAClE,MAAM,IAAI,GAAG,EAAE,KAAK,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;QACnE,OAAO,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,EAAe,CAAC;IACnF,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,6 +1,6 @@
1
1
  var ae,E,We,Gt,W,Be,Ke,Ve,fe,ee,X,Qe,ve,me,ge,Yt,re={},se=[],Xt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ie=Array.isArray;function q(e,t){for(var r in t)e[r]=t[r];return e}function ye(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Jt(e,t,r){var s,o,a,l={};for(a in t)a=="key"?s=t[a]:a=="ref"?o=t[a]:l[a]=t[a];if(arguments.length>2&&(l.children=arguments.length>3?ae.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(a in e.defaultProps)l[a]===void 0&&(l[a]=e.defaultProps[a]);return te(e,l,s,o,null)}function te(e,t,r,s,o){var a={type:e,props:t,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++We,__i:-1,__u:0};return o==null&&E.vnode!=null&&E.vnode(a),a}function j(e){return e.children}function ne(e,t){this.props=e,this.context=t}function G(e,t){if(t==null)return e.__?G(e.__,e.__i+1):null;for(var r;t<e.__k.length;t++)if((r=e.__k[t])!=null&&r.__e!=null)return r.__e;return typeof e.type=="function"?G(e):null}function Zt(e){if(e.__P&&e.__d){var t=e.__v,r=t.__e,s=[],o=[],a=q({},t);a.__v=t.__v+1,E.vnode&&E.vnode(a),_e(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[r]:null,s,r??G(t),!!(32&t.__u),o),a.__v=t.__v,a.__.__k[a.__i]=a,Xe(s,a,o),t.__e=t.__=null,a.__e!=r&&ze(a)}}function ze(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),ze(e)}function qe(e){(!e.__d&&(e.__d=!0)&&W.push(e)&&!oe.__r++||Be!=E.debounceRendering)&&((Be=E.debounceRendering)||Ke)(oe)}function oe(){try{for(var e,t=1;W.length;)W.length>t&&W.sort(Ve),e=W.shift(),t=W.length,Zt(e)}finally{W.length=oe.__r=0}}function Ge(e,t,r,s,o,a,l,d,u,c,p){var i,f,m,y,w,_,v,h=s&&s.__k||se,g=t.length;for(u=en(r,t,h,u,g),i=0;i<g;i++)(m=r.__k[i])!=null&&(f=m.__i!=-1&&h[m.__i]||re,m.__i=i,_=_e(e,m,f,o,a,l,d,u,c,p),y=m.__e,m.ref&&f.ref!=m.ref&&(f.ref&&be(f.ref,null,m),p.push(m.ref,m.__c||y,m)),w==null&&y!=null&&(w=y),(v=!!(4&m.__u))||f.__k===m.__k?(u=Ye(m,u,e,v),v&&f.__e&&(f.__e=null)):typeof m.type=="function"&&_!==void 0?u=_:y&&(u=y.nextSibling),m.__u&=-7);return r.__e=w,u}function en(e,t,r,s,o){var a,l,d,u,c,p=r.length,i=p,f=0;for(e.__k=new Array(o),a=0;a<o;a++)(l=t[a])!=null&&typeof l!="boolean"&&typeof l!="function"?(typeof l=="string"||typeof l=="number"||typeof l=="bigint"||l.constructor==String?l=e.__k[a]=te(null,l,null,null,null):ie(l)?l=e.__k[a]=te(j,{children:l},null,null,null):l.constructor===void 0&&l.__b>0?l=e.__k[a]=te(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):e.__k[a]=l,u=a+f,l.__=e,l.__b=e.__b+1,d=null,(c=l.__i=tn(l,r,u,i))!=-1&&(i--,(d=r[c])&&(d.__u|=2)),d==null||d.__v==null?(c==-1&&(o>p?f--:o<p&&f++),typeof l.type!="function"&&(l.__u|=4)):c!=u&&(c==u-1?f--:c==u+1?f++:(c>u?f--:f++,l.__u|=4))):e.__k[a]=null;if(i)for(a=0;a<p;a++)(d=r[a])!=null&&!(2&d.__u)&&(d.__e==s&&(s=G(d)),Ze(d,d));return s}function Ye(e,t,r,s){var o,a;if(typeof e.type=="function"){for(o=e.__k,a=0;o&&a<o.length;a++)o[a]&&(o[a].__=e,t=Ye(o[a],t,r,s));return t}e.__e!=t&&(s&&(t&&e.type&&!t.parentNode&&(t=G(e)),r.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function tn(e,t,r,s){var o,a,l,d=e.key,u=e.type,c=t[r],p=c!=null&&(2&c.__u)==0;if(c===null&&d==null||p&&d==c.key&&u==c.type)return r;if(s>(p?1:0)){for(o=r-1,a=r+1;o>=0||a<t.length;)if((c=t[l=o>=0?o--:a++])!=null&&!(2&c.__u)&&d==c.key&&u==c.type)return l}return-1}function Oe(e,t,r){t[0]=="-"?e.setProperty(t,r??""):e[t]=r==null?"":typeof r!="number"||Xt.test(t)?r:r+"px"}function Z(e,t,r,s,o){var a,l;e:if(t=="style")if(typeof r=="string")e.style.cssText=r;else{if(typeof s=="string"&&(e.style.cssText=s=""),s)for(t in s)r&&t in r||Oe(e.style,t,"");if(r)for(t in r)s&&r[t]==s[t]||Oe(e.style,t,r[t])}else if(t[0]=="o"&&t[1]=="n")a=t!=(t=t.replace(Qe,"$1")),l=t.toLowerCase(),t=l in e||t=="onFocusOut"||t=="onFocusIn"?l.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=r,r?s?r[X]=s[X]:(r[X]=ve,e.addEventListener(t,a?ge:me,a)):e.removeEventListener(t,a?ge:me,a);else{if(o=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=r??"";break e}catch{}typeof r=="function"||(r==null||r===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&r==1?"":r))}}function He(e){return function(t){if(this.l){var r=this.l[t.type+e];if(t[ee]==null)t[ee]=ve++;else if(t[ee]<r[X])return;return r(E.event?E.event(t):t)}}}function _e(e,t,r,s,o,a,l,d,u,c){var p,i,f,m,y,w,_,v,h,g,k,S,L,B,x,$=t.type;if(t.constructor!==void 0)return null;128&r.__u&&(u=!!(32&r.__u),a=[d=t.__e=r.__e]),(p=E.__b)&&p(t);e:if(typeof $=="function")try{if(v=t.props,h=$.prototype&&$.prototype.render,g=(p=$.contextType)&&s[p.__c],k=p?g?g.props.value:p.__:s,r.__c?_=(i=t.__c=r.__c).__=i.__E:(h?t.__c=i=new $(v,k):(t.__c=i=new ne(v,k),i.constructor=$,i.render=rn),g&&g.sub(i),i.state||(i.state={}),i.__n=s,f=i.__d=!0,i.__h=[],i._sb=[]),h&&i.__s==null&&(i.__s=i.state),h&&$.getDerivedStateFromProps!=null&&(i.__s==i.state&&(i.__s=q({},i.__s)),q(i.__s,$.getDerivedStateFromProps(v,i.__s))),m=i.props,y=i.state,i.__v=t,f)h&&$.getDerivedStateFromProps==null&&i.componentWillMount!=null&&i.componentWillMount(),h&&i.componentDidMount!=null&&i.__h.push(i.componentDidMount);else{if(h&&$.getDerivedStateFromProps==null&&v!==m&&i.componentWillReceiveProps!=null&&i.componentWillReceiveProps(v,k),t.__v==r.__v||!i.__e&&i.shouldComponentUpdate!=null&&i.shouldComponentUpdate(v,i.__s,k)===!1){t.__v!=r.__v&&(i.props=v,i.state=i.__s,i.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(A){A&&(A.__=t)}),se.push.apply(i.__h,i._sb),i._sb=[],i.__h.length&&l.push(i);break e}i.componentWillUpdate!=null&&i.componentWillUpdate(v,i.__s,k),h&&i.componentDidUpdate!=null&&i.__h.push(function(){i.componentDidUpdate(m,y,w)})}if(i.context=k,i.props=v,i.__P=e,i.__e=!1,S=E.__r,L=0,h)i.state=i.__s,i.__d=!1,S&&S(t),p=i.render(i.props,i.state,i.context),se.push.apply(i.__h,i._sb),i._sb=[];else do i.__d=!1,S&&S(t),p=i.render(i.props,i.state,i.context),i.state=i.__s;while(i.__d&&++L<25);i.state=i.__s,i.getChildContext!=null&&(s=q(q({},s),i.getChildContext())),h&&!f&&i.getSnapshotBeforeUpdate!=null&&(w=i.getSnapshotBeforeUpdate(m,y)),B=p!=null&&p.type===j&&p.key==null?Je(p.props.children):p,d=Ge(e,ie(B)?B:[B],t,r,s,o,a,l,d,u,c),i.base=t.__e,t.__u&=-161,i.__h.length&&l.push(i),_&&(i.__E=i.__=null)}catch(A){if(t.__v=null,u||a!=null)if(A.then){for(t.__u|=u?160:128;d&&d.nodeType==8&&d.nextSibling;)d=d.nextSibling;a[a.indexOf(d)]=null,t.__e=d}else{for(x=a.length;x--;)ye(a[x]);he(t)}else t.__e=r.__e,t.__k=r.__k,A.then||he(t);E.__e(A,t,r)}else a==null&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):d=t.__e=nn(r.__e,t,r,s,o,a,l,u,c);return(p=E.diffed)&&p(t),128&t.__u?void 0:d}function he(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(he))}function Xe(e,t,r){for(var s=0;s<r.length;s++)be(r[s],r[++s],r[++s]);E.__c&&E.__c(t,e),e.some(function(o){try{e=o.__h,o.__h=[],e.some(function(a){a.call(o)})}catch(a){E.__e(a,o.__v)}})}function Je(e){return typeof e!="object"||e==null||e.__b>0?e:ie(e)?e.map(Je):e.constructor!==void 0?null:q({},e)}function nn(e,t,r,s,o,a,l,d,u){var c,p,i,f,m,y,w,_=r.props||re,v=t.props,h=t.type;if(h=="svg"?o="http://www.w3.org/2000/svg":h=="math"?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),a!=null){for(c=0;c<a.length;c++)if((m=a[c])&&"setAttribute"in m==!!h&&(h?m.localName==h:m.nodeType==3)){e=m,a[c]=null;break}}if(e==null){if(h==null)return document.createTextNode(v);e=document.createElementNS(o,h,v.is&&v),d&&(E.__m&&E.__m(t,a),d=!1),a=null}if(h==null)_===v||d&&e.data==v||(e.data=v);else{if(a=h=="textarea"&&v.defaultValue!=null?null:a&&ae.call(e.childNodes),!d&&a!=null)for(_={},c=0;c<e.attributes.length;c++)_[(m=e.attributes[c]).name]=m.value;for(c in _)m=_[c],c=="dangerouslySetInnerHTML"?i=m:c=="children"||c in v||c=="value"&&"defaultValue"in v||c=="checked"&&"defaultChecked"in v||Z(e,c,null,m,o);for(c in v)m=v[c],c=="children"?f=m:c=="dangerouslySetInnerHTML"?p=m:c=="value"?y=m:c=="checked"?w=m:d&&typeof m!="function"||_[c]===m||Z(e,c,m,_[c],o);if(p)d||i&&(p.__html==i.__html||p.__html==e.innerHTML)||(e.innerHTML=p.__html),t.__k=[];else if(i&&(e.innerHTML=""),Ge(t.type=="template"?e.content:e,ie(f)?f:[f],t,r,s,h=="foreignObject"?"http://www.w3.org/1999/xhtml":o,a,l,a?a[0]:r.__k&&G(r,0),d,u),a!=null)for(c=a.length;c--;)ye(a[c]);d&&h!="textarea"||(c="value",h=="progress"&&y==null?e.removeAttribute("value"):y!=null&&(y!==e[c]||h=="progress"&&!y||h=="option"&&y!=_[c])&&Z(e,c,y,_[c],o),c="checked",w!=null&&w!=e[c]&&Z(e,c,w,_[c],o))}return e}function be(e,t,r){try{if(typeof e=="function"){var s=typeof e.__u=="function";s&&e.__u(),s&&t==null||(e.__u=e(t))}else e.current=t}catch(o){E.__e(o,r)}}function Ze(e,t,r){var s,o;if(E.unmount&&E.unmount(e),(s=e.ref)&&(s.current&&s.current!=e.__e||be(s,null,t)),(s=e.__c)!=null){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(a){E.__e(a,t)}s.base=s.__P=null}if(s=e.__k)for(o=0;o<s.length;o++)s[o]&&Ze(s[o],t,r||typeof e.type!="function");r||ye(e.__e),e.__c=e.__=e.__e=void 0}function rn(e,t,r){return this.constructor(e,r)}function we(e,t,r){var s,o,a,l;t==document&&(t=document.documentElement),E.__&&E.__(e,t),o=(s=typeof r=="function")?null:r&&r.__k||t.__k,a=[],l=[],_e(t,e=(!s&&r||t).__k=Jt(j,null,[e]),o||re,re,t.namespaceURI,!s&&r?[r]:o?null:t.firstChild?ae.call(t.childNodes):null,a,!s&&r?r:o?o.__e:t.firstChild,s,l),Xe(a,e,l)}ae=se.slice,E={__e:function(e,t,r,s){for(var o,a,l;t=t.__;)if((o=t.__c)&&!o.__)try{if((a=o.constructor)&&a.getDerivedStateFromError!=null&&(o.setState(a.getDerivedStateFromError(e)),l=o.__d),o.componentDidCatch!=null&&(o.componentDidCatch(e,s||{}),l=o.__d),l)return o.__E=o}catch(d){e=d}throw e}},We=0,Gt=function(e){return e!=null&&e.constructor===void 0},ne.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=q({},this.state),typeof e=="function"&&(e=e(q({},r),this.props)),e&&q(r,e),e!=null&&this.__v&&(t&&this._sb.push(t),qe(this))},ne.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),qe(this))},ne.prototype.render=j,W=[],Ke=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ve=function(e,t){return e.__v.__b-t.__v.__b},oe.__r=0,fe=Math.random().toString(8),ee="__d"+fe,X="__a"+fe,Qe=/(PointerCapture)$|Capture$/i,ve=0,me=He(!1),ge=He(!0),Yt=0;var J,P,ke,et,ce=0,lt=[],C=E,tt=C.__b,nt=C.__r,rt=C.diffed,st=C.__c,ot=C.unmount,at=C.__;function Se(e,t){C.__h&&C.__h(P,e,ce||t),ce=0;var r=P.__H||(P.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__[e]}function b(e){return ce=1,Ee(dt,e)}function Ee(e,t,r){var s=Se(J++,2);if(s.t=e,!s.__c&&(s.__=[r?r(t):dt(void 0,t),function(d){var u=s.__N?s.__N[0]:s.__[0],c=s.t(u,d);u!==c&&(s.__N=[c,s.__[1]],s.__c.setState({}))}],s.__c=P,!P.__f)){var o=function(d,u,c){if(!s.__c.__H)return!0;var p=s.__c.__H.__.filter(function(f){return f.__c});if(p.every(function(f){return!f.__N}))return!a||a.call(this,d,u,c);var i=s.__c.props!==d;return p.some(function(f){if(f.__N){var m=f.__[0];f.__=f.__N,f.__N=void 0,m!==f.__[0]&&(i=!0)}}),a&&a.call(this,d,u,c)||i};P.__f=!0;var a=P.shouldComponentUpdate,l=P.componentWillUpdate;P.componentWillUpdate=function(d,u,c){if(this.__e){var p=a;a=void 0,o(d,u,c),a=p}l&&l.call(this,d,u,c)},P.shouldComponentUpdate=o}return s.__N||s.__}function M(e,t){var r=Se(J++,3);!C.__s&&ct(r.__H,t)&&(r.__=e,r.u=t,P.__H.__h.push(r))}function I(e){return ce=5,N(function(){return{current:e}},[])}function N(e,t){var r=Se(J++,7);return ct(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function sn(){for(var e;e=lt.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(le),t.__h.some(xe),t.__h=[]}catch(r){t.__h=[],C.__e(r,e.__v)}}}C.__b=function(e){P=null,tt&&tt(e)},C.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),at&&at(e,t)},C.__r=function(e){nt&&nt(e),J=0;var t=(P=e.__c).__H;t&&(ke===P?(t.__h=[],P.__h=[],t.__.some(function(r){r.__N&&(r.__=r.__N),r.u=r.__N=void 0})):(t.__h.some(le),t.__h.some(xe),t.__h=[],J=0)),ke=P},C.diffed=function(e){rt&&rt(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(lt.push(t)!==1&&et===C.requestAnimationFrame||((et=C.requestAnimationFrame)||on)(sn)),t.__H.__.some(function(r){r.u&&(r.__H=r.u),r.u=void 0})),ke=P=null},C.__c=function(e,t){t.some(function(r){try{r.__h.some(le),r.__h=r.__h.filter(function(s){return!s.__||xe(s)})}catch(s){t.some(function(o){o.__h&&(o.__h=[])}),t=[],C.__e(s,r.__v)}}),st&&st(e,t)},C.unmount=function(e){ot&&ot(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.some(function(s){try{le(s)}catch(o){t=o}}),r.__H=void 0,t&&C.__e(t,r.__v))};var it=typeof requestAnimationFrame=="function";function on(e){var t,r=function(){clearTimeout(s),it&&cancelAnimationFrame(t),setTimeout(e)},s=setTimeout(r,35);it&&(t=requestAnimationFrame(r))}function le(e){var t=P,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),P=t}function xe(e){var t=P;e.__c=e.__(),P=t}function ct(e,t){return!e||e.length!==t.length||t.some(function(r,s){return r!==e[s]})}function dt(e,t){return typeof t=="function"?t(e):t}var ut="rudder.board.session.v1:",pt=/^[a-f0-9]{64}$/,an=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/,T=class extends Error{constructor(){super("Open this board from Rudder to connect"),this.name="BoardAccessExpired"}},Re=class{#r="";#t=null;#s="";#u;#o;#c=new Set;#e=0;#i;#n;#p;constructor(t){let{href:r,now:s,...o}=t;this.#p=r,this.#n=o,this.#i=s??Date.now}onLost(t){return this.#c.add(t),()=>{this.#c.delete(t)}}#a(t=!0){this.#e++,this.#r="",this.#t=null,this.#o=void 0,clearTimeout(this.#u);try{this.#s&&this.#n.storage?.removeItem(this.#s)}catch{}if(t)for(let r of this.#c)r()}#d(t,r){let s=t;if(!s||s.format_version!==1||s.origin!==this.#n.origin||s.instance_id!==r.instance_id||!Number.isSafeInteger(s.expires_at_ms)||s.expires_at_ms<=this.#i()||typeof s.owner_slug!="string"||!["projector","scheduler"].includes(s.control_mode)||s.scope?.registered_projects!==!0||s.scope.usage!==!0||s.scope.owner_project_control!==!0)throw new T;return s}#f(){try{this.#n.storage?.setItem(this.#s,JSON.stringify({token:this.#r,session:this.#t}))}catch{}clearTimeout(this.#u);let t=this.#e;this.#t&&(this.#u=setTimeout(()=>{this.#m().catch(()=>{t===this.#e&&this.#a()})},Math.max(1e3,this.#t.expires_at_ms-this.#i()-6e4)))}#l(t,r){let s=new URL(t,this.#n.origin);return s.origin!==this.#n.origin?Promise.reject(new T):this.#n.fetch(s.href,{...r,credentials:"omit",cache:"no-store",redirect:"error",referrerPolicy:"no-referrer"})}async initialize(){this.#a(!1);let t=this.#e,r=new URL(this.#p),s=/^#rudder-board-ticket=([a-f0-9]{64})$/.exec(r.hash)?.[1];r.hash.startsWith("#rudder-board-ticket")&&(this.#n.replaceUrl(r.pathname+r.search),this.#p=r.origin+r.pathname+r.search);try{let o=await this.#l("/api/board/descriptor"),a=await o.json();if(t!==this.#e)throw new T;if(!o.ok||a.format_version!==1||a.origin!==this.#n.origin||!an.test(a.instance_id))throw new T;this.#s=`${ut}${this.#n.origin}:${a.instance_id}`;try{let l=this.#n.storage;for(let d=(l?.length??0)-1;d>=0;d--){let u=l.key(d);u?.startsWith(`${ut}${this.#n.origin}:`)&&u!==this.#s&&l.removeItem(u)}}catch{}if(s){let l=await this.#l("/api/board/session",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ticket:s,instance_id:a.instance_id})});if(!l.ok)throw new T;let d=await l.json();if(t!==this.#e)throw new T;if(!pt.test(d.token))throw new T;this.#r=d.token,this.#t=this.#d(d.session,a)}else{let l=null;try{l=JSON.parse(this.#n.storage?.getItem(this.#s)??"null")}catch{}if(!l||typeof l.token!="string"||!pt.test(l.token))throw new T;this.#r=l.token,this.#d(l.session,a);let d=await this.#l("/api/board/session",{headers:{Authorization:`Bearer ${this.#r}`}});if(!d.ok)throw new T;let u=await d.json();if(t!==this.#e)throw new T;this.#t=this.#d(u,a)}return this.#f(),this.#t}catch{throw t===this.#e&&this.#a(),new T}}async#m(){if(this.#o?.epoch===this.#e)return this.#o.promise;let t=this.#e,r={epoch:t,promise:Promise.resolve()};return r.promise=(async()=>{if(!this.#r||!this.#t||this.#t.expires_at_ms<=this.#i())throw new T;let s=await this.#l("/api/board/session/renew",{method:"POST",headers:{Authorization:`Bearer ${this.#r}`}});if(!s.ok)throw new T;let o=await s.json();if(t!==this.#e||!this.#t)throw new T;this.#t=this.#d(o,this.#t),this.#f()})().finally(()=>{this.#o===r&&(this.#o=void 0)}),this.#o=r,r.promise}async fetch(t,r){if(!this.#r||!this.#t)throw new T;let s=this.#e;if(this.#t.expires_at_ms<=this.#i()+6e4)try{await this.#m()}catch{throw s===this.#e&&this.#a(),new T}if(s!==this.#e)throw new T;let o=new Headers(r?.headers);o.set("Authorization",`Bearer ${this.#r}`);let a=await this.#l(t,{...r,headers:o});if(s!==this.#e)throw await a.body?.cancel(),new T;if(a.status===401)throw this.#a(),new T;return a}close(){this.#a(!1),this.#c.clear()}},Te;function V(){if(!Te){let e;try{e=window.sessionStorage}catch{}Te=new Re({origin:window.location.origin,href:window.location.href,storage:e,replaceUrl:t=>window.history.replaceState(null,"",t),fetch:window.fetch.bind(window)})}return Te}function F(e,t){return V().fetch(e,t)}async function O(e){if(!e.ok){let t=await e.text().catch(()=>"");throw new Error(`${e.status} ${e.statusText}${t?`: ${t}`:""}`)}return e.json()}async function ft(e){return O(await F(`/api/usage/tokens?range=${encodeURIComponent(e)}`))}async function mt(e=!1){return O(await F(`/api/usage/quota${e?"?refresh=1":""}`))}async function gt(){return O(await F("/api/usage/machine"))}async function ht(){return O(await F("/api/projects"))}async function vt(e,t){return O(await F(`/api/projects/${encodeURIComponent(e)}/state`,{signal:t}))}async function yt(e,t,r=200){let s=await F(`/api/projects/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}/log?tail=${r}`);if(!s.ok)throw new Error(`${s.status} ${s.statusText}`);return s.text()}async function _t(e,t){let r=xt();return O(await St(`/api/projects/${encodeURIComponent(e)}/tasks`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({prompt:t,requestId:r})}))}async function bt(e,t){return O(await F(`/api/projects/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}/merge`,{method:"POST",headers:{}}))}async function wt(e,t){let r=await F(`/api/projects/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}/cancel`,{method:"POST",headers:{}});if(!r.ok)throw new Error(`${r.status} ${r.statusText}`)}async function kt(e,t,r){let s=xt(),o=t==="conductor"?`/api/projects/${encodeURIComponent(e)}/steer`:`/api/projects/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}/steer`;return O(await St(o,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({instruction:r,requestId:s})}))}function xt(){return globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`}async function St(e,t){try{return await F(e,t)}catch{return await new Promise(r=>setTimeout(r,150)),F(e,t)}}async function Pe(e,t){return O(await F(`/api/projects/${encodeURIComponent(e)}/steer-receipts/${encodeURIComponent(t)}`))}function Et(e){return`/api/projects/${encodeURIComponent(e)}/events`}var de=4*1024*1024;async function ln(e,t,r){if(!e.body)throw new Error("Board stream unavailable");let s=e.body.getReader(),o=new TextDecoder("utf-8",{fatal:!0}),a="",l="message",d=[],u=0,c=setTimeout(()=>{s.cancel().catch(()=>{})},45e3),p=()=>{s.cancel().catch(()=>{})};r.addEventListener("abort",p,{once:!0});try{for(;!r.aborted;){let i=await s.read();if(i.done)return;if(clearTimeout(c),c=setTimeout(()=>{s.cancel().catch(()=>{})},45e3),i.value.byteLength>2*de)throw new Error("Board stream exceeds frame limit");if(a+=o.decode(i.value,{stream:!0}),a.length>2*de)throw new Error("Board stream exceeds frame limit");for(;;){let f=a.indexOf(`
2
2
  `);if(f<0)break;let m=a.slice(0,f).replace(/\r$/,"");if(a=a.slice(f+1),u+=new TextEncoder().encode(m).byteLength+1,u>de)throw new Error("Board stream exceeds frame limit");m===""?(d.length&&t({event:l,data:d.join(`
3
3
  `)}),l="message",d=[],u=0):m.startsWith("event:")?l=m.slice(6).replace(/^ /,""):m.startsWith("data:")&&d.push(m.slice(5).replace(/^ /,""))}if(a.length+u>de)throw new Error("Board stream exceeds frame limit")}}finally{clearTimeout(c),r.removeEventListener("abort",p),await s.cancel().catch(()=>{}),s.releaseLock()}}function cn(e,t){return new Promise(r=>{let s=()=>{clearTimeout(o),t.removeEventListener("abort",s),r()},o=setTimeout(s,e);t.aborted?s():t.addEventListener("abort",s,{once:!0})})}async function Tt(e,t,r=F){let s=0;for(;!t.signal.aborted;){let o=new AbortController,a=()=>o.abort(),l=setTimeout(a,1e4);t.signal.addEventListener("abort",a,{once:!0});try{if(t.signal.aborted)return;let d=await r(e,{headers:{Accept:"text/event-stream"},signal:o.signal});if(clearTimeout(l),!d.ok||!d.headers.get("content-type")?.startsWith("text/event-stream"))throw await d.body?.cancel(),new Error("Board stream unavailable");t.open(),s=0,await ln(d,t.consume,o.signal)}catch(d){if(d instanceof T)return}finally{clearTimeout(l),t.signal.removeEventListener("abort",a),o.abort()}if(t.signal.aborted)return;t.reconnecting(),await cn(Math.min(1e4,500*2**Math.min(s++,5)),t.signal)}}function dn(){return{nodes:new Map,edges:[],gates:[],memory:[],activity:[],loaded:!1}}function un(e,t){switch(t.type){case"SNAPSHOT":{let r=new Map;for(let s of t.snapshot.nodes)r.set(s.id,s);return{nodes:r,edges:t.snapshot.edges??[],gates:t.snapshot.gates??[],memory:t.snapshot.memory??[],activity:t.snapshot.activity??[],loaded:!0}}case"NODE_UPSERT":{let r=new Map(e.nodes);return r.set(t.node.id,t.node),{...e,nodes:r}}case"NODE_REMOVE":{if(!e.nodes.has(t.id))return e;let r=new Map(e.nodes);return r.delete(t.id),{...e,nodes:r}}case"EDGE_UPSERT":{let r=e.edges.filter(s=>!(s.from===t.edge.from&&s.to===t.edge.to&&s.kind===t.edge.kind));return r.push(t.edge),{...e,edges:r}}case"EDGE_REMOVE":return{...e,edges:e.edges.filter(r=>!(r.from===t.from&&r.to===t.to))};case"MEMORY":return{...e,memory:t.memory};case"ACTIVITY":return{...e,activity:t.activity};default:return e}}function Rt(e){let[t,r]=Ee(un,void 0,dn),[s,o]=b("connecting"),[a,l]=b(""),d=I(!1);return M(()=>{let u=new AbortController;d.current=!1;let c=async()=>{try{let p=await vt(e,u.signal);if(u.signal.aborted)return;l(p.name||e),r({type:"SNAPSHOT",snapshot:p})}catch{}};return c(),Tt(Et(e),{signal:u.signal,open:()=>{u.signal.aborted||(d.current&&c(),d.current=!0,o("live"))},reconnecting:()=>{u.signal.aborted||o(d.current?"reconnecting":"connecting")},consume:({event:p,data:i})=>{if(!u.signal.aborted)try{let f=JSON.parse(i);switch(p){case"snapshot":l(f.name||e),r({type:"SNAPSHOT",snapshot:f});break;case"node.added":case"node.updated":r({type:"NODE_UPSERT",node:f});break;case"node.removed":{let m=typeof f=="string"?f:f.id;m&&r({type:"NODE_REMOVE",id:m});break}case"edge.added":r({type:"EDGE_UPSERT",edge:f});break;case"edge.removed":f?.from&&f?.to&&r({type:"EDGE_REMOVE",from:f.from,to:f.to});break;case"memory.updated":r({type:"MEMORY",memory:Array.isArray(f)?f:f.memory??[]});break;case"activity.updated":r({type:"ACTIVITY",activity:Array.isArray(f)?f:f.activity??[]});break}}catch{}}}),()=>u.abort()},[e]),{state:t,conn:s,name:a}}var pn=0,fr=Array.isArray;function n(e,t,r,s,o,a){t||(t={});var l,d,u=t;if("ref"in u)for(d in u={},t)d=="ref"?l=t[d]:u[d]=t[d];var c={type:e,props:u,key:r,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--pn,__i:-1,__u:0,__source:o,__self:a};if(typeof e=="function"&&(l=e.defaultProps))for(d in l)u[d]===void 0&&(u[d]=l[d]);return E.vnode&&E.vnode(c),c}var $t=[{key:"todo",label:"Todo"},{key:"running",label:"Running"},{key:"review",label:"Review"},{key:"done",label:"Done"}];function Ct(e){let t=e.delivery;return!!(t?.required&&(t.status==="deployed"||t.status==="verified")&&t.kind?.trim()&&t.target?.trim()&&t.verifiedAt?.trim()&&t.checks?.length)}function Ce(e){if(e.merge&&e.merge.status==="merge-conflict")return"conflict";if(e.blocked)return"blocked";if(e.delivery?.required&&e.status==="completed")return e.delivery.status==="blocked"||e.delivery.status==="failed"?"failed":Ct(e)?"done":"review";switch(e.status){case"running":case"steering":case"verifying":case"created":return"running";case"completed":return"review";case"merged":return"done";case"failed":return"failed";case"cancelled":return"failed";case"paused":return"done";case"merge-conflict":return"conflict";default:return e.column}}function ue(e){return e.merge&&e.merge.status==="merge-conflict"?"conflict":e.blocked?"blocked":e.delivery?.required&&e.status==="completed"?e.delivery.status==="blocked"||e.delivery.status==="failed"?"delivery blocked":Ct(e)?"deployed":"delivery proof needed":e.status||e.column}function Mt(e){return["running","steering","verifying","created"].includes(e.status)}function pe(e){return e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}function At(){let[e,t]=b(null),[r,s]=b(null);return M(()=>{let o=!1;return ht().then(a=>{o||t(a.projects??[])}).catch(a=>{o||s(String(a?.message??a))}),()=>{o=!0}},[]),n("div",{class:"page",children:[n("header",{class:"topbar",children:[n("div",{class:"brand",children:[n("span",{class:"brand-mark",children:"\u25B0"}),n("span",{class:"brand-name",children:"Rudder"}),n("span",{class:"brand-sub mono",children:"board"})]}),n("div",{class:"toolbar-actions",children:n("a",{class:"btn",href:"/usage",title:"Quota meters, token costs, machine resources",children:"Usage"})})]}),n("main",{class:"index-main",children:[n("h1",{class:"index-title",children:"Projects"}),n("p",{class:"index-lede",children:"Local agent runs, projected live. Pick a repo."}),r&&n("div",{class:"banner banner-error mono",children:["failed to load projects: ",r]}),e===null&&!r&&n("div",{class:"tile-grid",children:[n($e,{}),n($e,{}),n($e,{})]}),e!==null&&e.length===0&&n("div",{class:"empty",children:[n("div",{class:"empty-title",children:"no projects yet"}),n("div",{class:"empty-sub mono",children:"start a run in any repo and it registers here"})]}),e!==null&&e.length>0&&n("div",{class:"tile-grid",children:e.map(o=>n(fn,{project:o},o.slug))})]})]})}function fn({project:e}){let t=e.counts,r=()=>{window.location.href=`/rudder/${encodeURIComponent(e.slug)}`},s=[{token:"running",label:"running",n:t.running},{token:"review",label:"review",n:t.review},{token:"todo",label:"todo",n:t.todo},{token:"done",label:"done",n:t.done},{token:"blocked",label:"blocked",n:t.blocked},{token:"failed",label:"failed",n:t.failed}];return n("button",{class:"tile",onClick:r,type:"button",children:[n("div",{class:"tile-head",children:n("span",{class:"tile-name",children:e.name})}),n("div",{class:"tile-path mono",children:e.repoRoot}),n("div",{class:"tile-counts",children:s.map(o=>n("span",{class:`count count-${o.token}`,"data-zero":o.n===0,children:[n("span",{class:"count-n mono",children:o.n}),n("span",{class:"count-label",children:o.label})]},o.label))})]})}function $e(){return n("div",{class:"tile tile-skeleton","aria-hidden":"true",children:[n("div",{class:"skel skel-line",style:"width: 52%"}),n("div",{class:"skel skel-line",style:"width: 78%"}),n("div",{class:"skel skel-row"})]})}var jt="rudder.board.view";function mn(){try{let e=localStorage.getItem(jt);if(e==="board"||e==="nest"||e==="activity"||e==="memory")return e}catch{}return"board"}function Ft({slug:e}){let{state:t,conn:r,name:s}=Rt(e),[o,a]=b(mn),[l,d]=b(null),u=I(null),c=window.__RUDDER_CONTROL_MODE__??"projector",p=window.__RUDDER_CAN_MUTATE__!==!1,i=w=>{a(w);try{localStorage.setItem(jt,w)}catch{}},f=N(()=>Array.from(t.nodes.values()),[t.nodes]),m=l?t.nodes.get(l)??null:null,y=(w,_)=>{u.current=_,d(w)};return n("div",{class:"page board-page",children:[n(gn,{slug:e,name:s||e,conn:r,view:o,onView:i,memoryCount:t.memory.length,latestActivity:t.activity.length?t.activity[t.activity.length-1]:null,canMutate:p}),n("main",{class:"board-main",children:!t.loaded&&r!=="reconnecting"?n(Cn,{}):o==="board"?n(yn,{nodes:f,onOpen:y,selected:l}):o==="nest"?n(xn,{nodes:f,edges:t.edges,onOpen:y,selected:l}):o==="activity"?n(Pn,{slug:e,activity:t.activity,canSteerConductor:p&&c==="projector"}):n($n,{memory:t.memory})}),m&&n(Sn,{slug:e,node:m,onClose:()=>d(null),returnFocus:u.current,canMutate:p})]})}function gn({slug:e,name:t,conn:r,view:s,onView:o,memoryCount:a,latestActivity:l,canMutate:d}){let[u,c]=b(!1);return n("header",{class:"topbar board-topbar",children:[n("div",{class:"brand",children:[n("a",{class:"brand-link",href:"/rudder",title:"Back to all projects",children:[n("span",{class:"brand-mark",children:"\u25B0"}),n("span",{class:"brand-back",children:"\u2190 all projects"})]}),n("span",{class:"brand-name",children:t}),n(hn,{conn:r}),l&&s!=="activity"&&n("button",{type:"button",class:"activity-ticker mono",title:"Latest activity \u2014 click for the full feed",onClick:()=>o("activity"),children:[n("span",{class:"pulse-dot","aria-hidden":"true"}),n("span",{class:"activity-ticker-text",children:l.text})]})]}),n("div",{class:"toolbar-actions",children:[n("a",{class:"btn",href:"/usage",title:"Quota meters, token costs, machine resources",children:"Usage"}),n("div",{class:"view-toggle",role:"group","aria-label":"View",children:[n("button",{type:"button","aria-pressed":s==="board",class:`toggle ${s==="board"?"toggle-on":""}`,onClick:()=>o("board"),children:"Board"}),n("button",{type:"button","aria-pressed":s==="nest",class:`toggle ${s==="nest"?"toggle-on":""}`,onClick:()=>o("nest"),title:"Nest / DAG view",children:"Nest"}),n("button",{type:"button","aria-pressed":s==="activity",class:`toggle ${s==="activity"?"toggle-on":""}`,onClick:()=>o("activity"),title:"Live activity feed",children:"Activity"}),n("button",{type:"button","aria-pressed":s==="memory",class:`toggle ${s==="memory"?"toggle-on":""}`,onClick:()=>o("memory"),children:["Memory",a>0&&n("span",{class:"toggle-badge mono",children:a})]})]}),d?n("button",{type:"button",class:"btn btn-accent",onClick:()=>c(!0),children:"+ Task"}):n("span",{class:"readonly-pill mono",title:"Open this project's own Rudder board to make changes",children:"read-only"})]}),u&&n(vn,{slug:e,onClose:()=>c(!1)})]})}function hn({conn:e}){if(e==="live")return n("span",{class:"conn conn-live",title:"Live",children:[n("span",{class:"conn-dot"}),n("span",{class:"conn-label mono",children:"live"})]});let t=e==="connecting"?"connecting":"reconnecting";return n("span",{class:"conn conn-warn",title:t,children:[n("span",{class:"conn-dot conn-dot-pulse"}),n("span",{class:"conn-label mono",children:t})]})}function vn({slug:e,onClose:t}){let[r,s]=b(""),[o,a]=b(!1),[l,d]=b(null),[u,c]=b(null),p=I(null),i=I(null),f=I(!1),m=I(t);m.current=t,f.current=o,M(()=>{let _=document.activeElement;p.current?.focus();let v=h=>{if(h.key==="Escape"){h.preventDefault(),f.current||m.current();return}if(h.key!=="Tab"||!i.current)return;let g=Array.from(i.current.querySelectorAll('button:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')),k=g[0],S=g[g.length-1];k&&S&&h.shiftKey&&document.activeElement===k?(h.preventDefault(),S.focus()):k&&S&&!h.shiftKey&&document.activeElement===S&&(h.preventDefault(),k.focus())};return window.addEventListener("keydown",v),()=>{window.removeEventListener("keydown",v),_?.focus()}},[]),M(()=>{if(u?.state!=="queued"||!u.requestId)return;let _=!1,v,h=async()=>{let g=0;try{let k=await Pe(e,u.requestId);if(_)return;if(k.status==="delivered"){c({requestId:k.requestId,state:"delivered",message:"Delivered to the native conductor"});return}if(k.status==="failed"){c(null),d(k.error||"The native conductor could not accept the task");return}}catch{g=500}_||(v=window.setTimeout(h,g))};return h(),()=>{_=!0,v!==void 0&&window.clearTimeout(v)}},[e,u?.state,u?.requestId]);let y=async()=>{let _=r.trim();if(!(!_||o)){a(!0),d(null),c(null);try{let v=await _t(e,_);if(v.status==="queued"){s(""),c({requestId:v.requestId,state:"queued",message:"Queued for the native conductor"}),a(!1);return}if(v.status==="failed")throw new Error("The task could not be delivered to the conductor");t()}catch(v){d(String(v?.message??v)),a(!1)}}};return n("div",{class:"overlay",onClick:()=>{o||t()},children:n("form",{ref:i,class:"composer",onClick:_=>_.stopPropagation(),onSubmit:_=>{_.preventDefault(),y()},role:"dialog","aria-modal":"true","aria-labelledby":"new-task-title","aria-busy":o,children:[n("div",{class:"composer-head",children:[n("span",{class:"composer-title",id:"new-task-title",children:"New task"}),n("span",{class:"composer-hint mono",id:"new-task-hint",children:"\u2318/Ctrl + Enter to run \xB7 Esc to close"})]}),n("label",{class:"sr-only",for:"new-task-prompt",children:"Task description"}),n("textarea",{ref:p,id:"new-task-prompt",class:"composer-input mono",rows:5,placeholder:"Describe the task. The agent decomposes and schedules it.",value:r,"aria-describedby":"new-task-hint",onInput:_=>s(_.target.value),onKeyDown:_=>{(_.metaKey||_.ctrlKey)&&_.key==="Enter"&&(_.preventDefault(),y())},readOnly:o}),l&&n("div",{class:"banner banner-error mono",role:"alert",children:l}),u&&n("div",{class:"banner mono",role:"status",children:u.message}),n("div",{class:"composer-actions",children:[n("button",{type:"button",class:"btn",onClick:t,disabled:o,children:u?"Close":"Cancel"}),n("button",{type:"submit",class:"btn btn-accent",disabled:o||!r.trim(),children:o?"Running\u2026":"Run task"})]})]})})}function yn({nodes:e,onOpen:t,selected:r}){let s=N(()=>{let o={todo:[],running:[],review:[],done:[]};for(let a of e)(o[a.column]??o.todo).push(a);for(let a of Object.keys(o))o[a].sort((l,d)=>l.updatedAt<d.updatedAt?1:-1);return o},[e]);return n("div",{class:"board",children:$t.map(o=>{let a=s[o.key];return n("section",{class:"column","data-column":o.key,children:[n("header",{class:"column-head",children:[n("span",{class:"column-title",children:o.label}),n("span",{class:"column-count mono",children:a.length})]}),n("div",{class:"column-body",children:a.length===0?n("div",{class:"column-empty mono",children:"empty"}):a.map(l=>n(_n,{node:l,onOpen:t,selected:r===l.id},l.id))})]},o.key)})})}function _n({node:e,onOpen:t,selected:r}){let s=Ce(e),o=Mt(e),a=e.deps.hard.length+e.deps.soft.length;return n("article",{class:`card ${r?"card-selected":""}`,"data-status":s,"data-task-id":e.id,tabIndex:0,role:"button","aria-haspopup":"dialog","aria-expanded":r,onClick:l=>t(e.id,l.currentTarget),onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),t(e.id,l.currentTarget))},children:[n("div",{class:"card-spine","data-status":s}),n("div",{class:"card-body",children:[n("div",{class:"card-top",children:[n("span",{class:"card-status mono","data-status":s,children:ue(e)}),e.blocked&&n("span",{class:"flag flag-blocked mono",children:"blocked"})]}),n("h3",{class:"card-title",children:e.title}),n("div",{class:"card-meta mono",children:[n("span",{class:"card-backend",children:e.backend}),e.model&&n("span",{class:"card-model",children:e.model}),e.effort&&n("span",{class:"card-effort",children:e.effort})]}),e.delivery?.required&&n("div",{class:"card-lastline mono",children:n("span",{class:"lastline-text",children:["delivery ",e.delivery.status," \xB7 ",e.delivery.target??"target not recorded",e.delivery.checks?.length?` \xB7 ${e.delivery.checks.length} check${e.delivery.checks.length===1?"":"s"}`:""]})}),e.lastLine&&n("div",{class:"card-lastline mono",children:[o&&n("span",{class:"pulse-dot","aria-hidden":"true"}),n("span",{class:"lastline-text",children:e.lastLine})]}),n("div",{class:"card-foot",children:[e.tokens&&n("span",{class:"tokens mono",title:"input / output tokens",children:[n("span",{class:"tok-in",children:["\u2193",pe(e.tokens.input)]}),n("span",{class:"tok-out",children:["\u2191",pe(e.tokens.output)]})]}),a>0&&n("span",{class:"dep-badge mono",title:"upstream dependencies",children:[e.deps.hard.length>0&&n("span",{class:"dep dep-hard",title:`${e.deps.hard.length} hard dependency(ies)`,children:["\u2191",e.deps.hard.length," hard"]}),e.deps.soft.length>0&&n("span",{class:"dep dep-soft",title:`${e.deps.soft.length} soft dependency(ies)`,children:["\u2191",e.deps.soft.length," soft"]})]})]})]})]})}var R={boxW:220,boxH:64,gapX:96,gapY:26,padX:40,padY:40,spineW:5};function bn(e,t){let r=new Map;for(let l of e)r.set(l.id,l.deps.hard.filter(d=>t.has(d)&&d!==l.id));let s=new Map,o=new Set,a=l=>{let d=s.get(l);if(d!==void 0)return d;if(o.has(l))return 0;o.add(l);let u=r.get(l)??[],c=-1;for(let i of u)c=Math.max(c,a(i));o.delete(l);let p=c+1;return s.set(l,p),p};for(let l of e)a(l.id);return s}function wn(e){let t=new Set(e.map(p=>p.id)),r=bn(e,t),s=new Map;for(let p of e){let i=r.get(p.id)??0,f=s.get(i);f?f.push(p):s.set(i,[p])}let o=new Map,a=Array.from(s.keys()).sort((p,i)=>p-i),l=0;for(let p of a){let i=s.get(p);i.sort((y,w)=>y.createdAt!==w.createdAt?y.createdAt<w.createdAt?-1:1:y.id<w.id?-1:1);let f=R.padX+p*(R.boxW+R.gapX),m=R.padY;for(let y of i)o.set(y.id,{x:f,y:m}),m+=R.boxH+R.gapY;l=Math.max(l,m-R.gapY)}let d=a.length?a[a.length-1]:0,u=R.padX*2+(d+1)*R.boxW+d*R.gapX,c=Math.max(l+R.padY,R.padY*2+R.boxH);return{pos:o,width:u,height:c}}function kn(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}\u2026`}function xn({nodes:e,edges:t,onOpen:r,selected:s}){let o=N(()=>wn(e),[e]),a=N(()=>new Set(e.map(u=>u.id)),[e]);if(e.length===0)return n("div",{class:"empty",children:[n("div",{class:"empty-title",children:"no tasks in the graph yet"}),n("div",{class:"empty-sub mono",children:"the dependency DAG renders here once tasks exist"})]});let l=t.filter(u=>a.has(u.from)&&a.has(u.to)),d=u=>{let c=o.pos.get(u.from),p=o.pos.get(u.to);if(!c||!p)return null;let i=c.x+R.boxW,f=c.y+R.boxH/2,m=p.x,y=p.y+R.boxH/2,w=Math.max(28,(m-i)/2);return`M ${i} ${f} C ${i+w} ${f}, ${m-w} ${y}, ${m} ${y}`};return n("div",{class:"nest",children:n("svg",{class:"nest-svg",width:o.width,height:o.height,viewBox:`0 0 ${o.width} ${o.height}`,role:"group","aria-label":"Task dependency graph",children:[n("defs",{children:[n("marker",{id:"arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto-start-reverse",children:n("path",{d:"M 0 0 L 10 5 L 0 10 z",class:"arrow-head"})}),n("marker",{id:"arrow-soft",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:n("path",{d:"M 0 0 L 10 5 L 0 10 z",class:"arrow-head-soft"})})]}),n("g",{class:"nest-edges",children:l.map((u,c)=>{let p=d(u);return p?n("path",{d:p,fill:"none",class:u.kind==="hard"?"edge edge-hard":"edge edge-soft"},`${u.from}->${u.to}:${u.kind}:${c}`):null})}),n("g",{class:"nest-nodes",children:e.map(u=>{let c=o.pos.get(u.id);if(!c)return null;let p=Ce(u),i=s===u.id,f=m=>r(u.id,m);return n("g",{class:`node ${i?"node-selected":""}`,"data-status":p,"data-task-id":u.id,transform:`translate(${c.x} ${c.y})`,tabIndex:0,role:"button","aria-label":`${ue(u)}: ${u.title}`,"aria-haspopup":"dialog","aria-expanded":i,onClick:m=>f(m.currentTarget),onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),f(m.currentTarget))},children:[n("rect",{class:"node-box",x:"0",y:"0",width:R.boxW,height:R.boxH}),n("rect",{class:"node-spine",x:"0",y:"0",width:R.spineW,height:R.boxH}),n("text",{class:"node-status mono",x:R.spineW+12,y:"22",children:ue(u)}),n("text",{class:"node-title",x:R.spineW+12,y:"44",children:kn(u.title,30)})]},u.id)})})]})})}function Sn({slug:e,node:t,onClose:r,returnFocus:s,canMutate:o}){let[a,l]=b(null),[d,u]=b(null),[c,p]=b({busy:!1,msg:null,err:null}),i=I(null),f=I(r);f.current=r;let m=Ce(t),y=Mt(t),w=t.status==="completed"||t.status==="review",_=w||t.column==="review",v=y||w,h=w&&!y,g=t.runId??t.id,k=`task-update-${t.id.replace(/[^A-Za-z0-9_-]/g,"-")}`;M(()=>{let x=s??document.activeElement,$=window.requestAnimationFrame(()=>{(i.current?.querySelector("[data-autofocus]")??i.current)?.focus()}),A=U=>{if(U.key==="Escape"){U.preventDefault(),f.current();return}if(U.key!=="Tab"||!i.current)return;let z=Array.from(i.current.querySelectorAll('a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(z.length===0){U.preventDefault(),i.current.focus();return}let Ne=z[0],Ue=z[z.length-1];U.shiftKey&&document.activeElement===Ne?(U.preventDefault(),Ue.focus()):!U.shiftKey&&document.activeElement===Ue&&(U.preventDefault(),Ne.focus())};return window.addEventListener("keydown",A),()=>{window.cancelAnimationFrame($),window.removeEventListener("keydown",A),x?.isConnected?x.focus():Array.from(document.querySelectorAll("[data-task-id]")).find(z=>z.getAttribute("data-task-id")===t.id)?.focus()}},[t.id]),M(()=>{let x=!1;return l(null),u(null),yt(e,g,200).then($=>{x||l($)}).catch($=>{x||u(String($?.message??$))}),()=>{x=!0}},[e,g]);let S=N(()=>{let x=a??"";return!t.lastLine||x.trimEnd().endsWith(t.lastLine.trimEnd())?x:x?`${x}
4
- ${t.lastLine}`:t.lastLine},[a,t.lastLine]),L=async()=>{p({busy:!0,msg:null,err:null});try{let x=await bt(e,g);if(x.status==="merge-conflict"||x.status==="conflict"||x.status==="blocked"){let A=x.conflictedFiles?.length??0;p({busy:!1,msg:null,err:A?`conflict in ${A} file(s)`:"merge conflict"})}else p({busy:!1,msg:x.status,err:null})}catch(x){p({busy:!1,msg:null,err:String(x?.message??x)})}},B=async()=>{p({busy:!0,msg:null,err:null});try{await wt(e,g),p({busy:!1,msg:"cancel requested",err:null})}catch(x){p({busy:!1,msg:null,err:String(x?.message??x)})}};return n("div",{class:"drawer-overlay",onClick:r,children:n("aside",{ref:i,class:"drawer",onClick:x=>x.stopPropagation(),"data-status":m,role:"dialog","aria-modal":"true","aria-labelledby":"task-detail-title",tabIndex:-1,children:[n("div",{class:"drawer-spine","data-status":m}),n("header",{class:"drawer-head",children:[n("div",{class:"drawer-head-top",children:[n("span",{class:"card-status mono","data-status":m,children:ue(t)}),n("button",{type:"button",class:"drawer-close",onClick:r,"aria-label":"Close",children:"\u2715"})]}),n("h2",{class:"drawer-title",id:"task-detail-title",children:t.title}),n("div",{class:"drawer-meta mono",children:[n("span",{children:t.backend}),t.model&&n("span",{children:t.model}),t.effort&&n("span",{children:t.effort}),t.tokens&&n("span",{children:["\u2193",pe(t.tokens.input)," \u2191",pe(t.tokens.output)]})]}),t.workspace&&n("div",{class:"drawer-worktree mono",title:t.workspace.path,children:t.workspace.workspaceName??t.workspace.path}),t.delivery?.required&&n("div",{class:"drawer-worktree mono",title:t.delivery.url??t.delivery.appPath??t.delivery.target,children:["delivery ",t.delivery.status," \xB7 ",t.delivery.target??"target not recorded",t.delivery.revision?` \xB7 ${t.delivery.revision}`:""]})]}),o&&n("div",{class:"drawer-actions",children:[_&&n("button",{type:"button",class:"btn btn-accent",onClick:L,disabled:c.busy,children:c.busy?"Merging\u2026":"Merge"}),h&&n("button",{type:"button",class:"btn",onClick:()=>document.getElementById(k)?.focus(),disabled:c.busy,children:"Request changes"}),y&&n("button",{type:"button",class:"btn btn-danger",onClick:B,disabled:c.busy,children:c.busy?"Stopping\u2026":"Stop"}),c.msg&&n("span",{class:"action-msg","aria-live":"polite",children:c.msg}),c.err&&n("span",{class:"action-err",role:"alert",children:c.err})]}),n("div",{class:"drawer-scroll",children:[n(En,{updates:t.updates??[],lastLine:t.lastLine}),n("div",{class:"drawer-log",children:[n("div",{class:"drawer-log-head mono",children:[n("span",{children:"Worker log"}),y&&n("span",{class:"pulse-dot","aria-hidden":"true"})]}),n(Rn,{text:S,error:d,loading:a===null&&!d})]})]}),o&&v&&n("div",{class:"drawer-steer",children:n(It,{slug:e,targetId:g,inputId:k,label:h?"Request changes":"Send update",submitLabel:h?"Request changes":"Send update",placeholder:h?"Describe what should change before this task is merged.":"Add context or redirect this worker.",autoFocus:!0})})]})})}function En({updates:e,lastLine:t}){let r=e.filter(s=>s.instruction.trim());return n("section",{class:"task-updates","aria-labelledby":"task-updates-title",children:[n("div",{class:"task-updates-head",children:[n("h3",{id:"task-updates-title",children:"Updates"}),r.length>0&&n("span",{class:"task-updates-count mono",children:r.length})]}),n("div",{class:"task-thread",children:[r.length===0&&!t&&n("p",{class:"task-thread-empty",children:"No updates have been sent yet."}),r.map((s,o)=>n("article",{class:"task-update task-update-user",children:[n("div",{class:"task-update-avatar","aria-hidden":"true",children:"Y"}),n("div",{class:"task-update-body",children:[n("div",{class:"task-update-meta",children:[n("span",{children:Tn(s.source)}),n("time",{class:"mono",dateTime:s.ts,children:Dt(s.ts)})]}),n("p",{children:s.instruction})]})]},`${s.ts}-${o}`)),t&&n("article",{class:"task-update task-update-agent",children:[n("div",{class:"task-update-avatar task-update-avatar-agent","aria-hidden":"true",children:"R"}),n("div",{class:"task-update-body",children:[n("div",{class:"task-update-meta",children:n("span",{children:"Latest from worker"})}),n("p",{class:"mono",children:t})]})]})]})]})}function Tn(e){let t=(e??"").trim().toLowerCase();return!t||t==="user"||t==="web"||t==="operator"||t==="regoal"?"You":t==="steerer"||t==="rudder"?"Rudder":e??"You"}function Rn({text:e,error:t,loading:r}){let s=I(null);return M(()=>{let o=s.current;o&&(o.scrollTop=o.scrollHeight)},[e]),t?n("div",{class:"banner banner-error mono",children:["log unavailable: ",t]}):r?n("div",{class:"log-pre log-loading mono","aria-label":"Loading worker log",children:[n("div",{class:"skel skel-line",style:"width:70%"}),n("div",{class:"skel skel-line",style:"width:90%"}),n("div",{class:"skel skel-line",style:"width:55%"})]}):n("pre",{ref:s,class:"log-pre mono",children:e||"no output yet"})}function Pt(e){return e.status==="failed"?e.error||"Delivery failed":e.status==="accepted"?e.mode==="resumed"?"Accepted \xB7 agent is resuming":"Accepted \xB7 agent is restarting":e.status==="delivered"?e.mode==="resumed"?"Delivered \xB7 agent resumed":"Delivered to agent":e.mode==="resumed"?"Queued \xB7 agent is resuming":e.mode==="redirected"?"Queued for the live agent":"Queued for delivery"}function It({slug:e,targetId:t,inputId:r,label:s,submitLabel:o,placeholder:a,autoFocus:l=!1}){let[d,u]=b(""),[c,p]=b(!1),[i,f]=b(null),[m,y]=b(null);M(()=>{if(i?.state!=="queued"||!i.requestId||window.__RUDDER_CONTROL_MODE__!=="projector")return;let v=!1,h,g=async()=>{let k=0;try{let S=await Pe(e,i.requestId);if(v)return;if(S.status==="delivered"||S.status==="failed"){f(L=>L?.requestId===S.requestId?{...L,state:S.status,message:Pt(S)}:L);return}}catch{k=500}v||(h=window.setTimeout(g,k))};return g(),()=>{v=!0,h!==void 0&&window.clearTimeout(h)}},[e,i?.state,i?.requestId]);let w=async()=>{let v=d.trim();if(!(!v||c)){p(!0),f({instruction:v,state:"sending",message:"Sending request\u2026"}),y(null);try{let h=await kt(e,t,v);u(""),f({instruction:v,requestId:h.requestId,state:h.status,message:Pt(h)})}catch(h){f(null),y(String(h?.message??h))}finally{p(!1)}}},_=v=>{(v.metaKey||v.ctrlKey)&&v.key==="Enter"&&(v.preventDefault(),w())};return n("form",{class:"steer",onSubmit:v=>{v.preventDefault(),w()},"aria-busy":c,children:[n("label",{class:"steer-label",for:r,children:s}),n("textarea",{id:r,class:"steer-input",rows:3,maxLength:8e3,placeholder:a,value:d,disabled:c,"data-autofocus":l?"true":void 0,"aria-describedby":`${r}-hint${i?` ${r}-status`:""}`,onInput:v=>{u(v.target.value),m&&y(null)},onKeyDown:_}),n("div",{class:"steer-actions",children:[n("span",{class:"steer-hint",id:`${r}-hint`,children:"\u2318/Ctrl + Enter to send"}),n("button",{type:"submit",class:"btn btn-accent",disabled:c||!d.trim(),children:c?"Sending\u2026":o})]}),i&&n("div",{class:`steer-feedback steer-feedback-${i.state}`,id:`${r}-status`,"aria-live":"polite",children:[n("span",{class:"steer-feedback-state",children:i.message}),n("span",{class:"steer-feedback-text",children:i.instruction})]}),m&&n("div",{class:"action-err steer-error",role:"alert",children:["Could not send: ",m]})]})}function Pn({slug:e,activity:t,canSteerConductor:r}){let s=I(null);return M(()=>{let o=s.current;o&&(o.scrollTop=o.scrollHeight)},[t]),n("div",{class:"activity",children:[r&&n("div",{class:"activity-steer",children:n(It,{slug:e,targetId:"conductor",inputId:"conductor-update",label:"Message conductor",submitLabel:"Send update",placeholder:"Tell the live orchestrator what to do next."})}),t.length===0?n("div",{class:"empty",children:[n("div",{class:"empty-title",children:"no activity yet"}),n("div",{class:"empty-sub mono",children:"the conductor narrates what it is doing here as work runs"})]}):n("div",{class:"activity-feed",ref:s,children:t.map((o,a)=>n("div",{class:`activity-entry activity-${o.kind}`,children:[n("span",{class:"activity-dot","aria-hidden":"true"}),n("span",{class:"activity-text",children:o.text}),o.ts&&n("span",{class:"activity-ts mono",children:Dt(o.ts)})]},`${o.ts??""}-${a}`))})]})}function Dt(e){let t=/^\d{10,}$/.test(e.trim())?Number(e):e,r=new Date(t);return Number.isNaN(r.getTime())?"":r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function $n({memory:e}){return e.length===0?n("div",{class:"empty",children:[n("div",{class:"empty-title",children:"no decisions recorded yet"}),n("div",{class:"empty-sub mono",children:"agents append cross-cutting decisions here as they work"})]}):n("div",{class:"memory",children:e.map((t,r)=>n("article",{class:"memory-entry",children:[n("div",{class:"memory-bead","aria-hidden":"true"}),n("div",{class:"memory-content",children:[n("p",{class:"memory-text",children:t.text}),n("div",{class:"memory-meta mono",children:[t.owner&&n("span",{class:"memory-owner",children:t.owner}),t.ts&&n("span",{class:"memory-ts",children:t.ts})]})]})]},r))})}function Cn(){return n("div",{class:"board","aria-hidden":"true",children:$t.map(e=>n("section",{class:"column",children:[n("header",{class:"column-head",children:[n("span",{class:"column-title",children:e.label}),n("span",{class:"column-count mono",children:"\xB7"})]}),n("div",{class:"column-body",children:[n("div",{class:"card card-skeleton",children:[n("div",{class:"skel skel-line",style:"width:60%"}),n("div",{class:"skel skel-line",style:"width:85%"})]}),e.key==="running"&&n("div",{class:"card card-skeleton",children:[n("div",{class:"skel skel-line",style:"width:70%"}),n("div",{class:"skel skel-line",style:"width:50%"})]})]})]},e.key))})}var Me={claude:"Claude Code",codex:"Codex"};function Y(e){return e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:`$${e.toFixed(2)}`}function D(e){return e>=1e9?`${(e/1e9).toFixed(2)}B`:e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Math.round(e))}function H(e){return e>=1<<30?`${(e/(1<<30)).toFixed(2)} GB`:e>=1<<20?`${(e/(1<<20)).toFixed(0)} MB`:`${(e/1024).toFixed(0)} KB`}function Ae(e){return e.input+e.output+e.cacheWrite+e.cacheRead}function K(e,t){return t==="cost"?e.cost:Ae(e)}function Q(e,t){return t==="cost"?Y(e):D(e)}function Mn(e,t){if(!e)return"";let r=new Date(e).getTime()-t;if(Number.isNaN(r))return"";if(r<=0)return"resets now";let s=Math.round(r/6e4);if(s<60)return`resets in ${s}m`;let o=Math.floor(s/60);return o<24?`resets in ${o}h ${s%60}m`:`resets in ${Math.floor(o/24)}d ${o%24}h`}function Lt(e){return e.replace(/^claude-/,"").replace(/-\d{8}$/,"")}function An(e){let[,t,r]=e.split("-");return`${Number(t)}/${Number(r)}`}function Nt(){let[e,t]=b("tokens");return n("div",{class:"page usage-page",children:[n("header",{class:"topbar",children:[n("div",{class:"brand",children:[n("a",{class:"brand-link",href:"/rudder",title:"Back to all projects",children:[n("span",{class:"brand-mark",children:"\u25B0"}),n("span",{class:"brand-back",children:"\u2190 all projects"})]}),n("span",{class:"brand-name",children:"Usage"}),n("span",{class:"brand-sub mono",children:"this machine"})]}),n("div",{class:"toolbar-actions",children:n("div",{class:"view-toggle",role:"group","aria-label":"Usage view",children:[n("button",{type:"button","aria-pressed":e==="tokens",class:`toggle ${e==="tokens"?"toggle-on":""}`,onClick:()=>t("tokens"),children:"Token usage"}),n("button",{type:"button","aria-pressed":e==="machine",class:`toggle ${e==="machine"?"toggle-on":""}`,onClick:()=>t("machine"),children:"Machine resources"})]})})]}),n("main",{class:"usage-main",children:e==="tokens"?n(Dn,{}):n(qn,{})})]})}function jn(){let[e,t]=b(null),[r,s]=b(null),[o,a]=b(!1),[l,d]=b(Date.now()),u=c=>{a(!0),mt(c).then(p=>{t(p),s(null)}).catch(p=>s(String(p?.message??p))).finally(()=>a(!1))};return M(()=>{u(!1);let c=setInterval(()=>d(Date.now()),3e4),p=setInterval(()=>u(!1),5*6e4);return()=>{clearInterval(c),clearInterval(p)}},[]),n("section",{class:"usage-section",children:[n("div",{class:"usage-section-head",children:[n("h2",{class:"usage-h2",children:"Subscription quota"}),n("div",{class:"usage-section-actions",children:[e&&n("span",{class:"usage-muted mono",children:["refreshed ",new Date(e.fetchedAt).toLocaleTimeString()," \xB7 every ",Math.round(e.ttlSeconds/60),"m"]}),n("button",{type:"button",class:"btn",disabled:o,onClick:()=>u(!0),children:o?"refreshing\u2026":"refresh"})]})]}),r&&n("div",{class:"banner banner-error mono",children:["quota failed: ",r]}),n("div",{class:"quota-grid",children:[(e?.accounts??[]).map(c=>n(In,{account:c,now:l},c.provider)),!e&&!r&&n(j,{children:[n("div",{class:"quota-card quota-card-skeleton"}),n("div",{class:"quota-card quota-card-skeleton"})]})]}),n("p",{class:"usage-note",children:"Read from the providers' own usage endpoints with the sign-ins the CLIs already hold. Rudder never handles a password and never stores a token."})]})}function Fn(e){return e>=90?"meter-fill meter-hot":e>=70?"meter-fill meter-warm":"meter-fill"}function In({account:e,now:t}){return n("div",{class:`quota-card ${e.error?"quota-card-error":""}`,children:[n("div",{class:"quota-head",children:[n("span",{class:`provider-dot provider-${e.provider}`,"aria-hidden":"true"}),n("span",{class:"quota-provider",children:Me[e.provider]}),e.plan&&n("span",{class:"quota-plan mono",children:e.plan})]}),e.email&&n("div",{class:"quota-email mono",children:e.email}),e.blocked&&!e.error&&n("div",{class:"quota-blocked mono",children:e.blocked}),e.error?n("div",{class:"quota-error mono",children:e.error}):n("div",{class:"meters",children:e.windows.map(r=>n("div",{class:"meter",children:[n("div",{class:"meter-row",children:[n("span",{class:"meter-label",children:r.label}),n("span",{class:"meter-value mono",children:[r.percent,"%"]})]}),n("div",{class:"meter-track",role:"progressbar","aria-valuenow":r.percent,"aria-valuemin":0,"aria-valuemax":100,children:n("div",{class:Fn(r.percent),style:{width:`${Math.min(100,r.percent)}%`}})}),n("div",{class:"meter-reset mono",children:Mn(r.resetsAt,t)})]},r.label))})]})}function Dn(){let[e,t]=b("30d"),[r,s]=b(null),[o,a]=b(null);return M(()=>{let l=!1;return s(null),ft(e).then(d=>{l||(s(d),a(null))}).catch(d=>{l||a(String(d?.message??d))}),()=>{l=!0}},[e]),n(j,{children:[n(jn,{}),n(Ln,{report:r,error:o,range:e,onRange:t})]})}function Ln({report:e,error:t,range:r,onRange:s}){let[o,a]=b("cost"),[l,d]=b(new Set),[u,c]=b(null),[p,i]=b(null),[f,m]=b(null),[y,w]=b(!1),_=g=>{d(k=>{let S=new Set(k);return S.has(g)?S.delete(g):S.add(g),S})},v=N(()=>{if(!e)return 0;let g=0;for(let k of["claude","codex"])l.has(k)||(g+=K(e.providers[k],o));return g},[e,l,o]),h=e?.days.find(g=>g.day===u)??null;return n(j,{children:n("section",{class:"usage-section",children:[n("div",{class:"usage-section-head",children:[n("h2",{class:"usage-h2",children:"Token usage"}),n("div",{class:"usage-section-actions",children:[n("div",{class:"view-toggle",role:"group","aria-label":"Metric",children:["cost","tokens"].map(g=>n("button",{type:"button","aria-pressed":o===g,class:`toggle ${o===g?"toggle-on":""}`,onClick:()=>a(g),children:g==="cost"?"Cost":"Tokens"},g))}),n("div",{class:"view-toggle",role:"group","aria-label":"Range",children:["7d","30d","90d"].map(g=>n("button",{type:"button","aria-pressed":r===g,class:`toggle ${r===g?"toggle-on":""}`,onClick:()=>s(g),children:g},g))})]})]}),t&&n("div",{class:"banner banner-error mono",children:["usage failed: ",t]}),!e&&!t&&n("div",{class:"usage-loading mono",children:"scanning session logs\u2026"}),e&&n(j,{children:[n("div",{class:"stat-row",children:[n("div",{class:"stat",children:[n("div",{class:"stat-label",children:"Cost to you"}),n("div",{class:"stat-value",children:"$0"}),n("div",{class:"stat-sub",children:"subscription"})]}),n("div",{class:"stat",children:[n("div",{class:"stat-label",children:"At API rates"}),n("div",{class:"stat-value",children:Y(e.total.cost)}),n("div",{class:"stat-sub",children:[D(Ae(e.total))," tokens \xB7 ",e.total.calls," calls"]})]}),n("div",{class:"stat",children:[n("div",{class:"stat-label",children:"Caching saved"}),n("div",{class:"stat-value",children:Y(e.total.cacheSavings)}),n("div",{class:"stat-sub",children:[D(e.total.cacheRead)," cache reads"]})]}),n("div",{class:"stat",children:[n("div",{class:"stat-label",children:"Output"}),n("div",{class:"stat-value",children:D(e.total.output)}),n("div",{class:"stat-sub",children:[D(e.total.input+e.total.cacheWrite)," fresh input"]})]})]}),n("div",{class:"provider-chips",children:[["claude","codex"].map(g=>n("button",{type:"button",class:`chip ${l.has(g)?"chip-off":""}`,"aria-pressed":!l.has(g),onClick:()=>_(g),title:"Click to show or hide in the chart",children:[n("span",{class:`provider-dot provider-${g}`,"aria-hidden":"true"}),Me[g],n("span",{class:"chip-value mono",children:Q(K(e.providers[g],o),o)})]},g)),n("span",{class:"usage-muted mono",children:[Q(v,o)," shown \xB7 ",e.scannedFiles," logs"]})]}),n(Un,{report:e,metric:o,hidden:l,selected:u,onSelect:c}),h&&n("div",{class:"day-detail",children:[n("div",{class:"day-detail-head",children:[n("strong",{children:h.day}),n("button",{type:"button",class:"btn",onClick:()=>c(null),children:"close"})]}),n("div",{class:"day-detail-grid",children:["claude","codex"].map(g=>n("div",{class:"day-detail-cell",children:[n("span",{class:`provider-dot provider-${g}`,"aria-hidden":"true"})," ",Me[g],n("div",{class:"mono",children:[Y(h[g].cost)," \xB7 ",D(Ae(h[g]))," tokens \xB7 ",h[g].calls," calls"]})]},g))})]}),n("div",{class:"usage-columns",children:[n("div",{children:[n("h3",{class:"usage-h3",children:"Models"}),n("table",{class:"usage-table",children:[n("thead",{children:n("tr",{children:[n("th",{children:"model"}),n("th",{class:"num",children:o==="cost"?"cost":"tokens"}),n("th",{class:"num",children:"output"}),n("th",{class:"num",children:"cache read"}),n("th",{class:"num",children:"sessions"})]})}),n("tbody",{children:[e.models.map(g=>{let k=`${g.provider}:${g.model}`,S=p===k;return n(j,{children:[n("tr",{class:`usage-row ${S?"usage-row-open":""}`,onClick:()=>i(S?null:k),children:[n("td",{children:[n("span",{class:`provider-dot provider-${g.provider}`,"aria-hidden":"true"}),n("span",{class:"mono",children:Lt(g.model)})]}),n("td",{class:"num mono",children:Q(K(g.totals,o),o)}),n("td",{class:"num mono",children:D(g.totals.output)}),n("td",{class:"num mono",children:D(g.totals.cacheRead)}),n("td",{class:"num mono",children:g.sessions})]},k),S&&n("tr",{class:"usage-drill",children:n("td",{colSpan:5,children:n(Nn,{totals:g.totals})})},`${k}-drill`)]})}),e.models.length===0&&n("tr",{children:n("td",{colSpan:5,class:"usage-muted mono",children:"no usage in this range"})})]})]})]}),n("div",{children:[n("div",{class:"usage-h3-row",children:[n("h3",{class:"usage-h3",children:"Workspaces"}),e.projects.length>8&&n("button",{type:"button",class:"btn-link mono",onClick:()=>w(g=>!g),children:y?"top 8":`All ${e.projects.length} \u2192`})]}),n(Bn,{projects:y?e.projects:e.projects.slice(0,8),metric:o,selected:f,onSelect:m})]})]}),n("p",{class:"usage-note",children:e.pricingNote})]})]})})}function Nn({totals:e}){return n("div",{class:"totals-breakdown mono",children:[n("span",{children:["input ",D(e.input)]}),n("span",{children:["output ",D(e.output)]}),n("span",{children:["cache write ",D(e.cacheWrite)]}),n("span",{children:["cache read ",D(e.cacheRead)]}),n("span",{children:[Y(e.cost)," at API rates"]}),n("span",{children:[Y(e.cacheSavings)," saved by caching"]})]})}function Un({report:e,metric:t,hidden:r,selected:s,onSelect:o}){let l=e.days.map(g=>({day:g.day,claude:r.has("claude")?0:K(g.claude,t),codex:r.has("codex")?0:K(g.codex,t)})),d=Math.max(1e-9,...l.map(g=>g.claude+g.codex)),u=900,c=180,p=44,i=22,f=8,m=u-p-8,y=c-i-f,w=m/Math.max(1,l.length),_=Math.max(2,w*.7),v=l.length>45?10:l.length>14?5:1,h=[0,.5,1].map(g=>({f:g,label:Q(d*g,t)}));return n("div",{class:"chart-wrap",children:n("svg",{class:"daily-chart",viewBox:`0 0 ${u} ${c}`,role:"img","aria-label":"Daily usage",children:[h.map(g=>{let k=f+y-y*g.f;return n("g",{children:[n("line",{x1:p,x2:u-8,y1:k,y2:k,class:"chart-grid"}),n("text",{x:p-6,y:k+4,class:"chart-tick","text-anchor":"end",children:g.label})]},g.f)}),l.map((g,k)=>{let S=p+k*w+(w-_)/2,L=g.claude/d*y,B=g.codex/d*y,x=f+y-B,$=x-L,A=s===g.day;return n("g",{class:`chart-bar ${A?"chart-bar-selected":""}`,onClick:()=>o(A?null:g.day),children:[n("title",{children:[g.day,": ",Q(g.claude+g.codex,t)]}),n("rect",{x:p+k*w,y:f,width:w,height:y,class:"chart-hit"}),n("rect",{x:S,y:x,width:_,height:B,class:"bar-codex"}),n("rect",{x:S,y:$,width:_,height:L,class:"bar-claude"}),k%v===0&&n("text",{x:S+_/2,y:c-6,class:"chart-tick","text-anchor":"middle",children:An(g.day)})]},g.day)})]})})}function Bn({projects:e,metric:t,selected:r,onSelect:s}){let o=Math.max(1e-9,...e.map(u=>K(u.totals,t))),[a,l]=b(null),d=u=>{navigator.clipboard?.writeText(u).then(()=>{l(u),setTimeout(()=>l(null),1200)},()=>l(null))};return e.length===0?n("div",{class:"usage-muted mono",children:"no workspaces in this range"}):n("div",{class:"project-bars",children:e.map(u=>{let c=K(u.totals,t),p=r===u.key;return n("div",{class:`project-bar ${p?"project-bar-open":""}`,children:[n("button",{type:"button",class:"project-bar-btn",onClick:()=>s(p?null:u.key),children:[n("div",{class:"project-bar-row",children:[n("span",{class:"project-name",children:u.slug?n("a",{href:`/rudder/${encodeURIComponent(u.slug)}`,onClick:i=>i.stopPropagation(),children:u.name}):u.name}),n("span",{class:"mono project-value",children:Q(c,t)})]}),n("div",{class:"project-track",children:n("div",{class:"project-fill",style:{width:`${c/o*100}%`}})}),n("div",{class:"project-path mono",children:u.key})]}),p&&n("div",{class:"project-sessions",children:[n("div",{class:"usage-muted mono",children:"top sessions by cost \xB7 click to copy the id for --resume"}),u.sessions.slice(0,10).map(i=>n("button",{type:"button",class:"session-row",title:`${i.provider} ${i.id}`,onClick:()=>d(i.id),children:[n("span",{class:`provider-dot provider-${i.provider}`,"aria-hidden":"true"}),n("span",{class:"mono session-id",children:a===i.id?"copied \u2713":i.id.slice(0,8)}),n("span",{class:"mono session-model",children:Lt(i.model)}),n("span",{class:"mono session-when",children:new Date(i.lastAt).toLocaleString()}),n("span",{class:"mono session-cost",children:Q(K(i.totals,t),t)})]},i.id))]})]},u.key)})})}function qn(){let[e,t]=b(null),[r,s]=b(null);return M(()=>{let o=!1,a=()=>gt().then(d=>{o||(t(d),s(null))}).catch(d=>{o||s(String(d?.message??d))});a();let l=setInterval(a,2e3);return()=>{o=!0,clearInterval(l)}},[]),r?n("div",{class:"banner banner-error mono",children:["machine failed: ",r]}):e?n(On,{report:e}):n("div",{class:"usage-loading mono",children:"sampling\u2026"})}function On({report:e}){let t=e.totalMem-e.freeMem,r=e.byKind.claude.rss+e.byKind.codex.rss+e.byKind.opencode.rss,s=e.byKind.rudder.rss,o=Math.max(0,t-r-s),a=l=>`${(l/e.totalMem*100).toFixed(1)}%`;return n("section",{class:"usage-section",children:[n("div",{class:"usage-section-head",children:[n("h2",{class:"usage-h2",children:"Machine resources"}),n("span",{class:"usage-muted mono",children:["live \xB7 every 2s \xB7 load ",e.load.map(l=>l.toFixed(2)).join(" ")," on ",e.cpus," cores"]})]}),n("div",{class:"stat-row",children:[n("div",{class:"stat",children:[n("div",{class:"stat-label",children:"Rudder"}),n("div",{class:"stat-value",children:H(s)}),n("div",{class:"stat-sub",children:[e.byKind.rudder.cpu.toFixed(1),"% cpu \xB7 ",e.byKind.rudder.count," procs"]})]}),n("div",{class:"stat",children:[n("div",{class:"stat-label",children:"Agents"}),n("div",{class:"stat-value",children:H(r)}),n("div",{class:"stat-sub",children:[(e.byKind.claude.cpu+e.byKind.codex.cpu+e.byKind.opencode.cpu).toFixed(1),"% cpu \xB7"," ",e.byKind.claude.count+e.byKind.codex.count+e.byKind.opencode.count," procs"]})]}),n("div",{class:"stat",children:[n("div",{class:"stat-label",children:"System RAM"}),n("div",{class:"stat-value",children:[H(t)," / ",H(e.totalMem)]}),n("div",{class:"stat-sub",children:[a(t)," in use"]})]})]}),n("div",{class:"ram-bar",role:"img","aria-label":"RAM split",children:[n("div",{class:"ram-seg ram-rudder",style:{width:a(s)},title:`rudder ${H(s)}`}),n("div",{class:"ram-seg ram-agents",style:{width:a(r)},title:`agents ${H(r)}`}),n("div",{class:"ram-seg ram-other",style:{width:a(o)},title:`everything else ${H(o)}`})]}),n("div",{class:"ram-legend mono",children:[n("span",{children:[n("i",{class:"ram-swatch ram-rudder"})," rudder"]}),n("span",{children:[n("i",{class:"ram-swatch ram-agents"})," agents"]}),n("span",{children:[n("i",{class:"ram-swatch ram-other"})," everything else"]}),n("span",{children:["free ",H(e.freeMem)]})]}),n("h3",{class:"usage-h3",children:"Processes"}),n("table",{class:"usage-table",children:[n("thead",{children:n("tr",{children:[n("th",{children:"kind"}),n("th",{children:"pid"}),n("th",{class:"num",children:"cpu"}),n("th",{class:"num",children:"memory"}),n("th",{children:"uptime"}),n("th",{children:"command"})]})}),n("tbody",{children:[e.processes.map(l=>n("tr",{children:[n("td",{children:[n("span",{class:`provider-dot provider-${l.kind}`,"aria-hidden":"true"}),l.kind]}),n("td",{class:"mono",children:l.pid}),n("td",{class:"num mono",children:[l.cpu.toFixed(1),"%"]}),n("td",{class:"num mono",children:H(l.rss)}),n("td",{class:"mono",children:l.elapsed}),n("td",{class:"mono cmd",title:l.command,children:l.command.length>90?`${l.command.slice(0,90)}\u2026`:l.command})]},l.pid)),e.processes.length===0&&n("tr",{children:n("td",{colSpan:6,class:"usage-muted mono",children:"no agent processes running"})})]})]})]})}var Hn="default-src 'none'; script-src 'none'; connect-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:; media-src 'none'; object-src 'none'; frame-src 'none'; form-action 'none'; base-uri 'none'",Wn=new Set(["image/png","image/jpeg","image/gif","image/webp","image/avif"]);function Kn(e,t){if(!t||t.length>2048||/[\\\u0000-\u001f\u007f]/.test(t)||/^[a-z][a-z\d+.-]*:/i.test(t)||t.startsWith("/"))return null;let r=t.split(/[?#]/,1)[0],s;try{s=decodeURIComponent(r)}catch{return null}if(s!==r&&/[\\/?#\u0000-\u001f\u007f]/.test(s))return null;let o=e.split("/").slice(0,-1);for(let a of s.split("/"))if(!(!a||a==="."))if(a===".."){if(!o.length)return null;o.pop()}else{if(a.includes(":"))return null;o.push(a)}return o.join("/")}function Ut(e){return e.replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}function Vn(e){let t=!1;return e.split(/\r?\n/).map(r=>{if(/^```/.test(r))return t=!t,t?"<pre><code>":"</code></pre>";if(t)return`${Ut(r)}
4
+ ${t.lastLine}`:t.lastLine},[a,t.lastLine]),L=async()=>{p({busy:!0,msg:null,err:null});try{let x=await bt(e,g);if(x.status==="merge-conflict"||x.status==="conflict"||x.status==="blocked"){let A=x.conflictedFiles?.length??0;p({busy:!1,msg:null,err:A?`conflict in ${A} file(s)`:"merge conflict"})}else p({busy:!1,msg:x.status,err:null})}catch(x){p({busy:!1,msg:null,err:String(x?.message??x)})}},B=async()=>{p({busy:!0,msg:null,err:null});try{await wt(e,g),p({busy:!1,msg:"cancel requested",err:null})}catch(x){p({busy:!1,msg:null,err:String(x?.message??x)})}};return n("div",{class:"drawer-overlay",onClick:r,children:n("aside",{ref:i,class:"drawer",onClick:x=>x.stopPropagation(),"data-status":m,role:"dialog","aria-modal":"true","aria-labelledby":"task-detail-title",tabIndex:-1,children:[n("div",{class:"drawer-spine","data-status":m}),n("header",{class:"drawer-head",children:[n("div",{class:"drawer-head-top",children:[n("span",{class:"card-status mono","data-status":m,children:ue(t)}),n("button",{type:"button",class:"drawer-close",onClick:r,"aria-label":"Close",children:"\u2715"})]}),n("h2",{class:"drawer-title",id:"task-detail-title",children:t.title}),n("div",{class:"drawer-meta mono",children:[n("span",{children:t.backend}),t.model&&n("span",{children:t.model}),t.effort&&n("span",{children:t.effort}),t.tokens&&n("span",{children:["\u2193",pe(t.tokens.input)," \u2191",pe(t.tokens.output)]})]}),t.workspace&&n("div",{class:"drawer-worktree mono",title:t.workspace.path,children:t.workspace.workspaceName??t.workspace.path}),t.delivery?.required&&n("div",{class:"drawer-worktree mono",title:t.delivery.url??t.delivery.appPath??t.delivery.target,children:["delivery ",t.delivery.status," \xB7 ",t.delivery.target??"target not recorded",t.delivery.revision?` \xB7 ${t.delivery.revision}`:""]})]}),o&&n("div",{class:"drawer-actions",children:[_&&n("button",{type:"button",class:"btn btn-accent",onClick:L,disabled:c.busy,children:c.busy?"Merging\u2026":"Merge"}),h&&n("button",{type:"button",class:"btn",onClick:()=>document.getElementById(k)?.focus(),disabled:c.busy,children:"Request changes"}),y&&n("button",{type:"button",class:"btn btn-danger",onClick:B,disabled:c.busy,children:c.busy?"Stopping\u2026":"Stop"}),c.msg&&n("span",{class:"action-msg","aria-live":"polite",children:c.msg}),c.err&&n("span",{class:"action-err",role:"alert",children:c.err})]}),n("div",{class:"drawer-scroll",children:[n(En,{updates:t.updates??[],lastLine:t.lastLine}),n("div",{class:"drawer-log",children:[n("div",{class:"drawer-log-head mono",children:[n("span",{children:"Worker log"}),y&&n("span",{class:"pulse-dot","aria-hidden":"true"})]}),n(Rn,{text:S,error:d,loading:a===null&&!d})]})]}),o&&v&&n("div",{class:"drawer-steer",children:n(It,{slug:e,targetId:g,inputId:k,label:h?"Request changes":"Send update",submitLabel:h?"Request changes":"Send update",placeholder:h?"Describe what should change before this task is merged.":"Add context or redirect this worker.",autoFocus:!0})})]})})}function En({updates:e,lastLine:t}){let r=e.filter(s=>s.instruction.trim());return n("section",{class:"task-updates","aria-labelledby":"task-updates-title",children:[n("div",{class:"task-updates-head",children:[n("h3",{id:"task-updates-title",children:"Updates"}),r.length>0&&n("span",{class:"task-updates-count mono",children:r.length})]}),n("div",{class:"task-thread",children:[r.length===0&&!t&&n("p",{class:"task-thread-empty",children:"No updates have been sent yet."}),r.map((s,o)=>n("article",{class:"task-update task-update-user",children:[n("div",{class:"task-update-avatar","aria-hidden":"true",children:"Y"}),n("div",{class:"task-update-body",children:[n("div",{class:"task-update-meta",children:[n("span",{children:Tn(s.source)}),n("time",{class:"mono",dateTime:s.ts,children:Dt(s.ts)})]}),n("p",{children:s.instruction})]})]},`${s.ts}-${o}`)),t&&n("article",{class:"task-update task-update-agent",children:[n("div",{class:"task-update-avatar task-update-avatar-agent","aria-hidden":"true",children:"R"}),n("div",{class:"task-update-body",children:[n("div",{class:"task-update-meta",children:n("span",{children:"Latest from worker"})}),n("p",{class:"mono",children:t})]})]})]})]})}function Tn(e){let t=(e??"").trim().toLowerCase();return!t||t==="user"||t==="web"||t==="operator"||t==="regoal"?"You":t==="steerer"||t==="rudder"?"Rudder":e??"You"}function Rn({text:e,error:t,loading:r}){let s=I(null);return M(()=>{let o=s.current;o&&(o.scrollTop=o.scrollHeight)},[e]),t?n("div",{class:"banner banner-error mono",children:["log unavailable: ",t]}):r?n("div",{class:"log-pre log-loading mono","aria-label":"Loading worker log",children:[n("div",{class:"skel skel-line",style:"width:70%"}),n("div",{class:"skel skel-line",style:"width:90%"}),n("div",{class:"skel skel-line",style:"width:55%"})]}):n("pre",{ref:s,class:"log-pre mono",children:e||"no output yet"})}function Pt(e){return e.status==="failed"?e.error||"Delivery failed":e.status==="accepted"?e.mode==="resumed"?"Accepted \xB7 agent is resuming":"Accepted \xB7 agent is restarting":e.status==="delivered"?e.mode==="resumed"?"Delivered \xB7 agent resumed":"Delivered to agent":e.mode==="resumed"?"Queued \xB7 agent is resuming":e.mode==="redirected"?"Queued for the live agent":"Queued for delivery"}function It({slug:e,targetId:t,inputId:r,label:s,submitLabel:o,placeholder:a,autoFocus:l=!1}){let[d,u]=b(""),[c,p]=b(!1),[i,f]=b(null),[m,y]=b(null);M(()=>{if(i?.state!=="queued"||!i.requestId||window.__RUDDER_CONTROL_MODE__!=="projector")return;let v=!1,h,g=async()=>{let k=0;try{let S=await Pe(e,i.requestId);if(v)return;if(S.status==="delivered"||S.status==="failed"){f(L=>L?.requestId===S.requestId?{...L,state:S.status,message:Pt(S)}:L);return}}catch{k=500}v||(h=window.setTimeout(g,k))};return g(),()=>{v=!0,h!==void 0&&window.clearTimeout(h)}},[e,i?.state,i?.requestId]);let w=async()=>{let v=d.trim();if(!(!v||c)){p(!0),f({instruction:v,state:"sending",message:"Sending request\u2026"}),y(null);try{let h=await kt(e,t,v);u(""),f({instruction:v,requestId:h.requestId,state:h.status,message:Pt(h)})}catch(h){f(null),y(String(h?.message??h))}finally{p(!1)}}},_=v=>{(v.metaKey||v.ctrlKey)&&v.key==="Enter"&&(v.preventDefault(),w())};return n("form",{class:"steer",onSubmit:v=>{v.preventDefault(),w()},"aria-busy":c,children:[n("label",{class:"steer-label",for:r,children:s}),n("textarea",{id:r,class:"steer-input",rows:3,maxLength:8e3,placeholder:a,value:d,disabled:c,"data-autofocus":l?"true":void 0,"aria-describedby":`${r}-hint${i?` ${r}-status`:""}`,onInput:v=>{u(v.target.value),m&&y(null)},onKeyDown:_}),n("div",{class:"steer-actions",children:[n("span",{class:"steer-hint",id:`${r}-hint`,children:"\u2318/Ctrl + Enter to send"}),n("button",{type:"submit",class:"btn btn-accent",disabled:c||!d.trim(),children:c?"Sending\u2026":o})]}),i&&n("div",{class:`steer-feedback steer-feedback-${i.state}`,id:`${r}-status`,"aria-live":"polite",children:[n("span",{class:"steer-feedback-state",children:i.message}),n("span",{class:"steer-feedback-text",children:i.instruction})]}),m&&n("div",{class:"action-err steer-error",role:"alert",children:["Could not send: ",m]})]})}function Pn({slug:e,activity:t,canSteerConductor:r}){let s=I(null);return M(()=>{let o=s.current;o&&(o.scrollTop=o.scrollHeight)},[t]),n("div",{class:"activity",children:[r&&n("div",{class:"activity-steer",children:n(It,{slug:e,targetId:"conductor",inputId:"conductor-update",label:"Message conductor",submitLabel:"Send update",placeholder:"Tell the live orchestrator what to do next."})}),t.length===0?n("div",{class:"empty",children:[n("div",{class:"empty-title",children:"no activity yet"}),n("div",{class:"empty-sub mono",children:"the conductor narrates what it is doing here as work runs"})]}):n("div",{class:"activity-feed",ref:s,children:t.map((o,a)=>n("div",{class:`activity-entry activity-${o.kind}`,children:[n("span",{class:"activity-dot","aria-hidden":"true"}),n("span",{class:"activity-text",children:o.text}),o.ts&&n("span",{class:"activity-ts mono",children:Dt(o.ts)})]},`${o.ts??""}-${a}`))})]})}function Dt(e){let t=/^\d{10,}$/.test(e.trim())?Number(e):e,r=new Date(t);return Number.isNaN(r.getTime())?"":r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function $n({memory:e}){return e.length===0?n("div",{class:"empty",children:[n("div",{class:"empty-title",children:"no decisions recorded yet"}),n("div",{class:"empty-sub mono",children:"agents append cross-cutting decisions here as they work"})]}):n("div",{class:"memory",children:e.map((t,r)=>n("article",{class:"memory-entry",children:[n("div",{class:"memory-bead","aria-hidden":"true"}),n("div",{class:"memory-content",children:[n("p",{class:"memory-text",children:t.text}),n("div",{class:"memory-meta mono",children:[t.owner&&n("span",{class:"memory-owner",children:t.owner}),t.ts&&n("span",{class:"memory-ts",children:t.ts})]})]})]},r))})}function Cn(){return n("div",{class:"board","aria-hidden":"true",children:$t.map(e=>n("section",{class:"column",children:[n("header",{class:"column-head",children:[n("span",{class:"column-title",children:e.label}),n("span",{class:"column-count mono",children:"\xB7"})]}),n("div",{class:"column-body",children:[n("div",{class:"card card-skeleton",children:[n("div",{class:"skel skel-line",style:"width:60%"}),n("div",{class:"skel skel-line",style:"width:85%"})]}),e.key==="running"&&n("div",{class:"card card-skeleton",children:[n("div",{class:"skel skel-line",style:"width:70%"}),n("div",{class:"skel skel-line",style:"width:50%"})]})]})]},e.key))})}var Me={claude:"Claude Code",codex:"Codex"};function Y(e){return e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:`$${e.toFixed(2)}`}function D(e){return e>=1e9?`${(e/1e9).toFixed(2)}B`:e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Math.round(e))}function H(e){return e>=1<<30?`${(e/(1<<30)).toFixed(2)} GB`:e>=1<<20?`${(e/(1<<20)).toFixed(0)} MB`:`${(e/1024).toFixed(0)} KB`}function Ae(e){return e.input+e.output+e.cacheWrite+e.cacheRead}function K(e,t){return t==="cost"?e.cost:Ae(e)}function Q(e,t){return t==="cost"?Y(e):D(e)}function Mn(e,t){if(!e)return"";let r=new Date(e).getTime()-t;if(Number.isNaN(r))return"";if(r<=0)return"resets now";let s=Math.round(r/6e4);if(s<60)return`resets in ${s}m`;let o=Math.floor(s/60);return o<24?`resets in ${o}h ${s%60}m`:`resets in ${Math.floor(o/24)}d ${o%24}h`}function Lt(e){return e.replace(/^claude-/,"").replace(/-\d{8}$/,"")}function An(e){let[,t,r]=e.split("-");return`${Number(t)}/${Number(r)}`}function Nt(){let[e,t]=b("tokens");return n("div",{class:"page usage-page",children:[n("header",{class:"topbar",children:[n("div",{class:"brand",children:[n("a",{class:"brand-link",href:"/rudder",title:"Back to all projects",children:[n("span",{class:"brand-mark",children:"\u25B0"}),n("span",{class:"brand-back",children:"\u2190 all projects"})]}),n("span",{class:"brand-name",children:"Usage"}),n("span",{class:"brand-sub mono",children:"this machine"})]}),n("div",{class:"toolbar-actions",children:n("div",{class:"view-toggle",role:"group","aria-label":"Usage view",children:[n("button",{type:"button","aria-pressed":e==="tokens",class:`toggle ${e==="tokens"?"toggle-on":""}`,onClick:()=>t("tokens"),children:"Token usage"}),n("button",{type:"button","aria-pressed":e==="machine",class:`toggle ${e==="machine"?"toggle-on":""}`,onClick:()=>t("machine"),children:"Machine resources"})]})})]}),n("main",{class:"usage-main",children:e==="tokens"?n(Dn,{}):n(qn,{})})]})}function jn(){let[e,t]=b(null),[r,s]=b(null),[o,a]=b(!1),[l,d]=b(Date.now()),u=c=>{a(!0),mt(c).then(p=>{t(p),s(null)}).catch(p=>s(String(p?.message??p))).finally(()=>a(!1))};return M(()=>{u(!1);let c=setInterval(()=>d(Date.now()),3e4),p=setInterval(()=>u(!1),5*6e4);return()=>{clearInterval(c),clearInterval(p)}},[]),n("section",{class:"usage-section",children:[n("div",{class:"usage-section-head",children:[n("h2",{class:"usage-h2",children:"Subscription quota"}),n("div",{class:"usage-section-actions",children:[e&&n("span",{class:"usage-muted mono",children:["refreshed ",new Date(e.fetchedAt).toLocaleTimeString()," \xB7 every ",Math.round(e.ttlSeconds/60),"m"]}),n("button",{type:"button",class:"btn",disabled:o,onClick:()=>u(!0),children:o?"refreshing\u2026":"refresh"})]})]}),r&&n("div",{class:"banner banner-error mono",children:["quota failed: ",r]}),n("div",{class:"quota-grid",children:[(e?.accounts??[]).map(c=>n(In,{account:c,now:l},`${c.provider}:${c.account}`)),!e&&!r&&n(j,{children:[n("div",{class:"quota-card quota-card-skeleton"}),n("div",{class:"quota-card quota-card-skeleton"})]})]}),n("p",{class:"usage-note",children:"Read from the providers' own usage endpoints with the sign-ins the CLIs already hold. Rudder never handles a password and never stores a token."})]})}function Fn(e){return e>=90?"meter-fill meter-hot":e>=70?"meter-fill meter-warm":"meter-fill"}function In({account:e,now:t}){return n("div",{class:`quota-card ${e.error?"quota-card-error":""}`,children:[n("div",{class:"quota-head",children:[n("span",{class:`provider-dot provider-${e.provider}`,"aria-hidden":"true"}),n("span",{class:"quota-provider",children:Me[e.provider]}),e.plan&&n("span",{class:"quota-plan mono",children:e.plan})]}),e.email&&n("div",{class:"quota-email mono",children:e.email}),e.blocked&&!e.error&&n("div",{class:"quota-blocked mono",children:e.blocked}),e.error?n("div",{class:"quota-error mono",children:e.error}):n("div",{class:"meters",children:e.windows.map(r=>n("div",{class:"meter",children:[n("div",{class:"meter-row",children:[n("span",{class:"meter-label",children:r.label}),n("span",{class:"meter-value mono",children:[r.percent,"%"]})]}),n("div",{class:"meter-track",role:"progressbar","aria-valuenow":r.percent,"aria-valuemin":0,"aria-valuemax":100,children:n("div",{class:Fn(r.percent),style:{width:`${Math.min(100,r.percent)}%`}})}),n("div",{class:"meter-reset mono",children:Mn(r.resetsAt,t)})]},r.label))})]})}function Dn(){let[e,t]=b("30d"),[r,s]=b(null),[o,a]=b(null);return M(()=>{let l=!1;return s(null),ft(e).then(d=>{l||(s(d),a(null))}).catch(d=>{l||a(String(d?.message??d))}),()=>{l=!0}},[e]),n(j,{children:[n(jn,{}),n(Ln,{report:r,error:o,range:e,onRange:t})]})}function Ln({report:e,error:t,range:r,onRange:s}){let[o,a]=b("cost"),[l,d]=b(new Set),[u,c]=b(null),[p,i]=b(null),[f,m]=b(null),[y,w]=b(!1),_=g=>{d(k=>{let S=new Set(k);return S.has(g)?S.delete(g):S.add(g),S})},v=N(()=>{if(!e)return 0;let g=0;for(let k of["claude","codex"])l.has(k)||(g+=K(e.providers[k],o));return g},[e,l,o]),h=e?.days.find(g=>g.day===u)??null;return n(j,{children:n("section",{class:"usage-section",children:[n("div",{class:"usage-section-head",children:[n("h2",{class:"usage-h2",children:"Token usage"}),n("div",{class:"usage-section-actions",children:[n("div",{class:"view-toggle",role:"group","aria-label":"Metric",children:["cost","tokens"].map(g=>n("button",{type:"button","aria-pressed":o===g,class:`toggle ${o===g?"toggle-on":""}`,onClick:()=>a(g),children:g==="cost"?"Cost":"Tokens"},g))}),n("div",{class:"view-toggle",role:"group","aria-label":"Range",children:["7d","30d","90d"].map(g=>n("button",{type:"button","aria-pressed":r===g,class:`toggle ${r===g?"toggle-on":""}`,onClick:()=>s(g),children:g},g))})]})]}),t&&n("div",{class:"banner banner-error mono",children:["usage failed: ",t]}),!e&&!t&&n("div",{class:"usage-loading mono",children:"scanning session logs\u2026"}),e&&n(j,{children:[n("div",{class:"stat-row",children:[n("div",{class:"stat",children:[n("div",{class:"stat-label",children:"Cost to you"}),n("div",{class:"stat-value",children:"$0"}),n("div",{class:"stat-sub",children:"subscription"})]}),n("div",{class:"stat",children:[n("div",{class:"stat-label",children:"At API rates"}),n("div",{class:"stat-value",children:Y(e.total.cost)}),n("div",{class:"stat-sub",children:[D(Ae(e.total))," tokens \xB7 ",e.total.calls," calls"]})]}),n("div",{class:"stat",children:[n("div",{class:"stat-label",children:"Caching saved"}),n("div",{class:"stat-value",children:Y(e.total.cacheSavings)}),n("div",{class:"stat-sub",children:[D(e.total.cacheRead)," cache reads"]})]}),n("div",{class:"stat",children:[n("div",{class:"stat-label",children:"Output"}),n("div",{class:"stat-value",children:D(e.total.output)}),n("div",{class:"stat-sub",children:[D(e.total.input+e.total.cacheWrite)," fresh input"]})]})]}),n("div",{class:"provider-chips",children:[["claude","codex"].map(g=>n("button",{type:"button",class:`chip ${l.has(g)?"chip-off":""}`,"aria-pressed":!l.has(g),onClick:()=>_(g),title:"Click to show or hide in the chart",children:[n("span",{class:`provider-dot provider-${g}`,"aria-hidden":"true"}),Me[g],n("span",{class:"chip-value mono",children:Q(K(e.providers[g],o),o)})]},g)),n("span",{class:"usage-muted mono",children:[Q(v,o)," shown \xB7 ",e.scannedFiles," logs"]})]}),n(Un,{report:e,metric:o,hidden:l,selected:u,onSelect:c}),h&&n("div",{class:"day-detail",children:[n("div",{class:"day-detail-head",children:[n("strong",{children:h.day}),n("button",{type:"button",class:"btn",onClick:()=>c(null),children:"close"})]}),n("div",{class:"day-detail-grid",children:["claude","codex"].map(g=>n("div",{class:"day-detail-cell",children:[n("span",{class:`provider-dot provider-${g}`,"aria-hidden":"true"})," ",Me[g],n("div",{class:"mono",children:[Y(h[g].cost)," \xB7 ",D(Ae(h[g]))," tokens \xB7 ",h[g].calls," calls"]})]},g))})]}),n("div",{class:"usage-columns",children:[n("div",{children:[n("h3",{class:"usage-h3",children:"Models"}),n("table",{class:"usage-table",children:[n("thead",{children:n("tr",{children:[n("th",{children:"model"}),n("th",{class:"num",children:o==="cost"?"cost":"tokens"}),n("th",{class:"num",children:"output"}),n("th",{class:"num",children:"cache read"}),n("th",{class:"num",children:"sessions"})]})}),n("tbody",{children:[e.models.map(g=>{let k=`${g.provider}:${g.model}`,S=p===k;return n(j,{children:[n("tr",{class:`usage-row ${S?"usage-row-open":""}`,onClick:()=>i(S?null:k),children:[n("td",{children:[n("span",{class:`provider-dot provider-${g.provider}`,"aria-hidden":"true"}),n("span",{class:"mono",children:Lt(g.model)})]}),n("td",{class:"num mono",children:Q(K(g.totals,o),o)}),n("td",{class:"num mono",children:D(g.totals.output)}),n("td",{class:"num mono",children:D(g.totals.cacheRead)}),n("td",{class:"num mono",children:g.sessions})]},k),S&&n("tr",{class:"usage-drill",children:n("td",{colSpan:5,children:n(Nn,{totals:g.totals})})},`${k}-drill`)]})}),e.models.length===0&&n("tr",{children:n("td",{colSpan:5,class:"usage-muted mono",children:"no usage in this range"})})]})]})]}),n("div",{children:[n("div",{class:"usage-h3-row",children:[n("h3",{class:"usage-h3",children:"Workspaces"}),e.projects.length>8&&n("button",{type:"button",class:"btn-link mono",onClick:()=>w(g=>!g),children:y?"top 8":`All ${e.projects.length} \u2192`})]}),n(Bn,{projects:y?e.projects:e.projects.slice(0,8),metric:o,selected:f,onSelect:m})]})]}),n("p",{class:"usage-note",children:e.pricingNote})]})]})})}function Nn({totals:e}){return n("div",{class:"totals-breakdown mono",children:[n("span",{children:["input ",D(e.input)]}),n("span",{children:["output ",D(e.output)]}),n("span",{children:["cache write ",D(e.cacheWrite)]}),n("span",{children:["cache read ",D(e.cacheRead)]}),n("span",{children:[Y(e.cost)," at API rates"]}),n("span",{children:[Y(e.cacheSavings)," saved by caching"]})]})}function Un({report:e,metric:t,hidden:r,selected:s,onSelect:o}){let l=e.days.map(g=>({day:g.day,claude:r.has("claude")?0:K(g.claude,t),codex:r.has("codex")?0:K(g.codex,t)})),d=Math.max(1e-9,...l.map(g=>g.claude+g.codex)),u=900,c=180,p=44,i=22,f=8,m=u-p-8,y=c-i-f,w=m/Math.max(1,l.length),_=Math.max(2,w*.7),v=l.length>45?10:l.length>14?5:1,h=[0,.5,1].map(g=>({f:g,label:Q(d*g,t)}));return n("div",{class:"chart-wrap",children:n("svg",{class:"daily-chart",viewBox:`0 0 ${u} ${c}`,role:"img","aria-label":"Daily usage",children:[h.map(g=>{let k=f+y-y*g.f;return n("g",{children:[n("line",{x1:p,x2:u-8,y1:k,y2:k,class:"chart-grid"}),n("text",{x:p-6,y:k+4,class:"chart-tick","text-anchor":"end",children:g.label})]},g.f)}),l.map((g,k)=>{let S=p+k*w+(w-_)/2,L=g.claude/d*y,B=g.codex/d*y,x=f+y-B,$=x-L,A=s===g.day;return n("g",{class:`chart-bar ${A?"chart-bar-selected":""}`,onClick:()=>o(A?null:g.day),children:[n("title",{children:[g.day,": ",Q(g.claude+g.codex,t)]}),n("rect",{x:p+k*w,y:f,width:w,height:y,class:"chart-hit"}),n("rect",{x:S,y:x,width:_,height:B,class:"bar-codex"}),n("rect",{x:S,y:$,width:_,height:L,class:"bar-claude"}),k%v===0&&n("text",{x:S+_/2,y:c-6,class:"chart-tick","text-anchor":"middle",children:An(g.day)})]},g.day)})]})})}function Bn({projects:e,metric:t,selected:r,onSelect:s}){let o=Math.max(1e-9,...e.map(u=>K(u.totals,t))),[a,l]=b(null),d=u=>{navigator.clipboard?.writeText(u).then(()=>{l(u),setTimeout(()=>l(null),1200)},()=>l(null))};return e.length===0?n("div",{class:"usage-muted mono",children:"no workspaces in this range"}):n("div",{class:"project-bars",children:e.map(u=>{let c=K(u.totals,t),p=r===u.key;return n("div",{class:`project-bar ${p?"project-bar-open":""}`,children:[n("button",{type:"button",class:"project-bar-btn",onClick:()=>s(p?null:u.key),children:[n("div",{class:"project-bar-row",children:[n("span",{class:"project-name",children:u.slug?n("a",{href:`/rudder/${encodeURIComponent(u.slug)}`,onClick:i=>i.stopPropagation(),children:u.name}):u.name}),n("span",{class:"mono project-value",children:Q(c,t)})]}),n("div",{class:"project-track",children:n("div",{class:"project-fill",style:{width:`${c/o*100}%`}})}),n("div",{class:"project-path mono",children:u.key})]}),p&&n("div",{class:"project-sessions",children:[n("div",{class:"usage-muted mono",children:"top sessions by cost \xB7 click to copy the id for --resume"}),u.sessions.slice(0,10).map(i=>n("button",{type:"button",class:"session-row",title:`${i.provider} ${i.id}`,onClick:()=>d(i.id),children:[n("span",{class:`provider-dot provider-${i.provider}`,"aria-hidden":"true"}),n("span",{class:"mono session-id",children:a===i.id?"copied \u2713":i.id.slice(0,8)}),n("span",{class:"mono session-model",children:Lt(i.model)}),n("span",{class:"mono session-when",children:new Date(i.lastAt).toLocaleString()}),n("span",{class:"mono session-cost",children:Q(K(i.totals,t),t)})]},i.id))]})]},u.key)})})}function qn(){let[e,t]=b(null),[r,s]=b(null);return M(()=>{let o=!1,a=()=>gt().then(d=>{o||(t(d),s(null))}).catch(d=>{o||s(String(d?.message??d))});a();let l=setInterval(a,2e3);return()=>{o=!0,clearInterval(l)}},[]),r?n("div",{class:"banner banner-error mono",children:["machine failed: ",r]}):e?n(On,{report:e}):n("div",{class:"usage-loading mono",children:"sampling\u2026"})}function On({report:e}){let t=e.totalMem-e.freeMem,r=e.byKind.claude.rss+e.byKind.codex.rss+e.byKind.opencode.rss,s=e.byKind.rudder.rss,o=Math.max(0,t-r-s),a=l=>`${(l/e.totalMem*100).toFixed(1)}%`;return n("section",{class:"usage-section",children:[n("div",{class:"usage-section-head",children:[n("h2",{class:"usage-h2",children:"Machine resources"}),n("span",{class:"usage-muted mono",children:["live \xB7 every 2s \xB7 load ",e.load.map(l=>l.toFixed(2)).join(" ")," on ",e.cpus," cores"]})]}),n("div",{class:"stat-row",children:[n("div",{class:"stat",children:[n("div",{class:"stat-label",children:"Rudder"}),n("div",{class:"stat-value",children:H(s)}),n("div",{class:"stat-sub",children:[e.byKind.rudder.cpu.toFixed(1),"% cpu \xB7 ",e.byKind.rudder.count," procs"]})]}),n("div",{class:"stat",children:[n("div",{class:"stat-label",children:"Agents"}),n("div",{class:"stat-value",children:H(r)}),n("div",{class:"stat-sub",children:[(e.byKind.claude.cpu+e.byKind.codex.cpu+e.byKind.opencode.cpu).toFixed(1),"% cpu \xB7"," ",e.byKind.claude.count+e.byKind.codex.count+e.byKind.opencode.count," procs"]})]}),n("div",{class:"stat",children:[n("div",{class:"stat-label",children:"System RAM"}),n("div",{class:"stat-value",children:[H(t)," / ",H(e.totalMem)]}),n("div",{class:"stat-sub",children:[a(t)," in use"]})]})]}),n("div",{class:"ram-bar",role:"img","aria-label":"RAM split",children:[n("div",{class:"ram-seg ram-rudder",style:{width:a(s)},title:`rudder ${H(s)}`}),n("div",{class:"ram-seg ram-agents",style:{width:a(r)},title:`agents ${H(r)}`}),n("div",{class:"ram-seg ram-other",style:{width:a(o)},title:`everything else ${H(o)}`})]}),n("div",{class:"ram-legend mono",children:[n("span",{children:[n("i",{class:"ram-swatch ram-rudder"})," rudder"]}),n("span",{children:[n("i",{class:"ram-swatch ram-agents"})," agents"]}),n("span",{children:[n("i",{class:"ram-swatch ram-other"})," everything else"]}),n("span",{children:["free ",H(e.freeMem)]})]}),n("h3",{class:"usage-h3",children:"Processes"}),n("table",{class:"usage-table",children:[n("thead",{children:n("tr",{children:[n("th",{children:"kind"}),n("th",{children:"pid"}),n("th",{class:"num",children:"cpu"}),n("th",{class:"num",children:"memory"}),n("th",{children:"uptime"}),n("th",{children:"command"})]})}),n("tbody",{children:[e.processes.map(l=>n("tr",{children:[n("td",{children:[n("span",{class:`provider-dot provider-${l.kind}`,"aria-hidden":"true"}),l.kind]}),n("td",{class:"mono",children:l.pid}),n("td",{class:"num mono",children:[l.cpu.toFixed(1),"%"]}),n("td",{class:"num mono",children:H(l.rss)}),n("td",{class:"mono",children:l.elapsed}),n("td",{class:"mono cmd",title:l.command,children:l.command.length>90?`${l.command.slice(0,90)}\u2026`:l.command})]},l.pid)),e.processes.length===0&&n("tr",{children:n("td",{colSpan:6,class:"usage-muted mono",children:"no agent processes running"})})]})]})]})}var Hn="default-src 'none'; script-src 'none'; connect-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:; media-src 'none'; object-src 'none'; frame-src 'none'; form-action 'none'; base-uri 'none'",Wn=new Set(["image/png","image/jpeg","image/gif","image/webp","image/avif"]);function Kn(e,t){if(!t||t.length>2048||/[\\\u0000-\u001f\u007f]/.test(t)||/^[a-z][a-z\d+.-]*:/i.test(t)||t.startsWith("/"))return null;let r=t.split(/[?#]/,1)[0],s;try{s=decodeURIComponent(r)}catch{return null}if(s!==r&&/[\\/?#\u0000-\u001f\u007f]/.test(s))return null;let o=e.split("/").slice(0,-1);for(let a of s.split("/"))if(!(!a||a==="."))if(a===".."){if(!o.length)return null;o.pop()}else{if(a.includes(":"))return null;o.push(a)}return o.join("/")}function Ut(e){return e.replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}function Vn(e){let t=!1;return e.split(/\r?\n/).map(r=>{if(/^```/.test(r))return t=!t,t?"<pre><code>":"</code></pre>";if(t)return`${Ut(r)}
5
5
  `;let s=/^(#{1,6})\s+(.*)$/.exec(r),o=a=>Ut(a).replace(/!\[([^\]]*)\]\(([^\s)]+)\)/g,'<img alt="$1" src="$2">').replace(/\[([^\]]+)\]\(([^\s)]+)\)/g,"$1").replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>");return s?`<h${s[1].length}>${o(s[2])}</h${s[1].length}>`:/^[-*] /.test(r)?`<p>\u2022 ${o(r.slice(2))}</p>`:r?`<p>${o(r)}</p>`:""}).join(`
6
6
  `)+(t?"</code></pre>":"")}function je(e){return!Wn.has(e.mime)||!e.base64||!/^[A-Za-z0-9+/]*={0,2}$/.test(e.base64)?null:`data:${e.mime};base64,${e.base64}`}function Bt(e){let t=e.base64;if(e.kind!=="pdf"||e.mime!=="application/pdf"||!t||t.length<8||t.length>Math.ceil(16*1024*1024/3)*4||t.length%4!==0||!/^[A-Za-z0-9+/]*={0,2}$/.test(t))return null;try{if(!atob(t.slice(0,8)).startsWith("%PDF-")||btoa(atob(t.slice(-4)))!==t.slice(-4))return null}catch{return null}return`data:application/pdf;base64,${t}`}async function qt(e,t,r,s){let o=e.kind==="markdown"?Vn(e.text??""):e.text??"",a=new DOMParser().parseFromString("<!doctype html><html><head></head><body></body></html>","text/html"),l=a.createElement("template");l.innerHTML=o;let d=l.content;d.querySelectorAll("script,iframe,frame,frameset,object,embed,form,base,meta,svg,math,template,video,audio,source,track").forEach(i=>i.remove());let u=16,c=0,p=async i=>{if(u--<=0||s.aborted)return null;let f=Kn(e.path,i);if(f===null)return null;try{let m=await r.read(t,f,s);return c+=m.base64?.length??m.text?.length??0,c<=12*1024*1024?m:null}catch(m){if(s.aborted)throw m;return null}};for(let i of Array.from(d.querySelectorAll("*"))){for(let f of Array.from(i.attributes))if(/^on/i.test(f.name)||["srcdoc","href","action","formaction","srcset","poster","background","ping","target","download","nonce","integrity","is"].includes(f.name)){if(i.tagName==="LINK"&&f.name==="href")continue;i.removeAttribute(f.name)}if(i.tagName==="IMG"){let f=i.getAttribute("src")??"";i.removeAttribute("src");let m=await p(f),y=m&&je(m);y&&i.setAttribute("src",y)}else i.removeAttribute("src");if(i.tagName==="LINK"){let f=i.getAttribute("href")??"";if(i.getAttribute("rel")?.toLowerCase()==="stylesheet"){let m=await p(f);if(m?.text&&["text/css","text/plain"].includes(m.mime)){let y=a.createElement("style");y.textContent=m.text,i.replaceWith(y)}}i.remove()}}return s.throwIfAborted(),`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${Hn}"><meta name="referrer" content="no-referrer"><style>body{font:16px/1.6 system-ui,sans-serif;padding:20px;overflow-wrap:anywhere}img{max-width:100%}pre{white-space:pre-wrap}code{font-family:monospace}</style></head><body>${l.innerHTML}</body></html>`}function Ot(e){let t=!1,r,s,o=async()=>{s=new AbortController;let a=setTimeout(()=>s?.abort(new Error("File request timed out")),e.timeoutMs??1e4);try{let l=new Promise((c,p)=>s.signal.addEventListener("abort",()=>p(s.signal.reason??new Error("File request cancelled")),{once:!0})),[d,u]=await Promise.race([Promise.all([e.transport.list(e.scope,e.directory,s.signal),e.path===null?Promise.resolve(null):e.transport.read(e.scope,e.path,s.signal)]),l]);!t&&!s.signal.aborted&&e.onSnapshot({listing:d,document:u})}catch(l){s.abort(),t||e.onError(l),t=!0}finally{clearTimeout(a),t||(r=setTimeout(o,Math.max(250,e.intervalMs??2e3)))}};return o(),()=>{t=!0,clearTimeout(r),s?.abort()}}function Ht(e){return typeof e=="string"&&e.length<=4096&&!/[\\\u0000-\u001f\u007f]/.test(e)&&!e.startsWith("/")&&!e.split("/").some(t=>t==="."||t===".."||t===""&&e!=="")}async function Qn(e,t){if(Number(e.headers.get("content-length"))>25165824)throw new Error("File response is too large");if(!e.body)throw new Error("Empty file response");let r=e.body.getReader(),s=()=>{r.cancel().catch(()=>{})};t.addEventListener("abort",s,{once:!0});let o=0,a="",l=new TextDecoder("utf-8",{fatal:!0});try{for(t.throwIfAborted();;){let{value:d,done:u}=await r.read();if(t.throwIfAborted(),u)break;if(o+=d.length,o>25165824)throw new Error("File response is too large");a+=l.decode(d,{stream:!0})}return a+=l.decode(),JSON.parse(a)}finally{t.removeEventListener("abort",s),r.cancel().catch(()=>{}),r.releaseLock()}}async function Wt(e,t){t.throwIfAborted();let r,s=new Promise((o,a)=>{r=()=>a(t.reason??new Error("File request cancelled")),t.addEventListener("abort",r,{once:!0})});try{return await Promise.race([e,s])}finally{t.removeEventListener("abort",r)}}function Fe(e,t){if(!e.startsWith("/")||e.startsWith("//")||/[?#\\\u0000-\u001f]/.test(e))throw new Error("File endpoint must be a private application route");async function r(s,o,a,l){if(l.throwIfAborted(),!Ht(o)||!Number.isSafeInteger(s.ownerEpoch)||s.ownerEpoch<0||[s.projectId,s.workspaceId,s.attemptId].some(i=>typeof i!="string"||!i||i.length>256||/[\u0000-\u001f\u007f]/.test(i)))throw new Error("Invalid project file identity");let d=AbortSignal.any([l,AbortSignal.timeout(1e4)]),u=new URLSearchParams({version:"1",operation:a,projectId:s.projectId,workspaceId:s.workspaceId,attemptId:s.attemptId,ownerEpoch:String(s.ownerEpoch),path:o}),c=await Wt(t(`${e}?${u}`,{signal:d,credentials:"omit",redirect:"error",cache:"no-store",referrerPolicy:"no-referrer"}),d),p=await Wt(Qn(c,d),d);if(!c.ok)throw new Error(typeof p?.error=="string"?p.error.slice(0,500):`Unable to open file (${c.status})`);if(p?.path!==o)throw new Error("File response identity changed");if(a==="list"){if(!Array.isArray(p.entries)||p.entries.length>500||typeof p.truncated!="boolean")throw new Error("Invalid folder response");let i=new Set;for(let f of p.entries){if(!Ht(f.path)||!f.path||typeof f.name!="string"||!f.name||f.path!==(o?`${o}/`:"")+f.name||f.name.includes("/")||!["file","folder"].includes(f.kind)||i.has(f.path))throw new Error("Invalid folder entry");i.add(f.path)}return p}if(typeof p.revision!="string"||!/^[a-f0-9]{64}$/.test(p.revision)||typeof p.mime!="string"||p.mime.length>100||!["text","markdown","html","image","pdf","binary"].includes(p.kind)||p.text!==void 0&&(typeof p.text!="string"||p.text.length>4*1024*1024)||p.base64!==void 0&&(typeof p.base64!="string"||p.base64.length>23*1024*1024||!/^[A-Za-z0-9+/]*={0,2}$/.test(p.base64)))throw new Error("Invalid file response");return p}return{list:(s,o,a)=>r(s,o,"list",a),read:(s,o,a)=>r(s,o,"read",a)}}function Ie(e){return e.split("/").slice(0,-1).join("/")}function Kt(e){return JSON.stringify([e.projectId,e.workspaceId,e.attemptId,e.ownerEpoch])}function Vt({reference:e,transport:t,onClose:r}){let s=`${Kt(e.scope)}:${e.kind}:${e.path}`;return n(zn,{reference:e,transport:t,onClose:r},s)}function zn({reference:e,transport:t,onClose:r}){let s=e.kind==="folder"||!e.path,[o,a]=b(s?e.path:Ie(e.path)),[l,d]=b(s?null:e.path),[u,c]=b(null),[p,i]=b(""),[f,m]=b(!1),[y,w]=b(0);M(()=>(c(null),i(""),Ot({transport:t,scope:e.scope,directory:o,path:l,onSnapshot:h=>{c(h),i("")},onError:h=>{c(null),i(h instanceof Error?h.message:"Unable to open project files")}})),[t,o,l,y]);let _=(h,g)=>{c(null),i(""),m(!1),a(g==="folder"?h:Ie(h)),d(g==="folder"?null:h)},v=u?.document;return n("section",{class:"project-file-viewer","aria-label":"Project files",style:{border:"1px solid var(--line, #ddd)",borderRadius:8,overflow:"hidden",background:"var(--paper, white)"},children:[n("header",{style:{display:"flex",alignItems:"center",gap:8,padding:12,borderBottom:"1px solid var(--line, #ddd)",flexWrap:"wrap"},children:[n("strong",{children:"Project files"}),n("span",{class:"mono",style:{flex:1,overflowWrap:"anywhere"},children:l??(o||"/")}),n("button",{type:"button",class:"btn",onClick:()=>w(y+1),children:"Refresh"}),v&&["text","markdown","html"].includes(v.kind)&&n("div",{role:"group","aria-label":"File view",children:[n("button",{type:"button",class:"btn","aria-pressed":!f,onClick:()=>m(!1),children:"Rendered"}),n("button",{type:"button",class:"btn","aria-pressed":f,onClick:()=>m(!0),children:"Source"})]}),r&&n("button",{type:"button",class:"btn",onClick:r,children:"Close"})]}),n("div",{style:{display:"flex",flexWrap:"wrap",minHeight:400},children:[n("nav",{"aria-label":"Nearby files",style:{width:240,flex:"0 1 240px",borderRight:"1px solid var(--line, #ddd)",padding:12,maxHeight:640,overflow:"auto"},children:[n("button",{type:"button",class:"btn",disabled:!o,onClick:()=>_(Ie(o),"folder"),children:"Parent folder"}),n("button",{type:"button",class:"btn",onClick:()=>_("","folder"),children:"Project root"}),n("ul",{style:{listStyle:"none",padding:0},children:u?.listing.entries.map(h=>n("li",{children:n("button",{type:"button","aria-current":h.path===l?"page":void 0,onClick:()=>_(h.path,h.kind),style:{border:0,background:h.path===l?"var(--paper-2, #eee)":"transparent",color:"inherit",textAlign:"left",padding:"7px 2px",width:"100%",overflowWrap:"anywhere",cursor:"pointer"},children:[h.kind==="folder"?"\u25B8 ":"",h.name,h.kind==="folder"?"/":""]})},h.path))}),u?.listing.truncated&&n("p",{role:"status",children:"Folder limit reached. Open a subfolder to browse more files."})]}),n("main",{style:{flex:"1 1 280px",minWidth:0,padding:16},children:p?n("p",{role:"alert",children:p}):u?v?n(Gn,{document:v,source:f,scope:e.scope,transport:t}):n("p",{children:"Choose a file to preview. Saved changes appear automatically."}):n("p",{role:"status",children:"Loading files\u2026"})})]})]})}function Gn({document:e,source:t,scope:r,transport:s}){let[o,a]=b(null),[l,d]=b("");if(M(()=>{if(d(""),t||!["markdown","html"].includes(e.kind))return;let u=!1,c,p,i,f=async()=>{c=new AbortController,i=setTimeout(()=>c.abort(),1e4);try{let m=await qt(e,r,s,c.signal);!u&&!c.signal.aborted&&(a({revision:e.revision,source:m}),d(""))}catch{u||d("Unable to render this document. Open Source to read it.")}finally{clearTimeout(i),!u&&!c.signal.aborted&&(p=setTimeout(f,2e3))}};return f(),()=>{u=!0,clearTimeout(i),clearTimeout(p),c?.abort()}},[e.path,e.revision,e.kind,t,s,Kt(r)]),t||e.kind==="text")return n("pre",{style:{whiteSpace:"pre-wrap",overflowWrap:"anywhere",font:"13px/1.6 var(--mono, monospace)"},children:e.text??"Binary file. Source is unavailable."});if(e.kind==="markdown"||e.kind==="html")return l?n("p",{role:"alert",children:l}):o?.revision===e.revision?n(Yn,{title:`Preview of ${e.path}`,source:o.source}):n("p",{role:"status",children:"Rendering preview\u2026"});if(e.kind==="image"){let u=je(e);return u?n("img",{src:u,alt:e.path,style:{maxWidth:"100%",maxHeight:"70vh",objectFit:"contain"}}):n("p",{children:"Unsupported image format. Open a supported image or view its source."})}return e.kind==="pdf"?n(Xn,{document:e}):n("p",{children:"This binary format has no preview."})}function Yn({title:e,source:t}){return n("iframe",{title:e,sandbox:"",referrerPolicy:"no-referrer",srcDoc:t,style:{border:0,width:"100%",height:"65vh",background:"white"}})}function Xn({document:e}){let t=Bt(e);return t?n("iframe",{title:`PDF: ${e.path}`,referrerPolicy:"no-referrer",src:t,style:{border:0,width:"100%",height:"65vh"}}):n("p",{role:"alert",children:"This file is not a supported PDF."})}function De(e){return JSON.stringify([e.projectId,e.workspaceId,e.attemptId,e.ownerEpoch])}function Qt(e){let t=e;return!!(t&&[t.projectId,t.workspaceId,t.attemptId].every(r=>typeof r=="string"&&r.length>0&&r.length<=256&&!/[\x00-\x1f\x7f]/.test(r))&&Number.isSafeInteger(t.ownerEpoch)&&t.ownerEpoch>=0)}function Jn(e){let t=new URLSearchParams(window.location.search);if(!t.has("file"))return null;let r={projectId:t.get("projectId"),workspaceId:t.get("workspaceId"),attemptId:t.get("attemptId"),ownerEpoch:Number(t.get("ownerEpoch"))};return!Qt(r)||!e.some(s=>De(s)===De(r))?null:{scope:r,path:t.get("file"),kind:t.get("fileKind")==="folder"?"folder":"file"}}function zt({slug:e}){let[t,r]=b([]),[s,o]=b(null),[a,l]=b(""),[d,u]=b(0),c=`/api/projects/${encodeURIComponent(e)}`,p=N(()=>Fe(`${c}/files`,V().fetch.bind(V())),[c]);return M(()=>{let i=new AbortController;return r([]),o(null),l(""),V().fetch(`${c}/file-scopes`,{signal:i.signal}).then(async f=>{if(!f.ok)throw new Error("Project files require a current engine workspace.");let m=await f.json();if(!Array.isArray(m.scopes)||m.scopes.length>16||!m.scopes.every(Qt))throw new Error("Project file bindings are unavailable.");i.signal.aborted||(r(m.scopes),o(Jn(m.scopes)))}).catch(f=>{i.signal.aborted||l(f instanceof Error?f.message:"Project files are unavailable.")}),()=>i.abort()},[c,d]),n("section",{style:{padding:"12px 24px"},"aria-label":"Workspace files",children:[n("details",{children:[n("summary",{children:"Project files"}),n("p",{children:"Open files from a current task workspace."}),a&&n("p",{role:"status",children:a}),!a&&t.length===0&&n("p",{role:"status",children:"No current task workspace is available."}),t.map(i=>n("button",{type:"button",class:"btn",onClick:()=>o({scope:i,path:"",kind:"folder"}),children:["Files \xB7 ",i.workspaceId]},De(i))),n("button",{type:"button",class:"btn",onClick:()=>u(d+1),children:"Refresh workspaces"})]}),s&&n(Vt,{reference:s,transport:p,onClose:()=>o(null)})]})}function Zn({slug:e,usage:t}){return t?n(Nt,{}):e?n(j,{children:[n(Ft,{slug:e}),n(zt,{slug:e},e)]}):n(At,{})}var Le=document.getElementById("app");if(Le){let e=()=>we(n("main",{class:"index-main",children:n("p",{role:"alert",children:"Open this board from Rudder to connect."})}),Le),t=V();t.onLost(e),t.initialize().then(r=>{let s=window.location.pathname==="/usage"||window.location.pathname==="/rudder/usage",o=/^\/rudder\/([^/]+)\/?$/.exec(window.location.pathname),a="";try{o&&!s&&(a=decodeURIComponent(o[1]))}catch{}window.__RUDDER_CONTROL_MODE__=r.control_mode,window.__RUDDER_CAN_MUTATE__=r.scope.owner_project_control&&a===r.owner_slug,document.title=s?"rudder \xB7 usage":"rudder",we(n(Zn,{slug:a,usage:s}),Le)}).catch(e)}