@x-code-cli/core 0.1.11 → 0.2.1

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 (115) hide show
  1. package/dist/agent/api-errors.d.ts.map +1 -1
  2. package/dist/agent/api-errors.js +18 -0
  3. package/dist/agent/api-errors.js.map +1 -1
  4. package/dist/agent/diff.d.ts +35 -0
  5. package/dist/agent/diff.d.ts.map +1 -0
  6. package/dist/agent/diff.js +83 -0
  7. package/dist/agent/diff.js.map +1 -0
  8. package/dist/agent/loop-state.d.ts +45 -3
  9. package/dist/agent/loop-state.d.ts.map +1 -1
  10. package/dist/agent/loop-state.js +24 -3
  11. package/dist/agent/loop-state.js.map +1 -1
  12. package/dist/agent/loop.d.ts +10 -6
  13. package/dist/agent/loop.d.ts.map +1 -1
  14. package/dist/agent/loop.js +212 -30
  15. package/dist/agent/loop.js.map +1 -1
  16. package/dist/agent/plan-storage.d.ts +55 -0
  17. package/dist/agent/plan-storage.d.ts.map +1 -0
  18. package/dist/agent/plan-storage.js +156 -0
  19. package/dist/agent/plan-storage.js.map +1 -0
  20. package/dist/agent/session-store.d.ts +114 -0
  21. package/dist/agent/session-store.d.ts.map +1 -0
  22. package/dist/agent/session-store.js +415 -0
  23. package/dist/agent/session-store.js.map +1 -0
  24. package/dist/agent/sub-agents/built-in.d.ts +3 -0
  25. package/dist/agent/sub-agents/built-in.d.ts.map +1 -0
  26. package/dist/agent/sub-agents/built-in.js +98 -0
  27. package/dist/agent/sub-agents/built-in.js.map +1 -0
  28. package/dist/agent/sub-agents/index.d.ts +7 -0
  29. package/dist/agent/sub-agents/index.d.ts.map +1 -0
  30. package/dist/agent/sub-agents/index.js +5 -0
  31. package/dist/agent/sub-agents/index.js.map +1 -0
  32. package/dist/agent/sub-agents/loader.d.ts +5 -0
  33. package/dist/agent/sub-agents/loader.d.ts.map +1 -0
  34. package/dist/agent/sub-agents/loader.js +117 -0
  35. package/dist/agent/sub-agents/loader.js.map +1 -0
  36. package/dist/agent/sub-agents/registry.d.ts +14 -0
  37. package/dist/agent/sub-agents/registry.d.ts.map +1 -0
  38. package/dist/agent/sub-agents/registry.js +37 -0
  39. package/dist/agent/sub-agents/registry.js.map +1 -0
  40. package/dist/agent/sub-agents/runner.d.ts +26 -0
  41. package/dist/agent/sub-agents/runner.d.ts.map +1 -0
  42. package/dist/agent/sub-agents/runner.js +287 -0
  43. package/dist/agent/sub-agents/runner.js.map +1 -0
  44. package/dist/agent/sub-agents/types.d.ts +63 -0
  45. package/dist/agent/sub-agents/types.d.ts.map +1 -0
  46. package/dist/agent/sub-agents/types.js +2 -0
  47. package/dist/agent/sub-agents/types.js.map +1 -0
  48. package/dist/agent/system-prompt.d.ts +15 -0
  49. package/dist/agent/system-prompt.d.ts.map +1 -1
  50. package/dist/agent/system-prompt.js +161 -0
  51. package/dist/agent/system-prompt.js.map +1 -1
  52. package/dist/agent/tool-execution.d.ts +4 -3
  53. package/dist/agent/tool-execution.d.ts.map +1 -1
  54. package/dist/agent/tool-execution.js +324 -14
  55. package/dist/agent/tool-execution.js.map +1 -1
  56. package/dist/agent/tool-result-sanitize.d.ts +12 -0
  57. package/dist/agent/tool-result-sanitize.d.ts.map +1 -1
  58. package/dist/agent/tool-result-sanitize.js +70 -0
  59. package/dist/agent/tool-result-sanitize.js.map +1 -1
  60. package/dist/config/index.d.ts +6 -0
  61. package/dist/config/index.d.ts.map +1 -1
  62. package/dist/config/index.js.map +1 -1
  63. package/dist/index.d.ts +15 -5
  64. package/dist/index.d.ts.map +1 -1
  65. package/dist/index.js +13 -3
  66. package/dist/index.js.map +1 -1
  67. package/dist/knowledge/session.d.ts +4 -7
  68. package/dist/knowledge/session.d.ts.map +1 -1
  69. package/dist/knowledge/session.js +20 -55
  70. package/dist/knowledge/session.js.map +1 -1
  71. package/dist/permissions/index.d.ts +21 -4
  72. package/dist/permissions/index.d.ts.map +1 -1
  73. package/dist/permissions/index.js +37 -3
  74. package/dist/permissions/index.js.map +1 -1
  75. package/dist/permissions/session-store.d.ts +60 -0
  76. package/dist/permissions/session-store.d.ts.map +1 -0
  77. package/dist/permissions/session-store.js +233 -0
  78. package/dist/permissions/session-store.js.map +1 -0
  79. package/dist/tools/ask-user.d.ts.map +1 -1
  80. package/dist/tools/ask-user.js +8 -6
  81. package/dist/tools/ask-user.js.map +1 -1
  82. package/dist/tools/enter-plan-mode.d.ts +25 -0
  83. package/dist/tools/enter-plan-mode.d.ts.map +1 -0
  84. package/dist/tools/enter-plan-mode.js +120 -0
  85. package/dist/tools/enter-plan-mode.js.map +1 -0
  86. package/dist/tools/exit-plan-mode.d.ts +13 -0
  87. package/dist/tools/exit-plan-mode.d.ts.map +1 -0
  88. package/dist/tools/exit-plan-mode.js +22 -0
  89. package/dist/tools/exit-plan-mode.js.map +1 -0
  90. package/dist/tools/grep.d.ts +1 -1
  91. package/dist/tools/index.d.ts +20 -4
  92. package/dist/tools/index.d.ts.map +1 -1
  93. package/dist/tools/index.js +7 -1
  94. package/dist/tools/index.js.map +1 -1
  95. package/dist/tools/save-knowledge.d.ts +2 -2
  96. package/dist/tools/shell-provider.d.ts +4 -0
  97. package/dist/tools/shell-provider.d.ts.map +1 -1
  98. package/dist/tools/shell-provider.js +2 -0
  99. package/dist/tools/shell-provider.js.map +1 -1
  100. package/dist/tools/task.d.ts +14 -0
  101. package/dist/tools/task.d.ts.map +1 -0
  102. package/dist/tools/task.js +95 -0
  103. package/dist/tools/task.js.map +1 -0
  104. package/dist/tools/todo-write.d.ts +21 -0
  105. package/dist/tools/todo-write.d.ts.map +1 -0
  106. package/dist/tools/todo-write.js +117 -0
  107. package/dist/tools/todo-write.js.map +1 -0
  108. package/dist/types/index.d.ts +104 -1
  109. package/dist/types/index.d.ts.map +1 -1
  110. package/dist/types/index.js.map +1 -1
  111. package/package.json +1 -1
  112. package/dist/knowledge/session-usage.d.ts +0 -24
  113. package/dist/knowledge/session-usage.d.ts.map +0 -1
  114. package/dist/knowledge/session-usage.js +0 -86
  115. package/dist/knowledge/session-usage.js.map +0 -1
