pull/715/head
Travis Fischer 2025-05-23 00:23:39 +07:00
rodzic 8a5a9b421e
commit 092ce0fc8e
4 zmienionych plików z 33 dodań i 3 usunięć

Wyświetl plik

@ -52,6 +52,12 @@ export class AgenticApiClient {
return this.getAuthSession()
}
async clearAuthSession(): Promise<void> {
this.ky = this.ky.extend({
headers: {}
})
}
async getUser({
userId,
...searchParams

Wyświetl plik

@ -0,0 +1,22 @@
import { Command } from 'commander'
import type { Context } from '../types'
import { AuthStore } from '../store'
export function registerSignoutCommand({ client, program, logger }: Context) {
const command = new Command('logout')
.alias('signout')
.description('Signs the current user out')
.action(async () => {
if (!AuthStore.isAuthenticated()) {
return
}
await client.clearAuthSession()
AuthStore.clearAuth()
logger.log('Signed out')
})
program.addCommand(command)
}

Wyświetl plik

@ -3,17 +3,17 @@ import { Command } from 'commander'
import type { Context } from '../types'
import { AuthStore } from '../store'
export function registerWhoAmICommand({ client, program }: Context) {
export function registerWhoAmICommand({ client, program, logger }: Context) {
const command = new Command('whoami')
.description('Displays info about the current user')
.action(async () => {
if (!AuthStore.isAuthenticated()) {
console.log('Not signed in')
logger.log('Not signed in')
return
}
const res = await client.getAuthSession()
console.log(res)
logger.log(res)
})
program.addCommand(command)

Wyświetl plik

@ -5,6 +5,7 @@ import { Command } from 'commander'
import restoreCursor from 'restore-cursor'
import { registerSigninCommand } from './commands/signin'
import { registerSignoutCommand } from './commands/signout'
import { registerWhoAmICommand } from './commands/whoami'
import { AuthStore } from './store'
@ -41,6 +42,7 @@ async function main() {
// Register all commands
registerSigninCommand(ctx)
registerWhoAmICommand(ctx)
registerSignoutCommand(ctx)
program.parse()
}