@crmy/cli 0.5.2 → 0.5.3

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.
@@ -1,119 +0,0 @@
1
- // Copyright 2026 CRMy Contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import { Command } from 'commander';
5
- import { getClient } from '../client.js';
6
-
7
- export function workflowsCommand(): Command {
8
- const cmd = new Command('workflows').description('Manage automation workflows');
9
-
10
- cmd.command('list')
11
- .option('--trigger <event>', 'Filter by trigger event')
12
- .option('--active', 'Show only active workflows')
13
- .action(async (opts) => {
14
- const client = await getClient();
15
- const result = await client.call('workflow_list', {
16
- trigger_event: opts.trigger,
17
- is_active: opts.active ?? undefined,
18
- limit: 20,
19
- });
20
- const data = JSON.parse(result);
21
- if (data.workflows?.length === 0) {
22
- console.log('No workflows found.');
23
- return;
24
- }
25
- console.table(data.workflows?.map((w: Record<string, unknown>) => ({
26
- id: (w.id as string).slice(0, 8),
27
- name: w.name,
28
- trigger: w.trigger_event,
29
- active: w.is_active,
30
- runs: w.run_count,
31
- })));
32
- await client.close();
33
- });
34
-
35
- cmd.command('get <id>')
36
- .action(async (id) => {
37
- const client = await getClient();
38
- const result = await client.call('workflow_get', { id });
39
- const data = JSON.parse(result);
40
- console.log('\nWorkflow:', data.workflow.name);
41
- console.log('Trigger:', data.workflow.trigger_event);
42
- console.log('Active:', data.workflow.is_active);
43
- console.log('Actions:', JSON.stringify(data.workflow.actions, null, 2));
44
- if (data.recent_runs?.length > 0) {
45
- console.log('\nRecent runs:');
46
- console.table(data.recent_runs.map((r: Record<string, unknown>) => ({
47
- id: (r.id as string).slice(0, 8),
48
- status: r.status,
49
- actions: `${r.actions_run}/${r.actions_total}`,
50
- started: r.started_at,
51
- })));
52
- }
53
- await client.close();
54
- });
55
-
56
- cmd.command('create')
57
- .action(async () => {
58
- const { default: inquirer } = await import('inquirer');
59
- const answers = await inquirer.prompt([
60
- { type: 'input', name: 'name', message: 'Workflow name:' },
61
- { type: 'input', name: 'trigger_event', message: 'Trigger event (e.g. contact.created):' },
62
- { type: 'input', name: 'description', message: 'Description:' },
63
- ]);
64
-
65
- // Simple single-action workflow via interactive prompt
66
- const actionAnswers = await inquirer.prompt([
67
- {
68
- type: 'list', name: 'type', message: 'Action type:',
69
- choices: ['send_notification', 'create_activity', 'create_note', 'add_tag', 'webhook'],
70
- },
71
- { type: 'input', name: 'message', message: 'Action message/body:' },
72
- ]);
73
-
74
- const client = await getClient();
75
- const result = await client.call('workflow_create', {
76
- name: answers.name,
77
- description: answers.description || undefined,
78
- trigger_event: answers.trigger_event,
79
- actions: [{ type: actionAnswers.type, config: { message: actionAnswers.message } }],
80
- });
81
- const data = JSON.parse(result);
82
- console.log(`\n Created workflow: ${data.workflow.id}\n`);
83
- await client.close();
84
- });
85
-
86
- cmd.command('delete <id>')
87
- .action(async (id) => {
88
- const client = await getClient();
89
- const result = await client.call('workflow_delete', { id });
90
- console.log(JSON.parse(result));
91
- await client.close();
92
- });
93
-
94
- cmd.command('runs <workflow_id>')
95
- .option('--status <status>', 'Filter: running, completed, failed')
96
- .action(async (workflowId, opts) => {
97
- const client = await getClient();
98
- const result = await client.call('workflow_run_list', {
99
- workflow_id: workflowId,
100
- status: opts.status,
101
- limit: 20,
102
- });
103
- const data = JSON.parse(result);
104
- if (data.runs?.length === 0) {
105
- console.log('No runs found.');
106
- return;
107
- }
108
- console.table(data.runs?.map((r: Record<string, unknown>) => ({
109
- id: (r.id as string).slice(0, 8),
110
- status: r.status,
111
- actions: `${r.actions_run}/${r.actions_total}`,
112
- error: r.error ?? '',
113
- started: r.started_at,
114
- })));
115
- await client.close();
116
- });
117
-
118
- return cmd;
119
- }
package/src/config.ts DELETED
@@ -1,74 +0,0 @@
1
- // Copyright 2026 CRMy Contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import fs from 'node:fs';
5
- import path from 'node:path';
6
- import os from 'node:os';
7
-
8
- export interface CrmyConfig {
9
- serverUrl?: string;
10
- apiKey?: string;
11
- tenantId?: string;
12
- database?: { url?: string };
13
- jwtSecret?: string;
14
- hitl?: { requireApproval?: string[]; autoApproveSeconds?: number };
15
- }
16
-
17
- export interface AuthState {
18
- serverUrl: string;
19
- token: string;
20
- user: { id: string; email: string; name: string; role: string; tenant_id: string };
21
- expiresAt?: string;
22
- }
23
-
24
- const AUTH_DIR = path.join(os.homedir(), '.crmy');
25
- const AUTH_FILE = path.join(AUTH_DIR, 'auth.json');
26
-
27
- export function loadConfigFile(): CrmyConfig {
28
- const configPath = path.join(process.cwd(), '.crmy.json');
29
- try {
30
- const raw = fs.readFileSync(configPath, 'utf-8');
31
- return JSON.parse(raw) as CrmyConfig;
32
- } catch {
33
- return {};
34
- }
35
- }
36
-
37
- export function saveConfigFile(config: CrmyConfig): void {
38
- const configPath = path.join(process.cwd(), '.crmy.json');
39
- fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
40
- }
41
-
42
- export function loadAuthState(): AuthState | null {
43
- try {
44
- const raw = fs.readFileSync(AUTH_FILE, 'utf-8');
45
- const state = JSON.parse(raw) as AuthState;
46
- // Check if token is expired
47
- if (state.expiresAt && new Date(state.expiresAt) < new Date()) {
48
- return null;
49
- }
50
- return state;
51
- } catch {
52
- return null;
53
- }
54
- }
55
-
56
- export function saveAuthState(state: AuthState): void {
57
- fs.mkdirSync(AUTH_DIR, { recursive: true });
58
- fs.writeFileSync(AUTH_FILE, JSON.stringify(state, null, 2) + '\n', { mode: 0o600 });
59
- }
60
-
61
- export function clearAuthState(): void {
62
- try {
63
- fs.unlinkSync(AUTH_FILE);
64
- } catch {
65
- // ignore if doesn't exist
66
- }
67
- }
68
-
69
- /** Resolve the server URL from auth state, config, env, or default */
70
- export function resolveServerUrl(): string | undefined {
71
- return process.env.CRMY_SERVER_URL
72
- ?? loadAuthState()?.serverUrl
73
- ?? loadConfigFile().serverUrl;
74
- }
package/src/index.ts DELETED
@@ -1,80 +0,0 @@
1
- #!/usr/bin/env node
2
- // Copyright 2026 CRMy Contributors
3
- // SPDX-License-Identifier: Apache-2.0
4
-
5
- import { Command } from 'commander';
6
- import { initCommand } from './commands/init.js';
7
- import { serverCommand } from './commands/server.js';
8
- import { mcpCommand } from './commands/mcp.js';
9
- import { contactsCommand } from './commands/contacts.js';
10
- import { accountsCommand } from './commands/accounts.js';
11
- import { oppsCommand } from './commands/opps.js';
12
- import { pipelineCommand } from './commands/pipeline.js';
13
- import { searchCommand } from './commands/search.js';
14
- import { hitlCommand } from './commands/hitl.js';
15
- import { eventsCommand } from './commands/events.js';
16
- import { configCommand } from './commands/config.js';
17
- import { migrateCommand } from './commands/migrate.js';
18
- import { useCasesCommand } from './commands/use-cases.js';
19
- import { webhooksCommand } from './commands/webhooks.js';
20
- import { emailsCommand } from './commands/emails.js';
21
- import { customFieldsCommand } from './commands/custom-fields.js';
22
- import { notesCommand } from './commands/notes.js';
23
- import { workflowsCommand } from './commands/workflows.js';
24
- import { actorsCommand } from './commands/actors.js';
25
- import { assignmentsCommand } from './commands/assignments.js';
26
- import { contextCommand } from './commands/context.js';
27
- import { activityTypesCommand } from './commands/activity-types.js';
28
- import { contextTypesCommand } from './commands/context-types.js';
29
- import { briefingCommand } from './commands/briefing.js';
30
- import { authCommand } from './commands/auth.js';
31
- import { helpCommand } from './commands/help.js';
32
-
33
- const program = new Command();
34
-
35
- program
36
- .name('crmy')
37
- .description('CRMy — The agent-first open source CRM')
38
- .version('0.5.0');
39
-
40
- program.addCommand(authCommand());
41
- program.addCommand(initCommand());
42
- program.addCommand(serverCommand());
43
- program.addCommand(mcpCommand());
44
- program.addCommand(contactsCommand());
45
- program.addCommand(accountsCommand());
46
- program.addCommand(oppsCommand());
47
- program.addCommand(pipelineCommand());
48
- program.addCommand(searchCommand());
49
- program.addCommand(hitlCommand());
50
- program.addCommand(eventsCommand());
51
- program.addCommand(configCommand());
52
- program.addCommand(migrateCommand());
53
- program.addCommand(useCasesCommand());
54
- program.addCommand(webhooksCommand());
55
- program.addCommand(emailsCommand());
56
- program.addCommand(customFieldsCommand());
57
- program.addCommand(notesCommand());
58
- program.addCommand(workflowsCommand());
59
- program.addCommand(actorsCommand());
60
- program.addCommand(assignmentsCommand());
61
- program.addCommand(contextCommand());
62
- program.addCommand(activityTypesCommand());
63
- program.addCommand(contextTypesCommand());
64
- program.addCommand(briefingCommand());
65
- program.addCommand(helpCommand());
66
-
67
- // Top-level `crmy login` shortcut (delegates to `crmy auth login`)
68
- program.command('login')
69
- .description('Sign in to a CRMy server (shortcut for `crmy auth login`)')
70
- .option('-e, --email <email>', 'Email address')
71
- .option('-p, --password <password>', 'Password')
72
- .action(async (opts) => {
73
- // Re-run as `auth login` with same args
74
- const args = ['auth', 'login'];
75
- if (opts.email) args.push('-e', opts.email);
76
- if (opts.password) args.push('-p', opts.password);
77
- await program.parseAsync(['node', 'crmy', ...args]);
78
- });
79
-
80
- program.parse();
package/tsconfig.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "dist",
5
- "rootDir": "src",
6
- "composite": true
7
- },
8
- "include": ["src"],
9
- "references": [
10
- { "path": "../shared" },
11
- { "path": "../server" }
12
- ]
13
- }