@originatedev/run-sdk 0.1.1 → 0.1.2

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 ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -4,7 +4,7 @@ The backend SDK for Run, Originate's managed service. It reports what Originate
4
4
 
5
5
  It never sends prompts, completions, request bodies, headers or user content. See "What is sent" below.
6
6
 
7
- Node 18 or newer. No runtime dependencies. ESM.
7
+ Node 18 or newer. No runtime dependencies. Works with `import` and with `require`.
8
8
 
9
9
  ## Install
10
10
 
@@ -39,6 +39,36 @@ Before `init()` ran the singleton is a disabled client: calls are no-ops and not
39
39
 
40
40
  Timers are unref'd, so the SDK never keeps your process alive. Queues are bounded (oldest dropped on a long outage) and every delivery is retried three times with backoff; 4xx answers are not retried.
41
41
 
42
+ ### CommonJS
43
+
44
+ ```js
45
+ const { init, ai } = require('@originatedev/run-sdk');
46
+ ```
47
+
48
+ The sub-paths (`/express`, `/fastify`, `/otel`) load the same way. Use one style per process: a process that loads the package both with `import` and with `require` gets two separate clients, and `init()` on one does not configure the other.
49
+
50
+ ### Serverless (Vercel, Lambda, Cloud Run with CPU only during requests)
51
+
52
+ A function can be frozen the moment it answers, so the background timers may never fire and queued rows are lost. Turn the timers off and send before you return:
53
+
54
+ ```ts
55
+ const run = init({ key: process.env.ORIGINATE_RUN_KEY!, flushIntervalMs: 0, heartbeatIntervalMs: 0, requestTimeoutMs: 3000 });
56
+
57
+ export async function handler(event) {
58
+ const result = await doTheWork(event);
59
+ await run.flush(); // sends everything queued; never throws
60
+ return result;
61
+ }
62
+ ```
63
+
64
+ `flush()` waits for delivery, including the retries. When Originate is slow or unreachable that can take several seconds, so bound it if the wait matters, and consider skipping reports for a while after one that timed out:
65
+
66
+ ```ts
67
+ await Promise.race([run.flush(), new Promise((r) => setTimeout(r, 1500))]);
68
+ ```
69
+
70
+ Where the host offers it (`waitUntil` on Vercel and Cloudflare), hand it the flush instead of awaiting it. Request metrics are per-minute aggregates and suit long-running servers; on serverless, report events, AI calls and audit rows.
71
+
42
72
  ## Request metrics
43
73
 
44
74
  Every response is counted per minute and per route (`METHOD route`), with 5xx errors and p50, p95 and p99 latency. Finished minutes go to the api on the next flush. Only the route template and timings are sent: no URLs with ids, no query strings, no headers.
@@ -214,3 +244,7 @@ Customers who decline an AI gateway (deployment with `gatewayMode: 'none'`) have
214
244
  npm run build --workspace=@originatedev/run-sdk
215
245
  npm run test --workspace=@originatedev/run-sdk
