@agentforge-io/sdk-server 4.61.0 → 4.63.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
@@ -5,6 +5,16 @@ export declare class AgentForgeError extends Error {
5
5
  * legacy `{ error }`), when the platform sent one — e.g. `FILE_EMPTY_FILE`,
6
6
  * `INVALID_MAPPING`, `CATALOG_NOT_FOUND`. Also set on 404/401/403 errors. */
7
7
  readonly code?: string;
8
+ /** PDK-CONSOLE. Machine-readable `reason` of the response body, for the
9
+ * routes that answer `{ reason, message }` instead of `{ code }`: e.g.
10
+ * `publisher_app_not_found`, `publisher_app_not_live`,
11
+ * `publisher_policy_violation`, `invalid_publisher_app_id`,
12
+ * `invalid_template_policy`. (`invalid_publisher` / `publisher_needs_app`
13
+ * arrive as `code`.) */
14
+ readonly reason?: string;
15
+ /** PDK-CONSOLE. `issues` of the response body (publication-issue shape) when
16
+ * present, e.g. on `publisher_policy_violation`. */
17
+ readonly issues?: unknown[];
8
18
  constructor(status: number, message: string, body?: string, code?: string);
9
19
  }
10
20
  export declare class AgentForgeAuthError extends AgentForgeError {
package/dist/errors.js CHANGED
@@ -9,10 +9,29 @@ class AgentForgeError extends Error {
9
9
  this.name = 'AgentForgeError';
10
10
  this.status = status;
11
11
  this.body = body;
12
- this.code = code ?? parseErrorCode(body);
12
+ const extra = parseReasonAndIssues(body);
13
+ // `code` falls back to `reason` for routes that only send `{ reason, message }`.
14
+ this.code = code ?? parseErrorCode(body) ?? extra.reason;
15
+ this.reason = extra.reason;
16
+ this.issues = extra.issues;
13
17
  }
14
18
  }
15
19
  exports.AgentForgeError = AgentForgeError;
20
+ function parseReasonAndIssues(body) {
21
+ if (!body)
22
+ return {};
23
+ try {
24
+ const parsed = JSON.parse(body);
25
+ // Nest may wrap an object payload one level down in `message`.
26
+ const inner = parsed.message && typeof parsed.message === 'object' ? parsed.message : undefined;
27
+ const reason = typeof parsed.reason === 'string' ? parsed.reason : typeof inner?.reason === 'string' ? inner.reason : undefined;
28
+ const issues = Array.isArray(parsed.issues) ? parsed.issues : Array.isArray(inner?.issues) ? inner.issues : undefined;
29
+ return { reason, issues };
30
+ }
31
+ catch {
32
+ return {};
33
+ }
34
+ }
16
35
  // `CASE_NOT_FOUND`-style codes, and the lowercase snake_case codes of the
17
36
  // contacts / verification routes (`rate_limited`, `invalid_code`). Nest's
