@vinaverse/server 0.1.0-alpha.15 → 0.1.0-alpha.16
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/README.md +8 -0
- package/dist/api.cjs +44 -0
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.cts +31 -2
- package/dist/api.d.ts +31 -2
- package/dist/api.js +44 -0
- package/dist/api.js.map +1 -1
- package/dist/express.d.cts +2 -2
- package/dist/express.d.ts +2 -2
- package/dist/fastify.d.cts +2 -2
- package/dist/fastify.d.ts +2 -2
- package/dist/hono.d.cts +2 -2
- package/dist/hono.d.ts +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/lambda.d.cts +2 -2
- package/dist/lambda.d.ts +2 -2
- package/dist/{provider-ClyzwMQx.d.ts → provider-1SsRbyN-.d.ts} +6 -1
- package/dist/{provider-CLoSmI29.d.cts → provider-DhsUFcqq.d.cts} +6 -1
- package/dist/{vinaverse-v1.d-DiulmRgx.d.cts → vinaverse-v1.d-D-NPpZqW.d.cts} +1339 -25
- package/dist/{vinaverse-v1.d-DiulmRgx.d.ts → vinaverse-v1.d-D-NPpZqW.d.ts} +1339 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -160,6 +160,14 @@ try {
|
|
|
160
160
|
`conversations.delete(id, { subject_id })` read and delete a person's past conversations; another subject's or an
|
|
161
161
|
unknown conversation is `not_found`, never told apart. **Served from A7**, when the gateway's history support ships:
|
|
162
162
|
until then every call is answered 404, which reads as `not_found` and does not mean the conversation is unknown.
|
|
163
|
+
- **The chat experience:** `agents.getExperience(agent, { experience_mode })` reads the tenant's chat settings for an
|
|
164
|
+
agent, resolved, before any session: copy it into your agent status as `features.chat`. Inside a session the app
|
|
165
|
+
reads the session's own copy. **Served once the gateway's chat settings ship** (VIN-115): until then the call is
|
|
166
|
+
answered 404, which reads as `not_found` and does not mean the agent is unknown.
|
|
167
|
+
- **Memory:** `subjects.getMemory(id, { experience_mode })`, `subjects.putMemory(id, body)`,
|
|
168
|
+
`subjects.acknowledgeMemoryNotice(id, { version })` and `subjects.deleteMemoryPreference(id, preferenceId)` back a
|
|
169
|
+
person's memory settings screen: what the agent remembers, their choice, the notice they saw, and forgetting one
|
|
170
|
+
thing.
|
|
163
171
|
- **Every operation** is also on `vinaverse.api`, the typed openapi-fetch client (`api.GET('/v1/usage')`).
|
|
164
172
|
- **Backend only.** The client refuses a client secret, and refuses to start in a browser or in React Native: a
|
|
165
173
|
service key there ships to everyone who loads the app. Apps use `@vinaverse/client` with the session's client secret.
|
package/dist/api.cjs
CHANGED
|
@@ -470,6 +470,50 @@ function createApiClient(options) {
|
|
|
470
470
|
params: { path: { subject_id: subjectId }, header },
|
|
471
471
|
...init(o)
|
|
472
472
|
})
|
|
473
|
+
),
|
|
474
|
+
/** What the agent remembers of the person, and their choice, on one side of the app (memory settings). */
|
|
475
|
+
getMemory: (subjectId, query = {}, o) => run(
|
|
476
|
+
api.GET("/v1/subjects/{subject_id}/memory", {
|
|
477
|
+
params: { path: { subject_id: subjectId }, query },
|
|
478
|
+
...init(o)
|
|
479
|
+
})
|
|
480
|
+
),
|
|
481
|
+
/** The person's choice: whether the agent may remember them. */
|
|
482
|
+
putMemory: (subjectId, body, o) => run(
|
|
483
|
+
api.PUT("/v1/subjects/{subject_id}/memory", {
|
|
484
|
+
params: { path: { subject_id: subjectId } },
|
|
485
|
+
body,
|
|
486
|
+
...init(o)
|
|
487
|
+
})
|
|
488
|
+
),
|
|
489
|
+
/** The person saw the memory notice of this version. */
|
|
490
|
+
acknowledgeMemoryNotice: (subjectId, body, o) => run(
|
|
491
|
+
api.POST("/v1/subjects/{subject_id}/memory/notice", {
|
|
492
|
+
params: { path: { subject_id: subjectId } },
|
|
493
|
+
body,
|
|
494
|
+
...init(o)
|
|
495
|
+
})
|
|
496
|
+
),
|
|
497
|
+
/** Forgets one thing the agent learned about the person. */
|
|
498
|
+
deleteMemoryPreference: (subjectId, preferenceId, o) => run(
|
|
499
|
+
api.DELETE(
|
|
500
|
+
"/v1/subjects/{subject_id}/memory/preferences/{preference_id}",
|
|
501
|
+
{
|
|
502
|
+
params: {
|
|
503
|
+
path: { subject_id: subjectId, preference_id: preferenceId }
|
|
504
|
+
},
|
|
505
|
+
...init(o)
|
|
506
|
+
}
|
|
507
|
+
)
|
|
508
|
+
)
|
|
509
|
+
},
|
|
510
|
+
agents: {
|
|
511
|
+
/** The tenant's chat experience for an agent, resolved, before any session: copy it into the agent status. */
|
|
512
|
+
getExperience: (agent, query = {}, o) => run(
|
|
513
|
+
api.GET("/v1/agents/{agent}/experience", {
|
|
514
|
+
params: { path: { agent }, query },
|
|
515
|
+
...init(o)
|
|
516
|
+
})
|
|
473
517
|
)
|
|
474
518
|
},
|
|
475
519
|
feedback: {
|
package/dist/api.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/errors.ts","../src/api/random.ts","../src/api/retry.ts","../src/api/client.ts"],"names":["createClient","key"],"mappings":";;;;;;;;;;;AAQO,IAAM,iBAAA,GAAN,cAAgC,KAAA,CAAM;AAAA,EACzB,IAAA,GAAO,mBAAA;AAAA,EAChB,MAAA;AAAA;AAAA,EAEA,IAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,UAAA;AAAA;AAAA,EAEA,MAAA;AAAA;AAAA,EAEA,OAAA;AAAA;AAAA,EAEA,cAAA;AAAA,EAET,YAAY,IAAA,EAMT;AACD,IAAA,MAAM,EAAE,MAAA,EAAQ,OAAA,EAAQ,GAAI,IAAA;AAC5B,IAAA,KAAA;AAAA,MACE,UACI,CAAA,EAAG,OAAA,CAAQ,KAAK,CAAA,EAAA,EAAK,QAAQ,IAAI,CAAA,CAAA,EAAI,OAAA,CAAQ,MAAA,GAAS,K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AACN,IAAA,MAAM,IAAI,SAAA,CAAU,CAAA,sBAAA,EAAyB,KAAK,CAAA,CAAE,CAAA;AAAA,EACtD;AACA,EAAA,IACE,GAAA,CAAI,QAAA,KAAa,QAAA,IACjB,EAAE,GAAA,CAAI,QAAA,KAAa,OAAA,IAAW,QAAA,CAAS,GAAA,CAAI,GAAA,CAAI,QAAQ,CAAA,CAAA,EACvD;AACA,IAAA,MAAM,IAAI,SAAA;AAAA,MACR,CAAA,sFAAA,EAAyF,IAAI,MAAM,CAAA;AAAA,KACrG;AAAA,EACF;AACA,EAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA;AACjC;AAGA,SAAS,WAAW,OAAA,EAAwC;AAC1D,EAAA,MAAM,MAAA,GAAS,IAAI,GAAA,CAAI,OAAO,CAAA,CAAE,MAAA;AAChC,EAAA,OAAO,CAAC,GAAA,KAAQ;AACd,IAAA,MAAM,MAAA,GAAS,IAAI,GAAA,CAAI,GAAG,CAAA;AAC1B,IAAA,IAAI,MAAA,CAAO,WAAW,MAAA,EAAQ;AAC5B,MAAA,MAAM,IAAI,SAAA;AAAA,QACR,CAAA,kDAAA,EAAqD,MAAM,CAAA,cAAA,EAAiB,MAAA,CAAO,MAAM,CAAA;AAAA,OAC3F;AAAA,IACF;AAAA,EACF,CAAA;AACF;AAEA,SAAS,MAAA,GAA0B;AACjC,EAAA,OAAO,UAAA,EAAW;AACpB","file":"api.cjs","sourcesContent":["// What the Vinaverse API answers when it refuses a call: RFC 9457 problem details (vinaverse-v1.yaml, `Problem`),\n// as a typed error. conformance/README.md §5 lists every code with its status and whether it is retryable.\nimport type { components } from '../generated/vinaverse-v1.js';\n\nexport type ApiProblem = components['schemas']['Problem'];\nexport type ApiProblemCode = ApiProblem['code'];\n\n/** The API refused a call: its problem details, typed, with the request id to quote to support. */\nexport class VinaverseApiError extends Error {\n override readonly name = 'VinaverseApiError';\n readonly status: number;\n /** The problem's code (`invalid_request`, `rate_limited`, …), or `http_<status>` when the body was not a problem. */\n readonly code: ApiProblemCode | `http_${number}`;\n /** Whether the same call may succeed later: the problem's `retryable`, else true for 429 and 5xx. */\n readonly retryable: boolean;\n /** `Vinaverse-Request-Id`, or the problem's `request_id`. */\n readonly requestId: string | undefined;\n /** `Retry-After`, in seconds, when the API sent one. */\n readonly retryAfter: number | undefined;\n /** For `invalid_request`: the fields refused, as JSON Pointers into the request. */\n readonly errors: readonly { pointer: string; message: string }[];\n /** The problem as sent, or undefined when the body was not one. */\n readonly problem: ApiProblem | undefined;\n /** The `Idempotency-Key` the call carried: send the same call again with it to have it done once. */\n readonly idempotencyKey: string | undefined;\n\n constructor(init: {\n status: number;\n problem?: ApiProblem | undefined;\n requestId?: string | undefined;\n retryAfter?: number | undefined;\n idempotencyKey?: string | undefined;\n }) {\n const { status, problem } = init;\n super(\n problem\n ? `${problem.title} (${problem.code})${problem.detail ? `: ${problem.detail}` : ''}`\n : `The Vinaverse API answered HTTP ${status}.`,\n );\n this.idempotencyKey = init.idempotencyKey;\n this.status = status;\n this.problem = problem;\n this.code = problem?.code ?? `http_${status}`;\n this.retryable = problem?.retryable ?? (status === 429 || status >= 500);\n this.requestId = init.requestId ?? problem?.request_id;\n this.retryAfter = init.retryAfter;\n this.errors = problem?.errors ?? [];\n }\n}\n\n/** The error for a refused response and its parsed body: what every call of the API client throws. */\nexport function apiError(\n response: Response,\n body: unknown,\n idempotencyKey?: string,\n): VinaverseApiError {\n return new VinaverseApiError({\n status: response.status,\n problem: isProblem(body) ? body : undefined,\n requestId: response.headers.get('vinaverse-request-id') ?? undefined,\n retryAfter: retryAfterSeconds(response),\n idempotencyKey,\n });\n}\n\n/** `Retry-After` in seconds: a number of seconds or an HTTP date; undefined when absent or unreadable. */\nexport function retryAfterSeconds(\n response: Response,\n now: () => number = Date.now,\n): number | undefined {\n const value = response.headers.get('retry-after');\n if (value === null || value.trim() === '') return undefined;\n if (/^\\d+$/.test(value.trim())) return Number(value.trim());\n const at = Date.parse(value);\n return Number.isNaN(at)\n ? undefined\n : Math.max(0, Math.ceil((at - now()) / 1000));\n}\n\nfunction isProblem(body: unknown): body is ApiProblem {\n if (typeof body !== 'object' || body === null) return false;\n const b = body as Record<string, unknown>;\n return typeof b.code === 'string' && typeof b.status === 'number';\n}\n","// A random UUID for idempotency keys wherever the client runs. Node 20+, Deno, Bun and edge runtimes have\n// `crypto.randomUUID`; Node 18 has it only in its crypto module when loaded as an ES module, so it is loaded from\n// there, once.\nlet fromNode: Promise<() => string> | undefined;\n\nexport async function randomUUID(): Promise<string> {\n const global = (globalThis as { crypto?: { randomUUID?: () => string } })\n .crypto;\n if (global?.randomUUID) return global.randomUUID();\n // Built at run time on purpose: a bundler for an edge runtime, where this line never runs, must not resolve it.\n const specifier = ['node', 'crypto'].join(':');\n fromNode ??= import(\n /* webpackIgnore: true */ /* @vite-ignore */ specifier\n ).then((mod: { randomUUID: () => string }) => mod.randomUUID);\n return (await fromNode)();\n}\n","// Safe retries for calls to the Vinaverse API. A call is sent again only when that cannot do it twice:\n// - `429`: the API refused it before doing anything, so any call is retried, after its `Retry-After`;\n// - a retryable failure (a `5xx`, a problem with `retryable: true`, a timeout or a network error): only a read\n// (`GET`, `HEAD`, `OPTIONS`), an idempotent `PUT` or `DELETE`, or a call carrying an `Idempotency-Key`, which the\n// API answers once whatever the number of tries.\n// Delays: `Retry-After` when the API sends one, else 0.5 s doubling, with jitter; a `Retry-After` longer than\n// `maxRetryDelay` is not waited for: the refusal is returned.\n// Each try reads the whole response within its timeout, so a stalled body cannot hang a call, and the caller's\n// signal stops everything at once: a try in flight, a body being read, a wait between tries. An aborted signal never\n// sends the call. Redirects are refused: a service key never follows one.\n\nimport { retryAfterSeconds } from './errors.js';\n\nexport type FetchFn = (input: Request) => Promise<Response>;\n\nexport interface RetryOptions {\n /** Retries after the first try: a whole number, 0 or more; default 2. */\n readonly maxRetries?: number;\n /** The longest wait, in seconds, before a retry: 0 to 2 147 483 (a timer's limit); default 30. */\n readonly maxRetryDelay?: number;\n /** One try's timeout, reading the body included, in milliseconds: more than 0, at most 2 147 483 647; default 30 000. */\n readonly timeout?: number;\n /** Waits, in milliseconds; tests replace it. The wait ends early when the call is aborted. */\n readonly sleep?: (ms: number) => Promise<void>;\n readonly random?: () => number;\n}\n\nconst IDEMPOTENT = new Set(['GET', 'HEAD', 'PUT', 'DELETE', 'OPTIONS']);\n/** Statuses whose responses have no body. */\nconst NULL_BODY = new Set([101, 204, 205, 304]);\n/** A refusal's body is read up to this size: a problem is far smaller; more is an intermediary's page. */\nconst MAX_REFUSAL_BYTES = 64 * 1024;\n\n/**\n * The API did not answer within `timeout` on the last try. `idempotencyKey` is the key the call carried: pass it as\n * `{ idempotencyKey }` to try the same call again later without doing it twice.\n */\nexport class VinaverseTimeoutError extends Error {\n override readonly name = 'VinaverseTimeoutError';\n readonly idempotencyKey: string | undefined;\n constructor(ms: number, idempotencyKey?: string) {\n super(`The Vinaverse API did not answer within ${ms} ms.`);\n this.idempotencyKey = idempotencyKey;\n }\n}\n\n/** The call could not reach the API (`cause` holds why). `idempotencyKey` as for a timeout. */\nexport class VinaverseNetworkError extends Error {\n override readonly name = 'VinaverseNetworkError';\n readonly idempotencyKey: string | undefined;\n constructor(cause: unknown, idempotencyKey?: string) {\n super(\n `The Vinaverse API could not be reached: ${cause instanceof Error ? cause.message : String(cause)}`,\n { cause },\n );\n this.idempotencyKey = idempotencyKey;\n }\n}\n\n/** The longest a timer can wait: beyond it, Node fires it after 1 ms. */\nconst MAX_TIMER_MS = 2_147_483_647;\n\n/**\n * `guard` checks each request's URL before anything is sent (the client allows its own origin only); what it throws\n * is thrown as is.\n */\nexport function retryingFetch(\n fetchFn: FetchFn,\n options: RetryOptions = {},\n guard: (url: string) => void = () => {},\n): FetchFn {\n const maxRetries = check(\n 'maxRetries',\n options.maxRetries ?? 2,\n (n) => Number.isSafeInteger(n) && n >= 0,\n );\n const maxDelay =\n check(\n 'maxRetryDelay',\n options.maxRetryDelay ?? 30,\n (n) => Number.isFinite(n) && n >= 0 && n * 1000 <= MAX_TIMER_MS,\n ) * 1000;\n const timeout = check(\n 'timeout',\n options.timeout ?? 30_000,\n (n) => Number.isFinite(n) && n > 0 && n <= MAX_TIMER_MS,\n );\n const sleep = options.sleep;\n const random = options.random ?? Math.random;\n\n return async (request) => {\n guard(request.url);\n const signal = request.signal;\n const key = request.headers.get('idempotency-key') ?? undefined;\n const replayable =\n IDEMPOTENT.has(request.method.toUpperCase()) || key !== undefined;\n for (let attempt = 0; ; attempt++) {\n if (signal.aborted) throw aborted(signal);\n const last = attempt >= maxRetries;\n let response: Response;\n try {\n response = await once(fetchFn, request.clone(), signal, timeout);\n } catch (error) {\n if (signal.aborted) throw aborted(signal);\n // A network error or a timeout: the call may have been done; only a replayable one goes again.\n if (last || !replayable) {\n throw error instanceof VinaverseTimeoutError\n ? new VinaverseTimeoutError(timeout, key)\n : new VinaverseNetworkError(error, key);\n }\n await wait(sleep, Math.min(backoff(attempt, random), maxDelay), signal);\n continue;\n }\n const retry =\n response.status === 429 ||\n (replayable && retryable(response, await problemOf(response)));\n if (!retry || last) return response;\n const delay = retryAfter(response) ?? backoff(attempt, random);\n if (delay > maxDelay) return response;\n await wait(sleep, delay, signal);\n }\n };\n}\n\n/** One try, its body read in full within the timeout; refused bodies up to `MAX_REFUSAL_BYTES`. */\nasync function once(\n fetchFn: FetchFn,\n request: Request,\n signal: AbortSignal,\n timeout: number,\n): Promise<Response> {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeout);\n const stop = () => controller.abort();\n signal.addEventListener('abort', stop, { once: true });\n if (signal.aborted) controller.abort();\n try {\n // Raced against the timeout and the caller's signal too, so a transport that ignores its signal is still bounded.\n const pending = fetchFn(\n new Request(request, { signal: controller.signal, redirect: 'error' }),\n );\n pending.catch(() => {}); // when the abort wins, the transport's own failure is not reported twice\n const response = await until(pending, controller.signal);\n const empty = NULL_BODY.has(response.status);\n const body = empty\n ? null\n : await readBody(\n response,\n response.ok ? Number.POSITIVE_INFINITY : MAX_REFUSAL_BYTES,\n controller.signal,\n );\n return new Response(body, {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n } catch (error) {\n if (controller.signal.aborted && !signal.aborted)\n throw new VinaverseTimeoutError(timeout);\n throw error;\n } finally {\n clearTimeout(timer);\n signal.removeEventListener('abort', stop);\n }\n}\n\nasync function readBody(\n response: Response,\n limit: number,\n signal: AbortSignal,\n): Promise<Uint8Array<ArrayBuffer> | null> {\n if (!response.body) return null;\n const reader = response.body.getReader();\n const chunks: Uint8Array[] = [];\n let size = 0;\n for (;;) {\n const read = reader.read();\n read.catch(() => {}); // an abort below wins; the read's own failure is not reported twice\n const { done, value } = await until(read, signal).catch(\n async (error: unknown) => {\n void reader.cancel().catch(() => {}); // not awaited: a teed body settles its cancel only with its twin\n throw error;\n },\n );\n if (done) break;\n chunks.push(value);\n size += value.length;\n if (size >= limit) {\n void reader.cancel().catch(() => {}); // not awaited: a teed body settles its cancel only with its twin\n break;\n }\n }\n const body = new Uint8Array(new ArrayBuffer(Math.min(size, limit)));\n let at = 0;\n for (const chunk of chunks) {\n const part = chunk.subarray(0, body.length - at);\n body.set(part, at);\n at += part.length;\n if (at >= body.length) break;\n }\n return body;\n}\n\nasync function problemOf(\n response: Response,\n): Promise<{ retryable?: unknown } | undefined> {\n if (response.ok) return undefined;\n try {\n return (await response.clone().json()) as { retryable?: unknown };\n } catch {\n return undefined;\n }\n}\n\nfunction retryable(\n response: Response,\n problem: { retryable?: unknown } | undefined,\n): boolean {\n if (response.status >= 500) return true;\n // Another refusal is retried only when the API says so.\n return response.status >= 400 && problem?.retryable === true;\n}\n\n/** `promise`, or the signal's abort, whichever comes first. */\nasync function until<T>(promise: Promise<T>, signal: AbortSignal): Promise<T> {\n if (signal.aborted) throw aborted(signal);\n let stop: () => void = () => {};\n const abort = new Promise<never>((_, reject) => {\n stop = () => reject(aborted(signal));\n signal.addEventListener('abort', stop, { once: true });\n });\n try {\n return await Promise.race([promise, abort]);\n } finally {\n signal.removeEventListener('abort', stop);\n }\n}\n\n/** Waits `ms`, or less: an abort ends the wait, clears its timer, and throws. */\nfunction wait(\n sleep: ((ms: number) => Promise<void>) | undefined,\n ms: number,\n signal: AbortSignal,\n): Promise<void> {\n if (sleep) return until(sleep(ms), signal);\n if (signal.aborted) return Promise.reject(aborted(signal));\n return new Promise<void>((resolve, reject) => {\n const stop = () => {\n clearTimeout(timer);\n reject(aborted(signal));\n };\n const timer = setTimeout(() => {\n signal.removeEventListener('abort', stop);\n resolve();\n }, ms);\n signal.addEventListener('abort', stop, { once: true });\n });\n}\n\nfunction aborted(signal: AbortSignal): unknown {\n return (\n signal.reason ?? new DOMException('The call was aborted.', 'AbortError')\n );\n}\n\nfunction retryAfter(response: Response): number | undefined {\n const seconds = retryAfterSeconds(response);\n return seconds === undefined ? undefined : seconds * 1000;\n}\n\nfunction backoff(attempt: number, random: () => number): number {\n const base = 500 * 2 ** attempt;\n return Math.round(base / 2 + random() * (base / 2));\n}\n\nfunction check(\n name: string,\n value: number,\n valid: (n: number) => boolean,\n): number {\n if (typeof value !== 'number' || !valid(value)) {\n throw new TypeError(`${name} is not valid: ${String(value)}`);\n }\n return value;\n}\n","// The Vinaverse API from a Node backend: typed calls generated from the pinned public contract (vinaverse-v1.yaml,\n// through openapi-fetch), authenticated with a service key, with idempotency keys added where the contract wants\n// one, safe retries honouring `Retry-After` (./retry.ts), and refusals thrown as typed errors (./errors.ts).\n// A service key never belongs in a browser or an app: the client refuses to start there.\nimport createClient, { type Client } from 'openapi-fetch';\nimport type { operations, paths } from '../generated/vinaverse-v1.js';\nimport { apiError } from './errors.js';\nimport { randomUUID } from './random.js';\nimport { type FetchFn, type RetryOptions, retryingFetch } from './retry.js';\n\ntype Op = operations;\n/** An operation's JSON request body. */\nexport type ApiBody<K extends keyof Op> = Op[K] extends {\n requestBody?: { content: { 'application/json': infer B } };\n}\n ? B\n : never;\n/** An operation's success result. */\nexport type ApiResult<K extends keyof Op> = Success<Op[K]['responses']>;\ntype Success<R> = R extends {\n 200: { content: { 'application/json': infer B } };\n}\n ? B\n : R extends { 201: { content: { 'application/json': infer B } } }\n ? B\n : R extends { 202: { content: { 'application/json': infer B } } }\n ? B\n : undefined;\ntype QueryOf<K extends keyof Op> = Op[K]['parameters'] extends {\n query?: infer Q;\n}\n ? NonNullable<Q>\n : never;\n\n/** Per call: a signal that stops it at once, waits between tries included. */\nexport interface CallOptions {\n readonly signal?: AbortSignal;\n}\n\n/**\n * For the calls the contract makes idempotent: a key of your own, 1 to 255 characters (one is made otherwise).\n * After a `VinaverseTimeoutError` or a `VinaverseNetworkError`, try again later with the error's `idempotencyKey`,\n * so the call is done once however many times it is sent.\n */\nexport interface KeyedCallOptions extends CallOptions {\n readonly idempotencyKey?: string;\n}\n\nexport interface ApiClientOptions extends RetryOptions {\n /** A service key, `vv_sk_<mock|dev|live>_…`: from your secrets store, never from code. */\n readonly apiKey: string;\n /**\n * Default: `https://api.vinaverse.com` for a live key, `https://api-dev.vinaverse.com` for mock and dev keys. Any\n * other URL must be `https:` (a proxy you run, say), or `http:` on this machine only (`localhost`, `127.0.0.1`,\n * `[::1]`): a service key never travels in clear.\n */\n readonly baseUrl?: string;\n readonly fetch?: (request: Request) => Promise<Response>;\n /** Extra headers on every call, for example `Vinaverse-Mock-Scenario` in tests against the mock environment. */\n readonly headers?: Readonly<Record<string, string>>;\n}\n\nconst SERVICE_KEY = /^vv_sk_(mock|dev|live)_[A-Za-z0-9_-]{8,}$/;\n\n/** The client was made where a service key must never be: a browser or an app. */\nexport class ServiceKeyExposureError extends Error {\n override readonly name = 'ServiceKeyExposureError';\n}\n\nexport function createApiClient(options: ApiClientOptions) {\n refuseClientRuntime();\n const key = options.apiKey;\n if (typeof key !== 'string' || !SERVICE_KEY.test(key)) {\n throw new TypeError(\n key?.startsWith?.('vv_cs_')\n ? 'createApiClient takes a service key (vv_sk_…); a client secret (vv_cs_…) is for the app'\n : 'createApiClient needs a service key: vv_sk_<mock|dev|live>_…',\n );\n }\n const live = key.startsWith('vv_sk_live_');\n const baseUrl = safeBaseUrl(\n options.baseUrl ??\n (live ? 'https://api.vinaverse.com' : 'https://api-dev.vinaverse.com'),\n );\n const transport: FetchFn =\n options.fetch ?? ((request) => globalThis.fetch(request));\n const api: Client<paths> = createClient<paths>({\n baseUrl,\n redirect: 'error', // the API never redirects; a service key never follows one\n // Every request, from a helper or from `api` with a per-call baseUrl, goes to this origin only.\n fetch: retryingFetch(transport, options, sameOrigin(baseUrl)),\n headers: {\n ...options.headers,\n authorization: `Bearer ${key}`,\n accept: 'application/json',\n },\n });\n\n type Answer = Promise<{\n data?: unknown;\n error?: unknown;\n response: Response;\n }>;\n async function run<T>(call: Answer, idempotencyKey?: string): Promise<T> {\n const { data, error, response } = await call;\n if (!response.ok) throw apiError(response, error, idempotencyKey);\n return data as T;\n }\n /** A call the contract makes idempotent: under the caller's key, or a new one, on every try. */\n async function keyed<T>(\n o: KeyedCallOptions | undefined,\n call: (header: { 'Idempotency-Key': string }) => Answer,\n ): Promise<T> {\n const key = o?.idempotencyKey ?? (await newKey());\n if (typeof key !== 'string' || key.length < 1 || key.length > 255) {\n throw new TypeError('idempotencyKey must be 1 to 255 characters');\n }\n return run<T>(call({ 'Idempotency-Key': key }), key);\n }\n const init = (o?: CallOptions) => (o?.signal ? { signal: o.signal } : {});\n\n return {\n /** Every operation of the contract, typed, for what the helpers below do not cover (openapi-fetch). */\n api,\n sessions: {\n /** Mint a session for the person in your app; give the app its `id`, URLs and `client_secret` only. */\n create: (body: ApiBody<'createSession'>, o?: KeyedCallOptions) =>\n keyed<ApiResult<'createSession'>>(o, (header) =>\n api.POST('/v1/sessions', {\n body,\n params: { header },\n ...init(o),\n }),\n ),\n get: (sessionId: string, o?: CallOptions) =>\n run<ApiResult<'getSession'>>(\n api.GET('/v1/sessions/{session_id}', {\n params: { path: { session_id: sessionId } },\n ...init(o),\n }),\n ),\n revoke: (sessionId: string, o?: CallOptions) =>\n run<ApiResult<'revokeSession'>>(\n api.POST('/v1/sessions/{session_id}/revoke', {\n params: { path: { session_id: sessionId } },\n ...init(o),\n }),\n ),\n /**\n * Where the person is now, for an open session (no new session per screen): a screen context, or\n * `{ clear: true, revision }`; `revision` greater than the session's, the same revision and body a retry.\n */\n updateContext: (\n sessionId: string,\n body: ApiBody<'updateSessionContext'>,\n o?: CallOptions,\n ) =>\n run<ApiResult<'updateSessionContext'>>(\n api.PUT('/v1/sessions/{session_id}/context', {\n params: { path: { session_id: sessionId } },\n body,\n ...init(o),\n }),\n ),\n /** A fresh client secret for an open session: what an app's `refreshSecret(sessionId)` asks your backend for. */\n refreshClientSecret: (sessionId: string, o?: CallOptions) =>\n run<ApiResult<'refreshClientSecret'>>(\n api.POST('/v1/sessions/{session_id}/client_secret', {\n params: { path: { session_id: sessionId } },\n ...init(o),\n }),\n ),\n },\n conversations: {\n get: (conversationId: string, o?: CallOptions) =>\n run<ApiResult<'getConversation'>>(\n api.GET('/v1/conversations/{conversation_id}', {\n params: { path: { conversation_id: conversationId } },\n ...init(o),\n }),\n ),\n /** A person's past conversations with an agent, newest activity first (history). */\n list: (query: QueryOf<'listConversations'>, o?: CallOptions) =>\n run<ApiResult<'listConversations'>>(\n api.GET('/v1/conversations', { params: { query }, ...init(o) }),\n ),\n /** A past conversation's messages, the newest page first and oldest first within a page. */\n listMessages: (\n conversationId: string,\n query: QueryOf<'listConversationMessages'>,\n o?: CallOptions,\n ) =>\n run<ApiResult<'listConversationMessages'>>(\n api.GET('/v1/conversations/{conversation_id}/messages', {\n params: { path: { conversation_id: conversationId }, query },\n ...init(o),\n }),\n ),\n /** Deletes a person's conversation (history's delete); another subject's or an unknown one is `not_found`. */\n delete: (\n conversationId: string,\n query: QueryOf<'deleteConversation'>,\n o?: CallOptions,\n ) =>\n run<ApiResult<'deleteConversation'>>(\n api.DELETE('/v1/conversations/{conversation_id}', {\n params: { path: { conversation_id: conversationId }, query },\n ...init(o),\n }),\n ),\n },\n suggestions: {\n create: (body: ApiBody<'createSuggestions'>, o?: CallOptions) =>\n run<ApiResult<'createSuggestions'>>(\n api.POST('/v1/suggestions', { body, ...init(o) }),\n ),\n },\n moderation: {\n createJob: (body: ApiBody<'createModerationJob'>, o?: KeyedCallOptions) =>\n keyed<ApiResult<'createModerationJob'>>(o, (header) =>\n api.POST('/v1/moderation/jobs', {\n body,\n params: { header },\n ...init(o),\n }),\n ),\n getJob: (jobId: string, o?: CallOptions) =>\n run<ApiResult<'getModerationJob'>>(\n api.GET('/v1/moderation/jobs/{job_id}', {\n params: { path: { job_id: jobId } },\n ...init(o),\n }),\n ),\n getItem: (itemId: string, o?: CallOptions) =>\n run<ApiResult<'getModerationItem'>>(\n api.GET('/v1/moderation/items/{item_id}', {\n params: { path: { item_id: itemId } },\n ...init(o),\n }),\n ),\n },\n media: {\n createJob: (body: ApiBody<'createMediaJob'>, o?: KeyedCallOptions) =>\n keyed<ApiResult<'createMediaJob'>>(o, (header) =>\n api.POST('/v1/media/jobs', {\n body,\n params: { header },\n ...init(o),\n }),\n ),\n listJobs: (query: QueryOf<'listMediaJobs'> = {}, o?: CallOptions) =>\n run<ApiResult<'listMediaJobs'>>(\n api.GET('/v1/media/jobs', { params: { query }, ...init(o) }),\n ),\n getJob: (jobId: string, o?: CallOptions) =>\n run<ApiResult<'getMediaJob'>>(\n api.GET('/v1/media/jobs/{job_id}', {\n params: { path: { job_id: jobId } },\n ...init(o),\n }),\n ),\n cancelJob: (jobId: string, o?: CallOptions) =>\n run<ApiResult<'cancelMediaJob'>>(\n api.POST('/v1/media/jobs/{job_id}/cancel', {\n params: { path: { job_id: jobId } },\n ...init(o),\n }),\n ),\n listProfiles: (o?: CallOptions) =>\n run<ApiResult<'listMediaProfiles'>>(\n api.GET('/v1/media/profiles', { ...init(o) }),\n ),\n },\n screening: {\n text: (body: ApiBody<'screenText'>, o?: CallOptions) =>\n run<ApiResult<'screenText'>>(\n api.POST('/v1/screening/text', { body, ...init(o) }),\n ),\n },\n documentChecks: {\n create: (body: ApiBody<'createDocumentCheck'>, o?: KeyedCallOptions) =>\n keyed<ApiResult<'createDocumentCheck'>>(o, (header) =>\n api.POST('/v1/document-checks', {\n body,\n params: { header },\n ...init(o),\n }),\n ),\n get: (checkId: string, o?: CallOptions) =>\n run<ApiResult<'getDocumentCheck'>>(\n api.GET('/v1/document-checks/{check_id}', {\n params: { path: { check_id: checkId } },\n ...init(o),\n }),\n ),\n },\n subjects: {\n erase: (subjectId: string, o?: KeyedCallOptions) =>\n keyed<ApiResult<'eraseSubject'>>(o, (header) =>\n api.POST('/v1/subjects/{subject_id}/erase', {\n params: { path: { subject_id: subjectId }, header },\n ...init(o),\n }),\n ),\n },\n feedback: {\n send: (body: ApiBody<'sendFeedback'>, o?: CallOptions) =>\n run<ApiResult<'sendFeedback'>>(\n api.POST('/v1/feedback', { body, ...init(o) }),\n ),\n },\n events: {\n send: (body: ApiBody<'sendEvents'>, o?: CallOptions) =>\n run<ApiResult<'sendEvents'>>(\n api.POST('/v1/events', { body, ...init(o) }),\n ),\n },\n knowledge: {\n sendDocument: (body: ApiBody<'sendKnowledgeDocument'>, o?: CallOptions) =>\n run<ApiResult<'sendKnowledgeDocument'>>(\n api.POST('/v1/knowledge/documents', { body, ...init(o) }),\n ),\n },\n catalog: {\n put: (\n type: Op['putCatalogEntity']['parameters']['path']['type'],\n id: string,\n body: ApiBody<'putCatalogEntity'>,\n o?: CallOptions,\n ) =>\n run<ApiResult<'putCatalogEntity'>>(\n api.PUT('/v1/catalog/{type}/{id}', {\n params: { path: { type, id } },\n body,\n ...init(o),\n }),\n ),\n },\n usage: {\n get: (query: QueryOf<'getUsage'> = {}, o?: CallOptions) =>\n run<ApiResult<'getUsage'>>(\n api.GET('/v1/usage', { params: { query }, ...init(o) }),\n ),\n },\n };\n}\n\nexport type ApiClient = ReturnType<typeof createApiClient>;\n\n/**\n * Throws in a browser (a `window` with a `document`) and in React Native: a service key there ships to everyone who\n * loads the app. Node, AWS Lambda, Deno, Bun and edge runtimes have neither.\n */\nfunction refuseClientRuntime(): void {\n const scope = globalThis as {\n window?: unknown;\n document?: unknown;\n navigator?: { product?: unknown };\n };\n if (scope.window !== undefined && scope.document !== undefined) {\n throw new ServiceKeyExposureError(\n 'The Vinaverse API client holds a service key and runs on your backend only, never in a browser. Give the app a session client secret (sessions.create).',\n );\n }\n if (scope.navigator?.product === 'ReactNative') {\n throw new ServiceKeyExposureError(\n 'The Vinaverse API client holds a service key and runs on your backend only, never in an app. Use @vinaverse/client with a session client secret.',\n );\n }\n}\n\nconst LOOPBACK = new Set(['localhost', '127.0.0.1', '[::1]']);\n\n/** The base URL, checked: `https:`, or `http:` on this machine only, so a service key never travels in clear. */\nfunction safeBaseUrl(value: string): string {\n let url: URL;\n try {\n url = new URL(value);\n } catch {\n throw new TypeError(`baseUrl is not a URL: ${value}`);\n }\n if (\n url.protocol !== 'https:' &&\n !(url.protocol === 'http:' && LOOPBACK.has(url.hostname))\n ) {\n throw new TypeError(\n `baseUrl must be https: (or http: on localhost); a service key never travels in clear: ${url.origin}`,\n );\n }\n return value.replace(/\\/+$/, '');\n}\n\n/** A check for every request: the client's own origin, and so never in clear nor to another host. */\nfunction sameOrigin(baseUrl: string): (url: string) => void {\n const origin = new URL(baseUrl).origin;\n return (url) => {\n const target = new URL(url);\n if (target.origin !== origin) {\n throw new TypeError(\n `The Vinaverse API client sends its service key to ${origin} only, not to ${target.origin}`,\n );\n }\n };\n}\n\nfunction newKey(): Promise<string> {\n return randomUUID();\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/api/errors.ts","../src/api/random.ts","../src/api/retry.ts","../src/api/client.ts"],"names":["createClient","key"],"mappings":";;;;;;;;;;;AAQO,IAAM,iBAAA,GAAN,cAAgC,KAAA,CAAM;AAAA,EACzB,IAAA,GAAO,mBAAA;AAAA,EAChB,MAAA;AAAA;AAAA,EAEA,IAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,UAAA;AAAA;AAAA,EAEA,MA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AACjC,EAAA,OAAO,UAAA,EAAW;AACpB","file":"api.cjs","sourcesContent":["// What the Vinaverse API answers when it refuses a call: RFC 9457 problem details (vinaverse-v1.yaml, `Problem`),\n// as a typed error. conformance/README.md §5 lists every code with its status and whether it is retryable.\nimport type { components } from '../generated/vinaverse-v1.js';\n\nexport type ApiProblem = components['schemas']['Problem'];\nexport type ApiProblemCode = ApiProblem['code'];\n\n/** The API refused a call: its problem details, typed, with the request id to quote to support. */\nexport class VinaverseApiError extends Error {\n override readonly name = 'VinaverseApiError';\n readonly status: number;\n /** The problem's code (`invalid_request`, `rate_limited`, …), or `http_<status>` when the body was not a problem. */\n readonly code: ApiProblemCode | `http_${number}`;\n /** Whether the same call may succeed later: the problem's `retryable`, else true for 429 and 5xx. */\n readonly retryable: boolean;\n /** `Vinaverse-Request-Id`, or the problem's `request_id`. */\n readonly requestId: string | undefined;\n /** `Retry-After`, in seconds, when the API sent one. */\n readonly retryAfter: number | undefined;\n /** For `invalid_request`: the fields refused, as JSON Pointers into the request. */\n readonly errors: readonly { pointer: string; message: string }[];\n /** The problem as sent, or undefined when the body was not one. */\n readonly problem: ApiProblem | undefined;\n /** The `Idempotency-Key` the call carried: send the same call again with it to have it done once. */\n readonly idempotencyKey: string | undefined;\n\n constructor(init: {\n status: number;\n problem?: ApiProblem | undefined;\n requestId?: string | undefined;\n retryAfter?: number | undefined;\n idempotencyKey?: string | undefined;\n }) {\n const { status, problem } = init;\n super(\n problem\n ? `${problem.title} (${problem.code})${problem.detail ? `: ${problem.detail}` : ''}`\n : `The Vinaverse API answered HTTP ${status}.`,\n );\n this.idempotencyKey = init.idempotencyKey;\n this.status = status;\n this.problem = problem;\n this.code = problem?.code ?? `http_${status}`;\n this.retryable = problem?.retryable ?? (status === 429 || status >= 500);\n this.requestId = init.requestId ?? problem?.request_id;\n this.retryAfter = init.retryAfter;\n this.errors = problem?.errors ?? [];\n }\n}\n\n/** The error for a refused response and its parsed body: what every call of the API client throws. */\nexport function apiError(\n response: Response,\n body: unknown,\n idempotencyKey?: string,\n): VinaverseApiError {\n return new VinaverseApiError({\n status: response.status,\n problem: isProblem(body) ? body : undefined,\n requestId: response.headers.get('vinaverse-request-id') ?? undefined,\n retryAfter: retryAfterSeconds(response),\n idempotencyKey,\n });\n}\n\n/** `Retry-After` in seconds: a number of seconds or an HTTP date; undefined when absent or unreadable. */\nexport function retryAfterSeconds(\n response: Response,\n now: () => number = Date.now,\n): number | undefined {\n const value = response.headers.get('retry-after');\n if (value === null || value.trim() === '') return undefined;\n if (/^\\d+$/.test(value.trim())) return Number(value.trim());\n const at = Date.parse(value);\n return Number.isNaN(at)\n ? undefined\n : Math.max(0, Math.ceil((at - now()) / 1000));\n}\n\nfunction isProblem(body: unknown): body is ApiProblem {\n if (typeof body !== 'object' || body === null) return false;\n const b = body as Record<string, unknown>;\n return typeof b.code === 'string' && typeof b.status === 'number';\n}\n","// A random UUID for idempotency keys wherever the client runs. Node 20+, Deno, Bun and edge runtimes have\n// `crypto.randomUUID`; Node 18 has it only in its crypto module when loaded as an ES module, so it is loaded from\n// there, once.\nlet fromNode: Promise<() => string> | undefined;\n\nexport async function randomUUID(): Promise<string> {\n const global = (globalThis as { crypto?: { randomUUID?: () => string } })\n .crypto;\n if (global?.randomUUID) return global.randomUUID();\n // Built at run time on purpose: a bundler for an edge runtime, where this line never runs, must not resolve it.\n const specifier = ['node', 'crypto'].join(':');\n fromNode ??= import(\n /* webpackIgnore: true */ /* @vite-ignore */ specifier\n ).then((mod: { randomUUID: () => string }) => mod.randomUUID);\n return (await fromNode)();\n}\n","// Safe retries for calls to the Vinaverse API. A call is sent again only when that cannot do it twice:\n// - `429`: the API refused it before doing anything, so any call is retried, after its `Retry-After`;\n// - a retryable failure (a `5xx`, a problem with `retryable: true`, a timeout or a network error): only a read\n// (`GET`, `HEAD`, `OPTIONS`), an idempotent `PUT` or `DELETE`, or a call carrying an `Idempotency-Key`, which the\n// API answers once whatever the number of tries.\n// Delays: `Retry-After` when the API sends one, else 0.5 s doubling, with jitter; a `Retry-After` longer than\n// `maxRetryDelay` is not waited for: the refusal is returned.\n// Each try reads the whole response within its timeout, so a stalled body cannot hang a call, and the caller's\n// signal stops everything at once: a try in flight, a body being read, a wait between tries. An aborted signal never\n// sends the call. Redirects are refused: a service key never follows one.\n\nimport { retryAfterSeconds } from './errors.js';\n\nexport type FetchFn = (input: Request) => Promise<Response>;\n\nexport interface RetryOptions {\n /** Retries after the first try: a whole number, 0 or more; default 2. */\n readonly maxRetries?: number;\n /** The longest wait, in seconds, before a retry: 0 to 2 147 483 (a timer's limit); default 30. */\n readonly maxRetryDelay?: number;\n /** One try's timeout, reading the body included, in milliseconds: more than 0, at most 2 147 483 647; default 30 000. */\n readonly timeout?: number;\n /** Waits, in milliseconds; tests replace it. The wait ends early when the call is aborted. */\n readonly sleep?: (ms: number) => Promise<void>;\n readonly random?: () => number;\n}\n\nconst IDEMPOTENT = new Set(['GET', 'HEAD', 'PUT', 'DELETE', 'OPTIONS']);\n/** Statuses whose responses have no body. */\nconst NULL_BODY = new Set([101, 204, 205, 304]);\n/** A refusal's body is read up to this size: a problem is far smaller; more is an intermediary's page. */\nconst MAX_REFUSAL_BYTES = 64 * 1024;\n\n/**\n * The API did not answer within `timeout` on the last try. `idempotencyKey` is the key the call carried: pass it as\n * `{ idempotencyKey }` to try the same call again later without doing it twice.\n */\nexport class VinaverseTimeoutError extends Error {\n override readonly name = 'VinaverseTimeoutError';\n readonly idempotencyKey: string | undefined;\n constructor(ms: number, idempotencyKey?: string) {\n super(`The Vinaverse API did not answer within ${ms} ms.`);\n this.idempotencyKey = idempotencyKey;\n }\n}\n\n/** The call could not reach the API (`cause` holds why). `idempotencyKey` as for a timeout. */\nexport class VinaverseNetworkError extends Error {\n override readonly name = 'VinaverseNetworkError';\n readonly idempotencyKey: string | undefined;\n constructor(cause: unknown, idempotencyKey?: string) {\n super(\n `The Vinaverse API could not be reached: ${cause instanceof Error ? cause.message : String(cause)}`,\n { cause },\n );\n this.idempotencyKey = idempotencyKey;\n }\n}\n\n/** The longest a timer can wait: beyond it, Node fires it after 1 ms. */\nconst MAX_TIMER_MS = 2_147_483_647;\n\n/**\n * `guard` checks each request's URL before anything is sent (the client allows its own origin only); what it throws\n * is thrown as is.\n */\nexport function retryingFetch(\n fetchFn: FetchFn,\n options: RetryOptions = {},\n guard: (url: string) => void = () => {},\n): FetchFn {\n const maxRetries = check(\n 'maxRetries',\n options.maxRetries ?? 2,\n (n) => Number.isSafeInteger(n) && n >= 0,\n );\n const maxDelay =\n check(\n 'maxRetryDelay',\n options.maxRetryDelay ?? 30,\n (n) => Number.isFinite(n) && n >= 0 && n * 1000 <= MAX_TIMER_MS,\n ) * 1000;\n const timeout = check(\n 'timeout',\n options.timeout ?? 30_000,\n (n) => Number.isFinite(n) && n > 0 && n <= MAX_TIMER_MS,\n );\n const sleep = options.sleep;\n const random = options.random ?? Math.random;\n\n return async (request) => {\n guard(request.url);\n const signal = request.signal;\n const key = request.headers.get('idempotency-key') ?? undefined;\n const replayable =\n IDEMPOTENT.has(request.method.toUpperCase()) || key !== undefined;\n for (let attempt = 0; ; attempt++) {\n if (signal.aborted) throw aborted(signal);\n const last = attempt >= maxRetries;\n let response: Response;\n try {\n response = await once(fetchFn, request.clone(), signal, timeout);\n } catch (error) {\n if (signal.aborted) throw aborted(signal);\n // A network error or a timeout: the call may have been done; only a replayable one goes again.\n if (last || !replayable) {\n throw error instanceof VinaverseTimeoutError\n ? new VinaverseTimeoutError(timeout, key)\n : new VinaverseNetworkError(error, key);\n }\n await wait(sleep, Math.min(backoff(attempt, random), maxDelay), signal);\n continue;\n }\n const retry =\n response.status === 429 ||\n (replayable && retryable(response, await problemOf(response)));\n if (!retry || last) return response;\n const delay = retryAfter(response) ?? backoff(attempt, random);\n if (delay > maxDelay) return response;\n await wait(sleep, delay, signal);\n }\n };\n}\n\n/** One try, its body read in full within the timeout; refused bodies up to `MAX_REFUSAL_BYTES`. */\nasync function once(\n fetchFn: FetchFn,\n request: Request,\n signal: AbortSignal,\n timeout: number,\n): Promise<Response> {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeout);\n const stop = () => controller.abort();\n signal.addEventListener('abort', stop, { once: true });\n if (signal.aborted) controller.abort();\n try {\n // Raced against the timeout and the caller's signal too, so a transport that ignores its signal is still bounded.\n const pending = fetchFn(\n new Request(request, { signal: controller.signal, redirect: 'error' }),\n );\n pending.catch(() => {}); // when the abort wins, the transport's own failure is not reported twice\n const response = await until(pending, controller.signal);\n const empty = NULL_BODY.has(response.status);\n const body = empty\n ? null\n : await readBody(\n response,\n response.ok ? Number.POSITIVE_INFINITY : MAX_REFUSAL_BYTES,\n controller.signal,\n );\n return new Response(body, {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n } catch (error) {\n if (controller.signal.aborted && !signal.aborted)\n throw new VinaverseTimeoutError(timeout);\n throw error;\n } finally {\n clearTimeout(timer);\n signal.removeEventListener('abort', stop);\n }\n}\n\nasync function readBody(\n response: Response,\n limit: number,\n signal: AbortSignal,\n): Promise<Uint8Array<ArrayBuffer> | null> {\n if (!response.body) return null;\n const reader = response.body.getReader();\n const chunks: Uint8Array[] = [];\n let size = 0;\n for (;;) {\n const read = reader.read();\n read.catch(() => {}); // an abort below wins; the read's own failure is not reported twice\n const { done, value } = await until(read, signal).catch(\n async (error: unknown) => {\n void reader.cancel().catch(() => {}); // not awaited: a teed body settles its cancel only with its twin\n throw error;\n },\n );\n if (done) break;\n chunks.push(value);\n size += value.length;\n if (size >= limit) {\n void reader.cancel().catch(() => {}); // not awaited: a teed body settles its cancel only with its twin\n break;\n }\n }\n const body = new Uint8Array(new ArrayBuffer(Math.min(size, limit)));\n let at = 0;\n for (const chunk of chunks) {\n const part = chunk.subarray(0, body.length - at);\n body.set(part, at);\n at += part.length;\n if (at >= body.length) break;\n }\n return body;\n}\n\nasync function problemOf(\n response: Response,\n): Promise<{ retryable?: unknown } | undefined> {\n if (response.ok) return undefined;\n try {\n return (await response.clone().json()) as { retryable?: unknown };\n } catch {\n return undefined;\n }\n}\n\nfunction retryable(\n response: Response,\n problem: { retryable?: unknown } | undefined,\n): boolean {\n if (response.status >= 500) return true;\n // Another refusal is retried only when the API says so.\n return response.status >= 400 && problem?.retryable === true;\n}\n\n/** `promise`, or the signal's abort, whichever comes first. */\nasync function until<T>(promise: Promise<T>, signal: AbortSignal): Promise<T> {\n if (signal.aborted) throw aborted(signal);\n let stop: () => void = () => {};\n const abort = new Promise<never>((_, reject) => {\n stop = () => reject(aborted(signal));\n signal.addEventListener('abort', stop, { once: true });\n });\n try {\n return await Promise.race([promise, abort]);\n } finally {\n signal.removeEventListener('abort', stop);\n }\n}\n\n/** Waits `ms`, or less: an abort ends the wait, clears its timer, and throws. */\nfunction wait(\n sleep: ((ms: number) => Promise<void>) | undefined,\n ms: number,\n signal: AbortSignal,\n): Promise<void> {\n if (sleep) return until(sleep(ms), signal);\n if (signal.aborted) return Promise.reject(aborted(signal));\n return new Promise<void>((resolve, reject) => {\n const stop = () => {\n clearTimeout(timer);\n reject(aborted(signal));\n };\n const timer = setTimeout(() => {\n signal.removeEventListener('abort', stop);\n resolve();\n }, ms);\n signal.addEventListener('abort', stop, { once: true });\n });\n}\n\nfunction aborted(signal: AbortSignal): unknown {\n return (\n signal.reason ?? new DOMException('The call was aborted.', 'AbortError')\n );\n}\n\nfunction retryAfter(response: Response): number | undefined {\n const seconds = retryAfterSeconds(response);\n return seconds === undefined ? undefined : seconds * 1000;\n}\n\nfunction backoff(attempt: number, random: () => number): number {\n const base = 500 * 2 ** attempt;\n return Math.round(base / 2 + random() * (base / 2));\n}\n\nfunction check(\n name: string,\n value: number,\n valid: (n: number) => boolean,\n): number {\n if (typeof value !== 'number' || !valid(value)) {\n throw new TypeError(`${name} is not valid: ${String(value)}`);\n }\n return value;\n}\n","// The Vinaverse API from a Node backend: typed calls generated from the pinned public contract (vinaverse-v1.yaml,\n// through openapi-fetch), authenticated with a service key, with idempotency keys added where the contract wants\n// one, safe retries honouring `Retry-After` (./retry.ts), and refusals thrown as typed errors (./errors.ts).\n// A service key never belongs in a browser or an app: the client refuses to start there.\nimport createClient, { type Client } from 'openapi-fetch';\nimport type { operations, paths } from '../generated/vinaverse-v1.js';\nimport { apiError } from './errors.js';\nimport { randomUUID } from './random.js';\nimport { type FetchFn, type RetryOptions, retryingFetch } from './retry.js';\n\ntype Op = operations;\n/** An operation's JSON request body. */\nexport type ApiBody<K extends keyof Op> = Op[K] extends {\n requestBody?: { content: { 'application/json': infer B } };\n}\n ? B\n : never;\n/** An operation's success result. */\nexport type ApiResult<K extends keyof Op> = Success<Op[K]['responses']>;\ntype Success<R> = R extends {\n 200: { content: { 'application/json': infer B } };\n}\n ? B\n : R extends { 201: { content: { 'application/json': infer B } } }\n ? B\n : R extends { 202: { content: { 'application/json': infer B } } }\n ? B\n : undefined;\ntype QueryOf<K extends keyof Op> = Op[K]['parameters'] extends {\n query?: infer Q;\n}\n ? NonNullable<Q>\n : never;\n\n/** Per call: a signal that stops it at once, waits between tries included. */\nexport interface CallOptions {\n readonly signal?: AbortSignal;\n}\n\n/**\n * For the calls the contract makes idempotent: a key of your own, 1 to 255 characters (one is made otherwise).\n * After a `VinaverseTimeoutError` or a `VinaverseNetworkError`, try again later with the error's `idempotencyKey`,\n * so the call is done once however many times it is sent.\n */\nexport interface KeyedCallOptions extends CallOptions {\n readonly idempotencyKey?: string;\n}\n\nexport interface ApiClientOptions extends RetryOptions {\n /** A service key, `vv_sk_<mock|dev|live>_…`: from your secrets store, never from code. */\n readonly apiKey: string;\n /**\n * Default: `https://api.vinaverse.com` for a live key, `https://api-dev.vinaverse.com` for mock and dev keys. Any\n * other URL must be `https:` (a proxy you run, say), or `http:` on this machine only (`localhost`, `127.0.0.1`,\n * `[::1]`): a service key never travels in clear.\n */\n readonly baseUrl?: string;\n readonly fetch?: (request: Request) => Promise<Response>;\n /** Extra headers on every call, for example `Vinaverse-Mock-Scenario` in tests against the mock environment. */\n readonly headers?: Readonly<Record<string, string>>;\n}\n\nconst SERVICE_KEY = /^vv_sk_(mock|dev|live)_[A-Za-z0-9_-]{8,}$/;\n\n/** The client was made where a service key must never be: a browser or an app. */\nexport class ServiceKeyExposureError extends Error {\n override readonly name = 'ServiceKeyExposureError';\n}\n\nexport function createApiClient(options: ApiClientOptions) {\n refuseClientRuntime();\n const key = options.apiKey;\n if (typeof key !== 'string' || !SERVICE_KEY.test(key)) {\n throw new TypeError(\n key?.startsWith?.('vv_cs_')\n ? 'createApiClient takes a service key (vv_sk_…); a client secret (vv_cs_…) is for the app'\n : 'createApiClient needs a service key: vv_sk_<mock|dev|live>_…',\n );\n }\n const live = key.startsWith('vv_sk_live_');\n const baseUrl = safeBaseUrl(\n options.baseUrl ??\n (live ? 'https://api.vinaverse.com' : 'https://api-dev.vinaverse.com'),\n );\n const transport: FetchFn =\n options.fetch ?? ((request) => globalThis.fetch(request));\n const api: Client<paths> = createClient<paths>({\n baseUrl,\n redirect: 'error', // the API never redirects; a service key never follows one\n // Every request, from a helper or from `api` with a per-call baseUrl, goes to this origin only.\n fetch: retryingFetch(transport, options, sameOrigin(baseUrl)),\n headers: {\n ...options.headers,\n authorization: `Bearer ${key}`,\n accept: 'application/json',\n },\n });\n\n type Answer = Promise<{\n data?: unknown;\n error?: unknown;\n response: Response;\n }>;\n async function run<T>(call: Answer, idempotencyKey?: string): Promise<T> {\n const { data, error, response } = await call;\n if (!response.ok) throw apiError(response, error, idempotencyKey);\n return data as T;\n }\n /** A call the contract makes idempotent: under the caller's key, or a new one, on every try. */\n async function keyed<T>(\n o: KeyedCallOptions | undefined,\n call: (header: { 'Idempotency-Key': string }) => Answer,\n ): Promise<T> {\n const key = o?.idempotencyKey ?? (await newKey());\n if (typeof key !== 'string' || key.length < 1 || key.length > 255) {\n throw new TypeError('idempotencyKey must be 1 to 255 characters');\n }\n return run<T>(call({ 'Idempotency-Key': key }), key);\n }\n const init = (o?: CallOptions) => (o?.signal ? { signal: o.signal } : {});\n\n return {\n /** Every operation of the contract, typed, for what the helpers below do not cover (openapi-fetch). */\n api,\n sessions: {\n /** Mint a session for the person in your app; give the app its `id`, URLs and `client_secret` only. */\n create: (body: ApiBody<'createSession'>, o?: KeyedCallOptions) =>\n keyed<ApiResult<'createSession'>>(o, (header) =>\n api.POST('/v1/sessions', {\n body,\n params: { header },\n ...init(o),\n }),\n ),\n get: (sessionId: string, o?: CallOptions) =>\n run<ApiResult<'getSession'>>(\n api.GET('/v1/sessions/{session_id}', {\n params: { path: { session_id: sessionId } },\n ...init(o),\n }),\n ),\n revoke: (sessionId: string, o?: CallOptions) =>\n run<ApiResult<'revokeSession'>>(\n api.POST('/v1/sessions/{session_id}/revoke', {\n params: { path: { session_id: sessionId } },\n ...init(o),\n }),\n ),\n /**\n * Where the person is now, for an open session (no new session per screen): a screen context, or\n * `{ clear: true, revision }`; `revision` greater than the session's, the same revision and body a retry.\n */\n updateContext: (\n sessionId: string,\n body: ApiBody<'updateSessionContext'>,\n o?: CallOptions,\n ) =>\n run<ApiResult<'updateSessionContext'>>(\n api.PUT('/v1/sessions/{session_id}/context', {\n params: { path: { session_id: sessionId } },\n body,\n ...init(o),\n }),\n ),\n /** A fresh client secret for an open session: what an app's `refreshSecret(sessionId)` asks your backend for. */\n refreshClientSecret: (sessionId: string, o?: CallOptions) =>\n run<ApiResult<'refreshClientSecret'>>(\n api.POST('/v1/sessions/{session_id}/client_secret', {\n params: { path: { session_id: sessionId } },\n ...init(o),\n }),\n ),\n },\n conversations: {\n get: (conversationId: string, o?: CallOptions) =>\n run<ApiResult<'getConversation'>>(\n api.GET('/v1/conversations/{conversation_id}', {\n params: { path: { conversation_id: conversationId } },\n ...init(o),\n }),\n ),\n /** A person's past conversations with an agent, newest activity first (history). */\n list: (query: QueryOf<'listConversations'>, o?: CallOptions) =>\n run<ApiResult<'listConversations'>>(\n api.GET('/v1/conversations', { params: { query }, ...init(o) }),\n ),\n /** A past conversation's messages, the newest page first and oldest first within a page. */\n listMessages: (\n conversationId: string,\n query: QueryOf<'listConversationMessages'>,\n o?: CallOptions,\n ) =>\n run<ApiResult<'listConversationMessages'>>(\n api.GET('/v1/conversations/{conversation_id}/messages', {\n params: { path: { conversation_id: conversationId }, query },\n ...init(o),\n }),\n ),\n /** Deletes a person's conversation (history's delete); another subject's or an unknown one is `not_found`. */\n delete: (\n conversationId: string,\n query: QueryOf<'deleteConversation'>,\n o?: CallOptions,\n ) =>\n run<ApiResult<'deleteConversation'>>(\n api.DELETE('/v1/conversations/{conversation_id}', {\n params: { path: { conversation_id: conversationId }, query },\n ...init(o),\n }),\n ),\n },\n suggestions: {\n create: (body: ApiBody<'createSuggestions'>, o?: CallOptions) =>\n run<ApiResult<'createSuggestions'>>(\n api.POST('/v1/suggestions', { body, ...init(o) }),\n ),\n },\n moderation: {\n createJob: (body: ApiBody<'createModerationJob'>, o?: KeyedCallOptions) =>\n keyed<ApiResult<'createModerationJob'>>(o, (header) =>\n api.POST('/v1/moderation/jobs', {\n body,\n params: { header },\n ...init(o),\n }),\n ),\n getJob: (jobId: string, o?: CallOptions) =>\n run<ApiResult<'getModerationJob'>>(\n api.GET('/v1/moderation/jobs/{job_id}', {\n params: { path: { job_id: jobId } },\n ...init(o),\n }),\n ),\n getItem: (itemId: string, o?: CallOptions) =>\n run<ApiResult<'getModerationItem'>>(\n api.GET('/v1/moderation/items/{item_id}', {\n params: { path: { item_id: itemId } },\n ...init(o),\n }),\n ),\n },\n media: {\n createJob: (body: ApiBody<'createMediaJob'>, o?: KeyedCallOptions) =>\n keyed<ApiResult<'createMediaJob'>>(o, (header) =>\n api.POST('/v1/media/jobs', {\n body,\n params: { header },\n ...init(o),\n }),\n ),\n listJobs: (query: QueryOf<'listMediaJobs'> = {}, o?: CallOptions) =>\n run<ApiResult<'listMediaJobs'>>(\n api.GET('/v1/media/jobs', { params: { query }, ...init(o) }),\n ),\n getJob: (jobId: string, o?: CallOptions) =>\n run<ApiResult<'getMediaJob'>>(\n api.GET('/v1/media/jobs/{job_id}', {\n params: { path: { job_id: jobId } },\n ...init(o),\n }),\n ),\n cancelJob: (jobId: string, o?: CallOptions) =>\n run<ApiResult<'cancelMediaJob'>>(\n api.POST('/v1/media/jobs/{job_id}/cancel', {\n params: { path: { job_id: jobId } },\n ...init(o),\n }),\n ),\n listProfiles: (o?: CallOptions) =>\n run<ApiResult<'listMediaProfiles'>>(\n api.GET('/v1/media/profiles', { ...init(o) }),\n ),\n },\n screening: {\n text: (body: ApiBody<'screenText'>, o?: CallOptions) =>\n run<ApiResult<'screenText'>>(\n api.POST('/v1/screening/text', { body, ...init(o) }),\n ),\n },\n documentChecks: {\n create: (body: ApiBody<'createDocumentCheck'>, o?: KeyedCallOptions) =>\n keyed<ApiResult<'createDocumentCheck'>>(o, (header) =>\n api.POST('/v1/document-checks', {\n body,\n params: { header },\n ...init(o),\n }),\n ),\n get: (checkId: string, o?: CallOptions) =>\n run<ApiResult<'getDocumentCheck'>>(\n api.GET('/v1/document-checks/{check_id}', {\n params: { path: { check_id: checkId } },\n ...init(o),\n }),\n ),\n },\n subjects: {\n erase: (subjectId: string, o?: KeyedCallOptions) =>\n keyed<ApiResult<'eraseSubject'>>(o, (header) =>\n api.POST('/v1/subjects/{subject_id}/erase', {\n params: { path: { subject_id: subjectId }, header },\n ...init(o),\n }),\n ),\n /** What the agent remembers of the person, and their choice, on one side of the app (memory settings). */\n getMemory: (\n subjectId: string,\n query: QueryOf<'getSubjectMemory'> = {},\n o?: CallOptions,\n ) =>\n run<ApiResult<'getSubjectMemory'>>(\n api.GET('/v1/subjects/{subject_id}/memory', {\n params: { path: { subject_id: subjectId }, query },\n ...init(o),\n }),\n ),\n /** The person's choice: whether the agent may remember them. */\n putMemory: (\n subjectId: string,\n body: ApiBody<'putSubjectMemory'>,\n o?: CallOptions,\n ) =>\n run<ApiResult<'putSubjectMemory'>>(\n api.PUT('/v1/subjects/{subject_id}/memory', {\n params: { path: { subject_id: subjectId } },\n body,\n ...init(o),\n }),\n ),\n /** The person saw the memory notice of this version. */\n acknowledgeMemoryNotice: (\n subjectId: string,\n body: ApiBody<'acknowledgeMemoryNotice'>,\n o?: CallOptions,\n ) =>\n run<ApiResult<'acknowledgeMemoryNotice'>>(\n api.POST('/v1/subjects/{subject_id}/memory/notice', {\n params: { path: { subject_id: subjectId } },\n body,\n ...init(o),\n }),\n ),\n /** Forgets one thing the agent learned about the person. */\n deleteMemoryPreference: (\n subjectId: string,\n preferenceId: string,\n o?: CallOptions,\n ) =>\n run<ApiResult<'deleteMemoryPreference'>>(\n api.DELETE(\n '/v1/subjects/{subject_id}/memory/preferences/{preference_id}',\n {\n params: {\n path: { subject_id: subjectId, preference_id: preferenceId },\n },\n ...init(o),\n },\n ),\n ),\n },\n agents: {\n /** The tenant's chat experience for an agent, resolved, before any session: copy it into the agent status. */\n getExperience: (\n agent: string,\n query: QueryOf<'getAgentExperience'> = {},\n o?: CallOptions,\n ) =>\n run<ApiResult<'getAgentExperience'>>(\n api.GET('/v1/agents/{agent}/experience', {\n params: { path: { agent }, query },\n ...init(o),\n }),\n ),\n },\n feedback: {\n send: (body: ApiBody<'sendFeedback'>, o?: CallOptions) =>\n run<ApiResult<'sendFeedback'>>(\n api.POST('/v1/feedback', { body, ...init(o) }),\n ),\n },\n events: {\n send: (body: ApiBody<'sendEvents'>, o?: CallOptions) =>\n run<ApiResult<'sendEvents'>>(\n api.POST('/v1/events', { body, ...init(o) }),\n ),\n },\n knowledge: {\n sendDocument: (body: ApiBody<'sendKnowledgeDocument'>, o?: CallOptions) =>\n run<ApiResult<'sendKnowledgeDocument'>>(\n api.POST('/v1/knowledge/documents', { body, ...init(o) }),\n ),\n },\n catalog: {\n put: (\n type: Op['putCatalogEntity']['parameters']['path']['type'],\n id: string,\n body: ApiBody<'putCatalogEntity'>,\n o?: CallOptions,\n ) =>\n run<ApiResult<'putCatalogEntity'>>(\n api.PUT('/v1/catalog/{type}/{id}', {\n params: { path: { type, id } },\n body,\n ...init(o),\n }),\n ),\n },\n usage: {\n get: (query: QueryOf<'getUsage'> = {}, o?: CallOptions) =>\n run<ApiResult<'getUsage'>>(\n api.GET('/v1/usage', { params: { query }, ...init(o) }),\n ),\n },\n };\n}\n\nexport type ApiClient = ReturnType<typeof createApiClient>;\n\n/**\n * Throws in a browser (a `window` with a `document`) and in React Native: a service key there ships to everyone who\n * loads the app. Node, AWS Lambda, Deno, Bun and edge runtimes have neither.\n */\nfunction refuseClientRuntime(): void {\n const scope = globalThis as {\n window?: unknown;\n document?: unknown;\n navigator?: { product?: unknown };\n };\n if (scope.window !== undefined && scope.document !== undefined) {\n throw new ServiceKeyExposureError(\n 'The Vinaverse API client holds a service key and runs on your backend only, never in a browser. Give the app a session client secret (sessions.create).',\n );\n }\n if (scope.navigator?.product === 'ReactNative') {\n throw new ServiceKeyExposureError(\n 'The Vinaverse API client holds a service key and runs on your backend only, never in an app. Use @vinaverse/client with a session client secret.',\n );\n }\n}\n\nconst LOOPBACK = new Set(['localhost', '127.0.0.1', '[::1]']);\n\n/** The base URL, checked: `https:`, or `http:` on this machine only, so a service key never travels in clear. */\nfunction safeBaseUrl(value: string): string {\n let url: URL;\n try {\n url = new URL(value);\n } catch {\n throw new TypeError(`baseUrl is not a URL: ${value}`);\n }\n if (\n url.protocol !== 'https:' &&\n !(url.protocol === 'http:' && LOOPBACK.has(url.hostname))\n ) {\n throw new TypeError(\n `baseUrl must be https: (or http: on localhost); a service key never travels in clear: ${url.origin}`,\n );\n }\n return value.replace(/\\/+$/, '');\n}\n\n/** A check for every request: the client's own origin, and so never in clear nor to another host. */\nfunction sameOrigin(baseUrl: string): (url: string) => void {\n const origin = new URL(baseUrl).origin;\n return (url) => {\n const target = new URL(url);\n if (target.origin !== origin) {\n throw new TypeError(\n `The Vinaverse API client sends its service key to ${origin} only, not to ${target.origin}`,\n );\n }\n };\n}\n\nfunction newKey(): Promise<string> {\n return randomUUID();\n}\n"]}
|
package/dist/api.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as operations, p as paths, c as components } from './vinaverse-v1.d-
|
|
1
|
+
import { o as operations, p as paths, c as components } from './vinaverse-v1.d-D-NPpZqW.cjs';
|
|
2
2
|
import { Client } from 'openapi-fetch';
|
|
3
3
|
|
|
4
4
|
interface RetryOptions {
|
|
@@ -114,6 +114,9 @@ declare function createApiClient(options: ApiClientOptions): {
|
|
|
114
114
|
business_scope_id?: components["schemas"]["BusinessScopeId"];
|
|
115
115
|
screen_context?: components["schemas"]["ScreenContext"];
|
|
116
116
|
welcome?: components["schemas"]["Welcome"];
|
|
117
|
+
memory?: components["schemas"]["SessionMemory"];
|
|
118
|
+
anchor?: components["schemas"]["SessionAnchorView"];
|
|
119
|
+
experience?: components["schemas"]["ChatExperience"];
|
|
117
120
|
}>;
|
|
118
121
|
get: (sessionId: string, o?: CallOptions) => Promise<{
|
|
119
122
|
id: string;
|
|
@@ -182,6 +185,7 @@ declare function createApiClient(options: ApiClientOptions): {
|
|
|
182
185
|
}>;
|
|
183
186
|
/** A past conversation's messages, the newest page first and oldest first within a page. */
|
|
184
187
|
listMessages: (conversationId: string, query: QueryOf<"listConversationMessages">, o?: CallOptions) => Promise<{
|
|
188
|
+
conversation: components["schemas"]["ConversationSummary"];
|
|
185
189
|
data: components["schemas"]["TimelineItem"][];
|
|
186
190
|
next_cursor: string | null;
|
|
187
191
|
}>;
|
|
@@ -375,7 +379,8 @@ declare function createApiClient(options: ApiClientOptions): {
|
|
|
375
379
|
flags?: components["schemas"]["DocumentFlag"][];
|
|
376
380
|
decision?: components["schemas"]["Decision"];
|
|
377
381
|
model?: {
|
|
378
|
-
id?:
|
|
382
|
+
id?: components["schemas"]["ModelName"];
|
|
383
|
+
label?: string;
|
|
379
384
|
provider?: string;
|
|
380
385
|
};
|
|
381
386
|
error?: components["schemas"]["Problem"];
|
|
@@ -391,6 +396,30 @@ declare function createApiClient(options: ApiClientOptions): {
|
|
|
391
396
|
sessions_revoked: number;
|
|
392
397
|
deadline: string;
|
|
393
398
|
}>;
|
|
399
|
+
/** What the agent remembers of the person, and their choice, on one side of the app (memory settings). */
|
|
400
|
+
getMemory: (subjectId: string, query?: QueryOf<"getSubjectMemory">, o?: CallOptions) => Promise<{
|
|
401
|
+
remembered: boolean;
|
|
402
|
+
notice_acknowledged?: components["schemas"]["MemoryNoticeVersion"];
|
|
403
|
+
preferences: components["schemas"]["MemoryPreference"][];
|
|
404
|
+
last_search?: components["schemas"]["LastSearch"];
|
|
405
|
+
}>;
|
|
406
|
+
/** The person's choice: whether the agent may remember them. */
|
|
407
|
+
putMemory: (subjectId: string, body: ApiBody<"putSubjectMemory">, o?: CallOptions) => Promise<{
|
|
408
|
+
remembered: boolean;
|
|
409
|
+
}>;
|
|
410
|
+
/** The person saw the memory notice of this version. */
|
|
411
|
+
acknowledgeMemoryNotice: (subjectId: string, body: ApiBody<"acknowledgeMemoryNotice">, o?: CallOptions) => Promise<undefined>;
|
|
412
|
+
/** Forgets one thing the agent learned about the person. */
|
|
413
|
+
deleteMemoryPreference: (subjectId: string, preferenceId: string, o?: CallOptions) => Promise<undefined>;
|
|
414
|
+
};
|
|
415
|
+
agents: {
|
|
416
|
+
/** The tenant's chat experience for an agent, resolved, before any session: copy it into the agent status. */
|
|
417
|
+
getExperience: (agent: string, query?: QueryOf<"getAgentExperience">, o?: CallOptions) => Promise<{
|
|
418
|
+
agent: string;
|
|
419
|
+
experience_mode: components["schemas"]["ExperienceMode"];
|
|
420
|
+
experience: components["schemas"]["ChatExperience"];
|
|
421
|
+
updated_at?: string;
|
|
422
|
+
}>;
|
|
394
423
|
};
|
|
395
424
|
feedback: {
|
|
396
425
|
send: (body: ApiBody<"sendFeedback">, o?: CallOptions) => Promise<{
|
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as operations, p as paths, c as components } from './vinaverse-v1.d-
|
|
1
|
+
import { o as operations, p as paths, c as components } from './vinaverse-v1.d-D-NPpZqW.js';
|
|
2
2
|
import { Client } from 'openapi-fetch';
|
|
3
3
|
|
|
4
4
|
interface RetryOptions {
|
|
@@ -114,6 +114,9 @@ declare function createApiClient(options: ApiClientOptions): {
|
|
|
114
114
|
business_scope_id?: components["schemas"]["BusinessScopeId"];
|
|
115
115
|
screen_context?: components["schemas"]["ScreenContext"];
|
|
116
116
|
welcome?: components["schemas"]["Welcome"];
|
|
117
|
+
memory?: components["schemas"]["SessionMemory"];
|
|
118
|
+
anchor?: components["schemas"]["SessionAnchorView"];
|
|
119
|
+
experience?: components["schemas"]["ChatExperience"];
|
|
117
120
|
}>;
|
|
118
121
|
get: (sessionId: string, o?: CallOptions) => Promise<{
|
|
119
122
|
id: string;
|
|
@@ -182,6 +185,7 @@ declare function createApiClient(options: ApiClientOptions): {
|
|
|
182
185
|
}>;
|
|
183
186
|
/** A past conversation's messages, the newest page first and oldest first within a page. */
|
|
184
187
|
listMessages: (conversationId: string, query: QueryOf<"listConversationMessages">, o?: CallOptions) => Promise<{
|
|
188
|
+
conversation: components["schemas"]["ConversationSummary"];
|
|
185
189
|
data: components["schemas"]["TimelineItem"][];
|
|
186
190
|
next_cursor: string | null;
|
|
187
191
|
}>;
|
|
@@ -375,7 +379,8 @@ declare function createApiClient(options: ApiClientOptions): {
|
|
|
375
379
|
flags?: components["schemas"]["DocumentFlag"][];
|
|
376
380
|
decision?: components["schemas"]["Decision"];
|
|
377
381
|
model?: {
|
|
378
|
-
id?:
|
|
382
|
+
id?: components["schemas"]["ModelName"];
|
|
383
|
+
label?: string;
|
|
379
384
|
provider?: string;
|
|
380
385
|
};
|
|
381
386
|
error?: components["schemas"]["Problem"];
|
|
@@ -391,6 +396,30 @@ declare function createApiClient(options: ApiClientOptions): {
|
|
|
391
396
|
sessions_revoked: number;
|
|
392
397
|
deadline: string;
|
|
393
398
|
}>;
|
|
399
|
+
/** What the agent remembers of the person, and their choice, on one side of the app (memory settings). */
|
|
400
|
+
getMemory: (subjectId: string, query?: QueryOf<"getSubjectMemory">, o?: CallOptions) => Promise<{
|
|
401
|
+
remembered: boolean;
|
|
402
|
+
notice_acknowledged?: components["schemas"]["MemoryNoticeVersion"];
|
|
403
|
+
preferences: components["schemas"]["MemoryPreference"][];
|
|
404
|
+
last_search?: components["schemas"]["LastSearch"];
|
|
405
|
+
}>;
|
|
406
|
+
/** The person's choice: whether the agent may remember them. */
|
|
407
|
+
putMemory: (subjectId: string, body: ApiBody<"putSubjectMemory">, o?: CallOptions) => Promise<{
|
|
408
|
+
remembered: boolean;
|
|
409
|
+
}>;
|
|
410
|
+
/** The person saw the memory notice of this version. */
|
|
411
|
+
acknowledgeMemoryNotice: (subjectId: string, body: ApiBody<"acknowledgeMemoryNotice">, o?: CallOptions) => Promise<undefined>;
|
|
412
|
+
/** Forgets one thing the agent learned about the person. */
|
|
413
|
+
deleteMemoryPreference: (subjectId: string, preferenceId: string, o?: CallOptions) => Promise<undefined>;
|
|
414
|
+
};
|
|
415
|
+
agents: {
|
|
416
|
+
/** The tenant's chat experience for an agent, resolved, before any session: copy it into the agent status. */
|
|
417
|
+
getExperience: (agent: string, query?: QueryOf<"getAgentExperience">, o?: CallOptions) => Promise<{
|
|
418
|
+
agent: string;
|
|
419
|
+
experience_mode: components["schemas"]["ExperienceMode"];
|
|
420
|
+
experience: components["schemas"]["ChatExperience"];
|
|
421
|
+
updated_at?: string;
|
|
422
|
+
}>;
|
|
394
423
|
};
|
|
395
424
|
feedback: {
|
|
396
425
|
send: (body: ApiBody<"sendFeedback">, o?: CallOptions) => Promise<{
|
package/dist/api.js
CHANGED
|
@@ -464,6 +464,50 @@ function createApiClient(options) {
|
|
|
464
464
|
params: { path: { subject_id: subjectId }, header },
|
|
465
465
|
...init(o)
|
|
466
466
|
})
|
|
467
|
+
),
|
|
468
|
+
/** What the agent remembers of the person, and their choice, on one side of the app (memory settings). */
|
|
469
|
+
getMemory: (subjectId, query = {}, o) => run(
|
|
470
|
+
api.GET("/v1/subjects/{subject_id}/memory", {
|
|
471
|
+
params: { path: { subject_id: subjectId }, query },
|
|
472
|
+
...init(o)
|
|
473
|
+
})
|
|
474
|
+
),
|
|
475
|
+
/** The person's choice: whether the agent may remember them. */
|
|
476
|
+
putMemory: (subjectId, body, o) => run(
|
|
477
|
+
api.PUT("/v1/subjects/{subject_id}/memory", {
|
|
478
|
+
params: { path: { subject_id: subjectId } },
|
|
479
|
+
body,
|
|
480
|
+
...init(o)
|
|
481
|
+
})
|
|
482
|
+
),
|
|
483
|
+
/** The person saw the memory notice of this version. */
|
|
484
|
+
acknowledgeMemoryNotice: (subjectId, body, o) => run(
|
|
485
|
+
api.POST("/v1/subjects/{subject_id}/memory/notice", {
|
|
486
|
+
params: { path: { subject_id: subjectId } },
|
|
487
|
+
body,
|
|
488
|
+
...init(o)
|
|
489
|
+
})
|
|
490
|
+
),
|
|
491
|
+
/** Forgets one thing the agent learned about the person. */
|
|
492
|
+
deleteMemoryPreference: (subjectId, preferenceId, o) => run(
|
|
493
|
+
api.DELETE(
|
|
494
|
+
"/v1/subjects/{subject_id}/memory/preferences/{preference_id}",
|
|
495
|
+
{
|
|
496
|
+
params: {
|
|
497
|
+
path: { subject_id: subjectId, preference_id: preferenceId }
|
|
498
|
+
},
|
|
499
|
+
...init(o)
|
|
500
|
+
}
|
|
501
|
+
)
|
|
502
|
+
)
|
|
503
|
+
},
|
|
504
|
+
agents: {
|
|
505
|
+
/** The tenant's chat experience for an agent, resolved, before any session: copy it into the agent status. */
|
|
506
|
+
getExperience: (agent, query = {}, o) => run(
|
|
507
|
+
api.GET("/v1/agents/{agent}/experience", {
|
|
508
|
+
params: { path: { agent }, query },
|
|
509
|
+
...init(o)
|
|
510
|
+
})
|
|
467
511
|
)
|
|
468
512
|
},
|
|
469
513
|
feedback: {
|