@@ -1,12 +1,15 @@
1
1
  // @x-code-cli/core — Tool registry (unified export)
2
2
  import { askUser } from './ask-user.js';
3
3
  import { edit } from './edit.js';
4
+ import { enterPlanMode } from './enter-plan-mode.js';
5
+ import { exitPlanMode } from './exit-plan-mode.js';
4
6
  import { glob } from './glob.js';
5
7
  import { grep } from './grep.js';
6
8
  import { listDir } from './list-dir.js';
7
9
  import { readFile } from './read-file.js';
8
10
  import { saveKnowledge } from './save-knowledge.js';
9
11
  import { shell } from './shell.js';
12
+ import { todoWrite } from './todo-write.js';
10
13
  import { webFetch } from './web-fetch.js';
11
14
  import { webSearch } from './web-search.js';
12
15
  import { writeFile } from './write-file.js';
@@ -22,7 +25,10 @@ export const toolRegistry = {
22
25
  webFetch,
23
26
  askUser,
24
27
  saveKnowledge,
28
+ enterPlanMode,
29
+ exitPlanMode,
30
+ todoWrite,
25
31
  };
26
- export { readFile, writeFile, edit, shell, glob, grep, listDir, webSearch, webFetch, askUser, saveKnowledge, };
32
+ export { readFile, writeFile, edit, shell, glob, grep, listDir, webSearch, webFetch, askUser, saveKnowledge, enterPlanMode, exitPlanMode, todoWrite, };
27
33
  export { MAX_TOOL_RESULT_LINES, MAX_TOOL_RESULT_BYTES, MAX_AGGREGATE_TOOL_RESULT_BYTES, truncateToolResult, } from './truncate.js';
28
34
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,MAA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AK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,QAAQ;IACR,SAAS;IACT,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,OAAO;IACP,SAAS;IACT,QAAQ;IACR,OAAO;IACP,aAAa;IACb,aAAa;IACb,YAAY;IACZ,SAAS;CACV,CAAA;AAED,OAAO,EACL,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,SAAS,EACT,QAAQ,EACR,OAAO,EACP,aAAa,EACb,aAAa,EACb,YAAY,EACZ,SAAS,GACV,CAAA;AAED,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,+BAA+B,EAC/B,kBAAkB,GACnB,MAAM,eAAe,CAAA"}
@@ -1,8 +1,8 @@
1
1
  export declare const saveKnowledge: import("ai").Tool<{
2
- category: "user" | "feedback" | "project" | "reference";
2
+ category: "project" | "user" | "feedback" | "reference";
3
3
  action: "add" | "delete";
4
4
  key: string;
5
5
  fact: string;
6
- scope: "project" | "global";
6
+ scope: "global" | "project";
7
7
  }, string>;
8
8
  //# sourceMappingURL=save-knowledge.d.ts.map
@@ -4,6 +4,10 @@ export interface ShellSpawnOptions {
4
4
  timeout: number;
5
5
  env?: NodeJS.ProcessEnv;
6
6
  cwd?: string;
7
+ /** When this signal aborts, execa kills the child process tree. Used to
8
+ * honor user Esc / Ctrl+C cancellation mid-command without waiting for
9
+ * the timeout. */
10
+ signal?: AbortSignal;
7
11
  }
