@agentforge-io/sdk-server 4.22.0 → 4.24.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 +3 -0
- package/dist/client.js +2 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +5 -1
- package/dist/resources/webhook.d.ts +16 -0
- package/dist/resources/webhook.js +30 -0
- package/dist/types.d.ts +31 -0
- package/dist/webhooks.d.ts +19 -0
- package/dist/webhooks.js +25 -1
- package/package.json +1 -1
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
|
|
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");
|
|
@@ -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
|
@@ -1593,6 +1593,11 @@ export interface CaseView {
|
|
|
1593
1593
|
threadId: string | null;
|
|
1594
1594
|
/** The customer's name on that thread, when known. */
|
|
1595
1595
|
customerName: string | null;
|
|
1596
|
+
/** The road the business walks it: sent, accepted, the type's own phases, completed. */
|
|
1597
|
+
path: Array<{
|
|
1598
|
+
key: string;
|
|
1599
|
+
label: string;
|
|
1600
|
+
}>;
|
|
1596
1601
|
openedAt: string;
|
|
1597
1602
|
reviewedAt: string | null;
|
|
1598
1603
|
submittedAt: string | null;
|
|
@@ -1608,4 +1613,30 @@ export interface ListCasesInput {
|
|
|
1608
1613
|
/** 1–200, default 50. */
|
|
1609
1614
|
limit?: number;
|
|
1610
1615
|
}
|
|
1616
|
+
export type AppWebhookEventName = 'case.submitted' | 'case.state_changed' | 'case.closed';
|
|
1617
|
+
export interface AppWebhook {
|
|
1618
|
+
url: string;
|
|
1619
|
+
events: AppWebhookEventName[];
|
|
1620
|
+
active: boolean;
|
|
1621
|
+
createdAt: string;
|
|
1622
|
+
updatedAt: string;
|
|
1623
|
+
}
|
|
1624
|
+
/** What the platform POSTs. No customer data: read the case with `forTenant(tenantId).cases.get(caseId)`. */
|
|
1625
|
+
export interface AppWebhookEvent {
|
|
1626
|
+
/** Delivery id — dedupe on it (retries keep it). */
|
|
1627
|
+
id: string;
|
|
1628
|
+
type: AppWebhookEventName;
|
|
1629
|
+
createdAt: string;
|
|
1630
|
+
tenantId: string;
|
|
1631
|
+
data: {
|
|
1632
|
+
caseId: string;
|
|
1633
|
+
caseNumber: number;
|
|
1634
|
+
/** The case type key ("pedido"). */
|
|
1635
|
+
type: string;
|
|
1636
|
+
state: string;
|
|
1637
|
+
previousState?: string;
|
|
1638
|
+
by: 'assistant' | 'business' | 'system';
|
|
1639
|
+
conversationId: string;
|
|
1640
|
+
};
|
|
1641
|
+
}
|
|
1611
1642
|
export {};
|
package/dist/webhooks.d.ts
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "4.24.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",
|