@absolutejs/agent-control 0.3.0 → 0.4.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/README.md CHANGED
@@ -6,7 +6,8 @@ before cleanup, reports partial source failures, restores deliberately, and uses
6
6
  leased idempotency records so operator retries cannot change the requested input.
7
7
 
8
8
  Scopes are `agents:read`, `agents:revoke`, and `agents:restore`. Mutations require
9
- an `operationId` and `reason`; PostgreSQL operations can be safely reclaimed
9
+ an `operationId`, bounded `reason`, same-origin `Origin` header, and
10
+ `X-Agent-Control-Intent: mutate`; PostgreSQL operations can be safely reclaimed
10
11
  after a crashed operator process's lease expires.
11
12
 
12
13
  `createAgentControlConsoleHandler()` adds a dependency-free authenticated
package/dist/index.js CHANGED
@@ -339,11 +339,20 @@ var createAgentControlHandler = ({
339
339
  return Response.json(await control.inventory(agentId));
340
340
  if (request.method !== "POST" || action !== "revoke" && action !== "restore")
341
341
  return new Response(null, { status: 405 });
342
- const body = await request.json().catch(() => {
343
- return;
344
- });
345
- if (!body?.operationId || !body.reason)
346
- return Response.json({ error: "operationId and reason are required" }, { status: 400 });
342
+ if (request.headers.get("origin") !== url.origin || request.headers.get("x-agent-control-intent") !== "mutate")
343
+ return new Response("Cross-site mutation denied", { status: 403 });
344
+ const raw = await request.text();
345
+ if (new TextEncoder().encode(raw).byteLength > 4096)
346
+ return Response.json({ error: "Request body is too large" }, { status: 413 });
347
+ const body = (() => {
348
+ try {
349
+ return JSON.parse(raw);
350
+ } catch {
351
+ return;
352
+ }
353
+ })();
354
+ if (!body?.operationId || body.operationId.length > 200 || !body.reason || body.reason.length > 1000)
355
+ return Response.json({ error: "A bounded operationId and reason are required" }, { status: 400 });
347
356
  const digest2 = await hash2({ action, agentId, reason: body.reason });
348
357
  let claim;
349
358
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/agent-control",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Authenticated AI agent operator API, console, and bound plan-then-execute playground.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,7 +40,7 @@
40
40
  "check:package": "bun run format && bun run typecheck && bun run test && bun run build"
41
41
  },
42
42
  "dependencies": {
43
- "@absolutejs/agency": "^0.4.0",
43
+ "@absolutejs/agency": "^0.5.0",
44
44
  "@absolutejs/manifest": "^0.3.0",
45
45
  "@sinclair/typebox": "^0.34.0"
46
46
  },