@alfe.ai/agent-api-client 0.0.13 → 0.1.1
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 +139 -28
- package/dist/index.d.cts +376 -50
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +376 -50
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +139 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/index.ts
|
|
3
|
+
/**
|
|
4
|
+
* Encode each path segment but keep the `/` separators — `encodeURIComponent`
|
|
5
|
+
* would escape the slashes too, breaking greedy proxy routes.
|
|
6
|
+
*/
|
|
7
|
+
function encodeFilePath(filePath) {
|
|
8
|
+
return filePath.split("/").map(encodeURIComponent).join("/");
|
|
9
|
+
}
|
|
3
10
|
var AgentApiClient = class {
|
|
4
11
|
apiKey;
|
|
5
12
|
apiUrl;
|
|
@@ -22,6 +29,57 @@ var AgentApiClient = class {
|
|
|
22
29
|
}
|
|
23
30
|
return (await res.json()).data;
|
|
24
31
|
}
|
|
32
|
+
async syncRegister(args) {
|
|
33
|
+
return this.request("/agent/sync/register", {
|
|
34
|
+
method: "POST",
|
|
35
|
+
body: JSON.stringify(args ?? {})
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async syncGetManifest() {
|
|
39
|
+
return this.request("/agent/sync/manifest");
|
|
40
|
+
}
|
|
41
|
+
async syncPresign(args) {
|
|
42
|
+
return this.request("/agent/sync/presign", {
|
|
43
|
+
method: "POST",
|
|
44
|
+
body: JSON.stringify(args)
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
async syncConfirmUpload(args) {
|
|
48
|
+
return this.request("/agent/sync/confirm", {
|
|
49
|
+
method: "POST",
|
|
50
|
+
body: JSON.stringify(args)
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async syncReconstruct(args) {
|
|
54
|
+
return this.request("/agent/sync/reconstruct", {
|
|
55
|
+
method: "POST",
|
|
56
|
+
body: JSON.stringify(args)
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async syncGetStats() {
|
|
60
|
+
return this.request("/agent/sync/stats");
|
|
61
|
+
}
|
|
62
|
+
async syncListFiles(args) {
|
|
63
|
+
const qs = new URLSearchParams();
|
|
64
|
+
if (args?.prefix) qs.set("prefix", args.prefix);
|
|
65
|
+
const query = qs.toString();
|
|
66
|
+
return this.request(`/agent/sync/files${query ? `?${query}` : ""}`);
|
|
67
|
+
}
|
|
68
|
+
async syncListSessions() {
|
|
69
|
+
return this.request("/agent/sync/sessions");
|
|
70
|
+
}
|
|
71
|
+
async syncGetSession(sessionId) {
|
|
72
|
+
return this.request(`/agent/sync/sessions/${encodeURIComponent(sessionId)}`);
|
|
73
|
+
}
|
|
74
|
+
async syncDeleteFile(filePath) {
|
|
75
|
+
return this.request(`/agent/sync/files/${encodeFilePath(filePath)}`, { method: "DELETE" });
|
|
76
|
+
}
|
|
77
|
+
async sharedListFiles(args) {
|
|
78
|
+
return this.request(`/agent/org/files/${encodeURIComponent(args.scope)}/${encodeURIComponent(args.scopeId)}`);
|
|
79
|
+
}
|
|
80
|
+
async sharedDownloadUrl(args) {
|
|
81
|
+
return this.request(`/agent/org/files/${encodeURIComponent(args.scope)}/${encodeURIComponent(args.scopeId)}/download/${encodeFilePath(args.filePath)}`);
|
|
82
|
+
}
|
|
25
83
|
async listIntegrations() {
|
|
26
84
|
return this.request("/agent/integrations");
|
|
27
85
|
}
|
|
@@ -119,9 +177,12 @@ var AgentApiClient = class {
|
|
|
119
177
|
});
|
|
120
178
|
}
|
|
121
179
|
/**
|
|
122
|
-
* Mint a fresh AES-256 data key for a
|
|
123
|
-
* context is rebuilt server-side from `auth.tenantId` + the body
|
|
124
|
-
* agent cannot forge context for a scope
|
|
180
|
+
* Mint a fresh AES-256 data key for a specific (secret, field) pair. The
|
|
181
|
+
* encryption context is rebuilt server-side from `auth.tenantId` + the body
|
|
182
|
+
* fields including `fieldKey`; the agent cannot forge context for a scope
|
|
183
|
+
* or field it doesn't own. Legacy single-envelope secrets are migrated to
|
|
184
|
+
* `field#value` rows by the data migration, so call with `fieldKey: "value"`
|
|
185
|
+
* to reach them.
|
|
125
186
|
*/
|
|
126
187
|
async generateSecretDataKey(args) {
|
|
127
188
|
return this.request("/agent/secrets/generate-data-key", {
|
|
@@ -131,8 +192,9 @@ var AgentApiClient = class {
|
|
|
131
192
|
}
|
|
132
193
|
/**
|
|
133
194
|
* Unwrap a wrapped data key so the agent can decrypt the envelope locally.
|
|
134
|
-
*
|
|
135
|
-
*
|
|
195
|
+
* `fieldKey` MUST match the value supplied when the data key was generated
|
|
196
|
+
* (it's bound into KMS encryption context); mismatch fails with
|
|
197
|
+
* `InvalidCiphertextException`.
|
|
136
198
|
*/
|
|
137
199
|
async decryptSecretDataKey(args) {
|
|
138
200
|
return this.request("/agent/secrets/decrypt-data-key", {
|
|
@@ -140,23 +202,65 @@ var AgentApiClient = class {
|
|
|
140
202
|
body: JSON.stringify(args)
|
|
141
203
|
});
|
|
142
204
|
}
|
|
143
|
-
/**
|
|
144
|
-
|
|
205
|
+
/**
|
|
206
|
+
* Create a new secret with one or more fields. Encrypted fields must arrive
|
|
207
|
+
* pre-sealed (the agent has already obtained per-field data keys via
|
|
208
|
+
* `generateSecretDataKey({ ..., fieldKey })` and AES-encrypted locally).
|
|
209
|
+
* Plaintext fields ship the value inline.
|
|
210
|
+
*/
|
|
211
|
+
async createSecret(args) {
|
|
145
212
|
const { scope, scopeId, secretId, ...body } = args;
|
|
146
213
|
return this.request(`/agent/secrets/${encodeURIComponent(scope)}/${encodeURIComponent(scopeId)}/${encodeURIComponent(secretId)}`, {
|
|
147
214
|
method: "PUT",
|
|
148
215
|
body: JSON.stringify(body)
|
|
149
216
|
});
|
|
150
217
|
}
|
|
151
|
-
/** Fetch the
|
|
152
|
-
async
|
|
218
|
+
/** Fetch the secret aggregate plus per-field encrypted envelopes. */
|
|
219
|
+
async getSecret(args) {
|
|
153
220
|
return this.request(`/agent/secrets/${encodeURIComponent(args.scope)}/${encodeURIComponent(args.scopeId)}/${encodeURIComponent(args.secretId)}`);
|
|
154
221
|
}
|
|
155
|
-
/**
|
|
222
|
+
/** Fetch one field. Plaintext: value inline. Encrypted: envelope. */
|
|
223
|
+
async getSecretField(args) {
|
|
224
|
+
return this.request(`/agent/secrets/${encodeURIComponent(args.scope)}/${encodeURIComponent(args.scopeId)}/${encodeURIComponent(args.secretId)}/fields/${encodeURIComponent(args.fieldKey)}`);
|
|
225
|
+
}
|
|
226
|
+
/** Add OR rotate one field. */
|
|
227
|
+
async setSecretField(args) {
|
|
228
|
+
const { scope, scopeId, secretId, fieldKey, ...body } = args;
|
|
229
|
+
return this.request(`/agent/secrets/${encodeURIComponent(scope)}/${encodeURIComponent(scopeId)}/${encodeURIComponent(secretId)}/fields/${encodeURIComponent(fieldKey)}`, {
|
|
230
|
+
method: "PUT",
|
|
231
|
+
body: JSON.stringify(body)
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
/** Remove one field. */
|
|
235
|
+
async removeSecretField(args) {
|
|
236
|
+
await this.request(`/agent/secrets/${encodeURIComponent(args.scope)}/${encodeURIComponent(args.scopeId)}/${encodeURIComponent(args.secretId)}/fields/${encodeURIComponent(args.fieldKey)}`, { method: "DELETE" });
|
|
237
|
+
}
|
|
238
|
+
/** Update secret-level metadata (name/description/tags/category). */
|
|
239
|
+
async updateSecretMetadata(args) {
|
|
240
|
+
const { scope, scopeId, secretId, ...body } = args;
|
|
241
|
+
return this.request(`/agent/secrets/${encodeURIComponent(scope)}/${encodeURIComponent(scopeId)}/${encodeURIComponent(secretId)}`, {
|
|
242
|
+
method: "PATCH",
|
|
243
|
+
body: JSON.stringify(body)
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
/** List metadata for secrets in a scope. Optional filters route through the byFacet GSI. */
|
|
156
247
|
async listSecrets(args) {
|
|
157
|
-
|
|
248
|
+
const params = new URLSearchParams();
|
|
249
|
+
if (args.category) params.set("category", args.category);
|
|
250
|
+
if (args.tag) params.set("tag", args.tag);
|
|
251
|
+
if (args.fieldKey) params.set("fieldKey", args.fieldKey);
|
|
252
|
+
const qs = params.toString();
|
|
253
|
+
return (await this.request(`/agent/secrets/${encodeURIComponent(args.scope)}/${encodeURIComponent(args.scopeId)}${qs ? `?${qs}` : ""}`)).secrets;
|
|
254
|
+
}
|
|
255
|
+
/** Bounded changelog read — metadata-only audit entries. */
|
|
256
|
+
async getSecretHistory(args) {
|
|
257
|
+
const params = new URLSearchParams();
|
|
258
|
+
if (args.limit) params.set("limit", String(args.limit));
|
|
259
|
+
if (args.cursor) params.set("cursor", args.cursor);
|
|
260
|
+
const qs = params.toString();
|
|
261
|
+
return this.request(`/agent/secrets/${encodeURIComponent(args.scope)}/${encodeURIComponent(args.scopeId)}/${encodeURIComponent(args.secretId)}/history${qs ? `?${qs}` : ""}`);
|
|
158
262
|
}
|
|
159
|
-
/** Delete a secret. */
|
|
263
|
+
/** Delete a secret (and all its field rows + tag rows + changelog rows). */
|
|
160
264
|
async deleteSecret(args) {
|
|
161
265
|
await this.request(`/agent/secrets/${encodeURIComponent(args.scope)}/${encodeURIComponent(args.scopeId)}/${encodeURIComponent(args.secretId)}`, { method: "DELETE" });
|
|
162
266
|
}
|
|
@@ -170,26 +274,11 @@ var AgentApiClient = class {
|
|
|
170
274
|
body: JSON.stringify(args)
|
|
171
275
|
});
|
|
172
276
|
}
|
|
173
|
-
async enforcePolicy(args) {
|
|
174
|
-
return this.request("/agent/identity/enforce", {
|
|
175
|
-
method: "POST",
|
|
176
|
-
body: JSON.stringify(args)
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
async checkToolPermission(args) {
|
|
180
|
-
return this.request("/agent/identity/check-tool", {
|
|
181
|
-
method: "POST",
|
|
182
|
-
body: JSON.stringify(args)
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
277
|
async searchIdentities(args) {
|
|
186
278
|
const qs = new URLSearchParams();
|
|
187
279
|
if (args?.q) qs.set("q", args.q);
|
|
188
280
|
if (args?.status) qs.set("status", args.status);
|
|
189
|
-
if (args?.tag) qs.set("tag", args.tag);
|
|
190
|
-
if (args?.platform) qs.set("platform", args.platform);
|
|
191
281
|
if (args?.limit) qs.set("limit", String(args.limit));
|
|
192
|
-
if (args?.offset) qs.set("offset", String(args.offset));
|
|
193
282
|
const query = qs.toString();
|
|
194
283
|
return this.request(`/agent/identity/search${query ? `?${query}` : ""}`);
|
|
195
284
|
}
|
|
@@ -223,7 +312,6 @@ var AgentApiClient = class {
|
|
|
223
312
|
async getIdentityChangelog(identityId, args) {
|
|
224
313
|
const qs = new URLSearchParams();
|
|
225
314
|
if (args?.limit) qs.set("limit", String(args.limit));
|
|
226
|
-
if (args?.offset) qs.set("offset", String(args.offset));
|
|
227
315
|
const query = qs.toString();
|
|
228
316
|
return this.request(`/agent/identity/${encodeURIComponent(identityId)}/changelog${query ? `?${query}` : ""}`);
|
|
229
317
|
}
|
|
@@ -245,6 +333,29 @@ var AgentApiClient = class {
|
|
|
245
333
|
body: JSON.stringify(args)
|
|
246
334
|
});
|
|
247
335
|
}
|
|
336
|
+
/**
|
|
337
|
+
* Update display-shape fields on an Identity. Body excludes `email` /
|
|
338
|
+
* `phone` / `title` / `company` / `metadata` per Section D4 — contacts go
|
|
339
|
+
* via the verify flow, title/company live on OrgMembership, metadata is
|
|
340
|
+
* not agent-writable.
|
|
341
|
+
*/
|
|
342
|
+
async updateIdentity(identityId, args) {
|
|
343
|
+
return this.request(`/agent/identity/${encodeURIComponent(identityId)}/update`, {
|
|
344
|
+
method: "POST",
|
|
345
|
+
body: JSON.stringify(args)
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Phase 2 (Section H): server-side verification of a Google Chat sender via
|
|
350
|
+
* the agent's existing Google OAuth credentials. Returns the resolved
|
|
351
|
+
* identity (created or matched via Scenario-B email enrichment).
|
|
352
|
+
*/
|
|
353
|
+
async resolveGoogleChatSender(args) {
|
|
354
|
+
return this.request("/agent/google/resolve-sender", {
|
|
355
|
+
method: "POST",
|
|
356
|
+
body: JSON.stringify(args)
|
|
357
|
+
});
|
|
358
|
+
}
|
|
248
359
|
async memorySearch(query, opts) {
|
|
249
360
|
return this.request("/agent/memory/search", {
|
|
250
361
|
method: "POST",
|