@agentforge-io/sdk-server 4.23.0 → 4.25.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/client.d.ts CHANGED
@@ -5,6 +5,7 @@ import { ChatResource } from './resources/chat';
5
5
  import { ConnectorsResource } from './resources/connectors';
6
6
  import { InboxResource } from './resources/inbox';
7
7
  import { InstallationsResource } from './resources/installations';
8
+ import { WebhookResource } from './resources/webhook';
8
9
  import { ProvisioningResource } from './resources/provisioning';
9
10
  import { SecretsResource } from './resources/secrets';
10
11
  import { TeamsResource } from './resources/teams';
@@ -90,6 +91,8 @@ export declare class AgentForgeClient {
90
91
  readonly connectors: ConnectorsResource;
91
92
  readonly inbox: InboxResource;
92
93
  readonly installations: InstallationsResource;
94
+ /** Where the platform sends this App its events (AGF-APP-WEBHOOKS). */
95
+ readonly webhook: WebhookResource;
93
96
  readonly provisioning: ProvisioningResource;
94
97
  readonly secrets: SecretsResource;
95
98
  readonly tools: ToolsResource;
package/dist/client.js CHANGED
@@ -27,6 +27,7 @@ const chat_1 = require("./resources/chat");
27
27
  const connectors_1 = require("./resources/connectors");
28
28
  const inbox_1 = require("./resources/inbox");
29
29
  const installations_1 = require("./resources/installations");
30
+ const webhook_1 = require("./resources/webhook");
30
31
  const provisioning_1 = require("./resources/provisioning");
31
32
  const secrets_1 = require("./resources/secrets");
32
33
  const teams_1 = require("./resources/teams");
@@ -72,6 +73,7 @@ class AgentForgeClient {
72
73
  this.connectors = new connectors_1.ConnectorsResource(this);
73
74
  this.inbox = new inbox_1.InboxResource(this);
74
75
  this.installations = new installations_1.InstallationsResource(this);
76
+ this.webhook = new webhook_1.WebhookResource(this);
75
77
  this.provisioning = new provisioning_1.ProvisioningResource(this);
76
78
  this.secrets = new secrets_1.SecretsResource(this);
77
79
  this.tools = new tools_1.ToolsResource(this);
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  export { AgentForgeClient, INSTALLED_TENANT_HEADER } from './client';
2
2
  export type { AgentForgeClientOptions, RequestOptions } from './client';
3
3
  export { AgentForgeError, AgentForgeAuthError, AgentForgeNotFoundError, AgentForgeNetworkError, } from './errors';
4
- export { TOOL_CALLBACK_HEADERS, ToolCallbackSignatureError, signToolCallbackPayload, verifyToolCallbackSignature, } from './webhooks';
5
- export type { 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, ListCasesInput, AddressValue, DeliveryLocalPricing, DeliverySettings, PaymentMethodKind, PaymentSettings, 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';
4
+ export { APP_WEBHOOK_HEADERS, TOOL_CALLBACK_HEADERS, ToolCallbackSignatureError, signToolCallbackPayload, verifyAppWebhook, verifyToolCallbackSignature, } from './webhooks';
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, ListCasesInput, AddressValue, DeliveryLocalPricing, DeliverySettings, PaymentMethodKind, PaymentSettings, 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
7
  export { AgentsResource } from './resources/agents';
7
8
  export { AnalyticsResource } from './resources/analytics';
8
9
  export type { GetSupportKpisInput, GetAgentAttentionLogInput, } from './resources/analytics';
package/dist/index.js CHANGED
@@ -28,7 +28,7 @@
28
28
  // const payload = af.tools.verifyCallback({ rawBody, signatureHeader, secretPlaintext });
29
29
  // await af.tools.respondToCallback({ resultUrl: payload.resultUrl, tenantId: payload.tenantId, secret, result });
30
30
  Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.ToolsResource = exports.TeamsResource = exports.SecretsResource = exports.ProvisioningResource = exports.CATALOG_IMPORT_MAX_ITEMS = exports.AgentForgeCatalogImportLimitError = exports.CatalogSourcesResource = exports.CatalogFileImportResource = exports.CatalogImportResource = exports.CatalogPhotosResource = exports.CatalogProductsResource = exports.CatalogCategoriesResource = exports.CatalogResource = exports.BusinessRolesResource = exports.CasesResource = exports.DeliveryResource = exports.PlacesResource = exports.TenantConfigResource = exports.MarketplaceResource = exports.TemplatesResource = exports.InstallationsResource = exports.InboxResource = exports.parseGoogleSheetsPickerResult = exports.ConnectorsResource = exports.ChatResource = exports.AppsResource = exports.AnalyticsResource = exports.AgentsResource = exports.verifyToolCallbackSignature = exports.signToolCallbackPayload = exports.ToolCallbackSignatureError = exports.TOOL_CALLBACK_HEADERS = exports.AgentForgeNetworkError = exports.AgentForgeNotFoundError = exports.AgentForgeAuthError = exports.AgentForgeError = exports.INSTALLED_TENANT_HEADER = exports.AgentForgeClient = void 0;
31
+ exports.ToolsResource = exports.TeamsResource = exports.SecretsResource = exports.ProvisioningResource = exports.CATALOG_IMPORT_MAX_ITEMS = exports.AgentForgeCatalogImportLimitError = exports.CatalogSourcesResource = exports.CatalogFileImportResource = exports.CatalogImportResource = exports.CatalogPhotosResource = exports.CatalogProductsResource = exports.CatalogCategoriesResource = exports.CatalogResource = exports.BusinessRolesResource = exports.CasesResource = exports.DeliveryResource = exports.PlacesResource = exports.TenantConfigResource = exports.MarketplaceResource = exports.TemplatesResource = exports.InstallationsResource = exports.InboxResource = exports.parseGoogleSheetsPickerResult = exports.ConnectorsResource = exports.ChatResource = exports.AppsResource = exports.AnalyticsResource = exports.AgentsResource = exports.WebhookResource = exports.verifyToolCallbackSignature = exports.verifyAppWebhook = exports.signToolCallbackPayload = exports.ToolCallbackSignatureError = exports.TOOL_CALLBACK_HEADERS = exports.APP_WEBHOOK_HEADERS = exports.AgentForgeNetworkError = exports.AgentForgeNotFoundError = exports.AgentForgeAuthError = exports.AgentForgeError = exports.INSTALLED_TENANT_HEADER = exports.AgentForgeClient = void 0;
32
32
  var client_1 = require("./client");
33
33
  Object.defineProperty(exports, "AgentForgeClient", { enumerable: true, get: function () { return client_1.AgentForgeClient; } });
34
34
  Object.defineProperty(exports, "INSTALLED_TENANT_HEADER", { enumerable: true, get: function () { return client_1.INSTALLED_TENANT_HEADER; } });
@@ -38,10 +38,14 @@ Object.defineProperty(exports, "AgentForgeAuthError", { enumerable: true, get: f
38
38
  Object.defineProperty(exports, "AgentForgeNotFoundError", { enumerable: true, get: function () { return errors_1.AgentForgeNotFoundError; } });
39
39
  Object.defineProperty(exports, "AgentForgeNetworkError", { enumerable: true, get: function () { return errors_1.AgentForgeNetworkError; } });
40
40
  var webhooks_1 = require("./webhooks");
41
+ Object.defineProperty(exports, "APP_WEBHOOK_HEADERS", { enumerable: true, get: function () { return webhooks_1.APP_WEBHOOK_HEADERS; } });
41
42
  Object.defineProperty(exports, "TOOL_CALLBACK_HEADERS", { enumerable: true, get: function () { return webhooks_1.TOOL_CALLBACK_HEADERS; } });
42
43
  Object.defineProperty(exports, "ToolCallbackSignatureError", { enumerable: true, get: function () { return webhooks_1.ToolCallbackSignatureError; } });
43
44
  Object.defineProperty(exports, "signToolCallbackPayload", { enumerable: true, get: function () { return webhooks_1.signToolCallbackPayload; } });
45
+ Object.defineProperty(exports, "verifyAppWebhook", { enumerable: true, get: function () { return webhooks_1.verifyAppWebhook; } });
44
46
  Object.defineProperty(exports, "verifyToolCallbackSignature", { enumerable: true, get: function () { return webhooks_1.verifyToolCallbackSignature; } });
47
+ var webhook_1 = require("./resources/webhook");
48
+ Object.defineProperty(exports, "WebhookResource", { enumerable: true, get: function () { return webhook_1.WebhookResource; } });
45
49
  var agents_1 = require("./resources/agents");
46
50
  Object.defineProperty(exports, "AgentsResource", { enumerable: true, get: function () { return agents_1.AgentsResource; } });
47
51
  var analytics_1 = require("./resources/analytics");
@@ -21,8 +21,14 @@ export declare class ConnectorsResource {
21
21
  * Drive…). Si el connector está conectado pero no tiene selector
22
22
  * implementado todavía, devuelve `{ items: [], unsupported: true }` en vez
23
23
  * de tirar — no es un error, es un estado a mostrar en la UI.
24
+ *
25
+ * `opts.q` (AGF-SHEETS-SEARCH) busca por nombre en Google Drive / Sheets
26
+ * (los demás connectors lo ignoran). Con un grant de Sheets sin
27
+ * `drive.readonly` el resultado trae `limited: true`.
24
28
  */
25
- listResources(connectorId: string): Promise<ListConnectorResourcesResult>;
29
+ listResources(connectorId: string, opts?: {
30
+ q?: string;
31
+ }): Promise<ListConnectorResourcesResult>;
26
32
  /**
27
33
  * `POST /connectors/oauth/:id/authorize-for-tenant` — arranca el OAuth
28
34
  * authorize del connector para el tenant del ak_live_ (sin sesión de
@@ -37,9 +37,14 @@ class ConnectorsResource {
37
37
  * Drive…). Si el connector está conectado pero no tiene selector
38
38
  * implementado todavía, devuelve `{ items: [], unsupported: true }` en vez
39
39
  * de tirar — no es un error, es un estado a mostrar en la UI.
40
+ *
41
+ * `opts.q` (AGF-SHEETS-SEARCH) busca por nombre en Google Drive / Sheets
42
+ * (los demás connectors lo ignoran). Con un grant de Sheets sin
43
+ * `drive.readonly` el resultado trae `limited: true`.
40
44
  */
41
- async listResources(connectorId) {
42
- return this.client.requestWithApiKey('GET', `/connector-resources/${encodeURIComponent(connectorId)}`);
45
+ async listResources(connectorId, opts) {
46
+ const q = opts?.q?.trim();
47
+ return this.client.requestWithApiKey('GET', `/connector-resources/${encodeURIComponent(connectorId)}${q ? `?q=${encodeURIComponent(q)}` : ''}`);
43
48
  }
44
49
  /**
45
50
  * `POST /connectors/oauth/:id/authorize-for-tenant` — arranca el OAuth
@@ -0,0 +1,16 @@
1
+ import type { AgentForgeClient } from '../client';
2
+ import type { AppWebhook, AppWebhookEventName } from '../types';
3
+ export interface SetAppWebhookInput {
4
+ /** https (http only for localhost while developing). */
5
+ url: string;
6
+ events: AppWebhookEventName[];
7
+ /** 32–256 characters; the App keeps it to verify deliveries. */
8
+ secret: string;
9
+ }
10
+ export declare class WebhookResource {
11
+ private readonly client;
12
+ constructor(client: AgentForgeClient);
13
+ set(input: SetAppWebhookInput): Promise<AppWebhook>;
14
+ get(): Promise<AppWebhook | null>;
15
+ remove(): Promise<void>;
16
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ // webhook resource — where the platform tells this App about events
3
+ // (AGF-APP-WEBHOOKS). One webhook per App; it receives the events of every
4
+ // tenant the App is installed in, and of its home tenant.
5
+ //
6
+ // - `set({ url, events, secret })` — `PUT /api/v1/webhook`. The App brings
7
+ // its own secret (32–256 chars) and keeps it: the platform never returns
8
+ // it. Idempotent: calling it on every boot is fine.
9
+ // - `get()` — the current webhook (url, events, active), or null.
10
+ // - `remove()` — stop receiving events.
11
+ //
12
+ // Verify each delivery with `verifyAppWebhook` (same signature scheme as the
13
+ // remote-tool callbacks). App secret, home tenant only (not on `forTenant`).
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.WebhookResource = void 0;
16
+ class WebhookResource {
17
+ constructor(client) {
18
+ this.client = client;
19
+ }
20
+ async set(input) {
21
+ return (await this.client.request('PUT', '/api/v1/webhook', input)).webhook;
22
+ }
23
+ async get() {
24
+ return (await this.client.request('GET', '/api/v1/webhook')).webhook;
25
+ }
26
+ async remove() {
27
+ await this.client.request('DELETE', '/api/v1/webhook');
28
+ }
29
+ }
30
+ exports.WebhookResource = WebhookResource;
package/dist/types.d.ts CHANGED
@@ -460,6 +460,10 @@ export interface ListConnectorResourcesResult {
460
460
  * `items` igual trae lo que SÍ se pudo listar (ej. los canales); la UI
461
461
  * debe ofrecer un CTA de reconectar en vez de tratarlo como error. */
462
462
  needsReconnectForDms?: true;
463
+ /** AGF-SHEETS-SEARCH: el grant de Google no puede listar todo el Drive (sin
464
+ * `drive.readonly`); `items` solo trae archivos que la app ya recibió (creados
465
+ * por ella o elegidos en el selector de Google). Ofrecer el selector o reconectar. */
466
+ limited?: true;
463
467
  }
464
468
  export interface CreateClickupTaskInput {
465
469
  /** Id de la lista de ClickUp (`ConnectorResourceItem.id` del picker). */
@@ -1248,8 +1252,10 @@ export interface CatalogImportSource {
1248
1252
  url?: string | null;
1249
1253
  columnMapping: CatalogImportColumnMapping;
1250
1254
  /** Per-connector extras, e.g. `{ shop: 'acme.myshopify.com' }`. */
1255
+ /** `linked`: a Google Sheet synced both ways with the catalog (AGF-SHEET-LIVE-SOURCE). */
1251
1256
  config: {
1252
1257
  shop?: string;
1258
+ linked?: boolean;
1253
1259
  };
1254
1260
  currency?: string | null;
1255
1261
  /** Cron string; null = manual only. */
@@ -1275,6 +1281,7 @@ export interface CreateCatalogImportSourceInput {
1275
1281
  columnMapping?: CatalogImportColumnMapping;
1276
1282
  config?: {
1277
1283
  shop?: string;
1284
+ linked?: boolean;
1278
1285
  };
1279
1286
  currency?: string;
1280
1287
  schedule?: string | null;
@@ -1293,6 +1300,7 @@ export interface UpdateCatalogImportSourceInput {
1293
1300
  columnMapping?: CatalogImportColumnMapping;
1294
1301
  config?: {
1295
1302
  shop?: string;
1303
+ linked?: boolean;
1296
1304
  };
1297
1305
  currency?: string | null;
1298
1306
  schedule?: string | null;
@@ -1613,4 +1621,30 @@ export interface ListCasesInput {
1613
1621
  /** 1–200, default 50. */
1614
1622
  limit?: number;
1615
1623
  }
1624
+ export type AppWebhookEventName = 'case.submitted' | 'case.state_changed' | 'case.closed';
1625
+ export interface AppWebhook {
1626
+ url: string;
1627
+ events: AppWebhookEventName[];
1628
+ active: boolean;
1629
+ createdAt: string;
1630
+ updatedAt: string;
1631
+ }
1632
+ /** What the platform POSTs. No customer data: read the case with `forTenant(tenantId).cases.get(caseId)`. */
1633
+ export interface AppWebhookEvent {
1634
+ /** Delivery id — dedupe on it (retries keep it). */
1635
+ id: string;
1636
+ type: AppWebhookEventName;
1637
+ createdAt: string;
1638
+ tenantId: string;
1639
+ data: {
1640
+ caseId: string;
1641
+ caseNumber: number;
1642
+ /** The case type key ("pedido"). */
1643
+ type: string;
1644
+ state: string;
1645
+ previousState?: string;
1646
+ by: 'assistant' | 'business' | 'system';
1647
+ conversationId: string;
1648
+ };
1649
+ }
1616
1650
  export {};
@@ -20,3 +20,22 @@ export declare function verifyToolCallbackSignature(input: {
20
20
  secretPlaintext: string;
21
21
  nowSeconds?: number;
22
22
  }): void;
23
+ export declare const APP_WEBHOOK_HEADERS: {
24
+ readonly signature: "x-agentforge-signature";
25
+ readonly event: "x-agentforge-event";
26
+ readonly delivery: "x-agentforge-delivery";
27
+ };
28
+ /**
29
+ * Verifies an App webhook delivery and returns its event. `rawBody` must be
30
+ * the exact bytes received (not a re-serialised object). Throws
31
+ * `ToolCallbackSignatureError` (`malformed` / `stale` / `mismatch`) — the same
32
+ * scheme and checks as the tool callbacks: `t=<ts>,v1=<hmac>`, ±5 min.
33
+ * Dedupe on `event.id` (= the `x-agentforge-delivery` header): a delivery can
34
+ * be retried.
35
+ */
36
+ export declare function verifyAppWebhook(input: {
37
+ rawBody: string;
38
+ signatureHeader: string;
39
+ secret: string;
40
+ nowSeconds?: number;
41
+ }): import('./types').AppWebhookEvent;
package/dist/webhooks.js CHANGED
@@ -24,9 +24,10 @@
24
24
  // `ToolsResource.respondToCallback`, que llama `signToolCallbackPayload`
25
25
  // internamente (no hace falta invocarlo a mano).
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.ToolCallbackSignatureError = exports.TOOL_CALLBACK_HEADERS = void 0;
27
+ exports.APP_WEBHOOK_HEADERS = exports.ToolCallbackSignatureError = exports.TOOL_CALLBACK_HEADERS = void 0;
28
28
  exports.signToolCallbackPayload = signToolCallbackPayload;
29
29
  exports.verifyToolCallbackSignature = verifyToolCallbackSignature;
30
+ exports.verifyAppWebhook = verifyAppWebhook;
30
31
  const node_crypto_1 = require("node:crypto");
31
32
  const MAX_AGE_SECONDS = 300;
32
33
  exports.TOOL_CALLBACK_HEADERS = {
@@ -88,3 +89,26 @@ function computeHmac(secretPlaintext, timestamp, rawBody) {
88
89
  .update(`${timestamp}.${rawBody}`)
89
90
  .digest('hex');
90
91
  }
92
+ // ─── App webhooks (AGF-APP-WEBHOOKS) ──────────────────────────────────
93
+ exports.APP_WEBHOOK_HEADERS = {
94
+ signature: 'x-agentforge-signature',
95
+ event: 'x-agentforge-event',
96
+ delivery: 'x-agentforge-delivery',
97
+ };
98
+ /**
99
+ * Verifies an App webhook delivery and returns its event. `rawBody` must be
100
+ * the exact bytes received (not a re-serialised object). Throws
101
+ * `ToolCallbackSignatureError` (`malformed` / `stale` / `mismatch`) — the same
102
+ * scheme and checks as the tool callbacks: `t=<ts>,v1=<hmac>`, ±5 min.
103
+ * Dedupe on `event.id` (= the `x-agentforge-delivery` header): a delivery can
104
+ * be retried.
105
+ */
106
+ function verifyAppWebhook(input) {
107
+ verifyToolCallbackSignature({
108
+ rawBody: input.rawBody,
109
+ signatureHeader: input.signatureHeader,
110
+ secretPlaintext: input.secret,
111
+ nowSeconds: input.nowSeconds,
112
+ });
113
+ return JSON.parse(input.rawBody);
114
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentforge-io/sdk-server",
3
- "version": "4.23.0",
3
+ "version": "4.25.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",