@startanaicompany/crm 2.4.0 → 2.5.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/README.md +130 -49
- package/index.js +115 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,43 +10,56 @@ npm install -g @startanaicompany/crm
|
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## 🏢 Multi-Tenant Architecture
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
This CRM is **multi-tenant**: each company gets its own isolated workspace. All data (leads, contacts, calls, contracts, etc.) is completely separated between workspaces.
|
|
16
|
+
|
|
17
|
+
- One workspace slug per company (e.g. `mygardeningcompany`, `johnscarshop`)
|
|
18
|
+
- All agents of a company share the same workspace — one key per "fleet" or one key per agent, your choice
|
|
19
|
+
- Cross-workspace data access is impossible: a key from workspace `mygardeningcompany` can never see data from `johnscarshop`
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 🤖 AI Agent Quick Start (zero-auth)
|
|
24
|
+
|
|
25
|
+
Agents bootstrap themselves in two steps:
|
|
16
26
|
|
|
17
27
|
```bash
|
|
18
|
-
# Step 1:
|
|
19
|
-
saac_crm config set --url https://
|
|
20
|
-
|
|
21
|
-
#
|
|
28
|
+
# Step 1: Point at the CRM deployment
|
|
29
|
+
saac_crm config set --url https://crm.startanaicompany.com
|
|
30
|
+
|
|
31
|
+
# Step 2: Bootstrap your workspace + get an API key (no auth needed, no human required)
|
|
32
|
+
saac_crm workspace init --workspace mygardeningcompany --name my-agent
|
|
33
|
+
# → Returns crm_xxxx API key + saves key + workspace to ~/.saac_crm/config.json
|
|
22
34
|
|
|
23
|
-
# Step
|
|
24
|
-
export SAAC_CRM_API_KEY=crm_xxxxxxxxxxxx
|
|
35
|
+
# Step 3: Start working (workspace is automatically used from config)
|
|
25
36
|
saac_crm leads create --name "Jane Smith" --email "jane@example.com"
|
|
26
37
|
saac_crm leads list
|
|
38
|
+
|
|
39
|
+
# Optional: attribute actions to a named agent for audit trail
|
|
40
|
+
saac_crm leads create --name "Bob Jones" --email "bob@example.com" --from-agent-name "discovery-agent-v2"
|
|
27
41
|
```
|
|
28
42
|
|
|
29
43
|
> **Auth priority**: `--api-key` flag > `SAAC_CRM_API_KEY` env var > config file (`~/.saac_crm/config.json`)
|
|
44
|
+
> **Workspace priority**: `--workspace` flag > `SAAC_CRM_WORKSPACE` env var > config file `workspace` field
|
|
30
45
|
|
|
31
|
-
> ⚠️ **Agents:
|
|
46
|
+
> ⚠️ **Agents: `workspace init` is idempotent** — if the workspace already exists, it just creates a new key for it. Safe to call from any agent on first run.
|
|
32
47
|
|
|
33
48
|
---
|
|
34
49
|
|
|
35
50
|
## 👤 Operator Setup (one-time, human)
|
|
36
51
|
|
|
37
|
-
|
|
52
|
+
For the initial admin setup or to create admin-scope keys:
|
|
38
53
|
|
|
39
54
|
```bash
|
|
40
55
|
# 1. Point at your deployment
|
|
41
|
-
saac_crm config set --url https://
|
|
56
|
+
saac_crm config set --url https://crm.startanaicompany.com
|
|
42
57
|
|
|
43
|
-
# 2.
|
|
44
|
-
saac_crm
|
|
45
|
-
# →
|
|
46
|
-
# → prompts: Deployment admin password:
|
|
47
|
-
# → returns crm_xxx admin key — store securely
|
|
58
|
+
# 2. Create admin-scope key for your workspace (requires deployment admin password)
|
|
59
|
+
saac_crm keys create --name "admin-key" --workspace mycompany --scope admin
|
|
60
|
+
# → Prompts for admin password
|
|
48
61
|
|
|
49
|
-
# 3. Save admin key and create first human user account
|
|
62
|
+
# 3. Save admin key to config and create the first human user account
|
|
50
63
|
saac_crm config set --api-key crm_xxx_admin_key
|
|
51
64
|
saac_crm users create --email admin@example.com --name "Admin" --role admin
|
|
52
65
|
```
|
|
@@ -55,17 +68,27 @@ saac_crm users create --email admin@example.com --name "Admin" --role admin
|
|
|
55
68
|
|
|
56
69
|
## Commands
|
|
57
70
|
|
|
71
|
+
### Workspace
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# Bootstrap workspace + create API key in one step (recommended for agent auto-init)
|
|
75
|
+
saac_crm workspace init --workspace mycompany --name "my-agent"
|
|
76
|
+
saac_crm workspace init --workspace mycompany --name "admin-key" --scope admin
|
|
77
|
+
|
|
78
|
+
# Via REST: POST /api/v1/workspaces/register
|
|
79
|
+
# Body: { workspace, key_name, scope?, admin_password? }
|
|
80
|
+
```
|
|
81
|
+
|
|
58
82
|
### API Keys
|
|
59
83
|
|
|
60
84
|
```bash
|
|
61
|
-
# Create agent key —
|
|
62
|
-
saac_crm keys create --name "my-agent"
|
|
85
|
+
# Create agent key — workspace required (auto-creates workspace if it doesn't exist yet)
|
|
86
|
+
saac_crm keys create --name "my-agent" --workspace mycompany
|
|
63
87
|
|
|
64
|
-
# Create admin scope key (
|
|
65
|
-
saac_crm keys create --name "admin-key" --scope admin
|
|
66
|
-
--workspace mycompany --admin-password <deployment-password>
|
|
88
|
+
# Create admin scope key (requires deployment password)
|
|
89
|
+
saac_crm keys create --name "admin-key" --workspace mycompany --scope admin
|
|
67
90
|
|
|
68
|
-
# List all keys
|
|
91
|
+
# List all keys in current workspace
|
|
69
92
|
saac_crm keys list
|
|
70
93
|
|
|
71
94
|
# Show current key info
|
|
@@ -78,11 +101,11 @@ saac_crm keys revoke <id>
|
|
|
78
101
|
### Leads
|
|
79
102
|
|
|
80
103
|
```bash
|
|
81
|
-
# Create a lead
|
|
82
|
-
saac_crm leads create --name "Jane Smith" --email "jane@example.com" --company "Acme"
|
|
104
|
+
# Create a lead (optional: --from-agent-name for audit trail)
|
|
105
|
+
saac_crm leads create --name "Jane Smith" --email "jane@example.com" --company "Acme" --from-agent-name "lead-gen-agent"
|
|
83
106
|
|
|
84
107
|
# List leads (with filters)
|
|
85
|
-
saac_crm leads list --status new --tag vip
|
|
108
|
+
saac_crm leads list --status new --tag vip
|
|
86
109
|
|
|
87
110
|
# Get single lead
|
|
88
111
|
saac_crm leads get <id>
|
|
@@ -95,22 +118,76 @@ saac_crm leads delete <id>
|
|
|
95
118
|
|
|
96
119
|
# Status change history
|
|
97
120
|
saac_crm leads history <id>
|
|
121
|
+
|
|
122
|
+
# Move lead to pipeline stage
|
|
123
|
+
saac_crm leads stage <id> --stage discovery
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Contacts
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
saac_crm contacts create --email contact@example.com --first-name "Jane" --from-agent-name "enrichment-agent"
|
|
130
|
+
saac_crm contacts list
|
|
131
|
+
saac_crm contacts get <id>
|
|
132
|
+
saac_crm contacts update <id> --company "Acme"
|
|
133
|
+
saac_crm contacts delete <id>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Calls
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
saac_crm calls create --lead-id <id> --direction outbound --outcome connected --from-agent-name "call-agent"
|
|
140
|
+
saac_crm calls list [--lead-id <id>]
|
|
141
|
+
saac_crm calls get <id>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Meetings
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
saac_crm meetings create --lead-id <id> --title "Demo call" --from-agent-name "scheduler-agent"
|
|
148
|
+
saac_crm meetings list
|
|
149
|
+
saac_crm meetings get <id>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Emails
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
saac_crm emails create --lead-id <id> --subject "Follow-up" --direction sent --from-agent-name "outreach-agent"
|
|
156
|
+
saac_crm emails list [--lead-id <id>]
|
|
157
|
+
saac_crm emails get <id>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Quotes
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
saac_crm quotes create --lead-id <id> --title "Q-2026-001" --value 5000 --from-agent-name "quote-agent"
|
|
164
|
+
saac_crm quotes list
|
|
165
|
+
saac_crm quotes get <id>
|
|
166
|
+
saac_crm quotes status <id> --status accepted
|
|
167
|
+
saac_crm quotes add-line <id> --description "License" --quantity 1 --unit-price 5000
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Contracts
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
saac_crm contracts create --lead-id <id> --title "Service Agreement" --from-agent-name "contract-agent"
|
|
174
|
+
saac_crm contracts list
|
|
175
|
+
saac_crm contracts get <id>
|
|
176
|
+
saac_crm contracts status <id> --status sent
|
|
177
|
+
saac_crm contracts signatories <id>
|
|
178
|
+
saac_crm contracts add-signatory <id> --contact-id <cid> --party customer --role signer
|
|
179
|
+
saac_crm contracts sign <id> --contact-id <cid>
|
|
180
|
+
saac_crm contracts decline-signature <id> --contact-id <cid>
|
|
181
|
+
saac_crm contracts remind-signatory <id> --contact-id <cid>
|
|
182
|
+
saac_crm contracts remind-all-pending <id>
|
|
98
183
|
```
|
|
99
184
|
|
|
100
185
|
### Users (requires admin scope key)
|
|
101
186
|
|
|
102
187
|
```bash
|
|
103
|
-
# Create a human user account (both commands are equivalent)
|
|
104
188
|
saac_crm users create --email admin@example.com --name "Admin User" --role admin
|
|
105
|
-
saac_crm users register --email admin@example.com --name "Admin User" --role admin
|
|
106
|
-
|
|
107
|
-
# List users
|
|
108
189
|
saac_crm users list
|
|
109
|
-
|
|
110
|
-
# Update user
|
|
111
190
|
saac_crm users update <id> --role viewer
|
|
112
|
-
|
|
113
|
-
# Deactivate user
|
|
114
191
|
saac_crm users deactivate <id>
|
|
115
192
|
```
|
|
116
193
|
|
|
@@ -119,23 +196,16 @@ saac_crm users deactivate <id>
|
|
|
119
196
|
```bash
|
|
120
197
|
# Log in as admin/viewer — saves JWT to config for dashboard access
|
|
121
198
|
saac_crm login --workspace mycompany --email admin@example.com
|
|
122
|
-
# →
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### Workspace Registration (operator only)
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
# First-time setup — registers workspace slug + creates admin key
|
|
129
|
-
# Prompts for --workspace and --admin-password if not provided
|
|
130
|
-
saac_crm register --name "main-admin-key"
|
|
131
|
-
saac_crm register --name "main-admin-key" --workspace mycompany --admin-password <pw>
|
|
199
|
+
# → Prompts for password, saves JWT to ~/.saac_crm/config.json
|
|
132
200
|
```
|
|
133
201
|
|
|
134
202
|
### Configuration
|
|
135
203
|
|
|
136
204
|
```bash
|
|
137
|
-
saac_crm config set --url https://
|
|
205
|
+
saac_crm config set --url https://crm.startanaicompany.com
|
|
138
206
|
saac_crm config set --api-key crm_xxxxxxxxxxxx
|
|
207
|
+
saac_crm config set --workspace mycompany
|
|
208
|
+
saac_crm config set --agent-name "my-agent-v2" # default --from-agent-name for all commands
|
|
139
209
|
saac_crm config get
|
|
140
210
|
```
|
|
141
211
|
|
|
@@ -146,10 +216,21 @@ saac_crm config get
|
|
|
146
216
|
--url <url> Override API base URL for this command
|
|
147
217
|
```
|
|
148
218
|
|
|
219
|
+
## `--from-agent-name` Attribution
|
|
220
|
+
|
|
221
|
+
Pass `--from-agent-name <name>` (or set `SAAC_CRM_AGENT_NAME` env / `config.defaultAgentName`) on any create command to attribute the action to a named agent. This is for **audit trail only** — it does NOT affect authentication or authorization. The same workspace key is shared across all agents of that workspace.
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
export SAAC_CRM_AGENT_NAME=discovery-agent-v2
|
|
225
|
+
saac_crm leads create --name "Alice" --email "alice@example.com"
|
|
226
|
+
# → lead.from_agent_name = "discovery-agent-v2"
|
|
227
|
+
```
|
|
228
|
+
|
|
149
229
|
## Architecture
|
|
150
230
|
|
|
151
|
-
This is a **
|
|
231
|
+
This is a **multi-tenant** system: multiple workspace slugs per deployment, each fully isolated.
|
|
152
232
|
|
|
153
|
-
- **Agents** →
|
|
154
|
-
- **Operators** → `
|
|
155
|
-
- **Humans** → `login` → web dashboard
|
|
233
|
+
- **Agents** → `workspace init` once → `leads create` → manage leads with workspace isolation
|
|
234
|
+
- **Operators** → `keys create --scope admin` → `users create` → human accounts
|
|
235
|
+
- **Humans** → `login` → web dashboard (only shows their workspace's data)
|
|
236
|
+
- **Audit** → `--from-agent-name` for per-agent attribution within a workspace
|
package/index.js
CHANGED
|
@@ -43,7 +43,21 @@ function resolveApiUrl(cliUrl) {
|
|
|
43
43
|
return cfg.apiUrl || null;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
function
|
|
46
|
+
function resolveWorkspace(cliWorkspace) {
|
|
47
|
+
if (cliWorkspace) return cliWorkspace;
|
|
48
|
+
if (process.env.SAAC_CRM_WORKSPACE) return process.env.SAAC_CRM_WORKSPACE;
|
|
49
|
+
const cfg = loadConfig();
|
|
50
|
+
return cfg.workspace || null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function resolveAgentName(cliAgentName) {
|
|
54
|
+
if (cliAgentName) return cliAgentName;
|
|
55
|
+
if (process.env.SAAC_CRM_AGENT_NAME) return process.env.SAAC_CRM_AGENT_NAME;
|
|
56
|
+
const cfg = loadConfig();
|
|
57
|
+
return cfg.defaultAgentName || null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function getClient(options = {}, agentName = null) {
|
|
47
61
|
const apiKey = resolveApiKey(options.apiKey);
|
|
48
62
|
const apiUrl = resolveApiUrl(options.url);
|
|
49
63
|
|
|
@@ -56,12 +70,15 @@ function getClient(options = {}) {
|
|
|
56
70
|
process.exit(1);
|
|
57
71
|
}
|
|
58
72
|
|
|
73
|
+
const headers = {
|
|
74
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
75
|
+
'Content-Type': 'application/json'
|
|
76
|
+
};
|
|
77
|
+
if (agentName) headers['X-Agent-Name'] = agentName;
|
|
78
|
+
|
|
59
79
|
return axios.create({
|
|
60
80
|
baseURL: `${apiUrl.replace(/\/$/, '')}/api/v1`,
|
|
61
|
-
headers
|
|
62
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
63
|
-
'Content-Type': 'application/json'
|
|
64
|
-
}
|
|
81
|
+
headers
|
|
65
82
|
});
|
|
66
83
|
}
|
|
67
84
|
|
|
@@ -116,6 +133,8 @@ configCmd
|
|
|
116
133
|
.description('Set configuration values')
|
|
117
134
|
.option('--url <url>', 'CRM API base URL (e.g. https://yourapp.example.com)')
|
|
118
135
|
.option('--api-key <key>', 'Default API key to use')
|
|
136
|
+
.option('--workspace <slug>', 'Default workspace slug')
|
|
137
|
+
.option('--agent-name <name>', 'Default agent name for attribution (stored as defaultAgentName)')
|
|
119
138
|
.action((opts) => {
|
|
120
139
|
// NOTE: commander.js may consume --url and --api-key at the parent program level
|
|
121
140
|
// if they share the same option names. Always fall back to program.opts().
|
|
@@ -125,6 +144,8 @@ configCmd
|
|
|
125
144
|
const apiKeyValue = opts.apiKey || globalOpts.apiKey;
|
|
126
145
|
if (urlValue) cfg.apiUrl = urlValue;
|
|
127
146
|
if (apiKeyValue) cfg.apiKey = apiKeyValue;
|
|
147
|
+
if (opts.workspace) cfg.workspace = opts.workspace;
|
|
148
|
+
if (opts.agentName) cfg.defaultAgentName = opts.agentName;
|
|
128
149
|
saveConfig(cfg);
|
|
129
150
|
console.log('Configuration saved to', CONFIG_FILE);
|
|
130
151
|
printJSON(cfg);
|
|
@@ -151,7 +172,7 @@ keysCmd
|
|
|
151
172
|
.description('Create a new API key')
|
|
152
173
|
.requiredOption('--name <name>', 'Name/label for the key')
|
|
153
174
|
.option('--scope <scope>', 'Key scope: agent (default) or admin', 'agent')
|
|
154
|
-
.option('--workspace <slug>', 'Workspace slug (
|
|
175
|
+
.option('--workspace <slug>', 'Workspace slug (falls back to config workspace)')
|
|
155
176
|
.option('--admin-password <password>', 'Admin password (required for scope=admin)')
|
|
156
177
|
.action(async (opts) => {
|
|
157
178
|
const globalOpts = program.opts();
|
|
@@ -161,15 +182,15 @@ keysCmd
|
|
|
161
182
|
process.exit(1);
|
|
162
183
|
}
|
|
163
184
|
|
|
164
|
-
const
|
|
185
|
+
const workspace = resolveWorkspace(opts.workspace);
|
|
186
|
+
if (!workspace) {
|
|
187
|
+
console.error('Error: --workspace <slug> is required (or set in config via: saac_crm config set --workspace <slug>)');
|
|
188
|
+
process.exit(1);
|
|
189
|
+
}
|
|
165
190
|
|
|
166
|
-
|
|
167
|
-
if (!opts.workspace) {
|
|
168
|
-
console.error('Error: --workspace <slug> is required for scope=admin');
|
|
169
|
-
process.exit(1);
|
|
170
|
-
}
|
|
171
|
-
body.workspace = opts.workspace;
|
|
191
|
+
const body = { name: opts.name, scope: opts.scope, workspace };
|
|
172
192
|
|
|
193
|
+
if (opts.scope === 'admin') {
|
|
173
194
|
let adminPw = opts.adminPassword;
|
|
174
195
|
if (!adminPw) {
|
|
175
196
|
adminPw = await promptSecret('Admin password: ');
|
|
@@ -242,6 +263,64 @@ program
|
|
|
242
263
|
}
|
|
243
264
|
});
|
|
244
265
|
|
|
266
|
+
// ============================================================
|
|
267
|
+
// WORKSPACE COMMANDS
|
|
268
|
+
// ============================================================
|
|
269
|
+
|
|
270
|
+
const workspaceCmd = program.command('workspace').description('Manage CRM workspaces');
|
|
271
|
+
|
|
272
|
+
workspaceCmd
|
|
273
|
+
.command('init')
|
|
274
|
+
.description('Bootstrap a new workspace: register slug + create API key, save to config')
|
|
275
|
+
.requiredOption('--workspace <slug>', 'Workspace slug (3-50 chars, a-z0-9/dash/underscore)')
|
|
276
|
+
.requiredOption('--name <keyname>', 'Name/label for the initial API key')
|
|
277
|
+
.option('--scope <scope>', 'Key scope: agent (default) or admin', 'agent')
|
|
278
|
+
.option('--admin-password <password>', 'Admin password (required for scope=admin; will prompt if not provided)')
|
|
279
|
+
.option('--save-key', 'Save the returned key to CLI config (default: true)', true)
|
|
280
|
+
.action(async (opts) => {
|
|
281
|
+
const globalOpts = program.opts();
|
|
282
|
+
const apiUrl = resolveApiUrl(globalOpts.url);
|
|
283
|
+
if (!apiUrl) {
|
|
284
|
+
console.error('Error: API URL not configured. Run: saac_crm config set --url <api-url>');
|
|
285
|
+
process.exit(1);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const body = {
|
|
289
|
+
workspace: opts.workspace.trim().toLowerCase(),
|
|
290
|
+
key_name: opts.name,
|
|
291
|
+
scope: opts.scope
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
if (opts.scope === 'admin') {
|
|
295
|
+
let adminPw = opts.adminPassword;
|
|
296
|
+
if (!adminPw) {
|
|
297
|
+
adminPw = await promptSecret('Admin password: ');
|
|
298
|
+
}
|
|
299
|
+
body.admin_password = adminPw;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
try {
|
|
303
|
+
const res = await axios.post(
|
|
304
|
+
`${apiUrl.replace(/\/$/, '')}/api/v1/workspaces/register`,
|
|
305
|
+
body,
|
|
306
|
+
{ headers: { 'Content-Type': 'application/json' } }
|
|
307
|
+
);
|
|
308
|
+
const data = res.data.data;
|
|
309
|
+
console.log(`Workspace '${data.workspace}' initialized. API key created.`);
|
|
310
|
+
console.log('Store the key — it will not be shown again.');
|
|
311
|
+
printJSON(data);
|
|
312
|
+
|
|
313
|
+
// Auto-save to config
|
|
314
|
+
const cfg = loadConfig();
|
|
315
|
+
cfg.apiKey = data.key;
|
|
316
|
+
cfg.workspace = data.workspace;
|
|
317
|
+
saveConfig(cfg);
|
|
318
|
+
console.log(`\nKey and workspace saved to config: ${CONFIG_FILE}`);
|
|
319
|
+
} catch (err) {
|
|
320
|
+
handleError(err);
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
|
|
245
324
|
keysCmd
|
|
246
325
|
.command('list')
|
|
247
326
|
.description('List all API keys (metadata only)')
|
|
@@ -307,9 +386,11 @@ leadsCmd
|
|
|
307
386
|
.option('--tag <tag>', 'Tag (repeatable)', (v, prev) => prev.concat([v]), [])
|
|
308
387
|
.option('--external-id <externalId>', 'External ID')
|
|
309
388
|
.option('--idempotency-key <key>', 'Idempotency key for deduplication')
|
|
389
|
+
.option('--from-agent-name <name>', 'Agent name for attribution (falls back to config defaultAgentName)')
|
|
310
390
|
.action(async (opts) => {
|
|
311
391
|
const globalOpts = program.opts();
|
|
312
|
-
const
|
|
392
|
+
const agentName = resolveAgentName(opts.fromAgentName);
|
|
393
|
+
const client = getClient(globalOpts, agentName);
|
|
313
394
|
const headers = {};
|
|
314
395
|
if (opts.idempotencyKey) headers['Idempotency-Key'] = opts.idempotencyKey;
|
|
315
396
|
const body = {
|
|
@@ -624,9 +705,11 @@ contactsCmd
|
|
|
624
705
|
.option('--tags <tags>', 'Comma-separated tags')
|
|
625
706
|
.option('--do-not-contact', 'Mark as do not contact')
|
|
626
707
|
.option('--notes <notes>', 'Notes')
|
|
708
|
+
.option('--from-agent-name <name>', 'Agent name for attribution (falls back to config defaultAgentName)')
|
|
627
709
|
.action(async (opts) => {
|
|
628
710
|
const globalOpts = program.opts();
|
|
629
|
-
const
|
|
711
|
+
const agentName = resolveAgentName(opts.fromAgentName);
|
|
712
|
+
const client = getClient(globalOpts, agentName);
|
|
630
713
|
try {
|
|
631
714
|
const body = {
|
|
632
715
|
first_name: opts.firstName,
|
|
@@ -780,9 +863,11 @@ callsCmd
|
|
|
780
863
|
.option('--duration <seconds>', 'Duration in seconds')
|
|
781
864
|
.option('--notes <notes>', 'Call notes')
|
|
782
865
|
.option('--call-time <iso>', 'Call time (ISO8601, defaults to now)')
|
|
866
|
+
.option('--from-agent-name <name>', 'Agent name for attribution (falls back to config defaultAgentName)')
|
|
783
867
|
.action(async (opts) => {
|
|
784
868
|
const globalOpts = program.opts();
|
|
785
|
-
const
|
|
869
|
+
const agentName = resolveAgentName(opts.fromAgentName);
|
|
870
|
+
const client = getClient(globalOpts, agentName);
|
|
786
871
|
try {
|
|
787
872
|
const body = { direction: opts.direction };
|
|
788
873
|
if (opts.leadId) body.lead_id = opts.leadId;
|
|
@@ -948,9 +1033,11 @@ meetingsCmd
|
|
|
948
1033
|
.option('--notes <notes>', 'Meeting notes or agenda')
|
|
949
1034
|
.option('--outcome <outcome>', 'scheduled | completed | cancelled | no_show')
|
|
950
1035
|
.option('--sentiment <sentiment>', 'positive | neutral | negative | unknown')
|
|
1036
|
+
.option('--from-agent-name <name>', 'Agent name for attribution (falls back to config defaultAgentName)')
|
|
951
1037
|
.action(async (opts) => {
|
|
952
1038
|
const globalOpts = program.opts();
|
|
953
|
-
const
|
|
1039
|
+
const agentName = resolveAgentName(opts.fromAgentName);
|
|
1040
|
+
const client = getClient(globalOpts, agentName);
|
|
954
1041
|
try {
|
|
955
1042
|
const body = {
|
|
956
1043
|
title: opts.title,
|
|
@@ -1078,9 +1165,11 @@ emailsCmd
|
|
|
1078
1165
|
.option('--body-summary <summary>', 'Body summary (max 1000 chars)')
|
|
1079
1166
|
.option('--thread-id <id>', 'Thread ID for grouping related emails')
|
|
1080
1167
|
.option('--email-timestamp <iso>', 'When the email was sent/received (ISO8601, defaults to now)')
|
|
1168
|
+
.option('--from-agent-name <name>', 'Agent name for attribution (falls back to config defaultAgentName)')
|
|
1081
1169
|
.action(async (opts) => {
|
|
1082
1170
|
const globalOpts = program.opts();
|
|
1083
|
-
const
|
|
1171
|
+
const agentName = resolveAgentName(opts.fromAgentName);
|
|
1172
|
+
const client = getClient(globalOpts, agentName);
|
|
1084
1173
|
try {
|
|
1085
1174
|
const body = {
|
|
1086
1175
|
direction: opts.direction,
|
|
@@ -1171,9 +1260,11 @@ quotesCmd
|
|
|
1171
1260
|
.option('--currency <code>', 'Currency code (default: USD)')
|
|
1172
1261
|
.option('--validity-date <date>', 'Validity date (YYYY-MM-DD)')
|
|
1173
1262
|
.option('--notes <notes>', 'Notes')
|
|
1263
|
+
.option('--from-agent-name <name>', 'Agent name for attribution (falls back to config defaultAgentName)')
|
|
1174
1264
|
.action(async (opts) => {
|
|
1175
1265
|
const globalOpts = program.opts();
|
|
1176
|
-
const
|
|
1266
|
+
const agentName = resolveAgentName(opts.fromAgentName);
|
|
1267
|
+
const client = getClient(globalOpts, agentName);
|
|
1177
1268
|
try {
|
|
1178
1269
|
|
|
1179
1270
|
const res = await client.post('/quotes', {
|
|
@@ -1185,7 +1276,7 @@ quotesCmd
|
|
|
1185
1276
|
notes: opts.notes
|
|
1186
1277
|
});
|
|
1187
1278
|
printJSON(res.data);
|
|
1188
|
-
|
|
1279
|
+
|
|
1189
1280
|
} catch (err) {
|
|
1190
1281
|
handleError(err);
|
|
1191
1282
|
}
|
|
@@ -1396,9 +1487,11 @@ contractsCmd
|
|
|
1396
1487
|
.option('--end-date <date>', 'End date (YYYY-MM-DD)')
|
|
1397
1488
|
.option('--document-url <url>', 'Document URL reference')
|
|
1398
1489
|
.option('--notes <notes>', 'Notes')
|
|
1490
|
+
.option('--from-agent-name <name>', 'Agent name for attribution (falls back to config defaultAgentName)')
|
|
1399
1491
|
.action(async (opts) => {
|
|
1400
1492
|
const globalOpts = program.opts();
|
|
1401
|
-
const
|
|
1493
|
+
const agentName = resolveAgentName(opts.fromAgentName);
|
|
1494
|
+
const client = getClient(globalOpts, agentName);
|
|
1402
1495
|
try {
|
|
1403
1496
|
|
|
1404
1497
|
const res = await client.post('/contracts', {
|
|
@@ -1414,7 +1507,7 @@ contractsCmd
|
|
|
1414
1507
|
notes: opts.notes
|
|
1415
1508
|
});
|
|
1416
1509
|
printJSON(res.data);
|
|
1417
|
-
|
|
1510
|
+
|
|
1418
1511
|
} catch (err) {
|
|
1419
1512
|
handleError(err);
|
|
1420
1513
|
}
|