@sansavision/runfuse 0.1.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/README.md +85 -0
- package/dist/index.d.ts +174 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +245 -0
- package/dist/index.js.map +1 -0
- package/package.json +20 -0
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# @sansavision/runfuse
|
|
2
|
+
|
|
3
|
+
Optional Node client for the RunFuse managed gateway and metadata-only External Guard.
|
|
4
|
+
|
|
5
|
+
## Runtime and security boundary
|
|
6
|
+
|
|
7
|
+
This is a **server-side SDK**. It supports Node.js 18 or newer and server runtimes that provide compatible `fetch`, `AbortController`, `TextEncoder`, and `btoa` globals.
|
|
8
|
+
|
|
9
|
+
| Application | Supported use |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| Next.js, Remix, Express, Fastify, serverless functions | Use the SDK in server-only code. |
|
|
12
|
+
| Browser React | Call your own backend. Never include a RunFuse project key in the browser bundle. |
|
|
13
|
+
| React Native | Call your own backend or serverless orchestration layer. Never embed a RunFuse project key in the app binary. |
|
|
14
|
+
| Electron or other packaged desktop apps | Use a remote backend. A key shipped in the renderer, main process, resources, or installer can be extracted. |
|
|
15
|
+
|
|
16
|
+
The public raw HTTP API and this SDK provide the same capabilities. Client applications should authenticate to a customer-controlled backend, and that backend should hold the RunFuse key and invoke RunFuse.
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
npm install @sansavision/runfuse
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { RunFuseClient } from "@sansavision/runfuse";
|
|
24
|
+
|
|
25
|
+
const runfuse = new RunFuseClient({
|
|
26
|
+
gatewayUrl: "https://gateway.runfuse.xyz",
|
|
27
|
+
projectKey: process.env.RUNFUSE_PROJECT_KEY!
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const response = await runfuse.chatCompletions({
|
|
31
|
+
model: "runfuse-default",
|
|
32
|
+
messages: [{ role: "user", content: "Summarize this incident." }],
|
|
33
|
+
max_completion_tokens: 400
|
|
34
|
+
}, {
|
|
35
|
+
metadata: {
|
|
36
|
+
feature: "incident-summary",
|
|
37
|
+
operation_id: crypto.randomUUID(),
|
|
38
|
+
attempt: 1
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Keep the provider call in your infrastructure
|
|
44
|
+
|
|
45
|
+
External Guard gives a regular function or provider call budget authority before execution. RunFuse receives operational metadata only. Your provider key, prompt, request body, and response stay in your infrastructure.
|
|
46
|
+
|
|
47
|
+
Use `executeExternalSafely` for the recommended lifecycle. It enforces the signed deadline, supplies a cooperative abort signal, preserves uncertain reservations, and can invoke a narrowly scoped provider or workflow termination callback.
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
const outcome = await runfuse.executeExternalSafely({
|
|
51
|
+
kind: "function",
|
|
52
|
+
feature: "invoice-sync",
|
|
53
|
+
runId,
|
|
54
|
+
operationId,
|
|
55
|
+
logicalOperationId: invoiceId,
|
|
56
|
+
estimatedMaxCostUsd: 0.03,
|
|
57
|
+
attempt: 1,
|
|
58
|
+
maxOutputTokens: 800
|
|
59
|
+
}, {
|
|
60
|
+
timeoutMs: 45_000,
|
|
61
|
+
execute: async ({ signal, markStarted }) => {
|
|
62
|
+
markStarted();
|
|
63
|
+
const result = await callYourProvider({ invoiceId, signal, maxSteps: 6 });
|
|
64
|
+
return { value: result, actualCostUsd: result.costUsd };
|
|
65
|
+
},
|
|
66
|
+
terminate: async ({ signal }) => {
|
|
67
|
+
const stopped = await cancelProviderJob(jobId, { signal });
|
|
68
|
+
return stopped.confirmed
|
|
69
|
+
? { status: "confirmed", actualCostUsd: stopped.costUsd }
|
|
70
|
+
: { status: "uncertain" };
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
if (outcome.status === "uncertain") {
|
|
75
|
+
await enqueueProviderLogReconciliation(outcome.authorization.operation_id);
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`markStarted()` must be called immediately before dispatch. Before that point, the helper can safely release unused authority. After that point, a timeout is not proof that no billable work occurred, so the helper never calls the RunFuse cancellation endpoint. It either confirms provider termination and settles measured cost, or returns `uncertain` and retains the reservation for reconciliation.
|
|
80
|
+
|
|
81
|
+
An abort signal is cooperative. The provider SDK, HTTP client, function, or runtime must honor it. Also set provider-side maximum tokens, steps, duration, retry, and fanout limits. For asynchronous work, use a durable watchdog or provider cancel-job API because an in-process timer disappears when its process crashes.
|
|
82
|
+
|
|
83
|
+
The package is not required. See https://runfuse.xyz/docs/api for raw HTTP, Fetch, External Guard, OpenAI-compatible client, envelope, and error documentation.
|
|
84
|
+
|
|
85
|
+
Keep every `rf_live_` key in a server-side secret manager. Use a separate key and consumer label for each calling product.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
export interface RunFuseClientOptions {
|
|
2
|
+
projectKey: string;
|
|
3
|
+
gatewayUrl: string;
|
|
4
|
+
fetch?: typeof globalThis.fetch;
|
|
5
|
+
}
|
|
6
|
+
export interface RunContext {
|
|
7
|
+
organizationId: string;
|
|
8
|
+
projectId: string;
|
|
9
|
+
environment: string;
|
|
10
|
+
runId?: string;
|
|
11
|
+
feature?: string;
|
|
12
|
+
tenantId?: string;
|
|
13
|
+
userId?: string;
|
|
14
|
+
hardBudgetUsd?: number;
|
|
15
|
+
economicContext?: {
|
|
16
|
+
expectedRevenueUsd: number;
|
|
17
|
+
outcomeUnits?: number;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export interface CompletionInput {
|
|
21
|
+
model: string;
|
|
22
|
+
messages: Array<{
|
|
23
|
+
role: "system" | "user" | "assistant" | "tool";
|
|
24
|
+
content: unknown;
|
|
25
|
+
}>;
|
|
26
|
+
max_tokens?: number;
|
|
27
|
+
max_completion_tokens?: number;
|
|
28
|
+
stream?: boolean;
|
|
29
|
+
[key: string]: unknown;
|
|
30
|
+
}
|
|
31
|
+
export type ExternalOperationKind = "model" | "tool" | "queue" | "function" | "browser";
|
|
32
|
+
export interface ExternalAuthorizationInput {
|
|
33
|
+
estimatedMaxCostUsd: number;
|
|
34
|
+
kind?: ExternalOperationKind;
|
|
35
|
+
organizationId?: string;
|
|
36
|
+
projectId?: string;
|
|
37
|
+
environment?: string;
|
|
38
|
+
runId?: string;
|
|
39
|
+
operationId?: string;
|
|
40
|
+
logicalOperationId?: string;
|
|
41
|
+
feature?: string;
|
|
42
|
+
ttlSeconds?: number;
|
|
43
|
+
depth?: number;
|
|
44
|
+
attempt?: number;
|
|
45
|
+
childCount?: number;
|
|
46
|
+
concurrentChildren?: number;
|
|
47
|
+
maxOutputTokens?: number;
|
|
48
|
+
fingerprint?: string;
|
|
49
|
+
transition?: string;
|
|
50
|
+
errorCode?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface ExternalAuthorization {
|
|
53
|
+
authorized: true;
|
|
54
|
+
decision: string;
|
|
55
|
+
authorization: string;
|
|
56
|
+
run_id: string;
|
|
57
|
+
operation_id: string;
|
|
58
|
+
reserved_micros: number;
|
|
59
|
+
execution_deadline_at?: string;
|
|
60
|
+
expires_at: string;
|
|
61
|
+
}
|
|
62
|
+
export interface ExternalSettlement {
|
|
63
|
+
settled: true;
|
|
64
|
+
run_id: string;
|
|
65
|
+
operation_id: string;
|
|
66
|
+
reserved_micros: number;
|
|
67
|
+
actual_micros: number;
|
|
68
|
+
exceeded_reservation: boolean;
|
|
69
|
+
}
|
|
70
|
+
export interface ExternalCancellation {
|
|
71
|
+
cancelled: true;
|
|
72
|
+
run_id: string;
|
|
73
|
+
operation_id: string;
|
|
74
|
+
released_micros: number;
|
|
75
|
+
}
|
|
76
|
+
export type ExternalExecutionStopReason = "deadline" | "caller_abort" | "execution_error";
|
|
77
|
+
export interface ExternalExecutionContext {
|
|
78
|
+
/** Cooperative signal for fetch/provider SDK calls. It cannot kill code that ignores it. */
|
|
79
|
+
signal: AbortSignal;
|
|
80
|
+
/** Hard local deadline, always earlier than the authorization receipt expiry. */
|
|
81
|
+
deadline: Date;
|
|
82
|
+
/** Call immediately before dispatching work outside the current process. */
|
|
83
|
+
markStarted(): void;
|
|
84
|
+
remainingMs(): number;
|
|
85
|
+
}
|
|
86
|
+
export interface ExternalExecutionValue<T> {
|
|
87
|
+
value: T;
|
|
88
|
+
actualCostUsd: number;
|
|
89
|
+
priceVersion?: string;
|
|
90
|
+
}
|
|
91
|
+
export type ExternalTerminationResult = {
|
|
92
|
+
status: "confirmed";
|
|
93
|
+
actualCostUsd: number;
|
|
94
|
+
priceVersion?: string;
|
|
95
|
+
} | {
|
|
96
|
+
status: "uncertain";
|
|
97
|
+
};
|
|
98
|
+
export interface ExternalSafeExecutionOptions<T> {
|
|
99
|
+
envelope?: string;
|
|
100
|
+
/** Optional stricter runtime ceiling. The signed server deadline remains the upper bound. */
|
|
101
|
+
timeoutMs?: number;
|
|
102
|
+
/** Used only with older servers that do not return execution_deadline_at. Default: 10 seconds. */
|
|
103
|
+
safetyMarginMs?: number;
|
|
104
|
+
/** Upper bound for the provider/job termination call. Default: 5 seconds. */
|
|
105
|
+
terminationTimeoutMs?: number;
|
|
106
|
+
signal?: AbortSignal;
|
|
107
|
+
execute(context: ExternalExecutionContext): Promise<ExternalExecutionValue<T>>;
|
|
108
|
+
/** A narrowly scoped provider cancel, workflow terminate, queue pause, or watchdog call. */
|
|
109
|
+
terminate?(context: {
|
|
110
|
+
authorization: ExternalAuthorization;
|
|
111
|
+
reason: ExternalExecutionStopReason;
|
|
112
|
+
signal: AbortSignal;
|
|
113
|
+
}): Promise<ExternalTerminationResult>;
|
|
114
|
+
}
|
|
115
|
+
export type ExternalSafeExecutionResult<T> = {
|
|
116
|
+
status: "settled";
|
|
117
|
+
value: T;
|
|
118
|
+
authorization: ExternalAuthorization;
|
|
119
|
+
settlement: ExternalSettlement;
|
|
120
|
+
} | {
|
|
121
|
+
status: "cancelled";
|
|
122
|
+
authorization: ExternalAuthorization;
|
|
123
|
+
reason: "deadline_before_start" | "execution_failed_before_start";
|
|
124
|
+
cancellation: ExternalCancellation;
|
|
125
|
+
cause?: unknown;
|
|
126
|
+
} | {
|
|
127
|
+
status: "terminated";
|
|
128
|
+
authorization: ExternalAuthorization;
|
|
129
|
+
reason: ExternalExecutionStopReason;
|
|
130
|
+
settlement: ExternalSettlement;
|
|
131
|
+
cause?: unknown;
|
|
132
|
+
} | {
|
|
133
|
+
status: "uncertain";
|
|
134
|
+
authorization: ExternalAuthorization;
|
|
135
|
+
reason: ExternalExecutionStopReason | "settlement_error" | "cancellation_error" | "termination_error";
|
|
136
|
+
executionStarted: boolean;
|
|
137
|
+
reconcileRequired: true;
|
|
138
|
+
actualCostUsd?: number;
|
|
139
|
+
cause?: unknown;
|
|
140
|
+
};
|
|
141
|
+
export declare class RunFuseClient {
|
|
142
|
+
private readonly options;
|
|
143
|
+
private readonly fetcher;
|
|
144
|
+
constructor(options: RunFuseClientOptions);
|
|
145
|
+
createRun(context: RunContext): Promise<{
|
|
146
|
+
envelope: string;
|
|
147
|
+
runId: string;
|
|
148
|
+
}>;
|
|
149
|
+
chatCompletions(input: CompletionInput, options?: {
|
|
150
|
+
envelope?: string;
|
|
151
|
+
metadata?: Record<string, unknown>;
|
|
152
|
+
}): Promise<Response>;
|
|
153
|
+
authorizeExternal(input: ExternalAuthorizationInput, options?: {
|
|
154
|
+
envelope?: string;
|
|
155
|
+
}): Promise<ExternalAuthorization>;
|
|
156
|
+
/**
|
|
157
|
+
* Runs the complete External Guard lifecycle with a fail-closed local deadline.
|
|
158
|
+
* The caller must pass the supplied signal to the provider/runtime and call
|
|
159
|
+
* markStarted immediately before external dispatch.
|
|
160
|
+
*/
|
|
161
|
+
executeExternalSafely<T>(input: ExternalAuthorizationInput, options: ExternalSafeExecutionOptions<T>): Promise<ExternalSafeExecutionResult<T>>;
|
|
162
|
+
settleExternal(authorization: string, actualCostUsd: number, options?: {
|
|
163
|
+
priceVersion?: string;
|
|
164
|
+
}): Promise<ExternalSettlement>;
|
|
165
|
+
cancelExternal(authorization: string): Promise<ExternalCancellation>;
|
|
166
|
+
}
|
|
167
|
+
export declare class RunFuseError extends Error {
|
|
168
|
+
readonly status: number;
|
|
169
|
+
readonly code?: string | undefined;
|
|
170
|
+
readonly runId?: string | undefined;
|
|
171
|
+
constructor(message: string, status: number, code?: string | undefined, runId?: string | undefined);
|
|
172
|
+
static fromResponse(response: Response): Promise<RunFuseError>;
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC;AAED,MAAM,WAAW,UAAU;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE;QAChB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACtF,UAA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AAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,CAInE;CACF"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
function validPositiveDuration(value, fallback, label) {
|
|
2
|
+
const resolved = value ?? fallback;
|
|
3
|
+
if (!Number.isFinite(resolved) || resolved <= 0)
|
|
4
|
+
throw new RangeError(`${label} must be a finite value greater than zero`);
|
|
5
|
+
return resolved;
|
|
6
|
+
}
|
|
7
|
+
function stopReason(signal, deadlineFired) {
|
|
8
|
+
if (deadlineFired)
|
|
9
|
+
return "deadline";
|
|
10
|
+
if (signal.aborted)
|
|
11
|
+
return "caller_abort";
|
|
12
|
+
return "execution_error";
|
|
13
|
+
}
|
|
14
|
+
export class RunFuseClient {
|
|
15
|
+
options;
|
|
16
|
+
fetcher;
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this.options = options;
|
|
19
|
+
if (!options.projectKey)
|
|
20
|
+
throw new Error("RunFuse projectKey is required");
|
|
21
|
+
if (!options.gatewayUrl)
|
|
22
|
+
throw new Error("RunFuse gatewayUrl is required");
|
|
23
|
+
this.fetcher = options.fetch ?? globalThis.fetch;
|
|
24
|
+
}
|
|
25
|
+
async createRun(context) {
|
|
26
|
+
const response = await this.fetcher(`${this.options.gatewayUrl.replace(/\/$/, "")}/v1/runfuse/envelopes`, {
|
|
27
|
+
method: "POST",
|
|
28
|
+
headers: { "content-type": "application/json", "x-runfuse-project-key": this.options.projectKey },
|
|
29
|
+
body: JSON.stringify({
|
|
30
|
+
organizationId: context.organizationId,
|
|
31
|
+
projectId: context.projectId,
|
|
32
|
+
environment: context.environment,
|
|
33
|
+
...(context.runId ? { runId: context.runId } : {}),
|
|
34
|
+
...(context.feature ? { feature: context.feature } : {}),
|
|
35
|
+
...(context.tenantId ? { tenantId: context.tenantId } : {}),
|
|
36
|
+
...(context.userId ? { userId: context.userId } : {}),
|
|
37
|
+
...(context.economicContext ? { economicContext: { expectedRevenueUsd: context.economicContext.expectedRevenueUsd, outcomeUnits: context.economicContext.outcomeUnits ?? 1 } } : {})
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
if (!response.ok)
|
|
41
|
+
throw await RunFuseError.fromResponse(response);
|
|
42
|
+
const signed = await response.json();
|
|
43
|
+
return { envelope: btoa(JSON.stringify(signed)), runId: signed.payload.runId };
|
|
44
|
+
}
|
|
45
|
+
async chatCompletions(input, options = {}) {
|
|
46
|
+
const response = await this.fetcher(`${this.options.gatewayUrl.replace(/\/$/, "")}/v1/chat/completions`, {
|
|
47
|
+
method: "POST",
|
|
48
|
+
headers: {
|
|
49
|
+
"content-type": "application/json",
|
|
50
|
+
"x-runfuse-project-key": this.options.projectKey,
|
|
51
|
+
...(options.envelope ? { "x-runfuse-envelope": options.envelope } : {})
|
|
52
|
+
},
|
|
53
|
+
body: JSON.stringify({ ...input, ...(options.metadata ? { runfuse: options.metadata } : {}) })
|
|
54
|
+
});
|
|
55
|
+
if (!response.ok)
|
|
56
|
+
throw await RunFuseError.fromResponse(response);
|
|
57
|
+
return response;
|
|
58
|
+
}
|
|
59
|
+
async authorizeExternal(input, options = {}) {
|
|
60
|
+
const response = await this.fetcher(`${this.options.gatewayUrl.replace(/\/$/, "")}/v1/runfuse/authorizations`, {
|
|
61
|
+
method: "POST",
|
|
62
|
+
headers: {
|
|
63
|
+
"content-type": "application/json",
|
|
64
|
+
"x-runfuse-project-key": this.options.projectKey,
|
|
65
|
+
...(options.envelope ? { "x-runfuse-envelope": options.envelope } : {})
|
|
66
|
+
},
|
|
67
|
+
body: JSON.stringify({
|
|
68
|
+
estimated_max_cost_usd: input.estimatedMaxCostUsd,
|
|
69
|
+
...(input.kind ? { kind: input.kind } : {}),
|
|
70
|
+
...(input.organizationId ? { organization_id: input.organizationId } : {}),
|
|
71
|
+
...(input.projectId ? { project_id: input.projectId } : {}),
|
|
72
|
+
...(input.environment ? { environment: input.environment } : {}),
|
|
73
|
+
...(input.runId ? { run_id: input.runId } : {}),
|
|
74
|
+
...(input.operationId ? { operation_id: input.operationId } : {}),
|
|
75
|
+
...(input.logicalOperationId ? { logical_operation_id: input.logicalOperationId } : {}),
|
|
76
|
+
...(input.feature ? { feature: input.feature } : {}),
|
|
77
|
+
...(input.ttlSeconds !== undefined ? { ttl_seconds: input.ttlSeconds } : {}),
|
|
78
|
+
...(input.depth !== undefined ? { depth: input.depth } : {}),
|
|
79
|
+
...(input.attempt !== undefined ? { attempt: input.attempt } : {}),
|
|
80
|
+
...(input.childCount !== undefined ? { child_count: input.childCount } : {}),
|
|
81
|
+
...(input.concurrentChildren !== undefined ? { concurrent_children: input.concurrentChildren } : {}),
|
|
82
|
+
...(input.maxOutputTokens !== undefined ? { max_output_tokens: input.maxOutputTokens } : {}),
|
|
83
|
+
...(input.fingerprint ? { fingerprint: input.fingerprint } : {}),
|
|
84
|
+
...(input.transition ? { transition: input.transition } : {}),
|
|
85
|
+
...(input.errorCode ? { error_code: input.errorCode } : {})
|
|
86
|
+
})
|
|
87
|
+
});
|
|
88
|
+
if (!response.ok)
|
|
89
|
+
throw await RunFuseError.fromResponse(response);
|
|
90
|
+
return response.json();
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Runs the complete External Guard lifecycle with a fail-closed local deadline.
|
|
94
|
+
* The caller must pass the supplied signal to the provider/runtime and call
|
|
95
|
+
* markStarted immediately before external dispatch.
|
|
96
|
+
*/
|
|
97
|
+
async executeExternalSafely(input, options) {
|
|
98
|
+
const safetyMarginMs = validPositiveDuration(options.safetyMarginMs, 10_000, "safetyMarginMs");
|
|
99
|
+
const terminationTimeoutMs = validPositiveDuration(options.terminationTimeoutMs, 5_000, "terminationTimeoutMs");
|
|
100
|
+
const requestedTimeoutMs = options.timeoutMs === undefined
|
|
101
|
+
? Number.POSITIVE_INFINITY
|
|
102
|
+
: validPositiveDuration(options.timeoutMs, 1, "timeoutMs");
|
|
103
|
+
const authorization = await this.authorizeExternal(input, { ...(options.envelope ? { envelope: options.envelope } : {}) });
|
|
104
|
+
const now = Date.now();
|
|
105
|
+
const expiresAtMs = Date.parse(authorization.expires_at);
|
|
106
|
+
const serverDeadlineMs = authorization.execution_deadline_at
|
|
107
|
+
? Date.parse(authorization.execution_deadline_at)
|
|
108
|
+
: expiresAtMs - safetyMarginMs;
|
|
109
|
+
const deadlineMs = Math.min(serverDeadlineMs, now + requestedTimeoutMs);
|
|
110
|
+
if (options.signal?.aborted || !Number.isFinite(expiresAtMs) || !Number.isFinite(deadlineMs) || deadlineMs >= expiresAtMs || deadlineMs <= now) {
|
|
111
|
+
try {
|
|
112
|
+
const cancellation = await this.cancelExternal(authorization.authorization);
|
|
113
|
+
return { status: "cancelled", authorization, reason: options.signal?.aborted ? "execution_failed_before_start" : "deadline_before_start", cancellation, ...(options.signal?.aborted ? { cause: options.signal.reason } : {}) };
|
|
114
|
+
}
|
|
115
|
+
catch (cause) {
|
|
116
|
+
return { status: "uncertain", authorization, reason: "cancellation_error", executionStarted: false, reconcileRequired: true, cause };
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const controller = new AbortController();
|
|
120
|
+
let executionStarted = false;
|
|
121
|
+
let deadlineFired = false;
|
|
122
|
+
const abortFromCaller = () => controller.abort(options.signal?.reason ?? new Error("External execution aborted by caller"));
|
|
123
|
+
if (options.signal?.aborted)
|
|
124
|
+
abortFromCaller();
|
|
125
|
+
else
|
|
126
|
+
options.signal?.addEventListener("abort", abortFromCaller, { once: true });
|
|
127
|
+
const timer = setTimeout(() => {
|
|
128
|
+
deadlineFired = true;
|
|
129
|
+
controller.abort(new Error("External execution deadline exceeded"));
|
|
130
|
+
}, Math.max(0, deadlineMs - Date.now()));
|
|
131
|
+
const abortPromise = new Promise((_, reject) => {
|
|
132
|
+
const rejectAbort = () => reject(controller.signal.reason ?? new Error("External execution aborted"));
|
|
133
|
+
if (controller.signal.aborted)
|
|
134
|
+
rejectAbort();
|
|
135
|
+
else
|
|
136
|
+
controller.signal.addEventListener("abort", rejectAbort, { once: true });
|
|
137
|
+
});
|
|
138
|
+
let execution;
|
|
139
|
+
try {
|
|
140
|
+
execution = await Promise.race([
|
|
141
|
+
options.execute({
|
|
142
|
+
signal: controller.signal,
|
|
143
|
+
deadline: new Date(deadlineMs),
|
|
144
|
+
markStarted: () => { executionStarted = true; },
|
|
145
|
+
remainingMs: () => Math.max(0, deadlineMs - Date.now())
|
|
146
|
+
}),
|
|
147
|
+
abortPromise
|
|
148
|
+
]);
|
|
149
|
+
}
|
|
150
|
+
catch (cause) {
|
|
151
|
+
clearTimeout(timer);
|
|
152
|
+
options.signal?.removeEventListener("abort", abortFromCaller);
|
|
153
|
+
const reason = stopReason(controller.signal, deadlineFired);
|
|
154
|
+
if (!executionStarted) {
|
|
155
|
+
try {
|
|
156
|
+
const cancellation = await this.cancelExternal(authorization.authorization);
|
|
157
|
+
return { status: "cancelled", authorization, reason: reason === "deadline" ? "deadline_before_start" : "execution_failed_before_start", cancellation, cause };
|
|
158
|
+
}
|
|
159
|
+
catch (cancellationCause) {
|
|
160
|
+
return { status: "uncertain", authorization, reason: "cancellation_error", executionStarted: false, reconcileRequired: true, cause: cancellationCause };
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (!options.terminate)
|
|
164
|
+
return { status: "uncertain", authorization, reason, executionStarted: true, reconcileRequired: true, cause };
|
|
165
|
+
const terminationController = new AbortController();
|
|
166
|
+
const terminationTimer = setTimeout(() => terminationController.abort(new Error("External termination deadline exceeded")), terminationTimeoutMs);
|
|
167
|
+
try {
|
|
168
|
+
const termination = await Promise.race([
|
|
169
|
+
options.terminate({ authorization, reason, signal: terminationController.signal }),
|
|
170
|
+
new Promise((_, reject) => terminationController.signal.addEventListener("abort", () => reject(terminationController.signal.reason), { once: true }))
|
|
171
|
+
]);
|
|
172
|
+
if (termination.status === "uncertain")
|
|
173
|
+
return { status: "uncertain", authorization, reason, executionStarted: true, reconcileRequired: true, cause };
|
|
174
|
+
if (!Number.isFinite(termination.actualCostUsd) || termination.actualCostUsd < 0) {
|
|
175
|
+
return { status: "uncertain", authorization, reason: "settlement_error", executionStarted: true, reconcileRequired: true, cause: new RangeError("Termination must report a finite non-negative actualCostUsd") };
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
const settlement = await this.settleExternal(authorization.authorization, termination.actualCostUsd, { ...(termination.priceVersion ? { priceVersion: termination.priceVersion } : {}) });
|
|
179
|
+
return { status: "terminated", authorization, reason, settlement, cause };
|
|
180
|
+
}
|
|
181
|
+
catch (settlementCause) {
|
|
182
|
+
return { status: "uncertain", authorization, reason: "settlement_error", executionStarted: true, reconcileRequired: true, actualCostUsd: termination.actualCostUsd, cause: settlementCause };
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
catch (terminationCause) {
|
|
186
|
+
return { status: "uncertain", authorization, reason: "termination_error", executionStarted: true, reconcileRequired: true, cause: terminationCause };
|
|
187
|
+
}
|
|
188
|
+
finally {
|
|
189
|
+
clearTimeout(terminationTimer);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
finally {
|
|
193
|
+
clearTimeout(timer);
|
|
194
|
+
options.signal?.removeEventListener("abort", abortFromCaller);
|
|
195
|
+
}
|
|
196
|
+
if (!Number.isFinite(execution.actualCostUsd) || execution.actualCostUsd < 0) {
|
|
197
|
+
return { status: "uncertain", authorization, reason: "settlement_error", executionStarted: true, reconcileRequired: true, cause: new RangeError("execute must report a finite non-negative actualCostUsd") };
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
const settlement = await this.settleExternal(authorization.authorization, execution.actualCostUsd, { ...(execution.priceVersion ? { priceVersion: execution.priceVersion } : {}) });
|
|
201
|
+
return { status: "settled", value: execution.value, authorization, settlement };
|
|
202
|
+
}
|
|
203
|
+
catch (cause) {
|
|
204
|
+
return { status: "uncertain", authorization, reason: "settlement_error", executionStarted: true, reconcileRequired: true, actualCostUsd: execution.actualCostUsd, cause };
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
async settleExternal(authorization, actualCostUsd, options = {}) {
|
|
208
|
+
const response = await this.fetcher(`${this.options.gatewayUrl.replace(/\/$/, "")}/v1/runfuse/authorizations/settle`, {
|
|
209
|
+
method: "POST",
|
|
210
|
+
headers: { "content-type": "application/json", "x-runfuse-project-key": this.options.projectKey },
|
|
211
|
+
body: JSON.stringify({ authorization, actual_cost_usd: actualCostUsd, ...(options.priceVersion ? { price_version: options.priceVersion } : {}) })
|
|
212
|
+
});
|
|
213
|
+
if (!response.ok)
|
|
214
|
+
throw await RunFuseError.fromResponse(response);
|
|
215
|
+
return response.json();
|
|
216
|
+
}
|
|
217
|
+
async cancelExternal(authorization) {
|
|
218
|
+
const response = await this.fetcher(`${this.options.gatewayUrl.replace(/\/$/, "")}/v1/runfuse/authorizations/cancel`, {
|
|
219
|
+
method: "POST",
|
|
220
|
+
headers: { "content-type": "application/json", "x-runfuse-project-key": this.options.projectKey },
|
|
221
|
+
body: JSON.stringify({ authorization })
|
|
222
|
+
});
|
|
223
|
+
if (!response.ok)
|
|
224
|
+
throw await RunFuseError.fromResponse(response);
|
|
225
|
+
return response.json();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
export class RunFuseError extends Error {
|
|
229
|
+
status;
|
|
230
|
+
code;
|
|
231
|
+
runId;
|
|
232
|
+
constructor(message, status, code, runId) {
|
|
233
|
+
super(message);
|
|
234
|
+
this.status = status;
|
|
235
|
+
this.code = code;
|
|
236
|
+
this.runId = runId;
|
|
237
|
+
this.name = "RunFuseError";
|
|
238
|
+
}
|
|
239
|
+
static async fromResponse(response) {
|
|
240
|
+
const fallback = { error: { message: response.statusText, type: undefined, run_id: undefined } };
|
|
241
|
+
const body = await response.clone().json().catch(() => fallback);
|
|
242
|
+
return new RunFuseError(body.error.message, response.status, body.error.type, body.error.run_id);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names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"description": "Dependency-free server-side TypeScript client for protected RunFuse AI calls",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"engines": { "node": ">=18" },
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"keywords": ["ai", "budget", "guardrails", "runaway", "typescript"],
|
|
10
|
+
"homepage": "https://runfuse.xyz/docs/api",
|
|
11
|
+
"files": ["dist", "README.md"],
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } },
|
|
14
|
+
"publishConfig": { "access": "public" },
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc -p tsconfig.build.json",
|
|
17
|
+
"prepack": "npm run build",
|
|
18
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
19
|
+
}
|
|
20
|
+
}
|