@evandu/super-pi 0.1.146 → 0.1.148

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/agents/super-pi-task/core.ts +223 -2
  2. package/agents/super-pi-task/index.ts +50 -0
  3. package/dist/.super-pi-check-inputs.json +2 -2
  4. package/dist/client/.super-pi-client-sources.json +8 -8
  5. package/dist/client/assets/{CodeMirrorEditor-CEwBCVM6.js → CodeMirrorEditor-DQCjEnxG.js} +2 -2
  6. package/dist/client/assets/{dist-DC1IocrS.js → dist-1Innu17E.js} +1 -1
  7. package/dist/client/assets/{dist-CSCUT1PQ.js → dist-1lynFOc5.js} +1 -1
  8. package/dist/client/assets/{dist-Do52MRwm.js → dist-B1qLZVMK.js} +1 -1
  9. package/dist/client/assets/{dist-CAOcjKAQ.js → dist-B4pz_xdd.js} +1 -1
  10. package/dist/client/assets/{dist-B0RXZeXQ.js → dist-B6KwDpeI.js} +1 -1
  11. package/dist/client/assets/{dist-DFMtP3wG.js → dist-BJVI1Unv.js} +1 -1
  12. package/dist/client/assets/{dist-oLq6HXLG.js → dist-BWvzD8Pe.js} +1 -1
  13. package/dist/client/assets/{dist-9F1wL-T5.js → dist-BayWssd0.js} +1 -1
  14. package/dist/client/assets/{dist-DBUqwiWG.js → dist-Bk_pkBVH.js} +1 -1
  15. package/dist/client/assets/{dist-CbVf2Cjn.js → dist-BpeClAv0.js} +1 -1
  16. package/dist/client/assets/{dist-DftD4ibj.js → dist-BsmJg5PX.js} +1 -1
  17. package/dist/client/assets/{dist-CUB_Chdh.js → dist-Bx7s4rni.js} +1 -1
  18. package/dist/client/assets/{dist-Bh8Q7Y_n.js → dist-CDBKM9tL.js} +1 -1
  19. package/dist/client/assets/{dist-BoyICDlL.js → dist-CGzXCzCG.js} +1 -1
  20. package/dist/client/assets/{dist-BCNaDgNW.js → dist-CRxCwn-Z.js} +1 -1
  21. package/dist/client/assets/{dist-76ArZ5M4.js → dist-CTDgUnBG.js} +1 -1
  22. package/dist/client/assets/{dist-BXBSIuTD.js → dist-D1VfMWmf.js} +1 -1
  23. package/dist/client/assets/{dist-DN0GlnnZ.js → dist-DTZLNEci.js} +1 -1
  24. package/dist/client/assets/{dist-JvQIIdqB.js → dist-DuUi29km.js} +1 -1
  25. package/dist/client/assets/{dist-CHt8PX8R.js → dist-F3S0t1oM.js} +1 -1
  26. package/dist/client/assets/{dist-BuR5Iagd.js → dist-QZ-FAVJV.js} +1 -1
  27. package/dist/client/assets/{dist-Bx6ZWYUW.js → dist-u0nBg0fZ.js} +1 -1
  28. package/dist/client/assets/index-BMpqviwU.css +1 -0
  29. package/dist/client/assets/{index-E7yaLa2C.js → index-Dzyp_7sf.js} +43 -43
  30. package/dist/client/index.html +2 -2
  31. package/dist/server/active-memory.d.ts +17 -0
  32. package/dist/server/active-memory.js +39 -0
  33. package/dist/server/agents.d.ts +1 -1
  34. package/dist/server/agents.js +1 -1
  35. package/dist/server/application/conversation-service.js +6 -0
  36. package/dist/server/application/run-service.d.ts +16 -0
  37. package/dist/server/application/run-service.js +175 -26
  38. package/dist/server/application/session-orchestrator-service.d.ts +103 -1
  39. package/dist/server/application/session-orchestrator-service.js +308 -8
  40. package/dist/server/application/session-watchdog.d.ts +159 -0
  41. package/dist/server/application/session-watchdog.js +244 -0
  42. package/dist/server/http-server.js +136 -76
  43. package/dist/server/index.js +3 -0
  44. package/dist/server/knowledge-vectors.d.ts +15 -0
  45. package/dist/server/knowledge-vectors.js +118 -37
  46. package/dist/server/knowledge.d.ts +7 -8
  47. package/dist/server/knowledge.js +133 -55
  48. package/dist/server/length-continuation.d.ts +50 -0
  49. package/dist/server/length-continuation.js +55 -0
  50. package/dist/server/pi-session-events.js +5 -1
  51. package/dist/server/pi-session-pool.d.ts +2 -0
  52. package/dist/server/pi-session-pool.js +16 -0
  53. package/dist/server/runtime.js +5 -4
  54. package/dist/server/session-tree-scope.d.ts +125 -0
  55. package/dist/server/session-tree-scope.js +337 -0
  56. package/dist/server/store.d.ts +13 -0
  57. package/dist/server/store.js +37 -4
  58. package/dist/server/task-tool.d.ts +4 -1
  59. package/dist/server/task-tool.js +25 -1
  60. package/dist/server/turn-failure.d.ts +26 -0
  61. package/dist/server/turn-failure.js +51 -0
  62. package/dist/server/types.d.ts +15 -1
  63. package/package.json +20 -3
  64. package/dist/client/assets/index-D-OxlUxN.css +0 -1
@@ -110,7 +110,7 @@ description: 用脚本清洗、转换、统计 Excel/CSV 数据
110
110
  mode: primary
111
111
  ---
112
112
  (正文从这里开始,写它的职责和工作方式。)保存后下一条消息即可使用;修改已有的自定义 Agent 就是编辑同一个目录里对应的 .md 文件。
113
- - 用户要多个 agent 分工协作:单个子任务用 task 工具委托,有先后依赖的流程用 workflow 工具编排;同一流程要按明确结论行反复执行时用 loop 节点,要对 primary 自己列出的一批同构对象逐项执行时用 foreach 节点,两者可以任意嵌套。需要拆分多条独立并行工作线、多会话持续跟踪管理、或用户要求创建多个会话并行时,用 session_spawn 创建兄弟会话,并用 session_status / session_dispatch / session_stop 监督管理。`;
113
+ - 用户要多个 agent 分工协作:单个子任务用 task 工具委托,有先后依赖的流程用 workflow 工具编排;同一流程要按明确结论行反复执行时用 loop 节点,要对 primary 自己列出的一批同构对象逐项执行时用 foreach 节点,两者可以任意嵌套。需要拆分多条独立并行工作线、多会话持续跟踪管理、或用户要求创建多个会话并行时,用 session_spawn 创建兄弟会话,并用 session_status / session_dispatch / session_stop 监督管理。父会话可在 session_spawn 时用 watchdogTimeoutSeconds 声明「多久没收到汇报就提醒我一次」;被创建出来的子会话用 session_report 主动向自己的父会话汇报(status 用 in_progress 表示进行中、completed 表示完成、failed 表示失败)。`;
114
114
 
115
115
  /** The parameters, OpenCode's `tool/todo.ts:6-8` minus its schema wrapper. */
116
116
  export type TodoParams = { todos: TodoEntry[] };
@@ -1140,6 +1140,7 @@ export const SESSION_SPAWN_TOOL_NAME = "session_spawn";
1140
1140
  export const SESSION_STATUS_TOOL_NAME = "session_status";
1141
1141
  export const SESSION_DISPATCH_TOOL_NAME = "session_dispatch";
1142
1142
  export const SESSION_STOP_TOOL_NAME = "session_stop";
1143
+ export const SESSION_REPORT_TOOL_NAME = "session_report";
1143
1144
 
1144
1145
  /** Model-facing description for session_spawn. */
1145
1146
  export const SESSION_SPAWN_DESCRIPTION = `Create a new sibling conversation in the current workspace and immediately dispatch its initial task.
@@ -1163,7 +1164,9 @@ Usage notes:
1163
1164
  2. The initial task should provide clear context and goals since the new session starts with a fresh conversation history.
1164
1165
  3. Use session_status with the returned conversationId to check progress, or session_dispatch to send further messages.
1165
1166
  4. The new session reports completion to its DIRECT parent automatically. 'parentConversationId' optionally selects that parent; by default it is the calling session.
1166
- 5. The new session always belongs to the calling session's workspace. Pass 'cwd' as a workspace-relative subdirectory (for example, 'packages/a') when it should work below the workspace root; absolute paths and traversal are rejected.`;
1167
+ 5. The new session always belongs to the calling session's workspace. Pass 'cwd' as a workspace-relative subdirectory (for example, 'packages/a') when it should work below the workspace root; absolute paths and traversal are rejected.
1168
+ 6. Optionally pass 'model' to choose which model the NEW session runs on: {"provider":"...","modelId":"..."} - the same "provider/modelId" pair the model picker shows, and BOTH halves are required. Leave 'model' out and the new session starts on the workspace default model.
1169
+ 7. Optionally pass 'watchdogTimeoutSeconds' to declare how long YOU are willing to wait for a report before you want to be reminded: a positive number of seconds. If the new session stays silent that long, you receive a '[Watchdog 提醒]' message naming it. A report from the child (session_report) restarts the clock; the watchdog never stops the child. Leave it out to run without a watchdog.`;
1167
1170
 
1168
1171
  /** Model-facing description for session_status. */
1169
1172
  export const SESSION_STATUS_DESCRIPTION = `Inspect the progress, run state, and latest activity of sibling conversations created by the orchestrator.
