@plucky-ai/node 0.2.0 → 0.2.1
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/index.cjs +1001 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +357 -2
- package/dist/index.d.mts +407 -0
- package/dist/index.mjs +1107 -0
- package/dist/index.mjs.map +1 -0
- package/dist/package.json +3 -3
- package/package.json +31 -31
- package/dist/index.d.ts +0 -51
- package/dist/index.js +0 -135
- package/dist/index.js.map +0 -1
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["oc","z$1","z"],"sources":["../../api-contracts/dist/src-BsXbfiX4.js","../src/index.ts"],"sourcesContent":["import { oc } from \"@orpc/contract\";\nimport z$1, { z } from \"zod\";\n\n//#region src/apps.ts\nconst findApps = oc.route({\n\tmethod: \"GET\",\n\tpath: \"/apps/{id}\",\n\ttags: [\"Apps\"],\n\tsummary: \"Get an app\",\n\tdescription: \"Retrieve an app by its ID\"\n}).input(z$1.object({ id: z$1.string() })).output(z$1.object({\n\tid: z$1.string(),\n\tname: z$1.string(),\n\tcreatedAt: z$1.coerce.date()\n}));\nconst listApps = oc.route({\n\tmethod: \"GET\",\n\tpath: \"/apps\",\n\ttags: [\"Apps\"],\n\tsummary: \"List apps\",\n\tdescription: \"Retrieve all apps\"\n}).output(z$1.object({ results: z$1.array(z$1.object({\n\tid: z$1.string(),\n\tname: z$1.string(),\n\tcreatedAt: z$1.coerce.date()\n})) }));\nvar apps_default = {\n\tfind: findApps,\n\tlist: listApps\n};\n\n//#endregion\n//#region src/chats.ts\nconst ChatSchema = z$1.object({\n\tid: z$1.string(),\n\ttitle: z$1.string(),\n\tuserId: z$1.string(),\n\tcreatedAt: z$1.coerce.date()\n});\nconst createChat = oc.route({\n\tmethod: \"POST\",\n\tpath: \"/chats\",\n\ttags: [\"Chats\"],\n\tsummary: \"Create a chat\",\n\tdescription: \"Create a new chat session\"\n}).input(z$1.object({\n\ttitle: z$1.string(),\n\tuserId: z$1.string().min(1)\n})).output(ChatSchema);\nconst findChat = oc.route({\n\tmethod: \"GET\",\n\tpath: \"/chats/{id}\",\n\ttags: [\"Chats\"],\n\tsummary: \"Get a chat\",\n\tdescription: \"Retrieve a chat by its ID\"\n}).input(z$1.object({ id: z$1.string() })).output(ChatSchema);\nconst listChats = oc.route({\n\tmethod: \"GET\",\n\tpath: \"/chats\",\n\ttags: [\"Chats\"],\n\tsummary: \"List chats\",\n\tdescription: \"Retrieve all chats with pagination support\"\n}).input(z$1.object({\n\tuserId: z$1.string().min(1).optional(),\n\tlimit: z$1.coerce.number().int().min(1).max(100).default(20),\n\tcursor: z$1.string().optional()\n})).output(z$1.object({\n\tresults: z$1.array(ChatSchema),\n\tnextCursor: z$1.string().nullable(),\n\thasMore: z$1.boolean()\n}));\nvar chats_default = {\n\tcreate: createChat,\n\tfind: findChat,\n\tlist: listChats\n};\n\n//#endregion\n//#region src/headers.ts\n/**\n* Header name constants for the public API\n*/\nconst API_KEY_HEADER = \"x-api-key\";\n/**\n* Schema for the API key header\n* API keys are prefixed with 'sk_' (secret key)\n*/\nconst ApiKeyHeaderSchema = z.string().min(1, \"API key is required\");\n/**\n* Combined headers schema for all API requests\n*/\nconst ApiHeadersSchema = z.object({ [API_KEY_HEADER]: ApiKeyHeaderSchema });\n\n//#endregion\n//#region src/index.ts\nconst contract = {\n\tapps: apps_default,\n\tchats: chats_default\n};\n\n//#endregion\nexport { ApiKeyHeaderSchema as i, API_KEY_HEADER as n, ApiHeadersSchema as r, contract as t };\n//# sourceMappingURL=src-BsXbfiX4.js.map","/**\n * @plucky-ai/node - Official Node.js SDK for the Plucky API\n *\n * @example\n * ```ts\n * import Plucky from '@plucky-ai/node'\n *\n * const plucky = new Plucky({\n * apiKey: 'sk_...',\n * })\n *\n * // List all chats\n * const { results } = await plucky.chats.list()\n *\n * // Create a new chat\n * const chat = await plucky.chats.create({ title: 'New Chat' })\n * ```\n */\n\nexport {\n createApiClient,\n type ApiClient,\n type CreateApiClientOptions,\n} from '@plucky-ai/api-contracts/client'\n\nexport { API_KEY_HEADER, contract } from '@plucky-ai/api-contracts'\n\nimport {\n createApiClient,\n type ApiClient,\n type CreateApiClientOptions,\n} from '@plucky-ai/api-contracts/client'\n\nconst DEFAULT_BASE_URL = 'https://api.plucky.ai'\n\nexport interface PluckyOptions {\n /**\n * Your Plucky API key (starts with 'sk_')\n */\n apiKey: string\n /**\n * Base URL of the Plucky API\n * @default 'https://api.plucky.ai'\n */\n baseUrl?: string\n /**\n * Optional custom fetch implementation for advanced use cases\n */\n fetch?: typeof fetch\n}\n\n/**\n * Plucky API client for Node.js\n *\n * @example\n * ```ts\n * import Plucky from '@plucky-ai/node'\n *\n * const plucky = new Plucky({ apiKey: 'sk_...' })\n *\n * const chats = await plucky.chats.list()\n * ```\n */\nexport class Plucky {\n private client: ApiClient\n\n /**\n * Access to chat operations\n */\n public readonly chats: ApiClient['chats']\n\n /**\n * Access to app operations\n */\n public readonly apps: ApiClient['apps']\n\n constructor(options: PluckyOptions) {\n const { apiKey, baseUrl = DEFAULT_BASE_URL, fetch: customFetch } = options\n\n if (!apiKey) {\n throw new Error('API key is required. Get one at https://app.plucky.ai')\n }\n\n const clientOptions: CreateApiClientOptions = {\n apiKey,\n baseUrl,\n fetch: customFetch,\n }\n\n this.client = createApiClient(clientOptions)\n\n // Expose API resources\n this.chats = this.client.chats\n this.apps = this.client.apps\n }\n\n /**\n * Get the underlying API client for advanced use cases\n */\n get api(): ApiClient {\n return this.client\n }\n}\n\nexport default Plucky\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAI,eAAe;CAClB,MAvBgBA,mBAAG,MAAM;EACzB,QAAQ;EACR,MAAM;EACN,MAAM,CAAC,OAAO;EACd,SAAS;EACT,aAAa;EACb,CAAC,CAAC,MAAMC,YAAI,OAAO,EAAE,IAAIA,YAAI,QAAQ,EAAE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IAAI,EAAE,CAAC,UAAU;EACtC,OAAOA,YAAI,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI,CAAC,QAAQ,GAAG;EAC5D,QAAQA,YAAI,QAAQ,CAAC,UAAU;EAC/B,CAAC,CAAC,CAAC,OAAOA,YAAI,OAAO;EACrB,SAASA,YAAI,MAAM,WAAW;EAC9B,YAAYA,YAAI,QAAQ,CAAC,UAAU;EACnC,SAASA,YAAI,SAAS;EACtB,CAAC,CAAC;CAKF;;;;AAOD,MAAM,iBAAiB;;;;;AAKvB,MAAM,qBAAqBC,MAAE,QAAQ,CAAC,IAAI,GAAG,sBAAsB;;;;AAInE,MAAM,mBAAmBA,MAAE,OAAO,GAAG,iBAAiB,oBAAoB,CAAC;AAI3E,MAAM,WAAW;CAChB,MAAM;CACN,OAAO;CACP;;;;ACjED,MAAM,mBAAmB;;;;;;;;;;;;;AA8BzB,IAAa,SAAb,MAAoB;CAClB,AAAQ;;;;CAKR,AAAgB;;;;CAKhB,AAAgB;CAEhB,YAAY,SAAwB;EAClC,MAAM,EAAE,QAAQ,UAAU,kBAAkB,OAAO,gBAAgB;AAEnE,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,wDAAwD;AAS1E,OAAK,+DANyC;GAC5C;GACA;GACA,OAAO;GACR,CAE2C;AAG5C,OAAK,QAAQ,KAAK,OAAO;AACzB,OAAK,OAAO,KAAK,OAAO;;;;;CAM1B,IAAI,MAAiB;AACnB,SAAO,KAAK;;;AAIhB,kBAAe"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["z","MessageSchema","#cleanup","#next","#isDone","#isExecuteComplete","ORPCError","ValidationError","oc","z$1","z"],"sources":["../../llm-schemas/dist/index.mjs","../../../node_modules/.pnpm/@orpc+shared@1.13.6_@opentelemetry+api@1.9.0/node_modules/@orpc/shared/dist/index.mjs","../../../node_modules/.pnpm/@orpc+standard-server@1.13.6_@opentelemetry+api@1.9.0/node_modules/@orpc/standard-server/dist/index.mjs","../../../node_modules/.pnpm/@orpc+server@1.13.6_@opentelemetry+api@1.9.0_crossws@0.3.5_ws@8.19.0/node_modules/@orpc/server/dist/shared/server.Ds4HPpvH.mjs","../../../node_modules/.pnpm/@orpc+server@1.13.6_@opentelemetry+api@1.9.0_crossws@0.3.5_ws@8.19.0/node_modules/@orpc/server/dist/index.mjs","../../api-contracts/dist/src-bLbxYIy4.mjs","../src/index.ts"],"sourcesContent":["import { z } from \"zod\";\n//#region src/schemas.ts\nconst TextContentBlockSchema = z.object({\n\ttype: z.literal(\"text\"),\n\ttext: z.string()\n});\nconst ToolUseContentBlockSchema = z.object({\n\ttype: z.literal(\"tool_use\"),\n\tid: z.string(),\n\tname: z.string(),\n\tinput: z.unknown(),\n\tdefaultLoadingText: z.string().nullable().optional(),\n\tdefaultSuccessText: z.string().nullable().optional(),\n\tpartial_json: z.string().nullable().optional()\n});\nconst ToolResultContentBlockSchema = z.object({\n\ttype: z.literal(\"tool_result\"),\n\ttoolUseId: z.string(),\n\tcontent: z.string(),\n\tsuccessText: z.string().nullish()\n});\nconst ContentBlockSchema = z.union([\n\tTextContentBlockSchema,\n\tToolUseContentBlockSchema,\n\tToolResultContentBlockSchema\n]);\nconst ContentFieldSchema = z.union([z.string(), z.array(ContentBlockSchema)]);\nconst InputMessageSchema = z.object({\n\trole: z.enum([\"user\", \"assistant\"]),\n\tcontent: ContentFieldSchema\n});\nconst NormalizedInputMessageSchema = InputMessageSchema.extend({ content: z.array(ContentBlockSchema) });\nconst SavedInputMessageSchema = InputMessageSchema.extend({\n\tid: z.string(),\n\tcontent: z.array(ContentBlockSchema),\n\tcreatedAt: z.coerce.date()\n});\nconst UsageSchema = z.object({\n\tinputTokens: z.number(),\n\toutputTokens: z.number(),\n\tcacheReadInputTokens: z.number().optional(),\n\tcacheCreationInputTokens: z.number().optional()\n});\nconst OutputMessageSchema = InputMessageSchema.extend({\n\tid: z.string(),\n\tcontent: z.array(ContentBlockSchema),\n\tusage: UsageSchema\n});\nconst SavedOutputMessageSchema = OutputMessageSchema.extend({ createdAt: z.coerce.date() });\nconst SavedMessageSchema = z.union([SavedInputMessageSchema, SavedOutputMessageSchema]);\nconst MessageSchema = z.union([\n\tInputMessageSchema,\n\tOutputMessageSchema,\n\tSavedInputMessageSchema,\n\tSavedOutputMessageSchema\n]);\nconst ResponseSchema = z.object({ messages: z.array(SavedMessageSchema) });\nconst MessageStartEventSchema = z.object({\n\ttype: z.literal(\"message_start\"),\n\tdata: z.object({\n\t\ttype: z.literal(\"message_start\"),\n\t\tmessage: z.object({\n\t\t\tid: z.string(),\n\t\t\trole: z.enum([\"user\", \"assistant\"]),\n\t\t\tcontent: z.array(ContentBlockSchema)\n\t\t})\n\t})\n});\nconst MessageDeltaEventSchema = z.object({\n\ttype: z.literal(\"message_delta\"),\n\tdata: z.object({\n\t\ttype: z.literal(\"message_delta\"),\n\t\tdelta: z.object({\n\t\t\tstop_reason: z.enum([\"end_turn\", \"tool_use\"]),\n\t\t\tstop_sequence: z.string().nullable()\n\t\t}),\n\t\tusage: UsageSchema.optional()\n\t})\n});\nconst MessageStopEventSchema = z.object({\n\ttype: z.literal(\"message_stop\"),\n\tdata: z.object({ type: z.literal(\"message_stop\") })\n});\nconst ContentBlockStartEventSchema = z.object({\n\ttype: z.literal(\"content_block_start\"),\n\tdata: z.object({\n\t\ttype: z.literal(\"content_block_start\"),\n\t\tindex: z.number(),\n\t\tcontentBlock: ContentBlockSchema\n\t})\n});\nconst ContentBlockDeltaEventSchema = z.object({\n\ttype: z.literal(\"content_block_delta\"),\n\tdata: z.object({\n\t\ttype: z.literal(\"content_block_delta\"),\n\t\tindex: z.number(),\n\t\tdelta: z.union([z.object({\n\t\t\ttype: z.literal(\"text_delta\"),\n\t\t\ttext: z.string()\n\t\t}), z.object({\n\t\t\ttype: z.literal(\"input_json_delta\"),\n\t\t\tpartial_json: z.string()\n\t\t})])\n\t})\n});\nconst ContentBlockStopEventSchema = z.object({\n\ttype: z.literal(\"content_block_stop\"),\n\tdata: z.object({\n\t\ttype: z.literal(\"content_block_stop\"),\n\t\tindex: z.number()\n\t})\n});\nconst ErrorEventSchema = z.object({\n\ttype: z.literal(\"error\"),\n\tdata: z.object({\n\t\ttype: z.literal(\"error\"),\n\t\terror: z.object({\n\t\t\tcode: z.string(),\n\t\t\tmessage: z.string()\n\t\t})\n\t})\n});\nconst PingEventSchema = z.object({\n\ttype: z.literal(\"ping\"),\n\tdata: z.object({\n\t\ttype: z.literal(\"ping\"),\n\t\ttimestamp: z.number()\n\t})\n});\nconst MessageStreamEventSchema = z.union([\n\tMessageStartEventSchema,\n\tMessageDeltaEventSchema,\n\tMessageStopEventSchema,\n\tContentBlockStartEventSchema,\n\tContentBlockDeltaEventSchema,\n\tContentBlockStopEventSchema,\n\tErrorEventSchema,\n\tPingEventSchema\n]);\n//#endregion\nexport { ContentBlockDeltaEventSchema, ContentBlockSchema, ContentFieldSchema, InputMessageSchema, MessageSchema, MessageStreamEventSchema, NormalizedInputMessageSchema, OutputMessageSchema, ResponseSchema, SavedInputMessageSchema, SavedMessageSchema, SavedOutputMessageSchema, TextContentBlockSchema, ToolResultContentBlockSchema, ToolUseContentBlockSchema, UsageSchema };\n\n//# sourceMappingURL=index.mjs.map","export { group, guard, mapEntries, mapValues, omit, retry, sleep } from 'radash';\n\nfunction resolveMaybeOptionalOptions(rest) {\n return rest[0] ?? {};\n}\n\nfunction toArray(value) {\n return Array.isArray(value) ? value : value === void 0 || value === null ? [] : [value];\n}\nfunction splitInHalf(arr) {\n const half = Math.ceil(arr.length / 2);\n return [arr.slice(0, half), arr.slice(half)];\n}\n\nfunction readAsBuffer(source) {\n if (typeof source.bytes === \"function\") {\n return source.bytes();\n }\n return source.arrayBuffer();\n}\n\nconst ORPC_NAME = \"orpc\";\nconst ORPC_SHARED_PACKAGE_NAME = \"@orpc/shared\";\nconst ORPC_SHARED_PACKAGE_VERSION = \"1.13.6\";\n\nclass AbortError extends Error {\n constructor(...rest) {\n super(...rest);\n this.name = \"AbortError\";\n }\n}\n\nfunction once(fn) {\n let cached;\n return () => {\n if (cached) {\n return cached.result;\n }\n const result = fn();\n cached = { result };\n return result;\n };\n}\nfunction sequential(fn) {\n let lastOperationPromise = Promise.resolve();\n return (...args) => {\n return lastOperationPromise = lastOperationPromise.catch(() => {\n }).then(() => {\n return fn(...args);\n });\n };\n}\nfunction defer(callback) {\n if (typeof setTimeout === \"function\") {\n setTimeout(callback, 0);\n } else {\n Promise.resolve().then(() => Promise.resolve().then(() => Promise.resolve().then(callback)));\n }\n}\n\nconst SPAN_ERROR_STATUS = 2;\nconst GLOBAL_OTEL_CONFIG_KEY = `__${ORPC_SHARED_PACKAGE_NAME}@${ORPC_SHARED_PACKAGE_VERSION}/otel/config__`;\nfunction setGlobalOtelConfig(config) {\n globalThis[GLOBAL_OTEL_CONFIG_KEY] = config;\n}\nfunction getGlobalOtelConfig() {\n return globalThis[GLOBAL_OTEL_CONFIG_KEY];\n}\nfunction startSpan(name, options = {}, context) {\n const tracer = getGlobalOtelConfig()?.tracer;\n return tracer?.startSpan(name, options, context);\n}\nfunction setSpanError(span, error, options = {}) {\n if (!span) {\n return;\n }\n const exception = toOtelException(error);\n span.recordException(exception);\n if (!options.signal?.aborted || options.signal.reason !== error) {\n span.setStatus({\n code: SPAN_ERROR_STATUS,\n message: exception.message\n });\n }\n}\nfunction setSpanAttribute(span, key, value) {\n if (!span || value === void 0) {\n return;\n }\n span.setAttribute(key, value);\n}\nfunction toOtelException(error) {\n if (error instanceof Error) {\n const exception = {\n message: error.message,\n name: error.name,\n stack: error.stack\n };\n if (\"code\" in error && (typeof error.code === \"string\" || typeof error.code === \"number\")) {\n exception.code = error.code;\n }\n return exception;\n }\n return { message: String(error) };\n}\nfunction toSpanAttributeValue(data) {\n if (data === void 0) {\n return \"undefined\";\n }\n try {\n return JSON.stringify(data, (_, value) => {\n if (typeof value === \"bigint\") {\n return value.toString();\n }\n if (value instanceof Map || value instanceof Set) {\n return Array.from(value);\n }\n return value;\n });\n } catch {\n return String(data);\n }\n}\nasync function runWithSpan({ name, context, ...options }, fn) {\n const tracer = getGlobalOtelConfig()?.tracer;\n if (!tracer) {\n return fn();\n }\n const callback = async (span) => {\n try {\n return await fn(span);\n } catch (e) {\n setSpanError(span, e, options);\n throw e;\n } finally {\n span.end();\n }\n };\n if (context) {\n return tracer.startActiveSpan(name, options, context, callback);\n } else {\n return tracer.startActiveSpan(name, options, callback);\n }\n}\nasync function runInSpanContext(span, fn) {\n const otelConfig = getGlobalOtelConfig();\n if (!span || !otelConfig) {\n return fn();\n }\n const ctx = otelConfig.trace.setSpan(otelConfig.context.active(), span);\n return otelConfig.context.with(ctx, fn);\n}\n\nclass AsyncIdQueue {\n openIds = /* @__PURE__ */ new Set();\n queues = /* @__PURE__ */ new Map();\n waiters = /* @__PURE__ */ new Map();\n get length() {\n return this.openIds.size;\n }\n get waiterIds() {\n return Array.from(this.waiters.keys());\n }\n hasBufferedItems(id) {\n return Boolean(this.queues.get(id)?.length);\n }\n open(id) {\n this.openIds.add(id);\n }\n isOpen(id) {\n return this.openIds.has(id);\n }\n push(id, item) {\n this.assertOpen(id);\n const pending = this.waiters.get(id);\n if (pending?.length) {\n pending.shift()[0](item);\n if (pending.length === 0) {\n this.waiters.delete(id);\n }\n } else {\n const items = this.queues.get(id);\n if (items) {\n items.push(item);\n } else {\n this.queues.set(id, [item]);\n }\n }\n }\n async pull(id) {\n this.assertOpen(id);\n const items = this.queues.get(id);\n if (items?.length) {\n const item = items.shift();\n if (items.length === 0) {\n this.queues.delete(id);\n }\n return item;\n }\n return new Promise((resolve, reject) => {\n const waitingPulls = this.waiters.get(id);\n const pending = [resolve, reject];\n if (waitingPulls) {\n waitingPulls.push(pending);\n } else {\n this.waiters.set(id, [pending]);\n }\n });\n }\n close({ id, reason } = {}) {\n if (id === void 0) {\n this.waiters.forEach((pendingPulls, id2) => {\n const error2 = reason ?? new AbortError(`[AsyncIdQueue] Queue[${id2}] was closed or aborted while waiting for pulling.`);\n pendingPulls.forEach(([, reject]) => reject(error2));\n });\n this.waiters.clear();\n this.openIds.clear();\n this.queues.clear();\n return;\n }\n const error = reason ?? new AbortError(`[AsyncIdQueue] Queue[${id}] was closed or aborted while waiting for pulling.`);\n this.waiters.get(id)?.forEach(([, reject]) => reject(error));\n this.waiters.delete(id);\n this.openIds.delete(id);\n this.queues.delete(id);\n }\n assertOpen(id) {\n if (!this.isOpen(id)) {\n throw new Error(`[AsyncIdQueue] Cannot access queue[${id}] because it is not open or aborted.`);\n }\n }\n}\n\nfunction isAsyncIteratorObject(maybe) {\n if (!maybe || typeof maybe !== \"object\") {\n return false;\n }\n return \"next\" in maybe && typeof maybe.next === \"function\" && Symbol.asyncIterator in maybe && typeof maybe[Symbol.asyncIterator] === \"function\";\n}\nconst fallbackAsyncDisposeSymbol = Symbol.for(\"asyncDispose\");\nconst asyncDisposeSymbol = Symbol.asyncDispose ?? fallbackAsyncDisposeSymbol;\nclass AsyncIteratorClass {\n #isDone = false;\n #isExecuteComplete = false;\n #cleanup;\n #next;\n constructor(next, cleanup) {\n this.#cleanup = cleanup;\n this.#next = sequential(async () => {\n if (this.#isDone) {\n return { done: true, value: void 0 };\n }\n try {\n const result = await next();\n if (result.done) {\n this.#isDone = true;\n }\n return result;\n } catch (err) {\n this.#isDone = true;\n throw err;\n } finally {\n if (this.#isDone && !this.#isExecuteComplete) {\n this.#isExecuteComplete = true;\n await this.#cleanup(\"next\");\n }\n }\n });\n }\n next() {\n return this.#next();\n }\n async return(value) {\n this.#isDone = true;\n if (!this.#isExecuteComplete) {\n this.#isExecuteComplete = true;\n await this.#cleanup(\"return\");\n }\n return { done: true, value };\n }\n async throw(err) {\n this.#isDone = true;\n if (!this.#isExecuteComplete) {\n this.#isExecuteComplete = true;\n await this.#cleanup(\"throw\");\n }\n throw err;\n }\n /**\n * asyncDispose symbol only available in esnext, we should fallback to Symbol.for('asyncDispose')\n */\n async [asyncDisposeSymbol]() {\n this.#isDone = true;\n if (!this.#isExecuteComplete) {\n this.#isExecuteComplete = true;\n await this.#cleanup(\"dispose\");\n }\n }\n [Symbol.asyncIterator]() {\n return this;\n }\n}\nfunction replicateAsyncIterator(source, count) {\n const queue = new AsyncIdQueue();\n const ids = Array.from({ length: count }, (_, i) => i.toString());\n let isSourceFinished = false;\n const start = once(async () => {\n try {\n while (true) {\n const item = await source.next();\n ids.forEach((id) => {\n if (queue.isOpen(id)) {\n queue.push(id, { next: item });\n }\n });\n if (item.done) {\n break;\n }\n }\n } catch (error) {\n ids.forEach((id) => {\n if (queue.isOpen(id)) {\n queue.push(id, { error });\n }\n });\n } finally {\n isSourceFinished = true;\n }\n });\n const replicated = ids.map((id) => {\n queue.open(id);\n return new AsyncIteratorClass(\n async () => {\n start();\n const item = await queue.pull(id);\n if (item.next) {\n return item.next;\n }\n throw item.error;\n },\n async (reason) => {\n queue.close({ id });\n if (reason !== \"next\" && !queue.length && !isSourceFinished) {\n isSourceFinished = true;\n await source?.return?.();\n }\n }\n );\n });\n return replicated;\n}\nfunction asyncIteratorWithSpan({ name, ...options }, iterator) {\n let span;\n return new AsyncIteratorClass(\n async () => {\n span ??= startSpan(name);\n try {\n const result = await runInSpanContext(span, () => iterator.next());\n span?.addEvent(result.done ? \"completed\" : \"yielded\");\n return result;\n } catch (err) {\n setSpanError(span, err, options);\n throw err;\n }\n },\n async (reason) => {\n try {\n if (reason !== \"next\") {\n await runInSpanContext(span, () => iterator.return?.());\n }\n } catch (err) {\n setSpanError(span, err, options);\n throw err;\n } finally {\n span?.end();\n }\n }\n );\n}\n\nclass EventPublisher {\n #listenersMap = /* @__PURE__ */ new Map();\n #maxBufferedEvents;\n constructor(options = {}) {\n this.#maxBufferedEvents = options.maxBufferedEvents ?? 100;\n }\n get size() {\n return this.#listenersMap.size;\n }\n /**\n * Emits an event and delivers the payload to all subscribed listeners.\n */\n publish(event, payload) {\n const listeners = this.#listenersMap.get(event);\n if (!listeners) {\n return;\n }\n for (const listener of listeners) {\n listener(payload);\n }\n }\n subscribe(event, listenerOrOptions) {\n if (typeof listenerOrOptions === \"function\") {\n let listeners = this.#listenersMap.get(event);\n if (!listeners) {\n this.#listenersMap.set(event, listeners = []);\n }\n listeners.push(listenerOrOptions);\n return once(() => {\n listeners.splice(listeners.indexOf(listenerOrOptions), 1);\n if (listeners.length === 0) {\n this.#listenersMap.delete(event);\n }\n });\n }\n const signal = listenerOrOptions?.signal;\n const maxBufferedEvents = listenerOrOptions?.maxBufferedEvents ?? this.#maxBufferedEvents;\n signal?.throwIfAborted();\n const bufferedEvents = [];\n const pullResolvers = [];\n const unsubscribe = this.subscribe(event, (payload) => {\n const resolver = pullResolvers.shift();\n if (resolver) {\n resolver[0]({ done: false, value: payload });\n } else {\n bufferedEvents.push(payload);\n if (bufferedEvents.length > maxBufferedEvents) {\n bufferedEvents.shift();\n }\n }\n });\n const abortListener = (event2) => {\n unsubscribe();\n pullResolvers.forEach((resolver) => resolver[1](event2.target.reason));\n pullResolvers.length = 0;\n bufferedEvents.length = 0;\n };\n signal?.addEventListener(\"abort\", abortListener, { once: true });\n return new AsyncIteratorClass(async () => {\n if (signal?.aborted) {\n throw signal.reason;\n }\n if (bufferedEvents.length > 0) {\n return { done: false, value: bufferedEvents.shift() };\n }\n return new Promise((resolve, reject) => {\n pullResolvers.push([resolve, reject]);\n });\n }, async () => {\n unsubscribe();\n signal?.removeEventListener(\"abort\", abortListener);\n pullResolvers.forEach((resolver) => resolver[0]({ done: true, value: void 0 }));\n pullResolvers.length = 0;\n bufferedEvents.length = 0;\n });\n }\n}\n\nclass SequentialIdGenerator {\n index = BigInt(1);\n generate() {\n const id = this.index.toString(36);\n this.index++;\n return id;\n }\n}\nfunction compareSequentialIds(a, b) {\n if (a.length !== b.length) {\n return a.length - b.length;\n }\n return a < b ? -1 : a > b ? 1 : 0;\n}\n\nfunction onStart(callback) {\n return async (options, ...rest) => {\n await callback(options, ...rest);\n return await options.next();\n };\n}\nfunction onSuccess(callback) {\n return async (options, ...rest) => {\n const result = await options.next();\n await callback(result, options, ...rest);\n return result;\n };\n}\nfunction onError(callback) {\n return async (options, ...rest) => {\n try {\n return await options.next();\n } catch (error) {\n await callback(error, options, ...rest);\n throw error;\n }\n };\n}\nfunction onFinish(callback) {\n let state;\n return async (options, ...rest) => {\n try {\n const result = await options.next();\n state = [null, result, true];\n return result;\n } catch (error) {\n state = [error, void 0, false];\n throw error;\n } finally {\n await callback(state, options, ...rest);\n }\n };\n}\nfunction intercept(interceptors, options, main) {\n const next = (options2, index) => {\n const interceptor = interceptors[index];\n if (!interceptor) {\n return main(options2);\n }\n return interceptor({\n ...options2,\n next: (newOptions = options2) => next(newOptions, index + 1)\n });\n };\n return next(options, 0);\n}\n\nfunction parseEmptyableJSON(text) {\n if (!text) {\n return void 0;\n }\n return JSON.parse(text);\n}\nfunction stringifyJSON(value) {\n return JSON.stringify(value);\n}\n\nfunction findDeepMatches(check, payload, segments = [], maps = [], values = []) {\n if (check(payload)) {\n maps.push(segments);\n values.push(payload);\n } else if (Array.isArray(payload)) {\n payload.forEach((v, i) => {\n findDeepMatches(check, v, [...segments, i], maps, values);\n });\n } else if (isObject(payload)) {\n for (const key in payload) {\n findDeepMatches(check, payload[key], [...segments, key], maps, values);\n }\n }\n return { maps, values };\n}\nfunction getConstructor(value) {\n if (!isTypescriptObject(value)) {\n return null;\n }\n return Object.getPrototypeOf(value)?.constructor;\n}\nfunction isObject(value) {\n if (!value || typeof value !== \"object\") {\n return false;\n }\n const proto = Object.getPrototypeOf(value);\n return proto === Object.prototype || !proto || !proto.constructor;\n}\nfunction isTypescriptObject(value) {\n return !!value && (typeof value === \"object\" || typeof value === \"function\");\n}\nfunction clone(value) {\n if (Array.isArray(value)) {\n return value.map(clone);\n }\n if (isObject(value)) {\n const result = {};\n for (const key in value) {\n result[key] = clone(value[key]);\n }\n for (const sym of Object.getOwnPropertySymbols(value)) {\n result[sym] = clone(value[sym]);\n }\n return result;\n }\n return value;\n}\nfunction get(object, path) {\n let current = object;\n for (const key of path) {\n if (!isTypescriptObject(current)) {\n return void 0;\n }\n current = current[key];\n }\n return current;\n}\nfunction isPropertyKey(value) {\n const type = typeof value;\n return type === \"string\" || type === \"number\" || type === \"symbol\";\n}\nconst NullProtoObj = /* @__PURE__ */ (() => {\n const e = function() {\n };\n e.prototype = /* @__PURE__ */ Object.create(null);\n Object.freeze(e.prototype);\n return e;\n})();\n\nfunction value(value2, ...args) {\n if (typeof value2 === \"function\") {\n return value2(...args);\n }\n return value2;\n}\nfunction fallback(value2, fallback2) {\n return value2 === void 0 ? fallback2 : value2;\n}\n\nfunction preventNativeAwait(target) {\n return new Proxy(target, {\n get(target2, prop, receiver) {\n const value2 = Reflect.get(target2, prop, receiver);\n if (prop !== \"then\" || typeof value2 !== \"function\") {\n return value2;\n }\n return new Proxy(value2, {\n apply(targetFn, thisArg, args) {\n if (args.length !== 2 || args.some((arg) => !isNativeFunction(arg))) {\n return Reflect.apply(targetFn, thisArg, args);\n }\n let shouldOmit = true;\n args[0].call(thisArg, preventNativeAwait(new Proxy(target2, {\n get: (target3, prop2, receiver2) => {\n if (shouldOmit && prop2 === \"then\") {\n shouldOmit = false;\n return void 0;\n }\n return Reflect.get(target3, prop2, receiver2);\n }\n })));\n }\n });\n }\n });\n}\nconst NATIVE_FUNCTION_REGEX = /^\\s*function\\s*\\(\\)\\s*\\{\\s*\\[native code\\]\\s*\\}\\s*$/;\nfunction isNativeFunction(fn) {\n return typeof fn === \"function\" && NATIVE_FUNCTION_REGEX.test(fn.toString());\n}\nfunction overlayProxy(target, partial) {\n const proxy = new Proxy(typeof target === \"function\" ? partial : target, {\n get(_, prop) {\n const targetValue = prop in partial ? partial : value(target);\n const v = Reflect.get(targetValue, prop);\n return typeof v === \"function\" ? v.bind(targetValue) : v;\n },\n has(_, prop) {\n return Reflect.has(partial, prop) || Reflect.has(value(target), prop);\n }\n });\n return proxy;\n}\n\nfunction streamToAsyncIteratorClass(stream) {\n const reader = stream.getReader();\n return new AsyncIteratorClass(\n async () => {\n return reader.read();\n },\n async () => {\n await reader.cancel();\n }\n );\n}\nfunction asyncIteratorToStream(iterator) {\n return new ReadableStream({\n async pull(controller) {\n const { done, value } = await iterator.next();\n if (done) {\n controller.close();\n } else {\n controller.enqueue(value);\n }\n },\n async cancel() {\n await iterator.return?.();\n }\n });\n}\nfunction asyncIteratorToUnproxiedDataStream(iterator) {\n return new ReadableStream({\n async pull(controller) {\n const { done, value } = await iterator.next();\n if (done) {\n controller.close();\n } else {\n const unproxied = isObject(value) ? { ...value } : Array.isArray(value) ? value.map((i) => i) : value;\n controller.enqueue(unproxied);\n }\n },\n async cancel() {\n await iterator.return?.();\n }\n });\n}\n\nfunction tryDecodeURIComponent(value) {\n try {\n return decodeURIComponent(value);\n } catch {\n return value;\n }\n}\n\nexport { AbortError, AsyncIdQueue, AsyncIteratorClass, EventPublisher, NullProtoObj, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION, SequentialIdGenerator, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, asyncIteratorWithSpan, clone, compareSequentialIds, defer, fallback, findDeepMatches, get, getConstructor, getGlobalOtelConfig, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, overlayProxy, parseEmptyableJSON, preventNativeAwait, readAsBuffer, replicateAsyncIterator, resolveMaybeOptionalOptions, runInSpanContext, runWithSpan, sequential, setGlobalOtelConfig, setSpanAttribute, setSpanError, splitInHalf, startSpan, streamToAsyncIteratorClass, stringifyJSON, toArray, toOtelException, toSpanAttributeValue, tryDecodeURIComponent, value };\n","import { isTypescriptObject, AsyncIteratorClass, tryDecodeURIComponent, toArray, once, isAsyncIteratorObject, replicateAsyncIterator } from '@orpc/shared';\n\nclass EventEncoderError extends TypeError {\n}\nclass EventDecoderError extends TypeError {\n}\nclass ErrorEvent extends Error {\n data;\n constructor(options) {\n super(options?.message ?? \"An error event was received\", options);\n this.data = options?.data;\n }\n}\n\nfunction decodeEventMessage(encoded) {\n const lines = encoded.replace(/\\n+$/, \"\").split(/\\n/);\n const message = {\n data: void 0,\n event: void 0,\n id: void 0,\n retry: void 0,\n comments: []\n };\n for (const line of lines) {\n const index = line.indexOf(\":\");\n const key = index === -1 ? line : line.slice(0, index);\n const value = index === -1 ? \"\" : line.slice(index + 1).replace(/^\\s/, \"\");\n if (index === 0) {\n message.comments.push(value);\n } else if (key === \"data\") {\n message.data ??= \"\";\n message.data += `${value}\n`;\n } else if (key === \"event\") {\n message.event = value;\n } else if (key === \"id\") {\n message.id = value;\n } else if (key === \"retry\") {\n const maybeInteger = Number.parseInt(value);\n if (Number.isInteger(maybeInteger) && maybeInteger >= 0 && maybeInteger.toString() === value) {\n message.retry = maybeInteger;\n }\n }\n }\n message.data = message.data?.replace(/\\n$/, \"\");\n return message;\n}\nclass EventDecoder {\n constructor(options = {}) {\n this.options = options;\n }\n incomplete = \"\";\n feed(chunk) {\n this.incomplete += chunk;\n const lastCompleteIndex = this.incomplete.lastIndexOf(\"\\n\\n\");\n if (lastCompleteIndex === -1) {\n return;\n }\n const completes = this.incomplete.slice(0, lastCompleteIndex).split(/\\n\\n/);\n this.incomplete = this.incomplete.slice(lastCompleteIndex + 2);\n for (const encoded of completes) {\n const message = decodeEventMessage(`${encoded}\n\n`);\n if (this.options.onEvent) {\n this.options.onEvent(message);\n }\n }\n }\n end() {\n if (this.incomplete) {\n throw new EventDecoderError(\"Event Iterator ended before complete\");\n }\n }\n}\nclass EventDecoderStream extends TransformStream {\n constructor() {\n let decoder;\n super({\n start(controller) {\n decoder = new EventDecoder({\n onEvent: (event) => {\n controller.enqueue(event);\n }\n });\n },\n transform(chunk) {\n decoder.feed(chunk);\n },\n flush() {\n decoder.end();\n }\n });\n }\n}\n\nfunction assertEventId(id) {\n if (id.includes(\"\\n\")) {\n throw new EventEncoderError(\"Event's id must not contain a newline character\");\n }\n}\nfunction assertEventName(event) {\n if (event.includes(\"\\n\")) {\n throw new EventEncoderError(\"Event's event must not contain a newline character\");\n }\n}\nfunction assertEventRetry(retry) {\n if (!Number.isInteger(retry) || retry < 0) {\n throw new EventEncoderError(\"Event's retry must be a integer and >= 0\");\n }\n}\nfunction assertEventComment(comment) {\n if (comment.includes(\"\\n\")) {\n throw new EventEncoderError(\"Event's comment must not contain a newline character\");\n }\n}\nfunction encodeEventData(data) {\n const lines = data?.split(/\\n/) ?? [];\n let output = \"\";\n for (const line of lines) {\n output += `data: ${line}\n`;\n }\n return output;\n}\nfunction encodeEventComments(comments) {\n let output = \"\";\n for (const comment of comments ?? []) {\n assertEventComment(comment);\n output += `: ${comment}\n`;\n }\n return output;\n}\nfunction encodeEventMessage(message) {\n let output = \"\";\n output += encodeEventComments(message.comments);\n if (message.event !== void 0) {\n assertEventName(message.event);\n output += `event: ${message.event}\n`;\n }\n if (message.retry !== void 0) {\n assertEventRetry(message.retry);\n output += `retry: ${message.retry}\n`;\n }\n if (message.id !== void 0) {\n assertEventId(message.id);\n output += `id: ${message.id}\n`;\n }\n output += encodeEventData(message.data);\n output += \"\\n\";\n return output;\n}\n\nconst EVENT_SOURCE_META_SYMBOL = Symbol(\"ORPC_EVENT_SOURCE_META\");\nfunction withEventMeta(container, meta) {\n if (meta.id === void 0 && meta.retry === void 0 && !meta.comments?.length) {\n return container;\n }\n if (meta.id !== void 0) {\n assertEventId(meta.id);\n }\n if (meta.retry !== void 0) {\n assertEventRetry(meta.retry);\n }\n if (meta.comments !== void 0) {\n for (const comment of meta.comments) {\n assertEventComment(comment);\n }\n }\n return new Proxy(container, {\n get(target, prop, receiver) {\n if (prop === EVENT_SOURCE_META_SYMBOL) {\n return meta;\n }\n return Reflect.get(target, prop, receiver);\n }\n });\n}\nfunction getEventMeta(container) {\n return isTypescriptObject(container) ? Reflect.get(container, EVENT_SOURCE_META_SYMBOL) : void 0;\n}\n\nclass HibernationEventIterator extends AsyncIteratorClass {\n /**\n * this property is not transferred to the client, so it should be optional for type safety\n */\n hibernationCallback;\n constructor(hibernationCallback) {\n super(async () => {\n throw new Error(\"Cannot iterate over hibernating iterator directly\");\n }, async (reason) => {\n if (reason !== \"next\") {\n throw new Error(\"Cannot cleanup hibernating iterator directly\");\n }\n });\n this.hibernationCallback = hibernationCallback;\n }\n}\n\nfunction generateContentDisposition(filename) {\n const escapedFileName = filename.replace(/\"/g, '\\\\\"');\n const encodedFilenameStar = encodeURIComponent(filename).replace(/['()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%(7C|60|5E)/g, (str, hex) => String.fromCharCode(Number.parseInt(hex, 16)));\n return `inline; filename=\"${escapedFileName}\"; filename*=utf-8''${encodedFilenameStar}`;\n}\nfunction getFilenameFromContentDisposition(contentDisposition) {\n const encodedFilenameStarMatch = contentDisposition.match(/filename\\*=(UTF-8'')?([^;]*)/i);\n if (encodedFilenameStarMatch && typeof encodedFilenameStarMatch[2] === \"string\") {\n return tryDecodeURIComponent(encodedFilenameStarMatch[2]);\n }\n const encodedFilenameMatch = contentDisposition.match(/filename=\"((?:\\\\\"|[^\"])*)\"/i);\n if (encodedFilenameMatch && typeof encodedFilenameMatch[1] === \"string\") {\n return encodedFilenameMatch[1].replace(/\\\\\"/g, '\"');\n }\n}\nfunction mergeStandardHeaders(a, b) {\n const merged = { ...a };\n for (const key in b) {\n if (Array.isArray(b[key])) {\n merged[key] = [...toArray(merged[key]), ...b[key]];\n } else if (b[key] !== void 0) {\n if (Array.isArray(merged[key])) {\n merged[key] = [...merged[key], b[key]];\n } else if (merged[key] !== void 0) {\n merged[key] = [merged[key], b[key]];\n } else {\n merged[key] = b[key];\n }\n }\n }\n return merged;\n}\nfunction flattenHeader(header) {\n if (typeof header === \"string\" || header === void 0) {\n return header;\n }\n if (header.length === 0) {\n return void 0;\n }\n return header.join(\", \");\n}\nfunction replicateStandardLazyResponse(response, count) {\n const replicated = [];\n let bodyPromise;\n let replicatedAsyncIteratorObjects;\n for (let i = 0; i < count; i++) {\n replicated.push({\n ...response,\n body: once(async () => {\n const body = await (bodyPromise ??= response.body());\n if (!isAsyncIteratorObject(body)) {\n return body;\n }\n replicatedAsyncIteratorObjects ??= replicateAsyncIterator(body, count);\n return replicatedAsyncIteratorObjects.shift();\n })\n });\n }\n return replicated;\n}\nfunction isEventIteratorHeaders(headers) {\n return Boolean(flattenHeader(headers[\"content-type\"])?.startsWith(\"text/event-stream\") && flattenHeader(headers[\"content-disposition\"]) === void 0);\n}\n\nexport { ErrorEvent, EventDecoder, EventDecoderError, EventDecoderStream, EventEncoderError, HibernationEventIterator, assertEventComment, assertEventId, assertEventName, assertEventRetry, decodeEventMessage, encodeEventComments, encodeEventData, encodeEventMessage, flattenHeader, generateContentDisposition, getEventMeta, getFilenameFromContentDisposition, isEventIteratorHeaders, mergeStandardHeaders, replicateStandardLazyResponse, withEventMeta };\n","import { isContractProcedure, validateORPCError, ValidationError, mergePrefix, mergeErrorMap, enhanceRoute } from '@orpc/contract';\nimport { resolveMaybeOptionalOptions, toArray, value, runWithSpan, intercept, isAsyncIteratorObject, overlayProxy, asyncIteratorWithSpan } from '@orpc/shared';\nimport { ORPCError, mapEventIterator } from '@orpc/client';\nimport { HibernationEventIterator } from '@orpc/standard-server';\n\nconst LAZY_SYMBOL = Symbol(\"ORPC_LAZY_SYMBOL\");\nfunction lazy(loader, meta = {}) {\n return {\n [LAZY_SYMBOL]: {\n loader,\n meta\n }\n };\n}\nfunction isLazy(item) {\n return (typeof item === \"object\" || typeof item === \"function\") && item !== null && LAZY_SYMBOL in item;\n}\nfunction getLazyMeta(lazied) {\n return lazied[LAZY_SYMBOL].meta;\n}\nfunction unlazy(lazied) {\n return isLazy(lazied) ? lazied[LAZY_SYMBOL].loader() : Promise.resolve({ default: lazied });\n}\n\nfunction isStartWithMiddlewares(middlewares, compare) {\n if (compare.length > middlewares.length) {\n return false;\n }\n for (let i = 0; i < middlewares.length; i++) {\n if (compare[i] === void 0) {\n return true;\n }\n if (middlewares[i] !== compare[i]) {\n return false;\n }\n }\n return true;\n}\nfunction mergeMiddlewares(first, second, options) {\n if (options.dedupeLeading && isStartWithMiddlewares(second, first)) {\n return second;\n }\n return [...first, ...second];\n}\nfunction addMiddleware(middlewares, addition) {\n return [...middlewares, addition];\n}\n\nclass Procedure {\n /**\n * This property holds the defined options.\n */\n \"~orpc\";\n constructor(def) {\n this[\"~orpc\"] = def;\n }\n}\nfunction isProcedure(item) {\n if (item instanceof Procedure) {\n return true;\n }\n return isContractProcedure(item) && \"middlewares\" in item[\"~orpc\"] && \"inputValidationIndex\" in item[\"~orpc\"] && \"outputValidationIndex\" in item[\"~orpc\"] && \"handler\" in item[\"~orpc\"];\n}\n\nfunction mergeCurrentContext(context, other) {\n return { ...context, ...other };\n}\n\nfunction createORPCErrorConstructorMap(errors) {\n const proxy = new Proxy(errors, {\n get(target, code) {\n if (typeof code !== \"string\") {\n return Reflect.get(target, code);\n }\n const item = (...rest) => {\n const options = resolveMaybeOptionalOptions(rest);\n const config = errors[code];\n return new ORPCError(code, {\n defined: Boolean(config),\n status: config?.status,\n message: options.message ?? config?.message,\n data: options.data,\n cause: options.cause\n });\n };\n return item;\n }\n });\n return proxy;\n}\n\nfunction middlewareOutputFn(output) {\n return { output, context: {} };\n}\n\nfunction createProcedureClient(lazyableProcedure, ...rest) {\n const options = resolveMaybeOptionalOptions(rest);\n return async (...[input, callerOptions]) => {\n const path = toArray(options.path);\n const { default: procedure } = await unlazy(lazyableProcedure);\n const clientContext = callerOptions?.context ?? {};\n const context = await value(options.context ?? {}, clientContext);\n const errors = createORPCErrorConstructorMap(procedure[\"~orpc\"].errorMap);\n const validateError = async (e) => {\n if (e instanceof ORPCError) {\n return await validateORPCError(procedure[\"~orpc\"].errorMap, e);\n }\n return e;\n };\n try {\n const output = await runWithSpan(\n { name: \"call_procedure\", signal: callerOptions?.signal },\n (span) => {\n span?.setAttribute(\"procedure.path\", [...path]);\n return intercept(\n toArray(options.interceptors),\n {\n context,\n input,\n // input only optional when it undefinable so we can safely cast it\n errors,\n path,\n procedure,\n signal: callerOptions?.signal,\n lastEventId: callerOptions?.lastEventId\n },\n (interceptorOptions) => executeProcedureInternal(interceptorOptions.procedure, interceptorOptions)\n );\n }\n );\n if (isAsyncIteratorObject(output)) {\n if (output instanceof HibernationEventIterator) {\n return output;\n }\n return overlayProxy(output, mapEventIterator(\n asyncIteratorWithSpan(\n { name: \"consume_event_iterator_output\", signal: callerOptions?.signal },\n output\n ),\n {\n value: (v) => v,\n error: (e) => validateError(e)\n }\n ));\n }\n return output;\n } catch (e) {\n throw await validateError(e);\n }\n };\n}\nasync function validateInput(procedure, input) {\n const schema = procedure[\"~orpc\"].inputSchema;\n if (!schema) {\n return input;\n }\n return runWithSpan(\n { name: \"validate_input\" },\n async () => {\n const result = await schema[\"~standard\"].validate(input);\n if (result.issues) {\n throw new ORPCError(\"BAD_REQUEST\", {\n message: \"Input validation failed\",\n data: {\n issues: result.issues\n },\n cause: new ValidationError({\n message: \"Input validation failed\",\n issues: result.issues,\n data: input\n })\n });\n }\n return result.value;\n }\n );\n}\nasync function validateOutput(procedure, output) {\n const schema = procedure[\"~orpc\"].outputSchema;\n if (!schema) {\n return output;\n }\n return runWithSpan(\n { name: \"validate_output\" },\n async () => {\n const result = await schema[\"~standard\"].validate(output);\n if (result.issues) {\n throw new ORPCError(\"INTERNAL_SERVER_ERROR\", {\n message: \"Output validation failed\",\n cause: new ValidationError({\n message: \"Output validation failed\",\n issues: result.issues,\n data: output\n })\n });\n }\n return result.value;\n }\n );\n}\nasync function executeProcedureInternal(procedure, options) {\n const middlewares = procedure[\"~orpc\"].middlewares;\n const inputValidationIndex = Math.min(Math.max(0, procedure[\"~orpc\"].inputValidationIndex), middlewares.length);\n const outputValidationIndex = Math.min(Math.max(0, procedure[\"~orpc\"].outputValidationIndex), middlewares.length);\n const next = async (index, context, input) => {\n let currentInput = input;\n if (index === inputValidationIndex) {\n currentInput = await validateInput(procedure, currentInput);\n }\n const mid = middlewares[index];\n const output = mid ? await runWithSpan(\n { name: `middleware.${mid.name}`, signal: options.signal },\n async (span) => {\n span?.setAttribute(\"middleware.index\", index);\n span?.setAttribute(\"middleware.name\", mid.name);\n const result = await mid({\n ...options,\n context,\n next: async (...[nextOptions]) => {\n const nextContext = nextOptions?.context ?? {};\n return {\n output: await next(index + 1, mergeCurrentContext(context, nextContext), currentInput),\n context: nextContext\n };\n }\n }, currentInput, middlewareOutputFn);\n return result.output;\n }\n ) : await runWithSpan(\n { name: \"handler\", signal: options.signal },\n () => procedure[\"~orpc\"].handler({ ...options, context, input: currentInput })\n );\n if (index === outputValidationIndex) {\n return await validateOutput(procedure, output);\n }\n return output;\n };\n return next(0, options.context, options.input);\n}\n\nconst HIDDEN_ROUTER_CONTRACT_SYMBOL = Symbol(\"ORPC_HIDDEN_ROUTER_CONTRACT\");\nfunction setHiddenRouterContract(router, contract) {\n return new Proxy(router, {\n get(target, key) {\n if (key === HIDDEN_ROUTER_CONTRACT_SYMBOL) {\n return contract;\n }\n return Reflect.get(target, key);\n }\n });\n}\nfunction getHiddenRouterContract(router) {\n return router[HIDDEN_ROUTER_CONTRACT_SYMBOL];\n}\n\nfunction getRouter(router, path) {\n let current = router;\n for (let i = 0; i < path.length; i++) {\n const segment = path[i];\n if (!current) {\n return void 0;\n }\n if (isProcedure(current)) {\n return void 0;\n }\n if (!isLazy(current)) {\n current = current[segment];\n continue;\n }\n const lazied = current;\n const rest = path.slice(i);\n return lazy(async () => {\n const unwrapped = await unlazy(lazied);\n const next = getRouter(unwrapped.default, rest);\n return unlazy(next);\n }, getLazyMeta(lazied));\n }\n return current;\n}\nfunction createAccessibleLazyRouter(lazied) {\n const recursive = new Proxy(lazied, {\n get(target, key) {\n if (typeof key !== \"string\") {\n return Reflect.get(target, key);\n }\n const next = getRouter(lazied, [key]);\n return createAccessibleLazyRouter(next);\n }\n });\n return recursive;\n}\nfunction enhanceRouter(router, options) {\n if (isLazy(router)) {\n const laziedMeta = getLazyMeta(router);\n const enhancedPrefix = laziedMeta?.prefix ? mergePrefix(options.prefix, laziedMeta?.prefix) : options.prefix;\n const enhanced2 = lazy(async () => {\n const { default: unlaziedRouter } = await unlazy(router);\n const enhanced3 = enhanceRouter(unlaziedRouter, options);\n return unlazy(enhanced3);\n }, {\n ...laziedMeta,\n prefix: enhancedPrefix\n });\n const accessible = createAccessibleLazyRouter(enhanced2);\n return accessible;\n }\n if (isProcedure(router)) {\n const newMiddlewares = mergeMiddlewares(options.middlewares, router[\"~orpc\"].middlewares, { dedupeLeading: options.dedupeLeadingMiddlewares });\n const newMiddlewareAdded = newMiddlewares.length - router[\"~orpc\"].middlewares.length;\n const enhanced2 = new Procedure({\n ...router[\"~orpc\"],\n route: enhanceRoute(router[\"~orpc\"].route, options),\n errorMap: mergeErrorMap(options.errorMap, router[\"~orpc\"].errorMap),\n middlewares: newMiddlewares,\n inputValidationIndex: router[\"~orpc\"].inputValidationIndex + newMiddlewareAdded,\n outputValidationIndex: router[\"~orpc\"].outputValidationIndex + newMiddlewareAdded\n });\n return enhanced2;\n }\n const enhanced = {};\n for (const key in router) {\n enhanced[key] = enhanceRouter(router[key], options);\n }\n return enhanced;\n}\nfunction traverseContractProcedures(options, callback, lazyOptions = []) {\n let currentRouter = options.router;\n const hiddenContract = getHiddenRouterContract(options.router);\n if (hiddenContract !== void 0) {\n currentRouter = hiddenContract;\n }\n if (isLazy(currentRouter)) {\n lazyOptions.push({\n router: currentRouter,\n path: options.path\n });\n } else if (isContractProcedure(currentRouter)) {\n callback({\n contract: currentRouter,\n path: options.path\n });\n } else {\n for (const key in currentRouter) {\n traverseContractProcedures(\n {\n router: currentRouter[key],\n path: [...options.path, key]\n },\n callback,\n lazyOptions\n );\n }\n }\n return lazyOptions;\n}\nasync function resolveContractProcedures(options, callback) {\n const pending = [options];\n for (const options2 of pending) {\n const lazyOptions = traverseContractProcedures(options2, callback);\n for (const options3 of lazyOptions) {\n const { default: router } = await unlazy(options3.router);\n pending.push({\n router,\n path: options3.path\n });\n }\n }\n}\nasync function unlazyRouter(router) {\n if (isProcedure(router)) {\n return router;\n }\n const unlazied = {};\n for (const key in router) {\n const item = router[key];\n const { default: unlaziedRouter } = await unlazy(item);\n unlazied[key] = await unlazyRouter(unlaziedRouter);\n }\n return unlazied;\n}\n\nfunction createAssertedLazyProcedure(lazied) {\n const lazyProcedure = lazy(async () => {\n const { default: maybeProcedure } = await unlazy(lazied);\n if (!isProcedure(maybeProcedure)) {\n throw new Error(`\n Expected a lazy<procedure> but got lazy<unknown>.\n This should be caught by TypeScript compilation.\n Please report this issue if this makes you feel uncomfortable.\n `);\n }\n return { default: maybeProcedure };\n }, getLazyMeta(lazied));\n return lazyProcedure;\n}\nfunction createContractedProcedure(procedure, contract) {\n return new Procedure({\n ...procedure[\"~orpc\"],\n errorMap: contract[\"~orpc\"].errorMap,\n route: contract[\"~orpc\"].route,\n meta: contract[\"~orpc\"].meta\n });\n}\nfunction call(procedure, input, ...rest) {\n const options = resolveMaybeOptionalOptions(rest);\n return createProcedureClient(procedure, options)(input, options);\n}\n\nexport { LAZY_SYMBOL as L, Procedure as P, createContractedProcedure as a, addMiddleware as b, createProcedureClient as c, isLazy as d, enhanceRouter as e, createAssertedLazyProcedure as f, getRouter as g, createORPCErrorConstructorMap as h, isProcedure as i, getLazyMeta as j, middlewareOutputFn as k, lazy as l, mergeCurrentContext as m, isStartWithMiddlewares as n, mergeMiddlewares as o, call as p, getHiddenRouterContract as q, createAccessibleLazyRouter as r, setHiddenRouterContract as s, traverseContractProcedures as t, unlazy as u, resolveContractProcedures as v, unlazyRouter as w };\n","import { mergeErrorMap, mergeMeta, mergeRoute, mergePrefix, mergeTags, isContractProcedure, getContractRouter, fallbackContractConfig } from '@orpc/contract';\nexport { ValidationError, eventIterator, type, validateORPCError } from '@orpc/contract';\nimport { P as Procedure, b as addMiddleware, c as createProcedureClient, e as enhanceRouter, l as lazy, s as setHiddenRouterContract, u as unlazy, g as getRouter, i as isProcedure, d as isLazy, f as createAssertedLazyProcedure } from './shared/server.Ds4HPpvH.mjs';\nexport { L as LAZY_SYMBOL, p as call, r as createAccessibleLazyRouter, a as createContractedProcedure, h as createORPCErrorConstructorMap, q as getHiddenRouterContract, j as getLazyMeta, n as isStartWithMiddlewares, m as mergeCurrentContext, o as mergeMiddlewares, k as middlewareOutputFn, v as resolveContractProcedures, t as traverseContractProcedures, w as unlazyRouter } from './shared/server.Ds4HPpvH.mjs';\nimport { toORPCError } from '@orpc/client';\nexport { ORPCError, isDefinedError, safe } from '@orpc/client';\nimport { isObject, resolveMaybeOptionalOptions } from '@orpc/shared';\nexport { AsyncIteratorClass, EventPublisher, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';\nexport { getEventMeta, withEventMeta } from '@orpc/standard-server';\n\nconst DEFAULT_CONFIG = {\n initialInputValidationIndex: 0,\n initialOutputValidationIndex: 0,\n dedupeLeadingMiddlewares: true\n};\nfunction fallbackConfig(key, value) {\n if (value === void 0) {\n return DEFAULT_CONFIG[key];\n }\n return value;\n}\n\nfunction decorateMiddleware(middleware) {\n const decorated = ((...args) => middleware(...args));\n decorated.mapInput = (mapInput) => {\n const mapped = decorateMiddleware(\n (options, input, ...rest) => middleware(options, mapInput(input), ...rest)\n );\n return mapped;\n };\n decorated.concat = (concatMiddleware, mapInput) => {\n const mapped = mapInput ? decorateMiddleware(concatMiddleware).mapInput(mapInput) : concatMiddleware;\n const concatted = decorateMiddleware((options, input, output, ...rest) => {\n const merged = middleware({\n ...options,\n next: (...[nextOptions1]) => mapped({\n ...options,\n context: { ...options.context, ...nextOptions1?.context },\n next: (...[nextOptions2]) => options.next({ context: { ...nextOptions1?.context, ...nextOptions2?.context } })\n }, input, output, ...rest)\n }, input, output, ...rest);\n return merged;\n });\n return concatted;\n };\n return decorated;\n}\n\nfunction createActionableClient(client) {\n const action = async (input) => {\n try {\n return [null, await client(input)];\n } catch (error) {\n if (error instanceof Error && \"digest\" in error && typeof error.digest === \"string\" && error.digest.startsWith(\"NEXT_\")) {\n throw error;\n }\n if (error instanceof Response && \"options\" in error && isObject(error.options) || isObject(error) && error.isNotFound === true) {\n throw error;\n }\n return [toORPCError(error).toJSON(), void 0];\n }\n };\n return action;\n}\n\nclass DecoratedProcedure extends Procedure {\n /**\n * Adds type-safe custom errors.\n * The provided errors are spared-merged with any existing errors.\n *\n * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}\n */\n errors(errors) {\n return new DecoratedProcedure({\n ...this[\"~orpc\"],\n errorMap: mergeErrorMap(this[\"~orpc\"].errorMap, errors)\n });\n }\n /**\n * Sets or updates the metadata.\n * The provided metadata is spared-merged with any existing metadata.\n *\n * @see {@link https://orpc.dev/docs/metadata Metadata Docs}\n */\n meta(meta) {\n return new DecoratedProcedure({\n ...this[\"~orpc\"],\n meta: mergeMeta(this[\"~orpc\"].meta, meta)\n });\n }\n /**\n * Sets or updates the route definition.\n * The provided route is spared-merged with any existing route.\n * This option is typically relevant when integrating with OpenAPI.\n *\n * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}\n * @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}\n */\n route(route) {\n return new DecoratedProcedure({\n ...this[\"~orpc\"],\n route: mergeRoute(this[\"~orpc\"].route, route)\n });\n }\n use(middleware, mapInput) {\n const mapped = mapInput ? decorateMiddleware(middleware).mapInput(mapInput) : middleware;\n return new DecoratedProcedure({\n ...this[\"~orpc\"],\n middlewares: addMiddleware(this[\"~orpc\"].middlewares, mapped)\n });\n }\n /**\n * Make this procedure callable (works like a function while still being a procedure).\n *\n * @see {@link https://orpc.dev/docs/client/server-side Server-side Client Docs}\n */\n callable(...rest) {\n const client = createProcedureClient(this, ...rest);\n return new Proxy(client, {\n get: (target, key) => {\n return Reflect.has(this, key) ? Reflect.get(this, key) : Reflect.get(target, key);\n },\n has: (target, key) => {\n return Reflect.has(this, key) || Reflect.has(target, key);\n }\n });\n }\n /**\n * Make this procedure compatible with server action.\n *\n * @see {@link https://orpc.dev/docs/server-action Server Action Docs}\n */\n actionable(...rest) {\n const action = createActionableClient(createProcedureClient(this, ...rest));\n return new Proxy(action, {\n get: (target, key) => {\n return Reflect.has(this, key) ? Reflect.get(this, key) : Reflect.get(target, key);\n },\n has: (target, key) => {\n return Reflect.has(this, key) || Reflect.has(target, key);\n }\n });\n }\n}\n\nclass Builder {\n /**\n * This property holds the defined options.\n */\n \"~orpc\";\n constructor(def) {\n this[\"~orpc\"] = def;\n }\n /**\n * Sets or overrides the config.\n *\n * @see {@link https://orpc.dev/docs/client/server-side#middlewares-order Middlewares Order Docs}\n * @see {@link https://orpc.dev/docs/best-practices/dedupe-middleware#configuration Dedupe Middleware Docs}\n */\n $config(config) {\n const inputValidationCount = this[\"~orpc\"].inputValidationIndex - fallbackConfig(\"initialInputValidationIndex\", this[\"~orpc\"].config.initialInputValidationIndex);\n const outputValidationCount = this[\"~orpc\"].outputValidationIndex - fallbackConfig(\"initialOutputValidationIndex\", this[\"~orpc\"].config.initialOutputValidationIndex);\n return new Builder({\n ...this[\"~orpc\"],\n config,\n dedupeLeadingMiddlewares: fallbackConfig(\"dedupeLeadingMiddlewares\", config.dedupeLeadingMiddlewares),\n inputValidationIndex: fallbackConfig(\"initialInputValidationIndex\", config.initialInputValidationIndex) + inputValidationCount,\n outputValidationIndex: fallbackConfig(\"initialOutputValidationIndex\", config.initialOutputValidationIndex) + outputValidationCount\n });\n }\n /**\n * Set or override the initial context.\n *\n * @see {@link https://orpc.dev/docs/context Context Docs}\n */\n $context() {\n return new Builder({\n ...this[\"~orpc\"],\n middlewares: [],\n inputValidationIndex: fallbackConfig(\"initialInputValidationIndex\", this[\"~orpc\"].config.initialInputValidationIndex),\n outputValidationIndex: fallbackConfig(\"initialOutputValidationIndex\", this[\"~orpc\"].config.initialOutputValidationIndex)\n });\n }\n /**\n * Sets or overrides the initial meta.\n *\n * @see {@link https://orpc.dev/docs/metadata Metadata Docs}\n */\n $meta(initialMeta) {\n return new Builder({\n ...this[\"~orpc\"],\n meta: initialMeta\n });\n }\n /**\n * Sets or overrides the initial route.\n * This option is typically relevant when integrating with OpenAPI.\n *\n * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}\n * @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}\n */\n $route(initialRoute) {\n return new Builder({\n ...this[\"~orpc\"],\n route: initialRoute\n });\n }\n /**\n * Sets or overrides the initial input schema.\n *\n * @see {@link https://orpc.dev/docs/procedure#initial-configuration Initial Procedure Configuration Docs}\n */\n $input(initialInputSchema) {\n return new Builder({\n ...this[\"~orpc\"],\n inputSchema: initialInputSchema\n });\n }\n /**\n * Creates a middleware.\n *\n * @see {@link https://orpc.dev/docs/middleware Middleware Docs}\n */\n middleware(middleware) {\n return decorateMiddleware(middleware);\n }\n /**\n * Adds type-safe custom errors.\n * The provided errors are spared-merged with any existing errors.\n *\n * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}\n */\n errors(errors) {\n return new Builder({\n ...this[\"~orpc\"],\n errorMap: mergeErrorMap(this[\"~orpc\"].errorMap, errors)\n });\n }\n use(middleware, mapInput) {\n const mapped = mapInput ? decorateMiddleware(middleware).mapInput(mapInput) : middleware;\n return new Builder({\n ...this[\"~orpc\"],\n middlewares: addMiddleware(this[\"~orpc\"].middlewares, mapped)\n });\n }\n /**\n * Sets or updates the metadata.\n * The provided metadata is spared-merged with any existing metadata.\n *\n * @see {@link https://orpc.dev/docs/metadata Metadata Docs}\n */\n meta(meta) {\n return new Builder({\n ...this[\"~orpc\"],\n meta: mergeMeta(this[\"~orpc\"].meta, meta)\n });\n }\n /**\n * Sets or updates the route definition.\n * The provided route is spared-merged with any existing route.\n * This option is typically relevant when integrating with OpenAPI.\n *\n * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}\n * @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}\n */\n route(route) {\n return new Builder({\n ...this[\"~orpc\"],\n route: mergeRoute(this[\"~orpc\"].route, route)\n });\n }\n /**\n * Defines the input validation schema.\n *\n * @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}\n */\n input(schema) {\n return new Builder({\n ...this[\"~orpc\"],\n inputSchema: schema,\n inputValidationIndex: fallbackConfig(\"initialInputValidationIndex\", this[\"~orpc\"].config.initialInputValidationIndex) + this[\"~orpc\"].middlewares.length\n });\n }\n /**\n * Defines the output validation schema.\n *\n * @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs}\n */\n output(schema) {\n return new Builder({\n ...this[\"~orpc\"],\n outputSchema: schema,\n outputValidationIndex: fallbackConfig(\"initialOutputValidationIndex\", this[\"~orpc\"].config.initialOutputValidationIndex) + this[\"~orpc\"].middlewares.length\n });\n }\n /**\n * Defines the handler of the procedure.\n *\n * @see {@link https://orpc.dev/docs/procedure Procedure Docs}\n */\n handler(handler) {\n return new DecoratedProcedure({\n ...this[\"~orpc\"],\n handler\n });\n }\n /**\n * Prefixes all procedures in the router.\n * The provided prefix is post-appended to any existing router prefix.\n *\n * @note This option does not affect procedures that do not define a path in their route definition.\n *\n * @see {@link https://orpc.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}\n */\n prefix(prefix) {\n return new Builder({\n ...this[\"~orpc\"],\n prefix: mergePrefix(this[\"~orpc\"].prefix, prefix)\n });\n }\n /**\n * Adds tags to all procedures in the router.\n * This helpful when you want to group procedures together in the OpenAPI specification.\n *\n * @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}\n */\n tag(...tags) {\n return new Builder({\n ...this[\"~orpc\"],\n tags: mergeTags(this[\"~orpc\"].tags, tags)\n });\n }\n /**\n * Applies all of the previously defined options to the specified router.\n *\n * @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs}\n */\n router(router) {\n return enhanceRouter(router, this[\"~orpc\"]);\n }\n /**\n * Create a lazy router\n * And applies all of the previously defined options to the specified router.\n *\n * @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs}\n */\n lazy(loader) {\n return enhanceRouter(lazy(loader), this[\"~orpc\"]);\n }\n}\nconst os = new Builder({\n config: {},\n route: {},\n meta: {},\n errorMap: {},\n inputValidationIndex: fallbackConfig(\"initialInputValidationIndex\"),\n outputValidationIndex: fallbackConfig(\"initialOutputValidationIndex\"),\n middlewares: [],\n dedupeLeadingMiddlewares: true\n});\n\nfunction implementerInternal(contract, config, middlewares) {\n if (isContractProcedure(contract)) {\n const impl2 = new Builder({\n ...contract[\"~orpc\"],\n config,\n middlewares,\n inputValidationIndex: fallbackConfig(\"initialInputValidationIndex\", config?.initialInputValidationIndex) + middlewares.length,\n outputValidationIndex: fallbackConfig(\"initialOutputValidationIndex\", config?.initialOutputValidationIndex) + middlewares.length,\n dedupeLeadingMiddlewares: fallbackConfig(\"dedupeLeadingMiddlewares\", config.dedupeLeadingMiddlewares)\n });\n return impl2;\n }\n const impl = new Proxy(contract, {\n get: (target, key) => {\n if (typeof key !== \"string\") {\n return Reflect.get(target, key);\n }\n let method;\n if (key === \"middleware\") {\n method = (mid) => decorateMiddleware(mid);\n } else if (key === \"use\") {\n method = (mid) => {\n return implementerInternal(\n contract,\n config,\n addMiddleware(middlewares, mid)\n );\n };\n } else if (key === \"router\") {\n method = (router) => {\n const adapted = enhanceRouter(router, {\n middlewares,\n errorMap: {},\n prefix: void 0,\n tags: void 0,\n dedupeLeadingMiddlewares: fallbackConfig(\"dedupeLeadingMiddlewares\", config.dedupeLeadingMiddlewares)\n });\n return setHiddenRouterContract(adapted, contract);\n };\n } else if (key === \"lazy\") {\n method = (loader) => {\n const adapted = enhanceRouter(lazy(loader), {\n middlewares,\n errorMap: {},\n prefix: void 0,\n tags: void 0,\n dedupeLeadingMiddlewares: fallbackConfig(\"dedupeLeadingMiddlewares\", config.dedupeLeadingMiddlewares)\n });\n return setHiddenRouterContract(adapted, contract);\n };\n }\n const next = getContractRouter(target, [key]);\n if (!next) {\n return method ?? next;\n }\n const nextImpl = implementerInternal(next, config, middlewares);\n if (method) {\n return new Proxy(method, {\n get(_, key2) {\n return Reflect.get(nextImpl, key2);\n }\n });\n }\n return nextImpl;\n }\n });\n return impl;\n}\nfunction implement(contract, config = {}) {\n const implInternal = implementerInternal(contract, config, []);\n const impl = new Proxy(implInternal, {\n get: (target, key) => {\n let method;\n if (key === \"$context\") {\n method = () => impl;\n } else if (key === \"$config\") {\n method = (config2) => implement(contract, config2);\n }\n const next = Reflect.get(target, key);\n if (!method || !next || typeof next !== \"function\" && typeof next !== \"object\") {\n return method || next;\n }\n return new Proxy(method, {\n get(_, key2) {\n return Reflect.get(next, key2);\n }\n });\n }\n });\n return impl;\n}\n\nfunction inferRPCMethodFromRouter(router) {\n return async (_, path) => {\n const { default: procedure } = await unlazy(getRouter(router, path));\n if (!isProcedure(procedure)) {\n throw new Error(\n `[inferRPCMethodFromRouter] No valid procedure found at path \"${path.join(\".\")}\". This may happen when the router is not properly configured.`\n );\n }\n const method = fallbackContractConfig(\"defaultMethod\", procedure[\"~orpc\"].route.method);\n return method === \"HEAD\" ? \"GET\" : method;\n };\n}\n\nfunction createRouterClient(router, ...rest) {\n const options = resolveMaybeOptionalOptions(rest);\n if (isProcedure(router)) {\n const caller = createProcedureClient(router, options);\n return caller;\n }\n const procedureCaller = isLazy(router) ? createProcedureClient(createAssertedLazyProcedure(router), options) : {};\n const recursive = new Proxy(procedureCaller, {\n get(target, key) {\n if (typeof key !== \"string\") {\n return Reflect.get(target, key);\n }\n const next = getRouter(router, [key]);\n if (!next) {\n return Reflect.get(target, key);\n }\n return createRouterClient(next, {\n ...rest[0],\n path: [...rest[0]?.path ?? [], key]\n });\n }\n });\n return recursive;\n}\n\nexport { Builder, DecoratedProcedure, Procedure, addMiddleware, createActionableClient, createAssertedLazyProcedure, createProcedureClient, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getRouter, implement, implementerInternal, inferRPCMethodFromRouter, isLazy, isProcedure, lazy, os, setHiddenRouterContract, unlazy };\n","import { oc } from \"@orpc/contract\";\nimport z$1, { z } from \"zod\";\nimport { ContentBlockSchema, ContentFieldSchema, MessageStreamEventSchema } from \"@plucky-ai/llm-schemas\";\nimport { eventIterator } from \"@orpc/server\";\nvar apps_default = {\n\tfind: oc.route({\n\t\tmethod: \"GET\",\n\t\tpath: \"/apps/{id}\",\n\t\ttags: [\"Apps\"],\n\t\tsummary: \"Get an app\",\n\t\tdescription: \"Retrieve an app by its ID\"\n\t}).input(z$1.object({ id: z$1.string() })).output(z$1.object({\n\t\tid: z$1.string(),\n\t\tname: z$1.string(),\n\t\tcreatedAt: z$1.coerce.date()\n\t})),\n\tlist: oc.route({\n\t\tmethod: \"GET\",\n\t\tpath: \"/apps\",\n\t\ttags: [\"Apps\"],\n\t\tsummary: \"List apps\",\n\t\tdescription: \"Retrieve all apps\"\n\t}).output(z$1.object({ results: z$1.array(z$1.object({\n\t\tid: z$1.string(),\n\t\tname: z$1.string(),\n\t\tcreatedAt: z$1.coerce.date()\n\t})) }))\n};\n//#endregion\n//#region src/chats.ts\nconst ChatSchema = z$1.object({\n\tid: z$1.string(),\n\ttitle: z$1.string(),\n\tuserId: z$1.string(),\n\tcreatedAt: z$1.coerce.date()\n});\nvar chats_default = {\n\tcreate: oc.route({\n\t\tmethod: \"POST\",\n\t\tpath: \"/chats\",\n\t\ttags: [\"Chats\"],\n\t\tsummary: \"Create a chat\",\n\t\tdescription: \"Create a new chat session\"\n\t}).input(z$1.object({\n\t\ttitle: z$1.string(),\n\t\tuserId: z$1.string().min(1)\n\t})).output(ChatSchema),\n\tfind: oc.route({\n\t\tmethod: \"GET\",\n\t\tpath: \"/chats/{id}\",\n\t\ttags: [\"Chats\"],\n\t\tsummary: \"Get a chat\",\n\t\tdescription: \"Retrieve a chat by its ID\"\n\t}).input(z$1.object({ id: z$1.string() })).output(ChatSchema),\n\tlist: oc.route({\n\t\tmethod: \"GET\",\n\t\tpath: \"/chats\",\n\t\ttags: [\"Chats\"],\n\t\tsummary: \"List chats\",\n\t\tdescription: \"Retrieve all chats with pagination support\"\n\t}).input(z$1.object({\n\t\tuserId: z$1.string().min(1).optional(),\n\t\tlimit: z$1.coerce.number().int().min(1).max(100).default(20),\n\t\tcursor: z$1.string().optional()\n\t})).output(z$1.object({\n\t\tresults: z$1.array(ChatSchema),\n\t\tnextCursor: z$1.string().nullable(),\n\t\thasMore: z$1.boolean()\n\t}))\n};\n//#endregion\n//#region src/messages.ts\nconst MessageSchema = z$1.object({\n\tid: z$1.string(),\n\trole: z$1.enum([\"user\", \"assistant\"]),\n\tcontent: z$1.array(ContentBlockSchema),\n\tcreatedAt: z$1.coerce.date(),\n\terror: z$1.object({\n\t\tcode: z$1.string(),\n\t\tmessage: z$1.string()\n\t}).nullable()\n});\nvar messages_default = { create: oc.route({\n\tmethod: \"POST\",\n\tpath: \"/messages\",\n\ttags: [\"Messages\"],\n\tsummary: \"Create a message\",\n\tdescription: \"Create a user message in a chat\"\n}).input(z$1.object({\n\tid: z$1.string().optional(),\n\tchatId: z$1.string(),\n\tcontent: ContentFieldSchema\n})).output(MessageSchema) };\n//#endregion\n//#region src/responses.ts\nconst toolSchema = z$1.object({\n\tname: z$1.string(),\n\tdescription: z$1.string(),\n\tdefaultLoadingText: z$1.string().nullish(),\n\tdefaultSuccessText: z$1.string().nullish(),\n\tinputSchema: z$1.any().optional()\n});\nvar responses_default = { create: oc.route({\n\tmethod: \"POST\",\n\tpath: \"/responses\",\n\ttags: [\"Responses\"],\n\tsummary: \"Create a response\",\n\tdescription: \"Send a user message to a chat and stream the assistant response. Returns a Server-Sent Events (SSE) stream of message events.\",\n\tsuccessDescription: \"SSE stream of message events (message_start, content_block_delta, message_delta, message_stop, etc.).\"\n}).input(z$1.object({\n\tid: z$1.string().optional().describe(\"Optional client-generated message ID.\"),\n\tchatId: z$1.string().describe(\"The chat ID to send the message to.\"),\n\tcontent: ContentFieldSchema.describe(\"The message content (text or structured blocks).\"),\n\ttools: z$1.array(toolSchema).default([]).describe(\"Tools available to the assistant for this request.\"),\n\ttags: z$1.array(z$1.string()).optional().describe(\"Tags to attach to this response.\"),\n\tmodel: z$1.string().optional().describe(\"Override the model for this request.\")\n})).output(eventIterator(MessageStreamEventSchema)) };\n//#endregion\n//#region src/headers.ts\n/**\n* Header name constants for the public API\n*/\nconst API_KEY_HEADER = \"x-api-key\";\n/**\n* Schema for the API key header\n* API keys are prefixed with 'sk_' (secret key)\n*/\nconst ApiKeyHeaderSchema = z.string().min(1, \"API key is required\");\n/**\n* Combined headers schema for all API requests\n*/\nconst ApiHeadersSchema = z.object({ [API_KEY_HEADER]: ApiKeyHeaderSchema });\n//#endregion\n//#region src/index.ts\nconst contract = {\n\tapps: apps_default,\n\tchats: chats_default,\n\tmessages: messages_default,\n\tresponses: responses_default\n};\n//#endregion\nexport { ApiKeyHeaderSchema as i, API_KEY_HEADER as n, ApiHeadersSchema as r, contract as t };\n\n//# sourceMappingURL=src-bLbxYIy4.mjs.map","/**\n * @plucky-ai/node - Official Node.js SDK for the Plucky API\n *\n * @example\n * ```ts\n * import Plucky from '@plucky-ai/node'\n *\n * const plucky = new Plucky({\n * apiKey: 'sk_...',\n * })\n *\n * // List all chats\n * const { results } = await plucky.chats.list()\n *\n * // Create a new chat\n * const chat = await plucky.chats.create({ title: 'New Chat' })\n * ```\n */\n\nexport {\n createApiClient,\n type ApiClient,\n type CreateApiClientOptions,\n} from '@plucky-ai/api-contracts/client'\n\nexport { API_KEY_HEADER, contract } from '@plucky-ai/api-contracts'\n\nimport {\n createApiClient,\n type ApiClient,\n type CreateApiClientOptions,\n} from '@plucky-ai/api-contracts/client'\n\nconst DEFAULT_BASE_URL = 'https://api.plucky.ai'\n\nexport interface PluckyOptions {\n /**\n * Your Plucky API key (starts with 'sk_')\n */\n apiKey: string\n /**\n * Base URL of the Plucky API\n * @default 'https://api.plucky.ai'\n */\n baseUrl?: string\n /**\n * Optional custom fetch implementation for advanced use cases\n */\n fetch?: typeof fetch\n}\n\n/**\n * Plucky API client for Node.js\n *\n * @example\n * ```ts\n * import Plucky from '@plucky-ai/node'\n *\n * const plucky = new Plucky({ apiKey: 'sk_...' })\n *\n * const chats = await plucky.chats.list()\n * ```\n */\nexport class Plucky {\n private client: ApiClient\n\n /**\n * Access to chat operations\n */\n public readonly chats: ApiClient['chats']\n\n /**\n * Access to app operations\n */\n public readonly apps: ApiClient['apps']\n\n constructor(options: PluckyOptions) {\n const { apiKey, baseUrl = DEFAULT_BASE_URL, fetch: customFetch } = options\n\n if (!apiKey) {\n throw new Error('API key is required. Get one at https://app.plucky.ai')\n }\n\n const clientOptions: CreateApiClientOptions = {\n apiKey,\n baseUrl,\n fetch: customFetch,\n }\n\n this.client = createApiClient(clientOptions)\n\n // Expose API resources\n this.chats = this.client.chats\n this.apps = this.client.apps\n }\n\n /**\n * Get the underlying API client for advanced use cases\n */\n get api(): ApiClient {\n return this.client\n }\n}\n\nexport default Plucky\n"],"x_google_ignoreList":[1,2,3,4],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,yBAAyBA,IAAAA,EAAE,OAAO;CACvC,MAAMA,IAAAA,EAAE,QAAQ,OAAO;CACvB,MAAMA,IAAAA,EAAE,QAAQ;CAChB,CAAC;AACF,MAAM,4BAA4BA,IAAAA,EAAE,OAAO;CAC1C,MAAMA,IAAAA,EAAE,QAAQ,WAAW;CAC3B,IAAIA,IAAAA,EAAE,QAAQ;CACd,MAAMA,IAAAA,EAAE,QAAQ;CAChB,OAAOA,IAAAA,EAAE,SAAS;CAClB,oBAAoBA,IAAAA,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;CACpD,oBAAoBA,IAAAA,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;CACpD,cAAcA,IAAAA,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;CAC9C,CAAC;AACF,MAAM,+BAA+BA,IAAAA,EAAE,OAAO;CAC7C,MAA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G,iBAAiB,oBAAoB,CAAC;AAG3E,MAAM,WAAW;CAChB,MAAM;CACN,OAAO;CACP,UAAU;CACV,WAAW;CACX;;;AC1GD,MAAM,mBAAmB;;;;;;;;;;;;;AA8BzB,IAAa,SAAb,MAAoB;CAClB;;;;CAKA;;;;CAKA;CAEA,YAAY,SAAwB;EAClC,MAAM,EAAE,QAAQ,UAAU,kBAAkB,OAAO,gBAAgB;AAEnE,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,wDAAwD;AAS1E,OAAK,UAAA,GAAA,gCAAA,iBANyC;GAC5C;GACA;GACA,OAAO;GACR,CAE2C;AAG5C,OAAK,QAAQ,KAAK,OAAO;AACzB,OAAK,OAAO,KAAK,OAAO;;;;;CAM1B,IAAI,MAAiB;AACnB,SAAO,KAAK"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,363 @@
|
|
|
1
1
|
import { ApiClient, ApiClient as ApiClient$1, CreateApiClientOptions, createApiClient } from "@plucky-ai/api-contracts/client";
|
|
2
|
-
import
|
|
2
|
+
import * as _orpc_contract0 from "@orpc/contract";
|
|
3
|
+
import * as zod from "zod";
|
|
4
|
+
import * as _orpc_client0 from "@orpc/client";
|
|
5
|
+
import * as zod_v4_core0 from "zod/v4/core";
|
|
3
6
|
|
|
7
|
+
//#region ../api-contracts/dist/index.d.mts
|
|
8
|
+
//#region src/headers.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Header name constants for the public API
|
|
11
|
+
*/
|
|
12
|
+
declare const API_KEY_HEADER = "x-api-key";
|
|
13
|
+
/**
|
|
14
|
+
* Schema for the API key header
|
|
15
|
+
* API keys are prefixed with 'sk_' (secret key)
|
|
16
|
+
*/
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/index.d.ts
|
|
19
|
+
declare const contract: {
|
|
20
|
+
apps: {
|
|
21
|
+
find: _orpc_contract0.ContractProcedureBuilderWithInputOutput<zod.ZodObject<{
|
|
22
|
+
id: zod.ZodString;
|
|
23
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
24
|
+
id: zod.ZodString;
|
|
25
|
+
name: zod.ZodString;
|
|
26
|
+
createdAt: zod.ZodCoercedDate<unknown>;
|
|
27
|
+
}, zod_v4_core0.$strip>, Record<never, never>, Record<never, never>>;
|
|
28
|
+
list: _orpc_contract0.ContractProcedureBuilderWithOutput<_orpc_contract0.Schema<unknown, unknown>, zod.ZodObject<{
|
|
29
|
+
results: zod.ZodArray<zod.ZodObject<{
|
|
30
|
+
id: zod.ZodString;
|
|
31
|
+
name: zod.ZodString;
|
|
32
|
+
createdAt: zod.ZodCoercedDate<unknown>;
|
|
33
|
+
}, zod_v4_core0.$strip>>;
|
|
34
|
+
}, zod_v4_core0.$strip>, Record<never, never>, Record<never, never>>;
|
|
35
|
+
};
|
|
36
|
+
chats: {
|
|
37
|
+
create: _orpc_contract0.ContractProcedureBuilderWithInputOutput<zod.ZodObject<{
|
|
38
|
+
title: zod.ZodString;
|
|
39
|
+
userId: zod.ZodString;
|
|
40
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
41
|
+
id: zod.ZodString;
|
|
42
|
+
title: zod.ZodString;
|
|
43
|
+
userId: zod.ZodString;
|
|
44
|
+
createdAt: zod.ZodCoercedDate<unknown>;
|
|
45
|
+
}, zod_v4_core0.$strip>, Record<never, never>, Record<never, never>>;
|
|
46
|
+
find: _orpc_contract0.ContractProcedureBuilderWithInputOutput<zod.ZodObject<{
|
|
47
|
+
id: zod.ZodString;
|
|
48
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
49
|
+
id: zod.ZodString;
|
|
50
|
+
title: zod.ZodString;
|
|
51
|
+
userId: zod.ZodString;
|
|
52
|
+
createdAt: zod.ZodCoercedDate<unknown>;
|
|
53
|
+
}, zod_v4_core0.$strip>, Record<never, never>, Record<never, never>>;
|
|
54
|
+
list: _orpc_contract0.ContractProcedureBuilderWithInputOutput<zod.ZodObject<{
|
|
55
|
+
userId: zod.ZodOptional<zod.ZodString>;
|
|
56
|
+
limit: zod.ZodDefault<zod.ZodCoercedNumber<unknown>>;
|
|
57
|
+
cursor: zod.ZodOptional<zod.ZodString>;
|
|
58
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
59
|
+
results: zod.ZodArray<zod.ZodObject<{
|
|
60
|
+
id: zod.ZodString;
|
|
61
|
+
title: zod.ZodString;
|
|
62
|
+
userId: zod.ZodString;
|
|
63
|
+
createdAt: zod.ZodCoercedDate<unknown>;
|
|
64
|
+
}, zod_v4_core0.$strip>>;
|
|
65
|
+
nextCursor: zod.ZodNullable<zod.ZodString>;
|
|
66
|
+
hasMore: zod.ZodBoolean;
|
|
67
|
+
}, zod_v4_core0.$strip>, Record<never, never>, Record<never, never>>;
|
|
68
|
+
};
|
|
69
|
+
messages: {
|
|
70
|
+
create: _orpc_contract0.ContractProcedureBuilderWithInputOutput<zod.ZodObject<{
|
|
71
|
+
id: zod.ZodOptional<zod.ZodString>;
|
|
72
|
+
chatId: zod.ZodString;
|
|
73
|
+
content: zod.ZodUnion<readonly [zod.ZodString, zod.ZodArray<zod.ZodUnion<readonly [zod.ZodObject<{
|
|
74
|
+
type: zod.ZodLiteral<"text">;
|
|
75
|
+
text: zod.ZodString;
|
|
76
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
77
|
+
type: zod.ZodLiteral<"tool_use">;
|
|
78
|
+
id: zod.ZodString;
|
|
79
|
+
name: zod.ZodString;
|
|
80
|
+
input: zod.ZodUnknown;
|
|
81
|
+
defaultLoadingText: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
82
|
+
defaultSuccessText: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
83
|
+
partial_json: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
84
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
85
|
+
type: zod.ZodLiteral<"tool_result">;
|
|
86
|
+
toolUseId: zod.ZodString;
|
|
87
|
+
content: zod.ZodString;
|
|
88
|
+
successText: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
89
|
+
}, zod_v4_core0.$strip>]>>]>;
|
|
90
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
91
|
+
id: zod.ZodString;
|
|
92
|
+
role: zod.ZodEnum<{
|
|
93
|
+
user: "user";
|
|
94
|
+
assistant: "assistant";
|
|
95
|
+
}>;
|
|
96
|
+
content: zod.ZodArray<zod.ZodUnion<readonly [zod.ZodObject<{
|
|
97
|
+
type: zod.ZodLiteral<"text">;
|
|
98
|
+
text: zod.ZodString;
|
|
99
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
100
|
+
type: zod.ZodLiteral<"tool_use">;
|
|
101
|
+
id: zod.ZodString;
|
|
102
|
+
name: zod.ZodString;
|
|
103
|
+
input: zod.ZodUnknown;
|
|
104
|
+
defaultLoadingText: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
105
|
+
defaultSuccessText: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
106
|
+
partial_json: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
107
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
108
|
+
type: zod.ZodLiteral<"tool_result">;
|
|
109
|
+
toolUseId: zod.ZodString;
|
|
110
|
+
content: zod.ZodString;
|
|
111
|
+
successText: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
112
|
+
}, zod_v4_core0.$strip>]>>;
|
|
113
|
+
createdAt: zod.ZodCoercedDate<unknown>;
|
|
114
|
+
error: zod.ZodNullable<zod.ZodObject<{
|
|
115
|
+
code: zod.ZodString;
|
|
116
|
+
message: zod.ZodString;
|
|
117
|
+
}, zod_v4_core0.$strip>>;
|
|
118
|
+
}, zod_v4_core0.$strip>, Record<never, never>, Record<never, never>>;
|
|
119
|
+
};
|
|
120
|
+
responses: {
|
|
121
|
+
create: _orpc_contract0.ContractProcedureBuilderWithInputOutput<zod.ZodObject<{
|
|
122
|
+
id: zod.ZodOptional<zod.ZodString>;
|
|
123
|
+
chatId: zod.ZodString;
|
|
124
|
+
content: zod.ZodUnion<readonly [zod.ZodString, zod.ZodArray<zod.ZodUnion<readonly [zod.ZodObject<{
|
|
125
|
+
type: zod.ZodLiteral<"text">;
|
|
126
|
+
text: zod.ZodString;
|
|
127
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
128
|
+
type: zod.ZodLiteral<"tool_use">;
|
|
129
|
+
id: zod.ZodString;
|
|
130
|
+
name: zod.ZodString;
|
|
131
|
+
input: zod.ZodUnknown;
|
|
132
|
+
defaultLoadingText: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
133
|
+
defaultSuccessText: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
134
|
+
partial_json: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
135
|
+
}, zod_v4_core0.$strip>, zod.ZodObject<{
|
|
136
|
+
type: zod.ZodLiteral<"tool_result">;
|
|
137
|
+
toolUseId: zod.ZodString;
|
|
138
|
+
content: zod.ZodString;
|
|
139
|
+
successText: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
140
|
+
}, zod_v4_core0.$strip>]>>]>;
|
|
141
|
+
tools: zod.ZodDefault<zod.ZodArray<zod.ZodObject<{
|
|
142
|
+
name: zod.ZodString;
|
|
143
|
+
description: zod.ZodString;
|
|
144
|
+
defaultLoadingText: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
145
|
+
defaultSuccessText: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
146
|
+
inputSchema: zod.ZodOptional<zod.ZodAny>;
|
|
147
|
+
}, zod_v4_core0.$strip>>>;
|
|
148
|
+
tags: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
|
|
149
|
+
model: zod.ZodOptional<zod.ZodString>;
|
|
150
|
+
}, zod_v4_core0.$strip>, _orpc_contract0.Schema<AsyncIteratorObject<{
|
|
151
|
+
type: "message_start";
|
|
152
|
+
data: {
|
|
153
|
+
type: "message_start";
|
|
154
|
+
message: {
|
|
155
|
+
id: string;
|
|
156
|
+
role: "user" | "assistant";
|
|
157
|
+
content: ({
|
|
158
|
+
type: "text";
|
|
159
|
+
text: string;
|
|
160
|
+
} | {
|
|
161
|
+
type: "tool_use";
|
|
162
|
+
id: string;
|
|
163
|
+
name: string;
|
|
164
|
+
input: unknown;
|
|
165
|
+
defaultLoadingText?: string | null | undefined;
|
|
166
|
+
defaultSuccessText?: string | null | undefined;
|
|
167
|
+
partial_json?: string | null | undefined;
|
|
168
|
+
} | {
|
|
169
|
+
type: "tool_result";
|
|
170
|
+
toolUseId: string;
|
|
171
|
+
content: string;
|
|
172
|
+
successText?: string | null | undefined;
|
|
173
|
+
})[];
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
} | {
|
|
177
|
+
type: "message_delta";
|
|
178
|
+
data: {
|
|
179
|
+
type: "message_delta";
|
|
180
|
+
delta: {
|
|
181
|
+
stop_reason: "tool_use" | "end_turn";
|
|
182
|
+
stop_sequence: string | null;
|
|
183
|
+
};
|
|
184
|
+
usage?: {
|
|
185
|
+
inputTokens: number;
|
|
186
|
+
outputTokens: number;
|
|
187
|
+
cacheReadInputTokens?: number | undefined;
|
|
188
|
+
cacheCreationInputTokens?: number | undefined;
|
|
189
|
+
} | undefined;
|
|
190
|
+
};
|
|
191
|
+
} | {
|
|
192
|
+
type: "message_stop";
|
|
193
|
+
data: {
|
|
194
|
+
type: "message_stop";
|
|
195
|
+
};
|
|
196
|
+
} | {
|
|
197
|
+
type: "content_block_start";
|
|
198
|
+
data: {
|
|
199
|
+
type: "content_block_start";
|
|
200
|
+
index: number;
|
|
201
|
+
contentBlock: {
|
|
202
|
+
type: "text";
|
|
203
|
+
text: string;
|
|
204
|
+
} | {
|
|
205
|
+
type: "tool_use";
|
|
206
|
+
id: string;
|
|
207
|
+
name: string;
|
|
208
|
+
input: unknown;
|
|
209
|
+
defaultLoadingText?: string | null | undefined;
|
|
210
|
+
defaultSuccessText?: string | null | undefined;
|
|
211
|
+
partial_json?: string | null | undefined;
|
|
212
|
+
} | {
|
|
213
|
+
type: "tool_result";
|
|
214
|
+
toolUseId: string;
|
|
215
|
+
content: string;
|
|
216
|
+
successText?: string | null | undefined;
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
} | {
|
|
220
|
+
type: "content_block_delta";
|
|
221
|
+
data: {
|
|
222
|
+
type: "content_block_delta";
|
|
223
|
+
index: number;
|
|
224
|
+
delta: {
|
|
225
|
+
type: "text_delta";
|
|
226
|
+
text: string;
|
|
227
|
+
} | {
|
|
228
|
+
type: "input_json_delta";
|
|
229
|
+
partial_json: string;
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
} | {
|
|
233
|
+
type: "content_block_stop";
|
|
234
|
+
data: {
|
|
235
|
+
type: "content_block_stop";
|
|
236
|
+
index: number;
|
|
237
|
+
};
|
|
238
|
+
} | {
|
|
239
|
+
type: "error";
|
|
240
|
+
data: {
|
|
241
|
+
type: "error";
|
|
242
|
+
error: {
|
|
243
|
+
code: string;
|
|
244
|
+
message: string;
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
} | {
|
|
248
|
+
type: "ping";
|
|
249
|
+
data: {
|
|
250
|
+
type: "ping";
|
|
251
|
+
timestamp: number;
|
|
252
|
+
};
|
|
253
|
+
}, unknown, void>, _orpc_client0.AsyncIteratorClass<{
|
|
254
|
+
type: "message_start";
|
|
255
|
+
data: {
|
|
256
|
+
type: "message_start";
|
|
257
|
+
message: {
|
|
258
|
+
id: string;
|
|
259
|
+
role: "user" | "assistant";
|
|
260
|
+
content: ({
|
|
261
|
+
type: "text";
|
|
262
|
+
text: string;
|
|
263
|
+
} | {
|
|
264
|
+
type: "tool_use";
|
|
265
|
+
id: string;
|
|
266
|
+
name: string;
|
|
267
|
+
input: unknown;
|
|
268
|
+
defaultLoadingText?: string | null | undefined;
|
|
269
|
+
defaultSuccessText?: string | null | undefined;
|
|
270
|
+
partial_json?: string | null | undefined;
|
|
271
|
+
} | {
|
|
272
|
+
type: "tool_result";
|
|
273
|
+
toolUseId: string;
|
|
274
|
+
content: string;
|
|
275
|
+
successText?: string | null | undefined;
|
|
276
|
+
})[];
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
} | {
|
|
280
|
+
type: "message_delta";
|
|
281
|
+
data: {
|
|
282
|
+
type: "message_delta";
|
|
283
|
+
delta: {
|
|
284
|
+
stop_reason: "tool_use" | "end_turn";
|
|
285
|
+
stop_sequence: string | null;
|
|
286
|
+
};
|
|
287
|
+
usage?: {
|
|
288
|
+
inputTokens: number;
|
|
289
|
+
outputTokens: number;
|
|
290
|
+
cacheReadInputTokens?: number | undefined;
|
|
291
|
+
cacheCreationInputTokens?: number | undefined;
|
|
292
|
+
} | undefined;
|
|
293
|
+
};
|
|
294
|
+
} | {
|
|
295
|
+
type: "message_stop";
|
|
296
|
+
data: {
|
|
297
|
+
type: "message_stop";
|
|
298
|
+
};
|
|
299
|
+
} | {
|
|
300
|
+
type: "content_block_start";
|
|
301
|
+
data: {
|
|
302
|
+
type: "content_block_start";
|
|
303
|
+
index: number;
|
|
304
|
+
contentBlock: {
|
|
305
|
+
type: "text";
|
|
306
|
+
text: string;
|
|
307
|
+
} | {
|
|
308
|
+
type: "tool_use";
|
|
309
|
+
id: string;
|
|
310
|
+
name: string;
|
|
311
|
+
input: unknown;
|
|
312
|
+
defaultLoadingText?: string | null | undefined;
|
|
313
|
+
defaultSuccessText?: string | null | undefined;
|
|
314
|
+
partial_json?: string | null | undefined;
|
|
315
|
+
} | {
|
|
316
|
+
type: "tool_result";
|
|
317
|
+
toolUseId: string;
|
|
318
|
+
content: string;
|
|
319
|
+
successText?: string | null | undefined;
|
|
320
|
+
};
|
|
321
|
+
};
|
|
322
|
+
} | {
|
|
323
|
+
type: "content_block_delta";
|
|
324
|
+
data: {
|
|
325
|
+
type: "content_block_delta";
|
|
326
|
+
index: number;
|
|
327
|
+
delta: {
|
|
328
|
+
type: "text_delta";
|
|
329
|
+
text: string;
|
|
330
|
+
} | {
|
|
331
|
+
type: "input_json_delta";
|
|
332
|
+
partial_json: string;
|
|
333
|
+
};
|
|
334
|
+
};
|
|
335
|
+
} | {
|
|
336
|
+
type: "content_block_stop";
|
|
337
|
+
data: {
|
|
338
|
+
type: "content_block_stop";
|
|
339
|
+
index: number;
|
|
340
|
+
};
|
|
341
|
+
} | {
|
|
342
|
+
type: "error";
|
|
343
|
+
data: {
|
|
344
|
+
type: "error";
|
|
345
|
+
error: {
|
|
346
|
+
code: string;
|
|
347
|
+
message: string;
|
|
348
|
+
};
|
|
349
|
+
};
|
|
350
|
+
} | {
|
|
351
|
+
type: "ping";
|
|
352
|
+
data: {
|
|
353
|
+
type: "ping";
|
|
354
|
+
timestamp: number;
|
|
355
|
+
};
|
|
356
|
+
}, unknown, void>>, Record<never, never>, Record<never, never>>;
|
|
357
|
+
};
|
|
358
|
+
}; //#endregion
|
|
359
|
+
//#endregion
|
|
4
360
|
//#region src/index.d.ts
|
|
5
|
-
|
|
6
361
|
interface PluckyOptions {
|
|
7
362
|
/**
|
|
8
363
|
* Your Plucky API key (starts with 'sk_')
|