@agentforge-io/sdk-server 4.71.0 → 4.72.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/errors.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { TemplatePublishIssue } from './types';
1
2
  export declare class AgentForgeError extends Error {
2
3
  readonly status: number;
3
4
  readonly body?: string;
@@ -15,6 +16,10 @@ export declare class AgentForgeError extends Error {
15
16
  /** PDK-CONSOLE. `issues` of the response body (publication-issue shape) when
16
17
  * present, e.g. on `publisher_policy_violation`. */
17
18
  readonly issues?: unknown[];
19
+ /** PDK-PILLARS. `errors` / `warnings` of the response body when present (e.g. 400
20
+ * `template_not_publishable`). Same shape as `TemplatePublishIssue`. */
21
+ readonly errors?: TemplatePublishIssue[];
22
+ readonly warnings?: TemplatePublishIssue[];
18
23
  constructor(status: number, message: string, body?: string, code?: string);
19
24
  }
20
25
  export declare class AgentForgeAuthError extends AgentForgeError {
package/dist/errors.js CHANGED
@@ -1,6 +1,4 @@
1
1
  "use strict";
2
- // Errores tipados que el SDK lanza. Las apps cliente pueden hacer
3
- // `instanceof AgentForgeAuthError` para distinguir 401/403 de otros fallos.
4
2
  Object.defineProperty(exports, "__esModule", { value: true });
5
3
  exports.AgentForgeNetworkError = exports.AgentForgeBillingError = exports.AGENTFORGE_BILLING_ERROR_CODES = exports.AgentForgeDuplicateContactError = exports.AgentForgeNotFoundError = exports.AgentForgeAuthError = exports.AgentForgeError = void 0;
6
4
  class AgentForgeError extends Error {
@@ -14,6 +12,8 @@ class AgentForgeError extends Error {
14
12
  this.code = code ?? parseErrorCode(body) ?? extra.reason;
15
13
  this.reason = extra.reason;
16
14
  this.issues = extra.issues;
15
+ this.errors = extra.errors;
16
+ this.warnings = extra.warnings;
17
17
  }
18
18
  }
19
19
  exports.AgentForgeError = AgentForgeError;
@@ -26,7 +26,8 @@ function parseReasonAndIssues(body) {
26
26
  const inner = parsed.message && typeof parsed.message === 'object' ? parsed.message : undefined;
27
27
  const reason = typeof parsed.reason === 'string' ? parsed.reason : typeof inner?.reason === 'string' ? inner.reason : undefined;
28
28
  const issues = Array.isArray(parsed.issues) ? parsed.issues : Array.isArray(inner?.issues) ? inner.issues : undefined;
29
- return { reason, issues };
29
+ const pick = (k) => (Array.isArray(parsed[k]) ? parsed[k] : Array.isArray(inner?.[k]) ? inner?.[k] : undefined);
30
+ return { reason, issues, errors: pick('errors'), warnings: pick('warnings') };
30
31
  }
31
32
  catch {
32
33
  return {};
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export { BillingResource } from './resources/billing';
6
6
  export type { BillingEntitlement, BillingEntitlementStatus, BillingInterval, BillingLimits, BillingPlan, BillingInvoice, BillingPaymentMethod, BillingCheckoutInput, BillingStartTrialInput, AppBillingWebhookEvent, AppBillingWebhookEventName, AppBillingWebhookData, } from './resources/billing';
7
7
  export { APP_WEBHOOK_HEADERS, TOOL_CALLBACK_HEADERS, ToolCallbackSignatureError, signToolCallbackPayload, verifyAppWebhook, verifyToolCallbackSignature, } from './webhooks';
8
8
  export { WebhookResource, type SetAppWebhookInput } from './resources/webhook';
9
- export type { AppWebhook, AppWebhookEvent, AppWebhookEventName, AppCaseWebhookEvent, AppCaseWebhookEventName, AppConversationMessageWebhookEvent, AppChannelStatusWebhookEvent, 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, ProfileBlockPlacement, ProfileBlockPosition, CatalogBlockPreview, ServiceCta, ServiceCtaAction, CatalogServicesBlockConfig, AppInstallation, TemplateConfigField, TemplateSummary, TemplateDetail, TemplateInstallStats, TemplatePublisher, TemplateAuthor, AppTemplatePolicy, TemplateCategoryRef, MarketplaceCategory, MarketplaceCategoryGroup, MarketplaceLocale, TemplateInstallResult, UpsertSystemTemplateInput, UpsertSystemTemplateResult, TemplateReview, TemplateRatingSummary, TemplateReviewsPage, BusinessReview, BusinessReviewsPage, ProductRatingSummary, ProductReview, ProductReviewOwner, ProductReviewsPage, ProductReviewsOwnerPage, ListProductReviewsInput, ListProductReviewsForOwnerInput, HideProductReviewInput, ProductLikeResult, ReceiptReviewable, ReceiptReviewables, SaveReceiptReviewInput, ListTemplateReviewsInput, SaveTemplateReviewInput, TemplateReportKind, CreateTemplateReportInput, TenantConfigEntry, Place, PlaceSuggestion, SearchPlacesInput, AutocompletePlacesInput, PlacesScope, CaseField, CaseBusinessState, CaseType, CaseState, CaseStateType, CasePayment, CasePaymentAccount, CasePaymentStatus, CaseReceiptPayment, CaseDestination, CaseView, CaseStateStep, CreateDirectOrderInput, CreateOpenOrderInput, OpenOrderLine, CreateDirectBookingInput, MoveCaseSlotInput, CaseSlot, CatalogAttendedAt, CatalogBookingRule, CaseOrigin, CaseOriginChannel, DirectOrderForm, DirectPaymentOption, CaseClosingMethod, CaseClosingOrder, CaseClosingReport, CaseReportPage, CaseReceipt, CaseReceiptLine, CaseProposal, CaseProposalAnswer, CaseProposalChange, CaseProposalInput, ListCasesInput, AddressValue, DeliveryLocalPricing, DeliverySettings, PaymentMethodKind, PaymentSettings, PaymentSettingsInput, PaymentAccount, PaymentCountry, PaymentFieldDef, PaymentFieldDue, PaymentRequirements, PaymentMethodDef, StructuredConfigInput, StructuredConfigEntry, DeliveryQuoteStatus, DeliveryQuoteInput, DeliveryPricePreview, DeliveryPricingPreview, DeliveryPricingPreviewInput, DeliveryRoute, DeliveryRouteInput, DeliveryQuote, AppSelf, AppOwner, 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, AttachCatalogCategoryImageInput, CatalogImportItem, CatalogImportPreview, CatalogImportApplyResult, CatalogFileMapping, CatalogFilePlan, CatalogFilePreview, CatalogFileApplyResult, CatalogFileInput, CatalogFilePreviewInput, CatalogMenuItem, CatalogMenuRead, CatalogMenuReadInput, CatalogMenuAttachInput, CatalogMenuChatFile, CatalogMenuKeepInSyncInput, CatalogMenuKeepInSyncResult, CatalogOption, CatalogOptionGroup, SaveCatalogOptionGroupInput, CatalogOptionChoice, CatalogOptionChange, CatalogOptionChangesPlan, CatalogUnit, SaveCatalogUnitInput, CatalogSaleRule, 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';
9
+ export type { AppWebhook, AppWebhookEvent, AppWebhookEventName, AppCaseWebhookEvent, AppCaseWebhookEventName, AppConversationMessageWebhookEvent, AppChannelStatusWebhookEvent, 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, ProfileBlockPlacement, ProfileBlockPosition, CatalogBlockPreview, ServiceCta, ServiceCtaAction, CatalogServicesBlockConfig, AppInstallation, TemplateConfigField, TemplateSummary, TemplateDetail, TemplateInstallStats, TemplatePublisher, TemplateAuthor, AppTemplatePolicy, TemplateCategoryRef, MarketplaceCategory, MarketplaceCategoryGroup, MarketplaceLocale, TemplateInstallResult, CheckSystemTemplateResult, TemplatePublishIssue, UpsertSystemTemplateInput, UpsertSystemTemplateResult, TemplateReview, TemplateRatingSummary, TemplateReviewsPage, BusinessReview, BusinessReviewsPage, ProductRatingSummary, ProductReview, ProductReviewOwner, ProductReviewsPage, ProductReviewsOwnerPage, ListProductReviewsInput, ListProductReviewsForOwnerInput, HideProductReviewInput, ProductLikeResult, ReceiptReviewable, ReceiptReviewables, SaveReceiptReviewInput, ListTemplateReviewsInput, SaveTemplateReviewInput, TemplateReportKind, CreateTemplateReportInput, TenantConfigEntry, Place, PlaceSuggestion, SearchPlacesInput, AutocompletePlacesInput, PlacesScope, CaseField, CaseBusinessState, CaseType, CaseState, CaseStateType, CasePayment, CasePaymentAccount, CasePaymentStatus, CaseReceiptPayment, CaseDestination, CaseView, CaseStateStep, CreateDirectOrderInput, CreateOpenOrderInput, OpenOrderFreeLine, OpenOrderLineMark, OpenOrderPayment, CreateDirectBookingInput, MoveCaseSlotInput, CaseSlot, CatalogAttendedAt, CatalogBookingRule, CaseOrigin, CaseOriginChannel, DirectOrderForm, DirectPaymentOption, CaseClosingMethod, CaseClosingOrder, CaseClosingReport, CaseReportPage, CaseReceipt, CaseReceiptLine, CaseProposal, CaseProposalAnswer, CaseProposalChange, CaseProposalInput, ListCasesInput, AddressValue, DeliveryLocalPricing, DeliverySettings, PaymentMethodKind, PaymentSettings, PaymentSettingsInput, PaymentAccount, PaymentCountry, PaymentFieldDef, PaymentMethodDef, StructuredConfigInput, StructuredConfigEntry, DeliveryQuoteStatus, DeliveryQuoteInput, DeliveryPricePreview, DeliveryPricingPreview, DeliveryPricingPreviewInput, DeliveryRoute, DeliveryRouteInput, DeliveryQuote, AppSelf, AppOwner, 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, AttachCatalogCategoryImageInput, CatalogImportItem, CatalogImportPreview, CatalogImportApplyResult, CatalogFileMapping, CatalogFilePlan, CatalogFilePreview, CatalogFileApplyResult, CatalogFileInput, CatalogFilePreviewInput, CatalogMenuItem, CatalogMenuRead, CatalogMenuReadInput, CatalogMenuAttachInput, CatalogMenuChatFile, CatalogMenuKeepInSyncInput, CatalogMenuKeepInSyncResult, CatalogOption, CatalogOptionGroup, SaveCatalogOptionGroupInput, CatalogOptionChoice, CatalogOptionChange, CatalogOptionChangesPlan, CatalogUnit, SaveCatalogUnitInput, CatalogSaleRule, 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';
10
10
  export { AgentsResource } from './resources/agents';
11
11
  export { AnalyticsResource } from './resources/analytics';
12
12
  export type { GetSupportKpisInput, GetAgentAttentionLogInput, } from './resources/analytics';
@@ -135,10 +135,6 @@ export declare class CasesResource {
135
135
  * assistant cannot answer). Created already sent: units held, receipt issued,
136
136
  * `case.submitted` fired — the business sees it in its requests like any other.
137
137
  * 400 for a bad order or missing fields, 409 when a product lacks stock.
138
- *
139
- * PDK-ORDER-INVITE — with `CreateOpenOrderInput` (`origin: { channel: 'link', place: 'open-order' }` +
140
- * `freeLines` + `totalCents` + `state: 'confirmed'`) it creates an open order instead: free-text lines,
141
- * the typed total, born `confirmed`, no stock holds.
142
138
  */
143
139
  createDirect(input: CreateDirectOrderInput | CreateOpenOrderInput): Promise<CaseView>;
144
140
  /**
@@ -194,10 +194,6 @@ class CasesResource {
194
194
  * assistant cannot answer). Created already sent: units held, receipt issued,
195
195
  * `case.submitted` fired — the business sees it in its requests like any other.
196
196
  * 400 for a bad order or missing fields, 409 when a product lacks stock.
197
- *
198
- * PDK-ORDER-INVITE — with `CreateOpenOrderInput` (`origin: { channel: 'link', place: 'open-order' }` +
199
- * `freeLines` + `totalCents` + `state: 'confirmed'`) it creates an open order instead: free-text lines,
200
- * the typed total, born `confirmed`, no stock holds.
201
197
  */
202
198
  async createDirect(input) {
203
199
  return this.client.request('POST', '/api/v1/cases/direct', input);
@@ -1,5 +1,5 @@
1
1
  import type { AgentForgeClient } from '../client';
2
- import type { CreateTemplateReportInput, UpsertSystemTemplateInput, UpsertSystemTemplateResult, ListTemplateReviewsInput, SaveTemplateReviewInput, TemplateDetail, TemplateInstallResult, TemplateReview, TemplateReviewsPage, TemplateSummary } from '../types';
2
+ import type { CheckSystemTemplateResult, CreateTemplateReportInput, UpsertSystemTemplateInput, UpsertSystemTemplateResult, ListTemplateReviewsInput, SaveTemplateReviewInput, TemplateDetail, TemplateInstallResult, TemplateReview, TemplateReviewsPage, TemplateSummary } from '../types';
3
3
  export interface ListTemplatesInput {
4
4
  kind?: 'agent' | 'team';
5
5
  /** Every tag must match (AND), e.g. ['type:food']. */
@@ -55,6 +55,14 @@ export declare class TemplatesResource {
55
55
  * });
56
56
  */
57
57
  upsertSystem(slug: string, input: UpsertSystemTemplateInput): Promise<UpsertSystemTemplateResult>;
58
+ /**
59
+ * PDK-PILLARS — `POST /api/v1/templates/system/:slug/check[?strict=true]`: runs the publish
60
+ * gate on a definition without writing anything. `strict` promotes warnings to errors.
61
+ * Same body and auth as `upsertSystem`.
62
+ */
63
+ checkSystem(slug: string, input: UpsertSystemTemplateInput, opts?: {
64
+ strict?: boolean;
65
+ }): Promise<CheckSystemTemplateResult>;
58
66
  /** `GET /api/v1/templates/:id` — summary + payload. 404 → `AgentForgeNotFoundError`. An unlisted template is readable by id only from its own tenant / App. */
59
67
  get(templateId: string): Promise<TemplateDetail>;
60
68
  /** `POST /api/v1/templates/:id/install` — clone into the caller's tenant. */
@@ -74,6 +74,14 @@ class TemplatesResource {
74
74
  async upsertSystem(slug, input) {
75
75
  return this.client.request('PUT', `/api/v1/templates/system/${encodeURIComponent(slug)}`, input);
76
76
  }
77
+ /**
78
+ * PDK-PILLARS — `POST /api/v1/templates/system/:slug/check[?strict=true]`: runs the publish
79
+ * gate on a definition without writing anything. `strict` promotes warnings to errors.
80
+ * Same body and auth as `upsertSystem`.
81
+ */
82
+ async checkSystem(slug, input, opts = {}) {
83
+ return this.client.request('POST', `/api/v1/templates/system/${encodeURIComponent(slug)}/check${opts.strict ? '?strict=true' : ''}`, input);
84
+ }
77
85
  /** `GET /api/v1/templates/:id` — summary + payload. 404 → `AgentForgeNotFoundError`. An unlisted template is readable by id only from its own tenant / App. */
78
86
  async get(templateId) {
79
87
  return this.client.request('GET', `/api/v1/templates/${encodeURIComponent(templateId)}`);
package/dist/types.d.ts CHANGED
@@ -1037,6 +1037,12 @@ export interface TemplateSummary {
1037
1037
  createdAt: string;
1038
1038
  updatedAt: string;
1039
1039
  [field: string]: unknown;
1040
+ /**
1041
+ * PDK-TEMPLATE-PROFILE. The opaque JSON object the CALLING App stored on this template
1042
+ * (`templates.appProfile` in the console), as of the published version. `null` when none,
1043
+ * or when the key is not an App's (`sk_live_`). Other Apps' blobs are never returned.
1044
+ */
1045
+ appProfile?: Record<string, unknown> | null;
1040
1046
  }
1041
1047
  /**
1042
1048
  * AGF-PDK-SUPERADMIN — `templates.upsertSystem` input: the definition of a
@@ -1064,6 +1070,34 @@ export interface UpsertSystemTemplateInput {
1064
1070
  configSchema?: TemplateConfigField[];
1065
1071
  /** Force "sells from the catalog" on; omitted = derived from the payload. */
1066
1072
  usesCatalog?: boolean;
1073
+ /** PDK-PILLARS. Default `false` (unlisted). `true` lists the template in the marketplace
1074
+ * once it passes the publish gate (see `templates.checkSystem`). */
1075
+ listed?: boolean;
1076
+ /** PDK-PILLARS. Only `'tenant'`; `'public'` is rejected with 400. */
1077
+ visibility?: 'tenant';
1078
+ /** PDK-PILLARS. https URL on an allowed host. Omitted = unchanged, `null` = clear. */
1079
+ logoUrl?: string | null;
1080
+ /** PDK-PILLARS. Same rules as `logoUrl`. */
1081
+ coverUrl?: string | null;
1082
+ /** PDK-PILLARS. Omitted = unchanged, `null` = clear. */
1083
+ locale?: 'es' | 'en' | null;
1084
+ /** PDK-PILLARS. Template guide in Markdown. Omitted = unchanged, `null` = clear. */
1085
+ guideMd?: string | null;
1086
+ /** PDK-PILLARS. 1-3 category slugs; the first is the primary one. */
1087
+ categories?: string[];
1088
+ }
1089
+ /** PDK-PILLARS. One finding of the publish gate. */
1090
+ export interface TemplatePublishIssue {
1091
+ source: 'completeness' | 'hilo' | 'listing';
1092
+ code: string;
1093
+ reason: string;
1094
+ ref?: string;
1095
+ }
1096
+ /** PDK-PILLARS. `templates.checkSystem` result (nothing is written). */
1097
+ export interface CheckSystemTemplateResult {
1098
+ ok: boolean;
1099
+ errors: TemplatePublishIssue[];
1100
+ warnings: TemplatePublishIssue[];
1067
1101
  }
1068
1102
  /** `created`: new template (v1). `updated`: a new version was published, or
1069
1103
  * display fields changed (compare `template.currentVersion`). `unchanged`:
@@ -1071,6 +1105,8 @@ export interface UpsertSystemTemplateInput {
1071
1105
  export interface UpsertSystemTemplateResult {
1072
1106
  action: 'created' | 'updated' | 'unchanged';
1073
1107
  template: TemplateDetail;
1108
+ /** PDK-PILLARS. Non-blocking findings of the publish gate. */
1109
+ warnings: TemplatePublishIssue[];
1074
1110
  }
1075
1111
  /** `GET /api/v1/templates/:id` — summary + the snapshot it installs. */
1076
1112
  export interface TemplateDetail extends TemplateSummary {
@@ -2102,21 +2138,12 @@ export interface DeliverySettings {
2102
2138
  export type PaymentMethodKind = 'cash' | 'bank_transfer' | 'card_on_delivery' | 'payment_link' | 'card_in_store' | 'other';
2103
2139
  /** AGF-PAYMENT-ACCOUNTS — countries with a payment catalog. */
2104
2140
  export type PaymentCountry = 'CO';
2105
- /**
2106
- * PDK-ORDER-PARTICIPANTS D8 — when a field is due (progressive requirements). `save`: the account cannot be
2107
- * saved without it; `offer`: saved, but not offered to customers until present; `eventually`: saved and offered,
2108
- * shown to the business as a pending item. Absent: optional.
2109
- */
2110
- export type PaymentFieldDue = 'save' | 'offer' | 'eventually';
2111
2141
  /** A field an account of a method asks for. */
2112
2142
  export interface PaymentFieldDef {
2113
2143
  key: string;
2114
2144
  label: string;
2115
2145
  kind: 'text' | 'phone' | 'digits' | 'select' | 'bank';
2116
- /** Derived from `due` (`due === 'save'`), kept for older clients. */
2117
2146
  required: boolean;
2118
- /** When the field is due. Absent on an older platform: read `required`. */
2119
- due?: PaymentFieldDue;
2120
2147
  /** `select` / `bank`: the options. */
2121
2148
  options?: Array<{
2122
2149
  value: string;
@@ -2152,13 +2179,6 @@ export interface PaymentAccount {
2152
2179
  when: 'before' | 'on_delivery';
2153
2180
  /** Paused without deleting. */
2154
2181
  active: boolean;
2155
- /** PDK-ORDER-PARTICIPANTS D8 — what the account still lacks (field keys); read-only, set by the platform on read. */
2156
- requirements?: PaymentRequirements;
2157
- }
2158
- /** Field keys an account still lacks. `currentlyDue` non-empty: the account is not offered to customers. */
2159
- export interface PaymentRequirements {
2160
- currentlyDue: string[];
2161
- eventuallyDue: string[];
2162
2182
  }
2163
2183
  export interface PaymentSettings {
2164
2184
  locale?: 'es' | 'en';
@@ -2461,12 +2481,6 @@ export interface CasePaymentAccount {
2461
2481
  when: 'before' | 'on_delivery';
2462
2482
  /** "Nequi (Principal): 3001234567 a nombre de Ana Pérez". */
2463
2483
  line: string;
2464
- /**
2465
- * PDK-ORDER-PARTICIPANTS-S3b — `line` with the holder unmasked. Business reads only (cases API, never the
2466
- * public receipt); present only when it differs from `line` (wallets / Bre-B with a titular). Prefer
2467
- * `ownerLine ?? line` in the business's views.
2468
- */
2469
- ownerLine?: string;
2470
2484
  /** What to copy to pay (empty for cash / card terminal). */
2471
2485
  copy: Array<{
2472
2486
  label: string;
@@ -2573,8 +2587,7 @@ export interface CaseReceiptLine {
2573
2587
  coverUrl?: string;
2574
2588
  /** AGF-PRODUCT-SKU — the product's inventory code as it is now (absent: none, or an older platform). */
2575
2589
  sku?: string;
2576
- /** PDK-ORDER-INVITE — open-order lines (free text: no `productId`, `unitCents` null, `priceKind` `on_request`).
2577
- * `out`: not delivered («Agotado»), show it struck; `swapText`: delivered as this instead; `note`: the customer's note. */
2590
+ /** PDK-ORDER-INVITE — open-order lines: `out` = not delivered (never counted), `swapText` = delivered as this instead, `note` = the customer's note. */
2578
2591
  out?: true;
2579
2592
  swapText?: string;
2580
2593
  note?: string;
@@ -2676,7 +2689,7 @@ export interface CaseReceipt {
2676
2689
  distanceKm?: number;
2677
2690
  };
2678
2691
  totalCents: number | null;
2679
- /** PDK-ORDER-INVITE — `totalCents` is the amount typed at dispatch (an open order), not Σ of the lines; final, delivery included. */
2692
+ /** PDK-ORDER-INVITE — an open order's `totalCents` was typed by the business (some line had no price): it is final, delivery included. Absent when the total is the sum of fixed prices (PDK-ORDER-PRICES). */
2680
2693
  totalManual?: true;
2681
2694
  currency: string | null;
2682
2695
  fields: Array<{
@@ -2799,27 +2812,52 @@ export interface CreateDirectOrderInput {
2799
2812
  */
2800
2813
  reopens?: string;
2801
2814
  }
2802
- /** PDK-ORDER-INVITE — one free-text line of an open order (no catalog product, no unit price). */
2803
- export interface OpenOrderLine {
2815
+ /** PDK-ORDER-PRICES — how a shopkeeper marked a line of an open order. */
2816
+ export type OpenOrderLineMark = 'ready' | 'out' | 'swap';
2817
+ /** PDK-ORDER-INVITE / PDK-ORDER-PRICES — one free-text line of an open order. */
2818
+ export interface OpenOrderFreeLine {
2804
2819
  title: string;
2820
+ /** > 0, at most 3 decimals, <= 100000. */
2805
2821
  qty: number;
2822
+ /** What `qty` and `unitPriceCents` are in («kg», «libra»). <= 20 chars. */
2806
2823
  unit?: string;
2824
+ /** Price of ONE `unit`, whole cents, 0..1e9. Ignored on an `out` line. */
2825
+ unitPriceCents?: number;
2807
2826
  note?: string;
2808
- /** What dispatch decided: `ready` (delivered), `out` («Agotado»: not delivered), `swap` (delivered as `swapText`). */
2809
- mark: 'ready' | 'out' | 'swap';
2827
+ mark: OpenOrderLineMark;
2810
2828
  /** Required with `mark: 'swap'`, refused otherwise. */
2811
2829
  swapText?: string;
2812
2830
  }
2831
+ /** PDK-ORDER-INVITE — how the customer pays an open order (no business account yet). */
2832
+ export interface OpenOrderPayment {
2833
+ /** A platform payment method key («efectivo», «nequi», «daviplata»…). */
2834
+ method: string;
2835
+ /** What the customer copies to pay (the shopkeeper's Nequi number). */
2836
+ payTo?: string;
2837
+ label?: string;
2838
+ /**
2839
+ * PDK-ORDER-PRICES — the bill the customer says they pay with: whole cents, 1..1e9, ONLY with
2840
+ * `method: 'efectivo'` (else 400). Below the total is accepted (the customer chose it before prices
2841
+ * existed): the case then stores `cashTenderedCents` with `changeCents: 0` — «faltan» is `totalCents - cashTenderedCents`.
2842
+ */
2843
+ cashTenderedCents?: number;
2844
+ }
2813
2845
  /**
2814
- * PDK-ORDER-INVITE — an OPEN ORDER: a free-form order a shopkeeper already dispatched (no catalog, no
2815
- * unit prices), created in a business's tenant once it exists. Same endpoint as `CreateDirectOrderInput`;
2816
- * the explicit opt-in is `origin = { channel: 'link', place: 'open-order' }` together with `freeLines`
2817
- * (either one alone → 400). The case is born `confirmed` (dispatch made it final): no holds, no proposals,
2818
- * no redo. The receipt shows `totalCents` exactly (`totalManual`), `out` lines struck, swaps as dispatched.
2819
- * Name/phone are optional; `customerContact` is another name for `customer` (`customer.ref` defaults to a
2820
- * key-derived value). `payment` here is a method snapshot, not a catalog account.
2846
+ * PDK-ORDER-INVITE — an open order: a shopkeeper's free-form dispatch (no catalog), created already
2847
+ * `confirmed`, no holds. `cases.createDirect` accepts it with `origin: { channel: 'link', place: 'open-order' }`.
2848
+ *
2849
+ * Total rule (PDK-ORDER-PRICES): when EVERY non-`out` line has `unitPriceCents`, `totalCents` MUST equal
2850
+ * Σ round(qty × unitPriceCents) + (deliveryFeeCents ?? 0), else 400 `{ error: 'total_mismatch', expected }`;
2851
+ * the receipt then has fixed-price lines, a `delivery` row and no `totalManual`. When some non-`out` line has no
2852
+ * price, `totalCents` is the final typed amount (unchecked), lines stay `on_request`, `deliveryFeeCents` is ignored
2853
+ * and the receipt is `totalManual: true`.
2821
2854
  */
2822
2855
  export interface CreateOpenOrderInput {
2856
+ customer: {
2857
+ ref?: string;
2858
+ name?: string;
2859
+ phone?: string;
2860
+ };
2823
2861
  origin: {
2824
2862
  channel: 'link';
2825
2863
  place: 'open-order' | {
@@ -2827,38 +2865,19 @@ export interface CreateOpenOrderInput {
2827
2865
  label: string;
2828
2866
  };
2829
2867
  };
2830
- freeLines: OpenOrderLine[];
2831
- /** The total the business typed at dispatch, in cents (> 0). The receipt and the case read exactly this. */
2868
+ freeLines: OpenOrderFreeLine[];
2869
+ /** Whole cents, 1..1e9. */
2832
2870
  totalCents: number;
2833
- /** ISO code, default `COP`. */
2871
+ /** PDK-ORDER-PRICES — the delivery fee on top of the lines, whole cents 0..1e8 (used when every sold line is priced). */
2872
+ deliveryFeeCents?: number;
2834
2873
  currency?: string;
2835
2874
  state: 'confirmed';
2836
- /** How the customer said they pay (a method of the platform's country catalog: `nequi`, `daviplata`, `efectivo`…) and where to. */
2837
- payment?: {
2838
- method: string;
2839
- payTo?: string;
2840
- label?: string;
2841
- };
2842
- customer?: {
2843
- ref?: string;
2844
- name?: string;
2845
- phone?: string;
2846
- };
2847
- customerContact?: {
2848
- name?: string;
2849
- phone?: string;
2850
- };
2851
- /** Delivery address (domicilio). Absent: pickup. The quote, if any, is NOT added to `totalCents`. */
2875
+ payment?: OpenOrderPayment;
2852
2876
  destination?: CaseDestination;
2853
- /** The order type's other fields (entrega, notas…), by key. `entrega` defaults from `destination`. */
2854
2877
  fields?: Record<string, unknown>;
2855
2878
  type?: string;
2856
2879
  conversationId?: string;
2857
- /** Same key → same order. 8–80 of [A-Za-z0-9_.:-]. */
2858
2880
  idempotencyKey: string;
2859
- lines?: never;
2860
- reopens?: never;
2861
- place?: never;
2862
2881
  }
2863
2882
  /** A payment method a checkout offers (no account data — that is on the receipt once the order is sent). */
2864
2883
  export interface DirectPaymentOption {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentforge-io/sdk-server",
3
- "version": "4.71.0",
3
+ "version": "4.72.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",