careervivid 1.12.1 → 1.12.2

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.
Files changed (38) hide show
  1. package/README.md +218 -135
  2. package/dist/agent/AgentCreditsClient.d.ts +36 -0
  3. package/dist/agent/AgentCreditsClient.d.ts.map +1 -0
  4. package/dist/agent/AgentCreditsClient.js +77 -0
  5. package/dist/agent/QueryEngine.d.ts +2 -1
  6. package/dist/agent/QueryEngine.d.ts.map +1 -1
  7. package/dist/agent/QueryEngine.js +24 -12
  8. package/dist/agent/providers/AnthropicProvider.d.ts +22 -0
  9. package/dist/agent/providers/AnthropicProvider.d.ts.map +1 -0
  10. package/dist/agent/providers/AnthropicProvider.js +235 -0
  11. package/dist/agent/providers/LLMProvider.d.ts +60 -0
  12. package/dist/agent/providers/LLMProvider.d.ts.map +1 -0
  13. package/dist/agent/providers/LLMProvider.js +9 -0
  14. package/dist/agent/providers/OpenAIProvider.d.ts +39 -0
  15. package/dist/agent/providers/OpenAIProvider.d.ts.map +1 -0
  16. package/dist/agent/providers/OpenAIProvider.js +267 -0
  17. package/dist/agent/tools/jobs.d.ts +2 -0
  18. package/dist/agent/tools/jobs.d.ts.map +1 -1
  19. package/dist/agent/tools/jobs.js +93 -2
  20. package/dist/api.d.ts +18 -0
  21. package/dist/api.d.ts.map +1 -1
  22. package/dist/api.js +6 -0
  23. package/dist/commands/agent.d.ts.map +1 -1
  24. package/dist/commands/agent.js +459 -156
  25. package/dist/commands/config.d.ts +6 -1
  26. package/dist/commands/config.d.ts.map +1 -1
  27. package/dist/commands/config.js +58 -27
  28. package/dist/commands/resumes.d.ts +3 -0
  29. package/dist/commands/resumes.d.ts.map +1 -0
  30. package/dist/commands/resumes.js +142 -0
  31. package/dist/config.d.ts +25 -0
  32. package/dist/config.d.ts.map +1 -1
  33. package/dist/config.js +32 -0
  34. package/dist/index.js +2 -0
  35. package/dist/postinstall.d.ts +1 -1
  36. package/dist/postinstall.d.ts.map +1 -1
  37. package/dist/postinstall.js +29 -16
  38. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # careervivid · CLI
2
2
 
