@soft-boy/agentschema 0.3.6 → 0.3.7

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.
Files changed (2) hide show
  1. package/lib/channels.js +5 -1
  2. package/package.json +1 -1
package/lib/channels.js CHANGED
@@ -94,6 +94,7 @@ export const CHANNEL_TYPES = {
94
94
  public_key: { required: true, check: matches(/^[0-9a-f]{64}$/, "the 64-character public key") },
95
95
  guilds: { check: listOf(matches(DISCORD_ID, "a numeric server ID")) },
96
96
  channels: { check: listOf(matches(DISCORD_ID, "a numeric channel ID")) },
97
+ dedicated_channels: { check: listOf(matches(DISCORD_ID, "a numeric channel ID")) },
97
98
  command: { check: matches(/^[a-z0-9_-]{1,32}$/, "a slash command's name, like ask") },
98
99
  },
99
100
  identity: ({ application_id: id }) => id,
@@ -200,7 +201,9 @@ function checkAllow({ allow, approvals }, type, err, warn) {
200
201
  function checkShared(data, type, err, warn) {
201
202
  if (data.enabled !== undefined && typeof data.enabled !== "boolean") err("`enabled` must be true or false");
202
203
 
203
- if (data.respond_to !== undefined) {
204
+ // An agent can answer only in channels it has to itself, and nowhere else.
205
+ const onlyDedicated = Array.isArray(data.respond_to) && data.respond_to.length === 0 && data.dedicated_channels?.length > 0;
206
+ if (data.respond_to !== undefined && !onlyDedicated) {
204
207
  const list = data.respond_to;
205
208
  if (!Array.isArray(list) || list.length === 0 || list.some((v) => !RESPOND_TO.includes(v))) {
206
209
  err(`\`respond_to\` must be a list of ${RESPOND_TO.map(code).join(", ")}`);
@@ -278,6 +281,7 @@ export function channelSettings({ data }) {
278
281
  enabled: data.enabled ?? true,
279
282
  allow: data.allow,
280
283
  respondTo: data.respond_to ?? DEFAULT_RESPOND_TO,
284
+ dedicatedChannels: data.dedicated_channels ?? [],
281
285
  scope: data.scope ?? type.scopes[0],
282
286
  expiresAfterMs: durationMs(data.expires_after ?? DEFAULT_EXPIRES_AFTER),
283
287
  approvals: data.approvals ?? "deny",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soft-boy/agentschema",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "Markdown based AI agent schema",
5
5
  "type": "module",
6
6
  "bin": {