@robhowley/pi-openrouter 0.13.0 → 0.14.1

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.
@@ -269,7 +269,7 @@ describe('openrouter hooks', () => {
269
269
  expect(mocks.includeBuiltinRouterModels).toHaveBeenCalledWith([{ id: 'model-a' }], 'full');
270
270
  expect(pi.registerProvider).toHaveBeenCalledWith('openrouter', {
271
271
  baseUrl: 'https://openrouter.ai/api/v1',
272
- apiKey: 'OPENROUTER_API_KEY',
272
+ apiKey: '$OPENROUTER_API_KEY',
273
273
  api: 'openai-completions',
274
274
  models: [{ id: 'model-a' }, { id: 'router' }],
275
275
  authHeader: true,
@@ -121,11 +121,12 @@ describe('writeLocalUsage', () => {
121
121
  });
122
122
 
123
123
  it('appends multiple events to same daily file', async () => {
124
+ const usageDate = addUtcDays(getCurrentUtcDate(), -1);
124
125
  const event1: LocalUsageEvent = {
125
126
  id: 'test-1',
126
127
  generationId: 'gen-1',
127
128
  sessionId: 'session-1',
128
- completedAt: '2026-05-22T10:00:00.000Z',
129
+ completedAt: `${usageDate}T10:00:00.000Z`,
129
130
  cost: 0.001,
130
131
  };
131
132
 
@@ -133,14 +134,14 @@ describe('writeLocalUsage', () => {
133
134
  id: 'test-2',
134
135
  generationId: 'gen-2',
135
136
  sessionId: 'session-2',
136
- completedAt: '2026-05-22T15:00:00.000Z',
137
+ completedAt: `${usageDate}T15:00:00.000Z`,
137
138
  cost: 0.002,
138
139
  };
139
140
 
140
141
  await writeLocalUsage(event1);
141
142
  await writeLocalUsage(event2);
142
143
 
143
- const filePath = path.join(testDir, '2026-05-22.jsonl');
144
+ const filePath = path.join(testDir, `${usageDate}.jsonl`);
144
145
  const content = await fs.readFile(filePath, 'utf8');
145
146
  const lines = content.trim().split('\n');
146
147
 
@@ -150,11 +151,13 @@ describe('writeLocalUsage', () => {
150
151
  });
151
152
 
152
153
  it('writes to different files for different UTC dates', async () => {
154
+ const firstDate = addUtcDays(getCurrentUtcDate(), -2);
155
+ const secondDate = addUtcDays(firstDate, 1);
153
156
  const event1: LocalUsageEvent = {
154
157
  id: 'test-1',
155
158
  generationId: 'gen-1',
156
159
  sessionId: 'session-1',
157
- completedAt: '2026-05-22T23:59:59.999Z',
160
+ completedAt: `${firstDate}T23:59:59.999Z`,
158
161
  cost: 0.001,
159
162
  };
160
163
 
@@ -162,15 +165,15 @@ describe('writeLocalUsage', () => {
162
165
  id: 'test-2',
163
166
  generationId: 'gen-2',
164
167
  sessionId: 'session-2',
165
- completedAt: '2026-05-23T00:00:00.000Z',
168
+ completedAt: `${secondDate}T00:00:00.000Z`,
166
169
  cost: 0.002,
167
170
  };
168
171
 
169
172
  await writeLocalUsage(event1);
170
173
  await writeLocalUsage(event2);
171
174
 
172
- const file1 = await fs.readFile(path.join(testDir, '2026-05-22.jsonl'), 'utf8');
173
- const file2 = await fs.readFile(path.join(testDir, '2026-05-23.jsonl'), 'utf8');
175
+ const file1 = await fs.readFile(path.join(testDir, `${firstDate}.jsonl`), 'utf8');
176
+ const file2 = await fs.readFile(path.join(testDir, `${secondDate}.jsonl`), 'utf8');
174
177
 
175
178
  expect(JSON.parse(file1.trim())).toEqual(event1);
176
179
  expect(JSON.parse(file2.trim())).toEqual(event2);
@@ -108,7 +108,7 @@ export async function loadStartupCacheState(
108
108
 
109
109
  pi.registerProvider('openrouter', {
110
110
  baseUrl: 'https://openrouter.ai/api/v1',
111
- apiKey: 'OPENROUTER_API_KEY',
111
+ apiKey: '$OPENROUTER_API_KEY',
112
112
  api: 'openai-completions',
113
113
  models: configsWithRouters,
114
114
  authHeader: true,
@@ -92,7 +92,7 @@ export async function registerModelsWithProvider(
92
92
  ): Promise<void> {
93
93
  ctx.modelRegistry.registerProvider('openrouter', {
94
94
  baseUrl: 'https://openrouter.ai/api/v1',
95
- apiKey: 'OPENROUTER_API_KEY',
95
+ apiKey: '$OPENROUTER_API_KEY',
96
96
  api: 'openai-completions',
97
97
  models: configs,
98
98
  authHeader: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robhowley/pi-openrouter",
3
- "version": "0.13.0",
3
+ "version": "0.14.1",
4
4
  "type": "module",
5
5
  "description": "Live OpenRouter spend/account TUI overlays, user-scoped or free-only model sync, api key management, and session tagging for Pi.",
6
6
  "license": "MIT",