@@ -1206,6 +1209,28 @@ Usage notes:
1206
1209
  - 'queued': only cancels pending queued messages; lets the currently running turn complete naturally.
1207
1210
  2. Use 'messageId' if you want to cancel or interrupt one specific queued message instead of all queued messages.`;
1208
1211
 
1212
+ /** Model-facing description for session_report. */
1213
+ export const SESSION_REPORT_DESCRIPTION = `Report progress from THIS session to the parent session that spawned it.
1214
+
1215
+ WHEN TO USE THIS:
1216
+ - You are a spawned sibling session, and the parent is waiting to hear from you: a milestone is done, a roadblock appeared, or the task is finished.
1217
+ - The parent set a watchdog (session_spawn's 'watchdogTimeoutSeconds'): a report is what restarts that clock, and silence is what triggers the reminder.
1218
+ - The task is over and the parent needs the outcome NOW rather than after the automatic end-of-turn result.
1219
+
1220
+ WHEN NOT TO USE THIS:
1221
+ - This session has no parent (the user opened it directly): there is nobody to report to, and the server refuses the call.
1222
+ - You want to ASK the parent something or send it new instructions: that is session_dispatch, and only the parent can send it. A report is one-way - the parent receives it as a message.
1223
+
1224
+ Usage notes:
1225
+ 1. 'content' is required: it is the text the parent receives. Write it for the parent - what is done, what is left, what you need.
1226
+ 2. 'status' says what the report MEANS:
1227
+ - 'in_progress' (default): an interim update. The task continues, and the parent's watchdog clock restarts.
1228
+ - 'completed': the task is finished and this is your final word.
1229
+ - 'failed': the task could not be finished, and this says why.
1230
+ 3. A 'completed' or 'failed' report tells the server the work is over, so the parent is NOT also sent the automatic end-of-turn result. Send it once, at the end, with the final answer in 'content'.
1231
+ 4. Reporting does NOT end your turn. If the task is not done, keep working afterwards - the parent is waiting on the work, not on the report.
1232
+ 5. The report reaches your DIRECT parent only. A sibling, a cousin, and the user's own session are all out of reach, and the server refuses those.`;
1233
+
1209
1234
  /** Compact summary returned for an orchestrated session. */
1210
1235
  export type OrchestratorSessionSummary = {
1211
1236
  conversationId: string;
@@ -1259,10 +1284,24 @@ export type SessionSpawnParams = {
1259
1284
  parentConversationId?: string;
1260
1285
  title?: string;
1261
1286
  agentId?: string;
1287
+ /**
1288
+ * The model the NEW session runs on, as the "provider/modelId" pair the model picker shows.
1289
+ *
1290
+ * Both halves are required when this is present, and the server looks the pair up in Pi's
1291
+ * catalog: a pair Pi does not offer is REFUSED there, not quietly replaced by the default.
1292
+ */
1293
+ model?: { provider: string; modelId: string };
1262
1294
  thinkingLevel?: string;
1263
1295
  wait?: boolean;
1264
1296
  /** Optional subdirectory (relative to the resolved workspace root) the new session's cwd should be rooted in. */
1265
1297
  cwd?: string;
1298
+ /**
1299
+ * How long the PARENT is willing to wait for a report before it wants to be reminded, in seconds.
1300
+ *
1301
+ * The parent declares it once, at spawn time, and the watchdog never stops the child - it only
1302
+ * tells the parent that the child has gone quiet. A report from the child restarts the clock.
1303
+ */
1304
+ watchdogTimeoutSeconds?: number;
1266
1305
  };
1267
1306
 
1268
1307
  export type SessionStatusParams = {
@@ -1283,6 +1322,86 @@ export type SessionStopParams = {
1283
1322
  messageId?: string;
1284
1323
  };
1285
1324
 
1325
+ /**
1326
+ * What this session is allowed to tell its parent.
1327
+ *
1328
+ * `status` is the model's word for what the report MEANS, and the server turns it into two
1329
+ * different things: an interim report restarts the watchdog clock, a terminal one cancels it and
1330
+ * silences the automatic end-of-turn result. The three values are the server's own vocabulary.
1331
+ */
1332
+ export type SessionReportParams = {
1333
+ content: string;
1334
+ status?: "in_progress" | "completed" | "failed";
1335
+ };
1336
+
1337
+ /**
1338
+ * THE FORMAT THE MODEL IS TOLD TO USE. The client hands its model picker a single
1339
+ * "provider/modelId" string, so this is the shape the model already knows how to read.
1340
+ */
1341
+ const SPAWN_MODEL_FORMAT = 'the "provider/modelId" pair the model picker shows, e.g. {"provider":"anthropic","modelId":"claude-..."}';
1342
+
1343
+ const SPAWN_MODEL_SHAPE_REFUSAL = `session_spawn's \`model\` parameter must be an object carrying BOTH \`provider\` and \`modelId\` - ${SPAWN_MODEL_FORMAT}. Provide both, or leave \`model\` out entirely to use the workspace default model.`;
1344
+
1345
+ const SPAWN_MODEL_MISSING_PROVIDER_REFUSAL = `session_spawn's \`model\` parameter is missing \`provider\`. It needs BOTH \`provider\` and \`modelId\` - ${SPAWN_MODEL_FORMAT}. Provide both, or leave \`model\` out entirely to use the workspace default model.`;
1346
+
1347
+ const SPAWN_MODEL_MISSING_MODEL_ID_REFUSAL = `session_spawn's \`model\` parameter is missing \`modelId\`. It needs BOTH \`provider\` and \`modelId\` - ${SPAWN_MODEL_FORMAT}. Provide both, or leave \`model\` out entirely to use the workspace default model.`;
1348
+
1349
+ /**
1350
+ * The silence watchdog the parent declares, or the reason it cannot be used.
1351
+ *
1352
+ * A NUMBER OF SECONDS, AND NOTHING ELSE. The server clamps whatever arrives into the range it
1353
+ * accepts, so a nonsense value would arrive as a real watchdog with a duration nobody chose - a
1354
+ * parent that asked for "about five minutes" and got three seconds of tolerance would be reminded
1355
+ * before the child had said anything. So a value that is not a positive number is refused HERE,
1356
+ * where the model is told exactly what to write instead.
1357
+ *
1358
+ * An ABSENT value is not a case here: it means "no watchdog", which is what a spawn without one has
1359
+ * always meant, and the body then carries no watchdog field at all.
1360
+ */
1361
+ const SPAWN_WATCHDOG_REFUSAL = `session_spawn's \`watchdogTimeoutSeconds\` parameter must be a positive number of seconds - how long the parent is willing to wait for a report before it wants to be reminded. Provide a number such as 300, or leave the parameter out to run without a watchdog.`;
1362
+
1363
+ function readSpawnWatchdog(raw: unknown): { seconds?: number; error?: string } {
1364
+ if (raw === undefined || raw === null) return {};
1365
+ // A NUMBER, OR A STRING THAT IS ONE. Anything else - a boolean, an object, an array - is not a
1366
+ // duration, and `Number(true)` being 1 is exactly the kind of accident a duration must not have.
1367
+ const value = typeof raw === "number"
1368
+ ? raw
1369
+ : (typeof raw === "string" && raw.trim() ? Number(raw) : Number.NaN);
1370
+ if (!Number.isFinite(value) || value <= 0) return { error: SPAWN_WATCHDOG_REFUSAL };
1371
+ // THE SERVER'S OWN FLOOR. A watchdog shorter than a second is not a watchdog, and the server
1372
+ // clamps it up to one second - so the tool does the same, and a parent that asked for "half a
1373
+ // second" gets a second rather than a watchdog that never fires.
1374
+ return { seconds: Math.max(1, Math.floor(value)) };
1375
+ }
1376
+
1377
+ /**
1378
+ * The model selection the model asked for, or the reason it cannot be used.
1379
+ *
1380
+ * THE MODEL IS A PAIR OR IT IS NOTHING. The server's `setModel` looks the pair up in Pi's catalog:
1381
+ * half a pair is looked up with an empty string, is not found, and comes back as a catalog error
1382
+ * that does not say WHICH half was missing. So the pair is checked here, where the model can be
1383
+ * told exactly what to fix.
1384
+ *
1385
+ * A HALF-SPECIFIED MODEL IS REFUSED, NOT DROPPED. A dropped `model` is indistinguishable from a
1386
+ * deliberate "use the workspace default": the new session would run on a model nobody asked for,
1387
+ * and the mistake would not surface until the session behaved differently from what was expected.
1388
+ * That is why an empty object and a blank string are refusals too, rather than "no model at all".
1389
+ *
1390
+ * An ABSENT `model` is not a case here. It means "the workspace default", which is what the server
1391
+ * has always done, and the body then carries no model field at all.
1392
+ */
1393
+ function readSpawnModel(raw: unknown): { model?: { provider: string; modelId: string }; error?: string } {
1394
+ if (raw === undefined || raw === null) return {};
1395
+ const pair = (typeof raw === "object" && !Array.isArray(raw)) ? raw as { provider?: unknown; modelId?: unknown } : undefined;
1396
+ if (!pair) return { error: SPAWN_MODEL_SHAPE_REFUSAL };
1397
+ const provider = typeof pair.provider === "string" ? pair.provider.trim() : "";
1398
+ const modelId = typeof pair.modelId === "string" ? pair.modelId.trim() : "";
1399
+ if (!provider && !modelId) return { error: SPAWN_MODEL_SHAPE_REFUSAL };
1400
+ if (!provider) return { error: SPAWN_MODEL_MISSING_PROVIDER_REFUSAL };
1401
+ if (!modelId) return { error: SPAWN_MODEL_MISSING_MODEL_ID_REFUSAL };
1402
+ return { model: { provider, modelId } };
1403
+ }
1404
+
1286
1405
  /** Execute session_spawn: creates a new sibling conversation and queues initial prompt. */
1287
1406
  export async function executeSessionSpawn(
1288
1407
  params: SessionSpawnParams,
@@ -1304,6 +1423,20 @@ export async function executeSessionSpawn(
1304
1423
  if (!params.task || !params.task.trim()) {
1305
1424
  return text("session_spawn requires a non-empty `task` parameter describing what the sibling session should do.", true);
1306
1425
  }
1426
+ // THE MODEL IS CHECKED BEFORE THE CALL, not after it. A half-specified pair would reach the server
1427
+ // as a catalog lookup with an empty half, and the answer would be an error about a model nobody
1428
+ // could name. Refused here, the model is told which half is missing and can fix it in one call.
1429
+ const selection = readSpawnModel(params.model);
1430
+ if (selection.error) {
1431
+ return text(selection.error, true);
1432
+ }
1433
+ // THE SAME TREATMENT FOR THE WATCHDOG. A silence timeout that is not a number would reach the
1434
+ // server as a duration nobody chose, and the server would clamp it into a real watchdog anyway -
1435
+ // so the mistake is refused here, where the model can fix it in one call.
1436
+ const watchdog = readSpawnWatchdog(params.watchdogTimeoutSeconds);
1437
+ if (watchdog.error) {
1438
+ return text(watchdog.error, true);
1439
+ }
1307
1440
 
1308
1441
  const send = deps.fetch ?? (globalFetch as unknown as TaskFetch);
1309
1442
  try {
@@ -1319,9 +1452,16 @@ export async function executeSessionSpawn(
1319
1452
  task: params.task.trim(),
1320
1453
  title: params.title?.trim() || undefined,
1321
1454
  agentId: params.agentId?.trim() || undefined,
1455
+ // ONLY WHEN A PAIR WAS GIVEN. An absent `model` leaves the field out of the body entirely,
1456
+ // and the server then applies the workspace default - which is what a spawn without a model
1457
+ // has always done, and what an explicit model must not quietly replace.
1458
+ ...(selection.model ? { model: selection.model } : {}),
1322
1459
  thinkingLevel: params.thinkingLevel?.trim() || undefined,
1323
1460
  wait: Boolean(params.wait),
1324
1461
  cwd: params.cwd?.trim() || undefined,
1462
+ // ONLY WHEN A DURATION WAS GIVEN. An absent watchdog leaves the field out entirely, and the
1463
+ // child then runs unwatched - which is what a spawn without one has always meant.
1464
+ ...(watchdog.seconds ? { watchdogTimeoutSeconds: watchdog.seconds } : {}),
1325
1465
  callerConversationId: config.conversationId || undefined,
1326
1466
  parentConversationId: params.parentConversationId?.trim() || config.conversationId || undefined,
1327
1467
  capability: config.capability,
@@ -1557,3 +1697,84 @@ export async function executeSessionStop(
1557
1697
  return text(`session_stop network error: ${error instanceof Error ? error.message : String(error)}`, true);
1558
1698
  }
1559
1699
  }
1700
+
1701
+ /**
1702
+ * Execute session_report: THIS session tells its direct parent what is going on.
1703
+ *
1704
+ * WHO CALLS IT. The child. The parent has no use for it - the parent's half of this conversation is
1705
+ * `session_dispatch`, `session_status` and `session_stop`. The child has no other way to speak at
1706
+ * all: without this tool, everything a child knows stays in the child's transcript until the turn
1707
+ * ends, and a parent waiting on a long task has nothing to read in the meantime.
1708
+ *
1709
+ * WHY THE CALLER ID AND NOT A TARGET. The body carries THIS session's id and no target at all. The
1710
+ * server reads the parent off the conversation's own tree edge, so the report can only ever reach
1711
+ * the session that spawned this one: a sibling, a cousin, and the user's own session are out of
1712
+ * reach by construction rather than by a rule that could be forgotten. The server owns that rule and
1713
+ * refuses what does not belong to the tree.
1714
+ *
1715
+ * WHY A REPORT DOES NOT END THE TURN. The parent asked to hear from this child WHILE it worked; a
1716
+ * report that ended the child's turn would turn every interim update into a completion. So the
1717
+ * report is a message, and the child's turn continues.
1718
+ */
1719
+ export async function executeSessionReport(
1720
+ params: SessionReportParams,
1721
+ config: OrchestratorToolConfig,
1722
+ deps: { signal?: AbortSignal; fetch?: TaskFetch } = {},
1723
+ ): Promise<TaskToolResult> {
1724
+ const text = (body: string, isError?: boolean): TaskToolResult => ({
1725
+ content: [{ type: "text", text: body }],
1726
+ details: undefined,
1727
+ ...(isError ? { isError: true } : {}),
1728
+ });
1729
+
1730
+ if (!config.endpoint) {
1731
+ return text("The session_report tool is not available in this session: SUPER_PI_ORCHESTRATOR_ENDPOINT is not set.", true);
1732
+ }
1733
+ if (!config.conversationId) {
1734
+ return text("The session_report tool is not available in this session: SUPER_PI_TASK_CONVERSATION is not set.", true);
1735
+ }
1736
+ if (!params.content || !params.content.trim()) {
1737
+ return text("session_report requires a non-empty `content` message.", true);
1738
+ }
1739
+ // THE STATUS IS THE MODEL'S OWN WORD, AND THE THREE VALUES ARE THE SERVER'S VOCABULARY. An
1740
+ // unknown value would reach the server as an interim report - the least consequential of the
1741
+ // three - so it is normalized here rather than travelling as something the server never saw.
1742
+ const status = params.status === "completed" || params.status === "failed" ? params.status : "in_progress";
1743
+
1744
+ const send = deps.fetch ?? (globalFetch as unknown as TaskFetch);
1745
+ try {
1746
+ const response = await send(config.endpoint, {
1747
+ method: "POST",
1748
+ headers: {
1749
+ "content-type": "application/json",
1750
+ ...(config.token ? { authorization: `Bearer ${config.token}` } : {}),
1751
+ },
1752
+ body: JSON.stringify({
1753
+ action: "report",
1754
+ content: params.content.trim(),
1755
+ status,
1756
+ // THE CALLER IS THIS SESSION. There is no target field: the parent is the server's to
1757
+ // decide, and it decides from the tree edge.
1758
+ callerConversationId: config.conversationId,
1759
+ capability: config.capability,
1760
+ }),
1761
+ ...(deps.signal ? { signal: deps.signal } : {}),
1762
+ });
1763
+
1764
+ const bodyText = await response.text();
1765
+ let payload: { ok?: boolean; delivered?: boolean; parentConversationId?: string; error?: string };
1766
+ try {
1767
+ payload = JSON.parse(bodyText);
1768
+ } catch {
1769
+ return text(`The orchestrator endpoint returned HTTP ${response.status}: ${bodyText}`, true);
1770
+ }
1771
+
1772
+ if (!response.ok || !payload.ok || !payload.delivered) {
1773
+ return text(`Failed to report to the parent session: ${payload.error ?? `HTTP ${response.status}`}`, true);
1774
+ }
1775
+
1776
+ return text(`Report delivered to parent session ${payload.parentConversationId ?? "(unknown)"}.`);
1777
+ } catch (error) {
1778
+ return text(`session_report network error: ${error instanceof Error ? error.message : String(error)}`, true);
1779
+ }
1780
+ }
@@ -41,19 +41,23 @@ import {
41
41
  SESSION_STATUS_TOOL_NAME,
42
42
  SESSION_DISPATCH_TOOL_NAME,
43
43
  SESSION_STOP_TOOL_NAME,
44
+ SESSION_REPORT_TOOL_NAME,
44
45
  SESSION_SPAWN_DESCRIPTION,
45
46
  SESSION_STATUS_DESCRIPTION,
46
47
  SESSION_DISPATCH_DESCRIPTION,
47
48
  SESSION_STOP_DESCRIPTION,
49
+ SESSION_REPORT_DESCRIPTION,
48
50
  executeSessionSpawn,
49
51
  executeSessionStatus,
50
52
  executeSessionDispatch,
51
53
  executeSessionStop,
54
+ executeSessionReport,
52
55
  readOrchestratorConfig,
53
56
  type SessionSpawnParams,
54
57
  type SessionStatusParams,
55
58
  type SessionDispatchParams,
56
59
  type SessionStopParams,
60
+ type SessionReportParams,
57
61
  } from "./core.ts";
58
62
 
59
63
  /**
@@ -458,6 +462,10 @@ const extension = (pi: ExtensionApi): void => {
458
462
  agentId: Type.Optional(Type.String({
459
463
  description: "Optional agent definition to assign to the new session (e.g. 'coder', 'planner'). Defaults to the workspace default.",
460
464
  })),
465
+ model: Type.Optional(Type.Object({
466
+ provider: Type.String({ description: "The provider half of the \"provider/modelId\" pair, e.g. \"anthropic\"." }),
467
+ modelId: Type.String({ description: "The model half of the \"provider/modelId\" pair, e.g. \"claude-...\"." }),
468
+ }, { description: "The model the NEW session runs on. BOTH halves are required - it is one \"provider/modelId\" pair, exactly as the model picker shows it. Leave it out to use the workspace default model." })),
461
469
  thinkingLevel: Type.Optional(Type.String({
462
470
  description: "Optional thinking level override ('off', 'low', 'medium', 'high'). Defaults to workspace setting.",
463
471
  })),
@@ -467,6 +475,9 @@ const extension = (pi: ExtensionApi): void => {
467
475
  cwd: Type.Optional(Type.String({
468
476
  description: "Optional workspace-root-relative subdirectory (for example, packages/a). Absolute paths, '..' traversal, UNC paths, and escaping symlinks are rejected; omit it to use the workspace root.",
469
477
  })),
478
+ watchdogTimeoutSeconds: Type.Optional(Type.Number({
479
+ description: "How long YOU are willing to wait for a report from the new session before you want to be reminded, in seconds (for example 300 for five minutes). A report from the child restarts the clock; the watchdog never stops the child. Omit it to run without a watchdog.",
480
+ })),
470
481
  });
471
482
 
472
483
  const SessionStatusParameters = Type.Object({
@@ -509,6 +520,27 @@ const extension = (pi: ExtensionApi): void => {
509
520
  })),
510
521
  });
511
522
 
523
+ /**
524
+ * The `session_report` parameter schema.
525
+ *
526
+ * `content` is required, because a report with nothing in it is a report that says nothing - and
527
+ * the parent reads it as if it had been told something. `status` is a closed union of the three
528
+ * words the server understands, so a model cannot invent a fourth one that arrives as an
529
+ * unintended interim update.
530
+ */
531
+ const SessionReportParameters = Type.Object({
532
+ content: Type.String({
533
+ description: "The text the parent receives. Write it for the parent: what is done, what is left, what you need.",
534
+ }),
535
+ status: Type.Optional(Type.Union([
536
+ Type.Literal("in_progress", { description: "An interim update; the task continues and the parent's watchdog clock restarts (default)" }),
537
+ Type.Literal("completed", { description: "The task is finished and this is the final report" }),
538
+ Type.Literal("failed", { description: "The task could not be finished; say why" }),
539
+ ], {
540
+ description: "What this report means: 'in_progress' (default), 'completed', or 'failed'.",
541
+ })),
542
+ });
543
+
512
544
  if (orchestratorConfig.endpoint) {
513
545
  pi.registerTool({
514
546
  name: SESSION_SPAWN_TOOL_NAME,
@@ -549,6 +581,24 @@ const extension = (pi: ExtensionApi): void => {
549
581
  execute: async (_toolCallId, params, signal) =>
550
582
  await executeSessionStop(params as SessionStopParams, orchestratorConfig, { signal: signal ?? undefined }),
551
583
  });
584
+
585
+ /**
586
+ * `session_report`, registered AFTER the four tools that act ON OTHER SESSIONS.
587
+ *
588
+ * The order is the reading order, and this one is the odd one out: the other four are a
589
+ * PARENT's tools - they reach out and manage somebody else's session - while this one is the
590
+ * CHILD's own voice. A model reading the list top to bottom meets the manager's instruments
591
+ * first and the worker's mouth last, which is the order the relationship actually has.
592
+ */
593
+ pi.registerTool({
594
+ name: SESSION_REPORT_TOOL_NAME,
595
+ label: "Report to Parent",
596
+ description: SESSION_REPORT_DESCRIPTION,
597
+ promptSnippet: "report progress or a blocker to the parent session that spawned this one",
598
+ parameters: SessionReportParameters,
599
+ execute: async (_toolCallId, params, signal) =>
600
+ await executeSessionReport(params as SessionReportParams, orchestratorConfig, { signal: signal ?? undefined }),
601
+ });
552
602
  }
553
603
  };
554
604
 
@@ -1,4 +1,4 @@
1
1
  {
2
- "hash": "18d8fc3b741101f1cce33ac67a4feee227b1c1db58e90cf33ea3e6bd4c79f225",
3
- "recordedAt": "2026-10-31T09:16:04.927Z"
2
+ "hash": "e5cb906c56347ca1a24242d67ae0850776c429dd1ede01841d6b7385f6615400",
3
+ "recordedAt": "2026-11-01T04:12:06.469Z"
4
4
  }
@@ -1,20 +1,20 @@
1
1
  {
2
- "hash": "e744700c40ec7a903b3e20b034b70ed20aac955aa6023fdf8099131ab59cc49f",
2
+ "hash": "32e49d6e2012d538c105b4faff8416b2d9963d87a41e18c1e5b7a85d686e9084",
3
3
  "files": {
4
- "src/client/App.tsx": "e370ca6c86a9b061b699277e346622cd168d53e5c19ead08846ad24799eef47e",
4
+ "src/client/App.tsx": "ecd95b1f6b5491092e0a639ebd9446e8050b9a5add3e995696e13f76a65c4264",
5
5
  "src/client/CodeMirrorEditor.tsx": "b6b6479effa1482eda710f04a26f3af843515526e129ca5bc70692cca9074b09",
6
6
  "src/client/ErrorBoundary.tsx": "d16376f9f6c7cc1fab8590c65a66438127642f7d6bb8023cec53d8a6cc9f3964",
7
7
  "src/client/FeishuPanel.tsx": "52f116eba265bfde683338f5893107ad5559fd2f7d4a9e0df935507a46862a3b",
8
8
  "src/client/FilesPanel.tsx": "820a8685729ab03d22917bc56b7831f5cd8c6534dde4ba2a8d145f4dab5a9293",
9
- "src/client/GitPanel.tsx": "c684c851820f233e3b755665266d5b9195b1f1b1d4cfdddc72c95a5f98413ed7",
9
+ "src/client/GitPanel.tsx": "101cd8dd4549ddedb4c75bc48cebf4d06e9229cc4daf48196d3de07a51cb6538",
10
10
  "src/client/HelpWindow.tsx": "a52005240894911eb8a35efab78aa6ddcda9fef6dca976aafc4255a4f635ca76",
11
11
  "src/client/KnowledgeFilePicker.tsx": "8f7eb7e9f70265aed09cc0892b091827976757d8f2a2d736d6ca170fcdd871e7",
12
12
  "src/client/KnowledgePanel.tsx": "4f7230cfe610cd86d63aa143c82f6195b3c4208ef0bea703f92104ef27237704",
13
13
  "src/client/MarkdownView.tsx": "4f04a8f3c9381946e5d2f957ac4fb74a6b16272e90375fb4dc6bd3a43d7c744d",
14
14
  "src/client/MemoryPanel.tsx": "2cc1f4ee709f6d56ede8b0ceced228ea4c935cfd1cc803275558dbbd5f5244fb",
15
- "src/client/ScheduledTasksPanel.tsx": "83a97794ed99b25a3175ed31ea3fb096976311566b03ddcc975685378d78a217",
15
+ "src/client/ScheduledTasksPanel.tsx": "ad8d929b73c7d332730fd41a8594e3d79930161121d5727b94d39a089d36d9c8",
16
16
  "src/client/SlashCommandMenu.tsx": "69cd0a9d5e35f41f703e91a845e5bd750c952d2957be03b5528e156e60bf6ecb",
17
- "src/client/Tabs.tsx": "53323a198c0948887cb0cd018284ecd5c9b36025364484a91426f8e1e2198000",
17
+ "src/client/Tabs.tsx": "4b29ddad2451a039f2bd7de99011683949307846667f0f0aa554a1d591fd7f18",
18
18
  "src/client/TerminalPanel.tsx": "89db360a96c47e4afa7d84bbeada7ab765794a6a28b8c1260f15a71fbf948201",
19
19
  "src/client/WorkflowCard.tsx": "8ce5458537a3b02dcbb9bbb4c7afacb07e0f41857ed250aa4cde0cbc8d4bde6c",
20
20
  "src/client/editor-blame.ts": "d03669f945aca09ff77d100ef0d4f0129af4f8ccef81963c3ce00f8f6fb034c2",
@@ -27,13 +27,13 @@
27
27
  "src/client/pending-operations.ts": "8a5f9e9711c0f875c8ed194196c218162de5270298dad4091351d41294c859d7",
28
28
  "src/client/session-tree.ts": "affc00d2264926d615a38e458a89d3a8c651b74135bbfe004d0a9be9b14a0c86",
29
29
  "src/client/slash-commands.ts": "b792018fb67bd9e6f777397b0720b8b3aa565a4d8f7a76f94fec097ddf749480",
30
- "src/client/styles.css": "ed619bab79aa716f7dddd8e046ff432c0cb03677899ecc4f4ae1449877c733c9",
30
+ "src/client/styles.css": "e75703da5ef20811ff70bd882729bb1b7228fb6667542181d61bdf85d2505c1e",
31
31
  "src/client/terminal-emulator.ts": "ffcc4f5fbddaf25cebcc9e03dbe5d7d0ad2c21586f5d169e57c04c82e2308b3b",
32
32
  "src/client/theme.tsx": "5892479a802f41e7d45adeb5170efbf555b240f8581528bcde7bf2d99c635010",
33
33
  "src/client/tool-sharing.ts": "679c97f6d40be466964f2f1076aa7ea55f4a585c3deff8214675070220921059",
34
34
  "src/client/tools.ts": "58fe41f0edbd490e3fab7f12f258b1dbc2163b653553b03ac61caf1543618e50",
35
- "src/client/types.ts": "85997a0aa7553c0aed07fb7920463720770ffe4ab1a760dbfbb0b19abed24534",
35
+ "src/client/types.ts": "7c06189b32890009d28a371a64d9f29161c14a349a5b399d51d1314d38fa27ac",
36
36
  "src/client/vite-env.d.ts": "65996936fbb042915f7b74a200fcdde7e410f32a669b1ab9597cfaa4b0faddb5"
37
37
  },
38
- "recordedAt": "2026-10-31T10:13:46.384Z"
38
+ "recordedAt": "2026-11-01T14:41:49.801Z"
39
39
  }
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-Do52MRwm.js","assets/dist-DBUqwiWG.js","assets/index-E7yaLa2C.js","assets/index-D-OxlUxN.css","assets/dist-BCNaDgNW.js","assets/dist-Bx6ZWYUW.js","assets/dist-BoyICDlL.js","assets/dist-DFMtP3wG.js","assets/dist-CUB_Chdh.js","assets/dist-DC1IocrS.js","assets/dist-Bh8Q7Y_n.js","assets/dist-CbVf2Cjn.js","assets/dist-DftD4ibj.js","assets/dist-JvQIIdqB.js","assets/dist-BXBSIuTD.js","assets/dist-CHt8PX8R.js","assets/dist-DN0GlnnZ.js","assets/dist-76ArZ5M4.js","assets/dist-B0RXZeXQ.js","assets/dist-oLq6HXLG.js","assets/dist-CAOcjKAQ.js","assets/dist-BuR5Iagd.js","assets/dist-CSCUT1PQ.js","assets/dist-9F1wL-T5.js"])))=>i.map(i=>d[i]);
2
- import{a as e,i as t,n,r,s as i,t as a}from"./index-E7yaLa2C.js";var o=i(e(),1);async function s(e,t){let[{StreamLanguage:n},i]=await Promise.all([r(()=>import(`./dist-Do52MRwm.js`),__vite__mapDeps([0,1,2,3,4,5])),e()]),a=i[t]??i.default??i;return n.define(a)}var c={cpp:()=>r(()=>import(`./dist-BoyICDlL.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cc:()=>r(()=>import(`./dist-BoyICDlL.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cxx:()=>r(()=>import(`./dist-BoyICDlL.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hpp:()=>r(()=>import(`./dist-BoyICDlL.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hh:()=>r(()=>import(`./dist-BoyICDlL.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hxx:()=>r(()=>import(`./dist-BoyICDlL.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),c:()=>r(()=>import(`./dist-BoyICDlL.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),h:()=>r(()=>import(`./dist-BoyICDlL.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cu:()=>r(()=>import(`./dist-BoyICDlL.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cuh:()=>r(()=>import(`./dist-BoyICDlL.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),js:()=>r(()=>import(`./dist-CUB_Chdh.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),jsx:()=>r(()=>import(`./dist-CUB_Chdh.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),mjs:()=>r(()=>import(`./dist-CUB_Chdh.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),cjs:()=>r(()=>import(`./dist-CUB_Chdh.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),ts:()=>r(()=>import(`./dist-CUB_Chdh.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),tsx:()=>r(()=>import(`./dist-CUB_Chdh.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0,jsx:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),mts:()=>r(()=>import(`./dist-CUB_Chdh.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),cts:()=>r(()=>import(`./dist-CUB_Chdh.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),py:()=>r(()=>import(`./dist-Bh8Q7Y_n.js`).then(e=>e.python()),__vite__mapDeps([10,5,2,3,0,1,4,7,9])),pyi:()=>r(()=>import(`./dist-Bh8Q7Y_n.js`).then(e=>e.python()),__vite__mapDeps([10,5,2,3,0,1,4,7,9])),java:()=>r(()=>import(`./dist-CbVf2Cjn.js`).then(e=>e.java()),__vite__mapDeps([11,5,2,3,0,1,4,7])),php:()=>r(()=>import(`./dist-DftD4ibj.js`).then(e=>e.php()),__vite__mapDeps([12,5,2,3,0,1,4,7,13,14,8,9])),sql:()=>r(()=>import(`./dist-CHt8PX8R.js`).then(e=>e.sql()),__vite__mapDeps([15,5,2,3,0,1,4,7,9])),yaml:()=>r(()=>import(`./dist-DN0GlnnZ.js`).then(e=>e.yaml()),__vite__mapDeps([16,5,2,3,0,1,4,7])),yml:()=>r(()=>import(`./dist-DN0GlnnZ.js`).then(e=>e.yaml()),__vite__mapDeps([16,5,2,3,0,1,4,7])),xml:()=>r(()=>import(`./dist-76ArZ5M4.js`).then(e=>e.xml()),__vite__mapDeps([17,1,2,3,4,5,0,7])),json:()=>r(()=>import(`./dist-B0RXZeXQ.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),jsonc:()=>r(()=>import(`./dist-B0RXZeXQ.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),json5:()=>r(()=>import(`./dist-B0RXZeXQ.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),html:()=>r(()=>import(`./dist-JvQIIdqB.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),htm:()=>r(()=>import(`./dist-JvQIIdqB.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),vue:()=>r(()=>import(`./dist-JvQIIdqB.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),svelte:()=>r(()=>import(`./dist-JvQIIdqB.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),css:()=>r(()=>import(`./dist-BXBSIuTD.js`).then(e=>e.r).then(e=>e.css()),__vite__mapDeps([14,2,3,5,0,1,4,7])),md:()=>r(()=>import(`./dist-oLq6HXLG.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),markdown:()=>r(()=>import(`./dist-oLq6HXLG.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),mdx:()=>r(()=>import(`./dist-oLq6HXLG.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),rs:()=>r(()=>import(`./dist-CAOcjKAQ.js`).then(e=>e.rust()),__vite__mapDeps([20,5,2,3,0,1,4,7])),go:()=>r(()=>import(`./dist-BuR5Iagd.js`).then(e=>e.go()),__vite__mapDeps([21,5,2,3,0,1,4,7,9])),sh:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),bash:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),zsh:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),fish:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),ps1:()=>s(()=>r(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),psm1:()=>s(()=>r(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),rb:()=>s(()=>r(()=>import(`./ruby-ChfNwlCY.js`),[]),`ruby`),swift:()=>s(()=>r(()=>import(`./swift-DKB6_1j6.js`),[]),`swift`),toml:()=>s(()=>r(()=>import(`./toml-BPTmHmyx.js`),[]),`toml`),ini:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),cfg:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),conf:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),properties:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),dockerfile:()=>s(()=>r(()=>import(`./dockerfile-BDePf5PZ.js`),[]),`dockerfile`),diff:()=>s(()=>r(()=>import(`./diff-ChtP43wD.js`),[]),`diff`),patch:()=>s(()=>r(()=>import(`./diff-ChtP43wD.js`),[]),`diff`)},l={cpp:`C++`,cc:`C++`,cxx:`C++`,hpp:`C++`,hh:`C++`,hxx:`C++`,cu:`CUDA C++`,cuh:`CUDA C++`,c:`C`,h:`C/C++ Header`,js:`JavaScript`,jsx:`JSX`,mjs:`JavaScript`,cjs:`JavaScript`,ts:`TypeScript`,tsx:`TSX`,mts:`TypeScript`,cts:`TypeScript`,py:`Python`,pyi:`Python Stub`,java:`Java`,php:`PHP`,sql:`SQL`,yaml:`YAML`,yml:`YAML`,xml:`XML`,json:`JSON`,jsonc:`JSON with Comments`,json5:`JSON5`,css:`CSS`,md:`Markdown`,markdown:`Markdown`,mdx:`MDX`,rs:`Rust`,go:`Go`,html:`HTML`,htm:`HTML`,vue:`Vue`,svelte:`Svelte`,sh:`Shell`,bash:`Bash`,zsh:`Zsh`,fish:`Fish`,ps1:`PowerShell`,psm1:`PowerShell`,rb:`Ruby`,swift:`Swift`,toml:`TOML`,ini:`INI`,cfg:`Config`,conf:`Config`,properties:`Properties`,dockerfile:`Dockerfile`,diff:`Diff`,patch:`Patch`};function u(e){return c[e.toLowerCase()]}function d(e){return l[e.toLowerCase()]}var f=t(),p=262144,m=131072;function h(e){return e.split(`.`).pop()?.toLowerCase()??``}function g(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function _(e,t){return e.HighlightStyle.define([{tag:t.tags.keyword,color:g(`--cm-keyword`)},{tag:t.tags.string,color:g(`--cm-string`)},{tag:t.tags.number,color:g(`--cm-number`)},{tag:t.tags.comment,color:g(`--cm-comment`),fontStyle:`italic`},{tag:t.tags.function(t.tags.variableName),color:g(`--cm-function`)},{tag:t.tags.typeName,color:g(`--cm-type`)},{tag:t.tags.className,color:g(`--cm-type`)},{tag:t.tags.propertyName,color:g(`--cm-property`)},{tag:t.tags.operator,color:g(`--cm-operator`)},{tag:t.tags.variableName,color:g(`--cm-variable`)}])}function v({path:e,value:t,onChange:i,jumpToLine:s,onSave:c,workspaceId:l,blame:g}){let v=(0,o.useRef)(null),y=(0,o.useRef)(null),b=(0,o.useRef)(null),x=(0,o.useRef)(null),S=(0,o.useRef)(null),C=(0,o.useRef)(null),w=(0,o.useRef)(null),T=(0,o.useRef)(null),E=(0,o.useRef)(i),D=(0,o.useRef)(c);E.current=i,D.current=c;let[O,k]=(0,o.useState)(!1),[A,j]=(0,o.useState)(!1),[M,N]=(0,o.useState)(`0,0`),[P,F]=(0,o.useState)(0);(0,o.useEffect)(()=>{let i=!1,a,o,s,c,l;return(async()=>{try{let d=h(e),f=u(d),[m,g,O,A,M,P,I,L]=await Promise.all([r(()=>import(`./dist-DBUqwiWG.js`).then(e=>e.x),__vite__mapDeps([1,2,3])),r(()=>import(`./dist-BCNaDgNW.js`).then(e=>e.s),__vite__mapDeps([4,2,3,1])),r(()=>import(`./dist-CSCUT1PQ.js`),__vite__mapDeps([22,1,2,3,4,5,0])),r(()=>import(`./dist-9F1wL-T5.js`),__vite__mapDeps([23,1,2,3,4])),r(()=>import(`./dist-Do52MRwm.js`),__vite__mapDeps([0,1,2,3,4,5])),r(()=>import(`./dist-Bx6ZWYUW.js`).then(e=>e.n),__vite__mapDeps([5,2,3])),f?f().catch(e=>(console.warn(`[CodeMirror] Failed to load language for .${d}:`,e),null)):Promise.resolve(null),n().catch(e=>(console.warn(`[CodeMirror] Failed to build the blame extension:`,e),null))]);if(i||!v.current)return;c=M,l=P,x.current=m.Annotation.define(),S.current=m.Transaction.addToHistory;let R=t.length<=p&&I!==null;o=new m.Compartment;let z=[g.lineNumbers(),g.highlightActiveLine(),g.drawSelection(),O.history(),g.keymap.of([O.indentWithTab,...O.defaultKeymap,...O.historyKeymap,...A.searchKeymap,{key:`Mod-s`,run:()=>(D.current(),!0)}]),g.EditorView.updateListener.of(e=>{e.docChanged&&!(x.current&&e.transactions.some(e=>e.annotation(x.current)===!0))&&E.current(e.state.doc.toString()),e.selectionSet&&N(`${e.state.selection.main.from},${e.state.selection.main.to}`)}),g.EditorView.domEventHandlers({mousedown:(e,t)=>(t.focus(),!1)})];if(L&&(s=new m.Compartment,z.splice(1,0,s.of([])),z.push(L.base)),I)try{z.push(I)}catch(e){console.warn(`[CodeMirror] Failed to apply language extension for .${d}:`,e),R=!1}if(R&&o&&c&&l)try{z.push(o.of(c.syntaxHighlighting(_(c,l))))}catch(e){console.warn(`[CodeMirror] Failed to attach syntaxHighlighting for .${d}:`,e),R=!1}if(a=new g.EditorView({state:m.EditorState.create({doc:t,extensions:z}),parent:v.current}),i){a.destroy();return}y.current=a,k(R),j(!0),C.current=L,w.current=s??null,T.current=null,F(e=>e+1);let B=new MutationObserver(()=>{let e=y.current;if(e&&R&&o&&c&&l)try{e.dispatch({effects:o.reconfigure(c.syntaxHighlighting(_(c,l)))})}catch{}});b.current=B,B.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]})}catch(e){console.error(`[CodeMirror] Fatal editor initialization error:`,e),i||j(!0)}})(),()=>{i=!0,b.current?.disconnect(),b.current=null,a?.destroy(),y.current=null,j(!1),v.current&&(v.current.textContent=``)}},[e]),(0,o.useEffect)(()=>{let e=y.current;if(!e)return;let n=e.state.doc.toString();n!==t&&e.dispatch({changes:{from:0,to:n.length,insert:t},annotations:x.current?x.current.of(!0):void 0})},[t]),(0,o.useEffect)(()=>{let e=y.current;if(!e||!s)return;let t=e.state.doc.line(Math.min(Math.max(1,s.line),e.state.doc.lines));e.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0}),e.focus()},[s,A]);let I=!!(g&&g.state===`ready`&&g.response&&g.path===e&&g.workspaceId===l);(0,o.useEffect)(()=>{let t=y.current,n=C.current,r=w.current;if(!t||!n||!r)return;let i=g&&g.state===`ready`&&g.response&&g.path===e&&g.workspaceId===l?g.response:null,o=i?a(i):null;T.current!==o&&(T.current=o,t.dispatch({effects:[n.setBlame.of(o),r.reconfigure(o?n.gutter:[])]}))},[g?.state,g?.response,g?.path,g?.workspaceId,e,l,P]);let L=y.current?.state.doc.toString()??t,R=L.length<=m?L:L.slice(0,m),z=h(e),B=d(z);return(0,f.jsxs)(`div`,{className:`file-cm-wrap`,"data-file-text":e,"data-file-content":R,"data-file-content-truncated":L.length>m?`1`:`0`,"data-file-selection":M,"data-file-editor-ready":A?`1`:`0`,"data-file-blame-gutter":I?`1`:void 0,onMouseDown:()=>y.current?.focus(),children:[(0,f.jsx)(`div`,{className:`file-cm`,ref:v,"aria-label":`编辑 ${e}`}),!A&&(0,f.jsx)(`span`,{className:`file-cm-status`,"data-file-editor-loading":`1`,children:`⌛ 正在加载编辑器…`}),A&&!O&&(0,f.jsx)(`span`,{className:`file-cm-status`,"data-file-highlight-status":`plain`,children:`纯文本`}),A&&O&&B&&(0,f.jsx)(`span`,{className:`file-cm-status file-cm-status-lang`,"data-file-highlight-status":z,children:B})]})}export{v as CodeMirrorEditor};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-B1qLZVMK.js","assets/dist-Bk_pkBVH.js","assets/index-Dzyp_7sf.js","assets/index-BMpqviwU.css","assets/dist-CRxCwn-Z.js","assets/dist-u0nBg0fZ.js","assets/dist-CGzXCzCG.js","assets/dist-BJVI1Unv.js","assets/dist-Bx7s4rni.js","assets/dist-1Innu17E.js","assets/dist-CDBKM9tL.js","assets/dist-BpeClAv0.js","assets/dist-BsmJg5PX.js","assets/dist-DuUi29km.js","assets/dist-D1VfMWmf.js","assets/dist-F3S0t1oM.js","assets/dist-DTZLNEci.js","assets/dist-CTDgUnBG.js","assets/dist-B6KwDpeI.js","assets/dist-BWvzD8Pe.js","assets/dist-B4pz_xdd.js","assets/dist-QZ-FAVJV.js","assets/dist-1lynFOc5.js","assets/dist-BayWssd0.js"])))=>i.map(i=>d[i]);
2
+ import{a as e,i as t,n,r,s as i,t as a}from"./index-Dzyp_7sf.js";var o=i(e(),1);async function s(e,t){let[{StreamLanguage:n},i]=await Promise.all([r(()=>import(`./dist-B1qLZVMK.js`),__vite__mapDeps([0,1,2,3,4,5])),e()]),a=i[t]??i.default??i;return n.define(a)}var c={cpp:()=>r(()=>import(`./dist-CGzXCzCG.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cc:()=>r(()=>import(`./dist-CGzXCzCG.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cxx:()=>r(()=>import(`./dist-CGzXCzCG.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hpp:()=>r(()=>import(`./dist-CGzXCzCG.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hh:()=>r(()=>import(`./dist-CGzXCzCG.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hxx:()=>r(()=>import(`./dist-CGzXCzCG.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),c:()=>r(()=>import(`./dist-CGzXCzCG.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),h:()=>r(()=>import(`./dist-CGzXCzCG.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cu:()=>r(()=>import(`./dist-CGzXCzCG.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cuh:()=>r(()=>import(`./dist-CGzXCzCG.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),js:()=>r(()=>import(`./dist-Bx7s4rni.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),jsx:()=>r(()=>import(`./dist-Bx7s4rni.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),mjs:()=>r(()=>import(`./dist-Bx7s4rni.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),cjs:()=>r(()=>import(`./dist-Bx7s4rni.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),ts:()=>r(()=>import(`./dist-Bx7s4rni.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),tsx:()=>r(()=>import(`./dist-Bx7s4rni.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0,jsx:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),mts:()=>r(()=>import(`./dist-Bx7s4rni.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),cts:()=>r(()=>import(`./dist-Bx7s4rni.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),py:()=>r(()=>import(`./dist-CDBKM9tL.js`).then(e=>e.python()),__vite__mapDeps([10,5,2,3,0,1,4,7,9])),pyi:()=>r(()=>import(`./dist-CDBKM9tL.js`).then(e=>e.python()),__vite__mapDeps([10,5,2,3,0,1,4,7,9])),java:()=>r(()=>import(`./dist-BpeClAv0.js`).then(e=>e.java()),__vite__mapDeps([11,5,2,3,0,1,4,7])),php:()=>r(()=>import(`./dist-BsmJg5PX.js`).then(e=>e.php()),__vite__mapDeps([12,5,2,3,0,1,4,7,13,14,8,9])),sql:()=>r(()=>import(`./dist-F3S0t1oM.js`).then(e=>e.sql()),__vite__mapDeps([15,5,2,3,0,1,4,7,9])),yaml:()=>r(()=>import(`./dist-DTZLNEci.js`).then(e=>e.yaml()),__vite__mapDeps([16,5,2,3,0,1,4,7])),yml:()=>r(()=>import(`./dist-DTZLNEci.js`).then(e=>e.yaml()),__vite__mapDeps([16,5,2,3,0,1,4,7])),xml:()=>r(()=>import(`./dist-CTDgUnBG.js`).then(e=>e.xml()),__vite__mapDeps([17,1,2,3,4,5,0,7])),json:()=>r(()=>import(`./dist-B6KwDpeI.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),jsonc:()=>r(()=>import(`./dist-B6KwDpeI.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),json5:()=>r(()=>import(`./dist-B6KwDpeI.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),html:()=>r(()=>import(`./dist-DuUi29km.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),htm:()=>r(()=>import(`./dist-DuUi29km.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),vue:()=>r(()=>import(`./dist-DuUi29km.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),svelte:()=>r(()=>import(`./dist-DuUi29km.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),css:()=>r(()=>import(`./dist-D1VfMWmf.js`).then(e=>e.r).then(e=>e.css()),__vite__mapDeps([14,2,3,5,0,1,4,7])),md:()=>r(()=>import(`./dist-BWvzD8Pe.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),markdown:()=>r(()=>import(`./dist-BWvzD8Pe.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),mdx:()=>r(()=>import(`./dist-BWvzD8Pe.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),rs:()=>r(()=>import(`./dist-B4pz_xdd.js`).then(e=>e.rust()),__vite__mapDeps([20,5,2,3,0,1,4,7])),go:()=>r(()=>import(`./dist-QZ-FAVJV.js`).then(e=>e.go()),__vite__mapDeps([21,5,2,3,0,1,4,7,9])),sh:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),bash:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),zsh:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),fish:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),ps1:()=>s(()=>r(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),psm1:()=>s(()=>r(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),rb:()=>s(()=>r(()=>import(`./ruby-ChfNwlCY.js`),[]),`ruby`),swift:()=>s(()=>r(()=>import(`./swift-DKB6_1j6.js`),[]),`swift`),toml:()=>s(()=>r(()=>import(`./toml-BPTmHmyx.js`),[]),`toml`),ini:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),cfg:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),conf:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),properties:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),dockerfile:()=>s(()=>r(()=>import(`./dockerfile-BDePf5PZ.js`),[]),`dockerfile`),diff:()=>s(()=>r(()=>import(`./diff-ChtP43wD.js`),[]),`diff`),patch:()=>s(()=>r(()=>import(`./diff-ChtP43wD.js`),[]),`diff`)},l={cpp:`C++`,cc:`C++`,cxx:`C++`,hpp:`C++`,hh:`C++`,hxx:`C++`,cu:`CUDA C++`,cuh:`CUDA C++`,c:`C`,h:`C/C++ Header`,js:`JavaScript`,jsx:`JSX`,mjs:`JavaScript`,cjs:`JavaScript`,ts:`TypeScript`,tsx:`TSX`,mts:`TypeScript`,cts:`TypeScript`,py:`Python`,pyi:`Python Stub`,java:`Java`,php:`PHP`,sql:`SQL`,yaml:`YAML`,yml:`YAML`,xml:`XML`,json:`JSON`,jsonc:`JSON with Comments`,json5:`JSON5`,css:`CSS`,md:`Markdown`,markdown:`Markdown`,mdx:`MDX`,rs:`Rust`,go:`Go`,html:`HTML`,htm:`HTML`,vue:`Vue`,svelte:`Svelte`,sh:`Shell`,bash:`Bash`,zsh:`Zsh`,fish:`Fish`,ps1:`PowerShell`,psm1:`PowerShell`,rb:`Ruby`,swift:`Swift`,toml:`TOML`,ini:`INI`,cfg:`Config`,conf:`Config`,properties:`Properties`,dockerfile:`Dockerfile`,diff:`Diff`,patch:`Patch`};function u(e){return c[e.toLowerCase()]}function d(e){return l[e.toLowerCase()]}var f=t(),p=262144,m=131072;function h(e){return e.split(`.`).pop()?.toLowerCase()??``}function g(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function _(e,t){return e.HighlightStyle.define([{tag:t.tags.keyword,color:g(`--cm-keyword`)},{tag:t.tags.string,color:g(`--cm-string`)},{tag:t.tags.number,color:g(`--cm-number`)},{tag:t.tags.comment,color:g(`--cm-comment`),fontStyle:`italic`},{tag:t.tags.function(t.tags.variableName),color:g(`--cm-function`)},{tag:t.tags.typeName,color:g(`--cm-type`)},{tag:t.tags.className,color:g(`--cm-type`)},{tag:t.tags.propertyName,color:g(`--cm-property`)},{tag:t.tags.operator,color:g(`--cm-operator`)},{tag:t.tags.variableName,color:g(`--cm-variable`)}])}function v({path:e,value:t,onChange:i,jumpToLine:s,onSave:c,workspaceId:l,blame:g}){let v=(0,o.useRef)(null),y=(0,o.useRef)(null),b=(0,o.useRef)(null),x=(0,o.useRef)(null),S=(0,o.useRef)(null),C=(0,o.useRef)(null),w=(0,o.useRef)(null),T=(0,o.useRef)(null),E=(0,o.useRef)(i),D=(0,o.useRef)(c);E.current=i,D.current=c;let[O,k]=(0,o.useState)(!1),[A,j]=(0,o.useState)(!1),[M,N]=(0,o.useState)(`0,0`),[P,F]=(0,o.useState)(0);(0,o.useEffect)(()=>{let i=!1,a,o,s,c,l;return(async()=>{try{let d=h(e),f=u(d),[m,g,O,A,M,P,I,L]=await Promise.all([r(()=>import(`./dist-Bk_pkBVH.js`).then(e=>e.x),__vite__mapDeps([1,2,3])),r(()=>import(`./dist-CRxCwn-Z.js`).then(e=>e.s),__vite__mapDeps([4,2,3,1])),r(()=>import(`./dist-1lynFOc5.js`),__vite__mapDeps([22,1,2,3,4,5,0])),r(()=>import(`./dist-BayWssd0.js`),__vite__mapDeps([23,1,2,3,4])),r(()=>import(`./dist-B1qLZVMK.js`),__vite__mapDeps([0,1,2,3,4,5])),r(()=>import(`./dist-u0nBg0fZ.js`).then(e=>e.n),__vite__mapDeps([5,2,3])),f?f().catch(e=>(console.warn(`[CodeMirror] Failed to load language for .${d}:`,e),null)):Promise.resolve(null),n().catch(e=>(console.warn(`[CodeMirror] Failed to build the blame extension:`,e),null))]);if(i||!v.current)return;c=M,l=P,x.current=m.Annotation.define(),S.current=m.Transaction.addToHistory;let R=t.length<=p&&I!==null;o=new m.Compartment;let z=[g.lineNumbers(),g.highlightActiveLine(),g.drawSelection(),O.history(),g.keymap.of([O.indentWithTab,...O.defaultKeymap,...O.historyKeymap,...A.searchKeymap,{key:`Mod-s`,run:()=>(D.current(),!0)}]),g.EditorView.updateListener.of(e=>{e.docChanged&&!(x.current&&e.transactions.some(e=>e.annotation(x.current)===!0))&&E.current(e.state.doc.toString()),e.selectionSet&&N(`${e.state.selection.main.from},${e.state.selection.main.to}`)}),g.EditorView.domEventHandlers({mousedown:(e,t)=>(t.focus(),!1)})];if(L&&(s=new m.Compartment,z.splice(1,0,s.of([])),z.push(L.base)),I)try{z.push(I)}catch(e){console.warn(`[CodeMirror] Failed to apply language extension for .${d}:`,e),R=!1}if(R&&o&&c&&l)try{z.push(o.of(c.syntaxHighlighting(_(c,l))))}catch(e){console.warn(`[CodeMirror] Failed to attach syntaxHighlighting for .${d}:`,e),R=!1}if(a=new g.EditorView({state:m.EditorState.create({doc:t,extensions:z}),parent:v.current}),i){a.destroy();return}y.current=a,k(R),j(!0),C.current=L,w.current=s??null,T.current=null,F(e=>e+1);let B=new MutationObserver(()=>{let e=y.current;if(e&&R&&o&&c&&l)try{e.dispatch({effects:o.reconfigure(c.syntaxHighlighting(_(c,l)))})}catch{}});b.current=B,B.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]})}catch(e){console.error(`[CodeMirror] Fatal editor initialization error:`,e),i||j(!0)}})(),()=>{i=!0,b.current?.disconnect(),b.current=null,a?.destroy(),y.current=null,j(!1),v.current&&(v.current.textContent=``)}},[e]),(0,o.useEffect)(()=>{let e=y.current;if(!e)return;let n=e.state.doc.toString();n!==t&&e.dispatch({changes:{from:0,to:n.length,insert:t},annotations:x.current?x.current.of(!0):void 0})},[t]),(0,o.useEffect)(()=>{let e=y.current;if(!e||!s)return;let t=e.state.doc.line(Math.min(Math.max(1,s.line),e.state.doc.lines));e.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0}),e.focus()},[s,A]);let I=!!(g&&g.state===`ready`&&g.response&&g.path===e&&g.workspaceId===l);(0,o.useEffect)(()=>{let t=y.current,n=C.current,r=w.current;if(!t||!n||!r)return;let i=g&&g.state===`ready`&&g.response&&g.path===e&&g.workspaceId===l?g.response:null,o=i?a(i):null;T.current!==o&&(T.current=o,t.dispatch({effects:[n.setBlame.of(o),r.reconfigure(o?n.gutter:[])]}))},[g?.state,g?.response,g?.path,g?.workspaceId,e,l,P]);let L=y.current?.state.doc.toString()??t,R=L.length<=m?L:L.slice(0,m),z=h(e),B=d(z);return(0,f.jsxs)(`div`,{className:`file-cm-wrap`,"data-file-text":e,"data-file-content":R,"data-file-content-truncated":L.length>m?`1`:`0`,"data-file-selection":M,"data-file-editor-ready":A?`1`:`0`,"data-file-blame-gutter":I?`1`:void 0,onMouseDown:()=>y.current?.focus(),children:[(0,f.jsx)(`div`,{className:`file-cm`,ref:v,"aria-label":`编辑 ${e}`}),!A&&(0,f.jsx)(`span`,{className:`file-cm-status`,"data-file-editor-loading":`1`,children:`⌛ 正在加载编辑器…`}),A&&!O&&(0,f.jsx)(`span`,{className:`file-cm-status`,"data-file-highlight-status":`plain`,children:`纯文本`}),A&&O&&B&&(0,f.jsx)(`span`,{className:`file-cm-status file-cm-status-lang`,"data-file-highlight-status":z,children:B})]})}export{v as CodeMirrorEditor};
@@ -1 +1 @@
1
- import{a as e,c as t,f as n,g as r,h as i,l as a,m as o,p as s,s as c,t as l}from"./dist-DBUqwiWG.js";import{d as u,o as d,r as f,t as p}from"./dist-BCNaDgNW.js";import{indentUnit as m,syntaxTree as h}from"./dist-Do52MRwm.js";var g=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=h(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(x(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function _(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function v(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=_(t)+_(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function y(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:v(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function b(e,t){return n=>{for(let t=h(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}function x(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var S=l.define();typeof navigator==`object`&&navigator.platform;var C=f.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`,cursor:`pointer`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),w=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},T=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(n){let r=n.mapPos(this.from,-1,t.TrackDel),i=n.mapPos(this.to,1,t.TrackDel);return r==null||i==null?null:new e(this.field,r,i)}},E=class e{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],r=[t],i=e.doc.lineAt(t),a=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=a,o=/^\t*/.exec(i)[0].length;for(let t=0;t<o;t++)n+=e.facet(m);r.push(t+n.length-o),i=n+i.slice(o)}n.push(i),t+=i.length+1}return{text:n,ranges:this.fieldPositions.map(e=>new T(e.field,r[e.line]+e.from,r[e.line]+e.to))}}static parse(t){let n=[],r=[],i=[],a;for(let e of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(e);){let t=a[1]?+a[1]:null,o=a[2]||a[3]||``,s=-1;t===0&&(t=1e9);let c=o.replace(/\\[{}]/g,e=>e[1]);for(let e=0;e<n.length;e++)(t==null?c&&n[e].name==c:n[e].seq==t)&&(s=e);if(s<0){let e=0;for(;e<n.length&&(t==null||n[e].seq!=null&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:c}),s=e;for(let e of i)e.field>=s&&e.field++}for(let e of i)if(e.line==r.length&&e.from>a.index){let t=a[2]?3+(a[1]||``).length:2;e.from-=t,e.to-=t}i.push(new w(s,r.length,a.index,a.index+c.length)),e=e.slice(0,a.index)+o+e.slice(a.index+a[0].length)}e=e.replace(/\\([{}])/g,(e,t,n)=>{for(let e of i)e.line==r.length&&e.from>n&&(e.from--,e.to--);return t}),r.push(e)}return new e(r,i)}},D=p.widget({widget:new class extends d{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),O=p.mark({class:`cm-snippetField`}),k=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=p.set(e.map(e=>(e.from==e.to?D:O).range(e.from,e.to)),!0)}map(t){let n=[];for(let e of this.ranges){let r=e.map(t);if(!r)return null;n.push(r)}return new e(n,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}},A=s.define({map(e,t){return e&&e.map(t)}}),j=s.define(),M=o.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(A))return n.value;if(n.is(j)&&e)return new k(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>f.decorations.from(e,e=>e?e.deco:p.none)});function N(t,n){return e.create(t.filter(e=>e.field==n).map(t=>e.range(t.from,t.to)))}function P(e){let t=E.parse(e);return(e,n,a,o)=>{let{text:c,ranges:l}=t.instantiate(e.state,a),{main:u}=e.state.selection,d={changes:{from:a,to:o==u.from?u.to:o,insert:i.of(c)},scrollIntoView:!0,annotations:n?[S.of(n),r.userEvent.of(`input.complete`)]:void 0};if(l.length&&(d.selection=N(l,0)),l.some(e=>e.field>0)){let t=new k(l,0),n=d.effects=[A.of(t)];e.state.field(M,!1)===void 0&&n.push(s.appendConfig.of([M,R,B,C]))}e.dispatch(e.state.update(d))}}function F(e){return({state:t,dispatch:n})=>{let r=t.field(M,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(t=>t.field==i+e);return n(t.update({selection:N(r.ranges,i),effects:A.of(a?null:new k(r.ranges,i)),scrollIntoView:!0})),!0}}var I=[{key:`Tab`,run:F(1),shift:F(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(M,!1)?(t(e.update({effects:A.of(null)})),!0):!1}],L=c.define({combine(e){return e.length?e[0]:I}}),R=a.highest(u.compute([L],e=>e.facet(L)));function z(e,t){return{...t,apply:P(e)}}var B=f.domEventHandlers({mousedown(e,t){let n=t.state.field(M,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(e=>e.from<=r&&e.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:N(n.ranges,i.field),effects:A.of(n.ranges.some(e=>e.field>i.field)?new k(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),V=new class extends n{};V.startSide=1,V.endSide=-1,typeof navigator==`object`&&navigator.userAgent;export{z as i,y as n,b as r,g as t};
1
+ import{a as e,c as t,f as n,g as r,h as i,l as a,m as o,p as s,s as c,t as l}from"./dist-Bk_pkBVH.js";import{d as u,o as d,r as f,t as p}from"./dist-CRxCwn-Z.js";import{indentUnit as m,syntaxTree as h}from"./dist-B1qLZVMK.js";var g=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=h(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(x(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function _(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function v(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=_(t)+_(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function y(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:v(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function b(e,t){return n=>{for(let t=h(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}function x(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var S=l.define();typeof navigator==`object`&&navigator.platform;var C=f.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`,cursor:`pointer`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),w=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},T=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(n){let r=n.mapPos(this.from,-1,t.TrackDel),i=n.mapPos(this.to,1,t.TrackDel);return r==null||i==null?null:new e(this.field,r,i)}},E=class e{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],r=[t],i=e.doc.lineAt(t),a=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=a,o=/^\t*/.exec(i)[0].length;for(let t=0;t<o;t++)n+=e.facet(m);r.push(t+n.length-o),i=n+i.slice(o)}n.push(i),t+=i.length+1}return{text:n,ranges:this.fieldPositions.map(e=>new T(e.field,r[e.line]+e.from,r[e.line]+e.to))}}static parse(t){let n=[],r=[],i=[],a;for(let e of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(e);){let t=a[1]?+a[1]:null,o=a[2]||a[3]||``,s=-1;t===0&&(t=1e9);let c=o.replace(/\\[{}]/g,e=>e[1]);for(let e=0;e<n.length;e++)(t==null?c&&n[e].name==c:n[e].seq==t)&&(s=e);if(s<0){let e=0;for(;e<n.length&&(t==null||n[e].seq!=null&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:c}),s=e;for(let e of i)e.field>=s&&e.field++}for(let e of i)if(e.line==r.length&&e.from>a.index){let t=a[2]?3+(a[1]||``).length:2;e.from-=t,e.to-=t}i.push(new w(s,r.length,a.index,a.index+c.length)),e=e.slice(0,a.index)+o+e.slice(a.index+a[0].length)}e=e.replace(/\\([{}])/g,(e,t,n)=>{for(let e of i)e.line==r.length&&e.from>n&&(e.from--,e.to--);return t}),r.push(e)}return new e(r,i)}},D=p.widget({widget:new class extends d{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),O=p.mark({class:`cm-snippetField`}),k=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=p.set(e.map(e=>(e.from==e.to?D:O).range(e.from,e.to)),!0)}map(t){let n=[];for(let e of this.ranges){let r=e.map(t);if(!r)return null;n.push(r)}return new e(n,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}},A=s.define({map(e,t){return e&&e.map(t)}}),j=s.define(),M=o.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(A))return n.value;if(n.is(j)&&e)return new k(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>f.decorations.from(e,e=>e?e.deco:p.none)});function N(t,n){return e.create(t.filter(e=>e.field==n).map(t=>e.range(t.from,t.to)))}function P(e){let t=E.parse(e);return(e,n,a,o)=>{let{text:c,ranges:l}=t.instantiate(e.state,a),{main:u}=e.state.selection,d={changes:{from:a,to:o==u.from?u.to:o,insert:i.of(c)},scrollIntoView:!0,annotations:n?[S.of(n),r.userEvent.of(`input.complete`)]:void 0};if(l.length&&(d.selection=N(l,0)),l.some(e=>e.field>0)){let t=new k(l,0),n=d.effects=[A.of(t)];e.state.field(M,!1)===void 0&&n.push(s.appendConfig.of([M,R,B,C]))}e.dispatch(e.state.update(d))}}function F(e){return({state:t,dispatch:n})=>{let r=t.field(M,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(t=>t.field==i+e);return n(t.update({selection:N(r.ranges,i),effects:A.of(a?null:new k(r.ranges,i)),scrollIntoView:!0})),!0}}var I=[{key:`Tab`,run:F(1),shift:F(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(M,!1)?(t(e.update({effects:A.of(null)})),!0):!1}],L=c.define({combine(e){return e.length?e[0]:I}}),R=a.highest(u.compute([L],e=>e.facet(L)));function z(e,t){return{...t,apply:P(e)}}var B=f.domEventHandlers({mousedown(e,t){let n=t.state.field(M,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(e=>e.from<=r&&e.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:N(n.ranges,i.field),effects:A.of(n.ranges.some(e=>e.field>i.field)?new k(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),V=new class extends n{};V.startSide=1,V.endSide=-1,typeof navigator==`object`&&navigator.userAgent;export{z as i,y as n,b as r,g as t};