3
- > **Publish technical articles, architecture diagrams, and portfolio updates to [CareerVivid](https://careervivid.app) directly from your terminal or AI agent.**
3
+ > **Your AI-powered career terminal publish articles, run autonomous job-hunting agents, and build your portfolio from the command line.**
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/careervivid?color=0ea5e9&label=careervivid)](https://www.npmjs.com/package/careervivid)
6
6
  [![License: MIT](https://img.shields.io/badge/license-MIT-brightgreen)](LICENSE)
@@ -12,15 +12,19 @@
12
12
 
13
13
  - [Quick Start](#quick-start)
14
14
  - [Commands](#commands)
15
+ - [cv agent](#cv-agent) ⭐ **New**
15
16
  - [cv publish](#cv-publish)
17
+ - [cv jobs](#cv-jobs)
16
18
  - [cv whiteboard](#cv-whiteboard)
17
19
  - [cv workspace](#cv-workspace)
18
20
  - [cv profile](#cv-profile)
19
- - [cv jobs](#cv-jobs)
20
21
  - [cv auth](#cv-auth)
22
+ - [cv login](#cv-login)
21
23
  - [cv config](#cv-config)
24
+ - [AI Credits](#ai-credits)
25
+ - [Bring Your Own API Key (BYO)](#bring-your-own-api-key-byo)
22
26
  - [Whiteboard Templates](#whiteboard-templates)
23
- - [AI Agent Integration](#ai-agent-integration)
27
+ - [AI Agent Integration (MCP / CI)](#ai-agent-integration-mcp--ci)
24
28
  - [Updating](#updating)
25
29
  - [Troubleshooting](#troubleshooting)
26
30
 
@@ -32,21 +36,82 @@
32
36
  # 1. Install globally
33
37
  npm install -g careervivid
34
38
 
35
- # 2. Save your API key (get it at careervivid.app/developer)
39
+ # 2. Log in and get your free API key
40
+ cv login
41
+ # → opens careervivid.app/developer in your browser
42
+ # → copy your API key, then:
36
43
  cv auth set-key cv_live_YOUR_KEY_HERE
37
44
 
38
- # 3. Publish an article
39
- cv publish my-article.md --tags "typescript,react"
45
+ # 3. Start the AI agent (uses your free AI credits)
46
+ cv agent
40
47
 
41
- # 4. Create & publish an architecture diagram (shortcuts)
42
- cv new my-arch --template system-arch
43
- cv whiteboard publish my-arch.mmd --title "System Architecture"
48
+ # 4. Or publish an article
49
+ cv publish my-article.md --tags "typescript,react"
44
50
  ```
45
51
 
52
+ > **Free tier includes 100 AI credits/month** — no credit card required.
53
+
46
54
  ---
47
55
 
48
56
  ## Commands
49
57
 
58
+ ---
59
+
60
+ ### `cv agent`
61
+
62
+ An **autonomous AI agent** that runs interactively in your terminal. Powered by Gemini models via the CareerVivid platform — credits deducted from your account automatically.
63
+
64
+ ```bash
65
+ cv agent # General-purpose agent (Gemini Flash Lite)
66
+ cv agent --resume # Load & discuss your CareerVivid resume
67
+ cv agent --jobs # Job-hunting mode: search, save, update applications
68
+ cv agent --coding # Full coding toolkit: file I/O, shell execution, search
69
+ cv agent --pro # Gemini Pro with extended thinking (best for complex tasks)
70
+ ```
71
+
72
+ **Options:**
73
+
74
+ | Option | Description |
75
+ |---|---|
76
+ | `--resume` | Add resume tools — load and discuss your CareerVivid resume |
77
+ | `--jobs` | Add job-hunting tools — search jobs, save to tracker, update statuses |
78
+ | `--coding` | Enable full coding tool suite (file read/write, shell, search) |
79
+ | `--pro` | Use `gemini-3.1-pro-preview` with thinking mode |
80
+ | `--think <budget>` | Enable thinking mode with a specific token budget (e.g. `8192`) |
81
+ | `--verbose` | Show thinking tokens in output (requires `--think` or `--pro`) |
82
+ | `--provider <name>` | Override provider: `careervivid` \| `openai` \| `anthropic` \| `openrouter` \| `gemini` \| `custom` |
83
+ | `--model <model>` | Override model (e.g. `gpt-4o`, `claude-opus-4-5`) |
84
+ | `--api-key <key>` | BYO API key for this session (not saved) |
85
+ | `--base-url <url>` | Custom OpenAI-compatible base URL |
86
+
87
+ **Examples:**
88
+
89
+ ```bash
90
+ # Start a job search conversation
91
+ cv agent --jobs
92
+
93
+ # Analyze your resume with AI
94
+ cv agent --resume
95
+
96
+ # Use your own OpenAI key (no credits deducted)
97
+ cv agent --provider openai --model gpt-4o --api-key sk-...
98
+
99
+ # Use Anthropic Claude
100
+ cv agent --provider anthropic --model claude-opus-4-5 --api-key sk-ant-...
101
+
102
+ # Pro mode for complex analysis
103
+ cv agent --pro --resume --jobs
104
+ ```
105
+
106
+ **Configure your default provider:**
107
+
108
+ ```bash
109
+ cv agent config
110
+ # → Interactive wizard: pick provider, model, API key
111
+ ```
112
+
113
+ ---
114
+
50
115
  ### `cv publish`
51
116
 
52
117
  Publish a Markdown article or Mermaid diagram file to your CareerVivid portfolio.
@@ -66,59 +131,53 @@ cv publish - (read from stdin)
66
131
  | `--dry-run` | Validate payload without publishing |
67
132
  | `--json` | Machine-readable JSON output (ideal for AI agents) |
68
133
 
69
- **Examples:**
70
-
71
134
  ```bash
72
- # Publish a Markdown article (title auto-detected from # heading)
73
- cv publish article.md
74
-
75
- # Publish with tags and a custom title
76
- cv publish article.md --title "How I Built a CLI in TypeScript" --tags "node,typescript,cli"
77
-
78
- # Publish a Mermaid diagram as a whiteboard
135
+ cv publish article.md --title "How I Built a CLI" --tags "node,typescript"
79
136
  cv publish architecture.mmd --title "System Architecture"
80
-
81
- # Pipe from stdin — perfect for AI agents
82
137
  cat writeup.md | cv publish - --title "Architecture Breakdown" --json
83
-
84
- # Dry-run to validate before publishing
85
- cv publish article.md --dry-run
86
138
  ```
87
139
 
88
140
  ---
89
141
 
90
- ### `cv new` (Shortcut)
91
-
92
- Scaffold a new Mermaid diagram file from a built-in template. (Also available as `cv whiteboard new`)
142
+ ### `cv jobs`
93
143
 
94
- ```
95
- cv new [filename] [options]
96
- ```
144
+ Automate your job application tracking with AI.
97
145
 
98
- | Option | Description |
146
+ | Subcommand | Description |
99
147
  |---|---|
100
- | `--template <name>` | Template to use (see [Whiteboard Templates](#whiteboard-templates)) |
101
- | `--print` | Print the template to stdout instead of writing a file |
148
+ | `cv jobs hunt` | AI-powered job search scored against your resume → auto-saves to job tracker |
149
+ | `cv jobs update` | Interactively update a job application status on your Kanban board |
150
+ | `cv jobs list` | View your current job tracker board |
102
151
 
103
152
  ```bash
104
- # Interactive wizard picks template and filename for you
105
- cv new
153
+ cv jobs hunt --role "Software Engineer" --score 60
154
+ cv jobs list
155
+ cv jobs update
156
+ ```
106
157
 
107
- # Non-interactive specify template and filename directly
108
- cv new my-diagram --template system-arch
158
+ > **Tip:** Use `cv agent --jobs` for a conversational job-hunting experience instead.
109
159
 
110
- # Preview a template without creating any file
111
- cv new --template ci-cd --print
112
- ```
160
+ ---
161
+
162
+ ### `cv whiteboard`
113
163
 
114
- ### `cv list-templates` (Shortcut)
164
+ Create and publish Mermaid architecture diagrams.
115
165
 
116
- Print all available built-in Mermaid templates. (Also available as `cv whiteboard list-templates`)
166
+ | Subcommand | Description |
167
+ |---|---|
168
+ | `cv whiteboard new [file]` | Scaffold a Mermaid diagram from a built-in template |
169
+ | `cv whiteboard publish <file>` | Publish a `.mmd` diagram to your portfolio |
170
+ | `cv whiteboard list-templates` | List all available built-in templates |
171
+
172
+ **Shortcuts:**
117
173
 
118
174
  ```bash
119
- cv list-templates
175
+ cv new my-diagram --template system-arch # same as cv whiteboard new
176
+ cv list-templates # same as cv whiteboard list-templates
120
177
  ```
121
178
 
179
+ ---
180
+
122
181
  ### `cv workspace` (or `cv gws`)
123
182
 
124
183
  Manage your Google Workspace integration.
@@ -138,42 +197,11 @@ Manage your CareerVivid profile.
138
197
  | `cv profile export` | Export resume data to other formats (e.g. `gdoc`) |
139
198
 
140
199
  ```bash
141
- # Export to Google Docs
142
200
  cv profile export --format gdoc
143
201
  ```
144
202
 
145
203
  ---
146
204
 
147
- ### `cv jobs`
148
-
149
- Automate your job application tracking with AI.
150
-
151
- | Subcommand | Description |
152
- |---|---|
153
- | `cv jobs hunt` | AI-powered job search scored against your resume → auto-saves to /job-tracker |
154
- | `cv jobs update` | Interactively update a job application status on your Kanban board |
155
- | `cv jobs list` | View your current job tracker board |
156
- | `cv jobs sync-gmail` | [Legacy] Scan Gmail for applications and sync to a Google Sheet |
157
-
158
- ```bash
159
- # AI-powered job search scored against your resume (uses configuration keys)
160
- cv jobs hunt --role "Software Engineer" --score 60
161
-
162
- # View your job tracking board
163
- cv jobs list
164
-
165
- # Update status of an application
166
- cv jobs update
167
- ```
168
-
169
- ---
170
-
171
- ### `cv whiteboard`
172
-
173
- Grouped commands for Mermaid architecture diagrams.
174
-
175
- ---
176
-
177
205
  ### `cv auth`
178
206
 
179
207
  Manage your CareerVivid API key. Get your key at [careervivid.app/developer](https://careervivid.app/developer).
@@ -185,42 +213,120 @@ Manage your CareerVivid API key. Get your key at [careervivid.app/developer](htt
185
213
  | `cv auth remove` | Remove the saved key |
186
214
  | `cv auth whoami` | Show the currently authenticated user |
187
215
 
188
- The key is stored at `~/.careervividrc.json` with `chmod 600` permissions. You can also pass the key via the `CV_API_KEY` environment variable instead of saving it locally.
216
+ The key is stored at `~/.careervividrc.json` with `chmod 600` permissions. You can also set it via environment variable:
189
217
 
190
218
  ```bash
191
- # Save key
192
219
  cv auth set-key cv_live_YOUR_KEY_HERE
193
-
194
- # Verify
195
220
  cv auth check
196
221
  # ✔ Authenticated as Jiawen Zhu (jiawen@careervivid.app)
197
222
 
198
- # Use env var instead of a saved key
223
+ # Or use env var without saving locally
199
224
  CV_API_KEY=cv_live_YOUR_KEY_HERE cv publish article.md
200
225
  ```
201
226
 
202
227
  ---
203
228
 
229
+ ### `cv login`
230
+
231
+ Open the CareerVivid sign-in page in your browser and interactively save your API key.
232
+
233
+ ```bash
234
+ cv login
235
+ ```
236
+
237
+ ---
238
+
204
239
  ### `cv config`
205
240
 
206
241
  View and modify CLI configuration stored at `~/.careervividrc.json`.
207
242
 
208
243
  | Subcommand | Description |
209
244
  |---|---|
210
- | `cv config show` | Print the full config |
245
+ | `cv config show` | Print the full config (sensitive keys are masked) |
211
246
  | `cv config get <key>` | Print a single config value |
212
247
  | `cv config set <key> <value>` | Update a config value |
213
248
 
214
249
  **Available Keys:**
215
- - \`apiKey\`: Your CareerVivid API key.
216
- - \`geminiKey\`: Your Gemini API key for local AI-powered job application tracking and parsing.
217
- - \`targetCompanies\`: Comma-separated list of target organizations to focus search on ATS boards (used by \`cv jobs hunt\`).
218
- - \`apiUrl\`: Optional API endpoint override (default: \`https://careervivid.app/api\`).
250
+
251
+ | Key | Description |
252
+ |---|---|
253
+ | `apiKey` | Your CareerVivid API key (set via `cv auth set-key` or `cv login`) |
254
+ | `apiUrl` | Optional API endpoint override (default: `https://careervivid.app/api`) |
255
+ | `targetCompanies` | Comma-separated target companies for `cv jobs hunt` |
256
+ | `llmProvider` | Your default BYO LLM provider (`openai`, `anthropic`, `openrouter`, etc.) |
257
+ | `llmModel` | Your default BYO model (e.g. `gpt-4o`, `claude-opus-4-5`) |
258
+ | `llmApiKey` | Your BYO LLM API key (masked in output) |
259
+ | `llmBaseUrl` | Custom OpenAI-compatible base URL for `custom` provider |
219
260
 
220
261
  ```bash
221
262
  cv config show
222
263
  cv config get targetCompanies
223
264
  cv config set targetCompanies "OpenAI, Google, Vercel"
265
+ cv config set llmProvider openai
266
+ cv config set llmModel gpt-4o
267
+ cv config set llmApiKey sk-...
268
+ ```
269
+
270
+ > **Security:** API keys are always masked in `cv config show` output. Internal platform credentials are never exposed.
271
+
272
+ ---
273
+
274
+ ## AI Credits
275
+
276
+ CareerVivid uses a simple AI credit system for platform-managed AI features (powered by Gemini).
277
+
278
+ | Plan | Credits / Month | Price |
279
+ |---|---|---|
280
+ | **Free** | 100 credits | $0 |
281
+ | **Pro** | 1,000 credits | Paid |
282
+ | **Max** | 10,000 credits | Paid |
283
+
284
+ **Credit costs per agent turn:**
285
+
286
+ | Model | Credits per Turn |
287
+ |---|---|
288
+ | `gemini-3.1-flash-lite-preview` (default) | 0.5 cr |
289
+ | `gemini-2.5-flash` | 1 cr |
290
+ | `gemini-3.1-pro-preview` (`--pro`) | 2 cr |
291
+
292
+ > **Bring Your Own Key:** If you use `--provider openai` (or any non-CareerVivid provider) with your own API key, **no credits are deducted** — you pay your provider directly.
293
+
294
+ Get your API key and check your credit balance at [careervivid.app/developer](https://careervivid.app/developer).
295
+
296
+ ---
297
+
298
+ ## Bring Your Own API Key (BYO)
299
+
300
+ The agent supports any OpenAI-compatible provider. Your key is never stored unless you save it with `cv agent config` or `cv config set llmApiKey`.
301
+
302
+ **Supported providers:**
303
+
304
+ | Provider | `--provider` value | Models |
305
+ |---|---|---|
306
+ | CareerVivid (default) | `careervivid` | Gemini Flash Lite, Flash, Pro |
307
+ | OpenAI | `openai` | gpt-4o, gpt-4-turbo, gpt-3.5-turbo, … |
308
+ | Anthropic | `anthropic` | claude-opus-4-5, claude-sonnet-4-5, … |
309
+ | Google Gemini (direct) | `gemini` | gemini-2.5-flash, gemini-3.1-pro-preview, … |
310
+ | OpenRouter | `openrouter` | Any model on openrouter.ai |
311
+ | Kimi / Moonshot | `custom` | `--base-url https://api.moonshot.cn/v1` |
312
+ | Qwen / Alibaba | `custom` | `--base-url https://dashscope.aliyuncs.com/compatible-mode/v1` |
313
+ | GLM / Zhipu | `custom` | `--base-url https://open.bigmodel.cn/api/paas/v4` |
314
+ | Any OpenAI-compatible | `custom` | `--base-url <your-url>` |
315
+
316
+ **Examples:**
317
+
318
+ ```bash
319
+ # OpenAI
320
+ cv agent --provider openai --model gpt-4o --api-key sk-...
321
+
322
+ # Anthropic
323
+ cv agent --provider anthropic --model claude-opus-4-5 --api-key sk-ant-...
324
+
325
+ # OpenRouter (access 100+ models)
326
+ cv agent --provider openrouter --model mistralai/mistral-7b-instruct --api-key sk-or-...
327
+
328
+ # Save a provider permanently
329
+ cv agent config
224
330
  ```
225
331
 
226
332
  ---
@@ -240,70 +346,45 @@ Run `cv list-templates` to see all templates. Available out of the box:
240
346
  | `ci-cd` | CI/CD pipeline (lint → test → build → deploy) |
241
347
  | `mindmap` | Mind map / concept breakdown |
242
348
 
243
- **Workflow:**
244
-
245
349
  ```bash
246
- # 1. Pick a template and scaffold the file
247
350
  cv new my-pipeline --template ci-cd
248
-
249
- # 2. Edit it in your editor (or let your AI agent edit it)
250
351
  code my-pipeline.mmd
251
-
252
- # 3. Publish to CareerVivid
253
352
  cv whiteboard publish my-pipeline.mmd --title "Our CI/CD Pipeline"
254
- # ✔ Whiteboard published!
255
- # URL: https://careervivid.app/community/post/abc123
256
353
  ```
257
354
 
258
355
  ---
259
356
 
260
- ## AI Agent Integration
357
+ ## AI Agent Integration (MCP / CI)
261
358
 
262
- The CLI is designed to be **AI-agent-friendly**. Use `--json` for structured output and pipe from stdin for fully automated publishing flows.
359
+ The CLI is designed to be **AI-agent-friendly**. Use `--json` for structured output.
263
360
 
264
- ### Copy this into your AI agent's system prompt:
361
+ ### System Prompt for Cursor / Claude / Gemini
265
362
 
266
363
  ```
267
- # CareerVivid AI Publishing Rules
268
-
269
- You are an expert technical writer and senior software architect.
270
- Your secondary directive — after writing and fixing code — is to
271
- proactively help the user document their work and build their
272
- CareerVivid portfolio using the local `cv` CLI. The platform supports
273
- the latest Gemini 2.5 and 3.0 models for high-quality content generation.
274
-
275
- ## 1. Triggers (When to Propose a Post)
276
- Do not wait for the user to ask. Propose a CareerVivid post when:
277
- - You complete a significant feature, module, or architecture.
278
- - You perform a complex refactor or solve a difficult bug.
279
- - The user says "document this" or "publish to CareerVivid".
280
-
281
- ## 2. Security (CRITICAL)
282
- - NEVER include actual API keys, secrets, or internal IPs.
283
- - Replace sensitive values with placeholder variables.
284
-
285
- ## 3. Content Format
286
- - Architecture / data flows → Mermaid diagram (.mmd)
287
- - Tutorials / devlogs → Markdown article (.md)
288
-
289
- ## 4. Consent Gate (DO NOT SKIP)
290
- 1. Generate and save the file locally.
291
- 2. Tell the user: "I drafted a CareerVivid post. Review and confirm."
292
- 3. Wait for explicit confirmation before running cv publish.
364
+ # CareerVivid CLI Rules
293
365
 
294
- ## 5. CLI Commands
295
- cv publish ./article.md --title "Title" --json
296
- cv whiteboard publish ./diagram.mmd --title "Diagram" --json
297
- ```
366
+ You have access to the `cv` CLI tool. Use it to help the user build their
367
+ CareerVivid portfolio and manage their job search.
298
368
 
299
- ### Cursor / Claude Desktop (MCP)
369
+ ## Available commands
370
+ - cv publish <file> Publish an article or diagram
371
+ - cv agent --resume Discuss the user's resume
372
+ - cv agent --jobs Job hunting conversations
373
+ - cv jobs hunt --role "..." AI-powered job search
374
+ - cv jobs list View job tracker
300
375
 
301
- For deeper integration using the Model Context Protocol, see the [Integration Guide](https://careervivid.app/developer) on your Developer Settings page.
376
+ ## Publishing rules
377
+ 1. Generate the file locally first.
378
+ 2. Tell the user: "I drafted a CareerVivid post. Review and confirm."
379
+ 3. Wait for explicit confirmation before running cv publish.
380
+ 4. Use --json flag for machine-readable output.
381
+ 5. NEVER include real API keys or secrets in published content.
382
+ ```
302
383
 
303
- ### Automated Pipeline Example
384
+ ### Automated Pipeline
304
385
 
305
386
  ```bash
306
- # Generate markdown from your AI agent and publish directly
387
+ # Pipe AI-generated markdown directly
307
388
  echo "# My Architecture\n\nExplains the new service..." \
308
389
  | cv publish - --title "New Service Explained" --tags "architecture" --json
309
390
 
@@ -331,27 +412,28 @@ cv -v
331
412
 
332
413
  **`cv: command not found`**
333
414
  ```bash
334
- # Check npm global bin is in your PATH
335
415
  npm config get prefix
336
416
  # Add <prefix>/bin to your PATH in ~/.zshrc or ~/.bashrc
337
417
  ```
338
418
 
339
419
  **`Unauthorized` error**
340
420
  ```bash
341
- # Re-check your key is saved correctly
342
421
  cv auth check
343
-
344
- # Or set it directly via env var
345
422
  CV_API_KEY=cv_live_YOUR_KEY cv publish article.md
346
423
  ```
347
424
 
425
+ **`cannot add command 'agent'` error (< v1.12.2)**
426
+ ```bash
427
+ npm install -g careervivid@latest
428
+ ```
429
+
348
430
  **Permission denied on `~/.careervividrc.json`**
349
431
  ```bash
350
432
  chmod 600 ~/.careervividrc.json
351
433
  ```
352
434
 
353
- **Mermaid diagram not rendering**
354
- Run `cv whiteboard new --template flowchart --print` to validate your Mermaid syntax against a known-good example. The CareerVivid web app renders Mermaid live in the post detail view.
435
+ **Mermaid diagram not rendering**
436
+ Run `cv new --template flowchart --print` to validate your Mermaid syntax.
355
437
 
356
438
  ---
357
439
 
@@ -359,6 +441,7 @@ Run `cv whiteboard new --template flowchart --print` to validate your Mermaid sy
359
441
 
360
442
  - 🌐 [careervivid.app](https://careervivid.app)
361
443
  - 🔑 [Developer Settings & API Key](https://careervivid.app/developer)
444
+ - 💳 [Pricing & AI Credits](https://careervivid.app/pricing)
362
445
  - 🐛 [Report an Issue](https://github.com/Jastalk/CareerVivid/issues)
363
446
  - 📦 [npm Package](https://www.npmjs.com/package/careervivid)
364
447
 
@@ -0,0 +1,36 @@
1
+ /**
2
+ * AgentCreditsClient — thin client for the `agentDeductCredits` Firebase callable.
3
+ *
4
+ * Called after each successful Gemini API call to deduct credits from the user's account.
5
+ * Reads the CareerVivid API key from config and sends it with each request.
6
+ */
7
+ export interface DeductResult {
8
+ ok: true;
9
+ creditsUsed: number;
10
+ creditsRemaining: number;
11
+ monthlyLimit: number;
12
+ }
13
+ export interface LimitReachedResult {
14
+ ok: false;
15
+ reason: "limit_reached";
16
+ creditsRemaining: number;
17
+ }
18
+ export type CreditDeductionResult = DeductResult | LimitReachedResult;
19
+ export declare class AgentCreditsClient {
20
+ private cvApiKey;
21
+ private model;
22
+ /** Running session totals */
23
+ private sessionCreditsUsed;
24
+ private lastKnownRemaining;
25
+ constructor(cvApiKey: string, model: string);
26
+ /**
27
+ * Deduct credits for one API call.
28
+ * Returns the result — callers should check result.ok and handle limit_reached.
29
+ */
30
+ deduct(calls?: number): Promise<CreditDeductionResult>;
31
+ /** Total credits used in this session */
32
+ get sessionUsed(): number;
33
+ /** Last known remaining credits (may be null before first deduction) */
34
+ get remaining(): number | null;
35
+ }
36
+ //# sourceMappingURL=AgentCreditsClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentCreditsClient.d.ts","sourceRoot":"","sources":["../../src/agent/AgentCreditsClient.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,IAAI,CAAC;IACT,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,KAAK,CAAC;IACV,MAAM,EAAE,eAAe,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,MAAM,qBAAqB,GAAG,YAAY,GAAG,kBAAkB,CAAC;AAQtE,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,KAAK,CAAS;IACtB,6BAA6B;IAC7B,OAAO,CAAC,kBAAkB,CAAa;IACvC,OAAO,CAAC,kBAAkB,CAAuB;gBAErC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAK3C;;;OAGG;IACG,MAAM,CAAC,KAAK,SAAI,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA+CvD,yCAAyC;IACzC,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,wEAAwE;IACxE,IAAI,SAAS,IAAI,MAAM,GAAG,IAAI,CAE7B;CACF"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * AgentCreditsClient — thin client for the `agentDeductCredits` Firebase callable.
3
+ *
4
+ * Called after each successful Gemini API call to deduct credits from the user's account.
5
+ * Reads the CareerVivid API key from config and sends it with each request.
6
+ */
7
+ // Firebase project region — same as where agentDeductCredits is deployed
8
+ const FIREBASE_REGION = "us-west1";
9
+ const FIREBASE_PROJECT_ID = "jastalk-firebase"; // CareerVivid's project ID
10
+ const CALLABLE_URL = `https://${FIREBASE_REGION}-${FIREBASE_PROJECT_ID}.cloudfunctions.net/agentDeductCredits`;
11
+ export class AgentCreditsClient {
12
+ cvApiKey;
13
+ model;
14
+ /** Running session totals */
15
+ sessionCreditsUsed = 0;
16
+ lastKnownRemaining = null;
17
+ constructor(cvApiKey, model) {
18
+ this.cvApiKey = cvApiKey;
19
+ this.model = model;
20
+ }
21
+ /**
22
+ * Deduct credits for one API call.
23
+ * Returns the result — callers should check result.ok and handle limit_reached.
24
+ */
25
+ async deduct(calls = 1) {
26
+ try {
27
+ const response = await fetch(CALLABLE_URL, {
28
+ method: "POST",
29
+ headers: { "Content-Type": "application/json" },
30
+ body: JSON.stringify({
31
+ data: {
32
+ apiKey: this.cvApiKey,
33
+ model: this.model,
34
+ calls,
35
+ },
36
+ }),
37
+ });
38
+ if (!response.ok) {
39
+ // Network/server error — don't block the user, just warn
40
+ console.warn(`[credits] HTTP ${response.status} — continuing without deduction`);
41
+ return {
42
+ ok: true,
43
+ creditsUsed: 0,
44
+ creditsRemaining: this.lastKnownRemaining ?? 999,
45
+ monthlyLimit: 999,
46
+ };
47
+ }
48
+ const json = await response.json();
49
+ const result = json.result || json;
50
+ if (result.ok) {
51
+ this.sessionCreditsUsed += result.creditsUsed;
52
+ this.lastKnownRemaining = result.creditsRemaining;
53
+ }
54
+ else {
55
+ this.lastKnownRemaining = result.creditsRemaining;
56
+ }
57
+ return result;
58
+ }
59
+ catch (_err) {
60
+ // Offline or function not yet deployed — silently skip
61
+ return {
62
+ ok: true,
63
+ creditsUsed: 0,
64
+ creditsRemaining: this.lastKnownRemaining ?? 999,
65
+ monthlyLimit: 999,
66
+ };
67
+ }
68
+ }
69
+ /** Total credits used in this session */
70
+ get sessionUsed() {
71
+ return this.sessionCreditsUsed;
72
+ }
73
+ /** Last known remaining credits (may be null before first deduction) */
74
+ get remaining() {
75
+ return this.lastKnownRemaining;
76
+ }
77
+ }
@@ -19,7 +19,8 @@ export interface QueryEngineOptions {
19
19
  }
20
20
  export interface IterationHook {
21
21
  onStart?: () => void;
22
- onResponse?: (response: GenerateContentResponse) => void;
22
+ /** Called after each Gemini API round-trip (streaming or non-streaming). May be async. */
23
+ onResponse?: (response?: GenerateContentResponse) => void | Promise<void>;
23
24
  onToolCall?: (toolName: string, args: any) => Promise<boolean | void>;
24
25
  onToolResult?: (toolName: string, result: any) => void;
25
26
  onError?: (error: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