8
12
  export interface ShellProvider {
9
13
  type: ShellType;
@@ -1 +1 @@
1
- {"version":3,"file":"shell-provider.d.ts","sourceRoot":"","sources":["../../src/tools/shell-provider.ts"],"names":[],"mappings":"AAMA,OAAO,EAAS,KAAK,aAAa,EAAE,MAAM,OAAO,CAAA;AAGjD,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,KAAK,GAAG,YAAY,CAAA;AAErD,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAA;IACvB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,SAAS,CAAA;IACf,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,GAAG,aAAa,CAAA;CAC/D;AA6DD,wBAAgB,gBAAgB,IAAI,aAAa,CAYhD"}
1
+ {"version":3,"file":"shell-provider.d.ts","sourceRoot":"","sources":["../../src/tools/shell-provider.ts"],"names":[],"mappings":"AAMA,OAAO,EAAS,KAAK,aAAa,EAAE,MAAM,OAAO,CAAA;AAGjD,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,KAAK,GAAG,YAAY,CAAA;AAErD,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAA;IACvB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;uBAEmB;IACnB,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,SAAS,CAAA;IACf,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,GAAG,aAAa,CAAA;CAC/D;AA+DD,wBAAgB,gBAAgB,IAAI,aAAa,CAYhD"}
@@ -14,6 +14,7 @@ function createPosixProvider(executable, type) {
14
14
  timeout: opts.timeout,
15
15
  cwd: opts.cwd,
16
16
  reject: false,
17
+ cancelSignal: opts.signal,
17
18
  env: { ...(opts.env ?? process.env), PYTHONIOENCODING: 'utf-8' },
18
19
  });
19
20
  },
@@ -53,6 +54,7 @@ function createPowerShellProvider(executable) {
53
54
  timeout: opts.timeout,
54
55
  cwd: opts.cwd,
55
56
  reject: false,
57
+ cancelSignal: opts.signal,
56
58
  env: { ...(opts.env ?? process.env), PYTHONIOENCODING: 'utf-8' },
57
59
  });
58
60
  },
