@agentforge-io/sdk-server 4.29.0 → 4.30.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/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export type { AgentForgeClientOptions, RequestOptions } from './client';
3
3
  export { AgentForgeError, AgentForgeAuthError, AgentForgeNotFoundError, AgentForgeNetworkError, } from './errors';
4
4
  export { APP_WEBHOOK_HEADERS, TOOL_CALLBACK_HEADERS, ToolCallbackSignatureError, signToolCallbackPayload, verifyAppWebhook, verifyToolCallbackSignature, } from './webhooks';
5
5
  export { WebhookResource, type SetAppWebhookInput } from './resources/webhook';
6
- export type { AppWebhook, AppWebhookEvent, AppWebhookEventName, AgentMe, AgentSummary, AppUserConnectorStatus, ApprovalCopyBundle, ChannelContext, ChatStreamChunk, ChatStreamEvent, ChatTokenRecord, ConnectorDefaultsResult, ConnectorDefaultsSource, ConnectorResourceItem, ConnectorStatus, ConnectorToolInfo, ConversationHistory, ConversationStatus, CreateAgentInput, CreateClickupTaskInput, CreateClickupTaskResult, ExternalToolSummary, IssueChatTokenInput, ListAgentsResult, ListConnectorResourcesResult, McpServerConfig, MessageRecord, MessageRole, PublicAppBranding, PublicProfileBlock, PublicProfileTemplate, PublicTeamLanding, CreateTeamInput, UpdateTeamInput, TeamSummary, TeamDetail, TeamTheme, TeamBusinessHours, TeamWeekday, TeamProfileBlock, AppInstallation, TemplateConfigField, TemplateSummary, TemplateDetail, TemplateCategoryRef, MarketplaceCategory, MarketplaceCategoryGroup, MarketplaceLocale, TemplateInstallResult, TenantConfigEntry, Place, SearchPlacesInput, CaseField, CaseBusinessState, CaseType, CaseState, CaseView, CaseReceipt, CaseReceiptLine, ListCasesInput, AddressValue, DeliveryLocalPricing, DeliverySettings, PaymentMethodKind, PaymentSettings, PaymentSettingsInput, PaymentAccount, PaymentCountry, PaymentFieldDef, PaymentMethodDef, StructuredConfigInput, StructuredConfigEntry, DeliveryQuoteStatus, DeliveryQuoteInput, DeliveryQuote, AppSelf, AppSelfConnector, AppSelfConnectors, AppSelfConnectorTools, AppSelfConnectorToolsResponse, RegisterToolInput, RegisterToolsInput, BusinessRoleEntry, Catalog, CatalogCheckoutCta, CatalogCategory, CatalogProduct, CatalogProductPhoto, CatalogProductKind, CatalogProductStatus, CatalogPriceKind, CatalogAvailability, CatalogLockableField, CatalogProductPage, UpsertCatalogInput, CreateCatalogCategoryInput, UpdateCatalogCategoryInput, CreateCatalogProductInput, UpdateCatalogProductInput, ListCatalogProductsInput, CatalogPhotoUploadTarget, SignCatalogPhotoUploadInput, AttachCatalogPhotoInput, CatalogImportItem, CatalogImportPreview, CatalogImportApplyResult, CatalogFileMapping, CatalogFilePlan, CatalogFilePreview, CatalogFileApplyResult, CatalogFileInput, CatalogFilePreviewInput, CatalogFileApplyInput, CatalogFileErrorCode, CatalogImportSourceStatus, CatalogImportColumnMapping, CatalogImportRunResult, CatalogImportSource, CreateCatalogImportSourceInput, UpdateCatalogImportSourceInput, PreviewCatalogImportSourceInput, CatalogImportSourcePreview, CatalogSheetTab, CatalogTemplateSheet, CreateCatalogTemplateSheetInput, GoogleSheetsPickerInput, GoogleSheetsPickerSession, GoogleSheetsPickerErrorCode, GoogleSheetsPickerResult, RegisterToolsResult, ToolCallbackPayload, ToolCallRecord, ToolPermission, ToolPermissionMode, TokenUsage, TenantSecretEntry, UpdateAgentInput, InboxThreadMode, InboxMessageDirection, InboxMessageSource, InboxMessageType, InboxThreadCustomerProfileView, InboxThreadView, InboxMessageView, SupportKpiTotals, SupportKpiResponse, AgentAttentionLogRow, } from './types';
6
+ export type { AppWebhook, AppWebhookEvent, AppWebhookEventName, AgentMe, AgentSummary, AppUserConnectorStatus, ApprovalCopyBundle, ChannelContext, ChatStreamChunk, ChatStreamEvent, ChatTokenRecord, ConnectorDefaultsResult, ConnectorDefaultsSource, ConnectorResourceItem, ConnectorStatus, ConnectorToolInfo, ConversationHistory, ConversationStatus, CreateAgentInput, CreateClickupTaskInput, CreateClickupTaskResult, ExternalToolSummary, IssueChatTokenInput, ListAgentsResult, ListConnectorResourcesResult, McpServerConfig, MessageRecord, MessageRole, PublicAppBranding, PublicProfileBlock, PublicProfileTemplate, PublicTeamLanding, CreateTeamInput, UpdateTeamInput, TeamSummary, TeamDetail, TeamTheme, TeamBusinessHours, TeamWeekday, TeamProfileBlock, AppInstallation, TemplateConfigField, TemplateSummary, TemplateDetail, TemplateCategoryRef, MarketplaceCategory, MarketplaceCategoryGroup, MarketplaceLocale, TemplateInstallResult, TenantConfigEntry, Place, SearchPlacesInput, CaseField, CaseBusinessState, CaseType, CaseState, CasePayment, CasePaymentAccount, CasePaymentStatus, CaseReceiptPayment, CaseView, CaseReceipt, CaseReceiptLine, ListCasesInput, AddressValue, DeliveryLocalPricing, DeliverySettings, PaymentMethodKind, PaymentSettings, PaymentSettingsInput, PaymentAccount, PaymentCountry, PaymentFieldDef, PaymentMethodDef, StructuredConfigInput, StructuredConfigEntry, DeliveryQuoteStatus, DeliveryQuoteInput, DeliveryQuote, AppSelf, AppSelfConnector, AppSelfConnectors, AppSelfConnectorTools, AppSelfConnectorToolsResponse, RegisterToolInput, RegisterToolsInput, BusinessRoleEntry, Catalog, CatalogCheckoutCta, CatalogCategory, CatalogProduct, CatalogProductPhoto, CatalogProductKind, CatalogProductStatus, CatalogPriceKind, CatalogAvailability, CatalogLockableField, CatalogProductPage, UpsertCatalogInput, CreateCatalogCategoryInput, UpdateCatalogCategoryInput, CreateCatalogProductInput, UpdateCatalogProductInput, ListCatalogProductsInput, CatalogPhotoUploadTarget, SignCatalogPhotoUploadInput, AttachCatalogPhotoInput, CatalogImportItem, CatalogImportPreview, CatalogImportApplyResult, CatalogFileMapping, CatalogFilePlan, CatalogFilePreview, CatalogFileApplyResult, CatalogFileInput, CatalogFilePreviewInput, CatalogFileApplyInput, CatalogFileErrorCode, CatalogImportSourceStatus, CatalogImportColumnMapping, CatalogImportRunResult, CatalogImportSource, CreateCatalogImportSourceInput, UpdateCatalogImportSourceInput, PreviewCatalogImportSourceInput, CatalogImportSourcePreview, CatalogSheetTab, CatalogTemplateSheet, CreateCatalogTemplateSheetInput, GoogleSheetsPickerInput, GoogleSheetsPickerSession, GoogleSheetsPickerErrorCode, GoogleSheetsPickerResult, RegisterToolsResult, ToolCallbackPayload, ToolCallRecord, ToolPermission, ToolPermissionMode, TokenUsage, TenantSecretEntry, UpdateAgentInput, InboxThreadMode, InboxMessageDirection, InboxMessageSource, InboxMessageType, InboxThreadCustomerProfileView, InboxThreadView, InboxMessageView, SupportKpiTotals, SupportKpiResponse, AgentAttentionLogRow, } from './types';
7
7
  export { AgentsResource } from './resources/agents';
