careervivid 1.12.0 → 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 (40) hide show
  1. package/README.md +222 -124
  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 +34 -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 +3 -0
  18. package/dist/agent/tools/jobs.d.ts.map +1 -1
  19. package/dist/agent/tools/jobs.js +126 -4
  20. package/dist/api.d.ts +29 -0
  21. package/dist/api.d.ts.map +1 -1
  22. package/dist/api.js +10 -0
  23. package/dist/commands/agent.d.ts.map +1 -1
  24. package/dist/commands/agent.js +470 -147
  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 -24
  28. package/dist/commands/jobs.d.ts.map +1 -1
  29. package/dist/commands/jobs.js +7 -0
  30. package/dist/commands/resumes.d.ts +3 -0
  31. package/dist/commands/resumes.d.ts.map +1 -0
  32. package/dist/commands/resumes.js +142 -0
  33. package/dist/config.d.ts +26 -0
  34. package/dist/config.d.ts.map +1 -1
  35. package/dist/config.js +32 -0
  36. package/dist/index.js +2 -0
  37. package/dist/postinstall.d.ts +1 -1
  38. package/dist/postinstall.d.ts.map +1 -1
  39. package/dist/postinstall.js +29 -16
  40. 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
+ ---
113
161
 
114
- ### `cv list-templates` (Shortcut)
162
+ ### `cv whiteboard`
115
163
 
116
- Print all available built-in Mermaid templates. (Also available as `cv whiteboard list-templates`)
164
+ Create and publish Mermaid architecture diagrams.
165
+
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,33 +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.
150
-
151
- | Subcommand | Description |
152
- |---|---|
153
- | `cv jobs sync-gmail` | Scan Gmail for applications and sync to a Google Sheet |
154
-
155
- ```bash
156
- # Sync recent applications to Google Sheets
157
- cv jobs sync-gmail
158
- ```
159
-
160
- ---
161
-
162
- ### `cv whiteboard`
163
-
164
- Grouped commands for Mermaid architecture diagrams.
165
-
166
- ---
167
-
168
205
  ### `cv auth`
169
206
 
