@gpt-platform/client 0.4.0 → 0.4.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/dist/index.js CHANGED
@@ -1285,7 +1285,7 @@ function buildUserAgent(sdkVersion, appInfo) {
1285
1285
  }
1286
1286
 
1287
1287
  // src/version.ts
1288
- var SDK_VERSION = "0.4.0";
1288
+ var SDK_VERSION = "0.4.2";
1289
1289
  var DEFAULT_API_VERSION = "2026-02-27";
1290
1290
 
1291
1291
  // src/base-client.ts
@@ -1751,6 +1751,15 @@ var postEmailOutboundEmails = (options) => (options.client ?? client).post({
1751
1751
  ...options.headers
1752
1752
  }
1753
1753
  });
1754
+ var patchWalletCredits = (options) => (options.client ?? client).patch({
1755
+ security: [{ scheme: "bearer", type: "http" }],
1756
+ url: "/wallet/credits",
1757
+ ...options,
1758
+ headers: {
1759
+ "Content-Type": "application/vnd.api+json",
1760
+ ...options.headers
1761
+ }
1762
+ });
1754
1763
  var getCrmCustomEntitiesWorkspaceByWorkspaceId = (options) => (options.client ?? client).get({
1755
1764
  security: [{ scheme: "bearer", type: "http" }],
1756
1765
  url: "/crm/custom-entities/workspace/{workspace_id}",
@@ -2233,6 +2242,15 @@ var postAgentsByIdRestoreVersion = (options) => (options.client ?? client).post(
2233
2242
  ...options.headers
2234
2243
  }
2235
2244
  });
