Skip to content

Commit e411509

Browse files
feat(cli): sync unified chat billing source
1 parent 255f700 commit e411509

4 files changed

Lines changed: 31 additions & 11 deletions

File tree

packages/sim-cli/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,11 @@ sim documents upload <path> --kb <knowledgeBaseId> [--tag <value>...]
165165
sim documents delete <documentId> --kb <knowledgeBaseId> --yes
166166

167167
sim billing
168-
sim billing logs [--period 7d] [--limit <n>]
168+
sim billing logs [--period 7d] [--source sim-chat] [--limit <n>]
169169
```
170170

171+
The `sim-chat` billing source combines Copilot and workspace chat usage.
172+
171173
Workflow output selectors use `blockName.field` syntax, such as
172174
`--select-output agent_1.content`; fields that are not produced are omitted.
173175

packages/sim-cli/src/contract/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const CLI_CONTRACT: CliContract = {
7171
command: 'billing logs',
7272
describe: 'List credit usage events',
7373
flags: {
74-
source: { describe: 'Filter by usage source' },
74+
source: { describe: 'Filter by usage source; sim-chat combines Copilot and workspace chat' },
7575
period: { describe: 'Billing period' },
7676
startDate: { describe: 'Custom period start (ISO 8601)' },
7777
endDate: { describe: 'Custom period end (ISO 8601)' },

packages/sim-cli/src/generated/v2-api.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3173,8 +3173,7 @@ export type ListUsageLogsQuery = {
31733173
source?:
31743174
| 'workflow'
31753175
| 'wand'
3176-
| 'copilot'
3177-
| 'workspace-chat'
3176+
| 'sim-chat'
31783177
| 'mcp_copilot'
31793178
| 'mothership_block'
31803179
| 'knowledge-base'
@@ -3196,8 +3195,7 @@ export type ListUsageLogsResponse = {
31963195
source:
31973196
| 'workflow'
31983197
| 'wand'
3199-
| 'copilot'
3200-
| 'workspace-chat'
3198+
| 'sim-chat'
32013199
| 'mcp_copilot'
32023200
| 'mothership_block'
32033201
| 'knowledge-base'
@@ -5486,8 +5484,7 @@ export const V2_OPERATIONS = {
54865484
values: [
54875485
'workflow',
54885486
'wand',
5489-
'copilot',
5490-
'workspace-chat',
5487+
'sim-chat',
54915488
'mcp_copilot',
54925489
'mothership_block',
54935490
'knowledge-base',

packages/sim-cli/src/runtime/build.test.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,10 @@ describe('commands parsed through commander', () => {
165165

166166
const help = commandAt('billing', 'logs').helpInformation()
167167
expect(help).toContain('--source <value>')
168-
expect(help).toContain('Filter by usage source (choices:')
168+
expect(help).toMatch(/sim-chat combines Copilot and\s+workspace chat/)
169+
expect(help).toContain('"sim-chat"')
170+
expect(help).not.toContain('"workspace-chat"')
171+
expect(help).not.toContain('"copilot"')
169172
expect(help).not.toContain('One of: workflow')
170173

171174
const [summaryPath, summaryOptions] = await run(['billing'], {
@@ -174,9 +177,27 @@ describe('commands parsed through commander', () => {
174177
expect(summaryPath).toBe('/api/v2/billing/usage')
175178
expect(summaryOptions.query).toEqual({ workspaceId: 'ws_local' })
176179

177-
const [logsPath, logsOptions] = await run(['billing', 'logs', '--period', '7d'])
180+
const [logsPath, logsOptions] = await run([
181+
'billing',
182+
'logs',
183+
'--period',
184+
'7d',
185+
'--source',
186+
'sim-chat',
187+
])
178188
expect(logsPath).toBe('/api/v2/billing/usage/logs')
179-
expect(logsOptions.query).toMatchObject({ workspaceId: 'ws_local', period: '7d' })
189+
expect(logsOptions.query).toMatchObject({
190+
workspaceId: 'ws_local',
191+
period: '7d',
192+
source: 'sim-chat',
193+
})
194+
195+
for (const deprecated of ['copilot', 'workspace-chat']) {
196+
await expect(run(['billing', 'logs', '--source', deprecated])).rejects.toThrow(
197+
/allowed choices.*sim-chat/i
198+
)
199+
expect(mockRequest).not.toHaveBeenCalled()
200+
}
180201
})
181202

182203
it('carries every multi-word flag on a command, not just the first', async () => {

0 commit comments

Comments
 (0)