@sylix/coworker 1.5.3 → 2.0.0

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 (88) hide show
  1. package/README.md +57 -164
  2. package/dist/agents/SubagentLoader.d.ts +59 -0
  3. package/dist/agents/SubagentLoader.d.ts.map +1 -0
  4. package/dist/agents/SubagentLoader.js +140 -0
  5. package/dist/agents/SubagentLoader.js.map +1 -0
  6. package/dist/agents/SubagentRunner.d.ts +15 -0
  7. package/dist/agents/SubagentRunner.d.ts.map +1 -0
  8. package/dist/agents/SubagentRunner.js +116 -0
  9. package/dist/agents/SubagentRunner.js.map +1 -0
  10. package/dist/cli/index.d.ts.map +1 -1
  11. package/dist/cli/index.js +0 -9
  12. package/dist/cli/index.js.map +1 -1
  13. package/dist/commands/slash/config.d.ts.map +1 -1
  14. package/dist/commands/slash/config.js +15 -0
  15. package/dist/commands/slash/config.js.map +1 -1
  16. package/dist/commands/slash/context.d.ts.map +1 -1
  17. package/dist/commands/slash/context.js +31 -0
  18. package/dist/commands/slash/context.js.map +1 -1
  19. package/dist/commands/slash/core.js +4 -4
  20. package/dist/commands/slash/core.js.map +1 -1
  21. package/dist/commands/slash/registry.d.ts.map +1 -1
  22. package/dist/commands/slash/registry.js +2 -0
  23. package/dist/commands/slash/registry.js.map +1 -1
  24. package/dist/commands/slash/session.d.ts.map +1 -1
  25. package/dist/commands/slash/session.js +97 -44
  26. package/dist/commands/slash/session.js.map +1 -1
  27. package/dist/commands/slash/snapshot.d.ts +3 -0
  28. package/dist/commands/slash/snapshot.d.ts.map +1 -0
  29. package/dist/commands/slash/snapshot.js +144 -0
  30. package/dist/commands/slash/snapshot.js.map +1 -0
  31. package/dist/config/SettingsManager.d.ts +2 -0
  32. package/dist/config/SettingsManager.d.ts.map +1 -1
  33. package/dist/config/SettingsManager.js +7 -0
  34. package/dist/config/SettingsManager.js.map +1 -1
  35. package/dist/core/CoWorkerAgent.d.ts +32 -0
  36. package/dist/core/CoWorkerAgent.d.ts.map +1 -1
  37. package/dist/core/CoWorkerAgent.js +414 -71
  38. package/dist/core/CoWorkerAgent.js.map +1 -1
  39. package/dist/hooks/HookEngine.d.ts +115 -0
  40. package/dist/hooks/HookEngine.d.ts.map +1 -0
  41. package/dist/hooks/HookEngine.js +220 -0
  42. package/dist/hooks/HookEngine.js.map +1 -0
  43. package/dist/memory/AutoMemory.d.ts +55 -0
  44. package/dist/memory/AutoMemory.d.ts.map +1 -0
  45. package/dist/memory/AutoMemory.js +185 -0
  46. package/dist/memory/AutoMemory.js.map +1 -0
  47. package/dist/permissions/PermissionInterceptor.d.ts +55 -7
  48. package/dist/permissions/PermissionInterceptor.d.ts.map +1 -1
  49. package/dist/permissions/PermissionInterceptor.js +170 -22
  50. package/dist/permissions/PermissionInterceptor.js.map +1 -1
  51. package/dist/session/SessionManager.d.ts +53 -10
  52. package/dist/session/SessionManager.d.ts.map +1 -1
  53. package/dist/session/SessionManager.js +127 -55
  54. package/dist/session/SessionManager.js.map +1 -1
  55. package/dist/session/db.d.ts +81 -0
  56. package/dist/session/db.d.ts.map +1 -0
  57. package/dist/session/db.js +268 -0
  58. package/dist/session/db.js.map +1 -0
  59. package/dist/skills/HookAndSkillManager.d.ts +7 -5
  60. package/dist/skills/HookAndSkillManager.d.ts.map +1 -1
  61. package/dist/skills/HookAndSkillManager.js +30 -56
  62. package/dist/skills/HookAndSkillManager.js.map +1 -1
  63. package/dist/snapshot/SnapshotManager.d.ts +94 -0
  64. package/dist/snapshot/SnapshotManager.d.ts.map +1 -0
  65. package/dist/snapshot/SnapshotManager.js +260 -0
  66. package/dist/snapshot/SnapshotManager.js.map +1 -0
  67. package/dist/tools/LSPTool.d.ts +18 -0
  68. package/dist/tools/LSPTool.d.ts.map +1 -0
  69. package/dist/tools/LSPTool.js +137 -0
  70. package/dist/tools/LSPTool.js.map +1 -0
  71. package/dist/tools/NativeTools.d.ts +4 -3
  72. package/dist/tools/NativeTools.d.ts.map +1 -1
  73. package/dist/tools/NativeTools.js +66 -19
  74. package/dist/tools/NativeTools.js.map +1 -1
  75. package/dist/tools/Schemas.d.ts +69 -0
  76. package/dist/tools/Schemas.d.ts.map +1 -1
  77. package/dist/tools/Schemas.js +32 -0
  78. package/dist/tools/Schemas.js.map +1 -1
  79. package/dist/utils/contextManager.d.ts +1 -1
  80. package/dist/utils/contextManager.d.ts.map +1 -1
  81. package/dist/utils/output.d.ts +2 -5
  82. package/dist/utils/output.d.ts.map +1 -1
  83. package/dist/utils/output.js +43 -38
  84. package/dist/utils/output.js.map +1 -1
  85. package/dist/utils/systemPrompt.d.ts.map +1 -1
  86. package/dist/utils/systemPrompt.js +1 -0
  87. package/dist/utils/systemPrompt.js.map +1 -1
  88. package/package.json +3 -1
