@agentforge-io/sdk-server 4.7.0 → 4.9.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 +26 -0
- package/dist/client.js +36 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.js +8 -1
- package/dist/resources/chat.d.ts +19 -0
- package/dist/resources/chat.js +1 -0
- package/dist/resources/config.d.ts +11 -0
- package/dist/resources/config.js +23 -0
- package/dist/resources/installations.d.ts +22 -0
- package/dist/resources/installations.js +45 -0
- package/dist/resources/teams.d.ts +4 -1
- package/dist/resources/teams.js +5 -0
- package/dist/resources/templates.d.ts +23 -0
- package/dist/resources/templates.js +40 -0
- package/dist/types.d.ts +79 -0
- package/package.json +2 -2
package/dist/client.d.ts
CHANGED
|
@@ -4,9 +4,12 @@ import { AppsResource } from './resources/apps';
|
|
|
4
4
|
import { ChatResource } from './resources/chat';
|
|
5
5
|
import { ConnectorsResource } from './resources/connectors';
|
|
6
6
|
import { InboxResource } from './resources/inbox';
|
|
7
|
+
import { InstallationsResource } from './resources/installations';
|
|
7
8
|
import { ProvisioningResource } from './resources/provisioning';
|
|
8
9
|
import { SecretsResource } from './resources/secrets';
|
|
9
10
|
import { TeamsResource } from './resources/teams';
|
|
11
|
+
import { TemplatesResource } from './resources/templates';
|
|
12
|
+
import { TenantConfigResource } from './resources/config';
|
|
10
13
|
import { ToolsResource } from './resources/tools';
|
|
11
14
|
export interface AgentForgeClientOptions {
|
|
12
15
|
/** Platform base URL — e.g. http://localhost:3032 in dev. */
|
|
@@ -29,6 +32,11 @@ export interface AgentForgeClientOptions {
|
|
|
29
32
|
* travels on the `x-provisioning-secret` header, never `Authorization`. A
|
|
30
33
|
* client built with only this can ONLY call the provisioning surface. */
|
|
31
34
|
provisioningSecret?: string;
|
|
35
|
+
/** Tenant to act in when the App is installed there (App installations,
|
|
36
|
+
* AGF-096v). Requires `appSecret`; sent as `x-af-tenant`. Usually set via
|
|
37
|
+
* `af.forTenant(tenantId)` rather than by hand. Omit to act in the App's
|
|
38
|
+
* own tenant. */
|
|
39
|
+
tenantId?: string;
|
|
32
40
|
/** Override fetch (for testing or custom transports). */
|
|
33
41
|
fetch?: typeof fetch;
|
|
34
42
|
/** Default request timeout in ms. Applied to every HTTP call unless
|
|
@@ -52,8 +60,13 @@ export interface RequestOptions {
|
|
|
52
60
|
* run long. Defaults to the client's `timeoutMs`. */
|
|
53
61
|
timeoutMs?: number | null;
|
|
54
62
|
}
|
|
63
|
+
/** Header that selects an installed tenant for an App secret. */
|
|
64
|
+
export declare const INSTALLED_TENANT_HEADER = "x-af-tenant";
|
|
55
65
|
export declare class AgentForgeClient {
|
|
56
66
|
readonly baseURL: string;
|
|
67
|
+
/** Installed tenant this client acts in (`forTenant`), if any. */
|
|
68
|
+
readonly tenantId?: string;
|
|
69
|
+
private readonly options;
|
|
57
70
|
private readonly chatToken?;
|
|
58
71
|
private readonly apiKey?;
|
|
59
72
|
private readonly appSecret?;
|
|
@@ -66,11 +79,24 @@ export declare class AgentForgeClient {
|
|
|
66
79
|
readonly chat: ChatResource;
|
|
67
80
|
readonly connectors: ConnectorsResource;
|
|
68
81
|
readonly inbox: InboxResource;
|
|
82
|
+
readonly installations: InstallationsResource;
|
|
69
83
|
readonly provisioning: ProvisioningResource;
|
|
70
84
|
readonly secrets: SecretsResource;
|
|
71
85
|
readonly tools: ToolsResource;
|
|
72
86
|
readonly teams: TeamsResource;
|
|
87
|
+
readonly templates: TemplatesResource;
|
|
88
|
+
readonly config: TenantConfigResource;
|
|
73
89
|
constructor(opts: AgentForgeClientOptions);
|
|
90
|
+
/**
|
|
91
|
+
* A client that acts inside `tenantId`, a tenant where this App is
|
|
92
|
+
* installed (`af.installations.install`). Same App secret, same App
|
|
93
|
+
* identity; every call carries `x-af-tenant`. Only the App secret is
|
|
94
|
+
* kept — a chat token or `ak_live_` never crosses tenants.
|
|
95
|
+
*
|
|
96
|
+
* const owner = af.forTenant(installation.tenantId);
|
|
97
|
+
* await owner.templates.install(templateId, { name: 'Café Azul' });
|
|
98
|
+
*/
|
|
99
|
+
forTenant(tenantId: string): AgentForgeClient;
|
|
74
100
|
authHeaders(): Record<string, string>;
|
|
75
101
|
getAppSecret(): string | undefined;
|
|
76
102
|
/** The `x-provisioning-secret` header value, or throws if the client wasn't
|
package/dist/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AgentForgeClient = void 0;
|
|
3
|
+
exports.AgentForgeClient = exports.INSTALLED_TENANT_HEADER = void 0;
|
|
4
4
|
// AgentForgeClient — punto de entrada del SDK.
|
|
5
5
|
//
|
|
6
6
|
// Uso:
|
|
@@ -26,10 +26,15 @@ const apps_1 = require("./resources/apps");
|
|
|
26
26
|
const chat_1 = require("./resources/chat");
|
|
27
27
|
const connectors_1 = require("./resources/connectors");
|
|
28
28
|
const inbox_1 = require("./resources/inbox");
|
|
29
|
+
const installations_1 = require("./resources/installations");
|
|
29
30
|
const provisioning_1 = require("./resources/provisioning");
|
|
30
31
|
const secrets_1 = require("./resources/secrets");
|
|
31
32
|
const teams_1 = require("./resources/teams");
|
|
33
|
+
const templates_1 = require("./resources/templates");
|
|
34
|
+
const config_1 = require("./resources/config");
|
|
32
35
|
const tools_1 = require("./resources/tools");
|
|
36
|
+
/** Header that selects an installed tenant for an App secret. */
|
|
37
|
+
exports.INSTALLED_TENANT_HEADER = 'x-af-tenant';
|
|
33
38
|
class AgentForgeClient {
|
|
34
39
|
constructor(opts) {
|
|
35
40
|
if (!opts.baseURL) {
|
|
@@ -42,6 +47,11 @@ class AgentForgeClient {
|
|
|
42
47
|
throw new Error('AgentForgeClient: one of chatToken, apiKey, appSecret, or ' +
|
|
43
48
|
'provisioningSecret is required');
|
|
44
49
|
}
|
|
50
|
+
if (opts.tenantId !== undefined && (!opts.appSecret || !opts.tenantId.trim())) {
|
|
51
|
+
throw new Error('AgentForgeClient: tenantId needs an appSecret (sk_live_/sk_test_) and a non-empty id');
|
|
52
|
+
}
|
|
53
|
+
this.options = opts;
|
|
54
|
+
this.tenantId = opts.tenantId?.trim();
|
|
45
55
|
this.baseURL = opts.baseURL.replace(/\/$/, '');
|
|
46
56
|
this.chatToken = opts.chatToken;
|
|
47
57
|
this.apiKey = opts.apiKey;
|
|
@@ -55,10 +65,34 @@ class AgentForgeClient {
|
|
|
55
65
|
this.chat = new chat_1.ChatResource(this);
|
|
56
66
|
this.connectors = new connectors_1.ConnectorsResource(this);
|
|
57
67
|
this.inbox = new inbox_1.InboxResource(this);
|
|
68
|
+
this.installations = new installations_1.InstallationsResource(this);
|
|
58
69
|
this.provisioning = new provisioning_1.ProvisioningResource(this);
|
|
59
70
|
this.secrets = new secrets_1.SecretsResource(this);
|
|
60
71
|
this.tools = new tools_1.ToolsResource(this);
|
|
61
72
|
this.teams = new teams_1.TeamsResource(this);
|
|
73
|
+
this.templates = new templates_1.TemplatesResource(this);
|
|
74
|
+
this.config = new config_1.TenantConfigResource(this);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A client that acts inside `tenantId`, a tenant where this App is
|
|
78
|
+
* installed (`af.installations.install`). Same App secret, same App
|
|
79
|
+
* identity; every call carries `x-af-tenant`. Only the App secret is
|
|
80
|
+
* kept — a chat token or `ak_live_` never crosses tenants.
|
|
81
|
+
*
|
|
82
|
+
* const owner = af.forTenant(installation.tenantId);
|
|
83
|
+
* await owner.templates.install(templateId, { name: 'Café Azul' });
|
|
84
|
+
*/
|
|
85
|
+
forTenant(tenantId) {
|
|
86
|
+
if (!this.appSecret) {
|
|
87
|
+
throw new Error('AgentForgeClient.forTenant: needs a client built with an appSecret');
|
|
88
|
+
}
|
|
89
|
+
return new AgentForgeClient({
|
|
90
|
+
baseURL: this.baseURL,
|
|
91
|
+
appSecret: this.appSecret,
|
|
92
|
+
tenantId,
|
|
93
|
+
fetch: this.options.fetch,
|
|
94
|
+
timeoutMs: this.options.timeoutMs,
|
|
95
|
+
});
|
|
62
96
|
}
|
|
63
97
|
// Auth headers derivados del modo. ChatToken gana si ambos están presentes;
|
|
64
98
|
// luego apiKey (ak_live_); luego appSecret (sk_live_) — ambos secrets viajan
|
|
@@ -128,6 +162,7 @@ class AgentForgeClient {
|
|
|
128
162
|
...(opts?.rawBody !== undefined ? { 'content-type': 'application/json' } : {}),
|
|
129
163
|
accept: 'application/json',
|
|
130
164
|
...this.resolveAuthHeaders(opts),
|
|
165
|
+
...(this.tenantId ? { [exports.INSTALLED_TENANT_HEADER]: this.tenantId } : {}),
|
|
131
166
|
...(opts?.headers ?? {}),
|
|
132
167
|
},
|
|
133
168
|
body: opts?.rawBody,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
export { AgentForgeClient } from './client';
|
|
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
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, TeamSummary, AppSelf, AppSelfConnector, AppSelfConnectors, AppSelfConnectorTools, AppSelfConnectorToolsResponse, RegisterToolInput, RegisterToolsInput, RegisterToolsResult, ToolCallbackPayload, ToolCallRecord, ToolPermission, ToolPermissionMode, TokenUsage, TenantSecretEntry, UpdateAgentInput, InboxThreadMode, InboxMessageDirection, InboxMessageSource, InboxMessageType, InboxThreadCustomerProfileView, InboxThreadView, InboxMessageView, SupportKpiTotals, SupportKpiResponse, AgentAttentionLogRow, } from './types';
|
|
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, AppInstallation, TemplateConfigField, TemplateSummary, TemplateDetail, TemplateInstallResult, TenantConfigEntry, AppSelf, AppSelfConnector, AppSelfConnectors, AppSelfConnectorTools, AppSelfConnectorToolsResponse, RegisterToolInput, RegisterToolsInput, RegisterToolsResult, ToolCallbackPayload, ToolCallRecord, ToolPermission, ToolPermissionMode, TokenUsage, TenantSecretEntry, UpdateAgentInput, InboxThreadMode, InboxMessageDirection, InboxMessageSource, InboxMessageType, InboxThreadCustomerProfileView, InboxThreadView, InboxMessageView, SupportKpiTotals, SupportKpiResponse, AgentAttentionLogRow, } from './types';
|
|
6
6
|
export { AgentsResource } from './resources/agents';
|
|
7
7
|
export { AnalyticsResource } from './resources/analytics';
|
|
8
8
|
export type { GetSupportKpisInput, GetAgentAttentionLogInput, } from './resources/analytics';
|
|
9
9
|
export { AppsResource } from './resources/apps';
|
|
10
10
|
export { ChatResource } from './resources/chat';
|
|
11
|
-
export type { AnthropicClientOptions, StreamMessageInput } from './resources/chat';
|
|
11
|
+
export type { AnthropicClientOptions, AppCallerClaims, StreamMessageInput, StreamMessageForAppUserInput, } from './resources/chat';
|
|
12
12
|
export { ConnectorsResource } from './resources/connectors';
|
|
13
13
|
export type { InboxChannelView } from './resources/connectors';
|
|
14
14
|
export { InboxResource } from './resources/inbox';
|
|
15
|
+
export { InstallationsResource } from './resources/installations';
|
|
16
|
+
export type { InstallAppInput } from './resources/installations';
|
|
17
|
+
export { TemplatesResource } from './resources/templates';
|
|
18
|
+
export type { ListTemplatesInput } from './resources/templates';
|
|
19
|
+
export { TenantConfigResource } from './resources/config';
|
|
15
20
|
export type { ListThreadsOptions, SendMessageInput, AssignThreadInput, UnassignThreadInput, SetThreadModeInput, CloseThreadInput, } from './resources/inbox';
|
|
16
21
|
export { ProvisioningResource } from './resources/provisioning';
|
|
17
22
|
export type { ProvisionedTenant, ProvisionedApp, ProvisionedTeam, } from './resources/provisioning';
|
package/dist/index.js
CHANGED
|
@@ -28,9 +28,10 @@
|
|
|
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.InboxResource = 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.AgentForgeClient = void 0;
|
|
31
|
+
exports.ToolsResource = exports.TeamsResource = exports.SecretsResource = exports.ProvisioningResource = exports.TenantConfigResource = exports.TemplatesResource = exports.InstallationsResource = exports.InboxResource = 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;
|
|
32
32
|
var client_1 = require("./client");
|
|
33
33
|
Object.defineProperty(exports, "AgentForgeClient", { enumerable: true, get: function () { return client_1.AgentForgeClient; } });
|
|
34
|
+
Object.defineProperty(exports, "INSTALLED_TENANT_HEADER", { enumerable: true, get: function () { return client_1.INSTALLED_TENANT_HEADER; } });
|
|
34
35
|
var errors_1 = require("./errors");
|
|
35
36
|
Object.defineProperty(exports, "AgentForgeError", { enumerable: true, get: function () { return errors_1.AgentForgeError; } });
|
|
36
37
|
Object.defineProperty(exports, "AgentForgeAuthError", { enumerable: true, get: function () { return errors_1.AgentForgeAuthError; } });
|
|
@@ -53,6 +54,12 @@ var connectors_1 = require("./resources/connectors");
|
|
|
53
54
|
Object.defineProperty(exports, "ConnectorsResource", { enumerable: true, get: function () { return connectors_1.ConnectorsResource; } });
|
|
54
55
|
var inbox_1 = require("./resources/inbox");
|
|
55
56
|
Object.defineProperty(exports, "InboxResource", { enumerable: true, get: function () { return inbox_1.InboxResource; } });
|
|
57
|
+
var installations_1 = require("./resources/installations");
|
|
58
|
+
Object.defineProperty(exports, "InstallationsResource", { enumerable: true, get: function () { return installations_1.InstallationsResource; } });
|
|
59
|
+
var templates_1 = require("./resources/templates");
|
|
60
|
+
Object.defineProperty(exports, "TemplatesResource", { enumerable: true, get: function () { return templates_1.TemplatesResource; } });
|
|
61
|
+
var config_1 = require("./resources/config");
|
|
62
|
+
Object.defineProperty(exports, "TenantConfigResource", { enumerable: true, get: function () { return config_1.TenantConfigResource; } });
|
|
56
63
|
var provisioning_1 = require("./resources/provisioning");
|
|
57
64
|
Object.defineProperty(exports, "ProvisioningResource", { enumerable: true, get: function () { return provisioning_1.ProvisioningResource; } });
|
|
58
65
|
var secrets_1 = require("./resources/secrets");
|
package/dist/resources/chat.d.ts
CHANGED
|
@@ -42,6 +42,25 @@ export interface StreamMessageForAppUserInput {
|
|
|
42
42
|
* here to turn the sanitizer OFF for this operator-facing surface.
|
|
43
43
|
*/
|
|
44
44
|
channel?: ChannelContext;
|
|
45
|
+
/**
|
|
46
|
+
* AGF-OUTCOMES I5 — what the App declares about this end user for this
|
|
47
|
+
* turn. The platform shows it to the agent in the per-turn identity block
|
|
48
|
+
* as "declared by the App, not verified by AgentForge"; omit for no claims.
|
|
49
|
+
*/
|
|
50
|
+
caller?: AppCallerClaims;
|
|
51
|
+
}
|
|
52
|
+
/** What an App declares about its end user on a chat turn (see `caller`). */
|
|
53
|
+
export interface AppCallerClaims {
|
|
54
|
+
displayName?: string;
|
|
55
|
+
email?: string;
|
|
56
|
+
phone?: string;
|
|
57
|
+
/** App-defined role slugs (e.g. `mayorista`); prompts can branch on them. */
|
|
58
|
+
roles?: string[];
|
|
59
|
+
/** `true` only when the App itself verified the email. */
|
|
60
|
+
emailVerified?: boolean;
|
|
61
|
+
/** Where the person is, in the App's words — e.g. the reference of a
|
|
62
|
+
* scanned QR code (`mesa-03`). */
|
|
63
|
+
location?: string;
|
|
45
64
|
}
|
|
46
65
|
export declare class ChatResource {
|
|
47
66
|
private readonly client;
|
package/dist/resources/chat.js
CHANGED
|
@@ -149,6 +149,7 @@ class ChatResource {
|
|
|
149
149
|
externalUserId: input.externalUserId,
|
|
150
150
|
content: input.content,
|
|
151
151
|
...(input.channel ? { channel: input.channel } : {}),
|
|
152
|
+
...(input.caller ? { caller: input.caller } : {}),
|
|
152
153
|
});
|
|
153
154
|
if (!res.body) {
|
|
154
155
|
throw new Error('chat.streamMessageForAppUser: response has no readable body');
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AgentForgeClient } from '../client';
|
|
2
|
+
import type { TenantConfigEntry } from '../types';
|
|
3
|
+
export declare class TenantConfigResource {
|
|
4
|
+
private readonly client;
|
|
5
|
+
constructor(client: AgentForgeClient);
|
|
6
|
+
/** `GET /api/v1/config` — config variables that have a value. */
|
|
7
|
+
list(): Promise<TenantConfigEntry[]>;
|
|
8
|
+
/** `PUT /api/v1/config/:key` — set one variable (created when missing).
|
|
9
|
+
* 409 when the key is a secret, not a config variable. */
|
|
10
|
+
set(key: string, value: string): Promise<TenantConfigEntry>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// config resource — the tenant's config variables (`{{config:KEY}}` in
|
|
3
|
+
// prompts), company scope of the tenant the client acts in (AGF-096v). A
|
|
4
|
+
// host App fills the variables a template install created empty, e.g. the
|
|
5
|
+
// business name and hours of an owner's tenant.
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.TenantConfigResource = void 0;
|
|
8
|
+
class TenantConfigResource {
|
|
9
|
+
constructor(client) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
}
|
|
12
|
+
/** `GET /api/v1/config` — config variables that have a value. */
|
|
13
|
+
async list() {
|
|
14
|
+
const res = await this.client.request('GET', '/api/v1/config');
|
|
15
|
+
return res.items;
|
|
16
|
+
}
|
|
17
|
+
/** `PUT /api/v1/config/:key` — set one variable (created when missing).
|
|
18
|
+
* 409 when the key is a secret, not a config variable. */
|
|
19
|
+
async set(key, value) {
|
|
20
|
+
return this.client.request('PUT', `/api/v1/config/${encodeURIComponent(key)}`, { value });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.TenantConfigResource = TenantConfigResource;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AgentForgeClient } from '../client';
|
|
2
|
+
import type { AppInstallation } from '../types';
|
|
3
|
+
export interface InstallAppInput {
|
|
4
|
+
/** The host's id for this tenant (e.g. the owner id). Unique per App. */
|
|
5
|
+
externalRef: string;
|
|
6
|
+
/** Display name of the new tenant. */
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class InstallationsResource {
|
|
10
|
+
private readonly client;
|
|
11
|
+
constructor(client: AgentForgeClient);
|
|
12
|
+
/** `POST /api/v1/installations` — new tenant + installation, or the existing one for this ref. */
|
|
13
|
+
install(input: InstallAppInput): Promise<AppInstallation & {
|
|
14
|
+
created: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
/** `GET /api/v1/installations` — every installation of this App. */
|
|
17
|
+
list(): Promise<AppInstallation[]>;
|
|
18
|
+
/** `GET /api/v1/installations/:tenantId`. 404 → `AgentForgeNotFoundError`. */
|
|
19
|
+
get(tenantId: string): Promise<AppInstallation>;
|
|
20
|
+
/** `DELETE /api/v1/installations/:tenantId` — suspend (data kept). */
|
|
21
|
+
suspend(tenantId: string): Promise<AppInstallation>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// installations resource — App installations (AGF-096v, GitHub-App style).
|
|
3
|
+
//
|
|
4
|
+
// One App, many tenants: an App installs itself into a NEW tenant for one of
|
|
5
|
+
// its customers (PoodleDeck: one per business owner) and then acts inside it
|
|
6
|
+
// with the same `sk_live_` through `af.forTenant(tenantId)`.
|
|
7
|
+
//
|
|
8
|
+
// - `install({ externalRef, name })` — `POST /api/v1/installations`.
|
|
9
|
+
// Creates the tenant + installation; idempotent by `externalRef` (a retry
|
|
10
|
+
// returns the same tenant, `created: false`).
|
|
11
|
+
// - `list()` / `get(tenantId)` — the App's installations.
|
|
12
|
+
// - `suspend(tenantId)` — `DELETE`; the tenant and its data are kept and a
|
|
13
|
+
// later `install` with the same ref re-activates it.
|
|
14
|
+
//
|
|
15
|
+
// App secret only, called from the App's own tenant (not on a `forTenant`
|
|
16
|
+
// client — the platform answers 403 there).
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.InstallationsResource = void 0;
|
|
19
|
+
class InstallationsResource {
|
|
20
|
+
constructor(client) {
|
|
21
|
+
this.client = client;
|
|
22
|
+
}
|
|
23
|
+
/** `POST /api/v1/installations` — new tenant + installation, or the existing one for this ref. */
|
|
24
|
+
async install(input) {
|
|
25
|
+
const res = await this.client.requestRaw('POST', '/api/v1/installations', {
|
|
26
|
+
rawBody: JSON.stringify(input),
|
|
27
|
+
});
|
|
28
|
+
const body = (await res.json());
|
|
29
|
+
return { ...body, created: res.status === 201 };
|
|
30
|
+
}
|
|
31
|
+
/** `GET /api/v1/installations` — every installation of this App. */
|
|
32
|
+
async list() {
|
|
33
|
+
const res = await this.client.request('GET', '/api/v1/installations');
|
|
34
|
+
return res.items;
|
|
35
|
+
}
|
|
36
|
+
/** `GET /api/v1/installations/:tenantId`. 404 → `AgentForgeNotFoundError`. */
|
|
37
|
+
async get(tenantId) {
|
|
38
|
+
return this.client.request('GET', `/api/v1/installations/${encodeURIComponent(tenantId)}`);
|
|
39
|
+
}
|
|
40
|
+
/** `DELETE /api/v1/installations/:tenantId` — suspend (data kept). */
|
|
41
|
+
async suspend(tenantId) {
|
|
42
|
+
return this.client.request('DELETE', `/api/v1/installations/${encodeURIComponent(tenantId)}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.InstallationsResource = InstallationsResource;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentForgeClient } from '../client';
|
|
2
|
-
import type { CreateTeamInput, PublicTeamLanding, TeamSummary } from '../types';
|
|
2
|
+
import type { CreateTeamInput, PublicTeamLanding, TeamSummary, UpdateTeamInput } from '../types';
|
|
3
3
|
export declare class TeamsResource {
|
|
4
4
|
private readonly client;
|
|
5
5
|
constructor(client: AgentForgeClient);
|
|
@@ -7,6 +7,9 @@ export declare class TeamsResource {
|
|
|
7
7
|
getPublic(slug: string): Promise<PublicTeamLanding>;
|
|
8
8
|
/** `POST /api/v1/teams` — create a team (and its orchestrator) in the caller's tenant. */
|
|
9
9
|
create(input: CreateTeamInput): Promise<TeamSummary>;
|
|
10
|
+
/** `PATCH /api/v1/teams/:teamId` — e.g. give a team installed from a
|
|
11
|
+
* template its public page (`publicSlug` + `visibility: 'public'`). */
|
|
12
|
+
update(teamId: string, input: UpdateTeamInput): Promise<TeamSummary>;
|
|
10
13
|
/** `DELETE /api/v1/teams/:teamId` — delete a team of the caller's tenant. */
|
|
11
14
|
delete(teamId: string): Promise<void>;
|
|
12
15
|
}
|
package/dist/resources/teams.js
CHANGED
|
@@ -32,6 +32,11 @@ class TeamsResource {
|
|
|
32
32
|
async create(input) {
|
|
33
33
|
return this.client.request('POST', '/api/v1/teams', input);
|
|
34
34
|
}
|
|
35
|
+
/** `PATCH /api/v1/teams/:teamId` — e.g. give a team installed from a
|
|
36
|
+
* template its public page (`publicSlug` + `visibility: 'public'`). */
|
|
37
|
+
async update(teamId, input) {
|
|
38
|
+
return this.client.request('PATCH', `/api/v1/teams/${encodeURIComponent(teamId)}`, input);
|
|
39
|
+
}
|
|
35
40
|
/** `DELETE /api/v1/teams/:teamId` — delete a team of the caller's tenant. */
|
|
36
41
|
async delete(teamId) {
|
|
37
42
|
await this.client.request('DELETE', `/api/v1/teams/${encodeURIComponent(teamId)}`);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AgentForgeClient } from '../client';
|
|
2
|
+
import type { TemplateDetail, TemplateInstallResult, TemplateSummary } from '../types';
|
|
3
|
+
export interface ListTemplatesInput {
|
|
4
|
+
kind?: 'agent' | 'team';
|
|
5
|
+
/** Every tag must match (AND), e.g. ['poodledeck', 'type:food']. */
|
|
6
|
+
tags?: string[];
|
|
7
|
+
/** Free-text search. */
|
|
8
|
+
q?: string;
|
|
9
|
+
/** 1–200. */
|
|
10
|
+
limit?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare class TemplatesResource {
|
|
13
|
+
private readonly client;
|
|
14
|
+
constructor(client: AgentForgeClient);
|
|
15
|
+
/** `GET /api/v1/templates` — templates visible to the caller's tenant. */
|
|
16
|
+
list(input?: ListTemplatesInput): Promise<TemplateSummary[]>;
|
|
17
|
+
/** `GET /api/v1/templates/:id` — summary + payload. 404 → `AgentForgeNotFoundError`. */
|
|
18
|
+
get(templateId: string): Promise<TemplateDetail>;
|
|
19
|
+
/** `POST /api/v1/templates/:id/install` — clone into the caller's tenant. */
|
|
20
|
+
install(templateId: string, input?: {
|
|
21
|
+
name?: string;
|
|
22
|
+
}): Promise<TemplateInstallResult>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// templates resource — the platform template catalog for API keys
|
|
3
|
+
// (AGF-096v). A host App lists agent/team templates (its own + system +
|
|
4
|
+
// public, filtered by tag) and installs one into the tenant it acts in —
|
|
5
|
+
// usually an owner's tenant via `af.forTenant(tenantId).templates.install`.
|
|
6
|
+
//
|
|
7
|
+
// Installing copies the team, members, orchestrator, skills and tools, and
|
|
8
|
+
// creates the template's config variables EMPTY (`configCreated`); fill them
|
|
9
|
+
// with `config.set`. Rows created by an App secret are owned by the App.
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.TemplatesResource = void 0;
|
|
12
|
+
class TemplatesResource {
|
|
13
|
+
constructor(client) {
|
|
14
|
+
this.client = client;
|
|
15
|
+
}
|
|
16
|
+
/** `GET /api/v1/templates` — templates visible to the caller's tenant. */
|
|
17
|
+
async list(input = {}) {
|
|
18
|
+
const qs = new URLSearchParams();
|
|
19
|
+
if (input.kind)
|
|
20
|
+
qs.set('kind', input.kind);
|
|
21
|
+
for (const tag of input.tags ?? [])
|
|
22
|
+
qs.append('tag', tag);
|
|
23
|
+
if (input.q)
|
|
24
|
+
qs.set('q', input.q);
|
|
25
|
+
if (input.limit !== undefined)
|
|
26
|
+
qs.set('limit', String(input.limit));
|
|
27
|
+
const query = qs.toString();
|
|
28
|
+
const res = await this.client.request('GET', `/api/v1/templates${query ? `?${query}` : ''}`);
|
|
29
|
+
return res.items;
|
|
30
|
+
}
|
|
31
|
+
/** `GET /api/v1/templates/:id` — summary + payload. 404 → `AgentForgeNotFoundError`. */
|
|
32
|
+
async get(templateId) {
|
|
33
|
+
return this.client.request('GET', `/api/v1/templates/${encodeURIComponent(templateId)}`);
|
|
34
|
+
}
|
|
35
|
+
/** `POST /api/v1/templates/:id/install` — clone into the caller's tenant. */
|
|
36
|
+
async install(templateId, input = {}) {
|
|
37
|
+
return this.client.request('POST', `/api/v1/templates/${encodeURIComponent(templateId)}/install`, input);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.TemplatesResource = TemplatesResource;
|
package/dist/types.d.ts
CHANGED
|
@@ -650,4 +650,83 @@ export interface TeamSummary {
|
|
|
650
650
|
orchestrationMode: 'flat' | 'hierarchical';
|
|
651
651
|
[field: string]: unknown;
|
|
652
652
|
}
|
|
653
|
+
/** `PATCH /api/v1/teams/:id` body — only the fields sent change. */
|
|
654
|
+
export interface UpdateTeamInput {
|
|
655
|
+
name?: string;
|
|
656
|
+
description?: string | null;
|
|
657
|
+
/** Replaces the whole member set (short form: agent ids). */
|
|
658
|
+
memberAgentIds?: string[];
|
|
659
|
+
roleHints?: Record<string, string>;
|
|
660
|
+
/** Public page handle; `null` removes it. */
|
|
661
|
+
publicSlug?: string | null;
|
|
662
|
+
visibility?: 'private' | 'public';
|
|
663
|
+
orchestrationMode?: 'flat' | 'hierarchical';
|
|
664
|
+
}
|
|
665
|
+
/** An App's installation in a tenant (AGF-096v, `/api/v1/installations`). */
|
|
666
|
+
export interface AppInstallation {
|
|
667
|
+
id: string;
|
|
668
|
+
/** The installed tenant — pass it to `af.forTenant()`. */
|
|
669
|
+
tenantId: string;
|
|
670
|
+
externalRef: string;
|
|
671
|
+
status: 'active' | 'suspended';
|
|
672
|
+
createdAt: string;
|
|
673
|
+
}
|
|
674
|
+
/** One field of a template's config form (`{{config:KEY}}` variables). */
|
|
675
|
+
export interface TemplateConfigField {
|
|
676
|
+
key: string;
|
|
677
|
+
label: string;
|
|
678
|
+
help?: string;
|
|
679
|
+
/** 'text' | 'textarea' | 'hours' | 'address' | 'url' | 'phone' | … */
|
|
680
|
+
type: string;
|
|
681
|
+
required: boolean;
|
|
682
|
+
/** Resource picker for connector-backed fields (e.g. a Google Sheet). */
|
|
683
|
+
picker?: Record<string, unknown>;
|
|
684
|
+
}
|
|
685
|
+
/** A template as the API-key catalog lists it (`GET /api/v1/templates`). */
|
|
686
|
+
export interface TemplateSummary {
|
|
687
|
+
id: string;
|
|
688
|
+
tenantId: string | null;
|
|
689
|
+
kind: 'agent' | 'team';
|
|
690
|
+
name: string;
|
|
691
|
+
description?: string;
|
|
692
|
+
icon?: string;
|
|
693
|
+
category?: string;
|
|
694
|
+
tags?: string[];
|
|
695
|
+
visibility: 'system' | 'tenant' | 'public';
|
|
696
|
+
requiresConnectors?: string[];
|
|
697
|
+
requiresSecrets?: string[];
|
|
698
|
+
requiresConfig?: string[];
|
|
699
|
+
configSchema?: TemplateConfigField[];
|
|
700
|
+
installsCount: number;
|
|
701
|
+
currentVersion: number;
|
|
702
|
+
priceCents?: number;
|
|
703
|
+
createdAt: string;
|
|
704
|
+
updatedAt: string;
|
|
705
|
+
[field: string]: unknown;
|
|
706
|
+
}
|
|
707
|
+
/** `GET /api/v1/templates/:id` — summary + the snapshot it installs. */
|
|
708
|
+
export interface TemplateDetail extends TemplateSummary {
|
|
709
|
+
payload: Record<string, unknown>;
|
|
710
|
+
}
|
|
711
|
+
/** `POST /api/v1/templates/:id/install` result. */
|
|
712
|
+
export interface TemplateInstallResult {
|
|
713
|
+
kind: 'agent' | 'team';
|
|
714
|
+
agentId: string | null;
|
|
715
|
+
agentSlug: string | null;
|
|
716
|
+
teamId: string | null;
|
|
717
|
+
teamSlug: string | null;
|
|
718
|
+
requiresConnectors: string[];
|
|
719
|
+
requiresSecrets: string[];
|
|
720
|
+
requiresConfig: string[];
|
|
721
|
+
configSchema?: TemplateConfigField[];
|
|
722
|
+
/** Config variables this install created EMPTY — the host fills them. */
|
|
723
|
+
configCreated?: string[];
|
|
724
|
+
}
|
|
725
|
+
/** A tenant config variable (`/api/v1/config`). */
|
|
726
|
+
export interface TenantConfigEntry {
|
|
727
|
+
key: string;
|
|
728
|
+
description: string;
|
|
729
|
+
value: string | null;
|
|
730
|
+
updatedAt?: string;
|
|
731
|
+
}
|
|
653
732
|
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentforge-io/sdk-server",
|
|
3
|
-
"version": "4.
|
|
4
|
-
"description": "Server-side SDK for backend apps integrating with AgentForge platform. Auth via ChatToken
|
|
3
|
+
"version": "4.9.0",
|
|
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",
|
|
7
7
|
"types": "dist/index.d.ts",
|