@dereekb/openrouter 13.37.0
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/LICENSE +21 -0
- package/README.md +195 -0
- package/firebase/index.cjs.default.js +1 -0
- package/firebase/index.cjs.js +666 -0
- package/firebase/index.cjs.mjs +2 -0
- package/firebase/index.d.ts +1 -0
- package/firebase/index.esm.js +626 -0
- package/firebase/package.json +25 -0
- package/firebase/src/index.d.ts +1 -0
- package/firebase/src/lib/index.d.ts +4 -0
- package/firebase/src/lib/openrouter.api.d.ts +226 -0
- package/firebase/src/lib/openrouter.id.d.ts +56 -0
- package/firebase/src/lib/openrouter.model.d.ts +609 -0
- package/firebase/src/lib/openrouter.query.d.ts +121 -0
- package/firebase-server/index.cjs.default.js +1 -0
- package/firebase-server/index.cjs.js +4520 -0
- package/firebase-server/index.cjs.mjs +2 -0
- package/firebase-server/index.d.ts +1 -0
- package/firebase-server/index.esm.js +4466 -0
- package/firebase-server/package.json +38 -0
- package/firebase-server/src/index.d.ts +1 -0
- package/firebase-server/src/lib/index.d.ts +10 -0
- package/firebase-server/src/lib/openrouter.action.server.d.ts +196 -0
- package/firebase-server/src/lib/openrouter.broadcast.d.ts +93 -0
- package/firebase-server/src/lib/openrouter.call.inline.d.ts +57 -0
- package/firebase-server/src/lib/openrouter.file.attachment.d.ts +97 -0
- package/firebase-server/src/lib/openrouter.module.d.ts +65 -0
- package/firebase-server/src/lib/openrouter.prompt.service.d.ts +109 -0
- package/firebase-server/src/lib/openrouter.runtask.handle.d.ts +56 -0
- package/firebase-server/src/lib/openrouter.runtask.service.d.ts +380 -0
- package/firebase-server/src/lib/openrouter.runtask.sweep.d.ts +170 -0
- package/firebase-server/src/lib/openrouter.state.accessor.d.ts +106 -0
- package/firebase-server/src/test/openrouter.fake.d.ts +134 -0
- package/index.cjs.default.js +1 -0
- package/index.cjs.js +1867 -0
- package/index.cjs.mjs +2 -0
- package/index.d.ts +1 -0
- package/index.esm.js +1771 -0
- package/package.json +32 -0
- package/src/index.d.ts +1 -0
- package/src/lib/index.d.ts +10 -0
- package/src/lib/openrouter.call.d.ts +268 -0
- package/src/lib/openrouter.config.d.ts +314 -0
- package/src/lib/openrouter.embedding.d.ts +87 -0
- package/src/lib/openrouter.generation.d.ts +46 -0
- package/src/lib/openrouter.input.d.ts +238 -0
- package/src/lib/openrouter.prompt.d.ts +79 -0
- package/src/lib/openrouter.request.d.ts +91 -0
- package/src/lib/openrouter.sdk.d.ts +37 -0
- package/src/lib/openrouter.tool.d.ts +99 -0
- package/src/lib/openrouter.type.d.ts +125 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { type Maybe } from '@dereekb/util';
|
|
2
|
+
/**
|
|
3
|
+
* A model slug/id as used by OpenRouter (e.g. `openai/gpt-5.1`).
|
|
4
|
+
*
|
|
5
|
+
* NOTE: `@dereekb/nestjs/openrouter` declares a type-identical alias of the same name. The two are
|
|
6
|
+
* deliberately not shared: importing this package from there would put an edge from the `nestjs`
|
|
7
|
+
* build pipeline into this one, and this package's `firebase-server` entry already depends on
|
|
8
|
+
* `@dereekb/nestjs/openrouter`. They are plain string aliases, so values cross the boundary freely.
|
|
9
|
+
*/
|
|
10
|
+
export type OpenRouterModelId = string;
|
|
11
|
+
/**
|
|
12
|
+
* A generation id returned by OpenRouter for a completed request.
|
|
13
|
+
*
|
|
14
|
+
* See the note on {@link OpenRouterModelId} regarding the twin in `@dereekb/nestjs/openrouter`.
|
|
15
|
+
*/
|
|
16
|
+
export type OpenRouterGenerationId = string;
|
|
17
|
+
/**
|
|
18
|
+
* The stable, human-readable key of an OpenRouterPrompt. Doubles as the prompt's Firestore document
|
|
19
|
+
* id, replacing OpenAI's opaque `pmpt_…` identifiers.
|
|
20
|
+
*
|
|
21
|
+
* Example: `kaia-resume-parser`.
|
|
22
|
+
*/
|
|
23
|
+
export type OpenRouterPromptKey = string;
|
|
24
|
+
/**
|
|
25
|
+
* A published version number of an OpenRouterPrompt. Monotonically increasing from 1.
|
|
26
|
+
*/
|
|
27
|
+
export type OpenRouterPromptVersionNumber = number;
|
|
28
|
+
/**
|
|
29
|
+
* The caller-supplied key of an OpenRouterRunTask. Doubles as the run task's Firestore document id,
|
|
30
|
+
* and is the value stored wherever an OpenAI `responseId` is stored today.
|
|
31
|
+
*
|
|
32
|
+
* Callers are expected to derive this deterministically (e.g. from a NotificationTask's model key)
|
|
33
|
+
* so re-entering the checkpoint that enqueued it reuses the same document instead of queueing a
|
|
34
|
+
* duplicate run.
|
|
35
|
+
*/
|
|
36
|
+
export type OpenRouterRunTaskKey = string;
|
|
37
|
+
/**
|
|
38
|
+
* Identifier of a deferred tool call, chosen by the system that will eventually resolve it.
|
|
39
|
+
*
|
|
40
|
+
* OpenRouter does not allocate these — `ctx.defer(taskId)` takes whatever the caller passes.
|
|
41
|
+
*/
|
|
42
|
+
export type OpenRouterDeferredToolTaskId = string;
|
|
43
|
+
/**
|
|
44
|
+
* A GCS object path (no bucket, no signed query string) of a file to send with a request.
|
|
45
|
+
*
|
|
46
|
+
* Stored rather than a signed URL so the URL can be minted per attempt — see
|
|
47
|
+
* {@link OpenRouterFileReference}.
|
|
48
|
+
*/
|
|
49
|
+
export type OpenRouterFileStoragePath = string;
|
|
50
|
+
/**
|
|
51
|
+
* The `hash` OpenRouter returns on a `file-parser` annotation, identifying an already-parsed file.
|
|
52
|
+
*/
|
|
53
|
+
export type OpenRouterFileAnnotationHash = string;
|
|
54
|
+
/**
|
|
55
|
+
* A reference to a file to send with a request.
|
|
56
|
+
*
|
|
57
|
+
* This type exists BECAUSE of the constraint, so this is where the constraint is stated: the path is
|
|
58
|
+
* stored, never a signed URL. A run task can sit queued for a sweep interval, be retried, and (with
|
|
59
|
+
* deferred tools) resume much later, so a URL minted at enqueue time would 403 by the time it was used.
|
|
60
|
+
* The runner signs the path fresh on every attempt instead.
|
|
61
|
+
*/
|
|
62
|
+
export interface OpenRouterFileReference {
|
|
63
|
+
/**
|
|
64
|
+
* GCS object path of the file.
|
|
65
|
+
*/
|
|
66
|
+
readonly storagePath: OpenRouterFileStoragePath;
|
|
67
|
+
/**
|
|
68
|
+
* Filename to present to the model. Its extension is what tells OpenRouter how to treat the file.
|
|
69
|
+
*/
|
|
70
|
+
readonly filename: string;
|
|
71
|
+
/**
|
|
72
|
+
* Optional bucket override, for a file that does not live in the app's default bucket.
|
|
73
|
+
*/
|
|
74
|
+
readonly bucket?: Maybe<string>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A cached `file-parser` annotation, as returned on a response and resubmitted on a later request to
|
|
78
|
+
* skip re-parsing the same file.
|
|
79
|
+
*
|
|
80
|
+
* This is the canonical statement of what a re-parse costs, and why caching one is worth a persisted
|
|
81
|
+
* field: under `mistral-ocr` it is $2/1,000 pages, and under any engine it is the latency of reading a
|
|
82
|
+
* document we have already read.
|
|
83
|
+
*/
|
|
84
|
+
export interface OpenRouterFileAnnotation {
|
|
85
|
+
/**
|
|
86
|
+
* The file hash OpenRouter assigned to the parsed file.
|
|
87
|
+
*/
|
|
88
|
+
readonly hash: OpenRouterFileAnnotationHash;
|
|
89
|
+
/**
|
|
90
|
+
* Filename the annotation is for.
|
|
91
|
+
*/
|
|
92
|
+
readonly filename?: Maybe<string>;
|
|
93
|
+
/**
|
|
94
|
+
* The parsed content, verbatim as returned.
|
|
95
|
+
*/
|
|
96
|
+
readonly content?: Maybe<unknown>;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Token/cost usage of a run, flattened from OpenRouter's `usage` object.
|
|
100
|
+
*/
|
|
101
|
+
export interface OpenRouterRunUsage {
|
|
102
|
+
readonly inputTokens?: Maybe<number>;
|
|
103
|
+
readonly outputTokens?: Maybe<number>;
|
|
104
|
+
readonly totalTokens?: Maybe<number>;
|
|
105
|
+
readonly reasoningTokens?: Maybe<number>;
|
|
106
|
+
readonly cachedTokens?: Maybe<number>;
|
|
107
|
+
/**
|
|
108
|
+
* Total cost in USD, as reported by OpenRouter.
|
|
109
|
+
*
|
|
110
|
+
* Finalised server-side, so a value written by the runner may be refined later by the broadcast
|
|
111
|
+
* webhook.
|
|
112
|
+
*/
|
|
113
|
+
readonly cost?: Maybe<number>;
|
|
114
|
+
/**
|
|
115
|
+
* Whether the generation ran on a bring-your-own-key upstream credential.
|
|
116
|
+
*/
|
|
117
|
+
readonly isByok?: Maybe<boolean>;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* An error recorded on a failed run.
|
|
121
|
+
*/
|
|
122
|
+
export interface OpenRouterRunError {
|
|
123
|
+
readonly code?: Maybe<string>;
|
|
124
|
+
readonly message?: Maybe<string>;
|
|
125
|
+
}
|