sarvam-agents-client 0.5.2 → 0.5.3
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/README.md +52 -29
- package/dist/apis/AgentsApi.d.ts +96 -11
- package/dist/apis/AgentsApi.js +229 -9
- package/dist/apis/ConversationsApi.d.ts +5 -2
- package/dist/apis/ConversationsApi.js +7 -2
- package/dist/client.d.ts +3 -2
- package/dist/client.js +2 -1
- package/dist/compose/deploy.d.ts +14 -3
- package/dist/compose/deploy.js +60 -7
- package/dist/compose/errors.d.ts +4 -0
- package/dist/compose/errors.js +6 -1
- package/dist/compose/settingsTransport.d.ts +18 -13
- package/dist/compose/settingsTransport.js +78 -130
- package/dist/compose/transport.d.ts +12 -2
- package/dist/compose/webhook.d.ts +10 -13
- package/dist/compose/webhook.js +48 -45
- package/dist/compose/webhookSecrets.d.ts +79 -49
- package/dist/compose/webhookSecrets.js +244 -195
- package/dist/esm/apis/AgentsApi.d.ts +96 -11
- package/dist/esm/apis/AgentsApi.js +230 -10
- package/dist/esm/apis/ConversationsApi.d.ts +5 -2
- package/dist/esm/apis/ConversationsApi.js +7 -2
- package/dist/esm/client.d.ts +3 -2
- package/dist/esm/client.js +2 -1
- package/dist/esm/compose/deploy.d.ts +14 -3
- package/dist/esm/compose/deploy.js +60 -7
- package/dist/esm/compose/errors.d.ts +4 -0
- package/dist/esm/compose/errors.js +4 -0
- package/dist/esm/compose/settingsTransport.d.ts +18 -13
- package/dist/esm/compose/settingsTransport.js +80 -132
- package/dist/esm/compose/transport.d.ts +12 -2
- package/dist/esm/compose/webhook.d.ts +10 -13
- package/dist/esm/compose/webhook.js +45 -42
- package/dist/esm/compose/webhookSecrets.d.ts +79 -49
- package/dist/esm/compose/webhookSecrets.js +241 -193
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/models/AgentConversationDetail.d.ts +12 -0
- package/dist/esm/models/AgentConversationDetail.js +4 -0
- package/dist/esm/models/AgentConversationView.d.ts +12 -0
- package/dist/esm/models/AgentConversationView.js +4 -0
- package/dist/esm/models/AgentResource.d.ts +7 -0
- package/dist/esm/models/AgentResource.js +3 -0
- package/dist/esm/models/AgentVersionSavedResource.d.ts +65 -0
- package/dist/esm/models/AgentVersionSavedResource.js +60 -0
- package/dist/esm/models/AgentWebhookList.d.ts +33 -0
- package/dist/esm/models/AgentWebhookList.js +44 -0
- package/dist/esm/models/AgentWebhookView.d.ts +76 -0
- package/dist/esm/models/AgentWebhookView.js +70 -0
- package/dist/esm/models/ConversationDetail.d.ts +6 -0
- package/dist/esm/models/ConversationDetail.js +2 -0
- package/dist/esm/models/ConversationView.d.ts +6 -0
- package/dist/esm/models/ConversationView.js +2 -0
- package/dist/esm/models/ErrorDetailItem.d.ts +3 -0
- package/dist/esm/models/FileNodeView.d.ts +7 -0
- package/dist/esm/models/FileNodeView.js +3 -0
- package/dist/esm/models/QueueMessageInput.d.ts +6 -0
- package/dist/esm/models/QueueMessageInput.js +2 -0
- package/dist/esm/models/RotatedWebhookSecretView.d.ts +58 -0
- package/dist/esm/models/RotatedWebhookSecretView.js +61 -0
- package/dist/esm/models/SaveWarningView.d.ts +44 -0
- package/dist/esm/models/SaveWarningView.js +51 -0
- package/dist/esm/models/ShareSkippedResource.d.ts +41 -0
- package/dist/esm/models/ShareSkippedResource.js +47 -0
- package/dist/esm/models/WebhookSecretPutBody.d.ts +32 -0
- package/dist/esm/models/WebhookSecretPutBody.js +43 -0
- package/dist/esm/models/WebhookSecretStateView.d.ts +52 -0
- package/dist/esm/models/WebhookSecretStateView.js +56 -0
- package/dist/esm/models/WebhookSecretValueView.d.ts +32 -0
- package/dist/esm/models/WebhookSecretValueView.js +44 -0
- package/dist/esm/models/WebhookWarning.d.ts +44 -0
- package/dist/esm/models/WebhookWarning.js +51 -0
- package/dist/esm/models/index.d.ts +10 -0
- package/dist/esm/models/index.js +10 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -1
- package/dist/models/AgentConversationDetail.d.ts +12 -0
- package/dist/models/AgentConversationDetail.js +4 -0
- package/dist/models/AgentConversationView.d.ts +12 -0
- package/dist/models/AgentConversationView.js +4 -0
- package/dist/models/AgentResource.d.ts +7 -0
- package/dist/models/AgentResource.js +3 -0
- package/dist/models/AgentVersionSavedResource.d.ts +65 -0
- package/dist/models/AgentVersionSavedResource.js +67 -0
- package/dist/models/AgentWebhookList.d.ts +33 -0
- package/dist/models/AgentWebhookList.js +51 -0
- package/dist/models/AgentWebhookView.d.ts +76 -0
- package/dist/models/AgentWebhookView.js +78 -0
- package/dist/models/ConversationDetail.d.ts +6 -0
- package/dist/models/ConversationDetail.js +2 -0
- package/dist/models/ConversationView.d.ts +6 -0
- package/dist/models/ConversationView.js +2 -0
- package/dist/models/ErrorDetailItem.d.ts +3 -0
- package/dist/models/FileNodeView.d.ts +7 -0
- package/dist/models/FileNodeView.js +3 -0
- package/dist/models/QueueMessageInput.d.ts +6 -0
- package/dist/models/QueueMessageInput.js +2 -0
- package/dist/models/RotatedWebhookSecretView.d.ts +58 -0
- package/dist/models/RotatedWebhookSecretView.js +69 -0
- package/dist/models/SaveWarningView.d.ts +44 -0
- package/dist/models/SaveWarningView.js +58 -0
- package/dist/models/ShareSkippedResource.d.ts +41 -0
- package/dist/models/ShareSkippedResource.js +54 -0
- package/dist/models/WebhookSecretPutBody.d.ts +32 -0
- package/dist/models/WebhookSecretPutBody.js +50 -0
- package/dist/models/WebhookSecretStateView.d.ts +52 -0
- package/dist/models/WebhookSecretStateView.js +64 -0
- package/dist/models/WebhookSecretValueView.d.ts +32 -0
- package/dist/models/WebhookSecretValueView.js +51 -0
- package/dist/models/WebhookWarning.d.ts +44 -0
- package/dist/models/WebhookWarning.js +58 -0
- package/dist/models/index.d.ts +10 -0
- package/dist/models/index.js +10 -0
- package/package.json +1 -1
- package/src/apis/AgentsApi.ts +366 -11
- package/src/apis/ConversationsApi.ts +9 -2
- package/src/client.ts +3 -2
- package/src/compose/deploy.ts +71 -10
- package/src/compose/errors.ts +4 -0
- package/src/compose/settingsTransport.ts +78 -131
- package/src/compose/transport.ts +10 -2
- package/src/compose/webhook.ts +49 -45
- package/src/compose/webhookSecrets.ts +227 -179
- package/src/index.ts +2 -1
- package/src/models/AgentConversationDetail.ts +16 -0
- package/src/models/AgentConversationView.ts +16 -0
- package/src/models/AgentResource.ts +15 -0
- package/src/models/AgentVersionSavedResource.ts +119 -0
- package/src/models/AgentWebhookList.ts +74 -0
- package/src/models/AgentWebhookView.ts +129 -0
- package/src/models/ConversationDetail.ts +8 -0
- package/src/models/ConversationView.ts +8 -0
- package/src/models/ErrorDetailItem.ts +3 -0
- package/src/models/FileNodeView.ts +16 -0
- package/src/models/QueueMessageInput.ts +8 -0
- package/src/models/RotatedWebhookSecretView.ts +103 -0
- package/src/models/SaveWarningView.ts +84 -0
- package/src/models/ShareSkippedResource.ts +78 -0
- package/src/models/WebhookSecretPutBody.ts +66 -0
- package/src/models/WebhookSecretStateView.ts +94 -0
- package/src/models/WebhookSecretValueView.ts +66 -0
- package/src/models/WebhookWarning.ts +84 -0
- package/src/models/index.ts +10 -0
|
@@ -1,64 +1,94 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `client.webhooks`:
|
|
3
|
-
* `sarvam_agents.compose.webhook_secrets`).
|
|
2
|
+
* `client.webhooks`: list an agent's webhooks, and create, view, rotate, set and delete each one's signing secret (as
|
|
3
|
+
* Python's `sarvam_agents.compose.webhook_secrets`).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* (SARC-2597: PUT/DELETE secret, rotate-secret, secretStatus), a second backend replaces this one in `secretBackend`
|
|
10
|
-
* and nothing else changes.
|
|
5
|
+
* Built on the owner-only routes of the server's webhook secret store (panja #1857, SARC-2597):
|
|
6
|
+
* `GET /v1/agents/{id}/webhooks` and `POST`/`GET`/`PUT`/`DELETE .../webhooks/{webhookKey}/secret` and
|
|
7
|
+
* `POST .../rotate-secret`. The `webhookKey` is always read from the list, by the webhook's exact URL; it is never
|
|
8
|
+
* computed here.
|
|
11
9
|
*
|
|
12
10
|
* No secret is logged, kept on an object or put in an error message.
|
|
13
11
|
*/
|
|
14
|
-
import {
|
|
12
|
+
import { AgentsApi } from "../apis/AgentsApi.js";
|
|
13
|
+
import type { AgentWebhookView } from "../models/AgentWebhookView.js";
|
|
15
14
|
import type { Configuration } from "../runtime.js";
|
|
16
15
|
import type { Webhook } from "./webhook.js";
|
|
16
|
+
/** `"set"`: deliveries are signed with the webhook's secret. `"missing"`: it has none, so nothing is sent to it. */
|
|
17
17
|
export type SecretStatus = "set" | "missing";
|
|
18
|
-
/**
|
|
19
|
-
export declare const
|
|
20
|
-
/** The
|
|
21
|
-
|
|
22
|
-
export declare const PLACEHOLDER_DESCRIPTION = "Webhook signing secret managed by the Sarvam Agents SDK (client.webhooks). Placeholder: call client.webhooks.set_secret";
|
|
23
|
-
/** Where webhook secrets live. Swap the implementation in `secretBackend`, nowhere else. */
|
|
24
|
-
export interface SecretBackend {
|
|
25
|
-
/** Store `secret` for `url` on the agent, replacing any current one. */
|
|
26
|
-
put(agentId: string, url: string, secret: string): Promise<void>;
|
|
27
|
-
/** `"set"` only for a secret stored by `put`; a placeholder from `ensure` is `"missing"`. */
|
|
28
|
-
status(agentId: string, url: string): Promise<SecretStatus>;
|
|
29
|
-
/** Remove the secret; nothing to remove is not an error. */
|
|
30
|
-
delete(agentId: string, url: string): Promise<void>;
|
|
31
|
-
/** For `deploy`: make sure the agent has a secret for `url` (a random placeholder one if none) and return the
|
|
32
|
-
* credential name for agent.json `secret_credential` and `status` (`"missing"` while it is a placeholder). */
|
|
33
|
-
ensure(agentId: string, url: string): Promise<{
|
|
34
|
-
name: string;
|
|
35
|
-
status: SecretStatus;
|
|
36
|
-
}>;
|
|
37
|
-
}
|
|
38
|
-
/** The one place that picks where secrets live. */
|
|
39
|
-
export declare function secretBackend(api: {
|
|
40
|
-
config?: Configuration;
|
|
41
|
-
customApis?: CustomAPIsApi;
|
|
42
|
-
}): SecretBackend;
|
|
18
|
+
/** How long a replaced secret keeps signing after `rotateSecret` or `setSecret` (fixed by the server). */
|
|
19
|
+
export declare const PREVIOUS_SECRET_SECONDS = 86400;
|
|
20
|
+
/** The fine-grained reason of a chat_service error (`details[0].code` or `.reason`), else undefined. */
|
|
21
|
+
export declare function errorCode(err: unknown): Promise<string | undefined>;
|
|
43
22
|
/**
|
|
44
|
-
* `client.webhooks`:
|
|
23
|
+
* `client.webhooks`: an agent's agent.json webhooks and each one's signing secret.
|
|
24
|
+
*
|
|
25
|
+
* `url` is the webhook's URL exactly as in agent.json (or a webhook object). Its `webhookKey` is read from `list` by
|
|
26
|
+
* exact URL match, so the agent must have the webhook (`deploy` it first). Secrets are `whsec_` plus base64 of 24 to
|
|
27
|
+
* 64 bytes. Only the agent's owner can call these.
|
|
45
28
|
*
|
|
46
|
-
* `
|
|
47
|
-
*
|
|
29
|
+
* `deploy` already creates the secret of each webhook it adds and returns it once (`Deployment.webhookSecrets`).
|
|
30
|
+
* Nothing is delivered to a webhook without a secret.
|
|
48
31
|
*/
|
|
49
32
|
export declare class WebhookSecrets {
|
|
50
33
|
#private;
|
|
34
|
+
/** The generated API these helpers call. */
|
|
35
|
+
readonly api: AgentsApi;
|
|
51
36
|
constructor(config: Configuration);
|
|
52
|
-
/**
|
|
53
|
-
*
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
*
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
|
|
37
|
+
/**
|
|
38
|
+
* The agent's webhooks, each with `webhookKey`, `url`, `events`, `inAgentJson`, `secretStatus` (`"set"` or
|
|
39
|
+
* `"missing"`), `secretUpdatedAt` and, during the 24 hours after a rotation, `previousExpiresAt`.
|
|
40
|
+
*
|
|
41
|
+
* After them come orphans: a secret whose webhook was removed from agent.json is kept (the same URL added back signs
|
|
42
|
+
* with it again) and listed with `inAgentJson: false` and `url: null` (the server keeps only the key). Remove one
|
|
43
|
+
* with `deleteSecret(agentId, { webhookKey })`.
|
|
44
|
+
*/
|
|
45
|
+
list(agentId: string): Promise<AgentWebhookView[]>;
|
|
46
|
+
/** `"set"` or `"missing"` (nothing is sent to a webhook without a secret). */
|
|
47
|
+
secretStatus(agentId: string, url: string | Webhook): Promise<SecretStatus>;
|
|
48
|
+
/** The webhook's current signing secret, to view again at any time (never the previous one during a rotation).
|
|
49
|
+
* Throws `UserError` when it has none. If it leaked, rotate it. */
|
|
50
|
+
getSecret(agentId: string, url: string | Webhook): Promise<string>;
|
|
51
|
+
/** Create the webhook's first signing secret (or a new one after a delete) and return it. Give it to your receiver.
|
|
52
|
+
* Throws `SecretExistsError` when the webhook already has one: rotate it instead. */
|
|
53
|
+
createSecret(agentId: string, url: string | Webhook): Promise<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Replace the webhook's signing secret with a new one the server generates, and return it.
|
|
56
|
+
*
|
|
57
|
+
* The old secret keeps signing for 24 hours (fixed), so every delivery meanwhile carries both signatures: switch
|
|
58
|
+
* your receiver to the new secret within that time. There is one previous slot: rotating again within the 24 hours
|
|
59
|
+
* drops the first old secret at once. After a leak, cut over at once instead: `deleteSecret`, then `createSecret`.
|
|
60
|
+
* Throws `UserError` when the webhook has no secret: create one first.
|
|
61
|
+
*/
|
|
62
|
+
rotateSecret(agentId: string, url: string | Webhook): Promise<string>;
|
|
63
|
+
/**
|
|
64
|
+
* Use `secret`, one you made, as the webhook's signing secret (bring your own). A secret it replaces keeps signing
|
|
65
|
+
* for 24 hours. The server never echoes it. A malformed secret throws `SecretFormatError` before anything is sent.
|
|
66
|
+
*
|
|
67
|
+
* Called without `secret` (the 0.5 form, deprecated) it generates one here, sets it and returns it, with a warning.
|
|
68
|
+
*/
|
|
69
|
+
setSecret(agentId: string, url: string | Webhook, secret: string): Promise<void>;
|
|
70
|
+
/** @deprecated The 0.5 form: generates a secret, sets it and returns it. Call `createSecret` (no secret yet) or
|
|
71
|
+
* `rotateSecret` (replace it) instead. */
|
|
72
|
+
setSecret(agentId: string, url: string | Webhook): Promise<string>;
|
|
73
|
+
/**
|
|
74
|
+
* Remove the webhook's signing secret (the current one and any previous one). Nothing is sent to the webhook until
|
|
75
|
+
* it gets a new one (`createSecret` or `setSecret`), even if it is removed from agent.json and added back. Nothing
|
|
76
|
+
* to remove is not an error.
|
|
77
|
+
*
|
|
78
|
+
* Pass the webhook's `url`, or `{ webhookKey }` (from `list`) for an orphan: a secret whose webhook was removed from
|
|
79
|
+
* agent.json has no URL.
|
|
80
|
+
*/
|
|
81
|
+
deleteSecret(agentId: string, url: string | Webhook | {
|
|
82
|
+
webhookKey: string;
|
|
83
|
+
}): Promise<void>;
|
|
64
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* For `deploy`: create the secret of each of `urls` that is in `added` (the webhooks the deploy added) and whose
|
|
87
|
+
* `secretStatus` is `missing`. Returns the new secrets by URL and the URLs still without a secret: a failed create, a
|
|
88
|
+
* webhook not listed, and a webhook deployed before whose secret is missing (never recreated here). Never rotates or
|
|
89
|
+
* overwrites a secret. A failed create is reported as missing, never thrown; a failed list throws.
|
|
90
|
+
*/
|
|
91
|
+
export declare function createMissingSecrets(api: AgentsApi, agentId: string, urls: readonly string[], added: ReadonlySet<string>): Promise<{
|
|
92
|
+
created: Record<string, string>;
|
|
93
|
+
missing: string[];
|
|
94
|
+
}>;
|