@alfe.ai/agent-api-client 0.0.6 → 0.0.8

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.cjs CHANGED
@@ -17,25 +17,25 @@ var AgentApiClient = class {
17
17
  headers
18
18
  });
19
19
  if (!res.ok) {
20
- const body = await res.text();
21
- throw new Error(`Agent API error ${String(res.status)}: ${body}`);
20
+ await res.text();
21
+ throw new Error(`Agent API request failed (${String(res.status)})`);
22
22
  }
23
23
  return (await res.json()).data;
24
24
  }
25
25
  async listIntegrations() {
26
- return this.request("/agents/integrations");
26
+ return this.request("/agent/integrations");
27
27
  }
28
28
  async getIntegrationConfig(integrationId) {
29
- return this.request(`/agents/integrations/${encodeURIComponent(integrationId)}/config`);
29
+ return this.request(`/agent/integrations/${encodeURIComponent(integrationId)}/config`);
30
30
  }
31
31
  async updateIntegrationConfig(integrationId, config) {
32
- await this.request(`/agents/integrations/${encodeURIComponent(integrationId)}`, {
32
+ await this.request(`/agent/integrations/${encodeURIComponent(integrationId)}`, {
33
33
  method: "PATCH",
34
34
  body: JSON.stringify({ config })
35
35
  });
36
36
  }
37
37
  async installIntegration(integrationId, options) {
38
- return this.request("/agents/integrations", {
38
+ return this.request("/agent/integrations", {
39
39
  method: "POST",
40
40
  body: JSON.stringify({
41
41
  integrationId,
@@ -45,20 +45,114 @@ var AgentApiClient = class {
45
45
  });
46
46
  }
47
47
  async removeIntegration(integrationId) {
48
- return this.request(`/agents/integrations/${encodeURIComponent(integrationId)}`, { method: "DELETE" });
48
+ return this.request(`/agent/integrations/${encodeURIComponent(integrationId)}`, { method: "DELETE" });
49
49
  }
50
50
  async getRegistry() {
51
51
  return this.request("/integrations/registry");
52
52
  }
53
53
  async getGoogleCredentials() {
54
- return this.request("/agents/google/credentials");
54
+ return this.request("/agent/google/credentials");
55
+ }
56
+ async disconnectGoogleAccount(email) {
57
+ return this.request(`/agent/google/accounts/${encodeURIComponent(email)}`, { method: "DELETE" });
58
+ }
59
+ async setDefaultGoogleAccount(email) {
60
+ return this.request(`/agent/google/accounts/${encodeURIComponent(email)}/default`, { method: "PUT" });
61
+ }
62
+ async getGithubCredentials() {
63
+ return this.request("/agent/github/credentials");
64
+ }
65
+ async getXeroCredentials() {
66
+ return this.request("/agent/xero/credentials");
67
+ }
68
+ async refreshXeroToken() {
69
+ return this.request("/agent/xero/token", { method: "POST" });
70
+ }
71
+ async getNotionCredentials() {
72
+ return this.request("/agent/notion/credentials");
73
+ }
74
+ async getAtlassianCredentials() {
75
+ return this.request("/agent/atlassian/credentials");
76
+ }
77
+ async refreshAtlassianToken() {
78
+ return this.request("/agent/atlassian/token", { method: "POST" });
79
+ }
80
+ async getMYOBCredentials() {
81
+ return this.request("/agent/myob/credentials");
82
+ }
83
+ async refreshMYOBToken() {
84
+ return this.request("/agent/myob/token", { method: "POST" });
85
+ }
86
+ async getTeamsCredentials() {
87
+ return this.request("/agent/microsoft/credentials");
88
+ }
89
+ async sendTeamsMessage(data) {
90
+ return this.request("/agent/microsoft/send", {
91
+ method: "POST",
92
+ body: JSON.stringify(data)
93
+ });
94
+ }
95
+ async listTeamsChannels() {
96
+ return this.request("/agent/microsoft/channels");
97
+ }
98
+ async presignAttachments(files) {
99
+ return this.request("/agent/chat/attachments/presign", {
100
+ method: "POST",
101
+ body: JSON.stringify({ files })
102
+ });
55
103
  }
56
104
  async recordActivity(data) {
57
- return this.request("/agents/activity", {
105
+ return this.request("/agent/activity", {
58
106
  method: "POST",
59
107
  body: JSON.stringify(data)
60
108
  });
61
109
  }
110
+ /**
111
+ * Mint a fresh AES-256 data key for a new secret or rotation. The encryption
112
+ * context is rebuilt server-side from `auth.tenantId` + the body fields; the
113
+ * agent cannot forge context for a scope it doesn't own.
114
+ */
115
+ async generateSecretDataKey(args) {
116
+ return this.request("/agent/secrets/generate-data-key", {
117
+ method: "POST",
118
+ body: JSON.stringify(args)
119
+ });
120
+ }
121
+ /**
122
+ * Unwrap a wrapped data key so the agent can decrypt the envelope locally.
123
+ * KMS Decrypt will fail with `InvalidCiphertextException` if the envelope
124
+ * was tampered with in a way that changes `{ tenantId, scope, scopeId, secretId }`.
125
+ */
126
+ async decryptSecretDataKey(args) {
127
+ return this.request("/agent/secrets/decrypt-data-key", {
128
+ method: "POST",
129
+ body: JSON.stringify(args)
130
+ });
131
+ }
132
+ /** Upload a pre-encrypted envelope for a secret. */
133
+ async putSecretEnvelope(args) {
134
+ const { scope, scopeId, secretId, ...body } = args;
135
+ return this.request(`/agent/secrets/${encodeURIComponent(scope)}/${encodeURIComponent(scopeId)}/${encodeURIComponent(secretId)}`, {
136
+ method: "PUT",
137
+ body: JSON.stringify(body)
138
+ });
139
+ }
140
+ /** Fetch the encrypted envelope for a single secret. */
141
+ async getSecretEnvelope(args) {
142
+ return this.request(`/agent/secrets/${encodeURIComponent(args.scope)}/${encodeURIComponent(args.scopeId)}/${encodeURIComponent(args.secretId)}`);
143
+ }
144
+ /** List metadata (never envelopes) for secrets in a scope. */
145
+ async listSecrets(args) {
146
+ return (await this.request(`/agent/secrets/${encodeURIComponent(args.scope)}/${encodeURIComponent(args.scopeId)}`)).secrets;
147
+ }
148
+ /** Delete a secret. */
149
+ async deleteSecret(args) {
150
+ await this.request(`/agent/secrets/${encodeURIComponent(args.scope)}/${encodeURIComponent(args.scopeId)}/${encodeURIComponent(args.secretId)}`, { method: "DELETE" });
151
+ }
152
+ /** Enumerate scopes (org/team/project/agent) this agent can access. */
153
+ async listSecretScopes() {
154
+ return (await this.request("/agent/secrets/scopes")).scopes;
155
+ }
62
156
  };
63
157
  //#endregion
64
158
  exports.AgentApiClient = AgentApiClient;
package/dist/index.d.cts CHANGED
@@ -1,9 +1,8 @@
1
1
  //#region ../../packages-internal/types/dist/integration.d.ts
2
2
 
3
- /** Controls where an integration appears: public (everyone), dev (non-prod only), hidden (nowhere) */
3
+ /** Controls where an integration appears: public (everyone), hidden (nowhere) */
4
4
  declare const IntegrationVisibility: {
5
5
  readonly Public: "public";
6
- readonly Dev: "dev";
7
6
  readonly Hidden: "hidden";
8
7
  };
9
8
  type IntegrationVisibility = (typeof IntegrationVisibility)[keyof typeof IntegrationVisibility];
@@ -58,6 +57,7 @@ interface IntegrationConfigSchemaField {
58
57
  }[];
59
58
  oauth_provider?: string;
60
59
  editable?: string;
60
+ hidden?: boolean;
61
61
  }
62
62
  interface IntegrationConfigResult {
63
63
  integrationId: string;
@@ -95,6 +95,61 @@ interface RegistryEntry {
95
95
  }
96
96
  //# sourceMappingURL=integration.d.ts.map
97
97
  //#endregion
98
+ //#region ../../packages-internal/types/dist/secrets.d.ts
99
+ /**
100
+ * Secrets types — shared between services/secrets, @alfe.ai/agent-api-client,
101
+ * the openclaw-secrets plugin, and dashboard clients.
102
+ *
103
+ * Server-side crypto and KMS glue live in @alfe/secret-store (Node/AWS-only);
104
+ * this module is a pure, dependency-free shape contract safe for every
105
+ * environment the agent-api-client ships to.
106
+ */
107
+ /** Scope levels at which a secret can be owned. */
108
+ type SecretScope = "org" | "team" | "project" | "agent";
109
+ /**
110
+ * v1 encrypted envelope as persisted by services/secrets and exchanged with
111
+ * agents. Values are AES-256-GCM ciphertext; iv/authTag/ciphertext/dataKeyCiphertext
112
+ * are all base64-encoded.
113
+ */
114
+ interface EncryptedEnvelopeV1 {
115
+ version: 1;
116
+ iv: string;
117
+ ciphertext: string;
118
+ authTag: string;
119
+ dataKeyCiphertext: string;
120
+ }
121
+ /** Opaque metadata about a secret row — never includes plaintext. */
122
+ interface SecretMetadata {
123
+ secretId: string;
124
+ secretName: string;
125
+ description?: string;
126
+ tags?: string[];
127
+ createdAt: string;
128
+ updatedAt: string;
129
+ rotatedAt?: string;
130
+ }
131
+ /** A single secret row including its encrypted envelope. */
132
+ interface SecretEnvelopeResponse extends SecretMetadata {
133
+ envelope: EncryptedEnvelopeV1;
134
+ }
135
+ /** A scope the caller can read or write secrets in. */
136
+ interface ScopeInfo {
137
+ scope: SecretScope;
138
+ scopeId: string;
139
+ name?: string;
140
+ }
141
+ /**
142
+ * KMS-issued data key, returned by the secrets service's
143
+ * `/secrets/generate-data-key` KMS proxy endpoint. The plaintext key is
144
+ * returned base64-encoded; callers MUST decode it to a Buffer and zero the
145
+ * Buffer after use — never keep the plaintext as a JS string.
146
+ */
147
+ interface GeneratedDataKey {
148
+ plaintextKey: string;
149
+ dataKeyCiphertext: string;
150
+ }
151
+ //# sourceMappingURL=secrets.d.ts.map
152
+ //#endregion
98
153
  //#region src/index.d.ts
99
154
  interface AgentApiClientConfig {
100
155
  apiKey: string;
@@ -117,10 +172,115 @@ declare class AgentApiClient {
117
172
  integrations: RegistryEntry[];
118
173
  }>;
119
174
  getGoogleCredentials(): Promise<{
175
+ accounts?: {
176
+ email: string;
177
+ refreshToken: string;
178
+ clientId: string;
179
+ clientSecret: string;
180
+ enabledServices?: string[];
181
+ isDefault: boolean;
182
+ displayName?: string;
183
+ }[];
120
184
  email: string;
121
185
  refreshToken: string;
122
186
  clientId: string;
123
187
  clientSecret: string;
188
+ projectId: string;
189
+ enabledServices?: string[];
190
+ }>;
191
+ disconnectGoogleAccount(email: string): Promise<{
192
+ accounts: {
193
+ email: string;
194
+ displayName?: string;
195
+ isDefault: boolean;
196
+ }[];
197
+ }>;
198
+ setDefaultGoogleAccount(email: string): Promise<{
199
+ accounts: {
200
+ email: string;
201
+ displayName?: string;
202
+ isDefault: boolean;
203
+ }[];
204
+ }>;
205
+ getGithubCredentials(): Promise<{
206
+ login: string;
207
+ accessToken: string;
208
+ }>;
209
+ getXeroCredentials(): Promise<{
210
+ accessToken: string;
211
+ accessTokenExpiresAt: string;
212
+ xeroTenantId: string;
213
+ }>;
214
+ refreshXeroToken(): Promise<{
215
+ accessToken: string;
216
+ expiresAt: string;
217
+ }>;
218
+ getNotionCredentials(): Promise<{
219
+ accessToken: string;
220
+ workspaceId: string;
221
+ workspaceName: string;
222
+ }>;
223
+ getAtlassianCredentials(): Promise<{
224
+ accessToken: string;
225
+ refreshToken: string;
226
+ accessTokenExpiresAt: string;
227
+ cloudId: string;
228
+ siteName: string;
229
+ siteUrl: string;
230
+ email: string;
231
+ enabledProducts: string[];
232
+ }>;
233
+ refreshAtlassianToken(): Promise<{
234
+ accessToken: string;
235
+ expiresAt: string;
236
+ }>;
237
+ getMYOBCredentials(): Promise<{
238
+ accessToken: string;
239
+ accessTokenExpiresAt: string;
240
+ myobBusinessId: string;
241
+ clientId: string;
242
+ }>;
243
+ refreshMYOBToken(): Promise<{
244
+ accessToken: string;
245
+ expiresAt: string;
246
+ }>;
247
+ getTeamsCredentials(): Promise<{
248
+ agentId: string;
249
+ tenantId: string;
250
+ azureAppId: string;
251
+ azureBotId: string;
252
+ azureClientSecret: string;
253
+ botDisplayName?: string;
254
+ teamsTenantId?: string;
255
+ serviceUrl?: string;
256
+ }>;
257
+ sendTeamsMessage(data: {
258
+ conversationId: string;
259
+ text?: string;
260
+ adaptiveCard?: Record<string, unknown>;
261
+ }): Promise<{
262
+ ok: boolean;
263
+ activityId: string;
264
+ }>;
265
+ listTeamsChannels(): Promise<{
266
+ channels: {
267
+ id: string;
268
+ name: string;
269
+ description?: string;
270
+ }[];
271
+ }>;
272
+ presignAttachments(files: {
273
+ filename: string;
274
+ mimeType: string;
275
+ size: number;
276
+ }[]): Promise<{
277
+ attachments: {
278
+ id: string;
279
+ uploadUrl: string;
280
+ downloadUrl: string;
281
+ s3Key: string;
282
+ expiresAt: string;
283
+ }[];
124
284
  }>;
125
285
  recordActivity(data: {
126
286
  userId?: string;
@@ -129,9 +289,62 @@ declare class AgentApiClient {
129
289
  }): Promise<{
130
290
  recorded: boolean;
131
291
  }>;
292
+ /**
293
+ * Mint a fresh AES-256 data key for a new secret or rotation. The encryption
294
+ * context is rebuilt server-side from `auth.tenantId` + the body fields; the
295
+ * agent cannot forge context for a scope it doesn't own.
296
+ */
297
+ generateSecretDataKey(args: {
298
+ scope: SecretScope;
299
+ scopeId: string;
300
+ secretId: string;
301
+ }): Promise<GeneratedDataKey>;
302
+ /**
303
+ * Unwrap a wrapped data key so the agent can decrypt the envelope locally.
304
+ * KMS Decrypt will fail with `InvalidCiphertextException` if the envelope
305
+ * was tampered with in a way that changes `{ tenantId, scope, scopeId, secretId }`.
306
+ */
307
+ decryptSecretDataKey(args: {
308
+ scope: SecretScope;
309
+ scopeId: string;
310
+ secretId: string;
311
+ dataKeyCiphertext: string;
312
+ }): Promise<{
313
+ plaintextKey: string;
314
+ }>;
315
+ /** Upload a pre-encrypted envelope for a secret. */
316
+ putSecretEnvelope(args: {
317
+ scope: SecretScope;
318
+ scopeId: string;
319
+ secretId: string;
320
+ secretName: string;
321
+ envelope: EncryptedEnvelopeV1;
322
+ description?: string;
323
+ tags?: string[];
324
+ }): Promise<{
325
+ secretId: string;
326
+ }>;
327
+ /** Fetch the encrypted envelope for a single secret. */
328
+ getSecretEnvelope(args: {
329
+ scope: SecretScope;
330
+ scopeId: string;
331
+ secretId: string;
332
+ }): Promise<SecretEnvelopeResponse>;
333
+ /** List metadata (never envelopes) for secrets in a scope. */
334
+ listSecrets(args: {
335
+ scope: SecretScope;
336
+ scopeId: string;
337
+ }): Promise<SecretMetadata[]>;
338
+ /** Delete a secret. */
339
+ deleteSecret(args: {
340
+ scope: SecretScope;
341
+ scopeId: string;
342
+ secretId: string;
343
+ }): Promise<void>;
344
+ /** Enumerate scopes (org/team/project/agent) this agent can access. */
345
+ listSecretScopes(): Promise<ScopeInfo[]>;
132
346
  }
133
347
  //# sourceMappingURL=index.d.ts.map
134
-
135
348
  //#endregion
136
- export { AgentApiClient, AgentApiClientConfig, type IntegrationConfigResult, type IntegrationConfigSchemaField, type IntegrationInstall, type RegistryEntry };
349
+ export { AgentApiClient, AgentApiClientConfig, type EncryptedEnvelopeV1, type GeneratedDataKey, type IntegrationConfigResult, type IntegrationConfigSchemaField, type IntegrationInstall, type RegistryEntry, type ScopeInfo, type SecretEnvelopeResponse, type SecretMetadata, type SecretScope };
137
350
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":["DEFAULT_INTEGRATIONS","IntegrationVisibility","INTEGRATION_VISIBILITIES","IntegrationScope","INTEGRATION_SCOPES","IntegrationDesiredStatus","INTEGRATION_DESIRED_STATUSES","IntegrationActualStatus","INTEGRATION_ACTUAL_STATUSES","IntegrationInstall","Record","AgentIntegration","OrgIntegration","IntegrationConfigSchemaField","IntegrationConfigResult","RegistryEntry"],"sources":["../../../packages-internal/types/dist/integration.d.ts","../src/index.ts"],"sourcesContent":["/** Integrations auto-installed for ALL agents regardless of hosting type. Cannot be removed. */\nexport declare const DEFAULT_INTEGRATIONS: readonly string[];\n/** Controls where an integration appears: public (everyone), dev (non-prod only), hidden (nowhere) */\nexport declare const IntegrationVisibility: {\n readonly Public: \"public\";\n readonly Dev: \"dev\";\n readonly Hidden: \"hidden\";\n};\nexport type IntegrationVisibility = (typeof IntegrationVisibility)[keyof typeof IntegrationVisibility];\nexport declare const INTEGRATION_VISIBILITIES: readonly [\"dev\" | \"public\" | \"hidden\", ...(\"dev\" | \"public\" | \"hidden\")[]];\n/** Scope at which an integration is installed */\nexport declare const IntegrationScope: {\n readonly Org: \"org\";\n readonly Team: \"team\";\n readonly Project: \"project\";\n readonly Agent: \"agent\";\n};\nexport type IntegrationScope = (typeof IntegrationScope)[keyof typeof IntegrationScope];\nexport declare const INTEGRATION_SCOPES: readonly [\"org\" | \"team\" | \"project\" | \"agent\", ...(\"org\" | \"team\" | \"project\" | \"agent\")[]];\nexport 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 IntegrationInstall {\n scope: IntegrationScope;\n scopeId: 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}\n/** @deprecated Use IntegrationInstall instead */\nexport type AgentIntegration = IntegrationInstall;\n/** Org-scoped integration install */\nexport type OrgIntegration = IntegrationInstall;\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\" | \"usage\";\n price?: number;\n currency?: string;\n interval?: \"month\" | \"year\";\n description?: string;\n };\n features?: string[];\n preview_images?: string[];\n config_schema?: IntegrationConfigSchemaField[];\n supported_agents?: string[];\n /** Scopes where this integration can be installed */\n supported_scopes?: IntegrationScope[];\n /** Visibility status — controls where integration appears */\n visibility?: IntegrationVisibility;\n}\n//# sourceMappingURL=integration.d.ts.map"],"mappings":";;AAQA;AAAiC,cALZC,qBAKY,EAAA;WAAWA,MAAAA,EAAAA,QAAAA;WAAoCA,GAAAA,EAAAA,KAAAA;EAAqB,SAAA,MAAA,EAAA,QAAA;AAGrG,CAAA;A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Z,ODzDY,CAAA;IACxBN,YAAAA,ECwDoC,aDxDpCA,EAAAA;;sBAKOI,CAAAA,CAAAA,ECuDc,ODvDdA,CAAAA;IAENG,KAAAA,EAAAA,MAAAA;IAAM,YAAA,EAAA,MAAA;IASDG,QAAAA,EAAAA,MAAAA;IAeAC,YAAAA,EAAAA,MAAAA;EAAuB,CAAA,CAAA;gBAE5BJ,CAAAA,IAAAA,EAAAA;IACMG,MAAAA,CAAAA,EAAAA,MAAAA;IAA4B,OAAA,EAAA,MAAA;IAE7BE,IAAAA,EAAAA,MAAa,GAAA,WAAA;EAAA,CAAA,CAAA,ECqCxB,ODrCwB,CAAA;IAsBVF,QAAAA,EAAAA,OAAAA"}
1
+ {"version":3,"file":"index.d.cts","names":["DEFAULT_INTEGRATIONS","IntegrationVisibility","INTEGRATION_VISIBILITIES","IntegrationScope","INTEGRATION_SCOPES","IntegrationDesiredStatus","INTEGRATION_DESIRED_STATUSES","IntegrationActualStatus","INTEGRATION_ACTUAL_STATUSES","IntegrationInstall","Record","AgentIntegration","OrgIntegration","IntegrationConfigSchemaField","IntegrationConfigResult","RegistryEntry","SecretScope","EncryptedEnvelopeV1","SecretMetadata","SecretEnvelopeResponse","ScopeInfo","GeneratedDataKey"],"sources":["../../../packages-internal/types/dist/integration.d.ts","../../../packages-internal/types/dist/secrets.d.ts","../src/index.ts"],"sourcesContent":["/** Integrations auto-installed for ALL agents regardless of hosting type. Cannot be removed. */\nexport declare const DEFAULT_INTEGRATIONS: readonly string[];\n/** Controls where an integration appears: public (everyone), hidden (nowhere) */\nexport declare const IntegrationVisibility: {\n readonly Public: \"public\";\n readonly Hidden: \"hidden\";\n};\nexport type IntegrationVisibility = (typeof IntegrationVisibility)[keyof typeof IntegrationVisibility];\nexport declare const INTEGRATION_VISIBILITIES: readonly [\"public\" | \"hidden\", ...(\"public\" | \"hidden\")[]];\n/** Scope at which an integration is installed */\nexport declare const IntegrationScope: {\n readonly Org: \"org\";\n readonly Team: \"team\";\n readonly Project: \"project\";\n readonly Agent: \"agent\";\n};\nexport type IntegrationScope = (typeof IntegrationScope)[keyof typeof IntegrationScope];\nexport declare const INTEGRATION_SCOPES: readonly [\"org\" | \"team\" | \"project\" | \"agent\", ...(\"org\" | \"team\" | \"project\" | \"agent\")[]];\nexport 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 IntegrationInstall {\n scope: IntegrationScope;\n scopeId: 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}\n/** @deprecated Use IntegrationInstall instead */\nexport type AgentIntegration = IntegrationInstall;\n/** Org-scoped integration install */\nexport type OrgIntegration = IntegrationInstall;\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 hidden?: boolean;\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\" | \"usage\";\n price?: number;\n currency?: string;\n interval?: \"month\" | \"year\";\n description?: string;\n };\n features?: string[];\n preview_images?: string[];\n config_schema?: IntegrationConfigSchemaField[];\n supported_agents?: string[];\n /** Scopes where this integration can be installed */\n supported_scopes?: IntegrationScope[];\n /** Visibility status — controls where integration appears */\n visibility?: IntegrationVisibility;\n}\n//# sourceMappingURL=integration.d.ts.map","/**\n * Secrets types — shared between services/secrets, @alfe.ai/agent-api-client,\n * the openclaw-secrets plugin, and dashboard clients.\n *\n * Server-side crypto and KMS glue live in @alfe/secret-store (Node/AWS-only);\n * this module is a pure, dependency-free shape contract safe for every\n * environment the agent-api-client ships to.\n */\n/** Scope levels at which a secret can be owned. */\nexport type SecretScope = \"org\" | \"team\" | \"project\" | \"agent\";\n/**\n * v1 encrypted envelope as persisted by services/secrets and exchanged with\n * agents. Values are AES-256-GCM ciphertext; iv/authTag/ciphertext/dataKeyCiphertext\n * are all base64-encoded.\n */\nexport interface EncryptedEnvelopeV1 {\n version: 1;\n iv: string;\n ciphertext: string;\n authTag: string;\n dataKeyCiphertext: string;\n}\n/** Opaque metadata about a secret row — never includes plaintext. */\nexport interface SecretMetadata {\n secretId: string;\n secretName: string;\n description?: string;\n tags?: string[];\n createdAt: string;\n updatedAt: string;\n rotatedAt?: string;\n}\n/** A single secret row including its encrypted envelope. */\nexport interface SecretEnvelopeResponse extends SecretMetadata {\n envelope: EncryptedEnvelopeV1;\n}\n/** A scope the caller can read or write secrets in. */\nexport interface ScopeInfo {\n scope: SecretScope;\n scopeId: string;\n name?: string;\n}\n/**\n * KMS-issued data key, returned by the secrets service's\n * `/secrets/generate-data-key` KMS proxy endpoint. The plaintext key is\n * returned base64-encoded; callers MUST decode it to a Buffer and zero the\n * Buffer after use — never keep the plaintext as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ASK,cAAA,CAAA,EAAA,MAAA;IAGL,aAAA,CAAA,EAAA,MAAA;IAQ8B,UAAA,CAAA,EAAA,MAAA;;EAAD,gBAAA,CAAA,IAAA,EAAA;;;mBA7IhB;MACb;;;;uBAOuB;;;;;;;;;;;QAM8D;;;;;;;;;;;;;MAarF;;;;;;;;;WAgCK;;;MAGL,QAAQ;;;;;;;WAaH;;;;MAIL;;;;;WASK;;;;cAIG;;;MAGR;;;;;WAaK;;;MAGL,QAAQ;;;WAQH;;MAEL,QAAQ;;;WASH;;;MAGL;;sBAQsB,QAAQ"}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  //#region ../../packages-internal/types/dist/integration.d.ts
2
2
 
3
- /** Controls where an integration appears: public (everyone), dev (non-prod only), hidden (nowhere) */
3
+ /** Controls where an integration appears: public (everyone), hidden (nowhere) */
4
4
  declare const IntegrationVisibility: {
5
5
  readonly Public: "public";
6
- readonly Dev: "dev";
7
6
  readonly Hidden: "hidden";
8
7
  };
9
8
  type IntegrationVisibility = (typeof IntegrationVisibility)[keyof typeof IntegrationVisibility];
@@ -58,6 +57,7 @@ interface IntegrationConfigSchemaField {
58
57
  }[];
59
58
  oauth_provider?: string;
60
59
  editable?: string;
60
+ hidden?: boolean;
61
61
  }
62
62
  interface IntegrationConfigResult {
63
63
  integrationId: string;
@@ -95,6 +95,61 @@ interface RegistryEntry {
95
95
  }
96
96
  //# sourceMappingURL=integration.d.ts.map
97
97
  //#endregion
98
+ //#region ../../packages-internal/types/dist/secrets.d.ts
99
+ /**
100
+ * Secrets types — shared between services/secrets, @alfe.ai/agent-api-client,
101
+ * the openclaw-secrets plugin, and dashboard clients.
102
+ *
103
+ * Server-side crypto and KMS glue live in @alfe/secret-store (Node/AWS-only);
104
+ * this module is a pure, dependency-free shape contract safe for every
105
+ * environment the agent-api-client ships to.
106
+ */
107
+ /** Scope levels at which a secret can be owned. */
108
+ type SecretScope = "org" | "team" | "project" | "agent";
109
+ /**
110
+ * v1 encrypted envelope as persisted by services/secrets and exchanged with
111
+ * agents. Values are AES-256-GCM ciphertext; iv/authTag/ciphertext/dataKeyCiphertext
112
+ * are all base64-encoded.
113
+ */
114
+ interface EncryptedEnvelopeV1 {
115
+ version: 1;
116
+ iv: string;
117
+ ciphertext: string;
118
+ authTag: string;
119
+ dataKeyCiphertext: string;
120
+ }
121
+ /** Opaque metadata about a secret row — never includes plaintext. */
122
+ interface SecretMetadata {
123
+ secretId: string;
124
+ secretName: string;
125
+ description?: string;
126
+ tags?: string[];
127
+ createdAt: string;
128
+ updatedAt: string;
129
+ rotatedAt?: string;
130
+ }
131
+ /** A single secret row including its encrypted envelope. */
132
+ interface SecretEnvelopeResponse extends SecretMetadata {
133
+ envelope: EncryptedEnvelopeV1;
134
+ }
135
+ /** A scope the caller can read or write secrets in. */
136
+ interface ScopeInfo {
137
+ scope: SecretScope;
138
+ scopeId: string;
139
+ name?: string;
140
+ }
141
+ /**
142
+ * KMS-issued data key, returned by the secrets service's
143
+ * `/secrets/generate-data-key` KMS proxy endpoint. The plaintext key is
144
+ * returned base64-encoded; callers MUST decode it to a Buffer and zero the
145
+ * Buffer after use — never keep the plaintext as a JS string.
146
+ */
147
+ interface GeneratedDataKey {
148
+ plaintextKey: string;
149
+ dataKeyCiphertext: string;
150
+ }
151
+ //# sourceMappingURL=secrets.d.ts.map
152
+ //#endregion
98
153
  //#region src/index.d.ts
99
154
  interface AgentApiClientConfig {
100
155
  apiKey: string;
@@ -117,10 +172,115 @@ declare class AgentApiClient {
117
172
  integrations: RegistryEntry[];
118
173
  }>;
119
174
  getGoogleCredentials(): Promise<{
175
+ accounts?: {
176
+ email: string;
177
+ refreshToken: string;
178
+ clientId: string;
179
+ clientSecret: string;
180
+ enabledServices?: string[];
181
+ isDefault: boolean;
182
+ displayName?: string;
183
+ }[];
120
184
  email: string;
121
185
  refreshToken: string;
122
186
  clientId: string;
123
187
  clientSecret: string;
188
+ projectId: string;
189
+ enabledServices?: string[];
190
+ }>;
191
+ disconnectGoogleAccount(email: string): Promise<{
192
+ accounts: {
193
+ email: string;
194
+ displayName?: string;
195
+ isDefault: boolean;
196
+ }[];
197
+ }>;
198
+ setDefaultGoogleAccount(email: string): Promise<{
199
+ accounts: {
200
+ email: string;
201
+ displayName?: string;
202
+ isDefault: boolean;
203
+ }[];
204
+ }>;
205
+ getGithubCredentials(): Promise<{
206
+ login: string;
207
+ accessToken: string;
208
+ }>;
209
+ getXeroCredentials(): Promise<{
210
+ accessToken: string;
211
+ accessTokenExpiresAt: string;
212
+ xeroTenantId: string;
213
+ }>;
214
+ refreshXeroToken(): Promise<{
215
+ accessToken: string;
216
+ expiresAt: string;
217
+ }>;
218
+ getNotionCredentials(): Promise<{
219
+ accessToken: string;
220
+ workspaceId: string;
221
+ workspaceName: string;
222
+ }>;
223
+ getAtlassianCredentials(): Promise<{
224
+ accessToken: string;
225
+ refreshToken: string;
226
+ accessTokenExpiresAt: string;
227
+ cloudId: string;
228
+ siteName: string;
229
+ siteUrl: string;
230
+ email: string;
231
+ enabledProducts: string[];
232
+ }>;
233
+ refreshAtlassianToken(): Promise<{
234
+ accessToken: string;
235
+ expiresAt: string;
236
+ }>;
237
+ getMYOBCredentials(): Promise<{
238
+ accessToken: string;
239
+ accessTokenExpiresAt: string;
240
+ myobBusinessId: string;
241
+ clientId: string;
242
+ }>;
243
+ refreshMYOBToken(): Promise<{
244
+ accessToken: string;
245
+ expiresAt: string;
246
+ }>;
247
+ getTeamsCredentials(): Promise<{
248
+ agentId: string;
249
+ tenantId: string;
250
+ azureAppId: string;
251
+ azureBotId: string;
252
+ azureClientSecret: string;
253
+ botDisplayName?: string;
254
+ teamsTenantId?: string;
255
+ serviceUrl?: string;
256
+ }>;
257
+ sendTeamsMessage(data: {
258
+ conversationId: string;
259
+ text?: string;
260
+ adaptiveCard?: Record<string, unknown>;
261
+ }): Promise<{
262
+ ok: boolean;
263
+ activityId: string;
264
+ }>;
265
+ listTeamsChannels(): Promise<{
266
+ channels: {
267
+ id: string;
268
+ name: string;
269
+ description?: string;
270
+ }[];
271
+ }>;
272
+ presignAttachments(files: {
273
+ filename: string;
274
+ mimeType: string;
275
+ size: number;
276
+ }[]): Promise<{
277
+ attachments: {
278
+ id: string;
279
+ uploadUrl: string;
280
+ downloadUrl: string;
281
+ s3Key: string;
282
+ expiresAt: string;
283
+ }[];
124
284
  }>;
125
285
  recordActivity(data: {
126
286
  userId?: string;
@@ -129,9 +289,62 @@ declare class AgentApiClient {
129
289
  }): Promise<{
130
290
  recorded: boolean;
131
291
  }>;
292
+ /**
293
+ * Mint a fresh AES-256 data key for a new secret or rotation. The encryption
294
+ * context is rebuilt server-side from `auth.tenantId` + the body fields; the
295
+ * agent cannot forge context for a scope it doesn't own.
296
+ */
297
+ generateSecretDataKey(args: {
298
+ scope: SecretScope;
299
+ scopeId: string;
300
+ secretId: string;
301
+ }): Promise<GeneratedDataKey>;
302
+ /**
303
+ * Unwrap a wrapped data key so the agent can decrypt the envelope locally.
304
+ * KMS Decrypt will fail with `InvalidCiphertextException` if the envelope
305
+ * was tampered with in a way that changes `{ tenantId, scope, scopeId, secretId }`.
306
+ */
307
+ decryptSecretDataKey(args: {
308
+ scope: SecretScope;
309
+ scopeId: string;
310
+ secretId: string;
311
+ dataKeyCiphertext: string;
312
+ }): Promise<{
313
+ plaintextKey: string;
314
+ }>;
315
+ /** Upload a pre-encrypted envelope for a secret. */
316
+ putSecretEnvelope(args: {
317
+ scope: SecretScope;
318
+ scopeId: string;
319
+ secretId: string;
320
+ secretName: string;
321
+ envelope: EncryptedEnvelopeV1;
322
+ description?: string;
323
+ tags?: string[];
324
+ }): Promise<{
325
+ secretId: string;
326
+ }>;
327
+ /** Fetch the encrypted envelope for a single secret. */
328
+ getSecretEnvelope(args: {
329
+ scope: SecretScope;
330
+ scopeId: string;
331
+ secretId: string;
332
+ }): Promise<SecretEnvelopeResponse>;
333
+ /** List metadata (never envelopes) for secrets in a scope. */
334
+ listSecrets(args: {
335
+ scope: SecretScope;
336
+ scopeId: string;
337
+ }): Promise<SecretMetadata[]>;
338
+ /** Delete a secret. */
339
+ deleteSecret(args: {
340
+ scope: SecretScope;
341
+ scopeId: string;
342
+ secretId: string;
343
+ }): Promise<void>;
344
+ /** Enumerate scopes (org/team/project/agent) this agent can access. */
345
+ listSecretScopes(): Promise<ScopeInfo[]>;
132
346
  }
133
347
  //# sourceMappingURL=index.d.ts.map
134
-
135
348
  //#endregion
136
- export { AgentApiClient, AgentApiClientConfig, type IntegrationConfigResult, type IntegrationConfigSchemaField, type IntegrationInstall, type RegistryEntry };
349
+ export { AgentApiClient, AgentApiClientConfig, type EncryptedEnvelopeV1, type GeneratedDataKey, type IntegrationConfigResult, type IntegrationConfigSchemaField, type IntegrationInstall, type RegistryEntry, type ScopeInfo, type SecretEnvelopeResponse, type SecretMetadata, type SecretScope };
137
350
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["DEFAULT_INTEGRATIONS","IntegrationVisibility","INTEGRATION_VISIBILITIES","IntegrationScope","INTEGRATION_SCOPES","IntegrationDesiredStatus","INTEGRATION_DESIRED_STATUSES","IntegrationActualStatus","INTEGRATION_ACTUAL_STATUSES","IntegrationInstall","Record","AgentIntegration","OrgIntegration","IntegrationConfigSchemaField","IntegrationConfigResult","RegistryEntry"],"sources":["../../../packages-internal/types/dist/integration.d.ts","../src/index.ts"],"sourcesContent":["/** Integrations auto-installed for ALL agents regardless of hosting type. Cannot be removed. */\nexport declare const DEFAULT_INTEGRATIONS: readonly string[];\n/** Controls where an integration appears: public (everyone), dev (non-prod only), hidden (nowhere) */\nexport declare const IntegrationVisibility: {\n readonly Public: \"public\";\n readonly Dev: \"dev\";\n readonly Hidden: \"hidden\";\n};\nexport type IntegrationVisibility = (typeof IntegrationVisibility)[keyof typeof IntegrationVisibility];\nexport declare const INTEGRATION_VISIBILITIES: readonly [\"dev\" | \"public\" | \"hidden\", ...(\"dev\" | \"public\" | \"hidden\")[]];\n/** Scope at which an integration is installed */\nexport declare const IntegrationScope: {\n readonly Org: \"org\";\n readonly Team: \"team\";\n readonly Project: \"project\";\n readonly Agent: \"agent\";\n};\nexport type IntegrationScope = (typeof IntegrationScope)[keyof typeof IntegrationScope];\nexport declare const INTEGRATION_SCOPES: readonly [\"org\" | \"team\" | \"project\" | \"agent\", ...(\"org\" | \"team\" | \"project\" | \"agent\")[]];\nexport 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 IntegrationInstall {\n scope: IntegrationScope;\n scopeId: 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}\n/** @deprecated Use IntegrationInstall instead */\nexport type AgentIntegration = IntegrationInstall;\n/** Org-scoped integration install */\nexport type OrgIntegration = IntegrationInstall;\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\" | \"usage\";\n price?: number;\n currency?: string;\n interval?: \"month\" | \"year\";\n description?: string;\n };\n features?: string[];\n preview_images?: string[];\n config_schema?: IntegrationConfigSchemaField[];\n supported_agents?: string[];\n /** Scopes where this integration can be installed */\n supported_scopes?: IntegrationScope[];\n /** Visibility status — controls where integration appears */\n visibility?: IntegrationVisibility;\n}\n//# sourceMappingURL=integration.d.ts.map"],"mappings":";;AAQA;AAAiC,cALZC,qBAKY,EAAA;WAAWA,MAAAA,EAAAA,QAAAA;WAAoCA,GAAAA,EAAAA,KAAAA;EAAqB,SAAA,MAAA,EAAA,QAAA;AAGrG,CAAA;AAMYE,KATAF,qBAAAA,GASgB,CAAA,OATgBA,qBAShB,CAAA,CAAA,MAAA,OAToDA,qBASpD,CAAA;;AAA0CE,cANjDA,gBAMiDA,EAAAA;EAAgB,SAAA,GAAA,EAAA,KAAA;EAEjEE,SAAAA,IAAAA,EAAAA,MAAAA;EAITA,SAAAA,OAAAA,EAAAA,SAAwB;EAAA,SAAA,KAAA,EAAA,OAAA;;AAAkDA,KAN1EF,gBAAAA,GAM0EE,CAAAA,OAN/CF,gBAM+CE,CAAAA,CAAAA,MAAAA,OANhBF,gBAMgBE,CAAAA;AAEjEE,cANAF,wBAapB,EAAA;EACWE,SAAAA,MAAAA,EAAAA,QAAAA;EAAuB,SAAA,OAAA,EAAA,SAAA;;AAAiDA,KAVxEF,wBAAAA,GAUwEE,CAAAA,OAVrCF,wBAUqCE,CAAAA,CAAAA,MAAAA,OAVEF,wBAUFE,CAAAA;AAEnEE,cAVIF,uBAUc,EAAA;EAAA,SAAA,UAAA,EAAA,YAAA;WACxBJ,MAAAA,EAAAA,QAAAA;WAIQE,KAA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BAAAA,CAAAA,aAOpB,EAAA,MAAA,CAAA,ECoBoD,ODpBpD,CCoB4D,uBDpB5D,CAAA;EACWA,uBAAAA,CAAAA,aAAuB,EAAA,MAAA,EAAA,MAAA,EC2BvB,MD3BuB,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA,EC4B9B,OD5B8B,CAAA,IAAA,CAAA;EAAA,kBAAA,CAAA,aAAA,EAAA,MAAA,EAAA,OAAwE,CAAxE,EAAA;IAAWA,OAAAA,CAAAA,EAAAA,MAAAA;IAAsCA,MAAAA,CAAAA,ECwCzC,MDxCyCA,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;EAAuB,CAAA,CAAA,ECyCtG,ODzCsG,CCyC9F,kBDzC8F,CAAA;EAE1FE,iBAAAA,CAAAA,aAAkB,EAAA,MAAA,CAAA,ECkDe,ODlDf,CCkDuB,kBDlDvB,CAAA;EAAA,WAAA,CAAA,CAAA,ECyDZ,ODzDY,CAAA;IACxBN,YAAAA,ECwDoC,aDxDpCA,EAAAA;;sBAKOI,CAAAA,CAAAA,ECuDc,ODvDdA,CAAAA;IAENG,KAAAA,EAAAA,MAAAA;IAAM,YAAA,EAAA,MAAA;IASDG,QAAAA,EAAAA,MAAAA;IAeAC,YAAAA,EAAAA,MAAAA;EAAuB,CAAA,CAAA;gBAE5BJ,CAAAA,IAAAA,EAAAA;IACMG,MAAAA,CAAAA,EAAAA,MAAAA;IAA4B,OAAA,EAAA,MAAA;IAE7BE,IAAAA,EAAAA,MAAa,GAAA,WAAA;EAAA,CAAA,CAAA,ECqCxB,ODrCwB,CAAA;IAsBVF,QAAAA,EAAAA,OAAAA"}
1
+ {"version":3,"file":"index.d.ts","names":["DEFAULT_INTEGRATIONS","IntegrationVisibility","INTEGRATION_VISIBILITIES","IntegrationScope","INTEGRATION_SCOPES","IntegrationDesiredStatus","INTEGRATION_DESIRED_STATUSES","IntegrationActualStatus","INTEGRATION_ACTUAL_STATUSES","IntegrationInstall","Record","AgentIntegration","OrgIntegration","IntegrationConfigSchemaField","IntegrationConfigResult","RegistryEntry","SecretScope","EncryptedEnvelopeV1","SecretMetadata","SecretEnvelopeResponse","ScopeInfo","GeneratedDataKey"],"sources":["../../../packages-internal/types/dist/integration.d.ts","../../../packages-internal/types/dist/secrets.d.ts","../src/index.ts"],"sourcesContent":["/** Integrations auto-installed for ALL agents regardless of hosting type. Cannot be removed. */\nexport declare const DEFAULT_INTEGRATIONS: readonly string[];\n/** Controls where an integration appears: public (everyone), hidden (nowhere) */\nexport declare const IntegrationVisibility: {\n readonly Public: \"public\";\n readonly Hidden: \"hidden\";\n};\nexport type IntegrationVisibility = (typeof IntegrationVisibility)[keyof typeof IntegrationVisibility];\nexport declare const INTEGRATION_VISIBILITIES: readonly [\"public\" | \"hidden\", ...(\"public\" | \"hidden\")[]];\n/** Scope at which an integration is installed */\nexport declare const IntegrationScope: {\n readonly Org: \"org\";\n readonly Team: \"team\";\n readonly Project: \"project\";\n readonly Agent: \"agent\";\n};\nexport type IntegrationScope = (typeof IntegrationScope)[keyof typeof IntegrationScope];\nexport declare const INTEGRATION_SCOPES: readonly [\"org\" | \"team\" | \"project\" | \"agent\", ...(\"org\" | \"team\" | \"project\" | \"agent\")[]];\nexport 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 IntegrationInstall {\n scope: IntegrationScope;\n scopeId: 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}\n/** @deprecated Use IntegrationInstall instead */\nexport type AgentIntegration = IntegrationInstall;\n/** Org-scoped integration install */\nexport type OrgIntegration = IntegrationInstall;\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 hidden?: boolean;\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\" | \"usage\";\n price?: number;\n currency?: string;\n interval?: \"month\" | \"year\";\n description?: string;\n };\n features?: string[];\n preview_images?: string[];\n config_schema?: IntegrationConfigSchemaField[];\n supported_agents?: string[];\n /** Scopes where this integration can be installed */\n supported_scopes?: IntegrationScope[];\n /** Visibility status — controls where integration appears */\n visibility?: IntegrationVisibility;\n}\n//# sourceMappingURL=integration.d.ts.map","/**\n * Secrets types — shared between services/secrets, @alfe.ai/agent-api-client,\n * the openclaw-secrets plugin, and dashboard clients.\n *\n * Server-side crypto and KMS glue live in @alfe/secret-store (Node/AWS-only);\n * this module is a pure, dependency-free shape contract safe for every\n * environment the agent-api-client ships to.\n */\n/** Scope levels at which a secret can be owned. */\nexport type SecretScope = \"org\" | \"team\" | \"project\" | \"agent\";\n/**\n * v1 encrypted envelope as persisted by services/secrets and exchanged with\n * agents. Values are AES-256-GCM ciphertext; iv/authTag/ciphertext/dataKeyCiphertext\n * are all base64-encoded.\n */\nexport interface EncryptedEnvelopeV1 {\n version: 1;\n iv: string;\n ciphertext: string;\n authTag: string;\n dataKeyCiphertext: string;\n}\n/** Opaque metadata about a secret row — never includes plaintext. */\nexport interface SecretMetadata {\n secretId: string;\n secretName: string;\n description?: string;\n tags?: string[];\n createdAt: string;\n updatedAt: string;\n rotatedAt?: string;\n}\n/** A single secret row including its encrypted envelope. */\nexport interface SecretEnvelopeResponse extends SecretMetadata {\n envelope: EncryptedEnvelopeV1;\n}\n/** A scope the caller can read or write secrets in. */\nexport interface ScopeInfo {\n scope: SecretScope;\n scopeId: string;\n name?: string;\n}\n/**\n * KMS-issued data key, returned by the secrets service's\n * `/secrets/generate-data-key` KMS proxy endpoint. The plaintext key is\n * returned base64-encoded; callers MUST decode it to a Buffer and zero the\n * Buffer after use — never keep the plaintext as a JS string.\n */\nexport interface GeneratedDataKey {\n plaintextKey: string;\n dataKeyCiphertext: string;\n}\n//# sourceMappingURL=secrets.d.ts.map"],"mappings":";;AAOA;AAAiC,cAJZC,qBAIY,EAAA;WAAWA,MAAAA,EAAAA,QAAAA;WAAoCA,MAAAA,EAAAA,QAAAA;CAAqB;AAGhFE,KAHTF,qBAAAA,GAQX,CAAA,OAR2CA,qBAQ3C,CAAA,CAAA,MAAA,OAR+EA,qBAQ/E,CAAA;;AACsCE,cANlBA,gBAMkBA,EAAAA;WAA+BA,GAAAA,EAAAA,KAAAA;EAAgB,SAAA,IAAA,EAAA,MAAA;EAEjEE,SAAAA,OAAAA,EAAAA,SAGpB;EACWA,SAAAA,KAAAA,EAAAA,OAAAA;CAAwB;AAAWA,KANnCF,gBAAAA,GAMmCE,CAAAA,OANRF,gBAMQE,CAAAA,CAAAA,MAAAA,OANuBF,gBAMvBE,CAAAA;AAA+D,cAJzFA,wBAIyF,EAAA;EAEzFE,SAAAA,MAAAA,EAAAA,QAAAA;EAQTA,SAAAA,OAAA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AA;IAQG,OAAA,EAAA,MAAA;IAaF,KAAA,EAAA,MAAA;IAOH,eAAA,EAAA,MAAA,EAAA;;uBAgBC,CAAA,CAAA,EAvBE,OAuBF,CAAA;IAgBZ,WAAA,EAAA,MAAA;IACb,SAAA,EAAA,MAAA;;oBAaqF,CAAA,CAAA,EA9C7D,OA8C6D,CAAA;IAarF,WAAA,EAAA,MAAA;IAgCK,oBAAA,EAAA,MAAA;IAGG,cAAA,EAAA,MAAA;IAAR,QAAA,EAAA,MAAA;;kBAiBA,CAAA,CAAA,EAtGsB,OAsGtB,CAAA;IASK,WAAA,EAAA,MAAA;IAIG,SAAA,EAAA,MAAA;;qBAgBH,CAAA,CAAA,EA5HoB,OA4HpB,CAAA;IAGG,OAAA,EAAA,MAAA;IAAR,QAAA,EAAA,MAAA;IAQK,UAAA,EAAA,MAAA;IAEG,UAAA,EAAA,MAAA;IAAR,iBAAA,EAAA,MAAA;IASK,cAAA,CAAA,EAAA,MAAA;IAGL,aAAA,CAAA,EAAA,MAAA;IAQ8B,UAAA,CAAA,EAAA,MAAA;;EAAD,gBAAA,CAAA,IAAA,EAAA;;;mBA7IhB;MACb;;;;uBAOuB;;;;;;;;;;;QAM8D;;;;;;;;;;;;;MAarF;;;;;;;;;WAgCK;;;MAGL,QAAQ;;;;;;;WAaH;;;;MAIL;;;;;WASK;;;;cAIG;;;MAGR;;;;;WAaK;;;MAGL,QAAQ;;;WAQH;;MAEL,QAAQ;;;WASH;;;MAGL;;sBAQsB,QAAQ"}
package/dist/index.js CHANGED
@@ -16,25 +16,25 @@ var AgentApiClient = class {
16
16
  headers
17
17
  });
18
18
  if (!res.ok) {
19
- const body = await res.text();
20
- throw new Error(`Agent API error ${String(res.status)}: ${body}`);
19
+ await res.text();
20
+ throw new Error(`Agent API request failed (${String(res.status)})`);
21
21
  }
22
22
  return (await res.json()).data;
23
23
  }
24
24
  async listIntegrations() {
25
- return this.request("/agents/integrations");
25
+ return this.request("/agent/integrations");
26
26
  }
27
27
  async getIntegrationConfig(integrationId) {
28
- return this.request(`/agents/integrations/${encodeURIComponent(integrationId)}/config`);
28
+ return this.request(`/agent/integrations/${encodeURIComponent(integrationId)}/config`);
29
29
  }
30
30
  async updateIntegrationConfig(integrationId, config) {
31
- await this.request(`/agents/integrations/${encodeURIComponent(integrationId)}`, {
31
+ await this.request(`/agent/integrations/${encodeURIComponent(integrationId)}`, {
32
32
  method: "PATCH",
33
33
  body: JSON.stringify({ config })
34
34
  });
35
35
  }
36
36
  async installIntegration(integrationId, options) {
37
- return this.request("/agents/integrations", {
37
+ return this.request("/agent/integrations", {
38
38
  method: "POST",
39
39
  body: JSON.stringify({
40
40
  integrationId,
@@ -44,20 +44,114 @@ var AgentApiClient = class {
44
44
  });
45
45
  }
46
46
  async removeIntegration(integrationId) {
47
- return this.request(`/agents/integrations/${encodeURIComponent(integrationId)}`, { method: "DELETE" });
47
+ return this.request(`/agent/integrations/${encodeURIComponent(integrationId)}`, { method: "DELETE" });
48
48
  }
49
49
  async getRegistry() {
50
50
  return this.request("/integrations/registry");
51
51
  }
52
52
  async getGoogleCredentials() {
53
- return this.request("/agents/google/credentials");
53
+ return this.request("/agent/google/credentials");
54
+ }
55
+ async disconnectGoogleAccount(email) {
56
+ return this.request(`/agent/google/accounts/${encodeURIComponent(email)}`, { method: "DELETE" });
57
+ }
58
+ async setDefaultGoogleAccount(email) {
59
+ return this.request(`/agent/google/accounts/${encodeURIComponent(email)}/default`, { method: "PUT" });
60
+ }
61
+ async getGithubCredentials() {
62
+ return this.request("/agent/github/credentials");
63
+ }
64
+ async getXeroCredentials() {
65
+ return this.request("/agent/xero/credentials");
66
+ }
67
+ async refreshXeroToken() {
68
+ return this.request("/agent/xero/token", { method: "POST" });
69
+ }
70
+ async getNotionCredentials() {
71
+ return this.request("/agent/notion/credentials");
72
+ }
73
+ async getAtlassianCredentials() {
74
+ return this.request("/agent/atlassian/credentials");
75
+ }
76
+ async refreshAtlassianToken() {
77
+ return this.request("/agent/atlassian/token", { method: "POST" });
78
+ }
79
+ async getMYOBCredentials() {
80
+ return this.request("/agent/myob/credentials");
81
+ }
82
+ async refreshMYOBToken() {
83
+ return this.request("/agent/myob/token", { method: "POST" });
84
+ }
85
+ async getTeamsCredentials() {
86
+ return this.request("/agent/microsoft/credentials");
87
+ }
88
+ async sendTeamsMessage(data) {
89
+ return this.request("/agent/microsoft/send", {
90
+ method: "POST",
91
+ body: JSON.stringify(data)
92
+ });
93
+ }
94
+ async listTeamsChannels() {
95
+ return this.request("/agent/microsoft/channels");
96
+ }
97
+ async presignAttachments(files) {
98
+ return this.request("/agent/chat/attachments/presign", {
99
+ method: "POST",
100
+ body: JSON.stringify({ files })
101
+ });
54
102
  }
55
103
  async recordActivity(data) {
56
- return this.request("/agents/activity", {
104
+ return this.request("/agent/activity", {
57
105
  method: "POST",
58
106
  body: JSON.stringify(data)
59
107
  });
60
108
  }
109
+ /**
110
+ * Mint a fresh AES-256 data key for a new secret or rotation. The encryption
111
+ * context is rebuilt server-side from `auth.tenantId` + the body fields; the
112
+ * agent cannot forge context for a scope it doesn't own.
113
+ */
114
+ async generateSecretDataKey(args) {
115
+ return this.request("/agent/secrets/generate-data-key", {
116
+ method: "POST",
117
+ body: JSON.stringify(args)
118
+ });
119
+ }
120
+ /**
121
+ * Unwrap a wrapped data key so the agent can decrypt the envelope locally.
122
+ * KMS Decrypt will fail with `InvalidCiphertextException` if the envelope
123
+ * was tampered with in a way that changes `{ tenantId, scope, scopeId, secretId }`.
124
+ */
125
+ async decryptSecretDataKey(args) {
126
+ return this.request("/agent/secrets/decrypt-data-key", {
127
+ method: "POST",
128
+ body: JSON.stringify(args)
129
+ });
130
+ }
131
+ /** Upload a pre-encrypted envelope for a secret. */
132
+ async putSecretEnvelope(args) {
133
+ const { scope, scopeId, secretId, ...body } = args;
134
+ return this.request(`/agent/secrets/${encodeURIComponent(scope)}/${encodeURIComponent(scopeId)}/${encodeURIComponent(secretId)}`, {
135
+ method: "PUT",
136
+ body: JSON.stringify(body)
137
+ });
138
+ }
139
+ /** Fetch the encrypted envelope for a single secret. */
140
+ async getSecretEnvelope(args) {
141
+ return this.request(`/agent/secrets/${encodeURIComponent(args.scope)}/${encodeURIComponent(args.scopeId)}/${encodeURIComponent(args.secretId)}`);
142
+ }
143
+ /** List metadata (never envelopes) for secrets in a scope. */
144
+ async listSecrets(args) {
145
+ return (await this.request(`/agent/secrets/${encodeURIComponent(args.scope)}/${encodeURIComponent(args.scopeId)}`)).secrets;
146
+ }
147
+ /** Delete a secret. */
148
+ async deleteSecret(args) {
149
+ await this.request(`/agent/secrets/${encodeURIComponent(args.scope)}/${encodeURIComponent(args.scopeId)}/${encodeURIComponent(args.secretId)}`, { method: "DELETE" });
150
+ }
151
+ /** Enumerate scopes (org/team/project/agent) this agent can access. */
152
+ async listSecretScopes() {
153
+ return (await this.request("/agent/secrets/scopes")).scopes;
154
+ }
61
155
  };
62
156
  //#endregion
63
157
  export { AgentApiClient };
package/dist/index.js.map CHANGED
@@ -1 +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 IntegrationInstall,\n IntegrationConfigResult,\n RegistryEntry,\n IntegrationConfigSchemaField,\n} from \"@alfe/types\";\n\nimport type { IntegrationInstall, 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<IntegrationInstall[]> {\n return this.request<IntegrationInstall[]>(\"/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<IntegrationInstall> {\n return this.request<IntegrationInstall>(\"/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<IntegrationInstall> {\n return this.request<IntegrationInstall>(\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 async getGoogleCredentials(): Promise<{\n email: string;\n refreshToken: string;\n clientId: string;\n clientSecret: string;\n }> {\n return this.request(\"/agents/google/credentials\");\n }\n\n async recordActivity(data: {\n userId?: string;\n channel: string;\n role: \"user\" | \"assistant\";\n }): Promise<{ recorded: boolean }> {\n return this.request<{ recorded: boolean }>(\"/agents/activity\", {\n method: \"POST\",\n body: JSON.stringify(data),\n });\n }\n}\n"],"mappings":";AAsBA,IAAa,iBAAb,MAA4B;CAC1B;CACA;CAEA,YAAY,QAA8B;AACxC,OAAK,SAAS,O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K,UAAU,KAAK;GAC3B,CAAC"}
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 /agent/ 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 IntegrationInstall,\n IntegrationConfigResult,\n RegistryEntry,\n IntegrationConfigSchemaField,\n SecretScope,\n EncryptedEnvelopeV1,\n SecretMetadata,\n SecretEnvelopeResponse,\n ScopeInfo,\n GeneratedDataKey,\n} from \"@alfe/types\";\n\nimport type {\n IntegrationInstall,\n IntegrationConfigResult,\n RegistryEntry,\n SecretScope,\n EncryptedEnvelopeV1,\n SecretMetadata,\n SecretEnvelopeResponse,\n ScopeInfo,\n GeneratedDataKey,\n} 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 await res.text(); // drain body\n throw new Error(`Agent API request failed (${String(res.status)})`);\n }\n\n const body = (await res.json()) as { data: T };\n return body.data;\n }\n\n async listIntegrations(): Promise<IntegrationInstall[]> {\n return this.request<IntegrationInstall[]>(\"/agent/integrations\");\n }\n\n async getIntegrationConfig(integrationId: string): Promise<IntegrationConfigResult> {\n return this.request<IntegrationConfigResult>(\n `/agent/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 `/agent/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<IntegrationInstall> {\n return this.request<IntegrationInstall>(\"/agent/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<IntegrationInstall> {\n return this.request<IntegrationInstall>(\n `/agent/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 async getGoogleCredentials(): Promise<{\n accounts?: {\n email: string;\n refreshToken: string;\n clientId: string;\n clientSecret: string;\n enabledServices?: string[];\n isDefault: boolean;\n displayName?: string;\n }[];\n email: string;\n refreshToken: string;\n clientId: string;\n clientSecret: string;\n projectId: string;\n enabledServices?: string[];\n }> {\n return this.request(\"/agent/google/credentials\");\n }\n\n async disconnectGoogleAccount(email: string): Promise<{\n accounts: { email: string; displayName?: string; isDefault: boolean }[];\n }> {\n return this.request(`/agent/google/accounts/${encodeURIComponent(email)}`, {\n method: \"DELETE\",\n });\n }\n\n async setDefaultGoogleAccount(email: string): Promise<{\n accounts: { email: string; displayName?: string; isDefault: boolean }[];\n }> {\n return this.request(`/agent/google/accounts/${encodeURIComponent(email)}/default`, {\n method: \"PUT\",\n });\n }\n\n async getGithubCredentials(): Promise<{\n login: string;\n accessToken: string;\n }> {\n return this.request(\"/agent/github/credentials\");\n }\n\n async getXeroCredentials(): Promise<{\n accessToken: string;\n accessTokenExpiresAt: string;\n xeroTenantId: string;\n }> {\n return this.request(\"/agent/xero/credentials\");\n }\n\n async refreshXeroToken(): Promise<{\n accessToken: string;\n expiresAt: string;\n }> {\n return this.request(\"/agent/xero/token\", { method: \"POST\" });\n }\n\n async getNotionCredentials(): Promise<{\n accessToken: string;\n workspaceId: string;\n workspaceName: string;\n }> {\n return this.request(\"/agent/notion/credentials\");\n }\n\n async getAtlassianCredentials(): Promise<{\n accessToken: string;\n refreshToken: string;\n accessTokenExpiresAt: string;\n cloudId: string;\n siteName: string;\n siteUrl: string;\n email: string;\n enabledProducts: string[];\n }> {\n return this.request(\"/agent/atlassian/credentials\");\n }\n\n async refreshAtlassianToken(): Promise<{\n accessToken: string;\n expiresAt: string;\n }> {\n return this.request(\"/agent/atlassian/token\", { method: \"POST\" });\n }\n\n async getMYOBCredentials(): Promise<{\n accessToken: string;\n accessTokenExpiresAt: string;\n myobBusinessId: string;\n clientId: string;\n }> {\n return this.request(\"/agent/myob/credentials\");\n }\n\n async refreshMYOBToken(): Promise<{\n accessToken: string;\n expiresAt: string;\n }> {\n return this.request(\"/agent/myob/token\", { method: \"POST\" });\n }\n\n async getTeamsCredentials(): Promise<{\n agentId: string;\n tenantId: string;\n azureAppId: string;\n azureBotId: string;\n azureClientSecret: string;\n botDisplayName?: string;\n teamsTenantId?: string;\n serviceUrl?: string;\n }> {\n return this.request(\"/agent/microsoft/credentials\");\n }\n\n async sendTeamsMessage(data: {\n conversationId: string;\n text?: string;\n adaptiveCard?: Record<string, unknown>;\n }): Promise<{ ok: boolean; activityId: string }> {\n return this.request(\"/agent/microsoft/send\", {\n method: \"POST\",\n body: JSON.stringify(data),\n });\n }\n\n async listTeamsChannels(): Promise<{\n channels: { id: string; name: string; description?: string }[];\n }> {\n return this.request(\"/agent/microsoft/channels\");\n }\n\n async presignAttachments(files: { filename: string; mimeType: string; size: number }[]): Promise<{\n attachments: { id: string; uploadUrl: string; downloadUrl: string; s3Key: string; expiresAt: string }[];\n }> {\n return this.request(\"/agent/chat/attachments/presign\", {\n method: \"POST\",\n body: JSON.stringify({ files }),\n });\n }\n\n async recordActivity(data: {\n userId?: string;\n channel: string;\n role: \"user\" | \"assistant\";\n }): Promise<{ recorded: boolean }> {\n return this.request<{ recorded: boolean }>(\"/agent/activity\", {\n method: \"POST\",\n body: JSON.stringify(data),\n });\n }\n\n // ─── Secrets ──────────────────────────────────────────────────\n //\n // Envelope CRUD + KMS proxy for per-scope encrypted secret storage.\n // Agents never hold a KMS master key — these proxy endpoints mint one-shot\n // AES-256 data keys bound (via KMS encryption context) to\n // `{ tenantId, scope, scopeId, secretId }`. The agent performs AES-256-GCM\n // locally; the backend only ever sees opaque envelopes.\n //\n // Routes resolve to the agent API gateway (mapping key `agent`), where\n // services/secrets registers its routes with pathPrefix `/secrets`. With\n // `apiUrl` set to the host root (e.g. `https://api.alfe.ai`), the full URL\n // is `https://api.alfe.ai/agent/secrets/...`. This is the same mapping as\n // `/agent/integrations/...` etc. — do NOT hit `/secrets/...` on the root\n // host: that's the user-auth dashboard gateway, which rejects agent tokens.\n //\n // `plaintextKey` in responses is base64 — callers MUST decode to a Node\n // `Buffer` immediately and zero it after use. NEVER keep plaintext keys\n // as JS strings (strings are immutable and cannot be wiped).\n\n /**\n * Mint a fresh AES-256 data key for a new secret or rotation. The encryption\n * context is rebuilt server-side from `auth.tenantId` + the body fields; the\n * agent cannot forge context for a scope it doesn't own.\n */\n async generateSecretDataKey(args: {\n scope: SecretScope;\n scopeId: string;\n secretId: string;\n }): Promise<GeneratedDataKey> {\n return this.request<GeneratedDataKey>(\"/agent/secrets/generate-data-key\", {\n method: \"POST\",\n body: JSON.stringify(args),\n });\n }\n\n /**\n * Unwrap a wrapped data key so the agent can decrypt the envelope locally.\n * KMS Decrypt will fail with `InvalidCiphertextException` if the envelope\n * was tampered with in a way that changes `{ tenantId, scope, scopeId, secretId }`.\n */\n async decryptSecretDataKey(args: {\n scope: SecretScope;\n scopeId: string;\n secretId: string;\n dataKeyCiphertext: string;\n }): Promise<{ plaintextKey: string }> {\n return this.request<{ plaintextKey: string }>(\"/agent/secrets/decrypt-data-key\", {\n method: \"POST\",\n body: JSON.stringify(args),\n });\n }\n\n /** Upload a pre-encrypted envelope for a secret. */\n async putSecretEnvelope(args: {\n scope: SecretScope;\n scopeId: string;\n secretId: string;\n secretName: string;\n envelope: EncryptedEnvelopeV1;\n description?: string;\n tags?: string[];\n }): Promise<{ secretId: string }> {\n const { scope, scopeId, secretId, ...body } = args;\n return this.request<{ secretId: string }>(\n `/agent/secrets/${encodeURIComponent(scope)}/${encodeURIComponent(scopeId)}/${encodeURIComponent(secretId)}`,\n {\n method: \"PUT\",\n body: JSON.stringify(body),\n },\n );\n }\n\n /** Fetch the encrypted envelope for a single secret. */\n async getSecretEnvelope(args: {\n scope: SecretScope;\n scopeId: string;\n secretId: string;\n }): Promise<SecretEnvelopeResponse> {\n return this.request<SecretEnvelopeResponse>(\n `/agent/secrets/${encodeURIComponent(args.scope)}/${encodeURIComponent(args.scopeId)}/${encodeURIComponent(args.secretId)}`,\n );\n }\n\n /** List metadata (never envelopes) for secrets in a scope. */\n async listSecrets(args: {\n scope: SecretScope;\n scopeId: string;\n }): Promise<SecretMetadata[]> {\n const resp = await this.request<{ secrets: SecretMetadata[] }>(\n `/agent/secrets/${encodeURIComponent(args.scope)}/${encodeURIComponent(args.scopeId)}`,\n );\n return resp.secrets;\n }\n\n /** Delete a secret. */\n async deleteSecret(args: {\n scope: SecretScope;\n scopeId: string;\n secretId: string;\n }): Promise<void> {\n await this.request<unknown>(\n `/agent/secrets/${encodeURIComponent(args.scope)}/${encodeURIComponent(args.scopeId)}/${encodeURIComponent(args.secretId)}`,\n { method: \"DELETE\" },\n );\n }\n\n /** Enumerate scopes (org/team/project/agent) this agent can access. */\n async listSecretScopes(): Promise<ScopeInfo[]> {\n const resp = await this.request<{ scopes: ScopeInfo[] }>(\"/agent/secrets/scopes\");\n return resp.scopes;\n }\n}\n"],"mappings":";AAsCA,IAAa,iBAAb,MAA4B;CAC1B;CACA;CAEA,YAAY,QAA8B;AACxC,OAAK,SAAS,OAAO;AACrB,OAAK,SAAS,OAAO;;CAGvB,MAAc,QAAW,MAAc,SAAmC;EACxE,MAAM,MAAM,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,MAAM,KAAK,UAAU,KAAK;GAC3B,CAAC;;;CAIJ,MAAM,kBAAkB,MAQU;EAChC,MAAM,EAAE,OAAO,SAAS,UAAU,GAAG,SAAS;AAC9C,SAAO,KAAK,QACV,kBAAkB,mBAAmB,MAAM,CAAC,GAAG,mBAAmB,QAAQ,CAAC,GAAG,mBAAmB,SAAS,IAC1G;GACE,QAAQ;GACR,MAAM,KAAK,UAAU,KAAK;GAC3B,CACF;;;CAIH,MAAM,kBAAkB,MAIY;AAClC,SAAO,KAAK,QACV,kBAAkB,mBAAmB,KAAK,MAAM,CAAC,GAAG,mBAAmB,KAAK,QAAQ,CAAC,GAAG,mBAAmB,KAAK,SAAS,GAC1H;;;CAIH,MAAM,YAAY,MAGY;AAI5B,UAHa,MAAM,KAAK,QACtB,kBAAkB,mBAAmB,KAAK,MAAM,CAAC,GAAG,mBAAmB,KAAK,QAAQ,GACrF,EACW;;;CAId,MAAM,aAAa,MAID;AAChB,QAAM,KAAK,QACT,kBAAkB,mBAAmB,KAAK,MAAM,CAAC,GAAG,mBAAmB,KAAK,QAAQ,CAAC,GAAG,mBAAmB,KAAK,SAAS,IACzH,EAAE,QAAQ,UAAU,CACrB;;;CAIH,MAAM,mBAAyC;AAE7C,UADa,MAAM,KAAK,QAAiC,wBAAwB,EACrE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfe.ai/agent-api-client",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Agent self-service API client — agents calling /agents/ endpoints",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",