@sixb/client 0.1.11 → 0.1.13
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.
- package/dist/agent-streams.d.ts +7 -2
- package/dist/agent-streams.d.ts.map +1 -1
- package/dist/api.d.ts +8 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/base-url.d.ts +2 -0
- package/dist/base-url.d.ts.map +1 -0
- package/dist/browser.js +7 -7
- package/dist/browser.js.map +3 -3
- package/dist/{chunk-y4g6jrvs.js → chunk-1d0xnr6p.js} +38 -7
- package/dist/chunk-1d0xnr6p.js.map +10 -0
- package/dist/{chunk-f4qeqxz2.js → chunk-50rkzhcy.js} +23 -30
- package/dist/chunk-50rkzhcy.js.map +10 -0
- package/dist/{chunk-65mmaq7r.js → chunk-6k1hzwk1.js} +13 -11
- package/dist/chunk-6k1hzwk1.js.map +17 -0
- package/dist/{chunk-7bv57jcq.js → chunk-hdgztpzs.js} +372 -70
- package/dist/chunk-hdgztpzs.js.map +19 -0
- package/dist/{chunk-tyym13kq.js → chunk-jh4ts8mt.js} +3 -1
- package/dist/chunk-jh4ts8mt.js.map +10 -0
- package/dist/{chunk-qaacaq2e.js → chunk-nkx0fxxn.js} +6 -4
- package/dist/chunk-nkx0fxxn.js.map +10 -0
- package/dist/{chunk-65bdf9vw.js → chunk-tgyh8wz9.js} +7 -6
- package/dist/chunk-tgyh8wz9.js.map +12 -0
- package/dist/chunk-ys86w6hc.js +277 -0
- package/dist/chunk-ys86w6hc.js.map +12 -0
- package/dist/client-authority.d.ts +4 -0
- package/dist/client-authority.d.ts.map +1 -1
- package/dist/connectors/queries.d.ts.map +1 -1
- package/dist/events-builder.d.ts +2 -2
- package/dist/events-builder.d.ts.map +1 -1
- package/dist/events-transport.d.ts +4 -1
- package/dist/events-transport.d.ts.map +1 -1
- package/dist/generated/@tanstack/react-query.gen.d.ts +1555 -366
- package/dist/generated/@tanstack/react-query.gen.d.ts.map +1 -1
- package/dist/generated/index.d.ts +2 -2
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/sdk.gen.d.ts +9 -1
- package/dist/generated/sdk.gen.d.ts.map +1 -1
- package/dist/generated/types.gen.d.ts +594 -91
- package/dist/generated/types.gen.d.ts.map +1 -1
- package/dist/hooks.js +44 -12
- package/dist/hooks.js.map +6 -6
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -10
- package/dist/index.js.map +1 -1
- package/dist/logs-builder.d.ts +1 -1
- package/dist/logs-builder.d.ts.map +1 -1
- package/dist/logs-transport.d.ts +4 -1
- package/dist/logs-transport.d.ts.map +1 -1
- package/dist/logs.js +4 -4
- package/dist/models.d.ts +2 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +7 -3
- package/dist/models.js.map +1 -1
- package/dist/query-hooks.d.ts +3 -21
- package/dist/query-hooks.d.ts.map +1 -1
- package/dist/query.d.ts +2 -4
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +4 -4
- package/dist/session.d.ts +56 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/useAgentActivityStream.d.ts +3 -0
- package/dist/useAgentActivityStream.d.ts.map +1 -1
- package/dist/useAgentRunStream.d.ts +4 -1
- package/dist/useAgentRunStream.d.ts.map +1 -1
- package/dist/ws-socket.d.ts +3 -0
- package/dist/ws-socket.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/agent-streams.ts +11 -4
- package/src/api.ts +37 -32
- package/src/base-url.ts +30 -0
- package/src/browser.ts +1 -1
- package/src/client-authority.ts +19 -0
- package/src/events-builder.ts +5 -9
- package/src/events-transport.ts +6 -2
- package/src/generated/@tanstack/react-query.gen.ts +62 -0
- package/src/generated/index.ts +13 -0
- package/src/generated/sdk.gen.ts +398 -68
- package/src/generated/types.gen.ts +735 -87
- package/src/index.ts +13 -1
- package/src/logs-builder.ts +2 -2
- package/src/logs-transport.ts +6 -2
- package/src/models.ts +4 -2
- package/src/query-hooks.ts +2 -17
- package/src/query.ts +9 -12
- package/src/session.ts +316 -0
- package/src/useAgentActivityStream.ts +6 -2
- package/src/useAgentRunStream.ts +7 -3
- package/src/ws-socket.ts +62 -5
- package/dist/chunk-65bdf9vw.js.map +0 -12
- package/dist/chunk-65mmaq7r.js.map +0 -17
- package/dist/chunk-65zz479s.js +0 -23
- package/dist/chunk-65zz479s.js.map +0 -10
- package/dist/chunk-7bv57jcq.js.map +0 -19
- package/dist/chunk-f4qeqxz2.js.map +0 -10
- package/dist/chunk-qaacaq2e.js.map +0 -10
- package/dist/chunk-tyym13kq.js.map +0 -10
- package/dist/chunk-y4g6jrvs.js.map +0 -10
package/src/agent-streams.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { AgentRunActivityEvent, AgentRunStreamEvent } from "@sixb/core/agen
|
|
|
3
3
|
// node-only runtime (e.g. `node:crypto`), which breaks the Atlas browser bundle.
|
|
4
4
|
import { isAgentRunActivityEvent, isAgentRunStreamEvent } from "@sixb/core/agents/streams"
|
|
5
5
|
import type { BrokerRecord } from "@sixb/core/broker"
|
|
6
|
+
import type { Client } from "./generated/client"
|
|
6
7
|
import type { GetAgentRunResponses } from "./generated/types.gen"
|
|
7
8
|
import {
|
|
8
9
|
createReconnectingSocket,
|
|
@@ -78,8 +79,10 @@ export interface AgentRunSocketOptions {
|
|
|
78
79
|
readonly afterCursor?: string
|
|
79
80
|
readonly reconnect?: boolean
|
|
80
81
|
readonly reconnectDelayMs?: number
|
|
81
|
-
/** Override the API base url. Defaults to the global client config. */
|
|
82
|
+
/** Override the API base url. Defaults to `client`'s, then the global client config. */
|
|
82
83
|
readonly baseUrl?: string
|
|
84
|
+
/** The client whose API and credential the socket uses. Defaults to the package's shared client. */
|
|
85
|
+
readonly client?: Client
|
|
83
86
|
readonly onEvent: (event: AgentRunStreamEvent, cursor: string) => void
|
|
84
87
|
readonly onRunSnapshot?: (run: AgentRunSnapshot) => void
|
|
85
88
|
readonly onError?: (message: string) => void
|
|
@@ -89,8 +92,10 @@ export interface AgentRunSocketOptions {
|
|
|
89
92
|
export interface AgentActivitySocketOptions {
|
|
90
93
|
readonly reconnect?: boolean
|
|
91
94
|
readonly reconnectDelayMs?: number
|
|
92
|
-
/** Override the API base url. Defaults to the global client config. */
|
|
95
|
+
/** Override the API base url. Defaults to `client`'s, then the global client config. */
|
|
93
96
|
readonly baseUrl?: string
|
|
97
|
+
/** The client whose API and credential the socket uses. Defaults to the package's shared client. */
|
|
98
|
+
readonly client?: Client
|
|
94
99
|
readonly onActivity: (event: AgentRunActivityEvent) => void
|
|
95
100
|
/** Called after each initial or reconnect subscription, so durable state can be reconciled. */
|
|
96
101
|
readonly onSubscribed?: () => void
|
|
@@ -107,7 +112,8 @@ export function createAgentRunSocket(options: AgentRunSocketOptions): Reconnecti
|
|
|
107
112
|
let latestCursor = options.afterCursor
|
|
108
113
|
|
|
109
114
|
return createReconnectingSocket({
|
|
110
|
-
url: createSixbAgentsWebSocketUrl(options.baseUrl),
|
|
115
|
+
url: createSixbAgentsWebSocketUrl(options.baseUrl ?? options.client?.getConfig().baseUrl),
|
|
116
|
+
client: options.client,
|
|
111
117
|
reconnect: options.reconnect,
|
|
112
118
|
reconnectDelayMs: options.reconnectDelayMs,
|
|
113
119
|
connectionErrorMessage: "Agent stream websocket connection failed.",
|
|
@@ -144,7 +150,8 @@ export function createAgentRunSocket(options: AgentRunSocketOptions): Reconnecti
|
|
|
144
150
|
/** Open one project-level lifecycle feed, independent of how many Agent threads are running. */
|
|
145
151
|
export function createAgentActivitySocket(options: AgentActivitySocketOptions): ReconnectingSocket {
|
|
146
152
|
return createReconnectingSocket({
|
|
147
|
-
url: createSixbAgentsWebSocketUrl(options.baseUrl),
|
|
153
|
+
url: createSixbAgentsWebSocketUrl(options.baseUrl ?? options.client?.getConfig().baseUrl),
|
|
154
|
+
client: options.client,
|
|
148
155
|
reconnect: options.reconnect,
|
|
149
156
|
reconnectDelayMs: options.reconnectDelayMs,
|
|
150
157
|
connectionErrorMessage: "Agent activity websocket connection failed.",
|
package/src/api.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import type { SixbErrorCode } from "@sixb/core"
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeSixbApiBaseUrl } from "./base-url"
|
|
3
|
+
import {
|
|
4
|
+
assertSharedAccessGrantId,
|
|
5
|
+
markClientSessionAuthority,
|
|
6
|
+
markClientSharedAuthority,
|
|
7
|
+
} from "./client-authority"
|
|
3
8
|
import { type Auth, type Client, type Config, createClient, createConfig } from "./generated/client"
|
|
4
9
|
import { client as sharedClient } from "./generated/client.gen"
|
|
10
|
+
import { createSixbSessionFetch, type SixbSessionOptions, type SixbSessionStore } from "./session"
|
|
11
|
+
|
|
12
|
+
export { normalizeSixbApiBaseUrl } from "./base-url"
|
|
5
13
|
|
|
6
14
|
export const SIXB_CSRF_HEADER_NAME = "x-sixb-csrf"
|
|
7
15
|
export const SIXB_CSRF_TOKEN_RESPONSE_HEADER_NAME = "x-sixb-csrf-token"
|
|
@@ -23,6 +31,13 @@ export type SixbClientAuth =
|
|
|
23
31
|
readonly grantId: string
|
|
24
32
|
readonly csrfToken?: () => string | null | undefined
|
|
25
33
|
}
|
|
34
|
+
| {
|
|
35
|
+
/** A native client's session: its access token is sent, and refreshed, on every request. */
|
|
36
|
+
readonly kind: "session"
|
|
37
|
+
readonly store: SixbSessionStore
|
|
38
|
+
/** Called once when the session ends; the store has been cleared. Sign the user in again. */
|
|
39
|
+
readonly onSessionEnded?: () => void
|
|
40
|
+
}
|
|
26
41
|
| {
|
|
27
42
|
readonly kind: "none"
|
|
28
43
|
}
|
|
@@ -94,6 +109,7 @@ export function isSixbApiError(value: unknown): value is SixbApiError {
|
|
|
94
109
|
export function createSixbClient(options: SixbClientOptions = {}): SixbClient {
|
|
95
110
|
const client = createClient(createSixbClientConfig(options))
|
|
96
111
|
markClientSharedAuthority(client, options.auth?.kind === "shared")
|
|
112
|
+
markClientSessionAuthority(client, sixbSessionOptions(options))
|
|
97
113
|
installSixbErrorInterceptor(client)
|
|
98
114
|
return client
|
|
99
115
|
}
|
|
@@ -104,6 +120,7 @@ export function configureSixbClient(
|
|
|
104
120
|
): SixbClient {
|
|
105
121
|
client.setConfig(createSixbClientConfig(options))
|
|
106
122
|
markClientSharedAuthority(client, options.auth?.kind === "shared")
|
|
123
|
+
markClientSessionAuthority(client, sixbSessionOptions(options))
|
|
107
124
|
installSixbErrorInterceptor(client)
|
|
108
125
|
return client
|
|
109
126
|
}
|
|
@@ -119,6 +136,9 @@ export function createSixbClientConfig(options: SixbClientOptions = {}): Config
|
|
|
119
136
|
|
|
120
137
|
const baseUrl =
|
|
121
138
|
options.baseUrl === undefined ? undefined : normalizeSixbApiBaseUrl(options.baseUrl)
|
|
139
|
+
const session = sixbSessionOptions(options)
|
|
140
|
+
// Shares and sessions stamp their credential at the transport, on every request to the API. The
|
|
141
|
+
// generated per-operation auth only covers operations whose OpenAPI entry declares that scheme.
|
|
122
142
|
const configuredFetch =
|
|
123
143
|
auth.kind === "shared"
|
|
124
144
|
? createSharedAuthorityFetch({
|
|
@@ -126,36 +146,34 @@ export function createSixbClientConfig(options: SixbClientOptions = {}): Config
|
|
|
126
146
|
grantId: auth.grantId,
|
|
127
147
|
fetch: options.fetch ?? globalThis.fetch,
|
|
128
148
|
})
|
|
129
|
-
:
|
|
149
|
+
: session
|
|
150
|
+
? createSixbSessionFetch(session)
|
|
151
|
+
: options.fetch
|
|
130
152
|
|
|
131
153
|
return createConfig({
|
|
132
154
|
...(baseUrl === undefined ? {} : { baseUrl }),
|
|
133
155
|
...(configuredFetch === undefined ? {} : { fetch: configuredFetch }),
|
|
134
156
|
...(options.headers === undefined ? {} : { headers: options.headers }),
|
|
135
157
|
credentials: auth.kind === "cookie" || auth.kind === "shared" ? "include" : options.credentials,
|
|
136
|
-
auth:
|
|
158
|
+
auth:
|
|
159
|
+
auth.kind === "none" || auth.kind === "session" ? undefined : createSixbAuthResolver(auth),
|
|
137
160
|
})
|
|
138
161
|
}
|
|
139
162
|
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const pathname = stripTrailingApiPath(url.pathname)
|
|
151
|
-
if (!absolute) {
|
|
152
|
-
return pathname
|
|
163
|
+
function sixbSessionOptions(options: SixbClientOptions): SixbSessionOptions | null {
|
|
164
|
+
const auth = options.auth
|
|
165
|
+
if (auth?.kind !== "session") return null
|
|
166
|
+
return {
|
|
167
|
+
baseUrl: options.baseUrl === undefined ? "" : normalizeSixbApiBaseUrl(options.baseUrl),
|
|
168
|
+
store: auth.store,
|
|
169
|
+
onSessionEnded: auth.onSessionEnded,
|
|
170
|
+
fetch: options.fetch,
|
|
153
171
|
}
|
|
154
|
-
|
|
155
|
-
return `${url.origin}${pathname === "/" ? "" : pathname}`
|
|
156
172
|
}
|
|
157
173
|
|
|
158
|
-
function createSixbAuthResolver(
|
|
174
|
+
function createSixbAuthResolver(
|
|
175
|
+
auth: Exclude<SixbClientAuth, { readonly kind: "none" | "session" }>
|
|
176
|
+
): Config["auth"] {
|
|
159
177
|
return (scheme: Auth) => {
|
|
160
178
|
if (auth.kind === "bearer") {
|
|
161
179
|
return isBearerAuth(scheme) ? auth.token : undefined
|
|
@@ -243,19 +261,6 @@ function resolveSharedApiOrigin(baseUrl: string | undefined): string {
|
|
|
243
261
|
}
|
|
244
262
|
}
|
|
245
263
|
|
|
246
|
-
function stripTrailingApiPath(pathname: string): string {
|
|
247
|
-
const trimmed = pathname.replace(/\/+$/, "")
|
|
248
|
-
if (!trimmed || trimmed === "/api") {
|
|
249
|
-
return ""
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if (trimmed.endsWith("/api")) {
|
|
253
|
-
return trimmed.slice(0, -4) || ""
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
return trimmed
|
|
257
|
-
}
|
|
258
|
-
|
|
259
264
|
/**
|
|
260
265
|
* Maps the generated client's raw error (bare body) into a `SixbApiError`.
|
|
261
266
|
* Runs for every failed response regardless of `throwOnError`, so both thrown
|
package/src/base-url.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function normalizeSixbApiBaseUrl(value: string): string {
|
|
2
|
+
const absolute = /^[a-z][a-z\d+.-]*:\/\//i.test(value)
|
|
3
|
+
let url: URL
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
url = new URL(value, absolute ? undefined : "http://sixb.local")
|
|
7
|
+
} catch {
|
|
8
|
+
throw new Error(`[SixbClient] Invalid API base URL '${value}'.`)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const pathname = stripTrailingApiPath(url.pathname)
|
|
12
|
+
if (!absolute) {
|
|
13
|
+
return pathname
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return `${url.origin}${pathname === "/" ? "" : pathname}`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function stripTrailingApiPath(pathname: string): string {
|
|
20
|
+
const trimmed = pathname.replace(/\/+$/, "")
|
|
21
|
+
if (!trimmed || trimmed === "/api") {
|
|
22
|
+
return ""
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (trimmed.endsWith("/api")) {
|
|
26
|
+
return trimmed.slice(0, -4) || ""
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return trimmed
|
|
30
|
+
}
|
package/src/browser.ts
CHANGED
|
@@ -457,7 +457,7 @@ export async function requireSixbBrowserAuthSession(
|
|
|
457
457
|
const { data } = await getAuthSession({ throwOnError: true })
|
|
458
458
|
|
|
459
459
|
if (data.authenticated) {
|
|
460
|
-
controller.setCsrfToken(data.csrfToken)
|
|
460
|
+
controller.setCsrfToken(data.csrfToken ?? null)
|
|
461
461
|
return data
|
|
462
462
|
}
|
|
463
463
|
|
package/src/client-authority.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Client } from "./generated/client"
|
|
2
|
+
import type { SixbSessionOptions } from "./session"
|
|
2
3
|
|
|
3
4
|
const sharedAuthorityClients = new WeakSet<Client>()
|
|
5
|
+
const sessionAuthorityClients = new WeakMap<Client, SixbSessionOptions>()
|
|
4
6
|
|
|
5
7
|
export const SHARED_ACCESS_REALTIME_UNAVAILABLE =
|
|
6
8
|
"Live updates are unavailable during shared access."
|
|
@@ -29,3 +31,20 @@ export function markClientSharedAuthority(client: Client, shared: boolean): void
|
|
|
29
31
|
export function hasClientSharedAuthority(client: Client): boolean {
|
|
30
32
|
return sharedAuthorityClients.has(client)
|
|
31
33
|
}
|
|
34
|
+
|
|
35
|
+
/** Record the native session a client signs in with, so its WebSockets can present it too. */
|
|
36
|
+
export function markClientSessionAuthority(
|
|
37
|
+
client: Client,
|
|
38
|
+
session: SixbSessionOptions | null
|
|
39
|
+
): void {
|
|
40
|
+
if (session) {
|
|
41
|
+
sessionAuthorityClients.set(client, session)
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
sessionAuthorityClients.delete(client)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function getClientSessionAuthority(client: Client): SixbSessionOptions | null {
|
|
49
|
+
return sessionAuthorityClients.get(client) ?? null
|
|
50
|
+
}
|
package/src/events-builder.ts
CHANGED
|
@@ -50,8 +50,8 @@ export interface EventsFilterSpec extends EventSelectorSpec {}
|
|
|
50
50
|
|
|
51
51
|
// ── Payload typing ──────────────────────────────────────────────────────────
|
|
52
52
|
// Flat, named conditionals keyed on the channel — never a recursive resolver —
|
|
53
|
-
//
|
|
54
|
-
//
|
|
53
|
+
// so property-value inference stays shallow enough for TypeScript's recursion
|
|
54
|
+
// limits (no TS2589).
|
|
55
55
|
|
|
56
56
|
type Override<TBase, TPatch> = Omit<TBase, keyof TPatch> & TPatch
|
|
57
57
|
|
|
@@ -103,7 +103,7 @@ type TelemetryEventForProperty<TToken extends PropertyToken | undefined> =
|
|
|
103
103
|
{
|
|
104
104
|
payload: Override<
|
|
105
105
|
StoredTelemetryEvent["payload"],
|
|
106
|
-
{ value: InferPropertyValue<TProperty
|
|
106
|
+
{ value: InferPropertyValue<TProperty> }
|
|
107
107
|
>
|
|
108
108
|
}
|
|
109
109
|
>
|
|
@@ -116,10 +116,7 @@ type ObjectPropertiesEventOf<
|
|
|
116
116
|
> = Override<
|
|
117
117
|
TEvent,
|
|
118
118
|
{
|
|
119
|
-
payload: Override<
|
|
120
|
-
TEvent["payload"],
|
|
121
|
-
{ properties: InferObjectProperties<TObjectType, readonly []> }
|
|
122
|
-
>
|
|
119
|
+
payload: Override<TEvent["payload"], { properties: InferObjectProperties<TObjectType> }>
|
|
123
120
|
}
|
|
124
121
|
>
|
|
125
122
|
|
|
@@ -343,7 +340,6 @@ export interface EventSubscribeExecutor {
|
|
|
343
340
|
*/
|
|
344
341
|
export function createWsSubscribeExecutor(options?: { client?: Client }): EventSubscribeExecutor {
|
|
345
342
|
const transportClient = options?.client ?? generatedClient
|
|
346
|
-
const baseUrl = transportClient.getConfig().baseUrl
|
|
347
343
|
if (hasClientSharedAuthority(transportClient)) {
|
|
348
344
|
return {
|
|
349
345
|
subscribe(_filter, _handler, subscribeOptions) {
|
|
@@ -375,7 +371,7 @@ export function createWsSubscribeExecutor(options?: { client?: Client }): EventS
|
|
|
375
371
|
reconnect: subscribeOptions?.reconnect,
|
|
376
372
|
reconnectDelayMs: subscribeOptions?.reconnectDelayMs,
|
|
377
373
|
handshakeTimeoutMs: subscribeOptions?.handshakeTimeoutMs,
|
|
378
|
-
|
|
374
|
+
client: transportClient,
|
|
379
375
|
onEvent: (event) => {
|
|
380
376
|
if (matches(event)) handler(event)
|
|
381
377
|
},
|
package/src/events-transport.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
type SixbEventTopic,
|
|
15
15
|
type SixbEventType,
|
|
16
16
|
} from "./events-model"
|
|
17
|
+
import type { Client } from "./generated/client"
|
|
17
18
|
import {
|
|
18
19
|
createReconnectingSocket,
|
|
19
20
|
createSixbWebSocketUrl,
|
|
@@ -40,8 +41,10 @@ export interface EventSocketOptions {
|
|
|
40
41
|
readonly reconnectDelayMs?: number
|
|
41
42
|
/** Maximum time to complete the event protocol handshake. */
|
|
42
43
|
readonly handshakeTimeoutMs?: number
|
|
43
|
-
/** Override the API base url. Defaults to the global client config. */
|
|
44
|
+
/** Override the API base url. Defaults to `client`'s, then the global client config. */
|
|
44
45
|
readonly baseUrl?: string
|
|
46
|
+
/** The client whose API and credential the socket uses. Defaults to the package's shared client. */
|
|
47
|
+
readonly client?: Client
|
|
45
48
|
readonly onEvent: (event: SixbEvent) => void
|
|
46
49
|
readonly onError?: (error: string) => void
|
|
47
50
|
readonly onStateChange?: (state: EventSocketState) => void
|
|
@@ -81,7 +84,8 @@ export function createEventSocket(options: EventSocketOptions): EventSocket {
|
|
|
81
84
|
}
|
|
82
85
|
|
|
83
86
|
return createReconnectingSocket({
|
|
84
|
-
url: createSixbEventsWebSocketUrl(options.baseUrl),
|
|
87
|
+
url: createSixbEventsWebSocketUrl(options.baseUrl ?? options.client?.getConfig().baseUrl),
|
|
88
|
+
client: options.client,
|
|
85
89
|
reconnect: options.reconnect,
|
|
86
90
|
reconnectDelayMs: options.reconnectDelayMs,
|
|
87
91
|
readyTimeoutMs: options.handshakeTimeoutMs,
|
|
@@ -117,6 +117,8 @@ import {
|
|
|
117
117
|
queryObjects,
|
|
118
118
|
reactivateAuthMember,
|
|
119
119
|
reauthorizeConnectorConnection,
|
|
120
|
+
recreateAgentThreadSandbox,
|
|
121
|
+
refreshAuthSession,
|
|
120
122
|
removeObjectLink,
|
|
121
123
|
requestAction,
|
|
122
124
|
requestPipelineRun,
|
|
@@ -451,6 +453,12 @@ import type {
|
|
|
451
453
|
ReauthorizeConnectorConnectionData,
|
|
452
454
|
ReauthorizeConnectorConnectionError,
|
|
453
455
|
ReauthorizeConnectorConnectionResponse,
|
|
456
|
+
RecreateAgentThreadSandboxData,
|
|
457
|
+
RecreateAgentThreadSandboxError,
|
|
458
|
+
RecreateAgentThreadSandboxResponse,
|
|
459
|
+
RefreshAuthSessionData,
|
|
460
|
+
RefreshAuthSessionError,
|
|
461
|
+
RefreshAuthSessionResponse,
|
|
454
462
|
RemoveObjectLinkData,
|
|
455
463
|
RemoveObjectLinkError,
|
|
456
464
|
RemoveObjectLinkResponse,
|
|
@@ -588,6 +596,33 @@ export const exchangeDeviceAuthorizationMutation = (
|
|
|
588
596
|
return mutationOptions
|
|
589
597
|
}
|
|
590
598
|
|
|
599
|
+
/**
|
|
600
|
+
* Refresh a native client's session tokens
|
|
601
|
+
*/
|
|
602
|
+
export const refreshAuthSessionMutation = (
|
|
603
|
+
options?: Partial<Options<RefreshAuthSessionData>>
|
|
604
|
+
): UseMutationOptions<
|
|
605
|
+
RefreshAuthSessionResponse,
|
|
606
|
+
RefreshAuthSessionError,
|
|
607
|
+
Options<RefreshAuthSessionData>
|
|
608
|
+
> => {
|
|
609
|
+
const mutationOptions: UseMutationOptions<
|
|
610
|
+
RefreshAuthSessionResponse,
|
|
611
|
+
RefreshAuthSessionError,
|
|
612
|
+
Options<RefreshAuthSessionData>
|
|
613
|
+
> = {
|
|
614
|
+
mutationFn: async (fnOptions) => {
|
|
615
|
+
const { data } = await refreshAuthSession({
|
|
616
|
+
...options,
|
|
617
|
+
...fnOptions,
|
|
618
|
+
throwOnError: true,
|
|
619
|
+
})
|
|
620
|
+
return data
|
|
621
|
+
},
|
|
622
|
+
}
|
|
623
|
+
return mutationOptions
|
|
624
|
+
}
|
|
625
|
+
|
|
591
626
|
export type QueryKey<TOptions extends Options> = [
|
|
592
627
|
Pick<TOptions, "baseUrl" | "body" | "headers" | "path" | "query"> & {
|
|
593
628
|
_id: string
|
|
@@ -4088,6 +4123,33 @@ export const getAgentThreadOptions = (options: Options<GetAgentThreadData>) =>
|
|
|
4088
4123
|
queryKey: getAgentThreadQueryKey(options),
|
|
4089
4124
|
})
|
|
4090
4125
|
|
|
4126
|
+
/**
|
|
4127
|
+
* Explicitly recreate an unavailable or uncertain workspace without deleting its previous state
|
|
4128
|
+
*/
|
|
4129
|
+
export const recreateAgentThreadSandboxMutation = (
|
|
4130
|
+
options?: Partial<Options<RecreateAgentThreadSandboxData>>
|
|
4131
|
+
): UseMutationOptions<
|
|
4132
|
+
RecreateAgentThreadSandboxResponse,
|
|
4133
|
+
RecreateAgentThreadSandboxError,
|
|
4134
|
+
Options<RecreateAgentThreadSandboxData>
|
|
4135
|
+
> => {
|
|
4136
|
+
const mutationOptions: UseMutationOptions<
|
|
4137
|
+
RecreateAgentThreadSandboxResponse,
|
|
4138
|
+
RecreateAgentThreadSandboxError,
|
|
4139
|
+
Options<RecreateAgentThreadSandboxData>
|
|
4140
|
+
> = {
|
|
4141
|
+
mutationFn: async (fnOptions) => {
|
|
4142
|
+
const { data } = await recreateAgentThreadSandbox({
|
|
4143
|
+
...options,
|
|
4144
|
+
...fnOptions,
|
|
4145
|
+
throwOnError: true,
|
|
4146
|
+
})
|
|
4147
|
+
return data
|
|
4148
|
+
},
|
|
4149
|
+
}
|
|
4150
|
+
return mutationOptions
|
|
4151
|
+
}
|
|
4152
|
+
|
|
4091
4153
|
export const listAgentThreadMessagesQueryKey = (options: Options<ListAgentThreadMessagesData>) =>
|
|
4092
4154
|
createQueryKey("listAgentThreadMessages", options)
|
|
4093
4155
|
|
package/src/generated/index.ts
CHANGED
|
@@ -113,6 +113,8 @@ export {
|
|
|
113
113
|
queryObjects,
|
|
114
114
|
reactivateAuthMember,
|
|
115
115
|
reauthorizeConnectorConnection,
|
|
116
|
+
recreateAgentThreadSandbox,
|
|
117
|
+
refreshAuthSession,
|
|
116
118
|
removeObjectLink,
|
|
117
119
|
requestAction,
|
|
118
120
|
requestPipelineRun,
|
|
@@ -152,6 +154,7 @@ export type {
|
|
|
152
154
|
AddConnectorConnectionErrors,
|
|
153
155
|
AddConnectorConnectionResponse,
|
|
154
156
|
AddConnectorConnectionResponses,
|
|
157
|
+
AiUsageLimitErrorResponse,
|
|
155
158
|
AppendTelemetryData,
|
|
156
159
|
AppendTelemetryError,
|
|
157
160
|
AppendTelemetryErrors,
|
|
@@ -692,6 +695,16 @@ export type {
|
|
|
692
695
|
ReauthorizeConnectorConnectionErrors,
|
|
693
696
|
ReauthorizeConnectorConnectionResponse,
|
|
694
697
|
ReauthorizeConnectorConnectionResponses,
|
|
698
|
+
RecreateAgentThreadSandboxData,
|
|
699
|
+
RecreateAgentThreadSandboxError,
|
|
700
|
+
RecreateAgentThreadSandboxErrors,
|
|
701
|
+
RecreateAgentThreadSandboxResponse,
|
|
702
|
+
RecreateAgentThreadSandboxResponses,
|
|
703
|
+
RefreshAuthSessionData,
|
|
704
|
+
RefreshAuthSessionError,
|
|
705
|
+
RefreshAuthSessionErrors,
|
|
706
|
+
RefreshAuthSessionResponse,
|
|
707
|
+
RefreshAuthSessionResponses,
|
|
695
708
|
RemoveObjectLinkData,
|
|
696
709
|
RemoveObjectLinkError,
|
|
697
710
|
RemoveObjectLinkErrors,
|