@alfe.ai/agent-api-client 0.0.2
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/index.d.ts +100 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -0
- package/package.json +28 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
//#region ../../packages-internal/types/dist/integration.d.ts
|
|
2
|
+
declare const IntegrationDesiredStatus: {
|
|
3
|
+
readonly Active: "active";
|
|
4
|
+
readonly Removed: "removed";
|
|
5
|
+
};
|
|
6
|
+
type IntegrationDesiredStatus = (typeof IntegrationDesiredStatus)[keyof typeof IntegrationDesiredStatus];
|
|
7
|
+
declare const IntegrationActualStatus: {
|
|
8
|
+
readonly Installing: "installing";
|
|
9
|
+
readonly Active: "active";
|
|
10
|
+
readonly Error: "error";
|
|
11
|
+
readonly Removing: "removing";
|
|
12
|
+
readonly Inactive: "inactive";
|
|
13
|
+
readonly Unknown: "unknown";
|
|
14
|
+
};
|
|
15
|
+
type IntegrationActualStatus = (typeof IntegrationActualStatus)[keyof typeof IntegrationActualStatus];
|
|
16
|
+
interface AgentIntegration {
|
|
17
|
+
agentId: string;
|
|
18
|
+
integrationId: string;
|
|
19
|
+
tenantId: string;
|
|
20
|
+
desiredStatus: IntegrationDesiredStatus;
|
|
21
|
+
actualStatus: IntegrationActualStatus;
|
|
22
|
+
version: string;
|
|
23
|
+
config: Record<string, unknown>;
|
|
24
|
+
errorMessage: string;
|
|
25
|
+
installedAt: string;
|
|
26
|
+
updatedAt: string;
|
|
27
|
+
}
|
|
28
|
+
interface IntegrationConfigSchemaField {
|
|
29
|
+
key: string;
|
|
30
|
+
label: string;
|
|
31
|
+
type: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
required?: boolean;
|
|
34
|
+
default?: string | number | boolean;
|
|
35
|
+
options?: string[];
|
|
36
|
+
select_options?: {
|
|
37
|
+
value: string;
|
|
38
|
+
label: string;
|
|
39
|
+
}[];
|
|
40
|
+
oauth_provider?: string;
|
|
41
|
+
editable?: string;
|
|
42
|
+
}
|
|
43
|
+
interface IntegrationConfigResult {
|
|
44
|
+
integrationId: string;
|
|
45
|
+
config: Record<string, unknown>;
|
|
46
|
+
configSchema: IntegrationConfigSchemaField[];
|
|
47
|
+
}
|
|
48
|
+
interface RegistryEntry {
|
|
49
|
+
id: string;
|
|
50
|
+
name: string;
|
|
51
|
+
description: string;
|
|
52
|
+
versions: string[];
|
|
53
|
+
latest: string;
|
|
54
|
+
repository: string;
|
|
55
|
+
commit?: string;
|
|
56
|
+
icon?: string;
|
|
57
|
+
author?: {
|
|
58
|
+
name: string;
|
|
59
|
+
url?: string;
|
|
60
|
+
} | string;
|
|
61
|
+
pricing?: {
|
|
62
|
+
type: "free" | "paid";
|
|
63
|
+
price?: number;
|
|
64
|
+
currency?: string;
|
|
65
|
+
interval?: "month" | "year";
|
|
66
|
+
};
|
|
67
|
+
features?: string[];
|
|
68
|
+
preview_images?: string[];
|
|
69
|
+
config_schema?: IntegrationConfigSchemaField[];
|
|
70
|
+
supported_agents?: string[];
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=integration.d.ts.map
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/index.d.ts
|
|
75
|
+
interface AgentApiClientConfig {
|
|
76
|
+
apiKey: string;
|
|
77
|
+
apiUrl: string;
|
|
78
|
+
}
|
|
79
|
+
declare class AgentApiClient {
|
|
80
|
+
private readonly apiKey;
|
|
81
|
+
private readonly apiUrl;
|
|
82
|
+
constructor(config: AgentApiClientConfig);
|
|
83
|
+
private request;
|
|
84
|
+
listIntegrations(): Promise<AgentIntegration[]>;
|
|
85
|
+
getIntegrationConfig(integrationId: string): Promise<IntegrationConfigResult>;
|
|
86
|
+
updateIntegrationConfig(integrationId: string, config: Record<string, unknown>): Promise<void>;
|
|
87
|
+
installIntegration(integrationId: string, options?: {
|
|
88
|
+
version?: string;
|
|
89
|
+
config?: Record<string, unknown>;
|
|
90
|
+
}): Promise<AgentIntegration>;
|
|
91
|
+
removeIntegration(integrationId: string): Promise<AgentIntegration>;
|
|
92
|
+
getRegistry(): Promise<{
|
|
93
|
+
integrations: RegistryEntry[];
|
|
94
|
+
}>;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=index.d.ts.map
|
|
97
|
+
|
|
98
|
+
//#endregion
|
|
99
|
+
export { AgentApiClient, AgentApiClientConfig, type AgentIntegration, type IntegrationConfigResult, type IntegrationConfigSchemaField, type RegistryEntry };
|
|
100
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["IntegrationDesiredStatus","INTEGRATION_DESIRED_STATUSES","IntegrationActualStatus","INTEGRATION_ACTUAL_STATUSES","AgentIntegration","Record","IntegrationConfigSchemaField","IntegrationConfigResult","RegistryEntry"],"sources":["../../../packages-internal/types/dist/integration.d.ts","../src/index.ts"],"sourcesContent":["export declare const IntegrationDesiredStatus: {\n readonly Active: \"active\";\n readonly Removed: \"removed\";\n};\nexport type IntegrationDesiredStatus = (typeof IntegrationDesiredStatus)[keyof typeof IntegrationDesiredStatus];\nexport declare const INTEGRATION_DESIRED_STATUSES: readonly [\"active\" | \"removed\", ...(\"active\" | \"removed\")[]];\nexport declare const IntegrationActualStatus: {\n readonly Installing: \"installing\";\n readonly Active: \"active\";\n readonly Error: \"error\";\n readonly Removing: \"removing\";\n readonly Inactive: \"inactive\";\n readonly Unknown: \"unknown\";\n};\nexport type IntegrationActualStatus = (typeof IntegrationActualStatus)[keyof typeof IntegrationActualStatus];\nexport declare const INTEGRATION_ACTUAL_STATUSES: readonly [\"active\" | \"error\" | \"installing\" | \"removing\" | \"inactive\" | \"unknown\", ...(\"active\" | \"error\" | \"installing\" | \"removing\" | \"inactive\" | \"unknown\")[]];\nexport interface AgentIntegration {\n agentId: string;\n integrationId: string;\n tenantId: string;\n desiredStatus: IntegrationDesiredStatus;\n actualStatus: IntegrationActualStatus;\n version: string;\n config: Record<string, unknown>;\n errorMessage: string;\n installedAt: string;\n updatedAt: string;\n}\nexport interface IntegrationConfigSchemaField {\n key: string;\n label: string;\n type: string;\n description?: string;\n required?: boolean;\n default?: string | number | boolean;\n options?: string[];\n select_options?: {\n value: string;\n label: string;\n }[];\n oauth_provider?: string;\n editable?: string;\n}\nexport interface IntegrationConfigResult {\n integrationId: string;\n config: Record<string, unknown>;\n configSchema: IntegrationConfigSchemaField[];\n}\nexport interface RegistryEntry {\n id: string;\n name: string;\n description: string;\n versions: string[];\n latest: string;\n repository: string;\n commit?: string;\n icon?: string;\n author?: {\n name: string;\n url?: string;\n } | string;\n pricing?: {\n type: \"free\" | \"paid\";\n price?: number;\n currency?: string;\n interval?: \"month\" | \"year\";\n };\n features?: string[];\n preview_images?: string[];\n config_schema?: IntegrationConfigSchemaField[];\n supported_agents?: string[];\n}\n//# sourceMappingURL=integration.d.ts.map"],"mappings":";cAAqBA;EAAAA,SAAAA,MAAAA,EAAAA,QAAAA;EAITA,SAAAA,OAAAA,EAAAA,SAAwB;CAAA;AAAWA,KAAnCA,wBAAAA,GAAmCA,CAAAA,OAAAA,wBAAAA,CAAAA,CAAAA,MAAAA,OAAuCA,wBAAvCA,CAAAA;AAA+D,cAEzFE,uBAFyF,EAAA;EAEzFA,SAAAA,UAAAA,EAAAA,YAOpB;EACWA,SAAAA,MAAAA,EAAAA,QAAAA;EAAuB,SAAA,KAAA,EAAA,OAAA;WAAWA,QAAAA,EAAAA,UAAAA;WAAsCA,QAAAA,EAAAA,UAAAA;EAAuB,SAAA,OAAA,EAAA,SAAA;AAE3G,CAAA;AAAiC,KAFrBA,uBAAAA,GAEqB,CAAA,OAFaA,uBAEb,CAAA,CAAA,MAAA,OAFmDA,uBAEnD,CAAA;AAKfA,UALDE,gBAAAA,CAKCF;SAENG,EAAAA,MAAAA;EAAM,aAAA,EAAA,MAAA;EAKDC,QAAAA,EAAAA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,CAAA;EAAA,kBAAA,CAAA,aAAA,EAAA,MAAA,EAAA,OAGM,CAHN,EAAA;IAE5BF,OAAAA,CAAAA,EAAAA,MAAAA;IACMC,MAAAA,CAAAA,EC2ByB,MD3BzBA,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;EAA4B,CAAA,CAAA,EC4BzC,OD5ByC,CC4BjC,gBD5BiC,CAAA;EAE7BE,iBAAa,CAAA,aAqBVF,EAAAA,MAAAA,CAAAA,ECgB8B,ODhB9BA,CCgBsC,gBDhBV,CAAA;iBCuBzB;kBAAwB;;AA3E/C;AAKA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//#region src/index.ts
|
|
2
|
+
var AgentApiClient = class {
|
|
3
|
+
apiKey;
|
|
4
|
+
apiUrl;
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.apiKey = config.apiKey;
|
|
7
|
+
this.apiUrl = config.apiUrl;
|
|
8
|
+
}
|
|
9
|
+
async request(path, options) {
|
|
10
|
+
const url = `${this.apiUrl}${path}`;
|
|
11
|
+
const headers = new Headers(options?.headers);
|
|
12
|
+
headers.set("Authorization", `Bearer ${this.apiKey}`);
|
|
13
|
+
headers.set("Content-Type", "application/json");
|
|
14
|
+
const res = await fetch(url, {
|
|
15
|
+
...options,
|
|
16
|
+
headers
|
|
17
|
+
});
|
|
18
|
+
if (!res.ok) {
|
|
19
|
+
const body = await res.text();
|
|
20
|
+
throw new Error(`Agent API error ${String(res.status)}: ${body}`);
|
|
21
|
+
}
|
|
22
|
+
return (await res.json()).data;
|
|
23
|
+
}
|
|
24
|
+
async listIntegrations() {
|
|
25
|
+
return this.request("/agents/integrations");
|
|
26
|
+
}
|
|
27
|
+
async getIntegrationConfig(integrationId) {
|
|
28
|
+
return this.request(`/agents/integrations/${encodeURIComponent(integrationId)}/config`);
|
|
29
|
+
}
|
|
30
|
+
async updateIntegrationConfig(integrationId, config) {
|
|
31
|
+
await this.request(`/agents/integrations/${encodeURIComponent(integrationId)}`, {
|
|
32
|
+
method: "PATCH",
|
|
33
|
+
body: JSON.stringify({ config })
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async installIntegration(integrationId, options) {
|
|
37
|
+
return this.request("/agents/integrations", {
|
|
38
|
+
method: "POST",
|
|
39
|
+
body: JSON.stringify({
|
|
40
|
+
integrationId,
|
|
41
|
+
version: options?.version,
|
|
42
|
+
config: options?.config
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
async removeIntegration(integrationId) {
|
|
47
|
+
return this.request(`/agents/integrations/${encodeURIComponent(integrationId)}`, { method: "DELETE" });
|
|
48
|
+
}
|
|
49
|
+
async getRegistry() {
|
|
50
|
+
return this.request("/integrations/registry");
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
//#endregion
|
|
54
|
+
export { AgentApiClient };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @alfe.ai/agent-api-client — Agent self-service API client.\n *\n * Used by agents calling /agents/ endpoints. The agent authenticates\n * with its API key — the backend resolves agentId + tenantId from the token.\n * No agent ID needed in paths or config.\n */\n\nexport type {\n AgentIntegration,\n IntegrationConfigResult,\n RegistryEntry,\n IntegrationConfigSchemaField,\n} from \"@alfe/types\";\n\nimport type { AgentIntegration, IntegrationConfigResult, RegistryEntry } from \"@alfe/types\";\n\nexport interface AgentApiClientConfig {\n apiKey: string;\n apiUrl: string;\n}\n\nexport class AgentApiClient {\n private readonly apiKey: string;\n private readonly apiUrl: string;\n\n constructor(config: AgentApiClientConfig) {\n this.apiKey = config.apiKey;\n this.apiUrl = config.apiUrl;\n }\n\n private async request<T>(path: string, options?: RequestInit): Promise<T> {\n const url = `${this.apiUrl}${path}`;\n const headers = new Headers(options?.headers);\n headers.set(\"Authorization\", `Bearer ${this.apiKey}`);\n headers.set(\"Content-Type\", \"application/json\");\n\n const res = await fetch(url, { ...options, headers });\n\n if (!res.ok) {\n const body = await res.text();\n throw new Error(`Agent API error ${String(res.status)}: ${body}`);\n }\n\n const body = (await res.json()) as { data: T };\n return body.data;\n }\n\n async listIntegrations(): Promise<AgentIntegration[]> {\n return this.request<AgentIntegration[]>(\"/agents/integrations\");\n }\n\n async getIntegrationConfig(integrationId: string): Promise<IntegrationConfigResult> {\n return this.request<IntegrationConfigResult>(\n `/agents/integrations/${encodeURIComponent(integrationId)}/config`,\n );\n }\n\n async updateIntegrationConfig(\n integrationId: string,\n config: Record<string, unknown>,\n ): Promise<void> {\n await this.request<unknown>(\n `/agents/integrations/${encodeURIComponent(integrationId)}`,\n {\n method: \"PATCH\",\n body: JSON.stringify({ config }),\n },\n );\n }\n\n async installIntegration(\n integrationId: string,\n options?: { version?: string; config?: Record<string, unknown> },\n ): Promise<AgentIntegration> {\n return this.request<AgentIntegration>(\"/agents/integrations\", {\n method: \"POST\",\n body: JSON.stringify({\n integrationId,\n version: options?.version,\n config: options?.config,\n }),\n });\n }\n\n async removeIntegration(integrationId: string): Promise<AgentIntegration> {\n return this.request<AgentIntegration>(\n `/agents/integrations/${encodeURIComponent(integrationId)}`,\n { method: \"DELETE\" },\n );\n }\n\n async getRegistry(): Promise<{ integrations: RegistryEntry[] }> {\n return this.request<{ integrations: RegistryEntry[] }>(\"/integrations/registry\");\n }\n}\n"],"mappings":";AAsBA,IAAa,iBAAb,MAA4B;CAC1B;CACA;CAEA,YAAY,QAA8B;AACxC,OAAK,SAAS,OAAO;AACrB,OAAK,SAAS,OAAO;;CAGvB,MAAc,QAAW,MAAc,SAAmC;EACxE,MAAM,MAAM,GAAG,KAAK,SAAS;EAC7B,MAAM,UAAU,IAAI,QAAQ,SAAS,QAAQ;AAC7C,UAAQ,IAAI,iBAAiB,UAAU,KAAK,SAAS;AACrD,UAAQ,IAAI,gBAAgB,mBAAmB;EAE/C,MAAM,MAAM,MAAM,MAAM,KAAK;GAAE,GAAG;GAAS;GAAS,CAAC;AAErD,MAAI,CAAC,IAAI,IAAI;GACX,MAAM,OAAO,MAAM,IAAI,MAAM;AAC7B,SAAM,IAAI,MAAM,mBAAmB,OAAO,IAAI,OAAO,CAAC,IAAI,OAAO;;AAInE,UADc,MAAM,IAAI,MAAM,EAClB;;CAGd,MAAM,mBAAgD;AACpD,SAAO,KAAK,QAA4B,uBAAuB;;CAGjE,MAAM,qBAAqB,eAAyD;AAClF,SAAO,KAAK,QACV,wBAAwB,mBAAmB,cAAc,CAAC,SAC3D;;CAGH,MAAM,wBACJ,eACA,QACe;AACf,QAAM,KAAK,QACT,wBAAwB,mBAAmB,cAAc,IACzD;GACE,QAAQ;GACR,MAAM,KAAK,UAAU,EAAE,QAAQ,CAAC;GACjC,CACF;;CAGH,MAAM,mBACJ,eACA,SAC2B;AAC3B,SAAO,KAAK,QAA0B,wBAAwB;GAC5D,QAAQ;GACR,MAAM,KAAK,UAAU;IACnB;IACA,SAAS,SAAS;IAClB,QAAQ,SAAS;IAClB,CAAC;GACH,CAAC;;CAGJ,MAAM,kBAAkB,eAAkD;AACxE,SAAO,KAAK,QACV,wBAAwB,mBAAmB,cAAc,IACzD,EAAE,QAAQ,UAAU,CACrB;;CAGH,MAAM,cAA0D;AAC9D,SAAO,KAAK,QAA2C,yBAAyB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alfe.ai/agent-api-client",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Agent self-service API client — agents calling /agents/ endpoints",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"dependencies": {},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@alfe/types": "0.1.0"
|
|
20
|
+
},
|
|
21
|
+
"license": "UNLICENSED",
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsdown",
|
|
24
|
+
"dev": "tsdown --watch",
|
|
25
|
+
"typecheck": "tsc --noEmit",
|
|
26
|
+
"lint": "eslint ."
|
|
27
|
+
}
|
|
28
|
+
}
|