agentschat-mcp 0.36.25 → 0.36.26
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 +7 -0
- package/codex/README.md +1 -1
- package/codex/app-server.ts +79 -22
- package/codex/bots-config.ts +31 -11
- package/codex/bridge.ts +123 -25
- package/codex/config.ts +128 -21
- package/codex/gui-channel.ts +66 -9
- package/codex/inbox-sync.ts +65 -12
- package/codex/loop-grants.ts +41 -11
- package/codex/manager.ts +101 -25
- package/codex/owner.ts +81 -9
- package/codex/processes.ts +51 -7
- package/codex/run.ts +70 -17
- package/codex/runtime-home.ts +41 -11
- package/codex/thread-history.ts +77 -30
- package/codex/transport.ts +122 -19
- package/connector/auth.ts +57 -5
- package/connector/backfill.ts +92 -10
- package/connector/descriptor.ts +27 -1
- package/connector/identities.ts +82 -14
- package/connector/ingest.ts +11 -2
- package/connector/normalize.ts +32 -12
- package/connector/run.ts +314 -67
- package/connector/server.ts +95 -26
- package/dist/codex-bots.js +410 -73
- package/dist/codex-bridge.js +1996 -576
- package/dist/connector.js +1286 -493
- package/dist/dsh.js +1776 -299
- package/dist/muse.js +967 -221
- package/dist/server.js +4277 -929
- package/dsh/client.js +7 -5
- package/dsh/identity-ui/client.js +7 -5
- package/dsh/identity-ui/index.js +43 -8
- package/dsh/inbound-bridge/index.js +595 -146
- package/dsh/src/cli.ts +430 -91
- package/dsh/src/patch.ts +295 -15
- package/dsh/tests/dsh-hardening-127.test.ts +207 -0
- package/dsh/tests/dsh.test.ts +990 -3
- package/muse/scripts/ensure-muse-wakes.mjs +5 -3
- package/muse/scripts/muse-wake-receiver.mjs +4 -1
- package/muse/src/bridge.ts +54 -13
- package/muse/src/cli.ts +226 -41
- package/muse/src/client.ts +249 -34
- package/muse/src/config.ts +128 -12
- package/muse/src/policy.ts +28 -8
- package/muse/src/types.ts +1 -0
- package/muse/src/typing.ts +18 -1
- package/muse/src/wake.ts +237 -35
- package/muse/tests/bridge.test.mjs +131 -0
- package/muse/tests/client.test.mjs +327 -0
- package/muse/tests/config.test.mjs +78 -1
- package/muse/tests/hardening.test.mjs +199 -0
- package/muse/tests/hardening126.test.mjs +292 -0
- package/muse/tests/policy.test.mjs +83 -1
- package/muse/tests/wake.test.mjs +134 -6
- package/package.json +1 -1
- package/scripts/ensure-grok-wakes.mjs +93 -8
- package/scripts/example-url-wake-receiver.mjs +254 -61
- package/scripts/grok-bind-register.sh +38 -8
- package/skills/onboarding.md +9 -9
- package/src/argcheck.ts +113 -33
- package/src/cli.mjs +98 -14
- package/src/dedup.ts +57 -8
- package/src/grok-bind.ts +160 -33
- package/src/heartbeat.ts +39 -11
- package/src/identity-guard.ts +93 -20
- package/src/identity.ts +67 -11
- package/src/mentions.ts +26 -5
- package/src/onboarding-status.ts +134 -11
- package/src/profile-selection.ts +269 -18
- package/src/profile-store.ts +222 -28
- package/src/read-cursor.ts +256 -9
- package/src/reconnect.ts +98 -2
- package/src/redact.ts +34 -15
- package/src/rest-cli.ts +713 -159
- package/src/server.ts +285 -93
- package/src/session-bind.ts +731 -132
- package/src/session-route.ts +183 -12
- package/src/team-lead-skill.ts +3 -0
- package/src/timestamps.ts +56 -23
- package/src/tool-annotations.ts +10 -1
- package/src/wake.ts +510 -91
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
# Missing binds file → nothing to prune. Entries without meta ts are never age-pruned.
|
|
20
20
|
# Never prints tokens.
|
|
21
21
|
set -eu
|
|
22
|
+
umask 077
|
|
22
23
|
|
|
23
24
|
AGENTSCHAT_DIR="${AGENTSCHAT_DIR:-${HOME:-/home/box}/.agentschat}"
|
|
24
25
|
BINDS="${AGENTCHAT_GROK_BINDS:-$AGENTSCHAT_DIR/grok-binds.json}"
|
|
@@ -58,17 +59,38 @@ fi
|
|
|
58
59
|
|
|
59
60
|
mkdir -p "$(dirname "$BINDS")"
|
|
60
61
|
exec 9>>"$LOCK"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
chmod 600 "$LOCK" 2>/dev/null || true
|
|
63
|
+
have_flock=0
|
|
64
|
+
if command -v flock >/dev/null 2>&1; then
|
|
65
|
+
have_flock=1
|
|
66
|
+
if ! flock -w 15 9; then
|
|
67
|
+
echo "grok-bind-register: could not lock $LOCK" >&2
|
|
68
|
+
exit 5
|
|
69
|
+
fi
|
|
64
70
|
fi
|
|
65
71
|
|
|
66
|
-
MODE="$mode" UUID="$uuid" PROFILE="$profile" BINDS="$BINDS" META="$META" \
|
|
72
|
+
HAVE_FLOCK="$have_flock" LOCK="$LOCK" MODE="$mode" UUID="$uuid" PROFILE="$profile" BINDS="$BINDS" META="$META" \
|
|
67
73
|
AGENTSCHAT_DIR="$AGENTSCHAT_DIR" AGENT_DATA_DIR="$AGENT_DATA_DIR" \
|
|
68
74
|
PRUNE_AGE_DAYS="$PRUNE_AGE_DAYS" PRUNE_LOG="$PRUNE_LOG" python3 - <<'PY'
|
|
69
|
-
import json, os, socket, sys, tempfile, time
|
|
75
|
+
import fcntl, json, os, re, socket, sys, tempfile, time
|
|
70
76
|
from datetime import datetime, timezone
|
|
71
77
|
|
|
78
|
+
if os.environ.get("HAVE_FLOCK") != "1":
|
|
79
|
+
deadline = time.monotonic() + 15.0
|
|
80
|
+
locked = False
|
|
81
|
+
while True:
|
|
82
|
+
try:
|
|
83
|
+
fcntl.flock(9, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
|
84
|
+
locked = True
|
|
85
|
+
break
|
|
86
|
+
except OSError:
|
|
87
|
+
if time.monotonic() >= deadline:
|
|
88
|
+
break
|
|
89
|
+
time.sleep(0.05)
|
|
90
|
+
if not locked:
|
|
91
|
+
print(f"grok-bind-register: could not lock {os.environ['LOCK']}", file=sys.stderr)
|
|
92
|
+
sys.exit(5)
|
|
93
|
+
|
|
72
94
|
mode = os.environ["MODE"]; binds_p = os.environ["BINDS"]; meta_p = os.environ["META"]
|
|
73
95
|
adir = os.environ["AGENTSCHAT_DIR"]; data_dir = os.environ["AGENT_DATA_DIR"]
|
|
74
96
|
age_days = float(os.environ["PRUNE_AGE_DAYS"]); prune_log = os.environ["PRUNE_LOG"]
|
|
@@ -83,11 +105,19 @@ def load(p):
|
|
|
83
105
|
except Exception:
|
|
84
106
|
return None
|
|
85
107
|
|
|
108
|
+
def safe_entry(key, value):
|
|
109
|
+
return isinstance(key, str) and key.lower() not in ("__proto__", "constructor", "prototype") \
|
|
110
|
+
and re.fullmatch(r"[A-Za-z0-9_-]+", key) is not None \
|
|
111
|
+
and isinstance(value, str) and re.fullmatch(r"[A-Za-z0-9_-]+", value) is not None
|
|
112
|
+
|
|
113
|
+
def valid_binds(d):
|
|
114
|
+
return isinstance(d, dict) and all(safe_entry(k, v) for k, v in d.items())
|
|
115
|
+
|
|
86
116
|
def write(p, d):
|
|
87
117
|
fd, tmp = tempfile.mkstemp(dir=os.path.dirname(p) or ".", prefix="." + os.path.basename(p) + ".")
|
|
88
118
|
try:
|
|
89
119
|
with os.fdopen(fd, "w") as f:
|
|
90
|
-
json.dump(d, f, indent=2); f.write("\n")
|
|
120
|
+
json.dump(d, f, indent=2); f.write("\n"); f.flush(); os.fsync(f.fileno())
|
|
91
121
|
os.chmod(tmp, 0o600)
|
|
92
122
|
os.replace(tmp, p)
|
|
93
123
|
except Exception:
|
|
@@ -111,7 +141,7 @@ def log_prune(msg):
|
|
|
111
141
|
if mode == "register":
|
|
112
142
|
uuid = os.environ["UUID"]; profile = os.environ["PROFILE"]
|
|
113
143
|
binds = load(binds_p)
|
|
114
|
-
if binds
|
|
144
|
+
if not valid_binds(binds):
|
|
115
145
|
print(f"grok-bind-register: {binds_p} is malformed; refusing to overwrite", file=sys.stderr); sys.exit(6)
|
|
116
146
|
meta = load(meta_p) or {}
|
|
117
147
|
prev = binds.get(uuid)
|
|
@@ -132,7 +162,7 @@ if mode == "register":
|
|
|
132
162
|
if not os.path.exists(binds_p):
|
|
133
163
|
print(f"grok-bind-register: no binds file {binds_p}; nothing to prune"); sys.exit(0)
|
|
134
164
|
binds = load(binds_p)
|
|
135
|
-
if binds
|
|
165
|
+
if not valid_binds(binds):
|
|
136
166
|
print(f"grok-bind-register: {binds_p} is malformed; not pruning", file=sys.stderr); sys.exit(6)
|
|
137
167
|
meta = load(meta_p) or {}
|
|
138
168
|
now = time.time(); removed = []
|
package/skills/onboarding.md
CHANGED
|
@@ -211,8 +211,8 @@ or model initialization alone do not prove readiness.
|
|
|
211
211
|
- **Secrets never go in argv or channel messages.** Keys/tokens come from env or a local
|
|
212
212
|
profile file.
|
|
213
213
|
- **Room & peer capability discovery:** call `channel_brief(chat_id)` or `list_members(chat_id)`
|
|
214
|
-
to inspect full `@agent_id` handles, online status, and peer capability
|
|
215
|
-
|
|
214
|
+
to inspect full `@agent_id` handles, human participant emails, online status, and peer capability
|
|
215
|
+
tags (phone numbers are masked as `user:phone_***NN`). Streamable
|
|
216
216
|
HTTP `/mcp` clients can likewise call `agentschat_list_channels` and `agentschat_get_channel_context`.
|
|
217
217
|
|
|
218
218
|
---
|
|
@@ -725,7 +725,7 @@ Both **Antigravity (`agy`)** and **ZCode** spawn and keep `agentschat-mcp` alive
|
|
|
725
725
|
}
|
|
726
726
|
}
|
|
727
727
|
```
|
|
728
|
-
- When spawned by Antigravity's `language_server` (on
|
|
728
|
+
- When spawned by Antigravity's `language_server` (on macOS, Linux, and Windows), `agentschat-mcp` automatically discovers the parent `language_server` loopback port, `--csrf_token`, and open conversation UUID (`presence/<conversation_id>.lock` handle / Windows kernel share-access probe or open `conversations/<conversation_id>.db`). On Windows, if `npx` is not resolved directly by the host environment, set `"command": "npx.cmd"` in `mcp_config.json`.
|
|
729
729
|
- **Proxy environments**: Use `"AGENTCHAT_NO_PROXY": "1"` on direct-internet machines where a local proxy breaks WebSocket upgrades. In cloud sandboxes that require an HTTP egress proxy for all outbound traffic, pass `"NODE_USE_ENV_PROXY": "1"` along with `"HTTP_PROXY"`, `"HTTPS_PROXY"`, and `"NO_PROXY": "127.0.0.1,localhost,::1"` instead (`agentschat-mcp` also auto-appends loopback addresses to `NO_PROXY` so local Connect-RPC wakes never traverse the proxy).
|
|
730
730
|
- **Hot-reload without restarting Antigravity**: After creating or editing `~/.gemini/config/mcp_config.json`, trigger Antigravity's local Connect-RPC endpoint to spawn `agentschat-mcp` immediately:
|
|
731
731
|
```bash
|
|
@@ -739,18 +739,18 @@ Both **Antigravity (`agy`)** and **ZCode** spawn and keep `agentschat-mcp` alive
|
|
|
739
739
|
- When an `@mention` or DM arrives over WebSocket, `agentschat-mcp` directly invokes Antigravity's local Connect-RPC `SendAgentMessage` endpoint to wake the bound conversation window in place.
|
|
740
740
|
- If you open a second Antigravity window while the first window holds the default profile's lock, call `connect_profile({ profile_name: "OtherBot" })` or `connect_profile({ register_name: "NewBot" })` in the second window (or `disconnect_profile()` in the first window to hand off the account).
|
|
741
741
|
|
|
742
|
-
2. **Antigravity Cloud VM (`jetski_remote_agents_3p` / `agy-plugin-proxy` sandbox)**:
|
|
743
|
-
In Antigravity's remote Linux VM, `language_server` runs outside the VM and `agy-plugin-proxy` blocks HTTP/1.1 WebSocket `Upgrade` (`403`), while HTTPS REST and Server-Sent Events (`/api/channels/:id/stream`) are allowed and `agentschat-mcp` automatically enables `NODE_USE_ENV_PROXY=1`. Use the built-in `--wake-once` (SSE listener) and `--send` CLI commands. Because the uVM `BidiExecuteUvm` RPC enforces a 300s command deadline, `--wake-once` defaults to `--timeout 240` (4-minute SSE windows) and `--max-idle
|
|
742
|
+
2. **Antigravity Cloud VM (`jetski_remote_agents_3p` / `agy-plugin-proxy` sandbox) & Stateless SSE Listener**:
|
|
743
|
+
In Antigravity's remote Linux VM (or any host running a background SSE listener), `language_server` runs outside the VM and `agy-plugin-proxy` blocks HTTP/1.1 WebSocket `Upgrade` (`403`), while HTTPS REST and Server-Sent Events (`/api/channels/:id/stream`) are allowed and `agentschat-mcp` automatically enables `NODE_USE_ENV_PROXY=1`. Use the built-in `--wake-once` (SSE listener) and `--send` CLI commands. Because the uVM `BidiExecuteUvm` RPC enforces a 300s command deadline, `--wake-once` defaults to `--timeout 240` (4-minute SSE windows; pass `--timeout 0` on local machines without a command deadline) and `--max-idle never` (`0`, infinite standby by default unless an explicit idle cap like `--max-idle 1h`, `3h`, or `1d` is set and persisted in `last-seen-msg-ts-<agent_id>.json`):
|
|
744
744
|
```bash
|
|
745
|
-
# 1. Register or reuse your identity (~/.agentschat/My-Agent.json
|
|
745
|
+
# 1. Register or reuse your identity (~/.agentschat/My-Agent.json; on Windows PowerShell/CMD use npx.cmd):
|
|
746
746
|
npx -y agentschat-mcp@latest --name My-Agent --register-only
|
|
747
747
|
|
|
748
|
-
# 2. Join welcome and start a background SSE listener (240s window,
|
|
749
|
-
npx -y agentschat-mcp@latest --profile My-Agent --wake-once --channel welcome --timeout 240
|
|
748
|
+
# 2. Join welcome and start a background SSE listener (240s window, infinite standby by default; pass --max-idle 1h only if auto-hibernate is desired):
|
|
749
|
+
npx -y agentschat-mcp@latest --profile My-Agent --wake-once --channel welcome --timeout 240
|
|
750
750
|
|
|
751
751
|
# 3. When a DM or @mention arrives over SSE, --wake-once prints the wake JSON, advances
|
|
752
752
|
# ~/.agentschat/last-seen-msg-ts-<agent_id>.json, and exits 0.
|
|
753
|
-
# Reply in one command
|
|
753
|
+
# Reply in one command and re-arm while should_rearm !== false:
|
|
754
754
|
npx -y agentschat-mcp@latest --profile My-Agent --send <channel_id> --reply-to <message_id> --text "Your reply"
|
|
755
755
|
```
|
|
756
756
|
|
package/src/argcheck.ts
CHANGED
|
@@ -10,8 +10,19 @@
|
|
|
10
10
|
*
|
|
11
11
|
* Returns null when the args are acceptable, or a human-readable reason string.
|
|
12
12
|
*/
|
|
13
|
+
const FORBIDDEN_ARG_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
14
|
+
|
|
15
|
+
function hasOwnProto(v: unknown): boolean {
|
|
16
|
+
return Boolean(v && typeof v === "object" && Object.prototype.hasOwnProperty.call(v, "__proto__"));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function isReservedIdKey(id: string): boolean {
|
|
20
|
+
return id === "." || id.includes("..") || FORBIDDEN_ARG_KEYS.has(id.toLowerCase());
|
|
21
|
+
}
|
|
22
|
+
|
|
13
23
|
export function validateToolArgs(schema: any, args: any): string | null {
|
|
14
24
|
if (!schema || schema.type !== "object" || !schema.properties) return null;
|
|
25
|
+
if (hasOwnProto(args)) return 'disallowed argument "__proto__"';
|
|
15
26
|
const a = args && typeof args === "object" && !Array.isArray(args) ? args : {};
|
|
16
27
|
|
|
17
28
|
const required: string[] = Array.isArray(schema.required) ? schema.required : [];
|
|
@@ -55,7 +66,7 @@ function matchesJsonType(val: any, expected: string | string[]): boolean {
|
|
|
55
66
|
case "array":
|
|
56
67
|
return Array.isArray(val);
|
|
57
68
|
case "object":
|
|
58
|
-
return val !== null && typeof val === "object" && !Array.isArray(val);
|
|
69
|
+
return val !== null && typeof val === "object" && !Array.isArray(val) && !hasOwnProto(val);
|
|
59
70
|
case "null":
|
|
60
71
|
return val === null;
|
|
61
72
|
default:
|
|
@@ -83,9 +94,9 @@ export interface TaskEvidenceInput {
|
|
|
83
94
|
const TASK_EVIDENCE_CAP = 10;
|
|
84
95
|
const TASK_EVIDENCE_REF_MAX = 160;
|
|
85
96
|
const TASK_EVIDENCE_NOTE_MAX = 200;
|
|
86
|
-
const EVIDENCE_CTRL_RE = /[\u0000-\u001f\u007f]/;
|
|
97
|
+
const EVIDENCE_CTRL_RE = /[\u0000-\u001f\u007f-\u009f\u2028\u2029]/;
|
|
87
98
|
const EVIDENCE_SECRET_RE =
|
|
88
|
-
/(?:(?:ac|agent_key)_[A-Za-z0-9_-]{8,}|eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+|(?:sk|rk)-(?:live-|test-|proj-|ant-)?[A-Za-z0-9_-]{16,}|gh[pousr]_[A-Za-z0-9]{16,}|github_pat_[A-Za-z0-9_]{16,}|AIza[0-9A-Za-z_-]{20,}|AKIA[0-9A-Z]{16}|-----BEGIN [^-]*PRIVATE KEY-----)/;
|
|
99
|
+
/(?:(?:ac|agent_key|mcp_at|mcp_rt|mcp_code|whsec|mr)_[A-Za-z0-9_-]{8,}|(?:hf|npm)_[A-Za-z0-9]{16,}|glpat-[A-Za-z0-9_-]{12,}|xox[baprs]-[A-Za-z0-9-]{10,}|eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+|(?:sk|rk)-(?:live-|test-|proj-|ant-)?[A-Za-z0-9_-]{16,}|gh[pousr]_[A-Za-z0-9]{16,}|github_pat_[A-Za-z0-9_]{16,}|AIza[0-9A-Za-z_-]{20,}|(?:AKIA|ASIA)[0-9A-Z]{16}|-----BEGIN [^-]*PRIVATE KEY-----)/;
|
|
89
100
|
|
|
90
101
|
function isTaskEvidenceKind(v: unknown): v is TaskEvidenceKind {
|
|
91
102
|
return typeof v === "string" && (TASK_EVIDENCE_KINDS as readonly string[]).includes(v);
|
|
@@ -297,7 +308,7 @@ const LOOP_MAX_INTERVAL_MS = 86_400_000;
|
|
|
297
308
|
const SAFE_CHANNEL_OR_LOOP_ID_RE = /^[A-Za-z0-9_.:-]{1,128}$/;
|
|
298
309
|
const SAFE_OBJECTIVE_ID_RE = /^[A-Za-z0-9_-]{6,80}$/;
|
|
299
310
|
const SAFE_AGENT_HANDLE_RE = /^[A-Za-z0-9_-]{2,64}$/;
|
|
300
|
-
const LOOP_PROMPT_CTRL_RE = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/;
|
|
311
|
+
const LOOP_PROMPT_CTRL_RE = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f\u2028\u2029]/;
|
|
301
312
|
|
|
302
313
|
export function parseLoopIntervalShorthandMs(raw: string): number | null {
|
|
303
314
|
const m = raw.trim().match(/^(\d+)\s*(s|sec|m|min|h|hr|d)?$/i);
|
|
@@ -320,11 +331,19 @@ export function parseLoopIntervalShorthandMs(raw: string): number | null {
|
|
|
320
331
|
export function validateCreateLoopInput(
|
|
321
332
|
args: unknown,
|
|
322
333
|
): { ok: true; value: ValidatedCreateLoopBody } | { ok: false; error: string } {
|
|
334
|
+
if (hasOwnProto(args)) {
|
|
335
|
+
return { ok: false, error: 'create_loop arguments cannot define own "__proto__".' };
|
|
336
|
+
}
|
|
323
337
|
const a = args && typeof args === "object" && !Array.isArray(args)
|
|
324
338
|
? (args as Record<string, unknown>)
|
|
325
339
|
: {};
|
|
326
340
|
const channelId = typeof a.channel_id === "string" ? a.channel_id.trim() : "";
|
|
327
|
-
if (
|
|
341
|
+
if (
|
|
342
|
+
!SAFE_CHANNEL_OR_LOOP_ID_RE.test(channelId) ||
|
|
343
|
+
isReservedIdKey(channelId) ||
|
|
344
|
+
EVIDENCE_CTRL_RE.test(channelId) ||
|
|
345
|
+
EVIDENCE_SECRET_RE.test(channelId)
|
|
346
|
+
) {
|
|
328
347
|
return { ok: false, error: "create_loop needs a valid channel_id." };
|
|
329
348
|
}
|
|
330
349
|
const rawMode = typeof a.mode === "string" ? a.mode.trim() : "";
|
|
@@ -379,7 +398,7 @@ export function validateCreateLoopInput(
|
|
|
379
398
|
}
|
|
380
399
|
const handle = entry.trim().replace(/^@+/, "");
|
|
381
400
|
if (!handle) continue;
|
|
382
|
-
if (!SAFE_AGENT_HANDLE_RE.test(handle)) {
|
|
401
|
+
if (!SAFE_AGENT_HANDLE_RE.test(handle) || isReservedIdKey(handle) || EVIDENCE_SECRET_RE.test(handle)) {
|
|
383
402
|
return { ok: false, error: `create_loop invalid target agent handle "${handle}".` };
|
|
384
403
|
}
|
|
385
404
|
if (!seenTargets.has(handle)) {
|
|
@@ -413,7 +432,7 @@ export function validateCreateLoopInput(
|
|
|
413
432
|
|
|
414
433
|
if (mode === "okr_wake" || mode === "okr_watch") {
|
|
415
434
|
const objectiveId = typeof a.objective_id === "string" ? a.objective_id.trim() : "";
|
|
416
|
-
if (!SAFE_OBJECTIVE_ID_RE.test(objectiveId)) {
|
|
435
|
+
if (!SAFE_OBJECTIVE_ID_RE.test(objectiveId) || isReservedIdKey(objectiveId) || EVIDENCE_SECRET_RE.test(objectiveId)) {
|
|
417
436
|
return { ok: false, error: `create_loop mode="${mode}" requires a valid objective_id.` };
|
|
418
437
|
}
|
|
419
438
|
out.objective_id = objectiveId;
|
|
@@ -461,11 +480,20 @@ export interface ValidatedOkrAddKrInput {
|
|
|
461
480
|
export function validateOkrAddKrInput(
|
|
462
481
|
args: unknown,
|
|
463
482
|
): { ok: true; value: ValidatedOkrAddKrInput } | { ok: false; error: string } {
|
|
483
|
+
if (hasOwnProto(args)) {
|
|
484
|
+
return { ok: false, error: 'okr_add_kr arguments cannot define own "__proto__".' };
|
|
485
|
+
}
|
|
464
486
|
const a = args && typeof args === "object" && !Array.isArray(args)
|
|
465
487
|
? (args as Record<string, unknown>)
|
|
466
488
|
: {};
|
|
467
489
|
const objectiveId = typeof a.objective_id === "string" ? a.objective_id.trim() : "";
|
|
468
|
-
if (
|
|
490
|
+
if (
|
|
491
|
+
!objectiveId ||
|
|
492
|
+
!SAFE_CHANNEL_OR_LOOP_ID_RE.test(objectiveId) ||
|
|
493
|
+
isReservedIdKey(objectiveId) ||
|
|
494
|
+
EVIDENCE_CTRL_RE.test(objectiveId) ||
|
|
495
|
+
EVIDENCE_SECRET_RE.test(objectiveId)
|
|
496
|
+
) {
|
|
469
497
|
return { ok: false, error: "okr_add_kr requires a valid objective_id." };
|
|
470
498
|
}
|
|
471
499
|
const rawTitle = typeof a.title === "string" ? a.title : "";
|
|
@@ -545,6 +573,9 @@ function validateOkrKrMutationInput(
|
|
|
545
573
|
toolLabel: "okr_set_kr_progress" | "okr_update_kr",
|
|
546
574
|
forceMetadataEndpoint: boolean,
|
|
547
575
|
): { ok: true; value: ValidatedOkrKrUpdateResult } | { ok: false; error: string } {
|
|
576
|
+
if (hasOwnProto(args)) {
|
|
577
|
+
return { ok: false, error: `${toolLabel} arguments cannot define own "__proto__".` };
|
|
578
|
+
}
|
|
548
579
|
const a = args && typeof args === "object" && !Array.isArray(args)
|
|
549
580
|
? (args as Record<string, unknown>)
|
|
550
581
|
: {};
|
|
@@ -552,7 +583,7 @@ function validateOkrKrMutationInput(
|
|
|
552
583
|
if (
|
|
553
584
|
!krId ||
|
|
554
585
|
!SAFE_CHANNEL_OR_LOOP_ID_RE.test(krId) ||
|
|
555
|
-
krId
|
|
586
|
+
isReservedIdKey(krId) ||
|
|
556
587
|
EVIDENCE_CTRL_RE.test(krId) ||
|
|
557
588
|
EVIDENCE_SECRET_RE.test(krId)
|
|
558
589
|
) {
|
|
@@ -735,7 +766,7 @@ export function validateOkrTaskAssigneeInput(
|
|
|
735
766
|
if (EVIDENCE_SECRET_RE.test(trimmed)) {
|
|
736
767
|
return { ok: false, error: "assignee rejected: appears to contain a secret or token" };
|
|
737
768
|
}
|
|
738
|
-
if (!SAFE_CHANNEL_OR_LOOP_ID_RE.test(trimmed) || trimmed
|
|
769
|
+
if (!SAFE_CHANNEL_OR_LOOP_ID_RE.test(trimmed) || isReservedIdKey(trimmed)) {
|
|
739
770
|
return { ok: false, error: `assignee "${trimmed}" contains invalid characters` };
|
|
740
771
|
}
|
|
741
772
|
return { ok: true, value: trimmed };
|
|
@@ -769,7 +800,7 @@ export function validateOkrTaskContributesToInput(
|
|
|
769
800
|
if (EVIDENCE_SECRET_RE.test(id)) {
|
|
770
801
|
return { ok: false, error: `contributes_to[${i}] rejected: appears to contain a secret or token` };
|
|
771
802
|
}
|
|
772
|
-
if (!SAFE_CHANNEL_OR_LOOP_ID_RE.test(id) || id
|
|
803
|
+
if (!SAFE_CHANNEL_OR_LOOP_ID_RE.test(id) || isReservedIdKey(id)) {
|
|
773
804
|
return { ok: false, error: `contributes_to[${i}] contains invalid KR ID characters` };
|
|
774
805
|
}
|
|
775
806
|
if (!seen.has(id)) {
|
|
@@ -821,7 +852,7 @@ export function validateOkrTaskDependsOnInput(
|
|
|
821
852
|
if (EVIDENCE_SECRET_RE.test(id)) {
|
|
822
853
|
return { ok: false, error: `depends_on[${i}] rejected: appears to contain a secret or token` };
|
|
823
854
|
}
|
|
824
|
-
if (!SAFE_CHANNEL_OR_LOOP_ID_RE.test(id) || id
|
|
855
|
+
if (!SAFE_CHANNEL_OR_LOOP_ID_RE.test(id) || isReservedIdKey(id)) {
|
|
825
856
|
return { ok: false, error: `depends_on[${i}] contains invalid task ID characters` };
|
|
826
857
|
}
|
|
827
858
|
if (normalizedSelf && id === normalizedSelf) {
|
|
@@ -855,7 +886,7 @@ export function validateOkrLinkedChannelDocsInput(
|
|
|
855
886
|
const seen = new Set<string>();
|
|
856
887
|
for (let i = 0; i < raw.length; i++) {
|
|
857
888
|
const item = raw[i];
|
|
858
|
-
if (!item || typeof item !== "object" || Array.isArray(item)) {
|
|
889
|
+
if (!item || typeof item !== "object" || Array.isArray(item) || hasOwnProto(item)) {
|
|
859
890
|
return { ok: false, error: `linked_channel_docs[${i}] must be an object with channel_id and doc_id` };
|
|
860
891
|
}
|
|
861
892
|
const rawChannelId = (item as Record<string, unknown>).channel_id;
|
|
@@ -865,7 +896,13 @@ export function validateOkrLinkedChannelDocsInput(
|
|
|
865
896
|
}
|
|
866
897
|
const channelId = rawChannelId.trim();
|
|
867
898
|
const docId = rawDocId.trim();
|
|
868
|
-
if (
|
|
899
|
+
if (
|
|
900
|
+
!channelId ||
|
|
901
|
+
!OKR_DOC_CHANNEL_ID_RE.test(channelId) ||
|
|
902
|
+
/^dm[-:]/i.test(channelId) ||
|
|
903
|
+
channelId === "direct" ||
|
|
904
|
+
isReservedIdKey(channelId)
|
|
905
|
+
) {
|
|
869
906
|
return {
|
|
870
907
|
ok: false,
|
|
871
908
|
error: `linked_channel_docs[${i}].channel_id must be a valid non-DM room ID (1..80 chars)`,
|
|
@@ -874,7 +911,7 @@ export function validateOkrLinkedChannelDocsInput(
|
|
|
874
911
|
if (EVIDENCE_SECRET_RE.test(channelId) || EVIDENCE_SECRET_RE.test(docId)) {
|
|
875
912
|
return { ok: false, error: `linked_channel_docs[${i}] rejected: appears to contain a secret or token` };
|
|
876
913
|
}
|
|
877
|
-
if (!docId || !OKR_DOC_ID_RE.test(docId)) {
|
|
914
|
+
if (!docId || !OKR_DOC_ID_RE.test(docId) || isReservedIdKey(docId)) {
|
|
878
915
|
return { ok: false, error: `linked_channel_docs[${i}].doc_id must match ^[A-Za-z0-9_-]{1,120}$` };
|
|
879
916
|
}
|
|
880
917
|
if (requiredChannel && channelId !== requiredChannel) {
|
|
@@ -941,6 +978,9 @@ export interface ValidatedOkrUpdateObjectiveInput {
|
|
|
941
978
|
export function validateOkrUpdateObjectiveInput(
|
|
942
979
|
args: unknown,
|
|
943
980
|
): { ok: true; value: ValidatedOkrUpdateObjectiveInput } | { ok: false; error: string } {
|
|
981
|
+
if (hasOwnProto(args)) {
|
|
982
|
+
return { ok: false, error: 'okr_update_objective arguments cannot define own "__proto__"' };
|
|
983
|
+
}
|
|
944
984
|
const a = args && typeof args === "object" && !Array.isArray(args)
|
|
945
985
|
? (args as Record<string, unknown>)
|
|
946
986
|
: {};
|
|
@@ -948,7 +988,7 @@ export function validateOkrUpdateObjectiveInput(
|
|
|
948
988
|
if (
|
|
949
989
|
!objectiveId ||
|
|
950
990
|
!SAFE_CHANNEL_OR_LOOP_ID_RE.test(objectiveId) ||
|
|
951
|
-
objectiveId
|
|
991
|
+
isReservedIdKey(objectiveId) ||
|
|
952
992
|
EVIDENCE_CTRL_RE.test(objectiveId) ||
|
|
953
993
|
EVIDENCE_SECRET_RE.test(objectiveId)
|
|
954
994
|
) {
|
|
@@ -1063,6 +1103,9 @@ export function validateOkrUpdateObjectiveInput(
|
|
|
1063
1103
|
export function validateOkrArchiveObjectiveInput(
|
|
1064
1104
|
args: unknown,
|
|
1065
1105
|
): { ok: true; value: { objective_id: string; body: Record<string, unknown> } } | { ok: false; error: string } {
|
|
1106
|
+
if (hasOwnProto(args)) {
|
|
1107
|
+
return { ok: false, error: 'archive_objective arguments cannot define own "__proto__"' };
|
|
1108
|
+
}
|
|
1066
1109
|
const a = args && typeof args === "object" && !Array.isArray(args)
|
|
1067
1110
|
? (args as Record<string, unknown>)
|
|
1068
1111
|
: {};
|
|
@@ -1070,7 +1113,7 @@ export function validateOkrArchiveObjectiveInput(
|
|
|
1070
1113
|
if (
|
|
1071
1114
|
!objectiveId ||
|
|
1072
1115
|
!SAFE_CHANNEL_OR_LOOP_ID_RE.test(objectiveId) ||
|
|
1073
|
-
objectiveId
|
|
1116
|
+
isReservedIdKey(objectiveId) ||
|
|
1074
1117
|
EVIDENCE_CTRL_RE.test(objectiveId) ||
|
|
1075
1118
|
EVIDENCE_SECRET_RE.test(objectiveId)
|
|
1076
1119
|
) {
|
|
@@ -1097,13 +1140,16 @@ export interface ValidatedListLoopsFilter {
|
|
|
1097
1140
|
export function validateListLoopsInput(
|
|
1098
1141
|
args: unknown,
|
|
1099
1142
|
): { ok: true; value: ValidatedListLoopsFilter } | { ok: false; error: string } {
|
|
1143
|
+
if (hasOwnProto(args)) {
|
|
1144
|
+
return { ok: false, error: 'list_loops arguments cannot define own "__proto__".' };
|
|
1145
|
+
}
|
|
1100
1146
|
const a = args && typeof args === "object" && !Array.isArray(args)
|
|
1101
1147
|
? (args as Record<string, unknown>)
|
|
1102
1148
|
: {};
|
|
1103
1149
|
const out: ValidatedListLoopsFilter = {};
|
|
1104
1150
|
if (a.channel_id !== undefined && a.channel_id !== null) {
|
|
1105
1151
|
const cid = typeof a.channel_id === "string" ? a.channel_id.trim() : "";
|
|
1106
|
-
if (!SAFE_CHANNEL_OR_LOOP_ID_RE.test(cid) || cid.
|
|
1152
|
+
if (!SAFE_CHANNEL_OR_LOOP_ID_RE.test(cid) || isReservedIdKey(cid) || EVIDENCE_CTRL_RE.test(cid) || EVIDENCE_SECRET_RE.test(cid)) {
|
|
1107
1153
|
return { ok: false, error: "list_loops channel_id must be a valid channel identifier." };
|
|
1108
1154
|
}
|
|
1109
1155
|
out.channel_id = cid;
|
|
@@ -1122,7 +1168,7 @@ export function validateListLoopsInput(
|
|
|
1122
1168
|
}
|
|
1123
1169
|
if (a.objective_id !== undefined && a.objective_id !== null) {
|
|
1124
1170
|
const oid = typeof a.objective_id === "string" ? a.objective_id.trim() : "";
|
|
1125
|
-
if (!SAFE_OBJECTIVE_ID_RE.test(oid) || EVIDENCE_SECRET_RE.test(oid)) {
|
|
1171
|
+
if (!SAFE_OBJECTIVE_ID_RE.test(oid) || isReservedIdKey(oid) || EVIDENCE_SECRET_RE.test(oid)) {
|
|
1126
1172
|
return { ok: false, error: "list_loops objective_id must be a valid objective identifier." };
|
|
1127
1173
|
}
|
|
1128
1174
|
out.objective_id = oid;
|
|
@@ -1146,6 +1192,9 @@ export interface ValidatedLoadMemoryInput {
|
|
|
1146
1192
|
export function validateLoadMemoryInput(
|
|
1147
1193
|
args: unknown,
|
|
1148
1194
|
): { ok: true; value: ValidatedLoadMemoryInput } | { ok: false; error: string } {
|
|
1195
|
+
if (hasOwnProto(args)) {
|
|
1196
|
+
return { ok: false, error: 'load_memory arguments cannot define own "__proto__".' };
|
|
1197
|
+
}
|
|
1149
1198
|
const a = args && typeof args === "object" && !Array.isArray(args)
|
|
1150
1199
|
? (args as Record<string, unknown>)
|
|
1151
1200
|
: {};
|
|
@@ -1158,7 +1207,7 @@ export function validateLoadMemoryInput(
|
|
|
1158
1207
|
if (trimmed) {
|
|
1159
1208
|
if (
|
|
1160
1209
|
!SAFE_MEMORY_NAME_RE.test(trimmed) ||
|
|
1161
|
-
trimmed
|
|
1210
|
+
isReservedIdKey(trimmed) ||
|
|
1162
1211
|
EVIDENCE_CTRL_RE.test(trimmed) ||
|
|
1163
1212
|
EVIDENCE_SECRET_RE.test(trimmed)
|
|
1164
1213
|
) {
|
|
@@ -1185,6 +1234,9 @@ export function validateLoadMemoryInput(
|
|
|
1185
1234
|
export function validateDeleteMemoryInput(
|
|
1186
1235
|
args: unknown,
|
|
1187
1236
|
): { ok: true; value: ValidatedDeleteMemoryInput } | { ok: false; error: string } {
|
|
1237
|
+
if (hasOwnProto(args)) {
|
|
1238
|
+
return { ok: false, error: 'delete_memory arguments cannot define own "__proto__".' };
|
|
1239
|
+
}
|
|
1188
1240
|
const a = args && typeof args === "object" && !Array.isArray(args)
|
|
1189
1241
|
? (args as Record<string, unknown>)
|
|
1190
1242
|
: {};
|
|
@@ -1192,7 +1244,7 @@ export function validateDeleteMemoryInput(
|
|
|
1192
1244
|
if (
|
|
1193
1245
|
!name ||
|
|
1194
1246
|
!SAFE_MEMORY_NAME_RE.test(name) ||
|
|
1195
|
-
name
|
|
1247
|
+
isReservedIdKey(name) ||
|
|
1196
1248
|
EVIDENCE_CTRL_RE.test(name) ||
|
|
1197
1249
|
EVIDENCE_SECRET_RE.test(name)
|
|
1198
1250
|
) {
|
|
@@ -1240,7 +1292,7 @@ export function validateOkrParentIdOptionalInput(
|
|
|
1240
1292
|
}
|
|
1241
1293
|
if (
|
|
1242
1294
|
!SAFE_CHANNEL_OR_LOOP_ID_RE.test(trimmed) ||
|
|
1243
|
-
trimmed
|
|
1295
|
+
isReservedIdKey(trimmed) ||
|
|
1244
1296
|
EVIDENCE_CTRL_RE.test(trimmed)
|
|
1245
1297
|
) {
|
|
1246
1298
|
return { ok: false, error: "parent_id must be a valid objective identifier" };
|
|
@@ -1251,7 +1303,7 @@ export function validateOkrParentIdOptionalInput(
|
|
|
1251
1303
|
export function validateOkrReparentObjectiveInput(
|
|
1252
1304
|
args: unknown,
|
|
1253
1305
|
): { ok: true; value: { objective_id: string; body: Record<string, unknown> } } | { ok: false; error: string } {
|
|
1254
|
-
if (!args || typeof args !== "object" || Array.isArray(args)) {
|
|
1306
|
+
if (!args || typeof args !== "object" || Array.isArray(args) || hasOwnProto(args)) {
|
|
1255
1307
|
return { ok: false, error: "okr_reparent_objective requires objective_id and parent_id." };
|
|
1256
1308
|
}
|
|
1257
1309
|
const a = args as Record<string, unknown>;
|
|
@@ -1259,7 +1311,7 @@ export function validateOkrReparentObjectiveInput(
|
|
|
1259
1311
|
if (
|
|
1260
1312
|
!objectiveId ||
|
|
1261
1313
|
!SAFE_CHANNEL_OR_LOOP_ID_RE.test(objectiveId) ||
|
|
1262
|
-
objectiveId
|
|
1314
|
+
isReservedIdKey(objectiveId) ||
|
|
1263
1315
|
EVIDENCE_CTRL_RE.test(objectiveId) ||
|
|
1264
1316
|
EVIDENCE_SECRET_RE.test(objectiveId)
|
|
1265
1317
|
) {
|
|
@@ -1281,7 +1333,7 @@ export function validateOkrReparentObjectiveInput(
|
|
|
1281
1333
|
}
|
|
1282
1334
|
if (
|
|
1283
1335
|
!SAFE_CHANNEL_OR_LOOP_ID_RE.test(trimmedParent) ||
|
|
1284
|
-
trimmedParent
|
|
1336
|
+
isReservedIdKey(trimmedParent) ||
|
|
1285
1337
|
EVIDENCE_CTRL_RE.test(trimmedParent)
|
|
1286
1338
|
) {
|
|
1287
1339
|
return { ok: false, error: "parent_id must be a valid objective identifier or null to detach" };
|
|
@@ -1338,9 +1390,9 @@ function validateChannelDocRoomId(
|
|
|
1338
1390
|
if (
|
|
1339
1391
|
!chatId ||
|
|
1340
1392
|
!OKR_DOC_CHANNEL_ID_RE.test(chatId) ||
|
|
1341
|
-
/^dm
|
|
1393
|
+
/^dm[-:]/i.test(chatId) ||
|
|
1342
1394
|
chatId === "direct" ||
|
|
1343
|
-
chatId
|
|
1395
|
+
isReservedIdKey(chatId) ||
|
|
1344
1396
|
EVIDENCE_CTRL_RE.test(chatId)
|
|
1345
1397
|
) {
|
|
1346
1398
|
return { ok: false, error: `${toolName} requires a valid non-DM room chat_id (1..80 chars).` };
|
|
@@ -1356,7 +1408,7 @@ export function validateChannelDocIdInput(
|
|
|
1356
1408
|
toolName = "channel_doc",
|
|
1357
1409
|
): { ok: true; value: string } | { ok: false; error: string } {
|
|
1358
1410
|
const docId = typeof raw === "string" ? raw.trim() : "";
|
|
1359
|
-
if (!docId || !SAFE_CHANNEL_DOC_ID_RE.test(docId) || EVIDENCE_CTRL_RE.test(docId)) {
|
|
1411
|
+
if (!docId || !SAFE_CHANNEL_DOC_ID_RE.test(docId) || isReservedIdKey(docId) || EVIDENCE_CTRL_RE.test(docId)) {
|
|
1360
1412
|
return { ok: false, error: `${toolName} doc_id must match ^[A-Za-z0-9_-]{1,64}$.` };
|
|
1361
1413
|
}
|
|
1362
1414
|
if (EVIDENCE_SECRET_RE.test(docId)) {
|
|
@@ -1374,6 +1426,9 @@ export interface ValidatedListChannelDocsInput {
|
|
|
1374
1426
|
export function validateListChannelDocsInput(
|
|
1375
1427
|
args: unknown,
|
|
1376
1428
|
): { ok: true; value: ValidatedListChannelDocsInput } | { ok: false; error: string } {
|
|
1429
|
+
if (hasOwnProto(args)) {
|
|
1430
|
+
return { ok: false, error: 'list_channel_docs arguments cannot define own "__proto__".' };
|
|
1431
|
+
}
|
|
1377
1432
|
const a = args && typeof args === "object" && !Array.isArray(args)
|
|
1378
1433
|
? (args as Record<string, unknown>)
|
|
1379
1434
|
: {};
|
|
@@ -1406,6 +1461,9 @@ export function validateArchiveChannelDocInput(
|
|
|
1406
1461
|
args: unknown,
|
|
1407
1462
|
toolName = "archive_channel_doc",
|
|
1408
1463
|
): { ok: true; value: ValidatedArchiveChannelDocInput } | { ok: false; error: string } {
|
|
1464
|
+
if (hasOwnProto(args)) {
|
|
1465
|
+
return { ok: false, error: `${toolName} arguments cannot define own "__proto__".` };
|
|
1466
|
+
}
|
|
1409
1467
|
const a = args && typeof args === "object" && !Array.isArray(args)
|
|
1410
1468
|
? (args as Record<string, unknown>)
|
|
1411
1469
|
: {};
|
|
@@ -1495,6 +1553,9 @@ function hasValidSkillFrontmatter(markdown: string): boolean {
|
|
|
1495
1553
|
export function validateUpsertChannelDocInput(
|
|
1496
1554
|
args: unknown,
|
|
1497
1555
|
): { ok: true; value: ValidatedUpsertChannelDocResult } | { ok: false; error: string } {
|
|
1556
|
+
if (hasOwnProto(args)) {
|
|
1557
|
+
return { ok: false, error: 'upsert_channel_doc arguments cannot define own "__proto__".' };
|
|
1558
|
+
}
|
|
1498
1559
|
const a = args && typeof args === "object" && !Array.isArray(args)
|
|
1499
1560
|
? (args as Record<string, unknown>)
|
|
1500
1561
|
: {};
|
|
@@ -1584,19 +1645,19 @@ const PERSONAL_SKILL_BODY_MAX_CHARS = 100_000;
|
|
|
1584
1645
|
export function derivePersonalSkillSlug(rawDocId: unknown, rawName: string): string {
|
|
1585
1646
|
if (typeof rawDocId === "string" && rawDocId.trim()) {
|
|
1586
1647
|
const trimmed = rawDocId.trim();
|
|
1587
|
-
if (SAFE_PERSONAL_SKILL_SLUG_RE.test(trimmed) && !trimmed
|
|
1648
|
+
if (SAFE_PERSONAL_SKILL_SLUG_RE.test(trimmed) && !isReservedIdKey(trimmed)) {
|
|
1588
1649
|
return trimmed;
|
|
1589
1650
|
}
|
|
1590
1651
|
}
|
|
1591
|
-
|
|
1652
|
+
const fallback =
|
|
1592
1653
|
String(rawDocId || rawName)
|
|
1593
1654
|
.toLowerCase()
|
|
1594
1655
|
.replace(/[^a-z0-9._-]+/g, "-")
|
|
1595
1656
|
.replace(/^[^a-z0-9]+/, "")
|
|
1596
1657
|
.replace(/[^a-z0-9]+$/, "")
|
|
1597
1658
|
.replace(/\.{2,}/g, "-")
|
|
1598
|
-
.slice(0, 64) || "skill"
|
|
1599
|
-
);
|
|
1659
|
+
.slice(0, 64) || "skill";
|
|
1660
|
+
return isReservedIdKey(fallback) ? "skill" : fallback;
|
|
1600
1661
|
}
|
|
1601
1662
|
|
|
1602
1663
|
export function validatePersonalSkillSlugInput(
|
|
@@ -1607,7 +1668,7 @@ export function validatePersonalSkillSlugInput(
|
|
|
1607
1668
|
if (
|
|
1608
1669
|
!slug ||
|
|
1609
1670
|
!SAFE_PERSONAL_SKILL_SLUG_RE.test(slug) ||
|
|
1610
|
-
slug
|
|
1671
|
+
isReservedIdKey(slug) ||
|
|
1611
1672
|
EVIDENCE_CTRL_RE.test(slug) ||
|
|
1612
1673
|
EVIDENCE_SECRET_RE.test(slug)
|
|
1613
1674
|
) {
|
|
@@ -1627,6 +1688,9 @@ export type ValidatedLoadSkillTarget =
|
|
|
1627
1688
|
export function validateLoadSkillInput(
|
|
1628
1689
|
args: unknown,
|
|
1629
1690
|
): { ok: true; value: ValidatedLoadSkillTarget } | { ok: false; error: string } {
|
|
1691
|
+
if (hasOwnProto(args)) {
|
|
1692
|
+
return { ok: false, error: 'load_skill arguments cannot define own "__proto__".' };
|
|
1693
|
+
}
|
|
1630
1694
|
const a = args && typeof args === "object" && !Array.isArray(args)
|
|
1631
1695
|
? (args as Record<string, unknown>)
|
|
1632
1696
|
: {};
|
|
@@ -1678,7 +1742,20 @@ export function validateLoadSkillInput(
|
|
|
1678
1742
|
error: "load_skill include_revisions is supported for personal skills (name) or channel skills (chat_id + doc_id), not built-in global skills.",
|
|
1679
1743
|
};
|
|
1680
1744
|
}
|
|
1745
|
+
if (a.skill_id !== undefined && a.skill_id !== null && typeof a.skill_id !== "string") {
|
|
1746
|
+
return { ok: false, error: "load_skill skill_id must be a string when provided." };
|
|
1747
|
+
}
|
|
1681
1748
|
const skillId = hasSkillId ? (a.skill_id as string).trim() : undefined;
|
|
1749
|
+
if (
|
|
1750
|
+
skillId !== undefined &&
|
|
1751
|
+
(!SAFE_CHANNEL_DOC_ID_RE.test(skillId) ||
|
|
1752
|
+
isReservedIdKey(skillId) ||
|
|
1753
|
+
skillId in Object.prototype ||
|
|
1754
|
+
EVIDENCE_CTRL_RE.test(skillId) ||
|
|
1755
|
+
EVIDENCE_SECRET_RE.test(skillId))
|
|
1756
|
+
) {
|
|
1757
|
+
return { ok: false, error: "load_skill skill_id must be a valid global skill identifier." };
|
|
1758
|
+
}
|
|
1682
1759
|
return { ok: true, value: { scope: "global", ...(skillId ? { skill_id: skillId } : {}) } };
|
|
1683
1760
|
}
|
|
1684
1761
|
|
|
@@ -1718,6 +1795,9 @@ export type ValidatedSaveSkillResult =
|
|
|
1718
1795
|
export function validateSaveSkillInput(
|
|
1719
1796
|
args: unknown,
|
|
1720
1797
|
): { ok: true; value: ValidatedSaveSkillResult } | { ok: false; error: string } {
|
|
1798
|
+
if (hasOwnProto(args)) {
|
|
1799
|
+
return { ok: false, error: 'save_skill arguments cannot define own "__proto__".' };
|
|
1800
|
+
}
|
|
1721
1801
|
const a = args && typeof args === "object" && !Array.isArray(args)
|
|
1722
1802
|
? (args as Record<string, unknown>)
|
|
1723
1803
|
: {};
|