package/README.md CHANGED
@@ -1,191 +1,84 @@
1
- # CoWorker by Sylix
1
+ # CoWorker by Sylix (Vision 2.0)
2
2
 
3
- A powerful AI-powered CLI coding assistant that runs in your terminal.
3
+ A powerful, production-grade AI-powered CLI coding assistant with Claude Code parity.
4
4
 
5
- ![CoWorker Banner](https://img.shields.io/badge/CoWorker-Sylix-cyan)
5
+ ![CoWorker Banner](https://img.shields.io/badge/CoWorker-v2.0.0-cyan)
6
+ ![Vision 2.0](https://img.shields.io/badge/Vision%202.0-Ready-green)
6
7
 
7
- ## Features
8
+ ## 🚀 Vision 2.0 Features
8
9
 
9
- - **Ask**: Query your codebase with natural language questions
10
- - **Explain**: Get clear explanations of any file's purpose and structure
11
- - **Edit**: AI-assisted file editing with diff preview and confirmation
12
- - **Run**: Execute tasks with intelligent command suggestions
13
- - **Config**: Easy configuration management for your Sylix API credentials
10
+ CoWorker v2.0 is a major upgrade introducing enterprise-grade agentic capabilities:
14
11
 
15
- ## Installation
12
+ - **Hook Engine (20+ Events)**: Deeply instrumented lifecycle with Command, HTTP, and Prompt handlers.
13
+ - **SQLite Session Persistence**: Robust message storage with forking, archiving, and full-text search.
14
+ - **2-Phase Compaction**: Intelligent context management that preserves recent history while summarizing older tool outputs.
15
+ - **Subagent System**: Tiered agent architecture (`explore`, `plan`, `review`) with scoped toolsets and permission modes.
16
+ - **Auto Memory**: Persistent cross-session learnings that automatically inject project-specific knowledge.
17
+ - **LSP Integration**: Real-time code navigation via Language Server Protocol (Definition/References).
18
+ - **Premium UX**: High-fidelity terminal output with `<thinking>` tag support, animated status indicators, and custom themes.
16
19
 
17
- ### Prerequisites
18
-
19
- - Node.js 18 or higher
20
- - npm or yarn
21
- - Sylix API access
20
+ ## 🛠 Installation
22
21
 
23
- ### Install Dependencies
22
+ ### Prerequisites
23
+ - Node.js 18 or higher (v20 recommended)
24
+ - Git (for snapshot/undo support)
25
+ - SQLite (included via `better-sqlite3`)
24
26
 
27
+ ### Setup
25
28
  ```bash
29
+ git clone https://github.com/sylix/coworker
26
30
  cd coworker
27
31
  npm install
28
- ```
29
-
30
- ### Build
31
-
32
- ```bash
33
32
  npm run build
34
- ```
35
-
36
- ### Global Installation (Optional)
37
-
38
- To use `coworker` command anywhere:
39
-
40
- ```bash
41
33
  npm link
42
34
  ```
43
35
 
44
- ## Configuration
45
-
46
- Before using CoWorker, configure your Sylix API credentials:
47
-
48
- ```bash
49
- coworker config init
50
- ```
51
-
52
- You'll be prompted for:
53
- - **Base URL**: Your Sylix API endpoint (default: `https://api.sylix.ai`)
54
- - **API Key**: Your Sylix API key
55
- - **Default Model**: Model to use (default: `sylix-4`)
56
-
57
- To view your current configuration:
58
-
59
- ```bash
60
- coworker config show
61
- ```
62
-
63
- ## Usage
64
-
65
- ### Ask a Question
66
-
67
- Ask questions about your codebase with context awareness:
36
+ ## ⌨️ Usage
68
37
 
38
+ ### Interactive Chat (REPL)
39
+ Start the agent in your current workspace:
69
40
  ```bash
70
- coworker ask "What does the authentication module do?"
41
+ coworker
71
42
  ```
72
43
 
73
- ```bash
74
- coworker ask "How can I optimize the database queries in this project?"
75
- ```
76
-
77
- ### Explain a File
44
+ ### Protocol Modes
45
+ - `/explore <query>`: Read-only exploration mode (mutations blocked).
46
+ - `/plan <task>`: Strict planning mode (enforces `TodoWrite` before execution).
78
47
 
79
- Get detailed explanations of any file:
48
+ ### Slash Commands
49
+ - `/sessions`: Search, fork, or resume previous conversations.
50
+ - `/memory`: Manage persistent project learnings and auto-extracted facts.
51
+ - `/context`: View real-time token usage and compaction status.
52
+ - `/undo`: Revert the last code modification via snapshotting.
53
+ - `/config`: Quick access to model, theme, and effort settings.
80
54
 
81
- ```bash
82
- coworker explain src/api/sylix.ts
83
- ```
84
-
85
- ```bash
86
- coworker explain package.json
87
- ```
88
-
89
- ### Edit a File
90
-
91
- AI-assisted editing with diff preview:
92
-
93
- ```bash
94
- coworker edit src/utils/helper.ts "Add input validation to the parseConfig function"
95
- ```
96
-
97
- ```bash
98
- coworker edit app.js "Convert the callback-based function to use async/await"
99
- ```
100
-
101
- ### Run a Task
102
-
103
- Execute tasks with command suggestions:
104
-
105
- ```bash
106
- coworker run "Set up a new React component library"
107
- ```
108
-
109
- ```bash
110
- coworker run "Run all tests and show me the results"
111
- ```
112
-
113
- The assistant will suggest commands and ask for confirmation before executing them.
114
-
115
- ## Project Structure
55
+ ## 📁 Project Structure
116
56
 
117
57
  ```
118
58
  coworker/
119
59
  ├── src/
120
- │ ├── cli.ts # Main CLI entry point
121
- │ ├── api/
122
- │ └── sylix.ts # Sylix API client
123
- │ ├── context/
124
- │ └── reader.ts # Context reader for codebase
125
- │ ├── commands/
126
- ├── ask.ts # Ask command implementation
127
- │ ├── edit.ts # Edit command implementation
128
- │ │ ├── explain.ts # Explain command implementation
129
- ├── run.ts # Run command implementation
130
- └── config.ts # Config commands
131
- └── utils/
132
- │ └── output.ts # Output formatting utilities
133
- ├── package.json
134
- ├── tsconfig.json
135
- └── README.md
136
- ```
137
-
138
- ## API Configuration
139
-
140
- The configuration is stored at `~/.coworker/config.json`:
141
-
142
- ```json
143
- {
144
- "baseUrl": "https://api.sylix.ai",
145
- "apiKey": "your-api-key",
146
- "defaultModel": "sylix-4"
147
- }
148
- ```
149
-
150
- ## Development
151
-
152
- ### Run in Development Mode
153
-
154
- ```bash
155
- npm run dev -- ask "What does this project do?"
156
- ```
157
-
158
- ### Build
159
-
160
- ```bash
161
- npm run build
162
- ```
163
-
164
- ## Output Formatting
165
-
166
- CoWorker provides beautifully formatted terminal output:
167
-
168
- - **Cyan** - Branding and headers
169
- - **Green** - Success messages
170
- - **Red** - Errors
171
- - **Yellow** - Warnings
172
- - **Code blocks** - Syntax highlighted with line numbers
173
- - **Spinners** - Loading indicators for async operations
174
-
175
- ## Security
176
-
177
- - API keys are stored locally in `~/.coworker/config.json`
178
- - Never commit your config file to version control
179
- - The config file path respects your home directory across platforms
180
-
181
- ## License
182
-
183
- MIT License - Copyright (c) Sylix
184
-
185
- ## Support
186
-
187
- For issues and feature requests, please visit the [GitHub repository](https://github.com/sylix/coworker).
60
+ │ ├── core/ # Agentic Loop & Context Reader
61
+ │ ├── hooks/ # HookEngine (Event Bus)
62
+ ├── session/ # SQLite Session Management
63
+ │ ├── agents/ # Subagent Loader & Runner
64
+ ├── permissions/ # Mode-based Permission Interceptor
65
+ │ ├── tools/ # Native Tools (Bash, Write, LSP, etc.)
66
+ │ ├── memory/ # Persistent Auto Memory
67
+ └── utils/ # Premium UI & Stream Rendering
68
+ ├── .coworker/
69
+ │ ├── agents/ # Custom Agent Definitions (.md)
70
+ │ └── skills/ # Reusable Agent Skills
71
+ └── package.json
72
+ ```
73
+
74
+ ## 🛡 Security & Permissions
75
+ CoWorker implements a multi-layer permission system:
76
+ 1. **Consent Mode**: Always asks before executing destructive commands (Bash, Edit).
77
+ 2. **Read-Only Mode**: Activated via `/explore`.
78
+ 3. **Environment Isolation**: Support for sandboxed browser execution.
79
+
80
+ ## 📄 License
81
+ MIT License - Copyright (c) 2026 Sylix
188
82
 
189
83
  ---
190
-
191
- **CoWorker by Sylix** - Your AI pair programmer in the terminal.
84
+ **CoWorker by Sylix** — The ultimate open-source alternative to Claude Code.
@@ -0,0 +1,59 @@
1
+ export interface SubagentDefinition {
2
+ name: string;
3
+ description: string;
4
+ /** Allowlist of tools this agent can use */
5
+ tools?: string[];
6
+ /** Denylist of tools this agent cannot use */
7
+ disallowedTools?: string[];
8
+ /** Model to use (overrides default) */
9
+ model?: string;
10
+ /** Maximum LLM turns before stopping */
11
+ maxTurns: number;
12
+ /** Permission mode for this agent */
13
+ permissionMode?: 'default' | 'plan' | 'auto';
14
+ /** System prompt body (markdown after frontmatter) */
15
+ systemPrompt: string;
16
+ /** Source file path */
17
+ source: string;
18
+ }
19
+ /**
20
+ * Loads subagent definitions from .coworker/agents/*.md and built-in defaults.
21
+ */
22
+ export declare class SubagentLoader {
23
+ private agents;
24
+ /**
25
+ * Scan both built-in and user-defined agent directories.
26
+ */
27
+ load(): Promise<void>;
28
+ private scanDirectory;
29
+ /**
30
+ * Parse a markdown file with YAML frontmatter into a SubagentDefinition.
31
+ *
32
+ * Expected format:
33
+ * ```
34
+ * ---
35
+ * name: explore
36
+ * description: Read-only codebase search
37
+ * tools: Read, Glob, Grep, LS
38
+ * model: helix-fast
39
+ * maxTurns: 15
40
+ * permissionMode: plan
41
+ * ---
42
+ * You are a fast codebase explorer...
43
+ * ```
44
+ */
45
+ private parseDefinition;
46
+ /**
47
+ * Get a specific agent definition by name.
48
+ */
49
+ get(name: string): SubagentDefinition | undefined;
50
+ /**
51
+ * Get all loaded agent definitions.
52
+ */
53
+ list(): SubagentDefinition[];
54
+ /**
55
+ * Check if an agent exists.
56
+ */
57
+ has(name: string): boolean;
58
+ }
59
+ //# sourceMappingURL=SubagentLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubagentLoader.d.ts","sourceRoot":"","sources":["../../src/agents/SubagentLoader.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,8CAA8C;IAC9C,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,cAAc,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;IAC7C,sDAAsD;IACtD,YAAY,EAAE,MAAM,CAAC;IACrB,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAA8C;IAE5D;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YAcb,aAAa;IAgB3B;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,eAAe;IA+BvB;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAIjD;;OAEG;IACH,IAAI,IAAI,kBAAkB,EAAE;IAI5B;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAG3B"}
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.SubagentLoader = void 0;
37
+ const fs = __importStar(require("fs/promises"));
38
+ const path = __importStar(require("path"));
39
+ /**
40
+ * Loads subagent definitions from .coworker/agents/*.md and built-in defaults.
41
+ */
42
+ class SubagentLoader {
43
+ constructor() {
44
+ this.agents = new Map();
45
+ }
46
+ /**
47
+ * Scan both built-in and user-defined agent directories.
48
+ */
49
+ async load() {
50
+ // 1. Load built-in defaults
51
+ const builtInDir = path.join(__dirname, 'defaults');
52
+ await this.scanDirectory(builtInDir);
53
+ // 2. Load user/project agents (can override built-ins)
54
+ const userDir = path.join(process.cwd(), '.coworker', 'agents');
55
+ await this.scanDirectory(userDir);
56
+ if (process.env.CW_VERBOSE) {
57
+ console.log(`[SubagentLoader] Loaded ${this.agents.size} agent definitions`);
58
+ }
59
+ }
60
+ async scanDirectory(dirPath) {
61
+ try {
62
+ const files = await fs.readdir(dirPath);
63
+ for (const file of files) {
64
+ if (!file.endsWith('.md'))
65
+ continue;
66
+ const content = await fs.readFile(path.join(dirPath, file), 'utf8');
67
+ const def = this.parseDefinition(content, path.join(dirPath, file));
68
+ if (def) {
69
+ this.agents.set(def.name, def);
70
+ }
71
+ }
72
+ }
73
+ catch {
74
+ // Directory doesn't exist — skip silently
75
+ }
76
+ }
77
+ /**
78
+ * Parse a markdown file with YAML frontmatter into a SubagentDefinition.
79
+ *
80
+ * Expected format:
81
+ * ```
82
+ * ---
83
+ * name: explore
84
+ * description: Read-only codebase search
85
+ * tools: Read, Glob, Grep, LS
86
+ * model: helix-fast
87
+ * maxTurns: 15
88
+ * permissionMode: plan
89
+ * ---
90
+ * You are a fast codebase explorer...
91
+ * ```
92
+ */
93
+ parseDefinition(content, source) {
94
+ const yamlMatch = content.match(/^---\n([\s\S]*?)\n---/);
95
+ if (!yamlMatch)
96
+ return null;
97
+ const rawYaml = yamlMatch[1];
98
+ const body = content.replace(yamlMatch[0], '').trim();
99
+ const get = (key) => {
100
+ const match = rawYaml.match(new RegExp(`^${key}:\\s*(.+)`, 'm'));
101
+ return match ? match[1].trim() : undefined;
102
+ };
103
+ const name = get('name');
104
+ if (!name)
105
+ return null;
106
+ const toolsStr = get('tools');
107
+ const disallowedStr = get('disallowedTools');
108
+ return {
109
+ name,
110
+ description: get('description') || `${name} subagent`,
111
+ tools: toolsStr ? toolsStr.split(',').map(t => t.trim()) : undefined,
112
+ disallowedTools: disallowedStr ? disallowedStr.split(',').map(t => t.trim()) : undefined,
113
+ model: get('model'),
114
+ maxTurns: parseInt(get('maxTurns') || '20', 10),
115
+ permissionMode: get('permissionMode') || 'default',
116
+ systemPrompt: body,
117
+ source,
118
+ };
119
+ }
120
+ /**
121
+ * Get a specific agent definition by name.
122
+ */
123
+ get(name) {
124
+ return this.agents.get(name);
125
+ }
126
+ /**
127
+ * Get all loaded agent definitions.
128
+ */
129
+ list() {
130
+ return Array.from(this.agents.values());
131
+ }
132
+ /**
133
+ * Check if an agent exists.
134
+ */
135
+ has(name) {
136
+ return this.agents.has(name);
137
+ }
138
+ }
139
+ exports.SubagentLoader = SubagentLoader;
140
+ //# sourceMappingURL=SubagentLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubagentLoader.js","sourceRoot":"","sources":["../../src/agents/SubagentLoader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,2CAA6B;AA0B7B;;GAEG;AACH,MAAa,cAAc;IAA3B;QACU,WAAM,GAAo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AAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS;YACxF,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC;YACnB,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC;YAC/C,cAAc,EAAG,GAAG,CAAC,gBAAgB,CAAS,IAAI,SAAS;YAC3D,YAAY,EAAE,IAAI;YAClB,MAAM;SACP,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAI;QACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF;AAvGD,wCAuGC"}
@@ -0,0 +1,15 @@
1
+ import { SubagentDefinition } from './SubagentLoader';
2
+ /**
3
+ * Result of a subagent execution.
4
+ */
5
+ export interface SubagentResult {
6
+ output: string;
7
+ turnsUsed: number;
8
+ toolsCalled: string[];
9
+ success: boolean;
10
+ }
11
+ /**
12
+ * Run a scoped subagent with tool/model/turn restrictions.
13
+ */
14
+ export declare function runSubagent(definition: SubagentDefinition, task: string, parentCwd?: string): Promise<SubagentResult>;
15
+ //# sourceMappingURL=SubagentRunner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubagentRunner.d.ts","sourceRoot":"","sources":["../../src/agents/SubagentRunner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAStD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;CAClB;AAQD;;GAEG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,kBAAkB,EAC9B,IAAI,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,cAAc,CAAC,CA4EzB"}
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.runSubagent = runSubagent;
37
+ const CoWorkerAgent_1 = require("../core/CoWorkerAgent");
38
+ /**
39
+ * Tracks the current nesting depth to prevent infinite subagent recursion.
40
+ */
41
+ let currentDepth = 0;
42
+ const MAX_DEPTH = 1; // Subagents cannot spawn sub-subagents
43
+ /**
44
+ * Run a scoped subagent with tool/model/turn restrictions.
45
+ */
46
+ async function runSubagent(definition, task, parentCwd) {
47
+ if (currentDepth >= MAX_DEPTH) {
48
+ return {
49
+ output: '[SUBAGENT ERROR] Cannot spawn sub-subagents (max nesting depth reached).',
50
+ turnsUsed: 0,
51
+ toolsCalled: [],
52
+ success: false,
53
+ };
54
+ }
55
+ currentDepth++;
56
+ const result = {
57
+ output: '',
58
+ turnsUsed: 0,
59
+ toolsCalled: [],
60
+ success: true,
61
+ };
62
+ try {
63
+ // Create a scoped agent with the definition's settings
64
+ const options = {
65
+ model: definition.model || 'helix-1.2',
66
+ role: 'General',
67
+ cwd: parentCwd || process.cwd(),
68
+ };
69
+ const agent = new CoWorkerAgent_1.CoWorkerAgent(options);
70
+ await agent.boot();
71
+ // Apply permission mode
72
+ if (definition.permissionMode === 'plan') {
73
+ agent.permissions = new (await Promise.resolve().then(() => __importStar(require('../permissions/PermissionInterceptor')))).PermissionInterceptor({
74
+ mode: 'plan',
75
+ });
76
+ }
77
+ // Override system prompt with subagent-specific prompt
78
+ if (definition.systemPrompt) {
79
+ agent.systemPrompt = definition.systemPrompt +
80
+ `\n\n## Constraints\n` +
81
+ `- You are a ${definition.name} subagent\n` +
82
+ `- Max turns: ${definition.maxTurns}\n` +
83
+ (definition.tools ? `- You may ONLY use these tools: ${definition.tools.join(', ')}\n` : '') +
84
+ (definition.disallowedTools ? `- You may NOT use these tools: ${definition.disallowedTools.join(', ')}\n` : '') +
85
+ `- You CANNOT spawn sub-subagents\n` +
86
+ `- Stay focused on the task. Be concise in your responses.\n`;
87
+ }
88
+ // Execute with turn limiting
89
+ let turnCount = 0;
90
+ for await (const chunk of agent.chat(task)) {
91
+ result.output += chunk;
92
+ // Track tool calls by checking for the tool indicator
93
+ if (chunk.includes('◈')) {
94
+ turnCount++;
95
+ const toolMatch = chunk.match(/◈\s+(\S+)/);
96
+ if (toolMatch)
97
+ result.toolsCalled.push(toolMatch[1]);
98
+ }
99
+ // Enforce max turns
100
+ if (turnCount >= definition.maxTurns) {
101
+ result.output += `\n[SUBAGENT] Reached max turns limit (${definition.maxTurns}). Stopping.`;
102
+ break;
103
+ }
104
+ }
105
+ result.turnsUsed = turnCount;
106
+ }
107
+ catch (e) {
108
+ result.output = `[SUBAGENT ERROR] ${e.message}`;
109
+ result.success = false;
110
+ }
111
+ finally {
112
+ currentDepth--;
113
+ }
114
+ return result;
115
+ }
116
+ //# sourceMappingURL=SubagentRunner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubagentRunner.js","sourceRoot":"","sources":["../../src/agents/SubagentRunner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,kCAgFC;AA7GD,yDAAuE;AAoBvE;;GAEG;AACH,IAAI,YAAY,GAAG,CAAC,CAAC;AACrB,MAAM,SAAS,GAAG,CAAC,CAAC,CAAC,uCAAuC;AAE5D;;GAEG;AACI,KAAK,UAAU,WAAW,CAC/B,UAA8B,EAC9B,IAAY,EACZ,SAAkB;IAElB,IAAI,YAAY,IAAI,SAAS,EAAE,CAAC;QAC9B,OAAO;YACL,MAAM,EAAE,0EAA0E;YAClF,SAAS,EAAE,CAAC;YACZ,WAAW,EAAE,EAAE;YACf,OAAO,EAAE,KAAK;SACf,CAAC;IACJ,CAAC;IAED,YAAY,EAAE,CAAC;IACf,MAAM,MAAM,GAAmB;QAC7B,MAAM,EAAE,EAAE;QACV,SAAS,EAAE,CAAC;QACZ,WAAW,EAAE,EAAE;QACf,OAAO,EAAE,IAAI;KACd,CAAC;IAEF,IAAI,CAAC;QACH,uDAAuD;QACvD,MAAM,OAAO,GAAoB;YAC/B,KAAK,EAAE,UAAU,CAAC,KAAK,IAAI,WAAW;YACtC,IAAI,EAAE,SAAS;Y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,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;gBAC3C,IAAI,SAAS;oBAAE,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;YACvD,CAAC;YAED,oBAAoB;YACpB,IAAI,SAAS,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;gBACrC,MAAM,CAAC,MAAM,IAAI,yCAAyC,UAAU,CAAC,QAAQ,cAAc,CAAC;gBAC5F,MAAM;YACR,CAAC;QACH,CAAC;QAED,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,MAAM,CAAC,MAAM,GAAG,oBAAoB,CAAC,CAAC,OAAO,EAAE,CAAC;QAChD,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC;IACzB,CAAC;YAAS,CAAC;QACT,YAAY,EAAE,CAAC;IACjB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AA0VA,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAmLvD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AA+UA,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAmLvD"}
package/dist/cli/index.js CHANGED
@@ -258,15 +258,6 @@ async function runInteractiveChat(agent, opts) {
258
258
  continue;
259
259
  }
260
260
  // ── Regular chat message ──
261
- // Clear the input frame drawn by ask() (bottom border + status)
262
- process.stdout.write('\x1b[1A\x1b[2K'); // clear status line
263
- process.stdout.write('\x1b[1A\x1b[2K'); // clear bottom border
264
- process.stdout.write('\x1b[1A\x1b[2K'); // clear input line
265
- process.stdout.write('\x1b[1A\x1b[2K'); // clear top border
266
- // Show user message above
267
- console.log('');
268
- console.log(` ${output_1.theme.dim('you')} ${output_1.theme.brand('\u203a')} ${input}`);
269
- console.log('');
270
261
  // Thinking animation
271
262
  const thinking = new output_1.ThinkingAnimation();
272
263
  thinking.start();