170
207
  Manage your CareerVivid API key. Get your key at [careervivid.app/developer](https://careervivid.app/developer).
@@ -176,36 +213,120 @@ Manage your CareerVivid API key. Get your key at [careervivid.app/developer](htt
176
213
  | `cv auth remove` | Remove the saved key |
177
214
  | `cv auth whoami` | Show the currently authenticated user |
178
215
 
179
- 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:
180
217
 
181
218
  ```bash
182
- # Save key
183
219
  cv auth set-key cv_live_YOUR_KEY_HERE
184
-
185
- # Verify
186
220
  cv auth check
187
221
  # ✔ Authenticated as Jiawen Zhu (jiawen@careervivid.app)
188
222
 
189
- # Use env var instead of a saved key
223
+ # Or use env var without saving locally
190
224
  CV_API_KEY=cv_live_YOUR_KEY_HERE cv publish article.md
191
225
  ```
192
226
 
193
227
  ---
194
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
+
195
239
  ### `cv config`
196
240
 
197
241
  View and modify CLI configuration stored at `~/.careervividrc.json`.
198
242
 
199
243
  | Subcommand | Description |
200
244
  |---|---|
201
- | `cv config show` | Print the full config |
245
+ | `cv config show` | Print the full config (sensitive keys are masked) |
202
246
  | `cv config get <key>` | Print a single config value |
203
247
  | `cv config set <key> <value>` | Update a config value |
204
248
 
249
+ **Available Keys:**
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 |
260
+
205
261
  ```bash
206
262
  cv config show
207
- cv config get apiKey
208
- cv config set apiUrl https://careervivid.app/api/publish
263
+ cv config get targetCompanies
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
209
330
  ```
210
331
 
211
332
  ---
@@ -225,70 +346,45 @@ Run `cv list-templates` to see all templates. Available out of the box:
225
346
  | `ci-cd` | CI/CD pipeline (lint → test → build → deploy) |
226
347
  | `mindmap` | Mind map / concept breakdown |
227
348
 
228
- **Workflow:**
229
-
230
349
  ```bash
231
- # 1. Pick a template and scaffold the file
232
350
  cv new my-pipeline --template ci-cd
233
-
234
- # 2. Edit it in your editor (or let your AI agent edit it)
235
351
  code my-pipeline.mmd
236
-
237
- # 3. Publish to CareerVivid
238
352
  cv whiteboard publish my-pipeline.mmd --title "Our CI/CD Pipeline"
239
- # ✔ Whiteboard published!
240
- # URL: https://careervivid.app/community/post/abc123
241
353
  ```
242
354
 
243
355
  ---
244
356
 
245
- ## AI Agent Integration
357
+ ## AI Agent Integration (MCP / CI)
246
358
 
247
- 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.
248
360
 
249
- ### Copy this into your AI agent's system prompt:
361
+ ### System Prompt for Cursor / Claude / Gemini
250
362
 
251
363
  ```
252
- # CareerVivid AI Publishing Rules
253
-
254
- You are an expert technical writer and senior software architect.
255
- Your secondary directive — after writing and fixing code — is to
256
- proactively help the user document their work and build their
257
- CareerVivid portfolio using the local `cv` CLI. The platform supports
258
- the latest Gemini 2.5 and 3.0 models for high-quality content generation.
259
-
260
- ## 1. Triggers (When to Propose a Post)
261
- Do not wait for the user to ask. Propose a CareerVivid post when:
262
- - You complete a significant feature, module, or architecture.
263
- - You perform a complex refactor or solve a difficult bug.
264
- - The user says "document this" or "publish to CareerVivid".
265
-
266
- ## 2. Security (CRITICAL)
267
- - NEVER include actual API keys, secrets, or internal IPs.
268
- - Replace sensitive values with placeholder variables.
269
-
270
- ## 3. Content Format
271
- - Architecture / data flows → Mermaid diagram (.mmd)
272
- - Tutorials / devlogs → Markdown article (.md)
273
-
274
- ## 4. Consent Gate (DO NOT SKIP)
275
- 1. Generate and save the file locally.
276
- 2. Tell the user: "I drafted a CareerVivid post. Review and confirm."
277
- 3. Wait for explicit confirmation before running cv publish.
364
+ # CareerVivid CLI Rules
278
365
 
279
- ## 5. CLI Commands
280
- cv publish ./article.md --title "Title" --json
281
- cv whiteboard publish ./diagram.mmd --title "Diagram" --json
282
- ```
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.
283
368
 
284
- ### 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
285
375
 
286
- 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
+ ```
287
383
 
288
- ### Automated Pipeline Example
384
+ ### Automated Pipeline
289
385
 
290
386
  ```bash
291
- # Generate markdown from your AI agent and publish directly
387
+ # Pipe AI-generated markdown directly
292
388
  echo "# My Architecture\n\nExplains the new service..." \
293
389
  | cv publish - --title "New Service Explained" --tags "architecture" --json
294
390
 
@@ -316,27 +412,28 @@ cv -v
316
412
 
317
413
  **`cv: command not found`**
318
414
  ```bash
319
- # Check npm global bin is in your PATH
320
415
  npm config get prefix
321
416
  # Add <prefix>/bin to your PATH in ~/.zshrc or ~/.bashrc
322
417
  ```
323
418
 
324
419
  **`Unauthorized` error**
325
420
  ```bash
326
- # Re-check your key is saved correctly
327
421
  cv auth check
328
-
329
- # Or set it directly via env var
330
422
  CV_API_KEY=cv_live_YOUR_KEY cv publish article.md
331
423
  ```
332
424
 
425
+ **`cannot add command 'agent'` error (< v1.12.2)**
426
+ ```bash
427
+ npm install -g careervivid@latest
428
+ ```
429
+
333
430
  **Permission denied on `~/.careervividrc.json`**
334
431
  ```bash
335
432
  chmod 600 ~/.careervividrc.json
336
433
  ```
337
434
 
338
- **Mermaid diagram not rendering**
339
- 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.
340
437
 
341
438
  ---
342
439
 
@@ -344,6 +441,7 @@ Run `cv whiteboard new --template flowchart --print` to validate your Mermaid sy
344
441
 
345
442
  - 🌐 [careervivid.app](https://careervivid.app)
346
443
  - 🔑 [Developer Settings & API Key](https://careervivid.app/developer)
444
+ - 💳 [Pricing & AI Credits](https://careervivid.app/pricing)
347
445
  - 🐛 [Report an Issue](https://github.com/Jastalk/CareerVivid/issues)
348
446
  - 📦 [npm Package](https://www.npmjs.com/package/careervivid)
349
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: Error) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"QueryEngine.d.ts","sourceRoot":"","sources":["../../src/agent/QueryEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,uBAAuB,EAAE,OAAO,EAAQ,MAAM,eAAe,CAAC;AACpF,OAAO,EAAE,IAAI,EAAsB,MAAM,WAAW,CAAC;AAMrD,eAAO,MAAM,0BAA0B,QA8B/B,CAAC;AAMT,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE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