visionclaw 0.1.82 → 0.1.84

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 (49) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE +200 -0
  3. package/README.md +14 -4
  4. package/dist/agent/activity-tracker.d.ts +7 -0
  5. package/dist/agent/activity-tracker.d.ts.map +1 -1
  6. package/dist/agent/activity-tracker.js +8 -0
  7. package/dist/agent/activity-tracker.js.map +1 -1
  8. package/dist/agent/command-handlers.d.ts +22 -0
  9. package/dist/agent/command-handlers.d.ts.map +1 -0
  10. package/dist/agent/command-handlers.js +127 -0
  11. package/dist/agent/command-handlers.js.map +1 -0
  12. package/dist/agent/loop.d.ts.map +1 -1
  13. package/dist/agent/loop.js +10 -90
  14. package/dist/agent/loop.js.map +1 -1
  15. package/dist/agent/session.d.ts +6 -0
  16. package/dist/agent/session.d.ts.map +1 -1
  17. package/dist/agent/session.js +3 -0
  18. package/dist/agent/session.js.map +1 -1
  19. package/dist/agent/status.d.ts +14 -0
  20. package/dist/agent/status.d.ts.map +1 -0
  21. package/dist/agent/status.js +230 -0
  22. package/dist/agent/status.js.map +1 -0
  23. package/dist/agent/stream-handler.d.ts.map +1 -1
  24. package/dist/agent/stream-handler.js +6 -0
  25. package/dist/agent/stream-handler.js.map +1 -1
  26. package/dist/channels/interface.d.ts +17 -0
  27. package/dist/channels/interface.d.ts.map +1 -1
  28. package/dist/channels/manager.d.ts.map +1 -1
  29. package/dist/channels/manager.js +6 -0
  30. package/dist/channels/manager.js.map +1 -1
  31. package/dist/channels/telegram.d.ts.map +1 -1
  32. package/dist/channels/telegram.js +21 -0
  33. package/dist/channels/telegram.js.map +1 -1
  34. package/dist/obs/server.d.ts.map +1 -1
  35. package/dist/obs/server.js +13 -0
  36. package/dist/obs/server.js.map +1 -1
  37. package/dist/obs/ui.d.ts.map +1 -1
  38. package/dist/obs/ui.js +67 -0
  39. package/dist/obs/ui.js.map +1 -1
  40. package/dist/onboarding/index.js +30 -29
  41. package/dist/onboarding/index.js.map +1 -1
  42. package/dist/onboarding/macos-permissions.d.ts +8 -3
  43. package/dist/onboarding/macos-permissions.d.ts.map +1 -1
  44. package/dist/onboarding/macos-permissions.js +12 -6
  45. package/dist/onboarding/macos-permissions.js.map +1 -1
  46. package/dist/onboarding/prepare-mac.d.ts.map +1 -1
  47. package/dist/onboarding/prepare-mac.js +58 -2
  48. package/dist/onboarding/prepare-mac.js.map +1 -1
  49. package/package.json +25 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ## [0.1.84](https://github.com/babelcloud/visionclaw/compare/v0.1.83...v0.1.84) (2026-03-04)
