@tyvm/knowhow 0.0.108 → 0.0.109
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -0
- package/package.json +9 -4
- package/scripts/publish.sh +86 -0
- package/src/agents/base/base.ts +10 -0
- package/src/agents/tools/execCommand.ts +49 -6
- package/src/agents/tools/index.ts +0 -1
- package/src/agents/tools/list.ts +0 -2
- package/src/chat/CliChatService.ts +10 -1
- package/src/chat/modules/AgentModule.ts +55 -30
- package/src/chat/modules/SessionsModule.ts +7 -2
- package/src/chat/renderer/CompactRenderer.ts +20 -0
- package/src/chat/renderer/ConsoleRenderer.ts +19 -0
- package/src/chat/renderer/FancyRenderer.ts +19 -0
- package/src/chat/renderer/types.ts +11 -0
- package/src/cli.ts +91 -659
- package/src/clients/anthropic.ts +17 -16
- package/src/clients/index.ts +6 -5
- package/src/clients/types.ts +19 -4
- package/src/cloudWorker.ts +175 -113
- package/src/commands/agent.ts +246 -0
- package/src/commands/misc.ts +174 -0
- package/src/commands/modules.ts +182 -0
- package/src/commands/services.ts +77 -0
- package/src/commands/workers.ts +168 -0
- package/src/config.ts +37 -0
- package/src/fileSync.ts +50 -17
- package/src/index.ts +18 -0
- package/src/logger.ts +197 -0
- package/src/plugins/embedding.ts +11 -6
- package/src/plugins/plugins.ts +0 -21
- package/src/plugins/vim.ts +5 -16
- package/src/processors/JsonCompressor.ts +6 -6
- package/src/services/EventService.ts +61 -1
- package/src/services/KnowhowClient.ts +34 -4
- package/src/services/modules/index.ts +70 -50
- package/src/services/modules/types.ts +6 -0
- package/src/tunnel.ts +216 -0
- package/src/types.ts +0 -1
- package/src/worker.ts +105 -312
- package/src/workers/auth/WsMiddleware.ts +99 -0
- package/src/workers/auth/authMiddleware.ts +104 -0
- package/src/workers/auth/types.ts +14 -2
- package/src/workers/tools/index.ts +2 -0
- package/src/workers/tools/reloadConfig.ts +84 -0
- package/tests/services/WorkerReloadConfig.test.ts +141 -0
- package/tests/unit/commands/github-credentials.test.ts +211 -0
- package/tests/unit/modules/moduleLoading.test.ts +39 -37
- package/tests/unit/plugins/pluginLoading.test.ts +0 -85
- package/ts_build/package.json +9 -4
- package/ts_build/src/agents/base/base.js +11 -0
- package/ts_build/src/agents/base/base.js.map +1 -1
- package/ts_build/src/agents/tools/execCommand.d.ts +1 -1
- package/ts_build/src/agents/tools/execCommand.js +39 -5
- package/ts_build/src/agents/tools/execCommand.js.map +1 -1
- package/ts_build/src/agents/tools/index.d.ts +0 -1
- package/ts_build/src/agents/tools/index.js +0 -1
- package/ts_build/src/agents/tools/index.js.map +1 -1
- package/ts_build/src/agents/tools/list.js +0 -2
- package/ts_build/src/agents/tools/list.js.map +1 -1
- package/ts_build/src/chat/CliChatService.js +13 -1
- package/ts_build/src/chat/CliChatService.js.map +1 -1
- package/ts_build/src/chat/modules/AgentModule.d.ts +1 -1
- package/ts_build/src/chat/modules/AgentModule.js +39 -19
- package/ts_build/src/chat/modules/AgentModule.js.map +1 -1
- package/ts_build/src/chat/modules/SessionsModule.js +7 -2
- package/ts_build/src/chat/modules/SessionsModule.js.map +1 -1
- package/ts_build/src/chat/renderer/CompactRenderer.d.ts +4 -0
- package/ts_build/src/chat/renderer/CompactRenderer.js +16 -0
- package/ts_build/src/chat/renderer/CompactRenderer.js.map +1 -1
- package/ts_build/src/chat/renderer/ConsoleRenderer.d.ts +4 -0
- package/ts_build/src/chat/renderer/ConsoleRenderer.js +16 -0
- package/ts_build/src/chat/renderer/ConsoleRenderer.js.map +1 -1
- package/ts_build/src/chat/renderer/FancyRenderer.d.ts +4 -0
- package/ts_build/src/chat/renderer/FancyRenderer.js +16 -0
- package/ts_build/src/chat/renderer/FancyRenderer.js.map +1 -1
- package/ts_build/src/chat/renderer/types.d.ts +2 -0
- package/ts_build/src/cli.js +47 -519
- package/ts_build/src/cli.js.map +1 -1
- package/ts_build/src/clients/anthropic.d.ts +5 -5
- package/ts_build/src/clients/anthropic.js +17 -16
- package/ts_build/src/clients/anthropic.js.map +1 -1
- package/ts_build/src/clients/index.js +2 -4
- package/ts_build/src/clients/index.js.map +1 -1
- package/ts_build/src/clients/types.d.ts +3 -2
- package/ts_build/src/cloudWorker.d.ts +14 -0
- package/ts_build/src/cloudWorker.js +105 -66
- package/ts_build/src/cloudWorker.js.map +1 -1
- package/ts_build/src/commands/agent.d.ts +6 -0
- package/ts_build/src/commands/agent.js +229 -0
- package/ts_build/src/commands/agent.js.map +1 -0
- package/ts_build/src/commands/misc.d.ts +10 -0
- package/ts_build/src/commands/misc.js +197 -0
- package/ts_build/src/commands/misc.js.map +1 -0
- package/ts_build/src/commands/modules.d.ts +3 -0
- package/ts_build/src/commands/modules.js +160 -0
- package/ts_build/src/commands/modules.js.map +1 -0
- package/ts_build/src/commands/services.d.ts +5 -0
- package/ts_build/src/commands/services.js +87 -0
- package/ts_build/src/commands/services.js.map +1 -0
- package/ts_build/src/commands/workers.d.ts +6 -0
- package/ts_build/src/commands/workers.js +168 -0
- package/ts_build/src/commands/workers.js.map +1 -0
- package/ts_build/src/config.d.ts +1 -0
- package/ts_build/src/config.js +32 -0
- package/ts_build/src/config.js.map +1 -1
- package/ts_build/src/fileSync.d.ts +6 -0
- package/ts_build/src/fileSync.js +37 -12
- package/ts_build/src/fileSync.js.map +1 -1
- package/ts_build/src/index.d.ts +1 -0
- package/ts_build/src/index.js +17 -1
- package/ts_build/src/index.js.map +1 -1
- package/ts_build/src/logger.d.ts +21 -0
- package/ts_build/src/logger.js +106 -0
- package/ts_build/src/logger.js.map +1 -0
- package/ts_build/src/plugins/embedding.js +4 -3
- package/ts_build/src/plugins/embedding.js.map +1 -1
- package/ts_build/src/plugins/plugins.d.ts +0 -2
- package/ts_build/src/plugins/plugins.js +0 -11
- package/ts_build/src/plugins/plugins.js.map +1 -1
- package/ts_build/src/plugins/vim.js +3 -9
- package/ts_build/src/plugins/vim.js.map +1 -1
- package/ts_build/src/processors/JsonCompressor.js +4 -4
- package/ts_build/src/processors/JsonCompressor.js.map +1 -1
- package/ts_build/src/services/EventService.d.ts +6 -1
- package/ts_build/src/services/EventService.js +29 -0
- package/ts_build/src/services/EventService.js.map +1 -1
- package/ts_build/src/services/KnowhowClient.d.ts +13 -1
- package/ts_build/src/services/KnowhowClient.js +19 -2
- package/ts_build/src/services/KnowhowClient.js.map +1 -1
- package/ts_build/src/services/modules/index.d.ts +33 -0
- package/ts_build/src/services/modules/index.js +46 -45
- package/ts_build/src/services/modules/index.js.map +1 -1
- package/ts_build/src/services/modules/types.d.ts +6 -0
- package/ts_build/src/tunnel.d.ts +27 -0
- package/ts_build/src/tunnel.js +112 -0
- package/ts_build/src/tunnel.js.map +1 -0
- package/ts_build/src/types.d.ts +0 -1
- package/ts_build/src/types.js.map +1 -1
- package/ts_build/src/worker.d.ts +1 -4
- package/ts_build/src/worker.js +59 -227
- package/ts_build/src/worker.js.map +1 -1
- package/ts_build/src/workers/auth/WsMiddleware.d.ts +8 -0
- package/ts_build/src/workers/auth/WsMiddleware.js +65 -0
- package/ts_build/src/workers/auth/WsMiddleware.js.map +1 -0
- package/ts_build/src/workers/auth/authMiddleware.d.ts +3 -0
- package/ts_build/src/workers/auth/authMiddleware.js +60 -0
- package/ts_build/src/workers/auth/authMiddleware.js.map +1 -0
- package/ts_build/src/workers/auth/types.d.ts +8 -1
- package/ts_build/src/workers/tools/index.d.ts +2 -0
- package/ts_build/src/workers/tools/index.js +4 -1
- package/ts_build/src/workers/tools/index.js.map +1 -1
- package/ts_build/src/workers/tools/reloadConfig.d.ts +14 -0
- package/ts_build/src/workers/tools/reloadConfig.js +48 -0
- package/ts_build/src/workers/tools/reloadConfig.js.map +1 -0
- package/ts_build/tests/services/WorkerReloadConfig.test.d.ts +1 -0
- package/ts_build/tests/services/WorkerReloadConfig.test.js +86 -0
- package/ts_build/tests/services/WorkerReloadConfig.test.js.map +1 -0
- package/ts_build/tests/unit/commands/github-credentials.test.d.ts +1 -0
- package/ts_build/tests/unit/commands/github-credentials.test.js +146 -0
- package/ts_build/tests/unit/commands/github-credentials.test.js.map +1 -0
- package/ts_build/tests/unit/modules/moduleLoading.test.js +20 -26
- package/ts_build/tests/unit/modules/moduleLoading.test.js.map +1 -1
- package/ts_build/tests/unit/plugins/pluginLoading.test.js +0 -65
- package/ts_build/tests/unit/plugins/pluginLoading.test.js.map +1 -1
- package/src/agents/tools/executeScript/README.md +0 -94
- package/src/agents/tools/executeScript/definition.ts +0 -79
- package/src/agents/tools/executeScript/examples/dependency-injection-validation.ts +0 -272
- package/src/agents/tools/executeScript/examples/quick-test.ts +0 -74
- package/src/agents/tools/executeScript/examples/serialization-test.ts +0 -321
- package/src/agents/tools/executeScript/examples/test-runner.ts +0 -197
- package/src/agents/tools/executeScript/index.ts +0 -98
- package/src/services/script-execution/SandboxContext.ts +0 -282
- package/src/services/script-execution/ScriptExecutor.ts +0 -441
- package/src/services/script-execution/ScriptPolicy.ts +0 -194
- package/src/services/script-execution/ScriptTracer.ts +0 -249
- package/src/services/script-execution/types.ts +0 -134
- package/ts_build/src/agents/tools/executeScript/definition.d.ts +0 -2
- package/ts_build/src/agents/tools/executeScript/definition.js +0 -76
- package/ts_build/src/agents/tools/executeScript/definition.js.map +0 -1
- package/ts_build/src/agents/tools/executeScript/examples/dependency-injection-validation.d.ts +0 -18
- package/ts_build/src/agents/tools/executeScript/examples/dependency-injection-validation.js +0 -192
- package/ts_build/src/agents/tools/executeScript/examples/dependency-injection-validation.js.map +0 -1
- package/ts_build/src/agents/tools/executeScript/examples/quick-test.d.ts +0 -3
- package/ts_build/src/agents/tools/executeScript/examples/quick-test.js +0 -64
- package/ts_build/src/agents/tools/executeScript/examples/quick-test.js.map +0 -1
- package/ts_build/src/agents/tools/executeScript/examples/serialization-test.d.ts +0 -15
- package/ts_build/src/agents/tools/executeScript/examples/serialization-test.js +0 -266
- package/ts_build/src/agents/tools/executeScript/examples/serialization-test.js.map +0 -1
- package/ts_build/src/agents/tools/executeScript/examples/test-runner.d.ts +0 -4
- package/ts_build/src/agents/tools/executeScript/examples/test-runner.js +0 -208
- package/ts_build/src/agents/tools/executeScript/examples/test-runner.js.map +0 -1
- package/ts_build/src/agents/tools/executeScript/index.d.ts +0 -28
- package/ts_build/src/agents/tools/executeScript/index.js +0 -72
- package/ts_build/src/agents/tools/executeScript/index.js.map +0 -1
- package/ts_build/src/services/script-execution/SandboxContext.d.ts +0 -34
- package/ts_build/src/services/script-execution/SandboxContext.js +0 -189
- package/ts_build/src/services/script-execution/SandboxContext.js.map +0 -1
- package/ts_build/src/services/script-execution/ScriptExecutor.d.ts +0 -19
- package/ts_build/src/services/script-execution/ScriptExecutor.js +0 -269
- package/ts_build/src/services/script-execution/ScriptExecutor.js.map +0 -1
- package/ts_build/src/services/script-execution/ScriptPolicy.d.ts +0 -28
- package/ts_build/src/services/script-execution/ScriptPolicy.js +0 -115
- package/ts_build/src/services/script-execution/ScriptPolicy.js.map +0 -1
- package/ts_build/src/services/script-execution/ScriptTracer.d.ts +0 -19
- package/ts_build/src/services/script-execution/ScriptTracer.js +0 -186
- package/ts_build/src/services/script-execution/ScriptTracer.js.map +0 -1
- package/ts_build/src/services/script-execution/types.d.ts +0 -108
- package/ts_build/src/services/script-execution/types.js +0 -3
- package/ts_build/src/services/script-execution/types.js.map +0 -1
|
@@ -0,0 +1,197 @@
|
|
|
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.addInitCommand = addInitCommand;
|
|
37
|
+
exports.addLoginCommand = addLoginCommand;
|
|
38
|
+
exports.addUpdateCommand = addUpdateCommand;
|
|
39
|
+
exports.addGenerateCommand = addGenerateCommand;
|
|
40
|
+
exports.addEmbedCommands = addEmbedCommands;
|
|
41
|
+
exports.addUploadCommand = addUploadCommand;
|
|
42
|
+
exports.addDownloadCommand = addDownloadCommand;
|
|
43
|
+
exports.addChatCommand = addChatCommand;
|
|
44
|
+
exports.addGithubCredentialsCommand = addGithubCredentialsCommand;
|
|
45
|
+
const child_process_1 = require("child_process");
|
|
46
|
+
const package_json_1 = require("../../package.json");
|
|
47
|
+
const logger_1 = require("../logger");
|
|
48
|
+
const index_1 = require("../index");
|
|
49
|
+
const config_1 = require("../config");
|
|
50
|
+
const login_1 = require("../login");
|
|
51
|
+
const KnowhowClient_1 = require("../services/KnowhowClient");
|
|
52
|
+
const chat_1 = require("../chat");
|
|
53
|
+
function addInitCommand(program) {
|
|
54
|
+
program
|
|
55
|
+
.command("init")
|
|
56
|
+
.description("Initialize knowhow configuration")
|
|
57
|
+
.action(async () => {
|
|
58
|
+
await (0, config_1.init)();
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function addLoginCommand(program) {
|
|
62
|
+
program
|
|
63
|
+
.command("login")
|
|
64
|
+
.description("Login to knowhow")
|
|
65
|
+
.option("--jwt", "Use manual JWT input instead of browser login")
|
|
66
|
+
.action(async (opts) => {
|
|
67
|
+
await (0, login_1.login)(opts.jwt);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function addUpdateCommand(program) {
|
|
71
|
+
program
|
|
72
|
+
.command("update")
|
|
73
|
+
.description("Update knowhow to the latest version from npm")
|
|
74
|
+
.action(async () => {
|
|
75
|
+
try {
|
|
76
|
+
console.log("🔄 Checking for knowhow updates...");
|
|
77
|
+
console.log(`Current version: ${package_json_1.version}`);
|
|
78
|
+
console.log("📦 Installing latest version from npm...");
|
|
79
|
+
(0, child_process_1.execSync)("npm install -g @tyvm/knowhow@latest", {
|
|
80
|
+
stdio: "inherit",
|
|
81
|
+
encoding: "utf-8",
|
|
82
|
+
});
|
|
83
|
+
console.log("✓ knowhow has been updated successfully!");
|
|
84
|
+
console.log("Run 'knowhow --version' to see the new version.");
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
console.error("Error updating knowhow:", error.message);
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function addGenerateCommand(program) {
|
|
93
|
+
program
|
|
94
|
+
.command("generate")
|
|
95
|
+
.description("Generate documentation")
|
|
96
|
+
.action(async () => {
|
|
97
|
+
const { setupServices } = await Promise.resolve().then(() => __importStar(require("./services")));
|
|
98
|
+
await setupServices();
|
|
99
|
+
await (0, index_1.generate)();
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function addEmbedCommands(program) {
|
|
103
|
+
program
|
|
104
|
+
.command("embed")
|
|
105
|
+
.description("Create embeddings")
|
|
106
|
+
.action(async () => {
|
|
107
|
+
const { setupServices } = await Promise.resolve().then(() => __importStar(require("./services")));
|
|
108
|
+
await setupServices();
|
|
109
|
+
await (0, index_1.embed)();
|
|
110
|
+
});
|
|
111
|
+
program
|
|
112
|
+
.command("embed:purge")
|
|
113
|
+
.description("Purge embeddings matching a glob pattern")
|
|
114
|
+
.argument("<pattern>", "Glob pattern to match files for purging")
|
|
115
|
+
.action(async (pattern) => {
|
|
116
|
+
await (0, index_1.purge)(pattern);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function addUploadCommand(program) {
|
|
120
|
+
program
|
|
121
|
+
.command("upload")
|
|
122
|
+
.description("Upload data")
|
|
123
|
+
.action(async () => {
|
|
124
|
+
await (0, index_1.upload)();
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function addDownloadCommand(program) {
|
|
128
|
+
program
|
|
129
|
+
.command("download")
|
|
130
|
+
.description("Download data")
|
|
131
|
+
.action(async () => {
|
|
132
|
+
await (0, index_1.download)();
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
function addChatCommand(program) {
|
|
136
|
+
program
|
|
137
|
+
.command("chat")
|
|
138
|
+
.description("Start new chat interface")
|
|
139
|
+
.action(async () => {
|
|
140
|
+
const { setupServices } = await Promise.resolve().then(() => __importStar(require("./services")));
|
|
141
|
+
await setupServices();
|
|
142
|
+
await (0, chat_1.startChat)();
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
function addGithubCredentialsCommand(program) {
|
|
146
|
+
program
|
|
147
|
+
.command("github-credentials [action]")
|
|
148
|
+
.description("Git credential helper for GitHub. Use as: git config credential.helper 'knowhow github-credentials'")
|
|
149
|
+
.option("--repo <repo>", "Repository in owner/repo format (e.g. myorg/myrepo)")
|
|
150
|
+
.action(async (action, options) => {
|
|
151
|
+
logger_1.logger.silence();
|
|
152
|
+
const client = new KnowhowClient_1.KnowhowSimpleClient();
|
|
153
|
+
let repo = options.repo;
|
|
154
|
+
if (action === "get") {
|
|
155
|
+
const lines = [];
|
|
156
|
+
const readline = await Promise.resolve().then(() => __importStar(require("readline")));
|
|
157
|
+
const rl = readline.createInterface({
|
|
158
|
+
input: process.stdin,
|
|
159
|
+
terminal: false,
|
|
160
|
+
});
|
|
161
|
+
await new Promise((resolve) => {
|
|
162
|
+
rl.on("line", (line) => {
|
|
163
|
+
if (line.trim())
|
|
164
|
+
lines.push(line.trim());
|
|
165
|
+
});
|
|
166
|
+
rl.on("close", resolve);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
else if (action === "store" || action === "erase") {
|
|
170
|
+
process.exit(0);
|
|
171
|
+
}
|
|
172
|
+
if (!repo) {
|
|
173
|
+
try {
|
|
174
|
+
const remoteUrl = (0, child_process_1.execSync)("git remote get-url origin", {
|
|
175
|
+
encoding: "utf-8",
|
|
176
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
177
|
+
}).trim();
|
|
178
|
+
const match = remoteUrl.match(/github\.com[/:]([^/]+\/[^/]+?)(?:\.git)?$/) ||
|
|
179
|
+
remoteUrl.match(/github\.com\/([^/]+\/[^/]+)/);
|
|
180
|
+
if (match) {
|
|
181
|
+
repo = match[1];
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
try {
|
|
188
|
+
const credential = await client.getGitCredential(repo || "");
|
|
189
|
+
process.stdout.write(`protocol=${credential.protocol}\nhost=${credential.host}\nusername=${credential.username}\npassword=${credential.password}\n`);
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
console.error("Failed to get git credentials:", error.message);
|
|
193
|
+
process.exit(1);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=misc.js.map
|
|
@@ -0,0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AC,KAAK,CAClB,YAAY,UAAU,CAAC,QAAQ,UAAU,UAAU,CAAC,IAAI,cAAc,UAAU,CAAC,QAAQ,cAAc,UAAU,CAAC,QAAQ,IAAI,CAC/H,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;YAC/D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BUILTIN_MODULES = void 0;
|
|
4
|
+
exports.addModulesCommand = addModulesCommand;
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
const config_1 = require("../config");
|
|
7
|
+
exports.BUILTIN_MODULES = [
|
|
8
|
+
"@tyvm/knowhow-module-script",
|
|
9
|
+
"@tyvm/knowhow-module-terminal",
|
|
10
|
+
];
|
|
11
|
+
function addModulesCommand(program) {
|
|
12
|
+
const modulesCmd = program
|
|
13
|
+
.command("modules")
|
|
14
|
+
.description("Manage knowhow modules (install, add to config, list)");
|
|
15
|
+
modulesCmd
|
|
16
|
+
.command("setup")
|
|
17
|
+
.description("Add default built-in modules to your config and install them via npm")
|
|
18
|
+
.option("--global", "Use the global config (~/.knowhow/knowhow.json)")
|
|
19
|
+
.action(async (opts) => {
|
|
20
|
+
try {
|
|
21
|
+
const isGlobal = opts.global ?? false;
|
|
22
|
+
const cfg = isGlobal ? await (0, config_1.getGlobalConfig)() : await (0, config_1.getConfig)();
|
|
23
|
+
const configLabel = isGlobal
|
|
24
|
+
? "~/.knowhow/knowhow.json"
|
|
25
|
+
: ".knowhow/knowhow.json";
|
|
26
|
+
if (!cfg.modules)
|
|
27
|
+
cfg.modules = [];
|
|
28
|
+
const toAdd = exports.BUILTIN_MODULES.filter((m) => !cfg.modules.includes(m));
|
|
29
|
+
if (toAdd.length === 0) {
|
|
30
|
+
console.log(`✅ All default modules are already in ${configLabel}. Nothing to do.`);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
for (const mod of toAdd) {
|
|
34
|
+
if (!mod.startsWith(".") && !mod.startsWith("/")) {
|
|
35
|
+
console.log(`📦 Installing ${mod}...`);
|
|
36
|
+
const installFlag = isGlobal ? "-g" : "";
|
|
37
|
+
(0, child_process_1.execSync)(`npm install ${installFlag} ${mod}`, {
|
|
38
|
+
stdio: "inherit",
|
|
39
|
+
encoding: "utf-8",
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
cfg.modules.push(mod);
|
|
43
|
+
console.log(`✅ Added ${mod} to ${configLabel}`);
|
|
44
|
+
}
|
|
45
|
+
if (isGlobal) {
|
|
46
|
+
await (0, config_1.updateGlobalConfig)(cfg);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
await (0, config_1.updateConfig)(cfg);
|
|
50
|
+
}
|
|
51
|
+
console.log(`\n🎉 Setup complete! ${toAdd.length} module(s) added to ${configLabel}`);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
console.error("Error during modules setup:", error.message ?? error);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
modulesCmd
|
|
59
|
+
.command("install [module]")
|
|
60
|
+
.description("Install a module via npm and add it to your config. " +
|
|
61
|
+
"If no module name is given, installs all modules already in the config.")
|
|
62
|
+
.option("--global", "Use the global config (~/.knowhow/knowhow.json)")
|
|
63
|
+
.action(async (moduleName, opts) => {
|
|
64
|
+
try {
|
|
65
|
+
const isGlobal = opts.global ?? false;
|
|
66
|
+
const cfg = isGlobal ? await (0, config_1.getGlobalConfig)() : await (0, config_1.getConfig)();
|
|
67
|
+
const configLabel = isGlobal
|
|
68
|
+
? "~/.knowhow/knowhow.json"
|
|
69
|
+
: ".knowhow/knowhow.json";
|
|
70
|
+
if (!cfg.modules)
|
|
71
|
+
cfg.modules = [];
|
|
72
|
+
if (!moduleName) {
|
|
73
|
+
const installable = cfg.modules.filter((m) => !m.startsWith(".") && !m.startsWith("/"));
|
|
74
|
+
if (installable.length === 0) {
|
|
75
|
+
console.log(`ℹ No installable modules found in ${configLabel}.`);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
console.log(`📦 Installing ${installable.length} module(s) from ${configLabel}...`);
|
|
79
|
+
const installFlag = isGlobal ? "-g" : "";
|
|
80
|
+
for (const mod of installable) {
|
|
81
|
+
console.log(` 📦 Installing ${mod}...`);
|
|
82
|
+
(0, child_process_1.execSync)(`npm install ${installFlag} ${mod}`, {
|
|
83
|
+
stdio: "inherit",
|
|
84
|
+
encoding: "utf-8",
|
|
85
|
+
});
|
|
86
|
+
console.log(` ✅ Installed ${mod}`);
|
|
87
|
+
}
|
|
88
|
+
console.log(`\n🎉 All modules installed!`);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const installFlag = isGlobal ? "-g" : "";
|
|
92
|
+
console.log(`📦 Installing ${moduleName}...`);
|
|
93
|
+
(0, child_process_1.execSync)(`npm install ${installFlag} ${moduleName}`, {
|
|
94
|
+
stdio: "inherit",
|
|
95
|
+
encoding: "utf-8",
|
|
96
|
+
});
|
|
97
|
+
console.log(`✅ Installed ${moduleName}`);
|
|
98
|
+
if (!cfg.modules.includes(moduleName)) {
|
|
99
|
+
cfg.modules.push(moduleName);
|
|
100
|
+
if (isGlobal) {
|
|
101
|
+
await (0, config_1.updateGlobalConfig)(cfg);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
await (0, config_1.updateConfig)(cfg);
|
|
105
|
+
}
|
|
106
|
+
console.log(`✅ Added ${moduleName} to ${configLabel}`);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
console.log(`ℹ ${moduleName} is already in ${configLabel}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
console.error("Error during module install:", error.message ?? error);
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
modulesCmd
|
|
118
|
+
.command("list")
|
|
119
|
+
.description("List all modules in your config")
|
|
120
|
+
.option("--global", "Show global config modules only")
|
|
121
|
+
.action(async (opts) => {
|
|
122
|
+
try {
|
|
123
|
+
const isGlobal = opts.global ?? false;
|
|
124
|
+
const globalCfg = await (0, config_1.getGlobalConfig)();
|
|
125
|
+
const localCfg = isGlobal ? null : await (0, config_1.getConfig)();
|
|
126
|
+
const globalModules = globalCfg.modules || [];
|
|
127
|
+
const localModules = localCfg?.modules || [];
|
|
128
|
+
if (isGlobal) {
|
|
129
|
+
console.log(`\n🌐 Global modules (~/.knowhow/knowhow.json):`);
|
|
130
|
+
if (globalModules.length === 0) {
|
|
131
|
+
console.log(" (none)");
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
globalModules.forEach((m, i) => console.log(` ${i + 1}. ${m}`));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
console.log(`\n🌐 Global modules (~/.knowhow/knowhow.json):`);
|
|
139
|
+
if (globalModules.length === 0) {
|
|
140
|
+
console.log(" (none)");
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
globalModules.forEach((m, i) => console.log(` ${i + 1}. ${m}`));
|
|
144
|
+
}
|
|
145
|
+
console.log(`\n📁 Local modules (.knowhow/knowhow.json):`);
|
|
146
|
+
if (localModules.length === 0) {
|
|
147
|
+
console.log(" (none)");
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
localModules.forEach((m, i) => console.log(` ${i + 1}. ${m}`));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
console.error("Error listing modules:", error.message ?? error);
|
|
156
|
+
process.exit(1);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=modules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../../../src/commands/modules.ts"],"names":[],"mappings":";;;AAUA,8CA2KC;AApLD,iDAAyC;AACzC,sCAAyF;AAG5E,QAAA,eAAe,GAAG;IAC7B,6BAA6B;IAC7B,+BAA+B;CAChC,CAAC;AAEF,SAAgB,iBAAiB,CAAC,OAAgB;IAChD,MAAM,UAAU,GAAG,OAAO;SACvB,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,uDAAuD,CAAC,CAAC;IAExE,UAAU;SACP,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CACV,sEAAsE,CACvE;SACA,MAAM,CAAC,UAAU,EAAE,iDAAiD,CAAC;SACrE,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACrB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAY,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC;YAC/C,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,IAAA,wBAAe,GAAE,CAAC,CAAC,CAAC,MAAM,IAAA,kBAAS,GAAE,CAAC;YACnE,MAAM,WAAW,GAAG,QAAQ;gBAC1B,CAAC,CAAC,yBAAyB;gBAC3B,CAAC,CAAC,uBAAuB,CAAC;YAE5B,IAAI,CAAC,GAAG,CAAC,OAAO;gBAAE,GAAG,CAAC,OAAO,GAAG,EAAE,CAAC;YAEnC,MAAM,KAAK,GAAG,uBAAe,CAAC,MAAM,CAClC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,OAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CACjC,CAAC;YAEF,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACvB,OAAO,CAAC,GAAG,CACT,wCAAwC,WAAW,kBAAkB,CACtE,CAAC;gBACF,OAAO;YACT,CAAC;YAGD,KAAK,M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CAAC;gBACD,OAAO,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;gBAC3D,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBAC9B,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;gBAC1B,CAAC;qBAAM,CAAC;oBACN,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;gBAClE,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC;YAChE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
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.setupServices = setupServices;
|
|
37
|
+
const list_1 = require("../agents/tools/list");
|
|
38
|
+
const allTools = __importStar(require("../agents/tools"));
|
|
39
|
+
const services_1 = require("../services");
|
|
40
|
+
const agents_1 = require("../agents");
|
|
41
|
+
const modules_1 = require("../services/modules");
|
|
42
|
+
async function setupServices() {
|
|
43
|
+
const { Agents, Mcp, Clients, Tools: AllTools, Embeddings, Plugins, Events, MediaProcessor, } = (0, services_1.services)();
|
|
44
|
+
const Tools = new services_1.LazyToolsService();
|
|
45
|
+
Tools.setContext({
|
|
46
|
+
...AllTools.getContext(),
|
|
47
|
+
});
|
|
48
|
+
const agentContext = {
|
|
49
|
+
...(0, services_1.services)(),
|
|
50
|
+
Tools,
|
|
51
|
+
};
|
|
52
|
+
const { Researcher, Developer, Patcher, Setup } = (0, agents_1.agents)({
|
|
53
|
+
...agentContext,
|
|
54
|
+
});
|
|
55
|
+
Agents.registerAgent(Researcher);
|
|
56
|
+
Agents.registerAgent(Patcher);
|
|
57
|
+
Agents.registerAgent(Developer);
|
|
58
|
+
Agents.registerAgent(Setup);
|
|
59
|
+
Agents.loadAgentsFromConfig(agentContext);
|
|
60
|
+
Tools.defineTools(list_1.includedTools, allTools);
|
|
61
|
+
Tools.addContext("Mcp", Mcp);
|
|
62
|
+
Agents.setAgentContext(agentContext);
|
|
63
|
+
console.log("🔌 Connecting to MCP...");
|
|
64
|
+
try {
|
|
65
|
+
await Mcp.connectToConfigured(Tools);
|
|
66
|
+
}
|
|
67
|
+
catch (mcpError) {
|
|
68
|
+
const msg = mcpError instanceof Error ? mcpError.message : String(mcpError);
|
|
69
|
+
console.warn(`⚠ Some MCP servers failed to connect (continuing without them): ${msg}`);
|
|
70
|
+
}
|
|
71
|
+
console.log("Connecting to clients...");
|
|
72
|
+
await Clients.registerConfiguredModels();
|
|
73
|
+
console.log("✓ Services are set up and ready to go!");
|
|
74
|
+
console.log("📦 Loading modules from config...");
|
|
75
|
+
const modulesService = new modules_1.ModulesService();
|
|
76
|
+
await modulesService.loadModulesFromConfig({
|
|
77
|
+
Agents,
|
|
78
|
+
Embeddings,
|
|
79
|
+
Plugins,
|
|
80
|
+
Clients,
|
|
81
|
+
Tools,
|
|
82
|
+
MediaProcessor,
|
|
83
|
+
Events
|
|
84
|
+
});
|
|
85
|
+
return { Tools, Clients };
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=services.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.js","sourceRoot":"","sources":["../../../src/commands/services.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,sCAmEC;AA5ED,+CAAqD;AACrD,0DAA4C;AAC5C,0CAAyD;AACzD,sCAAmC;AACnC,iDAAqD;AAK9C,KAAK,UAAU,aAAa;IACjC,MAAM,EACJ,MAAM,EACN,GAAG,EACH,OAAO,EACP,KAAK,EAAE,QAAQ,EACf,UAAU,EACV,OAAO,EACP,MAAM,EACN,cAAc,GACf,GAAG,IAAA,mBAAQ,GAAE,CAAC;IAIf,MAAM,KAAK,GAAG,IAAI,2BAAgB,EAAE,CAAC;IAErC,K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,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;IACjD,MAAM,cAAc,GAAG,IAAI,wBAAc,EAAE,CAAC;IAC5C,MAAM,cAAc,CAAC,qBAAqB,CAAC;QACzC,MAAM;QACN,UAAU;QACV,OAAO;QACP,OAAO;QACP,KAAK;QACL,cAAc;QACd,MAAM;KACP,CAAC,CAAC;IAEH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
export declare function addWorkerCommand(program: Command): void;
|
|
3
|
+
export declare function addWorkersCommand(program: Command): void;
|
|
4
|
+
export declare function addTunnelCommand(program: Command): void;
|
|
5
|
+
export declare function addFilesCommand(program: Command): void;
|
|
6
|
+
export declare function addCloudWorkerCommand(program: Command): void;
|
|
@@ -0,0 +1,168 @@
|
|
|
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.addWorkerCommand = addWorkerCommand;
|
|
37
|
+
exports.addWorkersCommand = addWorkersCommand;
|
|
38
|
+
exports.addTunnelCommand = addTunnelCommand;
|
|
39
|
+
exports.addFilesCommand = addFilesCommand;
|
|
40
|
+
exports.addCloudWorkerCommand = addCloudWorkerCommand;
|
|
41
|
+
const worker_1 = require("../worker");
|
|
42
|
+
const tunnel_1 = require("../tunnel");
|
|
43
|
+
const fileSync_1 = require("../fileSync");
|
|
44
|
+
const workerRegistry_1 = require("../workerRegistry");
|
|
45
|
+
function addWorkerCommand(program) {
|
|
46
|
+
program
|
|
47
|
+
.command("worker")
|
|
48
|
+
.description("Start worker process and optionally register current directory")
|
|
49
|
+
.option("--register", "Register current directory as a worker path")
|
|
50
|
+
.option("--share", "Share this worker with your organization (allows other users to use it)")
|
|
51
|
+
.option("--unshare", "Make this worker private (only you can use it)")
|
|
52
|
+
.option("--sandbox", "Run worker in a Docker container for isolation")
|
|
53
|
+
.option("--no-sandbox", "Run worker directly on host (disable sandbox mode)")
|
|
54
|
+
.option("--passkey", "Set up passkey authentication for this worker")
|
|
55
|
+
.option("--passkey-reset", "Remove passkey authentication requirement")
|
|
56
|
+
.action(async (options) => {
|
|
57
|
+
const { setupServices } = await Promise.resolve().then(() => __importStar(require("./services")));
|
|
58
|
+
await setupServices();
|
|
59
|
+
await (0, worker_1.worker)(options);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function addWorkersCommand(program) {
|
|
63
|
+
program
|
|
64
|
+
.command("workers")
|
|
65
|
+
.description("Manage and start all registered workers")
|
|
66
|
+
.option("--list", "List all registered worker paths")
|
|
67
|
+
.option("--unregister <path>", "Unregister a worker path")
|
|
68
|
+
.option("--clear", "Clear all registered worker paths")
|
|
69
|
+
.action(async (options) => {
|
|
70
|
+
try {
|
|
71
|
+
if (options.list) {
|
|
72
|
+
const workers = await (0, workerRegistry_1.listWorkerPaths)();
|
|
73
|
+
if (workers.length === 0) {
|
|
74
|
+
console.log("No workers registered.");
|
|
75
|
+
console.log("\nTo register a worker, run 'knowhow worker --register' from the worker directory.");
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
console.log(`Registered workers (${workers.length}):`);
|
|
79
|
+
workers.forEach((workerPath, index) => {
|
|
80
|
+
console.log(` ${index + 1}. ${workerPath}`);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (options.unregister) {
|
|
86
|
+
await (0, workerRegistry_1.unregisterWorkerPath)(options.unregister);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (options.clear) {
|
|
90
|
+
await (0, workerRegistry_1.clearWorkerRegistry)();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const { setupServices } = await Promise.resolve().then(() => __importStar(require("./services")));
|
|
94
|
+
await setupServices();
|
|
95
|
+
await (0, workerRegistry_1.startAllWorkers)();
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
console.error("Error managing workers:", error);
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function addTunnelCommand(program) {
|
|
104
|
+
program
|
|
105
|
+
.command("tunnel")
|
|
106
|
+
.description("Start a minimal worker with tunnel enabled: exposes local ports to the cloud. " +
|
|
107
|
+
"Registers essential tools (unlock, lock, listAllowedPorts) so the backend is aware of the worker and ports. " +
|
|
108
|
+
"If passkey auth is configured, the tunnel is locked until unlocked via tool call or WebSocket auth protocol.")
|
|
109
|
+
.option("--share", "Share this tunnel with your organization (allows other users to use it)")
|
|
110
|
+
.option("--unshare", "Make this tunnel private (only you can use it)")
|
|
111
|
+
.action(async (options) => {
|
|
112
|
+
console.log("🌐 Starting tunnel (minimal worker) mode...");
|
|
113
|
+
console.log(` Tools: ${tunnel_1.TUNNEL_MINIMAL_TOOLS.join(", ")}`);
|
|
114
|
+
await (0, worker_1.worker)({
|
|
115
|
+
...options,
|
|
116
|
+
allowedTools: tunnel_1.TUNNEL_MINIMAL_TOOLS,
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function addFilesCommand(program) {
|
|
121
|
+
program
|
|
122
|
+
.command("files")
|
|
123
|
+
.description("Sync files between local filesystem and Knowhow FS (uses fileMounts config)")
|
|
124
|
+
.option("--upload", "Force upload direction for all mounts")
|
|
125
|
+
.option("--download", "Force download direction for all mounts")
|
|
126
|
+
.option("--config <path>", "Path to knowhow.json", "./knowhow.json")
|
|
127
|
+
.option("--dry-run", "Print what would be synced without doing it")
|
|
128
|
+
.action(async (options) => {
|
|
129
|
+
try {
|
|
130
|
+
await (0, fileSync_1.fileSync)(options);
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
console.error("Error syncing files:", error);
|
|
134
|
+
process.exit(1);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function addCloudWorkerCommand(program) {
|
|
139
|
+
program
|
|
140
|
+
.command("cloudworker")
|
|
141
|
+
.description("Create or sync a cloud worker with your local knowhow config")
|
|
142
|
+
.option("--init", "Initialize config.files entries based on what exists in .knowhow/ (run once before --push)")
|
|
143
|
+
.option("--create", "Create a new cloud worker with synced config and files")
|
|
144
|
+
.option("--push <uid>", "Push/sync local config and files to an existing cloud worker")
|
|
145
|
+
.option("--pull <id>", "Pull the latest workerConfigJson from a cloud worker and update local config")
|
|
146
|
+
.option("--name <name>", "Name for the cloud worker (used with --create)")
|
|
147
|
+
.option("--dry-run", "Print what would be synced without doing it")
|
|
148
|
+
.action(async (options) => {
|
|
149
|
+
try {
|
|
150
|
+
const { cloudWorker, pullCloudWorkerConfig, initCloudWorker } = await Promise.resolve().then(() => __importStar(require("../cloudWorker")));
|
|
151
|
+
if (options.init) {
|
|
152
|
+
await initCloudWorker({ dryRun: options.dryRun });
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (options.pull) {
|
|
156
|
+
await pullCloudWorkerConfig({ id: options.pull });
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
await cloudWorker(options);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
console.error("Error running cloudworker:", error);
|
|
164
|
+
process.exit(1);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=workers.js.map
|