vantage-peers-mcp 5.0.0 → 5.0.2
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 +19 -0
- package/README.md +16 -1
- package/dist/src/auth.js +3 -1
- package/dist/src/fresh-state-guard.js +7 -3
- package/dist/src/tools.d.ts +14 -0
- package/dist/src/tools.js +149 -69
- package/dist/src/validate-task-payload-re.js +20 -5
- package/dist/src/validate-task-payload.js +7 -2
- package/dist/src/verifiedActor.d.ts +12 -0
- package/dist/src/verifiedActor.js +22 -5
- package/dist/src/whoamiIdentity.js +11 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [5.0.2] — 2026-11-24
|
|
6
|
+
|
|
7
|
+
A patch release. Tool inputs and outputs are unchanged. Each entry names the product it concerns.
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- Cloud and Self-host: `next_task` works for a master-scope caller. Such a caller got `RBAC_DENIED` (`claimless-service-account`) because it resolves no organisation and sent no claim. A master caller with a verified agent ID now sends that agent (`verifiedActor`), and the backend judges it as an agent of the operator organisation. An organisation seat still sends its organisation only and is still refused for another organisation's assignee. A Clerk session sends no claim. A master caller with no agent ID is still refused. `get_tool_usage` and `get_owner_tool_usage` are unchanged here: their backend doors do not yet accept an agent claim. ([Tool inputs and outputs](README.md#tool-inputs-and-outputs))
|
|
12
|
+
- Self-host: no backend change. The required backend contract stays 29 with 153 called functions. ([Backend compatibility check](README.md#backend-compatibility-check))
|
|
13
|
+
|
|
14
|
+
## [5.0.1] — 2026-11-24
|
|
15
|
+
|
|
16
|
+
A patch release. Tool inputs are unchanged, and so are the outputs for a backend that answers its contract. Each entry names the product it concerns.
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- Cloud and Self-host: `reorder_queue` now names only the callers MCP admits: the assignee agent and a queue coordinator its organisation lists. A person bearer is refused; a person sets a queue from a signed-in session. The 5.0.0 description also named an organisation admin, which MCP never admitted. ([Tool inputs and outputs](README.md#tool-inputs-and-outputs))
|
|
21
|
+
- Cloud and Self-host: a backend reply that breaks its contract (null, a shapeless object, or an envelope without its array) now fails with `BACKEND_SHAPE_MISMATCH`, naming the tool and the backend door, and the outcome is reported as unknown. Before, it was read as an empty list or a default. This covers `reorder_queue` and `next_task`, `list_tasks` (every sort), and 23 other list and read tools: `list_peers`, `list_messages`, `search_messages_by_keyword`, `search_tasks_by_keyword`, `list_tasks_by_mission`, `list_missions`, `list_briefing_notes`, `search_briefing_notes_by_keyword`, `list_recurring_tasks`, `list_mandates`, `list_issues`, `search_fix_patterns`, `list_fix_patterns`, `list_errors`, `get_tool_usage`, `get_owner_tool_usage`, `list_blocked_on_me`, `list_episodes`, `list_memories`, `list_diaries`, `list_bus`, `list_repo_mappings` and `get_github_owner_bindings`. A well-formed empty reply still returns an empty list, and a backend refusal is still reported as a refusal. `check_messages` keeps its documented tolerance of an older backend. ([Tool inputs and outputs](README.md#tool-inputs-and-outputs))
|
|
22
|
+
- Self-host: no backend change. The required backend contract stays 29 with 153 called functions, so a 5.0.0 backend serves 5.0.1 as is. ([Backend compatibility check](README.md#backend-compatibility-check))
|
|
23
|
+
|
|
5
24
|
## [5.0.0] — 2026-11-24
|
|
6
25
|
|
|
7
26
|
Customer-facing summary of every `mcp-server/` change since 4.1.0. Each entry says which product it concerns (VantagePeers Cloud, the hosted service; VantagePeers Self-host, the separate product) and links the README section that documents it. This is a major release because tool inputs and output shapes changed (see the package's [Versioning](README.md#versioning) rules).
|
package/README.md
CHANGED
|
@@ -343,7 +343,7 @@ _Applies to: Cloud and Self-host._
|
|
|
343
343
|
- **Dependencies append.** `add_task_dependency` and `block_task` (`blockedBy`) add to a task's existing dependencies, deduplicated, and answer the resulting list; they no longer replace it. `update_task` `dependsOn` stays the explicit replace. `link_commit_to_issue` skips a commit SHA already recorded.
|
|
344
344
|
- **Tool usage.** `get_tool_usage` lists which MCP tools a caller has called, with first call, last call and call count; `get_owner_tool_usage` sums that across the agents a person owns.
|
|
345
345
|
- **Refusal codes.** A refused `send_message` carries `RBAC_DENIED` or `INVALID_RECIPIENTS`, and a missing message `MESSAGE_NOT_FOUND`, instead of a bare server error.
|
|
346
|
-
- **Task queue.** `reorder_queue` sets one agent's queue (`assignedToAgentId`, `taskIds`): listed tasks get ranks 1 to N, the agent's other open tasks lose their rank, `[]` clears it.
|
|
346
|
+
- **Task queue.** `reorder_queue` sets one agent's queue (`assignedToAgentId`, `taskIds`): listed tasks get ranks 1 to N, the agent's other open tasks lose their rank, `[]` clears it. Over MCP it is open to the assignee agent itself and to a listed queue coordinator; a person bearer is refused (a person sets a queue from a signed-in session, not through this tool). `next_task` returns the first task of that queue the agent can take (rank, then priority, then age, dependencies done) or `found: false`. `list_tasks` with `sort: "queue"` lists in that order; without `sort` it is unchanged.
|
|
347
347
|
- **Project is required.** `create_task` refuses a missing, empty or blank `project`; `update_task` refuses setting it to empty. `billing_summary_by_project` keeps `unattributedTaskCount` and adds `noProjectCount` and `noDurationCount`; `listNoDuration: true` also returns up to 200 tasks with a project and no measured duration (`noDurationTasks`, `noDurationTasksTruncated`).
|
|
348
348
|
- **Task windows.** `list_tasks` with `updatedSince` pages a window of any size, newest-updated first, with an opaque cursor. A combination the indexes cannot serve is refused with the remedy in the message, never answered with a partial page.
|
|
349
349
|
- **Erase.** `erase_row` deletes one row of the eleven covered tables, `erase_fix_pattern` one fix pattern, `erase_memory` the matching text of a memory. An organisation admin may erase any row of the organisation; an author the rows it wrote (a person by verified identity, an agent by its agent ID); any other caller is refused `RBAC_DENIED`. Erasing a memory covers every version of it.
|
|
@@ -407,6 +407,21 @@ So upgrade in this order: deploy the backend of the same release first, then upg
|
|
|
407
407
|
|
|
408
408
|
## Release notes
|
|
409
409
|
|
|
410
|
+
### 5.0.2
|
|
411
|
+
|
|
412
|
+
_Applies to: Cloud and Self-host._ A patch release: tool inputs and outputs are unchanged.
|
|
413
|
+
|
|
414
|
+
- Cloud and Self-host: `next_task` serves a master-scope caller that has a verified agent ID. That caller now sends the agent as its claim; organisation seats are unchanged (see [Tool inputs and outputs](#tool-inputs-and-outputs)).
|
|
415
|
+
- Self-host: no backend change; contract 29, 153 called functions (see [Backend compatibility check](#backend-compatibility-check)).
|
|
416
|
+
|
|
417
|
+
### 5.0.1
|
|
418
|
+
|
|
419
|
+
_Applies to: Cloud and Self-host._ A patch release: tool inputs are unchanged, and so are the outputs for a backend that answers its contract.
|
|
420
|
+
|
|
421
|
+
- Cloud and Self-host: `reorder_queue` names only the callers MCP admits (the assignee, or a listed queue coordinator); a person bearer is refused (see [Tool inputs and outputs](#tool-inputs-and-outputs)).
|
|
422
|
+
- Cloud and Self-host: a backend reply that breaks its contract fails with `BACKEND_SHAPE_MISMATCH` instead of reading as an empty list. This applies to `reorder_queue`, `next_task`, `list_tasks` and 23 other list and read tools; `check_messages` keeps its documented tolerance (see [Tool inputs and outputs](#tool-inputs-and-outputs)).
|
|
423
|
+
- Self-host: no backend change; contract 29, 153 called functions (see [Backend compatibility check](#backend-compatibility-check)).
|
|
424
|
+
|
|
410
425
|
### 5.0.0
|
|
411
426
|
|
|
412
427
|
_Applies to: Cloud and Self-host._ Each item names the product it concerns. A major release: tool inputs and output shapes changed.
|
package/dist/src/auth.js
CHANGED
|
@@ -421,7 +421,9 @@ export function resolveSeatOrg(ctx) {
|
|
|
421
421
|
// (`oauth:getAccessTokenByHash`), never from an argument. Forwarded so the
|
|
422
422
|
// Convex door keys the seat by ID, not by the reusable label. Only the token
|
|
423
423
|
// path carries it; an agent-credential-only seat forwards the label alone.
|
|
424
|
-
const orgClerkId = fromToken !== undefined &&
|
|
424
|
+
const orgClerkId = fromToken !== undefined &&
|
|
425
|
+
ctx.orgClerkId !== undefined &&
|
|
426
|
+
ctx.orgClerkId !== ""
|
|
425
427
|
? ctx.orgClerkId
|
|
426
428
|
: undefined;
|
|
427
429
|
return {
|
|
@@ -277,7 +277,9 @@ async function checkPrClaims(text, deps, warn) {
|
|
|
277
277
|
const matches = [];
|
|
278
278
|
for (const line of text.split("\n")) {
|
|
279
279
|
const explicit = [...line.matchAll(PR_CLAIM_RE)];
|
|
280
|
-
matches.push(...(explicit.length > 0
|
|
280
|
+
matches.push(...(explicit.length > 0
|
|
281
|
+
? explicit
|
|
282
|
+
: [...line.matchAll(GH_PR_CMD_CLAIM_RE)]));
|
|
281
283
|
}
|
|
282
284
|
for (const m of matches) {
|
|
283
285
|
const [, number, repoInClaim, typedStateRaw] = m;
|
|
@@ -436,13 +438,15 @@ export async function guardFreshState(content, deps) {
|
|
|
436
438
|
return;
|
|
437
439
|
if (OVERRIDE_RE.test(content))
|
|
438
440
|
return;
|
|
439
|
-
const warn = deps.warn ??
|
|
441
|
+
const warn = deps.warn ??
|
|
442
|
+
((message) => console.warn(`[fresh-state-guard] ${message}`));
|
|
440
443
|
const scope = evidenceScope(content);
|
|
441
444
|
if (!scope.trim())
|
|
442
445
|
return;
|
|
443
446
|
// Bare-literal check, before any network call: a refusal that needs no
|
|
444
447
|
// live read cannot be turned into a pass by an unreachable registry.
|
|
445
|
-
const log = deps.log ??
|
|
448
|
+
const log = deps.log ??
|
|
449
|
+
((message) => console.error(`[fresh-state-guard] ${message}`));
|
|
446
450
|
const lines = scope.split("\n");
|
|
447
451
|
let firstBare;
|
|
448
452
|
let any = false;
|
package/dist/src/tools.d.ts
CHANGED
|
@@ -285,6 +285,20 @@ export declare function mcpRefused(tool: string, door: string): {
|
|
|
285
285
|
}>;
|
|
286
286
|
isError: true;
|
|
287
287
|
};
|
|
288
|
+
export declare function mcpBackendShapeMismatch(tool: string, door: string, expected: string): {
|
|
289
|
+
content: Array<{
|
|
290
|
+
type: "text";
|
|
291
|
+
text: string;
|
|
292
|
+
}>;
|
|
293
|
+
isError: true;
|
|
294
|
+
};
|
|
295
|
+
/** Thrown by `requireRows`; every tool's catch turns it into the named refusal. */
|
|
296
|
+
export declare class BackendShapeMismatchError extends Error {
|
|
297
|
+
readonly tool: string;
|
|
298
|
+
readonly door: string;
|
|
299
|
+
readonly expected: string;
|
|
300
|
+
constructor(tool: string, door: string, expected: string);
|
|
301
|
+
}
|
|
288
302
|
export interface ParsedConvexError {
|
|
289
303
|
code: string;
|
|
290
304
|
message: string;
|
package/dist/src/tools.js
CHANGED
|
@@ -861,6 +861,60 @@ export function mcpRefused(tool, door) {
|
|
|
861
861
|
isError: true,
|
|
862
862
|
};
|
|
863
863
|
}
|
|
864
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
865
|
+
// Helper: a backend reply that breaks its `returns:` contract is refused
|
|
866
|
+
//
|
|
867
|
+
// A tool that substitutes a default for a reply it could not read (a count taken
|
|
868
|
+
// from the request, an empty queue) turns a contract break into a success. The
|
|
869
|
+
// named refusal below states what the tool expected and which door answered, and
|
|
870
|
+
// says the call's outcome is unknown.
|
|
871
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
872
|
+
export function mcpBackendShapeMismatch(tool, door, expected) {
|
|
873
|
+
return mcpError(`BACKEND_SHAPE_MISMATCH: ${tool} got a reply from the backend door "${door}" that does not match its contract (expected ${expected}). ` +
|
|
874
|
+
`The outcome of this call is unknown: do not read it as success or as an empty result; report it as a backend contract break.`);
|
|
875
|
+
}
|
|
876
|
+
function isPlainObject(v) {
|
|
877
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
878
|
+
}
|
|
879
|
+
/**
|
|
880
|
+
* The rows of a backend list reply, or null when the reply is not an array.
|
|
881
|
+
* A caller that gets null refuses with `mcpBackendShapeMismatch`: a reply that
|
|
882
|
+
* breaks the door's `returns:` contract is never read as an empty list.
|
|
883
|
+
*/
|
|
884
|
+
function asRows(reply) {
|
|
885
|
+
return Array.isArray(reply) ? reply : null;
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* The rows of a list door documented as "an array, or an envelope `{ items: array }`".
|
|
889
|
+
* Anything else (null, a string, an envelope whose `items` is not an array) is a
|
|
890
|
+
* contract break, never an empty list.
|
|
891
|
+
*/
|
|
892
|
+
function requireItems(reply, tool, door) {
|
|
893
|
+
if (Array.isArray(reply))
|
|
894
|
+
return reply;
|
|
895
|
+
if (isPlainObject(reply) && Array.isArray(reply.items))
|
|
896
|
+
return reply.items;
|
|
897
|
+
throw new BackendShapeMismatchError(tool, door, "an array, or { items: array, ... }");
|
|
898
|
+
}
|
|
899
|
+
/** Thrown by `requireRows`; every tool's catch turns it into the named refusal. */
|
|
900
|
+
export class BackendShapeMismatchError extends Error {
|
|
901
|
+
tool;
|
|
902
|
+
door;
|
|
903
|
+
expected;
|
|
904
|
+
constructor(tool, door, expected) {
|
|
905
|
+
super(`BACKEND_SHAPE_MISMATCH: ${tool} ${door} ${expected}`);
|
|
906
|
+
this.tool = tool;
|
|
907
|
+
this.door = door;
|
|
908
|
+
this.expected = expected;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
/** The rows of a backend list reply; a non-array reply is a contract break, never []. */
|
|
912
|
+
function requireRows(reply, tool, door, expected) {
|
|
913
|
+
const rows = asRows(reply);
|
|
914
|
+
if (rows === null)
|
|
915
|
+
throw new BackendShapeMismatchError(tool, door, expected);
|
|
916
|
+
return rows;
|
|
917
|
+
}
|
|
864
918
|
/**
|
|
865
919
|
* Parse a Convex error message string into a structured object.
|
|
866
920
|
*
|
|
@@ -934,6 +988,9 @@ export function parseConvexError(rawMessage) {
|
|
|
934
988
|
* used by `mcpError`.
|
|
935
989
|
*/
|
|
936
990
|
export function mcpConvexError(error) {
|
|
991
|
+
if (error instanceof BackendShapeMismatchError) {
|
|
992
|
+
return mcpBackendShapeMismatch(error.tool, error.door, error.expected);
|
|
993
|
+
}
|
|
937
994
|
// Empirical probe (Day 127, 2026-07-10 — Sigma): Convex redacts
|
|
938
995
|
// `error.message` to a bare "[Request ID: ...] Server Error" string for
|
|
939
996
|
// ConvexError throws, but the ACTUAL actionable payload passed to
|
|
@@ -1844,7 +1901,10 @@ async function listPeersFromOrgRoster(convex, oauthCtx) {
|
|
|
1844
1901
|
// and each keeps its own ID. An entry with no ID is keyed by its
|
|
1845
1902
|
// normalised name. Bounded.
|
|
1846
1903
|
const seen = new Map();
|
|
1847
|
-
|
|
1904
|
+
if (!Array.isArray(roster)) {
|
|
1905
|
+
return mcpBackendShapeMismatch(LIST_PEERS, directoryDoors.directory, "an array of agent directory entries");
|
|
1906
|
+
}
|
|
1907
|
+
for (const entry of roster) {
|
|
1848
1908
|
let name = null;
|
|
1849
1909
|
let agentId = null;
|
|
1850
1910
|
if (typeof entry === "string") {
|
|
@@ -2849,9 +2909,10 @@ options) {
|
|
|
2849
2909
|
const memories = await convex.query("memories:listMemories", queryArgs);
|
|
2850
2910
|
// S3.3 B8 — extract from Convex paginationOpts shape {value, continueCursor, isDone}
|
|
2851
2911
|
// Pre-fix bug: handler read memories?.page (undefined) → rawList = [] always.
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2912
|
+
if (!Array.isArray(memories?.value)) {
|
|
2913
|
+
return mcpBackendShapeMismatch("list_episodes", "memories:listMemories", "a page { value: array, continueCursor, isDone }");
|
|
2914
|
+
}
|
|
2915
|
+
const rawList = memories.value;
|
|
2855
2916
|
const filteredList = scopeFilterList(oauthCtx ?? DENIED_SCOPE_CTX, rawList);
|
|
2856
2917
|
// Encode continueCursor → opaque nextCursor token for the MCP caller.
|
|
2857
2918
|
const backendNextCursor = memories?.continueCursor ?? null;
|
|
@@ -3192,9 +3253,10 @@ options) {
|
|
|
3192
3253
|
const memories = await convex.query("memories:listMemories", queryArgs);
|
|
3193
3254
|
// S3.3 B8 — extract from Convex paginationOpts shape {value, continueCursor, isDone}
|
|
3194
3255
|
// Pre-fix bug: handler read memories?.page (undefined) → rawList = [] always.
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3256
|
+
if (!Array.isArray(memories?.value)) {
|
|
3257
|
+
return mcpBackendShapeMismatch("list_memories", "memories:listMemories", "a page { value: array, continueCursor, isDone }");
|
|
3258
|
+
}
|
|
3259
|
+
const rawList = memories.value;
|
|
3198
3260
|
// S3.1.A Wave A — row-level scope filter on the post-query list.
|
|
3199
3261
|
// Master + legacy bearer pass through unchanged. Non-master clients
|
|
3200
3262
|
// see only rows whose createdBy ∈ fromAllowList OR whose namespace
|
|
@@ -3681,8 +3743,11 @@ options) {
|
|
|
3681
3743
|
"tasks:listBlockedOnMe", {
|
|
3682
3744
|
...(tenantId !== undefined ? { tenantId } : {}),
|
|
3683
3745
|
});
|
|
3684
|
-
|
|
3685
|
-
|
|
3746
|
+
if (!isPlainObject(result) || !Array.isArray(result.entries)) {
|
|
3747
|
+
return mcpBackendShapeMismatch("list_blocked_on_me", "tasks:listBlockedOnMe", "{ entries: array, ... }");
|
|
3748
|
+
}
|
|
3749
|
+
const waiters = result;
|
|
3750
|
+
const entries = waiters.entries;
|
|
3686
3751
|
const shown = entries.slice(0, limit ?? 50);
|
|
3687
3752
|
// The same object is the text (unchanged) and the structuredContent the
|
|
3688
3753
|
// outputSchema validates (task k1793xkjhzh1xm23gmmwjgwfyx8htbv0).
|
|
@@ -3927,7 +3992,8 @@ options) {
|
|
|
3927
3992
|
// remap orchestratorId->createdBy before scopeFilterList, then
|
|
3928
3993
|
// strip the synthetic field back out (the output projection below
|
|
3929
3994
|
// never reads `createdBy`, so no explicit strip is needed).
|
|
3930
|
-
const
|
|
3995
|
+
const profileRows = requireRows(profiles, "list_peers", "profiles:listProfiles", "an array of profiles");
|
|
3996
|
+
const filteredProfiles = scopeFilterList(oauthCtx ?? DENIED_SCOPE_CTX, profileRows.map((p) => ({
|
|
3931
3997
|
...p,
|
|
3932
3998
|
createdBy: p.orchestratorId,
|
|
3933
3999
|
})));
|
|
@@ -3946,7 +4012,7 @@ options) {
|
|
|
3946
4012
|
// S3.3 B8 follow-up — emit nextCursor when page is full.
|
|
3947
4013
|
// Measured on the RAW page, before the scope filter narrowed it.
|
|
3948
4014
|
const requestedLimit = effectiveLimit ?? 20;
|
|
3949
|
-
const { nextCursor, scopeFiltered } = scopedPageContinuation(
|
|
4015
|
+
const { nextCursor, scopeFiltered } = scopedPageContinuation(profileRows, requestedLimit, filteredProfiles.length, { reportRemoved: oauthCtx?.clerkOrgSlug !== undefined });
|
|
3950
4016
|
const peersWithCursor = nextCursor !== null || scopeFiltered > 0
|
|
3951
4017
|
? {
|
|
3952
4018
|
items: peers,
|
|
@@ -4043,7 +4109,8 @@ options) {
|
|
|
4043
4109
|
// sender included. Same remedy as search_messages_by_keyword
|
|
4044
4110
|
// (tools.ts ~3399-3423): remap `from`->`createdBy` before
|
|
4045
4111
|
// scopeFilterList, then strip the synthetic field back out.
|
|
4046
|
-
const
|
|
4112
|
+
const messageRows = requireRows(messages, "list_messages", "messages:listMessages", "an array of messages");
|
|
4113
|
+
const filteredMessages = scopeFilterList(oauthCtx ?? DENIED_SCOPE_CTX, messageRows.map((m) => ({
|
|
4047
4114
|
...m,
|
|
4048
4115
|
createdBy: m.from,
|
|
4049
4116
|
}))).map(({ createdBy: _createdBy, ...rest }) => rest);
|
|
@@ -4053,9 +4120,7 @@ options) {
|
|
|
4053
4120
|
// full page whose rows the roster filter then dropped is still a
|
|
4054
4121
|
// page with more behind it.
|
|
4055
4122
|
const requestedLimit = effectiveLimit ?? 20;
|
|
4056
|
-
const messagesPage =
|
|
4057
|
-
? messages
|
|
4058
|
-
: [];
|
|
4123
|
+
const messagesPage = messageRows;
|
|
4059
4124
|
let nextCursor = null;
|
|
4060
4125
|
if (messagesPage.length >= requestedLimit && messagesPage.length > 0) {
|
|
4061
4126
|
const last = messagesPage[messagesPage.length - 1];
|
|
@@ -4175,9 +4240,8 @@ options) {
|
|
|
4175
4240
|
// which established the sanctioned remedy: remap the tool's real
|
|
4176
4241
|
// ownership field onto `createdBy` BEFORE calling scopeFilterList,
|
|
4177
4242
|
// then strip the synthetic field back out of the response.
|
|
4178
|
-
const
|
|
4179
|
-
|
|
4180
|
-
: []).map((m) => ({ ...m, createdBy: m.from }))).map(({ createdBy: _createdBy, ...rest }) => rest);
|
|
4243
|
+
const resultRows = requireRows(results, "search_messages_by_keyword", "messages:searchMessagesByKeyword", "an array of messages");
|
|
4244
|
+
const filteredResults = scopeFilterList(oauthCtx ?? DENIED_SCOPE_CTX, resultRows.map((m) => ({ ...m, createdBy: m.from }))).map(({ createdBy: _createdBy, ...rest }) => rest);
|
|
4181
4245
|
const capped = capPage(filteredResults, "search_messages_by_keyword", "array");
|
|
4182
4246
|
return {
|
|
4183
4247
|
content: [
|
|
@@ -4499,9 +4563,8 @@ options) {
|
|
|
4499
4563
|
// assignee must still see their own task in the list.
|
|
4500
4564
|
// TENANT GATE, collection surface — applied BEFORE the roster/owner
|
|
4501
4565
|
// filter, with the same predicate get_task applies to its one row.
|
|
4502
|
-
const
|
|
4503
|
-
|
|
4504
|
-
: []), ["assignedTo"]);
|
|
4566
|
+
const taskRows = requireRows(rawTasks, "list_tasks", "tasks:list", "an array of tasks");
|
|
4567
|
+
const scopedTasks = scopeFilterList(oauthCtx ?? DENIED_SCOPE_CTX, filterRowsToActorTenant(oauthCtx, taskRows), ["assignedTo"]);
|
|
4505
4568
|
const tasks = wantsFull
|
|
4506
4569
|
? scopedTasks
|
|
4507
4570
|
: scopedTasks.map((t) => ({
|
|
@@ -4524,10 +4587,8 @@ options) {
|
|
|
4524
4587
|
// narrowing filters above: a full page whose rows the roster filter
|
|
4525
4588
|
// then dropped still has more behind it.
|
|
4526
4589
|
const requestedLimit = effectiveLimit ?? 20;
|
|
4527
|
-
const tasksArr =
|
|
4528
|
-
const tasksPage =
|
|
4529
|
-
? rawTasks
|
|
4530
|
-
: [];
|
|
4590
|
+
const tasksArr = tasks;
|
|
4591
|
+
const tasksPage = taskRows;
|
|
4531
4592
|
let nextCursor = null;
|
|
4532
4593
|
// A queue-ordered page is not in creation order: a createdBefore cursor
|
|
4533
4594
|
// would skip rows, so none is minted.
|
|
@@ -4771,9 +4832,8 @@ options) {
|
|
|
4771
4832
|
// createdBy===caller || assignedTo===caller), so a non-creator
|
|
4772
4833
|
// assignee must still see their own task in search results.
|
|
4773
4834
|
// TENANT GATE, collection surface (same predicate as get_task).
|
|
4774
|
-
const
|
|
4775
|
-
|
|
4776
|
-
: []), ["assignedTo"]);
|
|
4835
|
+
const resultRows = requireRows(results, "search_tasks_by_keyword", "tasks:searchTasksByKeyword", "an array of tasks");
|
|
4836
|
+
const filteredFull = scopeFilterList(oauthCtx ?? DENIED_SCOPE_CTX, filterRowsToActorTenant(oauthCtx, resultRows), ["assignedTo"]);
|
|
4777
4837
|
const projected = wantsFull
|
|
4778
4838
|
? filteredFull
|
|
4779
4839
|
: filteredFull.map((t) => ({
|
|
@@ -5508,11 +5568,11 @@ options) {
|
|
|
5508
5568
|
// ── reorder_queue ───────────────────────────────────────────────────────────
|
|
5509
5569
|
defineTool(server, authCtx, {
|
|
5510
5570
|
kind: "filtered",
|
|
5511
|
-
reason: "unresolvedOrgDenial() refuses a bearer whose organisation cannot be resolved before any call; the caller gate itself is decided by its Convex door tasks:reorderQueue on the verified principal (a seat's verifiedActor, forwarded by the wrapped client
|
|
5571
|
+
reason: "unresolvedOrgDenial() refuses a bearer whose organisation cannot be resolved before any call; the caller gate itself is decided by its Convex door tasks:reorderQueue on the verified principal (a seat's verifiedActor, forwarded by the wrapped client): over MCP the callers that succeed are the assignee agent itself and a listed queue coordinator, in the assignee's own organisation; a person bearer carries no verifiedActor over MCP (withVerifiedActor returns the client unchanged when no agent ID resolves), so the door resolves the service-account session and refuses it, and an organisation admin acts from a signed-in session, not through this tool; the tool takes no acting name and relays the door's refusal unchanged (tasks k176p84j83gac7reyycweacyb58jvtxg, k17c5xftwzvtts05ban1dhxazs8jv4h6)",
|
|
5512
5572
|
}, "reorder_queue", "Set the explicit work queue of one agent: the listed tasks get ranks 1..N in the order given (1 = next), and every other open task of that agent loses its rank. " +
|
|
5513
5573
|
"A FULL REPLACEMENT: an empty taskIds clears the whole queue. The order is set without dependencies: a task listed before the task it depends on is still not handed out by next_task until its dependencies are done. " +
|
|
5514
5574
|
"Each task must be an open task (todo, in_progress, review or blocked) assigned to that agent, listed once, at most 100 per call; one refused task changes nothing. " +
|
|
5515
|
-
"Who may call: the agent itself, a queue coordinator its organisation lists,
|
|
5575
|
+
"Who may call over MCP: the agent itself (the assignee), or a queue coordinator its organisation lists; anyone else is refused, including a person bearer (a person sets a queue from a signed-in session, not through this tool). " +
|
|
5516
5576
|
"Returns { ranked, cleared }: how many tasks now hold a rank and how many others lost theirs. A refusal (QUEUE_TASK_NOT_ASSIGNED, QUEUE_TASK_NOT_OPEN, QUEUE_TASK_DUPLICATE, QUEUE_TOO_LONG, RBAC_DENIED) is an error naming its cause, never a partial write. " +
|
|
5517
5577
|
"WHEN: to put an agent's backlog in the order it must be worked, or to clear that order. " +
|
|
5518
5578
|
"EXAMPLE: reorder_queue assignedToAgentId='r57bexrjnt2229qzchhj5bs3yh8j5ta1' taskIds=['k178d3ns...', 'k17bbbbb...']. " +
|
|
@@ -5545,9 +5605,16 @@ options) {
|
|
|
5545
5605
|
assignedToAgentId,
|
|
5546
5606
|
taskIds: taskIds.map((id) => id),
|
|
5547
5607
|
}));
|
|
5608
|
+
// The door's `returns:` is { ranked: number, cleared: number }: a reply
|
|
5609
|
+
// that is not that is refused, never completed with a default.
|
|
5610
|
+
if (!isPlainObject(result) ||
|
|
5611
|
+
typeof result.ranked !== "number" ||
|
|
5612
|
+
typeof result.cleared !== "number") {
|
|
5613
|
+
return mcpBackendShapeMismatch("reorder_queue", "tasks:reorderQueue", "{ ranked: number, cleared: number }");
|
|
5614
|
+
}
|
|
5548
5615
|
const structured = {
|
|
5549
|
-
ranked: result
|
|
5550
|
-
cleared: result
|
|
5616
|
+
ranked: result.ranked,
|
|
5617
|
+
cleared: result.cleared,
|
|
5551
5618
|
};
|
|
5552
5619
|
return {
|
|
5553
5620
|
content: [
|
|
@@ -5563,7 +5630,7 @@ options) {
|
|
|
5563
5630
|
// ── next_task ───────────────────────────────────────────────────────────────
|
|
5564
5631
|
defineTool(server, authCtx, {
|
|
5565
5632
|
kind: "filtered",
|
|
5566
|
-
reason: "tenant applied INSIDE the Convex read: doorScopeArgs() forwards verifiedOrg on every call to tasks:nextForAssignee and unresolvedOrgDenial() refuses a bearer with none;
|
|
5633
|
+
reason: "tenant applied INSIDE the Convex read: doorScopeArgs() forwards verifiedOrg on every call to tasks:nextForAssignee for a bearer that resolves an organisation, and unresolvedOrgDenial() refuses a non-master bearer with none; the fleet master, which resolves no organisation, is admitted by its verified agent ID instead: withVerifiedActor forwards verifiedActor (MASTER_ACTOR_CLAIM_DOORS) only for a master scope and only when no verifiedOrg rides the call, so the door judges it as an operator-organisation agent, and a master with no agent ID forwards no claim and is refused by the door (claimless-service-account); a client-organisation seat is never sent an actor; the door resolves the assignee in the claimed organisation only and serves the caller's visible tasks (tasks k176p84j83gac7reyycweacyb58jvtxg, k178q6x954qeh4mxh0b4x6sss98jtarn)",
|
|
5567
5634
|
}, "next_task", "Get the one task an agent should take next: among its todo tasks you may see, the first in queue order (ranked tasks by rank, then unranked by priority and age) whose dependencies are all done. " +
|
|
5568
5635
|
"Name the agent by assignedToAgentId (its agentId, as list_peers returns it) or by assignedTo (its name); one of the two is required. " +
|
|
5569
5636
|
"Returns { found, task?{ _id, _creationTime, title, description?, status, priority, assignedTo, missionId?, queueRank? }, message? }: found is true with the task, or false with a message saying no task is pickable (an empty answer is stated, never silent). " +
|
|
@@ -5593,8 +5660,10 @@ options) {
|
|
|
5593
5660
|
return mcpError("QUEUE_ASSIGNEE_REQUIRED: name the assignee: assignedTo (a name) or assignedToAgentId (an agent ID)");
|
|
5594
5661
|
}
|
|
5595
5662
|
// The organisation is forwarded on EVERY call (doorScopeArgs, verifiedOrg
|
|
5596
|
-
// always): without it the backend would resolve
|
|
5597
|
-
// master. A bearer with no resolvable
|
|
5663
|
+
// always for a bearer that resolves one): without it the backend would resolve
|
|
5664
|
+
// the caller as the fleet master. A non-master bearer with no resolvable
|
|
5665
|
+
// organisation is refused here; the master is claimed by its verified agent ID
|
|
5666
|
+
// (withVerifiedActor, MASTER_ACTOR_CLAIM_DOORS), never by a verifiedOrg.
|
|
5598
5667
|
const orgDenied = unresolvedOrgDenial("next_task");
|
|
5599
5668
|
if (orgDenied)
|
|
5600
5669
|
return orgDenied;
|
|
@@ -5605,7 +5674,14 @@ options) {
|
|
|
5605
5674
|
...(assignedToAgentId !== undefined ? { assignedToAgentId } : {}),
|
|
5606
5675
|
...doorScopeArgs("tasks:nextForAssignee", undefined),
|
|
5607
5676
|
}));
|
|
5608
|
-
|
|
5677
|
+
// The door answers { found: true, task } or { found: false }; anything
|
|
5678
|
+
// else is a contract break, not an empty queue.
|
|
5679
|
+
if (!isPlainObject(result) ||
|
|
5680
|
+
typeof result.found !== "boolean" ||
|
|
5681
|
+
(result.found === true && !isPlainObject(result.task))) {
|
|
5682
|
+
return mcpBackendShapeMismatch("next_task", "tasks:nextForAssignee", "{ found: true, task } or { found: false }");
|
|
5683
|
+
}
|
|
5684
|
+
const structured = result.found === true
|
|
5609
5685
|
? { found: true, task: result.task }
|
|
5610
5686
|
: {
|
|
5611
5687
|
found: false,
|
|
@@ -5694,9 +5770,8 @@ options) {
|
|
|
5694
5770
|
// `tenantRows` is the page after the tenant gate: only these rows are
|
|
5695
5771
|
// attributable to the caller's own organisation, so only their
|
|
5696
5772
|
// removals by the allow-list below are counted as `scopeFiltered`.
|
|
5697
|
-
const
|
|
5698
|
-
|
|
5699
|
-
: []);
|
|
5773
|
+
const missionTaskRows = requireRows(tasks, "list_tasks_by_mission", "tasks:listByMission", "an array of tasks");
|
|
5774
|
+
const tenantRows = filterRowsToActorTenant(oauthCtx, missionTaskRows);
|
|
5700
5775
|
const scopedRows = scopeFilterList(oauthCtx ?? DENIED_SCOPE_CTX, tenantRows, ["assignedTo"]);
|
|
5701
5776
|
// The gate needs `orgId`, which the lite projection strips, so a
|
|
5702
5777
|
// gated caller is served full rows internally and reprojected to the
|
|
@@ -5717,7 +5792,7 @@ options) {
|
|
|
5717
5792
|
// S3.3 B8 follow-up — emit nextCursor when page is full.
|
|
5718
5793
|
// Measured on the RAW page, before the scope filter narrowed it.
|
|
5719
5794
|
const requestedLimit = effectiveLimit ?? 20;
|
|
5720
|
-
const { nextCursor, scopeFiltered } = scopedPageContinuation(
|
|
5795
|
+
const { nextCursor, scopeFiltered } = scopedPageContinuation(missionTaskRows, requestedLimit, filteredTasks.length, {
|
|
5721
5796
|
inTenantCount: tenantRows.length,
|
|
5722
5797
|
reportRemoved: oauthCtx?.clerkOrgSlug !== undefined,
|
|
5723
5798
|
});
|
|
@@ -5883,7 +5958,7 @@ options) {
|
|
|
5883
5958
|
});
|
|
5884
5959
|
// S3.3 B8 follow-up — emit nextCursor when page is full.
|
|
5885
5960
|
const requestedLimit = effectiveLimit ?? 20;
|
|
5886
|
-
const missionsArr =
|
|
5961
|
+
const missionsArr = requireRows(missions, "list_missions", "missions:list", "an array of missions");
|
|
5887
5962
|
let nextCursor = null;
|
|
5888
5963
|
if (missionsArr.length >= requestedLimit && missionsArr.length > 0) {
|
|
5889
5964
|
const last = missionsArr[missionsArr.length - 1];
|
|
@@ -6303,10 +6378,8 @@ options) {
|
|
|
6303
6378
|
? entries
|
|
6304
6379
|
: null;
|
|
6305
6380
|
const entriesArr = partial
|
|
6306
|
-
? partial
|
|
6307
|
-
:
|
|
6308
|
-
? entries
|
|
6309
|
-
: [];
|
|
6381
|
+
? requireItems(partial, "list_diaries", "diary:list")
|
|
6382
|
+
: requireRows(entries, "list_diaries", "diary:list", "an array of diary entries, or a partial page { items: array, nextCreatedBefore }");
|
|
6310
6383
|
let nextCursor = null;
|
|
6311
6384
|
if (partial) {
|
|
6312
6385
|
nextCursor = encodeCursor({ createdBefore: partial.nextCreatedBefore });
|
|
@@ -6625,7 +6698,7 @@ options) {
|
|
|
6625
6698
|
if (isRefusedEnvelope(notes)) {
|
|
6626
6699
|
return mcpRefused("list_briefing_notes", "briefingNotes:list");
|
|
6627
6700
|
}
|
|
6628
|
-
const rawNotes =
|
|
6701
|
+
const rawNotes = requireRows(notes, "list_briefing_notes", "briefingNotes:list", "an array of notes");
|
|
6629
6702
|
const scopeFiltered = new Set(scopeFilterList(oauthCtx ?? DENIED_SCOPE_CTX, rawNotes));
|
|
6630
6703
|
const filteredNotes = rawNotes.filter((n) => scopeFiltered.has(n) ||
|
|
6631
6704
|
passesBriefingNoteParticipantScope(oauthCtx, n));
|
|
@@ -6761,7 +6834,7 @@ options) {
|
|
|
6761
6834
|
// on lite results too, see convex/briefingNotes.ts) instead of
|
|
6762
6835
|
// trusting Convex's decision blindly — real defense-in-depth,
|
|
6763
6836
|
// same posture Day 141 relied on for tenant isolation here.
|
|
6764
|
-
const rawResults =
|
|
6837
|
+
const rawResults = requireRows(results, "search_briefing_notes_by_keyword", "briefingNotes:searchBriefingNotesByKeyword", "an array of notes");
|
|
6765
6838
|
const scopeFiltered = new Set(scopeFilterList(oauthCtx ?? DENIED_SCOPE_CTX, rawResults));
|
|
6766
6839
|
const filteredResults = rawResults.filter((r) => scopeFiltered.has(r) ||
|
|
6767
6840
|
passesBriefingNoteParticipantScope(oauthCtx, r));
|
|
@@ -6895,11 +6968,12 @@ options) {
|
|
|
6895
6968
|
fields: "lite",
|
|
6896
6969
|
createdBefore,
|
|
6897
6970
|
});
|
|
6898
|
-
const
|
|
6971
|
+
const recurringRows = requireRows(tasks, "list_recurring_tasks", "recurringTasks:list", "an array of recurring tasks");
|
|
6972
|
+
const filteredTasks = scopeFilterList(oauthCtx ?? DENIED_SCOPE_CTX, recurringRows);
|
|
6899
6973
|
// S3.3 B8 follow-up — emit nextCursor when page is full.
|
|
6900
6974
|
// Measured on the RAW page, before the scope filter narrowed it.
|
|
6901
6975
|
const requestedLimit = effectiveLimit ?? 20;
|
|
6902
|
-
const { nextCursor, scopeFiltered } = scopedPageContinuation(
|
|
6976
|
+
const { nextCursor, scopeFiltered } = scopedPageContinuation(recurringRows, requestedLimit, filteredTasks.length, { reportRemoved: oauthCtx?.clerkOrgSlug !== undefined });
|
|
6903
6977
|
const tasksWithCursor = nextCursor !== null || scopeFiltered > 0
|
|
6904
6978
|
? {
|
|
6905
6979
|
items: filteredTasks,
|
|
@@ -7501,7 +7575,7 @@ options) {
|
|
|
7501
7575
|
// 0.5.0's `grantFields` declares both as per-row grants directly —
|
|
7502
7576
|
// no createdBy-remap + union-by-_id workaround needed: either
|
|
7503
7577
|
// party to the mandate is a named grantee, consulted in one pass.
|
|
7504
|
-
const mandateRows =
|
|
7578
|
+
const mandateRows = requireRows(mandates, "list_mandates", "mandates:list", "an array of mandates");
|
|
7505
7579
|
const filteredMandates = scopeFilterList(oauthCtx ?? DENIED_SCOPE_CTX, mandateRows, ["requestedBy", "fulfilledBy"]);
|
|
7506
7580
|
// S3.3 B8 follow-up — emit nextCursor when page is full.
|
|
7507
7581
|
// Measured on the RAW page, before the scope filter narrowed it.
|
|
@@ -7797,11 +7871,7 @@ options) {
|
|
|
7797
7871
|
createdBefore,
|
|
7798
7872
|
...doorScopeArgs("businessUnits:list", undefined),
|
|
7799
7873
|
});
|
|
7800
|
-
const rawItems = (envelope
|
|
7801
|
-
? envelope.items
|
|
7802
|
-
: Array.isArray(envelope)
|
|
7803
|
-
? envelope
|
|
7804
|
-
: []);
|
|
7874
|
+
const rawItems = requireItems(envelope, "list_bus", "businessUnits:list");
|
|
7805
7875
|
const backendNextCursor = envelope && typeof envelope === "object" && "nextCursor" in envelope
|
|
7806
7876
|
? envelope.nextCursor
|
|
7807
7877
|
: null;
|
|
@@ -8028,11 +8098,7 @@ options) {
|
|
|
8028
8098
|
createdBefore,
|
|
8029
8099
|
...doorScopeArgs("githubRepoMapping:list", undefined),
|
|
8030
8100
|
});
|
|
8031
|
-
const rawItems = (envelope
|
|
8032
|
-
? envelope.items
|
|
8033
|
-
: Array.isArray(envelope)
|
|
8034
|
-
? envelope
|
|
8035
|
-
: []);
|
|
8101
|
+
const rawItems = requireItems(envelope, "list_repo_mappings", "githubRepoMapping:list");
|
|
8036
8102
|
const backendNextCursor = envelope && typeof envelope === "object" && "nextCursor" in envelope
|
|
8037
8103
|
? envelope.nextCursor
|
|
8038
8104
|
: null;
|
|
@@ -8201,10 +8267,14 @@ options) {
|
|
|
8201
8267
|
: undefined;
|
|
8202
8268
|
// The same object is the text (unchanged) and the structuredContent the
|
|
8203
8269
|
// outputSchema validates (task k1793xkjhzh1xm23gmmwjgwfyx8htbv0).
|
|
8270
|
+
const bindingItems = requireItems(isPlainObject(bindingsPage) ? bindingsPage : null, "get_github_owner_bindings", "githubOwnerBinding:listBindings");
|
|
8271
|
+
const unprovenItems = unprovenPage === undefined
|
|
8272
|
+
? undefined
|
|
8273
|
+
: requireItems(isPlainObject(unprovenPage) ? unprovenPage : null, "get_github_owner_bindings", "githubOwnerBinding:listUnprovenMappings");
|
|
8204
8274
|
const structured = {
|
|
8205
|
-
bindings:
|
|
8275
|
+
bindings: bindingItems,
|
|
8206
8276
|
nextCursor: opaque(bindingsPage.nextCursor),
|
|
8207
|
-
unprovenMappings:
|
|
8277
|
+
unprovenMappings: unprovenItems,
|
|
8208
8278
|
unprovenNextCursor: opaque(unprovenPage?.nextCursor),
|
|
8209
8279
|
};
|
|
8210
8280
|
return {
|
|
@@ -8330,7 +8400,8 @@ options) {
|
|
|
8330
8400
|
createdBefore,
|
|
8331
8401
|
});
|
|
8332
8402
|
}
|
|
8333
|
-
const
|
|
8403
|
+
const issueRows = requireRows(results, "list_issues", "issues:listBy*", "an array of issues");
|
|
8404
|
+
const filteredIssues = scopeFilterList(oauthCtx ?? DENIED_SCOPE_CTX, issueRows);
|
|
8334
8405
|
// S3.3 B8 follow-up — emit nextCursor when page is full.
|
|
8335
8406
|
let nextCursor = null;
|
|
8336
8407
|
if (filteredIssues.length >= requestedLimit &&
|
|
@@ -8754,7 +8825,8 @@ options) {
|
|
|
8754
8825
|
limit: limit ?? 20,
|
|
8755
8826
|
fields: fields ?? "lite",
|
|
8756
8827
|
});
|
|
8757
|
-
const
|
|
8828
|
+
const patternRows = requireRows(results, "search_fix_patterns", "search:searchFixPatterns", "an array of fix patterns");
|
|
8829
|
+
const filteredResults = scopeFilterList(oauthCtx ?? DENIED_SCOPE_CTX, patternRows);
|
|
8758
8830
|
const capped = capPage(filteredResults, "search_fix_patterns", "array");
|
|
8759
8831
|
return {
|
|
8760
8832
|
content: [
|
|
@@ -8838,7 +8910,8 @@ options) {
|
|
|
8838
8910
|
fields: "lite",
|
|
8839
8911
|
createdBefore,
|
|
8840
8912
|
});
|
|
8841
|
-
const
|
|
8913
|
+
const projectRows = requireRows(results, "list_fix_patterns", "fixPatterns:listByProject", "an array of fix patterns");
|
|
8914
|
+
const filteredResults = scopeFilterList(oauthCtx ?? DENIED_SCOPE_CTX, projectRows);
|
|
8842
8915
|
const payload = buildPayload(filteredResults);
|
|
8843
8916
|
const capped = capPage(payload, "list_fix_patterns");
|
|
8844
8917
|
return {
|
|
@@ -8851,7 +8924,8 @@ options) {
|
|
|
8851
8924
|
fields: "lite",
|
|
8852
8925
|
createdBefore,
|
|
8853
8926
|
});
|
|
8854
|
-
const
|
|
8927
|
+
const allRows = requireRows(allResults, "list_fix_patterns", "fixPatterns:listAll", "an array of fix patterns");
|
|
8928
|
+
const filteredAll = scopeFilterList(oauthCtx ?? DENIED_SCOPE_CTX, allRows);
|
|
8855
8929
|
const payload = buildPayload(filteredAll);
|
|
8856
8930
|
const capped = capPage(payload, "list_fix_patterns");
|
|
8857
8931
|
return {
|
|
@@ -9299,7 +9373,7 @@ options) {
|
|
|
9299
9373
|
fields: fields ?? "lite",
|
|
9300
9374
|
createdBefore,
|
|
9301
9375
|
});
|
|
9302
|
-
const filteredErrors =
|
|
9376
|
+
const filteredErrors = requireRows(errors, "list_errors", "errorMonitor:listErrors", "an array of errors");
|
|
9303
9377
|
// S3.3 B8 follow-up — emit nextCursor when page is full.
|
|
9304
9378
|
const requestedLimit = effectiveLimit ?? 20;
|
|
9305
9379
|
let nextCursor = null;
|
|
@@ -9407,7 +9481,10 @@ options) {
|
|
|
9407
9481
|
...(caller !== undefined ? { caller } : {}),
|
|
9408
9482
|
...reader.args,
|
|
9409
9483
|
});
|
|
9410
|
-
|
|
9484
|
+
if (!Array.isArray(rows)) {
|
|
9485
|
+
return mcpBackendShapeMismatch("get_tool_usage", "toolUsage:getToolUsage", "an array of usage rows");
|
|
9486
|
+
}
|
|
9487
|
+
const capped = capPage(rows, "get_tool_usage", "array");
|
|
9411
9488
|
return {
|
|
9412
9489
|
content: [
|
|
9413
9490
|
{ type: "text", text: capped.text },
|
|
@@ -9456,7 +9533,10 @@ options) {
|
|
|
9456
9533
|
const rows = await convex.query(
|
|
9457
9534
|
// biome-ignore lint/suspicious/noExplicitAny: Convex string API
|
|
9458
9535
|
"toolUsage:usageByOwner", { ownerUserId, ...reader.args });
|
|
9459
|
-
|
|
9536
|
+
if (!Array.isArray(rows)) {
|
|
9537
|
+
return mcpBackendShapeMismatch("get_owner_tool_usage", "toolUsage:usageByOwner", "an array of usage rows");
|
|
9538
|
+
}
|
|
9539
|
+
const capped = capPageMirrored(rows, "get_owner_tool_usage", "array");
|
|
9460
9540
|
return {
|
|
9461
9541
|
// The text is the structuredContent as JSON (capPageMirrored).
|
|
9462
9542
|
content: [{ type: "text", text: capped.text }],
|
|
@@ -17,13 +17,28 @@
|
|
|
17
17
|
// Pattern: Estimated: N or Estimated N ... // allow-time-estimate: pattern-definition-file
|
|
18
18
|
const ESTIMATE_PATTERNS = [
|
|
19
19
|
{ re: /estimated?\s*:?\s*[~\d]/i, idx: 0 }, // allow-time-estimate: pattern-definition-file
|
|
20
|
-
{
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
{
|
|
21
|
+
re: /\b\d+\s*[-à]\s*\d+\s*(jour|jours|heure|heures|h|min|mn|mins|minutes|heures?|hours?)\b/i,
|
|
22
|
+
idx: 1,
|
|
23
|
+
}, // allow-time-estimate: pattern-definition-file
|
|
24
|
+
{
|
|
25
|
+
re: /~\s*\d+\s*\.?\d*\s*(min|mn|mins|minute|minutes|h|hour|hours|jour|jours|heure|heures|day|days)\b/i,
|
|
26
|
+
idx: 2,
|
|
27
|
+
}, // allow-time-estimate: pattern-definition-file
|
|
28
|
+
{
|
|
29
|
+
re: /\b\d+\s*\.?\d*\s*(min|mn|h|jour|jours|heure|heures|hour|hours|day|days)\s+(max|env|environ|approx|approximately)\b/i,
|
|
30
|
+
idx: 3,
|
|
31
|
+
}, // allow-time-estimate: pattern-definition-file
|
|
23
32
|
{ re: /\bETA\s*:?\s*\d/, idx: 4 }, // allow-time-estimate: pattern-definition-file (case-sensitive — Eta proper noun exempted)
|
|
24
|
-
{
|
|
33
|
+
{
|
|
34
|
+
re: /\b\d+\s*\.?\d*\s*(?:min|mn|h|jour|jours|heure|heures|hour|hours|day|days)\s+de\s+(dev|revue|review|test|debug|coding|recherche|research|investigation|setup|implem|impl|implementation)/i,
|
|
35
|
+
idx: 5,
|
|
36
|
+
}, // allow-time-estimate: pattern-definition-file
|
|
25
37
|
{ re: /^#+\s*estimated?\s*$/im, idx: 6 }, // allow-time-estimate: pattern-definition-file
|
|
26
|
-
{
|
|
38
|
+
{
|
|
39
|
+
re: /\b(?:effort|temps|time|durée|duration)\s*(?:estimé?|estimated?|prévu?|expected?)\s*:?\s*[~\d]/i,
|
|
40
|
+
idx: 7,
|
|
41
|
+
}, // allow-time-estimate: pattern-definition-file
|
|
27
42
|
];
|
|
28
43
|
// Backward-context exemption for range pattern (idx=1)
|
|
29
44
|
const RANGE_BACKWARD_CONTEXT_RE = /\b(?:créneau|creneau|window|shift|meeting|réunion|reunion|call|appel|slot|interval|range|history|past|hier|aujourd'hui|today|yesterday|il\s+y\s+a|duré|a\s+pris|took|lasted|spent)\b/i;
|
|
@@ -80,7 +80,11 @@ function checkVerificationTests(description, acc) {
|
|
|
80
80
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
81
81
|
// Axis: delegation triplet (hard-block when partial)
|
|
82
82
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
83
|
-
const DELEGATION_KEYS = [
|
|
83
|
+
const DELEGATION_KEYS = [
|
|
84
|
+
"subagent_type",
|
|
85
|
+
"run_in_background",
|
|
86
|
+
"model",
|
|
87
|
+
];
|
|
84
88
|
function checkDelegationTriplet(description, acc) {
|
|
85
89
|
// Skip if [META] tag present (orchestrator meta-tasks exempt from delegation rules)
|
|
86
90
|
if (/\[META\]/i.test(description))
|
|
@@ -302,7 +306,8 @@ function dispatchCompleteTask(payload, acc) {
|
|
|
302
306
|
if (noteOk) {
|
|
303
307
|
checkFriction(note, acc);
|
|
304
308
|
}
|
|
305
|
-
else if (note.trim().length >= 40 &&
|
|
309
|
+
else if (note.trim().length >= 40 &&
|
|
310
|
+
!acc.errors.some((e) => e.field === "completionNote.evidence")) {
|
|
306
311
|
checkFriction(note, acc);
|
|
307
312
|
}
|
|
308
313
|
}
|
|
@@ -15,6 +15,18 @@ export declare const VERIFIED_ACTOR_DOORS: ReadonlySet<string>;
|
|
|
15
15
|
* its own rows (task k17a388w6d0cxmyw8gfk5tryp18hvw2k).
|
|
16
16
|
*/
|
|
17
17
|
export declare const MASTER_UNNARROWED_DOORS: ReadonlySet<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Doors that admit a `verifiedActor` ONLY from the operator organisation
|
|
20
|
+
* (requireFleetAgentActor behind requireClaimedCaller) and take the organisation of
|
|
21
|
+
* every other caller as `verifiedOrg` (doorScope). The actor is the claim of the
|
|
22
|
+
* caller that has NO `verifiedOrg`: the fleet master, whose bearer resolves no
|
|
23
|
+
* organisation, so the door would otherwise refuse it as a claimless service account
|
|
24
|
+
* (RBAC_DENIED claimless-service-account). It is forwarded for a master scope only,
|
|
25
|
+
* and only when no `verifiedOrg` rides the call, so a client-organisation seat (served
|
|
26
|
+
* by verifiedOrg) is never sent an actor the door would refuse, and the two claims
|
|
27
|
+
* never travel together. Every door here is pinned in test/next-task-claim.test.ts.
|
|
28
|
+
*/
|
|
29
|
+
export declare const MASTER_ACTOR_CLAIM_DOORS: ReadonlySet<string>;
|
|
18
30
|
export type VerifiedActorArg = {
|
|
19
31
|
agentId: string;
|
|
20
32
|
orgSlug: string;
|
|
@@ -37,10 +37,7 @@ export const VERIFIED_ACTOR_DOORS = new Set([
|
|
|
37
37
|
"tasks:checkout",
|
|
38
38
|
"tasks:deleteTask",
|
|
39
39
|
"tasks:blockTask",
|
|
40
|
-
// The queue write door: the caller is judged by its verified agent ID.
|
|
41
|
-
// deliberately NOT here: it admits a verifiedActor only as an agent of the operator
|
|
42
|
-
// organisation (requireFleetAgentActor), so a client-organisation seat is served by
|
|
43
|
-
// verifiedOrg alone (doorScope), never refused for carrying an actor.
|
|
40
|
+
// The queue write door: the caller is judged by its verified agent ID.
|
|
44
41
|
"tasks:reorderQueue",
|
|
45
42
|
"tasks:bulkComplete",
|
|
46
43
|
// The briefing-note doors (module M10c): the author of a note, and the editor
|
|
@@ -127,6 +124,20 @@ export const VERIFIED_ACTOR_DOORS = new Set([
|
|
|
127
124
|
export const MASTER_UNNARROWED_DOORS = new Set([
|
|
128
125
|
"fixPatterns:get",
|
|
129
126
|
]);
|
|
127
|
+
/**
|
|
128
|
+
* Doors that admit a `verifiedActor` ONLY from the operator organisation
|
|
129
|
+
* (requireFleetAgentActor behind requireClaimedCaller) and take the organisation of
|
|
130
|
+
* every other caller as `verifiedOrg` (doorScope). The actor is the claim of the
|
|
131
|
+
* caller that has NO `verifiedOrg`: the fleet master, whose bearer resolves no
|
|
132
|
+
* organisation, so the door would otherwise refuse it as a claimless service account
|
|
133
|
+
* (RBAC_DENIED claimless-service-account). It is forwarded for a master scope only,
|
|
134
|
+
* and only when no `verifiedOrg` rides the call, so a client-organisation seat (served
|
|
135
|
+
* by verifiedOrg) is never sent an actor the door would refuse, and the two claims
|
|
136
|
+
* never travel together. Every door here is pinned in test/next-task-claim.test.ts.
|
|
137
|
+
*/
|
|
138
|
+
export const MASTER_ACTOR_CLAIM_DOORS = new Set([
|
|
139
|
+
"tasks:nextForAssignee",
|
|
140
|
+
]);
|
|
130
141
|
/**
|
|
131
142
|
* The acting agent's ID and org for this request, or undefined.
|
|
132
143
|
*
|
|
@@ -163,7 +174,13 @@ export function withVerifiedActor(convex, ctx) {
|
|
|
163
174
|
return convex;
|
|
164
175
|
const master = isMasterScope(ctx);
|
|
165
176
|
const forward = (name, args) => {
|
|
166
|
-
|
|
177
|
+
const masterActorClaim = MASTER_ACTOR_CLAIM_DOORS.has(name);
|
|
178
|
+
if ((!VERIFIED_ACTOR_DOORS.has(name) && !masterActorClaim) ||
|
|
179
|
+
(masterActorClaim &&
|
|
180
|
+
(!master ||
|
|
181
|
+
typeof args !== "object" ||
|
|
182
|
+
args === null ||
|
|
183
|
+
args.verifiedOrg !== undefined)) ||
|
|
167
184
|
(master && MASTER_UNNARROWED_DOORS.has(name)) ||
|
|
168
185
|
typeof args !== "object" ||
|
|
169
186
|
args === null) {
|
|
@@ -71,7 +71,11 @@ export function deriveOpaqueCallerId(ctx, env) {
|
|
|
71
71
|
*/
|
|
72
72
|
export function resolveActingAgent(ctx, verified) {
|
|
73
73
|
if (!ctx) {
|
|
74
|
-
return {
|
|
74
|
+
return {
|
|
75
|
+
actor: null,
|
|
76
|
+
agent_id: null,
|
|
77
|
+
agent_unresolved_reason: "no-context",
|
|
78
|
+
};
|
|
75
79
|
}
|
|
76
80
|
const seat = !ctx.actor && verified !== undefined
|
|
77
81
|
? {
|
|
@@ -117,7 +121,12 @@ export function resolveActingAgent(ctx, verified) {
|
|
|
117
121
|
}
|
|
118
122
|
export function resolveWhoamiIdentity(ctx, env) {
|
|
119
123
|
if (!ctx) {
|
|
120
|
-
return {
|
|
124
|
+
return {
|
|
125
|
+
caller_id: null,
|
|
126
|
+
org_slug: null,
|
|
127
|
+
role: "legacy",
|
|
128
|
+
acting_name: null,
|
|
129
|
+
};
|
|
121
130
|
}
|
|
122
131
|
let role;
|
|
123
132
|
if (isMasterScope(ctx))
|
package/package.json
CHANGED