Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/lib/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,26 @@ test('uses the workspace SDK and its raw client', async () => {
name: 'Test',
is_sandbox: true,
}
const onboarding = {
org_type: 'startup',
primary_goal: null,
use_case: null,
build_target: null,
embed_customer_portal: null,
device_categories: ['locks'],
}
get.mockResolvedValue(workspace)
post.mockResolvedValue({
data: {
wizard_session: { token: 'token', expires_at: 'tomorrow' },
onboarding: null,
wizard_session: { token: 'token', expires_at: 'tomorrow', onboarding },
},
})

await expect(getWorkspaceForApiKey('seam_key')).resolves.toBe(workspace)
await expect(exchangeWizardInferenceToken('seam_key')).resolves.toEqual({
token: 'token',
expires_at: 'tomorrow',
onboarding: null,
onboarding,
})
expect(post).toHaveBeenCalledWith('/internal/wizard_inference/session', {})
expect(post).toHaveBeenCalledWith('/seam/wizard/v1/session', {})
})
17 changes: 10 additions & 7 deletions src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ export function looksLikeSeamApiKey(value: string): boolean {
}

// Base URL for Seam-hosted inference. The embedded agent's SDK appends
// /v1/messages; the exchange endpoint below lives at /session.
// /v1/messages; the exchange endpoint below lives at /v1/session.
export function getInferenceBaseUrl(): string {
return `${getApiBaseUrl()}/internal/wizard_inference`
return `${getApiBaseUrl()}/seam/wizard`
}

// The Console-collected onboarding answers Seam returns alongside the token, so
// The Console-collected onboarding answers Seam returns within the session, so
// the wizard can pre-fill its plan instead of re-asking (null if none recorded).
export interface WizardOnboarding {
org_type: string | null
Expand All @@ -82,9 +82,12 @@ export async function exchangeWizardInferenceToken(
): Promise<WizardInferenceSession> {
try {
const { data: body } = await getApi(apiKey).client.post<{
wizard_session?: { token: string; expires_at: string }
onboarding?: WizardOnboarding | null
}>('/internal/wizard_inference/session', {})
wizard_session?: {
token: string
expires_at: string
onboarding?: WizardOnboarding | null
}
}>('/seam/wizard/v1/session', {})
if (body.wizard_session == null) {
throw new ApiKeyError(
'Unexpected response from Seam starting the AI session.',
Expand All @@ -93,7 +96,7 @@ export async function exchangeWizardInferenceToken(
return {
token: body.wizard_session.token,
expires_at: body.wizard_session.expires_at,
onboarding: body.onboarding ?? null,
onboarding: body.wizard_session.onboarding ?? null,
}
} catch (error) {
if (error instanceof ApiKeyError) throw error
Expand Down
Loading