failproofai 0.0.10-beta.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +3 -3
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/required-server-files.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +7 -7
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
- package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +15 -15
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +15 -15
- package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
- package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +10 -10
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js +1 -1
- package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/index.html +1 -1
- package/.next/standalone/.next/server/app/index.rsc +15 -15
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +15 -15
- package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +4 -4
- package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +10 -10
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +8 -8
- package/.next/standalone/.next/server/app/policies/page.js +1 -1
- package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0fjhqi9._.js → [root-of-the-server]__044xt9.._.js} +2 -2
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0d_ob4n._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0vlhtkc._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0yfq1yr._.js +1 -1
- package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_0z7w.hh._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__07_-mkc._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0e9o9ri._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0mnba92._.js → [root-of-the-server]__0l6swv1._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0logebz._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0mi5ejy._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0podumr._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0rkxer-._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0rl2kwi._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0vg0uey._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ye1w50._.js +4 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ymlddl._.js +32 -7
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__10._f0s._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/app_0cdqd9w._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_0xerkr6._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_0q-m0y-._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/lib_gemini-projects_ts_0sl~yqr._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/lib_opencode-projects_ts_0op9gyp._.js +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +9 -9
- package/.next/standalone/.next/static/chunks/{0.a7kxwvbre7q.js → 0j171xiqge4rv.js} +1 -1
- package/.next/standalone/.next/static/chunks/0kqar56yl~41o.js +6 -0
- package/.next/standalone/.next/static/chunks/{0bndjr3n70vjn.js → 0lt8ko3lw.5yt.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0el2m08z2u5jm.js → 0ml1.ck_5t36i.js} +1 -1
- package/.next/standalone/.next/static/chunks/{11zd_~~dqyu39.js → 0pkl..xgo-qox.js} +1 -1
- package/.next/standalone/.next/static/chunks/12l2t63hkyo2q.js +1 -0
- package/.next/standalone/.next/static/chunks/{0-17za-4x~4gj.js → 14lii11wmo450.js} +1 -1
- package/.next/standalone/.next/static/chunks/{05i2pvqx75mg1.js → 179yytvmam0ug.js} +1 -1
- package/.next/standalone/.next/static/chunks/17rm86uz2nd5a.css +2 -0
- package/.next/standalone/.opencode/plugins/failproofai.mjs +75 -15
- package/.next/standalone/app/actions/get-hooks-config.ts +25 -1
- package/.next/standalone/app/policies/hooks-client.tsx +228 -44
- package/.next/standalone/lib/gemini-projects.ts +64 -24
- package/.next/standalone/lib/opencode-projects.ts +9 -7
- package/.next/standalone/package.json +2 -2
- package/.next/standalone/pi-extension/index.ts +113 -12
- package/.next/standalone/server.js +1 -1
- package/dist/cli.mjs +193 -68
- package/lib/gemini-projects.ts +64 -24
- package/lib/opencode-projects.ts +9 -7
- package/package.json +2 -2
- package/pi-extension/index.ts +113 -12
- package/scripts/launch.ts +5 -29
- package/src/hooks/handler.ts +63 -6
- package/src/hooks/integrations.ts +31 -6
- package/src/hooks/policy-evaluator.ts +34 -2
- package/src/hooks/types.ts +52 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0.2-_y.._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0okpm5k._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0zwce~o._.js +0 -4
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0~tyclf._.js +0 -3
- package/.next/standalone/.next/static/chunks/0xd2k83e47~cx.js +0 -6
- package/.next/standalone/.next/static/chunks/0ywdtmk13p9_i.css +0 -2
- /package/.next/standalone/.next/static/{rOMtBtMm3y5vK0uC-Nzvi → dAuQps6jUwCz9X1Q5FFOO}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{rOMtBtMm3y5vK0uC-Nzvi → dAuQps6jUwCz9X1Q5FFOO}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{rOMtBtMm3y5vK0uC-Nzvi → dAuQps6jUwCz9X1Q5FFOO}/_ssgManifest.js +0 -0
|
@@ -42,6 +42,28 @@ function canonicalizeTool(raw) {
|
|
|
42
42
|
return TOOL_NAME_MAP[raw] != null ? TOOL_NAME_MAP[raw] : raw;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
// Per-tool input-key translation: opencode native tools deliver args as
|
|
46
|
+
// camelCase (\`filePath\`, \`oldString\`, …) but failproofai builtin policies
|
|
47
|
+
// (\`block-read-outside-cwd\`, \`block-env-files\`, \`block-secrets-write\`)
|
|
48
|
+
// read \`ctx.toolInput.file_path\` etc. Without this map every Read/Write/Edit
|
|
49
|
+
// path-check silently no-ops on opencode. Keys are PascalCase canonical tool
|
|
50
|
+
// names so the lookup pairs with canonicalizeTool's output. Tools outside the
|
|
51
|
+
// map (MCP \`mcp_*\`, plugins) pass through unchanged. Keep in sync with
|
|
52
|
+
// OPENCODE_TOOL_INPUT_MAP in failproofai/src/hooks/types.ts.
|
|
53
|
+
const TOOL_INPUT_MAP = {
|
|
54
|
+
Read: { filePath: "file_path" },
|
|
55
|
+
Write: { filePath: "file_path" },
|
|
56
|
+
Edit: { filePath: "file_path", oldString: "old_string", newString: "new_string", replaceAll: "replace_all" },
|
|
57
|
+
};
|
|
58
|
+
function canonicalizeToolInput(canonicalToolName, args) {
|
|
59
|
+
if (!args || typeof args !== "object") return args;
|
|
60
|
+
const map = TOOL_INPUT_MAP[canonicalToolName];
|
|
61
|
+
if (!map) return args;
|
|
62
|
+
const out = {};
|
|
63
|
+
for (const k of Object.keys(args)) out[map[k] != null ? map[k] : k] = args[k];
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
|
|
45
67
|
const FAILPROOFAI_BIN = ${h};
|
|
46
68
|
const USE_NPX = ${d};
|
|
47
69
|
|
|
@@ -140,11 +162,12 @@ export default async function failproofaiPlugin({ client, directory }) {
|
|
|
140
162
|
|
|
141
163
|
// First-class PreToolUse hook. Note: tool args live on output.args (mutable).
|
|
142
164
|
"tool.execute.before": async (input, output) => {
|
|
165
|
+
const canonicalTool = canonicalizeTool(input.tool);
|
|
143
166
|
const r = runFailproofai("PreToolUse", {
|
|
144
167
|
session_id: input.sessionID,
|
|
145
168
|
cwd: directory,
|
|
146
|
-
tool_name:
|
|
147
|
-
tool_input: output.args,
|
|
169
|
+
tool_name: canonicalTool,
|
|
170
|
+
tool_input: canonicalizeToolInput(canonicalTool, output.args),
|
|
148
171
|
hook_event_name: "PreToolUse",
|
|
149
172
|
}, directory);
|
|
150
173
|
await applyDecision(r, { client, sessionID: input.sessionID }, "PreToolUse");
|
|
@@ -152,11 +175,12 @@ export default async function failproofaiPlugin({ client, directory }) {
|
|
|
152
175
|
|
|
153
176
|
// First-class PostToolUse hook. Note: tool args live on input.args here.
|
|
154
177
|
"tool.execute.after": async (input, output) => {
|
|
178
|
+
const canonicalTool = canonicalizeTool(input.tool);
|
|
155
179
|
const r = runFailproofai("PostToolUse", {
|
|
156
180
|
session_id: input.sessionID,
|
|
157
181
|
cwd: directory,
|
|
158
|
-
tool_name:
|
|
159
|
-
tool_input: input.args,
|
|
182
|
+
tool_name: canonicalTool,
|
|
183
|
+
tool_input: canonicalizeToolInput(canonicalTool, input.args),
|
|
160
184
|
tool_response: { title: output.title, output: output.output, metadata: output.metadata },
|
|
161
185
|
hook_event_name: "PostToolUse",
|
|
162
186
|
}, directory);
|
|
@@ -165,11 +189,12 @@ export default async function failproofaiPlugin({ client, directory }) {
|
|
|
165
189
|
|
|
166
190
|
// Cleaner deny UX for prompted tools — mutate output.status instead of throwing.
|
|
167
191
|
"permission.ask": async (input, output) => {
|
|
192
|
+
const canonicalTool = canonicalizeTool(input.tool);
|
|
168
193
|
const r = runFailproofai("PermissionRequest", {
|
|
169
194
|
session_id: input.sessionID,
|
|
170
195
|
cwd: directory,
|
|
171
|
-
tool_name:
|
|
172
|
-
tool_input: input,
|
|
196
|
+
tool_name: canonicalTool || input.command || "permission",
|
|
197
|
+
tool_input: canonicalizeToolInput(canonicalTool, input),
|
|
173
198
|
hook_event_name: "PermissionRequest",
|
|
174
199
|
}, directory);
|
|
175
200
|
try {
|
|
@@ -193,6 +218,6 @@ Use either: --install all or --install block-sudo sanitize-jwt ...`)}let m=j&&
|
|
|
193
218
|
Validated ${a.length} custom hook(s): ${a.map(a=>a.name).join(", ")}`)}x(q,b,c),console.log(`
|
|
194
219
|
Enabled ${k.length} policy(ies): ${k.join(", ")}
|
|
195
220
|
`),i?console.log("Custom hooks path cleared."):q.customPoliciesPath&&console.log(`Custom hooks path: ${q.customPoliciesPath}`);let r=[];for(let a of m){let d=V(a),e=d.getSettingsPath(b,c),f=d.readSettings(e);d.writeHookEntries(f,n,b),d.writeSettings(e,f),r.push({cli:a,path:e})}try{let a=new Set(k),c=k.filter(a=>!p.has(a)),d=[...p].filter(b=>!a.has(b)),f=(0,bA.getInstanceId)();await bz(f,"hooks_installed",{scope:b,cli:m,cli_count:m.length,policies:k,policy_count:k.length,policies_added:c,policies_removed:d,...e?{source:e}:{},platform:(0,g.platform)(),arch:(0,g.arch)(),os_release:(0,g.release)(),hostname_hash:(0,bA.hashToId)((0,g.hostname)()),has_custom_hooks_path:!!q.customPoliciesPath,has_policy_params:!!(q.policyParams&&Object.keys(q.policyParams).length>0),param_policy_names:q.policyParams?Object.keys(q.policyParams):[],command_format:"project"===b?"npx":"absolute"})}catch{}for(let{cli:a,path:c}of r){let d=V(a);console.log(`Failproof AI hooks installed for ${d.displayName} (${d.eventTypes.length} event types, scope: ${b}).`),console.log(`Settings: ${c}`)}"project"===b?(console.log("Command: npx -y failproofai"),console.log(`
|
|
196
|
-
This file can be committed to git — no machine-specific paths.`)):console.log(`Binary: ${n}`);let s=(l=new Set,z.filter(a=>{let b=bD(a,c);return!l.has(b)&&(l.add(b),!0)})).filter(a=>a!==b).filter(a=>bF(a,c));if(s.length>0){let a=s.map(a=>`${a} (${function(a){switch(a){case"user":return"~/.claude/settings.json";case"project":return"{cwd}/.claude/settings.json";case"local":return"{cwd}/.claude/settings.local.json"}}(a)})`).join(", ");console.log(),console.log(`\x1b[33mWarning: Failproof AI hooks are also installed at ${a}.\x1b[0m`),console.log("Having hooks in multiple scopes may cause duplicate policy evaluation."),console.log(`Use \`failproofai policies --uninstall --scope ${s[0]}\` to remove the other installation,`),console.log("or `failproofai policies` to see all scopes.")}}async function bH(a,b="user",c,d){let f="all"===b?"user":b,h=d?.cli&&d.cli.length>0?[...new Set(d.cli)]:["claude"];if(d?.removeCustomHooks){let a=w(f,c);delete a.customPoliciesPath,x(a,f,c),console.log("Custom hooks path cleared.")}if(a&&a.length>0&&(1!==a.length||"all"!==a[0])){bE(a);let e=w(f,c),i=new Set(a),j=e.enabledPolicies.filter(a=>!i.has(a)),k=a.filter(a=>!e.enabledPolicies.includes(a));k.length>0&&console.log(`Warning: policy(ies) not currently enabled: ${k.join(", ")}`);let{policyParams:l,...m}=e,n=l?Object.fromEntries(Object.entries(l).filter(([a])=>!i.has(a))):null;x({...m,enabledPolicies:j,...n&&Object.keys(n).length>0?{policyParams:n}:{}},f,c);try{let c=(0,bA.getInstanceId)(),f=a.filter(a=>e.enabledPolicies.includes(a));await bz(c,"hooks_removed",{scope:b,cli:h,removal_mode:d?.betaOnly?"beta_policies":"policies",beta_only:d?.betaOnly??!1,policies_removed:f,removed_count:f.length,...d?.source?{source:d.source}:{},platform:(0,g.platform)(),arch:(0,g.arch)(),os_release:(0,g.release)(),hostname_hash:(0,bA.hashToId)((0,g.hostname)())})}catch{}console.log(`Disabled ${a.length-k.length} policy(ies).`),console.log(`Remaining: ${j.length>0?j.join(", "):"(none)"}`);return}let i=w(f,c),j=0,k=!1;for(let a of h){let d=V(a);for(let a of"all"===b?[...d.scopes]:d.scopes.includes(b)?[b]:[]){let f=d.getSettingsPath(a,c);if(!(0,e.existsSync)(f)){"all"!==b&&1===h.length&&(console.log("No settings file found. Nothing to remove."),k=!0);continue}let g=d.removeHooksFromFile(f);if(0===g&&"all"!==b&&1===h.length){console.log("No hooks found in settings. Nothing to remove."),k=!0;continue}j+=g,"all"!==b&&(console.log(`Removed ${g} failproofai hook(s) from ${d.displayName} settings.`),console.log(`Settings: ${f}`))}}if(!k||0!==j){if("all"===b)for(let a of(console.log(`Removed ${j} failproofai hook(s) from all scopes.`),h)){let b=V(a);for(let a of b.scopes)console.log(` ${b.displayName} / ${a}: ${b.getSettingsPath(a,c)}`)}try{let a=(0,bA.getInstanceId)();await bz(a,"hooks_removed",{scope:b,cli:h,removal_mode:"hooks",policies_removed:i.enabledPolicies,removed_count:j,...d?.source?{source:d.source}:{},platform:(0,g.platform)(),arch:(0,g.arch)(),os_release:(0,g.release)(),hostname_hash:(0,bA.hashToId)((0,g.hostname)())})}catch{}if("all"===b)for(let a of z){let b=w(a,c);if(b.enabledPolicies.length>0||b.customPoliciesPath||b.policyParams){let{customPoliciesPath:d,policyParams:e,...f}=b;x({...f,enabledPolicies:[]},a,c)}}else if(!z.some(a=>bF(a,c))){let{customPoliciesPath:a,policyParams:b,...d}=w(f,c);x({...d,enabledPolicies:[]},f,c)}}}var bI=a.i(13095);async function
|
|
221
|
+
This file can be committed to git — no machine-specific paths.`)):console.log(`Binary: ${n}`);let s=(l=new Set,z.filter(a=>{let b=bD(a,c);return!l.has(b)&&(l.add(b),!0)})).filter(a=>a!==b).filter(a=>bF(a,c));if(s.length>0){let a=s.map(a=>`${a} (${function(a){switch(a){case"user":return"~/.claude/settings.json";case"project":return"{cwd}/.claude/settings.json";case"local":return"{cwd}/.claude/settings.local.json"}}(a)})`).join(", ");console.log(),console.log(`\x1b[33mWarning: Failproof AI hooks are also installed at ${a}.\x1b[0m`),console.log("Having hooks in multiple scopes may cause duplicate policy evaluation."),console.log(`Use \`failproofai policies --uninstall --scope ${s[0]}\` to remove the other installation,`),console.log("or `failproofai policies` to see all scopes.")}}async function bH(a,b="user",c,d){let f="all"===b?"user":b,h=d?.cli&&d.cli.length>0?[...new Set(d.cli)]:["claude"];if(d?.removeCustomHooks){let a=w(f,c);delete a.customPoliciesPath,x(a,f,c),console.log("Custom hooks path cleared.")}if(a&&a.length>0&&(1!==a.length||"all"!==a[0])){bE(a);let e=w(f,c),i=new Set(a),j=e.enabledPolicies.filter(a=>!i.has(a)),k=a.filter(a=>!e.enabledPolicies.includes(a));k.length>0&&console.log(`Warning: policy(ies) not currently enabled: ${k.join(", ")}`);let{policyParams:l,...m}=e,n=l?Object.fromEntries(Object.entries(l).filter(([a])=>!i.has(a))):null;x({...m,enabledPolicies:j,...n&&Object.keys(n).length>0?{policyParams:n}:{}},f,c);try{let c=(0,bA.getInstanceId)(),f=a.filter(a=>e.enabledPolicies.includes(a));await bz(c,"hooks_removed",{scope:b,cli:h,removal_mode:d?.betaOnly?"beta_policies":"policies",beta_only:d?.betaOnly??!1,policies_removed:f,removed_count:f.length,...d?.source?{source:d.source}:{},platform:(0,g.platform)(),arch:(0,g.arch)(),os_release:(0,g.release)(),hostname_hash:(0,bA.hashToId)((0,g.hostname)())})}catch{}console.log(`Disabled ${a.length-k.length} policy(ies).`),console.log(`Remaining: ${j.length>0?j.join(", "):"(none)"}`);return}let i=w(f,c),j=0,k=!1;for(let a of h){let d=V(a);for(let a of"all"===b?[...d.scopes]:d.scopes.includes(b)?[b]:[]){let f=d.getSettingsPath(a,c);if(!(0,e.existsSync)(f)){"all"!==b&&1===h.length&&(console.log("No settings file found. Nothing to remove."),k=!0);continue}let g=d.removeHooksFromFile(f);if(0===g&&"all"!==b&&1===h.length){console.log("No hooks found in settings. Nothing to remove."),k=!0;continue}j+=g,"all"!==b&&(console.log(`Removed ${g} failproofai hook(s) from ${d.displayName} settings.`),console.log(`Settings: ${f}`))}}if(!k||0!==j){if("all"===b)for(let a of(console.log(`Removed ${j} failproofai hook(s) from all scopes.`),h)){let b=V(a);for(let a of b.scopes)console.log(` ${b.displayName} / ${a}: ${b.getSettingsPath(a,c)}`)}try{let a=(0,bA.getInstanceId)();await bz(a,"hooks_removed",{scope:b,cli:h,removal_mode:"hooks",policies_removed:i.enabledPolicies,removed_count:j,...d?.source?{source:d.source}:{},platform:(0,g.platform)(),arch:(0,g.arch)(),os_release:(0,g.release)(),hostname_hash:(0,bA.hashToId)((0,g.hostname)())})}catch{}if("all"===b)for(let a of z){let b=w(a,c);if(b.enabledPolicies.length>0||b.customPoliciesPath||b.policyParams){let{customPoliciesPath:d,policyParams:e,...f}=b;x({...f,enabledPolicies:[]},a,c)}}else if(!z.some(a=>bF(a,c))){let{customPoliciesPath:a,policyParams:b,...d}=w(f,c);x({...d,enabledPolicies:[]},f,c)}}}var bI=a.i(24282),bJ=a.i(13095);async function bK(a){if(!(0,e.existsSync)(a))return[];let b=await (0,Y.readFile)(a,"utf-8"),c=[],d=b.split(/customPolicies\.add\s*\(/);for(let a=1;a<d.length;a++){let b=d[a],e=b.match(/name:\s*["'`]([^"'`]+)["'`]/);if(!e)continue;let f=b.match(/description:\s*["'`]([^"'`]+)["'`]/),g=b.match(/events:\s*\[([^\]]+)\]/),h=g?g[1].replace(/["'`\s]/g,"").split(",").filter(Boolean).join(", "):void 0;c.push({name:e[1],description:f?.[1],eventScope:h})}return c}async function bL(){let a=t(),b=new Set(a.enabledPolicies),c=z.filter(a=>bF(a)),d=bD(c[0]??"user"),e=A.map(a=>U[a]).map(a=>({id:a.id,label:(0,bI.getCliLabel)(a.id),installed:a.hooksInstalledInSettings("user"),settingsPath:a.getSettingsPath("user"),detected:a.detectInstalled()})),f=bf.map(c=>{var d;let e,f;return{name:c.name,description:c.description,category:c.category,defaultEnabled:c.defaultEnabled,beta:!!c.beta,enabled:b.has(c.name),eventScope:(d=c.match,e=d.events?.join(", ")??"",f=d.toolNames?` \xb7 ${d.toolNames.join(", ")}`:"",`${e}${f}`),params:c.params?Object.fromEntries(Object.entries(c.params).map(([a,b])=>[a,{type:b.type,description:b.description,default:b.default}])):void 0,currentParams:c.params?a.policyParams?.[c.name]??{}:void 0}}),g=a.customPoliciesPath?await bK(a.customPoliciesPath):void 0;return{enabledPolicies:a.enabledPolicies,installedScopes:c,settingsPath:d,clis:e,policies:f,customPoliciesPath:a.customPoliciesPath,customPolicies:g?.length?g:void 0}}async function bM(a,b){let c=t(),d=new Set(c.enabledPolicies);b?d.add(a):d.delete(a),u({...c,enabledPolicies:[...d]});try{let c=(0,bA.getInstanceId)();await bz(c,"policy_toggled",{policy_name:a,enabled:b,action:b?"enable":"disable",source:"web"})}catch{}}async function bN(a="user",b){let c=t(),d=c.enabledPolicies.length>0?c.enabledPolicies:bf.filter(a=>a.defaultEnabled&&!a.beta).map(a=>a.name),e=b&&b.length>0?b:W(),f=e.length>0?e:["claude"];await bG(d,a,void 0,!1,"web",void 0,!1,f)}async function bO(a="user",b){let c=b&&b.length>0?b:W(),d=c.length>0?c:["claude"];await bH(void 0,a,void 0,{source:"web",cli:d})}async function bP(a,b){let c=t(),d={...c.policyParams??{},[a]:b};u({...c,policyParams:d});try{let c=(0,bA.getInstanceId)();await bz(c,"policy_params_updated",{policy_name:a,param_keys:Object.keys(b),source:"web"})}catch{}}(0,bJ.ensureServerEntryExports)([bL]),(0,d.registerServerReference)(bL,"006ae6c77a6b860631f0b05f055600b490d96feb01",null),(0,bJ.ensureServerEntryExports)([bM]),(0,d.registerServerReference)(bM,"60474dd63e4ca78318418a84742753bcf27e8be12d",null),(0,bJ.ensureServerEntryExports)([bN,bO]),(0,d.registerServerReference)(bN,"60afa57857d3f18dc463fc3a2dcf942a73adeb9e28",null),(0,d.registerServerReference)(bO,"6010e22670ccd7912f669a127211be1912462760c1",null),(0,bJ.ensureServerEntryExports)([bP]),(0,d.registerServerReference)(bP,"6009f76760f968bad6473b991630e917577dcad669",null),a.s([],63895),a.i(63895),a.s(["001ce9bc6145239393c867a916f9601df1c75bfbf7",()=>b.getTelemetryConfig,"006ae6c77a6b860631f0b05f055600b490d96feb01",0,bL,"402714e0127fd96b57ab64b8f734f9316459cc9edc",()=>c.getHookActivityAction,"6009f76760f968bad6473b991630e917577dcad669",0,bP,"6010e22670ccd7912f669a127211be1912462760c1",0,bO,"60474dd63e4ca78318418a84742753bcf27e8be12d",0,bM,"60a3d76dbcd84dcda4d20bb06166e7d742409464f3",()=>c.searchHookActivityAction,"60afa57857d3f18dc463fc3a2dcf942a73adeb9e28",0,bN],11369)}];
|
|
197
222
|
|
|
198
223
|
//# sourceMappingURL=%5Broot-of-the-server%5D__0ymlddl._.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module.exports=[50227,(a,b,c)=>{b.exports=a.x("node:path",()=>require("node:path"))},60526,(a,b,c)=>{b.exports=a.x("node:os",()=>require("node:os"))},2157,(a,b,c)=>{b.exports=a.x("node:fs",()=>require("node:fs"))},74533,(a,b,c)=>{b.exports=a.x("node:child_process",()=>require("node:child_process"))},66680,(a,b,c)=>{b.exports=a.x("node:crypto",()=>require("node:crypto"))},37936,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"registerServerReference",{enumerable:!0,get:function(){return d.registerServerReference}});let d=a.r(11857)},12072,(a,b,c)=>{b.exports={name:"failproofai",version:"0.0.10
|
|
2
|
-
Read more: https://nextjs.org/docs/messages/invalid-use-server-value`),"__NEXT_ERROR_CODE",{value:"E352",enumerable:!1,configurable:!0})}}Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"ensureServerEntryExports",{enumerable:!0,get:function(){return d}})},36359,69839,79779,a=>{"use strict";let b;var c=a.i(37936),d=a.i(2157),e=a.i(50227),f=a.i(60526),g=a.i(66680);a.i(74533);let h=e.default.join(f.default.homedir(),".failproofai"),i=e.default.join(h,"instance-id");function j(a){return g.default.createHmac("sha256","failproofai-telemetry-v1").update(a).digest("hex")}function k(){if(b)return b;let a=function(){try{for(let a of(f.default.platform(),["/etc/machine-id","/var/lib/dbus/machine-id"]))try{let b=d.default.readFileSync(a,"utf-8").trim();if(b)return b}catch{}}catch{}}();if(a)return b=j(a);let c=[f.default.hostname(),f.default.homedir(),f.default.platform(),f.default.arch(),f.default.cpus()[0]?.model??""].join(":");return b=c?j(c):function(){try{let a=d.default.readFileSync(i,"utf-8").trim();if(a)return a}catch{}let a=g.default.randomUUID();try{d.default.mkdirSync(h,{recursive:!0}),d.default.writeFileSync(i,a,"utf-8")}catch{}return a}()}a.s(["getInstanceId",0,k,"hashToId",0,j],69839),a.s(["POSTHOG_API_KEY",0,"phc_Ac1Ww1GqKc0z1SyrRWbmatEeQdlOQIsDEEdP8l8JRgX"],79779);var l=a.i(12072);async function m(){let a="1"!==process.env.FAILPROOFAI_TELEMETRY_DISABLED;return{enabled:a,distinctId:a?k():"",apiKey:process.env.FAILPROOFAI_POSTHOG_KEY??"phc_Ac1Ww1GqKc0z1SyrRWbmatEeQdlOQIsDEEdP8l8JRgX",host:process.env.FAILPROOFAI_POSTHOG_HOST??"https://us.i.posthog.com",version:l.version}}(0,a.i(13095).ensureServerEntryExports)([m]),(0,c.registerServerReference)(m,"
|
|
1
|
+
module.exports=[50227,(a,b,c)=>{b.exports=a.x("node:path",()=>require("node:path"))},60526,(a,b,c)=>{b.exports=a.x("node:os",()=>require("node:os"))},2157,(a,b,c)=>{b.exports=a.x("node:fs",()=>require("node:fs"))},74533,(a,b,c)=>{b.exports=a.x("node:child_process",()=>require("node:child_process"))},66680,(a,b,c)=>{b.exports=a.x("node:crypto",()=>require("node:crypto"))},37936,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"registerServerReference",{enumerable:!0,get:function(){return d.registerServerReference}});let d=a.r(11857)},12072,(a,b,c)=>{b.exports={name:"failproofai",version:"0.0.10",description:"The easiest way to manage policies that keep your AI agents reliable, on-task, and running autonomously — for Claude Code & the Agents SDK",bin:{failproofai:"./dist/cli.mjs"},files:["bin/","src/","scripts/","lib/","pi-extension/",".next/standalone/","dist/","README.md"],engines:{node:">=20.9.0",bun:">=1.3.0"},scripts:{predev:"bun run build:cli && bun link",dev:"FAILPROOFAI_TELEMETRY_DISABLED=1 bun scripts/dev.ts --port 8020","build:cli":"bun build --target=node --format=esm --outfile=dist/cli.mjs bin/failproofai.mjs --external posthog-node && node -e \"const fs=require('fs');const c=fs.readFileSync('dist/cli.mjs','utf8');fs.writeFileSync('dist/cli.mjs',c.replace('#!/usr/bin/env bun','#!/usr/bin/env node').replace('// @bun\\n',''))\"",build:"bun build --target=node --format=cjs --outfile=dist/index.js src/index.ts && bun run build:cli && bun --bun next build && node -e \"const {cpSync}=require('fs');cpSync('.next/static','.next/standalone/.next/static',{recursive:true});\" && node scripts/prune-standalone.mjs",prestart:"bun run build:cli && bun link",start:"FAILPROOFAI_TELEMETRY_DISABLED=1 bun scripts/start.ts",test:"vitest","test:run":"vitest run",lint:"eslint . --config eslint.config.mjs",postinstall:"node scripts/postinstall.mjs",preuninstall:"node scripts/preuninstall.mjs",prepare:"bun run build","test:e2e":"vitest run --config vitest.config.e2e.mts","test:e2e:watch":"vitest --config vitest.config.e2e.mts",translate:"bun scripts/translate-docs/cli.ts","translate:readme":"bun scripts/translate-docs/cli.ts --readme-only","translate:docs":"bun scripts/translate-docs/cli.ts --docs-only","translate:dry-run":"bun scripts/translate-docs/cli.ts --dry-run","translate:validate":"bun scripts/translate-docs/cli.ts --validate"},keywords:["claude","claude-code","claude-agents-sdk","anthropic","ai-agent","agent-reliability","agent-monitoring","autonomous-agent","failure-prevention","developer-tools","devtools","cli","local-first","hooks","policies"],author:"ExosphereHost Inc. <failproofai@exosphere.host>",license:"SEE LICENSE IN LICENSE",homepage:"https://github.com/exospherehost/failproofai",repository:{type:"git",url:"https://github.com/exospherehost/failproofai.git"},bugs:{url:"https://github.com/exospherehost/failproofai/issues"},publishConfig:{access:"public"},devDependencies:{"@anthropic-ai/sdk":"^0.93.0","@tailwindcss/postcss":"^4.1.18","@tanstack/react-virtual":"^3.13.18","@testing-library/jest-dom":"^6.9.1","@testing-library/react":"^16.3.2","@testing-library/user-event":"^14.6.1","@types/node":"^25.5.2","@types/react":"^19.2.13","@types/react-dom":"^19.2.3","@vitejs/plugin-react":"^6.0.1",clsx:"^2.1.1",eslint:"^10.2.0","eslint-config-next":"^16.2.2","happy-dom":"^20.7.0","lucide-react":"^1.0.1",next:"^16.2.2",react:"^19.2.4","react-dom":"^19.2.4","tailwind-merge":"^3.4.0",tailwindcss:"^4.1.18",typescript:"^6.0.2",vitest:"^4.0.18"},dependencies:{"posthog-node":"^5.28.11"}}},13095,(a,b,c)=>{"use strict";function d(a){for(let b=0;b<a.length;b++){let c=a[b];if("function"!=typeof c)throw Object.defineProperty(Error(`A "use server" file can only export async functions, found ${typeof c}.
|
|
2
|
+
Read more: https://nextjs.org/docs/messages/invalid-use-server-value`),"__NEXT_ERROR_CODE",{value:"E352",enumerable:!1,configurable:!0})}}Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"ensureServerEntryExports",{enumerable:!0,get:function(){return d}})},36359,69839,79779,a=>{"use strict";let b;var c=a.i(37936),d=a.i(2157),e=a.i(50227),f=a.i(60526),g=a.i(66680);a.i(74533);let h=e.default.join(f.default.homedir(),".failproofai"),i=e.default.join(h,"instance-id");function j(a){return g.default.createHmac("sha256","failproofai-telemetry-v1").update(a).digest("hex")}function k(){if(b)return b;let a=function(){try{for(let a of(f.default.platform(),["/etc/machine-id","/var/lib/dbus/machine-id"]))try{let b=d.default.readFileSync(a,"utf-8").trim();if(b)return b}catch{}}catch{}}();if(a)return b=j(a);let c=[f.default.hostname(),f.default.homedir(),f.default.platform(),f.default.arch(),f.default.cpus()[0]?.model??""].join(":");return b=c?j(c):function(){try{let a=d.default.readFileSync(i,"utf-8").trim();if(a)return a}catch{}let a=g.default.randomUUID();try{d.default.mkdirSync(h,{recursive:!0}),d.default.writeFileSync(i,a,"utf-8")}catch{}return a}()}a.s(["getInstanceId",0,k,"hashToId",0,j],69839),a.s(["POSTHOG_API_KEY",0,"phc_Ac1Ww1GqKc0z1SyrRWbmatEeQdlOQIsDEEdP8l8JRgX"],79779);var l=a.i(12072);async function m(){let a="1"!==process.env.FAILPROOFAI_TELEMETRY_DISABLED;return{enabled:a,distinctId:a?k():"",apiKey:process.env.FAILPROOFAI_POSTHOG_KEY??"phc_Ac1Ww1GqKc0z1SyrRWbmatEeQdlOQIsDEEdP8l8JRgX",host:process.env.FAILPROOFAI_POSTHOG_HOST??"https://us.i.posthog.com",version:l.version}}(0,a.i(13095).ensureServerEntryExports)([m]),(0,c.registerServerReference)(m,"001ce9bc6145239393c867a916f9601df1c75bfbf7",null),a.s(["getTelemetryConfig",0,m],36359)},24190,a=>{"use strict";var b=a.i(36359);a.s([],40488),a.i(40488),a.s(["001ce9bc6145239393c867a916f9601df1c75bfbf7",()=>b.getTelemetryConfig],24190)},2726,a=>{a.v(b=>Promise.all(["server/chunks/ssr/[externals]__12dv.x0._.js","server/chunks/ssr/node_modules_posthog-node_dist_entrypoints_index_node_mjs_0mebn66._.js"].map(b=>a.l(b))).then(()=>b(74493)))}];
|
|
3
3
|
|
|
4
4
|
//# sourceMappingURL=%5Broot-of-the-server%5D__10._f0s._.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module.exports=[14066,a=>{"use strict";a.s(["default",()=>b]);let b=(0,a.i(11857).registerClientReference)(function(){throw Error("Attempted to call the default export of [project]/app/components/lazy-log-viewer.tsx <module evaluation> from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/app/components/lazy-log-viewer.tsx <module evaluation>","default")},19597,a=>{"use strict";a.s(["default",()=>b]);let b=(0,a.i(11857).registerClientReference)(function(){throw Error("Attempted to call the default export of [project]/app/components/lazy-log-viewer.tsx from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/app/components/lazy-log-viewer.tsx","default")},71130,a=>{"use strict";a.i(14066);var b=a.i(19597);a.n(b)},85540,a=>{"use strict";a.s(["CopyButton",()=>b]);let b=(0,a.i(11857).registerClientReference)(function(){throw Error("Attempted to call CopyButton() from the server but CopyButton is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/app/components/copy-button.tsx <module evaluation>","CopyButton")},35770,a=>{"use strict";a.s(["CopyButton",()=>b]);let b=(0,a.i(11857).registerClientReference)(function(){throw Error("Attempted to call CopyButton() from the server but CopyButton is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/app/components/copy-button.tsx","CopyButton")},893,a=>{"use strict";a.i(85540);var b=a.i(35770);a.n(b)},41190,a=>{"use strict";var b=a.i(7997),c=a.i(95936),d=a.i(84930);let e=(0,a.i(92277).default)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);a.i(70396);var f=a.i(73727),g=a.i(24868),h=a.i(14747),i=a.i(90798),j=a.i(69191);async function k(a,b,c,d){let e=`agent-${d}.jsonl`;for(let d of[(0,h.join)(a,b,e),(0,h.join)(a,b,c,e),(0,h.join)(a,b,c,"subagents",e)])if(!(0,h.relative)(a,d).startsWith(".."))try{return await (0,g.access)(d),d}catch(a){if("ENOENT"===a.code)continue;break}return null}var l=a.i(34900),m=a.i(26192),n=a.i(33432);function o(a){if(a<1e3)return`${a}ms`;let b=a/1e3;if(b<60)return`${b.toFixed(1)}s`;let c=Math.floor(b/60);if(c>=60){let a=Math.floor(c/60);return`${a}h ${c%60}m`}let d=(b%60).toFixed(0);return`${c}m ${d}s`}function p(a){let b=(0,n.formatDate)(a),c=a.getMilliseconds().toString().padStart(3,"0");return`${b}.${c}`}function q(a,b,c,d){return{_source:d,uuid:a.uuid||"",parentUuid:a.parentUuid??null,timestamp:b,timestampMs:c.getTime(),timestampFormatted:p(c)}}async function r(a,b){let c=a.split("\n").filter(a=>""!==a.trim()),d=new Map,e=[],f=[],g=new Set,h=!1;for(let a=0;a<c.length;a++){let i;a>0&&a%200==0&&await new Promise(a=>setImmediate(a));let j=c[a];try{i=JSON.parse(j)}catch{continue}let k={...i,_source:b};f.push(k);let l=i.type,m=i.timestamp;if(!m)continue;let n=new Date(m),o=n.getTime();if("user"===l){let a=i.message;if(Array.isArray(a?.content)){let b=a.content;if(b.some(a=>"tool_result"===a.type)){let a=i.toolUseResult,c="string"==typeof a?.agentId?a.agentId:void 0;for(let a of(c&&/^[a-f0-9]+$/.test(c)&&g.add(c),b)){if("tool_result"!==a.type)continue;let b=a.tool_use_id;if(!b)continue;let{text:e,images:f}=function(a){let b=a.content;if("string"==typeof b)return{text:b};if(Array.isArray(b)){let a=b.filter(a=>"text"===a.type).map(a=>a.text),c=b.filter(a=>"image"===a.type).map(a=>{let b=a.source;return{base64:b.data,mediaType:b.media_type}}).filter(a=>a.base64&&a.mediaType);return{text:a.length>0?a.join("\n"):void 0,images:c.length>0?c:void 0}}return{}}(a);d.set(b,{timestamp:m,timestampMs:o,content:e,images:f,agentId:c})}continue}}let c="string"==typeof a?.content?a.content:"";e.push({type:"user",...q(i,m,n,b),message:{role:"user",content:c}});continue}if("assistant"===l){let a=i.message,c=[];if(Array.isArray(a?.content)&&(c=a.content.filter(a=>["text","tool_use","thinking"].includes(a.type)).map(a=>{if("text"===a.type)return{type:"text",text:a.text};if("tool_use"===a.type){let b=a.input;return{type:"tool_use",id:a.id,name:a.name,input:a.input??{},..."Task"===a.name&&b?{subagentType:b.subagent_type,subagentDescription:b.description}:{}}}return{type:"thinking",thinking:a.thinking,signature:a.signature}})),0===c.length)continue;e.push({type:"assistant",...q(i,m,n,b),message:{role:"assistant",content:c,model:a?.model}});continue}if("file-history-snapshot"===l||"progress"===l||"system"===l){e.push({type:l,...q(i,m,n,b),raw:{...i}});continue}if("queue-operation"===l){let a=h?"Session Resumed":"Session Started";h=!0,e.push({type:"queue-operation",...q(i,m,n,b),label:a});continue}}let i=0;for(let a of e)if("assistant"===a.type)for(let b of(++i%200==0&&await new Promise(a=>setImmediate(a)),a.message.content)){if("tool_use"!==b.type)continue;let c=d.get(b.id);if(!c)continue;let e=new Date(c.timestamp),f=Math.max(0,c.timestampMs-a.timestampMs);b.result={timestamp:c.timestamp,timestampFormatted:p(e),content:c.content,images:c.images,durationMs:f,durationFormatted:o(f)},c.agentId&&(b.subagentId=c.agentId)}return e.length>500&&await new Promise(a=>setImmediate(a)),e.sort((a,b)=>a.timestampMs-b.timestampMs),{entries:e,rawLines:f,subagentIds:Array.from(g)}}async function s(a,b){let c=(0,j.resolveProjectPath)(a),d=(0,i.getClaudeProjectsPath)(),e=(0,h.join)(c,`${b}.jsonl`),f=await (0,g.readFile)(e,"utf-8"),{entries:l,rawLines:n,subagentIds:o}=await r(f,"session");if(0===o.length)return{entries:l,rawLines:n,subagentIds:[]};let p=await (0,m.batchAll)(o.map(c=>async()=>{let e=`agent-${c}`,f=await k(d,a,b,c);if(!f)return null;let h=await (0,g.readFile)(f,"utf-8"),{entries:i,rawLines:j}=await r(h,e);return{entries:i,rawLines:j}}),4),q=[...l],s=[...n];for(let a of p)"fulfilled"===a.status&&a.value&&(q.push(...a.value.entries),s.push(...a.value.rawLines));return q.length>500&&await new Promise(a=>setImmediate(a)),q.sort((a,b)=>a.timestampMs-b.timestampMs),{entries:q,rawLines:s,subagentIds:o}}let t=(0,l.runtimeCache)((a,b)=>s(a,b),60,{maxSize:50});var u=a.i(2157),v=a.i(12714),w=a.i(50227),x=a.i(60526);let y=(0,w.join)((0,x.homedir)(),".failproofai","cache","codex-session-paths.json");function z(){try{if(!(0,u.existsSync)(y))return{};return JSON.parse((0,u.readFileSync)(y,"utf-8"))}catch{return{}}}function A(a,b){try{(0,u.mkdirSync)((0,w.dirname)(y),{recursive:!0});let c=z();c[a]=b,(0,u.writeFileSync)(y,JSON.stringify(c),"utf-8")}catch{}}function B(a,b){try{for(let c of(0,u.readdirSync)(a,{withFileTypes:!0}))if(c.isFile()&&c.name.includes(b)&&c.name.endsWith(".jsonl"))return(0,w.join)(a,c.name)}catch{}return null}function C(a,b){return Array.isArray(a)?a.filter(a=>a?.type===b&&"string"==typeof a.text).map(a=>a.text).join("\n"):""}async function D(a,b="session"){let c,d=a.split("\n").filter(a=>""!==a.trim()),e=[],f=[],g=new Map,h=new Map,i=!1;for(let a=0;a<d.length;a++){let j;a>0&&a%200==0&&await new Promise(a=>setImmediate(a));let k=d[a];try{j=JSON.parse(k)}catch{continue}let l={...j,_source:b};f.push(l);let m=j.timestamp;if(!m)continue;let n=new Date(m);if(Number.isNaN(n.getTime()))continue;let r=j.type,s=j.payload??{};if("session_meta"===r){let a=s.cwd;"string"!=typeof a||c||(c=a),e.push({type:"system",...q(l,m,n,b),raw:l});continue}if("response_item"===r){let a=s.type;if("message"===a){let a=s.role,c=s.content;if("user"===a||"developer"===a){let d=C(c,"input_text");if(!d)continue;let f="developer"===a?`[developer] ${d}`:d;e.push({type:"user",...q(l,m,n,b),message:{role:"user",content:f}});continue}if("assistant"===a){let a=C(c,"output_text");if(!a)continue;let d=[{type:"text",text:a}];e.push({type:"assistant",...q(l,m,n,b),message:{role:"assistant",content:d}});continue}e.push({type:"system",...q(l,m,n,b),raw:l});continue}if("function_call"===a){let a=s.call_id,c=s.name??"function_call",d={type:"tool_use",id:a??`${m}-${c}`,name:c,input:function(a){if(!a)return{};try{return JSON.parse(a)}catch{return{}}}(s.arguments)},f={type:"assistant",...q(l,m,n,b),message:{role:"assistant",content:[d]}};e.push(f),a&&(g.set(a,d),h.set(a,n.getTime()));continue}if("function_call_output"===a){let a=s.call_id,c=a?g.get(a):void 0;if(c){let b=h.get(a)??n.getTime(),d=Math.max(0,n.getTime()-b);c.result={timestamp:m,timestampFormatted:p(n),content:"string"==typeof s.output?s.output:JSON.stringify(s.output),durationMs:d,durationFormatted:o(d)};continue}e.push({type:"system",...q(l,m,n,b),raw:l});continue}e.push({type:"system",...q(l,m,n,b),raw:l});continue}if("event_msg"===r){let a=s.type;if("task_started"===a){let a=i?"Session Resumed":"Session Started";i=!0,e.push({type:"queue-operation",...q(l,m,n,b),label:a});continue}if("exec_command_end"===a){let a=s.call_id,c=a?g.get(a):void 0;if(c){let b=s.duration,d=b?(b.secs??0)*1e3+Math.round((b.nanos??0)/1e6):Math.max(0,n.getTime()-(h.get(a)??n.getTime())),e=s.aggregated_output;c.result={timestamp:m,timestampFormatted:p(n),content:"string"==typeof e?e:JSON.stringify(e),durationMs:d,durationFormatted:o(d)};continue}e.push({type:"system",...q(l,m,n,b),raw:l});continue}if("user_message"===a||"agent_message"===a)continue;e.push({type:"system",...q(l,m,n,b),raw:l});continue}e.push({type:"system",...q(l,m,n,b),raw:l})}return e.length>500&&await new Promise(a=>setImmediate(a)),e.sort((a,b)=>a.timestampMs-b.timestampMs),{entries:e,rawLines:f,cwd:c}}async function E(a){let b=function(a){let b=z()[a];if(b&&(0,u.existsSync)(b))return b;let c=(0,w.join)((0,x.homedir)(),".codex","sessions"),d=new Date,e=new Date(d.getTime()-864e5);for(let b of[d,e].map(a=>{let b=String(a.getUTCFullYear()),d=String(a.getUTCMonth()+1).padStart(2,"0"),e=String(a.getUTCDate()).padStart(2,"0");return(0,w.join)(c,b,d,e)})){let c=B(b,a);if(c)return A(a,c),c}try{for(let b of(0,u.readdirSync)(c,{withFileTypes:!0}))if(b.isDirectory()){for(let d of(0,u.readdirSync)((0,w.join)(c,b.name),{withFileTypes:!0}))if(d.isDirectory())for(let e of(0,u.readdirSync)((0,w.join)(c,b.name,d.name),{withFileTypes:!0})){if(!e.isDirectory())continue;let f=B((0,w.join)(c,b.name,d.name,e.name),a);if(f)return A(a,f),f}}}catch{}return null}(a);if(!b)return null;let c=await (0,v.readFile)(b,"utf-8"),{entries:d,rawLines:e,cwd:f}=await D(c,"session");return{entries:d,rawLines:e,cwd:f,filePath:b}}let F=(0,l.runtimeCache)(a=>E(a),60,{maxSize:50});function G(a,b){let c=function(a){if(!a)return null;let b=(0,w.resolve)((0,w.join)(process.env.COPILOT_HOME||(0,w.join)((0,x.homedir)(),".copilot"),"session-state")),c=(0,w.resolve)(b,a);return c!==b&&c.startsWith(`${b}${w.sep}`)?c:null}(a);return c?(0,w.join)(c,b):null}async function H(a,b="session"){let c,d=a.split("\n").filter(a=>""!==a.trim()),e=[],f=[],g=new Map,h=new Map,i=!1;for(let a=0;a<d.length;a++){let j;a>0&&a%200==0&&await new Promise(a=>setImmediate(a));let k=d[a];try{j=JSON.parse(k)}catch{continue}let l={...j,_source:b};f.push(l);let m=j.timestamp;if(!m)continue;let n=new Date(m);if(Number.isNaN(n.getTime()))continue;let r=n.toISOString(),s=j.type,t=j.data??{};if("session.start"===s){let a=t.context,d=a?.cwd;"string"!=typeof d||c||(c=d);let f=i?"Session Resumed":"Session Started";i=!0,e.push({type:"queue-operation",...q(l,r,n,b),label:f});continue}if("user.message"===s){let a=t.content??"";if(!a)continue;e.push({type:"user",...q(l,r,n,b),message:{role:"user",content:a}});continue}if("system.message"===s){e.push({type:"system",...q(l,r,n,b),raw:l});continue}if("assistant.message"===s){let a=t.content??"";if(!a){e.push({type:"system",...q(l,r,n,b),raw:l});continue}let c=[{type:"text",text:a}];e.push({type:"assistant",...q(l,r,n,b),message:{role:"assistant",content:c}});continue}if("tool.execution_start"===s){let a=t.toolCallId,c=t.toolName??"tool",d=t.arguments??{},f={type:"tool_use",id:a??`${n.getTime()}-${c}`,name:c,input:d},i={type:"assistant",...q(l,r,n,b),message:{role:"assistant",content:[f]}};e.push(i),a&&(g.set(a,f),h.set(a,n.getTime()));continue}if("tool.execution_complete"===s){let a=t.toolCallId,c=a?g.get(a):void 0;if(c){let b=h.get(a)??n.getTime(),d=t.result??{},e=t.toolTelemetry??{},f=e.metrics?.commandTimeMs??e.metrics?.durationMs??null,g="number"==typeof f&&f>=0?f:Math.max(0,n.getTime()-b),i=d.detailedContent??d.content??"";c.result={timestamp:r,timestampFormatted:p(n),content:"string"==typeof i?i:JSON.stringify(i),durationMs:g,durationFormatted:o(g)};continue}e.push({type:"system",...q(l,r,n,b),raw:l});continue}e.push({type:"system",...q(l,r,n,b),raw:l})}return e.length>500&&await new Promise(a=>setImmediate(a)),e.sort((a,b)=>a.timestampMs-b.timestampMs),{entries:e,rawLines:f,cwd:c}}async function I(a){let b,c,d=(c=G(a,"events.jsonl"))&&(0,u.existsSync)(c)?c:null;if(!d)return null;try{b=await (0,v.readFile)(d,"utf-8")}catch{return null}let{entries:e,rawLines:f,cwd:g}=await H(b,"session");return{entries:e,rawLines:f,cwd:g??function(a){let b,c=(b=G(a,"workspace.yaml"))&&(0,u.existsSync)(b)?b:null;if(c)try{let a=(0,u.readFileSync)(c,"utf-8"),b=RegExp("^cwd\\s*:\\s*(.+?)\\s*$","m"),d=a.match(b);if(!d)return;return d[1].replace(/^['"]|['"]$/g,"")}catch{return}}(a),filePath:d}}let J=(0,l.runtimeCache)(a=>I(a),60,{maxSize:50}),K=["agent-sessions","conversations","sessions"],L=["events.jsonl","transcript.jsonl","messages.jsonl"],M="agent-transcripts";async function N(a,b="session"){let c,d=a.split("\n").filter(a=>""!==a.trim()),e=[],f=[],g=new Map,h=new Map,i=!1,j=Date.now();for(let a=0;a<d.length;a++){let k;a>0&&a%200==0&&await new Promise(a=>setImmediate(a));let l=d[a];try{k=JSON.parse(l)}catch{continue}let m={...k,_source:b};if(f.push(m),!k.type&&k.role&&k.message?.content){let c=new Date(j+a),d=c.toISOString(),f=k.message.content.filter(a=>a?.type==="text"&&"string"==typeof a.text).map(a=>a.text).join("");if("user"===k.role){let a=/<user_query>\s*([\s\S]*?)\s*<\/user_query>/.exec(f),g=a?a[1]:f;g&&e.push({type:"user",...q(m,d,c,b),message:{role:"user",content:g}});continue}if("assistant"===k.role){let a=f?[{type:"text",text:f}]:[];0===a.length?e.push({type:"system",...q(m,d,c,b),raw:m}):e.push({type:"assistant",...q(m,d,c,b),message:{role:"assistant",content:a}});continue}e.push({type:"system",...q(m,d,c,b),raw:m});continue}let n=k.timestamp;if(!n)continue;let r=new Date(n);if(Number.isNaN(r.getTime()))continue;let s=r.toISOString(),t=k.type,u=k.data??{};if("session.start"===t||"sessionStart"===t||"session_start"===t){let a=u.context??u,d=a.cwd;"string"!=typeof d||c||(c=d),!c&&Array.isArray(a.workspace_roots)&&"string"==typeof a.workspace_roots[0]&&(c=a.workspace_roots[0]);let f=i?"Session Resumed":"Session Started";i=!0,e.push({type:"queue-operation",...q(m,s,r,b),label:f});continue}if("user.message"===t||"userMessage"===t){let a="string"==typeof u.content?u.content:"string"==typeof u.text?u.text:"";if(!a)continue;e.push({type:"user",...q(m,s,r,b),message:{role:"user",content:a}});continue}if("system.message"===t||"systemMessage"===t){e.push({type:"system",...q(m,s,r,b),raw:m});continue}if("assistant.message"===t||"assistantMessage"===t){let a="string"==typeof u.content?u.content:"string"==typeof u.text?u.text:"";if(!a){e.push({type:"system",...q(m,s,r,b),raw:m});continue}let c=[{type:"text",text:a}];e.push({type:"assistant",...q(m,s,r,b),message:{role:"assistant",content:c}});continue}if("tool.execution_start"===t||"tool.executionStart"===t||"preToolUse"===t){let a=u.toolCallId??u.tool_use_id,c=u.toolName??u.tool_name??"tool",d=u.arguments??u.tool_input??{},f={type:"tool_use",id:a??`${r.getTime()}-${c}`,name:c,input:d},i={type:"assistant",...q(m,s,r,b),message:{role:"assistant",content:[f]}};e.push(i),a&&(g.set(a,f),h.set(a,r.getTime()));continue}if("tool.execution_complete"===t||"tool.executionComplete"===t||"postToolUse"===t){let a=u.toolCallId??u.tool_use_id,c=a?g.get(a):void 0;if(c){let b=h.get(a)??r.getTime(),d=u.result??{},e=u.duration,f="number"==typeof e&&e>=0?e:Math.max(0,r.getTime()-b),g=d.detailedContent??d.content??u.tool_output??"";c.result={timestamp:s,timestampFormatted:p(r),content:"string"==typeof g?g:JSON.stringify(g),durationMs:f,durationFormatted:o(f)};continue}e.push({type:"system",...q(m,s,r,b),raw:m});continue}e.push({type:"system",...q(m,s,r,b),raw:m})}return e.length>500&&await new Promise(a=>setImmediate(a)),e.sort((a,b)=>a.timestampMs-b.timestampMs),{entries:e,rawLines:f,cwd:c}}async function O(a){let b,c=function(a){let b=function(a){if(!a)return null;let b=(0,w.resolve)(process.env.CURSOR_HOME||(0,w.join)((0,x.homedir)(),".cursor")),c=(0,w.resolve)(b,"projects"),d=[];try{d=(0,u.readdirSync)(c,{withFileTypes:!0})}catch{}for(let b of d){if(!b.isDirectory())continue;let d=(0,w.resolve)(c,b.name,M,a),e=(0,w.resolve)(c,b.name,M);if(d!==e&&d.startsWith(`${e}${w.sep}`)&&(0,u.existsSync)(d))return d}for(let c of K){let d=(0,w.resolve)(b,c),e=(0,w.resolve)(d,a);if(e!==d&&e.startsWith(`${d}${w.sep}`)&&(0,u.existsSync)(e))return e}return null}(a);if(!b)return null;let c=(0,w.join)(b,`${(0,w.basename)(b)}.jsonl`);if((0,u.existsSync)(c))return c;for(let a of L){let c=(0,w.join)(b,a);if((0,u.existsSync)(c))return c}return null}(a);if(!c)return null;try{b=await (0,v.readFile)(c,"utf-8")}catch{return null}let{entries:d,rawLines:e,cwd:f}=await N(b,"session");return{entries:d,rawLines:e,cwd:f,filePath:c}}let P=(0,l.runtimeCache)(a=>O(a),60,{maxSize:50});var Q=a.i(74533);function R(a){try{let b=(0,Q.execFileSync)("opencode",["db","--format","json",a],{encoding:"utf8",timeout:5e3,stdio:["ignore","pipe","pipe"]});if(!b.trim())return[];let c=JSON.parse(b);if(!Array.isArray(c))return null;return c}catch{return null}}function S(a){return!!a&&"object"==typeof a&&!Array.isArray(a)}function T(a){if("string"!=typeof a||0===a.length)return null;try{let b=JSON.parse(a);return S(b)?b:null}catch{return null}}async function U(a){if(!a||!/^[A-Za-z0-9_-]+$/.test(a))return null;let b=R(`SELECT id, project_id, slug, directory, title, time_created, time_updated FROM session WHERE id = '${a}'`);if(!b||0===b.length)return null;let c=b[0],d=R(`SELECT id, session_id, time_created, time_updated, data FROM message WHERE session_id = '${a}' ORDER BY time_created ASC`),e=R(`SELECT id, message_id, session_id, time_created, time_updated, data FROM part WHERE session_id = '${a}' ORDER BY time_created ASC`);if(!d)return{entries:[],rawLines:[],cwd:c.directory??void 0,filePath:`opencode://${a}`};let f=new Map;for(let a of e??[]){let b=f.get(a.message_id);b||(b=[],f.set(a.message_id,b)),b.push(a)}let g=[],h=[];for(let a of d){let b=f.get(a.id)??[];g.push(function(a,b,c){let d=T(a.data)??{},e="string"==typeof d.role?d.role:"system",f=new Date(a.time_created),g=f.toISOString(),h=q({uuid:a.id,parentUuid:null},g,f,c),i=[],j="";for(let a of b){let b=T(a.data);if(!b)continue;let c="string"==typeof b.type?b.type:"unknown";if("text"===c){let a="string"==typeof b.text?b.text:"string"==typeof b.content?b.content:"";a&&(i.push({type:"text",text:a}),j+=(j?"\n":"")+a);continue}if("tool"===c){let c="string"==typeof b.tool?b.tool:"string"==typeof b.name?b.name:"tool",d=S(b.state)?b.state:null,e=d&&S(d.input)?d.input:S(b.input)?b.input:S(b.args)?b.args:{},f={type:"tool_use",id:a.id,name:c,input:e},g=d&&"string"==typeof d.status?d.status:"";if(d&&("completed"===g||"error"===g)){let b=("error"===g&&"string"==typeof d.error?d.error:null)??d.output,c="string"==typeof b?b:null!=b?JSON.stringify(b):"",e=S(d.time)?d.time:{},h="number"==typeof e.start?e.start:a.time_created,i="number"==typeof e.end?e.end:a.time_updated,j=Math.max(0,i-h),k=new Date(i);f.result={timestamp:k.toISOString(),timestampFormatted:p(k),content:c,durationMs:j,durationFormatted:o(j)}}i.push(f);continue}i.push({type:"text",text:`[opencode ${c}]`})}if("user"===e)return{...h,type:"user",message:{role:"user",content:j}};if("assistant"===e){let a=S(d.model)?d.model:null,b=a&&"string"==typeof a.modelID?a.modelID:void 0;return{...h,type:"assistant",message:{role:"assistant",content:i,model:b}}}return{...h,type:"system",raw:{id:a.id,role:e,parts:i}}}(a,b,"session"));let c=T(a.data);h.push({id:a.id,session_id:a.session_id,time_created:a.time_created,data:c??a.data})}return{entries:g,rawLines:h,cwd:c.directory??void 0,filePath:`opencode://${a}`}}let V=(0,l.runtimeCache)(a=>U(a),30,{maxSize:50}),W=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,X=/^[\d-]+T[\d-]+Z_([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.jsonl$/i;async function Y(a,b="session"){let c,d=a.split("\n").filter(a=>""!==a.trim()),e=[],f=[],g=!1;for(let a=0;a<d.length;a++){let h;a>0&&a%200==0&&await new Promise(a=>setImmediate(a));let i=d[a];try{h=JSON.parse(i)}catch{continue}let j={...h,_source:b};f.push(j);let k=h.timestamp;if(!k)continue;let l=new Date(k);if(Number.isNaN(l.getTime()))continue;let m=l.toISOString(),n=h.type;if("session"===n){"string"!=typeof h.cwd||c||(c=h.cwd);let a=g?"Session Resumed":"Session Started";g=!0,e.push({type:"queue-operation",...q(j,m,l,b),label:a});continue}if("message"===n&&h.message&&"object"==typeof h.message){let a=h.message.role,c=h.message.content;if("user"===a){let a=function(a){if(!Array.isArray(a))return"";let b=[];for(let c of a)c?.type==="text"&&"string"==typeof c.text&&b.push(c.text);return b.join("\n\n")}(c);if(!a)continue;e.push({type:"user",...q(j,m,l,b),message:{role:"user",content:a}});continue}if("assistant"===a){let a=function(a){if(!Array.isArray(a))return[];let b=[];for(let c of a)c?.type==="text"&&"string"==typeof c.text&&c.text.length>0&&b.push({type:"text",text:c.text}),c?.type==="thinking"&&"string"==typeof c.thinking&&c.thinking.length>0&&b.push({type:"text",text:`[thinking] ${c.thinking}`});return b}(c);if(0===a.length){e.push({type:"system",...q(j,m,l,b),raw:j});continue}e.push({type:"assistant",...q(j,m,l,b),message:{role:"assistant",content:a}});continue}e.push({type:"system",...q(j,m,l,b),raw:j});continue}e.push({type:"system",...q(j,m,l,b),raw:j})}return e.length>500&&await new Promise(a=>setImmediate(a)),e.sort((a,b)=>a.timestampMs-b.timestampMs),{entries:e,rawLines:f,cwd:c}}async function Z(a){let b,c,d=function(a){let b;if(!W.test(a))return null;let c=(0,w.resolve)(process.env.PI_SESSIONS_DIR||(0,w.join)((0,x.homedir)(),".pi","agent","sessions"));try{b=(0,u.readdirSync)(c)}catch{return null}for(let d of b){let b,e=(0,w.resolve)(c,d);if(e.startsWith(`${c}${w.sep}`)){try{b=(0,u.readdirSync)(e)}catch{continue}for(let c of b){let b=X.exec(c);if(!b||b[1].toLowerCase()!==a.toLowerCase())continue;let d=(0,w.resolve)(e,c);if(d.startsWith(`${e}${w.sep}`)&&(0,u.existsSync)(d))return d}}}return null}(a);if(!d)return null;try{b=await (0,v.readFile)(d,"utf-8")}catch{return null}try{c=await Y(b,"session")}catch{return null}return{entries:c.entries,rawLines:c.rawLines,cwd:c.cwd,filePath:d}}let $=(0,l.runtimeCache)(a=>Z(a),60,{maxSize:50}),_=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,aa=/^session-(.+)-([0-9a-f]{8})\.jsonl$/i;async function ab(a,b="session",c){let d=a.split("\n").filter(a=>""!==a.trim()),e=[],f=[],g=!1;for(let a=0;a<d.length;a++){let c;a>0&&a%200==0&&await new Promise(a=>setImmediate(a));let h=d[a];try{c=JSON.parse(h)}catch{continue}let i={...c,_source:b};if(f.push(i),"string"==typeof c.sessionId&&"string"==typeof c.startTime){let a=new Date(c.startTime);if(!Number.isNaN(a.getTime())){let c=g?"Session Resumed":"Session Started";g=!0,e.push({type:"queue-operation",...q(i,a.toISOString(),a,b),label:c})}continue}if(c.$set)continue;let j=c.timestamp;if(!j)continue;let k=new Date(j);if(Number.isNaN(k.getTime()))continue;let l=k.toISOString(),m=c.type;if("user"===m){let a=function(a){if(!Array.isArray(a))return"";let b=[];for(let c of a)"string"==typeof c?.text&&b.push(c.text);return b.join("\n\n")}(c.content);if(!a)continue;e.push({type:"user",...q(i,l,k,b),message:{role:"user",content:a}});continue}if("assistant"===m||"model"===m){let a=function(a){if(!Array.isArray(a))return[];let b=[];for(let c of a)"string"==typeof c?.text&&c.text.length>0&&b.push({type:"text",text:c.text});return b}(c.content);if(0===a.length){e.push({type:"system",...q(i,l,k,b),raw:i});continue}e.push({type:"assistant",...q(i,l,k,b),message:{role:"assistant",content:a}});continue}e.push({type:"system",...q(i,l,k,b),raw:i})}return e.length>500&&await new Promise(a=>setImmediate(a)),e.sort((a,b)=>a.timestampMs-b.timestampMs),{entries:e,rawLines:f,cwd:c}}async function ac(a){let b,c,d=function(a){let b;if(!_.test(a))return null;let c=(0,w.resolve)(process.env.GEMINI_SESSIONS_DIR||(0,w.join)((0,x.homedir)(),".gemini","tmp")),d=a.slice(0,8).toLowerCase();try{b=(0,u.readdirSync)(c)}catch{return null}for(let e of b){let b,f=(0,w.resolve)(c,e);if(!f.startsWith(`${c}${w.sep}`))continue;let g=(0,w.resolve)(f,"chats");try{b=(0,u.readdirSync)(g)}catch{continue}for(let c of b){let b=aa.exec(c);if(!b||b[2].toLowerCase()!==d)continue;let e=(0,w.resolve)(g,c);if(!e.startsWith(`${g}${w.sep}`)||!(0,u.existsSync)(e))continue;let f=function(a){let b;try{b=(0,u.openSync)(a,"r")}catch{return null}try{let a=Buffer.alloc(4096),c=(0,u.readSync)(b,a,0,a.length,0);if(0===c)return null;let d=a.subarray(0,c).toString("utf-8"),e=d.indexOf("\n");return e>=0?d.slice(0,e):d}catch{return null}finally{try{(0,u.closeSync)(b)}catch{}}}(e);if(f)try{let b=JSON.parse(f);if("string"==typeof b.sessionId&&b.sessionId.toLowerCase()===a.toLowerCase())return e}catch{continue}}}return null}(a);if(!d)return null;try{b=await (0,v.readFile)(d,"utf-8")}catch{return null}let e=function(a){let b=(0,w.resolve)(a,".."),c=(0,w.resolve)(b,".."),d=(0,w.join)(c,".project_root");try{let a=(0,u.readFileSync)(d,"utf-8").trim();return a.length>0?a:void 0}catch{return}}(d);try{c=await ab(b,"session",e)}catch{return null}return{entries:c.entries,rawLines:c.rawLines,cwd:c.cwd,filePath:d}}let ad=(0,l.runtimeCache)(a=>ac(a),60,{maxSize:50});var ae=a.i(71130),af=a.i(893);let ag={claude:{id:"claude",label:"Claude Code",badgeClasses:"bg-orange-500/10 text-orange-400 border-orange-500/20"},codex:{id:"codex",label:"OpenAI Codex",badgeClasses:"bg-purple-500/10 text-purple-400 border-purple-500/20"},copilot:{id:"copilot",label:"GitHub Copilot",badgeClasses:"bg-blue-500/10 text-blue-400 border-blue-500/20"},cursor:{id:"cursor",label:"Cursor Agent",badgeClasses:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20"},opencode:{id:"opencode",label:"OpenCode",badgeClasses:"bg-amber-500/10 text-amber-400 border-amber-500/20"},pi:{id:"pi",label:"Pi",badgeClasses:"bg-pink-500/10 text-pink-400 border-pink-500/20"},gemini:{id:"gemini",label:"Gemini CLI",badgeClasses:"bg-sky-500/10 text-sky-400 border-sky-500/20"}};function ah({cli:a}){var c,d;let e=(c=a,ag[c]?.label??c),f=(d=a,ag[d]?.badgeClasses??ag.claude.badgeClasses);return(0,b.jsx)("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-mono font-medium uppercase tracking-wider border ${f}`,title:`Agent CLI: ${e}`,children:e})}async function ai({params:a}){let g,h,{name:k,sessionId:l}=await a;try{(0,j.resolveProjectPath)(k)}catch{(0,f.notFound)()}let m=(0,i.decodeFolderName)(k),n=-1===(h=l.indexOf("/"))?l:l.slice(0,h);j.UUID_RE.test(n)||/^ses_[A-Za-z0-9]+$/.test(n)||(0,f.notFound)();let o=null,p=null,q=null,r="claude";try{let a=await t(k,n);o=a.entries,p=a.rawLines}catch(a){if("ENOENT"===a.code){let a=await F(n);if(a)o=a.entries,p=a.rawLines,g=a.cwd,r="codex";else{let a=await J(n);if(a)o=a.entries,p=a.rawLines,g=a.cwd,r="copilot";else{let a=await P(n);if(a)o=a.entries,p=a.rawLines,g=a.cwd,r="cursor";else{let a=await V(n);if(a)o=a.entries,p=a.rawLines,g=a.cwd,r="opencode";else{let a=await $(n);if(a)o=a.entries,p=a.rawLines,g=a.cwd,r="pi";else{let a=await ad(n);a?(o=a.entries,p=a.rawLines,g=a.cwd,r="gemini"):q="Session log file not found."}}}}}}else q="Failed to read session log."}let s="claude"!==r,u="codex"===r?`OpenAI Codex${g?` \xb7 ${g}`:""}`:"copilot"===r?`GitHub Copilot${g?` \xb7 ${g}`:""}`:"cursor"===r?`Cursor Agent${g?` \xb7 ${g}`:""}`:"opencode"===r?`OpenCode${g?` \xb7 ${g}`:""}`:"pi"===r?`Pi${g?` \xb7 ${g}`:""}`:"gemini"===r?`Gemini CLI${g?` \xb7 ${g}`:""}`:m;return(0,b.jsx)("main",{className:"min-h-screen bg-background",children:(0,b.jsxs)("div",{className:"container mx-auto p-8",children:[(0,b.jsxs)(c.default,{href:s?"/policies?tab=activity":`/project/${encodeURIComponent(k)}`,className:"inline-flex items-center gap-2 text-muted-foreground hover:text-foreground mb-6 transition-colors",children:[(0,b.jsx)(d.ArrowLeft,{className:"w-4 h-4"}),(0,b.jsx)("span",{children:s?"Back to Activity":"Back to Sessions"})]}),(0,b.jsxs)("div",{className:"mb-8",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-3 mb-2",children:[(0,b.jsx)("h1",{className:"text-4xl font-bold text-foreground",children:"Session Log"}),(0,b.jsx)(ah,{cli:r})]}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsxs)("p",{className:"text-muted-foreground",children:[(0,b.jsxs)("span",{className:"font-medium",children:[s?"CLI":"Project",":"]})," ",u]}),(0,b.jsxs)("p",{className:"text-muted-foreground break-words break-all inline-flex items-center gap-1",children:[(0,b.jsx)("span",{className:"font-medium",children:"Session:"})," ",n,(0,b.jsx)(af.CopyButton,{text:n})]}),o&&p&&(0,b.jsxs)("div",{className:"flex items-center gap-4",children:[(0,b.jsxs)("p",{className:"text-muted-foreground",children:[(0,b.jsx)("span",{className:"font-medium",children:p.length})," log lines"]}),(0,b.jsxs)("a",{href:`/api/download/${encodeURIComponent(k)}/${encodeURIComponent(n)}?cli=${r}`,download:!0,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground transition-colors",children:[(0,b.jsx)(e,{className:"w-4 h-4"}),"Download Logs"]})]})]})]}),q&&(0,b.jsx)("div",{className:"bg-card text-card-foreground rounded-lg border border-destructive/50 p-6 shadow-sm",children:(0,b.jsx)("p",{className:"text-destructive text-center py-8",children:q})}),!q&&o&&(0,b.jsx)(ae.default,{entries:o,projectName:s?g??("codex"===r?"OpenAI Codex":"copilot"===r?"GitHub Copilot":"cursor"===r?"Cursor Agent":"opencode"===r?"OpenCode":"pi"===r?"Pi":"Gemini CLI"):m,sessionId:n})]})})}a.s(["default",0,ai,"dynamic",0,"force-dynamic"],41190)},87330,a=>{a.n(a.i(41190))}];
|
|
1
|
+
module.exports=[14066,a=>{"use strict";a.s(["default",()=>b]);let b=(0,a.i(11857).registerClientReference)(function(){throw Error("Attempted to call the default export of [project]/app/components/lazy-log-viewer.tsx <module evaluation> from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/app/components/lazy-log-viewer.tsx <module evaluation>","default")},19597,a=>{"use strict";a.s(["default",()=>b]);let b=(0,a.i(11857).registerClientReference)(function(){throw Error("Attempted to call the default export of [project]/app/components/lazy-log-viewer.tsx from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/app/components/lazy-log-viewer.tsx","default")},71130,a=>{"use strict";a.i(14066);var b=a.i(19597);a.n(b)},85540,a=>{"use strict";a.s(["CopyButton",()=>b]);let b=(0,a.i(11857).registerClientReference)(function(){throw Error("Attempted to call CopyButton() from the server but CopyButton is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/app/components/copy-button.tsx <module evaluation>","CopyButton")},35770,a=>{"use strict";a.s(["CopyButton",()=>b]);let b=(0,a.i(11857).registerClientReference)(function(){throw Error("Attempted to call CopyButton() from the server but CopyButton is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/app/components/copy-button.tsx","CopyButton")},893,a=>{"use strict";a.i(85540);var b=a.i(35770);a.n(b)},41190,a=>{"use strict";var b=a.i(7997),c=a.i(95936),d=a.i(84930);let e=(0,a.i(92277).default)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);a.i(70396);var f=a.i(73727),g=a.i(24868),h=a.i(14747),i=a.i(90798),j=a.i(69191);async function k(a,b,c,d){let e=`agent-${d}.jsonl`;for(let d of[(0,h.join)(a,b,e),(0,h.join)(a,b,c,e),(0,h.join)(a,b,c,"subagents",e)])if(!(0,h.relative)(a,d).startsWith(".."))try{return await (0,g.access)(d),d}catch(a){if("ENOENT"===a.code)continue;break}return null}var l=a.i(34900),m=a.i(26192),n=a.i(33432);function o(a){if(a<1e3)return`${a}ms`;let b=a/1e3;if(b<60)return`${b.toFixed(1)}s`;let c=Math.floor(b/60);if(c>=60){let a=Math.floor(c/60);return`${a}h ${c%60}m`}let d=(b%60).toFixed(0);return`${c}m ${d}s`}function p(a){let b=(0,n.formatDate)(a),c=a.getMilliseconds().toString().padStart(3,"0");return`${b}.${c}`}function q(a,b,c,d){return{_source:d,uuid:a.uuid||"",parentUuid:a.parentUuid??null,timestamp:b,timestampMs:c.getTime(),timestampFormatted:p(c)}}async function r(a,b){let c=a.split("\n").filter(a=>""!==a.trim()),d=new Map,e=[],f=[],g=new Set,h=!1;for(let a=0;a<c.length;a++){let i;a>0&&a%200==0&&await new Promise(a=>setImmediate(a));let j=c[a];try{i=JSON.parse(j)}catch{continue}let k={...i,_source:b};f.push(k);let l=i.type,m=i.timestamp;if(!m)continue;let n=new Date(m),o=n.getTime();if("user"===l){let a=i.message;if(Array.isArray(a?.content)){let b=a.content;if(b.some(a=>"tool_result"===a.type)){let a=i.toolUseResult,c="string"==typeof a?.agentId?a.agentId:void 0;for(let a of(c&&/^[a-f0-9]+$/.test(c)&&g.add(c),b)){if("tool_result"!==a.type)continue;let b=a.tool_use_id;if(!b)continue;let{text:e,images:f}=function(a){let b=a.content;if("string"==typeof b)return{text:b};if(Array.isArray(b)){let a=b.filter(a=>"text"===a.type).map(a=>a.text),c=b.filter(a=>"image"===a.type).map(a=>{let b=a.source;return{base64:b.data,mediaType:b.media_type}}).filter(a=>a.base64&&a.mediaType);return{text:a.length>0?a.join("\n"):void 0,images:c.length>0?c:void 0}}return{}}(a);d.set(b,{timestamp:m,timestampMs:o,content:e,images:f,agentId:c})}continue}}let c="string"==typeof a?.content?a.content:"";e.push({type:"user",...q(i,m,n,b),message:{role:"user",content:c}});continue}if("assistant"===l){let a=i.message,c=[];if(Array.isArray(a?.content)&&(c=a.content.filter(a=>["text","tool_use","thinking"].includes(a.type)).map(a=>{if("text"===a.type)return{type:"text",text:a.text};if("tool_use"===a.type){let b=a.input;return{type:"tool_use",id:a.id,name:a.name,input:a.input??{},..."Task"===a.name&&b?{subagentType:b.subagent_type,subagentDescription:b.description}:{}}}return{type:"thinking",thinking:a.thinking,signature:a.signature}})),0===c.length)continue;e.push({type:"assistant",...q(i,m,n,b),message:{role:"assistant",content:c,model:a?.model}});continue}if("file-history-snapshot"===l||"progress"===l||"system"===l){e.push({type:l,...q(i,m,n,b),raw:{...i}});continue}if("queue-operation"===l){let a=h?"Session Resumed":"Session Started";h=!0,e.push({type:"queue-operation",...q(i,m,n,b),label:a});continue}}let i=0;for(let a of e)if("assistant"===a.type)for(let b of(++i%200==0&&await new Promise(a=>setImmediate(a)),a.message.content)){if("tool_use"!==b.type)continue;let c=d.get(b.id);if(!c)continue;let e=new Date(c.timestamp),f=Math.max(0,c.timestampMs-a.timestampMs);b.result={timestamp:c.timestamp,timestampFormatted:p(e),content:c.content,images:c.images,durationMs:f,durationFormatted:o(f)},c.agentId&&(b.subagentId=c.agentId)}return e.length>500&&await new Promise(a=>setImmediate(a)),e.sort((a,b)=>a.timestampMs-b.timestampMs),{entries:e,rawLines:f,subagentIds:Array.from(g)}}async function s(a,b){let c=(0,j.resolveProjectPath)(a),d=(0,i.getClaudeProjectsPath)(),e=(0,h.join)(c,`${b}.jsonl`),f=await (0,g.readFile)(e,"utf-8"),{entries:l,rawLines:n,subagentIds:o}=await r(f,"session");if(0===o.length)return{entries:l,rawLines:n,subagentIds:[]};let p=await (0,m.batchAll)(o.map(c=>async()=>{let e=`agent-${c}`,f=await k(d,a,b,c);if(!f)return null;let h=await (0,g.readFile)(f,"utf-8"),{entries:i,rawLines:j}=await r(h,e);return{entries:i,rawLines:j}}),4),q=[...l],s=[...n];for(let a of p)"fulfilled"===a.status&&a.value&&(q.push(...a.value.entries),s.push(...a.value.rawLines));return q.length>500&&await new Promise(a=>setImmediate(a)),q.sort((a,b)=>a.timestampMs-b.timestampMs),{entries:q,rawLines:s,subagentIds:o}}let t=(0,l.runtimeCache)((a,b)=>s(a,b),60,{maxSize:50});var u=a.i(2157),v=a.i(12714),w=a.i(50227),x=a.i(60526);let y=(0,w.join)((0,x.homedir)(),".failproofai","cache","codex-session-paths.json");function z(){try{if(!(0,u.existsSync)(y))return{};return JSON.parse((0,u.readFileSync)(y,"utf-8"))}catch{return{}}}function A(a,b){try{(0,u.mkdirSync)((0,w.dirname)(y),{recursive:!0});let c=z();c[a]=b,(0,u.writeFileSync)(y,JSON.stringify(c),"utf-8")}catch{}}function B(a,b){try{for(let c of(0,u.readdirSync)(a,{withFileTypes:!0}))if(c.isFile()&&c.name.includes(b)&&c.name.endsWith(".jsonl"))return(0,w.join)(a,c.name)}catch{}return null}function C(a,b){return Array.isArray(a)?a.filter(a=>a?.type===b&&"string"==typeof a.text).map(a=>a.text).join("\n"):""}async function D(a,b="session"){let c,d=a.split("\n").filter(a=>""!==a.trim()),e=[],f=[],g=new Map,h=new Map,i=!1;for(let a=0;a<d.length;a++){let j;a>0&&a%200==0&&await new Promise(a=>setImmediate(a));let k=d[a];try{j=JSON.parse(k)}catch{continue}let l={...j,_source:b};f.push(l);let m=j.timestamp;if(!m)continue;let n=new Date(m);if(Number.isNaN(n.getTime()))continue;let r=j.type,s=j.payload??{};if("session_meta"===r){let a=s.cwd;"string"!=typeof a||c||(c=a),e.push({type:"system",...q(l,m,n,b),raw:l});continue}if("response_item"===r){let a=s.type;if("message"===a){let a=s.role,c=s.content;if("user"===a||"developer"===a){let d=C(c,"input_text");if(!d)continue;let f="developer"===a?`[developer] ${d}`:d;e.push({type:"user",...q(l,m,n,b),message:{role:"user",content:f}});continue}if("assistant"===a){let a=C(c,"output_text");if(!a)continue;let d=[{type:"text",text:a}];e.push({type:"assistant",...q(l,m,n,b),message:{role:"assistant",content:d}});continue}e.push({type:"system",...q(l,m,n,b),raw:l});continue}if("function_call"===a){let a=s.call_id,c=s.name??"function_call",d={type:"tool_use",id:a??`${m}-${c}`,name:c,input:function(a){if(!a)return{};try{return JSON.parse(a)}catch{return{}}}(s.arguments)},f={type:"assistant",...q(l,m,n,b),message:{role:"assistant",content:[d]}};e.push(f),a&&(g.set(a,d),h.set(a,n.getTime()));continue}if("function_call_output"===a){let a=s.call_id,c=a?g.get(a):void 0;if(c){let b=h.get(a)??n.getTime(),d=Math.max(0,n.getTime()-b);c.result={timestamp:m,timestampFormatted:p(n),content:"string"==typeof s.output?s.output:JSON.stringify(s.output),durationMs:d,durationFormatted:o(d)};continue}e.push({type:"system",...q(l,m,n,b),raw:l});continue}e.push({type:"system",...q(l,m,n,b),raw:l});continue}if("event_msg"===r){let a=s.type;if("task_started"===a){let a=i?"Session Resumed":"Session Started";i=!0,e.push({type:"queue-operation",...q(l,m,n,b),label:a});continue}if("exec_command_end"===a){let a=s.call_id,c=a?g.get(a):void 0;if(c){let b=s.duration,d=b?(b.secs??0)*1e3+Math.round((b.nanos??0)/1e6):Math.max(0,n.getTime()-(h.get(a)??n.getTime())),e=s.aggregated_output;c.result={timestamp:m,timestampFormatted:p(n),content:"string"==typeof e?e:JSON.stringify(e),durationMs:d,durationFormatted:o(d)};continue}e.push({type:"system",...q(l,m,n,b),raw:l});continue}if("user_message"===a||"agent_message"===a)continue;e.push({type:"system",...q(l,m,n,b),raw:l});continue}e.push({type:"system",...q(l,m,n,b),raw:l})}return e.length>500&&await new Promise(a=>setImmediate(a)),e.sort((a,b)=>a.timestampMs-b.timestampMs),{entries:e,rawLines:f,cwd:c}}async function E(a){let b=function(a){let b=z()[a];if(b&&(0,u.existsSync)(b))return b;let c=(0,w.join)((0,x.homedir)(),".codex","sessions"),d=new Date,e=new Date(d.getTime()-864e5);for(let b of[d,e].map(a=>{let b=String(a.getUTCFullYear()),d=String(a.getUTCMonth()+1).padStart(2,"0"),e=String(a.getUTCDate()).padStart(2,"0");return(0,w.join)(c,b,d,e)})){let c=B(b,a);if(c)return A(a,c),c}try{for(let b of(0,u.readdirSync)(c,{withFileTypes:!0}))if(b.isDirectory()){for(let d of(0,u.readdirSync)((0,w.join)(c,b.name),{withFileTypes:!0}))if(d.isDirectory())for(let e of(0,u.readdirSync)((0,w.join)(c,b.name,d.name),{withFileTypes:!0})){if(!e.isDirectory())continue;let f=B((0,w.join)(c,b.name,d.name,e.name),a);if(f)return A(a,f),f}}}catch{}return null}(a);if(!b)return null;let c=await (0,v.readFile)(b,"utf-8"),{entries:d,rawLines:e,cwd:f}=await D(c,"session");return{entries:d,rawLines:e,cwd:f,filePath:b}}let F=(0,l.runtimeCache)(a=>E(a),60,{maxSize:50});function G(a,b){let c=function(a){if(!a)return null;let b=(0,w.resolve)((0,w.join)(process.env.COPILOT_HOME||(0,w.join)((0,x.homedir)(),".copilot"),"session-state")),c=(0,w.resolve)(b,a);return c!==b&&c.startsWith(`${b}${w.sep}`)?c:null}(a);return c?(0,w.join)(c,b):null}async function H(a,b="session"){let c,d=a.split("\n").filter(a=>""!==a.trim()),e=[],f=[],g=new Map,h=new Map,i=!1;for(let a=0;a<d.length;a++){let j;a>0&&a%200==0&&await new Promise(a=>setImmediate(a));let k=d[a];try{j=JSON.parse(k)}catch{continue}let l={...j,_source:b};f.push(l);let m=j.timestamp;if(!m)continue;let n=new Date(m);if(Number.isNaN(n.getTime()))continue;let r=n.toISOString(),s=j.type,t=j.data??{};if("session.start"===s){let a=t.context,d=a?.cwd;"string"!=typeof d||c||(c=d);let f=i?"Session Resumed":"Session Started";i=!0,e.push({type:"queue-operation",...q(l,r,n,b),label:f});continue}if("user.message"===s){let a=t.content??"";if(!a)continue;e.push({type:"user",...q(l,r,n,b),message:{role:"user",content:a}});continue}if("system.message"===s){e.push({type:"system",...q(l,r,n,b),raw:l});continue}if("assistant.message"===s){let a=t.content??"";if(!a){e.push({type:"system",...q(l,r,n,b),raw:l});continue}let c=[{type:"text",text:a}];e.push({type:"assistant",...q(l,r,n,b),message:{role:"assistant",content:c}});continue}if("tool.execution_start"===s){let a=t.toolCallId,c=t.toolName??"tool",d=t.arguments??{},f={type:"tool_use",id:a??`${n.getTime()}-${c}`,name:c,input:d},i={type:"assistant",...q(l,r,n,b),message:{role:"assistant",content:[f]}};e.push(i),a&&(g.set(a,f),h.set(a,n.getTime()));continue}if("tool.execution_complete"===s){let a=t.toolCallId,c=a?g.get(a):void 0;if(c){let b=h.get(a)??n.getTime(),d=t.result??{},e=t.toolTelemetry??{},f=e.metrics?.commandTimeMs??e.metrics?.durationMs??null,g="number"==typeof f&&f>=0?f:Math.max(0,n.getTime()-b),i=d.detailedContent??d.content??"";c.result={timestamp:r,timestampFormatted:p(n),content:"string"==typeof i?i:JSON.stringify(i),durationMs:g,durationFormatted:o(g)};continue}e.push({type:"system",...q(l,r,n,b),raw:l});continue}e.push({type:"system",...q(l,r,n,b),raw:l})}return e.length>500&&await new Promise(a=>setImmediate(a)),e.sort((a,b)=>a.timestampMs-b.timestampMs),{entries:e,rawLines:f,cwd:c}}async function I(a){let b,c,d=(c=G(a,"events.jsonl"))&&(0,u.existsSync)(c)?c:null;if(!d)return null;try{b=await (0,v.readFile)(d,"utf-8")}catch{return null}let{entries:e,rawLines:f,cwd:g}=await H(b,"session");return{entries:e,rawLines:f,cwd:g??function(a){let b,c=(b=G(a,"workspace.yaml"))&&(0,u.existsSync)(b)?b:null;if(c)try{let a=(0,u.readFileSync)(c,"utf-8"),b=RegExp("^cwd\\s*:\\s*(.+?)\\s*$","m"),d=a.match(b);if(!d)return;return d[1].replace(/^['"]|['"]$/g,"")}catch{return}}(a),filePath:d}}let J=(0,l.runtimeCache)(a=>I(a),60,{maxSize:50}),K=["agent-sessions","conversations","sessions"],L=["events.jsonl","transcript.jsonl","messages.jsonl"],M="agent-transcripts";async function N(a,b="session"){let c,d=a.split("\n").filter(a=>""!==a.trim()),e=[],f=[],g=new Map,h=new Map,i=!1,j=Date.now();for(let a=0;a<d.length;a++){let k;a>0&&a%200==0&&await new Promise(a=>setImmediate(a));let l=d[a];try{k=JSON.parse(l)}catch{continue}let m={...k,_source:b};if(f.push(m),!k.type&&k.role&&k.message?.content){let c=new Date(j+a),d=c.toISOString(),f=k.message.content.filter(a=>a?.type==="text"&&"string"==typeof a.text).map(a=>a.text).join("");if("user"===k.role){let a=/<user_query>\s*([\s\S]*?)\s*<\/user_query>/.exec(f),g=a?a[1]:f;g&&e.push({type:"user",...q(m,d,c,b),message:{role:"user",content:g}});continue}if("assistant"===k.role){let a=f?[{type:"text",text:f}]:[];0===a.length?e.push({type:"system",...q(m,d,c,b),raw:m}):e.push({type:"assistant",...q(m,d,c,b),message:{role:"assistant",content:a}});continue}e.push({type:"system",...q(m,d,c,b),raw:m});continue}let n=k.timestamp;if(!n)continue;let r=new Date(n);if(Number.isNaN(r.getTime()))continue;let s=r.toISOString(),t=k.type,u=k.data??{};if("session.start"===t||"sessionStart"===t||"session_start"===t){let a=u.context??u,d=a.cwd;"string"!=typeof d||c||(c=d),!c&&Array.isArray(a.workspace_roots)&&"string"==typeof a.workspace_roots[0]&&(c=a.workspace_roots[0]);let f=i?"Session Resumed":"Session Started";i=!0,e.push({type:"queue-operation",...q(m,s,r,b),label:f});continue}if("user.message"===t||"userMessage"===t){let a="string"==typeof u.content?u.content:"string"==typeof u.text?u.text:"";if(!a)continue;e.push({type:"user",...q(m,s,r,b),message:{role:"user",content:a}});continue}if("system.message"===t||"systemMessage"===t){e.push({type:"system",...q(m,s,r,b),raw:m});continue}if("assistant.message"===t||"assistantMessage"===t){let a="string"==typeof u.content?u.content:"string"==typeof u.text?u.text:"";if(!a){e.push({type:"system",...q(m,s,r,b),raw:m});continue}let c=[{type:"text",text:a}];e.push({type:"assistant",...q(m,s,r,b),message:{role:"assistant",content:c}});continue}if("tool.execution_start"===t||"tool.executionStart"===t||"preToolUse"===t){let a=u.toolCallId??u.tool_use_id,c=u.toolName??u.tool_name??"tool",d=u.arguments??u.tool_input??{},f={type:"tool_use",id:a??`${r.getTime()}-${c}`,name:c,input:d},i={type:"assistant",...q(m,s,r,b),message:{role:"assistant",content:[f]}};e.push(i),a&&(g.set(a,f),h.set(a,r.getTime()));continue}if("tool.execution_complete"===t||"tool.executionComplete"===t||"postToolUse"===t){let a=u.toolCallId??u.tool_use_id,c=a?g.get(a):void 0;if(c){let b=h.get(a)??r.getTime(),d=u.result??{},e=u.duration,f="number"==typeof e&&e>=0?e:Math.max(0,r.getTime()-b),g=d.detailedContent??d.content??u.tool_output??"";c.result={timestamp:s,timestampFormatted:p(r),content:"string"==typeof g?g:JSON.stringify(g),durationMs:f,durationFormatted:o(f)};continue}e.push({type:"system",...q(m,s,r,b),raw:m});continue}e.push({type:"system",...q(m,s,r,b),raw:m})}return e.length>500&&await new Promise(a=>setImmediate(a)),e.sort((a,b)=>a.timestampMs-b.timestampMs),{entries:e,rawLines:f,cwd:c}}async function O(a){let b,c=function(a){let b=function(a){if(!a)return null;let b=(0,w.resolve)(process.env.CURSOR_HOME||(0,w.join)((0,x.homedir)(),".cursor")),c=(0,w.resolve)(b,"projects"),d=[];try{d=(0,u.readdirSync)(c,{withFileTypes:!0})}catch{}for(let b of d){if(!b.isDirectory())continue;let d=(0,w.resolve)(c,b.name,M,a),e=(0,w.resolve)(c,b.name,M);if(d!==e&&d.startsWith(`${e}${w.sep}`)&&(0,u.existsSync)(d))return d}for(let c of K){let d=(0,w.resolve)(b,c),e=(0,w.resolve)(d,a);if(e!==d&&e.startsWith(`${d}${w.sep}`)&&(0,u.existsSync)(e))return e}return null}(a);if(!b)return null;let c=(0,w.join)(b,`${(0,w.basename)(b)}.jsonl`);if((0,u.existsSync)(c))return c;for(let a of L){let c=(0,w.join)(b,a);if((0,u.existsSync)(c))return c}return null}(a);if(!c)return null;try{b=await (0,v.readFile)(c,"utf-8")}catch{return null}let{entries:d,rawLines:e,cwd:f}=await N(b,"session");return{entries:d,rawLines:e,cwd:f,filePath:c}}let P=(0,l.runtimeCache)(a=>O(a),60,{maxSize:50});var Q=a.i(74533);function R(a){try{let b=(0,Q.execFileSync)("opencode",["db","--format","json",a],{encoding:"utf8",timeout:5e3,stdio:["ignore","pipe","pipe"]});if(!b.trim())return[];let c=JSON.parse(b);if(!Array.isArray(c))return null;return c}catch{return null}}function S(a){return!!a&&"object"==typeof a&&!Array.isArray(a)}function T(a){if("string"!=typeof a||0===a.length)return null;try{let b=JSON.parse(a);return S(b)?b:null}catch{return null}}async function U(a){if(!a||!/^[A-Za-z0-9_-]+$/.test(a))return null;let b=R(`SELECT id, project_id, slug, directory, title, time_created, time_updated FROM session WHERE id = '${a}'`);if(!b||0===b.length)return null;let c=b[0],d=R(`SELECT id, session_id, time_created, time_updated, data FROM message WHERE session_id = '${a}' ORDER BY time_created ASC`),e=R(`SELECT id, message_id, session_id, time_created, time_updated, data FROM part WHERE session_id = '${a}' ORDER BY time_created ASC`);if(!d)return{entries:[],rawLines:[],cwd:c.directory??void 0,filePath:`opencode://${a}`};let f=new Map;for(let a of e??[]){let b=f.get(a.message_id);b||(b=[],f.set(a.message_id,b)),b.push(a)}let g=[],h=[];for(let a of d){let b=f.get(a.id)??[];g.push(function(a,b,c){let d=T(a.data)??{},e="string"==typeof d.role?d.role:"system",f=new Date(a.time_created),g=f.toISOString(),h=q({uuid:a.id,parentUuid:null},g,f,c),i=[],j="";for(let a of b){let b=T(a.data);if(!b)continue;let c="string"==typeof b.type?b.type:"unknown";if("text"===c){let a="string"==typeof b.text?b.text:"string"==typeof b.content?b.content:"";a&&(i.push({type:"text",text:a}),j+=(j?"\n":"")+a);continue}if("tool"===c){let c="string"==typeof b.tool?b.tool:"string"==typeof b.name?b.name:"tool",d=S(b.state)?b.state:null,e=d&&S(d.input)?d.input:S(b.input)?b.input:S(b.args)?b.args:{},f={type:"tool_use",id:a.id,name:c,input:e},g=d&&"string"==typeof d.status?d.status:"";if(d&&("completed"===g||"error"===g)){let b=("error"===g&&"string"==typeof d.error?d.error:null)??d.output,c="string"==typeof b?b:null!=b?JSON.stringify(b):"",e=S(d.time)?d.time:{},h="number"==typeof e.start?e.start:a.time_created,i="number"==typeof e.end?e.end:a.time_updated,j=Math.max(0,i-h),k=new Date(i);f.result={timestamp:k.toISOString(),timestampFormatted:p(k),content:c,durationMs:j,durationFormatted:o(j)}}i.push(f);continue}i.push({type:"text",text:`[opencode ${c}]`})}if("user"===e)return{...h,type:"user",message:{role:"user",content:j}};if("assistant"===e){let a=S(d.model)?d.model:null,b=a&&"string"==typeof a.modelID?a.modelID:void 0;return{...h,type:"assistant",message:{role:"assistant",content:i,model:b}}}return{...h,type:"system",raw:{id:a.id,role:e,parts:i}}}(a,b,"session"));let c=T(a.data);h.push({id:a.id,session_id:a.session_id,time_created:a.time_created,data:c??a.data})}return{entries:g,rawLines:h,cwd:c.directory??void 0,filePath:`opencode://${a}`}}let V=(0,l.runtimeCache)(a=>U(a),30,{maxSize:50}),W=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,X=/^[\d-]+T[\d-]+Z_([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.jsonl$/i;async function Y(a,b="session"){let c,d=a.split("\n").filter(a=>""!==a.trim()),e=[],f=[],g=!1;for(let a=0;a<d.length;a++){let h;a>0&&a%200==0&&await new Promise(a=>setImmediate(a));let i=d[a];try{h=JSON.parse(i)}catch{continue}let j={...h,_source:b};f.push(j);let k=h.timestamp;if(!k)continue;let l=new Date(k);if(Number.isNaN(l.getTime()))continue;let m=l.toISOString(),n=h.type;if("session"===n){"string"!=typeof h.cwd||c||(c=h.cwd);let a=g?"Session Resumed":"Session Started";g=!0,e.push({type:"queue-operation",...q(j,m,l,b),label:a});continue}if("message"===n&&h.message&&"object"==typeof h.message){let a=h.message.role,c=h.message.content;if("user"===a){let a=function(a){if(!Array.isArray(a))return"";let b=[];for(let c of a)c?.type==="text"&&"string"==typeof c.text&&b.push(c.text);return b.join("\n\n")}(c);if(!a)continue;e.push({type:"user",...q(j,m,l,b),message:{role:"user",content:a}});continue}if("assistant"===a){let a=function(a){if(!Array.isArray(a))return[];let b=[];for(let c of a)c?.type==="text"&&"string"==typeof c.text&&c.text.length>0&&b.push({type:"text",text:c.text}),c?.type==="thinking"&&"string"==typeof c.thinking&&c.thinking.length>0&&b.push({type:"text",text:`[thinking] ${c.thinking}`});return b}(c);if(0===a.length){e.push({type:"system",...q(j,m,l,b),raw:j});continue}e.push({type:"assistant",...q(j,m,l,b),message:{role:"assistant",content:a}});continue}e.push({type:"system",...q(j,m,l,b),raw:j});continue}e.push({type:"system",...q(j,m,l,b),raw:j})}return e.length>500&&await new Promise(a=>setImmediate(a)),e.sort((a,b)=>a.timestampMs-b.timestampMs),{entries:e,rawLines:f,cwd:c}}async function Z(a){let b,c,d=function(a){let b;if(!W.test(a))return null;let c=(0,w.resolve)(process.env.PI_SESSIONS_DIR||(0,w.join)((0,x.homedir)(),".pi","agent","sessions"));try{b=(0,u.readdirSync)(c)}catch{return null}for(let d of b){let b,e=(0,w.resolve)(c,d);if(e.startsWith(`${c}${w.sep}`)){try{b=(0,u.readdirSync)(e)}catch{continue}for(let c of b){let b=X.exec(c);if(!b||b[1].toLowerCase()!==a.toLowerCase())continue;let d=(0,w.resolve)(e,c);if(d.startsWith(`${e}${w.sep}`)&&(0,u.existsSync)(d))return d}}}return null}(a);if(!d)return null;try{b=await (0,v.readFile)(d,"utf-8")}catch{return null}try{c=await Y(b,"session")}catch{return null}return{entries:c.entries,rawLines:c.rawLines,cwd:c.cwd,filePath:d}}let $=(0,l.runtimeCache)(a=>Z(a),60,{maxSize:50}),_=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,aa=/^session-(.+)-([0-9a-f]{8})\.jsonl$/i;async function ab(a,b="session",c){let d=a.split("\n").filter(a=>""!==a.trim()),e=[],f=[],g=!1;for(let a=0;a<d.length;a++){let c;a>0&&a%200==0&&await new Promise(a=>setImmediate(a));let h=d[a];try{c=JSON.parse(h)}catch{continue}let i={...c,_source:b};if(f.push(i),"string"==typeof c.sessionId&&"string"==typeof c.startTime){let a=new Date(c.startTime);if(!Number.isNaN(a.getTime())){let c=g?"Session Resumed":"Session Started";g=!0,e.push({type:"queue-operation",...q(i,a.toISOString(),a,b),label:c})}continue}if(c.$set)continue;let j=c.timestamp;if(!j)continue;let k=new Date(j);if(Number.isNaN(k.getTime()))continue;let l=k.toISOString(),m=c.type;if("user"===m){let a=function(a){if(!Array.isArray(a))return"";let b=[];for(let c of a)"string"==typeof c?.text&&b.push(c.text);return b.join("\n\n")}(c.content);if(!a)continue;e.push({type:"user",...q(i,l,k,b),message:{role:"user",content:a}});continue}if("assistant"===m||"model"===m){let a=function(a){if(!Array.isArray(a))return[];let b=[];for(let c of a)"string"==typeof c?.text&&c.text.length>0&&b.push({type:"text",text:c.text});return b}(c.content);if(0===a.length){e.push({type:"system",...q(i,l,k,b),raw:i});continue}e.push({type:"assistant",...q(i,l,k,b),message:{role:"assistant",content:a}});continue}e.push({type:"system",...q(i,l,k,b),raw:i})}return e.length>500&&await new Promise(a=>setImmediate(a)),e.sort((a,b)=>a.timestampMs-b.timestampMs),{entries:e,rawLines:f,cwd:c}}async function ac(a){let b,c,d=function(a){let b;if(!_.test(a))return null;let c=(0,w.resolve)(process.env.GEMINI_SESSIONS_DIR||(0,w.join)((0,x.homedir)(),".gemini","tmp")),d=a.slice(0,8).toLowerCase();try{b=(0,u.readdirSync)(c)}catch{return null}for(let e of b){let b,f=(0,w.resolve)(c,e);if(!f.startsWith(`${c}${w.sep}`))continue;let g=(0,w.resolve)(f,"chats");try{b=(0,u.readdirSync)(g)}catch{continue}for(let c of b){let b=aa.exec(c);if(!b||b[2].toLowerCase()!==d)continue;let e=(0,w.resolve)(g,c);if(!e.startsWith(`${g}${w.sep}`)||!(0,u.existsSync)(e))continue;let f=function(a){let b;try{b=(0,u.openSync)(a,"r")}catch{return null}try{let a=Buffer.alloc(4096),c=(0,u.readSync)(b,a,0,a.length,0);if(0===c)return null;let d=a.subarray(0,c).toString("utf-8"),e=d.indexOf("\n");return e>=0?d.slice(0,e):d}catch{return null}finally{try{(0,u.closeSync)(b)}catch{}}}(e);if(f)try{let b=JSON.parse(f);if("string"==typeof b.sessionId&&b.sessionId.toLowerCase()===a.toLowerCase())return e}catch{continue}}}return null}(a);if(!d)return null;try{b=await (0,v.readFile)(d,"utf-8")}catch{return null}let e=function(a){let b=(0,w.resolve)(a,".."),c=(0,w.resolve)(b,".."),d=(0,w.join)(c,".project_root");try{let a=(0,u.readFileSync)(d,"utf-8").trim();return a.length>0?a:void 0}catch{return}}(d);try{c=await ab(b,"session",e)}catch{return null}return{entries:c.entries,rawLines:c.rawLines,cwd:c.cwd,filePath:d}}let ad=(0,l.runtimeCache)(a=>ac(a),60,{maxSize:50});var ae=a.i(71130),af=a.i(893),ag=a.i(24282);function ah({cli:a}){let c=(0,ag.getCliLabel)(a),d=(0,ag.getCliBadgeClasses)(a);return(0,b.jsx)("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-mono font-medium uppercase tracking-wider border ${d}`,title:`Agent CLI: ${c}`,children:c})}async function ai({params:a}){let g,h,{name:k,sessionId:l}=await a;try{(0,j.resolveProjectPath)(k)}catch{(0,f.notFound)()}let m=(0,i.decodeFolderName)(k),n=-1===(h=l.indexOf("/"))?l:l.slice(0,h);j.UUID_RE.test(n)||/^ses_[A-Za-z0-9]+$/.test(n)||(0,f.notFound)();let o=null,p=null,q=null,r="claude";try{let a=await t(k,n);o=a.entries,p=a.rawLines}catch(a){if("ENOENT"===a.code){let a=await F(n);if(a)o=a.entries,p=a.rawLines,g=a.cwd,r="codex";else{let a=await J(n);if(a)o=a.entries,p=a.rawLines,g=a.cwd,r="copilot";else{let a=await P(n);if(a)o=a.entries,p=a.rawLines,g=a.cwd,r="cursor";else{let a=await V(n);if(a)o=a.entries,p=a.rawLines,g=a.cwd,r="opencode";else{let a=await $(n);if(a)o=a.entries,p=a.rawLines,g=a.cwd,r="pi";else{let a=await ad(n);a?(o=a.entries,p=a.rawLines,g=a.cwd,r="gemini"):q="Session log file not found."}}}}}}else q="Failed to read session log."}let s="claude"!==r,u="codex"===r?`OpenAI Codex${g?` \xb7 ${g}`:""}`:"copilot"===r?`GitHub Copilot${g?` \xb7 ${g}`:""}`:"cursor"===r?`Cursor Agent${g?` \xb7 ${g}`:""}`:"opencode"===r?`OpenCode${g?` \xb7 ${g}`:""}`:"pi"===r?`Pi${g?` \xb7 ${g}`:""}`:"gemini"===r?`Gemini CLI${g?` \xb7 ${g}`:""}`:m;return(0,b.jsx)("main",{className:"min-h-screen bg-background",children:(0,b.jsxs)("div",{className:"container mx-auto p-8",children:[(0,b.jsxs)(c.default,{href:s?"/policies?tab=activity":`/project/${encodeURIComponent(k)}`,className:"inline-flex items-center gap-2 text-muted-foreground hover:text-foreground mb-6 transition-colors",children:[(0,b.jsx)(d.ArrowLeft,{className:"w-4 h-4"}),(0,b.jsx)("span",{children:s?"Back to Activity":"Back to Sessions"})]}),(0,b.jsxs)("div",{className:"mb-8",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-3 mb-2",children:[(0,b.jsx)("h1",{className:"text-4xl font-bold text-foreground",children:"Session Log"}),(0,b.jsx)(ah,{cli:r})]}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsxs)("p",{className:"text-muted-foreground",children:[(0,b.jsxs)("span",{className:"font-medium",children:[s?"CLI":"Project",":"]})," ",u]}),(0,b.jsxs)("p",{className:"text-muted-foreground break-words break-all inline-flex items-center gap-1",children:[(0,b.jsx)("span",{className:"font-medium",children:"Session:"})," ",n,(0,b.jsx)(af.CopyButton,{text:n})]}),o&&p&&(0,b.jsxs)("div",{className:"flex items-center gap-4",children:[(0,b.jsxs)("p",{className:"text-muted-foreground",children:[(0,b.jsx)("span",{className:"font-medium",children:p.length})," log lines"]}),(0,b.jsxs)("a",{href:`/api/download/${encodeURIComponent(k)}/${encodeURIComponent(n)}?cli=${r}`,download:!0,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground transition-colors",children:[(0,b.jsx)(e,{className:"w-4 h-4"}),"Download Logs"]})]})]})]}),q&&(0,b.jsx)("div",{className:"bg-card text-card-foreground rounded-lg border border-destructive/50 p-6 shadow-sm",children:(0,b.jsx)("p",{className:"text-destructive text-center py-8",children:q})}),!q&&o&&(0,b.jsx)(ae.default,{entries:o,projectName:s?g??("codex"===r?"OpenAI Codex":"copilot"===r?"GitHub Copilot":"cursor"===r?"Cursor Agent":"opencode"===r?"OpenCode":"pi"===r?"Pi":"Gemini CLI"):m,sessionId:n})]})})}a.s(["default",0,ai,"dynamic",0,"force-dynamic"],41190)},87330,a=>{a.n(a.i(41190))}];
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=app_0cdqd9w._.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module.exports=[3171,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(
|
|
1
|
+
module.exports=[3171,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(2121),e=a.i(66036);a.s(["default",0,function({error:a,reset:f}){return(0,c.useEffect)(()=>{(0,d.getTelemetryConfig)().then(b=>{(0,e.setClientTelemetryConfig)(b),(0,e.captureClientEvent)("client_error",{error_message:a.message,error_name:a.name,error_digest:a.digest,boundary:"global"})}).catch(()=>{})},[a]),(0,b.jsx)("html",{children:(0,b.jsx)("body",{children:(0,b.jsx)("main",{style:{minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",background:"#031035",color:"#f8fafc",fontFamily:"system-ui, sans-serif"},children:(0,b.jsxs)("div",{style:{textAlign:"center",padding:"2rem",border:"1px solid rgba(239,68,68,0.4)",borderRadius:"0.5rem",maxWidth:"500px"},children:[(0,b.jsx)("h2",{style:{color:"#ef4444",marginBottom:"0.5rem",fontSize:"1.25rem"},children:"Something went wrong"}),(0,b.jsx)("p",{style:{color:"#94a3b8",marginBottom:"1.5rem"},children:a.message||"An unexpected error occurred."}),(0,b.jsx)("button",{onClick:f,style:{padding:"0.5rem 1.25rem",background:"#3b82f6",color:"white",border:"none",borderRadius:"0.375rem",cursor:"pointer",fontSize:"0.875rem"},children:"Try again"})]})})})})}])}];
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=app_global-error_tsx_0xerkr6._.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
module.exports=[22712,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(35112),e=a.i(38246),f=a.i(64831);let g=(0,f.default)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),h=(0,f.default)("shield-check",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),i=(0,f.default)("shield-x",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]),j=(0,f.default)("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);var k=a.i(14258),l=a.i(89027),m=a.i(85650),n=a.i(52562);let o=(0,f.default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),p=(0,f.default)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]);var q=a.i(74215),r=a.i(65967),s=a.i(5050);let t=(0,s.createServerReference)("40e3cab3b3642d97fbe28635d88b1add49f4e95e3c",s.callServer,void 0,s.findSourceMapURL,"getHookActivityAction"),u=(0,s.createServerReference)("60323d71d0332805024f646b7e47b80c27b897b771",s.callServer,void 0,s.findSourceMapURL,"searchHookActivityAction"),v=(0,s.createServerReference)("0049f897fa7c73fd87c03de403c0c07054e18da764",s.callServer,void 0,s.findSourceMapURL,"getHooksConfigAction"),w=(0,s.createServerReference)("6036a5b719208f115a4589641a70cb6ba991c5947e",s.callServer,void 0,s.findSourceMapURL,"togglePolicyAction"),x=(0,s.createServerReference)("60b349cceb1dc050a181b148dc5d2abc20980e4acc",s.callServer,void 0,s.findSourceMapURL,"installHooksWebAction"),y=(0,s.createServerReference)("60db4e56f0781686e7adec3c8a346df925f9c2d477",s.callServer,void 0,s.findSourceMapURL,"removeHooksWebAction"),z=(0,s.createServerReference)("60301ad27d8a5b630d6ed59f46d5adc1ef40b0c7e3",s.callServer,void 0,s.findSourceMapURL,"updatePolicyParamsAction");var A=a.i(6236),B=a.i(90619),C=a.i(95947),D=a.i(87256),E=a.i(40695);function F({sessionId:a,transcriptPath:c,integration:d,cwd:f}){if(!a)return(0,b.jsx)("span",{className:"text-muted-foreground",children:"\\u2014"});let g=a?a.slice(0,8):"—",h="codex"===d||(c?.includes("/.codex/")??!1),i="copilot"===d||(c?.includes("/.copilot/session-state/")??!1),j="cursor"===d||(c?.includes("/.cursor/")??!1),k="opencode"===d||(c?.includes("/.local/share/opencode/")??!1)||(c?.includes("/.opencode/")??!1),l="pi"===d||(c?.includes("/.pi/")??!1),m="gemini"===d||(c?.includes("/.gemini/")??!1);if(h||i||j||k||l||m){let c,d=f?(c=/^([A-Za-z]):[\\/](.*)$/.exec(f))?c[1]+"--"+c[2].replace(/[\\/]/g,"-"):f.replace(/[\\/]/g,"-"):h?"codex":i?"copilot":j?"cursor":k?"opencode":l?"pi":"gemini";return(0,b.jsx)(e.default,{href:`/project/${encodeURIComponent(d)}/session/${encodeURIComponent(a)}`,className:"text-primary hover:underline font-mono",onClick:a=>a.stopPropagation(),children:g})}let n=c?function(a){let b=a.replace(/\\/g,"/").split("/").filter(Boolean);if(b.length<2)return null;let c=b[b.length-2];return!c||c.startsWith(".")?null:c}(c):null;return n?(0,b.jsx)(e.default,{href:`/project/${encodeURIComponent(n)}/session/${encodeURIComponent(a)}`,className:"text-primary hover:underline font-mono",onClick:a=>a.stopPropagation(),children:g}):(0,b.jsx)("span",{className:"text-muted-foreground font-mono",children:g})}function G({decision:a}){return"deny"===a?(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-red-500/10 text-red-400 border border-red-500/20",children:[(0,b.jsx)(i,{className:"h-3 w-3"}),"Deny"]}):"instruct"===a?(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-amber-500/10 text-amber-400 border border-amber-500/20",children:[(0,b.jsx)(j,{className:"h-3 w-3"}),"Instruct"]}):(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:[(0,b.jsx)(h,{className:"h-3 w-3"}),"Allow"]})}function H({eventType:a}){return(0,b.jsx)("span",{className:"inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium bg-muted text-muted-foreground border border-border/50",children:a})}function I({integration:a}){if(!a)return null;let c=(0,D.getCliLabel)(a),d=(0,D.getCliBadgeClasses)(a);return(0,b.jsx)("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium border ${d}`,title:`Agent CLI: ${c}`,children:c})}function J({mode:a}){let c="default"===a;return(0,b.jsx)("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium border ${c?"bg-sky-500/10 text-sky-400 border-sky-500/20":"bg-amber-500/10 text-amber-400 border-amber-500/20"}`,children:a})}function K({ms:a}){return(0,b.jsx)("span",{className:`font-mono text-[0.7rem] ${a>500?"text-red-400":a>100?"text-amber-400":"text-muted-foreground"}`,children:a<1e3?`${a}ms`:`${(a/1e3).toFixed(1)}s`})}function L({text:a}){let[d,e]=(0,c.useState)(!1),f=async b=>{b.stopPropagation();try{await navigator.clipboard.writeText(a),e(!0),setTimeout(()=>e(!1),1500)}catch{let b=document.createElement("textarea");b.value=a,b.style.position="fixed",b.style.opacity="0",document.body.appendChild(b),b.select(),document.execCommand("copy"),document.body.removeChild(b),e(!0),setTimeout(()=>e(!1),1500)}};return(0,b.jsx)("button",{onClick:f,className:"inline-flex items-center justify-center h-5 w-5 rounded hover:bg-muted/50 text-muted-foreground hover:text-foreground transition-colors",title:"Copy",children:d?(0,b.jsx)(n.Check,{className:"h-3 w-3 text-emerald-400"}):(0,b.jsx)(m.Copy,{className:"h-3 w-3"})})}function M({value:a,onChange:c}){return(0,b.jsx)("div",{className:"inline-flex items-center rounded-md border border-border bg-muted/30 p-0.5",children:[{label:"All",value:""},{label:"Allow",value:"allow"},{label:"Instruct",value:"instruct"},{label:"Deny",value:"deny"}].map(d=>(0,b.jsx)("button",{onClick:()=>c(d.value),className:`px-2.5 py-1 text-[0.65rem] font-medium rounded transition-all ${a===d.value?"deny"===d.value?"bg-red-500/15 text-red-400 shadow-sm":"allow"===d.value?"bg-emerald-500/15 text-emerald-400 shadow-sm":"instruct"===d.value?"bg-amber-500/15 text-amber-400 shadow-sm":"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:d.label},d.value))})}function N({stats:a}){let c=a.totalEvents>0?(a.denyCount/a.totalEvents*100).toFixed(0):"0";return(0,b.jsxs)("div",{className:"flex items-center gap-6 text-[0.7rem] text-muted-foreground",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-foreground font-mono font-semibold",children:a.totalEvents})," total events"]}),(0,b.jsxs)("div",{children:[(0,b.jsxs)("span",{className:`font-mono font-semibold ${a.denyCount>0?"text-red-400":"text-foreground"}`,children:[c,"%"]})," ","deny rate"]}),(0,b.jsxs)("div",{className:"hidden sm:block",children:["top policy:"," ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.topPolicy??"—"})]})]})}function O({item:a}){return(0,b.jsx)("tr",{children:(0,b.jsx)("td",{colSpan:10,className:"px-0 py-0",children:(0,b.jsxs)("div",{className:"px-6 py-3 bg-muted/20 border-t border-border/30 space-y-2 text-xs animate-expand",children:[(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-x-8 gap-y-1.5",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Session ID: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.sessionId??"—"}),a.sessionId&&(0,b.jsx)(L,{text:a.sessionId})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"CWD: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.cwd??"—"}),a.cwd&&(0,b.jsx)(L,{text:a.cwd})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Transcript: "}),(0,b.jsx)("span",{className:"font-mono text-foreground break-all",children:a.transcriptPath??"—"}),a.transcriptPath?.startsWith("opencode-db://")&&(0,b.jsx)("span",{className:"text-muted-foreground ml-1",children:"(stored in opencode DB)"})]})]}),a.policyNames&&a.policyNames.length>1&&(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Policies: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.policyNames.join(", ")})]}),a.reason&&(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Full reason: "}),(0,b.jsx)("span",{className:"text-foreground",children:a.reason})]})]})})})}function P({hooksInstalled:a,onSwitchTab:d}){let{intervalSec:e}=(0,A.useAutoRefresh)(),f=(0,B.useUrlParams)(),g=(0,c.useRef)(!1),[h,i]=(0,c.useState)(()=>(0,C.paramToPage)(f.get("page"))),[j,m]=(0,c.useState)(null),[n,o]=(0,c.useState)(null),[p,q]=(0,c.useState)(()=>{let a=f.get("decision");return"allow"===a||"deny"===a||"instruct"===a?a:""}),[s,v]=(0,c.useState)(()=>f.get("event")??""),[w,x]=(0,c.useState)(()=>f.get("policy")??""),[y,z]=(0,c.useState)(()=>f.get("session")??""),[E,L]=(0,c.useState)(()=>{let a=f.get("cli");return(0,D.isKnownCli)(a)?a:""}),Q=(0,c.useRef)(null),R=(0,c.useRef)({filterDecision:p,filterEventType:s,filterPolicy:w,filterSessionId:y,filterCli:E});R.current={filterDecision:p,filterEventType:s,filterPolicy:w,filterSessionId:y,filterCli:E},(0,c.useEffect)(()=>{if(!g.current){g.current=!0;return}f.setAll({decision:p||void 0,event:s||void 0,policy:w||void 0,session:y||void 0,cli:E||void 0,page:(0,C.pageToParam)(h)})},[p,s,w,y,E,h]);let S=""!==p||""!==s||""!==w||""!==y||""!==E,T=(0,c.useCallback)(async a=>{try{let b,{filterDecision:c,filterEventType:d,filterPolicy:e,filterSessionId:f,filterCli:g}=R.current;b=""!==c||""!==d||""!==e||""!==f||""!==g?await u({decision:c||void 0,eventType:d||void 0,policyName:e||void 0,sessionId:f||void 0,integration:g||void 0},a):await t(a),m(b)}catch{}},[]);(0,c.useEffect)(()=>{T(h);let a=setInterval(()=>T(h),e>0?1e3*e:5e3);return()=>clearInterval(a)},[h,T,e]),(0,c.useEffect)(()=>(Q.current&&clearTimeout(Q.current),Q.current=setTimeout(()=>{i(1),o(null),T(1)},300),()=>{Q.current&&clearTimeout(Q.current)}),[p,s,w,y,E]);let U=j?.entries??[],V=j?.totalPages??1;return(0,b.jsxs)(b.Fragment,{children:[j?.stats&&j.stats.totalEvents>0&&(0,b.jsx)("div",{className:"mb-4",children:(0,b.jsx)(N,{stats:j.stats})}),(0,b.jsxs)("div",{className:"bg-card border border-border rounded-lg overflow-hidden",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-3 px-4 py-2.5 border-b border-border bg-muted/20",children:[(0,b.jsx)(M,{value:p,onChange:q}),(0,b.jsxs)("select",{value:s,onChange:a=>v(a.target.value),className:"h-7 rounded-md border border-border bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary/40 focus:border-primary/40 transition-shadow",children:[(0,b.jsx)("option",{value:"",children:"All Events"}),(0,b.jsx)("option",{value:"PreToolUse",children:"PreToolUse"}),(0,b.jsx)("option",{value:"PostToolUse",children:"PostToolUse"}),(0,b.jsx)("option",{value:"SessionStart",children:"SessionStart"}),(0,b.jsx)("option",{value:"SessionEnd",children:"SessionEnd"}),(0,b.jsx)("option",{value:"UserPromptSubmit",children:"UserPromptSubmit"}),(0,b.jsx)("option",{value:"PermissionRequest",children:"PermissionRequest"})]}),(0,b.jsxs)("select",{value:E,onChange:a=>{let b=a.target.value;L(""===b||(0,D.isKnownCli)(b)?b:"")},className:"h-7 rounded-md border border-border bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary/40 focus:border-primary/40 transition-shadow","aria-label":"Filter by CLI",children:[(0,b.jsx)("option",{value:"",children:"All CLIs"}),D.KNOWN_CLI_IDS.map(a=>(0,b.jsx)("option",{value:a,children:(0,D.getCliLabel)(a)},a))]}),(0,b.jsx)("div",{className:"relative",children:(0,b.jsx)("input",{type:"text",value:w,onChange:a=>x(a.target.value),placeholder:"Filter by policy\\u2026",className:"h-7 rounded-md border border-border bg-background px-2.5 text-xs text-foreground placeholder:text-muted-foreground w-44 focus:outline-none focus:ring-2 focus:ring-primary/40 focus:border-primary/40 transition-shadow"})}),(0,b.jsx)("div",{className:"relative",children:(0,b.jsx)("input",{type:"text",value:y,onChange:a=>z(a.target.value),placeholder:"Filter by session…",className:"h-7 rounded-md border border-border bg-background px-2.5 text-xs text-foreground placeholder:text-muted-foreground w-44 focus:outline-none focus:ring-2 focus:ring-primary/40 focus:border-primary/40 transition-shadow"})})]}),0===U.length?(0,b.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 px-4 text-center",children:[(0,b.jsx)(k.Shield,{className:"h-12 w-12 text-muted-foreground/30"}),!1===a?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("p",{className:"text-sm text-muted-foreground mt-4 font-medium",children:"Policies are not installed"}),(0,b.jsxs)("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm",children:["Go to the"," ",(0,b.jsx)("button",{className:"underline hover:text-foreground transition-colors",onClick:()=>d?.("policies"),children:"Policies tab"})," ","and click ",(0,b.jsx)("span",{className:"font-mono bg-muted px-1 rounded",children:"Install"})," to enable policy monitoring."]})]}):(0,b.jsx)("p",{className:"text-sm text-muted-foreground mt-4",children:S?"No matching activity.":"Waiting for hook events…"})]}):(0,b.jsx)("div",{className:"overflow-x-auto",children:(0,b.jsxs)("table",{className:"w-full text-xs",children:[(0,b.jsx)("thead",{children:(0,b.jsxs)("tr",{className:"text-left text-muted-foreground border-b border-border bg-muted/30",children:[(0,b.jsx)("th",{className:"px-4 py-2.5 font-medium w-6"}),(0,b.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Decision"}),(0,b.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Event"}),(0,b.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"CLI"}),(0,b.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Tool"}),(0,b.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Policy"}),(0,b.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Reason"}),(0,b.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Duration"}),(0,b.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Session"}),(0,b.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Mode"}),(0,b.jsx)("th",{className:"px-3 py-2.5 font-medium text-right",children:"Time"})]})}),(0,b.jsx)("tbody",{className:"divide-y divide-border/30",children:U.map((a,d)=>{var e;let f,g="deny"===a.decision,h=n===d,i="instruct"===a.decision;return(0,b.jsxs)(c.default.Fragment,{children:[(0,b.jsxs)("tr",{onClick:()=>{o(a=>a===d?null:d)},className:`cursor-pointer transition-colors ${g?"bg-red-500/[0.03] hover:bg-red-500/[0.07] border-l-2 border-l-red-500/40":i?"bg-amber-500/[0.03] hover:bg-amber-500/[0.07] border-l-2 border-l-amber-500/40":d%2==0?"hover:bg-muted/30":"bg-muted/[0.04] hover:bg-muted/30"} ${h?"bg-muted/20":""}`,children:[(0,b.jsx)("td",{className:"px-4 py-2",children:(0,b.jsx)(l.ChevronDown,{className:`h-3.5 w-3.5 text-muted-foreground transition-transform duration-150 ${h?"rotate-0":"-rotate-90"}`})}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(G,{decision:a.decision})}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(H,{eventType:a.eventType})}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(I,{integration:a.integration})}),(0,b.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:a.toolName??"—"}),(0,b.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:a.policyNames&&a.policyNames.length>1?(0,b.jsxs)("span",{title:a.policyNames.join(", "),children:[a.policyNames[0],(0,b.jsxs)("span",{className:"text-muted-foreground text-[0.6rem]",children:[" +",a.policyNames.length-1]})]}):a.policyName??"—"}),(0,b.jsx)("td",{className:"px-3 py-2 text-muted-foreground truncate max-w-[240px]",title:a.reason??"",children:a.reason??"—"}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(K,{ms:a.durationMs})}),(0,b.jsx)("td",{className:"px-3 py-2",title:a.sessionId??"",children:(0,b.jsx)(F,{sessionId:a.sessionId,transcriptPath:a.transcriptPath,integration:a.integration,cwd:a.cwd})}),(0,b.jsx)("td",{className:"px-3 py-2",children:a.permissionMode?(0,b.jsx)(J,{mode:a.permissionMode}):"—"}),(0,b.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground whitespace-nowrap",title:new Date(a.timestamp).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),children:(e=a.timestamp,(f=Date.now()-e)<6e4?`${Math.max(1,Math.floor(f/1e3))}s ago`:f<36e5?`${Math.floor(f/6e4)}m ago`:f<864e5?`${Math.floor(f/36e5)}h ago`:`${Math.floor(f/864e5)}d ago`)})]}),h&&(0,b.jsx)(O,{item:a})]},`${a.timestamp}-${d}`)})})]})}),(0,b.jsx)(r.default,{currentPage:h,totalPages:V,onPageChange:a=>{i(a),o(null)}})]})]})}function Q({enabled:a,onChange:c,disabled:d}){return(0,b.jsx)("button",{onClick:c,disabled:d,className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors disabled:opacity-40 ${a?"bg-emerald-500":"bg-muted-foreground/30"}`,"aria-label":a?"Disable policy":"Enable policy",children:(0,b.jsx)("span",{className:`inline-block h-3 w-3 rounded-full bg-white shadow transition-transform ${a?"translate-x-3.5":"translate-x-0.5"}`})})}function R({policy:a,onClose:d,onSave:e}){let f=a.params??{},g=a.currentParams??{},[h,i]=(0,c.useState)(()=>{let a={};for(let[b,c]of Object.entries(f)){let d=b in g?g[b]:c.default;a[b]=d}return a});(0,c.useEffect)(()=>{let a=a=>{"Escape"===a.key&&d()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[d]);let j=(a,b)=>{i(c=>({...c,[a]:b}))};return(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:a=>{a.target===a.currentTarget&&d()},children:(0,b.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[80vh] flex flex-col",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"text-sm font-mono font-semibold text-foreground",children:a.name}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:a.description})]}),(0,b.jsx)("button",{onClick:d,className:"text-muted-foreground hover:text-foreground transition-colors",children:(0,b.jsx)(q.X,{className:"h-4 w-4"})})]}),(0,b.jsx)("div",{className:"overflow-y-auto flex-1 px-4 py-4 space-y-4",children:Object.entries(f).map(([a,c])=>(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1 font-mono",children:a}),(0,b.jsx)("p",{className:"text-[0.65rem] text-muted-foreground mb-1.5",children:c.description}),((a,c)=>{let d=h[a];if("boolean"===c.type)return(0,b.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,b.jsx)("input",{type:"checkbox",checked:!!d,onChange:b=>j(a,b.target.checked),className:"rounded border-border"}),(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:c.description})]});if("number"===c.type)return(0,b.jsx)("input",{type:"number",value:"number"==typeof d?d:"",onChange:b=>j(a,Number(b.target.value)),className:"w-full h-7 rounded border border-border bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary/40"});if("string[]"===c.type){let c=Array.isArray(d)?d.join("\n"):"";return(0,b.jsx)("textarea",{value:c,onChange:b=>j(a,b.target.value.split("\n").filter(a=>""!==a.trim())),rows:4,placeholder:"One entry per line",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground font-mono focus:outline-none focus:ring-2 focus:ring-primary/40 resize-y"})}if("pattern[]"===c.type){let c=Array.isArray(d)?d:[];return(0,b.jsxs)("div",{className:"space-y-1.5",children:[c.map((d,e)=>(0,b.jsxs)("div",{className:"flex gap-1.5 items-center",children:[(0,b.jsx)("input",{type:"text",value:d.regex,onChange:b=>{let d=[...c];d[e]={...d[e],regex:b.target.value},j(a,d)},placeholder:"regex",className:"flex-1 h-6 rounded border border-border bg-background px-2 text-xs font-mono focus:outline-none focus:ring-2 focus:ring-primary/40"}),(0,b.jsx)("input",{type:"text",value:d.label,onChange:b=>{let d=[...c];d[e]={...d[e],label:b.target.value},j(a,d)},placeholder:"label",className:"flex-1 h-6 rounded border border-border bg-background px-2 text-xs focus:outline-none focus:ring-2 focus:ring-primary/40"}),(0,b.jsx)("button",{onClick:()=>j(a,c.filter((a,b)=>b!==e)),className:"text-muted-foreground/50 hover:text-destructive transition-colors",children:(0,b.jsx)(q.X,{className:"h-3.5 w-3.5"})})]},e)),(0,b.jsx)("button",{onClick:()=>j(a,[...c,{regex:"",label:""}]),className:"text-xs text-primary hover:underline",children:"+ Add pattern"})]})}return(0,b.jsx)("input",{type:"text",value:"string"==typeof d?d:"",onChange:b=>j(a,b.target.value),className:"w-full h-7 rounded border border-border bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary/40"})})(a,c)]},a))}),(0,b.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,b.jsx)(E.Button,{variant:"outline",size:"sm",onClick:d,className:"h-7 text-xs",children:"Cancel"}),(0,b.jsx)(E.Button,{size:"sm",onClick:()=>e(h),className:"h-7 text-xs",children:"Save"})]})]})})}function S({message:a,onDismiss:c,onInstall:e,isPending:f}){return(0,d.createPortal)((0,b.jsxs)("div",{className:"fixed top-4 right-4 z-[9999] w-full max-w-sm",style:{animation:"slideInFromRight 0.25s ease-out"},children:[(0,b.jsx)("style",{children:`
|
|
1
|
+
module.exports=[22712,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(35112),e=a.i(38246),f=a.i(64831);let g=(0,f.default)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),h=(0,f.default)("shield-check",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),i=(0,f.default)("shield-x",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]),j=(0,f.default)("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);var k=a.i(14258),l=a.i(89027),m=a.i(85650),n=a.i(52562);let o=(0,f.default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),p=(0,f.default)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]);var q=a.i(74215),r=a.i(65967),s=a.i(5050);let t=(0,s.createServerReference)("402714e0127fd96b57ab64b8f734f9316459cc9edc",s.callServer,void 0,s.findSourceMapURL,"getHookActivityAction"),u=(0,s.createServerReference)("60a3d76dbcd84dcda4d20bb06166e7d742409464f3",s.callServer,void 0,s.findSourceMapURL,"searchHookActivityAction"),v=(0,s.createServerReference)("006ae6c77a6b860631f0b05f055600b490d96feb01",s.callServer,void 0,s.findSourceMapURL,"getHooksConfigAction"),w=(0,s.createServerReference)("60474dd63e4ca78318418a84742753bcf27e8be12d",s.callServer,void 0,s.findSourceMapURL,"togglePolicyAction"),x=(0,s.createServerReference)("60afa57857d3f18dc463fc3a2dcf942a73adeb9e28",s.callServer,void 0,s.findSourceMapURL,"installHooksWebAction"),y=(0,s.createServerReference)("6010e22670ccd7912f669a127211be1912462760c1",s.callServer,void 0,s.findSourceMapURL,"removeHooksWebAction"),z=(0,s.createServerReference)("6009f76760f968bad6473b991630e917577dcad669",s.callServer,void 0,s.findSourceMapURL,"updatePolicyParamsAction");var A=a.i(6236),B=a.i(90619),C=a.i(95947),D=a.i(87256),E=a.i(40695);function F({sessionId:a,transcriptPath:c,integration:d,cwd:f}){if(!a)return(0,b.jsx)("span",{className:"text-muted-foreground",children:"\\u2014"});let g=a?a.slice(0,8):"—",h="codex"===d||(c?.includes("/.codex/")??!1),i="copilot"===d||(c?.includes("/.copilot/session-state/")??!1),j="cursor"===d||(c?.includes("/.cursor/")??!1),k="opencode"===d||(c?.includes("/.local/share/opencode/")??!1)||(c?.includes("/.opencode/")??!1),l="pi"===d||(c?.includes("/.pi/")??!1),m="gemini"===d||(c?.includes("/.gemini/")??!1);if(h||i||j||k||l||m){let c,d=f?(c=/^([A-Za-z]):[\\/](.*)$/.exec(f))?c[1]+"--"+c[2].replace(/[\\/]/g,"-"):f.replace(/[\\/]/g,"-"):h?"codex":i?"copilot":j?"cursor":k?"opencode":l?"pi":"gemini";return(0,b.jsx)(e.default,{href:`/project/${encodeURIComponent(d)}/session/${encodeURIComponent(a)}`,className:"text-primary hover:underline font-mono",onClick:a=>a.stopPropagation(),children:g})}let n=c?function(a){let b=a.replace(/\\/g,"/").split("/").filter(Boolean);if(b.length<2)return null;let c=b[b.length-2];return!c||c.startsWith(".")?null:c}(c):null;return n?(0,b.jsx)(e.default,{href:`/project/${encodeURIComponent(n)}/session/${encodeURIComponent(a)}`,className:"text-primary hover:underline font-mono",onClick:a=>a.stopPropagation(),children:g}):(0,b.jsx)("span",{className:"text-muted-foreground font-mono",children:g})}function G({decision:a}){return"deny"===a?(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-red-500/10 text-red-400 border border-red-500/20",children:[(0,b.jsx)(i,{className:"h-3 w-3"}),"Deny"]}):"instruct"===a?(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-amber-500/10 text-amber-400 border border-amber-500/20",children:[(0,b.jsx)(j,{className:"h-3 w-3"}),"Instruct"]}):(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:[(0,b.jsx)(h,{className:"h-3 w-3"}),"Allow"]})}function H({eventType:a}){return(0,b.jsx)("span",{className:"inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium bg-muted text-muted-foreground border border-border/50",children:a})}function I({integration:a}){if(!a)return null;let c=(0,D.getCliLabel)(a),d=(0,D.getCliBadgeClasses)(a);return(0,b.jsx)("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium border ${d}`,title:`Agent CLI: ${c}`,children:c})}function J({mode:a}){let c="default"===a;return(0,b.jsx)("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium border ${c?"bg-sky-500/10 text-sky-400 border-sky-500/20":"bg-amber-500/10 text-amber-400 border-amber-500/20"}`,children:a})}function K({ms:a}){return(0,b.jsx)("span",{className:`font-mono text-[0.7rem] ${a>500?"text-red-400":a>100?"text-amber-400":"text-muted-foreground"}`,children:a<1e3?`${a}ms`:`${(a/1e3).toFixed(1)}s`})}function L({text:a}){let[d,e]=(0,c.useState)(!1),f=async b=>{b.stopPropagation();try{await navigator.clipboard.writeText(a),e(!0),setTimeout(()=>e(!1),1500)}catch{let b=document.createElement("textarea");b.value=a,b.style.position="fixed",b.style.opacity="0",document.body.appendChild(b),b.select(),document.execCommand("copy"),document.body.removeChild(b),e(!0),setTimeout(()=>e(!1),1500)}};return(0,b.jsx)("button",{onClick:f,className:"inline-flex items-center justify-center h-5 w-5 rounded hover:bg-muted/50 text-muted-foreground hover:text-foreground transition-colors",title:"Copy",children:d?(0,b.jsx)(n.Check,{className:"h-3 w-3 text-emerald-400"}):(0,b.jsx)(m.Copy,{className:"h-3 w-3"})})}function M({value:a,onChange:c}){return(0,b.jsx)("div",{className:"inline-flex items-center rounded-md border border-border bg-muted/30 p-0.5",children:[{label:"All",value:""},{label:"Allow",value:"allow"},{label:"Instruct",value:"instruct"},{label:"Deny",value:"deny"}].map(d=>(0,b.jsx)("button",{onClick:()=>c(d.value),className:`px-2.5 py-1 text-[0.65rem] font-medium rounded transition-all ${a===d.value?"deny"===d.value?"bg-red-500/15 text-red-400 shadow-sm":"allow"===d.value?"bg-emerald-500/15 text-emerald-400 shadow-sm":"instruct"===d.value?"bg-amber-500/15 text-amber-400 shadow-sm":"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:d.label},d.value))})}function N({stats:a}){let c=a.totalEvents>0?(a.denyCount/a.totalEvents*100).toFixed(0):"0";return(0,b.jsxs)("div",{className:"flex items-center gap-6 text-[0.7rem] text-muted-foreground",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-foreground font-mono font-semibold",children:a.totalEvents})," total events"]}),(0,b.jsxs)("div",{children:[(0,b.jsxs)("span",{className:`font-mono font-semibold ${a.denyCount>0?"text-red-400":"text-foreground"}`,children:[c,"%"]})," ","deny rate"]}),(0,b.jsxs)("div",{className:"hidden sm:block",children:["top policy:"," ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.topPolicy??"—"})]})]})}function O({item:a}){return(0,b.jsx)("tr",{children:(0,b.jsx)("td",{colSpan:10,className:"px-0 py-0",children:(0,b.jsxs)("div",{className:"px-6 py-3 bg-muted/20 border-t border-border/30 space-y-2 text-xs animate-expand",children:[(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-x-8 gap-y-1.5",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Session ID: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.sessionId??"—"}),a.sessionId&&(0,b.jsx)(L,{text:a.sessionId})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"CWD: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.cwd??"—"}),a.cwd&&(0,b.jsx)(L,{text:a.cwd})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Transcript: "}),(0,b.jsx)("span",{className:"font-mono text-foreground break-all",children:a.transcriptPath??"—"}),a.transcriptPath?.startsWith("opencode-db://")&&(0,b.jsx)("span",{className:"text-muted-foreground ml-1",children:"(stored in opencode DB)"})]})]}),a.policyNames&&a.policyNames.length>1&&(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Policies: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.policyNames.join(", ")})]}),a.reason&&(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Full reason: "}),(0,b.jsx)("span",{className:"text-foreground",children:a.reason})]})]})})})}function P({hooksInstalled:a,onSwitchTab:d}){let{intervalSec:e}=(0,A.useAutoRefresh)(),f=(0,B.useUrlParams)(),g=(0,c.useRef)(!1),[h,i]=(0,c.useState)(()=>(0,C.paramToPage)(f.get("page"))),[j,m]=(0,c.useState)(null),[n,o]=(0,c.useState)(null),[p,q]=(0,c.useState)(()=>{let a=f.get("decision");return"allow"===a||"deny"===a||"instruct"===a?a:""}),[s,v]=(0,c.useState)(()=>f.get("event")??""),[w,x]=(0,c.useState)(()=>f.get("policy")??""),[y,z]=(0,c.useState)(()=>f.get("session")??""),[E,L]=(0,c.useState)(()=>{let a=f.get("cli");return(0,D.isKnownCli)(a)?a:""}),Q=(0,c.useRef)(null),R=(0,c.useRef)({filterDecision:p,filterEventType:s,filterPolicy:w,filterSessionId:y,filterCli:E});R.current={filterDecision:p,filterEventType:s,filterPolicy:w,filterSessionId:y,filterCli:E},(0,c.useEffect)(()=>{if(!g.current){g.current=!0;return}f.setAll({decision:p||void 0,event:s||void 0,policy:w||void 0,session:y||void 0,cli:E||void 0,page:(0,C.pageToParam)(h)})},[p,s,w,y,E,h]);let S=""!==p||""!==s||""!==w||""!==y||""!==E,T=(0,c.useCallback)(async a=>{try{let b,{filterDecision:c,filterEventType:d,filterPolicy:e,filterSessionId:f,filterCli:g}=R.current;b=""!==c||""!==d||""!==e||""!==f||""!==g?await u({decision:c||void 0,eventType:d||void 0,policyName:e||void 0,sessionId:f||void 0,integration:g||void 0},a):await t(a),m(b)}catch{}},[]);(0,c.useEffect)(()=>{T(h);let a=setInterval(()=>T(h),e>0?1e3*e:5e3);return()=>clearInterval(a)},[h,T,e]),(0,c.useEffect)(()=>(Q.current&&clearTimeout(Q.current),Q.current=setTimeout(()=>{i(1),o(null),T(1)},300),()=>{Q.current&&clearTimeout(Q.current)}),[p,s,w,y,E]);let U=j?.entries??[],V=j?.totalPages??1;return(0,b.jsxs)(b.Fragment,{children:[j?.stats&&j.stats.totalEvents>0&&(0,b.jsx)("div",{className:"mb-4",children:(0,b.jsx)(N,{stats:j.stats})}),(0,b.jsxs)("div",{className:"bg-card border border-border rounded-lg overflow-hidden",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-3 px-4 py-2.5 border-b border-border bg-muted/20",children:[(0,b.jsx)(M,{value:p,onChange:q}),(0,b.jsxs)("select",{value:s,onChange:a=>v(a.target.value),className:"h-7 rounded-md border border-border bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary/40 focus:border-primary/40 transition-shadow",children:[(0,b.jsx)("option",{value:"",children:"All Events"}),(0,b.jsx)("option",{value:"PreToolUse",children:"PreToolUse"}),(0,b.jsx)("option",{value:"PostToolUse",children:"PostToolUse"}),(0,b.jsx)("option",{value:"SessionStart",children:"SessionStart"}),(0,b.jsx)("option",{value:"SessionEnd",children:"SessionEnd"}),(0,b.jsx)("option",{value:"UserPromptSubmit",children:"UserPromptSubmit"}),(0,b.jsx)("option",{value:"PermissionRequest",children:"PermissionRequest"})]}),(0,b.jsxs)("select",{value:E,onChange:a=>{let b=a.target.value;L(""===b||(0,D.isKnownCli)(b)?b:"")},className:"h-7 rounded-md border border-border bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary/40 focus:border-primary/40 transition-shadow","aria-label":"Filter by CLI",children:[(0,b.jsx)("option",{value:"",children:"All CLIs"}),D.KNOWN_CLI_IDS.map(a=>(0,b.jsx)("option",{value:a,children:(0,D.getCliLabel)(a)},a))]}),(0,b.jsx)("div",{className:"relative",children:(0,b.jsx)("input",{type:"text",value:w,onChange:a=>x(a.target.value),placeholder:"Filter by policy\\u2026",className:"h-7 rounded-md border border-border bg-background px-2.5 text-xs text-foreground placeholder:text-muted-foreground w-44 focus:outline-none focus:ring-2 focus:ring-primary/40 focus:border-primary/40 transition-shadow"})}),(0,b.jsx)("div",{className:"relative",children:(0,b.jsx)("input",{type:"text",value:y,onChange:a=>z(a.target.value),placeholder:"Filter by session…",className:"h-7 rounded-md border border-border bg-background px-2.5 text-xs text-foreground placeholder:text-muted-foreground w-44 focus:outline-none focus:ring-2 focus:ring-primary/40 focus:border-primary/40 transition-shadow"})})]}),0===U.length?(0,b.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 px-4 text-center",children:[(0,b.jsx)(k.Shield,{className:"h-12 w-12 text-muted-foreground/30"}),!1===a?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("p",{className:"text-sm text-muted-foreground mt-4 font-medium",children:"Policies are not installed"}),(0,b.jsxs)("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm",children:["Go to the"," ",(0,b.jsx)("button",{className:"underline hover:text-foreground transition-colors",onClick:()=>d?.("policies"),children:"Policies tab"})," ","and click ",(0,b.jsx)("span",{className:"font-mono bg-muted px-1 rounded",children:"Install"})," to enable policy monitoring."]})]}):(0,b.jsx)("p",{className:"text-sm text-muted-foreground mt-4",children:S?"No matching activity.":"Waiting for hook events…"})]}):(0,b.jsx)("div",{className:"overflow-x-auto",children:(0,b.jsxs)("table",{className:"w-full text-xs",children:[(0,b.jsx)("thead",{children:(0,b.jsxs)("tr",{className:"text-left text-muted-foreground border-b border-border bg-muted/30",children:[(0,b.jsx)("th",{className:"px-4 py-2.5 font-medium w-6"}),(0,b.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Decision"}),(0,b.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Event"}),(0,b.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"CLI"}),(0,b.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Tool"}),(0,b.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Policy"}),(0,b.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Reason"}),(0,b.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Duration"}),(0,b.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Session"}),(0,b.jsx)("th",{className:"px-3 py-2.5 font-medium",children:"Mode"}),(0,b.jsx)("th",{className:"px-3 py-2.5 font-medium text-right",children:"Time"})]})}),(0,b.jsx)("tbody",{className:"divide-y divide-border/30",children:U.map((a,d)=>{var e;let f,g="deny"===a.decision,h=n===d,i="instruct"===a.decision;return(0,b.jsxs)(c.default.Fragment,{children:[(0,b.jsxs)("tr",{onClick:()=>{o(a=>a===d?null:d)},className:`cursor-pointer transition-colors ${g?"bg-red-500/[0.03] hover:bg-red-500/[0.07] border-l-2 border-l-red-500/40":i?"bg-amber-500/[0.03] hover:bg-amber-500/[0.07] border-l-2 border-l-amber-500/40":d%2==0?"hover:bg-muted/30":"bg-muted/[0.04] hover:bg-muted/30"} ${h?"bg-muted/20":""}`,children:[(0,b.jsx)("td",{className:"px-4 py-2",children:(0,b.jsx)(l.ChevronDown,{className:`h-3.5 w-3.5 text-muted-foreground transition-transform duration-150 ${h?"rotate-0":"-rotate-90"}`})}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(G,{decision:a.decision})}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(H,{eventType:a.eventType})}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(I,{integration:a.integration})}),(0,b.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:a.toolName??"—"}),(0,b.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:a.policyNames&&a.policyNames.length>1?(0,b.jsxs)("span",{title:a.policyNames.join(", "),children:[a.policyNames[0],(0,b.jsxs)("span",{className:"text-muted-foreground text-[0.6rem]",children:[" +",a.policyNames.length-1]})]}):a.policyName??"—"}),(0,b.jsx)("td",{className:"px-3 py-2 text-muted-foreground truncate max-w-[240px]",title:a.reason??"",children:a.reason??"—"}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(K,{ms:a.durationMs})}),(0,b.jsx)("td",{className:"px-3 py-2",title:a.sessionId??"",children:(0,b.jsx)(F,{sessionId:a.sessionId,transcriptPath:a.transcriptPath,integration:a.integration,cwd:a.cwd})}),(0,b.jsx)("td",{className:"px-3 py-2",children:a.permissionMode?(0,b.jsx)(J,{mode:a.permissionMode}):"—"}),(0,b.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground whitespace-nowrap",title:new Date(a.timestamp).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),children:(e=a.timestamp,(f=Date.now()-e)<6e4?`${Math.max(1,Math.floor(f/1e3))}s ago`:f<36e5?`${Math.floor(f/6e4)}m ago`:f<864e5?`${Math.floor(f/36e5)}h ago`:`${Math.floor(f/864e5)}d ago`)})]}),h&&(0,b.jsx)(O,{item:a})]},`${a.timestamp}-${d}`)})})]})}),(0,b.jsx)(r.default,{currentPage:h,totalPages:V,onPageChange:a=>{i(a),o(null)}})]})]})}function Q({enabled:a,onChange:c,disabled:d}){return(0,b.jsx)("button",{onClick:c,disabled:d,className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors disabled:opacity-40 ${a?"bg-emerald-500":"bg-muted-foreground/30"}`,"aria-label":a?"Disable policy":"Enable policy",children:(0,b.jsx)("span",{className:`inline-block h-3 w-3 rounded-full bg-white shadow transition-transform ${a?"translate-x-3.5":"translate-x-0.5"}`})})}function R({policy:a,onClose:d,onSave:e}){let f=a.params??{},g=a.currentParams??{},[h,i]=(0,c.useState)(()=>{let a={};for(let[b,c]of Object.entries(f)){let d=b in g?g[b]:c.default;a[b]=d}return a});(0,c.useEffect)(()=>{let a=a=>{"Escape"===a.key&&d()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[d]);let j=(a,b)=>{i(c=>({...c,[a]:b}))};return(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:a=>{a.target===a.currentTarget&&d()},children:(0,b.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[80vh] flex flex-col",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"text-sm font-mono font-semibold text-foreground",children:a.name}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:a.description})]}),(0,b.jsx)("button",{onClick:d,className:"text-muted-foreground hover:text-foreground transition-colors",children:(0,b.jsx)(q.X,{className:"h-4 w-4"})})]}),(0,b.jsx)("div",{className:"overflow-y-auto flex-1 px-4 py-4 space-y-4",children:Object.entries(f).map(([a,c])=>(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1 font-mono",children:a}),(0,b.jsx)("p",{className:"text-[0.65rem] text-muted-foreground mb-1.5",children:c.description}),((a,c)=>{let d=h[a];if("boolean"===c.type)return(0,b.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,b.jsx)("input",{type:"checkbox",checked:!!d,onChange:b=>j(a,b.target.checked),className:"rounded border-border"}),(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:c.description})]});if("number"===c.type)return(0,b.jsx)("input",{type:"number",value:"number"==typeof d?d:"",onChange:b=>j(a,Number(b.target.value)),className:"w-full h-7 rounded border border-border bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary/40"});if("string[]"===c.type){let c=Array.isArray(d)?d.join("\n"):"";return(0,b.jsx)("textarea",{value:c,onChange:b=>j(a,b.target.value.split("\n").filter(a=>""!==a.trim())),rows:4,placeholder:"One entry per line",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground font-mono focus:outline-none focus:ring-2 focus:ring-primary/40 resize-y"})}if("pattern[]"===c.type){let c=Array.isArray(d)?d:[];return(0,b.jsxs)("div",{className:"space-y-1.5",children:[c.map((d,e)=>(0,b.jsxs)("div",{className:"flex gap-1.5 items-center",children:[(0,b.jsx)("input",{type:"text",value:d.regex,onChange:b=>{let d=[...c];d[e]={...d[e],regex:b.target.value},j(a,d)},placeholder:"regex",className:"flex-1 h-6 rounded border border-border bg-background px-2 text-xs font-mono focus:outline-none focus:ring-2 focus:ring-primary/40"}),(0,b.jsx)("input",{type:"text",value:d.label,onChange:b=>{let d=[...c];d[e]={...d[e],label:b.target.value},j(a,d)},placeholder:"label",className:"flex-1 h-6 rounded border border-border bg-background px-2 text-xs focus:outline-none focus:ring-2 focus:ring-primary/40"}),(0,b.jsx)("button",{onClick:()=>j(a,c.filter((a,b)=>b!==e)),className:"text-muted-foreground/50 hover:text-destructive transition-colors",children:(0,b.jsx)(q.X,{className:"h-3.5 w-3.5"})})]},e)),(0,b.jsx)("button",{onClick:()=>j(a,[...c,{regex:"",label:""}]),className:"text-xs text-primary hover:underline",children:"+ Add pattern"})]})}return(0,b.jsx)("input",{type:"text",value:"string"==typeof d?d:"",onChange:b=>j(a,b.target.value),className:"w-full h-7 rounded border border-border bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary/40"})})(a,c)]},a))}),(0,b.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,b.jsx)(E.Button,{variant:"outline",size:"sm",onClick:d,className:"h-7 text-xs",children:"Cancel"}),(0,b.jsx)(E.Button,{size:"sm",onClick:()=>e(h),className:"h-7 text-xs",children:"Save"})]})]})})}function S({message:a,onDismiss:c,onInstall:e,isPending:f}){return(0,d.createPortal)((0,b.jsxs)("div",{className:"fixed top-4 right-4 z-[9999] w-full max-w-sm",style:{animation:"slideInFromRight 0.25s ease-out"},children:[(0,b.jsx)("style",{children:`
|
|
2
2
|
@keyframes slideInFromRight {
|
|
3
3
|
from { transform: translateX(calc(100% + 1rem)); opacity: 0; }
|
|
4
4
|
to { transform: translateX(0); opacity: 1; }
|
|
5
5
|
}
|
|
6
|
-
`}),(0,b.jsxs)("div",{className:"rounded-lg border border-red-500/40 bg-red-950/95 shadow-2xl shadow-red-900/40 overflow-hidden backdrop-blur-sm",children:[(0,b.jsx)("div",{className:"h-0.5 w-full bg-gradient-to-r from-red-600 via-red-400 to-red-600"}),(0,b.jsxs)("div",{className:"p-4",children:[(0,b.jsxs)("div",{className:"flex items-start gap-3",children:[(0,b.jsx)("div",{className:"shrink-0 mt-0.5 flex h-5 w-5 items-center justify-center rounded-full bg-red-500 ring-2 ring-red-500/30",children:(0,b.jsx)(q.X,{className:"h-3 w-3 text-white",strokeWidth:3})}),(0,b.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,b.jsx)("p",{className:"text-[0.65rem] font-bold uppercase tracking-widest text-red-400 mb-0.5",children:"Error"}),(0,b.jsx)("p",{className:"text-sm text-red-100 leading-snug",children:a})]}),(0,b.jsx)("button",{onClick:c,className:"shrink-0 -mt-0.5 -mr-0.5 rounded p-0.5 text-red-400/60 transition-colors hover:bg-red-500/20 hover:text-red-200","aria-label":"Dismiss",children:(0,b.jsx)(q.X,{className:"h-4 w-4"})})]}),(0,b.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,b.jsx)(E.Button,{size:"sm",onClick:()=>{c(),e()},disabled:f,className:"h-7 flex-1 border-0 bg-red-500 px-3 text-xs font-semibold text-white hover:bg-red-400 disabled:opacity-50",children:"Install hooks"}),(0,b.jsx)(E.Button,{variant:"ghost",size:"sm",onClick:c,className:"h-7 px-3 text-xs text-red-400 hover:bg-red-500/10 hover:text-red-200",children:"Dismiss"})]})]})]})]}),document.body)}function T({onHooksInstallChange:a}){let[d,e]=(0,c.useState)(null),[f,g]=(0,c.useTransition)(),[h,i]=(0,c.useState)(null),[j,l]=(0,c.useState)(null),[m,n]=(0,c.useState)(null),q=(0,c.useCallback)(async()=>{try{let b=await v();e(b),a?.(b.installedScopes.length>0)}catch{}},[a]);(0,c.useEffect)(()=>{q()},[q]);let r=()=>{g(async()=>{try{i(null),await x("user"),await q()}catch(a){i(a instanceof Error?a.message:"Failed to install hooks.")}})};if(!d)return(0,b.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,b.jsx)("span",{className:"text-sm text-muted-foreground",children:"Loading\\u2026"})});let s=d.installedScopes.length>0,t=Array.from(new Set(d.policies.map(a=>a.category)));return(0,b.jsxs)(b.Fragment,{children:[m&&(0,b.jsx)(R,{policy:m,onClose:()=>n(null),onSave:a=>{if(!m)return;let b=m.name;n(null),g(async()=>{try{i(null),await z(b,a),await q()}catch(a){i(a instanceof Error?a.message:"Failed to save configuration.")}})}}),(0,b.jsxs)("div",{className:"bg-card border border-border rounded-lg overflow-hidden",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-muted/10",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,b.jsx)("span",{className:`h-2 w-2 rounded-full shrink-0 ${s?"bg-emerald-500":"bg-muted-foreground/50"}`}),(0,b.jsx)("span",{className:"text-sm text-foreground",children:s?"Policies installed":"Policies not installed"}),s&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground font-mono hidden sm:inline",children:["· ",d.installedScopes.join(", ")," scope · ",d.settingsPath]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[s&&(0,b.jsx)(E.Button,{variant:"outline",size:"sm",onClick:()=>{g(async()=>{try{i(null),await y("user"),await q()}catch(a){i(a instanceof Error?a.message:"Failed to remove hooks.")}})},disabled:f,className:"text-xs h-7 px-3",children:"Remove"}),(0,b.jsx)(E.Button,{variant:s?"outline":"default",size:"sm",onClick:r,disabled:f,className:"text-xs h-7 px-3",children:s?"Reinstall":"Install policies"})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border/40 bg-muted/5",children:[(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,b.jsx)("span",{className:"font-semibold text-foreground",children:d.enabledPolicies.length})," / ",d.policies.length+(d.customPolicies?.length??0)," ","policies enabled"]}),s&&(0,b.jsxs)("span",{className:"text-[0.65rem] text-muted-foreground/60",children:["· active in ",d.installedScopes.join(", ")," scope"]})]}),h&&(0,b.jsx)("div",{className:"px-4 py-2 bg-red-500/10 border-b border-red-500/20 text-xs text-red-400",children:h}),j&&(0,b.jsx)(S,{message:j,onDismiss:()=>l(null),onInstall:r,isPending:f}),t.map(a=>{let c=d.policies.filter(b=>b.category===a),h=c.filter(a=>a.enabled).length;return(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border/50",children:[(0,b.jsx)("span",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:a}),(0,b.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[h," / ",c.length," enabled"]})]}),c.map(a=>(0,b.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 border-b border-border/20 hover:bg-muted/20 transition-colors",children:[(0,b.jsx)("div",{className:"mt-0.5 shrink-0",children:(0,b.jsx)(Q,{enabled:a.enabled,onChange:()=>{var b,c;return b=a.name,c=a.enabled,void(!d||(!(d.installedScopes.length>0)?l("Policies are not installed. Install policies to continue."):(l(null),e(a=>a?{...a,policies:a.policies.map(a=>a.name===b?{...a,enabled:!c}:a),enabledPolicies:c?a.enabledPolicies.filter(a=>a!==b):[...a.enabledPolicies,b]}:a),g(async()=>{try{await w(b,!c)}catch{i("Failed to save policy change."),q()}}))))},disabled:f})}),(0,b.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0 w-56 shrink-0 mt-0.5",children:[(0,b.jsx)("span",{className:"text-xs font-mono text-foreground truncate",children:a.name}),a.beta&&(0,b.jsx)("span",{className:"shrink-0 text-[0.6rem] px-1 py-0.5 rounded border bg-violet-500/10 text-violet-400 border-violet-500/20",children:"beta"})]}),(0,b.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground leading-relaxed",children:a.description}),a.eventScope&&(0,b.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5 hidden lg:block",children:a.eventScope}),a.params&&Object.keys(a.params).length>0&&(0,b.jsx)("div",{className:"flex flex-wrap gap-1 mt-1.5",children:Object.entries(a.params).map(([c,d])=>{let e=a.currentParams?.[c]??d.default,f=JSON.stringify(e)!==JSON.stringify(d.default);return(0,b.jsxs)("span",{className:`inline-flex items-center gap-1 font-mono text-[0.6rem] px-1.5 py-0.5 rounded border ${f?"bg-primary/10 text-primary/70 border-primary/20":"bg-muted/40 text-muted-foreground/55 border-border/40"}`,children:[(0,b.jsxs)("span",{className:"opacity-70",children:[c,":"]}),(0,b.jsx)("span",{children:function(a,b){if("string[]"===a||"pattern[]"===a){let c=Array.isArray(b)?b:[];return 0===c.length?"none":"pattern[]"===a?`${c.length} pattern${1!==c.length?"s":""}`:1===c.length?String(c[0]).slice(0,24):`${c.length} values`}return"boolean"===a?b?"on":"off":null==b||""===b?"—":String(b).slice(0,32)}(d.type,e)})]},c)})})]}),a.params&&Object.keys(a.params).length>0&&(0,b.jsx)("button",{className:"shrink-0 mt-0.5 text-muted-foreground hover:text-primary transition-colors",onClick:()=>n(a),title:"Edit parameters",children:(0,b.jsx)(o,{className:"h-3.5 w-3.5"})})]},a.name))]},a)}),d.customPoliciesPath&&(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border/50",children:[(0,b.jsx)("span",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:"Custom Policies"}),(0,b.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[d.customPolicies?.length??0," detected"]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/20",children:[(0,b.jsx)(p,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,b.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:d.customPoliciesPath})]}),(0,b.jsxs)("div",{className:"flex items-start gap-2 px-4 py-2.5 border-b border-border/20 bg-muted/10",children:[(0,b.jsx)(k.Shield,{className:"h-3.5 w-3.5 text-muted-foreground/60 shrink-0 mt-0.5"}),(0,b.jsx)("p",{className:"text-[0.7rem] text-muted-foreground/70 leading-relaxed",children:"Custom policies are always active. To add, remove, or reorder them, edit the JS file above."})]}),d.customPolicies?.map(a=>(0,b.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 border-b border-border/20 hover:bg-muted/20 transition-colors",children:[(0,b.jsx)("div",{className:"h-4 w-7 shrink-0 mt-0.5"}),(0,b.jsx)("div",{className:"flex items-center gap-1.5 min-w-0 w-56 shrink-0 mt-0.5",children:(0,b.jsx)("span",{className:"text-xs font-mono text-foreground truncate",children:a.name})}),(0,b.jsxs)("div",{className:"flex-1 min-w-0",children:[a.description&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground leading-relaxed",children:a.description}),a.eventScope&&(0,b.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5 hidden lg:block",children:a.eventScope})]})]},a.name))]})]})]})}function U({activeTab:a,onChange:c}){return(0,b.jsx)("div",{className:"inline-flex items-center rounded-md border border-border bg-muted/30 p-0.5 mb-5",children:[{id:"activity",label:"Activity"},{id:"policies",label:"Configure"}].map(d=>(0,b.jsx)("button",{onClick:()=>c(d.id),className:`px-3 py-1.5 text-xs font-medium rounded transition-all ${a===d.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:d.label},d.id))})}a.s(["default",0,function({initialTab:a="activity"}){let d=(0,B.useUrlParams)(),[f,h]=(0,c.useState)(a),[i,j]=(0,c.useState)(void 0),[k,l]=(0,c.useState)(null);(0,c.useEffect)(()=>{v().then(a=>{j(a.installedScopes.length>0),l({enabled:a.enabledPolicies.length,total:a.policies.length+(a.customPolicies?.length??0)})}).catch(()=>j(void 0))},[]);let m=a=>{h(a),d.setAll({tab:"activity"===a?void 0:a})};return(0,b.jsxs)("div",{className:"min-h-screen bg-background px-4 py-6 sm:px-6 lg:px-10",children:[(0,b.jsxs)("div",{className:"mb-6",children:[(0,b.jsxs)(e.default,{href:"/projects",className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[(0,b.jsx)(g,{className:"h-3.5 w-3.5"}),"Back"]}),(0,b.jsxs)("div",{className:"flex items-center gap-3 mt-3",children:[(0,b.jsx)("h1",{className:"text-2xl font-bold text-foreground tracking-tight",children:"Policies"}),"activity"===f&&(0,b.jsxs)("span",{className:"relative flex h-2.5 w-2.5 mt-0.5",children:[(0,b.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),(0,b.jsx)("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-emerald-500"})]})]}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"activity"===f?(0,b.jsxs)(b.Fragment,{children:["Policy evaluations for Claude",k&&(0,b.jsxs)("span",{className:"text-muted-foreground/60",children:[" · ","enabled policies"," ",(0,b.jsxs)("span",{className:"font-mono text-foreground/70",children:[k.enabled,"/",k.total]})]}),(0,b.jsxs)("span",{className:"block text-xs text-muted-foreground/50 mt-0.5",children:["To configure policies,"," ",(0,b.jsx)("button",{className:"underline underline-offset-2 hover:text-foreground transition-colors",onClick:()=>m("policies"),children:"go here"})]})]}):"Configure Policies"})]}),(0,b.jsx)(U,{activeTab:f,onChange:m}),"activity"===f?(0,b.jsx)(P,{hooksInstalled:i,onSwitchTab:m}):(0,b.jsx)(T,{onHooksInstallChange:j})]})}],22712)}];
|
|
6
|
+
`}),(0,b.jsxs)("div",{className:"rounded-lg border border-red-500/40 bg-red-950/95 shadow-2xl shadow-red-900/40 overflow-hidden backdrop-blur-sm",children:[(0,b.jsx)("div",{className:"h-0.5 w-full bg-gradient-to-r from-red-600 via-red-400 to-red-600"}),(0,b.jsxs)("div",{className:"p-4",children:[(0,b.jsxs)("div",{className:"flex items-start gap-3",children:[(0,b.jsx)("div",{className:"shrink-0 mt-0.5 flex h-5 w-5 items-center justify-center rounded-full bg-red-500 ring-2 ring-red-500/30",children:(0,b.jsx)(q.X,{className:"h-3 w-3 text-white",strokeWidth:3})}),(0,b.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,b.jsx)("p",{className:"text-[0.65rem] font-bold uppercase tracking-widest text-red-400 mb-0.5",children:"Error"}),(0,b.jsx)("p",{className:"text-sm text-red-100 leading-snug",children:a})]}),(0,b.jsx)("button",{onClick:c,className:"shrink-0 -mt-0.5 -mr-0.5 rounded p-0.5 text-red-400/60 transition-colors hover:bg-red-500/20 hover:text-red-200","aria-label":"Dismiss",children:(0,b.jsx)(q.X,{className:"h-4 w-4"})})]}),(0,b.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,b.jsx)(E.Button,{size:"sm",onClick:()=>{c(),e()},disabled:f,className:"h-7 flex-1 border-0 bg-red-500 px-3 text-xs font-semibold text-white hover:bg-red-400 disabled:opacity-50",children:"Install hooks"}),(0,b.jsx)(E.Button,{variant:"ghost",size:"sm",onClick:c,className:"h-7 px-3 text-xs text-red-400 hover:bg-red-500/10 hover:text-red-200",children:"Dismiss"})]})]})]})]}),document.body)}function T({onHooksInstallChange:a}){let[d,e]=(0,c.useState)(null),[f,g]=(0,c.useTransition)(),[h,i]=(0,c.useState)(null),[j,l]=(0,c.useState)(null),[m,n]=(0,c.useState)(null),[q,r]=(0,c.useState)(()=>new Set),s=(0,c.useRef)(!1),t=(0,c.useCallback)(async()=>{try{let b=await v();e(b),a?.(b.clis.some(a=>a.installed))}catch{}},[a]);(0,c.useEffect)(()=>{t()},[t]),(0,c.useEffect)(()=>{d&&(s.current?r(new Set(d.clis.filter(a=>a.installed).map(a=>a.id))):(s.current=!0,r(new Set(d.clis.filter(a=>a.installed||a.detected).map(a=>a.id)))))},[d?.clis]);let u=(0,c.useMemo)(()=>new Set((d?.clis??[]).filter(a=>a.installed).map(a=>a.id)),[d?.clis]),A=(0,c.useMemo)(()=>{let a=[],b=[];for(let c of d?.clis??[]){let d=q.has(c.id);d&&!u.has(c.id)&&a.push(c.id),!d&&u.has(c.id)&&b.push(c.id)}return{toInstall:a,toRemove:b}},[d?.clis,q,u]),B=A.toInstall.length>0||A.toRemove.length>0,C=()=>{let{toInstall:a,toRemove:b}=A;(0!==a.length||0!==b.length)&&g(async()=>{try{i(null),a.length>0&&await x("user",a),b.length>0&&await y("user",b)}catch(a){i(a instanceof Error?a.message:"Failed to apply changes.")}finally{await t()}})};if(!d)return(0,b.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,b.jsx)("span",{className:"text-sm text-muted-foreground",children:"Loading\\u2026"})});let F=d.clis.some(a=>a.installed),G=u.size,H=q.size,I=Array.from(new Set(d.policies.map(a=>a.category)));return(0,b.jsxs)(b.Fragment,{children:[m&&(0,b.jsx)(R,{policy:m,onClose:()=>n(null),onSave:a=>{if(!m)return;let b=m.name;n(null),g(async()=>{try{i(null),await z(b,a),await t()}catch(a){i(a instanceof Error?a.message:"Failed to save configuration.")}})}}),(0,b.jsxs)("div",{className:"bg-card border border-border rounded-lg overflow-hidden",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-4 px-5 py-3.5 border-b border-border/60 bg-muted/10",children:[(0,b.jsxs)("div",{className:"flex items-center gap-3 min-w-0 flex-wrap",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:`h-2 w-2 rounded-full transition-shadow ${F?"bg-emerald-400 shadow-[0_0_8px_rgba(52,211,153,0.6)]":"bg-muted-foreground/40"}`,"aria-hidden":!0}),(0,b.jsx)("span",{className:"text-[0.65rem] uppercase tracking-[0.2em] font-mono text-foreground/90",children:"Integrations"})]}),(0,b.jsx)("span",{className:"text-[0.65rem] font-mono text-muted-foreground/40",children:"·"}),(0,b.jsxs)("div",{className:"text-[0.65rem] uppercase tracking-[0.2em] font-mono text-muted-foreground",children:[(0,b.jsx)("span",{className:"text-foreground tabular-nums",children:G.toString().padStart(2,"0")}),(0,b.jsxs)("span",{className:"opacity-50",children:[" / 0",d.clis.length," active"]})]}),B&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"text-[0.65rem] font-mono text-muted-foreground/40",children:"·"}),(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-[0.65rem] uppercase tracking-[0.2em] font-mono text-pink-400",children:[(0,b.jsx)("span",{className:"h-1 w-1 rounded-full bg-pink-400 animate-pulse"}),A.toInstall.length+A.toRemove.length," pending"]})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,b.jsx)(E.Button,{variant:"outline",size:"sm",onClick:()=>{let a=Array.from(u).filter(a=>q.has(a));0!==a.length&&g(async()=>{try{i(null),await x("user",a)}catch(a){i(a instanceof Error?a.message:"Failed to reinstall.")}finally{await t()}})},disabled:f||0===H,className:"text-xs h-7 px-3 font-mono",children:"Reinstall"}),(0,b.jsx)(E.Button,{variant:"default",size:"sm",onClick:C,disabled:f||!B,className:"text-xs h-7 px-3 font-mono",children:"Apply changes"})]})]}),(0,b.jsx)("div",{className:"divide-y divide-border/30 border-b border-border/60",children:d.clis.map((a,c)=>{let d=q.has(a.id),e=u.has(a.id),g=d!==e,h=(0,D.getCliBadgeClasses)(a.id),i=h.split(" ").find(a=>a.startsWith("text-"))??"text-foreground";return(0,b.jsxs)("label",{className:`group relative flex items-center gap-3 pl-6 pr-5 py-3 cursor-pointer transition-colors hover:bg-muted/15 ${g?"bg-pink-500/[0.04]":""}`,children:[(0,b.jsx)("div",{className:`absolute left-0 top-0 bottom-0 w-[3px] ${i} bg-current transition-opacity ${d?"opacity-100":"opacity-25 group-hover:opacity-60"}`,"aria-hidden":!0}),(0,b.jsx)("div",{className:"font-mono text-[0.65rem] text-muted-foreground/40 tabular-nums w-6 select-none",children:(c+1).toString().padStart(2,"0")}),(0,b.jsxs)("div",{className:"relative shrink-0",children:[(0,b.jsx)("input",{type:"checkbox",checked:d,onChange:()=>{var b;return b=a.id,void r(a=>{let c=new Set(a);return c.has(b)?c.delete(b):c.add(b),c})},disabled:f,className:"sr-only peer","aria-label":`Toggle ${a.label}`}),(0,b.jsx)("div",{className:`h-[18px] w-[18px] rounded-sm border transition-all peer-focus-visible:ring-2 peer-focus-visible:ring-primary/40 ${d?"bg-primary border-primary":"bg-background/50 border-border group-hover:border-foreground/40"}`,children:d&&(0,b.jsx)("svg",{viewBox:"0 0 18 18",className:"h-full w-full text-primary-foreground",fill:"none","aria-hidden":!0,children:(0,b.jsx)("path",{d:"M4 9.5L7.5 12.5L14 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),(0,b.jsx)("div",{className:"min-w-[150px] shrink-0",children:(0,b.jsx)("div",{className:"text-sm font-medium text-foreground",children:a.label})}),(0,b.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[e?(0,b.jsxs)("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-sm text-[0.6rem] uppercase tracking-[0.15em] font-mono border ${h}`,children:[(0,b.jsx)("span",{className:"h-1 w-1 rounded-full bg-current shadow-[0_0_4px_currentColor]"}),"Active"]}):a.detected?(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-sm text-[0.6rem] uppercase tracking-[0.15em] font-mono border border-border/60 text-muted-foreground/80 bg-muted/20",children:[(0,b.jsx)("span",{className:"h-1 w-1 rounded-full bg-current opacity-60"}),"Detected"]}):(0,b.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-sm text-[0.6rem] uppercase tracking-[0.15em] font-mono border border-border/30 text-muted-foreground/40",children:"Inactive"}),g&&(0,b.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-sm text-[0.6rem] uppercase tracking-[0.15em] font-mono border border-pink-500/40 text-pink-400 bg-pink-500/10",children:d?"+ install":"− remove"})]}),(0,b.jsx)("div",{className:"ml-auto hidden lg:block text-[0.7rem] font-mono text-muted-foreground/50 truncate max-w-[420px] group-hover:text-muted-foreground/80 transition-colors",title:a.settingsPath,children:a.settingsPath})]},a.id)})}),(0,b.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border/40 bg-muted/5",children:[(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,b.jsx)("span",{className:"font-semibold text-foreground",children:d.enabledPolicies.length})," / ",d.policies.length+(d.customPolicies?.length??0)," ","policies enabled"]}),F&&(0,b.jsxs)("span",{className:"text-[0.65rem] text-muted-foreground/60",children:["· shared across ",G," active CLI",1===G?"":"s"]})]}),h&&(0,b.jsx)("div",{className:"px-4 py-2 bg-red-500/10 border-b border-red-500/20 text-xs text-red-400",children:h}),j&&(0,b.jsx)(S,{message:j,onDismiss:()=>l(null),onInstall:C,isPending:f}),I.map(a=>{let c=d.policies.filter(b=>b.category===a),h=c.filter(a=>a.enabled).length;return(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border/50",children:[(0,b.jsx)("span",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:a}),(0,b.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[h," / ",c.length," enabled"]})]}),c.map(a=>(0,b.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 border-b border-border/20 hover:bg-muted/20 transition-colors",children:[(0,b.jsx)("div",{className:"mt-0.5 shrink-0",children:(0,b.jsx)(Q,{enabled:a.enabled,onChange:()=>{var b,c;return b=a.name,c=a.enabled,void(!d||(!d.clis.some(a=>a.installed)?l("Policies are not installed. Install policies to continue."):(l(null),e(a=>a?{...a,policies:a.policies.map(a=>a.name===b?{...a,enabled:!c}:a),enabledPolicies:c?a.enabledPolicies.filter(a=>a!==b):[...a.enabledPolicies,b]}:a),g(async()=>{try{await w(b,!c)}catch{i("Failed to save policy change."),t()}}))))},disabled:f})}),(0,b.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0 w-56 shrink-0 mt-0.5",children:[(0,b.jsx)("span",{className:"text-xs font-mono text-foreground truncate",children:a.name}),a.beta&&(0,b.jsx)("span",{className:"shrink-0 text-[0.6rem] px-1 py-0.5 rounded border bg-violet-500/10 text-violet-400 border-violet-500/20",children:"beta"})]}),(0,b.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground leading-relaxed",children:a.description}),a.eventScope&&(0,b.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5 hidden lg:block",children:a.eventScope}),a.params&&Object.keys(a.params).length>0&&(0,b.jsx)("div",{className:"flex flex-wrap gap-1 mt-1.5",children:Object.entries(a.params).map(([c,d])=>{let e=a.currentParams?.[c]??d.default,f=JSON.stringify(e)!==JSON.stringify(d.default);return(0,b.jsxs)("span",{className:`inline-flex items-center gap-1 font-mono text-[0.6rem] px-1.5 py-0.5 rounded border ${f?"bg-primary/10 text-primary/70 border-primary/20":"bg-muted/40 text-muted-foreground/55 border-border/40"}`,children:[(0,b.jsxs)("span",{className:"opacity-70",children:[c,":"]}),(0,b.jsx)("span",{children:function(a,b){if("string[]"===a||"pattern[]"===a){let c=Array.isArray(b)?b:[];return 0===c.length?"none":"pattern[]"===a?`${c.length} pattern${1!==c.length?"s":""}`:1===c.length?String(c[0]).slice(0,24):`${c.length} values`}return"boolean"===a?b?"on":"off":null==b||""===b?"—":String(b).slice(0,32)}(d.type,e)})]},c)})})]}),a.params&&Object.keys(a.params).length>0&&(0,b.jsx)("button",{className:"shrink-0 mt-0.5 text-muted-foreground hover:text-primary transition-colors",onClick:()=>n(a),title:"Edit parameters",children:(0,b.jsx)(o,{className:"h-3.5 w-3.5"})})]},a.name))]},a)}),d.customPoliciesPath&&(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border/50",children:[(0,b.jsx)("span",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:"Custom Policies"}),(0,b.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[d.customPolicies?.length??0," detected"]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/20",children:[(0,b.jsx)(p,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,b.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:d.customPoliciesPath})]}),(0,b.jsxs)("div",{className:"flex items-start gap-2 px-4 py-2.5 border-b border-border/20 bg-muted/10",children:[(0,b.jsx)(k.Shield,{className:"h-3.5 w-3.5 text-muted-foreground/60 shrink-0 mt-0.5"}),(0,b.jsx)("p",{className:"text-[0.7rem] text-muted-foreground/70 leading-relaxed",children:"Custom policies are always active. To add, remove, or reorder them, edit the JS file above."})]}),d.customPolicies?.map(a=>(0,b.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 border-b border-border/20 hover:bg-muted/20 transition-colors",children:[(0,b.jsx)("div",{className:"h-4 w-7 shrink-0 mt-0.5"}),(0,b.jsx)("div",{className:"flex items-center gap-1.5 min-w-0 w-56 shrink-0 mt-0.5",children:(0,b.jsx)("span",{className:"text-xs font-mono text-foreground truncate",children:a.name})}),(0,b.jsxs)("div",{className:"flex-1 min-w-0",children:[a.description&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground leading-relaxed",children:a.description}),a.eventScope&&(0,b.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5 hidden lg:block",children:a.eventScope})]})]},a.name))]})]})]})}function U({activeTab:a,onChange:c}){return(0,b.jsx)("div",{className:"inline-flex items-center rounded-md border border-border bg-muted/30 p-0.5 mb-5",children:[{id:"activity",label:"Activity"},{id:"policies",label:"Configure"}].map(d=>(0,b.jsx)("button",{onClick:()=>c(d.id),className:`px-3 py-1.5 text-xs font-medium rounded transition-all ${a===d.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:d.label},d.id))})}a.s(["default",0,function({initialTab:a="activity"}){let d=(0,B.useUrlParams)(),[f,h]=(0,c.useState)(a),[i,j]=(0,c.useState)(void 0),[k,l]=(0,c.useState)(null);(0,c.useEffect)(()=>{v().then(a=>{j(a.clis.some(a=>a.installed)),l({enabled:a.enabledPolicies.length,total:a.policies.length+(a.customPolicies?.length??0)})}).catch(()=>j(void 0))},[]);let m=a=>{h(a),d.setAll({tab:"activity"===a?void 0:a})};return(0,b.jsxs)("div",{className:"min-h-screen bg-background px-4 py-6 sm:px-6 lg:px-10",children:[(0,b.jsxs)("div",{className:"mb-6",children:[(0,b.jsxs)(e.default,{href:"/projects",className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[(0,b.jsx)(g,{className:"h-3.5 w-3.5"}),"Back"]}),(0,b.jsxs)("div",{className:"flex items-center gap-3 mt-3",children:[(0,b.jsx)("h1",{className:"text-2xl font-bold text-foreground tracking-tight",children:"Policies"}),"activity"===f&&(0,b.jsxs)("span",{className:"relative flex h-2.5 w-2.5 mt-0.5",children:[(0,b.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),(0,b.jsx)("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-emerald-500"})]})]}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"activity"===f?(0,b.jsxs)(b.Fragment,{children:["Policy evaluations for Claude",k&&(0,b.jsxs)("span",{className:"text-muted-foreground/60",children:[" · ","enabled policies"," ",(0,b.jsxs)("span",{className:"font-mono text-foreground/70",children:[k.enabled,"/",k.total]})]}),(0,b.jsxs)("span",{className:"block text-xs text-muted-foreground/50 mt-0.5",children:["To configure policies,"," ",(0,b.jsx)("button",{className:"underline underline-offset-2 hover:text-foreground transition-colors",onClick:()=>m("policies"),children:"go here"})]})]}):"Configure Policies"})]}),(0,b.jsx)(U,{activeTab:f,onChange:m}),"activity"===f?(0,b.jsx)(P,{hooksInstalled:i,onSwitchTab:m}):(0,b.jsx)(T,{onHooksInstallChange:j})]})}],22712)}];
|
|
7
7
|
|
|
8
8
|
//# sourceMappingURL=app_policies_hooks-client_tsx_0q-m0y-._.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module.exports=[62074,a=>{"use strict";var b=a.i(12714),c=a.i(60526),d=a.i(50227),e=a.i(34900),f=a.i(26192),g=a.i(33432),h=a.i(90798),i=a.i(76668);let j=/^session-(\d{4}-\d{2}-\d{2}T\d{2}-\d{2})-([0-9a-f]{8})\.jsonl$/i;async function
|
|
1
|
+
module.exports=[62074,a=>{"use strict";var b=a.i(12714),c=a.i(60526),d=a.i(50227),e=a.i(34900),f=a.i(26192),g=a.i(33432),h=a.i(90798),i=a.i(76668);let j=/^session-(\d{4}-\d{2}-\d{2}T\d{2}-\d{2})-([0-9a-f]{8})\.jsonl$/i,k=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function l(a){try{return await (0,b.readdir)(a,{withFileTypes:!0})}catch{return null}}async function m(a){try{return(await (0,b.stat)(a)).mtime}catch{return null}}async function n(a){let c=null;try{c=await (0,b.open)(a,"r");let d=Buffer.alloc(4096),{bytesRead:e}=await c.read(d,0,4096,0);if(0===e)return null;let f=d.subarray(0,e),g=f.indexOf(10),h=-1===g?e:g;return f.subarray(0,h).toString("utf-8")}catch{return null}finally{c&&await c.close().catch(()=>{})}}async function o(a){try{let c=(await (0,b.readFile)((0,d.join)(a,".project_root"),"utf-8")).trim();return c.length>0?c:null}catch{return null}}async function p(){let a=process.env.GEMINI_SESSIONS_DIR||(0,d.join)((0,c.homedir)(),".gemini","tmp"),b=await l(a);if(!b)return[];let e=[];return await (0,f.batchAll)(b.filter(a=>a.isDirectory()).map(b=>async()=>{let c=(0,d.join)(a,b.name),f=await o(c);if(!f)return;let g=(0,d.join)(c,"chats"),h=await l(g);if(h)for(let a of h){if(!a.isFile()||!j.test(a.name))continue;let b=(0,d.join)(g,a.name),c=await m(b);if(!c)continue;let h=function(a){if(a)try{let b=JSON.parse(a);if("string"!=typeof b.sessionId)return;return k.test(b.sessionId)?b.sessionId:void 0}catch{return}}(await n(b));e.push({filePath:b,sessionFilename:a.name,cwd:f,fileMtime:c,sessionId:h})}}),16),e}async function q(){let a=await p(),b=new Map;for(let c of a){let a=b.get(c.cwd);(!a||c.fileMtime.getTime()>a.mtime.getTime())&&b.set(c.cwd,{mtime:c.fileMtime})}let c=[...b.entries()].map(([a,{mtime:b}])=>({name:(0,h.encodeFolderName)(a),path:a,isDirectory:!0,lastModified:b,lastModifiedFormatted:(0,g.formatDate)(b),cli:["gemini"]}));return c.sort((a,b)=>b.lastModified.getTime()-a.lastModified.getTime()),c}async function r(a){let b=(await p()).filter(b=>b.cwd===a).map(a=>({name:a.sessionFilename,path:a.filePath,lastModified:a.fileMtime,lastModifiedFormatted:(0,g.formatDate)(a.fileMtime),sessionId:a.sessionId,cli:"gemini"}));return b.sort((a,b)=>b.lastModified.getTime()-a.lastModified.getTime()),b}async function s(a){let b;try{b=await p()}catch(a){return(0,i.logWarn)("Failed to scan Gemini sessions:",a),{cwd:null,sessions:[]}}let c=b.filter(b=>(0,h.encodeFolderName)(b.cwd)===a),d=Array.from(new Set(c.map(a=>a.cwd)));if(1!==d.length)return{cwd:null,sessions:[]};let e=c.map(a=>({name:a.sessionFilename,path:a.filePath,lastModified:a.fileMtime,lastModifiedFormatted:(0,g.formatDate)(a.fileMtime),sessionId:a.sessionId,cli:"gemini"}));return e.sort((a,b)=>b.lastModified.getTime()-a.lastModified.getTime()),{cwd:d[0],sessions:e}}let t=(0,e.runtimeCache)(q,30),u=(0,e.runtimeCache)(a=>s(a),30,{maxSize:50});a.s(["getCachedGeminiProjects",0,t,"getCachedGeminiSessionsByEncodedName",0,u,"getGeminiProjects",0,q,"getGeminiSessionsByEncodedName",0,s,"getGeminiSessionsForCwd",0,r])}];
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=lib_gemini-projects_ts_0sl~yqr._.js.map
|