18
37
  // status text ("Bad Request") matches neither.
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, 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, AppInstallation, TemplateConfigField, TemplateSummary, TemplateDetail, TemplateCategoryRef, MarketplaceCategory, MarketplaceCategoryGroup, MarketplaceLocale, TemplateInstallResult, UpsertSystemTemplateInput, UpsertSystemTemplateResult, TemplateReview, TemplateRatingSummary, TemplateReviewsPage, BusinessReview, BusinessReviewsPage, ListTemplateReviewsInput, SaveTemplateReviewInput, TemplateReportKind, CreateTemplateReportInput, TenantConfigEntry, Place, PlaceSuggestion, SearchPlacesInput, AutocompletePlacesInput, PlacesScope, CaseField, CaseBusinessState, CaseType, CaseState, CaseStateType, CasePayment, CasePaymentAccount, CasePaymentStatus, CaseReceiptPayment, CaseDestination, CaseView, CaseStateStep, CreateDirectOrderInput, 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, 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, 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';
6
+ 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, AppInstallation, TemplateConfigField, TemplateSummary, TemplateDetail, TemplateInstallStats, TemplatePublisher, TemplateAuthor, AppTemplatePolicy, TemplateCategoryRef, MarketplaceCategory, MarketplaceCategoryGroup, MarketplaceLocale, TemplateInstallResult, UpsertSystemTemplateInput, UpsertSystemTemplateResult, TemplateReview, TemplateRatingSummary, TemplateReviewsPage, BusinessReview, BusinessReviewsPage, ListTemplateReviewsInput, SaveTemplateReviewInput, TemplateReportKind, CreateTemplateReportInput, TenantConfigEntry, Place, PlaceSuggestion, SearchPlacesInput, AutocompletePlacesInput, PlacesScope, CaseField, CaseBusinessState, CaseType, CaseState, CaseStateType, CasePayment, CasePaymentAccount, CasePaymentStatus, CaseReceiptPayment, CaseDestination, CaseView, CaseStateStep, CreateDirectOrderInput, 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, 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, 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';
7
7
  export { AgentsResource } from './resources/agents';
8
8
  export { AnalyticsResource } from './resources/analytics';
9
9
  export type { GetSupportKpisInput, GetAgentAttentionLogInput, } from './resources/analytics';
@@ -34,6 +34,20 @@ export declare class CasesResource {
34
34
  * then says it was weighed.
35
35
  */
36
36
  weighLine(caseId: string, line: string, weight: number): Promise<CaseView>;
37
+ /**
38
+ * `POST /api/v1/cases/:id/lines/takeaway` — PDK-BUG-006: while dispatching, the team marks ONE
39
+ * line of a sent order «para llevar» (`takeaway: true`) or back to eaten here (`false`);
40
+ * `key` is the receipt line's `key`. Internal packing info: it is not a proposal, the customer
41
+ * is not told, the receipt keeps its revision and the price does not change. The same value
42
+ * is a no-op. The line takes another `key` (read the receipt again); a line of the same
43
+ * product and choice already in the other state absorbs it (one line, quantities added).
44
+ * Returns the updated case (`receipt.allTakeaway` follows). 400 closed or still-edited order,
45
+ * 404 unknown line, 409 a proposal is waiting (withdraw it first).
46
+ */
47
+ setLineTakeaway(caseId: string, input: {
48
+ key: string;
49
+ takeaway: boolean;
50
+ }): Promise<CaseView>;
37
51
  /**
38
52
  * `POST /api/v1/cases/:id/proposal` — AGF-PDK-DISPATCH-PROPOSAL: the business proposes
39
53
  * changes while picking (a line out of stock, another product in its place; lines by
@@ -69,6 +69,19 @@ class CasesResource {
69
69
  async weighLine(caseId, line, weight) {
70
70
  return this.client.request('POST', `/api/v1/cases/${encodeURIComponent(caseId)}/weigh`, { line, weight });
71
71
  }
72
+ /**
73
+ * `POST /api/v1/cases/:id/lines/takeaway` — PDK-BUG-006: while dispatching, the team marks ONE
74
+ * line of a sent order «para llevar» (`takeaway: true`) or back to eaten here (`false`);
75
+ * `key` is the receipt line's `key`. Internal packing info: it is not a proposal, the customer
76
+ * is not told, the receipt keeps its revision and the price does not change. The same value
77
+ * is a no-op. The line takes another `key` (read the receipt again); a line of the same
78
+ * product and choice already in the other state absorbs it (one line, quantities added).
79
+ * Returns the updated case (`receipt.allTakeaway` follows). 400 closed or still-edited order,
80
+ * 404 unknown line, 409 a proposal is waiting (withdraw it first).
81
+ */
82
+ async setLineTakeaway(caseId, input) {
83
+ return this.client.request('POST', `/api/v1/cases/${encodeURIComponent(caseId)}/lines/takeaway`, { key: input.key, takeaway: input.takeaway });
84
+ }
72
85
  /**
73
86
  * `POST /api/v1/cases/:id/proposal` — AGF-PDK-DISPATCH-PROPOSAL: the business proposes
74
87
  * changes while picking (a line out of stock, another product in its place; lines by
@@ -17,6 +17,10 @@ export interface ListTemplatesInput {
17
17
  categories?: string[];
18
18
  /** Templates whose PRIMARY category is this slug. */
19
19
  primaryCategory?: string;
20
+ /** PDK-CONSOLE. `'me'`: only templates published under the calling App
21
+ * (sent as `publisher=me`). Needs a platform that supports the filter;
22
+ * older platforms ignore it. */
23
+ publisher?: 'me';
20
24
  /** 1–200. */
21
25
  limit?: number;
22
26
  }