8
8
  export { AnalyticsResource } from './resources/analytics';
9
9
  export type { GetSupportKpisInput, GetAgentAttentionLogInput, } from './resources/analytics';
@@ -1,5 +1,5 @@
1
1
  import type { AgentForgeClient } from '../client';
2
- import type { CaseReceipt, CaseState, CaseView, ListCasesInput } from '../types';
2
+ import type { CasePaymentStatus, CaseReceipt, CaseState, CaseView, ListCasesInput } from '../types';
3
3
  export declare class CasesResource {
4
4
  private readonly client;
5
5
  constructor(client: AgentForgeClient);
@@ -27,6 +27,33 @@ export declare class CasesResource {
27
27
  * it was accepted or once closed. Returns the receipt as it is now.
28
28
  */
29
29
  receiptReceived(token: string): Promise<CaseReceipt>;
30
+ /**
31
+ * `POST /api/v1/cases/:id/payment` — AGF-PAYMENT-ACCOUNTS: the business moves the
32
+ * payment: `paid` (confirmed, or cash received), `rejected` (did not arrive),
33
+ * `refunded`, `partially_refunded` (with `amountCents` returned), `reversed`.
34
+ * The customer is told of paid, rejected and refunds.
35
+ */
36
+ setPayment(caseId: string, status: CasePaymentStatus, opts?: {
37
+ note?: string;
38
+ amountCents?: number;
39
+ }): Promise<CaseView>;
40
+ /**
41
+ * `POST /api/v1/cases/receipts/:token/payment/choose` — the customer chooses how
42
+ * to pay on the receipt (an `accountId` from `payment.options`).
43
+ */
44
+ receiptChoosePayment(token: string, accountId: string): Promise<CaseReceipt>;
45
+ /**
46
+ * `POST /api/v1/cases/receipts/:token/payment/report` — the customer says they
47
+ * paid: the transfer `reference` and/or the `proof` image (jpeg/png/webp, base64,
48
+ * ≤ 700 KB). The payment waits for the business to confirm it.
49
+ */
50
+ receiptReportPayment(token: string, input: {
51
+ reference?: string;
52
+ proof?: {
53
+ contentType: 'image/jpeg' | 'image/png' | 'image/webp';
54
+ dataBase64: string;
55
+ };
56
+ }): Promise<CaseReceipt>;
30
57
  /**
31
58
  * `GET /api/v1/cases/receipts/:token/image.png` — the receipt as a PNG:
32
59
  * `wide` (1200×630, what a shared link previews) or `tall` (1080×1350, to send or save).
@@ -56,6 +56,34 @@ class CasesResource {
56
56
  async receiptReceived(token) {
57
57
  return this.client.request('POST', `/api/v1/cases/receipts/${encodeURIComponent(token)}/received`, {});
58
58
  }
59
+ /**
60
+ * `POST /api/v1/cases/:id/payment` — AGF-PAYMENT-ACCOUNTS: the business moves the
61
+ * payment: `paid` (confirmed, or cash received), `rejected` (did not arrive),
62
+ * `refunded`, `partially_refunded` (with `amountCents` returned), `reversed`.
63
+ * The customer is told of paid, rejected and refunds.
64
+ */
65
+ async setPayment(caseId, status, opts = {}) {
66
+ return this.client.request('POST', `/api/v1/cases/${encodeURIComponent(caseId)}/payment`, {
67
+ status,
68
+ ...(opts.note ? { note: opts.note } : {}),
69
+ ...(opts.amountCents ? { amountCents: opts.amountCents } : {}),
70
+ });
71
+ }
72
+ /**
73
+ * `POST /api/v1/cases/receipts/:token/payment/choose` — the customer chooses how
74
+ * to pay on the receipt (an `accountId` from `payment.options`).
75
+ */
76
+ async receiptChoosePayment(token, accountId) {
77
+ return this.client.request('POST', `/api/v1/cases/receipts/${encodeURIComponent(token)}/payment/choose`, { accountId });
78
+ }
79
+ /**
80
+ * `POST /api/v1/cases/receipts/:token/payment/report` — the customer says they
81
+ * paid: the transfer `reference` and/or the `proof` image (jpeg/png/webp, base64,
82
+ * ≤ 700 KB). The payment waits for the business to confirm it.
83
+ */
84
+ async receiptReportPayment(token, input) {
85
+ return this.client.request('POST', `/api/v1/cases/receipts/${encodeURIComponent(token)}/payment/report`, input);
86
+ }
59
87
  /**
60
88
  * `GET /api/v1/cases/receipts/:token/image.png` — the receipt as a PNG:
61
89
  * `wide` (1200×630, what a shared link previews) or `tall` (1080×1350, to send or save).
package/dist/types.d.ts CHANGED
@@ -1497,6 +1497,8 @@ export interface PaymentMethodDef {
1497
1497
  /** When the customer pays: before it is sent, or when they get it. */
1498
1498
  when: 'before' | 'on_delivery';
1499
1499
  fields: PaymentFieldDef[];
1500
+ /** One per business (cash): no name to tell accounts apart, a second one is refused. */
1501
+ single?: boolean;
1500
1502
  }
1501
1503
  /** One way to pay into the business, with the data a customer needs. Several per method allowed. */
1502
1504
  export interface PaymentAccount {
@@ -1682,12 +1684,88 @@ export interface CaseView {
1682
1684
  text: string;
1683
1685
  at: string;
1684
1686
  } | null;
1687
+ /** AGF-PAYMENT-ACCOUNTS — how it is paid: null before the business took it (or closed undone with nothing chosen). */
1688
+ payment: CasePayment | null;
1685
1689
  openedAt: string;
1686
1690
  reviewedAt: string | null;
1687
1691
  submittedAt: string | null;
1688
1692
  closedAt: string | null;
1689
1693
  lastActivityAt: string;
1690
1694
  }
1695
+ /**
1696
+ * The payment's own lifecycle, apart from the case's states: `unpaid` →
1697
+ * `awaiting_payment` (method chosen) → `pending_confirmation` (the customer
1698
+ * reported it) → `paid` | `rejected`; then `refunded`, `partially_refunded`,
1699
+ * `reversed`; `voided` when the order ended unpaid. Completing never marks it paid.
1700
+ */
1701
+ export type CasePaymentStatus = 'unpaid' | 'awaiting_payment' | 'pending_confirmation' | 'paid' | 'rejected' | 'refunded' | 'partially_refunded' | 'reversed' | 'voided';
1702
+ /** The account the customer chose, as it was then (a later edit never rewrites a sale). */
1703
+ export interface CasePaymentAccount {
1704
+ id: string;
1705
+ method: string;
1706
+ methodName: string;
1707
+ label?: string;
1708
+ when: 'before' | 'on_delivery';
1709
+ /** "Nequi (Principal): 3001234567 a nombre de Ana Pérez". */
1710
+ line: string;
1711
+ /** What to copy to pay (empty for cash / card terminal). */
1712
+ copy: Array<{
1713
+ label: string;
1714
+ value: string;
1715
+ }>;
1716
+ notes?: string;
1717
+ }
1718
+ export interface CasePayment {
1719
+ status: CasePaymentStatus;
1720
+ statusLabel: string;
1721
+ account?: CasePaymentAccount;
1722
+ reference?: string;
1723
+ /** The proof image the customer sent (for the business). */
1724
+ proofUrl?: string;
1725
+ reportedAt?: string;
1726
+ confirmedAt?: string;
1727
+ refundedCents?: number;
1728
+ /** The business's note on its last move of the payment. */
1729
+ note?: string;
1730
+ /** The receipt's total, when every line has a price. */
1731
+ amountCents: number | null;
1732
+ currency: string | null;
1733
+ /** Where the business may move it now. */
1734
+ nextStatuses: Array<{
1735
+ key: CasePaymentStatus;
1736
+ label: string;
1737
+ }>;
1738
+ history: Array<{
1739
+ status: CasePaymentStatus;
1740
+ by: 'assistant' | 'customer' | 'business' | 'system';
1741
+ at: string;
1742
+ note?: string;
1743
+ amountCents?: number;
1744
+ }>;
1745
+ }
1746
+ /** The payment as a receipt's public link shows it (no proof image, only that one was sent). */
1747
+ export interface CaseReceiptPayment {
1748
+ status: CasePaymentStatus;
1749
+ statusLabel: string;
1750
+ account: CasePaymentAccount | null;
1751
+ amountCents: number | null;
1752
+ currency: string | null;
1753
+ reference: string | null;
1754
+ proofSent: boolean;
1755
+ reportedAt: string | null;
1756
+ confirmedAt: string | null;
1757
+ note: string | null;
1758
+ /** Methods the customer may choose now (`cases.receiptChoosePayment`). */
1759
+ options: Array<{
1760
+ accountId: string;
1761
+ method: string;
1762
+ methodName: string;
1763
+ label?: string;
1764
+ when: 'before' | 'on_delivery';
1765
+ }>;
1766
+ /** The customer may say they paid now (`cases.receiptReportPayment`). */
1767
+ canReport: boolean;
1768
+ }
1691
1769
  /** AGF-CASE-RECEIPT — one product line, with the price it had when the receipt was issued. */
1692
1770
  export interface CaseReceiptLine {
1693
1771
  title: string;
@@ -1738,6 +1816,8 @@ export interface CaseReceipt {
1738
1816
  /** Closed without being done (rejected, cancelled, abandoned). */
1739
1817
  stopped: boolean;
1740
1818
  updatedAt: string;
1819
+ /** AGF-PAYMENT-ACCOUNTS — how it is paid; null before the business took it. */
1820
+ payment: CaseReceiptPayment | null;
1741
1821
  business: {
1742
1822
  name: string;
1743
1823
  description: string | null;
@@ -1756,7 +1836,7 @@ export interface ListCasesInput {
1756
1836
  /** 1–200, default 50. */
1757
1837
  limit?: number;
1758
1838
  }
1759
- export type AppWebhookEventName = 'case.submitted' | 'case.state_changed' | 'case.closed' | 'case.customer_request';
1839
+ export type AppWebhookEventName = 'case.submitted' | 'case.state_changed' | 'case.closed' | 'case.customer_request' | 'case.payment_changed';
1760
1840
  export interface AppWebhook {
1761
1841
  url: string;
1762
1842
  events: AppWebhookEventName[];
@@ -1786,6 +1866,9 @@ export interface AppWebhookEvent {
1786
1866
  /** What people read it by ("K7Q2XM"). */
1787
1867
  caseCode?: string;
1788
1868
  conversationId: string;
1869
+ /** `case.payment_changed`: where the payment is now, and where it was. */
1870
+ paymentStatus?: CasePaymentStatus;
1871
+ previousPaymentStatus?: CasePaymentStatus;
1789
1872
  };
1790
1873
  }
1791
1874
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentforge-io/sdk-server",
3
- "version": "4.29.0",
3
+ "version": "4.30.0",
4
4
  "description": "Server-side SDK for backend apps integrating with AgentForge platform. Auth via ChatToken, ak_live_ API key or App secret (sk_live_), with App installations across tenants.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",