@evandu/super-pi 0.1.142 → 0.1.144
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agents/super-pi-task/core.ts +55 -27
- package/agents/super-pi-task/index.ts +76 -4
- package/dist/.super-pi-check-inputs.json +2 -2
- package/dist/client/.super-pi-client-sources.json +7 -7
- package/dist/client/assets/{CodeMirrorEditor-iLUdQy9q.js → CodeMirrorEditor-DfQHX1Hy.js} +2 -2
- package/dist/client/assets/{dist-Bt8G7e7e.js → dist-B8oH6dsc.js} +1 -1
- package/dist/client/assets/{dist-DbLEngKN.js → dist-BCLhQXYY.js} +1 -1
- package/dist/client/assets/{dist-DBAoCOnn.js → dist-BEbEv2KM.js} +1 -1
- package/dist/client/assets/{dist-Dxq1s4j3.js → dist-BGBinEie.js} +1 -1
- package/dist/client/assets/{dist-CWBm3q4a.js → dist-BRjyQs_L.js} +1 -1
- package/dist/client/assets/{dist-JuLMNOUt.js → dist-BS-FBUKW.js} +1 -1
- package/dist/client/assets/{dist-Cfa_e2VZ.js → dist-BsMikSTM.js} +1 -1
- package/dist/client/assets/{dist-0dCNvYEE.js → dist-BuPimjY-.js} +1 -1
- package/dist/client/assets/{dist-rIYPNzbY.js → dist-C5BQsmB7.js} +1 -1
- package/dist/client/assets/{dist-B8FbKhnf.js → dist-CDtFD-PW.js} +1 -1
- package/dist/client/assets/{dist-ic-MopV2.js → dist-CgQ7zaWY.js} +1 -1
- package/dist/client/assets/{dist-F634gv7V.js → dist-Cu3B0JQX.js} +1 -1
- package/dist/client/assets/{dist-Bj2C-QqM.js → dist-Cw_KCDH9.js} +1 -1
- package/dist/client/assets/{dist-BA6EsWzo.js → dist-D7aAMRTb.js} +1 -1
- package/dist/client/assets/{dist-B4JqBNQI.js → dist-DKkMk3XX.js} +1 -1
- package/dist/client/assets/{dist-CoTJns5x.js → dist-DOvzruAQ.js} +1 -1
- package/dist/client/assets/{dist-Nt-BWmBB.js → dist-Dnru8_uX.js} +1 -1
- package/dist/client/assets/{dist-DHyWJ9kA.js → dist-ISoxXlmW.js} +1 -1
- package/dist/client/assets/{dist-DEUl3Yqk.js → dist-KQJCVwxy.js} +1 -1
- package/dist/client/assets/{dist-Dq6y_nK3.js → dist-LRNzDUVb.js} +1 -1
- package/dist/client/assets/{dist-CtCiGxne.js → dist-SzZEAk24.js} +1 -1
- package/dist/client/assets/{dist-Df9zcCXs.js → dist-qAUj_2Ue.js} +1 -1
- package/dist/client/assets/{index-CX5gWDve.js → index-BLWr70ej.js} +22 -22
- package/dist/client/assets/{index-DMhigTiY.css → index-Xaui0uUI.css} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/application/run-service.d.ts +15 -0
- package/dist/server/application/run-service.js +59 -1
- package/dist/server/application/session-orchestrator-service.d.ts +9 -1
- package/dist/server/application/session-orchestrator-service.js +79 -10
- package/dist/server/http-server.js +18 -11
- package/dist/server/runtime.js +7 -6
- package/dist/server/store.js +7 -1
- package/dist/server/task-tool.d.ts +4 -2
- package/dist/server/task-tool.js +6 -3
- package/dist/server/time-zone.d.ts +20 -0
- package/dist/server/time-zone.js +32 -0
- package/dist/server/types.d.ts +9 -0
- package/dist/server/workflow-engine.d.ts +11 -95
- package/dist/server/workflow-engine.js +122 -134
- package/dist/server/workflow.d.ts +73 -31
- package/dist/server/workflow.js +112 -30
- package/package.json +331 -325
|
@@ -41,6 +41,8 @@ export const TASK_ENDPOINT_ENV = "SUPER_PI_TASK_ENDPOINT";
|
|
|
41
41
|
export const TASK_EXEC_ENDPOINT_ENV = "SUPER_PI_EXEC_ENDPOINT";
|
|
42
42
|
export const TASK_ROSTER_ENV = "SUPER_PI_TASK_ROSTER";
|
|
43
43
|
export const TASK_CONVERSATION_ENV = "SUPER_PI_TASK_CONVERSATION";
|
|
44
|
+
/** The conversation that spawned this one. Empty means a top-level conversation. */
|
|
45
|
+
export const PARENT_CONVERSATION_ENV = "SUPER_PI_PARENT_CONVERSATION";
|
|
44
46
|
export const TASK_DEPTH_ENV = "SUPER_PI_TASK_DEPTH";
|
|
45
47
|
|
|
46
48
|
/** The independent background-command tool. NOT a sub-agent dispatch: a shell command run asynchronously. */
|
|
@@ -106,7 +108,7 @@ description: 用脚本清洗、转换、统计 Excel/CSV 数据
|
|
|
106
108
|
mode: primary
|
|
107
109
|
---
|
|
108
110
|
(正文从这里开始,写它的职责和工作方式。)保存后下一条消息即可使用;修改已有的自定义 Agent 就是编辑同一个目录里对应的 .md 文件。
|
|
109
|
-
- 用户要多个 agent 分工协作:单个子任务用 task 工具委托,有先后依赖的流程用 workflow
|
|
111
|
+
- 用户要多个 agent 分工协作:单个子任务用 task 工具委托,有先后依赖的流程用 workflow 工具编排;同一流程要按明确结论行反复执行时用 loop 节点,要对 primary 自己列出的一批同构对象逐项执行时用 foreach 节点,两者可以任意嵌套。需要拆分多条独立并行工作线、多会话持续跟踪管理、或用户要求创建多个会话并行时,用 session_spawn 创建兄弟会话,并用 session_status / session_dispatch / session_stop 监督管理。`;
|
|
110
112
|
|
|
111
113
|
/** The parameters, OpenCode's `tool/todo.ts:6-8` minus its schema wrapper. */
|
|
112
114
|
export type TodoParams = { todos: TodoEntry[] };
|
|
@@ -714,16 +716,19 @@ export async function executeTodo(
|
|
|
714
716
|
// timeline is on screen the whole way. See `src/server/workflow.ts` for the rules and
|
|
715
717
|
// `docs/AGENT_LOOP_DESIGN.md` for what this deliberately does not do.
|
|
716
718
|
//
|
|
717
|
-
// WHAT IT IS NOT
|
|
718
|
-
//
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
719
|
+
// WHAT IT IS NOT: an arbitrary graph, an expression language, a parallel runner, or a second orchestration
|
|
720
|
+
// authority. The three node kinds cover sequencing, bounded conclusion-driven repetition and explicit batches.
|
|
721
|
+
|
|
722
|
+
/** What the model declares. The server validates this untrusted recursive shape against the live roster. */
|
|
723
|
+
export type WorkflowParamsNode =
|
|
724
|
+
| { kind: "step"; agentId: string; label?: string; prompt: string }
|
|
725
|
+
| { kind: "loop"; until: string; max?: number; do: WorkflowParamsNode[] }
|
|
726
|
+
| { kind: "foreach"; items: string[]; do: WorkflowParamsNode[] };
|
|
723
727
|
export type WorkflowParams = {
|
|
724
728
|
summary?: string;
|
|
725
729
|
onFailure?: string;
|
|
726
730
|
steps?: { agentId?: string; label?: string; prompt?: string }[];
|
|
731
|
+
nodes?: WorkflowParamsNode[];
|
|
727
732
|
};
|
|
728
733
|
|
|
729
734
|
/**
|
|
@@ -739,23 +744,24 @@ export type WorkflowParams = {
|
|
|
739
744
|
* behaviour it will not see again until the end: `stop` is the default and is what a plan that failed has
|
|
740
745
|
* honestly earned, `skip` hands the next subagent a hole, and `retry` costs another whole subagent run.
|
|
741
746
|
*/
|
|
742
|
-
export const WORKFLOW_DESCRIPTION = `Run
|
|
747
|
+
export const WORKFLOW_DESCRIPTION = `Run a recursive plan of sub-agent steps, bounded loops and foreach iterations. The server executes the structure you write; every sub-agent remains a smart worker with no control-flow decision authority.
|
|
743
748
|
|
|
744
749
|
WHEN TO USE THIS, AND WHEN NOT:
|
|
745
|
-
- Two steps, or a chain you can hold in your head: use the task tool, twice. You see each answer before you write the next prompt
|
|
746
|
-
- Three or more steps
|
|
747
|
-
-
|
|
748
|
-
-
|
|
750
|
+
- Two steps, or a chain you can hold in your head: use the task tool, twice. You see each answer before you write the next prompt.
|
|
751
|
+
- Three or more dependent steps: use step nodes (or the legacy steps array). The server runs them in order and hands earlier output forward.
|
|
752
|
+
- Repeat the same one-or-more-node body until a written conclusion condition holds: use {"kind":"loop","until":"通过","max":8,"do":[...nodes]}. The body runs before each check, and max defaults to 8.
|
|
753
|
+
- Process a homogeneous batch once per entry: use {"kind":"foreach","items":["..."],"do":[...nodes]}. YOU, the primary agent, must supply the explicit items array after deciding what belongs in it. The server never discovers a list, and a foreach without items is refused.
|
|
754
|
+
- Independent work that should run in parallel: use several task calls instead; workflow nodes run sequentially.
|
|
755
|
+
- Arbitrary branches or an expression language: not supported. Use only step, loop and foreach nodes, nested as needed.
|
|
749
756
|
|
|
750
757
|
Usage notes:
|
|
751
|
-
1. This call BLOCKS until the whole plan finishes, and every step is a separate sub-agent process that takes minutes.
|
|
752
|
-
2. Steps run IN ORDER, one at a time. Each is a fresh subagent with a fresh context.
|
|
753
|
-
3.
|
|
754
|
-
4.
|
|
755
|
-
5.
|
|
756
|
-
6. onFailure controls
|
|
757
|
-
7. label is optional and is only
|
|
758
|
-
8. agentId must be one of the dispatchable sub-agent types listed below.`;
|
|
758
|
+
1. This call BLOCKS until the whole plan finishes, and every step is a separate sub-agent process that takes minutes.
|
|
759
|
+
2. Steps run IN ORDER, one at a time. Each is a fresh subagent with a fresh context and no authority to change the plan.
|
|
760
|
+
3. Earlier step output is prepended by default. {{previous}} selects only the nearest prior output and {{history}} selects all of it; either suppresses the automatic block.
|
|
761
|
+
4. Inside a loop body, {{last}} is the previous round's last node output (empty in round one). Inside foreach, {{item}} is the current primary-supplied item. These are plain string substitutions, not expressions.
|
|
762
|
+
5. loop.until is matched by the SERVER against the LAST LINE of this round's last node output. The comparison is an EXACT WHOLE-LINE match after trimming whitespace: "结论:通过" does NOT match until="通过". Missing output or no conclusion line means false, not an error. At most max rounds run.
|
|
763
|
+
6. onFailure controls a step that FAILS TO RUN: stop (default), skip, or retry:N. This is separate from the textual conclusion matched by until.
|
|
764
|
+
7. label is optional and is only shown to the user. agentId must be one of the dispatchable sub-agent types listed for the task tool.`;
|
|
759
765
|
|
|
760
766
|
/** What the extension knows about the workflow endpoint before it can call anything. */
|
|
761
767
|
export type WorkflowToolConfig = {
|
|
@@ -791,7 +797,9 @@ export function readWorkflowConfig(env: Record<string, string | undefined>): Wor
|
|
|
791
797
|
export function refuseWorkflow(config: WorkflowToolConfig, params: WorkflowParams): string | undefined {
|
|
792
798
|
if (!config.endpoint) return `The workflow tool is not available in this session: ${WORKFLOW_ENDPOINT_ENV} is not set, so there is no Super Pi server to run the plan. Use the task tool, or do the steps yourself.`;
|
|
793
799
|
if (!config.conversationId) return `The workflow tool is not available in this session: ${TASK_CONVERSATION_ENV} is not set. Use the task tool, or do the steps yourself.`;
|
|
794
|
-
if (!Array.isArray(params.steps)
|
|
800
|
+
if (!Array.isArray(params.steps) && !Array.isArray(params.nodes)) return "workflow requires a non-empty `steps` array or a recursive `nodes` array. For a single sub-agent, use the task tool instead.";
|
|
801
|
+
if (Array.isArray(params.steps) && !params.steps.length) return "workflow.steps was empty. For a single sub-agent, use the task tool instead.";
|
|
802
|
+
if (Array.isArray(params.nodes) && !params.nodes.length) return "workflow.nodes was empty. Add at least one step, loop or foreach node.";
|
|
795
803
|
return undefined;
|
|
796
804
|
}
|
|
797
805
|
|
|
@@ -881,6 +889,7 @@ export async function executeWorkflow(
|
|
|
881
889
|
summary: params.summary,
|
|
882
890
|
onFailure: params.onFailure,
|
|
883
891
|
steps: params.steps,
|
|
892
|
+
nodes: params.nodes,
|
|
884
893
|
capability: config.capability,
|
|
885
894
|
}),
|
|
886
895
|
...(deps.signal ? { signal: deps.signal } : {}),
|
|
@@ -1149,7 +1158,8 @@ WHEN NOT TO USE THIS:
|
|
|
1149
1158
|
Usage notes:
|
|
1150
1159
|
1. Spawning is ASYNCHRONOUS by default: it creates the conversation, enqueues the initial task, and returns the new conversationId immediately. The sibling session runs in the background.
|
|
1151
1160
|
2. The initial task should provide clear context and goals since the new session starts with a fresh conversation history.
|
|
1152
|
-
3. Use session_status with the returned conversationId to check progress, or session_dispatch to send further messages
|
|
1161
|
+
3. Use session_status with the returned conversationId to check progress, or session_dispatch to send further messages.
|
|
1162
|
+
4. The new session reports completion to its DIRECT parent automatically. 'parentConversationId' optionally selects that parent; by default it is the calling session.`;
|
|
1153
1163
|
|
|
1154
1164
|
/** Model-facing description for session_status. */
|
|
1155
1165
|
export const SESSION_STATUS_DESCRIPTION = `Inspect the progress, run state, and latest activity of sibling conversations created by the orchestrator.
|
|
@@ -1161,8 +1171,8 @@ WHEN TO USE THIS:
|
|
|
1161
1171
|
|
|
1162
1172
|
Usage notes:
|
|
1163
1173
|
1. When 'conversationId' is provided: returns a compact summary for that specific session, including its run status ('idle', 'running', 'waiting', 'stopped', 'failed'), messageCount, turnCount, lastAssistantSnippet, lastUserSnippet, activeTool, and error (if any).
|
|
1164
|
-
2. When 'conversationId' is omitted: returns a summary list of
|
|
1165
|
-
3.
|
|
1174
|
+
2. When 'conversationId' is omitted: returns a summary list of sibling conversations whose direct parent is 'parentConversationId' (the calling session by default).
|
|
1175
|
+
3. By default it never returns full transcripts; concise summaries keep your context window lean. Set 'includeOutput' with a conversationId to read the final output from its result file, capped to the last 64Ki characters with an explicit truncation notice.`;
|
|
1166
1176
|
|
|
1167
1177
|
/** Model-facing description for session_dispatch. */
|
|
1168
1178
|
export const SESSION_DISPATCH_DESCRIPTION = `Send a message, follow-up instructions, or steering guidance to an existing sibling conversation.
|
|
@@ -1211,11 +1221,15 @@ export type OrchestratorSessionSummary = {
|
|
|
1211
1221
|
updatedAt: string;
|
|
1212
1222
|
createdAt?: number;
|
|
1213
1223
|
lastProgress?: string;
|
|
1224
|
+
output?: string;
|
|
1225
|
+
outputPath?: string;
|
|
1226
|
+
outputTruncated?: boolean;
|
|
1214
1227
|
};
|
|
1215
1228
|
|
|
1216
1229
|
export type OrchestratorToolConfig = {
|
|
1217
1230
|
endpoint: string;
|
|
1218
1231
|
conversationId: string;
|
|
1232
|
+
parentConversationId?: string;
|
|
1219
1233
|
token?: string;
|
|
1220
1234
|
capability?: string;
|
|
1221
1235
|
};
|
|
@@ -1224,9 +1238,11 @@ export type OrchestratorToolConfig = {
|
|
|
1224
1238
|
export function readOrchestratorConfig(env: Record<string, string | undefined>): OrchestratorToolConfig {
|
|
1225
1239
|
const token = env.SUPER_PI_ACCESS_TOKEN;
|
|
1226
1240
|
const capability = env[TASK_CAPABILITY_ENV];
|
|
1241
|
+
const parentConversationId = env[PARENT_CONVERSATION_ENV];
|
|
1227
1242
|
return {
|
|
1228
1243
|
endpoint: env[ORCHESTRATOR_ENDPOINT_ENV] ?? "",
|
|
1229
1244
|
conversationId: env[TASK_CONVERSATION_ENV] ?? "",
|
|
1245
|
+
...(parentConversationId ? { parentConversationId } : {}),
|
|
1230
1246
|
...(token ? { token } : {}),
|
|
1231
1247
|
...(capability ? { capability } : {}),
|
|
1232
1248
|
};
|
|
@@ -1234,6 +1250,7 @@ export function readOrchestratorConfig(env: Record<string, string | undefined>):
|
|
|
1234
1250
|
|
|
1235
1251
|
export type SessionSpawnParams = {
|
|
1236
1252
|
task: string;
|
|
1253
|
+
parentConversationId?: string;
|
|
1237
1254
|
title?: string;
|
|
1238
1255
|
agentId?: string;
|
|
1239
1256
|
thinkingLevel?: string;
|
|
@@ -1242,6 +1259,8 @@ export type SessionSpawnParams = {
|
|
|
1242
1259
|
|
|
1243
1260
|
export type SessionStatusParams = {
|
|
1244
1261
|
conversationId?: string;
|
|
1262
|
+
parentConversationId?: string;
|
|
1263
|
+
includeOutput?: boolean;
|
|
1245
1264
|
};
|
|
1246
1265
|
|
|
1247
1266
|
export type SessionDispatchParams = {
|
|
@@ -1290,7 +1309,8 @@ export async function executeSessionSpawn(
|
|
|
1290
1309
|
agentId: params.agentId?.trim() || undefined,
|
|
1291
1310
|
thinkingLevel: params.thinkingLevel?.trim() || undefined,
|
|
1292
1311
|
wait: Boolean(params.wait),
|
|
1293
|
-
|
|
1312
|
+
callerConversationId: config.conversationId || undefined,
|
|
1313
|
+
parentConversationId: params.parentConversationId?.trim() || config.conversationId || undefined,
|
|
1294
1314
|
capability: config.capability,
|
|
1295
1315
|
}),
|
|
1296
1316
|
...(deps.signal ? { signal: deps.signal } : {}),
|
|
@@ -1350,7 +1370,9 @@ export async function executeSessionStatus(
|
|
|
1350
1370
|
body: JSON.stringify({
|
|
1351
1371
|
action: targetId ? "status" : "list",
|
|
1352
1372
|
conversationId: targetId || undefined,
|
|
1353
|
-
|
|
1373
|
+
includeOutput: Boolean(params.includeOutput),
|
|
1374
|
+
callerConversationId: config.conversationId || undefined,
|
|
1375
|
+
parentConversationId: params.parentConversationId?.trim() || config.conversationId || undefined,
|
|
1354
1376
|
capability: config.capability,
|
|
1355
1377
|
}),
|
|
1356
1378
|
...(deps.signal ? { signal: deps.signal } : {}),
|
|
@@ -1380,6 +1402,11 @@ export async function executeSessionStatus(
|
|
|
1380
1402
|
...(s.error ? [`- Error: ${s.error}`] : []),
|
|
1381
1403
|
...(s.lastAssistantSnippet ? [`- Latest Assistant Progress: "${s.lastAssistantSnippet}"`] : []),
|
|
1382
1404
|
...(s.lastUserSnippet ? [`- Latest User/Prompt Snippet: "${s.lastUserSnippet}"`] : []),
|
|
1405
|
+
...(s.output !== undefined ? [
|
|
1406
|
+
`- Output File: ${s.outputPath ?? "unavailable"}`,
|
|
1407
|
+
...(s.outputTruncated ? ["- Output was truncated to the last 64Ki characters; read the output file for the complete result."] : []),
|
|
1408
|
+
`<session_output>\n${s.output}\n</session_output>`,
|
|
1409
|
+
] : []),
|
|
1383
1410
|
];
|
|
1384
1411
|
return text(lines.join("\n"));
|
|
1385
1412
|
}
|
|
@@ -1436,6 +1463,7 @@ export async function executeSessionDispatch(
|
|
|
1436
1463
|
conversationId: params.conversationId.trim(),
|
|
1437
1464
|
content: params.content.trim(),
|
|
1438
1465
|
wait: Boolean(params.wait),
|
|
1466
|
+
callerConversationId: config.conversationId || undefined,
|
|
1439
1467
|
parentConversationId: config.conversationId || undefined,
|
|
1440
1468
|
capability: config.capability,
|
|
1441
1469
|
}),
|
|
@@ -1492,6 +1520,7 @@ export async function executeSessionStop(
|
|
|
1492
1520
|
conversationId: params.conversationId.trim(),
|
|
1493
1521
|
mode: params.mode ?? "all",
|
|
1494
1522
|
messageId: params.messageId?.trim() || undefined,
|
|
1523
|
+
callerConversationId: config.conversationId || undefined,
|
|
1495
1524
|
parentConversationId: config.conversationId || undefined,
|
|
1496
1525
|
capability: config.capability,
|
|
1497
1526
|
}),
|
|
@@ -1515,4 +1544,3 @@ export async function executeSessionStop(
|
|
|
1515
1544
|
return text(`session_stop network error: ${error instanceof Error ? error.message : String(error)}`, true);
|
|
1516
1545
|
}
|
|
1517
1546
|
}
|
|
1518
|
-
|
|
@@ -132,14 +132,77 @@ type ExtensionToolDefinition = {
|
|
|
132
132
|
* enum here would be a second list that could disagree with `parseFailurePolicy`, and the message a model
|
|
133
133
|
* gets for a bad value is better written by the side that knows the real options.
|
|
134
134
|
*/
|
|
135
|
+
/**
|
|
136
|
+
* THE RECURSIVE NODE SCHEMA.
|
|
137
|
+
*
|
|
138
|
+
* WHY IT IS WRITTEN AS RAW JSON SCHEMA RATHER THAN `Type.Recursive`.
|
|
139
|
+
*
|
|
140
|
+
* Pi hands extensions its OWN typebox as a VIRTUAL MODULE - `virtual-modules.ts` maps both
|
|
141
|
+
* `typebox` and `@sinclair/typebox` to the bundled `typebox` package, which on this host is
|
|
142
|
+
* **1.3.27**. That version has `Type.Unsafe`, `Type.Ref` and `Type.Any`, but it does NOT have
|
|
143
|
+
* `Type.Recursive`: the function arrived in typebox 0.34 and the 1.x line dropped it.
|
|
144
|
+
*
|
|
145
|
+
* Using it anyway fails at LOAD time, not at call time, and it fails for everything:
|
|
146
|
+
*
|
|
147
|
+
* Failed to load extension ".../agents/super-pi-task/index.ts":
|
|
148
|
+
* Failed to load extension: _typebox.Type.Recursive is not a function
|
|
149
|
+
*
|
|
150
|
+
* An extension that does not load takes Pi's whole extension host with it - every Super Pi tool
|
|
151
|
+
* disappears, not just this one. So the schema is written as the JSON Schema it actually is,
|
|
152
|
+
* with a `$ref` back to its own `$id`, which is what `Type.Recursive` would have produced anyway.
|
|
153
|
+
*
|
|
154
|
+
* `$defs` is not used: the `$ref` is relative to the root of THIS schema, and the root carries the
|
|
155
|
+
* `$id` the reference names.
|
|
156
|
+
*/
|
|
157
|
+
const WorkflowNodeParameters = Type.Unsafe({
|
|
158
|
+
$id: "WorkflowNode",
|
|
159
|
+
type: "object",
|
|
160
|
+
required: ["kind"],
|
|
161
|
+
properties: {
|
|
162
|
+
kind: { type: "string", enum: ["step", "loop", "foreach"] },
|
|
163
|
+
},
|
|
164
|
+
anyOf: [
|
|
165
|
+
{
|
|
166
|
+
type: "object",
|
|
167
|
+
required: ["kind", "agentId", "prompt"],
|
|
168
|
+
properties: {
|
|
169
|
+
kind: { const: "step" },
|
|
170
|
+
agentId: { type: "string", description: "The dispatchable sub-agent type to run, e.g. scout" },
|
|
171
|
+
label: { type: "string", description: "3-4 words saying what this step is FOR, shown to the user only" },
|
|
172
|
+
prompt: { type: "string", description: "The instruction for this step. Supports {{item}}, {{last}}, {{previous}} and {{history}} substitutions." },
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
type: "object",
|
|
177
|
+
required: ["kind", "until", "do"],
|
|
178
|
+
properties: {
|
|
179
|
+
kind: { const: "loop" },
|
|
180
|
+
until: { type: "string", description: "Exact conclusion line to match after trimming the final output line, e.g. 通过" },
|
|
181
|
+
max: { type: "integer", minimum: 1, maximum: 100, description: "Maximum rounds; defaults to 8" },
|
|
182
|
+
do: { type: "array", minItems: 1, items: { $ref: "WorkflowNode" }, description: "One or more nodes to rerun before each until check" },
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
type: "object",
|
|
187
|
+
required: ["kind", "items", "do"],
|
|
188
|
+
properties: {
|
|
189
|
+
kind: { const: "foreach" },
|
|
190
|
+
items: { type: "array", minItems: 1, items: { type: "string" }, description: "Explicit list supplied by the primary agent; the server never discovers it" },
|
|
191
|
+
do: { type: "array", minItems: 1, items: { $ref: "WorkflowNode" }, description: "One or more nodes to run once per item; prompts may use {{item}}" },
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
});
|
|
196
|
+
|
|
135
197
|
const WorkflowParameters = Type.Object({
|
|
136
198
|
summary: Type.String({ description: "One line saying what this whole plan is for, shown to the user above the timeline" }),
|
|
137
199
|
onFailure: Type.Optional(Type.String({ description: "What to do when a step FAILS TO RUN: stop (default), skip, retry:1, retry:2 or retry:3" })),
|
|
138
|
-
steps: Type.Array(Type.Object({
|
|
200
|
+
steps: Type.Optional(Type.Array(Type.Object({
|
|
139
201
|
agentId: Type.String({ description: "The dispatchable sub-agent type to run, e.g. scout" }),
|
|
140
202
|
label: Type.Optional(Type.String({ description: "3-4 words saying what this step is FOR, shown to the user only" })),
|
|
141
203
|
prompt: Type.String({ description: "The instruction for THIS step alone. Earlier steps' output is added for you." }),
|
|
142
|
-
}), { minItems: 1, maxItems: 8, description: "
|
|
204
|
+
}), { minItems: 1, maxItems: 8, description: "Legacy flat steps, equivalent to step nodes" })),
|
|
205
|
+
nodes: Type.Optional(Type.Array(WorkflowNodeParameters, { minItems: 1, description: "Recursive step/loop/foreach plan; use this OR legacy steps, not both" })),
|
|
143
206
|
});
|
|
144
207
|
|
|
145
208
|
type ExtensionApi = { registerTool(tool: ExtensionToolDefinition): void; on(eventName: string, handler: (event: any) => unknown): void };
|
|
@@ -301,7 +364,7 @@ const extension = (pi: ExtensionApi): void => {
|
|
|
301
364
|
name: WORKFLOW_TOOL_NAME,
|
|
302
365
|
label: "Workflow",
|
|
303
366
|
description: WORKFLOW_DESCRIPTION,
|
|
304
|
-
promptSnippet: "run
|
|
367
|
+
promptSnippet: "run recursive sub-agent steps, bounded loops and explicit foreach batches",
|
|
305
368
|
parameters: WorkflowParameters,
|
|
306
369
|
execute: async (_toolCallId, params, signal) =>
|
|
307
370
|
await executeWorkflow(params as WorkflowParams, workflowConfig, { signal: signal ?? undefined }),
|
|
@@ -386,6 +449,9 @@ const extension = (pi: ExtensionApi): void => {
|
|
|
386
449
|
task: Type.String({
|
|
387
450
|
description: "The high-level task or instructions to be performed by the new sibling session. This is sent as the initial prompt.",
|
|
388
451
|
}),
|
|
452
|
+
parentConversationId: Type.Optional(Type.String({
|
|
453
|
+
description: "Optional explicit parent conversation. Defaults to the calling session; completion is reported to this direct parent.",
|
|
454
|
+
})),
|
|
389
455
|
title: Type.Optional(Type.String({
|
|
390
456
|
description: "An optional title for the new sibling conversation in the sidebar. If omitted, derived from task.",
|
|
391
457
|
})),
|
|
@@ -402,7 +468,13 @@ const extension = (pi: ExtensionApi): void => {
|
|
|
402
468
|
|
|
403
469
|
const SessionStatusParameters = Type.Object({
|
|
404
470
|
conversationId: Type.Optional(Type.String({
|
|
405
|
-
description: "The ID of the sibling conversation to inspect. Omit to list
|
|
471
|
+
description: "The ID of the sibling conversation to inspect. Omit to list sibling conversations.",
|
|
472
|
+
})),
|
|
473
|
+
parentConversationId: Type.Optional(Type.String({
|
|
474
|
+
description: "When listing, only return sessions whose direct parent has this ID. Defaults to the calling session.",
|
|
475
|
+
})),
|
|
476
|
+
includeOutput: Type.Optional(Type.Boolean({
|
|
477
|
+
description: "For a single session, include its final output from the result file, capped to the last 64Ki characters with an explicit truncation notice.",
|
|
406
478
|
})),
|
|
407
479
|
});
|
|
408
480
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"hash": "
|
|
2
|
+
"hash": "7552fc27e94bbca33b0ca2c3960f45b6b4001a0eed4db31ed95fdc79b893e476",
|
|
3
3
|
"files": {
|
|
4
|
-
"src/client/App.tsx": "
|
|
4
|
+
"src/client/App.tsx": "6dfe15b15c936b215bda0f8b1f177beccd4dcf2533e2459eb133dded20e4f4f1",
|
|
5
5
|
"src/client/CodeMirrorEditor.tsx": "b6b6479effa1482eda710f04a26f3af843515526e129ca5bc70692cca9074b09",
|
|
6
6
|
"src/client/ErrorBoundary.tsx": "d16376f9f6c7cc1fab8590c65a66438127642f7d6bb8023cec53d8a6cc9f3964",
|
|
7
7
|
"src/client/FeishuPanel.tsx": "52f116eba265bfde683338f5893107ad5559fd2f7d4a9e0df935507a46862a3b",
|
|
@@ -12,11 +12,11 @@
|
|
|
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": "
|
|
15
|
+
"src/client/ScheduledTasksPanel.tsx": "83a97794ed99b25a3175ed31ea3fb096976311566b03ddcc975685378d78a217",
|
|
16
16
|
"src/client/SlashCommandMenu.tsx": "69cd0a9d5e35f41f703e91a845e5bd750c952d2957be03b5528e156e60bf6ecb",
|
|
17
17
|
"src/client/Tabs.tsx": "53323a198c0948887cb0cd018284ecd5c9b36025364484a91426f8e1e2198000",
|
|
18
18
|
"src/client/TerminalPanel.tsx": "6a8dbb0e0806ccfef6fd67ae16f580177dca9a7a8943fd5b801da555e424ad72",
|
|
19
|
-
"src/client/WorkflowCard.tsx": "
|
|
19
|
+
"src/client/WorkflowCard.tsx": "8ce5458537a3b02dcbb9bbb4c7afacb07e0f41857ed250aa4cde0cbc8d4bde6c",
|
|
20
20
|
"src/client/editor-blame.ts": "db504141cf6f8beb5ce020e9b4016b219ace817cf78b1d71cd98d5862ca2b985",
|
|
21
21
|
"src/client/editor-languages.ts": "d5319cfd9b9f3b07c2599ba64ec49a9038304d09fa1702302f3b2b97493d0a69",
|
|
22
22
|
"src/client/errors.ts": "e2e3b417a02eca0870237f5f502041a06a91a56d3d508161b1afca4dd6101889",
|
|
@@ -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": "
|
|
30
|
+
"src/client/styles.css": "6495955378304ce92b58668080ac16625bd643044083a1b460dc4df664b1f172",
|
|
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": "
|
|
35
|
+
"src/client/types.ts": "24fb82b292b852f3fedc166a5fcf710724f9f29ebbda5d1abe04c8158bdcef6a",
|
|
36
36
|
"src/client/vite-env.d.ts": "65996936fbb042915f7b74a200fcdde7e410f32a669b1ab9597cfaa4b0faddb5"
|
|
37
37
|
},
|
|
38
|
-
"recordedAt": "2026-10-
|
|
38
|
+
"recordedAt": "2026-10-30T07:07:18.951Z"
|
|
39
39
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-
|
|
2
|
-
import{a as e,i as t,n,r,s as i,t as a}from"./index-CX5gWDve.js";var o=i(e(),1);async function s(e,t){let[{StreamLanguage:n},i]=await Promise.all([r(()=>import(`./dist-ic-MopV2.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-B4JqBNQI.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cc:()=>r(()=>import(`./dist-B4JqBNQI.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cxx:()=>r(()=>import(`./dist-B4JqBNQI.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hpp:()=>r(()=>import(`./dist-B4JqBNQI.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hh:()=>r(()=>import(`./dist-B4JqBNQI.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hxx:()=>r(()=>import(`./dist-B4JqBNQI.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),c:()=>r(()=>import(`./dist-B4JqBNQI.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),h:()=>r(()=>import(`./dist-B4JqBNQI.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cu:()=>r(()=>import(`./dist-B4JqBNQI.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cuh:()=>r(()=>import(`./dist-B4JqBNQI.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),js:()=>r(()=>import(`./dist-Cfa_e2VZ.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),jsx:()=>r(()=>import(`./dist-Cfa_e2VZ.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-Cfa_e2VZ.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),cjs:()=>r(()=>import(`./dist-Cfa_e2VZ.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),ts:()=>r(()=>import(`./dist-Cfa_e2VZ.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-Cfa_e2VZ.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-Cfa_e2VZ.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-Cfa_e2VZ.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-Dxq1s4j3.js`).then(e=>e.python()),__vite__mapDeps([10,5,2,3,0,1,4,7,9])),pyi:()=>r(()=>import(`./dist-Dxq1s4j3.js`).then(e=>e.python()),__vite__mapDeps([10,5,2,3,0,1,4,7,9])),java:()=>r(()=>import(`./dist-DEUl3Yqk.js`).then(e=>e.java()),__vite__mapDeps([11,5,2,3,0,1,4,7])),php:()=>r(()=>import(`./dist-DbLEngKN.js`).then(e=>e.php()),__vite__mapDeps([12,5,2,3,0,1,4,7,13,14,8,9])),sql:()=>r(()=>import(`./dist-B8FbKhnf.js`).then(e=>e.sql()),__vite__mapDeps([15,5,2,3,0,1,4,7,9])),yaml:()=>r(()=>import(`./dist-Bj2C-QqM.js`).then(e=>e.yaml()),__vite__mapDeps([16,5,2,3,0,1,4,7])),yml:()=>r(()=>import(`./dist-Bj2C-QqM.js`).then(e=>e.yaml()),__vite__mapDeps([16,5,2,3,0,1,4,7])),xml:()=>r(()=>import(`./dist-F634gv7V.js`).then(e=>e.xml()),__vite__mapDeps([17,1,2,3,4,5,0,7])),json:()=>r(()=>import(`./dist-CWBm3q4a.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),jsonc:()=>r(()=>import(`./dist-CWBm3q4a.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),json5:()=>r(()=>import(`./dist-CWBm3q4a.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),html:()=>r(()=>import(`./dist-JuLMNOUt.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),htm:()=>r(()=>import(`./dist-JuLMNOUt.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),vue:()=>r(()=>import(`./dist-JuLMNOUt.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),svelte:()=>r(()=>import(`./dist-JuLMNOUt.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),css:()=>r(()=>import(`./dist-Df9zcCXs.js`).then(e=>e.r).then(e=>e.css()),__vite__mapDeps([14,2,3,5,0,1,4,7])),md:()=>r(()=>import(`./dist-rIYPNzbY.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),markdown:()=>r(()=>import(`./dist-rIYPNzbY.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),mdx:()=>r(()=>import(`./dist-rIYPNzbY.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),rs:()=>r(()=>import(`./dist-CoTJns5x.js`).then(e=>e.rust()),__vite__mapDeps([20,5,2,3,0,1,4,7])),go:()=>r(()=>import(`./dist-DHyWJ9kA.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-Nt-BWmBB.js`).then(e=>e.x),__vite__mapDeps([1,2,3])),r(()=>import(`./dist-CtCiGxne.js`).then(e=>e.s),__vite__mapDeps([4,2,3,1])),r(()=>import(`./dist-0dCNvYEE.js`),__vite__mapDeps([22,1,2,3,4,5,0])),r(()=>import(`./dist-DBAoCOnn.js`),__vite__mapDeps([23,1,2,3,4])),r(()=>import(`./dist-ic-MopV2.js`),__vite__mapDeps([0,1,2,3,4,5])),r(()=>import(`./dist-Dq6y_nK3.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-CgQ7zaWY.js","assets/dist-Dnru8_uX.js","assets/index-BLWr70ej.js","assets/index-Xaui0uUI.css","assets/dist-SzZEAk24.js","assets/dist-LRNzDUVb.js","assets/dist-DKkMk3XX.js","assets/dist-D7aAMRTb.js","assets/dist-BsMikSTM.js","assets/dist-B8oH6dsc.js","assets/dist-BGBinEie.js","assets/dist-KQJCVwxy.js","assets/dist-BCLhQXYY.js","assets/dist-BS-FBUKW.js","assets/dist-qAUj_2Ue.js","assets/dist-CDtFD-PW.js","assets/dist-Cw_KCDH9.js","assets/dist-Cu3B0JQX.js","assets/dist-BRjyQs_L.js","assets/dist-C5BQsmB7.js","assets/dist-DOvzruAQ.js","assets/dist-ISoxXlmW.js","assets/dist-BuPimjY-.js","assets/dist-BEbEv2KM.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e,i as t,n,r,s as i,t as a}from"./index-BLWr70ej.js";var o=i(e(),1);async function s(e,t){let[{StreamLanguage:n},i]=await Promise.all([r(()=>import(`./dist-CgQ7zaWY.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-DKkMk3XX.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cc:()=>r(()=>import(`./dist-DKkMk3XX.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cxx:()=>r(()=>import(`./dist-DKkMk3XX.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hpp:()=>r(()=>import(`./dist-DKkMk3XX.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hh:()=>r(()=>import(`./dist-DKkMk3XX.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hxx:()=>r(()=>import(`./dist-DKkMk3XX.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),c:()=>r(()=>import(`./dist-DKkMk3XX.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),h:()=>r(()=>import(`./dist-DKkMk3XX.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cu:()=>r(()=>import(`./dist-DKkMk3XX.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cuh:()=>r(()=>import(`./dist-DKkMk3XX.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),js:()=>r(()=>import(`./dist-BsMikSTM.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),jsx:()=>r(()=>import(`./dist-BsMikSTM.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-BsMikSTM.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),cjs:()=>r(()=>import(`./dist-BsMikSTM.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),ts:()=>r(()=>import(`./dist-BsMikSTM.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-BsMikSTM.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-BsMikSTM.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-BsMikSTM.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-BGBinEie.js`).then(e=>e.python()),__vite__mapDeps([10,5,2,3,0,1,4,7,9])),pyi:()=>r(()=>import(`./dist-BGBinEie.js`).then(e=>e.python()),__vite__mapDeps([10,5,2,3,0,1,4,7,9])),java:()=>r(()=>import(`./dist-KQJCVwxy.js`).then(e=>e.java()),__vite__mapDeps([11,5,2,3,0,1,4,7])),php:()=>r(()=>import(`./dist-BCLhQXYY.js`).then(e=>e.php()),__vite__mapDeps([12,5,2,3,0,1,4,7,13,14,8,9])),sql:()=>r(()=>import(`./dist-CDtFD-PW.js`).then(e=>e.sql()),__vite__mapDeps([15,5,2,3,0,1,4,7,9])),yaml:()=>r(()=>import(`./dist-Cw_KCDH9.js`).then(e=>e.yaml()),__vite__mapDeps([16,5,2,3,0,1,4,7])),yml:()=>r(()=>import(`./dist-Cw_KCDH9.js`).then(e=>e.yaml()),__vite__mapDeps([16,5,2,3,0,1,4,7])),xml:()=>r(()=>import(`./dist-Cu3B0JQX.js`).then(e=>e.xml()),__vite__mapDeps([17,1,2,3,4,5,0,7])),json:()=>r(()=>import(`./dist-BRjyQs_L.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),jsonc:()=>r(()=>import(`./dist-BRjyQs_L.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),json5:()=>r(()=>import(`./dist-BRjyQs_L.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),html:()=>r(()=>import(`./dist-BS-FBUKW.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),htm:()=>r(()=>import(`./dist-BS-FBUKW.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),vue:()=>r(()=>import(`./dist-BS-FBUKW.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),svelte:()=>r(()=>import(`./dist-BS-FBUKW.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),css:()=>r(()=>import(`./dist-qAUj_2Ue.js`).then(e=>e.r).then(e=>e.css()),__vite__mapDeps([14,2,3,5,0,1,4,7])),md:()=>r(()=>import(`./dist-C5BQsmB7.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),markdown:()=>r(()=>import(`./dist-C5BQsmB7.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),mdx:()=>r(()=>import(`./dist-C5BQsmB7.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),rs:()=>r(()=>import(`./dist-DOvzruAQ.js`).then(e=>e.rust()),__vite__mapDeps([20,5,2,3,0,1,4,7])),go:()=>r(()=>import(`./dist-ISoxXlmW.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-Dnru8_uX.js`).then(e=>e.x),__vite__mapDeps([1,2,3])),r(()=>import(`./dist-SzZEAk24.js`).then(e=>e.s),__vite__mapDeps([4,2,3,1])),r(()=>import(`./dist-BuPimjY-.js`),__vite__mapDeps([22,1,2,3,4,5,0])),r(()=>import(`./dist-BEbEv2KM.js`),__vite__mapDeps([23,1,2,3,4])),r(()=>import(`./dist-CgQ7zaWY.js`),__vite__mapDeps([0,1,2,3,4,5])),r(()=>import(`./dist-LRNzDUVb.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-
|
|
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-Dnru8_uX.js";import{d as u,o as d,r as f,t as p}from"./dist-SzZEAk24.js";import{indentUnit as m,syntaxTree as h}from"./dist-CgQ7zaWY.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};
|