jazz-ai 0.1.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.
- package/LICENSE +21 -0
- package/README.md +182 -0
- package/dist/cli/commands/auth.d.ts +18 -0
- package/dist/cli/commands/auth.d.ts.map +1 -0
- package/dist/cli/commands/auth.js +128 -0
- package/dist/cli/commands/auth.js.map +1 -0
- package/dist/cli/commands/chat-agent.d.ts +18 -0
- package/dist/cli/commands/chat-agent.d.ts.map +1 -0
- package/dist/cli/commands/chat-agent.js +421 -0
- package/dist/cli/commands/chat-agent.js.map +1 -0
- package/dist/cli/commands/edit-agent.d.ts +10 -0
- package/dist/cli/commands/edit-agent.d.ts.map +1 -0
- package/dist/cli/commands/edit-agent.js +310 -0
- package/dist/cli/commands/edit-agent.js.map +1 -0
- package/dist/cli/commands/task-agent.d.ts +126 -0
- package/dist/cli/commands/task-agent.d.ts.map +1 -0
- package/dist/cli/commands/task-agent.js +345 -0
- package/dist/cli/commands/task-agent.js.map +1 -0
- package/dist/core/agent/agent-prompt.d.ts +47 -0
- package/dist/core/agent/agent-prompt.d.ts.map +1 -0
- package/dist/core/agent/agent-prompt.js +146 -0
- package/dist/core/agent/agent-prompt.js.map +1 -0
- package/dist/core/agent/agent-runner.d.ts +63 -0
- package/dist/core/agent/agent-runner.d.ts.map +1 -0
- package/dist/core/agent/agent-runner.js +346 -0
- package/dist/core/agent/agent-runner.js.map +1 -0
- package/dist/core/agent/agent-service.d.ts +164 -0
- package/dist/core/agent/agent-service.d.ts.map +1 -0
- package/dist/core/agent/agent-service.js +463 -0
- package/dist/core/agent/agent-service.js.map +1 -0
- package/dist/core/agent/gmail-agent.d.ts +17 -0
- package/dist/core/agent/gmail-agent.d.ts.map +1 -0
- package/dist/core/agent/gmail-agent.js +191 -0
- package/dist/core/agent/gmail-agent.js.map +1 -0
- package/dist/core/agent/prompts/default/v1.d.ts +2 -0
- package/dist/core/agent/prompts/default/v1.d.ts.map +1 -0
- package/dist/core/agent/prompts/default/v1.js +202 -0
- package/dist/core/agent/prompts/default/v1.js.map +1 -0
- package/dist/core/agent/prompts/default/v2.d.ts +2 -0
- package/dist/core/agent/prompts/default/v2.d.ts.map +1 -0
- package/dist/core/agent/prompts/default/v2.js +72 -0
- package/dist/core/agent/prompts/default/v2.js.map +1 -0
- package/dist/core/agent/prompts/gmail/v1.d.ts +2 -0
- package/dist/core/agent/prompts/gmail/v1.d.ts.map +1 -0
- package/dist/core/agent/prompts/gmail/v1.js +206 -0
- package/dist/core/agent/prompts/gmail/v1.js.map +1 -0
- package/dist/core/agent/prompts/gmail/v2.d.ts +2 -0
- package/dist/core/agent/prompts/gmail/v2.d.ts.map +1 -0
- package/dist/core/agent/prompts/gmail/v2.js +59 -0
- package/dist/core/agent/prompts/gmail/v2.js.map +1 -0
- package/dist/core/agent/tools/base-tool.d.ts +161 -0
- package/dist/core/agent/tools/base-tool.d.ts.map +1 -0
- package/dist/core/agent/tools/base-tool.js +153 -0
- package/dist/core/agent/tools/base-tool.js.map +1 -0
- package/dist/core/agent/tools/fs-tools.d.ts +21 -0
- package/dist/core/agent/tools/fs-tools.d.ts.map +1 -0
- package/dist/core/agent/tools/fs-tools.js +1210 -0
- package/dist/core/agent/tools/fs-tools.js.map +1 -0
- package/dist/core/agent/tools/git-tools.d.ts +63 -0
- package/dist/core/agent/tools/git-tools.d.ts.map +1 -0
- package/dist/core/agent/tools/git-tools.js +600 -0
- package/dist/core/agent/tools/git-tools.js.map +1 -0
- package/dist/core/agent/tools/gmail-tools.d.ts +22 -0
- package/dist/core/agent/tools/gmail-tools.d.ts.map +1 -0
- package/dist/core/agent/tools/gmail-tools.js +779 -0
- package/dist/core/agent/tools/gmail-tools.js.map +1 -0
- package/dist/core/agent/tools/register-tools.d.ts +13 -0
- package/dist/core/agent/tools/register-tools.d.ts.map +1 -0
- package/dist/core/agent/tools/register-tools.js +169 -0
- package/dist/core/agent/tools/register-tools.js.map +1 -0
- package/dist/core/agent/tools/shell-tools.d.ts +19 -0
- package/dist/core/agent/tools/shell-tools.d.ts.map +1 -0
- package/dist/core/agent/tools/shell-tools.js +367 -0
- package/dist/core/agent/tools/shell-tools.js.map +1 -0
- package/dist/core/agent/tools/tool-registry.d.ts +62 -0
- package/dist/core/agent/tools/tool-registry.d.ts.map +1 -0
- package/dist/core/agent/tools/tool-registry.js +187 -0
- package/dist/core/agent/tools/tool-registry.js.map +1 -0
- package/dist/core/agent/tools/web-search-tools.d.ts +39 -0
- package/dist/core/agent/tools/web-search-tools.d.ts.map +1 -0
- package/dist/core/agent/tools/web-search-tools.js +220 -0
- package/dist/core/agent/tools/web-search-tools.js.map +1 -0
- package/dist/core/types/errors.d.ts +300 -0
- package/dist/core/types/errors.d.ts.map +1 -0
- package/dist/core/types/errors.js +115 -0
- package/dist/core/types/errors.js.map +1 -0
- package/dist/core/types/index.d.ts +208 -0
- package/dist/core/types/index.d.ts.map +1 -0
- package/dist/core/types/index.js +30 -0
- package/dist/core/types/index.js.map +1 -0
- package/dist/core/utils/error-handler.d.ts +114 -0
- package/dist/core/utils/error-handler.d.ts.map +1 -0
- package/dist/core/utils/error-handler.js +551 -0
- package/dist/core/utils/error-handler.js.map +1 -0
- package/dist/core/utils/markdown-renderer.d.ts +52 -0
- package/dist/core/utils/markdown-renderer.d.ts.map +1 -0
- package/dist/core/utils/markdown-renderer.js +134 -0
- package/dist/core/utils/markdown-renderer.js.map +1 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +255 -0
- package/dist/main.js.map +1 -0
- package/dist/services/config.d.ts +29 -0
- package/dist/services/config.d.ts.map +1 -0
- package/dist/services/config.js +204 -0
- package/dist/services/config.js.map +1 -0
- package/dist/services/gmail.d.ts +197 -0
- package/dist/services/gmail.d.ts.map +1 -0
- package/dist/services/gmail.js +592 -0
- package/dist/services/gmail.js.map +1 -0
- package/dist/services/llm/ai-sdk-service.d.ts +5 -0
- package/dist/services/llm/ai-sdk-service.d.ts.map +1 -0
- package/dist/services/llm/ai-sdk-service.js +326 -0
- package/dist/services/llm/ai-sdk-service.js.map +1 -0
- package/dist/services/llm/context-manager.d.ts +51 -0
- package/dist/services/llm/context-manager.d.ts.map +1 -0
- package/dist/services/llm/context-manager.js +269 -0
- package/dist/services/llm/context-manager.js.map +1 -0
- package/dist/services/llm/types.d.ts +114 -0
- package/dist/services/llm/types.d.ts.map +1 -0
- package/dist/services/llm/types.js +51 -0
- package/dist/services/llm/types.js.map +1 -0
- package/dist/services/logger.d.ts +28 -0
- package/dist/services/logger.d.ts.map +1 -0
- package/dist/services/logger.js +267 -0
- package/dist/services/logger.js.map +1 -0
- package/dist/services/shell.d.ts +37 -0
- package/dist/services/shell.d.ts.map +1 -0
- package/dist/services/shell.js +197 -0
- package/dist/services/shell.js.map +1 -0
- package/dist/services/storage/file.d.ts +37 -0
- package/dist/services/storage/file.d.ts.map +1 -0
- package/dist/services/storage/file.js +221 -0
- package/dist/services/storage/file.js.map +1 -0
- package/dist/services/storage/inMemory.d.ts +25 -0
- package/dist/services/storage/inMemory.d.ts.map +1 -0
- package/dist/services/storage/inMemory.js +106 -0
- package/dist/services/storage/inMemory.js.map +1 -0
- package/dist/services/storage/service.d.ts +26 -0
- package/dist/services/storage/service.d.ts.map +1 -0
- package/dist/services/storage/service.js +48 -0
- package/dist/services/storage/service.js.map +1 -0
- package/package.json +92 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MarkdownRenderer = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
|
+
const effect_1 = require("effect");
|
|
7
|
+
const marked_1 = require("marked");
|
|
8
|
+
const marked_terminal_1 = tslib_1.__importDefault(require("marked-terminal"));
|
|
9
|
+
// Type workaround for marked v16 compatibility with marked-terminal
|
|
10
|
+
// Suppress unused type alias for now
|
|
11
|
+
// type _MarkedRenderer = Parameters<typeof marked.setOptions>[0]["renderer"];
|
|
12
|
+
/**
|
|
13
|
+
* Markdown renderer utility for terminal output
|
|
14
|
+
*/
|
|
15
|
+
class MarkdownRenderer {
|
|
16
|
+
static renderer = null;
|
|
17
|
+
/**
|
|
18
|
+
* Initialize the markdown renderer with terminal-friendly options
|
|
19
|
+
*/
|
|
20
|
+
static initialize() {
|
|
21
|
+
try {
|
|
22
|
+
// Configure marked with our terminal renderer using setOptions
|
|
23
|
+
marked_1.marked.setOptions({
|
|
24
|
+
// @ts-expect-error marked-terminal types lag behind marked v16
|
|
25
|
+
renderer: new marked_terminal_1.default({
|
|
26
|
+
// Color scheme for better readability
|
|
27
|
+
code: chalk_1.default.cyan,
|
|
28
|
+
codespan: chalk_1.default.cyan,
|
|
29
|
+
blockquote: chalk_1.default.gray,
|
|
30
|
+
html: chalk_1.default.gray,
|
|
31
|
+
heading: chalk_1.default.bold.blue,
|
|
32
|
+
firstHeading: chalk_1.default.bold.blue.underline,
|
|
33
|
+
strong: chalk_1.default.bold.white,
|
|
34
|
+
em: chalk_1.default.italic,
|
|
35
|
+
del: chalk_1.default.strikethrough,
|
|
36
|
+
link: chalk_1.default.blue.underline,
|
|
37
|
+
href: chalk_1.default.gray,
|
|
38
|
+
listitem: chalk_1.default.white,
|
|
39
|
+
// Custom styling for better terminal experience
|
|
40
|
+
paragraph: chalk_1.default.white,
|
|
41
|
+
text: chalk_1.default.white,
|
|
42
|
+
// Disable some features that don't work well in terminal
|
|
43
|
+
showSectionPrefix: false,
|
|
44
|
+
// Better spacing
|
|
45
|
+
reflowText: true,
|
|
46
|
+
// Maximum width for better readability
|
|
47
|
+
width: 80,
|
|
48
|
+
}),
|
|
49
|
+
gfm: true, // GitHub Flavored Markdown
|
|
50
|
+
breaks: true, // Convert line breaks to <br>
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
console.error("Error initializing markdown renderer:", error instanceof Error ? error.message : String(error));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Render markdown content to terminal-friendly text
|
|
59
|
+
*/
|
|
60
|
+
static render(markdown) {
|
|
61
|
+
if (!this.renderer) {
|
|
62
|
+
this.initialize();
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
// Use marked.parse for synchronous parsing
|
|
66
|
+
return marked_1.marked.parse(markdown);
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
// Fallback to plain text if markdown parsing fails
|
|
70
|
+
console.warn("Markdown parsing failed, falling back to plain text:", error);
|
|
71
|
+
return markdown;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Render markdown content with error handling
|
|
76
|
+
*/
|
|
77
|
+
static renderSafe(markdown) {
|
|
78
|
+
return effect_1.Effect.sync(() => this.render(markdown));
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Format agent response with proper styling
|
|
82
|
+
*/
|
|
83
|
+
static formatAgentResponse(agentName, content) {
|
|
84
|
+
const header = chalk_1.default.bold.blue(`🤖 ${agentName}:`);
|
|
85
|
+
const renderedContent = this.render(content);
|
|
86
|
+
return `${header}\n${renderedContent}`;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Format tool execution message with styling
|
|
90
|
+
*/
|
|
91
|
+
static formatToolExecution(agentName, toolNames) {
|
|
92
|
+
const tools = toolNames.join(", ");
|
|
93
|
+
return chalk_1.default.yellow(`🔧 ${agentName} is using tools: ${tools}`);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Format thinking/processing message with styling
|
|
97
|
+
*/
|
|
98
|
+
static formatThinking(agentName, isFirstIteration = false) {
|
|
99
|
+
const message = isFirstIteration ? "thinking..." : "processing results...";
|
|
100
|
+
return chalk_1.default.cyan(`🤖 ${agentName} is ${message}`);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Format completion message with styling
|
|
104
|
+
*/
|
|
105
|
+
static formatCompletion(agentName) {
|
|
106
|
+
return chalk_1.default.green(`✅ ${agentName} completed successfully`);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Format warning message with styling
|
|
110
|
+
*/
|
|
111
|
+
static formatWarning(agentName, message) {
|
|
112
|
+
return chalk_1.default.yellow(`⚠️ ${agentName}: ${message}`);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Format error message with styling
|
|
116
|
+
*/
|
|
117
|
+
static formatError(message) {
|
|
118
|
+
return chalk_1.default.red(`❌ ${message}`);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Format info message with styling
|
|
122
|
+
*/
|
|
123
|
+
static formatInfo(message) {
|
|
124
|
+
return chalk_1.default.blue(`ℹ️ ${message}`);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Format success message with styling
|
|
128
|
+
*/
|
|
129
|
+
static formatSuccess(message) {
|
|
130
|
+
return chalk_1.default.green(`✅ ${message}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.MarkdownRenderer = MarkdownRenderer;
|
|
134
|
+
//# sourceMappingURL=markdown-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-renderer.js","sourceRoot":"","sources":["../../../src/core/utils/markdown-renderer.ts"],"names":[],"mappings":";;;;AAAA,0DAA0B;AAC1B,mCAAgC;AAChC,mCAAgC;AAChC,8EAA+C;AAE/C,oEAAoE;AACpE,qCAAqC;AACrC,8EAA8E;AAE9E;;GAEG;AACH,MAAa,gBAAgB;IACnB,MAAM,CAAC,QAAQ,GAA4B,IAAI,CAAC;IAExD;;OAEG;IACH,MAAM,CAAC,UAAU;QACf,IAAI,CAAC;YACH,+DAA+D;YAC/D,eAAM,CAAC,UAAU,CAAC;gBAChB,+DAA+D;gBAC/D,QAAQ,EAAE,IAAK,yBAAwE,CAAC;oBACtF,sCAAsC;oBACtC,IAAI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B,CAAC,CAAC;IAC9D,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,SAAiB,EAAE,OAAe;QACrD,OAAO,eAAK,CAAC,MAAM,CAAC,MAAM,SAAS,KAAK,OAAO,EAAE,CAAC,CAAC;IACrD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,OAAe;QAChC,OAAO,eAAK,CAAC,GAAG,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,OAAe;QAC/B,OAAO,eAAK,CAAC,IAAI,CAAC,MAAM,OAAO,EAAE,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,OAAe;QAClC,OAAO,eAAK,CAAC,KAAK,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;IACrC,CAAC;;AAjIH,4CAkIC"}
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":""}
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const platform_1 = require("@effect/platform");
|
|
5
|
+
const platform_node_1 = require("@effect/platform-node");
|
|
6
|
+
const commander_1 = require("commander");
|
|
7
|
+
const effect_1 = require("effect");
|
|
8
|
+
const auth_1 = require("./cli/commands/auth");
|
|
9
|
+
const chat_agent_1 = require("./cli/commands/chat-agent");
|
|
10
|
+
const edit_agent_1 = require("./cli/commands/edit-agent");
|
|
11
|
+
const task_agent_1 = require("./cli/commands/task-agent");
|
|
12
|
+
const agent_service_1 = require("./core/agent/agent-service");
|
|
13
|
+
const register_tools_1 = require("./core/agent/tools/register-tools");
|
|
14
|
+
const tool_registry_1 = require("./core/agent/tools/tool-registry");
|
|
15
|
+
const error_handler_1 = require("./core/utils/error-handler");
|
|
16
|
+
const markdown_renderer_1 = require("./core/utils/markdown-renderer");
|
|
17
|
+
const config_1 = require("./services/config");
|
|
18
|
+
const gmail_1 = require("./services/gmail");
|
|
19
|
+
const ai_sdk_service_1 = require("./services/llm/ai-sdk-service");
|
|
20
|
+
const logger_1 = require("./services/logger");
|
|
21
|
+
const shell_1 = require("./services/shell");
|
|
22
|
+
const file_1 = require("./services/storage/file");
|
|
23
|
+
const service_1 = require("./services/storage/service");
|
|
24
|
+
/**
|
|
25
|
+
* Main entry point for the Jazz CLI
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Create the application layer with all required services
|
|
29
|
+
*
|
|
30
|
+
* Composes all service layers including file system, configuration, logging,
|
|
31
|
+
* storage, Gmail, LLM, tool registry, and agent services. This layer provides
|
|
32
|
+
* all dependencies needed by the CLI commands.
|
|
33
|
+
*
|
|
34
|
+
* @returns A complete Effect layer containing all application services
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const appLayer = createAppLayer();
|
|
39
|
+
* yield* someCommand().pipe(Effect.provide(appLayer));
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
function createAppLayer() {
|
|
43
|
+
const fileSystemLayer = platform_node_1.NodeFileSystem.layer;
|
|
44
|
+
const configLayer = (0, config_1.createConfigLayer)().pipe(effect_1.Layer.provide(fileSystemLayer));
|
|
45
|
+
const loggerLayer = (0, logger_1.createLoggerLayer)().pipe(effect_1.Layer.provide(configLayer));
|
|
46
|
+
const storageLayer = effect_1.Layer.effect(service_1.StorageServiceTag, effect_1.Effect.gen(function* () {
|
|
47
|
+
const config = yield* config_1.AgentConfigService;
|
|
48
|
+
const { storage } = yield* config.appConfig;
|
|
49
|
+
const basePath = storage.type === "file" ? storage.path : "./.jazz";
|
|
50
|
+
const fs = yield* platform_1.FileSystem.FileSystem;
|
|
51
|
+
return new file_1.FileStorageService(basePath, fs);
|
|
52
|
+
})).pipe(effect_1.Layer.provide(fileSystemLayer), effect_1.Layer.provide(configLayer));
|
|
53
|
+
const gmailLayer = (0, gmail_1.createGmailServiceLayer)().pipe(effect_1.Layer.provide(fileSystemLayer), effect_1.Layer.provide(configLayer), effect_1.Layer.provide(loggerLayer));
|
|
54
|
+
const llmLayer = (0, ai_sdk_service_1.createAISDKServiceLayer)().pipe(effect_1.Layer.provide(configLayer));
|
|
55
|
+
const toolRegistryLayer = (0, tool_registry_1.createToolRegistryLayer)();
|
|
56
|
+
const shellLayer = (0, shell_1.createFileSystemContextServiceLayer)().pipe(effect_1.Layer.provide(fileSystemLayer));
|
|
57
|
+
const toolRegistrationLayer = (0, register_tools_1.createToolRegistrationLayer)().pipe(effect_1.Layer.provide(toolRegistryLayer), effect_1.Layer.provide(shellLayer));
|
|
58
|
+
const agentLayer = (0, agent_service_1.createAgentServiceLayer)().pipe(effect_1.Layer.provide(storageLayer));
|
|
59
|
+
// Create a complete layer by providing all dependencies
|
|
60
|
+
return effect_1.Layer.mergeAll(fileSystemLayer, configLayer, loggerLayer, storageLayer, gmailLayer, llmLayer, toolRegistryLayer, shellLayer, toolRegistrationLayer, agentLayer);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Main CLI application entry point
|
|
64
|
+
*
|
|
65
|
+
* Sets up the Commander.js CLI program with all available commands including:
|
|
66
|
+
* - Task Agent management (create, list, run, get, delete) - for traditional automation
|
|
67
|
+
* - Chat Agent management (create, chat) - for AI-powered conversational agents
|
|
68
|
+
* - Automation management (list, create, run, delete)
|
|
69
|
+
* - Configuration management (get, set, list, validate)
|
|
70
|
+
* - Authentication (Gmail login, logout, status)
|
|
71
|
+
* - Logs viewing
|
|
72
|
+
*
|
|
73
|
+
* Each command is wrapped with proper error handling using the enhanced error handler
|
|
74
|
+
* that provides actionable suggestions and recovery steps.
|
|
75
|
+
*
|
|
76
|
+
* @returns An Effect that sets up and parses the CLI program
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* Effect.runPromise(main()).catch(console.error);
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
function main() {
|
|
84
|
+
return effect_1.Effect.sync(() => {
|
|
85
|
+
markdown_renderer_1.MarkdownRenderer.initialize();
|
|
86
|
+
const program = new commander_1.Command();
|
|
87
|
+
program.name("jazz").description("A powerful agentic automation CLI").version("0.1.0");
|
|
88
|
+
// Global options
|
|
89
|
+
program
|
|
90
|
+
.option("-v, --verbose", "Enable verbose logging")
|
|
91
|
+
.option("-q, --quiet", "Suppress output")
|
|
92
|
+
.option("--config <path>", "Path to configuration file");
|
|
93
|
+
// Agent commands
|
|
94
|
+
const agentCommand = program.command("agent").description("Manage agents");
|
|
95
|
+
agentCommand
|
|
96
|
+
.command("list")
|
|
97
|
+
.description("List all agents")
|
|
98
|
+
.action(() => {
|
|
99
|
+
void effect_1.Effect.runPromise((0, task_agent_1.listAgentsCommand)().pipe(effect_1.Effect.provide(createAppLayer()), effect_1.Effect.catchAll((error) => (0, error_handler_1.handleError)(error))));
|
|
100
|
+
});
|
|
101
|
+
agentCommand
|
|
102
|
+
.command("create")
|
|
103
|
+
.description("Create a new AI chat agent (interactive mode)")
|
|
104
|
+
.action(() => {
|
|
105
|
+
void effect_1.Effect.runPromise((0, chat_agent_1.createAIAgentCommand)().pipe(effect_1.Effect.provide(createAppLayer()), effect_1.Effect.catchAll((error) => (0, error_handler_1.handleError)(error))));
|
|
106
|
+
});
|
|
107
|
+
agentCommand
|
|
108
|
+
.command("create-quick <name>")
|
|
109
|
+
.description("Create a new task agent quickly with command line options")
|
|
110
|
+
.option("-d, --description <description>", "Agent description")
|
|
111
|
+
.option("-t, --timeout <timeout>", "Agent timeout in milliseconds", (value) => parseInt(value, 10))
|
|
112
|
+
.option("-r, --max-retries <retries>", "Maximum number of retries", (value) => parseInt(value, 10))
|
|
113
|
+
.option("--retry-delay <delay>", "Retry delay in milliseconds", (value) => parseInt(value, 10))
|
|
114
|
+
.option("--retry-backoff <backoff>", "Retry backoff strategy", "exponential")
|
|
115
|
+
.action((name, options) => {
|
|
116
|
+
void effect_1.Effect.runPromise((0, task_agent_1.createAgentCommand)(name, options.description || "", options).pipe(effect_1.Effect.provide(createAppLayer()), effect_1.Effect.catchAll((error) => (0, error_handler_1.handleError)(error))));
|
|
117
|
+
});
|
|
118
|
+
agentCommand
|
|
119
|
+
.command("run <agentId>")
|
|
120
|
+
.description("Run a task agent")
|
|
121
|
+
.option("--watch", "Watch for changes")
|
|
122
|
+
.option("--dry-run", "Show what would be executed without running")
|
|
123
|
+
.action((agentId, options) => {
|
|
124
|
+
void effect_1.Effect.runPromise((0, task_agent_1.runAgentCommand)(agentId, options).pipe(effect_1.Effect.provide(createAppLayer()), effect_1.Effect.catchAll((error) => (0, error_handler_1.handleError)(error))));
|
|
125
|
+
});
|
|
126
|
+
agentCommand
|
|
127
|
+
.command("get <agentId>")
|
|
128
|
+
.description("Get task agent details")
|
|
129
|
+
.action((agentId) => {
|
|
130
|
+
void effect_1.Effect.runPromise((0, task_agent_1.getAgentCommand)(agentId).pipe(effect_1.Effect.provide(createAppLayer()), effect_1.Effect.catchAll((error) => (0, error_handler_1.handleError)(error))));
|
|
131
|
+
});
|
|
132
|
+
agentCommand
|
|
133
|
+
.command("delete <agentId>")
|
|
134
|
+
.description("Delete a task agent")
|
|
135
|
+
.action((agentId) => {
|
|
136
|
+
void effect_1.Effect.runPromise((0, task_agent_1.deleteAgentCommand)(agentId).pipe(effect_1.Effect.provide(createAppLayer()), effect_1.Effect.catchAll((error) => (0, error_handler_1.handleError)(error))));
|
|
137
|
+
});
|
|
138
|
+
agentCommand
|
|
139
|
+
.command("chat <agentId>")
|
|
140
|
+
.description("Start a chat with an AI agent")
|
|
141
|
+
.action((agentId) => {
|
|
142
|
+
void effect_1.Effect.runPromise((0, chat_agent_1.chatWithAIAgentCommand)(agentId).pipe(effect_1.Effect.provide(createAppLayer()), effect_1.Effect.catchAll((error) => (0, error_handler_1.handleError)(error))));
|
|
143
|
+
});
|
|
144
|
+
agentCommand
|
|
145
|
+
.command("edit <agentId>")
|
|
146
|
+
.description("Edit an existing agent (interactive mode)")
|
|
147
|
+
.action((agentId) => {
|
|
148
|
+
void effect_1.Effect.runPromise((0, edit_agent_1.editAgentCommand)(agentId).pipe(effect_1.Effect.provide(createAppLayer()), effect_1.Effect.catchAll((error) => (0, error_handler_1.handleError)(error))));
|
|
149
|
+
});
|
|
150
|
+
// Automation commands
|
|
151
|
+
const automationCommand = program.command("automation").description("Manage automations");
|
|
152
|
+
automationCommand
|
|
153
|
+
.command("list")
|
|
154
|
+
.description("List all automations")
|
|
155
|
+
.action(() => {
|
|
156
|
+
void effect_1.Effect.runPromise(effect_1.Effect.gen(function* () {
|
|
157
|
+
const logger = yield* logger_1.LoggerServiceTag;
|
|
158
|
+
yield* logger.info("Listing automations...");
|
|
159
|
+
// TODO: Implement automation listing
|
|
160
|
+
}).pipe(effect_1.Effect.provide(createAppLayer())));
|
|
161
|
+
});
|
|
162
|
+
automationCommand
|
|
163
|
+
.command("create")
|
|
164
|
+
.description("Create a new automation")
|
|
165
|
+
.option("-d, --description <description>", "Automation description")
|
|
166
|
+
.action((name, options) => {
|
|
167
|
+
void effect_1.Effect.runPromise(effect_1.Effect.gen(function* () {
|
|
168
|
+
const logger = yield* logger_1.LoggerServiceTag;
|
|
169
|
+
yield* logger.info(`Creating automation: ${name}`);
|
|
170
|
+
if (options.description) {
|
|
171
|
+
yield* logger.info(`Description: ${options.description}`);
|
|
172
|
+
}
|
|
173
|
+
// TODO: Implement automation creation
|
|
174
|
+
}).pipe(effect_1.Effect.provide(createAppLayer())));
|
|
175
|
+
});
|
|
176
|
+
// Config commands
|
|
177
|
+
const configCommand = program.command("config").description("Manage configuration");
|
|
178
|
+
configCommand
|
|
179
|
+
.command("get <key>")
|
|
180
|
+
.description("Get a configuration value")
|
|
181
|
+
.action((key) => {
|
|
182
|
+
void effect_1.Effect.runPromise(effect_1.Effect.gen(function* () {
|
|
183
|
+
const logger = yield* logger_1.LoggerServiceTag;
|
|
184
|
+
yield* logger.info(`Getting config: ${key}`);
|
|
185
|
+
// TODO: Implement config retrieval
|
|
186
|
+
}).pipe(effect_1.Effect.provide(createAppLayer())));
|
|
187
|
+
});
|
|
188
|
+
configCommand
|
|
189
|
+
.command("set <key> <value>")
|
|
190
|
+
.description("Set a configuration value")
|
|
191
|
+
.action((key, value) => {
|
|
192
|
+
void effect_1.Effect.runPromise(effect_1.Effect.gen(function* () {
|
|
193
|
+
const logger = yield* logger_1.LoggerServiceTag;
|
|
194
|
+
yield* logger.info(`Setting config: ${key} = ${value}`);
|
|
195
|
+
// TODO: Implement config setting
|
|
196
|
+
}).pipe(effect_1.Effect.provide(createAppLayer())));
|
|
197
|
+
});
|
|
198
|
+
configCommand
|
|
199
|
+
.command("list")
|
|
200
|
+
.description("List all configuration values")
|
|
201
|
+
.action(() => {
|
|
202
|
+
void effect_1.Effect.runPromise(effect_1.Effect.gen(function* () {
|
|
203
|
+
const logger = yield* logger_1.LoggerServiceTag;
|
|
204
|
+
yield* logger.info("Listing configuration...");
|
|
205
|
+
// TODO: Implement config listing
|
|
206
|
+
}).pipe(effect_1.Effect.provide(createAppLayer())));
|
|
207
|
+
});
|
|
208
|
+
// Auth commands
|
|
209
|
+
const authCommand = program.command("auth").description("Manage authentication");
|
|
210
|
+
const gmailAuthCommand = authCommand
|
|
211
|
+
.command("gmail")
|
|
212
|
+
.description("Gmail authentication commands");
|
|
213
|
+
gmailAuthCommand
|
|
214
|
+
.command("login")
|
|
215
|
+
.description("Authenticate with Gmail")
|
|
216
|
+
.action(() => {
|
|
217
|
+
void effect_1.Effect.runPromise((0, auth_1.gmailLoginCommand)().pipe(effect_1.Effect.provide(createAppLayer()), effect_1.Effect.catchAll((error) => (0, error_handler_1.handleError)(error))));
|
|
218
|
+
});
|
|
219
|
+
gmailAuthCommand
|
|
220
|
+
.command("logout")
|
|
221
|
+
.description("Logout from Gmail")
|
|
222
|
+
.action(() => {
|
|
223
|
+
void effect_1.Effect.runPromise((0, auth_1.gmailLogoutCommand)().pipe(effect_1.Effect.provide(createAppLayer()), effect_1.Effect.catchAll((error) => (0, error_handler_1.handleError)(error))));
|
|
224
|
+
});
|
|
225
|
+
gmailAuthCommand
|
|
226
|
+
.command("status")
|
|
227
|
+
.description("Check Gmail authentication status")
|
|
228
|
+
.action(() => {
|
|
229
|
+
void effect_1.Effect.runPromise((0, auth_1.gmailStatusCommand)().pipe(effect_1.Effect.provide(createAppLayer()), effect_1.Effect.catchAll((error) => (0, error_handler_1.handleError)(error))));
|
|
230
|
+
});
|
|
231
|
+
// Logs command
|
|
232
|
+
program
|
|
233
|
+
.command("logs")
|
|
234
|
+
.description("View logs")
|
|
235
|
+
.option("-f, --follow", "Follow log output")
|
|
236
|
+
.option("-l, --level <level>", "Filter by log level", "info")
|
|
237
|
+
.action((options) => {
|
|
238
|
+
void effect_1.Effect.runPromise(effect_1.Effect.gen(function* () {
|
|
239
|
+
const logger = yield* logger_1.LoggerServiceTag;
|
|
240
|
+
yield* logger.info("Viewing logs...");
|
|
241
|
+
if (options.follow) {
|
|
242
|
+
yield* logger.info("Following log output");
|
|
243
|
+
}
|
|
244
|
+
yield* logger.info(`Log level: ${options.level}`);
|
|
245
|
+
// TODO: Implement log viewing
|
|
246
|
+
}).pipe(effect_1.Effect.provide(createAppLayer())));
|
|
247
|
+
});
|
|
248
|
+
program.parse();
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
effect_1.Effect.runPromise(main()).catch((error) => {
|
|
252
|
+
console.error("Fatal error:", error);
|
|
253
|
+
process.exit(1);
|
|
254
|
+
});
|
|
255
|
+
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;AAEA,+CAA8C;AAC9C,yDAAuD;AACvD,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AAI,CAAC,cAAc,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;gBAClD,8BAA8B;YAChC,CAAC,CAAC,CAAC,IAAI,CAAC,eAAM,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,CAC1C,CAAC;QACJ,CAAC,CAAC,CAAC;QAEL,OAAO,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,eAAM,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACxC,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FileSystem } from "@effect/platform";
|
|
2
|
+
import { Context, Effect, Layer } from "effect";
|
|
3
|
+
import type { AppConfig } from "../core/types/index";
|
|
4
|
+
/**
|
|
5
|
+
* Configuration service using Effect's Config module
|
|
6
|
+
*/
|
|
7
|
+
export interface ConfigService {
|
|
8
|
+
readonly get: <A>(key: string) => Effect.Effect<A, never>;
|
|
9
|
+
readonly getOrElse: <A>(key: string, fallback: A) => Effect.Effect<A, never>;
|
|
10
|
+
readonly getOrFail: <A>(key: string) => Effect.Effect<A, never>;
|
|
11
|
+
readonly has: (key: string) => Effect.Effect<boolean, never>;
|
|
12
|
+
readonly set: <A>(key: string, value: A) => Effect.Effect<void, never>;
|
|
13
|
+
readonly appConfig: Effect.Effect<AppConfig, never>;
|
|
14
|
+
}
|
|
15
|
+
export declare class ConfigServiceImpl implements ConfigService {
|
|
16
|
+
private currentConfig;
|
|
17
|
+
constructor(initialConfig: AppConfig);
|
|
18
|
+
get<A>(key: string): Effect.Effect<A, never>;
|
|
19
|
+
getOrElse<A>(key: string, fallback: A): Effect.Effect<A, never>;
|
|
20
|
+
getOrFail<A>(key: string): Effect.Effect<A, never>;
|
|
21
|
+
has(key: string): Effect.Effect<boolean, never>;
|
|
22
|
+
set<A>(key: string, value: A): Effect.Effect<void, never>;
|
|
23
|
+
get appConfig(): Effect.Effect<AppConfig, never>;
|
|
24
|
+
}
|
|
25
|
+
export declare const AgentConfigService: Context.Tag<ConfigService, ConfigService>;
|
|
26
|
+
export declare function createConfigLayer(): Layer.Layer<ConfigService, never, FileSystem.FileSystem>;
|
|
27
|
+
export declare function getConfigValue<T>(key: string, defaultValue: T): Effect.Effect<T, never, ConfigService>;
|
|
28
|
+
export declare function requireConfigValue<T>(key: string): Effect.Effect<T, never, ConfigService>;
|
|
29
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/services/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAU,MAAM,QAAQ,CAAC;AACxD,OAAO,KAAK,EACV,SAAS,EAQV,MAAM,qBAAqB,CAAC;AAE7B;;GAEG;AAEH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC1D,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC7E,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAChE,QAAQ,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,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AC,GACd,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAMxC;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAMzF"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AgentConfigService = exports.ConfigServiceImpl = void 0;
|
|
4
|
+
exports.createConfigLayer = createConfigLayer;
|
|
5
|
+
exports.getConfigValue = getConfigValue;
|
|
6
|
+
exports.requireConfigValue = requireConfigValue;
|
|
7
|
+
const platform_1 = require("@effect/platform");
|
|
8
|
+
const effect_1 = require("effect");
|
|
9
|
+
class ConfigServiceImpl {
|
|
10
|
+
currentConfig;
|
|
11
|
+
constructor(initialConfig) {
|
|
12
|
+
this.currentConfig = initialConfig;
|
|
13
|
+
}
|
|
14
|
+
get(key) {
|
|
15
|
+
return effect_1.Effect.sync(() => deepGet(this.currentConfig, key));
|
|
16
|
+
}
|
|
17
|
+
getOrElse(key, fallback) {
|
|
18
|
+
return effect_1.Effect.sync(() => {
|
|
19
|
+
const value = deepGet(this.currentConfig, key);
|
|
20
|
+
return value === undefined || value === null ? fallback : value;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
getOrFail(key) {
|
|
24
|
+
return effect_1.Effect.sync(() => deepGet(this.currentConfig, key));
|
|
25
|
+
}
|
|
26
|
+
has(key) {
|
|
27
|
+
return effect_1.Effect.sync(() => deepHas(this.currentConfig, key));
|
|
28
|
+
}
|
|
29
|
+
set(key, value) {
|
|
30
|
+
return effect_1.Effect.sync(() => {
|
|
31
|
+
deepSet(this.currentConfig, key, value);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
get appConfig() {
|
|
35
|
+
return effect_1.Effect.succeed(this.currentConfig);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.ConfigServiceImpl = ConfigServiceImpl;
|
|
39
|
+
exports.AgentConfigService = effect_1.Context.GenericTag("ConfigService");
|
|
40
|
+
function createConfigLayer() {
|
|
41
|
+
return effect_1.Layer.effect(exports.AgentConfigService, effect_1.Effect.gen(function* () {
|
|
42
|
+
const fs = yield* platform_1.FileSystem.FileSystem;
|
|
43
|
+
const loaded = yield* loadConfigFile(fs);
|
|
44
|
+
const config = mergeConfig(defaultConfig(), loaded.fileConfig ?? undefined);
|
|
45
|
+
return new ConfigServiceImpl(config);
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
function getConfigValue(key, defaultValue) {
|
|
49
|
+
return effect_1.Effect.gen(function* () {
|
|
50
|
+
const config = yield* exports.AgentConfigService;
|
|
51
|
+
const result = yield* config.getOrElse(key, defaultValue);
|
|
52
|
+
return result;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function requireConfigValue(key) {
|
|
56
|
+
return effect_1.Effect.gen(function* () {
|
|
57
|
+
const config = yield* exports.AgentConfigService;
|
|
58
|
+
const result = yield* config.getOrFail(key);
|
|
59
|
+
return result;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
// -----------------
|
|
63
|
+
// Internal helpers
|
|
64
|
+
// -----------------
|
|
65
|
+
function defaultConfig() {
|
|
66
|
+
const storage = { type: "file", path: "./.jazz" };
|
|
67
|
+
const logging = { level: "info", format: "pretty", output: "console" };
|
|
68
|
+
const security = {};
|
|
69
|
+
const performance = {
|
|
70
|
+
maxConcurrentAgents: 5,
|
|
71
|
+
maxConcurrentTasks: 10,
|
|
72
|
+
timeout: 30000,
|
|
73
|
+
};
|
|
74
|
+
const google = {
|
|
75
|
+
clientId: "",
|
|
76
|
+
clientSecret: "",
|
|
77
|
+
};
|
|
78
|
+
const llm = {
|
|
79
|
+
contextManagement: {
|
|
80
|
+
summarizationThreshold: 0.75, // Summarize when 75% of context window is used
|
|
81
|
+
targetTokensRatio: 0.6, // Target 60% of context window after summarization
|
|
82
|
+
aggressiveThreshold: 0.4, // Use 40% for aggressive summarization on errors
|
|
83
|
+
preserveRecentMessages: 3, // Always keep last 3 messages (conservative for tool-heavy workflows)
|
|
84
|
+
maxRecentTokens: 2000, // Maximum tokens to preserve in recent messages
|
|
85
|
+
enableProactiveSummarization: true, // Enable proactive summarization
|
|
86
|
+
summarizeToolResults: true, // Summarize large tool call results
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
const linkup = {
|
|
90
|
+
apiKey: "",
|
|
91
|
+
baseUrl: "https://api.linkup.so",
|
|
92
|
+
timeout: 30000,
|
|
93
|
+
};
|
|
94
|
+
return { storage, logging, security, performance, google, llm, linkup };
|
|
95
|
+
}
|
|
96
|
+
function mergeConfig(base, override) {
|
|
97
|
+
if (!override)
|
|
98
|
+
return base;
|
|
99
|
+
return {
|
|
100
|
+
storage: { ...base.storage, ...(override.storage ?? {}) },
|
|
101
|
+
logging: { ...base.logging, ...(override.logging ?? {}) },
|
|
102
|
+
security: { ...base.security, ...(override.security ?? {}) },
|
|
103
|
+
performance: { ...base.performance, ...(override.performance ?? {}) },
|
|
104
|
+
...(override.google && { google: { ...base.google, ...override.google } }),
|
|
105
|
+
...(override.llm && { llm: { ...(base.llm ?? {}), ...override.llm } }),
|
|
106
|
+
...(override.linkup && { linkup: { ...base.linkup, ...override.linkup } }),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function expandHome(p) {
|
|
110
|
+
if (p.startsWith("~")) {
|
|
111
|
+
const home = process.env["HOME"] || process.env["USERPROFILE"] || "";
|
|
112
|
+
return home ? p.replace(/^~/, home) : p;
|
|
113
|
+
}
|
|
114
|
+
return p;
|
|
115
|
+
}
|
|
116
|
+
function loadConfigFile(fs) {
|
|
117
|
+
return effect_1.Effect.gen(function* () {
|
|
118
|
+
const envConfigPath = process.env["JAZZ_CONFIG_PATH"];
|
|
119
|
+
const candidates = [
|
|
120
|
+
envConfigPath ? expandHome(envConfigPath) : "",
|
|
121
|
+
`${process.cwd()}/jazz.config.json`,
|
|
122
|
+
`${expandHome("~/.jazz")}/config.json`,
|
|
123
|
+
].filter(Boolean);
|
|
124
|
+
for (const path of candidates) {
|
|
125
|
+
const exists = yield* fs.exists(path).pipe(effect_1.Effect.catchAll(() => effect_1.Effect.succeed(false)));
|
|
126
|
+
if (!exists)
|
|
127
|
+
continue;
|
|
128
|
+
const content = yield* fs
|
|
129
|
+
.readFileString(path)
|
|
130
|
+
.pipe(effect_1.Effect.catchAll(() => effect_1.Effect.succeed("")));
|
|
131
|
+
if (!content)
|
|
132
|
+
return { configPath: path };
|
|
133
|
+
const parsed = safeParseJson(content);
|
|
134
|
+
if (effect_1.Option.isSome(parsed)) {
|
|
135
|
+
return { configPath: path, fileConfig: parsed.value };
|
|
136
|
+
}
|
|
137
|
+
// If parse failed, ignore and continue to next
|
|
138
|
+
}
|
|
139
|
+
return {};
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function safeParseJson(text) {
|
|
143
|
+
try {
|
|
144
|
+
return effect_1.Option.some(JSON.parse(text));
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
return effect_1.Option.none();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Deep object property access using dot notation paths.
|
|
152
|
+
*
|
|
153
|
+
* The 'path' parameter uses dot notation to navigate nested objects:
|
|
154
|
+
* - "name" -> obj.name
|
|
155
|
+
* - "storage.type" -> obj.storage.type
|
|
156
|
+
* - "logging.level" -> obj.logging.level
|
|
157
|
+
*
|
|
158
|
+
* This allows flexible access to both simple and deeply nested properties
|
|
159
|
+
* using the same interface, commonly used in configuration management.
|
|
160
|
+
*/
|
|
161
|
+
function deepGet(obj, path) {
|
|
162
|
+
const parts = path.split(".").filter(Boolean);
|
|
163
|
+
let cur = obj;
|
|
164
|
+
for (const part of parts) {
|
|
165
|
+
if (cur && typeof cur === "object" && part in cur) {
|
|
166
|
+
cur = cur[part];
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return cur;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Checks if a property exists at the given dot notation path.
|
|
176
|
+
* Uses deepGet internally to determine existence.
|
|
177
|
+
*/
|
|
178
|
+
function deepHas(obj, path) {
|
|
179
|
+
return deepGet(obj, path) !== undefined;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Sets a value at the given dot notation path, creating intermediate objects as needed.
|
|
183
|
+
*
|
|
184
|
+
* Example: deepSet(obj, "storage.type", "file") sets obj.storage.type = "file"
|
|
185
|
+
* If obj.storage doesn't exist, it will be created as an empty object first.
|
|
186
|
+
*/
|
|
187
|
+
function deepSet(obj, path, value) {
|
|
188
|
+
const parts = path.split(".").filter(Boolean);
|
|
189
|
+
let cur = obj;
|
|
190
|
+
for (let i = 0; i < parts.length; i++) {
|
|
191
|
+
const key = parts[i];
|
|
192
|
+
if (i === parts.length - 1) {
|
|
193
|
+
cur[key] = value;
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
const next = cur[key];
|
|
197
|
+
if (!next || typeof next !== "object") {
|
|
198
|
+
cur[key] = {};
|
|
199
|
+
}
|
|
200
|
+
cur = cur[key];
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=config.js.map
|