flavor-code 1.4.0-beta.7 → 1.4.0-beta.9

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.
@@ -19,9 +19,9 @@ import {
19
19
  thinkingWindow,
20
20
  transcriptReducer,
21
21
  withTimeout
22
- } from "./chunk-ITKOMJD6.js";
22
+ } from "./chunk-CWCYXOH6.js";
23
23
  import "./chunk-N5MXHJKD.js";
24
- import "./chunk-KQMKY7C5.js";
24
+ import "./chunk-EXOSMO57.js";
25
25
  import {
26
26
  Box_default,
27
27
  ClockContext,
@@ -23,7 +23,7 @@ import {
23
23
  redactConfig,
24
24
  setProjectMcpServerDisabled,
25
25
  updateProtectedFile
26
- } from "./chunk-KQMKY7C5.js";
26
+ } from "./chunk-EXOSMO57.js";
27
27
  import {
28
28
  AuditLogger,
29
29
  appendUsageLog,
@@ -66,7 +66,7 @@ function normalizeProviderError(error) {
66
66
  code = "authentication";
67
67
  } else if (status === 429 || /rate.?limit|overloaded/.test(searchable)) {
68
68
  code = "rate_limit";
69
- } else if (/context|too many tokens|prompt.*long/.test(searchable)) {
69
+ } else if (/context[_\s-]?(?:length|window|overflow)(?:[_\s-]?(?:exceeded|limit))?/.test(searchable) || /maximum context length|too many tokens|prompt.*(?:too )?long/.test(searchable)) {
70
70
  code = "context_overflow";
71
71
  } else if (status === 404 || /model.*not.?found|not.?found.*model/.test(searchable)) {
72
72
  code = "model_not_found";
@@ -8791,6 +8791,8 @@ function modelToolFromZod(name, description, schema) {
8791
8791
  }
8792
8792
  function ensureStrictSchema(schema) {
8793
8793
  const output = { ...schema };
8794
+ delete output.propertyNames;
8795
+ delete output.patternProperties;
8794
8796
  for (const keyword of ["anyOf", "oneOf", "allOf", "prefixItems"]) {
8795
8797
  const branches = schema[keyword];
8796
8798
  if (Array.isArray(branches)) {
@@ -8809,12 +8811,13 @@ function ensureStrictSchema(schema) {
8809
8811
  ]));
8810
8812
  }
8811
8813
  }
8812
- if (schema.type !== "object" || typeof schema.properties !== "object" || schema.properties === null) {
8814
+ if (schema.type !== "object") {
8813
8815
  return output;
8814
8816
  }
8817
+ const sourceProperties = typeof schema.properties === "object" && schema.properties !== null && !Array.isArray(schema.properties) ? schema.properties : {};
8815
8818
  const requiredSet = new Set(Array.isArray(schema.required) ? schema.required : []);
8816
8819
  const properties = {};
8817
- for (const [key, value] of Object.entries(schema.properties)) {
8820
+ for (const [key, value] of Object.entries(sourceProperties)) {
8818
8821
  const child = typeof value === "object" && value !== null ? ensureStrictSchema(value) : value;
8819
8822
  if (requiredSet.has(key) || jsonSchemaAllowsNull(child)) properties[key] = child;
8820
8823
  else properties[key] = { anyOf: [child, { type: "null" }] };
@@ -19980,6 +19983,15 @@ var RegisterManagedToolInputSchema = z31.object({
19980
19983
  "Agent roles allowed to call the generated tool; omit to allow both"
19981
19984
  )
19982
19985
  }).strict();
19986
+ var RegisterManagedToolModelInputSchema = (() => {
19987
+ const schema = jsonSchemaFromZod(RegisterManagedToolInputSchema);
19988
+ const properties = schema.properties;
19989
+ const inputSchema = { ...properties.inputSchema };
19990
+ delete inputSchema.propertyNames;
19991
+ delete inputSchema.patternProperties;
19992
+ inputSchema.additionalProperties = true;
19993
+ return { ...schema, properties: { ...properties, inputSchema } };
19994
+ })();
19983
19995
  var RemoveManagedToolInputSchema = z31.object({
19984
19996
  name: z31.string().regex(TOOL_NAME).describe("Managed tool name to remove"),
19985
19997
  scope: z31.enum(["project", "global"]).optional().describe("Required only when the same name exists in both scopes")
@@ -20125,6 +20137,8 @@ function createManagedToolManagementTools(options) {
20125
20137
  name: "RegisterTool",
20126
20138
  description: "Create a durable custom tool from JSON Schema and async JavaScript, then expose it immediately",
20127
20139
  inputSchema: RegisterManagedToolInputSchema,
20140
+ modelInputSchema: RegisterManagedToolModelInputSchema,
20141
+ modelStrict: false,
20128
20142
  agents: mainOnly,
20129
20143
  paths: (rawInput) => {
20130
20144
  const parsed = RegisterManagedToolInputSchema.safeParse(rawInput);
@@ -25488,7 +25502,12 @@ async function registerConfiguredAdapters(providers, registry, environment, diag
25488
25502
  if (result.llmConfig !== void 0) {
25489
25503
  apiProtocol = result.llmConfig.apiType;
25490
25504
  runtimeName = result.llmConfig.providerId;
25491
- runtimeProvider = providerFromOAuthConfig(result.llmConfig);
25505
+ runtimeProvider = {
25506
+ ...providerFromOAuthConfig(result.llmConfig),
25507
+ ...provider.thinkingEffort === void 0 ? {} : { thinkingEffort: provider.thinkingEffort },
25508
+ ...provider.thinkingBudget === void 0 ? {} : { thinkingBudget: provider.thinkingBudget },
25509
+ ...provider.claudeClient === void 0 ? {} : { claudeClient: provider.claudeClient }
25510
+ };
25492
25511
  effectiveLlm ??= effectiveRuntime(result, credentialId);
25493
25512
  }
25494
25513
  }
@@ -4,7 +4,7 @@ import {
4
4
  message,
5
5
  redactErrorText,
6
6
  redactSecrets
7
- } from "./chunk-ITKOMJD6.js";
7
+ } from "./chunk-CWCYXOH6.js";
8
8
 
9
9
  // src/rpc/server.ts
10
10
  import { createInterface } from "readline";
@@ -37,9 +37,10 @@ var ProviderConfigSchema = z.object({
37
37
  // Defaults to DEFAULT_THINKING_BUDGET; set to 0 to disable the request
38
38
  // parameter. Provider thinking deltas are forwarded whenever they arrive.
39
39
  thinkingBudget: z.number().int().min(0).optional(),
40
- // Reasoning effort requested from the OpenAI Responses protocol. Omitted by
41
- // default so strict compatible gateways never see an unknown parameter.
42
- thinkingEffort: z.enum(["low", "medium", "high"]).optional(),
40
+ // Reasoning effort requested from the OpenAI Responses protocol (sent as
41
+ // reasoning.effort). Omitted by default so strict compatible gateways never
42
+ // see an unknown parameter and the endpoint uses its server-side default.
43
+ thinkingEffort: z.enum(["minimal", "low", "medium", "high", "xhigh"]).optional(),
43
44
  // Send the Claude Code client fingerprint (User-Agent/x-app) with Anthropic requests,
44
45
  // for gateways that restrict the Anthropic protocol to Claude clients.
45
46
  claudeClient: z.boolean().optional(),
package/dist/cli-main.js CHANGED
@@ -3,7 +3,7 @@ import { createRequire } from "node:module"; const require = createRequire(impor
3
3
  import {
4
4
  FlavorRpcServer,
5
5
  TraceRecorder
6
- } from "./chunk-PT72RZVC.js";
6
+ } from "./chunk-D4OD67V6.js";
7
7
  import {
8
8
  staticTaskLines
9
9
  } from "./chunk-RAYH6K2H.js";
@@ -29,7 +29,7 @@ import {
29
29
  redactErrorText,
30
30
  runDoctor,
31
31
  runPalBroker
32
- } from "./chunk-ITKOMJD6.js";
32
+ } from "./chunk-CWCYXOH6.js";
33
33
  import {
34
34
  MEMORY_RESTART_EXIT_CODE
35
35
  } from "./chunk-N5MXHJKD.js";
@@ -41,7 +41,7 @@ import {
41
41
  readRecoverableFile,
42
42
  setProjectSkillDisabled,
43
43
  updateProtectedFile
44
- } from "./chunk-KQMKY7C5.js";
44
+ } from "./chunk-EXOSMO57.js";
45
45
  import {
46
46
  gt,
47
47
  isValidVersion
@@ -749,7 +749,7 @@ async function runEvaluationFile(path, outputPath) {
749
749
  })),
750
750
  ...parsed.maxTokens === void 0 ? {} : { maxTokens: parsed.maxTokens }
751
751
  };
752
- const configured = await import("./load-F4AYLCF6.js").then(({ loadConfig: loadConfig2 }) => loadConfig2({ cwd: workspace, home: process.env.USERPROFILE ?? process.env.HOME ?? workspace }));
752
+ const configured = await import("./load-EW56Q2MM.js").then(({ loadConfig: loadConfig2 }) => loadConfig2({ cwd: workspace, home: process.env.USERPROFILE ?? process.env.HOME ?? workspace }));
753
753
  const environment = createExecutionEnvironment(workspace, configured.config.execution) ?? new LocalExecutionEnvironment();
754
754
  let report;
755
755
  try {
@@ -921,7 +921,7 @@ async function runInteractiveCli(props) {
921
921
  const [{ render, AlternateScreen }, { createElement }, { App }] = await Promise.all([
922
922
  import("./claude-ink-6EZHF64C.js"),
923
923
  import("react"),
924
- import("./app-H2XGMAOY.js")
924
+ import("./app-XEW4ES4R.js")
925
925
  ]);
926
926
  const instance = await render(createElement(
927
927
  AlternateScreen,
@@ -24,6 +24,8 @@ export declare const ProviderConfigSchema: z.ZodObject<{
24
24
  high: "high";
25
25
  low: "low";
26
26
  medium: "medium";
27
+ minimal: "minimal";
28
+ xhigh: "xhigh";
27
29
  }>>;
28
30
  claudeClient: z.ZodOptional<z.ZodBoolean>;
29
31
  apiType: z.ZodOptional<z.ZodEnum<{
@@ -79,6 +81,8 @@ export declare const FlavorConfigSchema: z.ZodObject<{
79
81
  high: "high";
80
82
  low: "low";
81
83
  medium: "medium";
84
+ minimal: "minimal";
85
+ xhigh: "xhigh";
82
86
  }>>;
83
87
  claudeClient: z.ZodOptional<z.ZodBoolean>;
84
88
  apiType: z.ZodOptional<z.ZodEnum<{
@@ -213,9 +213,10 @@ var ProviderConfigSchema = z2.object({
213
213
  // Defaults to DEFAULT_THINKING_BUDGET; set to 0 to disable the request
214
214
  // parameter. Provider thinking deltas are forwarded whenever they arrive.
215
215
  thinkingBudget: z2.number().int().min(0).optional(),
216
- // Reasoning effort requested from the OpenAI Responses protocol. Omitted by
217
- // default so strict compatible gateways never see an unknown parameter.
218
- thinkingEffort: z2.enum(["low", "medium", "high"]).optional(),
216
+ // Reasoning effort requested from the OpenAI Responses protocol (sent as
217
+ // reasoning.effort). Omitted by default so strict compatible gateways never
218
+ // see an unknown parameter and the endpoint uses its server-side default.
219
+ thinkingEffort: z2.enum(["minimal", "low", "medium", "high", "xhigh"]).optional(),
219
220
  // Send the Claude Code client fingerprint (User-Agent/x-app) with Anthropic requests,
220
221
  // for gateways that restrict the Anthropic protocol to Claude clients.
221
222
  claudeClient: z2.boolean().optional(),
@@ -4266,7 +4267,7 @@ function normalizeProviderError(error) {
4266
4267
  code = "authentication";
4267
4268
  } else if (status === 429 || /rate.?limit|overloaded/.test(searchable)) {
4268
4269
  code = "rate_limit";
4269
- } else if (/context|too many tokens|prompt.*long/.test(searchable)) {
4270
+ } else if (/context[_\s-]?(?:length|window|overflow)(?:[_\s-]?(?:exceeded|limit))?/.test(searchable) || /maximum context length|too many tokens|prompt.*(?:too )?long/.test(searchable)) {
4270
4271
  code = "context_overflow";
4271
4272
  } else if (status === 404 || /model.*not.?found|not.?found.*model/.test(searchable)) {
4272
4273
  code = "model_not_found";
@@ -6543,6 +6544,8 @@ function modelToolFromZod(name, description, schema) {
6543
6544
  }
6544
6545
  function ensureStrictSchema(schema) {
6545
6546
  const output = { ...schema };
6547
+ delete output.propertyNames;
6548
+ delete output.patternProperties;
6546
6549
  for (const keyword of ["anyOf", "oneOf", "allOf", "prefixItems"]) {
6547
6550
  const branches = schema[keyword];
6548
6551
  if (Array.isArray(branches)) {
@@ -6561,12 +6564,13 @@ function ensureStrictSchema(schema) {
6561
6564
  ]));
6562
6565
  }
6563
6566
  }
6564
- if (schema.type !== "object" || typeof schema.properties !== "object" || schema.properties === null) {
6567
+ if (schema.type !== "object") {
6565
6568
  return output;
6566
6569
  }
6570
+ const sourceProperties = typeof schema.properties === "object" && schema.properties !== null && !Array.isArray(schema.properties) ? schema.properties : {};
6567
6571
  const requiredSet = new Set(Array.isArray(schema.required) ? schema.required : []);
6568
6572
  const properties = {};
6569
- for (const [key, value] of Object.entries(schema.properties)) {
6573
+ for (const [key, value] of Object.entries(sourceProperties)) {
6570
6574
  const child = typeof value === "object" && value !== null ? ensureStrictSchema(value) : value;
6571
6575
  if (requiredSet.has(key) || jsonSchemaAllowsNull(child)) properties[key] = child;
6572
6576
  else properties[key] = { anyOf: [child, { type: "null" }] };
@@ -21464,6 +21468,15 @@ var RegisterManagedToolInputSchema = z37.object({
21464
21468
  "Agent roles allowed to call the generated tool; omit to allow both"
21465
21469
  )
21466
21470
  }).strict();
21471
+ var RegisterManagedToolModelInputSchema = (() => {
21472
+ const schema = jsonSchemaFromZod(RegisterManagedToolInputSchema);
21473
+ const properties = schema.properties;
21474
+ const inputSchema = { ...properties.inputSchema };
21475
+ delete inputSchema.propertyNames;
21476
+ delete inputSchema.patternProperties;
21477
+ inputSchema.additionalProperties = true;
21478
+ return { ...schema, properties: { ...properties, inputSchema } };
21479
+ })();
21467
21480
  var RemoveManagedToolInputSchema = z37.object({
21468
21481
  name: z37.string().regex(TOOL_NAME).describe("Managed tool name to remove"),
21469
21482
  scope: z37.enum(["project", "global"]).optional().describe("Required only when the same name exists in both scopes")
@@ -21609,6 +21622,8 @@ function createManagedToolManagementTools(options) {
21609
21622
  name: "RegisterTool",
21610
21623
  description: "Create a durable custom tool from JSON Schema and async JavaScript, then expose it immediately",
21611
21624
  inputSchema: RegisterManagedToolInputSchema,
21625
+ modelInputSchema: RegisterManagedToolModelInputSchema,
21626
+ modelStrict: false,
21612
21627
  agents: mainOnly,
21613
21628
  paths: (rawInput) => {
21614
21629
  const parsed = RegisterManagedToolInputSchema.safeParse(rawInput);
@@ -29126,7 +29141,12 @@ async function registerConfiguredAdapters(providers, registry, environment, diag
29126
29141
  if (result.llmConfig !== void 0) {
29127
29142
  apiProtocol = result.llmConfig.apiType;
29128
29143
  runtimeName = result.llmConfig.providerId;
29129
- runtimeProvider = providerFromOAuthConfig(result.llmConfig);
29144
+ runtimeProvider = {
29145
+ ...providerFromOAuthConfig(result.llmConfig),
29146
+ ...provider.thinkingEffort === void 0 ? {} : { thinkingEffort: provider.thinkingEffort },
29147
+ ...provider.thinkingBudget === void 0 ? {} : { thinkingBudget: provider.thinkingBudget },
29148
+ ...provider.claudeClient === void 0 ? {} : { claudeClient: provider.claudeClient }
29149
+ };
29130
29150
  effectiveLlm ??= effectiveRuntime(result, credentialId);
29131
29151
  }
29132
29152
  }
@@ -132,7 +132,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
132
132
 
133
133
  `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=er,s=!Bn.jitless,c=s&&tr.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?ya([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Sa(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!gr(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>br(e,r,Vn())))}),t)}var Ca=F(`$ZodUnion`,(e,t)=>{z.init(e,t),I(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),I(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),I(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),I(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Kn(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Sa(t,r,e,i)):Sa(o,r,e,i)}}),wa=F(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Ca.init(e,t);let n=e._zod.parse;I(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=Wn(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!er(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),Ta=F(`$ZodIntersection`,(e,t)=>{z.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Da(e,t,n)):Da(e,i,a)}});function Ea(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(nr(e)&&nr(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Ea(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Ea(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Da(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),gr(e))return e;let o=Ea(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Oa=F(`$ZodRecord`,(e,t)=>{z.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!nr(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>br(e,r,Vn())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...vr(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...vr(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&hi.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>br(e,r,Vn())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...vr(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...vr(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),ka=F(`$ZodEnum`,(e,t)=>{z.init(e,t);let n=Hn(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>ir.has(typeof e)).map(e=>typeof e==`string`?ar(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Aa=F(`$ZodLiteral`,(e,t)=>{if(z.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?ar(e):e?ar(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),ja=F(`$ZodTransform`,(e,t)=>{z.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new zn(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new Rn;return n.value=i,n.fallback=!0,n}});function Ma(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Na=F(`$ZodOptional`,(e,t)=>{z.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,I(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),I(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Kn(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Ma(e,r)):Ma(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Pa=F(`$ZodExactOptional`,(e,t)=>{Na.init(e,t),I(e._zod,`values`,()=>t.innerType._zod.values),I(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Fa=F(`$ZodNullable`,(e,t)=>{z.init(e,t),I(e._zod,`optin`,()=>t.innerType._zod.optin),I(e._zod,`optout`,()=>t.innerType._zod.optout),I(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Kn(e.source)}|null)$`):void 0}),I(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Ia=F(`$ZodDefault`,(e,t)=>{z.init(e,t),e._zod.optin=`optional`,I(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>La(e,t)):La(r,t)}});function La(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Ra=F(`$ZodPrefault`,(e,t)=>{z.init(e,t),e._zod.optin=`optional`,I(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),za=F(`$ZodNonOptional`,(e,t)=>{z.init(e,t),I(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Ba(t,e)):Ba(i,e)}});function Ba(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Va=F(`$ZodCatch`,(e,t)=>{z.init(e,t),e._zod.optin=`optional`,I(e._zod,`optout`,()=>t.innerType._zod.optout),I(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>br(e,n,Vn()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>br(e,n,Vn()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Ha=F(`$ZodPipe`,(e,t)=>{z.init(e,t),I(e._zod,`values`,()=>t.in._zod.values),I(e._zod,`optin`,()=>t.in._zod.optin),I(e._zod,`optout`,()=>t.out._zod.optout),I(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Ua(e,t.in,n)):Ua(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Ua(e,t.out,n)):Ua(r,t.out,n)}});function Ua(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Wa=F(`$ZodPreprocess`,(e,t)=>{Ha.init(e,t)}),Ga=F(`$ZodReadonly`,(e,t)=>{z.init(e,t),I(e._zod,`propValues`,()=>t.innerType._zod.propValues),I(e._zod,`values`,()=>t.innerType._zod.values),I(e._zod,`optin`,()=>t.innerType?._zod?.optin),I(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Ka):Ka(r)}});function Ka(e){return e.value=Object.freeze(e.value),e}var qa=F(`$ZodCustom`,(e,t)=>{yi.init(e,t),z.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Ja(t,n,r,e));Ja(i,n,r,e)}});function Ja(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Sr(e))}}var Ya,Xa=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Za(){return new Xa}(Ya=globalThis).__zod_globalRegistry??(Ya.__zod_globalRegistry=Za());var Qa=globalThis.__zod_globalRegistry;function $a(e,t){return new e({type:`string`,...L(t)})}function eo(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...L(t)})}function to(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...L(t)})}function no(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...L(t)})}function ro(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...L(t)})}function io(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...L(t)})}function ao(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...L(t)})}function oo(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...L(t)})}function so(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...L(t)})}function co(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...L(t)})}function lo(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...L(t)})}function uo(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...L(t)})}function fo(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...L(t)})}function V(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...L(t)})}function po(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...L(t)})}function mo(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...L(t)})}function ho(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...L(t)})}function go(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...L(t)})}function _o(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...L(t)})}function vo(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...L(t)})}function yo(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...L(t)})}function bo(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...L(t)})}function xo(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...L(t)})}function So(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...L(t)})}function Co(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...L(t)})}function wo(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...L(t)})}function To(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...L(t)})}function Eo(e,t){return new e({type:`number`,checks:[],...L(t)})}function Do(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...L(t)})}function Oo(e,t){return new e({type:`boolean`,...L(t)})}function ko(e){return new e({type:`unknown`})}function Ao(e,t){return new e({type:`never`,...L(t)})}function jo(e,t){return new xi({check:`less_than`,...L(t),value:e,inclusive:!1})}function Mo(e,t){return new xi({check:`less_than`,...L(t),value:e,inclusive:!0})}function No(e,t){return new Si({check:`greater_than`,...L(t),value:e,inclusive:!1})}function Po(e,t){return new Si({check:`greater_than`,...L(t),value:e,inclusive:!0})}function Fo(e,t){return new Ci({check:`multiple_of`,...L(t),value:e})}function Io(e,t){return new Ti({check:`max_length`,...L(t),maximum:e})}function Lo(e,t){return new Ei({check:`min_length`,...L(t),minimum:e})}function Ro(e,t){return new Di({check:`length_equals`,...L(t),length:e})}function zo(e,t){return new ki({check:`string_format`,format:`regex`,...L(t),pattern:e})}function Bo(e){return new Ai({check:`string_format`,format:`lowercase`,...L(e)})}function Vo(e){return new ji({check:`string_format`,format:`uppercase`,...L(e)})}function Ho(e,t){return new Mi({check:`string_format`,format:`includes`,...L(t),includes:e})}function Uo(e,t){return new Ni({check:`string_format`,format:`starts_with`,...L(t),prefix:e})}function Wo(e,t){return new Pi({check:`string_format`,format:`ends_with`,...L(t),suffix:e})}function Go(e){return new Fi({check:`overwrite`,tx:e})}function Ko(e){return Go(t=>t.normalize(e))}function qo(){return Go(e=>e.trim())}function Jo(){return Go(e=>e.toLowerCase())}function Yo(){return Go(e=>e.toUpperCase())}function Xo(){return Go(e=>Qn(e))}function Zo(e,t,n){return new e({type:`array`,element:t,...L(n)})}function Qo(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...L(n)})}function $o(e,t){let n=es(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Sr(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Sr(r))}},e(t.value,t)),t);return n}function es(e,t){let n=new yi({check:`custom`,...L(t)});return n._zod.check=e,n}function ts(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Qa,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function ns(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,ns(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&as(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function rs(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
134
134
 
135
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function is(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:ss(t,`input`,e.processors),output:ss(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function as(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return as(r.element,n);if(r.type===`set`)return as(r.valueType,n);if(r.type===`lazy`)return as(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return as(r.innerType,n);if(r.type===`intersection`)return as(r.left,n)||as(r.right,n);if(r.type===`record`||r.type===`map`)return as(r.keyType,n)||as(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:as(r.in,n)||as(r.out,n);if(r.type===`object`){for(let e in r.shape)if(as(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(as(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(as(e,n))return!0;return!!(r.rest&&as(r.rest,n))}return!1}var os=(e,t={})=>n=>{let r=ts({...n,processors:t});return ns(e,r),rs(r,e),is(r,e)},ss=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ts({...i??{},target:a,io:t,processors:n});return ns(e,o),rs(o,e),is(o,e)},cs={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ls=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=cs[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},us=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},ds=(e,t,n,r)=>{n.type=`boolean`},fs=(e,t,n,r)=>{n.not={}},ps=(e,t,n,r)=>{let i=e._zod.def,a=Hn(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},ms=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},hs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},gs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},_s=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=ns(a.element,t,{...r,path:[...r.path,`items`]})},vs=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=ns(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=ns(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ys=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>ns(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},bs=(e,t,n,r)=>{let i=e._zod.def,a=ns(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=ns(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},xs=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=ns(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=ns(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=ns(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Ss=(e,t,n,r)=>{let i=e._zod.def,a=ns(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Cs=(e,t,n,r)=>{let i=e._zod.def;ns(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ws=(e,t,n,r)=>{let i=e._zod.def;ns(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Ts=(e,t,n,r)=>{let i=e._zod.def;ns(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Es=(e,t,n,r)=>{let i=e._zod.def;ns(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Ds=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;ns(o,t,r);let s=t.seen.get(e);s.ref=o},Os=(e,t,n,r)=>{let i=e._zod.def;ns(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ks=(e,t,n,r)=>{let i=e._zod.def;ns(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},As=F(`ZodISODateTime`,(e,t)=>{Yi.init(e,t),nc.init(e,t)});function js(e){return So(As,e)}var Ms=F(`ZodISODate`,(e,t)=>{Xi.init(e,t),nc.init(e,t)});function Ns(e){return Co(Ms,e)}var Ps=F(`ZodISOTime`,(e,t)=>{Zi.init(e,t),nc.init(e,t)});function Fs(e){return wo(Ps,e)}var Is=F(`ZodISODuration`,(e,t)=>{Qi.init(e,t),nc.init(e,t)});function Ls(e){return To(Is,e)}var Rs=F(`ZodError`,(e,t)=>{wr.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Dr(e,t)},flatten:{value:t=>Er(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Un,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Un,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),zs=Or(Rs),Bs=kr(Rs),Vs=Ar(Rs),Hs=Mr(Rs),Us=Pr(Rs),Ws=Fr(Rs),Gs=Ir(Rs),Ks=Lr(Rs),qs=Rr(Rs),Js=zr(Rs),Ys=Br(Rs),Xs=Vr(Rs),Zs=new WeakMap;function Qs(e,t,n){let r=Object.getPrototypeOf(e),i=Zs.get(r);if(i||(i=new Set,Zs.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var $s=F(`ZodType`,(e,t)=>(z.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:ss(e,`input`),output:ss(e,`output`)}}),e.toJSONSchema=os(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>zs(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Vs(e,t,n),e.parseAsync=async(t,n)=>Bs(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Hs(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Us(e,t,n),e.decode=(t,n)=>Ws(e,t,n),e.encodeAsync=async(t,n)=>Gs(e,t,n),e.decodeAsync=async(t,n)=>Ks(e,t,n),e.safeEncode=(t,n)=>qs(e,t,n),e.safeDecode=(t,n)=>Js(e,t,n),e.safeEncodeAsync=async(t,n)=>Ys(e,t,n),e.safeDecodeAsync=async(t,n)=>Xs(e,t,n),Qs(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Xn(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return or(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(ml(e,t))},superRefine(e,t){return this.check(hl(e,t))},overwrite(e){return this.check(Go(e))},optional(){return Yc(this)},exactOptional(){return Zc(this)},nullable(){return $c(this)},nullish(){return Yc($c(this))},nonoptional(e){return al(this,e)},array(){return Nc(this)},or(e){return Ic([this,e])},and(e){return Bc(this,e)},transform(e){return ll(this,qc(e))},default(e){return tl(this,e)},prefault(e){return rl(this,e)},catch(e){return sl(this,e)},pipe(e){return ll(this,e)},readonly(){return fl(this)},describe(e){let t=this.clone();return Qa.add(t,{description:e}),t},meta(...e){if(e.length===0)return Qa.get(this);let t=this.clone();return Qa.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Qa.get(e)?.description},configurable:!0}),e)),ec=F(`_ZodString`,(e,t)=>{Li.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Qs(e,`_ZodString`,{regex(...e){return this.check(zo(...e))},includes(...e){return this.check(Ho(...e))},startsWith(...e){return this.check(Uo(...e))},endsWith(...e){return this.check(Wo(...e))},min(...e){return this.check(Lo(...e))},max(...e){return this.check(Io(...e))},length(...e){return this.check(Ro(...e))},nonempty(...e){return this.check(Lo(1,...e))},lowercase(e){return this.check(Bo(e))},uppercase(e){return this.check(Vo(e))},trim(){return this.check(qo())},normalize(...e){return this.check(Ko(...e))},toLowerCase(){return this.check(Jo())},toUpperCase(){return this.check(Yo())},slugify(){return this.check(Xo())}})}),tc=F(`ZodString`,(e,t)=>{Li.init(e,t),ec.init(e,t),e.email=t=>e.check(eo(rc,t)),e.url=t=>e.check(oo(sc,t)),e.jwt=t=>e.check(xo(Sc,t)),e.emoji=t=>e.check(so(cc,t)),e.guid=t=>e.check(to(ic,t)),e.uuid=t=>e.check(no(ac,t)),e.uuidv4=t=>e.check(ro(ac,t)),e.uuidv6=t=>e.check(io(ac,t)),e.uuidv7=t=>e.check(ao(ac,t)),e.nanoid=t=>e.check(co(lc,t)),e.guid=t=>e.check(to(ic,t)),e.cuid=t=>e.check(lo(uc,t)),e.cuid2=t=>e.check(uo(dc,t)),e.ulid=t=>e.check(fo(fc,t)),e.base64=t=>e.check(vo(yc,t)),e.base64url=t=>e.check(yo(bc,t)),e.xid=t=>e.check(V(pc,t)),e.ksuid=t=>e.check(po(mc,t)),e.ipv4=t=>e.check(mo(hc,t)),e.ipv6=t=>e.check(ho(gc,t)),e.cidrv4=t=>e.check(go(_c,t)),e.cidrv6=t=>e.check(_o(vc,t)),e.e164=t=>e.check(bo(xc,t)),e.datetime=t=>e.check(js(t)),e.date=t=>e.check(Ns(t)),e.time=t=>e.check(Fs(t)),e.duration=t=>e.check(Ls(t))});function H(e){return $a(tc,e)}var nc=F(`ZodStringFormat`,(e,t)=>{B.init(e,t),ec.init(e,t)}),rc=F(`ZodEmail`,(e,t)=>{Bi.init(e,t),nc.init(e,t)}),ic=F(`ZodGUID`,(e,t)=>{Ri.init(e,t),nc.init(e,t)}),ac=F(`ZodUUID`,(e,t)=>{zi.init(e,t),nc.init(e,t)});function oc(e){return no(ac,e)}var sc=F(`ZodURL`,(e,t)=>{Vi.init(e,t),nc.init(e,t)}),cc=F(`ZodEmoji`,(e,t)=>{Hi.init(e,t),nc.init(e,t)}),lc=F(`ZodNanoID`,(e,t)=>{Ui.init(e,t),nc.init(e,t)}),uc=F(`ZodCUID`,(e,t)=>{Wi.init(e,t),nc.init(e,t)}),dc=F(`ZodCUID2`,(e,t)=>{Gi.init(e,t),nc.init(e,t)}),fc=F(`ZodULID`,(e,t)=>{Ki.init(e,t),nc.init(e,t)}),pc=F(`ZodXID`,(e,t)=>{qi.init(e,t),nc.init(e,t)}),mc=F(`ZodKSUID`,(e,t)=>{Ji.init(e,t),nc.init(e,t)}),hc=F(`ZodIPv4`,(e,t)=>{$i.init(e,t),nc.init(e,t)}),gc=F(`ZodIPv6`,(e,t)=>{ea.init(e,t),nc.init(e,t)}),_c=F(`ZodCIDRv4`,(e,t)=>{ta.init(e,t),nc.init(e,t)}),vc=F(`ZodCIDRv6`,(e,t)=>{na.init(e,t),nc.init(e,t)}),yc=F(`ZodBase64`,(e,t)=>{ia.init(e,t),nc.init(e,t)}),bc=F(`ZodBase64URL`,(e,t)=>{oa.init(e,t),nc.init(e,t)}),xc=F(`ZodE164`,(e,t)=>{sa.init(e,t),nc.init(e,t)}),Sc=F(`ZodJWT`,(e,t)=>{la.init(e,t),nc.init(e,t)}),Cc=F(`ZodNumber`,(e,t)=>{ua.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),Qs(e,`ZodNumber`,{gt(e,t){return this.check(No(e,t))},gte(e,t){return this.check(Po(e,t))},min(e,t){return this.check(Po(e,t))},lt(e,t){return this.check(jo(e,t))},lte(e,t){return this.check(Mo(e,t))},max(e,t){return this.check(Mo(e,t))},int(e){return this.check(Tc(e))},safe(e){return this.check(Tc(e))},positive(e){return this.check(No(0,e))},nonnegative(e){return this.check(Po(0,e))},negative(e){return this.check(jo(0,e))},nonpositive(e){return this.check(Mo(0,e))},multipleOf(e,t){return this.check(Fo(e,t))},step(e,t){return this.check(Fo(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function U(e){return Eo(Cc,e)}var wc=F(`ZodNumberFormat`,(e,t)=>{da.init(e,t),Cc.init(e,t)});function Tc(e){return Do(wc,e)}var Ec=F(`ZodBoolean`,(e,t)=>{fa.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r)});function Dc(e){return Oo(Ec,e)}var Oc=F(`ZodUnknown`,(e,t)=>{pa.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function kc(){return ko(Oc)}var Ac=F(`ZodNever`,(e,t)=>{ma.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r)});function jc(e){return Ao(Ac,e)}var Mc=F(`ZodArray`,(e,t)=>{ga.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(e,t,n,r),e.element=t.element,Qs(e,`ZodArray`,{min(e,t){return this.check(Lo(e,t))},nonempty(e){return this.check(Lo(1,e))},max(e,t){return this.check(Io(e,t))},length(e,t){return this.check(Ro(e,t))},unwrap(){return this.element}})});function Nc(e,t){return Zo(Mc,e,t)}var Pc=F(`ZodObject`,(e,t)=>{xa.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r),I(e,`shape`,()=>t.shape),Qs(e,`ZodObject`,{keyof(){return Wc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:kc()})},loose(){return this.clone({...this._zod.def,catchall:kc()})},strict(){return this.clone({...this._zod.def,catchall:jc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return dr(this,e)},safeExtend(e){return fr(this,e)},merge(e){return pr(this,e)},pick(e){return lr(this,e)},omit(e){return ur(this,e)},partial(...e){return mr(Jc,this,e[0])},required(...e){return hr(il,this,e[0])}})});function W(e,t){return new Pc({type:`object`,shape:e??{},...L(t)})}var Fc=F(`ZodUnion`,(e,t)=>{Ca.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r),e.options=t.options});function Ic(e,t){return new Fc({type:`union`,options:e,...L(t)})}var Lc=F(`ZodDiscriminatedUnion`,(e,t)=>{Fc.init(e,t),wa.init(e,t)});function Rc(e,t,n){return new Lc({type:`union`,options:t,discriminator:e,...L(n)})}var zc=F(`ZodIntersection`,(e,t)=>{Ta.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r)});function Bc(e,t){return new zc({type:`intersection`,left:e,right:t})}var Vc=F(`ZodRecord`,(e,t)=>{Oa.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Hc(e,t,n){return!t||!t._zod?new Vc({type:`record`,keyType:H(),valueType:e,...L(t)}):new Vc({type:`record`,keyType:e,valueType:t,...L(n)})}var Uc=F(`ZodEnum`,(e,t)=>{ka.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Uc({...t,checks:[],...L(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Uc({...t,checks:[],...L(r),entries:i})}});function Wc(e,t){return new Uc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...L(t)})}var Gc=F(`ZodLiteral`,(e,t)=>{Aa.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function G(e,t){return new Gc({type:`literal`,values:Array.isArray(e)?e:[e],...L(t)})}var Kc=F(`ZodTransform`,(e,t)=>{ja.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gs(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new zn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Sr(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Sr(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function qc(e){return new Kc({type:`transform`,transform:e})}var Jc=F(`ZodOptional`,(e,t)=>{Na.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ks(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yc(e){return new Jc({type:`optional`,innerType:e})}var Xc=F(`ZodExactOptional`,(e,t)=>{Pa.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ks(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zc(e){return new Xc({type:`optional`,innerType:e})}var Qc=F(`ZodNullable`,(e,t)=>{Fa.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ss(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function $c(e){return new Qc({type:`nullable`,innerType:e})}var el=F(`ZodDefault`,(e,t)=>{Ia.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ws(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function tl(e,t){return new el({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():rr(t)}})}var nl=F(`ZodPrefault`,(e,t)=>{Ra.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ts(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function rl(e,t){return new nl({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():rr(t)}})}var il=F(`ZodNonOptional`,(e,t)=>{za.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function al(e,t){return new il({type:`nonoptional`,innerType:e,...L(t)})}var ol=F(`ZodCatch`,(e,t)=>{Va.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Es(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function sl(e,t){return new ol({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var cl=F(`ZodPipe`,(e,t)=>{Ha.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ds(e,t,n,r),e.in=t.in,e.out=t.out});function ll(e,t){return new cl({type:`pipe`,in:e,out:t})}var ul=F(`ZodPreprocess`,(e,t)=>{cl.init(e,t),Wa.init(e,t)}),dl=F(`ZodReadonly`,(e,t)=>{Ga.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Os(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function fl(e){return new dl({type:`readonly`,innerType:e})}var pl=F(`ZodCustom`,(e,t)=>{qa.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r)});function ml(e,t={}){return Qo(pl,e,t)}function hl(e,t){return $o(e,t)}function gl(e,t){return new ul({type:`pipe`,in:qc(e),out:t})}var _l=[`default`,`acceptEdits`,`plan`,`bypassPermissions`,`auto`,`bubble`];function vl(e){return e===`safe`||e===`workspace`?`default`:e===`full`?`bypassPermissions`:e}var yl=gl(vl,Wc(_l).default(`default`)),bl=W({type:H(),baseURL:H().url().optional(),apiKey:H().optional(),defaultModel:H().min(1).optional(),cheapModel:H().min(1).optional(),models:Nc(H().min(1)).max(100).optional(),maxOutputTokens:U().int().positive().optional(),thinkingBudget:U().int().min(0).optional(),thinkingEffort:Wc([`low`,`medium`,`high`]).optional(),claudeClient:Dc().optional(),apiType:Wc([`openai`,`anthropic`]).optional(),authorizationUrl:H().url().optional(),tokenUrl:H().url().optional(),clientId:H().min(1).optional(),scope:H().optional()}),xl={disabled:Dc().default(!1),timeoutMs:U().int().min(100).max(30*6e4).default(6e4)},Sl=Ic([W({command:H().min(1),args:Nc(H()).default([]),env:Hc(H(),H()).default({}),cwd:H().min(1).optional(),...xl}).strict(),W({url:H().url().refine(e=>{let t=new URL(e).protocol;return t===`http:`||t===`https:`},`MCP HTTP URLs must use http or https`),headers:Hc(H(),H()).default({}),...xl}).strict()]),Cl=H().min(1).max(32).regex(/^[A-Za-z0-9_-]+$/,`MCP server names may contain only letters, digits, underscores, and hyphens`),wl=H().min(1).max(64).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/,`Skill names must use lowercase letters, digits, and single hyphens`);W({sleep:Dc().default(!1),providers:Hc(H(),bl).default({}),mcpServers:Hc(Cl,Sl).default({}),skills:W({disabled:Nc(wl).max(1e3).default([])}).prefault({}),agents:W({main:W({model:H()}).optional(),subagent:W({model:H()}).optional()}).optional(),maxSubagents:U().int().min(1).max(16).default(3),maxSessions:U().int().min(1).max(1e3).default(50),memory:W({enabled:Dc().default(!0),autoExtract:Dc().default(!0),autoExtractMinChars:U().int().min(200).max(1e5).default(200),scoreThreshold:U().int().min(0).max(12).default(9),autoStoreThreshold:U().int().min(0).max(12).default(11),ignoreStreakLimit:U().int().min(2).max(100).default(5),reviewAutoDismissSeconds:U().int().min(0).max(300).default(5),maxCandidatesPerTask:G(1).default(1),retrievalTopK:U().int().min(1).max(20).default(5),maxEntries:U().int().min(1).max(1e4).default(200),maxEntryChars:U().int().min(32).max(2e4).default(1e3),maxPromptChars:U().int().min(256).max(2e5).default(12e3)}).prefault({}),permissionMode:yl,execution:W({mode:Wc([`local`,`docker`]).default(`local`),image:H().trim().min(1).default(`node:24-bookworm-slim`),network:Dc().default(!1),memory:H().regex(/^[1-9][0-9]*(?:[kKmMgG])?$/).default(`2g`),cpus:U().positive().max(64).default(2)}).prefault({}),language:H().regex(/^[a-z]{2}(-[A-Z]{2})?$/,`language must be a BCP47 tag like zh-CN or en-US`).optional(),hallucination:W({showWarnings:Dc().default(!1),evaluationTimeoutMs:U().int().min(100).max(3e4).default(2e3)}).prefault({}),maxIterations:W({main:U().int().min(10).max(500).default(300),subagent:U().int().min(10).max(200).default(100),softLimitFactor:U().min(.5).max(1).default(.8),extendBy:U().int().min(5).max(100).default(50)}).prefault({}),loop:W({maxCycles:U().int().positive().max(1e4).default(100),maxTokens:U().int().positive().max(2**53-1).default(5e5),isolation:G(`auto`).default(`auto`)}).prefault({}),goal:W({maxRounds:U().int().positive().max(1e4).default(100),maxStallStreak:U().int().positive().max(100).default(3)}).prefault({}),context:W({windowTokens:U().int().positive().default(2e5),reservedOutputTokens:U().int().nonnegative().default(2e4),autoCompactBufferTokens:U().int().nonnegative().default(27e3),warningBufferTokens:U().int().nonnegative().default(2e4),blockingBufferTokens:U().int().nonnegative().default(3e3),microcompactKeepRecentToolResults:U().int().nonnegative().default(5),recentTokens:U().int().nonnegative().default(1e4),recentTextMessages:U().int().nonnegative().default(5),maxRecentTokens:U().int().nonnegative().default(4e4),compactAtChars:U().int().positive().optional(),toolOutputChars:U().int().positive().default(3e4)}).superRefine((e,t)=>{e.reservedOutputTokens>=e.windowTokens&&t.addIssue({code:`custom`,path:[`reservedOutputTokens`],message:`reservedOutputTokens must be below windowTokens`}),e.maxRecentTokens<e.recentTokens&&t.addIssue({code:`custom`,path:[`maxRecentTokens`],message:`maxRecentTokens must be at least recentTokens`})}).prefault({}),incidents:W({enabled:Dc().default(!1),webhookUrl:H().url().optional()}).prefault({}),evolve:W({promptTop:U().int().min(1).max(10).default(3),minRepeats:U().int().min(2).max(100).default(2),testCommand:H().trim().min(1).default(`npm test`),testTimeoutMs:U().int().min(1e3).max(6e5).default(12e4)}).prefault({})});var Tl=[`user`,`feedback`,`project`,`reference`],El=32*1024,Dl=64*1024,Ol=1024,kl=24*1024,Al=56*1024,jl=4*1024,Ml=12*1024,Nl=G(1),K=oc(),Pl=H().trim().min(1).max(64).refine(e=>!/[\p{Cc}\uD800-\uDFFF]/u.test(e),`Identity must contain only printable non-control Unicode`),Fl=Pl,Il=Pl,Ll=H().refine(e=>Buffer.byteLength(e,`utf8`)<=El,`Text must not exceed ${El} UTF-8 bytes`),q=Ll.refine(e=>e.length>0,`Text must not be empty`),J=H().trim().min(1).refine(e=>Buffer.byteLength(e,`utf8`)<=jl,`Completion evidence must not exceed ${jl} UTF-8 bytes`),Y=W({version:Nl,id:K,alias:Fl,projectPath:H().min(1).refine(e=>Buffer.byteLength(e,`utf8`)<=Ol,`Project path must not exceed ${Ol} UTF-8 bytes`),connectedAt:js(),lastSeenAt:js()}).strict();Nc(Y).max(16),W({version:Nl,type:G(`task`),messageId:K,target:Il,goal:q}).strict();var X=W({version:Nl,type:G(`task-event`),messageId:K,taskId:K,senderId:K,recipientId:K,status:Wc([`accepted`,`started`,`progress`,`completed`,`failed`,`cancelled`]),detail:Ll.optional()}).strict(),Z=W({version:Nl,type:G(`delivery-receipt`),messageId:K,status:Wc([`delivered`,`duplicate`,`rejected`]),recipientIds:Nc(K).max(16),error:Ll.optional()}).strict(),Rl=W({palId:K,required:Dc()}).strict(),zl=Nc(Rl).min(2).max(16).superRefine((e,t)=>{let n=new Set;for(let[r,i]of e.entries()){let e=i.palId.toLowerCase();n.has(e)&&t.addIssue({code:`custom`,path:[r,`palId`],message:`Duplicate participant`}),n.add(e)}}),Bl=W({id:H().min(1).max(128),assigneeId:K,description:q,dependsOn:Nc(H().min(1).max(128)).max(32)}).strict(),Vl=W({version:Nl,coWorkId:K,epoch:U().int().positive(),goal:q,participants:Nc(Rl).min(1).max(16),tasks:Nc(Bl).min(1).max(32)}).strict().superRefine((e,t)=>{Buffer.byteLength(JSON.stringify(e),`utf8`)>24576&&t.addIssue({code:`custom`,message:`Encoded plan must not exceed ${kl} UTF-8 bytes`});let n=new Set;for(let[r,i]of e.participants.entries())n.has(i.palId)&&t.addIssue({code:`custom`,path:[`participants`,r,`palId`],message:`Duplicate participant`}),n.add(i.palId);let r=new Set;for(let[i,a]of e.tasks.entries())r.has(a.id)&&t.addIssue({code:`custom`,path:[`tasks`,i,`id`],message:`Duplicate task id`}),r.add(a.id),n.has(a.assigneeId)||t.addIssue({code:`custom`,path:[`tasks`,i,`assigneeId`],message:`Assignee is not a participant`});for(let[n,i]of e.tasks.entries())for(let e of i.dependsOn)(!r.has(e)||e===i.id)&&t.addIssue({code:`custom`,path:[`tasks`,n,`dependsOn`],message:`Invalid task dependency`});let i=new Map(e.tasks.map(e=>[e.id,e.dependsOn])),a=new Set,o=new Set,s=e=>{if(a.has(e))return!0;if(o.has(e))return!1;a.add(e);for(let t of i.get(e)??[])if(i.has(t)&&s(t))return!0;return a.delete(e),o.add(e),!1};for(let[n,r]of e.tasks.entries())if(s(r.id)){t.addIssue({code:`custom`,path:[`tasks`,n,`dependsOn`],message:`Task dependencies must be acyclic`});break}}),Hl=Wc([`proposed`,`planning`,`prepared`,`running`,`verifying`,`completed`,`failed`,`cancelled`]),Ul=W({passed:Dc(),evidence:J}).strict(),Wl=W({participantId:K,passed:Dc(),detail:J.optional()}).strict(),Gl=W({version:Nl,coWorkId:K,epoch:U().int().positive(),phase:Hl,goal:q,participants:Nc(Rl).min(1).max(16),integrationOwnerId:K,acceptedParticipantIds:Nc(K).max(16),planHash:H().regex(/^[a-f0-9]{64}$/).nullable(),plan:Vl.nullable(),planAcceptedParticipantIds:Nc(K).max(16),readyParticipantIds:Nc(K).max(16),completedParticipantIds:Nc(K).max(16),completionAssertions:Nc(Wl).max(16),integration:Ul.nullable()}).strict().superRefine((e,t)=>{Buffer.byteLength(JSON.stringify(e),`utf8`)>57344&&t.addIssue({code:`custom`,message:`Encoded snapshot must not exceed ${Al} UTF-8 bytes`});let n=new Set(e.participants.map(({palId:e})=>e));new Set(e.participants.filter(({required:e})=>e).map(({palId:e})=>e)).has(e.integrationOwnerId)||t.addIssue({code:`custom`,path:[`integrationOwnerId`],message:`Integration owner must be a required participant`});let r=new Set,i=0;for(let[a,o]of e.completionAssertions.entries())n.has(o.participantId)||t.addIssue({code:`custom`,path:[`completionAssertions`,a,`participantId`],message:`Assertion owner must be a participant`}),r.has(o.participantId)&&t.addIssue({code:`custom`,path:[`completionAssertions`,a,`participantId`],message:`Duplicate completion assertion`}),r.add(o.participantId),i+=Buffer.byteLength(o.detail??``,`utf8`);i>12288&&t.addIssue({code:`custom`,path:[`completionAssertions`],message:`Completion assertions must not exceed ${Ml} UTF-8 bytes in aggregate`})}),Kl={version:Nl,requestId:K};Rc(`type`,[W({...Kl,type:G(`register`),authToken:H().regex(/^[a-f0-9]{64}$/).optional(),presence:Y}).strict(),W({...Kl,type:G(`heartbeat`)}).strict(),W({...Kl,type:G(`list`)}).strict(),W({...Kl,type:G(`disconnect`)}).strict(),W({...Kl,type:G(`chat`),messageId:K,target:Il,message:q}).strict(),W({...Kl,type:G(`task`),messageId:K,target:Il,goal:q}).strict(),W({...Kl,type:G(`cowork-propose`),coWorkId:K,goal:q,participants:zl}).strict(),W({...Kl,type:G(`cowork-accept`),coWorkId:K,epoch:U().int().positive()}).strict(),W({...Kl,type:G(`cowork-plan`),plan:Vl}).strict(),W({...Kl,type:G(`cowork-plan-accept`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/)}).strict(),W({...Kl,type:G(`cowork-ready`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/)}).strict(),W({...Kl,type:G(`cowork-complete`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/),passed:Dc(),detail:J.optional()}).strict(),W({...Kl,type:G(`cowork-integration`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/),passed:Dc(),evidence:J}).strict(),W({...Kl,type:G(`cowork-get`),coWorkId:K}).strict(),W({...Kl,type:G(`cowork-cancel`),coWorkId:K,reason:q}).strict()]);var ql=W({version:Nl,type:G(`ok`),requestId:K,data:kc()}).strict(),Jl=W({version:Nl,type:G(`error`),requestId:K,code:Wc([`invalid-request`,`authentication-failed`,`not-found`,`ambiguous-target`,`alias-conflict`,`invalid-transition`,`stale-epoch`,`duplicate`]),message:Ll}).strict(),Yl=Ic([W({version:Nl,type:G(`chat-event`),messageId:K,senderId:K,recipientId:K,message:q}).strict(),X,Z,W({version:Nl,type:G(`cowork-event`),action:Wc([`PROPOSE`,`PLAN`,`START`,`END`,`FAIL`,`CANCEL`]),actorId:K,coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/).nullable(),snapshot:Gl}).strict()]);Rc(`type`,[ql,Jl,W({version:Nl,type:G(`event`),event:Yl}).strict()]),H().refine(e=>Buffer.byteLength(e,`utf8`)<=Dl,`Control frame must not exceed ${Dl} UTF-8 bytes`);var Xl=`model.init.config.login.logout.permissions.skills.plugins.hooks.tasks.finish.compact.clear.help.exit.audit.usage.doctor.loop.goal.evolve.mcp.commit.review.explain.ide.memory.remember.forget.forget-cold.checkpoint.tree.rewind.unrevert.fork.pals.chat.co-work.tool`.split(`.`),Zl={model:`Switch the active model`,init:`Initialize Flavor project files`,config:`Show the resolved configuration`,login:`Authenticate via OAuth PKCE`,logout:`Clear stored OAuth credentials and restore configured models`,permissions:`Change the tool permission mode`,skills:`List discovered skills`,plugins:`List loaded plugins`,hooks:`Show plugin hook status`,tasks:`Show task planning status`,finish:`Complete this task and evaluate long-term memory`,compact:`Compact the conversation context`,clear:`Clear the transcript`,help:`Show available commands`,exit:`Exit Flavor`,audit:`Query tool failure audit log`,usage:`Show cache hit statistics for this session`,doctor:`Diagnose the local runtime, configuration, tools, plugins, and npm access`,loop:`Run a verified autonomous loop toward a goal`,goal:`Run a goal pipeline with adversarial verification`,evolve:`Self-improvement loop: capture failures, suggest fixes, verify with tests`,commit:`Generate a commit message for staged changes and commit after confirmation`,review:`Review uncommitted changes for bugs and risks before committing`,explain:`Explain a symbol for newcomers (AST graph + source + git history)`,mcp:`Manage MCP servers`,ide:`Show the connected IDE and editor context`,memory:`Show long-term project memory`,remember:`Add a long-term memory`,forget:`Remove matching long-term memories`,"forget-cold":`Remove all cold long-term memories and their files`,checkpoint:`Create a workspace and context checkpoint`,tree:`Show the session history tree`,rewind:`Restore a prior session node`,unrevert:`Undo the most recent rewind`,fork:`Continue context from a prior session node`,pals:`List, rename, or inspect active Flavor pals`,chat:`Send a task to another Flavor pal`,"co-work":`Coordinate a shared goal with another Flavor pal`,tool:`Run a registered managed tool with a JSON object`},Ql={name:``,description:``,body:`# Instructions
135
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function is(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:ss(t,`input`,e.processors),output:ss(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function as(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return as(r.element,n);if(r.type===`set`)return as(r.valueType,n);if(r.type===`lazy`)return as(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return as(r.innerType,n);if(r.type===`intersection`)return as(r.left,n)||as(r.right,n);if(r.type===`record`||r.type===`map`)return as(r.keyType,n)||as(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:as(r.in,n)||as(r.out,n);if(r.type===`object`){for(let e in r.shape)if(as(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(as(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(as(e,n))return!0;return!!(r.rest&&as(r.rest,n))}return!1}var os=(e,t={})=>n=>{let r=ts({...n,processors:t});return ns(e,r),rs(r,e),is(r,e)},ss=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ts({...i??{},target:a,io:t,processors:n});return ns(e,o),rs(o,e),is(o,e)},cs={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ls=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=cs[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},us=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},ds=(e,t,n,r)=>{n.type=`boolean`},fs=(e,t,n,r)=>{n.not={}},ps=(e,t,n,r)=>{let i=e._zod.def,a=Hn(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},ms=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},hs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},gs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},_s=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=ns(a.element,t,{...r,path:[...r.path,`items`]})},vs=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=ns(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=ns(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ys=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>ns(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},bs=(e,t,n,r)=>{let i=e._zod.def,a=ns(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=ns(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},xs=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=ns(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=ns(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=ns(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Ss=(e,t,n,r)=>{let i=e._zod.def,a=ns(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Cs=(e,t,n,r)=>{let i=e._zod.def;ns(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ws=(e,t,n,r)=>{let i=e._zod.def;ns(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Ts=(e,t,n,r)=>{let i=e._zod.def;ns(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Es=(e,t,n,r)=>{let i=e._zod.def;ns(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Ds=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;ns(o,t,r);let s=t.seen.get(e);s.ref=o},Os=(e,t,n,r)=>{let i=e._zod.def;ns(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ks=(e,t,n,r)=>{let i=e._zod.def;ns(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},As=F(`ZodISODateTime`,(e,t)=>{Yi.init(e,t),nc.init(e,t)});function js(e){return So(As,e)}var Ms=F(`ZodISODate`,(e,t)=>{Xi.init(e,t),nc.init(e,t)});function Ns(e){return Co(Ms,e)}var Ps=F(`ZodISOTime`,(e,t)=>{Zi.init(e,t),nc.init(e,t)});function Fs(e){return wo(Ps,e)}var Is=F(`ZodISODuration`,(e,t)=>{Qi.init(e,t),nc.init(e,t)});function Ls(e){return To(Is,e)}var Rs=F(`ZodError`,(e,t)=>{wr.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Dr(e,t)},flatten:{value:t=>Er(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Un,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Un,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),zs=Or(Rs),Bs=kr(Rs),Vs=Ar(Rs),Hs=Mr(Rs),Us=Pr(Rs),Ws=Fr(Rs),Gs=Ir(Rs),Ks=Lr(Rs),qs=Rr(Rs),Js=zr(Rs),Ys=Br(Rs),Xs=Vr(Rs),Zs=new WeakMap;function Qs(e,t,n){let r=Object.getPrototypeOf(e),i=Zs.get(r);if(i||(i=new Set,Zs.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var $s=F(`ZodType`,(e,t)=>(z.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:ss(e,`input`),output:ss(e,`output`)}}),e.toJSONSchema=os(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>zs(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Vs(e,t,n),e.parseAsync=async(t,n)=>Bs(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Hs(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Us(e,t,n),e.decode=(t,n)=>Ws(e,t,n),e.encodeAsync=async(t,n)=>Gs(e,t,n),e.decodeAsync=async(t,n)=>Ks(e,t,n),e.safeEncode=(t,n)=>qs(e,t,n),e.safeDecode=(t,n)=>Js(e,t,n),e.safeEncodeAsync=async(t,n)=>Ys(e,t,n),e.safeDecodeAsync=async(t,n)=>Xs(e,t,n),Qs(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Xn(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return or(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(ml(e,t))},superRefine(e,t){return this.check(hl(e,t))},overwrite(e){return this.check(Go(e))},optional(){return Yc(this)},exactOptional(){return Zc(this)},nullable(){return $c(this)},nullish(){return Yc($c(this))},nonoptional(e){return al(this,e)},array(){return Nc(this)},or(e){return Ic([this,e])},and(e){return Bc(this,e)},transform(e){return ll(this,qc(e))},default(e){return tl(this,e)},prefault(e){return rl(this,e)},catch(e){return sl(this,e)},pipe(e){return ll(this,e)},readonly(){return fl(this)},describe(e){let t=this.clone();return Qa.add(t,{description:e}),t},meta(...e){if(e.length===0)return Qa.get(this);let t=this.clone();return Qa.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Qa.get(e)?.description},configurable:!0}),e)),ec=F(`_ZodString`,(e,t)=>{Li.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Qs(e,`_ZodString`,{regex(...e){return this.check(zo(...e))},includes(...e){return this.check(Ho(...e))},startsWith(...e){return this.check(Uo(...e))},endsWith(...e){return this.check(Wo(...e))},min(...e){return this.check(Lo(...e))},max(...e){return this.check(Io(...e))},length(...e){return this.check(Ro(...e))},nonempty(...e){return this.check(Lo(1,...e))},lowercase(e){return this.check(Bo(e))},uppercase(e){return this.check(Vo(e))},trim(){return this.check(qo())},normalize(...e){return this.check(Ko(...e))},toLowerCase(){return this.check(Jo())},toUpperCase(){return this.check(Yo())},slugify(){return this.check(Xo())}})}),tc=F(`ZodString`,(e,t)=>{Li.init(e,t),ec.init(e,t),e.email=t=>e.check(eo(rc,t)),e.url=t=>e.check(oo(sc,t)),e.jwt=t=>e.check(xo(Sc,t)),e.emoji=t=>e.check(so(cc,t)),e.guid=t=>e.check(to(ic,t)),e.uuid=t=>e.check(no(ac,t)),e.uuidv4=t=>e.check(ro(ac,t)),e.uuidv6=t=>e.check(io(ac,t)),e.uuidv7=t=>e.check(ao(ac,t)),e.nanoid=t=>e.check(co(lc,t)),e.guid=t=>e.check(to(ic,t)),e.cuid=t=>e.check(lo(uc,t)),e.cuid2=t=>e.check(uo(dc,t)),e.ulid=t=>e.check(fo(fc,t)),e.base64=t=>e.check(vo(yc,t)),e.base64url=t=>e.check(yo(bc,t)),e.xid=t=>e.check(V(pc,t)),e.ksuid=t=>e.check(po(mc,t)),e.ipv4=t=>e.check(mo(hc,t)),e.ipv6=t=>e.check(ho(gc,t)),e.cidrv4=t=>e.check(go(_c,t)),e.cidrv6=t=>e.check(_o(vc,t)),e.e164=t=>e.check(bo(xc,t)),e.datetime=t=>e.check(js(t)),e.date=t=>e.check(Ns(t)),e.time=t=>e.check(Fs(t)),e.duration=t=>e.check(Ls(t))});function H(e){return $a(tc,e)}var nc=F(`ZodStringFormat`,(e,t)=>{B.init(e,t),ec.init(e,t)}),rc=F(`ZodEmail`,(e,t)=>{Bi.init(e,t),nc.init(e,t)}),ic=F(`ZodGUID`,(e,t)=>{Ri.init(e,t),nc.init(e,t)}),ac=F(`ZodUUID`,(e,t)=>{zi.init(e,t),nc.init(e,t)});function oc(e){return no(ac,e)}var sc=F(`ZodURL`,(e,t)=>{Vi.init(e,t),nc.init(e,t)}),cc=F(`ZodEmoji`,(e,t)=>{Hi.init(e,t),nc.init(e,t)}),lc=F(`ZodNanoID`,(e,t)=>{Ui.init(e,t),nc.init(e,t)}),uc=F(`ZodCUID`,(e,t)=>{Wi.init(e,t),nc.init(e,t)}),dc=F(`ZodCUID2`,(e,t)=>{Gi.init(e,t),nc.init(e,t)}),fc=F(`ZodULID`,(e,t)=>{Ki.init(e,t),nc.init(e,t)}),pc=F(`ZodXID`,(e,t)=>{qi.init(e,t),nc.init(e,t)}),mc=F(`ZodKSUID`,(e,t)=>{Ji.init(e,t),nc.init(e,t)}),hc=F(`ZodIPv4`,(e,t)=>{$i.init(e,t),nc.init(e,t)}),gc=F(`ZodIPv6`,(e,t)=>{ea.init(e,t),nc.init(e,t)}),_c=F(`ZodCIDRv4`,(e,t)=>{ta.init(e,t),nc.init(e,t)}),vc=F(`ZodCIDRv6`,(e,t)=>{na.init(e,t),nc.init(e,t)}),yc=F(`ZodBase64`,(e,t)=>{ia.init(e,t),nc.init(e,t)}),bc=F(`ZodBase64URL`,(e,t)=>{oa.init(e,t),nc.init(e,t)}),xc=F(`ZodE164`,(e,t)=>{sa.init(e,t),nc.init(e,t)}),Sc=F(`ZodJWT`,(e,t)=>{la.init(e,t),nc.init(e,t)}),Cc=F(`ZodNumber`,(e,t)=>{ua.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),Qs(e,`ZodNumber`,{gt(e,t){return this.check(No(e,t))},gte(e,t){return this.check(Po(e,t))},min(e,t){return this.check(Po(e,t))},lt(e,t){return this.check(jo(e,t))},lte(e,t){return this.check(Mo(e,t))},max(e,t){return this.check(Mo(e,t))},int(e){return this.check(Tc(e))},safe(e){return this.check(Tc(e))},positive(e){return this.check(No(0,e))},nonnegative(e){return this.check(Po(0,e))},negative(e){return this.check(jo(0,e))},nonpositive(e){return this.check(Mo(0,e))},multipleOf(e,t){return this.check(Fo(e,t))},step(e,t){return this.check(Fo(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function U(e){return Eo(Cc,e)}var wc=F(`ZodNumberFormat`,(e,t)=>{da.init(e,t),Cc.init(e,t)});function Tc(e){return Do(wc,e)}var Ec=F(`ZodBoolean`,(e,t)=>{fa.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r)});function Dc(e){return Oo(Ec,e)}var Oc=F(`ZodUnknown`,(e,t)=>{pa.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function kc(){return ko(Oc)}var Ac=F(`ZodNever`,(e,t)=>{ma.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r)});function jc(e){return Ao(Ac,e)}var Mc=F(`ZodArray`,(e,t)=>{ga.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(e,t,n,r),e.element=t.element,Qs(e,`ZodArray`,{min(e,t){return this.check(Lo(e,t))},nonempty(e){return this.check(Lo(1,e))},max(e,t){return this.check(Io(e,t))},length(e,t){return this.check(Ro(e,t))},unwrap(){return this.element}})});function Nc(e,t){return Zo(Mc,e,t)}var Pc=F(`ZodObject`,(e,t)=>{xa.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r),I(e,`shape`,()=>t.shape),Qs(e,`ZodObject`,{keyof(){return Wc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:kc()})},loose(){return this.clone({...this._zod.def,catchall:kc()})},strict(){return this.clone({...this._zod.def,catchall:jc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return dr(this,e)},safeExtend(e){return fr(this,e)},merge(e){return pr(this,e)},pick(e){return lr(this,e)},omit(e){return ur(this,e)},partial(...e){return mr(Jc,this,e[0])},required(...e){return hr(il,this,e[0])}})});function W(e,t){return new Pc({type:`object`,shape:e??{},...L(t)})}var Fc=F(`ZodUnion`,(e,t)=>{Ca.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r),e.options=t.options});function Ic(e,t){return new Fc({type:`union`,options:e,...L(t)})}var Lc=F(`ZodDiscriminatedUnion`,(e,t)=>{Fc.init(e,t),wa.init(e,t)});function Rc(e,t,n){return new Lc({type:`union`,options:t,discriminator:e,...L(n)})}var zc=F(`ZodIntersection`,(e,t)=>{Ta.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r)});function Bc(e,t){return new zc({type:`intersection`,left:e,right:t})}var Vc=F(`ZodRecord`,(e,t)=>{Oa.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Hc(e,t,n){return!t||!t._zod?new Vc({type:`record`,keyType:H(),valueType:e,...L(t)}):new Vc({type:`record`,keyType:e,valueType:t,...L(n)})}var Uc=F(`ZodEnum`,(e,t)=>{ka.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Uc({...t,checks:[],...L(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Uc({...t,checks:[],...L(r),entries:i})}});function Wc(e,t){return new Uc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...L(t)})}var Gc=F(`ZodLiteral`,(e,t)=>{Aa.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function G(e,t){return new Gc({type:`literal`,values:Array.isArray(e)?e:[e],...L(t)})}var Kc=F(`ZodTransform`,(e,t)=>{ja.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gs(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new zn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Sr(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Sr(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function qc(e){return new Kc({type:`transform`,transform:e})}var Jc=F(`ZodOptional`,(e,t)=>{Na.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ks(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yc(e){return new Jc({type:`optional`,innerType:e})}var Xc=F(`ZodExactOptional`,(e,t)=>{Pa.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ks(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zc(e){return new Xc({type:`optional`,innerType:e})}var Qc=F(`ZodNullable`,(e,t)=>{Fa.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ss(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function $c(e){return new Qc({type:`nullable`,innerType:e})}var el=F(`ZodDefault`,(e,t)=>{Ia.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ws(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function tl(e,t){return new el({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():rr(t)}})}var nl=F(`ZodPrefault`,(e,t)=>{Ra.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ts(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function rl(e,t){return new nl({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():rr(t)}})}var il=F(`ZodNonOptional`,(e,t)=>{za.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function al(e,t){return new il({type:`nonoptional`,innerType:e,...L(t)})}var ol=F(`ZodCatch`,(e,t)=>{Va.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Es(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function sl(e,t){return new ol({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var cl=F(`ZodPipe`,(e,t)=>{Ha.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ds(e,t,n,r),e.in=t.in,e.out=t.out});function ll(e,t){return new cl({type:`pipe`,in:e,out:t})}var ul=F(`ZodPreprocess`,(e,t)=>{cl.init(e,t),Wa.init(e,t)}),dl=F(`ZodReadonly`,(e,t)=>{Ga.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Os(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function fl(e){return new dl({type:`readonly`,innerType:e})}var pl=F(`ZodCustom`,(e,t)=>{qa.init(e,t),$s.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r)});function ml(e,t={}){return Qo(pl,e,t)}function hl(e,t){return $o(e,t)}function gl(e,t){return new ul({type:`pipe`,in:qc(e),out:t})}var _l=[`default`,`acceptEdits`,`plan`,`bypassPermissions`,`auto`,`bubble`];function vl(e){return e===`safe`||e===`workspace`?`default`:e===`full`?`bypassPermissions`:e}var yl=gl(vl,Wc(_l).default(`default`)),bl=W({type:H(),baseURL:H().url().optional(),apiKey:H().optional(),defaultModel:H().min(1).optional(),cheapModel:H().min(1).optional(),models:Nc(H().min(1)).max(100).optional(),maxOutputTokens:U().int().positive().optional(),thinkingBudget:U().int().min(0).optional(),thinkingEffort:Wc([`minimal`,`low`,`medium`,`high`,`xhigh`]).optional(),claudeClient:Dc().optional(),apiType:Wc([`openai`,`anthropic`]).optional(),authorizationUrl:H().url().optional(),tokenUrl:H().url().optional(),clientId:H().min(1).optional(),scope:H().optional()}),xl={disabled:Dc().default(!1),timeoutMs:U().int().min(100).max(30*6e4).default(6e4)},Sl=Ic([W({command:H().min(1),args:Nc(H()).default([]),env:Hc(H(),H()).default({}),cwd:H().min(1).optional(),...xl}).strict(),W({url:H().url().refine(e=>{let t=new URL(e).protocol;return t===`http:`||t===`https:`},`MCP HTTP URLs must use http or https`),headers:Hc(H(),H()).default({}),...xl}).strict()]),Cl=H().min(1).max(32).regex(/^[A-Za-z0-9_-]+$/,`MCP server names may contain only letters, digits, underscores, and hyphens`),wl=H().min(1).max(64).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/,`Skill names must use lowercase letters, digits, and single hyphens`);W({sleep:Dc().default(!1),providers:Hc(H(),bl).default({}),mcpServers:Hc(Cl,Sl).default({}),skills:W({disabled:Nc(wl).max(1e3).default([])}).prefault({}),agents:W({main:W({model:H()}).optional(),subagent:W({model:H()}).optional()}).optional(),maxSubagents:U().int().min(1).max(16).default(3),maxSessions:U().int().min(1).max(1e3).default(50),memory:W({enabled:Dc().default(!0),autoExtract:Dc().default(!0),autoExtractMinChars:U().int().min(200).max(1e5).default(200),scoreThreshold:U().int().min(0).max(12).default(9),autoStoreThreshold:U().int().min(0).max(12).default(11),ignoreStreakLimit:U().int().min(2).max(100).default(5),reviewAutoDismissSeconds:U().int().min(0).max(300).default(5),maxCandidatesPerTask:G(1).default(1),retrievalTopK:U().int().min(1).max(20).default(5),maxEntries:U().int().min(1).max(1e4).default(200),maxEntryChars:U().int().min(32).max(2e4).default(1e3),maxPromptChars:U().int().min(256).max(2e5).default(12e3)}).prefault({}),permissionMode:yl,execution:W({mode:Wc([`local`,`docker`]).default(`local`),image:H().trim().min(1).default(`node:24-bookworm-slim`),network:Dc().default(!1),memory:H().regex(/^[1-9][0-9]*(?:[kKmMgG])?$/).default(`2g`),cpus:U().positive().max(64).default(2)}).prefault({}),language:H().regex(/^[a-z]{2}(-[A-Z]{2})?$/,`language must be a BCP47 tag like zh-CN or en-US`).optional(),hallucination:W({showWarnings:Dc().default(!1),evaluationTimeoutMs:U().int().min(100).max(3e4).default(2e3)}).prefault({}),maxIterations:W({main:U().int().min(10).max(500).default(300),subagent:U().int().min(10).max(200).default(100),softLimitFactor:U().min(.5).max(1).default(.8),extendBy:U().int().min(5).max(100).default(50)}).prefault({}),loop:W({maxCycles:U().int().positive().max(1e4).default(100),maxTokens:U().int().positive().max(2**53-1).default(5e5),isolation:G(`auto`).default(`auto`)}).prefault({}),goal:W({maxRounds:U().int().positive().max(1e4).default(100),maxStallStreak:U().int().positive().max(100).default(3)}).prefault({}),context:W({windowTokens:U().int().positive().default(2e5),reservedOutputTokens:U().int().nonnegative().default(2e4),autoCompactBufferTokens:U().int().nonnegative().default(27e3),warningBufferTokens:U().int().nonnegative().default(2e4),blockingBufferTokens:U().int().nonnegative().default(3e3),microcompactKeepRecentToolResults:U().int().nonnegative().default(5),recentTokens:U().int().nonnegative().default(1e4),recentTextMessages:U().int().nonnegative().default(5),maxRecentTokens:U().int().nonnegative().default(4e4),compactAtChars:U().int().positive().optional(),toolOutputChars:U().int().positive().default(3e4)}).superRefine((e,t)=>{e.reservedOutputTokens>=e.windowTokens&&t.addIssue({code:`custom`,path:[`reservedOutputTokens`],message:`reservedOutputTokens must be below windowTokens`}),e.maxRecentTokens<e.recentTokens&&t.addIssue({code:`custom`,path:[`maxRecentTokens`],message:`maxRecentTokens must be at least recentTokens`})}).prefault({}),incidents:W({enabled:Dc().default(!1),webhookUrl:H().url().optional()}).prefault({}),evolve:W({promptTop:U().int().min(1).max(10).default(3),minRepeats:U().int().min(2).max(100).default(2),testCommand:H().trim().min(1).default(`npm test`),testTimeoutMs:U().int().min(1e3).max(6e5).default(12e4)}).prefault({})});var Tl=[`user`,`feedback`,`project`,`reference`],El=32*1024,Dl=64*1024,Ol=1024,kl=24*1024,Al=56*1024,jl=4*1024,Ml=12*1024,Nl=G(1),K=oc(),Pl=H().trim().min(1).max(64).refine(e=>!/[\p{Cc}\uD800-\uDFFF]/u.test(e),`Identity must contain only printable non-control Unicode`),Fl=Pl,Il=Pl,Ll=H().refine(e=>Buffer.byteLength(e,`utf8`)<=El,`Text must not exceed ${El} UTF-8 bytes`),q=Ll.refine(e=>e.length>0,`Text must not be empty`),J=H().trim().min(1).refine(e=>Buffer.byteLength(e,`utf8`)<=jl,`Completion evidence must not exceed ${jl} UTF-8 bytes`),Y=W({version:Nl,id:K,alias:Fl,projectPath:H().min(1).refine(e=>Buffer.byteLength(e,`utf8`)<=Ol,`Project path must not exceed ${Ol} UTF-8 bytes`),connectedAt:js(),lastSeenAt:js()}).strict();Nc(Y).max(16),W({version:Nl,type:G(`task`),messageId:K,target:Il,goal:q}).strict();var X=W({version:Nl,type:G(`task-event`),messageId:K,taskId:K,senderId:K,recipientId:K,status:Wc([`accepted`,`started`,`progress`,`completed`,`failed`,`cancelled`]),detail:Ll.optional()}).strict(),Z=W({version:Nl,type:G(`delivery-receipt`),messageId:K,status:Wc([`delivered`,`duplicate`,`rejected`]),recipientIds:Nc(K).max(16),error:Ll.optional()}).strict(),Rl=W({palId:K,required:Dc()}).strict(),zl=Nc(Rl).min(2).max(16).superRefine((e,t)=>{let n=new Set;for(let[r,i]of e.entries()){let e=i.palId.toLowerCase();n.has(e)&&t.addIssue({code:`custom`,path:[r,`palId`],message:`Duplicate participant`}),n.add(e)}}),Bl=W({id:H().min(1).max(128),assigneeId:K,description:q,dependsOn:Nc(H().min(1).max(128)).max(32)}).strict(),Vl=W({version:Nl,coWorkId:K,epoch:U().int().positive(),goal:q,participants:Nc(Rl).min(1).max(16),tasks:Nc(Bl).min(1).max(32)}).strict().superRefine((e,t)=>{Buffer.byteLength(JSON.stringify(e),`utf8`)>24576&&t.addIssue({code:`custom`,message:`Encoded plan must not exceed ${kl} UTF-8 bytes`});let n=new Set;for(let[r,i]of e.participants.entries())n.has(i.palId)&&t.addIssue({code:`custom`,path:[`participants`,r,`palId`],message:`Duplicate participant`}),n.add(i.palId);let r=new Set;for(let[i,a]of e.tasks.entries())r.has(a.id)&&t.addIssue({code:`custom`,path:[`tasks`,i,`id`],message:`Duplicate task id`}),r.add(a.id),n.has(a.assigneeId)||t.addIssue({code:`custom`,path:[`tasks`,i,`assigneeId`],message:`Assignee is not a participant`});for(let[n,i]of e.tasks.entries())for(let e of i.dependsOn)(!r.has(e)||e===i.id)&&t.addIssue({code:`custom`,path:[`tasks`,n,`dependsOn`],message:`Invalid task dependency`});let i=new Map(e.tasks.map(e=>[e.id,e.dependsOn])),a=new Set,o=new Set,s=e=>{if(a.has(e))return!0;if(o.has(e))return!1;a.add(e);for(let t of i.get(e)??[])if(i.has(t)&&s(t))return!0;return a.delete(e),o.add(e),!1};for(let[n,r]of e.tasks.entries())if(s(r.id)){t.addIssue({code:`custom`,path:[`tasks`,n,`dependsOn`],message:`Task dependencies must be acyclic`});break}}),Hl=Wc([`proposed`,`planning`,`prepared`,`running`,`verifying`,`completed`,`failed`,`cancelled`]),Ul=W({passed:Dc(),evidence:J}).strict(),Wl=W({participantId:K,passed:Dc(),detail:J.optional()}).strict(),Gl=W({version:Nl,coWorkId:K,epoch:U().int().positive(),phase:Hl,goal:q,participants:Nc(Rl).min(1).max(16),integrationOwnerId:K,acceptedParticipantIds:Nc(K).max(16),planHash:H().regex(/^[a-f0-9]{64}$/).nullable(),plan:Vl.nullable(),planAcceptedParticipantIds:Nc(K).max(16),readyParticipantIds:Nc(K).max(16),completedParticipantIds:Nc(K).max(16),completionAssertions:Nc(Wl).max(16),integration:Ul.nullable()}).strict().superRefine((e,t)=>{Buffer.byteLength(JSON.stringify(e),`utf8`)>57344&&t.addIssue({code:`custom`,message:`Encoded snapshot must not exceed ${Al} UTF-8 bytes`});let n=new Set(e.participants.map(({palId:e})=>e));new Set(e.participants.filter(({required:e})=>e).map(({palId:e})=>e)).has(e.integrationOwnerId)||t.addIssue({code:`custom`,path:[`integrationOwnerId`],message:`Integration owner must be a required participant`});let r=new Set,i=0;for(let[a,o]of e.completionAssertions.entries())n.has(o.participantId)||t.addIssue({code:`custom`,path:[`completionAssertions`,a,`participantId`],message:`Assertion owner must be a participant`}),r.has(o.participantId)&&t.addIssue({code:`custom`,path:[`completionAssertions`,a,`participantId`],message:`Duplicate completion assertion`}),r.add(o.participantId),i+=Buffer.byteLength(o.detail??``,`utf8`);i>12288&&t.addIssue({code:`custom`,path:[`completionAssertions`],message:`Completion assertions must not exceed ${Ml} UTF-8 bytes in aggregate`})}),Kl={version:Nl,requestId:K};Rc(`type`,[W({...Kl,type:G(`register`),authToken:H().regex(/^[a-f0-9]{64}$/).optional(),presence:Y}).strict(),W({...Kl,type:G(`heartbeat`)}).strict(),W({...Kl,type:G(`list`)}).strict(),W({...Kl,type:G(`disconnect`)}).strict(),W({...Kl,type:G(`chat`),messageId:K,target:Il,message:q}).strict(),W({...Kl,type:G(`task`),messageId:K,target:Il,goal:q}).strict(),W({...Kl,type:G(`cowork-propose`),coWorkId:K,goal:q,participants:zl}).strict(),W({...Kl,type:G(`cowork-accept`),coWorkId:K,epoch:U().int().positive()}).strict(),W({...Kl,type:G(`cowork-plan`),plan:Vl}).strict(),W({...Kl,type:G(`cowork-plan-accept`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/)}).strict(),W({...Kl,type:G(`cowork-ready`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/)}).strict(),W({...Kl,type:G(`cowork-complete`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/),passed:Dc(),detail:J.optional()}).strict(),W({...Kl,type:G(`cowork-integration`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/),passed:Dc(),evidence:J}).strict(),W({...Kl,type:G(`cowork-get`),coWorkId:K}).strict(),W({...Kl,type:G(`cowork-cancel`),coWorkId:K,reason:q}).strict()]);var ql=W({version:Nl,type:G(`ok`),requestId:K,data:kc()}).strict(),Jl=W({version:Nl,type:G(`error`),requestId:K,code:Wc([`invalid-request`,`authentication-failed`,`not-found`,`ambiguous-target`,`alias-conflict`,`invalid-transition`,`stale-epoch`,`duplicate`]),message:Ll}).strict(),Yl=Ic([W({version:Nl,type:G(`chat-event`),messageId:K,senderId:K,recipientId:K,message:q}).strict(),X,Z,W({version:Nl,type:G(`cowork-event`),action:Wc([`PROPOSE`,`PLAN`,`START`,`END`,`FAIL`,`CANCEL`]),actorId:K,coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/).nullable(),snapshot:Gl}).strict()]);Rc(`type`,[ql,Jl,W({version:Nl,type:G(`event`),event:Yl}).strict()]),H().refine(e=>Buffer.byteLength(e,`utf8`)<=Dl,`Control frame must not exceed ${Dl} UTF-8 bytes`);var Xl=`model.init.config.login.logout.permissions.skills.plugins.hooks.tasks.finish.compact.clear.help.exit.audit.usage.doctor.loop.goal.evolve.mcp.commit.review.explain.ide.memory.remember.forget.forget-cold.checkpoint.tree.rewind.unrevert.fork.pals.chat.co-work.tool`.split(`.`),Zl={model:`Switch the active model`,init:`Initialize Flavor project files`,config:`Show the resolved configuration`,login:`Authenticate via OAuth PKCE`,logout:`Clear stored OAuth credentials and restore configured models`,permissions:`Change the tool permission mode`,skills:`List discovered skills`,plugins:`List loaded plugins`,hooks:`Show plugin hook status`,tasks:`Show task planning status`,finish:`Complete this task and evaluate long-term memory`,compact:`Compact the conversation context`,clear:`Clear the transcript`,help:`Show available commands`,exit:`Exit Flavor`,audit:`Query tool failure audit log`,usage:`Show cache hit statistics for this session`,doctor:`Diagnose the local runtime, configuration, tools, plugins, and npm access`,loop:`Run a verified autonomous loop toward a goal`,goal:`Run a goal pipeline with adversarial verification`,evolve:`Self-improvement loop: capture failures, suggest fixes, verify with tests`,commit:`Generate a commit message for staged changes and commit after confirmation`,review:`Review uncommitted changes for bugs and risks before committing`,explain:`Explain a symbol for newcomers (AST graph + source + git history)`,mcp:`Manage MCP servers`,ide:`Show the connected IDE and editor context`,memory:`Show long-term project memory`,remember:`Add a long-term memory`,forget:`Remove matching long-term memories`,"forget-cold":`Remove all cold long-term memories and their files`,checkpoint:`Create a workspace and context checkpoint`,tree:`Show the session history tree`,rewind:`Restore a prior session node`,unrevert:`Undo the most recent rewind`,fork:`Continue context from a prior session node`,pals:`List, rename, or inspect active Flavor pals`,chat:`Send a task to another Flavor pal`,"co-work":`Coordinate a shared goal with another Flavor pal`,tool:`Run a registered managed tool with a JSON object`},Ql={name:``,description:``,body:`# Instructions
136
136
 
137
137
  Describe when and how the agent should use this skill.`,disableModelInvocation:!1};function $l({onClose:e,onError:t}){let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(Ql),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!0),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(!1),y=(0,_.useMemo)(()=>{let e=m.trim().toLowerCase();return e.length===0?n:n.filter(t=>t.name.includes(e)||t.description.toLowerCase().includes(e))},[m,n]),b=n.filter(e=>e.enabled).length,x=c?o.name.trim().length>0||o.description.trim().length>0||o.body!==Ql.body:i!==void 0&&(o.description!==i.description||o.body!==i.body||!!o.disableModelInvocation!==i.disableModelInvocation),S=e=>t(e instanceof Error?e.message:String(e)),C=async e=>{let t=await window.flavorDesktop.listSkills();r(t);let n=e??i?.name??t[0]?.name;n!==void 0&&t.some(e=>e.name===n)?await w(n):c||(a(void 0),s(Ql))},w=async e=>{try{let t=await window.flavorDesktop.getSkill(e);a(t),s({name:t.name,description:t.description,body:t.body,disableModelInvocation:t.disableModelInvocation}),l(!1),v(!1)}catch(e){S(e)}};(0,_.useEffect)(()=>{let e=!0;return window.flavorDesktop.listSkills().then(async t=>{e&&(r(t),t[0]!==void 0&&await w(t[0].name))}).catch(S).finally(()=>{e&&d(!1)}),()=>{e=!1}},[]);let ee=()=>{l(!0),a(void 0),s(Ql),v(!1)},T=async()=>{if(!f){p(!0);try{let e=c?await window.flavorDesktop.createSkill(o):await window.flavorDesktop.updateSkill(i.name,o);l(!1),a(e),s({name:e.name,description:e.description,body:e.body,disableModelInvocation:e.disableModelInvocation}),await C(e.name)}catch(e){S(e)}finally{p(!1)}}},te=async(e,t)=>{r(n=>n.map(n=>n.name===e.name?{...n,enabled:t}:n)),i?.name===e.name&&a({...i,enabled:t});try{await window.flavorDesktop.setSkillEnabled(e.name,t)}catch(n){r(n=>n.map(n=>n.name===e.name?{...n,enabled:!t}:n)),i?.name===e.name&&a({...i,enabled:!t}),S(n)}},ne=async()=>{if(!(i===void 0||f)){p(!0);try{await window.flavorDesktop.deleteSkill(i.name),v(!1),a(void 0),s(Ql);let e=await window.flavorDesktop.listSkills();r(e),e[0]!==void 0&&await w(e[0].name)}catch(e){S(e)}finally{p(!1)}}};return(0,P.jsxs)(`section`,{className:`skill-workbench`,"aria-label":`技能管理`,children:[(0,P.jsxs)(`header`,{className:`skill-workbench-header`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`button`,{className:`skill-back`,onClick:e,"aria-label":`返回对话`,children:`‹`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:`项目能力`}),(0,P.jsx)(`h1`,{children:`技能管理`})]})]}),(0,P.jsxs)(`div`,{className:`skill-health`,children:[(0,P.jsx)(`i`,{}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:b}),` / `,n.length,` 已开启`]})]})]}),(0,P.jsxs)(`div`,{className:`skill-workbench-body`,children:[(0,P.jsxs)(`aside`,{className:`skill-catalog`,children:[(0,P.jsxs)(`div`,{className:`skill-catalog-tools`,children:[(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`⌕`}),(0,P.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),placeholder:`搜索技能`})]}),(0,P.jsxs)(`button`,{className:`skill-create`,onClick:ee,children:[(0,P.jsx)(`span`,{children:`+`}),` 新建技能`]})]}),(0,P.jsxs)(`div`,{className:`skill-list`,"aria-busy":u,children:[u&&(0,P.jsx)(`p`,{className:`skill-list-empty`,children:`正在读取技能…`}),!u&&y.length===0&&(0,P.jsxs)(`div`,{className:`skill-list-empty`,children:[(0,P.jsx)(`strong`,{children:`没有匹配的技能`}),(0,P.jsx)(`span`,{children:`创建一个项目技能,或调整搜索词。`})]}),y.map(e=>(0,P.jsxs)(`article`,{className:`skill-list-item`,"data-selected":!c&&i?.name===e.name,"data-enabled":e.enabled,children:[(0,P.jsxs)(`button`,{className:`skill-select`,onClick:()=>void w(e.name),children:[(0,P.jsx)(`span`,{className:`skill-glyph`,children:e.name.slice(0,1).toUpperCase()}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:e.name}),(0,P.jsx)(`small`,{children:e.description})]})]}),(0,P.jsxs)(`label`,{className:`skill-toggle`,title:e.enabled?`关闭后 Agent 无法读取`:`开启后 Agent 可以读取`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:t=>void te(e,t.target.checked)}),(0,P.jsx)(`span`,{})]})]},e.name))]}),(0,P.jsxs)(`p`,{className:`skill-catalog-note`,children:[`启停状态保存在 `,(0,P.jsx)(`code`,{children:`.flavor/flavor.json`})]})]}),(0,P.jsx)(`main`,{className:`skill-editor`,children:i===void 0&&!c?(0,P.jsxs)(`div`,{className:`skill-editor-empty`,children:[(0,P.jsx)(`span`,{children:`◇`}),(0,P.jsx)(`h2`,{children:`选择或创建一个技能`}),(0,P.jsx)(`p`,{children:`技能会在任务匹配时为 Agent 注入专门的工作说明。`})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`skill-editor-heading`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:c?`新建项目技能`:i?.editable?`项目技能`:i?.source===`global`?`全局技能`:`插件技能`}),(0,P.jsx)(`h2`,{children:c?`定义一项新能力`:i?.name})]}),!c&&i!==void 0&&(0,P.jsxs)(`span`,{className:`skill-status`,"data-enabled":i.enabled,children:[(0,P.jsx)(`i`,{}),i.enabled?`Agent 可读取`:`已隔离`]})]}),!c&&i?.editable===!1&&(0,P.jsx)(`div`,{className:`skill-readonly-note`,children:`此技能由全局目录或插件提供,在此项目中只读。你仍可以为当前项目开启或关闭它。`}),(0,P.jsxs)(`div`,{className:`skill-form`,children:[(0,P.jsxs)(`label`,{children:[(0,P.jsxs)(`span`,{children:[`名称 `,(0,P.jsx)(`small`,{children:`小写字母、数字和连字符`})]}),(0,P.jsx)(`input`,{value:o.name,disabled:!c,onChange:e=>s({...o,name:e.target.value}),placeholder:`code-review`})]}),(0,P.jsxs)(`label`,{children:[(0,P.jsxs)(`span`,{children:[`描述 `,(0,P.jsx)(`small`,{children:`帮助 Agent 判断何时使用`})]}),(0,P.jsx)(`textarea`,{rows:3,value:o.description,disabled:!c&&!i?.editable,onChange:e=>s({...o,description:e.target.value}),placeholder:`在提交代码前检查正确性、安全性与可维护性`})]}),(0,P.jsxs)(`label`,{className:`skill-instructions`,children:[(0,P.jsxs)(`span`,{children:[`SKILL.md 指令 `,(0,P.jsx)(`small`,{children:`支持 Markdown`})]}),(0,P.jsx)(`textarea`,{value:o.body,disabled:!c&&!i?.editable,onChange:e=>s({...o,body:e.target.value}),spellCheck:!1})]}),(0,P.jsxs)(`label`,{className:`manual-invocation`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:!!o.disableModelInvocation,disabled:!c&&!i?.editable,onChange:e=>s({...o,disableModelInvocation:e.target.checked})}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:`仅允许手动调用`}),(0,P.jsxs)(`small`,{children:[`开启技能,但不让 Agent 自动匹配;仍可通过 /`,o.name||`skill-name`,` 调用。`]})]})]})]}),(0,P.jsxs)(`footer`,{className:`skill-editor-actions`,children:[!c&&i?.editable&&(0,P.jsx)(`button`,{className:`skill-delete`,onClick:()=>v(!0),children:`删除技能`}),c&&(0,P.jsx)(`button`,{onClick:()=>{l(!1),C()},children:`取消`}),(c||i?.editable)&&(0,P.jsx)(`button`,{className:`skill-save`,disabled:!x||f||!o.name.trim()||!o.description.trim()||!o.body.trim(),onClick:()=>void T(),children:f?`正在保存…`:c?`创建技能`:`保存更改`})]})]})})]}),g&&i!==void 0&&(0,P.jsx)(`div`,{className:`skill-delete-layer`,children:(0,P.jsxs)(`div`,{className:`skill-delete-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`skill-delete-title`,children:[(0,P.jsx)(`span`,{children:`!`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:`删除项目技能`}),(0,P.jsxs)(`h2`,{id:`skill-delete-title`,children:[`删除“`,i.name,`”?`]}),(0,P.jsx)(`small`,{children:`技能目录及其中的资源会被永久删除,此操作无法撤销。`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`button`,{onClick:()=>v(!1),children:`取消`}),(0,P.jsx)(`button`,{className:`danger`,disabled:f,onClick:()=>void ne(),children:f?`正在删除…`:`删除技能`})]})]})]})})]})}var eu={user:{label:`用户偏好`,hint:`长期稳定的角色、表达和工作偏好`},feedback:{label:`行为反馈`,hint:`希望 Agent 以后持续遵守的纠正`},project:{label:`项目约定`,hint:`不能只靠代码推导出的规则和决策`},reference:{label:`外部引用`,hint:`以后仍会用到的文档或系统入口`}},tu={enabled:!0,path:``,entries:[]},nu={type:`project`,content:``};function ru({heat:e=`normal`,recallTotal:t=0}){return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`memory-heat-badge`,"data-heat":e,children:e}),(0,P.jsxs)(`span`,{className:`memory-recall-count`,children:[`↻ `,t]})]})}function iu({onClose:e,onError:t}){let[n,r]=(0,_.useState)(tu),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(nu),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!0),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(`all`),[y,b]=(0,_.useState)(`all`),[x,S]=(0,_.useState)(!1),C=e=>t(e instanceof Error?e.message:String(e)),w=(0,_.useMemo)(()=>{let e=m.trim().toLocaleLowerCase();return n.entries.filter(t=>(g===`all`||t.type===g)&&(y===`all`||t.heat===y)&&(e.length===0||t.content.toLocaleLowerCase().includes(e)||t.id.includes(e)))},[g,y,m,n.entries]),ee=c?o.content.trim().length>0:i!==void 0&&(o.type!==i.type||o.content!==i.content),T=(e,t)=>{let n=e.entries.find(e=>e.id===t)??e.entries.find(e=>e.id===i?.id)??e.entries[0];a(n),s(n===void 0?nu:{type:n.type,content:n.content})},te=async e=>{let t=await window.flavorDesktop.listMemory();return r(t),T(t,e),t};(0,_.useEffect)(()=>{let e=!0;return window.flavorDesktop.listMemory().then(t=>{e&&(r(t),T(t))}).catch(C).finally(()=>{e&&d(!1)}),()=>{e=!1}},[]);let ne=()=>{l(!0),a(void 0),s(nu),S(!1)},re=e=>{l(!1),a(e),s({type:e.type,content:e.content}),S(!1)},ie=async()=>{if(!(f||o.content.trim().length===0)){p(!0);try{let e=c?await window.flavorDesktop.createMemory(o):await window.flavorDesktop.updateMemory(i.id,o);l(!1),await te(e.id)}catch(e){C(e)}finally{p(!1)}}},ae=async()=>{if(!(i===void 0||f)){p(!0);try{if(!await window.flavorDesktop.deleteMemory(i.id))throw Error(`这条记忆已不存在,请重新载入后再试。`);S(!1),a(void 0),s(nu),await te()}catch(e){C(e)}finally{p(!1)}}},oe=async()=>{let e=n.entries.filter(e=>e.heat===`cold`).length;if(!(e===0||!window.confirm(`删除全部 ${e} 条 cold 记忆?此操作不可撤销。`))){p(!0);try{await window.flavorDesktop.deleteColdMemory(),a(void 0),await te()}catch(e){C(e)}finally{p(!1)}}};return(0,P.jsxs)(`section`,{className:`memory-workbench`,"aria-label":`长期记忆管理`,children:[(0,P.jsxs)(`header`,{className:`memory-workbench-header`,children:[(0,P.jsxs)(`div`,{className:`memory-heading`,children:[(0,P.jsx)(`button`,{className:`memory-back`,onClick:e,"aria-label":`返回对话`,children:`‹`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:`项目上下文`}),(0,P.jsx)(`h1`,{children:`长期记忆`})]})]}),(0,P.jsxs)(`div`,{className:`memory-header-actions`,children:[(0,P.jsxs)(`div`,{className:`memory-ledger-status`,"data-enabled":n.enabled,children:[(0,P.jsx)(`i`,{}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:n.entries.length}),` 条记忆`]})]}),(0,P.jsx)(`button`,{className:`memory-purge-cold`,disabled:f||!n.entries.some(e=>e.heat===`cold`),onClick:()=>void oe(),children:`清理 cold`})]})]}),(0,P.jsxs)(`div`,{className:`memory-workbench-body`,children:[(0,P.jsxs)(`aside`,{className:`memory-catalog`,children:[(0,P.jsxs)(`div`,{className:`memory-catalog-tools`,children:[(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`⌕`}),(0,P.jsx)(`input`,{"aria-label":`搜索记忆`,value:m,onChange:e=>h(e.target.value),placeholder:`搜索记忆`})]}),(0,P.jsxs)(`button`,{className:`memory-create`,onClick:ne,disabled:!n.enabled,children:[(0,P.jsx)(`span`,{children:`+`}),` 新建记忆`]})]}),(0,P.jsxs)(`div`,{className:`memory-index`,"aria-label":`按类型筛选`,children:[(0,P.jsxs)(`button`,{"data-active":g===`all`,onClick:()=>v(`all`),children:[(0,P.jsx)(`span`,{children:`全部`}),(0,P.jsx)(`b`,{children:n.entries.length})]}),Tl.map(e=>(0,P.jsxs)(`button`,{"data-type":e,"data-active":g===e,onClick:()=>v(e),children:[(0,P.jsx)(`span`,{children:eu[e].label}),(0,P.jsx)(`b`,{children:n.entries.filter(t=>t.type===e).length})]},e))]}),(0,P.jsx)(`div`,{className:`memory-heat-index`,"aria-label":`按热度筛选`,children:[`all`,`hot`,`normal`,`cold`].map(e=>(0,P.jsxs)(`button`,{"data-active":y===e,"data-heat":e,onClick:()=>b(e),children:[e===`all`?`全部热度`:e,(0,P.jsx)(`b`,{children:e===`all`?n.entries.length:n.entries.filter(t=>t.heat===e).length})]},e))}),(0,P.jsxs)(`div`,{className:`memory-list`,"aria-busy":u,children:[u&&(0,P.jsx)(`p`,{className:`memory-list-empty`,children:`正在读取记忆…`}),!u&&!n.enabled&&(0,P.jsxs)(`div`,{className:`memory-list-empty`,children:[(0,P.jsx)(`strong`,{children:`长期记忆已关闭`}),(0,P.jsx)(`span`,{children:`在项目配置中将 memory.enabled 设为 true 后可维护。`})]}),!u&&n.enabled&&w.length===0&&(0,P.jsxs)(`div`,{className:`memory-list-empty`,children:[(0,P.jsx)(`strong`,{children:n.entries.length===0?`还没有长期记忆`:`没有匹配项`}),(0,P.jsx)(`span`,{children:n.entries.length===0?`新建一条明确、稳定、以后仍有用的信息。`:`尝试其他关键词或类型。`})]}),w.map(e=>(0,P.jsxs)(`button`,{className:`memory-card`,"data-selected":!c&&i?.id===e.id,"data-type":e.type,onClick:()=>re(e),children:[(0,P.jsxs)(`span`,{className:`memory-card-meta`,children:[(0,P.jsx)(`span`,{className:`memory-card-tab`,children:eu[e.type].label}),(0,P.jsx)(ru,{heat:e.heat,recallTotal:e.recallTotal})]}),(0,P.jsx)(`strong`,{children:e.content}),(0,P.jsx)(`code`,{children:e.id})]},e.id))]}),(0,P.jsxs)(`p`,{className:`memory-catalog-note`,children:[`存储于 `,(0,P.jsx)(`code`,{children:n.path||`.flavor/memory/MEMORY.md`})]})]}),(0,P.jsx)(`main`,{className:`memory-editor`,children:n.enabled?i===void 0&&!c?(0,P.jsxs)(`div`,{className:`memory-editor-empty`,children:[(0,P.jsx)(`span`,{children:`⌁`}),(0,P.jsx)(`h2`,{children:`建立项目的共同记忆`}),(0,P.jsx)(`p`,{children:`保存少量稳定事实。当前指令和仓库内容始终优先。`}),(0,P.jsx)(`button`,{onClick:ne,children:`新建第一条记忆`})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`memory-editor-heading`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:c?`新记忆`:`记忆 ${i?.id}`}),(0,P.jsx)(`h2`,{children:c?`记录一件以后仍有用的事`:eu[o.type].label})]}),(0,P.jsx)(`span`,{className:`memory-type-seal`,"data-type":o.type,children:o.type})]}),(0,P.jsxs)(`div`,{className:`memory-priority-note`,children:[(0,P.jsx)(`span`,{children:`i`}),(0,P.jsx)(`p`,{children:`记忆是历史背景,不是强制指令。新建或修改后,从下一次模型请求开始生效。`})]}),(0,P.jsxs)(`div`,{className:`memory-form`,children:[(0,P.jsxs)(`fieldset`,{children:[(0,P.jsx)(`legend`,{children:`记忆类型`}),(0,P.jsx)(`div`,{className:`memory-type-options`,children:Tl.map(e=>(0,P.jsxs)(`label`,{"data-type":e,"data-selected":o.type===e,children:[(0,P.jsx)(`input`,{type:`radio`,name:`memory-type`,value:e,checked:o.type===e,onChange:()=>s({...o,type:e})}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:eu[e].label}),(0,P.jsx)(`small`,{children:eu[e].hint})]})]},e))})]}),(0,P.jsxs)(`label`,{className:`memory-content-field`,children:[(0,P.jsxs)(`span`,{children:[`内容 `,(0,P.jsx)(`small`,{children:`只写一件事,避免密码、Token 和临时任务状态`})]}),(0,P.jsx)(`textarea`,{autoFocus:!0,value:o.content,maxLength:2e4,onChange:e=>s({...o,content:e.target.value}),placeholder:`例如:不要在未明确要求时创建 Git 提交。`}),(0,P.jsxs)(`em`,{children:[o.content.length,` 字符`]})]})]}),(0,P.jsxs)(`footer`,{className:`memory-editor-actions`,children:[!c&&(0,P.jsx)(`button`,{className:`memory-delete`,onClick:()=>S(!0),children:`删除记忆`}),c&&(0,P.jsx)(`button`,{onClick:()=>{l(!1),te()},children:`取消`}),(0,P.jsx)(`button`,{className:`memory-save`,disabled:!ee||f||o.content.trim().length===0,onClick:()=>void ie(),children:f?`正在保存…`:c?`保存记忆`:`保存更改`})]})]}):(0,P.jsxs)(`div`,{className:`memory-editor-empty`,children:[(0,P.jsx)(`span`,{children:`⊘`}),(0,P.jsx)(`h2`,{children:`长期记忆没有启用`}),(0,P.jsx)(`p`,{children:`启用后才能读取和修改项目记忆。`})]})})]}),x&&i!==void 0&&(0,P.jsx)(`div`,{className:`memory-delete-layer`,children:(0,P.jsxs)(`div`,{className:`memory-delete-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`memory-delete-title`,children:[(0,P.jsx)(`span`,{children:`!`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:`删除长期记忆`}),(0,P.jsxs)(`h2`,{id:`memory-delete-title`,children:[`删除这条`,eu[i.type].label,`?`]}),(0,P.jsx)(`small`,{children:i.content}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`button`,{onClick:()=>S(!1),children:`取消`}),(0,P.jsx)(`button`,{className:`danger`,disabled:f,onClick:()=>void ae(),children:f?`正在删除…`:`删除记忆`})]})]})]})})]})}var au={name:``,transport:`stdio`,enabled:!0,command:``,args:``,env:``,cwd:``,url:``,headers:``,timeoutMs:`60000`};function ou({onClose:e,onError:t}){let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(au),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!0),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(),y=(0,_.useMemo)(()=>{let e=m.trim().toLowerCase();return e===``?n:n.filter(t=>t.name.toLowerCase().includes(e)||t.transport.includes(e))},[m,n]),b=async e=>{let t=await window.flavorDesktop.listMcpServers();r(t);let n=t.find(t=>t.name===e)??t.find(e=>e.name===i)??t[0];n===void 0?t.length===0&&a(void 0):(a(n.name),s(su(n)))};(0,_.useEffect)(()=>{let e=!1;return window.flavorDesktop.listMcpServers().then(t=>{if(e)return;r(t);let n=t[0];n!==void 0&&(a(n.name),s(su(n)))}).catch(n=>{e||t(mu(n))}).finally(()=>{e||d(!1)}),()=>{e=!0}},[]);let x=e=>{l(!1),a(e.name),s(su(e))},S=()=>{l(!0),a(void 0),s(au)},C=async()=>{p(!0);try{let e=await window.flavorDesktop.saveMcpServer(c?void 0:i,cu(o));l(!1),a(e.name),await b(e.name)}catch(e){t(mu(e))}finally{p(!1)}},w=async(e,n)=>{try{let t=await window.flavorDesktop.setMcpServerEnabled(e.name,n);r(e=>e.map(e=>e.name===t.name?t:e)),i===t.name&&s(su(t))}catch(e){t(mu(e))}},ee=async()=>{let e=g;if(e!==void 0){p(!0);try{await window.flavorDesktop.deleteMcpServer(e.name),v(void 0),l(!1),a(void 0),s(au),await b()}catch(e){t(mu(e))}finally{p(!1)}}},T=n.find(e=>e.name===i);return(0,P.jsxs)(`section`,{className:`mcp-workbench`,"aria-label":`MCP 服务管理`,children:[(0,P.jsxs)(`header`,{className:`mcp-workbench-header`,children:[(0,P.jsxs)(`div`,{className:`mcp-heading`,children:[(0,P.jsx)(`button`,{className:`mcp-back`,onClick:e,"aria-label":`返回对话`,children:`‹`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:`PROJECT CONNECTIONS`}),(0,P.jsx)(`h1`,{children:`MCP 服务`})]})]}),(0,P.jsxs)(`div`,{className:`mcp-health`,children:[(0,P.jsx)(`i`,{}),`项目配置 `,(0,P.jsx)(`strong`,{children:n.filter(e=>e.enabled).length}),` 已开启`]})]}),(0,P.jsxs)(`div`,{className:`mcp-workbench-body`,children:[(0,P.jsxs)(`aside`,{className:`mcp-catalog`,children:[(0,P.jsxs)(`div`,{className:`mcp-catalog-tools`,children:[(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`⌕`}),(0,P.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),placeholder:`搜索服务`,"aria-label":`搜索服务`})]}),(0,P.jsxs)(`button`,{className:`mcp-create`,onClick:S,children:[(0,P.jsx)(`span`,{children:`+`}),`添加服务`]})]}),(0,P.jsx)(`div`,{className:`mcp-list`,children:u?(0,P.jsxs)(`div`,{className:`mcp-list-empty`,children:[(0,P.jsx)(`strong`,{children:`正在读取项目配置`}),(0,P.jsx)(`span`,{children:`.flavor/flavor.json`})]}):y.length===0?(0,P.jsxs)(`div`,{className:`mcp-list-empty`,children:[(0,P.jsx)(`strong`,{children:m?`没有匹配的服务`:`还没有项目 MCP 服务`}),(0,P.jsx)(`span`,{children:m?`尝试其他名称或传输类型`:`添加 stdio 或 Streamable HTTP 服务`})]}):y.map(e=>(0,P.jsxs)(`div`,{className:`mcp-list-item`,"data-selected":!c&&i===e.name,"data-transport":e.transport,"data-enabled":e.enabled,children:[(0,P.jsxs)(`button`,{className:`mcp-select`,onClick:()=>x(e),children:[(0,P.jsx)(`span`,{className:`mcp-transport-glyph`,children:e.transport===`stdio`?`>_`:`↗`}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:e.name}),(0,P.jsx)(`small`,{children:e.transport===`stdio`?fu(e.config):pu(e.config)})]})]}),(0,P.jsxs)(`label`,{className:`mcp-toggle`,title:e.enabled?`关闭服务`:`开启服务`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:t=>void w(e,t.target.checked),"aria-label":`${e.enabled?`关闭`:`开启`} ${e.name}`}),(0,P.jsx)(`span`,{})]})]},e.name))}),(0,P.jsxs)(`p`,{className:`mcp-catalog-note`,children:[`仅管理项目配置 `,(0,P.jsx)(`code`,{children:`.flavor/flavor.json`})]})]}),(0,P.jsx)(`article`,{className:`mcp-editor`,children:c||T!==void 0?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`mcp-editor-heading`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:c?`NEW CONNECTION`:`SERVICE CONFIGURATION`}),(0,P.jsx)(`h2`,{children:c?`添加 MCP 服务`:i})]}),(0,P.jsx)(`span`,{className:`mcp-transport-seal`,"data-transport":o.transport,children:o.transport})]}),(0,P.jsxs)(`div`,{className:`mcp-lifecycle-note`,children:[(0,P.jsx)(`span`,{children:`↻`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:`从下一个任务开始生效`}),(0,P.jsx)(`small`,{children:`现有对话不会因配置更改而中断。`})]})]}),(0,P.jsxs)(`form`,{className:`mcp-form`,onSubmit:e=>{e.preventDefault(),C()},children:[(0,P.jsxs)(`div`,{className:`mcp-form-grid`,children:[(0,P.jsxs)(`label`,{children:[(0,P.jsxs)(`span`,{children:[`服务名称 `,(0,P.jsx)(`small`,{children:`字母、数字、_ 或 -`})]}),(0,P.jsx)(`input`,{value:o.name,onChange:e=>s({...o,name:e.target.value}),required:!0,pattern:`[A-Za-z0-9_-]+`})]}),(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`传输方式`}),(0,P.jsxs)(`select`,{value:o.transport,onChange:e=>s({...o,transport:e.target.value}),children:[(0,P.jsx)(`option`,{value:`stdio`,children:`stdio · 本地进程`}),(0,P.jsx)(`option`,{value:`http`,children:`HTTP · 远程服务`})]})]})]}),o.transport===`stdio`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`启动命令`}),(0,P.jsx)(`input`,{value:o.command,onChange:e=>s({...o,command:e.target.value}),placeholder:`npx`,required:!0})]}),(0,P.jsxs)(`label`,{children:[(0,P.jsxs)(`span`,{children:[`参数 `,(0,P.jsx)(`small`,{children:`每行一个参数`})]}),(0,P.jsx)(`textarea`,{rows:4,value:o.args,onChange:e=>s({...o,args:e.target.value}),placeholder:`-y
138
138
  @modelcontextprotocol/server-filesystem
@@ -147,7 +147,7 @@ Describe when and how the agent should use this skill.`,disableModelInvocation:!
147
147
  `).length+3)),value:Ce,onChange:e=>we(e.target.value),onDoubleClick:e=>e.stopPropagation(),spellCheck:!1})]}):(0,P.jsx)(un,{text:Mu(e)})},e.id)})??(O.prdMarkdown!==void 0&&(0,P.jsx)(un,{text:O.prdMarkdown}))}),(0,P.jsxs)(`section`,{className:`d2c-prd-regenerate`,children:[(0,P.jsx)(`header`,{children:(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:`需要整体调整?`}),(0,P.jsx)(`span`,{children:`描述期望变化,AI 会基于当前 PRD 生成一份新草案。`})]})}),(0,P.jsx)(`textarea`,{rows:3,value:ye,"aria-label":`PRD 重新生成要求`,placeholder:`例如:保留现有范围,补充退款失败后的恢复流程`,onChange:e=>be(e.target.value)}),(0,P.jsxs)(`footer`,{children:[(0,P.jsx)(`span`,{children:`当前版本不会在生成过程中被覆盖`}),(0,P.jsxs)(`button`,{type:`button`,className:`d2c-prd-regenerate-button`,disabled:Te||s||ye.trim().length===0,onClick:()=>void sn(),children:[(0,P.jsx)(`i`,{"aria-hidden":`true`,children:`↻`}),`重新生成 PRD`]})]})]}),(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`退回意见`}),(0,P.jsx)(`textarea`,{rows:3,value:_e,placeholder:`例如:补充退款失败后的恢复路径`,onChange:e=>ve(e.target.value)})]}),(0,P.jsxs)(`div`,{className:`d2c-artifact-actions`,children:[(0,P.jsx)(`button`,{type:`button`,disabled:Te||s||_e.trim().length===0,onClick:()=>void N(`prd`,!1),children:`退回修改`}),(0,P.jsx)(`button`,{type:`button`,className:`primary`,disabled:Te||s,onClick:()=>void N(`prd`,!0),children:`确认 PRD,生成交互稿`})]})]}),O?.plan.phase===`design-generating`&&(0,P.jsxs)(`div`,{className:`d2c-artifact-wait`,"data-invalid":O.validationError?.stage===`design`,"aria-live":`polite`,children:[(0,P.jsx)(`i`,{}),(0,P.jsx)(`div`,{children:O.validationError?.stage===`design`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`strong`,{children:`交互契约未通过预检`}),(0,P.jsx)(`span`,{children:O.validationError.message})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`strong`,{children:`正在生成可交互体验基线`}),(0,P.jsx)(`span`,{children:`视觉、关键状态和行为契约会一起落盘。`})]})}),O.validationError?.stage===`design`?(0,P.jsx)(`button`,{type:`button`,disabled:Te||s,onClick:()=>void jt(),children:`自动修复清单`}):(0,P.jsx)(`button`,{type:`button`,onClick:()=>void an(O.plan.task),children:`刷新`})]}),O?.plan.phase===`design-review`&&(0,P.jsxs)(`div`,{className:`d2c-artifact-review d2c-design-review`,children:[(0,P.jsxs)(`header`,{children:[(0,P.jsx)(`span`,{children:`INTERACTIVE PROTOTYPE`}),(0,P.jsx)(`h3`,{children:`直接体验,再决定是否开发`}),(0,P.jsx)(`p`,{children:`点击、输入并检查主流程和异常状态;确认后它会成为 E2E 中 D2C 视觉还原的设计基线。`})]}),(0,P.jsx)($u,{url:he.url,onStart:()=>void nn(O.plan.task)}),(0,P.jsxs)(`div`,{className:`d2c-prototype-tools`,children:[(0,P.jsx)(`span`,{children:he.running?`● LOOPBACK PREVIEW`:`PREVIEW STOPPED`}),he.running&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>void window.flavorDesktop.openD2cProductPreview(O.plan.task),children:`浏览器打开`})]}),(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`退回意见`}),(0,P.jsx)(`textarea`,{rows:3,value:_e,placeholder:`例如:筛选结果缺少空状态,趋势图悬停信息不够明确`,onChange:e=>ve(e.target.value)})]}),(0,P.jsxs)(`div`,{className:`d2c-artifact-actions`,children:[(0,P.jsx)(`button`,{type:`button`,disabled:Te||s||_e.trim().length===0,onClick:()=>void N(`design`,!1),children:`退回修改`}),(0,P.jsx)(`button`,{type:`button`,className:`primary`,disabled:Te||s,onClick:()=>void N(`design`,!0),children:`确认设计,进入 D2C 视觉还原`})]})]}),O?.plan.phase===`ready-for-d2c`&&(0,P.jsxs)(`div`,{className:`d2c-artifact-wait`,"data-ready":`true`,children:[(0,P.jsx)(`i`,{}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:`设计基线已确认`}),(0,P.jsx)(`span`,{children:`如果生成任务未启动或应用曾关闭,可从这里安全地继续 D2C 视觉还原。`})]}),(0,P.jsx)(`button`,{type:`button`,disabled:Te||s,onClick:()=>void N(`design`,!0),children:`继续视觉还原 →`})]}),s&&(0,P.jsx)(`p`,{className:`d2c-start-warning`,children:`当前会话正在执行其他任务,完成或中断后可开始 E2E。`})]})]}):Cn===`pending`&&a!==void 0?(0,P.jsx)(sd,{pending:a,onOpenLog:e,onInterrupt:t}):(ke===`integration`||ke===`acceptance`)&&A.running&&A.url!==void 0?(0,P.jsxs)(`main`,{className:`d2c-live-preview`,"aria-label":`Interactive integration preview`,children:[(0,P.jsxs)(`header`,{className:`d2c-live-toolbar`,children:[(0,P.jsxs)(`span`,{className:`d2c-live-state`,children:[(0,P.jsx)(`i`,{}),` LIVE`]}),(0,P.jsx)(`code`,{title:A.url,children:A.url}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>ut(e=>e+1),children:`Refresh`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>void window.flavorDesktop.openD2cPreview(u.report.task),children:`Open in browser`})]}),(0,P.jsx)(ed,{url:A.url,reloadKey:lt,task:u.report.task})]}):(0,P.jsxs)(`main`,{className:`d2c-canvas-area`,"data-pages":yn.length>1?`multiple`:`single`,children:[u!==void 0&&Et!==void 0&&mn!==void 0&&hn!==void 0&&(0,P.jsxs)(P.Fragment,{children:[yn.length>1&&(0,P.jsxs)(`nav`,{className:`d2c-page-rail`,"aria-label":`页面评测结果`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:`页面`}),(0,P.jsx)(`span`,{children:u.report.page===void 0?``:`${u.report.page.index+1} / ${u.report.page.count}`})]}),(0,P.jsx)(`div`,{children:yn.map(e=>(0,P.jsxs)(`button`,{type:`button`,"aria-pressed":e.reportId===u.report.reportId,"data-selected":e.reportId===u.report.reportId,"data-status":e.evaluationStatus,onClick:()=>void kt(e),children:[(0,P.jsx)(`span`,{children:e.page?.label??e.reportId}),(0,P.jsx)(`small`,{children:e.evaluationStatus===`invalid`?`待重测`:`${e.total.toFixed(1)} · ${e.issueCount} 项`})]},e.reportId))})]}),(0,P.jsxs)(`div`,{className:`d2c-trust-bar`,"data-status":hn.status,children:[(0,P.jsx)(`strong`,{children:Gu[hn.verdict]}),(0,P.jsx)(`span`,{children:hn.summary}),(0,P.jsx)(`div`,{children:hn.checks.map(e=>(0,P.jsxs)(`span`,{"data-status":e.status,title:e.message,children:[e.status===`pass`?`✓`:e.status===`warn`?`!`:`×`,` `,e.label]},e.key))})]}),(0,P.jsxs)(`div`,{className:`d2c-canvas-toolbar`,children:[(0,P.jsx)(`div`,{className:`d2c-mode-switch`,role:`tablist`,"aria-label":`画布显示模式`,children:gn.map(e=>(0,P.jsx)(`button`,{role:`tab`,"aria-selected":g===e,"data-active":g===e,onClick:()=>v(e),children:Wu[e]},e))}),g===`overlay`&&(0,P.jsxs)(`label`,{className:`d2c-opacity d2c-opacity-overlay`,children:[(0,P.jsxs)(`span`,{children:[`实现 `,Math.round(y*100),`%`]}),(0,P.jsx)(`input`,{type:`range`,min:0,max:100,value:Math.round(y*100),onChange:e=>b(Number(e.target.value)/100)})]}),g===`wipe`&&(0,P.jsxs)(`label`,{className:`d2c-opacity d2c-opacity-wipe`,children:[(0,P.jsxs)(`span`,{children:[`分界 `,x,`%`]}),(0,P.jsx)(`input`,{type:`range`,min:0,max:100,value:x,onChange:e=>S(Number(e.target.value))})]}),(0,P.jsxs)(`div`,{className:`d2c-zoom-tools`,"aria-label":`缩放控制`,children:[(0,P.jsx)(`button`,{onClick:()=>zt(1/1.2),"aria-label":`缩小`,children:`−`}),(0,P.jsx)(`button`,{onClick:Vt,children:`100%`}),(0,P.jsx)(`button`,{onClick:Ot,children:`适应`}),(0,P.jsx)(`button`,{onClick:()=>zt(1.2),"aria-label":`放大`,children:`+`}),(0,P.jsxs)(`output`,{children:[Math.round(pt.scale*100),`%`]})]})]}),(0,P.jsxs)(`div`,{className:`d2c-canvas-viewport`,ref:ht,tabIndex:0,"aria-label":`差异画布。滚轮缩放,拖动平移,F 适应,0 显示 100%。`,onWheel:e=>{e.preventDefault();let t=e.currentTarget.getBoundingClientRect();zt(Math.exp(-e.deltaY*.0015),{x:e.clientX-t.left,y:e.clientY-t.top},!1),xt.current!==void 0&&clearTimeout(xt.current),xt.current=setTimeout(()=>{mt({...yt.current}),xt.current=void 0},120)},onPointerDown:e=>{e.button===0&&(e.currentTarget.setPointerCapture(e.pointerId),St.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,originX:yt.current.x,originY:yt.current.y},e.currentTarget.dataset.dragging=`true`)},onPointerMove:e=>{let t=St.current;t===void 0||t.pointerId!==e.pointerId||Dt({...yt.current,x:t.originX+e.clientX-t.x,y:t.originY+e.clientY-t.y},!1)},onPointerUp:e=>{St.current?.pointerId===e.pointerId&&(St.current=void 0,e.currentTarget.dataset.dragging=`false`,mt({...yt.current}))},onKeyDown:e=>{if(e.key===`+`||e.key===`=`)zt(1.2);else if(e.key===`-`)zt(1/1.2);else if(e.key===`0`)Vt();else if(e.key.toLowerCase()===`f`)Ot();else if(e.key.toLowerCase()===`b`&&Ct.current===void 0)Ct.current=g,v(`blink`);else if(/^[1-6]$/.test(e.key)){let t=gn[Number(e.key)-1];t!==void 0&&v(t)}},onKeyUp:e=>{e.key.toLowerCase()===`b`&&Ct.current!==void 0&&(v(Ct.current),Ct.current=void 0)},children:[(0,P.jsxs)(`div`,{className:`d2c-canvas-stage d2c-mode-${g}`,ref:vt,style:{width:Et.width,height:Et.height,"--d2c-scale":pt.scale,"--d2c-x":`${pt.x}px`,"--d2c-y":`${pt.y}px`,"--d2c-impl-opacity":y,"--d2c-wipe":`${x}%`},children:[(0,P.jsx)(`img`,{className:`d2c-layer d2c-layer-design`,src:u.designPng,alt:`设计稿截图`,draggable:!1}),(0,P.jsx)(`img`,{className:`d2c-layer d2c-layer-impl`,src:u.implementationPng,alt:`实现截图`,draggable:!1}),(0,P.jsx)(`img`,{className:`d2c-layer d2c-layer-heatmap`,src:u.heatmapPng,alt:`像素差异热力图`,draggable:!1}),hn.status===`invalid`&&(0,P.jsx)(`div`,{className:`d2c-invalid-capture-badge`,children:`错误现场 · 不参与评分`}),g===`wipe`&&(0,P.jsx)(`button`,{className:`d2c-wipe-handle`,"aria-label":`拖动拉帘分界,当前 ${Math.round(x)}%`,onPointerDown:e=>{e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&Bt(e.clientX,!1)},onPointerUp:e=>{Bt(e.clientX,!0),e.currentTarget.releasePointerCapture(e.pointerId)},children:(0,P.jsx)(`span`,{})}),(0,P.jsx)(`div`,{className:`d2c-annotations`,"aria-hidden":`true`,children:Lt.map(e=>{let t=e.designRect??e.implementationRect;return t===void 0?null:(0,P.jsx)(`div`,{className:`d2c-annotation`,"data-kind":e.kind,"data-severity":e.severity,"data-selected":e.fingerprint===C,style:td(t)},e.fingerprint)})}),It?.designRect!==void 0&&(0,P.jsx)(`div`,{className:`d2c-focus-box d2c-focus-design`,style:td(It.designRect),children:(0,P.jsx)(`span`,{children:`设计`})}),It?.implementationRect!==void 0&&(0,P.jsx)(`div`,{className:`d2c-focus-box d2c-focus-implementation`,style:td(It.implementationRect),children:(0,P.jsx)(`span`,{children:`实现`})}),It?.designRect!==void 0&&It.implementationRect!==void 0&&(0,P.jsx)(nd,{design:It.designRect,implementation:It.implementationRect,canvas:Et,scale:pt.scale})]}),(0,P.jsx)(`aside`,{className:`d2c-difference-ruler`,"aria-label":`垂直差异分布`,children:Nt.slice(0,500).map(e=>{let t=e.designRect??e.implementationRect;return t===void 0?null:(0,P.jsx)(`button`,{style:{top:`${(t.y+t.height/2)/Et.height*100}%`},"data-severity":e.severity,"aria-label":`定位 ${e.label}`,title:e.label,onClick:()=>Rt(e)},e.fingerprint)})}),(0,P.jsx)(`div`,{className:`d2c-canvas-hint`,children:`滚轮缩放 · 拖动平移 · F 适应 · 0 原始尺寸 · 按住 B 闪烁`})]})]}),m&&(0,P.jsx)(`div`,{className:`d2c-loading`,"aria-busy":`true`,children:`正在加载报告…`})]}),Cn===`report`&&(0,P.jsx)(`aside`,{className:`d2c-inspector`,"aria-label":`差异检查器`,children:u!==void 0&&Et!==void 0&&mn!==void 0?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`section`,{className:`d2c-inspector-verdict`,"data-verdict":u.report.evaluation.verdict,children:[(0,P.jsx)(`span`,{className:`d2c-verdict-mark`,"aria-hidden":`true`,children:u.report.evaluation.verdict===`pass`?`✓`:u.report.evaluation.verdict===`conditional`?`!`:`×`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:u.report.evaluation.status===`invalid`?`EVALUATION INTERRUPTED`:`PAGE VERDICT`}),(0,P.jsx)(`h2`,{children:u.report.evaluation.verdict===`pass`?Nt.length===0?`本页已通过验收`:`已通过,仍可继续优化`:u.report.evaluation.verdict===`conditional`?`有差异需要确认`:u.report.evaluation.verdict===`invalid`?`评测需要重新运行`:`本页尚未通过验收`}),(0,P.jsx)(`span`,{children:u.report.evaluation.summary})]})]}),(0,P.jsxs)(`nav`,{className:`d2c-stage-tabs`,"aria-label":`E2E 交付阶段`,children:[(0,P.jsxs)(`button`,{type:`button`,"data-active":ke===`review`,"aria-pressed":ke===`review`,onClick:()=>Ae(`review`),children:[(0,P.jsx)(`span`,{children:`04`}),`D2C 视觉还原`]}),(0,P.jsxs)(`button`,{type:`button`,"data-active":ke===`integration`,"aria-pressed":ke===`integration`,disabled:xn===void 0||!xn.complete||u.report.evaluation.status===`invalid`,title:xn?.complete?`进入接口联调`:`全部差异通过后解锁`,onClick:Gt,children:[(0,P.jsx)(`span`,{children:`05`}),`接口联调`]}),(0,P.jsxs)(`button`,{type:`button`,"data-active":ke===`acceptance`,"aria-pressed":ke===`acceptance`,disabled:u.workflow.integrationFiles===void 0,title:u.workflow.integrationFiles===void 0?`生成联调代码后解锁`:`进入验收与交付`,onClick:Kt,children:[(0,P.jsx)(`span`,{children:`06—07`}),`验收与交付`]})]}),ke===`review`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`section`,{className:`d2c-score-card`,"aria-label":`分项得分`,"data-status":u.report.evaluation.status,children:[(0,P.jsxs)(`header`,{children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:`QUALITY PROFILE`}),(0,P.jsx)(`h2`,{children:`五项质量`})]}),u.report.evaluation.status!==`invalid`&&(0,P.jsxs)(`span`,{children:[Hu.filter(({key:e})=>(mn[e]??0)>=.9).length,` / 5 达标`]})]}),u.report.evaluation.status===`invalid`&&(0,P.jsx)(`p`,{className:`d2c-score-invalid`,children:`实现页面渲染失败,当前截图仅用于诊断,不生成正式分数。`}),u.report.evaluation.status!==`invalid`&&(0,P.jsx)(`div`,{className:`d2c-score-list`,children:Hu.map(({key:e,label:t})=>mn[e]===void 0?null:(0,P.jsxs)(`div`,{"data-level":Zu(mn[e]),children:[(0,P.jsx)(`span`,{children:t}),(0,P.jsx)(`i`,{children:(0,P.jsx)(`b`,{style:{"--score":mn[e]}})}),(0,P.jsx)(`strong`,{children:Math.round(mn[e]*100)})]},e))})]}),u.report.evaluation.status!==`invalid`&&xn!==void 0&&(0,P.jsxs)(`section`,{className:`d2c-review-console`,"data-complete":xn.complete,children:[(0,P.jsxs)(`header`,{children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:`REVIEW QUEUE`}),(0,P.jsx)(`h2`,{children:xn.complete?`视觉审阅已完成`:`等待你的验收`})]}),(0,P.jsxs)(`strong`,{children:[xn.accepted,(0,P.jsxs)(`span`,{children:[` / `,xn.total]})]})]}),(0,P.jsxs)(`div`,{className:`d2c-review-meter`,"aria-label":`已通过 ${xn.accepted},待审 ${xn.pending},退回 ${xn.needsFix}`,children:[(0,P.jsx)(`i`,{style:{"--accepted":xn.total===0?1:xn.accepted/xn.total}}),(0,P.jsxs)(`span`,{children:[`待审 `,(0,P.jsx)(`b`,{children:xn.pending})]}),(0,P.jsxs)(`span`,{children:[`通过 `,(0,P.jsx)(`b`,{children:xn.accepted})]}),(0,P.jsxs)(`span`,{children:[`退回 `,(0,P.jsx)(`b`,{children:xn.needsFix})]})]}),(0,P.jsxs)(`div`,{className:`d2c-review-bulk`,children:[!xn.complete&&(0,P.jsx)(`button`,{type:`button`,disabled:je||s||Nt.length===0,onClick:()=>void Ut(Nt.map(e=>e.fingerprint),`accepted`),children:`全部跳过(不扣分)`}),!xn.complete&&(0,P.jsx)(`button`,{type:`button`,className:`d2c-review-reject`,disabled:je||s||Nt.length===0,onClick:()=>void Ut(Nt.map(e=>e.fingerprint),`needs-fix`,`集中修复所有退回差异,仍需严格限制在各自模块文件内。`),children:`全部退回并修复`}),xn.complete&&(0,P.jsxs)(`button`,{type:`button`,className:`d2c-review-next`,onClick:Gt,children:[`进入接口联调 `,(0,P.jsx)(`span`,{children:`→`})]})]})]}),(0,P.jsxs)(`div`,{className:`d2c-issue-heading`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{children:u.report.evaluation.status===`invalid`?`错误诊断`:`差异问题`}),u.report.evaluation.status!==`invalid`&&(0,P.jsxs)(`span`,{children:[Ft.length,` / `,Nt.length]})]}),u.report.evaluation.status!==`invalid`&&(0,P.jsx)(`div`,{className:`d2c-issue-filters`,children:[`all`,`blocking`,`content`,`geometry`].map(e=>(0,P.jsxs)(`button`,{type:`button`,"aria-pressed":ee===e,"data-active":ee===e,onClick:()=>{T(e),ne(Au)},children:[(0,P.jsx)(`span`,{children:Uu[e]}),(0,P.jsx)(`small`,{children:Pt[e]})]},e))})]}),Ft.length===0?(0,P.jsxs)(`div`,{className:`d2c-issue-empty`,"data-kind":u.report.evaluation.status===`invalid`?`invalid`:Nt.length===0?`clear`:`filtered`,children:[(0,P.jsx)(`span`,{className:`d2c-empty-mark`,"aria-hidden":`true`,children:u.report.evaluation.status===`invalid`?`!`:Nt.length===0?`✓`:`⌁`}),(0,P.jsx)(`strong`,{children:u.report.evaluation.status===`invalid`?`等待有效评测`:Nt.length===0?`未发现可定位的差异`:`这个筛选下没有问题`}),(0,P.jsx)(`p`,{children:u.report.evaluation.status===`invalid`?`修复项目并重新运行 E2E 中的 D2C 视觉还原后,这里会生成可定位的差异清单。`:Nt.length===0?`布局、色彩、字体、内容与像素结果均已通过检查。`:`切换分类或显示全部问题,继续检查其他差异。`}),u.report.evaluation.status!==`invalid`&&(0,P.jsxs)(`div`,{className:`d2c-empty-stats`,children:[(0,P.jsxs)(`span`,{children:[`阻断 `,(0,P.jsx)(`b`,{children:Pt.blocking})]}),(0,P.jsxs)(`span`,{children:[`内容 `,(0,P.jsx)(`b`,{children:Pt.content})]}),(0,P.jsxs)(`span`,{children:[`几何 `,(0,P.jsx)(`b`,{children:Pt.geometry})]})]}),u.report.evaluation.status!==`invalid`&&(Nt.length===0?(0,P.jsx)(`button`,{type:`button`,onClick:()=>{v(`overlay`),Ot()},children:`查看叠加结果`}):(0,P.jsx)(`button`,{type:`button`,onClick:()=>{T(`all`),ne(Au)},children:`显示全部问题`}))]}):(0,P.jsx)(`ol`,{className:`d2c-issue-list`,children:Ft.slice(0,te).map(e=>{let t=Sn(e.fingerprint);return(0,P.jsxs)(`li`,{"data-severity":e.severity,"data-selected":C===e.fingerprint,"data-review":t?.decision??`pending`,children:[(0,P.jsxs)(`button`,{className:`d2c-issue-main`,onClick:()=>Rt(e),"aria-pressed":C===e.fingerprint,children:[(0,P.jsx)(`span`,{className:`d2c-impact`,children:t?.decision===`accepted`?`✓`:t?.decision===`needs-fix`?`↻`:e.impact.toFixed(1)}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:e.label}),Yu(e).map(e=>(0,P.jsx)(`small`,{children:e},e))]})]}),C===e.fingerprint&&(0,P.jsxs)(`div`,{className:`d2c-evidence`,children:[(0,P.jsxs)(`div`,{className:`d2c-evidence-pair`,children:[e.designRect!==void 0&&(0,P.jsx)(Qu,{src:u.designPng,rect:e.designRect,canvas:Et,label:`设计`}),e.implementationRect!==void 0&&(0,P.jsx)(Qu,{src:u.implementationPng,rect:e.implementationRect,canvas:Et,label:`实现`})]}),(0,P.jsxs)(`div`,{className:`d2c-copy-actions`,children:[e.selector!==void 0&&(0,P.jsx)(`button`,{onClick:()=>Ht(e.selector),children:`复制选择器`}),(0,P.jsx)(`button`,{onClick:()=>Ht(`${e.label}\n${Yu(e).join(`
148
148
  `)}\n位置:${JSON.stringify(bn)}`),children:`复制修复线索`})]}),(0,P.jsxs)(`label`,{className:`d2c-review-instruction`,children:[(0,P.jsx)(`span`,{children:`补充修改要求`}),(0,P.jsx)(`textarea`,{rows:2,value:Ne,placeholder:`例如:保持卡片高度,只调整内部间距`,onChange:e=>Pe(e.target.value)})]}),(0,P.jsxs)(`div`,{className:`d2c-review-actions`,children:[(0,P.jsx)(`button`,{type:`button`,className:`d2c-accept`,disabled:je||s||t?.decision===`accepted`,onClick:()=>void Ut([e.fingerprint],`accepted`),children:`跳过(本项不扣分)`}),(0,P.jsx)(`button`,{type:`button`,className:`d2c-fix`,disabled:je||s,onClick:()=>void Ut([e.fingerprint],`needs-fix`,Ne||void 0),children:`修复并自动视觉复验`})]})]})]},e.fingerprint)})}),Ft.length>te&&(0,P.jsxs)(`button`,{className:`d2c-show-more`,onClick:()=>ne(e=>e+Au),children:[`再显示 `,Math.min(Au,Ft.length-te),` 条`]})]}):(0,P.jsxs)(`section`,{className:`d2c-integration-panel`,"data-stage":ke,"aria-label":ke===`acceptance`?`验收与交付`:`接口联调`,children:[(0,P.jsxs)(`header`,{children:[(0,P.jsx)(`p`,{children:ke===`acceptance`?`ACCEPTANCE & DELIVERY`:`API INTEGRATION`}),(0,P.jsx)(`h2`,{children:ke===`acceptance`?`验收与交付`:Fe===void 0?u.deliveryOrigin===`requirement`?`自动准备接口契约`:`导入接口描述`:Fe.document.title}),(0,P.jsx)(`span`,{children:ke===`acceptance`?`通过自动回放、人工操作与多模态质量门,完成最终交付验收。`:Fe===void 0?u.deliveryOrigin===`requirement`?`根据已确认 PRD 与实现模块生成 OpenAPI,无需手动上传。`:`上传 Swagger / OpenAPI JSON,自动匹配页面模块和接口出入参。`:`${Fe.document.version}${Fe.document.baseUrl?` · ${Fe.document.baseUrl}`:``}`})]}),Fe===void 0?(0,P.jsxs)(`div`,{className:`d2c-api-import`,"data-origin":u.deliveryOrigin,children:[(0,P.jsx)(`span`,{"aria-hidden":`true`,children:`{}`}),(0,P.jsx)(`strong`,{children:u.deliveryOrigin===`requirement`?`正在根据 PRD 与模块准备 OpenAPI 契约`:`Swagger JSON`}),(0,P.jsx)(`p`,{children:u.deliveryOrigin===`requirement`?`契约会自动生成并映射到当前实现;也可接入已有后端契约覆盖默认结果。`:`支持 Swagger 2.0、OpenAPI 3.0/3.1 和文档内引用。`}),(0,P.jsx)(`button`,{type:`button`,disabled:Le,onClick:()=>void qt(),children:Le?u.deliveryOrigin===`requirement`?`自动准备中…`:`正在解析…`:u.deliveryOrigin===`requirement`?`接入已有 Swagger / OpenAPI`:`选择 swagger.json`})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`d2c-api-summary`,children:[(0,P.jsxs)(`span`,{children:[`模块 `,(0,P.jsx)(`b`,{children:Fe.mappings.length})]}),(0,P.jsxs)(`span`,{children:[`自动匹配 `,(0,P.jsx)(`b`,{children:Fe.mappings.filter(e=>e.status===`auto`).length})]}),(0,P.jsxs)(`span`,{children:[`待确认 `,(0,P.jsx)(`b`,{children:Fe.mappings.filter(e=>e.status===`needs-confirmation`).length})]})]}),(0,P.jsx)(`ol`,{className:`d2c-mapping-list`,children:Fe.mappings.map(e=>(0,P.jsxs)(`li`,{"data-status":e.status,children:[(0,P.jsxs)(`header`,{children:[(0,P.jsx)(`span`,{children:e.moduleLabel}),(0,P.jsx)(`small`,{children:e.status===`auto`?`自动匹配`:e.status===`confirmed`?`已确认`:`需要确认`})]}),(0,P.jsx)(`select`,{"aria-label":`${e.moduleLabel} 接口`,value:e.operationKey,disabled:Le,onChange:t=>void Jt(e,t.target.value),children:Fe.document.operations.map(e=>(0,P.jsxs)(`option`,{value:e.id,children:[e.operationId,` · `,e.id]},e.id))}),e.status===`needs-confirmation`&&(0,P.jsx)(`button`,{type:`button`,className:`d2c-confirm-mapping`,disabled:Le,onClick:()=>void Jt(e,e.operationKey),children:`确认此映射`}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`span`,{children:[`请求 `,e.parameters.length+e.requestFields.length,` 字段`]}),(0,P.jsxs)(`span`,{children:[`响应 `,e.responseFields.length,` 字段`]}),(0,P.jsxs)(`b`,{children:[Math.round(e.confidence*100),`%`]})]})]},e.moduleId))}),(0,P.jsxs)(`div`,{className:`d2c-integration-launch`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{children:`接口映射已就绪`}),(0,P.jsx)(`small`,{children:Fe.mappings.some(e=>e.status===`needs-confirmation`)?`仍有接口需要人工确认`:`${Fe.mappings.length} 个模块将接入真实请求链路`})]}),(0,P.jsxs)(`button`,{type:`button`,className:`d2c-generate-integration`,disabled:Le||Fe.mappings.some(e=>e.status===`needs-confirmation`),onClick:()=>void Yt(),children:[Le?`正在准备联调…`:u.workflow.integrationFiles===void 0?`生成并开始联调`:`重新生成联调代码`,(0,P.jsx)(`span`,{children:`→`})]})]}),Fe.mappings.some(e=>e.status===`needs-confirmation`)&&(0,P.jsx)(`p`,{className:`d2c-api-hint`,children:`确认所有标记为“需要确认”的接口后即可生成。`}),(0,P.jsxs)(`section`,{className:`d2c-mock-control`,"data-running":ze.running,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`i`,{}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:u.deliveryOrigin===`requirement`?ze.running?`真实后端服务运行中`:`真实后端服务未启动`:ze.running?`本地契约服务运行中`:`本地契约服务未启动`}),(0,P.jsx)(`small`,{children:ze.url??`生成联调代码后可启动`})]})]}),u.workflow.integrationFiles!==void 0&&(0,P.jsx)(`button`,{type:`button`,disabled:Le||A.running,title:A.running?`请先停止交互页面`:void 0,onClick:()=>void Xt(),children:ze.running?`停止`:`启动`})]}),u.workflow.integrationFiles!==void 0&&(0,P.jsxs)(`section`,{className:`d2c-integration-ready`,"data-running":A.running,children:[(0,P.jsx)(`span`,{"aria-hidden":`true`,children:`✓`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:`联调环境已生成`}),(0,P.jsx)(`small`,{children:A.running?`前端页面与后端服务已连接,可进入最终验收。`:`启动联调页面后即可进入自动与人工验收。`})]}),(0,P.jsx)(`button`,{type:`button`,onClick:Kt,children:`进入验收与交付 →`})]}),(0,P.jsxs)(`section`,{className:`d2c-preview-control`,"data-running":A.running,children:[(0,P.jsxs)(`header`,{children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:`INTERACTIVE ACCEPTANCE`}),(0,P.jsx)(`h3`,{children:A.running?`可交互页面运行中`:`等待启动可交互页面`})]}),(0,P.jsx)(`i`,{})]}),(0,P.jsx)(`code`,{children:A.url??`Vite preview not started`}),(0,P.jsxs)(`div`,{className:`d2c-preview-actions`,children:[(0,P.jsx)(`button`,{type:`button`,disabled:Ge||u.workflow.integrationFiles===void 0,onClick:()=>void(A.running?Qt():Zt()),children:A.running?`停止页面`:`启动页面`}),(0,P.jsx)(`button`,{type:`button`,disabled:Ge||!A.running,onClick:()=>void $t(),children:qe?`可视回放中…`:Ge?`处理中…`:`运行自动验收`}),A.running&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>void window.flavorDesktop.openD2cPreview(u.report.task),children:`浏览器打开`})]}),qe&&(0,P.jsxs)(`div`,{className:`d2c-playback-notice`,role:`status`,"aria-live":`polite`,children:[(0,P.jsx)(`i`,{"aria-hidden":`true`}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:`正在可视化回放`}),(0,P.jsx)(`small`,{children:$e.configured?`多模态模型正在观察并规划用户旅程;随后青色指针会完成点击、输入、导航和检查。`:`请观察左侧页面:青色指针会依次完成设计契约中的定位、点击、输入和检查。配置多模态模型后可启用自主审阅。`})]})]}),Ue!==void 0&&(0,P.jsxs)(`div`,{className:`d2c-review-plan`,"data-mode":Ue.mode,children:[(0,P.jsx)(`strong`,{children:Ue.mode===`autonomous`?`自主审阅已执行`:Ue.mode===`contract-fallback`?`自主规划失败,已执行设计契约`:`设计契约已执行`}),(0,P.jsxs)(`span`,{children:[Ue.plannedScenarios,` 条用户旅程`,Ue.model?` · ${Ue.model}`:``]}),Ue.summary&&(0,P.jsx)(`p`,{children:Ue.summary}),Ue.warning&&(0,P.jsx)(`p`,{role:`alert`,children:Ue.warning})]}),j!==void 0&&(0,P.jsxs)(`div`,{className:`d2c-test-results`,"data-passed":j.passed,children:[(0,P.jsxs)(`header`,{children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:j.passed?`自动验收通过`:`${j.failures} 条自动验收失败`}),(0,P.jsxs)(`span`,{children:[j.total,` scenarios · `,j.apiRequestCount,` API requests`]})]}),!j.passed&&(0,P.jsx)(`button`,{type:`button`,disabled:Ye!==void 0||s,onClick:()=>void tn(j.scenarios.filter(e=>!e.passed)),children:Ye===`all`?`正在发起修复…`:Ze.trim()?`按要求修复全部`:`修复全部失败`})]}),!j.passed&&(0,P.jsxs)(`label`,{className:`d2c-interaction-repair-guide`,children:[(0,P.jsxs)(`span`,{children:[`补充修复要求 `,(0,P.jsx)(`small`,{children:`可选`})]}),(0,P.jsx)(`textarea`,{rows:3,value:Ze,placeholder:`例如:不要修改接口契约;优先检查登录响应的 data 包装层与会话持久化`,onChange:e=>Qe(e.target.value)}),(0,P.jsx)(`small`,{children:`留空则按失败证据自动修复;填写后会连同请求日志一起交给修复任务。`})]}),(0,P.jsx)(`ol`,{children:j.scenarios.map(e=>(0,P.jsxs)(`li`,{"data-passed":e.passed,children:[(0,P.jsxs)(`span`,{children:[e.passed?`✓`:`×`,` `,e.id]}),(0,P.jsxs)(`small`,{children:[e.apiRequestCount,` API · `,e.durationMs,`ms`]}),e.failure!==void 0&&(0,P.jsx)(`p`,{children:e.failure}),!e.passed&&(0,P.jsx)(`button`,{type:`button`,className:`d2c-fix-scenario`,disabled:Ye!==void 0||s,"aria-label":`修复失败场景 ${e.id}`,onClick:()=>void tn([e]),children:Ye===e.id?`正在发起修复…`:Ze.trim()?`按要求修复此项`:`修复此项`})]},e.id))})]}),(0,P.jsxs)(`div`,{className:`d2c-manual-acceptance`,children:[(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:`人工验收`}),(0,P.jsx)(`small`,{children:`请直接在左侧页面完成点击、输入和提交流程`})]}),(0,P.jsx)(`button`,{type:`button`,disabled:Ge||!A.running,"data-accepted":u.workflow.interaction?.manualDecision===`accepted`,onClick:()=>void en(u.workflow.interaction?.manualDecision!==`accepted`),children:u.workflow.interaction?.manualDecision===`accepted`?`已通过(撤回)`:`确认人工验收通过`})]}),(0,P.jsxs)(`section`,{className:`d2c-quality-gate`,"data-verdict":u.workflow.quality?.verdict??`pending`,children:[(0,P.jsxs)(`header`,{children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:`LLM-AS-A-JUDGE`}),(0,P.jsx)(`h3`,{children:`最终质量门`})]}),u.workflow.quality!==void 0&&(0,P.jsx)(`strong`,{children:u.workflow.quality.overallScore.toFixed(1)})]}),!$e.configured||at?(0,P.jsxs)(`form`,{className:`d2c-judge-config`,onSubmit:e=>void dn(e),children:[(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`协议`}),(0,P.jsxs)(`select`,{value:st.protocol,onChange:e=>ct(t=>({...t,protocol:e.target.value})),children:[(0,P.jsx)(`option`,{value:`openai-compatible`,children:`OpenAI 兼容`}),(0,P.jsx)(`option`,{value:`anthropic`,children:`Anthropic`})]})]}),(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`Base URL`}),(0,P.jsx)(`input`,{required:!0,type:`url`,placeholder:`https://api.example.com/v1`,value:st.baseURL,onChange:e=>ct(t=>({...t,baseURL:e.target.value}))})]}),(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`模型`}),(0,P.jsx)(`input`,{required:!0,placeholder:`支持视觉的模型名称`,value:st.model,onChange:e=>ct(t=>({...t,model:e.target.value}))})]}),(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`API Key`}),(0,P.jsx)(`input`,{required:!0,type:`password`,autoComplete:`off`,value:st.apiKey,onChange:e=>ct(t=>({...t,apiKey:e.target.value}))})]}),(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`通过阈值`}),(0,P.jsx)(`input`,{required:!0,type:`number`,min:0,max:100,value:st.passThreshold,onChange:e=>ct(t=>({...t,passThreshold:Number(e.target.value)}))})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`button`,{type:`submit`,disabled:tt,children:tt?`保存中…`:`保存多模态模型`}),$e.configured&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>ot(!1),children:`取消`})]})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`d2c-judge-model`,children:[(0,P.jsx)(`span`,{children:$e.model}),(0,P.jsxs)(`small`,{children:[$e.baseURL,` · 阈值 `,$e.passThreshold]}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>ot(!0),children:`修改配置`})]}),u.workflow.quality===void 0?(0,P.jsx)(`p`,{children:`可随时评测当前版本;自动与人工验收未通过时,评分只用于诊断,不会放行最终交付。`}):(0,P.jsxs)(`div`,{className:`d2c-quality-result`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`span`,{children:[`视觉质量 `,(0,P.jsx)(`b`,{children:u.workflow.quality.visualScore})]}),(0,P.jsxs)(`span`,{children:[`交互质量 `,(0,P.jsx)(`b`,{children:u.workflow.quality.interactionScore})]}),(0,P.jsxs)(`span`,{children:[`综合得分 `,(0,P.jsx)(`b`,{children:u.workflow.quality.overallScore})]})]}),(0,P.jsx)(`strong`,{children:u.workflow.quality.verdict===`pass`?`质量门通过`:`质量门未通过`}),(0,P.jsx)(`p`,{children:u.workflow.quality.summary}),u.workflow.quality.issues.length>0&&(0,P.jsx)(`ol`,{children:u.workflow.quality.issues.map(e=>(0,P.jsxs)(`li`,{"data-severity":e.severity,"data-decision":e.decision,children:[(0,P.jsx)(`span`,{children:e.description}),(0,P.jsx)(`small`,{children:e.recommendation}),(0,P.jsxs)(`em`,{children:[e.category,` · 影响 `,e.scoreImpact,` 分 · `,e.decision===`skipped`?`已跳过,不扣分`:e.decision===`fixing`?`修复中,完成后自动复验`:`待处理`]}),(0,P.jsxs)(`div`,{className:`d2c-quality-issue-actions`,children:[(0,P.jsx)(`button`,{type:`button`,disabled:rt!==void 0||e.decision===`skipped`,onClick:()=>void pn(e,`skipped`),children:`跳过(不扣分)`}),(0,P.jsx)(`button`,{type:`button`,disabled:rt!==void 0||e.decision===`fixing`,onClick:()=>void pn(e,`fixing`),children:`修复并自动复验`})]})]},e.id))})]}),(0,P.jsx)(`button`,{type:`button`,className:`d2c-run-judge`,disabled:tt||!A.running||u.workflow.interaction?.automated===void 0,title:u.workflow.interaction?.automated===void 0?`至少运行一次自动验收后可评分;验收失败也可以评分诊断`:void 0,onClick:()=>void fn(),children:tt?`AI 评审中…`:u.workflow.quality===void 0?`运行 AI 质量评审`:`重新运行 AI 质量评审`})]})]}),u.workflow.stage===`completed`&&(0,P.jsx)(`p`,{className:`d2c-acceptance-complete`,children:`✓ 自动、人工与多模态质量验收均已完成`})]})]})]})]}):(0,P.jsxs)(`div`,{className:`d2c-inspector-empty`,children:[(0,P.jsx)(`strong`,{children:`问题检查器`}),(0,P.jsx)(`span`,{children:`选择报告后,可按影响度逐项定位和取证。`})]})})]})]})}var ld={repository:!1,branch:``,head:``,files:[]};function ud(e,t=!1){let n=e.replace(/\r\n/g,`
149
149
  `).split(`
150
- `);if(n.at(-1)===``&&n.pop(),t&&!n.some(e=>e.startsWith(`@@`)))return n.map((e,t)=>({kind:`addition`,marker:`+`,text:e,newNumber:t+1}));let r=0,i=0,a=!1;return n.map(e=>{let t=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@(.*)$/.exec(e);if(t!==null)return r=Number(t[1]),i=Number(t[2]),a=!0,{kind:`hunk`,marker:`@@`,text:t[3]?.trim()??``};if(!a||e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`--- `)||e.startsWith(`+++ `))return{kind:`meta`,marker:``,text:e};if(e.startsWith(`+`)&&!e.startsWith(`+++`))return{kind:`addition`,marker:`+`,text:e.slice(1),newNumber:i++};if(e.startsWith(`-`)&&!e.startsWith(`---`))return{kind:`deletion`,marker:`−`,text:e.slice(1),oldNumber:r++};if(e.startsWith(`\\ No newline`))return{kind:`meta`,marker:``,text:e};let n={kind:`context`,marker:``,text:e.startsWith(` `)?e.slice(1):e,oldNumber:r,newNumber:i};return r+=1,i+=1,n})}function dd({onClose:e,onReview:t,onError:n}){let[r,i]=(0,_.useState)(ld),[a,o]=(0,_.useState)(),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(`working`),[d,f]=(0,_.useState)(!0),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(``),v=(0,_.useMemo)(()=>ud(s,a?.untracked),[s,a?.untracked]),y=v.filter(e=>e.kind===`addition`).length,b=v.filter(e=>e.kind===`deletion`).length,x=r.files.filter(e=>e.staged).length,S=async()=>{try{i(await window.flavorDesktop.gitStatus())}catch(e){n(pd(e))}finally{f(!1)}};(0,_.useEffect)(()=>{S()},[]);let C=async(e,t)=>{m(!0),c(``),u(t);try{c(await window.flavorDesktop.gitDiff(e.path,t===`staged`))}catch(e){let t=pd(e);c(t),n(t)}finally{m(!1)}},w=async e=>{o(e),await C(e,e.unstaged||e.untracked?`working`:`staged`)},ee=async(e,t)=>{if(!(e===`discard`&&!window.confirm(`确定还原 ${t.path}?此操作无法撤销。`)))try{let n=e===`stage`?await window.flavorDesktop.gitStage(t.path):e===`unstage`?await window.flavorDesktop.gitUnstage(t.path):await window.flavorDesktop.gitDiscard(t.path);i(n);let r=n.files.find(e=>e.path===t.path);r===void 0?(o(void 0),c(``)):(o(r),await C(r,r.unstaged||r.untracked?`working`:`staged`))}catch(e){n(pd(e))}},T=async()=>{if(h.trim())try{let e=await window.flavorDesktop.gitCommit(h.trim());i(e.status),g(``),o(void 0),c(``),n(`已提交 ${e.result}`)}catch(e){n(pd(e))}};return(0,P.jsxs)(`section`,{className:`manager-view git-view`,children:[(0,P.jsxs)(`header`,{className:`manager-header git-header`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`button`,{className:`git-back`,onClick:e,"aria-label":`返回`,children:`←`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{children:`Git 变更`}),(0,P.jsx)(`span`,{children:`审阅并整理本次工作区修改`})]})]}),r.repository&&(0,P.jsxs)(`span`,{className:`git-branch`,children:[(0,P.jsx)(`i`,{}),r.branch,(0,P.jsx)(`b`,{children:r.head})]})]}),d?(0,P.jsx)(`p`,{className:`manager-empty`,children:`正在读取工作区…`}):r.repository?(0,P.jsxs)(`div`,{className:`git-layout`,children:[(0,P.jsxs)(`aside`,{className:`git-files`,children:[(0,P.jsxs)(`div`,{className:`git-toolbar`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:`变更`}),(0,P.jsx)(`span`,{children:r.files.length})]}),(0,P.jsx)(`button`,{onClick:()=>void S(),title:`重新读取变更`,children:`↻`})]}),r.files.length===0?(0,P.jsxs)(`div`,{className:`git-clean`,children:[(0,P.jsx)(`i`,{children:`✓`}),(0,P.jsx)(`strong`,{children:`工作区干净`}),(0,P.jsx)(`span`,{children:`没有需要审阅的修改`})]}):r.files.map(e=>{let t=fd(e.path),n=e.untracked?`U`:e.index===`A`?`A`:e.index===`D`||e.worktree===`D`?`D`:`M`;return(0,P.jsxs)(`div`,{className:`git-file-row`,"data-active":a?.path===e.path,children:[(0,P.jsxs)(`button`,{className:`git-file-name`,onClick:()=>void w(e),title:e.path,children:[(0,P.jsx)(`code`,{"data-state":n,children:n}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`b`,{children:t.name}),t.directory&&(0,P.jsx)(`small`,{children:t.directory})]})]}),(0,P.jsxs)(`div`,{className:`git-file-actions`,children:[e.staged?(0,P.jsx)(`button`,{onClick:()=>void ee(`unstage`,e),children:`取消暂存`}):(0,P.jsx)(`button`,{className:`stage-action`,onClick:()=>void ee(`stage`,e),children:`暂存`}),(e.unstaged||e.untracked)&&(0,P.jsx)(`button`,{className:`danger-text`,onClick:()=>void ee(`discard`,e),children:`还原`})]})]},e.path)})]}),(0,P.jsx)(`article`,{className:`git-diff`,children:a===void 0?(0,P.jsxs)(`div`,{className:`git-diff-empty`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{children:`−`}),(0,P.jsx)(`span`,{children:`+`})]}),(0,P.jsx)(`strong`,{children:`选择文件查看差异`}),(0,P.jsx)(`p`,{children:`逐行审阅修改,然后决定暂存或还原。`})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`header`,{className:`git-diff-header`,children:[(0,P.jsxs)(`div`,{className:`git-diff-title`,children:[(0,P.jsx)(`span`,{children:fd(a.path).directory||`项目根目录`}),(0,P.jsx)(`strong`,{children:fd(a.path).name})]}),(0,P.jsxs)(`div`,{className:`git-diff-controls`,children:[a.staged&&a.unstaged&&(0,P.jsxs)(`div`,{className:`git-layer-switch`,children:[(0,P.jsx)(`button`,{"data-active":l===`working`,onClick:()=>void C(a,`working`),children:`工作区`}),(0,P.jsx)(`button`,{"data-active":l===`staged`,onClick:()=>void C(a,`staged`),children:`已暂存`})]}),!p&&(0,P.jsxs)(`div`,{className:`git-diff-stats`,children:[(0,P.jsxs)(`span`,{className:`add`,children:[`+`,y]}),(0,P.jsxs)(`span`,{className:`del`,children:[`−`,b]})]})]})]}),(0,P.jsx)(`div`,{className:`git-code`,"aria-label":`${a.path} 差异`,children:p?(0,P.jsxs)(`div`,{className:`git-diff-loading`,children:[(0,P.jsx)(`i`,{}),`正在生成差异…`]}):v.map((e,t)=>(0,P.jsxs)(`div`,{className:`git-code-line`,"data-kind":e.kind,children:[(0,P.jsx)(`span`,{className:`old-line`,children:e.oldNumber??``}),(0,P.jsx)(`span`,{className:`new-line`,children:e.newNumber??``}),(0,P.jsx)(`span`,{className:`change-marker`,children:e.marker}),(0,P.jsx)(`code`,{children:e.text||` `})]},`${t}-${e.oldNumber??``}-${e.newNumber??``}`))})]})})]}):(0,P.jsx)(`p`,{className:`manager-empty`,children:`当前项目不是 Git 仓库`}),r.repository&&(0,P.jsxs)(`footer`,{className:`git-footer`,children:[(0,P.jsx)(`button`,{className:`review-action`,onClick:t,children:`交给 /review`}),(0,P.jsxs)(`div`,{className:`commit-field`,children:[(0,P.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:x>0?`描述这次提交…`:`暂存文件后即可提交`}),(0,P.jsxs)(`span`,{children:[x,` 个文件已暂存`]})]}),(0,P.jsx)(`button`,{className:`commit-action`,disabled:!h.trim()||x===0,onClick:()=>void T(),children:`提交`})]})]})}function fd(e){let t=e.replace(/\\/g,`/`),n=t.lastIndexOf(`/`);return n<0?{name:t,directory:``}:{name:t.slice(n+1),directory:t.slice(0,n)}}function pd(e){return e instanceof Error?e.message:String(e)}function md(e){let t=[],n,r=()=>{if(n===void 0)return;let e=n.lines.length,r=n.hunks.map((t,r)=>({...t,end:n.hunks[r+1]?.start??e}));t.push({...n,hunks:r})};for(let t of e.split(/\r?\n/)){let e=/^diff --(?:git|flavor) a\/(.+?) b\/(.+)$/.exec(t);if(e!==null){r(),n={path:e[2],lines:[t],hunks:[],additions:0,deletions:0};continue}if(n===void 0)continue;let i=n.lines.length;n.lines.push(t),t.startsWith(`@@`)?n.hunks.push({id:`${n.path}:${n.hunks.length+1}`,header:t,start:i,end:i+1}):t.startsWith(`+`)&&!t.startsWith(`+++`)?n.additions+=1:t.startsWith(`-`)&&!t.startsWith(`---`)&&(n.deletions+=1)}return r(),t}function hd(e){return Math.min(2.4,Math.max(.55,e))}function gd(e,t,n){let r=hd(n),i=r/e.scale;return{x:t.x-(t.x-e.x)*i,y:t.y-(t.y-e.y)*i,scale:r}}function _d(e,t,n){return{x:Math.round(t.x+e.x*n.width*t.scale/100),y:Math.round(t.y+e.y*n.height*t.scale/100)}}function vd(e,t){let n=new Map,r=[];n.set(e.id,{...e,role:`origin`,x:50,y:50});let i=(t,i,a)=>{t.slice(0,8).forEach((t,o,s)=>{n.set(t.id,{...t,role:i,x:a,y:(o+1)*100/(s.length+1)}),r.push(i===`caller`?{from:t.id,to:e.id,kind:i}:{from:e.id,to:t.id,kind:i})})};i(t.callers,`caller`,14),i(t.callees,`callee`,86);let a=t.impact.filter(e=>!n.has(e.id)).slice(0,12),o=Math.ceil(a.length/2);return a.forEach((t,i)=>{let s=i<o,c=s?i:i-o,l=s?o:a.length-o,u=Math.floor(c/3),d=c%3,f=Math.min(3,l-u*3),p=(d+1)*100/(f+1),m=s?13+u*11:87-u*11;n.set(t.id,{...t,role:`impact`,x:p,y:m,hop:t.hop}),r.push({from:e.id,to:t.id,kind:`impact`,hop:t.hop})}),{nodes:[...n.values()],edges:r}}function $(e){let t=new Map(e.map(e=>[e.id,e]));return e.map(e=>{let n=0,r=e.parentId,i=new Set([e.id]);for(;r!==null&&n<12&&!i.has(r);){i.add(r);let e=t.get(r);if(e===void 0)break;n+=1,r=e.parentId}return{node:e,depth:n}})}function yd(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).at(-1)??e}function bd(e,t){let n=t.filter(e=>e.state!==`closed`);return e!==void 0&&n.some(t=>t.id===e)?e:n.find(e=>e.state===`running`)?.id??n[0]?.id}var xd=`modulepreload`,Sd=function(e,t){return new URL(e,t).href},Cd={},wd=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Sd(t,n),t=s(t),t in Cd)return;Cd[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:xd,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Td=[{id:`cockpit`,label:`执行`},{id:`timeline`,label:`时间机`},{id:`terminal`,label:`终端`},{id:`review`,label:`审查`},{id:`preview`,label:`预览`},{id:`context`,label:`上下文`},{id:`ast`,label:`代码图`},{id:`pals`,label:`Pals`},{id:`worktrees`,label:`工作树`}],Ed=_.lazy(()=>wd(()=>import(`./interactive-terminal-OJuLa-R6.js`),[],import.meta.url));function Dd({snapshot:e,onClose:t,onError:n,onCompose:r}){let[i,a]=(0,_.useState)(`cockpit`),[o,s]=(0,_.useState)(()=>Vd(e.jobs.map(e=>e.label).join(`
150
+ `);if(n.at(-1)===``&&n.pop(),t&&!n.some(e=>e.startsWith(`@@`)))return n.map((e,t)=>({kind:`addition`,marker:`+`,text:e,newNumber:t+1}));let r=0,i=0,a=!1;return n.map(e=>{let t=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@(.*)$/.exec(e);if(t!==null)return r=Number(t[1]),i=Number(t[2]),a=!0,{kind:`hunk`,marker:`@@`,text:t[3]?.trim()??``};if(!a||e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`--- `)||e.startsWith(`+++ `))return{kind:`meta`,marker:``,text:e};if(e.startsWith(`+`)&&!e.startsWith(`+++`))return{kind:`addition`,marker:`+`,text:e.slice(1),newNumber:i++};if(e.startsWith(`-`)&&!e.startsWith(`---`))return{kind:`deletion`,marker:`−`,text:e.slice(1),oldNumber:r++};if(e.startsWith(`\\ No newline`))return{kind:`meta`,marker:``,text:e};let n={kind:`context`,marker:``,text:e.startsWith(` `)?e.slice(1):e,oldNumber:r,newNumber:i};return r+=1,i+=1,n})}function dd({onClose:e,onReview:t,onError:n}){let[r,i]=(0,_.useState)(ld),[a,o]=(0,_.useState)(),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(`working`),[d,f]=(0,_.useState)(!0),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(``),v=(0,_.useMemo)(()=>ud(s,a?.untracked),[s,a?.untracked]),y=v.filter(e=>e.kind===`addition`).length,b=v.filter(e=>e.kind===`deletion`).length,x=r.files.filter(e=>e.staged).length,S=async()=>{try{i(await window.flavorDesktop.gitStatus())}catch(e){n(pd(e))}finally{f(!1)}};(0,_.useEffect)(()=>{S()},[]);let C=async(e,t)=>{m(!0),c(``),u(t);try{c(await window.flavorDesktop.gitDiff(e.path,t===`staged`))}catch(e){let t=pd(e);c(t),n(t)}finally{m(!1)}},w=async e=>{o(e),await C(e,e.unstaged||e.untracked?`working`:`staged`)},ee=async(e,t)=>{if(!(e===`discard`&&!window.confirm(`确定还原 ${t.path}?此操作无法撤销。`)))try{let n=e===`stage`?await window.flavorDesktop.gitStage(t.path):e===`unstage`?await window.flavorDesktop.gitUnstage(t.path):await window.flavorDesktop.gitDiscard(t.path);i(n);let r=n.files.find(e=>e.path===t.path);r===void 0?(o(void 0),c(``)):(o(r),await C(r,r.unstaged||r.untracked?`working`:`staged`))}catch(e){n(pd(e))}},T=async()=>{if(h.trim())try{let e=await window.flavorDesktop.gitCommit(h.trim());i(e.status),g(``),o(void 0),c(``),n(`已提交 ${e.result}`)}catch(e){n(pd(e))}};return(0,P.jsxs)(`section`,{className:`manager-view git-view`,children:[(0,P.jsxs)(`header`,{className:`manager-header git-header`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`button`,{className:`git-back`,onClick:e,"aria-label":`返回`,children:`←`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{children:`Git 变更`}),(0,P.jsx)(`span`,{children:`审阅并整理本次工作区修改`})]})]}),r.repository&&(0,P.jsxs)(`span`,{className:`git-branch`,children:[(0,P.jsx)(`i`,{}),r.branch,(0,P.jsx)(`b`,{children:r.head})]})]}),d?(0,P.jsx)(`p`,{className:`manager-empty`,children:`正在读取工作区…`}):r.repository?(0,P.jsxs)(`div`,{className:`git-layout`,children:[(0,P.jsxs)(`aside`,{className:`git-files`,children:[(0,P.jsxs)(`div`,{className:`git-toolbar`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:`变更`}),(0,P.jsx)(`span`,{children:r.files.length})]}),(0,P.jsx)(`button`,{onClick:()=>void S(),title:`重新读取变更`,children:`↻`})]}),r.files.length===0?(0,P.jsxs)(`div`,{className:`git-clean`,children:[(0,P.jsx)(`i`,{children:`✓`}),(0,P.jsx)(`strong`,{children:`工作区干净`}),(0,P.jsx)(`span`,{children:`没有需要审阅的修改`})]}):r.files.map(e=>{let t=fd(e.path),n=e.untracked?`U`:e.index===`A`?`A`:e.index===`D`||e.worktree===`D`?`D`:`M`;return(0,P.jsxs)(`div`,{className:`git-file-row`,"data-active":a?.path===e.path,children:[(0,P.jsxs)(`button`,{className:`git-file-name`,onClick:()=>void w(e),title:e.path,children:[(0,P.jsx)(`code`,{"data-state":n,children:n}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`b`,{children:t.name}),t.directory&&(0,P.jsx)(`small`,{children:t.directory})]})]}),(0,P.jsxs)(`div`,{className:`git-file-actions`,children:[e.staged?(0,P.jsx)(`button`,{onClick:()=>void ee(`unstage`,e),children:`取消暂存`}):(0,P.jsx)(`button`,{className:`stage-action`,onClick:()=>void ee(`stage`,e),children:`暂存`}),(e.unstaged||e.untracked)&&(0,P.jsx)(`button`,{className:`danger-text`,onClick:()=>void ee(`discard`,e),children:`还原`})]})]},e.path)})]}),(0,P.jsx)(`article`,{className:`git-diff`,children:a===void 0?(0,P.jsxs)(`div`,{className:`git-diff-empty`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{children:`−`}),(0,P.jsx)(`span`,{children:`+`})]}),(0,P.jsx)(`strong`,{children:`选择文件查看差异`}),(0,P.jsx)(`p`,{children:`逐行审阅修改,然后决定暂存或还原。`})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`header`,{className:`git-diff-header`,children:[(0,P.jsxs)(`div`,{className:`git-diff-title`,children:[(0,P.jsx)(`span`,{children:fd(a.path).directory||`项目根目录`}),(0,P.jsx)(`strong`,{children:fd(a.path).name})]}),(0,P.jsxs)(`div`,{className:`git-diff-controls`,children:[a.staged&&a.unstaged&&(0,P.jsxs)(`div`,{className:`git-layer-switch`,children:[(0,P.jsx)(`button`,{"data-active":l===`working`,onClick:()=>void C(a,`working`),children:`工作区`}),(0,P.jsx)(`button`,{"data-active":l===`staged`,onClick:()=>void C(a,`staged`),children:`已暂存`})]}),!p&&(0,P.jsxs)(`div`,{className:`git-diff-stats`,children:[(0,P.jsxs)(`span`,{className:`add`,children:[`+`,y]}),(0,P.jsxs)(`span`,{className:`del`,children:[`−`,b]})]})]})]}),(0,P.jsx)(`div`,{className:`git-code`,"aria-label":`${a.path} 差异`,children:p?(0,P.jsxs)(`div`,{className:`git-diff-loading`,children:[(0,P.jsx)(`i`,{}),`正在生成差异…`]}):v.map((e,t)=>(0,P.jsxs)(`div`,{className:`git-code-line`,"data-kind":e.kind,children:[(0,P.jsx)(`span`,{className:`old-line`,children:e.oldNumber??``}),(0,P.jsx)(`span`,{className:`new-line`,children:e.newNumber??``}),(0,P.jsx)(`span`,{className:`change-marker`,children:e.marker}),(0,P.jsx)(`code`,{children:e.text||` `})]},`${t}-${e.oldNumber??``}-${e.newNumber??``}`))})]})})]}):(0,P.jsx)(`p`,{className:`manager-empty`,children:`当前项目不是 Git 仓库`}),r.repository&&(0,P.jsxs)(`footer`,{className:`git-footer`,children:[(0,P.jsx)(`button`,{className:`review-action`,onClick:t,children:`交给 /review`}),(0,P.jsxs)(`div`,{className:`commit-field`,children:[(0,P.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:x>0?`描述这次提交…`:`暂存文件后即可提交`}),(0,P.jsxs)(`span`,{children:[x,` 个文件已暂存`]})]}),(0,P.jsx)(`button`,{className:`commit-action`,disabled:!h.trim()||x===0,onClick:()=>void T(),children:`提交`})]})]})}function fd(e){let t=e.replace(/\\/g,`/`),n=t.lastIndexOf(`/`);return n<0?{name:t,directory:``}:{name:t.slice(n+1),directory:t.slice(0,n)}}function pd(e){return e instanceof Error?e.message:String(e)}function md(e){let t=[],n,r=()=>{if(n===void 0)return;let e=n.lines.length,r=n.hunks.map((t,r)=>({...t,end:n.hunks[r+1]?.start??e}));t.push({...n,hunks:r})};for(let t of e.split(/\r?\n/)){let e=/^diff --(?:git|flavor) a\/(.+?) b\/(.+)$/.exec(t);if(e!==null){r(),n={path:e[2],lines:[t],hunks:[],additions:0,deletions:0};continue}if(n===void 0)continue;let i=n.lines.length;n.lines.push(t),t.startsWith(`@@`)?n.hunks.push({id:`${n.path}:${n.hunks.length+1}`,header:t,start:i,end:i+1}):t.startsWith(`+`)&&!t.startsWith(`+++`)?n.additions+=1:t.startsWith(`-`)&&!t.startsWith(`---`)&&(n.deletions+=1)}return r(),t}function hd(e){return Math.min(2.4,Math.max(.55,e))}function gd(e,t,n){let r=hd(n),i=r/e.scale;return{x:t.x-(t.x-e.x)*i,y:t.y-(t.y-e.y)*i,scale:r}}function _d(e,t,n){return{x:Math.round(t.x+e.x*n.width*t.scale/100),y:Math.round(t.y+e.y*n.height*t.scale/100)}}function vd(e,t){let n=new Map,r=[];n.set(e.id,{...e,role:`origin`,x:50,y:50});let i=(t,i,a)=>{t.slice(0,8).forEach((t,o,s)=>{n.set(t.id,{...t,role:i,x:a,y:(o+1)*100/(s.length+1)}),r.push(i===`caller`?{from:t.id,to:e.id,kind:i}:{from:e.id,to:t.id,kind:i})})};i(t.callers,`caller`,14),i(t.callees,`callee`,86);let a=t.impact.filter(e=>!n.has(e.id)).slice(0,12),o=Math.ceil(a.length/2);return a.forEach((t,i)=>{let s=i<o,c=s?i:i-o,l=s?o:a.length-o,u=Math.floor(c/3),d=c%3,f=Math.min(3,l-u*3),p=(d+1)*100/(f+1),m=s?13+u*11:87-u*11;n.set(t.id,{...t,role:`impact`,x:p,y:m,hop:t.hop}),r.push({from:e.id,to:t.id,kind:`impact`,hop:t.hop})}),{nodes:[...n.values()],edges:r}}function $(e){let t=new Map(e.map(e=>[e.id,e]));return e.map(e=>{let n=0,r=e.parentId,i=new Set([e.id]);for(;r!==null&&n<12&&!i.has(r);){i.add(r);let e=t.get(r);if(e===void 0)break;n+=1,r=e.parentId}return{node:e,depth:n}})}function yd(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).at(-1)??e}function bd(e,t){let n=t.filter(e=>e.state!==`closed`);return e!==void 0&&n.some(t=>t.id===e)?e:n.find(e=>e.state===`running`)?.id??n[0]?.id}var xd=`modulepreload`,Sd=function(e,t){return new URL(e,t).href},Cd={},wd=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Sd(t,n),t=s(t),t in Cd)return;Cd[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:xd,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Td=[{id:`cockpit`,label:`执行`},{id:`timeline`,label:`时间机`},{id:`terminal`,label:`终端`},{id:`review`,label:`审查`},{id:`preview`,label:`预览`},{id:`context`,label:`上下文`},{id:`ast`,label:`代码图`},{id:`pals`,label:`Pals`},{id:`worktrees`,label:`工作树`}],Ed=_.lazy(()=>wd(()=>import(`./interactive-terminal-DestMQ2z.js`),[],import.meta.url));function Dd({snapshot:e,onClose:t,onError:n,onCompose:r}){let[i,a]=(0,_.useState)(`cockpit`),[o,s]=(0,_.useState)(()=>Vd(e.jobs.map(e=>e.label).join(`
151
151
  `))),c=(0,_.useRef)(new Map),l=e=>s(t=>[...new Set([...t,...Vd(e)])].slice(-20));return(0,_.useEffect)(()=>{let t=!1;return Promise.all(e.jobs.map(async e=>{let n=await window.flavorDesktop.readJob(e.id,c.current.get(e.id)??0).catch(()=>void 0);n===void 0||t||(c.current.set(e.id,n.cursor),l(n.output))})),()=>{t=!0}},[e.jobs]),(0,P.jsxs)(`section`,{className:`agent-workbench manager-view`,children:[(0,P.jsxs)(`header`,{className:`manager-header workbench-header`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`button`,{onClick:t,children:`‹`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`small`,{children:`FLAVOR DESKTOP 1.3.4`}),(0,P.jsx)(`h2`,{children:`Agent 工作台`})]})]}),(0,P.jsx)(`span`,{children:e.activeSession?.environment===`worktree`?`隔离工作树`:`本地检出`})]}),(0,P.jsx)(`nav`,{className:`workbench-tabs`,"aria-label":`工作台功能`,children:Td.map(e=>(0,P.jsx)(`button`,{"data-active":i===e.id,onClick:()=>a(e.id),children:e.label},e.id))}),(0,P.jsxs)(`div`,{className:`workbench-stage`,children:[i===`cockpit`&&(0,P.jsx)(Od,{snapshot:e,onCompose:r}),i===`timeline`&&(0,P.jsx)(kd,{onError:n}),i===`terminal`&&(0,P.jsx)(Ad,{onError:n,onDiscover:l}),i===`review`&&(0,P.jsx)(jd,{onError:n,onCompose:r}),i===`preview`&&(0,P.jsx)(Nd,{onError:n,suggestions:o}),i===`context`&&(0,P.jsx)(Pd,{snapshot:e,onError:n}),i===`ast`&&(0,P.jsx)(Fd,{onError:n,onCompose:r}),i===`pals`&&(0,P.jsx)(Rd,{onError:n}),i===`worktrees`&&(0,P.jsx)(zd,{snapshot:e,onError:n})]})]})}function Od({snapshot:e,onCompose:t}){let[n,r]=(0,_.useState)(),[i,a]=(0,_.useState)(``);(0,_.useEffect)(()=>{window.flavorDesktop.inspectWorkbench().then(r).catch(()=>void 0)},[e.activeSession?.sessionId]);let o=n?.goals[0];(0,_.useEffect)(()=>{o!==void 0&&a(o.objective)},[o?.id]);let s=e.tasks?.plan?.tasks??[],c=Object.entries(e.tasks?.subagents.states??{});return(0,P.jsxs)(`div`,{className:`cockpit-grid`,children:[(0,P.jsxs)(`section`,{className:`cockpit-trace`,children:[(0,P.jsxs)(`header`,{children:[(0,P.jsx)(`small`,{children:`EXECUTION TRACE`}),(0,P.jsx)(`h3`,{children:o?.objective??`当前会话尚未启动持久目标`})]}),(0,P.jsx)(`ol`,{children:s.length===0?(0,P.jsxs)(`li`,{"data-state":`pending`,children:[(0,P.jsx)(`i`,{}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:`等待执行计划`}),(0,P.jsx)(`small`,{children:`TaskPlan 出现后会自动同步`})]})]}):s.map(e=>(0,P.jsxs)(`li`,{"data-state":e.status,children:[(0,P.jsx)(`i`,{}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:e.subject}),(0,P.jsxs)(`small`,{children:[e.status,e.result?` · ${e.result}`:``]})]})]},e.id))})]}),(0,P.jsxs)(`aside`,{className:`cockpit-evidence`,children:[(0,P.jsxs)(`section`,{children:[(0,P.jsx)(`small`,{children:`目标状态`}),(0,P.jsx)(`b`,{"data-phase":o?.phase,children:o?.phase??`idle`}),(0,P.jsx)(`p`,{children:o?`${o.status} · worker ${o.workerRounds} · verify ${o.verifyRounds}`:`使用 /goal 启动带验证的长期任务`}),o&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`textarea`,{className:`cockpit-goal-editor`,value:i,onChange:e=>a(e.target.value),"aria-label":`继续目标`}),(0,P.jsxs)(`div`,{className:`cockpit-goal-actions`,children:[e.activeSession?.busy&&(0,P.jsx)(`button`,{onClick:()=>void window.flavorDesktop.interrupt(),children:`安全暂停`}),(0,P.jsx)(`button`,{disabled:!i.trim(),onClick:()=>t(`/goal ${i.trim()}`),children:`以编辑目标继续`})]})]})]}),(0,P.jsxs)(`section`,{children:[(0,P.jsx)(`small`,{children:`协作 Agent`}),c.length===0?(0,P.jsx)(`p`,{children:`没有活跃子 Agent`}):c.map(([e,t])=>(0,P.jsxs)(`div`,{className:`cockpit-row`,children:[(0,P.jsx)(`code`,{children:e}),(0,P.jsx)(`span`,{"data-state":t,children:t})]},e))]}),(0,P.jsxs)(`section`,{children:[(0,P.jsx)(`small`,{children:`后台作业`}),e.jobs.length===0?(0,P.jsx)(`p`,{children:`没有后台作业`}):e.jobs.map(e=>(0,P.jsxs)(`div`,{className:`cockpit-row`,children:[(0,P.jsx)(`code`,{children:e.label}),(0,P.jsx)(`span`,{"data-state":e.state,children:e.state})]},e.id))]}),o&&o.evidenceRounds.length>0&&(0,P.jsxs)(`section`,{children:[(0,P.jsx)(`small`,{children:`验证证据`}),o.evidenceRounds.slice(-3).reverse().map(e=>(0,P.jsxs)(`div`,{className:`cockpit-evidence-round`,children:[(0,P.jsxs)(`b`,{children:[`ROUND `,e.round]}),(0,P.jsx)(`p`,{children:e.hostVerification?.summary??`workspace ${e.workspaceDiffHash.slice(0,10)}`}),(0,P.jsx)(`span`,{"data-passed":e.hostVerification?.passed,children:e.hostVerification===void 0?`workspace evidence`:e.hostVerification.passed?`passed`:`failed`})]},e.round))]}),o&&o.lastGaps.length>0&&(0,P.jsxs)(`section`,{children:[(0,P.jsx)(`small`,{children:`验证缺口`}),o.lastGaps.map((e,t)=>(0,P.jsx)(`p`,{className:`cockpit-gap`,children:e.description},t))]})]})]})}function kd({onError:e}){let[t,n]=(0,_.useState)({leafId:null,nodes:[]}),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(!1),s=()=>window.flavorDesktop.historySnapshot().then(n).catch(t=>e(Bd(t)));(0,_.useEffect)(()=>{s()},[]);let c=async t=>{o(!0);try{await t(),await s()}catch(t){e(Bd(t))}finally{o(!1)}},l=$(t.nodes);return(0,P.jsxs)(`div`,{className:`timeline-layout`,children:[(0,P.jsxs)(`section`,{className:`timeline-canvas`,children:[(0,P.jsxs)(`header`,{children:[(0,P.jsx)(`small`,{children:`SESSION TREE`}),(0,P.jsxs)(`h3`,{children:[t.nodes.length,` 个可恢复节点`]})]}),(0,P.jsx)(`ol`,{children:l.map(({node:e,depth:n})=>(0,P.jsxs)(`li`,{className:`timeline-node`,style:{paddingLeft:n*26},"data-depth":n,"data-current":e.id===t.leafId,children:[(0,P.jsx)(`i`,{}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:e.prompt||e.id}),(0,P.jsxs)(`small`,{children:[new Date(e.createdAt).toLocaleString(),` · `,e.checkpointId]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`button`,{disabled:a,onClick:()=>void c(()=>window.flavorDesktop.rewindHistory(e.id)),children:`回到这里`}),(0,P.jsx)(`button`,{disabled:a,onClick:()=>{window.confirm(`从这个节点建立新分支?当前上下文将切换。`)&&c(()=>window.flavorDesktop.forkHistory(e.id))},children:`Fork`})]})]},e.id))})]}),(0,P.jsxs)(`aside`,{className:`timeline-actions`,children:[(0,P.jsx)(`h3`,{children:`建立安全点`}),(0,P.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`例如:重构前`}),(0,P.jsx)(`button`,{disabled:a,onClick:()=>void c(()=>window.flavorDesktop.createCheckpoint(r||void 0)),children:`创建 checkpoint`}),(0,P.jsx)(`button`,{disabled:a,onClick:()=>void c(()=>window.flavorDesktop.unrevertHistory()),children:`撤销上次回退`})]})]})}function Ad({onError:e,onDiscover:t}){let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(),o=n.find(e=>e.id===i),s=(e,t)=>{let n=e.filter(e=>e.state!==`closed`);r(n),a(e=>bd(t??e,n))},c=async e=>s(await window.flavorDesktop.listTerminals(),e);(0,_.useEffect)(()=>{c().catch(t=>e(Bd(t)))},[]);let l=async()=>{try{let e=await window.flavorDesktop.openTerminal();await c(e.id)}catch(t){e(Bd(t))}},u=async()=>{if(i!==void 0)try{await window.flavorDesktop.closeTerminal(i),await c()}catch(t){e(Bd(t))}};return(0,P.jsxs)(`div`,{className:`terminal-layout`,children:[(0,P.jsxs)(`aside`,{children:[(0,P.jsx)(`button`,{className:`primary`,onClick:()=>void l(),children:`+ 新终端`}),n.map(e=>(0,P.jsxs)(`button`,{"data-active":e.id===i,onClick:()=>a(e.id),title:e.shell,children:[(0,P.jsx)(`strong`,{children:yd(e.shell)}),(0,P.jsxs)(`small`,{children:[e.state,` · `,e.id]})]},e.id))]}),(0,P.jsxs)(`main`,{children:[(0,P.jsxs)(`header`,{children:[(0,P.jsx)(`span`,{title:o?.cwd,children:o?.cwd??`尚未打开终端`}),o&&(0,P.jsx)(`button`,{onClick:()=>void u(),children:`关闭终端`})]}),o===void 0?(0,P.jsxs)(`div`,{className:`terminal-empty`,children:[(0,P.jsx)(`b`,{children:`没有打开终端`}),(0,P.jsx)(`span`,{children:`新建终端后,直接在终端区域输入和操作。`})]}):(0,P.jsx)(_.Suspense,{fallback:(0,P.jsxs)(`div`,{className:`terminal-empty`,children:[(0,P.jsx)(`b`,{children:`正在连接终端`}),(0,P.jsx)(`span`,{children:`正在加载交互渲染器…`})]}),children:(0,P.jsx)(Ed,{terminal:o,onError:e,onDiscover:t},o.id)})]})]})}function jd({onError:e,onCompose:t}){let[n,r]=(0,_.useState)(`working`),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(),[f,p]=(0,_.useState)(),m=(0,_.useMemo)(()=>md(o),[o]),h=m.find(e=>e.path===u)??m[0],g=async()=>{l(!0);try{let e=await window.flavorDesktop.gitReview(n,i||void 0);s(e);let t=md(e);d(t[0]?.path),p(t[0]?.hunks[0]?.id)}catch(t){e(Bd(t))}finally{l(!1)}};return(0,_.useEffect)(()=>{if(n===`commit`||n===`base`){s(``),d(void 0),p(void 0);return}g()},[n]),(0,P.jsxs)(`div`,{className:`review-layout`,children:[(0,P.jsxs)(`aside`,{className:`review-scope`,children:[(0,P.jsx)(`small`,{children:`DIFF SCOPE`}),[`working`,`staged`,`last-turn`,`commit`,`base`].map(e=>(0,P.jsx)(`button`,{"data-active":n===e,onClick:()=>r(e),children:e},e)),(n===`commit`||n===`base`)&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),placeholder:n===`base`?`main / origin/main`:`commit SHA`}),(0,P.jsx)(`button`,{onClick:()=>void g(),children:`载入范围`})]})]}),(0,P.jsxs)(`section`,{className:`review-files`,"aria-label":`变更文件`,children:[(0,P.jsxs)(`header`,{children:[(0,P.jsx)(`strong`,{children:`文件`}),(0,P.jsx)(`span`,{children:m.length})]}),m.map(e=>(0,P.jsxs)(`button`,{"data-active":e.path===h?.path,onClick:()=>{d(e.path),p(e.hunks[0]?.id)},children:[(0,P.jsx)(`strong`,{children:e.path.split(`/`).at(-1)}),(0,P.jsx)(`small`,{children:e.path}),(0,P.jsxs)(`span`,{children:[(0,P.jsxs)(`b`,{children:[`+`,e.additions]}),(0,P.jsxs)(`em`,{children:[`-`,e.deletions]})]})]},e.path))]}),(0,P.jsxs)(`main`,{children:[(0,P.jsxs)(`header`,{children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:h?.path??n}),(0,P.jsxs)(`span`,{children:[h?.hunks.length??0,` hunks`]})]}),(0,P.jsx)(`button`,{onClick:()=>t(`/review 请审查 ${n}${i?` ${i}`:``}${h?` 中的 ${h.path}`:``},按 P0/P1/P2 分级输出发现,必须给出文件行号和触发场景。`),children:`交给 Agent 审查`})]}),h&&h.hunks.length>0&&(0,P.jsx)(`nav`,{className:`review-hunks`,"aria-label":`Hunk 导航`,children:h.hunks.map((e,t)=>(0,P.jsxs)(`button`,{"data-active":f===e.id,onClick:()=>p(e.id),children:[`H`,t+1,(0,P.jsx)(`span`,{children:e.header})]},e.id))}),(0,P.jsx)(Md,{file:h,activeHunk:f,loading:c,empty:o}),(0,P.jsxs)(`footer`,{className:`review-priority-legend`,children:[(0,P.jsx)(`span`,{"data-priority":`0`,children:`P0 阻断`}),(0,P.jsx)(`span`,{"data-priority":`1`,children:`P1 高风险`}),(0,P.jsx)(`span`,{"data-priority":`2`,children:`P2 一般`}),(0,P.jsx)(`small`,{children:`审查结果将在对话中返回,并携带文件行号。`})]})]})]})}function Md({file:e,activeHunk:t,loading:n,empty:r}){return n?(0,P.jsx)(`div`,{className:`review-empty`,children:`正在生成 diff…`}):e===void 0?(0,P.jsx)(`div`,{className:`review-empty`,children:r||`此范围没有差异`}):(0,P.jsx)(`div`,{className:`review-code`,role:`region`,"aria-label":`${e.path} 差异`,children:(0,P.jsx)(`pre`,{children:e.lines.map((n,r)=>{let i=e.hunks.find(e=>r>=e.start&&r<e.end);return(0,P.jsx)(`code`,{"data-kind":n.startsWith(`+++`)||n.startsWith(`---`)?`meta`:n.startsWith(`+`)?`addition`:n.startsWith(`-`)?`deletion`:n.startsWith(`@@`)?`hunk`:`context`,"data-active":i?.id===t,children:n||` `},r)})})})}function Nd({onError:e,suggestions:t}){let[n,r]=(0,_.useState)(`http://localhost:3000`),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(0),c=async()=>{try{a(await window.flavorDesktop.validatePreviewUrl(n))}catch(t){e(Bd(t))}};return(0,P.jsxs)(`div`,{className:`preview-layout`,children:[(0,P.jsxs)(`header`,{children:[(0,P.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c()}}),(0,P.jsx)(`button`,{onClick:()=>void c(),children:`打开`}),(0,P.jsx)(`button`,{disabled:!i,onClick:()=>s(e=>e+1),children:`刷新`}),(0,P.jsx)(`button`,{disabled:!i,onClick:()=>{i&&window.flavorDesktop.openPreviewUrl(i)},children:`外部打开`}),(0,P.jsx)(`button`,{disabled:!i,onClick:()=>{i&&navigator.clipboard.writeText(i)},children:`复制`})]}),t.length>0&&(0,P.jsxs)(`div`,{className:`preview-suggestions`,children:[`检测到:`,t.map(t=>(0,P.jsx)(`button`,{onClick:()=>{r(t),window.flavorDesktop.validatePreviewUrl(t).then(a).catch(t=>e(Bd(t)))},children:t},t))]}),i?(0,P.jsx)(`iframe`,{src:i,title:`本地应用预览`,sandbox:`allow-forms allow-modals allow-popups allow-scripts allow-same-origin`},o):(0,P.jsxs)(`div`,{className:`preview-empty`,children:[(0,P.jsx)(`strong`,{children:`安全的本地预览`}),(0,P.jsx)(`p`,{children:`仅允许 localhost、127.0.0.1 和 ::1 的 HTTP(S) 地址。`})]})]})}function Pd({snapshot:e,onError:t}){let[n,r]=(0,_.useState)();return(0,_.useEffect)(()=>{window.flavorDesktop.inspectWorkbench().then(r).catch(e=>t(Bd(e)))},[]),(0,P.jsxs)(`div`,{className:`context-grid`,children:[(0,P.jsxs)(`section`,{children:[(0,P.jsxs)(`header`,{children:[(0,P.jsx)(`small`,{children:`RUNTIME`}),(0,P.jsx)(`h3`,{children:`上下文 Epoch`})]}),(0,P.jsxs)(`dl`,{children:[(0,P.jsx)(`dt`,{children:`Permission`}),(0,P.jsx)(`dd`,{children:e.activeSession?.permissionMode??`—`}),(0,P.jsx)(`dt`,{children:`Model`}),(0,P.jsx)(`dd`,{children:e.activeSession?.mainModel??`—`}),(0,P.jsx)(`dt`,{children:`Checkout`}),(0,P.jsx)(`dd`,{children:e.activeSession?.workingDirectory??e.workspace??`—`})]}),n?.context?.epoch!==void 0&&(0,P.jsx)(`pre`,{className:`context-record`,children:JSON.stringify(n.context.epoch,null,2)}),n?.context?.visibility.map((e,t)=>(0,P.jsx)(`pre`,{className:`context-record`,children:JSON.stringify(e,null,2)},t)),n?.context?.usage.map((e,t)=>(0,P.jsx)(`pre`,{className:`context-record`,children:JSON.stringify(e,null,2)},`usage-${t}`)),e.diagnostics.map((e,t)=>(0,P.jsx)(`p`,{className:`context-record`,children:e},`diag-${t}`))]}),(0,P.jsxs)(`section`,{children:[(0,P.jsxs)(`header`,{children:[(0,P.jsx)(`small`,{children:`INSTRUCTIONS`}),(0,P.jsx)(`h3`,{children:`生效的项目指令`})]}),n?.instructions.map(e=>(0,P.jsxs)(`details`,{children:[(0,P.jsx)(`summary`,{children:e.name}),(0,P.jsx)(`pre`,{children:e.content})]},e.path))]}),(0,P.jsxs)(`section`,{children:[(0,P.jsxs)(`header`,{children:[(0,P.jsx)(`small`,{children:`SAFETY`}),(0,P.jsx)(`h3`,{children:`权限规则与审计`})]}),n?.permissionFiles.map(e=>(0,P.jsxs)(`details`,{children:[(0,P.jsxs)(`summary`,{children:[e.tier,` · `,e.path]}),(0,P.jsx)(`pre`,{children:e.content})]},e.path)),n?.audit.slice(0,30).map((e,t)=>(0,P.jsx)(`pre`,{className:`context-record`,children:JSON.stringify(e,null,2)},t))]})]})}function Fd({onError:e,onCompose:t}){let[n,r]=(0,_.useState)(),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(),[u,d]=(0,_.useState)(),[f,p]=(0,_.useState)(2),[m,h]=(0,_.useState)(!1);(0,_.useEffect)(()=>{window.flavorDesktop.astStatus().then(r).catch(t=>e(Bd(t)))},[]);let g=async()=>{try{s(await window.flavorDesktop.astSearch(i))}catch(t){e(Bd(t))}},v=async(t,n=f)=>{l(t),h(!0);try{d(await window.flavorDesktop.astRelations(t.id,n))}catch(t){e(Bd(t))}finally{h(!1)}},y=c===void 0||u===void 0?void 0:vd(c,u);return(0,P.jsxs)(`div`,{className:`ast-layout`,children:[(0,P.jsxs)(`aside`,{className:`ast-symbols`,children:[(0,P.jsxs)(`header`,{children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`small`,{children:`SYMBOL INDEX`}),(0,P.jsx)(`strong`,{children:`代码索引`})]}),(0,P.jsx)(`span`,{"data-ready":n?.available,children:n?.available?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`b`,{children:n.nodes}),` symbols`,(0,P.jsx)(`br`,{}),(0,P.jsx)(`b`,{children:n.edges}),` edges`]}):`尚未建立索引`})]}),(0,P.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g()},children:[(0,P.jsx)(`span`,{"aria-hidden":`true`,children:`⌕`}),(0,P.jsx)(`input`,{"aria-label":`搜索代码符号`,value:i,onChange:e=>a(e.target.value),placeholder:`函数、类型或模块`}),(0,P.jsx)(`button`,{children:`搜索`})]}),(0,P.jsx)(`div`,{className:`ast-symbol-list`,children:o.length===0?(0,P.jsx)(`p`,{children:n?.available===!1?`项目尚未建立代码索引`:`输入名称,定位代码中的关键符号`}):o.map(e=>(0,P.jsxs)(`button`,{"data-active":e.id===c?.id,onClick:()=>void v(e),children:[(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:e.name}),(0,P.jsx)(`em`,{children:e.kind})]}),(0,P.jsxs)(`small`,{children:[e.filePath,`:`,e.startLine]})]},e.id))})]}),(0,P.jsxs)(`main`,{className:`ast-graph-stage`,children:[(0,P.jsxs)(`header`,{children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`small`,{children:`RELATION MAP`}),(0,P.jsx)(`h3`,{children:c?.qualifiedName??`代码关系浏览器`}),(0,P.jsx)(`code`,{children:c?`${c.filePath}:${c.startLine}-${c.endLine}`:`搜索并选择一个符号作为图中心`})]}),(0,P.jsxs)(`div`,{className:`ast-depth`,"aria-label":`影响深度`,children:[(0,P.jsx)(`span`,{children:`影响深度`}),[1,2,3,4].map(e=>(0,P.jsx)(`button`,{"aria-label":`${e} 层影响深度`,"data-active":f===e,onClick:()=>{p(e),c&&v(c,e)},children:e},e))]})]}),m?(0,P.jsx)(`div`,{className:`ast-graph-empty`,children:`正在展开关系图…`}):y?(0,P.jsx)(Id,{graph:y,selected:c,onSelect:e=>void v(e)}):(0,P.jsxs)(`div`,{className:`ast-graph-empty`,children:[(0,P.jsx)(`strong`,{children:`从一个符号开始`}),(0,P.jsx)(`p`,{children:`搜索函数、类或模块,在同一张图上查看调用者、被调用项和多跳影响范围。`})]})]}),(0,P.jsxs)(`aside`,{className:`ast-inspector`,children:[(0,P.jsxs)(`header`,{children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`small`,{children:`SYMBOL INSPECTOR`}),(0,P.jsx)(`h3`,{children:c?.name??`未选择符号`})]}),c&&(0,P.jsx)(`span`,{children:c.kind})]}),c?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`dl`,{children:[(0,P.jsx)(`dt`,{children:`语言`}),(0,P.jsx)(`dd`,{children:c.language}),(0,P.jsx)(`dt`,{children:`位置`}),(0,P.jsxs)(`dd`,{children:[c.filePath,`:`,c.startLine]}),c.signature&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`dt`,{children:`签名`}),(0,P.jsx)(`dd`,{children:c.signature})]})]}),(0,P.jsxs)(`button`,{className:`ast-compose`,onClick:()=>t(`请查看 @${c.filePath}#L${c.startLine}-L${c.endLine} 中的 ${c.qualifiedName}`),children:[(0,P.jsx)(`span`,{children:`加入输入框`}),(0,P.jsx)(`b`,{"aria-hidden":`true`,children:`↗`})]}),(0,P.jsx)(Ld,{title:`Callers`,nodes:u?.callers??[],onSelect:e=>void v(e)}),(0,P.jsx)(Ld,{title:`Callees`,nodes:u?.callees??[],onSelect:e=>void v(e)}),(0,P.jsx)(Ld,{title:`Impact`,nodes:u?.impact??[],onSelect:e=>void v(e)})]}):(0,P.jsx)(`p`,{className:`ast-inspector-empty`,children:`选择一个符号后,这里会显示源码位置和完整关系。`})]})]})}function Id({graph:e,selected:t,onSelect:n}){let r={x:0,y:0,scale:1},[i,a]=(0,_.useState)(r),[o,s]=(0,_.useState)({width:0,height:0}),[c,l]=(0,_.useState)(!1),u=(0,_.useRef)(null),d=(0,_.useRef)(void 0),f=new Map(e.nodes.map(e=>[e.id,e]));(0,_.useEffect)(()=>{a(r)},[t.id]),(0,_.useEffect)(()=>{let e=u.current;if(e===null)return;let t=()=>{let t=e.getBoundingClientRect();s({width:t.width,height:t.height})};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let p=(e,t)=>{let n=u.current?.getBoundingClientRect(),r=t??{x:(n?.width??0)/2,y:(n?.height??0)/2};a(t=>gd(t,r,e))},m=e=>{d.current?.pointerId===e.pointerId&&(d.current=void 0,l(!1),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))};return(0,P.jsxs)(`div`,{ref:u,className:`ast-graph`,"data-dragging":c,role:`region`,"aria-label":`${t.name} 代码关系图,可拖动和滚轮缩放`,onWheel:e=>{e.preventDefault();let t=e.currentTarget.getBoundingClientRect();p(i.scale*Math.exp(-e.deltaY*.0014),{x:e.clientX-t.left,y:e.clientY-t.top})},onPointerDown:e=>{e.button!==0||e.target.closest(`button`)||(e.currentTarget.setPointerCapture(e.pointerId),d.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY},l(!0))},onPointerMove:e=>{let t=d.current;if(t?.pointerId!==e.pointerId)return;let n=e.clientX-t.x,r=e.clientY-t.y;d.current={...t,x:e.clientX,y:e.clientY},a(e=>({...e,x:e.x+n,y:e.y+r}))},onPointerUp:m,onPointerCancel:m,children:[(0,P.jsx)(`div`,{className:`ast-graph-viewport`,style:{transform:`translate(${i.x}px, ${i.y}px) scale(${i.scale})`},children:(0,P.jsx)(`svg`,{viewBox:`0 0 100 100`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:e.edges.map((e,t)=>{let n=f.get(e.from),r=f.get(e.to);if(!n||!r)return null;let i=(n.x+r.x)/2;return(0,P.jsx)(`path`,{"data-kind":e.kind,d:`M ${n.x} ${n.y} C ${i} ${n.y}, ${i} ${r.y}, ${r.x} ${r.y}`},`${e.from}-${e.to}-${t}`)})})}),e.nodes.map(e=>{let t=_d(e,i,o);return(0,P.jsxs)(`button`,{className:`ast-graph-node`,"data-role":e.role,style:{left:t.x,top:t.y,visibility:o.width>0?`visible`:`hidden`},onClick:()=>n(e),title:`${e.qualifiedName}\n${e.filePath}:${e.startLine}`,children:[(0,P.jsx)(`i`,{}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:e.name}),(0,P.jsx)(`small`,{children:e.role===`impact`?`hop ${e.hop}`:e.kind})]})]},e.id)}),(0,P.jsxs)(`div`,{className:`ast-graph-hint`,children:[(0,P.jsx)(`span`,{"aria-hidden":`true`,children:`↔`}),` 拖动平移 `,(0,P.jsx)(`i`,{}),` 滚轮缩放`]}),(0,P.jsxs)(`div`,{className:`ast-graph-controls`,"aria-label":`画布缩放`,children:[(0,P.jsx)(`button`,{"aria-label":`放大`,onClick:()=>p(i.scale*1.2),children:`+`}),(0,P.jsxs)(`span`,{children:[Math.round(i.scale*100),`%`]}),(0,P.jsx)(`button`,{"aria-label":`缩小`,onClick:()=>p(i.scale/1.2),children:`−`}),(0,P.jsx)(`button`,{className:`ast-graph-reset`,"aria-label":`复位画布`,onClick:()=>a(r),children:`复位`})]}),(0,P.jsxs)(`div`,{className:`ast-graph-legend`,children:[(0,P.jsx)(`span`,{"data-kind":`caller`,children:`调用者`}),(0,P.jsx)(`span`,{"data-kind":`origin`,children:`中心符号`}),(0,P.jsx)(`span`,{"data-kind":`callee`,children:`被调用`}),(0,P.jsx)(`span`,{"data-kind":`impact`,children:`影响范围`})]})]})}function Ld({title:e,nodes:t,onSelect:n}){return(0,P.jsxs)(`section`,{className:`ast-relation`,children:[(0,P.jsxs)(`h4`,{children:[e,(0,P.jsx)(`span`,{children:t.length})]}),t.length===0?(0,P.jsx)(`p`,{children:`没有关系记录`}):t.slice(0,20).map(e=>(0,P.jsxs)(`button`,{onClick:()=>n(e),children:[(0,P.jsx)(`strong`,{children:e.name}),(0,P.jsxs)(`code`,{children:[e.filePath,`:`,e.startLine]})]},e.id))]})}function Rd({onError:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(),[d,f]=(0,_.useState)(),[p,m]=(0,_.useState)(),[h,g]=(0,_.useState)(),v=()=>window.flavorDesktop.listPals().then(e=>{f(void 0),n(e),i(t=>e.some(e=>e.alias===t)?t:e[0]?.alias)}).catch(e=>{n([]),f(Bd(e))});(0,_.useEffect)(()=>{v();let e=window.setInterval(v,4e3);return()=>window.clearInterval(e)},[]);let y=async(t,n,r)=>{m(t),g(void 0);try{r(await n())}catch(t){e(Bd(t))}finally{m(void 0)}},b=t.find(e=>e.alias===r),x=b?.alias,S=typeof l==`object`&&l?l:void 0,C=typeof S?.coWorkId==`string`?S.coWorkId:void 0,w=typeof S?.status==`string`?S.status:`created`,ee=e=>{x===void 0||!a.trim()||y(e,()=>window.flavorDesktop.sendPalMessage(x,a.trim(),e),()=>{o(``),g(e===`chat`?`消息已发送给 ${x}`:`任务已委托给 ${x}`)})};return(0,P.jsxs)(`div`,{className:`pals-layout`,children:[(0,P.jsxs)(`aside`,{children:[(0,P.jsxs)(`header`,{children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`small`,{children:`LOCAL BROKER`}),(0,P.jsx)(`h3`,{children:`在线 Pals`})]}),(0,P.jsx)(`span`,{children:t.length})]}),d===void 0?t.length===0&&(0,P.jsxs)(`div`,{className:`pals-list-empty`,children:[(0,P.jsx)(`b`,{children:`等待其他实例`}),(0,P.jsx)(`p`,{children:`同一台设备上的 Flavor 实例上线后会出现在这里。`})]}):(0,P.jsxs)(`div`,{className:`pals-unavailable`,children:[(0,P.jsx)(`strong`,{children:`正在恢复本地协作`}),(0,P.jsx)(`p`,{children:`broker 暂时不可用,工作台会自动重试。`}),(0,P.jsx)(`button`,{onClick:()=>void v(),children:`立即重试`})]}),(0,P.jsx)(`div`,{className:`pals-list`,children:t.map(e=>(0,P.jsxs)(`button`,{"data-active":r===e.alias,onClick:()=>{i(e.alias),g(void 0)},children:[(0,P.jsx)(`span`,{className:`pal-presence`,children:(0,P.jsx)(`i`,{})}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:e.alias}),(0,P.jsx)(`small`,{title:e.projectPath??e.id,children:e.projectPath??e.id})]}),(0,P.jsx)(`em`,{children:`在线`})]},e.id))})]}),(0,P.jsxs)(`main`,{children:[(0,P.jsxs)(`header`,{className:`pals-channel-header`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`small`,{children:`CO-WORK CHANNEL`}),(0,P.jsx)(`h3`,{children:x??`没有选中 Pal`}),(0,P.jsx)(`p`,{title:b?.projectPath,children:b?.projectPath??`从左侧选择一个在线实例后即可发送消息、委托任务或共同执行目标。`})]}),(0,P.jsxs)(`span`,{"data-online":b!==void 0,children:[(0,P.jsx)(`i`,{}),b===void 0?`等待选择`:`连接正常`]})]}),(0,P.jsxs)(`div`,{className:`pals-compose-grid`,children:[(0,P.jsxs)(`section`,{className:`pal-compose-card`,"data-kind":`message`,children:[(0,P.jsxs)(`header`,{children:[(0,P.jsx)(`span`,{children:`MESSAGE`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h4`,{children:`发消息或委托任务`}),(0,P.jsx)(`p`,{children:`同一段内容,可以即时沟通,也可以交给对方独立执行。`})]})]}),(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`内容`}),(0,P.jsx)(`textarea`,{"aria-label":`消息或任务内容`,value:a,onChange:e=>o(e.target.value),placeholder:`写下背景、期望结果和必要约束…`})]}),(0,P.jsxs)(`footer`,{children:[(0,P.jsx)(`small`,{children:a.length===0?`建议说明交付结果`:`${a.length} 字符`}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`button`,{disabled:p!==void 0||x===void 0||!a.trim(),onClick:()=>ee(`chat`),children:[(0,P.jsx)(`b`,{children:p===`chat`?`发送中…`:`发送 Chat`}),(0,P.jsx)(`span`,{children:`直接沟通`})]}),(0,P.jsxs)(`button`,{disabled:p!==void 0||x===void 0||!a.trim(),onClick:()=>ee(`task`),children:[(0,P.jsx)(`b`,{children:p===`task`?`委托中…`:`委托 Task`}),(0,P.jsx)(`span`,{children:`异步执行`})]})]})]})]}),(0,P.jsxs)(`section`,{className:`pal-compose-card`,"data-kind":`cowork`,children:[(0,P.jsxs)(`header`,{children:[(0,P.jsx)(`span`,{children:`CO-WORK`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h4`,{children:`共同完成一个目标`}),(0,P.jsx)(`p`,{children:`双方先共同规划,再持续同步执行状态与结果。`})]})]}),(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`共同目标`}),(0,P.jsx)(`textarea`,{"aria-label":`共同目标`,value:s,onChange:e=>c(e.target.value),placeholder:`描述目标、完成标准和双方需要协作的部分…`})]}),(0,P.jsxs)(`footer`,{children:[(0,P.jsx)(`small`,{children:s.length===0?`适合跨实例并行工作`:`${s.length} 字符`}),(0,P.jsxs)(`button`,{className:`primary`,disabled:p!==void 0||x===void 0||!s.trim(),onClick:()=>{x===void 0||!s.trim()||y(`cowork`,()=>window.flavorDesktop.startCoWork(x,s.trim()),e=>{u(e),c(``),g(`已与 ${x} 建立共同目标`)})},children:[(0,P.jsx)(`b`,{children:p===`cowork`?`建立中…`:`开始 Co-work`}),(0,P.jsx)(`span`,{children:`共同规划并执行`})]})]})]})]}),h!==void 0&&(0,P.jsxs)(`div`,{className:`pals-notice`,children:[(0,P.jsx)(`i`,{}),` `,h]}),l!==void 0&&(0,P.jsxs)(`section`,{className:`cowork-state`,children:[(0,P.jsxs)(`header`,{children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`small`,{children:`LIVE CO-WORK`}),(0,P.jsx)(`strong`,{children:`最新协作状态`})]}),(0,P.jsx)(`span`,{"data-status":w,children:w}),(0,P.jsxs)(`nav`,{children:[(0,P.jsx)(`button`,{disabled:p!==void 0,onClick:()=>void y(`refresh`,()=>window.flavorDesktop.coWorkStatus(C),u),children:`刷新状态`}),C&&(0,P.jsx)(`button`,{className:`danger`,disabled:p!==void 0,onClick:()=>{window.confirm(`取消这个 Co-work?`)&&y(`cancel`,()=>window.flavorDesktop.cancelCoWork(C,`cancelled from desktop workbench`),e=>{u(e),g(`协作已取消`)})},children:`取消协作`})]})]}),(0,P.jsxs)(`details`,{children:[(0,P.jsx)(`summary`,{children:`查看原始协作数据`}),(0,P.jsx)(`pre`,{children:JSON.stringify(l,null,2)})]})]})]})]})}function zd({snapshot:e,onError:t}){let[n,r]=(0,_.useState)([]),i=()=>window.flavorDesktop.listWorktrees().then(r).catch(e=>t(Bd(e)));return(0,_.useEffect)(()=>{i()},[]),(0,P.jsxs)(`div`,{className:`worktree-pane`,children:[(0,P.jsxs)(`header`,{children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`small`,{children:`TASK ISOLATION`}),(0,P.jsx)(`h3`,{children:`工作树`}),(0,P.jsx)(`p`,{children:`新任务可在独立分支中运行,不改动当前检出。`})]}),(0,P.jsxs)(`span`,{children:[n.length,` active`]})]}),n.length===0?(0,P.jsx)(`div`,{className:`manager-empty`,children:`还没有隔离工作树。新建任务时选择“隔离工作树”。`}):(0,P.jsx)(`div`,{className:`worktree-list`,children:n.map(n=>(0,P.jsxs)(`article`,{"data-current":e.activeSession?.worktreeId===n.id,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`i`,{}),(0,P.jsx)(`strong`,{children:n.branch}),(0,P.jsx)(`small`,{children:n.path})]}),(0,P.jsx)(`span`,{"data-dirty":n.dirty,children:n.merged?`merged`:n.dirty?`dirty`:`clean`}),(0,P.jsxs)(`div`,{className:`worktree-actions`,children:[(0,P.jsx)(`button`,{disabled:n.dirty||n.merged,onClick:()=>{window.confirm(`将 ${n.branch} 合并回当前项目分支?`)&&window.flavorDesktop.mergeWorktree(n.id).then(i).catch(e=>t(Bd(e)))},children:`合并交付`}),(0,P.jsx)(`button`,{onClick:()=>{window.confirm(`移除工作树 ${n.branch}?${n.dirty?`存在未提交变更,将强制移除。`:`分支会保留。`}`)&&window.flavorDesktop.removeWorktree(n.id,n.dirty).then(i).catch(e=>t(Bd(e)))},children:`移除并保留分支`})]})]},n.id))})]})}function Bd(e){return e instanceof Error?e.message:String(e)}function Vd(e){return e.match(/https?:\/\/(?:localhost|127\.0\.0\.1|\[?::1\]?)(?::\d{1,5})?(?:\/[^\s"'<>]*)?/gi)??[]}function Hd(e,t,n=Date.now()){return{task:e,framework:t,startedAt:n,updatedAt:n,phase:`analyzing`,comparisonCycle:0,activity:[{id:`import`,label:`HTML 设计稿已导入`,state:`completed`,startedAt:n,completedAt:n}]}}function Ud(e,t,n=Date.now()){if(t.type===`model-start`){let r=e.phase===`analyzing`?`分析设计并规划实现`:e.phase===`building`?`检查实现并规划下一步`:`分析评测结果`;return qd(e,{id:`model:${t.id}`,label:r,state:`running`,startedAt:n},n)}if(t.type===`model-end`)return Jd(e,`model:${t.id}`,`completed`,n);if(t.type===`tool-start`){let r=Gd(t.name,e.phase),i=Kd(t.name,t.label,t.hint);return qd({...e,phase:r},{id:`tool:${t.id}`,label:i,state:`running`,startedAt:n,...t.hint===void 0||t.hint===t.label?{}:{detail:Yd(t.hint,72)}},n)}if(t.type===`tool-end`){let r=t.result.ok?`completed`:`failed`,i=e.activity.find(e=>e.id===`tool:${t.id}`);return i===void 0?qd(e,{id:`tool:${t.id}`,label:Kd(t.name,t.label,t.hint),state:r,startedAt:n,completedAt:n},n):Jd(e,i.id,r,n)}return t.type===`model-retry`?qd(e,{id:`retry:${t.attempt}`,label:`模型请求重试 ${t.attempt}/${t.maxAttempts}`,detail:`${Math.ceil(t.delayMs/1e3)} 秒后继续`,state:`info`,startedAt:n,completedAt:n},n):t.type===`warning`?qd(e,{id:`warning:${n}`,label:Yd(t.message,96),state:`info`,startedAt:n,completedAt:n},n):t.type===`error`?qd(e,{id:`error:${n}`,label:Yd(t.error.message,96),state:`failed`,startedAt:n,completedAt:n},n):e}function Wd(e,t,n=Date.now()){if(t.task!==e.task)return e;let r=`engine:${t.cycle}:${t.stage}`,i=e.activity.find(e=>e.id===r);return qd({...e,phase:`evaluating`,comparisonCycle:t.cycle},{id:r,label:t.message,state:t.state,startedAt:i?.startedAt??n,...t.state===`running`?{}:{completedAt:n},...t.cached===!0?{detail:`已复用缓存`}:{}},n)}function Gd(e,t){return e===`D2cCompare`?`evaluating`:[`Write`,`Edit`,`ApplyPatch`,`Mkdir`,`Copy`,`Move`,`Shell`,`Bash`,`Command`,`Exec`].includes(e)?`building`:t}function Kd(e,t,n){let r=Yd(t??n??``,60),i=r===``?``:` ${r}`;return[`Read`,`Glob`,`Grep`,`Search`,`List`].includes(e)?`读取${i||`设计与项目文件`}`:e===`Write`?`创建${i||`前端文件`}`:e===`Edit`||e===`ApplyPatch`?`调整${i||`前端实现`}`:e===`Mkdir`?`创建${i||`项目目录`}`:[`Shell`,`Bash`,`Command`,`Exec`].includes(e)?`运行${i||`项目命令`}`:e===`D2cCompare`?`启动视觉评测`:`${e}${i}`}function qd(e,t,n){let r=e.activity.findIndex(e=>e.id===t.id),i=[...e.activity];return r<0?i.push(t):i[r]=t,{...e,updatedAt:n,activity:i.slice(-12)}}function Jd(e,t,n,r){let i=e.activity.find(e=>e.id===t);return i===void 0?e:qd(e,{...i,state:n,completedAt:r},r)}function Yd(e,t){let n=e.replaceAll(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}var Xd={sessions:[],diagnostics:[],models:[],jobs:[]},Zd=[`default`,`acceptEdits`,`plan`,`bypassPermissions`,`auto`,`bubble`],Qd=Xl.map(e=>({name:e,description:Zl[e]})),$d=5,ef=5*1024*1024,tf=20*1024*1024,nf=new Set([`image/png`,`image/jpeg`,`image/webp`]),rf=50;function af(e){let t=[];for(let n of e){let e=t.at(-1);n.type===`session-output`&&e?.type===`session-output`&&n.sessionId===e.sessionId&&n.workspace===e.workspace&&(n.event.type===`text`||n.event.type===`thinking`)&&e.event.type===n.event.type?t[t.length-1]={...n,event:{type:n.event.type,text:e.event.text+n.event.text}}:t.push(n)}return t}function of(e,t){return[e.trim(),...t.map((e,t)=>`[Image #${t+1}]`)].filter(Boolean).join(`
152
152
  `)}function sf({attachments:e,onRemove:t}){return(0,P.jsx)(`div`,{className:`image-attachment-strip`,"aria-label":`待发送图片`,children:e.map((e,n)=>(0,P.jsxs)(`figure`,{className:`image-attachment-chip`,children:[(0,P.jsx)(`img`,{src:e.previewUrl,alt:e.name}),(0,P.jsxs)(`figcaption`,{children:[(0,P.jsxs)(`strong`,{children:[`[Image #`,n+1,`]`]}),(0,P.jsx)(`span`,{children:e.name})]}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),"aria-label":`移除 ${e.name}`,title:`移除图片`,children:`×`})]},e.id))})}function cf(){let[e,t]=(0,_.useState)(Xd),[n,r]=(0,_.useState)(T),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(!0),[u,d]=(0,_.useState)(),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)(),[y,b]=(0,_.useState)(),[x,S]=(0,_.useState)(!1),[C,w]=(0,_.useState)(0),[ee,ne]=(0,_.useState)(),[re,ie]=(0,_.useState)([]),[ae,oe]=(0,_.useState)([]),[se,ce]=(0,_.useState)(0),[le,E]=(0,_.useState)(),[D,ue]=(0,_.useState)(),[de,fe]=(0,_.useState)(0),[O,k]=(0,_.useState)(`conversation`),[pe,me]=(0,_.useState)(!1),[he,ge]=(0,_.useState)(``),[_e,ve]=(0,_.useState)(`active`),[ye,be]=(0,_.useState)(),[xe,Se]=(0,_.useState)(),[Ce,we]=(0,_.useState)(``),[Te,Ee]=(0,_.useState)([]),[De,Oe]=(0,_.useState)(-1),[ke,Ae]=(0,_.useState)(0),[je,Fe]=(0,_.useState)(),[Le,Re]=(0,_.useState)(()=>new Map),ze=(0,_.useRef)(null),Be=(0,_.useRef)(null),A=(0,_.useRef)(void 0),Ve=(0,_.useRef)(void 0),j=(0,_.useRef)(n),He=(0,_.useRef)(new Map),Ue=(0,_.useRef)(new Map),We=(0,_.useRef)(new Map),Ge=(0,_.useRef)(new Set),Ke=(0,_.useRef)(!1),qe=(0,_.useCallback)(e=>{a(e),ne(void 0),E(void 0)},[]);(0,_.useEffect)(()=>{j.current=n},[n]);let Je=(0,_.useCallback)(()=>{let e=Ve.current;e!==void 0&&(He.current.set(e,{sessionId:A.current,transcript:j.current}),A.current!==void 0&&Ue.current.set(`${e}\u0000${A.current}`,j.current))},[]),Ye=(0,_.useCallback)(e=>{e!==void 0&&Re(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),Xe=(0,_.useCallback)(e=>{let n=e.workspace;Ve.current=n,A.current=e.activeSession?.sessionId,t(e);let i=n===void 0?void 0:He.current.get(n);r(i!==void 0&&i.sessionId===e.activeSession?.sessionId?i.transcript:T()),Ye(n),k(`conversation`),p(!1)},[Ye]);(0,_.useEffect)(()=>()=>{for(let e of Ge.current)URL.revokeObjectURL(e);Ge.current.clear()},[]);let Ze=(0,_.useCallback)(e=>{s(t=>{let n=t.find(t=>t.id===e);return n!==void 0&&(URL.revokeObjectURL(n.previewUrl),Ge.current.delete(n.previewUrl)),t.filter(t=>t.id!==e)})},[]),Qe=(0,_.useCallback)(()=>{s(e=>{for(let t of e)URL.revokeObjectURL(t.previewUrl),Ge.current.delete(t.previewUrl);return[]})},[]),$e=(0,_.useCallback)(async e=>{if(e.length===0)return;let t=$d-o.length;if(t<=0||e.length>t){d(`每条消息最多添加 ${$d} 张图片。`);return}if(o.reduce((e,t)=>e+Math.floor(t.dataBase64.length*3/4),0)+e.reduce((e,t)=>e+t.size,0)>tf){d(`单条消息的图片总大小不能超过 20 MiB。`);return}try{let t=await Promise.all(e.map(Tf));for(let e of t)Ge.current.add(e.previewUrl);s(e=>[...e,...t].slice(0,$d)),d(void 0)}catch(e){d(Vf(e))}},[o]);(0,_.useEffect)(()=>{let e=ze.current;if(!e)return;let t=e=>{e.deltaY<0?Ke.current=!0:requestAnimationFrame(()=>{let e=ze.current;e&&e.scrollHeight-e.scrollTop-e.clientHeight<8&&(Ke.current=!1)})};return e.addEventListener(`wheel`,t,{passive:!0}),()=>e.removeEventListener(`wheel`,t)},[]),(0,_.useEffect)(()=>{let e=[],n,i=e=>{if(e.type===`snapshot`&&e.workspace!==void 0&&e.snapshot.workspace===e.workspace){let t=Ve.current;if(t!==void 0&&t!==e.workspace){He.current.set(t,{sessionId:A.current,transcript:j.current});let n=He.current.get(e.workspace);r(n!==void 0&&n.sessionId===e.snapshot.activeSession?.sessionId?n.transcript:T()),k(`conversation`),Ye(e.workspace)}Ve.current=e.workspace}else if(e.workspace!==void 0&&(e.workspace!==Ve.current||e.type===`session-output`&&e.sessionId!==A.current||e.type===`session-started`&&e.payload.sessionId!==A.current)){let t=He.current.get(e.workspace)??{sessionId:void 0,transcript:T()};if(e.type===`session-started`){let t=te(T(),{type:`restore`,state:e.payload.restoredTranscript});Ue.current.set(`${e.workspace}\u0000${e.payload.sessionId}`,t),He.current.set(e.workspace,{sessionId:e.payload.sessionId,transcript:t})}else if(e.type===`session-output`){let n=`${e.workspace}\u0000${e.sessionId}`,r=Ie(Ue.current.get(n)??T(),e.sessionId,e);Ue.current.set(n,r),t.sessionId===e.sessionId&&He.current.set(e.workspace,{...t,transcript:r})}return}if(e.type===`d2c-report`){Ae(e=>e+1),Fe(t=>t!==void 0&&t.task===e.payload.task?void 0:t),k(`e2e`);return}if(e.type===`d2c-progress`){Fe(t=>t===void 0?t:Wd(t,e.payload));return}e.type===`session-output`&&e.sessionId===A.current&&Fe(t=>t===void 0?t:Ud(t,e.event)),(e.type===`session-output`&&e.sessionId===A.current&&[`done`,`error`,`exit`].includes(e.event.type)||e.type===`runtime-error`&&(e.sessionId===void 0||e.sessionId===A.current))&&Fe(void 0),pf(e,A,t,r,d)},a=()=>{n!==void 0&&(clearTimeout(n),n=void 0);let t=af(e.splice(0));for(let e of t)i(e)},o=window.flavorDesktop.onEvent(t=>{if(e.push(t),!(t.type===`session-output`&&(t.event.type===`text`||t.event.type===`thinking`))){a();return}n??=setTimeout(a,rf)});return window.flavorDesktop.bootstrap().then(e=>{Ve.current=e.workspace,A.current=e.activeSession?.sessionId,t(e)}).catch(e=>d(Vf(e))).finally(()=>l(!1)),()=>{n!==void 0&&clearTimeout(n),o()}},[]),(0,_.useEffect)(()=>{Ke.current||ze.current?.scrollTo({top:ze.current.scrollHeight,behavior:`smooth`})},[n]),(0,_.useEffect)(()=>{let e=!1;return window.flavorDesktop.listFiles().then(t=>{e||oe(On(t))}).catch(()=>{}),()=>{e=!0}},[e.workspace]),(0,_.useEffect)(()=>{let t=!1;return e.workspace===void 0?(ie([]),()=>{t=!0}):(window.flavorDesktop.listSkills().then(e=>{t||ie(e)}).catch(()=>{t||ie([])}),()=>{t=!0})},[e.workspace,O]);let et=e.activeSession?.busy??!1,tt=(0,_.useMemo)(()=>e.projects??(e.workspace===void 0?[]:[{workspace:e.workspace,sessions:e.sessions,...e.activeSession===void 0?{}:{activeSession:{sessionId:e.activeSession.sessionId,busy:e.activeSession.busy}},running:et||e.jobs.some(e=>e.state===`running`)}]),[e.projects,e.workspace,e.sessions,e.activeSession,e.jobs,et]);(0,_.useEffect)(()=>{Re(e=>{let t=Pe(tt,We.current,e);return We.current=t.activity,t.notices})},[tt]);let nt=(0,_.useMemo)(()=>mn(Qd,[],re.filter(e=>e.enabled),e.managedTools??[]),[re,e.managedTools]),rt=(0,_.useMemo)(()=>et||e.approval!==void 0||e.questions!==void 0||ee===i?null:gn(i,de,nt,C),[i,de,C,ee,et,e.approval,e.questions,nt]),it=(0,_.useMemo)(()=>et||e.approval!==void 0||e.questions!==void 0||le===i||rt!==null?null:kn(i,de,ae,se),[i,de,se,le,et,e.approval,e.questions,ae,rt]),at=rt===null?hn(i,nt,!1):0,ot=(0,_.useCallback)(e=>{let t=vn(i,de,e);a(t.text),ne(t.text),w(0),fe(t.cursor),setTimeout(()=>{let e=Be.current;e!==null&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},0)},[i,de]),st=(0,_.useCallback)(()=>{ne(i)},[i]),ct=(0,_.useCallback)(e=>{w(t=>_n(t,e,rt?.items.length??0))},[rt]),lt=(0,_.useCallback)(e=>{let t=jn(i,de,e);a(t.text),E(t.text),ce(0),ue(t.span===void 0?void 0:{...t.span,text:t.text.slice(t.span.start,t.span.end)}),fe(t.cursor),setTimeout(()=>{let e=Be.current;e!==null&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},0)},[i,de]),ut=(0,_.useCallback)(()=>{E(i)},[i]),dt=(0,_.useCallback)(e=>{ce(t=>An(t,e,it?.items.length??0))},[it]),ft=async()=>{d(void 0);try{Je();let e=await window.flavorDesktop.chooseWorkspace();e!==void 0&&(Qe(),Xe(e))}catch(e){d(Vf(e))}},pt=async n=>{if(n===e.workspace)return Ye(n),window.flavorDesktop.acknowledgeSession().then(t).catch(()=>void 0),k(`conversation`),p(!1),e;d(void 0),Je();try{let e=await window.flavorDesktop.openWorkspace(n);return Qe(),Xe(e),window.flavorDesktop.acknowledgeSession().then(t).catch(()=>void 0),e}catch(e){d(Vf(e));return}},mt=async(e,t)=>{let n=await pt(e);if(n!==void 0){if(n.activeSession?.sessionId===t.sessionId){k(`conversation`),p(!1);return}await ht(t)}},ht=async e=>{d(void 0);try{Je();let n=await window.flavorDesktop.selectSession(e.sessionId),i=n.snapshot.workspace===void 0?void 0:Ue.current.get(`${n.snapshot.workspace}\u0000${n.sessionId}`);t(n.snapshot),Ve.current=n.snapshot.workspace,A.current=n.sessionId,r(i??te(T(),{type:`restore`,state:n.restoredTranscript})),k(`conversation`),p(!1)}catch(e){d(Vf(e))}},gt=async(e,n)=>{d(void 0);try{let i=await window.flavorDesktop.startSession(e?.sessionId,n);Qe(),t(i.snapshot),Ve.current=i.snapshot.workspace,A.current=i.sessionId,r(te(T(),{type:`restore`,state:i.restoredTranscript})),i.snapshot.workspace!==void 0&&Ue.current.set(`${i.snapshot.workspace}\u0000${i.sessionId}`,te(T(),{type:`restore`,state:i.restoredTranscript})),p(!1),k(`conversation`),setTimeout(()=>Be.current?.focus(),0)}catch(e){d(Vf(e))}},_t=async(n,s,c)=>{let l=(n??i).trim(),u=n===void 0?o:[];if(!l&&u.length===0)return!1;d(void 0);try{let i=e;if(i.activeSession===void 0){let e=await window.flavorDesktop.startSession();i=e.snapshot,t(i),r(te(T(),{type:`restore`,state:e.restoredTranscript}))}let o=s??(et?`steer`:`prompt`);if(u.length>0&&o!==`prompt`)throw Error(`图片只能随新消息发送,不能作为运行中的引导或后续消息。`);return o===`prompt`&&r(e=>te(e,{type:`submit`,prompt:of(l,u)})),n===void 0&&a(``),await window.flavorDesktop.submit(l,o,u.map(({name:e,mediaType:t,dataBase64:n})=>({name:e,mediaType:t,dataBase64:n})),c),u.length>0&&Qe(),!0}catch(e){let t=Vf(e);return d(t),r(e=>te(e,{type:`submit-error`,message:t})),!1}},vt=e=>void _t(`/permissions ${e}`),yt=async e=>{d(void 0);try{t(await window.flavorDesktop.switchModel(e))}catch(e){d(Vf(e))}},bt=async()=>{if(!(et||e.activeSession===void 0)){d(void 0);try{await window.flavorDesktop.finishTask()}catch(e){d(Vf(e))}}},xt=async e=>{d(void 0);try{let n=await window.flavorDesktop.addModel(e);t(n.snapshot)}catch(e){throw d(Vf(e)),e}},St=(e,t)=>{let n=t.currentTarget.getBoundingClientRect();window.flavorDesktop.showAppMenu(e,Math.round(n.left),Math.round(n.bottom))},Ct=async()=>{if(!(y===void 0||x)){S(!0),d(void 0);try{let n=y.sessionId===e.activeSession?.sessionId,i=await window.flavorDesktop.deleteSession(y.sessionId);t(i),n&&r(T()),b(void 0),v(void 0)}catch(e){d(Vf(e))}finally{S(!1)}}},wt=async(e,n)=>{try{t(await window.flavorDesktop.updateSession(e.sessionId,n)),v(void 0)}catch(e){d(Vf(e))}},M=e=>{let t=window.prompt(`任务名称`,e.title??Me(e));t!==null&&wt(e,{title:t.trim()})},Tt=async(e,n)=>{try{t(await window.flavorDesktop.updateProject(e,n)),be(void 0)}catch(e){d(Vf(e))}},Et=(e,t)=>{let n=window.prompt(`项目显示名称`,t??Ne(e));n!==null&&Tt(e,{label:n.trim()})},Dt=async(e,t)=>{if(!(t&&!window.confirm(`项目中有任务正在运行。停止任务并关闭项目?`)))try{Xe(await window.flavorDesktop.closeProject(e,t)),be(void 0)}catch(e){d(Vf(e))}},Ot=async(e,t)=>{let n=await pt(e);if(n!==void 0&&t!==void 0){let e=n.sessions.find(e=>e.sessionId===t);e!==void 0&&await ht(e)}};(0,_.useEffect)(()=>{let t={...e.workspace===void 0?{}:{workspace:e.workspace},...e.activeSession===void 0?{}:{sessionId:e.activeSession.sessionId},view:O};Ee(e=>{let n=e[De];if(n?.workspace===t.workspace&&n?.sessionId===t.sessionId&&n?.view===t.view)return e;let r=[...e.slice(0,De+1),t].slice(-50);return Oe(r.length-1),r})},[e.workspace,e.activeSession?.sessionId,O]);let kt=async e=>{let n=De+e,i=Te[n];if(i!==void 0){if(Oe(n),i.workspace!==void 0){let e=await window.flavorDesktop.openWorkspace(i.workspace);if(Xe(e),i.sessionId!==void 0){let e=await window.flavorDesktop.selectSession(i.sessionId);t(e.snapshot),A.current=e.sessionId,r(Ue.current.get(`${i.workspace}\u0000${i.sessionId}`)??te(T(),{type:`restore`,state:e.restoredTranscript}))}}k(i.view)}};return(0,_.useEffect)(()=>{let e=e=>{if(!(e.ctrlKey||e.metaKey))return;let t=e.key.toLowerCase();t===`n`&&(e.preventDefault(),me(!0)),t===`p`&&(e.preventDefault(),Se(`projects`),we(``)),t===`k`&&(e.preventDefault(),Se(`commands`),we(``)),t===`[`&&(e.preventDefault(),kt(-1)),t===`]`&&(e.preventDefault(),kt(1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[e.workspace,Te,De]),(0,P.jsxs)(`div`,{className:`app-frame`,children:[(0,P.jsx)(ff,{railCollapsed:m,onToggleRail:()=>h(e=>!e),onMenu:St,canBack:De>0,canForward:De<Te.length-1,onBack:()=>void kt(-1),onForward:()=>void kt(1)}),(0,P.jsxs)(`div`,{className:`desktop-shell`,"data-rail-collapsed":m,children:[(0,P.jsx)(`button`,{className:`rail-scrim`,"data-open":f,onClick:()=>p(!1),"aria-label":`关闭项目栏`}),(0,P.jsxs)(`aside`,{className:`project-rail`,"data-open":f,children:[(0,P.jsxs)(`div`,{className:`brand-row`,children:[(0,P.jsx)(Bf,{}),(0,P.jsx)(`strong`,{children:`Flavor Code`})]}),(0,P.jsxs)(`nav`,{className:`primary-actions`,"aria-label":`主要操作`,children:[(0,P.jsxs)(`button`,{className:`rail-action rail-action-primary`,disabled:e.workspace===void 0,onClick:()=>me(!0),children:[(0,P.jsx)(`span`,{className:`action-icon`,children:(0,P.jsx)(zf,{name:`plus`})}),(0,P.jsx)(`span`,{children:`新建任务`}),(0,P.jsx)(`kbd`,{children:`Ctrl N`})]}),(0,P.jsxs)(`button`,{className:`rail-action`,onClick:()=>void ft(),children:[(0,P.jsx)(`span`,{className:`action-icon`,children:(0,P.jsx)(zf,{name:`folder`})}),(0,P.jsx)(`span`,{children:`打开项目`})]}),(0,P.jsxs)(`button`,{className:`rail-action`,"data-active":O===`skills`,onClick:()=>{k(`skills`),p(!1)},disabled:e.workspace===void 0,children:[(0,P.jsx)(`span`,{className:`action-icon`,children:(0,P.jsx)(zf,{name:`sparkles`})}),(0,P.jsx)(`span`,{children:`技能`})]}),(0,P.jsxs)(`button`,{className:`rail-action`,"data-active":O===`memory`,onClick:()=>{k(`memory`),p(!1)},disabled:e.workspace===void 0,children:[(0,P.jsx)(`span`,{className:`action-icon`,children:(0,P.jsx)(zf,{name:`database`})}),(0,P.jsx)(`span`,{children:`长期记忆`})]}),(0,P.jsxs)(`button`,{className:`rail-action`,"data-active":O===`mcp`,onClick:()=>{k(`mcp`),p(!1)},disabled:e.workspace===void 0,children:[(0,P.jsx)(`span`,{className:`action-icon`,children:(0,P.jsx)(zf,{name:`server`})}),(0,P.jsx)(`span`,{children:`MCP 服务`})]}),(0,P.jsxs)(`button`,{className:`rail-action`,"data-active":O===`e2e`,onClick:()=>{k(`e2e`),p(!1)},disabled:e.workspace===void 0,children:[(0,P.jsx)(`span`,{className:`action-icon`,children:(0,P.jsx)(zf,{name:`checklist`})}),(0,P.jsx)(`span`,{children:`E2E`})]}),(0,P.jsxs)(`button`,{className:`rail-action`,"data-active":O===`activity`,onClick:()=>{k(`activity`),p(!1)},children:[(0,P.jsx)(`span`,{className:`action-icon`,children:(0,P.jsx)(zf,{name:`bell`})}),(0,P.jsx)(`span`,{children:`活动`}),(e.activities?.filter(e=>e.unread).length??0)>0&&(0,P.jsx)(`em`,{className:`rail-badge`,children:e.activities.filter(e=>e.unread).length})]}),(0,P.jsxs)(`button`,{className:`rail-action`,"data-active":O===`git`,onClick:()=>{k(`git`),p(!1)},disabled:e.workspace===void 0,children:[(0,P.jsx)(`span`,{className:`action-icon`,children:(0,P.jsx)(zf,{name:`git`})}),(0,P.jsx)(`span`,{children:`Git 变更`})]}),(0,P.jsxs)(`button`,{className:`rail-action`,"data-active":O===`workbench`,onClick:()=>{k(`workbench`),p(!1)},disabled:e.workspace===void 0||e.activeSession===void 0,children:[(0,P.jsx)(`span`,{className:`action-icon`,children:(0,P.jsx)(zf,{name:`checklist`})}),(0,P.jsx)(`span`,{children:`Agent 工作台`})]})]}),(0,P.jsxs)(`div`,{className:`sessions-scroll`,children:[(0,P.jsxs)(`div`,{className:`rail-section-heading`,children:[(0,P.jsx)(`span`,{children:`项目`}),(0,P.jsx)(`button`,{onClick:()=>void ft(),"aria-label":`打开新项目`,title:`打开新项目`,children:(0,P.jsx)(zf,{name:`plus`})})]}),tt.length>0&&(0,P.jsxs)(`div`,{className:`session-filter`,children:[(0,P.jsxs)(`div`,{className:`session-search`,children:[(0,P.jsx)(zf,{name:`search`}),(0,P.jsx)(`input`,{value:he,onChange:e=>ge(e.target.value),placeholder:`搜索任务`,"aria-label":`搜索任务`}),he.length>0&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>ge(``),"aria-label":`清除搜索`,title:`清除搜索`,children:`×`})]}),(0,P.jsxs)(`div`,{className:`session-group-filter`,children:[(0,P.jsxs)(`select`,{value:_e,onChange:e=>ve(e.target.value),"aria-label":`按状态筛选`,children:[(0,P.jsx)(`option`,{value:`active`,children:`任务`}),(0,P.jsx)(`option`,{value:`running`,children:`运行`}),(0,P.jsx)(`option`,{value:`unread`,children:`未读`}),(0,P.jsx)(`option`,{value:`archived`,children:`归档`})]}),(0,P.jsx)(`span`,{"aria-hidden":`true`})]})]}),tt.length===0?(0,P.jsx)(`button`,{className:`empty-project`,onClick:()=>void ft(),children:`选择一个本地文件夹开始`}):tt.map(t=>{let n=t.workspace===e.workspace,r=Le.has(t.workspace);Le.get(t.workspace);let i=n||t.running||r;return(0,P.jsxs)(`section`,{className:`project-entry`,"data-active":n,children:[(0,P.jsxs)(`div`,{className:`project-heading-shell`,children:[(0,P.jsxs)(`button`,{className:`project-heading`,onClick:()=>void pt(t.workspace),title:t.workspace,children:[(0,P.jsx)(`span`,{className:`folder-icon`,"aria-hidden":`true`,children:(0,P.jsx)(zf,{name:`folder`})}),(0,P.jsx)(`span`,{children:t.label||Ne(t.workspace)}),t.running?(0,P.jsx)(`span`,{className:`project-running-dot`,title:`项目中有任务正在执行`}):(t.unreadCount??0)>0&&(0,P.jsx)(`span`,{className:`project-complete-dot`,role:`status`,"aria-label":`项目有未读活动`})]}),(0,P.jsx)(`button`,{className:`project-more`,onClick:()=>be(e=>e===t.workspace?void 0:t.workspace),"aria-label":`管理项目`,children:`•••`}),ye===t.workspace&&(0,P.jsxs)(`div`,{className:`project-menu`,role:`menu`,children:[(0,P.jsx)(`button`,{onClick:()=>Et(t.workspace,t.label),children:`修改显示名称`}),(0,P.jsx)(`button`,{onClick:()=>void Tt(t.workspace,{pinned:!t.pinned}),children:t.pinned?`取消置顶`:`置顶项目`}),(0,P.jsx)(`button`,{onClick:()=>void window.flavorDesktop.revealProject(t.workspace),children:`在资源管理器中打开`}),(0,P.jsx)(`button`,{onClick:()=>void window.flavorDesktop.copyProjectPath(t.workspace),children:`复制路径`}),(0,P.jsx)(`button`,{className:`danger-item`,onClick:()=>void Dt(t.workspace,t.running),children:`关闭项目`})]})]}),i&&t.sessions.length===0&&(0,P.jsx)(`p`,{className:`no-sessions`,children:`还没有任务`}),i&&t.sessions.filter(e=>(_e===`archived`?e.archived:!e.archived)&&(_e!==`running`||t.runningSessions?.includes(e.sessionId))&&(_e!==`unread`||e.unread)&&(!he.trim()||Me(e).toLowerCase().includes(he.trim().toLowerCase()))).map(r=>{let i=n&&r.sessionId===e.activeSession?.sessionId,a=t.runningSessions?.includes(r.sessionId)??(t.running&&r.sessionId===t.activeSession?.sessionId),o=r.unread&&r.activity===`completed`;return(0,P.jsxs)(`div`,{className:`session-item-shell`,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||v(void 0)},children:[(0,P.jsxs)(`button`,{className:`session-item`,"data-active":i,"data-running":a,disabled:n&&et&&!i,onClick:()=>void mt(t.workspace,r),children:[(0,P.jsxs)(`span`,{children:[r.pinned&&(0,P.jsx)(`i`,{className:`pin-mark`,children:`◆`}),Me(r)]}),a?(0,P.jsx)(`span`,{className:`session-spinner`,role:`status`,"aria-label":`任务正在执行`}):o?(0,P.jsx)(`span`,{className:`session-complete-dot`,role:`status`,"aria-label":`任务已完成,点击查看`}):(0,P.jsx)(`time`,{children:Gf(r.updatedAt)})]}),n&&(0,P.jsx)(`button`,{className:`session-more`,"aria-label":`管理会话:${Me(r)}`,"aria-expanded":g===r.sessionId,onClick:()=>v(e=>e===r.sessionId?void 0:r.sessionId),children:`•••`}),n&&g===r.sessionId&&(0,P.jsxs)(`div`,{className:`session-menu`,role:`menu`,children:[(0,P.jsx)(`button`,{role:`menuitem`,onClick:()=>M(r),children:`重命名`}),(0,P.jsx)(`button`,{role:`menuitem`,onClick:()=>void wt(r,{pinned:!r.pinned}),children:r.pinned?`取消置顶`:`置顶`}),(0,P.jsx)(`button`,{role:`menuitem`,onClick:()=>void wt(r,{archived:!r.archived}),children:r.archived?`取消归档`:`归档`}),(0,P.jsx)(`button`,{role:`menuitem`,className:`danger-item`,disabled:et&&r.sessionId===e.activeSession?.sessionId,onClick:()=>{b(r),v(void 0)},children:`删除会话`})]})]},r.sessionId)})]},t.workspace)})]}),(0,P.jsxs)(`div`,{className:`rail-footer`,children:[(0,P.jsx)(`span`,{className:`avatar`,children:`F`}),(0,P.jsx)(`span`,{children:`本地工作区`}),(0,P.jsx)(`button`,{title:`帮助`,children:`?`})]})]}),(0,P.jsxs)(`main`,{className:`workspace-panel`,children:[O===`workbench`&&e.workspace!==void 0&&e.activeSession!==void 0?(0,P.jsx)(Dd,{snapshot:e,onClose:()=>k(`conversation`),onError:d,onCompose:e=>{qe(e),k(`conversation`),setTimeout(()=>Be.current?.focus(),0)}}):O===`skills`&&e.workspace!==void 0?(0,P.jsx)($l,{onClose:()=>k(`conversation`),onError:d}):O===`memory`&&e.workspace!==void 0?(0,P.jsx)(iu,{onClose:()=>k(`conversation`),onError:d}):O===`mcp`&&e.workspace!==void 0?(0,P.jsx)(ou,{onClose:()=>k(`conversation`),onError:d}):O===`activity`?(0,P.jsx)(lf,{activities:e.activities??[],onClose:()=>k(`conversation`),onOpen:(e,t)=>void Ot(e,t),onClear:()=>void window.flavorDesktop.acknowledgeSession().then(t)}):O===`git`&&e.workspace!==void 0?(0,P.jsx)(dd,{onClose:()=>k(`conversation`),onError:d,onReview:()=>{k(`conversation`),_t(`/review`,`prompt`)}}):O===`e2e`&&e.workspace!==void 0?(0,P.jsx)(cd,{onClose:()=>k(`conversation`),onInterrupt:()=>void window.flavorDesktop.interrupt(),onError:d,refreshKey:ke,pending:je,disabled:et,onLaunch:(e,t)=>Fe(Hd(e,t)),onStartTask:e=>_t(e,`prompt`,`d2c`)}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`header`,{className:`workspace-header`,children:[(0,P.jsx)(`button`,{className:`mobile-rail-toggle`,onClick:()=>p(!0),"aria-label":`打开项目栏`,children:`☰`}),(0,P.jsx)(`div`,{className:`workspace-breadcrumb`,children:(0,P.jsx)(`span`,{children:Ne(e.workspace)})}),(0,P.jsxs)(`div`,{className:`header-actions`,children:[e.jobs.some(e=>e.state===`running`)&&(0,P.jsxs)(`div`,{className:`job-strip`,title:`后台任务`,children:[(0,P.jsx)(`span`,{className:`job-pulse`}),e.jobs.filter(e=>e.state===`running`).length,` 个后台任务`]}),(0,P.jsx)(`button`,{className:`finish-task-button`,onClick:()=>void bt(),disabled:et||e.activeSession===void 0,title:`评估并完成当前任务`,children:`完成任务`}),(0,P.jsx)(`button`,{title:`更多选项`,children:`•••`})]})]}),(e.recoveryItems?.filter(t=>t.workspace===e.workspace).length??0)>0&&(0,P.jsxs)(`div`,{className:`recovery-banner`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:`检测到上次未完成的任务`}),(0,P.jsx)(`span`,{children:`应用异常退出时,这些任务仍在运行。`})]}),e.recoveryItems.filter(t=>t.workspace===e.workspace).map(n=>(0,P.jsxs)(`div`,{className:`recovery-action`,children:[(0,P.jsx)(`code`,{children:Hf(n.sessionId)}),(0,P.jsx)(`button`,{onClick:()=>{let t=e.sessions.find(e=>e.sessionId===n.sessionId);t!==void 0&&ht(t)},children:`恢复 / 查看`}),(0,P.jsx)(`button`,{onClick:()=>void window.flavorDesktop.dismissRecovery(n.sessionId).then(t),children:`忽略`})]},n.sessionId))]}),(0,P.jsx)(`div`,{className:`conversation-scroll`,ref:ze,children:c?(0,P.jsx)(Ff,{}):e.workspace===void 0?(0,P.jsx)(Pf,{onOpen:ft}):n.completed.length===0&&n.active===void 0?(0,P.jsx)(Nf,{project:Ne(e.workspace),onStart:e=>void _t(e)}):(0,P.jsxs)(`div`,{className:`conversation-column`,children:[n.completed.length>60&&(0,P.jsxs)(`div`,{className:`transcript-window-notice`,children:[`更早的 `,n.completed.length-60,` 轮仍保存在会话中,已从实时渲染窗口隐藏`]}),n.completed.slice(-60).map(e=>(0,P.jsx)(hf,{turn:e},e.id)),n.active!==void 0&&(0,P.jsx)(hf,{turn:n.active,active:!0})]})}),e.diagnostics.length>0&&(0,P.jsxs)(`details`,{className:`diagnostics`,children:[(0,P.jsxs)(`summary`,{children:[e.diagnostics.length,` 条启动提示`]}),(0,P.jsx)(`pre`,{children:e.diagnostics.join(`
153
153
  `)})]}),(0,P.jsx)(Sf,{input:i,setInput:qe,onSend:e=>void _t(void 0,e),busy:et,onInterrupt:()=>{Fe(void 0),window.flavorDesktop.interrupt()},inputRef:Be,snapshot:e,attachments:o,onAddImages:e=>void $e(e),onRemoveImage:Ze,setModel:yt,addModel:xt,setPermission:vt,slashCompletion:rt,onSlashSelect:ot,onSlashDismiss:st,onSlashMove:ct,mentionCompletion:it,onMentionSelect:lt,onMentionDismiss:ut,onMentionMove:dt,mentionSpan:D,setMentionSpan:ue,completedTokenLen:at,cursorPos:de,setCursorPos:fe})]}),u!==void 0&&(0,P.jsxs)(`div`,{className:`error-toast`,role:`alert`,children:[(0,P.jsx)(`span`,{children:`!`}),(0,P.jsx)(`p`,{children:u}),(0,P.jsx)(`button`,{onClick:()=>d(void 0),children:`×`})]})]})]}),e.approval!==void 0&&(0,P.jsx)(kf,{approval:e.approval,onResolve:e=>void window.flavorDesktop.resolveApproval(e)}),e.questions!==void 0&&(0,P.jsx)(Af,{questions:e.questions,onAnswer:e=>void window.flavorDesktop.answerQuestions(e)}),e.memoryReviews!==void 0&&e.memoryReviews.length>0&&(0,P.jsx)(jf,{reviews:e.memoryReviews,autoDismissSeconds:e.memoryAutoDismissSeconds??0,onResolve:(e,t)=>{window.flavorDesktop.resolveMemoryReview(e,t).catch(e=>d(Vf(e)))}}),y!==void 0&&(0,P.jsx)(Df,{session:y,deleting:x,onCancel:()=>b(void 0),onDelete:()=>void Ct()}),pe&&(0,P.jsx)(uf,{onCancel:()=>me(!1),onChoose:e=>{me(!1),gt(void 0,e)}}),xe!==void 0&&(0,P.jsx)(df,{mode:xe,query:Ce,setQuery:we,projects:tt,onClose:()=>Se(void 0),onProject:e=>{Se(void 0),pt(e)},onCommand:e=>{Se(void 0),e===`new`?me(!0):e===`open`?ft():e===`activity`?k(`activity`):e===`git`?k(`git`):e===`skills`&&k(`skills`)}})]})}function lf({activities:e,onClose:t,onOpen:n,onClear:r}){return(0,P.jsxs)(`section`,{className:`manager-view activity-center`,children:[(0,P.jsxs)(`header`,{className:`manager-header`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`button`,{onClick:t,children:`←`}),(0,P.jsx)(`h2`,{children:`活动`})]}),(0,P.jsx)(`button`,{onClick:r,children:`全部标为已读`})]}),(0,P.jsx)(`div`,{className:`activity-list`,children:e.length===0?(0,P.jsx)(`p`,{className:`manager-empty`,children:`还没有任务活动`}):e.map(e=>(0,P.jsxs)(`button`,{className:`activity-row`,"data-kind":e.kind,"data-unread":e.unread,onClick:()=>n(e.workspace,e.sessionId),children:[(0,P.jsx)(`i`,{}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:e.title}),(0,P.jsxs)(`span`,{children:[Ne(e.workspace),e.detail?` · ${e.detail}`:``]})]}),(0,P.jsx)(`time`,{children:Gf(e.createdAt)})]},e.id))})]})}function uf({onCancel:e,onChoose:t}){return(0,P.jsx)(`div`,{className:`modal-layer`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,P.jsxs)(`section`,{className:`new-task-sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`new-task-title`,children:[(0,P.jsxs)(`header`,{children:[(0,P.jsx)(`p`,{children:`NEW TASK`}),(0,P.jsx)(`h2`,{id:`new-task-title`,children:`选择任务运行环境`}),(0,P.jsx)(`span`,{children:`隔离只影响 Electron 任务,不改变 CLI 默认行为。`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`button`,{onClick:()=>t(`worktree`),children:[(0,P.jsx)(`i`,{children:`◇`}),(0,P.jsx)(`strong`,{children:`隔离工作树`}),(0,P.jsx)(`span`,{children:`新建 flavor/desktop-* 分支,在应用目录中独立运行。`}),(0,P.jsx)(`em`,{children:`推荐`})]}),(0,P.jsxs)(`button`,{onClick:()=>t(`local`),children:[(0,P.jsx)(`i`,{children:`⌂`}),(0,P.jsx)(`strong`,{children:`当前检出`}),(0,P.jsx)(`span`,{children:`直接使用项目当前目录,适合快速查看和轻量操作。`})]})]}),(0,P.jsx)(`footer`,{children:(0,P.jsx)(`button`,{onClick:e,children:`取消`})})]})})}function df({mode:e,query:t,setQuery:n,projects:r,onClose:i,onProject:a,onCommand:o}){let s=[{id:`new`,label:`新建任务`,hint:`Ctrl N`},{id:`open`,label:`打开项目`,hint:`Ctrl O`},{id:`activity`,label:`查看活动`,hint:``},{id:`git`,label:`打开 Git 变更`,hint:``},{id:`skills`,label:`管理技能`,hint:``}].filter(e=>e.label.toLowerCase().includes(t.toLowerCase())),c=r.filter(e=>`${e.label??``} ${Ne(e.workspace)} ${e.workspace}`.toLowerCase().includes(t.toLowerCase()));return(0,P.jsx)(`div`,{className:`palette-layer`,onMouseDown:e=>{e.target===e.currentTarget&&i()},children:(0,P.jsxs)(`section`,{className:`command-palette`,role:`dialog`,"aria-modal":`true`,children:[(0,P.jsx)(`input`,{autoFocus:!0,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Escape`&&i()},placeholder:e===`projects`?`切换到项目…`:`键入命令…`}),(0,P.jsx)(`div`,{children:e===`projects`?c.map(e=>(0,P.jsxs)(`button`,{onClick:()=>a(e.workspace),children:[(0,P.jsx)(zf,{name:`folder`}),(0,P.jsx)(`span`,{children:e.label||Ne(e.workspace)}),(0,P.jsx)(`small`,{children:e.workspace})]},e.workspace)):s.map(e=>(0,P.jsxs)(`button`,{onClick:()=>o(e.id),children:[(0,P.jsx)(`span`,{children:e.label}),(0,P.jsx)(`kbd`,{children:e.hint})]},e.id))})]})})}function ff({railCollapsed:e,onToggleRail:t,onMenu:n,canBack:r,canForward:i,onBack:a,onForward:o}){return(0,P.jsxs)(`header`,{className:`window-titlebar`,children:[(0,P.jsx)(`button`,{className:`titlebar-icon sidebar-toggle`,"data-collapsed":e,onClick:t,"aria-label":e?`显示项目栏`:`隐藏项目栏`,title:e?`显示项目栏`:`隐藏项目栏`,children:(0,P.jsxs)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,P.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`11`,height:`11`,rx:`2`}),(0,P.jsx)(`path`,{d:`M6 3v10`})]})}),(0,P.jsx)(`button`,{className:`titlebar-icon nav-button`,disabled:!r,onClick:a,"aria-label":`后退`,title:`后退 (Ctrl+[)`,children:(0,P.jsx)(`span`,{children:`‹`})}),(0,P.jsx)(`button`,{className:`titlebar-icon nav-button`,disabled:!i,onClick:o,"aria-label":`前进`,title:`前进 (Ctrl+])`,children:(0,P.jsx)(`span`,{children:`›`})}),(0,P.jsxs)(`nav`,{className:`titlebar-menus`,"aria-label":`应用菜单`,children:[(0,P.jsx)(`button`,{onClick:e=>n(`file`,e),children:`文件`}),(0,P.jsx)(`button`,{onClick:e=>n(`edit`,e),children:`编辑`}),(0,P.jsx)(`button`,{onClick:e=>n(`view`,e),children:`视图`}),(0,P.jsx)(`button`,{onClick:e=>n(`help`,e),children:`帮助`})]})]})}function pf(e,t,n,r,i){e.type===`snapshot`?(t.current=e.snapshot.activeSession?.sessionId,n(e.snapshot)):e.type===`session-started`?(t.current=e.payload.sessionId,n(e.payload.snapshot),r(te(T(),{type:`restore`,state:e.payload.restoredTranscript}))):e.type===`session-output`?r(n=>Ie(n,t.current,e)):e.type===`runtime-error`&&(e.sessionId===void 0||e.sessionId===t.current)&&i(e.message)}function mf({turn:e,active:t=!1}){let n=t?e.blocks:e.blocks.filter(e=>e.kind!==`status`||e.task===void 0),r=Math.max(0,n.length-200),i=n.slice(-200);return(0,P.jsxs)(`article`,{className:`turn`,"data-active":t,"data-kind":e.kind??`conversation`,children:[(0,P.jsx)(`div`,{className:`user-message`,children:(0,P.jsx)(`span`,{children:_f(e.prompt,16e3)})}),(0,P.jsxs)(`div`,{className:`assistant-message`,children:[(0,P.jsx)(`div`,{className:`assistant-avatar`,children:(0,P.jsx)(Bf,{})}),(0,P.jsxs)(`div`,{className:`turn-content`,children:[r>0&&(0,P.jsxs)(`div`,{className:`transcript-window-notice`,children:[`更早的 `,r,` 条任务输出已从实时渲染窗口隐藏`]}),i.map((e,t)=>(0,P.jsx)(gf,{block:e},e.kind===`status`?e.id:`text-${t}`)),t&&i.length===0&&(0,P.jsxs)(`div`,{className:`thinking-line`,role:`status`,children:[(0,P.jsx)(`i`,{}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:`Flavoring`}),(0,P.jsx)(`small`,{children:`正在理解任务`})]})]})]})]})]})}var hf=_.memo(mf);function gf({block:e}){if(e.kind===`text`)return(0,P.jsx)(`div`,{className:`assistant-copy`,children:(0,P.jsx)(un,{text:_f(e.text)})});let t=e.state===`completed`?`✓`:e.state===`failed`?`×`:e.state===`cancelled`?`–`:e.state===`running`?``:`·`,n=e.activity===`model`,r=n&&e.thinkingText?vf(e.thinkingText):void 0;return(0,P.jsxs)(`div`,{className:`activity-card`,"data-state":e.state,"data-tone":e.tone,"data-activity":e.activity,children:[(0,P.jsx)(`span`,{className:`activity-node`,children:t}),(0,P.jsxs)(`div`,{className:`activity-body`,children:[(0,P.jsxs)(`div`,{className:`activity-title`,children:[(0,P.jsx)(`span`,{children:e.text.replace(/^[·✓×]\s*/,``)}),n&&e.state===`running`&&(0,P.jsx)(`small`,{children:`正在思考`}),e.hint&&(0,P.jsx)(`code`,{children:e.hint})]}),r&&(0,P.jsx)(`div`,{className:`reasoning-preview`,children:r}),e.progress!==void 0&&(0,P.jsx)(`div`,{className:`progress-track`,children:(0,P.jsx)(`i`,{style:{width:`${e.progress}%`}})}),e.presentation?.kind===`file-change`&&(0,P.jsx)(bf,{presentation:e.presentation}),e.presentation?.kind===`generic`&&(0,P.jsxs)(`div`,{className:`tool-presentation`,children:[(0,P.jsx)(`strong`,{children:e.presentation.title}),e.presentation.summary&&(0,P.jsx)(`span`,{children:e.presentation.summary})]}),e.presentation?.kind===`terminal`&&(0,P.jsxs)(`div`,{className:`tool-presentation terminal-presentation`,children:[(0,P.jsx)(`strong`,{children:e.presentation.title}),e.presentation.stdout&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`small`,{children:`OUTPUT`}),(0,P.jsx)(`pre`,{"data-stream":`stdout`,children:_f(e.presentation.stdout)})]}),e.presentation.stderr&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`small`,{children:`ERROR`}),(0,P.jsx)(`pre`,{"data-stream":`stderr`,children:_f(e.presentation.stderr)})]}),e.presentation.diagnostic&&(0,P.jsx)(`span`,{className:`terminal-diagnostic`,children:e.presentation.diagnostic})]}),e.presentation?.kind===`web`&&(0,P.jsxs)(`div`,{className:`tool-presentation`,children:[(0,P.jsx)(`strong`,{children:e.presentation.title}),e.presentation.summary&&(0,P.jsx)(`span`,{children:e.presentation.summary})]}),e.tool&&(0,P.jsxs)(`details`,{className:`tool-details`,children:[(0,P.jsx)(`summary`,{children:`调用详情`}),(0,P.jsx)(`label`,{children:`Input`}),(0,P.jsx)(`pre`,{children:yf(e.tool.input)}),e.tool.result===void 0?null:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`label`,{children:`Result`}),(0,P.jsx)(`pre`,{children:yf(e.tool.result)})]})]}),e.details&&(0,P.jsxs)(`details`,{className:`timeline-details`,children:[(0,P.jsx)(`summary`,{children:`压缩摘要`}),(0,P.jsx)(un,{text:_f(e.details)})]})]})]})}function _f(e,t=32e3){if(e.length<=t)return e;let n=Math.floor((t-64)/2);return`${e.slice(0,n)}\n\n… ${e.length-n*2} 个字符已隐藏 …\n\n${e.slice(-n)}`}function vf(e,t=280){let n=e.replace(/\s+/gu,` `).trim(),r=Math.max(1,Math.floor(t)),i=[...n];return i.length<=r?n:`…${i.slice(-r).join(``)}`}function yf(e,t=1e4){let n;try{n=JSON.stringify(e,null,2)??`undefined`}catch{n=String(e)}return n.length<=t?n:`${n.slice(0,t)}…`}function bf({presentation:e}){let t=e.operation===`delete`,n=e.operation===`create`?`新建`:e.operation===`delete`?`删除`:`修改`,r=e.path.replace(/^.*[/\\]/,``),i=t?1:Math.max(1,...e.lines.map(e=>Math.max(e.oldLine??0,e.newLine??0))).toString().length;return(0,P.jsxs)(`details`,{className:`diff-preview`,children:[(0,P.jsxs)(`summary`,{children:[(0,P.jsx)(`span`,{className:`diff-marker ${t?`diff-delete`:`diff-add`}`,children:`●`}),(0,P.jsx)(`span`,{className:`diff-label`,children:n}),(0,P.jsx)(`span`,{className:`diff-path`,children:r}),(0,P.jsxs)(`span`,{className:`diff-counts`,children:[!t&&(0,P.jsxs)(`span`,{className:`diff-added-count`,children:[`+`,e.added]}),!t&&e.removed>0&&(0,P.jsxs)(`span`,{className:`diff-removed-count`,children:[` −`,e.removed]}),t&&(0,P.jsxs)(`span`,{className:`diff-removed-count`,children:[`−`,e.removed]})]})]}),t?null:(0,P.jsx)(`div`,{className:`diff-body`,children:e.lines.map((e,t)=>(0,P.jsx)(xf,{line:e,lineWidth:i},t))})]})}function xf({line:e,lineWidth:t}){let n=e.kind===`removed`||e.kind===`context`?e.oldLine:e.newLine,r=e.kind===`removed`?`-`:e.kind===`added`?`+`:e.kind===`omitted`?`…`:` `;return(0,P.jsxs)(`div`,{className:`diff-row ${e.kind===`added`?`diff-row-added`:e.kind===`removed`?`diff-row-removed`:e.kind===`omitted`?`diff-row-omitted`:`diff-row-context`}`,children:[(0,P.jsx)(`span`,{className:`diff-line-number`,children:String(n??``).padStart(t)}),(0,P.jsx)(`span`,{className:`diff-line-marker`,children:r}),(0,P.jsx)(`span`,{className:`diff-line-text`,children:e.text})]})}function Sf(e){let t=e.snapshot.workspace===void 0,[n,r]=(0,_.useState)(!1),i=(0,_.useRef)(null),a=e.slashCompletion!==null,o=e.mentionCompletion!==null,s=a||o,c=e.completedTokenLen>0,l=c?e.input.slice(0,e.completedTokenLen):void 0,u=l?.startsWith(`/`)?l.slice(1).trim():l?.trim(),d=c?void 0:e.mentionSpan,f=d!==void 0&&d.start>=0&&d.end>d.start&&d.start<e.input.length&&d.end<=e.input.length&&e.input.slice(d.start,d.end)===d.text,p=f?e.input.slice(0,d.start):``,m=f?e.input.slice(d.start,d.end):``,h=f?e.input.slice(d.end):``,g=m.startsWith(`@`)?m.slice(1).trim():m,v=c?e.input.slice(e.completedTokenLen):f?h:e.input,y=c?l.length:f?d.start+m.length:0,b=e=>y+e,x=t=>{if(a){if(t.key===`ArrowDown`){t.preventDefault(),e.onSlashMove(1);return}if(t.key===`ArrowUp`){t.preventDefault(),e.onSlashMove(-1);return}if(t.key===`Tab`||t.key===`Enter`){t.preventDefault();let n=e.slashCompletion?.items[e.slashCompletion?.selectedIndex??0];n!==void 0&&e.onSlashSelect(n.name);return}if(t.key===`Escape`){t.preventDefault(),e.onSlashDismiss();return}}if(o){if(t.key===`ArrowDown`){t.preventDefault(),e.onMentionMove(1);return}if(t.key===`ArrowUp`){t.preventDefault(),e.onMentionMove(-1);return}if(t.key===`Tab`||t.key===`Enter`){t.preventDefault();let n=e.mentionCompletion?.items[e.mentionCompletion?.selectedIndex??0];n!==void 0&&e.onMentionSelect(n);return}if(t.key===`Escape`){t.preventDefault(),e.onMentionDismiss();return}}let n=t.target,r=n.selectionStart,i=n.selectionEnd;if(t.key===`Backspace`&&r===i&&!s){if(c){let n=yn(e.input,e.completedTokenLen,b(r));if(n!==null){t.preventDefault(),e.setInput(n.text),e.setCursorPos(n.cursor);return}}if(f&&r===0){t.preventDefault();let n=p+h;e.setInput(n),e.setMentionSpan(void 0),e.setCursorPos(p.length);return}}t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),e.onSend(t.altKey?`followUp`:e.busy?`steer`:void 0))},S=(t,n)=>{let r;if(r=c?l+t:f?p+m+t:t,f){let t=p+m;r.startsWith(t)||e.setMentionSpan(void 0)}e.setInput(r),e.setCursorPos(b(n))},C=t=>{e.setCursorPos(b(t))},w=(0,P.jsx)(`textarea`,{ref:e.inputRef,className:`composer-textarea`,value:v,onChange:e=>S(e.target.value,e.target.selectionStart),onSelect:e=>C(e.target.selectionStart),onKeyDown:x,onPaste:t=>{let n=Cf(t.clipboardData.files);n.length!==0&&(t.preventDefault(),e.onAddImages(n))},onClick:e=>C(e.target.selectionStart),placeholder:t?`先打开一个项目`:c||f?``:`给 Flavor 一个任务,或输入 / 查看命令`,disabled:t,rows:1}),ee=c?(0,P.jsxs)(`div`,{className:`composer-input-row`,children:[(0,P.jsx)(`span`,{className:`slash-tag`,children:u}),w]}):f?(0,P.jsxs)(`div`,{className:`composer-input-row`,children:[p.length>0&&(0,P.jsx)(`span`,{className:`composer-plain-text`,children:p}),(0,P.jsx)(`span`,{className:`mention-tag`,children:g}),w]}):w;return(0,P.jsxs)(`div`,{className:`composer-wrap`,onDragEnter:e=>{wf(e.dataTransfer)&&(e.preventDefault(),r(!0))},onDragOver:e=>{wf(e.dataTransfer)&&e.preventDefault()},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||r(!1)},onDrop:t=>{let n=Cf(t.dataTransfer.files);n.length!==0&&(t.preventDefault(),r(!1),e.onAddImages(n))},children:[a&&(0,P.jsx)(Cn,{completion:e.slashCompletion,onSelect:e.onSlashSelect,onDismiss:e.onSlashDismiss}),o&&(0,P.jsx)(En,{completion:e.mentionCompletion,onSelect:e.onMentionSelect,onDismiss:e.onMentionDismiss}),(0,P.jsxs)(`div`,{className:`composer${c||f?` has-tag`:``}`,"data-busy":e.busy,"data-image-drag":n,children:[e.attachments.length>0&&(0,P.jsx)(sf,{attachments:e.attachments,onRemove:e.onRemoveImage}),ee,(0,P.jsxs)(`div`,{className:`composer-tools`,children:[(0,P.jsx)(`input`,{ref:i,className:`image-file-input`,type:`file`,accept:`image/png,image/jpeg,image/webp`,multiple:!0,onChange:t=>{e.onAddImages(Cf(t.target.files)),t.target.value=``}}),(0,P.jsxs)(`button`,{type:`button`,className:`attach-button attach-button-labeled image-attach-button`,title:`添加图片(也可粘贴或拖入)`,"aria-label":`添加图片`,onClick:()=>i.current?.click(),disabled:t||e.busy||e.attachments.length>=$d,children:[(0,P.jsx)(zf,{name:`image`}),(0,P.jsx)(`span`,{children:`图片`})]}),(0,P.jsxs)(`button`,{className:`attach-button attach-button-labeled`,title:`在提示中输入 @ 引用项目文件`,onClick:()=>{e.setInput(`${e.input}${e.input?` `:``}@`),setTimeout(()=>{let t=e.inputRef.current;t!==null&&(t.focus(),t.setSelectionRange(t.value.length,t.value.length))},0)},disabled:t,children:[(0,P.jsx)(zf,{name:`at`}),(0,P.jsx)(`span`,{children:`文件`})]}),(0,P.jsxs)(`div`,{className:`composer-context`,children:[(0,P.jsxs)(`span`,{className:`context-item`,title:e.snapshot.workspace,children:[(0,P.jsx)(zf,{name:`folder`}),(0,P.jsx)(`span`,{children:Ne(e.snapshot.workspace)})]}),(0,P.jsxs)(`span`,{className:`context-item`,children:[(0,P.jsx)(zf,{name:`monitor`}),(0,P.jsx)(`span`,{children:`本地`})]})]}),(0,P.jsxs)(`div`,{className:`composer-controls`,children:[(0,P.jsx)(Wf,{models:e.snapshot.models,activeModel:e.snapshot.activeSession?.mainModel,busy:e.busy,onSelect:e.setModel,onAdd:e.addModel}),(0,P.jsx)(`select`,{"aria-label":`权限模式`,value:e.snapshot.activeSession?.permissionMode??`default`,disabled:e.busy||e.snapshot.activeSession===void 0,onChange:t=>e.setPermission(t.target.value),children:Zd.map(e=>(0,P.jsx)(`option`,{value:e,children:je(e)},e))}),e.busy&&(0,P.jsxs)(`span`,{className:`queue-count`,title:`引导 + 后续消息`,children:[e.snapshot.activeSession?.queue.steering.length??0,`+`,e.snapshot.activeSession?.queue.followUp.length??0]}),(0,P.jsx)(`button`,{className:`send-button`,onClick:()=>e.onSend(e.busy?`steer`:void 0),disabled:t||!e.input.trim()&&e.attachments.length===0,title:e.busy?`发送引导消息`:`发送`,children:(0,P.jsx)(`span`,{children:`↑`})}),e.busy&&(0,P.jsx)(`button`,{className:`send-button stop-button`,onClick:e.onInterrupt,title:`停止任务`,children:(0,P.jsx)(`span`,{})})]})]})]}),(0,P.jsx)(`p`,{className:`composer-hint`,children:`Enter 发送 · Shift Enter 换行 · 粘贴/拖入图片 · @ 引用文件 · / 调用命令`})]})}function Cf(e){return e===null?[]:Array.from(e).filter(e=>e.type.startsWith(`image/`))}function wf(e){return Array.from(e.items).some(e=>e.kind===`file`&&e.type.startsWith(`image/`))}async function Tf(e){if(!nf.has(e.type))throw Error(`不支持 ${e.type||`未知格式`};请选择 PNG、JPEG 或 WebP 图片。`);if(e.size<=0)throw Error(`${e.name} 是空文件。`);if(e.size>ef)throw Error(`${e.name} 超过单图 5 MiB 限制。`);let t=Ef(new Uint8Array(await e.arrayBuffer())),n=URL.createObjectURL(e);return{id:globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`,name:e.name,mediaType:e.type,dataBase64:t,previewUrl:n}}function Ef(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n)t+=String.fromCharCode(...e.subarray(r,r+n));return btoa(t)}function Df({session:e,deleting:t,onCancel:n,onDelete:r}){return(0,P.jsx)(`div`,{className:`modal-layer`,children:(0,P.jsxs)(`section`,{className:`decision-sheet delete-session-sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`delete-session-title`,children:[(0,P.jsx)(`div`,{className:`sheet-icon danger`,children:`×`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`sheet-kicker`,children:`删除历史会话`}),(0,P.jsxs)(`h2`,{id:`delete-session-title`,children:[`删除“`,Me(e),`”?`]}),(0,P.jsx)(`p`,{children:`此会话的消息和任务记录将从当前项目中永久删除,此操作无法撤销。`}),(0,P.jsxs)(`div`,{className:`sheet-actions`,children:[(0,P.jsx)(`button`,{disabled:t,onClick:n,children:`取消`}),(0,P.jsx)(`button`,{className:`danger`,disabled:t,onClick:r,children:t?`正在删除…`:`删除会话`})]})]})]})})}var Of=new Set([`Delete`,`Move`,`RemoveTool`]);function kf({approval:e,onResolve:t}){let n=Of.has(e.tool)||e.allowAlways===!1;return(0,P.jsx)(`div`,{className:`modal-layer`,children:(0,P.jsxs)(`section`,{className:`decision-sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`approval-title`,children:[(0,P.jsx)(`div`,{className:`sheet-icon warning`,children:`!`}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`p`,{className:`sheet-kicker`,children:[`权限确认 · `,e.agent===`main`?`主 Agent`:`子 Agent`]}),(0,P.jsxs)(`h2`,{id:`approval-title`,children:[`允许执行 `,e.tool,`?`]}),(0,P.jsx)(`p`,{children:e.reason??`这项操作需要你的确认。`}),(e.command||e.paths?.length)&&(0,P.jsxs)(`pre`,{children:[e.command??e.paths?.join(`
@@ -1,4 +1,4 @@
1
- import{i as e,n as t,r as n,t as r}from"./index-DoW9kFm4.js";var i=e(n(),1),a=2,o=1,s=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),s=window.getComputedStyle(this._terminal.element),c={top:parseInt(s.getPropertyValue(`padding-top`)),bottom:parseInt(s.getPropertyValue(`padding-bottom`)),right:parseInt(s.getPropertyValue(`padding-right`)),left:parseInt(s.getPropertyValue(`padding-left`))},l=c.top+c.bottom,u=c.right+c.left,d=r-l,f=i-u-t;return{cols:Math.max(a,Math.floor(f/e.css.cell.width)),rows:Math.max(o,Math.floor(d/e.css.cell.height))}}},c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=(e,t)=>{for(var n in t)c(e,n,{get:t[n],enumerable:!0})},d=(e,t,n,r)=>{for(var i=r>1?void 0:r?l(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&c(t,n,i),i},f=(e,t)=>(n,r)=>t(n,r,e),p=`Terminal input`,m={get:()=>p,set:e=>p=e},h=`Too much output to announce, navigate to rows manually to read`,g={get:()=>h,set:e=>h=e};function _(e){return e.replace(/\r?\n/g,`\r`)}function ee(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function te(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function ne(e,t,n,r){e.stopPropagation(),e.clipboardData&&re(e.clipboardData.getData(`text/plain`),t,n,r)}function re(e,t,n,r){e=_(e),e=ee(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function ie(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function ae(e,t,n,r,i){ie(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function v(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function oe(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var se=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},y=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},ce=``,le=` `,ue=class e{constructor(){this.fg=0,this.bg=0,this.extended=new b}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},b=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},x=class e extends ue{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new b,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?v(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},de=`di$target`,fe=`di$dependencies`,S=new Map;function pe(e){return e[fe]||[]}function C(e){if(S.has(e))return S.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);me(t,e,r)};return t._id=e,S.set(e,t),t}function me(e,t,n){t[de]===t?t[fe].push({id:e,index:n}):(t[fe]=[{id:e,index:n}],t[de]=t)}var w=C(`BufferService`),he=C(`CoreMouseService`),T=C(`CoreService`),ge=C(`CharsetService`),E=C(`InstantiationService`),_e=C(`LogService`),D=C(`OptionsService`),ve=C(`OscLinkService`),ye=C(`UnicodeService`),be=C(`DecorationService`),xe=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new x,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Se(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};xe=d([f(0,w),f(1,D),f(2,ve)],xe);function Se(e,t){if(confirm(`Do you want to navigate to ${t}?
1
+ import{i as e,n as t,r as n,t as r}from"./index-RNe5Gtum.js";var i=e(n(),1),a=2,o=1,s=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),s=window.getComputedStyle(this._terminal.element),c={top:parseInt(s.getPropertyValue(`padding-top`)),bottom:parseInt(s.getPropertyValue(`padding-bottom`)),right:parseInt(s.getPropertyValue(`padding-right`)),left:parseInt(s.getPropertyValue(`padding-left`))},l=c.top+c.bottom,u=c.right+c.left,d=r-l,f=i-u-t;return{cols:Math.max(a,Math.floor(f/e.css.cell.width)),rows:Math.max(o,Math.floor(d/e.css.cell.height))}}},c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=(e,t)=>{for(var n in t)c(e,n,{get:t[n],enumerable:!0})},d=(e,t,n,r)=>{for(var i=r>1?void 0:r?l(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&c(t,n,i),i},f=(e,t)=>(n,r)=>t(n,r,e),p=`Terminal input`,m={get:()=>p,set:e=>p=e},h=`Too much output to announce, navigate to rows manually to read`,g={get:()=>h,set:e=>h=e};function _(e){return e.replace(/\r?\n/g,`\r`)}function ee(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function te(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function ne(e,t,n,r){e.stopPropagation(),e.clipboardData&&re(e.clipboardData.getData(`text/plain`),t,n,r)}function re(e,t,n,r){e=_(e),e=ee(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function ie(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function ae(e,t,n,r,i){ie(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function v(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function oe(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var se=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},y=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},ce=``,le=` `,ue=class e{constructor(){this.fg=0,this.bg=0,this.extended=new b}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},b=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},x=class e extends ue{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new b,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?v(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},de=`di$target`,fe=`di$dependencies`,S=new Map;function pe(e){return e[fe]||[]}function C(e){if(S.has(e))return S.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);me(t,e,r)};return t._id=e,S.set(e,t),t}function me(e,t,n){t[de]===t?t[fe].push({id:e,index:n}):(t[fe]=[{id:e,index:n}],t[de]=t)}var w=C(`BufferService`),he=C(`CoreMouseService`),T=C(`CoreService`),ge=C(`CharsetService`),E=C(`InstantiationService`),_e=C(`LogService`),D=C(`OptionsService`),ve=C(`OscLinkService`),ye=C(`UnicodeService`),be=C(`DecorationService`),xe=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new x,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Se(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};xe=d([f(0,w),f(1,D),f(2,ve)],xe);function Se(e,t){if(confirm(`Do you want to navigate to ${t}?
2
2
 
3
3
  WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var Ce=C(`CharSizeService`),we=C(`CoreBrowserService`),Te=C(`MouseService`),Ee=C(`RenderService`),De=C(`SelectionService`),Oe=C(`CharacterJoinerService`),ke=C(`ThemeService`),Ae=C(`LinkProviderService`),je=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Le.isErrorNoTelemetry(e)?new Le(e.message+`
4
4
 
@@ -6,7 +6,7 @@
6
6
  <meta name="color-scheme" content="light" />
7
7
  <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self' http://127.0.0.1:* http://localhost:* http://[::1]:* ws://127.0.0.1:* ws://localhost:* ws://[::1]:*; frame-src http://127.0.0.1:* http://localhost:* http://[::1]:*" />
8
8
  <title>Flavor Code</title>
9
- <script type="module" crossorigin src="./assets/index-DoW9kFm4.js"></script>
9
+ <script type="module" crossorigin src="./assets/index-RNe5Gtum.js"></script>
10
10
  <link rel="stylesheet" crossorigin href="./assets/index-Bk6FYhyh.css">
11
11
  </head>
12
12
  <body>
@@ -7,7 +7,7 @@ import {
7
7
  setProjectMcpServerDisabled,
8
8
  setProjectProviderConfig,
9
9
  setProjectSkillDisabled
10
- } from "./chunk-KQMKY7C5.js";
10
+ } from "./chunk-EXOSMO57.js";
11
11
  import "./chunk-S32JRDZK.js";
12
12
  export {
13
13
  loadConfig,
@@ -14,7 +14,7 @@ export interface OpenAIModelAdapterOptions {
14
14
  /** Mirror the per-request cache breakdown to stderr. Defaults to FLAVOR_DEBUG_USAGE=1. File logging to usage.jsonl is always on. */
15
15
  debugUsage?: boolean;
16
16
  /** Reasoning effort requested from the Responses API; omitted when undefined. */
17
- thinkingEffort?: "low" | "medium" | "high";
17
+ thinkingEffort?: "minimal" | "low" | "medium" | "high" | "xhigh";
18
18
  }
19
19
  export declare class OpenAIModelAdapter implements ModelAdapter {
20
20
  #private;
package/dist/sdk/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  FlavorRpcServer,
5
5
  TraceRecordSchema,
6
6
  TraceRecorder
7
- } from "../chunk-PT72RZVC.js";
7
+ } from "../chunk-D4OD67V6.js";
8
8
  import {
9
9
  AgentMessageQueue,
10
10
  DockerExecutionEnvironment,
@@ -13,9 +13,9 @@ import {
13
13
  WorkspaceCheckpointStore,
14
14
  buildDockerInvocation,
15
15
  createProductionRuntime
16
- } from "../chunk-ITKOMJD6.js";
16
+ } from "../chunk-CWCYXOH6.js";
17
17
  import "../chunk-N5MXHJKD.js";
18
- import "../chunk-KQMKY7C5.js";
18
+ import "../chunk-EXOSMO57.js";
19
19
  import "../chunk-ZJCAQXA7.js";
20
20
  import "../chunk-S32JRDZK.js";
21
21
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flavor-code",
3
- "version": "1.4.0-beta.7",
3
+ "version": "1.4.0-beta.9",
4
4
  "author": "YachuanWzh",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -31,7 +31,7 @@
31
31
  "scripts": {
32
32
  "build": "npm run build:icons && npm run build:cli && npm run build:desktop",
33
33
  "build:icons": "node scripts/build-icons.mjs",
34
- "build:cli": "tsup && tsc -p tsconfig.sdk.json && node scripts/assert-production-cli.mjs",
34
+ "build:cli": "tsup && tsc -p tsconfig.sdk.json && node scripts/assert-production-cli.mjs",
35
35
  "build:desktop": "npm run build:desktop:main && npm run build:desktop:renderer",
36
36
  "build:desktop:main": "tsup --config tsup.desktop.config.ts",
37
37
  "build:desktop:renderer": "vite build --config vite.desktop.config.ts",
@@ -51,9 +51,9 @@
51
51
  "typecheck": "tsc --noEmit",
52
52
  "smoke:install": "node scripts/smoke-install.mjs",
53
53
  "smoke:d2c-worker": "npm run build:desktop:main && node scripts/smoke-d2c-worker.mjs",
54
- "stress:context": "vitest run scripts/stress-context-memory.test.ts --reporter=verbose",
55
- "stress:tui-memory": "npm run build:cli && node scripts/run-tui-memory-stress.mjs",
56
- "stress:production-memory": "npm run build:cli && node scripts/stress-production-memory.mjs",
54
+ "stress:context": "vitest run scripts/stress-context-memory.test.ts --reporter=verbose",
55
+ "stress:tui-memory": "npm run build:cli && node scripts/run-tui-memory-stress.mjs",
56
+ "stress:production-memory": "npm run build:cli && node scripts/stress-production-memory.mjs",
57
57
  "evidence:crash-fix": "vitest run scripts/evidence-crash-replay.test.ts --reporter=verbose",
58
58
  "prepack": "npm run build"
59
59
  },