codai-sdk 0.7.0 → 0.8.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 +12 -2
- package/dist/index.d.ts +114 -4
- package/dist/index.js +14 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@ surface.
|
|
|
65
65
|
| `receipt` | `get` | `GET /v1/receipt` |
|
|
66
66
|
| `feedback` | `submit` | `POST /v1/feedback` |
|
|
67
67
|
| `phoneModels` | `list` | `GET /v1/phone/models` |
|
|
68
|
-
| `resolve` | `submit`, `get`, `accept`, `attestation`, `health`, `waitFor`
|
|
68
|
+
| `resolve` | `submit`, `get`, `accept`, `balance`, `attestation`, `keys`, `verifyAttestation`, `health`, `waitFor` | `https://resolve.codai.ro/v1/resolve/*` (own host) |
|
|
69
69
|
|
|
70
70
|
Every method takes an optional last argument `{ ext, signal }` where `ext` is a
|
|
71
71
|
typed bag of `X-Codai-*` extension headers (see below).
|
|
@@ -180,7 +180,8 @@ if (q.status === 'quoted') {
|
|
|
180
180
|
try {
|
|
181
181
|
await codai.resolve.accept(q.id); // free-tier jobs are auto-accepted
|
|
182
182
|
} catch (err) {
|
|
183
|
-
if (err instanceof ResolveInsufficientFundsError)
|
|
183
|
+
if (err instanceof ResolveInsufficientFundsError)
|
|
184
|
+
console.log('top up:', err.topupUrl, err.bundleUrl ?? ''); // bundleUrl: t7 only
|
|
184
185
|
throw err;
|
|
185
186
|
}
|
|
186
187
|
}
|
|
@@ -198,6 +199,15 @@ with `balance`, `required`, `currency: 'micro_eur'` and `topupUrl`. `submit` and
|
|
|
198
199
|
`accept` are never retried. `waitFor` stops at `resolved | failed | declined | error`
|
|
199
200
|
(or `until`), and throws `ResolveError` with `status: 0` on timeout.
|
|
200
201
|
|
|
202
|
+
**Pricing.** Your first paid accept holds **€1** instead of the list price (the quote then
|
|
203
|
+
carries `intro_price_micro_eur` / `list_price_micro_eur`); it is used up only by a verified
|
|
204
|
+
fix — a failed intro job is refunded and the intro is offered again. A **fix bundle** (€49 = 10
|
|
205
|
+
credits, <https://pay.codai.ro/checkout?bundle=resolve10>) pays for `t7` jobs only: a credit is
|
|
206
|
+
taken at accept instead of a wallet hold and returned on failure. Precedence:
|
|
207
|
+
free > intro > credit (t7) > wallet; `accept()` reports it in `paid_with`, and a t7 `402`
|
|
208
|
+
carries `bundleUrl`. `codai.resolve.balance()` returns `fix_credits`, `intro_available` and
|
|
209
|
+
`wallet_micro_eur`.
|
|
210
|
+
|
|
201
211
|
### Webhooks instead of polling
|
|
202
212
|
|
|
203
213
|
Pass `callback_url` (https, public host) on `submit`; the response carries
|
package/dist/index.d.ts
CHANGED
|
@@ -10940,6 +10940,28 @@ type paths = {
|
|
|
10940
10940
|
readonly patch?: never;
|
|
10941
10941
|
readonly trace?: never;
|
|
10942
10942
|
};
|
|
10943
|
+
readonly '/v1/resolve/balance': {
|
|
10944
|
+
readonly parameters: {
|
|
10945
|
+
readonly query?: never;
|
|
10946
|
+
readonly header?: never;
|
|
10947
|
+
readonly path?: never;
|
|
10948
|
+
readonly cookie?: never;
|
|
10949
|
+
};
|
|
10950
|
+
/**
|
|
10951
|
+
* Fix credits, intro availability and wallet balance
|
|
10952
|
+
* @description Returns what you can pay with right now: the fix-credit balance (usable only on `t7`
|
|
10953
|
+
* jobs), whether the €1 intro price is still available (no verified paid job yet and no
|
|
10954
|
+
* other intro job in flight) and the wallet balance in EUR micros.
|
|
10955
|
+
*/
|
|
10956
|
+
readonly get: operations['getResolveBalance'];
|
|
10957
|
+
readonly put?: never;
|
|
10958
|
+
readonly post?: never;
|
|
10959
|
+
readonly delete?: never;
|
|
10960
|
+
readonly options?: never;
|
|
10961
|
+
readonly head?: never;
|
|
10962
|
+
readonly patch?: never;
|
|
10963
|
+
readonly trace?: never;
|
|
10964
|
+
};
|
|
10943
10965
|
readonly '/v1/resolve/jobs': {
|
|
10944
10966
|
readonly parameters: {
|
|
10945
10967
|
readonly query?: never;
|
|
@@ -11016,6 +11038,11 @@ type paths = {
|
|
|
11016
11038
|
* price). The hold is kept on a verified fix and refunded in full otherwise. If the
|
|
11017
11039
|
* balance is short, the answer is `402 insufficient_funds` with the shortfall and a
|
|
11018
11040
|
* top-up link, and the job stays `quoted` — top up, then call `/accept` again.
|
|
11041
|
+
*
|
|
11042
|
+
* Payment precedence: `intro` (first paid job, €1 hold) > `credit` (t7 only, one fix credit,
|
|
11043
|
+
* no wallet hold) > `wallet` (hold of the list price). `paid_with` in the response says which
|
|
11044
|
+
* was used; `held_micro_eur` is the wallet amount held (`0` for a credit). For a `t7` job the
|
|
11045
|
+
* `402` also carries `bundle_url` (10 fixes for €49).
|
|
11019
11046
|
*/
|
|
11020
11047
|
readonly post: operations['acceptResolveJob'];
|
|
11021
11048
|
readonly delete?: never;
|
|
@@ -11053,8 +11080,14 @@ type components = {
|
|
|
11053
11080
|
schemas: {
|
|
11054
11081
|
/** Accepted */
|
|
11055
11082
|
readonly ResolveAccepted: {
|
|
11083
|
+
/**
|
|
11084
|
+
* @description Amount held on the wallet in EUR micros — `1000000` for the intro, the quote for `wallet`, `0` for `credit`.
|
|
11085
|
+
* @example 1000000
|
|
11086
|
+
*/
|
|
11087
|
+
readonly held_micro_eur: number;
|
|
11056
11088
|
/** Format: uuid */
|
|
11057
11089
|
readonly id: string;
|
|
11090
|
+
readonly paid_with: components['schemas']['ResolvePaidWith'];
|
|
11058
11091
|
/** @constant */
|
|
11059
11092
|
readonly status: 'accepted';
|
|
11060
11093
|
};
|
|
@@ -11123,6 +11156,24 @@ type components = {
|
|
|
11123
11156
|
readonly sig: string;
|
|
11124
11157
|
}[];
|
|
11125
11158
|
};
|
|
11159
|
+
/**
|
|
11160
|
+
* Balance
|
|
11161
|
+
* @description Body of `GET /v1/resolve/balance`.
|
|
11162
|
+
*/
|
|
11163
|
+
readonly ResolveBalance: {
|
|
11164
|
+
/**
|
|
11165
|
+
* @description Fix credits left (usable only on `t7` jobs). Buy 10 for €49 at https://pay.codai.ro/checkout?bundle=resolve10.
|
|
11166
|
+
* @example 10
|
|
11167
|
+
*/
|
|
11168
|
+
readonly fix_credits: number;
|
|
11169
|
+
/** @description `true` while your next paid accept would hold the €1 intro price. */
|
|
11170
|
+
readonly intro_available: boolean;
|
|
11171
|
+
/**
|
|
11172
|
+
* @description Wallet balance in EUR micros (`5000000` = €5.00).
|
|
11173
|
+
* @example 5000000
|
|
11174
|
+
*/
|
|
11175
|
+
readonly wallet_micro_eur: number;
|
|
11176
|
+
};
|
|
11126
11177
|
/**
|
|
11127
11178
|
* Declined
|
|
11128
11179
|
* @description `200` body — triage declined the issue. The job is persisted with `status: declined` and is never billed.
|
|
@@ -11167,6 +11218,12 @@ type components = {
|
|
|
11167
11218
|
* @example 5000000
|
|
11168
11219
|
*/
|
|
11169
11220
|
readonly balance: number;
|
|
11221
|
+
/**
|
|
11222
|
+
* Format: uri
|
|
11223
|
+
* @description Present only for a `t7` job — checkout for the fix bundle (10 t7 fix credits for €49).
|
|
11224
|
+
* @example https://pay.codai.ro/checkout?bundle=resolve10
|
|
11225
|
+
*/
|
|
11226
|
+
readonly bundle_url?: string;
|
|
11170
11227
|
/**
|
|
11171
11228
|
* @description Unit of `balance` and `required`.
|
|
11172
11229
|
* @constant
|
|
@@ -11247,6 +11304,8 @@ type components = {
|
|
|
11247
11304
|
readonly fail_reason: string | null;
|
|
11248
11305
|
/** Format: uuid */
|
|
11249
11306
|
readonly id: string;
|
|
11307
|
+
/** @description Present once the job was accepted (and recorded how it was paid). */
|
|
11308
|
+
readonly paid_with?: components['schemas']['ResolvePaidWith'];
|
|
11250
11309
|
/** @description Quoted price in USD micros; `null` until quoted, `0` on the free tier. */
|
|
11251
11310
|
readonly quote_micro_usd: number | null;
|
|
11252
11311
|
/**
|
|
@@ -11286,6 +11345,14 @@ type components = {
|
|
|
11286
11345
|
readonly ResolveKeys: {
|
|
11287
11346
|
readonly keys: readonly components['schemas']['ResolveKey'][];
|
|
11288
11347
|
};
|
|
11348
|
+
/**
|
|
11349
|
+
* Payment method
|
|
11350
|
+
* @description How an accepted job is paid: `free` (free tier), `intro` (first paid job, €1 hold),
|
|
11351
|
+
* `credit` (one t7 fix credit, no wallet hold) or `wallet` (hold of the list price).
|
|
11352
|
+
* Precedence: `free` > `intro` > `credit` > `wallet`.
|
|
11353
|
+
* @enum {string}
|
|
11354
|
+
*/
|
|
11355
|
+
readonly ResolvePaidWith: 'intro' | 'credit' | 'wallet' | 'free';
|
|
11289
11356
|
/**
|
|
11290
11357
|
* Quote
|
|
11291
11358
|
* @description `201` body — the job was quoted (`quoted`) or auto-accepted on the free tier (`accepted`).
|
|
@@ -11301,6 +11368,17 @@ type components = {
|
|
|
11301
11368
|
readonly free_tier_remaining: number;
|
|
11302
11369
|
/** Format: uuid */
|
|
11303
11370
|
readonly id: string;
|
|
11371
|
+
/**
|
|
11372
|
+
* @description Present only on a `quoted` job while the intro price applies to you: accepting holds
|
|
11373
|
+
* this amount (EUR micros, `1000000` = €1) instead of the list price.
|
|
11374
|
+
* @example 1000000
|
|
11375
|
+
*/
|
|
11376
|
+
readonly intro_price_micro_eur?: number;
|
|
11377
|
+
/**
|
|
11378
|
+
* @description Present together with `intro_price_micro_eur`; the regular hold in EUR micros (the quote 1:1).
|
|
11379
|
+
* @example 7000000
|
|
11380
|
+
*/
|
|
11381
|
+
readonly list_price_micro_eur?: number;
|
|
11304
11382
|
/**
|
|
11305
11383
|
* @description Quoted price in USD micros (`7000000` = $7). `0` on the free tier.
|
|
11306
11384
|
* @example 7000000
|
|
@@ -11421,7 +11499,8 @@ type components = {
|
|
|
11421
11499
|
/**
|
|
11422
11500
|
* @description The wallet balance does not cover the quote. Nothing was debited and the job is still
|
|
11423
11501
|
* `quoted`. Open `topup_url` (pay.codai.ro checkout, shortfall rounded up to whole euros,
|
|
11424
|
-
* minimum €10, maximum €1000),
|
|
11502
|
+
* minimum €10, maximum €1000) — or, for a `t7` job, `bundle_url` (10 fix credits for €49) —
|
|
11503
|
+
* then retry `/accept`.
|
|
11425
11504
|
*/
|
|
11426
11505
|
readonly ResolveInsufficientFunds: {
|
|
11427
11506
|
headers: {
|
|
@@ -11525,6 +11604,27 @@ interface operations {
|
|
|
11525
11604
|
readonly 404: components['responses']['ResolveNotFound'];
|
|
11526
11605
|
};
|
|
11527
11606
|
};
|
|
11607
|
+
readonly getResolveBalance: {
|
|
11608
|
+
readonly parameters: {
|
|
11609
|
+
readonly query?: never;
|
|
11610
|
+
readonly header?: never;
|
|
11611
|
+
readonly path?: never;
|
|
11612
|
+
readonly cookie?: never;
|
|
11613
|
+
};
|
|
11614
|
+
readonly requestBody?: never;
|
|
11615
|
+
readonly responses: {
|
|
11616
|
+
/** @description Current balance. */
|
|
11617
|
+
readonly 200: {
|
|
11618
|
+
headers: {
|
|
11619
|
+
readonly [name: string]: unknown;
|
|
11620
|
+
};
|
|
11621
|
+
content: {
|
|
11622
|
+
readonly 'application/json': components['schemas']['ResolveBalance'];
|
|
11623
|
+
};
|
|
11624
|
+
};
|
|
11625
|
+
readonly 401: components['responses']['ResolveUnauthorized'];
|
|
11626
|
+
};
|
|
11627
|
+
};
|
|
11528
11628
|
readonly createResolveJob: {
|
|
11529
11629
|
readonly parameters: {
|
|
11530
11630
|
readonly query?: never;
|
|
@@ -11690,6 +11790,10 @@ type ResolveDeclined = ResolveSchemas['ResolveDeclined'];
|
|
|
11690
11790
|
/** `submit()` result: `201` quote / free-tier auto-accept, or `200` decline. */
|
|
11691
11791
|
type ResolveSubmitResult = ResolveQuote | ResolveDeclined;
|
|
11692
11792
|
type ResolveAccepted = ResolveSchemas['ResolveAccepted'];
|
|
11793
|
+
/** How an accepted job is paid: `free` > `intro` (€1) > `credit` (t7 fix credit) > `wallet`. */
|
|
11794
|
+
type ResolvePaidWith = ResolveSchemas['ResolvePaidWith'];
|
|
11795
|
+
/** `GET /v1/resolve/balance` — fix credits, intro availability, wallet (EUR micros). */
|
|
11796
|
+
type ResolveBalance = ResolveSchemas['ResolveBalance'];
|
|
11693
11797
|
type ResolveJob = ResolveSchemas['ResolveJob'];
|
|
11694
11798
|
type ResolveJobStatus = ResolveSchemas['ResolveJobStatus'];
|
|
11695
11799
|
type ResolveTier = ResolveSchemas['ResolveTier'];
|
|
@@ -11762,6 +11866,8 @@ declare class ResolveInsufficientFundsError extends ResolveError {
|
|
|
11762
11866
|
readonly currency: 'micro_eur';
|
|
11763
11867
|
/** pay.codai.ro checkout link for the shortfall — open it, then retry `accept()`. */
|
|
11764
11868
|
readonly topupUrl: string;
|
|
11869
|
+
/** Present only for a `t7` job: fix-bundle checkout (10 t7 fix credits for €49). */
|
|
11870
|
+
readonly bundleUrl?: string;
|
|
11765
11871
|
constructor(message: string, body: ResolveInsufficientFunds, meta?: {
|
|
11766
11872
|
requestId?: string | null;
|
|
11767
11873
|
});
|
|
@@ -11794,8 +11900,10 @@ declare class Resolve {
|
|
|
11794
11900
|
get(id: string, opts?: CallOpts$4): Promise<ResolveJob>;
|
|
11795
11901
|
/**
|
|
11796
11902
|
* `POST /v1/resolve/jobs/{id}/accept` — accept a paid quote and start the job.
|
|
11797
|
-
*
|
|
11798
|
-
*
|
|
11903
|
+
* The result's `paid_with` says how it was paid (`intro` €1 hold, `credit`
|
|
11904
|
+
* t7 fix credit, or `wallet`). Throws `ResolveInsufficientFundsError` (402,
|
|
11905
|
+
* carries `topupUrl`, plus `bundleUrl` for t7) when the wallet is short,
|
|
11906
|
+
* `ResolveError` 409 when the job is not `quoted`.
|
|
11799
11907
|
*/
|
|
11800
11908
|
accept(id: string, opts?: CallOpts$4): Promise<ResolveAccepted>;
|
|
11801
11909
|
/**
|
|
@@ -11805,6 +11913,8 @@ declare class Resolve {
|
|
|
11805
11913
|
attestation(idOrUrl: string, opts?: CallOpts$4): Promise<ResolveAttestation>;
|
|
11806
11914
|
/** `GET /health` — liveness of the Resolve service. */
|
|
11807
11915
|
health(opts?: CallOpts$4): Promise<ResolveHealth>;
|
|
11916
|
+
/** `GET /v1/resolve/balance` — fix credits (t7 only), intro availability and wallet balance. */
|
|
11917
|
+
balance(opts?: CallOpts$4): Promise<ResolveBalance>;
|
|
11808
11918
|
/** `GET /v1/resolve/keys` — public keys that sign attestations (no auth needed server-side). */
|
|
11809
11919
|
keys(opts?: CallOpts$4): Promise<ResolveKeys>;
|
|
11810
11920
|
/**
|
|
@@ -12323,4 +12433,4 @@ declare class Codai {
|
|
|
12323
12433
|
private legacyExt;
|
|
12324
12434
|
}
|
|
12325
12435
|
|
|
12326
|
-
export { Account, type AccountPatchRequest, type AccountPatchResponse, type AccountView, type AgentRun, type AgentRunAccepted, type AgentRunCreateRequest, type AgentRunRequest, type AgentRunResult, type AgentRunStats, type AgentRunStatus, type AgentRunStep, type AgentRunStreamEvent, AgentRuns, type AgentSyncResult, Agents, Audio, Chat, type ChatCallOptions, type ChatCompletionChunk, type ChatCompletionInput, type ChatCompletionRequest, type ChatCompletionResponse, ChatCompletions, type ChatMessage, type ChatOptions, type ChatResult, type ChatStream, type ChatStreamResult, type ChatTool, type ChatToolCall, type ChatUsage, Codai, type CodaiClientOptions, CodaiError, type CodaiRequestExtensions, type Device, type DevicePatch, type DevicePatched, Devices, type DispatchInbox, Embeddings, type EmbeddingsOptions, type EmbeddingsRequest, type EmbeddingsResponse, type EmbeddingsResult, type Environment, type EnvironmentAddMemberBody, type EnvironmentCreateBody, type EnvironmentDetail, type EnvironmentEnrollBody, type EnvironmentEnrollToken, type EnvironmentEnrolled, type EnvironmentMember, type EnvironmentMemberCreated, EnvironmentMembers, type EnvironmentPatchBody, type EnvironmentPort, type EnvironmentPortBody, EnvironmentPorts, type EnvironmentProvider, type EnvironmentRole, type EnvironmentSecret, type EnvironmentSecretSet, EnvironmentSecrets, type EnvironmentSshCa, type EnvironmentSshCert, type EnvironmentSshCertBody, type EnvironmentState, type EnvironmentTaskCreateBody, type EnvironmentTaskCreated, type EnvironmentTaskDetail, type EnvironmentTaskList, EnvironmentTasks, type EnvironmentTransition, Environments, type EphemeralScope, type EphemeralToken, type EphemeralTokenResponse, type ErrorCode, Feedback, type FeedbackRequest, type FeedbackResponse, Health, type HealthReadyResponse, type HealthResponse, type HostExecBody, type HostExecRequest, type HostExecResponse, type HostExecResultBody, type HostOp, type HostPresence, type HostStreamEvent, Hosts, HttpClient, type ListEnvironmentsQuery, type MessageCallOptions, type MessageInput, type MessageRequest, type MessageResponse, type MessageResult, type MessageStream, type MessageStreamEvent, type MessageStreamResult, Messages, type Model, type ModelList, Models, type NotificationList, Notifications, type NotificationsDeleted, type NotificationsRead, OPERATION_METHODS, type Org, type OrgAddMemberBody, type OrgMember, OrgMembers, type OrgRole, Orgs, type PhoneModel, PhoneModels, type Project, type ProjectCreateBody, type ProjectDetail, type ProjectIsolation, type ProjectPatchBody, Projects, RESOLVE_ATTESTATION_PAYLOAD_TYPE, RESOLVE_OPERATION_METHODS, RESOLVE_TERMINAL_STATUSES, type Receipt, Receipts, type RequestOptions, Resolve, type ResolveAccepted, type ResolveAttestation, type ResolveAttestationEnvelope, type ResolveAttestationVerifyResult, type components as ResolveComponents, type ResolveDeclined, ResolveError, type ResolveHealth, type ResolveInsufficientFunds, ResolveInsufficientFundsError, type ResolveIntake, type ResolveJob, type ResolveJobStatus, type ResolveKey, type ResolveKeys, type operations as ResolveOperations, type paths as ResolvePaths, type ResolveQuote, type ResolveReproTest, type ResolveSubmitResult, type ResolveTier, type ResolveValidationDetails, type ResolveWaitOptions, type ResolveWebhookEvent, type ResolveWebhookEventName, type ResolveWebhookJob, Responses, type ResponsesCallOptions, type ResponsesInput, type ResponsesRequest, type ResponsesResponse, type ResponsesResult, type ResponsesStream, type ResponsesStreamEvent, type ResponsesStreamResult, STREAMING_OPERATIONS, type Session, type SessionControl, type SessionControlAccepted, type SessionControlRequest, SessionControls, type SessionCreateRequest, type SessionDetail, type SessionDispatchRequest, type SessionDispatchResponse, type SessionEvent, SessionEvents, type SessionEventsAppendRequest, type SessionEventsAppendResponse, type SessionEventsPage, type SessionIncomingEvent, SessionLease, type SessionLeaseClaimRequest, type SessionLeaseResponse, type SessionListItem, type SessionPatchRequest, type SessionShare, type SessionShareCreateRequest, type SessionShareCreated, SessionShares, type SessionStreamEvent, Sessions, type SharedSession, type SpeechRequest, type SpeechResult, type SseFrame, type StatusResponse, type Task, type TaskConfirmRequest, type TaskConfirmResponse, type TaskListPage, type TaskListQuery, type TaskOutcome, type TaskStats, Tasks, type TokenUsage, Tokens, type ToolFetchRequest, type ToolFetchResponse, type ToolSearchRequest, type ToolSearchResponse, Tools, type TranscriptionOptions, type TranscriptionResponse, type TranscriptionResult, type TriggerCreateRequest, type TriggerCreated, type TriggerEvents, type TriggerList, type TriggerPatch, type TriggerTestRequest, type TriggerTestResult, type TriggerUpdated, Triggers, type VerifyResolveWebhookOptions, type components$1 as components, Codai as default, extensionHeaders, frameJson, mergeToolCall, type operations$1 as operations, type paths$1 as paths, readSse, resolveAttestationStatement, verifyAttestationWithKeys, verifyResolveWebhook };
|
|
12436
|
+
export { Account, type AccountPatchRequest, type AccountPatchResponse, type AccountView, type AgentRun, type AgentRunAccepted, type AgentRunCreateRequest, type AgentRunRequest, type AgentRunResult, type AgentRunStats, type AgentRunStatus, type AgentRunStep, type AgentRunStreamEvent, AgentRuns, type AgentSyncResult, Agents, Audio, Chat, type ChatCallOptions, type ChatCompletionChunk, type ChatCompletionInput, type ChatCompletionRequest, type ChatCompletionResponse, ChatCompletions, type ChatMessage, type ChatOptions, type ChatResult, type ChatStream, type ChatStreamResult, type ChatTool, type ChatToolCall, type ChatUsage, Codai, type CodaiClientOptions, CodaiError, type CodaiRequestExtensions, type Device, type DevicePatch, type DevicePatched, Devices, type DispatchInbox, Embeddings, type EmbeddingsOptions, type EmbeddingsRequest, type EmbeddingsResponse, type EmbeddingsResult, type Environment, type EnvironmentAddMemberBody, type EnvironmentCreateBody, type EnvironmentDetail, type EnvironmentEnrollBody, type EnvironmentEnrollToken, type EnvironmentEnrolled, type EnvironmentMember, type EnvironmentMemberCreated, EnvironmentMembers, type EnvironmentPatchBody, type EnvironmentPort, type EnvironmentPortBody, EnvironmentPorts, type EnvironmentProvider, type EnvironmentRole, type EnvironmentSecret, type EnvironmentSecretSet, EnvironmentSecrets, type EnvironmentSshCa, type EnvironmentSshCert, type EnvironmentSshCertBody, type EnvironmentState, type EnvironmentTaskCreateBody, type EnvironmentTaskCreated, type EnvironmentTaskDetail, type EnvironmentTaskList, EnvironmentTasks, type EnvironmentTransition, Environments, type EphemeralScope, type EphemeralToken, type EphemeralTokenResponse, type ErrorCode, Feedback, type FeedbackRequest, type FeedbackResponse, Health, type HealthReadyResponse, type HealthResponse, type HostExecBody, type HostExecRequest, type HostExecResponse, type HostExecResultBody, type HostOp, type HostPresence, type HostStreamEvent, Hosts, HttpClient, type ListEnvironmentsQuery, type MessageCallOptions, type MessageInput, type MessageRequest, type MessageResponse, type MessageResult, type MessageStream, type MessageStreamEvent, type MessageStreamResult, Messages, type Model, type ModelList, Models, type NotificationList, Notifications, type NotificationsDeleted, type NotificationsRead, OPERATION_METHODS, type Org, type OrgAddMemberBody, type OrgMember, OrgMembers, type OrgRole, Orgs, type PhoneModel, PhoneModels, type Project, type ProjectCreateBody, type ProjectDetail, type ProjectIsolation, type ProjectPatchBody, Projects, RESOLVE_ATTESTATION_PAYLOAD_TYPE, RESOLVE_OPERATION_METHODS, RESOLVE_TERMINAL_STATUSES, type Receipt, Receipts, type RequestOptions, Resolve, type ResolveAccepted, type ResolveAttestation, type ResolveAttestationEnvelope, type ResolveAttestationVerifyResult, type ResolveBalance, type components as ResolveComponents, type ResolveDeclined, ResolveError, type ResolveHealth, type ResolveInsufficientFunds, ResolveInsufficientFundsError, type ResolveIntake, type ResolveJob, type ResolveJobStatus, type ResolveKey, type ResolveKeys, type operations as ResolveOperations, type ResolvePaidWith, type paths as ResolvePaths, type ResolveQuote, type ResolveReproTest, type ResolveSubmitResult, type ResolveTier, type ResolveValidationDetails, type ResolveWaitOptions, type ResolveWebhookEvent, type ResolveWebhookEventName, type ResolveWebhookJob, Responses, type ResponsesCallOptions, type ResponsesInput, type ResponsesRequest, type ResponsesResponse, type ResponsesResult, type ResponsesStream, type ResponsesStreamEvent, type ResponsesStreamResult, STREAMING_OPERATIONS, type Session, type SessionControl, type SessionControlAccepted, type SessionControlRequest, SessionControls, type SessionCreateRequest, type SessionDetail, type SessionDispatchRequest, type SessionDispatchResponse, type SessionEvent, SessionEvents, type SessionEventsAppendRequest, type SessionEventsAppendResponse, type SessionEventsPage, type SessionIncomingEvent, SessionLease, type SessionLeaseClaimRequest, type SessionLeaseResponse, type SessionListItem, type SessionPatchRequest, type SessionShare, type SessionShareCreateRequest, type SessionShareCreated, SessionShares, type SessionStreamEvent, Sessions, type SharedSession, type SpeechRequest, type SpeechResult, type SseFrame, type StatusResponse, type Task, type TaskConfirmRequest, type TaskConfirmResponse, type TaskListPage, type TaskListQuery, type TaskOutcome, type TaskStats, Tasks, type TokenUsage, Tokens, type ToolFetchRequest, type ToolFetchResponse, type ToolSearchRequest, type ToolSearchResponse, Tools, type TranscriptionOptions, type TranscriptionResponse, type TranscriptionResult, type TriggerCreateRequest, type TriggerCreated, type TriggerEvents, type TriggerList, type TriggerPatch, type TriggerTestRequest, type TriggerTestResult, type TriggerUpdated, Triggers, type VerifyResolveWebhookOptions, type components$1 as components, Codai as default, extensionHeaders, frameJson, mergeToolCall, type operations$1 as operations, type paths$1 as paths, readSse, resolveAttestationStatement, verifyAttestationWithKeys, verifyResolveWebhook };
|
package/dist/index.js
CHANGED
|
@@ -1382,6 +1382,8 @@ var ResolveInsufficientFundsError = class extends ResolveError {
|
|
|
1382
1382
|
currency;
|
|
1383
1383
|
/** pay.codai.ro checkout link for the shortfall — open it, then retry `accept()`. */
|
|
1384
1384
|
topupUrl;
|
|
1385
|
+
/** Present only for a `t7` job: fix-bundle checkout (10 t7 fix credits for €49). */
|
|
1386
|
+
bundleUrl;
|
|
1385
1387
|
constructor(message, body, meta = {}) {
|
|
1386
1388
|
super(message, 402, body, meta);
|
|
1387
1389
|
this.name = "ResolveInsufficientFundsError";
|
|
@@ -1389,6 +1391,7 @@ var ResolveInsufficientFundsError = class extends ResolveError {
|
|
|
1389
1391
|
this.required = body.required;
|
|
1390
1392
|
this.currency = body.currency;
|
|
1391
1393
|
this.topupUrl = body.topup_url;
|
|
1394
|
+
if (typeof body.bundle_url === "string") this.bundleUrl = body.bundle_url;
|
|
1392
1395
|
}
|
|
1393
1396
|
};
|
|
1394
1397
|
var Resolve = class {
|
|
@@ -1420,8 +1423,10 @@ var Resolve = class {
|
|
|
1420
1423
|
}
|
|
1421
1424
|
/**
|
|
1422
1425
|
* `POST /v1/resolve/jobs/{id}/accept` — accept a paid quote and start the job.
|
|
1423
|
-
*
|
|
1424
|
-
*
|
|
1426
|
+
* The result's `paid_with` says how it was paid (`intro` €1 hold, `credit`
|
|
1427
|
+
* t7 fix credit, or `wallet`). Throws `ResolveInsufficientFundsError` (402,
|
|
1428
|
+
* carries `topupUrl`, plus `bundleUrl` for t7) when the wallet is short,
|
|
1429
|
+
* `ResolveError` 409 when the job is not `quoted`.
|
|
1425
1430
|
*/
|
|
1426
1431
|
accept(id, opts = {}) {
|
|
1427
1432
|
return this.call(`/v1/resolve/jobs/${encodeURIComponent(id)}/accept`, {
|
|
@@ -1446,6 +1451,10 @@ var Resolve = class {
|
|
|
1446
1451
|
health(opts = {}) {
|
|
1447
1452
|
return this.call("/health", { signal: opts.signal });
|
|
1448
1453
|
}
|
|
1454
|
+
/** `GET /v1/resolve/balance` — fix credits (t7 only), intro availability and wallet balance. */
|
|
1455
|
+
balance(opts = {}) {
|
|
1456
|
+
return this.call("/v1/resolve/balance", { signal: opts.signal });
|
|
1457
|
+
}
|
|
1449
1458
|
/** `GET /v1/resolve/keys` — public keys that sign attestations (no auth needed server-side). */
|
|
1450
1459
|
keys(opts = {}) {
|
|
1451
1460
|
return this.call("/v1/resolve/keys", { signal: opts.signal });
|
|
@@ -1511,7 +1520,7 @@ function toResolveError(path, err) {
|
|
|
1511
1520
|
if (err.status === 402 && isInsufficientFunds(err.body)) {
|
|
1512
1521
|
const b = err.body;
|
|
1513
1522
|
return new ResolveInsufficientFundsError(
|
|
1514
|
-
`codai-resolve ${path} \u2192 402: insufficient funds (balance ${b.balance}, required ${b.required} ${b.currency}); top up at ${b.topup_url}`,
|
|
1523
|
+
`codai-resolve ${path} \u2192 402: insufficient funds (balance ${b.balance}, required ${b.required} ${b.currency}); top up at ${b.topup_url}${b.bundle_url ? ` or buy 10 t7 fixes for \u20AC49 at ${b.bundle_url}` : ""}`,
|
|
1515
1524
|
b,
|
|
1516
1525
|
meta
|
|
1517
1526
|
);
|
|
@@ -2174,7 +2183,8 @@ var RESOLVE_OPERATION_METHODS = {
|
|
|
2174
2183
|
getResolveJob: "resolve.get",
|
|
2175
2184
|
acceptResolveJob: "resolve.accept",
|
|
2176
2185
|
getResolveAttestation: "resolve.attestation",
|
|
2177
|
-
getResolveKeys: "resolve.keys"
|
|
2186
|
+
getResolveKeys: "resolve.keys",
|
|
2187
|
+
getResolveBalance: "resolve.balance"
|
|
2178
2188
|
};
|
|
2179
2189
|
|
|
2180
2190
|
// src/index.ts
|