@yagr/agent 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 +201 -0
- package/README.md +257 -0
- package/dist/agent.d.ts +21 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +47 -0
- package/dist/agent.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +293 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/init-yagr-home.d.ts +2 -0
- package/dist/config/init-yagr-home.d.ts.map +1 -0
- package/dist/config/init-yagr-home.js +6 -0
- package/dist/config/init-yagr-home.js.map +1 -0
- package/dist/config/load-env.d.ts +2 -0
- package/dist/config/load-env.d.ts.map +1 -0
- package/dist/config/load-env.js +20 -0
- package/dist/config/load-env.js.map +1 -0
- package/dist/config/load-n8n-engine-config.d.ts +6 -0
- package/dist/config/load-n8n-engine-config.d.ts.map +1 -0
- package/dist/config/load-n8n-engine-config.js +39 -0
- package/dist/config/load-n8n-engine-config.js.map +1 -0
- package/dist/config/yagr-config-service.d.ts +51 -0
- package/dist/config/yagr-config-service.d.ts.map +1 -0
- package/dist/config/yagr-config-service.js +103 -0
- package/dist/config/yagr-config-service.js.map +1 -0
- package/dist/config/yagr-home.d.ts +4 -0
- package/dist/config/yagr-home.d.ts.map +1 -0
- package/dist/config/yagr-home.js +25 -0
- package/dist/config/yagr-home.js.map +1 -0
- package/dist/engine/engine.d.ts +15 -0
- package/dist/engine/engine.d.ts.map +1 -0
- package/dist/engine/engine.js +2 -0
- package/dist/engine/engine.js.map +1 -0
- package/dist/engine/n8n-engine.d.ts +26 -0
- package/dist/engine/n8n-engine.d.ts.map +1 -0
- package/dist/engine/n8n-engine.js +200 -0
- package/dist/engine/n8n-engine.js.map +1 -0
- package/dist/engine/yagr-engine.d.ts +17 -0
- package/dist/engine/yagr-engine.d.ts.map +1 -0
- package/dist/engine/yagr-engine.js +37 -0
- package/dist/engine/yagr-engine.js.map +1 -0
- package/dist/gateway/cli.d.ts +8 -0
- package/dist/gateway/cli.d.ts.map +1 -0
- package/dist/gateway/cli.js +50 -0
- package/dist/gateway/cli.js.map +1 -0
- package/dist/gateway/history-viewport.d.ts +14 -0
- package/dist/gateway/history-viewport.d.ts.map +1 -0
- package/dist/gateway/history-viewport.js +51 -0
- package/dist/gateway/history-viewport.js.map +1 -0
- package/dist/gateway/interactive-ui.d.ts +4 -0
- package/dist/gateway/interactive-ui.d.ts.map +1 -0
- package/dist/gateway/interactive-ui.js +430 -0
- package/dist/gateway/interactive-ui.js.map +1 -0
- package/dist/gateway/manager.d.ts +25 -0
- package/dist/gateway/manager.d.ts.map +1 -0
- package/dist/gateway/manager.js +204 -0
- package/dist/gateway/manager.js.map +1 -0
- package/dist/gateway/telegram.d.ts +30 -0
- package/dist/gateway/telegram.d.ts.map +1 -0
- package/dist/gateway/telegram.js +406 -0
- package/dist/gateway/telegram.js.map +1 -0
- package/dist/gateway/types.d.ts +19 -0
- package/dist/gateway/types.d.ts.map +1 -0
- package/dist/gateway/types.js +2 -0
- package/dist/gateway/types.js.map +1 -0
- package/dist/gateway/webui.d.ts +13 -0
- package/dist/gateway/webui.d.ts.map +1 -0
- package/dist/gateway/webui.js +663 -0
- package/dist/gateway/webui.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/create-language-model.d.ts +31 -0
- package/dist/llm/create-language-model.d.ts.map +1 -0
- package/dist/llm/create-language-model.js +129 -0
- package/dist/llm/create-language-model.js.map +1 -0
- package/dist/prompt/build-system-prompt.d.ts +3 -0
- package/dist/prompt/build-system-prompt.d.ts.map +1 -0
- package/dist/prompt/build-system-prompt.js +64 -0
- package/dist/prompt/build-system-prompt.js.map +1 -0
- package/dist/runtime/completion-gate.d.ts +21 -0
- package/dist/runtime/completion-gate.d.ts.map +1 -0
- package/dist/runtime/completion-gate.js +59 -0
- package/dist/runtime/completion-gate.js.map +1 -0
- package/dist/runtime/context-compaction.d.ts +25 -0
- package/dist/runtime/context-compaction.d.ts.map +1 -0
- package/dist/runtime/context-compaction.js +197 -0
- package/dist/runtime/context-compaction.js.map +1 -0
- package/dist/runtime/outcome.d.ts +23 -0
- package/dist/runtime/outcome.d.ts.map +1 -0
- package/dist/runtime/outcome.js +89 -0
- package/dist/runtime/outcome.js.map +1 -0
- package/dist/runtime/policy-hooks.d.ts +15 -0
- package/dist/runtime/policy-hooks.d.ts.map +1 -0
- package/dist/runtime/policy-hooks.js +54 -0
- package/dist/runtime/policy-hooks.js.map +1 -0
- package/dist/runtime/required-actions.d.ts +5 -0
- package/dist/runtime/required-actions.d.ts.map +1 -0
- package/dist/runtime/required-actions.js +77 -0
- package/dist/runtime/required-actions.js.map +1 -0
- package/dist/runtime/run-engine.d.ts +15 -0
- package/dist/runtime/run-engine.d.ts.map +1 -0
- package/dist/runtime/run-engine.js +624 -0
- package/dist/runtime/run-engine.js.map +1 -0
- package/dist/setup/setup-wizard.d.ts +52 -0
- package/dist/setup/setup-wizard.d.ts.map +1 -0
- package/dist/setup/setup-wizard.js +613 -0
- package/dist/setup/setup-wizard.js.map +1 -0
- package/dist/setup/start-launcher.d.ts +22 -0
- package/dist/setup/start-launcher.d.ts.map +1 -0
- package/dist/setup/start-launcher.js +76 -0
- package/dist/setup/start-launcher.js.map +1 -0
- package/dist/setup.d.ts +20 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +247 -0
- package/dist/setup.js.map +1 -0
- package/dist/tools/build-tools.d.ts +608 -0
- package/dist/tools/build-tools.d.ts.map +1 -0
- package/dist/tools/build-tools.js +35 -0
- package/dist/tools/build-tools.js.map +1 -0
- package/dist/tools/delete-workspace-file.d.ts +38 -0
- package/dist/tools/delete-workspace-file.d.ts.map +1 -0
- package/dist/tools/delete-workspace-file.js +31 -0
- package/dist/tools/delete-workspace-file.js.map +1 -0
- package/dist/tools/deploy.d.ts +110 -0
- package/dist/tools/deploy.d.ts.map +1 -0
- package/dist/tools/deploy.js +28 -0
- package/dist/tools/deploy.js.map +1 -0
- package/dist/tools/generate-workflow.d.ts +180 -0
- package/dist/tools/generate-workflow.d.ts.map +1 -0
- package/dist/tools/generate-workflow.js +46 -0
- package/dist/tools/generate-workflow.js.map +1 -0
- package/dist/tools/index.d.ts +20 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +20 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/list-directory.d.ts +48 -0
- package/dist/tools/list-directory.d.ts.map +1 -0
- package/dist/tools/list-directory.js +61 -0
- package/dist/tools/list-directory.js.map +1 -0
- package/dist/tools/list-workflows.d.ts +18 -0
- package/dist/tools/list-workflows.d.ts.map +1 -0
- package/dist/tools/list-workflows.js +17 -0
- package/dist/tools/list-workflows.js.map +1 -0
- package/dist/tools/manage-workflow.d.ts +42 -0
- package/dist/tools/manage-workflow.d.ts.map +1 -0
- package/dist/tools/manage-workflow.js +26 -0
- package/dist/tools/manage-workflow.js.map +1 -0
- package/dist/tools/move-workspace-file.d.ts +42 -0
- package/dist/tools/move-workspace-file.d.ts.map +1 -0
- package/dist/tools/move-workspace-file.js +45 -0
- package/dist/tools/move-workspace-file.js.map +1 -0
- package/dist/tools/n8nac.d.ts +144 -0
- package/dist/tools/n8nac.d.ts.map +1 -0
- package/dist/tools/n8nac.js +349 -0
- package/dist/tools/n8nac.js.map +1 -0
- package/dist/tools/node-info.d.ts +18 -0
- package/dist/tools/node-info.d.ts.map +1 -0
- package/dist/tools/node-info.js +15 -0
- package/dist/tools/node-info.js.map +1 -0
- package/dist/tools/observer.d.ts +32 -0
- package/dist/tools/observer.d.ts.map +1 -0
- package/dist/tools/observer.js +10 -0
- package/dist/tools/observer.js.map +1 -0
- package/dist/tools/read-workspace-file.d.ts +54 -0
- package/dist/tools/read-workspace-file.d.ts.map +1 -0
- package/dist/tools/read-workspace-file.js +49 -0
- package/dist/tools/read-workspace-file.js.map +1 -0
- package/dist/tools/replace-in-workspace-file.d.ts +62 -0
- package/dist/tools/replace-in-workspace-file.d.ts.map +1 -0
- package/dist/tools/replace-in-workspace-file.js +46 -0
- package/dist/tools/replace-in-workspace-file.js.map +1 -0
- package/dist/tools/report-progress.d.ts +20 -0
- package/dist/tools/report-progress.d.ts.map +1 -0
- package/dist/tools/report-progress.js +20 -0
- package/dist/tools/report-progress.js.map +1 -0
- package/dist/tools/request-required-action.d.ts +31 -0
- package/dist/tools/request-required-action.d.ts.map +1 -0
- package/dist/tools/request-required-action.js +33 -0
- package/dist/tools/request-required-action.js.map +1 -0
- package/dist/tools/search-nodes.d.ts +18 -0
- package/dist/tools/search-nodes.d.ts.map +1 -0
- package/dist/tools/search-nodes.js +15 -0
- package/dist/tools/search-nodes.js.map +1 -0
- package/dist/tools/search-templates.d.ts +18 -0
- package/dist/tools/search-templates.d.ts.map +1 -0
- package/dist/tools/search-templates.js +15 -0
- package/dist/tools/search-templates.js.map +1 -0
- package/dist/tools/search-workspace.d.ts +55 -0
- package/dist/tools/search-workspace.d.ts.map +1 -0
- package/dist/tools/search-workspace.js +86 -0
- package/dist/tools/search-workspace.js.map +1 -0
- package/dist/tools/validate.d.ts +110 -0
- package/dist/tools/validate.d.ts.map +1 -0
- package/dist/tools/validate.js +28 -0
- package/dist/tools/validate.js.map +1 -0
- package/dist/tools/workspace-utils.d.ts +10 -0
- package/dist/tools/workspace-utils.d.ts.map +1 -0
- package/dist/tools/workspace-utils.js +63 -0
- package/dist/tools/workspace-utils.js.map +1 -0
- package/dist/tools/write-workspace-file.d.ts +46 -0
- package/dist/tools/write-workspace-file.d.ts.map +1 -0
- package/dist/tools/write-workspace-file.js +39 -0
- package/dist/tools/write-workspace-file.js.map +1 -0
- package/dist/types.d.ts +243 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/webui/app.js +26759 -0
- package/dist/webui/app.js.map +7 -0
- package/dist/webui/styles.css +740 -0
- package/dist/webui/styles.css.map +7 -0
- package/package.json +72 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Engine } from '../engine/engine.js';
|
|
3
|
+
export declare function createManageWorkflowTool(engine: Engine): import("ai").Tool<z.ZodObject<{
|
|
4
|
+
workflowId: z.ZodString;
|
|
5
|
+
action: z.ZodEnum<["activate", "deactivate", "delete"]>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
action: "activate" | "deactivate" | "delete";
|
|
8
|
+
workflowId: string;
|
|
9
|
+
}, {
|
|
10
|
+
action: "activate" | "deactivate" | "delete";
|
|
11
|
+
workflowId: string;
|
|
12
|
+
}>, {
|
|
13
|
+
workflowId: string;
|
|
14
|
+
action: "activate";
|
|
15
|
+
ok: boolean;
|
|
16
|
+
} | {
|
|
17
|
+
workflowId: string;
|
|
18
|
+
action: "deactivate";
|
|
19
|
+
ok: boolean;
|
|
20
|
+
} | {
|
|
21
|
+
workflowId: string;
|
|
22
|
+
action: "delete";
|
|
23
|
+
ok: boolean;
|
|
24
|
+
}> & {
|
|
25
|
+
execute: (args: {
|
|
26
|
+
action: "activate" | "deactivate" | "delete";
|
|
27
|
+
workflowId: string;
|
|
28
|
+
}, options: import("ai").ToolExecutionOptions) => PromiseLike<{
|
|
29
|
+
workflowId: string;
|
|
30
|
+
action: "activate";
|
|
31
|
+
ok: boolean;
|
|
32
|
+
} | {
|
|
33
|
+
workflowId: string;
|
|
34
|
+
action: "deactivate";
|
|
35
|
+
ok: boolean;
|
|
36
|
+
} | {
|
|
37
|
+
workflowId: string;
|
|
38
|
+
action: "delete";
|
|
39
|
+
ok: boolean;
|
|
40
|
+
}>;
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=manage-workflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manage-workflow.d.ts","sourceRoot":"","sources":["../../src/tools/manage-workflow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuBtD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { tool } from 'ai';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export function createManageWorkflowTool(engine) {
|
|
4
|
+
return tool({
|
|
5
|
+
description: 'Activate, deactivate, or delete an existing workflow.',
|
|
6
|
+
parameters: z.object({
|
|
7
|
+
workflowId: z.string().min(1),
|
|
8
|
+
action: z.enum(['activate', 'deactivate', 'delete']),
|
|
9
|
+
}),
|
|
10
|
+
execute: async ({ workflowId, action }) => {
|
|
11
|
+
switch (action) {
|
|
12
|
+
case 'activate':
|
|
13
|
+
await engine.activateWorkflow(workflowId);
|
|
14
|
+
return { workflowId, action, ok: true };
|
|
15
|
+
case 'deactivate':
|
|
16
|
+
await engine.deactivateWorkflow(workflowId);
|
|
17
|
+
return { workflowId, action, ok: true };
|
|
18
|
+
case 'delete':
|
|
19
|
+
await engine.deleteWorkflow(workflowId);
|
|
20
|
+
return { workflowId, action, ok: true };
|
|
21
|
+
}
|
|
22
|
+
throw new Error(`Unsupported workflow action: ${action}`);
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=manage-workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manage-workflow.js","sourceRoot":"","sources":["../../src/tools/manage-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,UAAU,wBAAwB,CAAC,MAAc;IACrD,OAAO,IAAI,CAAC;QACV,WAAW,EAAE,uDAAuD;QACpE,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC;YACnB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;YAC7B,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;SACrD,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE;YACxC,QAAQ,MAAM,EAAE,CAAC;gBACf,KAAK,UAAU;oBACb,MAAM,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;oBAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;gBAC1C,KAAK,YAAY;oBACf,MAAM,MAAM,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;oBAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;gBAC1C,KAAK,QAAQ;oBACX,MAAM,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;oBACxC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;YAC5C,CAAC;YAED,MAAM,IAAI,KAAK,CAAC,gCAAgC,MAAM,EAAE,CAAC,CAAC;QAC5D,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ToolExecutionObserver } from './observer.js';
|
|
3
|
+
export declare function createMoveWorkspaceFileTool(_observer?: ToolExecutionObserver): import("ai").Tool<z.ZodObject<{
|
|
4
|
+
fromPath: z.ZodString;
|
|
5
|
+
toPath: z.ZodString;
|
|
6
|
+
overwrite: z.ZodDefault<z.ZodBoolean>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
fromPath: string;
|
|
9
|
+
toPath: string;
|
|
10
|
+
overwrite: boolean;
|
|
11
|
+
}, {
|
|
12
|
+
fromPath: string;
|
|
13
|
+
toPath: string;
|
|
14
|
+
overwrite?: boolean | undefined;
|
|
15
|
+
}>, {
|
|
16
|
+
ok: boolean;
|
|
17
|
+
fromPath: string;
|
|
18
|
+
toPath: string;
|
|
19
|
+
error: string;
|
|
20
|
+
} | {
|
|
21
|
+
ok: boolean;
|
|
22
|
+
fromPath: string;
|
|
23
|
+
toPath: string;
|
|
24
|
+
error?: undefined;
|
|
25
|
+
}> & {
|
|
26
|
+
execute: (args: {
|
|
27
|
+
fromPath: string;
|
|
28
|
+
toPath: string;
|
|
29
|
+
overwrite: boolean;
|
|
30
|
+
}, options: import("ai").ToolExecutionOptions) => PromiseLike<{
|
|
31
|
+
ok: boolean;
|
|
32
|
+
fromPath: string;
|
|
33
|
+
toPath: string;
|
|
34
|
+
error: string;
|
|
35
|
+
} | {
|
|
36
|
+
ok: boolean;
|
|
37
|
+
fromPath: string;
|
|
38
|
+
toPath: string;
|
|
39
|
+
error?: undefined;
|
|
40
|
+
}>;
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=move-workspace-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move-workspace-file.d.ts","sourceRoot":"","sources":["../../src/tools/move-workspace-file.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAG3D,wBAAgB,2BAA2B,CAAC,SAAS,CAAC,EAAE,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4C5E"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { ensureParentDirectory, fileExists, relativeWorkspacePath, resolveWorkspacePath } from './workspace-utils.js';
|
|
5
|
+
export function createMoveWorkspaceFileTool(_observer) {
|
|
6
|
+
return tool({
|
|
7
|
+
description: 'Move or rename a workspace file to a canonical path. Use this to consolidate provisional artifacts into the correct location before completion.',
|
|
8
|
+
parameters: z.object({
|
|
9
|
+
fromPath: z.string().min(1).describe('Current workspace-relative file path.'),
|
|
10
|
+
toPath: z.string().min(1).describe('Target workspace-relative file path.'),
|
|
11
|
+
overwrite: z.boolean().default(false).describe('Whether to overwrite the destination if it already exists.'),
|
|
12
|
+
}),
|
|
13
|
+
execute: async ({ fromPath, toPath, overwrite }) => {
|
|
14
|
+
const sourcePath = resolveWorkspacePath(fromPath);
|
|
15
|
+
const targetPath = resolveWorkspacePath(toPath);
|
|
16
|
+
if (!fileExists(sourcePath)) {
|
|
17
|
+
return {
|
|
18
|
+
ok: false,
|
|
19
|
+
fromPath: relativeWorkspacePath(sourcePath),
|
|
20
|
+
toPath: relativeWorkspacePath(targetPath),
|
|
21
|
+
error: `Source file does not exist: ${fromPath}`,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
if (!overwrite && fileExists(targetPath)) {
|
|
25
|
+
return {
|
|
26
|
+
ok: false,
|
|
27
|
+
fromPath: relativeWorkspacePath(sourcePath),
|
|
28
|
+
toPath: relativeWorkspacePath(targetPath),
|
|
29
|
+
error: `Destination already exists: ${toPath}`,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
ensureParentDirectory(targetPath);
|
|
33
|
+
if (overwrite && fileExists(targetPath)) {
|
|
34
|
+
fs.rmSync(targetPath, { force: true });
|
|
35
|
+
}
|
|
36
|
+
fs.renameSync(sourcePath, targetPath);
|
|
37
|
+
return {
|
|
38
|
+
ok: true,
|
|
39
|
+
fromPath: relativeWorkspacePath(sourcePath),
|
|
40
|
+
toPath: relativeWorkspacePath(targetPath),
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=move-workspace-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move-workspace-file.js","sourceRoot":"","sources":["../../src/tools/move-workspace-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEtH,MAAM,UAAU,2BAA2B,CAAC,SAAiC;IAC3E,OAAO,IAAI,CAAC;QACV,WAAW,EAAE,iJAAiJ;QAC9J,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC;YACnB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,uCAAuC,CAAC;YAC7E,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,sCAAsC,CAAC;YAC1E,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,4DAA4D,CAAC;SAC7G,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE;YACjD,MAAM,UAAU,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC;YAClD,MAAM,UAAU,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;YAEhD,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC5B,OAAO;oBACL,EAAE,EAAE,KAAK;oBACT,QAAQ,EAAE,qBAAqB,CAAC,UAAU,CAAC;oBAC3C,MAAM,EAAE,qBAAqB,CAAC,UAAU,CAAC;oBACzC,KAAK,EAAE,+BAA+B,QAAQ,EAAE;iBACjD,CAAC;YACJ,CAAC;YAED,IAAI,CAAC,SAAS,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBACzC,OAAO;oBACL,EAAE,EAAE,KAAK;oBACT,QAAQ,EAAE,qBAAqB,CAAC,UAAU,CAAC;oBAC3C,MAAM,EAAE,qBAAqB,CAAC,UAAU,CAAC;oBACzC,KAAK,EAAE,+BAA+B,MAAM,EAAE;iBAC/C,CAAC;YACJ,CAAC;YAED,qBAAqB,CAAC,UAAU,CAAC,CAAC;YAClC,IAAI,SAAS,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBACxC,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACzC,CAAC;YAED,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;YAEtC,OAAO;gBACL,EAAE,EAAE,IAAI;gBACR,QAAQ,EAAE,qBAAqB,CAAC,UAAU,CAAC;gBAC3C,MAAM,EAAE,qBAAqB,CAAC,UAAU,CAAC;aAC1C,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type ToolExecutionObserver } from './observer.js';
|
|
3
|
+
export declare function createN8nAcTool(observer?: ToolExecutionObserver): import("ai").Tool<z.ZodObject<{
|
|
4
|
+
action: z.ZodEnum<["setup_check", "init_auth", "init_project", "list", "pull", "push", "verify", "skills", "validate", "update_ai", "resolve", "skillsArgs", "skillsArgv"]>;
|
|
5
|
+
n8nHost: z.ZodOptional<z.ZodString>;
|
|
6
|
+
n8nApiKey: z.ZodOptional<z.ZodString>;
|
|
7
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
8
|
+
projectName: z.ZodOptional<z.ZodString>;
|
|
9
|
+
projectIndex: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
listScope: z.ZodOptional<z.ZodEnum<["all", "local", "remote", "distant"]>>;
|
|
11
|
+
workflowId: z.ZodOptional<z.ZodString>;
|
|
12
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
13
|
+
skillsArgs: z.ZodOptional<z.ZodString>;
|
|
14
|
+
skillsArgv: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
15
|
+
validateFile: z.ZodOptional<z.ZodString>;
|
|
16
|
+
syncFolder: z.ZodOptional<z.ZodString>;
|
|
17
|
+
resolveMode: z.ZodOptional<z.ZodEnum<["keep-current", "keep-incoming"]>>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
action: "validate" | "verify" | "push" | "list" | "resolve" | "setup_check" | "init_auth" | "init_project" | "pull" | "skills" | "update_ai" | "skillsArgs" | "skillsArgv";
|
|
20
|
+
syncFolder?: string | undefined;
|
|
21
|
+
projectId?: string | undefined;
|
|
22
|
+
projectName?: string | undefined;
|
|
23
|
+
skillsArgs?: string | undefined;
|
|
24
|
+
skillsArgv?: string[] | undefined;
|
|
25
|
+
n8nHost?: string | undefined;
|
|
26
|
+
n8nApiKey?: string | undefined;
|
|
27
|
+
projectIndex?: number | undefined;
|
|
28
|
+
listScope?: "all" | "local" | "remote" | "distant" | undefined;
|
|
29
|
+
workflowId?: string | undefined;
|
|
30
|
+
filename?: string | undefined;
|
|
31
|
+
validateFile?: string | undefined;
|
|
32
|
+
resolveMode?: "keep-current" | "keep-incoming" | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
action: "validate" | "verify" | "push" | "list" | "resolve" | "setup_check" | "init_auth" | "init_project" | "pull" | "skills" | "update_ai" | "skillsArgs" | "skillsArgv";
|
|
35
|
+
syncFolder?: string | undefined;
|
|
36
|
+
projectId?: string | undefined;
|
|
37
|
+
projectName?: string | undefined;
|
|
38
|
+
skillsArgs?: string | undefined;
|
|
39
|
+
skillsArgv?: string[] | undefined;
|
|
40
|
+
n8nHost?: string | undefined;
|
|
41
|
+
n8nApiKey?: string | undefined;
|
|
42
|
+
projectIndex?: number | undefined;
|
|
43
|
+
listScope?: "all" | "local" | "remote" | "distant" | undefined;
|
|
44
|
+
workflowId?: string | undefined;
|
|
45
|
+
filename?: string | undefined;
|
|
46
|
+
validateFile?: string | undefined;
|
|
47
|
+
resolveMode?: "keep-current" | "keep-incoming" | undefined;
|
|
48
|
+
}>, {
|
|
49
|
+
workspaceRoot: string;
|
|
50
|
+
next: string;
|
|
51
|
+
initialized: boolean;
|
|
52
|
+
configPath: string;
|
|
53
|
+
exitCode?: undefined;
|
|
54
|
+
timedOut?: undefined;
|
|
55
|
+
stdout?: undefined;
|
|
56
|
+
stderr?: undefined;
|
|
57
|
+
aiContextRefreshed?: undefined;
|
|
58
|
+
aiContextStdout?: undefined;
|
|
59
|
+
aiContextStderr?: undefined;
|
|
60
|
+
} | {
|
|
61
|
+
exitCode: number;
|
|
62
|
+
timedOut: boolean;
|
|
63
|
+
stdout: string;
|
|
64
|
+
stderr: string;
|
|
65
|
+
next: string;
|
|
66
|
+
aiContextRefreshed?: undefined;
|
|
67
|
+
aiContextStdout?: undefined;
|
|
68
|
+
aiContextStderr?: undefined;
|
|
69
|
+
} | {
|
|
70
|
+
exitCode: number;
|
|
71
|
+
timedOut: boolean;
|
|
72
|
+
stdout: string;
|
|
73
|
+
stderr: string;
|
|
74
|
+
next?: undefined;
|
|
75
|
+
aiContextRefreshed?: undefined;
|
|
76
|
+
aiContextStdout?: undefined;
|
|
77
|
+
aiContextStderr?: undefined;
|
|
78
|
+
} | {
|
|
79
|
+
exitCode: number;
|
|
80
|
+
timedOut: boolean;
|
|
81
|
+
stdout: string;
|
|
82
|
+
stderr: string;
|
|
83
|
+
aiContextRefreshed: boolean;
|
|
84
|
+
aiContextStdout: string;
|
|
85
|
+
aiContextStderr: string;
|
|
86
|
+
next: string;
|
|
87
|
+
}> & {
|
|
88
|
+
execute: (args: {
|
|
89
|
+
action: "validate" | "verify" | "push" | "list" | "resolve" | "setup_check" | "init_auth" | "init_project" | "pull" | "skills" | "update_ai" | "skillsArgs" | "skillsArgv";
|
|
90
|
+
syncFolder?: string | undefined;
|
|
91
|
+
projectId?: string | undefined;
|
|
92
|
+
projectName?: string | undefined;
|
|
93
|
+
skillsArgs?: string | undefined;
|
|
94
|
+
skillsArgv?: string[] | undefined;
|
|
95
|
+
n8nHost?: string | undefined;
|
|
96
|
+
n8nApiKey?: string | undefined;
|
|
97
|
+
projectIndex?: number | undefined;
|
|
98
|
+
listScope?: "all" | "local" | "remote" | "distant" | undefined;
|
|
99
|
+
workflowId?: string | undefined;
|
|
100
|
+
filename?: string | undefined;
|
|
101
|
+
validateFile?: string | undefined;
|
|
102
|
+
resolveMode?: "keep-current" | "keep-incoming" | undefined;
|
|
103
|
+
}, options: import("ai").ToolExecutionOptions) => PromiseLike<{
|
|
104
|
+
workspaceRoot: string;
|
|
105
|
+
next: string;
|
|
106
|
+
initialized: boolean;
|
|
107
|
+
configPath: string;
|
|
108
|
+
exitCode?: undefined;
|
|
109
|
+
timedOut?: undefined;
|
|
110
|
+
stdout?: undefined;
|
|
111
|
+
stderr?: undefined;
|
|
112
|
+
aiContextRefreshed?: undefined;
|
|
113
|
+
aiContextStdout?: undefined;
|
|
114
|
+
aiContextStderr?: undefined;
|
|
115
|
+
} | {
|
|
116
|
+
exitCode: number;
|
|
117
|
+
timedOut: boolean;
|
|
118
|
+
stdout: string;
|
|
119
|
+
stderr: string;
|
|
120
|
+
next: string;
|
|
121
|
+
aiContextRefreshed?: undefined;
|
|
122
|
+
aiContextStdout?: undefined;
|
|
123
|
+
aiContextStderr?: undefined;
|
|
124
|
+
} | {
|
|
125
|
+
exitCode: number;
|
|
126
|
+
timedOut: boolean;
|
|
127
|
+
stdout: string;
|
|
128
|
+
stderr: string;
|
|
129
|
+
next?: undefined;
|
|
130
|
+
aiContextRefreshed?: undefined;
|
|
131
|
+
aiContextStdout?: undefined;
|
|
132
|
+
aiContextStderr?: undefined;
|
|
133
|
+
} | {
|
|
134
|
+
exitCode: number;
|
|
135
|
+
timedOut: boolean;
|
|
136
|
+
stdout: string;
|
|
137
|
+
stderr: string;
|
|
138
|
+
aiContextRefreshed: boolean;
|
|
139
|
+
aiContextStdout: string;
|
|
140
|
+
aiContextStderr: string;
|
|
141
|
+
next: string;
|
|
142
|
+
}>;
|
|
143
|
+
};
|
|
144
|
+
//# sourceMappingURL=n8nac.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"n8nac.d.ts","sourceRoot":"","sources":["../../src/tools/n8nac.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAgC,KAAK,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAkNzF,wBAAgB,eAAe,CAAC,QAAQ,CAAC,EAAE,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAlBd,OAAO;gBAAc,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAA3B,OAAO;oBAAc,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqO5E"}
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
import { tool } from 'ai';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { emitToolEvent, quoteShellArg } from './observer.js';
|
|
6
|
+
import { relativeWorkspacePath, resolveWorkspacePath, truncateText, workspaceRoot } from './workspace-utils.js';
|
|
7
|
+
const N8NAC_ACTIONS = [
|
|
8
|
+
'setup_check',
|
|
9
|
+
'init_auth',
|
|
10
|
+
'init_project',
|
|
11
|
+
'list',
|
|
12
|
+
'pull',
|
|
13
|
+
'push',
|
|
14
|
+
'verify',
|
|
15
|
+
'skills',
|
|
16
|
+
'validate',
|
|
17
|
+
'update_ai',
|
|
18
|
+
'resolve',
|
|
19
|
+
'skillsArgs',
|
|
20
|
+
'skillsArgv',
|
|
21
|
+
];
|
|
22
|
+
function normalizeN8nAcAction(action) {
|
|
23
|
+
if (action === 'skillsArgs' || action === 'skillsArgv') {
|
|
24
|
+
return 'skills';
|
|
25
|
+
}
|
|
26
|
+
return action;
|
|
27
|
+
}
|
|
28
|
+
function splitArgv(input) {
|
|
29
|
+
const args = [];
|
|
30
|
+
let current = '';
|
|
31
|
+
let quote = null;
|
|
32
|
+
let escaping = false;
|
|
33
|
+
for (const character of input) {
|
|
34
|
+
if (escaping) {
|
|
35
|
+
current += character;
|
|
36
|
+
escaping = false;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (character === '\\' && quote !== '\'') {
|
|
40
|
+
escaping = true;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (quote) {
|
|
44
|
+
if (character === quote) {
|
|
45
|
+
quote = null;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
current += character;
|
|
49
|
+
}
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (character === '"' || character === '\'') {
|
|
53
|
+
quote = character;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (/\s/.test(character)) {
|
|
57
|
+
if (current) {
|
|
58
|
+
args.push(current);
|
|
59
|
+
current = '';
|
|
60
|
+
}
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
current += character;
|
|
64
|
+
}
|
|
65
|
+
if (escaping) {
|
|
66
|
+
current += '\\';
|
|
67
|
+
}
|
|
68
|
+
if (quote) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
if (current) {
|
|
72
|
+
args.push(current);
|
|
73
|
+
}
|
|
74
|
+
return args;
|
|
75
|
+
}
|
|
76
|
+
function runN8nac(args, cwd, env, onOutput) {
|
|
77
|
+
return new Promise((resolve) => {
|
|
78
|
+
const child = spawn('npx', ['--yes', 'n8nac', ...args], {
|
|
79
|
+
cwd,
|
|
80
|
+
env: { ...process.env, ...env },
|
|
81
|
+
stdio: 'pipe',
|
|
82
|
+
});
|
|
83
|
+
let stdout = '';
|
|
84
|
+
let stderr = '';
|
|
85
|
+
let settled = false;
|
|
86
|
+
let timedOut = false;
|
|
87
|
+
let killTimer;
|
|
88
|
+
const finish = (result) => {
|
|
89
|
+
if (settled) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
settled = true;
|
|
93
|
+
clearTimeout(timeout);
|
|
94
|
+
if (killTimer) {
|
|
95
|
+
clearTimeout(killTimer);
|
|
96
|
+
}
|
|
97
|
+
resolve(result);
|
|
98
|
+
};
|
|
99
|
+
child.stdout.on('data', (chunk) => {
|
|
100
|
+
const text = chunk.toString();
|
|
101
|
+
stdout += text;
|
|
102
|
+
void onOutput?.('stdout', text);
|
|
103
|
+
});
|
|
104
|
+
child.stderr.on('data', (chunk) => {
|
|
105
|
+
const text = chunk.toString();
|
|
106
|
+
stderr += text;
|
|
107
|
+
void onOutput?.('stderr', text);
|
|
108
|
+
});
|
|
109
|
+
const timeout = setTimeout(() => {
|
|
110
|
+
timedOut = true;
|
|
111
|
+
child.kill('SIGTERM');
|
|
112
|
+
killTimer = setTimeout(() => {
|
|
113
|
+
child.kill('SIGKILL');
|
|
114
|
+
finish({ stdout, stderr: stderr || 'Process timed out.', exitCode: 1, timedOut: true });
|
|
115
|
+
}, 2_000);
|
|
116
|
+
}, 120_000);
|
|
117
|
+
child.on('error', (error) => {
|
|
118
|
+
finish({ stdout, stderr: error.message || stderr, exitCode: 1, timedOut });
|
|
119
|
+
});
|
|
120
|
+
child.on('close', (exitCode) => {
|
|
121
|
+
finish({ stdout, stderr, exitCode: exitCode ?? 1, timedOut });
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
async function runObservedN8nac(observer, args, cwd, env) {
|
|
126
|
+
const command = ['npx', '--yes', 'n8nac', ...args].map(quoteShellArg).join(' ');
|
|
127
|
+
await emitToolEvent(observer, {
|
|
128
|
+
type: 'command-start',
|
|
129
|
+
toolName: 'n8nac',
|
|
130
|
+
command,
|
|
131
|
+
cwd: relativeWorkspacePath(cwd),
|
|
132
|
+
});
|
|
133
|
+
const result = await runN8nac(args, cwd, env, async (stream, chunk) => {
|
|
134
|
+
await emitToolEvent(observer, {
|
|
135
|
+
type: 'command-output',
|
|
136
|
+
toolName: 'n8nac',
|
|
137
|
+
stream,
|
|
138
|
+
chunk,
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
await emitToolEvent(observer, {
|
|
142
|
+
type: 'command-end',
|
|
143
|
+
toolName: 'n8nac',
|
|
144
|
+
exitCode: result.exitCode,
|
|
145
|
+
timedOut: result.timedOut,
|
|
146
|
+
message: result.exitCode === 0 ? 'Commande terminee.' : 'Commande en echec.',
|
|
147
|
+
});
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
function isWorkspaceInitialized() {
|
|
151
|
+
const configPath = resolveWorkspacePath('n8nac-config.json');
|
|
152
|
+
if (!fs.existsSync(configPath)) {
|
|
153
|
+
return { initialized: false, configPath: relativeWorkspacePath(configPath) };
|
|
154
|
+
}
|
|
155
|
+
try {
|
|
156
|
+
const raw = fs.readFileSync(configPath, 'utf-8');
|
|
157
|
+
const config = JSON.parse(raw);
|
|
158
|
+
return {
|
|
159
|
+
initialized: Boolean(config.projectId && config.projectName),
|
|
160
|
+
configPath: relativeWorkspacePath(configPath),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
return { initialized: false, configPath: relativeWorkspacePath(configPath) };
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
export function createN8nAcTool(observer) {
|
|
168
|
+
return tool({
|
|
169
|
+
description: 'Run n8n-as-code workflow operations from the active workspace. For skills queries, use action="skills" with either skillsArgs as a single shell-like string or skillsArgv as an array of arguments.',
|
|
170
|
+
parameters: z.object({
|
|
171
|
+
action: z.enum(N8NAC_ACTIONS).describe('Primary n8nac action. Use skills for any n8nac skills subcommand; skillsArgs and skillsArgv are accepted as legacy aliases and normalize to skills.'),
|
|
172
|
+
n8nHost: z.string().optional().describe('n8n host URL for init_auth.'),
|
|
173
|
+
n8nApiKey: z.string().optional().describe('n8n API key for init_auth.'),
|
|
174
|
+
projectId: z.string().optional().describe('n8n project ID for init_project.'),
|
|
175
|
+
projectName: z.string().optional().describe('n8n project name for init_project.'),
|
|
176
|
+
projectIndex: z.number().int().min(1).optional().describe('1-based project selector for init_project.'),
|
|
177
|
+
listScope: z.enum(['all', 'local', 'remote', 'distant']).optional().describe('Workflow listing scope for list.'),
|
|
178
|
+
workflowId: z.string().optional().describe('Workflow ID for pull, verify, or resolve.'),
|
|
179
|
+
filename: z.string().optional().describe('Workflow filename including .workflow.ts for push.'),
|
|
180
|
+
skillsArgs: z.string().optional().describe('String form of n8nac skills arguments, for example search telegram.'),
|
|
181
|
+
skillsArgv: z.array(z.string()).optional().describe('Array form of n8nac skills arguments when values contain spaces.'),
|
|
182
|
+
validateFile: z.string().optional().describe('Local workflow file path for n8nac skills validate.'),
|
|
183
|
+
syncFolder: z.string().optional().describe('Sync folder to pass to init_project. Defaults to workflows.'),
|
|
184
|
+
resolveMode: z.enum(['keep-current', 'keep-incoming']).optional().describe('Conflict resolution mode for resolve.'),
|
|
185
|
+
}),
|
|
186
|
+
execute: async ({ action, n8nHost, n8nApiKey, projectId, projectName, projectIndex, listScope, workflowId, filename, skillsArgs, skillsArgv, validateFile, syncFolder, resolveMode, }) => {
|
|
187
|
+
action = normalizeN8nAcAction(action);
|
|
188
|
+
const cwd = workspaceRoot();
|
|
189
|
+
if (action === 'setup_check') {
|
|
190
|
+
const status = isWorkspaceInitialized();
|
|
191
|
+
return {
|
|
192
|
+
...status,
|
|
193
|
+
workspaceRoot: relativeWorkspacePath(cwd),
|
|
194
|
+
next: status.initialized
|
|
195
|
+
? 'Workspace is initialized. You can list, pull, edit, validate, push, and verify workflows.'
|
|
196
|
+
: 'Workspace is not initialized. Ask for missing n8n credentials, then run init_auth followed by init_project.',
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
if (action === 'init_auth') {
|
|
200
|
+
if (!n8nHost || !n8nApiKey) {
|
|
201
|
+
throw new Error('init_auth requires n8nHost and n8nApiKey');
|
|
202
|
+
}
|
|
203
|
+
const result = await runObservedN8nac(observer, ['init-auth', '--host', n8nHost, '--api-key', n8nApiKey], cwd);
|
|
204
|
+
return {
|
|
205
|
+
exitCode: result.exitCode,
|
|
206
|
+
timedOut: result.timedOut,
|
|
207
|
+
stdout: truncateText(result.stdout),
|
|
208
|
+
stderr: truncateText(result.stderr),
|
|
209
|
+
next: result.exitCode === 0
|
|
210
|
+
? 'Credentials saved. Continue with init_project.'
|
|
211
|
+
: 'Initialization auth failed. Inspect stderr and retry with corrected host or API key.',
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
if (action === 'init_project') {
|
|
215
|
+
const args = ['init-project', '--sync-folder', syncFolder || 'workflows'];
|
|
216
|
+
if (projectId) {
|
|
217
|
+
args.push('--project-id', projectId);
|
|
218
|
+
}
|
|
219
|
+
else if (projectName) {
|
|
220
|
+
args.push('--project-name', projectName);
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
args.push('--project-index', String(projectIndex ?? 1));
|
|
224
|
+
}
|
|
225
|
+
const result = await runObservedN8nac(observer, args, cwd);
|
|
226
|
+
if (result.exitCode !== 0) {
|
|
227
|
+
return {
|
|
228
|
+
exitCode: result.exitCode,
|
|
229
|
+
timedOut: result.timedOut,
|
|
230
|
+
stdout: truncateText(result.stdout),
|
|
231
|
+
stderr: truncateText(result.stderr),
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
const refresh = await runObservedN8nac(observer, ['update-ai'], cwd);
|
|
235
|
+
return {
|
|
236
|
+
exitCode: result.exitCode,
|
|
237
|
+
timedOut: result.timedOut,
|
|
238
|
+
stdout: truncateText(result.stdout),
|
|
239
|
+
stderr: truncateText(result.stderr),
|
|
240
|
+
aiContextRefreshed: refresh.exitCode === 0,
|
|
241
|
+
aiContextStdout: truncateText(refresh.stdout),
|
|
242
|
+
aiContextStderr: truncateText(refresh.stderr),
|
|
243
|
+
next: refresh.exitCode === 0
|
|
244
|
+
? 'Workspace initialized and AGENTS.md refreshed.'
|
|
245
|
+
: 'Workspace initialized, but AGENTS.md refresh failed. Inspect aiContextStderr.',
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
if (action === 'list') {
|
|
249
|
+
const args = ['list'];
|
|
250
|
+
if (listScope && listScope !== 'all') {
|
|
251
|
+
args.push(`--${listScope}`);
|
|
252
|
+
}
|
|
253
|
+
const result = await runObservedN8nac(observer, args, cwd);
|
|
254
|
+
return {
|
|
255
|
+
exitCode: result.exitCode,
|
|
256
|
+
timedOut: result.timedOut,
|
|
257
|
+
stdout: truncateText(result.stdout),
|
|
258
|
+
stderr: truncateText(result.stderr),
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
if (action === 'pull') {
|
|
262
|
+
if (!workflowId) {
|
|
263
|
+
throw new Error('pull requires workflowId');
|
|
264
|
+
}
|
|
265
|
+
const result = await runObservedN8nac(observer, ['pull', workflowId], cwd);
|
|
266
|
+
return {
|
|
267
|
+
exitCode: result.exitCode,
|
|
268
|
+
timedOut: result.timedOut,
|
|
269
|
+
stdout: truncateText(result.stdout),
|
|
270
|
+
stderr: truncateText(result.stderr),
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
if (action === 'push') {
|
|
274
|
+
if (!filename) {
|
|
275
|
+
throw new Error('push requires filename including .workflow.ts');
|
|
276
|
+
}
|
|
277
|
+
const result = await runObservedN8nac(observer, ['push', filename, '--verify'], cwd);
|
|
278
|
+
return {
|
|
279
|
+
exitCode: result.exitCode,
|
|
280
|
+
timedOut: result.timedOut,
|
|
281
|
+
stdout: truncateText(result.stdout),
|
|
282
|
+
stderr: truncateText(result.stderr),
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
if (action === 'verify') {
|
|
286
|
+
if (!workflowId) {
|
|
287
|
+
throw new Error('verify requires workflowId');
|
|
288
|
+
}
|
|
289
|
+
const result = await runObservedN8nac(observer, ['verify', workflowId], cwd);
|
|
290
|
+
return {
|
|
291
|
+
exitCode: result.exitCode,
|
|
292
|
+
timedOut: result.timedOut,
|
|
293
|
+
stdout: truncateText(result.stdout),
|
|
294
|
+
stderr: truncateText(result.stderr),
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
if (action === 'skills') {
|
|
298
|
+
const argv = Array.isArray(skillsArgv) && skillsArgv.length > 0
|
|
299
|
+
? skillsArgv
|
|
300
|
+
: skillsArgs
|
|
301
|
+
? splitArgv(skillsArgs)
|
|
302
|
+
: null;
|
|
303
|
+
if (!argv) {
|
|
304
|
+
throw new Error('skills requires skillsArgv or a valid skillsArgs string');
|
|
305
|
+
}
|
|
306
|
+
const result = await runObservedN8nac(observer, ['skills', ...argv], cwd);
|
|
307
|
+
return {
|
|
308
|
+
exitCode: result.exitCode,
|
|
309
|
+
timedOut: result.timedOut,
|
|
310
|
+
stdout: truncateText(result.stdout),
|
|
311
|
+
stderr: truncateText(result.stderr),
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
if (action === 'validate') {
|
|
315
|
+
if (!validateFile) {
|
|
316
|
+
throw new Error('validate requires validateFile');
|
|
317
|
+
}
|
|
318
|
+
const filePath = relativeWorkspacePath(resolveWorkspacePath(validateFile));
|
|
319
|
+
const result = await runObservedN8nac(observer, ['skills', 'validate', filePath], cwd);
|
|
320
|
+
return {
|
|
321
|
+
exitCode: result.exitCode,
|
|
322
|
+
timedOut: result.timedOut,
|
|
323
|
+
stdout: truncateText(result.stdout),
|
|
324
|
+
stderr: truncateText(result.stderr),
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
if (action === 'update_ai') {
|
|
328
|
+
const result = await runObservedN8nac(observer, ['update-ai'], cwd);
|
|
329
|
+
return {
|
|
330
|
+
exitCode: result.exitCode,
|
|
331
|
+
timedOut: result.timedOut,
|
|
332
|
+
stdout: truncateText(result.stdout),
|
|
333
|
+
stderr: truncateText(result.stderr),
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
if (!workflowId || !resolveMode) {
|
|
337
|
+
throw new Error('resolve requires workflowId and resolveMode');
|
|
338
|
+
}
|
|
339
|
+
const result = await runObservedN8nac(observer, ['resolve', workflowId, '--mode', resolveMode], cwd);
|
|
340
|
+
return {
|
|
341
|
+
exitCode: result.exitCode,
|
|
342
|
+
timedOut: result.timedOut,
|
|
343
|
+
stdout: truncateText(result.stdout),
|
|
344
|
+
stderr: truncateText(result.stderr),
|
|
345
|
+
};
|
|
346
|
+
},
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
//# sourceMappingURL=n8nac.js.map
|