@@ -42,6 +42,8 @@ class TemplatesResource {
42
42
  qs.set('categories', input.categories.join(','));
43
43
  if (input.primaryCategory)
44
44
  qs.set('primaryCategory', input.primaryCategory);
45
+ if (input.publisher)
46
+ qs.set('publisher', input.publisher);
45
47
  if (input.limit !== undefined)
46
48
  qs.set('limit', String(input.limit));
47
49
  const query = qs.toString();
package/dist/types.d.ts CHANGED
@@ -48,6 +48,17 @@ export interface PublicAppBranding {
48
48
  logoUrl: string | null;
49
49
  coverUrl: string | null;
50
50
  }
51
+ /** PDK-CONSOLE G2. Publication rules an App declares as data; applied when a
52
+ * template / team is published UNDER that App (server:
53
+ * identity/domain/app-template-policy.ts). `*` wildcards, case-insensitive.
54
+ * Editing it (PATCH /apps/:id) is session-only (workspace owner): not in this SDK. */
55
+ export interface AppTemplatePolicy {
56
+ requireUsesCatalog?: boolean;
57
+ forbiddenToolNamePatterns?: string[];
58
+ forbiddenConnectorIds?: string[];
59
+ forbiddenSecretKeyPatterns?: string[];
60
+ blockFixedValuesInPrompts?: boolean;
61
+ }
51
62
  export interface AppSelf {
52
63
  /**
53
64
  * AGF-PDK-SUPERADMIN — the user who owns the App's tenant: who created the
@@ -63,6 +74,8 @@ export interface AppSelf {
63
74
  logoUrl: string | null;
64
75
  coverUrl: string | null;
65
76
  content: string | null;
77
+ /** PDK-CONSOLE G2. Absent on platforms older than the field. */
78
+ templatePolicy?: AppTemplatePolicy | null;
66
79
  status: 'draft' | 'published';
67
80
  publicKey: string;
68
81
  apiSecretPrefix: string;
@@ -869,6 +882,18 @@ export interface TemplateConfigField {
869
882
  /** Resource picker for connector-backed fields (e.g. a Google Sheet). */
870
883
  picker?: Record<string, unknown>;
871
884
  }
885
+ /** PDK-CONSOLE. The App a template is published under. */
886
+ export interface TemplatePublisher {
887
+ appId: string;
888
+ name: string;
889
+ logoUrl: string | null;
890
+ }
891
+ /** PDK-CONSOLE. Who authored a template. */
892
+ export interface TemplateAuthor {
893
+ tenantId: string;
894
+ tenantName: string;
895
+ userDisplayName?: string;
896
+ }
872
897
  /** A template as the API-key catalog lists it (`GET /api/v1/templates`). */
873
898
  export interface TemplateSummary {
874
899
  id: string;
@@ -888,6 +913,15 @@ export interface TemplateSummary {
888
913
  categories: TemplateCategoryRef[];
889
914
  /** Who published it: the workspace name, or 'AgentForge' for system rows. */
890
915
  publisherName?: string;
916
+ /** PDK-CONSOLE. The App the template is published under (its brand), or
917
+ * null when none. Absent on platforms older than the field. */
918
+ publisher?: TemplatePublisher | null;
919
+ /** PDK-CONSOLE. The workspace (and person) that authored it. Absent on
920
+ * platforms older than the field. */
921
+ author?: TemplateAuthor | null;
922
+ /** PDK-CONSOLE. Raw id of the publisher App; null = published by the
923
+ * workspace. Absent on platforms older than the field. */
924
+ publisherAppId?: string | null;
891
925
  tags?: string[];
892
926
  visibility: 'system' | 'tenant' | 'public';
893
927
  /** AGF-PDK-SUPERADMIN. False = an unlisted template: in no list (not even
@@ -968,6 +1002,20 @@ export interface TemplateDetail extends TemplateSummary {
968
1002
  guideMd?: string;
969
1003
  /** ISO timestamp of the last guide change. */
970
1004
  guideUpdatedAt?: string;
1005
+ /** PDK-CONSOLE G4. Only for the template's own workspace and the App that
1006
+ * publishes it (others read `installsCount`). `total` is cumulative; `byVersion`
1007
+ * counts installs that exist now (`version: null` = installed before versions
1008
+ * were recorded). */
1009
+ installs?: TemplateInstallStats;
1010
+ }
1011
+ /** PDK-CONSOLE G4. See {@link TemplateDetail.installs}. */
1012
+ export interface TemplateInstallStats {
1013
+ total: number;
1014
+ active: number;
1015
+ byVersion: Array<{
1016
+ version: number | null;
1017
+ count: number;
1018
+ }>;
971
1019
  }
972
1020
  /** AGF-PDK-TEMPLATE-PAGE. A person's review of a template (one per person,
973
1021
  * editable). Never carries the reviewer's ids. */
@@ -2221,6 +2269,8 @@ export interface CaseView {
2221
2269
  token: string;
2222
2270
  issuedAt: string;
2223
2271
  revision: number;
2272
+ /** PDK-BUG-006 — every product line of the receipt is to go (`takeaway`). Absent/false on mixed or eat-here orders, older receipts and older platforms. */
2273
+ allTakeaway?: boolean;
2224
2274
  } | null;
2225
2275
  /** What the customer asked after the business took the case (change, cancel), until the business moves it. */
2226
2276
  customerRequest: {
@@ -2363,6 +2413,9 @@ export interface CaseReceiptLine {
2363
2413
  name: string;
2364
2414
  deltaCents: number;
2365
2415
  }>;
2416
+ /** PDK-BUG-006 — the line is to go (packed for takeaway). Present only when `true`; absent means
2417
+ * eaten here, and also on receipts issued before this flag or by an older platform. */
2418
+ takeaway?: true;
2366
2419
  /** AGF-PDK-DISPATCH-PROPOSAL — the line's identity (product + choice): what `cases.propose` names.
2367
2420
  * Absent on an older platform. */
2368
2421
  key?: string;
@@ -2558,6 +2611,9 @@ export interface CreateDirectOrderInput {
2558
2611
  /** AGF-UNITS U3 — sold by value («$3.000 de queso»): the amount in cents instead of a quantity; its own line. */
2559
2612
  amountCents?: number;
2560
2613
  options?: CatalogOptionChoice[];
2614
+ /** PDK-BUG-006 — this line is to go (packed for takeaway). Boolean only; `false`/absent = eaten here.
2615
+ * The same product + options with another `takeaway` is a separate line. No packaging charge. */
2616
+ takeaway?: boolean;
2561
2617
  }>;
2562
2618
  /** The order type's other fields (entrega, direccion, notas…), by key. */
2563
2619
  fields?: Record<string, unknown>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentforge-io/sdk-server",
3
- "version": "4.61.0",
3
+ "version": "4.63.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",