2245
+ var patchWalletAutoTopUp = (options) => (options.client ?? client).patch({
2246
+ security: [{ scheme: "bearer", type: "http" }],
2247
+ url: "/wallet/auto-top-up",
2248
+ ...options,
2249
+ headers: {
2250
+ "Content-Type": "application/vnd.api+json",
2251
+ ...options.headers
2252
+ }
2253
+ });
2236
2254
  var postTokens = (options) => (options.client ?? client).post({
2237
2255
  security: [{ scheme: "bearer", type: "http" }],
2238
2256
  url: "/tokens",
@@ -3268,6 +3286,15 @@ var getVoiceTranscriptionResults = (options) => (options.client ?? client).get({
3268
3286
  url: "/voice/transcription-results",
3269
3287
  ...options
3270
3288
  });
3289
+ var postVoiceTranscriptionResults = (options) => (options.client ?? client).post({
3290
+ security: [{ scheme: "bearer", type: "http" }],
3291
+ url: "/voice/transcription-results",
3292
+ ...options,
3293
+ headers: {
3294
+ "Content-Type": "application/vnd.api+json",
3295
+ ...options.headers
3296
+ }
3297
+ });
3271
3298
  var getDataSubjectRequests = (options) => (options.client ?? client).get({
3272
3299
  security: [{ scheme: "bearer", type: "http" }],
3273
3300
  url: "/data-subject-requests",
@@ -3427,6 +3454,11 @@ var getExtractionSchemaDiscoveriesById = (options) => (options.client ?? client)
3427
3454
  url: "/extraction/schema-discoveries/{id}",
3428
3455
  ...options
3429
3456
  });
3457
+ var getWalletInvoices = (options) => (options.client ?? client).get({
3458
+ security: [{ scheme: "bearer", type: "http" }],
3459
+ url: "/wallet/invoices",
3460
+ ...options
3461
+ });
3430
3462
  var getFieldTemplates = (options) => (options.client ?? client).get({
3431
3463
  security: [{ scheme: "bearer", type: "http" }],
3432
3464
  url: "/field-templates",
@@ -3512,6 +3544,15 @@ var postDocumentsPresignedUpload = (options) => (options.client ?? client).post(
3512
3544
  ...options.headers
3513
3545
  }
3514
3546
  });
3547
+ var postPaymentMethodsTokenize = (options) => (options.client ?? client).post({
3548
+ security: [{ scheme: "bearer", type: "http" }],
3549
+ url: "/payment-methods/tokenize",
3550
+ ...options,
3551
+ headers: {
3552
+ "Content-Type": "application/vnd.api+json",
3553
+ ...options.headers
3554
+ }
3555
+ });
3515
3556
  var getCrmContactsWorkspaceByWorkspaceIdArchived = (options) => (options.client ?? client).get({
3516
3557
  security: [{ scheme: "bearer", type: "http" }],
3517
3558
  url: "/crm/contacts/workspace/{workspace_id}/archived",
@@ -3775,6 +3816,15 @@ var getLegalAcceptancesLatest = (options) => (options.client ?? client).get({
3775
3816
  url: "/legal-acceptances/latest",
3776
3817
  ...options
3777
3818
  });
3819
+ var postThreadsByIdComplete = (options) => (options.client ?? client).post({
3820
+ security: [{ scheme: "bearer", type: "http" }],
3821
+ url: "/threads/{id}/complete",
3822
+ ...options,
3823
+ headers: {
3824
+ "Content-Type": "application/vnd.api+json",
3825
+ ...options.headers
3826
+ }
3827
+ });
3778
3828
  var getWorkspacesShared = (options) => (options.client ?? client).get({
3779
3829
  security: [{ scheme: "bearer", type: "http" }],
3780
3830
  url: "/workspaces/shared",
@@ -3872,6 +3922,15 @@ var postSearchSavedByIdRun = (options) => (options.client ?? client).post({
3872
3922
  ...options.headers
3873
3923
  }
3874
3924
  });
3925
+ var patchWalletPlan = (options) => (options.client ?? client).patch({
3926
+ security: [{ scheme: "bearer", type: "http" }],
3927
+ url: "/wallet/plan",
3928
+ ...options,
3929
+ headers: {
3930
+ "Content-Type": "application/vnd.api+json",
3931
+ ...options.headers
3932
+ }
3933
+ });
3875
3934
  var deleteCatalogProductsById = (options) => (options.client ?? client).delete({
3876
3935
  security: [{ scheme: "bearer", type: "http" }],
3877
3936
  url: "/catalog/products/{id}",
@@ -4169,11 +4228,25 @@ var getAgentVersionRevisionsById = (options) => (options.client ?? client).get({
4169
4228
  url: "/agent-version-revisions/{id}",
4170
4229
  ...options
4171
4230
  });
4231
+ var deleteVoiceTranscriptionResultsById = (options) => (options.client ?? client).delete({
4232
+ security: [{ scheme: "bearer", type: "http" }],
4233
+ url: "/voice/transcription-results/{id}",
4234
+ ...options
4235
+ });
4172
4236
  var getVoiceTranscriptionResultsById = (options) => (options.client ?? client).get({
4173
4237
  security: [{ scheme: "bearer", type: "http" }],
4174
4238
  url: "/voice/transcription-results/{id}",
4175
4239
  ...options
4176
4240
  });
4241
+ var patchVoiceTranscriptionResultsById = (options) => (options.client ?? client).patch({
4242
+ security: [{ scheme: "bearer", type: "http" }],
4243
+ url: "/voice/transcription-results/{id}",
4244
+ ...options,
4245
+ headers: {
4246
+ "Content-Type": "application/vnd.api+json",
4247
+ ...options.headers
4248
+ }
4249
+ });
4177
4250
  var deleteFieldTemplatesById = (options) => (options.client ?? client).delete({
4178
4251
  security: [{ scheme: "bearer", type: "http" }],
4179
4252
  url: "/field-templates/{id}",
@@ -4468,6 +4541,11 @@ var postSupportTags = (options) => (options.client ?? client).post({
4468
4541
  ...options.headers
4469
4542
  }
4470
4543
  });
4544
+ var getWalletPlanPreview = (options) => (options.client ?? client).get({
4545
+ security: [{ scheme: "bearer", type: "http" }],
4546
+ url: "/wallet/plan/preview",
4547
+ ...options
4548
+ });
4471
4549
  var postAgentVersionsByIdSetSystemFields = (options) => (options.client ?? client).post({
4472
4550
  security: [{ scheme: "bearer", type: "http" }],
4473
4551
  url: "/agent-versions/{id}/set-system-fields",
@@ -7163,22 +7241,139 @@ function createBillingNamespace(rb) {
7163
7241
  /**
7164
7242
  * Retrieves the current workspace wallet, including the available credit
7165
7243
  * balance, usage totals, and any pending charges.
7244
+ */
7245
+ get: async (options) => {
7246
+ return rb.execute(getWallet, {}, options);
7247
+ },
7248
+ /**
7249
+ * Preview the cost and effective date of a plan change before committing.
7166
7250
  *
7167
- * @param options - Optional request options such as custom headers or an
7168
- * abort signal.
7169
- * @returns A promise resolving to a record containing wallet fields such as
7170
- * `balance`, `currency`, and usage metadata.
7251
+ * @param planSlug - The slug of the target plan (e.g. `"pro-monthly"`).
7252
+ */
7253
+ previewPlanChange: async (planSlug, options) => {
7254
+ return rb.execute(
7255
+ getWalletPlanPreview,
7256
+ { query: { plan_slug: planSlug } },
7257
+ options
7258
+ );
7259
+ },
7260
+ /**
7261
+ * Change the workspace's subscription plan.
7171
7262
  *
7172
- * @example
7173
- * ```typescript
7174
- * const client = new GptClient({ apiKey: 'sk_app_...' });
7263
+ * Upgrades charge a prorated amount immediately against the default payment
7264
+ * method. Downgrades are deferred to the end of the current billing period.
7265
+ * Use `previewPlanChange` first to show the user a cost estimate.
7175
7266
  *
7176
- * const wallet = await client.billing.wallet.get();
7177
- * console.log(`Available credits: ${wallet.balance}`);
7178
- * ```
7267
+ * @param walletId - The wallet UUID from `wallet.get()`.
7268
+ * @param planSlug - The slug of the target plan (e.g. `"pro-monthly"`).
7179
7269
  */
7180
- get: async (options) => {
7181
- return rb.execute(getWallet, {}, options);
7270
+ changePlan: async (walletId, planSlug, options) => {
7271
+ return rb.execute(
7272
+ patchWalletPlan,
7273
+ {
7274
+ body: {
7275
+ data: {
7276
+ id: walletId,
7277
+ type: "wallet",
7278
+ attributes: { plan_slug: planSlug }
7279
+ }
7280
+ }
7281
+ },
7282
+ options
7283
+ );
7284
+ },
7285
+ /**
7286
+ * Purchase a credit package to top up the workspace wallet immediately.
7287
+ *
7288
+ * Charges the specified (or default) payment method. Credits are added to
7289
+ * the `purchased` bucket and never expire.
7290
+ *
7291
+ * @param walletId - The wallet UUID from `wallet.get()`.
7292
+ * @param packageSlug - The slug of the credit package to purchase.
7293
+ * @param paymentMethodId - Optional payment method UUID. Uses the default if omitted.
7294
+ */
7295
+ buyCredits: async (walletId, packageSlug, paymentMethodId, options) => {
7296
+ const attributes = {
7297
+ package_slug: packageSlug
7298
+ };
7299
+ if (paymentMethodId !== void 0) {
7300
+ attributes.payment_method_id = paymentMethodId;
7301
+ }
7302
+ return rb.execute(
7303
+ patchWalletCredits,
7304
+ { body: { data: { id: walletId, type: "wallet", attributes } } },
7305
+ options
7306
+ );
7307
+ },
7308
+ /**
7309
+ * Update the workspace's auto top-up settings.
7310
+ *
7311
+ * When enabled, the platform automatically purchases the specified credit
7312
+ * package whenever the balance drops below `threshold`.
7313
+ *
7314
+ * @param walletId - The wallet UUID from `wallet.get()`.
7315
+ * @param opts.enabled - Enable or disable auto top-up.
7316
+ * @param opts.threshold - Credit balance floor that triggers a purchase.
7317
+ * @param opts.amount - Credits to purchase per top-up event.
7318
+ * @param opts.packageId - Credit package UUID to auto-purchase.
7319
+ */
7320
+ updateAutoTopUp: async (walletId, opts, options) => {
7321
+ const attributes = { enabled: opts.enabled };
7322
+ if (opts.threshold !== void 0) attributes.threshold = opts.threshold;
7323
+ if (opts.amount !== void 0) attributes.amount = opts.amount;
7324
+ if (opts.packageId !== void 0)
7325
+ attributes.package_id = opts.packageId;
7326
+ return rb.execute(
7327
+ patchWalletAutoTopUp,
7328
+ { body: { data: { id: walletId, type: "wallet", attributes } } },
7329
+ options
7330
+ );
7331
+ },
7332
+ /**
7333
+ * Sub-namespace for invoice operations.
7334
+ *
7335
+ * Invoices are generated per billing period and carry a `pdf_url` for
7336
+ * receipt download. Use `invoices.list()` for the transaction history page.
7337
+ */
7338
+ invoices: {
7339
+ /**
7340
+ * Returns a single page of invoices for the current workspace.
7341
+ *
7342
+ * Each invoice includes `pdf_url` for receipt download.
7343
+ *
7344
+ * @example
7345
+ * ```typescript
7346
+ * const invoices = await client.billing.wallet.invoices.list();
7347
+ * const paidInvoices = invoices.filter(inv => inv.attributes?.status === "paid");
7348
+ * ```
7349
+ */
7350
+ list: async (options) => {
7351
+ return rb.execute(
7352
+ getWalletInvoices,
7353
+ buildPageQuery(options?.page, options?.pageSize),
7354
+ options
7355
+ );
7356
+ },
7357
+ /**
7358
+ * Fetches all invoices by automatically paginating through every page.
7359
+ *
7360
+ * @example
7361
+ * ```typescript
7362
+ * const all = await client.billing.wallet.invoices.listAll();
7363
+ * const downloadUrl = all[0].attributes?.pdf_url;
7364
+ * ```
7365
+ */
7366
+ listAll: async (options) => {
7367
+ return paginateToArray(
7368
+ rb.createPaginatedFetcher(
7369
+ getWalletInvoices,
7370
+ (page, pageSize) => ({
7371
+ query: { page: { number: page, size: pageSize } }
7372
+ }),
7373
+ options
7374
+ )
7375
+ );
7376
+ }
7182
7377
  }
7183
7378
  },
7184
7379
  /**
@@ -7566,6 +7761,27 @@ function createBillingNamespace(rb) {
7566
7761
  options
7567
7762
  );
7568
7763
  },
7764
+ /**
7765
+ * Tokenizes a raw card server-side and saves the resulting payment method.
7766
+ *
7767
+ * Use this for direct card collection flows where your server handles card
7768
+ * data (PCI-DSS scope applies). The platform tokenizes the card with QorPay
7769
+ * and stores only the token — raw card data is never persisted.
7770
+ *
7771
+ * For hosted-fields flows where the client tokenizes the card, use
7772
+ * `paymentMethods.create({ provider_token })` instead.
7773
+ *
7774
+ * @param cardDetails - Raw card fields including number, CVC, expiry, and billing address.
7775
+ */
7776
+ tokenize: async (cardDetails, options) => {
7777
+ return rb.execute(
7778
+ postPaymentMethodsTokenize,
7779
+ {
7780
+ body: { data: { type: "payment_method", attributes: cardDetails } }
7781
+ },
7782
+ options
7783
+ );
7784
+ },
7569
7785
  /**
7570
7786
  * Updates the mutable attributes of an existing payment method, such as
7571
7787
  * the billing name or expiry date override.
@@ -19302,6 +19518,75 @@ function createThreadsNamespace(rb) {
19302
19518
  streamOptions
19303
19519
  );
19304
19520
  }
19521
+ },
19522
+ /**
19523
+ * Trigger AI inference on a thread without sending a new user message.
19524
+ *
19525
+ * Runs the full RAG pipeline (VectorSearch + GraphLookup + SynthesizeResponse)
19526
+ * using the thread's last user message as query context. Saves the AI response
19527
+ * as an assistant message and returns the updated Thread.
19528
+ *
19529
+ * Use this to let the AI proactively continue a conversation — for example,
19530
+ * after a voice session finalizes, to generate a follow-up or summary without
19531
+ * requiring the user to explicitly ask.
19532
+ *
19533
+ * @param threadId - The UUID of the thread to run AI completion on.
19534
+ * @param options - Optional request options.
19535
+ * @returns A promise resolving to the updated `Thread` after the assistant
19536
+ * message has been saved.
19537
+ *
19538
+ * @example
19539
+ * ```typescript
19540
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
19541
+ *
19542
+ * // After a voice session finalizes, trigger AI continuation:
19543
+ * const thread = await client.threads.complete('thr_01HXYZ...');
19544
+ * console.log(`Thread updated at: ${thread.attributes?.updated_at}`);
19545
+ * ```
19546
+ */
19547
+ complete: async (threadId, options) => {
19548
+ return rb.execute(
19549
+ postThreadsByIdComplete,
19550
+ {
19551
+ path: { id: threadId },
19552
+ body: { data: { type: "thread", attributes: {} } }
19553
+ },
19554
+ options
19555
+ );
19556
+ },
19557
+ /**
19558
+ * Trigger AI inference on a thread and receive the response via Server-Sent Events.
19559
+ *
19560
+ * Identical to {@link complete} in behavior but delivers the result as an SSE
19561
+ * stream. The stream yields a single `StreamMessageChunk` with `done: true`
19562
+ * when the AI response is ready.
19563
+ *
19564
+ * Note: This endpoint delivers the full response as one event (not token-by-token).
19565
+ * It gives the frontend a consistent SSE interface for uniform handling of both
19566
+ * streaming and non-streaming completions.
19567
+ *
19568
+ * @param threadId - The UUID of the thread to run AI completion on.
19569
+ * @param options - Optional request options (e.g. abort signal).
19570
+ * @param streamOptions - Optional streaming configuration.
19571
+ * @returns A promise resolving to an `AsyncIterableIterator<StreamMessageChunk>`.
19572
+ *
19573
+ * @example
19574
+ * ```typescript
19575
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
19576
+ *
19577
+ * const stream = await client.threads.completeStream('thr_01HXYZ...');
19578
+ * for await (const chunk of stream) {
19579
+ * if (chunk.type === 'done') console.log(`AI response: ${chunk.content}`);
19580
+ * }
19581
+ * ```
19582
+ */
19583
+ completeStream: async (threadId, options, streamOptions) => {
19584
+ return rb.streamRequest(
19585
+ `/threads/${threadId}/complete/stream`,
19586
+ {},
19587
+ options,
19588
+ streamOptions
19589
+ );
19305
19590
  }
19306
19591
  };
19307
19592
  }
@@ -20184,6 +20469,106 @@ function createVoiceNamespace(rb) {
20184
20469
  },
20185
20470
  options
20186
20471
  );
20472
+ },
20473
+ /**
20474
+ * Create a transcript record manually.
20475
+ *
20476
+ * Creates a `VoiceTranscriptionResult` record in the current workspace.
20477
+ * Useful when you have a pre-computed transcript (e.g. from an external STT
20478
+ * service) that you want to associate with a recording or session.
20479
+ *
20480
+ * @param attributes - Transcript data. Required: `text` (string).
20481
+ * Optional: `recording_id`, `session_id`, `document_id`, `segments`,
20482
+ * `language_detected`, `duration_seconds`, `processing_seconds`,
20483
+ * `stt_engine`, `stt_model`, `metadata`.
20484
+ * @param options - Optional request options.
20485
+ * @returns The created `VoiceTranscriptionResult`.
20486
+ *
20487
+ * @example
20488
+ * ```typescript
20489
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
20490
+ * const result = await client.voice.transcriptionResults.create({
20491
+ * text: 'Patient reports chest pain since this morning.',
20492
+ * session_id: 'vs_abc123',
20493
+ * language_detected: 'en',
20494
+ * duration_seconds: 47.2,
20495
+ * });
20496
+ * console.log(result.id);
20497
+ * ```
20498
+ */
20499
+ create: async (attributes, options) => {
20500
+ return rb.execute(
20501
+ postVoiceTranscriptionResults,
20502
+ {
20503
+ body: {
20504
+ data: {
20505
+ type: "voice_transcription_result",
20506
+ attributes
20507
+ }
20508
+ }
20509
+ },
20510
+ options
20511
+ );
20512
+ },
20513
+ /**
20514
+ * Update a transcript's text, segments, or metadata.
20515
+ *
20516
+ * Allows correcting transcript text after review, updating segments
20517
+ * with corrected timestamps or confidence scores, or annotating with
20518
+ * additional metadata. `recording_id`, `session_id`, and STT engine
20519
+ * fields are immutable after creation.
20520
+ *
20521
+ * @param id - The UUID of the transcription result to update.
20522
+ * @param attributes - Fields to update. One or more of: `text`, `segments`, `metadata`.
20523
+ * @param options - Optional request options.
20524
+ * @returns The updated `VoiceTranscriptionResult`.
20525
+ *
20526
+ * @example
20527
+ * ```typescript
20528
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
20529
+ * const updated = await client.voice.transcriptionResults.update('tr_abc123', {
20530
+ * text: 'Patient reports chest pain since yesterday morning.',
20531
+ * });
20532
+ * ```
20533
+ */
20534
+ update: async (id, attributes, options) => {
20535
+ return rb.execute(
20536
+ patchVoiceTranscriptionResultsById,
20537
+ {
20538
+ path: { id },
20539
+ body: {
20540
+ data: {
20541
+ id,
20542
+ type: "voice_transcription_result",
20543
+ attributes
20544
+ }
20545
+ }
20546
+ },
20547
+ options
20548
+ );
20549
+ },
20550
+ /**
20551
+ * Delete a transcription result by its ID.
20552
+ *
20553
+ * Permanently removes the transcript record. Associated recordings and
20554
+ * voice sessions are not affected.
20555
+ *
20556
+ * @param id - The UUID of the transcription result to delete.
20557
+ * @param options - Optional request options.
20558
+ * @returns A promise that resolves when the record is deleted.
20559
+ *
20560
+ * @example
20561
+ * ```typescript
20562
+ * const client = new GptClient({ apiKey: 'sk_app_...' });
20563
+ * await client.voice.transcriptionResults.destroy('tr_abc123');
20564
+ * ```
20565
+ */
20566
+ destroy: async (id, options) => {
20567
+ await rb.executeDelete(
20568
+ deleteVoiceTranscriptionResultsById,
20569
+ { path: { id } },
20570
+ options
20571
+ );
20187
20572
  }
20188
20573
  }
20189
20574
  };