216
246
  ```
247
+
248
+ ## License
249
+
250
+ Apache-2.0. Copyright 2026 Originate, Inc. See [LICENSE](LICENSE).
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Provider client wrappers. They patch the create methods in place to time
3
+ * the call and read token usage, model and finish reason from the response
4
+ * or from the stream. Return values are passed through untouched: the same
5
+ * promise, the same stream object (its async iterator is observed, not
6
+ * replaced by a different object). Prompts and completions are never read.
7
+ */
8
+ import type { AiCall, AiWrapOptions } from './types.js';
9
+ export type RecordFn = (call: AiCall) => void;
10
+ export type ErrorFn = (error: unknown) => void;
11
+ export declare function wrapOpenAI<T extends object>(client: T, record: RecordFn, onError: ErrorFn, options?: AiWrapOptions): T;
12
+ export declare function wrapAnthropic<T extends object>(client: T, record: RecordFn, onError: ErrorFn, options?: AiWrapOptions): T;
13
+ export declare function errorTypeOf(error: unknown): string;
package/dist/cjs/ai.js ADDED
@@ -0,0 +1,308 @@
1
+ "use strict";
2
+ /**
3
+ * Provider client wrappers. They patch the create methods in place to time
4
+ * the call and read token usage, model and finish reason from the response
5
+ * or from the stream. Return values are passed through untouched: the same
6
+ * promise, the same stream object (its async iterator is observed, not
7
+ * replaced by a different object). Prompts and completions are never read.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.wrapOpenAI = wrapOpenAI;
11
+ exports.wrapAnthropic = wrapAnthropic;
12
+ exports.errorTypeOf = errorTypeOf;
13
+ const WRAPPED = Symbol.for('originate.run.wrapped');
14
+ function wrapOpenAI(client, record, onError, options = {}) {
15
+ const specs = [
16
+ { path: ['chat', 'completions', 'create'], operation: 'chat', absorb: absorbOpenAIChat },
17
+ { path: ['responses', 'create'], operation: 'chat', absorb: absorbOpenAIResponses },
18
+ { path: ['embeddings', 'create'], operation: 'embeddings', absorb: absorbOpenAIEmbeddings },
19
+ ];
20
+ for (const spec of specs)
21
+ patchMethod(client, spec, 'openai', record, onError, options);
22
+ return client;
23
+ }
24
+ function wrapAnthropic(client, record, onError, options = {}) {
25
+ patchMethod(client, { path: ['messages', 'create'], operation: 'chat', absorb: absorbAnthropicMessage }, 'anthropic', record, onError, options);
26
+ return client;
27
+ }
28
+ function patchMethod(client, spec, provider, record, onError, options) {
29
+ const methodName = spec.path[spec.path.length - 1];
30
+ if (!methodName)
31
+ return;
32
+ let target = client;
33
+ for (const segment of spec.path.slice(0, -1)) {
34
+ if (!isObject(target))
35
+ return;
36
+ target = target[segment];
37
+ }
38
+ if (!isObject(target))
39
+ return;
40
+ const original = target[methodName];
41
+ if (typeof original !== 'function')
42
+ return;
43
+ if (original[WRAPPED])
44
+ return;
45
+ const wrapped = function (...args) {
46
+ const started = performance.now();
47
+ const params = isObject(args[0]) ? args[0] : {};
48
+ const requestModel = typeof params.model === 'string' ? params.model : 'unknown';
49
+ const streaming = params.stream === true;
50
+ const base = {
51
+ operation: spec.operation,
52
+ provider,
53
+ requestModel,
54
+ started,
55
+ feature: options.feature ?? null,
56
+ accountId: options.accountId ?? null,
57
+ record,
58
+ onError,
59
+ absorb: spec.absorb,
60
+ };
61
+ let result;
62
+ try {
63
+ result = original.apply(this, args);
64
+ }
65
+ catch (error) {
66
+ safeRecord(base, { finishReason: undefined }, null, error);
67
+ throw error;
68
+ }
69
+ if (!isThenable(result)) {
70
+ if (streaming && isAsyncIterable(result))
71
+ observeStream(result, base);
72
+ else
73
+ safeRecord(base, absorbSafe(spec.absorb, result), null, null);
74
+ return result;
75
+ }
76
+ // Observe the same promise the caller receives. Handlers never throw, so
77
+ // this derived promise never rejects and the original is returned as is.
78
+ result.then((value) => {
79
+ if (streaming && isAsyncIterable(value))
80
+ observeStream(value, base);
81
+ else
82
+ safeRecord(base, absorbSafe(spec.absorb, value), null, null);
83
+ }, (error) => {
84
+ safeRecord(base, {}, null, error);
85
+ });
86
+ return result;
87
+ };
88
+ Object.defineProperty(wrapped, WRAPPED, { value: true });
89
+ Object.defineProperty(wrapped, 'name', { value: original.name ?? methodName });
90
+ target[methodName] = wrapped;
91
+ }
92
+ function safeRecord(base, state, ttftMs, error) {
93
+ try {
94
+ base.record({
95
+ occurredAt: new Date().toISOString(),
96
+ operation: base.operation,
97
+ provider: base.provider,
98
+ model: state.model ?? base.requestModel,
99
+ inputTokens: state.inputTokens ?? 0,
100
+ cachedTokens: state.cachedTokens ?? 0,
101
+ outputTokens: state.outputTokens ?? 0,
102
+ durationMs: Math.round(performance.now() - base.started),
103
+ ttftMs: ttftMs === null ? undefined : Math.round(ttftMs),
104
+ finishReason: state.finishReason ?? null,
105
+ errorType: error === null ? null : errorTypeOf(error),
106
+ feature: base.feature,
107
+ accountId: base.accountId,
108
+ source: 'sdk',
109
+ batch: 0,
110
+ });
111
+ }
112
+ catch (e) {
113
+ try {
114
+ base.onError(e);
115
+ }
116
+ catch {
117
+ // Nothing left to report to.
118
+ }
119
+ }
120
+ }
121
+ function absorbSafe(absorb, value) {
122
+ const state = {};
123
+ try {
124
+ absorb(state, value);
125
+ }
126
+ catch {
127
+ // A shape we do not know; the call is still counted.
128
+ }
129
+ return state;
130
+ }
131
+ /**
132
+ * Patches the stream's async iterator in place so iteration is observed.
133
+ * The stream object the caller holds is unchanged in identity and API.
134
+ */
135
+ function observeStream(stream, base) {
136
+ const holder = stream;
137
+ const originalIterator = holder[Symbol.asyncIterator];
138
+ if (typeof originalIterator !== 'function')
139
+ return;
140
+ const state = {};
141
+ let ttftMs = null;
142
+ let recorded = false;
143
+ const finish = (error) => {
144
+ if (recorded)
145
+ return;
146
+ recorded = true;
147
+ safeRecord(base, state, ttftMs, error);
148
+ };
149
+ holder[Symbol.asyncIterator] = function () {
150
+ const inner = originalIterator.call(this);
151
+ const observed = {
152
+ async next(...args) {
153
+ let step;
154
+ try {
155
+ step = await inner.next(...args);
156
+ }
157
+ catch (error) {
158
+ finish(error);
159
+ throw error;
160
+ }
161
+ if (step.done) {
162
+ finish(null);
163
+ }
164
+ else {
165
+ if (ttftMs === null)
166
+ ttftMs = performance.now() - base.started;
167
+ try {
168
+ base.absorb(state, step.value);
169
+ }
170
+ catch {
171
+ // Unknown chunk shape; keep streaming.
172
+ }
173
+ }
174
+ return step;
175
+ },
176
+ async return(value) {
177
+ finish(null);
178
+ if (typeof inner.return === 'function')
179
+ return inner.return(value);
180
+ return { done: true, value };
181
+ },
182
+ async throw(error) {
183
+ finish(error ?? new Error('stream aborted'));
184
+ if (typeof inner.throw === 'function')
185
+ return inner.throw(error);
186
+ throw error;
187
+ },
188
+ [Symbol.asyncIterator]() {
189
+ return observed;
190
+ },
191
+ };
192
+ return observed;
193
+ };
194
+ }
195
+ // ── Shape readers ────────────────────────────────────────────────────────
196
+ function absorbOpenAIChat(state, value) {
197
+ if (!isObject(value))
198
+ return;
199
+ if (typeof value.model === 'string')
200
+ state.model = value.model;
201
+ readOpenAIUsage(state, value.usage);
202
+ const choices = value.choices;
203
+ if (Array.isArray(choices)) {
204
+ for (const choice of choices) {
205
+ if (isObject(choice) && typeof choice.finish_reason === 'string')
206
+ state.finishReason = choice.finish_reason;
207
+ }
208
+ }
209
+ }
210
+ function absorbOpenAIResponses(state, value) {
211
+ if (!isObject(value))
212
+ return;
213
+ // Stream events carry the response under `response`; a plain call is the response.
214
+ const response = isObject(value.response) ? value.response : value;
215
+ if (typeof response.model === 'string')
216
+ state.model = response.model;
217
+ readOpenAIUsage(state, response.usage);
218
+ if (typeof response.status === 'string') {
219
+ if (response.status === 'completed')
220
+ state.finishReason = 'stop';
221
+ else if (isObject(response.incomplete_details) && typeof response.incomplete_details.reason === 'string') {
222
+ state.finishReason = response.incomplete_details.reason;
223
+ }
224
+ else if (response.status !== 'in_progress' && response.status !== 'queued') {
225
+ state.finishReason = response.status;
226
+ }
227
+ }
228
+ }
229
+ function absorbOpenAIEmbeddings(state, value) {
230
+ if (!isObject(value))
231
+ return;
232
+ if (typeof value.model === 'string')
233
+ state.model = value.model;
234
+ readOpenAIUsage(state, value.usage);
235
+ }
236
+ function readOpenAIUsage(state, usage) {
237
+ if (!isObject(usage))
238
+ return;
239
+ const input = numberOf(usage.prompt_tokens) ?? numberOf(usage.input_tokens);
240
+ const output = numberOf(usage.completion_tokens) ?? numberOf(usage.output_tokens);
241
+ if (input !== undefined)
242
+ state.inputTokens = input;
243
+ if (output !== undefined)
244
+ state.outputTokens = output;
245
+ const details = isObject(usage.prompt_tokens_details)
246
+ ? usage.prompt_tokens_details
247
+ : isObject(usage.input_tokens_details)
248
+ ? usage.input_tokens_details
249
+ : null;
250
+ const cached = details ? numberOf(details.cached_tokens) : undefined;
251
+ if (cached !== undefined)
252
+ state.cachedTokens = cached;
253
+ }
254
+ function absorbAnthropicMessage(state, value) {
255
+ if (!isObject(value))
256
+ return;
257
+ // Stream: message_start carries the message; message_delta carries usage and the stop reason.
258
+ const message = isObject(value.message) ? value.message : value;
259
+ if (typeof message.model === 'string')
260
+ state.model = message.model;
261
+ readAnthropicUsage(state, message.usage);
262
+ if (message !== value)
263
+ readAnthropicUsage(state, value.usage);
264
+ if (typeof message.stop_reason === 'string')
265
+ state.finishReason = message.stop_reason;
266
+ if (isObject(value.delta) && typeof value.delta.stop_reason === 'string')
267
+ state.finishReason = value.delta.stop_reason;
268
+ }
269
+ function readAnthropicUsage(state, usage) {
270
+ if (!isObject(usage))
271
+ return;
272
+ const input = numberOf(usage.input_tokens);
273
+ const output = numberOf(usage.output_tokens);
274
+ const cached = numberOf(usage.cache_read_input_tokens);
275
+ if (input !== undefined)
276
+ state.inputTokens = input;
277
+ if (output !== undefined)
278
+ state.outputTokens = output;
279
+ if (cached !== undefined)
280
+ state.cachedTokens = cached;
281
+ }
282
+ // ── Small helpers ────────────────────────────────────────────────────────
283
+ function errorTypeOf(error) {
284
+ if (isObject(error)) {
285
+ if (typeof error.status === 'number')
286
+ return String(error.status);
287
+ if (typeof error.code === 'string' && error.code)
288
+ return error.code;
289
+ if (typeof error.name === 'string' && error.name)
290
+ return error.name;
291
+ }
292
+ if (error instanceof Error)
293
+ return error.name || 'Error';
294
+ return 'Error';
295
+ }
296
+ function isObject(value) {
297
+ return typeof value === 'object' && value !== null;
298
+ }
299
+ function isThenable(value) {
300
+ return isObject(value) && typeof value.then === 'function';
301
+ }
302
+ function isAsyncIterable(value) {
303
+ return isObject(value) && typeof value[Symbol.asyncIterator] === 'function';
304
+ }
305
+ function numberOf(value) {
306
+ return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
307
+ }
308
+ //# sourceMappingURL=ai.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai.js","sourceRoot":"","sources":["../../src/ai.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;AAOH,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAsBpD,oBAA6C,MAAS,EAAE,MAAgB,EAAE,OAAgB,EAAE,OAAO,GAAkB,EAAE;IACrH,MAAM,KAAK,GAAiB;QAC1B,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE;QACxF,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,qBAAqB,EAAE;QACnF,EAAE,IAAI,EAAE,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,sBAAsB,EAAE;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AK,YAAY,KAAK;QAAE,OAAO,KAAK,CAAC,IAAI,IAAI,OAAO,CAAC;IACzD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAQ,KAA4B,CAAC,IAAI,KAAK,UAAU,CAAC;AACrF,CAAC;AAED,SAAS,eAAe,CAAC,KAAc;IACrC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAQ,KAAmB,CAAC,MAAM,CAAC,aAAkC,CAAC,KAAK,UAAU,CAAC;AAClH,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACjF,CAAC"}
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * originate-run: a tiny CLI for CI pipelines.
4
+ *
5
+ * npx @originatedev/run-sdk deploy --version 1.4.0 --commit abc123 --summary "Checkout fixes" \
6
+ * --pr-url https://github.com/org/repo/pull/12 --deployer ci --outcome success
7
+ * npx @originatedev/run-sdk backup --datastore "Primary database" --status ok --size-bytes 18500000000
8
+ *
9
+ * Reads ORIGINATE_RUN_KEY (the application's opk_ key) and ORIGINATE_API_BASE
10
+ * (defaults to the production api) from the environment.
11
+ */
12
+ import type { BackupReport, DeployReport } from './types.js';
13
+ export declare function parseArgs(argv: string[]): {
14
+ command: string | undefined;
15
+ flags: Record<string, string>;
16
+ };
17
+ export declare function deployReportFromFlags(flags: Record<string, string>): DeployReport;
18
+ export declare function backupReportFromFlags(flags: Record<string, string>): BackupReport | string;