@segmentstream/agent 0.64.6 → 0.65.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.65.0
4
+
5
+ Workspace secrets named in code give way to values of the connections that use them.
6
+
7
+ - A workspace channel names a verification value of its connection with
8
+ `channels.<name>.input`, such as `"input": "webhook_signing_secret"`, and its code's
9
+ `signedWith` and `matches` check deliveries against it.
10
+ - `check` warns `named-secret-deprecated` for a webhook's `signature.secret` or
11
+ `verification.verifyToken` and for the guests' `botCheck.secret`.
12
+ - `secret_ref(...)` is documented as the older form of a connection's own `Secret(...)`.
13
+ - Deploying a connection field changed from `secret_ref(name)` to its own `Secret(...)` makes the
14
+ workspace secret that field's value, without reading it, when nothing else the deployment
15
+ declares names it: nobody enters the value again, and a Telegram bot keeps its token and chats.
16
+
17
+ Action required: `secret_ref(name)` in `connections/connections.py`, including
18
+ `TelegramBotConnection(key="telegram", token=secret_ref("agent-telegram-token"))` from earlier
19
+ `segmentstream agent init` runs, stops working after 2027-01-19. Replace each with the field's own
20
+ `Secret(...)`, or `TelegramBotConnection(key="telegram")`, and deploy: the deploy takes the
21
+ workspace secret over as the field's value.
22
+
23
+ Action required: a webhook's `signature: { scheme, secret }` and
24
+ `verification: { scheme: "meta", verifyToken }` stop working after 2027-01-19. Declare the secret
25
+ as a verification value of the webhook's connection, `verification={"webhook_signing_secret":
26
+ Secret(...)}`, name the connection with `connection`, write `input: "webhook_signing_secret"`, and
27
+ paste the value on the connection's page; a WhatsApp number on the workspace's own Meta app
28
+ uses `WhatsAppConnection(key=..., application="own")`, which checks Meta's deliveries itself.
29
+
30
+ Action required: a workspace channel's `channels.<name>.secret` in `agent/segmentstream.json`
31
+ stops working after 2027-01-19. Declare the value on the channel's connection with
32
+ `verification={...}`, write `"input": "<field>"` instead, and paste it on the connection's page.
33
+
34
+ Pins @segmentstream/ontology 0.136.0.
35
+
3
36
  ## 0.64.6
4
37
 
5
38
  Pins @segmentstream/ontology 0.135.0.
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- var version = "0.64.6";
7
+ var version = "0.65.0";
8
8
  function agentBuild(environment = process.env) {
9
9
  return {
10
10
  agent: version,
@@ -289,8 +289,16 @@ export interface WorkspaceChannelInput {
289
289
  /** With `poll`, how long the source may go unread, in minutes: 10 to 60, 10 when absent. */
290
290
  readonly checkAfterMinutes?: number;
291
291
  /**
292
- * The workspace secret holding what the provider signs its deliveries with, or the token it
293
- * sends, which the channel's code checks them against with `signedWith` or `matches`.
292
+ * The verification value of `connection` holding what the provider signs its deliveries with,
293
+ * or the token it sends, which the channel's code checks them against with `signedWith` or
294
+ * `matches`: a value the connection declares with `verification={...}`, such as
295
+ * `webhook_signing_secret`.
296
+ */
297
+ readonly input?: string;
298
+ /**
299
+ * The workspace secret holding it: the older form of `input`.
300
+ *
301
+ * @deprecated Name a verification value of the channel's connection with `input`.
294
302
  */
295
303
  readonly secret?: string;
296
304
  }
@@ -564,7 +572,12 @@ export interface WorkspaceChannelSettings {
564
572
  readonly receive: "webhook" | "poll";
565
573
  /** With `poll` only. */
566
574
  readonly checkAfterMinutes?: number;
567
- /** The workspace secret the provider's deliveries are checked against; the platform reads it. */
575
+ /**
576
+ * The verification value of `connection` the provider's deliveries are checked against; the
577
+ * platform reads it.
578
+ */
579
+ readonly input?: string;
580
+ /** The workspace secret they are checked against: the older form of `input`. */
568
581
  readonly secret?: string;
569
582
  }
570
583
  /**
@@ -230,6 +230,7 @@ const EMAIL_CHECK_MINUTES = {
230
230
  };
231
231
  const DEFAULT_EMAIL_QUERY = "in:inbox";
232
232
  const PUBSUB_TOPIC = /^projects\/[a-z][a-z0-9-]{4,28}[a-z0-9]\/topics\/[A-Za-z][A-Za-z0-9._~%+-]{2,254}$/;
233
+ const CONNECTION_FIELD = /^[a-z][a-z0-9_]{0,31}$/;
233
234
  const WORKSPACE_SECRET_NAME = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
234
235
  function workspaceChannelSettings(value, issues, path) {
235
236
  const channel = section({
@@ -240,6 +241,7 @@ function workspaceChannelSettings(value, issues, path) {
240
241
  "kind",
241
242
  "receive",
242
243
  "checkAfterMinutes",
244
+ "input",
243
245
  "secret"
244
246
  ],
245
247
  issues
@@ -264,12 +266,20 @@ function workspaceChannelSettings(value, issues, path) {
264
266
  message: `must be a whole number of minutes from ${EMAIL_CHECK_MINUTES.min} to ${EMAIL_CHECK_MINUTES.max}`,
265
267
  path: [...path, "checkAfterMinutes"]
266
268
  });
267
- if (channel.secret !== void 0 && (typeof channel.secret !== "string" || !WORKSPACE_SECRET_NAME.test(channel.secret))) issues.push({
269
+ if (channel.input !== void 0 && (typeof channel.input !== "string" || !CONNECTION_FIELD.test(channel.input))) issues.push({
270
+ message: "must be a verification value of the channel's connection, such as webhook_signing_secret",
271
+ path: [...path, "input"]
272
+ });
273
+ if (channel.secret !== void 0 && channel.input !== void 0) issues.push({
274
+ message: "name the connection's verification value with input, not a workspace secret too",
275
+ path: [...path, "secret"]
276
+ });
277
+ else if (channel.secret !== void 0 && (typeof channel.secret !== "string" || !WORKSPACE_SECRET_NAME.test(channel.secret))) issues.push({
268
278
  message: "must be a workspace secret's name, such as zernio-signing-secret",
269
279
  path: [...path, "secret"]
270
280
  });
271
281
  if (issues.length > before) return null;
272
- const secret = channel.secret === void 0 ? {} : { secret: channel.secret };
282
+ const secret = channel.input !== void 0 ? { input: channel.input } : channel.secret === void 0 ? {} : { secret: channel.secret };
273
283
  return receive === "poll" ? {
274
284
  connection: channel.connection,
275
285
  receive,
@@ -4,4 +4,4 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- export { t as agentBuild } from "../../_chunks/build-metadata-D5PZGMUy.mjs";
7
+ export { t as agentBuild } from "../../_chunks/build-metadata-BcKA2-D-.mjs";
@@ -10,7 +10,7 @@ import { groupRoutingHealth } from "../group-routing/health.mjs";
10
10
  import { dispatchStructuredMessage, structuredMessage } from "./structured.mjs";
11
11
  import { handleWorkspaceCallback, isWorkspaceCallback } from "./callbacks.mjs";
12
12
  import { telegramText, withTelegramTexts } from "./texts.mjs";
13
- import { t as agentBuild } from "../../../_chunks/build-metadata-D5PZGMUy.mjs";
13
+ import { t as agentBuild } from "../../../_chunks/build-metadata-BcKA2-D-.mjs";
14
14
  import { attachmentLifecycle } from "./lifecycle.mjs";
15
15
  import { manifestOf } from "../../config.mjs";
16
16
  import { gatewayAttachmentDescriber } from "./attachment-description.mjs";
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- import { t as agentBuild } from "../../../_chunks/build-metadata-D5PZGMUy.mjs";
7
+ import { t as agentBuild } from "../../../_chunks/build-metadata-BcKA2-D-.mjs";
8
8
  import { runtimeRequestFailure } from "./runtime-request.mjs";
9
9
  import { GET } from "eve/channels";
10
10
  const HEALTH_ROUTE = "/eve/v1/telegram/health";
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { E as OntologyActionNotPermitted, Ft as principalRuntimeSource, It as runtimeEnvelope, L as needsConfirmation, Lt as telegramRuntimeSource, W as member, c as currentInboundRequest, j as ontologyTools, k as actionToolName } from "../../../_chunks/principal-CDPJQgPO.mjs";
8
- import { t as agentBuild } from "../../../_chunks/build-metadata-D5PZGMUy.mjs";
8
+ import { t as agentBuild } from "../../../_chunks/build-metadata-BcKA2-D-.mjs";
9
9
  import { object } from "../confirmation-description.mjs";
10
10
  var AttachmentLifecycleNotPermitted = class extends Error {
11
11
  code = "attachment_lifecycle_not_permitted";
@@ -420,6 +420,8 @@ function workspaceChannelDefinition(options) {
420
420
  headers: request.headers,
421
421
  body
422
422
  }, options.checks?.(body) ?? channelChecks({
423
+ connection: settings.connection,
424
+ input: settings.input,
423
425
  secret: settings.secret,
424
426
  body,
425
427
  environment: () => proxyEnvironment(environment),
@@ -1,11 +1,11 @@
1
1
  import type { ProxyEnvironment } from "../environment.js";
2
2
  import type { RuntimeToken } from "../runtime-token.js";
3
3
  /**
4
- * Checks a workspace channel's code makes of a provider's delivery against the workspace secret
5
- * the channel's settings name (`channels.<name>.secret`), as the ontology checks its webhooks: the
6
- * platform reads the secret and answers only whether the check passed, so the secret never reaches
7
- * the deployment. The deployment asks with its Vercel OIDC token, and only for a secret its
8
- * deployed agent declares.
4
+ * Checks a workspace channel's code makes of a provider's delivery against the verification value
5
+ * of the channel's connection its settings name (`channels.<name>.input`), as the ontology checks
6
+ * its webhooks: the platform reads the value and answers only whether the check passed, so it
7
+ * never reaches the deployment. The deployment asks with its Vercel OIDC token, and only for a
8
+ * value its deployed agent names. `channels.<name>.secret`, a workspace secret, is the older form.
9
9
  */
10
10
  export interface ChannelChecks {
11
11
  /**
@@ -22,8 +22,13 @@ export declare class ChannelCheckUnavailable extends Error {
22
22
  readonly name = "ChannelCheckUnavailable";
23
23
  constructor(message: string, cause?: unknown);
24
24
  }
25
- /** The checks of one delivery, `body` as it arrived, against the workspace secret `secret`. */
25
+ /**
26
+ * The checks of one delivery, `body` as it arrived, against the verification value `input` of
27
+ * the channel's connection, or the workspace secret `secret`.
28
+ */
26
29
  export declare function channelChecks(input: {
30
+ readonly connection?: string;
31
+ readonly input?: string | undefined;
27
32
  readonly secret: string | undefined;
28
33
  readonly body: string;
29
34
  readonly environment: () => ProxyEnvironment;
@@ -15,12 +15,12 @@ const CHECK_TIMEOUT_MS = 3e3;
15
15
  const HEX = /^[0-9a-f]{1,256}$/i;
16
16
  function channelChecks(input) {
17
17
  const check = async (operation, payload) => {
18
- if (input.secret === void 0) throw new Error("The channel's settings name no secret to check its deliveries against.");
19
- const secret = input.secret;
18
+ const value = input.input !== void 0 && input.connection !== void 0 ? `connections/${encodeURIComponent(input.connection)}/inputs/${encodeURIComponent(input.input)}` : input.secret !== void 0 ? `secrets/${encodeURIComponent(input.secret)}` : void 0;
19
+ if (value === void 0) throw new Error("The channel's settings name no value to check its deliveries against.");
20
20
  let response;
21
21
  try {
22
22
  const environment = input.environment();
23
- response = await (input.fetch ?? fetch)(`${environment.segmentstreamUrl}/api/internal/v1/workspaces/${encodeURIComponent(environment.workspaceId)}/secrets/${encodeURIComponent(secret)}/${operation}`, {
23
+ response = await (input.fetch ?? fetch)(`${environment.segmentstreamUrl}/api/internal/v1/workspaces/${encodeURIComponent(environment.workspaceId)}/${value}/${operation}`, {
24
24
  method: "POST",
25
25
  headers: {
26
26
  "content-type": "application/json",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/agent",
3
- "version": "0.64.6",
3
+ "version": "0.65.0",
4
4
  "description": "The SegmentStream workspace agent: the ontology as tools, acting as the member who writes, and the browser, Telegram, WhatsApp and Slack through the workspace's connections.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SegmentStream",
@@ -80,7 +80,7 @@
80
80
  "@chat-adapter/state-memory": "4.42.0",
81
81
  "@chat-adapter/telegram": "4.41.0",
82
82
  "@chat-adapter/whatsapp": "4.42.0",
83
- "@segmentstream/ontology": "0.135.0",
83
+ "@segmentstream/ontology": "0.136.0",
84
84
  "@vercel/oidc": "^3.8.4",
85
85
  "ai": "^7.0.172",
86
86
  "chat": "4.42.0",