@@ -1 +1 @@
1
- {"version":3,"file":"shell-provider.js","sourceRoot":"","sources":["../../src/tools/shell-provider.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,8EAA8E;AAC9E,0CAA0C;AAC1C,OAAO,EAAE,KAAK,EAAsB,MAAM,OAAO,CAAA;AACjD,OAAO,EAAE,MAAM,SAAS,CAAA;AAexB,SAAS,mBAAmB,CAAC,UAAkB,EAAE,IAAoB;IACnE,OAAO;QACL,IAAI;QACJ,KAAK,CAAC,OAAO,EAAE,IAAI;YACjB,OAAO,KAAK,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE;gBACxC,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,MAAM,EAAE,KAAK;gBACb,GAAG,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,gBAAgB,EAAE,OAAO,EAAE;aACjE,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC;AAED,+EAA+E;AAC/E,4EAA4E;AAC5E,8EAA8E;AAC9E,yBAAyB;AACzB,SAAS,uBAAuB,CAAC,SAAiB;IAChD,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AAC7D,CAAC;AAED,SAAS,wBAAwB,CAAC,UAAkB;IAClD,OAAO;QACL,IAAI,EAAE,YAAY;QAClB,KAAK,CAA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AAI,WAAW,CAAA;IAClD,OAAO,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;AACnF,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { SubAgentRegistry } from '../agent/sub-agents/registry.js';
2
+ /** Build the task tool description dynamically from the registry.
3
+ * Called once per session when constructing the system prompt cache.
4
+ * The listing of available agents is embedded in the description so
5
+ * the model knows what subagent_type values are valid. */
6
+ export declare function buildTaskToolDescription(registry: SubAgentRegistry): string;
7
+ /** Create the task tool definition. Must be called with the registry
8
+ * so the description includes the available agent list. */
9
+ export declare function createTaskTool(registry: SubAgentRegistry): import("ai").Tool<{
10
+ description: string;
11
+ prompt: string;
12
+ subagent_type: string;
13
+ }, never>;
14
+ //# sourceMappingURL=task.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../../src/tools/task.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAEvE;;;2DAG2D;AAC3D,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,CAoE3E;AAED;4DAC4D;AAC5D,wBAAgB,cAAc,CAAC,QAAQ,EAAE,gBAAgB;;;;UAcxD"}
@@ -0,0 +1,95 @@
1
+ // @x-code-cli/core — task tool (sub-agent dispatch)
2
+ //
3
+ // The tool definition has no `execute` — dispatch is handled manually
4
+ // in tool-execution.ts's handleToolCall, which calls runSubAgent.
5
+ // This is intentional: the task tool needs access to LoopState,
6
+ // AgentOptions, and callbacks that aren't available in the tool's
7
+ // execute context.
8
+ import { tool } from 'ai';
9
+ import { z } from 'zod';
10
+ /** Build the task tool description dynamically from the registry.
11
+ * Called once per session when constructing the system prompt cache.
12
+ * The listing of available agents is embedded in the description so
13
+ * the model knows what subagent_type values are valid. */
14
+ export function buildTaskToolDescription(registry) {
15
+ const agents = registry.list();
16
+ const agentList = agents
17
+ .map((a) => ` - ${a.name}: ${a.description}`)
18
+ .join('\n');
19
+ return `Launch a sub-agent to handle a task in an isolated context. The sub-agent runs with its own message history and returns only its final conclusion — its intermediate tool calls never enter your context window, keeping the main conversation lean.
20
+
21
+ Available sub-agents:
22
+ ${agentList}
23
+
24
+ ## When to use
25
+
26
+ Use the task tool when intermediate tool output isn't worth keeping in your context:
27
+ - **Research / exploration**: open-ended questions about the codebase ("where is X defined", "find all callers of Y", "what test patterns does this project use")
28
+ - **Code review**: reviewing pending changes or specific files for bugs, security issues, style violations
29
+ - **Implementation planning**: designing an approach that requires reading many files before writing any
30
+ - **Multi-step investigation**: tasks that need 3+ tool calls whose raw output you don't need to see — only the conclusion matters
31
+
32
+ ## When NOT to use
33
+
34
+ Do NOT delegate when a direct tool call is faster or when you need the result in-context:
35
+ - If you want to read a specific file, use readFile directly
36
+ - If you are searching for a specific symbol like "class Foo", use grep directly
37
+ - If you are searching code within 1-3 known files, use readFile directly
38
+ - Simple single-step tasks (typo fix, add a comment, run one command)
39
+ - Tasks where your immediate next step depends on the raw output — do them locally to keep the critical path moving
40
+ - The user asked a simple question you can answer directly
41
+
42
+ ## Writing the prompt
43
+
44
+ Brief the sub-agent like a smart colleague who just walked into the room — it has zero prior context: hasn't seen this conversation, doesn't know what you've tried, doesn't understand why this task matters.
45
+ - Explain what you're trying to accomplish and why.
46
+ - Describe what you've already learned or ruled out.
47
+ - Give enough context about the surrounding problem that the agent can make judgment calls rather than just following a narrow instruction.
48
+ - Include concrete details: file paths, function names, line numbers, error messages.
49
+ - If you need a short response, say so ("report in under 200 words").
50
+ - For lookups: hand over the exact command. For investigations: hand over the question — prescribed steps become dead weight when the premise is wrong.
51
+
52
+ Terse command-style prompts produce shallow, generic work.
53
+
54
+ **Never delegate understanding.** Don't write "based on your findings, fix the bug" or "based on the research, implement it." Those phrases push synthesis onto the agent instead of doing it yourself. Write prompts that prove you understood: include file paths, line numbers, what specifically to change.
55
+
56
+ ## Concurrency safety
57
+
58
+ NEVER launch multiple sub-agents in one turn if they could modify the same files or resources. Only run multiple sub-agents in parallel when their tasks are genuinely independent (e.g., two read-only research questions about different parts of the codebase).
59
+
60
+ ## Example
61
+
62
+ <example>
63
+ user: "Can you check if there are any security issues in the auth module?"
64
+ assistant: I'll have the code reviewer check the auth module.
65
+ task({
66
+ description: "Review auth module security",
67
+ subagent_type: "code-reviewer",
68
+ prompt: "Review the authentication module for security issues. The main auth code lives in src/auth/. Focus on: JWT token handling in src/auth/jwt.ts, session management in src/auth/session.ts, and the login endpoint in src/routes/login.ts. Check for: token expiration handling, secret storage, injection vulnerabilities, and missing input validation. Report a numbered punch list with severity and file:line references."
69
+ })
70
+ </example>
71
+
72
+ <example>
73
+ user: "Fix the typo in README"
74
+ <commentary>Do NOT use task — this is a single-step edit. Just use the edit tool directly.</commentary>
75
+ </example>
76
+
77
+ <example>
78
+ user: "What does the glob tool do?"
79
+ <commentary>Do NOT use task — this is a direct Q&A question you can answer from your own knowledge.</commentary>
80
+ </example>`;
81
+ }
82
+ /** Create the task tool definition. Must be called with the registry
83
+ * so the description includes the available agent list. */
84
+ export function createTaskTool(registry) {
85
+ return tool({
86
+ description: buildTaskToolDescription(registry),
87
+ inputSchema: z.object({
88
+ description: z.string().describe('A short (3-5 words) description of the task'),
89
+ subagent_type: z.string().describe(`Which sub-agent to use. Available: ${registry.names().join(', ')}`),
90
+ prompt: z.string().describe('The complete task instruction sent to the sub-agent. Be specific — the sub-agent has no prior context.'),
91
+ }),
92
+ // No execute — handled manually in tool-execution.ts
93
+ });
94
+ }
95
+ //# sourceMappingURL=task.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.js","sourceRoot":"","sources":["../../src/tools/task.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,EAAE;AACF,sEAAsE;AACtE,kEAAkE;AAClE,gEAAgE;AAChE,kEAAkE;AAClE,mBAAmB;AACnB,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AACzB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB;;;2DAG2D;AAC3D,MAAM,UAAU,wBAAwB,CAAC,QAA0B;IACjE,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAA;IAC9B,MAAM,SAAS,GAAG,MAAM;SACrB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;SAC7C,IAAI,CAAC,IAAI,CAAC,CAAA;IAEb,OAAO;;;EAGP,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA0DA,CAAA;AACX,CAAC;AAED;4DAC4D;AAC5D,MAAM,UAAU,cAAc,CAAC,QAA0B;IACvD,OAAO,IAAI,CAAC;QACV,WAAW,EAAE,wBAAwB,CAAC,QAAQ,CAAC;QAC/C,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;YACpB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6CAA6C,CAAC;YAC/E,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAChC,sCAAsC,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACpE;YACD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CACzB,wGAAwG,CACzG;SACF,CAAC;QACF,qDAAqD;KACtD,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,21 @@
1
+ /** The model maintains a working checklist via this tool. Each call
2
+ * REPLACES the entire list (no merge / no delta) — the model is told
3
+ * to pass the full updated array every time, including unchanged items.
4
+ * When all items are completed, the agent loop auto-clears the list to
5
+ * free the live UI panel.
6
+ *
7
+ * Storage: in-memory on `LoopState.todos`, mirrored to React state via
8
+ * `callbacks.onTodosUpdate`. Never persisted to disk (matches Claude
9
+ * Code) — checklists are session-scoped working memory, not records.
10
+ *
11
+ * No `execute` field — the side-effect (mutating LoopState.todos and
12
+ * notifying the UI) is handled manually in `processToolCalls`. Same
13
+ * pattern as askUser / enterPlanMode. */
14
+ export declare const todoWrite: import("ai").Tool<{
15
+ todos: {
16
+ content?: string | undefined;
17
+ status?: "pending" | "in_progress" | "completed" | undefined;
18
+ activeForm?: string | undefined;
19
+ }[];
20
+ }, never>;
21
+ //# sourceMappingURL=todo-write.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"todo-write.d.ts","sourceRoot":"","sources":["../../src/tools/todo-write.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;0CAY0C;AAC1C,eAAO,MAAM,SAAS;;;;;;SAqGpB,CAAA"}
@@ -0,0 +1,117 @@
1
+ // @x-code-cli/core — todoWrite tool (model-managed checklist, no execute — handled in agent loop)
2
+ import { tool } from 'ai';
3
+ import { z } from 'zod';
4
+ /** The model maintains a working checklist via this tool. Each call
5
+ * REPLACES the entire list (no merge / no delta) — the model is told
6
+ * to pass the full updated array every time, including unchanged items.
7
+ * When all items are completed, the agent loop auto-clears the list to
8
+ * free the live UI panel.
9
+ *
10
+ * Storage: in-memory on `LoopState.todos`, mirrored to React state via
11
+ * `callbacks.onTodosUpdate`. Never persisted to disk (matches Claude
12
+ * Code) — checklists are session-scoped working memory, not records.
13
+ *
14
+ * No `execute` field — the side-effect (mutating LoopState.todos and
15
+ * notifying the UI) is handled manually in `processToolCalls`. Same
16
+ * pattern as askUser / enterPlanMode. */
17
+ export const todoWrite = tool({
18
+ description: `Use this tool to track multi-step tasks. The user sees a live checklist (☐ ◼ ✔) above the spinner — it makes long tasks feel structured and gives them visibility into your plan.
19
+
20
+ ## When to Use
21
+
22
+ - Multi-step tasks that involve 3+ logical steps
23
+ - Right after exitPlanMode is approved and you have an approved plan with several files / phases — translate the plan into todos before starting work
24
+ - The user gives multiple requests in one message ("do A, then B, then C")
25
+ - When you start a step (mark it \`in_progress\` BEFORE doing the work)
26
+ - When you finish a step (mark it \`completed\` IMMEDIATELY, not at the end)
27
+
28
+ ## When NOT to Use
29
+
30
+ - Single-file edits, typos, trivial fixes — todos add ceremony with no benefit
31
+ - Pure Q&A or research questions
32
+ - Tasks doable in 1-2 obvious steps
33
+ - Conversational replies that don't involve concrete work
34
+
35
+ ## Hard Rules
36
+
37
+ 1. **Status values**: \`pending\` | \`in_progress\` | \`completed\` (exactly these three).
38
+ 2. **Exactly ONE task in_progress at any time** — not zero, not two. The user reads the in_progress one as "what the agent is doing right now".
39
+ 3. **Mark complete IMMEDIATELY after finishing** — don't batch completions at the end of the run. The user wants live feedback.
40
+ 4. **Only mark complete when truly done** — if tests are failing, the implementation is partial, you hit an error, or you're going to follow up later: leave it as \`in_progress\` and add a NEW pending todo describing the unresolved part.
41
+ 5. **Provide both \`content\` and \`activeForm\`**:
42
+ - \`content\` is imperative: "Run tests", "Update auth handler"
43
+ - \`activeForm\` is present-continuous: "Running tests", "Updating auth handler"
44
+ - The activeForm is what shows in the live UI for the in_progress item.
45
+ 6. **Pass the FULL list every call** — todoWrite REPLACES the list, not merges. Include unchanged items.
46
+ 7. When you submit a list where every item is \`completed\`, the system auto-clears the checklist for you. No need to clear it manually.
47
+
48
+ ## Example
49
+
50
+ User: "Refactor the auth system to use JWT and update the login flow"
51
+
52
+ After exploration / planning, on the first implementation turn:
53
+ \`\`\`
54
+ todoWrite({
55
+ todos: [
56
+ { content: "Read existing auth implementation", activeForm: "Reading auth code", status: "in_progress" },
57
+ { content: "Add JWT signing/verification utility", activeForm: "Adding JWT utility", status: "pending" },
58
+ { content: "Update login handler", activeForm: "Updating login", status: "pending" },
59
+ { content: "Update protected routes middleware", activeForm: "Updating middleware", status: "pending" },
60
+ { content: "Add tests for new auth flow", activeForm: "Writing auth tests", status: "pending" }
61
+ ]
62
+ })
63
+ \`\`\`
64
+
65
+ After reading the code:
66
+ \`\`\`
67
+ todoWrite({
68
+ todos: [
69
+ { content: "Read existing auth implementation", activeForm: "Reading auth code", status: "completed" },
70
+ { content: "Add JWT signing/verification utility", activeForm: "Adding JWT utility", status: "in_progress" },
71
+ ...rest stay pending
72
+ ]
73
+ })
74
+ \`\`\`
75
+
76
+ After finishing all five (auto-cleared next call):
77
+ \`\`\`
78
+ todoWrite({ todos: [/* all five with status: "completed" */] })
79
+ \`\`\`
80
+
81
+ ## Bad usage
82
+
83
+ User: "fix this typo in README"
84
+ You: <do not call todoWrite — single edit, no value in a checklist>
85
+
86
+ User: "what does X do?"
87
+ You: <do not call todoWrite — pure Q&A, no work to track>`,
88
+ // SCHEMA LENIENCY (deliberate): all three per-todo fields are
89
+ // marked optional even though the tool description tells the model
90
+ // they are required. Reason: weaker provider models (DeepSeek-flash,
91
+ // GLM, Qwen, etc.) routinely drop one field per item — most often
92
+ // `status` on the last "current" entry, sometimes `content` when
93
+ // they think `activeForm` is enough. With strict requireds, Zod
94
+ // rejects the whole call → SDK emits tool-error → assistant
95
+ // tool_call with no result → next API turn fails with "tool must
96
+ // be a response to tool_calls". Validating loosely and synthesising
97
+ // sane defaults in the dispatch handler is dramatically more robust
98
+ // than playing whack-a-mole with model output. Strong models
99
+ // (Sonnet, Opus) still get the same rich description telling them
100
+ // to provide all three fields.
101
+ inputSchema: z.object({
102
+ todos: z
103
+ .array(z.object({
104
+ content: z.string().optional().describe('Imperative phrasing of the task ("Run tests").'),
105
+ activeForm: z
106
+ .string()
107
+ .optional()
108
+ .describe('Present-continuous phrasing ("Running tests"); shown in the live UI when this item is in_progress.'),
109
+ status: z
110
+ .enum(['pending', 'in_progress', 'completed'])
111
+ .optional()
112
+ .describe('Lifecycle state. Exactly one item should be in_progress at any time. Defaults to "pending" if omitted.'),
113
+ }))
114
+ .describe('The complete updated todo list. Every call REPLACES the existing list — include all items even if unchanged.'),
115
+ }),
116
+ });
117
+ //# sourceMappingURL=todo-write.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"todo-write.js","sourceRoot":"","sources":["../../src/tools/todo-write.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AAEzB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;;;;;;0CAY0C;AAC1C,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0DAqE2C;IACxD,8DAA8D;IAC9D,mEAAmE;IACnE,qEAAqE;IACrE,kEAAkE;IAClE,iEAAiE;IACjE,gEAAgE;IAChE,4DAA4D;IAC5D,iEAAiE;IACjE,oEAAoE;IACpE,oEAAoE;IACpE,6DAA6D;IAC7D,kEAAkE;IAClE,+BAA+B;IAC/B,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,KAAK,EAAE,CAAC;aACL,KAAK,CACJ,CAAC,CAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gDAAgD,CAAC;YACzF,UAAU,EAAE,CAAC;iBACV,MAAM,EAAE;iBACR,QAAQ,EAAE;iBACV,QAAQ,CAAC,oGAAoG,CAAC;YACjH,MAAM,EAAE,CAAC;iBACN,IAAI,CAAC,CAAC,SAAS,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;iBAC7C,QAAQ,EAAE;iBACV,QAAQ,CAAC,wGAAwG,CAAC;SACtH,CAAC,CACH;aACA,QAAQ,CAAC,8GAA8G,CAAC;KAC5H,CAAC;CACH,CAAC,CAAA"}
@@ -1,5 +1,47 @@
1
1
  import type { LanguageModel, ModelMessage } from 'ai';
2
+ import type { EditDiffPayload } from '../agent/diff.js';
3
+ import type { SubAgentEvent } from '../agent/sub-agents/types.js';
4
+ import type { SubAgentRegistry } from '../agent/sub-agents/registry.js';
2
5
  export type PermissionLevel = 'always-allow' | 'ask' | 'deny';
6
+ /** Approval mode for the current session.
7
+ *
8
+ * 'default' — normal flow: write tools ask, model can call anything.
9
+ * 'plan' — read-only mode: the model is told (via system-prompt
10
+ * overlay) to explore + write a plan to a session-local
11
+ * plan file but make no other edits. Enforcement is
12
+ * prompt-based — matching Claude Code, no hard
13
+ * permission-layer block — so a non-compliant model
14
+ * would still hit the regular `ask` prompt for
15
+ * write/edit/shell.
16
+ * 'acceptEdits' — write tools (writeFile / edit) auto-approve without
17
+ * asking; shell still goes through normal classification
18
+ * (always-allow / ask / deny) so destructive commands
19
+ * stay gated. Useful right after a plan is approved —
20
+ * the user already vetted the plan, having to click
21
+ * "Yes" on every writeFile during implementation is
22
+ * pure friction. exitPlanMode auto-switches into this
23
+ * mode on approval; the user can also enter it
24
+ * manually via Shift+Tab cycling.
25
+ *
26
+ * Cycling order on Shift+Tab: default → acceptEdits → plan → default. */
27
+ export type PermissionMode = 'default' | 'acceptEdits' | 'plan';
28
+ /** A single entry on the model's working checklist.
29
+ *
30
+ * content — imperative phrasing of the task ("Update auth handler")
31
+ * activeForm — present-continuous phrasing for the live indicator
32
+ * ("Updating auth handler"); shown in UI while status is
33
+ * 'in_progress' so the user sees what the agent is doing
34
+ * right now.
35
+ * status — 'pending' | 'in_progress' | 'completed'.
36
+ *
37
+ * Mirrors Claude Code's TodoWrite payload shape verbatim. Persisted
38
+ * in-memory only (LoopState.todos), per-session, no disk. */
39
+ export type TodoStatus = 'pending' | 'in_progress' | 'completed';
40
+ export interface TodoItem {
41
+ content: string;
42
+ activeForm: string;
43
+ status: TodoStatus;
44
+ }
3
45
  export interface TokenUsage {
4
46
  inputTokens: number;
5
47
  outputTokens: number;
@@ -12,6 +54,21 @@ export interface TokenUsage {
12
54
  * Billed at a premium over normal input rate but unlocks cheap reads on
13
55
  * subsequent turns. Zero on providers that don't separate creation from read. */
14
56
  cacheCreationTokens: number;
57
+ /** Current context-window occupancy — `input_tokens + output_tokens` of
58
+ * the MOST RECENT API response (`inputTokens` already includes cache_read
59
+ * + cache_write since AI SDK v6 normalises them into one field). Unlike
60
+ * the cumulative fields above, this is a SNAPSHOT — overwritten each
61
+ * turn, not accumulated. Drives the footer "N / M · X%" indicator.
62
+ *
63
+ * Why input + output (matching every provider's definition):
64
+ * every major LLM API — Anthropic, OpenAI, Google Gemini, DeepSeek,
65
+ * Moonshot, Alibaba, xAI — defines "context window" as the shared
66
+ * budget pool of input + output, with `input + output ≤ context_window`
67
+ * as the architectural constraint (single KV-cache cap). Showing input
68
+ * alone in the footer would be a different number than what users see
69
+ * when reading provider docs about model context windows. The cumulative
70
+ * fields above remain for `/usage` billing summaries. */
71
+ currentContextTokens: number;
15
72
  }
16
73
  export interface DisplayMessage {
17
74
  id: string;
@@ -47,6 +104,11 @@ export interface DisplayToolCall {
47
104
  status: 'pending' | 'running' | 'completed' | 'denied' | 'error';
48
105
  /** How long the tool call took to execute (milliseconds) */
49
106
  durationMs?: number;
107
+ /** Structured patch produced by writeFile / edit — drives the colored
108
+ * diff block under the tool bullet in scrollback. Absent for non-edit
109
+ * tools, hydrated history (we don't recompute on session resume), and
110
+ * edits that actually had no effect (oldContent === newContent). */
111
+ editPayload?: EditDiffPayload;
50
112
  }
51
113
  export interface AgentCallbacks {
52
114
  onTextDelta: (text: string) => void;
@@ -56,19 +118,39 @@ export interface AgentCallbacks {
56
118
  * shown in the live UI; the final summary comes through onToolResult. */
57
119
  onToolProgress: (toolCallId: string, message: string) => void;
58
120
  onToolResult: (toolCallId: string, result: string, isError?: boolean) => void;
121
+ /** Optional. Fired right BEFORE `onToolResult` for a successful
122
+ * writeFile / edit, carrying the structured patch + line counts so the
123
+ * UI can render a diff block under the tool bullet. Skipped for
124
+ * permission-denied / errored writes (the file wasn't actually changed)
125
+ * and for no-op edits that produced an identical file. */
126
+ onFileEdit?: (toolCallId: string, payload: EditDiffPayload) => void;
59
127
  onAskPermission: (toolCall: {
60
128
  toolCallId: string;
61
129
  toolName: string;
62
130
  input: Record<string, unknown>;
63
- }) => Promise<boolean>;
131
+ }) => Promise<'yes' | 'always' | 'no'>;
64
132
  onAskUser: (question: string, options: {
65
133
  label: string;
66
134
  description: string;
67
135
  }[]) => Promise<string>;
136
+ /** Triggered by `exitPlanMode`. Resolve `true` to leave plan mode and
137
+ * let the model start implementing; resolve `false` to reject the plan
138
+ * and keep the model in plan mode for further iteration. */
139
+ onPlanApprovalRequest: (planText: string) => Promise<boolean>;
140
+ /** Fired whenever permissionMode flips so the UI can resync the bottom
141
+ * indicator and (when persisting) write the new value to user config. */
142
+ onPlanModeChange: (mode: PermissionMode) => void;
143
+ /** Fired after the model calls `todoWrite` so the UI can show the
144
+ * current checklist. The full list is passed every call (todoWrite
145
+ * is a full-replacement tool, not a delta) — UI just stores it. */
146
+ onTodosUpdate: (todos: TodoItem[]) => void;
68
147
  onShellOutput: (chunk: string) => void;
69
148
  onUsageUpdate: (usage: TokenUsage) => void;
70
149
  onContextCompressed: (summary: string) => void;
71
150
  onError: (error: Error) => void;
151
+ /** Fired by the sub-agent runner to stream progress from child agent loops.
152
+ * The CLI UI uses these events to build the collapsed/expanded task block. */
153
+ onSubAgentEvent?: (event: SubAgentEvent) => void;
72
154
  }
73
155
  export interface AgentOptions {
74
156
  modelId: string;
@@ -80,8 +162,27 @@ export interface AgentOptions {
80
162
  * Persisted in `~/.x-code/config.json` as `thinking: boolean`,
81
163
  * toggled at runtime via `/thinking on|off`. Defaults to false. */
82
164
  thinking?: boolean;
165
+ /** Initial permission mode for the session. Defaults to 'default'.
166
+ * Set from `--plan` CLI flag or `loadUserConfig().permissionMode`. */
167
+ permissionMode?: PermissionMode;
83
168
  systemPromptExtra?: string;
84
169
  abortSignal?: AbortSignal;
170
+ /** Provider registry for resolving sub-agent model overrides.
171
+ * Injected by the CLI at startup. Absent = sub-agents inherit the
172
+ * parent model (no independent model selection). */
173
+ modelRegistry?: {
174
+ languageModel: (...args: any[]) => LanguageModel;
175
+ };
176
+ /** Sub-agent registry. Injected by the CLI at startup after scanning
177
+ * built-in + custom agent definitions. Absent = task tool is not
178
+ * registered (no sub-agent support). */
179
+ subAgentRegistry?: SubAgentRegistry;
180
+ /** Tool allow/deny filter. Used by sub-agent loops to restrict
181
+ * which tools the child can call. `task` is always in `deny`. */
182
+ toolFilter?: {
183
+ allow?: string[];
184
+ deny?: string[];
185
+ };
85
186
  }
86
187
  /**
87
188
  * Category taxonomy for auto memory entries. Categories describe the TYPE of
@@ -157,4 +258,6 @@ export interface ProviderModel {
157
258
  export declare const PROVIDER_MODELS: Record<string, readonly ProviderModel[]>;
158
259
  export declare const PROVIDER_KEY_URLS: Record<string, string>;
159
260
  export type { ModelMessage, LanguageModel };
261
+ export type { SubAgentEvent, SubAgentDefinition, SubAgentTrace } from '../agent/sub-agents/types.js';
262
+ export type { SubAgentRegistry } from '../agent/sub-agents/registry.js';
160
263
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AAIrD,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,KAAK,GAAG,MAAM,CAAA;AAI7D,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;IACnB;;gFAE4E;IAC5E,eAAe,EAAE,MAAM,CAAA;IACvB;;sFAEkF;IAClF,mBAAmB,EAAE,MAAM,CAAA;CAC5B;AAID,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,MAAM,CAAA;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,eAAe,EAAE,CAAA;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB;;;;gEAI4D;IAC5D,cAAc,CA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G,EAAE,uBAAuB;IAC5B,QAAQ,EAAE,wCAAwC;IAClD,OAAO,EAAE,6CAA6C;IACtD,KAAK,EAAE,6CAA6C;IACpD,UAAU,EAAE,+CAA+C;CAC5D,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@x-code-cli/core",
3
- "version": "0.1.11",
3
+ "version": "0.2.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/woai3c/x-code-cli",
@@ -1,24 +0,0 @@
1
- import type { LoopState } from '../agent/loop-state.js';
2
- import type { TokenUsage } from '../types/index.js';
3
- export interface SessionUsageSnapshot {
4
- id: string;
5
- modelId: string;
6
- startedAt: string;
7
- updatedAt: string;
8
- turnCount: number;
9
- usage: TokenUsage;
10
- }
11
- /** Write the current usage state to disk. Fire-and-forget from the loop —
12
- * callers should `void` this; failures are swallowed so a transient FS error
13
- * never aborts the agent turn. */
14
- export declare function persistUsageSnapshot(state: LoopState, modelId: string): Promise<void>;
15
- /** Read the most recent usage snapshot for the current project (cwd). Returns
16
- * null when no session has run here yet. /usage prefers in-memory state for
17
- * the live session and only hits this on a fresh process. */
18
- export declare function loadLatestUsageSnapshot(): Promise<SessionUsageSnapshot | null>;
19
- /** Enumerate every per-session usage snapshot in this project, newest first.
20
- * Used by `/usage history` — purely project-local, never traverses other
21
- * cwds. Skips `latest.usage.json` since it's a duplicate pointer. Silently
22
- * drops malformed JSON files instead of failing the whole listing. */
23
- export declare function listSessionUsageSnapshots(): Promise<SessionUsageSnapshot[]>;
24
- //# sourceMappingURL=session-usage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"session-usage.d.ts","sourceRoot":"","sources":["../../src/knowledge/session-usage.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAGnD,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,UAAU,CAAA;CAClB;AAgBD;;mCAEmC;AACnC,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAmB3F;AAED;;8DAE8D;AAC9D,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAOpF;AAED;;;uEAGuE;AACvE,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAqBjF"}