2
+
3
+
4
+ ### Features
5
+
6
+ * **activity-tracker:** add TodoItem interface and command handlers for todos ([ba2b36d](https://github.com/babelcloud/visionclaw/commit/ba2b36dc38041d251132097a3164c9263187a05b))
7
+ * **onboarding:** add wallpaper screen saver management functions ([d0685e7](https://github.com/babelcloud/visionclaw/commit/d0685e74f91eb4c3bf5a51a369ee1a388d02629b))
8
+ * **onboarding:** update macOS permission checks for Accessibility and Automation ([c9f8297](https://github.com/babelcloud/visionclaw/commit/c9f82973000a428914daa5bed74be2bfa5b976ca))
9
+ * **setup:** update project configuration and documentation ([a063d52](https://github.com/babelcloud/visionclaw/commit/a063d5270950a4fd2590f6d53750c8cf1193a486))
10
+
11
+
12
+
13
+ ## [0.1.83](https://github.com/babelcloud/visionclaw/compare/v0.1.82...v0.1.83) (2026-03-03)
14
+
15
+
16
+ ### Features
17
+
18
+ * **onboarding:** enhance setup process with SerpAPI and Telegram bot token prompts ([e782c63](https://github.com/babelcloud/visionclaw/commit/e782c63b24457d98aed936578b3a5a3b5b091167))
19
+
20
+
21
+
1
22
  ## [0.1.82](https://github.com/babelcloud/visionclaw/compare/v0.1.81...v0.1.82) (2026-03-03)
2
23
 
3
24
 
package/LICENSE ADDED
@@ -0,0 +1,200 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to the Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by the Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding any notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. Please also get an
186
+ "application/vnd.apache" MIME type registered for your file format.
187
+
188
+ Copyright 2025-2026 BabelCloud
189
+
190
+ Licensed under the Apache License, Version 2.0 (the "License");
191
+ you may not use this file except in compliance with the License.
192
+ You may obtain a copy of the License at
193
+
194
+ http://www.apache.org/licenses/LICENSE-2.0
195
+
196
+ Unless required by applicable law or agreed to in writing, software
197
+ distributed under the License is distributed on an "AS IS" BASIS,
198
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
199
+ See the License for the specific language governing permissions and
200
+ limitations under the License.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # VisionClaw
2
2
 
3
- A personal assistant agent that runs on your desktop (macOS/Windows). It receives command messages from pre-configured channels (Gmail, Telegram, Discord) and executes tasks autonomously using desktop control and browser automation. Results are sent back through the same channel.
3
+ A personal assistant agent that runs on your desktop (macOS). It receives command messages from pre-configured channels (Gmail, Telegram, Discord) and executes tasks autonomously using desktop control and browser automation. Results are sent back through the same channel.
4
+
5
+ > **Platform note**: Desktop automation (mouse, keyboard, screenshots) requires macOS with `cliclick` installed. Browser automation and channel integrations work cross-platform, but full computer-use features are macOS-only.
4
6
 
5
7
  ## Features
6
8
 
@@ -37,7 +39,7 @@ gui/ # Electron desktop GUI
37
39
 
38
40
  ## Prerequisites
39
41
 
40
- - Node.js >= 20
42
+ - Node.js >= 24.12.0
41
43
  - An Anthropic API key
42
44
  - A dedicated Gmail account for the agent
43
45
  - Google Cloud OAuth2 credentials (Client ID + Secret) with Gmail and Calendar API enabled
@@ -90,9 +92,9 @@ This is controlled via **advanced config** (not asked during onboarding):
90
92
  }
91
93
  ```
92
94
 
93
- ## GUI
95
+ ## GUI (Work in Progress)
94
96
 
95
- A desktop GUI (Electron) is available for configuration and monitoring:
97
+ > **Note**: The Electron GUI is under development and not yet functional. Use the CLI for now.
96
98
 
97
99
  ```bash
98
100
  cd gui
@@ -127,3 +129,11 @@ pnpm start
127
129
  | `computer_use_key` | Press a key or key combination |
128
130
  | `computer_use_scroll` | Scroll at a target location |
129
131
  | `computer_use_drag` | Drag from one element to another |
132
+
133
+ ## Contributing
134
+
135
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.
136
+
137
+ ## License
138
+
139
+ [Apache License 2.0](LICENSE)
@@ -1,3 +1,7 @@
1
+ export interface TodoItem {
2
+ content: string;
3
+ status: "pending" | "in_progress" | "completed";
4
+ }
1
5
  /**
2
6
  * Maintains a rolling summary of the primary agent's current activity.
3
7
  * Read by the fast responder to give context-aware quick replies when the
@@ -8,12 +12,15 @@ export declare class ActivityTracker {
8
12
  private recentActions;
9
13
  private lastAssistantText;
10
14
  private taskStartedAt;
15
+ private lastTodos;
11
16
  private readonly maxActions;
12
17
  constructor(maxActions?: number);
13
18
  startTask(description: string): void;
14
19
  recordAssistantText(text: string): void;
15
20
  recordToolCall(name: string, inputSummary: string): void;
16
21
  recordToolResult(name: string, outputSummary: string): void;
22
+ recordTodos(todos: TodoItem[]): void;
23
+ getTodos(): TodoItem[];
17
24
  /**
18
25
  * Produce a concise summary of the agent's current activity for the fast
19
26
  * responder's system context.
@@ -1 +1 @@
1
- {"version":3,"file":"activity-tracker.d.ts","sourceRoot":"","sources":["../../src/agent/activity-tracker.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,sBAAsB,CAAM;IACpC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,iBAAiB,CAAM;IAC/B,OAAO,CAAC,aAAa,CAAuB;IAE5C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAExB,UAAU,SAAK;IAI3B,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAQpC,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIvC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAOxD,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI;IAO3D;;;OAGG;IACH,UAAU,IAAI,MAAM;IA0BpB,KAAK,IAAI,IAAI;IAOb,OAAO,CAAC,IAAI;CAMb"}
1
+ {"version":3,"file":"activity-tracker.d.ts","sourceRoot":"","sources":["../../src/agent/activity-tracker.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,SAAS,GAAG,aAAa,GAAG,WAAW,CAAC;CACjD;AAED;;;;GAIG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,sBAAsB,CAAM;IACpC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,iBAAiB,CAAM;IAC/B,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,SAAS,CAAkB;IAEnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAExB,UAAU,SAAK;IAI3B,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAQpC,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIvC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAOxD,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI;IAO3D,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI;IAIpC,QAAQ,IAAI,QAAQ,EAAE;IAItB;;;OAGG;IACH,UAAU,IAAI,MAAM;IA0BpB,KAAK,IAAI,IAAI;IAQb,OAAO,CAAC,IAAI;CAMb"}
@@ -9,6 +9,7 @@ export class ActivityTracker {
9
9
  recentActions = [];
10
10
  lastAssistantText = "";
11
11
  taskStartedAt = null;
12
+ lastTodos = [];
12
13
  maxActions;
13
14
  constructor(maxActions = 15) {
14
15
  this.maxActions = maxActions;
@@ -35,6 +36,12 @@ export class ActivityTracker {
35
36
  : outputSummary;
36
37
  this.push(`← ${name}: ${truncated}`);
37
38
  }
39
+ recordTodos(todos) {
40
+ this.lastTodos = todos;
41
+ }
42
+ getTodos() {
43
+ return this.lastTodos;
44
+ }
38
45
  /**
39
46
  * Produce a concise summary of the agent's current activity for the fast
40
47
  * responder's system context.
@@ -66,6 +73,7 @@ export class ActivityTracker {
66
73
  this.recentActions = [];
67
74
  this.lastAssistantText = "";
68
75
  this.taskStartedAt = null;
76
+ this.lastTodos = [];
69
77
  }
70
78
  push(entry) {
71
79
  this.recentActions.push(entry);
@@ -1 +1 @@
1
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AAM,GAAG,GAAG;gBACjD,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG;gBAChD,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,uBAAuB,OAAO,EAAE,CAAC,CAAC;QAC/C,CAAC;QAED,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClC,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAC9B,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,aAAa;gBAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC3D,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,KAAK;QACH,IAAI,CAAC,sBAAsB,GAAG,EAAE,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;QACxB,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;IACtB,CAAC;IAEO,IAAI,CAAC,KAAa;QACxB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/B,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;YAChD,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAC7B,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,22 @@
1
+ import type { VisionClawConfig, OwnerConfig } from "../config/types.js";
2
+ import type { ChannelManager } from "../channels/manager.js";
3
+ import type { MessageQueue } from "../channels/queue.js";
4
+ import type { SessionManager } from "./session-manager.js";
5
+ import type { AgentState } from "./state.js";
6
+ export interface CommandHandlerDeps {
7
+ agentState: AgentState;
8
+ channelManager: ChannelManager;
9
+ messageQueue: MessageQueue;
10
+ session: SessionManager;
11
+ config: VisionClawConfig;
12
+ ownerConfig: OwnerConfig;
13
+ obsClose?: () => Promise<void>;
14
+ }
15
+ /**
16
+ * Register all slash-command event handlers on the channel manager.
17
+ * These handle /stop, /sleep, /console, /dual-session, /restart,
18
+ * /tunnel, /help, and /status — responding directly without entering
19
+ * the message queue.
20
+ */
21
+ export declare function registerCommandHandlers(deps: CommandHandlerDeps): void;
22
+ //# sourceMappingURL=command-handlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-handlers.d.ts","sourceRoot":"","sources":["../../src/agent/command-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAWxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAK7C,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,UAAU,CAAC;IACvB,cAAc,EAAE,cAAc,CAAC;IAC/B,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,cAAc,CAAC;IACxB,MAAM,EAAE,gBAAgB,CAAC;IACzB,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAoKtE"}
@@ -0,0 +1,127 @@
1
+ import { saveOwnerConfig } from "../config/index.js";
2
+ import { logger } from "../logger.js";
3
+ import { buildHelpText, buildStatusReport } from "./status.js";
4
+ /**
5
+ * Register all slash-command event handlers on the channel manager.
6
+ * These handle /stop, /sleep, /console, /dual-session, /restart,
7
+ * /tunnel, /help, and /status — responding directly without entering
8
+ * the message queue.
9
+ */
10
+ export function registerCommandHandlers(deps) {
11
+ const { agentState, channelManager, messageQueue, session, config, ownerConfig } = deps;
12
+ channelManager.on("stop_request", (req) => {
13
+ if (agentState.busy && !agentState.stopRequested) {
14
+ agentState.requestStop();
15
+ logger.system(`Agent stop requested via ${req.channel} by ${req.sender}`);
16
+ channelManager
17
+ .sendMessage(req.channel, req.sender, "Stop signal sent. The agent will finish its current step and stop.")
18
+ .catch((err) => {
19
+ logger.warn(`Failed to send stop confirmation: ${err instanceof Error ? err.message : String(err)}`);
20
+ });
21
+ }
22
+ else {
23
+ channelManager
24
+ .sendMessage(req.channel, req.sender, "The agent is not currently working.")
25
+ .catch((err) => {
26
+ logger.warn(`Failed to send stop reply: ${err instanceof Error ? err.message : String(err)}`);
27
+ });
28
+ }
29
+ });
30
+ channelManager.on("sleep_request", (req) => {
31
+ const minutes = Math.max(1, Math.min(1440, req.minutes));
32
+ const oldMs = ownerConfig.heartbeatIntervalMs;
33
+ ownerConfig.heartbeatIntervalMs = minutes * 60 * 1000;
34
+ saveOwnerConfig(ownerConfig);
35
+ logger.system(`Sleep interval changed from ${oldMs / 60000}m to ${minutes}m by ${req.sender} via ${req.channel}`);
36
+ channelManager
37
+ .sendMessage(req.channel, req.sender, `Sleep interval changed from ${oldMs / 60000}m to ${minutes}m.`)
38
+ .catch((err) => {
39
+ logger.warn(`Failed to send sleep confirmation: ${err instanceof Error ? err.message : String(err)}`);
40
+ });
41
+ });
42
+ channelManager.on("console_request", (req) => {
43
+ const url = agentState.consoleUrl;
44
+ const reply = url
45
+ ? `${url}/console`
46
+ : "Console URL is not available yet (tunnel may still be starting).";
47
+ channelManager
48
+ .sendMessage(req.channel, req.sender, reply)
49
+ .catch((err) => {
50
+ logger.warn(`Failed to send console URL: ${err instanceof Error ? err.message : String(err)}`);
51
+ });
52
+ });
53
+ channelManager.on("dual_session_request", (req) => {
54
+ const oldValue = ownerConfig.dualSessionEnabled;
55
+ ownerConfig.dualSessionEnabled = req.enabled;
56
+ saveOwnerConfig(ownerConfig);
57
+ session.setDualSessionEnabled(req.enabled);
58
+ const status = req.enabled ? "enabled" : "disabled";
59
+ logger.system(`Dual session ${status} by ${req.sender} via ${req.channel} (was: ${oldValue ? "enabled" : "disabled"})`);
60
+ channelManager
61
+ .sendMessage(req.channel, req.sender, `Dual session mode ${status}.`)
62
+ .catch((err) => {
63
+ logger.warn(`Failed to send dual-session confirmation: ${err instanceof Error ? err.message : String(err)}`);
64
+ });
65
+ });
66
+ channelManager.on("restart_request", (req) => {
67
+ logger.system(`Restart requested by ${req.sender} via ${req.channel}`);
68
+ channelManager
69
+ .sendMessage(req.channel, req.sender, "Restarting agent in 5 seconds...")
70
+ .catch((err) => {
71
+ logger.warn(`Failed to send restart confirmation: ${err instanceof Error ? err.message : String(err)}`);
72
+ });
73
+ const doRestart = async () => {
74
+ if (deps.obsClose)
75
+ await deps.obsClose();
76
+ const { scheduleRestart } = await import("../utils/restart.js");
77
+ scheduleRestart(5_000);
78
+ };
79
+ doRestart().catch((err) => {
80
+ logger.err(`Failed to schedule restart: ${err instanceof Error ? err.message : String(err)}`);
81
+ });
82
+ });
83
+ channelManager.on("tunnel_request", (req) => {
84
+ logger.system(`Tunnel restart requested by ${req.sender} via ${req.channel}`);
85
+ if (!agentState.restartTunnel) {
86
+ channelManager
87
+ .sendMessage(req.channel, req.sender, "Tunnel is not configured.")
88
+ .catch((err) => {
89
+ logger.warn(`Failed to send tunnel reply: ${err instanceof Error ? err.message : String(err)}`);
90
+ });
91
+ return;
92
+ }
93
+ channelManager
94
+ .sendMessage(req.channel, req.sender, "Restarting tunnel...")
95
+ .catch((err) => {
96
+ logger.warn(`Failed to send tunnel reply: ${err instanceof Error ? err.message : String(err)}`);
97
+ });
98
+ agentState.restartTunnel().catch((err) => {
99
+ logger.warn(`Failed to restart tunnel: ${err instanceof Error ? err.message : String(err)}`);
100
+ });
101
+ });
102
+ channelManager.on("help_request", (req) => {
103
+ channelManager
104
+ .sendMessage(req.channel, req.sender, buildHelpText())
105
+ .catch((err) => {
106
+ logger.warn(`Failed to send help reply: ${err instanceof Error ? err.message : String(err)}`);
107
+ });
108
+ });
109
+ channelManager.on("status_request", (req) => {
110
+ logger.system(`Status requested by ${req.sender} via ${req.channel}${req.forceRefresh ? " (refresh)" : ""}`);
111
+ const doStatus = async () => {
112
+ const report = await buildStatusReport({
113
+ agentState,
114
+ sessionManager: session,
115
+ messageQueue,
116
+ config,
117
+ ownerConfig,
118
+ forceRefresh: req.forceRefresh,
119
+ });
120
+ await channelManager.sendMessage(req.channel, req.sender, report);
121
+ };
122
+ doStatus().catch((err) => {
123
+ logger.warn(`Failed to send status reply: ${err instanceof Error ? err.message : String(err)}`);
124
+ });
125
+ });
126
+ }
127
+ //# sourceMappingURL=command-handlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-handlers.js","sourceRoot":"","sources":["../../src/agent/command-handlers.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAY/D;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAwB;IAC9D,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;IAExF,cAAc,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,GAAgB,EAAE,EAAE;QACrD,IAAI,UAAU,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;YACjD,UAAU,CAAC,WAAW,EAAE,CAAC;YACzB,MAAM,CAAC,MAAM,CAAC,4BAA4B,GAAG,CAAC,OAAO,OAA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AAE,EAAE;YAChC,MAAM,CAAC,IAAI,CACT,gCAAgC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CACnF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../src/agent/loop.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAkC3D,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAyC3C;;GAEG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,gBAAgB,EACxB,OAAO,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,GACzF,OAAO,CAAC,IAAI,CAAC,CA4kBf"}
1
+ {"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../src/agent/loop.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AA4B3D,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAyC3C;;GAEG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,gBAAgB,EACxB,OAAO,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,GACzF,OAAO,CAAC,IAAI,CAAC,CAkdf"}
@@ -6,7 +6,7 @@ import { MessageQueue } from "../channels/queue.js";
6
6
  import { ChannelManager } from "../channels/manager.js";
7
7
  import { ActivityTracker } from "./activity-tracker.js";
8
8
  import { shouldNotifyUpdate } from "../utils/version-check.js";
9
- import { loadOwnerConfig, saveOwnerConfig, getScreenshotsDir, } from "../config/index.js";
9
+ import { loadOwnerConfig, getScreenshotsDir, } from "../config/index.js";
10
10
  import { logger } from "../logger.js";
11
11
  import { cleanOldScreenshots } from "../tools/screenshot.js";
12
12
  import { initAgentState } from "./state.js";
@@ -15,6 +15,7 @@ import { InterruptHandler } from "./interrupt-handler.js";
15
15
  import { processAgentStream } from "./stream-handler.js";
16
16
  import { gatherWakeContext } from "./gather-context.js";
17
17
  import { ScreenshotInjector } from "./screenshot-injector.js";
18
+ import { registerCommandHandlers } from "./command-handlers.js";
18
19
  export { getAgentState } from "./state.js";
19
20
  const FATAL_PATTERNS = /\b(401|403|authentication|billing|unauthorized|forbidden|api.?key)\b/i;
20
21
  const RETRYABLE_PATTERNS = /\b(ECONNREFUSED|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|ECONNRESET|fetch failed|socket hang up|429|529|rate.?limit|overloaded|throttl|timeout|50[0234]|service.?unavailable|bad.?gateway|internal.?server)\b/i;
@@ -147,95 +148,14 @@ export async function startAgentLoop(config, options) {
147
148
  }
148
149
  });
149
150
  // --- Channel command handlers ---
150
- channelManager.on("stop_request", (req) => {
151
- if (agentState.busy && !agentState.stopRequested) {
152
- agentState.requestStop();
153
- logger.system(`Agent stop requested via ${req.channel} by ${req.sender}`);
154
- channelManager
155
- .sendMessage(req.channel, req.sender, "Stop signal sent. The agent will finish its current step and stop.")
156
- .catch((err) => {
157
- logger.warn(`Failed to send stop confirmation: ${err instanceof Error ? err.message : String(err)}`);
158
- });
159
- }
160
- else {
161
- channelManager
162
- .sendMessage(req.channel, req.sender, "The agent is not currently working.")
163
- .catch((err) => {
164
- logger.warn(`Failed to send stop reply: ${err instanceof Error ? err.message : String(err)}`);
165
- });
166
- }
167
- });
168
- channelManager.on("sleep_request", (req) => {
169
- const minutes = Math.max(1, Math.min(1440, req.minutes));
170
- const oldMs = ownerConfig.heartbeatIntervalMs;
171
- ownerConfig.heartbeatIntervalMs = minutes * 60 * 1000;
172
- saveOwnerConfig(ownerConfig);
173
- logger.system(`Sleep interval changed from ${oldMs / 60000}m to ${minutes}m by ${req.sender} via ${req.channel}`);
174
- channelManager
175
- .sendMessage(req.channel, req.sender, `Sleep interval changed from ${oldMs / 60000}m to ${minutes}m.`)
176
- .catch((err) => {
177
- logger.warn(`Failed to send sleep confirmation: ${err instanceof Error ? err.message : String(err)}`);
178
- });
179
- });
180
- channelManager.on("console_request", (req) => {
181
- const url = agentState.consoleUrl;
182
- const reply = url
183
- ? `${url}/console`
184
- : "Console URL is not available yet (tunnel may still be starting).";
185
- channelManager
186
- .sendMessage(req.channel, req.sender, reply)
187
- .catch((err) => {
188
- logger.warn(`Failed to send console URL: ${err instanceof Error ? err.message : String(err)}`);
189
- });
190
- });
191
- channelManager.on("dual_session_request", (req) => {
192
- const oldValue = ownerConfig.dualSessionEnabled;
193
- ownerConfig.dualSessionEnabled = req.enabled;
194
- saveOwnerConfig(ownerConfig);
195
- session.setDualSessionEnabled(req.enabled);
196
- const status = req.enabled ? "enabled" : "disabled";
197
- logger.system(`Dual session ${status} by ${req.sender} via ${req.channel} (was: ${oldValue ? "enabled" : "disabled"})`);
198
- channelManager
199
- .sendMessage(req.channel, req.sender, `Dual session mode ${status}.`)
200
- .catch((err) => {
201
- logger.warn(`Failed to send dual-session confirmation: ${err instanceof Error ? err.message : String(err)}`);
202
- });
203
- });
204
- channelManager.on("restart_request", (req) => {
205
- logger.system(`Restart requested by ${req.sender} via ${req.channel}`);
206
- channelManager
207
- .sendMessage(req.channel, req.sender, "Restarting agent in 5 seconds...")
208
- .catch((err) => {
209
- logger.warn(`Failed to send restart confirmation: ${err instanceof Error ? err.message : String(err)}`);
210
- });
211
- const doRestart = async () => {
212
- if (options?.obsClose)
213
- await options.obsClose();
214
- const { scheduleRestart } = await import("../utils/restart.js");
215
- scheduleRestart(5_000);
216
- };
217
- doRestart().catch((err) => {
218
- logger.err(`Failed to schedule restart: ${err instanceof Error ? err.message : String(err)}`);
219
- });
220
- });
221
- channelManager.on("tunnel_request", (req) => {
222
- logger.system(`Tunnel restart requested by ${req.sender} via ${req.channel}`);
223
- if (!agentState.restartTunnel) {
224
- channelManager
225
- .sendMessage(req.channel, req.sender, "Tunnel is not configured.")
226
- .catch((err) => {
227
- logger.warn(`Failed to send tunnel reply: ${err instanceof Error ? err.message : String(err)}`);
228
- });
229
- return;
230
- }
231
- channelManager
232
- .sendMessage(req.channel, req.sender, "Restarting tunnel...")
233
- .catch((err) => {
234
- logger.warn(`Failed to send tunnel reply: ${err instanceof Error ? err.message : String(err)}`);
235
- });
236
- agentState.restartTunnel().catch((err) => {
237
- logger.warn(`Failed to restart tunnel: ${err instanceof Error ? err.message : String(err)}`);
238
- });
151
+ registerCommandHandlers({
152
+ agentState,
153
+ channelManager,
154
+ messageQueue,
155
+ session,
156
+ config,
157
+ ownerConfig,
158
+ obsClose: options?.obsClose,
239
159
  });
240
160
  logger.system("Agent loop started. Waiting for messages or heartbeat...");
241
161
  // --- Error handling / retry state ---